[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALAqxLWZTevNPxBKBOGm2yMtevDkGXXninDGdZYj2qitFohvPw@mail.gmail.com>
Date: Thu, 7 Nov 2019 14:23:20 -0800
From: John Stultz <john.stultz@...aro.org>
To: Felipe Balbi <balbi@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
ShuFan Lee <shufan_lee@...htek.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Suzuki K Poulose <suzuki.poulose@....com>,
Chunfeng Yun <chunfeng.yun@...iatek.com>,
Yu Chen <chenyu56@...wei.com>,
Hans de Goede <hdegoede@...hat.com>,
Andy Shevchenko <andy.shevchenko@...il.com>,
Jun Li <lijun.kernel@...il.com>,
Valentin Schneider <valentin.schneider@....com>,
Jack Pham <jackp@...eaurora.org>,
Linux USB List <linux-usb@...r.kernel.org>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@...r.kernel.org>
Subject: Re: [PATCH v4 9/9] usb: dwc3: Add host-mode as default support
On Tue, Oct 29, 2019 at 2:25 AM Felipe Balbi <balbi@...nel.org> wrote:
> John Stultz <john.stultz@...aro.org> writes:
> > diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
> > index 61d4fd8aead4..0e3466fe5ac4 100644
> > --- a/drivers/usb/dwc3/drd.c
> > +++ b/drivers/usb/dwc3/drd.c
> > @@ -489,7 +489,10 @@ static int dwc3_usb_role_switch_set(struct device *dev, enum usb_role role)
> > mode = DWC3_GCTL_PRTCAP_DEVICE;
> > break;
> > default:
> > - mode = DWC3_GCTL_PRTCAP_DEVICE;
> > + if (dwc->role_switch_default_mode == USB_DR_MODE_HOST)
> > + mode = DWC3_GCTL_PRTCAP_HOST;
> > + else
> > + mode = DWC3_GCTL_PRTCAP_DEVICE;
> > break;
> > }
> >
> > @@ -515,7 +518,10 @@ static enum usb_role dwc3_usb_role_switch_get(struct device *dev)
> > role = dwc->current_otg_role;
> > break;
> > default:
> > - role = USB_ROLE_DEVICE;
> > + if (dwc->role_switch_default_mode == USB_DR_MODE_HOST)
> > + role = USB_ROLE_HOST;
>
> look at this, we now have 3 different encodings for role which DWC3
> needs to understand. One is its own PRTCAP_DIR, then there USB_DR_MODE_*
> and now USB_ROLE_*, can we make it so that we only have one private
> encoding and one generic encoding?
And you left out the DWC3_OTG_ROLE_* set too!
So I agree it can be easy to muddle up. The enums are *almost* equivalent:
include/linux/usb/role.h:
enum usb_role {
USB_ROLE_NONE,
USB_ROLE_HOST,
USB_ROLE_DEVICE,
};
include/linux/usb/otg.h:
enum usb_dr_mode {
USB_DR_MODE_UNKNOWN,
USB_DR_MODE_HOST,
USB_DR_MODE_PERIPHERAL,
USB_DR_MODE_OTG,
};
But both are widely used:
$ git grep USB_ROLE_ | wc -l
123
$ git grep USB_DR_MODE_ | wc -l
190
So I'm not sure how easy it will be to condense down, since the usage
is coming from different usb subsystems (otg and role switching) and
I worry assuming them equivalent in just one driver may run into
trouble eventually if the values diverge (ie someone adds
USB_ROLE_BRICK or something).
Heikki/Greg: Any thoughts on this? Does it make sense to try to drop
the usb_role enum and users and replace it with usb_dr_mode?
thanks
-john
Powered by blists - more mailing lists