2 * EISA "eeprom" support routines
4 * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/module.h>
23 #include <linux/init.h>
24 #include <linux/kernel.h>
25 #include <linux/miscdevice.h>
26 #include <linux/slab.h>
29 #include <asm/uaccess.h>
30 #include <asm/eisa_eeprom.h>
32 #define EISA_EEPROM_MINOR 241
34 static loff_t eisa_eeprom_llseek(struct file *file, loff_t offset, int origin)
36 return fixed_size_llseek(file, offset, origin, HPEE_MAX_LENGTH);
39 static ssize_t eisa_eeprom_read(struct file * file,
40 char __user *buf, size_t count, loff_t *ppos )
46 if (*ppos < 0 || *ppos >= HPEE_MAX_LENGTH)
49 count = *ppos + count < HPEE_MAX_LENGTH ? count : HPEE_MAX_LENGTH - *ppos;
50 tmp = kmalloc(count, GFP_KERNEL);
52 for (i = 0; i < count; i++)
53 tmp[i] = readb(eisa_eeprom_addr+(*ppos)++);
55 if (copy_to_user (buf, tmp, count))
66 static int eisa_eeprom_open(struct inode *inode, struct file *file)
68 if (file->f_mode & FMODE_WRITE)
74 static int eisa_eeprom_release(struct inode *inode, struct file *file)
80 * The various file operations we support.
82 static const struct file_operations eisa_eeprom_fops = {
84 .llseek = eisa_eeprom_llseek,
85 .read = eisa_eeprom_read,
86 .open = eisa_eeprom_open,
87 .release = eisa_eeprom_release,
90 static struct miscdevice eisa_eeprom_dev = {
96 static int __init eisa_eeprom_init(void)
100 if (!eisa_eeprom_addr)
103 retval = misc_register(&eisa_eeprom_dev);
105 printk(KERN_ERR "EISA EEPROM: cannot register misc device.\n");
109 printk(KERN_INFO "EISA EEPROM at 0x%p\n", eisa_eeprom_addr);
113 MODULE_LICENSE("GPL");
115 module_init(eisa_eeprom_init);