Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754033AbbDHOPh (ORCPT ); Wed, 8 Apr 2015 10:15:37 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:42318 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751672AbbDHOPe (ORCPT ); Wed, 8 Apr 2015 10:15:34 -0400 Date: Wed, 8 Apr 2015 10:15:32 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Krzysztof Opasiak cc: balbi@ti.com, , , , , , , Subject: Re: [PATCH v2 2/4] usb: gadget: mass_storage: Store lun_opts in fsg_opts In-Reply-To: <1428494808-12566-3-git-send-email-k.opasiak@samsung.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1748 Lines: 44 On Wed, 8 Apr 2015, Krzysztof Opasiak wrote: > Signed-off-by: Krzysztof Opasiak > --- > drivers/usb/gadget/function/f_mass_storage.c | 5 +++++ > drivers/usb/gadget/function/f_mass_storage.h | 1 + > 2 files changed, 6 insertions(+) > > diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c > index 811929c..095b618 100644 > --- a/drivers/usb/gadget/function/f_mass_storage.c > +++ b/drivers/usb/gadget/function/f_mass_storage.c > @@ -3372,6 +3372,8 @@ static struct config_group *fsg_lun_make(struct config_group *group, > } > opts->lun = fsg_opts->common->luns[num]; > opts->lun_id = num; > + BUG_ON(fsg_opts->lun_opts[num]); This is not a good idea. BUG_ON should hardly ever be used. In fact, Linus has said that the only time BUG_ON should be used is when things are so badly messed up that it is better to crash the computer than to let it continue. What's wrong with using WARN_ON instead? > diff --git a/drivers/usb/gadget/function/f_mass_storage.h b/drivers/usb/gadget/function/f_mass_storage.h > index b4866fc..0a7c656 100644 > --- a/drivers/usb/gadget/function/f_mass_storage.h > +++ b/drivers/usb/gadget/function/f_mass_storage.h > @@ -81,6 +81,7 @@ struct fsg_opts { > struct fsg_common *common; > struct usb_function_instance func_inst; > struct fsg_lun_opts lun0; > + struct fsg_lun_opts *lun_opts[FSG_MAX_LUNS]; This looks strange. Why is the entry for LUN 0 duplicated? Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/