aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/parisc/eisa_eeprom.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/parisc/eisa_eeprom.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/parisc/eisa_eeprom.c')
-rw-r--r--drivers/parisc/eisa_eeprom.c134
1 files changed, 134 insertions, 0 deletions
diff --git a/drivers/parisc/eisa_eeprom.c b/drivers/parisc/eisa_eeprom.c
new file mode 100644
index 000000000000..3a1b4826e5c1
--- /dev/null
+++ b/drivers/parisc/eisa_eeprom.c
@@ -0,0 +1,134 @@
1/*
2 * EISA "eeprom" support routines
3 *
4 * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org>
5 *
6 *
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.
11 *
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.
16 *
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
20 */
21
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>
27#include <linux/fs.h>
28#include <asm/io.h>
29#include <asm/uaccess.h>
30#include <asm/eisa_eeprom.h>
31
32#define EISA_EEPROM_MINOR 241
33
34static loff_t eisa_eeprom_llseek(struct file *file, loff_t offset, int origin )
35{
36 switch (origin) {
37 case 0:
38 /* nothing to do */
39 break;
40 case 1:
41 offset += file->f_pos;
42 break;
43 case 2:
44 offset += HPEE_MAX_LENGTH;
45 break;
46 }
47 return (offset >= 0 && offset < HPEE_MAX_LENGTH) ? (file->f_pos = offset) : -EINVAL;
48}
49
50static ssize_t eisa_eeprom_read(struct file * file,
51 char *buf, size_t count, loff_t *ppos )
52{
53 unsigned char *tmp;
54 ssize_t ret;
55 int i;
56
57 if (*ppos >= HPEE_MAX_LENGTH)
58 return 0;
59
60 count = *ppos + count < HPEE_MAX_LENGTH ? count : HPEE_MAX_LENGTH - *ppos;
61 tmp = kmalloc(count, GFP_KERNEL);
62 if (tmp) {
63 for (i = 0; i < count; i++)
64 tmp[i] = readb(eisa_eeprom_addr+(*ppos)++);
65
66 if (copy_to_user (buf, tmp, count))
67 ret = -EFAULT;
68 else
69 ret = count;
70 kfree (tmp);
71 } else
72 ret = -ENOMEM;
73
74 return ret;
75}
76
77static int eisa_eeprom_ioctl(struct inode *inode, struct file *file,
78 unsigned int cmd,
79 unsigned long arg)
80{
81 return -ENOTTY;
82}
83
84static int eisa_eeprom_open(struct inode *inode, struct file *file)
85{
86 if (file->f_mode & 2)
87 return -EINVAL;
88
89 return 0;
90}
91
92static int eisa_eeprom_release(struct inode *inode, struct file *file)
93{
94 return 0;
95}
96
97/*
98 * The various file operations we support.
99 */
100static struct file_operations eisa_eeprom_fops = {
101 .owner = THIS_MODULE,
102 .llseek = eisa_eeprom_llseek,
103 .read = eisa_eeprom_read,
104 .ioctl = eisa_eeprom_ioctl,
105 .open = eisa_eeprom_open,
106 .release = eisa_eeprom_release,
107};
108
109static struct miscdevice eisa_eeprom_dev = {
110 EISA_EEPROM_MINOR,
111 "eisa_eeprom",
112 &eisa_eeprom_fops
113};
114
115static int __init eisa_eeprom_init(void)
116{
117 int retval;
118
119 if (!eisa_eeprom_addr)
120 return -ENODEV;
121
122 retval = misc_register(&eisa_eeprom_dev);
123 if (retval < 0) {
124 printk(KERN_ERR "EISA EEPROM: cannot register misc device.\n");
125 return retval;
126 }
127
128 printk(KERN_INFO "EISA EEPROM at 0x%p\n", eisa_eeprom_addr);
129 return 0;
130}
131
132MODULE_LICENSE("GPL");
133
134module_init(eisa_eeprom_init);