Commit a43a4e58 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Pavel Machek

leds: el15203000: Introduce to_el15203000_led() helper

Introduce a helper to replace open coded container_of() calls.
At the same time move ldev member to be first in the struct el15203000_led,
that makes container_of() effectivelly a no-op.
Signed-off-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
parent 0ac40af8
...@@ -68,8 +68,8 @@ enum el15203000_command { ...@@ -68,8 +68,8 @@ enum el15203000_command {
}; };
struct el15203000_led { struct el15203000_led {
struct el15203000 *priv;
struct led_classdev ldev; struct led_classdev ldev;
struct el15203000 *priv;
u32 reg; u32 reg;
}; };
...@@ -82,6 +82,8 @@ struct el15203000 { ...@@ -82,6 +82,8 @@ struct el15203000 {
struct el15203000_led leds[]; struct el15203000_led leds[];
}; };
#define to_el15203000_led(d) container_of(d, struct el15203000_led, ldev)
static int el15203000_cmd(struct el15203000_led *led, u8 brightness) static int el15203000_cmd(struct el15203000_led *led, u8 brightness)
{ {
int ret; int ret;
...@@ -128,9 +130,7 @@ static int el15203000_cmd(struct el15203000_led *led, u8 brightness) ...@@ -128,9 +130,7 @@ static int el15203000_cmd(struct el15203000_led *led, u8 brightness)
static int el15203000_set_blocking(struct led_classdev *ldev, static int el15203000_set_blocking(struct led_classdev *ldev,
enum led_brightness brightness) enum led_brightness brightness)
{ {
struct el15203000_led *led = container_of(ldev, struct el15203000_led *led = to_el15203000_led(ldev);
struct el15203000_led,
ldev);
return el15203000_cmd(led, brightness == LED_OFF ? EL_OFF : EL_ON); return el15203000_cmd(led, brightness == LED_OFF ? EL_OFF : EL_ON);
} }
...@@ -139,9 +139,7 @@ static int el15203000_pattern_set_S(struct led_classdev *ldev, ...@@ -139,9 +139,7 @@ static int el15203000_pattern_set_S(struct led_classdev *ldev,
struct led_pattern *pattern, struct led_pattern *pattern,
u32 len, int repeat) u32 len, int repeat)
{ {
struct el15203000_led *led = container_of(ldev, struct el15203000_led *led = to_el15203000_led(ldev);
struct el15203000_led,
ldev);
if (repeat > 0 || len != 2 || if (repeat > 0 || len != 2 ||
pattern[0].delta_t != 4000 || pattern[0].brightness != 0 || pattern[0].delta_t != 4000 || pattern[0].brightness != 0 ||
...@@ -192,10 +190,8 @@ static int el15203000_pattern_set_P(struct led_classdev *ldev, ...@@ -192,10 +190,8 @@ static int el15203000_pattern_set_P(struct led_classdev *ldev,
struct led_pattern *pattern, struct led_pattern *pattern,
u32 len, int repeat) u32 len, int repeat)
{ {
struct el15203000_led *led = to_el15203000_led(ldev);
u8 cmd; u8 cmd;
struct el15203000_led *led = container_of(ldev,
struct el15203000_led,
ldev);
if (repeat > 0) if (repeat > 0)
return -EINVAL; return -EINVAL;
...@@ -232,9 +228,7 @@ static int el15203000_pattern_set_P(struct led_classdev *ldev, ...@@ -232,9 +228,7 @@ static int el15203000_pattern_set_P(struct led_classdev *ldev,
static int el15203000_pattern_clear(struct led_classdev *ldev) static int el15203000_pattern_clear(struct led_classdev *ldev)
{ {
struct el15203000_led *led = container_of(ldev, struct el15203000_led *led = to_el15203000_led(ldev);
struct el15203000_led,
ldev);
return el15203000_cmd(led, EL_OFF); return el15203000_cmd(led, EL_OFF);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment