2018-04-16 11:46:43

by Romain Izard

[permalink] [raw]
Subject: [PATCH 0/3] Fix an Atmel USBA UDC issue introducted in 4.17-rc1

The use of GPIO descriptors takes care of inversion flags declared in
the device tree. The conversion of the Atmel USBA UDC driver introduced
in 4.17-rc1 missed it, and as a result the inversion will not work.

In addition, cleanup the code to remove an include left behind after
the suppression of the support of platform_data to declare USBA
controllers.

These changes have not been tested on any hardware, as I do not have
a board that needs to use inverted GPIOs.

Romain Izard (3):
usb: gadget: udc: atmel: GPIO inversion is handled by gpiod
usb: gadget: udc: atmel: Remove obsolete include
usb: gadget: udc: atmel: Fix indenting

drivers/usb/gadget/udc/atmel_usba_udc.c | 22 ++++++++++------------
drivers/usb/gadget/udc/atmel_usba_udc.h | 1 -
include/linux/usb/atmel_usba_udc.h | 24 ------------------------
3 files changed, 10 insertions(+), 37 deletions(-)
delete mode 100644 include/linux/usb/atmel_usba_udc.h

--
2.14.1



2018-04-16 09:43:22

by Romain Izard

[permalink] [raw]
Subject: [PATCH 1/3] usb: gadget: udc: atmel: GPIO inversion is handled by gpiod

When converting to GPIO descriptors, gpiod_get_value automatically
handles the line inversion flags from the device tree.

Do not invert the line twice.

Fixes: 3df034081021fa4b6967ce3364bc7d867ec1c870

