From: Greg KH <greg@kroah.com>
To: Michal Nazarewicz <mnazarewicz@google.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
Felipe Balbi <balbi@ti.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Yang Rui Rui <ruirui.r.yang@tieto.com>,
Dave Young <hidave.darkstar@gmail.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCHv5 1/4] usb: Provide usb_speed_string() function
Date: Fri, 26 Aug 2011 11:07:34 -0700 [thread overview]
Message-ID: <20110826180734.GA24226@kroah.com> (raw)
In-Reply-To: <6ffc8c43e9d3fbef765329f0760fb236d20b585a.1314364323.git.mina86@mina86.com>
On Fri, Aug 26, 2011 at 03:18:34PM +0200, Michal Nazarewicz wrote:
> From: Michal Nazarewicz <mina86@mina86.com>
>
> In a few places in the kernel, the code prints
> a human-readable USB device speed (eg. "high speed").
> This involves a switch statement sometimes wrapped
> around in ({ ... }) block leading to code repetition.
>
> To mitigate this issue, this commit introduces
> usb_speed_string() function, which returns
> a human-readable name of provided speed.
>
> It also changes a few places switch was used to use
> this new function. This changes a bit the way the
> speed is printed in few instances at the same time
> standardising it.
> ---
> drivers/usb/Makefile | 2 +
> drivers/usb/common.c | 24 ++++++++++++++++
> drivers/usb/core/hub.c | 27 ++++++------------
> drivers/usb/gadget/amd5536udc.c | 9 +----
> drivers/usb/gadget/atmel_usba_udc.c | 9 ++---
> drivers/usb/gadget/composite.c | 22 ++------------
> drivers/usb/gadget/file_storage.c | 15 ++-------
> drivers/usb/gadget/fsl_udc_core.c | 53 ++++++++++++----------------------
> drivers/usb/gadget/gmidi.c | 11 +------
> drivers/usb/gadget/langwell_udc.c | 50 +++++++++++---------------------
> drivers/usb/gadget/net2272.c | 4 +-
> drivers/usb/gadget/net2280.c | 4 +--
> drivers/usb/gadget/printer.c | 14 ++-------
> drivers/usb/gadget/s3c-hsotg.c | 8 +----
> drivers/usb/gadget/udc-core.c | 19 +-----------
> drivers/usb/misc/usbtest.c | 21 +------------
> include/linux/usb/ch9.h | 12 ++++++++
> 17 files changed, 109 insertions(+), 195 deletions(-)
> create mode 100644 drivers/usb/common.c
>
> diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
> index 969b0a5..2d5af21 100644
> --- a/drivers/usb/Makefile
> +++ b/drivers/usb/Makefile
> @@ -53,3 +53,5 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb/
> obj-$(CONFIG_USB_RENESAS_USBHS) += renesas_usbhs/
> obj-$(CONFIG_USB_OTG_UTILS) += otg/
> obj-$(CONFIG_USB_GADGET) += gadget/
> +
> +obj-$(CONFIG_USB_SUPPORT) += common.o
You just built this into the kernel, which while ok for some things,
might not be what some people want.
Please make this into a separate module if people are building the usb
code as modules, usb_common.ko perhaps?
> diff --git a/drivers/usb/common.c b/drivers/usb/common.c
> new file mode 100644
> index 0000000..2f6627c
> --- /dev/null
> +++ b/drivers/usb/common.c
> @@ -0,0 +1,24 @@
> +/*
> + * Provides code common for host and device side USB.
> + */
> +
> +#include <linux/kernel.h> /* for ARRAY_SIZE() */
> +#include <linux/module.h> /* for EXPORT_SYMBOL_GPL() */
No need for the "/* for ... */" lines, we all know what this is for.
> --- a/include/linux/usb/ch9.h
> +++ b/include/linux/usb/ch9.h
> @@ -868,6 +868,18 @@ enum usb_device_speed {
> USB_SPEED_SUPER, /* usb 3.0 */
> };
>
> +#ifdef __KERNEL__
> +
> +/**
> + * usb_speed_string() - Returns human readable-name of the speed.
> + * @speed: The speed to return human-readable name for. If it's not
> + * any of the speeds defined in usb_device_speed enum, string for
> + * USB_SPEED_UNKNOWN will be returned.
> + */
> +extern const char *usb_speed_string(enum usb_device_speed speed);
> +
> +#endif
No, this should be in include/linux/usb.h, not ch9.h.
thanks,
greg k-h
next prev parent reply other threads:[~2011-08-26 18:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-26 13:18 [PATCHv5 0/4] Removing USB_GADGET_*SPEED macros Michal Nazarewicz
2011-08-26 13:18 ` [PATCHv5 1/4] usb: Provide usb_speed_string() function Michal Nazarewicz
2011-08-26 18:07 ` Greg KH [this message]
2011-08-26 18:26 ` Alan Stern
2011-08-26 18:34 ` Greg KH
2011-08-26 18:49 ` Alan Stern
2011-08-26 18:57 ` Michal Nazarewicz
2011-08-26 20:46 ` Alan Stern
2011-08-30 15:11 ` [PATCHv5.1 " Michal Nazarewicz
2011-08-26 13:18 ` [PATCHv5 2/4] usb: gadget: replace "is_dualspeed" with "max_speed" Michal Nazarewicz
2011-09-09 14:14 ` Michal Nazarewicz
2011-10-06 9:27 ` Felipe Balbi
2011-10-10 6:02 ` Felipe Balbi
2011-10-10 6:22 ` Dave Young
2011-10-10 7:40 ` Michal Nazarewicz
2011-10-10 7:42 ` Felipe Balbi
2011-08-26 13:18 ` [PATCHv5 3/4] usb: gadget: rename usb_gadget_driver::speed to max_speed Michal Nazarewicz
2011-10-10 6:02 ` Felipe Balbi
2011-08-26 13:18 ` [PATCHv5 4/4] usb: gadget: get rid of USB_GADGET_{DUAL,SUPER}SPEED Michal Nazarewicz
2011-10-10 6:02 ` Felipe Balbi
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=20110826180734.GA24226@kroah.com \
--to=greg@kroah.com \
--cc=balbi@ti.com \
--cc=bigeasy@linutronix.de \
--cc=hidave.darkstar@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mnazarewicz@google.com \
--cc=ruirui.r.yang@tieto.com \
--cc=stern@rowland.harvard.edu \
/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