aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acorn/block/Kconfig2
-rw-r--r--drivers/acpi/Kconfig7
-rw-r--r--drivers/acpi/Makefile1
-rw-r--r--drivers/acpi/ac.c63
-rw-r--r--drivers/acpi/acpi_memhotplug.c137
-rw-r--r--drivers/acpi/asus_acpi.c2
-rw-r--r--drivers/acpi/battery.c122
-rw-r--r--drivers/acpi/bus.c128
-rw-r--r--drivers/acpi/button.c72
-rw-r--r--drivers/acpi/container.c36
-rw-r--r--drivers/acpi/debug.c19
-rw-r--r--drivers/acpi/dispatcher/dsinit.c30
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c330
-rw-r--r--drivers/acpi/dispatcher/dswexec.c4
-rw-r--r--drivers/acpi/dispatcher/dswload.c49
-rw-r--r--drivers/acpi/dock.c739
-rw-r--r--drivers/acpi/ec.c168
-rw-r--r--drivers/acpi/event.c19
-rw-r--r--drivers/acpi/events/evgpe.c14
-rw-r--r--drivers/acpi/events/evxface.c47
-rw-r--r--drivers/acpi/executer/exconfig.c8
-rw-r--r--drivers/acpi/executer/excreate.c27
-rw-r--r--drivers/acpi/executer/exdump.c8
-rw-r--r--drivers/acpi/executer/exfldio.c71
-rw-r--r--drivers/acpi/executer/exmutex.c12
-rw-r--r--drivers/acpi/executer/exsystem.c82
-rw-r--r--drivers/acpi/fan.c51
-rw-r--r--drivers/acpi/hardware/hwregs.c77
-rw-r--r--drivers/acpi/hotkey.c132
-rw-r--r--drivers/acpi/motherboard.c5
-rw-r--r--drivers/acpi/namespace/nsaccess.c27
-rw-r--r--drivers/acpi/osl.c72
-rw-r--r--drivers/acpi/parser/psparse.c18
-rw-r--r--drivers/acpi/pci_bind.c87
-rw-r--r--drivers/acpi/pci_irq.c91
-rw-r--r--drivers/acpi/pci_link.c189
-rw-r--r--drivers/acpi/pci_root.c39
-rw-r--r--drivers/acpi/power.c145
-rw-r--r--drivers/acpi/processor_core.c161
-rw-r--r--drivers/acpi/processor_idle.c129
-rw-r--r--drivers/acpi/processor_perflib.c132
-rw-r--r--drivers/acpi/processor_thermal.c48
-rw-r--r--drivers/acpi/processor_throttling.c45
-rw-r--r--drivers/acpi/scan.c109
-rw-r--r--drivers/acpi/system.c21
-rw-r--r--drivers/acpi/thermal.c218
-rw-r--r--drivers/acpi/utilities/utdelete.c36
-rw-r--r--drivers/acpi/utilities/utglobal.c1
-rw-r--r--drivers/acpi/utilities/utmisc.c3
-rw-r--r--drivers/acpi/utilities/utmutex.c39
-rw-r--r--drivers/acpi/utils.c104
-rw-r--r--drivers/acpi/video.c270
-rw-r--r--drivers/base/node.c63
-rw-r--r--drivers/cdrom/cm206.c9
-rw-r--r--drivers/char/istallion.c17
-rw-r--r--drivers/char/pc8736x_gpio.c5
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c7
-rw-r--r--drivers/char/scx200_gpio.c6
-rw-r--r--drivers/edac/amd76x_edac.c98
-rw-r--r--drivers/edac/e752x_edac.c344
-rw-r--r--drivers/edac/e7xxx_edac.c175
-rw-r--r--drivers/edac/edac_mc.c589
-rw-r--r--drivers/edac/edac_mc.h18
-rw-r--r--drivers/edac/i82860_edac.c131
-rw-r--r--drivers/edac/i82875p_edac.c219
-rw-r--r--drivers/edac/r82600_edac.c142
-rw-r--r--drivers/i2c/busses/i2c-i801.c4
-rw-r--r--drivers/ide/legacy/ide-cs.c81
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.c1
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c4
-rw-r--r--drivers/media/dvb/frontends/cx22700.c1
-rw-r--r--drivers/media/dvb/frontends/cx24123.c4
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c15
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c5
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c43
-rw-r--r--drivers/media/video/cx88/cx88-cards.c19
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c28
-rw-r--r--drivers/media/video/cx88/cx88-video.c61
-rw-r--r--drivers/media/video/cx88/cx88.h3
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c2
-rw-r--r--drivers/media/video/msp3400-driver.h4
-rw-r--r--drivers/media/video/pvrusb2/Makefile2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-audio.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-context.c14
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ctrl.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-debugifc.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-demod.c126
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-demod.h38
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-eeprom.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-encoder.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h17
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c172
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h32
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.c34
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-i2c-core.h3
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-io.c57
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-io.h13
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ioread.c34
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-ioread.h1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-main.c10
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-std.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-sysfs.c14
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-tuner.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c42
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-video-v4l.c4
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-wm8775.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c2
-rw-r--r--drivers/media/video/tda9887.c4
-rw-r--r--drivers/media/video/tuner-core.c12
-rw-r--r--drivers/media/video/tuner-simple.c74
-rw-r--r--drivers/media/video/tuner-types.c38
-rw-r--r--drivers/media/video/tveeprom.c18
-rw-r--r--drivers/media/video/videocodec.h16
-rw-r--r--drivers/net/pcmcia/com20020_cs.c5
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c2
-rw-r--r--drivers/parisc/led.c11
-rw-r--r--drivers/pci/hotplug/Makefile3
-rw-r--r--drivers/pci/hotplug/acpiphp.h36
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c19
-rw-r--r--drivers/pci/hotplug/acpiphp_dock.c438
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c123
-rw-r--r--drivers/pcmcia/at91_cf.c75
-rw-r--r--drivers/pcmcia/au1000_db1x00.c2
-rw-r--r--drivers/pcmcia/cs.c29
-rw-r--r--drivers/pcmcia/pcmcia_resource.c27
-rw-r--r--drivers/pcmcia/ti113x.h1
-rw-r--r--drivers/pcmcia/yenta_socket.c83
-rw-r--r--drivers/serial/serial_cs.c1
-rw-r--r--drivers/usb/core/devio.c6
-rw-r--r--drivers/usb/core/inode.c2
-rw-r--r--drivers/usb/core/usb.h1
-rw-r--r--drivers/video/imacfb.c4
135 files changed, 4182 insertions, 4057 deletions
diff --git a/drivers/acorn/block/Kconfig b/drivers/acorn/block/Kconfig
index 073add35e66f..a0ff25ea439f 100644
--- a/drivers/acorn/block/Kconfig
+++ b/drivers/acorn/block/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4 4
5menu "Acorn-specific block devices" 5menu "Acorn-specific block devices"
6 depends on ARCH_ACORN 6 depends on ARCH_ARC || ARCH_A5K
7 7
8config BLK_DEV_FD1772 8config BLK_DEV_FD1772
9 tristate "Old Archimedes floppy (1772) support" 9 tristate "Old Archimedes floppy (1772) support"
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 610d2cc02cf8..bc2652d72fdc 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -133,6 +133,13 @@ config ACPI_FAN
133 This driver adds support for ACPI fan devices, allowing user-mode 133 This driver adds support for ACPI fan devices, allowing user-mode
134 applications to perform basic fan control (on, off, status). 134 applications to perform basic fan control (on, off, status).
135 135
136config ACPI_DOCK
137 tristate "Dock"
138 depends on !ACPI_IBM_DOCK
139 default y
140 help
141 This driver adds support for ACPI controlled docking stations
142
136config ACPI_PROCESSOR 143config ACPI_PROCESSOR
137 tristate "Processor" 144 tristate "Processor"
138 default y 145 default y
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 5984b4f6715a..f0a68ecf1e57 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_ACPI_BATTERY) += battery.o
42obj-$(CONFIG_ACPI_BUTTON) += button.o 42obj-$(CONFIG_ACPI_BUTTON) += button.o
43obj-$(CONFIG_ACPI_EC) += ec.o 43obj-$(CONFIG_ACPI_EC) += ec.o
44obj-$(CONFIG_ACPI_FAN) += fan.o 44obj-$(CONFIG_ACPI_FAN) += fan.o
45obj-$(CONFIG_ACPI_DOCK) += dock.o
45obj-$(CONFIG_ACPI_VIDEO) += video.o 46obj-$(CONFIG_ACPI_VIDEO) += video.o
46obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o 47obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o
47obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o 48obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 7839b831df94..36ca365bcead 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -84,20 +84,18 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
84{ 84{
85 acpi_status status = AE_OK; 85 acpi_status status = AE_OK;
86 86
87 ACPI_FUNCTION_TRACE("acpi_ac_get_state");
88 87
89 if (!ac) 88 if (!ac)
90 return_VALUE(-EINVAL); 89 return -EINVAL;
91 90
92 status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state); 91 status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state);
93 if (ACPI_FAILURE(status)) { 92 if (ACPI_FAILURE(status)) {
94 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 93 ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state"));
95 "Error reading AC Adapter state\n"));
96 ac->state = ACPI_AC_STATUS_UNKNOWN; 94 ac->state = ACPI_AC_STATUS_UNKNOWN;
97 return_VALUE(-ENODEV); 95 return -ENODEV;
98 } 96 }
99 97
100 return_VALUE(0); 98 return 0;
101} 99}
102 100
103/* -------------------------------------------------------------------------- 101/* --------------------------------------------------------------------------
@@ -110,14 +108,13 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
110{ 108{
111 struct acpi_ac *ac = (struct acpi_ac *)seq->private; 109 struct acpi_ac *ac = (struct acpi_ac *)seq->private;
112 110
113 ACPI_FUNCTION_TRACE("acpi_ac_seq_show");
114 111
115 if (!ac) 112 if (!ac)
116 return_VALUE(0); 113 return 0;
117 114
118 if (acpi_ac_get_state(ac)) { 115 if (acpi_ac_get_state(ac)) {
119 seq_puts(seq, "ERROR: Unable to read AC Adapter state\n"); 116 seq_puts(seq, "ERROR: Unable to read AC Adapter state\n");
120 return_VALUE(0); 117 return 0;
121 } 118 }
122 119
123 seq_puts(seq, "state: "); 120 seq_puts(seq, "state: ");
@@ -133,7 +130,7 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
133 break; 130 break;
134 } 131 }
135 132
136 return_VALUE(0); 133 return 0;
137} 134}
138 135
139static int acpi_ac_open_fs(struct inode *inode, struct file *file) 136static int acpi_ac_open_fs(struct inode *inode, struct file *file)
@@ -145,13 +142,12 @@ static int acpi_ac_add_fs(struct acpi_device *device)
145{ 142{
146 struct proc_dir_entry *entry = NULL; 143 struct proc_dir_entry *entry = NULL;
147 144
148 ACPI_FUNCTION_TRACE("acpi_ac_add_fs");
149 145
150 if (!acpi_device_dir(device)) { 146 if (!acpi_device_dir(device)) {
151 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 147 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
152 acpi_ac_dir); 148 acpi_ac_dir);
153 if (!acpi_device_dir(device)) 149 if (!acpi_device_dir(device))
154 return_VALUE(-ENODEV); 150 return -ENODEV;
155 acpi_device_dir(device)->owner = THIS_MODULE; 151 acpi_device_dir(device)->owner = THIS_MODULE;
156 } 152 }
157 153
@@ -159,21 +155,18 @@ static int acpi_ac_add_fs(struct acpi_device *device)
159 entry = create_proc_entry(ACPI_AC_FILE_STATE, 155 entry = create_proc_entry(ACPI_AC_FILE_STATE,
160 S_IRUGO, acpi_device_dir(device)); 156 S_IRUGO, acpi_device_dir(device));
161 if (!entry) 157 if (!entry)
162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 158 return -ENODEV;
163 "Unable to create '%s' fs entry\n",
164 ACPI_AC_FILE_STATE));
165 else { 159 else {
166 entry->proc_fops = &acpi_ac_fops; 160 entry->proc_fops = &acpi_ac_fops;
167 entry->data = acpi_driver_data(device); 161 entry->data = acpi_driver_data(device);
168 entry->owner = THIS_MODULE; 162 entry->owner = THIS_MODULE;
169 } 163 }
170 164
171 return_VALUE(0); 165 return 0;
172} 166}
173 167
174static int acpi_ac_remove_fs(struct acpi_device *device) 168static int acpi_ac_remove_fs(struct acpi_device *device)
175{ 169{
176 ACPI_FUNCTION_TRACE("acpi_ac_remove_fs");
177 170
178 if (acpi_device_dir(device)) { 171 if (acpi_device_dir(device)) {
179 remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device)); 172 remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device));
@@ -182,7 +175,7 @@ static int acpi_ac_remove_fs(struct acpi_device *device)
182 acpi_device_dir(device) = NULL; 175 acpi_device_dir(device) = NULL;
183 } 176 }
184 177
185 return_VALUE(0); 178 return 0;
186} 179}
187 180
188/* -------------------------------------------------------------------------- 181/* --------------------------------------------------------------------------
@@ -194,13 +187,12 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
194 struct acpi_ac *ac = (struct acpi_ac *)data; 187 struct acpi_ac *ac = (struct acpi_ac *)data;
195 struct acpi_device *device = NULL; 188 struct acpi_device *device = NULL;
196 189
197 ACPI_FUNCTION_TRACE("acpi_ac_notify");
198 190
199 if (!ac) 191 if (!ac)
200 return_VOID; 192 return;
201 193
202 if (acpi_bus_get_device(ac->handle, &device)) 194 if (acpi_bus_get_device(ac->handle, &device))
203 return_VOID; 195 return;
204 196
205 switch (event) { 197 switch (event) {
206 case ACPI_AC_NOTIFY_STATUS: 198 case ACPI_AC_NOTIFY_STATUS:
@@ -213,7 +205,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
213 break; 205 break;
214 } 206 }
215 207
216 return_VOID; 208 return;
217} 209}
218 210
219static int acpi_ac_add(struct acpi_device *device) 211static int acpi_ac_add(struct acpi_device *device)
@@ -222,14 +214,13 @@ static int acpi_ac_add(struct acpi_device *device)
222 acpi_status status = AE_OK; 214 acpi_status status = AE_OK;
223 struct acpi_ac *ac = NULL; 215 struct acpi_ac *ac = NULL;
224 216
225 ACPI_FUNCTION_TRACE("acpi_ac_add");
226 217
227 if (!device) 218 if (!device)
228 return_VALUE(-EINVAL); 219 return -EINVAL;
229 220
230 ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL); 221 ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL);
231 if (!ac) 222 if (!ac)
232 return_VALUE(-ENOMEM); 223 return -ENOMEM;
233 memset(ac, 0, sizeof(struct acpi_ac)); 224 memset(ac, 0, sizeof(struct acpi_ac));
234 225
235 ac->handle = device->handle; 226 ac->handle = device->handle;
@@ -249,8 +240,6 @@ static int acpi_ac_add(struct acpi_device *device)
249 ACPI_DEVICE_NOTIFY, acpi_ac_notify, 240 ACPI_DEVICE_NOTIFY, acpi_ac_notify,
250 ac); 241 ac);
251 if (ACPI_FAILURE(status)) { 242 if (ACPI_FAILURE(status)) {
252 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
253 "Error installing notify handler\n"));
254 result = -ENODEV; 243 result = -ENODEV;
255 goto end; 244 goto end;
256 } 245 }
@@ -265,7 +254,7 @@ static int acpi_ac_add(struct acpi_device *device)
265 kfree(ac); 254 kfree(ac);
266 } 255 }
267 256
268 return_VALUE(result); 257 return result;
269} 258}
270 259
271static int acpi_ac_remove(struct acpi_device *device, int type) 260static int acpi_ac_remove(struct acpi_device *device, int type)
@@ -273,55 +262,49 @@ static int acpi_ac_remove(struct acpi_device *device, int type)
273 acpi_status status = AE_OK; 262 acpi_status status = AE_OK;
274 struct acpi_ac *ac = NULL; 263 struct acpi_ac *ac = NULL;
275 264
276 ACPI_FUNCTION_TRACE("acpi_ac_remove");
277 265
278 if (!device || !acpi_driver_data(device)) 266 if (!device || !acpi_driver_data(device))
279 return_VALUE(-EINVAL); 267 return -EINVAL;
280 268
281 ac = (struct acpi_ac *)acpi_driver_data(device); 269 ac = (struct acpi_ac *)acpi_driver_data(device);
282 270
283 status = acpi_remove_notify_handler(ac->handle, 271 status = acpi_remove_notify_handler(ac->handle,
284 ACPI_DEVICE_NOTIFY, acpi_ac_notify); 272 ACPI_DEVICE_NOTIFY, acpi_ac_notify);
285 if (ACPI_FAILURE(status))
286 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
287 "Error removing notify handler\n"));
288 273
289 acpi_ac_remove_fs(device); 274 acpi_ac_remove_fs(device);
290 275
291 kfree(ac); 276 kfree(ac);
292 277
293 return_VALUE(0); 278 return 0;
294} 279}
295 280
296static int __init acpi_ac_init(void) 281static int __init acpi_ac_init(void)
297{ 282{
298 int result = 0; 283 int result = 0;
299 284
300 ACPI_FUNCTION_TRACE("acpi_ac_init");
301 285
302 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir); 286 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
303 if (!acpi_ac_dir) 287 if (!acpi_ac_dir)
304 return_VALUE(-ENODEV); 288 return -ENODEV;
305 acpi_ac_dir->owner = THIS_MODULE; 289 acpi_ac_dir->owner = THIS_MODULE;
306 290
307 result = acpi_bus_register_driver(&acpi_ac_driver); 291 result = acpi_bus_register_driver(&acpi_ac_driver);
308 if (result < 0) { 292 if (result < 0) {
309 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); 293 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
310 return_VALUE(-ENODEV); 294 return -ENODEV;
311 } 295 }
312 296
313 return_VALUE(0); 297 return 0;
314} 298}
315 299
316static void __exit acpi_ac_exit(void) 300static void __exit acpi_ac_exit(void)
317{ 301{
318 ACPI_FUNCTION_TRACE("acpi_ac_exit");
319 302
320 acpi_bus_unregister_driver(&acpi_ac_driver); 303 acpi_bus_unregister_driver(&acpi_ac_driver);
321 304
322 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); 305 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
323 306
324 return_VOID; 307 return;
325} 308}
326 309
327module_init(acpi_ac_init); 310module_init(acpi_ac_init);
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 1012284ff4f7..cd57372a6729 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -128,7 +128,6 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
128 acpi_status status; 128 acpi_status status;
129 struct acpi_memory_info *info, *n; 129 struct acpi_memory_info *info, *n;
130 130
131 ACPI_FUNCTION_TRACE("acpi_memory_get_device_resources");
132 131
133 status = acpi_walk_resources(mem_device->handle, METHOD_NAME__CRS, 132 status = acpi_walk_resources(mem_device->handle, METHOD_NAME__CRS,
134 acpi_memory_get_resource, mem_device); 133 acpi_memory_get_resource, mem_device);
@@ -150,23 +149,21 @@ acpi_memory_get_device(acpi_handle handle,
150 struct acpi_device *device = NULL; 149 struct acpi_device *device = NULL;
151 struct acpi_device *pdevice = NULL; 150 struct acpi_device *pdevice = NULL;
152 151
153 ACPI_FUNCTION_TRACE("acpi_memory_get_device");
154 152
155 if (!acpi_bus_get_device(handle, &device) && device) 153 if (!acpi_bus_get_device(handle, &device) && device)
156 goto end; 154 goto end;
157 155
158 status = acpi_get_parent(handle, &phandle); 156 status = acpi_get_parent(handle, &phandle);
159 if (ACPI_FAILURE(status)) { 157 if (ACPI_FAILURE(status)) {
160 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_get_parent\n")); 158 ACPI_EXCEPTION((AE_INFO, status, "Cannot find acpi parent"));
161 return_VALUE(-EINVAL); 159 return -EINVAL;
162 } 160 }
163 161
164 /* Get the parent device */ 162 /* Get the parent device */
165 status = acpi_bus_get_device(phandle, &pdevice); 163 status = acpi_bus_get_device(phandle, &pdevice);
166 if (ACPI_FAILURE(status)) { 164 if (ACPI_FAILURE(status)) {
167 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 165 ACPI_EXCEPTION((AE_INFO, status, "Cannot get acpi bus device"));
168 "Error in acpi_bus_get_device\n")); 166 return -EINVAL;
169 return_VALUE(-EINVAL);
170 } 167 }
171 168
172 /* 169 /*
@@ -175,30 +172,29 @@ acpi_memory_get_device(acpi_handle handle,
175 */ 172 */
176 status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); 173 status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE);
177 if (ACPI_FAILURE(status)) { 174 if (ACPI_FAILURE(status)) {
178 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error in acpi_bus_add\n")); 175 ACPI_EXCEPTION((AE_INFO, status, "Cannot add acpi bus"));
179 return_VALUE(-EINVAL); 176 return -EINVAL;
180 } 177 }
181 178
182 end: 179 end:
183 *mem_device = acpi_driver_data(device); 180 *mem_device = acpi_driver_data(device);
184 if (!(*mem_device)) { 181 if (!(*mem_device)) {
185 printk(KERN_ERR "\n driver data not found"); 182 printk(KERN_ERR "\n driver data not found");
186 return_VALUE(-ENODEV); 183 return -ENODEV;
187 } 184 }
188 185
189 return_VALUE(0); 186 return 0;
190} 187}
191 188
192static int acpi_memory_check_device(struct acpi_memory_device *mem_device) 189static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
193{ 190{
194 unsigned long current_status; 191 unsigned long current_status;
195 192
196 ACPI_FUNCTION_TRACE("acpi_memory_check_device");
197 193
198 /* Get device present/absent information from the _STA */ 194 /* Get device present/absent information from the _STA */
199 if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA", 195 if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA",
200 NULL, &current_status))) 196 NULL, &current_status)))
201 return_VALUE(-ENODEV); 197 return -ENODEV;
202 /* 198 /*
203 * Check for device status. Device should be 199 * Check for device status. Device should be
204 * present/enabled/functioning. 200 * present/enabled/functioning.
@@ -206,9 +202,9 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
206 if (!((current_status & ACPI_MEMORY_STA_PRESENT) 202 if (!((current_status & ACPI_MEMORY_STA_PRESENT)
207 && (current_status & ACPI_MEMORY_STA_ENABLED) 203 && (current_status & ACPI_MEMORY_STA_ENABLED)
208 && (current_status & ACPI_MEMORY_STA_FUNCTIONAL))) 204 && (current_status & ACPI_MEMORY_STA_FUNCTIONAL)))
209 return_VALUE(-ENODEV); 205 return -ENODEV;
210 206
211 return_VALUE(0); 207 return 0;
212} 208}
213 209
214static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) 210static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
@@ -217,13 +213,11 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
217 struct acpi_memory_info *info; 213 struct acpi_memory_info *info;
218 int node; 214 int node;
219 215
220 ACPI_FUNCTION_TRACE("acpi_memory_enable_device");
221 216
222 /* Get the range from the _CRS */ 217 /* Get the range from the _CRS */
223 result = acpi_memory_get_device_resources(mem_device); 218 result = acpi_memory_get_device_resources(mem_device);
224 if (result) { 219 if (result) {
225 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 220 printk(KERN_ERR PREFIX "get_device_resources failed\n");
226 "\nget_device_resources failed\n"));
227 mem_device->state = MEMORY_INVALID_STATE; 221 mem_device->state = MEMORY_INVALID_STATE;
228 return result; 222 return result;
229 } 223 }
@@ -254,7 +248,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
254 num_enabled++; 248 num_enabled++;
255 } 249 }
256 if (!num_enabled) { 250 if (!num_enabled) {
257 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "\nadd_memory failed\n")); 251 printk(KERN_ERR PREFIX "add_memory failed\n");
258 mem_device->state = MEMORY_INVALID_STATE; 252 mem_device->state = MEMORY_INVALID_STATE;
259 return -EINVAL; 253 return -EINVAL;
260 } 254 }
@@ -269,7 +263,6 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
269 union acpi_object arg; 263 union acpi_object arg;
270 unsigned long current_status; 264 unsigned long current_status;
271 265
272 ACPI_FUNCTION_TRACE("acpi_memory_powerdown_device");
273 266
274 /* Issue the _EJ0 command */ 267 /* Issue the _EJ0 command */
275 arg_list.count = 1; 268 arg_list.count = 1;
@@ -280,21 +273,21 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
280 "_EJ0", &arg_list, NULL); 273 "_EJ0", &arg_list, NULL);
281 /* Return on _EJ0 failure */ 274 /* Return on _EJ0 failure */
282 if (ACPI_FAILURE(status)) { 275 if (ACPI_FAILURE(status)) {
283 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_EJ0 failed.\n")); 276 ACPI_EXCEPTION((AE_INFO, status, "_EJ0 failed"));
284 return_VALUE(-ENODEV); 277 return -ENODEV;
285 } 278 }
286 279
287 /* Evalute _STA to check if the device is disabled */ 280 /* Evalute _STA to check if the device is disabled */
288 status = acpi_evaluate_integer(mem_device->handle, "_STA", 281 status = acpi_evaluate_integer(mem_device->handle, "_STA",
289 NULL, &current_status); 282 NULL, &current_status);
290 if (ACPI_FAILURE(status)) 283 if (ACPI_FAILURE(status))
291 return_VALUE(-ENODEV); 284 return -ENODEV;
292 285
293 /* Check for device status. Device should be disabled */ 286 /* Check for device status. Device should be disabled */
294 if (current_status & ACPI_MEMORY_STA_ENABLED) 287 if (current_status & ACPI_MEMORY_STA_ENABLED)
295 return_VALUE(-EINVAL); 288 return -EINVAL;
296 289
297 return_VALUE(0); 290 return 0;
298} 291}
299 292
300static int acpi_memory_disable_device(struct acpi_memory_device *mem_device) 293static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
@@ -302,7 +295,6 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
302 int result; 295 int result;
303 struct acpi_memory_info *info, *n; 296 struct acpi_memory_info *info, *n;
304 297
305 ACPI_FUNCTION_TRACE("acpi_memory_disable_device");
306 298
307 /* 299 /*
308 * Ask the VM to offline this memory range. 300 * Ask the VM to offline this memory range.
@@ -320,8 +312,6 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
320 /* Power-off and eject the device */ 312 /* Power-off and eject the device */
321 result = acpi_memory_powerdown_device(mem_device); 313 result = acpi_memory_powerdown_device(mem_device);
322 if (result) { 314 if (result) {
323 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
324 "Device Power Down failed.\n"));
325 /* Set the status of the device to invalid */ 315 /* Set the status of the device to invalid */
326 mem_device->state = MEMORY_INVALID_STATE; 316 mem_device->state = MEMORY_INVALID_STATE;
327 return result; 317 return result;
@@ -336,7 +326,6 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
336 struct acpi_memory_device *mem_device; 326 struct acpi_memory_device *mem_device;
337 struct acpi_device *device; 327 struct acpi_device *device;
338 328
339 ACPI_FUNCTION_TRACE("acpi_memory_device_notify");
340 329
341 switch (event) { 330 switch (event) {
342 case ACPI_NOTIFY_BUS_CHECK: 331 case ACPI_NOTIFY_BUS_CHECK:
@@ -348,15 +337,14 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
348 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 337 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
349 "\nReceived DEVICE CHECK notification for device\n")); 338 "\nReceived DEVICE CHECK notification for device\n"));
350 if (acpi_memory_get_device(handle, &mem_device)) { 339 if (acpi_memory_get_device(handle, &mem_device)) {
351 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 340 printk(KERN_ERR PREFIX "Cannot find driver data\n");
352 "Error in finding driver data\n")); 341 return;
353 return_VOID;
354 } 342 }
355 343
356 if (!acpi_memory_check_device(mem_device)) { 344 if (!acpi_memory_check_device(mem_device)) {
357 if (acpi_memory_enable_device(mem_device)) 345 if (acpi_memory_enable_device(mem_device))
358 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 346 printk(KERN_ERR PREFIX
359 "Error in acpi_memory_enable_device\n")); 347 "Cannot enable memory device\n");
360 } 348 }
361 break; 349 break;
362 case ACPI_NOTIFY_EJECT_REQUEST: 350 case ACPI_NOTIFY_EJECT_REQUEST:
@@ -364,14 +352,12 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
364 "\nReceived EJECT REQUEST notification for device\n")); 352 "\nReceived EJECT REQUEST notification for device\n"));
365 353
366 if (acpi_bus_get_device(handle, &device)) { 354 if (acpi_bus_get_device(handle, &device)) {
367 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 355 printk(KERN_ERR PREFIX "Device doesn't exist\n");
368 "Device doesn't exist\n"));
369 break; 356 break;
370 } 357 }
371 mem_device = acpi_driver_data(device); 358 mem_device = acpi_driver_data(device);
372 if (!mem_device) { 359 if (!mem_device) {
373 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 360 printk(KERN_ERR PREFIX "Driver Data is NULL\n");
374 "Driver Data is NULL\n"));
375 break; 361 break;
376 } 362 }
377 363
@@ -382,8 +368,8 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
382 * with generic sysfs driver 368 * with generic sysfs driver
383 */ 369 */
384 if (acpi_memory_disable_device(mem_device)) 370 if (acpi_memory_disable_device(mem_device))
385 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 371 printk(KERN_ERR PREFIX
386 "Error in acpi_memory_disable_device\n")); 372 "Disable memory device\n");
387 /* 373 /*
388 * TBD: Invoke acpi_bus_remove to cleanup data structures 374 * TBD: Invoke acpi_bus_remove to cleanup data structures
389 */ 375 */
@@ -394,7 +380,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
394 break; 380 break;
395 } 381 }
396 382
397 return_VOID; 383 return;
398} 384}
399 385
400static int acpi_memory_device_add(struct acpi_device *device) 386static int acpi_memory_device_add(struct acpi_device *device)
@@ -402,14 +388,13 @@ static int acpi_memory_device_add(struct acpi_device *device)
402 int result; 388 int result;
403 struct acpi_memory_device *mem_device = NULL; 389 struct acpi_memory_device *mem_device = NULL;
404 390
405 ACPI_FUNCTION_TRACE("acpi_memory_device_add");
406 391
407 if (!device) 392 if (!device)
408 return_VALUE(-EINVAL); 393 return -EINVAL;
409 394
410 mem_device = kmalloc(sizeof(struct acpi_memory_device), GFP_KERNEL); 395 mem_device = kmalloc(sizeof(struct acpi_memory_device), GFP_KERNEL);
411 if (!mem_device) 396 if (!mem_device)
412 return_VALUE(-ENOMEM); 397 return -ENOMEM;
413 memset(mem_device, 0, sizeof(struct acpi_memory_device)); 398 memset(mem_device, 0, sizeof(struct acpi_memory_device));
414 399
415 INIT_LIST_HEAD(&mem_device->res_list); 400 INIT_LIST_HEAD(&mem_device->res_list);
@@ -422,7 +407,7 @@ static int acpi_memory_device_add(struct acpi_device *device)
422 result = acpi_memory_get_device_resources(mem_device); 407 result = acpi_memory_get_device_resources(mem_device);
423 if (result) { 408 if (result) {
424 kfree(mem_device); 409 kfree(mem_device);
425 return_VALUE(result); 410 return result;
426 } 411 }
427 412
428 /* Set the device state */ 413 /* Set the device state */
@@ -430,22 +415,21 @@ static int acpi_memory_device_add(struct acpi_device *device)
430 415
431 printk(KERN_INFO "%s \n", acpi_device_name(device)); 416 printk(KERN_INFO "%s \n", acpi_device_name(device));
432 417
433 return_VALUE(result); 418 return result;
434} 419}
435 420
436static int acpi_memory_device_remove(struct acpi_device *device, int type) 421static int acpi_memory_device_remove(struct acpi_device *device, int type)
437{ 422{
438 struct acpi_memory_device *mem_device = NULL; 423 struct acpi_memory_device *mem_device = NULL;
439 424
440 ACPI_FUNCTION_TRACE("acpi_memory_device_remove");
441 425
442 if (!device || !acpi_driver_data(device)) 426 if (!device || !acpi_driver_data(device))
443 return_VALUE(-EINVAL); 427 return -EINVAL;
444 428
445 mem_device = (struct acpi_memory_device *)acpi_driver_data(device); 429 mem_device = (struct acpi_memory_device *)acpi_driver_data(device);
446 kfree(mem_device); 430 kfree(mem_device);
447 431
448 return_VALUE(0); 432 return 0;
449} 433}
450 434
451static int acpi_memory_device_start (struct acpi_device *device) 435static int acpi_memory_device_start (struct acpi_device *device)
@@ -453,8 +437,6 @@ static int acpi_memory_device_start (struct acpi_device *device)
453 struct acpi_memory_device *mem_device; 437 struct acpi_memory_device *mem_device;
454 int result = 0; 438 int result = 0;
455 439
456 ACPI_FUNCTION_TRACE("acpi_memory_device_start");
457
458 mem_device = acpi_driver_data(device); 440 mem_device = acpi_driver_data(device);
459 441
460 if (!acpi_memory_check_device(mem_device)) { 442 if (!acpi_memory_check_device(mem_device)) {
@@ -464,7 +446,7 @@ static int acpi_memory_device_start (struct acpi_device *device)
464 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 446 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
465 "Error in acpi_memory_enable_device\n")); 447 "Error in acpi_memory_enable_device\n"));
466 } 448 }
467 return_VALUE(result); 449 return result;
468} 450}
469 451
470/* 452/*
@@ -477,16 +459,15 @@ static acpi_status is_memory_device(acpi_handle handle)
477 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 459 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
478 struct acpi_device_info *info; 460 struct acpi_device_info *info;
479 461
480 ACPI_FUNCTION_TRACE("is_memory_device");
481 462
482 status = acpi_get_object_info(handle, &buffer); 463 status = acpi_get_object_info(handle, &buffer);
483 if (ACPI_FAILURE(status)) 464 if (ACPI_FAILURE(status))
484 return_ACPI_STATUS(AE_ERROR); 465 return status;
485 466
486 info = buffer.pointer; 467 info = buffer.pointer;
487 if (!(info->valid & ACPI_VALID_HID)) { 468 if (!(info->valid & ACPI_VALID_HID)) {
488 acpi_os_free(buffer.pointer); 469 acpi_os_free(buffer.pointer);
489 return_ACPI_STATUS(AE_ERROR); 470 return AE_ERROR;
490 } 471 }
491 472
492 hardware_id = info->hardware_id.value; 473 hardware_id = info->hardware_id.value;
@@ -495,7 +476,7 @@ static acpi_status is_memory_device(acpi_handle handle)
495 status = AE_ERROR; 476 status = AE_ERROR;
496 477
497 acpi_os_free(buffer.pointer); 478 acpi_os_free(buffer.pointer);
498 return_ACPI_STATUS(status); 479 return status;
499} 480}
500 481
501static acpi_status 482static acpi_status
@@ -504,21 +485,17 @@ acpi_memory_register_notify_handler(acpi_handle handle,
504{ 485{
505 acpi_status status; 486 acpi_status status;
506 487
507 ACPI_FUNCTION_TRACE("acpi_memory_register_notify_handler");
508 488
509 status = is_memory_device(handle); 489 status = is_memory_device(handle);
510 if (ACPI_FAILURE(status)) 490 if (ACPI_FAILURE(status)){
511 return_ACPI_STATUS(AE_OK); /* continue */ 491 ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device"));
492 return AE_OK; /* continue */
493 }
512 494
513 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, 495 status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
514 acpi_memory_device_notify, NULL); 496 acpi_memory_device_notify, NULL);
515 if (ACPI_FAILURE(status)) { 497 /* continue */
516 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 498 return AE_OK;
517 "Error installing notify handler\n"));
518 return_ACPI_STATUS(AE_OK); /* continue */
519 }
520
521 return_ACPI_STATUS(status);
522} 499}
523 500
524static acpi_status 501static acpi_status
@@ -527,22 +504,18 @@ acpi_memory_deregister_notify_handler(acpi_handle handle,
527{ 504{
528 acpi_status status; 505 acpi_status status;
529 506
530 ACPI_FUNCTION_TRACE("acpi_memory_deregister_notify_handler");
531 507
532 status = is_memory_device(handle); 508 status = is_memory_device(handle);
533 if (ACPI_FAILURE(status)) 509 if (ACPI_FAILURE(status)){
534 return_ACPI_STATUS(AE_OK); /* continue */ 510 ACPI_EXCEPTION((AE_INFO, status, "handle is no memory device"));
511 return AE_OK; /* continue */
512 }
535 513
536 status = acpi_remove_notify_handler(handle, 514 status = acpi_remove_notify_handler(handle,
537 ACPI_SYSTEM_NOTIFY, 515 ACPI_SYSTEM_NOTIFY,
538 acpi_memory_device_notify); 516 acpi_memory_device_notify);
539 if (ACPI_FAILURE(status)) {
540 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
541 "Error removing notify handler\n"));
542 return_ACPI_STATUS(AE_OK); /* continue */
543 }
544 517
545 return_ACPI_STATUS(status); 518 return AE_OK; /* continue */
546} 519}
547 520
548static int __init acpi_memory_device_init(void) 521static int __init acpi_memory_device_init(void)
@@ -550,12 +523,11 @@ static int __init acpi_memory_device_init(void)
550 int result; 523 int result;
551 acpi_status status; 524 acpi_status status;
552 525
553 ACPI_FUNCTION_TRACE("acpi_memory_device_init");
554 526
555 result = acpi_bus_register_driver(&acpi_memory_device_driver); 527 result = acpi_bus_register_driver(&acpi_memory_device_driver);
556 528
557 if (result < 0) 529 if (result < 0)
558 return_VALUE(-ENODEV); 530 return -ENODEV;
559 531
560 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 532 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
561 ACPI_UINT32_MAX, 533 ACPI_UINT32_MAX,
@@ -563,19 +535,18 @@ static int __init acpi_memory_device_init(void)
563 NULL, NULL); 535 NULL, NULL);
564 536
565 if (ACPI_FAILURE(status)) { 537 if (ACPI_FAILURE(status)) {
566 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n")); 538 ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed"));
567 acpi_bus_unregister_driver(&acpi_memory_device_driver); 539 acpi_bus_unregister_driver(&acpi_memory_device_driver);
568 return_VALUE(-ENODEV); 540 return -ENODEV;
569 } 541 }
570 542
571 return_VALUE(0); 543 return 0;
572} 544}
573 545
574static void __exit acpi_memory_device_exit(void) 546static void __exit acpi_memory_device_exit(void)
575{ 547{
576 acpi_status status; 548 acpi_status status;
577 549
578 ACPI_FUNCTION_TRACE("acpi_memory_device_exit");
579 550
580 /* 551 /*
581 * Adding this to un-install notification handlers for all the device 552 * Adding this to un-install notification handlers for all the device
@@ -587,11 +558,11 @@ static void __exit acpi_memory_device_exit(void)
587 NULL, NULL); 558 NULL, NULL);
588 559
589 if (ACPI_FAILURE(status)) 560 if (ACPI_FAILURE(status))
590 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed\n")); 561 ACPI_EXCEPTION((AE_INFO, status, "walk_namespace failed"));
591 562
592 acpi_bus_unregister_driver(&acpi_memory_device_driver); 563 acpi_bus_unregister_driver(&acpi_memory_device_driver);
593 564
594 return_VOID; 565 return;
595} 566}
596 567
597module_init(acpi_memory_device_init); 568module_init(acpi_memory_device_init);
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index 839f423d738d..055cfd5c8766 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -1232,7 +1232,7 @@ static int __init asus_acpi_init(void)
1232 result = acpi_bus_register_driver(&asus_hotk_driver); 1232 result = acpi_bus_register_driver(&asus_hotk_driver);
1233 if (result < 0) { 1233 if (result < 0) {
1234 remove_proc_entry(PROC_ASUS, acpi_root_dir); 1234 remove_proc_entry(PROC_ASUS, acpi_root_dir);
1235 return -ENODEV; 1235 return result;
1236 } 1236 }
1237 1237
1238 /* 1238 /*
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 702e857e98c5..00b0728efe82 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -132,17 +132,16 @@ acpi_battery_get_info(struct acpi_battery *battery,
132 struct acpi_buffer data = { 0, NULL }; 132 struct acpi_buffer data = { 0, NULL };
133 union acpi_object *package = NULL; 133 union acpi_object *package = NULL;
134 134
135 ACPI_FUNCTION_TRACE("acpi_battery_get_info");
136 135
137 if (!battery || !bif) 136 if (!battery || !bif)
138 return_VALUE(-EINVAL); 137 return -EINVAL;
139 138
140 /* Evalute _BIF */ 139 /* Evalute _BIF */
141 140
142 status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer); 141 status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer);
143 if (ACPI_FAILURE(status)) { 142 if (ACPI_FAILURE(status)) {
144 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BIF\n")); 143 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
145 return_VALUE(-ENODEV); 144 return -ENODEV;
146 } 145 }
147 146
148 package = (union acpi_object *)buffer.pointer; 147 package = (union acpi_object *)buffer.pointer;
@@ -151,7 +150,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
151 150
152 status = acpi_extract_package(package, &format, &data); 151 status = acpi_extract_package(package, &format, &data);
153 if (status != AE_BUFFER_OVERFLOW) { 152 if (status != AE_BUFFER_OVERFLOW) {
154 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n")); 153 ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF"));
155 result = -ENODEV; 154 result = -ENODEV;
156 goto end; 155 goto end;
157 } 156 }
@@ -165,7 +164,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
165 164
166 status = acpi_extract_package(package, &format, &data); 165 status = acpi_extract_package(package, &format, &data);
167 if (ACPI_FAILURE(status)) { 166 if (ACPI_FAILURE(status)) {
168 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BIF\n")); 167 ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF"));
169 kfree(data.pointer); 168 kfree(data.pointer);
170 result = -ENODEV; 169 result = -ENODEV;
171 goto end; 170 goto end;
@@ -177,7 +176,7 @@ acpi_battery_get_info(struct acpi_battery *battery,
177 if (!result) 176 if (!result)
178 (*bif) = (struct acpi_battery_info *)data.pointer; 177 (*bif) = (struct acpi_battery_info *)data.pointer;
179 178
180 return_VALUE(result); 179 return result;
181} 180}
182 181
183static int 182static int
@@ -193,17 +192,16 @@ acpi_battery_get_status(struct acpi_battery *battery,
193 struct acpi_buffer data = { 0, NULL }; 192 struct acpi_buffer data = { 0, NULL };
194 union acpi_object *package = NULL; 193 union acpi_object *package = NULL;
195 194
196 ACPI_FUNCTION_TRACE("acpi_battery_get_status");
197 195
198 if (!battery || !bst) 196 if (!battery || !bst)
199 return_VALUE(-EINVAL); 197 return -EINVAL;
200 198
201 /* Evalute _BST */ 199 /* Evalute _BST */
202 200
203 status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer); 201 status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer);
204 if (ACPI_FAILURE(status)) { 202 if (ACPI_FAILURE(status)) {
205 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BST\n")); 203 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
206 return_VALUE(-ENODEV); 204 return -ENODEV;
207 } 205 }
208 206
209 package = (union acpi_object *)buffer.pointer; 207 package = (union acpi_object *)buffer.pointer;
@@ -212,7 +210,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
212 210
213 status = acpi_extract_package(package, &format, &data); 211 status = acpi_extract_package(package, &format, &data);
214 if (status != AE_BUFFER_OVERFLOW) { 212 if (status != AE_BUFFER_OVERFLOW) {
215 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n")); 213 ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST"));
216 result = -ENODEV; 214 result = -ENODEV;
217 goto end; 215 goto end;
218 } 216 }
@@ -226,7 +224,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
226 224
227 status = acpi_extract_package(package, &format, &data); 225 status = acpi_extract_package(package, &format, &data);
228 if (ACPI_FAILURE(status)) { 226 if (ACPI_FAILURE(status)) {
229 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _BST\n")); 227 ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST"));
230 kfree(data.pointer); 228 kfree(data.pointer);
231 result = -ENODEV; 229 result = -ENODEV;
232 goto end; 230 goto end;
@@ -238,7 +236,7 @@ acpi_battery_get_status(struct acpi_battery *battery,
238 if (!result) 236 if (!result)
239 (*bst) = (struct acpi_battery_status *)data.pointer; 237 (*bst) = (struct acpi_battery_status *)data.pointer;
240 238
241 return_VALUE(result); 239 return result;
242} 240}
243 241
244static int 242static int
@@ -248,25 +246,24 @@ acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm)
248 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 246 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
249 struct acpi_object_list arg_list = { 1, &arg0 }; 247 struct acpi_object_list arg_list = { 1, &arg0 };
250 248
251 ACPI_FUNCTION_TRACE("acpi_battery_set_alarm");
252 249
253 if (!battery) 250 if (!battery)
254 return_VALUE(-EINVAL); 251 return -EINVAL;
255 252
256 if (!battery->flags.alarm) 253 if (!battery->flags.alarm)
257 return_VALUE(-ENODEV); 254 return -ENODEV;
258 255
259 arg0.integer.value = alarm; 256 arg0.integer.value = alarm;
260 257
261 status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL); 258 status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL);
262 if (ACPI_FAILURE(status)) 259 if (ACPI_FAILURE(status))
263 return_VALUE(-ENODEV); 260 return -ENODEV;
264 261
265 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm)); 262 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Alarm set to %d\n", (u32) alarm));
266 263
267 battery->alarm = alarm; 264 battery->alarm = alarm;
268 265
269 return_VALUE(0); 266 return 0;
270} 267}
271 268
272static int acpi_battery_check(struct acpi_battery *battery) 269static int acpi_battery_check(struct acpi_battery *battery)
@@ -277,18 +274,17 @@ static int acpi_battery_check(struct acpi_battery *battery)
277 struct acpi_device *device = NULL; 274 struct acpi_device *device = NULL;
278 struct acpi_battery_info *bif = NULL; 275 struct acpi_battery_info *bif = NULL;
279 276
280 ACPI_FUNCTION_TRACE("acpi_battery_check");
281 277
282 if (!battery) 278 if (!battery)
283 return_VALUE(-EINVAL); 279 return -EINVAL;
284 280
285 result = acpi_bus_get_device(battery->handle, &device); 281 result = acpi_bus_get_device(battery->handle, &device);
286 if (result) 282 if (result)
287 return_VALUE(result); 283 return result;
288 284
289 result = acpi_bus_get_status(device); 285 result = acpi_bus_get_status(device);
290 if (result) 286 if (result)
291 return_VALUE(result); 287 return result;
292 288
293 /* Insertion? */ 289 /* Insertion? */
294 290
@@ -300,7 +296,7 @@ static int acpi_battery_check(struct acpi_battery *battery)
300 296
301 result = acpi_battery_get_info(battery, &bif); 297 result = acpi_battery_get_info(battery, &bif);
302 if (result) 298 if (result)
303 return_VALUE(result); 299 return result;
304 300
305 battery->flags.power_unit = bif->power_unit; 301 battery->flags.power_unit = bif->power_unit;
306 battery->trips.warning = bif->design_capacity_warning; 302 battery->trips.warning = bif->design_capacity_warning;
@@ -324,7 +320,7 @@ static int acpi_battery_check(struct acpi_battery *battery)
324 320
325 battery->flags.present = device->status.battery_present; 321 battery->flags.present = device->status.battery_present;
326 322
327 return_VALUE(result); 323 return result;
328} 324}
329 325
330/* -------------------------------------------------------------------------- 326/* --------------------------------------------------------------------------
@@ -339,7 +335,6 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
339 struct acpi_battery_info *bif = NULL; 335 struct acpi_battery_info *bif = NULL;
340 char *units = "?"; 336 char *units = "?";
341 337
342 ACPI_FUNCTION_TRACE("acpi_battery_read_info");
343 338
344 if (!battery) 339 if (!battery)
345 goto end; 340 goto end;
@@ -409,7 +404,7 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
409 end: 404 end:
410 kfree(bif); 405 kfree(bif);
411 406
412 return_VALUE(0); 407 return 0;
413} 408}
414 409
415static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) 410static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
@@ -424,7 +419,6 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
424 struct acpi_battery_status *bst = NULL; 419 struct acpi_battery_status *bst = NULL;
425 char *units = "?"; 420 char *units = "?";
426 421
427 ACPI_FUNCTION_TRACE("acpi_battery_read_state");
428 422
429 if (!battery) 423 if (!battery)
430 goto end; 424 goto end;
@@ -458,8 +452,6 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
458 if ((bst->state & 0x01) && (bst->state & 0x02)) { 452 if ((bst->state & 0x01) && (bst->state & 0x02)) {
459 seq_printf(seq, 453 seq_printf(seq,
460 "charging state: charging/discharging\n"); 454 "charging state: charging/discharging\n");
461 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
462 "Battery Charging and Discharging?\n"));
463 } else if (bst->state & 0x01) 455 } else if (bst->state & 0x01)
464 seq_printf(seq, "charging state: discharging\n"); 456 seq_printf(seq, "charging state: discharging\n");
465 else if (bst->state & 0x02) 457 else if (bst->state & 0x02)
@@ -489,7 +481,7 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
489 end: 481 end:
490 kfree(bst); 482 kfree(bst);
491 483
492 return_VALUE(0); 484 return 0;
493} 485}
494 486
495static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) 487static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
@@ -502,7 +494,6 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
502 struct acpi_battery *battery = (struct acpi_battery *)seq->private; 494 struct acpi_battery *battery = (struct acpi_battery *)seq->private;
503 char *units = "?"; 495 char *units = "?";
504 496
505 ACPI_FUNCTION_TRACE("acpi_battery_read_alarm");
506 497
507 if (!battery) 498 if (!battery)
508 goto end; 499 goto end;
@@ -527,7 +518,7 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
527 seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units); 518 seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units);
528 519
529 end: 520 end:
530 return_VALUE(0); 521 return 0;
531} 522}
532 523
533static ssize_t 524static ssize_t
@@ -540,25 +531,24 @@ acpi_battery_write_alarm(struct file *file,
540 struct seq_file *m = (struct seq_file *)file->private_data; 531 struct seq_file *m = (struct seq_file *)file->private_data;
541 struct acpi_battery *battery = (struct acpi_battery *)m->private; 532 struct acpi_battery *battery = (struct acpi_battery *)m->private;
542 533
543 ACPI_FUNCTION_TRACE("acpi_battery_write_alarm");
544 534
545 if (!battery || (count > sizeof(alarm_string) - 1)) 535 if (!battery || (count > sizeof(alarm_string) - 1))
546 return_VALUE(-EINVAL); 536 return -EINVAL;
547 537
548 if (!battery->flags.present) 538 if (!battery->flags.present)
549 return_VALUE(-ENODEV); 539 return -ENODEV;
550 540
551 if (copy_from_user(alarm_string, buffer, count)) 541 if (copy_from_user(alarm_string, buffer, count))
552 return_VALUE(-EFAULT); 542 return -EFAULT;
553 543
554 alarm_string[count] = '\0'; 544 alarm_string[count] = '\0';
555 545
556 result = acpi_battery_set_alarm(battery, 546 result = acpi_battery_set_alarm(battery,
557 simple_strtoul(alarm_string, NULL, 0)); 547 simple_strtoul(alarm_string, NULL, 0));
558 if (result) 548 if (result)
559 return_VALUE(result); 549 return result;
560 550
561 return_VALUE(count); 551 return count;
562} 552}
563 553
564static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) 554static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
@@ -595,13 +585,12 @@ static int acpi_battery_add_fs(struct acpi_device *device)
595{ 585{
596 struct proc_dir_entry *entry = NULL; 586 struct proc_dir_entry *entry = NULL;
597 587
598 ACPI_FUNCTION_TRACE("acpi_battery_add_fs");
599 588
600 if (!acpi_device_dir(device)) { 589 if (!acpi_device_dir(device)) {
601 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 590 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
602 acpi_battery_dir); 591 acpi_battery_dir);
603 if (!acpi_device_dir(device)) 592 if (!acpi_device_dir(device))
604 return_VALUE(-ENODEV); 593 return -ENODEV;
605 acpi_device_dir(device)->owner = THIS_MODULE; 594 acpi_device_dir(device)->owner = THIS_MODULE;
606 } 595 }
607 596
@@ -609,9 +598,7 @@ static int acpi_battery_add_fs(struct acpi_device *device)
609 entry = create_proc_entry(ACPI_BATTERY_FILE_INFO, 598 entry = create_proc_entry(ACPI_BATTERY_FILE_INFO,
610 S_IRUGO, acpi_device_dir(device)); 599 S_IRUGO, acpi_device_dir(device));
611 if (!entry) 600 if (!entry)
612 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 601 return -ENODEV;
613 "Unable to create '%s' fs entry\n",
614 ACPI_BATTERY_FILE_INFO));
615 else { 602 else {
616 entry->proc_fops = &acpi_battery_info_ops; 603 entry->proc_fops = &acpi_battery_info_ops;
617 entry->data = acpi_driver_data(device); 604 entry->data = acpi_driver_data(device);
@@ -622,9 +609,7 @@ static int acpi_battery_add_fs(struct acpi_device *device)
622 entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS, 609 entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS,
623 S_IRUGO, acpi_device_dir(device)); 610 S_IRUGO, acpi_device_dir(device));
624 if (!entry) 611 if (!entry)
625 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 612 return -ENODEV;
626 "Unable to create '%s' fs entry\n",
627 ACPI_BATTERY_FILE_STATUS));
628 else { 613 else {
629 entry->proc_fops = &acpi_battery_state_ops; 614 entry->proc_fops = &acpi_battery_state_ops;
630 entry->data = acpi_driver_data(device); 615 entry->data = acpi_driver_data(device);
@@ -636,21 +621,18 @@ static int acpi_battery_add_fs(struct acpi_device *device)
636 S_IFREG | S_IRUGO | S_IWUSR, 621 S_IFREG | S_IRUGO | S_IWUSR,
637 acpi_device_dir(device)); 622 acpi_device_dir(device));
638 if (!entry) 623 if (!entry)
639 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 624 return -ENODEV;
640 "Unable to create '%s' fs entry\n",
641 ACPI_BATTERY_FILE_ALARM));
642 else { 625 else {
643 entry->proc_fops = &acpi_battery_alarm_ops; 626 entry->proc_fops = &acpi_battery_alarm_ops;
644 entry->data = acpi_driver_data(device); 627 entry->data = acpi_driver_data(device);
645 entry->owner = THIS_MODULE; 628 entry->owner = THIS_MODULE;
646 } 629 }
647 630
648 return_VALUE(0); 631 return 0;
649} 632}
650 633
651static int acpi_battery_remove_fs(struct acpi_device *device) 634static int acpi_battery_remove_fs(struct acpi_device *device)
652{ 635{
653 ACPI_FUNCTION_TRACE("acpi_battery_remove_fs");
654 636
655 if (acpi_device_dir(device)) { 637 if (acpi_device_dir(device)) {
656 remove_proc_entry(ACPI_BATTERY_FILE_ALARM, 638 remove_proc_entry(ACPI_BATTERY_FILE_ALARM,
@@ -664,7 +646,7 @@ static int acpi_battery_remove_fs(struct acpi_device *device)
664 acpi_device_dir(device) = NULL; 646 acpi_device_dir(device) = NULL;
665 } 647 }
666 648
667 return_VALUE(0); 649 return 0;
668} 650}
669 651
670/* -------------------------------------------------------------------------- 652/* --------------------------------------------------------------------------
@@ -676,13 +658,12 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
676 struct acpi_battery *battery = (struct acpi_battery *)data; 658 struct acpi_battery *battery = (struct acpi_battery *)data;
677 struct acpi_device *device = NULL; 659 struct acpi_device *device = NULL;
678 660
679 ACPI_FUNCTION_TRACE("acpi_battery_notify");
680 661
681 if (!battery) 662 if (!battery)
682 return_VOID; 663 return;
683 664
684 if (acpi_bus_get_device(handle, &device)) 665 if (acpi_bus_get_device(handle, &device))
685 return_VOID; 666 return;
686 667
687 switch (event) { 668 switch (event) {
688 case ACPI_BATTERY_NOTIFY_STATUS: 669 case ACPI_BATTERY_NOTIFY_STATUS:
@@ -696,7 +677,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
696 break; 677 break;
697 } 678 }
698 679
699 return_VOID; 680 return;
700} 681}
701 682
702static int acpi_battery_add(struct acpi_device *device) 683static int acpi_battery_add(struct acpi_device *device)
@@ -705,14 +686,13 @@ static int acpi_battery_add(struct acpi_device *device)
705 acpi_status status = 0; 686 acpi_status status = 0;
706 struct acpi_battery *battery = NULL; 687 struct acpi_battery *battery = NULL;
707 688
708 ACPI_FUNCTION_TRACE("acpi_battery_add");
709 689
710 if (!device) 690 if (!device)
711 return_VALUE(-EINVAL); 691 return -EINVAL;
712 692
713 battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL); 693 battery = kmalloc(sizeof(struct acpi_battery), GFP_KERNEL);
714 if (!battery) 694 if (!battery)
715 return_VALUE(-ENOMEM); 695 return -ENOMEM;
716 memset(battery, 0, sizeof(struct acpi_battery)); 696 memset(battery, 0, sizeof(struct acpi_battery));
717 697
718 battery->handle = device->handle; 698 battery->handle = device->handle;
@@ -732,8 +712,6 @@ static int acpi_battery_add(struct acpi_device *device)
732 ACPI_DEVICE_NOTIFY, 712 ACPI_DEVICE_NOTIFY,
733 acpi_battery_notify, battery); 713 acpi_battery_notify, battery);
734 if (ACPI_FAILURE(status)) { 714 if (ACPI_FAILURE(status)) {
735 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
736 "Error installing notify handler\n"));
737 result = -ENODEV; 715 result = -ENODEV;
738 goto end; 716 goto end;
739 } 717 }
@@ -748,7 +726,7 @@ static int acpi_battery_add(struct acpi_device *device)
748 kfree(battery); 726 kfree(battery);
749 } 727 }
750 728
751 return_VALUE(result); 729 return result;
752} 730}
753 731
754static int acpi_battery_remove(struct acpi_device *device, int type) 732static int acpi_battery_remove(struct acpi_device *device, int type)
@@ -756,56 +734,50 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
756 acpi_status status = 0; 734 acpi_status status = 0;
757 struct acpi_battery *battery = NULL; 735 struct acpi_battery *battery = NULL;
758 736
759 ACPI_FUNCTION_TRACE("acpi_battery_remove");
760 737
761 if (!device || !acpi_driver_data(device)) 738 if (!device || !acpi_driver_data(device))
762 return_VALUE(-EINVAL); 739 return -EINVAL;
763 740
764 battery = (struct acpi_battery *)acpi_driver_data(device); 741 battery = (struct acpi_battery *)acpi_driver_data(device);
765 742
766 status = acpi_remove_notify_handler(battery->handle, 743 status = acpi_remove_notify_handler(battery->handle,
767 ACPI_DEVICE_NOTIFY, 744 ACPI_DEVICE_NOTIFY,
768 acpi_battery_notify); 745 acpi_battery_notify);
769 if (ACPI_FAILURE(status))
770 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
771 "Error removing notify handler\n"));
772 746
773 acpi_battery_remove_fs(device); 747 acpi_battery_remove_fs(device);
774 748
775 kfree(battery); 749 kfree(battery);
776 750
777 return_VALUE(0); 751 return 0;
778} 752}
779 753
780static int __init acpi_battery_init(void) 754static int __init acpi_battery_init(void)
781{ 755{
782 int result = 0; 756 int result = 0;
783 757
784 ACPI_FUNCTION_TRACE("acpi_battery_init");
785 758
786 acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir); 759 acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir);
787 if (!acpi_battery_dir) 760 if (!acpi_battery_dir)
788 return_VALUE(-ENODEV); 761 return -ENODEV;
789 acpi_battery_dir->owner = THIS_MODULE; 762 acpi_battery_dir->owner = THIS_MODULE;
790 763
791 result = acpi_bus_register_driver(&acpi_battery_driver); 764 result = acpi_bus_register_driver(&acpi_battery_driver);
792 if (result < 0) { 765 if (result < 0) {
793 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); 766 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
794 return_VALUE(-ENODEV); 767 return -ENODEV;
795 } 768 }
796 769
797 return_VALUE(0); 770 return 0;
798} 771}
799 772
800static void __exit acpi_battery_exit(void) 773static void __exit acpi_battery_exit(void)
801{ 774{
802 ACPI_FUNCTION_TRACE("acpi_battery_exit");
803 775
804 acpi_bus_unregister_driver(&acpi_battery_driver); 776 acpi_bus_unregister_driver(&acpi_battery_driver);
805 777
806 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); 778 remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir);
807 779
808 return_VOID; 780 return;
809} 781}
810 782
811module_init(acpi_battery_init); 783module_init(acpi_battery_init);
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index dd3983cece92..dec044c04273 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -60,21 +60,19 @@ int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device)
60{ 60{
61 acpi_status status = AE_OK; 61 acpi_status status = AE_OK;
62 62
63 ACPI_FUNCTION_TRACE("acpi_bus_get_device");
64 63
65 if (!device) 64 if (!device)
66 return_VALUE(-EINVAL); 65 return -EINVAL;
67 66
68 /* TBD: Support fixed-feature devices */ 67 /* TBD: Support fixed-feature devices */
69 68
70 status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device); 69 status = acpi_get_data(handle, acpi_bus_data_handler, (void **)device);
71 if (ACPI_FAILURE(status) || !*device) { 70 if (ACPI_FAILURE(status) || !*device) {
72 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "No context for object [%p]\n", 71 ACPI_EXCEPTION((AE_INFO, status, "No context for object [%p]", handle));
73 handle)); 72 return -ENODEV;
74 return_VALUE(-ENODEV);
75 } 73 }
76 74
77 return_VALUE(0); 75 return 0;
78} 76}
79 77
80EXPORT_SYMBOL(acpi_bus_get_device); 78EXPORT_SYMBOL(acpi_bus_get_device);
@@ -84,10 +82,9 @@ int acpi_bus_get_status(struct acpi_device *device)
84 acpi_status status = AE_OK; 82 acpi_status status = AE_OK;
85 unsigned long sta = 0; 83 unsigned long sta = 0;
86 84
87 ACPI_FUNCTION_TRACE("acpi_bus_get_status");
88 85
89 if (!device) 86 if (!device)
90 return_VALUE(-EINVAL); 87 return -EINVAL;
91 88
92 /* 89 /*
93 * Evaluate _STA if present. 90 * Evaluate _STA if present.
@@ -96,7 +93,7 @@ int acpi_bus_get_status(struct acpi_device *device)
96 status = 93 status =
97 acpi_evaluate_integer(device->handle, "_STA", NULL, &sta); 94 acpi_evaluate_integer(device->handle, "_STA", NULL, &sta);
98 if (ACPI_FAILURE(status)) 95 if (ACPI_FAILURE(status))
99 return_VALUE(-ENODEV); 96 return -ENODEV;
100 STRUCT_TO_INT(device->status) = (int)sta; 97 STRUCT_TO_INT(device->status) = (int)sta;
101 } 98 }
102 99
@@ -120,7 +117,7 @@ int acpi_bus_get_status(struct acpi_device *device)
120 device->pnp.bus_id, 117 device->pnp.bus_id,
121 (u32) STRUCT_TO_INT(device->status))); 118 (u32) STRUCT_TO_INT(device->status)));
122 119
123 return_VALUE(0); 120 return 0;
124} 121}
125 122
126EXPORT_SYMBOL(acpi_bus_get_status); 123EXPORT_SYMBOL(acpi_bus_get_status);
@@ -136,11 +133,10 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
136 struct acpi_device *device = NULL; 133 struct acpi_device *device = NULL;
137 unsigned long psc = 0; 134 unsigned long psc = 0;
138 135
139 ACPI_FUNCTION_TRACE("acpi_bus_get_power");
140 136
141 result = acpi_bus_get_device(handle, &device); 137 result = acpi_bus_get_device(handle, &device);
142 if (result) 138 if (result)
143 return_VALUE(result); 139 return result;
144 140
145 *state = ACPI_STATE_UNKNOWN; 141 *state = ACPI_STATE_UNKNOWN;
146 142
@@ -159,12 +155,12 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
159 status = acpi_evaluate_integer(device->handle, "_PSC", 155 status = acpi_evaluate_integer(device->handle, "_PSC",
160 NULL, &psc); 156 NULL, &psc);
161 if (ACPI_FAILURE(status)) 157 if (ACPI_FAILURE(status))
162 return_VALUE(-ENODEV); 158 return -ENODEV;
163 device->power.state = (int)psc; 159 device->power.state = (int)psc;
164 } else if (device->power.flags.power_resources) { 160 } else if (device->power.flags.power_resources) {
165 result = acpi_power_get_inferred_state(device); 161 result = acpi_power_get_inferred_state(device);
166 if (result) 162 if (result)
167 return_VALUE(result); 163 return result;
168 } 164 }
169 165
170 *state = device->power.state; 166 *state = device->power.state;
@@ -173,7 +169,7 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
173 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n", 169 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is D%d\n",
174 device->pnp.bus_id, device->power.state)); 170 device->pnp.bus_id, device->power.state));
175 171
176 return_VALUE(0); 172 return 0;
177} 173}
178 174
179EXPORT_SYMBOL(acpi_bus_get_power); 175EXPORT_SYMBOL(acpi_bus_get_power);
@@ -185,21 +181,20 @@ int acpi_bus_set_power(acpi_handle handle, int state)
185 struct acpi_device *device = NULL; 181 struct acpi_device *device = NULL;
186 char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' }; 182 char object_name[5] = { '_', 'P', 'S', '0' + state, '\0' };
187 183
188 ACPI_FUNCTION_TRACE("acpi_bus_set_power");
189 184
190 result = acpi_bus_get_device(handle, &device); 185 result = acpi_bus_get_device(handle, &device);
191 if (result) 186 if (result)
192 return_VALUE(result); 187 return result;
193 188
194 if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) 189 if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
195 return_VALUE(-EINVAL); 190 return -EINVAL;
196 191
197 /* Make sure this is a valid target state */ 192 /* Make sure this is a valid target state */
198 193
199 if (!device->flags.power_manageable) { 194 if (!device->flags.power_manageable) {
200 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 195 printk(KERN_DEBUG "Device `[%s]is not power manageable",
201 "Device is not power manageable\n")); 196 device->kobj.name);
202 return_VALUE(-ENODEV); 197 return -ENODEV;
203 } 198 }
204 /* 199 /*
205 * Get device's current power state if it's unknown 200 * Get device's current power state if it's unknown
@@ -211,18 +206,18 @@ int acpi_bus_set_power(acpi_handle handle, int state)
211 if (state == device->power.state) { 206 if (state == device->power.state) {
212 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", 207 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n",
213 state)); 208 state));
214 return_VALUE(0); 209 return 0;
215 } 210 }
216 } 211 }
217 if (!device->power.states[state].flags.valid) { 212 if (!device->power.states[state].flags.valid) {
218 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Device does not support D%d\n", 213 printk(KERN_WARNING PREFIX "Device does not support D%d\n", state);
219 state)); 214 return -ENODEV;
220 return_VALUE(-ENODEV);
221 } 215 }
222 if (device->parent && (state < device->parent->power.state)) { 216 if (device->parent && (state < device->parent->power.state)) {
223 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 217 printk(KERN_WARNING PREFIX
224 "Cannot set device to a higher-powered state than parent\n")); 218 "Cannot set device to a higher-powered"
225 return_VALUE(-ENODEV); 219 " state than parent\n");
220 return -ENODEV;
226 } 221 }
227 222
228 /* 223 /*
@@ -264,15 +259,15 @@ int acpi_bus_set_power(acpi_handle handle, int state)
264 259
265 end: 260 end:
266 if (result) 261 if (result)
267 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 262 printk(KERN_WARNING PREFIX
268 "Error transitioning device [%s] to D%d\n", 263 "Transitioning device [%s] to D%d\n",
269 device->pnp.bus_id, state)); 264 device->pnp.bus_id, state);
270 else 265 else
271 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 266 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
272 "Device [%s] transitioned to D%d\n", 267 "Device [%s] transitioned to D%d\n",
273 device->pnp.bus_id, state)); 268 device->pnp.bus_id, state));
274 269
275 return_VALUE(result); 270 return result;
276} 271}
277 272
278EXPORT_SYMBOL(acpi_bus_set_power); 273EXPORT_SYMBOL(acpi_bus_set_power);
@@ -293,18 +288,17 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
293 struct acpi_bus_event *event = NULL; 288 struct acpi_bus_event *event = NULL;
294 unsigned long flags = 0; 289 unsigned long flags = 0;
295 290
296 ACPI_FUNCTION_TRACE("acpi_bus_generate_event");
297 291
298 if (!device) 292 if (!device)
299 return_VALUE(-EINVAL); 293 return -EINVAL;
300 294
301 /* drop event on the floor if no one's listening */ 295 /* drop event on the floor if no one's listening */
302 if (!event_is_open) 296 if (!event_is_open)
303 return_VALUE(0); 297 return 0;
304 298
305 event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC); 299 event = kmalloc(sizeof(struct acpi_bus_event), GFP_ATOMIC);
306 if (!event) 300 if (!event)
307 return_VALUE(-ENOMEM); 301 return -ENOMEM;
308 302
309 strcpy(event->device_class, device->pnp.device_class); 303 strcpy(event->device_class, device->pnp.device_class);
310 strcpy(event->bus_id, device->pnp.bus_id); 304 strcpy(event->bus_id, device->pnp.bus_id);
@@ -317,7 +311,7 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
317 311
318 wake_up_interruptible(&acpi_bus_event_queue); 312 wake_up_interruptible(&acpi_bus_event_queue);
319 313
320 return_VALUE(0); 314 return 0;
321} 315}
322 316
323EXPORT_SYMBOL(acpi_bus_generate_event); 317EXPORT_SYMBOL(acpi_bus_generate_event);
@@ -329,10 +323,9 @@ int acpi_bus_receive_event(struct acpi_bus_event *event)
329 323
330 DECLARE_WAITQUEUE(wait, current); 324 DECLARE_WAITQUEUE(wait, current);
331 325
332 ACPI_FUNCTION_TRACE("acpi_bus_receive_event");
333 326
334 if (!event) 327 if (!event)
335 return_VALUE(-EINVAL); 328 return -EINVAL;
336 329
337 if (list_empty(&acpi_bus_event_list)) { 330 if (list_empty(&acpi_bus_event_list)) {
338 331
@@ -346,7 +339,7 @@ int acpi_bus_receive_event(struct acpi_bus_event *event)
346 set_current_state(TASK_RUNNING); 339 set_current_state(TASK_RUNNING);
347 340
348 if (signal_pending(current)) 341 if (signal_pending(current))
349 return_VALUE(-ERESTARTSYS); 342 return -ERESTARTSYS;
350 } 343 }
351 344
352 spin_lock_irqsave(&acpi_bus_event_lock, flags); 345 spin_lock_irqsave(&acpi_bus_event_lock, flags);
@@ -357,13 +350,13 @@ int acpi_bus_receive_event(struct acpi_bus_event *event)
357 spin_unlock_irqrestore(&acpi_bus_event_lock, flags); 350 spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
358 351
359 if (!entry) 352 if (!entry)
360 return_VALUE(-ENODEV); 353 return -ENODEV;
361 354
362 memcpy(event, entry, sizeof(struct acpi_bus_event)); 355 memcpy(event, entry, sizeof(struct acpi_bus_event));
363 356
364 kfree(entry); 357 kfree(entry);
365 358
366 return_VALUE(0); 359 return 0;
367} 360}
368 361
369EXPORT_SYMBOL(acpi_bus_receive_event); 362EXPORT_SYMBOL(acpi_bus_receive_event);
@@ -378,10 +371,9 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed)
378 acpi_status status = 0; 371 acpi_status status = 0;
379 struct acpi_device_status old_status; 372 struct acpi_device_status old_status;
380 373
381 ACPI_FUNCTION_TRACE("acpi_bus_check_device");
382 374
383 if (!device) 375 if (!device)
384 return_VALUE(-EINVAL); 376 return -EINVAL;
385 377
386 if (status_changed) 378 if (status_changed)
387 *status_changed = 0; 379 *status_changed = 0;
@@ -398,15 +390,15 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed)
398 if (status_changed) 390 if (status_changed)
399 *status_changed = 1; 391 *status_changed = 1;
400 } 392 }
401 return_VALUE(0); 393 return 0;
402 } 394 }
403 395
404 status = acpi_bus_get_status(device); 396 status = acpi_bus_get_status(device);
405 if (ACPI_FAILURE(status)) 397 if (ACPI_FAILURE(status))
406 return_VALUE(-ENODEV); 398 return -ENODEV;
407 399
408 if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status)) 400 if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status))
409 return_VALUE(0); 401 return 0;
410 402
411 if (status_changed) 403 if (status_changed)
412 *status_changed = 1; 404 *status_changed = 1;
@@ -422,7 +414,7 @@ acpi_bus_check_device(struct acpi_device *device, int *status_changed)
422 /* TBD: Handle device removal */ 414 /* TBD: Handle device removal */
423 } 415 }
424 416
425 return_VALUE(0); 417 return 0;
426} 418}
427 419
428static int acpi_bus_check_scope(struct acpi_device *device) 420static int acpi_bus_check_scope(struct acpi_device *device)
@@ -430,25 +422,24 @@ static int acpi_bus_check_scope(struct acpi_device *device)
430 int result = 0; 422 int result = 0;
431 int status_changed = 0; 423 int status_changed = 0;
432 424
433 ACPI_FUNCTION_TRACE("acpi_bus_check_scope");
434 425
435 if (!device) 426 if (!device)
436 return_VALUE(-EINVAL); 427 return -EINVAL;
437 428
438 /* Status Change? */ 429 /* Status Change? */
439 result = acpi_bus_check_device(device, &status_changed); 430 result = acpi_bus_check_device(device, &status_changed);
440 if (result) 431 if (result)
441 return_VALUE(result); 432 return result;
442 433
443 if (!status_changed) 434 if (!status_changed)
444 return_VALUE(0); 435 return 0;
445 436
446 /* 437 /*
447 * TBD: Enumerate child devices within this device's scope and 438 * TBD: Enumerate child devices within this device's scope and
448 * run acpi_bus_check_device()'s on them. 439 * run acpi_bus_check_device()'s on them.
449 */ 440 */
450 441
451 return_VALUE(0); 442 return 0;
452} 443}
453 444
454/** 445/**
@@ -461,10 +452,9 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
461 int result = 0; 452 int result = 0;
462 struct acpi_device *device = NULL; 453 struct acpi_device *device = NULL;
463 454
464 ACPI_FUNCTION_TRACE("acpi_bus_notify");
465 455
466 if (acpi_bus_get_device(handle, &device)) 456 if (acpi_bus_get_device(handle, &device))
467 return_VOID; 457 return;
468 458
469 switch (type) { 459 switch (type) {
470 460
@@ -539,7 +529,7 @@ static void acpi_bus_notify(acpi_handle handle, u32 type, void *data)
539 break; 529 break;
540 } 530 }
541 531
542 return_VOID; 532 return;
543} 533}
544 534
545/* -------------------------------------------------------------------------- 535/* --------------------------------------------------------------------------
@@ -553,7 +543,6 @@ static int __init acpi_bus_init_irq(void)
553 struct acpi_object_list arg_list = { 1, &arg }; 543 struct acpi_object_list arg_list = { 1, &arg };
554 char *message = NULL; 544 char *message = NULL;
555 545
556 ACPI_FUNCTION_TRACE("acpi_bus_init_irq");
557 546
558 /* 547 /*
559 * Let the system know what interrupt model we are using by 548 * Let the system know what interrupt model we are using by
@@ -572,7 +561,7 @@ static int __init acpi_bus_init_irq(void)
572 break; 561 break;
573 default: 562 default:
574 printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n"); 563 printk(KERN_WARNING PREFIX "Unknown interrupt routing model\n");
575 return_VALUE(-ENODEV); 564 return -ENODEV;
576 } 565 }
577 566
578 printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message); 567 printk(KERN_INFO PREFIX "Using %s for interrupt routing\n", message);
@@ -581,11 +570,11 @@ static int __init acpi_bus_init_irq(void)
581 570
582 status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL); 571 status = acpi_evaluate_object(NULL, "\\_PIC", &arg_list, NULL);
583 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 572 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
584 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PIC\n")); 573 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PIC"));
585 return_VALUE(-ENODEV); 574 return -ENODEV;
586 } 575 }
587 576
588 return_VALUE(0); 577 return 0;
589} 578}
590 579
591void __init acpi_early_init(void) 580void __init acpi_early_init(void)
@@ -593,10 +582,9 @@ void __init acpi_early_init(void)
593 acpi_status status = AE_OK; 582 acpi_status status = AE_OK;
594 struct acpi_buffer buffer = { sizeof(acpi_fadt), &acpi_fadt }; 583 struct acpi_buffer buffer = { sizeof(acpi_fadt), &acpi_fadt };
595 584
596 ACPI_FUNCTION_TRACE("acpi_early_init");
597 585
598 if (acpi_disabled) 586 if (acpi_disabled)
599 return_VOID; 587 return;
600 588
601 printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION); 589 printk(KERN_INFO PREFIX "Core revision %08x\n", ACPI_CA_VERSION);
602 590
@@ -656,11 +644,11 @@ void __init acpi_early_init(void)
656 goto error0; 644 goto error0;
657 } 645 }
658 646
659 return_VOID; 647 return;
660 648
661 error0: 649 error0:
662 disable_acpi(); 650 disable_acpi();
663 return_VOID; 651 return;
664} 652}
665 653
666static int __init acpi_bus_init(void) 654static int __init acpi_bus_init(void)
@@ -669,7 +657,6 @@ static int __init acpi_bus_init(void)
669 acpi_status status = AE_OK; 657 acpi_status status = AE_OK;
670 extern acpi_status acpi_os_initialize1(void); 658 extern acpi_status acpi_os_initialize1(void);
671 659
672 ACPI_FUNCTION_TRACE("acpi_bus_init");
673 660
674 status = acpi_os_initialize1(); 661 status = acpi_os_initialize1();
675 662
@@ -731,12 +718,12 @@ static int __init acpi_bus_init(void)
731 */ 718 */
732 acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL); 719 acpi_root_dir = proc_mkdir(ACPI_BUS_FILE_ROOT, NULL);
733 720
734 return_VALUE(0); 721 return 0;
735 722
736 /* Mimic structured exception handling */ 723 /* Mimic structured exception handling */
737 error1: 724 error1:
738 acpi_terminate(); 725 acpi_terminate();
739 return_VALUE(-ENODEV); 726 return -ENODEV;
740} 727}
741 728
742decl_subsys(acpi, NULL, NULL); 729decl_subsys(acpi, NULL, NULL);
@@ -745,11 +732,10 @@ static int __init acpi_init(void)
745{ 732{
746 int result = 0; 733 int result = 0;
747 734
748 ACPI_FUNCTION_TRACE("acpi_init");
749 735
750 if (acpi_disabled) { 736 if (acpi_disabled) {
751 printk(KERN_INFO PREFIX "Interpreter disabled.\n"); 737 printk(KERN_INFO PREFIX "Interpreter disabled.\n");
752 return_VALUE(-ENODEV); 738 return -ENODEV;
753 } 739 }
754 740
755 firmware_register(&acpi_subsys); 741 firmware_register(&acpi_subsys);
@@ -770,7 +756,7 @@ static int __init acpi_init(void)
770 } else 756 } else
771 disable_acpi(); 757 disable_acpi();
772 758
773 return_VALUE(result); 759 return result;
774} 760}
775 761
776subsys_initcall(acpi_init); 762subsys_initcall(acpi_init);
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 4b6d9f0096a1..02594639c4d9 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -112,15 +112,14 @@ static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
112{ 112{
113 struct acpi_button *button = (struct acpi_button *)seq->private; 113 struct acpi_button *button = (struct acpi_button *)seq->private;
114 114
115 ACPI_FUNCTION_TRACE("acpi_button_info_seq_show");
116 115
117 if (!button || !button->device) 116 if (!button || !button->device)
118 return_VALUE(0); 117 return 0;
119 118
120 seq_printf(seq, "type: %s\n", 119 seq_printf(seq, "type: %s\n",
121 acpi_device_name(button->device)); 120 acpi_device_name(button->device));
122 121
123 return_VALUE(0); 122 return 0;
124} 123}
125 124
126static int acpi_button_info_open_fs(struct inode *inode, struct file *file) 125static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
@@ -134,10 +133,9 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
134 acpi_status status; 133 acpi_status status;
135 unsigned long state; 134 unsigned long state;
136 135
137 ACPI_FUNCTION_TRACE("acpi_button_state_seq_show");
138 136
139 if (!button || !button->device) 137 if (!button || !button->device)
140 return_VALUE(0); 138 return 0;
141 139
142 status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state); 140 status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state);
143 if (ACPI_FAILURE(status)) { 141 if (ACPI_FAILURE(status)) {
@@ -147,7 +145,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
147 (state ? "open" : "closed")); 145 (state ? "open" : "closed"));
148 } 146 }
149 147
150 return_VALUE(0); 148 return 0;
151} 149}
152 150
153static int acpi_button_state_open_fs(struct inode *inode, struct file *file) 151static int acpi_button_state_open_fs(struct inode *inode, struct file *file)
@@ -164,10 +162,9 @@ static int acpi_button_add_fs(struct acpi_device *device)
164 struct proc_dir_entry *entry = NULL; 162 struct proc_dir_entry *entry = NULL;
165 struct acpi_button *button = NULL; 163 struct acpi_button *button = NULL;
166 164
167 ACPI_FUNCTION_TRACE("acpi_button_add_fs");
168 165
169 if (!device || !acpi_driver_data(device)) 166 if (!device || !acpi_driver_data(device))
170 return_VALUE(-EINVAL); 167 return -EINVAL;
171 168
172 button = acpi_driver_data(device); 169 button = acpi_driver_data(device);
173 170
@@ -195,21 +192,19 @@ static int acpi_button_add_fs(struct acpi_device *device)
195 } 192 }
196 193
197 if (!entry) 194 if (!entry)
198 return_VALUE(-ENODEV); 195 return -ENODEV;
199 entry->owner = THIS_MODULE; 196 entry->owner = THIS_MODULE;
200 197
201 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); 198 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry);
202 if (!acpi_device_dir(device)) 199 if (!acpi_device_dir(device))
203 return_VALUE(-ENODEV); 200 return -ENODEV;
204 acpi_device_dir(device)->owner = THIS_MODULE; 201 acpi_device_dir(device)->owner = THIS_MODULE;
205 202
206 /* 'info' [R] */ 203 /* 'info' [R] */
207 entry = create_proc_entry(ACPI_BUTTON_FILE_INFO, 204 entry = create_proc_entry(ACPI_BUTTON_FILE_INFO,
208 S_IRUGO, acpi_device_dir(device)); 205 S_IRUGO, acpi_device_dir(device));
209 if (!entry) 206 if (!entry)
210 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 207 return -ENODEV;
211 "Unable to create '%s' fs entry\n",
212 ACPI_BUTTON_FILE_INFO));
213 else { 208 else {
214 entry->proc_fops = &acpi_button_info_fops; 209 entry->proc_fops = &acpi_button_info_fops;
215 entry->data = acpi_driver_data(device); 210 entry->data = acpi_driver_data(device);
@@ -221,9 +216,7 @@ static int acpi_button_add_fs(struct acpi_device *device)
221 entry = create_proc_entry(ACPI_BUTTON_FILE_STATE, 216 entry = create_proc_entry(ACPI_BUTTON_FILE_STATE,
222 S_IRUGO, acpi_device_dir(device)); 217 S_IRUGO, acpi_device_dir(device));
223 if (!entry) 218 if (!entry)
224 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 219 return -ENODEV;
225 "Unable to create '%s' fs entry\n",
226 ACPI_BUTTON_FILE_INFO));
227 else { 220 else {
228 entry->proc_fops = &acpi_button_state_fops; 221 entry->proc_fops = &acpi_button_state_fops;
229 entry->data = acpi_driver_data(device); 222 entry->data = acpi_driver_data(device);
@@ -231,14 +224,13 @@ static int acpi_button_add_fs(struct acpi_device *device)
231 } 224 }
232 } 225 }
233 226
234 return_VALUE(0); 227 return 0;
235} 228}
236 229
237static int acpi_button_remove_fs(struct acpi_device *device) 230static int acpi_button_remove_fs(struct acpi_device *device)
238{ 231{
239 struct acpi_button *button = NULL; 232 struct acpi_button *button = NULL;
240 233
241 ACPI_FUNCTION_TRACE("acpi_button_remove_fs");
242 234
243 button = acpi_driver_data(device); 235 button = acpi_driver_data(device);
244 if (acpi_device_dir(device)) { 236 if (acpi_device_dir(device)) {
@@ -253,7 +245,7 @@ static int acpi_button_remove_fs(struct acpi_device *device)
253 acpi_device_dir(device) = NULL; 245 acpi_device_dir(device) = NULL;
254 } 246 }
255 247
256 return_VALUE(0); 248 return 0;
257} 249}
258 250
259/* -------------------------------------------------------------------------- 251/* --------------------------------------------------------------------------
@@ -264,10 +256,9 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
264{ 256{
265 struct acpi_button *button = (struct acpi_button *)data; 257 struct acpi_button *button = (struct acpi_button *)data;
266 258
267 ACPI_FUNCTION_TRACE("acpi_button_notify");
268 259
269 if (!button || !button->device) 260 if (!button || !button->device)
270 return_VOID; 261 return;
271 262
272 switch (event) { 263 switch (event) {
273 case ACPI_BUTTON_NOTIFY_STATUS: 264 case ACPI_BUTTON_NOTIFY_STATUS:
@@ -280,21 +271,20 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
280 break; 271 break;
281 } 272 }
282 273
283 return_VOID; 274 return;
284} 275}
285 276
286static acpi_status acpi_button_notify_fixed(void *data) 277static acpi_status acpi_button_notify_fixed(void *data)
287{ 278{
288 struct acpi_button *button = (struct acpi_button *)data; 279 struct acpi_button *button = (struct acpi_button *)data;
289 280
290 ACPI_FUNCTION_TRACE("acpi_button_notify_fixed");
291 281
292 if (!button) 282 if (!button)
293 return_ACPI_STATUS(AE_BAD_PARAMETER); 283 return AE_BAD_PARAMETER;
294 284
295 acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); 285 acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button);
296 286
297 return_ACPI_STATUS(AE_OK); 287 return AE_OK;
298} 288}
299 289
300static int acpi_button_add(struct acpi_device *device) 290static int acpi_button_add(struct acpi_device *device)
@@ -303,14 +293,13 @@ static int acpi_button_add(struct acpi_device *device)
303 acpi_status status = AE_OK; 293 acpi_status status = AE_OK;
304 struct acpi_button *button = NULL; 294 struct acpi_button *button = NULL;
305 295
306 ACPI_FUNCTION_TRACE("acpi_button_add");
307 296
308 if (!device) 297 if (!device)
309 return_VALUE(-EINVAL); 298 return -EINVAL;
310 299
311 button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL); 300 button = kmalloc(sizeof(struct acpi_button), GFP_KERNEL);
312 if (!button) 301 if (!button)
313 return_VALUE(-ENOMEM); 302 return -ENOMEM;
314 memset(button, 0, sizeof(struct acpi_button)); 303 memset(button, 0, sizeof(struct acpi_button));
315 304
316 button->device = device; 305 button->device = device;
@@ -349,8 +338,8 @@ static int acpi_button_add(struct acpi_device *device)
349 sprintf(acpi_device_class(device), "%s/%s", 338 sprintf(acpi_device_class(device), "%s/%s",
350 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); 339 ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
351 } else { 340 } else {
352 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n", 341 printk(KERN_ERR PREFIX "Unsupported hid [%s]\n",
353 acpi_device_hid(device))); 342 acpi_device_hid(device));
354 result = -ENODEV; 343 result = -ENODEV;
355 goto end; 344 goto end;
356 } 345 }
@@ -381,8 +370,6 @@ static int acpi_button_add(struct acpi_device *device)
381 } 370 }
382 371
383 if (ACPI_FAILURE(status)) { 372 if (ACPI_FAILURE(status)) {
384 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
385 "Error installing notify handler\n"));
386 result = -ENODEV; 373 result = -ENODEV;
387 goto end; 374 goto end;
388 } 375 }
@@ -406,7 +393,7 @@ static int acpi_button_add(struct acpi_device *device)
406 kfree(button); 393 kfree(button);
407 } 394 }
408 395
409 return_VALUE(result); 396 return result;
410} 397}
411 398
412static int acpi_button_remove(struct acpi_device *device, int type) 399static int acpi_button_remove(struct acpi_device *device, int type)
@@ -414,10 +401,9 @@ static int acpi_button_remove(struct acpi_device *device, int type)
414 acpi_status status = 0; 401 acpi_status status = 0;
415 struct acpi_button *button = NULL; 402 struct acpi_button *button = NULL;
416 403
417 ACPI_FUNCTION_TRACE("acpi_button_remove");
418 404
419 if (!device || !acpi_driver_data(device)) 405 if (!device || !acpi_driver_data(device))
420 return_VALUE(-EINVAL); 406 return -EINVAL;
421 407
422 button = acpi_driver_data(device); 408 button = acpi_driver_data(device);
423 409
@@ -440,39 +426,33 @@ static int acpi_button_remove(struct acpi_device *device, int type)
440 break; 426 break;
441 } 427 }
442 428
443 if (ACPI_FAILURE(status))
444 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
445 "Error removing notify handler\n"));
446
447 acpi_button_remove_fs(device); 429 acpi_button_remove_fs(device);
448 430
449 kfree(button); 431 kfree(button);
450 432
451 return_VALUE(0); 433 return 0;
452} 434}
453 435
454static int __init acpi_button_init(void) 436static int __init acpi_button_init(void)
455{ 437{
456 int result = 0; 438 int result = 0;
457 439
458 ACPI_FUNCTION_TRACE("acpi_button_init");
459 440
460 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir); 441 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
461 if (!acpi_button_dir) 442 if (!acpi_button_dir)
462 return_VALUE(-ENODEV); 443 return -ENODEV;
463 acpi_button_dir->owner = THIS_MODULE; 444 acpi_button_dir->owner = THIS_MODULE;
464 result = acpi_bus_register_driver(&acpi_button_driver); 445 result = acpi_bus_register_driver(&acpi_button_driver);
465 if (result < 0) { 446 if (result < 0) {
466 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 447 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
467 return_VALUE(-ENODEV); 448 return -ENODEV;
468 } 449 }
469 450
470 return_VALUE(0); 451 return 0;
471} 452}
472 453
473static void __exit acpi_button_exit(void) 454static void __exit acpi_button_exit(void)
474{ 455{
475 ACPI_FUNCTION_TRACE("acpi_button_exit");
476 456
477 acpi_bus_unregister_driver(&acpi_button_driver); 457 acpi_bus_unregister_driver(&acpi_button_driver);
478 458
@@ -484,7 +464,7 @@ static void __exit acpi_button_exit(void)
484 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir); 464 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
485 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir); 465 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
486 466
487 return_VOID; 467 return;
488} 468}
489 469
490module_init(acpi_button_init); 470module_init(acpi_button_init);
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index b69a8cad82b7..7f7e41d40a3b 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -73,17 +73,16 @@ static int is_device_present(acpi_handle handle)
73 acpi_status status; 73 acpi_status status;
74 unsigned long sta; 74 unsigned long sta;
75 75
76 ACPI_FUNCTION_TRACE("is_device_present");
77 76
78 status = acpi_get_handle(handle, "_STA", &temp); 77 status = acpi_get_handle(handle, "_STA", &temp);
79 if (ACPI_FAILURE(status)) 78 if (ACPI_FAILURE(status))
80 return_VALUE(1); /* _STA not found, assmue device present */ 79 return 1; /* _STA not found, assmue device present */
81 80
82 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 81 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
83 if (ACPI_FAILURE(status)) 82 if (ACPI_FAILURE(status))
84 return_VALUE(0); /* Firmware error */ 83 return 0; /* Firmware error */
85 84
86 return_VALUE((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT); 85 return ((sta & ACPI_STA_PRESENT) == ACPI_STA_PRESENT);
87} 86}
88 87
89/*******************************************************************/ 88/*******************************************************************/
@@ -91,16 +90,15 @@ static int acpi_container_add(struct acpi_device *device)
91{ 90{
92 struct acpi_container *container; 91 struct acpi_container *container;
93 92
94 ACPI_FUNCTION_TRACE("acpi_container_add");
95 93
96 if (!device) { 94 if (!device) {
97 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "device is NULL\n")); 95 printk(KERN_ERR PREFIX "device is NULL\n");
98 return_VALUE(-EINVAL); 96 return -EINVAL;
99 } 97 }
100 98
101 container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL); 99 container = kmalloc(sizeof(struct acpi_container), GFP_KERNEL);
102 if (!container) 100 if (!container)
103 return_VALUE(-ENOMEM); 101 return -ENOMEM;
104 102
105 memset(container, 0, sizeof(struct acpi_container)); 103 memset(container, 0, sizeof(struct acpi_container));
106 container->handle = device->handle; 104 container->handle = device->handle;
@@ -111,7 +109,7 @@ static int acpi_container_add(struct acpi_device *device)
111 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n", 109 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n",
112 acpi_device_name(device), acpi_device_bid(device))); 110 acpi_device_name(device), acpi_device_bid(device)));
113 111
114 return_VALUE(0); 112 return 0;
115} 113}
116 114
117static int acpi_container_remove(struct acpi_device *device, int type) 115static int acpi_container_remove(struct acpi_device *device, int type)
@@ -130,23 +128,22 @@ static int container_device_add(struct acpi_device **device, acpi_handle handle)
130 struct acpi_device *pdev; 128 struct acpi_device *pdev;
131 int result; 129 int result;
132 130
133 ACPI_FUNCTION_TRACE("container_device_add");
134 131
135 if (acpi_get_parent(handle, &phandle)) { 132 if (acpi_get_parent(handle, &phandle)) {
136 return_VALUE(-ENODEV); 133 return -ENODEV;
137 } 134 }
138 135
139 if (acpi_bus_get_device(phandle, &pdev)) { 136 if (acpi_bus_get_device(phandle, &pdev)) {
140 return_VALUE(-ENODEV); 137 return -ENODEV;
141 } 138 }
142 139
143 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) { 140 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_DEVICE)) {
144 return_VALUE(-ENODEV); 141 return -ENODEV;
145 } 142 }
146 143
147 result = acpi_bus_start(*device); 144 result = acpi_bus_start(*device);
148 145
149 return_VALUE(result); 146 return result;
150} 147}
151 148
152static void container_notify_cb(acpi_handle handle, u32 type, void *context) 149static void container_notify_cb(acpi_handle handle, u32 type, void *context)
@@ -156,7 +153,6 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
156 int present; 153 int present;
157 acpi_status status; 154 acpi_status status;
158 155
159 ACPI_FUNCTION_TRACE("container_notify_cb");
160 156
161 present = is_device_present(handle); 157 present = is_device_present(handle);
162 158
@@ -192,7 +188,7 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
192 default: 188 default:
193 break; 189 break;
194 } 190 }
195 return_VOID; 191 return;
196} 192}
197 193
198static acpi_status 194static acpi_status
@@ -205,11 +201,10 @@ container_walk_namespace_cb(acpi_handle handle,
205 acpi_status status; 201 acpi_status status;
206 int *action = context; 202 int *action = context;
207 203
208 ACPI_FUNCTION_TRACE("container_walk_namespace_cb");
209 204
210 status = acpi_get_object_info(handle, &buffer); 205 status = acpi_get_object_info(handle, &buffer);
211 if (ACPI_FAILURE(status) || !buffer.pointer) { 206 if (ACPI_FAILURE(status) || !buffer.pointer) {
212 return_ACPI_STATUS(AE_OK); 207 return AE_OK;
213 } 208 }
214 209
215 info = buffer.pointer; 210 info = buffer.pointer;
@@ -243,7 +238,7 @@ container_walk_namespace_cb(acpi_handle handle,
243 end: 238 end:
244 acpi_os_free(buffer.pointer); 239 acpi_os_free(buffer.pointer);
245 240
246 return_ACPI_STATUS(AE_OK); 241 return AE_OK;
247} 242}
248 243
249static int __init acpi_container_init(void) 244static int __init acpi_container_init(void)
@@ -269,7 +264,6 @@ static void __exit acpi_container_exit(void)
269{ 264{
270 int action = UNINSTALL_NOTIFY_HANDLER; 265 int action = UNINSTALL_NOTIFY_HANDLER;
271 266
272 ACPI_FUNCTION_TRACE("acpi_container_exit");
273 267
274 acpi_walk_namespace(ACPI_TYPE_DEVICE, 268 acpi_walk_namespace(ACPI_TYPE_DEVICE,
275 ACPI_ROOT_OBJECT, 269 ACPI_ROOT_OBJECT,
@@ -278,7 +272,7 @@ static void __exit acpi_container_exit(void)
278 272
279 acpi_bus_unregister_driver(&acpi_container_driver); 273 acpi_bus_unregister_driver(&acpi_container_driver);
280 274
281 return_VOID; 275 return;
282} 276}
283 277
284module_init(acpi_container_init); 278module_init(acpi_container_init);
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c
index 263322b7d113..35c6af8a83cd 100644
--- a/drivers/acpi/debug.c
+++ b/drivers/acpi/debug.c
@@ -155,13 +155,12 @@ acpi_system_write_debug(struct file *file,
155{ 155{
156 char debug_string[12] = { '\0' }; 156 char debug_string[12] = { '\0' };
157 157
158 ACPI_FUNCTION_TRACE("acpi_system_write_debug");
159 158
160 if (count > sizeof(debug_string) - 1) 159 if (count > sizeof(debug_string) - 1)
161 return_VALUE(-EINVAL); 160 return -EINVAL;
162 161
163 if (copy_from_user(debug_string, buffer, count)) 162 if (copy_from_user(debug_string, buffer, count))
164 return_VALUE(-EFAULT); 163 return -EFAULT;
165 164
166 debug_string[count] = '\0'; 165 debug_string[count] = '\0';
167 166
@@ -173,10 +172,10 @@ acpi_system_write_debug(struct file *file,
173 acpi_dbg_level = simple_strtoul(debug_string, NULL, 0); 172 acpi_dbg_level = simple_strtoul(debug_string, NULL, 0);
174 break; 173 break;
175 default: 174 default:
176 return_VALUE(-EINVAL); 175 return -EINVAL;
177 } 176 }
178 177
179 return_VALUE(count); 178 return count;
180} 179}
181 180
182static int __init acpi_debug_init(void) 181static int __init acpi_debug_init(void)
@@ -185,10 +184,9 @@ static int __init acpi_debug_init(void)
185 int error = 0; 184 int error = 0;
186 char *name; 185 char *name;
187 186
188 ACPI_FUNCTION_TRACE("acpi_debug_init");
189 187
190 if (acpi_disabled) 188 if (acpi_disabled)
191 return_VALUE(0); 189 return 0;
192 190
193 /* 'debug_layer' [R/W] */ 191 /* 'debug_layer' [R/W] */
194 name = ACPI_SYSTEM_FILE_DEBUG_LAYER; 192 name = ACPI_SYSTEM_FILE_DEBUG_LAYER;
@@ -213,15 +211,12 @@ static int __init acpi_debug_init(void)
213 goto Error; 211 goto Error;
214 212
215 Done: 213 Done:
216 return_VALUE(error); 214 return error;
217 215
218 Error: 216 Error:
219 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
220 "Unable to create '%s' proc fs entry\n", name));
221
222 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir); 217 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LEVEL, acpi_root_dir);
223 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir); 218 remove_proc_entry(ACPI_SYSTEM_FILE_DEBUG_LAYER, acpi_root_dir);
224 error = -EFAULT; 219 error = -ENODEV;
225 goto Done; 220 goto Done;
226} 221}
227 222
diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c
index bbdf990e9f65..daf51b5b5875 100644
--- a/drivers/acpi/dispatcher/dsinit.c
+++ b/drivers/acpi/dispatcher/dsinit.c
@@ -125,37 +125,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
125 if (info->table_desc->pointer->revision == 1) { 125 if (info->table_desc->pointer->revision == 1) {
126 node->flags |= ANOBJ_DATA_WIDTH_32; 126 node->flags |= ANOBJ_DATA_WIDTH_32;
127 } 127 }
128#ifdef ACPI_INIT_PARSE_METHODS
129 /*
130 * Note 11/2005: Removed this code to parse all methods during table
131 * load because it causes problems if there are any errors during the
132 * parse. Also, it seems like overkill and we probably don't want to
133 * abort a table load because of an issue with a single method.
134 */
135
136 /*
137 * Print a dot for each method unless we are going to print
138 * the entire pathname
139 */
140 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
141 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
142 }
143 128
144 /*
145 * Always parse methods to detect errors, we will delete
146 * the parse tree below
147 */
148 status = acpi_ds_parse_method(obj_handle);
149 if (ACPI_FAILURE(status)) {
150 ACPI_ERROR((AE_INFO,
151 "Method %p [%4.4s] - parse failure, %s",
152 obj_handle,
153 acpi_ut_get_node_name(obj_handle),
154 acpi_format_exception(status)));
155
156 /* This parse failed, but we will continue parsing more methods */
157 }
158#endif
159 info->method_count++; 129 info->method_count++;
160 break; 130 break;
161 131
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index bc9aca4e7401..a39a33f4847a 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -52,6 +52,10 @@
52#define _COMPONENT ACPI_DISPATCHER 52#define _COMPONENT ACPI_DISPATCHER
53ACPI_MODULE_NAME("dsmethod") 53ACPI_MODULE_NAME("dsmethod")
54 54
55/* Local prototypes */
56static acpi_status
57acpi_ds_create_method_mutex(union acpi_operand_object *method_desc);
58
55/******************************************************************************* 59/*******************************************************************************
56 * 60 *
57 * FUNCTION: acpi_ds_method_error 61 * FUNCTION: acpi_ds_method_error
@@ -67,6 +71,7 @@ ACPI_MODULE_NAME("dsmethod")
67 * Note: Allows the exception handler to change the status code 71 * Note: Allows the exception handler to change the status code
68 * 72 *
69 ******************************************************************************/ 73 ******************************************************************************/
74
70acpi_status 75acpi_status
71acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state) 76acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
72{ 77{
@@ -113,11 +118,51 @@ acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
113 118
114/******************************************************************************* 119/*******************************************************************************
115 * 120 *
121 * FUNCTION: acpi_ds_create_method_mutex
122 *
123 * PARAMETERS: obj_desc - The method object
124 *
125 * RETURN: Status
126 *
127 * DESCRIPTION: Create a mutex object for a serialized control method
128 *
129 ******************************************************************************/
130
131static acpi_status
132acpi_ds_create_method_mutex(union acpi_operand_object *method_desc)
133{
134 union acpi_operand_object *mutex_desc;
135 acpi_status status;
136
137 ACPI_FUNCTION_NAME(ds_create_method_mutex);
138
139 /* Create the new mutex object */
140
141 mutex_desc = acpi_ut_create_internal_object(ACPI_TYPE_MUTEX);
142 if (!mutex_desc) {
143 return_ACPI_STATUS(AE_NO_MEMORY);
144 }
145
146 /* Create the actual OS Mutex */
147
148 status = acpi_os_create_mutex(&mutex_desc->mutex.os_mutex);
149 if (ACPI_FAILURE(status)) {
150 return_ACPI_STATUS(status);
151 }
152
153 mutex_desc->mutex.sync_level = method_desc->method.sync_level;
154 method_desc->method.mutex = mutex_desc;
155 return_ACPI_STATUS(AE_OK);
156}
157
158/*******************************************************************************
159 *
116 * FUNCTION: acpi_ds_begin_method_execution 160 * FUNCTION: acpi_ds_begin_method_execution
117 * 161 *
118 * PARAMETERS: method_node - Node of the method 162 * PARAMETERS: method_node - Node of the method
119 * obj_desc - The method object 163 * obj_desc - The method object
120 * calling_method_node - Caller of this method (if non-null) 164 * walk_state - current state, NULL if not yet executing
165 * a method.
121 * 166 *
122 * RETURN: Status 167 * RETURN: Status
123 * 168 *
@@ -128,9 +173,9 @@ acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
128 ******************************************************************************/ 173 ******************************************************************************/
129 174
130acpi_status 175acpi_status
131acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node, 176acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
132 union acpi_operand_object * obj_desc, 177 union acpi_operand_object *obj_desc,
133 struct acpi_namespace_node * calling_method_node) 178 struct acpi_walk_state *walk_state)
134{ 179{
135 acpi_status status = AE_OK; 180 acpi_status status = AE_OK;
136 181
@@ -149,35 +194,80 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node,
149 } 194 }
150 195
151 /* 196 /*
152 * If there is a concurrency limit on this method, we need to 197 * If this method is serialized, we need to acquire the method mutex.
153 * obtain a unit from the method semaphore.
154 */ 198 */
155 if (obj_desc->method.semaphore) { 199 if (obj_desc->method.method_flags & AML_METHOD_SERIALIZED) {
156 /* 200 /*
157 * Allow recursive method calls, up to the reentrancy/concurrency 201 * Create a mutex for the method if it is defined to be Serialized
158 * limit imposed by the SERIALIZED rule and the sync_level method 202 * and a mutex has not already been created. We defer the mutex creation
159 * parameter. 203 * until a method is actually executed, to minimize the object count
160 *
161 * The point of this code is to avoid permanently blocking a
162 * thread that is making recursive method calls.
163 */ 204 */
164 if (method_node == calling_method_node) { 205 if (!obj_desc->method.mutex) {
165 if (obj_desc->method.thread_count >= 206 status = acpi_ds_create_method_mutex(obj_desc);
166 obj_desc->method.concurrency) { 207 if (ACPI_FAILURE(status)) {
167 return_ACPI_STATUS(AE_AML_METHOD_LIMIT); 208 return_ACPI_STATUS(status);
168 } 209 }
169 } 210 }
170 211
171 /* 212 /*
172 * Get a unit from the method semaphore. This releases the 213 * The current_sync_level (per-thread) must be less than or equal to
173 * interpreter if we block (then reacquires it) 214 * the sync level of the method. This mechanism provides some
215 * deadlock prevention
216 *
217 * Top-level method invocation has no walk state at this point
174 */ 218 */
175 status = 219 if (walk_state &&
176 acpi_ex_system_wait_semaphore(obj_desc->method.semaphore, 220 (walk_state->thread->current_sync_level >
177 ACPI_WAIT_FOREVER); 221 obj_desc->method.mutex->mutex.sync_level)) {
178 if (ACPI_FAILURE(status)) { 222 ACPI_ERROR((AE_INFO,
179 return_ACPI_STATUS(status); 223 "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%d)",
224 acpi_ut_get_node_name(method_node),
225 walk_state->thread->current_sync_level));
226
227 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
180 } 228 }
229
230 /*
231 * Obtain the method mutex if necessary. Do not acquire mutex for a
232 * recursive call.
233 */
234 if (!walk_state ||
235 !obj_desc->method.mutex->mutex.owner_thread ||
236 (walk_state->thread !=
237 obj_desc->method.mutex->mutex.owner_thread)) {
238 /*
239 * Acquire the method mutex. This releases the interpreter if we
240 * block (and reacquires it before it returns)
241 */
242 status =
243 acpi_ex_system_wait_mutex(obj_desc->method.mutex->
244 mutex.os_mutex,
245 ACPI_WAIT_FOREVER);
246 if (ACPI_FAILURE(status)) {
247 return_ACPI_STATUS(status);
248 }
249
250 /* Update the mutex and walk info and save the original sync_level */
251
252 if (walk_state) {
253 obj_desc->method.mutex->mutex.
254 original_sync_level =
255 walk_state->thread->current_sync_level;
256
257 obj_desc->method.mutex->mutex.owner_thread =
258 walk_state->thread;
259 walk_state->thread->current_sync_level =
260 obj_desc->method.sync_level;
261 } else {
262 obj_desc->method.mutex->mutex.
263 original_sync_level =
264 obj_desc->method.mutex->mutex.sync_level;
265 }
266 }
267
268 /* Always increase acquisition depth */
269
270 obj_desc->method.mutex->mutex.acquisition_depth++;
181 } 271 }
182 272
183 /* 273 /*
@@ -200,10 +290,10 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node * method_node,
200 return_ACPI_STATUS(status); 290 return_ACPI_STATUS(status);
201 291
202 cleanup: 292 cleanup:
203 /* On error, must signal the method semaphore if present */ 293 /* On error, must release the method mutex (if present) */
204 294
205 if (obj_desc->method.semaphore) { 295 if (obj_desc->method.mutex) {
206 (void)acpi_os_signal_semaphore(obj_desc->method.semaphore, 1); 296 acpi_os_release_mutex(obj_desc->method.mutex->mutex.os_mutex);
207 } 297 }
208 return_ACPI_STATUS(status); 298 return_ACPI_STATUS(status);
209} 299}
@@ -253,10 +343,10 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
253 return_ACPI_STATUS(AE_NULL_OBJECT); 343 return_ACPI_STATUS(AE_NULL_OBJECT);
254 } 344 }
255 345
256 /* Init for new method, possibly wait on concurrency semaphore */ 346 /* Init for new method, possibly wait on method mutex */
257 347
258 status = acpi_ds_begin_method_execution(method_node, obj_desc, 348 status = acpi_ds_begin_method_execution(method_node, obj_desc,
259 this_walk_state->method_node); 349 this_walk_state);
260 if (ACPI_FAILURE(status)) { 350 if (ACPI_FAILURE(status)) {
261 return_ACPI_STATUS(status); 351 return_ACPI_STATUS(status);
262 } 352 }
@@ -478,6 +568,8 @@ acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
478 * created, delete all locals and arguments, and delete the parse 568 * created, delete all locals and arguments, and delete the parse
479 * tree if requested. 569 * tree if requested.
480 * 570 *
571 * MUTEX: Interpreter is locked
572 *
481 ******************************************************************************/ 573 ******************************************************************************/
482 574
483void 575void
@@ -503,26 +595,21 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
503 } 595 }
504 596
505 /* 597 /*
506 * Lock the parser while we terminate this method. 598 * If method is serialized, release the mutex and restore the
507 * If this is the last thread executing the method, 599 * current sync level for this thread
508 * we have additional cleanup to perform
509 */ 600 */
510 status = acpi_ut_acquire_mutex(ACPI_MTX_CONTROL_METHOD); 601 if (method_desc->method.mutex) {
511 if (ACPI_FAILURE(status)) {
512 return_VOID;
513 }
514 602
515 /* Signal completion of the execution of this method if necessary */ 603 /* Acquisition Depth handles recursive calls */
516 604
517 if (method_desc->method.semaphore) { 605 method_desc->method.mutex->mutex.acquisition_depth--;
518 status = 606 if (!method_desc->method.mutex->mutex.acquisition_depth) {
519 acpi_os_signal_semaphore(method_desc->method.semaphore, 1); 607 walk_state->thread->current_sync_level =
520 if (ACPI_FAILURE(status)) { 608 method_desc->method.mutex->mutex.
521 609 original_sync_level;
522 /* Ignore error and continue */
523 610
524 ACPI_EXCEPTION((AE_INFO, status, 611 acpi_os_release_mutex(method_desc->method.mutex->mutex.
525 "Could not signal method semaphore")); 612 os_mutex);
526 } 613 }
527 } 614 }
528 615
@@ -537,7 +624,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
537 624
538 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 625 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
539 if (ACPI_FAILURE(status)) { 626 if (ACPI_FAILURE(status)) {
540 goto exit; 627 return_VOID;
541 } 628 }
542 629
543 /* 630 /*
@@ -580,18 +667,16 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
580 /* 667 /*
581 * Support to dynamically change a method from not_serialized to 668 * Support to dynamically change a method from not_serialized to
582 * Serialized if it appears that the method is incorrectly written and 669 * Serialized if it appears that the method is incorrectly written and
583 * does not support multiple thread execution. The best example of this 670 * does not support multiple thread execution. The best example of this
584 * is if such a method creates namespace objects and blocks. A second 671 * is if such a method creates namespace objects and blocks. A second
585 * thread will fail with an AE_ALREADY_EXISTS exception 672 * thread will fail with an AE_ALREADY_EXISTS exception
586 * 673 *
587 * This code is here because we must wait until the last thread exits 674 * This code is here because we must wait until the last thread exits
588 * before creating the synchronization semaphore. 675 * before creating the synchronization semaphore.
589 */ 676 */
590 if ((method_desc->method.concurrency == 1) && 677 if ((method_desc->method.method_flags & AML_METHOD_SERIALIZED)
591 (!method_desc->method.semaphore)) { 678 && (!method_desc->method.mutex)) {
592 status = acpi_os_create_semaphore(1, 1, 679 status = acpi_ds_create_method_mutex(method_desc);
593 &method_desc->method.
594 semaphore);
595 } 680 }
596 681
597 /* No more threads, we can free the owner_id */ 682 /* No more threads, we can free the owner_id */
@@ -599,144 +684,5 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
599 acpi_ut_release_owner_id(&method_desc->method.owner_id); 684 acpi_ut_release_owner_id(&method_desc->method.owner_id);
600 } 685 }
601 686
602 exit:
603 (void)acpi_ut_release_mutex(ACPI_MTX_CONTROL_METHOD);
604 return_VOID; 687 return_VOID;
605} 688}
606
607#ifdef ACPI_INIT_PARSE_METHODS
608 /*
609 * Note 11/2005: Removed this code to parse all methods during table
610 * load because it causes problems if there are any errors during the
611 * parse. Also, it seems like overkill and we probably don't want to
612 * abort a table load because of an issue with a single method.
613 */
614
615/*******************************************************************************
616 *
617 * FUNCTION: acpi_ds_parse_method
618 *
619 * PARAMETERS: Node - Method node
620 *
621 * RETURN: Status
622 *
623 * DESCRIPTION: Parse the AML that is associated with the method.
624 *
625 * MUTEX: Assumes parser is locked
626 *
627 ******************************************************************************/
628
629acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node)
630{
631 acpi_status status;
632 union acpi_operand_object *obj_desc;
633 union acpi_parse_object *op;
634 struct acpi_walk_state *walk_state;
635
636 ACPI_FUNCTION_TRACE_PTR(ds_parse_method, node);
637
638 /* Parameter Validation */
639
640 if (!node) {
641 return_ACPI_STATUS(AE_NULL_ENTRY);
642 }
643
644 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
645 "**** Parsing [%4.4s] **** NamedObj=%p\n",
646 acpi_ut_get_node_name(node), node));
647
648 /* Extract the method object from the method Node */
649
650 obj_desc = acpi_ns_get_attached_object(node);
651 if (!obj_desc) {
652 return_ACPI_STATUS(AE_NULL_OBJECT);
653 }
654
655 /* Create a mutex for the method if there is a concurrency limit */
656
657 if ((obj_desc->method.concurrency != ACPI_INFINITE_CONCURRENCY) &&
658 (!obj_desc->method.semaphore)) {
659 status = acpi_os_create_semaphore(obj_desc->method.concurrency,
660 obj_desc->method.concurrency,
661 &obj_desc->method.semaphore);
662 if (ACPI_FAILURE(status)) {
663 return_ACPI_STATUS(status);
664 }
665 }
666
667 /*
668 * Allocate a new parser op to be the root of the parsed
669 * method tree
670 */
671 op = acpi_ps_alloc_op(AML_METHOD_OP);
672 if (!op) {
673 return_ACPI_STATUS(AE_NO_MEMORY);
674 }
675
676 /* Init new op with the method name and pointer back to the Node */
677
678 acpi_ps_set_name(op, node->name.integer);
679 op->common.node = node;
680
681 /*
682 * Get a new owner_id for objects created by this method. Namespace
683 * objects (such as Operation Regions) can be created during the
684 * first pass parse.
685 */
686 status = acpi_ut_allocate_owner_id(&obj_desc->method.owner_id);
687 if (ACPI_FAILURE(status)) {
688 goto cleanup;
689 }
690
691 /* Create and initialize a new walk state */
692
693 walk_state =
694 acpi_ds_create_walk_state(obj_desc->method.owner_id, NULL, NULL,
695 NULL);
696 if (!walk_state) {
697 status = AE_NO_MEMORY;
698 goto cleanup2;
699 }
700
701 status = acpi_ds_init_aml_walk(walk_state, op, node,
702 obj_desc->method.aml_start,
703 obj_desc->method.aml_length, NULL, 1);
704 if (ACPI_FAILURE(status)) {
705 acpi_ds_delete_walk_state(walk_state);
706 goto cleanup2;
707 }
708
709 /*
710 * Parse the method, first pass
711 *
712 * The first pass load is where newly declared named objects are added into
713 * the namespace. Actual evaluation of the named objects (what would be
714 * called a "second pass") happens during the actual execution of the
715 * method so that operands to the named objects can take on dynamic
716 * run-time values.
717 */
718 status = acpi_ps_parse_aml(walk_state);
719 if (ACPI_FAILURE(status)) {
720 goto cleanup2;
721 }
722
723 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
724 "**** [%4.4s] Parsed **** NamedObj=%p Op=%p\n",
725 acpi_ut_get_node_name(node), node, op));
726
727 /*
728 * Delete the parse tree. We simply re-parse the method for every
729 * execution since there isn't much overhead (compared to keeping lots
730 * of parse trees around)
731 */
732 acpi_ns_delete_namespace_subtree(node);
733 acpi_ns_delete_namespace_by_owner(obj_desc->method.owner_id);
734
735 cleanup2:
736 acpi_ut_release_owner_id(&obj_desc->method.owner_id);
737
738 cleanup:
739 acpi_ps_delete_parse_tree(op);
740 return_ACPI_STATUS(status);
741}
742#endif
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c
index 3acbd9145d72..b1ded62d0df1 100644
--- a/drivers/acpi/dispatcher/dswexec.c
+++ b/drivers/acpi/dispatcher/dswexec.c
@@ -472,7 +472,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
472 acpi_ds_result_push(walk_state->result_obj, 472 acpi_ds_result_push(walk_state->result_obj,
473 walk_state); 473 walk_state);
474 } 474 }
475
476 break; 475 break;
477 476
478 default: 477 default:
@@ -510,6 +509,7 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
510 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 509 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
511 "Method Reference in a Package, Op=%p\n", 510 "Method Reference in a Package, Op=%p\n",
512 op)); 511 op));
512
513 op->common.node = 513 op->common.node =
514 (struct acpi_namespace_node *)op->asl.value. 514 (struct acpi_namespace_node *)op->asl.value.
515 arg->asl.node->object; 515 arg->asl.node->object;
@@ -670,7 +670,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
670 670
671 status = acpi_ds_result_stack_pop(walk_state); 671 status = acpi_ds_result_stack_pop(walk_state);
672 } 672 }
673
674 break; 673 break;
675 674
676 case AML_TYPE_UNDEFINED: 675 case AML_TYPE_UNDEFINED:
@@ -708,7 +707,6 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
708 * Check if we just completed the evaluation of a 707 * Check if we just completed the evaluation of a
709 * conditional predicate 708 * conditional predicate
710 */ 709 */
711
712 if ((ACPI_SUCCESS(status)) && 710 if ((ACPI_SUCCESS(status)) &&
713 (walk_state->control_state) && 711 (walk_state->control_state) &&
714 (walk_state->control_state->common.state == 712 (walk_state->control_state->common.state ==
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
index 35074399c617..e3ca7f6539c1 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/dispatcher/dswload.c
@@ -175,7 +175,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
175 if (status == AE_NOT_FOUND) { 175 if (status == AE_NOT_FOUND) {
176 /* 176 /*
177 * Table disassembly: 177 * Table disassembly:
178 * Target of Scope() not found. Generate an External for it, and 178 * Target of Scope() not found. Generate an External for it, and
179 * insert the name into the namespace. 179 * insert the name into the namespace.
180 */ 180 */
181 acpi_dm_add_to_external_list(path, ACPI_TYPE_DEVICE, 0); 181 acpi_dm_add_to_external_list(path, ACPI_TYPE_DEVICE, 0);
@@ -210,16 +210,15 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
210 case ACPI_TYPE_BUFFER: 210 case ACPI_TYPE_BUFFER:
211 211
212 /* 212 /*
213 * These types we will allow, but we will change the type. This 213 * These types we will allow, but we will change the type. This
214 * enables some existing code of the form: 214 * enables some existing code of the form:
215 * 215 *
216 * Name (DEB, 0) 216 * Name (DEB, 0)
217 * Scope (DEB) { ... } 217 * Scope (DEB) { ... }
218 * 218 *
219 * Note: silently change the type here. On the second pass, we will report 219 * Note: silently change the type here. On the second pass, we will report
220 * a warning 220 * a warning
221 */ 221 */
222
223 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 222 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
224 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", 223 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n",
225 path, 224 path,
@@ -242,7 +241,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
242 break; 241 break;
243 242
244 default: 243 default:
245
246 /* 244 /*
247 * For all other named opcodes, we will enter the name into 245 * For all other named opcodes, we will enter the name into
248 * the namespace. 246 * the namespace.
@@ -259,7 +257,6 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
259 * buffer_field, or Package), the name of the object is already 257 * buffer_field, or Package), the name of the object is already
260 * in the namespace. 258 * in the namespace.
261 */ 259 */
262
263 if (walk_state->deferred_node) { 260 if (walk_state->deferred_node) {
264 261
265 /* This name is already in the namespace, get the node */ 262 /* This name is already in the namespace, get the node */
@@ -293,8 +290,8 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
293 } 290 }
294 291
295 /* 292 /*
296 * Enter the named type into the internal namespace. We enter the name 293 * Enter the named type into the internal namespace. We enter the name
297 * as we go downward in the parse tree. Any necessary subobjects that 294 * as we go downward in the parse tree. Any necessary subobjects that
298 * involve arguments to the opcode must be created as we go back up the 295 * involve arguments to the opcode must be created as we go back up the
299 * parse tree later. 296 * parse tree later.
300 */ 297 */
@@ -327,12 +324,12 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
327 (status); 324 (status);
328 } 325 }
329 } 326 }
327
330 status = AE_OK; 328 status = AE_OK;
331 } 329 }
332 } 330 }
333 331
334 if (ACPI_FAILURE(status)) { 332 if (ACPI_FAILURE(status)) {
335
336 ACPI_ERROR_NAMESPACE(path, status); 333 ACPI_ERROR_NAMESPACE(path, status);
337 return_ACPI_STATUS(status); 334 return_ACPI_STATUS(status);
338 } 335 }
@@ -434,9 +431,13 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
434 status = 431 status =
435 acpi_ex_create_region(op->named.data, 432 acpi_ex_create_region(op->named.data,
436 op->named.length, 433 op->named.length,
437 (acpi_adr_space_type) 434 (acpi_adr_space_type) ((op->
438 ((op->common.value.arg)-> 435 common.
439 common.value.integer), 436 value.
437 arg)->
438 common.
439 value.
440 integer),
440 walk_state); 441 walk_state);
441 if (ACPI_FAILURE(status)) { 442 if (ACPI_FAILURE(status)) {
442 return_ACPI_STATUS(status); 443 return_ACPI_STATUS(status);
@@ -474,7 +475,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
474 * method_op pkg_length name_string method_flags term_list 475 * method_op pkg_length name_string method_flags term_list
475 * 476 *
476 * Note: We must create the method node/object pair as soon as we 477 * Note: We must create the method node/object pair as soon as we
477 * see the method declaration. This allows later pass1 parsing 478 * see the method declaration. This allows later pass1 parsing
478 * of invocations of the method (need to know the number of 479 * of invocations of the method (need to know the number of
479 * arguments.) 480 * arguments.)
480 */ 481 */
@@ -499,6 +500,7 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)
499 length, 500 length,
500 walk_state); 501 walk_state);
501 } 502 }
503
502 walk_state->operands[0] = NULL; 504 walk_state->operands[0] = NULL;
503 walk_state->num_operands = 0; 505 walk_state->num_operands = 0;
504 506
@@ -570,7 +572,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
570#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE 572#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE
571 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) || 573 if ((walk_state->op_info->class == AML_CLASS_EXECUTE) ||
572 (walk_state->op_info->class == AML_CLASS_CONTROL)) { 574 (walk_state->op_info->class == AML_CLASS_CONTROL)) {
573
574 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 575 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
575 "Begin/EXEC: %s (fl %8.8X)\n", 576 "Begin/EXEC: %s (fl %8.8X)\n",
576 walk_state->op_info->name, 577 walk_state->op_info->name,
@@ -602,7 +603,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
602 } else { 603 } else {
603 /* Get name from the op */ 604 /* Get name from the op */
604 605
605 buffer_ptr = (char *)&op->named.name; 606 buffer_ptr = ACPI_CAST_PTR(char, &op->named.name);
606 } 607 }
607 } else { 608 } else {
608 /* Get the namestring from the raw AML */ 609 /* Get the namestring from the raw AML */
@@ -629,7 +630,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
629 break; 630 break;
630 631
631 case AML_INT_NAMEPATH_OP: 632 case AML_INT_NAMEPATH_OP:
632
633 /* 633 /*
634 * The name_path is an object reference to an existing object. 634 * The name_path is an object reference to an existing object.
635 * Don't enter the name into the namespace, but look it up 635 * Don't enter the name into the namespace, but look it up
@@ -642,7 +642,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
642 break; 642 break;
643 643
644 case AML_SCOPE_OP: 644 case AML_SCOPE_OP:
645
646 /* 645 /*
647 * The Path is an object reference to an existing object. 646 * The Path is an object reference to an existing object.
648 * Don't enter the name into the namespace, but look it up 647 * Don't enter the name into the namespace, but look it up
@@ -664,6 +663,7 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
664#endif 663#endif
665 return_ACPI_STATUS(status); 664 return_ACPI_STATUS(status);
666 } 665 }
666
667 /* 667 /*
668 * We must check to make sure that the target is 668 * We must check to make sure that the target is
669 * one of the opcodes that actually opens a scope 669 * one of the opcodes that actually opens a scope
@@ -683,13 +683,12 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
683 case ACPI_TYPE_BUFFER: 683 case ACPI_TYPE_BUFFER:
684 684
685 /* 685 /*
686 * These types we will allow, but we will change the type. This 686 * These types we will allow, but we will change the type. This
687 * enables some existing code of the form: 687 * enables some existing code of the form:
688 * 688 *
689 * Name (DEB, 0) 689 * Name (DEB, 0)
690 * Scope (DEB) { ... } 690 * Scope (DEB) { ... }
691 */ 691 */
692
693 ACPI_WARNING((AE_INFO, 692 ACPI_WARNING((AE_INFO,
694 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)", 693 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)",
695 buffer_ptr, 694 buffer_ptr,
@@ -729,14 +728,14 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
729 if (ACPI_FAILURE(status)) { 728 if (ACPI_FAILURE(status)) {
730 return_ACPI_STATUS(status); 729 return_ACPI_STATUS(status);
731 } 730 }
732
733 } 731 }
732
734 return_ACPI_STATUS(AE_OK); 733 return_ACPI_STATUS(AE_OK);
735 } 734 }
736 735
737 /* 736 /*
738 * Enter the named type into the internal namespace. We enter the name 737 * Enter the named type into the internal namespace. We enter the name
739 * as we go downward in the parse tree. Any necessary subobjects that 738 * as we go downward in the parse tree. Any necessary subobjects that
740 * involve arguments to the opcode must be created as we go back up the 739 * involve arguments to the opcode must be created as we go back up the
741 * parse tree later. 740 * parse tree later.
742 * 741 *
@@ -787,7 +786,6 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
787 * can get it again quickly when this scope is closed 786 * can get it again quickly when this scope is closed
788 */ 787 */
789 op->common.node = node; 788 op->common.node = node;
790
791 return_ACPI_STATUS(status); 789 return_ACPI_STATUS(status);
792} 790}
793 791
@@ -922,7 +920,6 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
922#ifndef ACPI_NO_METHOD_EXECUTION 920#ifndef ACPI_NO_METHOD_EXECUTION
923 921
924 case AML_TYPE_CREATE_FIELD: 922 case AML_TYPE_CREATE_FIELD:
925
926 /* 923 /*
927 * Create the field object, but the field buffer and index must 924 * Create the field object, but the field buffer and index must
928 * be evaluated later during the execution phase 925 * be evaluated later during the execution phase
@@ -931,7 +928,6 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
931 break; 928 break;
932 929
933 case AML_TYPE_NAMED_FIELD: 930 case AML_TYPE_NAMED_FIELD:
934
935 /* 931 /*
936 * If we are executing a method, initialize the field 932 * If we are executing a method, initialize the field
937 */ 933 */
@@ -1051,6 +1047,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
1051 * argument is the space_id. (We must save the address of the 1047 * argument is the space_id. (We must save the address of the
1052 * AML of the address and length operands) 1048 * AML of the address and length operands)
1053 */ 1049 */
1050
1054 /* 1051 /*
1055 * If we have a valid region, initialize it 1052 * If we have a valid region, initialize it
1056 * Namespace is NOT locked at this point. 1053 * Namespace is NOT locked at this point.
@@ -1080,7 +1077,7 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
1080 * method_op pkg_length name_string method_flags term_list 1077 * method_op pkg_length name_string method_flags term_list
1081 * 1078 *
1082 * Note: We must create the method node/object pair as soon as we 1079 * Note: We must create the method node/object pair as soon as we
1083 * see the method declaration. This allows later pass1 parsing 1080 * see the method declaration. This allows later pass1 parsing
1084 * of invocations of the method (need to know the number of 1081 * of invocations of the method (need to know the number of
1085 * arguments.) 1082 * arguments.)
1086 */ 1083 */
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
new file mode 100644
index 000000000000..510a94524298
--- /dev/null
+++ b/drivers/acpi/dock.c
@@ -0,0 +1,739 @@
1/*
2 * dock.c - ACPI dock station driver
3 *
4 * Copyright (C) 2006 Kristen Carlson Accardi <kristen.c.accardi@intel.com>
5 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 (at
11 * your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 */
24
25#include <linux/kernel.h>
26#include <linux/module.h>
27#include <linux/init.h>
28#include <linux/types.h>
29#include <linux/notifier.h>
30#include <acpi/acpi_bus.h>
31#include <acpi/acpi_drivers.h>
32
33#define ACPI_DOCK_DRIVER_NAME "ACPI Dock Station Driver"
34
35ACPI_MODULE_NAME("dock")
36MODULE_AUTHOR("Kristen Carlson Accardi");
37MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME);
38MODULE_LICENSE("GPL");
39
40static struct atomic_notifier_head dock_notifier_list;
41
42struct dock_station {
43 acpi_handle handle;
44 unsigned long last_dock_time;
45 u32 flags;
46 spinlock_t dd_lock;
47 spinlock_t hp_lock;
48 struct list_head dependent_devices;
49 struct list_head hotplug_devices;
50};
51
52struct dock_dependent_device {
53 struct list_head list;
54 struct list_head hotplug_list;
55 acpi_handle handle;
56 acpi_notify_handler handler;
57 void *context;
58};
59
60#define DOCK_DOCKING 0x00000001
61#define DOCK_EVENT KOBJ_DOCK
62#define UNDOCK_EVENT KOBJ_UNDOCK
63
64static struct dock_station *dock_station;
65
66/*****************************************************************************
67 * Dock Dependent device functions *
68 *****************************************************************************/
69/**
70 * alloc_dock_dependent_device - allocate and init a dependent device
71 * @handle: the acpi_handle of the dependent device
72 *
73 * Allocate memory for a dependent device structure for a device referenced
74 * by the acpi handle
75 */
76static struct dock_dependent_device *
77alloc_dock_dependent_device(acpi_handle handle)
78{
79 struct dock_dependent_device *dd;
80
81 dd = kzalloc(sizeof(*dd), GFP_KERNEL);
82 if (dd) {
83 dd->handle = handle;
84 INIT_LIST_HEAD(&dd->list);
85 INIT_LIST_HEAD(&dd->hotplug_list);
86 }
87 return dd;
88}
89
90/**
91 * add_dock_dependent_device - associate a device with the dock station
92 * @ds: The dock station
93 * @dd: The dependent device
94 *
95 * Add the dependent device to the dock's dependent device list.
96 */
97static void
98add_dock_dependent_device(struct dock_station *ds,
99 struct dock_dependent_device *dd)
100{
101 spin_lock(&ds->dd_lock);
102 list_add_tail(&dd->list, &ds->dependent_devices);
103 spin_unlock(&ds->dd_lock);
104}
105
106/**
107 * dock_add_hotplug_device - associate a hotplug handler with the dock station
108 * @ds: The dock station
109 * @dd: The dependent device struct
110 *
111 * Add the dependent device to the dock's hotplug device list
112 */
113static void
114dock_add_hotplug_device(struct dock_station *ds,
115 struct dock_dependent_device *dd)
116{
117 spin_lock(&ds->hp_lock);
118 list_add_tail(&dd->hotplug_list, &ds->hotplug_devices);
119 spin_unlock(&ds->hp_lock);
120}
121
122/**
123 * dock_del_hotplug_device - remove a hotplug handler from the dock station
124 * @ds: The dock station
125 * @dd: the dependent device struct
126 *
127 * Delete the dependent device from the dock's hotplug device list
128 */
129static void
130dock_del_hotplug_device(struct dock_station *ds,
131 struct dock_dependent_device *dd)
132{
133 spin_lock(&ds->hp_lock);
134 list_del(&dd->hotplug_list);
135 spin_unlock(&ds->hp_lock);
136}
137
138/**
139 * find_dock_dependent_device - get a device dependent on this dock
140 * @ds: the dock station
141 * @handle: the acpi_handle of the device we want
142 *
143 * iterate over the dependent device list for this dock. If the
144 * dependent device matches the handle, return.
145 */
146static struct dock_dependent_device *
147find_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
148{
149 struct dock_dependent_device *dd;
150
151 spin_lock(&ds->dd_lock);
152 list_for_each_entry(dd, &ds->dependent_devices, list) {
153 if (handle == dd->handle) {
154 spin_unlock(&ds->dd_lock);
155 return dd;
156 }
157 }
158 spin_unlock(&ds->dd_lock);
159 return NULL;
160}
161
162/*****************************************************************************
163 * Dock functions *
164 *****************************************************************************/
165/**
166 * is_dock - see if a device is a dock station
167 * @handle: acpi handle of the device
168 *
169 * If an acpi object has a _DCK method, then it is by definition a dock
170 * station, so return true.
171 */
172static int is_dock(acpi_handle handle)
173{
174 acpi_status status;
175 acpi_handle tmp;
176
177 status = acpi_get_handle(handle, "_DCK", &tmp);
178 if (ACPI_FAILURE(status))
179 return 0;
180 return 1;
181}
182
183/**
184 * is_dock_device - see if a device is on a dock station
185 * @handle: acpi handle of the device
186 *
187 * If this device is either the dock station itself,
188 * or is a device dependent on the dock station, then it
189 * is a dock device
190 */
191int is_dock_device(acpi_handle handle)
192{
193 if (!dock_station)
194 return 0;
195
196 if (is_dock(handle) || find_dock_dependent_device(dock_station, handle))
197 return 1;
198
199 return 0;
200}
201
202EXPORT_SYMBOL_GPL(is_dock_device);
203
204/**
205 * dock_present - see if the dock station is present.
206 * @ds: the dock station
207 *
208 * execute the _STA method. note that present does not
209 * imply that we are docked.
210 */
211static int dock_present(struct dock_station *ds)
212{
213 unsigned long sta;
214 acpi_status status;
215
216 if (ds) {
217 status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta);
218 if (ACPI_SUCCESS(status) && sta)
219 return 1;
220 }
221 return 0;
222}
223
224
225
226/**
227 * dock_create_acpi_device - add new devices to acpi
228 * @handle - handle of the device to add
229 *
230 * This function will create a new acpi_device for the given
231 * handle if one does not exist already. This should cause
232 * acpi to scan for drivers for the given devices, and call
233 * matching driver's add routine.
234 *
235 * Returns a pointer to the acpi_device corresponding to the handle.
236 */
237static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
238{
239 struct acpi_device *device = NULL;
240 struct acpi_device *parent_device;
241 acpi_handle parent;
242 int ret;
243
244 if (acpi_bus_get_device(handle, &device)) {
245 /*
246 * no device created for this object,
247 * so we should create one.
248 */
249 acpi_get_parent(handle, &parent);
250 if (acpi_bus_get_device(parent, &parent_device))
251 parent_device = NULL;
252
253 ret = acpi_bus_add(&device, parent_device, handle,
254 ACPI_BUS_TYPE_DEVICE);
255 if (ret) {
256 pr_debug("error adding bus, %x\n",
257 -ret);
258 return NULL;
259 }
260 }
261 return device;
262}
263
264/**
265 * dock_remove_acpi_device - remove the acpi_device struct from acpi
266 * @handle - the handle of the device to remove
267 *
268 * Tell acpi to remove the acpi_device. This should cause any loaded
269 * driver to have it's remove routine called.
270 */
271static void dock_remove_acpi_device(acpi_handle handle)
272{
273 struct acpi_device *device;
274 int ret;
275
276 if (!acpi_bus_get_device(handle, &device)) {
277 ret = acpi_bus_trim(device, 1);
278 if (ret)
279 pr_debug("error removing bus, %x\n", -ret);
280 }
281}
282
283
284/**
285 * hotplug_dock_devices - insert or remove devices on the dock station
286 * @ds: the dock station
287 * @event: either bus check or eject request
288 *
289 * Some devices on the dock station need to have drivers called
290 * to perform hotplug operations after a dock event has occurred.
291 * Traverse the list of dock devices that have registered a
292 * hotplug handler, and call the handler.
293 */
294static void hotplug_dock_devices(struct dock_station *ds, u32 event)
295{
296 struct dock_dependent_device *dd;
297
298 spin_lock(&ds->hp_lock);
299
300 /*
301 * First call driver specific hotplug functions
302 */
303 list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) {
304 if (dd->handler)
305 dd->handler(dd->handle, event, dd->context);
306 }
307
308 /*
309 * Now make sure that an acpi_device is created for each
310 * dependent device, or removed if this is an eject request.
311 * This will cause acpi_drivers to be stopped/started if they
312 * exist
313 */
314 list_for_each_entry(dd, &ds->dependent_devices, list) {
315 if (event == ACPI_NOTIFY_EJECT_REQUEST)
316 dock_remove_acpi_device(dd->handle);
317 else
318 dock_create_acpi_device(dd->handle);
319 }
320 spin_unlock(&ds->hp_lock);
321}
322
323static void dock_event(struct dock_station *ds, u32 event, int num)
324{
325 struct acpi_device *device;
326
327 device = dock_create_acpi_device(ds->handle);
328 if (device)
329 kobject_uevent(&device->kobj, num);
330}
331
332/**
333 * eject_dock - respond to a dock eject request
334 * @ds: the dock station
335 *
336 * This is called after _DCK is called, to execute the dock station's
337 * _EJ0 method.
338 */
339static void eject_dock(struct dock_station *ds)
340{
341 struct acpi_object_list arg_list;
342 union acpi_object arg;
343 acpi_status status;
344 acpi_handle tmp;
345
346 /* all dock devices should have _EJ0, but check anyway */
347 status = acpi_get_handle(ds->handle, "_EJ0", &tmp);
348 if (ACPI_FAILURE(status)) {
349 pr_debug("No _EJ0 support for dock device\n");
350 return;
351 }
352
353 arg_list.count = 1;
354 arg_list.pointer = &arg;
355 arg.type = ACPI_TYPE_INTEGER;
356 arg.integer.value = 1;
357
358 if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0",
359 &arg_list, NULL)))
360 pr_debug("Failed to evaluate _EJ0!\n");
361}
362
363/**
364 * handle_dock - handle a dock event
365 * @ds: the dock station
366 * @dock: to dock, or undock - that is the question
367 *
368 * Execute the _DCK method in response to an acpi event
369 */
370static void handle_dock(struct dock_station *ds, int dock)
371{
372 acpi_status status;
373 struct acpi_object_list arg_list;
374 union acpi_object arg;
375 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
376 struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
377 union acpi_object *obj;
378
379 acpi_get_name(ds->handle, ACPI_FULL_PATHNAME, &name_buffer);
380 obj = name_buffer.pointer;
381
382 printk(KERN_INFO PREFIX "%s\n", dock ? "docking" : "undocking");
383
384 /* _DCK method has one argument */
385 arg_list.count = 1;
386 arg_list.pointer = &arg;
387 arg.type = ACPI_TYPE_INTEGER;
388 arg.integer.value = dock;
389 status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer);
390 if (ACPI_FAILURE(status))
391 pr_debug("%s: failed to execute _DCK\n", obj->string.pointer);
392 kfree(buffer.pointer);
393 kfree(name_buffer.pointer);
394}
395
396static inline void dock(struct dock_station *ds)
397{
398 handle_dock(ds, 1);
399}
400
401static inline void undock(struct dock_station *ds)
402{
403 handle_dock(ds, 0);
404}
405
406static inline void begin_dock(struct dock_station *ds)
407{
408 ds->flags |= DOCK_DOCKING;
409}
410
411static inline void complete_dock(struct dock_station *ds)
412{
413 ds->flags &= ~(DOCK_DOCKING);
414 ds->last_dock_time = jiffies;
415}
416
417/**
418 * dock_in_progress - see if we are in the middle of handling a dock event
419 * @ds: the dock station
420 *
421 * Sometimes while docking, false dock events can be sent to the driver
422 * because good connections aren't made or some other reason. Ignore these
423 * if we are in the middle of doing something.
424 */
425static int dock_in_progress(struct dock_station *ds)
426{
427 if ((ds->flags & DOCK_DOCKING) ||
428 time_before(jiffies, (ds->last_dock_time + HZ)))
429 return 1;
430 return 0;
431}
432
433/**
434 * register_dock_notifier - add yourself to the dock notifier list
435 * @nb: the callers notifier block
436 *
437 * If a driver wishes to be notified about dock events, they can
438 * use this function to put a notifier block on the dock notifier list.
439 * this notifier call chain will be called after a dock event, but
440 * before hotplugging any new devices.
441 */
442int register_dock_notifier(struct notifier_block *nb)
443{
444 return atomic_notifier_chain_register(&dock_notifier_list, nb);
445}
446
447EXPORT_SYMBOL_GPL(register_dock_notifier);
448
449/**
450 * unregister_dock_notifier - remove yourself from the dock notifier list
451 * @nb: the callers notifier block
452 */
453void unregister_dock_notifier(struct notifier_block *nb)
454{
455 atomic_notifier_chain_unregister(&dock_notifier_list, nb);
456}
457
458EXPORT_SYMBOL_GPL(unregister_dock_notifier);
459
460/**
461 * register_hotplug_dock_device - register a hotplug function
462 * @handle: the handle of the device
463 * @handler: the acpi_notifier_handler to call after docking
464 * @context: device specific data
465 *
466 * If a driver would like to perform a hotplug operation after a dock
467 * event, they can register an acpi_notifiy_handler to be called by
468 * the dock driver after _DCK is executed.
469 */
470int
471register_hotplug_dock_device(acpi_handle handle, acpi_notify_handler handler,
472 void *context)
473{
474 struct dock_dependent_device *dd;
475
476 if (!dock_station)
477 return -ENODEV;
478
479 /*
480 * make sure this handle is for a device dependent on the dock,
481 * this would include the dock station itself
482 */
483 dd = find_dock_dependent_device(dock_station, handle);
484 if (dd) {
485 dd->handler = handler;
486 dd->context = context;
487 dock_add_hotplug_device(dock_station, dd);
488 return 0;
489 }
490
491 return -EINVAL;
492}
493
494EXPORT_SYMBOL_GPL(register_hotplug_dock_device);
495
496/**
497 * unregister_hotplug_dock_device - remove yourself from the hotplug list
498 * @handle: the acpi handle of the device
499 */
500void unregister_hotplug_dock_device(acpi_handle handle)
501{
502 struct dock_dependent_device *dd;
503
504 if (!dock_station)
505 return;
506
507 dd = find_dock_dependent_device(dock_station, handle);
508 if (dd)
509 dock_del_hotplug_device(dock_station, dd);
510}
511
512EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device);
513
514/**
515 * dock_notify - act upon an acpi dock notification
516 * @handle: the dock station handle
517 * @event: the acpi event
518 * @data: our driver data struct
519 *
520 * If we are notified to dock, then check to see if the dock is
521 * present and then dock. Notify all drivers of the dock event,
522 * and then hotplug and devices that may need hotplugging. For undock
523 * check to make sure the dock device is still present, then undock
524 * and hotremove all the devices that may need removing.
525 */
526static void dock_notify(acpi_handle handle, u32 event, void *data)
527{
528 struct dock_station *ds = (struct dock_station *)data;
529
530 switch (event) {
531 case ACPI_NOTIFY_BUS_CHECK:
532 if (!dock_in_progress(ds) && dock_present(ds)) {
533 begin_dock(ds);
534 dock(ds);
535 if (!dock_present(ds)) {
536 printk(KERN_ERR PREFIX "Unable to dock!\n");
537 break;
538 }
539 atomic_notifier_call_chain(&dock_notifier_list,
540 event, NULL);
541 hotplug_dock_devices(ds, event);
542 complete_dock(ds);
543 dock_event(ds, event, DOCK_EVENT);
544 }
545 break;
546 case ACPI_NOTIFY_DEVICE_CHECK:
547 /*
548 * According to acpi spec 3.0a, if a DEVICE_CHECK notification
549 * is sent and _DCK is present, it is assumed to mean an
550 * undock request. This notify routine will only be called
551 * for objects defining _DCK, so we will fall through to eject
552 * request here. However, we will pass an eject request through
553 * to the driver who wish to hotplug.
554 */
555 case ACPI_NOTIFY_EJECT_REQUEST:
556 if (!dock_in_progress(ds) && dock_present(ds)) {
557 /*
558 * here we need to generate the undock
559 * event prior to actually doing the undock
560 * so that the device struct still exists.
561 */
562 dock_event(ds, event, UNDOCK_EVENT);
563 hotplug_dock_devices(ds, ACPI_NOTIFY_EJECT_REQUEST);
564 undock(ds);
565 eject_dock(ds);
566 if (dock_present(ds))
567 printk(KERN_ERR PREFIX "Unable to undock!\n");
568 }
569 break;
570 default:
571 printk(KERN_ERR PREFIX "Unknown dock event %d\n", event);
572 }
573}
574
575/**
576 * find_dock_devices - find devices on the dock station
577 * @handle: the handle of the device we are examining
578 * @lvl: unused
579 * @context: the dock station private data
580 * @rv: unused
581 *
582 * This function is called by acpi_walk_namespace. It will
583 * check to see if an object has an _EJD method. If it does, then it
584 * will see if it is dependent on the dock station.
585 */
586static acpi_status
587find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
588{
589 acpi_status status;
590 acpi_handle tmp;
591 struct dock_station *ds = (struct dock_station *)context;
592 struct dock_dependent_device *dd;
593
594 status = acpi_bus_get_ejd(handle, &tmp);
595 if (ACPI_FAILURE(status))
596 return AE_OK;
597
598 if (tmp == ds->handle) {
599 dd = alloc_dock_dependent_device(handle);
600 if (dd)
601 add_dock_dependent_device(ds, dd);
602 }
603
604 return AE_OK;
605}
606
607/**
608 * dock_add - add a new dock station
609 * @handle: the dock station handle
610 *
611 * allocated and initialize a new dock station device. Find all devices
612 * that are on the dock station, and register for dock event notifications.
613 */
614static int dock_add(acpi_handle handle)
615{
616 int ret;
617 acpi_status status;
618 struct dock_dependent_device *dd;
619
620 /* allocate & initialize the dock_station private data */
621 dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL);
622 if (!dock_station)
623 return -ENOMEM;
624 dock_station->handle = handle;
625 dock_station->last_dock_time = jiffies - HZ;
626 INIT_LIST_HEAD(&dock_station->dependent_devices);
627 INIT_LIST_HEAD(&dock_station->hotplug_devices);
628 spin_lock_init(&dock_station->dd_lock);
629 spin_lock_init(&dock_station->hp_lock);
630
631 /* Find dependent devices */
632 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
633 ACPI_UINT32_MAX, find_dock_devices, dock_station,
634 NULL);
635
636 /* add the dock station as a device dependent on itself */
637 dd = alloc_dock_dependent_device(handle);
638 if (!dd) {
639 kfree(dock_station);
640 return -ENOMEM;
641 }
642 add_dock_dependent_device(dock_station, dd);
643
644 /* register for dock events */
645 status = acpi_install_notify_handler(dock_station->handle,
646 ACPI_SYSTEM_NOTIFY,
647 dock_notify, dock_station);
648
649 if (ACPI_FAILURE(status)) {
650 printk(KERN_ERR PREFIX "Error installing notify handler\n");
651 ret = -ENODEV;
652 goto dock_add_err;
653 }
654
655 printk(KERN_INFO PREFIX "%s \n", ACPI_DOCK_DRIVER_NAME);
656
657 return 0;
658
659dock_add_err:
660 kfree(dock_station);
661 kfree(dd);
662 return ret;
663}
664
665/**
666 * dock_remove - free up resources related to the dock station
667 */
668static int dock_remove(void)
669{
670 struct dock_dependent_device *dd, *tmp;
671 acpi_status status;
672
673 if (!dock_station)
674 return 0;
675
676 /* remove dependent devices */
677 list_for_each_entry_safe(dd, tmp, &dock_station->dependent_devices,
678 list)
679 kfree(dd);
680
681 /* remove dock notify handler */
682 status = acpi_remove_notify_handler(dock_station->handle,
683 ACPI_SYSTEM_NOTIFY,
684 dock_notify);
685 if (ACPI_FAILURE(status))
686 printk(KERN_ERR "Error removing notify handler\n");
687
688 /* free dock station memory */
689 kfree(dock_station);
690 return 0;
691}
692
693/**
694 * find_dock - look for a dock station
695 * @handle: acpi handle of a device
696 * @lvl: unused
697 * @context: counter of dock stations found
698 * @rv: unused
699 *
700 * This is called by acpi_walk_namespace to look for dock stations.
701 */
702static acpi_status
703find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
704{
705 int *count = (int *)context;
706 acpi_status status = AE_OK;
707
708 if (is_dock(handle)) {
709 if (dock_add(handle) >= 0) {
710 (*count)++;
711 status = AE_CTRL_TERMINATE;
712 }
713 }
714 return status;
715}
716
717static int __init dock_init(void)
718{
719 int num = 0;
720
721 dock_station = NULL;
722
723 /* look for a dock station */
724 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
725 ACPI_UINT32_MAX, find_dock, &num, NULL);
726
727 if (!num)
728 return -ENODEV;
729
730 return 0;
731}
732
733static void __exit dock_exit(void)
734{
735 dock_remove();
736}
737
738postcore_initcall(dock_init);
739module_exit(dock_exit);
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 18b3ea9dace2..8c5d7df7d343 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -207,16 +207,15 @@ static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event)
207{ 207{
208 int result = 0; 208 int result = 0;
209 209
210 ACPI_FUNCTION_TRACE("acpi_ec_wait");
211 210
212 ec->intr.expect_event = event; 211 ec->intr.expect_event = event;
213 smp_mb(); 212 smp_mb();
214 213
215 switch (event) { 214 switch (event) {
216 case ACPI_EC_EVENT_IBE: 215 case ACPI_EC_EVENT_IBE:
217 if (~acpi_ec_read_status(ec) & event) { 216 if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) {
218 ec->intr.expect_event = 0; 217 ec->intr.expect_event = 0;
219 return_VALUE(0); 218 return 0;
220 } 219 }
221 break; 220 break;
222 default: 221 default:
@@ -238,16 +237,16 @@ static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event)
238 switch (event) { 237 switch (event) {
239 case ACPI_EC_EVENT_OBF: 238 case ACPI_EC_EVENT_OBF:
240 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF) 239 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
241 return_VALUE(0); 240 return 0;
242 break; 241 break;
243 242
244 case ACPI_EC_EVENT_IBE: 243 case ACPI_EC_EVENT_IBE:
245 if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) 244 if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)
246 return_VALUE(0); 245 return 0;
247 break; 246 break;
248 } 247 }
249 248
250 return_VALUE(-ETIME); 249 return -ETIME;
251} 250}
252 251
253#ifdef ACPI_FUTURE_USAGE 252#ifdef ACPI_FUTURE_USAGE
@@ -260,7 +259,6 @@ int acpi_ec_enter_burst_mode(union acpi_ec *ec)
260 u32 tmp = 0; 259 u32 tmp = 0;
261 int status = 0; 260 int status = 0;
262 261
263 ACPI_FUNCTION_TRACE("acpi_ec_enter_burst_mode");
264 262
265 status = acpi_ec_read_status(ec); 263 status = acpi_ec_read_status(ec);
266 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { 264 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
@@ -272,22 +270,21 @@ int acpi_ec_enter_burst_mode(union acpi_ec *ec)
272 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 270 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
273 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr); 271 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
274 if (tmp != 0x90) { /* Burst ACK byte */ 272 if (tmp != 0x90) { /* Burst ACK byte */
275 return_VALUE(-EINVAL); 273 return -EINVAL;
276 } 274 }
277 } 275 }
278 276
279 atomic_set(&ec->intr.leaving_burst, 0); 277 atomic_set(&ec->intr.leaving_burst, 0);
280 return_VALUE(0); 278 return 0;
281 end: 279 end:
282 printk(KERN_WARNING PREFIX "Error in acpi_ec_wait\n"); 280 ACPI_EXCEPTION ((AE_INFO, status, "EC wait, burst mode");
283 return_VALUE(-1); 281 return -1;
284} 282}
285 283
286int acpi_ec_leave_burst_mode(union acpi_ec *ec) 284int acpi_ec_leave_burst_mode(union acpi_ec *ec)
287{ 285{
288 int status = 0; 286 int status = 0;
289 287
290 ACPI_FUNCTION_TRACE("acpi_ec_leave_burst_mode");
291 288
292 status = acpi_ec_read_status(ec); 289 status = acpi_ec_read_status(ec);
293 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){ 290 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){
@@ -298,10 +295,10 @@ int acpi_ec_leave_burst_mode(union acpi_ec *ec)
298 acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); 295 acpi_ec_wait(ec, ACPI_EC_FLAG_IBF);
299 } 296 }
300 atomic_set(&ec->intr.leaving_burst, 1); 297 atomic_set(&ec->intr.leaving_burst, 1);
301 return_VALUE(0); 298 return 0;
302end: 299end:
303 printk(KERN_WARNING PREFIX "leave burst_mode:error\n"); 300 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode");
304 return_VALUE(-1); 301 return -1;
305} 302}
306#endif /* ACPI_FUTURE_USAGE */ 303#endif /* ACPI_FUTURE_USAGE */
307 304
@@ -325,17 +322,16 @@ static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data)
325 int result = 0; 322 int result = 0;
326 u32 glk = 0; 323 u32 glk = 0;
327 324
328 ACPI_FUNCTION_TRACE("acpi_ec_read");
329 325
330 if (!ec || !data) 326 if (!ec || !data)
331 return_VALUE(-EINVAL); 327 return -EINVAL;
332 328
333 *data = 0; 329 *data = 0;
334 330
335 if (ec->common.global_lock) { 331 if (ec->common.global_lock) {
336 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 332 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
337 if (ACPI_FAILURE(status)) 333 if (ACPI_FAILURE(status))
338 return_VALUE(-ENODEV); 334 return -ENODEV;
339 } 335 }
340 336
341 if (down_interruptible(&ec->poll.sem)) { 337 if (down_interruptible(&ec->poll.sem)) {
@@ -365,7 +361,7 @@ end_nosem:
365 if (ec->common.global_lock) 361 if (ec->common.global_lock)
366 acpi_release_global_lock(glk); 362 acpi_release_global_lock(glk);
367 363
368 return_VALUE(result); 364 return result;
369} 365}
370 366
371static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data) 367static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data)
@@ -374,15 +370,14 @@ static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data)
374 acpi_status status = AE_OK; 370 acpi_status status = AE_OK;
375 u32 glk = 0; 371 u32 glk = 0;
376 372
377 ACPI_FUNCTION_TRACE("acpi_ec_write");
378 373
379 if (!ec) 374 if (!ec)
380 return_VALUE(-EINVAL); 375 return -EINVAL;
381 376
382 if (ec->common.global_lock) { 377 if (ec->common.global_lock) {
383 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 378 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
384 if (ACPI_FAILURE(status)) 379 if (ACPI_FAILURE(status))
385 return_VALUE(-ENODEV); 380 return -ENODEV;
386 } 381 }
387 382
388 if (down_interruptible(&ec->poll.sem)) { 383 if (down_interruptible(&ec->poll.sem)) {
@@ -415,7 +410,7 @@ end_nosem:
415 if (ec->common.global_lock) 410 if (ec->common.global_lock)
416 acpi_release_global_lock(glk); 411 acpi_release_global_lock(glk);
417 412
418 return_VALUE(result); 413 return result;
419} 414}
420 415
421static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data) 416static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data)
@@ -423,17 +418,16 @@ static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data)
423 int status = 0; 418 int status = 0;
424 u32 glk; 419 u32 glk;
425 420
426 ACPI_FUNCTION_TRACE("acpi_ec_read");
427 421
428 if (!ec || !data) 422 if (!ec || !data)
429 return_VALUE(-EINVAL); 423 return -EINVAL;
430 424
431 *data = 0; 425 *data = 0;
432 426
433 if (ec->common.global_lock) { 427 if (ec->common.global_lock) {
434 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 428 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
435 if (ACPI_FAILURE(status)) 429 if (ACPI_FAILURE(status))
436 return_VALUE(-ENODEV); 430 return -ENODEV;
437 } 431 }
438 432
439 WARN_ON(in_interrupt()); 433 WARN_ON(in_interrupt());
@@ -467,7 +461,7 @@ static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data)
467 if (ec->common.global_lock) 461 if (ec->common.global_lock)
468 acpi_release_global_lock(glk); 462 acpi_release_global_lock(glk);
469 463
470 return_VALUE(status); 464 return status;
471} 465}
472 466
473static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data) 467static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data)
@@ -475,15 +469,14 @@ static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data)
475 int status = 0; 469 int status = 0;
476 u32 glk; 470 u32 glk;
477 471
478 ACPI_FUNCTION_TRACE("acpi_ec_write");
479 472
480 if (!ec) 473 if (!ec)
481 return_VALUE(-EINVAL); 474 return -EINVAL;
482 475
483 if (ec->common.global_lock) { 476 if (ec->common.global_lock) {
484 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 477 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
485 if (ACPI_FAILURE(status)) 478 if (ACPI_FAILURE(status))
486 return_VALUE(-ENODEV); 479 return -ENODEV;
487 } 480 }
488 481
489 WARN_ON(in_interrupt()); 482 WARN_ON(in_interrupt());
@@ -516,7 +509,7 @@ static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data)
516 if (ec->common.global_lock) 509 if (ec->common.global_lock)
517 acpi_release_global_lock(glk); 510 acpi_release_global_lock(glk);
518 511
519 return_VALUE(status); 512 return status;
520} 513}
521 514
522/* 515/*
@@ -574,17 +567,16 @@ static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data)
574 acpi_status status = AE_OK; 567 acpi_status status = AE_OK;
575 u32 glk = 0; 568 u32 glk = 0;
576 569
577 ACPI_FUNCTION_TRACE("acpi_ec_query");
578 570
579 if (!ec || !data) 571 if (!ec || !data)
580 return_VALUE(-EINVAL); 572 return -EINVAL;
581 573
582 *data = 0; 574 *data = 0;
583 575
584 if (ec->common.global_lock) { 576 if (ec->common.global_lock) {
585 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 577 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
586 if (ACPI_FAILURE(status)) 578 if (ACPI_FAILURE(status))
587 return_VALUE(-ENODEV); 579 return -ENODEV;
588 } 580 }
589 581
590 /* 582 /*
@@ -613,23 +605,22 @@ end_nosem:
613 if (ec->common.global_lock) 605 if (ec->common.global_lock)
614 acpi_release_global_lock(glk); 606 acpi_release_global_lock(glk);
615 607
616 return_VALUE(result); 608 return result;
617} 609}
618static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data) 610static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data)
619{ 611{
620 int status = 0; 612 int status = 0;
621 u32 glk; 613 u32 glk;
622 614
623 ACPI_FUNCTION_TRACE("acpi_ec_query");
624 615
625 if (!ec || !data) 616 if (!ec || !data)
626 return_VALUE(-EINVAL); 617 return -EINVAL;
627 *data = 0; 618 *data = 0;
628 619
629 if (ec->common.global_lock) { 620 if (ec->common.global_lock) {
630 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 621 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
631 if (ACPI_FAILURE(status)) 622 if (ACPI_FAILURE(status))
632 return_VALUE(-ENODEV); 623 return -ENODEV;
633 } 624 }
634 625
635 down(&ec->intr.sem); 626 down(&ec->intr.sem);
@@ -662,7 +653,7 @@ static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data)
662 if (ec->common.global_lock) 653 if (ec->common.global_lock)
663 acpi_release_global_lock(glk); 654 acpi_release_global_lock(glk);
664 655
665 return_VALUE(status); 656 return status;
666} 657}
667 658
668/* -------------------------------------------------------------------------- 659/* --------------------------------------------------------------------------
@@ -691,13 +682,12 @@ static void acpi_ec_gpe_poll_query(void *ec_cxt)
691 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' 682 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
692 }; 683 };
693 684
694 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
695 685
696 if (!ec_cxt) 686 if (!ec_cxt)
697 goto end; 687 goto end;
698 688
699 if (down_interruptible (&ec->poll.sem)) { 689 if (down_interruptible (&ec->poll.sem)) {
700 return_VOID; 690 return;
701 } 691 }
702 acpi_hw_low_level_read(8, &value, &ec->common.command_addr); 692 acpi_hw_low_level_read(8, &value, &ec->common.command_addr);
703 up(&ec->poll.sem); 693 up(&ec->poll.sem);
@@ -734,7 +724,6 @@ static void acpi_ec_gpe_intr_query(void *ec_cxt)
734 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' 724 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
735 }; 725 };
736 726
737 ACPI_FUNCTION_TRACE("acpi_ec_gpe_query");
738 727
739 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI) 728 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI)
740 result = acpi_ec_query(ec, &value); 729 result = acpi_ec_query(ec, &value);
@@ -793,12 +782,15 @@ static u32 acpi_ec_gpe_intr_handler(void *data)
793 case ACPI_EC_EVENT_OBF: 782 case ACPI_EC_EVENT_OBF:
794 if (!(value & ACPI_EC_FLAG_OBF)) 783 if (!(value & ACPI_EC_FLAG_OBF))
795 break; 784 break;
785 ec->intr.expect_event = 0;
786 wake_up(&ec->intr.wait);
787 break;
796 case ACPI_EC_EVENT_IBE: 788 case ACPI_EC_EVENT_IBE:
797 if ((value & ACPI_EC_FLAG_IBF)) 789 if ((value & ACPI_EC_FLAG_IBF))
798 break; 790 break;
799 ec->intr.expect_event = 0; 791 ec->intr.expect_event = 0;
800 wake_up(&ec->intr.wait); 792 wake_up(&ec->intr.wait);
801 return ACPI_INTERRUPT_HANDLED; 793 break;
802 default: 794 default:
803 break; 795 break;
804 } 796 }
@@ -846,15 +838,14 @@ acpi_ec_space_handler(u32 function,
846 acpi_integer f_v = 0; 838 acpi_integer f_v = 0;
847 int i = 0; 839 int i = 0;
848 840
849 ACPI_FUNCTION_TRACE("acpi_ec_space_handler");
850 841
851 if ((address > 0xFF) || !value || !handler_context) 842 if ((address > 0xFF) || !value || !handler_context)
852 return_VALUE(AE_BAD_PARAMETER); 843 return AE_BAD_PARAMETER;
853 844
854 if (bit_width != 8 && acpi_strict) { 845 if (bit_width != 8 && acpi_strict) {
855 printk(KERN_WARNING PREFIX 846 printk(KERN_WARNING PREFIX
856 "acpi_ec_space_handler: bit_width should be 8\n"); 847 "acpi_ec_space_handler: bit_width should be 8\n");
857 return_VALUE(AE_BAD_PARAMETER); 848 return AE_BAD_PARAMETER;
858 } 849 }
859 850
860 ec = (union acpi_ec *)handler_context; 851 ec = (union acpi_ec *)handler_context;
@@ -893,16 +884,16 @@ acpi_ec_space_handler(u32 function,
893 out: 884 out:
894 switch (result) { 885 switch (result) {
895 case -EINVAL: 886 case -EINVAL:
896 return_VALUE(AE_BAD_PARAMETER); 887 return AE_BAD_PARAMETER;
897 break; 888 break;
898 case -ENODEV: 889 case -ENODEV:
899 return_VALUE(AE_NOT_FOUND); 890 return AE_NOT_FOUND;
900 break; 891 break;
901 case -ETIME: 892 case -ETIME:
902 return_VALUE(AE_TIME); 893 return AE_TIME;
903 break; 894 break;
904 default: 895 default:
905 return_VALUE(AE_OK); 896 return AE_OK;
906 } 897 }
907} 898}
908 899
@@ -916,7 +907,6 @@ static int acpi_ec_read_info(struct seq_file *seq, void *offset)
916{ 907{
917 union acpi_ec *ec = (union acpi_ec *)seq->private; 908 union acpi_ec *ec = (union acpi_ec *)seq->private;
918 909
919 ACPI_FUNCTION_TRACE("acpi_ec_read_info");
920 910
921 if (!ec) 911 if (!ec)
922 goto end; 912 goto end;
@@ -931,7 +921,7 @@ static int acpi_ec_read_info(struct seq_file *seq, void *offset)
931 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 921 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
932 922
933 end: 923 end:
934 return_VALUE(0); 924 return 0;
935} 925}
936 926
937static int acpi_ec_info_open_fs(struct inode *inode, struct file *file) 927static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
@@ -951,33 +941,29 @@ static int acpi_ec_add_fs(struct acpi_device *device)
951{ 941{
952 struct proc_dir_entry *entry = NULL; 942 struct proc_dir_entry *entry = NULL;
953 943
954 ACPI_FUNCTION_TRACE("acpi_ec_add_fs");
955 944
956 if (!acpi_device_dir(device)) { 945 if (!acpi_device_dir(device)) {
957 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 946 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
958 acpi_ec_dir); 947 acpi_ec_dir);
959 if (!acpi_device_dir(device)) 948 if (!acpi_device_dir(device))
960 return_VALUE(-ENODEV); 949 return -ENODEV;
961 } 950 }
962 951
963 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO, 952 entry = create_proc_entry(ACPI_EC_FILE_INFO, S_IRUGO,
964 acpi_device_dir(device)); 953 acpi_device_dir(device));
965 if (!entry) 954 if (!entry)
966 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 955 return -ENODEV;
967 "Unable to create '%s' fs entry\n",
968 ACPI_EC_FILE_INFO));
969 else { 956 else {
970 entry->proc_fops = &acpi_ec_info_ops; 957 entry->proc_fops = &acpi_ec_info_ops;
971 entry->data = acpi_driver_data(device); 958 entry->data = acpi_driver_data(device);
972 entry->owner = THIS_MODULE; 959 entry->owner = THIS_MODULE;
973 } 960 }
974 961
975 return_VALUE(0); 962 return 0;
976} 963}
977 964
978static int acpi_ec_remove_fs(struct acpi_device *device) 965static int acpi_ec_remove_fs(struct acpi_device *device)
979{ 966{
980 ACPI_FUNCTION_TRACE("acpi_ec_remove_fs");
981 967
982 if (acpi_device_dir(device)) { 968 if (acpi_device_dir(device)) {
983 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device)); 969 remove_proc_entry(ACPI_EC_FILE_INFO, acpi_device_dir(device));
@@ -985,7 +971,7 @@ static int acpi_ec_remove_fs(struct acpi_device *device)
985 acpi_device_dir(device) = NULL; 971 acpi_device_dir(device) = NULL;
986 } 972 }
987 973
988 return_VALUE(0); 974 return 0;
989} 975}
990 976
991/* -------------------------------------------------------------------------- 977/* --------------------------------------------------------------------------
@@ -998,14 +984,13 @@ static int acpi_ec_poll_add(struct acpi_device *device)
998 acpi_status status = AE_OK; 984 acpi_status status = AE_OK;
999 union acpi_ec *ec = NULL; 985 union acpi_ec *ec = NULL;
1000 986
1001 ACPI_FUNCTION_TRACE("acpi_ec_add");
1002 987
1003 if (!device) 988 if (!device)
1004 return_VALUE(-EINVAL); 989 return -EINVAL;
1005 990
1006 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); 991 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1007 if (!ec) 992 if (!ec)
1008 return_VALUE(-ENOMEM); 993 return -ENOMEM;
1009 memset(ec, 0, sizeof(union acpi_ec)); 994 memset(ec, 0, sizeof(union acpi_ec));
1010 995
1011 ec->common.handle = device->handle; 996 ec->common.handle = device->handle;
@@ -1038,8 +1023,7 @@ static int acpi_ec_poll_add(struct acpi_device *device)
1038 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, 1023 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL,
1039 &ec->common.gpe_bit); 1024 &ec->common.gpe_bit);
1040 if (ACPI_FAILURE(status)) { 1025 if (ACPI_FAILURE(status)) {
1041 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1026 ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit"));
1042 "Error obtaining GPE bit assignment\n"));
1043 result = -ENODEV; 1027 result = -ENODEV;
1044 goto end; 1028 goto end;
1045 } 1029 }
@@ -1059,7 +1043,7 @@ static int acpi_ec_poll_add(struct acpi_device *device)
1059 if (result) 1043 if (result)
1060 kfree(ec); 1044 kfree(ec);
1061 1045
1062 return_VALUE(result); 1046 return result;
1063} 1047}
1064static int acpi_ec_intr_add(struct acpi_device *device) 1048static int acpi_ec_intr_add(struct acpi_device *device)
1065{ 1049{
@@ -1067,14 +1051,13 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1067 acpi_status status = AE_OK; 1051 acpi_status status = AE_OK;
1068 union acpi_ec *ec = NULL; 1052 union acpi_ec *ec = NULL;
1069 1053
1070 ACPI_FUNCTION_TRACE("acpi_ec_add");
1071 1054
1072 if (!device) 1055 if (!device)
1073 return_VALUE(-EINVAL); 1056 return -EINVAL;
1074 1057
1075 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); 1058 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1076 if (!ec) 1059 if (!ec)
1077 return_VALUE(-ENOMEM); 1060 return -ENOMEM;
1078 memset(ec, 0, sizeof(union acpi_ec)); 1061 memset(ec, 0, sizeof(union acpi_ec));
1079 1062
1080 ec->common.handle = device->handle; 1063 ec->common.handle = device->handle;
@@ -1110,8 +1093,7 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1110 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, 1093 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL,
1111 &ec->common.gpe_bit); 1094 &ec->common.gpe_bit);
1112 if (ACPI_FAILURE(status)) { 1095 if (ACPI_FAILURE(status)) {
1113 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1096 printk(KERN_ERR PREFIX "Obtaining GPE bit assignment\n");
1114 "Error obtaining GPE bit assignment\n"));
1115 result = -ENODEV; 1097 result = -ENODEV;
1116 goto end; 1098 goto end;
1117 } 1099 }
@@ -1131,17 +1113,16 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1131 if (result) 1113 if (result)
1132 kfree(ec); 1114 kfree(ec);
1133 1115
1134 return_VALUE(result); 1116 return result;
1135} 1117}
1136 1118
1137static int acpi_ec_remove(struct acpi_device *device, int type) 1119static int acpi_ec_remove(struct acpi_device *device, int type)
1138{ 1120{
1139 union acpi_ec *ec = NULL; 1121 union acpi_ec *ec = NULL;
1140 1122
1141 ACPI_FUNCTION_TRACE("acpi_ec_remove");
1142 1123
1143 if (!device) 1124 if (!device)
1144 return_VALUE(-EINVAL); 1125 return -EINVAL;
1145 1126
1146 ec = acpi_driver_data(device); 1127 ec = acpi_driver_data(device);
1147 1128
@@ -1149,7 +1130,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
1149 1130
1150 kfree(ec); 1131 kfree(ec);
1151 1132
1152 return_VALUE(0); 1133 return 0;
1153} 1134}
1154 1135
1155static acpi_status 1136static acpi_status
@@ -1188,15 +1169,14 @@ static int acpi_ec_start(struct acpi_device *device)
1188 acpi_status status = AE_OK; 1169 acpi_status status = AE_OK;
1189 union acpi_ec *ec = NULL; 1170 union acpi_ec *ec = NULL;
1190 1171
1191 ACPI_FUNCTION_TRACE("acpi_ec_start");
1192 1172
1193 if (!device) 1173 if (!device)
1194 return_VALUE(-EINVAL); 1174 return -EINVAL;
1195 1175
1196 ec = acpi_driver_data(device); 1176 ec = acpi_driver_data(device);
1197 1177
1198 if (!ec) 1178 if (!ec)
1199 return_VALUE(-EINVAL); 1179 return -EINVAL;
1200 1180
1201 /* 1181 /*
1202 * Get I/O port addresses. Convert to GAS format. 1182 * Get I/O port addresses. Convert to GAS format.
@@ -1205,9 +1185,8 @@ static int acpi_ec_start(struct acpi_device *device)
1205 acpi_ec_io_ports, ec); 1185 acpi_ec_io_ports, ec);
1206 if (ACPI_FAILURE(status) 1186 if (ACPI_FAILURE(status)
1207 || ec->common.command_addr.register_bit_width == 0) { 1187 || ec->common.command_addr.register_bit_width == 0) {
1208 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1188 printk(KERN_ERR PREFIX "Error getting I/O port addresses\n");
1209 "Error getting I/O port addresses")); 1189 return -ENODEV;
1210 return_VALUE(-ENODEV);
1211 } 1190 }
1212 1191
1213 ec->common.status_addr = ec->common.command_addr; 1192 ec->common.status_addr = ec->common.command_addr;
@@ -1224,7 +1203,7 @@ static int acpi_ec_start(struct acpi_device *device)
1224 ACPI_GPE_EDGE_TRIGGERED, 1203 ACPI_GPE_EDGE_TRIGGERED,
1225 &acpi_ec_gpe_handler, ec); 1204 &acpi_ec_gpe_handler, ec);
1226 if (ACPI_FAILURE(status)) { 1205 if (ACPI_FAILURE(status)) {
1227 return_VALUE(-ENODEV); 1206 return -ENODEV;
1228 } 1207 }
1229 acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); 1208 acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME);
1230 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 1209 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
@@ -1236,10 +1215,10 @@ static int acpi_ec_start(struct acpi_device *device)
1236 if (ACPI_FAILURE(status)) { 1215 if (ACPI_FAILURE(status)) {
1237 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, 1216 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit,
1238 &acpi_ec_gpe_handler); 1217 &acpi_ec_gpe_handler);
1239 return_VALUE(-ENODEV); 1218 return -ENODEV;
1240 } 1219 }
1241 1220
1242 return_VALUE(AE_OK); 1221 return AE_OK;
1243} 1222}
1244 1223
1245static int acpi_ec_stop(struct acpi_device *device, int type) 1224static int acpi_ec_stop(struct acpi_device *device, int type)
@@ -1247,10 +1226,9 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
1247 acpi_status status = AE_OK; 1226 acpi_status status = AE_OK;
1248 union acpi_ec *ec = NULL; 1227 union acpi_ec *ec = NULL;
1249 1228
1250 ACPI_FUNCTION_TRACE("acpi_ec_stop");
1251 1229
1252 if (!device) 1230 if (!device)
1253 return_VALUE(-EINVAL); 1231 return -EINVAL;
1254 1232
1255 ec = acpi_driver_data(device); 1233 ec = acpi_driver_data(device);
1256 1234
@@ -1258,15 +1236,15 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
1258 ACPI_ADR_SPACE_EC, 1236 ACPI_ADR_SPACE_EC,
1259 &acpi_ec_space_handler); 1237 &acpi_ec_space_handler);
1260 if (ACPI_FAILURE(status)) 1238 if (ACPI_FAILURE(status))
1261 return_VALUE(-ENODEV); 1239 return -ENODEV;
1262 1240
1263 status = 1241 status =
1264 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, 1242 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit,
1265 &acpi_ec_gpe_handler); 1243 &acpi_ec_gpe_handler);
1266 if (ACPI_FAILURE(status)) 1244 if (ACPI_FAILURE(status))
1267 return_VALUE(-ENODEV); 1245 return -ENODEV;
1268 1246
1269 return_VALUE(0); 1247 return 0;
1270} 1248}
1271 1249
1272static acpi_status __init 1250static acpi_status __init
@@ -1536,23 +1514,22 @@ static int __init acpi_ec_init(void)
1536{ 1514{
1537 int result = 0; 1515 int result = 0;
1538 1516
1539 ACPI_FUNCTION_TRACE("acpi_ec_init");
1540 1517
1541 if (acpi_disabled) 1518 if (acpi_disabled)
1542 return_VALUE(0); 1519 return 0;
1543 1520
1544 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir); 1521 acpi_ec_dir = proc_mkdir(ACPI_EC_CLASS, acpi_root_dir);
1545 if (!acpi_ec_dir) 1522 if (!acpi_ec_dir)
1546 return_VALUE(-ENODEV); 1523 return -ENODEV;
1547 1524
1548 /* Now register the driver for the EC */ 1525 /* Now register the driver for the EC */
1549 result = acpi_bus_register_driver(&acpi_ec_driver); 1526 result = acpi_bus_register_driver(&acpi_ec_driver);
1550 if (result < 0) { 1527 if (result < 0) {
1551 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir); 1528 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1552 return_VALUE(-ENODEV); 1529 return -ENODEV;
1553 } 1530 }
1554 1531
1555 return_VALUE(result); 1532 return result;
1556} 1533}
1557 1534
1558subsys_initcall(acpi_ec_init); 1535subsys_initcall(acpi_ec_init);
@@ -1561,13 +1538,12 @@ subsys_initcall(acpi_ec_init);
1561#if 0 1538#if 0
1562static void __exit acpi_ec_exit(void) 1539static void __exit acpi_ec_exit(void)
1563{ 1540{
1564 ACPI_FUNCTION_TRACE("acpi_ec_exit");
1565 1541
1566 acpi_bus_unregister_driver(&acpi_ec_driver); 1542 acpi_bus_unregister_driver(&acpi_ec_driver);
1567 1543
1568 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir); 1544 remove_proc_entry(ACPI_EC_CLASS, acpi_root_dir);
1569 1545
1570 return_VOID; 1546 return;
1571} 1547}
1572#endif /* 0 */ 1548#endif /* 0 */
1573 1549
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index 2dbb1b0f11d5..a901b23e95e7 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -48,18 +48,17 @@ acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
48 static int chars_remaining = 0; 48 static int chars_remaining = 0;
49 static char *ptr; 49 static char *ptr;
50 50
51 ACPI_FUNCTION_TRACE("acpi_system_read_event");
52 51
53 if (!chars_remaining) { 52 if (!chars_remaining) {
54 memset(&event, 0, sizeof(struct acpi_bus_event)); 53 memset(&event, 0, sizeof(struct acpi_bus_event));
55 54
56 if ((file->f_flags & O_NONBLOCK) 55 if ((file->f_flags & O_NONBLOCK)
57 && (list_empty(&acpi_bus_event_list))) 56 && (list_empty(&acpi_bus_event_list)))
58 return_VALUE(-EAGAIN); 57 return -EAGAIN;
59 58
60 result = acpi_bus_receive_event(&event); 59 result = acpi_bus_receive_event(&event);
61 if (result) 60 if (result)
62 return_VALUE(result); 61 return result;
63 62
64 chars_remaining = sprintf(str, "%s %s %08x %08x\n", 63 chars_remaining = sprintf(str, "%s %s %08x %08x\n",
65 event.device_class ? event. 64 event.device_class ? event.
@@ -75,13 +74,13 @@ acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
75 } 74 }
76 75
77 if (copy_to_user(buffer, ptr, count)) 76 if (copy_to_user(buffer, ptr, count))
78 return_VALUE(-EFAULT); 77 return -EFAULT;
79 78
80 *ppos += count; 79 *ppos += count;
81 chars_remaining -= count; 80 chars_remaining -= count;
82 ptr += count; 81 ptr += count;
83 82
84 return_VALUE(count); 83 return count;
85} 84}
86 85
87static int acpi_system_close_event(struct inode *inode, struct file *file) 86static int acpi_system_close_event(struct inode *inode, struct file *file)
@@ -112,22 +111,18 @@ static int __init acpi_event_init(void)
112 struct proc_dir_entry *entry; 111 struct proc_dir_entry *entry;
113 int error = 0; 112 int error = 0;
114 113
115 ACPI_FUNCTION_TRACE("acpi_event_init");
116 114
117 if (acpi_disabled) 115 if (acpi_disabled)
118 return_VALUE(0); 116 return 0;
119 117
120 /* 'event' [R] */ 118 /* 'event' [R] */
121 entry = create_proc_entry("event", S_IRUSR, acpi_root_dir); 119 entry = create_proc_entry("event", S_IRUSR, acpi_root_dir);
122 if (entry) 120 if (entry)
123 entry->proc_fops = &acpi_system_event_ops; 121 entry->proc_fops = &acpi_system_event_ops;
124 else { 122 else {
125 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 123 error = -ENODEV;
126 "Unable to create '%s' proc fs entry\n",
127 "event"));
128 error = -EFAULT;
129 } 124 }
130 return_VALUE(error); 125 return error;
131} 126}
132 127
133subsys_initcall(acpi_event_init); 128subsys_initcall(acpi_event_init);
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c
index f01d339407f8..c76c0583ca6a 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/events/evgpe.c
@@ -382,7 +382,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
382 u32 status_reg; 382 u32 status_reg;
383 u32 enable_reg; 383 u32 enable_reg;
384 acpi_cpu_flags flags; 384 acpi_cpu_flags flags;
385 acpi_cpu_flags hw_flags;
386 acpi_native_uint i; 385 acpi_native_uint i;
387 acpi_native_uint j; 386 acpi_native_uint j;
388 387
@@ -394,8 +393,11 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
394 return (int_status); 393 return (int_status);
395 } 394 }
396 395
397 /* We need to hold the GPE lock now, hardware lock in the loop */ 396 /*
398 397 * We need to obtain the GPE lock for both the data structs and registers
398 * Note: Not necessary to obtain the hardware lock, since the GPE registers
399 * are owned by the gpe_lock.
400 */
399 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 401 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
400 402
401 /* Examine all GPE blocks attached to this interrupt level */ 403 /* Examine all GPE blocks attached to this interrupt level */
@@ -413,8 +415,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
413 415
414 gpe_register_info = &gpe_block->register_info[i]; 416 gpe_register_info = &gpe_block->register_info[i];
415 417
416 hw_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
417
418 /* Read the Status Register */ 418 /* Read the Status Register */
419 419
420 status = 420 status =
@@ -423,8 +423,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
423 &gpe_register_info-> 423 &gpe_register_info->
424 status_address); 424 status_address);
425 if (ACPI_FAILURE(status)) { 425 if (ACPI_FAILURE(status)) {
426 acpi_os_release_lock(acpi_gbl_hardware_lock,
427 hw_flags);
428 goto unlock_and_exit; 426 goto unlock_and_exit;
429 } 427 }
430 428
@@ -435,8 +433,6 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
435 &enable_reg, 433 &enable_reg,
436 &gpe_register_info-> 434 &gpe_register_info->
437 enable_address); 435 enable_address);
438 acpi_os_release_lock(acpi_gbl_hardware_lock, hw_flags);
439
440 if (ACPI_FAILURE(status)) { 436 if (ACPI_FAILURE(status)) {
441 goto unlock_and_exit; 437 goto unlock_and_exit;
442 } 438 }
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/events/evxface.c
index 76c34a66e0e0..4f948df17ab9 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/events/evxface.c
@@ -414,12 +414,13 @@ acpi_remove_notify_handler(acpi_handle device,
414 414
415 if ((!device) || 415 if ((!device) ||
416 (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { 416 (!handler) || (handler_type > ACPI_MAX_NOTIFY_HANDLER_TYPE)) {
417 return_ACPI_STATUS(AE_BAD_PARAMETER); 417 status = AE_BAD_PARAMETER;
418 goto exit;
418 } 419 }
419 420
420 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 421 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
421 if (ACPI_FAILURE(status)) { 422 if (ACPI_FAILURE(status)) {
422 return_ACPI_STATUS(status); 423 goto exit;
423 } 424 }
424 425
425 /* Convert and validate the device handle */ 426 /* Convert and validate the device handle */
@@ -427,7 +428,7 @@ acpi_remove_notify_handler(acpi_handle device,
427 node = acpi_ns_map_handle_to_node(device); 428 node = acpi_ns_map_handle_to_node(device);
428 if (!node) { 429 if (!node) {
429 status = AE_BAD_PARAMETER; 430 status = AE_BAD_PARAMETER;
430 goto unlock_and_exit; 431 goto unlock;
431 } 432 }
432 433
433 /* Root Object */ 434 /* Root Object */
@@ -441,7 +442,7 @@ acpi_remove_notify_handler(acpi_handle device,
441 ((handler_type & ACPI_DEVICE_NOTIFY) && 442 ((handler_type & ACPI_DEVICE_NOTIFY) &&
442 !acpi_gbl_device_notify.handler)) { 443 !acpi_gbl_device_notify.handler)) {
443 status = AE_NOT_EXIST; 444 status = AE_NOT_EXIST;
444 goto unlock_and_exit; 445 goto unlock;
445 } 446 }
446 447
447 /* Make sure all deferred tasks are completed */ 448 /* Make sure all deferred tasks are completed */
@@ -450,7 +451,7 @@ acpi_remove_notify_handler(acpi_handle device,
450 acpi_os_wait_events_complete(NULL); 451 acpi_os_wait_events_complete(NULL);
451 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 452 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
452 if (ACPI_FAILURE(status)) { 453 if (ACPI_FAILURE(status)) {
453 return_ACPI_STATUS(status); 454 goto exit;
454 } 455 }
455 456
456 if (handler_type & ACPI_SYSTEM_NOTIFY) { 457 if (handler_type & ACPI_SYSTEM_NOTIFY) {
@@ -473,7 +474,7 @@ acpi_remove_notify_handler(acpi_handle device,
473 474
474 if (!acpi_ev_is_notify_object(node)) { 475 if (!acpi_ev_is_notify_object(node)) {
475 status = AE_TYPE; 476 status = AE_TYPE;
476 goto unlock_and_exit; 477 goto unlock;
477 } 478 }
478 479
479 /* Check for an existing internal object */ 480 /* Check for an existing internal object */
@@ -481,7 +482,7 @@ acpi_remove_notify_handler(acpi_handle device,
481 obj_desc = acpi_ns_get_attached_object(node); 482 obj_desc = acpi_ns_get_attached_object(node);
482 if (!obj_desc) { 483 if (!obj_desc) {
483 status = AE_NOT_EXIST; 484 status = AE_NOT_EXIST;
484 goto unlock_and_exit; 485 goto unlock;
485 } 486 }
486 487
487 /* Object exists - make sure there's an existing handler */ 488 /* Object exists - make sure there's an existing handler */
@@ -491,7 +492,7 @@ acpi_remove_notify_handler(acpi_handle device,
491 if ((!notify_obj) || 492 if ((!notify_obj) ||
492 (notify_obj->notify.handler != handler)) { 493 (notify_obj->notify.handler != handler)) {
493 status = AE_BAD_PARAMETER; 494 status = AE_BAD_PARAMETER;
494 goto unlock_and_exit; 495 goto unlock;
495 } 496 }
496 /* Make sure all deferred tasks are completed */ 497 /* Make sure all deferred tasks are completed */
497 498
@@ -499,7 +500,7 @@ acpi_remove_notify_handler(acpi_handle device,
499 acpi_os_wait_events_complete(NULL); 500 acpi_os_wait_events_complete(NULL);
500 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 501 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
501 if (ACPI_FAILURE(status)) { 502 if (ACPI_FAILURE(status)) {
502 return_ACPI_STATUS(status); 503 goto exit;
503 } 504 }
504 505
505 /* Remove the handler */ 506 /* Remove the handler */
@@ -512,7 +513,7 @@ acpi_remove_notify_handler(acpi_handle device,
512 if ((!notify_obj) || 513 if ((!notify_obj) ||
513 (notify_obj->notify.handler != handler)) { 514 (notify_obj->notify.handler != handler)) {
514 status = AE_BAD_PARAMETER; 515 status = AE_BAD_PARAMETER;
515 goto unlock_and_exit; 516 goto unlock;
516 } 517 }
517 /* Make sure all deferred tasks are completed */ 518 /* Make sure all deferred tasks are completed */
518 519
@@ -520,7 +521,7 @@ acpi_remove_notify_handler(acpi_handle device,
520 acpi_os_wait_events_complete(NULL); 521 acpi_os_wait_events_complete(NULL);
521 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); 522 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
522 if (ACPI_FAILURE(status)) { 523 if (ACPI_FAILURE(status)) {
523 return_ACPI_STATUS(status); 524 goto exit;
524 } 525 }
525 526
526 /* Remove the handler */ 527 /* Remove the handler */
@@ -529,8 +530,11 @@ acpi_remove_notify_handler(acpi_handle device,
529 } 530 }
530 } 531 }
531 532
532 unlock_and_exit: 533unlock:
533 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 534 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
535exit:
536 if (ACPI_FAILURE(status))
537 ACPI_EXCEPTION((AE_INFO, status, "Removing notify handler"));
534 return_ACPI_STATUS(status); 538 return_ACPI_STATUS(status);
535} 539}
536 540
@@ -568,12 +572,13 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
568 /* Parameter validation */ 572 /* Parameter validation */
569 573
570 if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) { 574 if ((!address) || (type > ACPI_GPE_XRUPT_TYPE_MASK)) {
571 return_ACPI_STATUS(AE_BAD_PARAMETER); 575 status = AE_BAD_PARAMETER;
576 goto exit;
572 } 577 }
573 578
574 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); 579 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
575 if (ACPI_FAILURE(status)) { 580 if (ACPI_FAILURE(status)) {
576 return_ACPI_STATUS(status); 581 goto exit;
577 } 582 }
578 583
579 /* Ensure that we have a valid GPE number */ 584 /* Ensure that we have a valid GPE number */
@@ -581,7 +586,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
581 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number); 586 gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
582 if (!gpe_event_info) { 587 if (!gpe_event_info) {
583 status = AE_BAD_PARAMETER; 588 status = AE_BAD_PARAMETER;
584 goto unlock_and_exit; 589 goto unlock;
585 } 590 }
586 591
587 /* Make sure that there isn't a handler there already */ 592 /* Make sure that there isn't a handler there already */
@@ -589,7 +594,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
589 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) == 594 if ((gpe_event_info->flags & ACPI_GPE_DISPATCH_MASK) ==
590 ACPI_GPE_DISPATCH_HANDLER) { 595 ACPI_GPE_DISPATCH_HANDLER) {
591 status = AE_ALREADY_EXISTS; 596 status = AE_ALREADY_EXISTS;
592 goto unlock_and_exit; 597 goto unlock;
593 } 598 }
594 599
595 /* Allocate and init handler object */ 600 /* Allocate and init handler object */
@@ -597,7 +602,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
597 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info)); 602 handler = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_handler_info));
598 if (!handler) { 603 if (!handler) {
599 status = AE_NO_MEMORY; 604 status = AE_NO_MEMORY;
600 goto unlock_and_exit; 605 goto unlock;
601 } 606 }
602 607
603 handler->address = address; 608 handler->address = address;
@@ -608,7 +613,7 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
608 613
609 status = acpi_ev_disable_gpe(gpe_event_info); 614 status = acpi_ev_disable_gpe(gpe_event_info);
610 if (ACPI_FAILURE(status)) { 615 if (ACPI_FAILURE(status)) {
611 goto unlock_and_exit; 616 goto unlock;
612 } 617 }
613 618
614 /* Install the handler */ 619 /* Install the handler */
@@ -623,8 +628,12 @@ acpi_install_gpe_handler(acpi_handle gpe_device,
623 628
624 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 629 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
625 630
626 unlock_and_exit: 631unlock:
627 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); 632 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
633exit:
634 if (ACPI_FAILURE(status))
635 ACPI_EXCEPTION((AE_INFO, status,
636 "Installing notify handler failed"));
628 return_ACPI_STATUS(status); 637 return_ACPI_STATUS(status);
629} 638}
630 639
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c
index 823352435e08..83fed079a276 100644
--- a/drivers/acpi/executer/exconfig.c
+++ b/drivers/acpi/executer/exconfig.c
@@ -266,6 +266,10 @@ acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
266 } 266 }
267 } 267 }
268 268
269 ACPI_INFO((AE_INFO,
270 "Dynamic OEM Table Load - [%4.4s] OemId [%6.6s] OemTableId [%8.8s]",
271 table->signature, table->oem_id, table->oem_table_id));
272
269 *return_desc = ddb_handle; 273 *return_desc = ddb_handle;
270 return_ACPI_STATUS(status); 274 return_ACPI_STATUS(status);
271} 275}
@@ -446,6 +450,10 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
446 return_ACPI_STATUS(status); 450 return_ACPI_STATUS(status);
447 } 451 }
448 452
453 ACPI_INFO((AE_INFO,
454 "Dynamic SSDT Load - OemId [%6.6s] OemTableId [%8.8s]",
455 table_ptr->oem_id, table_ptr->oem_table_id));
456
449 cleanup: 457 cleanup:
450 if (ACPI_FAILURE(status)) { 458 if (ACPI_FAILURE(status)) {
451 ACPI_FREE(table_ptr); 459 ACPI_FREE(table_ptr);
diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/executer/excreate.c
index 106dc7219df7..34eec82c1b1e 100644
--- a/drivers/acpi/executer/excreate.c
+++ b/drivers/acpi/executer/excreate.c
@@ -177,7 +177,7 @@ acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state)
177 * that the event is created in an unsignalled state 177 * that the event is created in an unsignalled state
178 */ 178 */
179 status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, 179 status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0,
180 &obj_desc->event.semaphore); 180 &obj_desc->event.os_semaphore);
181 if (ACPI_FAILURE(status)) { 181 if (ACPI_FAILURE(status)) {
182 goto cleanup; 182 goto cleanup;
183 } 183 }
@@ -226,12 +226,9 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
226 goto cleanup; 226 goto cleanup;
227 } 227 }
228 228
229 /* 229 /* Create the actual OS Mutex */
230 * Create the actual OS semaphore. 230
231 * One unit max to make it a mutex, with one initial unit to allow 231 status = acpi_os_create_mutex(&obj_desc->mutex.os_mutex);
232 * the mutex to be acquired.
233 */
234 status = acpi_os_create_semaphore(1, 1, &obj_desc->mutex.semaphore);
235 if (ACPI_FAILURE(status)) { 232 if (ACPI_FAILURE(status)) {
236 goto cleanup; 233 goto cleanup;
237 } 234 }
@@ -565,7 +562,7 @@ acpi_ex_create_method(u8 * aml_start,
565 obj_desc->method.aml_length = aml_length; 562 obj_desc->method.aml_length = aml_length;
566 563
567 /* 564 /*
568 * Disassemble the method flags. Split off the Arg Count 565 * Disassemble the method flags. Split off the Arg Count
569 * for efficiency 566 * for efficiency
570 */ 567 */
571 method_flags = (u8) operand[1]->integer.value; 568 method_flags = (u8) operand[1]->integer.value;
@@ -576,21 +573,19 @@ acpi_ex_create_method(u8 * aml_start,
576 (u8) (method_flags & AML_METHOD_ARG_COUNT); 573 (u8) (method_flags & AML_METHOD_ARG_COUNT);
577 574
578 /* 575 /*
579 * Get the concurrency count. If required, a semaphore will be 576 * Get the sync_level. If method is serialized, a mutex will be
580 * created for this method when it is parsed. 577 * created for this method when it is parsed.
581 */ 578 */
582 if (acpi_gbl_all_methods_serialized) { 579 if (acpi_gbl_all_methods_serialized) {
583 obj_desc->method.concurrency = 1; 580 obj_desc->method.sync_level = 0;
584 obj_desc->method.method_flags |= AML_METHOD_SERIALIZED; 581 obj_desc->method.method_flags |= AML_METHOD_SERIALIZED;
585 } else if (method_flags & AML_METHOD_SERIALIZED) { 582 } else if (method_flags & AML_METHOD_SERIALIZED) {
586 /* 583 /*
587 * ACPI 1.0: Concurrency = 1 584 * ACPI 1.0: sync_level = 0
588 * ACPI 2.0: Concurrency = (sync_level (in method declaration) + 1) 585 * ACPI 2.0: sync_level = sync_level in method declaration
589 */ 586 */
590 obj_desc->method.concurrency = (u8) 587 obj_desc->method.sync_level = (u8)
591 (((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1); 588 ((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4);
592 } else {
593 obj_desc->method.concurrency = ACPI_INFINITE_CONCURRENCY;
594 } 589 }
595 590
596 /* Attach the new object to the method Node */ 591 /* Attach the new object to the method Node */
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index 7b9718e976bf..2450943add33 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -118,14 +118,14 @@ static struct acpi_exdump_info acpi_ex_dump_device[4] = {
118 118
119static struct acpi_exdump_info acpi_ex_dump_event[2] = { 119static struct acpi_exdump_info acpi_ex_dump_event[2] = {
120 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL}, 120 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_event), NULL},
121 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"} 121 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.os_semaphore), "OsSemaphore"}
122}; 122};
123 123
124static struct acpi_exdump_info acpi_ex_dump_method[8] = { 124static struct acpi_exdump_info acpi_ex_dump_method[8] = {
125 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL}, 125 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL},
126 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "ParamCount"}, 126 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "ParamCount"},
127 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"}, 127 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.sync_level), "Sync Level"},
128 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"}, 128 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.mutex), "Mutex"},
129 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"}, 129 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"},
130 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"}, 130 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"},
131 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"}, 131 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"},
@@ -138,7 +138,7 @@ static struct acpi_exdump_info acpi_ex_dump_mutex[5] = {
138 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"}, 138 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"},
139 {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth), 139 {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth),
140 "Acquire Depth"}, 140 "Acquire Depth"},
141 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.semaphore), "Semaphore"} 141 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"}
142}; 142};
143 143
144static struct acpi_exdump_info acpi_ex_dump_region[7] = { 144static struct acpi_exdump_info acpi_ex_dump_region[7] = {
diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/executer/exfldio.c
index 051053f7cccb..40f0bee6faa5 100644
--- a/drivers/acpi/executer/exfldio.c
+++ b/drivers/acpi/executer/exfldio.c
@@ -727,11 +727,23 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
727 return_ACPI_STATUS(status); 727 return_ACPI_STATUS(status);
728 } 728 }
729 729
730 /* Merge with previous datum if necessary */ 730 /*
731 731 * Merge with previous datum if necessary.
732 merged_datum |= raw_datum << 732 *
733 (obj_desc->common_field.access_bit_width - 733 * Note: Before the shift, check if the shift value will be larger than
734 obj_desc->common_field.start_field_bit_offset); 734 * the integer size. If so, there is no need to perform the operation.
735 * This avoids the differences in behavior between different compilers
736 * concerning shift values larger than the target data width.
737 */
738 if ((obj_desc->common_field.access_bit_width -
739 obj_desc->common_field.start_field_bit_offset) <
740 ACPI_INTEGER_BIT_SIZE) {
741 merged_datum |=
742 raw_datum << (obj_desc->common_field.
743 access_bit_width -
744 obj_desc->common_field.
745 start_field_bit_offset);
746 }
735 747
736 if (i == datum_count) { 748 if (i == datum_count) {
737 break; 749 break;
@@ -808,13 +820,23 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
808 return_ACPI_STATUS(AE_BUFFER_OVERFLOW); 820 return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
809 } 821 }
810 822
811 /* Compute the number of datums (access width data items) */ 823 /*
824 * Create the bitmasks used for bit insertion.
825 * Note: This if/else is used to bypass compiler differences with the
826 * shift operator
827 */
828 if (obj_desc->common_field.access_bit_width == ACPI_INTEGER_BIT_SIZE) {
829 width_mask = ACPI_INTEGER_MAX;
830 } else {
831 width_mask =
832 ACPI_MASK_BITS_ABOVE(obj_desc->common_field.
833 access_bit_width);
834 }
812 835
813 width_mask = 836 mask = width_mask &
814 ACPI_MASK_BITS_ABOVE(obj_desc->common_field.access_bit_width); 837 ACPI_MASK_BITS_BELOW(obj_desc->common_field.start_field_bit_offset);
815 mask = 838
816 width_mask & ACPI_MASK_BITS_BELOW(obj_desc->common_field. 839 /* Compute the number of datums (access width data items) */
817 start_field_bit_offset);
818 840
819 datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length, 841 datum_count = ACPI_ROUND_UP_TO(obj_desc->common_field.bit_length,
820 obj_desc->common_field.access_bit_width); 842 obj_desc->common_field.access_bit_width);
@@ -848,12 +870,29 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
848 return_ACPI_STATUS(status); 870 return_ACPI_STATUS(status);
849 } 871 }
850 872
851 /* Start new output datum by merging with previous input datum */
852
853 field_offset += obj_desc->common_field.access_byte_width; 873 field_offset += obj_desc->common_field.access_byte_width;
854 merged_datum = raw_datum >> 874
855 (obj_desc->common_field.access_bit_width - 875 /*
856 obj_desc->common_field.start_field_bit_offset); 876 * Start new output datum by merging with previous input datum
877 * if necessary.
878 *
879 * Note: Before the shift, check if the shift value will be larger than
880 * the integer size. If so, there is no need to perform the operation.
881 * This avoids the differences in behavior between different compilers
882 * concerning shift values larger than the target data width.
883 */
884 if ((obj_desc->common_field.access_bit_width -
885 obj_desc->common_field.start_field_bit_offset) <
886 ACPI_INTEGER_BIT_SIZE) {
887 merged_datum =
888 raw_datum >> (obj_desc->common_field.
889 access_bit_width -
890 obj_desc->common_field.
891 start_field_bit_offset);
892 } else {
893 merged_datum = 0;
894 }
895
857 mask = width_mask; 896 mask = width_mask;
858 897
859 if (i == datum_count) { 898 if (i == datum_count) {
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c
index 93098d68cadf..d8ac2877cf05 100644
--- a/drivers/acpi/executer/exmutex.c
+++ b/drivers/acpi/executer/exmutex.c
@@ -161,12 +161,13 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
161 161
162 /* 162 /*
163 * Current Sync must be less than or equal to the sync level of the 163 * Current Sync must be less than or equal to the sync level of the
164 * mutex. This mechanism provides some deadlock prevention 164 * mutex. This mechanism provides some deadlock prevention
165 */ 165 */
166 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) { 166 if (walk_state->thread->current_sync_level > obj_desc->mutex.sync_level) {
167 ACPI_ERROR((AE_INFO, 167 ACPI_ERROR((AE_INFO,
168 "Cannot acquire Mutex [%4.4s], incorrect SyncLevel", 168 "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%d)",
169 acpi_ut_get_node_name(obj_desc->mutex.node))); 169 acpi_ut_get_node_name(obj_desc->mutex.node),
170 walk_state->thread->current_sync_level));
170 return_ACPI_STATUS(AE_AML_MUTEX_ORDER); 171 return_ACPI_STATUS(AE_AML_MUTEX_ORDER);
171 } 172 }
172 173
@@ -178,8 +179,7 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
178 179
179 if ((obj_desc->mutex.owner_thread->thread_id == 180 if ((obj_desc->mutex.owner_thread->thread_id ==
180 walk_state->thread->thread_id) || 181 walk_state->thread->thread_id) ||
181 (obj_desc->mutex.semaphore == 182 (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK)) {
182 acpi_gbl_global_lock_semaphore)) {
183 /* 183 /*
184 * The mutex is already owned by this thread, 184 * The mutex is already owned by this thread,
185 * just increment the acquisition depth 185 * just increment the acquisition depth
@@ -264,7 +264,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
264 */ 264 */
265 if ((obj_desc->mutex.owner_thread->thread_id != 265 if ((obj_desc->mutex.owner_thread->thread_id !=
266 walk_state->thread->thread_id) 266 walk_state->thread->thread_id)
267 && (obj_desc->mutex.semaphore != acpi_gbl_global_lock_semaphore)) { 267 && (obj_desc->mutex.os_mutex != ACPI_GLOBAL_LOCK)) {
268 ACPI_ERROR((AE_INFO, 268 ACPI_ERROR((AE_INFO,
269 "Thread %X cannot release Mutex [%4.4s] acquired by thread %X", 269 "Thread %X cannot release Mutex [%4.4s] acquired by thread %X",
270 walk_state->thread->thread_id, 270 walk_state->thread->thread_id,
diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/executer/exsystem.c
index 52beee3674a0..6b5d1e6ce94b 100644
--- a/drivers/acpi/executer/exsystem.c
+++ b/drivers/acpi/executer/exsystem.c
@@ -63,14 +63,14 @@ ACPI_MODULE_NAME("exsystem")
63 * interpreter is released. 63 * interpreter is released.
64 * 64 *
65 ******************************************************************************/ 65 ******************************************************************************/
66acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout) 66acpi_status acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout)
67{ 67{
68 acpi_status status; 68 acpi_status status;
69 acpi_status status2; 69 acpi_status status2;
70 70
71 ACPI_FUNCTION_TRACE(ex_system_wait_semaphore); 71 ACPI_FUNCTION_TRACE(ex_system_wait_semaphore);
72 72
73 status = acpi_os_wait_semaphore(semaphore, 1, 0); 73 status = acpi_os_wait_semaphore(semaphore, 1, ACPI_DO_NOT_WAIT);
74 if (ACPI_SUCCESS(status)) { 74 if (ACPI_SUCCESS(status)) {
75 return_ACPI_STATUS(status); 75 return_ACPI_STATUS(status);
76 } 76 }
@@ -103,6 +103,59 @@ acpi_status acpi_ex_system_wait_semaphore(acpi_handle semaphore, u16 timeout)
103 103
104/******************************************************************************* 104/*******************************************************************************
105 * 105 *
106 * FUNCTION: acpi_ex_system_wait_mutex
107 *
108 * PARAMETERS: Mutex - Mutex to wait on
109 * Timeout - Max time to wait
110 *
111 * RETURN: Status
112 *
113 * DESCRIPTION: Implements a semaphore wait with a check to see if the
114 * semaphore is available immediately. If it is not, the
115 * interpreter is released.
116 *
117 ******************************************************************************/
118
119acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout)
120{
121 acpi_status status;
122 acpi_status status2;
123
124 ACPI_FUNCTION_TRACE(ex_system_wait_mutex);
125
126 status = acpi_os_acquire_mutex(mutex, ACPI_DO_NOT_WAIT);
127 if (ACPI_SUCCESS(status)) {
128 return_ACPI_STATUS(status);
129 }
130
131 if (status == AE_TIME) {
132
133 /* We must wait, so unlock the interpreter */
134
135 acpi_ex_exit_interpreter();
136
137 status = acpi_os_acquire_mutex(mutex, timeout);
138
139 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
140 "*** Thread awake after blocking, %s\n",
141 acpi_format_exception(status)));
142
143 /* Reacquire the interpreter */
144
145 status2 = acpi_ex_enter_interpreter();
146 if (ACPI_FAILURE(status2)) {
147
148 /* Report fatal error, could not acquire interpreter */
149
150 return_ACPI_STATUS(status2);
151 }
152 }
153
154 return_ACPI_STATUS(status);
155}
156
157/*******************************************************************************
158 *
106 * FUNCTION: acpi_ex_system_do_stall 159 * FUNCTION: acpi_ex_system_do_stall
107 * 160 *
108 * PARAMETERS: how_long - The amount of time to stall, 161 * PARAMETERS: how_long - The amount of time to stall,
@@ -176,7 +229,7 @@ acpi_status acpi_ex_system_do_suspend(acpi_integer how_long)
176 * 229 *
177 * FUNCTION: acpi_ex_system_acquire_mutex 230 * FUNCTION: acpi_ex_system_acquire_mutex
178 * 231 *
179 * PARAMETERS: time_desc - The 'time to delay' object descriptor 232 * PARAMETERS: time_desc - Maximum time to wait for the mutex
180 * obj_desc - The object descriptor for this op 233 * obj_desc - The object descriptor for this op
181 * 234 *
182 * RETURN: Status 235 * RETURN: Status
@@ -201,14 +254,14 @@ acpi_ex_system_acquire_mutex(union acpi_operand_object * time_desc,
201 254
202 /* Support for the _GL_ Mutex object -- go get the global lock */ 255 /* Support for the _GL_ Mutex object -- go get the global lock */
203 256
204 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { 257 if (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK) {
205 status = 258 status =
206 acpi_ev_acquire_global_lock((u16) time_desc->integer.value); 259 acpi_ev_acquire_global_lock((u16) time_desc->integer.value);
207 return_ACPI_STATUS(status); 260 return_ACPI_STATUS(status);
208 } 261 }
209 262
210 status = acpi_ex_system_wait_semaphore(obj_desc->mutex.semaphore, 263 status = acpi_ex_system_wait_mutex(obj_desc->mutex.os_mutex,
211 (u16) time_desc->integer.value); 264 (u16) time_desc->integer.value);
212 return_ACPI_STATUS(status); 265 return_ACPI_STATUS(status);
213} 266}
214 267
@@ -239,13 +292,13 @@ acpi_status acpi_ex_system_release_mutex(union acpi_operand_object *obj_desc)
239 292
240 /* Support for the _GL_ Mutex object -- release the global lock */ 293 /* Support for the _GL_ Mutex object -- release the global lock */
241 294
242 if (obj_desc->mutex.semaphore == acpi_gbl_global_lock_semaphore) { 295 if (obj_desc->mutex.os_mutex == ACPI_GLOBAL_LOCK) {
243 status = acpi_ev_release_global_lock(); 296 status = acpi_ev_release_global_lock();
244 return_ACPI_STATUS(status); 297 return_ACPI_STATUS(status);
245 } 298 }
246 299
247 status = acpi_os_signal_semaphore(obj_desc->mutex.semaphore, 1); 300 acpi_os_release_mutex(obj_desc->mutex.os_mutex);
248 return_ACPI_STATUS(status); 301 return_ACPI_STATUS(AE_OK);
249} 302}
250 303
251/******************************************************************************* 304/*******************************************************************************
@@ -268,7 +321,8 @@ acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc)
268 ACPI_FUNCTION_TRACE(ex_system_signal_event); 321 ACPI_FUNCTION_TRACE(ex_system_signal_event);
269 322
270 if (obj_desc) { 323 if (obj_desc) {
271 status = acpi_os_signal_semaphore(obj_desc->event.semaphore, 1); 324 status =
325 acpi_os_signal_semaphore(obj_desc->event.os_semaphore, 1);
272 } 326 }
273 327
274 return_ACPI_STATUS(status); 328 return_ACPI_STATUS(status);
@@ -299,7 +353,7 @@ acpi_ex_system_wait_event(union acpi_operand_object *time_desc,
299 353
300 if (obj_desc) { 354 if (obj_desc) {
301 status = 355 status =
302 acpi_ex_system_wait_semaphore(obj_desc->event.semaphore, 356 acpi_ex_system_wait_semaphore(obj_desc->event.os_semaphore,
303 (u16) time_desc->integer. 357 (u16) time_desc->integer.
304 value); 358 value);
305 } 359 }
@@ -322,7 +376,7 @@ acpi_ex_system_wait_event(union acpi_operand_object *time_desc,
322acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc) 376acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc)
323{ 377{
324 acpi_status status = AE_OK; 378 acpi_status status = AE_OK;
325 void *temp_semaphore; 379 acpi_semaphore temp_semaphore;
326 380
327 ACPI_FUNCTION_ENTRY(); 381 ACPI_FUNCTION_ENTRY();
328 382
@@ -333,8 +387,8 @@ acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc)
333 status = 387 status =
334 acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore); 388 acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, &temp_semaphore);
335 if (ACPI_SUCCESS(status)) { 389 if (ACPI_SUCCESS(status)) {
336 (void)acpi_os_delete_semaphore(obj_desc->event.semaphore); 390 (void)acpi_os_delete_semaphore(obj_desc->event.os_semaphore);
337 obj_desc->event.semaphore = temp_semaphore; 391 obj_desc->event.os_semaphore = temp_semaphore;
338 } 392 }
339 393
340 return (status); 394 return (status);
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 1cd25784b7a4..38acc69b21bc 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -78,7 +78,6 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset)
78 struct acpi_fan *fan = seq->private; 78 struct acpi_fan *fan = seq->private;
79 int state = 0; 79 int state = 0;
80 80
81 ACPI_FUNCTION_TRACE("acpi_fan_read_state");
82 81
83 if (fan) { 82 if (fan) {
84 if (acpi_bus_get_power(fan->handle, &state)) 83 if (acpi_bus_get_power(fan->handle, &state))
@@ -87,7 +86,7 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset)
87 seq_printf(seq, "status: %s\n", 86 seq_printf(seq, "status: %s\n",
88 !state ? "on" : "off"); 87 !state ? "on" : "off");
89 } 88 }
90 return_VALUE(0); 89 return 0;
91} 90}
92 91
93static int acpi_fan_state_open_fs(struct inode *inode, struct file *file) 92static int acpi_fan_state_open_fs(struct inode *inode, struct file *file)
@@ -104,22 +103,21 @@ acpi_fan_write_state(struct file *file, const char __user * buffer,
104 struct acpi_fan *fan = (struct acpi_fan *)m->private; 103 struct acpi_fan *fan = (struct acpi_fan *)m->private;
105 char state_string[12] = { '\0' }; 104 char state_string[12] = { '\0' };
106 105
107 ACPI_FUNCTION_TRACE("acpi_fan_write_state");
108 106
109 if (!fan || (count > sizeof(state_string) - 1)) 107 if (!fan || (count > sizeof(state_string) - 1))
110 return_VALUE(-EINVAL); 108 return -EINVAL;
111 109
112 if (copy_from_user(state_string, buffer, count)) 110 if (copy_from_user(state_string, buffer, count))
113 return_VALUE(-EFAULT); 111 return -EFAULT;
114 112
115 state_string[count] = '\0'; 113 state_string[count] = '\0';
116 114
117 result = acpi_bus_set_power(fan->handle, 115 result = acpi_bus_set_power(fan->handle,
118 simple_strtoul(state_string, NULL, 0)); 116 simple_strtoul(state_string, NULL, 0));
119 if (result) 117 if (result)
120 return_VALUE(result); 118 return result;
121 119
122 return_VALUE(count); 120 return count;
123} 121}
124 122
125static struct file_operations acpi_fan_state_ops = { 123static struct file_operations acpi_fan_state_ops = {
@@ -135,16 +133,15 @@ static int acpi_fan_add_fs(struct acpi_device *device)
135{ 133{
136 struct proc_dir_entry *entry = NULL; 134 struct proc_dir_entry *entry = NULL;
137 135
138 ACPI_FUNCTION_TRACE("acpi_fan_add_fs");
139 136
140 if (!device) 137 if (!device)
141 return_VALUE(-EINVAL); 138 return -EINVAL;
142 139
143 if (!acpi_device_dir(device)) { 140 if (!acpi_device_dir(device)) {
144 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 141 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
145 acpi_fan_dir); 142 acpi_fan_dir);
146 if (!acpi_device_dir(device)) 143 if (!acpi_device_dir(device))
147 return_VALUE(-ENODEV); 144 return -ENODEV;
148 acpi_device_dir(device)->owner = THIS_MODULE; 145 acpi_device_dir(device)->owner = THIS_MODULE;
149 } 146 }
150 147
@@ -153,21 +150,18 @@ static int acpi_fan_add_fs(struct acpi_device *device)
153 S_IFREG | S_IRUGO | S_IWUSR, 150 S_IFREG | S_IRUGO | S_IWUSR,
154 acpi_device_dir(device)); 151 acpi_device_dir(device));
155 if (!entry) 152 if (!entry)
156 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 153 return -ENODEV;
157 "Unable to create '%s' fs entry\n",
158 ACPI_FAN_FILE_STATE));
159 else { 154 else {
160 entry->proc_fops = &acpi_fan_state_ops; 155 entry->proc_fops = &acpi_fan_state_ops;
161 entry->data = acpi_driver_data(device); 156 entry->data = acpi_driver_data(device);
162 entry->owner = THIS_MODULE; 157 entry->owner = THIS_MODULE;
163 } 158 }
164 159
165 return_VALUE(0); 160 return 0;
166} 161}
167 162
168static int acpi_fan_remove_fs(struct acpi_device *device) 163static int acpi_fan_remove_fs(struct acpi_device *device)
169{ 164{
170 ACPI_FUNCTION_TRACE("acpi_fan_remove_fs");
171 165
172 if (acpi_device_dir(device)) { 166 if (acpi_device_dir(device)) {
173 remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device)); 167 remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device));
@@ -175,7 +169,7 @@ static int acpi_fan_remove_fs(struct acpi_device *device)
175 acpi_device_dir(device) = NULL; 169 acpi_device_dir(device) = NULL;
176 } 170 }
177 171
178 return_VALUE(0); 172 return 0;
179} 173}
180 174
181/* -------------------------------------------------------------------------- 175/* --------------------------------------------------------------------------
@@ -188,14 +182,13 @@ static int acpi_fan_add(struct acpi_device *device)
188 struct acpi_fan *fan = NULL; 182 struct acpi_fan *fan = NULL;
189 int state = 0; 183 int state = 0;
190 184
191 ACPI_FUNCTION_TRACE("acpi_fan_add");
192 185
193 if (!device) 186 if (!device)
194 return_VALUE(-EINVAL); 187 return -EINVAL;
195 188
196 fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL); 189 fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL);
197 if (!fan) 190 if (!fan)
198 return_VALUE(-ENOMEM); 191 return -ENOMEM;
199 memset(fan, 0, sizeof(struct acpi_fan)); 192 memset(fan, 0, sizeof(struct acpi_fan));
200 193
201 fan->handle = device->handle; 194 fan->handle = device->handle;
@@ -205,8 +198,7 @@ static int acpi_fan_add(struct acpi_device *device)
205 198
206 result = acpi_bus_get_power(fan->handle, &state); 199 result = acpi_bus_get_power(fan->handle, &state);
207 if (result) { 200 if (result) {
208 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 201 printk(KERN_ERR PREFIX "Reading power state\n");
209 "Error reading power state\n"));
210 goto end; 202 goto end;
211 } 203 }
212 204
@@ -226,17 +218,16 @@ static int acpi_fan_add(struct acpi_device *device)
226 if (result) 218 if (result)
227 kfree(fan); 219 kfree(fan);
228 220
229 return_VALUE(result); 221 return result;
230} 222}
231 223
232static int acpi_fan_remove(struct acpi_device *device, int type) 224static int acpi_fan_remove(struct acpi_device *device, int type)
233{ 225{
234 struct acpi_fan *fan = NULL; 226 struct acpi_fan *fan = NULL;
235 227
236 ACPI_FUNCTION_TRACE("acpi_fan_remove");
237 228
238 if (!device || !acpi_driver_data(device)) 229 if (!device || !acpi_driver_data(device))
239 return_VALUE(-EINVAL); 230 return -EINVAL;
240 231
241 fan = (struct acpi_fan *)acpi_driver_data(device); 232 fan = (struct acpi_fan *)acpi_driver_data(device);
242 233
@@ -244,7 +235,7 @@ static int acpi_fan_remove(struct acpi_device *device, int type)
244 235
245 kfree(fan); 236 kfree(fan);
246 237
247 return_VALUE(0); 238 return 0;
248} 239}
249 240
250static int acpi_fan_suspend(struct acpi_device *device, int state) 241static int acpi_fan_suspend(struct acpi_device *device, int state)
@@ -283,31 +274,29 @@ static int __init acpi_fan_init(void)
283{ 274{
284 int result = 0; 275 int result = 0;
285 276
286 ACPI_FUNCTION_TRACE("acpi_fan_init");
287 277
288 acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir); 278 acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir);
289 if (!acpi_fan_dir) 279 if (!acpi_fan_dir)
290 return_VALUE(-ENODEV); 280 return -ENODEV;
291 acpi_fan_dir->owner = THIS_MODULE; 281 acpi_fan_dir->owner = THIS_MODULE;
292 282
293 result = acpi_bus_register_driver(&acpi_fan_driver); 283 result = acpi_bus_register_driver(&acpi_fan_driver);
294 if (result < 0) { 284 if (result < 0) {
295 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); 285 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
296 return_VALUE(-ENODEV); 286 return -ENODEV;
297 } 287 }
298 288
299 return_VALUE(0); 289 return 0;
300} 290}
301 291
302static void __exit acpi_fan_exit(void) 292static void __exit acpi_fan_exit(void)
303{ 293{
304 ACPI_FUNCTION_TRACE("acpi_fan_exit");
305 294
306 acpi_bus_unregister_driver(&acpi_fan_driver); 295 acpi_bus_unregister_driver(&acpi_fan_driver);
307 296
308 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); 297 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
309 298
310 return_VOID; 299 return;
311} 300}
312 301
313module_init(acpi_fan_init); 302module_init(acpi_fan_init);
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/hardware/hwregs.c
index ae142de19507..3143f36fcec9 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/hardware/hwregs.c
@@ -172,9 +172,9 @@ acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
172 } 172 }
173 173
174 /* 174 /*
175 * The package must have at least two elements. NOTE (March 2005): This 175 * The package must have at least two elements. NOTE (March 2005): This
176 * goes against the current ACPI spec which defines this object as a 176 * goes against the current ACPI spec which defines this object as a
177 * package with one encoded DWORD element. However, existing practice 177 * package with one encoded DWORD element. However, existing practice
178 * by BIOS vendors seems to be to have 2 or more elements, at least 178 * by BIOS vendors seems to be to have 2 or more elements, at least
179 * one per sleep type (A/B). 179 * one per sleep type (A/B).
180 */ 180 */
@@ -255,7 +255,7 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
255 * return_value - Value that was read from the register 255 * return_value - Value that was read from the register
256 * Flags - Lock the hardware or not 256 * Flags - Lock the hardware or not
257 * 257 *
258 * RETURN: Status and the value read from specified Register. Value 258 * RETURN: Status and the value read from specified Register. Value
259 * returned is normalized to bit0 (is shifted all the way right) 259 * returned is normalized to bit0 (is shifted all the way right)
260 * 260 *
261 * DESCRIPTION: ACPI bit_register read function. 261 * DESCRIPTION: ACPI bit_register read function.
@@ -361,8 +361,8 @@ acpi_status acpi_set_register(u32 register_id, u32 value, u32 flags)
361 case ACPI_REGISTER_PM1_STATUS: 361 case ACPI_REGISTER_PM1_STATUS:
362 362
363 /* 363 /*
364 * Status Registers are different from the rest. Clear by 364 * Status Registers are different from the rest. Clear by
365 * writing 1, and writing 0 has no effect. So, the only relevant 365 * writing 1, and writing 0 has no effect. So, the only relevant
366 * information is the single bit we're interested in, all others should 366 * information is the single bit we're interested in, all others should
367 * be written as 0 so they will be left unchanged. 367 * be written as 0 so they will be left unchanged.
368 */ 368 */
@@ -467,14 +467,13 @@ ACPI_EXPORT_SYMBOL(acpi_set_register)
467 * 467 *
468 * FUNCTION: acpi_hw_register_read 468 * FUNCTION: acpi_hw_register_read
469 * 469 *
470 * PARAMETERS: use_lock - Mutex hw access 470 * PARAMETERS: use_lock - Lock hardware? True/False
471 * register_id - register_iD + Offset 471 * register_id - ACPI Register ID
472 * return_value - Where the register value is returned 472 * return_value - Where the register value is returned
473 * 473 *
474 * RETURN: Status and the value read. 474 * RETURN: Status and the value read.
475 * 475 *
476 * DESCRIPTION: Acpi register read function. Registers are read at the 476 * DESCRIPTION: Read from the specified ACPI register
477 * given offset.
478 * 477 *
479 ******************************************************************************/ 478 ******************************************************************************/
480acpi_status 479acpi_status
@@ -580,14 +579,26 @@ acpi_hw_register_read(u8 use_lock, u32 register_id, u32 * return_value)
580 * 579 *
581 * FUNCTION: acpi_hw_register_write 580 * FUNCTION: acpi_hw_register_write
582 * 581 *
583 * PARAMETERS: use_lock - Mutex hw access 582 * PARAMETERS: use_lock - Lock hardware? True/False
584 * register_id - register_iD + Offset 583 * register_id - ACPI Register ID
585 * Value - The value to write 584 * Value - The value to write
586 * 585 *
587 * RETURN: Status 586 * RETURN: Status
588 * 587 *
589 * DESCRIPTION: Acpi register Write function. Registers are written at the 588 * DESCRIPTION: Write to the specified ACPI register
590 * given offset. 589 *
590 * NOTE: In accordance with the ACPI specification, this function automatically
591 * preserves the value of the following bits, meaning that these bits cannot be
592 * changed via this interface:
593 *
594 * PM1_CONTROL[0] = SCI_EN
595 * PM1_CONTROL[9]
596 * PM1_STATUS[11]
597 *
598 * ACPI References:
599 * 1) Hardware Ignored Bits: When software writes to a register with ignored
600 * bit fields, it preserves the ignored bit fields
601 * 2) SCI_EN: OSPM always preserves this bit position
591 * 602 *
592 ******************************************************************************/ 603 ******************************************************************************/
593 604
@@ -595,6 +606,7 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
595{ 606{
596 acpi_status status; 607 acpi_status status;
597 acpi_cpu_flags lock_flags = 0; 608 acpi_cpu_flags lock_flags = 0;
609 u32 read_value;
598 610
599 ACPI_FUNCTION_TRACE(hw_register_write); 611 ACPI_FUNCTION_TRACE(hw_register_write);
600 612
@@ -605,6 +617,22 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
605 switch (register_id) { 617 switch (register_id) {
606 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 618 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
607 619
620 /* Perform a read first to preserve certain bits (per ACPI spec) */
621
622 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
623 ACPI_REGISTER_PM1_STATUS,
624 &read_value);
625 if (ACPI_FAILURE(status)) {
626 goto unlock_and_exit;
627 }
628
629 /* Insert the bits to be preserved */
630
631 ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS,
632 read_value);
633
634 /* Now we can write the data */
635
608 status = 636 status =
609 acpi_hw_low_level_write(16, value, 637 acpi_hw_low_level_write(16, value,
610 &acpi_gbl_FADT->xpm1a_evt_blk); 638 &acpi_gbl_FADT->xpm1a_evt_blk);
@@ -635,6 +663,25 @@ acpi_status acpi_hw_register_write(u8 use_lock, u32 register_id, u32 value)
635 663
636 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ 664 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
637 665
666 /*
667 * Perform a read first to preserve certain bits (per ACPI spec)
668 *
669 * Note: This includes SCI_EN, we never want to change this bit
670 */
671 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
672 ACPI_REGISTER_PM1_CONTROL,
673 &read_value);
674 if (ACPI_FAILURE(status)) {
675 goto unlock_and_exit;
676 }
677
678 /* Insert the bits to be preserved */
679
680 ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS,
681 read_value);
682
683 /* Now we can write the data */
684
638 status = 685 status =
639 acpi_hw_low_level_write(16, value, 686 acpi_hw_low_level_write(16, value,
640 &acpi_gbl_FADT->xpm1a_cnt_blk); 687 &acpi_gbl_FADT->xpm1a_cnt_blk);
@@ -726,7 +773,7 @@ acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
726 return (AE_OK); 773 return (AE_OK);
727 } 774 }
728 775
729 /* Get a local copy of the address. Handles possible alignment issues */ 776 /* Get a local copy of the address. Handles possible alignment issues */
730 777
731 ACPI_MOVE_64_TO_64(&address, &reg->address); 778 ACPI_MOVE_64_TO_64(&address, &reg->address);
732 if (!address) { 779 if (!address) {
@@ -798,7 +845,7 @@ acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
798 return (AE_OK); 845 return (AE_OK);
799 } 846 }
800 847
801 /* Get a local copy of the address. Handles possible alignment issues */ 848 /* Get a local copy of the address. Handles possible alignment issues */
802 849
803 ACPI_MOVE_64_TO_64(&address, &reg->address); 850 ACPI_MOVE_64_TO_64(&address, &reg->address);
804 if (!address) { 851 if (!address) {
diff --git a/drivers/acpi/hotkey.c b/drivers/acpi/hotkey.c
index c25b2b92edcf..fd81a0f5222f 100644
--- a/drivers/acpi/hotkey.c
+++ b/drivers/acpi/hotkey.c
@@ -231,11 +231,10 @@ struct list_head hotkey_entries; /* head of the list of hotkey_list */
231 231
232static int hotkey_info_seq_show(struct seq_file *seq, void *offset) 232static int hotkey_info_seq_show(struct seq_file *seq, void *offset)
233{ 233{
234 ACPI_FUNCTION_TRACE("hotkey_info_seq_show");
235 234
236 seq_printf(seq, "Hotkey generic driver ver: %s\n", HOTKEY_ACPI_VERSION); 235 seq_printf(seq, "Hotkey generic driver ver: %s\n", HOTKEY_ACPI_VERSION);
237 236
238 return_VALUE(0); 237 return 0;
239} 238}
240 239
241static int hotkey_info_open_fs(struct inode *inode, struct file *file) 240static int hotkey_info_open_fs(struct inode *inode, struct file *file)
@@ -266,7 +265,6 @@ static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
266 (struct acpi_polling_hotkey *)seq->private; 265 (struct acpi_polling_hotkey *)seq->private;
267 char *buf; 266 char *buf;
268 267
269 ACPI_FUNCTION_TRACE("hotkey_polling_seq_show");
270 268
271 if (poll_hotkey->poll_result) { 269 if (poll_hotkey->poll_result) {
272 buf = format_result(poll_hotkey->poll_result); 270 buf = format_result(poll_hotkey->poll_result);
@@ -274,7 +272,7 @@ static int hotkey_polling_seq_show(struct seq_file *seq, void *offset)
274 seq_printf(seq, "%s", buf); 272 seq_printf(seq, "%s", buf);
275 kfree(buf); 273 kfree(buf);
276 } 274 }
277 return_VALUE(0); 275 return 0;
278} 276}
279 277
280static int hotkey_polling_open_fs(struct inode *inode, struct file *file) 278static int hotkey_polling_open_fs(struct inode *inode, struct file *file)
@@ -293,7 +291,6 @@ static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list)
293 struct list_head *entries; 291 struct list_head *entries;
294 int val = -1; 292 int val = -1;
295 293
296 ACPI_FUNCTION_TRACE("hotkey_get_internal_event");
297 294
298 list_for_each(entries, list->entries) { 295 list_for_each(entries, list->entries) {
299 union acpi_hotkey *key = 296 union acpi_hotkey *key =
@@ -305,7 +302,7 @@ static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list)
305 } 302 }
306 } 303 }
307 304
308 return_VALUE(val); 305 return val;
309} 306}
310 307
311static void 308static void
@@ -314,15 +311,14 @@ acpi_hotkey_notify_handler(acpi_handle handle, u32 event, void *data)
314 struct acpi_device *device = NULL; 311 struct acpi_device *device = NULL;
315 u32 internal_event; 312 u32 internal_event;
316 313
317 ACPI_FUNCTION_TRACE("acpi_hotkey_notify_handler");
318 314
319 if (acpi_bus_get_device(handle, &device)) 315 if (acpi_bus_get_device(handle, &device))
320 return_VOID; 316 return;
321 317
322 internal_event = hotkey_get_internal_event(event, &global_hotkey_list); 318 internal_event = hotkey_get_internal_event(event, &global_hotkey_list);
323 acpi_bus_generate_event(device, internal_event, 0); 319 acpi_bus_generate_event(device, internal_event, 0);
324 320
325 return_VOID; 321 return;
326} 322}
327 323
328/* Need to invent automatically hotkey add method */ 324/* Need to invent automatically hotkey add method */
@@ -346,7 +342,6 @@ static int create_polling_proc(union acpi_hotkey *device)
346 char proc_name[80]; 342 char proc_name[80];
347 mode_t mode; 343 mode_t mode;
348 344
349 ACPI_FUNCTION_TRACE("create_polling_proc");
350 mode = S_IFREG | S_IRUGO | S_IWUGO; 345 mode = S_IFREG | S_IRUGO | S_IWUGO;
351 346
352 sprintf(proc_name, "%d", device->link.hotkey_standard_num); 347 sprintf(proc_name, "%d", device->link.hotkey_standard_num);
@@ -356,10 +351,7 @@ static int create_polling_proc(union acpi_hotkey *device)
356 proc = create_proc_entry(proc_name, mode, hotkey_proc_dir); 351 proc = create_proc_entry(proc_name, mode, hotkey_proc_dir);
357 352
358 if (!proc) { 353 if (!proc) {
359 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 354 return -ENODEV;
360 "Hotkey: Unable to create %s entry\n",
361 device->poll_hotkey.poll_method));
362 return_VALUE(-ENODEV);
363 } else { 355 } else {
364 proc->proc_fops = &hotkey_polling_fops; 356 proc->proc_fops = &hotkey_polling_fops;
365 proc->owner = THIS_MODULE; 357 proc->owner = THIS_MODULE;
@@ -368,7 +360,7 @@ static int create_polling_proc(union acpi_hotkey *device)
368 proc->gid = 0; 360 proc->gid = 0;
369 device->poll_hotkey.proc = proc; 361 device->poll_hotkey.proc = proc;
370 } 362 }
371 return_VALUE(0); 363 return 0;
372} 364}
373 365
374static int hotkey_add(union acpi_hotkey *device) 366static int hotkey_add(union acpi_hotkey *device)
@@ -376,7 +368,6 @@ static int hotkey_add(union acpi_hotkey *device)
376 int status = 0; 368 int status = 0;
377 struct acpi_device *dev = NULL; 369 struct acpi_device *dev = NULL;
378 370
379 ACPI_FUNCTION_TRACE("hotkey_add");
380 371
381 if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) { 372 if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) {
382 acpi_bus_get_device(device->event_hotkey.bus_handle, &dev); 373 acpi_bus_get_device(device->event_hotkey.bus_handle, &dev);
@@ -391,14 +382,13 @@ static int hotkey_add(union acpi_hotkey *device)
391 382
392 list_add_tail(&device->link.entries, global_hotkey_list.entries); 383 list_add_tail(&device->link.entries, global_hotkey_list.entries);
393 384
394 return_VALUE(status); 385 return status;
395} 386}
396 387
397static int hotkey_remove(union acpi_hotkey *device) 388static int hotkey_remove(union acpi_hotkey *device)
398{ 389{
399 struct list_head *entries, *next; 390 struct list_head *entries, *next;
400 391
401 ACPI_FUNCTION_TRACE("hotkey_remove");
402 392
403 list_for_each_safe(entries, next, global_hotkey_list.entries) { 393 list_for_each_safe(entries, next, global_hotkey_list.entries) {
404 union acpi_hotkey *key = 394 union acpi_hotkey *key =
@@ -412,14 +402,13 @@ static int hotkey_remove(union acpi_hotkey *device)
412 } 402 }
413 } 403 }
414 kfree(device); 404 kfree(device);
415 return_VALUE(0); 405 return 0;
416} 406}
417 407
418static int hotkey_update(union acpi_hotkey *key) 408static int hotkey_update(union acpi_hotkey *key)
419{ 409{
420 struct list_head *entries; 410 struct list_head *entries;
421 411
422 ACPI_FUNCTION_TRACE("hotkey_update");
423 412
424 list_for_each(entries, global_hotkey_list.entries) { 413 list_for_each(entries, global_hotkey_list.entries) {
425 union acpi_hotkey *tmp = 414 union acpi_hotkey *tmp =
@@ -461,19 +450,18 @@ static int hotkey_update(union acpi_hotkey *key)
461 */ 450 */
462 kfree(key); 451 kfree(key);
463 } 452 }
464 return_VALUE(0); 453 return 0;
465 break; 454 break;
466 } 455 }
467 } 456 }
468 457
469 return_VALUE(-ENODEV); 458 return -ENODEV;
470} 459}
471 460
472static void free_hotkey_device(union acpi_hotkey *key) 461static void free_hotkey_device(union acpi_hotkey *key)
473{ 462{
474 struct acpi_device *dev; 463 struct acpi_device *dev;
475 464
476 ACPI_FUNCTION_TRACE("free_hotkey_device");
477 465
478 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { 466 if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) {
479 acpi_bus_get_device(key->event_hotkey.bus_handle, &dev); 467 acpi_bus_get_device(key->event_hotkey.bus_handle, &dev);
@@ -493,7 +481,7 @@ static void free_hotkey_device(union acpi_hotkey *key)
493 free_poll_hotkey_buffer(key); 481 free_poll_hotkey_buffer(key);
494 } 482 }
495 kfree(key); 483 kfree(key);
496 return_VOID; 484 return;
497} 485}
498 486
499static void free_hotkey_buffer(union acpi_hotkey *key) 487static void free_hotkey_buffer(union acpi_hotkey *key)
@@ -514,7 +502,6 @@ init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
514 acpi_handle tmp_handle; 502 acpi_handle tmp_handle;
515 acpi_status status = AE_OK; 503 acpi_status status = AE_OK;
516 504
517 ACPI_FUNCTION_TRACE("init_hotkey_device");
518 505
519 if (std_num < 0 || IS_POLL(std_num) || !key) 506 if (std_num < 0 || IS_POLL(std_num) || !key)
520 goto do_fail; 507 goto do_fail;
@@ -541,9 +528,9 @@ init_hotkey_device(union acpi_hotkey *key, char *bus_str, char *action_str,
541 method, &tmp_handle); 528 method, &tmp_handle);
542 if (ACPI_FAILURE(status)) 529 if (ACPI_FAILURE(status))
543 goto do_fail; 530 goto do_fail;
544 return_VALUE(AE_OK); 531 return AE_OK;
545 do_fail: 532 do_fail:
546 return_VALUE(-ENODEV); 533 return -ENODEV;
547} 534}
548 535
549static int 536static int
@@ -555,7 +542,6 @@ init_poll_hotkey_device(union acpi_hotkey *key,
555 acpi_status status = AE_OK; 542 acpi_status status = AE_OK;
556 acpi_handle tmp_handle; 543 acpi_handle tmp_handle;
557 544
558 ACPI_FUNCTION_TRACE("init_poll_hotkey_device");
559 545
560 if (std_num < 0 || IS_EVENT(std_num) || !key) 546 if (std_num < 0 || IS_EVENT(std_num) || !key)
561 goto do_fail; 547 goto do_fail;
@@ -590,22 +576,20 @@ init_poll_hotkey_device(union acpi_hotkey *key,
590 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL); 576 (union acpi_object *)kmalloc(sizeof(union acpi_object), GFP_KERNEL);
591 if (!key->poll_hotkey.poll_result) 577 if (!key->poll_hotkey.poll_result)
592 goto do_fail; 578 goto do_fail;
593 return_VALUE(AE_OK); 579 return AE_OK;
594 do_fail: 580 do_fail:
595 return_VALUE(-ENODEV); 581 return -ENODEV;
596} 582}
597 583
598static int hotkey_open_config(struct inode *inode, struct file *file) 584static int hotkey_open_config(struct inode *inode, struct file *file)
599{ 585{
600 ACPI_FUNCTION_TRACE("hotkey_open_config"); 586 return (single_open
601 return_VALUE(single_open
602 (file, hotkey_config_seq_show, PDE(inode)->data)); 587 (file, hotkey_config_seq_show, PDE(inode)->data));
603} 588}
604 589
605static int hotkey_poll_open_config(struct inode *inode, struct file *file) 590static int hotkey_poll_open_config(struct inode *inode, struct file *file)
606{ 591{
607 ACPI_FUNCTION_TRACE("hotkey_poll_open_config"); 592 return (single_open
608 return_VALUE(single_open
609 (file, hotkey_poll_config_seq_show, PDE(inode)->data)); 593 (file, hotkey_poll_config_seq_show, PDE(inode)->data));
610} 594}
611 595
@@ -618,7 +602,6 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
618 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; 602 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name };
619 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; 603 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name };
620 604
621 ACPI_FUNCTION_TRACE(("hotkey_config_seq_show"));
622 605
623 list_for_each(entries, hotkey_list->entries) { 606 list_for_each(entries, hotkey_list->entries) {
624 union acpi_hotkey *key = 607 union acpi_hotkey *key =
@@ -636,7 +619,7 @@ static int hotkey_config_seq_show(struct seq_file *seq, void *offset)
636 } 619 }
637 } 620 }
638 seq_puts(seq, "\n"); 621 seq_puts(seq, "\n");
639 return_VALUE(0); 622 return 0;
640} 623}
641 624
642static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset) 625static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
@@ -648,7 +631,6 @@ static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
648 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; 631 struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name };
649 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; 632 struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name };
650 633
651 ACPI_FUNCTION_TRACE(("hotkey_config_seq_show"));
652 634
653 list_for_each(entries, hotkey_list->entries) { 635 list_for_each(entries, hotkey_list->entries) {
654 union acpi_hotkey *key = 636 union acpi_hotkey *key =
@@ -666,7 +648,7 @@ static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset)
666 } 648 }
667 } 649 }
668 seq_puts(seq, "\n"); 650 seq_puts(seq, "\n");
669 return_VALUE(0); 651 return 0;
670} 652}
671 653
672static int 654static int
@@ -678,7 +660,6 @@ get_parms(char *config_record,
678 char **method, int *internal_event_num, int *external_event_num) 660 char **method, int *internal_event_num, int *external_event_num)
679{ 661{
680 char *tmp, *tmp1, count; 662 char *tmp, *tmp1, count;
681 ACPI_FUNCTION_TRACE(("get_parms"));
682 663
683 sscanf(config_record, "%d", cmd); 664 sscanf(config_record, "%d", cmd);
684 665
@@ -744,9 +725,9 @@ get_parms(char *config_record,
744 0) 725 0)
745 goto do_fail; 726 goto do_fail;
746 727
747 return_VALUE(6); 728 return 6;
748 do_fail: 729 do_fail:
749 return_VALUE(-1); 730 return -1;
750} 731}
751 732
752/* count is length for one input record */ 733/* count is length for one input record */
@@ -763,16 +744,15 @@ static ssize_t hotkey_write_config(struct file *file,
763 int ret = 0; 744 int ret = 0;
764 union acpi_hotkey *key = NULL; 745 union acpi_hotkey *key = NULL;
765 746
766 ACPI_FUNCTION_TRACE(("hotkey_write_config"));
767 747
768 config_record = (char *)kmalloc(count + 1, GFP_KERNEL); 748 config_record = (char *)kmalloc(count + 1, GFP_KERNEL);
769 if (!config_record) 749 if (!config_record)
770 return_VALUE(-ENOMEM); 750 return -ENOMEM;
771 751
772 if (copy_from_user(config_record, buffer, count)) { 752 if (copy_from_user(config_record, buffer, count)) {
773 kfree(config_record); 753 kfree(config_record);
774 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data \n")); 754 printk(KERN_ERR PREFIX "Invalid data\n");
775 return_VALUE(-EINVAL); 755 return -EINVAL;
776 } 756 }
777 config_record[count] = 0; 757 config_record[count] = 0;
778 758
@@ -792,9 +772,8 @@ static ssize_t hotkey_write_config(struct file *file,
792 kfree(bus_method); 772 kfree(bus_method);
793 kfree(action_handle); 773 kfree(action_handle);
794 kfree(method); 774 kfree(method);
795 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 775 printk(KERN_ERR PREFIX "Invalid data format ret=%d\n", ret);
796 "Invalid data format ret=%d\n", ret)); 776 return -EINVAL;
797 return_VALUE(-EINVAL);
798 } 777 }
799 778
800 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL); 779 key = kmalloc(sizeof(union acpi_hotkey), GFP_KERNEL);
@@ -806,7 +785,7 @@ static ssize_t hotkey_write_config(struct file *file,
806 tmp = get_hotkey_by_event(&global_hotkey_list, 785 tmp = get_hotkey_by_event(&global_hotkey_list,
807 internal_event_num); 786 internal_event_num);
808 if (!tmp) 787 if (!tmp)
809 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid key")); 788 printk(KERN_ERR PREFIX "Invalid key\n");
810 else 789 else
811 memcpy(key, tmp, sizeof(union acpi_hotkey)); 790 memcpy(key, tmp, sizeof(union acpi_hotkey));
812 goto cont_cmd; 791 goto cont_cmd;
@@ -828,8 +807,8 @@ static ssize_t hotkey_write_config(struct file *file,
828 else 807 else
829 free_poll_hotkey_buffer(key); 808 free_poll_hotkey_buffer(key);
830 kfree(key); 809 kfree(key);
831 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid hotkey \n")); 810 printk(KERN_ERR PREFIX "Invalid hotkey\n");
832 return_VALUE(-EINVAL); 811 return -EINVAL;
833 } 812 }
834 813
835 cont_cmd: 814 cont_cmd:
@@ -855,15 +834,15 @@ static ssize_t hotkey_write_config(struct file *file,
855 goto fail_out; 834 goto fail_out;
856 break; 835 break;
857 } 836 }
858 return_VALUE(count); 837 return count;
859 fail_out: 838 fail_out:
860 if (IS_EVENT(internal_event_num)) 839 if (IS_EVENT(internal_event_num))
861 free_hotkey_buffer(key); 840 free_hotkey_buffer(key);
862 else 841 else
863 free_poll_hotkey_buffer(key); 842 free_poll_hotkey_buffer(key);
864 kfree(key); 843 kfree(key);
865 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "invalid key\n")); 844 printk(KERN_ERR PREFIX "invalid key\n");
866 return_VALUE(-EINVAL); 845 return -EINVAL;
867} 846}
868 847
869/* 848/*
@@ -880,7 +859,6 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
880 union acpi_object in_obj; /* the only param we use */ 859 union acpi_object in_obj; /* the only param we use */
881 acpi_status status; 860 acpi_status status;
882 861
883 ACPI_FUNCTION_TRACE("write_acpi_int");
884 params.count = 1; 862 params.count = 1;
885 params.pointer = &in_obj; 863 params.pointer = &in_obj;
886 in_obj.type = ACPI_TYPE_INTEGER; 864 in_obj.type = ACPI_TYPE_INTEGER;
@@ -888,7 +866,7 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
888 866
889 status = acpi_evaluate_object(handle, (char *)method, &params, output); 867 status = acpi_evaluate_object(handle, (char *)method, &params, output);
890 868
891 return_VALUE(status == AE_OK); 869 return (status == AE_OK);
892} 870}
893 871
894static int read_acpi_int(acpi_handle handle, const char *method, 872static int read_acpi_int(acpi_handle handle, const char *method,
@@ -898,7 +876,6 @@ static int read_acpi_int(acpi_handle handle, const char *method,
898 union acpi_object out_obj; 876 union acpi_object out_obj;
899 acpi_status status; 877 acpi_status status;
900 878
901 ACPI_FUNCTION_TRACE("read_acpi_int");
902 output.length = sizeof(out_obj); 879 output.length = sizeof(out_obj);
903 output.pointer = &out_obj; 880 output.pointer = &out_obj;
904 881
@@ -907,8 +884,8 @@ static int read_acpi_int(acpi_handle handle, const char *method,
907 val->integer.value = out_obj.integer.value; 884 val->integer.value = out_obj.integer.value;
908 val->type = out_obj.type; 885 val->type = out_obj.type;
909 } else 886 } else
910 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "null val pointer")); 887 printk(KERN_ERR PREFIX "null val pointer\n");
911 return_VALUE((status == AE_OK) 888 return ((status == AE_OK)
912 && (out_obj.type == ACPI_TYPE_INTEGER)); 889 && (out_obj.type == ACPI_TYPE_INTEGER));
913} 890}
914 891
@@ -945,24 +922,23 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
945 int event, method_type, type, value; 922 int event, method_type, type, value;
946 union acpi_hotkey *key; 923 union acpi_hotkey *key;
947 924
948 ACPI_FUNCTION_TRACE("hotkey_execte_aml_method");
949 925
950 arg = (char *)kmalloc(count + 1, GFP_KERNEL); 926 arg = (char *)kmalloc(count + 1, GFP_KERNEL);
951 if (!arg) 927 if (!arg)
952 return_VALUE(-ENOMEM); 928 return -ENOMEM;
953 arg[count] = 0; 929 arg[count] = 0;
954 930
955 if (copy_from_user(arg, buffer, count)) { 931 if (copy_from_user(arg, buffer, count)) {
956 kfree(arg); 932 kfree(arg);
957 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 2")); 933 printk(KERN_ERR PREFIX "Invalid argument 2\n");
958 return_VALUE(-EINVAL); 934 return -EINVAL;
959 } 935 }
960 936
961 if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) != 937 if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) !=
962 4) { 938 4) {
963 kfree(arg); 939 kfree(arg);
964 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument 3")); 940 printk(KERN_ERR PREFIX "Invalid argument 3\n");
965 return_VALUE(-EINVAL); 941 return -EINVAL;
966 } 942 }
967 kfree(arg); 943 kfree(arg);
968 if (type == ACPI_TYPE_INTEGER) { 944 if (type == ACPI_TYPE_INTEGER) {
@@ -987,12 +963,12 @@ static ssize_t hotkey_execute_aml_method(struct file *file,
987 963
988 } 964 }
989 } else { 965 } else {
990 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Not supported")); 966 printk(KERN_WARNING "Not supported\n");
991 return_VALUE(-EINVAL); 967 return -EINVAL;
992 } 968 }
993 return_VALUE(count); 969 return count;
994 do_fail: 970 do_fail:
995 return_VALUE(-EINVAL); 971 return -EINVAL;
996 972
997} 973}
998 974
@@ -1001,7 +977,6 @@ static int __init hotkey_init(void)
1001 int result; 977 int result;
1002 mode_t mode = S_IFREG | S_IRUGO | S_IWUGO; 978 mode_t mode = S_IFREG | S_IRUGO | S_IWUGO;
1003 979
1004 ACPI_FUNCTION_TRACE("hotkey_init");
1005 980
1006 if (acpi_disabled) 981 if (acpi_disabled)
1007 return -ENODEV; 982 return -ENODEV;
@@ -1013,9 +988,6 @@ static int __init hotkey_init(void)
1013 988
1014 hotkey_proc_dir = proc_mkdir(HOTKEY_PROC, acpi_root_dir); 989 hotkey_proc_dir = proc_mkdir(HOTKEY_PROC, acpi_root_dir);
1015 if (!hotkey_proc_dir) { 990 if (!hotkey_proc_dir) {
1016 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1017 "Hotkey: Unable to create %s entry\n",
1018 HOTKEY_PROC));
1019 return (-ENODEV); 991 return (-ENODEV);
1020 } 992 }
1021 hotkey_proc_dir->owner = THIS_MODULE; 993 hotkey_proc_dir->owner = THIS_MODULE;
@@ -1023,9 +995,6 @@ static int __init hotkey_init(void)
1023 hotkey_config = 995 hotkey_config =
1024 create_proc_entry(HOTKEY_EV_CONFIG, mode, hotkey_proc_dir); 996 create_proc_entry(HOTKEY_EV_CONFIG, mode, hotkey_proc_dir);
1025 if (!hotkey_config) { 997 if (!hotkey_config) {
1026 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1027 "Hotkey: Unable to create %s entry\n",
1028 HOTKEY_EV_CONFIG));
1029 goto do_fail1; 998 goto do_fail1;
1030 } else { 999 } else {
1031 hotkey_config->proc_fops = &hotkey_config_fops; 1000 hotkey_config->proc_fops = &hotkey_config_fops;
@@ -1038,10 +1007,6 @@ static int __init hotkey_init(void)
1038 hotkey_poll_config = 1007 hotkey_poll_config =
1039 create_proc_entry(HOTKEY_PL_CONFIG, mode, hotkey_proc_dir); 1008 create_proc_entry(HOTKEY_PL_CONFIG, mode, hotkey_proc_dir);
1040 if (!hotkey_poll_config) { 1009 if (!hotkey_poll_config) {
1041 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1042 "Hotkey: Unable to create %s entry\n",
1043 HOTKEY_EV_CONFIG));
1044
1045 goto do_fail2; 1010 goto do_fail2;
1046 } else { 1011 } else {
1047 hotkey_poll_config->proc_fops = &hotkey_poll_config_fops; 1012 hotkey_poll_config->proc_fops = &hotkey_poll_config_fops;
@@ -1053,9 +1018,6 @@ static int __init hotkey_init(void)
1053 1018
1054 hotkey_action = create_proc_entry(HOTKEY_ACTION, mode, hotkey_proc_dir); 1019 hotkey_action = create_proc_entry(HOTKEY_ACTION, mode, hotkey_proc_dir);
1055 if (!hotkey_action) { 1020 if (!hotkey_action) {
1056 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1057 "Hotkey: Unable to create %s entry\n",
1058 HOTKEY_ACTION));
1059 goto do_fail3; 1021 goto do_fail3;
1060 } else { 1022 } else {
1061 hotkey_action->proc_fops = &hotkey_action_fops; 1023 hotkey_action->proc_fops = &hotkey_action_fops;
@@ -1066,9 +1028,6 @@ static int __init hotkey_init(void)
1066 1028
1067 hotkey_info = create_proc_entry(HOTKEY_INFO, mode, hotkey_proc_dir); 1029 hotkey_info = create_proc_entry(HOTKEY_INFO, mode, hotkey_proc_dir);
1068 if (!hotkey_info) { 1030 if (!hotkey_info) {
1069 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1070 "Hotkey: Unable to create %s entry\n",
1071 HOTKEY_INFO));
1072 goto do_fail4; 1031 goto do_fail4;
1073 } else { 1032 } else {
1074 hotkey_info->proc_fops = &hotkey_info_fops; 1033 hotkey_info->proc_fops = &hotkey_info_fops;
@@ -1104,7 +1063,6 @@ static void __exit hotkey_exit(void)
1104{ 1063{
1105 struct list_head *entries, *next; 1064 struct list_head *entries, *next;
1106 1065
1107 ACPI_FUNCTION_TRACE("hotkey_exit");
1108 1066
1109 list_for_each_safe(entries, next, global_hotkey_list.entries) { 1067 list_for_each_safe(entries, next, global_hotkey_list.entries) {
1110 union acpi_hotkey *key = 1068 union acpi_hotkey *key =
diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c
index d51d68f5dd8d..ec6b7f9ede34 100644
--- a/drivers/acpi/motherboard.c
+++ b/drivers/acpi/motherboard.c
@@ -52,13 +52,12 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
52{ 52{
53 struct resource *requested_res = NULL; 53 struct resource *requested_res = NULL;
54 54
55 ACPI_FUNCTION_TRACE("acpi_reserve_io_ranges");
56 55
57 if (res->type == ACPI_RESOURCE_TYPE_IO) { 56 if (res->type == ACPI_RESOURCE_TYPE_IO) {
58 struct acpi_resource_io *io_res = &res->data.io; 57 struct acpi_resource_io *io_res = &res->data.io;
59 58
60 if (io_res->minimum != io_res->maximum) 59 if (io_res->minimum != io_res->maximum)
61 return_VALUE(AE_OK); 60 return AE_OK;
62 if (IS_RESERVED_ADDR 61 if (IS_RESERVED_ADDR
63 (io_res->minimum, io_res->address_length)) { 62 (io_res->minimum, io_res->address_length)) {
64 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 63 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -92,7 +91,7 @@ static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
92 91
93 if (requested_res) 92 if (requested_res)
94 requested_res->flags &= ~IORESOURCE_BUSY; 93 requested_res->flags &= ~IORESOURCE_BUSY;
95 return_VALUE(AE_OK); 94 return AE_OK;
96} 95}
97 96
98static int acpi_motherboard_add(struct acpi_device *device) 97static int acpi_motherboard_add(struct acpi_device *device)
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/namespace/nsaccess.c
index 48fadade52e2..c1c6c236df9a 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/namespace/nsaccess.c
@@ -196,33 +196,30 @@ acpi_status acpi_ns_root_initialize(void)
196 (u8) (ACPI_TO_INTEGER(val) - 1); 196 (u8) (ACPI_TO_INTEGER(val) - 1);
197 197
198 if (ACPI_STRCMP(init_val->name, "_GL_") == 0) { 198 if (ACPI_STRCMP(init_val->name, "_GL_") == 0) {
199 /* 199
200 * Create a counting semaphore for the 200 /* Create a counting semaphore for the global lock */
201 * global lock 201
202 */
203 status = 202 status =
204 acpi_os_create_semaphore 203 acpi_os_create_semaphore
205 (ACPI_NO_UNIT_LIMIT, 1, 204 (ACPI_NO_UNIT_LIMIT, 1,
206 &obj_desc->mutex.semaphore); 205 &acpi_gbl_global_lock_semaphore);
207 if (ACPI_FAILURE(status)) { 206 if (ACPI_FAILURE(status)) {
208 acpi_ut_remove_reference 207 acpi_ut_remove_reference
209 (obj_desc); 208 (obj_desc);
210 goto unlock_and_exit; 209 goto unlock_and_exit;
211 } 210 }
212 211
213 /* 212 /* Mark this mutex as very special */
214 * We just created the mutex for the 213
215 * global lock, save it 214 obj_desc->mutex.os_mutex =
216 */ 215 ACPI_GLOBAL_LOCK;
217 acpi_gbl_global_lock_semaphore =
218 obj_desc->mutex.semaphore;
219 } else { 216 } else {
220 /* Create a mutex */ 217 /* Create a mutex */
221 218
222 status = acpi_os_create_semaphore(1, 1, 219 status =
223 &obj_desc-> 220 acpi_os_create_mutex(&obj_desc->
224 mutex. 221 mutex.
225 semaphore); 222 os_mutex);
226 if (ACPI_FAILURE(status)) { 223 if (ACPI_FAILURE(status)) {
227 acpi_ut_remove_reference 224 acpi_ut_remove_reference
228 (obj_desc); 225 (obj_desc);
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 41da26a04cb4..5dd2ed11a387 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -136,6 +136,7 @@ void acpi_os_vprintf(const char *fmt, va_list args)
136#endif 136#endif
137} 137}
138 138
139
139extern int acpi_in_resume; 140extern int acpi_in_resume;
140void *acpi_os_allocate(acpi_size size) 141void *acpi_os_allocate(acpi_size size)
141{ 142{
@@ -585,19 +586,18 @@ static void acpi_os_execute_deferred(void *context)
585{ 586{
586 struct acpi_os_dpc *dpc = NULL; 587 struct acpi_os_dpc *dpc = NULL;
587 588
588 ACPI_FUNCTION_TRACE("os_execute_deferred");
589 589
590 dpc = (struct acpi_os_dpc *)context; 590 dpc = (struct acpi_os_dpc *)context;
591 if (!dpc) { 591 if (!dpc) {
592 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); 592 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
593 return_VOID; 593 return;
594 } 594 }
595 595
596 dpc->function(dpc->context); 596 dpc->function(dpc->context);
597 597
598 kfree(dpc); 598 kfree(dpc);
599 599
600 return_VOID; 600 return;
601} 601}
602 602
603static int acpi_os_execute_thread(void *context) 603static int acpi_os_execute_thread(void *context)
@@ -687,35 +687,19 @@ EXPORT_SYMBOL(acpi_os_wait_events_complete);
687/* 687/*
688 * Allocate the memory for a spinlock and initialize it. 688 * Allocate the memory for a spinlock and initialize it.
689 */ 689 */
690acpi_status acpi_os_create_lock(acpi_handle * out_handle) 690acpi_status acpi_os_create_lock(acpi_spinlock * handle)
691{ 691{
692 spinlock_t *lock_ptr; 692 spin_lock_init(*handle);
693
694 ACPI_FUNCTION_TRACE("os_create_lock");
695
696 lock_ptr = acpi_os_allocate(sizeof(spinlock_t));
697
698 spin_lock_init(lock_ptr);
699
700 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating spinlock[%p].\n", lock_ptr));
701 693
702 *out_handle = lock_ptr; 694 return AE_OK;
703
704 return_ACPI_STATUS(AE_OK);
705} 695}
706 696
707/* 697/*
708 * Deallocate the memory for a spinlock. 698 * Deallocate the memory for a spinlock.
709 */ 699 */
710void acpi_os_delete_lock(acpi_handle handle) 700void acpi_os_delete_lock(acpi_spinlock handle)
711{ 701{
712 ACPI_FUNCTION_TRACE("os_create_lock"); 702 return;
713
714 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting spinlock[%p].\n", handle));
715
716 acpi_os_free(handle);
717
718 return_VOID;
719} 703}
720 704
721acpi_status 705acpi_status
@@ -723,11 +707,10 @@ acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
723{ 707{
724 struct semaphore *sem = NULL; 708 struct semaphore *sem = NULL;
725 709
726 ACPI_FUNCTION_TRACE("os_create_semaphore");
727 710
728 sem = acpi_os_allocate(sizeof(struct semaphore)); 711 sem = acpi_os_allocate(sizeof(struct semaphore));
729 if (!sem) 712 if (!sem)
730 return_ACPI_STATUS(AE_NO_MEMORY); 713 return AE_NO_MEMORY;
731 memset(sem, 0, sizeof(struct semaphore)); 714 memset(sem, 0, sizeof(struct semaphore));
732 715
733 sema_init(sem, initial_units); 716 sema_init(sem, initial_units);
@@ -737,7 +720,7 @@ acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
737 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n", 720 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
738 *handle, initial_units)); 721 *handle, initial_units));
739 722
740 return_ACPI_STATUS(AE_OK); 723 return AE_OK;
741} 724}
742 725
743EXPORT_SYMBOL(acpi_os_create_semaphore); 726EXPORT_SYMBOL(acpi_os_create_semaphore);
@@ -753,17 +736,16 @@ acpi_status acpi_os_delete_semaphore(acpi_handle handle)
753{ 736{
754 struct semaphore *sem = (struct semaphore *)handle; 737 struct semaphore *sem = (struct semaphore *)handle;
755 738
756 ACPI_FUNCTION_TRACE("os_delete_semaphore");
757 739
758 if (!sem) 740 if (!sem)
759 return_ACPI_STATUS(AE_BAD_PARAMETER); 741 return AE_BAD_PARAMETER;
760 742
761 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle)); 743 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
762 744
763 acpi_os_free(sem); 745 acpi_os_free(sem);
764 sem = NULL; 746 sem = NULL;
765 747
766 return_ACPI_STATUS(AE_OK); 748 return AE_OK;
767} 749}
768 750
769EXPORT_SYMBOL(acpi_os_delete_semaphore); 751EXPORT_SYMBOL(acpi_os_delete_semaphore);
@@ -783,13 +765,12 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
783 struct semaphore *sem = (struct semaphore *)handle; 765 struct semaphore *sem = (struct semaphore *)handle;
784 int ret = 0; 766 int ret = 0;
785 767
786 ACPI_FUNCTION_TRACE("os_wait_semaphore");
787 768
788 if (!sem || (units < 1)) 769 if (!sem || (units < 1))
789 return_ACPI_STATUS(AE_BAD_PARAMETER); 770 return AE_BAD_PARAMETER;
790 771
791 if (units > 1) 772 if (units > 1)
792 return_ACPI_STATUS(AE_SUPPORT); 773 return AE_SUPPORT;
793 774
794 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n", 775 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
795 handle, units, timeout)); 776 handle, units, timeout));
@@ -838,17 +819,17 @@ acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
838 } 819 }
839 820
840 if (ACPI_FAILURE(status)) { 821 if (ACPI_FAILURE(status)) {
841 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 822 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
842 "Failed to acquire semaphore[%p|%d|%d], %s\n", 823 "Failed to acquire semaphore[%p|%d|%d], %s",
843 handle, units, timeout, 824 handle, units, timeout,
844 acpi_format_exception(status))); 825 acpi_format_exception(status)));
845 } else { 826 } else {
846 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 827 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
847 "Acquired semaphore[%p|%d|%d]\n", handle, 828 "Acquired semaphore[%p|%d|%d]", handle,
848 units, timeout)); 829 units, timeout));
849 } 830 }
850 831
851 return_ACPI_STATUS(status); 832 return status;
852} 833}
853 834
854EXPORT_SYMBOL(acpi_os_wait_semaphore); 835EXPORT_SYMBOL(acpi_os_wait_semaphore);
@@ -860,20 +841,19 @@ acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
860{ 841{
861 struct semaphore *sem = (struct semaphore *)handle; 842 struct semaphore *sem = (struct semaphore *)handle;
862 843
863 ACPI_FUNCTION_TRACE("os_signal_semaphore");
864 844
865 if (!sem || (units < 1)) 845 if (!sem || (units < 1))
866 return_ACPI_STATUS(AE_BAD_PARAMETER); 846 return AE_BAD_PARAMETER;
867 847
868 if (units > 1) 848 if (units > 1)
869 return_ACPI_STATUS(AE_SUPPORT); 849 return AE_SUPPORT;
870 850
871 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle, 851 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
872 units)); 852 units));
873 853
874 up(sem); 854 up(sem);
875 855
876 return_ACPI_STATUS(AE_OK); 856 return AE_OK;
877} 857}
878 858
879EXPORT_SYMBOL(acpi_os_signal_semaphore); 859EXPORT_SYMBOL(acpi_os_signal_semaphore);
@@ -1042,10 +1022,10 @@ EXPORT_SYMBOL(max_cstate);
1042 * handle is a pointer to the spinlock_t. 1022 * handle is a pointer to the spinlock_t.
1043 */ 1023 */
1044 1024
1045acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle) 1025acpi_cpu_flags acpi_os_acquire_lock(acpi_spinlock lockp)
1046{ 1026{
1047 acpi_cpu_flags flags; 1027 acpi_cpu_flags flags;
1048 spin_lock_irqsave((spinlock_t *) handle, flags); 1028 spin_lock_irqsave(lockp, flags);
1049 return flags; 1029 return flags;
1050} 1030}
1051 1031
@@ -1053,9 +1033,9 @@ acpi_cpu_flags acpi_os_acquire_lock(acpi_handle handle)
1053 * Release a spinlock. See above. 1033 * Release a spinlock. See above.
1054 */ 1034 */
1055 1035
1056void acpi_os_release_lock(acpi_handle handle, acpi_cpu_flags flags) 1036void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
1057{ 1037{
1058 spin_unlock_irqrestore((spinlock_t *) handle, flags); 1038 spin_unlock_irqrestore(lockp, flags);
1059} 1039}
1060 1040
1061#ifndef ACPI_USE_LOCAL_CACHE 1041#ifndef ACPI_USE_LOCAL_CACHE
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
index 7ee2f2e77525..a02aa62fe1e5 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/parser/psparse.c
@@ -469,6 +469,16 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
469 } 469 }
470 470
471 walk_state->thread = thread; 471 walk_state->thread = thread;
472
473 /*
474 * If executing a method, the starting sync_level is this method's
475 * sync_level
476 */
477 if (walk_state->method_desc) {
478 walk_state->thread->current_sync_level =
479 walk_state->method_desc->method.sync_level;
480 }
481
472 acpi_ds_push_walk_state(walk_state, thread); 482 acpi_ds_push_walk_state(walk_state, thread);
473 483
474 /* 484 /*
@@ -505,6 +515,10 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
505 status = 515 status =
506 acpi_ds_call_control_method(thread, walk_state, 516 acpi_ds_call_control_method(thread, walk_state,
507 NULL); 517 NULL);
518 if (ACPI_FAILURE(status)) {
519 status =
520 acpi_ds_method_error(status, walk_state);
521 }
508 522
509 /* 523 /*
510 * If the transfer to the new method method call worked, a new walk 524 * If the transfer to the new method method call worked, a new walk
@@ -525,7 +539,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
525 /* Check for possible multi-thread reentrancy problem */ 539 /* Check for possible multi-thread reentrancy problem */
526 540
527 if ((status == AE_ALREADY_EXISTS) && 541 if ((status == AE_ALREADY_EXISTS) &&
528 (!walk_state->method_desc->method.semaphore)) { 542 (!walk_state->method_desc->method.mutex)) {
529 /* 543 /*
530 * Method tried to create an object twice. The probable cause is 544 * Method tried to create an object twice. The probable cause is
531 * that the method cannot handle reentrancy. 545 * that the method cannot handle reentrancy.
@@ -537,7 +551,7 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
537 */ 551 */
538 walk_state->method_desc->method.method_flags |= 552 walk_state->method_desc->method.method_flags |=
539 AML_METHOD_SERIALIZED; 553 AML_METHOD_SERIALIZED;
540 walk_state->method_desc->method.concurrency = 1; 554 walk_state->method_desc->method.sync_level = 0;
541 } 555 }
542 } 556 }
543 557
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index 2a718df769b5..1e2ae6e7a7e4 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -47,11 +47,10 @@ struct acpi_pci_data {
47static void acpi_pci_data_handler(acpi_handle handle, u32 function, 47static void acpi_pci_data_handler(acpi_handle handle, u32 function,
48 void *context) 48 void *context)
49{ 49{
50 ACPI_FUNCTION_TRACE("acpi_pci_data_handler");
51 50
52 /* TBD: Anything we need to do here? */ 51 /* TBD: Anything we need to do here? */
53 52
54 return_VOID; 53 return;
55} 54}
56 55
57/** 56/**
@@ -68,25 +67,24 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id)
68 struct acpi_device *device = NULL; 67 struct acpi_device *device = NULL;
69 struct acpi_pci_data *data = NULL; 68 struct acpi_pci_data *data = NULL;
70 69
71 ACPI_FUNCTION_TRACE("acpi_get_pci_id");
72 70
73 if (!id) 71 if (!id)
74 return_ACPI_STATUS(AE_BAD_PARAMETER); 72 return AE_BAD_PARAMETER;
75 73
76 result = acpi_bus_get_device(handle, &device); 74 result = acpi_bus_get_device(handle, &device);
77 if (result) { 75 if (result) {
78 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 76 printk(KERN_ERR PREFIX
79 "Invalid ACPI Bus context for device %s\n", 77 "Invalid ACPI Bus context for device %s\n",
80 acpi_device_bid(device))); 78 acpi_device_bid(device));
81 return_ACPI_STATUS(AE_NOT_EXIST); 79 return AE_NOT_EXIST;
82 } 80 }
83 81
84 status = acpi_get_data(handle, acpi_pci_data_handler, (void **)&data); 82 status = acpi_get_data(handle, acpi_pci_data_handler, (void **)&data);
85 if (ACPI_FAILURE(status) || !data) { 83 if (ACPI_FAILURE(status) || !data) {
86 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 84 ACPI_EXCEPTION((AE_INFO, status,
87 "Invalid ACPI-PCI context for device %s\n", 85 "Invalid ACPI-PCI context for device %s",
88 acpi_device_bid(device))); 86 acpi_device_bid(device)));
89 return_ACPI_STATUS(status); 87 return status;
90 } 88 }
91 89
92 *id = data->id; 90 *id = data->id;
@@ -103,7 +101,7 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id)
103 acpi_device_bid(device), id->segment, id->bus, 101 acpi_device_bid(device), id->segment, id->bus,
104 id->device, id->function)); 102 id->device, id->function));
105 103
106 return_ACPI_STATUS(AE_OK); 104 return AE_OK;
107} 105}
108 106
109EXPORT_SYMBOL(acpi_get_pci_id); 107EXPORT_SYMBOL(acpi_get_pci_id);
@@ -120,14 +118,13 @@ int acpi_pci_bind(struct acpi_device *device)
120 struct pci_dev *dev; 118 struct pci_dev *dev;
121 struct pci_bus *bus; 119 struct pci_bus *bus;
122 120
123 ACPI_FUNCTION_TRACE("acpi_pci_bind");
124 121
125 if (!device || !device->parent) 122 if (!device || !device->parent)
126 return_VALUE(-EINVAL); 123 return -EINVAL;
127 124
128 pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 125 pathname = kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
129 if (!pathname) 126 if (!pathname)
130 return_VALUE(-ENOMEM); 127 return -ENOMEM;
131 memset(pathname, 0, ACPI_PATHNAME_MAX); 128 memset(pathname, 0, ACPI_PATHNAME_MAX);
132 buffer.length = ACPI_PATHNAME_MAX; 129 buffer.length = ACPI_PATHNAME_MAX;
133 buffer.pointer = pathname; 130 buffer.pointer = pathname;
@@ -135,7 +132,7 @@ int acpi_pci_bind(struct acpi_device *device)
135 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 132 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
136 if (!data) { 133 if (!data) {
137 kfree(pathname); 134 kfree(pathname);
138 return_VALUE(-ENOMEM); 135 return -ENOMEM;
139 } 136 }
140 memset(data, 0, sizeof(struct acpi_pci_data)); 137 memset(data, 0, sizeof(struct acpi_pci_data));
141 138
@@ -151,9 +148,9 @@ int acpi_pci_bind(struct acpi_device *device)
151 status = acpi_get_data(device->parent->handle, acpi_pci_data_handler, 148 status = acpi_get_data(device->parent->handle, acpi_pci_data_handler,
152 (void **)&pdata); 149 (void **)&pdata);
153 if (ACPI_FAILURE(status) || !pdata || !pdata->bus) { 150 if (ACPI_FAILURE(status) || !pdata || !pdata->bus) {
154 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 151 ACPI_EXCEPTION((AE_INFO, status,
155 "Invalid ACPI-PCI context for parent device %s\n", 152 "Invalid ACPI-PCI context for parent device %s",
156 acpi_device_bid(device->parent))); 153 acpi_device_bid(device->parent)));
157 result = -ENODEV; 154 result = -ENODEV;
158 goto end; 155 goto end;
159 } 156 }
@@ -206,10 +203,10 @@ int acpi_pci_bind(struct acpi_device *device)
206 goto end; 203 goto end;
207 } 204 }
208 if (!data->dev->bus) { 205 if (!data->dev->bus) {
209 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 206 printk(KERN_ERR PREFIX
210 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", 207 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n",
211 data->id.segment, data->id.bus, 208 data->id.segment, data->id.bus,
212 data->id.device, data->id.function)); 209 data->id.device, data->id.function);
213 result = -ENODEV; 210 result = -ENODEV;
214 goto end; 211 goto end;
215 } 212 }
@@ -237,9 +234,9 @@ int acpi_pci_bind(struct acpi_device *device)
237 */ 234 */
238 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 235 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
239 if (ACPI_FAILURE(status)) { 236 if (ACPI_FAILURE(status)) {
240 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 237 ACPI_EXCEPTION((AE_INFO, status,
241 "Unable to attach ACPI-PCI context to device %s\n", 238 "Unable to attach ACPI-PCI context to device %s",
242 acpi_device_bid(device))); 239 acpi_device_bid(device)));
243 result = -ENODEV; 240 result = -ENODEV;
244 goto end; 241 goto end;
245 } 242 }
@@ -269,7 +266,7 @@ int acpi_pci_bind(struct acpi_device *device)
269 if (result) 266 if (result)
270 kfree(data); 267 kfree(data);
271 268
272 return_VALUE(result); 269 return result;
273} 270}
274 271
275int acpi_pci_unbind(struct acpi_device *device) 272int acpi_pci_unbind(struct acpi_device *device)
@@ -280,14 +277,13 @@ int acpi_pci_unbind(struct acpi_device *device)
280 char *pathname = NULL; 277 char *pathname = NULL;
281 struct acpi_buffer buffer = { 0, NULL }; 278 struct acpi_buffer buffer = { 0, NULL };
282 279
283 ACPI_FUNCTION_TRACE("acpi_pci_unbind");
284 280
285 if (!device || !device->parent) 281 if (!device || !device->parent)
286 return_VALUE(-EINVAL); 282 return -EINVAL;
287 283
288 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 284 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
289 if (!pathname) 285 if (!pathname)
290 return_VALUE(-ENOMEM); 286 return -ENOMEM;
291 memset(pathname, 0, ACPI_PATHNAME_MAX); 287 memset(pathname, 0, ACPI_PATHNAME_MAX);
292 288
293 buffer.length = ACPI_PATHNAME_MAX; 289 buffer.length = ACPI_PATHNAME_MAX;
@@ -301,18 +297,18 @@ int acpi_pci_unbind(struct acpi_device *device)
301 acpi_get_data(device->handle, acpi_pci_data_handler, 297 acpi_get_data(device->handle, acpi_pci_data_handler,
302 (void **)&data); 298 (void **)&data);
303 if (ACPI_FAILURE(status)) { 299 if (ACPI_FAILURE(status)) {
304 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 300 ACPI_EXCEPTION((AE_INFO, status,
305 "Unable to get data from device %s\n", 301 "Unable to get data from device %s",
306 acpi_device_bid(device))); 302 acpi_device_bid(device)));
307 result = -ENODEV; 303 result = -ENODEV;
308 goto end; 304 goto end;
309 } 305 }
310 306
311 status = acpi_detach_data(device->handle, acpi_pci_data_handler); 307 status = acpi_detach_data(device->handle, acpi_pci_data_handler);
312 if (ACPI_FAILURE(status)) { 308 if (ACPI_FAILURE(status)) {
313 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 309 ACPI_EXCEPTION((AE_INFO, status,
314 "Unable to detach data from device %s\n", 310 "Unable to detach data from device %s",
315 acpi_device_bid(device))); 311 acpi_device_bid(device)));
316 result = -ENODEV; 312 result = -ENODEV;
317 goto end; 313 goto end;
318 } 314 }
@@ -322,7 +318,7 @@ int acpi_pci_unbind(struct acpi_device *device)
322 kfree(data); 318 kfree(data);
323 319
324 end: 320 end:
325 return_VALUE(result); 321 return result;
326} 322}
327 323
328int 324int
@@ -335,11 +331,10 @@ acpi_pci_bind_root(struct acpi_device *device,
335 char *pathname = NULL; 331 char *pathname = NULL;
336 struct acpi_buffer buffer = { 0, NULL }; 332 struct acpi_buffer buffer = { 0, NULL };
337 333
338 ACPI_FUNCTION_TRACE("acpi_pci_bind_root");
339 334
340 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 335 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
341 if (!pathname) 336 if (!pathname)
342 return_VALUE(-ENOMEM); 337 return -ENOMEM;
343 memset(pathname, 0, ACPI_PATHNAME_MAX); 338 memset(pathname, 0, ACPI_PATHNAME_MAX);
344 339
345 buffer.length = ACPI_PATHNAME_MAX; 340 buffer.length = ACPI_PATHNAME_MAX;
@@ -347,13 +342,13 @@ acpi_pci_bind_root(struct acpi_device *device,
347 342
348 if (!device || !id || !bus) { 343 if (!device || !id || !bus) {
349 kfree(pathname); 344 kfree(pathname);
350 return_VALUE(-EINVAL); 345 return -EINVAL;
351 } 346 }
352 347
353 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 348 data = kmalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
354 if (!data) { 349 if (!data) {
355 kfree(pathname); 350 kfree(pathname);
356 return_VALUE(-ENOMEM); 351 return -ENOMEM;
357 } 352 }
358 memset(data, 0, sizeof(struct acpi_pci_data)); 353 memset(data, 0, sizeof(struct acpi_pci_data));
359 354
@@ -369,9 +364,9 @@ acpi_pci_bind_root(struct acpi_device *device,
369 364
370 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 365 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
371 if (ACPI_FAILURE(status)) { 366 if (ACPI_FAILURE(status)) {
372 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 367 ACPI_EXCEPTION((AE_INFO, status,
373 "Unable to attach ACPI-PCI context to device %s\n", 368 "Unable to attach ACPI-PCI context to device %s",
374 pathname)); 369 pathname));
375 result = -ENODEV; 370 result = -ENODEV;
376 goto end; 371 goto end;
377 } 372 }
@@ -381,5 +376,5 @@ acpi_pci_bind_root(struct acpi_device *device,
381 if (result != 0) 376 if (result != 0)
382 kfree(data); 377 kfree(data);
383 378
384 return_VALUE(result); 379 return result;
385} 380}
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index ed3f226677aa..feda0341f5a7 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -54,10 +54,9 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment,
54 struct list_head *node = NULL; 54 struct list_head *node = NULL;
55 struct acpi_prt_entry *entry = NULL; 55 struct acpi_prt_entry *entry = NULL;
56 56
57 ACPI_FUNCTION_TRACE("acpi_pci_irq_find_prt_entry");
58 57
59 if (!acpi_prt.count) 58 if (!acpi_prt.count)
60 return_PTR(NULL); 59 return NULL;
61 60
62 /* 61 /*
63 * Parse through all PRT entries looking for a match on the specified 62 * Parse through all PRT entries looking for a match on the specified
@@ -72,12 +71,12 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment,
72 && (device == entry->id.device) 71 && (device == entry->id.device)
73 && (pin == entry->pin)) { 72 && (pin == entry->pin)) {
74 spin_unlock(&acpi_prt_lock); 73 spin_unlock(&acpi_prt_lock);
75 return_PTR(entry); 74 return entry;
76 } 75 }
77 } 76 }
78 77
79 spin_unlock(&acpi_prt_lock); 78 spin_unlock(&acpi_prt_lock);
80 return_PTR(NULL); 79 return NULL;
81} 80}
82 81
83static int 82static int
@@ -86,14 +85,13 @@ acpi_pci_irq_add_entry(acpi_handle handle,
86{ 85{
87 struct acpi_prt_entry *entry = NULL; 86 struct acpi_prt_entry *entry = NULL;
88 87
89 ACPI_FUNCTION_TRACE("acpi_pci_irq_add_entry");
90 88
91 if (!prt) 89 if (!prt)
92 return_VALUE(-EINVAL); 90 return -EINVAL;
93 91
94 entry = kmalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); 92 entry = kmalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
95 if (!entry) 93 if (!entry)
96 return_VALUE(-ENOMEM); 94 return -ENOMEM;
97 memset(entry, 0, sizeof(struct acpi_prt_entry)); 95 memset(entry, 0, sizeof(struct acpi_prt_entry));
98 96
99 entry->id.segment = segment; 97 entry->id.segment = segment;
@@ -140,7 +138,7 @@ acpi_pci_irq_add_entry(acpi_handle handle,
140 acpi_prt.count++; 138 acpi_prt.count++;
141 spin_unlock(&acpi_prt_lock); 139 spin_unlock(&acpi_prt_lock);
142 140
143 return_VALUE(0); 141 return 0;
144} 142}
145 143
146static void 144static void
@@ -162,11 +160,10 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
162 struct acpi_pci_routing_table *entry = NULL; 160 struct acpi_pci_routing_table *entry = NULL;
163 static int first_time = 1; 161 static int first_time = 1;
164 162
165 ACPI_FUNCTION_TRACE("acpi_pci_irq_add_prt");
166 163
167 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 164 pathname = (char *)kmalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
168 if (!pathname) 165 if (!pathname)
169 return_VALUE(-ENOMEM); 166 return -ENOMEM;
170 memset(pathname, 0, ACPI_PATHNAME_MAX); 167 memset(pathname, 0, ACPI_PATHNAME_MAX);
171 168
172 if (first_time) { 169 if (first_time) {
@@ -196,24 +193,24 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
196 kfree(pathname); 193 kfree(pathname);
197 status = acpi_get_irq_routing_table(handle, &buffer); 194 status = acpi_get_irq_routing_table(handle, &buffer);
198 if (status != AE_BUFFER_OVERFLOW) { 195 if (status != AE_BUFFER_OVERFLOW) {
199 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n", 196 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
200 acpi_format_exception(status))); 197 acpi_format_exception(status)));
201 return_VALUE(-ENODEV); 198 return -ENODEV;
202 } 199 }
203 200
204 prt = kmalloc(buffer.length, GFP_KERNEL); 201 prt = kmalloc(buffer.length, GFP_KERNEL);
205 if (!prt) { 202 if (!prt) {
206 return_VALUE(-ENOMEM); 203 return -ENOMEM;
207 } 204 }
208 memset(prt, 0, buffer.length); 205 memset(prt, 0, buffer.length);
209 buffer.pointer = prt; 206 buffer.pointer = prt;
210 207
211 status = acpi_get_irq_routing_table(handle, &buffer); 208 status = acpi_get_irq_routing_table(handle, &buffer);
212 if (ACPI_FAILURE(status)) { 209 if (ACPI_FAILURE(status)) {
213 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRT [%s]\n", 210 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
214 acpi_format_exception(status))); 211 acpi_format_exception(status)));
215 kfree(buffer.pointer); 212 kfree(buffer.pointer);
216 return_VALUE(-ENODEV); 213 return -ENODEV;
217 } 214 }
218 215
219 entry = prt; 216 entry = prt;
@@ -226,7 +223,7 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
226 223
227 kfree(prt); 224 kfree(prt);
228 225
229 return_VALUE(0); 226 return 0;
230} 227}
231 228
232void acpi_pci_irq_del_prt(int segment, int bus) 229void acpi_pci_irq_del_prt(int segment, int bus)
@@ -261,16 +258,15 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
261{ 258{
262 int irq; 259 int irq;
263 260
264 ACPI_FUNCTION_TRACE("acpi_pci_allocate_irq");
265 261
266 if (entry->link.handle) { 262 if (entry->link.handle) {
267 irq = acpi_pci_link_allocate_irq(entry->link.handle, 263 irq = acpi_pci_link_allocate_irq(entry->link.handle,
268 entry->link.index, triggering, 264 entry->link.index, triggering,
269 polarity, link); 265 polarity, link);
270 if (irq < 0) { 266 if (irq < 0) {
271 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 267 printk(KERN_WARNING PREFIX
272 "Invalid IRQ link routing entry\n")); 268 "Invalid IRQ link routing entry\n");
273 return_VALUE(-1); 269 return -1;
274 } 270 }
275 } else { 271 } else {
276 irq = entry->link.index; 272 irq = entry->link.index;
@@ -279,7 +275,7 @@ acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
279 } 275 }
280 276
281 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq)); 277 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
282 return_VALUE(irq); 278 return irq;
283} 279}
284 280
285static int 281static int
@@ -288,13 +284,12 @@ acpi_pci_free_irq(struct acpi_prt_entry *entry,
288{ 284{
289 int irq; 285 int irq;
290 286
291 ACPI_FUNCTION_TRACE("acpi_pci_free_irq");
292 if (entry->link.handle) { 287 if (entry->link.handle) {
293 irq = acpi_pci_link_free_irq(entry->link.handle); 288 irq = acpi_pci_link_free_irq(entry->link.handle);
294 } else { 289 } else {
295 irq = entry->link.index; 290 irq = entry->link.index;
296 } 291 }
297 return_VALUE(irq); 292 return irq;
298} 293}
299 294
300/* 295/*
@@ -314,7 +309,6 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
314 int bus_nr = bus->number; 309 int bus_nr = bus->number;
315 int ret; 310 int ret;
316 311
317 ACPI_FUNCTION_TRACE("acpi_pci_irq_lookup");
318 312
319 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 313 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
320 "Searching for PRT entry for %02x:%02x:%02x[%c]\n", 314 "Searching for PRT entry for %02x:%02x:%02x[%c]\n",
@@ -323,11 +317,11 @@ acpi_pci_irq_lookup(struct pci_bus *bus,
323 entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin); 317 entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin);
324 if (!entry) { 318 if (!entry) {
325 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n")); 319 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n"));
326 return_VALUE(-1); 320 return -1;
327 } 321 }
328 322
329 ret = func(entry, triggering, polarity, link); 323 ret = func(entry, triggering, polarity, link);
330 return_VALUE(ret); 324 return ret;
331} 325}
332 326
333/* 327/*
@@ -345,10 +339,9 @@ acpi_pci_irq_derive(struct pci_dev *dev,
345 int irq = -1; 339 int irq = -1;
346 u8 bridge_pin = 0; 340 u8 bridge_pin = 0;
347 341
348 ACPI_FUNCTION_TRACE("acpi_pci_irq_derive");
349 342
350 if (!dev) 343 if (!dev)
351 return_VALUE(-EINVAL); 344 return -EINVAL;
352 345
353 /* 346 /*
354 * Attempt to derive an IRQ for this device from a parent bridge's 347 * Attempt to derive an IRQ for this device from a parent bridge's
@@ -365,7 +358,7 @@ acpi_pci_irq_derive(struct pci_dev *dev,
365 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 358 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
366 "No interrupt pin configured for device %s\n", 359 "No interrupt pin configured for device %s\n",
367 pci_name(bridge))); 360 pci_name(bridge)));
368 return_VALUE(-1); 361 return -1;
369 } 362 }
370 /* Pin is from 0 to 3 */ 363 /* Pin is from 0 to 3 */
371 bridge_pin--; 364 bridge_pin--;
@@ -378,16 +371,15 @@ acpi_pci_irq_derive(struct pci_dev *dev,
378 } 371 }
379 372
380 if (irq < 0) { 373 if (irq < 0) {
381 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 374 printk(KERN_WARNING PREFIX "Unable to derive IRQ for device %s\n",
382 "Unable to derive IRQ for device %s\n", 375 pci_name(dev));
383 pci_name(dev))); 376 return -1;
384 return_VALUE(-1);
385 } 377 }
386 378
387 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n", 379 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n",
388 irq, pci_name(dev), pci_name(bridge))); 380 irq, pci_name(dev), pci_name(bridge)));
389 381
390 return_VALUE(irq); 382 return irq;
391} 383}
392 384
393/* 385/*
@@ -405,24 +397,22 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
405 char *link = NULL; 397 char *link = NULL;
406 int rc; 398 int rc;
407 399
408 ACPI_FUNCTION_TRACE("acpi_pci_irq_enable");
409 400
410 if (!dev) 401 if (!dev)
411 return_VALUE(-EINVAL); 402 return -EINVAL;
412 403
413 pin = dev->pin; 404 pin = dev->pin;
414 if (!pin) { 405 if (!pin) {
415 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 406 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
416 "No interrupt pin configured for device %s\n", 407 "No interrupt pin configured for device %s\n",
417 pci_name(dev))); 408 pci_name(dev)));
418 return_VALUE(0); 409 return 0;
419 } 410 }
420 pin--; 411 pin--;
421 412
422 if (!dev->bus) { 413 if (!dev->bus) {
423 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 414 printk(KERN_ERR PREFIX "Invalid (NULL) 'bus' field\n");
424 "Invalid (NULL) 'bus' field\n")); 415 return -ENODEV;
425 return_VALUE(-ENODEV);
426 } 416 }
427 417
428 /* 418 /*
@@ -454,10 +444,10 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
454 printk(" - using IRQ %d\n", dev->irq); 444 printk(" - using IRQ %d\n", dev->irq);
455 acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE, 445 acpi_register_gsi(dev->irq, ACPI_LEVEL_SENSITIVE,
456 ACPI_ACTIVE_LOW); 446 ACPI_ACTIVE_LOW);
457 return_VALUE(0); 447 return 0;
458 } else { 448 } else {
459 printk("\n"); 449 printk("\n");
460 return_VALUE(0); 450 return 0;
461 } 451 }
462 } 452 }
463 453
@@ -465,7 +455,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
465 if (rc < 0) { 455 if (rc < 0) {
466 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed " 456 printk(KERN_WARNING PREFIX "PCI Interrupt %s[%c]: failed "
467 "to register GSI\n", pci_name(dev), ('A' + pin)); 457 "to register GSI\n", pci_name(dev), ('A' + pin));
468 return_VALUE(rc); 458 return rc;
469 } 459 }
470 dev->irq = rc; 460 dev->irq = rc;
471 461
@@ -479,7 +469,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
479 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 469 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
480 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); 470 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
481 471
482 return_VALUE(0); 472 return 0;
483} 473}
484 474
485EXPORT_SYMBOL(acpi_pci_irq_enable); 475EXPORT_SYMBOL(acpi_pci_irq_enable);
@@ -496,14 +486,13 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
496 int triggering = ACPI_LEVEL_SENSITIVE; 486 int triggering = ACPI_LEVEL_SENSITIVE;
497 int polarity = ACPI_ACTIVE_LOW; 487 int polarity = ACPI_ACTIVE_LOW;
498 488
499 ACPI_FUNCTION_TRACE("acpi_pci_irq_disable");
500 489
501 if (!dev || !dev->bus) 490 if (!dev || !dev->bus)
502 return_VOID; 491 return;
503 492
504 pin = dev->pin; 493 pin = dev->pin;
505 if (!pin) 494 if (!pin)
506 return_VOID; 495 return;
507 pin--; 496 pin--;
508 497
509 /* 498 /*
@@ -521,7 +510,7 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
521 &triggering, &polarity, NULL, 510 &triggering, &polarity, NULL,
522 acpi_pci_free_irq); 511 acpi_pci_free_irq);
523 if (gsi < 0) 512 if (gsi < 0)
524 return_VOID; 513 return;
525 514
526 /* 515 /*
527 * TBD: It might be worth clearing dev->irq by magic constant 516 * TBD: It might be worth clearing dev->irq by magic constant
@@ -533,5 +522,5 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
533 522
534 acpi_unregister_gsi(gsi); 523 acpi_unregister_gsi(gsi);
535 524
536 return_VOID; 525 return;
537} 526}
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 228bdb626502..1badce27a83f 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -107,26 +107,23 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
107 struct acpi_pci_link *link = (struct acpi_pci_link *)context; 107 struct acpi_pci_link *link = (struct acpi_pci_link *)context;
108 u32 i = 0; 108 u32 i = 0;
109 109
110 ACPI_FUNCTION_TRACE("acpi_pci_link_check_possible");
111 110
112 switch (resource->type) { 111 switch (resource->type) {
113 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 112 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
114 return_ACPI_STATUS(AE_OK); 113 return AE_OK;
115 case ACPI_RESOURCE_TYPE_IRQ: 114 case ACPI_RESOURCE_TYPE_IRQ:
116 { 115 {
117 struct acpi_resource_irq *p = &resource->data.irq; 116 struct acpi_resource_irq *p = &resource->data.irq;
118 if (!p || !p->interrupt_count) { 117 if (!p || !p->interrupt_count) {
119 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 118 printk(KERN_WARNING PREFIX "Blank IRQ resource\n");
120 "Blank IRQ resource\n")); 119 return AE_OK;
121 return_ACPI_STATUS(AE_OK);
122 } 120 }
123 for (i = 0; 121 for (i = 0;
124 (i < p->interrupt_count 122 (i < p->interrupt_count
125 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 123 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
126 if (!p->interrupts[i]) { 124 if (!p->interrupts[i]) {
127 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 125 printk(KERN_WARNING PREFIX "Invalid IRQ %d\n",
128 "Invalid IRQ %d\n", 126 p->interrupts[i]);
129 p->interrupts[i]));
130 continue; 127 continue;
131 } 128 }
132 link->irq.possible[i] = p->interrupts[i]; 129 link->irq.possible[i] = p->interrupts[i];
@@ -142,17 +139,16 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
142 struct acpi_resource_extended_irq *p = 139 struct acpi_resource_extended_irq *p =
143 &resource->data.extended_irq; 140 &resource->data.extended_irq;
144 if (!p || !p->interrupt_count) { 141 if (!p || !p->interrupt_count) {
145 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 142 printk(KERN_WARNING PREFIX
146 "Blank EXT IRQ resource\n")); 143 "Blank EXT IRQ resource\n");
147 return_ACPI_STATUS(AE_OK); 144 return AE_OK;
148 } 145 }
149 for (i = 0; 146 for (i = 0;
150 (i < p->interrupt_count 147 (i < p->interrupt_count
151 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) { 148 && i < ACPI_PCI_LINK_MAX_POSSIBLE); i++) {
152 if (!p->interrupts[i]) { 149 if (!p->interrupts[i]) {
153 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 150 printk(KERN_WARNING PREFIX "Invalid IRQ %d\n",
154 "Invalid IRQ %d\n", 151 p->interrupts[i]);
155 p->interrupts[i]));
156 continue; 152 continue;
157 } 153 }
158 link->irq.possible[i] = p->interrupts[i]; 154 link->irq.possible[i] = p->interrupts[i];
@@ -164,35 +160,33 @@ acpi_pci_link_check_possible(struct acpi_resource *resource, void *context)
164 break; 160 break;
165 } 161 }
166 default: 162 default:
167 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 163 printk(KERN_ERR PREFIX "Resource is not an IRQ entry\n");
168 "Resource is not an IRQ entry\n")); 164 return AE_OK;
169 return_ACPI_STATUS(AE_OK);
170 } 165 }
171 166
172 return_ACPI_STATUS(AE_CTRL_TERMINATE); 167 return AE_CTRL_TERMINATE;
173} 168}
174 169
175static int acpi_pci_link_get_possible(struct acpi_pci_link *link) 170static int acpi_pci_link_get_possible(struct acpi_pci_link *link)
176{ 171{
177 acpi_status status; 172 acpi_status status;
178 173
179 ACPI_FUNCTION_TRACE("acpi_pci_link_get_possible");
180 174
181 if (!link) 175 if (!link)
182 return_VALUE(-EINVAL); 176 return -EINVAL;
183 177
184 status = acpi_walk_resources(link->handle, METHOD_NAME__PRS, 178 status = acpi_walk_resources(link->handle, METHOD_NAME__PRS,
185 acpi_pci_link_check_possible, link); 179 acpi_pci_link_check_possible, link);
186 if (ACPI_FAILURE(status)) { 180 if (ACPI_FAILURE(status)) {
187 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRS\n")); 181 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRS"));
188 return_VALUE(-ENODEV); 182 return -ENODEV;
189 } 183 }
190 184
191 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 185 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
192 "Found %d possible IRQs\n", 186 "Found %d possible IRQs\n",
193 link->irq.possible_count)); 187 link->irq.possible_count));
194 188
195 return_VALUE(0); 189 return 0;
196} 190}
197 191
198static acpi_status 192static acpi_status
@@ -200,7 +194,6 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
200{ 194{
201 int *irq = (int *)context; 195 int *irq = (int *)context;
202 196
203 ACPI_FUNCTION_TRACE("acpi_pci_link_check_current");
204 197
205 switch (resource->type) { 198 switch (resource->type) {
206 case ACPI_RESOURCE_TYPE_IRQ: 199 case ACPI_RESOURCE_TYPE_IRQ:
@@ -213,7 +206,7 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
213 */ 206 */
214 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 207 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
215 "Blank IRQ resource\n")); 208 "Blank IRQ resource\n"));
216 return_ACPI_STATUS(AE_OK); 209 return AE_OK;
217 } 210 }
218 *irq = p->interrupts[0]; 211 *irq = p->interrupts[0];
219 break; 212 break;
@@ -227,20 +220,20 @@ acpi_pci_link_check_current(struct acpi_resource *resource, void *context)
227 * extended IRQ descriptors must 220 * extended IRQ descriptors must
228 * return at least 1 IRQ 221 * return at least 1 IRQ
229 */ 222 */
230 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 223 printk(KERN_WARNING PREFIX
231 "Blank EXT IRQ resource\n")); 224 "Blank EXT IRQ resource\n");
232 return_ACPI_STATUS(AE_OK); 225 return AE_OK;
233 } 226 }
234 *irq = p->interrupts[0]; 227 *irq = p->interrupts[0];
235 break; 228 break;
236 } 229 }
237 break; 230 break;
238 default: 231 default:
239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Resource %d isn't an IRQ\n", resource->type)); 232 printk(KERN_ERR PREFIX "Resource %d isn't an IRQ\n", resource->type);
240 case ACPI_RESOURCE_TYPE_END_TAG: 233 case ACPI_RESOURCE_TYPE_END_TAG:
241 return_ACPI_STATUS(AE_OK); 234 return AE_OK;
242 } 235 }
243 return_ACPI_STATUS(AE_CTRL_TERMINATE); 236 return AE_CTRL_TERMINATE;
244} 237}
245 238
246/* 239/*
@@ -256,10 +249,9 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
256 acpi_status status = AE_OK; 249 acpi_status status = AE_OK;
257 int irq = 0; 250 int irq = 0;
258 251
259 ACPI_FUNCTION_TRACE("acpi_pci_link_get_current");
260 252
261 if (!link || !link->handle) 253 if (!link || !link->handle)
262 return_VALUE(-EINVAL); 254 return -EINVAL;
263 255
264 link->irq.active = 0; 256 link->irq.active = 0;
265 257
@@ -268,14 +260,13 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
268 /* Query _STA, set link->device->status */ 260 /* Query _STA, set link->device->status */
269 result = acpi_bus_get_status(link->device); 261 result = acpi_bus_get_status(link->device);
270 if (result) { 262 if (result) {
271 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 263 printk(KERN_ERR PREFIX "Unable to read status\n");
272 "Unable to read status\n"));
273 goto end; 264 goto end;
274 } 265 }
275 266
276 if (!link->device->status.enabled) { 267 if (!link->device->status.enabled) {
277 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link disabled\n")); 268 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link disabled\n"));
278 return_VALUE(0); 269 return 0;
279 } 270 }
280 } 271 }
281 272
@@ -286,13 +277,13 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
286 status = acpi_walk_resources(link->handle, METHOD_NAME__CRS, 277 status = acpi_walk_resources(link->handle, METHOD_NAME__CRS,
287 acpi_pci_link_check_current, &irq); 278 acpi_pci_link_check_current, &irq);
288 if (ACPI_FAILURE(status)) { 279 if (ACPI_FAILURE(status)) {
289 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _CRS\n")); 280 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _CRS"));
290 result = -ENODEV; 281 result = -ENODEV;
291 goto end; 282 goto end;
292 } 283 }
293 284
294 if (acpi_strict && !irq) { 285 if (acpi_strict && !irq) {
295 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "_CRS returned 0\n")); 286 printk(KERN_ERR PREFIX "_CRS returned 0\n");
296 result = -ENODEV; 287 result = -ENODEV;
297 } 288 }
298 289
@@ -301,7 +292,7 @@ static int acpi_pci_link_get_current(struct acpi_pci_link *link)
301 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active)); 292 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Link at IRQ %d \n", link->irq.active));
302 293
303 end: 294 end:
304 return_VALUE(result); 295 return result;
305} 296}
306 297
307static int acpi_pci_link_set(struct acpi_pci_link *link, int irq) 298static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
@@ -314,14 +305,13 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
314 } *resource; 305 } *resource;
315 struct acpi_buffer buffer = { 0, NULL }; 306 struct acpi_buffer buffer = { 0, NULL };
316 307
317 ACPI_FUNCTION_TRACE("acpi_pci_link_set");
318 308
319 if (!link || !irq) 309 if (!link || !irq)
320 return_VALUE(-EINVAL); 310 return -EINVAL;
321 311
322 resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC); 312 resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC);
323 if (!resource) 313 if (!resource)
324 return_VALUE(-ENOMEM); 314 return -ENOMEM;
325 315
326 memset(resource, 0, sizeof(*resource) + 1); 316 memset(resource, 0, sizeof(*resource) + 1);
327 buffer.length = sizeof(*resource) + 1; 317 buffer.length = sizeof(*resource) + 1;
@@ -362,7 +352,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
362 /* ignore resource_source, it's optional */ 352 /* ignore resource_source, it's optional */
363 break; 353 break;
364 default: 354 default:
365 printk("ACPI BUG: resource_type %d\n", link->irq.resource_type); 355 printk(KERN_ERR PREFIX "Invalid Resource_type %d\n", link->irq.resource_type);
366 result = -EINVAL; 356 result = -EINVAL;
367 goto end; 357 goto end;
368 358
@@ -374,7 +364,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
374 364
375 /* check for total failure */ 365 /* check for total failure */
376 if (ACPI_FAILURE(status)) { 366 if (ACPI_FAILURE(status)) {
377 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SRS\n")); 367 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SRS"));
378 result = -ENODEV; 368 result = -ENODEV;
379 goto end; 369 goto end;
380 } 370 }
@@ -382,14 +372,14 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
382 /* Query _STA, set device->status */ 372 /* Query _STA, set device->status */
383 result = acpi_bus_get_status(link->device); 373 result = acpi_bus_get_status(link->device);
384 if (result) { 374 if (result) {
385 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to read status\n")); 375 printk(KERN_ERR PREFIX "Unable to read status\n");
386 goto end; 376 goto end;
387 } 377 }
388 if (!link->device->status.enabled) { 378 if (!link->device->status.enabled) {
389 printk(KERN_WARNING PREFIX 379 printk(KERN_WARNING PREFIX
390 "%s [%s] disabled and referenced, BIOS bug.\n", 380 "%s [%s] disabled and referenced, BIOS bug\n",
391 acpi_device_name(link->device), 381 acpi_device_name(link->device),
392 acpi_device_bid(link->device)); 382 acpi_device_bid(link->device));
393 } 383 }
394 384
395 /* Query _CRS, set link->irq.active */ 385 /* Query _CRS, set link->irq.active */
@@ -408,9 +398,9 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
408 * assume _SRS worked and override _CRS value. 398 * assume _SRS worked and override _CRS value.
409 */ 399 */
410 printk(KERN_WARNING PREFIX 400 printk(KERN_WARNING PREFIX
411 "%s [%s] BIOS reported IRQ %d, using IRQ %d\n", 401 "%s [%s] BIOS reported IRQ %d, using IRQ %d\n",
412 acpi_device_name(link->device), 402 acpi_device_name(link->device),
413 acpi_device_bid(link->device), link->irq.active, irq); 403 acpi_device_bid(link->device), link->irq.active, irq);
414 link->irq.active = irq; 404 link->irq.active = irq;
415 } 405 }
416 406
@@ -418,7 +408,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
418 408
419 end: 409 end:
420 kfree(resource); 410 kfree(resource);
421 return_VALUE(result); 411 return result;
422} 412}
423 413
424/* -------------------------------------------------------------------------- 414/* --------------------------------------------------------------------------
@@ -492,7 +482,6 @@ int __init acpi_irq_penalty_init(void)
492 struct acpi_pci_link *link = NULL; 482 struct acpi_pci_link *link = NULL;
493 int i = 0; 483 int i = 0;
494 484
495 ACPI_FUNCTION_TRACE("acpi_irq_penalty_init");
496 485
497 /* 486 /*
498 * Update penalties to facilitate IRQ balancing. 487 * Update penalties to facilitate IRQ balancing.
@@ -501,8 +490,7 @@ int __init acpi_irq_penalty_init(void)
501 490
502 link = list_entry(node, struct acpi_pci_link, node); 491 link = list_entry(node, struct acpi_pci_link, node);
503 if (!link) { 492 if (!link) {
504 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 493 printk(KERN_ERR PREFIX "Invalid link context\n");
505 "Invalid link context\n"));
506 continue; 494 continue;
507 } 495 }
508 496
@@ -530,7 +518,7 @@ int __init acpi_irq_penalty_init(void)
530 /* Add a penalty for the SCI */ 518 /* Add a penalty for the SCI */
531 acpi_irq_penalty[acpi_fadt.sci_int] += PIRQ_PENALTY_PCI_USING; 519 acpi_irq_penalty[acpi_fadt.sci_int] += PIRQ_PENALTY_PCI_USING;
532 520
533 return_VALUE(0); 521 return 0;
534} 522}
535 523
536static int acpi_irq_balance; /* 0: static, 1: balance */ 524static int acpi_irq_balance; /* 0: static, 1: balance */
@@ -540,13 +528,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
540 int irq; 528 int irq;
541 int i; 529 int i;
542 530
543 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate");
544 531
545 if (link->irq.initialized) { 532 if (link->irq.initialized) {
546 if (link->refcnt == 0) 533 if (link->refcnt == 0)
547 /* This means the link is disabled but initialized */ 534 /* This means the link is disabled but initialized */
548 acpi_pci_link_set(link, link->irq.active); 535 acpi_pci_link_set(link, link->irq.active);
549 return_VALUE(0); 536 return 0;
550 } 537 }
551 538
552 /* 539 /*
@@ -562,7 +549,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
562 if (i == link->irq.possible_count) { 549 if (i == link->irq.possible_count) {
563 if (acpi_strict) 550 if (acpi_strict)
564 printk(KERN_WARNING PREFIX "_CRS %d not found" 551 printk(KERN_WARNING PREFIX "_CRS %d not found"
565 " in _PRS\n", link->irq.active); 552 " in _PRS\n", link->irq.active);
566 link->irq.active = 0; 553 link->irq.active = 0;
567 } 554 }
568 555
@@ -589,12 +576,11 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
589 576
590 /* Attempt to enable the link device at this IRQ. */ 577 /* Attempt to enable the link device at this IRQ. */
591 if (acpi_pci_link_set(link, irq)) { 578 if (acpi_pci_link_set(link, irq)) {
592 printk(PREFIX 579 printk(KERN_ERR PREFIX "Unable to set IRQ for %s [%s]. "
593 "Unable to set IRQ for %s [%s] (likely buggy ACPI BIOS).\n" 580 "Try pci=noacpi or acpi=off\n",
594 "Try pci=noacpi or acpi=off\n", 581 acpi_device_name(link->device),
595 acpi_device_name(link->device), 582 acpi_device_bid(link->device));
596 acpi_device_bid(link->device)); 583 return -ENODEV;
597 return_VALUE(-ENODEV);
598 } else { 584 } else {
599 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING; 585 acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING;
600 printk(PREFIX "%s [%s] enabled at IRQ %d\n", 586 printk(PREFIX "%s [%s] enabled at IRQ %d\n",
@@ -604,7 +590,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
604 590
605 link->irq.initialized = 1; 591 link->irq.initialized = 1;
606 592
607 return_VALUE(0); 593 return 0;
608} 594}
609 595
610/* 596/*
@@ -622,36 +608,35 @@ acpi_pci_link_allocate_irq(acpi_handle handle,
622 struct acpi_device *device = NULL; 608 struct acpi_device *device = NULL;
623 struct acpi_pci_link *link = NULL; 609 struct acpi_pci_link *link = NULL;
624 610
625 ACPI_FUNCTION_TRACE("acpi_pci_link_allocate_irq");
626 611
627 result = acpi_bus_get_device(handle, &device); 612 result = acpi_bus_get_device(handle, &device);
628 if (result) { 613 if (result) {
629 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n")); 614 printk(KERN_ERR PREFIX "Invalid link device\n");
630 return_VALUE(-1); 615 return -1;
631 } 616 }
632 617
633 link = (struct acpi_pci_link *)acpi_driver_data(device); 618 link = (struct acpi_pci_link *)acpi_driver_data(device);
634 if (!link) { 619 if (!link) {
635 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); 620 printk(KERN_ERR PREFIX "Invalid link context\n");
636 return_VALUE(-1); 621 return -1;
637 } 622 }
638 623
639 /* TBD: Support multiple index (IRQ) entries per Link Device */ 624 /* TBD: Support multiple index (IRQ) entries per Link Device */
640 if (index) { 625 if (index) {
641 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid index %d\n", index)); 626 printk(KERN_ERR PREFIX "Invalid index %d\n", index);
642 return_VALUE(-1); 627 return -1;
643 } 628 }
644 629
645 mutex_lock(&acpi_link_lock); 630 mutex_lock(&acpi_link_lock);
646 if (acpi_pci_link_allocate(link)) { 631 if (acpi_pci_link_allocate(link)) {
647 mutex_unlock(&acpi_link_lock); 632 mutex_unlock(&acpi_link_lock);
648 return_VALUE(-1); 633 return -1;
649 } 634 }
650 635
651 if (!link->irq.active) { 636 if (!link->irq.active) {
652 mutex_unlock(&acpi_link_lock); 637 mutex_unlock(&acpi_link_lock);
653 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link active IRQ is 0!\n")); 638 printk(KERN_ERR PREFIX "Link active IRQ is 0!\n");
654 return_VALUE(-1); 639 return -1;
655 } 640 }
656 link->refcnt++; 641 link->refcnt++;
657 mutex_unlock(&acpi_link_lock); 642 mutex_unlock(&acpi_link_lock);
@@ -665,7 +650,7 @@ acpi_pci_link_allocate_irq(acpi_handle handle,
665 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 650 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
666 "Link %s is referenced\n", 651 "Link %s is referenced\n",
667 acpi_device_bid(link->device))); 652 acpi_device_bid(link->device)));
668 return_VALUE(link->irq.active); 653 return (link->irq.active);
669} 654}
670 655
671/* 656/*
@@ -678,25 +663,24 @@ int acpi_pci_link_free_irq(acpi_handle handle)
678 struct acpi_pci_link *link = NULL; 663 struct acpi_pci_link *link = NULL;
679 acpi_status result; 664 acpi_status result;
680 665
681 ACPI_FUNCTION_TRACE("acpi_pci_link_free_irq");
682 666
683 result = acpi_bus_get_device(handle, &device); 667 result = acpi_bus_get_device(handle, &device);
684 if (result) { 668 if (result) {
685 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link device\n")); 669 printk(KERN_ERR PREFIX "Invalid link device\n");
686 return_VALUE(-1); 670 return -1;
687 } 671 }
688 672
689 link = (struct acpi_pci_link *)acpi_driver_data(device); 673 link = (struct acpi_pci_link *)acpi_driver_data(device);
690 if (!link) { 674 if (!link) {
691 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid link context\n")); 675 printk(KERN_ERR PREFIX "Invalid link context\n");
692 return_VALUE(-1); 676 return -1;
693 } 677 }
694 678
695 mutex_lock(&acpi_link_lock); 679 mutex_lock(&acpi_link_lock);
696 if (!link->irq.initialized) { 680 if (!link->irq.initialized) {
697 mutex_unlock(&acpi_link_lock); 681 mutex_unlock(&acpi_link_lock);
698 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Link isn't initialized\n")); 682 printk(KERN_ERR PREFIX "Link isn't initialized\n");
699 return_VALUE(-1); 683 return -1;
700 } 684 }
701#ifdef FUTURE_USE 685#ifdef FUTURE_USE
702 /* 686 /*
@@ -718,7 +702,7 @@ int acpi_pci_link_free_irq(acpi_handle handle)
718 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL); 702 acpi_ut_evaluate_object(link->handle, "_DIS", 0, NULL);
719 } 703 }
720 mutex_unlock(&acpi_link_lock); 704 mutex_unlock(&acpi_link_lock);
721 return_VALUE(link->irq.active); 705 return (link->irq.active);
722} 706}
723 707
724/* -------------------------------------------------------------------------- 708/* --------------------------------------------------------------------------
@@ -732,14 +716,13 @@ static int acpi_pci_link_add(struct acpi_device *device)
732 int i = 0; 716 int i = 0;
733 int found = 0; 717 int found = 0;
734 718
735 ACPI_FUNCTION_TRACE("acpi_pci_link_add");
736 719
737 if (!device) 720 if (!device)
738 return_VALUE(-EINVAL); 721 return -EINVAL;
739 722
740 link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL); 723 link = kmalloc(sizeof(struct acpi_pci_link), GFP_KERNEL);
741 if (!link) 724 if (!link)
742 return_VALUE(-ENOMEM); 725 return -ENOMEM;
743 memset(link, 0, sizeof(struct acpi_pci_link)); 726 memset(link, 0, sizeof(struct acpi_pci_link));
744 727
745 link->device = device; 728 link->device = device;
@@ -788,17 +771,16 @@ static int acpi_pci_link_add(struct acpi_device *device)
788 if (result) 771 if (result)
789 kfree(link); 772 kfree(link);
790 773
791 return_VALUE(result); 774 return result;
792} 775}
793 776
794static int acpi_pci_link_resume(struct acpi_pci_link *link) 777static int acpi_pci_link_resume(struct acpi_pci_link *link)
795{ 778{
796 ACPI_FUNCTION_TRACE("acpi_pci_link_resume");
797 779
798 if (link->refcnt && link->irq.active && link->irq.initialized) 780 if (link->refcnt && link->irq.active && link->irq.initialized)
799 return_VALUE(acpi_pci_link_set(link, link->irq.active)); 781 return (acpi_pci_link_set(link, link->irq.active));
800 else 782 else
801 return_VALUE(0); 783 return 0;
802} 784}
803 785
804/* 786/*
@@ -811,7 +793,6 @@ static int irqrouter_resume(struct sys_device *dev)
811 struct list_head *node = NULL; 793 struct list_head *node = NULL;
812 struct acpi_pci_link *link = NULL; 794 struct acpi_pci_link *link = NULL;
813 795
814 ACPI_FUNCTION_TRACE("irqrouter_resume");
815 796
816 /* Make sure SCI is enabled again (Apple firmware bug?) */ 797 /* Make sure SCI is enabled again (Apple firmware bug?) */
817 acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1, ACPI_MTX_DO_NOT_LOCK); 798 acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1, ACPI_MTX_DO_NOT_LOCK);
@@ -820,24 +801,22 @@ static int irqrouter_resume(struct sys_device *dev)
820 list_for_each(node, &acpi_link.entries) { 801 list_for_each(node, &acpi_link.entries) {
821 link = list_entry(node, struct acpi_pci_link, node); 802 link = list_entry(node, struct acpi_pci_link, node);
822 if (!link) { 803 if (!link) {
823 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 804 printk(KERN_ERR PREFIX "Invalid link context\n");
824 "Invalid link context\n"));
825 continue; 805 continue;
826 } 806 }
827 acpi_pci_link_resume(link); 807 acpi_pci_link_resume(link);
828 } 808 }
829 acpi_in_resume = 0; 809 acpi_in_resume = 0;
830 return_VALUE(0); 810 return 0;
831} 811}
832 812
833static int acpi_pci_link_remove(struct acpi_device *device, int type) 813static int acpi_pci_link_remove(struct acpi_device *device, int type)
834{ 814{
835 struct acpi_pci_link *link = NULL; 815 struct acpi_pci_link *link = NULL;
836 816
837 ACPI_FUNCTION_TRACE("acpi_pci_link_remove");
838 817
839 if (!device || !acpi_driver_data(device)) 818 if (!device || !acpi_driver_data(device))
840 return_VALUE(-EINVAL); 819 return -EINVAL;
841 820
842 link = (struct acpi_pci_link *)acpi_driver_data(device); 821 link = (struct acpi_pci_link *)acpi_driver_data(device);
843 822
@@ -847,7 +826,7 @@ static int acpi_pci_link_remove(struct acpi_device *device, int type)
847 826
848 kfree(link); 827 kfree(link);
849 828
850 return_VALUE(0); 829 return 0;
851} 830}
852 831
853/* 832/*
@@ -953,34 +932,32 @@ static int __init irqrouter_init_sysfs(void)
953{ 932{
954 int error; 933 int error;
955 934
956 ACPI_FUNCTION_TRACE("irqrouter_init_sysfs");
957 935
958 if (acpi_disabled || acpi_noirq) 936 if (acpi_disabled || acpi_noirq)
959 return_VALUE(0); 937 return 0;
960 938
961 error = sysdev_class_register(&irqrouter_sysdev_class); 939 error = sysdev_class_register(&irqrouter_sysdev_class);
962 if (!error) 940 if (!error)
963 error = sysdev_register(&device_irqrouter); 941 error = sysdev_register(&device_irqrouter);
964 942
965 return_VALUE(error); 943 return error;
966} 944}
967 945
968device_initcall(irqrouter_init_sysfs); 946device_initcall(irqrouter_init_sysfs);
969 947
970static int __init acpi_pci_link_init(void) 948static int __init acpi_pci_link_init(void)
971{ 949{
972 ACPI_FUNCTION_TRACE("acpi_pci_link_init");
973 950
974 if (acpi_noirq) 951 if (acpi_noirq)
975 return_VALUE(0); 952 return 0;
976 953
977 acpi_link.count = 0; 954 acpi_link.count = 0;
978 INIT_LIST_HEAD(&acpi_link.entries); 955 INIT_LIST_HEAD(&acpi_link.entries);
979 956
980 if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0) 957 if (acpi_bus_register_driver(&acpi_pci_link_driver) < 0)
981 return_VALUE(-ENODEV); 958 return -ENODEV;
982 959
983 return_VALUE(0); 960 return 0;
984} 961}
985 962
986subsys_initcall(acpi_pci_link_init); 963subsys_initcall(acpi_pci_link_init);
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 4c313eab6313..8f10442119f0 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -160,14 +160,13 @@ static int acpi_pci_root_add(struct acpi_device *device)
160 unsigned long value = 0; 160 unsigned long value = 0;
161 acpi_handle handle = NULL; 161 acpi_handle handle = NULL;
162 162
163 ACPI_FUNCTION_TRACE("acpi_pci_root_add");
164 163
165 if (!device) 164 if (!device)
166 return_VALUE(-EINVAL); 165 return -EINVAL;
167 166
168 root = kmalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); 167 root = kmalloc(sizeof(struct acpi_pci_root), GFP_KERNEL);
169 if (!root) 168 if (!root)
170 return_VALUE(-ENOMEM); 169 return -ENOMEM;
171 memset(root, 0, sizeof(struct acpi_pci_root)); 170 memset(root, 0, sizeof(struct acpi_pci_root));
172 INIT_LIST_HEAD(&root->node); 171 INIT_LIST_HEAD(&root->node);
173 172
@@ -198,7 +197,7 @@ static int acpi_pci_root_add(struct acpi_device *device)
198 root->id.segment = 0; 197 root->id.segment = 0;
199 break; 198 break;
200 default: 199 default:
201 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _SEG\n")); 200 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _SEG"));
202 result = -ENODEV; 201 result = -ENODEV;
203 goto end; 202 goto end;
204 } 203 }
@@ -219,7 +218,7 @@ static int acpi_pci_root_add(struct acpi_device *device)
219 root->id.bus = 0; 218 root->id.bus = 0;
220 break; 219 break;
221 default: 220 default:
222 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _BBN\n")); 221 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BBN"));
223 result = -ENODEV; 222 result = -ENODEV;
224 goto end; 223 goto end;
225 } 224 }
@@ -231,8 +230,9 @@ static int acpi_pci_root_add(struct acpi_device *device)
231 int bus = 0; 230 int bus = 0;
232 acpi_status status; 231 acpi_status status;
233 232
234 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 233 printk(KERN_ERR PREFIX
235 "Wrong _BBN value, please reboot and using option 'pci=noacpi'\n")); 234 "Wrong _BBN value, reboot"
235 " and use option 'pci=noacpi'\n");
236 236
237 status = try_get_root_bridge_busnr(root->handle, &bus); 237 status = try_get_root_bridge_busnr(root->handle, &bus);
238 if (ACPI_FAILURE(status)) 238 if (ACPI_FAILURE(status))
@@ -273,9 +273,9 @@ static int acpi_pci_root_add(struct acpi_device *device)
273 */ 273 */
274 root->bus = pci_acpi_scan_root(device, root->id.segment, root->id.bus); 274 root->bus = pci_acpi_scan_root(device, root->id.segment, root->id.bus);
275 if (!root->bus) { 275 if (!root->bus) {
276 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 276 printk(KERN_ERR PREFIX
277 "Bus %04x:%02x not present in PCI namespace\n", 277 "Bus %04x:%02x not present in PCI namespace\n",
278 root->id.segment, root->id.bus)); 278 root->id.segment, root->id.bus);
279 result = -ENODEV; 279 result = -ENODEV;
280 goto end; 280 goto end;
281 } 281 }
@@ -306,46 +306,43 @@ static int acpi_pci_root_add(struct acpi_device *device)
306 kfree(root); 306 kfree(root);
307 } 307 }
308 308
309 return_VALUE(result); 309 return result;
310} 310}
311 311
312static int acpi_pci_root_start(struct acpi_device *device) 312static int acpi_pci_root_start(struct acpi_device *device)
313{ 313{
314 struct acpi_pci_root *root; 314 struct acpi_pci_root *root;
315 315
316 ACPI_FUNCTION_TRACE("acpi_pci_root_start");
317 316
318 list_for_each_entry(root, &acpi_pci_roots, node) { 317 list_for_each_entry(root, &acpi_pci_roots, node) {
319 if (root->handle == device->handle) { 318 if (root->handle == device->handle) {
320 pci_bus_add_devices(root->bus); 319 pci_bus_add_devices(root->bus);
321 return_VALUE(0); 320 return 0;
322 } 321 }
323 } 322 }
324 return_VALUE(-ENODEV); 323 return -ENODEV;
325} 324}
326 325
327static int acpi_pci_root_remove(struct acpi_device *device, int type) 326static int acpi_pci_root_remove(struct acpi_device *device, int type)
328{ 327{
329 struct acpi_pci_root *root = NULL; 328 struct acpi_pci_root *root = NULL;
330 329
331 ACPI_FUNCTION_TRACE("acpi_pci_root_remove");
332 330
333 if (!device || !acpi_driver_data(device)) 331 if (!device || !acpi_driver_data(device))
334 return_VALUE(-EINVAL); 332 return -EINVAL;
335 333
336 root = (struct acpi_pci_root *)acpi_driver_data(device); 334 root = (struct acpi_pci_root *)acpi_driver_data(device);
337 335
338 kfree(root); 336 kfree(root);
339 337
340 return_VALUE(0); 338 return 0;
341} 339}
342 340
343static int __init acpi_pci_root_init(void) 341static int __init acpi_pci_root_init(void)
344{ 342{
345 ACPI_FUNCTION_TRACE("acpi_pci_root_init");
346 343
347 if (acpi_pci_disabled) 344 if (acpi_pci_disabled)
348 return_VALUE(0); 345 return 0;
349 346
350 /* DEBUG: 347 /* DEBUG:
351 acpi_dbg_layer = ACPI_PCI_COMPONENT; 348 acpi_dbg_layer = ACPI_PCI_COMPONENT;
@@ -353,9 +350,9 @@ static int __init acpi_pci_root_init(void)
353 */ 350 */
354 351
355 if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0) 352 if (acpi_bus_register_driver(&acpi_pci_root_driver) < 0)
356 return_VALUE(-ENODEV); 353 return -ENODEV;
357 354
358 return_VALUE(0); 355 return 0;
359} 356}
360 357
361subsys_initcall(acpi_pci_root_init); 358subsys_initcall(acpi_pci_root_init);
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 62a5595ed8bc..224f729f700e 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -98,23 +98,21 @@ acpi_power_get_context(acpi_handle handle,
98 int result = 0; 98 int result = 0;
99 struct acpi_device *device = NULL; 99 struct acpi_device *device = NULL;
100 100
101 ACPI_FUNCTION_TRACE("acpi_power_get_context");
102 101
103 if (!resource) 102 if (!resource)
104 return_VALUE(-ENODEV); 103 return -ENODEV;
105 104
106 result = acpi_bus_get_device(handle, &device); 105 result = acpi_bus_get_device(handle, &device);
107 if (result) { 106 if (result) {
108 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n", 107 printk(KERN_WARNING PREFIX "Getting context [%p]\n", handle);
109 handle)); 108 return result;
110 return_VALUE(result);
111 } 109 }
112 110
113 *resource = (struct acpi_power_resource *)acpi_driver_data(device); 111 *resource = (struct acpi_power_resource *)acpi_driver_data(device);
114 if (!resource) 112 if (!resource)
115 return_VALUE(-ENODEV); 113 return -ENODEV;
116 114
117 return_VALUE(0); 115 return 0;
118} 116}
119 117
120static int acpi_power_get_state(struct acpi_power_resource *resource) 118static int acpi_power_get_state(struct acpi_power_resource *resource)
@@ -122,14 +120,13 @@ static int acpi_power_get_state(struct acpi_power_resource *resource)
122 acpi_status status = AE_OK; 120 acpi_status status = AE_OK;
123 unsigned long sta = 0; 121 unsigned long sta = 0;
124 122
125 ACPI_FUNCTION_TRACE("acpi_power_get_state");
126 123
127 if (!resource) 124 if (!resource)
128 return_VALUE(-EINVAL); 125 return -EINVAL;
129 126
130 status = acpi_evaluate_integer(resource->handle, "_STA", NULL, &sta); 127 status = acpi_evaluate_integer(resource->handle, "_STA", NULL, &sta);
131 if (ACPI_FAILURE(status)) 128 if (ACPI_FAILURE(status))
132 return_VALUE(-ENODEV); 129 return -ENODEV;
133 130
134 if (sta & 0x01) 131 if (sta & 0x01)
135 resource->state = ACPI_POWER_RESOURCE_STATE_ON; 132 resource->state = ACPI_POWER_RESOURCE_STATE_ON;
@@ -139,7 +136,7 @@ static int acpi_power_get_state(struct acpi_power_resource *resource)
139 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", 136 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
140 resource->name, resource->state ? "on" : "off")); 137 resource->name, resource->state ? "on" : "off"));
141 138
142 return_VALUE(0); 139 return 0;
143} 140}
144 141
145static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) 142static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
@@ -148,20 +145,19 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
148 struct acpi_power_resource *resource = NULL; 145 struct acpi_power_resource *resource = NULL;
149 u32 i = 0; 146 u32 i = 0;
150 147
151 ACPI_FUNCTION_TRACE("acpi_power_get_list_state");
152 148
153 if (!list || !state) 149 if (!list || !state)
154 return_VALUE(-EINVAL); 150 return -EINVAL;
155 151
156 /* The state of the list is 'on' IFF all resources are 'on'. */ 152 /* The state of the list is 'on' IFF all resources are 'on'. */
157 153
158 for (i = 0; i < list->count; i++) { 154 for (i = 0; i < list->count; i++) {
159 result = acpi_power_get_context(list->handles[i], &resource); 155 result = acpi_power_get_context(list->handles[i], &resource);
160 if (result) 156 if (result)
161 return_VALUE(result); 157 return result;
162 result = acpi_power_get_state(resource); 158 result = acpi_power_get_state(resource);
163 if (result) 159 if (result)
164 return_VALUE(result); 160 return result;
165 161
166 *state = resource->state; 162 *state = resource->state;
167 163
@@ -172,7 +168,7 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
172 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n", 168 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n",
173 *state ? "on" : "off")); 169 *state ? "on" : "off"));
174 170
175 return_VALUE(result); 171 return result;
176} 172}
177 173
178static int acpi_power_on(acpi_handle handle) 174static int acpi_power_on(acpi_handle handle)
@@ -182,11 +178,10 @@ static int acpi_power_on(acpi_handle handle)
182 struct acpi_device *device = NULL; 178 struct acpi_device *device = NULL;
183 struct acpi_power_resource *resource = NULL; 179 struct acpi_power_resource *resource = NULL;
184 180
185 ACPI_FUNCTION_TRACE("acpi_power_on");
186 181
187 result = acpi_power_get_context(handle, &resource); 182 result = acpi_power_get_context(handle, &resource);
188 if (result) 183 if (result)
189 return_VALUE(result); 184 return result;
190 185
191 resource->references++; 186 resource->references++;
192 187
@@ -194,29 +189,29 @@ static int acpi_power_on(acpi_handle handle)
194 || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) { 189 || (resource->state == ACPI_POWER_RESOURCE_STATE_ON)) {
195 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n", 190 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already on\n",
196 resource->name)); 191 resource->name));
197 return_VALUE(0); 192 return 0;
198 } 193 }
199 194
200 status = acpi_evaluate_object(resource->handle, "_ON", NULL, NULL); 195 status = acpi_evaluate_object(resource->handle, "_ON", NULL, NULL);
201 if (ACPI_FAILURE(status)) 196 if (ACPI_FAILURE(status))
202 return_VALUE(-ENODEV); 197 return -ENODEV;
203 198
204 result = acpi_power_get_state(resource); 199 result = acpi_power_get_state(resource);
205 if (result) 200 if (result)
206 return_VALUE(result); 201 return result;
207 if (resource->state != ACPI_POWER_RESOURCE_STATE_ON) 202 if (resource->state != ACPI_POWER_RESOURCE_STATE_ON)
208 return_VALUE(-ENOEXEC); 203 return -ENOEXEC;
209 204
210 /* Update the power resource's _device_ power state */ 205 /* Update the power resource's _device_ power state */
211 result = acpi_bus_get_device(resource->handle, &device); 206 result = acpi_bus_get_device(resource->handle, &device);
212 if (result) 207 if (result)
213 return_VALUE(result); 208 return result;
214 device->power.state = ACPI_STATE_D0; 209 device->power.state = ACPI_STATE_D0;
215 210
216 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n", 211 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned on\n",
217 resource->name)); 212 resource->name));
218 213
219 return_VALUE(0); 214 return 0;
220} 215}
221 216
222static int acpi_power_off_device(acpi_handle handle) 217static int acpi_power_off_device(acpi_handle handle)
@@ -226,11 +221,10 @@ static int acpi_power_off_device(acpi_handle handle)
226 struct acpi_device *device = NULL; 221 struct acpi_device *device = NULL;
227 struct acpi_power_resource *resource = NULL; 222 struct acpi_power_resource *resource = NULL;
228 223
229 ACPI_FUNCTION_TRACE("acpi_power_off_device");
230 224
231 result = acpi_power_get_context(handle, &resource); 225 result = acpi_power_get_context(handle, &resource);
232 if (result) 226 if (result)
233 return_VALUE(result); 227 return result;
234 228
235 if (resource->references) 229 if (resource->references)
236 resource->references--; 230 resource->references--;
@@ -239,35 +233,35 @@ static int acpi_power_off_device(acpi_handle handle)
239 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 233 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
240 "Resource [%s] is still in use, dereferencing\n", 234 "Resource [%s] is still in use, dereferencing\n",
241 device->pnp.bus_id)); 235 device->pnp.bus_id));
242 return_VALUE(0); 236 return 0;
243 } 237 }
244 238
245 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) { 239 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) {
246 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n", 240 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n",
247 device->pnp.bus_id)); 241 device->pnp.bus_id));
248 return_VALUE(0); 242 return 0;
249 } 243 }
250 244
251 status = acpi_evaluate_object(resource->handle, "_OFF", NULL, NULL); 245 status = acpi_evaluate_object(resource->handle, "_OFF", NULL, NULL);
252 if (ACPI_FAILURE(status)) 246 if (ACPI_FAILURE(status))
253 return_VALUE(-ENODEV); 247 return -ENODEV;
254 248
255 result = acpi_power_get_state(resource); 249 result = acpi_power_get_state(resource);
256 if (result) 250 if (result)
257 return_VALUE(result); 251 return result;
258 if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF) 252 if (resource->state != ACPI_POWER_RESOURCE_STATE_OFF)
259 return_VALUE(-ENOEXEC); 253 return -ENOEXEC;
260 254
261 /* Update the power resource's _device_ power state */ 255 /* Update the power resource's _device_ power state */
262 result = acpi_bus_get_device(resource->handle, &device); 256 result = acpi_bus_get_device(resource->handle, &device);
263 if (result) 257 if (result)
264 return_VALUE(result); 258 return result;
265 device->power.state = ACPI_STATE_D3; 259 device->power.state = ACPI_STATE_D3;
266 260
267 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", 261 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n",
268 resource->name)); 262 resource->name));
269 263
270 return_VALUE(0); 264 return 0;
271} 265}
272 266
273/* 267/*
@@ -283,31 +277,29 @@ int acpi_enable_wakeup_device_power(struct acpi_device *dev)
283 int i; 277 int i;
284 int ret = 0; 278 int ret = 0;
285 279
286 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_power");
287 if (!dev || !dev->wakeup.flags.valid) 280 if (!dev || !dev->wakeup.flags.valid)
288 return_VALUE(-1); 281 return -1;
289 282
290 arg.integer.value = 1; 283 arg.integer.value = 1;
291 /* Open power resource */ 284 /* Open power resource */
292 for (i = 0; i < dev->wakeup.resources.count; i++) { 285 for (i = 0; i < dev->wakeup.resources.count; i++) {
293 ret = acpi_power_on(dev->wakeup.resources.handles[i]); 286 ret = acpi_power_on(dev->wakeup.resources.handles[i]);
294 if (ret) { 287 if (ret) {
295 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 288 printk(KERN_ERR PREFIX "Transition power state\n");
296 "Error transition power state\n"));
297 dev->wakeup.flags.valid = 0; 289 dev->wakeup.flags.valid = 0;
298 return_VALUE(-1); 290 return -1;
299 } 291 }
300 } 292 }
301 293
302 /* Execute PSW */ 294 /* Execute PSW */
303 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL); 295 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL);
304 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 296 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
305 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n")); 297 printk(KERN_ERR PREFIX "Evaluate _PSW\n");
306 dev->wakeup.flags.valid = 0; 298 dev->wakeup.flags.valid = 0;
307 ret = -1; 299 ret = -1;
308 } 300 }
309 301
310 return_VALUE(ret); 302 return ret;
311} 303}
312 304
313/* 305/*
@@ -323,32 +315,30 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
323 int i; 315 int i;
324 int ret = 0; 316 int ret = 0;
325 317
326 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device_power");
327 318
328 if (!dev || !dev->wakeup.flags.valid) 319 if (!dev || !dev->wakeup.flags.valid)
329 return_VALUE(-1); 320 return -1;
330 321
331 arg.integer.value = 0; 322 arg.integer.value = 0;
332 /* Execute PSW */ 323 /* Execute PSW */
333 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL); 324 status = acpi_evaluate_object(dev->handle, "_PSW", &arg_list, NULL);
334 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 325 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
335 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluate _PSW\n")); 326 printk(KERN_ERR PREFIX "Evaluate _PSW\n");
336 dev->wakeup.flags.valid = 0; 327 dev->wakeup.flags.valid = 0;
337 return_VALUE(-1); 328 return -1;
338 } 329 }
339 330
340 /* Close power resource */ 331 /* Close power resource */
341 for (i = 0; i < dev->wakeup.resources.count; i++) { 332 for (i = 0; i < dev->wakeup.resources.count; i++) {
342 ret = acpi_power_off_device(dev->wakeup.resources.handles[i]); 333 ret = acpi_power_off_device(dev->wakeup.resources.handles[i]);
343 if (ret) { 334 if (ret) {
344 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 335 printk(KERN_ERR PREFIX "Transition power state\n");
345 "Error transition power state\n"));
346 dev->wakeup.flags.valid = 0; 336 dev->wakeup.flags.valid = 0;
347 return_VALUE(-1); 337 return -1;
348 } 338 }
349 } 339 }
350 340
351 return_VALUE(ret); 341 return ret;
352} 342}
353 343
354/* -------------------------------------------------------------------------- 344/* --------------------------------------------------------------------------
@@ -362,10 +352,9 @@ int acpi_power_get_inferred_state(struct acpi_device *device)
362 int list_state = 0; 352 int list_state = 0;
363 int i = 0; 353 int i = 0;
364 354
365 ACPI_FUNCTION_TRACE("acpi_power_get_inferred_state");
366 355
367 if (!device) 356 if (!device)
368 return_VALUE(-EINVAL); 357 return -EINVAL;
369 358
370 device->power.state = ACPI_STATE_UNKNOWN; 359 device->power.state = ACPI_STATE_UNKNOWN;
371 360
@@ -380,17 +369,17 @@ int acpi_power_get_inferred_state(struct acpi_device *device)
380 369
381 result = acpi_power_get_list_state(list, &list_state); 370 result = acpi_power_get_list_state(list, &list_state);
382 if (result) 371 if (result)
383 return_VALUE(result); 372 return result;
384 373
385 if (list_state == ACPI_POWER_RESOURCE_STATE_ON) { 374 if (list_state == ACPI_POWER_RESOURCE_STATE_ON) {
386 device->power.state = i; 375 device->power.state = i;
387 return_VALUE(0); 376 return 0;
388 } 377 }
389 } 378 }
390 379
391 device->power.state = ACPI_STATE_D3; 380 device->power.state = ACPI_STATE_D3;
392 381
393 return_VALUE(0); 382 return 0;
394} 383}
395 384
396int acpi_power_transition(struct acpi_device *device, int state) 385int acpi_power_transition(struct acpi_device *device, int state)
@@ -400,14 +389,13 @@ int acpi_power_transition(struct acpi_device *device, int state)
400 struct acpi_handle_list *tl = NULL; /* Target Resources */ 389 struct acpi_handle_list *tl = NULL; /* Target Resources */
401 int i = 0; 390 int i = 0;
402 391
403 ACPI_FUNCTION_TRACE("acpi_power_transition");
404 392
405 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) 393 if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
406 return_VALUE(-EINVAL); 394 return -EINVAL;
407 395
408 if ((device->power.state < ACPI_STATE_D0) 396 if ((device->power.state < ACPI_STATE_D0)
409 || (device->power.state > ACPI_STATE_D3)) 397 || (device->power.state > ACPI_STATE_D3))
410 return_VALUE(-ENODEV); 398 return -ENODEV;
411 399
412 cl = &device->power.states[device->power.state].resources; 400 cl = &device->power.states[device->power.state].resources;
413 tl = &device->power.states[state].resources; 401 tl = &device->power.states[state].resources;
@@ -444,11 +432,10 @@ int acpi_power_transition(struct acpi_device *device, int state)
444 device->power.state = state; 432 device->power.state = state;
445 end: 433 end:
446 if (result) 434 if (result)
447 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 435 printk(KERN_WARNING PREFIX "Transitioning device [%s] to D%d\n",
448 "Error transitioning device [%s] to D%d\n", 436 device->pnp.bus_id, state);
449 device->pnp.bus_id, state));
450 437
451 return_VALUE(result); 438 return result;
452} 439}
453 440
454/* -------------------------------------------------------------------------- 441/* --------------------------------------------------------------------------
@@ -461,7 +448,6 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
461{ 448{
462 struct acpi_power_resource *resource = NULL; 449 struct acpi_power_resource *resource = NULL;
463 450
464 ACPI_FUNCTION_TRACE("acpi_power_seq_show");
465 451
466 resource = (struct acpi_power_resource *)seq->private; 452 resource = (struct acpi_power_resource *)seq->private;
467 453
@@ -488,7 +474,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
488 resource->order, resource->references); 474 resource->order, resource->references);
489 475
490 end: 476 end:
491 return_VALUE(0); 477 return 0;
492} 478}
493 479
494static int acpi_power_open_fs(struct inode *inode, struct file *file) 480static int acpi_power_open_fs(struct inode *inode, struct file *file)
@@ -500,36 +486,32 @@ static int acpi_power_add_fs(struct acpi_device *device)
500{ 486{
501 struct proc_dir_entry *entry = NULL; 487 struct proc_dir_entry *entry = NULL;
502 488
503 ACPI_FUNCTION_TRACE("acpi_power_add_fs");
504 489
505 if (!device) 490 if (!device)
506 return_VALUE(-EINVAL); 491 return -EINVAL;
507 492
508 if (!acpi_device_dir(device)) { 493 if (!acpi_device_dir(device)) {
509 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 494 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
510 acpi_power_dir); 495 acpi_power_dir);
511 if (!acpi_device_dir(device)) 496 if (!acpi_device_dir(device))
512 return_VALUE(-ENODEV); 497 return -ENODEV;
513 } 498 }
514 499
515 /* 'status' [R] */ 500 /* 'status' [R] */
516 entry = create_proc_entry(ACPI_POWER_FILE_STATUS, 501 entry = create_proc_entry(ACPI_POWER_FILE_STATUS,
517 S_IRUGO, acpi_device_dir(device)); 502 S_IRUGO, acpi_device_dir(device));
518 if (!entry) 503 if (!entry)
519 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 504 return -EIO;
520 "Unable to create '%s' fs entry\n",
521 ACPI_POWER_FILE_STATUS));
522 else { 505 else {
523 entry->proc_fops = &acpi_power_fops; 506 entry->proc_fops = &acpi_power_fops;
524 entry->data = acpi_driver_data(device); 507 entry->data = acpi_driver_data(device);
525 } 508 }
526 509
527 return_VALUE(0); 510 return 0;
528} 511}
529 512
530static int acpi_power_remove_fs(struct acpi_device *device) 513static int acpi_power_remove_fs(struct acpi_device *device)
531{ 514{
532 ACPI_FUNCTION_TRACE("acpi_power_remove_fs");
533 515
534 if (acpi_device_dir(device)) { 516 if (acpi_device_dir(device)) {
535 remove_proc_entry(ACPI_POWER_FILE_STATUS, 517 remove_proc_entry(ACPI_POWER_FILE_STATUS,
@@ -538,7 +520,7 @@ static int acpi_power_remove_fs(struct acpi_device *device)
538 acpi_device_dir(device) = NULL; 520 acpi_device_dir(device) = NULL;
539 } 521 }
540 522
541 return_VALUE(0); 523 return 0;
542} 524}
543 525
544/* -------------------------------------------------------------------------- 526/* --------------------------------------------------------------------------
@@ -553,14 +535,13 @@ static int acpi_power_add(struct acpi_device *device)
553 union acpi_object acpi_object; 535 union acpi_object acpi_object;
554 struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object }; 536 struct acpi_buffer buffer = { sizeof(acpi_object), &acpi_object };
555 537
556 ACPI_FUNCTION_TRACE("acpi_power_add");
557 538
558 if (!device) 539 if (!device)
559 return_VALUE(-EINVAL); 540 return -EINVAL;
560 541
561 resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL); 542 resource = kmalloc(sizeof(struct acpi_power_resource), GFP_KERNEL);
562 if (!resource) 543 if (!resource)
563 return_VALUE(-ENOMEM); 544 return -ENOMEM;
564 memset(resource, 0, sizeof(struct acpi_power_resource)); 545 memset(resource, 0, sizeof(struct acpi_power_resource));
565 546
566 resource->handle = device->handle; 547 resource->handle = device->handle;
@@ -605,17 +586,16 @@ static int acpi_power_add(struct acpi_device *device)
605 if (result) 586 if (result)
606 kfree(resource); 587 kfree(resource);
607 588
608 return_VALUE(result); 589 return result;
609} 590}
610 591
611static int acpi_power_remove(struct acpi_device *device, int type) 592static int acpi_power_remove(struct acpi_device *device, int type)
612{ 593{
613 struct acpi_power_resource *resource = NULL; 594 struct acpi_power_resource *resource = NULL;
614 595
615 ACPI_FUNCTION_TRACE("acpi_power_remove");
616 596
617 if (!device || !acpi_driver_data(device)) 597 if (!device || !acpi_driver_data(device))
618 return_VALUE(-EINVAL); 598 return -EINVAL;
619 599
620 resource = (struct acpi_power_resource *)acpi_driver_data(device); 600 resource = (struct acpi_power_resource *)acpi_driver_data(device);
621 601
@@ -623,31 +603,30 @@ static int acpi_power_remove(struct acpi_device *device, int type)
623 603
624 kfree(resource); 604 kfree(resource);
625 605
626 return_VALUE(0); 606 return 0;
627} 607}
628 608
629static int __init acpi_power_init(void) 609static int __init acpi_power_init(void)
630{ 610{
631 int result = 0; 611 int result = 0;
632 612
633 ACPI_FUNCTION_TRACE("acpi_power_init");
634 613
635 if (acpi_disabled) 614 if (acpi_disabled)
636 return_VALUE(0); 615 return 0;
637 616
638 INIT_LIST_HEAD(&acpi_power_resource_list); 617 INIT_LIST_HEAD(&acpi_power_resource_list);
639 618
640 acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir); 619 acpi_power_dir = proc_mkdir(ACPI_POWER_CLASS, acpi_root_dir);
641 if (!acpi_power_dir) 620 if (!acpi_power_dir)
642 return_VALUE(-ENODEV); 621 return -ENODEV;
643 622
644 result = acpi_bus_register_driver(&acpi_power_driver); 623 result = acpi_bus_register_driver(&acpi_power_driver);
645 if (result < 0) { 624 if (result < 0) {
646 remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir); 625 remove_proc_entry(ACPI_POWER_CLASS, acpi_root_dir);
647 return_VALUE(-ENODEV); 626 return -ENODEV;
648 } 627 }
649 628
650 return_VALUE(0); 629 return 0;
651} 630}
652 631
653subsys_initcall(acpi_power_init); 632subsys_initcall(acpi_power_init);
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index decaebb4cbe9..52674323b14d 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -122,10 +122,9 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
122 u8 value1 = 0; 122 u8 value1 = 0;
123 u8 value2 = 0; 123 u8 value2 = 0;
124 124
125 ACPI_FUNCTION_TRACE("acpi_processor_errata_piix4");
126 125
127 if (!dev) 126 if (!dev)
128 return_VALUE(-EINVAL); 127 return -EINVAL;
129 128
130 /* 129 /*
131 * Note that 'dev' references the PIIX4 ACPI Controller. 130 * Note that 'dev' references the PIIX4 ACPI Controller.
@@ -218,7 +217,7 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
218 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 217 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
219 "Type-F DMA livelock erratum (C3 disabled)\n")); 218 "Type-F DMA livelock erratum (C3 disabled)\n"));
220 219
221 return_VALUE(0); 220 return 0;
222} 221}
223 222
224static int acpi_processor_errata(struct acpi_processor *pr) 223static int acpi_processor_errata(struct acpi_processor *pr)
@@ -226,10 +225,9 @@ static int acpi_processor_errata(struct acpi_processor *pr)
226 int result = 0; 225 int result = 0;
227 struct pci_dev *dev = NULL; 226 struct pci_dev *dev = NULL;
228 227
229 ACPI_FUNCTION_TRACE("acpi_processor_errata");
230 228
231 if (!pr) 229 if (!pr)
232 return_VALUE(-EINVAL); 230 return -EINVAL;
233 231
234 /* 232 /*
235 * PIIX4 233 * PIIX4
@@ -242,7 +240,7 @@ static int acpi_processor_errata(struct acpi_processor *pr)
242 pci_dev_put(dev); 240 pci_dev_put(dev);
243 } 241 }
244 242
245 return_VALUE(result); 243 return result;
246} 244}
247 245
248/* -------------------------------------------------------------------------- 246/* --------------------------------------------------------------------------
@@ -258,10 +256,9 @@ static int acpi_processor_set_pdc(struct acpi_processor *pr)
258 struct acpi_object_list *pdc_in = pr->pdc; 256 struct acpi_object_list *pdc_in = pr->pdc;
259 acpi_status status = AE_OK; 257 acpi_status status = AE_OK;
260 258
261 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
262 259
263 if (!pdc_in) 260 if (!pdc_in)
264 return_VALUE(status); 261 return status;
265 262
266 status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL); 263 status = acpi_evaluate_object(pr->handle, "_PDC", pdc_in, NULL);
267 264
@@ -269,7 +266,7 @@ static int acpi_processor_set_pdc(struct acpi_processor *pr)
269 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 266 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
270 "Could not evaluate _PDC, using legacy perf. control...\n")); 267 "Could not evaluate _PDC, using legacy perf. control...\n"));
271 268
272 return_VALUE(status); 269 return status;
273} 270}
274 271
275/* -------------------------------------------------------------------------- 272/* --------------------------------------------------------------------------
@@ -282,7 +279,6 @@ static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
282{ 279{
283 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 280 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
284 281
285 ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show");
286 282
287 if (!pr) 283 if (!pr)
288 goto end; 284 goto end;
@@ -301,7 +297,7 @@ static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
301 pr->flags.limit ? "yes" : "no"); 297 pr->flags.limit ? "yes" : "no");
302 298
303 end: 299 end:
304 return_VALUE(0); 300 return 0;
305} 301}
306 302
307static int acpi_processor_info_open_fs(struct inode *inode, struct file *file) 303static int acpi_processor_info_open_fs(struct inode *inode, struct file *file)
@@ -314,13 +310,12 @@ static int acpi_processor_add_fs(struct acpi_device *device)
314{ 310{
315 struct proc_dir_entry *entry = NULL; 311 struct proc_dir_entry *entry = NULL;
316 312
317 ACPI_FUNCTION_TRACE("acpi_processor_add_fs");
318 313
319 if (!acpi_device_dir(device)) { 314 if (!acpi_device_dir(device)) {
320 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 315 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
321 acpi_processor_dir); 316 acpi_processor_dir);
322 if (!acpi_device_dir(device)) 317 if (!acpi_device_dir(device))
323 return_VALUE(-ENODEV); 318 return -ENODEV;
324 } 319 }
325 acpi_device_dir(device)->owner = THIS_MODULE; 320 acpi_device_dir(device)->owner = THIS_MODULE;
326 321
@@ -328,9 +323,7 @@ static int acpi_processor_add_fs(struct acpi_device *device)
328 entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO, 323 entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO,
329 S_IRUGO, acpi_device_dir(device)); 324 S_IRUGO, acpi_device_dir(device));
330 if (!entry) 325 if (!entry)
331 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 326 return -EIO;
332 "Unable to create '%s' fs entry\n",
333 ACPI_PROCESSOR_FILE_INFO));
334 else { 327 else {
335 entry->proc_fops = &acpi_processor_info_fops; 328 entry->proc_fops = &acpi_processor_info_fops;
336 entry->data = acpi_driver_data(device); 329 entry->data = acpi_driver_data(device);
@@ -342,9 +335,7 @@ static int acpi_processor_add_fs(struct acpi_device *device)
342 S_IFREG | S_IRUGO | S_IWUSR, 335 S_IFREG | S_IRUGO | S_IWUSR,
343 acpi_device_dir(device)); 336 acpi_device_dir(device));
344 if (!entry) 337 if (!entry)
345 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 338 return -EIO;
346 "Unable to create '%s' fs entry\n",
347 ACPI_PROCESSOR_FILE_THROTTLING));
348 else { 339 else {
349 entry->proc_fops = &acpi_processor_throttling_fops; 340 entry->proc_fops = &acpi_processor_throttling_fops;
350 entry->data = acpi_driver_data(device); 341 entry->data = acpi_driver_data(device);
@@ -356,21 +347,18 @@ static int acpi_processor_add_fs(struct acpi_device *device)
356 S_IFREG | S_IRUGO | S_IWUSR, 347 S_IFREG | S_IRUGO | S_IWUSR,
357 acpi_device_dir(device)); 348 acpi_device_dir(device));
358 if (!entry) 349 if (!entry)
359 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 350 return -EIO;
360 "Unable to create '%s' fs entry\n",
361 ACPI_PROCESSOR_FILE_LIMIT));
362 else { 351 else {
363 entry->proc_fops = &acpi_processor_limit_fops; 352 entry->proc_fops = &acpi_processor_limit_fops;
364 entry->data = acpi_driver_data(device); 353 entry->data = acpi_driver_data(device);
365 entry->owner = THIS_MODULE; 354 entry->owner = THIS_MODULE;
366 } 355 }
367 356
368 return_VALUE(0); 357 return 0;
369} 358}
370 359
371static int acpi_processor_remove_fs(struct acpi_device *device) 360static int acpi_processor_remove_fs(struct acpi_device *device)
372{ 361{
373 ACPI_FUNCTION_TRACE("acpi_processor_remove_fs");
374 362
375 if (acpi_device_dir(device)) { 363 if (acpi_device_dir(device)) {
376 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO, 364 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,
@@ -383,7 +371,7 @@ static int acpi_processor_remove_fs(struct acpi_device *device)
383 acpi_device_dir(device) = NULL; 371 acpi_device_dir(device) = NULL;
384 } 372 }
385 373
386 return_VALUE(0); 374 return 0;
387} 375}
388 376
389/* Use the acpiid in MADT to map cpus in case of SMP */ 377/* Use the acpiid in MADT to map cpus in case of SMP */
@@ -430,10 +418,9 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
430 int cpu_index; 418 int cpu_index;
431 static int cpu0_initialized; 419 static int cpu0_initialized;
432 420
433 ACPI_FUNCTION_TRACE("acpi_processor_get_info");
434 421
435 if (!pr) 422 if (!pr)
436 return_VALUE(-EINVAL); 423 return -EINVAL;
437 424
438 if (num_online_cpus() > 1) 425 if (num_online_cpus() > 1)
439 errata.smp = TRUE; 426 errata.smp = TRUE;
@@ -459,9 +446,8 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
459 */ 446 */
460 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); 447 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
461 if (ACPI_FAILURE(status)) { 448 if (ACPI_FAILURE(status)) {
462 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 449 printk(KERN_ERR PREFIX "Evaluating processor object\n");
463 "Error evaluating processor object\n")); 450 return -ENODEV;
464 return_VALUE(-ENODEV);
465 } 451 }
466 452
467 /* 453 /*
@@ -490,10 +476,10 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
490 if (cpu_index == -1) { 476 if (cpu_index == -1) {
491 if (ACPI_FAILURE 477 if (ACPI_FAILURE
492 (acpi_processor_hotadd_init(pr->handle, &pr->id))) { 478 (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
493 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 479 printk(KERN_ERR PREFIX
494 "Error getting cpuindex for acpiid 0x%x\n", 480 "Getting cpuindex for acpiid 0x%x\n",
495 pr->acpi_id)); 481 pr->acpi_id);
496 return_VALUE(-ENODEV); 482 return -ENODEV;
497 } 483 }
498 } 484 }
499 485
@@ -503,8 +489,8 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
503 if (!object.processor.pblk_address) 489 if (!object.processor.pblk_address)
504 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); 490 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
505 else if (object.processor.pblk_length != 6) 491 else if (object.processor.pblk_length != 6)
506 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n", 492 printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n",
507 object.processor.pblk_length)); 493 object.processor.pblk_length);
508 else { 494 else {
509 pr->throttling.address = object.processor.pblk_address; 495 pr->throttling.address = object.processor.pblk_address;
510 pr->throttling.duty_offset = acpi_fadt.duty_offset; 496 pr->throttling.duty_offset = acpi_fadt.duty_offset;
@@ -528,7 +514,7 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
528 acpi_processor_get_throttling_info(pr); 514 acpi_processor_get_throttling_info(pr);
529 acpi_processor_get_limit_info(pr); 515 acpi_processor_get_limit_info(pr);
530 516
531 return_VALUE(0); 517 return 0;
532} 518}
533 519
534static void *processor_device_array[NR_CPUS]; 520static void *processor_device_array[NR_CPUS];
@@ -539,14 +525,13 @@ static int acpi_processor_start(struct acpi_device *device)
539 acpi_status status = AE_OK; 525 acpi_status status = AE_OK;
540 struct acpi_processor *pr; 526 struct acpi_processor *pr;
541 527
542 ACPI_FUNCTION_TRACE("acpi_processor_start");
543 528
544 pr = acpi_driver_data(device); 529 pr = acpi_driver_data(device);
545 530
546 result = acpi_processor_get_info(pr); 531 result = acpi_processor_get_info(pr);
547 if (result) { 532 if (result) {
548 /* Processor is physically not present */ 533 /* Processor is physically not present */
549 return_VALUE(0); 534 return 0;
550 } 535 }
551 536
552 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0)); 537 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0));
@@ -560,7 +545,7 @@ static int acpi_processor_start(struct acpi_device *device)
560 processor_device_array[pr->id] != (void *)device) { 545 processor_device_array[pr->id] != (void *)device) {
561 printk(KERN_WARNING "BIOS reported wrong ACPI id" 546 printk(KERN_WARNING "BIOS reported wrong ACPI id"
562 "for the processor\n"); 547 "for the processor\n");
563 return_VALUE(-ENODEV); 548 return -ENODEV;
564 } 549 }
565 processor_device_array[pr->id] = (void *)device; 550 processor_device_array[pr->id] = (void *)device;
566 551
@@ -572,10 +557,6 @@ static int acpi_processor_start(struct acpi_device *device)
572 557
573 status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, 558 status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
574 acpi_processor_notify, pr); 559 acpi_processor_notify, pr);
575 if (ACPI_FAILURE(status)) {
576 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
577 "Error installing device notify handler\n"));
578 }
579 560
580 /* _PDC call should be done before doing anything else (if reqd.). */ 561 /* _PDC call should be done before doing anything else (if reqd.). */
581 arch_acpi_processor_init_pdc(pr); 562 arch_acpi_processor_init_pdc(pr);
@@ -592,7 +573,7 @@ static int acpi_processor_start(struct acpi_device *device)
592 573
593 end: 574 end:
594 575
595 return_VALUE(result); 576 return result;
596} 577}
597 578
598static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) 579static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
@@ -600,13 +581,12 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
600 struct acpi_processor *pr = (struct acpi_processor *)data; 581 struct acpi_processor *pr = (struct acpi_processor *)data;
601 struct acpi_device *device = NULL; 582 struct acpi_device *device = NULL;
602 583
603 ACPI_FUNCTION_TRACE("acpi_processor_notify");
604 584
605 if (!pr) 585 if (!pr)
606 return_VOID; 586 return;
607 587
608 if (acpi_bus_get_device(pr->handle, &device)) 588 if (acpi_bus_get_device(pr->handle, &device))
609 return_VOID; 589 return;
610 590
611 switch (event) { 591 switch (event) {
612 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: 592 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
@@ -624,21 +604,20 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
624 break; 604 break;
625 } 605 }
626 606
627 return_VOID; 607 return;
628} 608}
629 609
630static int acpi_processor_add(struct acpi_device *device) 610static int acpi_processor_add(struct acpi_device *device)
631{ 611{
632 struct acpi_processor *pr = NULL; 612 struct acpi_processor *pr = NULL;
633 613
634 ACPI_FUNCTION_TRACE("acpi_processor_add");
635 614
636 if (!device) 615 if (!device)
637 return_VALUE(-EINVAL); 616 return -EINVAL;
638 617
639 pr = kmalloc(sizeof(struct acpi_processor), GFP_KERNEL); 618 pr = kmalloc(sizeof(struct acpi_processor), GFP_KERNEL);
640 if (!pr) 619 if (!pr)
641 return_VALUE(-ENOMEM); 620 return -ENOMEM;
642 memset(pr, 0, sizeof(struct acpi_processor)); 621 memset(pr, 0, sizeof(struct acpi_processor));
643 622
644 pr->handle = device->handle; 623 pr->handle = device->handle;
@@ -646,7 +625,7 @@ static int acpi_processor_add(struct acpi_device *device)
646 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); 625 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
647 acpi_driver_data(device) = pr; 626 acpi_driver_data(device) = pr;
648 627
649 return_VALUE(0); 628 return 0;
650} 629}
651 630
652static int acpi_processor_remove(struct acpi_device *device, int type) 631static int acpi_processor_remove(struct acpi_device *device, int type)
@@ -654,31 +633,26 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
654 acpi_status status = AE_OK; 633 acpi_status status = AE_OK;
655 struct acpi_processor *pr = NULL; 634 struct acpi_processor *pr = NULL;
656 635
657 ACPI_FUNCTION_TRACE("acpi_processor_remove");
658 636
659 if (!device || !acpi_driver_data(device)) 637 if (!device || !acpi_driver_data(device))
660 return_VALUE(-EINVAL); 638 return -EINVAL;
661 639
662 pr = (struct acpi_processor *)acpi_driver_data(device); 640 pr = (struct acpi_processor *)acpi_driver_data(device);
663 641
664 if (pr->id >= NR_CPUS) { 642 if (pr->id >= NR_CPUS) {
665 kfree(pr); 643 kfree(pr);
666 return_VALUE(0); 644 return 0;
667 } 645 }
668 646
669 if (type == ACPI_BUS_REMOVAL_EJECT) { 647 if (type == ACPI_BUS_REMOVAL_EJECT) {
670 if (acpi_processor_handle_eject(pr)) 648 if (acpi_processor_handle_eject(pr))
671 return_VALUE(-EINVAL); 649 return -EINVAL;
672 } 650 }
673 651
674 acpi_processor_power_exit(pr, device); 652 acpi_processor_power_exit(pr, device);
675 653
676 status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, 654 status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
677 acpi_processor_notify); 655 acpi_processor_notify);
678 if (ACPI_FAILURE(status)) {
679 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
680 "Error removing notify handler\n"));
681 }
682 656
683 acpi_processor_remove_fs(device); 657 acpi_processor_remove_fs(device);
684 658
@@ -686,7 +660,7 @@ static int acpi_processor_remove(struct acpi_device *device, int type)
686 660
687 kfree(pr); 661 kfree(pr);
688 662
689 return_VALUE(0); 663 return 0;
690} 664}
691 665
692#ifdef CONFIG_ACPI_HOTPLUG_CPU 666#ifdef CONFIG_ACPI_HOTPLUG_CPU
@@ -701,15 +675,13 @@ static int is_processor_present(acpi_handle handle)
701 acpi_status status; 675 acpi_status status;
702 unsigned long sta = 0; 676 unsigned long sta = 0;
703 677
704 ACPI_FUNCTION_TRACE("is_processor_present");
705 678
706 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 679 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
707 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) { 680 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) {
708 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 681 ACPI_EXCEPTION((AE_INFO, status, "Processor Device is not present"));
709 "Processor Device is not present\n")); 682 return 0;
710 return_VALUE(0);
711 } 683 }
712 return_VALUE(1); 684 return 1;
713} 685}
714 686
715static 687static
@@ -719,30 +691,29 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
719 struct acpi_device *pdev; 691 struct acpi_device *pdev;
720 struct acpi_processor *pr; 692 struct acpi_processor *pr;
721 693
722 ACPI_FUNCTION_TRACE("acpi_processor_device_add");
723 694
724 if (acpi_get_parent(handle, &phandle)) { 695 if (acpi_get_parent(handle, &phandle)) {
725 return_VALUE(-ENODEV); 696 return -ENODEV;
726 } 697 }
727 698
728 if (acpi_bus_get_device(phandle, &pdev)) { 699 if (acpi_bus_get_device(phandle, &pdev)) {
729 return_VALUE(-ENODEV); 700 return -ENODEV;
730 } 701 }
731 702
732 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) { 703 if (acpi_bus_add(device, pdev, handle, ACPI_BUS_TYPE_PROCESSOR)) {
733 return_VALUE(-ENODEV); 704 return -ENODEV;
734 } 705 }
735 706
736 acpi_bus_start(*device); 707 acpi_bus_start(*device);
737 708
738 pr = acpi_driver_data(*device); 709 pr = acpi_driver_data(*device);
739 if (!pr) 710 if (!pr)
740 return_VALUE(-ENODEV); 711 return -ENODEV;
741 712
742 if ((pr->id >= 0) && (pr->id < NR_CPUS)) { 713 if ((pr->id >= 0) && (pr->id < NR_CPUS)) {
743 kobject_uevent(&(*device)->kobj, KOBJ_ONLINE); 714 kobject_uevent(&(*device)->kobj, KOBJ_ONLINE);
744 } 715 }
745 return_VALUE(0); 716 return 0;
746} 717}
747 718
748static void 719static void
@@ -752,7 +723,6 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
752 struct acpi_device *device = NULL; 723 struct acpi_device *device = NULL;
753 int result; 724 int result;
754 725
755 ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify");
756 726
757 switch (event) { 727 switch (event) {
758 case ACPI_NOTIFY_BUS_CHECK: 728 case ACPI_NOTIFY_BUS_CHECK:
@@ -767,15 +737,14 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
767 if (acpi_bus_get_device(handle, &device)) { 737 if (acpi_bus_get_device(handle, &device)) {
768 result = acpi_processor_device_add(handle, &device); 738 result = acpi_processor_device_add(handle, &device);
769 if (result) 739 if (result)
770 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 740 printk(KERN_ERR PREFIX
771 "Unable to add the device\n")); 741 "Unable to add the device\n");
772 break; 742 break;
773 } 743 }
774 744
775 pr = acpi_driver_data(device); 745 pr = acpi_driver_data(device);
776 if (!pr) { 746 if (!pr) {
777 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 747 printk(KERN_ERR PREFIX "Driver data is NULL\n");
778 "Driver data is NULL\n"));
779 break; 748 break;
780 } 749 }
781 750
@@ -788,9 +757,8 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
788 if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) { 757 if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) {
789 kobject_uevent(&device->kobj, KOBJ_ONLINE); 758 kobject_uevent(&device->kobj, KOBJ_ONLINE);
790 } else { 759 } else {
791 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 760 printk(KERN_ERR PREFIX "Device [%s] failed to start\n",
792 "Device [%s] failed to start\n", 761 acpi_device_bid(device));
793 acpi_device_bid(device)));
794 } 762 }
795 break; 763 break;
796 case ACPI_NOTIFY_EJECT_REQUEST: 764 case ACPI_NOTIFY_EJECT_REQUEST:
@@ -798,15 +766,15 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
798 "received ACPI_NOTIFY_EJECT_REQUEST\n")); 766 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
799 767
800 if (acpi_bus_get_device(handle, &device)) { 768 if (acpi_bus_get_device(handle, &device)) {
801 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 769 printk(KERN_ERR PREFIX
802 "Device don't exist, dropping EJECT\n")); 770 "Device don't exist, dropping EJECT\n");
803 break; 771 break;
804 } 772 }
805 pr = acpi_driver_data(device); 773 pr = acpi_driver_data(device);
806 if (!pr) { 774 if (!pr) {
807 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 775 printk(KERN_ERR PREFIX
808 "Driver data is NULL, dropping EJECT\n")); 776 "Driver data is NULL, dropping EJECT\n");
809 return_VOID; 777 return;
810 } 778 }
811 779
812 if ((pr->id < NR_CPUS) && (cpu_present(pr->id))) 780 if ((pr->id < NR_CPUS) && (cpu_present(pr->id)))
@@ -818,7 +786,7 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
818 break; 786 break;
819 } 787 }
820 788
821 return_VOID; 789 return;
822} 790}
823 791
824static acpi_status 792static acpi_status
@@ -857,21 +825,20 @@ processor_walk_namespace_cb(acpi_handle handle,
857 825
858static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu) 826static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
859{ 827{
860 ACPI_FUNCTION_TRACE("acpi_processor_hotadd_init");
861 828
862 if (!is_processor_present(handle)) { 829 if (!is_processor_present(handle)) {
863 return_VALUE(AE_ERROR); 830 return AE_ERROR;
864 } 831 }
865 832
866 if (acpi_map_lsapic(handle, p_cpu)) 833 if (acpi_map_lsapic(handle, p_cpu))
867 return_VALUE(AE_ERROR); 834 return AE_ERROR;
868 835
869 if (arch_register_cpu(*p_cpu)) { 836 if (arch_register_cpu(*p_cpu)) {
870 acpi_unmap_lsapic(*p_cpu); 837 acpi_unmap_lsapic(*p_cpu);
871 return_VALUE(AE_ERROR); 838 return AE_ERROR;
872 } 839 }
873 840
874 return_VALUE(AE_OK); 841 return AE_OK;
875} 842}
876 843
877static int acpi_processor_handle_eject(struct acpi_processor *pr) 844static int acpi_processor_handle_eject(struct acpi_processor *pr)
@@ -928,20 +895,19 @@ static int __init acpi_processor_init(void)
928{ 895{
929 int result = 0; 896 int result = 0;
930 897
931 ACPI_FUNCTION_TRACE("acpi_processor_init");
932 898
933 memset(&processors, 0, sizeof(processors)); 899 memset(&processors, 0, sizeof(processors));
934 memset(&errata, 0, sizeof(errata)); 900 memset(&errata, 0, sizeof(errata));
935 901
936 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); 902 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir);
937 if (!acpi_processor_dir) 903 if (!acpi_processor_dir)
938 return_VALUE(0); 904 return 0;
939 acpi_processor_dir->owner = THIS_MODULE; 905 acpi_processor_dir->owner = THIS_MODULE;
940 906
941 result = acpi_bus_register_driver(&acpi_processor_driver); 907 result = acpi_bus_register_driver(&acpi_processor_driver);
942 if (result < 0) { 908 if (result < 0) {
943 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); 909 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
944 return_VALUE(0); 910 return 0;
945 } 911 }
946 912
947 acpi_processor_install_hotplug_notify(); 913 acpi_processor_install_hotplug_notify();
@@ -950,12 +916,11 @@ static int __init acpi_processor_init(void)
950 916
951 acpi_processor_ppc_init(); 917 acpi_processor_ppc_init();
952 918
953 return_VALUE(0); 919 return 0;
954} 920}
955 921
956static void __exit acpi_processor_exit(void) 922static void __exit acpi_processor_exit(void)
957{ 923{
958 ACPI_FUNCTION_TRACE("acpi_processor_exit");
959 924
960 acpi_processor_ppc_exit(); 925 acpi_processor_ppc_exit();
961 926
@@ -967,7 +932,7 @@ static void __exit acpi_processor_exit(void)
967 932
968 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir); 933 remove_proc_entry(ACPI_PROCESSOR_CLASS, acpi_root_dir);
969 934
970 return_VOID; 935 return;
971} 936}
972 937
973module_init(acpi_processor_init); 938module_init(acpi_processor_init);
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 8a74bf3efd8e..e439eb77d283 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> 4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de> 6 * Copyright (C) 2004, 2005 Dominik Brodowski <linux@brodo.de>
7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> 7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 * - Added processor hotplug support 8 * - Added processor hotplug support
9 * Copyright (C) 2005 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> 9 * Copyright (C) 2005 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
@@ -99,6 +99,9 @@ static int set_max_cstate(struct dmi_system_id *id)
99static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = { 99static struct dmi_system_id __cpuinitdata processor_power_dmi_table[] = {
100 { set_max_cstate, "IBM ThinkPad R40e", { 100 { set_max_cstate, "IBM ThinkPad R40e", {
101 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"), 101 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
102 DMI_MATCH(DMI_BIOS_VERSION,"1SET70WW")}, (void *)1},
103 { set_max_cstate, "IBM ThinkPad R40e", {
104 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
102 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW")}, (void *)1}, 105 DMI_MATCH(DMI_BIOS_VERSION,"1SET60WW")}, (void *)1},
103 { set_max_cstate, "IBM ThinkPad R40e", { 106 { set_max_cstate, "IBM ThinkPad R40e", {
104 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"), 107 DMI_MATCH(DMI_BIOS_VENDOR,"IBM"),
@@ -261,21 +264,15 @@ static void acpi_processor_idle(void)
261 u32 bm_status = 0; 264 u32 bm_status = 0;
262 unsigned long diff = jiffies - pr->power.bm_check_timestamp; 265 unsigned long diff = jiffies - pr->power.bm_check_timestamp;
263 266
264 if (diff > 32) 267 if (diff > 31)
265 diff = 32; 268 diff = 31;
266 269
267 while (diff) { 270 pr->power.bm_activity <<= diff;
268 /* if we didn't get called, assume there was busmaster activity */
269 diff--;
270 if (diff)
271 pr->power.bm_activity |= 0x1;
272 pr->power.bm_activity <<= 1;
273 }
274 271
275 acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS, 272 acpi_get_register(ACPI_BITREG_BUS_MASTER_STATUS,
276 &bm_status, ACPI_MTX_DO_NOT_LOCK); 273 &bm_status, ACPI_MTX_DO_NOT_LOCK);
277 if (bm_status) { 274 if (bm_status) {
278 pr->power.bm_activity++; 275 pr->power.bm_activity |= 0x1;
279 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS, 276 acpi_set_register(ACPI_BITREG_BUS_MASTER_STATUS,
280 1, ACPI_MTX_DO_NOT_LOCK); 277 1, ACPI_MTX_DO_NOT_LOCK);
281 } 278 }
@@ -287,16 +284,16 @@ static void acpi_processor_idle(void)
287 else if (errata.piix4.bmisx) { 284 else if (errata.piix4.bmisx) {
288 if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01) 285 if ((inb_p(errata.piix4.bmisx + 0x02) & 0x01)
289 || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01)) 286 || (inb_p(errata.piix4.bmisx + 0x0A) & 0x01))
290 pr->power.bm_activity++; 287 pr->power.bm_activity |= 0x1;
291 } 288 }
292 289
293 pr->power.bm_check_timestamp = jiffies; 290 pr->power.bm_check_timestamp = jiffies;
294 291
295 /* 292 /*
296 * Apply bus mastering demotion policy. Automatically demote 293 * If bus mastering is or was active this jiffy, demote
297 * to avoid a faulty transition. Note that the processor 294 * to avoid a faulty transition. Note that the processor
298 * won't enter a low-power state during this call (to this 295 * won't enter a low-power state during this call (to this
299 * funciton) but should upon the next. 296 * function) but should upon the next.
300 * 297 *
301 * TBD: A better policy might be to fallback to the demotion 298 * TBD: A better policy might be to fallback to the demotion
302 * state (use it for this quantum only) istead of 299 * state (use it for this quantum only) istead of
@@ -304,7 +301,8 @@ static void acpi_processor_idle(void)
304 * qualification. This may, however, introduce DMA 301 * qualification. This may, however, introduce DMA
305 * issues (e.g. floppy DMA transfer overrun/underrun). 302 * issues (e.g. floppy DMA transfer overrun/underrun).
306 */ 303 */
307 if (pr->power.bm_activity & cx->demotion.threshold.bm) { 304 if ((pr->power.bm_activity & 0x1) &&
305 cx->demotion.threshold.bm) {
308 local_irq_enable(); 306 local_irq_enable();
309 next_state = cx->demotion.state; 307 next_state = cx->demotion.state;
310 goto end; 308 goto end;
@@ -322,8 +320,6 @@ static void acpi_processor_idle(void)
322 cx = &pr->power.states[ACPI_STATE_C1]; 320 cx = &pr->power.states[ACPI_STATE_C1];
323#endif 321#endif
324 322
325 cx->usage++;
326
327 /* 323 /*
328 * Sleep: 324 * Sleep:
329 * ------ 325 * ------
@@ -365,7 +361,9 @@ static void acpi_processor_idle(void)
365 t1 = inl(acpi_fadt.xpm_tmr_blk.address); 361 t1 = inl(acpi_fadt.xpm_tmr_blk.address);
366 /* Invoke C2 */ 362 /* Invoke C2 */
367 inb(cx->address); 363 inb(cx->address);
368 /* Dummy op - must do something useless after P_LVL2 read */ 364 /* Dummy wait op - must do something useless after P_LVL2 read
365 because chipsets cannot guarantee that STPCLK# signal
366 gets asserted in time to freeze execution properly. */
369 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 367 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
370 /* Get end time (ticks) */ 368 /* Get end time (ticks) */
371 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 369 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
@@ -403,7 +401,7 @@ static void acpi_processor_idle(void)
403 t1 = inl(acpi_fadt.xpm_tmr_blk.address); 401 t1 = inl(acpi_fadt.xpm_tmr_blk.address);
404 /* Invoke C3 */ 402 /* Invoke C3 */
405 inb(cx->address); 403 inb(cx->address);
406 /* Dummy op - must do something useless after P_LVL3 read */ 404 /* Dummy wait op (see above) */
407 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 405 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
408 /* Get end time (ticks) */ 406 /* Get end time (ticks) */
409 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 407 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
@@ -430,6 +428,9 @@ static void acpi_processor_idle(void)
430 local_irq_enable(); 428 local_irq_enable();
431 return; 429 return;
432 } 430 }
431 cx->usage++;
432 if ((cx->type != ACPI_STATE_C1) && (sleep_ticks > 0))
433 cx->time += sleep_ticks;
433 434
434 next_state = pr->power.state; 435 next_state = pr->power.state;
435 436
@@ -517,10 +518,9 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr)
517 struct acpi_processor_cx *higher = NULL; 518 struct acpi_processor_cx *higher = NULL;
518 struct acpi_processor_cx *cx; 519 struct acpi_processor_cx *cx;
519 520
520 ACPI_FUNCTION_TRACE("acpi_processor_set_power_policy");
521 521
522 if (!pr) 522 if (!pr)
523 return_VALUE(-EINVAL); 523 return -EINVAL;
524 524
525 /* 525 /*
526 * This function sets the default Cx state policy (OS idle handler). 526 * This function sets the default Cx state policy (OS idle handler).
@@ -544,7 +544,7 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr)
544 } 544 }
545 545
546 if (!state_is_set) 546 if (!state_is_set)
547 return_VALUE(-ENODEV); 547 return -ENODEV;
548 548
549 /* demotion */ 549 /* demotion */
550 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { 550 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
@@ -583,18 +583,17 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr)
583 higher = cx; 583 higher = cx;
584 } 584 }
585 585
586 return_VALUE(0); 586 return 0;
587} 587}
588 588
589static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) 589static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
590{ 590{
591 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_fadt");
592 591
593 if (!pr) 592 if (!pr)
594 return_VALUE(-EINVAL); 593 return -EINVAL;
595 594
596 if (!pr->pblk) 595 if (!pr->pblk)
597 return_VALUE(-ENODEV); 596 return -ENODEV;
598 597
599 /* if info is obtained from pblk/fadt, type equals state */ 598 /* if info is obtained from pblk/fadt, type equals state */
600 pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2; 599 pr->power.states[ACPI_STATE_C2].type = ACPI_STATE_C2;
@@ -606,7 +605,7 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
606 * an SMP system. 605 * an SMP system.
607 */ 606 */
608 if ((num_online_cpus() > 1) && !acpi_fadt.plvl2_up) 607 if ((num_online_cpus() > 1) && !acpi_fadt.plvl2_up)
609 return_VALUE(-ENODEV); 608 return -ENODEV;
610#endif 609#endif
611 610
612 /* determine C2 and C3 address from pblk */ 611 /* determine C2 and C3 address from pblk */
@@ -622,12 +621,11 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
622 pr->power.states[ACPI_STATE_C2].address, 621 pr->power.states[ACPI_STATE_C2].address,
623 pr->power.states[ACPI_STATE_C3].address)); 622 pr->power.states[ACPI_STATE_C3].address));
624 623
625 return_VALUE(0); 624 return 0;
626} 625}
627 626
628static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr) 627static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr)
629{ 628{
630 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1");
631 629
632 /* Zero initialize all the C-states info. */ 630 /* Zero initialize all the C-states info. */
633 memset(pr->power.states, 0, sizeof(pr->power.states)); 631 memset(pr->power.states, 0, sizeof(pr->power.states));
@@ -640,7 +638,7 @@ static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr)
640 pr->power.states[ACPI_STATE_C0].valid = 1; 638 pr->power.states[ACPI_STATE_C0].valid = 1;
641 pr->power.states[ACPI_STATE_C1].valid = 1; 639 pr->power.states[ACPI_STATE_C1].valid = 1;
642 640
643 return_VALUE(0); 641 return 0;
644} 642}
645 643
646static int acpi_processor_get_power_info_cst(struct acpi_processor *pr) 644static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
@@ -652,10 +650,9 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
652 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 650 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
653 union acpi_object *cst; 651 union acpi_object *cst;
654 652
655 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_cst");
656 653
657 if (nocst) 654 if (nocst)
658 return_VALUE(-ENODEV); 655 return -ENODEV;
659 656
660 current_count = 1; 657 current_count = 1;
661 658
@@ -667,15 +664,14 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
667 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer); 664 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer);
668 if (ACPI_FAILURE(status)) { 665 if (ACPI_FAILURE(status)) {
669 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No _CST, giving up\n")); 666 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No _CST, giving up\n"));
670 return_VALUE(-ENODEV); 667 return -ENODEV;
671 } 668 }
672 669
673 cst = (union acpi_object *)buffer.pointer; 670 cst = (union acpi_object *)buffer.pointer;
674 671
675 /* There must be at least 2 elements */ 672 /* There must be at least 2 elements */
676 if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) { 673 if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) {
677 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 674 printk(KERN_ERR PREFIX "not enough elements in _CST\n");
678 "not enough elements in _CST\n"));
679 status = -EFAULT; 675 status = -EFAULT;
680 goto end; 676 goto end;
681 } 677 }
@@ -684,8 +680,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
684 680
685 /* Validate number of power states. */ 681 /* Validate number of power states. */
686 if (count < 1 || count != cst->package.count - 1) { 682 if (count < 1 || count != cst->package.count - 1) {
687 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 683 printk(KERN_ERR PREFIX "count given by _CST is not valid\n");
688 "count given by _CST is not valid\n"));
689 status = -EFAULT; 684 status = -EFAULT;
690 goto end; 685 goto end;
691 } 686 }
@@ -775,15 +770,14 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
775 end: 770 end:
776 acpi_os_free(buffer.pointer); 771 acpi_os_free(buffer.pointer);
777 772
778 return_VALUE(status); 773 return status;
779} 774}
780 775
781static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx) 776static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
782{ 777{
783 ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c2");
784 778
785 if (!cx->address) 779 if (!cx->address)
786 return_VOID; 780 return;
787 781
788 /* 782 /*
789 * C2 latency must be less than or equal to 100 783 * C2 latency must be less than or equal to 100
@@ -792,7 +786,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
792 else if (cx->latency > ACPI_PROCESSOR_MAX_C2_LATENCY) { 786 else if (cx->latency > ACPI_PROCESSOR_MAX_C2_LATENCY) {
793 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 787 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
794 "latency too large [%d]\n", cx->latency)); 788 "latency too large [%d]\n", cx->latency));
795 return_VOID; 789 return;
796 } 790 }
797 791
798 /* 792 /*
@@ -802,7 +796,7 @@ static void acpi_processor_power_verify_c2(struct acpi_processor_cx *cx)
802 cx->valid = 1; 796 cx->valid = 1;
803 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); 797 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
804 798
805 return_VOID; 799 return;
806} 800}
807 801
808static void acpi_processor_power_verify_c3(struct acpi_processor *pr, 802static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
@@ -810,10 +804,9 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
810{ 804{
811 static int bm_check_flag; 805 static int bm_check_flag;
812 806
813 ACPI_FUNCTION_TRACE("acpi_processor_get_power_verify_c3");
814 807
815 if (!cx->address) 808 if (!cx->address)
816 return_VOID; 809 return;
817 810
818 /* 811 /*
819 * C3 latency must be less than or equal to 1000 812 * C3 latency must be less than or equal to 1000
@@ -822,7 +815,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
822 else if (cx->latency > ACPI_PROCESSOR_MAX_C3_LATENCY) { 815 else if (cx->latency > ACPI_PROCESSOR_MAX_C3_LATENCY) {
823 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 816 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
824 "latency too large [%d]\n", cx->latency)); 817 "latency too large [%d]\n", cx->latency));
825 return_VOID; 818 return;
826 } 819 }
827 820
828 /* 821 /*
@@ -835,7 +828,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
835 else if (errata.piix4.fdma) { 828 else if (errata.piix4.fdma) {
836 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 829 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
837 "C3 not supported on PIIX4 with Type-F DMA\n")); 830 "C3 not supported on PIIX4 with Type-F DMA\n"));
838 return_VOID; 831 return;
839 } 832 }
840 833
841 /* All the logic here assumes flags.bm_check is same across all CPUs */ 834 /* All the logic here assumes flags.bm_check is same across all CPUs */
@@ -852,7 +845,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
852 if (!pr->flags.bm_control) { 845 if (!pr->flags.bm_control) {
853 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 846 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
854 "C3 support requires bus mastering control\n")); 847 "C3 support requires bus mastering control\n"));
855 return_VOID; 848 return;
856 } 849 }
857 } else { 850 } else {
858 /* 851 /*
@@ -863,7 +856,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
863 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 856 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
864 "Cache invalidation should work properly" 857 "Cache invalidation should work properly"
865 " for C3 to be enabled on SMP systems\n")); 858 " for C3 to be enabled on SMP systems\n"));
866 return_VOID; 859 return;
867 } 860 }
868 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD, 861 acpi_set_register(ACPI_BITREG_BUS_MASTER_RLD,
869 0, ACPI_MTX_DO_NOT_LOCK); 862 0, ACPI_MTX_DO_NOT_LOCK);
@@ -878,7 +871,7 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
878 cx->valid = 1; 871 cx->valid = 1;
879 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency); 872 cx->latency_ticks = US_TO_PM_TIMER_TICKS(cx->latency);
880 873
881 return_VOID; 874 return;
882} 875}
883 876
884static int acpi_processor_power_verify(struct acpi_processor *pr) 877static int acpi_processor_power_verify(struct acpi_processor *pr)
@@ -937,7 +930,6 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
937 unsigned int i; 930 unsigned int i;
938 int result; 931 int result;
939 932
940 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info");
941 933
942 /* NOTE: the idle thread may not be running while calling 934 /* NOTE: the idle thread may not be running while calling
943 * this function */ 935 * this function */
@@ -960,7 +952,7 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
960 */ 952 */
961 result = acpi_processor_set_power_policy(pr); 953 result = acpi_processor_set_power_policy(pr);
962 if (result) 954 if (result)
963 return_VALUE(result); 955 return result;
964 956
965 /* 957 /*
966 * if one state of type C2 or C3 is available, mark this 958 * if one state of type C2 or C3 is available, mark this
@@ -974,24 +966,23 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
974 } 966 }
975 } 967 }
976 968
977 return_VALUE(0); 969 return 0;
978} 970}
979 971
980int acpi_processor_cst_has_changed(struct acpi_processor *pr) 972int acpi_processor_cst_has_changed(struct acpi_processor *pr)
981{ 973{
982 int result = 0; 974 int result = 0;
983 975
984 ACPI_FUNCTION_TRACE("acpi_processor_cst_has_changed");
985 976
986 if (!pr) 977 if (!pr)
987 return_VALUE(-EINVAL); 978 return -EINVAL;
988 979
989 if (nocst) { 980 if (nocst) {
990 return_VALUE(-ENODEV); 981 return -ENODEV;
991 } 982 }
992 983
993 if (!pr->flags.power_setup_done) 984 if (!pr->flags.power_setup_done)
994 return_VALUE(-ENODEV); 985 return -ENODEV;
995 986
996 /* Fall back to the default idle loop */ 987 /* Fall back to the default idle loop */
997 pm_idle = pm_idle_save; 988 pm_idle = pm_idle_save;
@@ -1002,7 +993,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1002 if ((pr->flags.power == 1) && (pr->flags.power_setup_done)) 993 if ((pr->flags.power == 1) && (pr->flags.power_setup_done))
1003 pm_idle = acpi_processor_idle; 994 pm_idle = acpi_processor_idle;
1004 995
1005 return_VALUE(result); 996 return result;
1006} 997}
1007 998
1008/* proc interface */ 999/* proc interface */
@@ -1012,7 +1003,6 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
1012 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 1003 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
1013 unsigned int i; 1004 unsigned int i;
1014 1005
1015 ACPI_FUNCTION_TRACE("acpi_processor_power_seq_show");
1016 1006
1017 if (!pr) 1007 if (!pr)
1018 goto end; 1008 goto end;
@@ -1064,13 +1054,14 @@ static int acpi_processor_power_seq_show(struct seq_file *seq, void *offset)
1064 else 1054 else
1065 seq_puts(seq, "demotion[--] "); 1055 seq_puts(seq, "demotion[--] ");
1066 1056
1067 seq_printf(seq, "latency[%03d] usage[%08d]\n", 1057 seq_printf(seq, "latency[%03d] usage[%08d] duration[%020llu]\n",
1068 pr->power.states[i].latency, 1058 pr->power.states[i].latency,
1069 pr->power.states[i].usage); 1059 pr->power.states[i].usage,
1060 pr->power.states[i].time);
1070 } 1061 }
1071 1062
1072 end: 1063 end:
1073 return_VALUE(0); 1064 return 0;
1074} 1065}
1075 1066
1076static int acpi_processor_power_open_fs(struct inode *inode, struct file *file) 1067static int acpi_processor_power_open_fs(struct inode *inode, struct file *file)
@@ -1094,7 +1085,6 @@ int acpi_processor_power_init(struct acpi_processor *pr,
1094 struct proc_dir_entry *entry = NULL; 1085 struct proc_dir_entry *entry = NULL;
1095 unsigned int i; 1086 unsigned int i;
1096 1087
1097 ACPI_FUNCTION_TRACE("acpi_processor_power_init");
1098 1088
1099 if (!first_run) { 1089 if (!first_run) {
1100 dmi_check_system(processor_power_dmi_table); 1090 dmi_check_system(processor_power_dmi_table);
@@ -1106,14 +1096,14 @@ int acpi_processor_power_init(struct acpi_processor *pr,
1106 } 1096 }
1107 1097
1108 if (!pr) 1098 if (!pr)
1109 return_VALUE(-EINVAL); 1099 return -EINVAL;
1110 1100
1111 if (acpi_fadt.cst_cnt && !nocst) { 1101 if (acpi_fadt.cst_cnt && !nocst) {
1112 status = 1102 status =
1113 acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8); 1103 acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8);
1114 if (ACPI_FAILURE(status)) { 1104 if (ACPI_FAILURE(status)) {
1115 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1105 ACPI_EXCEPTION((AE_INFO, status,
1116 "Notifying BIOS of _CST ability failed\n")); 1106 "Notifying BIOS of _CST ability failed"));
1117 } 1107 }
1118 } 1108 }
1119 1109
@@ -1142,9 +1132,7 @@ int acpi_processor_power_init(struct acpi_processor *pr,
1142 entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER, 1132 entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER,
1143 S_IRUGO, acpi_device_dir(device)); 1133 S_IRUGO, acpi_device_dir(device));
1144 if (!entry) 1134 if (!entry)
1145 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1135 return -EIO;
1146 "Unable to create '%s' fs entry\n",
1147 ACPI_PROCESSOR_FILE_POWER));
1148 else { 1136 else {
1149 entry->proc_fops = &acpi_processor_power_fops; 1137 entry->proc_fops = &acpi_processor_power_fops;
1150 entry->data = acpi_driver_data(device); 1138 entry->data = acpi_driver_data(device);
@@ -1153,13 +1141,12 @@ int acpi_processor_power_init(struct acpi_processor *pr,
1153 1141
1154 pr->flags.power_setup_done = 1; 1142 pr->flags.power_setup_done = 1;
1155 1143
1156 return_VALUE(0); 1144 return 0;
1157} 1145}
1158 1146
1159int acpi_processor_power_exit(struct acpi_processor *pr, 1147int acpi_processor_power_exit(struct acpi_processor *pr,
1160 struct acpi_device *device) 1148 struct acpi_device *device)
1161{ 1149{
1162 ACPI_FUNCTION_TRACE("acpi_processor_power_exit");
1163 1150
1164 pr->flags.power_setup_done = 0; 1151 pr->flags.power_setup_done = 0;
1165 1152
@@ -1179,5 +1166,5 @@ int acpi_processor_power_exit(struct acpi_processor *pr,
1179 cpu_idle_wait(); 1166 cpu_idle_wait();
1180 } 1167 }
1181 1168
1182 return_VALUE(0); 1169 return 0;
1183} 1170}
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 41aaaba74b19..14a00e5a8f6a 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -108,10 +108,9 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
108 acpi_status status = 0; 108 acpi_status status = 0;
109 unsigned long ppc = 0; 109 unsigned long ppc = 0;
110 110
111 ACPI_FUNCTION_TRACE("acpi_processor_get_platform_limit");
112 111
113 if (!pr) 112 if (!pr)
114 return_VALUE(-EINVAL); 113 return -EINVAL;
115 114
116 /* 115 /*
117 * _PPC indicates the maximum state currently supported by the platform 116 * _PPC indicates the maximum state currently supported by the platform
@@ -123,13 +122,13 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
123 acpi_processor_ppc_status |= PPC_IN_USE; 122 acpi_processor_ppc_status |= PPC_IN_USE;
124 123
125 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 124 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
126 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PPC\n")); 125 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PPC"));
127 return_VALUE(-ENODEV); 126 return -ENODEV;
128 } 127 }
129 128
130 pr->performance_platform_limit = (int)ppc; 129 pr->performance_platform_limit = (int)ppc;
131 130
132 return_VALUE(0); 131 return 0;
133} 132}
134 133
135int acpi_processor_ppc_has_changed(struct acpi_processor *pr) 134int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
@@ -168,18 +167,17 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
168 union acpi_object *pct = NULL; 167 union acpi_object *pct = NULL;
169 union acpi_object obj = { 0 }; 168 union acpi_object obj = { 0 };
170 169
171 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_control");
172 170
173 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer); 171 status = acpi_evaluate_object(pr->handle, "_PCT", NULL, &buffer);
174 if (ACPI_FAILURE(status)) { 172 if (ACPI_FAILURE(status)) {
175 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PCT\n")); 173 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PCT"));
176 return_VALUE(-ENODEV); 174 return -ENODEV;
177 } 175 }
178 176
179 pct = (union acpi_object *)buffer.pointer; 177 pct = (union acpi_object *)buffer.pointer;
180 if (!pct || (pct->type != ACPI_TYPE_PACKAGE) 178 if (!pct || (pct->type != ACPI_TYPE_PACKAGE)
181 || (pct->package.count != 2)) { 179 || (pct->package.count != 2)) {
182 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PCT data\n")); 180 printk(KERN_ERR PREFIX "Invalid _PCT data\n");
183 result = -EFAULT; 181 result = -EFAULT;
184 goto end; 182 goto end;
185 } 183 }
@@ -193,8 +191,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
193 if ((obj.type != ACPI_TYPE_BUFFER) 191 if ((obj.type != ACPI_TYPE_BUFFER)
194 || (obj.buffer.length < sizeof(struct acpi_pct_register)) 192 || (obj.buffer.length < sizeof(struct acpi_pct_register))
195 || (obj.buffer.pointer == NULL)) { 193 || (obj.buffer.pointer == NULL)) {
196 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 194 printk(KERN_ERR PREFIX "Invalid _PCT data (control_register)\n");
197 "Invalid _PCT data (control_register)\n"));
198 result = -EFAULT; 195 result = -EFAULT;
199 goto end; 196 goto end;
200 } 197 }
@@ -210,8 +207,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
210 if ((obj.type != ACPI_TYPE_BUFFER) 207 if ((obj.type != ACPI_TYPE_BUFFER)
211 || (obj.buffer.length < sizeof(struct acpi_pct_register)) 208 || (obj.buffer.length < sizeof(struct acpi_pct_register))
212 || (obj.buffer.pointer == NULL)) { 209 || (obj.buffer.pointer == NULL)) {
213 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 210 printk(KERN_ERR PREFIX "Invalid _PCT data (status_register)\n");
214 "Invalid _PCT data (status_register)\n"));
215 result = -EFAULT; 211 result = -EFAULT;
216 goto end; 212 goto end;
217 } 213 }
@@ -222,7 +218,7 @@ static int acpi_processor_get_performance_control(struct acpi_processor *pr)
222 end: 218 end:
223 acpi_os_free(buffer.pointer); 219 acpi_os_free(buffer.pointer);
224 220
225 return_VALUE(result); 221 return result;
226} 222}
227 223
228static int acpi_processor_get_performance_states(struct acpi_processor *pr) 224static int acpi_processor_get_performance_states(struct acpi_processor *pr)
@@ -235,17 +231,16 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
235 union acpi_object *pss = NULL; 231 union acpi_object *pss = NULL;
236 int i; 232 int i;
237 233
238 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_states");
239 234
240 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer); 235 status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
241 if (ACPI_FAILURE(status)) { 236 if (ACPI_FAILURE(status)) {
242 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PSS\n")); 237 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PSS"));
243 return_VALUE(-ENODEV); 238 return -ENODEV;
244 } 239 }
245 240
246 pss = (union acpi_object *)buffer.pointer; 241 pss = (union acpi_object *)buffer.pointer;
247 if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) { 242 if (!pss || (pss->type != ACPI_TYPE_PACKAGE)) {
248 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSS data\n")); 243 printk(KERN_ERR PREFIX "Invalid _PSS data\n");
249 result = -EFAULT; 244 result = -EFAULT;
250 goto end; 245 goto end;
251 } 246 }
@@ -274,8 +269,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
274 status = acpi_extract_package(&(pss->package.elements[i]), 269 status = acpi_extract_package(&(pss->package.elements[i]),
275 &format, &state); 270 &format, &state);
276 if (ACPI_FAILURE(status)) { 271 if (ACPI_FAILURE(status)) {
277 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 272 ACPI_EXCEPTION((AE_INFO, status, "Invalid _PSS data"));
278 "Invalid _PSS data\n"));
279 result = -EFAULT; 273 result = -EFAULT;
280 kfree(pr->performance->states); 274 kfree(pr->performance->states);
281 goto end; 275 goto end;
@@ -291,8 +285,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
291 (u32) px->control, (u32) px->status)); 285 (u32) px->control, (u32) px->status));
292 286
293 if (!px->core_frequency) { 287 if (!px->core_frequency) {
294 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 288 printk(KERN_ERR PREFIX
295 "Invalid _PSS data: freq is zero\n")); 289 "Invalid _PSS data: freq is zero\n");
296 result = -EFAULT; 290 result = -EFAULT;
297 kfree(pr->performance->states); 291 kfree(pr->performance->states);
298 goto end; 292 goto end;
@@ -302,7 +296,7 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
302 end: 296 end:
303 acpi_os_free(buffer.pointer); 297 acpi_os_free(buffer.pointer);
304 298
305 return_VALUE(result); 299 return result;
306} 300}
307 301
308static int acpi_processor_get_performance_info(struct acpi_processor *pr) 302static int acpi_processor_get_performance_info(struct acpi_processor *pr)
@@ -311,31 +305,30 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr)
311 acpi_status status = AE_OK; 305 acpi_status status = AE_OK;
312 acpi_handle handle = NULL; 306 acpi_handle handle = NULL;
313 307
314 ACPI_FUNCTION_TRACE("acpi_processor_get_performance_info");
315 308
316 if (!pr || !pr->performance || !pr->handle) 309 if (!pr || !pr->performance || !pr->handle)
317 return_VALUE(-EINVAL); 310 return -EINVAL;
318 311
319 status = acpi_get_handle(pr->handle, "_PCT", &handle); 312 status = acpi_get_handle(pr->handle, "_PCT", &handle);
320 if (ACPI_FAILURE(status)) { 313 if (ACPI_FAILURE(status)) {
321 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 314 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
322 "ACPI-based processor performance control unavailable\n")); 315 "ACPI-based processor performance control unavailable\n"));
323 return_VALUE(-ENODEV); 316 return -ENODEV;
324 } 317 }
325 318
326 result = acpi_processor_get_performance_control(pr); 319 result = acpi_processor_get_performance_control(pr);
327 if (result) 320 if (result)
328 return_VALUE(result); 321 return result;
329 322
330 result = acpi_processor_get_performance_states(pr); 323 result = acpi_processor_get_performance_states(pr);
331 if (result) 324 if (result)
332 return_VALUE(result); 325 return result;
333 326
334 result = acpi_processor_get_platform_limit(pr); 327 result = acpi_processor_get_platform_limit(pr);
335 if (result) 328 if (result)
336 return_VALUE(result); 329 return result;
337 330
338 return_VALUE(0); 331 return 0;
339} 332}
340 333
341int acpi_processor_notify_smm(struct module *calling_module) 334int acpi_processor_notify_smm(struct module *calling_module)
@@ -343,13 +336,12 @@ int acpi_processor_notify_smm(struct module *calling_module)
343 acpi_status status; 336 acpi_status status;
344 static int is_done = 0; 337 static int is_done = 0;
345 338
346 ACPI_FUNCTION_TRACE("acpi_processor_notify_smm");
347 339
348 if (!(acpi_processor_ppc_status & PPC_REGISTERED)) 340 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
349 return_VALUE(-EBUSY); 341 return -EBUSY;
350 342
351 if (!try_module_get(calling_module)) 343 if (!try_module_get(calling_module))
352 return_VALUE(-EINVAL); 344 return -EINVAL;
353 345
354 /* is_done is set to negative if an error occured, 346 /* is_done is set to negative if an error occured,
355 * and to postitive if _no_ error occured, but SMM 347 * and to postitive if _no_ error occured, but SMM
@@ -358,10 +350,10 @@ int acpi_processor_notify_smm(struct module *calling_module)
358 */ 350 */
359 if (is_done > 0) { 351 if (is_done > 0) {
360 module_put(calling_module); 352 module_put(calling_module);
361 return_VALUE(0); 353 return 0;
362 } else if (is_done < 0) { 354 } else if (is_done < 0) {
363 module_put(calling_module); 355 module_put(calling_module);
364 return_VALUE(is_done); 356 return is_done;
365 } 357 }
366 358
367 is_done = -EIO; 359 is_done = -EIO;
@@ -370,7 +362,7 @@ int acpi_processor_notify_smm(struct module *calling_module)
370 if ((!acpi_fadt.smi_cmd) || (!acpi_fadt.pstate_cnt)) { 362 if ((!acpi_fadt.smi_cmd) || (!acpi_fadt.pstate_cnt)) {
371 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_cnt\n")); 363 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No SMI port or pstate_cnt\n"));
372 module_put(calling_module); 364 module_put(calling_module);
373 return_VALUE(0); 365 return 0;
374 } 366 }
375 367
376 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 368 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -387,12 +379,12 @@ int acpi_processor_notify_smm(struct module *calling_module)
387 status = acpi_os_write_port(acpi_fadt.smi_cmd, 379 status = acpi_os_write_port(acpi_fadt.smi_cmd,
388 (u32) acpi_fadt.pstate_cnt, 8); 380 (u32) acpi_fadt.pstate_cnt, 8);
389 if (ACPI_FAILURE(status)) { 381 if (ACPI_FAILURE(status)) {
390 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 382 ACPI_EXCEPTION((AE_INFO, status,
391 "Failed to write pstate_cnt [0x%x] to " 383 "Failed to write pstate_cnt [0x%x] to "
392 "smi_cmd [0x%x]\n", acpi_fadt.pstate_cnt, 384 "smi_cmd [0x%x]", acpi_fadt.pstate_cnt,
393 acpi_fadt.smi_cmd)); 385 acpi_fadt.smi_cmd));
394 module_put(calling_module); 386 module_put(calling_module);
395 return_VALUE(status); 387 return status;
396 } 388 }
397 389
398 /* Success. If there's no _PPC, we need to fear nothing, so 390 /* Success. If there's no _PPC, we need to fear nothing, so
@@ -402,7 +394,7 @@ int acpi_processor_notify_smm(struct module *calling_module)
402 if (!(acpi_processor_ppc_status & PPC_IN_USE)) 394 if (!(acpi_processor_ppc_status & PPC_IN_USE))
403 module_put(calling_module); 395 module_put(calling_module);
404 396
405 return_VALUE(0); 397 return 0;
406} 398}
407 399
408EXPORT_SYMBOL(acpi_processor_notify_smm); 400EXPORT_SYMBOL(acpi_processor_notify_smm);
@@ -423,7 +415,6 @@ static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
423 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 415 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
424 int i; 416 int i;
425 417
426 ACPI_FUNCTION_TRACE("acpi_processor_perf_seq_show");
427 418
428 if (!pr) 419 if (!pr)
429 goto end; 420 goto end;
@@ -447,7 +438,7 @@ static int acpi_processor_perf_seq_show(struct seq_file *seq, void *offset)
447 (u32) pr->performance->states[i].transition_latency); 438 (u32) pr->performance->states[i].transition_latency);
448 439
449 end: 440 end:
450 return_VALUE(0); 441 return 0;
451} 442}
452 443
453static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file) 444static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
@@ -469,23 +460,22 @@ acpi_processor_write_performance(struct file *file,
469 unsigned int new_state = 0; 460 unsigned int new_state = 0;
470 struct cpufreq_policy policy; 461 struct cpufreq_policy policy;
471 462
472 ACPI_FUNCTION_TRACE("acpi_processor_write_performance");
473 463
474 if (!pr || (count > sizeof(state_string) - 1)) 464 if (!pr || (count > sizeof(state_string) - 1))
475 return_VALUE(-EINVAL); 465 return -EINVAL;
476 466
477 perf = pr->performance; 467 perf = pr->performance;
478 if (!perf) 468 if (!perf)
479 return_VALUE(-EINVAL); 469 return -EINVAL;
480 470
481 if (copy_from_user(state_string, buffer, count)) 471 if (copy_from_user(state_string, buffer, count))
482 return_VALUE(-EFAULT); 472 return -EFAULT;
483 473
484 state_string[count] = '\0'; 474 state_string[count] = '\0';
485 new_state = simple_strtoul(state_string, NULL, 0); 475 new_state = simple_strtoul(state_string, NULL, 0);
486 476
487 if (new_state >= perf->state_count) 477 if (new_state >= perf->state_count)
488 return_VALUE(-EINVAL); 478 return -EINVAL;
489 479
490 cpufreq_get_policy(&policy, pr->id); 480 cpufreq_get_policy(&policy, pr->id);
491 481
@@ -495,9 +485,9 @@ acpi_processor_write_performance(struct file *file,
495 485
496 result = cpufreq_set_policy(&policy); 486 result = cpufreq_set_policy(&policy);
497 if (result) 487 if (result)
498 return_VALUE(result); 488 return result;
499 489
500 return_VALUE(count); 490 return count;
501} 491}
502 492
503static void acpi_cpufreq_add_file(struct acpi_processor *pr) 493static void acpi_cpufreq_add_file(struct acpi_processor *pr)
@@ -505,42 +495,36 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr)
505 struct proc_dir_entry *entry = NULL; 495 struct proc_dir_entry *entry = NULL;
506 struct acpi_device *device = NULL; 496 struct acpi_device *device = NULL;
507 497
508 ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile");
509 498
510 if (acpi_bus_get_device(pr->handle, &device)) 499 if (acpi_bus_get_device(pr->handle, &device))
511 return_VOID; 500 return;
512 501
513 /* add file 'performance' [R/W] */ 502 /* add file 'performance' [R/W] */
514 entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, 503 entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
515 S_IFREG | S_IRUGO | S_IWUSR, 504 S_IFREG | S_IRUGO | S_IWUSR,
516 acpi_device_dir(device)); 505 acpi_device_dir(device));
517 if (!entry) 506 if (entry){
518 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
519 "Unable to create '%s' fs entry\n",
520 ACPI_PROCESSOR_FILE_PERFORMANCE));
521 else {
522 acpi_processor_perf_fops.write = acpi_processor_write_performance; 507 acpi_processor_perf_fops.write = acpi_processor_write_performance;
523 entry->proc_fops = &acpi_processor_perf_fops; 508 entry->proc_fops = &acpi_processor_perf_fops;
524 entry->data = acpi_driver_data(device); 509 entry->data = acpi_driver_data(device);
525 entry->owner = THIS_MODULE; 510 entry->owner = THIS_MODULE;
526 } 511 }
527 return_VOID; 512 return;
528} 513}
529 514
530static void acpi_cpufreq_remove_file(struct acpi_processor *pr) 515static void acpi_cpufreq_remove_file(struct acpi_processor *pr)
531{ 516{
532 struct acpi_device *device = NULL; 517 struct acpi_device *device = NULL;
533 518
534 ACPI_FUNCTION_TRACE("acpi_cpufreq_addfile");
535 519
536 if (acpi_bus_get_device(pr->handle, &device)) 520 if (acpi_bus_get_device(pr->handle, &device))
537 return_VOID; 521 return;
538 522
539 /* remove file 'performance' */ 523 /* remove file 'performance' */
540 remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE, 524 remove_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
541 acpi_device_dir(device)); 525 acpi_device_dir(device));
542 526
543 return_VOID; 527 return;
544} 528}
545 529
546#else 530#else
@@ -698,12 +682,12 @@ int acpi_processor_preregister_performance(
698 /* Validate the Domain info */ 682 /* Validate the Domain info */
699 count_target = pdomain->num_processors; 683 count_target = pdomain->num_processors;
700 count = 1; 684 count = 1;
701 if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL || 685 if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ALL)
702 pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL) {
703 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL; 686 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ALL;
704 } else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY) { 687 else if (pdomain->coord_type == DOMAIN_COORD_TYPE_HW_ALL)
688 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_HW;
689 else if (pdomain->coord_type == DOMAIN_COORD_TYPE_SW_ANY)
705 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ANY; 690 pr->performance->shared_type = CPUFREQ_SHARED_TYPE_ANY;
706 }
707 691
708 for_each_possible_cpu(j) { 692 for_each_possible_cpu(j) {
709 if (i == j) 693 if (i == j)
@@ -784,22 +768,21 @@ acpi_processor_register_performance(struct acpi_processor_performance
784{ 768{
785 struct acpi_processor *pr; 769 struct acpi_processor *pr;
786 770
787 ACPI_FUNCTION_TRACE("acpi_processor_register_performance");
788 771
789 if (!(acpi_processor_ppc_status & PPC_REGISTERED)) 772 if (!(acpi_processor_ppc_status & PPC_REGISTERED))
790 return_VALUE(-EINVAL); 773 return -EINVAL;
791 774
792 mutex_lock(&performance_mutex); 775 mutex_lock(&performance_mutex);
793 776
794 pr = processors[cpu]; 777 pr = processors[cpu];
795 if (!pr) { 778 if (!pr) {
796 mutex_unlock(&performance_mutex); 779 mutex_unlock(&performance_mutex);
797 return_VALUE(-ENODEV); 780 return -ENODEV;
798 } 781 }
799 782
800 if (pr->performance) { 783 if (pr->performance) {
801 mutex_unlock(&performance_mutex); 784 mutex_unlock(&performance_mutex);
802 return_VALUE(-EBUSY); 785 return -EBUSY;
803 } 786 }
804 787
805 WARN_ON(!performance); 788 WARN_ON(!performance);
@@ -809,13 +792,13 @@ acpi_processor_register_performance(struct acpi_processor_performance
809 if (acpi_processor_get_performance_info(pr)) { 792 if (acpi_processor_get_performance_info(pr)) {
810 pr->performance = NULL; 793 pr->performance = NULL;
811 mutex_unlock(&performance_mutex); 794 mutex_unlock(&performance_mutex);
812 return_VALUE(-EIO); 795 return -EIO;
813 } 796 }
814 797
815 acpi_cpufreq_add_file(pr); 798 acpi_cpufreq_add_file(pr);
816 799
817 mutex_unlock(&performance_mutex); 800 mutex_unlock(&performance_mutex);
818 return_VALUE(0); 801 return 0;
819} 802}
820 803
821EXPORT_SYMBOL(acpi_processor_register_performance); 804EXPORT_SYMBOL(acpi_processor_register_performance);
@@ -826,14 +809,13 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
826{ 809{
827 struct acpi_processor *pr; 810 struct acpi_processor *pr;
828 811
829 ACPI_FUNCTION_TRACE("acpi_processor_unregister_performance");
830 812
831 mutex_lock(&performance_mutex); 813 mutex_lock(&performance_mutex);
832 814
833 pr = processors[cpu]; 815 pr = processors[cpu];
834 if (!pr) { 816 if (!pr) {
835 mutex_unlock(&performance_mutex); 817 mutex_unlock(&performance_mutex);
836 return_VOID; 818 return;
837 } 819 }
838 820
839 if (pr->performance) 821 if (pr->performance)
@@ -844,7 +826,7 @@ acpi_processor_unregister_performance(struct acpi_processor_performance
844 826
845 mutex_unlock(&performance_mutex); 827 mutex_unlock(&performance_mutex);
846 828
847 return_VOID; 829 return;
848} 830}
849 831
850EXPORT_SYMBOL(acpi_processor_unregister_performance); 832EXPORT_SYMBOL(acpi_processor_unregister_performance);
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index f99ad05cd6a2..ef5e0f6efdba 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -54,13 +54,12 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr)
54 u16 px = 0; 54 u16 px = 0;
55 u16 tx = 0; 55 u16 tx = 0;
56 56
57 ACPI_FUNCTION_TRACE("acpi_processor_apply_limit");
58 57
59 if (!pr) 58 if (!pr)
60 return_VALUE(-EINVAL); 59 return -EINVAL;
61 60
62 if (!pr->flags.limit) 61 if (!pr->flags.limit)
63 return_VALUE(-ENODEV); 62 return -ENODEV;
64 63
65 if (pr->flags.throttling) { 64 if (pr->flags.throttling) {
66 if (pr->limit.user.tx > tx) 65 if (pr->limit.user.tx > tx)
@@ -82,9 +81,9 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr)
82 81
83 end: 82 end:
84 if (result) 83 if (result)
85 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n")); 84 printk(KERN_ERR PREFIX "Unable to set limit\n");
86 85
87 return_VALUE(result); 86 return result;
88} 87}
89 88
90#ifdef CONFIG_CPU_FREQ 89#ifdef CONFIG_CPU_FREQ
@@ -200,19 +199,18 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
200 struct acpi_device *device = NULL; 199 struct acpi_device *device = NULL;
201 int tx = 0, max_tx_px = 0; 200 int tx = 0, max_tx_px = 0;
202 201
203 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit");
204 202
205 if ((type < ACPI_PROCESSOR_LIMIT_NONE) 203 if ((type < ACPI_PROCESSOR_LIMIT_NONE)
206 || (type > ACPI_PROCESSOR_LIMIT_DECREMENT)) 204 || (type > ACPI_PROCESSOR_LIMIT_DECREMENT))
207 return_VALUE(-EINVAL); 205 return -EINVAL;
208 206
209 result = acpi_bus_get_device(handle, &device); 207 result = acpi_bus_get_device(handle, &device);
210 if (result) 208 if (result)
211 return_VALUE(result); 209 return result;
212 210
213 pr = (struct acpi_processor *)acpi_driver_data(device); 211 pr = (struct acpi_processor *)acpi_driver_data(device);
214 if (!pr) 212 if (!pr)
215 return_VALUE(-ENODEV); 213 return -ENODEV;
216 214
217 /* Thermal limits are always relative to the current Px/Tx state. */ 215 /* Thermal limits are always relative to the current Px/Tx state. */
218 if (pr->flags.throttling) 216 if (pr->flags.throttling)
@@ -289,30 +287,28 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
289 287
290 result = acpi_processor_apply_limit(pr); 288 result = acpi_processor_apply_limit(pr);
291 if (result) 289 if (result)
292 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 290 printk(KERN_ERR PREFIX "Unable to set thermal limit\n");
293 "Unable to set thermal limit\n"));
294 291
295 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n", 292 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n",
296 pr->limit.thermal.px, pr->limit.thermal.tx)); 293 pr->limit.thermal.px, pr->limit.thermal.tx));
297 } else 294 } else
298 result = 0; 295 result = 0;
299 if (max_tx_px) 296 if (max_tx_px)
300 return_VALUE(1); 297 return 1;
301 else 298 else
302 return_VALUE(result); 299 return result;
303} 300}
304 301
305int acpi_processor_get_limit_info(struct acpi_processor *pr) 302int acpi_processor_get_limit_info(struct acpi_processor *pr)
306{ 303{
307 ACPI_FUNCTION_TRACE("acpi_processor_get_limit_info");
308 304
309 if (!pr) 305 if (!pr)
310 return_VALUE(-EINVAL); 306 return -EINVAL;
311 307
312 if (pr->flags.throttling) 308 if (pr->flags.throttling)
313 pr->flags.limit = 1; 309 pr->flags.limit = 1;
314 310
315 return_VALUE(0); 311 return 0;
316} 312}
317 313
318/* /proc interface */ 314/* /proc interface */
@@ -321,7 +317,6 @@ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
321{ 317{
322 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 318 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
323 319
324 ACPI_FUNCTION_TRACE("acpi_processor_limit_seq_show");
325 320
326 if (!pr) 321 if (!pr)
327 goto end; 322 goto end;
@@ -339,7 +334,7 @@ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
339 pr->limit.thermal.px, pr->limit.thermal.tx); 334 pr->limit.thermal.px, pr->limit.thermal.tx);
340 335
341 end: 336 end:
342 return_VALUE(0); 337 return 0;
343} 338}
344 339
345static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file) 340static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file)
@@ -359,36 +354,33 @@ static ssize_t acpi_processor_write_limit(struct file * file,
359 int px = 0; 354 int px = 0;
360 int tx = 0; 355 int tx = 0;
361 356
362 ACPI_FUNCTION_TRACE("acpi_processor_write_limit");
363 357
364 if (!pr || (count > sizeof(limit_string) - 1)) { 358 if (!pr || (count > sizeof(limit_string) - 1)) {
365 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n")); 359 return -EINVAL;
366 return_VALUE(-EINVAL);
367 } 360 }
368 361
369 if (copy_from_user(limit_string, buffer, count)) { 362 if (copy_from_user(limit_string, buffer, count)) {
370 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n")); 363 return -EFAULT;
371 return_VALUE(-EFAULT);
372 } 364 }
373 365
374 limit_string[count] = '\0'; 366 limit_string[count] = '\0';
375 367
376 if (sscanf(limit_string, "%d:%d", &px, &tx) != 2) { 368 if (sscanf(limit_string, "%d:%d", &px, &tx) != 2) {
377 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n")); 369 printk(KERN_ERR PREFIX "Invalid data format\n");
378 return_VALUE(-EINVAL); 370 return -EINVAL;
379 } 371 }
380 372
381 if (pr->flags.throttling) { 373 if (pr->flags.throttling) {
382 if ((tx < 0) || (tx > (pr->throttling.state_count - 1))) { 374 if ((tx < 0) || (tx > (pr->throttling.state_count - 1))) {
383 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid tx\n")); 375 printk(KERN_ERR PREFIX "Invalid tx\n");
384 return_VALUE(-EINVAL); 376 return -EINVAL;
385 } 377 }
386 pr->limit.user.tx = tx; 378 pr->limit.user.tx = tx;
387 } 379 }
388 380
389 result = acpi_processor_apply_limit(pr); 381 result = acpi_processor_apply_limit(pr);
390 382
391 return_VALUE(count); 383 return count;
392} 384}
393 385
394struct file_operations acpi_processor_limit_fops = { 386struct file_operations acpi_processor_limit_fops = {
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index b966549ec000..d044ec519db0 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -55,13 +55,12 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
55 u32 duty_mask = 0; 55 u32 duty_mask = 0;
56 u32 duty_value = 0; 56 u32 duty_value = 0;
57 57
58 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling");
59 58
60 if (!pr) 59 if (!pr)
61 return_VALUE(-EINVAL); 60 return -EINVAL;
62 61
63 if (!pr->flags.throttling) 62 if (!pr->flags.throttling)
64 return_VALUE(-ENODEV); 63 return -ENODEV;
65 64
66 pr->throttling.state = 0; 65 pr->throttling.state = 0;
67 66
@@ -93,7 +92,7 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
93 "Throttling state is T%d (%d%% throttling applied)\n", 92 "Throttling state is T%d (%d%% throttling applied)\n",
94 state, pr->throttling.states[state].performance)); 93 state, pr->throttling.states[state].performance));
95 94
96 return_VALUE(0); 95 return 0;
97} 96}
98 97
99int acpi_processor_set_throttling(struct acpi_processor *pr, int state) 98int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
@@ -102,19 +101,18 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
102 u32 duty_mask = 0; 101 u32 duty_mask = 0;
103 u32 duty_value = 0; 102 u32 duty_value = 0;
104 103
105 ACPI_FUNCTION_TRACE("acpi_processor_set_throttling");
106 104
107 if (!pr) 105 if (!pr)
108 return_VALUE(-EINVAL); 106 return -EINVAL;
109 107
110 if ((state < 0) || (state > (pr->throttling.state_count - 1))) 108 if ((state < 0) || (state > (pr->throttling.state_count - 1)))
111 return_VALUE(-EINVAL); 109 return -EINVAL;
112 110
113 if (!pr->flags.throttling) 111 if (!pr->flags.throttling)
114 return_VALUE(-ENODEV); 112 return -ENODEV;
115 113
116 if (state == pr->throttling.state) 114 if (state == pr->throttling.state)
117 return_VALUE(0); 115 return 0;
118 116
119 /* 117 /*
120 * Calculate the duty_value and duty_mask. 118 * Calculate the duty_value and duty_mask.
@@ -165,7 +163,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
165 (pr->throttling.states[state].performance ? pr-> 163 (pr->throttling.states[state].performance ? pr->
166 throttling.states[state].performance / 10 : 0))); 164 throttling.states[state].performance / 10 : 0)));
167 165
168 return_VALUE(0); 166 return 0;
169} 167}
170 168
171int acpi_processor_get_throttling_info(struct acpi_processor *pr) 169int acpi_processor_get_throttling_info(struct acpi_processor *pr)
@@ -174,7 +172,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
174 int step = 0; 172 int step = 0;
175 int i = 0; 173 int i = 0;
176 174
177 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling_info");
178 175
179 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 176 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
180 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", 177 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -183,21 +180,21 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
183 pr->throttling.duty_width)); 180 pr->throttling.duty_width));
184 181
185 if (!pr) 182 if (!pr)
186 return_VALUE(-EINVAL); 183 return -EINVAL;
187 184
188 /* TBD: Support ACPI 2.0 objects */ 185 /* TBD: Support ACPI 2.0 objects */
189 186
190 if (!pr->throttling.address) { 187 if (!pr->throttling.address) {
191 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); 188 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
192 return_VALUE(0); 189 return 0;
193 } else if (!pr->throttling.duty_width) { 190 } else if (!pr->throttling.duty_width) {
194 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); 191 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
195 return_VALUE(0); 192 return 0;
196 } 193 }
197 /* TBD: Support duty_cycle values that span bit 4. */ 194 /* TBD: Support duty_cycle values that span bit 4. */
198 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) { 195 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
199 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "duty_cycle spans bit 4\n")); 196 printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
200 return_VALUE(0); 197 return 0;
201 } 198 }
202 199
203 /* 200 /*
@@ -208,7 +205,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
208 if (errata.piix4.throttle) { 205 if (errata.piix4.throttle) {
209 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 206 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
210 "Throttling not supported on PIIX4 A- or B-step\n")); 207 "Throttling not supported on PIIX4 A- or B-step\n"));
211 return_VALUE(0); 208 return 0;
212 } 209 }
213 210
214 pr->throttling.state_count = 1 << acpi_fadt.duty_width; 211 pr->throttling.state_count = 1 << acpi_fadt.duty_width;
@@ -254,7 +251,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
254 if (result) 251 if (result)
255 pr->flags.throttling = 0; 252 pr->flags.throttling = 0;
256 253
257 return_VALUE(result); 254 return result;
258} 255}
259 256
260/* proc interface */ 257/* proc interface */
@@ -266,7 +263,6 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
266 int i = 0; 263 int i = 0;
267 int result = 0; 264 int result = 0;
268 265
269 ACPI_FUNCTION_TRACE("acpi_processor_throttling_seq_show");
270 266
271 if (!pr) 267 if (!pr)
272 goto end; 268 goto end;
@@ -296,7 +292,7 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
296 throttling.states[i].performance / 10 : 0)); 292 throttling.states[i].performance / 10 : 0));
297 293
298 end: 294 end:
299 return_VALUE(0); 295 return 0;
300} 296}
301 297
302static int acpi_processor_throttling_open_fs(struct inode *inode, 298static int acpi_processor_throttling_open_fs(struct inode *inode,
@@ -315,13 +311,12 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
315 struct acpi_processor *pr = (struct acpi_processor *)m->private; 311 struct acpi_processor *pr = (struct acpi_processor *)m->private;
316 char state_string[12] = { '\0' }; 312 char state_string[12] = { '\0' };
317 313
318 ACPI_FUNCTION_TRACE("acpi_processor_write_throttling");
319 314
320 if (!pr || (count > sizeof(state_string) - 1)) 315 if (!pr || (count > sizeof(state_string) - 1))
321 return_VALUE(-EINVAL); 316 return -EINVAL;
322 317
323 if (copy_from_user(state_string, buffer, count)) 318 if (copy_from_user(state_string, buffer, count))
324 return_VALUE(-EFAULT); 319 return -EFAULT;
325 320
326 state_string[count] = '\0'; 321 state_string[count] = '\0';
327 322
@@ -329,9 +324,9 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
329 simple_strtoul(state_string, 324 simple_strtoul(state_string,
330 NULL, 0)); 325 NULL, 0));
331 if (result) 326 if (result)
332 return_VALUE(result); 327 return result;
333 328
334 return_VALUE(count); 329 return count;
335} 330}
336 331
337struct file_operations acpi_processor_throttling_fops = { 332struct file_operations acpi_processor_throttling_fops = {
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index f8316a05ede7..861ac378ce42 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -162,11 +162,10 @@ static void acpi_device_unregister(struct acpi_device *device, int type)
162 162
163void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context) 163void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context)
164{ 164{
165 ACPI_FUNCTION_TRACE("acpi_bus_data_handler");
166 165
167 /* TBD */ 166 /* TBD */
168 167
169 return_VOID; 168 return;
170} 169}
171 170
172static int acpi_bus_get_power_flags(struct acpi_device *device) 171static int acpi_bus_get_power_flags(struct acpi_device *device)
@@ -175,7 +174,6 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
175 acpi_handle handle = NULL; 174 acpi_handle handle = NULL;
176 u32 i = 0; 175 u32 i = 0;
177 176
178 ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags");
179 177
180 /* 178 /*
181 * Power Management Flags 179 * Power Management Flags
@@ -228,7 +226,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
228 226
229 device->power.state = ACPI_STATE_UNKNOWN; 227 device->power.state = ACPI_STATE_UNKNOWN;
230 228
231 return_VALUE(0); 229 return 0;
232} 230}
233 231
234int acpi_match_ids(struct acpi_device *device, char *ids) 232int acpi_match_ids(struct acpi_device *device, char *ids)
@@ -306,20 +304,18 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
306 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 304 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
307 union acpi_object *package = NULL; 305 union acpi_object *package = NULL;
308 306
309 ACPI_FUNCTION_TRACE("acpi_bus_get_wakeup_flags");
310 307
311 /* _PRW */ 308 /* _PRW */
312 status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer); 309 status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
313 if (ACPI_FAILURE(status)) { 310 if (ACPI_FAILURE(status)) {
314 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRW\n")); 311 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRW"));
315 goto end; 312 goto end;
316 } 313 }
317 314
318 package = (union acpi_object *)buffer.pointer; 315 package = (union acpi_object *)buffer.pointer;
319 status = acpi_bus_extract_wakeup_device_power_package(device, package); 316 status = acpi_bus_extract_wakeup_device_power_package(device, package);
320 if (ACPI_FAILURE(status)) { 317 if (ACPI_FAILURE(status)) {
321 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 318 ACPI_EXCEPTION((AE_INFO, status, "Extracting _PRW package"));
322 "Error extracting _PRW package\n"));
323 goto end; 319 goto end;
324 } 320 }
325 321
@@ -333,7 +329,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
333 end: 329 end:
334 if (ACPI_FAILURE(status)) 330 if (ACPI_FAILURE(status))
335 device->flags.wake_capable = 0; 331 device->flags.wake_capable = 0;
336 return_VALUE(0); 332 return 0;
337} 333}
338 334
339/* -------------------------------------------------------------------------- 335/* --------------------------------------------------------------------------
@@ -489,19 +485,18 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
489{ 485{
490 int result = 0; 486 int result = 0;
491 487
492 ACPI_FUNCTION_TRACE("acpi_bus_driver_init");
493 488
494 if (!device || !driver) 489 if (!device || !driver)
495 return_VALUE(-EINVAL); 490 return -EINVAL;
496 491
497 if (!driver->ops.add) 492 if (!driver->ops.add)
498 return_VALUE(-ENOSYS); 493 return -ENOSYS;
499 494
500 result = driver->ops.add(device); 495 result = driver->ops.add(device);
501 if (result) { 496 if (result) {
502 device->driver = NULL; 497 device->driver = NULL;
503 acpi_driver_data(device) = NULL; 498 acpi_driver_data(device) = NULL;
504 return_VALUE(result); 499 return result;
505 } 500 }
506 501
507 device->driver = driver; 502 device->driver = driver;
@@ -513,7 +508,7 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
513 508
514 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 509 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
515 "Driver successfully bound to device\n")); 510 "Driver successfully bound to device\n"));
516 return_VALUE(0); 511 return 0;
517} 512}
518 513
519static int acpi_start_single_object(struct acpi_device *device) 514static int acpi_start_single_object(struct acpi_device *device)
@@ -521,10 +516,9 @@ static int acpi_start_single_object(struct acpi_device *device)
521 int result = 0; 516 int result = 0;
522 struct acpi_driver *driver; 517 struct acpi_driver *driver;
523 518
524 ACPI_FUNCTION_TRACE("acpi_start_single_object");
525 519
526 if (!(driver = device->driver)) 520 if (!(driver = device->driver))
527 return_VALUE(0); 521 return 0;
528 522
529 if (driver->ops.start) { 523 if (driver->ops.start) {
530 result = driver->ops.start(device); 524 result = driver->ops.start(device);
@@ -532,14 +526,13 @@ static int acpi_start_single_object(struct acpi_device *device)
532 driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); 526 driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
533 } 527 }
534 528
535 return_VALUE(result); 529 return result;
536} 530}
537 531
538static void acpi_driver_attach(struct acpi_driver *drv) 532static void acpi_driver_attach(struct acpi_driver *drv)
539{ 533{
540 struct list_head *node, *next; 534 struct list_head *node, *next;
541 535
542 ACPI_FUNCTION_TRACE("acpi_driver_attach");
543 536
544 spin_lock(&acpi_device_lock); 537 spin_lock(&acpi_device_lock);
545 list_for_each_safe(node, next, &acpi_device_list) { 538 list_for_each_safe(node, next, &acpi_device_list) {
@@ -568,7 +561,6 @@ static void acpi_driver_detach(struct acpi_driver *drv)
568{ 561{
569 struct list_head *node, *next; 562 struct list_head *node, *next;
570 563
571 ACPI_FUNCTION_TRACE("acpi_driver_detach");
572 564
573 spin_lock(&acpi_device_lock); 565 spin_lock(&acpi_device_lock);
574 list_for_each_safe(node, next, &acpi_device_list) { 566 list_for_each_safe(node, next, &acpi_device_list) {
@@ -598,17 +590,16 @@ static void acpi_driver_detach(struct acpi_driver *drv)
598 */ 590 */
599int acpi_bus_register_driver(struct acpi_driver *driver) 591int acpi_bus_register_driver(struct acpi_driver *driver)
600{ 592{
601 ACPI_FUNCTION_TRACE("acpi_bus_register_driver");
602 593
603 if (acpi_disabled) 594 if (acpi_disabled)
604 return_VALUE(-ENODEV); 595 return -ENODEV;
605 596
606 spin_lock(&acpi_device_lock); 597 spin_lock(&acpi_device_lock);
607 list_add_tail(&driver->node, &acpi_bus_drivers); 598 list_add_tail(&driver->node, &acpi_bus_drivers);
608 spin_unlock(&acpi_device_lock); 599 spin_unlock(&acpi_device_lock);
609 acpi_driver_attach(driver); 600 acpi_driver_attach(driver);
610 601
611 return_VALUE(0); 602 return 0;
612} 603}
613 604
614EXPORT_SYMBOL(acpi_bus_register_driver); 605EXPORT_SYMBOL(acpi_bus_register_driver);
@@ -646,7 +637,6 @@ static int acpi_bus_find_driver(struct acpi_device *device)
646 int result = 0; 637 int result = 0;
647 struct list_head *node, *next; 638 struct list_head *node, *next;
648 639
649 ACPI_FUNCTION_TRACE("acpi_bus_find_driver");
650 640
651 spin_lock(&acpi_device_lock); 641 spin_lock(&acpi_device_lock);
652 list_for_each_safe(node, next, &acpi_bus_drivers) { 642 list_for_each_safe(node, next, &acpi_bus_drivers) {
@@ -666,19 +656,41 @@ static int acpi_bus_find_driver(struct acpi_device *device)
666 spin_unlock(&acpi_device_lock); 656 spin_unlock(&acpi_device_lock);
667 657
668 Done: 658 Done:
669 return_VALUE(result); 659 return result;
670} 660}
671 661
672/* -------------------------------------------------------------------------- 662/* --------------------------------------------------------------------------
673 Device Enumeration 663 Device Enumeration
674 -------------------------------------------------------------------------- */ 664 -------------------------------------------------------------------------- */
675 665
666acpi_status
667acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd)
668{
669 acpi_status status;
670 acpi_handle tmp;
671 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
672 union acpi_object *obj;
673
674 status = acpi_get_handle(handle, "_EJD", &tmp);
675 if (ACPI_FAILURE(status))
676 return status;
677
678 status = acpi_evaluate_object(handle, "_EJD", NULL, &buffer);
679 if (ACPI_SUCCESS(status)) {
680 obj = buffer.pointer;
681 status = acpi_get_handle(NULL, obj->string.pointer, ejd);
682 kfree(buffer.pointer);
683 }
684 return status;
685}
686EXPORT_SYMBOL_GPL(acpi_bus_get_ejd);
687
688
676static int acpi_bus_get_flags(struct acpi_device *device) 689static int acpi_bus_get_flags(struct acpi_device *device)
677{ 690{
678 acpi_status status = AE_OK; 691 acpi_status status = AE_OK;
679 acpi_handle temp = NULL; 692 acpi_handle temp = NULL;
680 693
681 ACPI_FUNCTION_TRACE("acpi_bus_get_flags");
682 694
683 /* Presence of _STA indicates 'dynamic_status' */ 695 /* Presence of _STA indicates 'dynamic_status' */
684 status = acpi_get_handle(device->handle, "_STA", &temp); 696 status = acpi_get_handle(device->handle, "_STA", &temp);
@@ -724,7 +736,7 @@ static int acpi_bus_get_flags(struct acpi_device *device)
724 736
725 /* TBD: Peformance management */ 737 /* TBD: Peformance management */
726 738
727 return_VALUE(0); 739 return 0;
728} 740}
729 741
730static void acpi_device_get_busid(struct acpi_device *device, 742static void acpi_device_get_busid(struct acpi_device *device,
@@ -918,10 +930,9 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
918 int result = 0; 930 int result = 0;
919 struct acpi_driver *driver; 931 struct acpi_driver *driver;
920 932
921 ACPI_FUNCTION_TRACE("acpi_bus_remove");
922 933
923 if (!dev) 934 if (!dev)
924 return_VALUE(-EINVAL); 935 return -EINVAL;
925 936
926 driver = dev->driver; 937 driver = dev->driver;
927 938
@@ -930,12 +941,12 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
930 if (driver->ops.stop) { 941 if (driver->ops.stop) {
931 result = driver->ops.stop(dev, ACPI_BUS_REMOVAL_EJECT); 942 result = driver->ops.stop(dev, ACPI_BUS_REMOVAL_EJECT);
932 if (result) 943 if (result)
933 return_VALUE(result); 944 return result;
934 } 945 }
935 946
936 result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT); 947 result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT);
937 if (result) { 948 if (result) {
938 return_VALUE(result); 949 return result;
939 } 950 }
940 951
941 atomic_dec(&dev->driver->references); 952 atomic_dec(&dev->driver->references);
@@ -944,7 +955,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
944 } 955 }
945 956
946 if (!rmdevice) 957 if (!rmdevice)
947 return_VALUE(0); 958 return 0;
948 959
949 if (dev->flags.bus_address) { 960 if (dev->flags.bus_address) {
950 if ((dev->parent) && (dev->parent->ops.unbind)) 961 if ((dev->parent) && (dev->parent->ops.unbind))
@@ -953,7 +964,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
953 964
954 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); 965 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
955 966
956 return_VALUE(0); 967 return 0;
957} 968}
958 969
959static int 970static int
@@ -963,15 +974,14 @@ acpi_add_single_object(struct acpi_device **child,
963 int result = 0; 974 int result = 0;
964 struct acpi_device *device = NULL; 975 struct acpi_device *device = NULL;
965 976
966 ACPI_FUNCTION_TRACE("acpi_add_single_object");
967 977
968 if (!child) 978 if (!child)
969 return_VALUE(-EINVAL); 979 return -EINVAL;
970 980
971 device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL); 981 device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL);
972 if (!device) { 982 if (!device) {
973 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n")); 983 printk(KERN_ERR PREFIX "Memory allocation error\n");
974 return_VALUE(-ENOMEM); 984 return -ENOMEM;
975 } 985 }
976 memset(device, 0, sizeof(struct acpi_device)); 986 memset(device, 0, sizeof(struct acpi_device));
977 987
@@ -1096,7 +1106,7 @@ acpi_add_single_object(struct acpi_device **child,
1096 kfree(device); 1106 kfree(device);
1097 } 1107 }
1098 1108
1099 return_VALUE(result); 1109 return result;
1100} 1110}
1101 1111
1102static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) 1112static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
@@ -1109,10 +1119,9 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
1109 acpi_object_type type = 0; 1119 acpi_object_type type = 0;
1110 u32 level = 1; 1120 u32 level = 1;
1111 1121
1112 ACPI_FUNCTION_TRACE("acpi_bus_scan");
1113 1122
1114 if (!start) 1123 if (!start)
1115 return_VALUE(-EINVAL); 1124 return -EINVAL;
1116 1125
1117 parent = start; 1126 parent = start;
1118 phandle = start->handle; 1127 phandle = start->handle;
@@ -1209,7 +1218,7 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
1209 } 1218 }
1210 } 1219 }
1211 1220
1212 return_VALUE(0); 1221 return 0;
1213} 1222}
1214 1223
1215int 1224int
@@ -1219,7 +1228,6 @@ acpi_bus_add(struct acpi_device **child,
1219 int result; 1228 int result;
1220 struct acpi_bus_ops ops; 1229 struct acpi_bus_ops ops;
1221 1230
1222 ACPI_FUNCTION_TRACE("acpi_bus_add");
1223 1231
1224 result = acpi_add_single_object(child, parent, handle, type); 1232 result = acpi_add_single_object(child, parent, handle, type);
1225 if (!result) { 1233 if (!result) {
@@ -1227,7 +1235,7 @@ acpi_bus_add(struct acpi_device **child,
1227 ops.acpi_op_add = 1; 1235 ops.acpi_op_add = 1;
1228 result = acpi_bus_scan(*child, &ops); 1236 result = acpi_bus_scan(*child, &ops);
1229 } 1237 }
1230 return_VALUE(result); 1238 return result;
1231} 1239}
1232 1240
1233EXPORT_SYMBOL(acpi_bus_add); 1241EXPORT_SYMBOL(acpi_bus_add);
@@ -1237,10 +1245,9 @@ int acpi_bus_start(struct acpi_device *device)
1237 int result; 1245 int result;
1238 struct acpi_bus_ops ops; 1246 struct acpi_bus_ops ops;
1239 1247
1240 ACPI_FUNCTION_TRACE("acpi_bus_start");
1241 1248
1242 if (!device) 1249 if (!device)
1243 return_VALUE(-EINVAL); 1250 return -EINVAL;
1244 1251
1245 result = acpi_start_single_object(device); 1252 result = acpi_start_single_object(device);
1246 if (!result) { 1253 if (!result) {
@@ -1248,7 +1255,7 @@ int acpi_bus_start(struct acpi_device *device)
1248 ops.acpi_op_start = 1; 1255 ops.acpi_op_start = 1;
1249 result = acpi_bus_scan(device, &ops); 1256 result = acpi_bus_scan(device, &ops);
1250 } 1257 }
1251 return_VALUE(result); 1258 return result;
1252} 1259}
1253 1260
1254EXPORT_SYMBOL(acpi_bus_start); 1261EXPORT_SYMBOL(acpi_bus_start);
@@ -1314,10 +1321,9 @@ static int acpi_bus_scan_fixed(struct acpi_device *root)
1314 int result = 0; 1321 int result = 0;
1315 struct acpi_device *device = NULL; 1322 struct acpi_device *device = NULL;
1316 1323
1317 ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed");
1318 1324
1319 if (!root) 1325 if (!root)
1320 return_VALUE(-ENODEV); 1326 return -ENODEV;
1321 1327
1322 /* 1328 /*
1323 * Enumerate all fixed-feature devices. 1329 * Enumerate all fixed-feature devices.
@@ -1338,7 +1344,7 @@ static int acpi_bus_scan_fixed(struct acpi_device *root)
1338 result = acpi_start_single_object(device); 1344 result = acpi_start_single_object(device);
1339 } 1345 }
1340 1346
1341 return_VALUE(result); 1347 return result;
1342} 1348}
1343 1349
1344 1350
@@ -1427,7 +1433,7 @@ static int acpi_device_resume(struct device * dev)
1427} 1433}
1428 1434
1429 1435
1430struct bus_type acpi_bus_type = { 1436static struct bus_type acpi_bus_type = {
1431 .name = "acpi", 1437 .name = "acpi",
1432 .suspend = acpi_device_suspend, 1438 .suspend = acpi_device_suspend,
1433 .resume = acpi_device_resume, 1439 .resume = acpi_device_resume,
@@ -1440,10 +1446,9 @@ static int __init acpi_scan_init(void)
1440 int result; 1446 int result;
1441 struct acpi_bus_ops ops; 1447 struct acpi_bus_ops ops;
1442 1448
1443 ACPI_FUNCTION_TRACE("acpi_scan_init");
1444 1449
1445 if (acpi_disabled) 1450 if (acpi_disabled)
1446 return_VALUE(0); 1451 return 0;
1447 1452
1448 kset_register(&acpi_namespace_kset); 1453 kset_register(&acpi_namespace_kset);
1449 1454
@@ -1488,7 +1493,7 @@ static int __init acpi_scan_init(void)
1488 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1493 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
1489 1494
1490 Done: 1495 Done:
1491 return_VALUE(result); 1496 return result;
1492} 1497}
1493 1498
1494subsys_initcall(acpi_scan_init); 1499subsys_initcall(acpi_scan_init);
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index a934ac42178d..c90bd2f70b3f 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -47,10 +47,9 @@ extern struct fadt_descriptor acpi_fadt;
47 47
48static int acpi_system_read_info(struct seq_file *seq, void *offset) 48static int acpi_system_read_info(struct seq_file *seq, void *offset)
49{ 49{
50 ACPI_FUNCTION_TRACE("acpi_system_read_info");
51 50
52 seq_printf(seq, "version: %x\n", ACPI_CA_VERSION); 51 seq_printf(seq, "version: %x\n", ACPI_CA_VERSION);
53 return_VALUE(0); 52 return 0;
54} 53}
55 54
56static int acpi_system_info_open_fs(struct inode *inode, struct file *file) 55static int acpi_system_info_open_fs(struct inode *inode, struct file *file)
@@ -80,17 +79,16 @@ acpi_system_read_dsdt(struct file *file,
80 struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL }; 79 struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL };
81 ssize_t res; 80 ssize_t res;
82 81
83 ACPI_FUNCTION_TRACE("acpi_system_read_dsdt");
84 82
85 status = acpi_get_table(ACPI_TABLE_ID_DSDT, 1, &dsdt); 83 status = acpi_get_table(ACPI_TABLE_ID_DSDT, 1, &dsdt);
86 if (ACPI_FAILURE(status)) 84 if (ACPI_FAILURE(status))
87 return_VALUE(-ENODEV); 85 return -ENODEV;
88 86
89 res = simple_read_from_buffer(buffer, count, ppos, 87 res = simple_read_from_buffer(buffer, count, ppos,
90 dsdt.pointer, dsdt.length); 88 dsdt.pointer, dsdt.length);
91 acpi_os_free(dsdt.pointer); 89 acpi_os_free(dsdt.pointer);
92 90
93 return_VALUE(res); 91 return res;
94} 92}
95 93
96static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t, 94static ssize_t acpi_system_read_fadt(struct file *, char __user *, size_t,
@@ -108,17 +106,16 @@ acpi_system_read_fadt(struct file *file,
108 struct acpi_buffer fadt = { ACPI_ALLOCATE_BUFFER, NULL }; 106 struct acpi_buffer fadt = { ACPI_ALLOCATE_BUFFER, NULL };
109 ssize_t res; 107 ssize_t res;
110 108
111 ACPI_FUNCTION_TRACE("acpi_system_read_fadt");
112 109
113 status = acpi_get_table(ACPI_TABLE_ID_FADT, 1, &fadt); 110 status = acpi_get_table(ACPI_TABLE_ID_FADT, 1, &fadt);
114 if (ACPI_FAILURE(status)) 111 if (ACPI_FAILURE(status))
115 return_VALUE(-ENODEV); 112 return -ENODEV;
116 113
117 res = simple_read_from_buffer(buffer, count, ppos, 114 res = simple_read_from_buffer(buffer, count, ppos,
118 fadt.pointer, fadt.length); 115 fadt.pointer, fadt.length);
119 acpi_os_free(fadt.pointer); 116 acpi_os_free(fadt.pointer);
120 117
121 return_VALUE(res); 118 return res;
122} 119}
123 120
124static int __init acpi_system_init(void) 121static int __init acpi_system_init(void)
@@ -127,10 +124,9 @@ static int __init acpi_system_init(void)
127 int error = 0; 124 int error = 0;
128 char *name; 125 char *name;
129 126
130 ACPI_FUNCTION_TRACE("acpi_system_init");
131 127
132 if (acpi_disabled) 128 if (acpi_disabled)
133 return_VALUE(0); 129 return 0;
134 130
135 /* 'info' [R] */ 131 /* 'info' [R] */
136 name = ACPI_SYSTEM_FILE_INFO; 132 name = ACPI_SYSTEM_FILE_INFO;
@@ -158,12 +154,9 @@ static int __init acpi_system_init(void)
158 goto Error; 154 goto Error;
159 155
160 Done: 156 Done:
161 return_VALUE(error); 157 return error;
162 158
163 Error: 159 Error:
164 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
165 "Unable to create '%s' proc fs entry\n", name));
166
167 remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir); 160 remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir);
168 remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir); 161 remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir);
169 remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir); 162 remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir);
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index e7fe3a14fdaf..c855f4446b5f 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -222,51 +222,48 @@ static int acpi_thermal_get_temperature(struct acpi_thermal *tz)
222{ 222{
223 acpi_status status = AE_OK; 223 acpi_status status = AE_OK;
224 224
225 ACPI_FUNCTION_TRACE("acpi_thermal_get_temperature");
226 225
227 if (!tz) 226 if (!tz)
228 return_VALUE(-EINVAL); 227 return -EINVAL;
229 228
230 tz->last_temperature = tz->temperature; 229 tz->last_temperature = tz->temperature;
231 230
232 status = 231 status =
233 acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature); 232 acpi_evaluate_integer(tz->handle, "_TMP", NULL, &tz->temperature);
234 if (ACPI_FAILURE(status)) 233 if (ACPI_FAILURE(status))
235 return_VALUE(-ENODEV); 234 return -ENODEV;
236 235
237 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n", 236 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Temperature is %lu dK\n",
238 tz->temperature)); 237 tz->temperature));
239 238
240 return_VALUE(0); 239 return 0;
241} 240}
242 241
243static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) 242static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
244{ 243{
245 acpi_status status = AE_OK; 244 acpi_status status = AE_OK;
246 245
247 ACPI_FUNCTION_TRACE("acpi_thermal_get_polling_frequency");
248 246
249 if (!tz) 247 if (!tz)
250 return_VALUE(-EINVAL); 248 return -EINVAL;
251 249
252 status = 250 status =
253 acpi_evaluate_integer(tz->handle, "_TZP", NULL, 251 acpi_evaluate_integer(tz->handle, "_TZP", NULL,
254 &tz->polling_frequency); 252 &tz->polling_frequency);
255 if (ACPI_FAILURE(status)) 253 if (ACPI_FAILURE(status))
256 return_VALUE(-ENODEV); 254 return -ENODEV;
257 255
258 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n", 256 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Polling frequency is %lu dS\n",
259 tz->polling_frequency)); 257 tz->polling_frequency));
260 258
261 return_VALUE(0); 259 return 0;
262} 260}
263 261
264static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds) 262static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
265{ 263{
266 ACPI_FUNCTION_TRACE("acpi_thermal_set_polling");
267 264
268 if (!tz) 265 if (!tz)
269 return_VALUE(-EINVAL); 266 return -EINVAL;
270 267
271 tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */ 268 tz->polling_frequency = seconds * 10; /* Convert value to deci-seconds */
272 269
@@ -274,7 +271,7 @@ static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds)
274 "Polling frequency set to %lu seconds\n", 271 "Polling frequency set to %lu seconds\n",
275 tz->polling_frequency)); 272 tz->polling_frequency));
276 273
277 return_VALUE(0); 274 return 0;
278} 275}
279 276
280static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) 277static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
@@ -284,29 +281,28 @@ static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
284 struct acpi_object_list arg_list = { 1, &arg0 }; 281 struct acpi_object_list arg_list = { 1, &arg0 };
285 acpi_handle handle = NULL; 282 acpi_handle handle = NULL;
286 283
287 ACPI_FUNCTION_TRACE("acpi_thermal_set_cooling_mode");
288 284
289 if (!tz) 285 if (!tz)
290 return_VALUE(-EINVAL); 286 return -EINVAL;
291 287
292 status = acpi_get_handle(tz->handle, "_SCP", &handle); 288 status = acpi_get_handle(tz->handle, "_SCP", &handle);
293 if (ACPI_FAILURE(status)) { 289 if (ACPI_FAILURE(status)) {
294 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n")); 290 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n"));
295 return_VALUE(-ENODEV); 291 return -ENODEV;
296 } 292 }
297 293
298 arg0.integer.value = mode; 294 arg0.integer.value = mode;
299 295
300 status = acpi_evaluate_object(handle, NULL, &arg_list, NULL); 296 status = acpi_evaluate_object(handle, NULL, &arg_list, NULL);
301 if (ACPI_FAILURE(status)) 297 if (ACPI_FAILURE(status))
302 return_VALUE(-ENODEV); 298 return -ENODEV;
303 299
304 tz->cooling_mode = mode; 300 tz->cooling_mode = mode;
305 301
306 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n", 302 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cooling mode [%s]\n",
307 mode ? "passive" : "active")); 303 mode ? "passive" : "active"));
308 304
309 return_VALUE(0); 305 return 0;
310} 306}
311 307
312static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) 308static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
@@ -314,10 +310,9 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
314 acpi_status status = AE_OK; 310 acpi_status status = AE_OK;
315 int i = 0; 311 int i = 0;
316 312
317 ACPI_FUNCTION_TRACE("acpi_thermal_get_trip_points");
318 313
319 if (!tz) 314 if (!tz)
320 return_VALUE(-EINVAL); 315 return -EINVAL;
321 316
322 /* Critical Shutdown (required) */ 317 /* Critical Shutdown (required) */
323 318
@@ -325,8 +320,8 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
325 &tz->trips.critical.temperature); 320 &tz->trips.critical.temperature);
326 if (ACPI_FAILURE(status)) { 321 if (ACPI_FAILURE(status)) {
327 tz->trips.critical.flags.valid = 0; 322 tz->trips.critical.flags.valid = 0;
328 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "No critical threshold\n")); 323 ACPI_EXCEPTION((AE_INFO, status, "No critical threshold"));
329 return_VALUE(-ENODEV); 324 return -ENODEV;
330 } else { 325 } else {
331 tz->trips.critical.flags.valid = 1; 326 tz->trips.critical.flags.valid = 1;
332 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 327 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -384,8 +379,7 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
384 tz->trips.passive.flags.valid = 0; 379 tz->trips.passive.flags.valid = 0;
385 380
386 if (!tz->trips.passive.flags.valid) 381 if (!tz->trips.passive.flags.valid)
387 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 382 printk(KERN_WARNING PREFIX "Invalid passive threshold\n");
388 "Invalid passive threshold\n"));
389 else 383 else
390 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 384 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
391 "Found passive threshold [%lu]\n", 385 "Found passive threshold [%lu]\n",
@@ -414,29 +408,27 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
414 "Found active threshold [%d]:[%lu]\n", 408 "Found active threshold [%d]:[%lu]\n",
415 i, tz->trips.active[i].temperature)); 409 i, tz->trips.active[i].temperature));
416 } else 410 } else
417 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 411 ACPI_EXCEPTION((AE_INFO, status,
418 "Invalid active threshold [%d]\n", 412 "Invalid active threshold [%d]", i));
419 i));
420 } 413 }
421 414
422 return_VALUE(0); 415 return 0;
423} 416}
424 417
425static int acpi_thermal_get_devices(struct acpi_thermal *tz) 418static int acpi_thermal_get_devices(struct acpi_thermal *tz)
426{ 419{
427 acpi_status status = AE_OK; 420 acpi_status status = AE_OK;
428 421
429 ACPI_FUNCTION_TRACE("acpi_thermal_get_devices");
430 422
431 if (!tz) 423 if (!tz)
432 return_VALUE(-EINVAL); 424 return -EINVAL;
433 425
434 status = 426 status =
435 acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices); 427 acpi_evaluate_reference(tz->handle, "_TZD", NULL, &tz->devices);
436 if (ACPI_FAILURE(status)) 428 if (ACPI_FAILURE(status))
437 return_VALUE(-ENODEV); 429 return -ENODEV;
438 430
439 return_VALUE(0); 431 return 0;
440} 432}
441 433
442static int acpi_thermal_call_usermode(char *path) 434static int acpi_thermal_call_usermode(char *path)
@@ -444,10 +436,9 @@ static int acpi_thermal_call_usermode(char *path)
444 char *argv[2] = { NULL, NULL }; 436 char *argv[2] = { NULL, NULL };
445 char *envp[3] = { NULL, NULL, NULL }; 437 char *envp[3] = { NULL, NULL, NULL };
446 438
447 ACPI_FUNCTION_TRACE("acpi_thermal_call_usermode");
448 439
449 if (!path) 440 if (!path)
450 return_VALUE(-EINVAL); 441 return -EINVAL;
451 442
452 argv[0] = path; 443 argv[0] = path;
453 444
@@ -457,7 +448,7 @@ static int acpi_thermal_call_usermode(char *path)
457 448
458 call_usermodehelper(argv[0], argv, envp, 0); 449 call_usermodehelper(argv[0], argv, envp, 0);
459 450
460 return_VALUE(0); 451 return 0;
461} 452}
462 453
463static int acpi_thermal_critical(struct acpi_thermal *tz) 454static int acpi_thermal_critical(struct acpi_thermal *tz)
@@ -465,20 +456,19 @@ static int acpi_thermal_critical(struct acpi_thermal *tz)
465 int result = 0; 456 int result = 0;
466 struct acpi_device *device = NULL; 457 struct acpi_device *device = NULL;
467 458
468 ACPI_FUNCTION_TRACE("acpi_thermal_critical");
469 459
470 if (!tz || !tz->trips.critical.flags.valid) 460 if (!tz || !tz->trips.critical.flags.valid)
471 return_VALUE(-EINVAL); 461 return -EINVAL;
472 462
473 if (tz->temperature >= tz->trips.critical.temperature) { 463 if (tz->temperature >= tz->trips.critical.temperature) {
474 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Critical trip point\n")); 464 printk(KERN_WARNING PREFIX "Critical trip point\n");
475 tz->trips.critical.flags.enabled = 1; 465 tz->trips.critical.flags.enabled = 1;
476 } else if (tz->trips.critical.flags.enabled) 466 } else if (tz->trips.critical.flags.enabled)
477 tz->trips.critical.flags.enabled = 0; 467 tz->trips.critical.flags.enabled = 0;
478 468
479 result = acpi_bus_get_device(tz->handle, &device); 469 result = acpi_bus_get_device(tz->handle, &device);
480 if (result) 470 if (result)
481 return_VALUE(result); 471 return result;
482 472
483 printk(KERN_EMERG 473 printk(KERN_EMERG
484 "Critical temperature reached (%ld C), shutting down.\n", 474 "Critical temperature reached (%ld C), shutting down.\n",
@@ -488,7 +478,7 @@ static int acpi_thermal_critical(struct acpi_thermal *tz)
488 478
489 acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF); 479 acpi_thermal_call_usermode(ACPI_THERMAL_PATH_POWEROFF);
490 480
491 return_VALUE(0); 481 return 0;
492} 482}
493 483
494static int acpi_thermal_hot(struct acpi_thermal *tz) 484static int acpi_thermal_hot(struct acpi_thermal *tz)
@@ -496,27 +486,26 @@ static int acpi_thermal_hot(struct acpi_thermal *tz)
496 int result = 0; 486 int result = 0;
497 struct acpi_device *device = NULL; 487 struct acpi_device *device = NULL;
498 488
499 ACPI_FUNCTION_TRACE("acpi_thermal_hot");
500 489
501 if (!tz || !tz->trips.hot.flags.valid) 490 if (!tz || !tz->trips.hot.flags.valid)
502 return_VALUE(-EINVAL); 491 return -EINVAL;
503 492
504 if (tz->temperature >= tz->trips.hot.temperature) { 493 if (tz->temperature >= tz->trips.hot.temperature) {
505 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Hot trip point\n")); 494 printk(KERN_WARNING PREFIX "Hot trip point\n");
506 tz->trips.hot.flags.enabled = 1; 495 tz->trips.hot.flags.enabled = 1;
507 } else if (tz->trips.hot.flags.enabled) 496 } else if (tz->trips.hot.flags.enabled)
508 tz->trips.hot.flags.enabled = 0; 497 tz->trips.hot.flags.enabled = 0;
509 498
510 result = acpi_bus_get_device(tz->handle, &device); 499 result = acpi_bus_get_device(tz->handle, &device);
511 if (result) 500 if (result)
512 return_VALUE(result); 501 return result;
513 502
514 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT, 503 acpi_bus_generate_event(device, ACPI_THERMAL_NOTIFY_HOT,
515 tz->trips.hot.flags.enabled); 504 tz->trips.hot.flags.enabled);
516 505
517 /* TBD: Call user-mode "sleep(S4)" function */ 506 /* TBD: Call user-mode "sleep(S4)" function */
518 507
519 return_VALUE(0); 508 return 0;
520} 509}
521 510
522static void acpi_thermal_passive(struct acpi_thermal *tz) 511static void acpi_thermal_passive(struct acpi_thermal *tz)
@@ -526,7 +515,6 @@ static void acpi_thermal_passive(struct acpi_thermal *tz)
526 int trend = 0; 515 int trend = 0;
527 int i = 0; 516 int i = 0;
528 517
529 ACPI_FUNCTION_TRACE("acpi_thermal_passive");
530 518
531 if (!tz || !tz->trips.passive.flags.valid) 519 if (!tz || !tz->trips.passive.flags.valid)
532 return; 520 return;
@@ -615,7 +603,6 @@ static void acpi_thermal_active(struct acpi_thermal *tz)
615 int j = 0; 603 int j = 0;
616 unsigned long maxtemp = 0; 604 unsigned long maxtemp = 0;
617 605
618 ACPI_FUNCTION_TRACE("acpi_thermal_active");
619 606
620 if (!tz) 607 if (!tz)
621 return; 608 return;
@@ -642,10 +629,10 @@ static void acpi_thermal_active(struct acpi_thermal *tz)
642 handles[j], 629 handles[j],
643 ACPI_STATE_D0); 630 ACPI_STATE_D0);
644 if (result) { 631 if (result) {
645 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 632 printk(KERN_WARNING PREFIX
646 "Unable to turn cooling device [%p] 'on'\n", 633 "Unable to turn cooling device [%p] 'on'\n",
647 active->devices. 634 active->devices.
648 handles[j])); 635 handles[j]);
649 continue; 636 continue;
650 } 637 }
651 active->flags.enabled = 1; 638 active->flags.enabled = 1;
@@ -667,9 +654,9 @@ static void acpi_thermal_active(struct acpi_thermal *tz)
667 result = acpi_bus_set_power(active->devices.handles[j], 654 result = acpi_bus_set_power(active->devices.handles[j],
668 ACPI_STATE_D3); 655 ACPI_STATE_D3);
669 if (result) { 656 if (result) {
670 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 657 printk(KERN_WARNING PREFIX
671 "Unable to turn cooling device [%p] 'off'\n", 658 "Unable to turn cooling device [%p] 'off'\n",
672 active->devices.handles[j])); 659 active->devices.handles[j]);
673 continue; 660 continue;
674 } 661 }
675 active->flags.enabled = 0; 662 active->flags.enabled = 0;
@@ -697,18 +684,17 @@ static void acpi_thermal_check(void *data)
697 int i = 0; 684 int i = 0;
698 struct acpi_thermal_state state; 685 struct acpi_thermal_state state;
699 686
700 ACPI_FUNCTION_TRACE("acpi_thermal_check");
701 687
702 if (!tz) { 688 if (!tz) {
703 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid (NULL) context.\n")); 689 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
704 return_VOID; 690 return;
705 } 691 }
706 692
707 state = tz->state; 693 state = tz->state;
708 694
709 result = acpi_thermal_get_temperature(tz); 695 result = acpi_thermal_get_temperature(tz);
710 if (result) 696 if (result)
711 return_VOID; 697 return;
712 698
713 memset(&tz->state, 0, sizeof(tz->state)); 699 memset(&tz->state, 0, sizeof(tz->state));
714 700
@@ -797,7 +783,7 @@ static void acpi_thermal_check(void *data)
797 } 783 }
798 } 784 }
799 785
800 return_VOID; 786 return;
801} 787}
802 788
803/* -------------------------------------------------------------------------- 789/* --------------------------------------------------------------------------
@@ -810,7 +796,6 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
810{ 796{
811 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 797 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
812 798
813 ACPI_FUNCTION_TRACE("acpi_thermal_state_seq_show");
814 799
815 if (!tz) 800 if (!tz)
816 goto end; 801 goto end;
@@ -833,7 +818,7 @@ static int acpi_thermal_state_seq_show(struct seq_file *seq, void *offset)
833 } 818 }
834 819
835 end: 820 end:
836 return_VALUE(0); 821 return 0;
837} 822}
838 823
839static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file) 824static int acpi_thermal_state_open_fs(struct inode *inode, struct file *file)
@@ -846,7 +831,6 @@ static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
846 int result = 0; 831 int result = 0;
847 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 832 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
848 833
849 ACPI_FUNCTION_TRACE("acpi_thermal_temp_seq_show");
850 834
851 if (!tz) 835 if (!tz)
852 goto end; 836 goto end;
@@ -859,7 +843,7 @@ static int acpi_thermal_temp_seq_show(struct seq_file *seq, void *offset)
859 KELVIN_TO_CELSIUS(tz->temperature)); 843 KELVIN_TO_CELSIUS(tz->temperature));
860 844
861 end: 845 end:
862 return_VALUE(0); 846 return 0;
863} 847}
864 848
865static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file) 849static int acpi_thermal_temp_open_fs(struct inode *inode, struct file *file)
@@ -873,7 +857,6 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
873 int i = 0; 857 int i = 0;
874 int j = 0; 858 int j = 0;
875 859
876 ACPI_FUNCTION_TRACE("acpi_thermal_trip_seq_show");
877 860
878 if (!tz) 861 if (!tz)
879 goto end; 862 goto end;
@@ -913,7 +896,7 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
913 } 896 }
914 897
915 end: 898 end:
916 return_VALUE(0); 899 return 0;
917} 900}
918 901
919static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file) 902static int acpi_thermal_trip_open_fs(struct inode *inode, struct file *file)
@@ -934,28 +917,25 @@ acpi_thermal_write_trip_points(struct file *file,
934 int *active; 917 int *active;
935 int i = 0; 918 int i = 0;
936 919
937 ACPI_FUNCTION_TRACE("acpi_thermal_write_trip_points");
938 920
939 limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL); 921 limit_string = kmalloc(ACPI_THERMAL_MAX_LIMIT_STR_LEN, GFP_KERNEL);
940 if (!limit_string) 922 if (!limit_string)
941 return_VALUE(-ENOMEM); 923 return -ENOMEM;
942 924
943 memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN); 925 memset(limit_string, 0, ACPI_THERMAL_MAX_LIMIT_STR_LEN);
944 926
945 active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL); 927 active = kmalloc(ACPI_THERMAL_MAX_ACTIVE * sizeof(int), GFP_KERNEL);
946 if (!active) { 928 if (!active) {
947 kfree(limit_string); 929 kfree(limit_string);
948 return_VALUE(-ENOMEM); 930 return -ENOMEM;
949 } 931 }
950 932
951 if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) { 933 if (!tz || (count > ACPI_THERMAL_MAX_LIMIT_STR_LEN - 1)) {
952 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid argument\n"));
953 count = -EINVAL; 934 count = -EINVAL;
954 goto end; 935 goto end;
955 } 936 }
956 937
957 if (copy_from_user(limit_string, buffer, count)) { 938 if (copy_from_user(limit_string, buffer, count)) {
958 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data\n"));
959 count = -EFAULT; 939 count = -EFAULT;
960 goto end; 940 goto end;
961 } 941 }
@@ -968,7 +948,6 @@ acpi_thermal_write_trip_points(struct file *file,
968 &active[5], &active[6], &active[7], &active[8], 948 &active[5], &active[6], &active[7], &active[8],
969 &active[9]); 949 &active[9]);
970 if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) { 950 if (!(num >= 5 && num < (ACPI_THERMAL_MAX_ACTIVE + 3))) {
971 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid data format\n"));
972 count = -EINVAL; 951 count = -EINVAL;
973 goto end; 952 goto end;
974 } 953 }
@@ -985,14 +964,13 @@ acpi_thermal_write_trip_points(struct file *file,
985 end: 964 end:
986 kfree(active); 965 kfree(active);
987 kfree(limit_string); 966 kfree(limit_string);
988 return_VALUE(count); 967 return count;
989} 968}
990 969
991static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset) 970static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
992{ 971{
993 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 972 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
994 973
995 ACPI_FUNCTION_TRACE("acpi_thermal_cooling_seq_show");
996 974
997 if (!tz) 975 if (!tz)
998 goto end; 976 goto end;
@@ -1008,7 +986,7 @@ static int acpi_thermal_cooling_seq_show(struct seq_file *seq, void *offset)
1008 tz->cooling_mode ? "passive" : "active"); 986 tz->cooling_mode ? "passive" : "active");
1009 987
1010 end: 988 end:
1011 return_VALUE(0); 989 return 0;
1012} 990}
1013 991
1014static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file) 992static int acpi_thermal_cooling_open_fs(struct inode *inode, struct file *file)
@@ -1027,16 +1005,15 @@ acpi_thermal_write_cooling_mode(struct file *file,
1027 int result = 0; 1005 int result = 0;
1028 char mode_string[12] = { '\0' }; 1006 char mode_string[12] = { '\0' };
1029 1007
1030 ACPI_FUNCTION_TRACE("acpi_thermal_write_cooling_mode");
1031 1008
1032 if (!tz || (count > sizeof(mode_string) - 1)) 1009 if (!tz || (count > sizeof(mode_string) - 1))
1033 return_VALUE(-EINVAL); 1010 return -EINVAL;
1034 1011
1035 if (!tz->flags.cooling_mode) 1012 if (!tz->flags.cooling_mode)
1036 return_VALUE(-ENODEV); 1013 return -ENODEV;
1037 1014
1038 if (copy_from_user(mode_string, buffer, count)) 1015 if (copy_from_user(mode_string, buffer, count))
1039 return_VALUE(-EFAULT); 1016 return -EFAULT;
1040 1017
1041 mode_string[count] = '\0'; 1018 mode_string[count] = '\0';
1042 1019
@@ -1044,18 +1021,17 @@ acpi_thermal_write_cooling_mode(struct file *file,
1044 simple_strtoul(mode_string, NULL, 1021 simple_strtoul(mode_string, NULL,
1045 0)); 1022 0));
1046 if (result) 1023 if (result)
1047 return_VALUE(result); 1024 return result;
1048 1025
1049 acpi_thermal_check(tz); 1026 acpi_thermal_check(tz);
1050 1027
1051 return_VALUE(count); 1028 return count;
1052} 1029}
1053 1030
1054static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset) 1031static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
1055{ 1032{
1056 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private; 1033 struct acpi_thermal *tz = (struct acpi_thermal *)seq->private;
1057 1034
1058 ACPI_FUNCTION_TRACE("acpi_thermal_polling_seq_show");
1059 1035
1060 if (!tz) 1036 if (!tz)
1061 goto end; 1037 goto end;
@@ -1069,7 +1045,7 @@ static int acpi_thermal_polling_seq_show(struct seq_file *seq, void *offset)
1069 (tz->polling_frequency / 10)); 1045 (tz->polling_frequency / 10));
1070 1046
1071 end: 1047 end:
1072 return_VALUE(0); 1048 return 0;
1073} 1049}
1074 1050
1075static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file) 1051static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file)
@@ -1089,13 +1065,12 @@ acpi_thermal_write_polling(struct file *file,
1089 char polling_string[12] = { '\0' }; 1065 char polling_string[12] = { '\0' };
1090 int seconds = 0; 1066 int seconds = 0;
1091 1067
1092 ACPI_FUNCTION_TRACE("acpi_thermal_write_polling");
1093 1068
1094 if (!tz || (count > sizeof(polling_string) - 1)) 1069 if (!tz || (count > sizeof(polling_string) - 1))
1095 return_VALUE(-EINVAL); 1070 return -EINVAL;
1096 1071
1097 if (copy_from_user(polling_string, buffer, count)) 1072 if (copy_from_user(polling_string, buffer, count))
1098 return_VALUE(-EFAULT); 1073 return -EFAULT;
1099 1074
1100 polling_string[count] = '\0'; 1075 polling_string[count] = '\0';
1101 1076
@@ -1103,24 +1078,23 @@ acpi_thermal_write_polling(struct file *file,
1103 1078
1104 result = acpi_thermal_set_polling(tz, seconds); 1079 result = acpi_thermal_set_polling(tz, seconds);
1105 if (result) 1080 if (result)
1106 return_VALUE(result); 1081 return result;
1107 1082
1108 acpi_thermal_check(tz); 1083 acpi_thermal_check(tz);
1109 1084
1110 return_VALUE(count); 1085 return count;
1111} 1086}
1112 1087
1113static int acpi_thermal_add_fs(struct acpi_device *device) 1088static int acpi_thermal_add_fs(struct acpi_device *device)
1114{ 1089{
1115 struct proc_dir_entry *entry = NULL; 1090 struct proc_dir_entry *entry = NULL;
1116 1091
1117 ACPI_FUNCTION_TRACE("acpi_thermal_add_fs");
1118 1092
1119 if (!acpi_device_dir(device)) { 1093 if (!acpi_device_dir(device)) {
1120 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 1094 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1121 acpi_thermal_dir); 1095 acpi_thermal_dir);
1122 if (!acpi_device_dir(device)) 1096 if (!acpi_device_dir(device))
1123 return_VALUE(-ENODEV); 1097 return -ENODEV;
1124 acpi_device_dir(device)->owner = THIS_MODULE; 1098 acpi_device_dir(device)->owner = THIS_MODULE;
1125 } 1099 }
1126 1100
@@ -1128,9 +1102,7 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1128 entry = create_proc_entry(ACPI_THERMAL_FILE_STATE, 1102 entry = create_proc_entry(ACPI_THERMAL_FILE_STATE,
1129 S_IRUGO, acpi_device_dir(device)); 1103 S_IRUGO, acpi_device_dir(device));
1130 if (!entry) 1104 if (!entry)
1131 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1105 return -ENODEV;
1132 "Unable to create '%s' fs entry\n",
1133 ACPI_THERMAL_FILE_STATE));
1134 else { 1106 else {
1135 entry->proc_fops = &acpi_thermal_state_fops; 1107 entry->proc_fops = &acpi_thermal_state_fops;
1136 entry->data = acpi_driver_data(device); 1108 entry->data = acpi_driver_data(device);
@@ -1141,9 +1113,7 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1141 entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE, 1113 entry = create_proc_entry(ACPI_THERMAL_FILE_TEMPERATURE,
1142 S_IRUGO, acpi_device_dir(device)); 1114 S_IRUGO, acpi_device_dir(device));
1143 if (!entry) 1115 if (!entry)
1144 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1116 return -ENODEV;
1145 "Unable to create '%s' fs entry\n",
1146 ACPI_THERMAL_FILE_TEMPERATURE));
1147 else { 1117 else {
1148 entry->proc_fops = &acpi_thermal_temp_fops; 1118 entry->proc_fops = &acpi_thermal_temp_fops;
1149 entry->data = acpi_driver_data(device); 1119 entry->data = acpi_driver_data(device);
@@ -1155,9 +1125,7 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1155 S_IFREG | S_IRUGO | S_IWUSR, 1125 S_IFREG | S_IRUGO | S_IWUSR,
1156 acpi_device_dir(device)); 1126 acpi_device_dir(device));
1157 if (!entry) 1127 if (!entry)
1158 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1128 return -ENODEV;
1159 "Unable to create '%s' fs entry\n",
1160 ACPI_THERMAL_FILE_TRIP_POINTS));
1161 else { 1129 else {
1162 entry->proc_fops = &acpi_thermal_trip_fops; 1130 entry->proc_fops = &acpi_thermal_trip_fops;
1163 entry->data = acpi_driver_data(device); 1131 entry->data = acpi_driver_data(device);
@@ -1169,9 +1137,7 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1169 S_IFREG | S_IRUGO | S_IWUSR, 1137 S_IFREG | S_IRUGO | S_IWUSR,
1170 acpi_device_dir(device)); 1138 acpi_device_dir(device));
1171 if (!entry) 1139 if (!entry)
1172 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1140 return -ENODEV;
1173 "Unable to create '%s' fs entry\n",
1174 ACPI_THERMAL_FILE_COOLING_MODE));
1175 else { 1141 else {
1176 entry->proc_fops = &acpi_thermal_cooling_fops; 1142 entry->proc_fops = &acpi_thermal_cooling_fops;
1177 entry->data = acpi_driver_data(device); 1143 entry->data = acpi_driver_data(device);
@@ -1183,21 +1149,18 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1183 S_IFREG | S_IRUGO | S_IWUSR, 1149 S_IFREG | S_IRUGO | S_IWUSR,
1184 acpi_device_dir(device)); 1150 acpi_device_dir(device));
1185 if (!entry) 1151 if (!entry)
1186 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1152 return -ENODEV;
1187 "Unable to create '%s' fs entry\n",
1188 ACPI_THERMAL_FILE_POLLING_FREQ));
1189 else { 1153 else {
1190 entry->proc_fops = &acpi_thermal_polling_fops; 1154 entry->proc_fops = &acpi_thermal_polling_fops;
1191 entry->data = acpi_driver_data(device); 1155 entry->data = acpi_driver_data(device);
1192 entry->owner = THIS_MODULE; 1156 entry->owner = THIS_MODULE;
1193 } 1157 }
1194 1158
1195 return_VALUE(0); 1159 return 0;
1196} 1160}
1197 1161
1198static int acpi_thermal_remove_fs(struct acpi_device *device) 1162static int acpi_thermal_remove_fs(struct acpi_device *device)
1199{ 1163{
1200 ACPI_FUNCTION_TRACE("acpi_thermal_remove_fs");
1201 1164
1202 if (acpi_device_dir(device)) { 1165 if (acpi_device_dir(device)) {
1203 remove_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ, 1166 remove_proc_entry(ACPI_THERMAL_FILE_POLLING_FREQ,
@@ -1214,7 +1177,7 @@ static int acpi_thermal_remove_fs(struct acpi_device *device)
1214 acpi_device_dir(device) = NULL; 1177 acpi_device_dir(device) = NULL;
1215 } 1178 }
1216 1179
1217 return_VALUE(0); 1180 return 0;
1218} 1181}
1219 1182
1220/* -------------------------------------------------------------------------- 1183/* --------------------------------------------------------------------------
@@ -1226,13 +1189,12 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
1226 struct acpi_thermal *tz = (struct acpi_thermal *)data; 1189 struct acpi_thermal *tz = (struct acpi_thermal *)data;
1227 struct acpi_device *device = NULL; 1190 struct acpi_device *device = NULL;
1228 1191
1229 ACPI_FUNCTION_TRACE("acpi_thermal_notify");
1230 1192
1231 if (!tz) 1193 if (!tz)
1232 return_VOID; 1194 return;
1233 1195
1234 if (acpi_bus_get_device(tz->handle, &device)) 1196 if (acpi_bus_get_device(tz->handle, &device))
1235 return_VOID; 1197 return;
1236 1198
1237 switch (event) { 1199 switch (event) {
1238 case ACPI_THERMAL_NOTIFY_TEMPERATURE: 1200 case ACPI_THERMAL_NOTIFY_TEMPERATURE:
@@ -1254,27 +1216,26 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
1254 break; 1216 break;
1255 } 1217 }
1256 1218
1257 return_VOID; 1219 return;
1258} 1220}
1259 1221
1260static int acpi_thermal_get_info(struct acpi_thermal *tz) 1222static int acpi_thermal_get_info(struct acpi_thermal *tz)
1261{ 1223{
1262 int result = 0; 1224 int result = 0;
1263 1225
1264 ACPI_FUNCTION_TRACE("acpi_thermal_get_info");
1265 1226
1266 if (!tz) 1227 if (!tz)
1267 return_VALUE(-EINVAL); 1228 return -EINVAL;
1268 1229
1269 /* Get temperature [_TMP] (required) */ 1230 /* Get temperature [_TMP] (required) */
1270 result = acpi_thermal_get_temperature(tz); 1231 result = acpi_thermal_get_temperature(tz);
1271 if (result) 1232 if (result)
1272 return_VALUE(result); 1233 return result;
1273 1234
1274 /* Get trip points [_CRT, _PSV, etc.] (required) */ 1235 /* Get trip points [_CRT, _PSV, etc.] (required) */
1275 result = acpi_thermal_get_trip_points(tz); 1236 result = acpi_thermal_get_trip_points(tz);
1276 if (result) 1237 if (result)
1277 return_VALUE(result); 1238 return result;
1278 1239
1279 /* Set the cooling mode [_SCP] to active cooling (default) */ 1240 /* Set the cooling mode [_SCP] to active cooling (default) */
1280 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); 1241 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
@@ -1314,7 +1275,7 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz)
1314 if (!result) 1275 if (!result)
1315 tz->flags.devices = 1; 1276 tz->flags.devices = 1;
1316 1277
1317 return_VALUE(0); 1278 return 0;
1318} 1279}
1319 1280
1320static int acpi_thermal_add(struct acpi_device *device) 1281static int acpi_thermal_add(struct acpi_device *device)
@@ -1323,14 +1284,13 @@ static int acpi_thermal_add(struct acpi_device *device)
1323 acpi_status status = AE_OK; 1284 acpi_status status = AE_OK;
1324 struct acpi_thermal *tz = NULL; 1285 struct acpi_thermal *tz = NULL;
1325 1286
1326 ACPI_FUNCTION_TRACE("acpi_thermal_add");
1327 1287
1328 if (!device) 1288 if (!device)
1329 return_VALUE(-EINVAL); 1289 return -EINVAL;
1330 1290
1331 tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL); 1291 tz = kmalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
1332 if (!tz) 1292 if (!tz)
1333 return_VALUE(-ENOMEM); 1293 return -ENOMEM;
1334 memset(tz, 0, sizeof(struct acpi_thermal)); 1294 memset(tz, 0, sizeof(struct acpi_thermal));
1335 1295
1336 tz->handle = device->handle; 1296 tz->handle = device->handle;
@@ -1355,8 +1315,6 @@ static int acpi_thermal_add(struct acpi_device *device)
1355 ACPI_DEVICE_NOTIFY, 1315 ACPI_DEVICE_NOTIFY,
1356 acpi_thermal_notify, tz); 1316 acpi_thermal_notify, tz);
1357 if (ACPI_FAILURE(status)) { 1317 if (ACPI_FAILURE(status)) {
1358 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1359 "Error installing notify handler\n"));
1360 result = -ENODEV; 1318 result = -ENODEV;
1361 goto end; 1319 goto end;
1362 } 1320 }
@@ -1371,7 +1329,7 @@ static int acpi_thermal_add(struct acpi_device *device)
1371 kfree(tz); 1329 kfree(tz);
1372 } 1330 }
1373 1331
1374 return_VALUE(result); 1332 return result;
1375} 1333}
1376 1334
1377static int acpi_thermal_remove(struct acpi_device *device, int type) 1335static int acpi_thermal_remove(struct acpi_device *device, int type)
@@ -1379,10 +1337,9 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
1379 acpi_status status = AE_OK; 1337 acpi_status status = AE_OK;
1380 struct acpi_thermal *tz = NULL; 1338 struct acpi_thermal *tz = NULL;
1381 1339
1382 ACPI_FUNCTION_TRACE("acpi_thermal_remove");
1383 1340
1384 if (!device || !acpi_driver_data(device)) 1341 if (!device || !acpi_driver_data(device))
1385 return_VALUE(-EINVAL); 1342 return -EINVAL;
1386 1343
1387 tz = (struct acpi_thermal *)acpi_driver_data(device); 1344 tz = (struct acpi_thermal *)acpi_driver_data(device);
1388 1345
@@ -1398,9 +1355,6 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
1398 status = acpi_remove_notify_handler(tz->handle, 1355 status = acpi_remove_notify_handler(tz->handle,
1399 ACPI_DEVICE_NOTIFY, 1356 ACPI_DEVICE_NOTIFY,
1400 acpi_thermal_notify); 1357 acpi_thermal_notify);
1401 if (ACPI_FAILURE(status))
1402 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1403 "Error removing notify handler\n"));
1404 1358
1405 /* Terminate policy */ 1359 /* Terminate policy */
1406 if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) { 1360 if (tz->trips.passive.flags.valid && tz->trips.passive.flags.enabled) {
@@ -1416,7 +1370,7 @@ static int acpi_thermal_remove(struct acpi_device *device, int type)
1416 acpi_thermal_remove_fs(device); 1370 acpi_thermal_remove_fs(device);
1417 1371
1418 kfree(tz); 1372 kfree(tz);
1419 return_VALUE(0); 1373 return 0;
1420} 1374}
1421 1375
1422static int acpi_thermal_resume(struct acpi_device *device, int state) 1376static int acpi_thermal_resume(struct acpi_device *device, int state)
@@ -1424,7 +1378,7 @@ static int acpi_thermal_resume(struct acpi_device *device, int state)
1424 struct acpi_thermal *tz = NULL; 1378 struct acpi_thermal *tz = NULL;
1425 1379
1426 if (!device || !acpi_driver_data(device)) 1380 if (!device || !acpi_driver_data(device))
1427 return_VALUE(-EINVAL); 1381 return -EINVAL;
1428 1382
1429 tz = (struct acpi_thermal *)acpi_driver_data(device); 1383 tz = (struct acpi_thermal *)acpi_driver_data(device);
1430 1384
@@ -1437,31 +1391,29 @@ static int __init acpi_thermal_init(void)
1437{ 1391{
1438 int result = 0; 1392 int result = 0;
1439 1393
1440 ACPI_FUNCTION_TRACE("acpi_thermal_init");
1441 1394
1442 acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir); 1395 acpi_thermal_dir = proc_mkdir(ACPI_THERMAL_CLASS, acpi_root_dir);
1443 if (!acpi_thermal_dir) 1396 if (!acpi_thermal_dir)
1444 return_VALUE(-ENODEV); 1397 return -ENODEV;
1445 acpi_thermal_dir->owner = THIS_MODULE; 1398 acpi_thermal_dir->owner = THIS_MODULE;
1446 1399
1447 result = acpi_bus_register_driver(&acpi_thermal_driver); 1400 result = acpi_bus_register_driver(&acpi_thermal_driver);
1448 if (result < 0) { 1401 if (result < 0) {
1449 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); 1402 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
1450 return_VALUE(-ENODEV); 1403 return -ENODEV;
1451 } 1404 }
1452 1405
1453 return_VALUE(0); 1406 return 0;
1454} 1407}
1455 1408
1456static void __exit acpi_thermal_exit(void) 1409static void __exit acpi_thermal_exit(void)
1457{ 1410{
1458 ACPI_FUNCTION_TRACE("acpi_thermal_exit");
1459 1411
1460 acpi_bus_unregister_driver(&acpi_thermal_driver); 1412 acpi_bus_unregister_driver(&acpi_thermal_driver);
1461 1413
1462 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir); 1414 remove_proc_entry(ACPI_THERMAL_CLASS, acpi_root_dir);
1463 1415
1464 return_VOID; 1416 return;
1465} 1417}
1466 1418
1467module_init(acpi_thermal_init); 1419module_init(acpi_thermal_init);
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index 67b9f325c6fa..38ebe1c54330 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -155,21 +155,30 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
155 case ACPI_TYPE_MUTEX: 155 case ACPI_TYPE_MUTEX:
156 156
157 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 157 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
158 "***** Mutex %p, Semaphore %p\n", 158 "***** Mutex %p, OS Mutex %p\n",
159 object, object->mutex.semaphore)); 159 object, object->mutex.os_mutex));
160 160
161 acpi_ex_unlink_mutex(object); 161 if (object->mutex.os_mutex != ACPI_GLOBAL_LOCK) {
162 (void)acpi_os_delete_semaphore(object->mutex.semaphore); 162 acpi_ex_unlink_mutex(object);
163 acpi_os_delete_mutex(object->mutex.os_mutex);
164 } else {
165 /* Global Lock "mutex" is actually a counting semaphore */
166
167 (void)
168 acpi_os_delete_semaphore
169 (acpi_gbl_global_lock_semaphore);
170 acpi_gbl_global_lock_semaphore = NULL;
171 }
163 break; 172 break;
164 173
165 case ACPI_TYPE_EVENT: 174 case ACPI_TYPE_EVENT:
166 175
167 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 176 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
168 "***** Event %p, Semaphore %p\n", 177 "***** Event %p, OS Semaphore %p\n",
169 object, object->event.semaphore)); 178 object, object->event.os_semaphore));
170 179
171 (void)acpi_os_delete_semaphore(object->event.semaphore); 180 (void)acpi_os_delete_semaphore(object->event.os_semaphore);
172 object->event.semaphore = NULL; 181 object->event.os_semaphore = NULL;
173 break; 182 break;
174 183
175 case ACPI_TYPE_METHOD: 184 case ACPI_TYPE_METHOD:
@@ -177,12 +186,13 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object)
177 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, 186 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS,
178 "***** Method %p\n", object)); 187 "***** Method %p\n", object));
179 188
180 /* Delete the method semaphore if it exists */ 189 /* Delete the method mutex if it exists */
181 190
182 if (object->method.semaphore) { 191 if (object->method.mutex) {
183 (void)acpi_os_delete_semaphore(object->method. 192 acpi_os_delete_mutex(object->method.mutex->mutex.
184 semaphore); 193 os_mutex);
185 object->method.semaphore = NULL; 194 acpi_ut_delete_object_desc(object->method.mutex);
195 object->method.mutex = NULL;
186 } 196 }
187 break; 197 break;
188 198
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index e5999c65c0b8..014030af8b50 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -794,6 +794,7 @@ void acpi_ut_init_globals(void)
794 794
795 /* Global Lock support */ 795 /* Global Lock support */
796 796
797 acpi_gbl_global_lock_semaphore = NULL;
797 acpi_gbl_global_lock_acquired = FALSE; 798 acpi_gbl_global_lock_acquired = FALSE;
798 acpi_gbl_global_lock_thread_count = 0; 799 acpi_gbl_global_lock_thread_count = 0;
799 acpi_gbl_global_lock_handle = 0; 800 acpi_gbl_global_lock_handle = 0;
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 5c75d35ad1cd..33268310c738 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -41,6 +41,8 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44#include <linux/module.h>
45
44#include <acpi/acpi.h> 46#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 47#include <acpi/acnamesp.h>
46 48
@@ -962,6 +964,7 @@ acpi_ut_exception(char *module_name,
962 acpi_os_vprintf(format, args); 964 acpi_os_vprintf(format, args);
963 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION); 965 acpi_os_printf(" [%X]\n", ACPI_CA_VERSION);
964} 966}
967EXPORT_SYMBOL(acpi_ut_exception);
965 968
966void ACPI_INTERNAL_VAR_XFACE 969void ACPI_INTERNAL_VAR_XFACE
967acpi_ut_warning(char *module_name, u32 line_number, char *format, ...) 970acpi_ut_warning(char *module_name, u32 line_number, char *format, ...)
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/utilities/utmutex.c
index 25eb34369afa..dfc8f30ca892 100644
--- a/drivers/acpi/utilities/utmutex.c
+++ b/drivers/acpi/utilities/utmutex.c
@@ -82,12 +82,9 @@ acpi_status acpi_ut_mutex_initialize(void)
82 82
83 /* Create the spinlocks for use at interrupt level */ 83 /* Create the spinlocks for use at interrupt level */
84 84
85 status = acpi_os_create_lock(&acpi_gbl_gpe_lock); 85 spin_lock_init(acpi_gbl_gpe_lock);
86 if (ACPI_FAILURE(status)) { 86 spin_lock_init(acpi_gbl_hardware_lock);
87 return_ACPI_STATUS(status);
88 }
89 87
90 status = acpi_os_create_lock(&acpi_gbl_hardware_lock);
91 return_ACPI_STATUS(status); 88 return_ACPI_STATUS(status);
92} 89}
93 90
@@ -146,9 +143,8 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
146 } 143 }
147 144
148 if (!acpi_gbl_mutex_info[mutex_id].mutex) { 145 if (!acpi_gbl_mutex_info[mutex_id].mutex) {
149 status = acpi_os_create_semaphore(1, 1, 146 status =
150 &acpi_gbl_mutex_info 147 acpi_os_create_mutex(&acpi_gbl_mutex_info[mutex_id].mutex);
151 [mutex_id].mutex);
152 acpi_gbl_mutex_info[mutex_id].thread_id = 148 acpi_gbl_mutex_info[mutex_id].thread_id =
153 ACPI_MUTEX_NOT_ACQUIRED; 149 ACPI_MUTEX_NOT_ACQUIRED;
154 acpi_gbl_mutex_info[mutex_id].use_count = 0; 150 acpi_gbl_mutex_info[mutex_id].use_count = 0;
@@ -171,7 +167,6 @@ static acpi_status acpi_ut_create_mutex(acpi_mutex_handle mutex_id)
171 167
172static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id) 168static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
173{ 169{
174 acpi_status status;
175 170
176 ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id); 171 ACPI_FUNCTION_TRACE_U32(ut_delete_mutex, mutex_id);
177 172
@@ -179,12 +174,12 @@ static acpi_status acpi_ut_delete_mutex(acpi_mutex_handle mutex_id)
179 return_ACPI_STATUS(AE_BAD_PARAMETER); 174 return_ACPI_STATUS(AE_BAD_PARAMETER);
180 } 175 }
181 176
182 status = acpi_os_delete_semaphore(acpi_gbl_mutex_info[mutex_id].mutex); 177 acpi_os_delete_mutex(acpi_gbl_mutex_info[mutex_id].mutex);
183 178
184 acpi_gbl_mutex_info[mutex_id].mutex = NULL; 179 acpi_gbl_mutex_info[mutex_id].mutex = NULL;
185 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 180 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
186 181
187 return_ACPI_STATUS(status); 182 return_ACPI_STATUS(AE_OK);
188} 183}
189 184
190/******************************************************************************* 185/*******************************************************************************
@@ -251,8 +246,8 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
251 "Thread %X attempting to acquire Mutex [%s]\n", 246 "Thread %X attempting to acquire Mutex [%s]\n",
252 this_thread_id, acpi_ut_get_mutex_name(mutex_id))); 247 this_thread_id, acpi_ut_get_mutex_name(mutex_id)));
253 248
254 status = acpi_os_wait_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 249 status = acpi_os_acquire_mutex(acpi_gbl_mutex_info[mutex_id].mutex,
255 1, ACPI_WAIT_FOREVER); 250 ACPI_WAIT_FOREVER);
256 if (ACPI_SUCCESS(status)) { 251 if (ACPI_SUCCESS(status)) {
257 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, 252 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
258 "Thread %X acquired Mutex [%s]\n", 253 "Thread %X acquired Mutex [%s]\n",
@@ -284,7 +279,6 @@ acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id)
284 279
285acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id) 280acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
286{ 281{
287 acpi_status status;
288 acpi_thread_id this_thread_id; 282 acpi_thread_id this_thread_id;
289 283
290 ACPI_FUNCTION_NAME(ut_release_mutex); 284 ACPI_FUNCTION_NAME(ut_release_mutex);
@@ -340,19 +334,6 @@ acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id)
340 334
341 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED; 335 acpi_gbl_mutex_info[mutex_id].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
342 336
343 status = 337 acpi_os_release_mutex(acpi_gbl_mutex_info[mutex_id].mutex);
344 acpi_os_signal_semaphore(acpi_gbl_mutex_info[mutex_id].mutex, 1); 338 return (AE_OK);
345
346 if (ACPI_FAILURE(status)) {
347 ACPI_EXCEPTION((AE_INFO, status,
348 "Thread %X could not release Mutex [%X]",
349 this_thread_id, mutex_id));
350 } else {
351 ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
352 "Thread %X released Mutex [%s]\n",
353 this_thread_id,
354 acpi_ut_get_mutex_name(mutex_id)));
355 }
356
357 return (status);
358} 339}
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 6b516852ac12..1930e1a75b22 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -58,31 +58,29 @@ acpi_extract_package(union acpi_object *package,
58 u8 *head = NULL; 58 u8 *head = NULL;
59 u8 *tail = NULL; 59 u8 *tail = NULL;
60 60
61 ACPI_FUNCTION_TRACE("acpi_extract_package");
62 61
63 if (!package || (package->type != ACPI_TYPE_PACKAGE) 62 if (!package || (package->type != ACPI_TYPE_PACKAGE)
64 || (package->package.count < 1)) { 63 || (package->package.count < 1)) {
65 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 64 printk(KERN_WARNING PREFIX "Invalid package argument\n");
66 "Invalid 'package' argument\n")); 65 return AE_BAD_PARAMETER;
67 return_ACPI_STATUS(AE_BAD_PARAMETER);
68 } 66 }
69 67
70 if (!format || !format->pointer || (format->length < 1)) { 68 if (!format || !format->pointer || (format->length < 1)) {
71 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n")); 69 printk(KERN_WARNING PREFIX "Invalid format argument\n");
72 return_ACPI_STATUS(AE_BAD_PARAMETER); 70 return AE_BAD_PARAMETER;
73 } 71 }
74 72
75 if (!buffer) { 73 if (!buffer) {
76 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n")); 74 printk(KERN_WARNING PREFIX "Invalid buffer argument\n");
77 return_ACPI_STATUS(AE_BAD_PARAMETER); 75 return AE_BAD_PARAMETER;
78 } 76 }
79 77
80 format_count = (format->length / sizeof(char)) - 1; 78 format_count = (format->length / sizeof(char)) - 1;
81 if (format_count > package->package.count) { 79 if (format_count > package->package.count) {
82 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 80 printk(KERN_WARNING PREFIX "Format specifies more objects [%d]"
83 "Format specifies more objects [%d] than exist in package [%d].", 81 " than exist in package [%d].\n",
84 format_count, package->package.count)); 82 format_count, package->package.count);
85 return_ACPI_STATUS(AE_BAD_DATA); 83 return AE_BAD_DATA;
86 } 84 }
87 85
88 format_string = (char *)format->pointer; 86 format_string = (char *)format->pointer;
@@ -95,7 +93,7 @@ acpi_extract_package(union acpi_object *package,
95 union acpi_object *element = &(package->package.elements[i]); 93 union acpi_object *element = &(package->package.elements[i]);
96 94
97 if (!element) { 95 if (!element) {
98 return_ACPI_STATUS(AE_BAD_DATA); 96 return AE_BAD_DATA;
99 } 97 }
100 98
101 switch (element->type) { 99 switch (element->type) {
@@ -113,10 +111,11 @@ acpi_extract_package(union acpi_object *package,
113 tail_offset += sizeof(char *); 111 tail_offset += sizeof(char *);
114 break; 112 break;
115 default: 113 default:
116 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 114 printk(KERN_WARNING PREFIX "Invalid package element"
117 "Invalid package element [%d]: got number, expecing [%c].\n", 115 " [%d]: got number, expecing"
118 i, format_string[i])); 116 " [%c]\n",
119 return_ACPI_STATUS(AE_BAD_DATA); 117 i, format_string[i]);
118 return AE_BAD_DATA;
120 break; 119 break;
121 } 120 }
122 break; 121 break;
@@ -138,10 +137,11 @@ acpi_extract_package(union acpi_object *package,
138 tail_offset += sizeof(u8 *); 137 tail_offset += sizeof(u8 *);
139 break; 138 break;
140 default: 139 default:
141 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 140 printk(KERN_WARNING PREFIX "Invalid package element"
142 "Invalid package element [%d] got string/buffer, expecing [%c].\n", 141 " [%d] got string/buffer,"
143 i, format_string[i])); 142 " expecing [%c]\n",
144 return_ACPI_STATUS(AE_BAD_DATA); 143 i, format_string[i]);
144 return AE_BAD_DATA;
145 break; 145 break;
146 } 146 }
147 break; 147 break;
@@ -152,7 +152,7 @@ acpi_extract_package(union acpi_object *package,
152 "Found unsupported element at index=%d\n", 152 "Found unsupported element at index=%d\n",
153 i)); 153 i));
154 /* TBD: handle nested packages... */ 154 /* TBD: handle nested packages... */
155 return_ACPI_STATUS(AE_SUPPORT); 155 return AE_SUPPORT;
156 break; 156 break;
157 } 157 }
158 } 158 }
@@ -162,9 +162,9 @@ acpi_extract_package(union acpi_object *package,
162 */ 162 */
163 if (buffer->length < size_required) { 163 if (buffer->length < size_required) {
164 buffer->length = size_required; 164 buffer->length = size_required;
165 return_ACPI_STATUS(AE_BUFFER_OVERFLOW); 165 return AE_BUFFER_OVERFLOW;
166 } else if (buffer->length != size_required || !buffer->pointer) { 166 } else if (buffer->length != size_required || !buffer->pointer) {
167 return_ACPI_STATUS(AE_BAD_PARAMETER); 167 return AE_BAD_PARAMETER;
168 } 168 }
169 169
170 head = buffer->pointer; 170 head = buffer->pointer;
@@ -179,7 +179,7 @@ acpi_extract_package(union acpi_object *package,
179 union acpi_object *element = &(package->package.elements[i]); 179 union acpi_object *element = &(package->package.elements[i]);
180 180
181 if (!element) { 181 if (!element) {
182 return_ACPI_STATUS(AE_BAD_DATA); 182 return AE_BAD_DATA;
183 } 183 }
184 184
185 switch (element->type) { 185 switch (element->type) {
@@ -244,7 +244,7 @@ acpi_extract_package(union acpi_object *package,
244 } 244 }
245 } 245 }
246 246
247 return_ACPI_STATUS(AE_OK); 247 return AE_OK;
248} 248}
249 249
250EXPORT_SYMBOL(acpi_extract_package); 250EXPORT_SYMBOL(acpi_extract_package);
@@ -258,14 +258,13 @@ acpi_evaluate_integer(acpi_handle handle,
258 union acpi_object *element; 258 union acpi_object *element;
259 struct acpi_buffer buffer = { 0, NULL }; 259 struct acpi_buffer buffer = { 0, NULL };
260 260
261 ACPI_FUNCTION_TRACE("acpi_evaluate_integer");
262 261
263 if (!data) 262 if (!data)
264 return_ACPI_STATUS(AE_BAD_PARAMETER); 263 return AE_BAD_PARAMETER;
265 264
266 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL); 265 element = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
267 if (!element) 266 if (!element)
268 return_ACPI_STATUS(AE_NO_MEMORY); 267 return AE_NO_MEMORY;
269 268
270 memset(element, 0, sizeof(union acpi_object)); 269 memset(element, 0, sizeof(union acpi_object));
271 buffer.length = sizeof(union acpi_object); 270 buffer.length = sizeof(union acpi_object);
@@ -274,13 +273,13 @@ acpi_evaluate_integer(acpi_handle handle,
274 if (ACPI_FAILURE(status)) { 273 if (ACPI_FAILURE(status)) {
275 acpi_util_eval_error(handle, pathname, status); 274 acpi_util_eval_error(handle, pathname, status);
276 kfree(element); 275 kfree(element);
277 return_ACPI_STATUS(status); 276 return status;
278 } 277 }
279 278
280 if (element->type != ACPI_TYPE_INTEGER) { 279 if (element->type != ACPI_TYPE_INTEGER) {
281 acpi_util_eval_error(handle, pathname, AE_BAD_DATA); 280 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
282 kfree(element); 281 kfree(element);
283 return_ACPI_STATUS(AE_BAD_DATA); 282 return AE_BAD_DATA;
284 } 283 }
285 284
286 *data = element->integer.value; 285 *data = element->integer.value;
@@ -288,7 +287,7 @@ acpi_evaluate_integer(acpi_handle handle,
288 287
289 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data)); 288 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data));
290 289
291 return_ACPI_STATUS(AE_OK); 290 return AE_OK;
292} 291}
293 292
294EXPORT_SYMBOL(acpi_evaluate_integer); 293EXPORT_SYMBOL(acpi_evaluate_integer);
@@ -303,15 +302,14 @@ acpi_evaluate_string(acpi_handle handle,
303 acpi_object *element = NULL; 302 acpi_object *element = NULL;
304 acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 303 acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
305 304
306 ACPI_FUNCTION_TRACE("acpi_evaluate_string");
307 305
308 if (!data) 306 if (!data)
309 return_ACPI_STATUS(AE_BAD_PARAMETER); 307 return AE_BAD_PARAMETER;
310 308
311 status = acpi_evaluate_object(handle, pathname, arguments, &buffer); 309 status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
312 if (ACPI_FAILURE(status)) { 310 if (ACPI_FAILURE(status)) {
313 acpi_util_eval_error(handle, pathname, status); 311 acpi_util_eval_error(handle, pathname, status);
314 return_ACPI_STATUS(status); 312 return status;
315 } 313 }
316 314
317 element = (acpi_object *) buffer.pointer; 315 element = (acpi_object *) buffer.pointer;
@@ -320,13 +318,13 @@ acpi_evaluate_string(acpi_handle handle,
320 || (element->type != ACPI_TYPE_BUFFER) 318 || (element->type != ACPI_TYPE_BUFFER)
321 || !element->string.length) { 319 || !element->string.length) {
322 acpi_util_eval_error(handle, pathname, AE_BAD_DATA); 320 acpi_util_eval_error(handle, pathname, AE_BAD_DATA);
323 return_ACPI_STATUS(AE_BAD_DATA); 321 return AE_BAD_DATA;
324 } 322 }
325 323
326 *data = kmalloc(element->string.length + 1, GFP_KERNEL); 324 *data = kmalloc(element->string.length + 1, GFP_KERNEL);
327 if (!data) { 325 if (!data) {
328 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n")); 326 printk(KERN_ERR PREFIX "Memory allocation\n");
329 return_VALUE(-ENOMEM); 327 return -ENOMEM;
330 } 328 }
331 memset(*data, 0, element->string.length + 1); 329 memset(*data, 0, element->string.length + 1);
332 330
@@ -336,7 +334,7 @@ acpi_evaluate_string(acpi_handle handle,
336 334
337 acpi_os_free(buffer.pointer); 335 acpi_os_free(buffer.pointer);
338 336
339 return_ACPI_STATUS(AE_OK); 337 return AE_OK;
340} 338}
341#endif 339#endif
342 340
@@ -352,10 +350,9 @@ acpi_evaluate_reference(acpi_handle handle,
352 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 350 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
353 u32 i = 0; 351 u32 i = 0;
354 352
355 ACPI_FUNCTION_TRACE("acpi_evaluate_reference");
356 353
357 if (!list) { 354 if (!list) {
358 return_ACPI_STATUS(AE_BAD_PARAMETER); 355 return AE_BAD_PARAMETER;
359 } 356 }
360 357
361 /* Evaluate object. */ 358 /* Evaluate object. */
@@ -367,32 +364,29 @@ acpi_evaluate_reference(acpi_handle handle,
367 package = (union acpi_object *)buffer.pointer; 364 package = (union acpi_object *)buffer.pointer;
368 365
369 if ((buffer.length == 0) || !package) { 366 if ((buffer.length == 0) || !package) {
370 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 367 printk(KERN_ERR PREFIX "No return object (len %X ptr %p)\n",
371 "No return object (len %X ptr %p)\n", 368 (unsigned)buffer.length, package);
372 (unsigned)buffer.length, package));
373 status = AE_BAD_DATA; 369 status = AE_BAD_DATA;
374 acpi_util_eval_error(handle, pathname, status); 370 acpi_util_eval_error(handle, pathname, status);
375 goto end; 371 goto end;
376 } 372 }
377 if (package->type != ACPI_TYPE_PACKAGE) { 373 if (package->type != ACPI_TYPE_PACKAGE) {
378 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 374 printk(KERN_ERR PREFIX "Expecting a [Package], found type %X\n",
379 "Expecting a [Package], found type %X\n", 375 package->type);
380 package->type));
381 status = AE_BAD_DATA; 376 status = AE_BAD_DATA;
382 acpi_util_eval_error(handle, pathname, status); 377 acpi_util_eval_error(handle, pathname, status);
383 goto end; 378 goto end;
384 } 379 }
385 if (!package->package.count) { 380 if (!package->package.count) {
386 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 381 printk(KERN_ERR PREFIX "[Package] has zero elements (%p)\n",
387 "[Package] has zero elements (%p)\n", 382 package);
388 package));
389 status = AE_BAD_DATA; 383 status = AE_BAD_DATA;
390 acpi_util_eval_error(handle, pathname, status); 384 acpi_util_eval_error(handle, pathname, status);
391 goto end; 385 goto end;
392 } 386 }
393 387
394 if (package->package.count > ACPI_MAX_HANDLES) { 388 if (package->package.count > ACPI_MAX_HANDLES) {
395 return_ACPI_STATUS(AE_NO_MEMORY); 389 return AE_NO_MEMORY;
396 } 390 }
397 list->count = package->package.count; 391 list->count = package->package.count;
398 392
@@ -404,9 +398,9 @@ acpi_evaluate_reference(acpi_handle handle,
404 398
405 if (element->type != ACPI_TYPE_ANY) { 399 if (element->type != ACPI_TYPE_ANY) {
406 status = AE_BAD_DATA; 400 status = AE_BAD_DATA;
407 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 401 printk(KERN_ERR PREFIX
408 "Expecting a [Reference] package element, found type %X\n", 402 "Expecting a [Reference] package element, found type %X\n",
409 element->type)); 403 element->type);
410 acpi_util_eval_error(handle, pathname, status); 404 acpi_util_eval_error(handle, pathname, status);
411 break; 405 break;
412 } 406 }
@@ -426,7 +420,7 @@ acpi_evaluate_reference(acpi_handle handle,
426 420
427 acpi_os_free(buffer.pointer); 421 acpi_os_free(buffer.pointer);
428 422
429 return_ACPI_STATUS(status); 423 return status;
430} 424}
431 425
432EXPORT_SYMBOL(acpi_evaluate_reference); 426EXPORT_SYMBOL(acpi_evaluate_reference);
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index e7e9a693953a..9feb633087a9 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -272,10 +272,9 @@ static int
272acpi_video_device_query(struct acpi_video_device *device, unsigned long *state) 272acpi_video_device_query(struct acpi_video_device *device, unsigned long *state)
273{ 273{
274 int status; 274 int status;
275 ACPI_FUNCTION_TRACE("acpi_video_device_query");
276 status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state); 275 status = acpi_evaluate_integer(device->handle, "_DGS", NULL, state);
277 276
278 return_VALUE(status); 277 return status;
279} 278}
280 279
281static int 280static int
@@ -284,11 +283,10 @@ acpi_video_device_get_state(struct acpi_video_device *device,
284{ 283{
285 int status; 284 int status;
286 285
287 ACPI_FUNCTION_TRACE("acpi_video_device_get_state");
288 286
289 status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state); 287 status = acpi_evaluate_integer(device->handle, "_DCS", NULL, state);
290 288
291 return_VALUE(status); 289 return status;
292} 290}
293 291
294static int 292static int
@@ -299,12 +297,11 @@ acpi_video_device_set_state(struct acpi_video_device *device, int state)
299 struct acpi_object_list args = { 1, &arg0 }; 297 struct acpi_object_list args = { 1, &arg0 };
300 unsigned long ret; 298 unsigned long ret;
301 299
302 ACPI_FUNCTION_TRACE("acpi_video_device_set_state");
303 300
304 arg0.integer.value = state; 301 arg0.integer.value = state;
305 status = acpi_evaluate_integer(device->handle, "_DSS", &args, &ret); 302 status = acpi_evaluate_integer(device->handle, "_DSS", &args, &ret);
306 303
307 return_VALUE(status); 304 return status;
308} 305}
309 306
310static int 307static int
@@ -315,28 +312,27 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
315 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 312 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
316 union acpi_object *obj; 313 union acpi_object *obj;
317 314
318 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_query_levels");
319 315
320 *levels = NULL; 316 *levels = NULL;
321 317
322 status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer); 318 status = acpi_evaluate_object(device->handle, "_BCL", NULL, &buffer);
323 if (!ACPI_SUCCESS(status)) 319 if (!ACPI_SUCCESS(status))
324 return_VALUE(status); 320 return status;
325 obj = (union acpi_object *)buffer.pointer; 321 obj = (union acpi_object *)buffer.pointer;
326 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { 322 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) {
327 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _BCL data\n")); 323 printk(KERN_ERR PREFIX "Invalid _BCL data\n");
328 status = -EFAULT; 324 status = -EFAULT;
329 goto err; 325 goto err;
330 } 326 }
331 327
332 *levels = obj; 328 *levels = obj;
333 329
334 return_VALUE(0); 330 return 0;
335 331
336 err: 332 err:
337 kfree(buffer.pointer); 333 kfree(buffer.pointer);
338 334
339 return_VALUE(status); 335 return status;
340} 336}
341 337
342static int 338static int
@@ -346,13 +342,12 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
346 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 342 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
347 struct acpi_object_list args = { 1, &arg0 }; 343 struct acpi_object_list args = { 1, &arg0 };
348 344
349 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_set_level");
350 345
351 arg0.integer.value = level; 346 arg0.integer.value = level;
352 status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL); 347 status = acpi_evaluate_object(device->handle, "_BCM", &args, NULL);
353 348
354 printk(KERN_DEBUG "set_level status: %x\n", status); 349 printk(KERN_DEBUG "set_level status: %x\n", status);
355 return_VALUE(status); 350 return status;
356} 351}
357 352
358static int 353static int
@@ -360,11 +355,10 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
360 unsigned long *level) 355 unsigned long *level)
361{ 356{
362 int status; 357 int status;
363 ACPI_FUNCTION_TRACE("acpi_video_device_lcd_get_level_current");
364 358
365 status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level); 359 status = acpi_evaluate_integer(device->handle, "_BQC", NULL, level);
366 360
367 return_VALUE(status); 361 return status;
368} 362}
369 363
370static int 364static int
@@ -377,34 +371,33 @@ acpi_video_device_EDID(struct acpi_video_device *device,
377 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 371 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
378 struct acpi_object_list args = { 1, &arg0 }; 372 struct acpi_object_list args = { 1, &arg0 };
379 373
380 ACPI_FUNCTION_TRACE("acpi_video_device_get_EDID");
381 374
382 *edid = NULL; 375 *edid = NULL;
383 376
384 if (!device) 377 if (!device)
385 return_VALUE(-ENODEV); 378 return -ENODEV;
386 if (length == 128) 379 if (length == 128)
387 arg0.integer.value = 1; 380 arg0.integer.value = 1;
388 else if (length == 256) 381 else if (length == 256)
389 arg0.integer.value = 2; 382 arg0.integer.value = 2;
390 else 383 else
391 return_VALUE(-EINVAL); 384 return -EINVAL;
392 385
393 status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer); 386 status = acpi_evaluate_object(device->handle, "_DDC", &args, &buffer);
394 if (ACPI_FAILURE(status)) 387 if (ACPI_FAILURE(status))
395 return_VALUE(-ENODEV); 388 return -ENODEV;
396 389
397 obj = (union acpi_object *)buffer.pointer; 390 obj = (union acpi_object *)buffer.pointer;
398 391
399 if (obj && obj->type == ACPI_TYPE_BUFFER) 392 if (obj && obj->type == ACPI_TYPE_BUFFER)
400 *edid = obj; 393 *edid = obj;
401 else { 394 else {
402 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DDC data\n")); 395 printk(KERN_ERR PREFIX "Invalid _DDC data\n");
403 status = -EFAULT; 396 status = -EFAULT;
404 kfree(obj); 397 kfree(obj);
405 } 398 }
406 399
407 return_VALUE(status); 400 return status;
408} 401}
409 402
410/* bus */ 403/* bus */
@@ -417,7 +410,6 @@ acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
417 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 410 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
418 struct acpi_object_list args = { 1, &arg0 }; 411 struct acpi_object_list args = { 1, &arg0 };
419 412
420 ACPI_FUNCTION_TRACE("acpi_video_bus_set_POST");
421 413
422 arg0.integer.value = option; 414 arg0.integer.value = option;
423 415
@@ -425,7 +417,7 @@ acpi_video_bus_set_POST(struct acpi_video_bus *video, unsigned long option)
425 if (ACPI_SUCCESS(status)) 417 if (ACPI_SUCCESS(status))
426 status = tmp ? (-EINVAL) : (AE_OK); 418 status = tmp ? (-EINVAL) : (AE_OK);
427 419
428 return_VALUE(status); 420 return status;
429} 421}
430 422
431static int 423static int
@@ -433,11 +425,10 @@ acpi_video_bus_get_POST(struct acpi_video_bus *video, unsigned long *id)
433{ 425{
434 int status; 426 int status;
435 427
436 ACPI_FUNCTION_TRACE("acpi_video_bus_get_POST");
437 428
438 status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id); 429 status = acpi_evaluate_integer(video->handle, "_GPD", NULL, id);
439 430
440 return_VALUE(status); 431 return status;
441} 432}
442 433
443static int 434static int
@@ -445,12 +436,11 @@ acpi_video_bus_POST_options(struct acpi_video_bus *video,
445 unsigned long *options) 436 unsigned long *options)
446{ 437{
447 int status; 438 int status;
448 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_options");
449 439
450 status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options); 440 status = acpi_evaluate_integer(video->handle, "_VPO", NULL, options);
451 *options &= 3; 441 *options &= 3;
452 442
453 return_VALUE(status); 443 return status;
454} 444}
455 445
456/* 446/*
@@ -481,7 +471,6 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
481 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 471 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
482 struct acpi_object_list args = { 1, &arg0 }; 472 struct acpi_object_list args = { 1, &arg0 };
483 473
484 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS");
485 474
486 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) { 475 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) {
487 status = -1; 476 status = -1;
@@ -492,7 +481,7 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
492 acpi_evaluate_object(video->handle, "_DOS", &args, NULL); 481 acpi_evaluate_object(video->handle, "_DOS", &args, NULL);
493 482
494 Failed: 483 Failed:
495 return_VALUE(status); 484 return status;
496} 485}
497 486
498/* 487/*
@@ -514,7 +503,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
514 union acpi_object *obj = NULL; 503 union acpi_object *obj = NULL;
515 struct acpi_video_device_brightness *br = NULL; 504 struct acpi_video_device_brightness *br = NULL;
516 505
517 ACPI_FUNCTION_TRACE("acpi_video_device_find_cap");
518 506
519 memset(&device->cap, 0, 4); 507 memset(&device->cap, 0, 4);
520 508
@@ -560,8 +548,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
560 o = (union acpi_object *)&obj->package. 548 o = (union acpi_object *)&obj->package.
561 elements[i]; 549 elements[i];
562 if (o->type != ACPI_TYPE_INTEGER) { 550 if (o->type != ACPI_TYPE_INTEGER) {
563 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 551 printk(KERN_ERR PREFIX "Invalid data\n");
564 "Invalid data\n"));
565 continue; 552 continue;
566 } 553 }
567 br->levels[count] = (u32) o->integer.value; 554 br->levels[count] = (u32) o->integer.value;
@@ -583,7 +570,7 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
583 570
584 kfree(obj); 571 kfree(obj);
585 572
586 return_VOID; 573 return;
587} 574}
588 575
589/* 576/*
@@ -630,10 +617,9 @@ static int acpi_video_bus_check(struct acpi_video_bus *video)
630{ 617{
631 acpi_status status = -ENOENT; 618 acpi_status status = -ENOENT;
632 619
633 ACPI_FUNCTION_TRACE("acpi_video_bus_check");
634 620
635 if (!video) 621 if (!video)
636 return_VALUE(-EINVAL); 622 return -EINVAL;
637 623
638 /* Since there is no HID, CID and so on for VGA driver, we have 624 /* Since there is no HID, CID and so on for VGA driver, we have
639 * to check well known required nodes. 625 * to check well known required nodes.
@@ -657,7 +643,7 @@ static int acpi_video_bus_check(struct acpi_video_bus *video)
657 status = 0; 643 status = 0;
658 } 644 }
659 645
660 return_VALUE(status); 646 return status;
661} 647}
662 648
663/* -------------------------------------------------------------------------- 649/* --------------------------------------------------------------------------
@@ -673,7 +659,6 @@ static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
673 struct acpi_video_device *dev = 659 struct acpi_video_device *dev =
674 (struct acpi_video_device *)seq->private; 660 (struct acpi_video_device *)seq->private;
675 661
676 ACPI_FUNCTION_TRACE("acpi_video_device_info_seq_show");
677 662
678 if (!dev) 663 if (!dev)
679 goto end; 664 goto end;
@@ -692,7 +677,7 @@ static int acpi_video_device_info_seq_show(struct seq_file *seq, void *offset)
692 seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no"); 677 seq_printf(seq, "known by bios: %s\n", dev->flags.bios ? "yes" : "no");
693 678
694 end: 679 end:
695 return_VALUE(0); 680 return 0;
696} 681}
697 682
698static int 683static int
@@ -709,7 +694,6 @@ static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
709 (struct acpi_video_device *)seq->private; 694 (struct acpi_video_device *)seq->private;
710 unsigned long state; 695 unsigned long state;
711 696
712 ACPI_FUNCTION_TRACE("acpi_video_device_state_seq_show");
713 697
714 if (!dev) 698 if (!dev)
715 goto end; 699 goto end;
@@ -729,7 +713,7 @@ static int acpi_video_device_state_seq_show(struct seq_file *seq, void *offset)
729 seq_printf(seq, "<not supported>\n"); 713 seq_printf(seq, "<not supported>\n");
730 714
731 end: 715 end:
732 return_VALUE(0); 716 return 0;
733} 717}
734 718
735static int 719static int
@@ -750,13 +734,12 @@ acpi_video_device_write_state(struct file *file,
750 char str[12] = { 0 }; 734 char str[12] = { 0 };
751 u32 state = 0; 735 u32 state = 0;
752 736
753 ACPI_FUNCTION_TRACE("acpi_video_device_write_state");
754 737
755 if (!dev || count + 1 > sizeof str) 738 if (!dev || count + 1 > sizeof str)
756 return_VALUE(-EINVAL); 739 return -EINVAL;
757 740
758 if (copy_from_user(str, buffer, count)) 741 if (copy_from_user(str, buffer, count))
759 return_VALUE(-EFAULT); 742 return -EFAULT;
760 743
761 str[count] = 0; 744 str[count] = 0;
762 state = simple_strtoul(str, NULL, 0); 745 state = simple_strtoul(str, NULL, 0);
@@ -765,9 +748,9 @@ acpi_video_device_write_state(struct file *file,
765 status = acpi_video_device_set_state(dev, state); 748 status = acpi_video_device_set_state(dev, state);
766 749
767 if (status) 750 if (status)
768 return_VALUE(-EFAULT); 751 return -EFAULT;
769 752
770 return_VALUE(count); 753 return count;
771} 754}
772 755
773static int 756static int
@@ -777,11 +760,10 @@ acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
777 (struct acpi_video_device *)seq->private; 760 (struct acpi_video_device *)seq->private;
778 int i; 761 int i;
779 762
780 ACPI_FUNCTION_TRACE("acpi_video_device_brightness_seq_show");
781 763
782 if (!dev || !dev->brightness) { 764 if (!dev || !dev->brightness) {
783 seq_printf(seq, "<not supported>\n"); 765 seq_printf(seq, "<not supported>\n");
784 return_VALUE(0); 766 return 0;
785 } 767 }
786 768
787 seq_printf(seq, "levels: "); 769 seq_printf(seq, "levels: ");
@@ -789,7 +771,7 @@ acpi_video_device_brightness_seq_show(struct seq_file *seq, void *offset)
789 seq_printf(seq, " %d", dev->brightness->levels[i]); 771 seq_printf(seq, " %d", dev->brightness->levels[i]);
790 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr); 772 seq_printf(seq, "\ncurrent: %d\n", dev->brightness->curr);
791 773
792 return_VALUE(0); 774 return 0;
793} 775}
794 776
795static int 777static int
@@ -810,19 +792,18 @@ acpi_video_device_write_brightness(struct file *file,
810 unsigned int level = 0; 792 unsigned int level = 0;
811 int i; 793 int i;
812 794
813 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
814 795
815 if (!dev || !dev->brightness || count + 1 > sizeof str) 796 if (!dev || !dev->brightness || count + 1 > sizeof str)
816 return_VALUE(-EINVAL); 797 return -EINVAL;
817 798
818 if (copy_from_user(str, buffer, count)) 799 if (copy_from_user(str, buffer, count))
819 return_VALUE(-EFAULT); 800 return -EFAULT;
820 801
821 str[count] = 0; 802 str[count] = 0;
822 level = simple_strtoul(str, NULL, 0); 803 level = simple_strtoul(str, NULL, 0);
823 804
824 if (level > 100) 805 if (level > 100)
825 return_VALUE(-EFAULT); 806 return -EFAULT;
826 807
827 /* validate though the list of available levels */ 808 /* validate though the list of available levels */
828 for (i = 0; i < dev->brightness->count; i++) 809 for (i = 0; i < dev->brightness->count; i++)
@@ -833,7 +814,7 @@ acpi_video_device_write_brightness(struct file *file,
833 break; 814 break;
834 } 815 }
835 816
836 return_VALUE(count); 817 return count;
837} 818}
838 819
839static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset) 820static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
@@ -844,7 +825,6 @@ static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
844 int i; 825 int i;
845 union acpi_object *edid = NULL; 826 union acpi_object *edid = NULL;
846 827
847 ACPI_FUNCTION_TRACE("acpi_video_device_EDID_seq_show");
848 828
849 if (!dev) 829 if (!dev)
850 goto out; 830 goto out;
@@ -869,7 +849,7 @@ static int acpi_video_device_EDID_seq_show(struct seq_file *seq, void *offset)
869 else 849 else
870 kfree(edid); 850 kfree(edid);
871 851
872 return_VALUE(0); 852 return 0;
873} 853}
874 854
875static int 855static int
@@ -884,28 +864,26 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
884 struct proc_dir_entry *entry = NULL; 864 struct proc_dir_entry *entry = NULL;
885 struct acpi_video_device *vid_dev; 865 struct acpi_video_device *vid_dev;
886 866
887 ACPI_FUNCTION_TRACE("acpi_video_device_add_fs");
888 867
889 if (!device) 868 if (!device)
890 return_VALUE(-ENODEV); 869 return -ENODEV;
891 870
892 vid_dev = (struct acpi_video_device *)acpi_driver_data(device); 871 vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
893 if (!vid_dev) 872 if (!vid_dev)
894 return_VALUE(-ENODEV); 873 return -ENODEV;
895 874
896 if (!acpi_device_dir(device)) { 875 if (!acpi_device_dir(device)) {
897 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 876 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
898 vid_dev->video->dir); 877 vid_dev->video->dir);
899 if (!acpi_device_dir(device)) 878 if (!acpi_device_dir(device))
900 return_VALUE(-ENODEV); 879 return -ENODEV;
901 acpi_device_dir(device)->owner = THIS_MODULE; 880 acpi_device_dir(device)->owner = THIS_MODULE;
902 } 881 }
903 882
904 /* 'info' [R] */ 883 /* 'info' [R] */
905 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); 884 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
906 if (!entry) 885 if (!entry)
907 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 886 return -ENODEV;
908 "Unable to create 'info' fs entry\n"));
909 else { 887 else {
910 entry->proc_fops = &acpi_video_device_info_fops; 888 entry->proc_fops = &acpi_video_device_info_fops;
911 entry->data = acpi_driver_data(device); 889 entry->data = acpi_driver_data(device);
@@ -917,8 +895,7 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
917 create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR, 895 create_proc_entry("state", S_IFREG | S_IRUGO | S_IWUSR,
918 acpi_device_dir(device)); 896 acpi_device_dir(device));
919 if (!entry) 897 if (!entry)
920 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 898 return -ENODEV;
921 "Unable to create 'state' fs entry\n"));
922 else { 899 else {
923 acpi_video_device_state_fops.write = acpi_video_device_write_state; 900 acpi_video_device_state_fops.write = acpi_video_device_write_state;
924 entry->proc_fops = &acpi_video_device_state_fops; 901 entry->proc_fops = &acpi_video_device_state_fops;
@@ -931,8 +908,7 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
931 create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR, 908 create_proc_entry("brightness", S_IFREG | S_IRUGO | S_IWUSR,
932 acpi_device_dir(device)); 909 acpi_device_dir(device));
933 if (!entry) 910 if (!entry)
934 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 911 return -ENODEV;
935 "Unable to create 'brightness' fs entry\n"));
936 else { 912 else {
937 acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness; 913 acpi_video_device_brightness_fops.write = acpi_video_device_write_brightness;
938 entry->proc_fops = &acpi_video_device_brightness_fops; 914 entry->proc_fops = &acpi_video_device_brightness_fops;
@@ -943,25 +919,23 @@ static int acpi_video_device_add_fs(struct acpi_device *device)
943 /* 'EDID' [R] */ 919 /* 'EDID' [R] */
944 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device)); 920 entry = create_proc_entry("EDID", S_IRUGO, acpi_device_dir(device));
945 if (!entry) 921 if (!entry)
946 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 922 return -ENODEV;
947 "Unable to create 'brightness' fs entry\n"));
948 else { 923 else {
949 entry->proc_fops = &acpi_video_device_EDID_fops; 924 entry->proc_fops = &acpi_video_device_EDID_fops;
950 entry->data = acpi_driver_data(device); 925 entry->data = acpi_driver_data(device);
951 entry->owner = THIS_MODULE; 926 entry->owner = THIS_MODULE;
952 } 927 }
953 928
954 return_VALUE(0); 929 return 0;
955} 930}
956 931
957static int acpi_video_device_remove_fs(struct acpi_device *device) 932static int acpi_video_device_remove_fs(struct acpi_device *device)
958{ 933{
959 struct acpi_video_device *vid_dev; 934 struct acpi_video_device *vid_dev;
960 ACPI_FUNCTION_TRACE("acpi_video_device_remove_fs");
961 935
962 vid_dev = (struct acpi_video_device *)acpi_driver_data(device); 936 vid_dev = (struct acpi_video_device *)acpi_driver_data(device);
963 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir) 937 if (!vid_dev || !vid_dev->video || !vid_dev->video->dir)
964 return_VALUE(-ENODEV); 938 return -ENODEV;
965 939
966 if (acpi_device_dir(device)) { 940 if (acpi_device_dir(device)) {
967 remove_proc_entry("info", acpi_device_dir(device)); 941 remove_proc_entry("info", acpi_device_dir(device));
@@ -972,7 +946,7 @@ static int acpi_video_device_remove_fs(struct acpi_device *device)
972 acpi_device_dir(device) = NULL; 946 acpi_device_dir(device) = NULL;
973 } 947 }
974 948
975 return_VALUE(0); 949 return 0;
976} 950}
977 951
978/* video bus */ 952/* video bus */
@@ -980,7 +954,6 @@ static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
980{ 954{
981 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; 955 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
982 956
983 ACPI_FUNCTION_TRACE("acpi_video_bus_info_seq_show");
984 957
985 if (!video) 958 if (!video)
986 goto end; 959 goto end;
@@ -993,7 +966,7 @@ static int acpi_video_bus_info_seq_show(struct seq_file *seq, void *offset)
993 video->flags.post ? "yes" : "no"); 966 video->flags.post ? "yes" : "no");
994 967
995 end: 968 end:
996 return_VALUE(0); 969 return 0;
997} 970}
998 971
999static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file) 972static int acpi_video_bus_info_open_fs(struct inode *inode, struct file *file)
@@ -1006,7 +979,6 @@ static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
1006{ 979{
1007 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; 980 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1008 981
1009 ACPI_FUNCTION_TRACE("acpi_video_bus_ROM_seq_show");
1010 982
1011 if (!video) 983 if (!video)
1012 goto end; 984 goto end;
@@ -1015,7 +987,7 @@ static int acpi_video_bus_ROM_seq_show(struct seq_file *seq, void *offset)
1015 seq_printf(seq, "<TODO>\n"); 987 seq_printf(seq, "<TODO>\n");
1016 988
1017 end: 989 end:
1018 return_VALUE(0); 990 return 0;
1019} 991}
1020 992
1021static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file) 993static int acpi_video_bus_ROM_open_fs(struct inode *inode, struct file *file)
@@ -1029,7 +1001,6 @@ static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
1029 unsigned long options; 1001 unsigned long options;
1030 int status; 1002 int status;
1031 1003
1032 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_info_seq_show");
1033 1004
1034 if (!video) 1005 if (!video)
1035 goto end; 1006 goto end;
@@ -1052,7 +1023,7 @@ static int acpi_video_bus_POST_info_seq_show(struct seq_file *seq, void *offset)
1052 } else 1023 } else
1053 seq_printf(seq, "<not supported>\n"); 1024 seq_printf(seq, "<not supported>\n");
1054 end: 1025 end:
1055 return_VALUE(0); 1026 return 0;
1056} 1027}
1057 1028
1058static int 1029static int
@@ -1068,7 +1039,6 @@ static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
1068 int status; 1039 int status;
1069 unsigned long id; 1040 unsigned long id;
1070 1041
1071 ACPI_FUNCTION_TRACE("acpi_video_bus_POST_seq_show");
1072 1042
1073 if (!video) 1043 if (!video)
1074 goto end; 1044 goto end;
@@ -1081,18 +1051,17 @@ static int acpi_video_bus_POST_seq_show(struct seq_file *seq, void *offset)
1081 seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]); 1051 seq_printf(seq, "device posted is <%s>\n", device_decode[id & 3]);
1082 1052
1083 end: 1053 end:
1084 return_VALUE(0); 1054 return 0;
1085} 1055}
1086 1056
1087static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset) 1057static int acpi_video_bus_DOS_seq_show(struct seq_file *seq, void *offset)
1088{ 1058{
1089 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private; 1059 struct acpi_video_bus *video = (struct acpi_video_bus *)seq->private;
1090 1060
1091 ACPI_FUNCTION_TRACE("acpi_video_bus_DOS_seq_show");
1092 1061
1093 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting); 1062 seq_printf(seq, "DOS setting: <%d>\n", video->dos_setting);
1094 1063
1095 return_VALUE(0); 1064 return 0;
1096} 1065}
1097 1066
1098static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file) 1067static int acpi_video_bus_POST_open_fs(struct inode *inode, struct file *file)
@@ -1117,22 +1086,21 @@ acpi_video_bus_write_POST(struct file *file,
1117 char str[12] = { 0 }; 1086 char str[12] = { 0 };
1118 unsigned long opt, options; 1087 unsigned long opt, options;
1119 1088
1120 ACPI_FUNCTION_TRACE("acpi_video_bus_write_POST");
1121 1089
1122 if (!video || count + 1 > sizeof str) 1090 if (!video || count + 1 > sizeof str)
1123 return_VALUE(-EINVAL); 1091 return -EINVAL;
1124 1092
1125 status = acpi_video_bus_POST_options(video, &options); 1093 status = acpi_video_bus_POST_options(video, &options);
1126 if (!ACPI_SUCCESS(status)) 1094 if (!ACPI_SUCCESS(status))
1127 return_VALUE(-EINVAL); 1095 return -EINVAL;
1128 1096
1129 if (copy_from_user(str, buffer, count)) 1097 if (copy_from_user(str, buffer, count))
1130 return_VALUE(-EFAULT); 1098 return -EFAULT;
1131 1099
1132 str[count] = 0; 1100 str[count] = 0;
1133 opt = strtoul(str, NULL, 0); 1101 opt = strtoul(str, NULL, 0);
1134 if (opt > 3) 1102 if (opt > 3)
1135 return_VALUE(-EFAULT); 1103 return -EFAULT;
1136 1104
1137 /* just in case an OEM 'forget' the motherboard... */ 1105 /* just in case an OEM 'forget' the motherboard... */
1138 options |= 1; 1106 options |= 1;
@@ -1140,11 +1108,11 @@ acpi_video_bus_write_POST(struct file *file,
1140 if (options & (1ul << opt)) { 1108 if (options & (1ul << opt)) {
1141 status = acpi_video_bus_set_POST(video, opt); 1109 status = acpi_video_bus_set_POST(video, opt);
1142 if (!ACPI_SUCCESS(status)) 1110 if (!ACPI_SUCCESS(status))
1143 return_VALUE(-EFAULT); 1111 return -EFAULT;
1144 1112
1145 } 1113 }
1146 1114
1147 return_VALUE(count); 1115 return count;
1148} 1116}
1149 1117
1150static ssize_t 1118static ssize_t
@@ -1158,25 +1126,24 @@ acpi_video_bus_write_DOS(struct file *file,
1158 char str[12] = { 0 }; 1126 char str[12] = { 0 };
1159 unsigned long opt; 1127 unsigned long opt;
1160 1128
1161 ACPI_FUNCTION_TRACE("acpi_video_bus_write_DOS");
1162 1129
1163 if (!video || count + 1 > sizeof str) 1130 if (!video || count + 1 > sizeof str)
1164 return_VALUE(-EINVAL); 1131 return -EINVAL;
1165 1132
1166 if (copy_from_user(str, buffer, count)) 1133 if (copy_from_user(str, buffer, count))
1167 return_VALUE(-EFAULT); 1134 return -EFAULT;
1168 1135
1169 str[count] = 0; 1136 str[count] = 0;
1170 opt = strtoul(str, NULL, 0); 1137 opt = strtoul(str, NULL, 0);
1171 if (opt > 7) 1138 if (opt > 7)
1172 return_VALUE(-EFAULT); 1139 return -EFAULT;
1173 1140
1174 status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2); 1141 status = acpi_video_bus_DOS(video, opt & 0x3, (opt & 0x4) >> 2);
1175 1142
1176 if (!ACPI_SUCCESS(status)) 1143 if (!ACPI_SUCCESS(status))
1177 return_VALUE(-EFAULT); 1144 return -EFAULT;
1178 1145
1179 return_VALUE(count); 1146 return count;
1180} 1147}
1181 1148
1182static int acpi_video_bus_add_fs(struct acpi_device *device) 1149static int acpi_video_bus_add_fs(struct acpi_device *device)
@@ -1184,7 +1151,6 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1184 struct proc_dir_entry *entry = NULL; 1151 struct proc_dir_entry *entry = NULL;
1185 struct acpi_video_bus *video; 1152 struct acpi_video_bus *video;
1186 1153
1187 ACPI_FUNCTION_TRACE("acpi_video_bus_add_fs");
1188 1154
1189 video = (struct acpi_video_bus *)acpi_driver_data(device); 1155 video = (struct acpi_video_bus *)acpi_driver_data(device);
1190 1156
@@ -1192,7 +1158,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1192 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 1158 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
1193 acpi_video_dir); 1159 acpi_video_dir);
1194 if (!acpi_device_dir(device)) 1160 if (!acpi_device_dir(device))
1195 return_VALUE(-ENODEV); 1161 return -ENODEV;
1196 video->dir = acpi_device_dir(device); 1162 video->dir = acpi_device_dir(device);
1197 acpi_device_dir(device)->owner = THIS_MODULE; 1163 acpi_device_dir(device)->owner = THIS_MODULE;
1198 } 1164 }
@@ -1200,8 +1166,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1200 /* 'info' [R] */ 1166 /* 'info' [R] */
1201 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device)); 1167 entry = create_proc_entry("info", S_IRUGO, acpi_device_dir(device));
1202 if (!entry) 1168 if (!entry)
1203 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1169 return -ENODEV;
1204 "Unable to create 'info' fs entry\n"));
1205 else { 1170 else {
1206 entry->proc_fops = &acpi_video_bus_info_fops; 1171 entry->proc_fops = &acpi_video_bus_info_fops;
1207 entry->data = acpi_driver_data(device); 1172 entry->data = acpi_driver_data(device);
@@ -1211,8 +1176,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1211 /* 'ROM' [R] */ 1176 /* 'ROM' [R] */
1212 entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device)); 1177 entry = create_proc_entry("ROM", S_IRUGO, acpi_device_dir(device));
1213 if (!entry) 1178 if (!entry)
1214 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1179 return -ENODEV;
1215 "Unable to create 'ROM' fs entry\n"));
1216 else { 1180 else {
1217 entry->proc_fops = &acpi_video_bus_ROM_fops; 1181 entry->proc_fops = &acpi_video_bus_ROM_fops;
1218 entry->data = acpi_driver_data(device); 1182 entry->data = acpi_driver_data(device);
@@ -1223,8 +1187,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1223 entry = 1187 entry =
1224 create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device)); 1188 create_proc_entry("POST_info", S_IRUGO, acpi_device_dir(device));
1225 if (!entry) 1189 if (!entry)
1226 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1190 return -ENODEV;
1227 "Unable to create 'POST_info' fs entry\n"));
1228 else { 1191 else {
1229 entry->proc_fops = &acpi_video_bus_POST_info_fops; 1192 entry->proc_fops = &acpi_video_bus_POST_info_fops;
1230 entry->data = acpi_driver_data(device); 1193 entry->data = acpi_driver_data(device);
@@ -1236,8 +1199,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1236 create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR, 1199 create_proc_entry("POST", S_IFREG | S_IRUGO | S_IRUSR,
1237 acpi_device_dir(device)); 1200 acpi_device_dir(device));
1238 if (!entry) 1201 if (!entry)
1239 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1202 return -ENODEV;
1240 "Unable to create 'POST' fs entry\n"));
1241 else { 1203 else {
1242 acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST; 1204 acpi_video_bus_POST_fops.write = acpi_video_bus_write_POST;
1243 entry->proc_fops = &acpi_video_bus_POST_fops; 1205 entry->proc_fops = &acpi_video_bus_POST_fops;
@@ -1250,8 +1212,7 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1250 create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR, 1212 create_proc_entry("DOS", S_IFREG | S_IRUGO | S_IRUSR,
1251 acpi_device_dir(device)); 1213 acpi_device_dir(device));
1252 if (!entry) 1214 if (!entry)
1253 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1215 return -ENODEV;
1254 "Unable to create 'DOS' fs entry\n"));
1255 else { 1216 else {
1256 acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS; 1217 acpi_video_bus_DOS_fops.write = acpi_video_bus_write_DOS;
1257 entry->proc_fops = &acpi_video_bus_DOS_fops; 1218 entry->proc_fops = &acpi_video_bus_DOS_fops;
@@ -1259,14 +1220,13 @@ static int acpi_video_bus_add_fs(struct acpi_device *device)
1259 entry->owner = THIS_MODULE; 1220 entry->owner = THIS_MODULE;
1260 } 1221 }
1261 1222
1262 return_VALUE(0); 1223 return 0;
1263} 1224}
1264 1225
1265static int acpi_video_bus_remove_fs(struct acpi_device *device) 1226static int acpi_video_bus_remove_fs(struct acpi_device *device)
1266{ 1227{
1267 struct acpi_video_bus *video; 1228 struct acpi_video_bus *video;
1268 1229
1269 ACPI_FUNCTION_TRACE("acpi_video_bus_remove_fs");
1270 1230
1271 video = (struct acpi_video_bus *)acpi_driver_data(device); 1231 video = (struct acpi_video_bus *)acpi_driver_data(device);
1272 1232
@@ -1280,7 +1240,7 @@ static int acpi_video_bus_remove_fs(struct acpi_device *device)
1280 acpi_device_dir(device) = NULL; 1240 acpi_device_dir(device) = NULL;
1281 } 1241 }
1282 1242
1283 return_VALUE(0); 1243 return 0;
1284} 1244}
1285 1245
1286/* -------------------------------------------------------------------------- 1246/* --------------------------------------------------------------------------
@@ -1297,10 +1257,9 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
1297 int status; 1257 int status;
1298 struct acpi_video_device *data; 1258 struct acpi_video_device *data;
1299 1259
1300 ACPI_FUNCTION_TRACE("acpi_video_bus_get_one_device");
1301 1260
1302 if (!device || !video) 1261 if (!device || !video)
1303 return_VALUE(-EINVAL); 1262 return -EINVAL;
1304 1263
1305 status = 1264 status =
1306 acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id); 1265 acpi_evaluate_integer(device->handle, "_ADR", NULL, &device_id);
@@ -1308,7 +1267,7 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
1308 1267
1309 data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL); 1268 data = kmalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
1310 if (!data) 1269 if (!data)
1311 return_VALUE(-ENOMEM); 1270 return -ENOMEM;
1312 1271
1313 memset(data, 0, sizeof(struct acpi_video_device)); 1272 memset(data, 0, sizeof(struct acpi_video_device));
1314 1273
@@ -1359,10 +1318,10 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
1359 1318
1360 acpi_video_device_add_fs(device); 1319 acpi_video_device_add_fs(device);
1361 1320
1362 return_VALUE(0); 1321 return 0;
1363 } 1322 }
1364 1323
1365 return_VALUE(-ENOENT); 1324 return -ENOENT;
1366} 1325}
1367 1326
1368/* 1327/*
@@ -1405,7 +1364,6 @@ acpi_video_device_bind(struct acpi_video_bus *video,
1405 struct acpi_video_device *device) 1364 struct acpi_video_device *device)
1406{ 1365{
1407 int i; 1366 int i;
1408 ACPI_FUNCTION_TRACE("acpi_video_device_bind");
1409 1367
1410#define IDS_VAL(i) video->attached_array[i].value.int_val 1368#define IDS_VAL(i) video->attached_array[i].value.int_val
1411#define IDS_BIND(i) video->attached_array[i].bind_info 1369#define IDS_BIND(i) video->attached_array[i].bind_info
@@ -1442,17 +1400,16 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1442 union acpi_object *dod = NULL; 1400 union acpi_object *dod = NULL;
1443 union acpi_object *obj; 1401 union acpi_object *obj;
1444 1402
1445 ACPI_FUNCTION_TRACE("acpi_video_device_enumerate");
1446 1403
1447 status = acpi_evaluate_object(video->handle, "_DOD", NULL, &buffer); 1404 status = acpi_evaluate_object(video->handle, "_DOD", NULL, &buffer);
1448 if (!ACPI_SUCCESS(status)) { 1405 if (!ACPI_SUCCESS(status)) {
1449 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _DOD\n")); 1406 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _DOD"));
1450 return_VALUE(status); 1407 return status;
1451 } 1408 }
1452 1409
1453 dod = (union acpi_object *)buffer.pointer; 1410 dod = (union acpi_object *)buffer.pointer;
1454 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) { 1411 if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
1455 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _DOD data\n")); 1412 ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data"));
1456 status = -EFAULT; 1413 status = -EFAULT;
1457 goto out; 1414 goto out;
1458 } 1415 }
@@ -1476,8 +1433,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1476 obj = (union acpi_object *)&dod->package.elements[i]; 1433 obj = (union acpi_object *)&dod->package.elements[i];
1477 1434
1478 if (obj->type != ACPI_TYPE_INTEGER) { 1435 if (obj->type != ACPI_TYPE_INTEGER) {
1479 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1436 printk(KERN_ERR PREFIX "Invalid _DOD data\n");
1480 "Invalid _DOD data\n"));
1481 active_device_list[i].value.int_val = 1437 active_device_list[i].value.int_val =
1482 ACPI_VIDEO_HEAD_INVALID; 1438 ACPI_VIDEO_HEAD_INVALID;
1483 } 1439 }
@@ -1495,7 +1451,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
1495 video->attached_count = count; 1451 video->attached_count = count;
1496 out: 1452 out:
1497 acpi_os_free(buffer.pointer); 1453 acpi_os_free(buffer.pointer);
1498 return_VALUE(status); 1454 return status;
1499} 1455}
1500 1456
1501/* 1457/*
@@ -1520,7 +1476,6 @@ static int acpi_video_switch_output(struct acpi_video_bus *video, int event)
1520 unsigned long state; 1476 unsigned long state;
1521 int status = 0; 1477 int status = 0;
1522 1478
1523 ACPI_FUNCTION_TRACE("acpi_video_switch_output");
1524 1479
1525 list_for_each_safe(node, next, &video->video_device_list) { 1480 list_for_each_safe(node, next, &video->video_device_list) {
1526 dev = container_of(node, struct acpi_video_device, entry); 1481 dev = container_of(node, struct acpi_video_device, entry);
@@ -1551,7 +1506,7 @@ static int acpi_video_switch_output(struct acpi_video_bus *video, int event)
1551 break; 1506 break;
1552 } 1507 }
1553 1508
1554 return_VALUE(status); 1509 return status;
1555} 1510}
1556 1511
1557static int 1512static int
@@ -1578,7 +1533,6 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video,
1578 int status = 0; 1533 int status = 0;
1579 struct list_head *node, *next; 1534 struct list_head *node, *next;
1580 1535
1581 ACPI_FUNCTION_TRACE("acpi_video_get_devices");
1582 1536
1583 acpi_video_device_enumerate(video); 1537 acpi_video_device_enumerate(video);
1584 1538
@@ -1591,13 +1545,12 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video,
1591 1545
1592 status = acpi_video_bus_get_one_device(dev, video); 1546 status = acpi_video_bus_get_one_device(dev, video);
1593 if (ACPI_FAILURE(status)) { 1547 if (ACPI_FAILURE(status)) {
1594 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1548 ACPI_EXCEPTION((AE_INFO, status, "Cant attach device"));
1595 "Cant attach device\n"));
1596 continue; 1549 continue;
1597 } 1550 }
1598 1551
1599 } 1552 }
1600 return_VALUE(status); 1553 return status;
1601} 1554}
1602 1555
1603static int acpi_video_bus_put_one_device(struct acpi_video_device *device) 1556static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
@@ -1605,10 +1558,9 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
1605 acpi_status status; 1558 acpi_status status;
1606 struct acpi_video_bus *video; 1559 struct acpi_video_bus *video;
1607 1560
1608 ACPI_FUNCTION_TRACE("acpi_video_bus_put_one_device");
1609 1561
1610 if (!device || !device->video) 1562 if (!device || !device->video)
1611 return_VALUE(-ENOENT); 1563 return -ENOENT;
1612 1564
1613 video = device->video; 1565 video = device->video;
1614 1566
@@ -1620,11 +1572,8 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
1620 status = acpi_remove_notify_handler(device->handle, 1572 status = acpi_remove_notify_handler(device->handle,
1621 ACPI_DEVICE_NOTIFY, 1573 ACPI_DEVICE_NOTIFY,
1622 acpi_video_device_notify); 1574 acpi_video_device_notify);
1623 if (ACPI_FAILURE(status))
1624 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1625 "Error removing notify handler\n"));
1626 1575
1627 return_VALUE(0); 1576 return 0;
1628} 1577}
1629 1578
1630static int acpi_video_bus_put_devices(struct acpi_video_bus *video) 1579static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
@@ -1632,7 +1581,6 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1632 int status; 1581 int status;
1633 struct list_head *node, *next; 1582 struct list_head *node, *next;
1634 1583
1635 ACPI_FUNCTION_TRACE("acpi_video_bus_put_devices");
1636 1584
1637 list_for_each_safe(node, next, &video->video_device_list) { 1585 list_for_each_safe(node, next, &video->video_device_list) {
1638 struct acpi_video_device *data = 1586 struct acpi_video_device *data =
@@ -1651,7 +1599,7 @@ static int acpi_video_bus_put_devices(struct acpi_video_bus *video)
1651 kfree(data); 1599 kfree(data);
1652 } 1600 }
1653 1601
1654 return_VALUE(0); 1602 return 0;
1655} 1603}
1656 1604
1657/* acpi_video interface */ 1605/* acpi_video interface */
@@ -1671,14 +1619,13 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1671 struct acpi_video_bus *video = (struct acpi_video_bus *)data; 1619 struct acpi_video_bus *video = (struct acpi_video_bus *)data;
1672 struct acpi_device *device = NULL; 1620 struct acpi_device *device = NULL;
1673 1621
1674 ACPI_FUNCTION_TRACE("acpi_video_bus_notify");
1675 printk("video bus notify\n"); 1622 printk("video bus notify\n");
1676 1623
1677 if (!video) 1624 if (!video)
1678 return_VOID; 1625 return;
1679 1626
1680 if (acpi_bus_get_device(handle, &device)) 1627 if (acpi_bus_get_device(handle, &device))
1681 return_VOID; 1628 return;
1682 1629
1683 switch (event) { 1630 switch (event) {
1684 case ACPI_VIDEO_NOTIFY_SWITCH: /* User request that a switch occur, 1631 case ACPI_VIDEO_NOTIFY_SWITCH: /* User request that a switch occur,
@@ -1707,7 +1654,7 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1707 break; 1654 break;
1708 } 1655 }
1709 1656
1710 return_VOID; 1657 return;
1711} 1658}
1712 1659
1713static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data) 1660static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
@@ -1716,14 +1663,13 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1716 (struct acpi_video_device *)data; 1663 (struct acpi_video_device *)data;
1717 struct acpi_device *device = NULL; 1664 struct acpi_device *device = NULL;
1718 1665
1719 ACPI_FUNCTION_TRACE("acpi_video_device_notify");
1720 1666
1721 printk("video device notify\n"); 1667 printk("video device notify\n");
1722 if (!video_device) 1668 if (!video_device)
1723 return_VOID; 1669 return;
1724 1670
1725 if (acpi_bus_get_device(handle, &device)) 1671 if (acpi_bus_get_device(handle, &device))
1726 return_VOID; 1672 return;
1727 1673
1728 switch (event) { 1674 switch (event) {
1729 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */ 1675 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */
@@ -1743,7 +1689,7 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1743 "Unsupported event [0x%x]\n", event)); 1689 "Unsupported event [0x%x]\n", event));
1744 break; 1690 break;
1745 } 1691 }
1746 return_VOID; 1692 return;
1747} 1693}
1748 1694
1749static int acpi_video_bus_add(struct acpi_device *device) 1695static int acpi_video_bus_add(struct acpi_device *device)
@@ -1752,14 +1698,13 @@ static int acpi_video_bus_add(struct acpi_device *device)
1752 acpi_status status = 0; 1698 acpi_status status = 0;
1753 struct acpi_video_bus *video = NULL; 1699 struct acpi_video_bus *video = NULL;
1754 1700
1755 ACPI_FUNCTION_TRACE("acpi_video_bus_add");
1756 1701
1757 if (!device) 1702 if (!device)
1758 return_VALUE(-EINVAL); 1703 return -EINVAL;
1759 1704
1760 video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL); 1705 video = kmalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
1761 if (!video) 1706 if (!video)
1762 return_VALUE(-ENOMEM); 1707 return -ENOMEM;
1763 memset(video, 0, sizeof(struct acpi_video_bus)); 1708 memset(video, 0, sizeof(struct acpi_video_bus));
1764 1709
1765 video->handle = device->handle; 1710 video->handle = device->handle;
@@ -1806,7 +1751,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
1806 if (result) 1751 if (result)
1807 kfree(video); 1752 kfree(video);
1808 1753
1809 return_VALUE(result); 1754 return result;
1810} 1755}
1811 1756
1812static int acpi_video_bus_remove(struct acpi_device *device, int type) 1757static int acpi_video_bus_remove(struct acpi_device *device, int type)
@@ -1814,10 +1759,9 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
1814 acpi_status status = 0; 1759 acpi_status status = 0;
1815 struct acpi_video_bus *video = NULL; 1760 struct acpi_video_bus *video = NULL;
1816 1761
1817 ACPI_FUNCTION_TRACE("acpi_video_bus_remove");
1818 1762
1819 if (!device || !acpi_driver_data(device)) 1763 if (!device || !acpi_driver_data(device))
1820 return_VALUE(-EINVAL); 1764 return -EINVAL;
1821 1765
1822 video = (struct acpi_video_bus *)acpi_driver_data(device); 1766 video = (struct acpi_video_bus *)acpi_driver_data(device);
1823 1767
@@ -1826,9 +1770,6 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
1826 status = acpi_remove_notify_handler(video->handle, 1770 status = acpi_remove_notify_handler(video->handle,
1827 ACPI_DEVICE_NOTIFY, 1771 ACPI_DEVICE_NOTIFY,
1828 acpi_video_bus_notify); 1772 acpi_video_bus_notify);
1829 if (ACPI_FAILURE(status))
1830 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
1831 "Error removing notify handler\n"));
1832 1773
1833 acpi_video_bus_put_devices(video); 1774 acpi_video_bus_put_devices(video);
1834 acpi_video_bus_remove_fs(device); 1775 acpi_video_bus_remove_fs(device);
@@ -1836,7 +1777,7 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
1836 kfree(video->attached_array); 1777 kfree(video->attached_array);
1837 kfree(video); 1778 kfree(video);
1838 1779
1839 return_VALUE(0); 1780 return 0;
1840} 1781}
1841 1782
1842static int 1783static int
@@ -1846,10 +1787,9 @@ acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver)
1846 acpi_handle h_dummy2; 1787 acpi_handle h_dummy2;
1847 acpi_handle h_dummy3; 1788 acpi_handle h_dummy3;
1848 1789
1849 ACPI_FUNCTION_TRACE("acpi_video_bus_match");
1850 1790
1851 if (!device || !driver) 1791 if (!device || !driver)
1852 return_VALUE(-EINVAL); 1792 return -EINVAL;
1853 1793
1854 /* Since there is no HID, CID for ACPI Video drivers, we have 1794 /* Since there is no HID, CID for ACPI Video drivers, we have
1855 * to check well known required nodes for each feature we support. 1795 * to check well known required nodes for each feature we support.
@@ -1858,26 +1798,25 @@ acpi_video_bus_match(struct acpi_device *device, struct acpi_driver *driver)
1858 /* Does this device able to support video switching ? */ 1798 /* Does this device able to support video switching ? */
1859 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) && 1799 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOD", &h_dummy1)) &&
1860 ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2))) 1800 ACPI_SUCCESS(acpi_get_handle(device->handle, "_DOS", &h_dummy2)))
1861 return_VALUE(0); 1801 return 0;
1862 1802
1863 /* Does this device able to retrieve a video ROM ? */ 1803 /* Does this device able to retrieve a video ROM ? */
1864 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1))) 1804 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_ROM", &h_dummy1)))
1865 return_VALUE(0); 1805 return 0;
1866 1806
1867 /* Does this device able to configure which video head to be POSTed ? */ 1807 /* Does this device able to configure which video head to be POSTed ? */
1868 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) && 1808 if (ACPI_SUCCESS(acpi_get_handle(device->handle, "_VPO", &h_dummy1)) &&
1869 ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) && 1809 ACPI_SUCCESS(acpi_get_handle(device->handle, "_GPD", &h_dummy2)) &&
1870 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3))) 1810 ACPI_SUCCESS(acpi_get_handle(device->handle, "_SPD", &h_dummy3)))
1871 return_VALUE(0); 1811 return 0;
1872 1812
1873 return_VALUE(-ENODEV); 1813 return -ENODEV;
1874} 1814}
1875 1815
1876static int __init acpi_video_init(void) 1816static int __init acpi_video_init(void)
1877{ 1817{
1878 int result = 0; 1818 int result = 0;
1879 1819
1880 ACPI_FUNCTION_TRACE("acpi_video_init");
1881 1820
1882 /* 1821 /*
1883 acpi_dbg_level = 0xFFFFFFFF; 1822 acpi_dbg_level = 0xFFFFFFFF;
@@ -1886,27 +1825,26 @@ static int __init acpi_video_init(void)
1886 1825
1887 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir); 1826 acpi_video_dir = proc_mkdir(ACPI_VIDEO_CLASS, acpi_root_dir);
1888 if (!acpi_video_dir) 1827 if (!acpi_video_dir)
1889 return_VALUE(-ENODEV); 1828 return -ENODEV;
1890 acpi_video_dir->owner = THIS_MODULE; 1829 acpi_video_dir->owner = THIS_MODULE;
1891 1830
1892 result = acpi_bus_register_driver(&acpi_video_bus); 1831 result = acpi_bus_register_driver(&acpi_video_bus);
1893 if (result < 0) { 1832 if (result < 0) {
1894 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir); 1833 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
1895 return_VALUE(-ENODEV); 1834 return -ENODEV;
1896 } 1835 }
1897 1836
1898 return_VALUE(0); 1837 return 0;
1899} 1838}
1900 1839
1901static void __exit acpi_video_exit(void) 1840static void __exit acpi_video_exit(void)
1902{ 1841{
1903 ACPI_FUNCTION_TRACE("acpi_video_exit");
1904 1842
1905 acpi_bus_unregister_driver(&acpi_video_bus); 1843 acpi_bus_unregister_driver(&acpi_video_bus);
1906 1844
1907 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir); 1845 remove_proc_entry(ACPI_VIDEO_CLASS, acpi_root_dir);
1908 1846
1909 return_VOID; 1847 return;
1910} 1848}
1911 1849
1912module_init(acpi_video_init); 1850module_init(acpi_video_init);
diff --git a/drivers/base/node.c b/drivers/base/node.c
index eae2bdc183bb..d7de1753e094 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -40,24 +40,13 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
40 int n; 40 int n;
41 int nid = dev->id; 41 int nid = dev->id;
42 struct sysinfo i; 42 struct sysinfo i;
43 struct page_state ps;
44 unsigned long inactive; 43 unsigned long inactive;
45 unsigned long active; 44 unsigned long active;
46 unsigned long free; 45 unsigned long free;
47 46
48 si_meminfo_node(&i, nid); 47 si_meminfo_node(&i, nid);
49 get_page_state_node(&ps, nid);
50 __get_zone_counts(&active, &inactive, &free, NODE_DATA(nid)); 48 __get_zone_counts(&active, &inactive, &free, NODE_DATA(nid));
51 49
52 /* Check for negative values in these approximate counters */
53 if ((long)ps.nr_dirty < 0)
54 ps.nr_dirty = 0;
55 if ((long)ps.nr_writeback < 0)
56 ps.nr_writeback = 0;
57 if ((long)ps.nr_mapped < 0)
58 ps.nr_mapped = 0;
59 if ((long)ps.nr_slab < 0)
60 ps.nr_slab = 0;
61 50
62 n = sprintf(buf, "\n" 51 n = sprintf(buf, "\n"
63 "Node %d MemTotal: %8lu kB\n" 52 "Node %d MemTotal: %8lu kB\n"
@@ -71,7 +60,12 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
71 "Node %d LowFree: %8lu kB\n" 60 "Node %d LowFree: %8lu kB\n"
72 "Node %d Dirty: %8lu kB\n" 61 "Node %d Dirty: %8lu kB\n"
73 "Node %d Writeback: %8lu kB\n" 62 "Node %d Writeback: %8lu kB\n"
63 "Node %d FilePages: %8lu kB\n"
74 "Node %d Mapped: %8lu kB\n" 64 "Node %d Mapped: %8lu kB\n"
65 "Node %d AnonPages: %8lu kB\n"
66 "Node %d PageTables: %8lu kB\n"
67 "Node %d NFS Unstable: %8lu kB\n"
68 "Node %d Bounce: %8lu kB\n"
75 "Node %d Slab: %8lu kB\n", 69 "Node %d Slab: %8lu kB\n",
76 nid, K(i.totalram), 70 nid, K(i.totalram),
77 nid, K(i.freeram), 71 nid, K(i.freeram),
@@ -82,10 +76,15 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
82 nid, K(i.freehigh), 76 nid, K(i.freehigh),
83 nid, K(i.totalram - i.totalhigh), 77 nid, K(i.totalram - i.totalhigh),
84 nid, K(i.freeram - i.freehigh), 78 nid, K(i.freeram - i.freehigh),
85 nid, K(ps.nr_dirty), 79 nid, K(node_page_state(nid, NR_FILE_DIRTY)),
86 nid, K(ps.nr_writeback), 80 nid, K(node_page_state(nid, NR_WRITEBACK)),
87 nid, K(ps.nr_mapped), 81 nid, K(node_page_state(nid, NR_FILE_PAGES)),
88 nid, K(ps.nr_slab)); 82 nid, K(node_page_state(nid, NR_FILE_MAPPED)),
83 nid, K(node_page_state(nid, NR_ANON_PAGES)),
84 nid, K(node_page_state(nid, NR_PAGETABLE)),
85 nid, K(node_page_state(nid, NR_UNSTABLE_NFS)),
86 nid, K(node_page_state(nid, NR_BOUNCE)),
87 nid, K(node_page_state(nid, NR_SLAB)));
89 n += hugetlb_report_node_meminfo(nid, buf + n); 88 n += hugetlb_report_node_meminfo(nid, buf + n);
90 return n; 89 return n;
91} 90}
@@ -95,28 +94,6 @@ static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL);
95 94
96static ssize_t node_read_numastat(struct sys_device * dev, char * buf) 95static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
97{ 96{
98 unsigned long numa_hit, numa_miss, interleave_hit, numa_foreign;
99 unsigned long local_node, other_node;
100 int i, cpu;
101 pg_data_t *pg = NODE_DATA(dev->id);
102 numa_hit = 0;
103 numa_miss = 0;
104 interleave_hit = 0;
105 numa_foreign = 0;
106 local_node = 0;
107 other_node = 0;
108 for (i = 0; i < MAX_NR_ZONES; i++) {
109 struct zone *z = &pg->node_zones[i];
110 for_each_online_cpu(cpu) {
111 struct per_cpu_pageset *ps = zone_pcp(z,cpu);
112 numa_hit += ps->numa_hit;
113 numa_miss += ps->numa_miss;
114 numa_foreign += ps->numa_foreign;
115 interleave_hit += ps->interleave_hit;
116 local_node += ps->local_node;
117 other_node += ps->other_node;
118 }
119 }
120 return sprintf(buf, 97 return sprintf(buf,
121 "numa_hit %lu\n" 98 "numa_hit %lu\n"
122 "numa_miss %lu\n" 99 "numa_miss %lu\n"
@@ -124,12 +101,12 @@ static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
124 "interleave_hit %lu\n" 101 "interleave_hit %lu\n"
125 "local_node %lu\n" 102 "local_node %lu\n"
126 "other_node %lu\n", 103 "other_node %lu\n",
127 numa_hit, 104 node_page_state(dev->id, NUMA_HIT),
128 numa_miss, 105 node_page_state(dev->id, NUMA_MISS),
129 numa_foreign, 106 node_page_state(dev->id, NUMA_FOREIGN),
130 interleave_hit, 107 node_page_state(dev->id, NUMA_INTERLEAVE_HIT),
131 local_node, 108 node_page_state(dev->id, NUMA_LOCAL),
132 other_node); 109 node_page_state(dev->id, NUMA_OTHER));
133} 110}
134static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL); 111static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
135 112
diff --git a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c
index 4ee288688fed..9b05ddd23141 100644
--- a/drivers/cdrom/cm206.c
+++ b/drivers/cdrom/cm206.c
@@ -914,7 +914,7 @@ static void seek(int lba)
914 cd->dsb = wait_dsb(); 914 cd->dsb = wait_dsb();
915} 915}
916 916
917uch bcdbin(unsigned char bcd) 917static uch bcdbin(unsigned char bcd)
918{ /* stolen from mcd.c! */ 918{ /* stolen from mcd.c! */
919 return (bcd >> 4) * 10 + (bcd & 0xf); 919 return (bcd >> 4) * 10 + (bcd & 0xf);
920} 920}
@@ -1532,7 +1532,7 @@ static void __init parse_options(void)
1532 } 1532 }
1533} 1533}
1534 1534
1535static int __cm206_init(void) 1535static int __init __cm206_init(void)
1536{ 1536{
1537 parse_options(); 1537 parse_options();
1538#if !defined(AUTO_PROBE_MODULE) 1538#if !defined(AUTO_PROBE_MODULE)
@@ -1593,8 +1593,3 @@ __setup("cm206=", cm206_setup);
1593#endif /* !MODULE */ 1593#endif /* !MODULE */
1594MODULE_ALIAS_BLOCKDEV_MAJOR(CM206_CDROM_MAJOR); 1594MODULE_ALIAS_BLOCKDEV_MAJOR(CM206_CDROM_MAJOR);
1595 1595
1596/*
1597 * Local variables:
1598 * compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -fno-strength-reduce -m486 -DMODULE -DMODVERSIONS -include /usr/src/linux/include/linux/modversions.h -c -o cm206.o cm206.c"
1599 * End:
1600 */
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index c86a718a702c..fbce2f0669d6 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -281,7 +281,6 @@ static char *stli_brdnames[] = {
281 281
282/*****************************************************************************/ 282/*****************************************************************************/
283 283
284#ifdef MODULE
285/* 284/*
286 * Define some string labels for arguments passed from the module 285 * Define some string labels for arguments passed from the module
287 * load line. These allow for easy board definitions, and easy 286 * load line. These allow for easy board definitions, and easy
@@ -380,8 +379,6 @@ MODULE_PARM_DESC(board2, "Board 2 config -> name[,ioaddr[,memaddr]");
380module_param_array(board3, charp, NULL, 0); 379module_param_array(board3, charp, NULL, 0);
381MODULE_PARM_DESC(board3, "Board 3 config -> name[,ioaddr[,memaddr]"); 380MODULE_PARM_DESC(board3, "Board 3 config -> name[,ioaddr[,memaddr]");
382 381
383#endif
384
385/* 382/*
386 * Set up a default memory address table for EISA board probing. 383 * Set up a default memory address table for EISA board probing.
387 * The default addresses are all bellow 1Mbyte, which has to be the 384 * The default addresses are all bellow 1Mbyte, which has to be the
@@ -642,14 +639,8 @@ static unsigned int stli_baudrates[] = {
642 * Prototype all functions in this driver! 639 * Prototype all functions in this driver!
643 */ 640 */
644 641
645#ifdef MODULE
646static void stli_argbrds(void);
647static int stli_parsebrd(stlconf_t *confp, char **argp); 642static int stli_parsebrd(stlconf_t *confp, char **argp);
648 643static int stli_init(void);
649static unsigned long stli_atol(char *str);
650#endif
651
652int stli_init(void);
653static int stli_open(struct tty_struct *tty, struct file *filp); 644static int stli_open(struct tty_struct *tty, struct file *filp);
654static void stli_close(struct tty_struct *tty, struct file *filp); 645static void stli_close(struct tty_struct *tty, struct file *filp);
655static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count); 646static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count);
@@ -785,8 +776,6 @@ static int stli_timeron;
785 776
786static struct class *istallion_class; 777static struct class *istallion_class;
787 778
788#ifdef MODULE
789
790/* 779/*
791 * Loadable module initialization stuff. 780 * Loadable module initialization stuff.
792 */ 781 */
@@ -953,8 +942,6 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
953 return(1); 942 return(1);
954} 943}
955 944
956#endif
957
958/*****************************************************************************/ 945/*****************************************************************************/
959 946
960static int stli_open(struct tty_struct *tty, struct file *filp) 947static int stli_open(struct tty_struct *tty, struct file *filp)
@@ -4693,7 +4680,7 @@ static struct tty_operations stli_ops = {
4693 4680
4694/*****************************************************************************/ 4681/*****************************************************************************/
4695 4682
4696int __init stli_init(void) 4683static int __init stli_init(void)
4697{ 4684{
4698 int i; 4685 int i;
4699 printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion); 4686 printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion);
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c
index 1c706ccfdbb3..c860de6a6fde 100644
--- a/drivers/char/pc8736x_gpio.c
+++ b/drivers/char/pc8736x_gpio.c
@@ -319,9 +319,10 @@ static int __init pc8736x_gpio_init(void)
319 return 0; 319 return 0;
320 320
321undo_platform_dev_add: 321undo_platform_dev_add:
322 platform_device_put(pdev); 322 platform_device_del(pdev);
323undo_platform_dev_alloc: 323undo_platform_dev_alloc:
324 kfree(pdev); 324 platform_device_put(pdev);
325
325 return rc; 326 return rc;
326} 327}
327 328
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index eab5394da666..31c8a21f9d87 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -149,12 +149,7 @@ struct cm4000_dev {
149#define ZERO_DEV(dev) \ 149#define ZERO_DEV(dev) \
150 memset(&dev->atr_csum,0, \ 150 memset(&dev->atr_csum,0, \
151 sizeof(struct cm4000_dev) - \ 151 sizeof(struct cm4000_dev) - \
152 /*link*/ sizeof(struct pcmcia_device *) - \ 152 offsetof(struct cm4000_dev, atr_csum))
153 /*node*/ sizeof(dev_node_t) - \
154 /*atr*/ MAX_ATR*sizeof(char) - \
155 /*rbuf*/ 512*sizeof(char) - \
156 /*sbuf*/ 512*sizeof(char) - \
157 /*queue*/ 4*sizeof(wait_queue_head_t))
158 153
159static struct pcmcia_device *dev_table[CM4000_MAX_DEV]; 154static struct pcmcia_device *dev_table[CM4000_MAX_DEV];
160static struct class *cmm_class; 155static struct class *cmm_class;
diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
index 5a280a330401..45083e5dd23b 100644
--- a/drivers/char/scx200_gpio.c
+++ b/drivers/char/scx200_gpio.c
@@ -126,9 +126,10 @@ static int __init scx200_gpio_init(void)
126undo_chrdev_region: 126undo_chrdev_region:
127 unregister_chrdev_region(dev, num_pins); 127 unregister_chrdev_region(dev, num_pins);
128undo_platform_device_add: 128undo_platform_device_add:
129 platform_device_put(pdev); 129 platform_device_del(pdev);
130undo_malloc: 130undo_malloc:
131 kfree(pdev); 131 platform_device_put(pdev);
132
132 return rc; 133 return rc;
133} 134}
134 135
@@ -136,7 +137,6 @@ static void __exit scx200_gpio_cleanup(void)
136{ 137{
137 kfree(scx200_devices); 138 kfree(scx200_devices);
138 unregister_chrdev_region(MKDEV(major, 0), num_pins); 139 unregister_chrdev_region(MKDEV(major, 0), num_pins);
139 platform_device_put(pdev);
140 platform_device_unregister(pdev); 140 platform_device_unregister(pdev);
141 /* kfree(pdev); */ 141 /* kfree(pdev); */
142} 142}
diff --git a/drivers/edac/amd76x_edac.c b/drivers/edac/amd76x_edac.c
index 35599ed4bad5..d75864e35fef 100644
--- a/drivers/edac/amd76x_edac.c
+++ b/drivers/edac/amd76x_edac.c
@@ -19,6 +19,9 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include "edac_mc.h" 20#include "edac_mc.h"
21 21
22#define AMD76X_REVISION " Ver: 2.0.0 " __DATE__
23
24
22#define amd76x_printk(level, fmt, arg...) \ 25#define amd76x_printk(level, fmt, arg...) \
23 edac_printk(level, "amd76x", fmt, ##arg) 26 edac_printk(level, "amd76x", fmt, ##arg)
24 27
@@ -101,15 +104,18 @@ static const struct amd76x_dev_info amd76x_devs[] = {
101static void amd76x_get_error_info(struct mem_ctl_info *mci, 104static void amd76x_get_error_info(struct mem_ctl_info *mci,
102 struct amd76x_error_info *info) 105 struct amd76x_error_info *info)
103{ 106{
104 pci_read_config_dword(mci->pdev, AMD76X_ECC_MODE_STATUS, 107 struct pci_dev *pdev;
108
109 pdev = to_pci_dev(mci->dev);
110 pci_read_config_dword(pdev, AMD76X_ECC_MODE_STATUS,
105 &info->ecc_mode_status); 111 &info->ecc_mode_status);
106 112
107 if (info->ecc_mode_status & BIT(8)) 113 if (info->ecc_mode_status & BIT(8))
108 pci_write_bits32(mci->pdev, AMD76X_ECC_MODE_STATUS, 114 pci_write_bits32(pdev, AMD76X_ECC_MODE_STATUS,
109 (u32) BIT(8), (u32) BIT(8)); 115 (u32) BIT(8), (u32) BIT(8));
110 116
111 if (info->ecc_mode_status & BIT(9)) 117 if (info->ecc_mode_status & BIT(9))
112 pci_write_bits32(mci->pdev, AMD76X_ECC_MODE_STATUS, 118 pci_write_bits32(pdev, AMD76X_ECC_MODE_STATUS,
113 (u32) BIT(9), (u32) BIT(9)); 119 (u32) BIT(9), (u32) BIT(9));
114} 120}
115 121
@@ -175,6 +181,38 @@ static void amd76x_check(struct mem_ctl_info *mci)
175 amd76x_process_error_info(mci, &info, 1); 181 amd76x_process_error_info(mci, &info, 1);
176} 182}
177 183
184static void amd76x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
185 enum edac_type edac_mode)
186{
187 struct csrow_info *csrow;
188 u32 mba, mba_base, mba_mask, dms;
189 int index;
190
191 for (index = 0; index < mci->nr_csrows; index++) {
192 csrow = &mci->csrows[index];
193
194 /* find the DRAM Chip Select Base address and mask */
195 pci_read_config_dword(pdev,
196 AMD76X_MEM_BASE_ADDR + (index * 4),
197 &mba);
198
199 if (!(mba & BIT(0)))
200 continue;
201
202 mba_base = mba & 0xff800000UL;
203 mba_mask = ((mba & 0xff80) << 16) | 0x7fffffUL;
204 pci_read_config_dword(pdev, AMD76X_DRAM_MODE_STATUS, &dms);
205 csrow->first_page = mba_base >> PAGE_SHIFT;
206 csrow->nr_pages = (mba_mask + 1) >> PAGE_SHIFT;
207 csrow->last_page = csrow->first_page + csrow->nr_pages - 1;
208 csrow->page_mask = mba_mask >> PAGE_SHIFT;
209 csrow->grain = csrow->nr_pages << PAGE_SHIFT;
210 csrow->mtype = MEM_RDDR;
211 csrow->dtype = ((dms >> index) & 0x1) ? DEV_X4 : DEV_UNKNOWN;
212 csrow->edac_mode = edac_mode;
213 }
214}
215
178/** 216/**
179 * amd76x_probe1 - Perform set up for detected device 217 * amd76x_probe1 - Perform set up for detected device
180 * @pdev; PCI device detected 218 * @pdev; PCI device detected
@@ -186,15 +224,13 @@ static void amd76x_check(struct mem_ctl_info *mci)
186 */ 224 */
187static int amd76x_probe1(struct pci_dev *pdev, int dev_idx) 225static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
188{ 226{
189 int rc = -ENODEV; 227 static const enum edac_type ems_modes[] = {
190 int index;
191 struct mem_ctl_info *mci = NULL;
192 enum edac_type ems_modes[] = {
193 EDAC_NONE, 228 EDAC_NONE,
194 EDAC_EC, 229 EDAC_EC,
195 EDAC_SECDED, 230 EDAC_SECDED,
196 EDAC_SECDED 231 EDAC_SECDED
197 }; 232 };
233 struct mem_ctl_info *mci = NULL;
198 u32 ems; 234 u32 ems;
199 u32 ems_mode; 235 u32 ems_mode;
200 struct amd76x_error_info discard; 236 struct amd76x_error_info discard;
@@ -205,53 +241,28 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
205 mci = edac_mc_alloc(0, AMD76X_NR_CSROWS, AMD76X_NR_CHANS); 241 mci = edac_mc_alloc(0, AMD76X_NR_CSROWS, AMD76X_NR_CHANS);
206 242
207 if (mci == NULL) { 243 if (mci == NULL) {
208 rc = -ENOMEM; 244 return -ENOMEM;
209 goto fail;
210 } 245 }
211 246
212 debugf0("%s(): mci = %p\n", __func__, mci); 247 debugf0("%s(): mci = %p\n", __func__, mci);
213 mci->pdev = pdev; 248 mci->dev = &pdev->dev;
214 mci->mtype_cap = MEM_FLAG_RDDR; 249 mci->mtype_cap = MEM_FLAG_RDDR;
215 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; 250 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
216 mci->edac_cap = ems_mode ? 251 mci->edac_cap = ems_mode ?
217 (EDAC_FLAG_EC | EDAC_FLAG_SECDED) : EDAC_FLAG_NONE; 252 (EDAC_FLAG_EC | EDAC_FLAG_SECDED) : EDAC_FLAG_NONE;
218 mci->mod_name = EDAC_MOD_STR; 253 mci->mod_name = EDAC_MOD_STR;
219 mci->mod_ver = "$Revision: 1.4.2.5 $"; 254 mci->mod_ver = AMD76X_REVISION;
220 mci->ctl_name = amd76x_devs[dev_idx].ctl_name; 255 mci->ctl_name = amd76x_devs[dev_idx].ctl_name;
221 mci->edac_check = amd76x_check; 256 mci->edac_check = amd76x_check;
222 mci->ctl_page_to_phys = NULL; 257 mci->ctl_page_to_phys = NULL;
223 258
224 for (index = 0; index < mci->nr_csrows; index++) { 259 amd76x_init_csrows(mci, pdev, ems_modes[ems_mode]);
225 struct csrow_info *csrow = &mci->csrows[index];
226 u32 mba;
227 u32 mba_base;
228 u32 mba_mask;
229 u32 dms;
230
231 /* find the DRAM Chip Select Base address and mask */
232 pci_read_config_dword(mci->pdev,
233 AMD76X_MEM_BASE_ADDR + (index * 4), &mba);
234
235 if (!(mba & BIT(0)))
236 continue;
237
238 mba_base = mba & 0xff800000UL;
239 mba_mask = ((mba & 0xff80) << 16) | 0x7fffffUL;
240 pci_read_config_dword(mci->pdev, AMD76X_DRAM_MODE_STATUS,
241 &dms);
242 csrow->first_page = mba_base >> PAGE_SHIFT;
243 csrow->nr_pages = (mba_mask + 1) >> PAGE_SHIFT;
244 csrow->last_page = csrow->first_page + csrow->nr_pages - 1;
245 csrow->page_mask = mba_mask >> PAGE_SHIFT;
246 csrow->grain = csrow->nr_pages << PAGE_SHIFT;
247 csrow->mtype = MEM_RDDR;
248 csrow->dtype = ((dms >> index) & 0x1) ? DEV_X4 : DEV_UNKNOWN;
249 csrow->edac_mode = ems_modes[ems_mode];
250 }
251
252 amd76x_get_error_info(mci, &discard); /* clear counters */ 260 amd76x_get_error_info(mci, &discard); /* clear counters */
253 261
254 if (edac_mc_add_mc(mci)) { 262 /* Here we assume that we will never see multiple instances of this
263 * type of memory controller. The ID is therefore hardcoded to 0.
264 */
265 if (edac_mc_add_mc(mci,0)) {
255 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 266 debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
256 goto fail; 267 goto fail;
257 } 268 }
@@ -261,9 +272,8 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
261 return 0; 272 return 0;
262 273
263fail: 274fail:
264 if (mci != NULL) 275 edac_mc_free(mci);
265 edac_mc_free(mci); 276 return -ENODEV;
266 return rc;
267} 277}
268 278
269/* returns count (>= 0), or negative on error */ 279/* returns count (>= 0), or negative on error */
@@ -290,7 +300,7 @@ static void __devexit amd76x_remove_one(struct pci_dev *pdev)
290 300
291 debugf0("%s()\n", __func__); 301 debugf0("%s()\n", __func__);
292 302
293 if ((mci = edac_mc_del_mc(pdev)) == NULL) 303 if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
294 return; 304 return;
295 305
296 edac_mc_free(mci); 306 edac_mc_free(mci);
diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
index a52573b3280c..815c3eb783de 100644
--- a/drivers/edac/e752x_edac.c
+++ b/drivers/edac/e752x_edac.c
@@ -24,6 +24,8 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include "edac_mc.h" 25#include "edac_mc.h"
26 26
27#define E752X_REVISION " Ver: 2.0.0 " __DATE__
28
27static int force_function_unhide; 29static int force_function_unhide;
28 30
29#define e752x_printk(level, fmt, arg...) \ 31#define e752x_printk(level, fmt, arg...) \
@@ -762,22 +764,174 @@ static void e752x_check(struct mem_ctl_info *mci)
762 e752x_process_error_info(mci, &info, 1); 764 e752x_process_error_info(mci, &info, 1);
763} 765}
764 766
765static int e752x_probe1(struct pci_dev *pdev, int dev_idx) 767/* Return 1 if dual channel mode is active. Else return 0. */
768static inline int dual_channel_active(u16 ddrcsr)
769{
770 return (((ddrcsr >> 12) & 3) == 3);
771}
772
773static void e752x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
774 u16 ddrcsr)
775{
776 struct csrow_info *csrow;
777 unsigned long last_cumul_size;
778 int index, mem_dev, drc_chan;
779 int drc_drbg; /* DRB granularity 0=64mb, 1=128mb */
780 int drc_ddim; /* DRAM Data Integrity Mode 0=none, 2=edac */
781 u8 value;
782 u32 dra, drc, cumul_size;
783
784 pci_read_config_dword(pdev, E752X_DRA, &dra);
785 pci_read_config_dword(pdev, E752X_DRC, &drc);
786 drc_chan = dual_channel_active(ddrcsr);
787 drc_drbg = drc_chan + 1; /* 128 in dual mode, 64 in single */
788 drc_ddim = (drc >> 20) & 0x3;
789
790 /* The dram row boundary (DRB) reg values are boundary address for
791 * each DRAM row with a granularity of 64 or 128MB (single/dual
792 * channel operation). DRB regs are cumulative; therefore DRB7 will
793 * contain the total memory contained in all eight rows.
794 */
795 for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
796 /* mem_dev 0=x8, 1=x4 */
797 mem_dev = (dra >> (index * 4 + 2)) & 0x3;
798 csrow = &mci->csrows[index];
799
800 mem_dev = (mem_dev == 2);
801 pci_read_config_byte(pdev, E752X_DRB + index, &value);
802 /* convert a 128 or 64 MiB DRB to a page size. */
803 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
804 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
805 cumul_size);
806 if (cumul_size == last_cumul_size)
807 continue; /* not populated */
808
809 csrow->first_page = last_cumul_size;
810 csrow->last_page = cumul_size - 1;
811 csrow->nr_pages = cumul_size - last_cumul_size;
812 last_cumul_size = cumul_size;
813 csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */
814 csrow->mtype = MEM_RDDR; /* only one type supported */
815 csrow->dtype = mem_dev ? DEV_X4 : DEV_X8;
816
817 /*
818 * if single channel or x8 devices then SECDED
819 * if dual channel and x4 then S4ECD4ED
820 */
821 if (drc_ddim) {
822 if (drc_chan && mem_dev) {
823 csrow->edac_mode = EDAC_S4ECD4ED;
824 mci->edac_cap |= EDAC_FLAG_S4ECD4ED;
825 } else {
826 csrow->edac_mode = EDAC_SECDED;
827 mci->edac_cap |= EDAC_FLAG_SECDED;
828 }
829 } else
830 csrow->edac_mode = EDAC_NONE;
831 }
832}
833
834static void e752x_init_mem_map_table(struct pci_dev *pdev,
835 struct e752x_pvt *pvt)
766{ 836{
767 int rc = -ENODEV;
768 int index; 837 int index;
838 u8 value, last, row, stat8;
839
840 last = 0;
841 row = 0;
842
843 for (index = 0; index < 8; index += 2) {
844 pci_read_config_byte(pdev, E752X_DRB + index, &value);
845 /* test if there is a dimm in this slot */
846 if (value == last) {
847 /* no dimm in the slot, so flag it as empty */
848 pvt->map[index] = 0xff;
849 pvt->map[index + 1] = 0xff;
850 } else { /* there is a dimm in the slot */
851 pvt->map[index] = row;
852 row++;
853 last = value;
854 /* test the next value to see if the dimm is double
855 * sided
856 */
857 pci_read_config_byte(pdev, E752X_DRB + index + 1,
858 &value);
859 pvt->map[index + 1] = (value == last) ?
860 0xff : /* the dimm is single sided,
861 so flag as empty */
862 row; /* this is a double sided dimm
863 to save the next row # */
864 row++;
865 last = value;
866 }
867 }
868
869 /* set the map type. 1 = normal, 0 = reversed */
870 pci_read_config_byte(pdev, E752X_DRM, &stat8);
871 pvt->map_type = ((stat8 & 0x0f) > ((stat8 >> 4) & 0x0f));
872}
873
874/* Return 0 on success or 1 on failure. */
875static int e752x_get_devs(struct pci_dev *pdev, int dev_idx,
876 struct e752x_pvt *pvt)
877{
878 struct pci_dev *dev;
879
880 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
881 pvt->dev_info->err_dev,
882 pvt->bridge_ck);
883
884 if (pvt->bridge_ck == NULL)
885 pvt->bridge_ck = pci_scan_single_device(pdev->bus,
886 PCI_DEVFN(0, 1));
887
888 if (pvt->bridge_ck == NULL) {
889 e752x_printk(KERN_ERR, "error reporting device not found:"
890 "vendor %x device 0x%x (broken BIOS?)\n",
891 PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].err_dev);
892 return 1;
893 }
894
895 dev = pci_get_device(PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].ctl_dev,
896 NULL);
897
898 if (dev == NULL)
899 goto fail;
900
901 pvt->dev_d0f0 = dev;
902 pvt->dev_d0f1 = pci_dev_get(pvt->bridge_ck);
903
904 return 0;
905
906fail:
907 pci_dev_put(pvt->bridge_ck);
908 return 1;
909}
910
911static void e752x_init_error_reporting_regs(struct e752x_pvt *pvt)
912{
913 struct pci_dev *dev;
914
915 dev = pvt->dev_d0f1;
916 /* Turn off error disable & SMI in case the BIOS turned it on */
917 pci_write_config_byte(dev, E752X_HI_ERRMASK, 0x00);
918 pci_write_config_byte(dev, E752X_HI_SMICMD, 0x00);
919 pci_write_config_word(dev, E752X_SYSBUS_ERRMASK, 0x00);
920 pci_write_config_word(dev, E752X_SYSBUS_SMICMD, 0x00);
921 pci_write_config_byte(dev, E752X_BUF_ERRMASK, 0x00);
922 pci_write_config_byte(dev, E752X_BUF_SMICMD, 0x00);
923 pci_write_config_byte(dev, E752X_DRAM_ERRMASK, 0x00);
924 pci_write_config_byte(dev, E752X_DRAM_SMICMD, 0x00);
925}
926
927static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
928{
769 u16 pci_data; 929 u16 pci_data;
770 u8 stat8; 930 u8 stat8;
771 struct mem_ctl_info *mci = NULL; 931 struct mem_ctl_info *mci;
772 struct e752x_pvt *pvt = NULL; 932 struct e752x_pvt *pvt;
773 u16 ddrcsr; 933 u16 ddrcsr;
774 u32 drc;
775 int drc_chan; /* Number of channels 0=1chan,1=2chan */ 934 int drc_chan; /* Number of channels 0=1chan,1=2chan */
776 int drc_drbg; /* DRB granularity 0=64mb, 1=128mb */
777 int drc_ddim; /* DRAM Data Integrity Mode 0=none,2=edac */
778 u32 dra;
779 unsigned long last_cumul_size;
780 struct pci_dev *dev = NULL;
781 struct e752x_error_info discard; 935 struct e752x_error_info discard;
782 936
783 debugf0("%s(): mci\n", __func__); 937 debugf0("%s(): mci\n", __func__);
@@ -791,25 +945,20 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
791 if (!force_function_unhide && !(stat8 & (1 << 5))) { 945 if (!force_function_unhide && !(stat8 & (1 << 5))) {
792 printk(KERN_INFO "Contact your BIOS vendor to see if the " 946 printk(KERN_INFO "Contact your BIOS vendor to see if the "
793 "E752x error registers can be safely un-hidden\n"); 947 "E752x error registers can be safely un-hidden\n");
794 goto fail; 948 return -ENOMEM;
795 } 949 }
796 stat8 |= (1 << 5); 950 stat8 |= (1 << 5);
797 pci_write_config_byte(pdev, E752X_DEVPRES1, stat8); 951 pci_write_config_byte(pdev, E752X_DEVPRES1, stat8);
798 952
799 /* need to find out the number of channels */
800 pci_read_config_dword(pdev, E752X_DRC, &drc);
801 pci_read_config_word(pdev, E752X_DDRCSR, &ddrcsr); 953 pci_read_config_word(pdev, E752X_DDRCSR, &ddrcsr);
802 /* FIXME: should check >>12 or 0xf, true for all? */ 954 /* FIXME: should check >>12 or 0xf, true for all? */
803 /* Dual channel = 1, Single channel = 0 */ 955 /* Dual channel = 1, Single channel = 0 */
804 drc_chan = (((ddrcsr >> 12) & 3) == 3); 956 drc_chan = dual_channel_active(ddrcsr);
805 drc_drbg = drc_chan + 1; /* 128 in dual mode, 64 in single */
806 drc_ddim = (drc >> 20) & 0x3;
807 957
808 mci = edac_mc_alloc(sizeof(*pvt), E752X_NR_CSROWS, drc_chan + 1); 958 mci = edac_mc_alloc(sizeof(*pvt), E752X_NR_CSROWS, drc_chan + 1);
809 959
810 if (mci == NULL) { 960 if (mci == NULL) {
811 rc = -ENOMEM; 961 return -ENOMEM;
812 goto fail;
813 } 962 }
814 963
815 debugf3("%s(): init mci\n", __func__); 964 debugf3("%s(): init mci\n", __func__);
@@ -818,159 +967,54 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
818 EDAC_FLAG_S4ECD4ED; 967 EDAC_FLAG_S4ECD4ED;
819 /* FIXME - what if different memory types are in different csrows? */ 968 /* FIXME - what if different memory types are in different csrows? */
820 mci->mod_name = EDAC_MOD_STR; 969 mci->mod_name = EDAC_MOD_STR;
821 mci->mod_ver = "$Revision: 1.5.2.11 $"; 970 mci->mod_ver = E752X_REVISION;
822 mci->pdev = pdev; 971 mci->dev = &pdev->dev;
823 972
824 debugf3("%s(): init pvt\n", __func__); 973 debugf3("%s(): init pvt\n", __func__);
825 pvt = (struct e752x_pvt *) mci->pvt_info; 974 pvt = (struct e752x_pvt *) mci->pvt_info;
826 pvt->dev_info = &e752x_devs[dev_idx]; 975 pvt->dev_info = &e752x_devs[dev_idx];
827 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL, 976 pvt->mc_symmetric = ((ddrcsr & 0x10) != 0);
828 pvt->dev_info->err_dev,
829 pvt->bridge_ck);
830
831 if (pvt->bridge_ck == NULL)
832 pvt->bridge_ck = pci_scan_single_device(pdev->bus,
833 PCI_DEVFN(0, 1));
834 977
835 if (pvt->bridge_ck == NULL) { 978 if (e752x_get_devs(pdev, dev_idx, pvt)) {
836 e752x_printk(KERN_ERR, "error reporting device not found:" 979 edac_mc_free(mci);
837 "vendor %x device 0x%x (broken BIOS?)\n", 980 return -ENODEV;
838 PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].err_dev);
839 goto fail;
840 } 981 }
841 982
842 pvt->mc_symmetric = ((ddrcsr & 0x10) != 0);
843 debugf3("%s(): more mci init\n", __func__); 983 debugf3("%s(): more mci init\n", __func__);
844 mci->ctl_name = pvt->dev_info->ctl_name; 984 mci->ctl_name = pvt->dev_info->ctl_name;
845 mci->edac_check = e752x_check; 985 mci->edac_check = e752x_check;
846 mci->ctl_page_to_phys = ctl_page_to_phys; 986 mci->ctl_page_to_phys = ctl_page_to_phys;
847 987
848 /* find out the device types */ 988 e752x_init_csrows(mci, pdev, ddrcsr);
849 pci_read_config_dword(pdev, E752X_DRA, &dra); 989 e752x_init_mem_map_table(pdev, pvt);
850
851 /*
852 * The dram row boundary (DRB) reg values are boundary address for
853 * each DRAM row with a granularity of 64 or 128MB (single/dual
854 * channel operation). DRB regs are cumulative; therefore DRB7 will
855 * contain the total memory contained in all eight rows.
856 */
857 for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
858 u8 value;
859 u32 cumul_size;
860
861 /* mem_dev 0=x8, 1=x4 */
862 int mem_dev = (dra >> (index * 4 + 2)) & 0x3;
863 struct csrow_info *csrow = &mci->csrows[index];
864
865 mem_dev = (mem_dev == 2);
866 pci_read_config_byte(mci->pdev, E752X_DRB + index, &value);
867 /* convert a 128 or 64 MiB DRB to a page size. */
868 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
869 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
870 cumul_size);
871
872 if (cumul_size == last_cumul_size)
873 continue; /* not populated */
874
875 csrow->first_page = last_cumul_size;
876 csrow->last_page = cumul_size - 1;
877 csrow->nr_pages = cumul_size - last_cumul_size;
878 last_cumul_size = cumul_size;
879 csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */
880 csrow->mtype = MEM_RDDR; /* only one type supported */
881 csrow->dtype = mem_dev ? DEV_X4 : DEV_X8;
882
883 /*
884 * if single channel or x8 devices then SECDED
885 * if dual channel and x4 then S4ECD4ED
886 */
887 if (drc_ddim) {
888 if (drc_chan && mem_dev) {
889 csrow->edac_mode = EDAC_S4ECD4ED;
890 mci->edac_cap |= EDAC_FLAG_S4ECD4ED;
891 } else {
892 csrow->edac_mode = EDAC_SECDED;
893 mci->edac_cap |= EDAC_FLAG_SECDED;
894 }
895 } else
896 csrow->edac_mode = EDAC_NONE;
897 }
898
899 /* Fill in the memory map table */
900 {
901 u8 value;
902 u8 last = 0;
903 u8 row = 0;
904
905 for (index = 0; index < 8; index += 2) {
906 pci_read_config_byte(mci->pdev, E752X_DRB + index,
907 &value);
908
909 /* test if there is a dimm in this slot */
910 if (value == last) {
911 /* no dimm in the slot, so flag it as empty */
912 pvt->map[index] = 0xff;
913 pvt->map[index + 1] = 0xff;
914 } else { /* there is a dimm in the slot */
915 pvt->map[index] = row;
916 row++;
917 last = value;
918 /* test the next value to see if the dimm is
919 double sided */
920 pci_read_config_byte(mci->pdev,
921 E752X_DRB + index + 1,
922 &value);
923 pvt->map[index + 1] = (value == last) ?
924 0xff : /* the dimm is single sided,
925 * so flag as empty
926 */
927 row; /* this is a double sided dimm
928 * to save the next row #
929 */
930 row++;
931 last = value;
932 }
933 }
934 }
935 990
936 /* set the map type. 1 = normal, 0 = reversed */ 991 /* set the map type. 1 = normal, 0 = reversed */
937 pci_read_config_byte(mci->pdev, E752X_DRM, &stat8); 992 pci_read_config_byte(pdev, E752X_DRM, &stat8);
938 pvt->map_type = ((stat8 & 0x0f) > ((stat8 >> 4) & 0x0f)); 993 pvt->map_type = ((stat8 & 0x0f) > ((stat8 >> 4) & 0x0f));
939 994
940 mci->edac_cap |= EDAC_FLAG_NONE; 995 mci->edac_cap |= EDAC_FLAG_NONE;
941 debugf3("%s(): tolm, remapbase, remaplimit\n", __func__); 996 debugf3("%s(): tolm, remapbase, remaplimit\n", __func__);
942 997
943 /* load the top of low memory, remap base, and remap limit vars */ 998 /* load the top of low memory, remap base, and remap limit vars */
944 pci_read_config_word(mci->pdev, E752X_TOLM, &pci_data); 999 pci_read_config_word(pdev, E752X_TOLM, &pci_data);
945 pvt->tolm = ((u32) pci_data) << 4; 1000 pvt->tolm = ((u32) pci_data) << 4;
946 pci_read_config_word(mci->pdev, E752X_REMAPBASE, &pci_data); 1001 pci_read_config_word(pdev, E752X_REMAPBASE, &pci_data);
947 pvt->remapbase = ((u32) pci_data) << 14; 1002 pvt->remapbase = ((u32) pci_data) << 14;
948 pci_read_config_word(mci->pdev, E752X_REMAPLIMIT, &pci_data); 1003 pci_read_config_word(pdev, E752X_REMAPLIMIT, &pci_data);
949 pvt->remaplimit = ((u32) pci_data) << 14; 1004 pvt->remaplimit = ((u32) pci_data) << 14;
950 e752x_printk(KERN_INFO, 1005 e752x_printk(KERN_INFO,
951 "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm, 1006 "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm,
952 pvt->remapbase, pvt->remaplimit); 1007 pvt->remapbase, pvt->remaplimit);
953 1008
954 if (edac_mc_add_mc(mci)) { 1009 /* Here we assume that we will never see multiple instances of this
1010 * type of memory controller. The ID is therefore hardcoded to 0.
1011 */
1012 if (edac_mc_add_mc(mci,0)) {
955 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 1013 debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
956 goto fail; 1014 goto fail;
957 } 1015 }
958 1016
959 dev = pci_get_device(PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].ctl_dev, 1017 e752x_init_error_reporting_regs(pvt);
960 NULL);
961 pvt->dev_d0f0 = dev;
962 /* find the error reporting device and clear errors */
963 dev = pvt->dev_d0f1 = pci_dev_get(pvt->bridge_ck);
964 /* Turn off error disable & SMI in case the BIOS turned it on */
965 pci_write_config_byte(dev, E752X_HI_ERRMASK, 0x00);
966 pci_write_config_byte(dev, E752X_HI_SMICMD, 0x00);
967 pci_write_config_word(dev, E752X_SYSBUS_ERRMASK, 0x00);
968 pci_write_config_word(dev, E752X_SYSBUS_SMICMD, 0x00);
969 pci_write_config_byte(dev, E752X_BUF_ERRMASK, 0x00);
970 pci_write_config_byte(dev, E752X_BUF_SMICMD, 0x00);
971 pci_write_config_byte(dev, E752X_DRAM_ERRMASK, 0x00);
972 pci_write_config_byte(dev, E752X_DRAM_SMICMD, 0x00);
973
974 e752x_get_error_info(mci, &discard); /* clear other MCH errors */ 1018 e752x_get_error_info(mci, &discard); /* clear other MCH errors */
975 1019
976 /* get this far and it's successful */ 1020 /* get this far and it's successful */
@@ -978,20 +1022,12 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
978 return 0; 1022 return 0;
979 1023
980fail: 1024fail:
981 if (mci) { 1025 pci_dev_put(pvt->dev_d0f0);
982 if (pvt->dev_d0f0) 1026 pci_dev_put(pvt->dev_d0f1);
983 pci_dev_put(pvt->dev_d0f0); 1027 pci_dev_put(pvt->bridge_ck);
984 1028 edac_mc_free(mci);
985 if (pvt->dev_d0f1)
986 pci_dev_put(pvt->dev_d0f1);
987
988 if (pvt->bridge_ck)
989 pci_dev_put(pvt->bridge_ck);
990
991 edac_mc_free(mci);
992 }
993 1029
994 return rc; 1030 return -ENODEV;
995} 1031}
996 1032
997/* returns count (>= 0), or negative on error */ 1033/* returns count (>= 0), or negative on error */
@@ -1014,7 +1050,7 @@ static void __devexit e752x_remove_one(struct pci_dev *pdev)
1014 1050
1015 debugf0("%s()\n", __func__); 1051 debugf0("%s()\n", __func__);
1016 1052
1017 if ((mci = edac_mc_del_mc(pdev)) == NULL) 1053 if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
1018 return; 1054 return;
1019 1055
1020 pvt = (struct e752x_pvt *) mci->pvt_info; 1056 pvt = (struct e752x_pvt *) mci->pvt_info;
diff --git a/drivers/edac/e7xxx_edac.c b/drivers/edac/e7xxx_edac.c
index ecfca7c6bba6..5a5ecd5a0409 100644
--- a/drivers/edac/e7xxx_edac.c
+++ b/drivers/edac/e7xxx_edac.c
@@ -29,6 +29,8 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include "edac_mc.h" 30#include "edac_mc.h"
31 31
32#define E7XXX_REVISION " Ver: 2.0.0 " __DATE__
33
32#define e7xxx_printk(level, fmt, arg...) \ 34#define e7xxx_printk(level, fmt, arg...) \
33 edac_printk(level, "e7xxx", fmt, ##arg) 35 edac_printk(level, "e7xxx", fmt, ##arg)
34 36
@@ -332,99 +334,61 @@ static void e7xxx_check(struct mem_ctl_info *mci)
332 e7xxx_process_error_info(mci, &info, 1); 334 e7xxx_process_error_info(mci, &info, 1);
333} 335}
334 336
335static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx) 337/* Return 1 if dual channel mode is active. Else return 0. */
338static inline int dual_channel_active(u32 drc, int dev_idx)
336{ 339{
337 int rc = -ENODEV; 340 return (dev_idx == E7501) ? ((drc >> 22) & 0x1) : 1;
338 int index; 341}
339 u16 pci_data;
340 struct mem_ctl_info *mci = NULL;
341 struct e7xxx_pvt *pvt = NULL;
342 u32 drc;
343 int drc_chan = 1; /* Number of channels 0=1chan,1=2chan */
344 int drc_drbg = 1; /* DRB granularity 0=32mb,1=64mb */
345 int drc_ddim; /* DRAM Data Integrity Mode 0=none,2=edac */
346 u32 dra;
347 unsigned long last_cumul_size;
348 struct e7xxx_error_info discard;
349
350 debugf0("%s(): mci\n", __func__);
351 342
352 /* need to find out the number of channels */
353 pci_read_config_dword(pdev, E7XXX_DRC, &drc);
354 343
344/* Return DRB granularity (0=32mb, 1=64mb). */
345static inline int drb_granularity(u32 drc, int dev_idx)
346{
355 /* only e7501 can be single channel */ 347 /* only e7501 can be single channel */
356 if (dev_idx == E7501) { 348 return (dev_idx == E7501) ? ((drc >> 18) & 0x3) : 1;
357 drc_chan = ((drc >> 22) & 0x1); 349}
358 drc_drbg = (drc >> 18) & 0x3;
359 }
360
361 drc_ddim = (drc >> 20) & 0x3;
362 mci = edac_mc_alloc(sizeof(*pvt), E7XXX_NR_CSROWS, drc_chan + 1);
363
364 if (mci == NULL) {
365 rc = -ENOMEM;
366 goto fail;
367 }
368
369 debugf3("%s(): init mci\n", __func__);
370 mci->mtype_cap = MEM_FLAG_RDDR;
371 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED |
372 EDAC_FLAG_S4ECD4ED;
373 /* FIXME - what if different memory types are in different csrows? */
374 mci->mod_name = EDAC_MOD_STR;
375 mci->mod_ver = "$Revision: 1.5.2.9 $";
376 mci->pdev = pdev;
377 350
378 debugf3("%s(): init pvt\n", __func__);
379 pvt = (struct e7xxx_pvt *) mci->pvt_info;
380 pvt->dev_info = &e7xxx_devs[dev_idx];
381 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
382 pvt->dev_info->err_dev,
383 pvt->bridge_ck);
384 351
385 if (!pvt->bridge_ck) { 352static void e7xxx_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
386 e7xxx_printk(KERN_ERR, "error reporting device not found:" 353 int dev_idx, u32 drc)
387 "vendor %x device 0x%x (broken BIOS?)\n", 354{
388 PCI_VENDOR_ID_INTEL, e7xxx_devs[dev_idx].err_dev); 355 unsigned long last_cumul_size;
389 goto fail; 356 int index;
390 } 357 u8 value;
391 358 u32 dra, cumul_size;
392 debugf3("%s(): more mci init\n", __func__); 359 int drc_chan, drc_drbg, drc_ddim, mem_dev;
393 mci->ctl_name = pvt->dev_info->ctl_name; 360 struct csrow_info *csrow;
394 mci->edac_check = e7xxx_check;
395 mci->ctl_page_to_phys = ctl_page_to_phys;
396 361
397 /* find out the device types */
398 pci_read_config_dword(pdev, E7XXX_DRA, &dra); 362 pci_read_config_dword(pdev, E7XXX_DRA, &dra);
363 drc_chan = dual_channel_active(drc, dev_idx);
364 drc_drbg = drb_granularity(drc, dev_idx);
365 drc_ddim = (drc >> 20) & 0x3;
366 last_cumul_size = 0;
399 367
400 /* 368 /* The dram row boundary (DRB) reg values are boundary address
401 * The dram row boundary (DRB) reg values are boundary address
402 * for each DRAM row with a granularity of 32 or 64MB (single/dual 369 * for each DRAM row with a granularity of 32 or 64MB (single/dual
403 * channel operation). DRB regs are cumulative; therefore DRB7 will 370 * channel operation). DRB regs are cumulative; therefore DRB7 will
404 * contain the total memory contained in all eight rows. 371 * contain the total memory contained in all eight rows.
405 */ 372 */
406 for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) { 373 for (index = 0; index < mci->nr_csrows; index++) {
407 u8 value;
408 u32 cumul_size;
409 /* mem_dev 0=x8, 1=x4 */ 374 /* mem_dev 0=x8, 1=x4 */
410 int mem_dev = (dra >> (index * 4 + 3)) & 0x1; 375 mem_dev = (dra >> (index * 4 + 3)) & 0x1;
411 struct csrow_info *csrow = &mci->csrows[index]; 376 csrow = &mci->csrows[index];
412 377
413 pci_read_config_byte(mci->pdev, E7XXX_DRB + index, &value); 378 pci_read_config_byte(pdev, E7XXX_DRB + index, &value);
414 /* convert a 64 or 32 MiB DRB to a page size. */ 379 /* convert a 64 or 32 MiB DRB to a page size. */
415 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT); 380 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
416 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, 381 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
417 cumul_size); 382 cumul_size);
418
419 if (cumul_size == last_cumul_size) 383 if (cumul_size == last_cumul_size)
420 continue; /* not populated */ 384 continue; /* not populated */
421 385
422 csrow->first_page = last_cumul_size; 386 csrow->first_page = last_cumul_size;
423 csrow->last_page = cumul_size - 1; 387 csrow->last_page = cumul_size - 1;
424 csrow->nr_pages = cumul_size - last_cumul_size; 388 csrow->nr_pages = cumul_size - last_cumul_size;
425 last_cumul_size = cumul_size; 389 last_cumul_size = cumul_size;
426 csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */ 390 csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */
427 csrow->mtype = MEM_RDDR; /* only one type supported */ 391 csrow->mtype = MEM_RDDR; /* only one type supported */
428 csrow->dtype = mem_dev ? DEV_X4 : DEV_X8; 392 csrow->dtype = mem_dev ? DEV_X4 : DEV_X8;
429 393
430 /* 394 /*
@@ -442,16 +406,61 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
442 } else 406 } else
443 csrow->edac_mode = EDAC_NONE; 407 csrow->edac_mode = EDAC_NONE;
444 } 408 }
409}
445 410
446 mci->edac_cap |= EDAC_FLAG_NONE; 411static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
412{
413 u16 pci_data;
414 struct mem_ctl_info *mci = NULL;
415 struct e7xxx_pvt *pvt = NULL;
416 u32 drc;
417 int drc_chan;
418 struct e7xxx_error_info discard;
419
420 debugf0("%s(): mci\n", __func__);
421 pci_read_config_dword(pdev, E7XXX_DRC, &drc);
422
423 drc_chan = dual_channel_active(drc, dev_idx);
424 mci = edac_mc_alloc(sizeof(*pvt), E7XXX_NR_CSROWS, drc_chan + 1);
425
426 if (mci == NULL)
427 return -ENOMEM;
428
429 debugf3("%s(): init mci\n", __func__);
430 mci->mtype_cap = MEM_FLAG_RDDR;
431 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED |
432 EDAC_FLAG_S4ECD4ED;
433 /* FIXME - what if different memory types are in different csrows? */
434 mci->mod_name = EDAC_MOD_STR;
435 mci->mod_ver = E7XXX_REVISION;
436 mci->dev = &pdev->dev;
437 debugf3("%s(): init pvt\n", __func__);
438 pvt = (struct e7xxx_pvt *) mci->pvt_info;
439 pvt->dev_info = &e7xxx_devs[dev_idx];
440 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
441 pvt->dev_info->err_dev,
442 pvt->bridge_ck);
447 443
444 if (!pvt->bridge_ck) {
445 e7xxx_printk(KERN_ERR, "error reporting device not found:"
446 "vendor %x device 0x%x (broken BIOS?)\n",
447 PCI_VENDOR_ID_INTEL, e7xxx_devs[dev_idx].err_dev);
448 goto fail0;
449 }
450
451 debugf3("%s(): more mci init\n", __func__);
452 mci->ctl_name = pvt->dev_info->ctl_name;
453 mci->edac_check = e7xxx_check;
454 mci->ctl_page_to_phys = ctl_page_to_phys;
455 e7xxx_init_csrows(mci, pdev, dev_idx, drc);
456 mci->edac_cap |= EDAC_FLAG_NONE;
448 debugf3("%s(): tolm, remapbase, remaplimit\n", __func__); 457 debugf3("%s(): tolm, remapbase, remaplimit\n", __func__);
449 /* load the top of low memory, remap base, and remap limit vars */ 458 /* load the top of low memory, remap base, and remap limit vars */
450 pci_read_config_word(mci->pdev, E7XXX_TOLM, &pci_data); 459 pci_read_config_word(pdev, E7XXX_TOLM, &pci_data);
451 pvt->tolm = ((u32) pci_data) << 4; 460 pvt->tolm = ((u32) pci_data) << 4;
452 pci_read_config_word(mci->pdev, E7XXX_REMAPBASE, &pci_data); 461 pci_read_config_word(pdev, E7XXX_REMAPBASE, &pci_data);
453 pvt->remapbase = ((u32) pci_data) << 14; 462 pvt->remapbase = ((u32) pci_data) << 14;
454 pci_read_config_word(mci->pdev, E7XXX_REMAPLIMIT, &pci_data); 463 pci_read_config_word(pdev, E7XXX_REMAPLIMIT, &pci_data);
455 pvt->remaplimit = ((u32) pci_data) << 14; 464 pvt->remaplimit = ((u32) pci_data) << 14;
456 e7xxx_printk(KERN_INFO, 465 e7xxx_printk(KERN_INFO,
457 "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm, 466 "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm,
@@ -460,23 +469,25 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
460 /* clear any pending errors, or initial state bits */ 469 /* clear any pending errors, or initial state bits */
461 e7xxx_get_error_info(mci, &discard); 470 e7xxx_get_error_info(mci, &discard);
462 471
463 if (edac_mc_add_mc(mci) != 0) { 472 /* Here we assume that we will never see multiple instances of this
473 * type of memory controller. The ID is therefore hardcoded to 0.
474 */
475 if (edac_mc_add_mc(mci,0)) {
464 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 476 debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
465 goto fail; 477 goto fail1;
466 } 478 }
467 479
468 /* get this far and it's successful */ 480 /* get this far and it's successful */
469 debugf3("%s(): success\n", __func__); 481 debugf3("%s(): success\n", __func__);
470 return 0; 482 return 0;
471 483
472fail: 484fail1:
473 if (mci != NULL) { 485 pci_dev_put(pvt->bridge_ck);
474 if(pvt != NULL && pvt->bridge_ck) 486
475 pci_dev_put(pvt->bridge_ck); 487fail0:
476 edac_mc_free(mci); 488 edac_mc_free(mci);
477 }
478 489
479 return rc; 490 return -ENODEV;
480} 491}
481 492
482/* returns count (>= 0), or negative on error */ 493/* returns count (>= 0), or negative on error */
@@ -497,7 +508,7 @@ static void __devexit e7xxx_remove_one(struct pci_dev *pdev)
497 508
498 debugf0("%s()\n", __func__); 509 debugf0("%s()\n", __func__);
499 510
500 if ((mci = edac_mc_del_mc(pdev)) == NULL) 511 if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
501 return; 512 return;
502 513
503 pvt = (struct e7xxx_pvt *) mci->pvt_info; 514 pvt = (struct e7xxx_pvt *) mci->pvt_info;
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 0499782db7c7..3a7cfe88b169 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -53,16 +53,17 @@ static int log_ce = 1;
53static int panic_on_ue; 53static int panic_on_ue;
54static int poll_msec = 1000; 54static int poll_msec = 1000;
55 55
56static int check_pci_parity = 0; /* default YES check PCI parity */
57static int panic_on_pci_parity; /* default no panic on PCI Parity */
58static atomic_t pci_parity_count = ATOMIC_INIT(0);
59
60/* lock to memory controller's control array */ 56/* lock to memory controller's control array */
61static DECLARE_MUTEX(mem_ctls_mutex); 57static DECLARE_MUTEX(mem_ctls_mutex);
62static struct list_head mc_devices = LIST_HEAD_INIT(mc_devices); 58static struct list_head mc_devices = LIST_HEAD_INIT(mc_devices);
63 59
64static struct task_struct *edac_thread; 60static struct task_struct *edac_thread;
65 61
62#ifdef CONFIG_PCI
63static int check_pci_parity = 0; /* default YES check PCI parity */
64static int panic_on_pci_parity; /* default no panic on PCI Parity */
65static atomic_t pci_parity_count = ATOMIC_INIT(0);
66
66/* Structure of the whitelist and blacklist arrays */ 67/* Structure of the whitelist and blacklist arrays */
67struct edac_pci_device_list { 68struct edac_pci_device_list {
68 unsigned int vendor; /* Vendor ID */ 69 unsigned int vendor; /* Vendor ID */
@@ -79,6 +80,12 @@ static int pci_blacklist_count;
79static struct edac_pci_device_list pci_whitelist[MAX_LISTED_PCI_DEVICES]; 80static struct edac_pci_device_list pci_whitelist[MAX_LISTED_PCI_DEVICES];
80static int pci_whitelist_count ; 81static int pci_whitelist_count ;
81 82
83#ifndef DISABLE_EDAC_SYSFS
84static struct kobject edac_pci_kobj; /* /sys/devices/system/edac/pci */
85static struct completion edac_pci_kobj_complete;
86#endif /* DISABLE_EDAC_SYSFS */
87#endif /* CONFIG_PCI */
88
82/* START sysfs data and methods */ 89/* START sysfs data and methods */
83 90
84#ifndef DISABLE_EDAC_SYSFS 91#ifndef DISABLE_EDAC_SYSFS
@@ -126,18 +133,15 @@ static struct sysdev_class edac_class = {
126 set_kset_name("edac"), 133 set_kset_name("edac"),
127}; 134};
128 135
129/* sysfs objects: 136/* sysfs object:
130 * /sys/devices/system/edac/mc 137 * /sys/devices/system/edac/mc
131 * /sys/devices/system/edac/pci
132 */ 138 */
133static struct kobject edac_memctrl_kobj; 139static struct kobject edac_memctrl_kobj;
134static struct kobject edac_pci_kobj;
135 140
136/* We use these to wait for the reference counts on edac_memctrl_kobj and 141/* We use these to wait for the reference counts on edac_memctrl_kobj and
137 * edac_pci_kobj to reach 0. 142 * edac_pci_kobj to reach 0.
138 */ 143 */
139static struct completion edac_memctrl_kobj_complete; 144static struct completion edac_memctrl_kobj_complete;
140static struct completion edac_pci_kobj_complete;
141 145
142/* 146/*
143 * /sys/devices/system/edac/mc; 147 * /sys/devices/system/edac/mc;
@@ -323,6 +327,8 @@ static void edac_sysfs_memctrl_teardown(void)
323#endif /* DISABLE_EDAC_SYSFS */ 327#endif /* DISABLE_EDAC_SYSFS */
324} 328}
325 329
330#ifdef CONFIG_PCI
331
326#ifndef DISABLE_EDAC_SYSFS 332#ifndef DISABLE_EDAC_SYSFS
327 333
328/* 334/*
@@ -623,6 +629,252 @@ static void edac_sysfs_pci_teardown(void)
623#endif 629#endif
624} 630}
625 631
632
633static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
634{
635 int where;
636 u16 status;
637
638 where = secondary ? PCI_SEC_STATUS : PCI_STATUS;
639 pci_read_config_word(dev, where, &status);
640
641 /* If we get back 0xFFFF then we must suspect that the card has been
642 * pulled but the Linux PCI layer has not yet finished cleaning up.
643 * We don't want to report on such devices
644 */
645
646 if (status == 0xFFFF) {
647 u32 sanity;
648
649 pci_read_config_dword(dev, 0, &sanity);
650
651 if (sanity == 0xFFFFFFFF)
652 return 0;
653 }
654
655 status &= PCI_STATUS_DETECTED_PARITY | PCI_STATUS_SIG_SYSTEM_ERROR |
656 PCI_STATUS_PARITY;
657
658 if (status)
659 /* reset only the bits we are interested in */
660 pci_write_config_word(dev, where, status);
661
662 return status;
663}
664
665typedef void (*pci_parity_check_fn_t) (struct pci_dev *dev);
666
667/* Clear any PCI parity errors logged by this device. */
668static void edac_pci_dev_parity_clear(struct pci_dev *dev)
669{
670 u8 header_type;
671
672 get_pci_parity_status(dev, 0);
673
674 /* read the device TYPE, looking for bridges */
675 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
676
677 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE)
678 get_pci_parity_status(dev, 1);
679}
680
681/*
682 * PCI Parity polling
683 *
684 */
685static void edac_pci_dev_parity_test(struct pci_dev *dev)
686{
687 u16 status;
688 u8 header_type;
689
690 /* read the STATUS register on this device
691 */
692 status = get_pci_parity_status(dev, 0);
693
694 debugf2("PCI STATUS= 0x%04x %s\n", status, dev->dev.bus_id );
695
696 /* check the status reg for errors */
697 if (status) {
698 if (status & (PCI_STATUS_SIG_SYSTEM_ERROR))
699 edac_printk(KERN_CRIT, EDAC_PCI,
700 "Signaled System Error on %s\n",
701 pci_name(dev));
702
703 if (status & (PCI_STATUS_PARITY)) {
704 edac_printk(KERN_CRIT, EDAC_PCI,
705 "Master Data Parity Error on %s\n",
706 pci_name(dev));
707
708 atomic_inc(&pci_parity_count);
709 }
710
711 if (status & (PCI_STATUS_DETECTED_PARITY)) {
712 edac_printk(KERN_CRIT, EDAC_PCI,
713 "Detected Parity Error on %s\n",
714 pci_name(dev));
715
716 atomic_inc(&pci_parity_count);
717 }
718 }
719
720 /* read the device TYPE, looking for bridges */
721 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
722
723 debugf2("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev->dev.bus_id );
724
725 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
726 /* On bridges, need to examine secondary status register */
727 status = get_pci_parity_status(dev, 1);
728
729 debugf2("PCI SEC_STATUS= 0x%04x %s\n",
730 status, dev->dev.bus_id );
731
732 /* check the secondary status reg for errors */
733 if (status) {
734 if (status & (PCI_STATUS_SIG_SYSTEM_ERROR))
735 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
736 "Signaled System Error on %s\n",
737 pci_name(dev));
738
739 if (status & (PCI_STATUS_PARITY)) {
740 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
741 "Master Data Parity Error on "
742 "%s\n", pci_name(dev));
743
744 atomic_inc(&pci_parity_count);
745 }
746
747 if (status & (PCI_STATUS_DETECTED_PARITY)) {
748 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
749 "Detected Parity Error on %s\n",
750 pci_name(dev));
751
752 atomic_inc(&pci_parity_count);
753 }
754 }
755 }
756}
757
758/*
759 * check_dev_on_list: Scan for a PCI device on a white/black list
760 * @list: an EDAC &edac_pci_device_list white/black list pointer
761 * @free_index: index of next free entry on the list
762 * @pci_dev: PCI Device pointer
763 *
764 * see if list contains the device.
765 *
766 * Returns: 0 not found
767 * 1 found on list
768 */
769static int check_dev_on_list(struct edac_pci_device_list *list,
770 int free_index, struct pci_dev *dev)
771{
772 int i;
773 int rc = 0; /* Assume not found */
774 unsigned short vendor=dev->vendor;
775 unsigned short device=dev->device;
776
777 /* Scan the list, looking for a vendor/device match */
778 for (i = 0; i < free_index; i++, list++ ) {
779 if ((list->vendor == vendor ) && (list->device == device )) {
780 rc = 1;
781 break;
782 }
783 }
784
785 return rc;
786}
787
788/*
789 * pci_dev parity list iterator
790 * Scan the PCI device list for one iteration, looking for SERRORs
791 * Master Parity ERRORS or Parity ERRORs on primary or secondary devices
792 */
793static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn)
794{
795 struct pci_dev *dev = NULL;
796
797 /* request for kernel access to the next PCI device, if any,
798 * and while we are looking at it have its reference count
799 * bumped until we are done with it
800 */
801 while((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
802 /* if whitelist exists then it has priority, so only scan
803 * those devices on the whitelist
804 */
805 if (pci_whitelist_count > 0 ) {
806 if (check_dev_on_list(pci_whitelist,
807 pci_whitelist_count, dev))
808 fn(dev);
809 } else {
810 /*
811 * if no whitelist, then check if this devices is
812 * blacklisted
813 */
814 if (!check_dev_on_list(pci_blacklist,
815 pci_blacklist_count, dev))
816 fn(dev);
817 }
818 }
819}
820
821static void do_pci_parity_check(void)
822{
823 unsigned long flags;
824 int before_count;
825
826 debugf3("%s()\n", __func__);
827
828 if (!check_pci_parity)
829 return;
830
831 before_count = atomic_read(&pci_parity_count);
832
833 /* scan all PCI devices looking for a Parity Error on devices and
834 * bridges
835 */
836 local_irq_save(flags);
837 edac_pci_dev_parity_iterator(edac_pci_dev_parity_test);
838 local_irq_restore(flags);
839
840 /* Only if operator has selected panic on PCI Error */
841 if (panic_on_pci_parity) {
842 /* If the count is different 'after' from 'before' */
843 if (before_count != atomic_read(&pci_parity_count))
844 panic("EDAC: PCI Parity Error");
845 }
846}
847
848static inline void clear_pci_parity_errors(void)
849{
850 /* Clear any PCI bus parity errors that devices initially have logged
851 * in their registers.
852 */
853 edac_pci_dev_parity_iterator(edac_pci_dev_parity_clear);
854}
855
856#else /* CONFIG_PCI */
857
858static inline void do_pci_parity_check(void)
859{
860 /* no-op */
861}
862
863static inline void clear_pci_parity_errors(void)
864{
865 /* no-op */
866}
867
868static void edac_sysfs_pci_teardown(void)
869{
870}
871
872static int edac_sysfs_pci_setup(void)
873{
874 return 0;
875}
876#endif /* CONFIG_PCI */
877
626#ifndef DISABLE_EDAC_SYSFS 878#ifndef DISABLE_EDAC_SYSFS
627 879
628/* EDAC sysfs CSROW data structures and methods */ 880/* EDAC sysfs CSROW data structures and methods */
@@ -1131,7 +1383,7 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1131 return err; 1383 return err;
1132 1384
1133 /* create a symlink for the device */ 1385 /* create a symlink for the device */
1134 err = sysfs_create_link(edac_mci_kobj, &mci->pdev->dev.kobj, 1386 err = sysfs_create_link(edac_mci_kobj, &mci->dev->kobj,
1135 EDAC_DEVICE_SYMLINK); 1387 EDAC_DEVICE_SYMLINK);
1136 1388
1137 if (err) 1389 if (err)
@@ -1237,7 +1489,7 @@ void edac_mc_dump_mci(struct mem_ctl_info *mci)
1237 debugf4("\tmci->edac_check = %p\n", mci->edac_check); 1489 debugf4("\tmci->edac_check = %p\n", mci->edac_check);
1238 debugf3("\tmci->nr_csrows = %d, csrows = %p\n", 1490 debugf3("\tmci->nr_csrows = %d, csrows = %p\n",
1239 mci->nr_csrows, mci->csrows); 1491 mci->nr_csrows, mci->csrows);
1240 debugf3("\tpdev = %p\n", mci->pdev); 1492 debugf3("\tdev = %p\n", mci->dev);
1241 debugf3("\tmod_name:ctl_name = %s:%s\n", 1493 debugf3("\tmod_name:ctl_name = %s:%s\n",
1242 mci->mod_name, mci->ctl_name); 1494 mci->mod_name, mci->ctl_name);
1243 debugf3("\tpvt_info = %p\n\n", mci->pvt_info); 1495 debugf3("\tpvt_info = %p\n\n", mci->pvt_info);
@@ -1362,7 +1614,7 @@ void edac_mc_free(struct mem_ctl_info *mci)
1362} 1614}
1363EXPORT_SYMBOL_GPL(edac_mc_free); 1615EXPORT_SYMBOL_GPL(edac_mc_free);
1364 1616
1365static struct mem_ctl_info *find_mci_by_pdev(struct pci_dev *pdev) 1617static struct mem_ctl_info *find_mci_by_dev(struct device *dev)
1366{ 1618{
1367 struct mem_ctl_info *mci; 1619 struct mem_ctl_info *mci;
1368 struct list_head *item; 1620 struct list_head *item;
@@ -1372,54 +1624,53 @@ static struct mem_ctl_info *find_mci_by_pdev(struct pci_dev *pdev)
1372 list_for_each(item, &mc_devices) { 1624 list_for_each(item, &mc_devices) {
1373 mci = list_entry(item, struct mem_ctl_info, link); 1625 mci = list_entry(item, struct mem_ctl_info, link);
1374 1626
1375 if (mci->pdev == pdev) 1627 if (mci->dev == dev)
1376 return mci; 1628 return mci;
1377 } 1629 }
1378 1630
1379 return NULL; 1631 return NULL;
1380} 1632}
1381 1633
1382static int add_mc_to_global_list(struct mem_ctl_info *mci) 1634/* Return 0 on success, 1 on failure.
1635 * Before calling this function, caller must
1636 * assign a unique value to mci->mc_idx.
1637 */
1638static int add_mc_to_global_list (struct mem_ctl_info *mci)
1383{ 1639{
1384 struct list_head *item, *insert_before; 1640 struct list_head *item, *insert_before;
1385 struct mem_ctl_info *p; 1641 struct mem_ctl_info *p;
1386 int i;
1387 1642
1388 if (list_empty(&mc_devices)) { 1643 insert_before = &mc_devices;
1389 mci->mc_idx = 0;
1390 insert_before = &mc_devices;
1391 } else {
1392 if (find_mci_by_pdev(mci->pdev)) {
1393 edac_printk(KERN_WARNING, EDAC_MC,
1394 "%s (%s) %s %s already assigned %d\n",
1395 mci->pdev->dev.bus_id,
1396 pci_name(mci->pdev), mci->mod_name,
1397 mci->ctl_name, mci->mc_idx);
1398 return 1;
1399 }
1400 1644
1401 insert_before = NULL; 1645 if (unlikely((p = find_mci_by_dev(mci->dev)) != NULL))
1402 i = 0; 1646 goto fail0;
1403 1647
1404 list_for_each(item, &mc_devices) { 1648 list_for_each(item, &mc_devices) {
1405 p = list_entry(item, struct mem_ctl_info, link); 1649 p = list_entry(item, struct mem_ctl_info, link);
1406 1650
1407 if (p->mc_idx != i) { 1651 if (p->mc_idx >= mci->mc_idx) {
1408 insert_before = item; 1652 if (unlikely(p->mc_idx == mci->mc_idx))
1409 break; 1653 goto fail1;
1410 }
1411 1654
1412 i++; 1655 insert_before = item;
1656 break;
1413 } 1657 }
1414
1415 mci->mc_idx = i;
1416
1417 if (insert_before == NULL)
1418 insert_before = &mc_devices;
1419 } 1658 }
1420 1659
1421 list_add_tail_rcu(&mci->link, insert_before); 1660 list_add_tail_rcu(&mci->link, insert_before);
1422 return 0; 1661 return 0;
1662
1663fail0:
1664 edac_printk(KERN_WARNING, EDAC_MC,
1665 "%s (%s) %s %s already assigned %d\n", p->dev->bus_id,
1666 dev_name(p->dev), p->mod_name, p->ctl_name, p->mc_idx);
1667 return 1;
1668
1669fail1:
1670 edac_printk(KERN_WARNING, EDAC_MC,
1671 "bug in low-level driver: attempt to assign\n"
1672 " duplicate mc_idx %d in %s()\n", p->mc_idx, __func__);
1673 return 1;
1423} 1674}
1424 1675
1425static void complete_mc_list_del(struct rcu_head *head) 1676static void complete_mc_list_del(struct rcu_head *head)
@@ -1443,6 +1694,7 @@ static void del_mc_from_global_list(struct mem_ctl_info *mci)
1443 * edac_mc_add_mc: Insert the 'mci' structure into the mci global list and 1694 * edac_mc_add_mc: Insert the 'mci' structure into the mci global list and
1444 * create sysfs entries associated with mci structure 1695 * create sysfs entries associated with mci structure
1445 * @mci: pointer to the mci structure to be added to the list 1696 * @mci: pointer to the mci structure to be added to the list
1697 * @mc_idx: A unique numeric identifier to be assigned to the 'mci' structure.
1446 * 1698 *
1447 * Return: 1699 * Return:
1448 * 0 Success 1700 * 0 Success
@@ -1450,9 +1702,10 @@ static void del_mc_from_global_list(struct mem_ctl_info *mci)
1450 */ 1702 */
1451 1703
1452/* FIXME - should a warning be printed if no error detection? correction? */ 1704/* FIXME - should a warning be printed if no error detection? correction? */
1453int edac_mc_add_mc(struct mem_ctl_info *mci) 1705int edac_mc_add_mc(struct mem_ctl_info *mci, int mc_idx)
1454{ 1706{
1455 debugf0("%s()\n", __func__); 1707 debugf0("%s()\n", __func__);
1708 mci->mc_idx = mc_idx;
1456#ifdef CONFIG_EDAC_DEBUG 1709#ifdef CONFIG_EDAC_DEBUG
1457 if (edac_debug_level >= 3) 1710 if (edac_debug_level >= 3)
1458 edac_mc_dump_mci(mci); 1711 edac_mc_dump_mci(mci);
@@ -1485,8 +1738,8 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
1485 } 1738 }
1486 1739
1487 /* Report action taken */ 1740 /* Report action taken */
1488 edac_mc_printk(mci, KERN_INFO, "Giving out device to %s %s: PCI %s\n", 1741 edac_mc_printk(mci, KERN_INFO, "Giving out device to %s %s: DEV %s\n",
1489 mci->mod_name, mci->ctl_name, pci_name(mci->pdev)); 1742 mci->mod_name, mci->ctl_name, dev_name(mci->dev));
1490 1743
1491 up(&mem_ctls_mutex); 1744 up(&mem_ctls_mutex);
1492 return 0; 1745 return 0;
@@ -1503,18 +1756,18 @@ EXPORT_SYMBOL_GPL(edac_mc_add_mc);
1503/** 1756/**
1504 * edac_mc_del_mc: Remove sysfs entries for specified mci structure and 1757 * edac_mc_del_mc: Remove sysfs entries for specified mci structure and
1505 * remove mci structure from global list 1758 * remove mci structure from global list
1506 * @pdev: Pointer to 'struct pci_dev' representing mci structure to remove. 1759 * @pdev: Pointer to 'struct device' representing mci structure to remove.
1507 * 1760 *
1508 * Return pointer to removed mci structure, or NULL if device not found. 1761 * Return pointer to removed mci structure, or NULL if device not found.
1509 */ 1762 */
1510struct mem_ctl_info * edac_mc_del_mc(struct pci_dev *pdev) 1763struct mem_ctl_info * edac_mc_del_mc(struct device *dev)
1511{ 1764{
1512 struct mem_ctl_info *mci; 1765 struct mem_ctl_info *mci;
1513 1766
1514 debugf0("MC: %s()\n", __func__); 1767 debugf0("MC: %s()\n", __func__);
1515 down(&mem_ctls_mutex); 1768 down(&mem_ctls_mutex);
1516 1769
1517 if ((mci = find_mci_by_pdev(pdev)) == NULL) { 1770 if ((mci = find_mci_by_dev(dev)) == NULL) {
1518 up(&mem_ctls_mutex); 1771 up(&mem_ctls_mutex);
1519 return NULL; 1772 return NULL;
1520 } 1773 }
@@ -1523,8 +1776,8 @@ struct mem_ctl_info * edac_mc_del_mc(struct pci_dev *pdev)
1523 del_mc_from_global_list(mci); 1776 del_mc_from_global_list(mci);
1524 up(&mem_ctls_mutex); 1777 up(&mem_ctls_mutex);
1525 edac_printk(KERN_INFO, EDAC_MC, 1778 edac_printk(KERN_INFO, EDAC_MC,
1526 "Removed device %d for %s %s: PCI %s\n", mci->mc_idx, 1779 "Removed device %d for %s %s: DEV %s\n", mci->mc_idx,
1527 mci->mod_name, mci->ctl_name, pci_name(mci->pdev)); 1780 mci->mod_name, mci->ctl_name, dev_name(mci->dev));
1528 return mci; 1781 return mci;
1529} 1782}
1530EXPORT_SYMBOL_GPL(edac_mc_del_mc); 1783EXPORT_SYMBOL_GPL(edac_mc_del_mc);
@@ -1738,244 +1991,6 @@ void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci, const char *msg)
1738} 1991}
1739EXPORT_SYMBOL_GPL(edac_mc_handle_ue_no_info); 1992EXPORT_SYMBOL_GPL(edac_mc_handle_ue_no_info);
1740 1993
1741#ifdef CONFIG_PCI
1742
1743static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
1744{
1745 int where;
1746 u16 status;
1747
1748 where = secondary ? PCI_SEC_STATUS : PCI_STATUS;
1749 pci_read_config_word(dev, where, &status);
1750
1751 /* If we get back 0xFFFF then we must suspect that the card has been
1752 * pulled but the Linux PCI layer has not yet finished cleaning up.
1753 * We don't want to report on such devices
1754 */
1755
1756 if (status == 0xFFFF) {
1757 u32 sanity;
1758
1759 pci_read_config_dword(dev, 0, &sanity);
1760
1761 if (sanity == 0xFFFFFFFF)
1762 return 0;
1763 }
1764
1765 status &= PCI_STATUS_DETECTED_PARITY | PCI_STATUS_SIG_SYSTEM_ERROR |
1766 PCI_STATUS_PARITY;
1767
1768 if (status)
1769 /* reset only the bits we are interested in */
1770 pci_write_config_word(dev, where, status);
1771
1772 return status;
1773}
1774
1775typedef void (*pci_parity_check_fn_t) (struct pci_dev *dev);
1776
1777/* Clear any PCI parity errors logged by this device. */
1778static void edac_pci_dev_parity_clear(struct pci_dev *dev)
1779{
1780 u8 header_type;
1781
1782 get_pci_parity_status(dev, 0);
1783
1784 /* read the device TYPE, looking for bridges */
1785 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
1786
1787 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE)
1788 get_pci_parity_status(dev, 1);
1789}
1790
1791/*
1792 * PCI Parity polling
1793 *
1794 */
1795static void edac_pci_dev_parity_test(struct pci_dev *dev)
1796{
1797 u16 status;
1798 u8 header_type;
1799
1800 /* read the STATUS register on this device
1801 */
1802 status = get_pci_parity_status(dev, 0);
1803
1804 debugf2("PCI STATUS= 0x%04x %s\n", status, dev->dev.bus_id );
1805
1806 /* check the status reg for errors */
1807 if (status) {
1808 if (status & (PCI_STATUS_SIG_SYSTEM_ERROR))
1809 edac_printk(KERN_CRIT, EDAC_PCI,
1810 "Signaled System Error on %s\n",
1811 pci_name(dev));
1812
1813 if (status & (PCI_STATUS_PARITY)) {
1814 edac_printk(KERN_CRIT, EDAC_PCI,
1815 "Master Data Parity Error on %s\n",
1816 pci_name(dev));
1817
1818 atomic_inc(&pci_parity_count);
1819 }
1820
1821 if (status & (PCI_STATUS_DETECTED_PARITY)) {
1822 edac_printk(KERN_CRIT, EDAC_PCI,
1823 "Detected Parity Error on %s\n",
1824 pci_name(dev));
1825
1826 atomic_inc(&pci_parity_count);
1827 }
1828 }
1829
1830 /* read the device TYPE, looking for bridges */
1831 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
1832
1833 debugf2("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev->dev.bus_id );
1834
1835 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
1836 /* On bridges, need to examine secondary status register */
1837 status = get_pci_parity_status(dev, 1);
1838
1839 debugf2("PCI SEC_STATUS= 0x%04x %s\n",
1840 status, dev->dev.bus_id );
1841
1842 /* check the secondary status reg for errors */
1843 if (status) {
1844 if (status & (PCI_STATUS_SIG_SYSTEM_ERROR))
1845 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
1846 "Signaled System Error on %s\n",
1847 pci_name(dev));
1848
1849 if (status & (PCI_STATUS_PARITY)) {
1850 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
1851 "Master Data Parity Error on "
1852 "%s\n", pci_name(dev));
1853
1854 atomic_inc(&pci_parity_count);
1855 }
1856
1857 if (status & (PCI_STATUS_DETECTED_PARITY)) {
1858 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
1859 "Detected Parity Error on %s\n",
1860 pci_name(dev));
1861
1862 atomic_inc(&pci_parity_count);
1863 }
1864 }
1865 }
1866}
1867
1868/*
1869 * check_dev_on_list: Scan for a PCI device on a white/black list
1870 * @list: an EDAC &edac_pci_device_list white/black list pointer
1871 * @free_index: index of next free entry on the list
1872 * @pci_dev: PCI Device pointer
1873 *
1874 * see if list contains the device.
1875 *
1876 * Returns: 0 not found
1877 * 1 found on list
1878 */
1879static int check_dev_on_list(struct edac_pci_device_list *list,
1880 int free_index, struct pci_dev *dev)
1881{
1882 int i;
1883 int rc = 0; /* Assume not found */
1884 unsigned short vendor=dev->vendor;
1885 unsigned short device=dev->device;
1886
1887 /* Scan the list, looking for a vendor/device match */
1888 for (i = 0; i < free_index; i++, list++ ) {
1889 if ((list->vendor == vendor ) && (list->device == device )) {
1890 rc = 1;
1891 break;
1892 }
1893 }
1894
1895 return rc;
1896}
1897
1898/*
1899 * pci_dev parity list iterator
1900 * Scan the PCI device list for one iteration, looking for SERRORs
1901 * Master Parity ERRORS or Parity ERRORs on primary or secondary devices
1902 */
1903static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn)
1904{
1905 struct pci_dev *dev = NULL;
1906
1907 /* request for kernel access to the next PCI device, if any,
1908 * and while we are looking at it have its reference count
1909 * bumped until we are done with it
1910 */
1911 while((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
1912 /* if whitelist exists then it has priority, so only scan
1913 * those devices on the whitelist
1914 */
1915 if (pci_whitelist_count > 0 ) {
1916 if (check_dev_on_list(pci_whitelist,
1917 pci_whitelist_count, dev))
1918 fn(dev);
1919 } else {
1920 /*
1921 * if no whitelist, then check if this devices is
1922 * blacklisted
1923 */
1924 if (!check_dev_on_list(pci_blacklist,
1925 pci_blacklist_count, dev))
1926 fn(dev);
1927 }
1928 }
1929}
1930
1931static void do_pci_parity_check(void)
1932{
1933 unsigned long flags;
1934 int before_count;
1935
1936 debugf3("%s()\n", __func__);
1937
1938 if (!check_pci_parity)
1939 return;
1940
1941 before_count = atomic_read(&pci_parity_count);
1942
1943 /* scan all PCI devices looking for a Parity Error on devices and
1944 * bridges
1945 */
1946 local_irq_save(flags);
1947 edac_pci_dev_parity_iterator(edac_pci_dev_parity_test);
1948 local_irq_restore(flags);
1949
1950 /* Only if operator has selected panic on PCI Error */
1951 if (panic_on_pci_parity) {
1952 /* If the count is different 'after' from 'before' */
1953 if (before_count != atomic_read(&pci_parity_count))
1954 panic("EDAC: PCI Parity Error");
1955 }
1956}
1957
1958static inline void clear_pci_parity_errors(void)
1959{
1960 /* Clear any PCI bus parity errors that devices initially have logged
1961 * in their registers.
1962 */
1963 edac_pci_dev_parity_iterator(edac_pci_dev_parity_clear);
1964}
1965
1966#else /* CONFIG_PCI */
1967
1968static inline void do_pci_parity_check(void)
1969{
1970 /* no-op */
1971}
1972
1973static inline void clear_pci_parity_errors(void)
1974{
1975 /* no-op */
1976}
1977
1978#endif /* CONFIG_PCI */
1979 1994
1980/* 1995/*
1981 * Iterate over all MC instances and check for ECC, et al, errors 1996 * Iterate over all MC instances and check for ECC, et al, errors
@@ -2095,10 +2110,12 @@ MODULE_DESCRIPTION("Core library routines for MC reporting");
2095 2110
2096module_param(panic_on_ue, int, 0644); 2111module_param(panic_on_ue, int, 0644);
2097MODULE_PARM_DESC(panic_on_ue, "Panic on uncorrected error: 0=off 1=on"); 2112MODULE_PARM_DESC(panic_on_ue, "Panic on uncorrected error: 0=off 1=on");
2113#ifdef CONFIG_PCI
2098module_param(check_pci_parity, int, 0644); 2114module_param(check_pci_parity, int, 0644);
2099MODULE_PARM_DESC(check_pci_parity, "Check for PCI bus parity errors: 0=off 1=on"); 2115MODULE_PARM_DESC(check_pci_parity, "Check for PCI bus parity errors: 0=off 1=on");
2100module_param(panic_on_pci_parity, int, 0644); 2116module_param(panic_on_pci_parity, int, 0644);
2101MODULE_PARM_DESC(panic_on_pci_parity, "Panic on PCI Bus Parity error: 0=off 1=on"); 2117MODULE_PARM_DESC(panic_on_pci_parity, "Panic on PCI Bus Parity error: 0=off 1=on");
2118#endif
2102module_param(log_ue, int, 0644); 2119module_param(log_ue, int, 0644);
2103MODULE_PARM_DESC(log_ue, "Log uncorrectable error to console: 0=off 1=on"); 2120MODULE_PARM_DESC(log_ue, "Log uncorrectable error to console: 0=off 1=on");
2104module_param(log_ce, int, 0644); 2121module_param(log_ce, int, 0644);
diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h
index ad578eb0969d..1be4947e28af 100644
--- a/drivers/edac/edac_mc.h
+++ b/drivers/edac/edac_mc.h
@@ -87,6 +87,12 @@ extern int edac_debug_level;
87#define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \ 87#define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \
88 PCI_DEVICE_ID_ ## vend ## _ ## dev 88 PCI_DEVICE_ID_ ## vend ## _ ## dev
89 89
90#if defined(CONFIG_X86) && defined(CONFIG_PCI)
91#define dev_name(dev) pci_name(to_pci_dev(dev))
92#else
93#define dev_name(dev) to_platform_device(dev)->name
94#endif
95
90/* memory devices */ 96/* memory devices */
91enum dev_type { 97enum dev_type {
92 DEV_UNKNOWN = 0, 98 DEV_UNKNOWN = 0,
@@ -326,10 +332,10 @@ struct mem_ctl_info {
326 struct csrow_info *csrows; 332 struct csrow_info *csrows;
327 /* 333 /*
328 * FIXME - what about controllers on other busses? - IDs must be 334 * FIXME - what about controllers on other busses? - IDs must be
329 * unique. pdev pointer should be sufficiently unique, but 335 * unique. dev pointer should be sufficiently unique, but
330 * BUS:SLOT.FUNC numbers may not be unique. 336 * BUS:SLOT.FUNC numbers may not be unique.
331 */ 337 */
332 struct pci_dev *pdev; 338 struct device *dev;
333 const char *mod_name; 339 const char *mod_name;
334 const char *mod_ver; 340 const char *mod_ver;
335 const char *ctl_name; 341 const char *ctl_name;
@@ -352,6 +358,8 @@ struct mem_ctl_info {
352 struct completion kobj_complete; 358 struct completion kobj_complete;
353}; 359};
354 360
361#ifdef CONFIG_PCI
362
355/* write all or some bits in a byte-register*/ 363/* write all or some bits in a byte-register*/
356static inline void pci_write_bits8(struct pci_dev *pdev, int offset, u8 value, 364static inline void pci_write_bits8(struct pci_dev *pdev, int offset, u8 value,
357 u8 mask) 365 u8 mask)
@@ -400,14 +408,16 @@ static inline void pci_write_bits32(struct pci_dev *pdev, int offset,
400 pci_write_config_dword(pdev, offset, value); 408 pci_write_config_dword(pdev, offset, value);
401} 409}
402 410
411#endif /* CONFIG_PCI */
412
403#ifdef CONFIG_EDAC_DEBUG 413#ifdef CONFIG_EDAC_DEBUG
404void edac_mc_dump_channel(struct channel_info *chan); 414void edac_mc_dump_channel(struct channel_info *chan);
405void edac_mc_dump_mci(struct mem_ctl_info *mci); 415void edac_mc_dump_mci(struct mem_ctl_info *mci);
406void edac_mc_dump_csrow(struct csrow_info *csrow); 416void edac_mc_dump_csrow(struct csrow_info *csrow);
407#endif /* CONFIG_EDAC_DEBUG */ 417#endif /* CONFIG_EDAC_DEBUG */
408 418
409extern int edac_mc_add_mc(struct mem_ctl_info *mci); 419extern int edac_mc_add_mc(struct mem_ctl_info *mci,int mc_idx);
410extern struct mem_ctl_info * edac_mc_del_mc(struct pci_dev *pdev); 420extern struct mem_ctl_info * edac_mc_del_mc(struct device *dev);
411extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci, 421extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
412 unsigned long page); 422 unsigned long page);
413extern void edac_mc_scrub_block(unsigned long page, unsigned long offset, 423extern void edac_mc_scrub_block(unsigned long page, unsigned long offset,
diff --git a/drivers/edac/i82860_edac.c b/drivers/edac/i82860_edac.c
index 56ba31f85f13..e30a4a2eaf38 100644
--- a/drivers/edac/i82860_edac.c
+++ b/drivers/edac/i82860_edac.c
@@ -16,6 +16,8 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include "edac_mc.h" 17#include "edac_mc.h"
18 18
19#define I82860_REVISION " Ver: 2.0.0 " __DATE__
20
19#define i82860_printk(level, fmt, arg...) \ 21#define i82860_printk(level, fmt, arg...) \
20 edac_printk(level, "i82860", fmt, ##arg) 22 edac_printk(level, "i82860", fmt, ##arg)
21 23
@@ -62,17 +64,21 @@ static struct pci_dev *mci_pdev = NULL; /* init dev: in case that AGP code
62static void i82860_get_error_info(struct mem_ctl_info *mci, 64static void i82860_get_error_info(struct mem_ctl_info *mci,
63 struct i82860_error_info *info) 65 struct i82860_error_info *info)
64{ 66{
67 struct pci_dev *pdev;
68
69 pdev = to_pci_dev(mci->dev);
70
65 /* 71 /*
66 * This is a mess because there is no atomic way to read all the 72 * This is a mess because there is no atomic way to read all the
67 * registers at once and the registers can transition from CE being 73 * registers at once and the registers can transition from CE being
68 * overwritten by UE. 74 * overwritten by UE.
69 */ 75 */
70 pci_read_config_word(mci->pdev, I82860_ERRSTS, &info->errsts); 76 pci_read_config_word(pdev, I82860_ERRSTS, &info->errsts);
71 pci_read_config_dword(mci->pdev, I82860_EAP, &info->eap); 77 pci_read_config_dword(pdev, I82860_EAP, &info->eap);
72 pci_read_config_word(mci->pdev, I82860_DERRCTL_STS, &info->derrsyn); 78 pci_read_config_word(pdev, I82860_DERRCTL_STS, &info->derrsyn);
73 pci_read_config_word(mci->pdev, I82860_ERRSTS, &info->errsts2); 79 pci_read_config_word(pdev, I82860_ERRSTS, &info->errsts2);
74 80
75 pci_write_bits16(mci->pdev, I82860_ERRSTS, 0x0003, 0x0003); 81 pci_write_bits16(pdev, I82860_ERRSTS, 0x0003, 0x0003);
76 82
77 /* 83 /*
78 * If the error is the same for both reads then the first set of reads 84 * If the error is the same for both reads then the first set of reads
@@ -83,8 +89,8 @@ static void i82860_get_error_info(struct mem_ctl_info *mci,
83 return; 89 return;
84 90
85 if ((info->errsts ^ info->errsts2) & 0x0003) { 91 if ((info->errsts ^ info->errsts2) & 0x0003) {
86 pci_read_config_dword(mci->pdev, I82860_EAP, &info->eap); 92 pci_read_config_dword(pdev, I82860_EAP, &info->eap);
87 pci_read_config_word(mci->pdev, I82860_DERRCTL_STS, 93 pci_read_config_word(pdev, I82860_DERRCTL_STS,
88 &info->derrsyn); 94 &info->derrsyn);
89 } 95 }
90} 96}
@@ -126,15 +132,50 @@ static void i82860_check(struct mem_ctl_info *mci)
126 i82860_process_error_info(mci, &info, 1); 132 i82860_process_error_info(mci, &info, 1);
127} 133}
128 134
129static int i82860_probe1(struct pci_dev *pdev, int dev_idx) 135static void i82860_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev)
130{ 136{
131 int rc = -ENODEV;
132 int index;
133 struct mem_ctl_info *mci = NULL;
134 unsigned long last_cumul_size; 137 unsigned long last_cumul_size;
135 struct i82860_error_info discard; 138 u16 mchcfg_ddim; /* DRAM Data Integrity Mode 0=none, 2=edac */
139 u16 value;
140 u32 cumul_size;
141 struct csrow_info *csrow;
142 int index;
143
144 pci_read_config_word(pdev, I82860_MCHCFG, &mchcfg_ddim);
145 mchcfg_ddim = mchcfg_ddim & 0x180;
146 last_cumul_size = 0;
147
148 /* The group row boundary (GRA) reg values are boundary address
149 * for each DRAM row with a granularity of 16MB. GRA regs are
150 * cumulative; therefore GRA15 will contain the total memory contained
151 * in all eight rows.
152 */
153 for (index = 0; index < mci->nr_csrows; index++) {
154 csrow = &mci->csrows[index];
155 pci_read_config_word(pdev, I82860_GBA + index * 2, &value);
156 cumul_size = (value & I82860_GBA_MASK) <<
157 (I82860_GBA_SHIFT - PAGE_SHIFT);
158 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
159 cumul_size);
136 160
137 u16 mchcfg_ddim; /* DRAM Data Integrity Mode 0=none,2=edac */ 161 if (cumul_size == last_cumul_size)
162 continue; /* not populated */
163
164 csrow->first_page = last_cumul_size;
165 csrow->last_page = cumul_size - 1;
166 csrow->nr_pages = cumul_size - last_cumul_size;
167 last_cumul_size = cumul_size;
168 csrow->grain = 1 << 12; /* I82860_EAP has 4KiB reolution */
169 csrow->mtype = MEM_RMBS;
170 csrow->dtype = DEV_UNKNOWN;
171 csrow->edac_mode = mchcfg_ddim ? EDAC_SECDED : EDAC_NONE;
172 }
173}
174
175static int i82860_probe1(struct pci_dev *pdev, int dev_idx)
176{
177 struct mem_ctl_info *mci;
178 struct i82860_error_info discard;
138 179
139 /* RDRAM has channels but these don't map onto the abstractions that 180 /* RDRAM has channels but these don't map onto the abstractions that
140 edac uses. 181 edac uses.
@@ -150,67 +191,35 @@ static int i82860_probe1(struct pci_dev *pdev, int dev_idx)
150 return -ENOMEM; 191 return -ENOMEM;
151 192
152 debugf3("%s(): init mci\n", __func__); 193 debugf3("%s(): init mci\n", __func__);
153 mci->pdev = pdev; 194 mci->dev = &pdev->dev;
154 mci->mtype_cap = MEM_FLAG_DDR; 195 mci->mtype_cap = MEM_FLAG_DDR;
155
156 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; 196 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
157 /* I"m not sure about this but I think that all RDRAM is SECDED */ 197 /* I"m not sure about this but I think that all RDRAM is SECDED */
158 mci->edac_cap = EDAC_FLAG_SECDED; 198 mci->edac_cap = EDAC_FLAG_SECDED;
159 /* adjust FLAGS */
160
161 mci->mod_name = EDAC_MOD_STR; 199 mci->mod_name = EDAC_MOD_STR;
162 mci->mod_ver = "$Revision: 1.1.2.6 $"; 200 mci->mod_ver = I82860_REVISION;
163 mci->ctl_name = i82860_devs[dev_idx].ctl_name; 201 mci->ctl_name = i82860_devs[dev_idx].ctl_name;
164 mci->edac_check = i82860_check; 202 mci->edac_check = i82860_check;
165 mci->ctl_page_to_phys = NULL; 203 mci->ctl_page_to_phys = NULL;
204 i82860_init_csrows(mci, pdev);
205 i82860_get_error_info(mci, &discard); /* clear counters */
166 206
167 pci_read_config_word(mci->pdev, I82860_MCHCFG, &mchcfg_ddim); 207 /* Here we assume that we will never see multiple instances of this
168 mchcfg_ddim = mchcfg_ddim & 0x180; 208 * type of memory controller. The ID is therefore hardcoded to 0.
169
170 /*
171 * The group row boundary (GRA) reg values are boundary address
172 * for each DRAM row with a granularity of 16MB. GRA regs are
173 * cumulative; therefore GRA15 will contain the total memory contained
174 * in all eight rows.
175 */ 209 */
176 for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) { 210 if (edac_mc_add_mc(mci,0)) {
177 u16 value; 211 debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
178 u32 cumul_size; 212 goto fail;
179 struct csrow_info *csrow = &mci->csrows[index];
180
181 pci_read_config_word(mci->pdev, I82860_GBA + index * 2,
182 &value);
183
184 cumul_size = (value & I82860_GBA_MASK) <<
185 (I82860_GBA_SHIFT - PAGE_SHIFT);
186 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
187 cumul_size);
188
189 if (cumul_size == last_cumul_size)
190 continue; /* not populated */
191
192 csrow->first_page = last_cumul_size;
193 csrow->last_page = cumul_size - 1;
194 csrow->nr_pages = cumul_size - last_cumul_size;
195 last_cumul_size = cumul_size;
196 csrow->grain = 1 << 12; /* I82860_EAP has 4KiB reolution */
197 csrow->mtype = MEM_RMBS;
198 csrow->dtype = DEV_UNKNOWN;
199 csrow->edac_mode = mchcfg_ddim ? EDAC_SECDED : EDAC_NONE;
200 } 213 }
201 214
202 i82860_get_error_info(mci, &discard); /* clear counters */ 215 /* get this far and it's successful */
216 debugf3("%s(): success\n", __func__);
203 217
204 if (edac_mc_add_mc(mci)) { 218 return 0;
205 debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
206 edac_mc_free(mci);
207 } else {
208 /* get this far and it's successful */
209 debugf3("%s(): success\n", __func__);
210 rc = 0;
211 }
212 219
213 return rc; 220fail:
221 edac_mc_free(mci);
222 return -ENODEV;
214} 223}
215 224
216/* returns count (>= 0), or negative on error */ 225/* returns count (>= 0), or negative on error */
@@ -239,7 +248,7 @@ static void __devexit i82860_remove_one(struct pci_dev *pdev)
239 248
240 debugf0("%s()\n", __func__); 249 debugf0("%s()\n", __func__);
241 250
242 if ((mci = edac_mc_del_mc(pdev)) == NULL) 251 if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
243 return; 252 return;
244 253
245 edac_mc_free(mci); 254 edac_mc_free(mci);
diff --git a/drivers/edac/i82875p_edac.c b/drivers/edac/i82875p_edac.c
index e1d751d39736..9423ee5e7edd 100644
--- a/drivers/edac/i82875p_edac.c
+++ b/drivers/edac/i82875p_edac.c
@@ -20,6 +20,8 @@
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include "edac_mc.h" 21#include "edac_mc.h"
22 22
23#define I82875P_REVISION " Ver: 2.0.0 " __DATE__
24
23#define i82875p_printk(level, fmt, arg...) \ 25#define i82875p_printk(level, fmt, arg...) \
24 edac_printk(level, "i82875p", fmt, ##arg) 26 edac_printk(level, "i82875p", fmt, ##arg)
25 27
@@ -184,18 +186,22 @@ static int i82875p_registered = 1;
184static void i82875p_get_error_info(struct mem_ctl_info *mci, 186static void i82875p_get_error_info(struct mem_ctl_info *mci,
185 struct i82875p_error_info *info) 187 struct i82875p_error_info *info)
186{ 188{
189 struct pci_dev *pdev;
190
191 pdev = to_pci_dev(mci->dev);
192
187 /* 193 /*
188 * This is a mess because there is no atomic way to read all the 194 * This is a mess because there is no atomic way to read all the
189 * registers at once and the registers can transition from CE being 195 * registers at once and the registers can transition from CE being
190 * overwritten by UE. 196 * overwritten by UE.
191 */ 197 */
192 pci_read_config_word(mci->pdev, I82875P_ERRSTS, &info->errsts); 198 pci_read_config_word(pdev, I82875P_ERRSTS, &info->errsts);
193 pci_read_config_dword(mci->pdev, I82875P_EAP, &info->eap); 199 pci_read_config_dword(pdev, I82875P_EAP, &info->eap);
194 pci_read_config_byte(mci->pdev, I82875P_DES, &info->des); 200 pci_read_config_byte(pdev, I82875P_DES, &info->des);
195 pci_read_config_byte(mci->pdev, I82875P_DERRSYN, &info->derrsyn); 201 pci_read_config_byte(pdev, I82875P_DERRSYN, &info->derrsyn);
196 pci_read_config_word(mci->pdev, I82875P_ERRSTS, &info->errsts2); 202 pci_read_config_word(pdev, I82875P_ERRSTS, &info->errsts2);
197 203
198 pci_write_bits16(mci->pdev, I82875P_ERRSTS, 0x0081, 0x0081); 204 pci_write_bits16(pdev, I82875P_ERRSTS, 0x0081, 0x0081);
199 205
200 /* 206 /*
201 * If the error is the same then we can for both reads then 207 * If the error is the same then we can for both reads then
@@ -207,9 +213,9 @@ static void i82875p_get_error_info(struct mem_ctl_info *mci,
207 return; 213 return;
208 214
209 if ((info->errsts ^ info->errsts2) & 0x0081) { 215 if ((info->errsts ^ info->errsts2) & 0x0081) {
210 pci_read_config_dword(mci->pdev, I82875P_EAP, &info->eap); 216 pci_read_config_dword(pdev, I82875P_EAP, &info->eap);
211 pci_read_config_byte(mci->pdev, I82875P_DES, &info->des); 217 pci_read_config_byte(pdev, I82875P_DES, &info->des);
212 pci_read_config_byte(mci->pdev, I82875P_DERRSYN, 218 pci_read_config_byte(pdev, I82875P_DERRSYN,
213 &info->derrsyn); 219 &info->derrsyn);
214 } 220 }
215} 221}
@@ -258,116 +264,109 @@ static void i82875p_check(struct mem_ctl_info *mci)
258extern int pci_proc_attach_device(struct pci_dev *); 264extern int pci_proc_attach_device(struct pci_dev *);
259#endif 265#endif
260 266
261static int i82875p_probe1(struct pci_dev *pdev, int dev_idx) 267/* Return 0 on success or 1 on failure. */
268static int i82875p_setup_overfl_dev(struct pci_dev *pdev,
269 struct pci_dev **ovrfl_pdev, void __iomem **ovrfl_window)
262{ 270{
263 int rc = -ENODEV; 271 struct pci_dev *dev;
264 int index; 272 void __iomem *window;
265 struct mem_ctl_info *mci = NULL;
266 struct i82875p_pvt *pvt = NULL;
267 unsigned long last_cumul_size;
268 struct pci_dev *ovrfl_pdev;
269 void __iomem *ovrfl_window = NULL;
270 u32 drc;
271 u32 drc_chan; /* Number of channels 0=1chan,1=2chan */
272 u32 nr_chans;
273 u32 drc_ddim; /* DRAM Data Integrity Mode 0=none,2=edac */
274 struct i82875p_error_info discard;
275 273
276 debugf0("%s()\n", __func__); 274 *ovrfl_pdev = NULL;
277 ovrfl_pdev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL); 275 *ovrfl_window = NULL;
276 dev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL);
278 277
279 if (!ovrfl_pdev) { 278 if (dev == NULL) {
280 /* 279 /* Intel tells BIOS developers to hide device 6 which
281 * Intel tells BIOS developers to hide device 6 which
282 * configures the overflow device access containing 280 * configures the overflow device access containing
283 * the DRBs - this is where we expose device 6. 281 * the DRBs - this is where we expose device 6.
284 * http://www.x86-secret.com/articles/tweak/pat/patsecrets-2.htm 282 * http://www.x86-secret.com/articles/tweak/pat/patsecrets-2.htm
285 */ 283 */
286 pci_write_bits8(pdev, 0xf4, 0x2, 0x2); 284 pci_write_bits8(pdev, 0xf4, 0x2, 0x2);
287 ovrfl_pdev = 285 dev = pci_scan_single_device(pdev->bus, PCI_DEVFN(6, 0));
288 pci_scan_single_device(pdev->bus, PCI_DEVFN(6, 0));
289 286
290 if (!ovrfl_pdev) 287 if (dev == NULL)
291 return -ENODEV; 288 return 1;
292 } 289 }
293 290
291 *ovrfl_pdev = dev;
292
294#ifdef CONFIG_PROC_FS 293#ifdef CONFIG_PROC_FS
295 if (!ovrfl_pdev->procent && pci_proc_attach_device(ovrfl_pdev)) { 294 if ((dev->procent == NULL) && pci_proc_attach_device(dev)) {
296 i82875p_printk(KERN_ERR, 295 i82875p_printk(KERN_ERR, "%s(): Failed to attach overflow "
297 "%s(): Failed to attach overflow device\n", __func__); 296 "device\n", __func__);
298 return -ENODEV; 297 return 1;
299 } 298 }
300#endif 299#endif /* CONFIG_PROC_FS */
301 /* CONFIG_PROC_FS */ 300 if (pci_enable_device(dev)) {
302 if (pci_enable_device(ovrfl_pdev)) { 301 i82875p_printk(KERN_ERR, "%s(): Failed to enable overflow "
303 i82875p_printk(KERN_ERR, 302 "device\n", __func__);
304 "%s(): Failed to enable overflow device\n", __func__); 303 return 1;
305 return -ENODEV;
306 } 304 }
307 305
308 if (pci_request_regions(ovrfl_pdev, pci_name(ovrfl_pdev))) { 306 if (pci_request_regions(dev, pci_name(dev))) {
309#ifdef CORRECT_BIOS 307#ifdef CORRECT_BIOS
310 goto fail0; 308 goto fail0;
311#endif 309#endif
312 } 310 }
313 311
314 /* cache is irrelevant for PCI bus reads/writes */ 312 /* cache is irrelevant for PCI bus reads/writes */
315 ovrfl_window = ioremap_nocache(pci_resource_start(ovrfl_pdev, 0), 313 window = ioremap_nocache(pci_resource_start(dev, 0),
316 pci_resource_len(ovrfl_pdev, 0)); 314 pci_resource_len(dev, 0));
317 315
318 if (!ovrfl_window) { 316 if (window == NULL) {
319 i82875p_printk(KERN_ERR, "%s(): Failed to ioremap bar6\n", 317 i82875p_printk(KERN_ERR, "%s(): Failed to ioremap bar6\n",
320 __func__); 318 __func__);
321 goto fail1; 319 goto fail1;
322 } 320 }
323 321
324 /* need to find out the number of channels */ 322 *ovrfl_window = window;
325 drc = readl(ovrfl_window + I82875P_DRC); 323 return 0;
326 drc_chan = ((drc >> 21) & 0x1);
327 nr_chans = drc_chan + 1;
328 324
329 drc_ddim = (drc >> 18) & 0x1; 325fail1:
330 mci = edac_mc_alloc(sizeof(*pvt), I82875P_NR_CSROWS(nr_chans), 326 pci_release_regions(dev);
331 nr_chans);
332 327
333 if (!mci) { 328#ifdef CORRECT_BIOS
334 rc = -ENOMEM; 329fail0:
335 goto fail2; 330 pci_disable_device(dev);
336 } 331#endif
332 /* NOTE: the ovrfl proc entry and pci_dev are intentionally left */
333 return 1;
334}
337 335
338 debugf3("%s(): init mci\n", __func__);
339 mci->pdev = pdev;
340 mci->mtype_cap = MEM_FLAG_DDR;
341 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
342 mci->edac_cap = EDAC_FLAG_UNKNOWN;
343 /* adjust FLAGS */
344 336
345 mci->mod_name = EDAC_MOD_STR; 337/* Return 1 if dual channel mode is active. Else return 0. */
346 mci->mod_ver = "$Revision: 1.5.2.11 $"; 338static inline int dual_channel_active(u32 drc)
347 mci->ctl_name = i82875p_devs[dev_idx].ctl_name; 339{
348 mci->edac_check = i82875p_check; 340 return (drc >> 21) & 0x1;
349 mci->ctl_page_to_phys = NULL; 341}
350 debugf3("%s(): init pvt\n", __func__);
351 pvt = (struct i82875p_pvt *) mci->pvt_info;
352 pvt->ovrfl_pdev = ovrfl_pdev;
353 pvt->ovrfl_window = ovrfl_window;
354 342
355 /* 343
356 * The dram row boundary (DRB) reg values are boundary address 344static void i82875p_init_csrows(struct mem_ctl_info *mci,
345 struct pci_dev *pdev, void __iomem *ovrfl_window, u32 drc)
346{
347 struct csrow_info *csrow;
348 unsigned long last_cumul_size;
349 u8 value;
350 u32 drc_ddim; /* DRAM Data Integrity Mode 0=none,2=edac */
351 u32 cumul_size;
352 int index;
353
354 drc_ddim = (drc >> 18) & 0x1;
355 last_cumul_size = 0;
356
357 /* The dram row boundary (DRB) reg values are boundary address
357 * for each DRAM row with a granularity of 32 or 64MB (single/dual 358 * for each DRAM row with a granularity of 32 or 64MB (single/dual
358 * channel operation). DRB regs are cumulative; therefore DRB7 will 359 * channel operation). DRB regs are cumulative; therefore DRB7 will
359 * contain the total memory contained in all eight rows. 360 * contain the total memory contained in all eight rows.
360 */ 361 */
361 for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) { 362
362 u8 value; 363 for (index = 0; index < mci->nr_csrows; index++) {
363 u32 cumul_size; 364 csrow = &mci->csrows[index];
364 struct csrow_info *csrow = &mci->csrows[index];
365 365
366 value = readb(ovrfl_window + I82875P_DRB + index); 366 value = readb(ovrfl_window + I82875P_DRB + index);
367 cumul_size = value << (I82875P_DRB_SHIFT - PAGE_SHIFT); 367 cumul_size = value << (I82875P_DRB_SHIFT - PAGE_SHIFT);
368 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, 368 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
369 cumul_size); 369 cumul_size);
370
371 if (cumul_size == last_cumul_size) 370 if (cumul_size == last_cumul_size)
372 continue; /* not populated */ 371 continue; /* not populated */
373 372
@@ -375,35 +374,75 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
375 csrow->last_page = cumul_size - 1; 374 csrow->last_page = cumul_size - 1;
376 csrow->nr_pages = cumul_size - last_cumul_size; 375 csrow->nr_pages = cumul_size - last_cumul_size;
377 last_cumul_size = cumul_size; 376 last_cumul_size = cumul_size;
378 csrow->grain = 1 << 12; /* I82875P_EAP has 4KiB reolution */ 377 csrow->grain = 1 << 12; /* I82875P_EAP has 4KiB reolution */
379 csrow->mtype = MEM_DDR; 378 csrow->mtype = MEM_DDR;
380 csrow->dtype = DEV_UNKNOWN; 379 csrow->dtype = DEV_UNKNOWN;
381 csrow->edac_mode = drc_ddim ? EDAC_SECDED : EDAC_NONE; 380 csrow->edac_mode = drc_ddim ? EDAC_SECDED : EDAC_NONE;
382 } 381 }
382}
383
384static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
385{
386 int rc = -ENODEV;
387 struct mem_ctl_info *mci;
388 struct i82875p_pvt *pvt;
389 struct pci_dev *ovrfl_pdev;
390 void __iomem *ovrfl_window;
391 u32 drc;
392 u32 nr_chans;
393 struct i82875p_error_info discard;
394
395 debugf0("%s()\n", __func__);
396 ovrfl_pdev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL);
397
398 if (i82875p_setup_overfl_dev(pdev, &ovrfl_pdev, &ovrfl_window))
399 return -ENODEV;
400 drc = readl(ovrfl_window + I82875P_DRC);
401 nr_chans = dual_channel_active(drc) + 1;
402 mci = edac_mc_alloc(sizeof(*pvt), I82875P_NR_CSROWS(nr_chans),
403 nr_chans);
404
405 if (!mci) {
406 rc = -ENOMEM;
407 goto fail0;
408 }
383 409
410 debugf3("%s(): init mci\n", __func__);
411 mci->dev = &pdev->dev;
412 mci->mtype_cap = MEM_FLAG_DDR;
413 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
414 mci->edac_cap = EDAC_FLAG_UNKNOWN;
415 mci->mod_name = EDAC_MOD_STR;
416 mci->mod_ver = I82875P_REVISION;
417 mci->ctl_name = i82875p_devs[dev_idx].ctl_name;
418 mci->edac_check = i82875p_check;
419 mci->ctl_page_to_phys = NULL;
420 debugf3("%s(): init pvt\n", __func__);
421 pvt = (struct i82875p_pvt *) mci->pvt_info;
422 pvt->ovrfl_pdev = ovrfl_pdev;
423 pvt->ovrfl_window = ovrfl_window;
424 i82875p_init_csrows(mci, pdev, ovrfl_window, drc);
384 i82875p_get_error_info(mci, &discard); /* clear counters */ 425 i82875p_get_error_info(mci, &discard); /* clear counters */
385 426
386 if (edac_mc_add_mc(mci)) { 427 /* Here we assume that we will never see multiple instances of this
428 * type of memory controller. The ID is therefore hardcoded to 0.
429 */
430 if (edac_mc_add_mc(mci,0)) {
387 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 431 debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
388 goto fail3; 432 goto fail1;
389 } 433 }
390 434
391 /* get this far and it's successful */ 435 /* get this far and it's successful */
392 debugf3("%s(): success\n", __func__); 436 debugf3("%s(): success\n", __func__);
393 return 0; 437 return 0;
394 438
395fail3: 439fail1:
396 edac_mc_free(mci); 440 edac_mc_free(mci);
397 441
398fail2: 442fail0:
399 iounmap(ovrfl_window); 443 iounmap(ovrfl_window);
400
401fail1:
402 pci_release_regions(ovrfl_pdev); 444 pci_release_regions(ovrfl_pdev);
403 445
404#ifdef CORRECT_BIOS
405fail0:
406#endif
407 pci_disable_device(ovrfl_pdev); 446 pci_disable_device(ovrfl_pdev);
408 /* NOTE: the ovrfl proc entry and pci_dev are intentionally left */ 447 /* NOTE: the ovrfl proc entry and pci_dev are intentionally left */
409 return rc; 448 return rc;
@@ -436,7 +475,7 @@ static void __devexit i82875p_remove_one(struct pci_dev *pdev)
436 475
437 debugf0("%s()\n", __func__); 476 debugf0("%s()\n", __func__);
438 477
439 if ((mci = edac_mc_del_mc(pdev)) == NULL) 478 if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
440 return; 479 return;
441 480
442 pvt = (struct i82875p_pvt *) mci->pvt_info; 481 pvt = (struct i82875p_pvt *) mci->pvt_info;
diff --git a/drivers/edac/r82600_edac.c b/drivers/edac/r82600_edac.c
index 4275b148c15e..a0e248d11ed9 100644
--- a/drivers/edac/r82600_edac.c
+++ b/drivers/edac/r82600_edac.c
@@ -22,6 +22,8 @@
22#include <linux/slab.h> 22#include <linux/slab.h>
23#include "edac_mc.h" 23#include "edac_mc.h"
24 24
25#define R82600_REVISION " Ver: 2.0.0 " __DATE__
26
25#define r82600_printk(level, fmt, arg...) \ 27#define r82600_printk(level, fmt, arg...) \
26 edac_printk(level, "r82600", fmt, ##arg) 28 edac_printk(level, "r82600", fmt, ##arg)
27 29
@@ -133,17 +135,20 @@ static unsigned int disable_hardware_scrub = 0;
133static void r82600_get_error_info (struct mem_ctl_info *mci, 135static void r82600_get_error_info (struct mem_ctl_info *mci,
134 struct r82600_error_info *info) 136 struct r82600_error_info *info)
135{ 137{
136 pci_read_config_dword(mci->pdev, R82600_EAP, &info->eapr); 138 struct pci_dev *pdev;
139
140 pdev = to_pci_dev(mci->dev);
141 pci_read_config_dword(pdev, R82600_EAP, &info->eapr);
137 142
138 if (info->eapr & BIT(0)) 143 if (info->eapr & BIT(0))
139 /* Clear error to allow next error to be reported [p.62] */ 144 /* Clear error to allow next error to be reported [p.62] */
140 pci_write_bits32(mci->pdev, R82600_EAP, 145 pci_write_bits32(pdev, R82600_EAP,
141 ((u32) BIT(0) & (u32) BIT(1)), 146 ((u32) BIT(0) & (u32) BIT(1)),
142 ((u32) BIT(0) & (u32) BIT(1))); 147 ((u32) BIT(0) & (u32) BIT(1)));
143 148
144 if (info->eapr & BIT(1)) 149 if (info->eapr & BIT(1))
145 /* Clear error to allow next error to be reported [p.62] */ 150 /* Clear error to allow next error to be reported [p.62] */
146 pci_write_bits32(mci->pdev, R82600_EAP, 151 pci_write_bits32(pdev, R82600_EAP,
147 ((u32) BIT(0) & (u32) BIT(1)), 152 ((u32) BIT(0) & (u32) BIT(1)),
148 ((u32) BIT(0) & (u32) BIT(1))); 153 ((u32) BIT(0) & (u32) BIT(1)));
149} 154}
@@ -199,25 +204,72 @@ static void r82600_check(struct mem_ctl_info *mci)
199 r82600_process_error_info(mci, &info, 1); 204 r82600_process_error_info(mci, &info, 1);
200} 205}
201 206
202static int r82600_probe1(struct pci_dev *pdev, int dev_idx) 207static inline int ecc_enabled(u8 dramcr)
208{
209 return dramcr & BIT(5);
210}
211
212static void r82600_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
213 u8 dramcr)
203{ 214{
204 int rc = -ENODEV; 215 struct csrow_info *csrow;
205 int index; 216 int index;
206 struct mem_ctl_info *mci = NULL; 217 u8 drbar; /* SDRAM Row Boundry Address Register */
218 u32 row_high_limit, row_high_limit_last;
219 u32 reg_sdram, ecc_on, row_base;
220
221 ecc_on = ecc_enabled(dramcr);
222 reg_sdram = dramcr & BIT(4);
223 row_high_limit_last = 0;
224
225 for (index = 0; index < mci->nr_csrows; index++) {
226 csrow = &mci->csrows[index];
227
228 /* find the DRAM Chip Select Base address and mask */
229 pci_read_config_byte(pdev, R82600_DRBA + index, &drbar);
230
231 debugf1("%s() Row=%d DRBA = %#0x\n", __func__, index, drbar);
232
233 row_high_limit = ((u32) drbar << 24);
234/* row_high_limit = ((u32)drbar << 24) | 0xffffffUL; */
235
236 debugf1("%s() Row=%d, Boundry Address=%#0x, Last = %#0x\n",
237 __func__, index, row_high_limit, row_high_limit_last);
238
239 /* Empty row [p.57] */
240 if (row_high_limit == row_high_limit_last)
241 continue;
242
243 row_base = row_high_limit_last;
244
245 csrow->first_page = row_base >> PAGE_SHIFT;
246 csrow->last_page = (row_high_limit >> PAGE_SHIFT) - 1;
247 csrow->nr_pages = csrow->last_page - csrow->first_page + 1;
248 /* Error address is top 19 bits - so granularity is *
249 * 14 bits */
250 csrow->grain = 1 << 14;
251 csrow->mtype = reg_sdram ? MEM_RDDR : MEM_DDR;
252 /* FIXME - check that this is unknowable with this chipset */
253 csrow->dtype = DEV_UNKNOWN;
254
255 /* Mode is global on 82600 */
256 csrow->edac_mode = ecc_on ? EDAC_SECDED : EDAC_NONE;
257 row_high_limit_last = row_high_limit;
258 }
259}
260
261static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
262{
263 struct mem_ctl_info *mci;
207 u8 dramcr; 264 u8 dramcr;
208 u32 ecc_on;
209 u32 reg_sdram;
210 u32 eapr; 265 u32 eapr;
211 u32 scrub_disabled; 266 u32 scrub_disabled;
212 u32 sdram_refresh_rate; 267 u32 sdram_refresh_rate;
213 u32 row_high_limit_last = 0;
214 struct r82600_error_info discard; 268 struct r82600_error_info discard;
215 269
216 debugf0("%s()\n", __func__); 270 debugf0("%s()\n", __func__);
217 pci_read_config_byte(pdev, R82600_DRAMC, &dramcr); 271 pci_read_config_byte(pdev, R82600_DRAMC, &dramcr);
218 pci_read_config_dword(pdev, R82600_EAP, &eapr); 272 pci_read_config_dword(pdev, R82600_EAP, &eapr);
219 ecc_on = dramcr & BIT(5);
220 reg_sdram = dramcr & BIT(4);
221 scrub_disabled = eapr & BIT(31); 273 scrub_disabled = eapr & BIT(31);
222 sdram_refresh_rate = dramcr & (BIT(0) | BIT(1)); 274 sdram_refresh_rate = dramcr & (BIT(0) | BIT(1));
223 debugf2("%s(): sdram refresh rate = %#0x\n", __func__, 275 debugf2("%s(): sdram refresh rate = %#0x\n", __func__,
@@ -225,13 +277,11 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
225 debugf2("%s(): DRAMC register = %#0x\n", __func__, dramcr); 277 debugf2("%s(): DRAMC register = %#0x\n", __func__, dramcr);
226 mci = edac_mc_alloc(0, R82600_NR_CSROWS, R82600_NR_CHANS); 278 mci = edac_mc_alloc(0, R82600_NR_CSROWS, R82600_NR_CHANS);
227 279
228 if (mci == NULL) { 280 if (mci == NULL)
229 rc = -ENOMEM; 281 return -ENOMEM;
230 goto fail;
231 }
232 282
233 debugf0("%s(): mci = %p\n", __func__, mci); 283 debugf0("%s(): mci = %p\n", __func__, mci);
234 mci->pdev = pdev; 284 mci->dev = &pdev->dev;
235 mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR; 285 mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR;
236 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; 286 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
237 /* FIXME try to work out if the chip leads have been used for COM2 287 /* FIXME try to work out if the chip leads have been used for COM2
@@ -244,7 +294,7 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
244 * is possible. */ 294 * is possible. */
245 mci->edac_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; 295 mci->edac_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
246 296
247 if (ecc_on) { 297 if (ecc_enabled(dramcr)) {
248 if (scrub_disabled) 298 if (scrub_disabled)
249 debugf3("%s(): mci = %p - Scrubbing disabled! EAP: " 299 debugf3("%s(): mci = %p - Scrubbing disabled! EAP: "
250 "%#0x\n", __func__, mci, eapr); 300 "%#0x\n", __func__, mci, eapr);
@@ -252,53 +302,17 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
252 mci->edac_cap = EDAC_FLAG_NONE; 302 mci->edac_cap = EDAC_FLAG_NONE;
253 303
254 mci->mod_name = EDAC_MOD_STR; 304 mci->mod_name = EDAC_MOD_STR;
255 mci->mod_ver = "$Revision: 1.1.2.6 $"; 305 mci->mod_ver = R82600_REVISION;
256 mci->ctl_name = "R82600"; 306 mci->ctl_name = "R82600";
257 mci->edac_check = r82600_check; 307 mci->edac_check = r82600_check;
258 mci->ctl_page_to_phys = NULL; 308 mci->ctl_page_to_phys = NULL;
259 309 r82600_init_csrows(mci, pdev, dramcr);
260 for (index = 0; index < mci->nr_csrows; index++) {
261 struct csrow_info *csrow = &mci->csrows[index];
262 u8 drbar; /* sDram Row Boundry Address Register */
263 u32 row_high_limit;
264 u32 row_base;
265
266 /* find the DRAM Chip Select Base address and mask */
267 pci_read_config_byte(mci->pdev, R82600_DRBA + index, &drbar);
268
269 debugf1("MC%d: %s() Row=%d DRBA = %#0x\n", mci->mc_idx,
270 __func__, index, drbar);
271
272 row_high_limit = ((u32) drbar << 24);
273/* row_high_limit = ((u32)drbar << 24) | 0xffffffUL; */
274
275 debugf1("MC%d: %s() Row=%d, Boundry Address=%#0x, Last = "
276 "%#0x \n", mci->mc_idx, __func__, index,
277 row_high_limit, row_high_limit_last);
278
279 /* Empty row [p.57] */
280 if (row_high_limit == row_high_limit_last)
281 continue;
282
283 row_base = row_high_limit_last;
284 csrow->first_page = row_base >> PAGE_SHIFT;
285 csrow->last_page = (row_high_limit >> PAGE_SHIFT) - 1;
286 csrow->nr_pages = csrow->last_page - csrow->first_page + 1;
287 /* Error address is top 19 bits - so granularity is *
288 * 14 bits */
289 csrow->grain = 1 << 14;
290 csrow->mtype = reg_sdram ? MEM_RDDR : MEM_DDR;
291 /* FIXME - check that this is unknowable with this chipset */
292 csrow->dtype = DEV_UNKNOWN;
293
294 /* Mode is global on 82600 */
295 csrow->edac_mode = ecc_on ? EDAC_SECDED : EDAC_NONE;
296 row_high_limit_last = row_high_limit;
297 }
298
299 r82600_get_error_info(mci, &discard); /* clear counters */ 310 r82600_get_error_info(mci, &discard); /* clear counters */
300 311
301 if (edac_mc_add_mc(mci)) { 312 /* Here we assume that we will never see multiple instances of this
313 * type of memory controller. The ID is therefore hardcoded to 0.
314 */
315 if (edac_mc_add_mc(mci,0)) {
302 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 316 debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
303 goto fail; 317 goto fail;
304 } 318 }
@@ -308,17 +322,15 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
308 if (disable_hardware_scrub) { 322 if (disable_hardware_scrub) {
309 debugf3("%s(): Disabling Hardware Scrub (scrub on error)\n", 323 debugf3("%s(): Disabling Hardware Scrub (scrub on error)\n",
310 __func__); 324 __func__);
311 pci_write_bits32(mci->pdev, R82600_EAP, BIT(31), BIT(31)); 325 pci_write_bits32(pdev, R82600_EAP, BIT(31), BIT(31));
312 } 326 }
313 327
314 debugf3("%s(): success\n", __func__); 328 debugf3("%s(): success\n", __func__);
315 return 0; 329 return 0;
316 330
317fail: 331fail:
318 if (mci) 332 edac_mc_free(mci);
319 edac_mc_free(mci); 333 return -ENODEV;
320
321 return rc;
322} 334}
323 335
324/* returns count (>= 0), or negative on error */ 336/* returns count (>= 0), or negative on error */
@@ -337,7 +349,7 @@ static void __devexit r82600_remove_one(struct pci_dev *pdev)
337 349
338 debugf0("%s()\n", __func__); 350 debugf0("%s()\n", __func__);
339 351
340 if ((mci = edac_mc_del_mc(pdev)) == NULL) 352 if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
341 return; 353 return;
342 354
343 edac_mc_free(mci); 355 edac_mc_free(mci);
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 8b46ef7d9ff8..7be1d0a3e8f8 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -494,8 +494,8 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
494 err = pci_request_region(dev, SMBBAR, i801_driver.name); 494 err = pci_request_region(dev, SMBBAR, i801_driver.name);
495 if (err) { 495 if (err) {
496 dev_err(&dev->dev, "Failed to request SMBus region " 496 dev_err(&dev->dev, "Failed to request SMBus region "
497 "0x%lx-0x%lx\n", i801_smba, 497 "0x%lx-0x%Lx\n", i801_smba,
498 pci_resource_end(dev, SMBBAR)); 498 (unsigned long long)pci_resource_end(dev, SMBBAR));
499 goto exit; 499 goto exit;
500 } 500 }
501 501
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index 602797a44208..b7e459e4f284 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -146,7 +146,16 @@ static void ide_detach(struct pcmcia_device *link)
146 kfree(link->priv); 146 kfree(link->priv);
147} /* ide_detach */ 147} /* ide_detach */
148 148
149static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle) 149static void idecs_mmio_fixup(ide_hwif_t *hwif)
150{
151 default_hwif_mmiops(hwif);
152 hwif->mmio = 2;
153
154 ide_undecoded_slave(hwif);
155}
156
157static int idecs_register(unsigned long io, unsigned long ctl,
158 unsigned long irq, struct pcmcia_device *handle, int is_mmio)
150{ 159{
151 hw_regs_t hw; 160 hw_regs_t hw;
152 memset(&hw, 0, sizeof(hw)); 161 memset(&hw, 0, sizeof(hw));
@@ -154,7 +163,19 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq
154 hw.irq = irq; 163 hw.irq = irq;
155 hw.chipset = ide_pci; 164 hw.chipset = ide_pci;
156 hw.dev = &handle->dev; 165 hw.dev = &handle->dev;
157 return ide_register_hw_with_fixup(&hw, NULL, ide_undecoded_slave); 166
167 if(is_mmio)
168 return ide_register_hw_with_fixup(&hw, NULL, idecs_mmio_fixup);
169 else
170 return ide_register_hw_with_fixup(&hw, NULL, ide_undecoded_slave);
171}
172
173void outb_io(unsigned char value, unsigned long port) {
174 outb(value, port);
175}
176
177void outb_mem(unsigned char value, unsigned long port) {
178 writeb(value, (void __iomem *) port);
158} 179}
159 180
160/*====================================================================== 181/*======================================================================
@@ -180,7 +201,8 @@ static int ide_config(struct pcmcia_device *link)
180 } *stk = NULL; 201 } *stk = NULL;
181 cistpl_cftable_entry_t *cfg; 202 cistpl_cftable_entry_t *cfg;
182 int i, pass, last_ret = 0, last_fn = 0, hd, is_kme = 0; 203 int i, pass, last_ret = 0, last_fn = 0, hd, is_kme = 0;
183 unsigned long io_base, ctl_base; 204 unsigned long io_base, ctl_base, is_mmio, try_slave;
205 void (*my_outb)(unsigned char, unsigned long);
184 206
185 DEBUG(0, "ide_config(0x%p)\n", link); 207 DEBUG(0, "ide_config(0x%p)\n", link);
186 208
@@ -210,7 +232,7 @@ static int ide_config(struct pcmcia_device *link)
210 /* Not sure if this is right... look up the current Vcc */ 232 /* Not sure if this is right... look up the current Vcc */
211 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf)); 233 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf));
212 234
213 pass = io_base = ctl_base = 0; 235 pass = io_base = ctl_base = is_mmio = try_slave = 0;
214 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 236 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
215 tuple.Attributes = 0; 237 tuple.Attributes = 0;
216 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 238 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
@@ -258,11 +280,45 @@ static int ide_config(struct pcmcia_device *link)
258 goto next_entry; 280 goto next_entry;
259 io_base = link->io.BasePort1; 281 io_base = link->io.BasePort1;
260 ctl_base = link->io.BasePort1 + 0x0e; 282 ctl_base = link->io.BasePort1 + 0x0e;
283
284 if (io->win[0].len >= 0x20)
285 try_slave = 1;
286
261 } else goto next_entry; 287 } else goto next_entry;
262 /* If we've got this far, we're done */ 288 /* If we've got this far, we're done */
263 break; 289 break;
264 } 290 }
265 291
292 if ((cfg->mem.nwin > 0) || (stk->dflt.mem.nwin > 0)) {
293 win_req_t req;
294 memreq_t map;
295 cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &stk->dflt.mem;
296
297 if (mem->win[0].len < 16)
298 goto next_entry;
299
300 req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
301 req.Attributes |= WIN_ENABLE;
302 req.Base = mem->win[0].host_addr;
303 req.Size = 0;
304
305 req.AccessSpeed = 0;
306 if (pcmcia_request_window(&link, &req, &link->win) != 0)
307 goto next_entry;
308 map.Page = 0; map.CardOffset = mem->win[0].card_addr;
309 if (pcmcia_map_mem_page(link->win, &map) != 0)
310 goto next_entry;
311
312 io_base = (unsigned long) ioremap(req.Base, req.Size);
313 ctl_base = io_base + 0x0e;
314 is_mmio = 1;
315
316 if (mem->win[0].len >= 0x20)
317 try_slave = 1;
318
319 break;
320 }
321
266 next_entry: 322 next_entry:
267 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 323 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
268 memcpy(&stk->dflt, cfg, sizeof(stk->dflt)); 324 memcpy(&stk->dflt, cfg, sizeof(stk->dflt));
@@ -278,21 +334,26 @@ static int ide_config(struct pcmcia_device *link)
278 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 334 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
279 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 335 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
280 336
337 if(is_mmio)
338 my_outb = outb_mem;
339 else
340 my_outb = outb_io;
341
281 /* disable drive interrupts during IDE probe */ 342 /* disable drive interrupts during IDE probe */
282 outb(0x02, ctl_base); 343 my_outb(0x02, ctl_base);
283 344
284 /* special setup for KXLC005 card */ 345 /* special setup for KXLC005 card */
285 if (is_kme) 346 if (is_kme)
286 outb(0x81, ctl_base+1); 347 my_outb(0x81, ctl_base+1);
287 348
288 /* retry registration in case device is still spinning up */ 349 /* retry registration in case device is still spinning up */
289 for (hd = -1, i = 0; i < 10; i++) { 350 for (hd = -1, i = 0; i < 10; i++) {
290 hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link); 351 hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link, is_mmio);
291 if (hd >= 0) break; 352 if (hd >= 0) break;
292 if (link->io.NumPorts1 == 0x20) { 353 if (try_slave) {
293 outb(0x02, ctl_base + 0x10); 354 my_outb(0x02, ctl_base + 0x10);
294 hd = idecs_register(io_base + 0x10, ctl_base + 0x10, 355 hd = idecs_register(io_base + 0x10, ctl_base + 0x10,
295 link->irq.AssignedIRQ, link); 356 link->irq.AssignedIRQ, link, is_mmio);
296 if (hd >= 0) { 357 if (hd >= 0) {
297 io_base += 0x10; 358 io_base += 0x10;
298 ctl_base += 0x10; 359 ctl_base += 0x10;
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 4c3f2de2a06e..b2c033edb03c 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -54,7 +54,6 @@
54#include <linux/blkdev.h> 54#include <linux/blkdev.h>
55#include <linux/init.h> 55#include <linux/init.h>
56#include <linux/ioctl.h> 56#include <linux/ioctl.h>
57#include <linux/devfs_fs_kernel.h>
58#include <linux/cdev.h> 57#include <linux/cdev.h>
59#include <linux/in.h> 58#include <linux/in.h>
60#include <linux/net.h> 59#include <linux/net.h>
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 5e8bb41a088b..59ac35ddd51e 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -570,7 +570,8 @@ static int dvb_frontend_thread(void *data)
570 dvb_frontend_add_event(fe, s); 570 dvb_frontend_add_event(fe, s);
571 fepriv->status = s; 571 fepriv->status = s;
572 } 572 }
573 } 573 } else
574 dvb_frontend_swzigzag(fe);
574 } else 575 } else
575 dvb_frontend_swzigzag(fe); 576 dvb_frontend_swzigzag(fe);
576 } 577 }
@@ -975,6 +976,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
975 976
976 case FE_SET_FRONTEND_TUNE_MODE: 977 case FE_SET_FRONTEND_TUNE_MODE:
977 fepriv->tune_mode_flags = (unsigned long) parg; 978 fepriv->tune_mode_flags = (unsigned long) parg;
979 err = 0;
978 break; 980 break;
979 }; 981 };
980 982
diff --git a/drivers/media/dvb/frontends/cx22700.c b/drivers/media/dvb/frontends/cx22700.c
index 3c7c09a362b2..13ad1bfae663 100644
--- a/drivers/media/dvb/frontends/cx22700.c
+++ b/drivers/media/dvb/frontends/cx22700.c
@@ -134,6 +134,7 @@ static int cx22700_set_tps (struct cx22700_state *state, struct dvb_ofdm_paramet
134 return -EINVAL; 134 return -EINVAL;
135 135
136 if (p->code_rate_LP < FEC_1_2 || p->code_rate_LP > FEC_7_8) 136 if (p->code_rate_LP < FEC_1_2 || p->code_rate_LP > FEC_7_8)
137 return -EINVAL;
137 138
138 if (p->code_rate_HP == FEC_4_5 || p->code_rate_LP == FEC_4_5) 139 if (p->code_rate_HP == FEC_4_5 || p->code_rate_LP == FEC_4_5)
139 return -EINVAL; 140 return -EINVAL;
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c
index f2f795cba56a..274a87b7a5d5 100644
--- a/drivers/media/dvb/frontends/cx24123.c
+++ b/drivers/media/dvb/frontends/cx24123.c
@@ -670,10 +670,10 @@ static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage
670 switch (voltage) { 670 switch (voltage) {
671 case SEC_VOLTAGE_13: 671 case SEC_VOLTAGE_13:
672 dprintk("%s: setting voltage 13V\n", __FUNCTION__); 672 dprintk("%s: setting voltage 13V\n", __FUNCTION__);
673 return cx24123_writereg(state, 0x29, val | 0x80); 673 return cx24123_writereg(state, 0x29, val & 0x7f);
674 case SEC_VOLTAGE_18: 674 case SEC_VOLTAGE_18:
675 dprintk("%s: setting voltage 18V\n", __FUNCTION__); 675 dprintk("%s: setting voltage 18V\n", __FUNCTION__);
676 return cx24123_writereg(state, 0x29, val & 0x7f); 676 return cx24123_writereg(state, 0x29, val | 0x80);
677 default: 677 default:
678 return -EINVAL; 678 return -EINVAL;
679 }; 679 };
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 6163cb03b8f4..5f111d407730 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -1141,6 +1141,15 @@ static void frontend_init(struct budget_av *budget_av)
1141 break; 1141 break;
1142 1142
1143 case SUBID_DVBC_KNC1: 1143 case SUBID_DVBC_KNC1:
1144 budget_av->reinitialise_demod = 1;
1145 fe = tda10021_attach(&philips_cu1216_config,
1146 &budget_av->budget.i2c_adap,
1147 read_pwm(budget_av));
1148 if (fe) {
1149 fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
1150 }
1151 break;
1152
1144 case SUBID_DVBC_KNC1_PLUS: 1153 case SUBID_DVBC_KNC1_PLUS:
1145 case SUBID_DVBC_CINERGY1200: 1154 case SUBID_DVBC_CINERGY1200:
1146 budget_av->reinitialise_demod = 1; 1155 budget_av->reinitialise_demod = 1;
@@ -1293,11 +1302,7 @@ static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extensio
1293 1302
1294 budget_av->budget.dvb_adapter.priv = budget_av; 1303 budget_av->budget.dvb_adapter.priv = budget_av;
1295 frontend_init(budget_av); 1304 frontend_init(budget_av);
1296 1305 ciintf_init(budget_av);
1297 if (!budget_av->has_saa7113) {
1298 ciintf_init(budget_av);
1299 }
1300
1301 return 0; 1306 return 0;
1302} 1307}
1303 1308
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index df576331fd76..de14818d5cc4 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -3547,11 +3547,6 @@ void __devinit bttv_init_card2(struct bttv *btv)
3547 /* Hybrid DVB card, DOES have a tda9887 */ 3547 /* Hybrid DVB card, DOES have a tda9887 */
3548 if (btv->c.type == BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE) 3548 if (btv->c.type == BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE)
3549 tda9887 = 1; 3549 tda9887 = 1;
3550 if((btv->tuner_type == TUNER_PHILIPS_FM1216ME_MK3) ||
3551 (btv->tuner_type == TUNER_PHILIPS_FM1236_MK3) ||
3552 (btv->tuner_type == TUNER_PHILIPS_FM1256_IH3) ||
3553 tda9887)
3554 request_module("tda9887");
3555 if (btv->tuner_type != UNSET) 3550 if (btv->tuner_type != UNSET)
3556 request_module("tuner"); 3551 request_module("tuner");
3557} 3552}
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index 4ff81582ec56..349632b48e93 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -686,6 +686,39 @@ static struct videobuf_queue_ops blackbird_qops = {
686 686
687/* ------------------------------------------------------------------ */ 687/* ------------------------------------------------------------------ */
688 688
689static const u32 *ctrl_classes[] = {
690 cx88_user_ctrls,
691 cx2341x_mpeg_ctrls,
692 NULL
693};
694
695static int blackbird_queryctrl(struct cx8802_dev *dev, struct v4l2_queryctrl *qctrl)
696{
697 qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
698 if (qctrl->id == 0)
699 return -EINVAL;
700
701 /* Standard V4L2 controls */
702 if (cx8800_ctrl_query(qctrl) == 0)
703 return 0;
704
705 /* MPEG V4L2 controls */
706 if (cx2341x_ctrl_query(&dev->params, qctrl))
707 qctrl->flags |= V4L2_CTRL_FLAG_DISABLED;
708 return 0;
709}
710
711static int blackbird_querymenu(struct cx8802_dev *dev, struct v4l2_querymenu *qmenu)
712{
713 struct v4l2_queryctrl qctrl;
714
715 qctrl.id = qmenu->id;
716 blackbird_queryctrl(dev, &qctrl);
717 return v4l2_ctrl_query_menu(qmenu, &qctrl, cx2341x_ctrl_get_menu(qmenu->id));
718}
719
720/* ------------------------------------------------------------------ */
721
689static int mpeg_do_ioctl(struct inode *inode, struct file *file, 722static int mpeg_do_ioctl(struct inode *inode, struct file *file,
690 unsigned int cmd, void *arg) 723 unsigned int cmd, void *arg)
691{ 724{
@@ -866,6 +899,16 @@ static int mpeg_do_ioctl(struct inode *inode, struct file *file,
866 core->name); 899 core->name);
867 return 0; 900 return 0;
868 } 901 }
902 case VIDIOC_QUERYMENU:
903 return blackbird_querymenu(dev, arg);
904 case VIDIOC_QUERYCTRL:
905 {
906 struct v4l2_queryctrl *c = arg;
907
908 if (blackbird_queryctrl(dev, c) == 0)
909 return 0;
910 return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl);
911 }
869 912
870 default: 913 default:
871 return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl); 914 return cx88_do_ioctl(inode, file, 0, dev->core, cmd, arg, mpeg_do_ioctl);
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index f9d68f20dc88..14bd4863d157 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1194,6 +1194,21 @@ struct cx88_board cx88_boards[] = {
1194 }}, 1194 }},
1195 .dvb = 1, 1195 .dvb = 1,
1196 }, 1196 },
1197 [CX88_BOARD_GENIATECH_DVBS] = {
1198 .name = "Geniatech DVB-S",
1199 .tuner_type = TUNER_ABSENT,
1200 .radio_type = UNSET,
1201 .tuner_addr = ADDR_UNSET,
1202 .radio_addr = ADDR_UNSET,
1203 .input = {{
1204 .type = CX88_VMUX_DVB,
1205 .vmux = 0,
1206 },{
1207 .type = CX88_VMUX_COMPOSITE1,
1208 .vmux = 1,
1209 }},
1210 .dvb = 1,
1211 },
1197}; 1212};
1198const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards); 1213const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
1199 1214
@@ -1439,6 +1454,10 @@ struct cx88_subid cx88_subids[] = {
1439 .subvendor = 0x18ac, 1454 .subvendor = 0x18ac,
1440 .subdevice = 0xd800, /* FusionHDTV 3 Gold (original revision) */ 1455 .subdevice = 0xd800, /* FusionHDTV 3 Gold (original revision) */
1441 .card = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q, 1456 .card = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q,
1457 },{
1458 .subvendor = 0x14f1,
1459 .subdevice = 0x0084,
1460 .card = CX88_BOARD_GENIATECH_DVBS,
1442 }, 1461 },
1443}; 1462};
1444const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids); 1463const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index dce1feddd55d..afde3789d702 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -496,6 +496,26 @@ static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t
496 return 0; 496 return 0;
497} 497}
498 498
499static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
500{
501 struct cx8802_dev *dev= fe->dvb->priv;
502 struct cx88_core *core = dev->core;
503
504 if (voltage == SEC_VOLTAGE_OFF) {
505 dprintk(1,"LNB Voltage OFF\n");
506 cx_write(MO_GP0_IO, 0x0000efff);
507 }
508
509 if (core->prev_set_voltage)
510 return core->prev_set_voltage(fe, voltage);
511 return 0;
512}
513
514static struct cx24123_config geniatech_dvbs_config = {
515 .demod_address = 0x55,
516 .set_ts_params = cx24123_set_ts_param,
517};
518
499static struct cx24123_config hauppauge_novas_config = { 519static struct cx24123_config hauppauge_novas_config = {
500 .demod_address = 0x55, 520 .demod_address = 0x55,
501 .set_ts_params = cx24123_set_ts_param, 521 .set_ts_params = cx24123_set_ts_param,
@@ -760,6 +780,14 @@ static int dvb_register(struct cx8802_dev *dev)
760 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; 780 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
761 } 781 }
762 break; 782 break;
783 case CX88_BOARD_GENIATECH_DVBS:
784 dev->dvb.frontend = cx24123_attach(&geniatech_dvbs_config,
785 &dev->core->i2c_adap);
786 if (dev->dvb.frontend) {
787 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
788 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
789 }
790 break;
763#endif 791#endif
764 default: 792 default:
765 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n", 793 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 8d5cf474b68e..c538d99ec9f6 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -327,6 +327,51 @@ static struct cx88_ctrl cx8800_ctls[] = {
327}; 327};
328static const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls); 328static const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls);
329 329
330const u32 cx88_user_ctrls[] = {
331 V4L2_CID_USER_CLASS,
332 V4L2_CID_BRIGHTNESS,
333 V4L2_CID_CONTRAST,
334 V4L2_CID_SATURATION,
335 V4L2_CID_HUE,
336 V4L2_CID_AUDIO_VOLUME,
337 V4L2_CID_AUDIO_BALANCE,
338 V4L2_CID_AUDIO_MUTE,
339 0
340};
341EXPORT_SYMBOL(cx88_user_ctrls);
342
343static const u32 *ctrl_classes[] = {
344 cx88_user_ctrls,
345 NULL
346};
347
348int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl)
349{
350 int i;
351
352 if (qctrl->id < V4L2_CID_BASE ||
353 qctrl->id >= V4L2_CID_LASTP1)
354 return -EINVAL;
355 for (i = 0; i < CX8800_CTLS; i++)
356 if (cx8800_ctls[i].v.id == qctrl->id)
357 break;
358 if (i == CX8800_CTLS) {
359 *qctrl = no_ctl;
360 return 0;
361 }
362 *qctrl = cx8800_ctls[i].v;
363 return 0;
364}
365EXPORT_SYMBOL(cx8800_ctrl_query);
366
367static int cx88_queryctrl(struct v4l2_queryctrl *qctrl)
368{
369 qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id);
370 if (qctrl->id == 0)
371 return -EINVAL;
372 return cx8800_ctrl_query(qctrl);
373}
374
330/* ------------------------------------------------------------------- */ 375/* ------------------------------------------------------------------- */
331/* resource management */ 376/* resource management */
332 377
@@ -1362,20 +1407,8 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
1362 case VIDIOC_QUERYCTRL: 1407 case VIDIOC_QUERYCTRL:
1363 { 1408 {
1364 struct v4l2_queryctrl *c = arg; 1409 struct v4l2_queryctrl *c = arg;
1365 int i;
1366 1410
1367 if (c->id < V4L2_CID_BASE || 1411 return cx88_queryctrl(c);
1368 c->id >= V4L2_CID_LASTP1)
1369 return -EINVAL;
1370 for (i = 0; i < CX8800_CTLS; i++)
1371 if (cx8800_ctls[i].v.id == c->id)
1372 break;
1373 if (i == CX8800_CTLS) {
1374 *c = no_ctl;
1375 return 0;
1376 }
1377 *c = cx8800_ctls[i].v;
1378 return 0;
1379 } 1412 }
1380 case VIDIOC_G_CTRL: 1413 case VIDIOC_G_CTRL:
1381 return get_control(core,arg); 1414 return get_control(core,arg);
@@ -1893,8 +1926,6 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1893 /* load and configure helper modules */ 1926 /* load and configure helper modules */
1894 if (TUNER_ABSENT != core->tuner_type) 1927 if (TUNER_ABSENT != core->tuner_type)
1895 request_module("tuner"); 1928 request_module("tuner");
1896 if (core->tda9887_conf)
1897 request_module("tda9887");
1898 1929
1899 /* register v4l devices */ 1930 /* register v4l devices */
1900 dev->video_dev = cx88_vdev_init(core,dev->pci, 1931 dev->video_dev = cx88_vdev_init(core,dev->pci,
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 9a9a0fc7a41a..e7810955dd4f 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -196,6 +196,7 @@ extern struct sram_channel cx88_sram_channels[];
196#define CX88_BOARD_PIXELVIEW_PLAYTV_P7000 49 196#define CX88_BOARD_PIXELVIEW_PLAYTV_P7000 49
197#define CX88_BOARD_NPGTECH_REALTV_TOP10FM 50 197#define CX88_BOARD_NPGTECH_REALTV_TOP10FM 50
198#define CX88_BOARD_WINFAST_DTV2000H 51 198#define CX88_BOARD_WINFAST_DTV2000H 51
199#define CX88_BOARD_GENIATECH_DVBS 52
199 200
200enum cx88_itype { 201enum cx88_itype {
201 CX88_VMUX_COMPOSITE1 = 1, 202 CX88_VMUX_COMPOSITE1 = 1,
@@ -590,6 +591,8 @@ int cx8802_resume_common(struct pci_dev *pci_dev);
590extern int cx88_do_ioctl(struct inode *inode, struct file *file, int radio, 591extern int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
591 struct cx88_core *core, unsigned int cmd, 592 struct cx88_core *core, unsigned int cmd,
592 void *arg, v4l2_kioctl driver_ioctl); 593 void *arg, v4l2_kioctl driver_ioctl);
594extern const u32 cx88_user_ctrls[];
595extern int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl);
593 596
594/* 597/*
595 * Local variables: 598 * Local variables:
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 9286090817cd..2a461dde480c 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1574,8 +1574,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1574 request_module("tvp5150"); 1574 request_module("tvp5150");
1575 if (dev->has_tuner) 1575 if (dev->has_tuner)
1576 request_module("tuner"); 1576 request_module("tuner");
1577 if (dev->tda9887_conf)
1578 request_module("tda9887");
1579#endif 1577#endif
1580 errCode = em28xx_config(dev); 1578 errCode = em28xx_config(dev);
1581 if (errCode) { 1579 if (errCode) {
diff --git a/drivers/media/video/msp3400-driver.h b/drivers/media/video/msp3400-driver.h
index 4e451049013d..545e4ac094f2 100644
--- a/drivers/media/video/msp3400-driver.h
+++ b/drivers/media/video/msp3400-driver.h
@@ -90,8 +90,8 @@ struct msp_state {
90 /* thread */ 90 /* thread */
91 struct task_struct *kthread; 91 struct task_struct *kthread;
92 wait_queue_head_t wq; 92 wait_queue_head_t wq;
93 int restart:1; 93 unsigned int restart:1;
94 int watch_stereo:1; 94 unsigned int watch_stereo:1;
95}; 95};
96 96
97/* msp3400-driver.c */ 97/* msp3400-driver.c */
diff --git a/drivers/media/video/pvrusb2/Makefile b/drivers/media/video/pvrusb2/Makefile
index fed603ad0a67..02e414210dac 100644
--- a/drivers/media/video/pvrusb2/Makefile
+++ b/drivers/media/video/pvrusb2/Makefile
@@ -8,7 +8,7 @@ obj-pvrusb2-24xxx-$(CONFIG_VIDEO_PVRUSB2_24XXX) := \
8pvrusb2-objs := pvrusb2-i2c-core.o pvrusb2-i2c-cmd-v4l2.o \ 8pvrusb2-objs := pvrusb2-i2c-core.o pvrusb2-i2c-cmd-v4l2.o \
9 pvrusb2-audio.o pvrusb2-i2c-chips-v4l2.o \ 9 pvrusb2-audio.o pvrusb2-i2c-chips-v4l2.o \
10 pvrusb2-encoder.o pvrusb2-video-v4l.o \ 10 pvrusb2-encoder.o pvrusb2-video-v4l.o \
11 pvrusb2-eeprom.o pvrusb2-tuner.o pvrusb2-demod.o \ 11 pvrusb2-eeprom.o pvrusb2-tuner.o \
12 pvrusb2-main.o pvrusb2-hdw.o pvrusb2-v4l2.o \ 12 pvrusb2-main.o pvrusb2-hdw.o pvrusb2-v4l2.o \
13 pvrusb2-ctrl.o pvrusb2-std.o \ 13 pvrusb2-ctrl.o pvrusb2-std.o \
14 pvrusb2-context.o pvrusb2-io.o pvrusb2-ioread.o \ 14 pvrusb2-context.o pvrusb2-io.o pvrusb2-ioread.o \
diff --git a/drivers/media/video/pvrusb2/pvrusb2-audio.c b/drivers/media/video/pvrusb2/pvrusb2-audio.c
index 313d2dcf9e4b..9846c464ec80 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-audio.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-audio.c
@@ -145,8 +145,8 @@ static int get_audio_status(struct pvr2_msp3400_handler *ctxt)
145 145
146static void pvr2_msp3400_detach(struct pvr2_msp3400_handler *ctxt) 146static void pvr2_msp3400_detach(struct pvr2_msp3400_handler *ctxt)
147{ 147{
148 ctxt->client->handler = 0; 148 ctxt->client->handler = NULL;
149 ctxt->hdw->audio_stat = 0; 149 ctxt->hdw->audio_stat = NULL;
150 kfree(ctxt); 150 kfree(ctxt);
151} 151}
152 152
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.c b/drivers/media/video/pvrusb2/pvrusb2-context.c
index 40dc59871a45..f129f316d20e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-context.c
@@ -77,7 +77,7 @@ struct pvr2_context *pvr2_context_create(
77 const struct usb_device_id *devid, 77 const struct usb_device_id *devid,
78 void (*setup_func)(struct pvr2_context *)) 78 void (*setup_func)(struct pvr2_context *))
79{ 79{
80 struct pvr2_context *mp = 0; 80 struct pvr2_context *mp = NULL;
81 mp = kmalloc(sizeof(*mp),GFP_KERNEL); 81 mp = kmalloc(sizeof(*mp),GFP_KERNEL);
82 if (!mp) goto done; 82 if (!mp) goto done;
83 memset(mp,0,sizeof(*mp)); 83 memset(mp,0,sizeof(*mp));
@@ -87,7 +87,7 @@ struct pvr2_context *pvr2_context_create(
87 mp->hdw = pvr2_hdw_create(intf,devid); 87 mp->hdw = pvr2_hdw_create(intf,devid);
88 if (!mp->hdw) { 88 if (!mp->hdw) {
89 pvr2_context_destroy(mp); 89 pvr2_context_destroy(mp);
90 mp = 0; 90 mp = NULL;
91 goto done; 91 goto done;
92 } 92 }
93 93
@@ -145,7 +145,7 @@ void pvr2_channel_init(struct pvr2_channel *cp,struct pvr2_context *mp)
145{ 145{
146 cp->hdw = mp->hdw; 146 cp->hdw = mp->hdw;
147 cp->mc_head = mp; 147 cp->mc_head = mp;
148 cp->mc_next = 0; 148 cp->mc_next = NULL;
149 cp->mc_prev = mp->mc_last; 149 cp->mc_prev = mp->mc_last;
150 if (mp->mc_last) { 150 if (mp->mc_last) {
151 mp->mc_last->mc_next = cp; 151 mp->mc_last->mc_next = cp;
@@ -160,8 +160,8 @@ static void pvr2_channel_disclaim_stream(struct pvr2_channel *cp)
160{ 160{
161 if (!cp->stream) return; 161 if (!cp->stream) return;
162 pvr2_stream_kill(cp->stream->stream); 162 pvr2_stream_kill(cp->stream->stream);
163 cp->stream->user = 0; 163 cp->stream->user = NULL;
164 cp->stream = 0; 164 cp->stream = NULL;
165} 165}
166 166
167 167
@@ -179,7 +179,7 @@ void pvr2_channel_done(struct pvr2_channel *cp)
179 } else { 179 } else {
180 mp->mc_first = cp->mc_next; 180 mp->mc_first = cp->mc_next;
181 } 181 }
182 cp->hdw = 0; 182 cp->hdw = NULL;
183} 183}
184 184
185 185
@@ -212,7 +212,7 @@ struct pvr2_ioread *pvr2_channel_create_mpeg_stream(
212{ 212{
213 struct pvr2_ioread *cp; 213 struct pvr2_ioread *cp;
214 cp = pvr2_ioread_create(); 214 cp = pvr2_ioread_create();
215 if (!cp) return 0; 215 if (!cp) return NULL;
216 pvr2_ioread_setup(cp,sp->stream); 216 pvr2_ioread_setup(cp,sp->stream);
217 pvr2_ioread_set_sync_key(cp,stream_sync_key,sizeof(stream_sync_key)); 217 pvr2_ioread_set_sync_key(cp,stream_sync_key,sizeof(stream_sync_key));
218 return cp; 218 return cp;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
index d5df9fbeba2f..fb6198f1df98 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c
@@ -158,7 +158,7 @@ int pvr2_ctrl_get_mask(struct pvr2_ctrl *cptr)
158/* Retrieve the control's name */ 158/* Retrieve the control's name */
159const char *pvr2_ctrl_get_name(struct pvr2_ctrl *cptr) 159const char *pvr2_ctrl_get_name(struct pvr2_ctrl *cptr)
160{ 160{
161 if (!cptr) return 0; 161 if (!cptr) return NULL;
162 return cptr->info->name; 162 return cptr->info->name;
163} 163}
164 164
@@ -166,7 +166,7 @@ const char *pvr2_ctrl_get_name(struct pvr2_ctrl *cptr)
166/* Retrieve the control's desc */ 166/* Retrieve the control's desc */
167const char *pvr2_ctrl_get_desc(struct pvr2_ctrl *cptr) 167const char *pvr2_ctrl_get_desc(struct pvr2_ctrl *cptr)
168{ 168{
169 if (!cptr) return 0; 169 if (!cptr) return NULL;
170 return cptr->info->desc; 170 return cptr->info->desc;
171} 171}
172 172
@@ -488,7 +488,7 @@ int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr,
488 488
489 LOCK_TAKE(cptr->hdw->big_lock); do { 489 LOCK_TAKE(cptr->hdw->big_lock); do {
490 if (cptr->info->type == pvr2_ctl_int) { 490 if (cptr->info->type == pvr2_ctl_int) {
491 ret = parse_token(ptr,len,valptr,0,0); 491 ret = parse_token(ptr,len,valptr,NULL,0);
492 if ((ret >= 0) && 492 if ((ret >= 0) &&
493 ((*valptr < cptr->info->def.type_int.min_value) || 493 ((*valptr < cptr->info->def.type_int.min_value) ||
494 (*valptr > cptr->info->def.type_int.max_value))) { 494 (*valptr > cptr->info->def.type_int.max_value))) {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
index 27eadaff75a0..c80c26be6e4d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c
@@ -139,8 +139,8 @@ static const struct pvr2_v4l_cx2584x_ops decoder_ops[] = {
139 139
140static void decoder_detach(struct pvr2_v4l_cx2584x *ctxt) 140static void decoder_detach(struct pvr2_v4l_cx2584x *ctxt)
141{ 141{
142 ctxt->client->handler = 0; 142 ctxt->client->handler = NULL;
143 ctxt->hdw->decoder_ctrl = 0; 143 ctxt->hdw->decoder_ctrl = NULL;
144 kfree(ctxt); 144 kfree(ctxt);
145} 145}
146 146
@@ -221,7 +221,7 @@ static unsigned int decoder_describe(struct pvr2_v4l_cx2584x *ctxt,
221static void decoder_reset(struct pvr2_v4l_cx2584x *ctxt) 221static void decoder_reset(struct pvr2_v4l_cx2584x *ctxt)
222{ 222{
223 int ret; 223 int ret;
224 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,0); 224 ret = pvr2_i2c_client_cmd(ctxt->client,VIDIOC_INT_RESET,NULL);
225 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_reset (ret=%d)",ret); 225 pvr2_trace(PVR2_TRACE_CHIPS,"i2c cx25840 decoder_reset (ret=%d)",ret);
226} 226}
227 227
diff --git a/drivers/media/video/pvrusb2/pvrusb2-debugifc.c b/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
index 586900e365ff..f985f00d885a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-debugifc.c
@@ -82,7 +82,7 @@ static unsigned int debugifc_isolate_word(const char *buf,unsigned int count,
82 unsigned int wlen; 82 unsigned int wlen;
83 unsigned int scnt; 83 unsigned int scnt;
84 84
85 wptr = 0; 85 wptr = NULL;
86 wlen = 0; 86 wlen = 0;
87 scnt = debugifc_count_whitespace(buf,count); 87 scnt = debugifc_count_whitespace(buf,count);
88 consume_cnt += scnt; count -= scnt; buf += scnt; 88 consume_cnt += scnt; count -= scnt; buf += scnt;
@@ -337,8 +337,8 @@ int pvr2_debugifc_print_status(struct pvr2_hdw *hdw,
337} 337}
338 338
339 339
340int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf, 340static int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf,
341 unsigned int count) 341 unsigned int count)
342{ 342{
343 const char *wptr; 343 const char *wptr;
344 unsigned int wlen; 344 unsigned int wlen;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-demod.c b/drivers/media/video/pvrusb2/pvrusb2-demod.c
deleted file mode 100644
index 9686569a11f6..000000000000
--- a/drivers/media/video/pvrusb2/pvrusb2-demod.c
+++ /dev/null
@@ -1,126 +0,0 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
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
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include "pvrusb2.h"
24#include "pvrusb2-util.h"
25#include "pvrusb2-demod.h"
26#include "pvrusb2-hdw-internal.h"
27#include "pvrusb2-debug.h"
28#include <linux/videodev2.h>
29#include <media/tuner.h>
30#include <media/v4l2-common.h>
31
32
33struct pvr2_demod_handler {
34 struct pvr2_hdw *hdw;
35 struct pvr2_i2c_client *client;
36 struct pvr2_i2c_handler i2c_handler;
37 int type_update_fl;
38};
39
40
41static void set_config(struct pvr2_demod_handler *ctxt)
42{
43 struct pvr2_hdw *hdw = ctxt->hdw;
44 int cfg = 0;
45
46 switch (hdw->tuner_type) {
47 case TUNER_PHILIPS_FM1216ME_MK3:
48 case TUNER_PHILIPS_FM1236_MK3:
49 cfg = TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE;
50 break;
51 default:
52 break;
53 }
54 pvr2_trace(PVR2_TRACE_CHIPS,"i2c demod set_config(0x%x)",cfg);
55 pvr2_i2c_client_cmd(ctxt->client,TDA9887_SET_CONFIG,&cfg);
56 ctxt->type_update_fl = 0;
57}
58
59
60static int demod_check(struct pvr2_demod_handler *ctxt)
61{
62 struct pvr2_hdw *hdw = ctxt->hdw;
63 if (hdw->tuner_updated) ctxt->type_update_fl = !0;
64 return ctxt->type_update_fl != 0;
65}
66
67
68static void demod_update(struct pvr2_demod_handler *ctxt)
69{
70 if (ctxt->type_update_fl) set_config(ctxt);
71}
72
73
74static void demod_detach(struct pvr2_demod_handler *ctxt)
75{
76 ctxt->client->handler = 0;
77 kfree(ctxt);
78}
79
80
81static unsigned int demod_describe(struct pvr2_demod_handler *ctxt,char *buf,unsigned int cnt)
82{
83 return scnprintf(buf,cnt,"handler: pvrusb2-demod");
84}
85
86
87const static struct pvr2_i2c_handler_functions tuner_funcs = {
88 .detach = (void (*)(void *))demod_detach,
89 .check = (int (*)(void *))demod_check,
90 .update = (void (*)(void *))demod_update,
91 .describe = (unsigned int (*)(void *,char *,unsigned int))demod_describe,
92};
93
94
95int pvr2_i2c_demod_setup(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
96{
97 struct pvr2_demod_handler *ctxt;
98 if (cp->handler) return 0;
99
100 ctxt = kmalloc(sizeof(*ctxt),GFP_KERNEL);
101 if (!ctxt) return 0;
102 memset(ctxt,0,sizeof(*ctxt));
103
104 ctxt->i2c_handler.func_data = ctxt;
105 ctxt->i2c_handler.func_table = &tuner_funcs;
106 ctxt->type_update_fl = !0;
107 ctxt->client = cp;
108 ctxt->hdw = hdw;
109 cp->handler = &ctxt->i2c_handler;
110 pvr2_trace(PVR2_TRACE_CHIPS,"i2c 0x%x tda9887 V4L2 handler set up",
111 cp->client->addr);
112 return !0;
113}
114
115
116
117
118/*
119 Stuff for Emacs to see, in order to encourage consistent editing style:
120 *** Local Variables: ***
121 *** mode: c ***
122 *** fill-column: 70 ***
123 *** tab-width: 8 ***
124 *** c-basic-offset: 8 ***
125 *** End: ***
126 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-demod.h b/drivers/media/video/pvrusb2/pvrusb2-demod.h
deleted file mode 100644
index 4c4e40ffbf03..000000000000
--- a/drivers/media/video/pvrusb2/pvrusb2-demod.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 *
3 * $Id$
4 *
5 * Copyright (C) 2005 Mike Isely <isely@pobox.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21#ifndef __PVRUSB2_DEMOD_H
22#define __PVRUSB2_DEMOD_H
23
24#include "pvrusb2-i2c-core.h"
25
26int pvr2_i2c_demod_setup(struct pvr2_hdw *,struct pvr2_i2c_client *);
27
28#endif /* __PVRUSB2_DEMOD_H */
29
30/*
31 Stuff for Emacs to see, in order to encourage consistent editing style:
32 *** Local Variables: ***
33 *** mode: c ***
34 *** fill-column: 70 ***
35 *** tab-width: 8 ***
36 *** c-basic-offset: 8 ***
37 *** End: ***
38 */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-eeprom.c b/drivers/media/video/pvrusb2/pvrusb2-eeprom.c
index 94d383ff9889..6cff8e75f426 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-eeprom.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-eeprom.c
@@ -58,7 +58,7 @@ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw)
58 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 58 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
59 "Failed to allocate memory" 59 "Failed to allocate memory"
60 " required to read eeprom"); 60 " required to read eeprom");
61 return 0; 61 return NULL;
62 } 62 }
63 63
64 trace_eeprom("Value for eeprom addr from controller was 0x%x", 64 trace_eeprom("Value for eeprom addr from controller was 0x%x",
@@ -108,7 +108,7 @@ static u8 *pvr2_eeprom_fetch(struct pvr2_hdw *hdw)
108 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 108 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
109 "eeprom fetch set offs err=%d",ret); 109 "eeprom fetch set offs err=%d",ret);
110 kfree(eeprom); 110 kfree(eeprom);
111 return 0; 111 return NULL;
112 } 112 }
113 } 113 }
114 return eeprom; 114 return eeprom;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
index 2cc31695b435..18a7073501c6 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c
@@ -65,7 +65,7 @@ static int pvr2_encoder_write_words(struct pvr2_hdw *hdw,
65 } 65 }
66 ret = pvr2_send_request(hdw, 66 ret = pvr2_send_request(hdw,
67 hdw->cmd_buffer,1+(chunkCnt*7), 67 hdw->cmd_buffer,1+(chunkCnt*7),
68 0,0); 68 NULL,0);
69 if (ret) return ret; 69 if (ret) return ret;
70 data += chunkCnt; 70 data += chunkCnt;
71 dlen -= chunkCnt; 71 dlen -= chunkCnt;
@@ -322,7 +322,7 @@ int pvr2_encoder_configure(struct pvr2_hdw *hdw)
322 } 322 }
323 323
324 ret = cx2341x_update(hdw,pvr2_encoder_cmd, 324 ret = cx2341x_update(hdw,pvr2_encoder_cmd,
325 (hdw->enc_cur_valid ? &hdw->enc_cur_state : 0), 325 (hdw->enc_cur_valid ? &hdw->enc_cur_state : NULL),
326 &hdw->enc_ctl_state); 326 &hdw->enc_ctl_state);
327 if (ret) { 327 if (ret) {
328 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 328 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
index ba2afbfe32c5..0d6dc33ca320 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h
@@ -354,23 +354,6 @@ struct pvr2_hdw {
354 unsigned int control_cnt; 354 unsigned int control_cnt;
355}; 355};
356 356
357int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
358
359unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *);
360
361void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
362 unsigned long msk,unsigned long val);
363void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
364 unsigned long msk,
365 unsigned long val);
366
367void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw);
368void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw);
369
370int pvr2_i2c_basic_op(struct pvr2_hdw *,u8 i2c_addr,
371 u8 *wdata,u16 wlen,
372 u8 *rdata,u16 rlen);
373
374#endif /* __PVRUSB2_HDW_INTERNAL_H */ 357#endif /* __PVRUSB2_HDW_INTERNAL_H */
375 358
376/* 359/*
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 643c471375da..9b48abcf6089 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -63,7 +63,6 @@ struct pvr2_string_table {
63static const char *pvr2_client_24xxx[] = { 63static const char *pvr2_client_24xxx[] = {
64 "cx25840", 64 "cx25840",
65 "tuner", 65 "tuner",
66 "tda9887",
67 "wm8775", 66 "wm8775",
68}; 67};
69#endif 68#endif
@@ -73,7 +72,6 @@ static const char *pvr2_client_29xxx[] = {
73 "msp3400", 72 "msp3400",
74 "saa7115", 73 "saa7115",
75 "tuner", 74 "tuner",
76 "tda9887",
77}; 75};
78 76
79static struct pvr2_string_table pvr2_client_lists[] = { 77static struct pvr2_string_table pvr2_client_lists[] = {
@@ -89,8 +87,8 @@ static struct pvr2_string_table pvr2_client_lists[] = {
89#endif 87#endif
90}; 88};
91 89
92static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = 0}; 90static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL};
93DECLARE_MUTEX(pvr2_unit_sem); 91static DECLARE_MUTEX(pvr2_unit_sem);
94 92
95static int ctlchg = 0; 93static int ctlchg = 0;
96static int initusbreset = 1; 94static int initusbreset = 1;
@@ -263,6 +261,25 @@ static const char *control_values_subsystem[] = {
263 [PVR2_SUBSYS_B_ENC_RUN] = "enc_run", 261 [PVR2_SUBSYS_B_ENC_RUN] = "enc_run",
264}; 262};
265 263
264static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
265static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw);
266static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw);
267static unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw);
268static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw);
269static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw);
270static void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw);
271static void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
272 unsigned long msk,
273 unsigned long val);
274static void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
275 unsigned long msk,
276 unsigned long val);
277static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
278 unsigned int timeout,int probe_fl,
279 void *write_data,unsigned int write_len,
280 void *read_data,unsigned int read_len);
281static int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res);
282static int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res);
266 283
267static int ctrl_channelfreq_get(struct pvr2_ctrl *cptr,int *vp) 284static int ctrl_channelfreq_get(struct pvr2_ctrl *cptr,int *vp)
268{ 285{
@@ -405,7 +422,7 @@ static unsigned int ctrl_cx2341x_getv4lflags(struct pvr2_ctrl *cptr)
405 info = (struct pvr2_ctl_info *)(cptr->info); 422 info = (struct pvr2_ctl_info *)(cptr->info);
406 if (qctrl.flags & V4L2_CTRL_FLAG_READ_ONLY) { 423 if (qctrl.flags & V4L2_CTRL_FLAG_READ_ONLY) {
407 if (info->set_value) { 424 if (info->set_value) {
408 info->set_value = 0; 425 info->set_value = NULL;
409 } 426 }
410 } else { 427 } else {
411 if (!(info->set_value)) { 428 if (!(info->set_value)) {
@@ -836,14 +853,6 @@ unsigned long pvr2_hdw_get_sn(struct pvr2_hdw *hdw)
836} 853}
837 854
838 855
839struct pvr2_hdw *pvr2_hdw_find(int unit_number)
840{
841 if (unit_number < 0) return 0;
842 if (unit_number >= PVR_NUM) return 0;
843 return unit_pointers[unit_number];
844}
845
846
847int pvr2_hdw_get_unit_number(struct pvr2_hdw *hdw) 856int pvr2_hdw_get_unit_number(struct pvr2_hdw *hdw)
848{ 857{
849 return hdw->unit_number; 858 return hdw->unit_number;
@@ -917,9 +926,9 @@ static int pvr2_locate_firmware(struct pvr2_hdw *hdw,
917 * is not suitable for an usb transaction. 926 * is not suitable for an usb transaction.
918 * 927 *
919 */ 928 */
920int pvr2_upload_firmware1(struct pvr2_hdw *hdw) 929static int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
921{ 930{
922 const struct firmware *fw_entry = 0; 931 const struct firmware *fw_entry = NULL;
923 void *fw_ptr; 932 void *fw_ptr;
924 unsigned int pipe; 933 unsigned int pipe;
925 int ret; 934 int ret;
@@ -1015,7 +1024,7 @@ int pvr2_upload_firmware1(struct pvr2_hdw *hdw)
1015 1024
1016int pvr2_upload_firmware2(struct pvr2_hdw *hdw) 1025int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
1017{ 1026{
1018 const struct firmware *fw_entry = 0; 1027 const struct firmware *fw_entry = NULL;
1019 void *fw_ptr; 1028 void *fw_ptr;
1020 unsigned int pipe, fw_len, fw_done; 1029 unsigned int pipe, fw_len, fw_done;
1021 int actual_length; 1030 int actual_length;
@@ -1166,8 +1175,9 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw)
1166 reconfigure and start over. 1175 reconfigure and start over.
1167 1176
1168*/ 1177*/
1169void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw, 1178static void pvr2_hdw_subsys_bit_chg_no_lock(struct pvr2_hdw *hdw,
1170 unsigned long msk,unsigned long val) 1179 unsigned long msk,
1180 unsigned long val)
1171{ 1181{
1172 unsigned long nmsk; 1182 unsigned long nmsk;
1173 unsigned long vmsk; 1183 unsigned long vmsk;
@@ -1318,18 +1328,6 @@ void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw,
1318} 1328}
1319 1329
1320 1330
1321void pvr2_hdw_subsys_bit_set(struct pvr2_hdw *hdw,unsigned long msk)
1322{
1323 pvr2_hdw_subsys_bit_chg(hdw,msk,msk);
1324}
1325
1326
1327void pvr2_hdw_subsys_bit_clr(struct pvr2_hdw *hdw,unsigned long msk)
1328{
1329 pvr2_hdw_subsys_bit_chg(hdw,msk,0);
1330}
1331
1332
1333unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *hdw) 1331unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *hdw)
1334{ 1332{
1335 return hdw->subsys_enabled_mask; 1333 return hdw->subsys_enabled_mask;
@@ -1342,9 +1340,9 @@ unsigned long pvr2_hdw_subsys_stream_get(struct pvr2_hdw *hdw)
1342} 1340}
1343 1341
1344 1342
1345void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw, 1343static void pvr2_hdw_subsys_stream_bit_chg_no_lock(struct pvr2_hdw *hdw,
1346 unsigned long msk, 1344 unsigned long msk,
1347 unsigned long val) 1345 unsigned long val)
1348{ 1346{
1349 unsigned long val2; 1347 unsigned long val2;
1350 msk &= PVR2_SUBSYS_ALL; 1348 msk &= PVR2_SUBSYS_ALL;
@@ -1366,7 +1364,7 @@ void pvr2_hdw_subsys_stream_bit_chg(struct pvr2_hdw *hdw,
1366} 1364}
1367 1365
1368 1366
1369int pvr2_hdw_set_streaming_no_lock(struct pvr2_hdw *hdw,int enableFl) 1367static int pvr2_hdw_set_streaming_no_lock(struct pvr2_hdw *hdw,int enableFl)
1370{ 1368{
1371 if ((!enableFl) == !(hdw->flag_streaming_enabled)) return 0; 1369 if ((!enableFl) == !(hdw->flag_streaming_enabled)) return 0;
1372 if (enableFl) { 1370 if (enableFl) {
@@ -1400,8 +1398,8 @@ int pvr2_hdw_set_streaming(struct pvr2_hdw *hdw,int enable_flag)
1400} 1398}
1401 1399
1402 1400
1403int pvr2_hdw_set_stream_type_no_lock(struct pvr2_hdw *hdw, 1401static int pvr2_hdw_set_stream_type_no_lock(struct pvr2_hdw *hdw,
1404 enum pvr2_config config) 1402 enum pvr2_config config)
1405{ 1403{
1406 unsigned long sm = hdw->subsys_enabled_mask; 1404 unsigned long sm = hdw->subsys_enabled_mask;
1407 if (!hdw->flag_ok) return -EIO; 1405 if (!hdw->flag_ok) return -EIO;
@@ -1741,7 +1739,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1741 sizeof(pvr2_device_names)/sizeof(pvr2_device_names[0])) { 1739 sizeof(pvr2_device_names)/sizeof(pvr2_device_names[0])) {
1742 pvr2_trace(PVR2_TRACE_ERROR_LEGS, 1740 pvr2_trace(PVR2_TRACE_ERROR_LEGS,
1743 "Bogus device type of %u reported",hdw_type); 1741 "Bogus device type of %u reported",hdw_type);
1744 return 0; 1742 return NULL;
1745 } 1743 }
1746 1744
1747 hdw = kmalloc(sizeof(*hdw),GFP_KERNEL); 1745 hdw = kmalloc(sizeof(*hdw),GFP_KERNEL);
@@ -1922,38 +1920,38 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1922 if (hdw->mpeg_ctrl_info) kfree(hdw->mpeg_ctrl_info); 1920 if (hdw->mpeg_ctrl_info) kfree(hdw->mpeg_ctrl_info);
1923 kfree(hdw); 1921 kfree(hdw);
1924 } 1922 }
1925 return 0; 1923 return NULL;
1926} 1924}
1927 1925
1928 1926
1929/* Remove _all_ associations between this driver and the underlying USB 1927/* Remove _all_ associations between this driver and the underlying USB
1930 layer. */ 1928 layer. */
1931void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw) 1929static void pvr2_hdw_remove_usb_stuff(struct pvr2_hdw *hdw)
1932{ 1930{
1933 if (hdw->flag_disconnected) return; 1931 if (hdw->flag_disconnected) return;
1934 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_remove_usb_stuff: hdw=%p",hdw); 1932 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_remove_usb_stuff: hdw=%p",hdw);
1935 if (hdw->ctl_read_urb) { 1933 if (hdw->ctl_read_urb) {
1936 usb_kill_urb(hdw->ctl_read_urb); 1934 usb_kill_urb(hdw->ctl_read_urb);
1937 usb_free_urb(hdw->ctl_read_urb); 1935 usb_free_urb(hdw->ctl_read_urb);
1938 hdw->ctl_read_urb = 0; 1936 hdw->ctl_read_urb = NULL;
1939 } 1937 }
1940 if (hdw->ctl_write_urb) { 1938 if (hdw->ctl_write_urb) {
1941 usb_kill_urb(hdw->ctl_write_urb); 1939 usb_kill_urb(hdw->ctl_write_urb);
1942 usb_free_urb(hdw->ctl_write_urb); 1940 usb_free_urb(hdw->ctl_write_urb);
1943 hdw->ctl_write_urb = 0; 1941 hdw->ctl_write_urb = NULL;
1944 } 1942 }
1945 if (hdw->ctl_read_buffer) { 1943 if (hdw->ctl_read_buffer) {
1946 kfree(hdw->ctl_read_buffer); 1944 kfree(hdw->ctl_read_buffer);
1947 hdw->ctl_read_buffer = 0; 1945 hdw->ctl_read_buffer = NULL;
1948 } 1946 }
1949 if (hdw->ctl_write_buffer) { 1947 if (hdw->ctl_write_buffer) {
1950 kfree(hdw->ctl_write_buffer); 1948 kfree(hdw->ctl_write_buffer);
1951 hdw->ctl_write_buffer = 0; 1949 hdw->ctl_write_buffer = NULL;
1952 } 1950 }
1953 pvr2_hdw_render_useless_unlocked(hdw); 1951 pvr2_hdw_render_useless_unlocked(hdw);
1954 hdw->flag_disconnected = !0; 1952 hdw->flag_disconnected = !0;
1955 hdw->usb_dev = 0; 1953 hdw->usb_dev = NULL;
1956 hdw->usb_intf = 0; 1954 hdw->usb_intf = NULL;
1957} 1955}
1958 1956
1959 1957
@@ -1963,11 +1961,11 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
1963 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw); 1961 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw);
1964 if (hdw->fw_buffer) { 1962 if (hdw->fw_buffer) {
1965 kfree(hdw->fw_buffer); 1963 kfree(hdw->fw_buffer);
1966 hdw->fw_buffer = 0; 1964 hdw->fw_buffer = NULL;
1967 } 1965 }
1968 if (hdw->vid_stream) { 1966 if (hdw->vid_stream) {
1969 pvr2_stream_destroy(hdw->vid_stream); 1967 pvr2_stream_destroy(hdw->vid_stream);
1970 hdw->vid_stream = 0; 1968 hdw->vid_stream = NULL;
1971 } 1969 }
1972 if (hdw->audio_stat) { 1970 if (hdw->audio_stat) {
1973 hdw->audio_stat->detach(hdw->audio_stat->ctxt); 1971 hdw->audio_stat->detach(hdw->audio_stat->ctxt);
@@ -1981,7 +1979,7 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
1981 if ((hdw->unit_number >= 0) && 1979 if ((hdw->unit_number >= 0) &&
1982 (hdw->unit_number < PVR_NUM) && 1980 (hdw->unit_number < PVR_NUM) &&
1983 (unit_pointers[hdw->unit_number] == hdw)) { 1981 (unit_pointers[hdw->unit_number] == hdw)) {
1984 unit_pointers[hdw->unit_number] = 0; 1982 unit_pointers[hdw->unit_number] = NULL;
1985 } 1983 }
1986 } while (0); up(&pvr2_unit_sem); 1984 } while (0); up(&pvr2_unit_sem);
1987 if (hdw->controls) kfree(hdw->controls); 1985 if (hdw->controls) kfree(hdw->controls);
@@ -2018,7 +2016,7 @@ void pvr2_hdw_disconnect(struct pvr2_hdw *hdw)
2018 2016
2019// Attempt to autoselect an appropriate value for std_enum_cur given 2017// Attempt to autoselect an appropriate value for std_enum_cur given
2020// whatever is currently in std_mask_cur 2018// whatever is currently in std_mask_cur
2021void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw) 2019static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
2022{ 2020{
2023 unsigned int idx; 2021 unsigned int idx;
2024 for (idx = 1; idx < hdw->std_enum_cnt; idx++) { 2022 for (idx = 1; idx < hdw->std_enum_cnt; idx++) {
@@ -2033,7 +2031,7 @@ void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw)
2033 2031
2034// Calculate correct set of enumerated standards based on currently known 2032// Calculate correct set of enumerated standards based on currently known
2035// set of available standards bits. 2033// set of available standards bits.
2036void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw) 2034static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
2037{ 2035{
2038 struct v4l2_standard *newstd; 2036 struct v4l2_standard *newstd;
2039 unsigned int std_cnt; 2037 unsigned int std_cnt;
@@ -2043,12 +2041,12 @@ void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw)
2043 2041
2044 if (hdw->std_defs) { 2042 if (hdw->std_defs) {
2045 kfree(hdw->std_defs); 2043 kfree(hdw->std_defs);
2046 hdw->std_defs = 0; 2044 hdw->std_defs = NULL;
2047 } 2045 }
2048 hdw->std_enum_cnt = 0; 2046 hdw->std_enum_cnt = 0;
2049 if (hdw->std_enum_names) { 2047 if (hdw->std_enum_names) {
2050 kfree(hdw->std_enum_names); 2048 kfree(hdw->std_enum_names);
2051 hdw->std_enum_names = 0; 2049 hdw->std_enum_names = NULL;
2052 } 2050 }
2053 2051
2054 if (!std_cnt) { 2052 if (!std_cnt) {
@@ -2099,7 +2097,7 @@ unsigned int pvr2_hdw_get_ctrl_count(struct pvr2_hdw *hdw)
2099struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw, 2097struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_index(struct pvr2_hdw *hdw,
2100 unsigned int idx) 2098 unsigned int idx)
2101{ 2099{
2102 if (idx >= hdw->control_cnt) return 0; 2100 if (idx >= hdw->control_cnt) return NULL;
2103 return hdw->controls + idx; 2101 return hdw->controls + idx;
2104} 2102}
2105 2103
@@ -2118,7 +2116,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_by_id(struct pvr2_hdw *hdw,
2118 i = cptr->info->internal_id; 2116 i = cptr->info->internal_id;
2119 if (i && (i == ctl_id)) return cptr; 2117 if (i && (i == ctl_id)) return cptr;
2120 } 2118 }
2121 return 0; 2119 return NULL;
2122} 2120}
2123 2121
2124 2122
@@ -2135,7 +2133,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_v4l(struct pvr2_hdw *hdw,unsigned int ctl_id
2135 i = cptr->info->v4l_id; 2133 i = cptr->info->v4l_id;
2136 if (i && (i == ctl_id)) return cptr; 2134 if (i && (i == ctl_id)) return cptr;
2137 } 2135 }
2138 return 0; 2136 return NULL;
2139} 2137}
2140 2138
2141 2139
@@ -2149,7 +2147,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *hdw,
2149 int i; 2147 int i;
2150 2148
2151 /* This could be made a lot more efficient, but for now... */ 2149 /* This could be made a lot more efficient, but for now... */
2152 cp2 = 0; 2150 cp2 = NULL;
2153 for (idx = 0; idx < hdw->control_cnt; idx++) { 2151 for (idx = 0; idx < hdw->control_cnt; idx++) {
2154 cptr = hdw->controls + idx; 2152 cptr = hdw->controls + idx;
2155 i = cptr->info->v4l_id; 2153 i = cptr->info->v4l_id;
@@ -2159,7 +2157,7 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *hdw,
2159 cp2 = cptr; 2157 cp2 = cptr;
2160 } 2158 }
2161 return cp2; 2159 return cp2;
2162 return 0; 2160 return NULL;
2163} 2161}
2164 2162
2165 2163
@@ -2182,7 +2180,7 @@ static const char *get_ctrl_typename(enum pvr2_ctl_type tp)
2182 state(s) back to their previous value before this function was called. 2180 state(s) back to their previous value before this function was called.
2183 Thus we can automatically reconfigure affected pieces of the driver as 2181 Thus we can automatically reconfigure affected pieces of the driver as
2184 controls are changed. */ 2182 controls are changed. */
2185int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw) 2183static int pvr2_hdw_commit_ctl_internal(struct pvr2_hdw *hdw)
2186{ 2184{
2187 unsigned long saved_subsys_mask = hdw->subsys_enabled_mask; 2185 unsigned long saved_subsys_mask = hdw->subsys_enabled_mask;
2188 unsigned long stale_subsys_mask = 0; 2186 unsigned long stale_subsys_mask = 0;
@@ -2321,14 +2319,6 @@ void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *hdw)
2321} 2319}
2322 2320
2323 2321
2324void pvr2_hdw_poll_trigger(struct pvr2_hdw *hdw)
2325{
2326 LOCK_TAKE(hdw->big_lock); do {
2327 pvr2_hdw_poll_trigger_unlocked(hdw);
2328 } while (0); LOCK_GIVE(hdw->big_lock);
2329}
2330
2331
2332/* Return name for this driver instance */ 2322/* Return name for this driver instance */
2333const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw) 2323const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)
2334{ 2324{
@@ -2337,7 +2327,7 @@ const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw)
2337 2327
2338 2328
2339/* Return bit mask indicating signal status */ 2329/* Return bit mask indicating signal status */
2340unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw) 2330static unsigned int pvr2_hdw_get_signal_status_internal(struct pvr2_hdw *hdw)
2341{ 2331{
2342 unsigned int msk = 0; 2332 unsigned int msk = 0;
2343 switch (hdw->input_val) { 2333 switch (hdw->input_val) {
@@ -2424,7 +2414,7 @@ void pvr2_hdw_cpufw_set_enabled(struct pvr2_hdw *hdw, int enable_flag)
2424 pvr2_trace(PVR2_TRACE_FIRMWARE, 2414 pvr2_trace(PVR2_TRACE_FIRMWARE,
2425 "Cleaning up after CPU firmware fetch"); 2415 "Cleaning up after CPU firmware fetch");
2426 kfree(hdw->fw_buffer); 2416 kfree(hdw->fw_buffer);
2427 hdw->fw_buffer = 0; 2417 hdw->fw_buffer = NULL;
2428 hdw->fw_size = 0; 2418 hdw->fw_size = 0;
2429 /* Now release the CPU. It will disconnect and 2419 /* Now release the CPU. It will disconnect and
2430 reconnect later. */ 2420 reconnect later. */
@@ -2519,22 +2509,6 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *hdw,int v)
2519} 2509}
2520 2510
2521 2511
2522void pvr2_reset_ctl_endpoints(struct pvr2_hdw *hdw)
2523{
2524 if (!hdw->usb_dev) return;
2525 usb_settoggle(hdw->usb_dev, PVR2_CTL_WRITE_ENDPOINT & 0xf,
2526 !(PVR2_CTL_WRITE_ENDPOINT & USB_DIR_IN), 0);
2527 usb_settoggle(hdw->usb_dev, PVR2_CTL_READ_ENDPOINT & 0xf,
2528 !(PVR2_CTL_READ_ENDPOINT & USB_DIR_IN), 0);
2529 usb_clear_halt(hdw->usb_dev,
2530 usb_rcvbulkpipe(hdw->usb_dev,
2531 PVR2_CTL_READ_ENDPOINT & 0x7f));
2532 usb_clear_halt(hdw->usb_dev,
2533 usb_sndbulkpipe(hdw->usb_dev,
2534 PVR2_CTL_WRITE_ENDPOINT & 0x7f));
2535}
2536
2537
2538static void pvr2_ctl_write_complete(struct urb *urb, struct pt_regs *regs) 2512static void pvr2_ctl_write_complete(struct urb *urb, struct pt_regs *regs)
2539{ 2513{
2540 struct pvr2_hdw *hdw = urb->context; 2514 struct pvr2_hdw *hdw = urb->context;
@@ -2568,10 +2542,10 @@ static void pvr2_ctl_timeout(unsigned long data)
2568} 2542}
2569 2543
2570 2544
2571int pvr2_send_request_ex(struct pvr2_hdw *hdw, 2545static int pvr2_send_request_ex(struct pvr2_hdw *hdw,
2572 unsigned int timeout,int probe_fl, 2546 unsigned int timeout,int probe_fl,
2573 void *write_data,unsigned int write_len, 2547 void *write_data,unsigned int write_len,
2574 void *read_data,unsigned int read_len) 2548 void *read_data,unsigned int read_len)
2575{ 2549{
2576 unsigned int idx; 2550 unsigned int idx;
2577 int status = 0; 2551 int status = 0;
@@ -2826,7 +2800,7 @@ int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data)
2826} 2800}
2827 2801
2828 2802
2829int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data) 2803static int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
2830{ 2804{
2831 int ret = 0; 2805 int ret = 0;
2832 2806
@@ -2850,7 +2824,7 @@ int pvr2_read_register(struct pvr2_hdw *hdw, u16 reg, u32 *data)
2850} 2824}
2851 2825
2852 2826
2853int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res) 2827static int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
2854{ 2828{
2855 int ret; 2829 int ret;
2856 2830
@@ -2867,7 +2841,7 @@ int pvr2_write_u16(struct pvr2_hdw *hdw, u16 data, int res)
2867} 2841}
2868 2842
2869 2843
2870int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res) 2844static int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
2871{ 2845{
2872 int ret; 2846 int ret;
2873 2847
@@ -2883,13 +2857,13 @@ int pvr2_write_u8(struct pvr2_hdw *hdw, u8 data, int res)
2883} 2857}
2884 2858
2885 2859
2886void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw) 2860static void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *hdw)
2887{ 2861{
2888 if (!hdw->flag_ok) return; 2862 if (!hdw->flag_ok) return;
2889 pvr2_trace(PVR2_TRACE_INIT,"render_useless"); 2863 pvr2_trace(PVR2_TRACE_INIT,"render_useless");
2890 hdw->flag_ok = 0; 2864 hdw->flag_ok = 0;
2891 if (hdw->vid_stream) { 2865 if (hdw->vid_stream) {
2892 pvr2_stream_setup(hdw->vid_stream,0,0,0); 2866 pvr2_stream_setup(hdw->vid_stream,NULL,0,0);
2893 } 2867 }
2894 hdw->flag_streaming_enabled = 0; 2868 hdw->flag_streaming_enabled = 0;
2895 hdw->subsys_enabled_mask = 0; 2869 hdw->subsys_enabled_mask = 0;
@@ -2908,7 +2882,7 @@ void pvr2_hdw_device_reset(struct pvr2_hdw *hdw)
2908{ 2882{
2909 int ret; 2883 int ret;
2910 pvr2_trace(PVR2_TRACE_INIT,"Performing a device reset..."); 2884 pvr2_trace(PVR2_TRACE_INIT,"Performing a device reset...");
2911 ret = usb_lock_device_for_reset(hdw->usb_dev,0); 2885 ret = usb_lock_device_for_reset(hdw->usb_dev,NULL);
2912 if (ret == 1) { 2886 if (ret == 1) {
2913 ret = usb_reset_device(hdw->usb_dev); 2887 ret = usb_reset_device(hdw->usb_dev);
2914 usb_unlock_device(hdw->usb_dev); 2888 usb_unlock_device(hdw->usb_dev);
@@ -2957,7 +2931,7 @@ int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *hdw)
2957 pvr2_trace(PVR2_TRACE_INIT,"Requesting uproc hard reset"); 2931 pvr2_trace(PVR2_TRACE_INIT,"Requesting uproc hard reset");
2958 hdw->flag_ok = !0; 2932 hdw->flag_ok = !0;
2959 hdw->cmd_buffer[0] = 0xdd; 2933 hdw->cmd_buffer[0] = 0xdd;
2960 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,0,0); 2934 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
2961 } while (0); LOCK_GIVE(hdw->ctl_lock); 2935 } while (0); LOCK_GIVE(hdw->ctl_lock);
2962 return status; 2936 return status;
2963} 2937}
@@ -2969,7 +2943,7 @@ int pvr2_hdw_cmd_powerup(struct pvr2_hdw *hdw)
2969 LOCK_TAKE(hdw->ctl_lock); do { 2943 LOCK_TAKE(hdw->ctl_lock); do {
2970 pvr2_trace(PVR2_TRACE_INIT,"Requesting powerup"); 2944 pvr2_trace(PVR2_TRACE_INIT,"Requesting powerup");
2971 hdw->cmd_buffer[0] = 0xde; 2945 hdw->cmd_buffer[0] = 0xde;
2972 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,0,0); 2946 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
2973 } while (0); LOCK_GIVE(hdw->ctl_lock); 2947 } while (0); LOCK_GIVE(hdw->ctl_lock);
2974 return status; 2948 return status;
2975} 2949}
@@ -2996,12 +2970,12 @@ int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *hdw)
2996} 2970}
2997 2971
2998 2972
2999int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl) 2973static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl)
3000{ 2974{
3001 int status; 2975 int status;
3002 LOCK_TAKE(hdw->ctl_lock); do { 2976 LOCK_TAKE(hdw->ctl_lock); do {
3003 hdw->cmd_buffer[0] = (runFl ? 0x36 : 0x37); 2977 hdw->cmd_buffer[0] = (runFl ? 0x36 : 0x37);
3004 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,0,0); 2978 status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0);
3005 } while (0); LOCK_GIVE(hdw->ctl_lock); 2979 } while (0); LOCK_GIVE(hdw->ctl_lock);
3006 if (!status) { 2980 if (!status) {
3007 hdw->subsys_enabled_mask = 2981 hdw->subsys_enabled_mask =
@@ -3094,7 +3068,7 @@ int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val)
3094} 3068}
3095 3069
3096 3070
3097int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw) 3071static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
3098{ 3072{
3099 int result; 3073 int result;
3100 LOCK_TAKE(hdw->ctl_lock); do { 3074 LOCK_TAKE(hdw->ctl_lock); do {
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index 63f529154431..fd931b5da490 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -91,7 +91,6 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
91void pvr2_hdw_poll(struct pvr2_hdw *); 91void pvr2_hdw_poll(struct pvr2_hdw *);
92 92
93/* Trigger a poll to take place later at a convenient time */ 93/* Trigger a poll to take place later at a convenient time */
94void pvr2_hdw_poll_trigger(struct pvr2_hdw *);
95void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *); 94void pvr2_hdw_poll_trigger_unlocked(struct pvr2_hdw *);
96 95
97/* Register a callback used to trigger a future poll */ 96/* Register a callback used to trigger a future poll */
@@ -99,9 +98,6 @@ void pvr2_hdw_setup_poll_trigger(struct pvr2_hdw *,
99 void (*func)(void *), 98 void (*func)(void *),
100 void *data); 99 void *data);
101 100
102/* Get pointer to structure given unit number */
103struct pvr2_hdw *pvr2_hdw_find(int unit_number);
104
105/* Destroy hardware interaction structure */ 101/* Destroy hardware interaction structure */
106void pvr2_hdw_destroy(struct pvr2_hdw *); 102void pvr2_hdw_destroy(struct pvr2_hdw *);
107 103
@@ -180,12 +176,6 @@ int pvr2_hdw_get_stdenum_value(struct pvr2_hdw *hdw,struct v4l2_standard *std,
180void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw, 176void pvr2_hdw_subsys_bit_chg(struct pvr2_hdw *hdw,
181 unsigned long msk,unsigned long val); 177 unsigned long msk,unsigned long val);
182 178
183/* Shortcut for pvr2_hdw_subsys_bit_chg(hdw,msk,msk) */
184void pvr2_hdw_subsys_bit_set(struct pvr2_hdw *hdw,unsigned long msk);
185
186/* Shortcut for pvr2_hdw_subsys_bit_chg(hdw,msk,0) */
187void pvr2_hdw_subsys_bit_clr(struct pvr2_hdw *hdw,unsigned long msk);
188
189/* Retrieve mask indicating which pieces of hardware are currently enabled 179/* Retrieve mask indicating which pieces of hardware are currently enabled
190 / configured. */ 180 / configured. */
191unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *); 181unsigned long pvr2_hdw_subsys_get(struct pvr2_hdw *);
@@ -225,34 +215,18 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int);
225/* The following entry points are all lower level things you normally don't 215/* The following entry points are all lower level things you normally don't
226 want to worry about. */ 216 want to worry about. */
227 217
228/* Attempt to recover from a USB foul-up (in practice I find that if you
229 have to do this, then it's already too late). */
230void pvr2_reset_ctl_endpoints(struct pvr2_hdw *hdw);
231
232/* Issue a command and get a response from the device. LOTS of higher 218/* Issue a command and get a response from the device. LOTS of higher
233 level stuff is built on this. */ 219 level stuff is built on this. */
234int pvr2_send_request(struct pvr2_hdw *, 220int pvr2_send_request(struct pvr2_hdw *,
235 void *write_ptr,unsigned int write_len, 221 void *write_ptr,unsigned int write_len,
236 void *read_ptr,unsigned int read_len); 222 void *read_ptr,unsigned int read_len);
237 223
238/* Issue a command and get a response from the device. This extended
239 version includes a probe flag (which if set means that device errors
240 should not be logged or treated as fatal) and a timeout in jiffies.
241 This can be used to non-lethally probe the health of endpoint 1. */
242int pvr2_send_request_ex(struct pvr2_hdw *,unsigned int timeout,int probe_fl,
243 void *write_ptr,unsigned int write_len,
244 void *read_ptr,unsigned int read_len);
245
246/* Slightly higher level device communication functions. */ 224/* Slightly higher level device communication functions. */
247int pvr2_write_register(struct pvr2_hdw *, u16, u32); 225int pvr2_write_register(struct pvr2_hdw *, u16, u32);
248int pvr2_read_register(struct pvr2_hdw *, u16, u32 *);
249int pvr2_write_u16(struct pvr2_hdw *, u16, int);
250int pvr2_write_u8(struct pvr2_hdw *, u8, int);
251 226
252/* Call if for any reason we can't talk to the hardware anymore - this will 227/* Call if for any reason we can't talk to the hardware anymore - this will
253 cause the driver to stop flailing on the device. */ 228 cause the driver to stop flailing on the device. */
254void pvr2_hdw_render_useless(struct pvr2_hdw *); 229void pvr2_hdw_render_useless(struct pvr2_hdw *);
255void pvr2_hdw_render_useless_unlocked(struct pvr2_hdw *);
256 230
257/* Set / clear 8051's reset bit */ 231/* Set / clear 8051's reset bit */
258void pvr2_hdw_cpureset_assert(struct pvr2_hdw *,int); 232void pvr2_hdw_cpureset_assert(struct pvr2_hdw *,int);
@@ -271,12 +245,6 @@ int pvr2_hdw_cmd_powerup(struct pvr2_hdw *);
271/* Order decoder to reset */ 245/* Order decoder to reset */
272int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *); 246int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *);
273 247
274/* Stop / start video stream transport */
275int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl);
276
277/* Find I2C address of eeprom */
278int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *);
279
280/* Direct manipulation of GPIO bits */ 248/* Direct manipulation of GPIO bits */
281int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *); 249int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *);
282int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *); 250int pvr2_hdw_gpio_get_out(struct pvr2_hdw *hdw,u32 *);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
index 1dd4f6249b99..fbe6039aeb6a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-chips-v4l2.c
@@ -25,7 +25,6 @@
25#include "pvrusb2-i2c-cmd-v4l2.h" 25#include "pvrusb2-i2c-cmd-v4l2.h"
26#include "pvrusb2-audio.h" 26#include "pvrusb2-audio.h"
27#include "pvrusb2-tuner.h" 27#include "pvrusb2-tuner.h"
28#include "pvrusb2-demod.h"
29#include "pvrusb2-video-v4l.h" 28#include "pvrusb2-video-v4l.h"
30#ifdef CONFIG_VIDEO_PVRUSB2_24XXX 29#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
31#include "pvrusb2-cx2584x-v4l.h" 30#include "pvrusb2-cx2584x-v4l.h"
@@ -89,11 +88,6 @@ void pvr2_i2c_probe(struct pvr2_hdw *hdw,struct pvr2_i2c_client *cp)
89 return; 88 return;
90 } 89 }
91 } 90 }
92 if (id == I2C_DRIVERID_TDA9887) {
93 if (pvr2_i2c_demod_setup(hdw,cp)) {
94 return;
95 }
96 }
97} 91}
98 92
99 93
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
index 9f81aff2b38a..8a9933dec912 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-cmd-v4l2.c
@@ -196,7 +196,7 @@ const struct pvr2_i2c_op pvr2_i2c_op_v4l2_size = {
196static void do_log(struct pvr2_hdw *hdw) 196static void do_log(struct pvr2_hdw *hdw)
197{ 197{
198 pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 do_log()"); 198 pvr2_trace(PVR2_TRACE_CHIPS,"i2c v4l2 do_log()");
199 pvr2_i2c_core_cmd(hdw,VIDIOC_LOG_STATUS,0); 199 pvr2_i2c_core_cmd(hdw,VIDIOC_LOG_STATUS,NULL);
200 200
201} 201}
202 202
@@ -217,7 +217,7 @@ const struct pvr2_i2c_op pvr2_i2c_op_v4l2_log = {
217void pvr2_v4l2_cmd_stream(struct pvr2_i2c_client *cp,int fl) 217void pvr2_v4l2_cmd_stream(struct pvr2_i2c_client *cp,int fl)
218{ 218{
219 pvr2_i2c_client_cmd(cp, 219 pvr2_i2c_client_cmd(cp,
220 (fl ? VIDIOC_STREAMON : VIDIOC_STREAMOFF),0); 220 (fl ? VIDIOC_STREAMON : VIDIOC_STREAMOFF),NULL);
221} 221}
222 222
223 223
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
index c8d0bdee3ff1..7fca47982277 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c
@@ -37,6 +37,10 @@ static unsigned int i2c_scan = 0;
37module_param(i2c_scan, int, S_IRUGO|S_IWUSR); 37module_param(i2c_scan, int, S_IRUGO|S_IWUSR);
38MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); 38MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
39 39
40static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp,
41 unsigned int detail,
42 char *buf,unsigned int maxlen);
43
40static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */ 44static int pvr2_i2c_write(struct pvr2_hdw *hdw, /* Context */
41 u8 i2c_addr, /* I2C address we're talking to */ 45 u8 i2c_addr, /* I2C address we're talking to */
42 u8 *data, /* Data to write */ 46 u8 *data, /* Data to write */
@@ -165,12 +169,12 @@ static int pvr2_i2c_read(struct pvr2_hdw *hdw, /* Context */
165 169
166/* This is the common low level entry point for doing I2C operations to the 170/* This is the common low level entry point for doing I2C operations to the
167 hardware. */ 171 hardware. */
168int pvr2_i2c_basic_op(struct pvr2_hdw *hdw, 172static int pvr2_i2c_basic_op(struct pvr2_hdw *hdw,
169 u8 i2c_addr, 173 u8 i2c_addr,
170 u8 *wdata, 174 u8 *wdata,
171 u16 wlen, 175 u16 wlen,
172 u8 *rdata, 176 u8 *rdata,
173 u16 rlen) 177 u16 rlen)
174{ 178{
175 if (!rdata) rlen = 0; 179 if (!rdata) rlen = 0;
176 if (!wdata) wlen = 0; 180 if (!wdata) wlen = 0;
@@ -267,7 +271,7 @@ static int i2c_hack_cx25840(struct pvr2_hdw *hdw,
267 "WARNING: Disabling further access to the device" 271 "WARNING: Disabling further access to the device"
268 " to prevent other foul-ups."); 272 " to prevent other foul-ups.");
269 // This blocks all further communication with the part. 273 // This blocks all further communication with the part.
270 hdw->i2c_func[0x44] = 0; 274 hdw->i2c_func[0x44] = NULL;
271 pvr2_hdw_render_useless(hdw); 275 pvr2_hdw_render_useless(hdw);
272 goto fail; 276 goto fail;
273 } 277 }
@@ -294,7 +298,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
294 int num) 298 int num)
295{ 299{
296 int ret = -ENOTSUPP; 300 int ret = -ENOTSUPP;
297 pvr2_i2c_func funcp = 0; 301 pvr2_i2c_func funcp = NULL;
298 struct pvr2_hdw *hdw = (struct pvr2_hdw *)(i2c_adap->algo_data); 302 struct pvr2_hdw *hdw = (struct pvr2_hdw *)(i2c_adap->algo_data);
299 303
300 if (!num) { 304 if (!num) {
@@ -319,7 +323,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
319 u16 tcnt,bcnt,offs; 323 u16 tcnt,bcnt,offs;
320 if (!msgs[0].len) { 324 if (!msgs[0].len) {
321 /* Length == 0 read. This is a probe. */ 325 /* Length == 0 read. This is a probe. */
322 if (funcp(hdw,msgs[0].addr,0,0,0,0)) { 326 if (funcp(hdw,msgs[0].addr,NULL,0,NULL,0)) {
323 ret = -EIO; 327 ret = -EIO;
324 goto done; 328 goto done;
325 } 329 }
@@ -336,7 +340,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
336 if (bcnt > sizeof(hdw->cmd_buffer)-1) { 340 if (bcnt > sizeof(hdw->cmd_buffer)-1) {
337 bcnt = sizeof(hdw->cmd_buffer)-1; 341 bcnt = sizeof(hdw->cmd_buffer)-1;
338 } 342 }
339 if (funcp(hdw,msgs[0].addr,0,0, 343 if (funcp(hdw,msgs[0].addr,NULL,0,
340 msgs[0].buf+offs,bcnt)) { 344 msgs[0].buf+offs,bcnt)) {
341 ret = -EIO; 345 ret = -EIO;
342 goto done; 346 goto done;
@@ -350,7 +354,7 @@ static int pvr2_i2c_xfer(struct i2c_adapter *i2c_adap,
350 /* Simple write */ 354 /* Simple write */
351 ret = 1; 355 ret = 1;
352 if (funcp(hdw,msgs[0].addr, 356 if (funcp(hdw,msgs[0].addr,
353 msgs[0].buf,msgs[0].len,0,0)) { 357 msgs[0].buf,msgs[0].len,NULL,0)) {
354 ret = -EIO; 358 ret = -EIO;
355 } 359 }
356 goto done; 360 goto done;
@@ -705,9 +709,9 @@ int pvr2_i2c_core_check_stale(struct pvr2_hdw *hdw)
705 return (hdw->i2c_pend_types & PVR2_I2C_PEND_ALL) != 0; 709 return (hdw->i2c_pend_types & PVR2_I2C_PEND_ALL) != 0;
706} 710}
707 711
708unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp, 712static unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *cp,
709 unsigned int detail, 713 unsigned int detail,
710 char *buf,unsigned int maxlen) 714 char *buf,unsigned int maxlen)
711{ 715{
712 unsigned int ccnt,bcnt; 716 unsigned int ccnt,bcnt;
713 int spcfl = 0; 717 int spcfl = 0;
@@ -871,7 +875,7 @@ static void do_i2c_scan(struct pvr2_hdw *hdw)
871 msg[0].addr = 0; 875 msg[0].addr = 0;
872 msg[0].flags = I2C_M_RD; 876 msg[0].flags = I2C_M_RD;
873 msg[0].len = 0; 877 msg[0].len = 0;
874 msg[0].buf = 0; 878 msg[0].buf = NULL;
875 printk("%s: i2c scan beginning\n",hdw->name); 879 printk("%s: i2c scan beginning\n",hdw->name);
876 for (i = 0; i < 128; i++) { 880 for (i = 0; i < 128; i++) {
877 msg[0].addr = i; 881 msg[0].addr = i;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h
index e8af5b0ed3ce..6d7e25247576 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.h
@@ -75,9 +75,6 @@ unsigned int pvr2_i2c_report(struct pvr2_hdw *,char *buf,unsigned int maxlen);
75 PVR2_I2C_DETAIL_DEBUG |\ 75 PVR2_I2C_DETAIL_DEBUG |\
76 PVR2_I2C_DETAIL_HANDLER |\ 76 PVR2_I2C_DETAIL_HANDLER |\
77 PVR2_I2C_DETAIL_CTLMASK) 77 PVR2_I2C_DETAIL_CTLMASK)
78unsigned int pvr2_i2c_client_describe(struct pvr2_i2c_client *,
79 unsigned int detail_mask,
80 char *buf,unsigned int maxlen);
81 78
82void pvr2_i2c_probe(struct pvr2_hdw *,struct pvr2_i2c_client *); 79void pvr2_i2c_probe(struct pvr2_hdw *,struct pvr2_i2c_client *);
83const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx); 80const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.c b/drivers/media/video/pvrusb2/pvrusb2-io.c
index a984c91f571c..681f79c8064e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-io.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-io.c
@@ -93,7 +93,7 @@ struct pvr2_buffer {
93 struct urb *purb; 93 struct urb *purb;
94}; 94};
95 95
96const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st) 96static const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st)
97{ 97{
98 switch (st) { 98 switch (st) {
99 case pvr2_buffer_state_none: return "none"; 99 case pvr2_buffer_state_none: return "none";
@@ -104,7 +104,8 @@ const char *pvr2_buffer_state_decode(enum pvr2_buffer_state st)
104 return "unknown"; 104 return "unknown";
105} 105}
106 106
107void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg) 107#ifdef SANITY_CHECK_BUFFERS
108static void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg)
108{ 109{
109 pvr2_trace(PVR2_TRACE_INFO, 110 pvr2_trace(PVR2_TRACE_INFO,
110 "buffer%s%s %p state=%s id=%d status=%d" 111 "buffer%s%s %p state=%s id=%d status=%d"
@@ -115,10 +116,11 @@ void pvr2_buffer_describe(struct pvr2_buffer *bp,const char *msg)
115 (bp ? pvr2_buffer_state_decode(bp->state) : "(invalid)"), 116 (bp ? pvr2_buffer_state_decode(bp->state) : "(invalid)"),
116 (bp ? bp->id : 0), 117 (bp ? bp->id : 0),
117 (bp ? bp->status : 0), 118 (bp ? bp->status : 0),
118 (bp ? bp->stream : 0), 119 (bp ? bp->stream : NULL),
119 (bp ? bp->purb : 0), 120 (bp ? bp->purb : NULL),
120 (bp ? bp->signature : 0)); 121 (bp ? bp->signature : 0));
121} 122}
123#endif /* SANITY_CHECK_BUFFERS */
122 124
123static void pvr2_buffer_remove(struct pvr2_buffer *bp) 125static void pvr2_buffer_remove(struct pvr2_buffer *bp)
124{ 126{
@@ -284,7 +286,7 @@ static void pvr2_buffer_done(struct pvr2_buffer *bp)
284 pvr2_buffer_wipe(bp); 286 pvr2_buffer_wipe(bp);
285 pvr2_buffer_set_none(bp); 287 pvr2_buffer_set_none(bp);
286 bp->signature = 0; 288 bp->signature = 0;
287 bp->stream = 0; 289 bp->stream = NULL;
288 if (bp->purb) usb_free_urb(bp->purb); 290 if (bp->purb) usb_free_urb(bp->purb);
289 pvr2_trace(PVR2_TRACE_BUF_POOL,"/*---TRACE_FLOW---*/" 291 pvr2_trace(PVR2_TRACE_BUF_POOL,"/*---TRACE_FLOW---*/"
290 " bufferDone %p",bp); 292 " bufferDone %p",bp);
@@ -339,13 +341,13 @@ static int pvr2_stream_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
339 struct pvr2_buffer *bp; 341 struct pvr2_buffer *bp;
340 bp = sp->buffers[sp->buffer_total_count - 1]; 342 bp = sp->buffers[sp->buffer_total_count - 1];
341 /* Paranoia */ 343 /* Paranoia */
342 sp->buffers[sp->buffer_total_count - 1] = 0; 344 sp->buffers[sp->buffer_total_count - 1] = NULL;
343 (sp->buffer_total_count)--; 345 (sp->buffer_total_count)--;
344 pvr2_buffer_done(bp); 346 pvr2_buffer_done(bp);
345 kfree(bp); 347 kfree(bp);
346 } 348 }
347 if (scnt < sp->buffer_slot_count) { 349 if (scnt < sp->buffer_slot_count) {
348 struct pvr2_buffer **nb = 0; 350 struct pvr2_buffer **nb = NULL;
349 if (scnt) { 351 if (scnt) {
350 nb = kmalloc(scnt * sizeof(*nb),GFP_KERNEL); 352 nb = kmalloc(scnt * sizeof(*nb),GFP_KERNEL);
351 if (!nb) return -ENOMEM; 353 if (!nb) return -ENOMEM;
@@ -513,10 +515,6 @@ void pvr2_stream_set_callback(struct pvr2_stream *sp,
513} 515}
514 516
515/* Query / set the nominal buffer count */ 517/* Query / set the nominal buffer count */
516int pvr2_stream_get_buffer_count(struct pvr2_stream *sp)
517{
518 return sp->buffer_target_count;
519}
520 518
521int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt) 519int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
522{ 520{
@@ -532,21 +530,21 @@ int pvr2_stream_set_buffer_count(struct pvr2_stream *sp,unsigned int cnt)
532struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *sp) 530struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *sp)
533{ 531{
534 struct list_head *lp = sp->idle_list.next; 532 struct list_head *lp = sp->idle_list.next;
535 if (lp == &sp->idle_list) return 0; 533 if (lp == &sp->idle_list) return NULL;
536 return list_entry(lp,struct pvr2_buffer,list_overhead); 534 return list_entry(lp,struct pvr2_buffer,list_overhead);
537} 535}
538 536
539struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *sp) 537struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *sp)
540{ 538{
541 struct list_head *lp = sp->ready_list.next; 539 struct list_head *lp = sp->ready_list.next;
542 if (lp == &sp->ready_list) return 0; 540 if (lp == &sp->ready_list) return NULL;
543 return list_entry(lp,struct pvr2_buffer,list_overhead); 541 return list_entry(lp,struct pvr2_buffer,list_overhead);
544} 542}
545 543
546struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id) 544struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id)
547{ 545{
548 if (id < 0) return 0; 546 if (id < 0) return NULL;
549 if (id >= sp->buffer_total_count) return 0; 547 if (id >= sp->buffer_total_count) return NULL;
550 return sp->buffers[id]; 548 return sp->buffers[id];
551} 549}
552 550
@@ -555,17 +553,6 @@ int pvr2_stream_get_ready_count(struct pvr2_stream *sp)
555 return sp->r_count; 553 return sp->r_count;
556} 554}
557 555
558int pvr2_stream_get_idle_count(struct pvr2_stream *sp)
559{
560 return sp->i_count;
561}
562
563void pvr2_stream_flush(struct pvr2_stream *sp)
564{
565 mutex_lock(&sp->mutex); do {
566 pvr2_stream_internal_flush(sp);
567 } while(0); mutex_unlock(&sp->mutex);
568}
569 556
570void pvr2_stream_kill(struct pvr2_stream *sp) 557void pvr2_stream_kill(struct pvr2_stream *sp)
571{ 558{
@@ -620,20 +607,6 @@ int pvr2_buffer_queue(struct pvr2_buffer *bp)
620 return ret; 607 return ret;
621} 608}
622 609
623int pvr2_buffer_idle(struct pvr2_buffer *bp)
624{
625 struct pvr2_stream *sp;
626 if (!bp) return -EINVAL;
627 sp = bp->stream;
628 mutex_lock(&sp->mutex); do {
629 pvr2_buffer_wipe(bp);
630 pvr2_buffer_set_idle(bp);
631 if (sp->buffer_total_count != sp->buffer_target_count) {
632 pvr2_stream_achieve_buffer_count(sp);
633 }
634 } while(0); mutex_unlock(&sp->mutex);
635 return 0;
636}
637 610
638int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt) 611int pvr2_buffer_set_buffer(struct pvr2_buffer *bp,void *ptr,unsigned int cnt)
639{ 612{
@@ -673,10 +646,6 @@ int pvr2_buffer_get_status(struct pvr2_buffer *bp)
673 return bp->status; 646 return bp->status;
674} 647}
675 648
676enum pvr2_buffer_state pvr2_buffer_get_state(struct pvr2_buffer *bp)
677{
678 return bp->state;
679}
680 649
681int pvr2_buffer_get_id(struct pvr2_buffer *bp) 650int pvr2_buffer_get_id(struct pvr2_buffer *bp)
682{ 651{
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.h b/drivers/media/video/pvrusb2/pvrusb2-io.h
index 65e11385b2b3..96285ad234a6 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-io.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-io.h
@@ -36,8 +36,6 @@ enum pvr2_buffer_state {
36struct pvr2_stream; 36struct pvr2_stream;
37struct pvr2_buffer; 37struct pvr2_buffer;
38 38
39const char *pvr2_buffer_state_decode(enum pvr2_buffer_state);
40
41/* Initialize / tear down stream structure */ 39/* Initialize / tear down stream structure */
42struct pvr2_stream *pvr2_stream_create(void); 40struct pvr2_stream *pvr2_stream_create(void);
43void pvr2_stream_destroy(struct pvr2_stream *); 41void pvr2_stream_destroy(struct pvr2_stream *);
@@ -49,7 +47,6 @@ void pvr2_stream_set_callback(struct pvr2_stream *,
49 void *data); 47 void *data);
50 48
51/* Query / set the nominal buffer count */ 49/* Query / set the nominal buffer count */
52int pvr2_stream_get_buffer_count(struct pvr2_stream *);
53int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int); 50int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int);
54 51
55/* Get a pointer to a buffer that is either idle, ready, or is specified 52/* Get a pointer to a buffer that is either idle, ready, or is specified
@@ -59,12 +56,8 @@ struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *);
59struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id); 56struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id);
60 57
61/* Find out how many buffers are idle or ready */ 58/* Find out how many buffers are idle or ready */
62int pvr2_stream_get_idle_count(struct pvr2_stream *);
63int pvr2_stream_get_ready_count(struct pvr2_stream *); 59int pvr2_stream_get_ready_count(struct pvr2_stream *);
64 60
65/* Kill all pending operations */
66void pvr2_stream_flush(struct pvr2_stream *);
67
68/* Kill all pending buffers and throw away any ready buffers as well */ 61/* Kill all pending buffers and throw away any ready buffers as well */
69void pvr2_stream_kill(struct pvr2_stream *); 62void pvr2_stream_kill(struct pvr2_stream *);
70 63
@@ -77,18 +70,12 @@ unsigned int pvr2_buffer_get_count(struct pvr2_buffer *);
77/* Retrieve completion code for given ready buffer */ 70/* Retrieve completion code for given ready buffer */
78int pvr2_buffer_get_status(struct pvr2_buffer *); 71int pvr2_buffer_get_status(struct pvr2_buffer *);
79 72
80/* Retrieve state of given buffer */
81enum pvr2_buffer_state pvr2_buffer_get_state(struct pvr2_buffer *);
82
83/* Retrieve ID of given buffer */ 73/* Retrieve ID of given buffer */
84int pvr2_buffer_get_id(struct pvr2_buffer *); 74int pvr2_buffer_get_id(struct pvr2_buffer *);
85 75
86/* Start reading into given buffer (kill it if needed) */ 76/* Start reading into given buffer (kill it if needed) */
87int pvr2_buffer_queue(struct pvr2_buffer *); 77int pvr2_buffer_queue(struct pvr2_buffer *);
88 78
89/* Move buffer back to idle pool (kill it if needed) */
90int pvr2_buffer_idle(struct pvr2_buffer *);
91
92#endif /* __PVRUSB2_IO_H */ 79#endif /* __PVRUSB2_IO_H */
93 80
94/* 81/*
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ioread.c b/drivers/media/video/pvrusb2/pvrusb2-ioread.c
index 49da062e3271..f7a2e225a002 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ioread.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-ioread.c
@@ -54,7 +54,7 @@ static int pvr2_ioread_init(struct pvr2_ioread *cp)
54{ 54{
55 unsigned int idx; 55 unsigned int idx;
56 56
57 cp->stream = 0; 57 cp->stream = NULL;
58 mutex_init(&cp->mutex); 58 mutex_init(&cp->mutex);
59 59
60 for (idx = 0; idx < BUFFER_COUNT; idx++) { 60 for (idx = 0; idx < BUFFER_COUNT; idx++) {
@@ -77,7 +77,7 @@ static void pvr2_ioread_done(struct pvr2_ioread *cp)
77{ 77{
78 unsigned int idx; 78 unsigned int idx;
79 79
80 pvr2_ioread_setup(cp,0); 80 pvr2_ioread_setup(cp,NULL);
81 for (idx = 0; idx < BUFFER_COUNT; idx++) { 81 for (idx = 0; idx < BUFFER_COUNT; idx++) {
82 if (!(cp->buffer_storage[idx])) continue; 82 if (!(cp->buffer_storage[idx])) continue;
83 kfree(cp->buffer_storage[idx]); 83 kfree(cp->buffer_storage[idx]);
@@ -88,12 +88,12 @@ struct pvr2_ioread *pvr2_ioread_create(void)
88{ 88{
89 struct pvr2_ioread *cp; 89 struct pvr2_ioread *cp;
90 cp = kmalloc(sizeof(*cp),GFP_KERNEL); 90 cp = kmalloc(sizeof(*cp),GFP_KERNEL);
91 if (!cp) return 0; 91 if (!cp) return NULL;
92 pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_create id=%p",cp); 92 pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_create id=%p",cp);
93 memset(cp,0,sizeof(*cp)); 93 memset(cp,0,sizeof(*cp));
94 if (pvr2_ioread_init(cp) < 0) { 94 if (pvr2_ioread_init(cp) < 0) {
95 kfree(cp); 95 kfree(cp);
96 return 0; 96 return NULL;
97 } 97 }
98 return cp; 98 return cp;
99} 99}
@@ -105,7 +105,7 @@ void pvr2_ioread_destroy(struct pvr2_ioread *cp)
105 pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_destroy id=%p",cp); 105 pvr2_trace(PVR2_TRACE_STRUCT,"pvr2_ioread_destroy id=%p",cp);
106 if (cp->sync_key_ptr) { 106 if (cp->sync_key_ptr) {
107 kfree(cp->sync_key_ptr); 107 kfree(cp->sync_key_ptr);
108 cp->sync_key_ptr = 0; 108 cp->sync_key_ptr = NULL;
109 } 109 }
110 kfree(cp); 110 kfree(cp);
111} 111}
@@ -124,7 +124,7 @@ void pvr2_ioread_set_sync_key(struct pvr2_ioread *cp,
124 if (sync_key_len != cp->sync_key_len) { 124 if (sync_key_len != cp->sync_key_len) {
125 if (cp->sync_key_ptr) { 125 if (cp->sync_key_ptr) {
126 kfree(cp->sync_key_ptr); 126 kfree(cp->sync_key_ptr);
127 cp->sync_key_ptr = 0; 127 cp->sync_key_ptr = NULL;
128 } 128 }
129 cp->sync_key_len = 0; 129 cp->sync_key_len = 0;
130 if (sync_key_len) { 130 if (sync_key_len) {
@@ -144,8 +144,8 @@ static void pvr2_ioread_stop(struct pvr2_ioread *cp)
144 pvr2_trace(PVR2_TRACE_START_STOP, 144 pvr2_trace(PVR2_TRACE_START_STOP,
145 "/*---TRACE_READ---*/ pvr2_ioread_stop id=%p",cp); 145 "/*---TRACE_READ---*/ pvr2_ioread_stop id=%p",cp);
146 pvr2_stream_kill(cp->stream); 146 pvr2_stream_kill(cp->stream);
147 cp->c_buf = 0; 147 cp->c_buf = NULL;
148 cp->c_data_ptr = 0; 148 cp->c_data_ptr = NULL;
149 cp->c_data_len = 0; 149 cp->c_data_len = 0;
150 cp->c_data_offs = 0; 150 cp->c_data_offs = 0;
151 cp->enabled = 0; 151 cp->enabled = 0;
@@ -179,8 +179,8 @@ static int pvr2_ioread_start(struct pvr2_ioread *cp)
179 } 179 }
180 } 180 }
181 cp->enabled = !0; 181 cp->enabled = !0;
182 cp->c_buf = 0; 182 cp->c_buf = NULL;
183 cp->c_data_ptr = 0; 183 cp->c_data_ptr = NULL;
184 cp->c_data_len = 0; 184 cp->c_data_len = 0;
185 cp->c_data_offs = 0; 185 cp->c_data_offs = 0;
186 cp->stream_running = 0; 186 cp->stream_running = 0;
@@ -214,7 +214,7 @@ int pvr2_ioread_setup(struct pvr2_ioread *cp,struct pvr2_stream *sp)
214 pvr2_ioread_stop(cp); 214 pvr2_ioread_stop(cp);
215 pvr2_stream_kill(cp->stream); 215 pvr2_stream_kill(cp->stream);
216 pvr2_stream_set_buffer_count(cp->stream,0); 216 pvr2_stream_set_buffer_count(cp->stream,0);
217 cp->stream = 0; 217 cp->stream = NULL;
218 } 218 }
219 if (sp) { 219 if (sp) {
220 pvr2_trace(PVR2_TRACE_START_STOP, 220 pvr2_trace(PVR2_TRACE_START_STOP,
@@ -251,12 +251,8 @@ int pvr2_ioread_set_enabled(struct pvr2_ioread *cp,int fl)
251 return ret; 251 return ret;
252} 252}
253 253
254int pvr2_ioread_get_enabled(struct pvr2_ioread *cp)
255{
256 return cp->enabled != 0;
257}
258 254
259int pvr2_ioread_get_buffer(struct pvr2_ioread *cp) 255static int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
260{ 256{
261 int stat; 257 int stat;
262 258
@@ -274,8 +270,8 @@ int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
274 pvr2_ioread_stop(cp); 270 pvr2_ioread_stop(cp);
275 return 0; 271 return 0;
276 } 272 }
277 cp->c_buf = 0; 273 cp->c_buf = NULL;
278 cp->c_data_ptr = 0; 274 cp->c_data_ptr = NULL;
279 cp->c_data_len = 0; 275 cp->c_data_len = 0;
280 cp->c_data_offs = 0; 276 cp->c_data_offs = 0;
281 } 277 }
@@ -307,7 +303,7 @@ int pvr2_ioread_get_buffer(struct pvr2_ioread *cp)
307 return !0; 303 return !0;
308} 304}
309 305
310void pvr2_ioread_filter(struct pvr2_ioread *cp) 306static void pvr2_ioread_filter(struct pvr2_ioread *cp)
311{ 307{
312 unsigned int idx; 308 unsigned int idx;
313 if (!cp->enabled) return; 309 if (!cp->enabled) return;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ioread.h b/drivers/media/video/pvrusb2/pvrusb2-ioread.h
index 6b002597f5de..1d362f833588 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-ioread.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-ioread.h
@@ -33,7 +33,6 @@ void pvr2_ioread_set_sync_key(struct pvr2_ioread *,
33 const char *sync_key_ptr, 33 const char *sync_key_ptr,
34 unsigned int sync_key_len); 34 unsigned int sync_key_len);
35int pvr2_ioread_set_enabled(struct pvr2_ioread *,int fl); 35int pvr2_ioread_set_enabled(struct pvr2_ioread *,int fl);
36int pvr2_ioread_get_enabled(struct pvr2_ioread *);
37int pvr2_ioread_read(struct pvr2_ioread *,void __user *buf,unsigned int cnt); 36int pvr2_ioread_read(struct pvr2_ioread *,void __user *buf,unsigned int cnt);
38int pvr2_ioread_avail(struct pvr2_ioread *); 37int pvr2_ioread_avail(struct pvr2_ioread *);
39 38
diff --git a/drivers/media/video/pvrusb2/pvrusb2-main.c b/drivers/media/video/pvrusb2/pvrusb2-main.c
index b95248274ed0..8f1a5afdd34e 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-main.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-main.c
@@ -54,7 +54,7 @@ module_param_named(debug,pvrusb2_debug,int,S_IRUGO|S_IWUSR);
54MODULE_PARM_DESC(debug, "Debug trace mask"); 54MODULE_PARM_DESC(debug, "Debug trace mask");
55 55
56#ifdef CONFIG_VIDEO_PVRUSB2_SYSFS 56#ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
57static struct pvr2_sysfs_class *class_ptr = 0; 57static struct pvr2_sysfs_class *class_ptr = NULL;
58#endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */ 58#endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
59 59
60static void pvr_setup_attach(struct pvr2_context *pvr) 60static void pvr_setup_attach(struct pvr2_context *pvr)
@@ -104,10 +104,10 @@ static void pvr_disconnect(struct usb_interface *intf)
104} 104}
105 105
106static struct usb_driver pvr_driver = { 106static struct usb_driver pvr_driver = {
107 name: "pvrusb2", 107 .name = "pvrusb2",
108 id_table: pvr2_device_table, 108 .id_table = pvr2_device_table,
109 probe: pvr_probe, 109 .probe = pvr_probe,
110 disconnect: pvr_disconnect 110 .disconnect = pvr_disconnect
111}; 111};
112 112
113/* 113/*
diff --git a/drivers/media/video/pvrusb2/pvrusb2-std.c b/drivers/media/video/pvrusb2/pvrusb2-std.c
index 134063693643..f95c598ff627 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-std.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-std.c
@@ -121,7 +121,7 @@ static const struct std_name *find_std_name(const struct std_name *arrPtr,
121 if (strlen(p->name) != bufSize) continue; 121 if (strlen(p->name) != bufSize) continue;
122 if (!memcmp(bufPtr,p->name,bufSize)) return p; 122 if (!memcmp(bufPtr,p->name,bufSize)) return p;
123 } 123 }
124 return 0; 124 return NULL;
125} 125}
126 126
127 127
@@ -289,7 +289,7 @@ static struct v4l2_standard *match_std(v4l2_std_id id)
289 return generic_standards + idx; 289 return generic_standards + idx;
290 } 290 }
291 } 291 }
292 return 0; 292 return NULL;
293} 293}
294 294
295static int pvr2_std_fill(struct v4l2_standard *std,v4l2_std_id id) 295static int pvr2_std_fill(struct v4l2_standard *std,v4l2_std_id id)
@@ -364,7 +364,7 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr,
364 364
365 pvr2_trace(PVR2_TRACE_INIT,"Setting up %u unique standard(s)", 365 pvr2_trace(PVR2_TRACE_INIT,"Setting up %u unique standard(s)",
366 std_cnt); 366 std_cnt);
367 if (!std_cnt) return 0; // paranoia 367 if (!std_cnt) return NULL; // paranoia
368 368
369 stddefs = kmalloc(sizeof(struct v4l2_standard) * std_cnt, 369 stddefs = kmalloc(sizeof(struct v4l2_standard) * std_cnt,
370 GFP_KERNEL); 370 GFP_KERNEL);
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
index c6e6523d74b4..6af55a8b6f05 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c
@@ -504,7 +504,7 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id)
504 cip->cptr = cptr; 504 cip->cptr = cptr;
505 505
506 cip->chptr = sfp; 506 cip->chptr = sfp;
507 cip->item_next = 0; 507 cip->item_next = NULL;
508 if (sfp->item_last) { 508 if (sfp->item_last) {
509 sfp->item_last->item_next = cip; 509 sfp->item_last->item_next = cip;
510 } else { 510 } else {
@@ -625,7 +625,7 @@ static void pvr2_sysfs_tear_down_debugifc(struct pvr2_sysfs *sfp)
625 &sfp->debugifc->attr_debuginfo); 625 &sfp->debugifc->attr_debuginfo);
626 class_device_remove_file(sfp->class_dev,&sfp->debugifc->attr_debugcmd); 626 class_device_remove_file(sfp->class_dev,&sfp->debugifc->attr_debugcmd);
627 kfree(sfp->debugifc); 627 kfree(sfp->debugifc);
628 sfp->debugifc = 0; 628 sfp->debugifc = NULL;
629} 629}
630#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */ 630#endif /* CONFIG_VIDEO_PVRUSB2_DEBUGIFC */
631 631
@@ -678,9 +678,9 @@ static void class_dev_destroy(struct pvr2_sysfs *sfp)
678 class_device_remove_file(sfp->class_dev,&sfp->attr_v4l_minor_number); 678 class_device_remove_file(sfp->class_dev,&sfp->attr_v4l_minor_number);
679 class_device_remove_file(sfp->class_dev,&sfp->attr_unit_number); 679 class_device_remove_file(sfp->class_dev,&sfp->attr_unit_number);
680 pvr2_sysfs_trace("Destroying class_dev id=%p",sfp->class_dev); 680 pvr2_sysfs_trace("Destroying class_dev id=%p",sfp->class_dev);
681 sfp->class_dev->class_data = 0; 681 sfp->class_dev->class_data = NULL;
682 class_device_unregister(sfp->class_dev); 682 class_device_unregister(sfp->class_dev);
683 sfp->class_dev = 0; 683 sfp->class_dev = NULL;
684} 684}
685 685
686 686
@@ -739,13 +739,13 @@ static void class_dev_create(struct pvr2_sysfs *sfp,
739 sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number"; 739 sfp->attr_v4l_minor_number.attr.name = "v4l_minor_number";
740 sfp->attr_v4l_minor_number.attr.mode = S_IRUGO; 740 sfp->attr_v4l_minor_number.attr.mode = S_IRUGO;
741 sfp->attr_v4l_minor_number.show = v4l_minor_number_show; 741 sfp->attr_v4l_minor_number.show = v4l_minor_number_show;
742 sfp->attr_v4l_minor_number.store = 0; 742 sfp->attr_v4l_minor_number.store = NULL;
743 class_device_create_file(sfp->class_dev,&sfp->attr_v4l_minor_number); 743 class_device_create_file(sfp->class_dev,&sfp->attr_v4l_minor_number);
744 sfp->attr_unit_number.attr.owner = THIS_MODULE; 744 sfp->attr_unit_number.attr.owner = THIS_MODULE;
745 sfp->attr_unit_number.attr.name = "unit_number"; 745 sfp->attr_unit_number.attr.name = "unit_number";
746 sfp->attr_unit_number.attr.mode = S_IRUGO; 746 sfp->attr_unit_number.attr.mode = S_IRUGO;
747 sfp->attr_unit_number.show = unit_number_show; 747 sfp->attr_unit_number.show = unit_number_show;
748 sfp->attr_unit_number.store = 0; 748 sfp->attr_unit_number.store = NULL;
749 class_device_create_file(sfp->class_dev,&sfp->attr_unit_number); 749 class_device_create_file(sfp->class_dev,&sfp->attr_unit_number);
750 750
751 pvr2_sysfs_add_controls(sfp); 751 pvr2_sysfs_add_controls(sfp);
@@ -806,7 +806,7 @@ struct pvr2_sysfs_class *pvr2_sysfs_class_create(void)
806 pvr2_sysfs_trace( 806 pvr2_sysfs_trace(
807 "Registration failed for pvr2_sysfs_class id=%p",clp); 807 "Registration failed for pvr2_sysfs_class id=%p",clp);
808 kfree(clp); 808 kfree(clp);
809 clp = 0; 809 clp = NULL;
810 } 810 }
811 return clp; 811 return clp;
812} 812}
diff --git a/drivers/media/video/pvrusb2/pvrusb2-tuner.c b/drivers/media/video/pvrusb2/pvrusb2-tuner.c
index f4aba8144ce0..af9f246f8d3f 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-tuner.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-tuner.c
@@ -69,7 +69,7 @@ static void tuner_update(struct pvr2_tuner_handler *ctxt)
69 69
70static void pvr2_tuner_detach(struct pvr2_tuner_handler *ctxt) 70static void pvr2_tuner_detach(struct pvr2_tuner_handler *ctxt)
71{ 71{
72 ctxt->client->handler = 0; 72 ctxt->client->handler = NULL;
73 kfree(ctxt); 73 kfree(ctxt);
74} 74}
75 75
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 961951010c27..0caf70b8c0de 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -81,7 +81,7 @@ static int video_nr[PVR_NUM] = {[0 ... PVR_NUM-1] = -1};
81module_param_array(video_nr, int, NULL, 0444); 81module_param_array(video_nr, int, NULL, 0444);
82MODULE_PARM_DESC(video_nr, "Offset for device's minor"); 82MODULE_PARM_DESC(video_nr, "Offset for device's minor");
83 83
84struct v4l2_capability pvr_capability ={ 84static struct v4l2_capability pvr_capability ={
85 .driver = "pvrusb2", 85 .driver = "pvrusb2",
86 .card = "Hauppauge WinTV pvr-usb2", 86 .card = "Hauppauge WinTV pvr-usb2",
87 .bus_info = "usb", 87 .bus_info = "usb",
@@ -111,7 +111,7 @@ static struct v4l2_tuner pvr_v4l2_tuners[]= {
111 } 111 }
112}; 112};
113 113
114struct v4l2_fmtdesc pvr_fmtdesc [] = { 114static struct v4l2_fmtdesc pvr_fmtdesc [] = {
115 { 115 {
116 .index = 0, 116 .index = 0,
117 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, 117 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
@@ -127,7 +127,7 @@ struct v4l2_fmtdesc pvr_fmtdesc [] = {
127#define PVR_FORMAT_PIX 0 127#define PVR_FORMAT_PIX 0
128#define PVR_FORMAT_VBI 1 128#define PVR_FORMAT_VBI 1
129 129
130struct v4l2_format pvr_format [] = { 130static struct v4l2_format pvr_format [] = {
131 [PVR_FORMAT_PIX] = { 131 [PVR_FORMAT_PIX] = {
132 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, 132 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
133 .fmt = { 133 .fmt = {
@@ -701,9 +701,8 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
701 701
702static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip) 702static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
703{ 703{
704 pvr2_trace(PVR2_TRACE_INIT, 704 printk(KERN_INFO "pvrusb2: unregistering device video%d [%s]\n",
705 "unregistering device video%d [%s]", 705 dip->vdev->minor,pvr2_config_get_name(dip->config));
706 dip->vdev->minor,pvr2_config_get_name(dip->config));
707 if (dip->ctxt_idx >= 0) { 706 if (dip->ctxt_idx >= 0) {
708 mutex_lock(&device_lock); 707 mutex_lock(&device_lock);
709 devices[dip->ctxt_idx] = NULL; 708 devices[dip->ctxt_idx] = NULL;
@@ -725,7 +724,7 @@ static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp)
725} 724}
726 725
727 726
728void pvr2_v4l2_internal_check(struct pvr2_channel *chp) 727static void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
729{ 728{
730 struct pvr2_v4l2 *vp; 729 struct pvr2_v4l2 *vp;
731 vp = container_of(chp,struct pvr2_v4l2,channel); 730 vp = container_of(chp,struct pvr2_v4l2,channel);
@@ -735,8 +734,8 @@ void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
735} 734}
736 735
737 736
738int pvr2_v4l2_ioctl(struct inode *inode, struct file *file, 737static int pvr2_v4l2_ioctl(struct inode *inode, struct file *file,
739 unsigned int cmd, unsigned long arg) 738 unsigned int cmd, unsigned long arg)
740{ 739{
741 740
742/* Temporary hack : use ivtv api until a v4l2 one is available. */ 741/* Temporary hack : use ivtv api until a v4l2 one is available. */
@@ -747,7 +746,7 @@ int pvr2_v4l2_ioctl(struct inode *inode, struct file *file,
747} 746}
748 747
749 748
750int pvr2_v4l2_release(struct inode *inode, struct file *file) 749static int pvr2_v4l2_release(struct inode *inode, struct file *file)
751{ 750{
752 struct pvr2_v4l2_fh *fhp = file->private_data; 751 struct pvr2_v4l2_fh *fhp = file->private_data;
753 struct pvr2_v4l2 *vp = fhp->vhead; 752 struct pvr2_v4l2 *vp = fhp->vhead;
@@ -761,9 +760,9 @@ int pvr2_v4l2_release(struct inode *inode, struct file *file)
761 hdw = fhp->channel.mc_head->hdw; 760 hdw = fhp->channel.mc_head->hdw;
762 pvr2_hdw_set_streaming(hdw,0); 761 pvr2_hdw_set_streaming(hdw,0);
763 sp = pvr2_ioread_get_stream(fhp->rhp); 762 sp = pvr2_ioread_get_stream(fhp->rhp);
764 if (sp) pvr2_stream_set_callback(sp,0,0); 763 if (sp) pvr2_stream_set_callback(sp,NULL,NULL);
765 pvr2_ioread_destroy(fhp->rhp); 764 pvr2_ioread_destroy(fhp->rhp);
766 fhp->rhp = 0; 765 fhp->rhp = NULL;
767 } 766 }
768 v4l2_prio_close(&vp->prio, &fhp->prio); 767 v4l2_prio_close(&vp->prio, &fhp->prio);
769 file->private_data = NULL; 768 file->private_data = NULL;
@@ -779,9 +778,9 @@ int pvr2_v4l2_release(struct inode *inode, struct file *file)
779 } else { 778 } else {
780 vp->vfirst = fhp->vnext; 779 vp->vfirst = fhp->vnext;
781 } 780 }
782 fhp->vnext = 0; 781 fhp->vnext = NULL;
783 fhp->vprev = 0; 782 fhp->vprev = NULL;
784 fhp->vhead = 0; 783 fhp->vhead = NULL;
785 pvr2_channel_done(&fhp->channel); 784 pvr2_channel_done(&fhp->channel);
786 pvr2_trace(PVR2_TRACE_STRUCT, 785 pvr2_trace(PVR2_TRACE_STRUCT,
787 "Destroying pvr_v4l2_fh id=%p",fhp); 786 "Destroying pvr_v4l2_fh id=%p",fhp);
@@ -794,9 +793,9 @@ int pvr2_v4l2_release(struct inode *inode, struct file *file)
794} 793}
795 794
796 795
797int pvr2_v4l2_open(struct inode *inode, struct file *file) 796static int pvr2_v4l2_open(struct inode *inode, struct file *file)
798{ 797{
799 struct pvr2_v4l2_dev *dip = 0; /* Our own context pointer */ 798 struct pvr2_v4l2_dev *dip = NULL; /* Our own context pointer */
800 struct pvr2_v4l2_fh *fhp; 799 struct pvr2_v4l2_fh *fhp;
801 struct pvr2_v4l2 *vp; 800 struct pvr2_v4l2 *vp;
802 struct pvr2_hdw *hdw; 801 struct pvr2_hdw *hdw;
@@ -854,7 +853,7 @@ int pvr2_v4l2_open(struct inode *inode, struct file *file)
854 pvr2_context_enter(vp->channel.mc_head); do { 853 pvr2_context_enter(vp->channel.mc_head); do {
855 pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr_v4l2_fh id=%p",fhp); 854 pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr_v4l2_fh id=%p",fhp);
856 pvr2_channel_init(&fhp->channel,vp->channel.mc_head); 855 pvr2_channel_init(&fhp->channel,vp->channel.mc_head);
857 fhp->vnext = 0; 856 fhp->vnext = NULL;
858 fhp->vprev = vp->vlast; 857 fhp->vprev = vp->vlast;
859 if (vp->vlast) { 858 if (vp->vlast) {
860 vp->vlast->vnext = fhp; 859 vp->vlast->vnext = fhp;
@@ -897,7 +896,7 @@ static int pvr2_v4l2_iosetup(struct pvr2_v4l2_fh *fh)
897 896
898 fh->rhp = pvr2_channel_create_mpeg_stream(fh->dev_info->stream); 897 fh->rhp = pvr2_channel_create_mpeg_stream(fh->dev_info->stream);
899 if (!fh->rhp) { 898 if (!fh->rhp) {
900 pvr2_channel_claim_stream(&fh->channel,0); 899 pvr2_channel_claim_stream(&fh->channel,NULL);
901 return -ENOMEM; 900 return -ENOMEM;
902 } 901 }
903 902
@@ -1078,9 +1077,8 @@ static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
1078 (video_register_device(dip->vdev, v4l_type, -1) < 0)) { 1077 (video_register_device(dip->vdev, v4l_type, -1) < 0)) {
1079 err("Failed to register pvrusb2 v4l video device"); 1078 err("Failed to register pvrusb2 v4l video device");
1080 } else { 1079 } else {
1081 pvr2_trace(PVR2_TRACE_INIT, 1080 printk(KERN_INFO "pvrusb2: registered device video%d [%s]\n",
1082 "registered device video%d [%s]", 1081 dip->vdev->minor,pvr2_config_get_name(dip->config));
1083 dip->vdev->minor,pvr2_config_get_name(dip->config));
1084 } 1082 }
1085 1083
1086 if ((dip->vdev->minor < sizeof(devices)/sizeof(devices[0])) && 1084 if ((dip->vdev->minor < sizeof(devices)/sizeof(devices[0])) &&
diff --git a/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
index e4ec7f25194c..05f2cddeb47b 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-video-v4l.c
@@ -126,8 +126,8 @@ static const struct pvr2_v4l_decoder_ops decoder_ops[] = {
126 126
127static void decoder_detach(struct pvr2_v4l_decoder *ctxt) 127static void decoder_detach(struct pvr2_v4l_decoder *ctxt)
128{ 128{
129 ctxt->client->handler = 0; 129 ctxt->client->handler = NULL;
130 ctxt->hdw->decoder_ctrl = 0; 130 ctxt->hdw->decoder_ctrl = NULL;
131 kfree(ctxt); 131 kfree(ctxt);
132} 132}
133 133
diff --git a/drivers/media/video/pvrusb2/pvrusb2-wm8775.c b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
index fcad346e3955..2413e5198e16 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-wm8775.c
@@ -89,7 +89,7 @@ static unsigned int wm8775_describe(struct pvr2_v4l_wm8775 *ctxt,
89 89
90static void wm8775_detach(struct pvr2_v4l_wm8775 *ctxt) 90static void wm8775_detach(struct pvr2_v4l_wm8775 *ctxt)
91{ 91{
92 ctxt->client->handler = 0; 92 ctxt->client->handler = NULL;
93 kfree(ctxt); 93 kfree(ctxt);
94} 94}
95 95
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 0841556233c9..535172f643b9 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -941,8 +941,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
941 /* load i2c helpers */ 941 /* load i2c helpers */
942 if (TUNER_ABSENT != dev->tuner_type) 942 if (TUNER_ABSENT != dev->tuner_type)
943 request_module("tuner"); 943 request_module("tuner");
944 if (dev->tda9887_conf)
945 request_module("tda9887");
946 if (card_is_empress(dev)) { 944 if (card_is_empress(dev)) {
947 request_module("saa6752hs"); 945 request_module("saa6752hs");
948 request_module_depend("saa7134-empress",&need_empress); 946 request_module_depend("saa7134-empress",&need_empress);
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index 2fadabf99688..8dab481d384a 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -590,8 +590,8 @@ int tda9887_tuner_init(struct i2c_client *c)
590 t->set_tv_freq = tda9887_set_freq; 590 t->set_tv_freq = tda9887_set_freq;
591 t->set_radio_freq = tda9887_set_freq; 591 t->set_radio_freq = tda9887_set_freq;
592 t->standby = tda9887_standby; 592 t->standby = tda9887_standby;
593 t->tuner_status=tda9887_tuner_status; 593 t->tuner_status = tda9887_tuner_status;
594 t->get_afc=tda9887_get_afc; 594 t->get_afc = tda9887_get_afc;
595 595
596 return 0; 596 return 0;
597} 597}
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 011413cf34a8..f7eb402d5f2b 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -416,7 +416,7 @@ static void tuner_status(struct i2c_client *client)
416 416
417/* ---------------------------------------------------------------------- */ 417/* ---------------------------------------------------------------------- */
418 418
419/* static var Used only in tuner_attach and tuner_probe */ 419/* static vars: used only in tuner_attach and tuner_probe */
420static unsigned default_mode_mask; 420static unsigned default_mode_mask;
421 421
422/* During client attach, set_type is called by adapter's attach_inform callback. 422/* During client attach, set_type is called by adapter's attach_inform callback.
@@ -608,13 +608,13 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
608 tuner_dbg("VIDIOCSAUDIO not implemented.\n"); 608 tuner_dbg("VIDIOCSAUDIO not implemented.\n");
609 break; 609 break;
610 case TDA9887_SET_CONFIG: 610 case TDA9887_SET_CONFIG:
611 { 611 if (t->type == TUNER_TDA9887) {
612 int *i = arg; 612 int *i = arg;
613 613
614 t->tda9887_config = *i; 614 t->tda9887_config = *i;
615 set_freq(client, t->tv_freq); 615 set_freq(client, t->tv_freq);
616 }
616 break; 617 break;
617 }
618 /* --- v4l ioctls --- */ 618 /* --- v4l ioctls --- */
619 /* take care: bttv does userspace copying, we'll get a 619 /* take care: bttv does userspace copying, we'll get a
620 kernel pointer here... */ 620 kernel pointer here... */
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c
index 6da6f82b8c88..d071c5cbf013 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -7,6 +7,7 @@
7#include <linux/i2c.h> 7#include <linux/i2c.h>
8#include <linux/videodev.h> 8#include <linux/videodev.h>
9#include <media/tuner.h> 9#include <media/tuner.h>
10#include <media/v4l2-common.h>
10 11
11static int offset = 0; 12static int offset = 0;
12module_param(offset, int, 0666); 13module_param(offset, int, 0666);
@@ -128,6 +129,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
128 u8 buffer[4]; 129 u8 buffer[4];
129 int rc, IFPCoff, i, j; 130 int rc, IFPCoff, i, j;
130 enum param_type desired_type; 131 enum param_type desired_type;
132 struct tuner_params *params;
131 133
132 tun = &tuners[t->type]; 134 tun = &tuners[t->type];
133 135
@@ -169,19 +171,20 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
169 IFPCoff,t->type); 171 IFPCoff,t->type);
170 j = 0; 172 j = 0;
171 } 173 }
174 params = &tun->params[j];
172 175
173 for (i = 0; i < tun->params[j].count; i++) { 176 for (i = 0; i < params->count; i++) {
174 if (freq > tun->params[j].ranges[i].limit) 177 if (freq > params->ranges[i].limit)
175 continue; 178 continue;
176 break; 179 break;
177 } 180 }
178 if (i == tun->params[j].count) { 181 if (i == params->count) {
179 tuner_dbg("TV frequency out of range (%d > %d)", 182 tuner_dbg("TV frequency out of range (%d > %d)",
180 freq, tun->params[j].ranges[i - 1].limit); 183 freq, params->ranges[i - 1].limit);
181 freq = tun->params[j].ranges[--i].limit; 184 freq = params->ranges[--i].limit;
182 } 185 }
183 config = tun->params[j].ranges[i].config; 186 config = params->ranges[i].config;
184 cb = tun->params[j].ranges[i].cb; 187 cb = params->ranges[i].cb;
185 /* i == 0 -> VHF_LO 188 /* i == 0 -> VHF_LO
186 * i == 1 -> VHF_HI 189 * i == 1 -> VHF_HI
187 * i == 2 -> UHF */ 190 * i == 2 -> UHF */
@@ -281,7 +284,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
281 break; 284 break;
282 } 285 }
283 286
284 if (tuners[t->type].params->cb_first_if_lower_freq && div < t->last_div) { 287 if (params->cb_first_if_lower_freq && div < t->last_div) {
285 buffer[0] = config; 288 buffer[0] = config;
286 buffer[1] = cb; 289 buffer[1] = cb;
287 buffer[2] = (div>>8) & 0x7f; 290 buffer[2] = (div>>8) & 0x7f;
@@ -293,6 +296,43 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
293 buffer[3] = cb; 296 buffer[3] = cb;
294 } 297 }
295 t->last_div = div; 298 t->last_div = div;
299 if (params->has_tda9887) {
300 int config = 0;
301 int is_secam_l = (t->std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) &&
302 !(t->std & ~(V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC));
303
304 if (t->std == V4L2_STD_SECAM_LC) {
305 if (params->port1_active ^ params->port1_invert_for_secam_lc)
306 config |= TDA9887_PORT1_ACTIVE;
307 if (params->port2_active ^ params->port2_invert_for_secam_lc)
308 config |= TDA9887_PORT2_ACTIVE;
309 }
310 else {
311 if (params->port1_active)
312 config |= TDA9887_PORT1_ACTIVE;
313 if (params->port2_active)
314 config |= TDA9887_PORT2_ACTIVE;
315 }
316 if (params->intercarrier_mode)
317 config |= TDA9887_INTERCARRIER;
318 if (is_secam_l) {
319 if (i == 0 && params->default_top_secam_low)
320 config |= TDA9887_TOP(params->default_top_secam_low);
321 else if (i == 1 && params->default_top_secam_mid)
322 config |= TDA9887_TOP(params->default_top_secam_mid);
323 else if (params->default_top_secam_high)
324 config |= TDA9887_TOP(params->default_top_secam_high);
325 }
326 else {
327 if (i == 0 && params->default_top_low)
328 config |= TDA9887_TOP(params->default_top_low);
329 else if (i == 1 && params->default_top_mid)
330 config |= TDA9887_TOP(params->default_top_mid);
331 else if (params->default_top_high)
332 config |= TDA9887_TOP(params->default_top_high);
333 }
334 i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config);
335 }
296 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", 336 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
297 buffer[0],buffer[1],buffer[2],buffer[3]); 337 buffer[0],buffer[1],buffer[2],buffer[3]);
298 338
@@ -339,6 +379,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
339 u16 div; 379 u16 div;
340 int rc, j; 380 int rc, j;
341 enum param_type desired_type = TUNER_PARAM_TYPE_RADIO; 381 enum param_type desired_type = TUNER_PARAM_TYPE_RADIO;
382 struct tuner_params *params;
342 383
343 tun = &tuners[t->type]; 384 tun = &tuners[t->type];
344 385
@@ -352,7 +393,8 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
352 j = 0; 393 j = 0;
353 394
354 div = (20 * freq / 16000) + (int)(20*10.7); /* IF 10.7 MHz */ 395 div = (20 * freq / 16000) + (int)(20*10.7); /* IF 10.7 MHz */
355 buffer[2] = (tun->params[j].ranges[0].config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */ 396 params = &tun->params[j];
397 buffer[2] = (params->ranges[0].config & ~TUNER_RATIO_MASK) | TUNER_RATIO_SELECT_50; /* 50 kHz step */
356 398
357 switch (t->type) { 399 switch (t->type) {
358 case TUNER_TENA_9533_DI: 400 case TUNER_TENA_9533_DI:
@@ -384,7 +426,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
384 } 426 }
385 buffer[0] = (div>>8) & 0x7f; 427 buffer[0] = (div>>8) & 0x7f;
386 buffer[1] = div & 0xff; 428 buffer[1] = div & 0xff;
387 if (tuners[t->type].params->cb_first_if_lower_freq && div < t->last_div) { 429 if (params->cb_first_if_lower_freq && div < t->last_div) {
388 buffer[0] = buffer[2]; 430 buffer[0] = buffer[2];
389 buffer[1] = buffer[3]; 431 buffer[1] = buffer[3];
390 buffer[2] = (div>>8) & 0x7f; 432 buffer[2] = (div>>8) & 0x7f;
@@ -398,6 +440,18 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
398 buffer[0],buffer[1],buffer[2],buffer[3]); 440 buffer[0],buffer[1],buffer[2],buffer[3]);
399 t->last_div = div; 441 t->last_div = div;
400 442
443 if (params->has_tda9887) {
444 int config = 0;
445 if (params->port1_active && !params->port1_fm_high_sensitivity)
446 config |= TDA9887_PORT1_ACTIVE;
447 if (params->port2_active && !params->port2_fm_high_sensitivity)
448 config |= TDA9887_PORT2_ACTIVE;
449 if (params->intercarrier_mode)
450 config |= TDA9887_INTERCARRIER;
451/* if (params->port1_set_for_fm_mono)
452 config &= ~TDA9887_PORT1_ACTIVE;*/
453 i2c_clients_command(c->adapter, TDA9887_SET_CONFIG, &config);
454 }
401 if (4 != (rc = i2c_master_send(c,buffer,4))) 455 if (4 != (rc = i2c_master_send(c,buffer,4)))
402 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); 456 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
403} 457}
diff --git a/drivers/media/video/tuner-types.c b/drivers/media/video/tuner-types.c
index 9d9226cb6393..a167e17c6dcd 100644
--- a/drivers/media/video/tuner-types.c
+++ b/drivers/media/video/tuner-types.c
@@ -380,6 +380,10 @@ static struct tuner_params tuner_philips_fq1216me_params[] = {
380 .type = TUNER_PARAM_TYPE_PAL, 380 .type = TUNER_PARAM_TYPE_PAL,
381 .ranges = tuner_lg_pal_ranges, 381 .ranges = tuner_lg_pal_ranges,
382 .count = ARRAY_SIZE(tuner_lg_pal_ranges), 382 .count = ARRAY_SIZE(tuner_lg_pal_ranges),
383 .has_tda9887 = 1,
384 .port1_active = 1,
385 .port2_active = 1,
386 .port2_invert_for_secam_lc = 1,
383 }, 387 },
384}; 388};
385 389
@@ -542,6 +546,14 @@ static struct tuner_params tuner_fm1216me_mk3_params[] = {
542 .ranges = tuner_fm1216me_mk3_pal_ranges, 546 .ranges = tuner_fm1216me_mk3_pal_ranges,
543 .count = ARRAY_SIZE(tuner_fm1216me_mk3_pal_ranges), 547 .count = ARRAY_SIZE(tuner_fm1216me_mk3_pal_ranges),
544 .cb_first_if_lower_freq = 1, 548 .cb_first_if_lower_freq = 1,
549 .has_tda9887 = 1,
550 .port1_active = 1,
551 .port2_active = 1,
552 .port2_invert_for_secam_lc = 1,
553 .port1_fm_high_sensitivity = 1,
554 .default_top_mid = -2,
555 .default_top_secam_mid = -2,
556 .default_top_secam_high = -2,
545 }, 557 },
546}; 558};
547 559
@@ -612,6 +624,10 @@ static struct tuner_params tuner_fm1236_mk3_params[] = {
612 .ranges = tuner_fm1236_mk3_ntsc_ranges, 624 .ranges = tuner_fm1236_mk3_ntsc_ranges,
613 .count = ARRAY_SIZE(tuner_fm1236_mk3_ntsc_ranges), 625 .count = ARRAY_SIZE(tuner_fm1236_mk3_ntsc_ranges),
614 .cb_first_if_lower_freq = 1, 626 .cb_first_if_lower_freq = 1,
627 .has_tda9887 = 1,
628 .port1_active = 1,
629 .port2_active = 1,
630 .port1_fm_high_sensitivity = 1,
615 }, 631 },
616}; 632};
617 633
@@ -632,6 +648,8 @@ static struct tuner_params tuner_microtune_4049_fm5_params[] = {
632 .type = TUNER_PARAM_TYPE_PAL, 648 .type = TUNER_PARAM_TYPE_PAL,
633 .ranges = tuner_temic_4009f_5_pal_ranges, 649 .ranges = tuner_temic_4009f_5_pal_ranges,
634 .count = ARRAY_SIZE(tuner_temic_4009f_5_pal_ranges), 650 .count = ARRAY_SIZE(tuner_temic_4009f_5_pal_ranges),
651 .has_tda9887 = 1,
652 .port1_invert_for_secam_lc = 1,
635 }, 653 },
636}; 654};
637 655
@@ -648,6 +666,8 @@ static struct tuner_params tuner_panasonic_vp27_params[] = {
648 .type = TUNER_PARAM_TYPE_NTSC, 666 .type = TUNER_PARAM_TYPE_NTSC,
649 .ranges = tuner_panasonic_vp27_ntsc_ranges, 667 .ranges = tuner_panasonic_vp27_ntsc_ranges,
650 .count = ARRAY_SIZE(tuner_panasonic_vp27_ntsc_ranges), 668 .count = ARRAY_SIZE(tuner_panasonic_vp27_ntsc_ranges),
669 .has_tda9887 = 1,
670 .intercarrier_mode = 1,
651 }, 671 },
652}; 672};
653 673
@@ -782,6 +802,13 @@ static struct tuner_params tuner_philips_fq1216ame_mk4_params[] = {
782 .type = TUNER_PARAM_TYPE_PAL, 802 .type = TUNER_PARAM_TYPE_PAL,
783 .ranges = tuner_philips_fq12_6a___mk4_pal_ranges, 803 .ranges = tuner_philips_fq12_6a___mk4_pal_ranges,
784 .count = ARRAY_SIZE(tuner_philips_fq12_6a___mk4_pal_ranges), 804 .count = ARRAY_SIZE(tuner_philips_fq12_6a___mk4_pal_ranges),
805 .has_tda9887 = 1,
806 .port1_active = 1,
807 .port2_invert_for_secam_lc = 1,
808 .default_top_mid = -2,
809 .default_top_secam_low = -2,
810 .default_top_secam_mid = -2,
811 .default_top_secam_high = -2,
785 }, 812 },
786}; 813};
787 814
@@ -870,6 +897,12 @@ static struct tuner_params tuner_philips_fmd1216me_mk3_params[] = {
870 .type = TUNER_PARAM_TYPE_PAL, 897 .type = TUNER_PARAM_TYPE_PAL,
871 .ranges = tuner_philips_fmd1216me_mk3_pal_ranges, 898 .ranges = tuner_philips_fmd1216me_mk3_pal_ranges,
872 .count = ARRAY_SIZE(tuner_philips_fmd1216me_mk3_pal_ranges), 899 .count = ARRAY_SIZE(tuner_philips_fmd1216me_mk3_pal_ranges),
900 .has_tda9887 = 1,
901 .port1_active = 1,
902 .port2_active = 1,
903 .port2_fm_high_sensitivity = 1,
904 .port2_invert_for_secam_lc = 1,
905 .port1_set_for_fm_mono = 1,
873 }, 906 },
874}; 907};
875 908
@@ -1005,6 +1038,7 @@ static struct tuner_params tuner_samsung_tcpn_2121p30a_params[] = {
1005 .type = TUNER_PARAM_TYPE_NTSC, 1038 .type = TUNER_PARAM_TYPE_NTSC,
1006 .ranges = tuner_samsung_tcpn_2121p30a_ntsc_ranges, 1039 .ranges = tuner_samsung_tcpn_2121p30a_ntsc_ranges,
1007 .count = ARRAY_SIZE(tuner_samsung_tcpn_2121p30a_ntsc_ranges), 1040 .count = ARRAY_SIZE(tuner_samsung_tcpn_2121p30a_ntsc_ranges),
1041 .has_tda9887 = 1,
1008 }, 1042 },
1009}; 1043};
1010 1044
@@ -1037,6 +1071,10 @@ static struct tuner_params tuner_samsung_tcpg_6121p30a_params[] = {
1037 .type = TUNER_PARAM_TYPE_PAL, 1071 .type = TUNER_PARAM_TYPE_PAL,
1038 .ranges = tuner_samsung_tcpg_6121p30a_pal_ranges, 1072 .ranges = tuner_samsung_tcpg_6121p30a_pal_ranges,
1039 .count = ARRAY_SIZE(tuner_samsung_tcpg_6121p30a_pal_ranges), 1073 .count = ARRAY_SIZE(tuner_samsung_tcpg_6121p30a_pal_ranges),
1074 .has_tda9887 = 1,
1075 .port1_active = 1,
1076 .port2_active = 1,
1077 .port2_invert_for_secam_lc = 1,
1040 }, 1078 },
1041}; 1079};
1042 1080
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 30f8d80ddcaa..d95529e8e513 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -73,14 +73,14 @@ static struct HAUPPAUGE_TUNER_FMT
73} 73}
74hauppauge_tuner_fmt[] = 74hauppauge_tuner_fmt[] =
75{ 75{
76 { V4L2_STD_UNKNOWN," UNKNOWN" }, 76 { V4L2_STD_UNKNOWN, " UNKNOWN" },
77 { V4L2_STD_UNKNOWN," FM" }, 77 { V4L2_STD_UNKNOWN, " FM" },
78 { V4L2_STD_PAL_BG, " PAL(B/G)" }, 78 { V4L2_STD_B|V4L2_STD_GH, " PAL(B/G)" },
79 { V4L2_STD_NTSC_M, " NTSC(M)" }, 79 { V4L2_STD_MN, " NTSC(M)" },
80 { V4L2_STD_PAL_I, " PAL(I)" }, 80 { V4L2_STD_PAL_I, " PAL(I)" },
81 { V4L2_STD_SECAM_L," SECAM(L/L')" }, 81 { V4L2_STD_SECAM_L|V4L2_STD_SECAM_LC, " SECAM(L/L')" },
82 { V4L2_STD_PAL_DK, " PAL(D/D1/K)" }, 82 { V4L2_STD_DK, " PAL(D/D1/K)" },
83 { V4L2_STD_ATSC, " ATSC/DVB Digital" }, 83 { V4L2_STD_ATSC, " ATSC/DVB Digital" },
84}; 84};
85 85
86/* This is the full list of possible tuners. Many thanks to Hauppauge for 86/* This is the full list of possible tuners. Many thanks to Hauppauge for
@@ -219,7 +219,7 @@ hauppauge_tuner[] =
219 { TUNER_ABSENT, "Thompson DTT75105"}, 219 { TUNER_ABSENT, "Thompson DTT75105"},
220 { TUNER_ABSENT, "Conexant_CX24109"}, 220 { TUNER_ABSENT, "Conexant_CX24109"},
221 { TUNER_TCL_2002N, "TCL M2523_5N_E"}, 221 { TUNER_TCL_2002N, "TCL M2523_5N_E"},
222 { TUNER_ABSENT, "TCL M2523_3DB_E"}, 222 { TUNER_TCL_2002MB, "TCL M2523_3DB_E"},
223 { TUNER_ABSENT, "Philips 8275A"}, 223 { TUNER_ABSENT, "Philips 8275A"},
224 { TUNER_ABSENT, "Microtune MT2060"}, 224 { TUNER_ABSENT, "Microtune MT2060"},
225 { TUNER_ABSENT, "Philips FM1236 MK5"}, 225 { TUNER_ABSENT, "Philips FM1236 MK5"},
diff --git a/drivers/media/video/videocodec.h b/drivers/media/video/videocodec.h
index 8c233720b6a5..97a3bbeda505 100644
--- a/drivers/media/video/videocodec.h
+++ b/drivers/media/video/videocodec.h
@@ -222,14 +222,14 @@ M zr36055[1] 0001 0000c001 00000000 (zr36050[1])
222/* ========================= */ 222/* ========================= */
223 223
224struct vfe_polarity { 224struct vfe_polarity {
225 int vsync_pol:1; 225 unsigned int vsync_pol:1;
226 int hsync_pol:1; 226 unsigned int hsync_pol:1;
227 int field_pol:1; 227 unsigned int field_pol:1;
228 int blank_pol:1; 228 unsigned int blank_pol:1;
229 int subimg_pol:1; 229 unsigned int subimg_pol:1;
230 int poe_pol:1; 230 unsigned int poe_pol:1;
231 int pvalid_pol:1; 231 unsigned int pvalid_pol:1;
232 int vclk_pol:1; 232 unsigned int vclk_pol:1;
233}; 233};
234 234
235struct vfe_settings { 235struct vfe_settings {
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 441de824ab6b..48434d7924eb 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -387,7 +387,10 @@ static int com20020_resume(struct pcmcia_device *link)
387} 387}
388 388
389static struct pcmcia_device_id com20020_ids[] = { 389static struct pcmcia_device_id com20020_ids[] = {
390 PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.", "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf), 390 PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.",
391 "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf),
392 PCMCIA_DEVICE_PROD_ID12("SoHard AG",
393 "SH ARC PCMCIA", 0xf8991729, 0x69dff0c7),
391 PCMCIA_DEVICE_NULL 394 PCMCIA_DEVICE_NULL
392}; 395};
393MODULE_DEVICE_TABLE(pcmcia, com20020_ids); 396MODULE_DEVICE_TABLE(pcmcia, com20020_ids);
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index c309d2ea414d..52e6df5c1a92 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -843,7 +843,7 @@ static struct pcmcia_device_id hostap_cs_ids[] = {
843 PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001), 843 PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001),
844 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001), 844 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001),
845 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), 845 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300),
846 PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000), 846/* PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000), conflict with pcnet_cs */
847 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), 847 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002),
848 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), 848 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005),
849 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010), 849 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010),
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c
index 133a616ae8d8..bf00fa2537bb 100644
--- a/drivers/parisc/led.c
+++ b/drivers/parisc/led.c
@@ -410,16 +410,17 @@ static __inline__ int led_get_net_activity(void)
410static __inline__ int led_get_diskio_activity(void) 410static __inline__ int led_get_diskio_activity(void)
411{ 411{
412 static unsigned long last_pgpgin, last_pgpgout; 412 static unsigned long last_pgpgin, last_pgpgout;
413 struct page_state pgstat; 413 unsigned long events[NR_VM_EVENT_ITEMS];
414 int changed; 414 int changed;
415 415
416 get_full_page_state(&pgstat); /* get no of sectors in & out */ 416 all_vm_events(events);
417 417
418 /* Just use a very simple calculation here. Do not care about overflow, 418 /* Just use a very simple calculation here. Do not care about overflow,
419 since we only want to know if there was activity or not. */ 419 since we only want to know if there was activity or not. */
420 changed = (pgstat.pgpgin != last_pgpgin) || (pgstat.pgpgout != last_pgpgout); 420 changed = (events[PGPGIN] != last_pgpgin) ||
421 last_pgpgin = pgstat.pgpgin; 421 (events[PGPGOUT] != last_pgpgout);
422 last_pgpgout = pgstat.pgpgout; 422 last_pgpgin = events[PGPGIN];
423 last_pgpgout = events[PGPGOUT];
423 424
424 return (changed ? LED_DISK_IO : 0); 425 return (changed ? LED_DISK_IO : 0);
425} 426}
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile
index 421cfffb1756..34a1891191fd 100644
--- a/drivers/pci/hotplug/Makefile
+++ b/drivers/pci/hotplug/Makefile
@@ -40,8 +40,7 @@ ibmphp-objs := ibmphp_core.o \
40 ibmphp_hpc.o 40 ibmphp_hpc.o
41 41
42acpiphp-objs := acpiphp_core.o \ 42acpiphp-objs := acpiphp_core.o \
43 acpiphp_glue.o \ 43 acpiphp_glue.o
44 acpiphp_dock.o
45 44
46rpaphp-objs := rpaphp_core.o \ 45rpaphp-objs := rpaphp_core.o \
47 rpaphp_pci.o \ 46 rpaphp_pci.o \
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 17a93f890dba..be104eced34c 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -130,7 +130,7 @@ struct acpiphp_func {
130 130
131 struct list_head sibling; 131 struct list_head sibling;
132 struct pci_dev *pci_dev; 132 struct pci_dev *pci_dev;
133 133 struct notifier_block nb;
134 acpi_handle handle; 134 acpi_handle handle;
135 135
136 u8 function; /* pci function# */ 136 u8 function; /* pci function# */
@@ -151,24 +151,6 @@ struct acpiphp_attention_info
151}; 151};
152 152
153 153
154struct dependent_device {
155 struct list_head device_list;
156 struct list_head pci_list;
157 acpi_handle handle;
158 struct acpiphp_func *func;
159};
160
161
162struct acpiphp_dock_station {
163 acpi_handle handle;
164 u32 last_dock_time;
165 u32 flags;
166 struct acpiphp_func *dock_bridge;
167 struct list_head dependent_devices;
168 struct list_head pci_dependent_devices;
169};
170
171
172/* PCI bus bridge HID */ 154/* PCI bus bridge HID */
173#define ACPI_PCI_HOST_HID "PNP0A03" 155#define ACPI_PCI_HOST_HID "PNP0A03"
174 156
@@ -207,11 +189,6 @@ struct acpiphp_dock_station {
207#define FUNC_HAS_PS2 (0x00000040) 189#define FUNC_HAS_PS2 (0x00000040)
208#define FUNC_HAS_PS3 (0x00000080) 190#define FUNC_HAS_PS3 (0x00000080)
209#define FUNC_HAS_DCK (0x00000100) 191#define FUNC_HAS_DCK (0x00000100)
210#define FUNC_IS_DD (0x00000200)
211
212/* dock station flags */
213#define DOCK_DOCKING (0x00000001)
214#define DOCK_HAS_BRIDGE (0x00000002)
215 192
216/* function prototypes */ 193/* function prototypes */
217 194
@@ -226,7 +203,6 @@ extern int acpiphp_glue_init (void);
226extern void acpiphp_glue_exit (void); 203extern void acpiphp_glue_exit (void);
227extern int acpiphp_get_num_slots (void); 204extern int acpiphp_get_num_slots (void);
228typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data); 205typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
229void handle_hotplug_event_func(acpi_handle, u32, void*);
230 206
231extern int acpiphp_enable_slot (struct acpiphp_slot *slot); 207extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
232extern int acpiphp_disable_slot (struct acpiphp_slot *slot); 208extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
@@ -236,16 +212,6 @@ extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
236extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot); 212extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
237extern u32 acpiphp_get_address (struct acpiphp_slot *slot); 213extern u32 acpiphp_get_address (struct acpiphp_slot *slot);
238 214
239/* acpiphp_dock.c */
240extern int find_dock_station(void);
241extern void remove_dock_station(void);
242extern void add_dependent_device(struct dependent_device *new_dd);
243extern void add_pci_dependent_device(struct dependent_device *new_dd);
244extern struct dependent_device *get_dependent_device(acpi_handle handle);
245extern int is_dependent_device(acpi_handle handle);
246extern int detect_dependent_devices(acpi_handle *bridge_handle);
247extern struct dependent_device *alloc_dependent_device(acpi_handle handle);
248
249/* variables */ 215/* variables */
250extern int acpiphp_debug; 216extern int acpiphp_debug;
251 217
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index 4f1b0da8e47e..34de5697983d 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -416,27 +416,12 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
416 416
417static int __init acpiphp_init(void) 417static int __init acpiphp_init(void)
418{ 418{
419 int retval;
420 int docking_station;
421
422 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 419 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
423 420
424 acpiphp_debug = debug; 421 acpiphp_debug = debug;
425 422
426 docking_station = find_dock_station();
427
428 /* read all the ACPI info from the system */ 423 /* read all the ACPI info from the system */
429 retval = init_acpi(); 424 return init_acpi();
430
431 /* if we have found a docking station, we should
432 * go ahead and load even if init_acpi has found
433 * no slots. This handles the case when the _DCK
434 * method not defined under the actual dock bridge
435 */
436 if (docking_station)
437 return 0;
438 else
439 return retval;
440} 425}
441 426
442 427
@@ -444,8 +429,6 @@ static void __exit acpiphp_exit(void)
444{ 429{
445 /* deallocate internal data structures etc. */ 430 /* deallocate internal data structures etc. */
446 acpiphp_glue_exit(); 431 acpiphp_glue_exit();
447
448 remove_dock_station();
449} 432}
450 433
451module_init(acpiphp_init); 434module_init(acpiphp_init);
diff --git a/drivers/pci/hotplug/acpiphp_dock.c b/drivers/pci/hotplug/acpiphp_dock.c
deleted file mode 100644
index 4f1aaf128312..000000000000
--- a/drivers/pci/hotplug/acpiphp_dock.c
+++ /dev/null
@@ -1,438 +0,0 @@
1/*
2 * ACPI PCI HotPlug dock functions to ACPI CA subsystem
3 *
4 * Copyright (C) 2006 Kristen Carlson Accardi (kristen.c.accardi@intel.com)
5 * Copyright (C) 2006 Intel Corporation
6 *
7 * All rights reserved.
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 as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
17 * NON INFRINGEMENT. See the GNU General Public License for more
18 * details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 * Send feedback to <kristen.c.accardi@intel.com>
25 *
26 */
27#include <linux/init.h>
28#include <linux/module.h>
29
30#include <linux/kernel.h>
31#include <linux/pci.h>
32#include <linux/smp_lock.h>
33#include <linux/mutex.h>
34
35#include "../pci.h"
36#include "pci_hotplug.h"
37#include "acpiphp.h"
38
39static struct acpiphp_dock_station *ds;
40#define MY_NAME "acpiphp_dock"
41
42
43int is_dependent_device(acpi_handle handle)
44{
45 return (get_dependent_device(handle) ? 1 : 0);
46}
47
48
49static acpi_status
50find_dependent_device(acpi_handle handle, u32 lvl, void *context, void **rv)
51{
52 int *count = (int *)context;
53
54 if (is_dependent_device(handle)) {
55 (*count)++;
56 return AE_CTRL_TERMINATE;
57 } else {
58 return AE_OK;
59 }
60}
61
62
63
64
65void add_dependent_device(struct dependent_device *new_dd)
66{
67 list_add_tail(&new_dd->device_list, &ds->dependent_devices);
68}
69
70
71void add_pci_dependent_device(struct dependent_device *new_dd)
72{
73 list_add_tail(&new_dd->pci_list, &ds->pci_dependent_devices);
74}
75
76
77
78struct dependent_device * get_dependent_device(acpi_handle handle)
79{
80 struct dependent_device *dd;
81
82 if (!ds)
83 return NULL;
84
85 list_for_each_entry(dd, &ds->dependent_devices, device_list) {
86 if (handle == dd->handle)
87 return dd;
88 }
89 return NULL;
90}
91
92
93
94struct dependent_device *alloc_dependent_device(acpi_handle handle)
95{
96 struct dependent_device *dd;
97
98 dd = kzalloc(sizeof(*dd), GFP_KERNEL);
99 if (dd) {
100 INIT_LIST_HEAD(&dd->pci_list);
101 INIT_LIST_HEAD(&dd->device_list);
102 dd->handle = handle;
103 }
104 return dd;
105}
106
107
108
109static int is_dock(acpi_handle handle)
110{
111 acpi_status status;
112 acpi_handle tmp;
113
114 status = acpi_get_handle(handle, "_DCK", &tmp);
115 if (ACPI_FAILURE(status)) {
116 return 0;
117 }
118 return 1;
119}
120
121
122
123static int dock_present(void)
124{
125 unsigned long sta;
126 acpi_status status;
127
128 if (ds) {
129 status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta);
130 if (ACPI_SUCCESS(status) && sta)
131 return 1;
132 }
133 return 0;
134}
135
136
137
138static void eject_dock(void)
139{
140 struct acpi_object_list arg_list;
141 union acpi_object arg;
142
143 arg_list.count = 1;
144 arg_list.pointer = &arg;
145 arg.type = ACPI_TYPE_INTEGER;
146 arg.integer.value = 1;
147
148 if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0",
149 &arg_list, NULL)) || dock_present())
150 warn("%s: failed to eject dock!\n", __FUNCTION__);
151
152 return;
153}
154
155
156
157
158static acpi_status handle_dock(int dock)
159{
160 acpi_status status;
161 struct acpi_object_list arg_list;
162 union acpi_object arg;
163 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
164
165 dbg("%s: %s\n", __FUNCTION__, dock ? "docking" : "undocking");
166
167 /* _DCK method has one argument */
168 arg_list.count = 1;
169 arg_list.pointer = &arg;
170 arg.type = ACPI_TYPE_INTEGER;
171 arg.integer.value = dock;
172 status = acpi_evaluate_object(ds->handle, "_DCK",
173 &arg_list, &buffer);
174 if (ACPI_FAILURE(status))
175 err("%s: failed to execute _DCK\n", __FUNCTION__);
176 acpi_os_free(buffer.pointer);
177
178 return status;
179}
180
181
182
183static inline void dock(void)
184{
185 handle_dock(1);
186}
187
188
189
190static inline void undock(void)
191{
192 handle_dock(0);
193}
194
195
196
197/*
198 * the _DCK method can do funny things... and sometimes not
199 * hah-hah funny.
200 *
201 * TBD - figure out a way to only call fixups for
202 * systems that require them.
203 */
204static void post_dock_fixups(void)
205{
206 struct pci_bus *bus;
207 u32 buses;
208 struct dependent_device *dd;
209
210 list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list) {
211 bus = dd->func->slot->bridge->pci_bus;
212
213 /* fixup bad _DCK function that rewrites
214 * secondary bridge on slot
215 */
216 pci_read_config_dword(bus->self,
217 PCI_PRIMARY_BUS,
218 &buses);
219
220 if (((buses >> 8) & 0xff) != bus->secondary) {
221 buses = (buses & 0xff000000)
222 | ((unsigned int)(bus->primary) << 0)
223 | ((unsigned int)(bus->secondary) << 8)
224 | ((unsigned int)(bus->subordinate) << 16);
225 pci_write_config_dword(bus->self,
226 PCI_PRIMARY_BUS,
227 buses);
228 }
229 }
230}
231
232
233
234static void hotplug_pci(u32 type)
235{
236 struct dependent_device *dd;
237
238 list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list)
239 handle_hotplug_event_func(dd->handle, type, dd->func);
240}
241
242
243
244static inline void begin_dock(void)
245{
246 ds->flags |= DOCK_DOCKING;
247}
248
249
250static inline void complete_dock(void)
251{
252 ds->flags &= ~(DOCK_DOCKING);
253 ds->last_dock_time = jiffies;
254}
255
256
257static int dock_in_progress(void)
258{
259 if (ds->flags & DOCK_DOCKING ||
260 ds->last_dock_time == jiffies) {
261 dbg("dock in progress\n");
262 return 1;
263 }
264 return 0;
265}
266
267
268
269static void
270handle_hotplug_event_dock(acpi_handle handle, u32 type, void *context)
271{
272 dbg("%s: enter\n", __FUNCTION__);
273
274 switch (type) {
275 case ACPI_NOTIFY_BUS_CHECK:
276 dbg("BUS Check\n");
277 if (!dock_in_progress() && dock_present()) {
278 begin_dock();
279 dock();
280 if (!dock_present()) {
281 err("Unable to dock!\n");
282 break;
283 }
284 post_dock_fixups();
285 hotplug_pci(type);
286 complete_dock();
287 }
288 break;
289 case ACPI_NOTIFY_EJECT_REQUEST:
290 dbg("EJECT request\n");
291 if (!dock_in_progress() && dock_present()) {
292 hotplug_pci(type);
293 undock();
294 eject_dock();
295 if (dock_present())
296 err("Unable to undock!\n");
297 }
298 break;
299 }
300}
301
302
303
304
305static acpi_status
306find_dock_ejd(acpi_handle handle, u32 lvl, void *context, void **rv)
307{
308 acpi_status status;
309 acpi_handle tmp;
310 acpi_handle dck_handle = (acpi_handle) context;
311 char objname[64];
312 struct acpi_buffer buffer = { .length = sizeof(objname),
313 .pointer = objname };
314 struct acpi_buffer ejd_buffer = {ACPI_ALLOCATE_BUFFER, NULL};
315 union acpi_object *ejd_obj;
316
317 status = acpi_get_handle(handle, "_EJD", &tmp);
318 if (ACPI_FAILURE(status))
319 return AE_OK;
320
321 /* make sure we are dependent on the dock device,
322 * by executing the _EJD method, then getting a handle
323 * to the device referenced by that name. If that
324 * device handle is the same handle as the dock station
325 * handle, then we are a device dependent on the dock station
326 */
327 acpi_get_name(dck_handle, ACPI_FULL_PATHNAME, &buffer);
328 status = acpi_evaluate_object(handle, "_EJD", NULL, &ejd_buffer);
329 if (ACPI_FAILURE(status)) {
330 err("Unable to execute _EJD!\n");
331 goto find_ejd_out;
332 }
333 ejd_obj = ejd_buffer.pointer;
334 status = acpi_get_handle(NULL, ejd_obj->string.pointer, &tmp);
335 if (ACPI_FAILURE(status))
336 goto find_ejd_out;
337
338 if (tmp == dck_handle) {
339 struct dependent_device *dd;
340 dbg("%s: found device dependent on dock\n", __FUNCTION__);
341 dd = alloc_dependent_device(handle);
342 if (!dd) {
343 err("Can't allocate memory for dependent device!\n");
344 goto find_ejd_out;
345 }
346 add_dependent_device(dd);
347 }
348
349find_ejd_out:
350 acpi_os_free(ejd_buffer.pointer);
351 return AE_OK;
352}
353
354
355
356int detect_dependent_devices(acpi_handle *bridge_handle)
357{
358 acpi_status status;
359 int count;
360
361 count = 0;
362
363 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle,
364 (u32)1, find_dependent_device,
365 (void *)&count, NULL);
366
367 return count;
368}
369
370
371
372
373
374static acpi_status
375find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
376{
377 int *count = (int *)context;
378
379 if (is_dock(handle)) {
380 dbg("%s: found dock\n", __FUNCTION__);
381 ds = kzalloc(sizeof(*ds), GFP_KERNEL);
382 ds->handle = handle;
383 INIT_LIST_HEAD(&ds->dependent_devices);
384 INIT_LIST_HEAD(&ds->pci_dependent_devices);
385
386 /* look for devices dependent on dock station */
387 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
388 ACPI_UINT32_MAX, find_dock_ejd, handle, NULL);
389
390 acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
391 handle_hotplug_event_dock, ds);
392 (*count)++;
393 }
394
395 return AE_OK;
396}
397
398
399
400
401int find_dock_station(void)
402{
403 int num = 0;
404
405 ds = NULL;
406
407 /* start from the root object, because some laptops define
408 * _DCK methods outside the scope of PCI (IBM x-series laptop)
409 */
410 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
411 ACPI_UINT32_MAX, find_dock, &num, NULL);
412
413 return num;
414}
415
416
417
418void remove_dock_station(void)
419{
420 struct dependent_device *dd, *tmp;
421 if (ds) {
422 if (ACPI_FAILURE(acpi_remove_notify_handler(ds->handle,
423 ACPI_SYSTEM_NOTIFY, handle_hotplug_event_dock)))
424 err("failed to remove dock notify handler\n");
425
426 /* free all dependent devices */
427 list_for_each_entry_safe(dd, tmp, &ds->dependent_devices,
428 device_list)
429 kfree(dd);
430
431 /* no need to touch the pci_dependent_device list,
432 * cause all memory was freed above
433 */
434 kfree(ds);
435 }
436}
437
438
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index d370f999782e..ef95d12fb32c 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -59,6 +59,7 @@ static LIST_HEAD(bridge_list);
59static void handle_hotplug_event_bridge (acpi_handle, u32, void *); 59static void handle_hotplug_event_bridge (acpi_handle, u32, void *);
60static void acpiphp_sanitize_bus(struct pci_bus *bus); 60static void acpiphp_sanitize_bus(struct pci_bus *bus);
61static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus); 61static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus);
62static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context);
62 63
63 64
64/* 65/*
@@ -116,6 +117,59 @@ is_ejectable_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
116 } 117 }
117} 118}
118 119
120/* callback routine to check for the existance of a pci dock device */
121static acpi_status
122is_pci_dock_device(acpi_handle handle, u32 lvl, void *context, void **rv)
123{
124 int *count = (int *)context;
125
126 if (is_dock_device(handle)) {
127 (*count)++;
128 return AE_CTRL_TERMINATE;
129 } else {
130 return AE_OK;
131 }
132}
133
134
135
136
137/*
138 * the _DCK method can do funny things... and sometimes not
139 * hah-hah funny.
140 *
141 * TBD - figure out a way to only call fixups for
142 * systems that require them.
143 */
144static int post_dock_fixups(struct notifier_block *nb, unsigned long val,
145 void *v)
146{
147 struct acpiphp_func *func = container_of(nb, struct acpiphp_func, nb);
148 struct pci_bus *bus = func->slot->bridge->pci_bus;
149 u32 buses;
150
151 if (!bus->self)
152 return NOTIFY_OK;
153
154 /* fixup bad _DCK function that rewrites
155 * secondary bridge on slot
156 */
157 pci_read_config_dword(bus->self,
158 PCI_PRIMARY_BUS,
159 &buses);
160
161 if (((buses >> 8) & 0xff) != bus->secondary) {
162 buses = (buses & 0xff000000)
163 | ((unsigned int)(bus->primary) << 0)
164 | ((unsigned int)(bus->secondary) << 8)
165 | ((unsigned int)(bus->subordinate) << 16);
166 pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses);
167 }
168 return NOTIFY_OK;
169}
170
171
172
119 173
120/* callback routine to register each ACPI PCI slot object */ 174/* callback routine to register each ACPI PCI slot object */
121static acpi_status 175static acpi_status
@@ -124,7 +178,6 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
124 struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context; 178 struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context;
125 struct acpiphp_slot *slot; 179 struct acpiphp_slot *slot;
126 struct acpiphp_func *newfunc; 180 struct acpiphp_func *newfunc;
127 struct dependent_device *dd;
128 acpi_handle tmp; 181 acpi_handle tmp;
129 acpi_status status = AE_OK; 182 acpi_status status = AE_OK;
130 unsigned long adr, sun; 183 unsigned long adr, sun;
@@ -137,7 +190,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
137 190
138 status = acpi_get_handle(handle, "_EJ0", &tmp); 191 status = acpi_get_handle(handle, "_EJ0", &tmp);
139 192
140 if (ACPI_FAILURE(status) && !(is_dependent_device(handle))) 193 if (ACPI_FAILURE(status) && !(is_dock_device(handle)))
141 return AE_OK; 194 return AE_OK;
142 195
143 device = (adr >> 16) & 0xffff; 196 device = (adr >> 16) & 0xffff;
@@ -162,22 +215,17 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
162 if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp))) 215 if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp)))
163 newfunc->flags |= FUNC_HAS_PS3; 216 newfunc->flags |= FUNC_HAS_PS3;
164 217
165 if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp))) { 218 if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp)))
166 newfunc->flags |= FUNC_HAS_DCK; 219 newfunc->flags |= FUNC_HAS_DCK;
167 /* add to devices dependent on dock station,
168 * because this may actually be the dock bridge
169 */
170 dd = alloc_dependent_device(handle);
171 if (!dd)
172 err("Can't allocate memory for "
173 "new dependent device!\n");
174 else
175 add_dependent_device(dd);
176 }
177 220
178 status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun); 221 status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
179 if (ACPI_FAILURE(status)) 222 if (ACPI_FAILURE(status)) {
180 sun = -1; 223 /*
224 * use the count of the number of slots we've found
225 * for the number of the slot
226 */
227 sun = bridge->nr_slots+1;
228 }
181 229
182 /* search for objects that share the same slot */ 230 /* search for objects that share the same slot */
183 for (slot = bridge->slots; slot; slot = slot->next) 231 for (slot = bridge->slots; slot; slot = slot->next)
@@ -225,20 +273,23 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
225 slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); 273 slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON);
226 } 274 }
227 275
228 /* if this is a device dependent on a dock station, 276 if (is_dock_device(handle)) {
229 * associate the acpiphp_func to the dependent_device 277 /* we don't want to call this device's _EJ0
230 * struct. 278 * because we want the dock notify handler
231 */ 279 * to call it after it calls _DCK
232 if ((dd = get_dependent_device(handle))) {
233 newfunc->flags |= FUNC_IS_DD;
234 /*
235 * we don't want any devices which is dependent
236 * on the dock to have it's _EJ0 method executed.
237 * because we need to run _DCK first.
238 */ 280 */
239 newfunc->flags &= ~FUNC_HAS_EJ0; 281 newfunc->flags &= ~FUNC_HAS_EJ0;
240 dd->func = newfunc; 282 if (register_hotplug_dock_device(handle,
241 add_pci_dependent_device(dd); 283 handle_hotplug_event_func, newfunc))
284 dbg("failed to register dock device\n");
285
286 /* we need to be notified when dock events happen
287 * outside of the hotplug operation, since we may
288 * need to do fixups before we can hotplug.
289 */
290 newfunc->nb.notifier_call = post_dock_fixups;
291 if (register_dock_notifier(&newfunc->nb))
292 dbg("failed to register a dock notifier");
242 } 293 }
243 294
244 /* install notify handler */ 295 /* install notify handler */
@@ -277,6 +328,15 @@ static int detect_ejectable_slots(acpi_handle *bridge_handle)
277 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, (u32)1, 328 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, (u32)1,
278 is_ejectable_slot, (void *)&count, NULL); 329 is_ejectable_slot, (void *)&count, NULL);
279 330
331 /*
332 * we also need to add this bridge if there is a dock bridge or
333 * other pci device on a dock station (removable)
334 */
335 if (!count)
336 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle,
337 (u32)1, is_pci_dock_device, (void *)&count,
338 NULL);
339
280 return count; 340 return count;
281} 341}
282 342
@@ -487,8 +547,7 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
487 goto out; 547 goto out;
488 548
489 /* check if this bridge has ejectable slots */ 549 /* check if this bridge has ejectable slots */
490 if ((detect_ejectable_slots(handle) > 0) || 550 if ((detect_ejectable_slots(handle) > 0)) {
491 (detect_dependent_devices(handle) > 0)) {
492 dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); 551 dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev));
493 add_p2p_bridge(handle, dev); 552 add_p2p_bridge(handle, dev);
494 } 553 }
@@ -605,6 +664,10 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
605 list_for_each_safe (list, tmp, &slot->funcs) { 664 list_for_each_safe (list, tmp, &slot->funcs) {
606 struct acpiphp_func *func; 665 struct acpiphp_func *func;
607 func = list_entry(list, struct acpiphp_func, sibling); 666 func = list_entry(list, struct acpiphp_func, sibling);
667 if (is_dock_device(func->handle)) {
668 unregister_hotplug_dock_device(func->handle);
669 unregister_dock_notifier(&func->nb);
670 }
608 if (!(func->flags & FUNC_HAS_DCK)) { 671 if (!(func->flags & FUNC_HAS_DCK)) {
609 status = acpi_remove_notify_handler(func->handle, 672 status = acpi_remove_notify_handler(func->handle,
610 ACPI_SYSTEM_NOTIFY, 673 ACPI_SYSTEM_NOTIFY,
@@ -1440,7 +1503,7 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *cont
1440 * handles ACPI event notification on slots 1503 * handles ACPI event notification on slots
1441 * 1504 *
1442 */ 1505 */
1443void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context) 1506static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context)
1444{ 1507{
1445 struct acpiphp_func *func; 1508 struct acpiphp_func *func;
1446 char objname[64]; 1509 char objname[64];
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index a4d50940ebeb..5256342e8532 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -214,11 +214,10 @@ static struct pccard_operations at91_cf_ops = {
214 214
215/*--------------------------------------------------------------------------*/ 215/*--------------------------------------------------------------------------*/
216 216
217static int __init at91_cf_probe(struct device *dev) 217static int __init at91_cf_probe(struct platform_device *pdev)
218{ 218{
219 struct at91_cf_socket *cf; 219 struct at91_cf_socket *cf;
220 struct at91_cf_data *board = dev->platform_data; 220 struct at91_cf_data *board = pdev->dev.platform_data;
221 struct platform_device *pdev = to_platform_device(dev);
222 struct resource *io; 221 struct resource *io;
223 unsigned int csa; 222 unsigned int csa;
224 int status; 223 int status;
@@ -236,7 +235,7 @@ static int __init at91_cf_probe(struct device *dev)
236 235
237 cf->board = board; 236 cf->board = board;
238 cf->pdev = pdev; 237 cf->pdev = pdev;
239 dev_set_drvdata(dev, cf); 238 platform_set_drvdata(pdev, cf);
240 239
241 /* CF takes over CS4, CS5, CS6 */ 240 /* CF takes over CS4, CS5, CS6 */
242 csa = at91_sys_read(AT91_EBI_CSA); 241 csa = at91_sys_read(AT91_EBI_CSA);
@@ -271,6 +270,7 @@ static int __init at91_cf_probe(struct device *dev)
271 SA_SAMPLE_RANDOM, driver_name, cf); 270 SA_SAMPLE_RANDOM, driver_name, cf);
272 if (status < 0) 271 if (status < 0)
273 goto fail0; 272 goto fail0;
273 device_init_wakeup(&pdev->dev, 1);
274 274
275 /* 275 /*
276 * The card driver will request this irq later as needed. 276 * The card driver will request this irq later as needed.
@@ -301,7 +301,7 @@ static int __init at91_cf_probe(struct device *dev)
301 board->det_pin, board->irq_pin); 301 board->det_pin, board->irq_pin);
302 302
303 cf->socket.owner = THIS_MODULE; 303 cf->socket.owner = THIS_MODULE;
304 cf->socket.dev.dev = dev; 304 cf->socket.dev.dev = &pdev->dev;
305 cf->socket.ops = &at91_cf_ops; 305 cf->socket.ops = &at91_cf_ops;
306 cf->socket.resource_ops = &pccard_static_ops; 306 cf->socket.resource_ops = &pccard_static_ops;
307 cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP 307 cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP
@@ -323,21 +323,25 @@ fail1:
323 free_irq(board->irq_pin, cf); 323 free_irq(board->irq_pin, cf);
324fail0a: 324fail0a:
325 free_irq(board->det_pin, cf); 325 free_irq(board->det_pin, cf);
326 device_init_wakeup(&pdev->dev, 0);
326fail0: 327fail0:
327 at91_sys_write(AT91_EBI_CSA, csa); 328 at91_sys_write(AT91_EBI_CSA, csa);
328 kfree(cf); 329 kfree(cf);
329 return status; 330 return status;
330} 331}
331 332
332static int __exit at91_cf_remove(struct device *dev) 333static int __exit at91_cf_remove(struct platform_device *pdev)
333{ 334{
334 struct at91_cf_socket *cf = dev_get_drvdata(dev); 335 struct at91_cf_socket *cf = platform_get_drvdata(pdev);
336 struct at91_cf_data *board = cf->board;
335 struct resource *io = cf->socket.io[0].res; 337 struct resource *io = cf->socket.io[0].res;
336 unsigned int csa; 338 unsigned int csa;
337 339
338 pcmcia_unregister_socket(&cf->socket); 340 pcmcia_unregister_socket(&cf->socket);
339 free_irq(cf->board->irq_pin, cf); 341 if (board->irq_pin)
340 free_irq(cf->board->det_pin, cf); 342 free_irq(board->irq_pin, cf);
343 free_irq(board->det_pin, cf);
344 device_init_wakeup(&pdev->dev, 0);
341 iounmap((void __iomem *) cf->socket.io_offset); 345 iounmap((void __iomem *) cf->socket.io_offset);
342 release_mem_region(io->start, io->end + 1 - io->start); 346 release_mem_region(io->start, io->end + 1 - io->start);
343 347
@@ -348,26 +352,65 @@ static int __exit at91_cf_remove(struct device *dev)
348 return 0; 352 return 0;
349} 353}
350 354
351static struct device_driver at91_cf_driver = { 355#ifdef CONFIG_PM
352 .name = (char *) driver_name, 356
353 .bus = &platform_bus_type, 357static int at91_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
358{
359 struct at91_cf_socket *cf = platform_get_drvdata(pdev);
360 struct at91_cf_data *board = cf->board;
361
362 pcmcia_socket_dev_suspend(&pdev->dev, mesg);
363 if (device_may_wakeup(&pdev->dev))
364 enable_irq_wake(board->det_pin);
365 else {
366 disable_irq_wake(board->det_pin);
367 disable_irq(board->det_pin);
368 }
369 if (board->irq_pin)
370 disable_irq(board->irq_pin);
371 return 0;
372}
373
374static int at91_cf_resume(struct platform_device *pdev)
375{
376 struct at91_cf_socket *cf = platform_get_drvdata(pdev);
377 struct at91_cf_data *board = cf->board;
378
379 if (board->irq_pin)
380 enable_irq(board->irq_pin);
381 if (!device_may_wakeup(&pdev->dev))
382 enable_irq(board->det_pin);
383 pcmcia_socket_dev_resume(&pdev->dev);
384 return 0;
385}
386
387#else
388#define at91_cf_suspend NULL
389#define at91_cf_resume NULL
390#endif
391
392static struct platform_driver at91_cf_driver = {
393 .driver = {
394 .name = (char *) driver_name,
395 .owner = THIS_MODULE,
396 },
354 .probe = at91_cf_probe, 397 .probe = at91_cf_probe,
355 .remove = __exit_p(at91_cf_remove), 398 .remove = __exit_p(at91_cf_remove),
356 .suspend = pcmcia_socket_dev_suspend, 399 .suspend = at91_cf_suspend,
357 .resume = pcmcia_socket_dev_resume, 400 .resume = at91_cf_resume,
358}; 401};
359 402
360/*--------------------------------------------------------------------------*/ 403/*--------------------------------------------------------------------------*/
361 404
362static int __init at91_cf_init(void) 405static int __init at91_cf_init(void)
363{ 406{
364 return driver_register(&at91_cf_driver); 407 return platform_driver_register(&at91_cf_driver);
365} 408}
366module_init(at91_cf_init); 409module_init(at91_cf_init);
367 410
368static void __exit at91_cf_exit(void) 411static void __exit at91_cf_exit(void)
369{ 412{
370 driver_unregister(&at91_cf_driver); 413 platform_driver_unregister(&at91_cf_driver);
371} 414}
372module_exit(at91_cf_exit); 415module_exit(at91_cf_exit);
373 416
diff --git a/drivers/pcmcia/au1000_db1x00.c b/drivers/pcmcia/au1000_db1x00.c
index 24cfee1a412c..74e051535d6c 100644
--- a/drivers/pcmcia/au1000_db1x00.c
+++ b/drivers/pcmcia/au1000_db1x00.c
@@ -295,7 +295,7 @@ struct pcmcia_low_level db1x00_pcmcia_ops = {
295 .socket_suspend = db1x00_socket_suspend 295 .socket_suspend = db1x00_socket_suspend
296}; 296};
297 297
298int __init au1x_board_init(struct device *dev) 298int au1x_board_init(struct device *dev)
299{ 299{
300 int ret = -ENODEV; 300 int ret = -ENODEV;
301 bcsr->pcmcia = 0; /* turn off power, if it's not already off */ 301 bcsr->pcmcia = 0; /* turn off power, if it's not already off */
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 3162998579c1..f9cd831a3f31 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -28,6 +28,7 @@
28#include <linux/pm.h> 28#include <linux/pm.h>
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/kthread.h>
31#include <asm/system.h> 32#include <asm/system.h>
32#include <asm/irq.h> 33#include <asm/irq.h>
33 34
@@ -176,6 +177,7 @@ static int pccardd(void *__skt);
176 */ 177 */
177int pcmcia_register_socket(struct pcmcia_socket *socket) 178int pcmcia_register_socket(struct pcmcia_socket *socket)
178{ 179{
180 struct task_struct *tsk;
179 int ret; 181 int ret;
180 182
181 if (!socket || !socket->ops || !socket->dev.dev || !socket->resource_ops) 183 if (!socket || !socket->ops || !socket->dev.dev || !socket->resource_ops)
@@ -239,15 +241,18 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
239 mutex_init(&socket->skt_mutex); 241 mutex_init(&socket->skt_mutex);
240 spin_lock_init(&socket->thread_lock); 242 spin_lock_init(&socket->thread_lock);
241 243
242 ret = kernel_thread(pccardd, socket, CLONE_KERNEL); 244 tsk = kthread_run(pccardd, socket, "pccardd");
243 if (ret < 0) 245 if (IS_ERR(tsk)) {
246 ret = PTR_ERR(tsk);
244 goto err; 247 goto err;
248 }
245 249
246 wait_for_completion(&socket->thread_done); 250 wait_for_completion(&socket->thread_done);
247 if(!socket->thread) { 251 if (!socket->thread) {
248 printk(KERN_WARNING "PCMCIA: warning: socket thread for socket %p did not start\n", socket); 252 printk(KERN_WARNING "PCMCIA: warning: socket thread for socket %p did not start\n", socket);
249 return -EIO; 253 return -EIO;
250 } 254 }
255
251 pcmcia_parse_events(socket, SS_DETECT); 256 pcmcia_parse_events(socket, SS_DETECT);
252 257
253 return 0; 258 return 0;
@@ -272,10 +277,8 @@ void pcmcia_unregister_socket(struct pcmcia_socket *socket)
272 cs_dbg(socket, 0, "pcmcia_unregister_socket(0x%p)\n", socket->ops); 277 cs_dbg(socket, 0, "pcmcia_unregister_socket(0x%p)\n", socket->ops);
273 278
274 if (socket->thread) { 279 if (socket->thread) {
275 init_completion(&socket->thread_done);
276 socket->thread = NULL;
277 wake_up(&socket->thread_wait); 280 wake_up(&socket->thread_wait);
278 wait_for_completion(&socket->thread_done); 281 kthread_stop(socket->thread);
279 } 282 }
280 release_cis_mem(socket); 283 release_cis_mem(socket);
281 284
@@ -630,8 +633,6 @@ static int pccardd(void *__skt)
630 DECLARE_WAITQUEUE(wait, current); 633 DECLARE_WAITQUEUE(wait, current);
631 int ret; 634 int ret;
632 635
633 daemonize("pccardd");
634
635 skt->thread = current; 636 skt->thread = current;
636 skt->socket = dead_socket; 637 skt->socket = dead_socket;
637 skt->ops->init(skt); 638 skt->ops->init(skt);
@@ -643,7 +644,8 @@ static int pccardd(void *__skt)
643 printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n", 644 printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n",
644 skt); 645 skt);
645 skt->thread = NULL; 646 skt->thread = NULL;
646 complete_and_exit(&skt->thread_done, 0); 647 complete(&skt->thread_done);
648 return 0;
647 } 649 }
648 650
649 add_wait_queue(&skt->thread_wait, &wait); 651 add_wait_queue(&skt->thread_wait, &wait);
@@ -674,7 +676,7 @@ static int pccardd(void *__skt)
674 continue; 676 continue;
675 } 677 }
676 678
677 if (!skt->thread) 679 if (kthread_should_stop())
678 break; 680 break;
679 681
680 schedule(); 682 schedule();
@@ -688,7 +690,7 @@ static int pccardd(void *__skt)
688 /* remove from the device core */ 690 /* remove from the device core */
689 class_device_unregister(&skt->dev); 691 class_device_unregister(&skt->dev);
690 692
691 complete_and_exit(&skt->thread_done, 0); 693 return 0;
692} 694}
693 695
694/* 696/*
@@ -697,11 +699,12 @@ static int pccardd(void *__skt)
697 */ 699 */
698void pcmcia_parse_events(struct pcmcia_socket *s, u_int events) 700void pcmcia_parse_events(struct pcmcia_socket *s, u_int events)
699{ 701{
702 unsigned long flags;
700 cs_dbg(s, 4, "parse_events: events %08x\n", events); 703 cs_dbg(s, 4, "parse_events: events %08x\n", events);
701 if (s->thread) { 704 if (s->thread) {
702 spin_lock(&s->thread_lock); 705 spin_lock_irqsave(&s->thread_lock, flags);
703 s->thread_events |= events; 706 s->thread_events |= events;
704 spin_unlock(&s->thread_lock); 707 spin_unlock_irqrestore(&s->thread_lock, flags);
705 708
706 wake_up(&s->thread_wait); 709 wake_up(&s->thread_wait);
707 } 710 }
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 3131bb0a0095..3281e519e714 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -788,6 +788,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
788 struct pcmcia_socket *s = p_dev->socket; 788 struct pcmcia_socket *s = p_dev->socket;
789 config_t *c; 789 config_t *c;
790 int ret = CS_IN_USE, irq = 0; 790 int ret = CS_IN_USE, irq = 0;
791 int type;
791 792
792 if (!(s->state & SOCKET_PRESENT)) 793 if (!(s->state & SOCKET_PRESENT))
793 return CS_NO_CARD; 794 return CS_NO_CARD;
@@ -797,6 +798,13 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
797 if (c->state & CONFIG_IRQ_REQ) 798 if (c->state & CONFIG_IRQ_REQ)
798 return CS_IN_USE; 799 return CS_IN_USE;
799 800
801 /* Decide what type of interrupt we are registering */
802 type = 0;
803 if (s->functions > 1) /* All of this ought to be handled higher up */
804 type = SA_SHIRQ;
805 if (req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)
806 type = SA_SHIRQ;
807
800#ifdef CONFIG_PCMCIA_PROBE 808#ifdef CONFIG_PCMCIA_PROBE
801 if (s->irq.AssignedIRQ != 0) { 809 if (s->irq.AssignedIRQ != 0) {
802 /* If the interrupt is already assigned, it must be the same */ 810 /* If the interrupt is already assigned, it must be the same */
@@ -822,9 +830,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
822 * marked as used by the kernel resource management core */ 830 * marked as used by the kernel resource management core */
823 ret = request_irq(irq, 831 ret = request_irq(irq,
824 (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Handler : test_action, 832 (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Handler : test_action,
825 ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || 833 type,
826 (s->functions > 1) ||
827 (irq == s->pci_irq)) ? SA_SHIRQ : 0,
828 p_dev->devname, 834 p_dev->devname,
829 (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Instance : data); 835 (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Instance : data);
830 if (!ret) { 836 if (!ret) {
@@ -839,18 +845,21 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
839 if (ret && !s->irq.AssignedIRQ) { 845 if (ret && !s->irq.AssignedIRQ) {
840 if (!s->pci_irq) 846 if (!s->pci_irq)
841 return ret; 847 return ret;
848 type = SA_SHIRQ;
842 irq = s->pci_irq; 849 irq = s->pci_irq;
843 } 850 }
844 851
845 if (ret && req->Attributes & IRQ_HANDLE_PRESENT) { 852 if (ret && (req->Attributes & IRQ_HANDLE_PRESENT)) {
846 if (request_irq(irq, req->Handler, 853 if (request_irq(irq, req->Handler, type, p_dev->devname, req->Instance))
847 ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) ||
848 (s->functions > 1) ||
849 (irq == s->pci_irq)) ? SA_SHIRQ : 0,
850 p_dev->devname, req->Instance))
851 return CS_IN_USE; 854 return CS_IN_USE;
852 } 855 }
853 856
857 /* Make sure the fact the request type was overridden is passed back */
858 if (type == SA_SHIRQ && !(req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)) {
859 req->Attributes |= IRQ_TYPE_DYNAMIC_SHARING;
860 printk(KERN_WARNING "pcmcia: request for exclusive IRQ could not be fulfilled.\n");
861 printk(KERN_WARNING "pcmcia: the driver needs updating to supported shared IRQ lines.\n");
862 }
854 c->irq.Attributes = req->Attributes; 863 c->irq.Attributes = req->Attributes;
855 s->irq.AssignedIRQ = req->AssignedIRQ = irq; 864 s->irq.AssignedIRQ = req->AssignedIRQ = irq;
856 s->irq.Config++; 865 s->irq.Config++;
diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
index 7a3d1b8e16b9..62e9ebf967f9 100644
--- a/drivers/pcmcia/ti113x.h
+++ b/drivers/pcmcia/ti113x.h
@@ -647,6 +647,7 @@ static int ti12xx_2nd_slot_empty(struct yenta_socket *socket)
647 */ 647 */
648 break; 648 break;
649 649
650 case PCI_DEVICE_ID_TI_XX12:
650 case PCI_DEVICE_ID_TI_X515: 651 case PCI_DEVICE_ID_TI_X515:
651 case PCI_DEVICE_ID_TI_X420: 652 case PCI_DEVICE_ID_TI_X420:
652 case PCI_DEVICE_ID_TI_X620: 653 case PCI_DEVICE_ID_TI_X620:
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 4145eb83b9b6..47e57602d5ea 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -287,7 +287,10 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
287 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); 287 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
288 u16 bridge; 288 u16 bridge;
289 289
290 yenta_set_power(socket, state); 290 /* if powering down: do it immediately */
291 if (state->Vcc == 0)
292 yenta_set_power(socket, state);
293
291 socket->io_irq = state->io_irq; 294 socket->io_irq = state->io_irq;
292 bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~(CB_BRIDGE_CRST | CB_BRIDGE_INTR); 295 bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~(CB_BRIDGE_CRST | CB_BRIDGE_INTR);
293 if (cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) { 296 if (cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) {
@@ -339,6 +342,10 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
339 /* Socket event mask: get card insert/remove events.. */ 342 /* Socket event mask: get card insert/remove events.. */
340 cb_writel(socket, CB_SOCKET_EVENT, -1); 343 cb_writel(socket, CB_SOCKET_EVENT, -1);
341 cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK); 344 cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK);
345
346 /* if powering up: do it as the last step when the socket is configured */
347 if (state->Vcc != 0)
348 yenta_set_power(socket, state);
342 return 0; 349 return 0;
343} 350}
344 351
@@ -998,6 +1005,77 @@ static void yenta_config_init(struct yenta_socket *socket)
998 config_writew(socket, CB_BRIDGE_CONTROL, bridge); 1005 config_writew(socket, CB_BRIDGE_CONTROL, bridge);
999} 1006}
1000 1007
1008/**
1009 * yenta_fixup_parent_bridge - Fix subordinate bus# of the parent bridge
1010 * @cardbus_bridge: The PCI bus which the CardBus bridge bridges to
1011 *
1012 * Checks if devices on the bus which the CardBus bridge bridges to would be
1013 * invisible during PCI scans because of a misconfigured subordinate number
1014 * of the parent brige - some BIOSes seem to be too lazy to set it right.
1015 * Does the fixup carefully by checking how far it can go without conflicts.
1016 * See http://bugzilla.kernel.org/show_bug.cgi?id=2944 for more information.
1017 */
1018static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
1019{
1020 struct list_head *tmp;
1021 unsigned char upper_limit;
1022 /*
1023 * We only check and fix the parent bridge: All systems which need
1024 * this fixup that have been reviewed are laptops and the only bridge
1025 * which needed fixing was the parent bridge of the CardBus bridge:
1026 */
1027 struct pci_bus *bridge_to_fix = cardbus_bridge->parent;
1028
1029 /* Check bus numbers are already set up correctly: */
1030 if (bridge_to_fix->subordinate >= cardbus_bridge->subordinate)
1031 return; /* The subordinate number is ok, nothing to do */
1032
1033 if (!bridge_to_fix->parent)
1034 return; /* Root bridges are ok */
1035
1036 /* stay within the limits of the bus range of the parent: */
1037 upper_limit = bridge_to_fix->parent->subordinate;
1038
1039 /* check the bus ranges of all silbling bridges to prevent overlap */
1040 list_for_each(tmp, &bridge_to_fix->parent->children) {
1041 struct pci_bus * silbling = pci_bus_b(tmp);
1042 /*
1043 * If the silbling has a higher secondary bus number
1044 * and it's secondary is equal or smaller than our
1045 * current upper limit, set the new upper limit to
1046 * the bus number below the silbling's range:
1047 */
1048 if (silbling->secondary > bridge_to_fix->subordinate
1049 && silbling->secondary <= upper_limit)
1050 upper_limit = silbling->secondary - 1;
1051 }
1052
1053 /* Show that the wanted subordinate number is not possible: */
1054 if (cardbus_bridge->subordinate > upper_limit)
1055 printk(KERN_WARNING "Yenta: Upper limit for fixing this "
1056 "bridge's parent bridge: #%02x\n", upper_limit);
1057
1058 /* If we have room to increase the bridge's subordinate number, */
1059 if (bridge_to_fix->subordinate < upper_limit) {
1060
1061 /* use the highest number of the hidden bus, within limits */
1062 unsigned char subordinate_to_assign =
1063 min(cardbus_bridge->subordinate, upper_limit);
1064
1065 printk(KERN_INFO "Yenta: Raising subordinate bus# of parent "
1066 "bus (#%02x) from #%02x to #%02x\n",
1067 bridge_to_fix->number,
1068 bridge_to_fix->subordinate, subordinate_to_assign);
1069
1070 /* Save the new subordinate in the bus struct of the bridge */
1071 bridge_to_fix->subordinate = subordinate_to_assign;
1072
1073 /* and update the PCI config space with the new subordinate */
1074 pci_write_config_byte(bridge_to_fix->self,
1075 PCI_SUBORDINATE_BUS, bridge_to_fix->subordinate);
1076 }
1077}
1078
1001/* 1079/*
1002 * Initialize a cardbus controller. Make sure we have a usable 1080 * Initialize a cardbus controller. Make sure we have a usable
1003 * interrupt, and that we can map the cardbus area. Fill in the 1081 * interrupt, and that we can map the cardbus area. Fill in the
@@ -1113,6 +1191,8 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1113 yenta_get_socket_capabilities(socket, isa_interrupts); 1191 yenta_get_socket_capabilities(socket, isa_interrupts);
1114 printk(KERN_INFO "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE)); 1192 printk(KERN_INFO "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE));
1115 1193
1194 yenta_fixup_parent_bridge(dev->subordinate);
1195
1116 /* Register it with the pcmcia layer.. */ 1196 /* Register it with the pcmcia layer.. */
1117 ret = pcmcia_register_socket(&socket->socket); 1197 ret = pcmcia_register_socket(&socket->socket);
1118 if (ret == 0) { 1198 if (ret == 0) {
@@ -1232,6 +1312,7 @@ static struct pci_device_id yenta_table [] = {
1232 1312
1233 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX21_XX11, TI12XX), 1313 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX21_XX11, TI12XX),
1234 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X515, TI12XX), 1314 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X515, TI12XX),
1315 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX12, TI12XX),
1235 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X420, TI12XX), 1316 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X420, TI12XX),
1236 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X620, TI12XX), 1317 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X620, TI12XX),
1237 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7410, TI12XX), 1318 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7410, TI12XX),
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 2c70773543e0..cbf260bc225d 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -786,6 +786,7 @@ static struct pcmcia_device_id serial_ids[] = {
786 PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"), 786 PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"),
787 PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"), 787 PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"),
788 PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "RS-COM-2P.cis"), 788 PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "RS-COM-2P.cis"),
789 PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "GLOBETROTTER.cis"),
789 /* too generic */ 790 /* too generic */
790 /* PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0160, 0x0002), */ 791 /* PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0160, 0x0002), */
791 /* PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0160, 0x0002), */ 792 /* PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0160, 0x0002), */
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index bcbeaf7101d1..f7bdd94b3aa8 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -47,6 +47,7 @@
47#include <linux/usbdevice_fs.h> 47#include <linux/usbdevice_fs.h>
48#include <linux/cdev.h> 48#include <linux/cdev.h>
49#include <linux/notifier.h> 49#include <linux/notifier.h>
50#include <linux/security.h>
50#include <asm/uaccess.h> 51#include <asm/uaccess.h>
51#include <asm/byteorder.h> 52#include <asm/byteorder.h>
52#include <linux/moduleparam.h> 53#include <linux/moduleparam.h>
@@ -68,6 +69,7 @@ struct async {
68 void __user *userbuffer; 69 void __user *userbuffer;
69 void __user *userurb; 70 void __user *userurb;
70 struct urb *urb; 71 struct urb *urb;
72 u32 secid;
71}; 73};
72 74
73static int usbfs_snoop = 0; 75static int usbfs_snoop = 0;
@@ -312,7 +314,7 @@ static void async_completed(struct urb *urb, struct pt_regs *regs)
312 sinfo.si_code = SI_ASYNCIO; 314 sinfo.si_code = SI_ASYNCIO;
313 sinfo.si_addr = as->userurb; 315 sinfo.si_addr = as->userurb;
314 kill_proc_info_as_uid(as->signr, &sinfo, as->pid, as->uid, 316 kill_proc_info_as_uid(as->signr, &sinfo, as->pid, as->uid,
315 as->euid); 317 as->euid, as->secid);
316 } 318 }
317 snoop(&urb->dev->dev, "urb complete\n"); 319 snoop(&urb->dev->dev, "urb complete\n");
318 snoop_urb(urb, as->userurb); 320 snoop_urb(urb, as->userurb);
@@ -572,6 +574,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
572 ps->disc_euid = current->euid; 574 ps->disc_euid = current->euid;
573 ps->disccontext = NULL; 575 ps->disccontext = NULL;
574 ps->ifclaimed = 0; 576 ps->ifclaimed = 0;
577 security_task_getsecid(current, &ps->secid);
575 wmb(); 578 wmb();
576 list_add_tail(&ps->list, &dev->filelist); 579 list_add_tail(&ps->list, &dev->filelist);
577 file->private_data = ps; 580 file->private_data = ps;
@@ -1053,6 +1056,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1053 as->pid = current->pid; 1056 as->pid = current->pid;
1054 as->uid = current->uid; 1057 as->uid = current->uid;
1055 as->euid = current->euid; 1058 as->euid = current->euid;
1059 security_task_getsecid(current, &as->secid);
1056 if (!(uurb->endpoint & USB_DIR_IN)) { 1060 if (!(uurb->endpoint & USB_DIR_IN)) {
1057 if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, as->urb->transfer_buffer_length)) { 1061 if (copy_from_user(as->urb->transfer_buffer, uurb->buffer, as->urb->transfer_buffer_length)) {
1058 free_async(as); 1062 free_async(as);
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 02a6312e0e0f..e47e3a8ed6e4 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -699,7 +699,7 @@ static void usbfs_remove_device(struct usb_device *dev)
699 sinfo.si_errno = EPIPE; 699 sinfo.si_errno = EPIPE;
700 sinfo.si_code = SI_ASYNCIO; 700 sinfo.si_code = SI_ASYNCIO;
701 sinfo.si_addr = ds->disccontext; 701 sinfo.si_addr = ds->disccontext;
702 kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid); 702 kill_proc_info_as_uid(ds->discsignr, &sinfo, ds->disc_pid, ds->disc_uid, ds->disc_euid, ds->secid);
703 } 703 }
704 } 704 }
705} 705}
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 7a650c763a62..49f69236b420 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -80,6 +80,7 @@ struct dev_state {
80 uid_t disc_uid, disc_euid; 80 uid_t disc_uid, disc_euid;
81 void __user *disccontext; 81 void __user *disccontext;
82 unsigned long ifclaimed; 82 unsigned long ifclaimed;
83 u32 secid;
83}; 84};
84 85
85/* internal notify stuff */ 86/* internal notify stuff */
diff --git a/drivers/video/imacfb.c b/drivers/video/imacfb.c
index 7b1c168c834d..cdbae173d69a 100644
--- a/drivers/video/imacfb.c
+++ b/drivers/video/imacfb.c
@@ -207,10 +207,6 @@ static int __init imacfb_probe(struct platform_device *dev)
207 size_remap = size_total; 207 size_remap = size_total;
208 imacfb_fix.smem_len = size_remap; 208 imacfb_fix.smem_len = size_remap;
209 209
210#ifndef __i386__
211 screen_info.imacpm_seg = 0;
212#endif
213
214 if (!request_mem_region(imacfb_fix.smem_start, size_total, "imacfb")) { 210 if (!request_mem_region(imacfb_fix.smem_start, size_total, "imacfb")) {
215 printk(KERN_WARNING 211 printk(KERN_WARNING
216 "imacfb: cannot reserve video memory at 0x%lx\n", 212 "imacfb: cannot reserve video memory at 0x%lx\n",