2 * /dev/nvram driver for Power Macintosh.
4 #include <linux/types.h>
5 #include <linux/errno.h>
7 #include <linux/miscdevice.h>
8 #include <linux/fcntl.h>
9 #include <linux/nvram.h>
10 #include <linux/init.h>
11 #include <asm/uaccess.h>
14 #define NVRAM_SIZE 8192
18 static long long nvram_llseek(struct file
*file
, loff_t offset
, int origin
)
22 offset
+= file
->f_pos
;
34 static ssize_t
read_nvram(struct file
*file
, char *buf
,
35 size_t count
, loff_t
*ppos
)
40 if (verify_area(VERIFY_WRITE
, buf
, count
))
42 if (*ppos
>= NVRAM_SIZE
)
44 for (i
= *ppos
; count
> 0 && i
< NVRAM_SIZE
; ++i
, ++p
, --count
)
45 if (__put_user(nvram_read_byte(i
), p
))
51 static ssize_t
write_nvram(struct file
*file
, const char *buf
,
52 size_t count
, loff_t
*ppos
)
58 if (verify_area(VERIFY_READ
, buf
, count
))
60 if (*ppos
>= NVRAM_SIZE
)
62 for (i
= *ppos
; count
> 0 && i
< NVRAM_SIZE
; ++i
, ++p
, --count
) {
65 nvram_write_byte(c
, i
);
71 static int nvram_open(struct inode
*inode
, struct file
*file
)
76 struct file_operations nvram_fops
= {
80 NULL
, /* nvram_readdir */
81 NULL
, /* nvram_select */
82 NULL
, /* nvram_ioctl */
83 NULL
, /* nvram_mmap */
86 NULL
, /* no special release code */
90 static struct miscdevice nvram_dev
= {
96 __initfunc(int nvram_init(void))
98 misc_register(&nvram_dev
);