rockchip: power & pmic: fix compile warning
authorElaine Zhang <zhangqing@rock-chips.com>
Fri, 26 Feb 2016 20:19:23 +0000 (04:19 +0800)
committerGerrit Code Review <gerrit@rock-chips.com>
Mon, 29 Feb 2016 12:49:13 +0000 (20:49 +0800)
fixed the WARNING: invalid free of devm_ allocated data

Change-Id: I54514cf53a8a0d1f885fd0a17e7f6db7af1d10f9
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
drivers/mfd/rk818.c
drivers/power/bq24296_charger.c
drivers/power/bq27320_battery.c
drivers/power/ricoh619-battery.c
drivers/power/rk30_factory_adc_battery.c
drivers/power/rt5025-battery.c
drivers/regulator/act8846.c
drivers/regulator/act8931.c
drivers/rtc/rtc-ricoh619.c

index ff24a2f87f25a7a727afaf67a291f41e99b87bc9..616d5665059269d5b1f23812da54279b5426d171 100755 (executable)
@@ -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;
 }
index 9bdc35e8877c0d34def6e09adea69050a0e67c3e..09a8d7f887350abdcbb5698f4908188984f2f4c7 100755 (executable)
@@ -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;
 }
 
index 349547f41af6529ad1ddbfe795a8375033914773..7d5e15ac15b37f51b90b91fa18c84834edd75a22 100755 (executable)
@@ -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;
 }
 
index d4da2416ea91ad2136b0be585fef0e683437c047..24e840aef59c853b625a982503bce1e33edee189 100755 (executable)
@@ -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;
 }
index 6ae42e4fe29b453f4e3836b511ab9f2c0715e76e..9d4b7dfc74ae0290b0cb43fcf68615359b544a77 100755 (executable)
@@ -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 @@ err_dcirq_failed:
 
 #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;
 }
index 6b4314e05746d71b8a04c2294bb509652f68ff8c..8403b1da02d11711a106fdac4f297e66bfeea0d5 100644 (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;
 }
index 8c57878ae700ec962fac9d137ddc58558ce51071..3042b0000678d118ec41b1ed8c85a80b38d512b6 100755 (executable)
@@ -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;
 }
index 11ae72354c3a6601d3ae6b4cf841ded7de8464de..150c9cfc060f43dd1d4dfe4f2b9d6a7424e28f13 100755 (executable)
@@ -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;
 }
index 9b16f28f28357548dd7e30f5faf8276efb7b4c8a..603fa1303b0e17654f6d5c6681af717db8e8d9b4 100755 (executable)
@@ -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;
 }