rockchip: power & pmic: fix compile warning

fixed the WARNING: invalid free of devm_ allocated data

Change-Id: I54514cf53a8a0d1f885fd0a17e7f6db7af1d10f9
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
This commit is contained in:
Elaine Zhang 2016-02-27 04:19:23 +08:00 committed by Gerrit Code Review
parent 6014197ab1
commit c2bdb4abe8
9 changed files with 17 additions and 49 deletions

View File

@ -1381,7 +1381,6 @@ static int rk818_i2c_remove(struct i2c_client *i2c)
if (rk818->rdev[i])
regulator_unregister(rk818->rdev[i]);
i2c_set_clientdata(i2c, NULL);
kfree(rk818);
return 0;
}

View File

@ -608,8 +608,7 @@ static void bq24296_battery_shutdown(struct i2c_client *client)
static int bq24296_battery_remove(struct i2c_client *client)
{
struct bq24296_device_info *di = i2c_get_clientdata(client);
kfree(di);
return 0;
}

View File

@ -1300,22 +1300,16 @@ static int bq27320_battery_probe(struct i2c_client *client,
bq27320_powersupply_init(di);
retval = power_supply_register(&client->dev, &di->bat);
if (retval) {
if (retval)
dev_err(&client->dev, "failed to register battery\n");
goto batt_failed_4;
}
retval = power_supply_register(&client->dev, &di->usb);
if (retval) {
if (retval)
dev_err(&client->dev, "failed to register ac\n");
goto batt_failed_4;
}
retval = power_supply_register(&client->dev, &di->ac);
if (retval) {
if (retval)
dev_err(&client->dev, "failed to register ac\n");
goto batt_failed_4;
}
g_bq27320_i2c_client = client;
@ -1333,8 +1327,6 @@ static int bq27320_battery_probe(struct i2c_client *client,
return 0;
batt_failed_4:
kfree(di);
batt_failed_3:
driver_remove_file(&(bq27320_battery_driver.driver), &driver_attr_state);
batt_failed_2:
@ -1354,7 +1346,6 @@ static int bq27320_battery_remove(struct i2c_client *client)
kfree(di->bat.name);
kfree(di->usb.name);
kfree(di->ac.name);
kfree(di);
return 0;
}

View File

@ -4504,7 +4504,6 @@ static int ricoh619_battery_probe(struct platform_device *pdev)
return 0;
out:
kfree(info);
return ret;
}
@ -4608,7 +4607,6 @@ static int ricoh619_battery_remove(struct platform_device *pdev)
#endif
power_supply_unregister(&info->battery);
kfree(info);
platform_set_drvdata(pdev, NULL);
return 0;
}

View File

@ -2285,17 +2285,14 @@ static int rk30_adc_battery_probe(struct platform_device *pdev)
gSecondsCnt = get_seconds();
/*data = kzalloc(sizeof(*data), GFP_KERNEL);*/
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (data == NULL) {
if (data == NULL)
ret = -ENOMEM;
goto err_data_alloc_failed;
}
/*pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);*/
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (pdata == NULL) {
if (pdata == NULL)
ret = -ENOMEM;
goto err_pdata_alloc_failed;
}
memset(data, 0, sizeof(struct rk30_adc_battery_data));
gBatteryData = data;
platform_set_drvdata(pdev, data);
@ -2470,12 +2467,6 @@ static int rk30_adc_battery_probe(struct platform_device *pdev)
#endif
err_io_init:
err_pdata_alloc_failed:
kfree(pdata);
err_data_alloc_failed:
kfree(data);
printk("rk30_adc_battery: error!\n");
return ret;
@ -2500,8 +2491,6 @@ static int rk30_adc_battery_remove(struct platform_device *pdev)
power_supply_unregister(&data ->bat);
if (batt_gpio_is_valid(pdata->dc_det_pin))
free_irq(gpio_to_irq(pdata->dc_det_pin), data);
kfree(data);
return 0;
}

View File

@ -1716,7 +1716,6 @@ static int rt5025_battery_remove(struct platform_device *pdev)
power_supply_unregister(&bi->battery);
cancel_delayed_work(&bi->monitor_work);
wake_lock_destroy(&bi->monitor_wake_lock);
kfree(bi);
RTINFO("\n");
return 0;
}

View File

@ -954,7 +954,10 @@ static int act8846_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id
if (pdev) {
act8846->num_regulators = act8846_NUM_REGULATORS;
act8846->rdev = kcalloc(act8846_NUM_REGULATORS,sizeof(struct regulator_dev *), GFP_KERNEL);
act8846->rdev = devm_kcalloc(act8846->dev,
act8846_NUM_REGULATORS,
sizeof(struct regulator_dev *),
GFP_KERNEL);
if (!act8846->rdev) {
return -ENOMEM;
}
@ -1012,9 +1015,7 @@ static int act8846_i2c_remove(struct i2c_client *i2c)
for (i = 0; i < act8846->num_regulators; i++)
if (act8846->rdev[i])
regulator_unregister(act8846->rdev[i]);
kfree(act8846->rdev);
i2c_set_clientdata(i2c, NULL);
kfree(act8846);
return 0;
}

View File

@ -775,9 +775,10 @@ static int act8931_i2c_probe(struct i2c_client *i2c,
if (pdata) {
act8931->num_regulators = ACT8931_NUM_REGULATORS;
act8931->rdev = kcalloc(ACT8931_NUM_REGULATORS,
sizeof(struct regulator_dev *),
GFP_KERNEL);
act8931->rdev = devm_kcalloc(act8931->dev,
ACT8931_NUM_REGULATORS,
sizeof(struct regulator_dev *),
GFP_KERNEL);
if (!act8931->rdev)
return -ENOMEM;
@ -857,9 +858,7 @@ static int act8931_i2c_remove(struct i2c_client *i2c)
for (i = 0; i < act8931->num_regulators; i++)
if (act8931->rdev[i])
regulator_unregister(act8931->rdev[i]);
kfree(act8931->rdev);
i2c_set_clientdata(i2c, NULL);
kfree(act8931);
return 0;
}

View File

@ -750,7 +750,7 @@ static int ricoh619_rtc_probe(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, 1);
// printk(KERN_INFO "PMU: %s register rtc device \n", __func__);
rtc->rtc = rtc_device_register(pdev->name, &pdev->dev,
rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
&ricoh619_rtc_ops, THIS_MODULE);
// set interrupt and enable it
@ -800,18 +800,11 @@ static int ricoh619_rtc_probe(struct platform_device *pdev)
return 0;
fail:
if (!IS_ERR_OR_NULL(rtc->rtc))
rtc_device_unregister(rtc->rtc);
kfree(rtc);
return err;
}
static int ricoh619_rtc_remove(struct platform_device *pdev)
{
struct ricoh619_rtc *rtc = dev_get_drvdata(&pdev->dev);
rtc_device_unregister(rtc->rtc);
kfree(rtc);
return 0;
}