Re: [PATCH 3/8][v2]usb:fsl:otg: Add support to add/remove usb host driver

From: Felipe Balbi
Date: Mon Aug 10 2015 - 10:36:32 EST


On Fri, Aug 07, 2015 at 04:33:33PM -0400, Alan Stern wrote:
> On Wed, 15 Jul 2015, Ramneek Mehresh wrote:
>
> > Add workqueue to add/remove host driver (outside
> > interrupt context) upon each id change.
> >
> > Signed-off-by: Li Yang <leoli@xxxxxxxxxxxxx>
> > Signed-off-by: Ramneek Mehresh <ramneek.mehresh@xxxxxxxxxxxxx>
> > ---
> > drivers/usb/host/ehci-fsl.c | 83 ++++++++++++++++++++++++++++++++++-----------
> > drivers/usb/host/ehci-fsl.h | 20 +++++++++++
> > 2 files changed, 84 insertions(+), 19 deletions(-)
> >
> > diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> > index 5352e74..81e4bf5 100644
> > --- a/drivers/usb/host/ehci-fsl.c
> > +++ b/drivers/usb/host/ehci-fsl.c
> > @@ -44,6 +44,34 @@
> >
> > static struct hc_driver __read_mostly fsl_ehci_hc_driver;
> >
> > +#if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
>
> You've got these #if lines all over the place. They look ugly and make
> the code hard to read. Consider removing them. Or even if you can't
> remove them entirely, removing most of them would help.
>
> Also, instead of testing both CONFIG_FSL_USB2_OTG and
> CONFIG_FSL_USB2_OTG_MODULE, how about testing a single symbol? For
> example:
>
> #if defined(CONFIG_FSL_USB2_OTG) || defined(CONFIG_FSL_USB2_OTG_MODULE)
> #define CHANGE_HCD 1
> #else
> #define CHANGE_HCD 0
> #endif
>
> Then all you need later on is "#if CHANGE_HCD". Or if it's inside a
> code block, just "if (CHANGE_HCD)".

what about IS_ENABLED() ?

if (IS_ENABLED(CONFIG_FSL_USB2_OTG)) {
foo();
} else {
bar();
}

--
balbi

Attachment: signature.asc
Description: Digital signature