1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * EISA "eeprom" support routines
5 * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org>
8 #include <linux/module.h>
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/miscdevice.h>
12 #include <linux/slab.h>
15 #include <linux/uaccess.h>
16 #include <asm/eisa_eeprom.h>
18 #define EISA_EEPROM_MINOR 241
20 static loff_t eisa_eeprom_llseek(struct file *file, loff_t offset, int origin)
22 return fixed_size_llseek(file, offset, origin, HPEE_MAX_LENGTH);
25 static ssize_t eisa_eeprom_read(struct file * file,
26 char __user *buf, size_t count, loff_t *ppos )
32 if (*ppos < 0 || *ppos >= HPEE_MAX_LENGTH)
35 count = *ppos + count < HPEE_MAX_LENGTH ? count : HPEE_MAX_LENGTH - *ppos;
36 tmp = kmalloc(count, GFP_KERNEL);
38 for (i = 0; i < count; i++)
39 tmp[i] = readb(eisa_eeprom_addr+(*ppos)++);
41 if (copy_to_user (buf, tmp, count))
52 static int eisa_eeprom_open(struct inode *inode, struct file *file)
54 if (file->f_mode & FMODE_WRITE)
60 static int eisa_eeprom_release(struct inode *inode, struct file *file)
66 * The various file operations we support.
68 static const struct file_operations eisa_eeprom_fops = {
70 .llseek = eisa_eeprom_llseek,
71 .read = eisa_eeprom_read,
72 .open = eisa_eeprom_open,
73 .release = eisa_eeprom_release,
76 static struct miscdevice eisa_eeprom_dev = {
82 static int __init eisa_eeprom_init(void)
86 if (!eisa_eeprom_addr)
89 retval = misc_register(&eisa_eeprom_dev);
91 printk(KERN_ERR "EISA EEPROM: cannot register misc device.\n");
95 printk(KERN_INFO "EISA EEPROM at 0x%px\n", eisa_eeprom_addr);
99 MODULE_LICENSE("GPL");
101 module_init(eisa_eeprom_init);