backlight: fix lm3697 probe fail panic

[    3.228313]  ti_lmu_backlight_probe+0x63c/0x6e4 [leds_lm3697]
[    3.228321]  platform_drv_probe+0xac/0xf0
[    3.228326]  really_probe+0x260/0x660
[    3.228330]  driver_probe_device+0x64/0x100
[    3.228335]  device_driver_attach+0x6c/0xac
[    3.228339]  __driver_attach+0xdc/0x184
[    3.228344]  bus_for_each_dev+0x9c/0x108
[    3.228348]  driver_attach+0x24/0x30
[    3.228352]  bus_add_driver+0x100/0x1e0
[    3.228357]  driver_register+0x78/0x114
[    3.228361]  __platform_driver_register+0x44/0x50
[    3.228370]  ti_lmu_probe+0x18c/0x1e4 [leds_lm3697]
[    3.228377]  i2c_device_probe+0x260/0x308

Change-Id: I470205dc144ef3219bdf4000ca197f9221f14f21
Signed-off-by: tanhua1 <tanhua1@lenovo.com>
Reviewed-on: https://gerrit.mot.com/2015311
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
Reviewed-by: Yeqing Wang <wangyq13@motorola.com>
This commit is contained in:
tanhua1 2021-07-16 20:37:39 +08:00 • committed by Hua Tan
commit 5981ab07e5

View file

@ -780,7 +780,7 @@ ti_lmu_backlight_register(struct device *dev, struct ti_lmu *lmu,
if (ret < 0)
{
pr_err("%s : ID idenfy failed\n", __func__);
goto err_id;
goto err_init;
}
for (i = 0; i < chip->num_backlights; i++) {
@ -788,12 +788,12 @@ ti_lmu_backlight_register(struct device *dev, struct ti_lmu *lmu,
ret = ti_lmu_backlight_configure(each);
if (ret) {
dev_err(dev, "[bkl] Backlight config err: %d\n", ret);
goto err_each;
goto err_init;
}
ret = ti_lmu_backlight_add_device(dev, each);
if (ret) {
dev_err(dev, "[bkl] Backlight device err: %d\n", ret);
goto err_add;
goto err_init;
}
}
@ -818,19 +818,16 @@ ti_lmu_backlight_register(struct device *dev, struct ti_lmu *lmu,
return chip;
err_id:
gpio_free(chip->lmu->en_gpio);
kfree(chip);
err_init:
kfree(chip);
err_add:
kfree(dev);
kfree(each);
err_each:
kfree(each);
if(chip->lmu_bl)
devm_kfree(dev, chip->lmu_bl);
if(chip)
devm_kfree(dev, chip);
err_ein:
gpio_free(lmu->en_gpio);
return ERR_PTR(-EINVAL);
err_eno:
gpio_free(lmu->en_gpio);
return ERR_PTR(-ENOMEM);
}
@ -874,8 +871,10 @@ static int ti_lmu_backlight_probe(struct platform_device *pdev)
chip = ti_lmu_backlight_register(dev, lmu, &lmu_bl_cfg[pdev->id]);
if (IS_ERR(chip))
return PTR_ERR(chip);
if (IS_ERR(chip)) {
pr_err("[bkl] %s error bkl register\n", __func__);
return -ENODEV;
}
/*
* Notifier callback is required because backlight device needs
* reconfiguration after fault detection procedure is done by