Skip to content

Commit

Permalink
backlight: lp855x: Add dev helper variable to lp855x_probe()
Browse files Browse the repository at this point in the history
Add a dev local variable to the lp855x_probe(), to replace "&cl->dev"
and "lp->dev" in various places.

Also switch to dev_err_probe() in one case which takes care of not
printing -EPROBE_DEFER errors for us.

This is mostly a preparation for adding ACPI enumeration support which
will use the new "dev" variable more.

Signed-off-by: Hans de Goede <[email protected]>
Reviewed-by: Daniel Thompson <[email protected]>
Signed-off-by: Lee Jones <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
jwrdegoede authored and Lee Jones committed Dec 22, 2021
1 parent dec5779 commit 92add94
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions drivers/video/backlight/lp855x_bl.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,21 +381,22 @@ static int lp855x_parse_dt(struct lp855x *lp)

static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
{
struct device *dev = &cl->dev;
struct lp855x *lp;
int ret;

if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
return -EIO;

lp = devm_kzalloc(&cl->dev, sizeof(struct lp855x), GFP_KERNEL);
lp = devm_kzalloc(dev, sizeof(struct lp855x), GFP_KERNEL);
if (!lp)
return -ENOMEM;

lp->client = cl;
lp->dev = &cl->dev;
lp->dev = dev;
lp->chipname = id->name;
lp->chip_id = id->driver_data;
lp->pdata = dev_get_platdata(&cl->dev);
lp->pdata = dev_get_platdata(dev);

switch (lp->chip_id) {
case LP8550:
Expand Down Expand Up @@ -424,38 +425,35 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
else
lp->mode = REGISTER_BASED;

lp->supply = devm_regulator_get(lp->dev, "power");
lp->supply = devm_regulator_get(dev, "power");
if (IS_ERR(lp->supply)) {
if (PTR_ERR(lp->supply) == -EPROBE_DEFER)
return -EPROBE_DEFER;
lp->supply = NULL;
}

lp->enable = devm_regulator_get_optional(lp->dev, "enable");
lp->enable = devm_regulator_get_optional(dev, "enable");
if (IS_ERR(lp->enable)) {
ret = PTR_ERR(lp->enable);
if (ret == -ENODEV) {
lp->enable = NULL;
} else {
if (ret != -EPROBE_DEFER)
dev_err(lp->dev, "error getting enable regulator: %d\n",
ret);
return ret;
return dev_err_probe(dev, ret, "getting enable regulator\n");
}
}

if (lp->supply) {
ret = regulator_enable(lp->supply);
if (ret < 0) {
dev_err(&cl->dev, "failed to enable supply: %d\n", ret);
dev_err(dev, "failed to enable supply: %d\n", ret);
return ret;
}
}

if (lp->enable) {
ret = regulator_enable(lp->enable);
if (ret < 0) {
dev_err(lp->dev, "failed to enable vddio: %d\n", ret);
dev_err(dev, "failed to enable vddio: %d\n", ret);
goto disable_supply;
}

Expand All @@ -470,20 +468,19 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)

ret = lp855x_configure(lp);
if (ret) {
dev_err(lp->dev, "device config err: %d", ret);
dev_err(dev, "device config err: %d", ret);
goto disable_vddio;
}

ret = lp855x_backlight_register(lp);
if (ret) {
dev_err(lp->dev,
"failed to register backlight. err: %d\n", ret);
dev_err(dev, "failed to register backlight. err: %d\n", ret);
goto disable_vddio;
}

ret = sysfs_create_group(&lp->dev->kobj, &lp855x_attr_group);
ret = sysfs_create_group(&dev->kobj, &lp855x_attr_group);
if (ret) {
dev_err(lp->dev, "failed to register sysfs. err: %d\n", ret);
dev_err(dev, "failed to register sysfs. err: %d\n", ret);
goto disable_vddio;
}

Expand Down

0 comments on commit 92add94

Please sign in to comment.