diff options
author | Heiner Kallweit <hkallweit1@gmail.com> | 2016-09-14 20:55:00 +0200 |
---|---|---|
committer | Jacek Anaszewski <j.anaszewski@samsung.com> | 2016-09-15 16:49:40 +0200 |
commit | 4580809436fc391aff9d876a14d07f66a5de6b28 (patch) | |
tree | 9b67c6bf62acf0df033a8dea2ba9b1f43f40f747 /drivers/leds/leds-gpio.c | |
parent | 061b5c1d013a94af385ba8980ea3b2617f1ff0f6 (diff) |
leds: gpio: add helper cdev_to_gpio_led_data
Add a helper for the container_of as it's used more than once.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Diffstat (limited to 'drivers/leds/leds-gpio.c')
-rw-r--r-- | drivers/leds/leds-gpio.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 10c851ecc6ce..da4aa8e95a58 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -29,11 +29,16 @@ struct gpio_led_data { gpio_blink_set_t platform_gpio_blink_set; }; +static inline struct gpio_led_data * + cdev_to_gpio_led_data(struct led_classdev *led_cdev) +{ + return container_of(led_cdev, struct gpio_led_data, cdev); +} + static void gpio_led_set(struct led_classdev *led_cdev, enum led_brightness value) { - struct gpio_led_data *led_dat = - container_of(led_cdev, struct gpio_led_data, cdev); + struct gpio_led_data *led_dat = cdev_to_gpio_led_data(led_cdev); int level; if (value == LED_OFF) @@ -63,8 +68,7 @@ static int gpio_led_set_blocking(struct led_classdev *led_cdev, static int gpio_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on, unsigned long *delay_off) { - struct gpio_led_data *led_dat = - container_of(led_cdev, struct gpio_led_data, cdev); + struct gpio_led_data *led_dat = cdev_to_gpio_led_data(led_cdev); led_dat->blinking = 1; return led_dat->platform_gpio_blink_set(led_dat->gpiod, GPIO_LED_BLINK, |