Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 157114
b: refs/heads/master
c: 48cccd2
h: refs/heads/master
v: v3
  • Loading branch information
Thadeu Lima de Souza Cascardo authored and Linus Torvalds committed Aug 27, 2009
1 parent 4bed11f commit 9ce2ec6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bdf57de4e6abc389cc3f3bd94ec15cce74cf6f4b
refs/heads/master: 48cccd26f36511ddb6aeca07485ecf2829683907
21 changes: 14 additions & 7 deletions trunk/drivers/leds/ledtrig-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,26 @@ static ssize_t gpio_trig_gpio_store(struct device *dev,
return -EINVAL;
}

if (gpio_data->gpio == gpio)
return n;

if (!gpio) {
free_irq(gpio_to_irq(gpio_data->gpio), led);
if (gpio_data->gpio != 0)
free_irq(gpio_to_irq(gpio_data->gpio), led);
gpio_data->gpio = 0;
return n;
}

if (gpio_data->gpio > 0 && gpio_data->gpio != gpio)
free_irq(gpio_to_irq(gpio_data->gpio), led);

gpio_data->gpio = gpio;
ret = request_irq(gpio_to_irq(gpio), gpio_trig_irq,
IRQF_SHARED | IRQF_TRIGGER_RISING
| IRQF_TRIGGER_FALLING, "ledtrig-gpio", led);
if (ret)
if (ret) {
dev_err(dev, "request_irq failed with error %d\n", ret);
} else {
if (gpio_data->gpio != 0)
free_irq(gpio_to_irq(gpio_data->gpio), led);
gpio_data->gpio = gpio;
}

return ret ? ret : n;
}
Expand Down Expand Up @@ -211,7 +217,8 @@ static void gpio_trig_deactivate(struct led_classdev *led)
device_remove_file(led->dev, &dev_attr_inverted);
device_remove_file(led->dev, &dev_attr_desired_brightness);
flush_work(&gpio_data->work);
free_irq(gpio_to_irq(gpio_data->gpio),led);
if (gpio_data->gpio != 0)
free_irq(gpio_to_irq(gpio_data->gpio), led);
kfree(gpio_data);
}
}
Expand Down

0 comments on commit 9ce2ec6

Please sign in to comment.