Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf8e3d77 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "usb: gadget: f_diag: allocate diag USB channel when not found"

parents 8f6bfe6b 35920526
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -386,9 +386,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;
}
@@ -863,6 +865,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__);

@@ -872,9 +875,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);