regulator: isl6271a-regulator: Use devm_kzalloc()
PATCH 1/3 regulator: isl6271a-regulator: Use devm_kzalloc()
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/isl6271a-regulator.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
drivers/regulator/isl6271a-regulator.c +1 -6
@@ -148,7 +148,7 @@ static int __devinit isl6271a_probe(struct i2c_client *i2c,if (!i2c_check_functionality (i2c->adapter,I2C_FUNC_SMBUS_BYTE_DATA ))return -EIO ; - pmic =kzalloc (sizeof (struct isl_pmic ),GFP_KERNEL ); + pmic =devm_kzalloc (&i2c->dev,sizeof (struct isl_pmic ),GFP_KERNEL );if (!pmic)return -ENOMEM ;
@@ -179,8 +179,6 @@ static int __devinit isl6271a_probe(struct i2c_client *i2c, error:while (--i >=0 )regulator_unregister (pmic->rdev[i]); - -kfree (pmic);return err; }
@@ -191,9 +189,6 @@ static int __devexit isl6271a_remove(struct i2c_client *i2c)for (i =0 ; i <3 ; i++)regulator_unregister (pmic->rdev[i]); - -kfree (pmic); -return 0 ; }
Signature · 1 line
1.7.5.4
PATCH 2/3 regulator: max1586: Use devm_kzalloc()
Signed-off-by Axel Lin <[email protected]>
--- drivers/regulator/max1586.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-)
drivers/regulator/max1586.c +5 -11
@@ -189,18 +189,17 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client,struct max1586_data *max1586;int i, id, ret = -ENOMEM ; - max1586 =kzalloc (sizeof (struct max1586_data ) + + max1586 =devm_kzalloc (&client->dev,sizeof (struct max1586_data ) +sizeof (struct regulator_dev *) * (MAX1586_V6 +1 ),GFP_KERNEL );if (!max1586) - goto out; +return -ENOMEM ; max1586->client = client; -if (!pdata->v3_gain) { - ret = -EINVAL ; - goto out_unmap; - } +if (!pdata->v3_gain) +return -EINVAL ; + max1586->min_uV =MAX1586_V3_MIN_UV /1000 * pdata->v3_gain /1000 ; max1586->max_uV =MAX1586_V3_MAX_UV /1000 * pdata->v3_gain /1000 ;
@@ -234,9 +233,6 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client, err:while (--i >=0 )regulator_unregister (rdev[i]); -out_unmap: -kfree (max1586); -out:return ret; }
@@ -248,8 +244,6 @@ static int __devexit max1586_pmic_remove(struct i2c_client *client)for (i =0 ; i <=MAX1586_V6 ; i++)if (max1586->rdev[i])regulator_unregister (max1586->rdev[i]); -kfree (max1586); -return 0 ; }
Signature · 1 line
1.7.5.4
PATCH 3/3 regulator: max8660: Use devm_kzalloc()
In reply to Axel LinSigned-off-by Axel Lin <[email protected]>
--- drivers/regulator/max8660.c | 20 +++++++------------- 1 files changed, 7 insertions(+), 13 deletions(-)
drivers/regulator/max8660.c +7 -13
@@ -367,16 +367,14 @@ static int __devinit max8660_probe(struct i2c_client *client,if (pdata->num_subdevs >MAX8660_V_END ) {dev_err (&client->dev,"Too many regulators found!\n" ); - goto out; +return -EINVAL ; } max8660 =kzalloc (sizeof (struct max8660 ) +sizeof (struct regulator_dev *) *MAX8660_V_END ,GFP_KERNEL ); -if (!max8660) { - ret = -ENOMEM ; - goto out; - } +if (!max8660) +return -ENOMEM ; max8660->client = client; rdev = max8660->rdev;
@@ -405,7 +403,7 @@ static int __devinit max8660_probe(struct i2c_client *client,for (i =0 ; i < pdata->num_subdevs; i++) {if (!pdata->subdevs[i].platform_data) - goto err_free; + goto err_out; boot_on = pdata->subdevs[i].platform_data->constraints.boot_on;
@@ -431,7 +429,7 @@ static int __devinit max8660_probe(struct i2c_client *client,case MAX8660_V7 :if (!strcmp (i2c_id->name,"max8661" )) {dev_err (&client->dev,"Regulator not on this chip!\n" ); - goto err_free; + goto err_out; }if (boot_on)
@@ -441,7 +439,7 @@ static int __devinit max8660_probe(struct i2c_client *client,default :dev_err (&client->dev,"invalid regulator %s\n" , pdata->subdevs[i].name); - goto err_free; + goto err_out; } }
@@ -469,9 +467,7 @@ static int __devinit max8660_probe(struct i2c_client *client, err_unregister:while (--i >=0 )regulator_unregister (rdev[i]); -err_free: -kfree (max8660); -out: +err_out:return ret; }
@@ -483,8 +479,6 @@ static int __devexit max8660_remove(struct i2c_client *client)for (i =0 ; i <MAX8660_V_END ; i++)if (max8660->rdev[i])regulator_unregister (max8660->rdev[i]); -kfree (max8660); -return 0 ; }
Signature · 1 line
1.7.5.4
Mark Brown
AppliedQuoted 1 line · Axel Lin
Signed-off-by Axel Lin <[email protected]>
Applied all, thanks.