diff options
author | Sylvain Rochet <sylvain.rochet@finsecur.com> | 2015-02-12 12:54:05 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-03-11 11:19:36 -0400 |
commit | bb0a203c3a4e37b4bbb1f8ef55a855618dbba265 (patch) | |
tree | 3e5df3157ecb51cce707a0b6b51e26476f3b3517 /drivers/usb/gadget | |
parent | 227ab58cff3c26ec279598112887d6bcca677a0c (diff) |
usb: gadget: atmel_usba_udc: Request an auto disabled Vbus signal IRQ
Vbus IRQ handler needs a started UDC driver to work because it uses
udc->driver, which is set by the UDC start handler. The previous way
chosen was to return from interrupt if udc->driver is NULL using a
spinlock around the check.
We now request an auto disabled (IRQ_NOAUTOEN) Vbus signal IRQ instead
of an auto enabled IRQ followed by disable_irq(). This way we remove the
very small timeslot of enabled IRQ which existed previously between
request() and disable(). We don't need anymore to check if udc->driver
is NULL in IRQ handler.
Signed-off-by: Sylvain Rochet <sylvain.rochet@finsecur.com>
Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/udc/atmel_usba_udc.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index e63c6fc8173b..bbbd5f11f767 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c | |||
@@ -1749,10 +1749,6 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid) | |||
1749 | 1749 | ||
1750 | spin_lock(&udc->lock); | 1750 | spin_lock(&udc->lock); |
1751 | 1751 | ||
1752 | /* May happen if Vbus pin toggles during probe() */ | ||
1753 | if (!udc->driver) | ||
1754 | goto out; | ||
1755 | |||
1756 | vbus = vbus_is_present(udc); | 1752 | vbus = vbus_is_present(udc); |
1757 | if (vbus != udc->vbus_prev) { | 1753 | if (vbus != udc->vbus_prev) { |
1758 | if (vbus) { | 1754 | if (vbus) { |
@@ -1773,7 +1769,6 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid) | |||
1773 | udc->vbus_prev = vbus; | 1769 | udc->vbus_prev = vbus; |
1774 | } | 1770 | } |
1775 | 1771 | ||
1776 | out: | ||
1777 | spin_unlock(&udc->lock); | 1772 | spin_unlock(&udc->lock); |
1778 | 1773 | ||
1779 | return IRQ_HANDLED; | 1774 | return IRQ_HANDLED; |
@@ -2113,6 +2108,8 @@ static int usba_udc_probe(struct platform_device *pdev) | |||
2113 | 2108 | ||
2114 | if (gpio_is_valid(udc->vbus_pin)) { | 2109 | if (gpio_is_valid(udc->vbus_pin)) { |
2115 | if (!devm_gpio_request(&pdev->dev, udc->vbus_pin, "atmel_usba_udc")) { | 2110 | if (!devm_gpio_request(&pdev->dev, udc->vbus_pin, "atmel_usba_udc")) { |
2111 | irq_set_status_flags(gpio_to_irq(udc->vbus_pin), | ||
2112 | IRQ_NOAUTOEN); | ||
2116 | ret = devm_request_irq(&pdev->dev, | 2113 | ret = devm_request_irq(&pdev->dev, |
2117 | gpio_to_irq(udc->vbus_pin), | 2114 | gpio_to_irq(udc->vbus_pin), |
2118 | usba_vbus_irq, 0, | 2115 | usba_vbus_irq, 0, |
@@ -2122,8 +2119,6 @@ static int usba_udc_probe(struct platform_device *pdev) | |||
2122 | dev_warn(&udc->pdev->dev, | 2119 | dev_warn(&udc->pdev->dev, |
2123 | "failed to request vbus irq; " | 2120 | "failed to request vbus irq; " |
2124 | "assuming always on\n"); | 2121 | "assuming always on\n"); |
2125 | } else { | ||
2126 | disable_irq(gpio_to_irq(udc->vbus_pin)); | ||
2127 | } | 2122 | } |
2128 | } else { | 2123 | } else { |
2129 | /* gpio_request fail so use -EINVAL for gpio_is_valid */ | 2124 | /* gpio_request fail so use -EINVAL for gpio_is_valid */ |