Skip to content

Commit ad83533

Browse files
himangi774Lee Jones
authored andcommitted
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>
1 parent 2321321 commit ad83533

1 file changed

Lines changed: 4 additions & 13 deletions

File tree

‎drivers/mfd/tps6105x.c‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static int tps6105x_probe(struct i2c_client *client,
141141
int ret;
142142
int i;
143143

144-
tps6105x = kmalloc(sizeof(*tps6105x), GFP_KERNEL);
144+
tps6105x = devm_kmalloc(&client->dev, sizeof(*tps6105x), GFP_KERNEL);
145145
if (!tps6105x)
146146
return -ENOMEM;
147147

@@ -154,7 +154,7 @@ static int tps6105x_probe(struct i2c_client *client,
154154
ret = tps6105x_startup(tps6105x);
155155
if (ret) {
156156
dev_err(&client->dev, "chip initialization failed\n");
157-
goto fail;
157+
return ret;
158158
}
159159

160160
/* Remove warning texts when you implement new cell drivers */
@@ -187,16 +187,8 @@ static int tps6105x_probe(struct i2c_client *client,
187187
tps6105x_cells[i].pdata_size = sizeof(*tps6105x);
188188
}
189189

190-
ret = mfd_add_devices(&client->dev, 0, tps6105x_cells,
191-
ARRAY_SIZE(tps6105x_cells), NULL, 0, NULL);
192-
if (ret)
193-
goto fail;
194-
195-
return 0;
196-
197-
fail:
198-
kfree(tps6105x);
199-
return ret;
190+
return mfd_add_devices(&client->dev, 0, tps6105x_cells,
191+
ARRAY_SIZE(tps6105x_cells), NULL, 0, NULL);
200192
}
201193

202194
static int tps6105x_remove(struct i2c_client *client)
@@ -210,7 +202,6 @@ static int tps6105x_remove(struct i2c_client *client)
210202
TPS6105X_REG0_MODE_MASK,
211203
TPS6105X_MODE_SHUTDOWN << TPS6105X_REG0_MODE_SHIFT);
212204

213-
kfree(tps6105x);
214205
return 0;
215206
}
216207

0 commit comments

Comments
 (0)