diff options
author | David Howells <dhowells@redhat.com> | 2013-04-10 11:21:08 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-04-29 15:41:55 -0400 |
commit | 788416bcee1a68aa0e8ed3f49c800b6c3df1c0a4 (patch) | |
tree | 0b2946d6df3368e6d35647b03953a8cd265cc138 | |
parent | a6d935a5b1d945c7bec2afe21dcf6f22b653acef (diff) |
efirtc: Don't use create_proc_read_entry()
Don't use create_proc_read_entry() as that is deprecated, but rather use
proc_create_data() and seq_file instead.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Arnd Bergmann <arnd@arndb.de>
cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | drivers/char/efirtc.c | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/drivers/char/efirtc.c b/drivers/char/efirtc.c index a082d00b0f11..ea54a6e3f5ad 100644 --- a/drivers/char/efirtc.c +++ b/drivers/char/efirtc.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/rtc.h> | 35 | #include <linux/rtc.h> |
36 | #include <linux/proc_fs.h> | 36 | #include <linux/proc_fs.h> |
37 | #include <linux/seq_file.h> | ||
37 | #include <linux/efi.h> | 38 | #include <linux/efi.h> |
38 | #include <linux/uaccess.h> | 39 | #include <linux/uaccess.h> |
39 | 40 | ||
@@ -296,12 +297,10 @@ static struct miscdevice efi_rtc_dev= { | |||
296 | /* | 297 | /* |
297 | * We export RAW EFI information to /proc/driver/efirtc | 298 | * We export RAW EFI information to /proc/driver/efirtc |
298 | */ | 299 | */ |
299 | static int | 300 | static int efi_rtc_proc_show(struct seq_file *m, void *v) |
300 | efi_rtc_get_status(char *buf) | ||
301 | { | 301 | { |
302 | efi_time_t eft, alm; | 302 | efi_time_t eft, alm; |
303 | efi_time_cap_t cap; | 303 | efi_time_cap_t cap; |
304 | char *p = buf; | ||
305 | efi_bool_t enabled, pending; | 304 | efi_bool_t enabled, pending; |
306 | unsigned long flags; | 305 | unsigned long flags; |
307 | 306 | ||
@@ -316,64 +315,63 @@ efi_rtc_get_status(char *buf) | |||
316 | 315 | ||
317 | spin_unlock_irqrestore(&efi_rtc_lock,flags); | 316 | spin_unlock_irqrestore(&efi_rtc_lock,flags); |
318 | 317 | ||
319 | p += sprintf(p, | 318 | seq_printf(m, |
320 | "Time : %u:%u:%u.%09u\n" | 319 | "Time : %u:%u:%u.%09u\n" |
321 | "Date : %u-%u-%u\n" | 320 | "Date : %u-%u-%u\n" |
322 | "Daylight : %u\n", | 321 | "Daylight : %u\n", |
323 | eft.hour, eft.minute, eft.second, eft.nanosecond, | 322 | eft.hour, eft.minute, eft.second, eft.nanosecond, |
324 | eft.year, eft.month, eft.day, | 323 | eft.year, eft.month, eft.day, |
325 | eft.daylight); | 324 | eft.daylight); |
326 | 325 | ||
327 | if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE) | 326 | if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE) |
328 | p += sprintf(p, "Timezone : unspecified\n"); | 327 | seq_puts(m, "Timezone : unspecified\n"); |
329 | else | 328 | else |
330 | /* XXX fixme: convert to string? */ | 329 | /* XXX fixme: convert to string? */ |
331 | p += sprintf(p, "Timezone : %u\n", eft.timezone); | 330 | seq_printf(m, "Timezone : %u\n", eft.timezone); |
332 | 331 | ||
333 | 332 | ||
334 | p += sprintf(p, | 333 | seq_printf(m, |
335 | "Alarm Time : %u:%u:%u.%09u\n" | 334 | "Alarm Time : %u:%u:%u.%09u\n" |
336 | "Alarm Date : %u-%u-%u\n" | 335 | "Alarm Date : %u-%u-%u\n" |
337 | "Alarm Daylight : %u\n" | 336 | "Alarm Daylight : %u\n" |
338 | "Enabled : %s\n" | 337 | "Enabled : %s\n" |
339 | "Pending : %s\n", | 338 | "Pending : %s\n", |
340 | alm.hour, alm.minute, alm.second, alm.nanosecond, | 339 | alm.hour, alm.minute, alm.second, alm.nanosecond, |
341 | alm.year, alm.month, alm.day, | 340 | alm.year, alm.month, alm.day, |
342 | alm.daylight, | 341 | alm.daylight, |
343 | enabled == 1 ? "yes" : "no", | 342 | enabled == 1 ? "yes" : "no", |
344 | pending == 1 ? "yes" : "no"); | 343 | pending == 1 ? "yes" : "no"); |
345 | 344 | ||
346 | if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE) | 345 | if (eft.timezone == EFI_UNSPECIFIED_TIMEZONE) |
347 | p += sprintf(p, "Timezone : unspecified\n"); | 346 | seq_puts(m, "Timezone : unspecified\n"); |
348 | else | 347 | else |
349 | /* XXX fixme: convert to string? */ | 348 | /* XXX fixme: convert to string? */ |
350 | p += sprintf(p, "Timezone : %u\n", alm.timezone); | 349 | seq_printf(m, "Timezone : %u\n", alm.timezone); |
351 | 350 | ||
352 | /* | 351 | /* |
353 | * now prints the capabilities | 352 | * now prints the capabilities |
354 | */ | 353 | */ |
355 | p += sprintf(p, | 354 | seq_printf(m, |
356 | "Resolution : %u\n" | 355 | "Resolution : %u\n" |
357 | "Accuracy : %u\n" | 356 | "Accuracy : %u\n" |
358 | "SetstoZero : %u\n", | 357 | "SetstoZero : %u\n", |
359 | cap.resolution, cap.accuracy, cap.sets_to_zero); | 358 | cap.resolution, cap.accuracy, cap.sets_to_zero); |
360 | 359 | ||
361 | return p - buf; | 360 | return 0; |
362 | } | 361 | } |
363 | 362 | ||
364 | static int | 363 | static int efi_rtc_proc_open(struct inode *inode, struct file *file) |
365 | efi_rtc_read_proc(char *page, char **start, off_t off, | ||
366 | int count, int *eof, void *data) | ||
367 | { | 364 | { |
368 | int len = efi_rtc_get_status(page); | 365 | return single_open(file, efi_rtc_proc_show, NULL); |
369 | if (len <= off+count) *eof = 1; | ||
370 | *start = page + off; | ||
371 | len -= off; | ||
372 | if (len>count) len = count; | ||
373 | if (len<0) len = 0; | ||
374 | return len; | ||
375 | } | 366 | } |
376 | 367 | ||
368 | static const struct file_operations efi_rtc_proc_fops = { | ||
369 | .open = efi_rtc_proc_open, | ||
370 | .read = seq_read, | ||
371 | .llseek = seq_lseek, | ||
372 | .release = seq_release, | ||
373 | }; | ||
374 | |||
377 | static int __init | 375 | static int __init |
378 | efi_rtc_init(void) | 376 | efi_rtc_init(void) |
379 | { | 377 | { |
@@ -389,8 +387,7 @@ efi_rtc_init(void) | |||
389 | return ret; | 387 | return ret; |
390 | } | 388 | } |
391 | 389 | ||
392 | dir = create_proc_read_entry ("driver/efirtc", 0, NULL, | 390 | dir = proc_create("driver/efirtc", 0, NULL, &efi_rtc_proc_fops); |
393 | efi_rtc_read_proc, NULL); | ||
394 | if (dir == NULL) { | 391 | if (dir == NULL) { |
395 | printk(KERN_ERR "efirtc: can't create /proc/driver/efirtc.\n"); | 392 | printk(KERN_ERR "efirtc: can't create /proc/driver/efirtc.\n"); |
396 | misc_deregister(&efi_rtc_dev); | 393 | misc_deregister(&efi_rtc_dev); |