diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2014-07-19 04:30:10 -0400 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2014-07-25 10:31:47 -0400 |
commit | ad83533a634b82c3a291e8a00c778bb6bcd7862b (patch) | |
tree | 3e79d86d45474f6419fc8dde65b48957cc291717 /drivers/mfd | |
parent | 23213218cb08d6de62996aab2241a3251ebbce70 (diff) |
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>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/tps6105x.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/mfd/tps6105x.c b/drivers/mfd/tps6105x.c index b5dfa6e4e692..5de95c265c1a 100644 --- a/drivers/mfd/tps6105x.c +++ b/drivers/mfd/tps6105x.c | |||
@@ -141,7 +141,7 @@ static int tps6105x_probe(struct i2c_client *client, | |||
141 | int ret; | 141 | int ret; |
142 | int i; | 142 | int i; |
143 | 143 | ||
144 | tps6105x = kmalloc(sizeof(*tps6105x), GFP_KERNEL); | 144 | tps6105x = devm_kmalloc(&client->dev, sizeof(*tps6105x), GFP_KERNEL); |
145 | if (!tps6105x) | 145 | if (!tps6105x) |
146 | return -ENOMEM; | 146 | return -ENOMEM; |
147 | 147 | ||
@@ -154,7 +154,7 @@ static int tps6105x_probe(struct i2c_client *client, | |||
154 | ret = tps6105x_startup(tps6105x); | 154 | ret = tps6105x_startup(tps6105x); |
155 | if (ret) { | 155 | if (ret) { |
156 | dev_err(&client->dev, "chip initialization failed\n"); | 156 | dev_err(&client->dev, "chip initialization failed\n"); |
157 | goto fail; | 157 | return ret; |
158 | } | 158 | } |
159 | 159 | ||
160 | /* Remove warning texts when you implement new cell drivers */ | 160 | /* Remove warning texts when you implement new cell drivers */ |
@@ -187,16 +187,8 @@ static int tps6105x_probe(struct i2c_client *client, | |||
187 | tps6105x_cells[i].pdata_size = sizeof(*tps6105x); | 187 | tps6105x_cells[i].pdata_size = sizeof(*tps6105x); |
188 | } | 188 | } |
189 | 189 | ||
190 | ret = mfd_add_devices(&client->dev, 0, tps6105x_cells, | 190 | return mfd_add_devices(&client->dev, 0, tps6105x_cells, |
191 | ARRAY_SIZE(tps6105x_cells), NULL, 0, NULL); | 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; | ||
200 | } | 192 | } |
201 | 193 | ||
202 | static int tps6105x_remove(struct i2c_client *client) | 194 | static int tps6105x_remove(struct i2c_client *client) |
@@ -210,7 +202,6 @@ static int tps6105x_remove(struct i2c_client *client) | |||
210 | TPS6105X_REG0_MODE_MASK, | 202 | TPS6105X_REG0_MODE_MASK, |
211 | TPS6105X_MODE_SHUTDOWN << TPS6105X_REG0_MODE_SHIFT); | 203 | TPS6105X_MODE_SHUTDOWN << TPS6105X_REG0_MODE_SHIFT); |
212 | 204 | ||
213 | kfree(tps6105x); | ||
214 | return 0; | 205 | return 0; |
215 | } | 206 | } |
216 | 207 | ||