aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ds1742.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-ds1742.c')
-rw-r--r--drivers/rtc/rtc-ds1742.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index eccdc62ae1c0..17b73fdc3b6e 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -52,11 +52,9 @@
52#define RTC_BATT_FLAG 0x80 52#define RTC_BATT_FLAG 0x80
53 53
54struct rtc_plat_data { 54struct rtc_plat_data {
55 struct rtc_device *rtc;
56 void __iomem *ioaddr_nvram; 55 void __iomem *ioaddr_nvram;
57 void __iomem *ioaddr_rtc; 56 void __iomem *ioaddr_rtc;
58 size_t size_nvram; 57 size_t size_nvram;
59 size_t size;
60 unsigned long last_jiffies; 58 unsigned long last_jiffies;
61 struct bin_attribute nvram_attr; 59 struct bin_attribute nvram_attr;
62}; 60};
@@ -117,11 +115,7 @@ static int ds1742_rtc_read_time(struct device *dev, struct rtc_time *tm)
117 /* year is 1900 + tm->tm_year */ 115 /* year is 1900 + tm->tm_year */
118 tm->tm_year = bcd2bin(year) + bcd2bin(century) * 100 - 1900; 116 tm->tm_year = bcd2bin(year) + bcd2bin(century) * 100 - 1900;
119 117
120 if (rtc_valid_tm(tm) < 0) { 118 return rtc_valid_tm(tm);
121 dev_err(dev, "retrieved date/time is not valid.\n");
122 rtc_time_to_tm(0, tm);
123 }
124 return 0;
125} 119}
126 120
127static const struct rtc_class_ops ds1742_rtc_ops = { 121static const struct rtc_class_ops ds1742_rtc_ops = {
@@ -168,22 +162,17 @@ static int ds1742_rtc_probe(struct platform_device *pdev)
168 void __iomem *ioaddr; 162 void __iomem *ioaddr;
169 int ret = 0; 163 int ret = 0;
170 164
171 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
172 if (!res)
173 return -ENODEV;
174 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 165 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
175 if (!pdata) 166 if (!pdata)
176 return -ENOMEM; 167 return -ENOMEM;
177 pdata->size = resource_size(res); 168
178 if (!devm_request_mem_region(&pdev->dev, res->start, pdata->size, 169 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
179 pdev->name)) 170 ioaddr = devm_ioremap_resource(&pdev->dev, res);
180 return -EBUSY; 171 if (IS_ERR(ioaddr))
181 ioaddr = devm_ioremap(&pdev->dev, res->start, pdata->size); 172 return PTR_ERR(ioaddr);
182 if (!ioaddr)
183 return -ENOMEM;
184 173
185 pdata->ioaddr_nvram = ioaddr; 174 pdata->ioaddr_nvram = ioaddr;
186 pdata->size_nvram = pdata->size - RTC_SIZE; 175 pdata->size_nvram = resource_size(res) - RTC_SIZE;
187 pdata->ioaddr_rtc = ioaddr + pdata->size_nvram; 176 pdata->ioaddr_rtc = ioaddr + pdata->size_nvram;
188 177
189 sysfs_bin_attr_init(&pdata->nvram_attr); 178 sysfs_bin_attr_init(&pdata->nvram_attr);
@@ -212,7 +201,6 @@ static int ds1742_rtc_probe(struct platform_device *pdev)
212 &ds1742_rtc_ops, THIS_MODULE); 201 &ds1742_rtc_ops, THIS_MODULE);
213 if (IS_ERR(rtc)) 202 if (IS_ERR(rtc))
214 return PTR_ERR(rtc); 203 return PTR_ERR(rtc);
215 pdata->rtc = rtc;
216 204
217 ret = sysfs_create_bin_file(&pdev->dev.kobj, &pdata->nvram_attr); 205 ret = sysfs_create_bin_file(&pdev->dev.kobj, &pdata->nvram_attr);
218 206