Signed-off-by: Romain Izard <[email protected]>
---
drivers/usb/gadget/udc/atmel_usba_udc.c | 3 +--
drivers/usb/gadget/udc/atmel_usba_udc.h | 1 -
2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 27c16399c7e8..0fe3d0feb8f7 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -417,7 +417,7 @@ static inline void usba_int_enb_set(struct usba_udc *udc, u32 val)
static int vbus_is_present(struct usba_udc *udc)
{
if (udc->vbus_pin)
- return gpiod_get_value(udc->vbus_pin) ^ udc->vbus_pin_inverted;
+ return gpiod_get_value(udc->vbus_pin);

/* No Vbus detection: Assume always present */
return 1;
@@ -2076,7 +2076,6 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,

udc->vbus_pin = devm_gpiod_get_optional(&pdev->dev, "atmel,vbus",
GPIOD_IN);
- udc->vbus_pin_inverted = gpiod_is_active_low(udc->vbus_pin);

if (fifo_mode == 0) {
pp = NULL;
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h b/drivers/usb/gadget/udc/atmel_usba_udc.h
index 969ce8f3c3e2..d7eb7cf4fd5c 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.h
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
@@ -326,7 +326,6 @@ struct usba_udc {
const struct usba_udc_errata *errata;
int irq;
struct gpio_desc *vbus_pin;
- int vbus_pin_inverted;
int num_ep;
int configured_ep;
struct usba_fifo_cfg *fifo_cfg;
--
2.14.1


2018-04-16 11:47:04

by Romain Izard

[permalink] [raw]
Subject: [PATCH 2/3] usb: gadget: udc: atmel: Remove obsolete include

The include defines the private platform_data structure used with AVR
platforms. It has no user since 7c55984e191f. Remove it.

Signed-off-by: Romain Izard <[email protected]>
---
drivers/usb/gadget/udc/atmel_usba_udc.c | 1 -
include/linux/usb/atmel_usba_udc.h | 24 ------------------------
2 files changed, 25 deletions(-)
delete mode 100644 include/linux/usb/atmel_usba_udc.h

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 0fe3d0feb8f7..b9623e228609 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -20,7 +20,6 @@
#include <linux/ctype.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
-#include <linux/usb/atmel_usba_udc.h>
#include <linux/delay.h>
#include <linux/of.h>
#include <linux/irq.h>
diff --git a/include/linux/usb/atmel_usba_udc.h b/include/linux/usb/atmel_usba_udc.h
deleted file mode 100644
index 9bb00df3b53f..000000000000
--- a/include/linux/usb/atmel_usba_udc.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Platform data definitions for Atmel USBA gadget driver.
- */
-#ifndef __LINUX_USB_USBA_H
-#define __LINUX_USB_USBA_H
-
-struct usba_ep_data {
- char *name;
- int index;
- int fifo_size;
- int nr_banks;
- int can_dma;
- int can_isoc;
-};
-
-struct usba_platform_data {
- int vbus_pin;
- int vbus_pin_inverted;
- int num_ep;
- struct usba_ep_data ep[0];
-};
-
-#endif /* __LINUX_USB_USBA_H */
--
2.14.1


2018-04-16 11:47:11

by Romain Izard

[permalink] [raw]
Subject: [PATCH 3/3] usb: gadget: udc: atmel: Fix indenting

Fix the fallout of the conversion to GPIO descriptors in 3df034081021.

Signed-off-by: Romain Izard <[email protected]>
---
drivers/usb/gadget/udc/atmel_usba_udc.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index b9623e228609..2f586f2bda7e 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -2277,15 +2277,15 @@ static int usba_udc_probe(struct platform_device *pdev)
if (udc->vbus_pin) {
irq_set_status_flags(gpiod_to_irq(udc->vbus_pin), IRQ_NOAUTOEN);
ret = devm_request_threaded_irq(&pdev->dev,
- gpiod_to_irq(udc->vbus_pin), NULL,
- usba_vbus_irq_thread, USBA_VBUS_IRQFLAGS,
- "atmel_usba_udc", udc);
- if (ret) {
- udc->vbus_pin = NULL;
- dev_warn(&udc->pdev->dev,
- "failed to request vbus irq; "
- "assuming always on\n");
- }
+ gpiod_to_irq(udc->vbus_pin), NULL,
+ usba_vbus_irq_thread, USBA_VBUS_IRQFLAGS,
+ "atmel_usba_udc", udc);
+ if (ret) {
+ udc->vbus_pin = NULL;
+ dev_warn(&udc->pdev->dev,
+ "failed to request vbus irq; "
+ "assuming always on\n");
+ }
}

ret = usb_add_gadget_udc(&pdev->dev, &udc->gadget);
--
2.14.1


2018-04-16 12:30:45

by Ludovic Desroches

[permalink] [raw]
Subject: Re: [PATCH 3/3] usb: gadget: udc: atmel: Fix indenting

On Mon, Apr 16, 2018 at 11:34:05AM +0200, Romain Izard wrote:
> Fix the fallout of the conversion to GPIO descriptors in 3df034081021.
>
> Signed-off-by: Romain Izard <[email protected]>
Acked-by: Ludovic Desroches <[email protected]>
> ---
> drivers/usb/gadget/udc/atmel_usba_udc.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index b9623e228609..2f586f2bda7e 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -2277,15 +2277,15 @@ static int usba_udc_probe(struct platform_device *pdev)
> if (udc->vbus_pin) {
> irq_set_status_flags(gpiod_to_irq(udc->vbus_pin), IRQ_NOAUTOEN);
> ret = devm_request_threaded_irq(&pdev->dev,
> - gpiod_to_irq(udc->vbus_pin), NULL,
> - usba_vbus_irq_thread, USBA_VBUS_IRQFLAGS,
> - "atmel_usba_udc", udc);
> - if (ret) {
> - udc->vbus_pin = NULL;
> - dev_warn(&udc->pdev->dev,
> - "failed to request vbus irq; "
> - "assuming always on\n");
> - }
> + gpiod_to_irq(udc->vbus_pin), NULL,
> + usba_vbus_irq_thread, USBA_VBUS_IRQFLAGS,
> + "atmel_usba_udc", udc);
> + if (ret) {
> + udc->vbus_pin = NULL;
> + dev_warn(&udc->pdev->dev,
> + "failed to request vbus irq; "
> + "assuming always on\n");
> + }
> }
>
> ret = usb_add_gadget_udc(&pdev->dev, &udc->gadget);
> --
> 2.14.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

2018-04-16 14:31:50

by Ludovic Desroches

[permalink] [raw]
Subject: Re: [PATCH 2/3] usb: gadget: udc: atmel: Remove obsolete include

On Mon, Apr 16, 2018 at 11:34:04AM +0200, Romain Izard wrote:
> The include defines the private platform_data structure used with AVR
> platforms. It has no user since 7c55984e191f. Remove it.
>
> Signed-off-by: Romain Izard <[email protected]>
Acked-by: Ludovic Desroches <[email protected]>
> ---
> drivers/usb/gadget/udc/atmel_usba_udc.c | 1 -
> include/linux/usb/atmel_usba_udc.h | 24 ------------------------
> 2 files changed, 25 deletions(-)
> delete mode 100644 include/linux/usb/atmel_usba_udc.h
>
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 0fe3d0feb8f7..b9623e228609 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -20,7 +20,6 @@
> #include <linux/ctype.h>
> #include <linux/usb/ch9.h>
> #include <linux/usb/gadget.h>
> -#include <linux/usb/atmel_usba_udc.h>
> #include <linux/delay.h>
> #include <linux/of.h>
> #include <linux/irq.h>
> diff --git a/include/linux/usb/atmel_usba_udc.h b/include/linux/usb/atmel_usba_udc.h
> deleted file mode 100644
> index 9bb00df3b53f..000000000000
> --- a/include/linux/usb/atmel_usba_udc.h
> +++ /dev/null
> @@ -1,24 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0 */
> -/*
> - * Platform data definitions for Atmel USBA gadget driver.
> - */
> -#ifndef __LINUX_USB_USBA_H
> -#define __LINUX_USB_USBA_H
> -
> -struct usba_ep_data {
> - char *name;
> - int index;
> - int fifo_size;
> - int nr_banks;
> - int can_dma;
> - int can_isoc;
> -};
> -
> -struct usba_platform_data {
> - int vbus_pin;
> - int vbus_pin_inverted;
> - int num_ep;
> - struct usba_ep_data ep[0];
> -};
> -
> -#endif /* __LINUX_USB_USBA_H */
> --
> 2.14.1
>

2018-04-16 14:32:04

by Ludovic Desroches

[permalink] [raw]
Subject: Re: [PATCH 1/3] usb: gadget: udc: atmel: GPIO inversion is handled by gpiod

On Mon, Apr 16, 2018 at 11:34:03AM +0200, Romain Izard wrote:
> When converting to GPIO descriptors, gpiod_get_value automatically
> handles the line inversion flags from the device tree.

Thanks, I totally missed it.

Regards

>
> Do not invert the line twice.
>
> Fixes: 3df034081021fa4b6967ce3364bc7d867ec1c870
>
> Signed-off-by: Romain Izard <[email protected]>
Acked-by: Ludovic Desroches <[email protected]>

> ---
> drivers/usb/gadget/udc/atmel_usba_udc.c | 3 +--
> drivers/usb/gadget/udc/atmel_usba_udc.h | 1 -
> 2 files changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 27c16399c7e8..0fe3d0feb8f7 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -417,7 +417,7 @@ static inline void usba_int_enb_set(struct usba_udc *udc, u32 val)
> static int vbus_is_present(struct usba_udc *udc)
> {
> if (udc->vbus_pin)
> - return gpiod_get_value(udc->vbus_pin) ^ udc->vbus_pin_inverted;
> + return gpiod_get_value(udc->vbus_pin);
>
> /* No Vbus detection: Assume always present */
> return 1;
> @@ -2076,7 +2076,6 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
>
> udc->vbus_pin = devm_gpiod_get_optional(&pdev->dev, "atmel,vbus",
> GPIOD_IN);
> - udc->vbus_pin_inverted = gpiod_is_active_low(udc->vbus_pin);
>
> if (fifo_mode == 0) {
> pp = NULL;
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h b/drivers/usb/gadget/udc/atmel_usba_udc.h
> index 969ce8f3c3e2..d7eb7cf4fd5c 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.h
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.h
> @@ -326,7 +326,6 @@ struct usba_udc {
> const struct usba_udc_errata *errata;
> int irq;
> struct gpio_desc *vbus_pin;
> - int vbus_pin_inverted;
> int num_ep;
> int configured_ep;
> struct usba_fifo_cfg *fifo_cfg;
> --
> 2.14.1
>

2018-04-17 08:27:19

by Nicolas Ferre

[permalink] [raw]
Subject: Re: [PATCH 0/3] Fix an Atmel USBA UDC issue introducted in 4.17-rc1

On 16/04/2018 at 11:34, Romain Izard wrote:
> The use of GPIO descriptors takes care of inversion flags declared in
> the device tree. The conversion of the Atmel USBA UDC driver introduced
> in 4.17-rc1 missed it, and as a result the inversion will not work.
>
> In addition, cleanup the code to remove an include left behind after
> the suppression of the support of platform_data to declare USBA
> controllers.
>
> These changes have not been tested on any hardware, as I do not have
> a board that needs to use inverted GPIOs.
>
> Romain Izard (3):
> usb: gadget: udc: atmel: GPIO inversion is handled by gpiod
> usb: gadget: udc: atmel: Remove obsolete include
> usb: gadget: udc: atmel: Fix indenting

To the whole series:
Acked-by: Nicolas Ferre <[email protected]>

Thank you Romain.
Best regards,
Nicolas

>
> drivers/usb/gadget/udc/atmel_usba_udc.c | 22 ++++++++++------------
> drivers/usb/gadget/udc/atmel_usba_udc.h | 1 -
> include/linux/usb/atmel_usba_udc.h | 24 ------------------------
> 3 files changed, 10 insertions(+), 37 deletions(-)
> delete mode 100644 include/linux/usb/atmel_usba_udc.h
>


--
Nicolas Ferre

2018-04-25 09:56:46

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH 1/3] usb: gadget: udc: atmel: GPIO inversion is handled by gpiod

Romain Izard <[email protected]> writes:

> When converting to GPIO descriptors, gpiod_get_value automatically
> handles the line inversion flags from the device tree.
>
> Do not invert the line twice.
>
> Fixes: 3df034081021fa4b6967ce3364bc7d867ec1c870

your fixes line is incorrect. Please fix and resend. While at that,
please collect Acked-bys and Tested-bys, etc.

--
balbi


Attachments:
signature.asc (847.00 B)