[PATCH 1/5] usb: gadget: fastboot: allow to build without BOOTM

Lucas Stach l.stach at pengutronix.de
Mon Dec 15 03:35:16 PST 2014


Am Donnerstag, den 11.12.2014, 08:36 +0100 schrieb Sascha Hauer:
> On Tue, Dec 09, 2014 at 12:05:42PM +0100, Lucas Stach wrote:
> > This will disable the capability to boot an uploaded image directly,
> > but keeps other fastboot functionality. This seems like a valid config.
> > 
> > Fixes:
> > In function `do_bootm_on_complete': undefined reference to `bootm_boot'
> > 
> > Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
> > ---
> >  drivers/usb/gadget/f_fastboot.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
> > index 92a1a218c643..76879db1f15d 100644
> > --- a/drivers/usb/gadget/f_fastboot.c
> > +++ b/drivers/usb/gadget/f_fastboot.c
> > @@ -653,7 +653,8 @@ static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
> >  		pr_err("Booting failed\n");
> >  }
> >  
> > -static void cb_boot(struct usb_ep *ep, struct usb_request *req, const char *opt)
> > +static void __maybe_unused cb_boot(struct usb_ep *ep, struct usb_request *req,
> > +				   const char *opt)
> >  {
> >  	struct f_fastboot *f_fb = req->context;
> >  
> > @@ -857,9 +858,11 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = {
> >  	}, {
> >  		.cmd = "download:",
> >  		.cb = cb_download,
> > +#if defined(CONFIG_BOOTM)
> >  	}, {
> >  		.cmd = "boot",
> >  		.cb = cb_boot,
> > +#endif
> 
> Instead of the #ifdef can we do a:
> 
> 	if (!IS_ENABLED(CONFIG_BOOTM)) {
> 		fastboot_tx_print(f_fb, "FAILCommand not supported");
> 		return;
> 	}
> 
> in cb_boot?
> 
Actually I like they way I did it in this patch better, as it is
explicit about why something is not available. Chasing through the code
just to find out why cb_boot returned early with an error seems like
obfuscation to me. Also it spreads the same error path through 2
functions which isn't nice if we ever have to change something there.

Regards,
Lucas

-- 
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |




More information about the barebox mailing list