Re: [PATCH] usb: Fix linker errors with CONFIG_PM=n

From: Sarah Sharp
Date: Fri Oct 15 2010 - 19:26:39 EST


On Sat, Oct 16, 2010 at 12:23:01AM +0200, Marcin Slusarz wrote:
> On Fri, Oct 15, 2010 at 02:59:15PM -0700, Sarah Sharp wrote:
> > diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
> > index c08928a..93d3bf4 100644
> > --- a/drivers/usb/host/xhci.h
> > +++ b/drivers/usb/host/xhci.h
> > @@ -1405,8 +1405,15 @@ int xhci_init(struct usb_hcd *hcd);
> > int xhci_run(struct usb_hcd *hcd);
> > void xhci_stop(struct usb_hcd *hcd);
> > void xhci_shutdown(struct usb_hcd *hcd);
> > +
> > +#ifdef CONFIG_PM
> > int xhci_suspend(struct xhci_hcd *xhci);
> > int xhci_resume(struct xhci_hcd *xhci, bool hibernated);
> > +#else
> > +#define xhci_suspend NULL
> > +#define xhci_resume NULL
> > +#endif
> > +
>
> "static inline int xhci_suspend(struct xhci_hcd *) {}"
> has the same effect but saves types

That doesn't have the same effect. Since those functions are only used
as function pointers, the original patch compiles to less code when
CONFIG_PM=n. Also, the original version will cause an oops if those
functions are ever called when CONFIG_PM=n, which would indicate a bug
in the callee (something we would rather catch anyway). This is the
style that other USB host controller drivers use, like EHCI.

I don't understand what you mean by "saves types". Is there something
I've missed?

Sarah Sharp
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/