diff options
Diffstat (limited to 'drivers/leds/leds-lm3692x.c')
-rw-r--r-- | drivers/leds/leds-lm3692x.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c index 3d381f2f73d0..8b408102e138 100644 --- a/drivers/leds/leds-lm3692x.c +++ b/drivers/leds/leds-lm3692x.c @@ -174,19 +174,20 @@ static int lm3692x_brightness_set(struct led_classdev *led_cdev, ret = lm3692x_fault_check(led); if (ret) { - dev_err(&led->client->dev, "Cannot read/clear faults\n"); + dev_err(&led->client->dev, "Cannot read/clear faults: %d\n", + ret); goto out; } ret = regmap_write(led->regmap, LM3692X_BRT_MSB, brt_val); if (ret) { - dev_err(&led->client->dev, "Cannot write MSB\n"); + dev_err(&led->client->dev, "Cannot write MSB: %d\n", ret); goto out; } ret = regmap_write(led->regmap, LM3692X_BRT_LSB, led_brightness_lsb); if (ret) { - dev_err(&led->client->dev, "Cannot write LSB\n"); + dev_err(&led->client->dev, "Cannot write LSB: %d\n", ret); goto out; } out: @@ -197,13 +198,13 @@ out: static int lm3692x_init(struct lm3692x_led *led) { int enable_state; - int ret; + int ret, reg_ret; if (led->regulator) { ret = regulator_enable(led->regulator); if (ret) { dev_err(&led->client->dev, - "Failed to enable regulator\n"); + "Failed to enable regulator: %d\n", ret); return ret; } } @@ -213,7 +214,8 @@ static int lm3692x_init(struct lm3692x_led *led) ret = lm3692x_fault_check(led); if (ret) { - dev_err(&led->client->dev, "Cannot read/clear faults\n"); + dev_err(&led->client->dev, "Cannot read/clear faults: %d\n", + ret); goto out; } @@ -248,9 +250,9 @@ static int lm3692x_init(struct lm3692x_led *led) goto out; ret = regmap_write(led->regmap, LM3692X_BOOST_CTRL, - LM3692X_BRHT_MODE_RAMP_MULTI | - LM3692X_BL_ADJ_POL | - LM3692X_RAMP_RATE_250us); + LM3692X_BOOST_SW_1MHZ | + LM3692X_BOOST_SW_NO_SHIFT | + LM3692X_OCP_PROT_1_5A); if (ret) goto out; @@ -267,7 +269,7 @@ static int lm3692x_init(struct lm3692x_led *led) goto out; ret = regmap_write(led->regmap, LM3692X_BRT_CTRL, - LM3692X_BL_ADJ_POL | LM3692X_PWM_HYSTER_4LSB); + LM3692X_BL_ADJ_POL | LM3692X_RAMP_EN); if (ret) goto out; @@ -311,14 +313,15 @@ out: gpiod_direction_output(led->enable_gpio, 0); if (led->regulator) { - ret = regulator_disable(led->regulator); - if (ret) + reg_ret = regulator_disable(led->regulator); + if (reg_ret) dev_err(&led->client->dev, - "Failed to disable regulator\n"); + "Failed to disable regulator: %d\n", reg_ret); } return ret; } + static int lm3692x_probe_dt(struct lm3692x_led *led) { struct fwnode_handle *child = NULL; @@ -334,9 +337,18 @@ static int lm3692x_probe_dt(struct lm3692x_led *led) return ret; } - led->regulator = devm_regulator_get(&led->client->dev, "vled"); - if (IS_ERR(led->regulator)) + led->regulator = devm_regulator_get_optional(&led->client->dev, "vled"); + if (IS_ERR(led->regulator)) { + ret = PTR_ERR(led->regulator); + if (ret != -ENODEV) { + if (ret != -EPROBE_DEFER) + dev_err(&led->client->dev, + "Failed to get vled regulator: %d\n", + ret); + return ret; + } led->regulator = NULL; + } child = device_get_next_child_node(&led->client->dev, child); if (!child) { @@ -409,7 +421,8 @@ static int lm3692x_remove(struct i2c_client *client) ret = regmap_update_bits(led->regmap, LM3692X_EN, LM3692X_DEVICE_EN, 0); if (ret) { - dev_err(&led->client->dev, "Failed to disable regulator\n"); + dev_err(&led->client->dev, "Failed to disable regulator: %d\n", + ret); return ret; } @@ -420,7 +433,7 @@ static int lm3692x_remove(struct i2c_client *client) ret = regulator_disable(led->regulator); if (ret) dev_err(&led->client->dev, - "Failed to disable regulator\n"); + "Failed to disable regulator: %d\n", ret); } mutex_destroy(&led->lock); |