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

Commit dd753cb7 authored by Vamsi Krishna Samavedam's avatar Vamsi Krishna Samavedam Committed by Manoj Prabhu B
Browse files

usb: gadget: diag: Notify cable status while opening channel



Client will miss cable connect notification if USB cable is
already connected before channel is opened. Notify client
through notify callback if usb cable is already connected
when channel is opened.

Change-Id: I5f94cd8c572522edb575d498fa2108c1a5b938c8
Signed-off-by: default avatarVamsi Krishna Samavedam <vskrishn@codeaurora.org>
parent bc44cd2d
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -331,6 +331,8 @@ struct usb_diag_ch *usb_diag_open(const char *name, void *priv,
	struct usb_diag_ch *ch;
	unsigned long flags;
	int found = 0;
	bool connected = false;
	struct diag_context  *dev;

	spin_lock_irqsave(&ch_lock, flags);
	/* Check if we already have a channel with this name */
@@ -358,6 +360,16 @@ struct usb_diag_ch *usb_diag_open(const char *name, void *priv,
		spin_unlock_irqrestore(&ch_lock, flags);
	}

	if (ch->priv_usb) {
		dev = ch->priv_usb;
		spin_lock_irqsave(&dev->lock, flags);
		connected = dev->configured;
		spin_unlock_irqrestore(&dev->lock, flags);
	}

	if (ch->notify && connected)
		ch->notify(priv, USB_DIAG_CONNECT, NULL);

	return ch;
}
EXPORT_SYMBOL(usb_diag_open);