diff options
Diffstat (limited to 'drivers/rtc/rtc-ds1374.c')
| -rw-r--r-- | drivers/rtc/rtc-ds1374.c | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index fef76868aae0..94366e12f40f 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c | |||
| @@ -347,7 +347,7 @@ static int ds1374_probe(struct i2c_client *client, | |||
| 347 | struct ds1374 *ds1374; | 347 | struct ds1374 *ds1374; |
| 348 | int ret; | 348 | int ret; |
| 349 | 349 | ||
| 350 | ds1374 = kzalloc(sizeof(struct ds1374), GFP_KERNEL); | 350 | ds1374 = devm_kzalloc(&client->dev, sizeof(struct ds1374), GFP_KERNEL); |
| 351 | if (!ds1374) | 351 | if (!ds1374) |
| 352 | return -ENOMEM; | 352 | return -ENOMEM; |
| 353 | 353 | ||
| @@ -359,36 +359,27 @@ static int ds1374_probe(struct i2c_client *client, | |||
| 359 | 359 | ||
| 360 | ret = ds1374_check_rtc_status(client); | 360 | ret = ds1374_check_rtc_status(client); |
| 361 | if (ret) | 361 | if (ret) |
| 362 | goto out_free; | 362 | return ret; |
| 363 | 363 | ||
| 364 | if (client->irq > 0) { | 364 | if (client->irq > 0) { |
| 365 | ret = request_irq(client->irq, ds1374_irq, 0, | 365 | ret = devm_request_irq(&client->dev, client->irq, ds1374_irq, 0, |
| 366 | "ds1374", client); | 366 | "ds1374", client); |
| 367 | if (ret) { | 367 | if (ret) { |
| 368 | dev_err(&client->dev, "unable to request IRQ\n"); | 368 | dev_err(&client->dev, "unable to request IRQ\n"); |
| 369 | goto out_free; | 369 | return ret; |
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | device_set_wakeup_capable(&client->dev, 1); | 372 | device_set_wakeup_capable(&client->dev, 1); |
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | ds1374->rtc = rtc_device_register(client->name, &client->dev, | 375 | ds1374->rtc = devm_rtc_device_register(&client->dev, client->name, |
| 376 | &ds1374_rtc_ops, THIS_MODULE); | 376 | &ds1374_rtc_ops, THIS_MODULE); |
| 377 | if (IS_ERR(ds1374->rtc)) { | 377 | if (IS_ERR(ds1374->rtc)) { |
| 378 | ret = PTR_ERR(ds1374->rtc); | ||
| 379 | dev_err(&client->dev, "unable to register the class device\n"); | 378 | dev_err(&client->dev, "unable to register the class device\n"); |
| 380 | goto out_irq; | 379 | return PTR_ERR(ds1374->rtc); |
| 381 | } | 380 | } |
| 382 | 381 | ||
| 383 | return 0; | 382 | return 0; |
| 384 | |||
| 385 | out_irq: | ||
| 386 | if (client->irq > 0) | ||
| 387 | free_irq(client->irq, client); | ||
| 388 | |||
| 389 | out_free: | ||
| 390 | kfree(ds1374); | ||
| 391 | return ret; | ||
| 392 | } | 383 | } |
| 393 | 384 | ||
| 394 | static int ds1374_remove(struct i2c_client *client) | 385 | static int ds1374_remove(struct i2c_client *client) |
| @@ -400,16 +391,14 @@ static int ds1374_remove(struct i2c_client *client) | |||
| 400 | ds1374->exiting = 1; | 391 | ds1374->exiting = 1; |
| 401 | mutex_unlock(&ds1374->mutex); | 392 | mutex_unlock(&ds1374->mutex); |
| 402 | 393 | ||
| 403 | free_irq(client->irq, client); | 394 | devm_free_irq(&client->dev, client->irq, client); |
| 404 | cancel_work_sync(&ds1374->work); | 395 | cancel_work_sync(&ds1374->work); |
| 405 | } | 396 | } |
| 406 | 397 | ||
| 407 | rtc_device_unregister(ds1374->rtc); | ||
| 408 | kfree(ds1374); | ||
| 409 | return 0; | 398 | return 0; |
| 410 | } | 399 | } |
| 411 | 400 | ||
| 412 | #ifdef CONFIG_PM | 401 | #ifdef CONFIG_PM_SLEEP |
| 413 | static int ds1374_suspend(struct device *dev) | 402 | static int ds1374_suspend(struct device *dev) |
| 414 | { | 403 | { |
| 415 | struct i2c_client *client = to_i2c_client(dev); | 404 | struct i2c_client *client = to_i2c_client(dev); |
| @@ -427,19 +416,15 @@ static int ds1374_resume(struct device *dev) | |||
| 427 | disable_irq_wake(client->irq); | 416 | disable_irq_wake(client->irq); |
| 428 | return 0; | 417 | return 0; |
| 429 | } | 418 | } |
| 419 | #endif | ||
| 430 | 420 | ||
| 431 | static SIMPLE_DEV_PM_OPS(ds1374_pm, ds1374_suspend, ds1374_resume); | 421 | static SIMPLE_DEV_PM_OPS(ds1374_pm, ds1374_suspend, ds1374_resume); |
| 432 | 422 | ||
| 433 | #define DS1374_PM (&ds1374_pm) | ||
| 434 | #else | ||
| 435 | #define DS1374_PM NULL | ||
| 436 | #endif | ||
| 437 | |||
| 438 | static struct i2c_driver ds1374_driver = { | 423 | static struct i2c_driver ds1374_driver = { |
| 439 | .driver = { | 424 | .driver = { |
| 440 | .name = "rtc-ds1374", | 425 | .name = "rtc-ds1374", |
| 441 | .owner = THIS_MODULE, | 426 | .owner = THIS_MODULE, |
| 442 | .pm = DS1374_PM, | 427 | .pm = &ds1374_pm, |
| 443 | }, | 428 | }, |
| 444 | .probe = ds1374_probe, | 429 | .probe = ds1374_probe, |
| 445 | .remove = ds1374_remove, | 430 | .remove = ds1374_remove, |
