diff options
Diffstat (limited to 'drivers')
97 files changed, 1910 insertions, 1706 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 20eacc2c9e0e..e942ffe8b57e 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -13,6 +13,7 @@ config ACPI | |||
13 | depends on IA64 || X86 | 13 | depends on IA64 || X86 |
14 | depends on PCI | 14 | depends on PCI |
15 | depends on PM | 15 | depends on PM |
16 | select PNP | ||
16 | default y | 17 | default y |
17 | ---help--- | 18 | ---help--- |
18 | Advanced Configuration and Power Interface (ACPI) support for | 19 | Advanced Configuration and Power Interface (ACPI) support for |
@@ -132,15 +133,6 @@ config ACPI_VIDEO | |||
132 | Note that this is an ref. implementation only. It may or may not work | 133 | Note that this is an ref. implementation only. It may or may not work |
133 | for your integrated video device. | 134 | for your integrated video device. |
134 | 135 | ||
135 | config ACPI_HOTKEY | ||
136 | tristate "Generic Hotkey (EXPERIMENTAL)" | ||
137 | depends on EXPERIMENTAL | ||
138 | depends on X86 | ||
139 | default n | ||
140 | help | ||
141 | Experimental consolidated hotkey driver. | ||
142 | If you are unsure, say N. | ||
143 | |||
144 | config ACPI_FAN | 136 | config ACPI_FAN |
145 | tristate "Fan" | 137 | tristate "Fan" |
146 | default y | 138 | default y |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 856c32bccacb..5956e9f64a8b 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -46,7 +46,6 @@ obj-$(CONFIG_ACPI_FAN) += fan.o | |||
46 | obj-$(CONFIG_ACPI_DOCK) += dock.o | 46 | obj-$(CONFIG_ACPI_DOCK) += dock.o |
47 | obj-$(CONFIG_ACPI_BAY) += bay.o | 47 | obj-$(CONFIG_ACPI_BAY) += bay.o |
48 | obj-$(CONFIG_ACPI_VIDEO) += video.o | 48 | obj-$(CONFIG_ACPI_VIDEO) += video.o |
49 | obj-$(CONFIG_ACPI_HOTKEY) += hotkey.o | ||
50 | obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o | 49 | obj-y += pci_root.o pci_link.o pci_irq.o pci_bind.o |
51 | obj-$(CONFIG_ACPI_POWER) += power.o | 50 | obj-$(CONFIG_ACPI_POWER) += power.o |
52 | obj-$(CONFIG_ACPI_PROCESSOR) += processor.o | 51 | obj-$(CONFIG_ACPI_PROCESSOR) += processor.o |
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 6daeace796a8..37c7dc4f9fe5 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #define ACPI_AC_COMPONENT 0x00020000 | 35 | #define ACPI_AC_COMPONENT 0x00020000 |
36 | #define ACPI_AC_CLASS "ac_adapter" | 36 | #define ACPI_AC_CLASS "ac_adapter" |
37 | #define ACPI_AC_HID "ACPI0003" | 37 | #define ACPI_AC_HID "ACPI0003" |
38 | #define ACPI_AC_DRIVER_NAME "ACPI AC Adapter Driver" | ||
39 | #define ACPI_AC_DEVICE_NAME "AC Adapter" | 38 | #define ACPI_AC_DEVICE_NAME "AC Adapter" |
40 | #define ACPI_AC_FILE_STATE "state" | 39 | #define ACPI_AC_FILE_STATE "state" |
41 | #define ACPI_AC_NOTIFY_STATUS 0x80 | 40 | #define ACPI_AC_NOTIFY_STATUS 0x80 |
@@ -44,10 +43,10 @@ | |||
44 | #define ACPI_AC_STATUS_UNKNOWN 0xFF | 43 | #define ACPI_AC_STATUS_UNKNOWN 0xFF |
45 | 44 | ||
46 | #define _COMPONENT ACPI_AC_COMPONENT | 45 | #define _COMPONENT ACPI_AC_COMPONENT |
47 | ACPI_MODULE_NAME("acpi_ac") | 46 | ACPI_MODULE_NAME("ac"); |
48 | 47 | ||
49 | MODULE_AUTHOR("Paul Diefenbaugh"); | 48 | MODULE_AUTHOR("Paul Diefenbaugh"); |
50 | MODULE_DESCRIPTION(ACPI_AC_DRIVER_NAME); | 49 | MODULE_DESCRIPTION("ACPI AC Adapter Driver"); |
51 | MODULE_LICENSE("GPL"); | 50 | MODULE_LICENSE("GPL"); |
52 | 51 | ||
53 | extern struct proc_dir_entry *acpi_lock_ac_dir(void); | 52 | extern struct proc_dir_entry *acpi_lock_ac_dir(void); |
@@ -58,7 +57,7 @@ static int acpi_ac_remove(struct acpi_device *device, int type); | |||
58 | static int acpi_ac_open_fs(struct inode *inode, struct file *file); | 57 | static int acpi_ac_open_fs(struct inode *inode, struct file *file); |
59 | 58 | ||
60 | static struct acpi_driver acpi_ac_driver = { | 59 | static struct acpi_driver acpi_ac_driver = { |
61 | .name = ACPI_AC_DRIVER_NAME, | 60 | .name = "ac", |
62 | .class = ACPI_AC_CLASS, | 61 | .class = ACPI_AC_CLASS, |
63 | .ids = ACPI_AC_HID, | 62 | .ids = ACPI_AC_HID, |
64 | .ops = { | 63 | .ops = { |
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index cd946ed192d3..c26172671fd8 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c | |||
@@ -35,14 +35,13 @@ | |||
35 | #define ACPI_MEMORY_DEVICE_COMPONENT 0x08000000UL | 35 | #define ACPI_MEMORY_DEVICE_COMPONENT 0x08000000UL |
36 | #define ACPI_MEMORY_DEVICE_CLASS "memory" | 36 | #define ACPI_MEMORY_DEVICE_CLASS "memory" |
37 | #define ACPI_MEMORY_DEVICE_HID "PNP0C80" | 37 | #define ACPI_MEMORY_DEVICE_HID "PNP0C80" |
38 | #define ACPI_MEMORY_DEVICE_DRIVER_NAME "Hotplug Mem Driver" | ||
39 | #define ACPI_MEMORY_DEVICE_NAME "Hotplug Mem Device" | 38 | #define ACPI_MEMORY_DEVICE_NAME "Hotplug Mem Device" |
40 | 39 | ||
41 | #define _COMPONENT ACPI_MEMORY_DEVICE_COMPONENT | 40 | #define _COMPONENT ACPI_MEMORY_DEVICE_COMPONENT |
42 | 41 | ||
43 | ACPI_MODULE_NAME("acpi_memory") | 42 | ACPI_MODULE_NAME("acpi_memhotplug"); |
44 | MODULE_AUTHOR("Naveen B S <naveen.b.s@intel.com>"); | 43 | MODULE_AUTHOR("Naveen B S <naveen.b.s@intel.com>"); |
45 | MODULE_DESCRIPTION(ACPI_MEMORY_DEVICE_DRIVER_NAME); | 44 | MODULE_DESCRIPTION("Hotplug Mem Driver"); |
46 | MODULE_LICENSE("GPL"); | 45 | MODULE_LICENSE("GPL"); |
47 | 46 | ||
48 | /* ACPI _STA method values */ | 47 | /* ACPI _STA method values */ |
@@ -60,7 +59,7 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type); | |||
60 | static int acpi_memory_device_start(struct acpi_device *device); | 59 | static int acpi_memory_device_start(struct acpi_device *device); |
61 | 60 | ||
62 | static struct acpi_driver acpi_memory_device_driver = { | 61 | static struct acpi_driver acpi_memory_device_driver = { |
63 | .name = ACPI_MEMORY_DEVICE_DRIVER_NAME, | 62 | .name = "acpi_memhotplug", |
64 | .class = ACPI_MEMORY_DEVICE_CLASS, | 63 | .class = ACPI_MEMORY_DEVICE_CLASS, |
65 | .ids = ACPI_MEMORY_DEVICE_HID, | 64 | .ids = ACPI_MEMORY_DEVICE_HID, |
66 | .ops = { | 65 | .ops = { |
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c index 31ad70a6e22e..772299fb5f9d 100644 --- a/drivers/acpi/asus_acpi.c +++ b/drivers/acpi/asus_acpi.c | |||
@@ -141,6 +141,7 @@ struct asus_hotk { | |||
141 | W5A, //W5A | 141 | W5A, //W5A |
142 | W3V, //W3030V | 142 | W3V, //W3030V |
143 | xxN, //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N | 143 | xxN, //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N |
144 | A4S, //Z81sp | ||
144 | //(Centrino) | 145 | //(Centrino) |
145 | END_MODEL | 146 | END_MODEL |
146 | } model; //Models currently supported | 147 | } model; //Models currently supported |
@@ -397,7 +398,16 @@ static struct model_data model_conf[END_MODEL] = { | |||
397 | .brightness_set = "SPLV", | 398 | .brightness_set = "SPLV", |
398 | .brightness_get = "GPLV", | 399 | .brightness_get = "GPLV", |
399 | .display_set = "SDSP", | 400 | .display_set = "SDSP", |
400 | .display_get = "\\ADVG"} | 401 | .display_get = "\\ADVG"}, |
402 | |||
403 | { | ||
404 | .name = "A4S", | ||
405 | .brightness_set = "SPLV", | ||
406 | .brightness_get = "GPLV", | ||
407 | .mt_bt_switch = "BLED", | ||
408 | .mt_wled = "WLED" | ||
409 | } | ||
410 | |||
401 | }; | 411 | }; |
402 | 412 | ||
403 | /* procdir we use */ | 413 | /* procdir we use */ |
@@ -421,7 +431,7 @@ static struct asus_hotk *hotk; | |||
421 | static int asus_hotk_add(struct acpi_device *device); | 431 | static int asus_hotk_add(struct acpi_device *device); |
422 | static int asus_hotk_remove(struct acpi_device *device, int type); | 432 | static int asus_hotk_remove(struct acpi_device *device, int type); |
423 | static struct acpi_driver asus_hotk_driver = { | 433 | static struct acpi_driver asus_hotk_driver = { |
424 | .name = ACPI_HOTK_NAME, | 434 | .name = "asus_acpi", |
425 | .class = ACPI_HOTK_CLASS, | 435 | .class = ACPI_HOTK_CLASS, |
426 | .ids = ACPI_HOTK_HID, | 436 | .ids = ACPI_HOTK_HID, |
427 | .ops = { | 437 | .ops = { |
@@ -1117,6 +1127,8 @@ static int asus_model_match(char *model) | |||
1117 | return W3V; | 1127 | return W3V; |
1118 | else if (strncmp(model, "W5A", 3) == 0) | 1128 | else if (strncmp(model, "W5A", 3) == 0) |
1119 | return W5A; | 1129 | return W5A; |
1130 | else if (strncmp(model, "A4S", 3) == 0) | ||
1131 | return A4S; | ||
1120 | else | 1132 | else |
1121 | return END_MODEL; | 1133 | return END_MODEL; |
1122 | } | 1134 | } |
@@ -1365,10 +1377,6 @@ static int __init asus_acpi_init(void) | |||
1365 | if (acpi_disabled) | 1377 | if (acpi_disabled) |
1366 | return -ENODEV; | 1378 | return -ENODEV; |
1367 | 1379 | ||
1368 | if (!acpi_specific_hotkey_enabled) { | ||
1369 | printk(KERN_ERR "Using generic hotkey driver\n"); | ||
1370 | return -ENODEV; | ||
1371 | } | ||
1372 | asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir); | 1380 | asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir); |
1373 | if (!asus_proc_dir) { | 1381 | if (!asus_proc_dir) { |
1374 | printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n"); | 1382 | printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n"); |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 2f4521a48fe7..02de49ef1bce 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #define ACPI_BATTERY_COMPONENT 0x00040000 | 42 | #define ACPI_BATTERY_COMPONENT 0x00040000 |
43 | #define ACPI_BATTERY_CLASS "battery" | 43 | #define ACPI_BATTERY_CLASS "battery" |
44 | #define ACPI_BATTERY_HID "PNP0C0A" | 44 | #define ACPI_BATTERY_HID "PNP0C0A" |
45 | #define ACPI_BATTERY_DRIVER_NAME "ACPI Battery Driver" | ||
46 | #define ACPI_BATTERY_DEVICE_NAME "Battery" | 45 | #define ACPI_BATTERY_DEVICE_NAME "Battery" |
47 | #define ACPI_BATTERY_FILE_INFO "info" | 46 | #define ACPI_BATTERY_FILE_INFO "info" |
48 | #define ACPI_BATTERY_FILE_STATUS "state" | 47 | #define ACPI_BATTERY_FILE_STATUS "state" |
@@ -53,10 +52,10 @@ | |||
53 | #define ACPI_BATTERY_UNITS_AMPS "mA" | 52 | #define ACPI_BATTERY_UNITS_AMPS "mA" |
54 | 53 | ||
55 | #define _COMPONENT ACPI_BATTERY_COMPONENT | 54 | #define _COMPONENT ACPI_BATTERY_COMPONENT |
56 | ACPI_MODULE_NAME("acpi_battery") | 55 | ACPI_MODULE_NAME("battery"); |
57 | 56 | ||
58 | MODULE_AUTHOR("Paul Diefenbaugh"); | 57 | MODULE_AUTHOR("Paul Diefenbaugh"); |
59 | MODULE_DESCRIPTION(ACPI_BATTERY_DRIVER_NAME); | 58 | MODULE_DESCRIPTION("ACPI Battery Driver"); |
60 | MODULE_LICENSE("GPL"); | 59 | MODULE_LICENSE("GPL"); |
61 | 60 | ||
62 | extern struct proc_dir_entry *acpi_lock_battery_dir(void); | 61 | extern struct proc_dir_entry *acpi_lock_battery_dir(void); |
@@ -67,7 +66,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type); | |||
67 | static int acpi_battery_resume(struct acpi_device *device); | 66 | static int acpi_battery_resume(struct acpi_device *device); |
68 | 67 | ||
69 | static struct acpi_driver acpi_battery_driver = { | 68 | static struct acpi_driver acpi_battery_driver = { |
70 | .name = ACPI_BATTERY_DRIVER_NAME, | 69 | .name = "battery", |
71 | .class = ACPI_BATTERY_CLASS, | 70 | .class = ACPI_BATTERY_CLASS, |
72 | .ids = ACPI_BATTERY_HID, | 71 | .ids = ACPI_BATTERY_HID, |
73 | .ops = { | 72 | .ops = { |
diff --git a/drivers/acpi/bay.c b/drivers/acpi/bay.c index 91082ce6f5d1..fb3f31b5e69f 100644 --- a/drivers/acpi/bay.c +++ b/drivers/acpi/bay.c | |||
@@ -32,11 +32,9 @@ | |||
32 | #include <asm/uaccess.h> | 32 | #include <asm/uaccess.h> |
33 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
34 | 34 | ||
35 | #define ACPI_BAY_DRIVER_NAME "ACPI Removable Drive Bay Driver" | 35 | ACPI_MODULE_NAME("bay"); |
36 | |||
37 | ACPI_MODULE_NAME("bay") | ||
38 | MODULE_AUTHOR("Kristen Carlson Accardi"); | 36 | MODULE_AUTHOR("Kristen Carlson Accardi"); |
39 | MODULE_DESCRIPTION(ACPI_BAY_DRIVER_NAME); | 37 | MODULE_DESCRIPTION("ACPI Removable Drive Bay Driver"); |
40 | MODULE_LICENSE("GPL"); | 38 | MODULE_LICENSE("GPL"); |
41 | #define ACPI_BAY_CLASS "bay" | 39 | #define ACPI_BAY_CLASS "bay" |
42 | #define ACPI_BAY_COMPONENT 0x10000000 | 40 | #define ACPI_BAY_COMPONENT 0x10000000 |
@@ -47,18 +45,6 @@ MODULE_LICENSE("GPL"); | |||
47 | acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\ | 45 | acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\ |
48 | printk(KERN_DEBUG PREFIX "%s: %s\n", prefix, s); } | 46 | printk(KERN_DEBUG PREFIX "%s: %s\n", prefix, s); } |
49 | static void bay_notify(acpi_handle handle, u32 event, void *data); | 47 | static void bay_notify(acpi_handle handle, u32 event, void *data); |
50 | static int acpi_bay_add(struct acpi_device *device); | ||
51 | static int acpi_bay_remove(struct acpi_device *device, int type); | ||
52 | |||
53 | static struct acpi_driver acpi_bay_driver = { | ||
54 | .name = ACPI_BAY_DRIVER_NAME, | ||
55 | .class = ACPI_BAY_CLASS, | ||
56 | .ids = ACPI_BAY_HID, | ||
57 | .ops = { | ||
58 | .add = acpi_bay_add, | ||
59 | .remove = acpi_bay_remove, | ||
60 | }, | ||
61 | }; | ||
62 | 48 | ||
63 | struct bay { | 49 | struct bay { |
64 | acpi_handle handle; | 50 | acpi_handle handle; |
@@ -234,14 +220,6 @@ int eject_removable_drive(struct device *dev) | |||
234 | } | 220 | } |
235 | EXPORT_SYMBOL_GPL(eject_removable_drive); | 221 | EXPORT_SYMBOL_GPL(eject_removable_drive); |
236 | 222 | ||
237 | static int acpi_bay_add(struct acpi_device *device) | ||
238 | { | ||
239 | bay_dprintk(device->handle, "adding bay device"); | ||
240 | strcpy(acpi_device_name(device), "Dockable Bay"); | ||
241 | strcpy(acpi_device_class(device), "bay"); | ||
242 | return 0; | ||
243 | } | ||
244 | |||
245 | static int acpi_bay_add_fs(struct bay *bay) | 223 | static int acpi_bay_add_fs(struct bay *bay) |
246 | { | 224 | { |
247 | int ret; | 225 | int ret; |
@@ -303,7 +281,7 @@ static int bay_add(acpi_handle handle, int id) | |||
303 | 281 | ||
304 | /* initialize platform device stuff */ | 282 | /* initialize platform device stuff */ |
305 | pdev = platform_device_register_simple(ACPI_BAY_CLASS, id, NULL, 0); | 283 | pdev = platform_device_register_simple(ACPI_BAY_CLASS, id, NULL, 0); |
306 | if (pdev == NULL) { | 284 | if (IS_ERR(pdev)) { |
307 | printk(KERN_ERR PREFIX "Error registering bay device\n"); | 285 | printk(KERN_ERR PREFIX "Error registering bay device\n"); |
308 | goto bay_add_err; | 286 | goto bay_add_err; |
309 | } | 287 | } |
@@ -339,52 +317,6 @@ bay_add_err: | |||
339 | return -ENODEV; | 317 | return -ENODEV; |
340 | } | 318 | } |
341 | 319 | ||
342 | static int acpi_bay_remove(struct acpi_device *device, int type) | ||
343 | { | ||
344 | /*** FIXME: do something here */ | ||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | /** | ||
349 | * bay_create_acpi_device - add new devices to acpi | ||
350 | * @handle - handle of the device to add | ||
351 | * | ||
352 | * This function will create a new acpi_device for the given | ||
353 | * handle if one does not exist already. This should cause | ||
354 | * acpi to scan for drivers for the given devices, and call | ||
355 | * matching driver's add routine. | ||
356 | * | ||
357 | * Returns a pointer to the acpi_device corresponding to the handle. | ||
358 | */ | ||
359 | static struct acpi_device * bay_create_acpi_device(acpi_handle handle) | ||
360 | { | ||
361 | struct acpi_device *device = NULL; | ||
362 | struct acpi_device *parent_device; | ||
363 | acpi_handle parent; | ||
364 | int ret; | ||
365 | |||
366 | bay_dprintk(handle, "Trying to get device"); | ||
367 | if (acpi_bus_get_device(handle, &device)) { | ||
368 | /* | ||
369 | * no device created for this object, | ||
370 | * so we should create one. | ||
371 | */ | ||
372 | bay_dprintk(handle, "No device for handle"); | ||
373 | acpi_get_parent(handle, &parent); | ||
374 | if (acpi_bus_get_device(parent, &parent_device)) | ||
375 | parent_device = NULL; | ||
376 | |||
377 | ret = acpi_bus_add(&device, parent_device, handle, | ||
378 | ACPI_BUS_TYPE_DEVICE); | ||
379 | if (ret) { | ||
380 | pr_debug("error adding bus, %x\n", | ||
381 | -ret); | ||
382 | return NULL; | ||
383 | } | ||
384 | } | ||
385 | return device; | ||
386 | } | ||
387 | |||
388 | /** | 320 | /** |
389 | * bay_notify - act upon an acpi bay notification | 321 | * bay_notify - act upon an acpi bay notification |
390 | * @handle: the bay handle | 322 | * @handle: the bay handle |
@@ -394,38 +326,19 @@ static struct acpi_device * bay_create_acpi_device(acpi_handle handle) | |||
394 | */ | 326 | */ |
395 | static void bay_notify(acpi_handle handle, u32 event, void *data) | 327 | static void bay_notify(acpi_handle handle, u32 event, void *data) |
396 | { | 328 | { |
397 | struct acpi_device *dev; | 329 | struct bay *bay_dev = (struct bay *)data; |
330 | struct device *dev = &bay_dev->pdev->dev; | ||
398 | 331 | ||
399 | bay_dprintk(handle, "Bay event"); | 332 | bay_dprintk(handle, "Bay event"); |
400 | 333 | ||
401 | switch(event) { | 334 | switch(event) { |
402 | case ACPI_NOTIFY_BUS_CHECK: | 335 | case ACPI_NOTIFY_BUS_CHECK: |
403 | printk("Bus Check\n"); | ||
404 | case ACPI_NOTIFY_DEVICE_CHECK: | 336 | case ACPI_NOTIFY_DEVICE_CHECK: |
405 | printk("Device Check\n"); | ||
406 | dev = bay_create_acpi_device(handle); | ||
407 | if (dev) | ||
408 | acpi_bus_generate_event(dev, event, 0); | ||
409 | else | ||
410 | printk("No device for generating event\n"); | ||
411 | /* wouldn't it be a good idea to just rescan SATA | ||
412 | * right here? | ||
413 | */ | ||
414 | break; | ||
415 | case ACPI_NOTIFY_EJECT_REQUEST: | 337 | case ACPI_NOTIFY_EJECT_REQUEST: |
416 | printk("Eject request\n"); | 338 | kobject_uevent(&dev->kobj, KOBJ_CHANGE); |
417 | dev = bay_create_acpi_device(handle); | ||
418 | if (dev) | ||
419 | acpi_bus_generate_event(dev, event, 0); | ||
420 | else | ||
421 | printk("No device for generating eventn"); | ||
422 | |||
423 | /* wouldn't it be a good idea to just call the | ||
424 | * eject_device here if we were a SATA device? | ||
425 | */ | ||
426 | break; | 339 | break; |
427 | default: | 340 | default: |
428 | printk("unknown event %d\n", event); | 341 | printk(KERN_ERR PREFIX "Bay: unknown event %d\n", event); |
429 | } | 342 | } |
430 | } | 343 | } |
431 | 344 | ||
@@ -457,10 +370,6 @@ static int __init bay_init(void) | |||
457 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, | 370 | acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, |
458 | ACPI_UINT32_MAX, find_bay, &bays, NULL); | 371 | ACPI_UINT32_MAX, find_bay, &bays, NULL); |
459 | 372 | ||
460 | if (bays) | ||
461 | if ((acpi_bus_register_driver(&acpi_bay_driver) < 0)) | ||
462 | printk(KERN_ERR "Unable to register bay driver\n"); | ||
463 | |||
464 | if (!bays) | 373 | if (!bays) |
465 | return -ENODEV; | 374 | return -ENODEV; |
466 | 375 | ||
@@ -481,8 +390,6 @@ static void __exit bay_exit(void) | |||
481 | kfree(bay->name); | 390 | kfree(bay->name); |
482 | kfree(bay); | 391 | kfree(bay); |
483 | } | 392 | } |
484 | |||
485 | acpi_bus_unregister_driver(&acpi_bay_driver); | ||
486 | } | 393 | } |
487 | 394 | ||
488 | postcore_initcall(bay_init); | 395 | postcore_initcall(bay_init); |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index c26468da4295..fd37e19360d0 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include <acpi/acpi_drivers.h> | 39 | #include <acpi/acpi_drivers.h> |
40 | 40 | ||
41 | #define _COMPONENT ACPI_BUS_COMPONENT | 41 | #define _COMPONENT ACPI_BUS_COMPONENT |
42 | ACPI_MODULE_NAME("acpi_bus") | 42 | ACPI_MODULE_NAME("bus"); |
43 | #ifdef CONFIG_X86 | 43 | #ifdef CONFIG_X86 |
44 | extern void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger); | 44 | extern void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger); |
45 | #endif | 45 | #endif |
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index c726612fafb6..cb4110b50cd0 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c | |||
@@ -34,7 +34,6 @@ | |||
34 | #include <acpi/acpi_drivers.h> | 34 | #include <acpi/acpi_drivers.h> |
35 | 35 | ||
36 | #define ACPI_BUTTON_COMPONENT 0x00080000 | 36 | #define ACPI_BUTTON_COMPONENT 0x00080000 |
37 | #define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver" | ||
38 | #define ACPI_BUTTON_CLASS "button" | 37 | #define ACPI_BUTTON_CLASS "button" |
39 | #define ACPI_BUTTON_FILE_INFO "info" | 38 | #define ACPI_BUTTON_FILE_INFO "info" |
40 | #define ACPI_BUTTON_FILE_STATE "state" | 39 | #define ACPI_BUTTON_FILE_STATE "state" |
@@ -61,10 +60,10 @@ | |||
61 | #define ACPI_BUTTON_TYPE_LID 0x05 | 60 | #define ACPI_BUTTON_TYPE_LID 0x05 |
62 | 61 | ||
63 | #define _COMPONENT ACPI_BUTTON_COMPONENT | 62 | #define _COMPONENT ACPI_BUTTON_COMPONENT |
64 | ACPI_MODULE_NAME("acpi_button") | 63 | ACPI_MODULE_NAME("button"); |
65 | 64 | ||
66 | MODULE_AUTHOR("Paul Diefenbaugh"); | 65 | MODULE_AUTHOR("Paul Diefenbaugh"); |
67 | MODULE_DESCRIPTION(ACPI_BUTTON_DRIVER_NAME); | 66 | MODULE_DESCRIPTION("ACPI Button Driver"); |
68 | MODULE_LICENSE("GPL"); | 67 | MODULE_LICENSE("GPL"); |
69 | 68 | ||
70 | static int acpi_button_add(struct acpi_device *device); | 69 | static int acpi_button_add(struct acpi_device *device); |
@@ -73,7 +72,7 @@ static int acpi_button_info_open_fs(struct inode *inode, struct file *file); | |||
73 | static int acpi_button_state_open_fs(struct inode *inode, struct file *file); | 72 | static int acpi_button_state_open_fs(struct inode *inode, struct file *file); |
74 | 73 | ||
75 | static struct acpi_driver acpi_button_driver = { | 74 | static struct acpi_driver acpi_button_driver = { |
76 | .name = ACPI_BUTTON_DRIVER_NAME, | 75 | .name = "button", |
77 | .class = ACPI_BUTTON_CLASS, | 76 | .class = ACPI_BUTTON_CLASS, |
78 | .ids = "button_power,button_sleep,PNP0C0D,PNP0C0C,PNP0C0E", | 77 | .ids = "button_power,button_sleep,PNP0C0D,PNP0C0C,PNP0C0E", |
79 | .ops = { | 78 | .ops = { |
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c index 4a9b7bf6f44e..f9db4f444bd0 100644 --- a/drivers/acpi/cm_sbs.c +++ b/drivers/acpi/cm_sbs.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <acpi/actypes.h> | 31 | #include <acpi/actypes.h> |
32 | #include <acpi/acutils.h> | 32 | #include <acpi/acutils.h> |
33 | 33 | ||
34 | ACPI_MODULE_NAME("cm_sbs") | 34 | ACPI_MODULE_NAME("cm_sbs"); |
35 | #define ACPI_AC_CLASS "ac_adapter" | 35 | #define ACPI_AC_CLASS "ac_adapter" |
36 | #define ACPI_BATTERY_CLASS "battery" | 36 | #define ACPI_BATTERY_CLASS "battery" |
37 | #define ACPI_SBS_COMPONENT 0x00080000 | 37 | #define ACPI_SBS_COMPONENT 0x00080000 |
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 69a68fd394cf..0930d9413dfa 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <acpi/acpi_drivers.h> | 35 | #include <acpi/acpi_drivers.h> |
36 | #include <acpi/container.h> | 36 | #include <acpi/container.h> |
37 | 37 | ||
38 | #define ACPI_CONTAINER_DRIVER_NAME "ACPI container driver" | ||
39 | #define ACPI_CONTAINER_DEVICE_NAME "ACPI container device" | 38 | #define ACPI_CONTAINER_DEVICE_NAME "ACPI container device" |
40 | #define ACPI_CONTAINER_CLASS "container" | 39 | #define ACPI_CONTAINER_CLASS "container" |
41 | 40 | ||
@@ -44,10 +43,10 @@ | |||
44 | 43 | ||
45 | #define ACPI_CONTAINER_COMPONENT 0x01000000 | 44 | #define ACPI_CONTAINER_COMPONENT 0x01000000 |
46 | #define _COMPONENT ACPI_CONTAINER_COMPONENT | 45 | #define _COMPONENT ACPI_CONTAINER_COMPONENT |
47 | ACPI_MODULE_NAME("acpi_container") | 46 | ACPI_MODULE_NAME("container"); |
48 | 47 | ||
49 | MODULE_AUTHOR("Anil S Keshavamurthy"); | 48 | MODULE_AUTHOR("Anil S Keshavamurthy"); |
50 | MODULE_DESCRIPTION(ACPI_CONTAINER_DRIVER_NAME); | 49 | MODULE_DESCRIPTION("ACPI container driver"); |
51 | MODULE_LICENSE("GPL"); | 50 | MODULE_LICENSE("GPL"); |
52 | 51 | ||
53 | #define ACPI_STA_PRESENT (0x00000001) | 52 | #define ACPI_STA_PRESENT (0x00000001) |
@@ -56,7 +55,7 @@ static int acpi_container_add(struct acpi_device *device); | |||
56 | static int acpi_container_remove(struct acpi_device *device, int type); | 55 | static int acpi_container_remove(struct acpi_device *device, int type); |
57 | 56 | ||
58 | static struct acpi_driver acpi_container_driver = { | 57 | static struct acpi_driver acpi_container_driver = { |
59 | .name = ACPI_CONTAINER_DRIVER_NAME, | 58 | .name = "container", |
60 | .class = ACPI_CONTAINER_CLASS, | 59 | .class = ACPI_CONTAINER_CLASS, |
61 | .ids = "ACPI0004,PNP0A05,PNP0A06", | 60 | .ids = "ACPI0004,PNP0A05,PNP0A06", |
62 | .ops = { | 61 | .ops = { |
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c index d48f65a8f658..bf513e07b773 100644 --- a/drivers/acpi/debug.c +++ b/drivers/acpi/debug.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <acpi/acglobal.h> | 12 | #include <acpi/acglobal.h> |
13 | 13 | ||
14 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | 14 | #define _COMPONENT ACPI_SYSTEM_COMPONENT |
15 | ACPI_MODULE_NAME("debug") | 15 | ACPI_MODULE_NAME("debug"); |
16 | 16 | ||
17 | #ifdef MODULE_PARAM_PREFIX | 17 | #ifdef MODULE_PARAM_PREFIX |
18 | #undef MODULE_PARAM_PREFIX | 18 | #undef MODULE_PARAM_PREFIX |
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c index 1cbe61905824..1683e5c5b94c 100644 --- a/drivers/acpi/dispatcher/dsmethod.c +++ b/drivers/acpi/dispatcher/dsmethod.c | |||
@@ -231,10 +231,8 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, | |||
231 | * Obtain the method mutex if necessary. Do not acquire mutex for a | 231 | * Obtain the method mutex if necessary. Do not acquire mutex for a |
232 | * recursive call. | 232 | * recursive call. |
233 | */ | 233 | */ |
234 | if (!walk_state || | 234 | if (acpi_os_get_thread_id() != |
235 | !obj_desc->method.mutex->mutex.owner_thread || | 235 | obj_desc->method.mutex->mutex.owner_thread_id) { |
236 | (walk_state->thread != | ||
237 | obj_desc->method.mutex->mutex.owner_thread)) { | ||
238 | /* | 236 | /* |
239 | * Acquire the method mutex. This releases the interpreter if we | 237 | * Acquire the method mutex. This releases the interpreter if we |
240 | * block (and reacquires it before it returns) | 238 | * block (and reacquires it before it returns) |
@@ -248,14 +246,14 @@ acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node, | |||
248 | } | 246 | } |
249 | 247 | ||
250 | /* Update the mutex and walk info and save the original sync_level */ | 248 | /* Update the mutex and walk info and save the original sync_level */ |
249 | obj_desc->method.mutex->mutex.owner_thread_id = | ||
250 | acpi_os_get_thread_id(); | ||
251 | 251 | ||
252 | if (walk_state) { | 252 | if (walk_state) { |
253 | obj_desc->method.mutex->mutex. | 253 | obj_desc->method.mutex->mutex. |
254 | original_sync_level = | 254 | original_sync_level = |
255 | walk_state->thread->current_sync_level; | 255 | walk_state->thread->current_sync_level; |
256 | 256 | ||
257 | obj_desc->method.mutex->mutex.owner_thread = | ||
258 | walk_state->thread; | ||
259 | walk_state->thread->current_sync_level = | 257 | walk_state->thread->current_sync_level = |
260 | obj_desc->method.sync_level; | 258 | obj_desc->method.sync_level; |
261 | } else { | 259 | } else { |
@@ -569,7 +567,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc, | |||
569 | 567 | ||
570 | acpi_os_release_mutex(method_desc->method.mutex->mutex. | 568 | acpi_os_release_mutex(method_desc->method.mutex->mutex. |
571 | os_mutex); | 569 | os_mutex); |
572 | method_desc->method.mutex->mutex.owner_thread = NULL; | 570 | method_desc->method.mutex->mutex.owner_thread_id = ACPI_MUTEX_NOT_ACQUIRED; |
573 | } | 571 | } |
574 | } | 572 | } |
575 | 573 | ||
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 688e83a16906..54a697f9aa18 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c | |||
@@ -32,11 +32,11 @@ | |||
32 | #include <acpi/acpi_bus.h> | 32 | #include <acpi/acpi_bus.h> |
33 | #include <acpi/acpi_drivers.h> | 33 | #include <acpi/acpi_drivers.h> |
34 | 34 | ||
35 | #define ACPI_DOCK_DRIVER_NAME "ACPI Dock Station Driver" | 35 | #define ACPI_DOCK_DRIVER_DESCRIPTION "ACPI Dock Station Driver" |
36 | 36 | ||
37 | ACPI_MODULE_NAME("dock") | 37 | ACPI_MODULE_NAME("dock"); |
38 | MODULE_AUTHOR("Kristen Carlson Accardi"); | 38 | MODULE_AUTHOR("Kristen Carlson Accardi"); |
39 | MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_NAME); | 39 | MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_DESCRIPTION); |
40 | MODULE_LICENSE("GPL"); | 40 | MODULE_LICENSE("GPL"); |
41 | 41 | ||
42 | static struct atomic_notifier_head dock_notifier_list; | 42 | static struct atomic_notifier_head dock_notifier_list; |
@@ -741,7 +741,7 @@ static int dock_add(acpi_handle handle) | |||
741 | goto dock_add_err; | 741 | goto dock_add_err; |
742 | } | 742 | } |
743 | 743 | ||
744 | printk(KERN_INFO PREFIX "%s \n", ACPI_DOCK_DRIVER_NAME); | 744 | printk(KERN_INFO PREFIX "%s \n", ACPI_DOCK_DRIVER_DESCRIPTION); |
745 | 745 | ||
746 | return 0; | 746 | return 0; |
747 | 747 | ||
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 743ce27fa0bb..ab6888373795 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -38,11 +38,10 @@ | |||
38 | #include <acpi/actypes.h> | 38 | #include <acpi/actypes.h> |
39 | 39 | ||
40 | #define _COMPONENT ACPI_EC_COMPONENT | 40 | #define _COMPONENT ACPI_EC_COMPONENT |
41 | ACPI_MODULE_NAME("acpi_ec") | 41 | ACPI_MODULE_NAME("ec"); |
42 | #define ACPI_EC_COMPONENT 0x00100000 | 42 | #define ACPI_EC_COMPONENT 0x00100000 |
43 | #define ACPI_EC_CLASS "embedded_controller" | 43 | #define ACPI_EC_CLASS "embedded_controller" |
44 | #define ACPI_EC_HID "PNP0C09" | 44 | #define ACPI_EC_HID "PNP0C09" |
45 | #define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" | ||
46 | #define ACPI_EC_DEVICE_NAME "Embedded Controller" | 45 | #define ACPI_EC_DEVICE_NAME "Embedded Controller" |
47 | #define ACPI_EC_FILE_INFO "info" | 46 | #define ACPI_EC_FILE_INFO "info" |
48 | #undef PREFIX | 47 | #undef PREFIX |
@@ -80,7 +79,7 @@ static int acpi_ec_stop(struct acpi_device *device, int type); | |||
80 | static int acpi_ec_add(struct acpi_device *device); | 79 | static int acpi_ec_add(struct acpi_device *device); |
81 | 80 | ||
82 | static struct acpi_driver acpi_ec_driver = { | 81 | static struct acpi_driver acpi_ec_driver = { |
83 | .name = ACPI_EC_DRIVER_NAME, | 82 | .name = "ec", |
84 | .class = ACPI_EC_CLASS, | 83 | .class = ACPI_EC_CLASS, |
85 | .ids = ACPI_EC_HID, | 84 | .ids = ACPI_EC_HID, |
86 | .ops = { | 85 | .ops = { |
@@ -280,8 +279,10 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command, | |||
280 | mutex_lock(&ec->lock); | 279 | mutex_lock(&ec->lock); |
281 | if (ec->global_lock) { | 280 | if (ec->global_lock) { |
282 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); | 281 | status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); |
283 | if (ACPI_FAILURE(status)) | 282 | if (ACPI_FAILURE(status)) { |
283 | mutex_unlock(&ec->lock); | ||
284 | return -ENODEV; | 284 | return -ENODEV; |
285 | } | ||
285 | } | 286 | } |
286 | 287 | ||
287 | /* Make sure GPE is enabled before doing transaction */ | 288 | /* Make sure GPE is enabled before doing transaction */ |
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index 959a893c8d1f..3b23562e6f92 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <acpi/acpi_drivers.h> | 13 | #include <acpi/acpi_drivers.h> |
14 | 14 | ||
15 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | 15 | #define _COMPONENT ACPI_SYSTEM_COMPONENT |
16 | ACPI_MODULE_NAME("event") | 16 | ACPI_MODULE_NAME("event"); |
17 | 17 | ||
18 | /* Global vars for handling event proc entry */ | 18 | /* Global vars for handling event proc entry */ |
19 | static DEFINE_SPINLOCK(acpi_system_event_lock); | 19 | static DEFINE_SPINLOCK(acpi_system_event_lock); |
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/events/evgpe.c index dfac3ecc596e..635ba449ebc2 100644 --- a/drivers/acpi/events/evgpe.c +++ b/drivers/acpi/events/evgpe.c | |||
@@ -636,17 +636,6 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number) | |||
636 | } | 636 | } |
637 | } | 637 | } |
638 | 638 | ||
639 | if (!acpi_gbl_system_awake_and_running) { | ||
640 | /* | ||
641 | * We just woke up because of a wake GPE. Disable any further GPEs | ||
642 | * until we are fully up and running (Only wake GPEs should be enabled | ||
643 | * at this time, but we just brute-force disable them all.) | ||
644 | * 1) We must disable this particular wake GPE so it won't fire again | ||
645 | * 2) We want to disable all wake GPEs, since we are now awake | ||
646 | */ | ||
647 | (void)acpi_hw_disable_all_gpes(); | ||
648 | } | ||
649 | |||
650 | /* | 639 | /* |
651 | * Dispatch the GPE to either an installed handler, or the control method | 640 | * Dispatch the GPE to either an installed handler, or the control method |
652 | * associated with this GPE (_Lxx or _Exx). If a handler exists, we invoke | 641 | * associated with this GPE (_Lxx or _Exx). If a handler exists, we invoke |
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c index 1b784ffe54c3..d572700197f3 100644 --- a/drivers/acpi/events/evmisc.c +++ b/drivers/acpi/events/evmisc.c | |||
@@ -196,12 +196,11 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node, | |||
196 | notify_info->notify.value = (u16) notify_value; | 196 | notify_info->notify.value = (u16) notify_value; |
197 | notify_info->notify.handler_obj = handler_obj; | 197 | notify_info->notify.handler_obj = handler_obj; |
198 | 198 | ||
199 | status = | 199 | acpi_ex_relinquish_interpreter(); |
200 | acpi_os_execute(OSL_NOTIFY_HANDLER, acpi_ev_notify_dispatch, | 200 | |
201 | notify_info); | 201 | acpi_ev_notify_dispatch(notify_info); |
202 | if (ACPI_FAILURE(status)) { | 202 | |
203 | acpi_ut_delete_generic_state(notify_info); | 203 | acpi_ex_reacquire_interpreter(); |
204 | } | ||
205 | } | 204 | } |
206 | 205 | ||
207 | if (!handler_obj) { | 206 | if (!handler_obj) { |
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c index 68d283fd60e7..1a73c14df2c5 100644 --- a/drivers/acpi/executer/exdump.c +++ b/drivers/acpi/executer/exdump.c | |||
@@ -134,7 +134,7 @@ static struct acpi_exdump_info acpi_ex_dump_method[8] = { | |||
134 | static struct acpi_exdump_info acpi_ex_dump_mutex[5] = { | 134 | static struct acpi_exdump_info acpi_ex_dump_mutex[5] = { |
135 | {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL}, | 135 | {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_mutex), NULL}, |
136 | {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"}, | 136 | {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(mutex.sync_level), "Sync Level"}, |
137 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread), "Owner Thread"}, | 137 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.owner_thread_id), "Owner Thread"}, |
138 | {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth), | 138 | {ACPI_EXD_UINT16, ACPI_EXD_OFFSET(mutex.acquisition_depth), |
139 | "Acquire Depth"}, | 139 | "Acquire Depth"}, |
140 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"} | 140 | {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(mutex.os_mutex), "OsMutex"} |
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/executer/exmutex.c index 5101bad5baf8..4eb883bda6ae 100644 --- a/drivers/acpi/executer/exmutex.c +++ b/drivers/acpi/executer/exmutex.c | |||
@@ -66,10 +66,9 @@ acpi_ex_link_mutex(union acpi_operand_object *obj_desc, | |||
66 | * | 66 | * |
67 | ******************************************************************************/ | 67 | ******************************************************************************/ |
68 | 68 | ||
69 | void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc) | 69 | void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc, |
70 | struct acpi_thread_state *thread) | ||
70 | { | 71 | { |
71 | struct acpi_thread_state *thread = obj_desc->mutex.owner_thread; | ||
72 | |||
73 | if (!thread) { | 72 | if (!thread) { |
74 | return; | 73 | return; |
75 | } | 74 | } |
@@ -174,16 +173,13 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, | |||
174 | 173 | ||
175 | /* Support for multiple acquires by the owning thread */ | 174 | /* Support for multiple acquires by the owning thread */ |
176 | 175 | ||
177 | if (obj_desc->mutex.owner_thread) { | 176 | if (obj_desc->mutex.owner_thread_id == acpi_os_get_thread_id()) { |
178 | if (obj_desc->mutex.owner_thread->thread_id == | 177 | /* |
179 | walk_state->thread->thread_id) { | 178 | * The mutex is already owned by this thread, just increment the |
180 | /* | 179 | * acquisition depth |
181 | * The mutex is already owned by this thread, just increment the | 180 | */ |
182 | * acquisition depth | 181 | obj_desc->mutex.acquisition_depth++; |
183 | */ | 182 | return_ACPI_STATUS(AE_OK); |
184 | obj_desc->mutex.acquisition_depth++; | ||
185 | return_ACPI_STATUS(AE_OK); | ||
186 | } | ||
187 | } | 183 | } |
188 | 184 | ||
189 | /* Acquire the mutex, wait if necessary. Special case for Global Lock */ | 185 | /* Acquire the mutex, wait if necessary. Special case for Global Lock */ |
@@ -206,7 +202,7 @@ acpi_ex_acquire_mutex(union acpi_operand_object *time_desc, | |||
206 | 202 | ||
207 | /* Have the mutex: update mutex and walk info and save the sync_level */ | 203 | /* Have the mutex: update mutex and walk info and save the sync_level */ |
208 | 204 | ||
209 | obj_desc->mutex.owner_thread = walk_state->thread; | 205 | obj_desc->mutex.owner_thread_id = acpi_os_get_thread_id(); |
210 | obj_desc->mutex.acquisition_depth = 1; | 206 | obj_desc->mutex.acquisition_depth = 1; |
211 | obj_desc->mutex.original_sync_level = | 207 | obj_desc->mutex.original_sync_level = |
212 | walk_state->thread->current_sync_level; | 208 | walk_state->thread->current_sync_level; |
@@ -246,7 +242,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
246 | 242 | ||
247 | /* The mutex must have been previously acquired in order to release it */ | 243 | /* The mutex must have been previously acquired in order to release it */ |
248 | 244 | ||
249 | if (!obj_desc->mutex.owner_thread) { | 245 | if (!obj_desc->mutex.owner_thread_id) { |
250 | ACPI_ERROR((AE_INFO, | 246 | ACPI_ERROR((AE_INFO, |
251 | "Cannot release Mutex [%4.4s], not acquired", | 247 | "Cannot release Mutex [%4.4s], not acquired", |
252 | acpi_ut_get_node_name(obj_desc->mutex.node))); | 248 | acpi_ut_get_node_name(obj_desc->mutex.node))); |
@@ -266,14 +262,14 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
266 | * The Mutex is owned, but this thread must be the owner. | 262 | * The Mutex is owned, but this thread must be the owner. |
267 | * Special case for Global Lock, any thread can release | 263 | * Special case for Global Lock, any thread can release |
268 | */ | 264 | */ |
269 | if ((obj_desc->mutex.owner_thread->thread_id != | 265 | if ((obj_desc->mutex.owner_thread_id != |
270 | walk_state->thread->thread_id) | 266 | walk_state->thread->thread_id) |
271 | && (obj_desc->mutex.os_mutex != acpi_gbl_global_lock_mutex)) { | 267 | && (obj_desc->mutex.os_mutex != acpi_gbl_global_lock_mutex)) { |
272 | ACPI_ERROR((AE_INFO, | 268 | ACPI_ERROR((AE_INFO, |
273 | "Thread %lX cannot release Mutex [%4.4s] acquired by thread %lX", | 269 | "Thread %lX cannot release Mutex [%4.4s] acquired by thread %lX", |
274 | (unsigned long)walk_state->thread->thread_id, | 270 | (unsigned long)walk_state->thread->thread_id, |
275 | acpi_ut_get_node_name(obj_desc->mutex.node), | 271 | acpi_ut_get_node_name(obj_desc->mutex.node), |
276 | (unsigned long)obj_desc->mutex.owner_thread->thread_id)); | 272 | (unsigned long)obj_desc->mutex.owner_thread_id)); |
277 | return_ACPI_STATUS(AE_AML_NOT_OWNER); | 273 | return_ACPI_STATUS(AE_AML_NOT_OWNER); |
278 | } | 274 | } |
279 | 275 | ||
@@ -300,7 +296,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
300 | 296 | ||
301 | /* Unlink the mutex from the owner's list */ | 297 | /* Unlink the mutex from the owner's list */ |
302 | 298 | ||
303 | acpi_ex_unlink_mutex(obj_desc); | 299 | acpi_ex_unlink_mutex(obj_desc, walk_state->thread); |
304 | 300 | ||
305 | /* Release the mutex, special case for Global Lock */ | 301 | /* Release the mutex, special case for Global Lock */ |
306 | 302 | ||
@@ -312,7 +308,7 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc, | |||
312 | 308 | ||
313 | /* Update the mutex and restore sync_level */ | 309 | /* Update the mutex and restore sync_level */ |
314 | 310 | ||
315 | obj_desc->mutex.owner_thread = NULL; | 311 | obj_desc->mutex.owner_thread_id = ACPI_MUTEX_NOT_ACQUIRED; |
316 | walk_state->thread->current_sync_level = | 312 | walk_state->thread->current_sync_level = |
317 | obj_desc->mutex.original_sync_level; | 313 | obj_desc->mutex.original_sync_level; |
318 | 314 | ||
@@ -367,7 +363,7 @@ void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread) | |||
367 | 363 | ||
368 | /* Mark mutex unowned */ | 364 | /* Mark mutex unowned */ |
369 | 365 | ||
370 | obj_desc->mutex.owner_thread = NULL; | 366 | obj_desc->mutex.owner_thread_id = ACPI_MUTEX_NOT_ACQUIRED; |
371 | 367 | ||
372 | /* Update Thread sync_level (Last mutex is the important one) */ | 368 | /* Update Thread sync_level (Last mutex is the important one) */ |
373 | 369 | ||
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index af22fdf73413..ec655c539492 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
@@ -36,14 +36,13 @@ | |||
36 | 36 | ||
37 | #define ACPI_FAN_COMPONENT 0x00200000 | 37 | #define ACPI_FAN_COMPONENT 0x00200000 |
38 | #define ACPI_FAN_CLASS "fan" | 38 | #define ACPI_FAN_CLASS "fan" |
39 | #define ACPI_FAN_DRIVER_NAME "ACPI Fan Driver" | ||
40 | #define ACPI_FAN_FILE_STATE "state" | 39 | #define ACPI_FAN_FILE_STATE "state" |
41 | 40 | ||
42 | #define _COMPONENT ACPI_FAN_COMPONENT | 41 | #define _COMPONENT ACPI_FAN_COMPONENT |
43 | ACPI_MODULE_NAME("acpi_fan") | 42 | ACPI_MODULE_NAME("fan"); |
44 | 43 | ||
45 | MODULE_AUTHOR("Paul Diefenbaugh"); | 44 | MODULE_AUTHOR("Paul Diefenbaugh"); |
46 | MODULE_DESCRIPTION(ACPI_FAN_DRIVER_NAME); | 45 | MODULE_DESCRIPTION("ACPI Fan Driver"); |
47 | MODULE_LICENSE("GPL"); | 46 | MODULE_LICENSE("GPL"); |
48 | 47 | ||
49 | static int acpi_fan_add(struct acpi_device *device); | 48 | static int acpi_fan_add(struct acpi_device *device); |
@@ -52,7 +51,7 @@ static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state); | |||
52 | static int acpi_fan_resume(struct acpi_device *device); | 51 | static int acpi_fan_resume(struct acpi_device *device); |
53 | 52 | ||
54 | static struct acpi_driver acpi_fan_driver = { | 53 | static struct acpi_driver acpi_fan_driver = { |
55 | .name = ACPI_FAN_DRIVER_NAME, | 54 | .name = "fan", |
56 | .class = ACPI_FAN_CLASS, | 55 | .class = ACPI_FAN_CLASS, |
57 | .ids = "PNP0C0B", | 56 | .ids = "PNP0C0B", |
58 | .ops = { | 57 | .ops = { |
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 7b6c9ff9bebe..4334c208841a 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c | |||
@@ -241,3 +241,65 @@ static int __init init_acpi_device_notify(void) | |||
241 | } | 241 | } |
242 | 242 | ||
243 | arch_initcall(init_acpi_device_notify); | 243 | arch_initcall(init_acpi_device_notify); |
244 | |||
245 | |||
246 | #if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE) | ||
247 | |||
248 | /* Every ACPI platform has a mc146818 compatible "cmos rtc". Here we find | ||
249 | * its device node and pass extra config data. This helps its driver use | ||
250 | * capabilities that the now-obsolete mc146818 didn't have, and informs it | ||
251 | * that this board's RTC is wakeup-capable (per ACPI spec). | ||
252 | */ | ||
253 | #include <linux/mc146818rtc.h> | ||
254 | |||
255 | static struct cmos_rtc_board_info rtc_info; | ||
256 | |||
257 | |||
258 | /* PNP devices are registered in a subsys_initcall(); | ||
259 | * ACPI specifies the PNP IDs to use. | ||
260 | */ | ||
261 | #include <linux/pnp.h> | ||
262 | |||
263 | static int __init pnp_match(struct device *dev, void *data) | ||
264 | { | ||
265 | static const char *ids[] = { "PNP0b00", "PNP0b01", "PNP0b02", }; | ||
266 | struct pnp_dev *pnp = to_pnp_dev(dev); | ||
267 | int i; | ||
268 | |||
269 | for (i = 0; i < ARRAY_SIZE(ids); i++) { | ||
270 | if (compare_pnp_id(pnp->id, ids[i]) != 0) | ||
271 | return 1; | ||
272 | } | ||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | static struct device *__init get_rtc_dev(void) | ||
277 | { | ||
278 | return bus_find_device(&pnp_bus_type, NULL, NULL, pnp_match); | ||
279 | } | ||
280 | |||
281 | static int __init acpi_rtc_init(void) | ||
282 | { | ||
283 | struct device *dev = get_rtc_dev(); | ||
284 | |||
285 | if (dev) { | ||
286 | rtc_info.rtc_day_alarm = acpi_gbl_FADT.day_alarm; | ||
287 | rtc_info.rtc_mon_alarm = acpi_gbl_FADT.month_alarm; | ||
288 | rtc_info.rtc_century = acpi_gbl_FADT.century; | ||
289 | |||
290 | /* NOTE: acpi_gbl_FADT->rtcs4 is NOT currently useful */ | ||
291 | |||
292 | dev->platform_data = &rtc_info; | ||
293 | |||
294 | /* RTC always wakes from S1/S2/S3, and often S4/STD */ | ||
295 | device_init_wakeup(dev, 1); | ||
296 | |||
297 | put_device(dev); | ||
298 | } else | ||
299 | pr_debug("ACPI: RTC unavailable?\n"); | ||
300 | return 0; | ||
301 | } | ||
302 | /* do this between RTC subsys_initcall() and rtc_cmos driver_initcall() */ | ||
303 | fs_initcall(acpi_rtc_init); | ||
304 | |||
305 | #endif | ||
diff --git a/drivers/acpi/hotkey.c b/drivers/acpi/hotkey.c deleted file mode 100644 index 8edfb92f7ede..000000000000 --- a/drivers/acpi/hotkey.c +++ /dev/null | |||
@@ -1,1042 +0,0 @@ | |||
1 | /* | ||
2 | * hotkey.c - ACPI Hotkey Driver ($Revision: 0.2 $) | ||
3 | * | ||
4 | * Copyright (C) 2004 Luming Yu <luming.yu@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 | #include <linux/kernel.h> | ||
25 | #include <linux/module.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/types.h> | ||
28 | #include <linux/proc_fs.h> | ||
29 | #include <linux/sched.h> | ||
30 | #include <linux/kmod.h> | ||
31 | #include <linux/seq_file.h> | ||
32 | #include <acpi/acpi_drivers.h> | ||
33 | #include <acpi/acpi_bus.h> | ||
34 | #include <asm/uaccess.h> | ||
35 | |||
36 | #define HOTKEY_ACPI_VERSION "0.1" | ||
37 | |||
38 | #define HOTKEY_PROC "hotkey" | ||
39 | #define HOTKEY_EV_CONFIG "event_config" | ||
40 | #define HOTKEY_PL_CONFIG "poll_config" | ||
41 | #define HOTKEY_ACTION "action" | ||
42 | #define HOTKEY_INFO "info" | ||
43 | |||
44 | #define ACPI_HOTK_NAME "Generic Hotkey Driver" | ||
45 | #define ACPI_HOTK_CLASS "Hotkey" | ||
46 | #define ACPI_HOTK_DEVICE_NAME "Hotkey" | ||
47 | #define ACPI_HOTK_HID "Unknown?" | ||
48 | #define ACPI_HOTKEY_COMPONENT 0x20000000 | ||
49 | |||
50 | #define ACPI_HOTKEY_EVENT 0x1 | ||
51 | #define ACPI_HOTKEY_POLLING 0x2 | ||
52 | #define ACPI_UNDEFINED_EVENT 0xf | ||
53 | |||
54 | #define RESULT_STR_LEN 80 | ||
55 | |||
56 | #define ACTION_METHOD 0 | ||
57 | #define POLL_METHOD 1 | ||
58 | |||
59 | #define IS_EVENT(e) ((e) <= 10000 && (e) >0) | ||
60 | #define IS_POLL(e) ((e) > 10000) | ||
61 | #define IS_OTHERS(e) ((e)<=0 || (e)>=20000) | ||
62 | #define _COMPONENT ACPI_HOTKEY_COMPONENT | ||
63 | ACPI_MODULE_NAME("acpi_hotkey") | ||
64 | |||
65 | MODULE_AUTHOR("luming.yu@intel.com"); | ||
66 | MODULE_DESCRIPTION(ACPI_HOTK_NAME); | ||
67 | MODULE_LICENSE("GPL"); | ||
68 | |||
69 | /* standardized internal hotkey number/event */ | ||
70 | enum { | ||
71 | /* Video Extension event */ | ||
72 | HK_EVENT_CYCLE_OUTPUT_DEVICE = 0x80, | ||
73 | HK_EVENT_OUTPUT_DEVICE_STATUS_CHANGE, | ||
74 | HK_EVENT_CYCLE_DISPLAY_OUTPUT, | ||
75 | HK_EVENT_NEXT_DISPLAY_OUTPUT, | ||
76 | HK_EVENT_PREVIOUS_DISPLAY_OUTPUT, | ||
77 | HK_EVENT_CYCLE_BRIGHTNESS, | ||
78 | HK_EVENT_INCREASE_BRIGHTNESS, | ||
79 | HK_EVENT_DECREASE_BRIGHTNESS, | ||
80 | HK_EVENT_ZERO_BRIGHTNESS, | ||
81 | HK_EVENT_DISPLAY_DEVICE_OFF, | ||
82 | |||
83 | /* Snd Card event */ | ||
84 | HK_EVENT_VOLUME_MUTE, | ||
85 | HK_EVENT_VOLUME_INCLREASE, | ||
86 | HK_EVENT_VOLUME_DECREASE, | ||
87 | |||
88 | /* running state control */ | ||
89 | HK_EVENT_ENTERRING_S3, | ||
90 | HK_EVENT_ENTERRING_S4, | ||
91 | HK_EVENT_ENTERRING_S5, | ||
92 | }; | ||
93 | |||
94 | enum conf_entry_enum { | ||
95 | bus_handle = 0, | ||
96 | bus_method = 1, | ||
97 | action_handle = 2, | ||
98 | method = 3, | ||
99 | LAST_CONF_ENTRY | ||
100 | }; | ||
101 | |||
102 | /* procdir we use */ | ||
103 | static struct proc_dir_entry *hotkey_proc_dir; | ||
104 | static struct proc_dir_entry *hotkey_config; | ||
105 | static struct proc_dir_entry *hotkey_poll_config; | ||
106 | static struct proc_dir_entry *hotkey_action; | ||
107 | static struct proc_dir_entry *hotkey_info; | ||
108 | |||
109 | /* linkage for all type of hotkey */ | ||
110 | struct acpi_hotkey_link { | ||
111 | struct list_head entries; | ||
112 | int hotkey_type; /* event or polling based hotkey */ | ||
113 | int hotkey_standard_num; /* standardized hotkey(event) number */ | ||
114 | }; | ||
115 | |||
116 | /* event based hotkey */ | ||
117 | struct acpi_event_hotkey { | ||
118 | struct acpi_hotkey_link hotkey_link; | ||
119 | int flag; | ||
120 | acpi_handle bus_handle; /* bus to install notify handler */ | ||
121 | int external_hotkey_num; /* external hotkey/event number */ | ||
122 | acpi_handle action_handle; /* acpi handle attached aml action method */ | ||
123 | char *action_method; /* action method */ | ||
124 | }; | ||
125 | |||
126 | /* | ||
127 | * There are two ways to poll status | ||
128 | * 1. directy call read_xxx method, without any arguments passed in | ||
129 | * 2. call write_xxx method, with arguments passed in, you need | ||
130 | * the result is saved in acpi_polling_hotkey.poll_result. | ||
131 | * anthoer read command through polling interface. | ||
132 | * | ||
133 | */ | ||
134 | |||
135 | /* polling based hotkey */ | ||
136 | struct acpi_polling_hotkey { | ||
137 | struct acpi_hotkey_link hotkey_link; | ||
138 | int flag; | ||
139 | acpi_handle poll_handle; /* acpi handle attached polling method */ | ||
140 | char *poll_method; /* poll method */ | ||
141 | acpi_handle action_handle; /* acpi handle attached action method */ | ||
142 | char *action_method; /* action method */ | ||
143 | union acpi_object *poll_result; /* polling_result */ | ||
144 | struct proc_dir_entry *proc; | ||
145 | }; | ||
146 | |||
147 | /* hotkey object union */ | ||
148 | union acpi_hotkey { | ||
149 | struct list_head entries; | ||
150 | struct acpi_hotkey_link link; | ||
151 | struct acpi_event_hotkey event_hotkey; | ||
152 | struct acpi_polling_hotkey poll_hotkey; | ||
153 | }; | ||
154 | |||
155 | /* hotkey object list */ | ||
156 | struct acpi_hotkey_list { | ||
157 | struct list_head *entries; | ||
158 | int count; | ||
159 | }; | ||
160 | |||
161 | static int auto_hotkey_add(struct acpi_device *device); | ||
162 | static int auto_hotkey_remove(struct acpi_device *device, int type); | ||
163 | |||
164 | static struct acpi_driver hotkey_driver = { | ||
165 | .name = ACPI_HOTK_NAME, | ||
166 | .class = ACPI_HOTK_CLASS, | ||
167 | .ids = ACPI_HOTK_HID, | ||
168 | .ops = { | ||
169 | .add = auto_hotkey_add, | ||
170 | .remove = auto_hotkey_remove, | ||
171 | }, | ||
172 | }; | ||
173 | |||
174 | static void free_hotkey_device(union acpi_hotkey *key); | ||
175 | static void free_hotkey_buffer(union acpi_hotkey *key); | ||
176 | static void free_poll_hotkey_buffer(union acpi_hotkey *key); | ||
177 | static int hotkey_open_config(struct inode *inode, struct file *file); | ||
178 | static int hotkey_poll_open_config(struct inode *inode, struct file *file); | ||
179 | static ssize_t hotkey_write_config(struct file *file, | ||
180 | const char __user * buffer, | ||
181 | size_t count, loff_t * data); | ||
182 | static int hotkey_info_open_fs(struct inode *inode, struct file *file); | ||
183 | static int hotkey_action_open_fs(struct inode *inode, struct file *file); | ||
184 | static ssize_t hotkey_execute_aml_method(struct file *file, | ||
185 | const char __user * buffer, | ||
186 | size_t count, loff_t * data); | ||
187 | static int hotkey_config_seq_show(struct seq_file *seq, void *offset); | ||
188 | static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset); | ||
189 | static int hotkey_polling_open_fs(struct inode *inode, struct file *file); | ||
190 | static union acpi_hotkey *get_hotkey_by_event(struct | ||
191 | acpi_hotkey_list | ||
192 | *hotkey_list, int event); | ||
193 | |||
194 | /* event based config */ | ||
195 | static const struct file_operations hotkey_config_fops = { | ||
196 | .open = hotkey_open_config, | ||
197 | .read = seq_read, | ||
198 | .write = hotkey_write_config, | ||
199 | .llseek = seq_lseek, | ||
200 | .release = single_release, | ||
201 | }; | ||
202 | |||
203 | /* polling based config */ | ||
204 | static const struct file_operations hotkey_poll_config_fops = { | ||
205 | .open = hotkey_poll_open_config, | ||
206 | .read = seq_read, | ||
207 | .write = hotkey_write_config, | ||
208 | .llseek = seq_lseek, | ||
209 | .release = single_release, | ||
210 | }; | ||
211 | |||
212 | /* hotkey driver info */ | ||
213 | static const struct file_operations hotkey_info_fops = { | ||
214 | .open = hotkey_info_open_fs, | ||
215 | .read = seq_read, | ||
216 | .llseek = seq_lseek, | ||
217 | .release = single_release, | ||
218 | }; | ||
219 | |||
220 | /* action */ | ||
221 | static const struct file_operations hotkey_action_fops = { | ||
222 | .open = hotkey_action_open_fs, | ||
223 | .read = seq_read, | ||
224 | .write = hotkey_execute_aml_method, | ||
225 | .llseek = seq_lseek, | ||
226 | .release = single_release, | ||
227 | }; | ||
228 | |||
229 | /* polling results */ | ||
230 | static const struct file_operations hotkey_polling_fops = { | ||
231 | .open = hotkey_polling_open_fs, | ||
232 | .read = seq_read, | ||
233 | .llseek = seq_lseek, | ||
234 | .release = single_release, | ||
235 | }; | ||
236 | |||
237 | struct acpi_hotkey_list global_hotkey_list; /* link all ev or pl hotkey */ | ||
238 | struct list_head hotkey_entries; /* head of the list of hotkey_list */ | ||
239 | |||
240 | static int hotkey_info_seq_show(struct seq_file *seq, void *offset) | ||
241 | { | ||
242 | |||
243 | seq_printf(seq, "Hotkey generic driver ver: %s\n", HOTKEY_ACPI_VERSION); | ||
244 | |||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | static int hotkey_info_open_fs(struct inode *inode, struct file *file) | ||
249 | { | ||
250 | return single_open(file, hotkey_info_seq_show, PDE(inode)->data); | ||
251 | } | ||
252 | |||
253 | static char *format_result(union acpi_object *object) | ||
254 | { | ||
255 | char *buf; | ||
256 | |||
257 | buf = kzalloc(RESULT_STR_LEN, GFP_KERNEL); | ||
258 | if (!buf) | ||
259 | return NULL; | ||
260 | /* Now, just support integer type */ | ||
261 | if (object->type == ACPI_TYPE_INTEGER) | ||
262 | sprintf(buf, "%d\n", (u32) object->integer.value); | ||
263 | return buf; | ||
264 | } | ||
265 | |||
266 | static int hotkey_polling_seq_show(struct seq_file *seq, void *offset) | ||
267 | { | ||
268 | struct acpi_polling_hotkey *poll_hotkey = seq->private; | ||
269 | char *buf; | ||
270 | |||
271 | |||
272 | if (poll_hotkey->poll_result) { | ||
273 | buf = format_result(poll_hotkey->poll_result); | ||
274 | if (buf) | ||
275 | seq_printf(seq, "%s", buf); | ||
276 | kfree(buf); | ||
277 | } | ||
278 | return 0; | ||
279 | } | ||
280 | |||
281 | static int hotkey_polling_open_fs(struct inode *inode, struct file *file) | ||
282 | { | ||
283 | return single_open(file, hotkey_polling_seq_show, PDE(inode)->data); | ||
284 | } | ||
285 | |||
286 | static int hotkey_action_open_fs(struct inode *inode, struct file *file) | ||
287 | { | ||
288 | return single_open(file, hotkey_info_seq_show, PDE(inode)->data); | ||
289 | } | ||
290 | |||
291 | /* Mapping external hotkey number to standardized hotkey event num */ | ||
292 | static int hotkey_get_internal_event(int event, struct acpi_hotkey_list *list) | ||
293 | { | ||
294 | struct list_head *entries; | ||
295 | int val = -1; | ||
296 | |||
297 | |||
298 | list_for_each(entries, list->entries) { | ||
299 | union acpi_hotkey *key = | ||
300 | container_of(entries, union acpi_hotkey, entries); | ||
301 | if (key->link.hotkey_type == ACPI_HOTKEY_EVENT | ||
302 | && key->event_hotkey.external_hotkey_num == event) { | ||
303 | val = key->link.hotkey_standard_num; | ||
304 | break; | ||
305 | } | ||
306 | } | ||
307 | |||
308 | return val; | ||
309 | } | ||
310 | |||
311 | static void | ||
312 | acpi_hotkey_notify_handler(acpi_handle handle, u32 event, void *data) | ||
313 | { | ||
314 | struct acpi_device *device = NULL; | ||
315 | u32 internal_event; | ||
316 | |||
317 | |||
318 | if (acpi_bus_get_device(handle, &device)) | ||
319 | return; | ||
320 | |||
321 | internal_event = hotkey_get_internal_event(event, &global_hotkey_list); | ||
322 | acpi_bus_generate_event(device, internal_event, 0); | ||
323 | |||
324 | return; | ||
325 | } | ||
326 | |||
327 | /* Need to invent automatically hotkey add method */ | ||
328 | static int auto_hotkey_add(struct acpi_device *device) | ||
329 | { | ||
330 | /* Implement me */ | ||
331 | return 0; | ||
332 | } | ||
333 | |||
334 | /* Need to invent automatically hotkey remove method */ | ||
335 | static int auto_hotkey_remove(struct acpi_device *device, int type) | ||
336 | { | ||
337 | /* Implement me */ | ||
338 | return 0; | ||
339 | } | ||
340 | |||
341 | /* Create a proc file for each polling method */ | ||
342 | static int create_polling_proc(union acpi_hotkey *device) | ||
343 | { | ||
344 | struct proc_dir_entry *proc; | ||
345 | char proc_name[80]; | ||
346 | mode_t mode; | ||
347 | |||
348 | mode = S_IFREG | S_IRUGO | S_IWUGO; | ||
349 | |||
350 | sprintf(proc_name, "%d", device->link.hotkey_standard_num); | ||
351 | /* | ||
352 | strcat(proc_name, device->poll_hotkey.poll_method); | ||
353 | */ | ||
354 | proc = create_proc_entry(proc_name, mode, hotkey_proc_dir); | ||
355 | |||
356 | if (!proc) { | ||
357 | return -ENODEV; | ||
358 | } else { | ||
359 | proc->proc_fops = &hotkey_polling_fops; | ||
360 | proc->owner = THIS_MODULE; | ||
361 | proc->data = device; | ||
362 | proc->uid = 0; | ||
363 | proc->gid = 0; | ||
364 | device->poll_hotkey.proc = proc; | ||
365 | } | ||
366 | return 0; | ||
367 | } | ||
368 | |||
369 | static int hotkey_add(union acpi_hotkey *device) | ||
370 | { | ||
371 | int status = 0; | ||
372 | struct acpi_device *dev = NULL; | ||
373 | |||
374 | |||
375 | if (device->link.hotkey_type == ACPI_HOTKEY_EVENT) { | ||
376 | acpi_bus_get_device(device->event_hotkey.bus_handle, &dev); | ||
377 | status = acpi_install_notify_handler(dev->handle, | ||
378 | ACPI_DEVICE_NOTIFY, | ||
379 | acpi_hotkey_notify_handler, | ||
380 | dev); | ||
381 | } else /* Add polling hotkey */ | ||
382 | create_polling_proc(device); | ||
383 | |||
384 | global_hotkey_list.count++; | ||
385 | |||
386 | list_add_tail(&device->link.entries, global_hotkey_list.entries); | ||
387 | |||
388 | return status; | ||
389 | } | ||
390 | |||
391 | static int hotkey_remove(union acpi_hotkey *device) | ||
392 | { | ||
393 | struct list_head *entries, *next; | ||
394 | |||
395 | |||
396 | list_for_each_safe(entries, next, global_hotkey_list.entries) { | ||
397 | union acpi_hotkey *key = | ||
398 | container_of(entries, union acpi_hotkey, entries); | ||
399 | if (key->link.hotkey_standard_num == | ||
400 | device->link.hotkey_standard_num) { | ||
401 | list_del(&key->link.entries); | ||
402 | free_hotkey_device(key); | ||
403 | global_hotkey_list.count--; | ||
404 | break; | ||
405 | } | ||
406 | } | ||
407 | kfree(device); | ||
408 | return 0; | ||
409 | } | ||
410 | |||
411 | static int hotkey_update(union acpi_hotkey *key) | ||
412 | { | ||
413 | struct list_head *entries; | ||
414 | |||
415 | |||
416 | list_for_each(entries, global_hotkey_list.entries) { | ||
417 | union acpi_hotkey *tmp = | ||
418 | container_of(entries, union acpi_hotkey, entries); | ||
419 | if (tmp->link.hotkey_standard_num == | ||
420 | key->link.hotkey_standard_num) { | ||
421 | if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { | ||
422 | free_hotkey_buffer(tmp); | ||
423 | tmp->event_hotkey.bus_handle = | ||
424 | key->event_hotkey.bus_handle; | ||
425 | tmp->event_hotkey.external_hotkey_num = | ||
426 | key->event_hotkey.external_hotkey_num; | ||
427 | tmp->event_hotkey.action_handle = | ||
428 | key->event_hotkey.action_handle; | ||
429 | tmp->event_hotkey.action_method = | ||
430 | key->event_hotkey.action_method; | ||
431 | kfree(key); | ||
432 | } else { | ||
433 | /* | ||
434 | char proc_name[80]; | ||
435 | |||
436 | sprintf(proc_name, "%d", tmp->link.hotkey_standard_num); | ||
437 | strcat(proc_name, tmp->poll_hotkey.poll_method); | ||
438 | remove_proc_entry(proc_name,hotkey_proc_dir); | ||
439 | */ | ||
440 | free_poll_hotkey_buffer(tmp); | ||
441 | tmp->poll_hotkey.poll_handle = | ||
442 | key->poll_hotkey.poll_handle; | ||
443 | tmp->poll_hotkey.poll_method = | ||
444 | key->poll_hotkey.poll_method; | ||
445 | tmp->poll_hotkey.action_handle = | ||
446 | key->poll_hotkey.action_handle; | ||
447 | tmp->poll_hotkey.action_method = | ||
448 | key->poll_hotkey.action_method; | ||
449 | tmp->poll_hotkey.poll_result = | ||
450 | key->poll_hotkey.poll_result; | ||
451 | /* | ||
452 | create_polling_proc(tmp); | ||
453 | */ | ||
454 | kfree(key); | ||
455 | } | ||
456 | return 0; | ||
457 | break; | ||
458 | } | ||
459 | } | ||
460 | |||
461 | return -ENODEV; | ||
462 | } | ||
463 | |||
464 | static void free_hotkey_device(union acpi_hotkey *key) | ||
465 | { | ||
466 | struct acpi_device *dev; | ||
467 | |||
468 | |||
469 | if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { | ||
470 | acpi_bus_get_device(key->event_hotkey.bus_handle, &dev); | ||
471 | if (dev->handle) | ||
472 | acpi_remove_notify_handler(dev->handle, | ||
473 | ACPI_DEVICE_NOTIFY, | ||
474 | acpi_hotkey_notify_handler); | ||
475 | free_hotkey_buffer(key); | ||
476 | } else { | ||
477 | char proc_name[80]; | ||
478 | |||
479 | sprintf(proc_name, "%d", key->link.hotkey_standard_num); | ||
480 | /* | ||
481 | strcat(proc_name, key->poll_hotkey.poll_method); | ||
482 | */ | ||
483 | remove_proc_entry(proc_name, hotkey_proc_dir); | ||
484 | free_poll_hotkey_buffer(key); | ||
485 | } | ||
486 | kfree(key); | ||
487 | return; | ||
488 | } | ||
489 | |||
490 | static void free_hotkey_buffer(union acpi_hotkey *key) | ||
491 | { | ||
492 | /* key would never be null, action method could be */ | ||
493 | kfree(key->event_hotkey.action_method); | ||
494 | } | ||
495 | |||
496 | static void free_poll_hotkey_buffer(union acpi_hotkey *key) | ||
497 | { | ||
498 | /* key would never be null, others could be*/ | ||
499 | kfree(key->poll_hotkey.action_method); | ||
500 | kfree(key->poll_hotkey.poll_method); | ||
501 | kfree(key->poll_hotkey.poll_result); | ||
502 | } | ||
503 | static int | ||
504 | init_hotkey_device(union acpi_hotkey *key, char **config_entry, | ||
505 | int std_num, int external_num) | ||
506 | { | ||
507 | acpi_handle tmp_handle; | ||
508 | acpi_status status = AE_OK; | ||
509 | |||
510 | if (std_num < 0 || IS_POLL(std_num) || !key) | ||
511 | goto do_fail; | ||
512 | |||
513 | if (!config_entry[bus_handle] || !config_entry[action_handle] | ||
514 | || !config_entry[method]) | ||
515 | goto do_fail; | ||
516 | |||
517 | key->link.hotkey_type = ACPI_HOTKEY_EVENT; | ||
518 | key->link.hotkey_standard_num = std_num; | ||
519 | key->event_hotkey.flag = 0; | ||
520 | key->event_hotkey.action_method = config_entry[method]; | ||
521 | |||
522 | status = acpi_get_handle(NULL, config_entry[bus_handle], | ||
523 | &(key->event_hotkey.bus_handle)); | ||
524 | if (ACPI_FAILURE(status)) | ||
525 | goto do_fail_zero; | ||
526 | key->event_hotkey.external_hotkey_num = external_num; | ||
527 | status = acpi_get_handle(NULL, config_entry[action_handle], | ||
528 | &(key->event_hotkey.action_handle)); | ||
529 | if (ACPI_FAILURE(status)) | ||
530 | goto do_fail_zero; | ||
531 | status = acpi_get_handle(key->event_hotkey.action_handle, | ||
532 | config_entry[method], &tmp_handle); | ||
533 | if (ACPI_FAILURE(status)) | ||
534 | goto do_fail_zero; | ||
535 | return AE_OK; | ||
536 | do_fail_zero: | ||
537 | key->event_hotkey.action_method = NULL; | ||
538 | do_fail: | ||
539 | return -ENODEV; | ||
540 | } | ||
541 | |||
542 | static int | ||
543 | init_poll_hotkey_device(union acpi_hotkey *key, char **config_entry, | ||
544 | int std_num) | ||
545 | { | ||
546 | acpi_status status = AE_OK; | ||
547 | acpi_handle tmp_handle; | ||
548 | |||
549 | if (std_num < 0 || IS_EVENT(std_num) || !key) | ||
550 | goto do_fail; | ||
551 | if (!config_entry[bus_handle] ||!config_entry[bus_method] || | ||
552 | !config_entry[action_handle] || !config_entry[method]) | ||
553 | goto do_fail; | ||
554 | |||
555 | key->link.hotkey_type = ACPI_HOTKEY_POLLING; | ||
556 | key->link.hotkey_standard_num = std_num; | ||
557 | key->poll_hotkey.flag = 0; | ||
558 | key->poll_hotkey.poll_method = config_entry[bus_method]; | ||
559 | key->poll_hotkey.action_method = config_entry[method]; | ||
560 | |||
561 | status = acpi_get_handle(NULL, config_entry[bus_handle], | ||
562 | &(key->poll_hotkey.poll_handle)); | ||
563 | if (ACPI_FAILURE(status)) | ||
564 | goto do_fail_zero; | ||
565 | status = acpi_get_handle(key->poll_hotkey.poll_handle, | ||
566 | config_entry[bus_method], &tmp_handle); | ||
567 | if (ACPI_FAILURE(status)) | ||
568 | goto do_fail_zero; | ||
569 | status = | ||
570 | acpi_get_handle(NULL, config_entry[action_handle], | ||
571 | &(key->poll_hotkey.action_handle)); | ||
572 | if (ACPI_FAILURE(status)) | ||
573 | goto do_fail_zero; | ||
574 | status = acpi_get_handle(key->poll_hotkey.action_handle, | ||
575 | config_entry[method], &tmp_handle); | ||
576 | if (ACPI_FAILURE(status)) | ||
577 | goto do_fail_zero; | ||
578 | key->poll_hotkey.poll_result = | ||
579 | kmalloc(sizeof(union acpi_object), GFP_KERNEL); | ||
580 | if (!key->poll_hotkey.poll_result) | ||
581 | goto do_fail_zero; | ||
582 | return AE_OK; | ||
583 | |||
584 | do_fail_zero: | ||
585 | key->poll_hotkey.poll_method = NULL; | ||
586 | key->poll_hotkey.action_method = NULL; | ||
587 | do_fail: | ||
588 | return -ENODEV; | ||
589 | } | ||
590 | |||
591 | static int hotkey_open_config(struct inode *inode, struct file *file) | ||
592 | { | ||
593 | return (single_open | ||
594 | (file, hotkey_config_seq_show, PDE(inode)->data)); | ||
595 | } | ||
596 | |||
597 | static int hotkey_poll_open_config(struct inode *inode, struct file *file) | ||
598 | { | ||
599 | return (single_open | ||
600 | (file, hotkey_poll_config_seq_show, PDE(inode)->data)); | ||
601 | } | ||
602 | |||
603 | static int hotkey_config_seq_show(struct seq_file *seq, void *offset) | ||
604 | { | ||
605 | struct acpi_hotkey_list *hotkey_list = &global_hotkey_list; | ||
606 | struct list_head *entries; | ||
607 | char bus_name[ACPI_PATHNAME_MAX] = { 0 }; | ||
608 | char action_name[ACPI_PATHNAME_MAX] = { 0 }; | ||
609 | struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; | ||
610 | struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; | ||
611 | |||
612 | |||
613 | list_for_each(entries, hotkey_list->entries) { | ||
614 | union acpi_hotkey *key = | ||
615 | container_of(entries, union acpi_hotkey, entries); | ||
616 | if (key->link.hotkey_type == ACPI_HOTKEY_EVENT) { | ||
617 | acpi_get_name(key->event_hotkey.bus_handle, | ||
618 | ACPI_NAME_TYPE_MAX, &bus); | ||
619 | acpi_get_name(key->event_hotkey.action_handle, | ||
620 | ACPI_NAME_TYPE_MAX, &act); | ||
621 | seq_printf(seq, "%s:%s:%s:%d:%d\n", bus_name, | ||
622 | action_name, | ||
623 | key->event_hotkey.action_method, | ||
624 | key->link.hotkey_standard_num, | ||
625 | key->event_hotkey.external_hotkey_num); | ||
626 | } | ||
627 | } | ||
628 | seq_puts(seq, "\n"); | ||
629 | return 0; | ||
630 | } | ||
631 | |||
632 | static int hotkey_poll_config_seq_show(struct seq_file *seq, void *offset) | ||
633 | { | ||
634 | struct acpi_hotkey_list *hotkey_list = &global_hotkey_list; | ||
635 | struct list_head *entries; | ||
636 | char bus_name[ACPI_PATHNAME_MAX] = { 0 }; | ||
637 | char action_name[ACPI_PATHNAME_MAX] = { 0 }; | ||
638 | struct acpi_buffer bus = { ACPI_PATHNAME_MAX, bus_name }; | ||
639 | struct acpi_buffer act = { ACPI_PATHNAME_MAX, action_name }; | ||
640 | |||
641 | |||
642 | list_for_each(entries, hotkey_list->entries) { | ||
643 | union acpi_hotkey *key = | ||
644 | container_of(entries, union acpi_hotkey, entries); | ||
645 | if (key->link.hotkey_type == ACPI_HOTKEY_POLLING) { | ||
646 | acpi_get_name(key->poll_hotkey.poll_handle, | ||
647 | ACPI_NAME_TYPE_MAX, &bus); | ||
648 | acpi_get_name(key->poll_hotkey.action_handle, | ||
649 | ACPI_NAME_TYPE_MAX, &act); | ||
650 | seq_printf(seq, "%s:%s:%s:%s:%d\n", bus_name, | ||
651 | key->poll_hotkey.poll_method, | ||
652 | action_name, | ||
653 | key->poll_hotkey.action_method, | ||
654 | key->link.hotkey_standard_num); | ||
655 | } | ||
656 | } | ||
657 | seq_puts(seq, "\n"); | ||
658 | return 0; | ||
659 | } | ||
660 | |||
661 | static int | ||
662 | get_parms(char *config_record, int *cmd, char **config_entry, | ||
663 | int *internal_event_num, int *external_event_num) | ||
664 | { | ||
665 | /* the format of *config_record = | ||
666 | * "1:\d+:*" : "cmd:internal_event_num" | ||
667 | * "\d+:\w+:\w+:\w+:\w+:\d+:\d+" : | ||
668 | * "cmd:bus_handle:bus_method:action_handle:method:internal_event_num:external_event_num" | ||
669 | */ | ||
670 | char *tmp, *tmp1, count; | ||
671 | int i; | ||
672 | |||
673 | sscanf(config_record, "%d", cmd); | ||
674 | if (*cmd == 1) { | ||
675 | if (sscanf(config_record, "%d:%d", cmd, internal_event_num) != | ||
676 | 2) | ||
677 | goto do_fail; | ||
678 | else | ||
679 | return (6); | ||
680 | } | ||
681 | tmp = strchr(config_record, ':'); | ||
682 | if (!tmp) | ||
683 | goto do_fail; | ||
684 | tmp++; | ||
685 | for (i = 0; i < LAST_CONF_ENTRY; i++) { | ||
686 | tmp1 = strchr(tmp, ':'); | ||
687 | if (!tmp1) { | ||
688 | goto do_fail; | ||
689 | } | ||
690 | count = tmp1 - tmp; | ||
691 | config_entry[i] = kzalloc(count + 1, GFP_KERNEL); | ||
692 | if (!config_entry[i]) | ||
693 | goto handle_failure; | ||
694 | strncpy(config_entry[i], tmp, count); | ||
695 | tmp = tmp1 + 1; | ||
696 | } | ||
697 | if (sscanf(tmp, "%d:%d", internal_event_num, external_event_num) <= 0) | ||
698 | goto handle_failure; | ||
699 | if (!IS_OTHERS(*internal_event_num)) { | ||
700 | return 6; | ||
701 | } | ||
702 | handle_failure: | ||
703 | while (i-- > 0) | ||
704 | kfree(config_entry[i]); | ||
705 | do_fail: | ||
706 | return -1; | ||
707 | } | ||
708 | |||
709 | /* count is length for one input record */ | ||
710 | static ssize_t hotkey_write_config(struct file *file, | ||
711 | const char __user * buffer, | ||
712 | size_t count, loff_t * data) | ||
713 | { | ||
714 | char *config_record = NULL; | ||
715 | char *config_entry[LAST_CONF_ENTRY]; | ||
716 | int cmd, internal_event_num, external_event_num; | ||
717 | int ret = 0; | ||
718 | union acpi_hotkey *key = kzalloc(sizeof(union acpi_hotkey), GFP_KERNEL); | ||
719 | |||
720 | if (!key) | ||
721 | return -ENOMEM; | ||
722 | |||
723 | config_record = kzalloc(count + 1, GFP_KERNEL); | ||
724 | if (!config_record) { | ||
725 | kfree(key); | ||
726 | return -ENOMEM; | ||
727 | } | ||
728 | |||
729 | if (copy_from_user(config_record, buffer, count)) { | ||
730 | kfree(config_record); | ||
731 | kfree(key); | ||
732 | printk(KERN_ERR PREFIX "Invalid data\n"); | ||
733 | return -EINVAL; | ||
734 | } | ||
735 | ret = get_parms(config_record, &cmd, config_entry, | ||
736 | &internal_event_num, &external_event_num); | ||
737 | kfree(config_record); | ||
738 | if (ret != 6) { | ||
739 | printk(KERN_ERR PREFIX "Invalid data format ret=%d\n", ret); | ||
740 | return -EINVAL; | ||
741 | } | ||
742 | |||
743 | if (cmd == 1) { | ||
744 | union acpi_hotkey *tmp = NULL; | ||
745 | tmp = get_hotkey_by_event(&global_hotkey_list, | ||
746 | internal_event_num); | ||
747 | if (!tmp) | ||
748 | printk(KERN_ERR PREFIX "Invalid key\n"); | ||
749 | else | ||
750 | memcpy(key, tmp, sizeof(union acpi_hotkey)); | ||
751 | goto cont_cmd; | ||
752 | } | ||
753 | if (IS_EVENT(internal_event_num)) { | ||
754 | if (init_hotkey_device(key, config_entry, | ||
755 | internal_event_num, external_event_num)) | ||
756 | goto init_hotkey_fail; | ||
757 | } else { | ||
758 | if (init_poll_hotkey_device(key, config_entry, | ||
759 | internal_event_num)) | ||
760 | goto init_poll_hotkey_fail; | ||
761 | } | ||
762 | cont_cmd: | ||
763 | switch (cmd) { | ||
764 | case 0: | ||
765 | if (get_hotkey_by_event(&global_hotkey_list, | ||
766 | key->link.hotkey_standard_num)) | ||
767 | goto fail_out; | ||
768 | else | ||
769 | hotkey_add(key); | ||
770 | break; | ||
771 | case 1: | ||
772 | hotkey_remove(key); | ||
773 | break; | ||
774 | case 2: | ||
775 | /* key is kfree()ed if matched*/ | ||
776 | if (hotkey_update(key)) | ||
777 | goto fail_out; | ||
778 | break; | ||
779 | default: | ||
780 | goto fail_out; | ||
781 | break; | ||
782 | } | ||
783 | return count; | ||
784 | |||
785 | init_poll_hotkey_fail: /* failed init_poll_hotkey_device */ | ||
786 | kfree(config_entry[bus_method]); | ||
787 | config_entry[bus_method] = NULL; | ||
788 | init_hotkey_fail: /* failed init_hotkey_device */ | ||
789 | kfree(config_entry[method]); | ||
790 | fail_out: | ||
791 | kfree(config_entry[bus_handle]); | ||
792 | kfree(config_entry[action_handle]); | ||
793 | /* No double free since elements =NULL for error cases */ | ||
794 | if (IS_EVENT(internal_event_num)) { | ||
795 | if (config_entry[bus_method]) | ||
796 | kfree(config_entry[bus_method]); | ||
797 | free_hotkey_buffer(key); /* frees [method] */ | ||
798 | } else | ||
799 | free_poll_hotkey_buffer(key); /* frees [bus_method]+[method] */ | ||
800 | kfree(key); | ||
801 | printk(KERN_ERR PREFIX "invalid key\n"); | ||
802 | return -EINVAL; | ||
803 | } | ||
804 | |||
805 | /* | ||
806 | * This function evaluates an ACPI method, given an int as parameter, the | ||
807 | * method is searched within the scope of the handle, can be NULL. The output | ||
808 | * of the method is written is output, which can also be NULL | ||
809 | * | ||
810 | * returns 1 if write is successful, 0 else. | ||
811 | */ | ||
812 | static int write_acpi_int(acpi_handle handle, const char *method, int val, | ||
813 | struct acpi_buffer *output) | ||
814 | { | ||
815 | struct acpi_object_list params; /* list of input parameters (an int here) */ | ||
816 | union acpi_object in_obj; /* the only param we use */ | ||
817 | acpi_status status; | ||
818 | |||
819 | params.count = 1; | ||
820 | params.pointer = &in_obj; | ||
821 | in_obj.type = ACPI_TYPE_INTEGER; | ||
822 | in_obj.integer.value = val; | ||
823 | |||
824 | status = acpi_evaluate_object(handle, (char *)method, ¶ms, output); | ||
825 | |||
826 | return (status == AE_OK); | ||
827 | } | ||
828 | |||
829 | static int read_acpi_int(acpi_handle handle, const char *method, | ||
830 | union acpi_object *val) | ||
831 | { | ||
832 | struct acpi_buffer output; | ||
833 | union acpi_object out_obj; | ||
834 | acpi_status status; | ||
835 | |||
836 | output.length = sizeof(out_obj); | ||
837 | output.pointer = &out_obj; | ||
838 | |||
839 | status = acpi_evaluate_object(handle, (char *)method, NULL, &output); | ||
840 | if (val) { | ||
841 | val->integer.value = out_obj.integer.value; | ||
842 | val->type = out_obj.type; | ||
843 | } else | ||
844 | printk(KERN_ERR PREFIX "null val pointer\n"); | ||
845 | return ((status == AE_OK) | ||
846 | && (out_obj.type == ACPI_TYPE_INTEGER)); | ||
847 | } | ||
848 | |||
849 | static union acpi_hotkey *get_hotkey_by_event(struct | ||
850 | acpi_hotkey_list | ||
851 | *hotkey_list, int event) | ||
852 | { | ||
853 | struct list_head *entries; | ||
854 | |||
855 | list_for_each(entries, hotkey_list->entries) { | ||
856 | union acpi_hotkey *key = | ||
857 | container_of(entries, union acpi_hotkey, entries); | ||
858 | if (key->link.hotkey_standard_num == event) { | ||
859 | return (key); | ||
860 | } | ||
861 | } | ||
862 | return (NULL); | ||
863 | } | ||
864 | |||
865 | /* | ||
866 | * user call AML method interface: | ||
867 | * Call convention: | ||
868 | * echo "event_num: arg type : value" | ||
869 | * example: echo "1:1:30" > /proc/acpi/action | ||
870 | * Just support 1 integer arg passing to AML method | ||
871 | */ | ||
872 | |||
873 | static ssize_t hotkey_execute_aml_method(struct file *file, | ||
874 | const char __user * buffer, | ||
875 | size_t count, loff_t * data) | ||
876 | { | ||
877 | struct acpi_hotkey_list *hotkey_list = &global_hotkey_list; | ||
878 | char *arg; | ||
879 | int event, method_type, type, value; | ||
880 | union acpi_hotkey *key; | ||
881 | |||
882 | |||
883 | arg = kzalloc(count + 1, GFP_KERNEL); | ||
884 | if (!arg) | ||
885 | return -ENOMEM; | ||
886 | |||
887 | if (copy_from_user(arg, buffer, count)) { | ||
888 | kfree(arg); | ||
889 | printk(KERN_ERR PREFIX "Invalid argument 2\n"); | ||
890 | return -EINVAL; | ||
891 | } | ||
892 | |||
893 | if (sscanf(arg, "%d:%d:%d:%d", &event, &method_type, &type, &value) != | ||
894 | 4) { | ||
895 | kfree(arg); | ||
896 | printk(KERN_ERR PREFIX "Invalid argument 3\n"); | ||
897 | return -EINVAL; | ||
898 | } | ||
899 | kfree(arg); | ||
900 | if (type == ACPI_TYPE_INTEGER) { | ||
901 | key = get_hotkey_by_event(hotkey_list, event); | ||
902 | if (!key) | ||
903 | goto do_fail; | ||
904 | if (IS_EVENT(event)) | ||
905 | write_acpi_int(key->event_hotkey.action_handle, | ||
906 | key->event_hotkey.action_method, value, | ||
907 | NULL); | ||
908 | else if (IS_POLL(event)) { | ||
909 | if (method_type == POLL_METHOD) | ||
910 | read_acpi_int(key->poll_hotkey.poll_handle, | ||
911 | key->poll_hotkey.poll_method, | ||
912 | key->poll_hotkey.poll_result); | ||
913 | else if (method_type == ACTION_METHOD) | ||
914 | write_acpi_int(key->poll_hotkey.action_handle, | ||
915 | key->poll_hotkey.action_method, | ||
916 | value, NULL); | ||
917 | else | ||
918 | goto do_fail; | ||
919 | |||
920 | } | ||
921 | } else { | ||
922 | printk(KERN_WARNING "Not supported\n"); | ||
923 | return -EINVAL; | ||
924 | } | ||
925 | return count; | ||
926 | do_fail: | ||
927 | return -EINVAL; | ||
928 | |||
929 | } | ||
930 | |||
931 | static int __init hotkey_init(void) | ||
932 | { | ||
933 | int result; | ||
934 | mode_t mode = S_IFREG | S_IRUGO | S_IWUGO; | ||
935 | |||
936 | |||
937 | if (acpi_disabled) | ||
938 | return -ENODEV; | ||
939 | |||
940 | if (acpi_specific_hotkey_enabled) { | ||
941 | printk("Using specific hotkey driver\n"); | ||
942 | return -ENODEV; | ||
943 | } | ||
944 | |||
945 | hotkey_proc_dir = proc_mkdir(HOTKEY_PROC, acpi_root_dir); | ||
946 | if (!hotkey_proc_dir) { | ||
947 | return (-ENODEV); | ||
948 | } | ||
949 | hotkey_proc_dir->owner = THIS_MODULE; | ||
950 | |||
951 | hotkey_config = | ||
952 | create_proc_entry(HOTKEY_EV_CONFIG, mode, hotkey_proc_dir); | ||
953 | if (!hotkey_config) { | ||
954 | goto do_fail1; | ||
955 | } else { | ||
956 | hotkey_config->proc_fops = &hotkey_config_fops; | ||
957 | hotkey_config->data = &global_hotkey_list; | ||
958 | hotkey_config->owner = THIS_MODULE; | ||
959 | hotkey_config->uid = 0; | ||
960 | hotkey_config->gid = 0; | ||
961 | } | ||
962 | |||
963 | hotkey_poll_config = | ||
964 | create_proc_entry(HOTKEY_PL_CONFIG, mode, hotkey_proc_dir); | ||
965 | if (!hotkey_poll_config) { | ||
966 | goto do_fail2; | ||
967 | } else { | ||
968 | hotkey_poll_config->proc_fops = &hotkey_poll_config_fops; | ||
969 | hotkey_poll_config->data = &global_hotkey_list; | ||
970 | hotkey_poll_config->owner = THIS_MODULE; | ||
971 | hotkey_poll_config->uid = 0; | ||
972 | hotkey_poll_config->gid = 0; | ||
973 | } | ||
974 | |||
975 | hotkey_action = create_proc_entry(HOTKEY_ACTION, mode, hotkey_proc_dir); | ||
976 | if (!hotkey_action) { | ||
977 | goto do_fail3; | ||
978 | } else { | ||
979 | hotkey_action->proc_fops = &hotkey_action_fops; | ||
980 | hotkey_action->owner = THIS_MODULE; | ||
981 | hotkey_action->uid = 0; | ||
982 | hotkey_action->gid = 0; | ||
983 | } | ||
984 | |||
985 | hotkey_info = create_proc_entry(HOTKEY_INFO, mode, hotkey_proc_dir); | ||
986 | if (!hotkey_info) { | ||
987 | goto do_fail4; | ||
988 | } else { | ||
989 | hotkey_info->proc_fops = &hotkey_info_fops; | ||
990 | hotkey_info->owner = THIS_MODULE; | ||
991 | hotkey_info->uid = 0; | ||
992 | hotkey_info->gid = 0; | ||
993 | } | ||
994 | |||
995 | result = acpi_bus_register_driver(&hotkey_driver); | ||
996 | if (result < 0) | ||
997 | goto do_fail5; | ||
998 | global_hotkey_list.count = 0; | ||
999 | global_hotkey_list.entries = &hotkey_entries; | ||
1000 | |||
1001 | INIT_LIST_HEAD(&hotkey_entries); | ||
1002 | |||
1003 | return (0); | ||
1004 | |||
1005 | do_fail5: | ||
1006 | remove_proc_entry(HOTKEY_INFO, hotkey_proc_dir); | ||
1007 | do_fail4: | ||
1008 | remove_proc_entry(HOTKEY_ACTION, hotkey_proc_dir); | ||
1009 | do_fail3: | ||
1010 | remove_proc_entry(HOTKEY_PL_CONFIG, hotkey_proc_dir); | ||
1011 | do_fail2: | ||
1012 | remove_proc_entry(HOTKEY_EV_CONFIG, hotkey_proc_dir); | ||
1013 | do_fail1: | ||
1014 | remove_proc_entry(HOTKEY_PROC, acpi_root_dir); | ||
1015 | return (-ENODEV); | ||
1016 | } | ||
1017 | |||
1018 | static void __exit hotkey_exit(void) | ||
1019 | { | ||
1020 | struct list_head *entries, *next; | ||
1021 | |||
1022 | |||
1023 | list_for_each_safe(entries, next, global_hotkey_list.entries) { | ||
1024 | union acpi_hotkey *key = | ||
1025 | container_of(entries, union acpi_hotkey, entries); | ||
1026 | |||
1027 | acpi_os_wait_events_complete(NULL); | ||
1028 | list_del(&key->link.entries); | ||
1029 | global_hotkey_list.count--; | ||
1030 | free_hotkey_device(key); | ||
1031 | } | ||
1032 | acpi_bus_unregister_driver(&hotkey_driver); | ||
1033 | remove_proc_entry(HOTKEY_EV_CONFIG, hotkey_proc_dir); | ||
1034 | remove_proc_entry(HOTKEY_PL_CONFIG, hotkey_proc_dir); | ||
1035 | remove_proc_entry(HOTKEY_ACTION, hotkey_proc_dir); | ||
1036 | remove_proc_entry(HOTKEY_INFO, hotkey_proc_dir); | ||
1037 | remove_proc_entry(HOTKEY_PROC, acpi_root_dir); | ||
1038 | return; | ||
1039 | } | ||
1040 | |||
1041 | module_init(hotkey_init); | ||
1042 | module_exit(hotkey_exit); | ||
diff --git a/drivers/acpi/i2c_ec.c b/drivers/acpi/i2c_ec.c index 76ec8b63e69f..acab4a481897 100644 --- a/drivers/acpi/i2c_ec.c +++ b/drivers/acpi/i2c_ec.c | |||
@@ -27,18 +27,17 @@ | |||
27 | #define ACPI_EC_HC_COMPONENT 0x00080000 | 27 | #define ACPI_EC_HC_COMPONENT 0x00080000 |
28 | #define ACPI_EC_HC_CLASS "ec_hc_smbus" | 28 | #define ACPI_EC_HC_CLASS "ec_hc_smbus" |
29 | #define ACPI_EC_HC_HID "ACPI0001" | 29 | #define ACPI_EC_HC_HID "ACPI0001" |
30 | #define ACPI_EC_HC_DRIVER_NAME "ACPI EC HC smbus driver" | ||
31 | #define ACPI_EC_HC_DEVICE_NAME "EC HC smbus" | 30 | #define ACPI_EC_HC_DEVICE_NAME "EC HC smbus" |
32 | 31 | ||
33 | #define _COMPONENT ACPI_EC_HC_COMPONENT | 32 | #define _COMPONENT ACPI_EC_HC_COMPONENT |
34 | 33 | ||
35 | ACPI_MODULE_NAME("acpi_smbus") | 34 | ACPI_MODULE_NAME("i2c_ec"); |
36 | 35 | ||
37 | static int acpi_ec_hc_add(struct acpi_device *device); | 36 | static int acpi_ec_hc_add(struct acpi_device *device); |
38 | static int acpi_ec_hc_remove(struct acpi_device *device, int type); | 37 | static int acpi_ec_hc_remove(struct acpi_device *device, int type); |
39 | 38 | ||
40 | static struct acpi_driver acpi_ec_hc_driver = { | 39 | static struct acpi_driver acpi_ec_hc_driver = { |
41 | .name = ACPI_EC_HC_DRIVER_NAME, | 40 | .name = "i2c_ec", |
42 | .class = ACPI_EC_HC_CLASS, | 41 | .class = ACPI_EC_HC_CLASS, |
43 | .ids = ACPI_EC_HC_HID, | 42 | .ids = ACPI_EC_HC_HID, |
44 | .ops = { | 43 | .ops = { |
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c index c6144ca66638..1a0ed3dc409c 100644 --- a/drivers/acpi/ibm_acpi.c +++ b/drivers/acpi/ibm_acpi.c | |||
@@ -496,6 +496,10 @@ static int ibm_acpi_driver_init(void) | |||
496 | printk(IBM_INFO "%s v%s\n", IBM_DESC, IBM_VERSION); | 496 | printk(IBM_INFO "%s v%s\n", IBM_DESC, IBM_VERSION); |
497 | printk(IBM_INFO "%s\n", IBM_URL); | 497 | printk(IBM_INFO "%s\n", IBM_URL); |
498 | 498 | ||
499 | if (ibm_thinkpad_ec_found) | ||
500 | printk(IBM_INFO "ThinkPad EC firmware %s\n", | ||
501 | ibm_thinkpad_ec_found); | ||
502 | |||
499 | return 0; | 503 | return 0; |
500 | } | 504 | } |
501 | 505 | ||
@@ -2617,7 +2621,7 @@ static void __init ibm_handle_init(char *name, | |||
2617 | ibm_handle_init(#object, &object##_handle, *object##_parent, \ | 2621 | ibm_handle_init(#object, &object##_handle, *object##_parent, \ |
2618 | object##_paths, ARRAY_SIZE(object##_paths), &object##_path) | 2622 | object##_paths, ARRAY_SIZE(object##_paths), &object##_path) |
2619 | 2623 | ||
2620 | static int set_ibm_param(const char *val, struct kernel_param *kp) | 2624 | static int __init set_ibm_param(const char *val, struct kernel_param *kp) |
2621 | { | 2625 | { |
2622 | unsigned int i; | 2626 | unsigned int i; |
2623 | 2627 | ||
@@ -2659,7 +2663,8 @@ static void acpi_ibm_exit(void) | |||
2659 | for (i = ARRAY_SIZE(ibms) - 1; i >= 0; i--) | 2663 | for (i = ARRAY_SIZE(ibms) - 1; i >= 0; i--) |
2660 | ibm_exit(&ibms[i]); | 2664 | ibm_exit(&ibms[i]); |
2661 | 2665 | ||
2662 | remove_proc_entry(IBM_DIR, acpi_root_dir); | 2666 | if (proc_dir) |
2667 | remove_proc_entry(IBM_DIR, acpi_root_dir); | ||
2663 | 2668 | ||
2664 | if (ibm_thinkpad_ec_found) | 2669 | if (ibm_thinkpad_ec_found) |
2665 | kfree(ibm_thinkpad_ec_found); | 2670 | kfree(ibm_thinkpad_ec_found); |
@@ -2696,11 +2701,6 @@ static int __init acpi_ibm_init(void) | |||
2696 | if (acpi_disabled) | 2701 | if (acpi_disabled) |
2697 | return -ENODEV; | 2702 | return -ENODEV; |
2698 | 2703 | ||
2699 | if (!acpi_specific_hotkey_enabled) { | ||
2700 | printk(IBM_ERR "using generic hotkey driver\n"); | ||
2701 | return -ENODEV; | ||
2702 | } | ||
2703 | |||
2704 | /* ec is required because many other handles are relative to it */ | 2704 | /* ec is required because many other handles are relative to it */ |
2705 | IBM_HANDLE_INIT(ec); | 2705 | IBM_HANDLE_INIT(ec); |
2706 | if (!ec_handle) { | 2706 | if (!ec_handle) { |
@@ -2710,9 +2710,6 @@ static int __init acpi_ibm_init(void) | |||
2710 | 2710 | ||
2711 | /* Models with newer firmware report the EC in DMI */ | 2711 | /* Models with newer firmware report the EC in DMI */ |
2712 | ibm_thinkpad_ec_found = check_dmi_for_ec(); | 2712 | ibm_thinkpad_ec_found = check_dmi_for_ec(); |
2713 | if (ibm_thinkpad_ec_found) | ||
2714 | printk(IBM_INFO "ThinkPad EC firmware %s\n", | ||
2715 | ibm_thinkpad_ec_found); | ||
2716 | 2713 | ||
2717 | /* these handles are not required */ | 2714 | /* these handles are not required */ |
2718 | IBM_HANDLE_INIT(vid); | 2715 | IBM_HANDLE_INIT(vid); |
@@ -2742,6 +2739,7 @@ static int __init acpi_ibm_init(void) | |||
2742 | proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir); | 2739 | proc_dir = proc_mkdir(IBM_DIR, acpi_root_dir); |
2743 | if (!proc_dir) { | 2740 | if (!proc_dir) { |
2744 | printk(IBM_ERR "unable to create proc dir %s", IBM_DIR); | 2741 | printk(IBM_ERR "unable to create proc dir %s", IBM_DIR); |
2742 | acpi_ibm_exit(); | ||
2745 | return -ENODEV; | 2743 | return -ENODEV; |
2746 | } | 2744 | } |
2747 | proc_dir->owner = THIS_MODULE; | 2745 | proc_dir->owner = THIS_MODULE; |
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index 4a9faff4c01d..8fcd6a15517f 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c | |||
@@ -33,7 +33,7 @@ | |||
33 | 33 | ||
34 | #define ACPI_NUMA 0x80000000 | 34 | #define ACPI_NUMA 0x80000000 |
35 | #define _COMPONENT ACPI_NUMA | 35 | #define _COMPONENT ACPI_NUMA |
36 | ACPI_MODULE_NAME("numa") | 36 | ACPI_MODULE_NAME("numa"); |
37 | 37 | ||
38 | static nodemask_t nodes_found_map = NODE_MASK_NONE; | 38 | static nodemask_t nodes_found_map = NODE_MASK_NONE; |
39 | #define PXM_INVAL -1 | 39 | #define PXM_INVAL -1 |
@@ -45,12 +45,6 @@ int __cpuinitdata pxm_to_node_map[MAX_PXM_DOMAINS] | |||
45 | int __cpuinitdata node_to_pxm_map[MAX_NUMNODES] | 45 | int __cpuinitdata node_to_pxm_map[MAX_NUMNODES] |
46 | = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL }; | 46 | = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL }; |
47 | 47 | ||
48 | extern int __init acpi_table_parse_madt_family(char *id, | ||
49 | unsigned long madt_size, | ||
50 | int entry_id, | ||
51 | acpi_madt_entry_handler handler, | ||
52 | unsigned int max_entries); | ||
53 | |||
54 | int __cpuinit pxm_to_node(int pxm) | 48 | int __cpuinit pxm_to_node(int pxm) |
55 | { | 49 | { |
56 | if (pxm < 0) | 50 | if (pxm < 0) |
@@ -208,9 +202,9 @@ static int __init acpi_parse_srat(struct acpi_table_header *table) | |||
208 | 202 | ||
209 | int __init | 203 | int __init |
210 | acpi_table_parse_srat(enum acpi_srat_type id, | 204 | acpi_table_parse_srat(enum acpi_srat_type id, |
211 | acpi_madt_entry_handler handler, unsigned int max_entries) | 205 | acpi_table_entry_handler handler, unsigned int max_entries) |
212 | { | 206 | { |
213 | return acpi_table_parse_madt_family(ACPI_SIG_SRAT, | 207 | return acpi_table_parse_entries(ACPI_SIG_SRAT, |
214 | sizeof(struct acpi_table_srat), id, | 208 | sizeof(struct acpi_table_srat), id, |
215 | handler, max_entries); | 209 | handler, max_entries); |
216 | } | 210 | } |
@@ -220,9 +214,7 @@ int __init acpi_numa_init(void) | |||
220 | int result; | 214 | int result; |
221 | 215 | ||
222 | /* SRAT: Static Resource Affinity Table */ | 216 | /* SRAT: Static Resource Affinity Table */ |
223 | result = acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat); | 217 | if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) { |
224 | |||
225 | if (result > 0) { | ||
226 | result = acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY, | 218 | result = acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY, |
227 | acpi_parse_processor_affinity, | 219 | acpi_parse_processor_affinity, |
228 | NR_CPUS); | 220 | NR_CPUS); |
@@ -230,7 +222,7 @@ int __init acpi_numa_init(void) | |||
230 | } | 222 | } |
231 | 223 | ||
232 | /* SLIT: System Locality Information Table */ | 224 | /* SLIT: System Locality Information Table */ |
233 | result = acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit); | 225 | acpi_table_parse(ACPI_SIG_SLIT, acpi_parse_slit); |
234 | 226 | ||
235 | acpi_numa_arch_fixup(); | 227 | acpi_numa_arch_fixup(); |
236 | return 0; | 228 | return 0; |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 0f6f3bcbc8eb..971eca4864fa 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/efi.h> | 46 | #include <linux/efi.h> |
47 | 47 | ||
48 | #define _COMPONENT ACPI_OS_SERVICES | 48 | #define _COMPONENT ACPI_OS_SERVICES |
49 | ACPI_MODULE_NAME("osl") | 49 | ACPI_MODULE_NAME("osl"); |
50 | #define PREFIX "ACPI: " | 50 | #define PREFIX "ACPI: " |
51 | struct acpi_os_dpc { | 51 | struct acpi_os_dpc { |
52 | acpi_osd_exec_callback function; | 52 | acpi_osd_exec_callback function; |
@@ -68,9 +68,6 @@ EXPORT_SYMBOL(acpi_in_debugger); | |||
68 | extern char line_buf[80]; | 68 | extern char line_buf[80]; |
69 | #endif /*ENABLE_DEBUGGER */ | 69 | #endif /*ENABLE_DEBUGGER */ |
70 | 70 | ||
71 | int acpi_specific_hotkey_enabled = TRUE; | ||
72 | EXPORT_SYMBOL(acpi_specific_hotkey_enabled); | ||
73 | |||
74 | static unsigned int acpi_irq_irq; | 71 | static unsigned int acpi_irq_irq; |
75 | static acpi_osd_handler acpi_irq_handler; | 72 | static acpi_osd_handler acpi_irq_handler; |
76 | static void *acpi_irq_context; | 73 | static void *acpi_irq_context; |
@@ -205,7 +202,7 @@ void __iomem *acpi_os_map_memory(acpi_physical_address phys, acpi_size size) | |||
205 | { | 202 | { |
206 | if (phys > ULONG_MAX) { | 203 | if (phys > ULONG_MAX) { |
207 | printk(KERN_ERR PREFIX "Cannot map memory that high\n"); | 204 | printk(KERN_ERR PREFIX "Cannot map memory that high\n"); |
208 | return 0; | 205 | return NULL; |
209 | } | 206 | } |
210 | if (acpi_gbl_permanent_mmap) | 207 | if (acpi_gbl_permanent_mmap) |
211 | /* | 208 | /* |
@@ -890,26 +887,6 @@ u32 acpi_os_get_line(char *buffer) | |||
890 | } | 887 | } |
891 | #endif /* ACPI_FUTURE_USAGE */ | 888 | #endif /* ACPI_FUTURE_USAGE */ |
892 | 889 | ||
893 | /* Assumes no unreadable holes inbetween */ | ||
894 | u8 acpi_os_readable(void *ptr, acpi_size len) | ||
895 | { | ||
896 | #if defined(__i386__) || defined(__x86_64__) | ||
897 | char tmp; | ||
898 | return !__get_user(tmp, (char __user *)ptr) | ||
899 | && !__get_user(tmp, (char __user *)ptr + len - 1); | ||
900 | #endif | ||
901 | return 1; | ||
902 | } | ||
903 | |||
904 | #ifdef ACPI_FUTURE_USAGE | ||
905 | u8 acpi_os_writable(void *ptr, acpi_size len) | ||
906 | { | ||
907 | /* could do dummy write (racy) or a kernel page table lookup. | ||
908 | The later may be difficult at early boot when kmap doesn't work yet. */ | ||
909 | return 1; | ||
910 | } | ||
911 | #endif | ||
912 | |||
913 | acpi_status acpi_os_signal(u32 function, void *info) | 890 | acpi_status acpi_os_signal(u32 function, void *info) |
914 | { | 891 | { |
915 | switch (function) { | 892 | switch (function) { |
@@ -1012,14 +989,6 @@ static int __init acpi_wake_gpes_always_on_setup(char *str) | |||
1012 | 989 | ||
1013 | __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); | 990 | __setup("acpi_wake_gpes_always_on", acpi_wake_gpes_always_on_setup); |
1014 | 991 | ||
1015 | static int __init acpi_hotkey_setup(char *str) | ||
1016 | { | ||
1017 | acpi_specific_hotkey_enabled = FALSE; | ||
1018 | return 1; | ||
1019 | } | ||
1020 | |||
1021 | __setup("acpi_generic_hotkey", acpi_hotkey_setup); | ||
1022 | |||
1023 | /* | 992 | /* |
1024 | * max_cstate is defined in the base kernel so modules can | 993 | * max_cstate is defined in the base kernel so modules can |
1025 | * change it w/o depending on the state of the processor module. | 994 | * change it w/o depending on the state of the processor module. |
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c index 55f57a61c55e..028969370bbf 100644 --- a/drivers/acpi/pci_bind.c +++ b/drivers/acpi/pci_bind.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include <acpi/acpi_drivers.h> | 36 | #include <acpi/acpi_drivers.h> |
37 | 37 | ||
38 | #define _COMPONENT ACPI_PCI_COMPONENT | 38 | #define _COMPONENT ACPI_PCI_COMPONENT |
39 | ACPI_MODULE_NAME("pci_bind") | 39 | ACPI_MODULE_NAME("pci_bind"); |
40 | 40 | ||
41 | struct acpi_pci_data { | 41 | struct acpi_pci_data { |
42 | struct acpi_pci_id id; | 42 | struct acpi_pci_id id; |
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index fe7d007833ad..dd3186abe07a 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include <acpi/acpi_drivers.h> | 38 | #include <acpi/acpi_drivers.h> |
39 | 39 | ||
40 | #define _COMPONENT ACPI_PCI_COMPONENT | 40 | #define _COMPONENT ACPI_PCI_COMPONENT |
41 | ACPI_MODULE_NAME("pci_irq") | 41 | ACPI_MODULE_NAME("pci_irq"); |
42 | 42 | ||
43 | static struct acpi_prt_list acpi_prt; | 43 | static struct acpi_prt_list acpi_prt; |
44 | static DEFINE_SPINLOCK(acpi_prt_lock); | 44 | static DEFINE_SPINLOCK(acpi_prt_lock); |
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c index 0f683c8c6fbc..acc594771379 100644 --- a/drivers/acpi/pci_link.c +++ b/drivers/acpi/pci_link.c | |||
@@ -44,10 +44,9 @@ | |||
44 | #include <acpi/acpi_drivers.h> | 44 | #include <acpi/acpi_drivers.h> |
45 | 45 | ||
46 | #define _COMPONENT ACPI_PCI_COMPONENT | 46 | #define _COMPONENT ACPI_PCI_COMPONENT |
47 | ACPI_MODULE_NAME("pci_link") | 47 | ACPI_MODULE_NAME("pci_link"); |
48 | #define ACPI_PCI_LINK_CLASS "pci_irq_routing" | 48 | #define ACPI_PCI_LINK_CLASS "pci_irq_routing" |
49 | #define ACPI_PCI_LINK_HID "PNP0C0F" | 49 | #define ACPI_PCI_LINK_HID "PNP0C0F" |
50 | #define ACPI_PCI_LINK_DRIVER_NAME "ACPI PCI Interrupt Link Driver" | ||
51 | #define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link" | 50 | #define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link" |
52 | #define ACPI_PCI_LINK_FILE_INFO "info" | 51 | #define ACPI_PCI_LINK_FILE_INFO "info" |
53 | #define ACPI_PCI_LINK_FILE_STATUS "state" | 52 | #define ACPI_PCI_LINK_FILE_STATUS "state" |
@@ -56,7 +55,7 @@ static int acpi_pci_link_add(struct acpi_device *device); | |||
56 | static int acpi_pci_link_remove(struct acpi_device *device, int type); | 55 | static int acpi_pci_link_remove(struct acpi_device *device, int type); |
57 | 56 | ||
58 | static struct acpi_driver acpi_pci_link_driver = { | 57 | static struct acpi_driver acpi_pci_link_driver = { |
59 | .name = ACPI_PCI_LINK_DRIVER_NAME, | 58 | .name = "pci_link", |
60 | .class = ACPI_PCI_LINK_CLASS, | 59 | .class = ACPI_PCI_LINK_CLASS, |
61 | .ids = ACPI_PCI_LINK_HID, | 60 | .ids = ACPI_PCI_LINK_HID, |
62 | .ops = { | 61 | .ops = { |
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 4ecf701687e8..ad4145a37786 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -36,17 +36,16 @@ | |||
36 | #include <acpi/acpi_drivers.h> | 36 | #include <acpi/acpi_drivers.h> |
37 | 37 | ||
38 | #define _COMPONENT ACPI_PCI_COMPONENT | 38 | #define _COMPONENT ACPI_PCI_COMPONENT |
39 | ACPI_MODULE_NAME("pci_root") | 39 | ACPI_MODULE_NAME("pci_root"); |
40 | #define ACPI_PCI_ROOT_CLASS "pci_bridge" | 40 | #define ACPI_PCI_ROOT_CLASS "pci_bridge" |
41 | #define ACPI_PCI_ROOT_HID "PNP0A03" | 41 | #define ACPI_PCI_ROOT_HID "PNP0A03" |
42 | #define ACPI_PCI_ROOT_DRIVER_NAME "ACPI PCI Root Bridge Driver" | ||
43 | #define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" | 42 | #define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" |
44 | static int acpi_pci_root_add(struct acpi_device *device); | 43 | static int acpi_pci_root_add(struct acpi_device *device); |
45 | static int acpi_pci_root_remove(struct acpi_device *device, int type); | 44 | static int acpi_pci_root_remove(struct acpi_device *device, int type); |
46 | static int acpi_pci_root_start(struct acpi_device *device); | 45 | static int acpi_pci_root_start(struct acpi_device *device); |
47 | 46 | ||
48 | static struct acpi_driver acpi_pci_root_driver = { | 47 | static struct acpi_driver acpi_pci_root_driver = { |
49 | .name = ACPI_PCI_ROOT_DRIVER_NAME, | 48 | .name = "pci_root", |
50 | .class = ACPI_PCI_ROOT_CLASS, | 49 | .class = ACPI_PCI_ROOT_CLASS, |
51 | .ids = ACPI_PCI_ROOT_HID, | 50 | .ids = ACPI_PCI_ROOT_HID, |
52 | .ops = { | 51 | .ops = { |
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index e768eb362932..00d6118ff1ef 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
@@ -45,10 +45,9 @@ | |||
45 | #include <acpi/acpi_drivers.h> | 45 | #include <acpi/acpi_drivers.h> |
46 | 46 | ||
47 | #define _COMPONENT ACPI_POWER_COMPONENT | 47 | #define _COMPONENT ACPI_POWER_COMPONENT |
48 | ACPI_MODULE_NAME("acpi_power") | 48 | ACPI_MODULE_NAME("power"); |
49 | #define ACPI_POWER_COMPONENT 0x00800000 | 49 | #define ACPI_POWER_COMPONENT 0x00800000 |
50 | #define ACPI_POWER_CLASS "power_resource" | 50 | #define ACPI_POWER_CLASS "power_resource" |
51 | #define ACPI_POWER_DRIVER_NAME "ACPI Power Resource Driver" | ||
52 | #define ACPI_POWER_DEVICE_NAME "Power Resource" | 51 | #define ACPI_POWER_DEVICE_NAME "Power Resource" |
53 | #define ACPI_POWER_FILE_INFO "info" | 52 | #define ACPI_POWER_FILE_INFO "info" |
54 | #define ACPI_POWER_FILE_STATUS "state" | 53 | #define ACPI_POWER_FILE_STATUS "state" |
@@ -61,7 +60,7 @@ static int acpi_power_resume(struct acpi_device *device); | |||
61 | static int acpi_power_open_fs(struct inode *inode, struct file *file); | 60 | static int acpi_power_open_fs(struct inode *inode, struct file *file); |
62 | 61 | ||
63 | static struct acpi_driver acpi_power_driver = { | 62 | static struct acpi_driver acpi_power_driver = { |
64 | .name = ACPI_POWER_DRIVER_NAME, | 63 | .name = "power", |
65 | .class = ACPI_POWER_CLASS, | 64 | .class = ACPI_POWER_CLASS, |
66 | .ids = ACPI_POWER_HID, | 65 | .ids = ACPI_POWER_HID, |
67 | .ops = { | 66 | .ops = { |
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 0079bc51082c..99d1516d1e70 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -60,7 +60,6 @@ | |||
60 | 60 | ||
61 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | 61 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 |
62 | #define ACPI_PROCESSOR_CLASS "processor" | 62 | #define ACPI_PROCESSOR_CLASS "processor" |
63 | #define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" | ||
64 | #define ACPI_PROCESSOR_DEVICE_NAME "Processor" | 63 | #define ACPI_PROCESSOR_DEVICE_NAME "Processor" |
65 | #define ACPI_PROCESSOR_FILE_INFO "info" | 64 | #define ACPI_PROCESSOR_FILE_INFO "info" |
66 | #define ACPI_PROCESSOR_FILE_THROTTLING "throttling" | 65 | #define ACPI_PROCESSOR_FILE_THROTTLING "throttling" |
@@ -74,10 +73,10 @@ | |||
74 | #define ACPI_STA_PRESENT 0x00000001 | 73 | #define ACPI_STA_PRESENT 0x00000001 |
75 | 74 | ||
76 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 75 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
77 | ACPI_MODULE_NAME("acpi_processor") | 76 | ACPI_MODULE_NAME("processor_core"); |
78 | 77 | ||
79 | MODULE_AUTHOR("Paul Diefenbaugh"); | 78 | MODULE_AUTHOR("Paul Diefenbaugh"); |
80 | MODULE_DESCRIPTION(ACPI_PROCESSOR_DRIVER_NAME); | 79 | MODULE_DESCRIPTION("ACPI Processor Driver"); |
81 | MODULE_LICENSE("GPL"); | 80 | MODULE_LICENSE("GPL"); |
82 | 81 | ||
83 | static int acpi_processor_add(struct acpi_device *device); | 82 | static int acpi_processor_add(struct acpi_device *device); |
@@ -89,7 +88,7 @@ static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu); | |||
89 | static int acpi_processor_handle_eject(struct acpi_processor *pr); | 88 | static int acpi_processor_handle_eject(struct acpi_processor *pr); |
90 | 89 | ||
91 | static struct acpi_driver acpi_processor_driver = { | 90 | static struct acpi_driver acpi_processor_driver = { |
92 | .name = ACPI_PROCESSOR_DRIVER_NAME, | 91 | .name = "processor", |
93 | .class = ACPI_PROCESSOR_CLASS, | 92 | .class = ACPI_PROCESSOR_CLASS, |
94 | .ids = ACPI_PROCESSOR_HID, | 93 | .ids = ACPI_PROCESSOR_HID, |
95 | .ops = { | 94 | .ops = { |
@@ -404,7 +403,7 @@ static int map_lsapic_id(struct acpi_subtable_header *entry, | |||
404 | if (lsapic->lapic_flags & ACPI_MADT_ENABLED) { | 403 | if (lsapic->lapic_flags & ACPI_MADT_ENABLED) { |
405 | /* First check against id */ | 404 | /* First check against id */ |
406 | if (lsapic->processor_id == acpi_id) { | 405 | if (lsapic->processor_id == acpi_id) { |
407 | *apic_id = lsapic->id; | 406 | *apic_id = (lsapic->id << 8) | lsapic->eid; |
408 | return 1; | 407 | return 1; |
409 | /* Check against optional uid */ | 408 | /* Check against optional uid */ |
410 | } else if (entry->length >= 16 && | 409 | } else if (entry->length >= 16 && |
@@ -1005,7 +1004,7 @@ static int __init acpi_processor_init(void) | |||
1005 | #ifdef CONFIG_SMP | 1004 | #ifdef CONFIG_SMP |
1006 | if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0, | 1005 | if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0, |
1007 | (struct acpi_table_header **)&madt))) | 1006 | (struct acpi_table_header **)&madt))) |
1008 | madt = 0; | 1007 | madt = NULL; |
1009 | #endif | 1008 | #endif |
1010 | 1009 | ||
1011 | acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); | 1010 | acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); |
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index 6c6751b1405b..60773005b8af 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -39,6 +39,25 @@ | |||
39 | #include <linux/moduleparam.h> | 39 | #include <linux/moduleparam.h> |
40 | #include <linux/sched.h> /* need_resched() */ | 40 | #include <linux/sched.h> /* need_resched() */ |
41 | #include <linux/latency.h> | 41 | #include <linux/latency.h> |
42 | #include <linux/clockchips.h> | ||
43 | |||
44 | /* | ||
45 | * Include the apic definitions for x86 to have the APIC timer related defines | ||
46 | * available also for UP (on SMP it gets magically included via linux/smp.h). | ||
47 | * asm/acpi.h is not an option, as it would require more include magic. Also | ||
48 | * creating an empty asm-ia64/apic.h would just trade pest vs. cholera. | ||
49 | */ | ||
50 | #ifdef CONFIG_X86 | ||
51 | #include <asm/apic.h> | ||
52 | #endif | ||
53 | |||
54 | /* | ||
55 | * Include the apic definitions for x86 to have the APIC timer related defines | ||
56 | * available also for UP (on SMP it gets magically included via linux/smp.h). | ||
57 | */ | ||
58 | #ifdef CONFIG_X86 | ||
59 | #include <asm/apic.h> | ||
60 | #endif | ||
42 | 61 | ||
43 | #include <asm/io.h> | 62 | #include <asm/io.h> |
44 | #include <asm/uaccess.h> | 63 | #include <asm/uaccess.h> |
@@ -48,9 +67,8 @@ | |||
48 | 67 | ||
49 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | 68 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 |
50 | #define ACPI_PROCESSOR_CLASS "processor" | 69 | #define ACPI_PROCESSOR_CLASS "processor" |
51 | #define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" | ||
52 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 70 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
53 | ACPI_MODULE_NAME("acpi_processor") | 71 | ACPI_MODULE_NAME("processor_idle"); |
54 | #define ACPI_PROCESSOR_FILE_POWER "power" | 72 | #define ACPI_PROCESSOR_FILE_POWER "power" |
55 | #define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000) | 73 | #define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000) |
56 | #define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */ | 74 | #define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */ |
@@ -238,6 +256,81 @@ static void acpi_cstate_enter(struct acpi_processor_cx *cstate) | |||
238 | } | 256 | } |
239 | } | 257 | } |
240 | 258 | ||
259 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 | ||
260 | |||
261 | /* | ||
262 | * Some BIOS implementations switch to C3 in the published C2 state. | ||
263 | * This seems to be a common problem on AMD boxen, but other vendors | ||
264 | * are affected too. We pick the most conservative approach: we assume | ||
265 | * that the local APIC stops in both C2 and C3. | ||
266 | */ | ||
267 | static void acpi_timer_check_state(int state, struct acpi_processor *pr, | ||
268 | struct acpi_processor_cx *cx) | ||
269 | { | ||
270 | struct acpi_processor_power *pwr = &pr->power; | ||
271 | |||
272 | /* | ||
273 | * Check, if one of the previous states already marked the lapic | ||
274 | * unstable | ||
275 | */ | ||
276 | if (pwr->timer_broadcast_on_state < state) | ||
277 | return; | ||
278 | |||
279 | if (cx->type >= ACPI_STATE_C2) | ||
280 | pr->power.timer_broadcast_on_state = state; | ||
281 | } | ||
282 | |||
283 | static void acpi_propagate_timer_broadcast(struct acpi_processor *pr) | ||
284 | { | ||
285 | #ifdef CONFIG_GENERIC_CLOCKEVENTS | ||
286 | unsigned long reason; | ||
287 | |||
288 | reason = pr->power.timer_broadcast_on_state < INT_MAX ? | ||
289 | CLOCK_EVT_NOTIFY_BROADCAST_ON : CLOCK_EVT_NOTIFY_BROADCAST_OFF; | ||
290 | |||
291 | clockevents_notify(reason, &pr->id); | ||
292 | #else | ||
293 | cpumask_t mask = cpumask_of_cpu(pr->id); | ||
294 | |||
295 | if (pr->power.timer_broadcast_on_state < INT_MAX) | ||
296 | on_each_cpu(switch_APIC_timer_to_ipi, &mask, 1, 1); | ||
297 | else | ||
298 | on_each_cpu(switch_ipi_to_APIC_timer, &mask, 1, 1); | ||
299 | #endif | ||
300 | } | ||
301 | |||
302 | /* Power(C) State timer broadcast control */ | ||
303 | static void acpi_state_timer_broadcast(struct acpi_processor *pr, | ||
304 | struct acpi_processor_cx *cx, | ||
305 | int broadcast) | ||
306 | { | ||
307 | #ifdef CONFIG_GENERIC_CLOCKEVENTS | ||
308 | |||
309 | int state = cx - pr->power.states; | ||
310 | |||
311 | if (state >= pr->power.timer_broadcast_on_state) { | ||
312 | unsigned long reason; | ||
313 | |||
314 | reason = broadcast ? CLOCK_EVT_NOTIFY_BROADCAST_ENTER : | ||
315 | CLOCK_EVT_NOTIFY_BROADCAST_EXIT; | ||
316 | clockevents_notify(reason, &pr->id); | ||
317 | } | ||
318 | #endif | ||
319 | } | ||
320 | |||
321 | #else | ||
322 | |||
323 | static void acpi_timer_check_state(int state, struct acpi_processor *pr, | ||
324 | struct acpi_processor_cx *cstate) { } | ||
325 | static void acpi_propagate_timer_broadcast(struct acpi_processor *pr) { } | ||
326 | static void acpi_state_timer_broadcast(struct acpi_processor *pr, | ||
327 | struct acpi_processor_cx *cx, | ||
328 | int broadcast) | ||
329 | { | ||
330 | } | ||
331 | |||
332 | #endif | ||
333 | |||
241 | static void acpi_processor_idle(void) | 334 | static void acpi_processor_idle(void) |
242 | { | 335 | { |
243 | struct acpi_processor *pr = NULL; | 336 | struct acpi_processor *pr = NULL; |
@@ -382,6 +475,7 @@ static void acpi_processor_idle(void) | |||
382 | /* Get start time (ticks) */ | 475 | /* Get start time (ticks) */ |
383 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 476 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
384 | /* Invoke C2 */ | 477 | /* Invoke C2 */ |
478 | acpi_state_timer_broadcast(pr, cx, 1); | ||
385 | acpi_cstate_enter(cx); | 479 | acpi_cstate_enter(cx); |
386 | /* Get end time (ticks) */ | 480 | /* Get end time (ticks) */ |
387 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 481 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
@@ -396,6 +490,7 @@ static void acpi_processor_idle(void) | |||
396 | /* Compute time (ticks) that we were actually asleep */ | 490 | /* Compute time (ticks) that we were actually asleep */ |
397 | sleep_ticks = | 491 | sleep_ticks = |
398 | ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD; | 492 | ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD; |
493 | acpi_state_timer_broadcast(pr, cx, 0); | ||
399 | break; | 494 | break; |
400 | 495 | ||
401 | case ACPI_STATE_C3: | 496 | case ACPI_STATE_C3: |
@@ -417,6 +512,7 @@ static void acpi_processor_idle(void) | |||
417 | /* Get start time (ticks) */ | 512 | /* Get start time (ticks) */ |
418 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 513 | t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
419 | /* Invoke C3 */ | 514 | /* Invoke C3 */ |
515 | acpi_state_timer_broadcast(pr, cx, 1); | ||
420 | acpi_cstate_enter(cx); | 516 | acpi_cstate_enter(cx); |
421 | /* Get end time (ticks) */ | 517 | /* Get end time (ticks) */ |
422 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); | 518 | t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); |
@@ -436,6 +532,7 @@ static void acpi_processor_idle(void) | |||
436 | /* Compute time (ticks) that we were actually asleep */ | 532 | /* Compute time (ticks) that we were actually asleep */ |
437 | sleep_ticks = | 533 | sleep_ticks = |
438 | ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD; | 534 | ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD; |
535 | acpi_state_timer_broadcast(pr, cx, 0); | ||
439 | break; | 536 | break; |
440 | 537 | ||
441 | default: | 538 | default: |
@@ -904,11 +1001,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) | |||
904 | unsigned int i; | 1001 | unsigned int i; |
905 | unsigned int working = 0; | 1002 | unsigned int working = 0; |
906 | 1003 | ||
907 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 | 1004 | pr->power.timer_broadcast_on_state = INT_MAX; |
908 | int timer_broadcast = 0; | ||
909 | cpumask_t mask = cpumask_of_cpu(pr->id); | ||
910 | on_each_cpu(switch_ipi_to_APIC_timer, &mask, 1, 1); | ||
911 | #endif | ||
912 | 1005 | ||
913 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { | 1006 | for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { |
914 | struct acpi_processor_cx *cx = &pr->power.states[i]; | 1007 | struct acpi_processor_cx *cx = &pr->power.states[i]; |
@@ -920,21 +1013,14 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) | |||
920 | 1013 | ||
921 | case ACPI_STATE_C2: | 1014 | case ACPI_STATE_C2: |
922 | acpi_processor_power_verify_c2(cx); | 1015 | acpi_processor_power_verify_c2(cx); |
923 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 | 1016 | if (cx->valid) |
924 | /* Some AMD systems fake C3 as C2, but still | 1017 | acpi_timer_check_state(i, pr, cx); |
925 | have timer troubles */ | ||
926 | if (cx->valid && | ||
927 | boot_cpu_data.x86_vendor == X86_VENDOR_AMD) | ||
928 | timer_broadcast++; | ||
929 | #endif | ||
930 | break; | 1018 | break; |
931 | 1019 | ||
932 | case ACPI_STATE_C3: | 1020 | case ACPI_STATE_C3: |
933 | acpi_processor_power_verify_c3(pr, cx); | 1021 | acpi_processor_power_verify_c3(pr, cx); |
934 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 | ||
935 | if (cx->valid) | 1022 | if (cx->valid) |
936 | timer_broadcast++; | 1023 | acpi_timer_check_state(i, pr, cx); |
937 | #endif | ||
938 | break; | 1024 | break; |
939 | } | 1025 | } |
940 | 1026 | ||
@@ -942,10 +1028,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr) | |||
942 | working++; | 1028 | working++; |
943 | } | 1029 | } |
944 | 1030 | ||
945 | #ifdef ARCH_APICTIMER_STOPS_ON_C3 | 1031 | acpi_propagate_timer_broadcast(pr); |
946 | if (timer_broadcast) | ||
947 | on_each_cpu(switch_APIC_timer_to_ipi, &mask, 1, 1); | ||
948 | #endif | ||
949 | 1032 | ||
950 | return (working); | 1033 | return (working); |
951 | } | 1034 | } |
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index 058f13cf3b79..2f2e7964226d 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
@@ -44,10 +44,9 @@ | |||
44 | 44 | ||
45 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | 45 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 |
46 | #define ACPI_PROCESSOR_CLASS "processor" | 46 | #define ACPI_PROCESSOR_CLASS "processor" |
47 | #define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" | ||
48 | #define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" | 47 | #define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" |
49 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 48 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
50 | ACPI_MODULE_NAME("acpi_processor") | 49 | ACPI_MODULE_NAME("processor_perflib"); |
51 | 50 | ||
52 | static DEFINE_MUTEX(performance_mutex); | 51 | static DEFINE_MUTEX(performance_mutex); |
53 | 52 | ||
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c index 40fecd67ad83..06e6f3fb8825 100644 --- a/drivers/acpi/processor_thermal.c +++ b/drivers/acpi/processor_thermal.c | |||
@@ -41,9 +41,8 @@ | |||
41 | 41 | ||
42 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | 42 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 |
43 | #define ACPI_PROCESSOR_CLASS "processor" | 43 | #define ACPI_PROCESSOR_CLASS "processor" |
44 | #define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" | ||
45 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 44 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
46 | ACPI_MODULE_NAME("acpi_processor") | 45 | ACPI_MODULE_NAME("processor_thermal"); |
47 | 46 | ||
48 | /* -------------------------------------------------------------------------- | 47 | /* -------------------------------------------------------------------------- |
49 | Limit Interface | 48 | Limit Interface |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 89dff3639abe..b33486009f41 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
@@ -41,9 +41,8 @@ | |||
41 | 41 | ||
42 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 | 42 | #define ACPI_PROCESSOR_COMPONENT 0x01000000 |
43 | #define ACPI_PROCESSOR_CLASS "processor" | 43 | #define ACPI_PROCESSOR_CLASS "processor" |
44 | #define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" | ||
45 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT | 44 | #define _COMPONENT ACPI_PROCESSOR_COMPONENT |
46 | ACPI_MODULE_NAME("acpi_processor") | 45 | ACPI_MODULE_NAME("processor_throttling"); |
47 | 46 | ||
48 | /* -------------------------------------------------------------------------- | 47 | /* -------------------------------------------------------------------------- |
49 | Throttling Control | 48 | Throttling Control |
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index f58fc7447ab4..1eab2034c9a5 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c | |||
@@ -59,7 +59,6 @@ extern void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); | |||
59 | #define ACPI_AC_CLASS "ac_adapter" | 59 | #define ACPI_AC_CLASS "ac_adapter" |
60 | #define ACPI_BATTERY_CLASS "battery" | 60 | #define ACPI_BATTERY_CLASS "battery" |
61 | #define ACPI_SBS_HID "ACPI0002" | 61 | #define ACPI_SBS_HID "ACPI0002" |
62 | #define ACPI_SBS_DRIVER_NAME "ACPI Smart Battery System Driver" | ||
63 | #define ACPI_SBS_DEVICE_NAME "Smart Battery System" | 62 | #define ACPI_SBS_DEVICE_NAME "Smart Battery System" |
64 | #define ACPI_SBS_FILE_INFO "info" | 63 | #define ACPI_SBS_FILE_INFO "info" |
65 | #define ACPI_SBS_FILE_STATE "state" | 64 | #define ACPI_SBS_FILE_STATE "state" |
@@ -78,7 +77,7 @@ extern void acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); | |||
78 | #define MAX_SBS_BAT 4 | 77 | #define MAX_SBS_BAT 4 |
79 | #define MAX_SMBUS_ERR 1 | 78 | #define MAX_SMBUS_ERR 1 |
80 | 79 | ||
81 | ACPI_MODULE_NAME("acpi_sbs"); | 80 | ACPI_MODULE_NAME("sbs"); |
82 | 81 | ||
83 | MODULE_AUTHOR("Rich Townsend"); | 82 | MODULE_AUTHOR("Rich Townsend"); |
84 | MODULE_DESCRIPTION("Smart Battery System ACPI interface driver"); | 83 | MODULE_DESCRIPTION("Smart Battery System ACPI interface driver"); |
@@ -110,7 +109,7 @@ static void acpi_battery_smbus_err_handler(struct acpi_ec_smbus *smbus); | |||
110 | static void acpi_sbs_update_queue(void *data); | 109 | static void acpi_sbs_update_queue(void *data); |
111 | 110 | ||
112 | static struct acpi_driver acpi_sbs_driver = { | 111 | static struct acpi_driver acpi_sbs_driver = { |
113 | .name = ACPI_SBS_DRIVER_NAME, | 112 | .name = "sbs", |
114 | .class = ACPI_SBS_CLASS, | 113 | .class = ACPI_SBS_CLASS, |
115 | .ids = ACPI_SBS_HID, | 114 | .ids = ACPI_SBS_HID, |
116 | .ops = { | 115 | .ops = { |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 64f26db10c8e..bb0e0da39fb1 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -11,13 +11,12 @@ | |||
11 | #include <acpi/acinterp.h> /* for acpi_ex_eisa_id_to_string() */ | 11 | #include <acpi/acinterp.h> /* for acpi_ex_eisa_id_to_string() */ |
12 | 12 | ||
13 | #define _COMPONENT ACPI_BUS_COMPONENT | 13 | #define _COMPONENT ACPI_BUS_COMPONENT |
14 | ACPI_MODULE_NAME("scan") | 14 | ACPI_MODULE_NAME("scan"); |
15 | #define STRUCT_TO_INT(s) (*((int*)&s)) | 15 | #define STRUCT_TO_INT(s) (*((int*)&s)) |
16 | extern struct acpi_device *acpi_root; | 16 | extern struct acpi_device *acpi_root; |
17 | 17 | ||
18 | #define ACPI_BUS_CLASS "system_bus" | 18 | #define ACPI_BUS_CLASS "system_bus" |
19 | #define ACPI_BUS_HID "ACPI_BUS" | 19 | #define ACPI_BUS_HID "ACPI_BUS" |
20 | #define ACPI_BUS_DRIVER_NAME "ACPI Bus Driver" | ||
21 | #define ACPI_BUS_DEVICE_NAME "System Bus" | 20 | #define ACPI_BUS_DEVICE_NAME "System Bus" |
22 | 21 | ||
23 | static LIST_HEAD(acpi_device_list); | 22 | static LIST_HEAD(acpi_device_list); |
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c index 7147b0bdab0a..83a8d3097904 100644 --- a/drivers/acpi/system.c +++ b/drivers/acpi/system.c | |||
@@ -31,14 +31,13 @@ | |||
31 | #include <acpi/acpi_drivers.h> | 31 | #include <acpi/acpi_drivers.h> |
32 | 32 | ||
33 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | 33 | #define _COMPONENT ACPI_SYSTEM_COMPONENT |
34 | ACPI_MODULE_NAME("acpi_system") | 34 | ACPI_MODULE_NAME("system"); |
35 | #ifdef MODULE_PARAM_PREFIX | 35 | #ifdef MODULE_PARAM_PREFIX |
36 | #undef MODULE_PARAM_PREFIX | 36 | #undef MODULE_PARAM_PREFIX |
37 | #endif | 37 | #endif |
38 | #define MODULE_PARAM_PREFIX "acpi." | 38 | #define MODULE_PARAM_PREFIX "acpi." |
39 | 39 | ||
40 | #define ACPI_SYSTEM_CLASS "system" | 40 | #define ACPI_SYSTEM_CLASS "system" |
41 | #define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver" | ||
42 | #define ACPI_SYSTEM_DEVICE_NAME "System" | 41 | #define ACPI_SYSTEM_DEVICE_NAME "System" |
43 | #define ACPI_SYSTEM_FILE_INFO "info" | 42 | #define ACPI_SYSTEM_FILE_INFO "info" |
44 | #define ACPI_SYSTEM_FILE_EVENT "event" | 43 | #define ACPI_SYSTEM_FILE_EVENT "event" |
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c index 45bd17313c4a..849e2c361804 100644 --- a/drivers/acpi/tables.c +++ b/drivers/acpi/tables.c | |||
@@ -169,40 +169,40 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header * header) | |||
169 | 169 | ||
170 | 170 | ||
171 | int __init | 171 | int __init |
172 | acpi_table_parse_madt_family(char *id, | 172 | acpi_table_parse_entries(char *id, |
173 | unsigned long madt_size, | 173 | unsigned long table_size, |
174 | int entry_id, | 174 | int entry_id, |
175 | acpi_madt_entry_handler handler, | 175 | acpi_table_entry_handler handler, |
176 | unsigned int max_entries) | 176 | unsigned int max_entries) |
177 | { | 177 | { |
178 | struct acpi_table_header *madt = NULL; | 178 | struct acpi_table_header *table_header = NULL; |
179 | struct acpi_subtable_header *entry; | 179 | struct acpi_subtable_header *entry; |
180 | unsigned int count = 0; | 180 | unsigned int count = 0; |
181 | unsigned long madt_end; | 181 | unsigned long table_end; |
182 | 182 | ||
183 | if (!handler) | 183 | if (!handler) |
184 | return -EINVAL; | 184 | return -EINVAL; |
185 | 185 | ||
186 | /* Locate the MADT (if exists). There should only be one. */ | 186 | /* Locate the table (if exists). There should only be one. */ |
187 | acpi_get_table(id, 0, &madt); | 187 | acpi_get_table(id, 0, &table_header); |
188 | 188 | ||
189 | if (!madt) { | 189 | if (!table_header) { |
190 | printk(KERN_WARNING PREFIX "%4.4s not present\n", id); | 190 | printk(KERN_WARNING PREFIX "%4.4s not present\n", id); |
191 | return -ENODEV; | 191 | return -ENODEV; |
192 | } | 192 | } |
193 | 193 | ||
194 | madt_end = (unsigned long)madt + madt->length; | 194 | table_end = (unsigned long)table_header + table_header->length; |
195 | 195 | ||
196 | /* Parse all entries looking for a match. */ | 196 | /* Parse all entries looking for a match. */ |
197 | 197 | ||
198 | entry = (struct acpi_subtable_header *) | 198 | entry = (struct acpi_subtable_header *) |
199 | ((unsigned long)madt + madt_size); | 199 | ((unsigned long)table_header + table_size); |
200 | 200 | ||
201 | while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < | 201 | while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) < |
202 | madt_end) { | 202 | table_end) { |
203 | if (entry->type == entry_id | 203 | if (entry->type == entry_id |
204 | && (!max_entries || count++ < max_entries)) | 204 | && (!max_entries || count++ < max_entries)) |
205 | if (handler(entry, madt_end)) | 205 | if (handler(entry, table_end)) |
206 | return -EINVAL; | 206 | return -EINVAL; |
207 | 207 | ||
208 | entry = (struct acpi_subtable_header *) | 208 | entry = (struct acpi_subtable_header *) |
@@ -218,13 +218,22 @@ acpi_table_parse_madt_family(char *id, | |||
218 | 218 | ||
219 | int __init | 219 | int __init |
220 | acpi_table_parse_madt(enum acpi_madt_type id, | 220 | acpi_table_parse_madt(enum acpi_madt_type id, |
221 | acpi_madt_entry_handler handler, unsigned int max_entries) | 221 | acpi_table_entry_handler handler, unsigned int max_entries) |
222 | { | 222 | { |
223 | return acpi_table_parse_madt_family(ACPI_SIG_MADT, | 223 | return acpi_table_parse_entries(ACPI_SIG_MADT, |
224 | sizeof(struct acpi_table_madt), id, | 224 | sizeof(struct acpi_table_madt), id, |
225 | handler, max_entries); | 225 | handler, max_entries); |
226 | } | 226 | } |
227 | 227 | ||
228 | /** | ||
229 | * acpi_table_parse - find table with @id, run @handler on it | ||
230 | * | ||
231 | * @id: table id to find | ||
232 | * @handler: handler to run | ||
233 | * | ||
234 | * Scan the ACPI System Descriptor Table (STD) for a table matching @id, | ||
235 | * run @handler on it. Return 0 if table found, return on if not. | ||
236 | */ | ||
228 | int __init acpi_table_parse(char *id, acpi_table_handler handler) | 237 | int __init acpi_table_parse(char *id, acpi_table_handler handler) |
229 | { | 238 | { |
230 | struct acpi_table_header *table = NULL; | 239 | struct acpi_table_header *table = NULL; |
@@ -234,9 +243,9 @@ int __init acpi_table_parse(char *id, acpi_table_handler handler) | |||
234 | acpi_get_table(id, 0, &table); | 243 | acpi_get_table(id, 0, &table); |
235 | if (table) { | 244 | if (table) { |
236 | handler(table); | 245 | handler(table); |
237 | return 1; | ||
238 | } else | ||
239 | return 0; | 246 | return 0; |
247 | } else | ||
248 | return 1; | ||
240 | } | 249 | } |
241 | 250 | ||
242 | /* | 251 | /* |
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c index 807978d5381a..417ef5fa7666 100644 --- a/drivers/acpi/tables/tbxface.c +++ b/drivers/acpi/tables/tbxface.c | |||
@@ -338,9 +338,9 @@ acpi_status acpi_unload_table_id(acpi_owner_id id) | |||
338 | int i; | 338 | int i; |
339 | acpi_status status = AE_NOT_EXIST; | 339 | acpi_status status = AE_NOT_EXIST; |
340 | 340 | ||
341 | ACPI_FUNCTION_TRACE(acpi_unload_table); | 341 | ACPI_FUNCTION_TRACE(acpi_unload_table_id); |
342 | 342 | ||
343 | /* Find table from the requested type list */ | 343 | /* Find table in the global table list */ |
344 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { | 344 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { |
345 | if (id != acpi_gbl_root_table_list.tables[i].owner_id) { | 345 | if (id != acpi_gbl_root_table_list.tables[i].owner_id) { |
346 | continue; | 346 | continue; |
@@ -352,8 +352,9 @@ acpi_status acpi_unload_table_id(acpi_owner_id id) | |||
352 | * simply a position within the hierarchy | 352 | * simply a position within the hierarchy |
353 | */ | 353 | */ |
354 | acpi_tb_delete_namespace_by_owner(i); | 354 | acpi_tb_delete_namespace_by_owner(i); |
355 | acpi_tb_release_owner_id(i); | 355 | status = acpi_tb_release_owner_id(i); |
356 | acpi_tb_set_table_loaded_flag(i, FALSE); | 356 | acpi_tb_set_table_loaded_flag(i, FALSE); |
357 | break; | ||
357 | } | 358 | } |
358 | return_ACPI_STATUS(status); | 359 | return_ACPI_STATUS(status); |
359 | } | 360 | } |
@@ -408,7 +409,7 @@ acpi_get_table(char *signature, | |||
408 | } | 409 | } |
409 | 410 | ||
410 | if (!acpi_gbl_permanent_mmap) { | 411 | if (!acpi_gbl_permanent_mmap) { |
411 | acpi_gbl_root_table_list.tables[i].pointer = 0; | 412 | acpi_gbl_root_table_list.tables[i].pointer = NULL; |
412 | } | 413 | } |
413 | 414 | ||
414 | return (status); | 415 | return (status); |
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 986afd470a14..15022bc86336 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c | |||
@@ -47,7 +47,6 @@ | |||
47 | 47 | ||
48 | #define ACPI_THERMAL_COMPONENT 0x04000000 | 48 | #define ACPI_THERMAL_COMPONENT 0x04000000 |
49 | #define ACPI_THERMAL_CLASS "thermal_zone" | 49 | #define ACPI_THERMAL_CLASS "thermal_zone" |
50 | #define ACPI_THERMAL_DRIVER_NAME "ACPI Thermal Zone Driver" | ||
51 | #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" | 50 | #define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" |
52 | #define ACPI_THERMAL_FILE_STATE "state" | 51 | #define ACPI_THERMAL_FILE_STATE "state" |
53 | #define ACPI_THERMAL_FILE_TEMPERATURE "temperature" | 52 | #define ACPI_THERMAL_FILE_TEMPERATURE "temperature" |
@@ -71,10 +70,10 @@ | |||
71 | #define CELSIUS_TO_KELVIN(t) ((t+273)*10) | 70 | #define CELSIUS_TO_KELVIN(t) ((t+273)*10) |
72 | 71 | ||
73 | #define _COMPONENT ACPI_THERMAL_COMPONENT | 72 | #define _COMPONENT ACPI_THERMAL_COMPONENT |
74 | ACPI_MODULE_NAME("acpi_thermal") | 73 | ACPI_MODULE_NAME("thermal"); |
75 | 74 | ||
76 | MODULE_AUTHOR("Paul Diefenbaugh"); | 75 | MODULE_AUTHOR("Paul Diefenbaugh"); |
77 | MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME); | 76 | MODULE_DESCRIPTION("ACPI Thermal Zone Driver"); |
78 | MODULE_LICENSE("GPL"); | 77 | MODULE_LICENSE("GPL"); |
79 | 78 | ||
80 | static int tzp; | 79 | static int tzp; |
@@ -99,7 +98,7 @@ static ssize_t acpi_thermal_write_polling(struct file *, const char __user *, | |||
99 | size_t, loff_t *); | 98 | size_t, loff_t *); |
100 | 99 | ||
101 | static struct acpi_driver acpi_thermal_driver = { | 100 | static struct acpi_driver acpi_thermal_driver = { |
102 | .name = ACPI_THERMAL_DRIVER_NAME, | 101 | .name = "thermal", |
103 | .class = ACPI_THERMAL_CLASS, | 102 | .class = ACPI_THERMAL_CLASS, |
104 | .ids = ACPI_THERMAL_HID, | 103 | .ids = ACPI_THERMAL_HID, |
105 | .ops = { | 104 | .ops = { |
@@ -270,7 +269,7 @@ static int acpi_thermal_set_polling(struct acpi_thermal *tz, int seconds) | |||
270 | 269 | ||
271 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 270 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
272 | "Polling frequency set to %lu seconds\n", | 271 | "Polling frequency set to %lu seconds\n", |
273 | tz->polling_frequency)); | 272 | tz->polling_frequency/10)); |
274 | 273 | ||
275 | return 0; | 274 | return 0; |
276 | } | 275 | } |
diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/acpi/toshiba_acpi.c index d9b651ffcdc0..faf8a5232d8e 100644 --- a/drivers/acpi/toshiba_acpi.c +++ b/drivers/acpi/toshiba_acpi.c | |||
@@ -125,7 +125,7 @@ static int write_acpi_int(const char *methodName, int val) | |||
125 | union acpi_object in_objs[1]; | 125 | union acpi_object in_objs[1]; |
126 | acpi_status status; | 126 | acpi_status status; |
127 | 127 | ||
128 | params.count = sizeof(in_objs) / sizeof(in_objs[0]); | 128 | params.count = ARRAY_SIZE(in_objs); |
129 | params.pointer = in_objs; | 129 | params.pointer = in_objs; |
130 | in_objs[0].type = ACPI_TYPE_INTEGER; | 130 | in_objs[0].type = ACPI_TYPE_INTEGER; |
131 | in_objs[0].integer.value = val; | 131 | in_objs[0].integer.value = val; |
@@ -561,10 +561,6 @@ static int __init toshiba_acpi_init(void) | |||
561 | if (acpi_disabled) | 561 | if (acpi_disabled) |
562 | return -ENODEV; | 562 | return -ENODEV; |
563 | 563 | ||
564 | if (!acpi_specific_hotkey_enabled) { | ||
565 | printk(MY_INFO "Using generic hotkey driver\n"); | ||
566 | return -ENODEV; | ||
567 | } | ||
568 | /* simple device detection: look for HCI method */ | 564 | /* simple device detection: look for HCI method */ |
569 | if (is_valid_acpi_path(METHOD_HCI_1)) | 565 | if (is_valid_acpi_path(METHOD_HCI_1)) |
570 | method_hci = METHOD_HCI_1; | 566 | method_hci = METHOD_HCI_1; |
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c index f777cebdc46d..673a0caa4073 100644 --- a/drivers/acpi/utilities/utdelete.c +++ b/drivers/acpi/utilities/utdelete.c | |||
@@ -170,7 +170,6 @@ static void acpi_ut_delete_internal_obj(union acpi_operand_object *object) | |||
170 | acpi_os_delete_mutex(object->mutex.os_mutex); | 170 | acpi_os_delete_mutex(object->mutex.os_mutex); |
171 | acpi_gbl_global_lock_mutex = NULL; | 171 | acpi_gbl_global_lock_mutex = NULL; |
172 | } else { | 172 | } else { |
173 | acpi_ex_unlink_mutex(object); | ||
174 | acpi_os_delete_mutex(object->mutex.os_mutex); | 173 | acpi_os_delete_mutex(object->mutex.os_mutex); |
175 | } | 174 | } |
176 | break; | 175 | break; |
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 68a809fa7b19..34f157571080 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <acpi/acpi_drivers.h> | 31 | #include <acpi/acpi_drivers.h> |
32 | 32 | ||
33 | #define _COMPONENT ACPI_BUS_COMPONENT | 33 | #define _COMPONENT ACPI_BUS_COMPONENT |
34 | ACPI_MODULE_NAME("acpi_utils") | 34 | ACPI_MODULE_NAME("utils"); |
35 | 35 | ||
36 | /* -------------------------------------------------------------------------- | 36 | /* -------------------------------------------------------------------------- |
37 | Object Evaluation Helpers | 37 | Object Evaluation Helpers |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index e0b97add8c63..bf525cca3b63 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -40,7 +40,6 @@ | |||
40 | 40 | ||
41 | #define ACPI_VIDEO_COMPONENT 0x08000000 | 41 | #define ACPI_VIDEO_COMPONENT 0x08000000 |
42 | #define ACPI_VIDEO_CLASS "video" | 42 | #define ACPI_VIDEO_CLASS "video" |
43 | #define ACPI_VIDEO_DRIVER_NAME "ACPI Video Driver" | ||
44 | #define ACPI_VIDEO_BUS_NAME "Video Bus" | 43 | #define ACPI_VIDEO_BUS_NAME "Video Bus" |
45 | #define ACPI_VIDEO_DEVICE_NAME "Video Device" | 44 | #define ACPI_VIDEO_DEVICE_NAME "Video Device" |
46 | #define ACPI_VIDEO_NOTIFY_SWITCH 0x80 | 45 | #define ACPI_VIDEO_NOTIFY_SWITCH 0x80 |
@@ -65,17 +64,17 @@ | |||
65 | #define ACPI_VIDEO_DISPLAY_LCD 4 | 64 | #define ACPI_VIDEO_DISPLAY_LCD 4 |
66 | 65 | ||
67 | #define _COMPONENT ACPI_VIDEO_COMPONENT | 66 | #define _COMPONENT ACPI_VIDEO_COMPONENT |
68 | ACPI_MODULE_NAME("acpi_video") | 67 | ACPI_MODULE_NAME("video"); |
69 | 68 | ||
70 | MODULE_AUTHOR("Bruno Ducrot"); | 69 | MODULE_AUTHOR("Bruno Ducrot"); |
71 | MODULE_DESCRIPTION(ACPI_VIDEO_DRIVER_NAME); | 70 | MODULE_DESCRIPTION("ACPI Video Driver"); |
72 | MODULE_LICENSE("GPL"); | 71 | MODULE_LICENSE("GPL"); |
73 | 72 | ||
74 | static int acpi_video_bus_add(struct acpi_device *device); | 73 | static int acpi_video_bus_add(struct acpi_device *device); |
75 | static int acpi_video_bus_remove(struct acpi_device *device, int type); | 74 | static int acpi_video_bus_remove(struct acpi_device *device, int type); |
76 | 75 | ||
77 | static struct acpi_driver acpi_video_bus = { | 76 | static struct acpi_driver acpi_video_bus = { |
78 | .name = ACPI_VIDEO_DRIVER_NAME, | 77 | .name = "video", |
79 | .class = ACPI_VIDEO_CLASS, | 78 | .class = ACPI_VIDEO_CLASS, |
80 | .ids = ACPI_VIDEO_HID, | 79 | .ids = ACPI_VIDEO_HID, |
81 | .ops = { | 80 | .ops = { |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 25d8d3f778a1..2cf8251728d2 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
@@ -1410,7 +1410,16 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, | |||
1410 | } | 1410 | } |
1411 | 1411 | ||
1412 | tf.protocol = ATA_PROT_PIO; | 1412 | tf.protocol = ATA_PROT_PIO; |
1413 | tf.flags |= ATA_TFLAG_POLLING; /* for polling presence detection */ | 1413 | |
1414 | /* Some devices choke if TF registers contain garbage. Make | ||
1415 | * sure those are properly initialized. | ||
1416 | */ | ||
1417 | tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; | ||
1418 | |||
1419 | /* Device presence detection is unreliable on some | ||
1420 | * controllers. Always poll IDENTIFY if available. | ||
1421 | */ | ||
1422 | tf.flags |= ATA_TFLAG_POLLING; | ||
1414 | 1423 | ||
1415 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, | 1424 | err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, |
1416 | id, sizeof(id[0]) * ATA_ID_WORDS); | 1425 | id, sizeof(id[0]) * ATA_ID_WORDS); |
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c index 4223e10de6a0..98c1fee4b305 100644 --- a/drivers/ata/pata_legacy.c +++ b/drivers/ata/pata_legacy.c | |||
@@ -89,9 +89,10 @@ static int probe_all; /* Set to check all ISA port ranges */ | |||
89 | static int ht6560a; /* HT 6560A on primary 1, secondary 2, both 3 */ | 89 | static int ht6560a; /* HT 6560A on primary 1, secondary 2, both 3 */ |
90 | static int ht6560b; /* HT 6560A on primary 1, secondary 2, both 3 */ | 90 | static int ht6560b; /* HT 6560A on primary 1, secondary 2, both 3 */ |
91 | static int opti82c611a; /* Opti82c611A on primary 1, secondary 2, both 3 */ | 91 | static int opti82c611a; /* Opti82c611A on primary 1, secondary 2, both 3 */ |
92 | static int opti82c46x; /* Opti 82c465MV present (pri/sec autodetect) */ | 92 | static int opti82c46x; /* Opti 82c465MV present (pri/sec autodetect) */ |
93 | static int autospeed; /* Chip present which snoops speed changes */ | 93 | static int autospeed; /* Chip present which snoops speed changes */ |
94 | static int pio_mask = 0x1F; /* PIO range for autospeed devices */ | 94 | static int pio_mask = 0x1F; /* PIO range for autospeed devices */ |
95 | static int iordy_mask = 0xFFFFFFFF; /* Use iordy if available */ | ||
95 | 96 | ||
96 | /** | 97 | /** |
97 | * legacy_set_mode - mode setting | 98 | * legacy_set_mode - mode setting |
@@ -113,6 +114,7 @@ static int legacy_set_mode(struct ata_port *ap, struct ata_device **unused) | |||
113 | for (i = 0; i < ATA_MAX_DEVICES; i++) { | 114 | for (i = 0; i < ATA_MAX_DEVICES; i++) { |
114 | struct ata_device *dev = &ap->device[i]; | 115 | struct ata_device *dev = &ap->device[i]; |
115 | if (ata_dev_enabled(dev)) { | 116 | if (ata_dev_enabled(dev)) { |
117 | ata_dev_printk(dev, KERN_INFO, "configured for PIO\n"); | ||
116 | dev->pio_mode = XFER_PIO_0; | 118 | dev->pio_mode = XFER_PIO_0; |
117 | dev->xfer_mode = XFER_PIO_0; | 119 | dev->xfer_mode = XFER_PIO_0; |
118 | dev->xfer_shift = ATA_SHIFT_PIO; | 120 | dev->xfer_shift = ATA_SHIFT_PIO; |
@@ -695,6 +697,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
695 | void __iomem *io_addr, *ctrl_addr; | 697 | void __iomem *io_addr, *ctrl_addr; |
696 | int pio_modes = pio_mask; | 698 | int pio_modes = pio_mask; |
697 | u32 mask = (1 << port); | 699 | u32 mask = (1 << port); |
700 | u32 iordy = (iordy_mask & mask) ? 0: ATA_FLAG_NO_IORDY; | ||
698 | int ret; | 701 | int ret; |
699 | 702 | ||
700 | pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0); | 703 | pdev = platform_device_register_simple(DRV_NAME, nr_legacy_host, NULL, 0); |
@@ -715,6 +718,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
715 | if (ht6560a & mask) { | 718 | if (ht6560a & mask) { |
716 | ops = &ht6560a_port_ops; | 719 | ops = &ht6560a_port_ops; |
717 | pio_modes = 0x07; | 720 | pio_modes = 0x07; |
721 | iordy = ATA_FLAG_NO_IORDY; | ||
718 | } | 722 | } |
719 | if (ht6560b & mask) { | 723 | if (ht6560b & mask) { |
720 | ops = &ht6560b_port_ops; | 724 | ops = &ht6560b_port_ops; |
@@ -750,6 +754,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
750 | printk(KERN_INFO "PDC20230-C/20630 VLB ATA controller detected.\n"); | 754 | printk(KERN_INFO "PDC20230-C/20630 VLB ATA controller detected.\n"); |
751 | pio_modes = 0x07; | 755 | pio_modes = 0x07; |
752 | ops = &pdc20230_port_ops; | 756 | ops = &pdc20230_port_ops; |
757 | iordy = ATA_FLAG_NO_IORDY; | ||
753 | udelay(100); | 758 | udelay(100); |
754 | inb(0x1F5); | 759 | inb(0x1F5); |
755 | } else { | 760 | } else { |
@@ -767,6 +772,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
767 | /* Chip does mode setting by command snooping */ | 772 | /* Chip does mode setting by command snooping */ |
768 | if (ops == &legacy_port_ops && (autospeed & mask)) | 773 | if (ops == &legacy_port_ops && (autospeed & mask)) |
769 | ops = &simple_port_ops; | 774 | ops = &simple_port_ops; |
775 | |||
770 | memset(&ae, 0, sizeof(struct ata_probe_ent)); | 776 | memset(&ae, 0, sizeof(struct ata_probe_ent)); |
771 | INIT_LIST_HEAD(&ae.node); | 777 | INIT_LIST_HEAD(&ae.node); |
772 | ae.dev = &pdev->dev; | 778 | ae.dev = &pdev->dev; |
@@ -776,7 +782,7 @@ static __init int legacy_init_one(int port, unsigned long io, unsigned long ctrl | |||
776 | ae.pio_mask = pio_modes; | 782 | ae.pio_mask = pio_modes; |
777 | ae.irq = irq; | 783 | ae.irq = irq; |
778 | ae.irq_flags = 0; | 784 | ae.irq_flags = 0; |
779 | ae.port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST; | 785 | ae.port_flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST|iordy; |
780 | ae.port[0].cmd_addr = io_addr; | 786 | ae.port[0].cmd_addr = io_addr; |
781 | ae.port[0].altstatus_addr = ctrl_addr; | 787 | ae.port[0].altstatus_addr = ctrl_addr; |
782 | ae.port[0].ctl_addr = ctrl_addr; | 788 | ae.port[0].ctl_addr = ctrl_addr; |
@@ -945,6 +951,7 @@ module_param(ht6560b, int, 0); | |||
945 | module_param(opti82c611a, int, 0); | 951 | module_param(opti82c611a, int, 0); |
946 | module_param(opti82c46x, int, 0); | 952 | module_param(opti82c46x, int, 0); |
947 | module_param(pio_mask, int, 0); | 953 | module_param(pio_mask, int, 0); |
954 | module_param(iordy_mask, int, 0); | ||
948 | 955 | ||
949 | module_init(legacy_init); | 956 | module_init(legacy_init); |
950 | module_exit(legacy_exit); | 957 | module_exit(legacy_exit); |
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c index 1b3b4ed8eb19..4362141976ad 100644 --- a/drivers/ata/pata_qdi.c +++ b/drivers/ata/pata_qdi.c | |||
@@ -264,16 +264,18 @@ static __init int qdi_init_one(unsigned long port, int type, unsigned long io, i | |||
264 | if (type == 6580) { | 264 | if (type == 6580) { |
265 | ae.port_ops = &qdi6580_port_ops; | 265 | ae.port_ops = &qdi6580_port_ops; |
266 | ae.pio_mask = 0x1F; | 266 | ae.pio_mask = 0x1F; |
267 | ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; | ||
267 | } else { | 268 | } else { |
268 | ae.port_ops = &qdi6500_port_ops; | 269 | ae.port_ops = &qdi6500_port_ops; |
269 | ae.pio_mask = 0x07; /* Actually PIO3 !IORDY is possible */ | 270 | ae.pio_mask = 0x07; /* Actually PIO3 !IORDY is possible */ |
271 | ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST | | ||
272 | ATA_FLAG_NO_IORDY; | ||
270 | } | 273 | } |
271 | 274 | ||
272 | ae.sht = &qdi_sht; | 275 | ae.sht = &qdi_sht; |
273 | ae.n_ports = 1; | 276 | ae.n_ports = 1; |
274 | ae.irq = irq; | 277 | ae.irq = irq; |
275 | ae.irq_flags = 0; | 278 | ae.irq_flags = 0; |
276 | ae.port_flags = ATA_FLAG_SLAVE_POSS | ATA_FLAG_SRST; | ||
277 | ae.port[0].cmd_addr = io_addr; | 279 | ae.port[0].cmd_addr = io_addr; |
278 | ae.port[0].altstatus_addr = ctl_addr; | 280 | ae.port[0].altstatus_addr = ctl_addr; |
279 | ae.port[0].ctl_addr = ctl_addr; | 281 | ae.port[0].ctl_addr = ctl_addr; |
diff --git a/drivers/ata/pata_sl82c105.c b/drivers/ata/pata_sl82c105.c index f2fa158d07ca..96e890fd645b 100644 --- a/drivers/ata/pata_sl82c105.c +++ b/drivers/ata/pata_sl82c105.c | |||
@@ -187,7 +187,9 @@ static void sl82c105_bmdma_start(struct ata_queued_cmd *qc) | |||
187 | { | 187 | { |
188 | struct ata_port *ap = qc->ap; | 188 | struct ata_port *ap = qc->ap; |
189 | 189 | ||
190 | udelay(100); | ||
190 | sl82c105_reset_engine(ap); | 191 | sl82c105_reset_engine(ap); |
192 | udelay(100); | ||
191 | 193 | ||
192 | /* Set the clocks for DMA */ | 194 | /* Set the clocks for DMA */ |
193 | sl82c105_configure_dmamode(ap, qc->dev); | 195 | sl82c105_configure_dmamode(ap, qc->dev); |
@@ -216,6 +218,7 @@ static void sl82c105_bmdma_stop(struct ata_queued_cmd *qc) | |||
216 | 218 | ||
217 | ata_bmdma_stop(qc); | 219 | ata_bmdma_stop(qc); |
218 | sl82c105_reset_engine(ap); | 220 | sl82c105_reset_engine(ap); |
221 | udelay(100); | ||
219 | 222 | ||
220 | /* This will redo the initial setup of the DMA device to matching | 223 | /* This will redo the initial setup of the DMA device to matching |
221 | PIO timings */ | 224 | PIO timings */ |
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c index 095ef1b2cd0e..ab92f208dae2 100644 --- a/drivers/ata/sata_nv.c +++ b/drivers/ata/sata_nv.c | |||
@@ -827,7 +827,8 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) | |||
827 | /* freeze if hotplugged or controller error */ | 827 | /* freeze if hotplugged or controller error */ |
828 | if (unlikely(status & (NV_ADMA_STAT_HOTPLUG | | 828 | if (unlikely(status & (NV_ADMA_STAT_HOTPLUG | |
829 | NV_ADMA_STAT_HOTUNPLUG | | 829 | NV_ADMA_STAT_HOTUNPLUG | |
830 | NV_ADMA_STAT_TIMEOUT))) { | 830 | NV_ADMA_STAT_TIMEOUT | |
831 | NV_ADMA_STAT_SERROR))) { | ||
831 | struct ata_eh_info *ehi = &ap->eh_info; | 832 | struct ata_eh_info *ehi = &ap->eh_info; |
832 | 833 | ||
833 | ata_ehi_clear_desc(ehi); | 834 | ata_ehi_clear_desc(ehi); |
@@ -841,6 +842,9 @@ static irqreturn_t nv_adma_interrupt(int irq, void *dev_instance) | |||
841 | } else if (status & NV_ADMA_STAT_HOTUNPLUG) { | 842 | } else if (status & NV_ADMA_STAT_HOTUNPLUG) { |
842 | ata_ehi_hotplugged(ehi); | 843 | ata_ehi_hotplugged(ehi); |
843 | ata_ehi_push_desc(ehi, ": hot unplug"); | 844 | ata_ehi_push_desc(ehi, ": hot unplug"); |
845 | } else if (status & NV_ADMA_STAT_SERROR) { | ||
846 | /* let libata analyze SError and figure out the cause */ | ||
847 | ata_ehi_push_desc(ehi, ": SError"); | ||
844 | } | 848 | } |
845 | ata_port_freeze(ap); | 849 | ata_port_freeze(ap); |
846 | continue; | 850 | continue; |
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c index b2e2e695c92e..cf9ed8c39301 100644 --- a/drivers/ata/sata_promise.c +++ b/drivers/ata/sata_promise.c | |||
@@ -119,9 +119,7 @@ static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg); | |||
119 | static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); | 119 | static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); |
120 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); | 120 | static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); |
121 | static irqreturn_t pdc_interrupt (int irq, void *dev_instance); | 121 | static irqreturn_t pdc_interrupt (int irq, void *dev_instance); |
122 | static void pdc_eng_timeout(struct ata_port *ap); | ||
123 | static int pdc_port_start(struct ata_port *ap); | 122 | static int pdc_port_start(struct ata_port *ap); |
124 | static void pdc_pata_phy_reset(struct ata_port *ap); | ||
125 | static void pdc_qc_prep(struct ata_queued_cmd *qc); | 123 | static void pdc_qc_prep(struct ata_queued_cmd *qc); |
126 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 124 | static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
127 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); | 125 | static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); |
@@ -215,12 +213,12 @@ static const struct ata_port_operations pdc_pata_ops = { | |||
215 | .dev_select = ata_std_dev_select, | 213 | .dev_select = ata_std_dev_select, |
216 | .check_atapi_dma = pdc_check_atapi_dma, | 214 | .check_atapi_dma = pdc_check_atapi_dma, |
217 | 215 | ||
218 | .phy_reset = pdc_pata_phy_reset, | ||
219 | |||
220 | .qc_prep = pdc_qc_prep, | 216 | .qc_prep = pdc_qc_prep, |
221 | .qc_issue = pdc_qc_issue_prot, | 217 | .qc_issue = pdc_qc_issue_prot, |
218 | .freeze = pdc_freeze, | ||
219 | .thaw = pdc_thaw, | ||
220 | .error_handler = pdc_error_handler, | ||
222 | .data_xfer = ata_data_xfer, | 221 | .data_xfer = ata_data_xfer, |
223 | .eng_timeout = pdc_eng_timeout, | ||
224 | .irq_handler = pdc_interrupt, | 222 | .irq_handler = pdc_interrupt, |
225 | .irq_clear = pdc_irq_clear, | 223 | .irq_clear = pdc_irq_clear, |
226 | .irq_on = ata_irq_on, | 224 | .irq_on = ata_irq_on, |
@@ -253,7 +251,7 @@ static const struct ata_port_info pdc_port_info[] = { | |||
253 | /* board_20619 */ | 251 | /* board_20619 */ |
254 | { | 252 | { |
255 | .sht = &pdc_ata_sht, | 253 | .sht = &pdc_ata_sht, |
256 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS, | 254 | .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, |
257 | .pio_mask = 0x1f, /* pio0-4 */ | 255 | .pio_mask = 0x1f, /* pio0-4 */ |
258 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 256 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
259 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | 257 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ |
@@ -389,14 +387,6 @@ static void pdc_pata_cbl_detect(struct ata_port *ap) | |||
389 | ap->cbl = ATA_CBL_PATA80; | 387 | ap->cbl = ATA_CBL_PATA80; |
390 | } | 388 | } |
391 | 389 | ||
392 | static void pdc_pata_phy_reset(struct ata_port *ap) | ||
393 | { | ||
394 | pdc_pata_cbl_detect(ap); | ||
395 | pdc_reset_port(ap); | ||
396 | ata_port_probe(ap); | ||
397 | ata_bus_reset(ap); | ||
398 | } | ||
399 | |||
400 | static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) | 390 | static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) |
401 | { | 391 | { |
402 | if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA) | 392 | if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA) |
@@ -564,6 +554,13 @@ static void pdc_thaw(struct ata_port *ap) | |||
564 | readl(mmio + PDC_CTLSTAT); /* flush */ | 554 | readl(mmio + PDC_CTLSTAT); /* flush */ |
565 | } | 555 | } |
566 | 556 | ||
557 | static int pdc_pre_reset(struct ata_port *ap) | ||
558 | { | ||
559 | if (!sata_scr_valid(ap)) | ||
560 | pdc_pata_cbl_detect(ap); | ||
561 | return ata_std_prereset(ap); | ||
562 | } | ||
563 | |||
567 | static void pdc_error_handler(struct ata_port *ap) | 564 | static void pdc_error_handler(struct ata_port *ap) |
568 | { | 565 | { |
569 | ata_reset_fn_t hardreset; | 566 | ata_reset_fn_t hardreset; |
@@ -576,7 +573,7 @@ static void pdc_error_handler(struct ata_port *ap) | |||
576 | hardreset = sata_std_hardreset; | 573 | hardreset = sata_std_hardreset; |
577 | 574 | ||
578 | /* perform recovery */ | 575 | /* perform recovery */ |
579 | ata_do_eh(ap, ata_std_prereset, ata_std_softreset, hardreset, | 576 | ata_do_eh(ap, pdc_pre_reset, ata_std_softreset, hardreset, |
580 | ata_std_postreset); | 577 | ata_std_postreset); |
581 | } | 578 | } |
582 | 579 | ||
@@ -592,43 +589,6 @@ static void pdc_post_internal_cmd(struct ata_queued_cmd *qc) | |||
592 | pdc_reset_port(ap); | 589 | pdc_reset_port(ap); |
593 | } | 590 | } |
594 | 591 | ||
595 | static void pdc_eng_timeout(struct ata_port *ap) | ||
596 | { | ||
597 | struct ata_host *host = ap->host; | ||
598 | u8 drv_stat; | ||
599 | struct ata_queued_cmd *qc; | ||
600 | unsigned long flags; | ||
601 | |||
602 | DPRINTK("ENTER\n"); | ||
603 | |||
604 | spin_lock_irqsave(&host->lock, flags); | ||
605 | |||
606 | qc = ata_qc_from_tag(ap, ap->active_tag); | ||
607 | |||
608 | switch (qc->tf.protocol) { | ||
609 | case ATA_PROT_DMA: | ||
610 | case ATA_PROT_NODATA: | ||
611 | ata_port_printk(ap, KERN_ERR, "command timeout\n"); | ||
612 | drv_stat = ata_wait_idle(ap); | ||
613 | qc->err_mask |= __ac_err_mask(drv_stat); | ||
614 | break; | ||
615 | |||
616 | default: | ||
617 | drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); | ||
618 | |||
619 | ata_port_printk(ap, KERN_ERR, | ||
620 | "unknown timeout, cmd 0x%x stat 0x%x\n", | ||
621 | qc->tf.command, drv_stat); | ||
622 | |||
623 | qc->err_mask |= ac_err_mask(drv_stat); | ||
624 | break; | ||
625 | } | ||
626 | |||
627 | spin_unlock_irqrestore(&host->lock, flags); | ||
628 | ata_eh_qc_complete(qc); | ||
629 | DPRINTK("EXIT\n"); | ||
630 | } | ||
631 | |||
632 | static inline unsigned int pdc_host_intr( struct ata_port *ap, | 592 | static inline unsigned int pdc_host_intr( struct ata_port *ap, |
633 | struct ata_queued_cmd *qc) | 593 | struct ata_queued_cmd *qc) |
634 | { | 594 | { |
diff --git a/drivers/ata/sata_vsc.c b/drivers/ata/sata_vsc.c index 3d9daf231115..2fd037bde090 100644 --- a/drivers/ata/sata_vsc.c +++ b/drivers/ata/sata_vsc.c | |||
@@ -346,6 +346,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d | |||
346 | struct ata_probe_ent *probe_ent; | 346 | struct ata_probe_ent *probe_ent; |
347 | void __iomem *mmio_base; | 347 | void __iomem *mmio_base; |
348 | int rc; | 348 | int rc; |
349 | u8 cls; | ||
349 | 350 | ||
350 | if (!printed_version++) | 351 | if (!printed_version++) |
351 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); | 352 | dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); |
@@ -383,9 +384,12 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d | |||
383 | INIT_LIST_HEAD(&probe_ent->node); | 384 | INIT_LIST_HEAD(&probe_ent->node); |
384 | 385 | ||
385 | /* | 386 | /* |
386 | * Due to a bug in the chip, the default cache line size can't be used | 387 | * Due to a bug in the chip, the default cache line size can't be |
388 | * used (unless the default is non-zero). | ||
387 | */ | 389 | */ |
388 | pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x80); | 390 | pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &cls); |
391 | if (cls == 0x00) | ||
392 | pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x80); | ||
389 | 393 | ||
390 | if (pci_enable_msi(pdev) == 0) | 394 | if (pci_enable_msi(pdev) == 0) |
391 | pci_intx(pdev, 0); | 395 | pci_intx(pdev, 0); |
diff --git a/drivers/char/agp/Makefile b/drivers/char/agp/Makefile index 3e581603d0a8..a0d04a23dacd 100644 --- a/drivers/char/agp/Makefile +++ b/drivers/char/agp/Makefile | |||
@@ -1,6 +1,7 @@ | |||
1 | agpgart-y := backend.o frontend.o generic.o isoch.o | 1 | agpgart-y := backend.o frontend.o generic.o isoch.o |
2 | 2 | ||
3 | obj-$(CONFIG_AGP) += agpgart.o | 3 | obj-$(CONFIG_AGP) += agpgart.o |
4 | obj-$(CONFIG_COMPAT) += compat_ioctl.o | ||
4 | obj-$(CONFIG_AGP_ALI) += ali-agp.o | 5 | obj-$(CONFIG_AGP_ALI) += ali-agp.o |
5 | obj-$(CONFIG_AGP_ATI) += ati-agp.o | 6 | obj-$(CONFIG_AGP_ATI) += ati-agp.o |
6 | obj-$(CONFIG_AGP_AMD) += amd-k7-agp.o | 7 | obj-$(CONFIG_AGP_AMD) += amd-k7-agp.o |
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h index 1d59e2a5b9aa..9bd68d9f0f59 100644 --- a/drivers/char/agp/agp.h +++ b/drivers/char/agp/agp.h | |||
@@ -114,6 +114,7 @@ struct agp_bridge_driver { | |||
114 | void (*free_by_type)(struct agp_memory *); | 114 | void (*free_by_type)(struct agp_memory *); |
115 | void *(*agp_alloc_page)(struct agp_bridge_data *); | 115 | void *(*agp_alloc_page)(struct agp_bridge_data *); |
116 | void (*agp_destroy_page)(void *); | 116 | void (*agp_destroy_page)(void *); |
117 | int (*agp_type_to_mask_type) (struct agp_bridge_data *, int); | ||
117 | }; | 118 | }; |
118 | 119 | ||
119 | struct agp_bridge_data { | 120 | struct agp_bridge_data { |
@@ -218,6 +219,7 @@ struct agp_bridge_data { | |||
218 | #define I810_PTE_MAIN_UNCACHED 0x00000000 | 219 | #define I810_PTE_MAIN_UNCACHED 0x00000000 |
219 | #define I810_PTE_LOCAL 0x00000002 | 220 | #define I810_PTE_LOCAL 0x00000002 |
220 | #define I810_PTE_VALID 0x00000001 | 221 | #define I810_PTE_VALID 0x00000001 |
222 | #define I830_PTE_SYSTEM_CACHED 0x00000006 | ||
221 | #define I810_SMRAM_MISCC 0x70 | 223 | #define I810_SMRAM_MISCC 0x70 |
222 | #define I810_GFX_MEM_WIN_SIZE 0x00010000 | 224 | #define I810_GFX_MEM_WIN_SIZE 0x00010000 |
223 | #define I810_GFX_MEM_WIN_32M 0x00010000 | 225 | #define I810_GFX_MEM_WIN_32M 0x00010000 |
@@ -270,8 +272,16 @@ void global_cache_flush(void); | |||
270 | void get_agp_version(struct agp_bridge_data *bridge); | 272 | void get_agp_version(struct agp_bridge_data *bridge); |
271 | unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge, | 273 | unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge, |
272 | unsigned long addr, int type); | 274 | unsigned long addr, int type); |
275 | int agp_generic_type_to_mask_type(struct agp_bridge_data *bridge, | ||
276 | int type); | ||
273 | struct agp_bridge_data *agp_generic_find_bridge(struct pci_dev *pdev); | 277 | struct agp_bridge_data *agp_generic_find_bridge(struct pci_dev *pdev); |
274 | 278 | ||
279 | /* generic functions for user-populated AGP memory types */ | ||
280 | struct agp_memory *agp_generic_alloc_user(size_t page_count, int type); | ||
281 | void agp_alloc_page_array(size_t size, struct agp_memory *mem); | ||
282 | void agp_free_page_array(struct agp_memory *mem); | ||
283 | |||
284 | |||
275 | /* generic routines for agp>=3 */ | 285 | /* generic routines for agp>=3 */ |
276 | int agp3_generic_fetch_size(void); | 286 | int agp3_generic_fetch_size(void); |
277 | void agp3_generic_tlbflush(struct agp_memory *mem); | 287 | void agp3_generic_tlbflush(struct agp_memory *mem); |
@@ -288,6 +298,8 @@ extern struct aper_size_info_16 agp3_generic_sizes[]; | |||
288 | extern int agp_off; | 298 | extern int agp_off; |
289 | extern int agp_try_unsupported_boot; | 299 | extern int agp_try_unsupported_boot; |
290 | 300 | ||
301 | long compat_agp_ioctl(struct file *file, unsigned int cmd, unsigned long arg); | ||
302 | |||
291 | /* Chipset independant registers (from AGP Spec) */ | 303 | /* Chipset independant registers (from AGP Spec) */ |
292 | #define AGP_APBASE 0x10 | 304 | #define AGP_APBASE 0x10 |
293 | 305 | ||
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c index 5a31ec7c62fc..98177a93076f 100644 --- a/drivers/char/agp/ali-agp.c +++ b/drivers/char/agp/ali-agp.c | |||
@@ -214,6 +214,7 @@ static struct agp_bridge_driver ali_generic_bridge = { | |||
214 | .free_by_type = agp_generic_free_by_type, | 214 | .free_by_type = agp_generic_free_by_type, |
215 | .agp_alloc_page = agp_generic_alloc_page, | 215 | .agp_alloc_page = agp_generic_alloc_page, |
216 | .agp_destroy_page = ali_destroy_page, | 216 | .agp_destroy_page = ali_destroy_page, |
217 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
217 | }; | 218 | }; |
218 | 219 | ||
219 | static struct agp_bridge_driver ali_m1541_bridge = { | 220 | static struct agp_bridge_driver ali_m1541_bridge = { |
@@ -237,6 +238,7 @@ static struct agp_bridge_driver ali_m1541_bridge = { | |||
237 | .free_by_type = agp_generic_free_by_type, | 238 | .free_by_type = agp_generic_free_by_type, |
238 | .agp_alloc_page = m1541_alloc_page, | 239 | .agp_alloc_page = m1541_alloc_page, |
239 | .agp_destroy_page = m1541_destroy_page, | 240 | .agp_destroy_page = m1541_destroy_page, |
241 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
240 | }; | 242 | }; |
241 | 243 | ||
242 | 244 | ||
diff --git a/drivers/char/agp/alpha-agp.c b/drivers/char/agp/alpha-agp.c index b4e00a343da9..b0acf41c0db9 100644 --- a/drivers/char/agp/alpha-agp.c +++ b/drivers/char/agp/alpha-agp.c | |||
@@ -91,6 +91,9 @@ static int alpha_core_agp_insert_memory(struct agp_memory *mem, off_t pg_start, | |||
91 | int num_entries, status; | 91 | int num_entries, status; |
92 | void *temp; | 92 | void *temp; |
93 | 93 | ||
94 | if (type >= AGP_USER_TYPES || mem->type >= AGP_USER_TYPES) | ||
95 | return -EINVAL; | ||
96 | |||
94 | temp = agp_bridge->current_size; | 97 | temp = agp_bridge->current_size; |
95 | num_entries = A_SIZE_FIX(temp)->num_entries; | 98 | num_entries = A_SIZE_FIX(temp)->num_entries; |
96 | if ((pg_start + mem->page_count) > num_entries) | 99 | if ((pg_start + mem->page_count) > num_entries) |
@@ -142,6 +145,7 @@ struct agp_bridge_driver alpha_core_agp_driver = { | |||
142 | .free_by_type = agp_generic_free_by_type, | 145 | .free_by_type = agp_generic_free_by_type, |
143 | .agp_alloc_page = agp_generic_alloc_page, | 146 | .agp_alloc_page = agp_generic_alloc_page, |
144 | .agp_destroy_page = agp_generic_destroy_page, | 147 | .agp_destroy_page = agp_generic_destroy_page, |
148 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
145 | }; | 149 | }; |
146 | 150 | ||
147 | struct agp_bridge_data *alpha_bridge; | 151 | struct agp_bridge_data *alpha_bridge; |
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c index c85c8cadb6df..3d8d448bf394 100644 --- a/drivers/char/agp/amd-k7-agp.c +++ b/drivers/char/agp/amd-k7-agp.c | |||
@@ -381,6 +381,7 @@ static struct agp_bridge_driver amd_irongate_driver = { | |||
381 | .free_by_type = agp_generic_free_by_type, | 381 | .free_by_type = agp_generic_free_by_type, |
382 | .agp_alloc_page = agp_generic_alloc_page, | 382 | .agp_alloc_page = agp_generic_alloc_page, |
383 | .agp_destroy_page = agp_generic_destroy_page, | 383 | .agp_destroy_page = agp_generic_destroy_page, |
384 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
384 | }; | 385 | }; |
385 | 386 | ||
386 | static struct agp_device_ids amd_agp_device_ids[] __devinitdata = | 387 | static struct agp_device_ids amd_agp_device_ids[] __devinitdata = |
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c index 93d2209fee4c..636d984ed4a6 100644 --- a/drivers/char/agp/amd64-agp.c +++ b/drivers/char/agp/amd64-agp.c | |||
@@ -62,12 +62,18 @@ static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
62 | { | 62 | { |
63 | int i, j, num_entries; | 63 | int i, j, num_entries; |
64 | long long tmp; | 64 | long long tmp; |
65 | int mask_type; | ||
66 | struct agp_bridge_data *bridge = mem->bridge; | ||
65 | u32 pte; | 67 | u32 pte; |
66 | 68 | ||
67 | num_entries = agp_num_entries(); | 69 | num_entries = agp_num_entries(); |
68 | 70 | ||
69 | if (type != 0 || mem->type != 0) | 71 | if (type != mem->type) |
70 | return -EINVAL; | 72 | return -EINVAL; |
73 | mask_type = bridge->driver->agp_type_to_mask_type(bridge, type); | ||
74 | if (mask_type != 0) | ||
75 | return -EINVAL; | ||
76 | |||
71 | 77 | ||
72 | /* Make sure we can fit the range in the gatt table. */ | 78 | /* Make sure we can fit the range in the gatt table. */ |
73 | /* FIXME: could wrap */ | 79 | /* FIXME: could wrap */ |
@@ -90,7 +96,7 @@ static int amd64_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
90 | 96 | ||
91 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 97 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
92 | tmp = agp_bridge->driver->mask_memory(agp_bridge, | 98 | tmp = agp_bridge->driver->mask_memory(agp_bridge, |
93 | mem->memory[i], mem->type); | 99 | mem->memory[i], mask_type); |
94 | 100 | ||
95 | BUG_ON(tmp & 0xffffff0000000ffcULL); | 101 | BUG_ON(tmp & 0xffffff0000000ffcULL); |
96 | pte = (tmp & 0x000000ff00000000ULL) >> 28; | 102 | pte = (tmp & 0x000000ff00000000ULL) >> 28; |
@@ -247,6 +253,7 @@ static struct agp_bridge_driver amd_8151_driver = { | |||
247 | .free_by_type = agp_generic_free_by_type, | 253 | .free_by_type = agp_generic_free_by_type, |
248 | .agp_alloc_page = agp_generic_alloc_page, | 254 | .agp_alloc_page = agp_generic_alloc_page, |
249 | .agp_destroy_page = agp_generic_destroy_page, | 255 | .agp_destroy_page = agp_generic_destroy_page, |
256 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
250 | }; | 257 | }; |
251 | 258 | ||
252 | /* Some basic sanity checks for the aperture. */ | 259 | /* Some basic sanity checks for the aperture. */ |
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c index 9987dc2e0c3f..77c9ad68fba9 100644 --- a/drivers/char/agp/ati-agp.c +++ b/drivers/char/agp/ati-agp.c | |||
@@ -431,6 +431,7 @@ static struct agp_bridge_driver ati_generic_bridge = { | |||
431 | .free_by_type = agp_generic_free_by_type, | 431 | .free_by_type = agp_generic_free_by_type, |
432 | .agp_alloc_page = agp_generic_alloc_page, | 432 | .agp_alloc_page = agp_generic_alloc_page, |
433 | .agp_destroy_page = agp_generic_destroy_page, | 433 | .agp_destroy_page = agp_generic_destroy_page, |
434 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
434 | }; | 435 | }; |
435 | 436 | ||
436 | 437 | ||
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c index d59e037ddd12..ebdd6dd66edb 100644 --- a/drivers/char/agp/backend.c +++ b/drivers/char/agp/backend.c | |||
@@ -43,7 +43,7 @@ | |||
43 | * fix some real stupidity. It's only by chance we can bump | 43 | * fix some real stupidity. It's only by chance we can bump |
44 | * past 0.99 at all due to some boolean logic error. */ | 44 | * past 0.99 at all due to some boolean logic error. */ |
45 | #define AGPGART_VERSION_MAJOR 0 | 45 | #define AGPGART_VERSION_MAJOR 0 |
46 | #define AGPGART_VERSION_MINOR 101 | 46 | #define AGPGART_VERSION_MINOR 102 |
47 | static const struct agp_version agp_current_version = | 47 | static const struct agp_version agp_current_version = |
48 | { | 48 | { |
49 | .major = AGPGART_VERSION_MAJOR, | 49 | .major = AGPGART_VERSION_MAJOR, |
diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c new file mode 100644 index 000000000000..fcb4b1bf0d4e --- /dev/null +++ b/drivers/char/agp/compat_ioctl.c | |||
@@ -0,0 +1,282 @@ | |||
1 | /* | ||
2 | * AGPGART driver frontend compatibility ioctls | ||
3 | * Copyright (C) 2004 Silicon Graphics, Inc. | ||
4 | * Copyright (C) 2002-2003 Dave Jones | ||
5 | * Copyright (C) 1999 Jeff Hartmann | ||
6 | * Copyright (C) 1999 Precision Insight, Inc. | ||
7 | * Copyright (C) 1999 Xi Graphics, Inc. | ||
8 | * | ||
9 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
10 | * copy of this software and associated documentation files (the "Software"), | ||
11 | * to deal in the Software without restriction, including without limitation | ||
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
13 | * and/or sell copies of the Software, and to permit persons to whom the | ||
14 | * Software is furnished to do so, subject to the following conditions: | ||
15 | * | ||
16 | * The above copyright notice and this permission notice shall be included | ||
17 | * in all copies or substantial portions of the Software. | ||
18 | * | ||
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
22 | * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, | ||
23 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
24 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | ||
25 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | #include <linux/kernel.h> | ||
30 | #include <linux/pci.h> | ||
31 | #include <linux/agpgart.h> | ||
32 | #include <asm/uaccess.h> | ||
33 | #include "agp.h" | ||
34 | #include "compat_ioctl.h" | ||
35 | |||
36 | static int compat_agpioc_info_wrap(struct agp_file_private *priv, void __user *arg) | ||
37 | { | ||
38 | struct agp_info32 userinfo; | ||
39 | struct agp_kern_info kerninfo; | ||
40 | |||
41 | agp_copy_info(agp_bridge, &kerninfo); | ||
42 | |||
43 | userinfo.version.major = kerninfo.version.major; | ||
44 | userinfo.version.minor = kerninfo.version.minor; | ||
45 | userinfo.bridge_id = kerninfo.device->vendor | | ||
46 | (kerninfo.device->device << 16); | ||
47 | userinfo.agp_mode = kerninfo.mode; | ||
48 | userinfo.aper_base = (compat_long_t)kerninfo.aper_base; | ||
49 | userinfo.aper_size = kerninfo.aper_size; | ||
50 | userinfo.pg_total = userinfo.pg_system = kerninfo.max_memory; | ||
51 | userinfo.pg_used = kerninfo.current_memory; | ||
52 | |||
53 | if (copy_to_user(arg, &userinfo, sizeof(userinfo))) | ||
54 | return -EFAULT; | ||
55 | |||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg) | ||
60 | { | ||
61 | struct agp_region32 ureserve; | ||
62 | struct agp_region kreserve; | ||
63 | struct agp_client *client; | ||
64 | struct agp_file_private *client_priv; | ||
65 | |||
66 | DBG(""); | ||
67 | if (copy_from_user(&ureserve, arg, sizeof(ureserve))) | ||
68 | return -EFAULT; | ||
69 | |||
70 | if ((unsigned) ureserve.seg_count >= ~0U/sizeof(struct agp_segment32)) | ||
71 | return -EFAULT; | ||
72 | |||
73 | kreserve.pid = ureserve.pid; | ||
74 | kreserve.seg_count = ureserve.seg_count; | ||
75 | |||
76 | client = agp_find_client_by_pid(kreserve.pid); | ||
77 | |||
78 | if (kreserve.seg_count == 0) { | ||
79 | /* remove a client */ | ||
80 | client_priv = agp_find_private(kreserve.pid); | ||
81 | |||
82 | if (client_priv != NULL) { | ||
83 | set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags); | ||
84 | set_bit(AGP_FF_IS_VALID, &client_priv->access_flags); | ||
85 | } | ||
86 | if (client == NULL) { | ||
87 | /* client is already removed */ | ||
88 | return 0; | ||
89 | } | ||
90 | return agp_remove_client(kreserve.pid); | ||
91 | } else { | ||
92 | struct agp_segment32 *usegment; | ||
93 | struct agp_segment *ksegment; | ||
94 | int seg; | ||
95 | |||
96 | if (ureserve.seg_count >= 16384) | ||
97 | return -EINVAL; | ||
98 | |||
99 | usegment = kmalloc(sizeof(*usegment) * ureserve.seg_count, GFP_KERNEL); | ||
100 | if (!usegment) | ||
101 | return -ENOMEM; | ||
102 | |||
103 | ksegment = kmalloc(sizeof(*ksegment) * kreserve.seg_count, GFP_KERNEL); | ||
104 | if (!ksegment) { | ||
105 | kfree(usegment); | ||
106 | return -ENOMEM; | ||
107 | } | ||
108 | |||
109 | if (copy_from_user(usegment, (void __user *) ureserve.seg_list, | ||
110 | sizeof(*usegment) * ureserve.seg_count)) { | ||
111 | kfree(usegment); | ||
112 | kfree(ksegment); | ||
113 | return -EFAULT; | ||
114 | } | ||
115 | |||
116 | for (seg = 0; seg < ureserve.seg_count; seg++) { | ||
117 | ksegment[seg].pg_start = usegment[seg].pg_start; | ||
118 | ksegment[seg].pg_count = usegment[seg].pg_count; | ||
119 | ksegment[seg].prot = usegment[seg].prot; | ||
120 | } | ||
121 | |||
122 | kfree(usegment); | ||
123 | kreserve.seg_list = ksegment; | ||
124 | |||
125 | if (client == NULL) { | ||
126 | /* Create the client and add the segment */ | ||
127 | client = agp_create_client(kreserve.pid); | ||
128 | |||
129 | if (client == NULL) { | ||
130 | kfree(ksegment); | ||
131 | return -ENOMEM; | ||
132 | } | ||
133 | client_priv = agp_find_private(kreserve.pid); | ||
134 | |||
135 | if (client_priv != NULL) { | ||
136 | set_bit(AGP_FF_IS_CLIENT, &client_priv->access_flags); | ||
137 | set_bit(AGP_FF_IS_VALID, &client_priv->access_flags); | ||
138 | } | ||
139 | } | ||
140 | return agp_create_segment(client, &kreserve); | ||
141 | } | ||
142 | /* Will never really happen */ | ||
143 | return -EINVAL; | ||
144 | } | ||
145 | |||
146 | static int compat_agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg) | ||
147 | { | ||
148 | struct agp_memory *memory; | ||
149 | struct agp_allocate32 alloc; | ||
150 | |||
151 | DBG(""); | ||
152 | if (copy_from_user(&alloc, arg, sizeof(alloc))) | ||
153 | return -EFAULT; | ||
154 | |||
155 | memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type); | ||
156 | |||
157 | if (memory == NULL) | ||
158 | return -ENOMEM; | ||
159 | |||
160 | alloc.key = memory->key; | ||
161 | alloc.physical = memory->physical; | ||
162 | |||
163 | if (copy_to_user(arg, &alloc, sizeof(alloc))) { | ||
164 | agp_free_memory_wrap(memory); | ||
165 | return -EFAULT; | ||
166 | } | ||
167 | return 0; | ||
168 | } | ||
169 | |||
170 | static int compat_agpioc_bind_wrap(struct agp_file_private *priv, void __user *arg) | ||
171 | { | ||
172 | struct agp_bind32 bind_info; | ||
173 | struct agp_memory *memory; | ||
174 | |||
175 | DBG(""); | ||
176 | if (copy_from_user(&bind_info, arg, sizeof(bind_info))) | ||
177 | return -EFAULT; | ||
178 | |||
179 | memory = agp_find_mem_by_key(bind_info.key); | ||
180 | |||
181 | if (memory == NULL) | ||
182 | return -EINVAL; | ||
183 | |||
184 | return agp_bind_memory(memory, bind_info.pg_start); | ||
185 | } | ||
186 | |||
187 | static int compat_agpioc_unbind_wrap(struct agp_file_private *priv, void __user *arg) | ||
188 | { | ||
189 | struct agp_memory *memory; | ||
190 | struct agp_unbind32 unbind; | ||
191 | |||
192 | DBG(""); | ||
193 | if (copy_from_user(&unbind, arg, sizeof(unbind))) | ||
194 | return -EFAULT; | ||
195 | |||
196 | memory = agp_find_mem_by_key(unbind.key); | ||
197 | |||
198 | if (memory == NULL) | ||
199 | return -EINVAL; | ||
200 | |||
201 | return agp_unbind_memory(memory); | ||
202 | } | ||
203 | |||
204 | long compat_agp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
205 | { | ||
206 | struct agp_file_private *curr_priv = file->private_data; | ||
207 | int ret_val = -ENOTTY; | ||
208 | |||
209 | mutex_lock(&(agp_fe.agp_mutex)); | ||
210 | |||
211 | if ((agp_fe.current_controller == NULL) && | ||
212 | (cmd != AGPIOC_ACQUIRE32)) { | ||
213 | ret_val = -EINVAL; | ||
214 | goto ioctl_out; | ||
215 | } | ||
216 | if ((agp_fe.backend_acquired != TRUE) && | ||
217 | (cmd != AGPIOC_ACQUIRE32)) { | ||
218 | ret_val = -EBUSY; | ||
219 | goto ioctl_out; | ||
220 | } | ||
221 | if (cmd != AGPIOC_ACQUIRE32) { | ||
222 | if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) { | ||
223 | ret_val = -EPERM; | ||
224 | goto ioctl_out; | ||
225 | } | ||
226 | /* Use the original pid of the controller, | ||
227 | * in case it's threaded */ | ||
228 | |||
229 | if (agp_fe.current_controller->pid != curr_priv->my_pid) { | ||
230 | ret_val = -EBUSY; | ||
231 | goto ioctl_out; | ||
232 | } | ||
233 | } | ||
234 | |||
235 | switch (cmd) { | ||
236 | case AGPIOC_INFO32: | ||
237 | ret_val = compat_agpioc_info_wrap(curr_priv, (void __user *) arg); | ||
238 | break; | ||
239 | |||
240 | case AGPIOC_ACQUIRE32: | ||
241 | ret_val = agpioc_acquire_wrap(curr_priv); | ||
242 | break; | ||
243 | |||
244 | case AGPIOC_RELEASE32: | ||
245 | ret_val = agpioc_release_wrap(curr_priv); | ||
246 | break; | ||
247 | |||
248 | case AGPIOC_SETUP32: | ||
249 | ret_val = agpioc_setup_wrap(curr_priv, (void __user *) arg); | ||
250 | break; | ||
251 | |||
252 | case AGPIOC_RESERVE32: | ||
253 | ret_val = compat_agpioc_reserve_wrap(curr_priv, (void __user *) arg); | ||
254 | break; | ||
255 | |||
256 | case AGPIOC_PROTECT32: | ||
257 | ret_val = agpioc_protect_wrap(curr_priv); | ||
258 | break; | ||
259 | |||
260 | case AGPIOC_ALLOCATE32: | ||
261 | ret_val = compat_agpioc_allocate_wrap(curr_priv, (void __user *) arg); | ||
262 | break; | ||
263 | |||
264 | case AGPIOC_DEALLOCATE32: | ||
265 | ret_val = agpioc_deallocate_wrap(curr_priv, (int) arg); | ||
266 | break; | ||
267 | |||
268 | case AGPIOC_BIND32: | ||
269 | ret_val = compat_agpioc_bind_wrap(curr_priv, (void __user *) arg); | ||
270 | break; | ||
271 | |||
272 | case AGPIOC_UNBIND32: | ||
273 | ret_val = compat_agpioc_unbind_wrap(curr_priv, (void __user *) arg); | ||
274 | break; | ||
275 | } | ||
276 | |||
277 | ioctl_out: | ||
278 | DBG("ioctl returns %d\n", ret_val); | ||
279 | mutex_unlock(&(agp_fe.agp_mutex)); | ||
280 | return ret_val; | ||
281 | } | ||
282 | |||
diff --git a/drivers/char/agp/compat_ioctl.h b/drivers/char/agp/compat_ioctl.h new file mode 100644 index 000000000000..71939d637236 --- /dev/null +++ b/drivers/char/agp/compat_ioctl.h | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * Copyright (C) 1999 Jeff Hartmann | ||
3 | * Copyright (C) 1999 Precision Insight, Inc. | ||
4 | * Copyright (C) 1999 Xi Graphics, Inc. | ||
5 | * | ||
6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
7 | * copy of this software and associated documentation files (the "Software"), | ||
8 | * to deal in the Software without restriction, including without limitation | ||
9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
10 | * and/or sell copies of the Software, and to permit persons to whom the | ||
11 | * Software is furnished to do so, subject to the following conditions: | ||
12 | * | ||
13 | * The above copyright notice and this permission notice shall be included | ||
14 | * in all copies or substantial portions of the Software. | ||
15 | * | ||
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
19 | * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, | ||
20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
21 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE | ||
22 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
23 | * | ||
24 | */ | ||
25 | |||
26 | #ifndef _AGP_COMPAT_IOCTL_H | ||
27 | #define _AGP_COMPAT_IOCTL_H | ||
28 | |||
29 | #include <linux/compat.h> | ||
30 | #include <linux/agpgart.h> | ||
31 | |||
32 | #define AGPIOC_INFO32 _IOR (AGPIOC_BASE, 0, compat_uptr_t) | ||
33 | #define AGPIOC_ACQUIRE32 _IO (AGPIOC_BASE, 1) | ||
34 | #define AGPIOC_RELEASE32 _IO (AGPIOC_BASE, 2) | ||
35 | #define AGPIOC_SETUP32 _IOW (AGPIOC_BASE, 3, compat_uptr_t) | ||
36 | #define AGPIOC_RESERVE32 _IOW (AGPIOC_BASE, 4, compat_uptr_t) | ||
37 | #define AGPIOC_PROTECT32 _IOW (AGPIOC_BASE, 5, compat_uptr_t) | ||
38 | #define AGPIOC_ALLOCATE32 _IOWR(AGPIOC_BASE, 6, compat_uptr_t) | ||
39 | #define AGPIOC_DEALLOCATE32 _IOW (AGPIOC_BASE, 7, compat_int_t) | ||
40 | #define AGPIOC_BIND32 _IOW (AGPIOC_BASE, 8, compat_uptr_t) | ||
41 | #define AGPIOC_UNBIND32 _IOW (AGPIOC_BASE, 9, compat_uptr_t) | ||
42 | |||
43 | struct agp_info32 { | ||
44 | struct agp_version version; /* version of the driver */ | ||
45 | u32 bridge_id; /* bridge vendor/device */ | ||
46 | u32 agp_mode; /* mode info of bridge */ | ||
47 | compat_long_t aper_base; /* base of aperture */ | ||
48 | compat_size_t aper_size; /* size of aperture */ | ||
49 | compat_size_t pg_total; /* max pages (swap + system) */ | ||
50 | compat_size_t pg_system; /* max pages (system) */ | ||
51 | compat_size_t pg_used; /* current pages used */ | ||
52 | }; | ||
53 | |||
54 | /* | ||
55 | * The "prot" down below needs still a "sleep" flag somehow ... | ||
56 | */ | ||
57 | struct agp_segment32 { | ||
58 | compat_off_t pg_start; /* starting page to populate */ | ||
59 | compat_size_t pg_count; /* number of pages */ | ||
60 | compat_int_t prot; /* prot flags for mmap */ | ||
61 | }; | ||
62 | |||
63 | struct agp_region32 { | ||
64 | compat_pid_t pid; /* pid of process */ | ||
65 | compat_size_t seg_count; /* number of segments */ | ||
66 | struct agp_segment32 *seg_list; | ||
67 | }; | ||
68 | |||
69 | struct agp_allocate32 { | ||
70 | compat_int_t key; /* tag of allocation */ | ||
71 | compat_size_t pg_count; /* number of pages */ | ||
72 | u32 type; /* 0 == normal, other devspec */ | ||
73 | u32 physical; /* device specific (some devices | ||
74 | * need a phys address of the | ||
75 | * actual page behind the gatt | ||
76 | * table) */ | ||
77 | }; | ||
78 | |||
79 | struct agp_bind32 { | ||
80 | compat_int_t key; /* tag of allocation */ | ||
81 | compat_off_t pg_start; /* starting page to populate */ | ||
82 | }; | ||
83 | |||
84 | struct agp_unbind32 { | ||
85 | compat_int_t key; /* tag of allocation */ | ||
86 | u32 priority; /* priority for paging out */ | ||
87 | }; | ||
88 | |||
89 | extern struct agp_front_data agp_fe; | ||
90 | |||
91 | int agpioc_acquire_wrap(struct agp_file_private *priv); | ||
92 | int agpioc_release_wrap(struct agp_file_private *priv); | ||
93 | int agpioc_protect_wrap(struct agp_file_private *priv); | ||
94 | int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg); | ||
95 | int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg); | ||
96 | struct agp_file_private *agp_find_private(pid_t pid); | ||
97 | struct agp_client *agp_create_client(pid_t id); | ||
98 | int agp_remove_client(pid_t id); | ||
99 | int agp_create_segment(struct agp_client *client, struct agp_region *region); | ||
100 | void agp_free_memory_wrap(struct agp_memory *memory); | ||
101 | struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type); | ||
102 | struct agp_memory *agp_find_mem_by_key(int key); | ||
103 | struct agp_client *agp_find_client_by_pid(pid_t id); | ||
104 | |||
105 | #endif /* _AGP_COMPAT_H */ | ||
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c index 30f730ff81c1..658cb1a72d2c 100644 --- a/drivers/char/agp/efficeon-agp.c +++ b/drivers/char/agp/efficeon-agp.c | |||
@@ -335,6 +335,7 @@ static struct agp_bridge_driver efficeon_driver = { | |||
335 | .free_by_type = agp_generic_free_by_type, | 335 | .free_by_type = agp_generic_free_by_type, |
336 | .agp_alloc_page = agp_generic_alloc_page, | 336 | .agp_alloc_page = agp_generic_alloc_page, |
337 | .agp_destroy_page = agp_generic_destroy_page, | 337 | .agp_destroy_page = agp_generic_destroy_page, |
338 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
338 | }; | 339 | }; |
339 | 340 | ||
340 | static int __devinit agp_efficeon_probe(struct pci_dev *pdev, | 341 | static int __devinit agp_efficeon_probe(struct pci_dev *pdev, |
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c index 0f2ed2aa2d81..679d7f972439 100644 --- a/drivers/char/agp/frontend.c +++ b/drivers/char/agp/frontend.c | |||
@@ -41,9 +41,9 @@ | |||
41 | #include <asm/pgtable.h> | 41 | #include <asm/pgtable.h> |
42 | #include "agp.h" | 42 | #include "agp.h" |
43 | 43 | ||
44 | static struct agp_front_data agp_fe; | 44 | struct agp_front_data agp_fe; |
45 | 45 | ||
46 | static struct agp_memory *agp_find_mem_by_key(int key) | 46 | struct agp_memory *agp_find_mem_by_key(int key) |
47 | { | 47 | { |
48 | struct agp_memory *curr; | 48 | struct agp_memory *curr; |
49 | 49 | ||
@@ -159,7 +159,7 @@ static pgprot_t agp_convert_mmap_flags(int prot) | |||
159 | return vm_get_page_prot(prot_bits); | 159 | return vm_get_page_prot(prot_bits); |
160 | } | 160 | } |
161 | 161 | ||
162 | static int agp_create_segment(struct agp_client *client, struct agp_region *region) | 162 | int agp_create_segment(struct agp_client *client, struct agp_region *region) |
163 | { | 163 | { |
164 | struct agp_segment_priv **ret_seg; | 164 | struct agp_segment_priv **ret_seg; |
165 | struct agp_segment_priv *seg; | 165 | struct agp_segment_priv *seg; |
@@ -211,7 +211,7 @@ static void agp_insert_into_pool(struct agp_memory * temp) | |||
211 | 211 | ||
212 | /* File private list routines */ | 212 | /* File private list routines */ |
213 | 213 | ||
214 | static struct agp_file_private *agp_find_private(pid_t pid) | 214 | struct agp_file_private *agp_find_private(pid_t pid) |
215 | { | 215 | { |
216 | struct agp_file_private *curr; | 216 | struct agp_file_private *curr; |
217 | 217 | ||
@@ -266,13 +266,13 @@ static void agp_remove_file_private(struct agp_file_private * priv) | |||
266 | * Wrappers for agp_free_memory & agp_allocate_memory | 266 | * Wrappers for agp_free_memory & agp_allocate_memory |
267 | * These make sure that internal lists are kept updated. | 267 | * These make sure that internal lists are kept updated. |
268 | */ | 268 | */ |
269 | static void agp_free_memory_wrap(struct agp_memory *memory) | 269 | void agp_free_memory_wrap(struct agp_memory *memory) |
270 | { | 270 | { |
271 | agp_remove_from_pool(memory); | 271 | agp_remove_from_pool(memory); |
272 | agp_free_memory(memory); | 272 | agp_free_memory(memory); |
273 | } | 273 | } |
274 | 274 | ||
275 | static struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type) | 275 | struct agp_memory *agp_allocate_memory_wrap(size_t pg_count, u32 type) |
276 | { | 276 | { |
277 | struct agp_memory *memory; | 277 | struct agp_memory *memory; |
278 | 278 | ||
@@ -484,7 +484,7 @@ static struct agp_controller *agp_find_controller_for_client(pid_t id) | |||
484 | return NULL; | 484 | return NULL; |
485 | } | 485 | } |
486 | 486 | ||
487 | static struct agp_client *agp_find_client_by_pid(pid_t id) | 487 | struct agp_client *agp_find_client_by_pid(pid_t id) |
488 | { | 488 | { |
489 | struct agp_client *temp; | 489 | struct agp_client *temp; |
490 | 490 | ||
@@ -509,7 +509,7 @@ static void agp_insert_client(struct agp_client *client) | |||
509 | agp_fe.current_controller->num_clients++; | 509 | agp_fe.current_controller->num_clients++; |
510 | } | 510 | } |
511 | 511 | ||
512 | static struct agp_client *agp_create_client(pid_t id) | 512 | struct agp_client *agp_create_client(pid_t id) |
513 | { | 513 | { |
514 | struct agp_client *new_client; | 514 | struct agp_client *new_client; |
515 | 515 | ||
@@ -522,7 +522,7 @@ static struct agp_client *agp_create_client(pid_t id) | |||
522 | return new_client; | 522 | return new_client; |
523 | } | 523 | } |
524 | 524 | ||
525 | static int agp_remove_client(pid_t id) | 525 | int agp_remove_client(pid_t id) |
526 | { | 526 | { |
527 | struct agp_client *client; | 527 | struct agp_client *client; |
528 | struct agp_client *prev_client; | 528 | struct agp_client *prev_client; |
@@ -746,7 +746,7 @@ static int agpioc_info_wrap(struct agp_file_private *priv, void __user *arg) | |||
746 | return 0; | 746 | return 0; |
747 | } | 747 | } |
748 | 748 | ||
749 | static int agpioc_acquire_wrap(struct agp_file_private *priv) | 749 | int agpioc_acquire_wrap(struct agp_file_private *priv) |
750 | { | 750 | { |
751 | struct agp_controller *controller; | 751 | struct agp_controller *controller; |
752 | 752 | ||
@@ -789,14 +789,14 @@ static int agpioc_acquire_wrap(struct agp_file_private *priv) | |||
789 | return 0; | 789 | return 0; |
790 | } | 790 | } |
791 | 791 | ||
792 | static int agpioc_release_wrap(struct agp_file_private *priv) | 792 | int agpioc_release_wrap(struct agp_file_private *priv) |
793 | { | 793 | { |
794 | DBG(""); | 794 | DBG(""); |
795 | agp_controller_release_current(agp_fe.current_controller, priv); | 795 | agp_controller_release_current(agp_fe.current_controller, priv); |
796 | return 0; | 796 | return 0; |
797 | } | 797 | } |
798 | 798 | ||
799 | static int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg) | 799 | int agpioc_setup_wrap(struct agp_file_private *priv, void __user *arg) |
800 | { | 800 | { |
801 | struct agp_setup mode; | 801 | struct agp_setup mode; |
802 | 802 | ||
@@ -876,7 +876,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg) | |||
876 | return -EINVAL; | 876 | return -EINVAL; |
877 | } | 877 | } |
878 | 878 | ||
879 | static int agpioc_protect_wrap(struct agp_file_private *priv) | 879 | int agpioc_protect_wrap(struct agp_file_private *priv) |
880 | { | 880 | { |
881 | DBG(""); | 881 | DBG(""); |
882 | /* This function is not currently implemented */ | 882 | /* This function is not currently implemented */ |
@@ -892,6 +892,9 @@ static int agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg) | |||
892 | if (copy_from_user(&alloc, arg, sizeof(struct agp_allocate))) | 892 | if (copy_from_user(&alloc, arg, sizeof(struct agp_allocate))) |
893 | return -EFAULT; | 893 | return -EFAULT; |
894 | 894 | ||
895 | if (alloc.type >= AGP_USER_TYPES) | ||
896 | return -EINVAL; | ||
897 | |||
895 | memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type); | 898 | memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type); |
896 | 899 | ||
897 | if (memory == NULL) | 900 | if (memory == NULL) |
@@ -907,7 +910,7 @@ static int agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg) | |||
907 | return 0; | 910 | return 0; |
908 | } | 911 | } |
909 | 912 | ||
910 | static int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg) | 913 | int agpioc_deallocate_wrap(struct agp_file_private *priv, int arg) |
911 | { | 914 | { |
912 | struct agp_memory *memory; | 915 | struct agp_memory *memory; |
913 | 916 | ||
@@ -1043,6 +1046,9 @@ static const struct file_operations agp_fops = | |||
1043 | .read = agp_read, | 1046 | .read = agp_read, |
1044 | .write = agp_write, | 1047 | .write = agp_write, |
1045 | .ioctl = agp_ioctl, | 1048 | .ioctl = agp_ioctl, |
1049 | #ifdef CONFIG_COMPAT | ||
1050 | .compat_ioctl = compat_agp_ioctl, | ||
1051 | #endif | ||
1046 | .mmap = agp_mmap, | 1052 | .mmap = agp_mmap, |
1047 | .open = agp_open, | 1053 | .open = agp_open, |
1048 | .release = agp_release, | 1054 | .release = agp_release, |
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c index 3491d6f84bc6..7923337c3d26 100644 --- a/drivers/char/agp/generic.c +++ b/drivers/char/agp/generic.c | |||
@@ -101,6 +101,63 @@ static int agp_get_key(void) | |||
101 | return -1; | 101 | return -1; |
102 | } | 102 | } |
103 | 103 | ||
104 | /* | ||
105 | * Use kmalloc if possible for the page list. Otherwise fall back to | ||
106 | * vmalloc. This speeds things up and also saves memory for small AGP | ||
107 | * regions. | ||
108 | */ | ||
109 | |||
110 | void agp_alloc_page_array(size_t size, struct agp_memory *mem) | ||
111 | { | ||
112 | mem->memory = NULL; | ||
113 | mem->vmalloc_flag = 0; | ||
114 | |||
115 | if (size <= 2*PAGE_SIZE) | ||
116 | mem->memory = kmalloc(size, GFP_KERNEL | __GFP_NORETRY); | ||
117 | if (mem->memory == NULL) { | ||
118 | mem->memory = vmalloc(size); | ||
119 | mem->vmalloc_flag = 1; | ||
120 | } | ||
121 | } | ||
122 | EXPORT_SYMBOL(agp_alloc_page_array); | ||
123 | |||
124 | void agp_free_page_array(struct agp_memory *mem) | ||
125 | { | ||
126 | if (mem->vmalloc_flag) { | ||
127 | vfree(mem->memory); | ||
128 | } else { | ||
129 | kfree(mem->memory); | ||
130 | } | ||
131 | } | ||
132 | EXPORT_SYMBOL(agp_free_page_array); | ||
133 | |||
134 | |||
135 | static struct agp_memory *agp_create_user_memory(unsigned long num_agp_pages) | ||
136 | { | ||
137 | struct agp_memory *new; | ||
138 | unsigned long alloc_size = num_agp_pages*sizeof(struct page *); | ||
139 | |||
140 | new = kzalloc(sizeof(struct agp_memory), GFP_KERNEL); | ||
141 | if (new == NULL) | ||
142 | return NULL; | ||
143 | |||
144 | new->key = agp_get_key(); | ||
145 | |||
146 | if (new->key < 0) { | ||
147 | kfree(new); | ||
148 | return NULL; | ||
149 | } | ||
150 | |||
151 | agp_alloc_page_array(alloc_size, new); | ||
152 | |||
153 | if (new->memory == NULL) { | ||
154 | agp_free_key(new->key); | ||
155 | kfree(new); | ||
156 | return NULL; | ||
157 | } | ||
158 | new->num_scratch_pages = 0; | ||
159 | return new; | ||
160 | } | ||
104 | 161 | ||
105 | struct agp_memory *agp_create_memory(int scratch_pages) | 162 | struct agp_memory *agp_create_memory(int scratch_pages) |
106 | { | 163 | { |
@@ -116,7 +173,8 @@ struct agp_memory *agp_create_memory(int scratch_pages) | |||
116 | kfree(new); | 173 | kfree(new); |
117 | return NULL; | 174 | return NULL; |
118 | } | 175 | } |
119 | new->memory = vmalloc(PAGE_SIZE * scratch_pages); | 176 | |
177 | agp_alloc_page_array(PAGE_SIZE * scratch_pages, new); | ||
120 | 178 | ||
121 | if (new->memory == NULL) { | 179 | if (new->memory == NULL) { |
122 | agp_free_key(new->key); | 180 | agp_free_key(new->key); |
@@ -124,6 +182,7 @@ struct agp_memory *agp_create_memory(int scratch_pages) | |||
124 | return NULL; | 182 | return NULL; |
125 | } | 183 | } |
126 | new->num_scratch_pages = scratch_pages; | 184 | new->num_scratch_pages = scratch_pages; |
185 | new->type = AGP_NORMAL_MEMORY; | ||
127 | return new; | 186 | return new; |
128 | } | 187 | } |
129 | EXPORT_SYMBOL(agp_create_memory); | 188 | EXPORT_SYMBOL(agp_create_memory); |
@@ -146,6 +205,11 @@ void agp_free_memory(struct agp_memory *curr) | |||
146 | if (curr->is_bound == TRUE) | 205 | if (curr->is_bound == TRUE) |
147 | agp_unbind_memory(curr); | 206 | agp_unbind_memory(curr); |
148 | 207 | ||
208 | if (curr->type >= AGP_USER_TYPES) { | ||
209 | agp_generic_free_by_type(curr); | ||
210 | return; | ||
211 | } | ||
212 | |||
149 | if (curr->type != 0) { | 213 | if (curr->type != 0) { |
150 | curr->bridge->driver->free_by_type(curr); | 214 | curr->bridge->driver->free_by_type(curr); |
151 | return; | 215 | return; |
@@ -157,7 +221,7 @@ void agp_free_memory(struct agp_memory *curr) | |||
157 | flush_agp_mappings(); | 221 | flush_agp_mappings(); |
158 | } | 222 | } |
159 | agp_free_key(curr->key); | 223 | agp_free_key(curr->key); |
160 | vfree(curr->memory); | 224 | agp_free_page_array(curr); |
161 | kfree(curr); | 225 | kfree(curr); |
162 | } | 226 | } |
163 | EXPORT_SYMBOL(agp_free_memory); | 227 | EXPORT_SYMBOL(agp_free_memory); |
@@ -188,6 +252,13 @@ struct agp_memory *agp_allocate_memory(struct agp_bridge_data *bridge, | |||
188 | if ((atomic_read(&bridge->current_memory_agp) + page_count) > bridge->max_memory_agp) | 252 | if ((atomic_read(&bridge->current_memory_agp) + page_count) > bridge->max_memory_agp) |
189 | return NULL; | 253 | return NULL; |
190 | 254 | ||
255 | if (type >= AGP_USER_TYPES) { | ||
256 | new = agp_generic_alloc_user(page_count, type); | ||
257 | if (new) | ||
258 | new->bridge = bridge; | ||
259 | return new; | ||
260 | } | ||
261 | |||
191 | if (type != 0) { | 262 | if (type != 0) { |
192 | new = bridge->driver->alloc_by_type(page_count, type); | 263 | new = bridge->driver->alloc_by_type(page_count, type); |
193 | if (new) | 264 | if (new) |
@@ -960,6 +1031,7 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type) | |||
960 | off_t j; | 1031 | off_t j; |
961 | void *temp; | 1032 | void *temp; |
962 | struct agp_bridge_data *bridge; | 1033 | struct agp_bridge_data *bridge; |
1034 | int mask_type; | ||
963 | 1035 | ||
964 | bridge = mem->bridge; | 1036 | bridge = mem->bridge; |
965 | if (!bridge) | 1037 | if (!bridge) |
@@ -995,7 +1067,11 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type) | |||
995 | num_entries -= agp_memory_reserved/PAGE_SIZE; | 1067 | num_entries -= agp_memory_reserved/PAGE_SIZE; |
996 | if (num_entries < 0) num_entries = 0; | 1068 | if (num_entries < 0) num_entries = 0; |
997 | 1069 | ||
998 | if (type != 0 || mem->type != 0) { | 1070 | if (type != mem->type) |
1071 | return -EINVAL; | ||
1072 | |||
1073 | mask_type = bridge->driver->agp_type_to_mask_type(bridge, type); | ||
1074 | if (mask_type != 0) { | ||
999 | /* The generic routines know nothing of memory types */ | 1075 | /* The generic routines know nothing of memory types */ |
1000 | return -EINVAL; | 1076 | return -EINVAL; |
1001 | } | 1077 | } |
@@ -1018,7 +1094,8 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type) | |||
1018 | } | 1094 | } |
1019 | 1095 | ||
1020 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 1096 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
1021 | writel(bridge->driver->mask_memory(bridge, mem->memory[i], mem->type), bridge->gatt_table+j); | 1097 | writel(bridge->driver->mask_memory(bridge, mem->memory[i], mask_type), |
1098 | bridge->gatt_table+j); | ||
1022 | } | 1099 | } |
1023 | readl(bridge->gatt_table+j-1); /* PCI Posting. */ | 1100 | readl(bridge->gatt_table+j-1); /* PCI Posting. */ |
1024 | 1101 | ||
@@ -1032,6 +1109,7 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
1032 | { | 1109 | { |
1033 | size_t i; | 1110 | size_t i; |
1034 | struct agp_bridge_data *bridge; | 1111 | struct agp_bridge_data *bridge; |
1112 | int mask_type; | ||
1035 | 1113 | ||
1036 | bridge = mem->bridge; | 1114 | bridge = mem->bridge; |
1037 | if (!bridge) | 1115 | if (!bridge) |
@@ -1040,7 +1118,11 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
1040 | if (mem->page_count == 0) | 1118 | if (mem->page_count == 0) |
1041 | return 0; | 1119 | return 0; |
1042 | 1120 | ||
1043 | if (type != 0 || mem->type != 0) { | 1121 | if (type != mem->type) |
1122 | return -EINVAL; | ||
1123 | |||
1124 | mask_type = bridge->driver->agp_type_to_mask_type(bridge, type); | ||
1125 | if (mask_type != 0) { | ||
1044 | /* The generic routines know nothing of memory types */ | 1126 | /* The generic routines know nothing of memory types */ |
1045 | return -EINVAL; | 1127 | return -EINVAL; |
1046 | } | 1128 | } |
@@ -1056,22 +1138,40 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
1056 | } | 1138 | } |
1057 | EXPORT_SYMBOL(agp_generic_remove_memory); | 1139 | EXPORT_SYMBOL(agp_generic_remove_memory); |
1058 | 1140 | ||
1059 | |||
1060 | struct agp_memory *agp_generic_alloc_by_type(size_t page_count, int type) | 1141 | struct agp_memory *agp_generic_alloc_by_type(size_t page_count, int type) |
1061 | { | 1142 | { |
1062 | return NULL; | 1143 | return NULL; |
1063 | } | 1144 | } |
1064 | EXPORT_SYMBOL(agp_generic_alloc_by_type); | 1145 | EXPORT_SYMBOL(agp_generic_alloc_by_type); |
1065 | 1146 | ||
1066 | |||
1067 | void agp_generic_free_by_type(struct agp_memory *curr) | 1147 | void agp_generic_free_by_type(struct agp_memory *curr) |
1068 | { | 1148 | { |
1069 | vfree(curr->memory); | 1149 | agp_free_page_array(curr); |
1070 | agp_free_key(curr->key); | 1150 | agp_free_key(curr->key); |
1071 | kfree(curr); | 1151 | kfree(curr); |
1072 | } | 1152 | } |
1073 | EXPORT_SYMBOL(agp_generic_free_by_type); | 1153 | EXPORT_SYMBOL(agp_generic_free_by_type); |
1074 | 1154 | ||
1155 | struct agp_memory *agp_generic_alloc_user(size_t page_count, int type) | ||
1156 | { | ||
1157 | struct agp_memory *new; | ||
1158 | int i; | ||
1159 | int pages; | ||
1160 | |||
1161 | pages = (page_count + ENTRIES_PER_PAGE - 1) / ENTRIES_PER_PAGE; | ||
1162 | new = agp_create_user_memory(page_count); | ||
1163 | if (new == NULL) | ||
1164 | return NULL; | ||
1165 | |||
1166 | for (i = 0; i < page_count; i++) | ||
1167 | new->memory[i] = 0; | ||
1168 | new->page_count = 0; | ||
1169 | new->type = type; | ||
1170 | new->num_scratch_pages = pages; | ||
1171 | |||
1172 | return new; | ||
1173 | } | ||
1174 | EXPORT_SYMBOL(agp_generic_alloc_user); | ||
1075 | 1175 | ||
1076 | /* | 1176 | /* |
1077 | * Basic Page Allocation Routines - | 1177 | * Basic Page Allocation Routines - |
@@ -1165,6 +1265,15 @@ unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge, | |||
1165 | } | 1265 | } |
1166 | EXPORT_SYMBOL(agp_generic_mask_memory); | 1266 | EXPORT_SYMBOL(agp_generic_mask_memory); |
1167 | 1267 | ||
1268 | int agp_generic_type_to_mask_type(struct agp_bridge_data *bridge, | ||
1269 | int type) | ||
1270 | { | ||
1271 | if (type >= AGP_USER_TYPES) | ||
1272 | return 0; | ||
1273 | return type; | ||
1274 | } | ||
1275 | EXPORT_SYMBOL(agp_generic_type_to_mask_type); | ||
1276 | |||
1168 | /* | 1277 | /* |
1169 | * These functions are implemented according to the AGPv3 spec, | 1278 | * These functions are implemented according to the AGPv3 spec, |
1170 | * which covers implementation details that had previously been | 1279 | * which covers implementation details that had previously been |
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c index 907fb66ec4a9..847deabf7f9b 100644 --- a/drivers/char/agp/hp-agp.c +++ b/drivers/char/agp/hp-agp.c | |||
@@ -438,6 +438,7 @@ struct agp_bridge_driver hp_zx1_driver = { | |||
438 | .free_by_type = agp_generic_free_by_type, | 438 | .free_by_type = agp_generic_free_by_type, |
439 | .agp_alloc_page = agp_generic_alloc_page, | 439 | .agp_alloc_page = agp_generic_alloc_page, |
440 | .agp_destroy_page = agp_generic_destroy_page, | 440 | .agp_destroy_page = agp_generic_destroy_page, |
441 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
441 | .cant_use_aperture = 1, | 442 | .cant_use_aperture = 1, |
442 | }; | 443 | }; |
443 | 444 | ||
diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c index 91769443d8fe..3e7618653abd 100644 --- a/drivers/char/agp/i460-agp.c +++ b/drivers/char/agp/i460-agp.c | |||
@@ -293,6 +293,9 @@ static int i460_insert_memory_small_io_page (struct agp_memory *mem, | |||
293 | pr_debug("i460_insert_memory_small_io_page(mem=%p, pg_start=%ld, type=%d, paddr0=0x%lx)\n", | 293 | pr_debug("i460_insert_memory_small_io_page(mem=%p, pg_start=%ld, type=%d, paddr0=0x%lx)\n", |
294 | mem, pg_start, type, mem->memory[0]); | 294 | mem, pg_start, type, mem->memory[0]); |
295 | 295 | ||
296 | if (type >= AGP_USER_TYPES || mem->type >= AGP_USER_TYPES) | ||
297 | return -EINVAL; | ||
298 | |||
296 | io_pg_start = I460_IOPAGES_PER_KPAGE * pg_start; | 299 | io_pg_start = I460_IOPAGES_PER_KPAGE * pg_start; |
297 | 300 | ||
298 | temp = agp_bridge->current_size; | 301 | temp = agp_bridge->current_size; |
@@ -396,6 +399,9 @@ static int i460_insert_memory_large_io_page (struct agp_memory *mem, | |||
396 | struct lp_desc *start, *end, *lp; | 399 | struct lp_desc *start, *end, *lp; |
397 | void *temp; | 400 | void *temp; |
398 | 401 | ||
402 | if (type >= AGP_USER_TYPES || mem->type >= AGP_USER_TYPES) | ||
403 | return -EINVAL; | ||
404 | |||
399 | temp = agp_bridge->current_size; | 405 | temp = agp_bridge->current_size; |
400 | num_entries = A_SIZE_8(temp)->num_entries; | 406 | num_entries = A_SIZE_8(temp)->num_entries; |
401 | 407 | ||
@@ -572,6 +578,7 @@ struct agp_bridge_driver intel_i460_driver = { | |||
572 | #endif | 578 | #endif |
573 | .alloc_by_type = agp_generic_alloc_by_type, | 579 | .alloc_by_type = agp_generic_alloc_by_type, |
574 | .free_by_type = agp_generic_free_by_type, | 580 | .free_by_type = agp_generic_free_by_type, |
581 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
575 | .cant_use_aperture = 1, | 582 | .cant_use_aperture = 1, |
576 | }; | 583 | }; |
577 | 584 | ||
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index a3011de51f7c..06b0bb6d982f 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/module.h> | 5 | #include <linux/module.h> |
6 | #include <linux/pci.h> | 6 | #include <linux/pci.h> |
7 | #include <linux/init.h> | 7 | #include <linux/init.h> |
8 | #include <linux/kernel.h> | ||
8 | #include <linux/pagemap.h> | 9 | #include <linux/pagemap.h> |
9 | #include <linux/agp_backend.h> | 10 | #include <linux/agp_backend.h> |
10 | #include "agp.h" | 11 | #include "agp.h" |
@@ -24,6 +25,9 @@ | |||
24 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB) | 25 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB) |
25 | 26 | ||
26 | 27 | ||
28 | extern int agp_memory_reserved; | ||
29 | |||
30 | |||
27 | /* Intel 815 register */ | 31 | /* Intel 815 register */ |
28 | #define INTEL_815_APCONT 0x51 | 32 | #define INTEL_815_APCONT 0x51 |
29 | #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF | 33 | #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF |
@@ -68,12 +72,15 @@ static struct aper_size_info_fixed intel_i810_sizes[] = | |||
68 | 72 | ||
69 | #define AGP_DCACHE_MEMORY 1 | 73 | #define AGP_DCACHE_MEMORY 1 |
70 | #define AGP_PHYS_MEMORY 2 | 74 | #define AGP_PHYS_MEMORY 2 |
75 | #define INTEL_AGP_CACHED_MEMORY 3 | ||
71 | 76 | ||
72 | static struct gatt_mask intel_i810_masks[] = | 77 | static struct gatt_mask intel_i810_masks[] = |
73 | { | 78 | { |
74 | {.mask = I810_PTE_VALID, .type = 0}, | 79 | {.mask = I810_PTE_VALID, .type = 0}, |
75 | {.mask = (I810_PTE_VALID | I810_PTE_LOCAL), .type = AGP_DCACHE_MEMORY}, | 80 | {.mask = (I810_PTE_VALID | I810_PTE_LOCAL), .type = AGP_DCACHE_MEMORY}, |
76 | {.mask = I810_PTE_VALID, .type = 0} | 81 | {.mask = I810_PTE_VALID, .type = 0}, |
82 | {.mask = I810_PTE_VALID | I830_PTE_SYSTEM_CACHED, | ||
83 | .type = INTEL_AGP_CACHED_MEMORY} | ||
77 | }; | 84 | }; |
78 | 85 | ||
79 | static struct _intel_i810_private { | 86 | static struct _intel_i810_private { |
@@ -117,13 +124,15 @@ static int intel_i810_configure(void) | |||
117 | 124 | ||
118 | current_size = A_SIZE_FIX(agp_bridge->current_size); | 125 | current_size = A_SIZE_FIX(agp_bridge->current_size); |
119 | 126 | ||
120 | pci_read_config_dword(intel_i810_private.i810_dev, I810_MMADDR, &temp); | ||
121 | temp &= 0xfff80000; | ||
122 | |||
123 | intel_i810_private.registers = ioremap(temp, 128 * 4096); | ||
124 | if (!intel_i810_private.registers) { | 127 | if (!intel_i810_private.registers) { |
125 | printk(KERN_ERR PFX "Unable to remap memory.\n"); | 128 | pci_read_config_dword(intel_i810_private.i810_dev, I810_MMADDR, &temp); |
126 | return -ENOMEM; | 129 | temp &= 0xfff80000; |
130 | |||
131 | intel_i810_private.registers = ioremap(temp, 128 * 4096); | ||
132 | if (!intel_i810_private.registers) { | ||
133 | printk(KERN_ERR PFX "Unable to remap memory.\n"); | ||
134 | return -ENOMEM; | ||
135 | } | ||
127 | } | 136 | } |
128 | 137 | ||
129 | if ((readl(intel_i810_private.registers+I810_DRAM_CTL) | 138 | if ((readl(intel_i810_private.registers+I810_DRAM_CTL) |
@@ -201,62 +210,79 @@ static void i8xx_destroy_pages(void *addr) | |||
201 | atomic_dec(&agp_bridge->current_memory_agp); | 210 | atomic_dec(&agp_bridge->current_memory_agp); |
202 | } | 211 | } |
203 | 212 | ||
213 | static int intel_i830_type_to_mask_type(struct agp_bridge_data *bridge, | ||
214 | int type) | ||
215 | { | ||
216 | if (type < AGP_USER_TYPES) | ||
217 | return type; | ||
218 | else if (type == AGP_USER_CACHED_MEMORY) | ||
219 | return INTEL_AGP_CACHED_MEMORY; | ||
220 | else | ||
221 | return 0; | ||
222 | } | ||
223 | |||
204 | static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start, | 224 | static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start, |
205 | int type) | 225 | int type) |
206 | { | 226 | { |
207 | int i, j, num_entries; | 227 | int i, j, num_entries; |
208 | void *temp; | 228 | void *temp; |
229 | int ret = -EINVAL; | ||
230 | int mask_type; | ||
209 | 231 | ||
210 | if (mem->page_count == 0) | 232 | if (mem->page_count == 0) |
211 | return 0; | 233 | goto out; |
212 | 234 | ||
213 | temp = agp_bridge->current_size; | 235 | temp = agp_bridge->current_size; |
214 | num_entries = A_SIZE_FIX(temp)->num_entries; | 236 | num_entries = A_SIZE_FIX(temp)->num_entries; |
215 | 237 | ||
216 | if ((pg_start + mem->page_count) > num_entries) | 238 | if ((pg_start + mem->page_count) > num_entries) |
217 | return -EINVAL; | 239 | goto out_err; |
218 | 240 | ||
219 | for (j = pg_start; j < (pg_start + mem->page_count); j++) { | ||
220 | if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) | ||
221 | return -EBUSY; | ||
222 | } | ||
223 | 241 | ||
224 | if (type != 0 || mem->type != 0) { | 242 | for (j = pg_start; j < (pg_start + mem->page_count); j++) { |
225 | if ((type == AGP_DCACHE_MEMORY) && (mem->type == AGP_DCACHE_MEMORY)) { | 243 | if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) { |
226 | /* special insert */ | 244 | ret = -EBUSY; |
227 | if (!mem->is_flushed) { | 245 | goto out_err; |
228 | global_cache_flush(); | ||
229 | mem->is_flushed = TRUE; | ||
230 | } | ||
231 | |||
232 | for (i = pg_start; i < (pg_start + mem->page_count); i++) { | ||
233 | writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID, intel_i810_private.registers+I810_PTE_BASE+(i*4)); | ||
234 | } | ||
235 | readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4)); /* PCI Posting. */ | ||
236 | |||
237 | agp_bridge->driver->tlb_flush(mem); | ||
238 | return 0; | ||
239 | } | 246 | } |
240 | if ((type == AGP_PHYS_MEMORY) && (mem->type == AGP_PHYS_MEMORY)) | ||
241 | goto insert; | ||
242 | return -EINVAL; | ||
243 | } | 247 | } |
244 | 248 | ||
245 | insert: | 249 | if (type != mem->type) |
246 | if (!mem->is_flushed) { | 250 | goto out_err; |
247 | global_cache_flush(); | ||
248 | mem->is_flushed = TRUE; | ||
249 | } | ||
250 | 251 | ||
251 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 252 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); |
252 | writel(agp_bridge->driver->mask_memory(agp_bridge, | 253 | |
253 | mem->memory[i], mem->type), | 254 | switch (mask_type) { |
254 | intel_i810_private.registers+I810_PTE_BASE+(j*4)); | 255 | case AGP_DCACHE_MEMORY: |
256 | if (!mem->is_flushed) | ||
257 | global_cache_flush(); | ||
258 | for (i = pg_start; i < (pg_start + mem->page_count); i++) { | ||
259 | writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID, | ||
260 | intel_i810_private.registers+I810_PTE_BASE+(i*4)); | ||
261 | } | ||
262 | readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4)); | ||
263 | break; | ||
264 | case AGP_PHYS_MEMORY: | ||
265 | case AGP_NORMAL_MEMORY: | ||
266 | if (!mem->is_flushed) | ||
267 | global_cache_flush(); | ||
268 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | ||
269 | writel(agp_bridge->driver->mask_memory(agp_bridge, | ||
270 | mem->memory[i], | ||
271 | mask_type), | ||
272 | intel_i810_private.registers+I810_PTE_BASE+(j*4)); | ||
273 | } | ||
274 | readl(intel_i810_private.registers+I810_PTE_BASE+((j-1)*4)); | ||
275 | break; | ||
276 | default: | ||
277 | goto out_err; | ||
255 | } | 278 | } |
256 | readl(intel_i810_private.registers+I810_PTE_BASE+((j-1)*4)); /* PCI Posting. */ | ||
257 | 279 | ||
258 | agp_bridge->driver->tlb_flush(mem); | 280 | agp_bridge->driver->tlb_flush(mem); |
259 | return 0; | 281 | out: |
282 | ret = 0; | ||
283 | out_err: | ||
284 | mem->is_flushed = 1; | ||
285 | return ret; | ||
260 | } | 286 | } |
261 | 287 | ||
262 | static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start, | 288 | static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start, |
@@ -337,12 +363,11 @@ static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type) | |||
337 | new->type = AGP_DCACHE_MEMORY; | 363 | new->type = AGP_DCACHE_MEMORY; |
338 | new->page_count = pg_count; | 364 | new->page_count = pg_count; |
339 | new->num_scratch_pages = 0; | 365 | new->num_scratch_pages = 0; |
340 | vfree(new->memory); | 366 | agp_free_page_array(new); |
341 | return new; | 367 | return new; |
342 | } | 368 | } |
343 | if (type == AGP_PHYS_MEMORY) | 369 | if (type == AGP_PHYS_MEMORY) |
344 | return alloc_agpphysmem_i8xx(pg_count, type); | 370 | return alloc_agpphysmem_i8xx(pg_count, type); |
345 | |||
346 | return NULL; | 371 | return NULL; |
347 | } | 372 | } |
348 | 373 | ||
@@ -357,7 +382,7 @@ static void intel_i810_free_by_type(struct agp_memory *curr) | |||
357 | gart_to_virt(curr->memory[0])); | 382 | gart_to_virt(curr->memory[0])); |
358 | global_flush_tlb(); | 383 | global_flush_tlb(); |
359 | } | 384 | } |
360 | vfree(curr->memory); | 385 | agp_free_page_array(curr); |
361 | } | 386 | } |
362 | kfree(curr); | 387 | kfree(curr); |
363 | } | 388 | } |
@@ -619,9 +644,11 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int | |||
619 | { | 644 | { |
620 | int i,j,num_entries; | 645 | int i,j,num_entries; |
621 | void *temp; | 646 | void *temp; |
647 | int ret = -EINVAL; | ||
648 | int mask_type; | ||
622 | 649 | ||
623 | if (mem->page_count == 0) | 650 | if (mem->page_count == 0) |
624 | return 0; | 651 | goto out; |
625 | 652 | ||
626 | temp = agp_bridge->current_size; | 653 | temp = agp_bridge->current_size; |
627 | num_entries = A_SIZE_FIX(temp)->num_entries; | 654 | num_entries = A_SIZE_FIX(temp)->num_entries; |
@@ -631,34 +658,41 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int | |||
631 | pg_start,intel_i830_private.gtt_entries); | 658 | pg_start,intel_i830_private.gtt_entries); |
632 | 659 | ||
633 | printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); | 660 | printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); |
634 | return -EINVAL; | 661 | goto out_err; |
635 | } | 662 | } |
636 | 663 | ||
637 | if ((pg_start + mem->page_count) > num_entries) | 664 | if ((pg_start + mem->page_count) > num_entries) |
638 | return -EINVAL; | 665 | goto out_err; |
639 | 666 | ||
640 | /* The i830 can't check the GTT for entries since its read only, | 667 | /* The i830 can't check the GTT for entries since its read only, |
641 | * depend on the caller to make the correct offset decisions. | 668 | * depend on the caller to make the correct offset decisions. |
642 | */ | 669 | */ |
643 | 670 | ||
644 | if ((type != 0 && type != AGP_PHYS_MEMORY) || | 671 | if (type != mem->type) |
645 | (mem->type != 0 && mem->type != AGP_PHYS_MEMORY)) | 672 | goto out_err; |
646 | return -EINVAL; | 673 | |
674 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); | ||
647 | 675 | ||
648 | if (!mem->is_flushed) { | 676 | if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY && |
677 | mask_type != INTEL_AGP_CACHED_MEMORY) | ||
678 | goto out_err; | ||
679 | |||
680 | if (!mem->is_flushed) | ||
649 | global_cache_flush(); | 681 | global_cache_flush(); |
650 | mem->is_flushed = TRUE; | ||
651 | } | ||
652 | 682 | ||
653 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 683 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
654 | writel(agp_bridge->driver->mask_memory(agp_bridge, | 684 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
655 | mem->memory[i], mem->type), | 685 | mem->memory[i], mask_type), |
656 | intel_i830_private.registers+I810_PTE_BASE+(j*4)); | 686 | intel_i830_private.registers+I810_PTE_BASE+(j*4)); |
657 | } | 687 | } |
658 | readl(intel_i830_private.registers+I810_PTE_BASE+((j-1)*4)); | 688 | readl(intel_i830_private.registers+I810_PTE_BASE+((j-1)*4)); |
659 | |||
660 | agp_bridge->driver->tlb_flush(mem); | 689 | agp_bridge->driver->tlb_flush(mem); |
661 | return 0; | 690 | |
691 | out: | ||
692 | ret = 0; | ||
693 | out_err: | ||
694 | mem->is_flushed = 1; | ||
695 | return ret; | ||
662 | } | 696 | } |
663 | 697 | ||
664 | static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start, | 698 | static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start, |
@@ -687,7 +721,6 @@ static struct agp_memory *intel_i830_alloc_by_type(size_t pg_count,int type) | |||
687 | { | 721 | { |
688 | if (type == AGP_PHYS_MEMORY) | 722 | if (type == AGP_PHYS_MEMORY) |
689 | return alloc_agpphysmem_i8xx(pg_count, type); | 723 | return alloc_agpphysmem_i8xx(pg_count, type); |
690 | |||
691 | /* always return NULL for other allocation types for now */ | 724 | /* always return NULL for other allocation types for now */ |
692 | return NULL; | 725 | return NULL; |
693 | } | 726 | } |
@@ -734,9 +767,11 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start, | |||
734 | { | 767 | { |
735 | int i,j,num_entries; | 768 | int i,j,num_entries; |
736 | void *temp; | 769 | void *temp; |
770 | int ret = -EINVAL; | ||
771 | int mask_type; | ||
737 | 772 | ||
738 | if (mem->page_count == 0) | 773 | if (mem->page_count == 0) |
739 | return 0; | 774 | goto out; |
740 | 775 | ||
741 | temp = agp_bridge->current_size; | 776 | temp = agp_bridge->current_size; |
742 | num_entries = A_SIZE_FIX(temp)->num_entries; | 777 | num_entries = A_SIZE_FIX(temp)->num_entries; |
@@ -746,33 +781,41 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start, | |||
746 | pg_start,intel_i830_private.gtt_entries); | 781 | pg_start,intel_i830_private.gtt_entries); |
747 | 782 | ||
748 | printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); | 783 | printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); |
749 | return -EINVAL; | 784 | goto out_err; |
750 | } | 785 | } |
751 | 786 | ||
752 | if ((pg_start + mem->page_count) > num_entries) | 787 | if ((pg_start + mem->page_count) > num_entries) |
753 | return -EINVAL; | 788 | goto out_err; |
754 | 789 | ||
755 | /* The i830 can't check the GTT for entries since its read only, | 790 | /* The i915 can't check the GTT for entries since its read only, |
756 | * depend on the caller to make the correct offset decisions. | 791 | * depend on the caller to make the correct offset decisions. |
757 | */ | 792 | */ |
758 | 793 | ||
759 | if ((type != 0 && type != AGP_PHYS_MEMORY) || | 794 | if (type != mem->type) |
760 | (mem->type != 0 && mem->type != AGP_PHYS_MEMORY)) | 795 | goto out_err; |
761 | return -EINVAL; | 796 | |
797 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); | ||
762 | 798 | ||
763 | if (!mem->is_flushed) { | 799 | if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY && |
800 | mask_type != INTEL_AGP_CACHED_MEMORY) | ||
801 | goto out_err; | ||
802 | |||
803 | if (!mem->is_flushed) | ||
764 | global_cache_flush(); | 804 | global_cache_flush(); |
765 | mem->is_flushed = TRUE; | ||
766 | } | ||
767 | 805 | ||
768 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | 806 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
769 | writel(agp_bridge->driver->mask_memory(agp_bridge, | 807 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
770 | mem->memory[i], mem->type), intel_i830_private.gtt+j); | 808 | mem->memory[i], mask_type), intel_i830_private.gtt+j); |
771 | } | 809 | } |
772 | readl(intel_i830_private.gtt+j-1); | ||
773 | 810 | ||
811 | readl(intel_i830_private.gtt+j-1); | ||
774 | agp_bridge->driver->tlb_flush(mem); | 812 | agp_bridge->driver->tlb_flush(mem); |
775 | return 0; | 813 | |
814 | out: | ||
815 | ret = 0; | ||
816 | out_err: | ||
817 | mem->is_flushed = 1; | ||
818 | return ret; | ||
776 | } | 819 | } |
777 | 820 | ||
778 | static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start, | 821 | static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start, |
@@ -803,7 +846,7 @@ static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start, | |||
803 | */ | 846 | */ |
804 | static int intel_i9xx_fetch_size(void) | 847 | static int intel_i9xx_fetch_size(void) |
805 | { | 848 | { |
806 | int num_sizes = sizeof(intel_i830_sizes) / sizeof(*intel_i830_sizes); | 849 | int num_sizes = ARRAY_SIZE(intel_i830_sizes); |
807 | int aper_size; /* size in megabytes */ | 850 | int aper_size; /* size in megabytes */ |
808 | int i; | 851 | int i; |
809 | 852 | ||
@@ -1384,6 +1427,7 @@ static struct agp_bridge_driver intel_generic_driver = { | |||
1384 | .free_by_type = agp_generic_free_by_type, | 1427 | .free_by_type = agp_generic_free_by_type, |
1385 | .agp_alloc_page = agp_generic_alloc_page, | 1428 | .agp_alloc_page = agp_generic_alloc_page, |
1386 | .agp_destroy_page = agp_generic_destroy_page, | 1429 | .agp_destroy_page = agp_generic_destroy_page, |
1430 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1387 | }; | 1431 | }; |
1388 | 1432 | ||
1389 | static struct agp_bridge_driver intel_810_driver = { | 1433 | static struct agp_bridge_driver intel_810_driver = { |
@@ -1408,6 +1452,7 @@ static struct agp_bridge_driver intel_810_driver = { | |||
1408 | .free_by_type = intel_i810_free_by_type, | 1452 | .free_by_type = intel_i810_free_by_type, |
1409 | .agp_alloc_page = agp_generic_alloc_page, | 1453 | .agp_alloc_page = agp_generic_alloc_page, |
1410 | .agp_destroy_page = agp_generic_destroy_page, | 1454 | .agp_destroy_page = agp_generic_destroy_page, |
1455 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1411 | }; | 1456 | }; |
1412 | 1457 | ||
1413 | static struct agp_bridge_driver intel_815_driver = { | 1458 | static struct agp_bridge_driver intel_815_driver = { |
@@ -1431,6 +1476,7 @@ static struct agp_bridge_driver intel_815_driver = { | |||
1431 | .free_by_type = agp_generic_free_by_type, | 1476 | .free_by_type = agp_generic_free_by_type, |
1432 | .agp_alloc_page = agp_generic_alloc_page, | 1477 | .agp_alloc_page = agp_generic_alloc_page, |
1433 | .agp_destroy_page = agp_generic_destroy_page, | 1478 | .agp_destroy_page = agp_generic_destroy_page, |
1479 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1434 | }; | 1480 | }; |
1435 | 1481 | ||
1436 | static struct agp_bridge_driver intel_830_driver = { | 1482 | static struct agp_bridge_driver intel_830_driver = { |
@@ -1455,6 +1501,7 @@ static struct agp_bridge_driver intel_830_driver = { | |||
1455 | .free_by_type = intel_i810_free_by_type, | 1501 | .free_by_type = intel_i810_free_by_type, |
1456 | .agp_alloc_page = agp_generic_alloc_page, | 1502 | .agp_alloc_page = agp_generic_alloc_page, |
1457 | .agp_destroy_page = agp_generic_destroy_page, | 1503 | .agp_destroy_page = agp_generic_destroy_page, |
1504 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | ||
1458 | }; | 1505 | }; |
1459 | 1506 | ||
1460 | static struct agp_bridge_driver intel_820_driver = { | 1507 | static struct agp_bridge_driver intel_820_driver = { |
@@ -1478,6 +1525,7 @@ static struct agp_bridge_driver intel_820_driver = { | |||
1478 | .free_by_type = agp_generic_free_by_type, | 1525 | .free_by_type = agp_generic_free_by_type, |
1479 | .agp_alloc_page = agp_generic_alloc_page, | 1526 | .agp_alloc_page = agp_generic_alloc_page, |
1480 | .agp_destroy_page = agp_generic_destroy_page, | 1527 | .agp_destroy_page = agp_generic_destroy_page, |
1528 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1481 | }; | 1529 | }; |
1482 | 1530 | ||
1483 | static struct agp_bridge_driver intel_830mp_driver = { | 1531 | static struct agp_bridge_driver intel_830mp_driver = { |
@@ -1501,6 +1549,7 @@ static struct agp_bridge_driver intel_830mp_driver = { | |||
1501 | .free_by_type = agp_generic_free_by_type, | 1549 | .free_by_type = agp_generic_free_by_type, |
1502 | .agp_alloc_page = agp_generic_alloc_page, | 1550 | .agp_alloc_page = agp_generic_alloc_page, |
1503 | .agp_destroy_page = agp_generic_destroy_page, | 1551 | .agp_destroy_page = agp_generic_destroy_page, |
1552 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1504 | }; | 1553 | }; |
1505 | 1554 | ||
1506 | static struct agp_bridge_driver intel_840_driver = { | 1555 | static struct agp_bridge_driver intel_840_driver = { |
@@ -1524,6 +1573,7 @@ static struct agp_bridge_driver intel_840_driver = { | |||
1524 | .free_by_type = agp_generic_free_by_type, | 1573 | .free_by_type = agp_generic_free_by_type, |
1525 | .agp_alloc_page = agp_generic_alloc_page, | 1574 | .agp_alloc_page = agp_generic_alloc_page, |
1526 | .agp_destroy_page = agp_generic_destroy_page, | 1575 | .agp_destroy_page = agp_generic_destroy_page, |
1576 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1527 | }; | 1577 | }; |
1528 | 1578 | ||
1529 | static struct agp_bridge_driver intel_845_driver = { | 1579 | static struct agp_bridge_driver intel_845_driver = { |
@@ -1547,6 +1597,7 @@ static struct agp_bridge_driver intel_845_driver = { | |||
1547 | .free_by_type = agp_generic_free_by_type, | 1597 | .free_by_type = agp_generic_free_by_type, |
1548 | .agp_alloc_page = agp_generic_alloc_page, | 1598 | .agp_alloc_page = agp_generic_alloc_page, |
1549 | .agp_destroy_page = agp_generic_destroy_page, | 1599 | .agp_destroy_page = agp_generic_destroy_page, |
1600 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1550 | }; | 1601 | }; |
1551 | 1602 | ||
1552 | static struct agp_bridge_driver intel_850_driver = { | 1603 | static struct agp_bridge_driver intel_850_driver = { |
@@ -1570,6 +1621,7 @@ static struct agp_bridge_driver intel_850_driver = { | |||
1570 | .free_by_type = agp_generic_free_by_type, | 1621 | .free_by_type = agp_generic_free_by_type, |
1571 | .agp_alloc_page = agp_generic_alloc_page, | 1622 | .agp_alloc_page = agp_generic_alloc_page, |
1572 | .agp_destroy_page = agp_generic_destroy_page, | 1623 | .agp_destroy_page = agp_generic_destroy_page, |
1624 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1573 | }; | 1625 | }; |
1574 | 1626 | ||
1575 | static struct agp_bridge_driver intel_860_driver = { | 1627 | static struct agp_bridge_driver intel_860_driver = { |
@@ -1593,6 +1645,7 @@ static struct agp_bridge_driver intel_860_driver = { | |||
1593 | .free_by_type = agp_generic_free_by_type, | 1645 | .free_by_type = agp_generic_free_by_type, |
1594 | .agp_alloc_page = agp_generic_alloc_page, | 1646 | .agp_alloc_page = agp_generic_alloc_page, |
1595 | .agp_destroy_page = agp_generic_destroy_page, | 1647 | .agp_destroy_page = agp_generic_destroy_page, |
1648 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1596 | }; | 1649 | }; |
1597 | 1650 | ||
1598 | static struct agp_bridge_driver intel_915_driver = { | 1651 | static struct agp_bridge_driver intel_915_driver = { |
@@ -1617,6 +1670,7 @@ static struct agp_bridge_driver intel_915_driver = { | |||
1617 | .free_by_type = intel_i810_free_by_type, | 1670 | .free_by_type = intel_i810_free_by_type, |
1618 | .agp_alloc_page = agp_generic_alloc_page, | 1671 | .agp_alloc_page = agp_generic_alloc_page, |
1619 | .agp_destroy_page = agp_generic_destroy_page, | 1672 | .agp_destroy_page = agp_generic_destroy_page, |
1673 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | ||
1620 | }; | 1674 | }; |
1621 | 1675 | ||
1622 | static struct agp_bridge_driver intel_i965_driver = { | 1676 | static struct agp_bridge_driver intel_i965_driver = { |
@@ -1641,6 +1695,7 @@ static struct agp_bridge_driver intel_i965_driver = { | |||
1641 | .free_by_type = intel_i810_free_by_type, | 1695 | .free_by_type = intel_i810_free_by_type, |
1642 | .agp_alloc_page = agp_generic_alloc_page, | 1696 | .agp_alloc_page = agp_generic_alloc_page, |
1643 | .agp_destroy_page = agp_generic_destroy_page, | 1697 | .agp_destroy_page = agp_generic_destroy_page, |
1698 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, | ||
1644 | }; | 1699 | }; |
1645 | 1700 | ||
1646 | static struct agp_bridge_driver intel_7505_driver = { | 1701 | static struct agp_bridge_driver intel_7505_driver = { |
@@ -1664,6 +1719,7 @@ static struct agp_bridge_driver intel_7505_driver = { | |||
1664 | .free_by_type = agp_generic_free_by_type, | 1719 | .free_by_type = agp_generic_free_by_type, |
1665 | .agp_alloc_page = agp_generic_alloc_page, | 1720 | .agp_alloc_page = agp_generic_alloc_page, |
1666 | .agp_destroy_page = agp_generic_destroy_page, | 1721 | .agp_destroy_page = agp_generic_destroy_page, |
1722 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
1667 | }; | 1723 | }; |
1668 | 1724 | ||
1669 | static int find_i810(u16 device) | 1725 | static int find_i810(u16 device) |
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c index df7f37b2739a..2563286b2fcf 100644 --- a/drivers/char/agp/nvidia-agp.c +++ b/drivers/char/agp/nvidia-agp.c | |||
@@ -310,6 +310,7 @@ static struct agp_bridge_driver nvidia_driver = { | |||
310 | .free_by_type = agp_generic_free_by_type, | 310 | .free_by_type = agp_generic_free_by_type, |
311 | .agp_alloc_page = agp_generic_alloc_page, | 311 | .agp_alloc_page = agp_generic_alloc_page, |
312 | .agp_destroy_page = agp_generic_destroy_page, | 312 | .agp_destroy_page = agp_generic_destroy_page, |
313 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
313 | }; | 314 | }; |
314 | 315 | ||
315 | static int __devinit agp_nvidia_probe(struct pci_dev *pdev, | 316 | static int __devinit agp_nvidia_probe(struct pci_dev *pdev, |
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c index 17c50b0f83f0..b7b4590673ae 100644 --- a/drivers/char/agp/parisc-agp.c +++ b/drivers/char/agp/parisc-agp.c | |||
@@ -228,6 +228,7 @@ struct agp_bridge_driver parisc_agp_driver = { | |||
228 | .free_by_type = agp_generic_free_by_type, | 228 | .free_by_type = agp_generic_free_by_type, |
229 | .agp_alloc_page = agp_generic_alloc_page, | 229 | .agp_alloc_page = agp_generic_alloc_page, |
230 | .agp_destroy_page = agp_generic_destroy_page, | 230 | .agp_destroy_page = agp_generic_destroy_page, |
231 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
231 | .cant_use_aperture = 1, | 232 | .cant_use_aperture = 1, |
232 | }; | 233 | }; |
233 | 234 | ||
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c index 902648db7efa..92d1dc45b9be 100644 --- a/drivers/char/agp/sgi-agp.c +++ b/drivers/char/agp/sgi-agp.c | |||
@@ -265,6 +265,7 @@ struct agp_bridge_driver sgi_tioca_driver = { | |||
265 | .free_by_type = agp_generic_free_by_type, | 265 | .free_by_type = agp_generic_free_by_type, |
266 | .agp_alloc_page = sgi_tioca_alloc_page, | 266 | .agp_alloc_page = sgi_tioca_alloc_page, |
267 | .agp_destroy_page = agp_generic_destroy_page, | 267 | .agp_destroy_page = agp_generic_destroy_page, |
268 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
268 | .cant_use_aperture = 1, | 269 | .cant_use_aperture = 1, |
269 | .needs_scratch_page = 0, | 270 | .needs_scratch_page = 0, |
270 | .num_aperture_sizes = 1, | 271 | .num_aperture_sizes = 1, |
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c index a00fd48a6f05..60342b708152 100644 --- a/drivers/char/agp/sis-agp.c +++ b/drivers/char/agp/sis-agp.c | |||
@@ -140,6 +140,7 @@ static struct agp_bridge_driver sis_driver = { | |||
140 | .free_by_type = agp_generic_free_by_type, | 140 | .free_by_type = agp_generic_free_by_type, |
141 | .agp_alloc_page = agp_generic_alloc_page, | 141 | .agp_alloc_page = agp_generic_alloc_page, |
142 | .agp_destroy_page = agp_generic_destroy_page, | 142 | .agp_destroy_page = agp_generic_destroy_page, |
143 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
143 | }; | 144 | }; |
144 | 145 | ||
145 | static struct agp_device_ids sis_agp_device_ids[] __devinitdata = | 146 | static struct agp_device_ids sis_agp_device_ids[] __devinitdata = |
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c index 4f2d7d99902f..9f5ae7714f85 100644 --- a/drivers/char/agp/sworks-agp.c +++ b/drivers/char/agp/sworks-agp.c | |||
@@ -444,6 +444,7 @@ static struct agp_bridge_driver sworks_driver = { | |||
444 | .free_by_type = agp_generic_free_by_type, | 444 | .free_by_type = agp_generic_free_by_type, |
445 | .agp_alloc_page = agp_generic_alloc_page, | 445 | .agp_alloc_page = agp_generic_alloc_page, |
446 | .agp_destroy_page = agp_generic_destroy_page, | 446 | .agp_destroy_page = agp_generic_destroy_page, |
447 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
447 | }; | 448 | }; |
448 | 449 | ||
449 | static int __devinit agp_serverworks_probe(struct pci_dev *pdev, | 450 | static int __devinit agp_serverworks_probe(struct pci_dev *pdev, |
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c index dffc19382f7e..6c45702e542c 100644 --- a/drivers/char/agp/uninorth-agp.c +++ b/drivers/char/agp/uninorth-agp.c | |||
@@ -510,6 +510,7 @@ struct agp_bridge_driver uninorth_agp_driver = { | |||
510 | .free_by_type = agp_generic_free_by_type, | 510 | .free_by_type = agp_generic_free_by_type, |
511 | .agp_alloc_page = agp_generic_alloc_page, | 511 | .agp_alloc_page = agp_generic_alloc_page, |
512 | .agp_destroy_page = agp_generic_destroy_page, | 512 | .agp_destroy_page = agp_generic_destroy_page, |
513 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
513 | .cant_use_aperture = 1, | 514 | .cant_use_aperture = 1, |
514 | }; | 515 | }; |
515 | 516 | ||
@@ -534,6 +535,7 @@ struct agp_bridge_driver u3_agp_driver = { | |||
534 | .free_by_type = agp_generic_free_by_type, | 535 | .free_by_type = agp_generic_free_by_type, |
535 | .agp_alloc_page = agp_generic_alloc_page, | 536 | .agp_alloc_page = agp_generic_alloc_page, |
536 | .agp_destroy_page = agp_generic_destroy_page, | 537 | .agp_destroy_page = agp_generic_destroy_page, |
538 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
537 | .cant_use_aperture = 1, | 539 | .cant_use_aperture = 1, |
538 | .needs_scratch_page = 1, | 540 | .needs_scratch_page = 1, |
539 | }; | 541 | }; |
diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c index 2ded7a280d7f..2e7c04370cd9 100644 --- a/drivers/char/agp/via-agp.c +++ b/drivers/char/agp/via-agp.c | |||
@@ -191,6 +191,7 @@ static struct agp_bridge_driver via_agp3_driver = { | |||
191 | .free_by_type = agp_generic_free_by_type, | 191 | .free_by_type = agp_generic_free_by_type, |
192 | .agp_alloc_page = agp_generic_alloc_page, | 192 | .agp_alloc_page = agp_generic_alloc_page, |
193 | .agp_destroy_page = agp_generic_destroy_page, | 193 | .agp_destroy_page = agp_generic_destroy_page, |
194 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
194 | }; | 195 | }; |
195 | 196 | ||
196 | static struct agp_bridge_driver via_driver = { | 197 | static struct agp_bridge_driver via_driver = { |
@@ -214,6 +215,7 @@ static struct agp_bridge_driver via_driver = { | |||
214 | .free_by_type = agp_generic_free_by_type, | 215 | .free_by_type = agp_generic_free_by_type, |
215 | .agp_alloc_page = agp_generic_alloc_page, | 216 | .agp_alloc_page = agp_generic_alloc_page, |
216 | .agp_destroy_page = agp_generic_destroy_page, | 217 | .agp_destroy_page = agp_generic_destroy_page, |
218 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, | ||
217 | }; | 219 | }; |
218 | 220 | ||
219 | static struct agp_device_ids via_agp_device_ids[] __devinitdata = | 221 | static struct agp_device_ids via_agp_device_ids[] __devinitdata = |
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c index 1aa93a752a9c..ae76a9ffe89f 100644 --- a/drivers/char/hangcheck-timer.c +++ b/drivers/char/hangcheck-timer.c | |||
@@ -117,7 +117,7 @@ __setup("hcheck_reboot", hangcheck_parse_reboot); | |||
117 | __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); | 117 | __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); |
118 | #endif /* not MODULE */ | 118 | #endif /* not MODULE */ |
119 | 119 | ||
120 | #if defined(CONFIG_X86_64) || defined(CONFIG_S390) | 120 | #if defined(CONFIG_S390) |
121 | # define HAVE_MONOTONIC | 121 | # define HAVE_MONOTONIC |
122 | # define TIMER_FREQ 1000000000ULL | 122 | # define TIMER_FREQ 1000000000ULL |
123 | #elif defined(CONFIG_IA64) | 123 | #elif defined(CONFIG_IA64) |
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c index be73c80d699d..1d8c4ae61551 100644 --- a/drivers/char/sysrq.c +++ b/drivers/char/sysrq.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/workqueue.h> | 36 | #include <linux/workqueue.h> |
37 | #include <linux/kexec.h> | 37 | #include <linux/kexec.h> |
38 | #include <linux/irq.h> | 38 | #include <linux/irq.h> |
39 | #include <linux/hrtimer.h> | ||
39 | 40 | ||
40 | #include <asm/ptrace.h> | 41 | #include <asm/ptrace.h> |
41 | #include <asm/irq_regs.h> | 42 | #include <asm/irq_regs.h> |
@@ -158,6 +159,17 @@ static struct sysrq_key_op sysrq_sync_op = { | |||
158 | .enable_mask = SYSRQ_ENABLE_SYNC, | 159 | .enable_mask = SYSRQ_ENABLE_SYNC, |
159 | }; | 160 | }; |
160 | 161 | ||
162 | static void sysrq_handle_show_timers(int key, struct tty_struct *tty) | ||
163 | { | ||
164 | sysrq_timer_list_show(); | ||
165 | } | ||
166 | |||
167 | static struct sysrq_key_op sysrq_show_timers_op = { | ||
168 | .handler = sysrq_handle_show_timers, | ||
169 | .help_msg = "show-all-timers(Q)", | ||
170 | .action_msg = "Show Pending Timers", | ||
171 | }; | ||
172 | |||
161 | static void sysrq_handle_mountro(int key, struct tty_struct *tty) | 173 | static void sysrq_handle_mountro(int key, struct tty_struct *tty) |
162 | { | 174 | { |
163 | emergency_remount(); | 175 | emergency_remount(); |
@@ -335,7 +347,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = { | |||
335 | /* o: This will often be registered as 'Off' at init time */ | 347 | /* o: This will often be registered as 'Off' at init time */ |
336 | NULL, /* o */ | 348 | NULL, /* o */ |
337 | &sysrq_showregs_op, /* p */ | 349 | &sysrq_showregs_op, /* p */ |
338 | NULL, /* q */ | 350 | &sysrq_show_timers_op, /* q */ |
339 | &sysrq_unraw_op, /* r */ | 351 | &sysrq_unraw_op, /* r */ |
340 | &sysrq_sync_op, /* s */ | 352 | &sysrq_sync_op, /* s */ |
341 | &sysrq_showstate_op, /* t */ | 353 | &sysrq_showstate_op, /* t */ |
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c index b6bcdbbf57b3..ccaa6a39cb4b 100644 --- a/drivers/clocksource/acpi_pm.c +++ b/drivers/clocksource/acpi_pm.c | |||
@@ -16,15 +16,13 @@ | |||
16 | * This file is licensed under the GPL v2. | 16 | * This file is licensed under the GPL v2. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/acpi_pmtmr.h> | ||
19 | #include <linux/clocksource.h> | 20 | #include <linux/clocksource.h> |
20 | #include <linux/errno.h> | 21 | #include <linux/errno.h> |
21 | #include <linux/init.h> | 22 | #include <linux/init.h> |
22 | #include <linux/pci.h> | 23 | #include <linux/pci.h> |
23 | #include <asm/io.h> | 24 | #include <asm/io.h> |
24 | 25 | ||
25 | /* Number of PMTMR ticks expected during calibration run */ | ||
26 | #define PMTMR_TICKS_PER_SEC 3579545 | ||
27 | |||
28 | /* | 26 | /* |
29 | * The I/O port the PMTMR resides at. | 27 | * The I/O port the PMTMR resides at. |
30 | * The location is detected during setup_arch(), | 28 | * The location is detected during setup_arch(), |
@@ -32,15 +30,13 @@ | |||
32 | */ | 30 | */ |
33 | u32 pmtmr_ioport __read_mostly; | 31 | u32 pmtmr_ioport __read_mostly; |
34 | 32 | ||
35 | #define ACPI_PM_MASK CLOCKSOURCE_MASK(24) /* limit it to 24 bits */ | ||
36 | |||
37 | static inline u32 read_pmtmr(void) | 33 | static inline u32 read_pmtmr(void) |
38 | { | 34 | { |
39 | /* mask the output to 24 bits */ | 35 | /* mask the output to 24 bits */ |
40 | return inl(pmtmr_ioport) & ACPI_PM_MASK; | 36 | return inl(pmtmr_ioport) & ACPI_PM_MASK; |
41 | } | 37 | } |
42 | 38 | ||
43 | static cycle_t acpi_pm_read_verified(void) | 39 | u32 acpi_pm_read_verified(void) |
44 | { | 40 | { |
45 | u32 v1 = 0, v2 = 0, v3 = 0; | 41 | u32 v1 = 0, v2 = 0, v3 = 0; |
46 | 42 | ||
@@ -57,7 +53,12 @@ static cycle_t acpi_pm_read_verified(void) | |||
57 | } while (unlikely((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) | 53 | } while (unlikely((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) |
58 | || (v3 > v1 && v3 < v2))); | 54 | || (v3 > v1 && v3 < v2))); |
59 | 55 | ||
60 | return (cycle_t)v2; | 56 | return v2; |
57 | } | ||
58 | |||
59 | static cycle_t acpi_pm_read_slow(void) | ||
60 | { | ||
61 | return (cycle_t)acpi_pm_read_verified(); | ||
61 | } | 62 | } |
62 | 63 | ||
63 | static cycle_t acpi_pm_read(void) | 64 | static cycle_t acpi_pm_read(void) |
@@ -72,7 +73,8 @@ static struct clocksource clocksource_acpi_pm = { | |||
72 | .mask = (cycle_t)ACPI_PM_MASK, | 73 | .mask = (cycle_t)ACPI_PM_MASK, |
73 | .mult = 0, /*to be caluclated*/ | 74 | .mult = 0, /*to be caluclated*/ |
74 | .shift = 22, | 75 | .shift = 22, |
75 | .is_continuous = 1, | 76 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
77 | |||
76 | }; | 78 | }; |
77 | 79 | ||
78 | 80 | ||
@@ -87,7 +89,7 @@ __setup("acpi_pm_good", acpi_pm_good_setup); | |||
87 | 89 | ||
88 | static inline void acpi_pm_need_workaround(void) | 90 | static inline void acpi_pm_need_workaround(void) |
89 | { | 91 | { |
90 | clocksource_acpi_pm.read = acpi_pm_read_verified; | 92 | clocksource_acpi_pm.read = acpi_pm_read_slow; |
91 | clocksource_acpi_pm.rating = 110; | 93 | clocksource_acpi_pm.rating = 110; |
92 | } | 94 | } |
93 | 95 | ||
diff --git a/drivers/clocksource/cyclone.c b/drivers/clocksource/cyclone.c index bf4d3d50d1c4..4f3925ceb360 100644 --- a/drivers/clocksource/cyclone.c +++ b/drivers/clocksource/cyclone.c | |||
@@ -31,7 +31,7 @@ static struct clocksource clocksource_cyclone = { | |||
31 | .mask = CYCLONE_TIMER_MASK, | 31 | .mask = CYCLONE_TIMER_MASK, |
32 | .mult = 10, | 32 | .mult = 10, |
33 | .shift = 0, | 33 | .shift = 0, |
34 | .is_continuous = 1, | 34 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
35 | }; | 35 | }; |
36 | 36 | ||
37 | static int __init init_cyclone_clocksource(void) | 37 | static int __init init_cyclone_clocksource(void) |
diff --git a/drivers/clocksource/scx200_hrt.c b/drivers/clocksource/scx200_hrt.c index 22915cc46ba7..b92da677aa5d 100644 --- a/drivers/clocksource/scx200_hrt.c +++ b/drivers/clocksource/scx200_hrt.c | |||
@@ -57,7 +57,7 @@ static struct clocksource cs_hrt = { | |||
57 | .rating = 250, | 57 | .rating = 250, |
58 | .read = read_hrt, | 58 | .read = read_hrt, |
59 | .mask = CLOCKSOURCE_MASK(32), | 59 | .mask = CLOCKSOURCE_MASK(32), |
60 | .is_continuous = 1, | 60 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, |
61 | /* mult, shift are set based on mhz27 flag */ | 61 | /* mult, shift are set based on mhz27 flag */ |
62 | }; | 62 | }; |
63 | 63 | ||
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index 491779af8d55..d155e81b5c97 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig | |||
@@ -16,7 +16,7 @@ config CPU_FREQ | |||
16 | if CPU_FREQ | 16 | if CPU_FREQ |
17 | 17 | ||
18 | config CPU_FREQ_TABLE | 18 | config CPU_FREQ_TABLE |
19 | def_tristate m | 19 | tristate |
20 | 20 | ||
21 | config CPU_FREQ_DEBUG | 21 | config CPU_FREQ_DEBUG |
22 | bool "Enable CPUfreq debugging" | 22 | bool "Enable CPUfreq debugging" |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index a45cc89e387a..f52facc570f5 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -41,8 +41,67 @@ static struct cpufreq_driver *cpufreq_driver; | |||
41 | static struct cpufreq_policy *cpufreq_cpu_data[NR_CPUS]; | 41 | static struct cpufreq_policy *cpufreq_cpu_data[NR_CPUS]; |
42 | static DEFINE_SPINLOCK(cpufreq_driver_lock); | 42 | static DEFINE_SPINLOCK(cpufreq_driver_lock); |
43 | 43 | ||
44 | /* | ||
45 | * cpu_policy_rwsem is a per CPU reader-writer semaphore designed to cure | ||
46 | * all cpufreq/hotplug/workqueue/etc related lock issues. | ||
47 | * | ||
48 | * The rules for this semaphore: | ||
49 | * - Any routine that wants to read from the policy structure will | ||
50 | * do a down_read on this semaphore. | ||
51 | * - Any routine that will write to the policy structure and/or may take away | ||
52 | * the policy altogether (eg. CPU hotplug), will hold this lock in write | ||
53 | * mode before doing so. | ||
54 | * | ||
55 | * Additional rules: | ||
56 | * - All holders of the lock should check to make sure that the CPU they | ||
57 | * are concerned with are online after they get the lock. | ||
58 | * - Governor routines that can be called in cpufreq hotplug path should not | ||
59 | * take this sem as top level hotplug notifier handler takes this. | ||
60 | */ | ||
61 | static DEFINE_PER_CPU(int, policy_cpu); | ||
62 | static DEFINE_PER_CPU(struct rw_semaphore, cpu_policy_rwsem); | ||
63 | |||
64 | #define lock_policy_rwsem(mode, cpu) \ | ||
65 | int lock_policy_rwsem_##mode \ | ||
66 | (int cpu) \ | ||
67 | { \ | ||
68 | int policy_cpu = per_cpu(policy_cpu, cpu); \ | ||
69 | BUG_ON(policy_cpu == -1); \ | ||
70 | down_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \ | ||
71 | if (unlikely(!cpu_online(cpu))) { \ | ||
72 | up_##mode(&per_cpu(cpu_policy_rwsem, policy_cpu)); \ | ||
73 | return -1; \ | ||
74 | } \ | ||
75 | \ | ||
76 | return 0; \ | ||
77 | } | ||
78 | |||
79 | lock_policy_rwsem(read, cpu); | ||
80 | EXPORT_SYMBOL_GPL(lock_policy_rwsem_read); | ||
81 | |||
82 | lock_policy_rwsem(write, cpu); | ||
83 | EXPORT_SYMBOL_GPL(lock_policy_rwsem_write); | ||
84 | |||
85 | void unlock_policy_rwsem_read(int cpu) | ||
86 | { | ||
87 | int policy_cpu = per_cpu(policy_cpu, cpu); | ||
88 | BUG_ON(policy_cpu == -1); | ||
89 | up_read(&per_cpu(cpu_policy_rwsem, policy_cpu)); | ||
90 | } | ||
91 | EXPORT_SYMBOL_GPL(unlock_policy_rwsem_read); | ||
92 | |||
93 | void unlock_policy_rwsem_write(int cpu) | ||
94 | { | ||
95 | int policy_cpu = per_cpu(policy_cpu, cpu); | ||
96 | BUG_ON(policy_cpu == -1); | ||
97 | up_write(&per_cpu(cpu_policy_rwsem, policy_cpu)); | ||
98 | } | ||
99 | EXPORT_SYMBOL_GPL(unlock_policy_rwsem_write); | ||
100 | |||
101 | |||
44 | /* internal prototypes */ | 102 | /* internal prototypes */ |
45 | static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); | 103 | static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); |
104 | static unsigned int __cpufreq_get(unsigned int cpu); | ||
46 | static void handle_update(struct work_struct *work); | 105 | static void handle_update(struct work_struct *work); |
47 | 106 | ||
48 | /** | 107 | /** |
@@ -415,12 +474,8 @@ static ssize_t store_##file_name \ | |||
415 | if (ret != 1) \ | 474 | if (ret != 1) \ |
416 | return -EINVAL; \ | 475 | return -EINVAL; \ |
417 | \ | 476 | \ |
418 | lock_cpu_hotplug(); \ | ||
419 | mutex_lock(&policy->lock); \ | ||
420 | ret = __cpufreq_set_policy(policy, &new_policy); \ | 477 | ret = __cpufreq_set_policy(policy, &new_policy); \ |
421 | policy->user_policy.object = policy->object; \ | 478 | policy->user_policy.object = policy->object; \ |
422 | mutex_unlock(&policy->lock); \ | ||
423 | unlock_cpu_hotplug(); \ | ||
424 | \ | 479 | \ |
425 | return ret ? ret : count; \ | 480 | return ret ? ret : count; \ |
426 | } | 481 | } |
@@ -434,7 +489,7 @@ store_one(scaling_max_freq,max); | |||
434 | static ssize_t show_cpuinfo_cur_freq (struct cpufreq_policy * policy, | 489 | static ssize_t show_cpuinfo_cur_freq (struct cpufreq_policy * policy, |
435 | char *buf) | 490 | char *buf) |
436 | { | 491 | { |
437 | unsigned int cur_freq = cpufreq_get(policy->cpu); | 492 | unsigned int cur_freq = __cpufreq_get(policy->cpu); |
438 | if (!cur_freq) | 493 | if (!cur_freq) |
439 | return sprintf(buf, "<unknown>"); | 494 | return sprintf(buf, "<unknown>"); |
440 | return sprintf(buf, "%u\n", cur_freq); | 495 | return sprintf(buf, "%u\n", cur_freq); |
@@ -479,18 +534,12 @@ static ssize_t store_scaling_governor (struct cpufreq_policy * policy, | |||
479 | &new_policy.governor)) | 534 | &new_policy.governor)) |
480 | return -EINVAL; | 535 | return -EINVAL; |
481 | 536 | ||
482 | lock_cpu_hotplug(); | ||
483 | |||
484 | /* Do not use cpufreq_set_policy here or the user_policy.max | 537 | /* Do not use cpufreq_set_policy here or the user_policy.max |
485 | will be wrongly overridden */ | 538 | will be wrongly overridden */ |
486 | mutex_lock(&policy->lock); | ||
487 | ret = __cpufreq_set_policy(policy, &new_policy); | 539 | ret = __cpufreq_set_policy(policy, &new_policy); |
488 | 540 | ||
489 | policy->user_policy.policy = policy->policy; | 541 | policy->user_policy.policy = policy->policy; |
490 | policy->user_policy.governor = policy->governor; | 542 | policy->user_policy.governor = policy->governor; |
491 | mutex_unlock(&policy->lock); | ||
492 | |||
493 | unlock_cpu_hotplug(); | ||
494 | 543 | ||
495 | if (ret) | 544 | if (ret) |
496 | return ret; | 545 | return ret; |
@@ -595,11 +644,17 @@ static ssize_t show(struct kobject * kobj, struct attribute * attr ,char * buf) | |||
595 | policy = cpufreq_cpu_get(policy->cpu); | 644 | policy = cpufreq_cpu_get(policy->cpu); |
596 | if (!policy) | 645 | if (!policy) |
597 | return -EINVAL; | 646 | return -EINVAL; |
647 | |||
648 | if (lock_policy_rwsem_read(policy->cpu) < 0) | ||
649 | return -EINVAL; | ||
650 | |||
598 | if (fattr->show) | 651 | if (fattr->show) |
599 | ret = fattr->show(policy, buf); | 652 | ret = fattr->show(policy, buf); |
600 | else | 653 | else |
601 | ret = -EIO; | 654 | ret = -EIO; |
602 | 655 | ||
656 | unlock_policy_rwsem_read(policy->cpu); | ||
657 | |||
603 | cpufreq_cpu_put(policy); | 658 | cpufreq_cpu_put(policy); |
604 | return ret; | 659 | return ret; |
605 | } | 660 | } |
@@ -613,11 +668,17 @@ static ssize_t store(struct kobject * kobj, struct attribute * attr, | |||
613 | policy = cpufreq_cpu_get(policy->cpu); | 668 | policy = cpufreq_cpu_get(policy->cpu); |
614 | if (!policy) | 669 | if (!policy) |
615 | return -EINVAL; | 670 | return -EINVAL; |
671 | |||
672 | if (lock_policy_rwsem_write(policy->cpu) < 0) | ||
673 | return -EINVAL; | ||
674 | |||
616 | if (fattr->store) | 675 | if (fattr->store) |
617 | ret = fattr->store(policy, buf, count); | 676 | ret = fattr->store(policy, buf, count); |
618 | else | 677 | else |
619 | ret = -EIO; | 678 | ret = -EIO; |
620 | 679 | ||
680 | unlock_policy_rwsem_write(policy->cpu); | ||
681 | |||
621 | cpufreq_cpu_put(policy); | 682 | cpufreq_cpu_put(policy); |
622 | return ret; | 683 | return ret; |
623 | } | 684 | } |
@@ -691,8 +752,10 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
691 | policy->cpu = cpu; | 752 | policy->cpu = cpu; |
692 | policy->cpus = cpumask_of_cpu(cpu); | 753 | policy->cpus = cpumask_of_cpu(cpu); |
693 | 754 | ||
694 | mutex_init(&policy->lock); | 755 | /* Initially set CPU itself as the policy_cpu */ |
695 | mutex_lock(&policy->lock); | 756 | per_cpu(policy_cpu, cpu) = cpu; |
757 | lock_policy_rwsem_write(cpu); | ||
758 | |||
696 | init_completion(&policy->kobj_unregister); | 759 | init_completion(&policy->kobj_unregister); |
697 | INIT_WORK(&policy->update, handle_update); | 760 | INIT_WORK(&policy->update, handle_update); |
698 | 761 | ||
@@ -702,7 +765,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
702 | ret = cpufreq_driver->init(policy); | 765 | ret = cpufreq_driver->init(policy); |
703 | if (ret) { | 766 | if (ret) { |
704 | dprintk("initialization failed\n"); | 767 | dprintk("initialization failed\n"); |
705 | mutex_unlock(&policy->lock); | 768 | unlock_policy_rwsem_write(cpu); |
706 | goto err_out; | 769 | goto err_out; |
707 | } | 770 | } |
708 | 771 | ||
@@ -716,6 +779,14 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
716 | */ | 779 | */ |
717 | managed_policy = cpufreq_cpu_get(j); | 780 | managed_policy = cpufreq_cpu_get(j); |
718 | if (unlikely(managed_policy)) { | 781 | if (unlikely(managed_policy)) { |
782 | |||
783 | /* Set proper policy_cpu */ | ||
784 | unlock_policy_rwsem_write(cpu); | ||
785 | per_cpu(policy_cpu, cpu) = managed_policy->cpu; | ||
786 | |||
787 | if (lock_policy_rwsem_write(cpu) < 0) | ||
788 | goto err_out_driver_exit; | ||
789 | |||
719 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 790 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
720 | managed_policy->cpus = policy->cpus; | 791 | managed_policy->cpus = policy->cpus; |
721 | cpufreq_cpu_data[cpu] = managed_policy; | 792 | cpufreq_cpu_data[cpu] = managed_policy; |
@@ -726,13 +797,13 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
726 | &managed_policy->kobj, | 797 | &managed_policy->kobj, |
727 | "cpufreq"); | 798 | "cpufreq"); |
728 | if (ret) { | 799 | if (ret) { |
729 | mutex_unlock(&policy->lock); | 800 | unlock_policy_rwsem_write(cpu); |
730 | goto err_out_driver_exit; | 801 | goto err_out_driver_exit; |
731 | } | 802 | } |
732 | 803 | ||
733 | cpufreq_debug_enable_ratelimit(); | 804 | cpufreq_debug_enable_ratelimit(); |
734 | mutex_unlock(&policy->lock); | ||
735 | ret = 0; | 805 | ret = 0; |
806 | unlock_policy_rwsem_write(cpu); | ||
736 | goto err_out_driver_exit; /* call driver->exit() */ | 807 | goto err_out_driver_exit; /* call driver->exit() */ |
737 | } | 808 | } |
738 | } | 809 | } |
@@ -746,7 +817,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
746 | 817 | ||
747 | ret = kobject_register(&policy->kobj); | 818 | ret = kobject_register(&policy->kobj); |
748 | if (ret) { | 819 | if (ret) { |
749 | mutex_unlock(&policy->lock); | 820 | unlock_policy_rwsem_write(cpu); |
750 | goto err_out_driver_exit; | 821 | goto err_out_driver_exit; |
751 | } | 822 | } |
752 | /* set up files for this cpu device */ | 823 | /* set up files for this cpu device */ |
@@ -761,8 +832,10 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
761 | sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); | 832 | sysfs_create_file(&policy->kobj, &scaling_cur_freq.attr); |
762 | 833 | ||
763 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 834 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
764 | for_each_cpu_mask(j, policy->cpus) | 835 | for_each_cpu_mask(j, policy->cpus) { |
765 | cpufreq_cpu_data[j] = policy; | 836 | cpufreq_cpu_data[j] = policy; |
837 | per_cpu(policy_cpu, j) = policy->cpu; | ||
838 | } | ||
766 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 839 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
767 | 840 | ||
768 | /* symlink affected CPUs */ | 841 | /* symlink affected CPUs */ |
@@ -778,14 +851,14 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
778 | ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, | 851 | ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, |
779 | "cpufreq"); | 852 | "cpufreq"); |
780 | if (ret) { | 853 | if (ret) { |
781 | mutex_unlock(&policy->lock); | 854 | unlock_policy_rwsem_write(cpu); |
782 | goto err_out_unregister; | 855 | goto err_out_unregister; |
783 | } | 856 | } |
784 | } | 857 | } |
785 | 858 | ||
786 | policy->governor = NULL; /* to assure that the starting sequence is | 859 | policy->governor = NULL; /* to assure that the starting sequence is |
787 | * run in cpufreq_set_policy */ | 860 | * run in cpufreq_set_policy */ |
788 | mutex_unlock(&policy->lock); | 861 | unlock_policy_rwsem_write(cpu); |
789 | 862 | ||
790 | /* set default policy */ | 863 | /* set default policy */ |
791 | ret = cpufreq_set_policy(&new_policy); | 864 | ret = cpufreq_set_policy(&new_policy); |
@@ -826,11 +899,13 @@ module_out: | |||
826 | 899 | ||
827 | 900 | ||
828 | /** | 901 | /** |
829 | * cpufreq_remove_dev - remove a CPU device | 902 | * __cpufreq_remove_dev - remove a CPU device |
830 | * | 903 | * |
831 | * Removes the cpufreq interface for a CPU device. | 904 | * Removes the cpufreq interface for a CPU device. |
905 | * Caller should already have policy_rwsem in write mode for this CPU. | ||
906 | * This routine frees the rwsem before returning. | ||
832 | */ | 907 | */ |
833 | static int cpufreq_remove_dev (struct sys_device * sys_dev) | 908 | static int __cpufreq_remove_dev (struct sys_device * sys_dev) |
834 | { | 909 | { |
835 | unsigned int cpu = sys_dev->id; | 910 | unsigned int cpu = sys_dev->id; |
836 | unsigned long flags; | 911 | unsigned long flags; |
@@ -849,6 +924,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) | |||
849 | if (!data) { | 924 | if (!data) { |
850 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 925 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
851 | cpufreq_debug_enable_ratelimit(); | 926 | cpufreq_debug_enable_ratelimit(); |
927 | unlock_policy_rwsem_write(cpu); | ||
852 | return -EINVAL; | 928 | return -EINVAL; |
853 | } | 929 | } |
854 | cpufreq_cpu_data[cpu] = NULL; | 930 | cpufreq_cpu_data[cpu] = NULL; |
@@ -865,6 +941,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) | |||
865 | sysfs_remove_link(&sys_dev->kobj, "cpufreq"); | 941 | sysfs_remove_link(&sys_dev->kobj, "cpufreq"); |
866 | cpufreq_cpu_put(data); | 942 | cpufreq_cpu_put(data); |
867 | cpufreq_debug_enable_ratelimit(); | 943 | cpufreq_debug_enable_ratelimit(); |
944 | unlock_policy_rwsem_write(cpu); | ||
868 | return 0; | 945 | return 0; |
869 | } | 946 | } |
870 | #endif | 947 | #endif |
@@ -873,6 +950,7 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) | |||
873 | if (!kobject_get(&data->kobj)) { | 950 | if (!kobject_get(&data->kobj)) { |
874 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 951 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
875 | cpufreq_debug_enable_ratelimit(); | 952 | cpufreq_debug_enable_ratelimit(); |
953 | unlock_policy_rwsem_write(cpu); | ||
876 | return -EFAULT; | 954 | return -EFAULT; |
877 | } | 955 | } |
878 | 956 | ||
@@ -906,10 +984,10 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) | |||
906 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 984 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
907 | #endif | 985 | #endif |
908 | 986 | ||
909 | mutex_lock(&data->lock); | ||
910 | if (cpufreq_driver->target) | 987 | if (cpufreq_driver->target) |
911 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); | 988 | __cpufreq_governor(data, CPUFREQ_GOV_STOP); |
912 | mutex_unlock(&data->lock); | 989 | |
990 | unlock_policy_rwsem_write(cpu); | ||
913 | 991 | ||
914 | kobject_unregister(&data->kobj); | 992 | kobject_unregister(&data->kobj); |
915 | 993 | ||
@@ -933,6 +1011,18 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev) | |||
933 | } | 1011 | } |
934 | 1012 | ||
935 | 1013 | ||
1014 | static int cpufreq_remove_dev (struct sys_device * sys_dev) | ||
1015 | { | ||
1016 | unsigned int cpu = sys_dev->id; | ||
1017 | int retval; | ||
1018 | if (unlikely(lock_policy_rwsem_write(cpu))) | ||
1019 | BUG(); | ||
1020 | |||
1021 | retval = __cpufreq_remove_dev(sys_dev); | ||
1022 | return retval; | ||
1023 | } | ||
1024 | |||
1025 | |||
936 | static void handle_update(struct work_struct *work) | 1026 | static void handle_update(struct work_struct *work) |
937 | { | 1027 | { |
938 | struct cpufreq_policy *policy = | 1028 | struct cpufreq_policy *policy = |
@@ -980,9 +1070,12 @@ unsigned int cpufreq_quick_get(unsigned int cpu) | |||
980 | unsigned int ret_freq = 0; | 1070 | unsigned int ret_freq = 0; |
981 | 1071 | ||
982 | if (policy) { | 1072 | if (policy) { |
983 | mutex_lock(&policy->lock); | 1073 | if (unlikely(lock_policy_rwsem_read(cpu))) |
1074 | return ret_freq; | ||
1075 | |||
984 | ret_freq = policy->cur; | 1076 | ret_freq = policy->cur; |
985 | mutex_unlock(&policy->lock); | 1077 | |
1078 | unlock_policy_rwsem_read(cpu); | ||
986 | cpufreq_cpu_put(policy); | 1079 | cpufreq_cpu_put(policy); |
987 | } | 1080 | } |
988 | 1081 | ||
@@ -991,24 +1084,13 @@ unsigned int cpufreq_quick_get(unsigned int cpu) | |||
991 | EXPORT_SYMBOL(cpufreq_quick_get); | 1084 | EXPORT_SYMBOL(cpufreq_quick_get); |
992 | 1085 | ||
993 | 1086 | ||
994 | /** | 1087 | static unsigned int __cpufreq_get(unsigned int cpu) |
995 | * cpufreq_get - get the current CPU frequency (in kHz) | ||
996 | * @cpu: CPU number | ||
997 | * | ||
998 | * Get the CPU current (static) CPU frequency | ||
999 | */ | ||
1000 | unsigned int cpufreq_get(unsigned int cpu) | ||
1001 | { | 1088 | { |
1002 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); | 1089 | struct cpufreq_policy *policy = cpufreq_cpu_data[cpu]; |
1003 | unsigned int ret_freq = 0; | 1090 | unsigned int ret_freq = 0; |
1004 | 1091 | ||
1005 | if (!policy) | ||
1006 | return 0; | ||
1007 | |||
1008 | if (!cpufreq_driver->get) | 1092 | if (!cpufreq_driver->get) |
1009 | goto out; | 1093 | return (ret_freq); |
1010 | |||
1011 | mutex_lock(&policy->lock); | ||
1012 | 1094 | ||
1013 | ret_freq = cpufreq_driver->get(cpu); | 1095 | ret_freq = cpufreq_driver->get(cpu); |
1014 | 1096 | ||
@@ -1022,11 +1104,33 @@ unsigned int cpufreq_get(unsigned int cpu) | |||
1022 | } | 1104 | } |
1023 | } | 1105 | } |
1024 | 1106 | ||
1025 | mutex_unlock(&policy->lock); | 1107 | return (ret_freq); |
1108 | } | ||
1026 | 1109 | ||
1027 | out: | 1110 | /** |
1028 | cpufreq_cpu_put(policy); | 1111 | * cpufreq_get - get the current CPU frequency (in kHz) |
1112 | * @cpu: CPU number | ||
1113 | * | ||
1114 | * Get the CPU current (static) CPU frequency | ||
1115 | */ | ||
1116 | unsigned int cpufreq_get(unsigned int cpu) | ||
1117 | { | ||
1118 | unsigned int ret_freq = 0; | ||
1119 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); | ||
1120 | |||
1121 | if (!policy) | ||
1122 | goto out; | ||
1123 | |||
1124 | if (unlikely(lock_policy_rwsem_read(cpu))) | ||
1125 | goto out_policy; | ||
1126 | |||
1127 | ret_freq = __cpufreq_get(cpu); | ||
1029 | 1128 | ||
1129 | unlock_policy_rwsem_read(cpu); | ||
1130 | |||
1131 | out_policy: | ||
1132 | cpufreq_cpu_put(policy); | ||
1133 | out: | ||
1030 | return (ret_freq); | 1134 | return (ret_freq); |
1031 | } | 1135 | } |
1032 | EXPORT_SYMBOL(cpufreq_get); | 1136 | EXPORT_SYMBOL(cpufreq_get); |
@@ -1278,7 +1382,6 @@ EXPORT_SYMBOL(cpufreq_unregister_notifier); | |||
1278 | *********************************************************************/ | 1382 | *********************************************************************/ |
1279 | 1383 | ||
1280 | 1384 | ||
1281 | /* Must be called with lock_cpu_hotplug held */ | ||
1282 | int __cpufreq_driver_target(struct cpufreq_policy *policy, | 1385 | int __cpufreq_driver_target(struct cpufreq_policy *policy, |
1283 | unsigned int target_freq, | 1386 | unsigned int target_freq, |
1284 | unsigned int relation) | 1387 | unsigned int relation) |
@@ -1304,20 +1407,19 @@ int cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1304 | if (!policy) | 1407 | if (!policy) |
1305 | return -EINVAL; | 1408 | return -EINVAL; |
1306 | 1409 | ||
1307 | lock_cpu_hotplug(); | 1410 | if (unlikely(lock_policy_rwsem_write(policy->cpu))) |
1308 | mutex_lock(&policy->lock); | 1411 | return -EINVAL; |
1309 | 1412 | ||
1310 | ret = __cpufreq_driver_target(policy, target_freq, relation); | 1413 | ret = __cpufreq_driver_target(policy, target_freq, relation); |
1311 | 1414 | ||
1312 | mutex_unlock(&policy->lock); | 1415 | unlock_policy_rwsem_write(policy->cpu); |
1313 | unlock_cpu_hotplug(); | ||
1314 | 1416 | ||
1315 | cpufreq_cpu_put(policy); | 1417 | cpufreq_cpu_put(policy); |
1316 | return ret; | 1418 | return ret; |
1317 | } | 1419 | } |
1318 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); | 1420 | EXPORT_SYMBOL_GPL(cpufreq_driver_target); |
1319 | 1421 | ||
1320 | int cpufreq_driver_getavg(struct cpufreq_policy *policy) | 1422 | int __cpufreq_driver_getavg(struct cpufreq_policy *policy) |
1321 | { | 1423 | { |
1322 | int ret = 0; | 1424 | int ret = 0; |
1323 | 1425 | ||
@@ -1325,20 +1427,15 @@ int cpufreq_driver_getavg(struct cpufreq_policy *policy) | |||
1325 | if (!policy) | 1427 | if (!policy) |
1326 | return -EINVAL; | 1428 | return -EINVAL; |
1327 | 1429 | ||
1328 | mutex_lock(&policy->lock); | ||
1329 | |||
1330 | if (cpu_online(policy->cpu) && cpufreq_driver->getavg) | 1430 | if (cpu_online(policy->cpu) && cpufreq_driver->getavg) |
1331 | ret = cpufreq_driver->getavg(policy->cpu); | 1431 | ret = cpufreq_driver->getavg(policy->cpu); |
1332 | 1432 | ||
1333 | mutex_unlock(&policy->lock); | ||
1334 | |||
1335 | cpufreq_cpu_put(policy); | 1433 | cpufreq_cpu_put(policy); |
1336 | return ret; | 1434 | return ret; |
1337 | } | 1435 | } |
1338 | EXPORT_SYMBOL_GPL(cpufreq_driver_getavg); | 1436 | EXPORT_SYMBOL_GPL(__cpufreq_driver_getavg); |
1339 | 1437 | ||
1340 | /* | 1438 | /* |
1341 | * Locking: Must be called with the lock_cpu_hotplug() lock held | ||
1342 | * when "event" is CPUFREQ_GOV_LIMITS | 1439 | * when "event" is CPUFREQ_GOV_LIMITS |
1343 | */ | 1440 | */ |
1344 | 1441 | ||
@@ -1420,9 +1517,7 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu) | |||
1420 | if (!cpu_policy) | 1517 | if (!cpu_policy) |
1421 | return -EINVAL; | 1518 | return -EINVAL; |
1422 | 1519 | ||
1423 | mutex_lock(&cpu_policy->lock); | ||
1424 | memcpy(policy, cpu_policy, sizeof(struct cpufreq_policy)); | 1520 | memcpy(policy, cpu_policy, sizeof(struct cpufreq_policy)); |
1425 | mutex_unlock(&cpu_policy->lock); | ||
1426 | 1521 | ||
1427 | cpufreq_cpu_put(cpu_policy); | 1522 | cpufreq_cpu_put(cpu_policy); |
1428 | return 0; | 1523 | return 0; |
@@ -1433,7 +1528,6 @@ EXPORT_SYMBOL(cpufreq_get_policy); | |||
1433 | /* | 1528 | /* |
1434 | * data : current policy. | 1529 | * data : current policy. |
1435 | * policy : policy to be set. | 1530 | * policy : policy to be set. |
1436 | * Locking: Must be called with the lock_cpu_hotplug() lock held | ||
1437 | */ | 1531 | */ |
1438 | static int __cpufreq_set_policy(struct cpufreq_policy *data, | 1532 | static int __cpufreq_set_policy(struct cpufreq_policy *data, |
1439 | struct cpufreq_policy *policy) | 1533 | struct cpufreq_policy *policy) |
@@ -1539,10 +1633,9 @@ int cpufreq_set_policy(struct cpufreq_policy *policy) | |||
1539 | if (!data) | 1633 | if (!data) |
1540 | return -EINVAL; | 1634 | return -EINVAL; |
1541 | 1635 | ||
1542 | lock_cpu_hotplug(); | 1636 | if (unlikely(lock_policy_rwsem_write(policy->cpu))) |
1637 | return -EINVAL; | ||
1543 | 1638 | ||
1544 | /* lock this CPU */ | ||
1545 | mutex_lock(&data->lock); | ||
1546 | 1639 | ||
1547 | ret = __cpufreq_set_policy(data, policy); | 1640 | ret = __cpufreq_set_policy(data, policy); |
1548 | data->user_policy.min = data->min; | 1641 | data->user_policy.min = data->min; |
@@ -1550,9 +1643,8 @@ int cpufreq_set_policy(struct cpufreq_policy *policy) | |||
1550 | data->user_policy.policy = data->policy; | 1643 | data->user_policy.policy = data->policy; |
1551 | data->user_policy.governor = data->governor; | 1644 | data->user_policy.governor = data->governor; |
1552 | 1645 | ||
1553 | mutex_unlock(&data->lock); | 1646 | unlock_policy_rwsem_write(policy->cpu); |
1554 | 1647 | ||
1555 | unlock_cpu_hotplug(); | ||
1556 | cpufreq_cpu_put(data); | 1648 | cpufreq_cpu_put(data); |
1557 | 1649 | ||
1558 | return ret; | 1650 | return ret; |
@@ -1576,8 +1668,8 @@ int cpufreq_update_policy(unsigned int cpu) | |||
1576 | if (!data) | 1668 | if (!data) |
1577 | return -ENODEV; | 1669 | return -ENODEV; |
1578 | 1670 | ||
1579 | lock_cpu_hotplug(); | 1671 | if (unlikely(lock_policy_rwsem_write(cpu))) |
1580 | mutex_lock(&data->lock); | 1672 | return -EINVAL; |
1581 | 1673 | ||
1582 | dprintk("updating policy for CPU %u\n", cpu); | 1674 | dprintk("updating policy for CPU %u\n", cpu); |
1583 | memcpy(&policy, data, sizeof(struct cpufreq_policy)); | 1675 | memcpy(&policy, data, sizeof(struct cpufreq_policy)); |
@@ -1602,8 +1694,8 @@ int cpufreq_update_policy(unsigned int cpu) | |||
1602 | 1694 | ||
1603 | ret = __cpufreq_set_policy(data, &policy); | 1695 | ret = __cpufreq_set_policy(data, &policy); |
1604 | 1696 | ||
1605 | mutex_unlock(&data->lock); | 1697 | unlock_policy_rwsem_write(cpu); |
1606 | unlock_cpu_hotplug(); | 1698 | |
1607 | cpufreq_cpu_put(data); | 1699 | cpufreq_cpu_put(data); |
1608 | return ret; | 1700 | return ret; |
1609 | } | 1701 | } |
@@ -1613,31 +1705,28 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb, | |||
1613 | unsigned long action, void *hcpu) | 1705 | unsigned long action, void *hcpu) |
1614 | { | 1706 | { |
1615 | unsigned int cpu = (unsigned long)hcpu; | 1707 | unsigned int cpu = (unsigned long)hcpu; |
1616 | struct cpufreq_policy *policy; | ||
1617 | struct sys_device *sys_dev; | 1708 | struct sys_device *sys_dev; |
1709 | struct cpufreq_policy *policy; | ||
1618 | 1710 | ||
1619 | sys_dev = get_cpu_sysdev(cpu); | 1711 | sys_dev = get_cpu_sysdev(cpu); |
1620 | |||
1621 | if (sys_dev) { | 1712 | if (sys_dev) { |
1622 | switch (action) { | 1713 | switch (action) { |
1623 | case CPU_ONLINE: | 1714 | case CPU_ONLINE: |
1624 | cpufreq_add_dev(sys_dev); | 1715 | cpufreq_add_dev(sys_dev); |
1625 | break; | 1716 | break; |
1626 | case CPU_DOWN_PREPARE: | 1717 | case CPU_DOWN_PREPARE: |
1627 | /* | 1718 | if (unlikely(lock_policy_rwsem_write(cpu))) |
1628 | * We attempt to put this cpu in lowest frequency | 1719 | BUG(); |
1629 | * possible before going down. This will permit | 1720 | |
1630 | * hardware-managed P-State to switch other related | ||
1631 | * threads to min or higher speeds if possible. | ||
1632 | */ | ||
1633 | policy = cpufreq_cpu_data[cpu]; | 1721 | policy = cpufreq_cpu_data[cpu]; |
1634 | if (policy) { | 1722 | if (policy) { |
1635 | cpufreq_driver_target(policy, policy->min, | 1723 | __cpufreq_driver_target(policy, policy->min, |
1636 | CPUFREQ_RELATION_H); | 1724 | CPUFREQ_RELATION_H); |
1637 | } | 1725 | } |
1726 | __cpufreq_remove_dev(sys_dev); | ||
1638 | break; | 1727 | break; |
1639 | case CPU_DEAD: | 1728 | case CPU_DOWN_FAILED: |
1640 | cpufreq_remove_dev(sys_dev); | 1729 | cpufreq_add_dev(sys_dev); |
1641 | break; | 1730 | break; |
1642 | } | 1731 | } |
1643 | } | 1732 | } |
@@ -1751,3 +1840,16 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver) | |||
1751 | return 0; | 1840 | return 0; |
1752 | } | 1841 | } |
1753 | EXPORT_SYMBOL_GPL(cpufreq_unregister_driver); | 1842 | EXPORT_SYMBOL_GPL(cpufreq_unregister_driver); |
1843 | |||
1844 | static int __init cpufreq_core_init(void) | ||
1845 | { | ||
1846 | int cpu; | ||
1847 | |||
1848 | for_each_possible_cpu(cpu) { | ||
1849 | per_cpu(policy_cpu, cpu) = -1; | ||
1850 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); | ||
1851 | } | ||
1852 | return 0; | ||
1853 | } | ||
1854 | |||
1855 | core_initcall(cpufreq_core_init); | ||
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 05d6c22ba07c..26f440ccc3fb 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -429,14 +429,12 @@ static void dbs_check_cpu(int cpu) | |||
429 | static void do_dbs_timer(struct work_struct *work) | 429 | static void do_dbs_timer(struct work_struct *work) |
430 | { | 430 | { |
431 | int i; | 431 | int i; |
432 | lock_cpu_hotplug(); | ||
433 | mutex_lock(&dbs_mutex); | 432 | mutex_lock(&dbs_mutex); |
434 | for_each_online_cpu(i) | 433 | for_each_online_cpu(i) |
435 | dbs_check_cpu(i); | 434 | dbs_check_cpu(i); |
436 | schedule_delayed_work(&dbs_work, | 435 | schedule_delayed_work(&dbs_work, |
437 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); | 436 | usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); |
438 | mutex_unlock(&dbs_mutex); | 437 | mutex_unlock(&dbs_mutex); |
439 | unlock_cpu_hotplug(); | ||
440 | } | 438 | } |
441 | 439 | ||
442 | static inline void dbs_timer_init(void) | 440 | static inline void dbs_timer_init(void) |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index f697449327c6..d60bcb9d14cc 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -52,19 +52,20 @@ static unsigned int def_sampling_rate; | |||
52 | static void do_dbs_timer(struct work_struct *work); | 52 | static void do_dbs_timer(struct work_struct *work); |
53 | 53 | ||
54 | /* Sampling types */ | 54 | /* Sampling types */ |
55 | enum dbs_sample {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE}; | 55 | enum {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE}; |
56 | 56 | ||
57 | struct cpu_dbs_info_s { | 57 | struct cpu_dbs_info_s { |
58 | cputime64_t prev_cpu_idle; | 58 | cputime64_t prev_cpu_idle; |
59 | cputime64_t prev_cpu_wall; | 59 | cputime64_t prev_cpu_wall; |
60 | struct cpufreq_policy *cur_policy; | 60 | struct cpufreq_policy *cur_policy; |
61 | struct delayed_work work; | 61 | struct delayed_work work; |
62 | enum dbs_sample sample_type; | ||
63 | unsigned int enable; | ||
64 | struct cpufreq_frequency_table *freq_table; | 62 | struct cpufreq_frequency_table *freq_table; |
65 | unsigned int freq_lo; | 63 | unsigned int freq_lo; |
66 | unsigned int freq_lo_jiffies; | 64 | unsigned int freq_lo_jiffies; |
67 | unsigned int freq_hi_jiffies; | 65 | unsigned int freq_hi_jiffies; |
66 | int cpu; | ||
67 | unsigned int enable:1, | ||
68 | sample_type:1; | ||
68 | }; | 69 | }; |
69 | static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); | 70 | static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info); |
70 | 71 | ||
@@ -402,7 +403,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
402 | if (load < (dbs_tuners_ins.up_threshold - 10)) { | 403 | if (load < (dbs_tuners_ins.up_threshold - 10)) { |
403 | unsigned int freq_next, freq_cur; | 404 | unsigned int freq_next, freq_cur; |
404 | 405 | ||
405 | freq_cur = cpufreq_driver_getavg(policy); | 406 | freq_cur = __cpufreq_driver_getavg(policy); |
406 | if (!freq_cur) | 407 | if (!freq_cur) |
407 | freq_cur = policy->cur; | 408 | freq_cur = policy->cur; |
408 | 409 | ||
@@ -423,9 +424,11 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
423 | 424 | ||
424 | static void do_dbs_timer(struct work_struct *work) | 425 | static void do_dbs_timer(struct work_struct *work) |
425 | { | 426 | { |
426 | unsigned int cpu = smp_processor_id(); | 427 | struct cpu_dbs_info_s *dbs_info = |
427 | struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu); | 428 | container_of(work, struct cpu_dbs_info_s, work.work); |
428 | enum dbs_sample sample_type = dbs_info->sample_type; | 429 | unsigned int cpu = dbs_info->cpu; |
430 | int sample_type = dbs_info->sample_type; | ||
431 | |||
429 | /* We want all CPUs to do sampling nearly on same jiffy */ | 432 | /* We want all CPUs to do sampling nearly on same jiffy */ |
430 | int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); | 433 | int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); |
431 | 434 | ||
@@ -434,15 +437,19 @@ static void do_dbs_timer(struct work_struct *work) | |||
434 | 437 | ||
435 | delay -= jiffies % delay; | 438 | delay -= jiffies % delay; |
436 | 439 | ||
437 | if (!dbs_info->enable) | 440 | if (lock_policy_rwsem_write(cpu) < 0) |
441 | return; | ||
442 | |||
443 | if (!dbs_info->enable) { | ||
444 | unlock_policy_rwsem_write(cpu); | ||
438 | return; | 445 | return; |
446 | } | ||
447 | |||
439 | /* Common NORMAL_SAMPLE setup */ | 448 | /* Common NORMAL_SAMPLE setup */ |
440 | dbs_info->sample_type = DBS_NORMAL_SAMPLE; | 449 | dbs_info->sample_type = DBS_NORMAL_SAMPLE; |
441 | if (!dbs_tuners_ins.powersave_bias || | 450 | if (!dbs_tuners_ins.powersave_bias || |
442 | sample_type == DBS_NORMAL_SAMPLE) { | 451 | sample_type == DBS_NORMAL_SAMPLE) { |
443 | lock_cpu_hotplug(); | ||
444 | dbs_check_cpu(dbs_info); | 452 | dbs_check_cpu(dbs_info); |
445 | unlock_cpu_hotplug(); | ||
446 | if (dbs_info->freq_lo) { | 453 | if (dbs_info->freq_lo) { |
447 | /* Setup timer for SUB_SAMPLE */ | 454 | /* Setup timer for SUB_SAMPLE */ |
448 | dbs_info->sample_type = DBS_SUB_SAMPLE; | 455 | dbs_info->sample_type = DBS_SUB_SAMPLE; |
@@ -454,26 +461,27 @@ static void do_dbs_timer(struct work_struct *work) | |||
454 | CPUFREQ_RELATION_H); | 461 | CPUFREQ_RELATION_H); |
455 | } | 462 | } |
456 | queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay); | 463 | queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay); |
464 | unlock_policy_rwsem_write(cpu); | ||
457 | } | 465 | } |
458 | 466 | ||
459 | static inline void dbs_timer_init(unsigned int cpu) | 467 | static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info) |
460 | { | 468 | { |
461 | struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu); | ||
462 | /* We want all CPUs to do sampling nearly on same jiffy */ | 469 | /* We want all CPUs to do sampling nearly on same jiffy */ |
463 | int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); | 470 | int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); |
464 | delay -= jiffies % delay; | 471 | delay -= jiffies % delay; |
465 | 472 | ||
473 | dbs_info->enable = 1; | ||
466 | ondemand_powersave_bias_init(); | 474 | ondemand_powersave_bias_init(); |
467 | INIT_DELAYED_WORK_NAR(&dbs_info->work, do_dbs_timer); | ||
468 | dbs_info->sample_type = DBS_NORMAL_SAMPLE; | 475 | dbs_info->sample_type = DBS_NORMAL_SAMPLE; |
469 | queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay); | 476 | INIT_DELAYED_WORK_NAR(&dbs_info->work, do_dbs_timer); |
477 | queue_delayed_work_on(dbs_info->cpu, kondemand_wq, &dbs_info->work, | ||
478 | delay); | ||
470 | } | 479 | } |
471 | 480 | ||
472 | static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info) | 481 | static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info) |
473 | { | 482 | { |
474 | dbs_info->enable = 0; | 483 | dbs_info->enable = 0; |
475 | cancel_delayed_work(&dbs_info->work); | 484 | cancel_delayed_work(&dbs_info->work); |
476 | flush_workqueue(kondemand_wq); | ||
477 | } | 485 | } |
478 | 486 | ||
479 | static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | 487 | static int cpufreq_governor_dbs(struct cpufreq_policy *policy, |
@@ -502,21 +510,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
502 | 510 | ||
503 | mutex_lock(&dbs_mutex); | 511 | mutex_lock(&dbs_mutex); |
504 | dbs_enable++; | 512 | dbs_enable++; |
505 | if (dbs_enable == 1) { | ||
506 | kondemand_wq = create_workqueue("kondemand"); | ||
507 | if (!kondemand_wq) { | ||
508 | printk(KERN_ERR | ||
509 | "Creation of kondemand failed\n"); | ||
510 | dbs_enable--; | ||
511 | mutex_unlock(&dbs_mutex); | ||
512 | return -ENOSPC; | ||
513 | } | ||
514 | } | ||
515 | 513 | ||
516 | rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); | 514 | rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); |
517 | if (rc) { | 515 | if (rc) { |
518 | if (dbs_enable == 1) | ||
519 | destroy_workqueue(kondemand_wq); | ||
520 | dbs_enable--; | 516 | dbs_enable--; |
521 | mutex_unlock(&dbs_mutex); | 517 | mutex_unlock(&dbs_mutex); |
522 | return rc; | 518 | return rc; |
@@ -530,7 +526,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
530 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j); | 526 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j); |
531 | j_dbs_info->prev_cpu_wall = get_jiffies_64(); | 527 | j_dbs_info->prev_cpu_wall = get_jiffies_64(); |
532 | } | 528 | } |
533 | this_dbs_info->enable = 1; | 529 | this_dbs_info->cpu = cpu; |
534 | /* | 530 | /* |
535 | * Start the timerschedule work, when this governor | 531 | * Start the timerschedule work, when this governor |
536 | * is used for first time | 532 | * is used for first time |
@@ -550,7 +546,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
550 | 546 | ||
551 | dbs_tuners_ins.sampling_rate = def_sampling_rate; | 547 | dbs_tuners_ins.sampling_rate = def_sampling_rate; |
552 | } | 548 | } |
553 | dbs_timer_init(policy->cpu); | 549 | dbs_timer_init(this_dbs_info); |
554 | 550 | ||
555 | mutex_unlock(&dbs_mutex); | 551 | mutex_unlock(&dbs_mutex); |
556 | break; | 552 | break; |
@@ -560,9 +556,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
560 | dbs_timer_exit(this_dbs_info); | 556 | dbs_timer_exit(this_dbs_info); |
561 | sysfs_remove_group(&policy->kobj, &dbs_attr_group); | 557 | sysfs_remove_group(&policy->kobj, &dbs_attr_group); |
562 | dbs_enable--; | 558 | dbs_enable--; |
563 | if (dbs_enable == 0) | ||
564 | destroy_workqueue(kondemand_wq); | ||
565 | |||
566 | mutex_unlock(&dbs_mutex); | 559 | mutex_unlock(&dbs_mutex); |
567 | 560 | ||
568 | break; | 561 | break; |
@@ -591,12 +584,18 @@ static struct cpufreq_governor cpufreq_gov_dbs = { | |||
591 | 584 | ||
592 | static int __init cpufreq_gov_dbs_init(void) | 585 | static int __init cpufreq_gov_dbs_init(void) |
593 | { | 586 | { |
587 | kondemand_wq = create_workqueue("kondemand"); | ||
588 | if (!kondemand_wq) { | ||
589 | printk(KERN_ERR "Creation of kondemand failed\n"); | ||
590 | return -EFAULT; | ||
591 | } | ||
594 | return cpufreq_register_governor(&cpufreq_gov_dbs); | 592 | return cpufreq_register_governor(&cpufreq_gov_dbs); |
595 | } | 593 | } |
596 | 594 | ||
597 | static void __exit cpufreq_gov_dbs_exit(void) | 595 | static void __exit cpufreq_gov_dbs_exit(void) |
598 | { | 596 | { |
599 | cpufreq_unregister_governor(&cpufreq_gov_dbs); | 597 | cpufreq_unregister_governor(&cpufreq_gov_dbs); |
598 | destroy_workqueue(kondemand_wq); | ||
600 | } | 599 | } |
601 | 600 | ||
602 | 601 | ||
@@ -608,3 +607,4 @@ MODULE_LICENSE("GPL"); | |||
608 | 607 | ||
609 | module_init(cpufreq_gov_dbs_init); | 608 | module_init(cpufreq_gov_dbs_init); |
610 | module_exit(cpufreq_gov_dbs_exit); | 609 | module_exit(cpufreq_gov_dbs_exit); |
610 | |||
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 91ad342a6051..d1c7cac9316c 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -370,12 +370,10 @@ __exit cpufreq_stats_exit(void) | |||
370 | cpufreq_unregister_notifier(¬ifier_trans_block, | 370 | cpufreq_unregister_notifier(¬ifier_trans_block, |
371 | CPUFREQ_TRANSITION_NOTIFIER); | 371 | CPUFREQ_TRANSITION_NOTIFIER); |
372 | unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier); | 372 | unregister_hotcpu_notifier(&cpufreq_stat_cpu_notifier); |
373 | lock_cpu_hotplug(); | ||
374 | for_each_online_cpu(cpu) { | 373 | for_each_online_cpu(cpu) { |
375 | cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, | 374 | cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, |
376 | CPU_DEAD, (void *)(long)cpu); | 375 | CPU_DEAD, (void *)(long)cpu); |
377 | } | 376 | } |
378 | unlock_cpu_hotplug(); | ||
379 | } | 377 | } |
380 | 378 | ||
381 | MODULE_AUTHOR ("Zou Nan hai <nanhai.zou@intel.com>"); | 379 | MODULE_AUTHOR ("Zou Nan hai <nanhai.zou@intel.com>"); |
diff --git a/drivers/cpufreq/cpufreq_userspace.c b/drivers/cpufreq/cpufreq_userspace.c index 2a4eb0bfaf30..860345c7799a 100644 --- a/drivers/cpufreq/cpufreq_userspace.c +++ b/drivers/cpufreq/cpufreq_userspace.c | |||
@@ -71,7 +71,6 @@ static int cpufreq_set(unsigned int freq, struct cpufreq_policy *policy) | |||
71 | 71 | ||
72 | dprintk("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq); | 72 | dprintk("cpufreq_set for cpu %u, freq %u kHz\n", policy->cpu, freq); |
73 | 73 | ||
74 | lock_cpu_hotplug(); | ||
75 | mutex_lock(&userspace_mutex); | 74 | mutex_lock(&userspace_mutex); |
76 | if (!cpu_is_managed[policy->cpu]) | 75 | if (!cpu_is_managed[policy->cpu]) |
77 | goto err; | 76 | goto err; |
@@ -94,7 +93,6 @@ static int cpufreq_set(unsigned int freq, struct cpufreq_policy *policy) | |||
94 | 93 | ||
95 | err: | 94 | err: |
96 | mutex_unlock(&userspace_mutex); | 95 | mutex_unlock(&userspace_mutex); |
97 | unlock_cpu_hotplug(); | ||
98 | return ret; | 96 | return ret; |
99 | } | 97 | } |
100 | 98 | ||
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index cd251efda410..0a26e0663542 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -546,7 +546,7 @@ static void ads7846_rx(void *ads) | |||
546 | ts->spi->dev.bus_id, ts->tc.ignore, Rt); | 546 | ts->spi->dev.bus_id, ts->tc.ignore, Rt); |
547 | #endif | 547 | #endif |
548 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), | 548 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), |
549 | HRTIMER_REL); | 549 | HRTIMER_MODE_REL); |
550 | return; | 550 | return; |
551 | } | 551 | } |
552 | 552 | ||
@@ -578,7 +578,8 @@ static void ads7846_rx(void *ads) | |||
578 | #endif | 578 | #endif |
579 | } | 579 | } |
580 | 580 | ||
581 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), HRTIMER_REL); | 581 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_PERIOD), |
582 | HRTIMER_MODE_REL); | ||
582 | } | 583 | } |
583 | 584 | ||
584 | static int ads7846_debounce(void *ads, int data_idx, int *val) | 585 | static int ads7846_debounce(void *ads, int data_idx, int *val) |
@@ -667,7 +668,7 @@ static void ads7846_rx_val(void *ads) | |||
667 | status); | 668 | status); |
668 | } | 669 | } |
669 | 670 | ||
670 | static int ads7846_timer(struct hrtimer *handle) | 671 | static enum hrtimer_restart ads7846_timer(struct hrtimer *handle) |
671 | { | 672 | { |
672 | struct ads7846 *ts = container_of(handle, struct ads7846, timer); | 673 | struct ads7846 *ts = container_of(handle, struct ads7846, timer); |
673 | int status = 0; | 674 | int status = 0; |
@@ -724,7 +725,7 @@ static irqreturn_t ads7846_irq(int irq, void *handle) | |||
724 | disable_irq(ts->spi->irq); | 725 | disable_irq(ts->spi->irq); |
725 | ts->pending = 1; | 726 | ts->pending = 1; |
726 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_DELAY), | 727 | hrtimer_start(&ts->timer, ktime_set(0, TS_POLL_DELAY), |
727 | HRTIMER_REL); | 728 | HRTIMER_MODE_REL); |
728 | } | 729 | } |
729 | } | 730 | } |
730 | spin_unlock_irqrestore(&ts->lock, flags); | 731 | spin_unlock_irqrestore(&ts->lock, flags); |
@@ -862,7 +863,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
862 | ts->spi = spi; | 863 | ts->spi = spi; |
863 | ts->input = input_dev; | 864 | ts->input = input_dev; |
864 | 865 | ||
865 | hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_REL); | 866 | hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
866 | ts->timer.function = ads7846_timer; | 867 | ts->timer.function = ads7846_timer; |
867 | 868 | ||
868 | spin_lock_init(&ts->lock); | 869 | spin_lock_init(&ts->lock); |
diff --git a/drivers/isdn/gigaset/Makefile b/drivers/isdn/gigaset/Makefile index 835b806a9de7..077e297d8c72 100644 --- a/drivers/isdn/gigaset/Makefile +++ b/drivers/isdn/gigaset/Makefile | |||
@@ -5,4 +5,4 @@ ser_gigaset-y := ser-gigaset.o asyncdata.o | |||
5 | 5 | ||
6 | obj-$(CONFIG_GIGASET_M105) += usb_gigaset.o gigaset.o | 6 | obj-$(CONFIG_GIGASET_M105) += usb_gigaset.o gigaset.o |
7 | obj-$(CONFIG_GIGASET_BASE) += bas_gigaset.o gigaset.o | 7 | obj-$(CONFIG_GIGASET_BASE) += bas_gigaset.o gigaset.o |
8 | obj-$(CONFIG_GIGASET_M105) += ser_gigaset.o gigaset.o | 8 | obj-$(CONFIG_GIGASET_M101) += ser_gigaset.o gigaset.o |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index bedae4ad3f74..80b199fa0aa9 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -107,4 +107,19 @@ config MSI_LAPTOP | |||
107 | 107 | ||
108 | If you have an MSI S270 laptop, say Y or M here. | 108 | If you have an MSI S270 laptop, say Y or M here. |
109 | 109 | ||
110 | config SONY_LAPTOP | ||
111 | tristate "Sony Laptop Extras" | ||
112 | depends on X86 && ACPI | ||
113 | select BACKLIGHT_CLASS_DEVICE | ||
114 | ---help--- | ||
115 | This mini-driver drives the SNC device present in the ACPI BIOS of | ||
116 | the Sony Vaio laptops. | ||
117 | |||
118 | It gives access to some extra laptop functionalities. In its current | ||
119 | form, this driver let the user set or query the screen brightness | ||
120 | through the backlight subsystem and remove/apply power to some | ||
121 | devices. | ||
122 | |||
123 | Read <file:Documentation/sony-laptop.txt> for more information. | ||
124 | |||
110 | endmenu | 125 | endmenu |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 35da53c409c0..7793ccd79049 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
@@ -11,3 +11,4 @@ obj-$(CONFIG_LKDTM) += lkdtm.o | |||
11 | obj-$(CONFIG_TIFM_CORE) += tifm_core.o | 11 | obj-$(CONFIG_TIFM_CORE) += tifm_core.o |
12 | obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o | 12 | obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o |
13 | obj-$(CONFIG_SGI_IOC4) += ioc4.o | 13 | obj-$(CONFIG_SGI_IOC4) += ioc4.o |
14 | obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o | ||
diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c index 861c39935f99..e4e2b707a353 100644 --- a/drivers/misc/asus-laptop.c +++ b/drivers/misc/asus-laptop.c | |||
@@ -1088,11 +1088,6 @@ static int __init asus_laptop_init(void) | |||
1088 | if (acpi_disabled) | 1088 | if (acpi_disabled) |
1089 | return -ENODEV; | 1089 | return -ENODEV; |
1090 | 1090 | ||
1091 | if (!acpi_specific_hotkey_enabled) { | ||
1092 | printk(ASUS_ERR "Using generic hotkey driver\n"); | ||
1093 | return -ENODEV; | ||
1094 | } | ||
1095 | |||
1096 | result = acpi_bus_register_driver(&asus_hotk_driver); | 1091 | result = acpi_bus_register_driver(&asus_hotk_driver); |
1097 | if (result < 0) | 1092 | if (result < 0) |
1098 | return result; | 1093 | return result; |
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c new file mode 100644 index 000000000000..cabbed0015e4 --- /dev/null +++ b/drivers/misc/sony-laptop.c | |||
@@ -0,0 +1,562 @@ | |||
1 | /* | ||
2 | * ACPI Sony Notebook Control Driver (SNC) | ||
3 | * | ||
4 | * Copyright (C) 2004-2005 Stelian Pop <stelian@popies.net> | ||
5 | * Copyright (C) 2007 Mattia Dongili <malattia@linux.it> | ||
6 | * | ||
7 | * Parts of this driver inspired from asus_acpi.c and ibm_acpi.c | ||
8 | * which are copyrighted by their respective authors. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more 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 | */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/module.h> | ||
28 | #include <linux/moduleparam.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/types.h> | ||
31 | #include <linux/backlight.h> | ||
32 | #include <linux/platform_device.h> | ||
33 | #include <linux/err.h> | ||
34 | #include <acpi/acpi_drivers.h> | ||
35 | #include <acpi/acpi_bus.h> | ||
36 | #include <asm/uaccess.h> | ||
37 | |||
38 | #define ACPI_SNC_CLASS "sony" | ||
39 | #define ACPI_SNC_HID "SNY5001" | ||
40 | #define ACPI_SNC_DRIVER_NAME "ACPI Sony Notebook Control Driver v0.4" | ||
41 | |||
42 | /* the device uses 1-based values, while the backlight subsystem uses | ||
43 | 0-based values */ | ||
44 | #define SONY_MAX_BRIGHTNESS 8 | ||
45 | |||
46 | #define LOG_PFX KERN_WARNING "sony-laptop: " | ||
47 | |||
48 | MODULE_AUTHOR("Stelian Pop, Mattia Dongili"); | ||
49 | MODULE_DESCRIPTION(ACPI_SNC_DRIVER_NAME); | ||
50 | MODULE_LICENSE("GPL"); | ||
51 | |||
52 | static int debug; | ||
53 | module_param(debug, int, 0); | ||
54 | MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help " | ||
55 | "the development of this driver"); | ||
56 | |||
57 | static ssize_t sony_acpi_show(struct device *, struct device_attribute *, | ||
58 | char *); | ||
59 | static ssize_t sony_acpi_store(struct device *, struct device_attribute *, | ||
60 | const char *, size_t); | ||
61 | static int boolean_validate(const int, const int); | ||
62 | static int brightness_default_validate(const int, const int); | ||
63 | |||
64 | #define SNC_VALIDATE_IN 0 | ||
65 | #define SNC_VALIDATE_OUT 1 | ||
66 | |||
67 | struct sony_acpi_value { | ||
68 | char *name; /* name of the entry */ | ||
69 | char **acpiget; /* names of the ACPI get function */ | ||
70 | char **acpiset; /* names of the ACPI set function */ | ||
71 | int (*validate)(const int, const int); /* input/output validation */ | ||
72 | int value; /* current setting */ | ||
73 | int valid; /* Has ever been set */ | ||
74 | int debug; /* active only in debug mode ? */ | ||
75 | struct device_attribute devattr; /* sysfs atribute */ | ||
76 | }; | ||
77 | |||
78 | #define HANDLE_NAMES(_name, _values...) \ | ||
79 | static char *snc_##_name[] = { _values, NULL } | ||
80 | |||
81 | #define SONY_ACPI_VALUE(_name, _getters, _setters, _validate, _debug) \ | ||
82 | { \ | ||
83 | .name = __stringify(_name), \ | ||
84 | .acpiget = _getters, \ | ||
85 | .acpiset = _setters, \ | ||
86 | .validate = _validate, \ | ||
87 | .debug = _debug, \ | ||
88 | .devattr = __ATTR(_name, 0, sony_acpi_show, sony_acpi_store), \ | ||
89 | } | ||
90 | |||
91 | #define SONY_ACPI_VALUE_NULL { .name = NULL } | ||
92 | |||
93 | HANDLE_NAMES(fnkey_get, "GHKE"); | ||
94 | |||
95 | HANDLE_NAMES(brightness_def_get, "GPBR"); | ||
96 | HANDLE_NAMES(brightness_def_set, "SPBR"); | ||
97 | |||
98 | HANDLE_NAMES(cdpower_get, "GCDP"); | ||
99 | HANDLE_NAMES(cdpower_set, "SCDP", "CDPW"); | ||
100 | |||
101 | HANDLE_NAMES(audiopower_get, "GAZP"); | ||
102 | HANDLE_NAMES(audiopower_set, "AZPW"); | ||
103 | |||
104 | HANDLE_NAMES(lanpower_get, "GLNP"); | ||
105 | HANDLE_NAMES(lanpower_set, "LNPW"); | ||
106 | |||
107 | HANDLE_NAMES(PID_get, "GPID"); | ||
108 | |||
109 | HANDLE_NAMES(CTR_get, "GCTR"); | ||
110 | HANDLE_NAMES(CTR_set, "SCTR"); | ||
111 | |||
112 | HANDLE_NAMES(PCR_get, "GPCR"); | ||
113 | HANDLE_NAMES(PCR_set, "SPCR"); | ||
114 | |||
115 | HANDLE_NAMES(CMI_get, "GCMI"); | ||
116 | HANDLE_NAMES(CMI_set, "SCMI"); | ||
117 | |||
118 | static struct sony_acpi_value sony_acpi_values[] = { | ||
119 | SONY_ACPI_VALUE(brightness_default, snc_brightness_def_get, | ||
120 | snc_brightness_def_set, brightness_default_validate, 0), | ||
121 | SONY_ACPI_VALUE(fnkey, snc_fnkey_get, NULL, NULL, 0), | ||
122 | SONY_ACPI_VALUE(cdpower, snc_cdpower_get, snc_cdpower_set, boolean_validate, 0), | ||
123 | SONY_ACPI_VALUE(audiopower, snc_audiopower_get, snc_audiopower_set, | ||
124 | boolean_validate, 0), | ||
125 | SONY_ACPI_VALUE(lanpower, snc_lanpower_get, snc_lanpower_set, | ||
126 | boolean_validate, 1), | ||
127 | /* unknown methods */ | ||
128 | SONY_ACPI_VALUE(PID, snc_PID_get, NULL, NULL, 1), | ||
129 | SONY_ACPI_VALUE(CTR, snc_CTR_get, snc_CTR_set, NULL, 1), | ||
130 | SONY_ACPI_VALUE(PCR, snc_PCR_get, snc_PCR_set, NULL, 1), | ||
131 | SONY_ACPI_VALUE(CMI, snc_CMI_get, snc_CMI_set, NULL, 1), | ||
132 | SONY_ACPI_VALUE_NULL | ||
133 | }; | ||
134 | |||
135 | static acpi_handle sony_acpi_handle; | ||
136 | static struct acpi_device *sony_acpi_acpi_device = NULL; | ||
137 | |||
138 | /* | ||
139 | * acpi_evaluate_object wrappers | ||
140 | */ | ||
141 | static int acpi_callgetfunc(acpi_handle handle, char *name, int *result) | ||
142 | { | ||
143 | struct acpi_buffer output; | ||
144 | union acpi_object out_obj; | ||
145 | acpi_status status; | ||
146 | |||
147 | output.length = sizeof(out_obj); | ||
148 | output.pointer = &out_obj; | ||
149 | |||
150 | status = acpi_evaluate_object(handle, name, NULL, &output); | ||
151 | if ((status == AE_OK) && (out_obj.type == ACPI_TYPE_INTEGER)) { | ||
152 | *result = out_obj.integer.value; | ||
153 | return 0; | ||
154 | } | ||
155 | |||
156 | printk(LOG_PFX "acpi_callreadfunc failed\n"); | ||
157 | |||
158 | return -1; | ||
159 | } | ||
160 | |||
161 | static int acpi_callsetfunc(acpi_handle handle, char *name, int value, | ||
162 | int *result) | ||
163 | { | ||
164 | struct acpi_object_list params; | ||
165 | union acpi_object in_obj; | ||
166 | struct acpi_buffer output; | ||
167 | union acpi_object out_obj; | ||
168 | acpi_status status; | ||
169 | |||
170 | params.count = 1; | ||
171 | params.pointer = &in_obj; | ||
172 | in_obj.type = ACPI_TYPE_INTEGER; | ||
173 | in_obj.integer.value = value; | ||
174 | |||
175 | output.length = sizeof(out_obj); | ||
176 | output.pointer = &out_obj; | ||
177 | |||
178 | status = acpi_evaluate_object(handle, name, ¶ms, &output); | ||
179 | if (status == AE_OK) { | ||
180 | if (result != NULL) { | ||
181 | if (out_obj.type != ACPI_TYPE_INTEGER) { | ||
182 | printk(LOG_PFX "acpi_evaluate_object bad " | ||
183 | "return type\n"); | ||
184 | return -1; | ||
185 | } | ||
186 | *result = out_obj.integer.value; | ||
187 | } | ||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | printk(LOG_PFX "acpi_evaluate_object failed\n"); | ||
192 | |||
193 | return -1; | ||
194 | } | ||
195 | |||
196 | /* | ||
197 | * sony_acpi_values input/output validate functions | ||
198 | */ | ||
199 | |||
200 | /* brightness_default_validate: | ||
201 | * | ||
202 | * manipulate input output values to keep consistency with the | ||
203 | * backlight framework for which brightness values are 0-based. | ||
204 | */ | ||
205 | static int brightness_default_validate(const int direction, const int value) | ||
206 | { | ||
207 | switch (direction) { | ||
208 | case SNC_VALIDATE_OUT: | ||
209 | return value - 1; | ||
210 | case SNC_VALIDATE_IN: | ||
211 | if (value >= 0 && value < SONY_MAX_BRIGHTNESS) | ||
212 | return value + 1; | ||
213 | } | ||
214 | return -EINVAL; | ||
215 | } | ||
216 | |||
217 | /* boolean_validate: | ||
218 | * | ||
219 | * on input validate boolean values 0/1, on output just pass the | ||
220 | * received value. | ||
221 | */ | ||
222 | static int boolean_validate(const int direction, const int value) | ||
223 | { | ||
224 | if (direction == SNC_VALIDATE_IN) { | ||
225 | if (value != 0 && value != 1) | ||
226 | return -EINVAL; | ||
227 | } | ||
228 | return value; | ||
229 | } | ||
230 | |||
231 | /* | ||
232 | * Sysfs show/store common to all sony_acpi_values | ||
233 | */ | ||
234 | static ssize_t sony_acpi_show(struct device *dev, struct device_attribute *attr, | ||
235 | char *buffer) | ||
236 | { | ||
237 | int value; | ||
238 | struct sony_acpi_value *item = | ||
239 | container_of(attr, struct sony_acpi_value, devattr); | ||
240 | |||
241 | if (!*item->acpiget) | ||
242 | return -EIO; | ||
243 | |||
244 | if (acpi_callgetfunc(sony_acpi_handle, *item->acpiget, &value) < 0) | ||
245 | return -EIO; | ||
246 | |||
247 | if (item->validate) | ||
248 | value = item->validate(SNC_VALIDATE_OUT, value); | ||
249 | |||
250 | return snprintf(buffer, PAGE_SIZE, "%d\n", value); | ||
251 | } | ||
252 | |||
253 | static ssize_t sony_acpi_store(struct device *dev, | ||
254 | struct device_attribute *attr, | ||
255 | const char *buffer, size_t count) | ||
256 | { | ||
257 | int value; | ||
258 | struct sony_acpi_value *item = | ||
259 | container_of(attr, struct sony_acpi_value, devattr); | ||
260 | |||
261 | if (!item->acpiset) | ||
262 | return -EIO; | ||
263 | |||
264 | if (count > 31) | ||
265 | return -EINVAL; | ||
266 | |||
267 | value = simple_strtoul(buffer, NULL, 10); | ||
268 | |||
269 | if (item->validate) | ||
270 | value = item->validate(SNC_VALIDATE_IN, value); | ||
271 | |||
272 | if (value < 0) | ||
273 | return value; | ||
274 | |||
275 | if (acpi_callsetfunc(sony_acpi_handle, *item->acpiset, value, NULL) < 0) | ||
276 | return -EIO; | ||
277 | item->value = value; | ||
278 | item->valid = 1; | ||
279 | return count; | ||
280 | } | ||
281 | |||
282 | /* | ||
283 | * Platform device | ||
284 | */ | ||
285 | static struct platform_driver sncpf_driver = { | ||
286 | .driver = { | ||
287 | .name = "sony-laptop", | ||
288 | .owner = THIS_MODULE, | ||
289 | } | ||
290 | }; | ||
291 | static struct platform_device *sncpf_device; | ||
292 | |||
293 | static int sony_snc_pf_add(void) | ||
294 | { | ||
295 | acpi_handle handle; | ||
296 | struct sony_acpi_value *item; | ||
297 | int ret = 0; | ||
298 | |||
299 | ret = platform_driver_register(&sncpf_driver); | ||
300 | if (ret) | ||
301 | goto out; | ||
302 | |||
303 | sncpf_device = platform_device_alloc("sony-laptop", -1); | ||
304 | if (!sncpf_device) { | ||
305 | ret = -ENOMEM; | ||
306 | goto out_platform_registered; | ||
307 | } | ||
308 | |||
309 | ret = platform_device_add(sncpf_device); | ||
310 | if (ret) | ||
311 | goto out_platform_alloced; | ||
312 | |||
313 | for (item = sony_acpi_values; item->name; ++item) { | ||
314 | |||
315 | if (!debug && item->debug) | ||
316 | continue; | ||
317 | |||
318 | /* find the available acpiget as described in the DSDT */ | ||
319 | for (; item->acpiget && *item->acpiget; ++item->acpiget) { | ||
320 | if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, | ||
321 | *item->acpiget, | ||
322 | &handle))) { | ||
323 | if (debug) | ||
324 | printk(LOG_PFX "Found %s getter: %s\n", | ||
325 | item->name, *item->acpiget); | ||
326 | item->devattr.attr.mode |= S_IRUGO; | ||
327 | break; | ||
328 | } | ||
329 | } | ||
330 | |||
331 | /* find the available acpiset as described in the DSDT */ | ||
332 | for (; item->acpiset && *item->acpiset; ++item->acpiset) { | ||
333 | if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, | ||
334 | *item->acpiset, | ||
335 | &handle))) { | ||
336 | if (debug) | ||
337 | printk(LOG_PFX "Found %s setter: %s\n", | ||
338 | item->name, *item->acpiset); | ||
339 | item->devattr.attr.mode |= S_IWUSR; | ||
340 | break; | ||
341 | } | ||
342 | } | ||
343 | |||
344 | if (item->devattr.attr.mode != 0) { | ||
345 | ret = | ||
346 | device_create_file(&sncpf_device->dev, | ||
347 | &item->devattr); | ||
348 | if (ret) | ||
349 | goto out_sysfs; | ||
350 | } | ||
351 | } | ||
352 | |||
353 | return 0; | ||
354 | |||
355 | out_sysfs: | ||
356 | for (item = sony_acpi_values; item->name; ++item) { | ||
357 | device_remove_file(&sncpf_device->dev, &item->devattr); | ||
358 | } | ||
359 | platform_device_del(sncpf_device); | ||
360 | out_platform_alloced: | ||
361 | platform_device_put(sncpf_device); | ||
362 | out_platform_registered: | ||
363 | platform_driver_unregister(&sncpf_driver); | ||
364 | out: | ||
365 | return ret; | ||
366 | } | ||
367 | |||
368 | static void sony_snc_pf_remove(void) | ||
369 | { | ||
370 | struct sony_acpi_value *item; | ||
371 | |||
372 | for (item = sony_acpi_values; item->name; ++item) { | ||
373 | device_remove_file(&sncpf_device->dev, &item->devattr); | ||
374 | } | ||
375 | |||
376 | platform_device_del(sncpf_device); | ||
377 | platform_device_put(sncpf_device); | ||
378 | platform_driver_unregister(&sncpf_driver); | ||
379 | } | ||
380 | |||
381 | /* | ||
382 | * Backlight device | ||
383 | */ | ||
384 | static int sony_backlight_update_status(struct backlight_device *bd) | ||
385 | { | ||
386 | return acpi_callsetfunc(sony_acpi_handle, "SBRT", | ||
387 | bd->props->brightness + 1, NULL); | ||
388 | } | ||
389 | |||
390 | static int sony_backlight_get_brightness(struct backlight_device *bd) | ||
391 | { | ||
392 | int value; | ||
393 | |||
394 | if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value)) | ||
395 | return 0; | ||
396 | /* brightness levels are 1-based, while backlight ones are 0-based */ | ||
397 | return value - 1; | ||
398 | } | ||
399 | |||
400 | static struct backlight_device *sony_backlight_device; | ||
401 | static struct backlight_properties sony_backlight_properties = { | ||
402 | .owner = THIS_MODULE, | ||
403 | .update_status = sony_backlight_update_status, | ||
404 | .get_brightness = sony_backlight_get_brightness, | ||
405 | .max_brightness = SONY_MAX_BRIGHTNESS - 1, | ||
406 | }; | ||
407 | |||
408 | /* | ||
409 | * ACPI callbacks | ||
410 | */ | ||
411 | static void sony_acpi_notify(acpi_handle handle, u32 event, void *data) | ||
412 | { | ||
413 | if (debug) | ||
414 | printk(LOG_PFX "sony_acpi_notify, event: %d\n", event); | ||
415 | acpi_bus_generate_event(sony_acpi_acpi_device, 1, event); | ||
416 | } | ||
417 | |||
418 | static acpi_status sony_walk_callback(acpi_handle handle, u32 level, | ||
419 | void *context, void **return_value) | ||
420 | { | ||
421 | struct acpi_namespace_node *node; | ||
422 | union acpi_operand_object *operand; | ||
423 | |||
424 | node = (struct acpi_namespace_node *)handle; | ||
425 | operand = (union acpi_operand_object *)node->object; | ||
426 | |||
427 | printk(LOG_PFX "method: name: %4.4s, args %X\n", node->name.ascii, | ||
428 | (u32) operand->method.param_count); | ||
429 | |||
430 | return AE_OK; | ||
431 | } | ||
432 | |||
433 | /* | ||
434 | * ACPI device | ||
435 | */ | ||
436 | static int sony_acpi_resume(struct acpi_device *device) | ||
437 | { | ||
438 | struct sony_acpi_value *item; | ||
439 | |||
440 | for (item = sony_acpi_values; item->name; item++) { | ||
441 | int ret; | ||
442 | |||
443 | if (!item->valid) | ||
444 | continue; | ||
445 | ret = acpi_callsetfunc(sony_acpi_handle, *item->acpiset, | ||
446 | item->value, NULL); | ||
447 | if (ret < 0) { | ||
448 | printk("%s: %d\n", __FUNCTION__, ret); | ||
449 | break; | ||
450 | } | ||
451 | } | ||
452 | return 0; | ||
453 | } | ||
454 | |||
455 | static int sony_acpi_add(struct acpi_device *device) | ||
456 | { | ||
457 | acpi_status status; | ||
458 | int result; | ||
459 | acpi_handle handle; | ||
460 | |||
461 | sony_acpi_acpi_device = device; | ||
462 | |||
463 | sony_acpi_handle = device->handle; | ||
464 | |||
465 | if (debug) { | ||
466 | status = acpi_walk_namespace(ACPI_TYPE_METHOD, sony_acpi_handle, | ||
467 | 1, sony_walk_callback, NULL, NULL); | ||
468 | if (ACPI_FAILURE(status)) { | ||
469 | printk(LOG_PFX "unable to walk acpi resources\n"); | ||
470 | result = -ENODEV; | ||
471 | goto outwalk; | ||
472 | } | ||
473 | } | ||
474 | |||
475 | status = acpi_install_notify_handler(sony_acpi_handle, | ||
476 | ACPI_DEVICE_NOTIFY, | ||
477 | sony_acpi_notify, NULL); | ||
478 | if (ACPI_FAILURE(status)) { | ||
479 | printk(LOG_PFX "unable to install notify handler\n"); | ||
480 | result = -ENODEV; | ||
481 | goto outwalk; | ||
482 | } | ||
483 | |||
484 | if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) { | ||
485 | sony_backlight_device = backlight_device_register("sony", NULL, | ||
486 | NULL, | ||
487 | &sony_backlight_properties); | ||
488 | |||
489 | if (IS_ERR(sony_backlight_device)) { | ||
490 | printk(LOG_PFX "unable to register backlight device\n"); | ||
491 | sony_backlight_device = NULL; | ||
492 | } else | ||
493 | sony_backlight_properties.brightness = | ||
494 | sony_backlight_get_brightness | ||
495 | (sony_backlight_device); | ||
496 | } | ||
497 | |||
498 | if (sony_snc_pf_add()) | ||
499 | goto outbacklight; | ||
500 | |||
501 | printk(KERN_INFO ACPI_SNC_DRIVER_NAME " successfully installed\n"); | ||
502 | |||
503 | return 0; | ||
504 | |||
505 | outbacklight: | ||
506 | if (sony_backlight_device) | ||
507 | backlight_device_unregister(sony_backlight_device); | ||
508 | |||
509 | status = acpi_remove_notify_handler(sony_acpi_handle, | ||
510 | ACPI_DEVICE_NOTIFY, | ||
511 | sony_acpi_notify); | ||
512 | if (ACPI_FAILURE(status)) | ||
513 | printk(LOG_PFX "unable to remove notify handler\n"); | ||
514 | outwalk: | ||
515 | return result; | ||
516 | } | ||
517 | |||
518 | static int sony_acpi_remove(struct acpi_device *device, int type) | ||
519 | { | ||
520 | acpi_status status; | ||
521 | |||
522 | if (sony_backlight_device) | ||
523 | backlight_device_unregister(sony_backlight_device); | ||
524 | |||
525 | sony_acpi_acpi_device = NULL; | ||
526 | |||
527 | status = acpi_remove_notify_handler(sony_acpi_handle, | ||
528 | ACPI_DEVICE_NOTIFY, | ||
529 | sony_acpi_notify); | ||
530 | if (ACPI_FAILURE(status)) | ||
531 | printk(LOG_PFX "unable to remove notify handler\n"); | ||
532 | |||
533 | sony_snc_pf_remove(); | ||
534 | |||
535 | printk(KERN_INFO ACPI_SNC_DRIVER_NAME " successfully removed\n"); | ||
536 | |||
537 | return 0; | ||
538 | } | ||
539 | |||
540 | static struct acpi_driver sony_acpi_driver = { | ||
541 | .name = ACPI_SNC_DRIVER_NAME, | ||
542 | .class = ACPI_SNC_CLASS, | ||
543 | .ids = ACPI_SNC_HID, | ||
544 | .ops = { | ||
545 | .add = sony_acpi_add, | ||
546 | .remove = sony_acpi_remove, | ||
547 | .resume = sony_acpi_resume, | ||
548 | }, | ||
549 | }; | ||
550 | |||
551 | static int __init sony_acpi_init(void) | ||
552 | { | ||
553 | return acpi_bus_register_driver(&sony_acpi_driver); | ||
554 | } | ||
555 | |||
556 | static void __exit sony_acpi_exit(void) | ||
557 | { | ||
558 | acpi_bus_unregister_driver(&sony_acpi_driver); | ||
559 | } | ||
560 | |||
561 | module_init(sony_acpi_init); | ||
562 | module_exit(sony_acpi_exit); | ||
diff --git a/drivers/pnp/pnpacpi/Kconfig b/drivers/pnp/pnpacpi/Kconfig index ad27e5e0101f..b04767ce273e 100644 --- a/drivers/pnp/pnpacpi/Kconfig +++ b/drivers/pnp/pnpacpi/Kconfig | |||
@@ -2,17 +2,5 @@ | |||
2 | # Plug and Play ACPI configuration | 2 | # Plug and Play ACPI configuration |
3 | # | 3 | # |
4 | config PNPACPI | 4 | config PNPACPI |
5 | bool "Plug and Play ACPI support" | 5 | bool |
6 | depends on PNP && ACPI | 6 | default (PNP && ACPI) |
7 | default y | ||
8 | ---help--- | ||
9 | Linux uses the PNPACPI to autodetect built-in | ||
10 | mainboard resources (e.g. parallel port resources). | ||
11 | |||
12 | Some features (e.g. real hotplug) are not currently | ||
13 | implemented. | ||
14 | |||
15 | If you would like the kernel to detect and allocate resources to | ||
16 | your mainboard devices (on some systems they are disabled by the | ||
17 | BIOS) say Y here. Also the PNPACPI can help prevent resource | ||
18 | conflicts between mainboard devices and other bus devices. | ||
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index 32f0e3a5b022..e573c8ba9785 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c | |||
@@ -281,8 +281,8 @@ static int appledisplay_probe(struct usb_interface *iface, | |||
281 | /* Register backlight device */ | 281 | /* Register backlight device */ |
282 | snprintf(bl_name, sizeof(bl_name), "appledisplay%d", | 282 | snprintf(bl_name, sizeof(bl_name), "appledisplay%d", |
283 | atomic_inc_return(&count_displays) - 1); | 283 | atomic_inc_return(&count_displays) - 1); |
284 | pdata->bd = backlight_device_register(bl_name, NULL, | 284 | pdata->bd = backlight_device_register(bl_name, NULL, pdata, |
285 | pdata, &appledisplay_bl_data); | 285 | &appledisplay_bl_data); |
286 | if (IS_ERR(pdata->bd)) { | 286 | if (IS_ERR(pdata->bd)) { |
287 | err("appledisplay: Backlight registration failed"); | 287 | err("appledisplay: Backlight registration failed"); |
288 | goto error; | 288 | goto error; |
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c index ccef56d0c157..ed3426062a8b 100644 --- a/drivers/video/s3c2410fb.c +++ b/drivers/video/s3c2410fb.c | |||
@@ -791,6 +791,8 @@ static int __init s3c2410fb_probe(struct platform_device *pdev) | |||
791 | 791 | ||
792 | info = fbinfo->par; | 792 | info = fbinfo->par; |
793 | info->fb = fbinfo; | 793 | info->fb = fbinfo; |
794 | info->dev = &pdev->dev; | ||
795 | |||
794 | platform_set_drvdata(pdev, fbinfo); | 796 | platform_set_drvdata(pdev, fbinfo); |
795 | 797 | ||
796 | dprintk("devinit\n"); | 798 | dprintk("devinit\n"); |