Re: [PATCH v2] usb: factor out state_string() on otg drivers

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

 



On 5/5/2011 4:45 AM, Anatolij Gustschin wrote:
> Provide common otg_state_string() and use
> it in drivers.
> 
> Signed-off-by: Anatolij Gustschin <agust@xxxxxxx>
> ---
> v2:
>   - factor out otg_state_string() in musb drivers, too.
>     Unfortunately I didn't notice that there is already
>     another otg_state_string() function used in musb
>     drivers, but with different prototype. Therefore,
>     the first patch version will break building musb
>     drivers. Fix this issue by this patch v2.
> 
>  drivers/usb/musb/am35x.c        |   11 ++++--
>  drivers/usb/musb/blackfin.c     |    7 ++--
>  drivers/usb/musb/da8xx.c        |   11 ++++--
>  drivers/usb/musb/davinci.c      |    5 ++-
>  drivers/usb/musb/musb_core.c    |   65 +++++++++++++++------------------------
>  drivers/usb/musb/musb_debug.h   |    2 -
>  drivers/usb/musb/musb_gadget.c  |    9 +++--
>  drivers/usb/musb/musb_host.c    |    2 +-
>  drivers/usb/musb/musb_virthub.c |    5 ++-
>  drivers/usb/musb/omap2430.c     |    7 ++--
>  drivers/usb/musb/tusb6010.c     |   16 +++++----
>  drivers/usb/otg/isp1301_omap.c  |   26 ++--------------
>  drivers/usb/otg/langwell_otg.c  |   40 ++----------------------
>  drivers/usb/otg/otg.c           |   35 +++++++++++++++++++++
>  include/linux/usb/otg.h         |    1 +
>  15 files changed, 110 insertions(+), 132 deletions(-)
>
<snip>
> +
> +const char *otg_state_string(enum usb_otg_state state)
> +{
> +	switch (state) {
> +	case OTG_STATE_A_IDLE:
> +		return "a_idle";
> +	case OTG_STATE_A_WAIT_VRISE:
> +		return "a_wait_vrise";
> +	case OTG_STATE_A_WAIT_BCON:
> +		return "a_wait_bcon";
> +	case OTG_STATE_A_HOST:
> +		return "a_host";
> +	case OTG_STATE_A_SUSPEND:
> +		return "a_suspend";
> +	case OTG_STATE_A_PERIPHERAL:
> +		return "a_peripheral";
> +	case OTG_STATE_A_WAIT_VFALL:
> +		return "a_wait_vfall";
> +	case OTG_STATE_A_VBUS_ERR:
> +		return "a_vbus_err";
> +	case OTG_STATE_B_IDLE:
> +		return "b_idle";
> +	case OTG_STATE_B_SRP_INIT:
> +		return "b_srp_init";
> +	case OTG_STATE_B_PERIPHERAL:
> +		return "b_peripheral";
> +	case OTG_STATE_B_WAIT_ACON:
> +		return "b_wait_acon";
> +	case OTG_STATE_B_HOST:
> +		return "b_host";
> +	default:
> +		return "UNDEFINED";
> +	}
> +}
> +EXPORT_SYMBOL(otg_state_string);
> diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
> index 6e40718..bc84858 100644
> --- a/include/linux/usb/otg.h
> +++ b/include/linux/usb/otg.h
> @@ -246,5 +246,6 @@ otg_unregister_notifier(struct otg_transceiver *otg, struct notifier_block *nb)
>  
>  /* for OTG controller drivers (and maybe other stuff) */
>  extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
> +extern const char *otg_state_string(enum usb_otg_state state);
>  
>  #endif /* __LINUX_USB_OTG_H */

I think you should move otg_state_string() function to under #ifdef
CONFIG_USB_OTG_UTILS block and provide nop if it is not defined.
Otherwise compilation may fail if anyone includes linux/usb/otg.h
without defining CONFIG_USB_OTG_UTILS.

Thanks,
Pavan

-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
--
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