1 #include <linux/config.h>
2 #include <linux/module.h>
3 #include <linux/init.h>
4 #include <linux/kernel.h>
5 #include <linux/miscdevice.h>
6 #include <linux/slab.h>
8 #include <asm/uaccess.h>
9 #include <asm/eisa_eeprom.h>
11 #define EISA_EEPROM_MINOR 241
13 static unsigned long eeprom_addr;
15 static long long eisa_eeprom_llseek(struct file *file, loff_t offset, int origin )
22 offset += file->f_pos;
25 offset += HPEE_MAX_LENGTH;
28 return (offset >= 0 && offset < HPEE_MAX_LENGTH) ? (file->f_pos = offset) : -EINVAL;
31 static ssize_t eisa_eeprom_read(struct file * file,
32 char *buf, size_t count, loff_t *ppos )
38 if (*ppos >= HPEE_MAX_LENGTH)
41 count = *ppos + count < HPEE_MAX_LENGTH ? count : HPEE_MAX_LENGTH - *ppos;
42 tmp = kmalloc(count, GFP_KERNEL);
44 for (i = 0; i < count; i++)
45 tmp[i] = gsc_readb(eeprom_addr+(*ppos)++);
47 if (copy_to_user (buf, tmp, count))
58 static int eisa_eeprom_ioctl(struct inode *inode, struct file *file,
65 static int eisa_eeprom_open(struct inode *inode, struct file *file)
67 if (file->f_mode & 2 || eeprom_addr == 0)
73 static int eisa_eeprom_release(struct inode *inode, struct file *file)
79 * The various file operations we support.
81 static struct file_operations eisa_eeprom_fops = {
83 llseek: eisa_eeprom_llseek,
84 read: eisa_eeprom_read,
85 ioctl: eisa_eeprom_ioctl,
86 open: eisa_eeprom_open,
87 release: eisa_eeprom_release,
90 static struct miscdevice eisa_eeprom_dev=
97 int __init eisa_eeprom_init(unsigned long addr)
101 misc_register(&eisa_eeprom_dev);
102 printk(KERN_INFO "EISA EEPROM at 0x%lx\n", eeprom_addr);
107 MODULE_LICENSE("GPL");