public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Prashanth K <quic_prashk@quicinc.com>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	AngeloGioacchino Del Regno 
	<angelogioacchino.delregno@collabora.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7] usb: common: usb-conn-gpio: Set last role to unknown before initial detection
Date: Thu, 15 Jun 2023 16:36:19 +0200	[thread overview]
Message-ID: <2023061512-vowed-panther-38ed@gregkh> (raw)
In-Reply-To: <d5561151-08bb-9f5f-aa51-44c5ad31976b@quicinc.com>

On Thu, Jun 15, 2023 at 07:52:32PM +0530, Prashanth K wrote:
> 
> 
> On 15-06-23 03:00 pm, Greg Kroah-Hartman wrote:
> > On Wed, Jun 14, 2023 at 12:14:08PM +0300, Heikki Krogerus wrote:
> > > On Wed, May 31, 2023 at 08:11:14PM +0530, Prashanth K wrote:
> > > > Currently if we bootup a device without cable connected, then
> > > > usb-conn-gpio won't call set_role() since last_role is same as
> > > > current role. This happens because during probe last_role gets
> > > > initialised to zero.
> > > > 
> > > > To avoid this, added a new constant in enum usb_role, last_role
> > > > is set to USB_ROLE_UNKNOWN before performing initial detection.
> > > > 
> > > > While at it, also handle default case for the usb_role switch
> > > > in cdns3, intel-xhci-usb-role-switch & musb/jz4740 to avoid
> > > > build warnings.
> > > > 
> > > > Fixes: 4602f3bff266 ("usb: common: add USB GPIO based connection detection driver")
> > > > Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
> > > > Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> > > > ---
> > > > v7: Added default case in musb/jz4740.c & intel-xhci-usb-role-switch.c to
> > > >      avoid build warnings.
> > > > v6: Moved USB_ROLE_UNKNOWN towards the end of enum usb_role.
> > > > v5: Update commit text to mention the changes made in cdns3 driver.
> > > > v4: Added Reviewed-by tag.
> > > > v3: Added a default case in drivers/usb/cdns3/core.c as pointed out by
> > > >      the test robot.
> > > > v2: Added USB_ROLE_UNKNWON to enum usb_role.
> > > > 
> > > >   drivers/usb/cdns3/core.c                       | 2 ++
> > > >   drivers/usb/common/usb-conn-gpio.c             | 3 +++
> > > >   drivers/usb/musb/jz4740.c                      | 2 ++
> > > >   drivers/usb/roles/intel-xhci-usb-role-switch.c | 2 ++
> > > >   include/linux/usb/role.h                       | 1 +
> > > >   5 files changed, 10 insertions(+)
> > > 
> > > Just to be clear to everybody, that USB_ROLE_UNKNOWN is not handled in
> > > drivers/usb/roles/class.c, so this patch is broken.
> > > 
> > > But the whole approach is wrong. That USB_ROLE_UNKNOWN is clearly a
> > > flag where the other values in enum usb_role are actual switch states.
> > > So it does not belong there.
> > > 
> > > In general, adding globals states like that just in order to work
> > > around issues in single drivers is never a good idea IMO.
> > 
> > Ok, let me go revert this from my tree, thanks for the review.
> > 
> > greg k-h
> 
> In that case, can I resubmit v1 of this patch again, where I have used a
> macro in usb-conn-gpio driver ? something like this.
> 
> @@ -27,6 +27,8 @@
>  #define USB_CONN_IRQF	\
>  	(IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT)
> 
> +#define USB_ROLE_UNKNOWN (USB_ROLE_NONE -1)

Are you referencing an existing enum here and assuming it is a specific
value?

For obvious reasons, that can never work :)

thanks,

greg k-h

  reply	other threads:[~2023-06-15 14:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-31 14:41 [PATCH v7] usb: common: usb-conn-gpio: Set last role to unknown before initial detection Prashanth K
2023-05-31 14:47 ` Prashanth K
2023-06-13  9:58   ` Greg Kroah-Hartman
2023-06-13 11:10 ` Heikki Krogerus
2023-06-14  4:25   ` Prashanth K
2023-06-14  8:36     ` Heikki Krogerus
2023-06-14  9:14 ` Heikki Krogerus
2023-06-15  9:30   ` Greg Kroah-Hartman
2023-06-15 14:22     ` Prashanth K
2023-06-15 14:36       ` Greg Kroah-Hartman [this message]
2023-06-15 14:58         ` Prashanth K
2023-06-15 15:05           ` Greg Kroah-Hartman
2023-06-15 18:11             ` Prashanth K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2023061512-vowed-panther-38ed@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=quic_prashk@quicinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox