mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-09 07:54:00 +00:00
rtc: rtc-rs5c348: 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>
This commit is contained in:
parent
ddb396f125
commit
8fb1ecb36f
1 changed files with 3 additions and 9 deletions
|
@ -158,7 +158,8 @@ static int rs5c348_probe(struct spi_device *spi)
|
||||||
struct rtc_device *rtc;
|
struct rtc_device *rtc;
|
||||||
struct rs5c348_plat_data *pdata;
|
struct rs5c348_plat_data *pdata;
|
||||||
|
|
||||||
pdata = kzalloc(sizeof(struct rs5c348_plat_data), GFP_KERNEL);
|
pdata = devm_kzalloc(&spi->dev, sizeof(struct rs5c348_plat_data),
|
||||||
|
GFP_KERNEL);
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
spi->dev.platform_data = pdata;
|
spi->dev.platform_data = pdata;
|
||||||
|
@ -202,7 +203,7 @@ static int rs5c348_probe(struct spi_device *spi)
|
||||||
if (ret & RS5C348_BIT_24H)
|
if (ret & RS5C348_BIT_24H)
|
||||||
pdata->rtc_24h = 1;
|
pdata->rtc_24h = 1;
|
||||||
|
|
||||||
rtc = rtc_device_register(rs5c348_driver.driver.name, &spi->dev,
|
rtc = devm_rtc_device_register(&spi->dev, rs5c348_driver.driver.name,
|
||||||
&rs5c348_rtc_ops, THIS_MODULE);
|
&rs5c348_rtc_ops, THIS_MODULE);
|
||||||
|
|
||||||
if (IS_ERR(rtc)) {
|
if (IS_ERR(rtc)) {
|
||||||
|
@ -214,18 +215,11 @@ static int rs5c348_probe(struct spi_device *spi)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
kfree_exit:
|
kfree_exit:
|
||||||
kfree(pdata);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rs5c348_remove(struct spi_device *spi)
|
static int rs5c348_remove(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct rs5c348_plat_data *pdata = spi->dev.platform_data;
|
|
||||||
struct rtc_device *rtc = pdata->rtc;
|
|
||||||
|
|
||||||
if (rtc)
|
|
||||||
rtc_device_unregister(rtc);
|
|
||||||
kfree(pdata);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue