flash.c (19fdb9eefb21b72edbc365b838502780c392bad6) flash.c (4018294b53d1dae026880e45f174c1cc63b5d435)
1/* flash.c: Allow mmap access to the OBP Flash, for OBP updates.
2 *
3 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
4 */
5
6#include <linux/module.h>
7#include <linux/types.h>
8#include <linux/errno.h>

--- 91 unchanged lines hidden (view full) ---

100 unlock_kernel();
101 return file->f_pos;
102}
103
104static ssize_t
105flash_read(struct file * file, char __user * buf,
106 size_t count, loff_t *ppos)
107{
1/* flash.c: Allow mmap access to the OBP Flash, for OBP updates.
2 *
3 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
4 */
5
6#include <linux/module.h>
7#include <linux/types.h>
8#include <linux/errno.h>

--- 91 unchanged lines hidden (view full) ---

100 unlock_kernel();
101 return file->f_pos;
102}
103
104static ssize_t
105flash_read(struct file * file, char __user * buf,
106 size_t count, loff_t *ppos)
107{
108 loff_t p = *ppos;
108 unsigned long p = file->f_pos;
109 int i;
109 int i;
110
110
111 if (count > flash.read_size - p)
112 count = flash.read_size - p;
113
114 for (i = 0; i < count; i++) {
115 u8 data = upa_readb(flash.read_base + p + i);
116 if (put_user(data, buf))
117 return -EFAULT;
118 buf++;
119 }
120
111 if (count > flash.read_size - p)
112 count = flash.read_size - p;
113
114 for (i = 0; i < count; i++) {
115 u8 data = upa_readb(flash.read_base + p + i);
116 if (put_user(data, buf))
117 return -EFAULT;
118 buf++;
119 }
120
121 *ppos += count;
121 file->f_pos += count;
122 return count;
123}
124
125static int
126flash_open(struct inode *inode, struct file *file)
127{
128 lock_kernel();
129 if (test_and_set_bit(0, (void *)&flash.busy) != 0) {

--- 27 unchanged lines hidden (view full) ---

157 .release = flash_release,
158};
159
160static struct miscdevice flash_dev = { FLASH_MINOR, "flash", &flash_fops };
161
162static int __devinit flash_probe(struct of_device *op,
163 const struct of_device_id *match)
164{
122 return count;
123}
124
125static int
126flash_open(struct inode *inode, struct file *file)
127{
128 lock_kernel();
129 if (test_and_set_bit(0, (void *)&flash.busy) != 0) {

--- 27 unchanged lines hidden (view full) ---

157 .release = flash_release,
158};
159
160static struct miscdevice flash_dev = { FLASH_MINOR, "flash", &flash_fops };
161
162static int __devinit flash_probe(struct of_device *op,
163 const struct of_device_id *match)
164{
165 struct device_node *dp = op->node;
165 struct device_node *dp = op->dev.of_node;
166 struct device_node *parent;
167
168 parent = dp->parent;
169
170 if (strcmp(parent->name, "sbus") &&
171 strcmp(parent->name, "sbi") &&
172 strcmp(parent->name, "ebus"))
173 return -ENODEV;

--- 5 unchanged lines hidden (view full) ---

179 flash.write_size = resource_size(&op->resource[1]);
180 } else {
181 flash.write_base = op->resource[0].start;
182 flash.write_size = resource_size(&op->resource[0]);
183 }
184 flash.busy = 0;
185
186 printk(KERN_INFO "%s: OBP Flash, RD %lx[%lx] WR %lx[%lx]\n",
166 struct device_node *parent;
167
168 parent = dp->parent;
169
170 if (strcmp(parent->name, "sbus") &&
171 strcmp(parent->name, "sbi") &&
172 strcmp(parent->name, "ebus"))
173 return -ENODEV;

--- 5 unchanged lines hidden (view full) ---

179 flash.write_size = resource_size(&op->resource[1]);
180 } else {
181 flash.write_base = op->resource[0].start;
182 flash.write_size = resource_size(&op->resource[0]);
183 }
184 flash.busy = 0;
185
186 printk(KERN_INFO "%s: OBP Flash, RD %lx[%lx] WR %lx[%lx]\n",
187 op->node->full_name,
187 op->dev.of_node->full_name,
188 flash.read_base, flash.read_size,
189 flash.write_base, flash.write_size);
190
191 return misc_register(&flash_dev);
192}
193
194static int __devexit flash_remove(struct of_device *op)
195{

--- 6 unchanged lines hidden (view full) ---

202 {
203 .name = "flashprom",
204 },
205 {},
206};
207MODULE_DEVICE_TABLE(of, flash_match);
208
209static struct of_platform_driver flash_driver = {
188 flash.read_base, flash.read_size,
189 flash.write_base, flash.write_size);
190
191 return misc_register(&flash_dev);
192}
193
194static int __devexit flash_remove(struct of_device *op)
195{

--- 6 unchanged lines hidden (view full) ---

202 {
203 .name = "flashprom",
204 },
205 {},
206};
207MODULE_DEVICE_TABLE(of, flash_match);
208
209static struct of_platform_driver flash_driver = {
210 .name = "flash",
211 .match_table = flash_match,
210 .driver = {
211 .name = "flash",
212 .owner = THIS_MODULE,
213 .of_match_table = flash_match,
214 },
212 .probe = flash_probe,
213 .remove = __devexit_p(flash_remove),
214};
215
216static int __init flash_init(void)
217{
218 return of_register_driver(&flash_driver, &of_bus_type);
219}
220
221static void __exit flash_cleanup(void)
222{
223 of_unregister_driver(&flash_driver);
224}
225
226module_init(flash_init);
227module_exit(flash_cleanup);
228MODULE_LICENSE("GPL");
215 .probe = flash_probe,
216 .remove = __devexit_p(flash_remove),
217};
218
219static int __init flash_init(void)
220{
221 return of_register_driver(&flash_driver, &of_bus_type);
222}
223
224static void __exit flash_cleanup(void)
225{
226 of_unregister_driver(&flash_driver);
227}
228
229module_init(flash_init);
230module_exit(flash_cleanup);
231MODULE_LICENSE("GPL");