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 )
40 if (n != pos || pos >= HPEE_MAX_LENGTH)
43 if (count > HPEE_MAX_LENGTH - pos)
44 count = HPEE_MAX_LENGTH - pos;
46 tmp = kmalloc(count, GFP_KERNEL);
48 for (i = 0; i < count; i++)
49 tmp[i] = gsc_readb(eeprom_addr+(pos)++);
51 if (copy_to_user (buf, tmp, count))
64 static int eisa_eeprom_ioctl(struct inode *inode, struct file *file,
71 static int eisa_eeprom_open(struct inode *inode, struct file *file)
73 if (file->f_mode & 2 || eeprom_addr == 0)
79 static int eisa_eeprom_release(struct inode *inode, struct file *file)
85 * The various file operations we support.
87 static struct file_operations eisa_eeprom_fops = {
89 llseek: eisa_eeprom_llseek,
90 read: eisa_eeprom_read,
91 ioctl: eisa_eeprom_ioctl,
92 open: eisa_eeprom_open,
93 release: eisa_eeprom_release,
96 static struct miscdevice eisa_eeprom_dev=
103 int __init eisa_eeprom_init(unsigned long addr)
107 misc_register(&eisa_eeprom_dev);
108 printk(KERN_INFO "EISA EEPROM at 0x%lx\n", eeprom_addr);
113 MODULE_LICENSE("GPL");