* [PATCH v3 0/7] s3c-hsudc: regulator handling and a lot of fixes @ 2011-12-19 13:23 ` Heiko Stübner 0 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:23 UTC (permalink / raw) To: Felipe Balbi, Kukjin Kim, 'Ben Dooks' Cc: linux-arm-kernel, linux-samsung-soc, Linux USB Mailing List, Heiko Stübner In his response to the first submission Felipe Balbi asked to also move the driver to the new udc_start and udc_stop functions and to make an effort to reduce dependencies on archictecture code. v3 of the series does not try to provide a remove function, due to the possible lifetime problem of gadget.dev found by Russel King. The first patch reduces the number of arch dependencies by one by moving the platform data struct to a header unter include/linux/usb. The fourth and fifth patches implement the move to udc_start / udc_stop And the sixt patch finally allows the s3c-hsudc driver to control its supplying regulators as intended in the first place. The regulator calls can use the regulators unconditionally and let necessary "stubbing and mapping" happen through the regulator framework, according to for example http://marc.info/?l=linux-netdev&m=131914562120725&w=2 meaning there is no need to gracefully fail if a regulator is not present. Each patch was compile-tested individually, the series applies cleanly against linux-next from 2011-12-16. Real-life testing happened on S3C2416 hardware. Heiko Stuebner (7): s3c-hsudc: move platform_data struct to global header s3c-hsudc: add __devinit to probe function s3c-hsudc: add missing otg_put_transceiver in probe s3c-hsudc: move device registration to probe s3c-hsudc: use udc_start and udc_stop functions s3c-hsudc: Add regulator handling s3c-hsudc: use release_mem_region instead of release_resource arch/arm/mach-s3c2416/mach-smdk2416.c | 1 + arch/arm/plat-samsung/devs.c | 1 + arch/arm/plat-samsung/include/plat/udc.h | 15 +---- drivers/usb/gadget/s3c-hsudc.c | 109 +++++++++++++++++------------- include/linux/usb/s3c-hsudc.h | 34 +++++++++ 5 files changed, 100 insertions(+), 60 deletions(-) create mode 100644 include/linux/usb/s3c-hsudc.h -- 1.7.5.4 ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH v3 0/7] s3c-hsudc: regulator handling and a lot of fixes @ 2011-12-19 13:23 ` Heiko Stübner 0 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:23 UTC (permalink / raw) To: linux-arm-kernel In his response to the first submission Felipe Balbi asked to also move the driver to the new udc_start and udc_stop functions and to make an effort to reduce dependencies on archictecture code. v3 of the series does not try to provide a remove function, due to the possible lifetime problem of gadget.dev found by Russel King. The first patch reduces the number of arch dependencies by one by moving the platform data struct to a header unter include/linux/usb. The fourth and fifth patches implement the move to udc_start / udc_stop And the sixt patch finally allows the s3c-hsudc driver to control its supplying regulators as intended in the first place. The regulator calls can use the regulators unconditionally and let necessary "stubbing and mapping" happen through the regulator framework, according to for example http://marc.info/?l=linux-netdev&m=131914562120725&w=2 meaning there is no need to gracefully fail if a regulator is not present. Each patch was compile-tested individually, the series applies cleanly against linux-next from 2011-12-16. Real-life testing happened on S3C2416 hardware. Heiko Stuebner (7): s3c-hsudc: move platform_data struct to global header s3c-hsudc: add __devinit to probe function s3c-hsudc: add missing otg_put_transceiver in probe s3c-hsudc: move device registration to probe s3c-hsudc: use udc_start and udc_stop functions s3c-hsudc: Add regulator handling s3c-hsudc: use release_mem_region instead of release_resource arch/arm/mach-s3c2416/mach-smdk2416.c | 1 + arch/arm/plat-samsung/devs.c | 1 + arch/arm/plat-samsung/include/plat/udc.h | 15 +---- drivers/usb/gadget/s3c-hsudc.c | 109 +++++++++++++++++------------- include/linux/usb/s3c-hsudc.h | 34 +++++++++ 5 files changed, 100 insertions(+), 60 deletions(-) create mode 100644 include/linux/usb/s3c-hsudc.h -- 1.7.5.4 ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 1/7] s3c-hsudc: move platform_data struct to global header 2011-12-19 13:23 ` Heiko Stübner @ 2011-12-19 13:24 ` Heiko Stübner -1 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:24 UTC (permalink / raw) To: Felipe Balbi, Kukjin Kim, 'Ben Dooks' Cc: linux-arm-kernel, linux-samsung-soc, Linux USB Mailing List Gadget drivers should be compilable on all architectures. This patch removes one dependency on architecture-specific code. Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- arch/arm/mach-s3c2416/mach-smdk2416.c | 1 + arch/arm/plat-samsung/devs.c | 1 + arch/arm/plat-samsung/include/plat/udc.h | 15 +------------ drivers/usb/gadget/s3c-hsudc.c | 2 +- include/linux/usb/s3c-hsudc.h | 34 ++++++++++++++++++++++++++++++ 5 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 include/linux/usb/s3c-hsudc.h diff --git a/arch/arm/mach-s3c2416/mach-smdk2416.c b/arch/arm/mach-s3c2416/mach-smdk2416.c index a9eee53..018338a 100644 --- a/arch/arm/mach-s3c2416/mach-smdk2416.c +++ b/arch/arm/mach-s3c2416/mach-smdk2416.c @@ -50,6 +50,7 @@ #include <plat/nand.h> #include <plat/sdhci.h> #include <plat/udc.h> +#include <linux/usb/s3c-hsudc.h> #include <plat/regs-fb-v4.h> #include <plat/fb.h> diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c index 4ca8b57..5468723 100644 --- a/arch/arm/plat-samsung/devs.c +++ b/arch/arm/plat-samsung/devs.c @@ -29,6 +29,7 @@ #include <linux/mtd/partitions.h> #include <linux/mmc/host.h> #include <linux/ioport.h> +#include <linux/usb/s3c-hsudc.h> #include <asm/irq.h> #include <asm/pmu.h> diff --git a/arch/arm/plat-samsung/include/plat/udc.h b/arch/arm/plat-samsung/include/plat/udc.h index 8c22d58..de8e228 100644 --- a/arch/arm/plat-samsung/include/plat/udc.h +++ b/arch/arm/plat-samsung/include/plat/udc.h @@ -37,20 +37,7 @@ struct s3c2410_udc_mach_info { extern void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *); -/** - * s3c24xx_hsudc_platdata - Platform data for USB High-Speed gadget controller. - * @epnum: Number of endpoints to be instantiated by the controller driver. - * @gpio_init: Platform specific USB related GPIO initialization. - * @gpio_uninit: Platform specific USB releted GPIO uninitialzation. - * - * Representation of platform data for the S3C24XX USB 2.0 High Speed gadget - * controllers. - */ -struct s3c24xx_hsudc_platdata { - unsigned int epnum; - void (*gpio_init)(void); - void (*gpio_uninit)(void); -}; +struct s3c24xx_hsudc_platdata; extern void __init s3c24xx_hsudc_set_platdata(struct s3c24xx_hsudc_platdata *pd); diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index 6f2a041..4c1abb1 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -28,9 +28,9 @@ #include <linux/usb/gadget.h> #include <linux/usb/otg.h> #include <linux/prefetch.h> +#include <linux/usb/s3c-hsudc.h> #include <mach/regs-s3c2443-clock.h> -#include <plat/udc.h> #define S3C_HSUDC_REG(x) (x) diff --git a/include/linux/usb/s3c-hsudc.h b/include/linux/usb/s3c-hsudc.h new file mode 100644 index 0000000..6fa1093 --- /dev/null +++ b/include/linux/usb/s3c-hsudc.h @@ -0,0 +1,34 @@ +/* + * S3C24XX USB 2.0 High-speed USB controller gadget driver + * + * Copyright (c) 2010 Samsung Electronics Co., Ltd. + * http://www.samsung.com/ + * + * The S3C24XX USB 2.0 high-speed USB controller supports upto 9 endpoints. + * Each endpoint can be configured as either in or out endpoint. Endpoints + * can be configured for Bulk or Interrupt transfer mode. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. +*/ + +#ifndef __LINUX_USB_S3C_HSUDC_H +#define __LINUX_USB_S3C_HSUDC_H + +/** + * s3c24xx_hsudc_platdata - Platform data for USB High-Speed gadget controller. + * @epnum: Number of endpoints to be instantiated by the controller driver. + * @gpio_init: Platform specific USB related GPIO initialization. + * @gpio_uninit: Platform specific USB releted GPIO uninitialzation. + * + * Representation of platform data for the S3C24XX USB 2.0 High Speed gadget + * controllers. + */ +struct s3c24xx_hsudc_platdata { + unsigned int epnum; + void (*gpio_init)(void); + void (*gpio_uninit)(void); +}; + +#endif /* __LINUX_USB_S3C_HSUDC_H */ -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 1/7] s3c-hsudc: move platform_data struct to global header @ 2011-12-19 13:24 ` Heiko Stübner 0 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:24 UTC (permalink / raw) To: linux-arm-kernel Gadget drivers should be compilable on all architectures. This patch removes one dependency on architecture-specific code. Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- arch/arm/mach-s3c2416/mach-smdk2416.c | 1 + arch/arm/plat-samsung/devs.c | 1 + arch/arm/plat-samsung/include/plat/udc.h | 15 +------------ drivers/usb/gadget/s3c-hsudc.c | 2 +- include/linux/usb/s3c-hsudc.h | 34 ++++++++++++++++++++++++++++++ 5 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 include/linux/usb/s3c-hsudc.h diff --git a/arch/arm/mach-s3c2416/mach-smdk2416.c b/arch/arm/mach-s3c2416/mach-smdk2416.c index a9eee53..018338a 100644 --- a/arch/arm/mach-s3c2416/mach-smdk2416.c +++ b/arch/arm/mach-s3c2416/mach-smdk2416.c @@ -50,6 +50,7 @@ #include <plat/nand.h> #include <plat/sdhci.h> #include <plat/udc.h> +#include <linux/usb/s3c-hsudc.h> #include <plat/regs-fb-v4.h> #include <plat/fb.h> diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c index 4ca8b57..5468723 100644 --- a/arch/arm/plat-samsung/devs.c +++ b/arch/arm/plat-samsung/devs.c @@ -29,6 +29,7 @@ #include <linux/mtd/partitions.h> #include <linux/mmc/host.h> #include <linux/ioport.h> +#include <linux/usb/s3c-hsudc.h> #include <asm/irq.h> #include <asm/pmu.h> diff --git a/arch/arm/plat-samsung/include/plat/udc.h b/arch/arm/plat-samsung/include/plat/udc.h index 8c22d58..de8e228 100644 --- a/arch/arm/plat-samsung/include/plat/udc.h +++ b/arch/arm/plat-samsung/include/plat/udc.h @@ -37,20 +37,7 @@ struct s3c2410_udc_mach_info { extern void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *); -/** - * s3c24xx_hsudc_platdata - Platform data for USB High-Speed gadget controller. - * @epnum: Number of endpoints to be instantiated by the controller driver. - * @gpio_init: Platform specific USB related GPIO initialization. - * @gpio_uninit: Platform specific USB releted GPIO uninitialzation. - * - * Representation of platform data for the S3C24XX USB 2.0 High Speed gadget - * controllers. - */ -struct s3c24xx_hsudc_platdata { - unsigned int epnum; - void (*gpio_init)(void); - void (*gpio_uninit)(void); -}; +struct s3c24xx_hsudc_platdata; extern void __init s3c24xx_hsudc_set_platdata(struct s3c24xx_hsudc_platdata *pd); diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index 6f2a041..4c1abb1 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -28,9 +28,9 @@ #include <linux/usb/gadget.h> #include <linux/usb/otg.h> #include <linux/prefetch.h> +#include <linux/usb/s3c-hsudc.h> #include <mach/regs-s3c2443-clock.h> -#include <plat/udc.h> #define S3C_HSUDC_REG(x) (x) diff --git a/include/linux/usb/s3c-hsudc.h b/include/linux/usb/s3c-hsudc.h new file mode 100644 index 0000000..6fa1093 --- /dev/null +++ b/include/linux/usb/s3c-hsudc.h @@ -0,0 +1,34 @@ +/* + * S3C24XX USB 2.0 High-speed USB controller gadget driver + * + * Copyright (c) 2010 Samsung Electronics Co., Ltd. + * http://www.samsung.com/ + * + * The S3C24XX USB 2.0 high-speed USB controller supports upto 9 endpoints. + * Each endpoint can be configured as either in or out endpoint. Endpoints + * can be configured for Bulk or Interrupt transfer mode. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. +*/ + +#ifndef __LINUX_USB_S3C_HSUDC_H +#define __LINUX_USB_S3C_HSUDC_H + +/** + * s3c24xx_hsudc_platdata - Platform data for USB High-Speed gadget controller. + * @epnum: Number of endpoints to be instantiated by the controller driver. + * @gpio_init: Platform specific USB related GPIO initialization. + * @gpio_uninit: Platform specific USB releted GPIO uninitialzation. + * + * Representation of platform data for the S3C24XX USB 2.0 High Speed gadget + * controllers. + */ +struct s3c24xx_hsudc_platdata { + unsigned int epnum; + void (*gpio_init)(void); + void (*gpio_uninit)(void); +}; + +#endif /* __LINUX_USB_S3C_HSUDC_H */ -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH 1/7] s3c-hsudc: move platform_data struct to global header 2011-12-19 13:24 ` Heiko Stübner @ 2011-12-19 13:29 ` Felipe Balbi -1 siblings, 0 replies; 24+ messages in thread From: Felipe Balbi @ 2011-12-19 13:29 UTC (permalink / raw) To: Heiko Stübner Cc: Felipe Balbi, Kukjin Kim, 'Ben Dooks', linux-arm-kernel, linux-samsung-soc, Linux USB Mailing List [-- Attachment #1: Type: text/plain, Size: 1703 bytes --] Hi, On Mon, Dec 19, 2011 at 02:24:24PM +0100, Heiko Stübner wrote: > diff --git a/include/linux/usb/s3c-hsudc.h b/include/linux/usb/s3c-hsudc.h > new file mode 100644 > index 0000000..6fa1093 > --- /dev/null > +++ b/include/linux/usb/s3c-hsudc.h > @@ -0,0 +1,34 @@ > +/* > + * S3C24XX USB 2.0 High-speed USB controller gadget driver > + * > + * Copyright (c) 2010 Samsung Electronics Co., Ltd. > + * http://www.samsung.com/ > + * > + * The S3C24XX USB 2.0 high-speed USB controller supports upto 9 endpoints. > + * Each endpoint can be configured as either in or out endpoint. Endpoints > + * can be configured for Bulk or Interrupt transfer mode. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > +*/ > + > +#ifndef __LINUX_USB_S3C_HSUDC_H > +#define __LINUX_USB_S3C_HSUDC_H > + > +/** > + * s3c24xx_hsudc_platdata - Platform data for USB High-Speed gadget controller. > + * @epnum: Number of endpoints to be instantiated by the controller driver. > + * @gpio_init: Platform specific USB related GPIO initialization. > + * @gpio_uninit: Platform specific USB releted GPIO uninitialzation. > + * > + * Representation of platform data for the S3C24XX USB 2.0 High Speed gadget > + * controllers. > + */ > +struct s3c24xx_hsudc_platdata { > + unsigned int epnum; > + void (*gpio_init)(void); > + void (*gpio_uninit)(void); > +}; > + > +#endif /* __LINUX_USB_S3C_HSUDC_H */ this holds platform_data only, how about <linux/platform_data/s3c-hsudc.h> ?? other than that, it looks good. -- balbi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 1/7] s3c-hsudc: move platform_data struct to global header @ 2011-12-19 13:29 ` Felipe Balbi 0 siblings, 0 replies; 24+ messages in thread From: Felipe Balbi @ 2011-12-19 13:29 UTC (permalink / raw) To: linux-arm-kernel Hi, On Mon, Dec 19, 2011 at 02:24:24PM +0100, Heiko St?bner wrote: > diff --git a/include/linux/usb/s3c-hsudc.h b/include/linux/usb/s3c-hsudc.h > new file mode 100644 > index 0000000..6fa1093 > --- /dev/null > +++ b/include/linux/usb/s3c-hsudc.h > @@ -0,0 +1,34 @@ > +/* > + * S3C24XX USB 2.0 High-speed USB controller gadget driver > + * > + * Copyright (c) 2010 Samsung Electronics Co., Ltd. > + * http://www.samsung.com/ > + * > + * The S3C24XX USB 2.0 high-speed USB controller supports upto 9 endpoints. > + * Each endpoint can be configured as either in or out endpoint. Endpoints > + * can be configured for Bulk or Interrupt transfer mode. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > +*/ > + > +#ifndef __LINUX_USB_S3C_HSUDC_H > +#define __LINUX_USB_S3C_HSUDC_H > + > +/** > + * s3c24xx_hsudc_platdata - Platform data for USB High-Speed gadget controller. > + * @epnum: Number of endpoints to be instantiated by the controller driver. > + * @gpio_init: Platform specific USB related GPIO initialization. > + * @gpio_uninit: Platform specific USB releted GPIO uninitialzation. > + * > + * Representation of platform data for the S3C24XX USB 2.0 High Speed gadget > + * controllers. > + */ > +struct s3c24xx_hsudc_platdata { > + unsigned int epnum; > + void (*gpio_init)(void); > + void (*gpio_uninit)(void); > +}; > + > +#endif /* __LINUX_USB_S3C_HSUDC_H */ this holds platform_data only, how about <linux/platform_data/s3c-hsudc.h> ?? other than that, it looks good. -- balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20111219/07222b53/attachment.sig> ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 2/7] s3c-hsudc: add __devinit to probe function 2011-12-19 13:23 ` Heiko Stübner @ 2011-12-19 13:24 ` Heiko Stübner -1 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:24 UTC (permalink / raw) To: Felipe Balbi, Kukjin Kim, 'Ben Dooks' Cc: linux-arm-kernel, linux-samsung-soc, Linux USB Mailing List Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- drivers/usb/gadget/s3c-hsudc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index 4c1abb1..3e5673d 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -1260,7 +1260,7 @@ static struct usb_gadget_ops s3c_hsudc_gadget_ops = { .vbus_draw = s3c_hsudc_vbus_draw, }; -static int s3c_hsudc_probe(struct platform_device *pdev) +static int __devinit s3c_hsudc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res; -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 2/7] s3c-hsudc: add __devinit to probe function @ 2011-12-19 13:24 ` Heiko Stübner 0 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:24 UTC (permalink / raw) To: linux-arm-kernel Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- drivers/usb/gadget/s3c-hsudc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index 4c1abb1..3e5673d 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -1260,7 +1260,7 @@ static struct usb_gadget_ops s3c_hsudc_gadget_ops = { .vbus_draw = s3c_hsudc_vbus_draw, }; -static int s3c_hsudc_probe(struct platform_device *pdev) +static int __devinit s3c_hsudc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct resource *res; -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
[parent not found: <201112191424.58081.heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>]
* Re: [PATCH 2/7] s3c-hsudc: add __devinit to probe function 2011-12-19 13:24 ` Heiko Stübner @ 2011-12-19 13:29 ` Felipe Balbi -1 siblings, 0 replies; 24+ messages in thread From: Felipe Balbi @ 2011-12-19 13:29 UTC (permalink / raw) To: Heiko Stübner Cc: Felipe Balbi, Kukjin Kim, 'Ben Dooks', linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, Linux USB Mailing List [-- Attachment #1: Type: text/plain, Size: 899 bytes --] On Mon, Dec 19, 2011 at 02:24:57PM +0100, Heiko Stübner wrote: I need a commit log, even if it's an obvious one. Sorry for the nit-picking. > Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> > --- > drivers/usb/gadget/s3c-hsudc.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c > index 4c1abb1..3e5673d 100644 > --- a/drivers/usb/gadget/s3c-hsudc.c > +++ b/drivers/usb/gadget/s3c-hsudc.c > @@ -1260,7 +1260,7 @@ static struct usb_gadget_ops s3c_hsudc_gadget_ops = { > .vbus_draw = s3c_hsudc_vbus_draw, > }; > > -static int s3c_hsudc_probe(struct platform_device *pdev) > +static int __devinit s3c_hsudc_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > struct resource *res; > -- > 1.7.5.4 > -- balbi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 2/7] s3c-hsudc: add __devinit to probe function @ 2011-12-19 13:29 ` Felipe Balbi 0 siblings, 0 replies; 24+ messages in thread From: Felipe Balbi @ 2011-12-19 13:29 UTC (permalink / raw) To: linux-arm-kernel On Mon, Dec 19, 2011 at 02:24:57PM +0100, Heiko St?bner wrote: I need a commit log, even if it's an obvious one. Sorry for the nit-picking. > Signed-off-by: Heiko Stuebner <heiko@sntech.de> > --- > drivers/usb/gadget/s3c-hsudc.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c > index 4c1abb1..3e5673d 100644 > --- a/drivers/usb/gadget/s3c-hsudc.c > +++ b/drivers/usb/gadget/s3c-hsudc.c > @@ -1260,7 +1260,7 @@ static struct usb_gadget_ops s3c_hsudc_gadget_ops = { > .vbus_draw = s3c_hsudc_vbus_draw, > }; > > -static int s3c_hsudc_probe(struct platform_device *pdev) > +static int __devinit s3c_hsudc_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > struct resource *res; > -- > 1.7.5.4 > -- balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20111219/2c8dcbaa/attachment-0001.sig> ^ permalink raw reply [flat|nested] 24+ messages in thread
[parent not found: <201112191423.21461.heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>]
* [PATCH 3/7] s3c-hsudc: add missing otg_put_transceiver in probe 2011-12-19 13:23 ` Heiko Stübner @ 2011-12-19 13:25 ` Heiko Stübner -1 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:25 UTC (permalink / raw) To: Felipe Balbi, Kukjin Kim, 'Ben Dooks' Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, Linux USB Mailing List The number of get and put calls should always be equal. Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> --- drivers/usb/gadget/s3c-hsudc.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index 3e5673d..6c2b2ce 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -1366,6 +1366,9 @@ err_remap: kfree(hsudc->mem_rsrc); err_res: + if (hsudc->transceiver) + otg_put_transceiver(hsudc->transceiver); + kfree(hsudc); return ret; } -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 3/7] s3c-hsudc: add missing otg_put_transceiver in probe @ 2011-12-19 13:25 ` Heiko Stübner 0 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:25 UTC (permalink / raw) To: linux-arm-kernel The number of get and put calls should always be equal. Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- drivers/usb/gadget/s3c-hsudc.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index 3e5673d..6c2b2ce 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -1366,6 +1366,9 @@ err_remap: kfree(hsudc->mem_rsrc); err_res: + if (hsudc->transceiver) + otg_put_transceiver(hsudc->transceiver); + kfree(hsudc); return ret; } -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 4/7] s3c-hsudc: move device registration to probe 2011-12-19 13:23 ` Heiko Stübner @ 2011-12-19 13:25 ` Heiko Stübner -1 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:25 UTC (permalink / raw) To: Felipe Balbi, Kukjin Kim, 'Ben Dooks' Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, Linux USB Mailing List Instead of adding and deleting the gadget device in the start and stop invocations. Use device_register in the probe method to initialize and add the gadget device. Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> --- drivers/usb/gadget/s3c-hsudc.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index 6c2b2ce..42bcd97 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -1156,11 +1156,6 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, hsudc->driver = driver; hsudc->gadget.dev.driver = &driver->driver; hsudc->gadget.speed = USB_SPEED_UNKNOWN; - ret = device_add(&hsudc->gadget.dev); - if (ret) { - dev_err(hsudc->dev, "failed to probe gadget device"); - return ret; - } ret = bind(&hsudc->gadget); if (ret) { @@ -1180,8 +1175,6 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, hsudc->gadget.name); driver->unbind(&hsudc->gadget); - device_del(&hsudc->gadget.dev); - hsudc->driver = NULL; hsudc->gadget.dev.driver = NULL; return ret; @@ -1222,7 +1215,6 @@ static int s3c_hsudc_stop(struct usb_gadget_driver *driver) (void) otg_set_peripheral(hsudc->transceiver, NULL); driver->unbind(&hsudc->gadget); - device_del(&hsudc->gadget.dev); disable_irq(hsudc->irq); dev_info(hsudc->dev, "unregistered gadget driver '%s'\n", @@ -1307,7 +1299,6 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) spin_lock_init(&hsudc->lock); - device_initialize(&hsudc->gadget.dev); dev_set_name(&hsudc->gadget.dev, "gadget"); hsudc->gadget.max_speed = USB_SPEED_HIGH; @@ -1348,12 +1339,20 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) disable_irq(hsudc->irq); local_irq_enable(); + ret = device_register(&hsudc->gadget.dev); + if (ret) { + put_device(&hsudc->gadget.dev); + goto err_add_device; + } + ret = usb_add_gadget_udc(&pdev->dev, &hsudc->gadget); if (ret) goto err_add_udc; return 0; err_add_udc: + device_unregister(&hsudc->gadget.dev); +err_add_device: clk_disable(hsudc->uclk); clk_put(hsudc->uclk); err_clk: -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 4/7] s3c-hsudc: move device registration to probe @ 2011-12-19 13:25 ` Heiko Stübner 0 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:25 UTC (permalink / raw) To: linux-arm-kernel Instead of adding and deleting the gadget device in the start and stop invocations. Use device_register in the probe method to initialize and add the gadget device. Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- drivers/usb/gadget/s3c-hsudc.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index 6c2b2ce..42bcd97 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -1156,11 +1156,6 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, hsudc->driver = driver; hsudc->gadget.dev.driver = &driver->driver; hsudc->gadget.speed = USB_SPEED_UNKNOWN; - ret = device_add(&hsudc->gadget.dev); - if (ret) { - dev_err(hsudc->dev, "failed to probe gadget device"); - return ret; - } ret = bind(&hsudc->gadget); if (ret) { @@ -1180,8 +1175,6 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, hsudc->gadget.name); driver->unbind(&hsudc->gadget); - device_del(&hsudc->gadget.dev); - hsudc->driver = NULL; hsudc->gadget.dev.driver = NULL; return ret; @@ -1222,7 +1215,6 @@ static int s3c_hsudc_stop(struct usb_gadget_driver *driver) (void) otg_set_peripheral(hsudc->transceiver, NULL); driver->unbind(&hsudc->gadget); - device_del(&hsudc->gadget.dev); disable_irq(hsudc->irq); dev_info(hsudc->dev, "unregistered gadget driver '%s'\n", @@ -1307,7 +1299,6 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) spin_lock_init(&hsudc->lock); - device_initialize(&hsudc->gadget.dev); dev_set_name(&hsudc->gadget.dev, "gadget"); hsudc->gadget.max_speed = USB_SPEED_HIGH; @@ -1348,12 +1339,20 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) disable_irq(hsudc->irq); local_irq_enable(); + ret = device_register(&hsudc->gadget.dev); + if (ret) { + put_device(&hsudc->gadget.dev); + goto err_add_device; + } + ret = usb_add_gadget_udc(&pdev->dev, &hsudc->gadget); if (ret) goto err_add_udc; return 0; err_add_udc: + device_unregister(&hsudc->gadget.dev); +err_add_device: clk_disable(hsudc->uclk); clk_put(hsudc->uclk); err_clk: -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 6/7] s3c-hsudc: Add regulator handling 2011-12-19 13:23 ` Heiko Stübner @ 2011-12-19 13:27 ` Heiko Stübner -1 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:27 UTC (permalink / raw) To: Felipe Balbi, Kukjin Kim, 'Ben Dooks' Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, Linux USB Mailing List The udc has three supplies: vdda (3.3V), vddi (1.2V) and vddosc (1.8-3.3V). Turn these on and off on start and stop calls. Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> --- drivers/usb/gadget/s3c-hsudc.c | 41 ++++++++++++++++++++++++++++++++++++--- 1 files changed, 37 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index daaccec..d6544f6 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -29,6 +29,7 @@ #include <linux/usb/otg.h> #include <linux/prefetch.h> #include <linux/usb/s3c-hsudc.h> +#include <linux/regulator/consumer.h> #include <mach/regs-s3c2443-clock.h> @@ -87,6 +88,12 @@ #define DATA_STATE_XMIT (1) #define DATA_STATE_RECV (2) +static const char * const s3c_hsudc_supply_names[] = { + "vdda", /* analog phy supply, 3.3V */ + "vddi", /* digital phy supply, 1.2V */ + "vddosc", /* oscillator supply, 1.8V - 3.3V */ +}; + /** * struct s3c_hsudc_ep - Endpoint representation used by driver. * @ep: USB gadget layer representation of device endpoint. @@ -139,6 +146,7 @@ struct s3c_hsudc { struct device *dev; struct s3c24xx_hsudc_platdata *pd; struct otg_transceiver *transceiver; + struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)]; spinlock_t lock; void __iomem *regs; struct resource *mem_rsrc; @@ -1150,15 +1158,20 @@ static int s3c_hsudc_start(struct usb_gadget *g, hsudc->driver = driver; hsudc->gadget.dev.driver = &driver->driver; + ret = regulator_bulk_enable(ARRAY_SIZE(hsudc->supplies), + hsudc->supplies); + if (ret != 0) { + dev_err(hsudc->dev, "failed to enable supplies: %d\n", ret); + goto err_supplies; + } + /* connect to bus through transceiver */ if (hsudc->transceiver) { ret = otg_set_peripheral(hsudc->transceiver, &hsudc->gadget); if (ret) { dev_err(hsudc->dev, "%s: can't bind to transceiver\n", hsudc->gadget.name); - hsudc->driver = NULL; - hsudc->gadget.dev.driver = NULL; - return ret; + goto err_otg; } } @@ -1171,6 +1184,12 @@ static int s3c_hsudc_start(struct usb_gadget *g, hsudc->pd->gpio_init(); return 0; +err_otg: + regulator_bulk_disable(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); +err_supplies: + hsudc->driver = NULL; + hsudc->gadget.dev.driver = NULL; + return ret; } static int s3c_hsudc_stop(struct usb_gadget *g, @@ -1200,6 +1219,8 @@ static int s3c_hsudc_stop(struct usb_gadget *g, disable_irq(hsudc->irq); + regulator_bulk_disable(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); + dev_info(hsudc->dev, "unregistered gadget driver '%s'\n", driver->driver.name); return 0; @@ -1241,7 +1262,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) struct resource *res; struct s3c_hsudc *hsudc; struct s3c24xx_hsudc_platdata *pd = pdev->dev.platform_data; - int ret; + int ret, i; hsudc = kzalloc(sizeof(struct s3c_hsudc) + sizeof(struct s3c_hsudc_ep) * pd->epnum, @@ -1258,6 +1279,16 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) hsudc->transceiver = otg_get_transceiver(); + for (i = 0; i < ARRAY_SIZE(hsudc->supplies); i++) + hsudc->supplies[i].supply = s3c_hsudc_supply_names[i]; + + ret = regulator_bulk_get(dev, ARRAY_SIZE(hsudc->supplies), + hsudc->supplies); + if (ret != 0) { + dev_err(dev, "failed to request supplies: %d\n", ret); + goto err_supplies; + } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "unable to obtain driver resource data\n"); @@ -1352,6 +1383,8 @@ err_res: if (hsudc->transceiver) otg_put_transceiver(hsudc->transceiver); + regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); +err_supplies: kfree(hsudc); return ret; } -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 6/7] s3c-hsudc: Add regulator handling @ 2011-12-19 13:27 ` Heiko Stübner 0 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:27 UTC (permalink / raw) To: linux-arm-kernel The udc has three supplies: vdda (3.3V), vddi (1.2V) and vddosc (1.8-3.3V). Turn these on and off on start and stop calls. Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- drivers/usb/gadget/s3c-hsudc.c | 41 ++++++++++++++++++++++++++++++++++++--- 1 files changed, 37 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index daaccec..d6544f6 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -29,6 +29,7 @@ #include <linux/usb/otg.h> #include <linux/prefetch.h> #include <linux/usb/s3c-hsudc.h> +#include <linux/regulator/consumer.h> #include <mach/regs-s3c2443-clock.h> @@ -87,6 +88,12 @@ #define DATA_STATE_XMIT (1) #define DATA_STATE_RECV (2) +static const char * const s3c_hsudc_supply_names[] = { + "vdda", /* analog phy supply, 3.3V */ + "vddi", /* digital phy supply, 1.2V */ + "vddosc", /* oscillator supply, 1.8V - 3.3V */ +}; + /** * struct s3c_hsudc_ep - Endpoint representation used by driver. * @ep: USB gadget layer representation of device endpoint. @@ -139,6 +146,7 @@ struct s3c_hsudc { struct device *dev; struct s3c24xx_hsudc_platdata *pd; struct otg_transceiver *transceiver; + struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)]; spinlock_t lock; void __iomem *regs; struct resource *mem_rsrc; @@ -1150,15 +1158,20 @@ static int s3c_hsudc_start(struct usb_gadget *g, hsudc->driver = driver; hsudc->gadget.dev.driver = &driver->driver; + ret = regulator_bulk_enable(ARRAY_SIZE(hsudc->supplies), + hsudc->supplies); + if (ret != 0) { + dev_err(hsudc->dev, "failed to enable supplies: %d\n", ret); + goto err_supplies; + } + /* connect to bus through transceiver */ if (hsudc->transceiver) { ret = otg_set_peripheral(hsudc->transceiver, &hsudc->gadget); if (ret) { dev_err(hsudc->dev, "%s: can't bind to transceiver\n", hsudc->gadget.name); - hsudc->driver = NULL; - hsudc->gadget.dev.driver = NULL; - return ret; + goto err_otg; } } @@ -1171,6 +1184,12 @@ static int s3c_hsudc_start(struct usb_gadget *g, hsudc->pd->gpio_init(); return 0; +err_otg: + regulator_bulk_disable(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); +err_supplies: + hsudc->driver = NULL; + hsudc->gadget.dev.driver = NULL; + return ret; } static int s3c_hsudc_stop(struct usb_gadget *g, @@ -1200,6 +1219,8 @@ static int s3c_hsudc_stop(struct usb_gadget *g, disable_irq(hsudc->irq); + regulator_bulk_disable(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); + dev_info(hsudc->dev, "unregistered gadget driver '%s'\n", driver->driver.name); return 0; @@ -1241,7 +1262,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) struct resource *res; struct s3c_hsudc *hsudc; struct s3c24xx_hsudc_platdata *pd = pdev->dev.platform_data; - int ret; + int ret, i; hsudc = kzalloc(sizeof(struct s3c_hsudc) + sizeof(struct s3c_hsudc_ep) * pd->epnum, @@ -1258,6 +1279,16 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) hsudc->transceiver = otg_get_transceiver(); + for (i = 0; i < ARRAY_SIZE(hsudc->supplies); i++) + hsudc->supplies[i].supply = s3c_hsudc_supply_names[i]; + + ret = regulator_bulk_get(dev, ARRAY_SIZE(hsudc->supplies), + hsudc->supplies); + if (ret != 0) { + dev_err(dev, "failed to request supplies: %d\n", ret); + goto err_supplies; + } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(dev, "unable to obtain driver resource data\n"); @@ -1352,6 +1383,8 @@ err_res: if (hsudc->transceiver) otg_put_transceiver(hsudc->transceiver); + regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); +err_supplies: kfree(hsudc); return ret; } -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH 6/7] s3c-hsudc: Add regulator handling 2011-12-19 13:27 ` Heiko Stübner @ 2011-12-20 15:04 ` Mark Brown -1 siblings, 0 replies; 24+ messages in thread From: Mark Brown @ 2011-12-20 15:04 UTC (permalink / raw) To: Heiko St?bner Cc: Felipe Balbi, Kukjin Kim, 'Ben Dooks', linux-samsung-soc, Linux USB Mailing List, linux-arm-kernel On Mon, Dec 19, 2011 at 02:27:07PM +0100, Heiko St?bner wrote: > The udc has three supplies: vdda (3.3V), vddi (1.2V) and vddosc (1.8-3.3V). > Turn these on and off on start and stop calls. > > Signed-off-by: Heiko Stuebner <heiko@sntech.de> Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 6/7] s3c-hsudc: Add regulator handling @ 2011-12-20 15:04 ` Mark Brown 0 siblings, 0 replies; 24+ messages in thread From: Mark Brown @ 2011-12-20 15:04 UTC (permalink / raw) To: linux-arm-kernel On Mon, Dec 19, 2011 at 02:27:07PM +0100, Heiko St?bner wrote: > The udc has three supplies: vdda (3.3V), vddi (1.2V) and vddosc (1.8-3.3V). > Turn these on and off on start and stop calls. > > Signed-off-by: Heiko Stuebner <heiko@sntech.de> Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com> ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 5/7] s3c-hsudc: use udc_start and udc_stop functions 2011-12-19 13:23 ` Heiko Stübner @ 2011-12-19 13:26 ` Heiko Stübner -1 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:26 UTC (permalink / raw) To: Felipe Balbi, Kukjin Kim, 'Ben Dooks' Cc: linux-arm-kernel, linux-samsung-soc, Linux USB Mailing List udc_start and udc_stop reduce code duplication in comparison to start and stop generalising calls done by all drivers (i.e. bind and unbind) and moving these calls to common code. Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- drivers/usb/gadget/s3c-hsudc.c | 44 ++++++++++++--------------------------- 1 files changed, 14 insertions(+), 30 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index 42bcd97..daaccec 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -282,8 +282,7 @@ static void s3c_hsudc_nuke_ep(struct s3c_hsudc_ep *hsep, int status) * All the endpoints are stopped and any pending transfer requests if any on * the endpoint are terminated. */ -static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc, - struct usb_gadget_driver *driver) +static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc) { struct s3c_hsudc_ep *hsep; int epnum; @@ -295,10 +294,6 @@ static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc, hsep->stopped = 1; s3c_hsudc_nuke_ep(hsep, -ESHUTDOWN); } - - spin_unlock(&hsudc->lock); - driver->disconnect(&hsudc->gadget); - spin_lock(&hsudc->lock); } /** @@ -1135,16 +1130,15 @@ static irqreturn_t s3c_hsudc_irq(int irq, void *_dev) return IRQ_HANDLED; } -static int s3c_hsudc_start(struct usb_gadget_driver *driver, - int (*bind)(struct usb_gadget *)) +static int s3c_hsudc_start(struct usb_gadget *g, + struct usb_gadget_driver *driver) { struct s3c_hsudc *hsudc = the_controller; int ret; if (!driver || driver->max_speed < USB_SPEED_FULL - || !bind - || !driver->unbind || !driver->disconnect || !driver->setup) + || !driver->setup) return -EINVAL; if (!hsudc) @@ -1155,17 +1149,6 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, hsudc->driver = driver; hsudc->gadget.dev.driver = &driver->driver; - hsudc->gadget.speed = USB_SPEED_UNKNOWN; - - ret = bind(&hsudc->gadget); - if (ret) { - dev_err(hsudc->dev, "%s: bind failed\n", hsudc->gadget.name); - device_del(&hsudc->gadget.dev); - - hsudc->driver = NULL; - hsudc->gadget.dev.driver = NULL; - return ret; - } /* connect to bus through transceiver */ if (hsudc->transceiver) { @@ -1173,8 +1156,6 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, if (ret) { dev_err(hsudc->dev, "%s: can't bind to transceiver\n", hsudc->gadget.name); - driver->unbind(&hsudc->gadget); - hsudc->driver = NULL; hsudc->gadget.dev.driver = NULL; return ret; @@ -1192,7 +1173,8 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, return 0; } -static int s3c_hsudc_stop(struct usb_gadget_driver *driver) +static int s3c_hsudc_stop(struct usb_gadget *g, + struct usb_gadget_driver *driver) { struct s3c_hsudc *hsudc = the_controller; unsigned long flags; @@ -1200,21 +1182,22 @@ static int s3c_hsudc_stop(struct usb_gadget_driver *driver) if (!hsudc) return -ENODEV; - if (!driver || driver != hsudc->driver || !driver->unbind) + if (!driver || driver != hsudc->driver) return -EINVAL; spin_lock_irqsave(&hsudc->lock, flags); - hsudc->driver = 0; + hsudc->driver = NULL; + hsudc->gadget.dev.driver = NULL; + hsudc->gadget.speed = USB_SPEED_UNKNOWN; s3c_hsudc_uninit_phy(); if (hsudc->pd->gpio_uninit) hsudc->pd->gpio_uninit(); - s3c_hsudc_stop_activity(hsudc, driver); + s3c_hsudc_stop_activity(hsudc); spin_unlock_irqrestore(&hsudc->lock, flags); if (hsudc->transceiver) (void) otg_set_peripheral(hsudc->transceiver, NULL); - driver->unbind(&hsudc->gadget); disable_irq(hsudc->irq); dev_info(hsudc->dev, "unregistered gadget driver '%s'\n", @@ -1247,8 +1230,8 @@ static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA) static struct usb_gadget_ops s3c_hsudc_gadget_ops = { .get_frame = s3c_hsudc_gadget_getframe, - .start = s3c_hsudc_start, - .stop = s3c_hsudc_stop, + .udc_start = s3c_hsudc_start, + .udc_stop = s3c_hsudc_stop, .vbus_draw = s3c_hsudc_vbus_draw, }; @@ -1310,6 +1293,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) hsudc->gadget.is_otg = 0; hsudc->gadget.is_a_peripheral = 0; + hsudc->gadget.speed = USB_SPEED_UNKNOWN; s3c_hsudc_setup_ep(hsudc); -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 5/7] s3c-hsudc: use udc_start and udc_stop functions @ 2011-12-19 13:26 ` Heiko Stübner 0 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:26 UTC (permalink / raw) To: linux-arm-kernel udc_start and udc_stop reduce code duplication in comparison to start and stop generalising calls done by all drivers (i.e. bind and unbind) and moving these calls to common code. Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- drivers/usb/gadget/s3c-hsudc.c | 44 ++++++++++++--------------------------- 1 files changed, 14 insertions(+), 30 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index 42bcd97..daaccec 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -282,8 +282,7 @@ static void s3c_hsudc_nuke_ep(struct s3c_hsudc_ep *hsep, int status) * All the endpoints are stopped and any pending transfer requests if any on * the endpoint are terminated. */ -static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc, - struct usb_gadget_driver *driver) +static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc) { struct s3c_hsudc_ep *hsep; int epnum; @@ -295,10 +294,6 @@ static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc, hsep->stopped = 1; s3c_hsudc_nuke_ep(hsep, -ESHUTDOWN); } - - spin_unlock(&hsudc->lock); - driver->disconnect(&hsudc->gadget); - spin_lock(&hsudc->lock); } /** @@ -1135,16 +1130,15 @@ static irqreturn_t s3c_hsudc_irq(int irq, void *_dev) return IRQ_HANDLED; } -static int s3c_hsudc_start(struct usb_gadget_driver *driver, - int (*bind)(struct usb_gadget *)) +static int s3c_hsudc_start(struct usb_gadget *g, + struct usb_gadget_driver *driver) { struct s3c_hsudc *hsudc = the_controller; int ret; if (!driver || driver->max_speed < USB_SPEED_FULL - || !bind - || !driver->unbind || !driver->disconnect || !driver->setup) + || !driver->setup) return -EINVAL; if (!hsudc) @@ -1155,17 +1149,6 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, hsudc->driver = driver; hsudc->gadget.dev.driver = &driver->driver; - hsudc->gadget.speed = USB_SPEED_UNKNOWN; - - ret = bind(&hsudc->gadget); - if (ret) { - dev_err(hsudc->dev, "%s: bind failed\n", hsudc->gadget.name); - device_del(&hsudc->gadget.dev); - - hsudc->driver = NULL; - hsudc->gadget.dev.driver = NULL; - return ret; - } /* connect to bus through transceiver */ if (hsudc->transceiver) { @@ -1173,8 +1156,6 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, if (ret) { dev_err(hsudc->dev, "%s: can't bind to transceiver\n", hsudc->gadget.name); - driver->unbind(&hsudc->gadget); - hsudc->driver = NULL; hsudc->gadget.dev.driver = NULL; return ret; @@ -1192,7 +1173,8 @@ static int s3c_hsudc_start(struct usb_gadget_driver *driver, return 0; } -static int s3c_hsudc_stop(struct usb_gadget_driver *driver) +static int s3c_hsudc_stop(struct usb_gadget *g, + struct usb_gadget_driver *driver) { struct s3c_hsudc *hsudc = the_controller; unsigned long flags; @@ -1200,21 +1182,22 @@ static int s3c_hsudc_stop(struct usb_gadget_driver *driver) if (!hsudc) return -ENODEV; - if (!driver || driver != hsudc->driver || !driver->unbind) + if (!driver || driver != hsudc->driver) return -EINVAL; spin_lock_irqsave(&hsudc->lock, flags); - hsudc->driver = 0; + hsudc->driver = NULL; + hsudc->gadget.dev.driver = NULL; + hsudc->gadget.speed = USB_SPEED_UNKNOWN; s3c_hsudc_uninit_phy(); if (hsudc->pd->gpio_uninit) hsudc->pd->gpio_uninit(); - s3c_hsudc_stop_activity(hsudc, driver); + s3c_hsudc_stop_activity(hsudc); spin_unlock_irqrestore(&hsudc->lock, flags); if (hsudc->transceiver) (void) otg_set_peripheral(hsudc->transceiver, NULL); - driver->unbind(&hsudc->gadget); disable_irq(hsudc->irq); dev_info(hsudc->dev, "unregistered gadget driver '%s'\n", @@ -1247,8 +1230,8 @@ static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA) static struct usb_gadget_ops s3c_hsudc_gadget_ops = { .get_frame = s3c_hsudc_gadget_getframe, - .start = s3c_hsudc_start, - .stop = s3c_hsudc_stop, + .udc_start = s3c_hsudc_start, + .udc_stop = s3c_hsudc_stop, .vbus_draw = s3c_hsudc_vbus_draw, }; @@ -1310,6 +1293,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) hsudc->gadget.is_otg = 0; hsudc->gadget.is_a_peripheral = 0; + hsudc->gadget.speed = USB_SPEED_UNKNOWN; s3c_hsudc_setup_ep(hsudc); -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
[parent not found: <201112191426.20365.heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>]
* Re: [PATCH 5/7] s3c-hsudc: use udc_start and udc_stop functions 2011-12-19 13:26 ` Heiko Stübner @ 2011-12-19 13:32 ` Felipe Balbi -1 siblings, 0 replies; 24+ messages in thread From: Felipe Balbi @ 2011-12-19 13:32 UTC (permalink / raw) To: Heiko Stübner Cc: Felipe Balbi, Kukjin Kim, 'Ben Dooks', linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA, Linux USB Mailing List [-- Attachment #1: Type: text/plain, Size: 1918 bytes --] On Mon, Dec 19, 2011 at 02:26:20PM +0100, Heiko Stübner wrote: > udc_start and udc_stop reduce code duplication in comparison to > start and stop generalising calls done by all drivers > (i.e. bind and unbind) and moving these calls to common code. > > Signed-off-by: Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> > --- > drivers/usb/gadget/s3c-hsudc.c | 44 ++++++++++++--------------------------- > 1 files changed, 14 insertions(+), 30 deletions(-) > > diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c > index 42bcd97..daaccec 100644 > --- a/drivers/usb/gadget/s3c-hsudc.c > +++ b/drivers/usb/gadget/s3c-hsudc.c > @@ -282,8 +282,7 @@ static void s3c_hsudc_nuke_ep(struct s3c_hsudc_ep *hsep, int status) > * All the endpoints are stopped and any pending transfer requests if any on > * the endpoint are terminated. > */ > -static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc, > - struct usb_gadget_driver *driver) > +static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc) > { > struct s3c_hsudc_ep *hsep; > int epnum; > @@ -295,10 +294,6 @@ static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc, > hsep->stopped = 1; > s3c_hsudc_nuke_ep(hsep, -ESHUTDOWN); > } > - > - spin_unlock(&hsudc->lock); > - driver->disconnect(&hsudc->gadget); > - spin_lock(&hsudc->lock); > } > > /** > @@ -1135,16 +1130,15 @@ static irqreturn_t s3c_hsudc_irq(int irq, void *_dev) > return IRQ_HANDLED; > } > > -static int s3c_hsudc_start(struct usb_gadget_driver *driver, > - int (*bind)(struct usb_gadget *)) > +static int s3c_hsudc_start(struct usb_gadget *g, > + struct usb_gadget_driver *driver) > { > struct s3c_hsudc *hsudc = the_controller; while at that, you can drop this "the_controller" global. You could use a container_of() to reach your s3c_hsudc pointer. -- balbi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 5/7] s3c-hsudc: use udc_start and udc_stop functions @ 2011-12-19 13:32 ` Felipe Balbi 0 siblings, 0 replies; 24+ messages in thread From: Felipe Balbi @ 2011-12-19 13:32 UTC (permalink / raw) To: linux-arm-kernel On Mon, Dec 19, 2011 at 02:26:20PM +0100, Heiko St?bner wrote: > udc_start and udc_stop reduce code duplication in comparison to > start and stop generalising calls done by all drivers > (i.e. bind and unbind) and moving these calls to common code. > > Signed-off-by: Heiko Stuebner <heiko@sntech.de> > --- > drivers/usb/gadget/s3c-hsudc.c | 44 ++++++++++++--------------------------- > 1 files changed, 14 insertions(+), 30 deletions(-) > > diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c > index 42bcd97..daaccec 100644 > --- a/drivers/usb/gadget/s3c-hsudc.c > +++ b/drivers/usb/gadget/s3c-hsudc.c > @@ -282,8 +282,7 @@ static void s3c_hsudc_nuke_ep(struct s3c_hsudc_ep *hsep, int status) > * All the endpoints are stopped and any pending transfer requests if any on > * the endpoint are terminated. > */ > -static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc, > - struct usb_gadget_driver *driver) > +static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc) > { > struct s3c_hsudc_ep *hsep; > int epnum; > @@ -295,10 +294,6 @@ static void s3c_hsudc_stop_activity(struct s3c_hsudc *hsudc, > hsep->stopped = 1; > s3c_hsudc_nuke_ep(hsep, -ESHUTDOWN); > } > - > - spin_unlock(&hsudc->lock); > - driver->disconnect(&hsudc->gadget); > - spin_lock(&hsudc->lock); > } > > /** > @@ -1135,16 +1130,15 @@ static irqreturn_t s3c_hsudc_irq(int irq, void *_dev) > return IRQ_HANDLED; > } > > -static int s3c_hsudc_start(struct usb_gadget_driver *driver, > - int (*bind)(struct usb_gadget *)) > +static int s3c_hsudc_start(struct usb_gadget *g, > + struct usb_gadget_driver *driver) > { > struct s3c_hsudc *hsudc = the_controller; while at that, you can drop this "the_controller" global. You could use a container_of() to reach your s3c_hsudc pointer. -- balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20111219/5b5914cd/attachment.sig> ^ permalink raw reply [flat|nested] 24+ messages in thread
* [PATCH 7/7] s3c-hsudc: use release_mem_region instead of release_resource 2011-12-19 13:23 ` Heiko Stübner @ 2011-12-19 13:27 ` Heiko Stübner -1 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:27 UTC (permalink / raw) To: Felipe Balbi, Kukjin Kim, 'Ben Dooks' Cc: linux-arm-kernel, linux-samsung-soc, Linux USB Mailing List As the memory region is requested through request_mem_region use the correct paired method to release it in the error path and don't go "beneath the API" as pointed out by Russel King. Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- drivers/usb/gadget/s3c-hsudc.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index d6544f6..af1e700 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -1376,9 +1376,7 @@ err_irq: iounmap(hsudc->regs); err_remap: - release_resource(hsudc->mem_rsrc); - kfree(hsudc->mem_rsrc); - + release_mem_region(res->start, resource_size(res)); err_res: if (hsudc->transceiver) otg_put_transceiver(hsudc->transceiver); -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH 7/7] s3c-hsudc: use release_mem_region instead of release_resource @ 2011-12-19 13:27 ` Heiko Stübner 0 siblings, 0 replies; 24+ messages in thread From: Heiko Stübner @ 2011-12-19 13:27 UTC (permalink / raw) To: linux-arm-kernel As the memory region is requested through request_mem_region use the correct paired method to release it in the error path and don't go "beneath the API" as pointed out by Russel King. Signed-off-by: Heiko Stuebner <heiko@sntech.de> --- drivers/usb/gadget/s3c-hsudc.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index d6544f6..af1e700 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c @@ -1376,9 +1376,7 @@ err_irq: iounmap(hsudc->regs); err_remap: - release_resource(hsudc->mem_rsrc); - kfree(hsudc->mem_rsrc); - + release_mem_region(res->start, resource_size(res)); err_res: if (hsudc->transceiver) otg_put_transceiver(hsudc->transceiver); -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 24+ messages in thread
end of thread, other threads:[~2011-12-20 15:05 UTC | newest] Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-12-19 13:23 [PATCH v3 0/7] s3c-hsudc: regulator handling and a lot of fixes Heiko Stübner 2011-12-19 13:23 ` Heiko Stübner 2011-12-19 13:24 ` [PATCH 1/7] s3c-hsudc: move platform_data struct to global header Heiko Stübner 2011-12-19 13:24 ` Heiko Stübner 2011-12-19 13:29 ` Felipe Balbi 2011-12-19 13:29 ` Felipe Balbi 2011-12-19 13:24 ` [PATCH 2/7] s3c-hsudc: add __devinit to probe function Heiko Stübner 2011-12-19 13:24 ` Heiko Stübner [not found] ` <201112191424.58081.heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> 2011-12-19 13:29 ` Felipe Balbi 2011-12-19 13:29 ` Felipe Balbi [not found] ` <201112191423.21461.heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> 2011-12-19 13:25 ` [PATCH 3/7] s3c-hsudc: add missing otg_put_transceiver in probe Heiko Stübner 2011-12-19 13:25 ` Heiko Stübner 2011-12-19 13:25 ` [PATCH 4/7] s3c-hsudc: move device registration to probe Heiko Stübner 2011-12-19 13:25 ` Heiko Stübner 2011-12-19 13:27 ` [PATCH 6/7] s3c-hsudc: Add regulator handling Heiko Stübner 2011-12-19 13:27 ` Heiko Stübner 2011-12-20 15:04 ` Mark Brown 2011-12-20 15:04 ` Mark Brown 2011-12-19 13:26 ` [PATCH 5/7] s3c-hsudc: use udc_start and udc_stop functions Heiko Stübner 2011-12-19 13:26 ` Heiko Stübner [not found] ` <201112191426.20365.heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org> 2011-12-19 13:32 ` Felipe Balbi 2011-12-19 13:32 ` Felipe Balbi 2011-12-19 13:27 ` [PATCH 7/7] s3c-hsudc: use release_mem_region instead of release_resource Heiko Stübner 2011-12-19 13:27 ` Heiko Stübner
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.