aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc/hp_sdc_rtc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/misc/hp_sdc_rtc.c')
-rw-r--r--drivers/input/misc/hp_sdc_rtc.c58
1 files changed, 26 insertions, 32 deletions
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index 2e3334b8f82d..770479df8657 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -41,6 +41,7 @@
41#include <linux/time.h> 41#include <linux/time.h>
42#include <linux/miscdevice.h> 42#include <linux/miscdevice.h>
43#include <linux/proc_fs.h> 43#include <linux/proc_fs.h>
44#include <linux/seq_file.h>
44#include <linux/poll.h> 45#include <linux/poll.h>
45#include <linux/rtc.h> 46#include <linux/rtc.h>
46#include <linux/mutex.h> 47#include <linux/mutex.h>
@@ -74,9 +75,6 @@ static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait);
74static int hp_sdc_rtc_open(struct inode *inode, struct file *file); 75static int hp_sdc_rtc_open(struct inode *inode, struct file *file);
75static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on); 76static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on);
76 77
77static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off,
78 int count, int *eof, void *data);
79
80static void hp_sdc_rtc_isr (int irq, void *dev_id, 78static void hp_sdc_rtc_isr (int irq, void *dev_id,
81 uint8_t status, uint8_t data) 79 uint8_t status, uint8_t data)
82{ 80{
@@ -427,22 +425,19 @@ static int hp_sdc_rtc_fasync (int fd, struct file *filp, int on)
427 return fasync_helper (fd, filp, on, &hp_sdc_rtc_async_queue); 425 return fasync_helper (fd, filp, on, &hp_sdc_rtc_async_queue);
428} 426}
429 427
430static int hp_sdc_rtc_proc_output (char *buf) 428static int hp_sdc_rtc_proc_show(struct seq_file *m, void *v)
431{ 429{
432#define YN(bit) ("no") 430#define YN(bit) ("no")
433#define NY(bit) ("yes") 431#define NY(bit) ("yes")
434 char *p;
435 struct rtc_time tm; 432 struct rtc_time tm;
436 struct timeval tv; 433 struct timeval tv;
437 434
438 memset(&tm, 0, sizeof(struct rtc_time)); 435 memset(&tm, 0, sizeof(struct rtc_time));
439 436
440 p = buf;
441
442 if (hp_sdc_rtc_read_bbrtc(&tm)) { 437 if (hp_sdc_rtc_read_bbrtc(&tm)) {
443 p += sprintf(p, "BBRTC\t\t: READ FAILED!\n"); 438 seq_puts(m, "BBRTC\t\t: READ FAILED!\n");
444 } else { 439 } else {
445 p += sprintf(p, 440 seq_printf(m,
446 "rtc_time\t: %02d:%02d:%02d\n" 441 "rtc_time\t: %02d:%02d:%02d\n"
447 "rtc_date\t: %04d-%02d-%02d\n" 442 "rtc_date\t: %04d-%02d-%02d\n"
448 "rtc_epoch\t: %04lu\n", 443 "rtc_epoch\t: %04lu\n",
@@ -452,41 +447,41 @@ static int hp_sdc_rtc_proc_output (char *buf)
452 } 447 }
453 448
454 if (hp_sdc_rtc_read_rt(&tv)) { 449 if (hp_sdc_rtc_read_rt(&tv)) {
455 p += sprintf(p, "i8042 rtc\t: READ FAILED!\n"); 450 seq_puts(m, "i8042 rtc\t: READ FAILED!\n");
456 } else { 451 } else {
457 p += sprintf(p, "i8042 rtc\t: %ld.%02d seconds\n", 452 seq_printf(m, "i8042 rtc\t: %ld.%02d seconds\n",
458 tv.tv_sec, (int)tv.tv_usec/1000); 453 tv.tv_sec, (int)tv.tv_usec/1000);
459 } 454 }
460 455
461 if (hp_sdc_rtc_read_fhs(&tv)) { 456 if (hp_sdc_rtc_read_fhs(&tv)) {
462 p += sprintf(p, "handshake\t: READ FAILED!\n"); 457 seq_puts(m, "handshake\t: READ FAILED!\n");
463 } else { 458 } else {
464 p += sprintf(p, "handshake\t: %ld.%02d seconds\n", 459 seq_printf(m, "handshake\t: %ld.%02d seconds\n",
465 tv.tv_sec, (int)tv.tv_usec/1000); 460 tv.tv_sec, (int)tv.tv_usec/1000);
466 } 461 }
467 462
468 if (hp_sdc_rtc_read_mt(&tv)) { 463 if (hp_sdc_rtc_read_mt(&tv)) {
469 p += sprintf(p, "alarm\t\t: READ FAILED!\n"); 464 seq_puts(m, "alarm\t\t: READ FAILED!\n");
470 } else { 465 } else {
471 p += sprintf(p, "alarm\t\t: %ld.%02d seconds\n", 466 seq_printf(m, "alarm\t\t: %ld.%02d seconds\n",
472 tv.tv_sec, (int)tv.tv_usec/1000); 467 tv.tv_sec, (int)tv.tv_usec/1000);
473 } 468 }
474 469
475 if (hp_sdc_rtc_read_dt(&tv)) { 470 if (hp_sdc_rtc_read_dt(&tv)) {
476 p += sprintf(p, "delay\t\t: READ FAILED!\n"); 471 seq_puts(m, "delay\t\t: READ FAILED!\n");
477 } else { 472 } else {
478 p += sprintf(p, "delay\t\t: %ld.%02d seconds\n", 473 seq_printf(m, "delay\t\t: %ld.%02d seconds\n",
479 tv.tv_sec, (int)tv.tv_usec/1000); 474 tv.tv_sec, (int)tv.tv_usec/1000);
480 } 475 }
481 476
482 if (hp_sdc_rtc_read_ct(&tv)) { 477 if (hp_sdc_rtc_read_ct(&tv)) {
483 p += sprintf(p, "periodic\t: READ FAILED!\n"); 478 seq_puts(m, "periodic\t: READ FAILED!\n");
484 } else { 479 } else {
485 p += sprintf(p, "periodic\t: %ld.%02d seconds\n", 480 seq_printf(m, "periodic\t: %ld.%02d seconds\n",
486 tv.tv_sec, (int)tv.tv_usec/1000); 481 tv.tv_sec, (int)tv.tv_usec/1000);
487 } 482 }
488 483
489 p += sprintf(p, 484 seq_printf(m,
490 "DST_enable\t: %s\n" 485 "DST_enable\t: %s\n"
491 "BCD\t\t: %s\n" 486 "BCD\t\t: %s\n"
492 "24hr\t\t: %s\n" 487 "24hr\t\t: %s\n"
@@ -506,23 +501,23 @@ static int hp_sdc_rtc_proc_output (char *buf)
506 1UL, 501 1UL,
507 1 ? "okay" : "dead"); 502 1 ? "okay" : "dead");
508 503
509 return p - buf; 504 return 0;
510#undef YN 505#undef YN
511#undef NY 506#undef NY
512} 507}
513 508
514static int hp_sdc_rtc_read_proc(char *page, char **start, off_t off, 509static int hp_sdc_rtc_proc_open(struct inode *inode, struct file *file)
515 int count, int *eof, void *data)
516{ 510{
517 int len = hp_sdc_rtc_proc_output (page); 511 return single_open(file, hp_sdc_rtc_proc_show, NULL);
518 if (len <= off+count) *eof = 1;
519 *start = page + off;
520 len -= off;
521 if (len>count) len = count;
522 if (len<0) len = 0;
523 return len;
524} 512}
525 513
514static const struct file_operations hp_sdc_rtc_proc_fops = {
515 .open = hp_sdc_rtc_proc_open,
516 .read = seq_read,
517 .llseek = seq_lseek,
518 .release = seq_release,
519};
520
526static int hp_sdc_rtc_ioctl(struct file *file, 521static int hp_sdc_rtc_ioctl(struct file *file,
527 unsigned int cmd, unsigned long arg) 522 unsigned int cmd, unsigned long arg)
528{ 523{
@@ -715,8 +710,7 @@ static int __init hp_sdc_rtc_init(void)
715 if (misc_register(&hp_sdc_rtc_dev) != 0) 710 if (misc_register(&hp_sdc_rtc_dev) != 0)
716 printk(KERN_INFO "Could not register misc. dev for i8042 rtc\n"); 711 printk(KERN_INFO "Could not register misc. dev for i8042 rtc\n");
717 712
718 create_proc_read_entry ("driver/rtc", 0, NULL, 713 proc_create("driver/rtc", 0, NULL, &hp_sdc_rtc_proc_fops);
719 hp_sdc_rtc_read_proc, NULL);
720 714
721 printk(KERN_INFO "HP i8042 SDC + MSM-58321 RTC support loaded " 715 printk(KERN_INFO "HP i8042 SDC + MSM-58321 RTC support loaded "
722 "(RTC v " RTC_VERSION ")\n"); 716 "(RTC v " RTC_VERSION ")\n");