Skip to content

Commit d37831e

Browse files
andy-shevlag-linaro
authored andcommitted
backlight: mp3309c: Utilise temporary variable for struct device
We have a temporary variable to keep pointer to struct device. Utilise it where it makes sense. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Tested-by: Flavio Suligoi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent ee7f026 commit d37831e

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

drivers/video/backlight/mp3309c.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,9 @@ static int mp3309c_parse_fwnode(struct mp3309c_chip *chip,
222222
*/
223223
pdata->dimming_mode = DIMMING_ANALOG_I2C;
224224
if (device_property_present(dev, "pwms")) {
225-
chip->pwmd = devm_pwm_get(chip->dev, NULL);
225+
chip->pwmd = devm_pwm_get(dev, NULL);
226226
if (IS_ERR(chip->pwmd))
227-
return dev_err_probe(chip->dev, PTR_ERR(chip->pwmd),
228-
"error getting pwm data\n");
227+
return dev_err_probe(dev, PTR_ERR(chip->pwmd), "error getting pwm data\n");
229228
pdata->dimming_mode = DIMMING_PWM;
230229
pwm_apply_args(chip->pwmd);
231230
}
@@ -243,11 +242,9 @@ static int mp3309c_parse_fwnode(struct mp3309c_chip *chip,
243242
num_levels = ANALOG_I2C_NUM_LEVELS;
244243

245244
/* Enable GPIO used in I2C dimming mode only */
246-
chip->enable_gpio = devm_gpiod_get(chip->dev, "enable",
247-
GPIOD_OUT_HIGH);
245+
chip->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH);
248246
if (IS_ERR(chip->enable_gpio))
249-
return dev_err_probe(chip->dev,
250-
PTR_ERR(chip->enable_gpio),
247+
return dev_err_probe(dev, PTR_ERR(chip->enable_gpio),
251248
"error getting enable gpio\n");
252249
} else {
253250
/*
@@ -265,8 +262,7 @@ static int mp3309c_parse_fwnode(struct mp3309c_chip *chip,
265262
}
266263

267264
/* Fill brightness levels array */
268-
pdata->levels = devm_kcalloc(chip->dev, num_levels,
269-
sizeof(*pdata->levels), GFP_KERNEL);
265+
pdata->levels = devm_kcalloc(dev, num_levels, sizeof(*pdata->levels), GFP_KERNEL);
270266
if (!pdata->levels)
271267
return -ENOMEM;
272268
if (device_property_present(dev, "brightness-levels")) {
@@ -336,21 +332,21 @@ static int mp3309c_probe(struct i2c_client *client)
336332
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
337333
return dev_err_probe(dev, -EOPNOTSUPP, "failed to check i2c functionality\n");
338334

339-
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
335+
chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
340336
if (!chip)
341337
return -ENOMEM;
342338

343-
chip->dev = &client->dev;
339+
chip->dev = dev;
344340

345341
chip->regmap = devm_regmap_init_i2c(client, &mp3309c_regmap);
346342
if (IS_ERR(chip->regmap))
347-
return dev_err_probe(&client->dev, PTR_ERR(chip->regmap),
343+
return dev_err_probe(dev, PTR_ERR(chip->regmap),
348344
"failed to allocate register map\n");
349345

350346
i2c_set_clientdata(client, chip);
351347

352348
if (!pdata) {
353-
pdata = devm_kzalloc(chip->dev, sizeof(*pdata), GFP_KERNEL);
349+
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
354350
if (!pdata)
355351
return -ENOMEM;
356352

@@ -367,11 +363,10 @@ static int mp3309c_probe(struct i2c_client *client)
367363
props.type = BACKLIGHT_RAW;
368364
props.power = FB_BLANK_UNBLANK;
369365
props.fb_blank = FB_BLANK_UNBLANK;
370-
chip->bl = devm_backlight_device_register(chip->dev, "mp3309c",
371-
chip->dev, chip,
366+
chip->bl = devm_backlight_device_register(dev, "mp3309c", dev, chip,
372367
&mp3309c_bl_ops, &props);
373368
if (IS_ERR(chip->bl))
374-
return dev_err_probe(chip->dev, PTR_ERR(chip->bl),
369+
return dev_err_probe(dev, PTR_ERR(chip->bl),
375370
"error registering backlight device\n");
376371

377372
/* In PWM dimming mode, enable pwm device */
@@ -383,8 +378,7 @@ static int mp3309c_probe(struct i2c_client *client)
383378
pwmstate.enabled = true;
384379
ret = pwm_apply_might_sleep(chip->pwmd, &pwmstate);
385380
if (ret)
386-
return dev_err_probe(chip->dev, ret,
387-
"error setting pwm device\n");
381+
return dev_err_probe(dev, ret, "error setting pwm device\n");
388382
}
389383

390384
chip->pdata->status = FIRST_POWER_ON;

0 commit comments

Comments
 (0)