Re: [PATCH 06/41] usb: gadget: add max_speed to usb_composite_driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 28, 2011 at 04:33:51PM +0300, Felipe Balbi wrote:
> From: Tatyana Brokhman <tlinder@xxxxxxxxxxxxxx>
> 
> This field is used by the Gadget drivers to specify
> the maximum speed they support, meaning: the maximum
> speed they can provide descriptors for.
> 
> The driver speed will be set in consideration of this
> value.
> 
> Signed-off-by: Tatyana Brokhman <tlinder@xxxxxxxxxxxxxx>
> Signed-off-by: Felipe Balbi <balbi@xxxxxx>
> ---
>  drivers/usb/gadget/audio.c        |    5 +++++
>  drivers/usb/gadget/cdc2.c         |    5 +++++
>  drivers/usb/gadget/composite.c    |    2 ++
>  drivers/usb/gadget/ether.c        |    5 +++++
>  drivers/usb/gadget/g_ffs.c        |    5 +++++
>  drivers/usb/gadget/hid.c          |    5 +++++
>  drivers/usb/gadget/mass_storage.c |    5 +++++
>  drivers/usb/gadget/multi.c        |    5 +++++
>  drivers/usb/gadget/ncm.c          |    5 +++++
>  drivers/usb/gadget/nokia.c        |    5 +++++
>  drivers/usb/gadget/serial.c       |    5 +++++
>  drivers/usb/gadget/webcam.c       |    5 +++++
>  drivers/usb/gadget/zero.c         |    5 +++++
>  include/linux/usb/composite.h     |    2 ++
>  14 files changed, 64 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c
> index 93b999e..0d7f0ae 100644
> --- a/drivers/usb/gadget/audio.c
> +++ b/drivers/usb/gadget/audio.c
> @@ -165,6 +165,11 @@ static struct usb_composite_driver audio_driver = {
>  	.name		= "g_audio",
>  	.dev		= &device_desc,
>  	.strings	= audio_strings,
> +#ifdef CONFIG_USB_GADGET_DUALSPEED
> +	.max_speed		= USB_SPEED_HIGH,
> +#else
> +	.max_speed		= USB_SPEED_FULL,
> +#endif /* CONFIG_USB_GADGET_DUALSPEED */

Really?

Come on, this is a mess, we don't want #ifdefs in .c files for a reason,
and this is an example of that.

And the comment after the #endif?  That's just useless.

How about a simple new define in a .h file somewhere that sets this
value based on the CONFIG entry:

#ifdef CONFIG_USB_GADGET_DUALSPEED
#define USB_DEFAULT_MAX_SPEED	USB_SPEED_HIGH
#else
#define USB_DEFAULT_MAX_SPEED	USB_SPEED_FULL
#endif

And then just use USB_DEFAULT_MAX_SPEED in the .c files and everyone is
happy and they don't get headaches looking at this code?

Care to fix this up?

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux