aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/rtc/rtc-rs5c348.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c
index 72ef10be8662..2c37df3586c7 100644
--- a/drivers/rtc/rtc-rs5c348.c
+++ b/drivers/rtc/rtc-rs5c348.c
@@ -158,7 +158,8 @@ static int rs5c348_probe(struct spi_device *spi)
158 struct rtc_device *rtc; 158 struct rtc_device *rtc;
159 struct rs5c348_plat_data *pdata; 159 struct rs5c348_plat_data *pdata;
160 160
161 pdata = kzalloc(sizeof(struct rs5c348_plat_data), GFP_KERNEL); 161 pdata = devm_kzalloc(&spi->dev, sizeof(struct rs5c348_plat_data),
162 GFP_KERNEL);
162 if (!pdata) 163 if (!pdata)
163 return -ENOMEM; 164 return -ENOMEM;
164 spi->dev.platform_data = pdata; 165 spi->dev.platform_data = pdata;
@@ -202,7 +203,7 @@ static int rs5c348_probe(struct spi_device *spi)
202 if (ret & RS5C348_BIT_24H) 203 if (ret & RS5C348_BIT_24H)
203 pdata->rtc_24h = 1; 204 pdata->rtc_24h = 1;
204 205
205 rtc = rtc_device_register(rs5c348_driver.driver.name, &spi->dev, 206 rtc = devm_rtc_device_register(&spi->dev, rs5c348_driver.driver.name,
206 &rs5c348_rtc_ops, THIS_MODULE); 207 &rs5c348_rtc_ops, THIS_MODULE);
207 208
208 if (IS_ERR(rtc)) { 209 if (IS_ERR(rtc)) {
@@ -214,18 +215,11 @@ static int rs5c348_probe(struct spi_device *spi)
214 215
215 return 0; 216 return 0;
216 kfree_exit: 217 kfree_exit:
217 kfree(pdata);
218 return ret; 218 return ret;
219} 219}
220 220
221static int rs5c348_remove(struct spi_device *spi) 221static int rs5c348_remove(struct spi_device *spi)
222{ 222{
223 struct rs5c348_plat_data *pdata = spi->dev.platform_data;
224 struct rtc_device *rtc = pdata->rtc;
225
226 if (rtc)
227 rtc_device_unregister(rtc);
228 kfree(pdata);
229 return 0; 223 return 0;
230} 224}
231 225