summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ds1390.c
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-04-29 16:20:39 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 18:28:37 -0700
commit1ce95ba7441240fef3becbf0d5be98141c45f0a5 (patch)
tree2408eb7c93db302c7467bb070d09417cb5912361 /drivers/rtc/rtc-ds1390.c
parent061d698e208efb8036673295b5be3b0c8be75082 (diff)
downloadlinux-1ce95ba7441240fef3becbf0d5be98141c45f0a5.tar.bz2
rtc: rtc-ds1390: 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/rtc-ds1390.c')
-rw-r--r--drivers/rtc/rtc-ds1390.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/rtc/rtc-ds1390.c b/drivers/rtc/rtc-ds1390.c
index 11b70763bb53..289af419dff4 100644
--- a/drivers/rtc/rtc-ds1390.c
+++ b/drivers/rtc/rtc-ds1390.c
@@ -131,7 +131,7 @@ static int ds1390_probe(struct spi_device *spi)
spi->bits_per_word = 8;
spi_setup(spi);
- chip = kzalloc(sizeof *chip, GFP_KERNEL);
+ chip = devm_kzalloc(&spi->dev, sizeof(*chip), GFP_KERNEL);
if (!chip) {
dev_err(&spi->dev, "unable to allocate device memory\n");
return -ENOMEM;
@@ -141,16 +141,14 @@ static int ds1390_probe(struct spi_device *spi)
res = ds1390_get_reg(&spi->dev, DS1390_REG_SECONDS, &tmp);
if (res != 0) {
dev_err(&spi->dev, "unable to read device\n");
- kfree(chip);
return res;
}
- chip->rtc = rtc_device_register("ds1390",
- &spi->dev, &ds1390_rtc_ops, THIS_MODULE);
+ chip->rtc = devm_rtc_device_register(&spi->dev, "ds1390",
+ &ds1390_rtc_ops, THIS_MODULE);
if (IS_ERR(chip->rtc)) {
dev_err(&spi->dev, "unable to register device\n");
res = PTR_ERR(chip->rtc);
- kfree(chip);
}
return res;
@@ -158,11 +156,6 @@ static int ds1390_probe(struct spi_device *spi)
static int ds1390_remove(struct spi_device *spi)
{
- struct ds1390 *chip = spi_get_drvdata(spi);
-
- rtc_device_unregister(chip->rtc);
- kfree(chip);
-
return 0;
}