Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: gpio_vbus: handle IRQ flags properly

Currently, 'res->flags' handlings are wrong in three respects:
* the driver _modifies_ the contents of platform data
* res->flags is set up, but not used anywhere in the driver
* request_irq() always takes VBUS_IRQ_FLAGS, regardless of refs->flags

This patch tries to fix this with a policy: If a platform IRQ resource
is available, give preference to its IRQ flag(s) over a default one
(VBUS_IRQ_FLAGS).

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Shinya Kuribayashi and committed by
Greg Kroah-Hartman
c8240c1b da020b49

+6 -5
+6 -5
drivers/usb/otg/gpio_vbus.c
··· 242 242 struct gpio_vbus_data *gpio_vbus; 243 243 struct resource *res; 244 244 int err, gpio, irq; 245 + unsigned long irqflags; 245 246 246 247 if (!pdata || !gpio_is_valid(pdata->gpio_vbus)) 247 248 return -EINVAL; ··· 279 278 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 280 279 if (res) { 281 280 irq = res->start; 282 - res->flags &= IRQF_TRIGGER_MASK; 283 - res->flags |= IRQF_SHARED; 284 - } else 281 + irqflags = (res->flags & IRQF_TRIGGER_MASK) | IRQF_SHARED; 282 + } else { 285 283 irq = gpio_to_irq(gpio); 284 + irqflags = VBUS_IRQ_FLAGS; 285 + } 286 286 287 287 gpio_vbus->irq = irq; 288 288 ··· 301 299 gpio_direction_output(gpio, pdata->gpio_pullup_inverted); 302 300 } 303 301 304 - err = request_irq(irq, gpio_vbus_irq, VBUS_IRQ_FLAGS, 305 - "vbus_detect", pdev); 302 + err = request_irq(irq, gpio_vbus_irq, irqflags, "vbus_detect", pdev); 306 303 if (err) { 307 304 dev_err(&pdev->dev, "can't request irq %i, err: %d\n", 308 305 irq, err);