diff options
author | Jingoo Han <jg1.han@samsung.com> | 2013-04-29 19:20:39 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 21:28:37 -0400 |
commit | 1ce95ba7441240fef3becbf0d5be98141c45f0a5 (patch) | |
tree | 2408eb7c93db302c7467bb070d09417cb5912361 /drivers/rtc/rtc-ds1390.c | |
parent | 061d698e208efb8036673295b5be3b0c8be75082 (diff) |
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.c | 13 |
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) | |||
131 | spi->bits_per_word = 8; | 131 | spi->bits_per_word = 8; |
132 | spi_setup(spi); | 132 | spi_setup(spi); |
133 | 133 | ||
134 | chip = kzalloc(sizeof *chip, GFP_KERNEL); | 134 | chip = devm_kzalloc(&spi->dev, sizeof(*chip), GFP_KERNEL); |
135 | if (!chip) { | 135 | if (!chip) { |
136 | dev_err(&spi->dev, "unable to allocate device memory\n"); | 136 | dev_err(&spi->dev, "unable to allocate device memory\n"); |
137 | return -ENOMEM; | 137 | return -ENOMEM; |
@@ -141,16 +141,14 @@ static int ds1390_probe(struct spi_device *spi) | |||
141 | res = ds1390_get_reg(&spi->dev, DS1390_REG_SECONDS, &tmp); | 141 | res = ds1390_get_reg(&spi->dev, DS1390_REG_SECONDS, &tmp); |
142 | if (res != 0) { | 142 | if (res != 0) { |
143 | dev_err(&spi->dev, "unable to read device\n"); | 143 | dev_err(&spi->dev, "unable to read device\n"); |
144 | kfree(chip); | ||
145 | return res; | 144 | return res; |
146 | } | 145 | } |
147 | 146 | ||
148 | chip->rtc = rtc_device_register("ds1390", | 147 | chip->rtc = devm_rtc_device_register(&spi->dev, "ds1390", |
149 | &spi->dev, &ds1390_rtc_ops, THIS_MODULE); | 148 | &ds1390_rtc_ops, THIS_MODULE); |
150 | if (IS_ERR(chip->rtc)) { | 149 | if (IS_ERR(chip->rtc)) { |
151 | dev_err(&spi->dev, "unable to register device\n"); | 150 | dev_err(&spi->dev, "unable to register device\n"); |
152 | res = PTR_ERR(chip->rtc); | 151 | res = PTR_ERR(chip->rtc); |
153 | kfree(chip); | ||
154 | } | 152 | } |
155 | 153 | ||
156 | return res; | 154 | return res; |
@@ -158,11 +156,6 @@ static int ds1390_probe(struct spi_device *spi) | |||
158 | 156 | ||
159 | static int ds1390_remove(struct spi_device *spi) | 157 | static int ds1390_remove(struct spi_device *spi) |
160 | { | 158 | { |
161 | struct ds1390 *chip = spi_get_drvdata(spi); | ||
162 | |||
163 | rtc_device_unregister(chip->rtc); | ||
164 | kfree(chip); | ||
165 | |||
166 | return 0; | 159 | return 0; |
167 | } | 160 | } |
168 | 161 | ||