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>
This commit is contained in:
parent
da020b49fa
commit
c8240c1b81
|
@ -242,6 +242,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
|
||||||
struct gpio_vbus_data *gpio_vbus;
|
struct gpio_vbus_data *gpio_vbus;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
int err, gpio, irq;
|
int err, gpio, irq;
|
||||||
|
unsigned long irqflags;
|
||||||
|
|
||||||
if (!pdata || !gpio_is_valid(pdata->gpio_vbus))
|
if (!pdata || !gpio_is_valid(pdata->gpio_vbus))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -278,10 +279,11 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
|
||||||
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
|
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
|
||||||
if (res) {
|
if (res) {
|
||||||
irq = res->start;
|
irq = res->start;
|
||||||
res->flags &= IRQF_TRIGGER_MASK;
|
irqflags = (res->flags & IRQF_TRIGGER_MASK) | IRQF_SHARED;
|
||||||
res->flags |= IRQF_SHARED;
|
} else {
|
||||||
} else
|
|
||||||
irq = gpio_to_irq(gpio);
|
irq = gpio_to_irq(gpio);
|
||||||
|
irqflags = VBUS_IRQ_FLAGS;
|
||||||
|
}
|
||||||
|
|
||||||
gpio_vbus->irq = irq;
|
gpio_vbus->irq = irq;
|
||||||
|
|
||||||
|
@ -299,8 +301,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev)
|
||||||
gpio_direction_output(gpio, pdata->gpio_pullup_inverted);
|
gpio_direction_output(gpio, pdata->gpio_pullup_inverted);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = request_irq(irq, gpio_vbus_irq, VBUS_IRQ_FLAGS,
|
err = request_irq(irq, gpio_vbus_irq, irqflags, "vbus_detect", pdev);
|
||||||
"vbus_detect", pdev);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(&pdev->dev, "can't request irq %i, err: %d\n",
|
dev_err(&pdev->dev, "can't request irq %i, err: %d\n",
|
||||||
irq, err);
|
irq, err);
|
||||||
|
|
Loading…
Reference in a new issue