mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-24 01:09:38 -05:00
mfd: tps6105x: Use managed resources when allocating memory
This patch introduces the use of devm_kzalloc instead of the corresponding unmanaged version and does away with the kfrees in the probe and remove functions. Also, a label is done away with. Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
parent
23213218cb
commit
ad83533a63
1 changed files with 4 additions and 13 deletions
|
@ -141,7 +141,7 @@ static int tps6105x_probe(struct i2c_client *client,
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
tps6105x = kmalloc(sizeof(*tps6105x), GFP_KERNEL);
|
tps6105x = devm_kmalloc(&client->dev, sizeof(*tps6105x), GFP_KERNEL);
|
||||||
if (!tps6105x)
|
if (!tps6105x)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ static int tps6105x_probe(struct i2c_client *client,
|
||||||
ret = tps6105x_startup(tps6105x);
|
ret = tps6105x_startup(tps6105x);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&client->dev, "chip initialization failed\n");
|
dev_err(&client->dev, "chip initialization failed\n");
|
||||||
goto fail;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove warning texts when you implement new cell drivers */
|
/* Remove warning texts when you implement new cell drivers */
|
||||||
|
@ -187,16 +187,8 @@ static int tps6105x_probe(struct i2c_client *client,
|
||||||
tps6105x_cells[i].pdata_size = sizeof(*tps6105x);
|
tps6105x_cells[i].pdata_size = sizeof(*tps6105x);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = mfd_add_devices(&client->dev, 0, tps6105x_cells,
|
return mfd_add_devices(&client->dev, 0, tps6105x_cells,
|
||||||
ARRAY_SIZE(tps6105x_cells), NULL, 0, NULL);
|
ARRAY_SIZE(tps6105x_cells), NULL, 0, NULL);
|
||||||
if (ret)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
fail:
|
|
||||||
kfree(tps6105x);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tps6105x_remove(struct i2c_client *client)
|
static int tps6105x_remove(struct i2c_client *client)
|
||||||
|
@ -210,7 +202,6 @@ static int tps6105x_remove(struct i2c_client *client)
|
||||||
TPS6105X_REG0_MODE_MASK,
|
TPS6105X_REG0_MODE_MASK,
|
||||||
TPS6105X_MODE_SHUTDOWN << TPS6105X_REG0_MODE_SHIFT);
|
TPS6105X_MODE_SHUTDOWN << TPS6105X_REG0_MODE_SHIFT);
|
||||||
|
|
||||||
kfree(tps6105x);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue