diff options
Diffstat (limited to 'drivers')
79 files changed, 2333 insertions, 937 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index c40e487d9f5c..52ea94b891f5 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -495,6 +495,21 @@ config LEGACY_PTY_COUNT | |||
495 | When not in use, each legacy PTY occupies 12 bytes on 32-bit | 495 | When not in use, each legacy PTY occupies 12 bytes on 32-bit |
496 | architectures and 24 bytes on 64-bit architectures. | 496 | architectures and 24 bytes on 64-bit architectures. |
497 | 497 | ||
498 | config BRIQ_PANEL | ||
499 | tristate 'Total Impact briQ front panel driver' | ||
500 | depends on PPC_CHRP | ||
501 | ---help--- | ||
502 | The briQ is a small footprint CHRP computer with a frontpanel VFD, a | ||
503 | tristate led and two switches. It is the size of a CDROM drive. | ||
504 | |||
505 | If you have such one and want anything showing on the VFD then you | ||
506 | must answer Y here. | ||
507 | |||
508 | To compile this driver as a module, choose M here: the | ||
509 | module will be called briq_panel. | ||
510 | |||
511 | It's safe to say N here. | ||
512 | |||
498 | config PRINTER | 513 | config PRINTER |
499 | tristate "Parallel printer support" | 514 | tristate "Parallel printer support" |
500 | depends on PARPORT | 515 | depends on PARPORT |
@@ -596,6 +611,13 @@ config HVC_CONSOLE | |||
596 | console. This driver allows each pSeries partition to have a console | 611 | console. This driver allows each pSeries partition to have a console |
597 | which is accessed via the HMC. | 612 | which is accessed via the HMC. |
598 | 613 | ||
614 | config HVC_ISERIES | ||
615 | bool "iSeries Hypervisor Virtual Console support" | ||
616 | depends on PPC_ISERIES && !VIOCONS | ||
617 | select HVC_DRIVER | ||
618 | help | ||
619 | iSeries machines support a hypervisor virtual console. | ||
620 | |||
599 | config HVC_RTAS | 621 | config HVC_RTAS |
600 | bool "IBM RTAS Console support" | 622 | bool "IBM RTAS Console support" |
601 | depends on PPC_RTAS | 623 | depends on PPC_RTAS |
diff --git a/drivers/char/Makefile b/drivers/char/Makefile index 6e0f4469d8bb..8c6dfc621520 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile | |||
@@ -42,6 +42,7 @@ obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o | |||
42 | obj-$(CONFIG_SX) += sx.o generic_serial.o | 42 | obj-$(CONFIG_SX) += sx.o generic_serial.o |
43 | obj-$(CONFIG_RIO) += rio/ generic_serial.o | 43 | obj-$(CONFIG_RIO) += rio/ generic_serial.o |
44 | obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o | 44 | obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o |
45 | obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o | ||
45 | obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o | 46 | obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o |
46 | obj-$(CONFIG_HVC_DRIVER) += hvc_console.o | 47 | obj-$(CONFIG_HVC_DRIVER) += hvc_console.o |
47 | obj-$(CONFIG_RAW_DRIVER) += raw.o | 48 | obj-$(CONFIG_RAW_DRIVER) += raw.o |
@@ -51,6 +52,7 @@ obj-$(CONFIG_VIOCONS) += viocons.o | |||
51 | obj-$(CONFIG_VIOTAPE) += viotape.o | 52 | obj-$(CONFIG_VIOTAPE) += viotape.o |
52 | obj-$(CONFIG_HVCS) += hvcs.o | 53 | obj-$(CONFIG_HVCS) += hvcs.o |
53 | obj-$(CONFIG_SGI_MBCS) += mbcs.o | 54 | obj-$(CONFIG_SGI_MBCS) += mbcs.o |
55 | obj-$(CONFIG_BRIQ_PANEL) += briq_panel.o | ||
54 | 56 | ||
55 | obj-$(CONFIG_PRINTER) += lp.o | 57 | obj-$(CONFIG_PRINTER) += lp.o |
56 | obj-$(CONFIG_TIPAR) += tipar.o | 58 | obj-$(CONFIG_TIPAR) += tipar.o |
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c index 1de1b12043bf..91b71e750ee1 100644 --- a/drivers/char/agp/uninorth-agp.c +++ b/drivers/char/agp/uninorth-agp.c | |||
@@ -601,8 +601,8 @@ static int __devinit agp_uninorth_probe(struct pci_dev *pdev, | |||
601 | uninorth_node = of_find_node_by_name(NULL, "u3"); | 601 | uninorth_node = of_find_node_by_name(NULL, "u3"); |
602 | } | 602 | } |
603 | if (uninorth_node) { | 603 | if (uninorth_node) { |
604 | int *revprop = (int *) | 604 | const int *revprop = get_property(uninorth_node, |
605 | get_property(uninorth_node, "device-rev", NULL); | 605 | "device-rev", NULL); |
606 | if (revprop != NULL) | 606 | if (revprop != NULL) |
607 | uninorth_rev = *revprop & 0x3f; | 607 | uninorth_rev = *revprop & 0x3f; |
608 | of_node_put(uninorth_node); | 608 | of_node_put(uninorth_node); |
diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c new file mode 100644 index 000000000000..a0e5eac5f33a --- /dev/null +++ b/drivers/char/briq_panel.c | |||
@@ -0,0 +1,268 @@ | |||
1 | /* | ||
2 | * Drivers for the Total Impact PPC based computer "BRIQ" | ||
3 | * by Dr. Karsten Jeppesen | ||
4 | * | ||
5 | */ | ||
6 | |||
7 | #include <linux/module.h> | ||
8 | |||
9 | #include <linux/types.h> | ||
10 | #include <linux/errno.h> | ||
11 | #include <linux/sched.h> | ||
12 | #include <linux/tty.h> | ||
13 | #include <linux/timer.h> | ||
14 | #include <linux/config.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/wait.h> | ||
17 | #include <linux/string.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/ioport.h> | ||
20 | #include <linux/delay.h> | ||
21 | #include <linux/miscdevice.h> | ||
22 | #include <linux/fs.h> | ||
23 | #include <linux/mm.h> | ||
24 | #include <linux/init.h> | ||
25 | |||
26 | #include <asm/uaccess.h> | ||
27 | #include <asm/io.h> | ||
28 | #include <asm/prom.h> | ||
29 | |||
30 | #define BRIQ_PANEL_MINOR 156 | ||
31 | #define BRIQ_PANEL_VFD_IOPORT 0x0390 | ||
32 | #define BRIQ_PANEL_LED_IOPORT 0x0398 | ||
33 | #define BRIQ_PANEL_VER "1.1 (04/20/2002)" | ||
34 | #define BRIQ_PANEL_MSG0 "Loading Linux" | ||
35 | |||
36 | static int vfd_is_open; | ||
37 | static unsigned char vfd[40]; | ||
38 | static int vfd_cursor; | ||
39 | static unsigned char ledpb, led; | ||
40 | |||
41 | static void update_vfd(void) | ||
42 | { | ||
43 | int i; | ||
44 | |||
45 | /* cursor home */ | ||
46 | outb(0x02, BRIQ_PANEL_VFD_IOPORT); | ||
47 | for (i=0; i<20; i++) | ||
48 | outb(vfd[i], BRIQ_PANEL_VFD_IOPORT + 1); | ||
49 | |||
50 | /* cursor to next line */ | ||
51 | outb(0xc0, BRIQ_PANEL_VFD_IOPORT); | ||
52 | for (i=20; i<40; i++) | ||
53 | outb(vfd[i], BRIQ_PANEL_VFD_IOPORT + 1); | ||
54 | |||
55 | } | ||
56 | |||
57 | static void set_led(char state) | ||
58 | { | ||
59 | if (state == 'R') | ||
60 | led = 0x01; | ||
61 | else if (state == 'G') | ||
62 | led = 0x02; | ||
63 | else if (state == 'Y') | ||
64 | led = 0x03; | ||
65 | else if (state == 'X') | ||
66 | led = 0x00; | ||
67 | outb(led, BRIQ_PANEL_LED_IOPORT); | ||
68 | } | ||
69 | |||
70 | static int briq_panel_open(struct inode *ino, struct file *filep) | ||
71 | { | ||
72 | /* enforce single access */ | ||
73 | if (vfd_is_open) | ||
74 | return -EBUSY; | ||
75 | vfd_is_open = 1; | ||
76 | |||
77 | return 0; | ||
78 | } | ||
79 | |||
80 | static int briq_panel_release(struct inode *ino, struct file *filep) | ||
81 | { | ||
82 | if (!vfd_is_open) | ||
83 | return -ENODEV; | ||
84 | |||
85 | vfd_is_open = 0; | ||
86 | |||
87 | return 0; | ||
88 | } | ||
89 | |||
90 | static ssize_t briq_panel_read(struct file *file, char *buf, size_t count, | ||
91 | loff_t *ppos) | ||
92 | { | ||
93 | unsigned short c; | ||
94 | unsigned char cp; | ||
95 | |||
96 | #if 0 /* Can't seek (pread) on this device */ | ||
97 | if (ppos != &file->f_pos) | ||
98 | return -ESPIPE; | ||
99 | #endif | ||
100 | |||
101 | if (!vfd_is_open) | ||
102 | return -ENODEV; | ||
103 | |||
104 | c = (inb(BRIQ_PANEL_LED_IOPORT) & 0x000c) | (ledpb & 0x0003); | ||
105 | set_led(' '); | ||
106 | /* upper button released */ | ||
107 | if ((!(ledpb & 0x0004)) && (c & 0x0004)) { | ||
108 | cp = ' '; | ||
109 | ledpb = c; | ||
110 | if (copy_to_user(buf, &cp, 1)) | ||
111 | return -EFAULT; | ||
112 | return 1; | ||
113 | } | ||
114 | /* lower button released */ | ||
115 | else if ((!(ledpb & 0x0008)) && (c & 0x0008)) { | ||
116 | cp = '\r'; | ||
117 | ledpb = c; | ||
118 | if (copy_to_user(buf, &cp, 1)) | ||
119 | return -EFAULT; | ||
120 | return 1; | ||
121 | } else { | ||
122 | ledpb = c; | ||
123 | return 0; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | static void scroll_vfd( void ) | ||
128 | { | ||
129 | int i; | ||
130 | |||
131 | for (i=0; i<20; i++) { | ||
132 | vfd[i] = vfd[i+20]; | ||
133 | vfd[i+20] = ' '; | ||
134 | } | ||
135 | vfd_cursor = 20; | ||
136 | } | ||
137 | |||
138 | static ssize_t briq_panel_write(struct file *file, const char *buf, size_t len, | ||
139 | loff_t *ppos) | ||
140 | { | ||
141 | size_t indx = len; | ||
142 | int i, esc = 0; | ||
143 | |||
144 | #if 0 /* Can't seek (pwrite) on this device */ | ||
145 | if (ppos != &file->f_pos) | ||
146 | return -ESPIPE; | ||
147 | #endif | ||
148 | |||
149 | if (!vfd_is_open) | ||
150 | return -EBUSY; | ||
151 | |||
152 | for (;;) { | ||
153 | if (!indx) | ||
154 | break; | ||
155 | if (esc) { | ||
156 | set_led(*buf); | ||
157 | esc = 0; | ||
158 | } else if (*buf == 27) { | ||
159 | esc = 1; | ||
160 | } else if (*buf == 12) { | ||
161 | /* do a form feed */ | ||
162 | for (i=0; i<40; i++) | ||
163 | vfd[i] = ' '; | ||
164 | vfd_cursor = 0; | ||
165 | } else if (*buf == 10) { | ||
166 | if (vfd_cursor < 20) | ||
167 | vfd_cursor = 20; | ||
168 | else if (vfd_cursor < 40) | ||
169 | vfd_cursor = 40; | ||
170 | else if (vfd_cursor < 60) | ||
171 | vfd_cursor = 60; | ||
172 | if (vfd_cursor > 59) | ||
173 | scroll_vfd(); | ||
174 | } else { | ||
175 | /* just a character */ | ||
176 | if (vfd_cursor > 39) | ||
177 | scroll_vfd(); | ||
178 | vfd[vfd_cursor++] = *buf; | ||
179 | } | ||
180 | indx--; | ||
181 | buf++; | ||
182 | } | ||
183 | update_vfd(); | ||
184 | |||
185 | return len; | ||
186 | } | ||
187 | |||
188 | static struct file_operations briq_panel_fops = { | ||
189 | .owner = THIS_MODULE, | ||
190 | .read = briq_panel_read, | ||
191 | .write = briq_panel_write, | ||
192 | .open = briq_panel_open, | ||
193 | .release = briq_panel_release, | ||
194 | }; | ||
195 | |||
196 | static struct miscdevice briq_panel_miscdev = { | ||
197 | BRIQ_PANEL_MINOR, | ||
198 | "briq_panel", | ||
199 | &briq_panel_fops | ||
200 | }; | ||
201 | |||
202 | static int __init briq_panel_init(void) | ||
203 | { | ||
204 | struct device_node *root = find_path_device("/"); | ||
205 | char *machine; | ||
206 | int i; | ||
207 | |||
208 | machine = get_property(root, "model", NULL); | ||
209 | if (!machine || strncmp(machine, "TotalImpact,BRIQ-1", 18) != 0) | ||
210 | return -ENODEV; | ||
211 | |||
212 | printk(KERN_INFO | ||
213 | "briq_panel: v%s Dr. Karsten Jeppesen (kj@totalimpact.com)\n", | ||
214 | BRIQ_PANEL_VER); | ||
215 | |||
216 | if (!request_region(BRIQ_PANEL_VFD_IOPORT, 4, "BRIQ Front Panel")) | ||
217 | return -EBUSY; | ||
218 | |||
219 | if (!request_region(BRIQ_PANEL_LED_IOPORT, 2, "BRIQ Front Panel")) { | ||
220 | release_region(BRIQ_PANEL_VFD_IOPORT, 4); | ||
221 | return -EBUSY; | ||
222 | } | ||
223 | ledpb = inb(BRIQ_PANEL_LED_IOPORT) & 0x000c; | ||
224 | |||
225 | if (misc_register(&briq_panel_miscdev) < 0) { | ||
226 | release_region(BRIQ_PANEL_VFD_IOPORT, 4); | ||
227 | release_region(BRIQ_PANEL_LED_IOPORT, 2); | ||
228 | return -EBUSY; | ||
229 | } | ||
230 | |||
231 | outb(0x38, BRIQ_PANEL_VFD_IOPORT); /* Function set */ | ||
232 | outb(0x01, BRIQ_PANEL_VFD_IOPORT); /* Clear display */ | ||
233 | outb(0x0c, BRIQ_PANEL_VFD_IOPORT); /* Display on */ | ||
234 | outb(0x06, BRIQ_PANEL_VFD_IOPORT); /* Entry normal */ | ||
235 | for (i=0; i<40; i++) | ||
236 | vfd[i]=' '; | ||
237 | #ifndef MODULE | ||
238 | vfd[0] = 'L'; | ||
239 | vfd[1] = 'o'; | ||
240 | vfd[2] = 'a'; | ||
241 | vfd[3] = 'd'; | ||
242 | vfd[4] = 'i'; | ||
243 | vfd[5] = 'n'; | ||
244 | vfd[6] = 'g'; | ||
245 | vfd[7] = ' '; | ||
246 | vfd[8] = '.'; | ||
247 | vfd[9] = '.'; | ||
248 | vfd[10] = '.'; | ||
249 | #endif /* !MODULE */ | ||
250 | |||
251 | update_vfd(); | ||
252 | |||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | static void __exit briq_panel_exit(void) | ||
257 | { | ||
258 | misc_deregister(&briq_panel_miscdev); | ||
259 | release_region(BRIQ_PANEL_VFD_IOPORT, 4); | ||
260 | release_region(BRIQ_PANEL_LED_IOPORT, 2); | ||
261 | } | ||
262 | |||
263 | module_init(briq_panel_init); | ||
264 | module_exit(briq_panel_exit); | ||
265 | |||
266 | MODULE_LICENSE("GPL"); | ||
267 | MODULE_AUTHOR("Karsten Jeppesen <karsten@jeppesens.com>"); | ||
268 | MODULE_DESCRIPTION("Driver for the Total Impact briQ front panel"); | ||
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index 613d67f1c7f0..a76d2c40dd5e 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c | |||
@@ -80,7 +80,8 @@ struct hvc_struct { | |||
80 | struct tty_struct *tty; | 80 | struct tty_struct *tty; |
81 | unsigned int count; | 81 | unsigned int count; |
82 | int do_wakeup; | 82 | int do_wakeup; |
83 | char outbuf[N_OUTBUF] __ALIGNED__; | 83 | char *outbuf; |
84 | int outbuf_size; | ||
84 | int n_outbuf; | 85 | int n_outbuf; |
85 | uint32_t vtermno; | 86 | uint32_t vtermno; |
86 | struct hv_ops *ops; | 87 | struct hv_ops *ops; |
@@ -319,10 +320,8 @@ static int hvc_open(struct tty_struct *tty, struct file * filp) | |||
319 | struct kobject *kobjp; | 320 | struct kobject *kobjp; |
320 | 321 | ||
321 | /* Auto increments kobject reference if found. */ | 322 | /* Auto increments kobject reference if found. */ |
322 | if (!(hp = hvc_get_by_index(tty->index))) { | 323 | if (!(hp = hvc_get_by_index(tty->index))) |
323 | printk(KERN_WARNING "hvc_console: tty open failed, no vty associated with tty.\n"); | ||
324 | return -ENODEV; | 324 | return -ENODEV; |
325 | } | ||
326 | 325 | ||
327 | spin_lock_irqsave(&hp->lock, flags); | 326 | spin_lock_irqsave(&hp->lock, flags); |
328 | /* Check and then increment for fast path open. */ | 327 | /* Check and then increment for fast path open. */ |
@@ -505,7 +504,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count | |||
505 | if (hp->n_outbuf > 0) | 504 | if (hp->n_outbuf > 0) |
506 | hvc_push(hp); | 505 | hvc_push(hp); |
507 | 506 | ||
508 | while (count > 0 && (rsize = N_OUTBUF - hp->n_outbuf) > 0) { | 507 | while (count > 0 && (rsize = hp->outbuf_size - hp->n_outbuf) > 0) { |
509 | if (rsize > count) | 508 | if (rsize > count) |
510 | rsize = count; | 509 | rsize = count; |
511 | memcpy(hp->outbuf + hp->n_outbuf, buf, rsize); | 510 | memcpy(hp->outbuf + hp->n_outbuf, buf, rsize); |
@@ -538,7 +537,7 @@ static int hvc_write_room(struct tty_struct *tty) | |||
538 | if (!hp) | 537 | if (!hp) |
539 | return -1; | 538 | return -1; |
540 | 539 | ||
541 | return N_OUTBUF - hp->n_outbuf; | 540 | return hp->outbuf_size - hp->n_outbuf; |
542 | } | 541 | } |
543 | 542 | ||
544 | static int hvc_chars_in_buffer(struct tty_struct *tty) | 543 | static int hvc_chars_in_buffer(struct tty_struct *tty) |
@@ -729,12 +728,13 @@ static struct kobj_type hvc_kobj_type = { | |||
729 | }; | 728 | }; |
730 | 729 | ||
731 | struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq, | 730 | struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq, |
732 | struct hv_ops *ops) | 731 | struct hv_ops *ops, int outbuf_size) |
733 | { | 732 | { |
734 | struct hvc_struct *hp; | 733 | struct hvc_struct *hp; |
735 | int i; | 734 | int i; |
736 | 735 | ||
737 | hp = kmalloc(sizeof(*hp), GFP_KERNEL); | 736 | hp = kmalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size, |
737 | GFP_KERNEL); | ||
738 | if (!hp) | 738 | if (!hp) |
739 | return ERR_PTR(-ENOMEM); | 739 | return ERR_PTR(-ENOMEM); |
740 | 740 | ||
@@ -743,6 +743,8 @@ struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq, | |||
743 | hp->vtermno = vtermno; | 743 | hp->vtermno = vtermno; |
744 | hp->irq = irq; | 744 | hp->irq = irq; |
745 | hp->ops = ops; | 745 | hp->ops = ops; |
746 | hp->outbuf_size = outbuf_size; | ||
747 | hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))]; | ||
746 | 748 | ||
747 | kobject_init(&hp->kobj); | 749 | kobject_init(&hp->kobj); |
748 | hp->kobj.ktype = &hvc_kobj_type; | 750 | hp->kobj.ktype = &hvc_kobj_type; |
diff --git a/drivers/char/hvc_console.h b/drivers/char/hvc_console.h index 96b7401319c1..8c59818050e6 100644 --- a/drivers/char/hvc_console.h +++ b/drivers/char/hvc_console.h | |||
@@ -56,7 +56,7 @@ extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops); | |||
56 | 56 | ||
57 | /* register a vterm for hvc tty operation (module_init or hotplug add) */ | 57 | /* register a vterm for hvc tty operation (module_init or hotplug add) */ |
58 | extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int irq, | 58 | extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int irq, |
59 | struct hv_ops *ops); | 59 | struct hv_ops *ops, int outbuf_size); |
60 | /* remove a vterm from hvc tty operation (modele_exit or hotplug remove) */ | 60 | /* remove a vterm from hvc tty operation (modele_exit or hotplug remove) */ |
61 | extern int __devexit hvc_remove(struct hvc_struct *hp); | 61 | extern int __devexit hvc_remove(struct hvc_struct *hp); |
62 | 62 | ||
diff --git a/drivers/char/hvc_iseries.c b/drivers/char/hvc_iseries.c new file mode 100644 index 000000000000..4747729459c7 --- /dev/null +++ b/drivers/char/hvc_iseries.c | |||
@@ -0,0 +1,594 @@ | |||
1 | /* | ||
2 | * iSeries vio driver interface to hvc_console.c | ||
3 | * | ||
4 | * This code is based heavily on hvc_vio.c and viocons.c | ||
5 | * | ||
6 | * Copyright (C) 2006 Stephen Rothwell, IBM Corporation | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | #include <stdarg.h> | ||
23 | #include <linux/types.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/spinlock.h> | ||
27 | #include <linux/console.h> | ||
28 | |||
29 | #include <asm/hvconsole.h> | ||
30 | #include <asm/vio.h> | ||
31 | #include <asm/prom.h> | ||
32 | #include <asm/iseries/vio.h> | ||
33 | #include <asm/iseries/hv_call.h> | ||
34 | #include <asm/iseries/hv_lp_config.h> | ||
35 | #include <asm/iseries/hv_lp_event.h> | ||
36 | |||
37 | #include "hvc_console.h" | ||
38 | |||
39 | #define VTTY_PORTS 10 | ||
40 | |||
41 | static DEFINE_SPINLOCK(consolelock); | ||
42 | static DEFINE_SPINLOCK(consoleloglock); | ||
43 | |||
44 | static const char hvc_driver_name[] = "hvc_console"; | ||
45 | |||
46 | #define IN_BUF_SIZE 200 | ||
47 | |||
48 | /* | ||
49 | * Our port information. | ||
50 | */ | ||
51 | static struct port_info { | ||
52 | HvLpIndex lp; | ||
53 | u64 seq; /* sequence number of last HV send */ | ||
54 | u64 ack; /* last ack from HV */ | ||
55 | struct hvc_struct *hp; | ||
56 | int in_start; | ||
57 | int in_end; | ||
58 | unsigned char in_buf[IN_BUF_SIZE]; | ||
59 | } port_info[VTTY_PORTS] = { | ||
60 | [ 0 ... VTTY_PORTS - 1 ] = { | ||
61 | .lp = HvLpIndexInvalid | ||
62 | } | ||
63 | }; | ||
64 | |||
65 | #define viochar_is_console(pi) ((pi) == &port_info[0]) | ||
66 | |||
67 | static struct vio_device_id hvc_driver_table[] __devinitdata = { | ||
68 | {"serial", "IBM,iSeries-vty"}, | ||
69 | { "", "" } | ||
70 | }; | ||
71 | MODULE_DEVICE_TABLE(vio, hvc_driver_table); | ||
72 | |||
73 | static void hvlog(char *fmt, ...) | ||
74 | { | ||
75 | int i; | ||
76 | unsigned long flags; | ||
77 | va_list args; | ||
78 | static char buf[256]; | ||
79 | |||
80 | spin_lock_irqsave(&consoleloglock, flags); | ||
81 | va_start(args, fmt); | ||
82 | i = vscnprintf(buf, sizeof(buf) - 1, fmt, args); | ||
83 | va_end(args); | ||
84 | buf[i++] = '\r'; | ||
85 | HvCall_writeLogBuffer(buf, i); | ||
86 | spin_unlock_irqrestore(&consoleloglock, flags); | ||
87 | } | ||
88 | |||
89 | /* | ||
90 | * Initialize the common fields in a charLpEvent | ||
91 | */ | ||
92 | static void init_data_event(struct viocharlpevent *viochar, HvLpIndex lp) | ||
93 | { | ||
94 | struct HvLpEvent *hev = &viochar->event; | ||
95 | |||
96 | memset(viochar, 0, sizeof(struct viocharlpevent)); | ||
97 | |||
98 | hev->flags = HV_LP_EVENT_VALID | HV_LP_EVENT_DEFERRED_ACK | | ||
99 | HV_LP_EVENT_INT; | ||
100 | hev->xType = HvLpEvent_Type_VirtualIo; | ||
101 | hev->xSubtype = viomajorsubtype_chario | viochardata; | ||
102 | hev->xSourceLp = HvLpConfig_getLpIndex(); | ||
103 | hev->xTargetLp = lp; | ||
104 | hev->xSizeMinus1 = sizeof(struct viocharlpevent); | ||
105 | hev->xSourceInstanceId = viopath_sourceinst(lp); | ||
106 | hev->xTargetInstanceId = viopath_targetinst(lp); | ||
107 | } | ||
108 | |||
109 | static int get_chars(uint32_t vtermno, char *buf, int count) | ||
110 | { | ||
111 | struct port_info *pi; | ||
112 | int n = 0; | ||
113 | unsigned long flags; | ||
114 | |||
115 | if (vtermno >= VTTY_PORTS) | ||
116 | return -EINVAL; | ||
117 | if (count == 0) | ||
118 | return 0; | ||
119 | |||
120 | pi = &port_info[vtermno]; | ||
121 | spin_lock_irqsave(&consolelock, flags); | ||
122 | |||
123 | if (pi->in_end == 0) | ||
124 | goto done; | ||
125 | |||
126 | n = pi->in_end - pi->in_start; | ||
127 | if (n > count) | ||
128 | n = count; | ||
129 | memcpy(buf, &pi->in_buf[pi->in_start], n); | ||
130 | pi->in_start += n; | ||
131 | if (pi->in_start == pi->in_end) { | ||
132 | pi->in_start = 0; | ||
133 | pi->in_end = 0; | ||
134 | } | ||
135 | done: | ||
136 | spin_unlock_irqrestore(&consolelock, flags); | ||
137 | return n; | ||
138 | } | ||
139 | |||
140 | static int put_chars(uint32_t vtermno, const char *buf, int count) | ||
141 | { | ||
142 | struct viocharlpevent *viochar; | ||
143 | struct port_info *pi; | ||
144 | HvLpEvent_Rc hvrc; | ||
145 | unsigned long flags; | ||
146 | int sent = 0; | ||
147 | |||
148 | if (vtermno >= VTTY_PORTS) | ||
149 | return -EINVAL; | ||
150 | |||
151 | pi = &port_info[vtermno]; | ||
152 | |||
153 | spin_lock_irqsave(&consolelock, flags); | ||
154 | |||
155 | if (viochar_is_console(pi) && !viopath_isactive(pi->lp)) { | ||
156 | spin_lock_irqsave(&consoleloglock, flags); | ||
157 | HvCall_writeLogBuffer(buf, count); | ||
158 | spin_unlock_irqrestore(&consoleloglock, flags); | ||
159 | sent = count; | ||
160 | goto done; | ||
161 | } | ||
162 | |||
163 | viochar = vio_get_event_buffer(viomajorsubtype_chario); | ||
164 | if (viochar == NULL) { | ||
165 | hvlog("\n\rviocons: Can't get viochar buffer."); | ||
166 | goto done; | ||
167 | } | ||
168 | |||
169 | while ((count > 0) && ((pi->seq - pi->ack) < VIOCHAR_WINDOW)) { | ||
170 | int len; | ||
171 | |||
172 | len = (count > VIOCHAR_MAX_DATA) ? VIOCHAR_MAX_DATA : count; | ||
173 | |||
174 | if (viochar_is_console(pi)) { | ||
175 | spin_lock_irqsave(&consoleloglock, flags); | ||
176 | HvCall_writeLogBuffer(buf, len); | ||
177 | spin_unlock_irqrestore(&consoleloglock, flags); | ||
178 | } | ||
179 | |||
180 | init_data_event(viochar, pi->lp); | ||
181 | |||
182 | viochar->len = len; | ||
183 | viochar->event.xCorrelationToken = pi->seq++; | ||
184 | viochar->event.xSizeMinus1 = | ||
185 | offsetof(struct viocharlpevent, data) + len; | ||
186 | |||
187 | memcpy(viochar->data, buf, len); | ||
188 | |||
189 | hvrc = HvCallEvent_signalLpEvent(&viochar->event); | ||
190 | if (hvrc) | ||
191 | hvlog("\n\rerror sending event! return code %d\n\r", | ||
192 | (int)hvrc); | ||
193 | sent += len; | ||
194 | count -= len; | ||
195 | buf += len; | ||
196 | } | ||
197 | |||
198 | vio_free_event_buffer(viomajorsubtype_chario, viochar); | ||
199 | done: | ||
200 | spin_unlock_irqrestore(&consolelock, flags); | ||
201 | return sent; | ||
202 | } | ||
203 | |||
204 | static struct hv_ops hvc_get_put_ops = { | ||
205 | .get_chars = get_chars, | ||
206 | .put_chars = put_chars, | ||
207 | }; | ||
208 | |||
209 | static int __devinit hvc_vio_probe(struct vio_dev *vdev, | ||
210 | const struct vio_device_id *id) | ||
211 | { | ||
212 | struct hvc_struct *hp; | ||
213 | struct port_info *pi; | ||
214 | |||
215 | /* probed with invalid parameters. */ | ||
216 | if (!vdev || !id) | ||
217 | return -EPERM; | ||
218 | |||
219 | if (vdev->unit_address >= VTTY_PORTS) | ||
220 | return -ENODEV; | ||
221 | |||
222 | pi = &port_info[vdev->unit_address]; | ||
223 | |||
224 | hp = hvc_alloc(vdev->unit_address, vdev->irq, &hvc_get_put_ops, | ||
225 | VIOCHAR_MAX_DATA); | ||
226 | if (IS_ERR(hp)) | ||
227 | return PTR_ERR(hp); | ||
228 | pi->hp = hp; | ||
229 | dev_set_drvdata(&vdev->dev, pi); | ||
230 | |||
231 | return 0; | ||
232 | } | ||
233 | |||
234 | static int __devexit hvc_vio_remove(struct vio_dev *vdev) | ||
235 | { | ||
236 | struct port_info *pi = dev_get_drvdata(&vdev->dev); | ||
237 | struct hvc_struct *hp = pi->hp; | ||
238 | |||
239 | return hvc_remove(hp); | ||
240 | } | ||
241 | |||
242 | static struct vio_driver hvc_vio_driver = { | ||
243 | .id_table = hvc_driver_table, | ||
244 | .probe = hvc_vio_probe, | ||
245 | .remove = hvc_vio_remove, | ||
246 | .driver = { | ||
247 | .name = hvc_driver_name, | ||
248 | .owner = THIS_MODULE, | ||
249 | } | ||
250 | }; | ||
251 | |||
252 | static void hvc_open_event(struct HvLpEvent *event) | ||
253 | { | ||
254 | unsigned long flags; | ||
255 | struct viocharlpevent *cevent = (struct viocharlpevent *)event; | ||
256 | u8 port = cevent->virtual_device; | ||
257 | struct port_info *pi; | ||
258 | int reject = 0; | ||
259 | |||
260 | if (hvlpevent_is_ack(event)) { | ||
261 | if (port >= VTTY_PORTS) | ||
262 | return; | ||
263 | |||
264 | spin_lock_irqsave(&consolelock, flags); | ||
265 | |||
266 | pi = &port_info[port]; | ||
267 | if (event->xRc == HvLpEvent_Rc_Good) { | ||
268 | pi->seq = pi->ack = 0; | ||
269 | /* | ||
270 | * This line allows connections from the primary | ||
271 | * partition but once one is connected from the | ||
272 | * primary partition nothing short of a reboot | ||
273 | * of linux will allow access from the hosting | ||
274 | * partition again without a required iSeries fix. | ||
275 | */ | ||
276 | pi->lp = event->xTargetLp; | ||
277 | } | ||
278 | |||
279 | spin_unlock_irqrestore(&consolelock, flags); | ||
280 | if (event->xRc != HvLpEvent_Rc_Good) | ||
281 | printk(KERN_WARNING | ||
282 | "hvc: handle_open_event: event->xRc == (%d).\n", | ||
283 | event->xRc); | ||
284 | |||
285 | if (event->xCorrelationToken != 0) { | ||
286 | atomic_t *aptr= (atomic_t *)event->xCorrelationToken; | ||
287 | atomic_set(aptr, 1); | ||
288 | } else | ||
289 | printk(KERN_WARNING | ||
290 | "hvc: weird...got open ack without atomic\n"); | ||
291 | return; | ||
292 | } | ||
293 | |||
294 | /* This had better require an ack, otherwise complain */ | ||
295 | if (!hvlpevent_need_ack(event)) { | ||
296 | printk(KERN_WARNING "hvc: viocharopen without ack bit!\n"); | ||
297 | return; | ||
298 | } | ||
299 | |||
300 | spin_lock_irqsave(&consolelock, flags); | ||
301 | |||
302 | /* Make sure this is a good virtual tty */ | ||
303 | if (port >= VTTY_PORTS) { | ||
304 | event->xRc = HvLpEvent_Rc_SubtypeError; | ||
305 | cevent->subtype_result_code = viorc_openRejected; | ||
306 | /* | ||
307 | * Flag state here since we can't printk while holding | ||
308 | * the consolelock spinlock. | ||
309 | */ | ||
310 | reject = 1; | ||
311 | } else { | ||
312 | pi = &port_info[port]; | ||
313 | if ((pi->lp != HvLpIndexInvalid) && | ||
314 | (pi->lp != event->xSourceLp)) { | ||
315 | /* | ||
316 | * If this is tty is already connected to a different | ||
317 | * partition, fail. | ||
318 | */ | ||
319 | event->xRc = HvLpEvent_Rc_SubtypeError; | ||
320 | cevent->subtype_result_code = viorc_openRejected; | ||
321 | reject = 2; | ||
322 | } else { | ||
323 | pi->lp = event->xSourceLp; | ||
324 | event->xRc = HvLpEvent_Rc_Good; | ||
325 | cevent->subtype_result_code = viorc_good; | ||
326 | pi->seq = pi->ack = 0; | ||
327 | } | ||
328 | } | ||
329 | |||
330 | spin_unlock_irqrestore(&consolelock, flags); | ||
331 | |||
332 | if (reject == 1) | ||
333 | printk(KERN_WARNING "hvc: open rejected: bad virtual tty.\n"); | ||
334 | else if (reject == 2) | ||
335 | printk(KERN_WARNING "hvc: open rejected: console in exclusive " | ||
336 | "use by another partition.\n"); | ||
337 | |||
338 | /* Return the acknowledgement */ | ||
339 | HvCallEvent_ackLpEvent(event); | ||
340 | } | ||
341 | |||
342 | /* | ||
343 | * Handle a close charLpEvent. This should ONLY be an Interrupt because the | ||
344 | * virtual console should never actually issue a close event to the hypervisor | ||
345 | * because the virtual console never goes away. A close event coming from the | ||
346 | * hypervisor simply means that there are no client consoles connected to the | ||
347 | * virtual console. | ||
348 | */ | ||
349 | static void hvc_close_event(struct HvLpEvent *event) | ||
350 | { | ||
351 | unsigned long flags; | ||
352 | struct viocharlpevent *cevent = (struct viocharlpevent *)event; | ||
353 | u8 port = cevent->virtual_device; | ||
354 | |||
355 | if (!hvlpevent_is_int(event)) { | ||
356 | printk(KERN_WARNING | ||
357 | "hvc: got unexpected close acknowlegement\n"); | ||
358 | return; | ||
359 | } | ||
360 | |||
361 | if (port >= VTTY_PORTS) { | ||
362 | printk(KERN_WARNING | ||
363 | "hvc: close message from invalid virtual device.\n"); | ||
364 | return; | ||
365 | } | ||
366 | |||
367 | /* For closes, just mark the console partition invalid */ | ||
368 | spin_lock_irqsave(&consolelock, flags); | ||
369 | |||
370 | if (port_info[port].lp == event->xSourceLp) | ||
371 | port_info[port].lp = HvLpIndexInvalid; | ||
372 | |||
373 | spin_unlock_irqrestore(&consolelock, flags); | ||
374 | } | ||
375 | |||
376 | static void hvc_data_event(struct HvLpEvent *event) | ||
377 | { | ||
378 | unsigned long flags; | ||
379 | struct viocharlpevent *cevent = (struct viocharlpevent *)event; | ||
380 | struct port_info *pi; | ||
381 | int n; | ||
382 | u8 port = cevent->virtual_device; | ||
383 | |||
384 | if (port >= VTTY_PORTS) { | ||
385 | printk(KERN_WARNING "hvc: data on invalid virtual device %d\n", | ||
386 | port); | ||
387 | return; | ||
388 | } | ||
389 | if (cevent->len == 0) | ||
390 | return; | ||
391 | |||
392 | /* | ||
393 | * Change 05/01/2003 - Ryan Arnold: If a partition other than | ||
394 | * the current exclusive partition tries to send us data | ||
395 | * events then just drop them on the floor because we don't | ||
396 | * want his stinking data. He isn't authorized to receive | ||
397 | * data because he wasn't the first one to get the console, | ||
398 | * therefore he shouldn't be allowed to send data either. | ||
399 | * This will work without an iSeries fix. | ||
400 | */ | ||
401 | pi = &port_info[port]; | ||
402 | if (pi->lp != event->xSourceLp) | ||
403 | return; | ||
404 | |||
405 | spin_lock_irqsave(&consolelock, flags); | ||
406 | |||
407 | n = IN_BUF_SIZE - pi->in_end; | ||
408 | if (n > cevent->len) | ||
409 | n = cevent->len; | ||
410 | if (n > 0) { | ||
411 | memcpy(&pi->in_buf[pi->in_end], cevent->data, n); | ||
412 | pi->in_end += n; | ||
413 | } | ||
414 | spin_unlock_irqrestore(&consolelock, flags); | ||
415 | if (n == 0) | ||
416 | printk(KERN_WARNING "hvc: input buffer overflow\n"); | ||
417 | } | ||
418 | |||
419 | static void hvc_ack_event(struct HvLpEvent *event) | ||
420 | { | ||
421 | struct viocharlpevent *cevent = (struct viocharlpevent *)event; | ||
422 | unsigned long flags; | ||
423 | u8 port = cevent->virtual_device; | ||
424 | |||
425 | if (port >= VTTY_PORTS) { | ||
426 | printk(KERN_WARNING "hvc: data on invalid virtual device\n"); | ||
427 | return; | ||
428 | } | ||
429 | |||
430 | spin_lock_irqsave(&consolelock, flags); | ||
431 | port_info[port].ack = event->xCorrelationToken; | ||
432 | spin_unlock_irqrestore(&consolelock, flags); | ||
433 | } | ||
434 | |||
435 | static void hvc_config_event(struct HvLpEvent *event) | ||
436 | { | ||
437 | struct viocharlpevent *cevent = (struct viocharlpevent *)event; | ||
438 | |||
439 | if (cevent->data[0] == 0x01) | ||
440 | printk(KERN_INFO "hvc: window resized to %d: %d: %d: %d\n", | ||
441 | cevent->data[1], cevent->data[2], | ||
442 | cevent->data[3], cevent->data[4]); | ||
443 | else | ||
444 | printk(KERN_WARNING "hvc: unknown config event\n"); | ||
445 | } | ||
446 | |||
447 | static void hvc_handle_event(struct HvLpEvent *event) | ||
448 | { | ||
449 | int charminor; | ||
450 | |||
451 | if (event == NULL) | ||
452 | return; | ||
453 | |||
454 | charminor = event->xSubtype & VIOMINOR_SUBTYPE_MASK; | ||
455 | switch (charminor) { | ||
456 | case viocharopen: | ||
457 | hvc_open_event(event); | ||
458 | break; | ||
459 | case viocharclose: | ||
460 | hvc_close_event(event); | ||
461 | break; | ||
462 | case viochardata: | ||
463 | hvc_data_event(event); | ||
464 | break; | ||
465 | case viocharack: | ||
466 | hvc_ack_event(event); | ||
467 | break; | ||
468 | case viocharconfig: | ||
469 | hvc_config_event(event); | ||
470 | break; | ||
471 | default: | ||
472 | if (hvlpevent_is_int(event) && hvlpevent_need_ack(event)) { | ||
473 | event->xRc = HvLpEvent_Rc_InvalidSubtype; | ||
474 | HvCallEvent_ackLpEvent(event); | ||
475 | } | ||
476 | } | ||
477 | } | ||
478 | |||
479 | static int send_open(HvLpIndex remoteLp, void *sem) | ||
480 | { | ||
481 | return HvCallEvent_signalLpEventFast(remoteLp, | ||
482 | HvLpEvent_Type_VirtualIo, | ||
483 | viomajorsubtype_chario | viocharopen, | ||
484 | HvLpEvent_AckInd_DoAck, HvLpEvent_AckType_ImmediateAck, | ||
485 | viopath_sourceinst(remoteLp), | ||
486 | viopath_targetinst(remoteLp), | ||
487 | (u64)(unsigned long)sem, VIOVERSION << 16, | ||
488 | 0, 0, 0, 0); | ||
489 | } | ||
490 | |||
491 | static int hvc_vio_init(void) | ||
492 | { | ||
493 | atomic_t wait_flag; | ||
494 | int rc; | ||
495 | |||
496 | /* +2 for fudge */ | ||
497 | rc = viopath_open(HvLpConfig_getPrimaryLpIndex(), | ||
498 | viomajorsubtype_chario, VIOCHAR_WINDOW + 2); | ||
499 | if (rc) | ||
500 | printk(KERN_WARNING "hvc: error opening to primary %d\n", rc); | ||
501 | |||
502 | if (viopath_hostLp == HvLpIndexInvalid) | ||
503 | vio_set_hostlp(); | ||
504 | |||
505 | /* | ||
506 | * And if the primary is not the same as the hosting LP, open to the | ||
507 | * hosting lp | ||
508 | */ | ||
509 | if ((viopath_hostLp != HvLpIndexInvalid) && | ||
510 | (viopath_hostLp != HvLpConfig_getPrimaryLpIndex())) { | ||
511 | printk(KERN_INFO "hvc: open path to hosting (%d)\n", | ||
512 | viopath_hostLp); | ||
513 | rc = viopath_open(viopath_hostLp, viomajorsubtype_chario, | ||
514 | VIOCHAR_WINDOW + 2); /* +2 for fudge */ | ||
515 | if (rc) | ||
516 | printk(KERN_WARNING | ||
517 | "error opening to partition %d: %d\n", | ||
518 | viopath_hostLp, rc); | ||
519 | } | ||
520 | |||
521 | if (vio_setHandler(viomajorsubtype_chario, hvc_handle_event) < 0) | ||
522 | printk(KERN_WARNING | ||
523 | "hvc: error seting handler for console events!\n"); | ||
524 | |||
525 | /* | ||
526 | * First, try to open the console to the hosting lp. | ||
527 | * Wait on a semaphore for the response. | ||
528 | */ | ||
529 | atomic_set(&wait_flag, 0); | ||
530 | if ((viopath_isactive(viopath_hostLp)) && | ||
531 | (send_open(viopath_hostLp, &wait_flag) == 0)) { | ||
532 | printk(KERN_INFO "hvc: hosting partition %d\n", viopath_hostLp); | ||
533 | while (atomic_read(&wait_flag) == 0) | ||
534 | mb(); | ||
535 | atomic_set(&wait_flag, 0); | ||
536 | } | ||
537 | |||
538 | /* | ||
539 | * If we don't have an active console, try the primary | ||
540 | */ | ||
541 | if ((!viopath_isactive(port_info[0].lp)) && | ||
542 | (viopath_isactive(HvLpConfig_getPrimaryLpIndex())) && | ||
543 | (send_open(HvLpConfig_getPrimaryLpIndex(), &wait_flag) == 0)) { | ||
544 | printk(KERN_INFO "hvc: opening console to primary partition\n"); | ||
545 | while (atomic_read(&wait_flag) == 0) | ||
546 | mb(); | ||
547 | } | ||
548 | |||
549 | /* Register as a vio device to receive callbacks */ | ||
550 | rc = vio_register_driver(&hvc_vio_driver); | ||
551 | |||
552 | return rc; | ||
553 | } | ||
554 | module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */ | ||
555 | |||
556 | static void hvc_vio_exit(void) | ||
557 | { | ||
558 | vio_unregister_driver(&hvc_vio_driver); | ||
559 | } | ||
560 | module_exit(hvc_vio_exit); | ||
561 | |||
562 | /* the device tree order defines our numbering */ | ||
563 | static int hvc_find_vtys(void) | ||
564 | { | ||
565 | struct device_node *vty; | ||
566 | int num_found = 0; | ||
567 | |||
568 | for (vty = of_find_node_by_name(NULL, "vty"); vty != NULL; | ||
569 | vty = of_find_node_by_name(vty, "vty")) { | ||
570 | uint32_t *vtermno; | ||
571 | |||
572 | /* We have statically defined space for only a certain number | ||
573 | * of console adapters. | ||
574 | */ | ||
575 | if ((num_found >= MAX_NR_HVC_CONSOLES) || | ||
576 | (num_found >= VTTY_PORTS)) | ||
577 | break; | ||
578 | |||
579 | vtermno = (uint32_t *)get_property(vty, "reg", NULL); | ||
580 | if (!vtermno) | ||
581 | continue; | ||
582 | |||
583 | if (!device_is_compatible(vty, "IBM,iSeries-vty")) | ||
584 | continue; | ||
585 | |||
586 | if (num_found == 0) | ||
587 | add_preferred_console("hvc", 0, NULL); | ||
588 | hvc_instantiate(*vtermno, num_found, &hvc_get_put_ops); | ||
589 | ++num_found; | ||
590 | } | ||
591 | |||
592 | return num_found; | ||
593 | } | ||
594 | console_initcall(hvc_find_vtys); | ||
diff --git a/drivers/char/hvc_rtas.c b/drivers/char/hvc_rtas.c index 57106e02fd2e..4b97eaf18602 100644 --- a/drivers/char/hvc_rtas.c +++ b/drivers/char/hvc_rtas.c | |||
@@ -94,7 +94,7 @@ static int hvc_rtas_init(void) | |||
94 | 94 | ||
95 | /* Allocate an hvc_struct for the console device we instantiated | 95 | /* Allocate an hvc_struct for the console device we instantiated |
96 | * earlier. Save off hp so that we can return it on exit */ | 96 | * earlier. Save off hp so that we can return it on exit */ |
97 | hp = hvc_alloc(hvc_rtas_cookie, NO_IRQ, &hvc_rtas_get_put_ops); | 97 | hp = hvc_alloc(hvc_rtas_cookie, NO_IRQ, &hvc_rtas_get_put_ops, 16); |
98 | if (IS_ERR(hp)) | 98 | if (IS_ERR(hp)) |
99 | return PTR_ERR(hp); | 99 | return PTR_ERR(hp); |
100 | 100 | ||
diff --git a/drivers/char/hvc_vio.c b/drivers/char/hvc_vio.c index 9add81ceb440..cc95941148fb 100644 --- a/drivers/char/hvc_vio.c +++ b/drivers/char/hvc_vio.c | |||
@@ -90,7 +90,8 @@ static int __devinit hvc_vio_probe(struct vio_dev *vdev, | |||
90 | if (!vdev || !id) | 90 | if (!vdev || !id) |
91 | return -EPERM; | 91 | return -EPERM; |
92 | 92 | ||
93 | hp = hvc_alloc(vdev->unit_address, vdev->irq, &hvc_get_put_ops); | 93 | hp = hvc_alloc(vdev->unit_address, vdev->irq, &hvc_get_put_ops, |
94 | MAX_VIO_PUT_CHARS); | ||
94 | if (IS_ERR(hp)) | 95 | if (IS_ERR(hp)) |
95 | return PTR_ERR(hp); | 96 | return PTR_ERR(hp); |
96 | dev_set_drvdata(&vdev->dev, hp); | 97 | dev_set_drvdata(&vdev->dev, hp); |
@@ -140,7 +141,7 @@ static int hvc_find_vtys(void) | |||
140 | 141 | ||
141 | for (vty = of_find_node_by_name(NULL, "vty"); vty != NULL; | 142 | for (vty = of_find_node_by_name(NULL, "vty"); vty != NULL; |
142 | vty = of_find_node_by_name(vty, "vty")) { | 143 | vty = of_find_node_by_name(vty, "vty")) { |
143 | uint32_t *vtermno; | 144 | const uint32_t *vtermno; |
144 | 145 | ||
145 | /* We have statically defined space for only a certain number | 146 | /* We have statically defined space for only a certain number |
146 | * of console adapters. | 147 | * of console adapters. |
@@ -148,7 +149,7 @@ static int hvc_find_vtys(void) | |||
148 | if (num_found >= MAX_NR_HVC_CONSOLES) | 149 | if (num_found >= MAX_NR_HVC_CONSOLES) |
149 | break; | 150 | break; |
150 | 151 | ||
151 | vtermno = (uint32_t *)get_property(vty, "reg", NULL); | 152 | vtermno = get_property(vty, "reg", NULL); |
152 | if (!vtermno) | 153 | if (!vtermno) |
153 | continue; | 154 | continue; |
154 | 155 | ||
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c index 017f755632a3..a89a95fb5e40 100644 --- a/drivers/char/hvsi.c +++ b/drivers/char/hvsi.c | |||
@@ -1274,11 +1274,10 @@ static int __init hvsi_console_init(void) | |||
1274 | vty != NULL; | 1274 | vty != NULL; |
1275 | vty = of_find_compatible_node(vty, "serial", "hvterm-protocol")) { | 1275 | vty = of_find_compatible_node(vty, "serial", "hvterm-protocol")) { |
1276 | struct hvsi_struct *hp; | 1276 | struct hvsi_struct *hp; |
1277 | uint32_t *vtermno; | 1277 | const uint32_t *vtermno, *irq; |
1278 | uint32_t *irq; | ||
1279 | 1278 | ||
1280 | vtermno = (uint32_t *)get_property(vty, "reg", NULL); | 1279 | vtermno = get_property(vty, "reg", NULL); |
1281 | irq = (uint32_t *)get_property(vty, "interrupts", NULL); | 1280 | irq = get_property(vty, "interrupts", NULL); |
1282 | if (!vtermno || !irq) | 1281 | if (!vtermno || !irq) |
1283 | continue; | 1282 | continue; |
1284 | 1283 | ||
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h index 2e68eeb8a2cd..aefd683c60b7 100644 --- a/drivers/char/tpm/tpm_atmel.h +++ b/drivers/char/tpm/tpm_atmel.h | |||
@@ -37,7 +37,7 @@ static void __iomem * atmel_get_base_addr(unsigned long *base, int *region_size) | |||
37 | { | 37 | { |
38 | struct device_node *dn; | 38 | struct device_node *dn; |
39 | unsigned long address, size; | 39 | unsigned long address, size; |
40 | unsigned int *reg; | 40 | const unsigned int *reg; |
41 | int reglen; | 41 | int reglen; |
42 | int naddrc; | 42 | int naddrc; |
43 | int nsizec; | 43 | int nsizec; |
@@ -52,7 +52,7 @@ static void __iomem * atmel_get_base_addr(unsigned long *base, int *region_size) | |||
52 | return NULL; | 52 | return NULL; |
53 | } | 53 | } |
54 | 54 | ||
55 | reg = (unsigned int *) get_property(dn, "reg", ®len); | 55 | reg = get_property(dn, "reg", ®len); |
56 | naddrc = prom_n_addr_cells(dn); | 56 | naddrc = prom_n_addr_cells(dn); |
57 | nsizec = prom_n_size_cells(dn); | 57 | nsizec = prom_n_size_cells(dn); |
58 | 58 | ||
diff --git a/drivers/char/viocons.c b/drivers/char/viocons.c index 766f7864c6c6..f3efeaf2826e 100644 --- a/drivers/char/viocons.c +++ b/drivers/char/viocons.c | |||
@@ -43,7 +43,6 @@ | |||
43 | #include <linux/sysrq.h> | 43 | #include <linux/sysrq.h> |
44 | 44 | ||
45 | #include <asm/iseries/vio.h> | 45 | #include <asm/iseries/vio.h> |
46 | |||
47 | #include <asm/iseries/hv_lp_event.h> | 46 | #include <asm/iseries/hv_lp_event.h> |
48 | #include <asm/iseries/hv_call_event.h> | 47 | #include <asm/iseries/hv_call_event.h> |
49 | #include <asm/iseries/hv_lp_config.h> | 48 | #include <asm/iseries/hv_lp_config.h> |
@@ -67,35 +66,6 @@ static int vio_sysrq_pressed; | |||
67 | extern int sysrq_enabled; | 66 | extern int sysrq_enabled; |
68 | #endif | 67 | #endif |
69 | 68 | ||
70 | /* | ||
71 | * The structure of the events that flow between us and OS/400. You can't | ||
72 | * mess with this unless the OS/400 side changes too | ||
73 | */ | ||
74 | struct viocharlpevent { | ||
75 | struct HvLpEvent event; | ||
76 | u32 reserved; | ||
77 | u16 version; | ||
78 | u16 subtype_result_code; | ||
79 | u8 virtual_device; | ||
80 | u8 len; | ||
81 | u8 data[VIOCHAR_MAX_DATA]; | ||
82 | }; | ||
83 | |||
84 | #define VIOCHAR_WINDOW 10 | ||
85 | #define VIOCHAR_HIGHWATERMARK 3 | ||
86 | |||
87 | enum viocharsubtype { | ||
88 | viocharopen = 0x0001, | ||
89 | viocharclose = 0x0002, | ||
90 | viochardata = 0x0003, | ||
91 | viocharack = 0x0004, | ||
92 | viocharconfig = 0x0005 | ||
93 | }; | ||
94 | |||
95 | enum viochar_rc { | ||
96 | viochar_rc_ebusy = 1 | ||
97 | }; | ||
98 | |||
99 | #define VIOCHAR_NUM_BUF 16 | 69 | #define VIOCHAR_NUM_BUF 16 |
100 | 70 | ||
101 | /* | 71 | /* |
@@ -1183,6 +1153,7 @@ static int __init viocons_init(void) | |||
1183 | port_info[i].magic = VIOTTY_MAGIC; | 1153 | port_info[i].magic = VIOTTY_MAGIC; |
1184 | } | 1154 | } |
1185 | HvCall_setLogBufferFormatAndCodepage(HvCall_LogBuffer_ASCII, 437); | 1155 | HvCall_setLogBufferFormatAndCodepage(HvCall_LogBuffer_ASCII, 437); |
1156 | add_preferred_console("viocons", 0, NULL); | ||
1186 | register_console(&viocons_early); | 1157 | register_console(&viocons_early); |
1187 | return 0; | 1158 | return 0; |
1188 | } | 1159 | } |
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c index b72b2049aaae..73c78bf75d7f 100644 --- a/drivers/char/viotape.c +++ b/drivers/char/viotape.c | |||
@@ -940,7 +940,6 @@ static void vioHandleTapeEvent(struct HvLpEvent *event) | |||
940 | 940 | ||
941 | static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id) | 941 | static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id) |
942 | { | 942 | { |
943 | char tapename[32]; | ||
944 | int i = vdev->unit_address; | 943 | int i = vdev->unit_address; |
945 | int j; | 944 | int j; |
946 | 945 | ||
@@ -956,10 +955,9 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id) | |||
956 | "iseries!vt%d", i); | 955 | "iseries!vt%d", i); |
957 | class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), | 956 | class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), |
958 | NULL, "iseries!nvt%d", i); | 957 | NULL, "iseries!nvt%d", i); |
959 | sprintf(tapename, "iseries/vt%d", i); | 958 | printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries " |
960 | printk(VIOTAPE_KERN_INFO "tape %s is iSeries " | ||
961 | "resource %10.10s type %4.4s, model %3.3s\n", | 959 | "resource %10.10s type %4.4s, model %3.3s\n", |
962 | tapename, viotape_unitinfo[i].rsrcname, | 960 | i, viotape_unitinfo[i].rsrcname, |
963 | viotape_unitinfo[i].type, viotape_unitinfo[i].model); | 961 | viotape_unitinfo[i].type, viotape_unitinfo[i].model); |
964 | return 0; | 962 | return 0; |
965 | } | 963 | } |
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c index 53bb43593863..d658d9107955 100644 --- a/drivers/i2c/busses/i2c-powermac.c +++ b/drivers/i2c/busses/i2c-powermac.c | |||
@@ -207,7 +207,8 @@ static int i2c_powermac_probe(struct device *dev) | |||
207 | struct pmac_i2c_bus *bus = dev->platform_data; | 207 | struct pmac_i2c_bus *bus = dev->platform_data; |
208 | struct device_node *parent = NULL; | 208 | struct device_node *parent = NULL; |
209 | struct i2c_adapter *adapter; | 209 | struct i2c_adapter *adapter; |
210 | char name[32], *basename; | 210 | char name[32]; |
211 | const char *basename; | ||
211 | int rc; | 212 | int rc; |
212 | 213 | ||
213 | if (bus == NULL) | 214 | if (bus == NULL) |
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index ebf961f1718d..996c694341bc 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
@@ -1154,7 +1154,7 @@ static int | |||
1154 | pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | 1154 | pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) |
1155 | { | 1155 | { |
1156 | struct device_node *np = pmif->node; | 1156 | struct device_node *np = pmif->node; |
1157 | int *bidp; | 1157 | const int *bidp; |
1158 | 1158 | ||
1159 | pmif->cable_80 = 0; | 1159 | pmif->cable_80 = 0; |
1160 | pmif->broken_dma = pmif->broken_dma_warn = 0; | 1160 | pmif->broken_dma = pmif->broken_dma_warn = 0; |
@@ -1176,14 +1176,14 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) | |||
1176 | pmif->broken_dma = 1; | 1176 | pmif->broken_dma = 1; |
1177 | } | 1177 | } |
1178 | 1178 | ||
1179 | bidp = (int *)get_property(np, "AAPL,bus-id", NULL); | 1179 | bidp = get_property(np, "AAPL,bus-id", NULL); |
1180 | pmif->aapl_bus_id = bidp ? *bidp : 0; | 1180 | pmif->aapl_bus_id = bidp ? *bidp : 0; |
1181 | 1181 | ||
1182 | /* Get cable type from device-tree */ | 1182 | /* Get cable type from device-tree */ |
1183 | if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6 | 1183 | if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6 |
1184 | || pmif->kind == controller_k2_ata6 | 1184 | || pmif->kind == controller_k2_ata6 |
1185 | || pmif->kind == controller_sh_ata6) { | 1185 | || pmif->kind == controller_sh_ata6) { |
1186 | char* cable = get_property(np, "cable-type", NULL); | 1186 | const char* cable = get_property(np, "cable-type", NULL); |
1187 | if (cable && !strncmp(cable, "80-", 3)) | 1187 | if (cable && !strncmp(cable, "80-", 3)) |
1188 | pmif->cable_80 = 1; | 1188 | pmif->cable_80 = 1; |
1189 | } | 1189 | } |
@@ -1326,7 +1326,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
1326 | if (macio_irq_count(mdev) == 0) { | 1326 | if (macio_irq_count(mdev) == 0) { |
1327 | printk(KERN_WARNING "ide%d: no intrs for device %s, using 13\n", | 1327 | printk(KERN_WARNING "ide%d: no intrs for device %s, using 13\n", |
1328 | i, mdev->ofdev.node->full_name); | 1328 | i, mdev->ofdev.node->full_name); |
1329 | irq = 13; | 1329 | irq = irq_create_mapping(NULL, 13); |
1330 | } else | 1330 | } else |
1331 | irq = macio_irq(mdev, 0); | 1331 | irq = macio_irq(mdev, 0); |
1332 | 1332 | ||
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c index 82657bc86d19..d56216067549 100644 --- a/drivers/macintosh/macio_asic.c +++ b/drivers/macintosh/macio_asic.c | |||
@@ -139,7 +139,9 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp, | |||
139 | { | 139 | { |
140 | struct macio_dev * macio_dev; | 140 | struct macio_dev * macio_dev; |
141 | struct of_device * of; | 141 | struct of_device * of; |
142 | char *scratch, *compat, *compat2; | 142 | char *scratch; |
143 | const char *compat, *compat2; | ||
144 | |||
143 | int i = 0; | 145 | int i = 0; |
144 | int length, cplen, cplen2, seen = 0; | 146 | int length, cplen, cplen2, seen = 0; |
145 | 147 | ||
@@ -173,7 +175,7 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp, | |||
173 | * it's not really legal to split it out with commas. We split it | 175 | * it's not really legal to split it out with commas. We split it |
174 | * up using a number of environment variables instead. */ | 176 | * up using a number of environment variables instead. */ |
175 | 177 | ||
176 | compat = (char *) get_property(of->node, "compatible", &cplen); | 178 | compat = get_property(of->node, "compatible", &cplen); |
177 | compat2 = compat; | 179 | compat2 = compat; |
178 | cplen2= cplen; | 180 | cplen2= cplen; |
179 | while (compat && cplen > 0) { | 181 | while (compat && cplen > 0) { |
@@ -454,7 +456,7 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip, | |||
454 | struct resource *parent_res) | 456 | struct resource *parent_res) |
455 | { | 457 | { |
456 | struct macio_dev *dev; | 458 | struct macio_dev *dev; |
457 | u32 *reg; | 459 | const u32 *reg; |
458 | 460 | ||
459 | if (np == NULL) | 461 | if (np == NULL) |
460 | return NULL; | 462 | return NULL; |
@@ -489,7 +491,7 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip, | |||
489 | #endif | 491 | #endif |
490 | MAX_NODE_NAME_SIZE, np->name); | 492 | MAX_NODE_NAME_SIZE, np->name); |
491 | } else { | 493 | } else { |
492 | reg = (u32 *)get_property(np, "reg", NULL); | 494 | reg = get_property(np, "reg", NULL); |
493 | sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s", | 495 | sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s", |
494 | chip->lbus.index, | 496 | chip->lbus.index, |
495 | reg ? *reg : 0, MAX_NODE_NAME_SIZE, np->name); | 497 | reg ? *reg : 0, MAX_NODE_NAME_SIZE, np->name); |
diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c index cae24a13526a..8566bdfdd4b8 100644 --- a/drivers/macintosh/macio_sysfs.c +++ b/drivers/macintosh/macio_sysfs.c | |||
@@ -16,12 +16,12 @@ static ssize_t | |||
16 | compatible_show (struct device *dev, struct device_attribute *attr, char *buf) | 16 | compatible_show (struct device *dev, struct device_attribute *attr, char *buf) |
17 | { | 17 | { |
18 | struct of_device *of; | 18 | struct of_device *of; |
19 | char *compat; | 19 | const char *compat; |
20 | int cplen; | 20 | int cplen; |
21 | int length = 0; | 21 | int length = 0; |
22 | 22 | ||
23 | of = &to_macio_device (dev)->ofdev; | 23 | of = &to_macio_device (dev)->ofdev; |
24 | compat = (char *) get_property(of->node, "compatible", &cplen); | 24 | compat = get_property(of->node, "compatible", &cplen); |
25 | if (!compat) { | 25 | if (!compat) { |
26 | *buf = '\0'; | 26 | *buf = '\0'; |
27 | return 0; | 27 | return 0; |
@@ -42,12 +42,12 @@ static ssize_t modalias_show (struct device *dev, struct device_attribute *attr, | |||
42 | char *buf) | 42 | char *buf) |
43 | { | 43 | { |
44 | struct of_device *of; | 44 | struct of_device *of; |
45 | char *compat; | 45 | const char *compat; |
46 | int cplen; | 46 | int cplen; |
47 | int length; | 47 | int length; |
48 | 48 | ||
49 | of = &to_macio_device (dev)->ofdev; | 49 | of = &to_macio_device (dev)->ofdev; |
50 | compat = (char *) get_property (of->node, "compatible", &cplen); | 50 | compat = get_property(of->node, "compatible", &cplen); |
51 | if (!compat) compat = "", cplen = 1; | 51 | if (!compat) compat = "", cplen = 1; |
52 | length = sprintf (buf, "of:N%sT%s", of->node->name, of->node->type); | 52 | length = sprintf (buf, "of:N%sT%s", of->node->name, of->node->type); |
53 | buf += length; | 53 | buf += length; |
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index 00ef46898147..090e40fc5013 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c | |||
@@ -454,7 +454,7 @@ EXPORT_SYMBOL(smu_present); | |||
454 | int __init smu_init (void) | 454 | int __init smu_init (void) |
455 | { | 455 | { |
456 | struct device_node *np; | 456 | struct device_node *np; |
457 | u32 *data; | 457 | const u32 *data; |
458 | 458 | ||
459 | np = of_find_node_by_type(NULL, "smu"); | 459 | np = of_find_node_by_type(NULL, "smu"); |
460 | if (np == NULL) | 460 | if (np == NULL) |
@@ -490,7 +490,7 @@ int __init smu_init (void) | |||
490 | printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n"); | 490 | printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n"); |
491 | goto fail; | 491 | goto fail; |
492 | } | 492 | } |
493 | data = (u32 *)get_property(smu->db_node, "reg", NULL); | 493 | data = get_property(smu->db_node, "reg", NULL); |
494 | if (data == NULL) { | 494 | if (data == NULL) { |
495 | of_node_put(smu->db_node); | 495 | of_node_put(smu->db_node); |
496 | smu->db_node = NULL; | 496 | smu->db_node = NULL; |
@@ -511,7 +511,7 @@ int __init smu_init (void) | |||
511 | smu->msg_node = of_find_node_by_name(NULL, "smu-interrupt"); | 511 | smu->msg_node = of_find_node_by_name(NULL, "smu-interrupt"); |
512 | if (smu->msg_node == NULL) | 512 | if (smu->msg_node == NULL) |
513 | break; | 513 | break; |
514 | data = (u32 *)get_property(smu->msg_node, "reg", NULL); | 514 | data = get_property(smu->msg_node, "reg", NULL); |
515 | if (data == NULL) { | 515 | if (data == NULL) { |
516 | of_node_put(smu->msg_node); | 516 | of_node_put(smu->msg_node); |
517 | smu->msg_node = NULL; | 517 | smu->msg_node = NULL; |
@@ -982,11 +982,11 @@ static struct smu_sdbp_header *smu_create_sdb_partition(int id) | |||
982 | /* Note: Only allowed to return error code in pointers (using ERR_PTR) | 982 | /* Note: Only allowed to return error code in pointers (using ERR_PTR) |
983 | * when interruptible is 1 | 983 | * when interruptible is 1 |
984 | */ | 984 | */ |
985 | struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size, | 985 | const struct smu_sdbp_header *__smu_get_sdb_partition(int id, |
986 | int interruptible) | 986 | unsigned int *size, int interruptible) |
987 | { | 987 | { |
988 | char pname[32]; | 988 | char pname[32]; |
989 | struct smu_sdbp_header *part; | 989 | const struct smu_sdbp_header *part; |
990 | 990 | ||
991 | if (!smu) | 991 | if (!smu) |
992 | return NULL; | 992 | return NULL; |
@@ -1003,8 +1003,7 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size, | |||
1003 | } else | 1003 | } else |
1004 | mutex_lock(&smu_part_access); | 1004 | mutex_lock(&smu_part_access); |
1005 | 1005 | ||
1006 | part = (struct smu_sdbp_header *)get_property(smu->of_node, | 1006 | part = get_property(smu->of_node, pname, size); |
1007 | pname, size); | ||
1008 | if (part == NULL) { | 1007 | if (part == NULL) { |
1009 | DPRINTK("trying to extract from SMU ...\n"); | 1008 | DPRINTK("trying to extract from SMU ...\n"); |
1010 | part = smu_create_sdb_partition(id); | 1009 | part = smu_create_sdb_partition(id); |
@@ -1015,7 +1014,7 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size, | |||
1015 | return part; | 1014 | return part; |
1016 | } | 1015 | } |
1017 | 1016 | ||
1018 | struct smu_sdbp_header *smu_get_sdb_partition(int id, unsigned int *size) | 1017 | const struct smu_sdbp_header *smu_get_sdb_partition(int id, unsigned int *size) |
1019 | { | 1018 | { |
1020 | return __smu_get_sdb_partition(id, size, 0); | 1019 | return __smu_get_sdb_partition(id, size, 0); |
1021 | } | 1020 | } |
@@ -1094,7 +1093,7 @@ static ssize_t smu_write(struct file *file, const char __user *buf, | |||
1094 | pp->mode = smu_file_events; | 1093 | pp->mode = smu_file_events; |
1095 | return 0; | 1094 | return 0; |
1096 | } else if (hdr.cmdtype == SMU_CMDTYPE_GET_PARTITION) { | 1095 | } else if (hdr.cmdtype == SMU_CMDTYPE_GET_PARTITION) { |
1097 | struct smu_sdbp_header *part; | 1096 | const struct smu_sdbp_header *part; |
1098 | part = __smu_get_sdb_partition(hdr.cmd, NULL, 1); | 1097 | part = __smu_get_sdb_partition(hdr.cmd, NULL, 1); |
1099 | if (part == NULL) | 1098 | if (part == NULL) |
1100 | return -EINVAL; | 1099 | return -EINVAL; |
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index 7f86478bdd36..a0f30d0853ea 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c | |||
@@ -47,7 +47,7 @@ static u8 FAN_SPD_SET[2] = {0x30, 0x31}; | |||
47 | 47 | ||
48 | static u8 default_limits_local[3] = {70, 50, 70}; /* local, sensor1, sensor2 */ | 48 | static u8 default_limits_local[3] = {70, 50, 70}; /* local, sensor1, sensor2 */ |
49 | static u8 default_limits_chip[3] = {80, 65, 80}; /* local, sensor1, sensor2 */ | 49 | static u8 default_limits_chip[3] = {80, 65, 80}; /* local, sensor1, sensor2 */ |
50 | static char *sensor_location[3] = {NULL, NULL, NULL}; | 50 | static const char *sensor_location[3] = {NULL, NULL, NULL}; |
51 | 51 | ||
52 | static int limit_adjust = 0; | 52 | static int limit_adjust = 0; |
53 | static int fan_speed = -1; | 53 | static int fan_speed = -1; |
@@ -553,7 +553,7 @@ static int __init | |||
553 | thermostat_init(void) | 553 | thermostat_init(void) |
554 | { | 554 | { |
555 | struct device_node* np; | 555 | struct device_node* np; |
556 | u32 *prop; | 556 | const u32 *prop; |
557 | int i = 0, offset = 0; | 557 | int i = 0, offset = 0; |
558 | 558 | ||
559 | np = of_find_node_by_name(NULL, "fan"); | 559 | np = of_find_node_by_name(NULL, "fan"); |
@@ -566,13 +566,13 @@ thermostat_init(void) | |||
566 | else | 566 | else |
567 | return -ENODEV; | 567 | return -ENODEV; |
568 | 568 | ||
569 | prop = (u32 *)get_property(np, "hwsensor-params-version", NULL); | 569 | prop = get_property(np, "hwsensor-params-version", NULL); |
570 | printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop, | 570 | printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop, |
571 | (*prop == 1)?"":"un"); | 571 | (*prop == 1)?"":"un"); |
572 | if (*prop != 1) | 572 | if (*prop != 1) |
573 | return -ENODEV; | 573 | return -ENODEV; |
574 | 574 | ||
575 | prop = (u32 *)get_property(np, "reg", NULL); | 575 | prop = get_property(np, "reg", NULL); |
576 | if (!prop) | 576 | if (!prop) |
577 | return -ENODEV; | 577 | return -ENODEV; |
578 | 578 | ||
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index 20bf67244e2c..d00c0c37a12e 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c | |||
@@ -660,7 +660,7 @@ static int read_eeprom(int cpu, struct mpu_data *out) | |||
660 | { | 660 | { |
661 | struct device_node *np; | 661 | struct device_node *np; |
662 | char nodename[64]; | 662 | char nodename[64]; |
663 | u8 *data; | 663 | const u8 *data; |
664 | int len; | 664 | int len; |
665 | 665 | ||
666 | /* prom.c routine for finding a node by path is a bit brain dead | 666 | /* prom.c routine for finding a node by path is a bit brain dead |
@@ -673,7 +673,7 @@ static int read_eeprom(int cpu, struct mpu_data *out) | |||
673 | printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid node from device-tree\n"); | 673 | printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid node from device-tree\n"); |
674 | return -ENODEV; | 674 | return -ENODEV; |
675 | } | 675 | } |
676 | data = (u8 *)get_property(np, "cpuid", &len); | 676 | data = get_property(np, "cpuid", &len); |
677 | if (data == NULL) { | 677 | if (data == NULL) { |
678 | printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid property from device-tree\n"); | 678 | printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid property from device-tree\n"); |
679 | of_node_put(np); | 679 | of_node_put(np); |
@@ -1336,7 +1336,7 @@ static int init_backside_state(struct backside_pid_state *state) | |||
1336 | */ | 1336 | */ |
1337 | u3 = of_find_node_by_path("/u3@0,f8000000"); | 1337 | u3 = of_find_node_by_path("/u3@0,f8000000"); |
1338 | if (u3 != NULL) { | 1338 | if (u3 != NULL) { |
1339 | u32 *vers = (u32 *)get_property(u3, "device-rev", NULL); | 1339 | const u32 *vers = get_property(u3, "device-rev", NULL); |
1340 | if (vers) | 1340 | if (vers) |
1341 | if (((*vers) & 0x3f) < 0x34) | 1341 | if (((*vers) & 0x3f) < 0x34) |
1342 | u3h = 0; | 1342 | u3h = 0; |
@@ -2111,8 +2111,8 @@ static void fcu_lookup_fans(struct device_node *fcu_node) | |||
2111 | 2111 | ||
2112 | while ((np = of_get_next_child(fcu_node, np)) != NULL) { | 2112 | while ((np = of_get_next_child(fcu_node, np)) != NULL) { |
2113 | int type = -1; | 2113 | int type = -1; |
2114 | char *loc; | 2114 | const char *loc; |
2115 | u32 *reg; | 2115 | const u32 *reg; |
2116 | 2116 | ||
2117 | DBG(" control: %s, type: %s\n", np->name, np->type); | 2117 | DBG(" control: %s, type: %s\n", np->name, np->type); |
2118 | 2118 | ||
@@ -2128,8 +2128,8 @@ static void fcu_lookup_fans(struct device_node *fcu_node) | |||
2128 | continue; | 2128 | continue; |
2129 | 2129 | ||
2130 | /* Lookup for a matching location */ | 2130 | /* Lookup for a matching location */ |
2131 | loc = (char *)get_property(np, "location", NULL); | 2131 | loc = get_property(np, "location", NULL); |
2132 | reg = (u32 *)get_property(np, "reg", NULL); | 2132 | reg = get_property(np, "reg", NULL); |
2133 | if (loc == NULL || reg == NULL) | 2133 | if (loc == NULL || reg == NULL) |
2134 | continue; | 2134 | continue; |
2135 | DBG(" matching location: %s, reg: 0x%08x\n", loc, *reg); | 2135 | DBG(" matching location: %s, reg: 0x%08x\n", loc, *reg); |
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index c7d1c290cb0c..738faab1b22c 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c | |||
@@ -484,14 +484,14 @@ struct apple_thermal_info { | |||
484 | static int __init | 484 | static int __init |
485 | g4fan_init( void ) | 485 | g4fan_init( void ) |
486 | { | 486 | { |
487 | struct apple_thermal_info *info; | 487 | const struct apple_thermal_info *info; |
488 | struct device_node *np; | 488 | struct device_node *np; |
489 | 489 | ||
490 | init_MUTEX( &x.lock ); | 490 | init_MUTEX( &x.lock ); |
491 | 491 | ||
492 | if( !(np=of_find_node_by_name(NULL, "power-mgt")) ) | 492 | if( !(np=of_find_node_by_name(NULL, "power-mgt")) ) |
493 | return -ENODEV; | 493 | return -ENODEV; |
494 | info = (struct apple_thermal_info*)get_property(np, "thermal-info", NULL); | 494 | info = get_property(np, "thermal-info", NULL); |
495 | of_node_put(np); | 495 | of_node_put(np); |
496 | 496 | ||
497 | if( !info || !machine_is_compatible("PowerMac3,6") ) | 497 | if( !info || !machine_is_compatible("PowerMac3,6") ) |
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c index 69d5452fd22f..7512d1c15207 100644 --- a/drivers/macintosh/via-cuda.c +++ b/drivers/macintosh/via-cuda.c | |||
@@ -123,7 +123,7 @@ int __init find_via_cuda(void) | |||
123 | { | 123 | { |
124 | struct adb_request req; | 124 | struct adb_request req; |
125 | phys_addr_t taddr; | 125 | phys_addr_t taddr; |
126 | u32 *reg; | 126 | const u32 *reg; |
127 | int err; | 127 | int err; |
128 | 128 | ||
129 | if (vias != 0) | 129 | if (vias != 0) |
@@ -132,7 +132,7 @@ int __init find_via_cuda(void) | |||
132 | if (vias == 0) | 132 | if (vias == 0) |
133 | return 0; | 133 | return 0; |
134 | 134 | ||
135 | reg = (u32 *)get_property(vias, "reg", NULL); | 135 | reg = get_property(vias, "reg", NULL); |
136 | if (reg == NULL) { | 136 | if (reg == NULL) { |
137 | printk(KERN_ERR "via-cuda: No \"reg\" property !\n"); | 137 | printk(KERN_ERR "via-cuda: No \"reg\" property !\n"); |
138 | goto fail; | 138 | goto fail; |
diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c index 5189d5454b1f..179af10105d9 100644 --- a/drivers/macintosh/via-pmu-led.c +++ b/drivers/macintosh/via-pmu-led.c | |||
@@ -120,7 +120,7 @@ static int __init via_pmu_led_init(void) | |||
120 | dt = of_find_node_by_path("/"); | 120 | dt = of_find_node_by_path("/"); |
121 | if (dt == NULL) | 121 | if (dt == NULL) |
122 | return -ENODEV; | 122 | return -ENODEV; |
123 | model = (const char *)get_property(dt, "model", NULL); | 123 | model = get_property(dt, "model", NULL); |
124 | if (model == NULL) | 124 | if (model == NULL) |
125 | return -ENODEV; | 125 | return -ENODEV; |
126 | if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 && | 126 | if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 && |
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 14610a63f580..dda03985dcf5 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -280,7 +280,7 @@ static char *pbook_type[] = { | |||
280 | int __init find_via_pmu(void) | 280 | int __init find_via_pmu(void) |
281 | { | 281 | { |
282 | u64 taddr; | 282 | u64 taddr; |
283 | u32 *reg; | 283 | const u32 *reg; |
284 | 284 | ||
285 | if (via != 0) | 285 | if (via != 0) |
286 | return 1; | 286 | return 1; |
@@ -288,7 +288,7 @@ int __init find_via_pmu(void) | |||
288 | if (vias == NULL) | 288 | if (vias == NULL) |
289 | return 0; | 289 | return 0; |
290 | 290 | ||
291 | reg = (u32 *)get_property(vias, "reg", NULL); | 291 | reg = get_property(vias, "reg", NULL); |
292 | if (reg == NULL) { | 292 | if (reg == NULL) { |
293 | printk(KERN_ERR "via-pmu: No \"reg\" property !\n"); | 293 | printk(KERN_ERR "via-pmu: No \"reg\" property !\n"); |
294 | goto fail; | 294 | goto fail; |
@@ -330,7 +330,7 @@ int __init find_via_pmu(void) | |||
330 | 330 | ||
331 | gpiop = of_find_node_by_name(NULL, "gpio"); | 331 | gpiop = of_find_node_by_name(NULL, "gpio"); |
332 | if (gpiop) { | 332 | if (gpiop) { |
333 | reg = (u32 *)get_property(gpiop, "reg", NULL); | 333 | reg = get_property(gpiop, "reg", NULL); |
334 | if (reg) | 334 | if (reg) |
335 | gaddr = of_translate_address(gpiop, reg); | 335 | gaddr = of_translate_address(gpiop, reg); |
336 | if (gaddr != OF_BAD_ADDR) | 336 | if (gaddr != OF_BAD_ADDR) |
@@ -479,9 +479,9 @@ static int __init via_pmu_dev_init(void) | |||
479 | pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; | 479 | pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; |
480 | } else { | 480 | } else { |
481 | struct device_node* prim = find_devices("power-mgt"); | 481 | struct device_node* prim = find_devices("power-mgt"); |
482 | u32 *prim_info = NULL; | 482 | const u32 *prim_info = NULL; |
483 | if (prim) | 483 | if (prim) |
484 | prim_info = (u32 *)get_property(prim, "prim-info", NULL); | 484 | prim_info = get_property(prim, "prim-info", NULL); |
485 | if (prim_info) { | 485 | if (prim_info) { |
486 | /* Other stuffs here yet unknown */ | 486 | /* Other stuffs here yet unknown */ |
487 | pmu_battery_count = (prim_info[6] >> 16) & 0xff; | 487 | pmu_battery_count = (prim_info[6] >> 16) & 0xff; |
diff --git a/drivers/macintosh/windfarm_pm81.c b/drivers/macintosh/windfarm_pm81.c index f1df6efcbe68..2ff546e4c92f 100644 --- a/drivers/macintosh/windfarm_pm81.c +++ b/drivers/macintosh/windfarm_pm81.c | |||
@@ -396,7 +396,7 @@ static void wf_smu_sys_fans_tick(struct wf_smu_sys_fans_state *st) | |||
396 | static void wf_smu_create_cpu_fans(void) | 396 | static void wf_smu_create_cpu_fans(void) |
397 | { | 397 | { |
398 | struct wf_cpu_pid_param pid_param; | 398 | struct wf_cpu_pid_param pid_param; |
399 | struct smu_sdbp_header *hdr; | 399 | const struct smu_sdbp_header *hdr; |
400 | struct smu_sdbp_cpupiddata *piddata; | 400 | struct smu_sdbp_cpupiddata *piddata; |
401 | struct smu_sdbp_fvt *fvt; | 401 | struct smu_sdbp_fvt *fvt; |
402 | s32 tmax, tdelta, maxpow, powadj; | 402 | s32 tmax, tdelta, maxpow, powadj; |
@@ -702,7 +702,7 @@ static struct notifier_block wf_smu_events = { | |||
702 | 702 | ||
703 | static int wf_init_pm(void) | 703 | static int wf_init_pm(void) |
704 | { | 704 | { |
705 | struct smu_sdbp_header *hdr; | 705 | const struct smu_sdbp_header *hdr; |
706 | 706 | ||
707 | hdr = smu_get_sdb_partition(SMU_SDB_SENSORTREE_ID, NULL); | 707 | hdr = smu_get_sdb_partition(SMU_SDB_SENSORTREE_ID, NULL); |
708 | if (hdr != 0) { | 708 | if (hdr != 0) { |
diff --git a/drivers/macintosh/windfarm_pm91.c b/drivers/macintosh/windfarm_pm91.c index 0d6372e96d32..59e9ffe37c39 100644 --- a/drivers/macintosh/windfarm_pm91.c +++ b/drivers/macintosh/windfarm_pm91.c | |||
@@ -144,7 +144,7 @@ static struct wf_smu_slots_fans_state *wf_smu_slots_fans; | |||
144 | static void wf_smu_create_cpu_fans(void) | 144 | static void wf_smu_create_cpu_fans(void) |
145 | { | 145 | { |
146 | struct wf_cpu_pid_param pid_param; | 146 | struct wf_cpu_pid_param pid_param; |
147 | struct smu_sdbp_header *hdr; | 147 | const struct smu_sdbp_header *hdr; |
148 | struct smu_sdbp_cpupiddata *piddata; | 148 | struct smu_sdbp_cpupiddata *piddata; |
149 | struct smu_sdbp_fvt *fvt; | 149 | struct smu_sdbp_fvt *fvt; |
150 | s32 tmax, tdelta, maxpow, powadj; | 150 | s32 tmax, tdelta, maxpow, powadj; |
diff --git a/drivers/macintosh/windfarm_smu_controls.c b/drivers/macintosh/windfarm_smu_controls.c index a9e88edc0c72..bff1f372f188 100644 --- a/drivers/macintosh/windfarm_smu_controls.c +++ b/drivers/macintosh/windfarm_smu_controls.c | |||
@@ -159,14 +159,15 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node, | |||
159 | int pwm_fan) | 159 | int pwm_fan) |
160 | { | 160 | { |
161 | struct smu_fan_control *fct; | 161 | struct smu_fan_control *fct; |
162 | s32 *v; u32 *reg; | 162 | const s32 *v; |
163 | char *l; | 163 | const u32 *reg; |
164 | const char *l; | ||
164 | 165 | ||
165 | fct = kmalloc(sizeof(struct smu_fan_control), GFP_KERNEL); | 166 | fct = kmalloc(sizeof(struct smu_fan_control), GFP_KERNEL); |
166 | if (fct == NULL) | 167 | if (fct == NULL) |
167 | return NULL; | 168 | return NULL; |
168 | fct->ctrl.ops = &smu_fan_ops; | 169 | fct->ctrl.ops = &smu_fan_ops; |
169 | l = (char *)get_property(node, "location", NULL); | 170 | l = get_property(node, "location", NULL); |
170 | if (l == NULL) | 171 | if (l == NULL) |
171 | goto fail; | 172 | goto fail; |
172 | 173 | ||
@@ -223,17 +224,17 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node, | |||
223 | goto fail; | 224 | goto fail; |
224 | 225 | ||
225 | /* Get min & max values*/ | 226 | /* Get min & max values*/ |
226 | v = (s32 *)get_property(node, "min-value", NULL); | 227 | v = get_property(node, "min-value", NULL); |
227 | if (v == NULL) | 228 | if (v == NULL) |
228 | goto fail; | 229 | goto fail; |
229 | fct->min = *v; | 230 | fct->min = *v; |
230 | v = (s32 *)get_property(node, "max-value", NULL); | 231 | v = get_property(node, "max-value", NULL); |
231 | if (v == NULL) | 232 | if (v == NULL) |
232 | goto fail; | 233 | goto fail; |
233 | fct->max = *v; | 234 | fct->max = *v; |
234 | 235 | ||
235 | /* Get "reg" value */ | 236 | /* Get "reg" value */ |
236 | reg = (u32 *)get_property(node, "reg", NULL); | 237 | reg = get_property(node, "reg", NULL); |
237 | if (reg == NULL) | 238 | if (reg == NULL) |
238 | goto fail; | 239 | goto fail; |
239 | fct->reg = *reg; | 240 | fct->reg = *reg; |
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c index e295a07a1ebc..aceb61d9fbc8 100644 --- a/drivers/macintosh/windfarm_smu_sat.c +++ b/drivers/macintosh/windfarm_smu_sat.c | |||
@@ -233,15 +233,15 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev) | |||
233 | { | 233 | { |
234 | struct wf_sat *sat; | 234 | struct wf_sat *sat; |
235 | struct wf_sat_sensor *sens; | 235 | struct wf_sat_sensor *sens; |
236 | u32 *reg; | 236 | const u32 *reg; |
237 | char *loc, *type; | 237 | const char *loc, *type; |
238 | u8 addr, chip, core; | 238 | u8 addr, chip, core; |
239 | struct device_node *child; | 239 | struct device_node *child; |
240 | int shift, cpu, index; | 240 | int shift, cpu, index; |
241 | char *name; | 241 | char *name; |
242 | int vsens[2], isens[2]; | 242 | int vsens[2], isens[2]; |
243 | 243 | ||
244 | reg = (u32 *) get_property(dev, "reg", NULL); | 244 | reg = get_property(dev, "reg", NULL); |
245 | if (reg == NULL) | 245 | if (reg == NULL) |
246 | return; | 246 | return; |
247 | addr = *reg; | 247 | addr = *reg; |
@@ -268,7 +268,7 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev) | |||
268 | isens[0] = isens[1] = -1; | 268 | isens[0] = isens[1] = -1; |
269 | child = NULL; | 269 | child = NULL; |
270 | while ((child = of_get_next_child(dev, child)) != NULL) { | 270 | while ((child = of_get_next_child(dev, child)) != NULL) { |
271 | reg = (u32 *) get_property(child, "reg", NULL); | 271 | reg = get_property(child, "reg", NULL); |
272 | type = get_property(child, "device_type", NULL); | 272 | type = get_property(child, "device_type", NULL); |
273 | loc = get_property(child, "location", NULL); | 273 | loc = get_property(child, "location", NULL); |
274 | if (reg == NULL || loc == NULL) | 274 | if (reg == NULL || loc == NULL) |
diff --git a/drivers/macintosh/windfarm_smu_sensors.c b/drivers/macintosh/windfarm_smu_sensors.c index bed25dcf8a1e..defe9922ebd1 100644 --- a/drivers/macintosh/windfarm_smu_sensors.c +++ b/drivers/macintosh/windfarm_smu_sensors.c | |||
@@ -198,14 +198,14 @@ static struct wf_sensor_ops smu_slotspow_ops = { | |||
198 | static struct smu_ad_sensor *smu_ads_create(struct device_node *node) | 198 | static struct smu_ad_sensor *smu_ads_create(struct device_node *node) |
199 | { | 199 | { |
200 | struct smu_ad_sensor *ads; | 200 | struct smu_ad_sensor *ads; |
201 | char *c, *l; | 201 | const char *c, *l; |
202 | u32 *v; | 202 | const u32 *v; |
203 | 203 | ||
204 | ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL); | 204 | ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL); |
205 | if (ads == NULL) | 205 | if (ads == NULL) |
206 | return NULL; | 206 | return NULL; |
207 | c = (char *)get_property(node, "device_type", NULL); | 207 | c = get_property(node, "device_type", NULL); |
208 | l = (char *)get_property(node, "location", NULL); | 208 | l = get_property(node, "location", NULL); |
209 | if (c == NULL || l == NULL) | 209 | if (c == NULL || l == NULL) |
210 | goto fail; | 210 | goto fail; |
211 | 211 | ||
@@ -255,7 +255,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node) | |||
255 | } else | 255 | } else |
256 | goto fail; | 256 | goto fail; |
257 | 257 | ||
258 | v = (u32 *)get_property(node, "reg", NULL); | 258 | v = get_property(node, "reg", NULL); |
259 | if (v == NULL) | 259 | if (v == NULL) |
260 | goto fail; | 260 | goto fail; |
261 | ads->reg = *v; | 261 | ads->reg = *v; |
@@ -382,7 +382,7 @@ smu_cpu_power_create(struct wf_sensor *volts, struct wf_sensor *amps) | |||
382 | 382 | ||
383 | static void smu_fetch_param_partitions(void) | 383 | static void smu_fetch_param_partitions(void) |
384 | { | 384 | { |
385 | struct smu_sdbp_header *hdr; | 385 | const struct smu_sdbp_header *hdr; |
386 | 386 | ||
387 | /* Get CPU voltage/current/power calibration data */ | 387 | /* Get CPU voltage/current/power calibration data */ |
388 | hdr = smu_get_sdb_partition(SMU_SDB_CPUVCP_ID, NULL); | 388 | hdr = smu_get_sdb_partition(SMU_SDB_CPUVCP_ID, NULL); |
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig index 1344ad7a4b14..717e90448fc6 100644 --- a/drivers/mtd/Kconfig +++ b/drivers/mtd/Kconfig | |||
@@ -263,6 +263,14 @@ config RFD_FTL | |||
263 | 263 | ||
264 | http://www.gensw.com/pages/prod/bios/rfd.htm | 264 | http://www.gensw.com/pages/prod/bios/rfd.htm |
265 | 265 | ||
266 | config SSFDC | ||
267 | bool "NAND SSFDC (SmartMedia) read only translation layer" | ||
268 | depends on MTD | ||
269 | default n | ||
270 | help | ||
271 | This enables read only access to SmartMedia formatted NAND | ||
272 | flash. You can mount it with FAT file system. | ||
273 | |||
266 | source "drivers/mtd/chips/Kconfig" | 274 | source "drivers/mtd/chips/Kconfig" |
267 | 275 | ||
268 | source "drivers/mtd/maps/Kconfig" | 276 | source "drivers/mtd/maps/Kconfig" |
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile index fc9374407c2b..1e36b9aed98b 100644 --- a/drivers/mtd/Makefile +++ b/drivers/mtd/Makefile | |||
@@ -21,6 +21,7 @@ obj-$(CONFIG_FTL) += ftl.o mtd_blkdevs.o | |||
21 | obj-$(CONFIG_NFTL) += nftl.o mtd_blkdevs.o | 21 | obj-$(CONFIG_NFTL) += nftl.o mtd_blkdevs.o |
22 | obj-$(CONFIG_INFTL) += inftl.o mtd_blkdevs.o | 22 | obj-$(CONFIG_INFTL) += inftl.o mtd_blkdevs.o |
23 | obj-$(CONFIG_RFD_FTL) += rfd_ftl.o mtd_blkdevs.o | 23 | obj-$(CONFIG_RFD_FTL) += rfd_ftl.o mtd_blkdevs.o |
24 | obj-$(CONFIG_SSFDC) += ssfdc.o mtd_blkdevs.o | ||
24 | 25 | ||
25 | nftl-objs := nftlcore.o nftlmount.o | 26 | nftl-objs := nftlcore.o nftlmount.o |
26 | inftl-objs := inftlcore.o inftlmount.o | 27 | inftl-objs := inftlcore.o inftlmount.o |
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index a482e8922de1..702ae4cd8691 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c | |||
@@ -212,6 +212,7 @@ static void fixup_use_atmel_lock(struct mtd_info *mtd, void *param) | |||
212 | { | 212 | { |
213 | mtd->lock = cfi_atmel_lock; | 213 | mtd->lock = cfi_atmel_lock; |
214 | mtd->unlock = cfi_atmel_unlock; | 214 | mtd->unlock = cfi_atmel_unlock; |
215 | mtd->flags |= MTD_STUPID_LOCK; | ||
215 | } | 216 | } |
216 | 217 | ||
217 | static struct cfi_fixup cfi_fixup_table[] = { | 218 | static struct cfi_fixup cfi_fixup_table[] = { |
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c index 2c0149708739..354e1657cc26 100644 --- a/drivers/mtd/devices/pmc551.c +++ b/drivers/mtd/devices/pmc551.c | |||
@@ -4,82 +4,82 @@ | |||
4 | * PMC551 PCI Mezzanine Ram Device | 4 | * PMC551 PCI Mezzanine Ram Device |
5 | * | 5 | * |
6 | * Author: | 6 | * Author: |
7 | * Mark Ferrell <mferrell@mvista.com> | 7 | * Mark Ferrell <mferrell@mvista.com> |
8 | * Copyright 1999,2000 Nortel Networks | 8 | * Copyright 1999,2000 Nortel Networks |
9 | * | 9 | * |
10 | * License: | 10 | * License: |
11 | * As part of this driver was derived from the slram.c driver it | 11 | * As part of this driver was derived from the slram.c driver it |
12 | * falls under the same license, which is GNU General Public | 12 | * falls under the same license, which is GNU General Public |
13 | * License v2 | 13 | * License v2 |
14 | * | 14 | * |
15 | * Description: | 15 | * Description: |
16 | * This driver is intended to support the PMC551 PCI Ram device | 16 | * This driver is intended to support the PMC551 PCI Ram device |
17 | * from Ramix Inc. The PMC551 is a PMC Mezzanine module for | 17 | * from Ramix Inc. The PMC551 is a PMC Mezzanine module for |
18 | * cPCI embedded systems. The device contains a single SROM | 18 | * cPCI embedded systems. The device contains a single SROM |
19 | * that initially programs the V370PDC chipset onboard the | 19 | * that initially programs the V370PDC chipset onboard the |
20 | * device, and various banks of DRAM/SDRAM onboard. This driver | 20 | * device, and various banks of DRAM/SDRAM onboard. This driver |
21 | * implements this PCI Ram device as an MTD (Memory Technology | 21 | * implements this PCI Ram device as an MTD (Memory Technology |
22 | * Device) so that it can be used to hold a file system, or for | 22 | * Device) so that it can be used to hold a file system, or for |
23 | * added swap space in embedded systems. Since the memory on | 23 | * added swap space in embedded systems. Since the memory on |
24 | * this board isn't as fast as main memory we do not try to hook | 24 | * this board isn't as fast as main memory we do not try to hook |
25 | * it into main memory as that would simply reduce performance | 25 | * it into main memory as that would simply reduce performance |
26 | * on the system. Using it as a block device allows us to use | 26 | * on the system. Using it as a block device allows us to use |
27 | * it as high speed swap or for a high speed disk device of some | 27 | * it as high speed swap or for a high speed disk device of some |
28 | * sort. Which becomes very useful on diskless systems in the | 28 | * sort. Which becomes very useful on diskless systems in the |
29 | * embedded market I might add. | 29 | * embedded market I might add. |
30 | * | 30 | * |
31 | * Notes: | 31 | * Notes: |
32 | * Due to what I assume is more buggy SROM, the 64M PMC551 I | 32 | * Due to what I assume is more buggy SROM, the 64M PMC551 I |
33 | * have available claims that all 4 of it's DRAM banks have 64M | 33 | * have available claims that all 4 of it's DRAM banks have 64M |
34 | * of ram configured (making a grand total of 256M onboard). | 34 | * of ram configured (making a grand total of 256M onboard). |
35 | * This is slightly annoying since the BAR0 size reflects the | 35 | * This is slightly annoying since the BAR0 size reflects the |
36 | * aperture size, not the dram size, and the V370PDC supplies no | 36 | * aperture size, not the dram size, and the V370PDC supplies no |
37 | * other method for memory size discovery. This problem is | 37 | * other method for memory size discovery. This problem is |
38 | * mostly only relevant when compiled as a module, as the | 38 | * mostly only relevant when compiled as a module, as the |
39 | * unloading of the module with an aperture size smaller then | 39 | * unloading of the module with an aperture size smaller then |
40 | * the ram will cause the driver to detect the onboard memory | 40 | * the ram will cause the driver to detect the onboard memory |
41 | * size to be equal to the aperture size when the module is | 41 | * size to be equal to the aperture size when the module is |
42 | * reloaded. Soooo, to help, the module supports an msize | 42 | * reloaded. Soooo, to help, the module supports an msize |
43 | * option to allow the specification of the onboard memory, and | 43 | * option to allow the specification of the onboard memory, and |
44 | * an asize option, to allow the specification of the aperture | 44 | * an asize option, to allow the specification of the aperture |
45 | * size. The aperture must be equal to or less then the memory | 45 | * size. The aperture must be equal to or less then the memory |
46 | * size, the driver will correct this if you screw it up. This | 46 | * size, the driver will correct this if you screw it up. This |
47 | * problem is not relevant for compiled in drivers as compiled | 47 | * problem is not relevant for compiled in drivers as compiled |
48 | * in drivers only init once. | 48 | * in drivers only init once. |
49 | * | 49 | * |
50 | * Credits: | 50 | * Credits: |
51 | * Saeed Karamooz <saeed@ramix.com> of Ramix INC. for the | 51 | * Saeed Karamooz <saeed@ramix.com> of Ramix INC. for the |
52 | * initial example code of how to initialize this device and for | 52 | * initial example code of how to initialize this device and for |
53 | * help with questions I had concerning operation of the device. | 53 | * help with questions I had concerning operation of the device. |
54 | * | 54 | * |
55 | * Most of the MTD code for this driver was originally written | 55 | * Most of the MTD code for this driver was originally written |
56 | * for the slram.o module in the MTD drivers package which | 56 | * for the slram.o module in the MTD drivers package which |
57 | * allows the mapping of system memory into an MTD device. | 57 | * allows the mapping of system memory into an MTD device. |
58 | * Since the PMC551 memory module is accessed in the same | 58 | * Since the PMC551 memory module is accessed in the same |
59 | * fashion as system memory, the slram.c code became a very nice | 59 | * fashion as system memory, the slram.c code became a very nice |
60 | * fit to the needs of this driver. All we added was PCI | 60 | * fit to the needs of this driver. All we added was PCI |
61 | * detection/initialization to the driver and automatically figure | 61 | * detection/initialization to the driver and automatically figure |
62 | * out the size via the PCI detection.o, later changes by Corey | 62 | * out the size via the PCI detection.o, later changes by Corey |
63 | * Minyard set up the card to utilize a 1M sliding apature. | 63 | * Minyard set up the card to utilize a 1M sliding apature. |
64 | * | 64 | * |
65 | * Corey Minyard <minyard@nortelnetworks.com> | 65 | * Corey Minyard <minyard@nortelnetworks.com> |
66 | * * Modified driver to utilize a sliding aperture instead of | 66 | * * Modified driver to utilize a sliding aperture instead of |
67 | * mapping all memory into kernel space which turned out to | 67 | * mapping all memory into kernel space which turned out to |
68 | * be very wasteful. | 68 | * be very wasteful. |
69 | * * Located a bug in the SROM's initialization sequence that | 69 | * * Located a bug in the SROM's initialization sequence that |
70 | * made the memory unusable, added a fix to code to touch up | 70 | * made the memory unusable, added a fix to code to touch up |
71 | * the DRAM some. | 71 | * the DRAM some. |
72 | * | 72 | * |
73 | * Bugs/FIXME's: | 73 | * Bugs/FIXME's: |
74 | * * MUST fix the init function to not spin on a register | 74 | * * MUST fix the init function to not spin on a register |
75 | * waiting for it to set .. this does not safely handle busted | 75 | * waiting for it to set .. this does not safely handle busted |
76 | * devices that never reset the register correctly which will | 76 | * devices that never reset the register correctly which will |
77 | * cause the system to hang w/ a reboot being the only chance at | 77 | * cause the system to hang w/ a reboot being the only chance at |
78 | * recover. [sort of fixed, could be better] | 78 | * recover. [sort of fixed, could be better] |
79 | * * Add I2C handling of the SROM so we can read the SROM's information | 79 | * * Add I2C handling of the SROM so we can read the SROM's information |
80 | * about the aperture size. This should always accurately reflect the | 80 | * about the aperture size. This should always accurately reflect the |
81 | * onboard memory size. | 81 | * onboard memory size. |
82 | * * Comb the init routine. It's still a bit cludgy on a few things. | 82 | * * Comb the init routine. It's still a bit cludgy on a few things. |
83 | */ | 83 | */ |
84 | 84 | ||
85 | #include <linux/kernel.h> | 85 | #include <linux/kernel.h> |
@@ -105,74 +105,77 @@ | |||
105 | 105 | ||
106 | static struct mtd_info *pmc551list; | 106 | static struct mtd_info *pmc551list; |
107 | 107 | ||
108 | static int pmc551_erase (struct mtd_info *mtd, struct erase_info *instr) | 108 | static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr) |
109 | { | 109 | { |
110 | struct mypriv *priv = mtd->priv; | 110 | struct mypriv *priv = mtd->priv; |
111 | u32 soff_hi, soff_lo; /* start address offset hi/lo */ | 111 | u32 soff_hi, soff_lo; /* start address offset hi/lo */ |
112 | u32 eoff_hi, eoff_lo; /* end address offset hi/lo */ | 112 | u32 eoff_hi, eoff_lo; /* end address offset hi/lo */ |
113 | unsigned long end; | 113 | unsigned long end; |
114 | u_char *ptr; | 114 | u_char *ptr; |
115 | size_t retlen; | 115 | size_t retlen; |
116 | 116 | ||
117 | #ifdef CONFIG_MTD_PMC551_DEBUG | 117 | #ifdef CONFIG_MTD_PMC551_DEBUG |
118 | printk(KERN_DEBUG "pmc551_erase(pos:%ld, len:%ld)\n", (long)instr->addr, (long)instr->len); | 118 | printk(KERN_DEBUG "pmc551_erase(pos:%ld, len:%ld)\n", (long)instr->addr, |
119 | (long)instr->len); | ||
119 | #endif | 120 | #endif |
120 | 121 | ||
121 | end = instr->addr + instr->len - 1; | 122 | end = instr->addr + instr->len - 1; |
122 | 123 | ||
123 | /* Is it past the end? */ | 124 | /* Is it past the end? */ |
124 | if ( end > mtd->size ) { | 125 | if (end > mtd->size) { |
125 | #ifdef CONFIG_MTD_PMC551_DEBUG | 126 | #ifdef CONFIG_MTD_PMC551_DEBUG |
126 | printk(KERN_DEBUG "pmc551_erase() out of bounds (%ld > %ld)\n", (long)end, (long)mtd->size); | 127 | printk(KERN_DEBUG "pmc551_erase() out of bounds (%ld > %ld)\n", |
128 | (long)end, (long)mtd->size); | ||
127 | #endif | 129 | #endif |
128 | return -EINVAL; | 130 | return -EINVAL; |
129 | } | 131 | } |
130 | 132 | ||
131 | eoff_hi = end & ~(priv->asize - 1); | 133 | eoff_hi = end & ~(priv->asize - 1); |
132 | soff_hi = instr->addr & ~(priv->asize - 1); | 134 | soff_hi = instr->addr & ~(priv->asize - 1); |
133 | eoff_lo = end & (priv->asize - 1); | 135 | eoff_lo = end & (priv->asize - 1); |
134 | soff_lo = instr->addr & (priv->asize - 1); | 136 | soff_lo = instr->addr & (priv->asize - 1); |
135 | 137 | ||
136 | pmc551_point (mtd, instr->addr, instr->len, &retlen, &ptr); | 138 | pmc551_point(mtd, instr->addr, instr->len, &retlen, &ptr); |
137 | 139 | ||
138 | if ( soff_hi == eoff_hi || mtd->size == priv->asize) { | 140 | if (soff_hi == eoff_hi || mtd->size == priv->asize) { |
139 | /* The whole thing fits within one access, so just one shot | 141 | /* The whole thing fits within one access, so just one shot |
140 | will do it. */ | 142 | will do it. */ |
141 | memset(ptr, 0xff, instr->len); | 143 | memset(ptr, 0xff, instr->len); |
142 | } else { | 144 | } else { |
143 | /* We have to do multiple writes to get all the data | 145 | /* We have to do multiple writes to get all the data |
144 | written. */ | 146 | written. */ |
145 | while (soff_hi != eoff_hi) { | 147 | while (soff_hi != eoff_hi) { |
146 | #ifdef CONFIG_MTD_PMC551_DEBUG | 148 | #ifdef CONFIG_MTD_PMC551_DEBUG |
147 | printk( KERN_DEBUG "pmc551_erase() soff_hi: %ld, eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi); | 149 | printk(KERN_DEBUG "pmc551_erase() soff_hi: %ld, " |
150 | "eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi); | ||
148 | #endif | 151 | #endif |
149 | memset(ptr, 0xff, priv->asize); | 152 | memset(ptr, 0xff, priv->asize); |
150 | if (soff_hi + priv->asize >= mtd->size) { | 153 | if (soff_hi + priv->asize >= mtd->size) { |
151 | goto out; | 154 | goto out; |
152 | } | 155 | } |
153 | soff_hi += priv->asize; | 156 | soff_hi += priv->asize; |
154 | pmc551_point (mtd,(priv->base_map0|soff_hi), | 157 | pmc551_point(mtd, (priv->base_map0 | soff_hi), |
155 | priv->asize, &retlen, &ptr); | 158 | priv->asize, &retlen, &ptr); |
156 | } | 159 | } |
157 | memset (ptr, 0xff, eoff_lo); | 160 | memset(ptr, 0xff, eoff_lo); |
158 | } | 161 | } |
159 | 162 | ||
160 | out: | 163 | out: |
161 | instr->state = MTD_ERASE_DONE; | 164 | instr->state = MTD_ERASE_DONE; |
162 | #ifdef CONFIG_MTD_PMC551_DEBUG | 165 | #ifdef CONFIG_MTD_PMC551_DEBUG |
163 | printk(KERN_DEBUG "pmc551_erase() done\n"); | 166 | printk(KERN_DEBUG "pmc551_erase() done\n"); |
164 | #endif | 167 | #endif |
165 | 168 | ||
166 | mtd_erase_callback(instr); | 169 | mtd_erase_callback(instr); |
167 | return 0; | 170 | return 0; |
168 | } | 171 | } |
169 | 172 | ||
170 | 173 | static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len, | |
171 | static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf) | 174 | size_t * retlen, u_char ** mtdbuf) |
172 | { | 175 | { |
173 | struct mypriv *priv = mtd->priv; | 176 | struct mypriv *priv = mtd->priv; |
174 | u32 soff_hi; | 177 | u32 soff_hi; |
175 | u32 soff_lo; | 178 | u32 soff_lo; |
176 | 179 | ||
177 | #ifdef CONFIG_MTD_PMC551_DEBUG | 180 | #ifdef CONFIG_MTD_PMC551_DEBUG |
178 | printk(KERN_DEBUG "pmc551_point(%ld, %ld)\n", (long)from, (long)len); | 181 | printk(KERN_DEBUG "pmc551_point(%ld, %ld)\n", (long)from, (long)len); |
@@ -180,18 +183,19 @@ static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t * | |||
180 | 183 | ||
181 | if (from + len > mtd->size) { | 184 | if (from + len > mtd->size) { |
182 | #ifdef CONFIG_MTD_PMC551_DEBUG | 185 | #ifdef CONFIG_MTD_PMC551_DEBUG |
183 | printk(KERN_DEBUG "pmc551_point() out of bounds (%ld > %ld)\n", (long)from+len, (long)mtd->size); | 186 | printk(KERN_DEBUG "pmc551_point() out of bounds (%ld > %ld)\n", |
187 | (long)from + len, (long)mtd->size); | ||
184 | #endif | 188 | #endif |
185 | return -EINVAL; | 189 | return -EINVAL; |
186 | } | 190 | } |
187 | 191 | ||
188 | soff_hi = from & ~(priv->asize - 1); | 192 | soff_hi = from & ~(priv->asize - 1); |
189 | soff_lo = from & (priv->asize - 1); | 193 | soff_lo = from & (priv->asize - 1); |
190 | 194 | ||
191 | /* Cheap hack optimization */ | 195 | /* Cheap hack optimization */ |
192 | if( priv->curr_map0 != from ) { | 196 | if (priv->curr_map0 != from) { |
193 | pci_write_config_dword ( priv->dev, PMC551_PCI_MEM_MAP0, | 197 | pci_write_config_dword(priv->dev, PMC551_PCI_MEM_MAP0, |
194 | (priv->base_map0 | soff_hi) ); | 198 | (priv->base_map0 | soff_hi)); |
195 | priv->curr_map0 = soff_hi; | 199 | priv->curr_map0 = soff_hi; |
196 | } | 200 | } |
197 | 201 | ||
@@ -200,137 +204,144 @@ static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t * | |||
200 | return 0; | 204 | return 0; |
201 | } | 205 | } |
202 | 206 | ||
203 | 207 | static void pmc551_unpoint(struct mtd_info *mtd, u_char * addr, loff_t from, | |
204 | static void pmc551_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, size_t len) | 208 | size_t len) |
205 | { | 209 | { |
206 | #ifdef CONFIG_MTD_PMC551_DEBUG | 210 | #ifdef CONFIG_MTD_PMC551_DEBUG |
207 | printk(KERN_DEBUG "pmc551_unpoint()\n"); | 211 | printk(KERN_DEBUG "pmc551_unpoint()\n"); |
208 | #endif | 212 | #endif |
209 | } | 213 | } |
210 | 214 | ||
211 | 215 | static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len, | |
212 | static int pmc551_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) | 216 | size_t * retlen, u_char * buf) |
213 | { | 217 | { |
214 | struct mypriv *priv = mtd->priv; | 218 | struct mypriv *priv = mtd->priv; |
215 | u32 soff_hi, soff_lo; /* start address offset hi/lo */ | 219 | u32 soff_hi, soff_lo; /* start address offset hi/lo */ |
216 | u32 eoff_hi, eoff_lo; /* end address offset hi/lo */ | 220 | u32 eoff_hi, eoff_lo; /* end address offset hi/lo */ |
217 | unsigned long end; | 221 | unsigned long end; |
218 | u_char *ptr; | 222 | u_char *ptr; |
219 | u_char *copyto = buf; | 223 | u_char *copyto = buf; |
220 | 224 | ||
221 | #ifdef CONFIG_MTD_PMC551_DEBUG | 225 | #ifdef CONFIG_MTD_PMC551_DEBUG |
222 | printk(KERN_DEBUG "pmc551_read(pos:%ld, len:%ld) asize: %ld\n", (long)from, (long)len, (long)priv->asize); | 226 | printk(KERN_DEBUG "pmc551_read(pos:%ld, len:%ld) asize: %ld\n", |
227 | (long)from, (long)len, (long)priv->asize); | ||
223 | #endif | 228 | #endif |
224 | 229 | ||
225 | end = from + len - 1; | 230 | end = from + len - 1; |
226 | 231 | ||
227 | /* Is it past the end? */ | 232 | /* Is it past the end? */ |
228 | if (end > mtd->size) { | 233 | if (end > mtd->size) { |
229 | #ifdef CONFIG_MTD_PMC551_DEBUG | 234 | #ifdef CONFIG_MTD_PMC551_DEBUG |
230 | printk(KERN_DEBUG "pmc551_read() out of bounds (%ld > %ld)\n", (long) end, (long)mtd->size); | 235 | printk(KERN_DEBUG "pmc551_read() out of bounds (%ld > %ld)\n", |
236 | (long)end, (long)mtd->size); | ||
231 | #endif | 237 | #endif |
232 | return -EINVAL; | 238 | return -EINVAL; |
233 | } | 239 | } |
234 | 240 | ||
235 | soff_hi = from & ~(priv->asize - 1); | 241 | soff_hi = from & ~(priv->asize - 1); |
236 | eoff_hi = end & ~(priv->asize - 1); | 242 | eoff_hi = end & ~(priv->asize - 1); |
237 | soff_lo = from & (priv->asize - 1); | 243 | soff_lo = from & (priv->asize - 1); |
238 | eoff_lo = end & (priv->asize - 1); | 244 | eoff_lo = end & (priv->asize - 1); |
239 | 245 | ||
240 | pmc551_point (mtd, from, len, retlen, &ptr); | 246 | pmc551_point(mtd, from, len, retlen, &ptr); |
241 | 247 | ||
242 | if (soff_hi == eoff_hi) { | 248 | if (soff_hi == eoff_hi) { |
243 | /* The whole thing fits within one access, so just one shot | 249 | /* The whole thing fits within one access, so just one shot |
244 | will do it. */ | 250 | will do it. */ |
245 | memcpy(copyto, ptr, len); | 251 | memcpy(copyto, ptr, len); |
246 | copyto += len; | 252 | copyto += len; |
247 | } else { | 253 | } else { |
248 | /* We have to do multiple writes to get all the data | 254 | /* We have to do multiple writes to get all the data |
249 | written. */ | 255 | written. */ |
250 | while (soff_hi != eoff_hi) { | 256 | while (soff_hi != eoff_hi) { |
251 | #ifdef CONFIG_MTD_PMC551_DEBUG | 257 | #ifdef CONFIG_MTD_PMC551_DEBUG |
252 | printk( KERN_DEBUG "pmc551_read() soff_hi: %ld, eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi); | 258 | printk(KERN_DEBUG "pmc551_read() soff_hi: %ld, " |
259 | "eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi); | ||
253 | #endif | 260 | #endif |
254 | memcpy(copyto, ptr, priv->asize); | 261 | memcpy(copyto, ptr, priv->asize); |
255 | copyto += priv->asize; | 262 | copyto += priv->asize; |
256 | if (soff_hi + priv->asize >= mtd->size) { | 263 | if (soff_hi + priv->asize >= mtd->size) { |
257 | goto out; | 264 | goto out; |
258 | } | 265 | } |
259 | soff_hi += priv->asize; | 266 | soff_hi += priv->asize; |
260 | pmc551_point (mtd, soff_hi, priv->asize, retlen, &ptr); | 267 | pmc551_point(mtd, soff_hi, priv->asize, retlen, &ptr); |
261 | } | 268 | } |
262 | memcpy(copyto, ptr, eoff_lo); | 269 | memcpy(copyto, ptr, eoff_lo); |
263 | copyto += eoff_lo; | 270 | copyto += eoff_lo; |
264 | } | 271 | } |
265 | 272 | ||
266 | out: | 273 | out: |
267 | #ifdef CONFIG_MTD_PMC551_DEBUG | 274 | #ifdef CONFIG_MTD_PMC551_DEBUG |
268 | printk(KERN_DEBUG "pmc551_read() done\n"); | 275 | printk(KERN_DEBUG "pmc551_read() done\n"); |
269 | #endif | 276 | #endif |
270 | *retlen = copyto - buf; | 277 | *retlen = copyto - buf; |
271 | return 0; | 278 | return 0; |
272 | } | 279 | } |
273 | 280 | ||
274 | static int pmc551_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) | 281 | static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len, |
282 | size_t * retlen, const u_char * buf) | ||
275 | { | 283 | { |
276 | struct mypriv *priv = mtd->priv; | 284 | struct mypriv *priv = mtd->priv; |
277 | u32 soff_hi, soff_lo; /* start address offset hi/lo */ | 285 | u32 soff_hi, soff_lo; /* start address offset hi/lo */ |
278 | u32 eoff_hi, eoff_lo; /* end address offset hi/lo */ | 286 | u32 eoff_hi, eoff_lo; /* end address offset hi/lo */ |
279 | unsigned long end; | 287 | unsigned long end; |
280 | u_char *ptr; | 288 | u_char *ptr; |
281 | const u_char *copyfrom = buf; | 289 | const u_char *copyfrom = buf; |
282 | |||
283 | 290 | ||
284 | #ifdef CONFIG_MTD_PMC551_DEBUG | 291 | #ifdef CONFIG_MTD_PMC551_DEBUG |
285 | printk(KERN_DEBUG "pmc551_write(pos:%ld, len:%ld) asize:%ld\n", (long)to, (long)len, (long)priv->asize); | 292 | printk(KERN_DEBUG "pmc551_write(pos:%ld, len:%ld) asize:%ld\n", |
293 | (long)to, (long)len, (long)priv->asize); | ||
286 | #endif | 294 | #endif |
287 | 295 | ||
288 | end = to + len - 1; | 296 | end = to + len - 1; |
289 | /* Is it past the end? or did the u32 wrap? */ | 297 | /* Is it past the end? or did the u32 wrap? */ |
290 | if (end > mtd->size ) { | 298 | if (end > mtd->size) { |
291 | #ifdef CONFIG_MTD_PMC551_DEBUG | 299 | #ifdef CONFIG_MTD_PMC551_DEBUG |
292 | printk(KERN_DEBUG "pmc551_write() out of bounds (end: %ld, size: %ld, to: %ld)\n", (long) end, (long)mtd->size, (long)to); | 300 | printk(KERN_DEBUG "pmc551_write() out of bounds (end: %ld, " |
301 | "size: %ld, to: %ld)\n", (long)end, (long)mtd->size, | ||
302 | (long)to); | ||
293 | #endif | 303 | #endif |
294 | return -EINVAL; | 304 | return -EINVAL; |
295 | } | 305 | } |
296 | 306 | ||
297 | soff_hi = to & ~(priv->asize - 1); | 307 | soff_hi = to & ~(priv->asize - 1); |
298 | eoff_hi = end & ~(priv->asize - 1); | 308 | eoff_hi = end & ~(priv->asize - 1); |
299 | soff_lo = to & (priv->asize - 1); | 309 | soff_lo = to & (priv->asize - 1); |
300 | eoff_lo = end & (priv->asize - 1); | 310 | eoff_lo = end & (priv->asize - 1); |
301 | 311 | ||
302 | pmc551_point (mtd, to, len, retlen, &ptr); | 312 | pmc551_point(mtd, to, len, retlen, &ptr); |
303 | 313 | ||
304 | if (soff_hi == eoff_hi) { | 314 | if (soff_hi == eoff_hi) { |
305 | /* The whole thing fits within one access, so just one shot | 315 | /* The whole thing fits within one access, so just one shot |
306 | will do it. */ | 316 | will do it. */ |
307 | memcpy(ptr, copyfrom, len); | 317 | memcpy(ptr, copyfrom, len); |
308 | copyfrom += len; | 318 | copyfrom += len; |
309 | } else { | 319 | } else { |
310 | /* We have to do multiple writes to get all the data | 320 | /* We have to do multiple writes to get all the data |
311 | written. */ | 321 | written. */ |
312 | while (soff_hi != eoff_hi) { | 322 | while (soff_hi != eoff_hi) { |
313 | #ifdef CONFIG_MTD_PMC551_DEBUG | 323 | #ifdef CONFIG_MTD_PMC551_DEBUG |
314 | printk( KERN_DEBUG "pmc551_write() soff_hi: %ld, eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi); | 324 | printk(KERN_DEBUG "pmc551_write() soff_hi: %ld, " |
325 | "eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi); | ||
315 | #endif | 326 | #endif |
316 | memcpy(ptr, copyfrom, priv->asize); | 327 | memcpy(ptr, copyfrom, priv->asize); |
317 | copyfrom += priv->asize; | 328 | copyfrom += priv->asize; |
318 | if (soff_hi >= mtd->size) { | 329 | if (soff_hi >= mtd->size) { |
319 | goto out; | 330 | goto out; |
320 | } | 331 | } |
321 | soff_hi += priv->asize; | 332 | soff_hi += priv->asize; |
322 | pmc551_point (mtd, soff_hi, priv->asize, retlen, &ptr); | 333 | pmc551_point(mtd, soff_hi, priv->asize, retlen, &ptr); |
323 | } | 334 | } |
324 | memcpy(ptr, copyfrom, eoff_lo); | 335 | memcpy(ptr, copyfrom, eoff_lo); |
325 | copyfrom += eoff_lo; | 336 | copyfrom += eoff_lo; |
326 | } | 337 | } |
327 | 338 | ||
328 | out: | 339 | out: |
329 | #ifdef CONFIG_MTD_PMC551_DEBUG | 340 | #ifdef CONFIG_MTD_PMC551_DEBUG |
330 | printk(KERN_DEBUG "pmc551_write() done\n"); | 341 | printk(KERN_DEBUG "pmc551_write() done\n"); |
331 | #endif | 342 | #endif |
332 | *retlen = copyfrom - buf; | 343 | *retlen = copyfrom - buf; |
333 | return 0; | 344 | return 0; |
334 | } | 345 | } |
335 | 346 | ||
336 | /* | 347 | /* |
@@ -345,58 +356,58 @@ out: | |||
345 | * mechanism | 356 | * mechanism |
346 | * returns the size of the memory region found. | 357 | * returns the size of the memory region found. |
347 | */ | 358 | */ |
348 | static u32 fixup_pmc551 (struct pci_dev *dev) | 359 | static u32 fixup_pmc551(struct pci_dev *dev) |
349 | { | 360 | { |
350 | #ifdef CONFIG_MTD_PMC551_BUGFIX | 361 | #ifdef CONFIG_MTD_PMC551_BUGFIX |
351 | u32 dram_data; | 362 | u32 dram_data; |
352 | #endif | 363 | #endif |
353 | u32 size, dcmd, cfg, dtmp; | 364 | u32 size, dcmd, cfg, dtmp; |
354 | u16 cmd, tmp, i; | 365 | u16 cmd, tmp, i; |
355 | u8 bcmd, counter; | 366 | u8 bcmd, counter; |
356 | 367 | ||
357 | /* Sanity Check */ | 368 | /* Sanity Check */ |
358 | if(!dev) { | 369 | if (!dev) { |
359 | return -ENODEV; | 370 | return -ENODEV; |
360 | } | 371 | } |
361 | 372 | ||
362 | /* | 373 | /* |
363 | * Attempt to reset the card | 374 | * Attempt to reset the card |
364 | * FIXME: Stop Spinning registers | 375 | * FIXME: Stop Spinning registers |
365 | */ | 376 | */ |
366 | counter=0; | 377 | counter = 0; |
367 | /* unlock registers */ | 378 | /* unlock registers */ |
368 | pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, 0xA5 ); | 379 | pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, 0xA5); |
369 | /* read in old data */ | 380 | /* read in old data */ |
370 | pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd ); | 381 | pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd); |
371 | /* bang the reset line up and down for a few */ | 382 | /* bang the reset line up and down for a few */ |
372 | for(i=0;i<10;i++) { | 383 | for (i = 0; i < 10; i++) { |
373 | counter=0; | 384 | counter = 0; |
374 | bcmd &= ~0x80; | 385 | bcmd &= ~0x80; |
375 | while(counter++ < 100) { | 386 | while (counter++ < 100) { |
376 | pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd); | 387 | pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd); |
377 | } | 388 | } |
378 | counter=0; | 389 | counter = 0; |
379 | bcmd |= 0x80; | 390 | bcmd |= 0x80; |
380 | while(counter++ < 100) { | 391 | while (counter++ < 100) { |
381 | pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd); | 392 | pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd); |
382 | } | 393 | } |
383 | } | 394 | } |
384 | bcmd |= (0x40|0x20); | 395 | bcmd |= (0x40 | 0x20); |
385 | pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd); | 396 | pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd); |
386 | 397 | ||
387 | /* | 398 | /* |
388 | * Take care and turn off the memory on the device while we | 399 | * Take care and turn off the memory on the device while we |
389 | * tweak the configurations | 400 | * tweak the configurations |
390 | */ | 401 | */ |
391 | pci_read_config_word(dev, PCI_COMMAND, &cmd); | 402 | pci_read_config_word(dev, PCI_COMMAND, &cmd); |
392 | tmp = cmd & ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY); | 403 | tmp = cmd & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY); |
393 | pci_write_config_word(dev, PCI_COMMAND, tmp); | 404 | pci_write_config_word(dev, PCI_COMMAND, tmp); |
394 | 405 | ||
395 | /* | 406 | /* |
396 | * Disable existing aperture before probing memory size | 407 | * Disable existing aperture before probing memory size |
397 | */ | 408 | */ |
398 | pci_read_config_dword(dev, PMC551_PCI_MEM_MAP0, &dcmd); | 409 | pci_read_config_dword(dev, PMC551_PCI_MEM_MAP0, &dcmd); |
399 | dtmp=(dcmd|PMC551_PCI_MEM_MAP_ENABLE|PMC551_PCI_MEM_MAP_REG_EN); | 410 | dtmp = (dcmd | PMC551_PCI_MEM_MAP_ENABLE | PMC551_PCI_MEM_MAP_REG_EN); |
400 | pci_write_config_dword(dev, PMC551_PCI_MEM_MAP0, dtmp); | 411 | pci_write_config_dword(dev, PMC551_PCI_MEM_MAP0, dtmp); |
401 | /* | 412 | /* |
402 | * Grab old BAR0 config so that we can figure out memory size | 413 | * Grab old BAR0 config so that we can figure out memory size |
@@ -407,220 +418,230 @@ static u32 fixup_pmc551 (struct pci_dev *dev) | |||
407 | * then write all 1's to the memory space, read back the result into | 418 | * then write all 1's to the memory space, read back the result into |
408 | * "size", and then write back all the old config. | 419 | * "size", and then write back all the old config. |
409 | */ | 420 | */ |
410 | pci_read_config_dword( dev, PCI_BASE_ADDRESS_0, &cfg ); | 421 | pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &cfg); |
411 | #ifndef CONFIG_MTD_PMC551_BUGFIX | 422 | #ifndef CONFIG_MTD_PMC551_BUGFIX |
412 | pci_write_config_dword( dev, PCI_BASE_ADDRESS_0, ~0 ); | 423 | pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, ~0); |
413 | pci_read_config_dword( dev, PCI_BASE_ADDRESS_0, &size ); | 424 | pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &size); |
414 | size = (size&PCI_BASE_ADDRESS_MEM_MASK); | 425 | size = (size & PCI_BASE_ADDRESS_MEM_MASK); |
415 | size &= ~(size-1); | 426 | size &= ~(size - 1); |
416 | pci_write_config_dword( dev, PCI_BASE_ADDRESS_0, cfg ); | 427 | pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, cfg); |
417 | #else | 428 | #else |
418 | /* | 429 | /* |
419 | * Get the size of the memory by reading all the DRAM size values | 430 | * Get the size of the memory by reading all the DRAM size values |
420 | * and adding them up. | 431 | * and adding them up. |
421 | * | 432 | * |
422 | * KLUDGE ALERT: the boards we are using have invalid column and | 433 | * KLUDGE ALERT: the boards we are using have invalid column and |
423 | * row mux values. We fix them here, but this will break other | 434 | * row mux values. We fix them here, but this will break other |
424 | * memory configurations. | 435 | * memory configurations. |
425 | */ | 436 | */ |
426 | pci_read_config_dword(dev, PMC551_DRAM_BLK0, &dram_data); | 437 | pci_read_config_dword(dev, PMC551_DRAM_BLK0, &dram_data); |
427 | size = PMC551_DRAM_BLK_GET_SIZE(dram_data); | 438 | size = PMC551_DRAM_BLK_GET_SIZE(dram_data); |
428 | dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5); | 439 | dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5); |
429 | dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9); | 440 | dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9); |
430 | pci_write_config_dword(dev, PMC551_DRAM_BLK0, dram_data); | 441 | pci_write_config_dword(dev, PMC551_DRAM_BLK0, dram_data); |
431 | 442 | ||
432 | pci_read_config_dword(dev, PMC551_DRAM_BLK1, &dram_data); | 443 | pci_read_config_dword(dev, PMC551_DRAM_BLK1, &dram_data); |
433 | size += PMC551_DRAM_BLK_GET_SIZE(dram_data); | 444 | size += PMC551_DRAM_BLK_GET_SIZE(dram_data); |
434 | dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5); | 445 | dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5); |
435 | dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9); | 446 | dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9); |
436 | pci_write_config_dword(dev, PMC551_DRAM_BLK1, dram_data); | 447 | pci_write_config_dword(dev, PMC551_DRAM_BLK1, dram_data); |
437 | 448 | ||
438 | pci_read_config_dword(dev, PMC551_DRAM_BLK2, &dram_data); | 449 | pci_read_config_dword(dev, PMC551_DRAM_BLK2, &dram_data); |
439 | size += PMC551_DRAM_BLK_GET_SIZE(dram_data); | 450 | size += PMC551_DRAM_BLK_GET_SIZE(dram_data); |
440 | dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5); | 451 | dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5); |
441 | dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9); | 452 | dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9); |
442 | pci_write_config_dword(dev, PMC551_DRAM_BLK2, dram_data); | 453 | pci_write_config_dword(dev, PMC551_DRAM_BLK2, dram_data); |
443 | 454 | ||
444 | pci_read_config_dword(dev, PMC551_DRAM_BLK3, &dram_data); | 455 | pci_read_config_dword(dev, PMC551_DRAM_BLK3, &dram_data); |
445 | size += PMC551_DRAM_BLK_GET_SIZE(dram_data); | 456 | size += PMC551_DRAM_BLK_GET_SIZE(dram_data); |
446 | dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5); | 457 | dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5); |
447 | dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9); | 458 | dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9); |
448 | pci_write_config_dword(dev, PMC551_DRAM_BLK3, dram_data); | 459 | pci_write_config_dword(dev, PMC551_DRAM_BLK3, dram_data); |
449 | 460 | ||
450 | /* | 461 | /* |
451 | * Oops .. something went wrong | 462 | * Oops .. something went wrong |
452 | */ | 463 | */ |
453 | if( (size &= PCI_BASE_ADDRESS_MEM_MASK) == 0) { | 464 | if ((size &= PCI_BASE_ADDRESS_MEM_MASK) == 0) { |
454 | return -ENODEV; | 465 | return -ENODEV; |
455 | } | 466 | } |
456 | #endif /* CONFIG_MTD_PMC551_BUGFIX */ | 467 | #endif /* CONFIG_MTD_PMC551_BUGFIX */ |
457 | 468 | ||
458 | if ((cfg&PCI_BASE_ADDRESS_SPACE) != PCI_BASE_ADDRESS_SPACE_MEMORY) { | 469 | if ((cfg & PCI_BASE_ADDRESS_SPACE) != PCI_BASE_ADDRESS_SPACE_MEMORY) { |
459 | return -ENODEV; | 470 | return -ENODEV; |
460 | } | 471 | } |
461 | 472 | ||
462 | /* | 473 | /* |
463 | * Precharge Dram | 474 | * Precharge Dram |
464 | */ | 475 | */ |
465 | pci_write_config_word( dev, PMC551_SDRAM_MA, 0x0400 ); | 476 | pci_write_config_word(dev, PMC551_SDRAM_MA, 0x0400); |
466 | pci_write_config_word( dev, PMC551_SDRAM_CMD, 0x00bf ); | 477 | pci_write_config_word(dev, PMC551_SDRAM_CMD, 0x00bf); |
467 | 478 | ||
468 | /* | 479 | /* |
469 | * Wait until command has gone through | 480 | * Wait until command has gone through |
470 | * FIXME: register spinning issue | 481 | * FIXME: register spinning issue |
471 | */ | 482 | */ |
472 | do { pci_read_config_word( dev, PMC551_SDRAM_CMD, &cmd ); | 483 | do { |
473 | if(counter++ > 100)break; | 484 | pci_read_config_word(dev, PMC551_SDRAM_CMD, &cmd); |
474 | } while ( (PCI_COMMAND_IO) & cmd ); | 485 | if (counter++ > 100) |
475 | 486 | break; | |
476 | /* | 487 | } while ((PCI_COMMAND_IO) & cmd); |
488 | |||
489 | /* | ||
477 | * Turn on auto refresh | 490 | * Turn on auto refresh |
478 | * The loop is taken directly from Ramix's example code. I assume that | 491 | * The loop is taken directly from Ramix's example code. I assume that |
479 | * this must be held high for some duration of time, but I can find no | 492 | * this must be held high for some duration of time, but I can find no |
480 | * documentation refrencing the reasons why. | 493 | * documentation refrencing the reasons why. |
481 | */ | 494 | */ |
482 | for ( i = 1; i<=8 ; i++) { | 495 | for (i = 1; i <= 8; i++) { |
483 | pci_write_config_word (dev, PMC551_SDRAM_CMD, 0x0df); | 496 | pci_write_config_word(dev, PMC551_SDRAM_CMD, 0x0df); |
484 | 497 | ||
485 | /* | 498 | /* |
486 | * Make certain command has gone through | 499 | * Make certain command has gone through |
487 | * FIXME: register spinning issue | 500 | * FIXME: register spinning issue |
488 | */ | 501 | */ |
489 | counter=0; | 502 | counter = 0; |
490 | do { pci_read_config_word(dev, PMC551_SDRAM_CMD, &cmd); | 503 | do { |
491 | if(counter++ > 100)break; | 504 | pci_read_config_word(dev, PMC551_SDRAM_CMD, &cmd); |
492 | } while ( (PCI_COMMAND_IO) & cmd ); | 505 | if (counter++ > 100) |
493 | } | 506 | break; |
494 | 507 | } while ((PCI_COMMAND_IO) & cmd); | |
495 | pci_write_config_word ( dev, PMC551_SDRAM_MA, 0x0020); | 508 | } |
496 | pci_write_config_word ( dev, PMC551_SDRAM_CMD, 0x0ff); | 509 | |
497 | 510 | pci_write_config_word(dev, PMC551_SDRAM_MA, 0x0020); | |
498 | /* | 511 | pci_write_config_word(dev, PMC551_SDRAM_CMD, 0x0ff); |
499 | * Wait until command completes | 512 | |
500 | * FIXME: register spinning issue | 513 | /* |
501 | */ | 514 | * Wait until command completes |
502 | counter=0; | 515 | * FIXME: register spinning issue |
503 | do { pci_read_config_word ( dev, PMC551_SDRAM_CMD, &cmd); | 516 | */ |
504 | if(counter++ > 100)break; | 517 | counter = 0; |
505 | } while ( (PCI_COMMAND_IO) & cmd ); | 518 | do { |
506 | 519 | pci_read_config_word(dev, PMC551_SDRAM_CMD, &cmd); | |
507 | pci_read_config_dword ( dev, PMC551_DRAM_CFG, &dcmd); | 520 | if (counter++ > 100) |
508 | dcmd |= 0x02000000; | 521 | break; |
509 | pci_write_config_dword ( dev, PMC551_DRAM_CFG, dcmd); | 522 | } while ((PCI_COMMAND_IO) & cmd); |
510 | 523 | ||
511 | /* | 524 | pci_read_config_dword(dev, PMC551_DRAM_CFG, &dcmd); |
512 | * Check to make certain fast back-to-back, if not | 525 | dcmd |= 0x02000000; |
513 | * then set it so | 526 | pci_write_config_dword(dev, PMC551_DRAM_CFG, dcmd); |
514 | */ | 527 | |
515 | pci_read_config_word( dev, PCI_STATUS, &cmd); | 528 | /* |
516 | if((cmd&PCI_COMMAND_FAST_BACK) == 0) { | 529 | * Check to make certain fast back-to-back, if not |
517 | cmd |= PCI_COMMAND_FAST_BACK; | 530 | * then set it so |
518 | pci_write_config_word( dev, PCI_STATUS, cmd); | 531 | */ |
519 | } | 532 | pci_read_config_word(dev, PCI_STATUS, &cmd); |
520 | 533 | if ((cmd & PCI_COMMAND_FAST_BACK) == 0) { | |
521 | /* | 534 | cmd |= PCI_COMMAND_FAST_BACK; |
522 | * Check to make certain the DEVSEL is set correctly, this device | 535 | pci_write_config_word(dev, PCI_STATUS, cmd); |
523 | * has a tendancy to assert DEVSEL and TRDY when a write is performed | 536 | } |
524 | * to the memory when memory is read-only | 537 | |
525 | */ | 538 | /* |
526 | if((cmd&PCI_STATUS_DEVSEL_MASK) != 0x0) { | 539 | * Check to make certain the DEVSEL is set correctly, this device |
527 | cmd &= ~PCI_STATUS_DEVSEL_MASK; | 540 | * has a tendancy to assert DEVSEL and TRDY when a write is performed |
528 | pci_write_config_word( dev, PCI_STATUS, cmd ); | 541 | * to the memory when memory is read-only |
529 | } | 542 | */ |
530 | /* | 543 | if ((cmd & PCI_STATUS_DEVSEL_MASK) != 0x0) { |
531 | * Set to be prefetchable and put everything back based on old cfg. | 544 | cmd &= ~PCI_STATUS_DEVSEL_MASK; |
545 | pci_write_config_word(dev, PCI_STATUS, cmd); | ||
546 | } | ||
547 | /* | ||
548 | * Set to be prefetchable and put everything back based on old cfg. | ||
532 | * it's possible that the reset of the V370PDC nuked the original | 549 | * it's possible that the reset of the V370PDC nuked the original |
533 | * setup | 550 | * setup |
534 | */ | 551 | */ |
552 | /* | ||
553 | cfg |= PCI_BASE_ADDRESS_MEM_PREFETCH; | ||
554 | pci_write_config_dword( dev, PCI_BASE_ADDRESS_0, cfg ); | ||
555 | */ | ||
556 | |||
535 | /* | 557 | /* |
536 | cfg |= PCI_BASE_ADDRESS_MEM_PREFETCH; | 558 | * Turn PCI memory and I/O bus access back on |
537 | pci_write_config_dword( dev, PCI_BASE_ADDRESS_0, cfg ); | 559 | */ |
538 | */ | 560 | pci_write_config_word(dev, PCI_COMMAND, |
539 | 561 | PCI_COMMAND_MEMORY | PCI_COMMAND_IO); | |
540 | /* | ||
541 | * Turn PCI memory and I/O bus access back on | ||
542 | */ | ||
543 | pci_write_config_word( dev, PCI_COMMAND, | ||
544 | PCI_COMMAND_MEMORY | PCI_COMMAND_IO ); | ||
545 | #ifdef CONFIG_MTD_PMC551_DEBUG | 562 | #ifdef CONFIG_MTD_PMC551_DEBUG |
546 | /* | 563 | /* |
547 | * Some screen fun | 564 | * Some screen fun |
548 | */ | 565 | */ |
549 | printk(KERN_DEBUG "pmc551: %d%c (0x%x) of %sprefetchable memory at 0x%llx\n", | 566 | printk(KERN_DEBUG "pmc551: %d%c (0x%x) of %sprefetchable memory at " |
550 | (size<1024)?size:(size<1048576)?size>>10:size>>20, | 567 | "0x%llx\n", (size < 1024) ? size : (size < 1048576) ? |
551 | (size<1024)?'B':(size<1048576)?'K':'M', | 568 | size >> 10 : size >> 20, |
552 | size, ((dcmd&(0x1<<3)) == 0)?"non-":"", | 569 | (size < 1024) ? 'B' : (size < 1048576) ? 'K' : 'M', size, |
553 | (unsigned long long)((dev->resource[0].start)&PCI_BASE_ADDRESS_MEM_MASK)); | 570 | ((dcmd & (0x1 << 3)) == 0) ? "non-" : "", |
554 | 571 | (unsigned long long)pci_resource_start(dev, 0)); | |
555 | /* | 572 | |
556 | * Check to see the state of the memory | 573 | /* |
557 | */ | 574 | * Check to see the state of the memory |
558 | pci_read_config_dword( dev, PMC551_DRAM_BLK0, &dcmd ); | 575 | */ |
559 | printk(KERN_DEBUG "pmc551: DRAM_BLK0 Flags: %s,%s\n" | 576 | pci_read_config_dword(dev, PMC551_DRAM_BLK0, &dcmd); |
560 | "pmc551: DRAM_BLK0 Size: %d at %d\n" | 577 | printk(KERN_DEBUG "pmc551: DRAM_BLK0 Flags: %s,%s\n" |
561 | "pmc551: DRAM_BLK0 Row MUX: %d, Col MUX: %d\n", | 578 | "pmc551: DRAM_BLK0 Size: %d at %d\n" |
562 | (((0x1<<1)&dcmd) == 0)?"RW":"RO", | 579 | "pmc551: DRAM_BLK0 Row MUX: %d, Col MUX: %d\n", |
563 | (((0x1<<0)&dcmd) == 0)?"Off":"On", | 580 | (((0x1 << 1) & dcmd) == 0) ? "RW" : "RO", |
564 | PMC551_DRAM_BLK_GET_SIZE(dcmd), | 581 | (((0x1 << 0) & dcmd) == 0) ? "Off" : "On", |
565 | ((dcmd>>20)&0x7FF), ((dcmd>>13)&0x7), ((dcmd>>9)&0xF) ); | 582 | PMC551_DRAM_BLK_GET_SIZE(dcmd), |
566 | 583 | ((dcmd >> 20) & 0x7FF), ((dcmd >> 13) & 0x7), | |
567 | pci_read_config_dword( dev, PMC551_DRAM_BLK1, &dcmd ); | 584 | ((dcmd >> 9) & 0xF)); |
568 | printk(KERN_DEBUG "pmc551: DRAM_BLK1 Flags: %s,%s\n" | 585 | |
569 | "pmc551: DRAM_BLK1 Size: %d at %d\n" | 586 | pci_read_config_dword(dev, PMC551_DRAM_BLK1, &dcmd); |
570 | "pmc551: DRAM_BLK1 Row MUX: %d, Col MUX: %d\n", | 587 | printk(KERN_DEBUG "pmc551: DRAM_BLK1 Flags: %s,%s\n" |
571 | (((0x1<<1)&dcmd) == 0)?"RW":"RO", | 588 | "pmc551: DRAM_BLK1 Size: %d at %d\n" |
572 | (((0x1<<0)&dcmd) == 0)?"Off":"On", | 589 | "pmc551: DRAM_BLK1 Row MUX: %d, Col MUX: %d\n", |
573 | PMC551_DRAM_BLK_GET_SIZE(dcmd), | 590 | (((0x1 << 1) & dcmd) == 0) ? "RW" : "RO", |
574 | ((dcmd>>20)&0x7FF), ((dcmd>>13)&0x7), ((dcmd>>9)&0xF) ); | 591 | (((0x1 << 0) & dcmd) == 0) ? "Off" : "On", |
575 | 592 | PMC551_DRAM_BLK_GET_SIZE(dcmd), | |
576 | pci_read_config_dword( dev, PMC551_DRAM_BLK2, &dcmd ); | 593 | ((dcmd >> 20) & 0x7FF), ((dcmd >> 13) & 0x7), |
577 | printk(KERN_DEBUG "pmc551: DRAM_BLK2 Flags: %s,%s\n" | 594 | ((dcmd >> 9) & 0xF)); |
578 | "pmc551: DRAM_BLK2 Size: %d at %d\n" | 595 | |
579 | "pmc551: DRAM_BLK2 Row MUX: %d, Col MUX: %d\n", | 596 | pci_read_config_dword(dev, PMC551_DRAM_BLK2, &dcmd); |
580 | (((0x1<<1)&dcmd) == 0)?"RW":"RO", | 597 | printk(KERN_DEBUG "pmc551: DRAM_BLK2 Flags: %s,%s\n" |
581 | (((0x1<<0)&dcmd) == 0)?"Off":"On", | 598 | "pmc551: DRAM_BLK2 Size: %d at %d\n" |
582 | PMC551_DRAM_BLK_GET_SIZE(dcmd), | 599 | "pmc551: DRAM_BLK2 Row MUX: %d, Col MUX: %d\n", |
583 | ((dcmd>>20)&0x7FF), ((dcmd>>13)&0x7), ((dcmd>>9)&0xF) ); | 600 | (((0x1 << 1) & dcmd) == 0) ? "RW" : "RO", |
584 | 601 | (((0x1 << 0) & dcmd) == 0) ? "Off" : "On", | |
585 | pci_read_config_dword( dev, PMC551_DRAM_BLK3, &dcmd ); | 602 | PMC551_DRAM_BLK_GET_SIZE(dcmd), |
586 | printk(KERN_DEBUG "pmc551: DRAM_BLK3 Flags: %s,%s\n" | 603 | ((dcmd >> 20) & 0x7FF), ((dcmd >> 13) & 0x7), |
587 | "pmc551: DRAM_BLK3 Size: %d at %d\n" | 604 | ((dcmd >> 9) & 0xF)); |
588 | "pmc551: DRAM_BLK3 Row MUX: %d, Col MUX: %d\n", | 605 | |
589 | (((0x1<<1)&dcmd) == 0)?"RW":"RO", | 606 | pci_read_config_dword(dev, PMC551_DRAM_BLK3, &dcmd); |
590 | (((0x1<<0)&dcmd) == 0)?"Off":"On", | 607 | printk(KERN_DEBUG "pmc551: DRAM_BLK3 Flags: %s,%s\n" |
591 | PMC551_DRAM_BLK_GET_SIZE(dcmd), | 608 | "pmc551: DRAM_BLK3 Size: %d at %d\n" |
592 | ((dcmd>>20)&0x7FF), ((dcmd>>13)&0x7), ((dcmd>>9)&0xF) ); | 609 | "pmc551: DRAM_BLK3 Row MUX: %d, Col MUX: %d\n", |
593 | 610 | (((0x1 << 1) & dcmd) == 0) ? "RW" : "RO", | |
594 | pci_read_config_word( dev, PCI_COMMAND, &cmd ); | 611 | (((0x1 << 0) & dcmd) == 0) ? "Off" : "On", |
595 | printk( KERN_DEBUG "pmc551: Memory Access %s\n", | 612 | PMC551_DRAM_BLK_GET_SIZE(dcmd), |
596 | (((0x1<<1)&cmd) == 0)?"off":"on" ); | 613 | ((dcmd >> 20) & 0x7FF), ((dcmd >> 13) & 0x7), |
597 | printk( KERN_DEBUG "pmc551: I/O Access %s\n", | 614 | ((dcmd >> 9) & 0xF)); |
598 | (((0x1<<0)&cmd) == 0)?"off":"on" ); | 615 | |
599 | 616 | pci_read_config_word(dev, PCI_COMMAND, &cmd); | |
600 | pci_read_config_word( dev, PCI_STATUS, &cmd ); | 617 | printk(KERN_DEBUG "pmc551: Memory Access %s\n", |
601 | printk( KERN_DEBUG "pmc551: Devsel %s\n", | 618 | (((0x1 << 1) & cmd) == 0) ? "off" : "on"); |
602 | ((PCI_STATUS_DEVSEL_MASK&cmd)==0x000)?"Fast": | 619 | printk(KERN_DEBUG "pmc551: I/O Access %s\n", |
603 | ((PCI_STATUS_DEVSEL_MASK&cmd)==0x200)?"Medium": | 620 | (((0x1 << 0) & cmd) == 0) ? "off" : "on"); |
604 | ((PCI_STATUS_DEVSEL_MASK&cmd)==0x400)?"Slow":"Invalid" ); | 621 | |
605 | 622 | pci_read_config_word(dev, PCI_STATUS, &cmd); | |
606 | printk( KERN_DEBUG "pmc551: %sFast Back-to-Back\n", | 623 | printk(KERN_DEBUG "pmc551: Devsel %s\n", |
607 | ((PCI_COMMAND_FAST_BACK&cmd) == 0)?"Not ":"" ); | 624 | ((PCI_STATUS_DEVSEL_MASK & cmd) == 0x000) ? "Fast" : |
608 | 625 | ((PCI_STATUS_DEVSEL_MASK & cmd) == 0x200) ? "Medium" : | |
609 | pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd ); | 626 | ((PCI_STATUS_DEVSEL_MASK & cmd) == 0x400) ? "Slow" : "Invalid"); |
610 | printk( KERN_DEBUG "pmc551: EEPROM is under %s control\n" | 627 | |
611 | "pmc551: System Control Register is %slocked to PCI access\n" | 628 | printk(KERN_DEBUG "pmc551: %sFast Back-to-Back\n", |
612 | "pmc551: System Control Register is %slocked to EEPROM access\n", | 629 | ((PCI_COMMAND_FAST_BACK & cmd) == 0) ? "Not " : ""); |
613 | (bcmd&0x1)?"software":"hardware", | 630 | |
614 | (bcmd&0x20)?"":"un", (bcmd&0x40)?"":"un"); | 631 | pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd); |
632 | printk(KERN_DEBUG "pmc551: EEPROM is under %s control\n" | ||
633 | "pmc551: System Control Register is %slocked to PCI access\n" | ||
634 | "pmc551: System Control Register is %slocked to EEPROM access\n", | ||
635 | (bcmd & 0x1) ? "software" : "hardware", | ||
636 | (bcmd & 0x20) ? "" : "un", (bcmd & 0x40) ? "" : "un"); | ||
615 | #endif | 637 | #endif |
616 | return size; | 638 | return size; |
617 | } | 639 | } |
618 | 640 | ||
619 | /* | 641 | /* |
620 | * Kernel version specific module stuffages | 642 | * Kernel version specific module stuffages |
621 | */ | 643 | */ |
622 | 644 | ||
623 | |||
624 | MODULE_LICENSE("GPL"); | 645 | MODULE_LICENSE("GPL"); |
625 | MODULE_AUTHOR("Mark Ferrell <mferrell@mvista.com>"); | 646 | MODULE_AUTHOR("Mark Ferrell <mferrell@mvista.com>"); |
626 | MODULE_DESCRIPTION(PMC551_VERSION); | 647 | MODULE_DESCRIPTION(PMC551_VERSION); |
@@ -628,11 +649,11 @@ MODULE_DESCRIPTION(PMC551_VERSION); | |||
628 | /* | 649 | /* |
629 | * Stuff these outside the ifdef so as to not bust compiled in driver support | 650 | * Stuff these outside the ifdef so as to not bust compiled in driver support |
630 | */ | 651 | */ |
631 | static int msize=0; | 652 | static int msize = 0; |
632 | #if defined(CONFIG_MTD_PMC551_APERTURE_SIZE) | 653 | #if defined(CONFIG_MTD_PMC551_APERTURE_SIZE) |
633 | static int asize=CONFIG_MTD_PMC551_APERTURE_SIZE | 654 | static int asize = CONFIG_MTD_PMC551_APERTURE_SIZE |
634 | #else | 655 | #else |
635 | static int asize=0; | 656 | static int asize = 0; |
636 | #endif | 657 | #endif |
637 | 658 | ||
638 | module_param(msize, int, 0); | 659 | module_param(msize, int, 0); |
@@ -645,164 +666,174 @@ MODULE_PARM_DESC(asize, "aperture size, must be <= memsize [1-1024]"); | |||
645 | */ | 666 | */ |
646 | static int __init init_pmc551(void) | 667 | static int __init init_pmc551(void) |
647 | { | 668 | { |
648 | struct pci_dev *PCI_Device = NULL; | 669 | struct pci_dev *PCI_Device = NULL; |
649 | struct mypriv *priv; | 670 | struct mypriv *priv; |
650 | int count, found=0; | 671 | int count, found = 0; |
651 | struct mtd_info *mtd; | 672 | struct mtd_info *mtd; |
652 | u32 length = 0; | 673 | u32 length = 0; |
653 | 674 | ||
654 | if(msize) { | 675 | if (msize) { |
655 | msize = (1 << (ffs(msize) - 1))<<20; | 676 | msize = (1 << (ffs(msize) - 1)) << 20; |
656 | if (msize > (1<<30)) { | 677 | if (msize > (1 << 30)) { |
657 | printk(KERN_NOTICE "pmc551: Invalid memory size [%d]\n", msize); | 678 | printk(KERN_NOTICE "pmc551: Invalid memory size [%d]\n", |
679 | msize); | ||
658 | return -EINVAL; | 680 | return -EINVAL; |
659 | } | 681 | } |
660 | } | 682 | } |
661 | 683 | ||
662 | if(asize) { | 684 | if (asize) { |
663 | asize = (1 << (ffs(asize) - 1))<<20; | 685 | asize = (1 << (ffs(asize) - 1)) << 20; |
664 | if (asize > (1<<30) ) { | 686 | if (asize > (1 << 30)) { |
665 | printk(KERN_NOTICE "pmc551: Invalid aperture size [%d]\n", asize); | 687 | printk(KERN_NOTICE "pmc551: Invalid aperture size " |
688 | "[%d]\n", asize); | ||
666 | return -EINVAL; | 689 | return -EINVAL; |
667 | } | 690 | } |
668 | } | 691 | } |
669 | 692 | ||
670 | printk(KERN_INFO PMC551_VERSION); | 693 | printk(KERN_INFO PMC551_VERSION); |
671 | 694 | ||
672 | /* | 695 | /* |
673 | * PCU-bus chipset probe. | 696 | * PCU-bus chipset probe. |
674 | */ | 697 | */ |
675 | for( count = 0; count < MAX_MTD_DEVICES; count++ ) { | 698 | for (count = 0; count < MAX_MTD_DEVICES; count++) { |
676 | 699 | ||
677 | if ((PCI_Device = pci_find_device(PCI_VENDOR_ID_V3_SEMI, | 700 | if ((PCI_Device = pci_get_device(PCI_VENDOR_ID_V3_SEMI, |
678 | PCI_DEVICE_ID_V3_SEMI_V370PDC, | 701 | PCI_DEVICE_ID_V3_SEMI_V370PDC, |
679 | PCI_Device ) ) == NULL) { | 702 | PCI_Device)) == NULL) { |
680 | break; | 703 | break; |
681 | } | 704 | } |
682 | 705 | ||
683 | printk(KERN_NOTICE "pmc551: Found PCI V370PDC at 0x%llx\n", | 706 | printk(KERN_NOTICE "pmc551: Found PCI V370PDC at 0x%llx\n", |
684 | (unsigned long long)PCI_Device->resource[0].start); | 707 | (unsigned long long)pci_resource_start(PCI_Device, 0)); |
685 | 708 | ||
686 | /* | 709 | /* |
687 | * The PMC551 device acts VERY weird if you don't init it | 710 | * The PMC551 device acts VERY weird if you don't init it |
688 | * first. i.e. it will not correctly report devsel. If for | 711 | * first. i.e. it will not correctly report devsel. If for |
689 | * some reason the sdram is in a wrote-protected state the | 712 | * some reason the sdram is in a wrote-protected state the |
690 | * device will DEVSEL when it is written to causing problems | 713 | * device will DEVSEL when it is written to causing problems |
691 | * with the oldproc.c driver in | 714 | * with the oldproc.c driver in |
692 | * some kernels (2.2.*) | 715 | * some kernels (2.2.*) |
693 | */ | 716 | */ |
694 | if((length = fixup_pmc551(PCI_Device)) <= 0) { | 717 | if ((length = fixup_pmc551(PCI_Device)) <= 0) { |
695 | printk(KERN_NOTICE "pmc551: Cannot init SDRAM\n"); | 718 | printk(KERN_NOTICE "pmc551: Cannot init SDRAM\n"); |
696 | break; | 719 | break; |
697 | } | 720 | } |
698 | 721 | ||
699 | /* | 722 | /* |
700 | * This is needed until the driver is capable of reading the | 723 | * This is needed until the driver is capable of reading the |
701 | * onboard I2C SROM to discover the "real" memory size. | 724 | * onboard I2C SROM to discover the "real" memory size. |
702 | */ | 725 | */ |
703 | if(msize) { | 726 | if (msize) { |
704 | length = msize; | 727 | length = msize; |
705 | printk(KERN_NOTICE "pmc551: Using specified memory size 0x%x\n", length); | 728 | printk(KERN_NOTICE "pmc551: Using specified memory " |
729 | "size 0x%x\n", length); | ||
706 | } else { | 730 | } else { |
707 | msize = length; | 731 | msize = length; |
708 | } | 732 | } |
709 | 733 | ||
710 | mtd = kmalloc(sizeof(struct mtd_info), GFP_KERNEL); | 734 | mtd = kzalloc(sizeof(struct mtd_info), GFP_KERNEL); |
711 | if (!mtd) { | 735 | if (!mtd) { |
712 | printk(KERN_NOTICE "pmc551: Cannot allocate new MTD device.\n"); | 736 | printk(KERN_NOTICE "pmc551: Cannot allocate new MTD " |
713 | break; | 737 | "device.\n"); |
714 | } | 738 | break; |
715 | 739 | } | |
716 | memset(mtd, 0, sizeof(struct mtd_info)); | 740 | |
717 | 741 | priv = kzalloc(sizeof(struct mypriv), GFP_KERNEL); | |
718 | priv = kmalloc (sizeof(struct mypriv), GFP_KERNEL); | 742 | if (!priv) { |
719 | if (!priv) { | 743 | printk(KERN_NOTICE "pmc551: Cannot allocate new MTD " |
720 | printk(KERN_NOTICE "pmc551: Cannot allocate new MTD device.\n"); | 744 | "device.\n"); |
721 | kfree(mtd); | 745 | kfree(mtd); |
722 | break; | 746 | break; |
723 | } | 747 | } |
724 | memset(priv, 0, sizeof(*priv)); | 748 | mtd->priv = priv; |
725 | mtd->priv = priv; | 749 | priv->dev = PCI_Device; |
726 | priv->dev = PCI_Device; | 750 | |
727 | 751 | if (asize > length) { | |
728 | if(asize > length) { | 752 | printk(KERN_NOTICE "pmc551: reducing aperture size to " |
729 | printk(KERN_NOTICE "pmc551: reducing aperture size to fit %dM\n",length>>20); | 753 | "fit %dM\n", length >> 20); |
730 | priv->asize = asize = length; | 754 | priv->asize = asize = length; |
731 | } else if (asize == 0 || asize == length) { | 755 | } else if (asize == 0 || asize == length) { |
732 | printk(KERN_NOTICE "pmc551: Using existing aperture size %dM\n", length>>20); | 756 | printk(KERN_NOTICE "pmc551: Using existing aperture " |
757 | "size %dM\n", length >> 20); | ||
733 | priv->asize = asize = length; | 758 | priv->asize = asize = length; |
734 | } else { | 759 | } else { |
735 | printk(KERN_NOTICE "pmc551: Using specified aperture size %dM\n", asize>>20); | 760 | printk(KERN_NOTICE "pmc551: Using specified aperture " |
761 | "size %dM\n", asize >> 20); | ||
736 | priv->asize = asize; | 762 | priv->asize = asize; |
737 | } | 763 | } |
738 | priv->start = ioremap(((PCI_Device->resource[0].start) | 764 | priv->start = pci_iomap(PCI_Device, 0, priv->asize); |
739 | & PCI_BASE_ADDRESS_MEM_MASK), | ||
740 | priv->asize); | ||
741 | 765 | ||
742 | if (!priv->start) { | 766 | if (!priv->start) { |
743 | printk(KERN_NOTICE "pmc551: Unable to map IO space\n"); | 767 | printk(KERN_NOTICE "pmc551: Unable to map IO space\n"); |
744 | kfree(mtd->priv); | 768 | kfree(mtd->priv); |
745 | kfree(mtd); | 769 | kfree(mtd); |
746 | break; | 770 | break; |
747 | } | 771 | } |
748 | |||
749 | #ifdef CONFIG_MTD_PMC551_DEBUG | 772 | #ifdef CONFIG_MTD_PMC551_DEBUG |
750 | printk( KERN_DEBUG "pmc551: setting aperture to %d\n", | 773 | printk(KERN_DEBUG "pmc551: setting aperture to %d\n", |
751 | ffs(priv->asize>>20)-1); | 774 | ffs(priv->asize >> 20) - 1); |
752 | #endif | 775 | #endif |
753 | 776 | ||
754 | priv->base_map0 = ( PMC551_PCI_MEM_MAP_REG_EN | 777 | priv->base_map0 = (PMC551_PCI_MEM_MAP_REG_EN |
755 | | PMC551_PCI_MEM_MAP_ENABLE | 778 | | PMC551_PCI_MEM_MAP_ENABLE |
756 | | (ffs(priv->asize>>20)-1)<<4 ); | 779 | | (ffs(priv->asize >> 20) - 1) << 4); |
757 | priv->curr_map0 = priv->base_map0; | 780 | priv->curr_map0 = priv->base_map0; |
758 | pci_write_config_dword ( priv->dev, PMC551_PCI_MEM_MAP0, | 781 | pci_write_config_dword(priv->dev, PMC551_PCI_MEM_MAP0, |
759 | priv->curr_map0 ); | 782 | priv->curr_map0); |
760 | 783 | ||
761 | #ifdef CONFIG_MTD_PMC551_DEBUG | 784 | #ifdef CONFIG_MTD_PMC551_DEBUG |
762 | printk( KERN_DEBUG "pmc551: aperture set to %d\n", | 785 | printk(KERN_DEBUG "pmc551: aperture set to %d\n", |
763 | (priv->base_map0 & 0xF0)>>4 ); | 786 | (priv->base_map0 & 0xF0) >> 4); |
764 | #endif | 787 | #endif |
765 | 788 | ||
766 | mtd->size = msize; | 789 | mtd->size = msize; |
767 | mtd->flags = MTD_CAP_RAM; | 790 | mtd->flags = MTD_CAP_RAM; |
768 | mtd->erase = pmc551_erase; | 791 | mtd->erase = pmc551_erase; |
769 | mtd->read = pmc551_read; | 792 | mtd->read = pmc551_read; |
770 | mtd->write = pmc551_write; | 793 | mtd->write = pmc551_write; |
771 | mtd->point = pmc551_point; | 794 | mtd->point = pmc551_point; |
772 | mtd->unpoint = pmc551_unpoint; | 795 | mtd->unpoint = pmc551_unpoint; |
773 | mtd->type = MTD_RAM; | 796 | mtd->type = MTD_RAM; |
774 | mtd->name = "PMC551 RAM board"; | 797 | mtd->name = "PMC551 RAM board"; |
775 | mtd->erasesize = 0x10000; | 798 | mtd->erasesize = 0x10000; |
776 | mtd->writesize = 1; | 799 | mtd->writesize = 1; |
777 | mtd->owner = THIS_MODULE; | 800 | mtd->owner = THIS_MODULE; |
778 | 801 | ||
779 | if (add_mtd_device(mtd)) { | 802 | if (add_mtd_device(mtd)) { |
780 | printk(KERN_NOTICE "pmc551: Failed to register new device\n"); | 803 | printk(KERN_NOTICE "pmc551: Failed to register new " |
781 | iounmap(priv->start); | 804 | "device\n"); |
782 | kfree(mtd->priv); | 805 | pci_iounmap(PCI_Device, priv->start); |
783 | kfree(mtd); | 806 | kfree(mtd->priv); |
784 | break; | 807 | kfree(mtd); |
785 | } | 808 | break; |
786 | printk(KERN_NOTICE "Registered pmc551 memory device.\n"); | 809 | } |
787 | printk(KERN_NOTICE "Mapped %dM of memory from 0x%p to 0x%p\n", | 810 | |
788 | priv->asize>>20, | 811 | /* Keep a reference as the add_mtd_device worked */ |
789 | priv->start, | 812 | pci_dev_get(PCI_Device); |
790 | priv->start + priv->asize); | 813 | |
791 | printk(KERN_NOTICE "Total memory is %d%c\n", | 814 | printk(KERN_NOTICE "Registered pmc551 memory device.\n"); |
792 | (length<1024)?length: | 815 | printk(KERN_NOTICE "Mapped %dM of memory from 0x%p to 0x%p\n", |
793 | (length<1048576)?length>>10:length>>20, | 816 | priv->asize >> 20, |
794 | (length<1024)?'B':(length<1048576)?'K':'M'); | 817 | priv->start, priv->start + priv->asize); |
818 | printk(KERN_NOTICE "Total memory is %d%c\n", | ||
819 | (length < 1024) ? length : | ||
820 | (length < 1048576) ? length >> 10 : length >> 20, | ||
821 | (length < 1024) ? 'B' : (length < 1048576) ? 'K' : 'M'); | ||
795 | priv->nextpmc551 = pmc551list; | 822 | priv->nextpmc551 = pmc551list; |
796 | pmc551list = mtd; | 823 | pmc551list = mtd; |
797 | found++; | 824 | found++; |
798 | } | 825 | } |
826 | |||
827 | /* Exited early, reference left over */ | ||
828 | if (PCI_Device) | ||
829 | pci_dev_put(PCI_Device); | ||
799 | 830 | ||
800 | if( !pmc551list ) { | 831 | if (!pmc551list) { |
801 | printk(KERN_NOTICE "pmc551: not detected\n"); | 832 | printk(KERN_NOTICE "pmc551: not detected\n"); |
802 | return -ENODEV; | 833 | return -ENODEV; |
803 | } else { | 834 | } else { |
804 | printk(KERN_NOTICE "pmc551: %d pmc551 devices loaded\n", found); | 835 | printk(KERN_NOTICE "pmc551: %d pmc551 devices loaded\n", found); |
805 | return 0; | 836 | return 0; |
806 | } | 837 | } |
807 | } | 838 | } |
808 | 839 | ||
@@ -811,23 +842,24 @@ static int __init init_pmc551(void) | |||
811 | */ | 842 | */ |
812 | static void __exit cleanup_pmc551(void) | 843 | static void __exit cleanup_pmc551(void) |
813 | { | 844 | { |
814 | int found=0; | 845 | int found = 0; |
815 | struct mtd_info *mtd; | 846 | struct mtd_info *mtd; |
816 | struct mypriv *priv; | 847 | struct mypriv *priv; |
817 | 848 | ||
818 | while((mtd=pmc551list)) { | 849 | while ((mtd = pmc551list)) { |
819 | priv = mtd->priv; | 850 | priv = mtd->priv; |
820 | pmc551list = priv->nextpmc551; | 851 | pmc551list = priv->nextpmc551; |
821 | 852 | ||
822 | if(priv->start) { | 853 | if (priv->start) { |
823 | printk (KERN_DEBUG "pmc551: unmapping %dM starting at 0x%p\n", | 854 | printk(KERN_DEBUG "pmc551: unmapping %dM starting at " |
824 | priv->asize>>20, priv->start); | 855 | "0x%p\n", priv->asize >> 20, priv->start); |
825 | iounmap (priv->start); | 856 | pci_iounmap(priv->dev, priv->start); |
826 | } | 857 | } |
858 | pci_dev_put(priv->dev); | ||
827 | 859 | ||
828 | kfree (mtd->priv); | 860 | kfree(mtd->priv); |
829 | del_mtd_device (mtd); | 861 | del_mtd_device(mtd); |
830 | kfree (mtd); | 862 | kfree(mtd); |
831 | found++; | 863 | found++; |
832 | } | 864 | } |
833 | 865 | ||
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index 64d1b6a6c920..24747bdc3e19 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig | |||
@@ -447,14 +447,6 @@ config MTD_DC21285 | |||
447 | 21285 bridge used with Intel's StrongARM processors. More info at | 447 | 21285 bridge used with Intel's StrongARM processors. More info at |
448 | <http://www.intel.com/design/bridge/docs/21285_documentation.htm>. | 448 | <http://www.intel.com/design/bridge/docs/21285_documentation.htm>. |
449 | 449 | ||
450 | config MTD_IQ80310 | ||
451 | tristate "CFI Flash device mapped on the XScale IQ80310 board" | ||
452 | depends on MTD_CFI && ARCH_IQ80310 | ||
453 | help | ||
454 | This enables access routines for the flash chips on the Intel XScale | ||
455 | IQ80310 evaluation board. If you have one of these boards and would | ||
456 | like to use the flash chips on it, say 'Y'. | ||
457 | |||
458 | config MTD_IXP4XX | 450 | config MTD_IXP4XX |
459 | tristate "CFI Flash device mapped on Intel IXP4xx based systems" | 451 | tristate "CFI Flash device mapped on Intel IXP4xx based systems" |
460 | depends on MTD_CFI && MTD_COMPLEX_MAPPINGS && ARCH_IXP4XX | 452 | depends on MTD_CFI && MTD_COMPLEX_MAPPINGS && ARCH_IXP4XX |
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile index ab71f172eb77..191c1928bbec 100644 --- a/drivers/mtd/maps/Makefile +++ b/drivers/mtd/maps/Makefile | |||
@@ -15,7 +15,6 @@ obj-$(CONFIG_MTD_CFI_FLAGADM) += cfi_flagadm.o | |||
15 | obj-$(CONFIG_MTD_CSTM_MIPS_IXX) += cstm_mips_ixx.o | 15 | obj-$(CONFIG_MTD_CSTM_MIPS_IXX) += cstm_mips_ixx.o |
16 | obj-$(CONFIG_MTD_DC21285) += dc21285.o | 16 | obj-$(CONFIG_MTD_DC21285) += dc21285.o |
17 | obj-$(CONFIG_MTD_DILNETPC) += dilnetpc.o | 17 | obj-$(CONFIG_MTD_DILNETPC) += dilnetpc.o |
18 | obj-$(CONFIG_MTD_IQ80310) += iq80310.o | ||
19 | obj-$(CONFIG_MTD_L440GX) += l440gx.o | 18 | obj-$(CONFIG_MTD_L440GX) += l440gx.o |
20 | obj-$(CONFIG_MTD_AMD76XROM) += amd76xrom.o | 19 | obj-$(CONFIG_MTD_AMD76XROM) += amd76xrom.o |
21 | obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o | 20 | obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o |
diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c index 447955be18af..797caffb20b1 100644 --- a/drivers/mtd/maps/amd76xrom.c +++ b/drivers/mtd/maps/amd76xrom.c | |||
@@ -57,6 +57,7 @@ static void amd76xrom_cleanup(struct amd76xrom_window *window) | |||
57 | /* Disable writes through the rom window */ | 57 | /* Disable writes through the rom window */ |
58 | pci_read_config_byte(window->pdev, 0x40, &byte); | 58 | pci_read_config_byte(window->pdev, 0x40, &byte); |
59 | pci_write_config_byte(window->pdev, 0x40, byte & ~1); | 59 | pci_write_config_byte(window->pdev, 0x40, byte & ~1); |
60 | pci_dev_put(window->pdev); | ||
60 | } | 61 | } |
61 | 62 | ||
62 | /* Free all of the mtd devices */ | 63 | /* Free all of the mtd devices */ |
@@ -91,7 +92,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev, | |||
91 | struct amd76xrom_map_info *map = NULL; | 92 | struct amd76xrom_map_info *map = NULL; |
92 | unsigned long map_top; | 93 | unsigned long map_top; |
93 | 94 | ||
94 | /* Remember the pci dev I find the window in */ | 95 | /* Remember the pci dev I find the window in - already have a ref */ |
95 | window->pdev = pdev; | 96 | window->pdev = pdev; |
96 | 97 | ||
97 | /* Assume the rom window is properly setup, and find it's size */ | 98 | /* Assume the rom window is properly setup, and find it's size */ |
@@ -302,7 +303,7 @@ static int __init init_amd76xrom(void) | |||
302 | struct pci_device_id *id; | 303 | struct pci_device_id *id; |
303 | pdev = NULL; | 304 | pdev = NULL; |
304 | for(id = amd76xrom_pci_tbl; id->vendor; id++) { | 305 | for(id = amd76xrom_pci_tbl; id->vendor; id++) { |
305 | pdev = pci_find_device(id->vendor, id->device, NULL); | 306 | pdev = pci_get_device(id->vendor, id->device, NULL); |
306 | if (pdev) { | 307 | if (pdev) { |
307 | break; | 308 | break; |
308 | } | 309 | } |
diff --git a/drivers/mtd/maps/arctic-mtd.c b/drivers/mtd/maps/arctic-mtd.c index d95ae582fbe9..642d96bc8919 100644 --- a/drivers/mtd/maps/arctic-mtd.c +++ b/drivers/mtd/maps/arctic-mtd.c | |||
@@ -96,6 +96,8 @@ static struct mtd_partition arctic_partitions[PARTITIONS] = { | |||
96 | static int __init | 96 | static int __init |
97 | init_arctic_mtd(void) | 97 | init_arctic_mtd(void) |
98 | { | 98 | { |
99 | int err = 0; | ||
100 | |||
99 | printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR); | 101 | printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR); |
100 | 102 | ||
101 | arctic_mtd_map.virt = ioremap(PADDR, SIZE); | 103 | arctic_mtd_map.virt = ioremap(PADDR, SIZE); |
@@ -109,12 +111,20 @@ init_arctic_mtd(void) | |||
109 | printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8); | 111 | printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8); |
110 | arctic_mtd = do_map_probe("cfi_probe", &arctic_mtd_map); | 112 | arctic_mtd = do_map_probe("cfi_probe", &arctic_mtd_map); |
111 | 113 | ||
112 | if (!arctic_mtd) | 114 | if (!arctic_mtd) { |
115 | iounmap((void *) arctic_mtd_map.virt); | ||
113 | return -ENXIO; | 116 | return -ENXIO; |
117 | } | ||
114 | 118 | ||
115 | arctic_mtd->owner = THIS_MODULE; | 119 | arctic_mtd->owner = THIS_MODULE; |
116 | 120 | ||
117 | return add_mtd_partitions(arctic_mtd, arctic_partitions, PARTITIONS); | 121 | err = add_mtd_partitions(arctic_mtd, arctic_partitions, PARTITIONS); |
122 | if (err) { | ||
123 | printk("%s: add_mtd_partitions failed\n", NAME); | ||
124 | iounmap((void *) arctic_mtd_map.virt); | ||
125 | } | ||
126 | |||
127 | return err; | ||
118 | } | 128 | } |
119 | 129 | ||
120 | static void __exit | 130 | static void __exit |
diff --git a/drivers/mtd/maps/beech-mtd.c b/drivers/mtd/maps/beech-mtd.c index 5df7361d1407..a64b1a5ab316 100644 --- a/drivers/mtd/maps/beech-mtd.c +++ b/drivers/mtd/maps/beech-mtd.c | |||
@@ -72,6 +72,8 @@ static struct mtd_partition beech_partitions[2] = { | |||
72 | static int __init | 72 | static int __init |
73 | init_beech_mtd(void) | 73 | init_beech_mtd(void) |
74 | { | 74 | { |
75 | int err = 0; | ||
76 | |||
75 | printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR); | 77 | printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR); |
76 | 78 | ||
77 | beech_mtd_map.virt = ioremap(PADDR, SIZE); | 79 | beech_mtd_map.virt = ioremap(PADDR, SIZE); |
@@ -86,12 +88,20 @@ init_beech_mtd(void) | |||
86 | printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8); | 88 | printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8); |
87 | beech_mtd = do_map_probe("cfi_probe", &beech_mtd_map); | 89 | beech_mtd = do_map_probe("cfi_probe", &beech_mtd_map); |
88 | 90 | ||
89 | if (!beech_mtd) | 91 | if (!beech_mtd) { |
92 | iounmap((void *) beech_mtd_map.virt); | ||
90 | return -ENXIO; | 93 | return -ENXIO; |
94 | } | ||
91 | 95 | ||
92 | beech_mtd->owner = THIS_MODULE; | 96 | beech_mtd->owner = THIS_MODULE; |
93 | 97 | ||
94 | return add_mtd_partitions(beech_mtd, beech_partitions, 2); | 98 | err = add_mtd_partitions(beech_mtd, beech_partitions, 2); |
99 | if (err) { | ||
100 | printk("%s: add_mtd_partitions failed\n", NAME); | ||
101 | iounmap((void *) beech_mtd_map.virt); | ||
102 | } | ||
103 | |||
104 | return err; | ||
95 | } | 105 | } |
96 | 106 | ||
97 | static void __exit | 107 | static void __exit |
diff --git a/drivers/mtd/maps/cstm_mips_ixx.c b/drivers/mtd/maps/cstm_mips_ixx.c index aa56defb94c8..d6bef100d69a 100644 --- a/drivers/mtd/maps/cstm_mips_ixx.c +++ b/drivers/mtd/maps/cstm_mips_ixx.c | |||
@@ -171,7 +171,14 @@ int __init init_cstm_mips_ixx(void) | |||
171 | cstm_mips_ixx_map[i].phys = cstm_mips_ixx_board_desc[i].window_addr; | 171 | cstm_mips_ixx_map[i].phys = cstm_mips_ixx_board_desc[i].window_addr; |
172 | cstm_mips_ixx_map[i].virt = ioremap(cstm_mips_ixx_board_desc[i].window_addr, cstm_mips_ixx_board_desc[i].window_size); | 172 | cstm_mips_ixx_map[i].virt = ioremap(cstm_mips_ixx_board_desc[i].window_addr, cstm_mips_ixx_board_desc[i].window_size); |
173 | if (!cstm_mips_ixx_map[i].virt) { | 173 | if (!cstm_mips_ixx_map[i].virt) { |
174 | int j = 0; | ||
174 | printk(KERN_WARNING "Failed to ioremap\n"); | 175 | printk(KERN_WARNING "Failed to ioremap\n"); |
176 | for (j = 0; j < i; j++) { | ||
177 | if (cstm_mips_ixx_map[j].virt) { | ||
178 | iounmap((void *)cstm_mips_ixx_map[j].virt); | ||
179 | cstm_mips_ixx_map[j].virt = 0; | ||
180 | } | ||
181 | } | ||
175 | return -EIO; | 182 | return -EIO; |
176 | } | 183 | } |
177 | cstm_mips_ixx_map[i].name = cstm_mips_ixx_board_desc[i].name; | 184 | cstm_mips_ixx_map[i].name = cstm_mips_ixx_board_desc[i].name; |
@@ -204,8 +211,15 @@ int __init init_cstm_mips_ixx(void) | |||
204 | cstm_mips_ixx_map[i].map_priv_2 = (unsigned long)mymtd; | 211 | cstm_mips_ixx_map[i].map_priv_2 = (unsigned long)mymtd; |
205 | add_mtd_partitions(mymtd, parts, cstm_mips_ixx_board_desc[i].num_partitions); | 212 | add_mtd_partitions(mymtd, parts, cstm_mips_ixx_board_desc[i].num_partitions); |
206 | } | 213 | } |
207 | else | 214 | else { |
208 | return -ENXIO; | 215 | for (i = 0; i < PHYSMAP_NUMBER; i++) { |
216 | if (cstm_mips_ixx_map[i].virt) { | ||
217 | iounmap((void *)cstm_mips_ixx_map[i].virt); | ||
218 | cstm_mips_ixx_map[i].virt = 0; | ||
219 | } | ||
220 | } | ||
221 | return -ENXIO; | ||
222 | } | ||
209 | } | 223 | } |
210 | return 0; | 224 | return 0; |
211 | } | 225 | } |
diff --git a/drivers/mtd/maps/ebony.c b/drivers/mtd/maps/ebony.c index 641e1dd8479e..1488bb92f26f 100644 --- a/drivers/mtd/maps/ebony.c +++ b/drivers/mtd/maps/ebony.c | |||
@@ -108,6 +108,7 @@ int __init init_ebony(void) | |||
108 | ARRAY_SIZE(ebony_small_partitions)); | 108 | ARRAY_SIZE(ebony_small_partitions)); |
109 | } else { | 109 | } else { |
110 | printk("map probe failed for flash\n"); | 110 | printk("map probe failed for flash\n"); |
111 | iounmap(ebony_small_map.virt); | ||
111 | return -ENXIO; | 112 | return -ENXIO; |
112 | } | 113 | } |
113 | 114 | ||
@@ -117,6 +118,7 @@ int __init init_ebony(void) | |||
117 | 118 | ||
118 | if (!ebony_large_map.virt) { | 119 | if (!ebony_large_map.virt) { |
119 | printk("Failed to ioremap flash\n"); | 120 | printk("Failed to ioremap flash\n"); |
121 | iounmap(ebony_small_map.virt); | ||
120 | return -EIO; | 122 | return -EIO; |
121 | } | 123 | } |
122 | 124 | ||
@@ -129,6 +131,8 @@ int __init init_ebony(void) | |||
129 | ARRAY_SIZE(ebony_large_partitions)); | 131 | ARRAY_SIZE(ebony_large_partitions)); |
130 | } else { | 132 | } else { |
131 | printk("map probe failed for flash\n"); | 133 | printk("map probe failed for flash\n"); |
134 | iounmap(ebony_small_map.virt); | ||
135 | iounmap(ebony_large_map.virt); | ||
132 | return -ENXIO; | 136 | return -ENXIO; |
133 | } | 137 | } |
134 | 138 | ||
diff --git a/drivers/mtd/maps/fortunet.c b/drivers/mtd/maps/fortunet.c index c6bf4e1219ef..7c50c271651c 100644 --- a/drivers/mtd/maps/fortunet.c +++ b/drivers/mtd/maps/fortunet.c | |||
@@ -218,8 +218,11 @@ int __init init_fortunet(void) | |||
218 | map_regions[ix].map_info.size); | 218 | map_regions[ix].map_info.size); |
219 | if(!map_regions[ix].map_info.virt) | 219 | if(!map_regions[ix].map_info.virt) |
220 | { | 220 | { |
221 | int j = 0; | ||
221 | printk(MTD_FORTUNET_PK "%s flash failed to ioremap!\n", | 222 | printk(MTD_FORTUNET_PK "%s flash failed to ioremap!\n", |
222 | map_regions[ix].map_info.name); | 223 | map_regions[ix].map_info.name); |
224 | for (j = 0 ; j < ix; j++) | ||
225 | iounmap(map_regions[j].map_info.virt); | ||
223 | return -ENXIO; | 226 | return -ENXIO; |
224 | } | 227 | } |
225 | simple_map_init(&map_regions[ix].map_info); | 228 | simple_map_init(&map_regions[ix].map_info); |
diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c index db4b570d874a..2bb3e63606e5 100644 --- a/drivers/mtd/maps/ichxrom.c +++ b/drivers/mtd/maps/ichxrom.c | |||
@@ -61,6 +61,7 @@ static void ichxrom_cleanup(struct ichxrom_window *window) | |||
61 | /* Disable writes through the rom window */ | 61 | /* Disable writes through the rom window */ |
62 | pci_read_config_word(window->pdev, BIOS_CNTL, &word); | 62 | pci_read_config_word(window->pdev, BIOS_CNTL, &word); |
63 | pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1); | 63 | pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1); |
64 | pci_dev_put(window->pdev); | ||
64 | 65 | ||
65 | /* Free all of the mtd devices */ | 66 | /* Free all of the mtd devices */ |
66 | list_for_each_entry_safe(map, scratch, &window->maps, list) { | 67 | list_for_each_entry_safe(map, scratch, &window->maps, list) { |
@@ -355,7 +356,7 @@ static int __init init_ichxrom(void) | |||
355 | 356 | ||
356 | pdev = NULL; | 357 | pdev = NULL; |
357 | for (id = ichxrom_pci_tbl; id->vendor; id++) { | 358 | for (id = ichxrom_pci_tbl; id->vendor; id++) { |
358 | pdev = pci_find_device(id->vendor, id->device, NULL); | 359 | pdev = pci_get_device(id->vendor, id->device, NULL); |
359 | if (pdev) { | 360 | if (pdev) { |
360 | break; | 361 | break; |
361 | } | 362 | } |
diff --git a/drivers/mtd/maps/iq80310.c b/drivers/mtd/maps/iq80310.c deleted file mode 100644 index 62d9e87d84e2..000000000000 --- a/drivers/mtd/maps/iq80310.c +++ /dev/null | |||
@@ -1,118 +0,0 @@ | |||
1 | /* | ||
2 | * $Id: iq80310.c,v 1.21 2005/11/07 11:14:27 gleixner Exp $ | ||
3 | * | ||
4 | * Mapping for the Intel XScale IQ80310 evaluation board | ||
5 | * | ||
6 | * Author: Nicolas Pitre | ||
7 | * Copyright: (C) 2001 MontaVista Software Inc. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/types.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <asm/io.h> | ||
20 | #include <linux/mtd/mtd.h> | ||
21 | #include <linux/mtd/map.h> | ||
22 | #include <linux/mtd/partitions.h> | ||
23 | |||
24 | |||
25 | #define WINDOW_ADDR 0 | ||
26 | #define WINDOW_SIZE 8*1024*1024 | ||
27 | #define BUSWIDTH 1 | ||
28 | |||
29 | static struct mtd_info *mymtd; | ||
30 | |||
31 | static struct map_info iq80310_map = { | ||
32 | .name = "IQ80310 flash", | ||
33 | .size = WINDOW_SIZE, | ||
34 | .bankwidth = BUSWIDTH, | ||
35 | .phys = WINDOW_ADDR | ||
36 | }; | ||
37 | |||
38 | static struct mtd_partition iq80310_partitions[4] = { | ||
39 | { | ||
40 | .name = "Firmware", | ||
41 | .size = 0x00080000, | ||
42 | .offset = 0, | ||
43 | .mask_flags = MTD_WRITEABLE /* force read-only */ | ||
44 | },{ | ||
45 | .name = "Kernel", | ||
46 | .size = 0x000a0000, | ||
47 | .offset = 0x00080000, | ||
48 | },{ | ||
49 | .name = "Filesystem", | ||
50 | .size = 0x00600000, | ||
51 | .offset = 0x00120000 | ||
52 | },{ | ||
53 | .name = "RedBoot", | ||
54 | .size = 0x000e0000, | ||
55 | .offset = 0x00720000, | ||
56 | .mask_flags = MTD_WRITEABLE | ||
57 | } | ||
58 | }; | ||
59 | |||
60 | static struct mtd_info *mymtd; | ||
61 | static struct mtd_partition *parsed_parts; | ||
62 | static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; | ||
63 | |||
64 | static int __init init_iq80310(void) | ||
65 | { | ||
66 | struct mtd_partition *parts; | ||
67 | int nb_parts = 0; | ||
68 | int parsed_nr_parts = 0; | ||
69 | int ret; | ||
70 | |||
71 | iq80310_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); | ||
72 | if (!iq80310_map.virt) { | ||
73 | printk("Failed to ioremap\n"); | ||
74 | return -EIO; | ||
75 | } | ||
76 | simple_map_init(&iq80310_map); | ||
77 | |||
78 | mymtd = do_map_probe("cfi_probe", &iq80310_map); | ||
79 | if (!mymtd) { | ||
80 | iounmap((void *)iq80310_map.virt); | ||
81 | return -ENXIO; | ||
82 | } | ||
83 | mymtd->owner = THIS_MODULE; | ||
84 | |||
85 | ret = parse_mtd_partitions(mymtd, probes, &parsed_parts, 0); | ||
86 | |||
87 | if (ret > 0) | ||
88 | parsed_nr_parts = ret; | ||
89 | |||
90 | if (parsed_nr_parts > 0) { | ||
91 | parts = parsed_parts; | ||
92 | nb_parts = parsed_nr_parts; | ||
93 | } else { | ||
94 | parts = iq80310_partitions; | ||
95 | nb_parts = ARRAY_SIZE(iq80310_partitions); | ||
96 | } | ||
97 | add_mtd_partitions(mymtd, parts, nb_parts); | ||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | static void __exit cleanup_iq80310(void) | ||
102 | { | ||
103 | if (mymtd) { | ||
104 | del_mtd_partitions(mymtd); | ||
105 | map_destroy(mymtd); | ||
106 | kfree(parsed_parts); | ||
107 | } | ||
108 | if (iq80310_map.virt) | ||
109 | iounmap((void *)iq80310_map.virt); | ||
110 | } | ||
111 | |||
112 | module_init(init_iq80310); | ||
113 | module_exit(cleanup_iq80310); | ||
114 | |||
115 | |||
116 | MODULE_LICENSE("GPL"); | ||
117 | MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>"); | ||
118 | MODULE_DESCRIPTION("MTD map driver for Intel XScale IQ80310 evaluation board"); | ||
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c index 986c58628390..7a828e3e6446 100644 --- a/drivers/mtd/maps/ixp4xx.c +++ b/drivers/mtd/maps/ixp4xx.c | |||
@@ -253,7 +253,7 @@ static int ixp4xx_flash_probe(struct platform_device *dev) | |||
253 | /* Use the fast version */ | 253 | /* Use the fast version */ |
254 | info->map.write = ixp4xx_write16, | 254 | info->map.write = ixp4xx_write16, |
255 | 255 | ||
256 | err = parse_mtd_partitions(info->mtd, probes, &info->partitions, 0); | 256 | err = parse_mtd_partitions(info->mtd, probes, &info->partitions, dev->resource->start); |
257 | if (err > 0) { | 257 | if (err > 0) { |
258 | err = add_mtd_partitions(info->mtd, info->partitions, err); | 258 | err = add_mtd_partitions(info->mtd, info->partitions, err); |
259 | if(err) | 259 | if(err) |
diff --git a/drivers/mtd/maps/l440gx.c b/drivers/mtd/maps/l440gx.c index 6b784ef5ee70..67620adf4811 100644 --- a/drivers/mtd/maps/l440gx.c +++ b/drivers/mtd/maps/l440gx.c | |||
@@ -61,14 +61,17 @@ static int __init init_l440gx(void) | |||
61 | struct resource *pm_iobase; | 61 | struct resource *pm_iobase; |
62 | __u16 word; | 62 | __u16 word; |
63 | 63 | ||
64 | dev = pci_find_device(PCI_VENDOR_ID_INTEL, | 64 | dev = pci_get_device(PCI_VENDOR_ID_INTEL, |
65 | PCI_DEVICE_ID_INTEL_82371AB_0, NULL); | 65 | PCI_DEVICE_ID_INTEL_82371AB_0, NULL); |
66 | 66 | ||
67 | pm_dev = pci_find_device(PCI_VENDOR_ID_INTEL, | 67 | pm_dev = pci_get_device(PCI_VENDOR_ID_INTEL, |
68 | PCI_DEVICE_ID_INTEL_82371AB_3, NULL); | 68 | PCI_DEVICE_ID_INTEL_82371AB_3, NULL); |
69 | 69 | ||
70 | pci_dev_put(dev); | ||
71 | |||
70 | if (!dev || !pm_dev) { | 72 | if (!dev || !pm_dev) { |
71 | printk(KERN_NOTICE "L440GX flash mapping: failed to find PIIX4 ISA bridge, cannot continue\n"); | 73 | printk(KERN_NOTICE "L440GX flash mapping: failed to find PIIX4 ISA bridge, cannot continue\n"); |
74 | pci_dev_put(pm_dev); | ||
72 | return -ENODEV; | 75 | return -ENODEV; |
73 | } | 76 | } |
74 | 77 | ||
@@ -76,6 +79,7 @@ static int __init init_l440gx(void) | |||
76 | 79 | ||
77 | if (!l440gx_map.virt) { | 80 | if (!l440gx_map.virt) { |
78 | printk(KERN_WARNING "Failed to ioremap L440GX flash region\n"); | 81 | printk(KERN_WARNING "Failed to ioremap L440GX flash region\n"); |
82 | pci_dev_put(pm_dev); | ||
79 | return -ENOMEM; | 83 | return -ENOMEM; |
80 | } | 84 | } |
81 | simple_map_init(&l440gx_map); | 85 | simple_map_init(&l440gx_map); |
@@ -99,8 +103,12 @@ static int __init init_l440gx(void) | |||
99 | pm_iobase->start += iobase & ~1; | 103 | pm_iobase->start += iobase & ~1; |
100 | pm_iobase->end += iobase & ~1; | 104 | pm_iobase->end += iobase & ~1; |
101 | 105 | ||
106 | pci_dev_put(pm_dev); | ||
107 | |||
102 | /* Allocate the resource region */ | 108 | /* Allocate the resource region */ |
103 | if (pci_assign_resource(pm_dev, PIIXE_IOBASE_RESOURCE) != 0) { | 109 | if (pci_assign_resource(pm_dev, PIIXE_IOBASE_RESOURCE) != 0) { |
110 | pci_dev_put(dev); | ||
111 | pci_dev_put(pm_dev); | ||
104 | printk(KERN_WARNING "Could not allocate pm iobase resource\n"); | 112 | printk(KERN_WARNING "Could not allocate pm iobase resource\n"); |
105 | iounmap(l440gx_map.virt); | 113 | iounmap(l440gx_map.virt); |
106 | return -ENXIO; | 114 | return -ENXIO; |
diff --git a/drivers/mtd/maps/lasat.c b/drivers/mtd/maps/lasat.c index 1c13d2dc0cdf..e34376321050 100644 --- a/drivers/mtd/maps/lasat.c +++ b/drivers/mtd/maps/lasat.c | |||
@@ -79,6 +79,7 @@ static int __init init_lasat(void) | |||
79 | return 0; | 79 | return 0; |
80 | } | 80 | } |
81 | 81 | ||
82 | iounmap(lasat_map.virt); | ||
82 | return -ENXIO; | 83 | return -ENXIO; |
83 | } | 84 | } |
84 | 85 | ||
@@ -89,6 +90,7 @@ static void __exit cleanup_lasat(void) | |||
89 | map_destroy(lasat_mtd); | 90 | map_destroy(lasat_mtd); |
90 | } | 91 | } |
91 | if (lasat_map.virt) { | 92 | if (lasat_map.virt) { |
93 | iounmap(lasat_map.virt); | ||
92 | lasat_map.virt = 0; | 94 | lasat_map.virt = 0; |
93 | } | 95 | } |
94 | } | 96 | } |
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c index 0994b5b2e331..198e840ff6db 100644 --- a/drivers/mtd/maps/nettel.c +++ b/drivers/mtd/maps/nettel.c | |||
@@ -277,6 +277,7 @@ int __init nettel_init(void) | |||
277 | nettel_amd_map.virt = ioremap_nocache(amdaddr, maxsize); | 277 | nettel_amd_map.virt = ioremap_nocache(amdaddr, maxsize); |
278 | if (!nettel_amd_map.virt) { | 278 | if (!nettel_amd_map.virt) { |
279 | printk("SNAPGEAR: failed to ioremap() BOOTCS\n"); | 279 | printk("SNAPGEAR: failed to ioremap() BOOTCS\n"); |
280 | iounmap(nettel_mmcrp); | ||
280 | return(-EIO); | 281 | return(-EIO); |
281 | } | 282 | } |
282 | simple_map_init(&nettel_amd_map); | 283 | simple_map_init(&nettel_amd_map); |
@@ -337,7 +338,8 @@ int __init nettel_init(void) | |||
337 | nettel_amd_map.virt = NULL; | 338 | nettel_amd_map.virt = NULL; |
338 | #else | 339 | #else |
339 | /* Only AMD flash supported */ | 340 | /* Only AMD flash supported */ |
340 | return(-ENXIO); | 341 | rc = -ENXIO; |
342 | goto out_unmap2; | ||
341 | #endif | 343 | #endif |
342 | } | 344 | } |
343 | 345 | ||
@@ -361,14 +363,15 @@ int __init nettel_init(void) | |||
361 | nettel_intel_map.virt = ioremap_nocache(intel0addr, maxsize); | 363 | nettel_intel_map.virt = ioremap_nocache(intel0addr, maxsize); |
362 | if (!nettel_intel_map.virt) { | 364 | if (!nettel_intel_map.virt) { |
363 | printk("SNAPGEAR: failed to ioremap() ROMCS1\n"); | 365 | printk("SNAPGEAR: failed to ioremap() ROMCS1\n"); |
364 | return(-EIO); | 366 | rc = -EIO; |
367 | goto out_unmap2; | ||
365 | } | 368 | } |
366 | simple_map_init(&nettel_intel_map); | 369 | simple_map_init(&nettel_intel_map); |
367 | 370 | ||
368 | intel_mtd = do_map_probe("cfi_probe", &nettel_intel_map); | 371 | intel_mtd = do_map_probe("cfi_probe", &nettel_intel_map); |
369 | if (!intel_mtd) { | 372 | if (!intel_mtd) { |
370 | iounmap(nettel_intel_map.virt); | 373 | rc = -ENXIO; |
371 | return(-ENXIO); | 374 | goto out_unmap1; |
372 | } | 375 | } |
373 | 376 | ||
374 | /* Set PAR to the detected size */ | 377 | /* Set PAR to the detected size */ |
@@ -394,13 +397,14 @@ int __init nettel_init(void) | |||
394 | nettel_intel_map.virt = ioremap_nocache(intel0addr, maxsize); | 397 | nettel_intel_map.virt = ioremap_nocache(intel0addr, maxsize); |
395 | if (!nettel_intel_map.virt) { | 398 | if (!nettel_intel_map.virt) { |
396 | printk("SNAPGEAR: failed to ioremap() ROMCS1/2\n"); | 399 | printk("SNAPGEAR: failed to ioremap() ROMCS1/2\n"); |
397 | return(-EIO); | 400 | rc = -EIO; |
401 | goto out_unmap2; | ||
398 | } | 402 | } |
399 | 403 | ||
400 | intel_mtd = do_map_probe("cfi_probe", &nettel_intel_map); | 404 | intel_mtd = do_map_probe("cfi_probe", &nettel_intel_map); |
401 | if (! intel_mtd) { | 405 | if (! intel_mtd) { |
402 | iounmap((void *) nettel_intel_map.virt); | 406 | rc = -ENXIO; |
403 | return(-ENXIO); | 407 | goto out_unmap1; |
404 | } | 408 | } |
405 | 409 | ||
406 | intel1size = intel_mtd->size - intel0size; | 410 | intel1size = intel_mtd->size - intel0size; |
@@ -456,6 +460,18 @@ int __init nettel_init(void) | |||
456 | #endif | 460 | #endif |
457 | 461 | ||
458 | return(rc); | 462 | return(rc); |
463 | |||
464 | #ifdef CONFIG_MTD_CFI_INTELEXT | ||
465 | out_unmap1: | ||
466 | iounmap((void *) nettel_intel_map.virt); | ||
467 | #endif | ||
468 | |||
469 | out_unmap2: | ||
470 | iounmap(nettel_mmcrp); | ||
471 | iounmap(nettel_amd_map.virt); | ||
472 | |||
473 | return(rc); | ||
474 | |||
459 | } | 475 | } |
460 | 476 | ||
461 | /****************************************************************************/ | 477 | /****************************************************************************/ |
@@ -469,6 +485,10 @@ void __exit nettel_cleanup(void) | |||
469 | del_mtd_partitions(amd_mtd); | 485 | del_mtd_partitions(amd_mtd); |
470 | map_destroy(amd_mtd); | 486 | map_destroy(amd_mtd); |
471 | } | 487 | } |
488 | if (nettel_mmcrp) { | ||
489 | iounmap(nettel_mmcrp); | ||
490 | nettel_mmcrp = NULL; | ||
491 | } | ||
472 | if (nettel_amd_map.virt) { | 492 | if (nettel_amd_map.virt) { |
473 | iounmap(nettel_amd_map.virt); | 493 | iounmap(nettel_amd_map.virt); |
474 | nettel_amd_map.virt = NULL; | 494 | nettel_amd_map.virt = NULL; |
diff --git a/drivers/mtd/maps/ocotea.c b/drivers/mtd/maps/ocotea.c index 2f07602ba940..5522eac8c980 100644 --- a/drivers/mtd/maps/ocotea.c +++ b/drivers/mtd/maps/ocotea.c | |||
@@ -97,6 +97,7 @@ int __init init_ocotea(void) | |||
97 | ARRAY_SIZE(ocotea_small_partitions)); | 97 | ARRAY_SIZE(ocotea_small_partitions)); |
98 | } else { | 98 | } else { |
99 | printk("map probe failed for flash\n"); | 99 | printk("map probe failed for flash\n"); |
100 | iounmap(ocotea_small_map.virt); | ||
100 | return -ENXIO; | 101 | return -ENXIO; |
101 | } | 102 | } |
102 | 103 | ||
@@ -106,6 +107,7 @@ int __init init_ocotea(void) | |||
106 | 107 | ||
107 | if (!ocotea_large_map.virt) { | 108 | if (!ocotea_large_map.virt) { |
108 | printk("Failed to ioremap flash\n"); | 109 | printk("Failed to ioremap flash\n"); |
110 | iounmap(ocotea_small_map.virt); | ||
109 | return -EIO; | 111 | return -EIO; |
110 | } | 112 | } |
111 | 113 | ||
@@ -118,6 +120,8 @@ int __init init_ocotea(void) | |||
118 | ARRAY_SIZE(ocotea_large_partitions)); | 120 | ARRAY_SIZE(ocotea_large_partitions)); |
119 | } else { | 121 | } else { |
120 | printk("map probe failed for flash\n"); | 122 | printk("map probe failed for flash\n"); |
123 | iounmap(ocotea_small_map.virt); | ||
124 | iounmap(ocotea_large_map.virt); | ||
121 | return -ENXIO; | 125 | return -ENXIO; |
122 | } | 126 | } |
123 | 127 | ||
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index c861134cbc48..995347b1beba 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
@@ -602,6 +602,10 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
602 | ret = pcmcia_request_configuration(link, &link->conf); | 602 | ret = pcmcia_request_configuration(link, &link->conf); |
603 | if(ret != CS_SUCCESS) { | 603 | if(ret != CS_SUCCESS) { |
604 | cs_error(link, RequestConfiguration, ret); | 604 | cs_error(link, RequestConfiguration, ret); |
605 | if (dev->win_base) { | ||
606 | iounmap(dev->win_base); | ||
607 | dev->win_base = NULL; | ||
608 | } | ||
605 | return -ENODEV; | 609 | return -ENODEV; |
606 | } | 610 | } |
607 | 611 | ||
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c index 7799a25a7f2a..bc7cc71788bc 100644 --- a/drivers/mtd/maps/physmap.c +++ b/drivers/mtd/maps/physmap.c | |||
@@ -158,9 +158,42 @@ err_out: | |||
158 | return err; | 158 | return err; |
159 | } | 159 | } |
160 | 160 | ||
161 | #ifdef CONFIG_PM | ||
162 | static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state) | ||
163 | { | ||
164 | struct physmap_flash_info *info = platform_get_drvdata(dev); | ||
165 | int ret = 0; | ||
166 | |||
167 | if (info) | ||
168 | ret = info->mtd->suspend(info->mtd); | ||
169 | |||
170 | return ret; | ||
171 | } | ||
172 | |||
173 | static int physmap_flash_resume(struct platform_device *dev) | ||
174 | { | ||
175 | struct physmap_flash_info *info = platform_get_drvdata(dev); | ||
176 | if (info) | ||
177 | info->mtd->resume(info->mtd); | ||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | static void physmap_flash_shutdown(struct platform_device *dev) | ||
182 | { | ||
183 | struct physmap_flash_info *info = platform_get_drvdata(dev); | ||
184 | if (info && info->mtd->suspend(info->mtd) == 0) | ||
185 | info->mtd->resume(info->mtd); | ||
186 | } | ||
187 | #endif | ||
188 | |||
161 | static struct platform_driver physmap_flash_driver = { | 189 | static struct platform_driver physmap_flash_driver = { |
162 | .probe = physmap_flash_probe, | 190 | .probe = physmap_flash_probe, |
163 | .remove = physmap_flash_remove, | 191 | .remove = physmap_flash_remove, |
192 | #ifdef CONFIG_PM | ||
193 | .suspend = physmap_flash_suspend, | ||
194 | .resume = physmap_flash_resume, | ||
195 | .shutdown = physmap_flash_shutdown, | ||
196 | #endif | ||
164 | .driver = { | 197 | .driver = { |
165 | .name = "physmap-flash", | 198 | .name = "physmap-flash", |
166 | }, | 199 | }, |
diff --git a/drivers/mtd/maps/redwood.c b/drivers/mtd/maps/redwood.c index ec8fdae1dd99..2257d2b500c0 100644 --- a/drivers/mtd/maps/redwood.c +++ b/drivers/mtd/maps/redwood.c | |||
@@ -126,6 +126,8 @@ static struct mtd_info *redwood_mtd; | |||
126 | 126 | ||
127 | int __init init_redwood_flash(void) | 127 | int __init init_redwood_flash(void) |
128 | { | 128 | { |
129 | int err = 0; | ||
130 | |||
129 | printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n", | 131 | printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n", |
130 | WINDOW_SIZE, WINDOW_ADDR); | 132 | WINDOW_SIZE, WINDOW_ADDR); |
131 | 133 | ||
@@ -141,11 +143,18 @@ int __init init_redwood_flash(void) | |||
141 | 143 | ||
142 | if (redwood_mtd) { | 144 | if (redwood_mtd) { |
143 | redwood_mtd->owner = THIS_MODULE; | 145 | redwood_mtd->owner = THIS_MODULE; |
144 | return add_mtd_partitions(redwood_mtd, | 146 | err = add_mtd_partitions(redwood_mtd, |
145 | redwood_flash_partitions, | 147 | redwood_flash_partitions, |
146 | NUM_REDWOOD_FLASH_PARTITIONS); | 148 | NUM_REDWOOD_FLASH_PARTITIONS); |
149 | if (err) { | ||
150 | printk("init_redwood_flash: add_mtd_partitions failed\n"); | ||
151 | iounmap(redwood_flash_map.virt); | ||
152 | } | ||
153 | return err; | ||
154 | |||
147 | } | 155 | } |
148 | 156 | ||
157 | iounmap(redwood_flash_map.virt); | ||
149 | return -ENXIO; | 158 | return -ENXIO; |
150 | } | 159 | } |
151 | 160 | ||
diff --git a/drivers/mtd/maps/sbc8240.c b/drivers/mtd/maps/sbc8240.c index 7d0fcf8f4f33..b8c1331b7a04 100644 --- a/drivers/mtd/maps/sbc8240.c +++ b/drivers/mtd/maps/sbc8240.c | |||
@@ -156,7 +156,7 @@ int __init init_sbc8240_mtd (void) | |||
156 | }; | 156 | }; |
157 | 157 | ||
158 | int devicesfound = 0; | 158 | int devicesfound = 0; |
159 | int i; | 159 | int i,j; |
160 | 160 | ||
161 | for (i = 0; i < NUM_FLASH_BANKS; i++) { | 161 | for (i = 0; i < NUM_FLASH_BANKS; i++) { |
162 | printk (KERN_NOTICE MSG_PREFIX | 162 | printk (KERN_NOTICE MSG_PREFIX |
@@ -166,6 +166,10 @@ int __init init_sbc8240_mtd (void) | |||
166 | (unsigned long) ioremap (pt[i].addr, pt[i].size); | 166 | (unsigned long) ioremap (pt[i].addr, pt[i].size); |
167 | if (!sbc8240_map[i].map_priv_1) { | 167 | if (!sbc8240_map[i].map_priv_1) { |
168 | printk (MSG_PREFIX "failed to ioremap\n"); | 168 | printk (MSG_PREFIX "failed to ioremap\n"); |
169 | for (j = 0; j < i; j++) { | ||
170 | iounmap((void *) sbc8240_map[j].map_priv_1); | ||
171 | sbc8240_map[j].map_priv_1 = 0; | ||
172 | } | ||
169 | return -EIO; | 173 | return -EIO; |
170 | } | 174 | } |
171 | simple_map_init(&sbc8240_mtd[i]); | 175 | simple_map_init(&sbc8240_mtd[i]); |
@@ -175,6 +179,11 @@ int __init init_sbc8240_mtd (void) | |||
175 | if (sbc8240_mtd[i]) { | 179 | if (sbc8240_mtd[i]) { |
176 | sbc8240_mtd[i]->module = THIS_MODULE; | 180 | sbc8240_mtd[i]->module = THIS_MODULE; |
177 | devicesfound++; | 181 | devicesfound++; |
182 | } else { | ||
183 | if (sbc8240_map[i].map_priv_1) { | ||
184 | iounmap((void *) sbc8240_map[i].map_priv_1); | ||
185 | sbc8240_map[i].map_priv_1 = 0; | ||
186 | } | ||
178 | } | 187 | } |
179 | } | 188 | } |
180 | 189 | ||
diff --git a/drivers/mtd/maps/scx200_docflash.c b/drivers/mtd/maps/scx200_docflash.c index 7391fd544e86..5e2bce22f37c 100644 --- a/drivers/mtd/maps/scx200_docflash.c +++ b/drivers/mtd/maps/scx200_docflash.c | |||
@@ -87,19 +87,23 @@ static int __init init_scx200_docflash(void) | |||
87 | 87 | ||
88 | printk(KERN_DEBUG NAME ": NatSemi SCx200 DOCCS Flash Driver\n"); | 88 | printk(KERN_DEBUG NAME ": NatSemi SCx200 DOCCS Flash Driver\n"); |
89 | 89 | ||
90 | if ((bridge = pci_find_device(PCI_VENDOR_ID_NS, | 90 | if ((bridge = pci_get_device(PCI_VENDOR_ID_NS, |
91 | PCI_DEVICE_ID_NS_SCx200_BRIDGE, | 91 | PCI_DEVICE_ID_NS_SCx200_BRIDGE, |
92 | NULL)) == NULL) | 92 | NULL)) == NULL) |
93 | return -ENODEV; | 93 | return -ENODEV; |
94 | 94 | ||
95 | /* check that we have found the configuration block */ | 95 | /* check that we have found the configuration block */ |
96 | if (!scx200_cb_present()) | 96 | if (!scx200_cb_present()) { |
97 | pci_dev_put(bridge); | ||
97 | return -ENODEV; | 98 | return -ENODEV; |
99 | } | ||
98 | 100 | ||
99 | if (probe) { | 101 | if (probe) { |
100 | /* Try to use the present flash mapping if any */ | 102 | /* Try to use the present flash mapping if any */ |
101 | pci_read_config_dword(bridge, SCx200_DOCCS_BASE, &base); | 103 | pci_read_config_dword(bridge, SCx200_DOCCS_BASE, &base); |
102 | pci_read_config_dword(bridge, SCx200_DOCCS_CTRL, &ctrl); | 104 | pci_read_config_dword(bridge, SCx200_DOCCS_CTRL, &ctrl); |
105 | pci_dev_put(bridge); | ||
106 | |||
103 | pmr = inl(scx200_cb_base + SCx200_PMR); | 107 | pmr = inl(scx200_cb_base + SCx200_PMR); |
104 | 108 | ||
105 | if (base == 0 | 109 | if (base == 0 |
@@ -127,6 +131,7 @@ static int __init init_scx200_docflash(void) | |||
127 | return -ENOMEM; | 131 | return -ENOMEM; |
128 | } | 132 | } |
129 | } else { | 133 | } else { |
134 | pci_dev_put(bridge); | ||
130 | for (u = size; u > 1; u >>= 1) | 135 | for (u = size; u > 1; u >>= 1) |
131 | ; | 136 | ; |
132 | if (u != 1) { | 137 | if (u != 1) { |
diff --git a/drivers/mtd/maps/walnut.c b/drivers/mtd/maps/walnut.c index ec80eec376bf..ca932122fb64 100644 --- a/drivers/mtd/maps/walnut.c +++ b/drivers/mtd/maps/walnut.c | |||
@@ -68,6 +68,7 @@ int __init init_walnut(void) | |||
68 | 68 | ||
69 | if (WALNUT_FLASH_ONBD_N(fpga_brds1)) { | 69 | if (WALNUT_FLASH_ONBD_N(fpga_brds1)) { |
70 | printk("The on-board flash is disabled (U79 sw 5)!"); | 70 | printk("The on-board flash is disabled (U79 sw 5)!"); |
71 | iounmap(fpga_status_adr); | ||
71 | return -EIO; | 72 | return -EIO; |
72 | } | 73 | } |
73 | if (WALNUT_FLASH_SRAM_SEL(fpga_brds1)) | 74 | if (WALNUT_FLASH_SRAM_SEL(fpga_brds1)) |
@@ -81,6 +82,7 @@ int __init init_walnut(void) | |||
81 | 82 | ||
82 | if (!walnut_map.virt) { | 83 | if (!walnut_map.virt) { |
83 | printk("Failed to ioremap flash.\n"); | 84 | printk("Failed to ioremap flash.\n"); |
85 | iounmap(fpga_status_adr); | ||
84 | return -EIO; | 86 | return -EIO; |
85 | } | 87 | } |
86 | 88 | ||
@@ -93,9 +95,11 @@ int __init init_walnut(void) | |||
93 | ARRAY_SIZE(walnut_partitions)); | 95 | ARRAY_SIZE(walnut_partitions)); |
94 | } else { | 96 | } else { |
95 | printk("map probe failed for flash\n"); | 97 | printk("map probe failed for flash\n"); |
98 | iounmap(fpga_status_adr); | ||
96 | return -ENXIO; | 99 | return -ENXIO; |
97 | } | 100 | } |
98 | 101 | ||
102 | iounmap(fpga_status_adr); | ||
99 | return 0; | 103 | return 0; |
100 | } | 104 | } |
101 | 105 | ||
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 168d3ba063c3..c4d26de74349 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -57,6 +57,16 @@ int add_mtd_device(struct mtd_info *mtd) | |||
57 | mtd->index = i; | 57 | mtd->index = i; |
58 | mtd->usecount = 0; | 58 | mtd->usecount = 0; |
59 | 59 | ||
60 | /* Some chips always power up locked. Unlock them now */ | ||
61 | if ((mtd->flags & MTD_WRITEABLE) | ||
62 | && (mtd->flags & MTD_STUPID_LOCK) && mtd->unlock) { | ||
63 | if (mtd->unlock(mtd, 0, mtd->size)) | ||
64 | printk(KERN_WARNING | ||
65 | "%s: unlock failed, " | ||
66 | "writes may not work\n", | ||
67 | mtd->name); | ||
68 | } | ||
69 | |||
60 | DEBUG(0, "mtd: Giving out device %d to %s\n",i, mtd->name); | 70 | DEBUG(0, "mtd: Giving out device %d to %s\n",i, mtd->name); |
61 | /* No need to get a refcount on the module containing | 71 | /* No need to get a refcount on the module containing |
62 | the notifier, since we hold the mtd_table_mutex */ | 72 | the notifier, since we hold the mtd_table_mutex */ |
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c index 31228334da12..09e421a96893 100644 --- a/drivers/mtd/nand/au1550nd.c +++ b/drivers/mtd/nand/au1550nd.c | |||
@@ -21,18 +21,7 @@ | |||
21 | #include <linux/version.h> | 21 | #include <linux/version.h> |
22 | #include <asm/io.h> | 22 | #include <asm/io.h> |
23 | 23 | ||
24 | /* fixme: this is ugly */ | ||
25 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0) | ||
26 | #include <asm/mach-au1x00/au1xxx.h> | 24 | #include <asm/mach-au1x00/au1xxx.h> |
27 | #else | ||
28 | #include <asm/au1000.h> | ||
29 | #ifdef CONFIG_MIPS_PB1550 | ||
30 | #include <asm/pb1550.h> | ||
31 | #endif | ||
32 | #ifdef CONFIG_MIPS_DB1550 | ||
33 | #include <asm/db1x00.h> | ||
34 | #endif | ||
35 | #endif | ||
36 | 25 | ||
37 | /* | 26 | /* |
38 | * MTD structure for NAND controller | 27 | * MTD structure for NAND controller |
diff --git a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c index 516c0e5e564c..12017f3c6bd6 100644 --- a/drivers/mtd/nand/edb7312.c +++ b/drivers/mtd/nand/edb7312.c | |||
@@ -198,6 +198,9 @@ static void __exit ep7312_cleanup(void) | |||
198 | /* Release resources, unregister device */ | 198 | /* Release resources, unregister device */ |
199 | nand_release(ap7312_mtd); | 199 | nand_release(ap7312_mtd); |
200 | 200 | ||
201 | /* Release io resource */ | ||
202 | iounmap((void *)this->IO_ADDR_R); | ||
203 | |||
201 | /* Free the MTD device structure */ | 204 | /* Free the MTD device structure */ |
202 | kfree(ep7312_mtd); | 205 | kfree(ep7312_mtd); |
203 | } | 206 | } |
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c index e5bd88f2d560..039c759cfbfc 100644 --- a/drivers/mtd/nand/ndfc.c +++ b/drivers/mtd/nand/ndfc.c | |||
@@ -168,7 +168,7 @@ static void ndfc_chip_init(struct ndfc_nand_mtd *mtd) | |||
168 | chip->ecc.mode = NAND_ECC_HW; | 168 | chip->ecc.mode = NAND_ECC_HW; |
169 | chip->ecc.size = 256; | 169 | chip->ecc.size = 256; |
170 | chip->ecc.bytes = 3; | 170 | chip->ecc.bytes = 3; |
171 | chip->ecclayout = mtd->pl_chip->ecclayout; | 171 | chip->ecclayout = chip->ecc.layout = mtd->pl_chip->ecclayout; |
172 | mtd->mtd.priv = chip; | 172 | mtd->mtd.priv = chip; |
173 | mtd->mtd.owner = THIS_MODULE; | 173 | mtd->mtd.owner = THIS_MODULE; |
174 | } | 174 | } |
diff --git a/drivers/mtd/nand/ppchameleonevb.c b/drivers/mtd/nand/ppchameleonevb.c index 22fa65c12ab9..eb7d4d443deb 100644 --- a/drivers/mtd/nand/ppchameleonevb.c +++ b/drivers/mtd/nand/ppchameleonevb.c | |||
@@ -276,6 +276,7 @@ static int __init ppchameleonevb_init(void) | |||
276 | /* Scan to find existence of the device (it could not be mounted) */ | 276 | /* Scan to find existence of the device (it could not be mounted) */ |
277 | if (nand_scan(ppchameleon_mtd, 1)) { | 277 | if (nand_scan(ppchameleon_mtd, 1)) { |
278 | iounmap((void *)ppchameleon_fio_base); | 278 | iounmap((void *)ppchameleon_fio_base); |
279 | ppchameleon_fio_base = NULL; | ||
279 | kfree(ppchameleon_mtd); | 280 | kfree(ppchameleon_mtd); |
280 | goto nand_evb_init; | 281 | goto nand_evb_init; |
281 | } | 282 | } |
@@ -314,6 +315,8 @@ static int __init ppchameleonevb_init(void) | |||
314 | ppchameleonevb_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); | 315 | ppchameleonevb_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); |
315 | if (!ppchameleonevb_mtd) { | 316 | if (!ppchameleonevb_mtd) { |
316 | printk("Unable to allocate PPChameleonEVB NAND MTD device structure.\n"); | 317 | printk("Unable to allocate PPChameleonEVB NAND MTD device structure.\n"); |
318 | if (ppchameleon_fio_base) | ||
319 | iounmap(ppchameleon_fio_base); | ||
317 | return -ENOMEM; | 320 | return -ENOMEM; |
318 | } | 321 | } |
319 | 322 | ||
@@ -322,6 +325,8 @@ static int __init ppchameleonevb_init(void) | |||
322 | if (!ppchameleonevb_fio_base) { | 325 | if (!ppchameleonevb_fio_base) { |
323 | printk("ioremap PPChameleonEVB NAND flash failed\n"); | 326 | printk("ioremap PPChameleonEVB NAND flash failed\n"); |
324 | kfree(ppchameleonevb_mtd); | 327 | kfree(ppchameleonevb_mtd); |
328 | if (ppchameleon_fio_base) | ||
329 | iounmap(ppchameleon_fio_base); | ||
325 | return -EIO; | 330 | return -EIO; |
326 | } | 331 | } |
327 | 332 | ||
@@ -378,6 +383,8 @@ static int __init ppchameleonevb_init(void) | |||
378 | if (nand_scan(ppchameleonevb_mtd, 1)) { | 383 | if (nand_scan(ppchameleonevb_mtd, 1)) { |
379 | iounmap((void *)ppchameleonevb_fio_base); | 384 | iounmap((void *)ppchameleonevb_fio_base); |
380 | kfree(ppchameleonevb_mtd); | 385 | kfree(ppchameleonevb_mtd); |
386 | if (ppchameleon_fio_base) | ||
387 | iounmap(ppchameleon_fio_base); | ||
381 | return -ENXIO; | 388 | return -ENXIO; |
382 | } | 389 | } |
383 | #ifdef CONFIG_MTD_PARTITIONS | 390 | #ifdef CONFIG_MTD_PARTITIONS |
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c new file mode 100644 index 000000000000..ddbf015f4119 --- /dev/null +++ b/drivers/mtd/ssfdc.c | |||
@@ -0,0 +1,468 @@ | |||
1 | /* | ||
2 | * Linux driver for SSFDC Flash Translation Layer (Read only) | ||
3 | * (c) 2005 Eptar srl | ||
4 | * Author: Claudio Lanconelli <lanconelli.claudio@eptar.com> | ||
5 | * | ||
6 | * Based on NTFL and MTDBLOCK_RO drivers | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/config.h> | ||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/hdreg.h> | ||
19 | #include <linux/mtd/mtd.h> | ||
20 | #include <linux/mtd/nand.h> | ||
21 | #include <linux/mtd/blktrans.h> | ||
22 | |||
23 | struct ssfdcr_record { | ||
24 | struct mtd_blktrans_dev mbd; | ||
25 | int usecount; | ||
26 | unsigned char heads; | ||
27 | unsigned char sectors; | ||
28 | unsigned short cylinders; | ||
29 | int cis_block; /* block n. containing CIS/IDI */ | ||
30 | int erase_size; /* phys_block_size */ | ||
31 | unsigned short *logic_block_map; /* all zones (max 8192 phys blocks on | ||
32 | the 128MB) */ | ||
33 | int map_len; /* n. phys_blocks on the card */ | ||
34 | }; | ||
35 | |||
36 | #define SSFDCR_MAJOR 257 | ||
37 | #define SSFDCR_PARTN_BITS 3 | ||
38 | |||
39 | #define SECTOR_SIZE 512 | ||
40 | #define SECTOR_SHIFT 9 | ||
41 | #define OOB_SIZE 16 | ||
42 | |||
43 | #define MAX_LOGIC_BLK_PER_ZONE 1000 | ||
44 | #define MAX_PHYS_BLK_PER_ZONE 1024 | ||
45 | |||
46 | #define KB(x) ( (x) * 1024L ) | ||
47 | #define MB(x) ( KB(x) * 1024L ) | ||
48 | |||
49 | /** CHS Table | ||
50 | 1MB 2MB 4MB 8MB 16MB 32MB 64MB 128MB | ||
51 | NCylinder 125 125 250 250 500 500 500 500 | ||
52 | NHead 4 4 4 4 4 8 8 16 | ||
53 | NSector 4 8 8 16 16 16 32 32 | ||
54 | SumSector 2,000 4,000 8,000 16,000 32,000 64,000 128,000 256,000 | ||
55 | SectorSize 512 512 512 512 512 512 512 512 | ||
56 | **/ | ||
57 | |||
58 | typedef struct { | ||
59 | unsigned long size; | ||
60 | unsigned short cyl; | ||
61 | unsigned char head; | ||
62 | unsigned char sec; | ||
63 | } chs_entry_t; | ||
64 | |||
65 | /* Must be ordered by size */ | ||
66 | static const chs_entry_t chs_table[] = { | ||
67 | { MB( 1), 125, 4, 4 }, | ||
68 | { MB( 2), 125, 4, 8 }, | ||
69 | { MB( 4), 250, 4, 8 }, | ||
70 | { MB( 8), 250, 4, 16 }, | ||
71 | { MB( 16), 500, 4, 16 }, | ||
72 | { MB( 32), 500, 8, 16 }, | ||
73 | { MB( 64), 500, 8, 32 }, | ||
74 | { MB(128), 500, 16, 32 }, | ||
75 | { 0 }, | ||
76 | }; | ||
77 | |||
78 | static int get_chs(unsigned long size, unsigned short *cyl, unsigned char *head, | ||
79 | unsigned char *sec) | ||
80 | { | ||
81 | int k; | ||
82 | int found = 0; | ||
83 | |||
84 | k = 0; | ||
85 | while (chs_table[k].size > 0 && size > chs_table[k].size) | ||
86 | k++; | ||
87 | |||
88 | if (chs_table[k].size > 0) { | ||
89 | if (cyl) | ||
90 | *cyl = chs_table[k].cyl; | ||
91 | if (head) | ||
92 | *head = chs_table[k].head; | ||
93 | if (sec) | ||
94 | *sec = chs_table[k].sec; | ||
95 | found = 1; | ||
96 | } | ||
97 | |||
98 | return found; | ||
99 | } | ||
100 | |||
101 | /* These bytes are the signature for the CIS/IDI sector */ | ||
102 | static const uint8_t cis_numbers[] = { | ||
103 | 0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02, 0xDF, 0x01, 0x20 | ||
104 | }; | ||
105 | |||
106 | /* Read and check for a valid CIS sector */ | ||
107 | static int get_valid_cis_sector(struct mtd_info *mtd) | ||
108 | { | ||
109 | int ret, k, cis_sector; | ||
110 | size_t retlen; | ||
111 | loff_t offset; | ||
112 | uint8_t sect_buf[SECTOR_SIZE]; | ||
113 | |||
114 | /* | ||
115 | * Look for CIS/IDI sector on the first GOOD block (give up after 4 bad | ||
116 | * blocks). If the first good block doesn't contain CIS number the flash | ||
117 | * is not SSFDC formatted | ||
118 | */ | ||
119 | cis_sector = -1; | ||
120 | for (k = 0, offset = 0; k < 4; k++, offset += mtd->erasesize) { | ||
121 | if (!mtd->block_isbad(mtd, offset)) { | ||
122 | ret = mtd->read(mtd, offset, SECTOR_SIZE, &retlen, | ||
123 | sect_buf); | ||
124 | |||
125 | /* CIS pattern match on the sector buffer */ | ||
126 | if ( ret < 0 || retlen != SECTOR_SIZE ) { | ||
127 | printk(KERN_WARNING | ||
128 | "SSFDC_RO:can't read CIS/IDI sector\n"); | ||
129 | } else if ( !memcmp(sect_buf, cis_numbers, | ||
130 | sizeof(cis_numbers)) ) { | ||
131 | /* Found */ | ||
132 | cis_sector = (int)(offset >> SECTOR_SHIFT); | ||
133 | } else { | ||
134 | DEBUG(MTD_DEBUG_LEVEL1, | ||
135 | "SSFDC_RO: CIS/IDI sector not found" | ||
136 | " on %s (mtd%d)\n", mtd->name, | ||
137 | mtd->index); | ||
138 | } | ||
139 | break; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | return cis_sector; | ||
144 | } | ||
145 | |||
146 | /* Read physical sector (wrapper to MTD_READ) */ | ||
147 | static int read_physical_sector(struct mtd_info *mtd, uint8_t *sect_buf, | ||
148 | int sect_no) | ||
149 | { | ||
150 | int ret; | ||
151 | size_t retlen; | ||
152 | loff_t offset = (loff_t)sect_no << SECTOR_SHIFT; | ||
153 | |||
154 | ret = mtd->read(mtd, offset, SECTOR_SIZE, &retlen, sect_buf); | ||
155 | if (ret < 0 || retlen != SECTOR_SIZE) | ||
156 | return -1; | ||
157 | |||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | /* Read redundancy area (wrapper to MTD_READ_OOB */ | ||
162 | static int read_raw_oob(struct mtd_info *mtd, loff_t offs, uint8_t *buf) | ||
163 | { | ||
164 | struct mtd_oob_ops ops; | ||
165 | int ret; | ||
166 | |||
167 | ops.mode = MTD_OOB_RAW; | ||
168 | ops.ooboffs = 0; | ||
169 | ops.ooblen = mtd->oobsize; | ||
170 | ops.len = OOB_SIZE; | ||
171 | ops.oobbuf = buf; | ||
172 | ops.datbuf = NULL; | ||
173 | |||
174 | ret = mtd->read_oob(mtd, offs, &ops); | ||
175 | if (ret < 0 || ops.retlen != OOB_SIZE) | ||
176 | return -1; | ||
177 | |||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | /* Parity calculator on a word of n bit size */ | ||
182 | static int get_parity(int number, int size) | ||
183 | { | ||
184 | int k; | ||
185 | int parity; | ||
186 | |||
187 | parity = 1; | ||
188 | for (k = 0; k < size; k++) { | ||
189 | parity += (number >> k); | ||
190 | parity &= 1; | ||
191 | } | ||
192 | return parity; | ||
193 | } | ||
194 | |||
195 | /* Read and validate the logical block address field stored in the OOB */ | ||
196 | static int get_logical_address(uint8_t *oob_buf) | ||
197 | { | ||
198 | int block_address, parity; | ||
199 | int offset[2] = {6, 11}; /* offset of the 2 address fields within OOB */ | ||
200 | int j; | ||
201 | int ok = 0; | ||
202 | |||
203 | /* | ||
204 | * Look for the first valid logical address | ||
205 | * Valid address has fixed pattern on most significant bits and | ||
206 | * parity check | ||
207 | */ | ||
208 | for (j = 0; j < ARRAY_SIZE(offset); j++) { | ||
209 | block_address = ((int)oob_buf[offset[j]] << 8) | | ||
210 | oob_buf[offset[j]+1]; | ||
211 | |||
212 | /* Check for the signature bits in the address field (MSBits) */ | ||
213 | if ((block_address & ~0x7FF) == 0x1000) { | ||
214 | parity = block_address & 0x01; | ||
215 | block_address &= 0x7FF; | ||
216 | block_address >>= 1; | ||
217 | |||
218 | if (get_parity(block_address, 10) != parity) { | ||
219 | DEBUG(MTD_DEBUG_LEVEL0, | ||
220 | "SSFDC_RO: logical address field%d" | ||
221 | "parity error(0x%04X)\n", j+1, | ||
222 | block_address); | ||
223 | } else { | ||
224 | ok = 1; | ||
225 | break; | ||
226 | } | ||
227 | } | ||
228 | } | ||
229 | |||
230 | if ( !ok ) | ||
231 | block_address = -2; | ||
232 | |||
233 | DEBUG(MTD_DEBUG_LEVEL3, "SSFDC_RO: get_logical_address() %d\n", | ||
234 | block_address); | ||
235 | |||
236 | return block_address; | ||
237 | } | ||
238 | |||
239 | /* Build the logic block map */ | ||
240 | static int build_logical_block_map(struct ssfdcr_record *ssfdc) | ||
241 | { | ||
242 | unsigned long offset; | ||
243 | uint8_t oob_buf[OOB_SIZE]; | ||
244 | int ret, block_address, phys_block; | ||
245 | struct mtd_info *mtd = ssfdc->mbd.mtd; | ||
246 | |||
247 | DEBUG(MTD_DEBUG_LEVEL1, "SSFDC_RO: build_block_map() nblks=%d (%luK)\n", | ||
248 | ssfdc->map_len, (unsigned long)ssfdc->map_len * | ||
249 | ssfdc->erase_size / 1024 ); | ||
250 | |||
251 | /* Scan every physical block, skip CIS block */ | ||
252 | for (phys_block = ssfdc->cis_block + 1; phys_block < ssfdc->map_len; | ||
253 | phys_block++) { | ||
254 | offset = (unsigned long)phys_block * ssfdc->erase_size; | ||
255 | if (mtd->block_isbad(mtd, offset)) | ||
256 | continue; /* skip bad blocks */ | ||
257 | |||
258 | ret = read_raw_oob(mtd, offset, oob_buf); | ||
259 | if (ret < 0) { | ||
260 | DEBUG(MTD_DEBUG_LEVEL0, | ||
261 | "SSFDC_RO: mtd read_oob() failed at %lu\n", | ||
262 | offset); | ||
263 | return -1; | ||
264 | } | ||
265 | block_address = get_logical_address(oob_buf); | ||
266 | |||
267 | /* Skip invalid addresses */ | ||
268 | if (block_address >= 0 && | ||
269 | block_address < MAX_LOGIC_BLK_PER_ZONE) { | ||
270 | int zone_index; | ||
271 | |||
272 | zone_index = phys_block / MAX_PHYS_BLK_PER_ZONE; | ||
273 | block_address += zone_index * MAX_LOGIC_BLK_PER_ZONE; | ||
274 | ssfdc->logic_block_map[block_address] = | ||
275 | (unsigned short)phys_block; | ||
276 | |||
277 | DEBUG(MTD_DEBUG_LEVEL2, | ||
278 | "SSFDC_RO: build_block_map() phys_block=%d," | ||
279 | "logic_block_addr=%d, zone=%d\n", | ||
280 | phys_block, block_address, zone_index); | ||
281 | } | ||
282 | } | ||
283 | return 0; | ||
284 | } | ||
285 | |||
286 | static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | ||
287 | { | ||
288 | struct ssfdcr_record *ssfdc; | ||
289 | int cis_sector; | ||
290 | |||
291 | /* Check for small page NAND flash */ | ||
292 | if (mtd->type != MTD_NANDFLASH || mtd->oobsize != OOB_SIZE) | ||
293 | return; | ||
294 | |||
295 | /* Check for SSDFC format by reading CIS/IDI sector */ | ||
296 | cis_sector = get_valid_cis_sector(mtd); | ||
297 | if (cis_sector == -1) | ||
298 | return; | ||
299 | |||
300 | ssfdc = kzalloc(sizeof(struct ssfdcr_record), GFP_KERNEL); | ||
301 | if (!ssfdc) { | ||
302 | printk(KERN_WARNING | ||
303 | "SSFDC_RO: out of memory for data structures\n"); | ||
304 | return; | ||
305 | } | ||
306 | |||
307 | ssfdc->mbd.mtd = mtd; | ||
308 | ssfdc->mbd.devnum = -1; | ||
309 | ssfdc->mbd.blksize = SECTOR_SIZE; | ||
310 | ssfdc->mbd.tr = tr; | ||
311 | ssfdc->mbd.readonly = 1; | ||
312 | |||
313 | ssfdc->cis_block = cis_sector / (mtd->erasesize >> SECTOR_SHIFT); | ||
314 | ssfdc->erase_size = mtd->erasesize; | ||
315 | ssfdc->map_len = mtd->size / mtd->erasesize; | ||
316 | |||
317 | DEBUG(MTD_DEBUG_LEVEL1, | ||
318 | "SSFDC_RO: cis_block=%d,erase_size=%d,map_len=%d,n_zones=%d\n", | ||
319 | ssfdc->cis_block, ssfdc->erase_size, ssfdc->map_len, | ||
320 | (ssfdc->map_len + MAX_PHYS_BLK_PER_ZONE - 1) / | ||
321 | MAX_PHYS_BLK_PER_ZONE); | ||
322 | |||
323 | /* Set geometry */ | ||
324 | ssfdc->heads = 16; | ||
325 | ssfdc->sectors = 32; | ||
326 | get_chs( mtd->size, NULL, &ssfdc->heads, &ssfdc->sectors); | ||
327 | ssfdc->cylinders = (unsigned short)((mtd->size >> SECTOR_SHIFT) / | ||
328 | ((long)ssfdc->sectors * (long)ssfdc->heads)); | ||
329 | |||
330 | DEBUG(MTD_DEBUG_LEVEL1, "SSFDC_RO: using C:%d H:%d S:%d == %ld sects\n", | ||
331 | ssfdc->cylinders, ssfdc->heads , ssfdc->sectors, | ||
332 | (long)ssfdc->cylinders * (long)ssfdc->heads * | ||
333 | (long)ssfdc->sectors ); | ||
334 | |||
335 | ssfdc->mbd.size = (long)ssfdc->heads * (long)ssfdc->cylinders * | ||
336 | (long)ssfdc->sectors; | ||
337 | |||
338 | /* Allocate logical block map */ | ||
339 | ssfdc->logic_block_map = kmalloc( sizeof(ssfdc->logic_block_map[0]) * | ||
340 | ssfdc->map_len, GFP_KERNEL); | ||
341 | if (!ssfdc->logic_block_map) { | ||
342 | printk(KERN_WARNING | ||
343 | "SSFDC_RO: out of memory for data structures\n"); | ||
344 | goto out_err; | ||
345 | } | ||
346 | memset(ssfdc->logic_block_map, 0xff, sizeof(ssfdc->logic_block_map[0]) * | ||
347 | ssfdc->map_len); | ||
348 | |||
349 | /* Build logical block map */ | ||
350 | if (build_logical_block_map(ssfdc) < 0) | ||
351 | goto out_err; | ||
352 | |||
353 | /* Register device + partitions */ | ||
354 | if (add_mtd_blktrans_dev(&ssfdc->mbd)) | ||
355 | goto out_err; | ||
356 | |||
357 | printk(KERN_INFO "SSFDC_RO: Found ssfdc%c on mtd%d (%s)\n", | ||
358 | ssfdc->mbd.devnum + 'a', mtd->index, mtd->name); | ||
359 | return; | ||
360 | |||
361 | out_err: | ||
362 | kfree(ssfdc->logic_block_map); | ||
363 | kfree(ssfdc); | ||
364 | } | ||
365 | |||
366 | static void ssfdcr_remove_dev(struct mtd_blktrans_dev *dev) | ||
367 | { | ||
368 | struct ssfdcr_record *ssfdc = (struct ssfdcr_record *)dev; | ||
369 | |||
370 | DEBUG(MTD_DEBUG_LEVEL1, "SSFDC_RO: remove_dev (i=%d)\n", dev->devnum); | ||
371 | |||
372 | del_mtd_blktrans_dev(dev); | ||
373 | kfree(ssfdc->logic_block_map); | ||
374 | kfree(ssfdc); | ||
375 | } | ||
376 | |||
377 | static int ssfdcr_readsect(struct mtd_blktrans_dev *dev, | ||
378 | unsigned long logic_sect_no, char *buf) | ||
379 | { | ||
380 | struct ssfdcr_record *ssfdc = (struct ssfdcr_record *)dev; | ||
381 | int sectors_per_block, offset, block_address; | ||
382 | |||
383 | sectors_per_block = ssfdc->erase_size >> SECTOR_SHIFT; | ||
384 | offset = (int)(logic_sect_no % sectors_per_block); | ||
385 | block_address = (int)(logic_sect_no / sectors_per_block); | ||
386 | |||
387 | DEBUG(MTD_DEBUG_LEVEL3, | ||
388 | "SSFDC_RO: ssfdcr_readsect(%lu) sec_per_blk=%d, ofst=%d," | ||
389 | " block_addr=%d\n", logic_sect_no, sectors_per_block, offset, | ||
390 | block_address); | ||
391 | |||
392 | if (block_address >= ssfdc->map_len) | ||
393 | BUG(); | ||
394 | |||
395 | block_address = ssfdc->logic_block_map[block_address]; | ||
396 | |||
397 | DEBUG(MTD_DEBUG_LEVEL3, | ||
398 | "SSFDC_RO: ssfdcr_readsect() phys_block_addr=%d\n", | ||
399 | block_address); | ||
400 | |||
401 | if (block_address < 0xffff) { | ||
402 | unsigned long sect_no; | ||
403 | |||
404 | sect_no = (unsigned long)block_address * sectors_per_block + | ||
405 | offset; | ||
406 | |||
407 | DEBUG(MTD_DEBUG_LEVEL3, | ||
408 | "SSFDC_RO: ssfdcr_readsect() phys_sect_no=%lu\n", | ||
409 | sect_no); | ||
410 | |||
411 | if (read_physical_sector( ssfdc->mbd.mtd, buf, sect_no ) < 0) | ||
412 | return -EIO; | ||
413 | } else { | ||
414 | memset(buf, 0xff, SECTOR_SIZE); | ||
415 | } | ||
416 | |||
417 | return 0; | ||
418 | } | ||
419 | |||
420 | static int ssfdcr_getgeo(struct mtd_blktrans_dev *dev, struct hd_geometry *geo) | ||
421 | { | ||
422 | struct ssfdcr_record *ssfdc = (struct ssfdcr_record *)dev; | ||
423 | |||
424 | DEBUG(MTD_DEBUG_LEVEL1, "SSFDC_RO: ssfdcr_getgeo() C=%d, H=%d, S=%d\n", | ||
425 | ssfdc->cylinders, ssfdc->heads, ssfdc->sectors); | ||
426 | |||
427 | geo->heads = ssfdc->heads; | ||
428 | geo->sectors = ssfdc->sectors; | ||
429 | geo->cylinders = ssfdc->cylinders; | ||
430 | |||
431 | return 0; | ||
432 | } | ||
433 | |||
434 | /**************************************************************************** | ||
435 | * | ||
436 | * Module stuff | ||
437 | * | ||
438 | ****************************************************************************/ | ||
439 | |||
440 | static struct mtd_blktrans_ops ssfdcr_tr = { | ||
441 | .name = "ssfdc", | ||
442 | .major = SSFDCR_MAJOR, | ||
443 | .part_bits = SSFDCR_PARTN_BITS, | ||
444 | .getgeo = ssfdcr_getgeo, | ||
445 | .readsect = ssfdcr_readsect, | ||
446 | .add_mtd = ssfdcr_add_mtd, | ||
447 | .remove_dev = ssfdcr_remove_dev, | ||
448 | .owner = THIS_MODULE, | ||
449 | }; | ||
450 | |||
451 | static int __init init_ssfdcr(void) | ||
452 | { | ||
453 | printk(KERN_INFO "SSFDC read-only Flash Translation layer\n"); | ||
454 | |||
455 | return register_mtd_blktrans(&ssfdcr_tr); | ||
456 | } | ||
457 | |||
458 | static void __exit cleanup_ssfdcr(void) | ||
459 | { | ||
460 | deregister_mtd_blktrans(&ssfdcr_tr); | ||
461 | } | ||
462 | |||
463 | module_init(init_ssfdcr); | ||
464 | module_exit(cleanup_ssfdcr); | ||
465 | |||
466 | MODULE_LICENSE("GPL"); | ||
467 | MODULE_AUTHOR("Claudio Lanconelli <lanconelli.claudio@eptar.com>"); | ||
468 | MODULE_DESCRIPTION("Flash Translation Layer for read-only SSFDC SmartMedia card"); | ||
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c index 6fad83f24c4f..711609665632 100644 --- a/drivers/net/bmac.c +++ b/drivers/net/bmac.c | |||
@@ -1264,7 +1264,8 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i | |||
1264 | { | 1264 | { |
1265 | int j, rev, ret; | 1265 | int j, rev, ret; |
1266 | struct bmac_data *bp; | 1266 | struct bmac_data *bp; |
1267 | unsigned char *addr; | 1267 | const unsigned char *prop_addr; |
1268 | unsigned char addr[6]; | ||
1268 | struct net_device *dev; | 1269 | struct net_device *dev; |
1269 | int is_bmac_plus = ((int)match->data) != 0; | 1270 | int is_bmac_plus = ((int)match->data) != 0; |
1270 | 1271 | ||
@@ -1272,14 +1273,16 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i | |||
1272 | printk(KERN_ERR "BMAC: can't use, need 3 addrs and 3 intrs\n"); | 1273 | printk(KERN_ERR "BMAC: can't use, need 3 addrs and 3 intrs\n"); |
1273 | return -ENODEV; | 1274 | return -ENODEV; |
1274 | } | 1275 | } |
1275 | addr = get_property(macio_get_of_node(mdev), "mac-address", NULL); | 1276 | prop_addr = get_property(macio_get_of_node(mdev), "mac-address", NULL); |
1276 | if (addr == NULL) { | 1277 | if (prop_addr == NULL) { |
1277 | addr = get_property(macio_get_of_node(mdev), "local-mac-address", NULL); | 1278 | prop_addr = get_property(macio_get_of_node(mdev), |
1278 | if (addr == NULL) { | 1279 | "local-mac-address", NULL); |
1280 | if (prop_addr == NULL) { | ||
1279 | printk(KERN_ERR "BMAC: Can't get mac-address\n"); | 1281 | printk(KERN_ERR "BMAC: Can't get mac-address\n"); |
1280 | return -ENODEV; | 1282 | return -ENODEV; |
1281 | } | 1283 | } |
1282 | } | 1284 | } |
1285 | memcpy(addr, prop_addr, sizeof(addr)); | ||
1283 | 1286 | ||
1284 | dev = alloc_etherdev(PRIV_BYTES); | 1287 | dev = alloc_etherdev(PRIV_BYTES); |
1285 | if (!dev) { | 1288 | if (!dev) { |
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c index 0464e78f733a..e56eac88b809 100644 --- a/drivers/net/ibmveth.c +++ b/drivers/net/ibmveth.c | |||
@@ -702,7 +702,8 @@ static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
702 | desc[3].desc, | 702 | desc[3].desc, |
703 | desc[4].desc, | 703 | desc[4].desc, |
704 | desc[5].desc, | 704 | desc[5].desc, |
705 | correlator); | 705 | correlator, |
706 | &correlator); | ||
706 | } while ((lpar_rc == H_BUSY) && (retry_count--)); | 707 | } while ((lpar_rc == H_BUSY) && (retry_count--)); |
707 | 708 | ||
708 | if(lpar_rc != H_SUCCESS && lpar_rc != H_DROPPED) { | 709 | if(lpar_rc != H_SUCCESS && lpar_rc != H_DROPPED) { |
diff --git a/drivers/net/ibmveth.h b/drivers/net/ibmveth.h index 8385bf836507..f5b25bff1540 100644 --- a/drivers/net/ibmveth.h +++ b/drivers/net/ibmveth.h | |||
@@ -41,16 +41,6 @@ | |||
41 | #define IbmVethMcastRemoveFilter 0x2UL | 41 | #define IbmVethMcastRemoveFilter 0x2UL |
42 | #define IbmVethMcastClearFilterTable 0x3UL | 42 | #define IbmVethMcastClearFilterTable 0x3UL |
43 | 43 | ||
44 | /* hcall numbers */ | ||
45 | #define H_VIO_SIGNAL 0x104 | ||
46 | #define H_REGISTER_LOGICAL_LAN 0x114 | ||
47 | #define H_FREE_LOGICAL_LAN 0x118 | ||
48 | #define H_ADD_LOGICAL_LAN_BUFFER 0x11C | ||
49 | #define H_SEND_LOGICAL_LAN 0x120 | ||
50 | #define H_MULTICAST_CTRL 0x130 | ||
51 | #define H_CHANGE_LOGICAL_LAN_MAC 0x14C | ||
52 | #define H_FREE_LOGICAL_LAN_BUFFER 0x1D4 | ||
53 | |||
54 | /* hcall macros */ | 44 | /* hcall macros */ |
55 | #define h_register_logical_lan(ua, buflst, rxq, fltlst, mac) \ | 45 | #define h_register_logical_lan(ua, buflst, rxq, fltlst, mac) \ |
56 | plpar_hcall_norets(H_REGISTER_LOGICAL_LAN, ua, buflst, rxq, fltlst, mac) | 46 | plpar_hcall_norets(H_REGISTER_LOGICAL_LAN, ua, buflst, rxq, fltlst, mac) |
@@ -61,8 +51,21 @@ | |||
61 | #define h_add_logical_lan_buffer(ua, buf) \ | 51 | #define h_add_logical_lan_buffer(ua, buf) \ |
62 | plpar_hcall_norets(H_ADD_LOGICAL_LAN_BUFFER, ua, buf) | 52 | plpar_hcall_norets(H_ADD_LOGICAL_LAN_BUFFER, ua, buf) |
63 | 53 | ||
64 | #define h_send_logical_lan(ua, buf1, buf2, buf3, buf4, buf5, buf6, correlator) \ | 54 | static inline long h_send_logical_lan(unsigned long unit_address, |
65 | plpar_hcall_8arg_2ret(H_SEND_LOGICAL_LAN, ua, buf1, buf2, buf3, buf4, buf5, buf6, correlator, &correlator) | 55 | unsigned long desc1, unsigned long desc2, unsigned long desc3, |
56 | unsigned long desc4, unsigned long desc5, unsigned long desc6, | ||
57 | unsigned long corellator_in, unsigned long *corellator_out) | ||
58 | { | ||
59 | long rc; | ||
60 | unsigned long retbuf[PLPAR_HCALL9_BUFSIZE]; | ||
61 | |||
62 | rc = plpar_hcall9(H_SEND_LOGICAL_LAN, retbuf, unit_address, desc1, | ||
63 | desc2, desc3, desc4, desc5, desc6, corellator_in); | ||
64 | |||
65 | *corellator_out = retbuf[0]; | ||
66 | |||
67 | return rc; | ||
68 | } | ||
66 | 69 | ||
67 | #define h_multicast_ctrl(ua, cmd, mac) \ | 70 | #define h_multicast_ctrl(ua, cmd, mac) \ |
68 | plpar_hcall_norets(H_MULTICAST_CTRL, ua, cmd, mac) | 71 | plpar_hcall_norets(H_MULTICAST_CTRL, ua, cmd, mac) |
diff --git a/drivers/net/mace.c b/drivers/net/mace.c index 29e4b5aa6ead..5d80e0e6a8e9 100644 --- a/drivers/net/mace.c +++ b/drivers/net/mace.c | |||
@@ -113,7 +113,7 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i | |||
113 | struct device_node *mace = macio_get_of_node(mdev); | 113 | struct device_node *mace = macio_get_of_node(mdev); |
114 | struct net_device *dev; | 114 | struct net_device *dev; |
115 | struct mace_data *mp; | 115 | struct mace_data *mp; |
116 | unsigned char *addr; | 116 | const unsigned char *addr; |
117 | int j, rev, rc = -EBUSY; | 117 | int j, rev, rc = -EBUSY; |
118 | 118 | ||
119 | if (macio_resource_count(mdev) != 3 || macio_irq_count(mdev) != 3) { | 119 | if (macio_resource_count(mdev) != 3 || macio_irq_count(mdev) != 3) { |
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c index 88907218457a..d64e718afbd2 100644 --- a/drivers/net/spider_net.c +++ b/drivers/net/spider_net.c | |||
@@ -1697,10 +1697,10 @@ spider_net_setup_phy(struct spider_net_card *card) | |||
1697 | */ | 1697 | */ |
1698 | static int | 1698 | static int |
1699 | spider_net_download_firmware(struct spider_net_card *card, | 1699 | spider_net_download_firmware(struct spider_net_card *card, |
1700 | u8 *firmware_ptr) | 1700 | const void *firmware_ptr) |
1701 | { | 1701 | { |
1702 | int sequencer, i; | 1702 | int sequencer, i; |
1703 | u32 *fw_ptr = (u32 *)firmware_ptr; | 1703 | const u32 *fw_ptr = firmware_ptr; |
1704 | 1704 | ||
1705 | /* stop sequencers */ | 1705 | /* stop sequencers */ |
1706 | spider_net_write_reg(card, SPIDER_NET_GSINIT, | 1706 | spider_net_write_reg(card, SPIDER_NET_GSINIT, |
@@ -1757,7 +1757,7 @@ spider_net_init_firmware(struct spider_net_card *card) | |||
1757 | { | 1757 | { |
1758 | struct firmware *firmware = NULL; | 1758 | struct firmware *firmware = NULL; |
1759 | struct device_node *dn; | 1759 | struct device_node *dn; |
1760 | u8 *fw_prop = NULL; | 1760 | const u8 *fw_prop = NULL; |
1761 | int err = -ENOENT; | 1761 | int err = -ENOENT; |
1762 | int fw_size; | 1762 | int fw_size; |
1763 | 1763 | ||
@@ -1783,7 +1783,7 @@ try_host_fw: | |||
1783 | if (!dn) | 1783 | if (!dn) |
1784 | goto out_err; | 1784 | goto out_err; |
1785 | 1785 | ||
1786 | fw_prop = (u8 *)get_property(dn, "firmware", &fw_size); | 1786 | fw_prop = get_property(dn, "firmware", &fw_size); |
1787 | if (!fw_prop) | 1787 | if (!fw_prop) |
1788 | goto out_err; | 1788 | goto out_err; |
1789 | 1789 | ||
@@ -1986,7 +1986,7 @@ spider_net_setup_netdev(struct spider_net_card *card) | |||
1986 | struct net_device *netdev = card->netdev; | 1986 | struct net_device *netdev = card->netdev; |
1987 | struct device_node *dn; | 1987 | struct device_node *dn; |
1988 | struct sockaddr addr; | 1988 | struct sockaddr addr; |
1989 | u8 *mac; | 1989 | const u8 *mac; |
1990 | 1990 | ||
1991 | SET_MODULE_OWNER(netdev); | 1991 | SET_MODULE_OWNER(netdev); |
1992 | SET_NETDEV_DEV(netdev, &card->pdev->dev); | 1992 | SET_NETDEV_DEV(netdev, &card->pdev->dev); |
@@ -2019,7 +2019,7 @@ spider_net_setup_netdev(struct spider_net_card *card) | |||
2019 | if (!dn) | 2019 | if (!dn) |
2020 | return -EIO; | 2020 | return -EIO; |
2021 | 2021 | ||
2022 | mac = (u8 *)get_property(dn, "local-mac-address", NULL); | 2022 | mac = get_property(dn, "local-mac-address", NULL); |
2023 | if (!mac) | 2023 | if (!mac) |
2024 | return -EIO; | 2024 | return -EIO; |
2025 | memcpy(addr.sa_data, mac, ETH_ALEN); | 2025 | memcpy(addr.sa_data, mac, ETH_ALEN); |
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c index b70bbd748978..d7b1d1882cab 100644 --- a/drivers/net/sungem.c +++ b/drivers/net/sungem.c | |||
@@ -2896,7 +2896,7 @@ static int __devinit gem_get_device_address(struct gem *gp) | |||
2896 | if (use_idprom) | 2896 | if (use_idprom) |
2897 | memcpy(dev->dev_addr, idprom->id_ethaddr, 6); | 2897 | memcpy(dev->dev_addr, idprom->id_ethaddr, 6); |
2898 | #elif defined(CONFIG_PPC_PMAC) | 2898 | #elif defined(CONFIG_PPC_PMAC) |
2899 | unsigned char *addr; | 2899 | const unsigned char *addr; |
2900 | 2900 | ||
2901 | addr = get_property(gp->of_node, "local-mac-address", NULL); | 2901 | addr = get_property(gp->of_node, "local-mac-address", NULL); |
2902 | if (addr == NULL) { | 2902 | if (addr == NULL) { |
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index 076bd6dcafae..7288a3eccfb3 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c | |||
@@ -176,16 +176,16 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe | |||
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | 178 | ||
179 | static int get_children_props(struct device_node *dn, int **drc_indexes, | 179 | static int get_children_props(struct device_node *dn, const int **drc_indexes, |
180 | int **drc_names, int **drc_types, int **drc_power_domains) | 180 | const int **drc_names, const int **drc_types, |
181 | const int **drc_power_domains) | ||
181 | { | 182 | { |
182 | int *indexes, *names; | 183 | const int *indexes, *names, *types, *domains; |
183 | int *types, *domains; | ||
184 | 184 | ||
185 | indexes = (int *) get_property(dn, "ibm,drc-indexes", NULL); | 185 | indexes = get_property(dn, "ibm,drc-indexes", NULL); |
186 | names = (int *) get_property(dn, "ibm,drc-names", NULL); | 186 | names = get_property(dn, "ibm,drc-names", NULL); |
187 | types = (int *) get_property(dn, "ibm,drc-types", NULL); | 187 | types = get_property(dn, "ibm,drc-types", NULL); |
188 | domains = (int *) get_property(dn, "ibm,drc-power-domains", NULL); | 188 | domains = get_property(dn, "ibm,drc-power-domains", NULL); |
189 | 189 | ||
190 | if (!indexes || !names || !types || !domains) { | 190 | if (!indexes || !names || !types || !domains) { |
191 | /* Slot does not have dynamically-removable children */ | 191 | /* Slot does not have dynamically-removable children */ |
@@ -212,13 +212,13 @@ static int get_children_props(struct device_node *dn, int **drc_indexes, | |||
212 | int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, | 212 | int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, |
213 | char **drc_name, char **drc_type, int *drc_power_domain) | 213 | char **drc_name, char **drc_type, int *drc_power_domain) |
214 | { | 214 | { |
215 | int *indexes, *names; | 215 | const int *indexes, *names; |
216 | int *types, *domains; | 216 | const int *types, *domains; |
217 | unsigned int *my_index; | 217 | const unsigned int *my_index; |
218 | char *name_tmp, *type_tmp; | 218 | char *name_tmp, *type_tmp; |
219 | int i, rc; | 219 | int i, rc; |
220 | 220 | ||
221 | my_index = (int *) get_property(dn, "ibm,my-drc-index", NULL); | 221 | my_index = get_property(dn, "ibm,my-drc-index", NULL); |
222 | if (!my_index) { | 222 | if (!my_index) { |
223 | /* Node isn't DLPAR/hotplug capable */ | 223 | /* Node isn't DLPAR/hotplug capable */ |
224 | return -EINVAL; | 224 | return -EINVAL; |
@@ -265,10 +265,10 @@ static int is_php_type(char *drc_type) | |||
265 | return 1; | 265 | return 1; |
266 | } | 266 | } |
267 | 267 | ||
268 | static int is_php_dn(struct device_node *dn, int **indexes, int **names, | 268 | static int is_php_dn(struct device_node *dn, const int **indexes, |
269 | int **types, int **power_domains) | 269 | const int **names, const int **types, const int **power_domains) |
270 | { | 270 | { |
271 | int *drc_types; | 271 | const int *drc_types; |
272 | int rc; | 272 | int rc; |
273 | 273 | ||
274 | rc = get_children_props(dn, indexes, names, &drc_types, power_domains); | 274 | rc = get_children_props(dn, indexes, names, &drc_types, power_domains); |
@@ -296,7 +296,7 @@ int rpaphp_add_slot(struct device_node *dn) | |||
296 | struct slot *slot; | 296 | struct slot *slot; |
297 | int retval = 0; | 297 | int retval = 0; |
298 | int i; | 298 | int i; |
299 | int *indexes, *names, *types, *power_domains; | 299 | const int *indexes, *names, *types, *power_domains; |
300 | char *name, *type; | 300 | char *name, *type; |
301 | 301 | ||
302 | dbg("Entry %s: dn->full_name=%s\n", __FUNCTION__, dn->full_name); | 302 | dbg("Entry %s: dn->full_name=%s\n", __FUNCTION__, dn->full_name); |
diff --git a/drivers/scsi/ibmvscsi/rpa_vscsi.c b/drivers/scsi/ibmvscsi/rpa_vscsi.c index ed22b96580c6..01b8ac641eb8 100644 --- a/drivers/scsi/ibmvscsi/rpa_vscsi.c +++ b/drivers/scsi/ibmvscsi/rpa_vscsi.c | |||
@@ -156,8 +156,8 @@ static void gather_partition_info(void) | |||
156 | { | 156 | { |
157 | struct device_node *rootdn; | 157 | struct device_node *rootdn; |
158 | 158 | ||
159 | char *ppartition_name; | 159 | const char *ppartition_name; |
160 | unsigned int *p_number_ptr; | 160 | const unsigned int *p_number_ptr; |
161 | 161 | ||
162 | /* Retrieve information about this partition */ | 162 | /* Retrieve information about this partition */ |
163 | rootdn = find_path_device("/"); | 163 | rootdn = find_path_device("/"); |
@@ -165,14 +165,11 @@ static void gather_partition_info(void) | |||
165 | return; | 165 | return; |
166 | } | 166 | } |
167 | 167 | ||
168 | ppartition_name = | 168 | ppartition_name = get_property(rootdn, "ibm,partition-name", NULL); |
169 | get_property(rootdn, "ibm,partition-name", NULL); | ||
170 | if (ppartition_name) | 169 | if (ppartition_name) |
171 | strncpy(partition_name, ppartition_name, | 170 | strncpy(partition_name, ppartition_name, |
172 | sizeof(partition_name)); | 171 | sizeof(partition_name)); |
173 | p_number_ptr = | 172 | p_number_ptr = get_property(rootdn, "ibm,partition-no", NULL); |
174 | (unsigned int *)get_property(rootdn, "ibm,partition-no", | ||
175 | NULL); | ||
176 | if (p_number_ptr) | 173 | if (p_number_ptr) |
177 | partition_number = *p_number_ptr; | 174 | partition_number = *p_number_ptr; |
178 | } | 175 | } |
diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c index 89ef34df5a1d..6422de72bf43 100644 --- a/drivers/scsi/mac53c94.c +++ b/drivers/scsi/mac53c94.c | |||
@@ -431,7 +431,7 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat | |||
431 | struct fsc_state *state; | 431 | struct fsc_state *state; |
432 | struct Scsi_Host *host; | 432 | struct Scsi_Host *host; |
433 | void *dma_cmd_space; | 433 | void *dma_cmd_space; |
434 | unsigned char *clkprop; | 434 | const unsigned char *clkprop; |
435 | int proplen, rc = -ENODEV; | 435 | int proplen, rc = -ENODEV; |
436 | 436 | ||
437 | if (macio_resource_count(mdev) != 2 || macio_irq_count(mdev) != 2) { | 437 | if (macio_resource_count(mdev) != 2 || macio_irq_count(mdev) != 2) { |
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c index 5572981a9f92..592b52afe658 100644 --- a/drivers/scsi/mesh.c +++ b/drivers/scsi/mesh.c | |||
@@ -1850,7 +1850,8 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match) | |||
1850 | { | 1850 | { |
1851 | struct device_node *mesh = macio_get_of_node(mdev); | 1851 | struct device_node *mesh = macio_get_of_node(mdev); |
1852 | struct pci_dev* pdev = macio_get_pci_dev(mdev); | 1852 | struct pci_dev* pdev = macio_get_pci_dev(mdev); |
1853 | int tgt, *cfp, minper; | 1853 | int tgt, minper; |
1854 | const int *cfp; | ||
1854 | struct mesh_state *ms; | 1855 | struct mesh_state *ms; |
1855 | struct Scsi_Host *mesh_host; | 1856 | struct Scsi_Host *mesh_host; |
1856 | void *dma_cmd_space; | 1857 | void *dma_cmd_space; |
@@ -1939,7 +1940,7 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match) | |||
1939 | ms->tgts[tgt].current_req = NULL; | 1940 | ms->tgts[tgt].current_req = NULL; |
1940 | } | 1941 | } |
1941 | 1942 | ||
1942 | if ((cfp = (int *) get_property(mesh, "clock-frequency", NULL))) | 1943 | if ((cfp = get_property(mesh, "clock-frequency", NULL))) |
1943 | ms->clk_freq = *cfp; | 1944 | ms->clk_freq = *cfp; |
1944 | else { | 1945 | else { |
1945 | printk(KERN_INFO "mesh: assuming 50MHz clock frequency\n"); | 1946 | printk(KERN_INFO "mesh: assuming 50MHz clock frequency\n"); |
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c index 7d0858095e1f..6b70c3c76dfd 100644 --- a/drivers/scsi/sata_svw.c +++ b/drivers/scsi/sata_svw.c | |||
@@ -268,7 +268,7 @@ static int k2_sata_proc_info(struct Scsi_Host *shost, char *page, char **start, | |||
268 | /* Match it to a port node */ | 268 | /* Match it to a port node */ |
269 | index = (ap == ap->host_set->ports[0]) ? 0 : 1; | 269 | index = (ap == ap->host_set->ports[0]) ? 0 : 1; |
270 | for (np = np->child; np != NULL; np = np->sibling) { | 270 | for (np = np->child; np != NULL; np = np->sibling) { |
271 | u32 *reg = (u32 *)get_property(np, "reg", NULL); | 271 | const u32 *reg = get_property(np, "reg", NULL); |
272 | if (!reg) | 272 | if (!reg) |
273 | continue; | 273 | continue; |
274 | if (index == *reg) | 274 | if (index == *reg) |
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c index bfd2a22759eb..a3b99caf80e6 100644 --- a/drivers/serial/pmac_zilog.c +++ b/drivers/serial/pmac_zilog.c | |||
@@ -1400,8 +1400,8 @@ static struct uart_ops pmz_pops = { | |||
1400 | static int __init pmz_init_port(struct uart_pmac_port *uap) | 1400 | static int __init pmz_init_port(struct uart_pmac_port *uap) |
1401 | { | 1401 | { |
1402 | struct device_node *np = uap->node; | 1402 | struct device_node *np = uap->node; |
1403 | char *conn; | 1403 | const char *conn; |
1404 | struct slot_names_prop { | 1404 | const struct slot_names_prop { |
1405 | int count; | 1405 | int count; |
1406 | char name[1]; | 1406 | char name[1]; |
1407 | } *slots; | 1407 | } *slots; |
@@ -1458,7 +1458,7 @@ no_dma: | |||
1458 | uap->flags |= PMACZILOG_FLAG_IS_IRDA; | 1458 | uap->flags |= PMACZILOG_FLAG_IS_IRDA; |
1459 | uap->port_type = PMAC_SCC_ASYNC; | 1459 | uap->port_type = PMAC_SCC_ASYNC; |
1460 | /* 1999 Powerbook G3 has slot-names property instead */ | 1460 | /* 1999 Powerbook G3 has slot-names property instead */ |
1461 | slots = (struct slot_names_prop *)get_property(np, "slot-names", &len); | 1461 | slots = get_property(np, "slot-names", &len); |
1462 | if (slots && slots->count > 0) { | 1462 | if (slots && slots->count > 0) { |
1463 | if (strcmp(slots->name, "IrDA") == 0) | 1463 | if (strcmp(slots->name, "IrDA") == 0) |
1464 | uap->flags |= PMACZILOG_FLAG_IS_IRDA; | 1464 | uap->flags |= PMACZILOG_FLAG_IS_IRDA; |
@@ -1470,7 +1470,8 @@ no_dma: | |||
1470 | if (ZS_IS_INTMODEM(uap)) { | 1470 | if (ZS_IS_INTMODEM(uap)) { |
1471 | struct device_node* i2c_modem = find_devices("i2c-modem"); | 1471 | struct device_node* i2c_modem = find_devices("i2c-modem"); |
1472 | if (i2c_modem) { | 1472 | if (i2c_modem) { |
1473 | char* mid = get_property(i2c_modem, "modem-id", NULL); | 1473 | const char* mid = |
1474 | get_property(i2c_modem, "modem-id", NULL); | ||
1474 | if (mid) switch(*mid) { | 1475 | if (mid) switch(*mid) { |
1475 | case 0x04 : | 1476 | case 0x04 : |
1476 | case 0x05 : | 1477 | case 0x05 : |
diff --git a/drivers/video/S3triofb.c b/drivers/video/S3triofb.c index afd146f5f683..397005eb392d 100644 --- a/drivers/video/S3triofb.c +++ b/drivers/video/S3triofb.c | |||
@@ -349,30 +349,30 @@ static void __init s3triofb_of_init(struct device_node *dp) | |||
349 | s3trio_name[sizeof(s3trio_name)-1] = '\0'; | 349 | s3trio_name[sizeof(s3trio_name)-1] = '\0'; |
350 | strcpy(fb_fix.id, s3trio_name); | 350 | strcpy(fb_fix.id, s3trio_name); |
351 | 351 | ||
352 | if((pp = (int *)get_property(dp, "vendor-id", &len)) != NULL | 352 | if((pp = get_property(dp, "vendor-id", &len)) != NULL |
353 | && *pp!=PCI_VENDOR_ID_S3) { | 353 | && *pp!=PCI_VENDOR_ID_S3) { |
354 | printk("%s: can't find S3 Trio board\n", dp->full_name); | 354 | printk("%s: can't find S3 Trio board\n", dp->full_name); |
355 | return; | 355 | return; |
356 | } | 356 | } |
357 | 357 | ||
358 | if((pp = (int *)get_property(dp, "device-id", &len)) != NULL | 358 | if((pp = get_property(dp, "device-id", &len)) != NULL |
359 | && *pp!=PCI_DEVICE_ID_S3_TRIO) { | 359 | && *pp!=PCI_DEVICE_ID_S3_TRIO) { |
360 | printk("%s: can't find S3 Trio board\n", dp->full_name); | 360 | printk("%s: can't find S3 Trio board\n", dp->full_name); |
361 | return; | 361 | return; |
362 | } | 362 | } |
363 | 363 | ||
364 | if ((pp = (int *)get_property(dp, "depth", &len)) != NULL | 364 | if ((pp = get_property(dp, "depth", &len)) != NULL |
365 | && len == sizeof(int) && *pp != 8) { | 365 | && len == sizeof(int) && *pp != 8) { |
366 | printk("%s: can't use depth = %d\n", dp->full_name, *pp); | 366 | printk("%s: can't use depth = %d\n", dp->full_name, *pp); |
367 | return; | 367 | return; |
368 | } | 368 | } |
369 | if ((pp = (int *)get_property(dp, "width", &len)) != NULL | 369 | if ((pp = get_property(dp, "width", &len)) != NULL |
370 | && len == sizeof(int)) | 370 | && len == sizeof(int)) |
371 | fb_var.xres = fb_var.xres_virtual = *pp; | 371 | fb_var.xres = fb_var.xres_virtual = *pp; |
372 | if ((pp = (int *)get_property(dp, "height", &len)) != NULL | 372 | if ((pp = get_property(dp, "height", &len)) != NULL |
373 | && len == sizeof(int)) | 373 | && len == sizeof(int)) |
374 | fb_var.yres = fb_var.yres_virtual = *pp; | 374 | fb_var.yres = fb_var.yres_virtual = *pp; |
375 | if ((pp = (int *)get_property(dp, "linebytes", &len)) != NULL | 375 | if ((pp = get_property(dp, "linebytes", &len)) != NULL |
376 | && len == sizeof(int)) | 376 | && len == sizeof(int)) |
377 | fb_fix.line_length = *pp; | 377 | fb_fix.line_length = *pp; |
378 | else | 378 | else |
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c index 8e3400d5dd21..0ed577e7cc21 100644 --- a/drivers/video/aty/radeon_base.c +++ b/drivers/video/aty/radeon_base.c | |||
@@ -413,11 +413,11 @@ static int __devinit radeon_find_mem_vbios(struct radeonfb_info *rinfo) | |||
413 | static int __devinit radeon_read_xtal_OF (struct radeonfb_info *rinfo) | 413 | static int __devinit radeon_read_xtal_OF (struct radeonfb_info *rinfo) |
414 | { | 414 | { |
415 | struct device_node *dp = rinfo->of_node; | 415 | struct device_node *dp = rinfo->of_node; |
416 | u32 *val; | 416 | const u32 *val; |
417 | 417 | ||
418 | if (dp == NULL) | 418 | if (dp == NULL) |
419 | return -ENODEV; | 419 | return -ENODEV; |
420 | val = (u32 *) get_property(dp, "ATY,RefCLK", NULL); | 420 | val = get_property(dp, "ATY,RefCLK", NULL); |
421 | if (!val || !*val) { | 421 | if (!val || !*val) { |
422 | printk(KERN_WARNING "radeonfb: No ATY,RefCLK property !\n"); | 422 | printk(KERN_WARNING "radeonfb: No ATY,RefCLK property !\n"); |
423 | return -EINVAL; | 423 | return -EINVAL; |
@@ -425,11 +425,11 @@ static int __devinit radeon_read_xtal_OF (struct radeonfb_info *rinfo) | |||
425 | 425 | ||
426 | rinfo->pll.ref_clk = (*val) / 10; | 426 | rinfo->pll.ref_clk = (*val) / 10; |
427 | 427 | ||
428 | val = (u32 *) get_property(dp, "ATY,SCLK", NULL); | 428 | val = get_property(dp, "ATY,SCLK", NULL); |
429 | if (val && *val) | 429 | if (val && *val) |
430 | rinfo->pll.sclk = (*val) / 10; | 430 | rinfo->pll.sclk = (*val) / 10; |
431 | 431 | ||
432 | val = (u32 *) get_property(dp, "ATY,MCLK", NULL); | 432 | val = get_property(dp, "ATY,MCLK", NULL); |
433 | if (val && *val) | 433 | if (val && *val) |
434 | rinfo->pll.mclk = (*val) / 10; | 434 | rinfo->pll.mclk = (*val) / 10; |
435 | 435 | ||
diff --git a/drivers/video/aty/radeon_monitor.c b/drivers/video/aty/radeon_monitor.c index 98c05bc0de44..ea531a6f45d1 100644 --- a/drivers/video/aty/radeon_monitor.c +++ b/drivers/video/aty/radeon_monitor.c | |||
@@ -64,13 +64,13 @@ static int __devinit radeon_parse_montype_prop(struct device_node *dp, u8 **out_ | |||
64 | { | 64 | { |
65 | static char *propnames[] = { "DFP,EDID", "LCD,EDID", "EDID", | 65 | static char *propnames[] = { "DFP,EDID", "LCD,EDID", "EDID", |
66 | "EDID1", "EDID2", NULL }; | 66 | "EDID1", "EDID2", NULL }; |
67 | u8 *pedid = NULL; | 67 | const u8 *pedid = NULL; |
68 | u8 *pmt = NULL; | 68 | const u8 *pmt = NULL; |
69 | u8 *tmp; | 69 | u8 *tmp; |
70 | int i, mt = MT_NONE; | 70 | int i, mt = MT_NONE; |
71 | 71 | ||
72 | RTRACE("analyzing OF properties...\n"); | 72 | RTRACE("analyzing OF properties...\n"); |
73 | pmt = (u8 *)get_property(dp, "display-type", NULL); | 73 | pmt = get_property(dp, "display-type", NULL); |
74 | if (!pmt) | 74 | if (!pmt) |
75 | return MT_NONE; | 75 | return MT_NONE; |
76 | RTRACE("display-type: %s\n", pmt); | 76 | RTRACE("display-type: %s\n", pmt); |
@@ -89,7 +89,7 @@ static int __devinit radeon_parse_montype_prop(struct device_node *dp, u8 **out_ | |||
89 | } | 89 | } |
90 | 90 | ||
91 | for (i = 0; propnames[i] != NULL; ++i) { | 91 | for (i = 0; propnames[i] != NULL; ++i) { |
92 | pedid = (u8 *)get_property(dp, propnames[i], NULL); | 92 | pedid = get_property(dp, propnames[i], NULL); |
93 | if (pedid != NULL) | 93 | if (pedid != NULL) |
94 | break; | 94 | break; |
95 | } | 95 | } |
@@ -124,14 +124,14 @@ static int __devinit radeon_probe_OF_head(struct radeonfb_info *rinfo, int head_ | |||
124 | return MT_NONE; | 124 | return MT_NONE; |
125 | 125 | ||
126 | if (rinfo->has_CRTC2) { | 126 | if (rinfo->has_CRTC2) { |
127 | char *pname; | 127 | const char *pname; |
128 | int len, second = 0; | 128 | int len, second = 0; |
129 | 129 | ||
130 | dp = dp->child; | 130 | dp = dp->child; |
131 | do { | 131 | do { |
132 | if (!dp) | 132 | if (!dp) |
133 | return MT_NONE; | 133 | return MT_NONE; |
134 | pname = (char *)get_property(dp, "name", NULL); | 134 | pname = get_property(dp, "name", NULL); |
135 | if (!pname) | 135 | if (!pname) |
136 | return MT_NONE; | 136 | return MT_NONE; |
137 | len = strlen(pname); | 137 | len = strlen(pname); |
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c index f31e606a2ded..e308ed2d249a 100644 --- a/drivers/video/aty/radeon_pm.c +++ b/drivers/video/aty/radeon_pm.c | |||
@@ -1268,7 +1268,7 @@ static void radeon_pm_full_reset_sdram(struct radeonfb_info *rinfo) | |||
1268 | 0x21320032, 0xa1320032, 0x21320032, 0xffffffff, | 1268 | 0x21320032, 0xa1320032, 0x21320032, 0xffffffff, |
1269 | 0x31320032 }; | 1269 | 0x31320032 }; |
1270 | 1270 | ||
1271 | u32 *mrtable = default_mrtable; | 1271 | const u32 *mrtable = default_mrtable; |
1272 | int i, mrtable_size = ARRAY_SIZE(default_mrtable); | 1272 | int i, mrtable_size = ARRAY_SIZE(default_mrtable); |
1273 | 1273 | ||
1274 | mdelay(30); | 1274 | mdelay(30); |
@@ -1287,7 +1287,7 @@ static void radeon_pm_full_reset_sdram(struct radeonfb_info *rinfo) | |||
1287 | if (rinfo->of_node != NULL) { | 1287 | if (rinfo->of_node != NULL) { |
1288 | int size; | 1288 | int size; |
1289 | 1289 | ||
1290 | mrtable = (u32 *)get_property(rinfo->of_node, "ATY,MRT", &size); | 1290 | mrtable = get_property(rinfo->of_node, "ATY,MRT", &size); |
1291 | if (mrtable) | 1291 | if (mrtable) |
1292 | mrtable_size = size >> 2; | 1292 | mrtable_size = size >> 2; |
1293 | else | 1293 | else |
diff --git a/drivers/video/nvidia/nv_of.c b/drivers/video/nvidia/nv_of.c index 8209106e26ee..d9af88c2b580 100644 --- a/drivers/video/nvidia/nv_of.c +++ b/drivers/video/nvidia/nv_of.c | |||
@@ -32,7 +32,7 @@ int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid) | |||
32 | { | 32 | { |
33 | struct nvidia_par *par = info->par; | 33 | struct nvidia_par *par = info->par; |
34 | struct device_node *parent, *dp; | 34 | struct device_node *parent, *dp; |
35 | unsigned char *pedid = NULL; | 35 | const unsigned char *pedid = NULL; |
36 | static char *propnames[] = { | 36 | static char *propnames[] = { |
37 | "DFP,EDID", "LCD,EDID", "EDID", "EDID1", | 37 | "DFP,EDID", "LCD,EDID", "EDID", "EDID1", |
38 | "EDID,B", "EDID,A", NULL }; | 38 | "EDID,B", "EDID,A", NULL }; |
@@ -42,20 +42,19 @@ int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid) | |||
42 | if (parent == NULL) | 42 | if (parent == NULL) |
43 | return -1; | 43 | return -1; |
44 | if (par->twoHeads) { | 44 | if (par->twoHeads) { |
45 | char *pname; | 45 | const char *pname; |
46 | int len; | 46 | int len; |
47 | 47 | ||
48 | for (dp = NULL; | 48 | for (dp = NULL; |
49 | (dp = of_get_next_child(parent, dp)) != NULL;) { | 49 | (dp = of_get_next_child(parent, dp)) != NULL;) { |
50 | pname = (char *)get_property(dp, "name", NULL); | 50 | pname = get_property(dp, "name", NULL); |
51 | if (!pname) | 51 | if (!pname) |
52 | continue; | 52 | continue; |
53 | len = strlen(pname); | 53 | len = strlen(pname); |
54 | if ((pname[len-1] == 'A' && conn == 1) || | 54 | if ((pname[len-1] == 'A' && conn == 1) || |
55 | (pname[len-1] == 'B' && conn == 2)) { | 55 | (pname[len-1] == 'B' && conn == 2)) { |
56 | for (i = 0; propnames[i] != NULL; ++i) { | 56 | for (i = 0; propnames[i] != NULL; ++i) { |
57 | pedid = (unsigned char *) | 57 | pedid = get_property(dp, propnames[i], |
58 | get_property(dp, propnames[i], | ||
59 | NULL); | 58 | NULL); |
60 | if (pedid != NULL) | 59 | if (pedid != NULL) |
61 | break; | 60 | break; |
@@ -67,8 +66,7 @@ int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid) | |||
67 | } | 66 | } |
68 | if (pedid == NULL) { | 67 | if (pedid == NULL) { |
69 | for (i = 0; propnames[i] != NULL; ++i) { | 68 | for (i = 0; propnames[i] != NULL; ++i) { |
70 | pedid = (unsigned char *) | 69 | pedid = get_property(parent, propnames[i], NULL); |
71 | get_property(parent, propnames[i], NULL); | ||
72 | if (pedid != NULL) | 70 | if (pedid != NULL) |
73 | break; | 71 | break; |
74 | } | 72 | } |
diff --git a/drivers/video/offb.c b/drivers/video/offb.c index 0013311e0564..bad0e98fb3b6 100644 --- a/drivers/video/offb.c +++ b/drivers/video/offb.c | |||
@@ -409,30 +409,30 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node) | |||
409 | unsigned int flags, rsize, addr_prop = 0; | 409 | unsigned int flags, rsize, addr_prop = 0; |
410 | unsigned long max_size = 0; | 410 | unsigned long max_size = 0; |
411 | u64 rstart, address = OF_BAD_ADDR; | 411 | u64 rstart, address = OF_BAD_ADDR; |
412 | u32 *pp, *addrp, *up; | 412 | const u32 *pp, *addrp, *up; |
413 | u64 asize; | 413 | u64 asize; |
414 | 414 | ||
415 | pp = (u32 *)get_property(dp, "linux,bootx-depth", &len); | 415 | pp = get_property(dp, "linux,bootx-depth", &len); |
416 | if (pp == NULL) | 416 | if (pp == NULL) |
417 | pp = (u32 *)get_property(dp, "depth", &len); | 417 | pp = get_property(dp, "depth", &len); |
418 | if (pp && len == sizeof(u32)) | 418 | if (pp && len == sizeof(u32)) |
419 | depth = *pp; | 419 | depth = *pp; |
420 | 420 | ||
421 | pp = (u32 *)get_property(dp, "linux,bootx-width", &len); | 421 | pp = get_property(dp, "linux,bootx-width", &len); |
422 | if (pp == NULL) | 422 | if (pp == NULL) |
423 | pp = (u32 *)get_property(dp, "width", &len); | 423 | pp = get_property(dp, "width", &len); |
424 | if (pp && len == sizeof(u32)) | 424 | if (pp && len == sizeof(u32)) |
425 | width = *pp; | 425 | width = *pp; |
426 | 426 | ||
427 | pp = (u32 *)get_property(dp, "linux,bootx-height", &len); | 427 | pp = get_property(dp, "linux,bootx-height", &len); |
428 | if (pp == NULL) | 428 | if (pp == NULL) |
429 | pp = (u32 *)get_property(dp, "height", &len); | 429 | pp = get_property(dp, "height", &len); |
430 | if (pp && len == sizeof(u32)) | 430 | if (pp && len == sizeof(u32)) |
431 | height = *pp; | 431 | height = *pp; |
432 | 432 | ||
433 | pp = (u32 *)get_property(dp, "linux,bootx-linebytes", &len); | 433 | pp = get_property(dp, "linux,bootx-linebytes", &len); |
434 | if (pp == NULL) | 434 | if (pp == NULL) |
435 | pp = (u32 *)get_property(dp, "linebytes", &len); | 435 | pp = get_property(dp, "linebytes", &len); |
436 | if (pp && len == sizeof(u32)) | 436 | if (pp && len == sizeof(u32)) |
437 | pitch = *pp; | 437 | pitch = *pp; |
438 | else | 438 | else |
@@ -450,9 +450,9 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node) | |||
450 | * ranges and pick one that is both big enough and if possible encloses | 450 | * ranges and pick one that is both big enough and if possible encloses |
451 | * the "address" property. If none match, we pick the biggest | 451 | * the "address" property. If none match, we pick the biggest |
452 | */ | 452 | */ |
453 | up = (u32 *)get_property(dp, "linux,bootx-addr", &len); | 453 | up = get_property(dp, "linux,bootx-addr", &len); |
454 | if (up == NULL) | 454 | if (up == NULL) |
455 | up = (u32 *)get_property(dp, "address", &len); | 455 | up = get_property(dp, "address", &len); |
456 | if (up && len == sizeof(u32)) | 456 | if (up && len == sizeof(u32)) |
457 | addr_prop = *up; | 457 | addr_prop = *up; |
458 | 458 | ||
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c index 8ddb47a56b07..67d1e1c8813d 100644 --- a/drivers/video/riva/fbdev.c +++ b/drivers/video/riva/fbdev.c | |||
@@ -1835,14 +1835,13 @@ static int __devinit riva_get_EDID_OF(struct fb_info *info, struct pci_dev *pd) | |||
1835 | NVTRACE_ENTER(); | 1835 | NVTRACE_ENTER(); |
1836 | dp = pci_device_to_OF_node(pd); | 1836 | dp = pci_device_to_OF_node(pd); |
1837 | for (; dp != NULL; dp = dp->child) { | 1837 | for (; dp != NULL; dp = dp->child) { |
1838 | disptype = (unsigned char *)get_property(dp, "display-type", NULL); | 1838 | disptype = get_property(dp, "display-type", NULL); |
1839 | if (disptype == NULL) | 1839 | if (disptype == NULL) |
1840 | continue; | 1840 | continue; |
1841 | if (strncmp(disptype, "LCD", 3) != 0) | 1841 | if (strncmp(disptype, "LCD", 3) != 0) |
1842 | continue; | 1842 | continue; |
1843 | for (i = 0; propnames[i] != NULL; ++i) { | 1843 | for (i = 0; propnames[i] != NULL; ++i) { |
1844 | pedid = (unsigned char *) | 1844 | pedid = get_property(dp, propnames[i], NULL); |
1845 | get_property(dp, propnames[i], NULL); | ||
1846 | if (pedid != NULL) { | 1845 | if (pedid != NULL) { |
1847 | par->EDID = pedid; | 1846 | par->EDID = pedid; |
1848 | NVTRACE("LCD found.\n"); | 1847 | NVTRACE("LCD found.\n"); |