mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-04 08:08:54 +00:00
leds: ss4200: fix attribute-creation race
Use the attribute groups of the led-class to create the blink attribute during probe in order to avoid racing with userspace. Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Bryan Wu <cooloney@gmail.com>
This commit is contained in:
parent
475f854826
commit
67bd8eb07e
1 changed files with 9 additions and 5 deletions
|
@ -469,6 +469,12 @@ static ssize_t nas_led_blink_store(struct device *dev,
|
||||||
|
|
||||||
static DEVICE_ATTR(blink, 0644, nas_led_blink_show, nas_led_blink_store);
|
static DEVICE_ATTR(blink, 0644, nas_led_blink_show, nas_led_blink_store);
|
||||||
|
|
||||||
|
static struct attribute *nasgpio_led_attrs[] = {
|
||||||
|
&dev_attr_blink.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
ATTRIBUTE_GROUPS(nasgpio_led);
|
||||||
|
|
||||||
static int register_nasgpio_led(int led_nr)
|
static int register_nasgpio_led(int led_nr)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -481,20 +487,18 @@ static int register_nasgpio_led(int led_nr)
|
||||||
led->brightness = LED_FULL;
|
led->brightness = LED_FULL;
|
||||||
led->brightness_set = nasgpio_led_set_brightness;
|
led->brightness_set = nasgpio_led_set_brightness;
|
||||||
led->blink_set = nasgpio_led_set_blink;
|
led->blink_set = nasgpio_led_set_blink;
|
||||||
|
led->groups = nasgpio_led_groups;
|
||||||
ret = led_classdev_register(&nas_gpio_pci_dev->dev, led);
|
ret = led_classdev_register(&nas_gpio_pci_dev->dev, led);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
ret = device_create_file(led->dev, &dev_attr_blink);
|
|
||||||
if (ret)
|
return 0;
|
||||||
led_classdev_unregister(led);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unregister_nasgpio_led(int led_nr)
|
static void unregister_nasgpio_led(int led_nr)
|
||||||
{
|
{
|
||||||
struct led_classdev *led = get_classdev_for_led_nr(led_nr);
|
struct led_classdev *led = get_classdev_for_led_nr(led_nr);
|
||||||
led_classdev_unregister(led);
|
led_classdev_unregister(led);
|
||||||
device_remove_file(led->dev, &dev_attr_blink);
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* module load/initialization
|
* module load/initialization
|
||||||
|
|
Loading…
Reference in a new issue