Skip to content

Commit ee7f026

Browse files
andy-shevlag-linaro
authored andcommitted
backlight: mp3309c: Use dev_err_probe() instead of dev_err()
Replace dev_err() with dev_err_probe(). This helps in simplifing code and standardizing the error output. Signed-off-by: Andy Shevchenko <[email protected]> Tested-by: Flavio Suligoi <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent b54c828 commit ee7f026

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

drivers/video/backlight/mp3309c.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,8 @@ static int mp3309c_parse_fwnode(struct mp3309c_chip *chip,
208208
unsigned int num_levels, tmp_value;
209209
struct device *dev = chip->dev;
210210

211-
if (!dev_fwnode(dev)) {
212-
dev_err(dev, "failed to get firmware node\n");
213-
return -ENODEV;
214-
}
211+
if (!dev_fwnode(dev))
212+
return dev_err_probe(dev, -ENODEV, "failed to get firmware node\n");
215213

216214
/*
217215
* Dimming mode: the MP3309C provides two dimming control mode:
@@ -287,8 +285,7 @@ static int mp3309c_parse_fwnode(struct mp3309c_chip *chip,
287285
if (ret)
288286
pdata->default_brightness = pdata->max_brightness;
289287
if (pdata->default_brightness > pdata->max_brightness) {
290-
dev_err(chip->dev,
291-
"default brightness exceeds max brightness\n");
288+
dev_err_probe(dev, -ERANGE, "default brightness exceeds max brightness\n");
292289
pdata->default_brightness = pdata->max_brightness;
293290
}
294291

@@ -329,16 +326,15 @@ static int mp3309c_parse_fwnode(struct mp3309c_chip *chip,
329326

330327
static int mp3309c_probe(struct i2c_client *client)
331328
{
332-
struct mp3309c_platform_data *pdata = dev_get_platdata(&client->dev);
329+
struct device *dev = &client->dev;
330+
struct mp3309c_platform_data *pdata = dev_get_platdata(dev);
333331
struct mp3309c_chip *chip;
334332
struct backlight_properties props;
335333
struct pwm_state pwmstate;
336334
int ret;
337335

338-
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
339-
dev_err(&client->dev, "failed to check i2c functionality\n");
340-
return -EOPNOTSUPP;
341-
}
336+
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
337+
return dev_err_probe(dev, -EOPNOTSUPP, "failed to check i2c functionality\n");
342338

343339
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
344340
if (!chip)

0 commit comments

Comments
 (0)