Merge "usb: gadget: f_diag: allocate diag USB channel when not found"
This commit is contained in:
commit
f11f069c5f
1 changed files with 18 additions and 5 deletions
|
@ -352,9 +352,11 @@ struct usb_diag_ch *usb_diag_open(const char *name, void *priv,
|
|||
ch->priv = priv;
|
||||
ch->notify = notify;
|
||||
|
||||
if (!found) {
|
||||
spin_lock_irqsave(&ch_lock, flags);
|
||||
list_add_tail(&ch->list, &usb_diag_ch_list);
|
||||
spin_unlock_irqrestore(&ch_lock, flags);
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
@ -828,6 +830,7 @@ static struct diag_context *diag_context_init(const char *name)
|
|||
struct diag_context *dev;
|
||||
struct usb_diag_ch *_ch;
|
||||
int found = 0;
|
||||
unsigned long flags;
|
||||
|
||||
pr_debug("%s\n", __func__);
|
||||
|
||||
|
@ -837,9 +840,19 @@ static struct diag_context *diag_context_init(const char *name)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
pr_err("%s: unable to get diag usb channel\n", __func__);
|
||||
return ERR_PTR(-ENODEV);
|
||||
pr_warn("%s: unable to get diag usb channel\n", __func__);
|
||||
|
||||
_ch = kzalloc(sizeof(*_ch), GFP_KERNEL);
|
||||
if (_ch == NULL)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
_ch->name = name;
|
||||
|
||||
spin_lock_irqsave(&ch_lock, flags);
|
||||
list_add_tail(&_ch->list, &usb_diag_ch_list);
|
||||
spin_unlock_irqrestore(&ch_lock, flags);
|
||||
}
|
||||
|
||||
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
||||
|
|
Loading…
Add table
Reference in a new issue