Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 370095
b: refs/heads/master
c: a6d935a
h: refs/heads/master
i:
  370093: c2deee5
  370091: b0b64a3
  370087: 08edac2
  370079: d370b6d
v: v3
  • Loading branch information
David Howells authored and Al Viro committed Apr 29, 2013
1 parent aa37f65 commit 2a06b5a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c18bd9a1ff477bd010d7607a8e575da24de0b08b
refs/heads/master: a6d935a5b1d945c7bec2afe21dcf6f22b653acef
48 changes: 23 additions & 25 deletions trunk/drivers/char/genrtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/mutex.h>
#include <linux/workqueue.h>

Expand Down Expand Up @@ -386,18 +387,15 @@ static int gen_rtc_release(struct inode *inode, struct file *file)
* Info exported via "/proc/driver/rtc".
*/

static int gen_rtc_proc_output(char *buf)
static int gen_rtc_proc_show(struct seq_file *m, void *v)
{
char *p;
struct rtc_time tm;
unsigned int flags;
struct rtc_pll_info pll;

p = buf;

flags = get_rtc_time(&tm);

p += sprintf(p,
seq_printf(m,
"rtc_time\t: %02d:%02d:%02d\n"
"rtc_date\t: %04d-%02d-%02d\n"
"rtc_epoch\t: %04u\n",
Expand All @@ -406,23 +404,23 @@ static int gen_rtc_proc_output(char *buf)

tm.tm_hour = tm.tm_min = tm.tm_sec = 0;

p += sprintf(p, "alarm\t\t: ");
seq_puts(m, "alarm\t\t: ");
if (tm.tm_hour <= 24)
p += sprintf(p, "%02d:", tm.tm_hour);
seq_printf(m, "%02d:", tm.tm_hour);
else
p += sprintf(p, "**:");
seq_puts(m, "**:");

if (tm.tm_min <= 59)
p += sprintf(p, "%02d:", tm.tm_min);
seq_printf(m, "%02d:", tm.tm_min);
else
p += sprintf(p, "**:");
seq_puts(m, "**:");

if (tm.tm_sec <= 59)
p += sprintf(p, "%02d\n", tm.tm_sec);
seq_printf(m, "%02d\n", tm.tm_sec);
else
p += sprintf(p, "**\n");
seq_puts(m, "**\n");

p += sprintf(p,
seq_printf(m,
"DST_enable\t: %s\n"
"BCD\t\t: %s\n"
"24hr\t\t: %s\n"
Expand All @@ -442,7 +440,7 @@ static int gen_rtc_proc_output(char *buf)
0L /* freq */,
(flags & RTC_BATT_BAD) ? "bad" : "okay");
if (!get_rtc_pll(&pll))
p += sprintf(p,
seq_printf(m,
"PLL adjustment\t: %d\n"
"PLL max +ve adjustment\t: %d\n"
"PLL max -ve adjustment\t: %d\n"
Expand All @@ -455,26 +453,26 @@ static int gen_rtc_proc_output(char *buf)
pll.pll_posmult,
pll.pll_negmult,
pll.pll_clock);
return p - buf;
return 0;
}

static int gen_rtc_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
static int gen_rtc_proc_open(struct inode *inode, struct file *file)
{
int len = gen_rtc_proc_output (page);
if (len <= off+count) *eof = 1;
*start = page + off;
len -= off;
if (len>count) len = count;
if (len<0) len = 0;
return len;
return single_open(file, gen_rtc_proc_show, NULL);
}

static const struct file_operations gen_rtc_proc_fops = {
.open = gen_rtc_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

static int __init gen_rtc_proc_init(void)
{
struct proc_dir_entry *r;

r = create_proc_read_entry("driver/rtc", 0, NULL, gen_rtc_read_proc, NULL);
r = proc_create("driver/rtc", 0, NULL, &gen_rtc_proc_fops);
if (!r)
return -ENOMEM;
return 0;
Expand Down

0 comments on commit 2a06b5a

Please sign in to comment.