Skip to content

Commit d17465a

Browse files
brglLee Jones
authored andcommitted
backlight: gpio: Use a helper variable for &pdev->dev
Instead of dereferencing pdev each time, use a helper variable for the associated device pointer. Signed-off-by: Bartosz Golaszewski <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent 2e7ec69 commit d17465a

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

drivers/video/backlight/gpio_backlight.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,41 +78,40 @@ static int gpio_backlight_initial_power_state(struct gpio_backlight *gbl)
7878

7979
static int gpio_backlight_probe(struct platform_device *pdev)
8080
{
81-
struct gpio_backlight_platform_data *pdata =
82-
dev_get_platdata(&pdev->dev);
81+
struct device *dev = &pdev->dev;
82+
struct gpio_backlight_platform_data *pdata = dev_get_platdata(dev);
8383
struct backlight_properties props;
8484
struct backlight_device *bl;
8585
struct gpio_backlight *gbl;
8686
int ret, init_brightness;
8787

88-
gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL);
88+
gbl = devm_kzalloc(dev, sizeof(*gbl), GFP_KERNEL);
8989
if (gbl == NULL)
9090
return -ENOMEM;
9191

92-
gbl->dev = &pdev->dev;
92+
gbl->dev = dev;
9393

9494
if (pdata)
9595
gbl->fbdev = pdata->fbdev;
9696

97-
gbl->def_value = device_property_read_bool(&pdev->dev, "default-on");
97+
gbl->def_value = device_property_read_bool(dev, "default-on");
9898

99-
gbl->gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_ASIS);
99+
gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS);
100100
if (IS_ERR(gbl->gpiod)) {
101101
ret = PTR_ERR(gbl->gpiod);
102102
if (ret != -EPROBE_DEFER)
103-
dev_err(&pdev->dev,
103+
dev_err(dev,
104104
"Error: The gpios parameter is missing or invalid.\n");
105105
return ret;
106106
}
107107

108108
memset(&props, 0, sizeof(props));
109109
props.type = BACKLIGHT_RAW;
110110
props.max_brightness = 1;
111-
bl = devm_backlight_device_register(&pdev->dev, dev_name(&pdev->dev),
112-
&pdev->dev, gbl, &gpio_backlight_ops,
113-
&props);
111+
bl = devm_backlight_device_register(dev, dev_name(dev), dev, gbl,
112+
&gpio_backlight_ops, &props);
114113
if (IS_ERR(bl)) {
115-
dev_err(&pdev->dev, "failed to register backlight\n");
114+
dev_err(dev, "failed to register backlight\n");
116115
return PTR_ERR(bl);
117116
}
118117

@@ -122,7 +121,7 @@ static int gpio_backlight_probe(struct platform_device *pdev)
122121
init_brightness = gpio_backlight_get_next_brightness(bl);
123122
ret = gpiod_direction_output(gbl->gpiod, init_brightness);
124123
if (ret) {
125-
dev_err(&pdev->dev, "failed to set initial brightness\n");
124+
dev_err(dev, "failed to set initial brightness\n");
126125
return ret;
127126
}
128127

0 commit comments

Comments
 (0)