cleanup patch
[openwrt.git] / target / linux / aruba-2.6 / patches / 000-aruba.patch
1 diff -Nur linux-2.6.21.1/arch/mips/Kconfig linux-2.6.21.1-owrt/arch/mips/Kconfig
2 --- linux-2.6.21.1/arch/mips/Kconfig 2007-04-27 23:49:26.000000000 +0200
3 +++ linux-2.6.21.1-owrt/arch/mips/Kconfig 2007-05-23 23:34:01.000000000 +0200
4 @@ -220,6 +220,17 @@
5 <http://www.marvell.com/>. Say Y here if you wish to build a
6 kernel for this platform.
7
8 +config MACH_ARUBA
9 + bool "Support for the ARUBA product line"
10 + select DMA_NONCOHERENT
11 + select CPU_HAS_PREFETCH
12 + select HW_HAS_PCI
13 + select SWAP_IO_SPACE
14 + select SYS_SUPPORTS_32BIT_KERNEL
15 + select SYS_HAS_CPU_MIPS32_R1
16 + select SYS_SUPPORTS_BIG_ENDIAN
17 +
18 +
19 config MACH_JAZZ
20 bool "Jazz family of machines"
21 select ARC
22 diff -Nur linux-2.6.21.1/arch/mips/Makefile linux-2.6.21.1-owrt/arch/mips/Makefile
23 --- linux-2.6.21.1/arch/mips/Makefile 2007-04-27 23:49:26.000000000 +0200
24 +++ linux-2.6.21.1-owrt/arch/mips/Makefile 2007-05-23 23:34:01.000000000 +0200
25 @@ -158,6 +158,14 @@
26 #
27
28 #
29 +# Aruba
30 +#
31 +
32 +core-$(CONFIG_MACH_ARUBA) += arch/mips/aruba/
33 +cflags-$(CONFIG_MACH_ARUBA) += -Iinclude/asm-mips/aruba
34 +load-$(CONFIG_MACH_ARUBA) += 0x80100000
35 +
36 +#
37 # Acer PICA 61, Mips Magnum 4000 and Olivetti M700.
38 #
39 core-$(CONFIG_MACH_JAZZ) += arch/mips/jazz/
40 diff -Nur linux-2.6.21.1/arch/mips/pci/Makefile linux-2.6.21.1-owrt/arch/mips/pci/Makefile
41 --- linux-2.6.21.1/arch/mips/pci/Makefile 2007-04-27 23:49:26.000000000 +0200
42 +++ linux-2.6.21.1-owrt/arch/mips/pci/Makefile 2007-05-23 23:36:48.000000000 +0200
43 @@ -53,3 +53,4 @@
44 obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o
45 obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o
46 obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o
47 +obj-$(CONFIG_MACH_ARUBA) += fixup-aruba.o ops-aruba.o pci-aruba.o
48 diff -Nur linux-2.6.21.1/drivers/char/watchdog/Makefile linux-2.6.21.1-owrt/drivers/char/watchdog/Makefile
49 --- linux-2.6.21.1/drivers/char/watchdog/Makefile 2007-04-27 23:49:26.000000000 +0200
50 +++ linux-2.6.21.1-owrt/drivers/char/watchdog/Makefile 2007-05-23 23:36:53.000000000 +0200
51 @@ -82,5 +82,8 @@
52
53 # SPARC64 Architecture
54
55 +# Aruba Architecture
56 +obj-$(CONFIG_MACH_ARUBA) += wdt_merlot.o
57 +
58 # Architecture Independant
59 obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
60 diff -Nur linux-2.6.21.1/drivers/mtd/chips/cfi_probe.c linux-2.6.21.1-owrt/drivers/mtd/chips/cfi_probe.c
61 --- linux-2.6.21.1/drivers/mtd/chips/cfi_probe.c 2007-04-27 23:49:26.000000000 +0200
62 +++ linux-2.6.21.1-owrt/drivers/mtd/chips/cfi_probe.c 2007-05-23 23:36:42.000000000 +0200
63 @@ -25,6 +25,74 @@
64 static void print_cfi_ident(struct cfi_ident *);
65 #endif
66
67 +#if 1
68 +
69 +#define AMD_AUTOSEL_OFF1 0xAAA
70 +#define AMD_AUTOSEL_OFF2 0x555
71 +#define AMD_MANUF_ID 0x1
72 +#define AMD_DEVICE_ID1 0xF6 /* T */
73 +#define AMD_DEVICE_ID2 0xF9 /* B */
74 +/* Foll. are definitions for Macronix Flash Part */
75 +#define MCX_MANUF_ID 0xC2
76 +#define MCX_DEVICE_ID1 0xA7
77 +#define MCX_DEVICE_ID2 0xA8
78 +/* Foll. common to both AMD and Macronix */
79 +#define FACTORY_LOCKED 0x99
80 +#define USER_LOCKED 0x19
81 +
82 +/* NOTE: AP-70/6x use BYTE mode flash access. Therefore the
83 + * lowest Addr. pin in the flash is not A0 but A-1 (A minus 1).
84 + * CPU's A0 is tied to Flash's A-1, A1 to A0 and so on. This
85 + * gives 4MB of byte-addressable mem. In byte mode, all addr
86 + * need to be multiplied by 2 (i.e compared to word mode).
87 + * NOTE: AMD_AUTOSEL_OFF1 and OFF2 are already mult. by 2
88 + * Just blindly use the addr offsets suggested in the manual
89 + * for byte mode and you'll be OK. Offs. in Table 6 need to
90 + * be mult by 2 (for getting autosel params)
91 + */
92 +void
93 +flash_detect(struct map_info *map, __u32 base, struct cfi_private *cfi)
94 +{
95 + map_word val[3];
96 + int osf = cfi->interleave * cfi->device_type; // =2 for AP70/6x
97 + char *manuf, *part, *lock ;
98 +
99 + if (osf != 1) return ;
100 +
101 + cfi_send_gen_cmd(0xAA, AMD_AUTOSEL_OFF1, base, map, cfi, cfi->device_type, NULL);
102 + cfi_send_gen_cmd(0x55, AMD_AUTOSEL_OFF2, base, map, cfi, cfi->device_type, NULL);
103 + cfi_send_gen_cmd(0x90, AMD_AUTOSEL_OFF1, base, map, cfi, cfi->device_type, NULL);
104 + val[0] = map_read(map, base) ; // manuf ID
105 + val[1] = map_read(map, base+2) ; // device ID
106 + val[2] = map_read(map, base+6) ; // lock indicator
107 +#if 0
108 +printk("v1=0x%x v2=0x%x v3=0x%x\n", val[0], val[1], val[2]) ;
109 +#endif
110 + if (val[0].x[0] == AMD_MANUF_ID) {
111 + manuf = "AMD Flash" ;
112 + if (val[1].x[0] == AMD_DEVICE_ID1)
113 + part = "AM29LV320D (Top)" ;
114 + else if (val[1].x[0] == AMD_DEVICE_ID2)
115 + part = "AM29LV320D (Bot)" ;
116 + else part = "Unknown" ;
117 + } else if (val[0].x[0] == MCX_MANUF_ID) {
118 + manuf = "Macronix Flash" ;
119 + if (val[1].x[0] == MCX_DEVICE_ID1)
120 + part = "MX29LV320A (Top)" ;
121 + else if (val[1].x[0] == MCX_DEVICE_ID2)
122 + part = "MX29LV320A (Bot)" ;
123 + else part = "Unknown" ;
124 + } else
125 + return ;
126 + if (val[2].x[0] == FACTORY_LOCKED)
127 + lock = "Factory Locked" ;
128 + else if (val[2].x[0] == USER_LOCKED)
129 + lock = "User Locked" ;
130 + else lock = "Unknown locking" ;
131 + printk("%s %s (%s)\n", manuf, part, lock) ;
132 +}
133 +#endif
134 +
135 static int cfi_probe_chip(struct map_info *map, __u32 base,
136 unsigned long *chip_map, struct cfi_private *cfi);
137 static int cfi_chip_setup(struct map_info *map, struct cfi_private *cfi);
138 @@ -117,6 +185,10 @@
139 }
140
141 xip_disable();
142 +#if 1
143 + //cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
144 + flash_detect(map, base, cfi) ;
145 +#endif
146 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
147 cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
148 cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
149 diff -Nur linux-2.6.21.1/drivers/net/Kconfig linux-2.6.21.1-owrt/drivers/net/Kconfig
150 --- linux-2.6.21.1/drivers/net/Kconfig 2007-04-27 23:49:26.000000000 +0200
151 +++ linux-2.6.21.1-owrt/drivers/net/Kconfig 2007-05-23 23:37:01.000000000 +0200
152 @@ -201,6 +201,19 @@
153
154 source "drivers/net/arm/Kconfig"
155
156 +config AR2313
157 + tristate "AR2313 Ethernet support"
158 + depends on NET_ETHERNET && MACH_ARUBA
159 + help
160 + Support for the AR2313 Ethernet part on Aruba AP60/61
161 +
162 +config IDT_RC32434_ETH
163 + tristate "IDT RC32434 Local Ethernet support"
164 + depends on NET_ETHERNET
165 + help
166 + IDT RC32434 has one local ethernet port. Say Y here to enable it.
167 + To compile this driver as a module, choose M here.
168 +
169 config MACE
170 tristate "MACE (Power Mac ethernet) support"
171 depends on NET_ETHERNET && PPC_PMAC && PPC32
172 diff -Nur linux-2.6.21.1/drivers/net/Makefile linux-2.6.21.1-owrt/drivers/net/Makefile
173 --- linux-2.6.21.1/drivers/net/Makefile 2007-04-27 23:49:26.000000000 +0200
174 +++ linux-2.6.21.1-owrt/drivers/net/Makefile 2007-05-23 23:37:01.000000000 +0200
175 @@ -11,6 +11,7 @@
176 obj-$(CONFIG_BONDING) += bonding/
177 obj-$(CONFIG_ATL1) += atl1/
178 obj-$(CONFIG_GIANFAR) += gianfar_driver.o
179 +obj-$(CONFIG_AR2313) += ar2313/
180
181 gianfar_driver-objs := gianfar.o \
182 gianfar_ethtool.o \
183 @@ -38,6 +39,7 @@
184 obj-$(CONFIG_MACE) += mace.o
185 obj-$(CONFIG_BMAC) += bmac.o
186
187 +obj-$(CONFIG_IDT_RC32434_ETH) += rc32434_eth.o
188 obj-$(CONFIG_DGRS) += dgrs.o
189 obj-$(CONFIG_VORTEX) += 3c59x.o
190 obj-$(CONFIG_TYPHOON) += typhoon.o
191 diff -Nur linux-2.6.21.1/drivers/net/natsemi.c linux-2.6.21.1-owrt/drivers/net/natsemi.c
192 --- linux-2.6.21.1/drivers/net/natsemi.c 2007-04-27 23:49:26.000000000 +0200
193 +++ linux-2.6.21.1-owrt/drivers/net/natsemi.c 2007-05-23 23:34:01.000000000 +0200
194 @@ -656,6 +656,49 @@
195 static int netdev_get_eeprom(struct net_device *dev, u8 *buf);
196 static const struct ethtool_ops ethtool_ops;
197
198 +#ifdef CONFIG_MACH_ARUBA
199 +
200 +#include <linux/ctype.h>
201 +
202 +#ifndef ERR
203 +#define ERR(fmt, args...) printk("%s: " fmt, __func__, ##args)
204 +#endif
205 +
206 +static int parse_mac_addr(struct net_device *dev, char* macstr)
207 +{
208 + int i, j;
209 + unsigned char result, value;
210 +
211 + for (i=0; i<6; i++) {
212 + result = 0;
213 + if (i != 5 && *(macstr+2) != ':') {
214 + ERR("invalid mac address format: %d %c\n",
215 + i, *(macstr+2));
216 + return -EINVAL;
217 + }
218 + for (j=0; j<2; j++) {
219 + if (isxdigit(*macstr) && (value = isdigit(*macstr) ? *macstr-'0' :
220 + toupper(*macstr)-'A'+10) < 16) {
221 + result = result*16 + value;
222 + macstr++;
223 + }
224 + else {
225 + ERR("invalid mac address "
226 + "character: %c\n", *macstr);
227 + return -EINVAL;
228 + }
229 + }
230 +
231 + macstr++;
232 + dev->dev_addr[i] = result;
233 + }
234 +
235 + dev->dev_addr[5]++;
236 + return 0;
237 +}
238 +
239 +#endif
240 +
241 static inline void __iomem *ns_ioaddr(struct net_device *dev)
242 {
243 return (void __iomem *) dev->base_addr;
244 @@ -794,6 +837,7 @@
245 goto err_ioremap;
246 }
247
248 +#ifndef CONFIG_MACH_ARUBA
249 /* Work around the dropped serial bit. */
250 prev_eedata = eeprom_read(ioaddr, 6);
251 for (i = 0; i < 3; i++) {
252 @@ -802,6 +846,19 @@
253 dev->dev_addr[i*2+1] = eedata >> 7;
254 prev_eedata = eedata;
255 }
256 +#else
257 + {
258 + char mac[32];
259 + unsigned char def_mac[6] = {00, 0x0b, 0x86, 0xba, 0xdb, 0xad};
260 + extern char *getenv(char *e);
261 + memset(mac, 0, 32);
262 + memcpy(mac, getenv("ethaddr"), 17);
263 + if (parse_mac_addr(dev, mac)){
264 + printk("%s: MAC address not found\n", __func__);
265 + memcpy(dev->dev_addr, def_mac, 6);
266 + }
267 + }
268 +#endif
269
270 dev->base_addr = (unsigned long __force) ioaddr;
271 dev->irq = irq;
272 diff -Nur linux-2.6.21.1/drivers/pci/access.c linux-2.6.21.1-owrt/drivers/pci/access.c
273 --- linux-2.6.21.1/drivers/pci/access.c 2007-04-27 23:49:26.000000000 +0200
274 +++ linux-2.6.21.1-owrt/drivers/pci/access.c 2007-05-23 23:36:48.000000000 +0200
275 @@ -23,6 +23,7 @@
276 #define PCI_word_BAD (pos & 1)
277 #define PCI_dword_BAD (pos & 3)
278
279 +#ifdef __MIPSEB__
280 #define PCI_OP_READ(size,type,len) \
281 int pci_bus_read_config_##size \
282 (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \
283 @@ -33,11 +34,32 @@
284 if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
285 spin_lock_irqsave(&pci_lock, flags); \
286 res = bus->ops->read(bus, devfn, pos, len, &data); \
287 + if (len == 1) \
288 + *value = (type)((data >> 24) & 0xff); \
289 + else if (len == 2) \
290 + *value = (type)((data >> 16) & 0xffff); \
291 + else \
292 *value = (type)data; \
293 spin_unlock_irqrestore(&pci_lock, flags); \
294 return res; \
295 }
296 +#else
297
298 +#define PCI_OP_READ(size,type,len) \
299 +int pci_bus_read_config_##size \
300 + (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \
301 +{ \
302 + int res; \
303 + unsigned long flags; \
304 + u32 data = 0; \
305 + if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
306 + spin_lock_irqsave(&pci_lock, flags); \
307 + res = bus->ops->read(bus, devfn, pos, len, &data); \
308 + *value = (type)data; \
309 + spin_unlock_irqrestore(&pci_lock, flags); \
310 + return res; \
311 +}
312 +#endif
313 #define PCI_OP_WRITE(size,type,len) \
314 int pci_bus_write_config_##size \
315 (struct pci_bus *bus, unsigned int devfn, int pos, type value) \
316 diff -Nur linux-2.6.21.1/drivers/serial/8250.c linux-2.6.21.1-owrt/drivers/serial/8250.c
317 --- linux-2.6.21.1/drivers/serial/8250.c 2007-04-27 23:49:26.000000000 +0200
318 +++ linux-2.6.21.1-owrt/drivers/serial/8250.c 2007-05-23 23:37:11.000000000 +0200
319 @@ -1635,7 +1635,7 @@
320 {
321 struct uart_8250_port *up = (struct uart_8250_port *)port;
322 unsigned long flags;
323 - unsigned char lsr, iir;
324 +// unsigned char lsr, iir;
325 int retval;
326
327 up->capabilities = uart_config[up->port.type].flags;
328 @@ -1772,6 +1772,8 @@
329
330 serial8250_set_mctrl(&up->port, up->port.mctrl);
331
332 +// For some reason this test causes problems on the AP6x serial console
333 +#if 0
334 /*
335 * Do a quick test to see if we receive an
336 * interrupt when we enable the TX irq.
337 @@ -1790,7 +1792,8 @@
338 } else {
339 up->bugs &= ~UART_BUG_TXEN;
340 }
341 -
342 +#endif
343 +
344 spin_unlock_irqrestore(&up->port.lock, flags);
345
346 /*
347 diff -Nur linux-2.6.21.1/drivers/usb/host/ehci.h linux-2.6.21.1-owrt/drivers/usb/host/ehci.h
348 --- linux-2.6.21.1/drivers/usb/host/ehci.h 2007-04-27 23:49:26.000000000 +0200
349 +++ linux-2.6.21.1-owrt/drivers/usb/host/ehci.h 2007-05-23 23:37:18.000000000 +0200
350 @@ -87,6 +87,7 @@
351 struct dma_pool *sitd_pool; /* sitd per split iso urb */
352
353 struct timer_list watchdog;
354 + struct timer_list softirq;
355 unsigned long actions;
356 unsigned stamp;
357 unsigned long next_statechange;
358 diff -Nur linux-2.6.21.1/drivers/usb/host/ehci-hcd.c linux-2.6.21.1-owrt/drivers/usb/host/ehci-hcd.c
359 --- linux-2.6.21.1/drivers/usb/host/ehci-hcd.c 2007-04-27 23:49:26.000000000 +0200
360 +++ linux-2.6.21.1-owrt/drivers/usb/host/ehci-hcd.c 2007-05-23 23:37:18.000000000 +0200
361 @@ -118,6 +118,7 @@
362 #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */
363 #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */
364 #define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */
365 +#define EHCI_SOFTIRQ (HZ/400)
366
367 /* Initial IRQ latency: faster than hw default */
368 static int log2_irq_thresh = 0; // 0 to 6
369 @@ -273,6 +274,16 @@
370 #include "ehci-sched.c"
371
372 /*-------------------------------------------------------------------------*/
373 +static irqreturn_t ehci_irq (struct usb_hcd *hcd);
374 +
375 +static void ehci_softirq (unsigned long param)
376 +{
377 + struct ehci_hcd *ehci = (struct ehci_hcd *) param;
378 +
379 + if (ehci_irq(ehci_to_hcd(ehci)) != IRQ_NONE)
380 + set_bit(HCD_FLAG_SAW_IRQ, &(ehci_to_hcd(ehci))->flags);
381 + mod_timer (&ehci->softirq, jiffies + EHCI_SOFTIRQ);
382 +}
383
384 static void ehci_watchdog (unsigned long param)
385 {
386 @@ -289,6 +300,10 @@
387 COUNT (ehci->stats.lost_iaa);
388 ehci_writel(ehci, STS_IAA, &ehci->regs->status);
389 ehci->reclaim_ready = 1;
390 + if (!timer_pending(&ehci->softirq)) {
391 + ehci_info(ehci, "switching to softirq\n");
392 + mod_timer (&ehci->softirq, jiffies + EHCI_SOFTIRQ);
393 + }
394 }
395 }
396
397 @@ -396,6 +411,7 @@
398
399 /* no more interrupts ... */
400 del_timer_sync (&ehci->watchdog);
401 + del_timer_sync (&ehci->softirq);
402
403 spin_lock_irq(&ehci->lock);
404 if (HC_IS_RUNNING (hcd->state))
405 @@ -444,6 +460,10 @@
406 ehci->watchdog.function = ehci_watchdog;
407 ehci->watchdog.data = (unsigned long) ehci;
408
409 + init_timer(&ehci->softirq);
410 + ehci->softirq.function = ehci_softirq;
411 + ehci->softirq.data = (unsigned long) ehci;
412 +
413 /*
414 * hw default: 1K periodic list heads, one per frame.
415 * periodic_size can shrink by USBCMD update if hcc_params allows.
416 diff -Nur linux-2.6.21.1/include/asm-mips/bootinfo.h linux-2.6.21.1-owrt/include/asm-mips/bootinfo.h
417 --- linux-2.6.21.1/include/asm-mips/bootinfo.h 2007-04-27 23:49:26.000000000 +0200
418 +++ linux-2.6.21.1-owrt/include/asm-mips/bootinfo.h 2007-05-23 23:34:01.000000000 +0200
419 @@ -213,6 +213,17 @@
420 #define MACH_GROUP_NEC_EMMA2RH 25 /* NEC EMMA2RH (was 23) */
421 #define MACH_NEC_MARKEINS 0 /* NEC EMMA2RH Mark-eins */
422
423 +
424 +/*
425 + * Valid machtype for group ARUBA
426 + */
427 +#define MACH_GROUP_ARUBA 23
428 +#define MACH_ARUBA_UNKNOWN 0
429 +#define MACH_ARUBA_AP60 1
430 +#define MACH_ARUBA_AP65 2
431 +#define MACH_ARUBA_AP70 3
432 +#define MACH_ARUBA_AP40 4
433 +
434 #define CL_SIZE COMMAND_LINE_SIZE
435
436 const char *get_system_type(void);
437 diff -Nur linux-2.6.21.1/include/asm-mips/cpu.h linux-2.6.21.1-owrt/include/asm-mips/cpu.h
438 --- linux-2.6.21.1/include/asm-mips/cpu.h 2007-04-27 23:49:26.000000000 +0200
439 +++ linux-2.6.21.1-owrt/include/asm-mips/cpu.h 2007-05-23 23:34:01.000000000 +0200
440 @@ -54,6 +54,9 @@
441 #define PRID_IMP_R14000 0x0f00
442 #define PRID_IMP_R8000 0x1000
443 #define PRID_IMP_PR4450 0x1200
444 +#define PRID_IMP_RC32334 0x1800
445 +#define PRID_IMP_RC32355 0x1900
446 +#define PRID_IMP_RC32365 0x1900
447 #define PRID_IMP_R4600 0x2000
448 #define PRID_IMP_R4700 0x2100
449 #define PRID_IMP_TX39 0x2200
450 @@ -200,7 +203,8 @@
451 #define CPU_SB1A 62
452 #define CPU_74K 63
453 #define CPU_R14000 64
454 -#define CPU_LAST 64
455 +#define CPU_RC32300 65
456 +#define CPU_LAST 65
457
458 /*
459 * ISA Level encodings
460 diff -Nur linux-2.6.21.1/include/asm-mips/mach-generic/irq.h linux-2.6.21.1-owrt/include/asm-mips/mach-generic/irq.h
461 --- linux-2.6.21.1/include/asm-mips/mach-generic/irq.h 2007-04-27 23:49:26.000000000 +0200
462 +++ linux-2.6.21.1-owrt/include/asm-mips/mach-generic/irq.h 2007-05-23 23:35:55.000000000 +0200
463 @@ -9,7 +9,7 @@
464 #define __ASM_MACH_GENERIC_IRQ_H
465
466 #ifndef NR_IRQS
467 -#define NR_IRQS 128
468 +#define NR_IRQS 256
469 #endif
470
471 #ifdef CONFIG_I8259
472 diff -Nur linux-2.6.21.1/include/linux/kernel.h linux-2.6.21.1-owrt/include/linux/kernel.h
473 --- linux-2.6.21.1/include/linux/kernel.h 2007-04-27 23:49:26.000000000 +0200
474 +++ linux-2.6.21.1-owrt/include/linux/kernel.h 2007-05-23 23:34:01.000000000 +0200
475 @@ -334,6 +334,7 @@
476 };
477
478 /* Force a compilation error if condition is true */
479 +extern void BUILD_BUG(void);
480 #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
481
482 /* Force a compilation error if condition is true, but also produce a
483 diff -Nur linux-2.6.21.1/include/linux/kernel.h.orig linux-2.6.21.1-owrt/include/linux/kernel.h.orig
484 --- linux-2.6.21.1/include/linux/kernel.h.orig 1970-01-01 01:00:00.000000000 +0100
485 +++ linux-2.6.21.1-owrt/include/linux/kernel.h.orig 2007-04-27 23:49:26.000000000 +0200
486 @@ -0,0 +1,355 @@
487 +#ifndef _LINUX_KERNEL_H
488 +#define _LINUX_KERNEL_H
489 +
490 +/*
491 + * 'kernel.h' contains some often-used function prototypes etc
492 + */
493 +
494 +#ifdef __KERNEL__
495 +
496 +#include <stdarg.h>
497 +#include <linux/linkage.h>
498 +#include <linux/stddef.h>
499 +#include <linux/types.h>
500 +#include <linux/compiler.h>
501 +#include <linux/bitops.h>
502 +#include <linux/log2.h>
503 +#include <asm/byteorder.h>
504 +#include <asm/bug.h>
505 +
506 +extern const char linux_banner[];
507 +extern const char linux_proc_banner[];
508 +
509 +#define INT_MAX ((int)(~0U>>1))
510 +#define INT_MIN (-INT_MAX - 1)
511 +#define UINT_MAX (~0U)
512 +#define LONG_MAX ((long)(~0UL>>1))
513 +#define LONG_MIN (-LONG_MAX - 1)
514 +#define ULONG_MAX (~0UL)
515 +#define LLONG_MAX ((long long)(~0ULL>>1))
516 +#define LLONG_MIN (-LLONG_MAX - 1)
517 +#define ULLONG_MAX (~0ULL)
518 +
519 +#define STACK_MAGIC 0xdeadbeef
520 +
521 +#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1)
522 +#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))
523 +
524 +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
525 +#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
526 +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
527 +#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
528 +
529 +#define KERN_EMERG "<0>" /* system is unusable */
530 +#define KERN_ALERT "<1>" /* action must be taken immediately */
531 +#define KERN_CRIT "<2>" /* critical conditions */
532 +#define KERN_ERR "<3>" /* error conditions */
533 +#define KERN_WARNING "<4>" /* warning conditions */
534 +#define KERN_NOTICE "<5>" /* normal but significant condition */
535 +#define KERN_INFO "<6>" /* informational */
536 +#define KERN_DEBUG "<7>" /* debug-level messages */
537 +
538 +extern int console_printk[];
539 +
540 +#define console_loglevel (console_printk[0])
541 +#define default_message_loglevel (console_printk[1])
542 +#define minimum_console_loglevel (console_printk[2])
543 +#define default_console_loglevel (console_printk[3])
544 +
545 +struct completion;
546 +struct pt_regs;
547 +struct user;
548 +
549 +/**
550 + * might_sleep - annotation for functions that can sleep
551 + *
552 + * this macro will print a stack trace if it is executed in an atomic
553 + * context (spinlock, irq-handler, ...).
554 + *
555 + * This is a useful debugging help to be able to catch problems early and not
556 + * be bitten later when the calling function happens to sleep when it is not
557 + * supposed to.
558 + */
559 +#ifdef CONFIG_PREEMPT_VOLUNTARY
560 +extern int cond_resched(void);
561 +# define might_resched() cond_resched()
562 +#else
563 +# define might_resched() do { } while (0)
564 +#endif
565 +
566 +#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
567 + void __might_sleep(char *file, int line);
568 +# define might_sleep() \
569 + do { __might_sleep(__FILE__, __LINE__); might_resched(); } while (0)
570 +#else
571 +# define might_sleep() do { might_resched(); } while (0)
572 +#endif
573 +
574 +#define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
575 +
576 +#define abs(x) ({ \
577 + int __x = (x); \
578 + (__x < 0) ? -__x : __x; \
579 + })
580 +
581 +extern struct atomic_notifier_head panic_notifier_list;
582 +extern long (*panic_blink)(long time);
583 +NORET_TYPE void panic(const char * fmt, ...)
584 + __attribute__ ((NORET_AND format (printf, 1, 2)));
585 +extern void oops_enter(void);
586 +extern void oops_exit(void);
587 +extern int oops_may_print(void);
588 +fastcall NORET_TYPE void do_exit(long error_code)
589 + ATTRIB_NORET;
590 +NORET_TYPE void complete_and_exit(struct completion *, long)
591 + ATTRIB_NORET;
592 +extern unsigned long simple_strtoul(const char *,char **,unsigned int);
593 +extern long simple_strtol(const char *,char **,unsigned int);
594 +extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
595 +extern long long simple_strtoll(const char *,char **,unsigned int);
596 +extern int sprintf(char * buf, const char * fmt, ...)
597 + __attribute__ ((format (printf, 2, 3)));
598 +extern int vsprintf(char *buf, const char *, va_list)
599 + __attribute__ ((format (printf, 2, 0)));
600 +extern int snprintf(char * buf, size_t size, const char * fmt, ...)
601 + __attribute__ ((format (printf, 3, 4)));
602 +extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
603 + __attribute__ ((format (printf, 3, 0)));
604 +extern int scnprintf(char * buf, size_t size, const char * fmt, ...)
605 + __attribute__ ((format (printf, 3, 4)));
606 +extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
607 + __attribute__ ((format (printf, 3, 0)));
608 +extern char *kasprintf(gfp_t gfp, const char *fmt, ...)
609 + __attribute__ ((format (printf, 2, 3)));
610 +
611 +extern int sscanf(const char *, const char *, ...)
612 + __attribute__ ((format (scanf, 2, 3)));
613 +extern int vsscanf(const char *, const char *, va_list)
614 + __attribute__ ((format (scanf, 2, 0)));
615 +
616 +extern int get_option(char **str, int *pint);
617 +extern char *get_options(const char *str, int nints, int *ints);
618 +extern unsigned long long memparse(char *ptr, char **retptr);
619 +
620 +extern int core_kernel_text(unsigned long addr);
621 +extern int __kernel_text_address(unsigned long addr);
622 +extern int kernel_text_address(unsigned long addr);
623 +struct pid;
624 +extern struct pid *session_of_pgrp(struct pid *pgrp);
625 +
626 +extern void dump_thread(struct pt_regs *regs, struct user *dump);
627 +
628 +#ifdef CONFIG_PRINTK
629 +asmlinkage int vprintk(const char *fmt, va_list args)
630 + __attribute__ ((format (printf, 1, 0)));
631 +asmlinkage int printk(const char * fmt, ...)
632 + __attribute__ ((format (printf, 1, 2)));
633 +#else
634 +static inline int vprintk(const char *s, va_list args)
635 + __attribute__ ((format (printf, 1, 0)));
636 +static inline int vprintk(const char *s, va_list args) { return 0; }
637 +static inline int printk(const char *s, ...)
638 + __attribute__ ((format (printf, 1, 2)));
639 +static inline int printk(const char *s, ...) { return 0; }
640 +#endif
641 +
642 +unsigned long int_sqrt(unsigned long);
643 +
644 +extern int printk_ratelimit(void);
645 +extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
646 +extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
647 + unsigned int interval_msec);
648 +
649 +static inline void console_silent(void)
650 +{
651 + console_loglevel = 0;
652 +}
653 +
654 +static inline void console_verbose(void)
655 +{
656 + if (console_loglevel)
657 + console_loglevel = 15;
658 +}
659 +
660 +extern void bust_spinlocks(int yes);
661 +extern void wake_up_klogd(void);
662 +extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
663 +extern int panic_timeout;
664 +extern int panic_on_oops;
665 +extern int panic_on_unrecovered_nmi;
666 +extern int tainted;
667 +extern const char *print_tainted(void);
668 +extern void add_taint(unsigned);
669 +
670 +/* Values used for system_state */
671 +extern enum system_states {
672 + SYSTEM_BOOTING,
673 + SYSTEM_RUNNING,
674 + SYSTEM_HALT,
675 + SYSTEM_POWER_OFF,
676 + SYSTEM_RESTART,
677 + SYSTEM_SUSPEND_DISK,
678 +} system_state;
679 +
680 +#define TAINT_PROPRIETARY_MODULE (1<<0)
681 +#define TAINT_FORCED_MODULE (1<<1)
682 +#define TAINT_UNSAFE_SMP (1<<2)
683 +#define TAINT_FORCED_RMMOD (1<<3)
684 +#define TAINT_MACHINE_CHECK (1<<4)
685 +#define TAINT_BAD_PAGE (1<<5)
686 +#define TAINT_USER (1<<6)
687 +
688 +extern void dump_stack(void);
689 +
690 +#ifdef DEBUG
691 +/* If you are writing a driver, please use dev_dbg instead */
692 +#define pr_debug(fmt,arg...) \
693 + printk(KERN_DEBUG fmt,##arg)
694 +#else
695 +static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char * fmt, ...)
696 +{
697 + return 0;
698 +}
699 +#endif
700 +
701 +#define pr_info(fmt,arg...) \
702 + printk(KERN_INFO fmt,##arg)
703 +
704 +/*
705 + * Display an IP address in readable format.
706 + */
707 +
708 +#define NIPQUAD(addr) \
709 + ((unsigned char *)&addr)[0], \
710 + ((unsigned char *)&addr)[1], \
711 + ((unsigned char *)&addr)[2], \
712 + ((unsigned char *)&addr)[3]
713 +#define NIPQUAD_FMT "%u.%u.%u.%u"
714 +
715 +#define NIP6(addr) \
716 + ntohs((addr).s6_addr16[0]), \
717 + ntohs((addr).s6_addr16[1]), \
718 + ntohs((addr).s6_addr16[2]), \
719 + ntohs((addr).s6_addr16[3]), \
720 + ntohs((addr).s6_addr16[4]), \
721 + ntohs((addr).s6_addr16[5]), \
722 + ntohs((addr).s6_addr16[6]), \
723 + ntohs((addr).s6_addr16[7])
724 +#define NIP6_FMT "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
725 +#define NIP6_SEQFMT "%04x%04x%04x%04x%04x%04x%04x%04x"
726 +
727 +#if defined(__LITTLE_ENDIAN)
728 +#define HIPQUAD(addr) \
729 + ((unsigned char *)&addr)[3], \
730 + ((unsigned char *)&addr)[2], \
731 + ((unsigned char *)&addr)[1], \
732 + ((unsigned char *)&addr)[0]
733 +#elif defined(__BIG_ENDIAN)
734 +#define HIPQUAD NIPQUAD
735 +#else
736 +#error "Please fix asm/byteorder.h"
737 +#endif /* __LITTLE_ENDIAN */
738 +
739 +/*
740 + * min()/max() macros that also do
741 + * strict type-checking.. See the
742 + * "unnecessary" pointer comparison.
743 + */
744 +#define min(x,y) ({ \
745 + typeof(x) _x = (x); \
746 + typeof(y) _y = (y); \
747 + (void) (&_x == &_y); \
748 + _x < _y ? _x : _y; })
749 +
750 +#define max(x,y) ({ \
751 + typeof(x) _x = (x); \
752 + typeof(y) _y = (y); \
753 + (void) (&_x == &_y); \
754 + _x > _y ? _x : _y; })
755 +
756 +/*
757 + * ..and if you can't take the strict
758 + * types, you can specify one yourself.
759 + *
760 + * Or not use min/max at all, of course.
761 + */
762 +#define min_t(type,x,y) \
763 + ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
764 +#define max_t(type,x,y) \
765 + ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
766 +
767 +
768 +/**
769 + * container_of - cast a member of a structure out to the containing structure
770 + * @ptr: the pointer to the member.
771 + * @type: the type of the container struct this is embedded in.
772 + * @member: the name of the member within the struct.
773 + *
774 + */
775 +#define container_of(ptr, type, member) ({ \
776 + const typeof( ((type *)0)->member ) *__mptr = (ptr); \
777 + (type *)( (char *)__mptr - offsetof(type,member) );})
778 +
779 +/*
780 + * Check at compile time that something is of a particular type.
781 + * Always evaluates to 1 so you may use it easily in comparisons.
782 + */
783 +#define typecheck(type,x) \
784 +({ type __dummy; \
785 + typeof(x) __dummy2; \
786 + (void)(&__dummy == &__dummy2); \
787 + 1; \
788 +})
789 +
790 +/*
791 + * Check at compile time that 'function' is a certain type, or is a pointer
792 + * to that type (needs to use typedef for the function type.)
793 + */
794 +#define typecheck_fn(type,function) \
795 +({ typeof(type) __tmp = function; \
796 + (void)__tmp; \
797 +})
798 +
799 +struct sysinfo;
800 +extern int do_sysinfo(struct sysinfo *info);
801 +
802 +#endif /* __KERNEL__ */
803 +
804 +#define SI_LOAD_SHIFT 16
805 +struct sysinfo {
806 + long uptime; /* Seconds since boot */
807 + unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
808 + unsigned long totalram; /* Total usable main memory size */
809 + unsigned long freeram; /* Available memory size */
810 + unsigned long sharedram; /* Amount of shared memory */
811 + unsigned long bufferram; /* Memory used by buffers */
812 + unsigned long totalswap; /* Total swap space size */
813 + unsigned long freeswap; /* swap space still available */
814 + unsigned short procs; /* Number of current processes */
815 + unsigned short pad; /* explicit padding for m68k */
816 + unsigned long totalhigh; /* Total high memory size */
817 + unsigned long freehigh; /* Available high memory size */
818 + unsigned int mem_unit; /* Memory unit size in bytes */
819 + char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
820 +};
821 +
822 +/* Force a compilation error if condition is true */
823 +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
824 +
825 +/* Force a compilation error if condition is true, but also produce a
826 + result (of value 0 and type size_t), so the expression can be used
827 + e.g. in a structure initializer (or where-ever else comma expressions
828 + aren't permitted). */
829 +#define BUILD_BUG_ON_ZERO(e) (sizeof(char[1 - 2 * !!(e)]) - 1)
830 +
831 +/* Trap pasters of __FUNCTION__ at compile-time */
832 +#define __FUNCTION__ (__func__)
833 +
834 +/* This helps us to avoid #ifdef CONFIG_NUMA */
835 +#ifdef CONFIG_NUMA
836 +#define NUMA_BUILD 1
837 +#else
838 +#define NUMA_BUILD 0
839 +#endif
840 +
841 +#endif
This page took 0.100559 seconds and 5 git commands to generate.