diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-04-29 19:20:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:38 -0400 |
commit | d6fbdc34c2eb7ad1309eaf83ead60dabf6e85352 (patch) | |
tree | d72d5dd3b5f32ebcf9e0aa3ce2f0209bdb151007 /drivers/rtc | |
parent | 76753caf7080a0ea28ac1567c919afe5ab2e0e79 (diff) |
rtc: rtc-pcf8563: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler.
Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-pcf8563.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/drivers/rtc/rtc-pcf8563.c b/drivers/rtc/rtc-pcf8563.c index f7daf18a112e..97b354a26a44 100644 --- a/drivers/rtc/rtc-pcf8563.c +++ b/drivers/rtc/rtc-pcf8563.c | |||
@@ -245,14 +245,13 @@ static int pcf8563_probe(struct i2c_client *client, | |||
245 | { | 245 | { |
246 | struct pcf8563 *pcf8563; | 246 | struct pcf8563 *pcf8563; |
247 | 247 | ||
248 | int err = 0; | ||
249 | |||
250 | dev_dbg(&client->dev, "%s\n", __func__); | 248 | dev_dbg(&client->dev, "%s\n", __func__); |
251 | 249 | ||
252 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) | 250 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) |
253 | return -ENODEV; | 251 | return -ENODEV; |
254 | 252 | ||
255 | pcf8563 = kzalloc(sizeof(struct pcf8563), GFP_KERNEL); | 253 | pcf8563 = devm_kzalloc(&client->dev, sizeof(struct pcf8563), |
254 | GFP_KERNEL); | ||
256 | if (!pcf8563) | 255 | if (!pcf8563) |
257 | return -ENOMEM; | 256 | return -ENOMEM; |
258 | 257 | ||
@@ -260,31 +259,18 @@ static int pcf8563_probe(struct i2c_client *client, | |||
260 | 259 | ||
261 | i2c_set_clientdata(client, pcf8563); | 260 | i2c_set_clientdata(client, pcf8563); |
262 | 261 | ||
263 | pcf8563->rtc = rtc_device_register(pcf8563_driver.driver.name, | 262 | pcf8563->rtc = devm_rtc_device_register(&client->dev, |
264 | &client->dev, &pcf8563_rtc_ops, THIS_MODULE); | 263 | pcf8563_driver.driver.name, |
264 | &pcf8563_rtc_ops, THIS_MODULE); | ||
265 | 265 | ||
266 | if (IS_ERR(pcf8563->rtc)) { | 266 | if (IS_ERR(pcf8563->rtc)) |
267 | err = PTR_ERR(pcf8563->rtc); | 267 | return PTR_ERR(pcf8563->rtc); |
268 | goto exit_kfree; | ||
269 | } | ||
270 | 268 | ||
271 | return 0; | 269 | return 0; |
272 | |||
273 | exit_kfree: | ||
274 | kfree(pcf8563); | ||
275 | |||
276 | return err; | ||
277 | } | 270 | } |
278 | 271 | ||
279 | static int pcf8563_remove(struct i2c_client *client) | 272 | static int pcf8563_remove(struct i2c_client *client) |
280 | { | 273 | { |
281 | struct pcf8563 *pcf8563 = i2c_get_clientdata(client); | ||
282 | |||
283 | if (pcf8563->rtc) | ||
284 | rtc_device_unregister(pcf8563->rtc); | ||
285 | |||
286 | kfree(pcf8563); | ||
287 | |||
288 | return 0; | 274 | return 0; |
289 | } | 275 | } |
290 | 276 | ||