aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/rtc/rtc-m48t86.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/drivers/rtc/rtc-m48t86.c b/drivers/rtc/rtc-m48t86.c
index 22656a90cfc5..d9aea9b6d9cd 100644
--- a/drivers/rtc/rtc-m48t86.c
+++ b/drivers/rtc/rtc-m48t86.c
@@ -163,35 +163,30 @@ static const struct rtc_class_ops m48t86_rtc_ops = {
163 .proc = m48t86_rtc_proc, 163 .proc = m48t86_rtc_proc,
164}; 164};
165 165
166static ssize_t m48t86_nvram_read(struct file *filp, struct kobject *kobj, 166static int m48t86_nvram_read(void *priv, unsigned int off, void *buf,
167 struct bin_attribute *attr, 167 size_t count)
168 char *buf, loff_t off, size_t count)
169{ 168{
170 struct device *dev = kobj_to_dev(kobj); 169 struct device *dev = priv;
171 unsigned int i; 170 unsigned int i;
172 171
173 for (i = 0; i < count; i++) 172 for (i = 0; i < count; i++)
174 buf[i] = m48t86_readb(dev, M48T86_NVRAM(off + i)); 173 ((u8 *)buf)[i] = m48t86_readb(dev, M48T86_NVRAM(off + i));
175 174
176 return count; 175 return 0;
177} 176}
178 177
179static ssize_t m48t86_nvram_write(struct file *filp, struct kobject *kobj, 178static int m48t86_nvram_write(void *priv, unsigned int off, void *buf,
180 struct bin_attribute *attr, 179 size_t count)
181 char *buf, loff_t off, size_t count)
182{ 180{
183 struct device *dev = kobj_to_dev(kobj); 181 struct device *dev = priv;
184 unsigned int i; 182 unsigned int i;
185 183
186 for (i = 0; i < count; i++) 184 for (i = 0; i < count; i++)
187 m48t86_writeb(dev, buf[i], M48T86_NVRAM(off + i)); 185 m48t86_writeb(dev, ((u8 *)buf)[i], M48T86_NVRAM(off + i));
188 186
189 return count; 187 return 0;
190} 188}
191 189
192static BIN_ATTR(nvram, 0644, m48t86_nvram_read, m48t86_nvram_write,
193 M48T86_NVRAM_LEN);
194
195/* 190/*
196 * The RTC is an optional feature at purchase time on some Technologic Systems 191 * The RTC is an optional feature at purchase time on some Technologic Systems
197 * boards. Verify that it actually exists by checking if the last two bytes 192 * boards. Verify that it actually exists by checking if the last two bytes
@@ -223,6 +218,15 @@ static bool m48t86_verify_chip(struct platform_device *pdev)
223 return false; 218 return false;
224} 219}
225 220
221static struct nvmem_config m48t86_nvmem_cfg = {
222 .name = "m48t86_nvram",
223 .word_size = 1,
224 .stride = 1,
225 .size = M48T86_NVRAM_LEN,
226 .reg_read = m48t86_nvram_read,
227 .reg_write = m48t86_nvram_write,
228};
229
226static int m48t86_rtc_probe(struct platform_device *pdev) 230static int m48t86_rtc_probe(struct platform_device *pdev)
227{ 231{
228 struct m48t86_rtc_info *info; 232 struct m48t86_rtc_info *info;
@@ -261,6 +265,10 @@ static int m48t86_rtc_probe(struct platform_device *pdev)
261 265
262 info->rtc->ops = &m48t86_rtc_ops; 266 info->rtc->ops = &m48t86_rtc_ops;
263 267
268 m48t86_nvmem_cfg.priv = &pdev->dev;
269 info->rtc->nvmem_config = &m48t86_nvmem_cfg;
270 info->rtc->nvram_old_abi = true;
271
264 err = rtc_register_device(info->rtc); 272 err = rtc_register_device(info->rtc);
265 if (err) 273 if (err)
266 return err; 274 return err;
@@ -270,15 +278,6 @@ static int m48t86_rtc_probe(struct platform_device *pdev)
270 dev_info(&pdev->dev, "battery %s\n", 278 dev_info(&pdev->dev, "battery %s\n",
271 (reg & M48T86_D_VRT) ? "ok" : "exhausted"); 279 (reg & M48T86_D_VRT) ? "ok" : "exhausted");
272 280
273 if (device_create_bin_file(&pdev->dev, &bin_attr_nvram))
274 dev_err(&pdev->dev, "failed to create nvram sysfs entry\n");
275
276 return 0;
277}
278
279static int m48t86_rtc_remove(struct platform_device *pdev)
280{
281 device_remove_bin_file(&pdev->dev, &bin_attr_nvram);
282 return 0; 281 return 0;
283} 282}
284 283
@@ -287,7 +286,6 @@ static struct platform_driver m48t86_rtc_platform_driver = {
287 .name = "rtc-m48t86", 286 .name = "rtc-m48t86",
288 }, 287 },
289 .probe = m48t86_rtc_probe, 288 .probe = m48t86_rtc_probe,
290 .remove = m48t86_rtc_remove,
291}; 289};
292 290
293module_platform_driver(m48t86_rtc_platform_driver); 291module_platform_driver(m48t86_rtc_platform_driver);