mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michał Nazarewicz" <m.nazarewicz@samsung.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: Re: [PATCH 2/3] usb gadget: don't save bind callback in struct usb_composite_driver
Date: Mon, 09 Aug 2010 17:36:47 +0200	[thread overview]
Message-ID: <op.vg6gblz87p4s8u@pikus> (raw)
In-Reply-To: <20100809152010.GE27747@pengutronix.de>

> On Mon, Aug 09, 2010 at 03:33:49PM +0200, Michal Nazarewicz wrote:
>> The bind function is most of the time only called at init time so there
>> is no need to save a pointer to it in the composite driver structure.
>>
>> This fixes many section mismatches reported by modpost.

>> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
>> --- a/drivers/usb/gadget/composite.c
>> +++ b/drivers/usb/gadget/composite.c
>> @@ -39,6 +39,7 @@
>>  #define USB_BUFSIZ	1024
>>
>>  static struct usb_composite_driver *composite;
>> +static int (*composite_gadget_bind)(struct usb_composite_dev *cdev);

On Mon, 09 Aug 2010 17:20:10 +0200, Uwe Kleine-König wrote:
> This can be __initdata, can't it?

No.  g_ffs.c uses usb_composite_probe() not only in init so neither
usb_composite_probe() nor this new variable can be in init section.

> I thought about usb_composite_drivers, too, and wondered if it would be
> sensible to change the additional argument of usb_gadget_probe_driver to
> struct usb_gadget_probe_data *probe_data.  Then you could do the
> following
>
> 	struct usb_composite_probe_data {
> 		struct usb_gadget_probe_data usb_probe_data;
> 		int (*composite_gadget_bind)(struct usb_composite_dev *);
> 	}
>
> and in composite_bind use container_of to get the gadget_bind function.

Yes, this seems sensible, however I'm not sure if it's worth the effort.
Note that the whole gadget API is designed in a way that there can be
only one gadget registered so that passing private data with
usb_gadget_probe_driver() as well as with usb_composite_probe() is not
really crucial and we can manage with global variables.

> Maybe that's overengineered though.  As there is already a dependency on
> a global variable (i.e. composite) your patch doesn't make it much
> worse.  Just my 0.02€.

Yep, that was my reasoning as well.

I guess we'll have to worry about it when (if) boards with many UDCs
became common. ;)

-- 
Best regards,                                        _     _
| Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
| Computer Science,  Michał "mina86" Nazarewicz       (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--

      reply	other threads:[~2010-08-09 15:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-09 13:33 [PATCH 1/3] usb gadget: don't save bind callback in struct usb_gadget_driver Michal Nazarewicz
2010-08-09 13:33 ` [PATCH 2/3] usb gadget: don't save bind callback in struct usb_composite_driver Michal Nazarewicz
2010-08-09 13:33   ` [PATCH 3/3] usb gadget: don't save bind callback in struct usb_configuration Michal Nazarewicz
2010-08-09 15:20   ` [PATCH 2/3] usb gadget: don't save bind callback in struct usb_composite_driver Uwe Kleine-König
2010-08-09 15:36     ` Michał Nazarewicz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=op.vg6gblz87p4s8u@pikus \
    --to=m.nazarewicz@samsung.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®