diff options
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-ds1742.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c index 8bc8501bffc8..09249459e9a4 100644 --- a/drivers/rtc/rtc-ds1742.c +++ b/drivers/rtc/rtc-ds1742.c | |||
@@ -57,6 +57,7 @@ struct rtc_plat_data { | |||
57 | size_t size; | 57 | size_t size; |
58 | resource_size_t baseaddr; | 58 | resource_size_t baseaddr; |
59 | unsigned long last_jiffies; | 59 | unsigned long last_jiffies; |
60 | struct bin_attribute nvram_attr; | ||
60 | }; | 61 | }; |
61 | 62 | ||
62 | static int ds1742_rtc_set_time(struct device *dev, struct rtc_time *tm) | 63 | static int ds1742_rtc_set_time(struct device *dev, struct rtc_time *tm) |
@@ -157,18 +158,6 @@ static ssize_t ds1742_nvram_write(struct kobject *kobj, | |||
157 | return count; | 158 | return count; |
158 | } | 159 | } |
159 | 160 | ||
160 | static struct bin_attribute ds1742_nvram_attr = { | ||
161 | .attr = { | ||
162 | .name = "nvram", | ||
163 | .mode = S_IRUGO | S_IWUSR, | ||
164 | }, | ||
165 | .read = ds1742_nvram_read, | ||
166 | .write = ds1742_nvram_write, | ||
167 | /* REVISIT: size in sysfs won't match actual size... if it's | ||
168 | * not a constant, each RTC should have its own attribute. | ||
169 | */ | ||
170 | }; | ||
171 | |||
172 | static int __devinit ds1742_rtc_probe(struct platform_device *pdev) | 161 | static int __devinit ds1742_rtc_probe(struct platform_device *pdev) |
173 | { | 162 | { |
174 | struct rtc_device *rtc; | 163 | struct rtc_device *rtc; |
@@ -199,6 +188,12 @@ static int __devinit ds1742_rtc_probe(struct platform_device *pdev) | |||
199 | pdata->size_nvram = pdata->size - RTC_SIZE; | 188 | pdata->size_nvram = pdata->size - RTC_SIZE; |
200 | pdata->ioaddr_rtc = ioaddr + pdata->size_nvram; | 189 | pdata->ioaddr_rtc = ioaddr + pdata->size_nvram; |
201 | 190 | ||
191 | pdata->nvram_attr.attr.name = "nvram"; | ||
192 | pdata->nvram_attr.attr.mode = S_IRUGO | S_IWUSR; | ||
193 | pdata->nvram_attr.read = ds1742_nvram_read; | ||
194 | pdata->nvram_attr.write = ds1742_nvram_write; | ||
195 | pdata->nvram_attr.size = pdata->size_nvram; | ||
196 | |||
202 | /* turn RTC on if it was not on */ | 197 | /* turn RTC on if it was not on */ |
203 | ioaddr = pdata->ioaddr_rtc; | 198 | ioaddr = pdata->ioaddr_rtc; |
204 | sec = readb(ioaddr + RTC_SECONDS); | 199 | sec = readb(ioaddr + RTC_SECONDS); |
@@ -221,11 +216,13 @@ static int __devinit ds1742_rtc_probe(struct platform_device *pdev) | |||
221 | pdata->rtc = rtc; | 216 | pdata->rtc = rtc; |
222 | pdata->last_jiffies = jiffies; | 217 | pdata->last_jiffies = jiffies; |
223 | platform_set_drvdata(pdev, pdata); | 218 | platform_set_drvdata(pdev, pdata); |
224 | ds1742_nvram_attr.size = max(ds1742_nvram_attr.size, | 219 | |
225 | pdata->size_nvram); | 220 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &pdata->nvram_attr); |
226 | ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr); | 221 | if (ret) { |
227 | if (ret) | 222 | dev_err(&pdev->dev, "creating nvram file in sysfs failed\n"); |
228 | goto out; | 223 | goto out; |
224 | } | ||
225 | |||
229 | return 0; | 226 | return 0; |
230 | out: | 227 | out: |
231 | if (pdata->rtc) | 228 | if (pdata->rtc) |
@@ -242,7 +239,7 @@ static int __devexit ds1742_rtc_remove(struct platform_device *pdev) | |||
242 | { | 239 | { |
243 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 240 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
244 | 241 | ||
245 | sysfs_remove_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr); | 242 | sysfs_remove_bin_file(&pdev->dev.kobj, &pdata->nvram_attr); |
246 | rtc_device_unregister(pdata->rtc); | 243 | rtc_device_unregister(pdata->rtc); |
247 | iounmap(pdata->ioaddr_nvram); | 244 | iounmap(pdata->ioaddr_nvram); |
248 | release_mem_region(pdata->baseaddr, pdata->size); | 245 | release_mem_region(pdata->baseaddr, pdata->size); |