tools, slub: Fix off-by-one buffer corruption after readlink() call
[linux-2.6/linux-mips.git] / arch / arm / mach-pxa / leds-mainstone.c
blobdb4af5eee8b21649b2dc1ef661bfb970896812c7
1 /*
2 * linux/arch/arm/mach-pxa/leds-mainstone.c
4 * Author: Nicolas Pitre
5 * Created: Nov 05, 2002
6 * Copyright: MontaVista Software Inc.
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.
13 #include <linux/init.h>
15 #include <mach/hardware.h>
16 #include <asm/leds.h>
17 #include <asm/system.h>
19 #include <mach/pxa27x.h>
20 #include <mach/mainstone.h>
22 #include "leds.h"
25 /* 8 discrete leds available for general use: */
26 #define D28 (1 << 0)
27 #define D27 (1 << 1)
28 #define D26 (1 << 2)
29 #define D25 (1 << 3)
30 #define D24 (1 << 4)
31 #define D23 (1 << 5)
32 #define D22 (1 << 6)
33 #define D21 (1 << 7)
35 #define LED_STATE_ENABLED 1
36 #define LED_STATE_CLAIMED 2
38 static unsigned int led_state;
39 static unsigned int hw_led_state;
41 void mainstone_leds_event(led_event_t evt)
43 unsigned long flags;
45 local_irq_save(flags);
47 switch (evt) {
48 case led_start:
49 hw_led_state = 0;
50 led_state = LED_STATE_ENABLED;
51 break;
53 case led_stop:
54 led_state &= ~LED_STATE_ENABLED;
55 break;
57 case led_claim:
58 led_state |= LED_STATE_CLAIMED;
59 hw_led_state = 0;
60 break;
62 case led_release:
63 led_state &= ~LED_STATE_CLAIMED;
64 hw_led_state = 0;
65 break;
67 #ifdef CONFIG_LEDS_TIMER
68 case led_timer:
69 hw_led_state ^= D26;
70 break;
71 #endif
73 #ifdef CONFIG_LEDS_CPU
74 case led_idle_start:
75 hw_led_state &= ~D27;
76 break;
78 case led_idle_end:
79 hw_led_state |= D27;
80 break;
81 #endif
83 case led_halted:
84 break;
86 case led_green_on:
87 hw_led_state |= D21;
88 break;
90 case led_green_off:
91 hw_led_state &= ~D21;
92 break;
94 case led_amber_on:
95 hw_led_state |= D22;
96 break;
98 case led_amber_off:
99 hw_led_state &= ~D22;
100 break;
102 case led_red_on:
103 hw_led_state |= D23;
104 break;
106 case led_red_off:
107 hw_led_state &= ~D23;
108 break;
110 default:
111 break;
114 if (led_state & LED_STATE_ENABLED)
115 MST_LEDCTRL = (MST_LEDCTRL | 0xff) & ~hw_led_state;
116 else
117 MST_LEDCTRL |= 0xff;
119 local_irq_restore(flags);