aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/accessibility/braille/braille_console.c13
-rw-r--r--drivers/acpi/acpi_memhotplug.c4
-rw-r--r--drivers/acpi/asus_acpi.c221
-rw-r--r--drivers/acpi/bus.c53
-rw-r--r--drivers/acpi/cm_sbs.c8
-rw-r--r--drivers/acpi/debug.c2
-rw-r--r--drivers/acpi/dispatcher/dsmethod.c3
-rw-r--r--drivers/acpi/dispatcher/dsmthdat.c83
-rw-r--r--drivers/acpi/dispatcher/dsobject.c62
-rw-r--r--drivers/acpi/dispatcher/dsopcode.c2
-rw-r--r--drivers/acpi/dispatcher/dswexec.c12
-rw-r--r--drivers/acpi/ec.c15
-rw-r--r--drivers/acpi/executer/exconfig.c123
-rw-r--r--drivers/acpi/executer/exconvrt.c32
-rw-r--r--drivers/acpi/executer/exdump.c87
-rw-r--r--drivers/acpi/executer/exmisc.c14
-rw-r--r--drivers/acpi/executer/exoparg1.c26
-rw-r--r--drivers/acpi/executer/exoparg2.c4
-rw-r--r--drivers/acpi/executer/exresnte.c16
-rw-r--r--drivers/acpi/executer/exresolv.c60
-rw-r--r--drivers/acpi/executer/exresop.c50
-rw-r--r--drivers/acpi/executer/exstore.c61
-rw-r--r--drivers/acpi/executer/exstoren.c3
-rw-r--r--drivers/acpi/fan.c4
-rw-r--r--drivers/acpi/glue.c5
-rw-r--r--drivers/acpi/namespace/Makefile2
-rw-r--r--drivers/acpi/namespace/nsdump.c5
-rw-r--r--drivers/acpi/namespace/nseval.c73
-rw-r--r--drivers/acpi/namespace/nsnames.c7
-rw-r--r--drivers/acpi/namespace/nspredef.c900
-rw-r--r--drivers/acpi/namespace/nssearch.c2
-rw-r--r--drivers/acpi/namespace/nsxfeval.c78
-rw-r--r--drivers/acpi/namespace/nsxfname.c5
-rw-r--r--drivers/acpi/osl.c4
-rw-r--r--drivers/acpi/parser/psloop.c2
-rw-r--r--drivers/acpi/parser/psparse.c32
-rw-r--r--drivers/acpi/pci_link.c4
-rw-r--r--drivers/acpi/power.c68
-rw-r--r--drivers/acpi/processor_idle.c1
-rw-r--r--drivers/acpi/processor_perflib.c28
-rw-r--r--drivers/acpi/processor_throttling.c10
-rw-r--r--drivers/acpi/reboot.c25
-rw-r--r--drivers/acpi/resources/rscalc.c5
-rw-r--r--drivers/acpi/resources/rscreate.c10
-rw-r--r--drivers/acpi/scan.c82
-rw-r--r--drivers/acpi/sleep/proc.c10
-rw-r--r--drivers/acpi/system.c4
-rw-r--r--drivers/acpi/tables/tbinstal.c61
-rw-r--r--drivers/acpi/thermal.c4
-rw-r--r--drivers/acpi/utilities/utalloc.c53
-rw-r--r--drivers/acpi/utilities/utcopy.c29
-rw-r--r--drivers/acpi/utilities/utdelete.c12
-rw-r--r--drivers/acpi/utilities/utglobal.c52
-rw-r--r--drivers/acpi/utilities/utmisc.c9
-rw-r--r--drivers/acpi/utilities/utobject.c15
-rw-r--r--drivers/acpi/utilities/utxface.c7
-rw-r--r--drivers/acpi/video.c12
-rw-r--r--drivers/acpi/wmi.c49
-rw-r--r--drivers/ata/sata_nv.c46
-rw-r--r--drivers/bluetooth/bpa10x.c2
-rw-r--r--drivers/bluetooth/btusb.c36
-rw-r--r--drivers/char/tty_io.c14
-rw-r--r--drivers/cpuidle/cpuidle.c9
-rw-r--r--drivers/dma/dw_dmac.c2
-rw-r--r--drivers/hwmon/abituguru3.c3
-rw-r--r--drivers/hwmon/it87.c70
-rw-r--r--drivers/i2c/busses/i2c-powermac.c4
-rw-r--r--drivers/i2c/i2c-dev.c4
-rw-r--r--drivers/ide/Kconfig18
-rw-r--r--drivers/ide/ide-cd.c6
-rw-r--r--drivers/ide/ide-dma.c2
-rw-r--r--drivers/ide/ide-probe.c2
-rw-r--r--drivers/ide/ide-tape.c10
-rw-r--r--drivers/ide/mips/Makefile1
-rw-r--r--drivers/ide/mips/swarm.c196
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c8
-rw-r--r--drivers/input/mouse/bcm5974.c13
-rw-r--r--drivers/input/touchscreen/jornada720_ts.c4
-rw-r--r--drivers/leds/leds-fsg.c28
-rw-r--r--drivers/leds/leds-pca955x.c70
-rw-r--r--drivers/md/dm-mpath.c16
-rw-r--r--drivers/md/dm.c12
-rw-r--r--drivers/media/common/tuners/tuner-xc2028.h1
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c1
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c16
-rw-r--r--drivers/media/dvb/dvb-core/dvb_demux.c16
-rw-r--r--drivers/media/dvb/frontends/s5h1420.c11
-rw-r--r--drivers/media/dvb/frontends/s5h1420.h8
-rw-r--r--drivers/media/dvb/siano/sms-cards.c4
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c2
-rw-r--r--drivers/media/video/cafe_ccic.c1
-rw-r--r--drivers/media/video/cpia2/cpia2_usb.c5
-rw-r--r--drivers/media/video/cx18/cx18-cards.c2
-rw-r--r--drivers/media/video/em28xx/em28xx-audio.c12
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c55
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c9
-rw-r--r--drivers/media/video/gspca/gspca.c3
-rw-r--r--drivers/media/video/gspca/pac7311.c1
-rw-r--r--drivers/media/video/gspca/sonixb.c4
-rw-r--r--drivers/media/video/gspca/sonixj.c19
-rw-r--r--drivers/media/video/gspca/spca561.c2
-rw-r--r--drivers/media/video/gspca/zc3xx.c4
-rw-r--r--drivers/media/video/ov511.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-devattr.c2
-rw-r--r--drivers/media/video/s2255drv.c3
-rw-r--r--drivers/media/video/uvc/uvc_ctrl.c2
-rw-r--r--drivers/media/video/w9968cf.c2
-rw-r--r--drivers/media/video/wm8739.c4
-rw-r--r--drivers/media/video/zoran_card.c2
-rw-r--r--drivers/media/video/zoran_driver.c15
-rw-r--r--drivers/mfd/Kconfig4
-rw-r--r--drivers/mfd/asic3.c2
-rw-r--r--drivers/misc/Kconfig1
-rw-r--r--drivers/misc/acer-wmi.c225
-rw-r--r--drivers/misc/eeepc-laptop.c16
-rw-r--r--drivers/mmc/host/atmel-mci.c6
-rw-r--r--drivers/net/e1000e/e1000.h5
-rw-r--r--drivers/net/e1000e/ethtool.c9
-rw-r--r--drivers/net/e1000e/ich8lan.c78
-rw-r--r--drivers/net/e1000e/netdev.c72
-rw-r--r--drivers/net/e1000e/param.c30
-rw-r--r--drivers/net/wireless/ath9k/core.c11
-rw-r--r--drivers/net/wireless/ath9k/core.h1
-rw-r--r--drivers/net/wireless/ath9k/main.c12
-rw-r--r--drivers/net/wireless/ath9k/xmit.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c1
-rw-r--r--drivers/pci/pci-sysfs.c19
-rw-r--r--drivers/pci/pcie/aspm.c2
-rw-r--r--drivers/pci/search.c6
-rw-r--r--drivers/pcmcia/ds.c23
-rw-r--r--drivers/pnp/pnpacpi/core.c6
-rw-r--r--drivers/rtc/rtc-dev.c15
-rw-r--r--drivers/s390/cio/qdio_setup.c55
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c2
-rw-r--r--drivers/scsi/qlogicpti.c1
-rw-r--r--drivers/scsi/scsi_lib.c3
-rw-r--r--drivers/serial/atmel_serial.c32
-rw-r--r--drivers/spi/orion_spi.c2
-rw-r--r--drivers/spi/pxa2xx_spi.c4
-rw-r--r--drivers/ssb/main.c1
-rw-r--r--drivers/usb/core/hcd.c3
-rw-r--r--drivers/usb/core/hub.c39
-rw-r--r--drivers/usb/gadget/fsl_usb2_udc.c2
-rw-r--r--drivers/usb/gadget/omap_udc.c4
-rw-r--r--drivers/usb/host/ehci-hcd.c26
-rw-r--r--drivers/usb/host/ehci-sched.c32
-rw-r--r--drivers/usb/musb/Kconfig1
-rw-r--r--drivers/usb/musb/musb_core.c4
-rw-r--r--drivers/usb/musb/omap2430.c4
-rw-r--r--drivers/usb/musb/omap2430.h4
-rw-r--r--drivers/usb/serial/cp2101.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.h5
-rw-r--r--drivers/usb/serial/option.c2
-rw-r--r--drivers/usb/serial/sierra.c12
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c2
-rw-r--r--drivers/usb/serial/usb-serial.c4
-rw-r--r--drivers/usb/storage/Kconfig12
-rw-r--r--drivers/usb/storage/Makefile3
-rw-r--r--drivers/usb/storage/unusual_devs.h30
-rw-r--r--drivers/usb/storage/usb.c2
-rw-r--r--drivers/video/console/fbcon.c6
-rw-r--r--drivers/video/console/fbcon.h2
-rw-r--r--drivers/watchdog/geodewdt.c6
-rw-r--r--drivers/watchdog/ibmasr.c1
-rw-r--r--drivers/watchdog/pnx4008_wdt.c4
-rw-r--r--drivers/watchdog/rc32434_wdt.c6
-rw-r--r--drivers/watchdog/rdc321x_wdt.c6
-rw-r--r--drivers/watchdog/wdt285.c15
170 files changed, 2953 insertions, 1352 deletions
diff --git a/drivers/accessibility/braille/braille_console.c b/drivers/accessibility/braille/braille_console.c
index 0a5f6b2114c5..d672cfe7ca59 100644
--- a/drivers/accessibility/braille/braille_console.c
+++ b/drivers/accessibility/braille/braille_console.c
@@ -376,6 +376,8 @@ int braille_register_console(struct console *console, int index,
376 console->flags |= CON_ENABLED; 376 console->flags |= CON_ENABLED;
377 console->index = index; 377 console->index = index;
378 braille_co = console; 378 braille_co = console;
379 register_keyboard_notifier(&keyboard_notifier_block);
380 register_vt_notifier(&vt_notifier_block);
379 return 0; 381 return 0;
380} 382}
381 383
@@ -383,15 +385,8 @@ int braille_unregister_console(struct console *console)
383{ 385{
384 if (braille_co != console) 386 if (braille_co != console)
385 return -EINVAL; 387 return -EINVAL;
388 unregister_keyboard_notifier(&keyboard_notifier_block);
389 unregister_vt_notifier(&vt_notifier_block);
386 braille_co = NULL; 390 braille_co = NULL;
387 return 0; 391 return 0;
388} 392}
389
390static int __init braille_init(void)
391{
392 register_keyboard_notifier(&keyboard_notifier_block);
393 register_vt_notifier(&vt_notifier_block);
394 return 0;
395}
396
397console_initcall(braille_init);
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 5f1127ad5a95..bbad9b6c2c88 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -454,8 +454,8 @@ static int acpi_memory_device_start (struct acpi_device *device)
454 /* call add_memory func */ 454 /* call add_memory func */
455 result = acpi_memory_enable_device(mem_device); 455 result = acpi_memory_enable_device(mem_device);
456 if (result) 456 if (result)
457 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 457 printk(KERN_ERR PREFIX
458 "Error in acpi_memory_enable_device\n")); 458 "Error in acpi_memory_enable_device\n");
459 } 459 }
460 return result; 460 return result;
461} 461}
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index d3d0886d637f..3f7adf683d4e 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -42,7 +42,7 @@
42 42
43#define ASUS_ACPI_VERSION "0.30" 43#define ASUS_ACPI_VERSION "0.30"
44 44
45#define PROC_ASUS "asus" //the directory 45#define PROC_ASUS "asus" /* The directory */
46#define PROC_MLED "mled" 46#define PROC_MLED "mled"
47#define PROC_WLED "wled" 47#define PROC_WLED "wled"
48#define PROC_TLED "tled" 48#define PROC_TLED "tled"
@@ -66,10 +66,10 @@
66/* 66/*
67 * Flags for hotk status 67 * Flags for hotk status
68 */ 68 */
69#define MLED_ON 0x01 //mail LED 69#define MLED_ON 0x01 /* Mail LED */
70#define WLED_ON 0x02 //wireless LED 70#define WLED_ON 0x02 /* Wireless LED */
71#define TLED_ON 0x04 //touchpad LED 71#define TLED_ON 0x04 /* Touchpad LED */
72#define BT_ON 0x08 //internal Bluetooth 72#define BT_ON 0x08 /* Internal Bluetooth */
73 73
74MODULE_AUTHOR("Julien Lerouge, Karol Kozimor"); 74MODULE_AUTHOR("Julien Lerouge, Karol Kozimor");
75MODULE_DESCRIPTION(ACPI_HOTK_NAME); 75MODULE_DESCRIPTION(ACPI_HOTK_NAME);
@@ -82,28 +82,28 @@ MODULE_PARM_DESC(asus_uid, "UID for entries in /proc/acpi/asus");
82module_param(asus_gid, uint, 0); 82module_param(asus_gid, uint, 0);
83MODULE_PARM_DESC(asus_gid, "GID for entries in /proc/acpi/asus"); 83MODULE_PARM_DESC(asus_gid, "GID for entries in /proc/acpi/asus");
84 84
85/* For each model, all features implemented, 85/* For each model, all features implemented,
86 * those marked with R are relative to HOTK, A for absolute */ 86 * those marked with R are relative to HOTK, A for absolute */
87struct model_data { 87struct model_data {
88 char *name; //name of the laptop________________A 88 char *name; /* name of the laptop________________A */
89 char *mt_mled; //method to handle mled_____________R 89 char *mt_mled; /* method to handle mled_____________R */
90 char *mled_status; //node to handle mled reading_______A 90 char *mled_status; /* node to handle mled reading_______A */
91 char *mt_wled; //method to handle wled_____________R 91 char *mt_wled; /* method to handle wled_____________R */
92 char *wled_status; //node to handle wled reading_______A 92 char *wled_status; /* node to handle wled reading_______A */
93 char *mt_tled; //method to handle tled_____________R 93 char *mt_tled; /* method to handle tled_____________R */
94 char *tled_status; //node to handle tled reading_______A 94 char *tled_status; /* node to handle tled reading_______A */
95 char *mt_ledd; //method to handle LED display______R 95 char *mt_ledd; /* method to handle LED display______R */
96 char *mt_bt_switch; //method to switch Bluetooth on/off_R 96 char *mt_bt_switch; /* method to switch Bluetooth on/off_R */
97 char *bt_status; //no model currently supports this__? 97 char *bt_status; /* no model currently supports this__? */
98 char *mt_lcd_switch; //method to turn LCD on/off_________A 98 char *mt_lcd_switch; /* method to turn LCD on/off_________A */
99 char *lcd_status; //node to read LCD panel state______A 99 char *lcd_status; /* node to read LCD panel state______A */
100 char *brightness_up; //method to set brightness up_______A 100 char *brightness_up; /* method to set brightness up_______A */
101 char *brightness_down; //guess what ?______________________A 101 char *brightness_down; /* method to set brightness down ____A */
102 char *brightness_set; //method to set absolute brightness_R 102 char *brightness_set; /* method to set absolute brightness_R */
103 char *brightness_get; //method to get absolute brightness_R 103 char *brightness_get; /* method to get absolute brightness_R */
104 char *brightness_status; //node to get brightness____________A 104 char *brightness_status;/* node to get brightness____________A */
105 char *display_set; //method to set video output________R 105 char *display_set; /* method to set video output________R */
106 char *display_get; //method to get video output________R 106 char *display_get; /* method to get video output________R */
107}; 107};
108 108
109/* 109/*
@@ -111,41 +111,41 @@ struct model_data {
111 * about the hotk device 111 * about the hotk device
112 */ 112 */
113struct asus_hotk { 113struct asus_hotk {
114 struct acpi_device *device; //the device we are in 114 struct acpi_device *device; /* the device we are in */
115 acpi_handle handle; //the handle of the hotk device 115 acpi_handle handle; /* the handle of the hotk device */
116 char status; //status of the hotk, for LEDs, ... 116 char status; /* status of the hotk, for LEDs */
117 u32 ledd_status; //status of the LED display 117 u32 ledd_status; /* status of the LED display */
118 struct model_data *methods; //methods available on the laptop 118 struct model_data *methods; /* methods available on the laptop */
119 u8 brightness; //brightness level 119 u8 brightness; /* brightness level */
120 enum { 120 enum {
121 A1x = 0, //A1340D, A1300F 121 A1x = 0, /* A1340D, A1300F */
122 A2x, //A2500H 122 A2x, /* A2500H */
123 A4G, //A4700G 123 A4G, /* A4700G */
124 D1x, //D1 124 D1x, /* D1 */
125 L2D, //L2000D 125 L2D, /* L2000D */
126 L3C, //L3800C 126 L3C, /* L3800C */
127 L3D, //L3400D 127 L3D, /* L3400D */
128 L3H, //L3H, L2000E, L5D 128 L3H, /* L3H, L2000E, L5D */
129 L4R, //L4500R 129 L4R, /* L4500R */
130 L5x, //L5800C 130 L5x, /* L5800C */
131 L8L, //L8400L 131 L8L, /* L8400L */
132 M1A, //M1300A 132 M1A, /* M1300A */
133 M2E, //M2400E, L4400L 133 M2E, /* M2400E, L4400L */
134 M6N, //M6800N, W3400N 134 M6N, /* M6800N, W3400N */
135 M6R, //M6700R, A3000G 135 M6R, /* M6700R, A3000G */
136 P30, //Samsung P30 136 P30, /* Samsung P30 */
137 S1x, //S1300A, but also L1400B and M2400A (L84F) 137 S1x, /* S1300A, but also L1400B and M2400A (L84F) */
138 S2x, //S200 (J1 reported), Victor MP-XP7210 138 S2x, /* S200 (J1 reported), Victor MP-XP7210 */
139 W1N, //W1000N 139 W1N, /* W1000N */
140 W5A, //W5A 140 W5A, /* W5A */
141 W3V, //W3030V 141 W3V, /* W3030V */
142 xxN, //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N 142 xxN, /* M2400N, M3700N, M5200N, M6800N,
143 A4S, //Z81sp 143 S1300N, S5200N*/
144 //(Centrino) 144 A4S, /* Z81sp */
145 F3Sa, 145 F3Sa, /* (Centrino) */
146 END_MODEL 146 END_MODEL
147 } model; //Models currently supported 147 } model; /* Models currently supported */
148 u16 event_count[128]; //count for each event TODO make this better 148 u16 event_count[128]; /* Count for each event TODO make this better */
149}; 149};
150 150
151/* Here we go */ 151/* Here we go */
@@ -459,18 +459,18 @@ static struct acpi_driver asus_hotk_driver = {
459 }, 459 },
460}; 460};
461 461
462/* 462/*
463 * This function evaluates an ACPI method, given an int as parameter, the 463 * This function evaluates an ACPI method, given an int as parameter, the
464 * method is searched within the scope of the handle, can be NULL. The output 464 * method is searched within the scope of the handle, can be NULL. The output
465 * of the method is written is output, which can also be NULL 465 * of the method is written is output, which can also be NULL
466 * 466 *
467 * returns 1 if write is successful, 0 else. 467 * returns 1 if write is successful, 0 else.
468 */ 468 */
469static int write_acpi_int(acpi_handle handle, const char *method, int val, 469static int write_acpi_int(acpi_handle handle, const char *method, int val,
470 struct acpi_buffer *output) 470 struct acpi_buffer *output)
471{ 471{
472 struct acpi_object_list params; //list of input parameters (an int here) 472 struct acpi_object_list params; /* list of input parameters (int) */
473 union acpi_object in_obj; //the only param we use 473 union acpi_object in_obj; /* the only param we use */
474 acpi_status status; 474 acpi_status status;
475 475
476 params.count = 1; 476 params.count = 1;
@@ -507,18 +507,18 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof,
507{ 507{
508 int len = 0; 508 int len = 0;
509 int temp; 509 int temp;
510 char buf[16]; //enough for all info 510 char buf[16]; /* enough for all info */
511 /* 511 /*
512 * We use the easy way, we don't care of off and count, so we don't set eof 512 * We use the easy way, we don't care of off and count,
513 * to 1 513 * so we don't set eof to 1
514 */ 514 */
515 515
516 len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n"); 516 len += sprintf(page, ACPI_HOTK_NAME " " ASUS_ACPI_VERSION "\n");
517 len += sprintf(page + len, "Model reference : %s\n", 517 len += sprintf(page + len, "Model reference : %s\n",
518 hotk->methods->name); 518 hotk->methods->name);
519 /* 519 /*
520 * The SFUN method probably allows the original driver to get the list 520 * The SFUN method probably allows the original driver to get the list
521 * of features supported by a given model. For now, 0x0100 or 0x0800 521 * of features supported by a given model. For now, 0x0100 or 0x0800
522 * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card. 522 * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card.
523 * The significance of others is yet to be found. 523 * The significance of others is yet to be found.
524 */ 524 */
@@ -528,7 +528,7 @@ proc_read_info(char *page, char **start, off_t off, int count, int *eof,
528 /* 528 /*
529 * Another value for userspace: the ASYM method returns 0x02 for 529 * Another value for userspace: the ASYM method returns 0x02 for
530 * battery low and 0x04 for battery critical, its readings tend to be 530 * battery low and 0x04 for battery critical, its readings tend to be
531 * more accurate than those provided by _BST. 531 * more accurate than those provided by _BST.
532 * Note: since not all the laptops provide this method, errors are 532 * Note: since not all the laptops provide this method, errors are
533 * silently ignored. 533 * silently ignored.
534 */ 534 */
@@ -579,7 +579,7 @@ static int read_led(const char *ledname, int ledmask)
579 return (hotk->status & ledmask) ? 1 : 0; 579 return (hotk->status & ledmask) ? 1 : 0;
580} 580}
581 581
582static int parse_arg(const char __user * buf, unsigned long count, int *val) 582static int parse_arg(const char __user *buf, unsigned long count, int *val)
583{ 583{
584 char s[32]; 584 char s[32];
585 if (!count) 585 if (!count)
@@ -596,7 +596,7 @@ static int parse_arg(const char __user * buf, unsigned long count, int *val)
596 596
597/* FIXME: kill extraneous args so it can be called independently */ 597/* FIXME: kill extraneous args so it can be called independently */
598static int 598static int
599write_led(const char __user * buffer, unsigned long count, 599write_led(const char __user *buffer, unsigned long count,
600 char *ledname, int ledmask, int invert) 600 char *ledname, int ledmask, int invert)
601{ 601{
602 int rv, value; 602 int rv, value;
@@ -631,7 +631,7 @@ proc_read_mled(char *page, char **start, off_t off, int count, int *eof,
631} 631}
632 632
633static int 633static int
634proc_write_mled(struct file *file, const char __user * buffer, 634proc_write_mled(struct file *file, const char __user *buffer,
635 unsigned long count, void *data) 635 unsigned long count, void *data)
636{ 636{
637 return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1); 637 return write_led(buffer, count, hotk->methods->mt_mled, MLED_ON, 1);
@@ -648,7 +648,7 @@ proc_read_ledd(char *page, char **start, off_t off, int count, int *eof,
648} 648}
649 649
650static int 650static int
651proc_write_ledd(struct file *file, const char __user * buffer, 651proc_write_ledd(struct file *file, const char __user *buffer,
652 unsigned long count, void *data) 652 unsigned long count, void *data)
653{ 653{
654 int rv, value; 654 int rv, value;
@@ -677,7 +677,7 @@ proc_read_wled(char *page, char **start, off_t off, int count, int *eof,
677} 677}
678 678
679static int 679static int
680proc_write_wled(struct file *file, const char __user * buffer, 680proc_write_wled(struct file *file, const char __user *buffer,
681 unsigned long count, void *data) 681 unsigned long count, void *data)
682{ 682{
683 return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0); 683 return write_led(buffer, count, hotk->methods->mt_wled, WLED_ON, 0);
@@ -694,10 +694,10 @@ proc_read_bluetooth(char *page, char **start, off_t off, int count, int *eof,
694} 694}
695 695
696static int 696static int
697proc_write_bluetooth(struct file *file, const char __user * buffer, 697proc_write_bluetooth(struct file *file, const char __user *buffer,
698 unsigned long count, void *data) 698 unsigned long count, void *data)
699{ 699{
700 /* Note: mt_bt_switch controls both internal Bluetooth adapter's 700 /* Note: mt_bt_switch controls both internal Bluetooth adapter's
701 presence and its LED */ 701 presence and its LED */
702 return write_led(buffer, count, hotk->methods->mt_bt_switch, BT_ON, 0); 702 return write_led(buffer, count, hotk->methods->mt_bt_switch, BT_ON, 0);
703} 703}
@@ -714,7 +714,7 @@ proc_read_tled(char *page, char **start, off_t off, int count, int *eof,
714} 714}
715 715
716static int 716static int
717proc_write_tled(struct file *file, const char __user * buffer, 717proc_write_tled(struct file *file, const char __user *buffer,
718 unsigned long count, void *data) 718 unsigned long count, void *data)
719{ 719{
720 return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0); 720 return write_led(buffer, count, hotk->methods->mt_tled, TLED_ON, 0);
@@ -734,7 +734,7 @@ static int get_lcd_state(void)
734 734
735 input.count = 2; 735 input.count = 2;
736 input.pointer = mt_params; 736 input.pointer = mt_params;
737 /* Note: the following values are partly guessed up, but 737 /* Note: the following values are partly guessed up, but
738 otherwise they seem to work */ 738 otherwise they seem to work */
739 mt_params[0].type = ACPI_TYPE_INTEGER; 739 mt_params[0].type = ACPI_TYPE_INTEGER;
740 mt_params[0].integer.value = 0x02; 740 mt_params[0].integer.value = 0x02;
@@ -796,12 +796,13 @@ static int set_lcd_state(int value)
796 acpi_evaluate_object(NULL, 796 acpi_evaluate_object(NULL,
797 hotk->methods->mt_lcd_switch, 797 hotk->methods->mt_lcd_switch,
798 NULL, NULL); 798 NULL, NULL);
799 } else { /* L3H and the like have to be handled differently */ 799 } else {
800 /* L3H and the like must be handled differently */
800 if (!write_acpi_int 801 if (!write_acpi_int
801 (hotk->handle, hotk->methods->mt_lcd_switch, 0x07, 802 (hotk->handle, hotk->methods->mt_lcd_switch, 0x07,
802 NULL)) 803 NULL))
803 status = AE_ERROR; 804 status = AE_ERROR;
804 /* L3H's AML executes EHK (0x07) upon Fn+F7 keypress, 805 /* L3H's AML executes EHK (0x07) upon Fn+F7 keypress,
805 the exact behaviour is simulated here */ 806 the exact behaviour is simulated here */
806 } 807 }
807 if (ACPI_FAILURE(status)) 808 if (ACPI_FAILURE(status))
@@ -819,7 +820,7 @@ proc_read_lcd(char *page, char **start, off_t off, int count, int *eof,
819} 820}
820 821
821static int 822static int
822proc_write_lcd(struct file *file, const char __user * buffer, 823proc_write_lcd(struct file *file, const char __user *buffer,
823 unsigned long count, void *data) 824 unsigned long count, void *data)
824{ 825{
825 int rv, value; 826 int rv, value;
@@ -897,7 +898,7 @@ proc_read_brn(char *page, char **start, off_t off, int count, int *eof,
897} 898}
898 899
899static int 900static int
900proc_write_brn(struct file *file, const char __user * buffer, 901proc_write_brn(struct file *file, const char __user *buffer,
901 unsigned long count, void *data) 902 unsigned long count, void *data)
902{ 903{
903 int rv, value; 904 int rv, value;
@@ -921,7 +922,7 @@ static void set_display(int value)
921} 922}
922 923
923/* 924/*
924 * Now, *this* one could be more user-friendly, but so far, no-one has 925 * Now, *this* one could be more user-friendly, but so far, no-one has
925 * complained. The significance of bits is the same as in proc_write_disp() 926 * complained. The significance of bits is the same as in proc_write_disp()
926 */ 927 */
927static int 928static int
@@ -933,18 +934,18 @@ proc_read_disp(char *page, char **start, off_t off, int count, int *eof,
933 if (!read_acpi_int(hotk->handle, hotk->methods->display_get, &value)) 934 if (!read_acpi_int(hotk->handle, hotk->methods->display_get, &value))
934 printk(KERN_WARNING 935 printk(KERN_WARNING
935 "Asus ACPI: Error reading display status\n"); 936 "Asus ACPI: Error reading display status\n");
936 value &= 0x07; /* needed for some models, shouldn't hurt others */ 937 value &= 0x07; /* needed for some models, shouldn't hurt others */
937 return sprintf(page, "%d\n", value); 938 return sprintf(page, "%d\n", value);
938} 939}
939 940
940/* 941/*
941 * Experimental support for display switching. As of now: 1 should activate 942 * Experimental support for display switching. As of now: 1 should activate
942 * the LCD output, 2 should do for CRT, and 4 for TV-Out. Any combination 943 * the LCD output, 2 should do for CRT, and 4 for TV-Out. Any combination
943 * (bitwise) of these will suffice. I never actually tested 3 displays hooked up 944 * (bitwise) of these will suffice. I never actually tested 3 displays hooked
944 * simultaneously, so be warned. See the acpi4asus README for more info. 945 * up simultaneously, so be warned. See the acpi4asus README for more info.
945 */ 946 */
946static int 947static int
947proc_write_disp(struct file *file, const char __user * buffer, 948proc_write_disp(struct file *file, const char __user *buffer,
948 unsigned long count, void *data) 949 unsigned long count, void *data)
949{ 950{
950 int rv, value; 951 int rv, value;
@@ -957,12 +958,12 @@ proc_write_disp(struct file *file, const char __user * buffer,
957 958
958typedef int (proc_readfunc) (char *page, char **start, off_t off, int count, 959typedef int (proc_readfunc) (char *page, char **start, off_t off, int count,
959 int *eof, void *data); 960 int *eof, void *data);
960typedef int (proc_writefunc) (struct file * file, const char __user * buffer, 961typedef int (proc_writefunc) (struct file *file, const char __user *buffer,
961 unsigned long count, void *data); 962 unsigned long count, void *data);
962 963
963static int 964static int
964asus_proc_add(char *name, proc_writefunc * writefunc, 965asus_proc_add(char *name, proc_writefunc *writefunc,
965 proc_readfunc * readfunc, mode_t mode, 966 proc_readfunc *readfunc, mode_t mode,
966 struct acpi_device *device) 967 struct acpi_device *device)
967{ 968{
968 struct proc_dir_entry *proc = 969 struct proc_dir_entry *proc =
@@ -1040,9 +1041,9 @@ static int asus_hotk_add_fs(struct acpi_device *device)
1040 &proc_read_bluetooth, mode, device); 1041 &proc_read_bluetooth, mode, device);
1041 } 1042 }
1042 1043
1043 /* 1044 /*
1044 * We need both read node and write method as LCD switch is also accessible 1045 * We need both read node and write method as LCD switch is also
1045 * from keyboard 1046 * accessible from the keyboard
1046 */ 1047 */
1047 if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) { 1048 if (hotk->methods->mt_lcd_switch && hotk->methods->lcd_status) {
1048 asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode, 1049 asus_proc_add(PROC_LCD, &proc_write_lcd, &proc_read_lcd, mode,
@@ -1096,11 +1097,10 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
1096 if (!hotk) 1097 if (!hotk)
1097 return; 1098 return;
1098 1099
1099 if ((event & ~((u32) BR_UP)) < 16) { 1100 if ((event & ~((u32) BR_UP)) < 16)
1100 hotk->brightness = (event & ~((u32) BR_UP)); 1101 hotk->brightness = (event & ~((u32) BR_UP));
1101 } else if ((event & ~((u32) BR_DOWN)) < 16) { 1102 else if ((event & ~((u32) BR_DOWN)) < 16)
1102 hotk->brightness = (event & ~((u32) BR_DOWN)); 1103 hotk->brightness = (event & ~((u32) BR_DOWN));
1103 }
1104 1104
1105 acpi_bus_generate_proc_event(hotk->device, event, 1105 acpi_bus_generate_proc_event(hotk->device, event,
1106 hotk->event_count[event % 128]++); 1106 hotk->event_count[event % 128]++);
@@ -1186,8 +1186,8 @@ static int asus_hotk_get_info(void)
1186 acpi_status status; 1186 acpi_status status;
1187 1187
1188 /* 1188 /*
1189 * Get DSDT headers early enough to allow for differentiating between 1189 * Get DSDT headers early enough to allow for differentiating between
1190 * models, but late enough to allow acpi_bus_register_driver() to fail 1190 * models, but late enough to allow acpi_bus_register_driver() to fail
1191 * before doing anything ACPI-specific. Should we encounter a machine, 1191 * before doing anything ACPI-specific. Should we encounter a machine,
1192 * which needs special handling (i.e. its hotkey device has a different 1192 * which needs special handling (i.e. its hotkey device has a different
1193 * HID), this bit will be moved. A global variable asus_info contains 1193 * HID), this bit will be moved. A global variable asus_info contains
@@ -1212,8 +1212,8 @@ static int asus_hotk_get_info(void)
1212 1212
1213 /* 1213 /*
1214 * Try to match the object returned by INIT to the specific model. 1214 * Try to match the object returned by INIT to the specific model.
1215 * Handle every possible object (or the lack of thereof) the DSDT 1215 * Handle every possible object (or the lack of thereof) the DSDT
1216 * writers might throw at us. When in trouble, we pass NULL to 1216 * writers might throw at us. When in trouble, we pass NULL to
1217 * asus_model_match() and try something completely different. 1217 * asus_model_match() and try something completely different.
1218 */ 1218 */
1219 if (buffer.pointer) { 1219 if (buffer.pointer) {
@@ -1254,7 +1254,7 @@ static int asus_hotk_get_info(void)
1254 /* Sort of per-model blacklist */ 1254 /* Sort of per-model blacklist */
1255 if (strncmp(string, "L2B", 3) == 0) 1255 if (strncmp(string, "L2B", 3) == 0)
1256 hotk->methods->lcd_status = NULL; 1256 hotk->methods->lcd_status = NULL;
1257 /* L2B is similar enough to L3C to use its settings, with this only 1257 /* L2B is similar enough to L3C to use its settings, with this only
1258 exception */ 1258 exception */
1259 else if (strncmp(string, "A3G", 3) == 0) 1259 else if (strncmp(string, "A3G", 3) == 0)
1260 hotk->methods->lcd_status = "\\BLFG"; 1260 hotk->methods->lcd_status = "\\BLFG";
@@ -1366,10 +1366,9 @@ static int asus_hotk_add(struct acpi_device *device)
1366 /* LED display is off by default */ 1366 /* LED display is off by default */
1367 hotk->ledd_status = 0xFFF; 1367 hotk->ledd_status = 0xFFF;
1368 1368
1369 end: 1369end:
1370 if (result) { 1370 if (result)
1371 kfree(hotk); 1371 kfree(hotk);
1372 }
1373 1372
1374 return result; 1373 return result;
1375} 1374}
@@ -1394,8 +1393,8 @@ static int asus_hotk_remove(struct acpi_device *device, int type)
1394} 1393}
1395 1394
1396static struct backlight_ops asus_backlight_data = { 1395static struct backlight_ops asus_backlight_data = {
1397 .get_brightness = read_brightness, 1396 .get_brightness = read_brightness,
1398 .update_status = set_brightness_status, 1397 .update_status = set_brightness_status,
1399}; 1398};
1400 1399
1401static void asus_acpi_exit(void) 1400static void asus_acpi_exit(void)
@@ -1442,15 +1441,15 @@ static int __init asus_acpi_init(void)
1442 return -ENODEV; 1441 return -ENODEV;
1443 } 1442 }
1444 1443
1445 asus_backlight_device = backlight_device_register("asus",NULL,NULL, 1444 asus_backlight_device = backlight_device_register("asus", NULL, NULL,
1446 &asus_backlight_data); 1445 &asus_backlight_data);
1447 if (IS_ERR(asus_backlight_device)) { 1446 if (IS_ERR(asus_backlight_device)) {
1448 printk(KERN_ERR "Could not register asus backlight device\n"); 1447 printk(KERN_ERR "Could not register asus backlight device\n");
1449 asus_backlight_device = NULL; 1448 asus_backlight_device = NULL;
1450 asus_acpi_exit(); 1449 asus_acpi_exit();
1451 return -ENODEV; 1450 return -ENODEV;
1452 } 1451 }
1453 asus_backlight_device->props.max_brightness = 15; 1452 asus_backlight_device->props.max_brightness = 15;
1454 1453
1455 return 0; 1454 return 0;
1456} 1455}
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 0dc44945725e..e6311f432edf 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -48,6 +48,23 @@ EXPORT_SYMBOL(acpi_root_dir);
48 48
49#define STRUCT_TO_INT(s) (*((int*)&s)) 49#define STRUCT_TO_INT(s) (*((int*)&s))
50 50
51static int set_power_nocheck(const struct dmi_system_id *id)
52{
53 printk(KERN_NOTICE PREFIX "%s detected - "
54 "disable power check in power transistion\n", id->ident);
55 acpi_power_nocheck = 1;
56 return 0;
57}
58static struct dmi_system_id __cpuinitdata power_nocheck_dmi_table[] = {
59 {
60 set_power_nocheck, "HP Pavilion 05", {
61 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
62 DMI_MATCH(DMI_SYS_VENDOR, "HP Pavilion 05"),
63 DMI_MATCH(DMI_PRODUCT_VERSION, "2001211RE101GLEND") }, NULL},
64 {},
65};
66
67
51/* -------------------------------------------------------------------------- 68/* --------------------------------------------------------------------------
52 Device Management 69 Device Management
53 -------------------------------------------------------------------------- */ 70 -------------------------------------------------------------------------- */
@@ -95,21 +112,21 @@ int acpi_bus_get_status(struct acpi_device *device)
95 } 112 }
96 113
97 /* 114 /*
98 * Otherwise we assume the status of our parent (unless we don't 115 * According to ACPI spec some device can be present and functional
99 * have one, in which case status is implied). 116 * even if the parent is not present but functional.
117 * In such conditions the child device should not inherit the status
118 * from the parent.
100 */ 119 */
101 else if (device->parent)
102 device->status = device->parent->status;
103 else 120 else
104 STRUCT_TO_INT(device->status) = 121 STRUCT_TO_INT(device->status) =
105 ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | 122 ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED |
106 ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; 123 ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING;
107 124
108 if (device->status.functional && !device->status.present) { 125 if (device->status.functional && !device->status.present) {
109 printk(KERN_WARNING PREFIX "Device [%s] status [%08x]: " 126 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
110 "functional but not present; setting present\n", 127 "functional but not present;\n",
111 device->pnp.bus_id, (u32) STRUCT_TO_INT(device->status)); 128 device->pnp.bus_id,
112 device->status.present = 1; 129 (u32) STRUCT_TO_INT(device->status)));
113 } 130 }
114 131
115 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", 132 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n",
@@ -223,7 +240,19 @@ int acpi_bus_set_power(acpi_handle handle, int state)
223 /* 240 /*
224 * Get device's current power state 241 * Get device's current power state
225 */ 242 */
226 acpi_bus_get_power(device->handle, &device->power.state); 243 if (!acpi_power_nocheck) {
244 /*
245 * Maybe the incorrect power state is returned on the bogus
246 * bios, which is different with the real power state.
247 * For example: the bios returns D0 state and the real power
248 * state is D3. OS expects to set the device to D0 state. In
249 * such case if OS uses the power state returned by the BIOS,
250 * the device can't be transisted to the correct power state.
251 * So if the acpi_power_nocheck is set, it is unnecessary to
252 * get the power state by calling acpi_bus_get_power.
253 */
254 acpi_bus_get_power(device->handle, &device->power.state);
255 }
227 if ((state == device->power.state) && !device->flags.force_power_state) { 256 if ((state == device->power.state) && !device->flags.force_power_state) {
228 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n", 257 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device is already at D%d\n",
229 state)); 258 state));
@@ -833,7 +862,11 @@ static int __init acpi_init(void)
833 } 862 }
834 } else 863 } else
835 disable_acpi(); 864 disable_acpi();
836 865 /*
866 * If the laptop falls into the DMI check table, the power state check
867 * will be disabled in the course of device power transistion.
868 */
869 dmi_check_system(power_nocheck_dmi_table);
837 return result; 870 return result;
838} 871}
839 872
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c
index f9db4f444bd0..4441e84b28a9 100644
--- a/drivers/acpi/cm_sbs.c
+++ b/drivers/acpi/cm_sbs.c
@@ -52,8 +52,8 @@ struct proc_dir_entry *acpi_lock_ac_dir(void)
52 if (acpi_ac_dir) { 52 if (acpi_ac_dir) {
53 lock_ac_dir_cnt++; 53 lock_ac_dir_cnt++;
54 } else { 54 } else {
55 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 55 printk(KERN_ERR PREFIX
56 "Cannot create %s\n", ACPI_AC_CLASS)); 56 "Cannot create %s\n", ACPI_AC_CLASS);
57 } 57 }
58 mutex_unlock(&cm_sbs_mutex); 58 mutex_unlock(&cm_sbs_mutex);
59 return acpi_ac_dir; 59 return acpi_ac_dir;
@@ -83,8 +83,8 @@ struct proc_dir_entry *acpi_lock_battery_dir(void)
83 if (acpi_battery_dir) { 83 if (acpi_battery_dir) {
84 lock_battery_dir_cnt++; 84 lock_battery_dir_cnt++;
85 } else { 85 } else {
86 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 86 printk(KERN_ERR PREFIX
87 "Cannot create %s\n", ACPI_BATTERY_CLASS)); 87 "Cannot create %s\n", ACPI_BATTERY_CLASS);
88 } 88 }
89 mutex_unlock(&cm_sbs_mutex); 89 mutex_unlock(&cm_sbs_mutex);
90 return acpi_battery_dir; 90 return acpi_battery_dir;
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c
index 6df564f4ca6e..abf36b4b1d1d 100644
--- a/drivers/acpi/debug.c
+++ b/drivers/acpi/debug.c
@@ -47,8 +47,6 @@ static const struct acpi_dlayer acpi_debug_layers[] = {
47}; 47};
48 48
49static const struct acpi_dlevel acpi_debug_levels[] = { 49static const struct acpi_dlevel acpi_debug_levels[] = {
50 ACPI_DEBUG_INIT(ACPI_LV_ERROR),
51 ACPI_DEBUG_INIT(ACPI_LV_WARN),
52 ACPI_DEBUG_INIT(ACPI_LV_INIT), 50 ACPI_DEBUG_INIT(ACPI_LV_INIT),
53 ACPI_DEBUG_INIT(ACPI_LV_DEBUG_OBJECT), 51 ACPI_DEBUG_INIT(ACPI_LV_DEBUG_OBJECT),
54 ACPI_DEBUG_INIT(ACPI_LV_INFO), 52 ACPI_DEBUG_INIT(ACPI_LV_INFO),
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/dispatcher/dsmethod.c
index 4613b9ca5792..279a5a60a0dd 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/dispatcher/dsmethod.c
@@ -103,6 +103,9 @@ acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state)
103 NULL); 103 NULL);
104 acpi_ex_enter_interpreter(); 104 acpi_ex_enter_interpreter();
105 } 105 }
106
107 acpi_ds_clear_implicit_return(walk_state);
108
106#ifdef ACPI_DISASSEMBLER 109#ifdef ACPI_DISASSEMBLER
107 if (ACPI_FAILURE(status)) { 110 if (ACPI_FAILURE(status)) {
108 111
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/dispatcher/dsmthdat.c
index 13c43eac35db..d03f81bd1bcb 100644
--- a/drivers/acpi/dispatcher/dsmthdat.c
+++ b/drivers/acpi/dispatcher/dsmthdat.c
@@ -43,7 +43,6 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acdispat.h> 45#include <acpi/acdispat.h>
46#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
49 48
@@ -52,11 +51,11 @@ ACPI_MODULE_NAME("dsmthdat")
52 51
53/* Local prototypes */ 52/* Local prototypes */
54static void 53static void
55acpi_ds_method_data_delete_value(u16 opcode, 54acpi_ds_method_data_delete_value(u8 type,
56 u32 index, struct acpi_walk_state *walk_state); 55 u32 index, struct acpi_walk_state *walk_state);
57 56
58static acpi_status 57static acpi_status
59acpi_ds_method_data_set_value(u16 opcode, 58acpi_ds_method_data_set_value(u8 type,
60 u32 index, 59 u32 index,
61 union acpi_operand_object *object, 60 union acpi_operand_object *object,
62 struct acpi_walk_state *walk_state); 61 struct acpi_walk_state *walk_state);
@@ -216,7 +215,7 @@ acpi_ds_method_data_init_args(union acpi_operand_object **params,
216 * Store the argument in the method/walk descriptor. 215 * Store the argument in the method/walk descriptor.
217 * Do not copy the arg in order to implement call by reference 216 * Do not copy the arg in order to implement call by reference
218 */ 217 */
219 status = acpi_ds_method_data_set_value(AML_ARG_OP, index, 218 status = acpi_ds_method_data_set_value(ACPI_REFCLASS_ARG, index,
220 params[index], 219 params[index],
221 walk_state); 220 walk_state);
222 if (ACPI_FAILURE(status)) { 221 if (ACPI_FAILURE(status)) {
@@ -234,7 +233,8 @@ acpi_ds_method_data_init_args(union acpi_operand_object **params,
234 * 233 *
235 * FUNCTION: acpi_ds_method_data_get_node 234 * FUNCTION: acpi_ds_method_data_get_node
236 * 235 *
237 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 236 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
237 * ACPI_REFCLASS_ARG
238 * Index - Which Local or Arg whose type to get 238 * Index - Which Local or Arg whose type to get
239 * walk_state - Current walk state object 239 * walk_state - Current walk state object
240 * Node - Where the node is returned. 240 * Node - Where the node is returned.
@@ -246,7 +246,7 @@ acpi_ds_method_data_init_args(union acpi_operand_object **params,
246 ******************************************************************************/ 246 ******************************************************************************/
247 247
248acpi_status 248acpi_status
249acpi_ds_method_data_get_node(u16 opcode, 249acpi_ds_method_data_get_node(u8 type,
250 u32 index, 250 u32 index,
251 struct acpi_walk_state *walk_state, 251 struct acpi_walk_state *walk_state,
252 struct acpi_namespace_node **node) 252 struct acpi_namespace_node **node)
@@ -256,8 +256,8 @@ acpi_ds_method_data_get_node(u16 opcode,
256 /* 256 /*
257 * Method Locals and Arguments are supported 257 * Method Locals and Arguments are supported
258 */ 258 */
259 switch (opcode) { 259 switch (type) {
260 case AML_LOCAL_OP: 260 case ACPI_REFCLASS_LOCAL:
261 261
262 if (index > ACPI_METHOD_MAX_LOCAL) { 262 if (index > ACPI_METHOD_MAX_LOCAL) {
263 ACPI_ERROR((AE_INFO, 263 ACPI_ERROR((AE_INFO,
@@ -271,7 +271,7 @@ acpi_ds_method_data_get_node(u16 opcode,
271 *node = &walk_state->local_variables[index]; 271 *node = &walk_state->local_variables[index];
272 break; 272 break;
273 273
274 case AML_ARG_OP: 274 case ACPI_REFCLASS_ARG:
275 275
276 if (index > ACPI_METHOD_MAX_ARG) { 276 if (index > ACPI_METHOD_MAX_ARG) {
277 ACPI_ERROR((AE_INFO, 277 ACPI_ERROR((AE_INFO,
@@ -286,8 +286,8 @@ acpi_ds_method_data_get_node(u16 opcode,
286 break; 286 break;
287 287
288 default: 288 default:
289 ACPI_ERROR((AE_INFO, "Opcode %d is invalid", opcode)); 289 ACPI_ERROR((AE_INFO, "Type %d is invalid", type));
290 return_ACPI_STATUS(AE_AML_BAD_OPCODE); 290 return_ACPI_STATUS(AE_TYPE);
291 } 291 }
292 292
293 return_ACPI_STATUS(AE_OK); 293 return_ACPI_STATUS(AE_OK);
@@ -297,7 +297,8 @@ acpi_ds_method_data_get_node(u16 opcode,
297 * 297 *
298 * FUNCTION: acpi_ds_method_data_set_value 298 * FUNCTION: acpi_ds_method_data_set_value
299 * 299 *
300 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 300 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
301 * ACPI_REFCLASS_ARG
301 * Index - Which Local or Arg to get 302 * Index - Which Local or Arg to get
302 * Object - Object to be inserted into the stack entry 303 * Object - Object to be inserted into the stack entry
303 * walk_state - Current walk state object 304 * walk_state - Current walk state object
@@ -310,7 +311,7 @@ acpi_ds_method_data_get_node(u16 opcode,
310 ******************************************************************************/ 311 ******************************************************************************/
311 312
312static acpi_status 313static acpi_status
313acpi_ds_method_data_set_value(u16 opcode, 314acpi_ds_method_data_set_value(u8 type,
314 u32 index, 315 u32 index,
315 union acpi_operand_object *object, 316 union acpi_operand_object *object,
316 struct acpi_walk_state *walk_state) 317 struct acpi_walk_state *walk_state)
@@ -321,13 +322,13 @@ acpi_ds_method_data_set_value(u16 opcode,
321 ACPI_FUNCTION_TRACE(ds_method_data_set_value); 322 ACPI_FUNCTION_TRACE(ds_method_data_set_value);
322 323
323 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 324 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
324 "NewObj %p Opcode %X, Refs=%d [%s]\n", object, 325 "NewObj %p Type %2.2X, Refs=%d [%s]\n", object,
325 opcode, object->common.reference_count, 326 type, object->common.reference_count,
326 acpi_ut_get_type_name(object->common.type))); 327 acpi_ut_get_type_name(object->common.type)));
327 328
328 /* Get the namespace node for the arg/local */ 329 /* Get the namespace node for the arg/local */
329 330
330 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); 331 status = acpi_ds_method_data_get_node(type, index, walk_state, &node);
331 if (ACPI_FAILURE(status)) { 332 if (ACPI_FAILURE(status)) {
332 return_ACPI_STATUS(status); 333 return_ACPI_STATUS(status);
333 } 334 }
@@ -350,7 +351,8 @@ acpi_ds_method_data_set_value(u16 opcode,
350 * 351 *
351 * FUNCTION: acpi_ds_method_data_get_value 352 * FUNCTION: acpi_ds_method_data_get_value
352 * 353 *
353 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 354 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
355 * ACPI_REFCLASS_ARG
354 * Index - Which local_var or argument to get 356 * Index - Which local_var or argument to get
355 * walk_state - Current walk state object 357 * walk_state - Current walk state object
356 * dest_desc - Where Arg or Local value is returned 358 * dest_desc - Where Arg or Local value is returned
@@ -363,7 +365,7 @@ acpi_ds_method_data_set_value(u16 opcode,
363 ******************************************************************************/ 365 ******************************************************************************/
364 366
365acpi_status 367acpi_status
366acpi_ds_method_data_get_value(u16 opcode, 368acpi_ds_method_data_get_value(u8 type,
367 u32 index, 369 u32 index,
368 struct acpi_walk_state *walk_state, 370 struct acpi_walk_state *walk_state,
369 union acpi_operand_object **dest_desc) 371 union acpi_operand_object **dest_desc)
@@ -383,7 +385,7 @@ acpi_ds_method_data_get_value(u16 opcode,
383 385
384 /* Get the namespace node for the arg/local */ 386 /* Get the namespace node for the arg/local */
385 387
386 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); 388 status = acpi_ds_method_data_get_node(type, index, walk_state, &node);
387 if (ACPI_FAILURE(status)) { 389 if (ACPI_FAILURE(status)) {
388 return_ACPI_STATUS(status); 390 return_ACPI_STATUS(status);
389 } 391 }
@@ -419,8 +421,8 @@ acpi_ds_method_data_get_value(u16 opcode,
419 /* Otherwise, return the error */ 421 /* Otherwise, return the error */
420 422
421 else 423 else
422 switch (opcode) { 424 switch (type) {
423 case AML_ARG_OP: 425 case ACPI_REFCLASS_ARG:
424 426
425 ACPI_ERROR((AE_INFO, 427 ACPI_ERROR((AE_INFO,
426 "Uninitialized Arg[%d] at node %p", 428 "Uninitialized Arg[%d] at node %p",
@@ -428,7 +430,7 @@ acpi_ds_method_data_get_value(u16 opcode,
428 430
429 return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG); 431 return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG);
430 432
431 case AML_LOCAL_OP: 433 case ACPI_REFCLASS_LOCAL:
432 434
433 ACPI_ERROR((AE_INFO, 435 ACPI_ERROR((AE_INFO,
434 "Uninitialized Local[%d] at node %p", 436 "Uninitialized Local[%d] at node %p",
@@ -437,9 +439,10 @@ acpi_ds_method_data_get_value(u16 opcode,
437 return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL); 439 return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL);
438 440
439 default: 441 default:
442
440 ACPI_ERROR((AE_INFO, 443 ACPI_ERROR((AE_INFO,
441 "Not a Arg/Local opcode: %X", 444 "Not a Arg/Local opcode: %X",
442 opcode)); 445 type));
443 return_ACPI_STATUS(AE_AML_INTERNAL); 446 return_ACPI_STATUS(AE_AML_INTERNAL);
444 } 447 }
445 } 448 }
@@ -458,7 +461,8 @@ acpi_ds_method_data_get_value(u16 opcode,
458 * 461 *
459 * FUNCTION: acpi_ds_method_data_delete_value 462 * FUNCTION: acpi_ds_method_data_delete_value
460 * 463 *
461 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 464 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
465 * ACPI_REFCLASS_ARG
462 * Index - Which local_var or argument to delete 466 * Index - Which local_var or argument to delete
463 * walk_state - Current walk state object 467 * walk_state - Current walk state object
464 * 468 *
@@ -470,7 +474,7 @@ acpi_ds_method_data_get_value(u16 opcode,
470 ******************************************************************************/ 474 ******************************************************************************/
471 475
472static void 476static void
473acpi_ds_method_data_delete_value(u16 opcode, 477acpi_ds_method_data_delete_value(u8 type,
474 u32 index, struct acpi_walk_state *walk_state) 478 u32 index, struct acpi_walk_state *walk_state)
475{ 479{
476 acpi_status status; 480 acpi_status status;
@@ -481,7 +485,7 @@ acpi_ds_method_data_delete_value(u16 opcode,
481 485
482 /* Get the namespace node for the arg/local */ 486 /* Get the namespace node for the arg/local */
483 487
484 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); 488 status = acpi_ds_method_data_get_node(type, index, walk_state, &node);
485 if (ACPI_FAILURE(status)) { 489 if (ACPI_FAILURE(status)) {
486 return_VOID; 490 return_VOID;
487 } 491 }
@@ -514,7 +518,8 @@ acpi_ds_method_data_delete_value(u16 opcode,
514 * 518 *
515 * FUNCTION: acpi_ds_store_object_to_local 519 * FUNCTION: acpi_ds_store_object_to_local
516 * 520 *
517 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP 521 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
522 * ACPI_REFCLASS_ARG
518 * Index - Which Local or Arg to set 523 * Index - Which Local or Arg to set
519 * obj_desc - Value to be stored 524 * obj_desc - Value to be stored
520 * walk_state - Current walk state 525 * walk_state - Current walk state
@@ -528,7 +533,7 @@ acpi_ds_method_data_delete_value(u16 opcode,
528 ******************************************************************************/ 533 ******************************************************************************/
529 534
530acpi_status 535acpi_status
531acpi_ds_store_object_to_local(u16 opcode, 536acpi_ds_store_object_to_local(u8 type,
532 u32 index, 537 u32 index,
533 union acpi_operand_object *obj_desc, 538 union acpi_operand_object *obj_desc,
534 struct acpi_walk_state *walk_state) 539 struct acpi_walk_state *walk_state)
@@ -539,8 +544,8 @@ acpi_ds_store_object_to_local(u16 opcode,
539 union acpi_operand_object *new_obj_desc; 544 union acpi_operand_object *new_obj_desc;
540 545
541 ACPI_FUNCTION_TRACE(ds_store_object_to_local); 546 ACPI_FUNCTION_TRACE(ds_store_object_to_local);
542 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n", 547 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Type=%2.2X Index=%d Obj=%p\n",
543 opcode, index, obj_desc)); 548 type, index, obj_desc));
544 549
545 /* Parameter validation */ 550 /* Parameter validation */
546 551
@@ -550,7 +555,7 @@ acpi_ds_store_object_to_local(u16 opcode,
550 555
551 /* Get the namespace node for the arg/local */ 556 /* Get the namespace node for the arg/local */
552 557
553 status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node); 558 status = acpi_ds_method_data_get_node(type, index, walk_state, &node);
554 if (ACPI_FAILURE(status)) { 559 if (ACPI_FAILURE(status)) {
555 return_ACPI_STATUS(status); 560 return_ACPI_STATUS(status);
556 } 561 }
@@ -602,7 +607,7 @@ acpi_ds_store_object_to_local(u16 opcode,
602 * 607 *
603 * Weird, but true. 608 * Weird, but true.
604 */ 609 */
605 if (opcode == AML_ARG_OP) { 610 if (type == ACPI_REFCLASS_ARG) {
606 /* 611 /*
607 * If we have a valid reference object that came from ref_of(), 612 * If we have a valid reference object that came from ref_of(),
608 * do the indirect store 613 * do the indirect store
@@ -611,8 +616,8 @@ acpi_ds_store_object_to_local(u16 opcode,
611 ACPI_DESC_TYPE_OPERAND) 616 ACPI_DESC_TYPE_OPERAND)
612 && (current_obj_desc->common.type == 617 && (current_obj_desc->common.type ==
613 ACPI_TYPE_LOCAL_REFERENCE) 618 ACPI_TYPE_LOCAL_REFERENCE)
614 && (current_obj_desc->reference.opcode == 619 && (current_obj_desc->reference.class ==
615 AML_REF_OF_OP)) { 620 ACPI_REFCLASS_REFOF)) {
616 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 621 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
617 "Arg (%p) is an ObjRef(Node), storing in node %p\n", 622 "Arg (%p) is an ObjRef(Node), storing in node %p\n",
618 new_obj_desc, 623 new_obj_desc,
@@ -640,11 +645,9 @@ acpi_ds_store_object_to_local(u16 opcode,
640 } 645 }
641 } 646 }
642 647
643 /* 648 /* Delete the existing object before storing the new one */
644 * Delete the existing object 649
645 * before storing the new one 650 acpi_ds_method_data_delete_value(type, index, walk_state);
646 */
647 acpi_ds_method_data_delete_value(opcode, index, walk_state);
648 } 651 }
649 652
650 /* 653 /*
@@ -653,7 +656,7 @@ acpi_ds_store_object_to_local(u16 opcode,
653 * (increments the object reference count by one) 656 * (increments the object reference count by one)
654 */ 657 */
655 status = 658 status =
656 acpi_ds_method_data_set_value(opcode, index, new_obj_desc, 659 acpi_ds_method_data_set_value(type, index, new_obj_desc,
657 walk_state); 660 walk_state);
658 661
659 /* Remove local reference if we copied the object above */ 662 /* Remove local reference if we copied the object above */
diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/dispatcher/dsobject.c
index 0f2805899210..4f08e599d07e 100644
--- a/drivers/acpi/dispatcher/dsobject.c
+++ b/drivers/acpi/dispatcher/dsobject.c
@@ -731,54 +731,70 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
731 switch (op_info->type) { 731 switch (op_info->type) {
732 case AML_TYPE_LOCAL_VARIABLE: 732 case AML_TYPE_LOCAL_VARIABLE:
733 733
734 /* Split the opcode into a base opcode + offset */ 734 /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */
735 735
736 obj_desc->reference.opcode = AML_LOCAL_OP; 736 obj_desc->reference.value = opcode - AML_LOCAL_OP;
737 obj_desc->reference.offset = opcode - AML_LOCAL_OP; 737 obj_desc->reference.class = ACPI_REFCLASS_LOCAL;
738 738
739#ifndef ACPI_NO_METHOD_EXECUTION 739#ifndef ACPI_NO_METHOD_EXECUTION
740 status = acpi_ds_method_data_get_node(AML_LOCAL_OP, 740 status =
741 obj_desc-> 741 acpi_ds_method_data_get_node(ACPI_REFCLASS_LOCAL,
742 reference.offset, 742 obj_desc->reference.
743 walk_state, 743 value, walk_state,
744 (struct 744 ACPI_CAST_INDIRECT_PTR
745 acpi_namespace_node 745 (struct
746 **)&obj_desc-> 746 acpi_namespace_node,
747 reference.object); 747 &obj_desc->reference.
748 object));
748#endif 749#endif
749 break; 750 break;
750 751
751 case AML_TYPE_METHOD_ARGUMENT: 752 case AML_TYPE_METHOD_ARGUMENT:
752 753
753 /* Split the opcode into a base opcode + offset */ 754 /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */
754 755
755 obj_desc->reference.opcode = AML_ARG_OP; 756 obj_desc->reference.value = opcode - AML_ARG_OP;
756 obj_desc->reference.offset = opcode - AML_ARG_OP; 757 obj_desc->reference.class = ACPI_REFCLASS_ARG;
757 758
758#ifndef ACPI_NO_METHOD_EXECUTION 759#ifndef ACPI_NO_METHOD_EXECUTION
759 status = acpi_ds_method_data_get_node(AML_ARG_OP, 760 status = acpi_ds_method_data_get_node(ACPI_REFCLASS_ARG,
760 obj_desc-> 761 obj_desc->
761 reference.offset, 762 reference.value,
762 walk_state, 763 walk_state,
764 ACPI_CAST_INDIRECT_PTR
763 (struct 765 (struct
764 acpi_namespace_node 766 acpi_namespace_node,
765 **)&obj_desc-> 767 &obj_desc->
766 reference.object); 768 reference.
769 object));
767#endif 770#endif
768 break; 771 break;
769 772
770 default: /* Other literals, etc.. */ 773 default: /* Object name or Debug object */
771 774
772 if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) { 775 switch (op->common.aml_opcode) {
776 case AML_INT_NAMEPATH_OP:
773 777
774 /* Node was saved in Op */ 778 /* Node was saved in Op */
775 779
776 obj_desc->reference.node = op->common.node; 780 obj_desc->reference.node = op->common.node;
777 obj_desc->reference.object = 781 obj_desc->reference.object =
778 op->common.node->object; 782 op->common.node->object;
779 } 783 obj_desc->reference.class = ACPI_REFCLASS_NAME;
784 break;
785
786 case AML_DEBUG_OP:
780 787
781 obj_desc->reference.opcode = opcode; 788 obj_desc->reference.class = ACPI_REFCLASS_DEBUG;
789 break;
790
791 default:
792
793 ACPI_ERROR((AE_INFO,
794 "Unimplemented reference type for AML opcode: %4.4X",
795 opcode));
796 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
797 }
782 break; 798 break;
783 } 799 }
784 break; 800 break;
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/dispatcher/dsopcode.c
index 6a81c4400edf..69fae5905bb8 100644
--- a/drivers/acpi/dispatcher/dsopcode.c
+++ b/drivers/acpi/dispatcher/dsopcode.c
@@ -1330,7 +1330,7 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1330 (walk_state->results->results.obj_desc[0]) == 1330 (walk_state->results->results.obj_desc[0]) ==
1331 ACPI_TYPE_LOCAL_REFERENCE) 1331 ACPI_TYPE_LOCAL_REFERENCE)
1332 && ((walk_state->results->results.obj_desc[0])-> 1332 && ((walk_state->results->results.obj_desc[0])->
1333 reference.opcode != AML_INDEX_OP)) { 1333 reference.class != ACPI_REFCLASS_INDEX)) {
1334 status = 1334 status =
1335 acpi_ex_resolve_to_value(&walk_state-> 1335 acpi_ex_resolve_to_value(&walk_state->
1336 results->results. 1336 results->results.
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/dispatcher/dswexec.c
index b5072fa9c920..396fe12078cd 100644
--- a/drivers/acpi/dispatcher/dswexec.c
+++ b/drivers/acpi/dispatcher/dswexec.c
@@ -166,6 +166,10 @@ acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
166 status = AE_CTRL_FALSE; 166 status = AE_CTRL_FALSE;
167 } 167 }
168 168
169 /* Predicate can be used for an implicit return value */
170
171 (void)acpi_ds_do_implicit_return(local_obj_desc, walk_state, TRUE);
172
169 cleanup: 173 cleanup:
170 174
171 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n", 175 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n",
@@ -429,10 +433,10 @@ acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
429 ACPI_TYPE_LOCAL_REFERENCE) 433 ACPI_TYPE_LOCAL_REFERENCE)
430 && (walk_state->operands[1]->common.type == 434 && (walk_state->operands[1]->common.type ==
431 ACPI_TYPE_LOCAL_REFERENCE) 435 ACPI_TYPE_LOCAL_REFERENCE)
432 && (walk_state->operands[0]->reference.opcode == 436 && (walk_state->operands[0]->reference.class ==
433 walk_state->operands[1]->reference.opcode) 437 walk_state->operands[1]->reference.class)
434 && (walk_state->operands[0]->reference.offset == 438 && (walk_state->operands[0]->reference.value ==
435 walk_state->operands[1]->reference.offset)) { 439 walk_state->operands[1]->reference.value)) {
436 status = AE_OK; 440 status = AE_OK;
437 } else { 441 } else {
438 ACPI_EXCEPTION((AE_INFO, status, 442 ACPI_EXCEPTION((AE_INFO, status,
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 13593f9f2197..4c004286b3d9 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -862,8 +862,19 @@ static int ec_install_handlers(struct acpi_ec *ec)
862 &acpi_ec_space_handler, 862 &acpi_ec_space_handler,
863 NULL, ec); 863 NULL, ec);
864 if (ACPI_FAILURE(status)) { 864 if (ACPI_FAILURE(status)) {
865 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler); 865 if (status == AE_NOT_FOUND) {
866 return -ENODEV; 866 /*
867 * Maybe OS fails in evaluating the _REG object.
868 * The AE_NOT_FOUND error will be ignored and OS
869 * continue to initialize EC.
870 */
871 printk(KERN_ERR "Fail in evaluating the _REG object"
872 " of EC device. Broken bios is suspected.\n");
873 } else {
874 acpi_remove_gpe_handler(NULL, ec->gpe,
875 &acpi_ec_gpe_handler);
876 return -ENODEV;
877 }
867 } 878 }
868 879
869 ec->handlers_installed = 1; 880 ec->handlers_installed = 1;
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/executer/exconfig.c
index 8892b9824fae..74da6fa52ef1 100644
--- a/drivers/acpi/executer/exconfig.c
+++ b/drivers/acpi/executer/exconfig.c
@@ -43,7 +43,6 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include <acpi/acinterp.h>
46#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48#include <acpi/actables.h> 47#include <acpi/actables.h>
49#include <acpi/acdispat.h> 48#include <acpi/acdispat.h>
@@ -91,13 +90,12 @@ acpi_ex_add_table(u32 table_index,
91 90
92 /* Init the table handle */ 91 /* Init the table handle */
93 92
94 obj_desc->reference.opcode = AML_LOAD_OP; 93 obj_desc->reference.class = ACPI_REFCLASS_TABLE;
95 *ddb_handle = obj_desc; 94 *ddb_handle = obj_desc;
96 95
97 /* Install the new table into the local data structures */ 96 /* Install the new table into the local data structures */
98 97
99 obj_desc->reference.object = ACPI_CAST_PTR(void, 98 obj_desc->reference.value = table_index;
100 (unsigned long)table_index);
101 99
102 /* Add the table to the namespace */ 100 /* Add the table to the namespace */
103 101
@@ -280,6 +278,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
280 struct acpi_walk_state *walk_state) 278 struct acpi_walk_state *walk_state)
281{ 279{
282 union acpi_operand_object *ddb_handle; 280 union acpi_operand_object *ddb_handle;
281 struct acpi_table_header *table;
283 struct acpi_table_desc table_desc; 282 struct acpi_table_desc table_desc;
284 u32 table_index; 283 u32 table_index;
285 acpi_status status; 284 acpi_status status;
@@ -294,9 +293,8 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
294 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 293 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
295 case ACPI_TYPE_REGION: 294 case ACPI_TYPE_REGION:
296 295
297 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Load from Region %p %s\n", 296 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
298 obj_desc, 297 "Load table from Region %p\n", obj_desc));
299 acpi_ut_get_object_type_name(obj_desc)));
300 298
301 /* Region must be system_memory (from ACPI spec) */ 299 /* Region must be system_memory (from ACPI spec) */
302 300
@@ -316,61 +314,112 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
316 } 314 }
317 315
318 /* 316 /*
319 * We will simply map the memory region for the table. However, the 317 * Map the table header and get the actual table length. The region
320 * memory region is technically not guaranteed to remain stable and 318 * length is not guaranteed to be the same as the table length.
321 * we may eventually have to copy the table to a local buffer. 319 */
320 table = acpi_os_map_memory(obj_desc->region.address,
321 sizeof(struct acpi_table_header));
322 if (!table) {
323 return_ACPI_STATUS(AE_NO_MEMORY);
324 }
325
326 length = table->length;
327 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
328
329 /* Must have at least an ACPI table header */
330
331 if (length < sizeof(struct acpi_table_header)) {
332 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
333 }
334
335 /*
336 * The memory region is not guaranteed to remain stable and we must
337 * copy the table to a local buffer. For example, the memory region
338 * is corrupted after suspend on some machines. Dynamically loaded
339 * tables are usually small, so this overhead is minimal.
322 */ 340 */
341
342 /* Allocate a buffer for the table */
343
344 table_desc.pointer = ACPI_ALLOCATE(length);
345 if (!table_desc.pointer) {
346 return_ACPI_STATUS(AE_NO_MEMORY);
347 }
348
349 /* Map the entire table and copy it */
350
351 table = acpi_os_map_memory(obj_desc->region.address, length);
352 if (!table) {
353 ACPI_FREE(table_desc.pointer);
354 return_ACPI_STATUS(AE_NO_MEMORY);
355 }
356
357 ACPI_MEMCPY(table_desc.pointer, table, length);
358 acpi_os_unmap_memory(table, length);
359
323 table_desc.address = obj_desc->region.address; 360 table_desc.address = obj_desc->region.address;
324 table_desc.length = obj_desc->region.length;
325 table_desc.flags = ACPI_TABLE_ORIGIN_MAPPED;
326 break; 361 break;
327 362
328 case ACPI_TYPE_BUFFER: /* Buffer or resolved region_field */ 363 case ACPI_TYPE_BUFFER: /* Buffer or resolved region_field */
329 364
330 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 365 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
331 "Load from Buffer or Field %p %s\n", obj_desc, 366 "Load table from Buffer or Field %p\n",
332 acpi_ut_get_object_type_name(obj_desc))); 367 obj_desc));
333
334 length = obj_desc->buffer.length;
335 368
336 /* Must have at least an ACPI table header */ 369 /* Must have at least an ACPI table header */
337 370
338 if (length < sizeof(struct acpi_table_header)) { 371 if (obj_desc->buffer.length < sizeof(struct acpi_table_header)) {
339 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); 372 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
340 } 373 }
341 374
342 /* Validate checksum here. It won't get validated in tb_add_table */ 375 /* Get the actual table length from the table header */
343 376
344 status = 377 table =
345 acpi_tb_verify_checksum(ACPI_CAST_PTR 378 ACPI_CAST_PTR(struct acpi_table_header,
346 (struct acpi_table_header, 379 obj_desc->buffer.pointer);
347 obj_desc->buffer.pointer), length); 380 length = table->length;
348 if (ACPI_FAILURE(status)) { 381
349 return_ACPI_STATUS(status); 382 /* Table cannot extend beyond the buffer */
383
384 if (length > obj_desc->buffer.length) {
385 return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
386 }
387 if (length < sizeof(struct acpi_table_header)) {
388 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
350 } 389 }
351 390
352 /* 391 /*
353 * We need to copy the buffer since the original buffer could be 392 * Copy the table from the buffer because the buffer could be modified
354 * changed or deleted in the future 393 * or even deleted in the future
355 */ 394 */
356 table_desc.pointer = ACPI_ALLOCATE(length); 395 table_desc.pointer = ACPI_ALLOCATE(length);
357 if (!table_desc.pointer) { 396 if (!table_desc.pointer) {
358 return_ACPI_STATUS(AE_NO_MEMORY); 397 return_ACPI_STATUS(AE_NO_MEMORY);
359 } 398 }
360 399
361 ACPI_MEMCPY(table_desc.pointer, obj_desc->buffer.pointer, 400 ACPI_MEMCPY(table_desc.pointer, table, length);
362 length); 401 table_desc.address = ACPI_TO_INTEGER(table_desc.pointer);
363 table_desc.length = length;
364 table_desc.flags = ACPI_TABLE_ORIGIN_ALLOCATED;
365 break; 402 break;
366 403
367 default: 404 default:
368 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 405 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
369 } 406 }
370 407
371 /* 408 /* Validate table checksum (will not get validated in tb_add_table) */
372 * Install the new table into the local data structures 409
373 */ 410 status = acpi_tb_verify_checksum(table_desc.pointer, length);
411 if (ACPI_FAILURE(status)) {
412 ACPI_FREE(table_desc.pointer);
413 return_ACPI_STATUS(status);
414 }
415
416 /* Complete the table descriptor */
417
418 table_desc.length = length;
419 table_desc.flags = ACPI_TABLE_ORIGIN_ALLOCATED;
420
421 /* Install the new table into the local data structures */
422
374 status = acpi_tb_add_table(&table_desc, &table_index); 423 status = acpi_tb_add_table(&table_desc, &table_index);
375 if (ACPI_FAILURE(status)) { 424 if (ACPI_FAILURE(status)) {
376 goto cleanup; 425 goto cleanup;
@@ -379,7 +428,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
379 /* 428 /*
380 * Add the table to the namespace. 429 * Add the table to the namespace.
381 * 430 *
382 * Note: We load the table objects relative to the root of the namespace. 431 * Note: Load the table objects relative to the root of the namespace.
383 * This appears to go against the ACPI specification, but we do it for 432 * This appears to go against the ACPI specification, but we do it for
384 * compatibility with other ACPI implementations. 433 * compatibility with other ACPI implementations.
385 */ 434 */
@@ -415,7 +464,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
415 cleanup: 464 cleanup:
416 if (ACPI_FAILURE(status)) { 465 if (ACPI_FAILURE(status)) {
417 466
418 /* Delete allocated buffer or mapping */ 467 /* Delete allocated table buffer */
419 468
420 acpi_tb_delete_table(&table_desc); 469 acpi_tb_delete_table(&table_desc);
421 } 470 }
@@ -455,9 +504,9 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
455 return_ACPI_STATUS(AE_BAD_PARAMETER); 504 return_ACPI_STATUS(AE_BAD_PARAMETER);
456 } 505 }
457 506
458 /* Get the table index from the ddb_handle (acpi_size for 64-bit case) */ 507 /* Get the table index from the ddb_handle */
459 508
460 table_index = (u32) (acpi_size) table_desc->reference.object; 509 table_index = table_desc->reference.value;
461 510
462 /* Invoke table handler if present */ 511 /* Invoke table handler if present */
463 512
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index 261d97516d9b..1d1f35adddde 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/executer/exconvrt.c
@@ -57,7 +57,7 @@ acpi_ex_convert_to_ascii(acpi_integer integer,
57 * 57 *
58 * FUNCTION: acpi_ex_convert_to_integer 58 * FUNCTION: acpi_ex_convert_to_integer
59 * 59 *
60 * PARAMETERS: obj_desc - Object to be converted. Must be an 60 * PARAMETERS: obj_desc - Object to be converted. Must be an
61 * Integer, Buffer, or String 61 * Integer, Buffer, or String
62 * result_desc - Where the new Integer object is returned 62 * result_desc - Where the new Integer object is returned
63 * Flags - Used for string conversion 63 * Flags - Used for string conversion
@@ -103,7 +103,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
103 } 103 }
104 104
105 /* 105 /*
106 * Convert the buffer/string to an integer. Note that both buffers and 106 * Convert the buffer/string to an integer. Note that both buffers and
107 * strings are treated as raw data - we don't convert ascii to hex for 107 * strings are treated as raw data - we don't convert ascii to hex for
108 * strings. 108 * strings.
109 * 109 *
@@ -120,7 +120,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
120 120
121 /* 121 /*
122 * Convert string to an integer - for most cases, the string must be 122 * Convert string to an integer - for most cases, the string must be
123 * hexadecimal as per the ACPI specification. The only exception (as 123 * hexadecimal as per the ACPI specification. The only exception (as
124 * of ACPI 3.0) is that the to_integer() operator allows both decimal 124 * of ACPI 3.0) is that the to_integer() operator allows both decimal
125 * and hexadecimal strings (hex prefixed with "0x"). 125 * and hexadecimal strings (hex prefixed with "0x").
126 */ 126 */
@@ -159,6 +159,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
159 break; 159 break;
160 160
161 default: 161 default:
162
162 /* No other types can get here */ 163 /* No other types can get here */
163 break; 164 break;
164 } 165 }
@@ -185,7 +186,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
185 * 186 *
186 * FUNCTION: acpi_ex_convert_to_buffer 187 * FUNCTION: acpi_ex_convert_to_buffer
187 * 188 *
188 * PARAMETERS: obj_desc - Object to be converted. Must be an 189 * PARAMETERS: obj_desc - Object to be converted. Must be an
189 * Integer, Buffer, or String 190 * Integer, Buffer, or String
190 * result_desc - Where the new buffer object is returned 191 * result_desc - Where the new buffer object is returned
191 * 192 *
@@ -365,7 +366,7 @@ acpi_ex_convert_to_ascii(acpi_integer integer,
365 } 366 }
366 367
367 /* 368 /*
368 * Since leading zeros are supressed, we must check for the case where 369 * Since leading zeros are suppressed, we must check for the case where
369 * the integer equals 0 370 * the integer equals 0
370 * 371 *
371 * Finally, null terminate the string and return the length 372 * Finally, null terminate the string and return the length
@@ -383,7 +384,7 @@ acpi_ex_convert_to_ascii(acpi_integer integer,
383 * 384 *
384 * FUNCTION: acpi_ex_convert_to_string 385 * FUNCTION: acpi_ex_convert_to_string
385 * 386 *
386 * PARAMETERS: obj_desc - Object to be converted. Must be an 387 * PARAMETERS: obj_desc - Object to be converted. Must be an
387 * Integer, Buffer, or String 388 * Integer, Buffer, or String
388 * result_desc - Where the string object is returned 389 * result_desc - Where the string object is returned
389 * Type - String flags (base and conversion type) 390 * Type - String flags (base and conversion type)
@@ -472,7 +473,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
472 base = 10; 473 base = 10;
473 474
474 /* 475 /*
475 * Calculate the final string length. Individual string values 476 * Calculate the final string length. Individual string values
476 * are variable length (include separator for each) 477 * are variable length (include separator for each)
477 */ 478 */
478 for (i = 0; i < obj_desc->buffer.length; i++) { 479 for (i = 0; i < obj_desc->buffer.length; i++) {
@@ -511,9 +512,14 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
511 /* 512 /*
512 * Create a new string object and string buffer 513 * Create a new string object and string buffer
513 * (-1 because of extra separator included in string_length from above) 514 * (-1 because of extra separator included in string_length from above)
515 * Allow creation of zero-length strings from zero-length buffers.
514 */ 516 */
517 if (string_length) {
518 string_length--;
519 }
520
515 return_desc = acpi_ut_create_string_object((acpi_size) 521 return_desc = acpi_ut_create_string_object((acpi_size)
516 (string_length - 1)); 522 string_length);
517 if (!return_desc) { 523 if (!return_desc) {
518 return_ACPI_STATUS(AE_NO_MEMORY); 524 return_ACPI_STATUS(AE_NO_MEMORY);
519 } 525 }
@@ -536,7 +542,9 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
536 * Null terminate the string 542 * Null terminate the string
537 * (overwrites final comma/space from above) 543 * (overwrites final comma/space from above)
538 */ 544 */
539 new_buf--; 545 if (obj_desc->buffer.length) {
546 new_buf--;
547 }
540 *new_buf = 0; 548 *new_buf = 0;
541 break; 549 break;
542 550
@@ -617,7 +625,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
617 case ACPI_TYPE_LOCAL_BANK_FIELD: 625 case ACPI_TYPE_LOCAL_BANK_FIELD:
618 case ACPI_TYPE_LOCAL_INDEX_FIELD: 626 case ACPI_TYPE_LOCAL_INDEX_FIELD:
619 /* 627 /*
620 * These types require an Integer operand. We can convert 628 * These types require an Integer operand. We can convert
621 * a Buffer or a String to an Integer if necessary. 629 * a Buffer or a String to an Integer if necessary.
622 */ 630 */
623 status = 631 status =
@@ -627,7 +635,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
627 635
628 case ACPI_TYPE_STRING: 636 case ACPI_TYPE_STRING:
629 /* 637 /*
630 * The operand must be a String. We can convert an 638 * The operand must be a String. We can convert an
631 * Integer or Buffer if necessary 639 * Integer or Buffer if necessary
632 */ 640 */
633 status = 641 status =
@@ -637,7 +645,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
637 645
638 case ACPI_TYPE_BUFFER: 646 case ACPI_TYPE_BUFFER:
639 /* 647 /*
640 * The operand must be a Buffer. We can convert an 648 * The operand must be a Buffer. We can convert an
641 * Integer or String if necessary 649 * Integer or String if necessary
642 */ 650 */
643 status = 651 status =
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index 2be2e2bf95bf..d087a7d28aa5 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -45,7 +45,6 @@
45#include <acpi/acinterp.h> 45#include <acpi/acinterp.h>
46#include <acpi/amlcode.h> 46#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h> 47#include <acpi/acnamesp.h>
48#include <acpi/acparser.h>
49 48
50#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exdump") 50ACPI_MODULE_NAME("exdump")
@@ -214,10 +213,11 @@ static struct acpi_exdump_info acpi_ex_dump_index_field[5] = {
214 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.data_obj), "Data Object"} 213 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(index_field.data_obj), "Data Object"}
215}; 214};
216 215
217static struct acpi_exdump_info acpi_ex_dump_reference[7] = { 216static struct acpi_exdump_info acpi_ex_dump_reference[8] = {
218 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_reference), NULL}, 217 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_reference), NULL},
218 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.class), "Class"},
219 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"}, 219 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(reference.target_type), "Target Type"},
220 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.offset), "Offset"}, 220 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(reference.value), "Value"},
221 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"}, 221 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.object), "Object Desc"},
222 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.node), "Node"}, 222 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.node), "Node"},
223 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"}, 223 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(reference.where), "Where"},
@@ -413,10 +413,10 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
413 413
414 case ACPI_EXD_REFERENCE: 414 case ACPI_EXD_REFERENCE:
415 415
416 acpi_ex_out_string("Opcode", 416 acpi_ex_out_string("Class Name",
417 (acpi_ps_get_opcode_info 417 (char *)
418 (obj_desc->reference.opcode))-> 418 acpi_ut_get_reference_name
419 name); 419 (obj_desc));
420 acpi_ex_dump_reference_obj(obj_desc); 420 acpi_ex_dump_reference_obj(obj_desc);
421 break; 421 break;
422 422
@@ -494,40 +494,41 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
494 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 494 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
495 case ACPI_TYPE_LOCAL_REFERENCE: 495 case ACPI_TYPE_LOCAL_REFERENCE:
496 496
497 switch (obj_desc->reference.opcode) { 497 acpi_os_printf("Reference: [%s] ",
498 case AML_DEBUG_OP: 498 acpi_ut_get_reference_name(obj_desc));
499
500 switch (obj_desc->reference.class) {
501 case ACPI_REFCLASS_DEBUG:
499 502
500 acpi_os_printf("Reference: Debug\n"); 503 acpi_os_printf("\n");
501 break; 504 break;
502 505
503 case AML_INDEX_OP: 506 case ACPI_REFCLASS_INDEX:
504 507
505 acpi_os_printf("Reference: Index %p\n", 508 acpi_os_printf("%p\n", obj_desc->reference.object);
506 obj_desc->reference.object);
507 break; 509 break;
508 510
509 case AML_LOAD_OP: 511 case ACPI_REFCLASS_TABLE:
510 512
511 acpi_os_printf("Reference: [DdbHandle] TableIndex %p\n", 513 acpi_os_printf("Table Index %X\n",
512 obj_desc->reference.object); 514 obj_desc->reference.value);
513 break; 515 break;
514 516
515 case AML_REF_OF_OP: 517 case ACPI_REFCLASS_REFOF:
516 518
517 acpi_os_printf("Reference: (RefOf) %p [%s]\n", 519 acpi_os_printf("%p [%s]\n", obj_desc->reference.object,
518 obj_desc->reference.object,
519 acpi_ut_get_type_name(((union 520 acpi_ut_get_type_name(((union
520 acpi_operand_object 521 acpi_operand_object
521 *)obj_desc-> 522 *)
523 obj_desc->
522 reference. 524 reference.
523 object)->common. 525 object)->common.
524 type)); 526 type));
525 break; 527 break;
526 528
527 case AML_ARG_OP: 529 case ACPI_REFCLASS_ARG:
528 530
529 acpi_os_printf("Reference: Arg%d", 531 acpi_os_printf("%X", obj_desc->reference.value);
530 obj_desc->reference.offset);
531 532
532 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { 533 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
533 534
@@ -542,10 +543,9 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
542 acpi_os_printf("\n"); 543 acpi_os_printf("\n");
543 break; 544 break;
544 545
545 case AML_LOCAL_OP: 546 case ACPI_REFCLASS_LOCAL:
546 547
547 acpi_os_printf("Reference: Local%d", 548 acpi_os_printf("%X", obj_desc->reference.value);
548 obj_desc->reference.offset);
549 549
550 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { 550 if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) {
551 551
@@ -560,21 +560,16 @@ void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth)
560 acpi_os_printf("\n"); 560 acpi_os_printf("\n");
561 break; 561 break;
562 562
563 case AML_INT_NAMEPATH_OP: 563 case ACPI_REFCLASS_NAME:
564 564
565 acpi_os_printf("Reference: Namepath %X [%4.4s]\n", 565 acpi_os_printf("- [%4.4s]\n",
566 obj_desc->reference.node->name.integer,
567 obj_desc->reference.node->name.ascii); 566 obj_desc->reference.node->name.ascii);
568 break; 567 break;
569 568
570 default: 569 default: /* Unknown reference class */
571
572 /* Unknown opcode */
573 570
574 acpi_os_printf("Unknown Reference opcode=%X\n", 571 acpi_os_printf("%2.2X\n", obj_desc->reference.class);
575 obj_desc->reference.opcode);
576 break; 572 break;
577
578 } 573 }
579 break; 574 break;
580 575
@@ -865,8 +860,8 @@ static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc)
865 860
866 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER; 861 ret_buf.length = ACPI_ALLOCATE_LOCAL_BUFFER;
867 862
868 if (obj_desc->reference.opcode == AML_INT_NAMEPATH_OP) { 863 if (obj_desc->reference.class == ACPI_REFCLASS_NAME) {
869 acpi_os_printf(" Named Object %p ", obj_desc->reference.node); 864 acpi_os_printf(" %p ", obj_desc->reference.node);
870 865
871 status = 866 status =
872 acpi_ns_handle_to_pathname(obj_desc->reference.node, 867 acpi_ns_handle_to_pathname(obj_desc->reference.node,
@@ -882,14 +877,12 @@ static void acpi_ex_dump_reference_obj(union acpi_operand_object *obj_desc)
882 ACPI_DESC_TYPE_OPERAND) { 877 ACPI_DESC_TYPE_OPERAND) {
883 acpi_os_printf(" Target: %p", 878 acpi_os_printf(" Target: %p",
884 obj_desc->reference.object); 879 obj_desc->reference.object);
885 if (obj_desc->reference.opcode == AML_LOAD_OP) { 880 if (obj_desc->reference.class == ACPI_REFCLASS_TABLE) {
886 /* 881 acpi_os_printf(" Table Index: %X\n",
887 * For DDBHandle reference, 882 obj_desc->reference.value);
888 * obj_desc->Reference.Object is the table index
889 */
890 acpi_os_printf(" [DDBHandle]\n");
891 } else { 883 } else {
892 acpi_os_printf(" [%s]\n", 884 acpi_os_printf(" Target: %p [%s]\n",
885 obj_desc->reference.object,
893 acpi_ut_get_type_name(((union 886 acpi_ut_get_type_name(((union
894 acpi_operand_object 887 acpi_operand_object
895 *) 888 *)
@@ -988,9 +981,9 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
988 981
989 case ACPI_TYPE_LOCAL_REFERENCE: 982 case ACPI_TYPE_LOCAL_REFERENCE:
990 983
991 acpi_os_printf("[Object Reference] %s", 984 acpi_os_printf("[Object Reference] Type [%s] %2.2X",
992 (acpi_ps_get_opcode_info 985 acpi_ut_get_reference_name(obj_desc),
993 (obj_desc->reference.opcode))->name); 986 obj_desc->reference.class);
994 acpi_ex_dump_reference_obj(obj_desc); 987 acpi_ex_dump_reference_obj(obj_desc);
995 break; 988 break;
996 989
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index 731414a581a6..efb191340059 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -86,10 +86,10 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
86 /* 86 /*
87 * Must be a reference to a Local or Arg 87 * Must be a reference to a Local or Arg
88 */ 88 */
89 switch (obj_desc->reference.opcode) { 89 switch (obj_desc->reference.class) {
90 case AML_LOCAL_OP: 90 case ACPI_REFCLASS_LOCAL:
91 case AML_ARG_OP: 91 case ACPI_REFCLASS_ARG:
92 case AML_DEBUG_OP: 92 case ACPI_REFCLASS_DEBUG:
93 93
94 /* The referenced object is the pseudo-node for the local/arg */ 94 /* The referenced object is the pseudo-node for the local/arg */
95 95
@@ -98,8 +98,8 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
98 98
99 default: 99 default:
100 100
101 ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X", 101 ACPI_ERROR((AE_INFO, "Unknown Reference Class %2.2X",
102 obj_desc->reference.opcode)); 102 obj_desc->reference.class));
103 return_ACPI_STATUS(AE_AML_INTERNAL); 103 return_ACPI_STATUS(AE_AML_INTERNAL);
104 } 104 }
105 break; 105 break;
@@ -127,7 +127,7 @@ acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
127 return_ACPI_STATUS(AE_NO_MEMORY); 127 return_ACPI_STATUS(AE_NO_MEMORY);
128 } 128 }
129 129
130 reference_obj->reference.opcode = AML_REF_OF_OP; 130 reference_obj->reference.class = ACPI_REFCLASS_REFOF;
131 reference_obj->reference.object = referenced_obj; 131 reference_obj->reference.object = referenced_obj;
132 *return_desc = reference_obj; 132 *return_desc = reference_obj;
133 133
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/executer/exoparg1.c
index 7c3bea575e02..f622f9eac8a1 100644
--- a/drivers/acpi/executer/exoparg1.c
+++ b/drivers/acpi/executer/exoparg1.c
@@ -825,16 +825,16 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
825 * 825 *
826 * Must resolve/dereference the local/arg reference first 826 * Must resolve/dereference the local/arg reference first
827 */ 827 */
828 switch (operand[0]->reference.opcode) { 828 switch (operand[0]->reference.class) {
829 case AML_LOCAL_OP: 829 case ACPI_REFCLASS_LOCAL:
830 case AML_ARG_OP: 830 case ACPI_REFCLASS_ARG:
831 831
832 /* Set Operand[0] to the value of the local/arg */ 832 /* Set Operand[0] to the value of the local/arg */
833 833
834 status = 834 status =
835 acpi_ds_method_data_get_value 835 acpi_ds_method_data_get_value
836 (operand[0]->reference.opcode, 836 (operand[0]->reference.class,
837 operand[0]->reference.offset, 837 operand[0]->reference.value,
838 walk_state, &temp_desc); 838 walk_state, &temp_desc);
839 if (ACPI_FAILURE(status)) { 839 if (ACPI_FAILURE(status)) {
840 goto cleanup; 840 goto cleanup;
@@ -848,7 +848,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
848 operand[0] = temp_desc; 848 operand[0] = temp_desc;
849 break; 849 break;
850 850
851 case AML_REF_OF_OP: 851 case ACPI_REFCLASS_REFOF:
852 852
853 /* Get the object to which the reference refers */ 853 /* Get the object to which the reference refers */
854 854
@@ -928,8 +928,8 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
928 * This must be a reference object produced by either the 928 * This must be a reference object produced by either the
929 * Index() or ref_of() operator 929 * Index() or ref_of() operator
930 */ 930 */
931 switch (operand[0]->reference.opcode) { 931 switch (operand[0]->reference.class) {
932 case AML_INDEX_OP: 932 case ACPI_REFCLASS_INDEX:
933 933
934 /* 934 /*
935 * The target type for the Index operator must be 935 * The target type for the Index operator must be
@@ -965,7 +965,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
965 return_desc->integer.value = 965 return_desc->integer.value =
966 temp_desc->buffer. 966 temp_desc->buffer.
967 pointer[operand[0]->reference. 967 pointer[operand[0]->reference.
968 offset]; 968 value];
969 break; 969 break;
970 970
971 case ACPI_TYPE_PACKAGE: 971 case ACPI_TYPE_PACKAGE:
@@ -985,7 +985,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
985 default: 985 default:
986 986
987 ACPI_ERROR((AE_INFO, 987 ACPI_ERROR((AE_INFO,
988 "Unknown Index TargetType %X in obj %p", 988 "Unknown Index TargetType %X in reference object %p",
989 operand[0]->reference. 989 operand[0]->reference.
990 target_type, operand[0])); 990 target_type, operand[0]));
991 status = AE_AML_OPERAND_TYPE; 991 status = AE_AML_OPERAND_TYPE;
@@ -993,7 +993,7 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
993 } 993 }
994 break; 994 break;
995 995
996 case AML_REF_OF_OP: 996 case ACPI_REFCLASS_REFOF:
997 997
998 return_desc = operand[0]->reference.object; 998 return_desc = operand[0]->reference.object;
999 999
@@ -1013,9 +1013,9 @@ acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state)
1013 1013
1014 default: 1014 default:
1015 ACPI_ERROR((AE_INFO, 1015 ACPI_ERROR((AE_INFO,
1016 "Unknown opcode in reference(%p) - %X", 1016 "Unknown class in reference(%p) - %2.2X",
1017 operand[0], 1017 operand[0],
1018 operand[0]->reference.opcode)); 1018 operand[0]->reference.class));
1019 1019
1020 status = AE_TYPE; 1020 status = AE_TYPE;
1021 goto cleanup; 1021 goto cleanup;
diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c
index 8e8bbb6ccebd..368def5dffce 100644
--- a/drivers/acpi/executer/exoparg2.c
+++ b/drivers/acpi/executer/exoparg2.c
@@ -391,8 +391,8 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
391 /* Initialize the Index reference object */ 391 /* Initialize the Index reference object */
392 392
393 index = operand[1]->integer.value; 393 index = operand[1]->integer.value;
394 return_desc->reference.offset = (u32) index; 394 return_desc->reference.value = (u32) index;
395 return_desc->reference.opcode = AML_INDEX_OP; 395 return_desc->reference.class = ACPI_REFCLASS_INDEX;
396 396
397 /* 397 /*
398 * At this point, the Source operand is a String, Buffer, or Package. 398 * At this point, the Source operand is a String, Buffer, or Package.
diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/executer/exresnte.c
index 5596f42c9676..423ad3635f3d 100644
--- a/drivers/acpi/executer/exresnte.c
+++ b/drivers/acpi/executer/exresnte.c
@@ -46,8 +46,6 @@
46#include <acpi/acdispat.h> 46#include <acpi/acdispat.h>
47#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
48#include <acpi/acnamesp.h> 48#include <acpi/acnamesp.h>
49#include <acpi/acparser.h>
50#include <acpi/amlcode.h>
51 49
52#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
53ACPI_MODULE_NAME("exresnte") 51ACPI_MODULE_NAME("exresnte")
@@ -238,10 +236,10 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
238 236
239 case ACPI_TYPE_LOCAL_REFERENCE: 237 case ACPI_TYPE_LOCAL_REFERENCE:
240 238
241 switch (source_desc->reference.opcode) { 239 switch (source_desc->reference.class) {
242 case AML_LOAD_OP: /* This is a ddb_handle */ 240 case ACPI_REFCLASS_TABLE: /* This is a ddb_handle */
243 case AML_REF_OF_OP: 241 case ACPI_REFCLASS_REFOF:
244 case AML_INDEX_OP: 242 case ACPI_REFCLASS_INDEX:
245 243
246 /* Return an additional reference to the object */ 244 /* Return an additional reference to the object */
247 245
@@ -253,10 +251,8 @@ acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
253 /* No named references are allowed here */ 251 /* No named references are allowed here */
254 252
255 ACPI_ERROR((AE_INFO, 253 ACPI_ERROR((AE_INFO,
256 "Unsupported Reference opcode %X (%s)", 254 "Unsupported Reference type %X",
257 source_desc->reference.opcode, 255 source_desc->reference.class));
258 acpi_ps_get_opcode_name(source_desc->
259 reference.opcode)));
260 256
261 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 257 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
262 } 258 }
diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/executer/exresolv.c
index b35f7c817acf..89571b92a522 100644
--- a/drivers/acpi/executer/exresolv.c
+++ b/drivers/acpi/executer/exresolv.c
@@ -47,7 +47,6 @@
47#include <acpi/acdispat.h> 47#include <acpi/acdispat.h>
48#include <acpi/acinterp.h> 48#include <acpi/acinterp.h>
49#include <acpi/acnamesp.h> 49#include <acpi/acnamesp.h>
50#include <acpi/acparser.h>
51 50
52#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
53ACPI_MODULE_NAME("exresolv") 52ACPI_MODULE_NAME("exresolv")
@@ -141,7 +140,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
141 acpi_status status = AE_OK; 140 acpi_status status = AE_OK;
142 union acpi_operand_object *stack_desc; 141 union acpi_operand_object *stack_desc;
143 union acpi_operand_object *obj_desc = NULL; 142 union acpi_operand_object *obj_desc = NULL;
144 u16 opcode; 143 u8 ref_type;
145 144
146 ACPI_FUNCTION_TRACE(ex_resolve_object_to_value); 145 ACPI_FUNCTION_TRACE(ex_resolve_object_to_value);
147 146
@@ -152,19 +151,19 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
152 switch (ACPI_GET_OBJECT_TYPE(stack_desc)) { 151 switch (ACPI_GET_OBJECT_TYPE(stack_desc)) {
153 case ACPI_TYPE_LOCAL_REFERENCE: 152 case ACPI_TYPE_LOCAL_REFERENCE:
154 153
155 opcode = stack_desc->reference.opcode; 154 ref_type = stack_desc->reference.class;
156 155
157 switch (opcode) { 156 switch (ref_type) {
158 case AML_LOCAL_OP: 157 case ACPI_REFCLASS_LOCAL:
159 case AML_ARG_OP: 158 case ACPI_REFCLASS_ARG:
160 159
161 /* 160 /*
162 * Get the local from the method's state info 161 * Get the local from the method's state info
163 * Note: this increments the local's object reference count 162 * Note: this increments the local's object reference count
164 */ 163 */
165 status = acpi_ds_method_data_get_value(opcode, 164 status = acpi_ds_method_data_get_value(ref_type,
166 stack_desc-> 165 stack_desc->
167 reference.offset, 166 reference.value,
168 walk_state, 167 walk_state,
169 &obj_desc); 168 &obj_desc);
170 if (ACPI_FAILURE(status)) { 169 if (ACPI_FAILURE(status)) {
@@ -173,7 +172,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
173 172
174 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 173 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
175 "[Arg/Local %X] ValueObj is %p\n", 174 "[Arg/Local %X] ValueObj is %p\n",
176 stack_desc->reference.offset, 175 stack_desc->reference.value,
177 obj_desc)); 176 obj_desc));
178 177
179 /* 178 /*
@@ -184,7 +183,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
184 *stack_ptr = obj_desc; 183 *stack_ptr = obj_desc;
185 break; 184 break;
186 185
187 case AML_INDEX_OP: 186 case ACPI_REFCLASS_INDEX:
188 187
189 switch (stack_desc->reference.target_type) { 188 switch (stack_desc->reference.target_type) {
190 case ACPI_TYPE_BUFFER_FIELD: 189 case ACPI_TYPE_BUFFER_FIELD:
@@ -239,15 +238,15 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
239 } 238 }
240 break; 239 break;
241 240
242 case AML_REF_OF_OP: 241 case ACPI_REFCLASS_REFOF:
243 case AML_DEBUG_OP: 242 case ACPI_REFCLASS_DEBUG:
244 case AML_LOAD_OP: 243 case ACPI_REFCLASS_TABLE:
245 244
246 /* Just leave the object as-is, do not dereference */ 245 /* Just leave the object as-is, do not dereference */
247 246
248 break; 247 break;
249 248
250 case AML_INT_NAMEPATH_OP: /* Reference to a named object */ 249 case ACPI_REFCLASS_NAME: /* Reference to a named object */
251 250
252 /* Dereference the name */ 251 /* Dereference the name */
253 252
@@ -273,8 +272,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
273 default: 272 default:
274 273
275 ACPI_ERROR((AE_INFO, 274 ACPI_ERROR((AE_INFO,
276 "Unknown Reference opcode %X (%s) in %p", 275 "Unknown Reference type %X in %p", ref_type,
277 opcode, acpi_ps_get_opcode_name(opcode),
278 stack_desc)); 276 stack_desc));
279 status = AE_AML_INTERNAL; 277 status = AE_AML_INTERNAL;
280 break; 278 break;
@@ -388,13 +386,13 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
388 * traversing the list of possibly many nested references. 386 * traversing the list of possibly many nested references.
389 */ 387 */
390 while (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) { 388 while (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_LOCAL_REFERENCE) {
391 switch (obj_desc->reference.opcode) { 389 switch (obj_desc->reference.class) {
392 case AML_REF_OF_OP: 390 case ACPI_REFCLASS_REFOF:
393 case AML_INT_NAMEPATH_OP: 391 case ACPI_REFCLASS_NAME:
394 392
395 /* Dereference the reference pointer */ 393 /* Dereference the reference pointer */
396 394
397 if (obj_desc->reference.opcode == AML_REF_OF_OP) { 395 if (obj_desc->reference.class == ACPI_REFCLASS_REFOF) {
398 node = obj_desc->reference.object; 396 node = obj_desc->reference.object;
399 } else { /* AML_INT_NAMEPATH_OP */ 397 } else { /* AML_INT_NAMEPATH_OP */
400 398
@@ -429,7 +427,7 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
429 } 427 }
430 break; 428 break;
431 429
432 case AML_INDEX_OP: 430 case ACPI_REFCLASS_INDEX:
433 431
434 /* Get the type of this reference (index into another object) */ 432 /* Get the type of this reference (index into another object) */
435 433
@@ -455,22 +453,22 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
455 } 453 }
456 break; 454 break;
457 455
458 case AML_LOAD_OP: 456 case ACPI_REFCLASS_TABLE:
459 457
460 type = ACPI_TYPE_DDB_HANDLE; 458 type = ACPI_TYPE_DDB_HANDLE;
461 goto exit; 459 goto exit;
462 460
463 case AML_LOCAL_OP: 461 case ACPI_REFCLASS_LOCAL:
464 case AML_ARG_OP: 462 case ACPI_REFCLASS_ARG:
465 463
466 if (return_desc) { 464 if (return_desc) {
467 status = 465 status =
468 acpi_ds_method_data_get_value(obj_desc-> 466 acpi_ds_method_data_get_value(obj_desc->
469 reference. 467 reference.
470 opcode, 468 class,
471 obj_desc-> 469 obj_desc->
472 reference. 470 reference.
473 offset, 471 value,
474 walk_state, 472 walk_state,
475 &obj_desc); 473 &obj_desc);
476 if (ACPI_FAILURE(status)) { 474 if (ACPI_FAILURE(status)) {
@@ -481,10 +479,10 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
481 status = 479 status =
482 acpi_ds_method_data_get_node(obj_desc-> 480 acpi_ds_method_data_get_node(obj_desc->
483 reference. 481 reference.
484 opcode, 482 class,
485 obj_desc-> 483 obj_desc->
486 reference. 484 reference.
487 offset, 485 value,
488 walk_state, 486 walk_state,
489 &node); 487 &node);
490 if (ACPI_FAILURE(status)) { 488 if (ACPI_FAILURE(status)) {
@@ -499,7 +497,7 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
499 } 497 }
500 break; 498 break;
501 499
502 case AML_DEBUG_OP: 500 case ACPI_REFCLASS_DEBUG:
503 501
504 /* The Debug Object is of type "DebugObject" */ 502 /* The Debug Object is of type "DebugObject" */
505 503
@@ -509,8 +507,8 @@ acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
509 default: 507 default:
510 508
511 ACPI_ERROR((AE_INFO, 509 ACPI_ERROR((AE_INFO,
512 "Unknown Reference subtype %X", 510 "Unknown Reference Class %2.2X",
513 obj_desc->reference.opcode)); 511 obj_desc->reference.class));
514 return_ACPI_STATUS(AE_AML_INTERNAL); 512 return_ACPI_STATUS(AE_AML_INTERNAL);
515 } 513 }
516 } 514 }
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/executer/exresop.c
index 54085f16ec28..0bb82593da72 100644
--- a/drivers/acpi/executer/exresop.c
+++ b/drivers/acpi/executer/exresop.c
@@ -225,41 +225,36 @@ acpi_ex_resolve_operands(u16 opcode,
225 225
226 if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) { 226 if (object_type == (u8) ACPI_TYPE_LOCAL_REFERENCE) {
227 227
228 /* Decode the Reference */ 228 /* Validate the Reference */
229 229
230 op_info = acpi_ps_get_opcode_info(opcode); 230 switch (obj_desc->reference.class) {
231 if (op_info->class == AML_CLASS_UNKNOWN) { 231 case ACPI_REFCLASS_DEBUG:
232 return_ACPI_STATUS(AE_AML_BAD_OPCODE);
233 }
234 232
235 switch (obj_desc->reference.opcode) {
236 case AML_DEBUG_OP:
237 target_op = AML_DEBUG_OP; 233 target_op = AML_DEBUG_OP;
238 234
239 /*lint -fallthrough */ 235 /*lint -fallthrough */
240 236
241 case AML_INDEX_OP: 237 case ACPI_REFCLASS_ARG:
242 case AML_REF_OF_OP: 238 case ACPI_REFCLASS_LOCAL:
243 case AML_ARG_OP: 239 case ACPI_REFCLASS_INDEX:
244 case AML_LOCAL_OP: 240 case ACPI_REFCLASS_REFOF:
245 case AML_LOAD_OP: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */ 241 case ACPI_REFCLASS_TABLE: /* ddb_handle from LOAD_OP or LOAD_TABLE_OP */
246 case AML_INT_NAMEPATH_OP: /* Reference to a named object */ 242 case ACPI_REFCLASS_NAME: /* Reference to a named object */
247 243
248 ACPI_DEBUG_ONLY_MEMBERS(ACPI_DEBUG_PRINT 244 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
249 ((ACPI_DB_EXEC, 245 "Operand is a Reference, Class [%s] %2.2X\n",
250 "Operand is a Reference, RefOpcode [%s]\n", 246 acpi_ut_get_reference_name
251 (acpi_ps_get_opcode_info 247 (obj_desc),
252 (obj_desc-> 248 obj_desc->reference.
253 reference. 249 class));
254 opcode))->
255 name)));
256 break; 250 break;
257 251
258 default: 252 default:
253
259 ACPI_ERROR((AE_INFO, 254 ACPI_ERROR((AE_INFO,
260 "Operand is a Reference, Unknown Reference Opcode: %X", 255 "Unknown Reference Class %2.2X in %p",
261 obj_desc->reference. 256 obj_desc->reference.class,
262 opcode)); 257 obj_desc));
263 258
264 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 259 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
265 } 260 }
@@ -270,8 +265,7 @@ acpi_ex_resolve_operands(u16 opcode,
270 265
271 /* Invalid descriptor */ 266 /* Invalid descriptor */
272 267
273 ACPI_ERROR((AE_INFO, 268 ACPI_ERROR((AE_INFO, "Invalid descriptor %p [%s]",
274 "Invalid descriptor %p [%s]",
275 obj_desc, 269 obj_desc,
276 acpi_ut_get_descriptor_name(obj_desc))); 270 acpi_ut_get_descriptor_name(obj_desc)));
277 271
@@ -343,7 +337,7 @@ acpi_ex_resolve_operands(u16 opcode,
343 if ((opcode == AML_STORE_OP) && 337 if ((opcode == AML_STORE_OP) &&
344 (ACPI_GET_OBJECT_TYPE(*stack_ptr) == 338 (ACPI_GET_OBJECT_TYPE(*stack_ptr) ==
345 ACPI_TYPE_LOCAL_REFERENCE) 339 ACPI_TYPE_LOCAL_REFERENCE)
346 && ((*stack_ptr)->reference.opcode == AML_INDEX_OP)) { 340 && ((*stack_ptr)->reference.class == ACPI_REFCLASS_INDEX)) {
347 goto next_operand; 341 goto next_operand;
348 } 342 }
349 break; 343 break;
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/executer/exstore.c
index 38b55e352495..3318df4cbd98 100644
--- a/drivers/acpi/executer/exstore.c
+++ b/drivers/acpi/executer/exstore.c
@@ -47,7 +47,6 @@
47#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
48#include <acpi/amlcode.h> 48#include <acpi/amlcode.h>
49#include <acpi/acnamesp.h> 49#include <acpi/acnamesp.h>
50#include <acpi/acparser.h>
51 50
52#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
53ACPI_MODULE_NAME("exstore") 52ACPI_MODULE_NAME("exstore")
@@ -179,22 +178,26 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
179 178
180 case ACPI_TYPE_LOCAL_REFERENCE: 179 case ACPI_TYPE_LOCAL_REFERENCE:
181 180
182 if (source_desc->reference.opcode == AML_INDEX_OP) { 181 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[%s] ",
183 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, 182 acpi_ut_get_reference_name(source_desc)));
184 "[%s, 0x%X]\n", 183
185 acpi_ps_get_opcode_name 184 /* Decode the reference */
186 (source_desc->reference.opcode), 185
187 source_desc->reference.offset)); 186 switch (source_desc->reference.class) {
188 } else { 187 case ACPI_REFCLASS_INDEX:
189 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[%s]", 188
190 acpi_ps_get_opcode_name 189 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "0x%X\n",
191 (source_desc->reference.opcode))); 190 source_desc->reference.value));
192 } 191 break;
192
193 case ACPI_REFCLASS_TABLE:
193 194
194 if (source_desc->reference.opcode == AML_LOAD_OP) { /* Load and load_table */
195 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, 195 ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
196 " Table OwnerId %p\n", 196 "Table Index 0x%X\n",
197 source_desc->reference.object)); 197 source_desc->reference.value));
198 break;
199
200 default:
198 break; 201 break;
199 } 202 }
200 203
@@ -347,15 +350,15 @@ acpi_ex_store(union acpi_operand_object *source_desc,
347 } 350 }
348 351
349 /* 352 /*
350 * Examine the Reference opcode. These cases are handled: 353 * Examine the Reference class. These cases are handled:
351 * 354 *
352 * 1) Store to Name (Change the object associated with a name) 355 * 1) Store to Name (Change the object associated with a name)
353 * 2) Store to an indexed area of a Buffer or Package 356 * 2) Store to an indexed area of a Buffer or Package
354 * 3) Store to a Method Local or Arg 357 * 3) Store to a Method Local or Arg
355 * 4) Store to the debug object 358 * 4) Store to the debug object
356 */ 359 */
357 switch (ref_desc->reference.opcode) { 360 switch (ref_desc->reference.class) {
358 case AML_REF_OF_OP: 361 case ACPI_REFCLASS_REFOF:
359 362
360 /* Storing an object into a Name "container" */ 363 /* Storing an object into a Name "container" */
361 364
@@ -365,7 +368,7 @@ acpi_ex_store(union acpi_operand_object *source_desc,
365 ACPI_IMPLICIT_CONVERSION); 368 ACPI_IMPLICIT_CONVERSION);
366 break; 369 break;
367 370
368 case AML_INDEX_OP: 371 case ACPI_REFCLASS_INDEX:
369 372
370 /* Storing to an Index (pointer into a packager or buffer) */ 373 /* Storing to an Index (pointer into a packager or buffer) */
371 374
@@ -374,18 +377,18 @@ acpi_ex_store(union acpi_operand_object *source_desc,
374 walk_state); 377 walk_state);
375 break; 378 break;
376 379
377 case AML_LOCAL_OP: 380 case ACPI_REFCLASS_LOCAL:
378 case AML_ARG_OP: 381 case ACPI_REFCLASS_ARG:
379 382
380 /* Store to a method local/arg */ 383 /* Store to a method local/arg */
381 384
382 status = 385 status =
383 acpi_ds_store_object_to_local(ref_desc->reference.opcode, 386 acpi_ds_store_object_to_local(ref_desc->reference.class,
384 ref_desc->reference.offset, 387 ref_desc->reference.value,
385 source_desc, walk_state); 388 source_desc, walk_state);
386 break; 389 break;
387 390
388 case AML_DEBUG_OP: 391 case ACPI_REFCLASS_DEBUG:
389 392
390 /* 393 /*
391 * Storing to the Debug object causes the value stored to be 394 * Storing to the Debug object causes the value stored to be
@@ -401,9 +404,9 @@ acpi_ex_store(union acpi_operand_object *source_desc,
401 404
402 default: 405 default:
403 406
404 ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X", 407 ACPI_ERROR((AE_INFO, "Unknown Reference Class %2.2X",
405 ref_desc->reference.opcode)); 408 ref_desc->reference.class));
406 ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR); 409 ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_INFO);
407 410
408 status = AE_AML_INTERNAL; 411 status = AE_AML_INTERNAL;
409 break; 412 break;
@@ -458,7 +461,7 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
458 461
459 if (ACPI_GET_OBJECT_TYPE(source_desc) == 462 if (ACPI_GET_OBJECT_TYPE(source_desc) ==
460 ACPI_TYPE_LOCAL_REFERENCE 463 ACPI_TYPE_LOCAL_REFERENCE
461 && source_desc->reference.opcode == AML_LOAD_OP) { 464 && source_desc->reference.class == ACPI_REFCLASS_TABLE) {
462 465
463 /* This is a DDBHandle, just add a reference to it */ 466 /* This is a DDBHandle, just add a reference to it */
464 467
@@ -553,7 +556,7 @@ acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
553 556
554 /* Store the source value into the target buffer byte */ 557 /* Store the source value into the target buffer byte */
555 558
556 obj_desc->buffer.pointer[index_desc->reference.offset] = value; 559 obj_desc->buffer.pointer[index_desc->reference.value] = value;
557 break; 560 break;
558 561
559 default: 562 default:
diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/executer/exstoren.c
index a6d2168b81f9..eef61a00803e 100644
--- a/drivers/acpi/executer/exstoren.c
+++ b/drivers/acpi/executer/exstoren.c
@@ -121,7 +121,8 @@ acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
121 (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) && 121 (ACPI_GET_OBJECT_TYPE(source_desc) != ACPI_TYPE_STRING) &&
122 !((ACPI_GET_OBJECT_TYPE(source_desc) == 122 !((ACPI_GET_OBJECT_TYPE(source_desc) ==
123 ACPI_TYPE_LOCAL_REFERENCE) 123 ACPI_TYPE_LOCAL_REFERENCE)
124 && (source_desc->reference.opcode == AML_LOAD_OP))) { 124 && (source_desc->reference.class ==
125 ACPI_REFCLASS_TABLE))) {
125 126
126 /* Conversion successful but still not a valid type */ 127 /* Conversion successful but still not a valid type */
127 128
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 2655bc1b4eeb..dfc0486ffaff 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -327,8 +327,8 @@ static int acpi_fan_resume(struct acpi_device *device)
327 327
328 result = acpi_bus_get_power(device->handle, &power_state); 328 result = acpi_bus_get_power(device->handle, &power_state);
329 if (result) { 329 if (result) {
330 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 330 printk(KERN_ERR PREFIX
331 "Error reading fan power state\n")); 331 "Error reading fan power state\n");
332 return result; 332 return result;
333 } 333 }
334 334
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 084109507c9f..8dd3336efd7e 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -165,8 +165,11 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
165 "firmware_node"); 165 "firmware_node");
166 ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, 166 ret = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
167 "physical_node"); 167 "physical_node");
168 if (acpi_dev->wakeup.flags.valid) 168 if (acpi_dev->wakeup.flags.valid) {
169 device_set_wakeup_capable(dev, true); 169 device_set_wakeup_capable(dev, true);
170 device_set_wakeup_enable(dev,
171 acpi_dev->wakeup.state.enabled);
172 }
170 } 173 }
171 174
172 return 0; 175 return 0;
diff --git a/drivers/acpi/namespace/Makefile b/drivers/acpi/namespace/Makefile
index 3f63d3640696..371a2daf837f 100644
--- a/drivers/acpi/namespace/Makefile
+++ b/drivers/acpi/namespace/Makefile
@@ -5,7 +5,7 @@
5obj-y := nsaccess.o nsload.o nssearch.o nsxfeval.o \ 5obj-y := nsaccess.o nsload.o nssearch.o nsxfeval.o \
6 nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \ 6 nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \
7 nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \ 7 nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \
8 nsparse.o 8 nsparse.o nspredef.o
9 9
10obj-$(ACPI_FUTURE_USAGE) += nsdumpdv.o 10obj-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
11 11
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/namespace/nsdump.c
index 0ab22004728a..cc0ae39440e4 100644
--- a/drivers/acpi/namespace/nsdump.c
+++ b/drivers/acpi/namespace/nsdump.c
@@ -43,7 +43,6 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
46#include <acpi/acparser.h>
47 46
48#define _COMPONENT ACPI_NAMESPACE 47#define _COMPONENT ACPI_NAMESPACE
49ACPI_MODULE_NAME("nsdump") 48ACPI_MODULE_NAME("nsdump")
@@ -334,9 +333,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
334 case ACPI_TYPE_LOCAL_REFERENCE: 333 case ACPI_TYPE_LOCAL_REFERENCE:
335 334
336 acpi_os_printf("[%s]\n", 335 acpi_os_printf("[%s]\n",
337 acpi_ps_get_opcode_name(obj_desc-> 336 acpi_ut_get_reference_name(obj_desc));
338 reference.
339 opcode));
340 break; 337 break;
341 338
342 case ACPI_TYPE_BUFFER_FIELD: 339 case ACPI_TYPE_BUFFER_FIELD:
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
index d369164e00b0..4cdf03ac2b46 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/namespace/nseval.c
@@ -78,6 +78,7 @@ ACPI_MODULE_NAME("nseval")
78acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info) 78acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
79{ 79{
80 acpi_status status; 80 acpi_status status;
81 struct acpi_namespace_node *node;
81 82
82 ACPI_FUNCTION_TRACE(ns_evaluate); 83 ACPI_FUNCTION_TRACE(ns_evaluate);
83 84
@@ -117,6 +118,8 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
117 info->resolved_node, 118 info->resolved_node,
118 acpi_ns_get_attached_object(info->resolved_node))); 119 acpi_ns_get_attached_object(info->resolved_node)));
119 120
121 node = info->resolved_node;
122
120 /* 123 /*
121 * Two major cases here: 124 * Two major cases here:
122 * 125 *
@@ -148,21 +151,22 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
148 info->param_count++; 151 info->param_count++;
149 } 152 }
150 153
151 /* Error if too few arguments were passed in */ 154 /*
155 * Warning if too few or too many arguments have been passed by the
156 * caller. We don't want to abort here with an error because an
157 * incorrect number of arguments may not cause the method to fail.
158 * However, the method will fail if there are too few arguments passed
159 * and the method attempts to use one of the missing ones.
160 */
152 161
153 if (info->param_count < info->obj_desc->method.param_count) { 162 if (info->param_count < info->obj_desc->method.param_count) {
154 ACPI_ERROR((AE_INFO, 163 ACPI_WARNING((AE_INFO,
155 "Insufficient arguments - " 164 "Insufficient arguments - "
156 "method [%4.4s] needs %d, found %d", 165 "method [%4.4s] needs %d, found %d",
157 acpi_ut_get_node_name(info->resolved_node), 166 acpi_ut_get_node_name(info->resolved_node),
158 info->obj_desc->method.param_count, 167 info->obj_desc->method.param_count,
159 info->param_count)); 168 info->param_count));
160 return_ACPI_STATUS(AE_MISSING_ARGUMENTS); 169 } else if (info->param_count >
161 }
162
163 /* Just a warning if too many arguments */
164
165 else if (info->param_count >
166 info->obj_desc->method.param_count) { 170 info->obj_desc->method.param_count) {
167 ACPI_WARNING((AE_INFO, 171 ACPI_WARNING((AE_INFO,
168 "Excess arguments - " 172 "Excess arguments - "
@@ -195,7 +199,28 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
195 } else { 199 } else {
196 /* 200 /*
197 * 2) Object is not a method, return its current value 201 * 2) Object is not a method, return its current value
202 *
203 * Disallow certain object types. For these, "evaluation" is undefined.
198 */ 204 */
205 switch (info->resolved_node->type) {
206 case ACPI_TYPE_DEVICE:
207 case ACPI_TYPE_EVENT:
208 case ACPI_TYPE_MUTEX:
209 case ACPI_TYPE_REGION:
210 case ACPI_TYPE_THERMAL:
211 case ACPI_TYPE_LOCAL_SCOPE:
212
213 ACPI_ERROR((AE_INFO,
214 "[%4.4s] Evaluation of object type [%s] is not supported",
215 info->resolved_node->name.ascii,
216 acpi_ut_get_type_name(info->resolved_node->
217 type)));
218
219 return_ACPI_STATUS(AE_TYPE);
220
221 default:
222 break;
223 }
199 224
200 /* 225 /*
201 * Objects require additional resolution steps (e.g., the Node may be 226 * Objects require additional resolution steps (e.g., the Node may be
@@ -239,9 +264,35 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
239 } 264 }
240 } 265 }
241 266
242 /* 267 /* Validation of return values for ACPI-predefined methods and objects */
243 * Check if there is a return value that must be dealt with 268
244 */ 269 if ((status == AE_OK) || (status == AE_CTRL_RETURN_VALUE)) {
270 /*
271 * If this is the first evaluation, check the return value. This
272 * ensures that any warnings will only be emitted during the very
273 * first evaluation of the object.
274 */
275 if (!(node->flags & ANOBJ_EVALUATED)) {
276 /*
277 * Check for a predefined ACPI name. If found, validate the
278 * returned object.
279 *
280 * Note: Ignore return status for now, emit warnings if there are
281 * problems with the returned object. May change later to abort
282 * the method on invalid return object.
283 */
284 (void)acpi_ns_check_predefined_names(node,
285 info->
286 return_object);
287 }
288
289 /* Mark the node as having been evaluated */
290
291 node->flags |= ANOBJ_EVALUATED;
292 }
293
294 /* Check if there is a return value that must be dealt with */
295
245 if (status == AE_CTRL_RETURN_VALUE) { 296 if (status == AE_CTRL_RETURN_VALUE) {
246 297
247 /* If caller does not want the return value, delete it */ 298 /* If caller does not want the return value, delete it */
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/namespace/nsnames.c
index bd5773878009..42a39a7c96e9 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/namespace/nsnames.c
@@ -115,7 +115,6 @@ acpi_ns_build_external_path(struct acpi_namespace_node *node,
115 return (AE_OK); 115 return (AE_OK);
116} 116}
117 117
118#ifdef ACPI_DEBUG_OUTPUT
119/******************************************************************************* 118/*******************************************************************************
120 * 119 *
121 * FUNCTION: acpi_ns_get_external_pathname 120 * FUNCTION: acpi_ns_get_external_pathname
@@ -142,7 +141,7 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
142 141
143 size = acpi_ns_get_pathname_length(node); 142 size = acpi_ns_get_pathname_length(node);
144 if (!size) { 143 if (!size) {
145 return (NULL); 144 return_PTR(NULL);
146 } 145 }
147 146
148 /* Allocate a buffer to be returned to caller */ 147 /* Allocate a buffer to be returned to caller */
@@ -157,12 +156,12 @@ char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node)
157 156
158 status = acpi_ns_build_external_path(node, size, name_buffer); 157 status = acpi_ns_build_external_path(node, size, name_buffer);
159 if (ACPI_FAILURE(status)) { 158 if (ACPI_FAILURE(status)) {
160 return (NULL); 159 ACPI_FREE(name_buffer);
160 return_PTR(NULL);
161 } 161 }
162 162
163 return_PTR(name_buffer); 163 return_PTR(name_buffer);
164} 164}
165#endif
166 165
167/******************************************************************************* 166/*******************************************************************************
168 * 167 *
diff --git a/drivers/acpi/namespace/nspredef.c b/drivers/acpi/namespace/nspredef.c
new file mode 100644
index 000000000000..0f17cf0898c9
--- /dev/null
+++ b/drivers/acpi/namespace/nspredef.c
@@ -0,0 +1,900 @@
1/******************************************************************************
2 *
3 * Module Name: nspredef - Validation of ACPI predefined methods and objects
4 * $Revision: 1.1 $
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2008, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h>
47#include <acpi/acpredef.h>
48
49#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nspredef")
51
52/*******************************************************************************
53 *
54 * This module validates predefined ACPI objects that appear in the namespace,
55 * at the time they are evaluated (via acpi_evaluate_object). The purpose of this
56 * validation is to detect problems with BIOS-exposed predefined ACPI objects
57 * before the results are returned to the ACPI-related drivers.
58 *
59 * There are several areas that are validated:
60 *
61 * 1) The number of input arguments as defined by the method/object in the
62 * ASL is validated against the ACPI specification.
63 * 2) The type of the return object (if any) is validated against the ACPI
64 * specification.
65 * 3) For returned package objects, the count of package elements is
66 * validated, as well as the type of each package element. Nested
67 * packages are supported.
68 *
69 * For any problems found, a warning message is issued.
70 *
71 ******************************************************************************/
72/* Local prototypes */
73static acpi_status
74acpi_ns_check_package(char *pathname,
75 union acpi_operand_object *return_object,
76 const union acpi_predefined_info *predefined);
77
78static acpi_status
79acpi_ns_check_package_elements(char *pathname,
80 union acpi_operand_object **elements,
81 u8 type1, u32 count1, u8 type2, u32 count2);
82
83static acpi_status
84acpi_ns_check_object_type(char *pathname,
85 union acpi_operand_object *return_object,
86 u32 expected_btypes, u32 package_index);
87
88static acpi_status
89acpi_ns_check_reference(char *pathname,
90 union acpi_operand_object *return_object);
91
92/*
93 * Names for the types that can be returned by the predefined objects.
94 * Used for warning messages. Must be in the same order as the ACPI_RTYPEs
95 */
96static const char *acpi_rtype_names[] = {
97 "/Integer",
98 "/String",
99 "/Buffer",
100 "/Package",
101 "/Reference",
102};
103
104#define ACPI_NOT_PACKAGE ACPI_UINT32_MAX
105
106/*******************************************************************************
107 *
108 * FUNCTION: acpi_ns_check_predefined_names
109 *
110 * PARAMETERS: Node - Namespace node for the method/object
111 * return_object - Object returned from the evaluation of this
112 * method/object
113 *
114 * RETURN: Status
115 *
116 * DESCRIPTION: Check an ACPI name for a match in the predefined name list.
117 *
118 ******************************************************************************/
119
120acpi_status
121acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
122 union acpi_operand_object *return_object)
123{
124 acpi_status status = AE_OK;
125 const union acpi_predefined_info *predefined;
126 char *pathname;
127
128 /* Match the name for this method/object against the predefined list */
129
130 predefined = acpi_ns_check_for_predefined_name(node);
131 if (!predefined) {
132
133 /* Name was not one of the predefined names */
134
135 return (AE_OK);
136 }
137
138 /* Get the full pathname to the object, for use in error messages */
139
140 pathname = acpi_ns_get_external_pathname(node);
141 if (!pathname) {
142 pathname = ACPI_CAST_PTR(char, predefined->info.name);
143 }
144
145 /*
146 * Check that the parameter count for this method is in accordance
147 * with the ACPI specification.
148 */
149 acpi_ns_check_parameter_count(pathname, node, predefined);
150
151 /*
152 * If there is no return value, check if we require a return value for
153 * this predefined name. Either one return value is expected, or none,
154 * for both methods and other objects.
155 *
156 * Exit now if there is no return object. Warning if one was expected.
157 */
158 if (!return_object) {
159 if ((predefined->info.expected_btypes) &&
160 (!(predefined->info.expected_btypes & ACPI_RTYPE_NONE))) {
161 ACPI_ERROR((AE_INFO,
162 "%s: Missing expected return value",
163 pathname));
164
165 status = AE_AML_NO_RETURN_VALUE;
166 }
167 goto exit;
168 }
169
170 /*
171 * We have a return value, but if one wasn't expected, just exit, this is
172 * not a problem
173 *
174 * For example, if "Implicit return value" is enabled, methods will
175 * always return a value
176 */
177 if (!predefined->info.expected_btypes) {
178 goto exit;
179 }
180
181 /*
182 * Check that the type of the return object is what is expected for
183 * this predefined name
184 */
185 status = acpi_ns_check_object_type(pathname, return_object,
186 predefined->info.expected_btypes,
187 ACPI_NOT_PACKAGE);
188 if (ACPI_FAILURE(status)) {
189 goto exit;
190 }
191
192 /* For returned Package objects, check the type of all sub-objects */
193
194 if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_PACKAGE) {
195 status =
196 acpi_ns_check_package(pathname, return_object, predefined);
197 }
198
199 exit:
200 if (pathname) {
201 ACPI_FREE(pathname);
202 }
203
204 return (status);
205}
206
207/*******************************************************************************
208 *
209 * FUNCTION: acpi_ns_check_parameter_count
210 *
211 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
212 * Node - Namespace node for the method/object
213 * Predefined - Pointer to entry in predefined name table
214 *
215 * RETURN: None
216 *
217 * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a
218 * predefined name is what is expected (i.e., what is defined in
219 * the ACPI specification for this predefined name.)
220 *
221 ******************************************************************************/
222
223void
224acpi_ns_check_parameter_count(char *pathname,
225 struct acpi_namespace_node *node,
226 const union acpi_predefined_info *predefined)
227{
228 u32 param_count;
229 u32 required_params_current;
230 u32 required_params_old;
231
232 /*
233 * Check that the ASL-defined parameter count is what is expected for
234 * this predefined name.
235 *
236 * Methods have 0-7 parameters. All other types have zero.
237 */
238 param_count = 0;
239 if (node->type == ACPI_TYPE_METHOD) {
240 param_count = node->object->method.param_count;
241 }
242
243 /* Validate parameter count - allow two different legal counts (_SCP) */
244
245 required_params_current = predefined->info.param_count & 0x0F;
246 required_params_old = predefined->info.param_count >> 4;
247
248 if ((param_count != required_params_current) &&
249 (param_count != required_params_old)) {
250 ACPI_WARNING((AE_INFO,
251 "%s: Parameter count mismatch - ASL declared %d, expected %d",
252 pathname, param_count, required_params_current));
253 }
254}
255
256/*******************************************************************************
257 *
258 * FUNCTION: acpi_ns_check_for_predefined_name
259 *
260 * PARAMETERS: Node - Namespace node for the method/object
261 *
262 * RETURN: Pointer to entry in predefined table. NULL indicates not found.
263 *
264 * DESCRIPTION: Check an object name against the predefined object list.
265 *
266 ******************************************************************************/
267
268const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
269 acpi_namespace_node
270 *node)
271{
272 const union acpi_predefined_info *this_name;
273
274 /* Quick check for a predefined name, first character must be underscore */
275
276 if (node->name.ascii[0] != '_') {
277 return (NULL);
278 }
279
280 /* Search info table for a predefined method/object name */
281
282 this_name = predefined_names;
283 while (this_name->info.name[0]) {
284 if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) {
285
286 /* Return pointer to this table entry */
287
288 return (this_name);
289 }
290
291 /*
292 * Skip next entry in the table if this name returns a Package
293 * (next entry contains the package info)
294 */
295 if (this_name->info.expected_btypes & ACPI_RTYPE_PACKAGE) {
296 this_name++;
297 }
298
299 this_name++;
300 }
301
302 return (NULL);
303}
304
305/*******************************************************************************
306 *
307 * FUNCTION: acpi_ns_check_package
308 *
309 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
310 * return_object - Object returned from the evaluation of a
311 * method or object
312 * Predefined - Pointer to entry in predefined name table
313 *
314 * RETURN: Status
315 *
316 * DESCRIPTION: Check a returned package object for the correct count and
317 * correct type of all sub-objects.
318 *
319 ******************************************************************************/
320
321static acpi_status
322acpi_ns_check_package(char *pathname,
323 union acpi_operand_object *return_object,
324 const union acpi_predefined_info *predefined)
325{
326 const union acpi_predefined_info *package;
327 union acpi_operand_object *sub_package;
328 union acpi_operand_object **elements;
329 union acpi_operand_object **sub_elements;
330 acpi_status status;
331 u32 expected_count;
332 u32 count;
333 u32 i;
334 u32 j;
335
336 ACPI_FUNCTION_NAME(ns_check_package);
337
338 /* The package info for this name is in the next table entry */
339
340 package = predefined + 1;
341
342 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
343 "%s Validating return Package of Type %X, Count %X\n",
344 pathname, package->ret_info.type,
345 return_object->package.count));
346
347 /* Extract package count and elements array */
348
349 elements = return_object->package.elements;
350 count = return_object->package.count;
351
352 /* The package must have at least one element, else invalid */
353
354 if (!count) {
355 ACPI_WARNING((AE_INFO,
356 "%s: Return Package has no elements (empty)",
357 pathname));
358
359 return (AE_AML_OPERAND_VALUE);
360 }
361
362 /*
363 * Decode the type of the expected package contents
364 *
365 * PTYPE1 packages contain no subpackages
366 * PTYPE2 packages contain sub-packages
367 */
368 switch (package->ret_info.type) {
369 case ACPI_PTYPE1_FIXED:
370
371 /*
372 * The package count is fixed and there are no sub-packages
373 *
374 * If package is too small, exit.
375 * If package is larger than expected, issue warning but continue
376 */
377 expected_count =
378 package->ret_info.count1 + package->ret_info.count2;
379 if (count < expected_count) {
380 goto package_too_small;
381 } else if (count > expected_count) {
382 ACPI_WARNING((AE_INFO,
383 "%s: Return Package is larger than needed - "
384 "found %u, expected %u", pathname, count,
385 expected_count));
386 }
387
388 /* Validate all elements of the returned package */
389
390 status = acpi_ns_check_package_elements(pathname, elements,
391 package->ret_info.
392 object_type1,
393 package->ret_info.
394 count1,
395 package->ret_info.
396 object_type2,
397 package->ret_info.
398 count2);
399 if (ACPI_FAILURE(status)) {
400 return (status);
401 }
402 break;
403
404 case ACPI_PTYPE1_VAR:
405
406 /*
407 * The package count is variable, there are no sub-packages, and all
408 * elements must be of the same type
409 */
410 for (i = 0; i < count; i++) {
411 status = acpi_ns_check_object_type(pathname, *elements,
412 package->ret_info.
413 object_type1, i);
414 if (ACPI_FAILURE(status)) {
415 return (status);
416 }
417 elements++;
418 }
419 break;
420
421 case ACPI_PTYPE1_OPTION:
422
423 /*
424 * The package count is variable, there are no sub-packages. There are
425 * a fixed number of required elements, and a variable number of
426 * optional elements.
427 *
428 * Check if package is at least as large as the minimum required
429 */
430 expected_count = package->ret_info3.count;
431 if (count < expected_count) {
432 goto package_too_small;
433 }
434
435 /* Variable number of sub-objects */
436
437 for (i = 0; i < count; i++) {
438 if (i < package->ret_info3.count) {
439
440 /* These are the required package elements (0, 1, or 2) */
441
442 status =
443 acpi_ns_check_object_type(pathname,
444 *elements,
445 package->
446 ret_info3.
447 object_type[i],
448 i);
449 if (ACPI_FAILURE(status)) {
450 return (status);
451 }
452 } else {
453 /* These are the optional package elements */
454
455 status =
456 acpi_ns_check_object_type(pathname,
457 *elements,
458 package->
459 ret_info3.
460 tail_object_type,
461 i);
462 if (ACPI_FAILURE(status)) {
463 return (status);
464 }
465 }
466 elements++;
467 }
468 break;
469
470 case ACPI_PTYPE2_PKG_COUNT:
471
472 /* First element is the (Integer) count of sub-packages to follow */
473
474 status = acpi_ns_check_object_type(pathname, *elements,
475 ACPI_RTYPE_INTEGER, 0);
476 if (ACPI_FAILURE(status)) {
477 return (status);
478 }
479
480 /*
481 * Count cannot be larger than the parent package length, but allow it
482 * to be smaller. The >= accounts for the Integer above.
483 */
484 expected_count = (u32) (*elements)->integer.value;
485 if (expected_count >= count) {
486 goto package_too_small;
487 }
488
489 count = expected_count;
490 elements++;
491
492 /* Now we can walk the sub-packages */
493
494 /*lint -fallthrough */
495
496 case ACPI_PTYPE2:
497 case ACPI_PTYPE2_FIXED:
498 case ACPI_PTYPE2_MIN:
499 case ACPI_PTYPE2_COUNT:
500
501 /*
502 * These types all return a single package that consists of a variable
503 * number of sub-packages
504 */
505 for (i = 0; i < count; i++) {
506 sub_package = *elements;
507 sub_elements = sub_package->package.elements;
508
509 /* Each sub-object must be of type Package */
510
511 status =
512 acpi_ns_check_object_type(pathname, sub_package,
513 ACPI_RTYPE_PACKAGE, i);
514 if (ACPI_FAILURE(status)) {
515 return (status);
516 }
517
518 /* Examine the different types of sub-packages */
519
520 switch (package->ret_info.type) {
521 case ACPI_PTYPE2:
522 case ACPI_PTYPE2_PKG_COUNT:
523
524 /* Each subpackage has a fixed number of elements */
525
526 expected_count =
527 package->ret_info.count1 +
528 package->ret_info.count2;
529 if (sub_package->package.count !=
530 expected_count) {
531 count = sub_package->package.count;
532 goto package_too_small;
533 }
534
535 status =
536 acpi_ns_check_package_elements(pathname,
537 sub_elements,
538 package->
539 ret_info.
540 object_type1,
541 package->
542 ret_info.
543 count1,
544 package->
545 ret_info.
546 object_type2,
547 package->
548 ret_info.
549 count2);
550 if (ACPI_FAILURE(status)) {
551 return (status);
552 }
553 break;
554
555 case ACPI_PTYPE2_FIXED:
556
557 /* Each sub-package has a fixed length */
558
559 expected_count = package->ret_info2.count;
560 if (sub_package->package.count < expected_count) {
561 count = sub_package->package.count;
562 goto package_too_small;
563 }
564
565 /* Check the type of each sub-package element */
566
567 for (j = 0; j < expected_count; j++) {
568 status =
569 acpi_ns_check_object_type(pathname,
570 sub_elements
571 [j],
572 package->
573 ret_info2.
574 object_type
575 [j], j);
576 if (ACPI_FAILURE(status)) {
577 return (status);
578 }
579 }
580 break;
581
582 case ACPI_PTYPE2_MIN:
583
584 /* Each sub-package has a variable but minimum length */
585
586 expected_count = package->ret_info.count1;
587 if (sub_package->package.count < expected_count) {
588 count = sub_package->package.count;
589 goto package_too_small;
590 }
591
592 /* Check the type of each sub-package element */
593
594 status =
595 acpi_ns_check_package_elements(pathname,
596 sub_elements,
597 package->
598 ret_info.
599 object_type1,
600 sub_package->
601 package.
602 count, 0, 0);
603 if (ACPI_FAILURE(status)) {
604 return (status);
605 }
606 break;
607
608 case ACPI_PTYPE2_COUNT:
609
610 /* First element is the (Integer) count of elements to follow */
611
612 status =
613 acpi_ns_check_object_type(pathname,
614 *sub_elements,
615 ACPI_RTYPE_INTEGER,
616 0);
617 if (ACPI_FAILURE(status)) {
618 return (status);
619 }
620
621 /* Make sure package is large enough for the Count */
622
623 expected_count =
624 (u32) (*sub_elements)->integer.value;
625 if (sub_package->package.count < expected_count) {
626 count = sub_package->package.count;
627 goto package_too_small;
628 }
629
630 /* Check the type of each sub-package element */
631
632 status =
633 acpi_ns_check_package_elements(pathname,
634 (sub_elements
635 + 1),
636 package->
637 ret_info.
638 object_type1,
639 (expected_count
640 - 1), 0, 0);
641 if (ACPI_FAILURE(status)) {
642 return (status);
643 }
644 break;
645
646 default:
647 break;
648 }
649
650 elements++;
651 }
652 break;
653
654 default:
655
656 /* Should not get here if predefined info table is correct */
657
658 ACPI_WARNING((AE_INFO,
659 "%s: Invalid internal return type in table entry: %X",
660 pathname, package->ret_info.type));
661
662 return (AE_AML_INTERNAL);
663 }
664
665 return (AE_OK);
666
667 package_too_small:
668
669 /* Error exit for the case with an incorrect package count */
670
671 ACPI_WARNING((AE_INFO, "%s: Return Package is too small - "
672 "found %u, expected %u", pathname, count,
673 expected_count));
674
675 return (AE_AML_OPERAND_VALUE);
676}
677
678/*******************************************************************************
679 *
680 * FUNCTION: acpi_ns_check_package_elements
681 *
682 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
683 * Elements - Pointer to the package elements array
684 * Type1 - Object type for first group
685 * Count1 - Count for first group
686 * Type2 - Object type for second group
687 * Count2 - Count for second group
688 *
689 * RETURN: Status
690 *
691 * DESCRIPTION: Check that all elements of a package are of the correct object
692 * type. Supports up to two groups of different object types.
693 *
694 ******************************************************************************/
695
696static acpi_status
697acpi_ns_check_package_elements(char *pathname,
698 union acpi_operand_object **elements,
699 u8 type1, u32 count1, u8 type2, u32 count2)
700{
701 union acpi_operand_object **this_element = elements;
702 acpi_status status;
703 u32 i;
704
705 /*
706 * Up to two groups of package elements are supported by the data
707 * structure. All elements in each group must be of the same type.
708 * The second group can have a count of zero.
709 */
710 for (i = 0; i < count1; i++) {
711 status = acpi_ns_check_object_type(pathname, *this_element,
712 type1, i);
713 if (ACPI_FAILURE(status)) {
714 return (status);
715 }
716 this_element++;
717 }
718
719 for (i = 0; i < count2; i++) {
720 status = acpi_ns_check_object_type(pathname, *this_element,
721 type2, (i + count1));
722 if (ACPI_FAILURE(status)) {
723 return (status);
724 }
725 this_element++;
726 }
727
728 return (AE_OK);
729}
730
731/*******************************************************************************
732 *
733 * FUNCTION: acpi_ns_check_object_type
734 *
735 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
736 * return_object - Object return from the execution of this
737 * method/object
738 * expected_btypes - Bitmap of expected return type(s)
739 * package_index - Index of object within parent package (if
740 * applicable - ACPI_NOT_PACKAGE otherwise)
741 *
742 * RETURN: Status
743 *
744 * DESCRIPTION: Check the type of the return object against the expected object
745 * type(s). Use of Btype allows multiple expected object types.
746 *
747 ******************************************************************************/
748
749static acpi_status
750acpi_ns_check_object_type(char *pathname,
751 union acpi_operand_object *return_object,
752 u32 expected_btypes, u32 package_index)
753{
754 acpi_status status = AE_OK;
755 u32 return_btype;
756 char type_buffer[48]; /* Room for 5 types */
757 u32 this_rtype;
758 u32 i;
759 u32 j;
760
761 /*
762 * If we get a NULL return_object here, it is a NULL package element,
763 * and this is always an error.
764 */
765 if (!return_object) {
766 goto type_error_exit;
767 }
768
769 /* A Namespace node should not get here, but make sure */
770
771 if (ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) {
772 ACPI_WARNING((AE_INFO,
773 "%s: Invalid return type - Found a Namespace node [%4.4s] type %s",
774 pathname, return_object->node.name.ascii,
775 acpi_ut_get_type_name(return_object->node.type)));
776 return (AE_AML_OPERAND_TYPE);
777 }
778
779 /*
780 * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type.
781 * The bitmapped type allows multiple possible return types.
782 *
783 * Note, the cases below must handle all of the possible types returned
784 * from all of the predefined names (including elements of returned
785 * packages)
786 */
787 switch (ACPI_GET_OBJECT_TYPE(return_object)) {
788 case ACPI_TYPE_INTEGER:
789 return_btype = ACPI_RTYPE_INTEGER;
790 break;
791
792 case ACPI_TYPE_BUFFER:
793 return_btype = ACPI_RTYPE_BUFFER;
794 break;
795
796 case ACPI_TYPE_STRING:
797 return_btype = ACPI_RTYPE_STRING;
798 break;
799
800 case ACPI_TYPE_PACKAGE:
801 return_btype = ACPI_RTYPE_PACKAGE;
802 break;
803
804 case ACPI_TYPE_LOCAL_REFERENCE:
805 return_btype = ACPI_RTYPE_REFERENCE;
806 break;
807
808 default:
809 /* Not one of the supported objects, must be incorrect */
810
811 goto type_error_exit;
812 }
813
814 /* Is the object one of the expected types? */
815
816 if (!(return_btype & expected_btypes)) {
817 goto type_error_exit;
818 }
819
820 /* For reference objects, check that the reference type is correct */
821
822 if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_LOCAL_REFERENCE) {
823 status = acpi_ns_check_reference(pathname, return_object);
824 }
825
826 return (status);
827
828 type_error_exit:
829
830 /* Create a string with all expected types for this predefined object */
831
832 j = 1;
833 type_buffer[0] = 0;
834 this_rtype = ACPI_RTYPE_INTEGER;
835
836 for (i = 0; i < ACPI_NUM_RTYPES; i++) {
837
838 /* If one of the expected types, concatenate the name of this type */
839
840 if (expected_btypes & this_rtype) {
841 ACPI_STRCAT(type_buffer, &acpi_rtype_names[i][j]);
842 j = 0; /* Use name separator from now on */
843 }
844 this_rtype <<= 1; /* Next Rtype */
845 }
846
847 if (package_index == ACPI_NOT_PACKAGE) {
848 ACPI_WARNING((AE_INFO,
849 "%s: Return type mismatch - found %s, expected %s",
850 pathname,
851 acpi_ut_get_object_type_name(return_object),
852 type_buffer));
853 } else {
854 ACPI_WARNING((AE_INFO,
855 "%s: Return Package type mismatch at index %u - "
856 "found %s, expected %s", pathname, package_index,
857 acpi_ut_get_object_type_name(return_object),
858 type_buffer));
859 }
860
861 return (AE_AML_OPERAND_TYPE);
862}
863
864/*******************************************************************************
865 *
866 * FUNCTION: acpi_ns_check_reference
867 *
868 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
869 * return_object - Object returned from the evaluation of a
870 * method or object
871 *
872 * RETURN: Status
873 *
874 * DESCRIPTION: Check a returned reference object for the correct reference
875 * type. The only reference type that can be returned from a
876 * predefined method is a named reference. All others are invalid.
877 *
878 ******************************************************************************/
879
880static acpi_status
881acpi_ns_check_reference(char *pathname,
882 union acpi_operand_object *return_object)
883{
884
885 /*
886 * Check the reference object for the correct reference type (opcode).
887 * The only type of reference that can be converted to an union acpi_object is
888 * a reference to a named object (reference class: NAME)
889 */
890 if (return_object->reference.class == ACPI_REFCLASS_NAME) {
891 return (AE_OK);
892 }
893
894 ACPI_WARNING((AE_INFO,
895 "%s: Return type mismatch - unexpected reference object type [%s] %2.2X",
896 pathname, acpi_ut_get_reference_name(return_object),
897 return_object->reference.class));
898
899 return (AE_AML_OPERAND_TYPE);
900}
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/namespace/nssearch.c
index 8399276cba1e..a9a80bf811b3 100644
--- a/drivers/acpi/namespace/nssearch.c
+++ b/drivers/acpi/namespace/nssearch.c
@@ -331,7 +331,7 @@ acpi_ns_search_and_enter(u32 target_name,
331 "Found bad character(s) in name, repaired: [%4.4s]\n", 331 "Found bad character(s) in name, repaired: [%4.4s]\n",
332 ACPI_CAST_PTR(char, &target_name))); 332 ACPI_CAST_PTR(char, &target_name)));
333 } else { 333 } else {
334 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 334 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
335 "Found bad character(s) in name, repaired: [%4.4s]\n", 335 "Found bad character(s) in name, repaired: [%4.4s]\n",
336 ACPI_CAST_PTR(char, &target_name))); 336 ACPI_CAST_PTR(char, &target_name)));
337 } 337 }
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
index 38be5865d95d..a085cc39c055 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/namespace/nsxfeval.c
@@ -48,6 +48,10 @@
48 48
49#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsxfeval") 50ACPI_MODULE_NAME("nsxfeval")
51
52/* Local prototypes */
53static void acpi_ns_resolve_references(struct acpi_evaluate_info *info);
54
51#ifdef ACPI_FUTURE_USAGE 55#ifdef ACPI_FUTURE_USAGE
52/******************************************************************************* 56/*******************************************************************************
53 * 57 *
@@ -69,6 +73,7 @@ ACPI_MODULE_NAME("nsxfeval")
69 * be valid (non-null) 73 * be valid (non-null)
70 * 74 *
71 ******************************************************************************/ 75 ******************************************************************************/
76
72acpi_status 77acpi_status
73acpi_evaluate_object_typed(acpi_handle handle, 78acpi_evaluate_object_typed(acpi_handle handle,
74 acpi_string pathname, 79 acpi_string pathname,
@@ -283,6 +288,10 @@ acpi_evaluate_object(acpi_handle handle,
283 288
284 if (ACPI_SUCCESS(status)) { 289 if (ACPI_SUCCESS(status)) {
285 290
291 /* Dereference Index and ref_of references */
292
293 acpi_ns_resolve_references(info);
294
286 /* Get the size of the returned object */ 295 /* Get the size of the returned object */
287 296
288 status = 297 status =
@@ -352,6 +361,74 @@ ACPI_EXPORT_SYMBOL(acpi_evaluate_object)
352 361
353/******************************************************************************* 362/*******************************************************************************
354 * 363 *
364 * FUNCTION: acpi_ns_resolve_references
365 *
366 * PARAMETERS: Info - Evaluation info block
367 *
368 * RETURN: Info->return_object is replaced with the dereferenced object
369 *
370 * DESCRIPTION: Dereference certain reference objects. Called before an
371 * internal return object is converted to an external union acpi_object.
372 *
373 * Performs an automatic dereference of Index and ref_of reference objects.
374 * These reference objects are not supported by the union acpi_object, so this is a
375 * last resort effort to return something useful. Also, provides compatibility
376 * with other ACPI implementations.
377 *
378 * NOTE: does not handle references within returned package objects or nested
379 * references, but this support could be added later if found to be necessary.
380 *
381 ******************************************************************************/
382static void acpi_ns_resolve_references(struct acpi_evaluate_info *info)
383{
384 union acpi_operand_object *obj_desc = NULL;
385 struct acpi_namespace_node *node;
386
387 /* We are interested in reference objects only */
388
389 if (ACPI_GET_OBJECT_TYPE(info->return_object) !=
390 ACPI_TYPE_LOCAL_REFERENCE) {
391 return;
392 }
393
394 /*
395 * Two types of references are supported - those created by Index and
396 * ref_of operators. A name reference (AML_NAMEPATH_OP) can be converted
397 * to an union acpi_object, so it is not dereferenced here. A ddb_handle
398 * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to
399 * an union acpi_object.
400 */
401 switch (info->return_object->reference.class) {
402 case ACPI_REFCLASS_INDEX:
403
404 obj_desc = *(info->return_object->reference.where);
405 break;
406
407 case ACPI_REFCLASS_REFOF:
408
409 node = info->return_object->reference.object;
410 if (node) {
411 obj_desc = node->object;
412 }
413 break;
414
415 default:
416 return;
417 }
418
419 /* Replace the existing reference object */
420
421 if (obj_desc) {
422 acpi_ut_add_reference(obj_desc);
423 acpi_ut_remove_reference(info->return_object);
424 info->return_object = obj_desc;
425 }
426
427 return;
428}
429
430/*******************************************************************************
431 *
355 * FUNCTION: acpi_walk_namespace 432 * FUNCTION: acpi_walk_namespace
356 * 433 *
357 * PARAMETERS: Type - acpi_object_type to search for 434 * PARAMETERS: Type - acpi_object_type to search for
@@ -379,6 +456,7 @@ ACPI_EXPORT_SYMBOL(acpi_evaluate_object)
379 * function, etc. 456 * function, etc.
380 * 457 *
381 ******************************************************************************/ 458 ******************************************************************************/
459
382acpi_status 460acpi_status
383acpi_walk_namespace(acpi_object_type type, 461acpi_walk_namespace(acpi_object_type type,
384 acpi_handle start_object, 462 acpi_handle start_object,
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/namespace/nsxfname.c
index a287ed550f54..5efa4e7ddb0b 100644
--- a/drivers/acpi/namespace/nsxfname.c
+++ b/drivers/acpi/namespace/nsxfname.c
@@ -253,6 +253,7 @@ acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
253 node = acpi_ns_map_handle_to_node(handle); 253 node = acpi_ns_map_handle_to_node(handle);
254 if (!node) { 254 if (!node) {
255 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 255 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
256 status = AE_BAD_PARAMETER;
256 goto cleanup; 257 goto cleanup;
257 } 258 }
258 259
@@ -264,6 +265,10 @@ acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
264 info->name = node->name.integer; 265 info->name = node->name.integer;
265 info->valid = 0; 266 info->valid = 0;
266 267
268 if (node->type == ACPI_TYPE_METHOD) {
269 info->param_count = node->object->method.param_count;
270 }
271
267 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 272 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
268 if (ACPI_FAILURE(status)) { 273 if (ACPI_FAILURE(status)) {
269 goto cleanup; 274 goto cleanup;
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 750e0df15604..6234d3e7acd3 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -754,8 +754,8 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
754 } 754 }
755 755
756 if (!ret) { 756 if (!ret) {
757 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 757 printk(KERN_ERR PREFIX
758 "Call to queue_work() failed.\n")); 758 "Call to queue_work() failed.\n");
759 status = AE_ERROR; 759 status = AE_ERROR;
760 kfree(dpc); 760 kfree(dpc);
761 } 761 }
diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/parser/psloop.c
index c06238e55d98..4647039a0d8a 100644
--- a/drivers/acpi/parser/psloop.c
+++ b/drivers/acpi/parser/psloop.c
@@ -719,6 +719,8 @@ acpi_ps_complete_op(struct acpi_walk_state *walk_state,
719 *op = NULL; 719 *op = NULL;
720 } 720 }
721 721
722 ACPI_PREEMPTION_POINT();
723
722 return_ACPI_STATUS(AE_OK); 724 return_ACPI_STATUS(AE_OK);
723} 725}
724 726
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
index 15e1702e48d6..68e932f215ea 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/parser/psparse.c
@@ -137,6 +137,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
137 union acpi_parse_object *next; 137 union acpi_parse_object *next;
138 const struct acpi_opcode_info *parent_info; 138 const struct acpi_opcode_info *parent_info;
139 union acpi_parse_object *replacement_op = NULL; 139 union acpi_parse_object *replacement_op = NULL;
140 acpi_status status = AE_OK;
140 141
141 ACPI_FUNCTION_TRACE_PTR(ps_complete_this_op, op); 142 ACPI_FUNCTION_TRACE_PTR(ps_complete_this_op, op);
142 143
@@ -186,7 +187,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
186 replacement_op = 187 replacement_op =
187 acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); 188 acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP);
188 if (!replacement_op) { 189 if (!replacement_op) {
189 goto allocate_error; 190 status = AE_NO_MEMORY;
190 } 191 }
191 break; 192 break;
192 193
@@ -211,7 +212,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
211 replacement_op = 212 replacement_op =
212 acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); 213 acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP);
213 if (!replacement_op) { 214 if (!replacement_op) {
214 goto allocate_error; 215 status = AE_NO_MEMORY;
215 } 216 }
216 } else 217 } else
217 if ((op->common.parent->common.aml_opcode == 218 if ((op->common.parent->common.aml_opcode ==
@@ -226,13 +227,13 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
226 acpi_ps_alloc_op(op->common. 227 acpi_ps_alloc_op(op->common.
227 aml_opcode); 228 aml_opcode);
228 if (!replacement_op) { 229 if (!replacement_op) {
229 goto allocate_error; 230 status = AE_NO_MEMORY;
231 } else {
232 replacement_op->named.data =
233 op->named.data;
234 replacement_op->named.length =
235 op->named.length;
230 } 236 }
231
232 replacement_op->named.data =
233 op->named.data;
234 replacement_op->named.length =
235 op->named.length;
236 } 237 }
237 } 238 }
238 break; 239 break;
@@ -242,7 +243,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
242 replacement_op = 243 replacement_op =
243 acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP); 244 acpi_ps_alloc_op(AML_INT_RETURN_VALUE_OP);
244 if (!replacement_op) { 245 if (!replacement_op) {
245 goto allocate_error; 246 status = AE_NO_MEMORY;
246 } 247 }
247 } 248 }
248 249
@@ -302,14 +303,7 @@ acpi_ps_complete_this_op(struct acpi_walk_state * walk_state,
302 /* Now we can actually delete the subtree rooted at Op */ 303 /* Now we can actually delete the subtree rooted at Op */
303 304
304 acpi_ps_delete_parse_tree(op); 305 acpi_ps_delete_parse_tree(op);
305 return_ACPI_STATUS(AE_OK); 306 return_ACPI_STATUS(status);
306
307 allocate_error:
308
309 /* Always delete the subtree, even on error */
310
311 acpi_ps_delete_parse_tree(op);
312 return_ACPI_STATUS(AE_NO_MEMORY);
313} 307}
314 308
315/******************************************************************************* 309/*******************************************************************************
@@ -641,10 +635,12 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
641 ACPI_WALK_METHOD_RESTART; 635 ACPI_WALK_METHOD_RESTART;
642 } 636 }
643 } else { 637 } else {
644 /* On error, delete any return object */ 638 /* On error, delete any return object or implicit return */
645 639
646 acpi_ut_remove_reference(previous_walk_state-> 640 acpi_ut_remove_reference(previous_walk_state->
647 return_desc); 641 return_desc);
642 acpi_ds_clear_implicit_return
643 (previous_walk_state);
648 } 644 }
649 } 645 }
650 646
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index cf47805a7448..65bf4fa59633 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -709,7 +709,7 @@ int acpi_pci_link_free_irq(acpi_handle handle)
709 acpi_device_bid(link->device))); 709 acpi_device_bid(link->device)));
710 710
711 if (link->refcnt == 0) { 711 if (link->refcnt == 0) {
712 acpi_ut_evaluate_object(link->device->handle, "_DIS", 0, NULL); 712 acpi_evaluate_object(link->device->handle, "_DIS", NULL, NULL);
713 } 713 }
714 mutex_unlock(&acpi_link_lock); 714 mutex_unlock(&acpi_link_lock);
715 return (link->irq.active); 715 return (link->irq.active);
@@ -773,7 +773,7 @@ static int acpi_pci_link_add(struct acpi_device *device)
773 773
774 end: 774 end:
775 /* disable all links -- to be activated on use */ 775 /* disable all links -- to be activated on use */
776 acpi_ut_evaluate_object(device->handle, "_DIS", 0, NULL); 776 acpi_evaluate_object(device->handle, "_DIS", NULL, NULL);
777 mutex_unlock(&acpi_link_lock); 777 mutex_unlock(&acpi_link_lock);
778 778
779 if (result) 779 if (result)
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 4ab21cb1c8c7..7ff7349c0c52 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -54,6 +54,14 @@ ACPI_MODULE_NAME("power");
54#define ACPI_POWER_RESOURCE_STATE_OFF 0x00 54#define ACPI_POWER_RESOURCE_STATE_OFF 0x00
55#define ACPI_POWER_RESOURCE_STATE_ON 0x01 55#define ACPI_POWER_RESOURCE_STATE_ON 0x01
56#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF 56#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF
57
58#ifdef MODULE_PARAM_PREFIX
59#undef MODULE_PARAM_PREFIX
60#endif
61#define MODULE_PARAM_PREFIX "acpi."
62int acpi_power_nocheck;
63module_param_named(power_nocheck, acpi_power_nocheck, bool, 000);
64
57static int acpi_power_add(struct acpi_device *device); 65static int acpi_power_add(struct acpi_device *device);
58static int acpi_power_remove(struct acpi_device *device, int type); 66static int acpi_power_remove(struct acpi_device *device, int type);
59static int acpi_power_resume(struct acpi_device *device); 67static int acpi_power_resume(struct acpi_device *device);
@@ -128,16 +136,16 @@ acpi_power_get_context(acpi_handle handle,
128 return 0; 136 return 0;
129} 137}
130 138
131static int acpi_power_get_state(struct acpi_power_resource *resource, int *state) 139static int acpi_power_get_state(acpi_handle handle, int *state)
132{ 140{
133 acpi_status status = AE_OK; 141 acpi_status status = AE_OK;
134 unsigned long sta = 0; 142 unsigned long sta = 0;
135 143
136 144
137 if (!resource || !state) 145 if (!handle || !state)
138 return -EINVAL; 146 return -EINVAL;
139 147
140 status = acpi_evaluate_integer(resource->device->handle, "_STA", NULL, &sta); 148 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
141 if (ACPI_FAILURE(status)) 149 if (ACPI_FAILURE(status))
142 return -ENODEV; 150 return -ENODEV;
143 151
@@ -145,7 +153,7 @@ static int acpi_power_get_state(struct acpi_power_resource *resource, int *state
145 ACPI_POWER_RESOURCE_STATE_OFF; 153 ACPI_POWER_RESOURCE_STATE_OFF;
146 154
147 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", 155 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
148 resource->name, state ? "on" : "off")); 156 acpi_ut_get_node_name(handle), state ? "on" : "off"));
149 157
150 return 0; 158 return 0;
151} 159}
@@ -153,7 +161,6 @@ static int acpi_power_get_state(struct acpi_power_resource *resource, int *state
153static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state) 161static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
154{ 162{
155 int result = 0, state1; 163 int result = 0, state1;
156 struct acpi_power_resource *resource = NULL;
157 u32 i = 0; 164 u32 i = 0;
158 165
159 166
@@ -161,12 +168,15 @@ static int acpi_power_get_list_state(struct acpi_handle_list *list, int *state)
161 return -EINVAL; 168 return -EINVAL;
162 169
163 /* The state of the list is 'on' IFF all resources are 'on'. */ 170 /* The state of the list is 'on' IFF all resources are 'on'. */
171 /* */
164 172
165 for (i = 0; i < list->count; i++) { 173 for (i = 0; i < list->count; i++) {
166 result = acpi_power_get_context(list->handles[i], &resource); 174 /*
167 if (result) 175 * The state of the power resource can be obtained by
168 return result; 176 * using the ACPI handle. In such case it is unnecessary to
169 result = acpi_power_get_state(resource, &state1); 177 * get the Power resource first and then get its state again.
178 */
179 result = acpi_power_get_state(list->handles[i], &state1);
170 if (result) 180 if (result)
171 return result; 181 return result;
172 182
@@ -226,12 +236,18 @@ static int acpi_power_on(acpi_handle handle, struct acpi_device *dev)
226 if (ACPI_FAILURE(status)) 236 if (ACPI_FAILURE(status))
227 return -ENODEV; 237 return -ENODEV;
228 238
229 result = acpi_power_get_state(resource, &state); 239 if (!acpi_power_nocheck) {
230 if (result) 240 /*
231 return result; 241 * If acpi_power_nocheck is set, it is unnecessary to check
232 if (state != ACPI_POWER_RESOURCE_STATE_ON) 242 * the power state after power transition.
233 return -ENOEXEC; 243 */
234 244 result = acpi_power_get_state(resource->device->handle,
245 &state);
246 if (result)
247 return result;
248 if (state != ACPI_POWER_RESOURCE_STATE_ON)
249 return -ENOEXEC;
250 }
235 /* Update the power resource's _device_ power state */ 251 /* Update the power resource's _device_ power state */
236 resource->device->power.state = ACPI_STATE_D0; 252 resource->device->power.state = ACPI_STATE_D0;
237 253
@@ -277,11 +293,17 @@ static int acpi_power_off_device(acpi_handle handle, struct acpi_device *dev)
277 if (ACPI_FAILURE(status)) 293 if (ACPI_FAILURE(status))
278 return -ENODEV; 294 return -ENODEV;
279 295
280 result = acpi_power_get_state(resource, &state); 296 if (!acpi_power_nocheck) {
281 if (result) 297 /*
282 return result; 298 * If acpi_power_nocheck is set, it is unnecessary to check
283 if (state != ACPI_POWER_RESOURCE_STATE_OFF) 299 * the power state after power transition.
284 return -ENOEXEC; 300 */
301 result = acpi_power_get_state(handle, &state);
302 if (result)
303 return result;
304 if (state != ACPI_POWER_RESOURCE_STATE_OFF)
305 return -ENOEXEC;
306 }
285 307
286 /* Update the power resource's _device_ power state */ 308 /* Update the power resource's _device_ power state */
287 resource->device->power.state = ACPI_STATE_D3; 309 resource->device->power.state = ACPI_STATE_D3;
@@ -555,7 +577,7 @@ static int acpi_power_seq_show(struct seq_file *seq, void *offset)
555 if (!resource) 577 if (!resource)
556 goto end; 578 goto end;
557 579
558 result = acpi_power_get_state(resource, &state); 580 result = acpi_power_get_state(resource->device->handle, &state);
559 if (result) 581 if (result)
560 goto end; 582 goto end;
561 583
@@ -668,7 +690,7 @@ static int acpi_power_add(struct acpi_device *device)
668 resource->system_level = acpi_object.power_resource.system_level; 690 resource->system_level = acpi_object.power_resource.system_level;
669 resource->order = acpi_object.power_resource.resource_order; 691 resource->order = acpi_object.power_resource.resource_order;
670 692
671 result = acpi_power_get_state(resource, &state); 693 result = acpi_power_get_state(device->handle, &state);
672 if (result) 694 if (result)
673 goto end; 695 goto end;
674 696
@@ -735,7 +757,7 @@ static int acpi_power_resume(struct acpi_device *device)
735 757
736 resource = (struct acpi_power_resource *)acpi_driver_data(device); 758 resource = (struct acpi_power_resource *)acpi_driver_data(device);
737 759
738 result = acpi_power_get_state(resource, &state); 760 result = acpi_power_get_state(device->handle, &state);
739 if (result) 761 if (result)
740 return result; 762 return result;
741 763
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index cf5b1b7b684f..81b40ed5379e 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -1587,6 +1587,7 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
1587 1587
1588 if (acpi_idle_bm_check()) { 1588 if (acpi_idle_bm_check()) {
1589 if (dev->safe_state) { 1589 if (dev->safe_state) {
1590 dev->last_state = dev->safe_state;
1590 return dev->safe_state->enter(dev, dev->safe_state); 1591 return dev->safe_state->enter(dev, dev->safe_state);
1591 } else { 1592 } else {
1592 local_irq_disable(); 1593 local_irq_disable();
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 80c251ec6d2a..b0614f379470 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -38,6 +38,7 @@
38 38
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40#endif 40#endif
41#include <asm/cpufeature.h>
41 42
42#include <acpi/acpi_bus.h> 43#include <acpi/acpi_bus.h>
43#include <acpi/processor.h> 44#include <acpi/processor.h>
@@ -334,7 +335,6 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr)
334 acpi_status status = AE_OK; 335 acpi_status status = AE_OK;
335 acpi_handle handle = NULL; 336 acpi_handle handle = NULL;
336 337
337
338 if (!pr || !pr->performance || !pr->handle) 338 if (!pr || !pr->performance || !pr->handle)
339 return -EINVAL; 339 return -EINVAL;
340 340
@@ -347,13 +347,25 @@ static int acpi_processor_get_performance_info(struct acpi_processor *pr)
347 347
348 result = acpi_processor_get_performance_control(pr); 348 result = acpi_processor_get_performance_control(pr);
349 if (result) 349 if (result)
350 return result; 350 goto update_bios;
351 351
352 result = acpi_processor_get_performance_states(pr); 352 result = acpi_processor_get_performance_states(pr);
353 if (result) 353 if (result)
354 return result; 354 goto update_bios;
355 355
356 return 0; 356 return 0;
357
358 /*
359 * Having _PPC but missing frequencies (_PSS, _PCT) is a very good hint that
360 * the BIOS is older than the CPU and does not know its frequencies
361 */
362 update_bios:
363 if (ACPI_SUCCESS(acpi_get_handle(pr->handle, "_PPC", &handle))){
364 if(boot_cpu_has(X86_FEATURE_EST))
365 printk(KERN_WARNING FW_BUG "BIOS needs update for CPU "
366 "frequency support\n");
367 }
368 return result;
357} 369}
358 370
359int acpi_processor_notify_smm(struct module *calling_module) 371int acpi_processor_notify_smm(struct module *calling_module)
@@ -524,13 +536,13 @@ static int acpi_processor_get_psd(struct acpi_processor *pr)
524 536
525 psd = buffer.pointer; 537 psd = buffer.pointer;
526 if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) { 538 if (!psd || (psd->type != ACPI_TYPE_PACKAGE)) {
527 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n")); 539 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
528 result = -EFAULT; 540 result = -EFAULT;
529 goto end; 541 goto end;
530 } 542 }
531 543
532 if (psd->package.count != 1) { 544 if (psd->package.count != 1) {
533 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n")); 545 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
534 result = -EFAULT; 546 result = -EFAULT;
535 goto end; 547 goto end;
536 } 548 }
@@ -543,19 +555,19 @@ static int acpi_processor_get_psd(struct acpi_processor *pr)
543 status = acpi_extract_package(&(psd->package.elements[0]), 555 status = acpi_extract_package(&(psd->package.elements[0]),
544 &format, &state); 556 &format, &state);
545 if (ACPI_FAILURE(status)) { 557 if (ACPI_FAILURE(status)) {
546 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _PSD data\n")); 558 printk(KERN_ERR PREFIX "Invalid _PSD data\n");
547 result = -EFAULT; 559 result = -EFAULT;
548 goto end; 560 goto end;
549 } 561 }
550 562
551 if (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES) { 563 if (pdomain->num_entries != ACPI_PSD_REV0_ENTRIES) {
552 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _PSD:num_entries\n")); 564 printk(KERN_ERR PREFIX "Unknown _PSD:num_entries\n");
553 result = -EFAULT; 565 result = -EFAULT;
554 goto end; 566 goto end;
555 } 567 }
556 568
557 if (pdomain->revision != ACPI_PSD_REV0_REVISION) { 569 if (pdomain->revision != ACPI_PSD_REV0_REVISION) {
558 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _PSD:revision\n")); 570 printk(KERN_ERR PREFIX "Unknown _PSD:revision\n");
559 result = -EFAULT; 571 result = -EFAULT;
560 goto end; 572 goto end;
561 } 573 }
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index a56fc6c4394b..e89a25824f2a 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -528,13 +528,13 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
528 528
529 tsd = buffer.pointer; 529 tsd = buffer.pointer;
530 if (!tsd || (tsd->type != ACPI_TYPE_PACKAGE)) { 530 if (!tsd || (tsd->type != ACPI_TYPE_PACKAGE)) {
531 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n")); 531 printk(KERN_ERR PREFIX "Invalid _TSD data\n");
532 result = -EFAULT; 532 result = -EFAULT;
533 goto end; 533 goto end;
534 } 534 }
535 535
536 if (tsd->package.count != 1) { 536 if (tsd->package.count != 1) {
537 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n")); 537 printk(KERN_ERR PREFIX "Invalid _TSD data\n");
538 result = -EFAULT; 538 result = -EFAULT;
539 goto end; 539 goto end;
540 } 540 }
@@ -547,19 +547,19 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
547 status = acpi_extract_package(&(tsd->package.elements[0]), 547 status = acpi_extract_package(&(tsd->package.elements[0]),
548 &format, &state); 548 &format, &state);
549 if (ACPI_FAILURE(status)) { 549 if (ACPI_FAILURE(status)) {
550 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n")); 550 printk(KERN_ERR PREFIX "Invalid _TSD data\n");
551 result = -EFAULT; 551 result = -EFAULT;
552 goto end; 552 goto end;
553 } 553 }
554 554
555 if (pdomain->num_entries != ACPI_TSD_REV0_ENTRIES) { 555 if (pdomain->num_entries != ACPI_TSD_REV0_ENTRIES) {
556 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _TSD:num_entries\n")); 556 printk(KERN_ERR PREFIX "Unknown _TSD:num_entries\n");
557 result = -EFAULT; 557 result = -EFAULT;
558 goto end; 558 goto end;
559 } 559 }
560 560
561 if (pdomain->revision != ACPI_TSD_REV0_REVISION) { 561 if (pdomain->revision != ACPI_TSD_REV0_REVISION) {
562 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _TSD:revision\n")); 562 printk(KERN_ERR PREFIX "Unknown _TSD:revision\n");
563 result = -EFAULT; 563 result = -EFAULT;
564 goto end; 564 goto end;
565 } 565 }
diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c
index a6b662c00b67..755baf2ca70a 100644
--- a/drivers/acpi/reboot.c
+++ b/drivers/acpi/reboot.c
@@ -15,9 +15,28 @@ void acpi_reboot(void)
15 15
16 rr = &acpi_gbl_FADT.reset_register; 16 rr = &acpi_gbl_FADT.reset_register;
17 17
18 /* Is the reset register supported? */ 18 /*
19 if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) || 19 * Is the ACPI reset register supported?
20 rr->bit_width != 8 || rr->bit_offset != 0) 20 *
21 * According to ACPI 3.0, FADT.flags.RESET_REG_SUP indicates
22 * whether the ACPI reset mechanism is supported.
23 *
24 * However, some boxes have this bit clear, yet a valid
25 * ACPI_RESET_REG & RESET_VALUE, and ACPI reboot is the only
26 * mechanism that works for them after S3.
27 *
28 * This suggests that other operating systems may not be checking
29 * the RESET_REG_SUP bit, and are using other means to decide
30 * whether to use the ACPI reboot mechanism or not.
31 *
32 * So when acpi reboot is requested,
33 * only the reset_register is checked. If the following
34 * conditions are met, it indicates that the reset register is supported.
35 * a. reset_register is not zero
36 * b. the access width is eight
37 * c. the bit_offset is zero
38 */
39 if (!(rr->address) || rr->bit_width != 8 || rr->bit_offset != 0)
21 return; 40 return;
22 41
23 reset_value = acpi_gbl_FADT.reset_value; 42 reset_value = acpi_gbl_FADT.reset_value;
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
index d9063ea414e3..8eaaecf92009 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/resources/rscalc.c
@@ -43,7 +43,6 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
46#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48 47
49#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
@@ -560,8 +559,8 @@ acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
560 ACPI_GET_OBJECT_TYPE(*sub_object_list)) || 559 ACPI_GET_OBJECT_TYPE(*sub_object_list)) ||
561 ((ACPI_TYPE_LOCAL_REFERENCE == 560 ((ACPI_TYPE_LOCAL_REFERENCE ==
562 ACPI_GET_OBJECT_TYPE(*sub_object_list)) && 561 ACPI_GET_OBJECT_TYPE(*sub_object_list)) &&
563 ((*sub_object_list)->reference.opcode == 562 ((*sub_object_list)->reference.class ==
564 AML_INT_NAMEPATH_OP)))) { 563 ACPI_REFCLASS_NAME)))) {
565 name_found = TRUE; 564 name_found = TRUE;
566 } else { 565 } else {
567 /* Look at the next element */ 566 /* Look at the next element */
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/resources/rscreate.c
index 7804a8c40e7a..c0bbfa2c4193 100644
--- a/drivers/acpi/resources/rscreate.c
+++ b/drivers/acpi/resources/rscreate.c
@@ -43,7 +43,6 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
46#include <acpi/amlcode.h>
47#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
48 47
49#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
@@ -310,13 +309,12 @@ acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
310 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { 309 switch (ACPI_GET_OBJECT_TYPE(obj_desc)) {
311 case ACPI_TYPE_LOCAL_REFERENCE: 310 case ACPI_TYPE_LOCAL_REFERENCE:
312 311
313 if (obj_desc->reference.opcode != 312 if (obj_desc->reference.class !=
314 AML_INT_NAMEPATH_OP) { 313 ACPI_REFCLASS_NAME) {
315 ACPI_ERROR((AE_INFO, 314 ACPI_ERROR((AE_INFO,
316 "(PRT[%X].Source) Need name, found reference op %X", 315 "(PRT[%X].Source) Need name, found Reference Class %X",
317 index, 316 index,
318 obj_desc->reference. 317 obj_desc->reference.class));
319 opcode));
320 return_ACPI_STATUS(AE_BAD_DATA); 318 return_ACPI_STATUS(AE_BAD_DATA);
321 } 319 }
322 320
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index f6f52c1a2aba..3196749398ea 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -113,16 +113,16 @@ static int acpi_bus_hot_remove_device(void *context)
113 113
114 114
115 if (acpi_bus_trim(device, 1)) { 115 if (acpi_bus_trim(device, 1)) {
116 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 116 printk(KERN_ERR PREFIX
117 "Removing device failed\n")); 117 "Removing device failed\n");
118 return -1; 118 return -1;
119 } 119 }
120 120
121 /* power off device */ 121 /* power off device */
122 status = acpi_evaluate_object(handle, "_PS3", NULL, NULL); 122 status = acpi_evaluate_object(handle, "_PS3", NULL, NULL);
123 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) 123 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
124 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 124 printk(KERN_WARNING PREFIX
125 "Power-off device failed\n")); 125 "Power-off device failed\n");
126 126
127 if (device->flags.lockable) { 127 if (device->flags.lockable) {
128 arg_list.count = 1; 128 arg_list.count = 1;
@@ -276,6 +276,13 @@ int acpi_match_device_ids(struct acpi_device *device,
276{ 276{
277 const struct acpi_device_id *id; 277 const struct acpi_device_id *id;
278 278
279 /*
280 * If the device is not present, it is unnecessary to load device
281 * driver for it.
282 */
283 if (!device->status.present)
284 return -ENODEV;
285
279 if (device->flags.hardware_id) { 286 if (device->flags.hardware_id) {
280 for (id = ids; id->id[0]; id++) { 287 for (id = ids; id->id[0]; id++) {
281 if (!strcmp((char*)id->id, device->pnp.hardware_id)) 288 if (!strcmp((char*)id->id, device->pnp.hardware_id))
@@ -477,7 +484,7 @@ static int acpi_device_register(struct acpi_device *device,
477 484
478 result = acpi_device_setup_files(device); 485 result = acpi_device_setup_files(device);
479 if(result) 486 if(result)
480 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error creating sysfs interface for device %s\n", device->dev.bus_id)); 487 printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n", device->dev.bus_id);
481 488
482 device->removal_type = ACPI_BUS_REMOVAL_NORMAL; 489 device->removal_type = ACPI_BUS_REMOVAL_NORMAL;
483 return 0; 490 return 0;
@@ -744,6 +751,16 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
744 if (!acpi_match_device_ids(device, button_device_ids)) 751 if (!acpi_match_device_ids(device, button_device_ids))
745 device->wakeup.flags.run_wake = 1; 752 device->wakeup.flags.run_wake = 1;
746 753
754 /*
755 * Don't set Power button GPE as run_wake
756 * if Fixed Power button is used
757 */
758 if (!strcmp(device->pnp.hardware_id, "PNP0C0C") &&
759 !(acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON)) {
760 device->wakeup.flags.run_wake = 0;
761 device->wakeup.flags.valid = 0;
762 }
763
747 end: 764 end:
748 if (ACPI_FAILURE(status)) 765 if (ACPI_FAILURE(status))
749 device->flags.wake_capable = 0; 766 device->flags.wake_capable = 0;
@@ -807,6 +824,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
807 /* TBD: System wake support and resource requirements. */ 824 /* TBD: System wake support and resource requirements. */
808 825
809 device->power.state = ACPI_STATE_UNKNOWN; 826 device->power.state = ACPI_STATE_UNKNOWN;
827 acpi_bus_get_power(device->handle, &(device->power.state));
810 828
811 return 0; 829 return 0;
812} 830}
@@ -1153,20 +1171,6 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
1153} 1171}
1154 1172
1155static int 1173static int
1156acpi_is_child_device(struct acpi_device *device,
1157 int (*matcher)(struct acpi_device *))
1158{
1159 int result = -ENODEV;
1160
1161 do {
1162 if (ACPI_SUCCESS(matcher(device)))
1163 return AE_OK;
1164 } while ((device = device->parent));
1165
1166 return result;
1167}
1168
1169static int
1170acpi_add_single_object(struct acpi_device **child, 1174acpi_add_single_object(struct acpi_device **child,
1171 struct acpi_device *parent, acpi_handle handle, int type, 1175 struct acpi_device *parent, acpi_handle handle, int type,
1172 struct acpi_bus_ops *ops) 1176 struct acpi_bus_ops *ops)
@@ -1221,15 +1225,18 @@ acpi_add_single_object(struct acpi_device **child,
1221 result = -ENODEV; 1225 result = -ENODEV;
1222 goto end; 1226 goto end;
1223 } 1227 }
1224 if (!device->status.present) { 1228 /*
1225 /* Bay and dock should be handled even if absent */ 1229 * When the device is neither present nor functional, the
1226 if (!ACPI_SUCCESS( 1230 * device should not be added to Linux ACPI device tree.
1227 acpi_is_child_device(device, acpi_bay_match)) && 1231 * When the status of the device is not present but functinal,
1228 !ACPI_SUCCESS( 1232 * it should be added to Linux ACPI tree. For example : bay
1229 acpi_is_child_device(device, acpi_dock_match))) { 1233 * device , dock device.
1230 result = -ENODEV; 1234 * In such conditions it is unncessary to check whether it is
1231 goto end; 1235 * bay device or dock device.
1232 } 1236 */
1237 if (!device->status.present && !device->status.functional) {
1238 result = -ENODEV;
1239 goto end;
1233 } 1240 }
1234 break; 1241 break;
1235 default: 1242 default:
@@ -1252,6 +1259,16 @@ acpi_add_single_object(struct acpi_device **child,
1252 acpi_device_set_id(device, parent, handle, type); 1259 acpi_device_set_id(device, parent, handle, type);
1253 1260
1254 /* 1261 /*
1262 * The ACPI device is attached to acpi handle before getting
1263 * the power/wakeup/peformance flags. Otherwise OS can't get
1264 * the corresponding ACPI device by the acpi handle in the course
1265 * of getting the power/wakeup/performance flags.
1266 */
1267 result = acpi_device_set_context(device, type);
1268 if (result)
1269 goto end;
1270
1271 /*
1255 * Power Management 1272 * Power Management
1256 * ---------------- 1273 * ----------------
1257 */ 1274 */
@@ -1281,8 +1298,6 @@ acpi_add_single_object(struct acpi_device **child,
1281 goto end; 1298 goto end;
1282 } 1299 }
1283 1300
1284 if ((result = acpi_device_set_context(device, type)))
1285 goto end;
1286 1301
1287 result = acpi_device_register(device, parent); 1302 result = acpi_device_register(device, parent);
1288 1303
@@ -1402,7 +1417,12 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
1402 * TBD: Need notifications and other detection mechanisms 1417 * TBD: Need notifications and other detection mechanisms
1403 * in place before we can fully implement this. 1418 * in place before we can fully implement this.
1404 */ 1419 */
1405 if (child->status.present) { 1420 /*
1421 * When the device is not present but functional, it is also
1422 * necessary to scan the children of this device.
1423 */
1424 if (child->status.present || (!child->status.present &&
1425 child->status.functional)) {
1406 status = acpi_get_next_object(ACPI_TYPE_ANY, chandle, 1426 status = acpi_get_next_object(ACPI_TYPE_ANY, chandle,
1407 NULL, NULL); 1427 NULL, NULL);
1408 if (ACPI_SUCCESS(status)) { 1428 if (ACPI_SUCCESS(status)) {
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index 4ebbba2b6b19..bf5b04de02d1 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -377,6 +377,14 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
377 return 0; 377 return 0;
378} 378}
379 379
380static void physical_device_enable_wakeup(struct acpi_device *adev)
381{
382 struct device *dev = acpi_get_physical_device(adev->handle);
383
384 if (dev && device_can_wakeup(dev))
385 device_set_wakeup_enable(dev, adev->wakeup.state.enabled);
386}
387
380static ssize_t 388static ssize_t
381acpi_system_write_wakeup_device(struct file *file, 389acpi_system_write_wakeup_device(struct file *file,
382 const char __user * buffer, 390 const char __user * buffer,
@@ -411,6 +419,7 @@ acpi_system_write_wakeup_device(struct file *file,
411 } 419 }
412 } 420 }
413 if (found_dev) { 421 if (found_dev) {
422 physical_device_enable_wakeup(found_dev);
414 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 423 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
415 struct acpi_device *dev = container_of(node, 424 struct acpi_device *dev = container_of(node,
416 struct 425 struct
@@ -428,6 +437,7 @@ acpi_system_write_wakeup_device(struct file *file,
428 dev->pnp.bus_id, found_dev->pnp.bus_id); 437 dev->pnp.bus_id, found_dev->pnp.bus_id);
429 dev->wakeup.state.enabled = 438 dev->wakeup.state.enabled =
430 found_dev->wakeup.state.enabled; 439 found_dev->wakeup.state.enabled;
440 physical_device_enable_wakeup(dev);
431 } 441 }
432 } 442 }
433 } 443 }
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 91dec448b3ed..3eefd6d029f9 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -387,8 +387,8 @@ static ssize_t counter_set(struct kobject *kobj,
387 goto end; 387 goto end;
388 388
389 if (!(all_counters[index].flags & ACPI_EVENT_VALID)) { 389 if (!(all_counters[index].flags & ACPI_EVENT_VALID)) {
390 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 390 printk(KERN_WARNING PREFIX
391 "Can not change Invalid GPE/Fixed Event status\n")); 391 "Can not change Invalid GPE/Fixed Event status\n");
392 return -EINVAL; 392 return -EINVAL;
393 } 393 }
394 394
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c
index b22185f55a16..18747ce8dd2f 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/tables/tbinstal.c
@@ -110,7 +110,6 @@ acpi_status
110acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) 110acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
111{ 111{
112 u32 i; 112 u32 i;
113 u32 length;
114 acpi_status status = AE_OK; 113 acpi_status status = AE_OK;
115 114
116 ACPI_FUNCTION_TRACE(tb_add_table); 115 ACPI_FUNCTION_TRACE(tb_add_table);
@@ -145,25 +144,64 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
145 } 144 }
146 } 145 }
147 146
148 length = ACPI_MIN(table_desc->length, 147 /*
149 acpi_gbl_root_table_list.tables[i].length); 148 * Check for a table match on the entire table length,
149 * not just the header.
150 */
151 if (table_desc->length !=
152 acpi_gbl_root_table_list.tables[i].length) {
153 continue;
154 }
155
150 if (ACPI_MEMCMP(table_desc->pointer, 156 if (ACPI_MEMCMP(table_desc->pointer,
151 acpi_gbl_root_table_list.tables[i].pointer, 157 acpi_gbl_root_table_list.tables[i].pointer,
152 length)) { 158 acpi_gbl_root_table_list.tables[i].length)) {
153 continue; 159 continue;
154 } 160 }
155 161
156 /* Table is already registered */ 162 /*
157 163 * Note: the current mechanism does not unregister a table if it is
164 * dynamically unloaded. The related namespace entries are deleted,
165 * but the table remains in the root table list.
166 *
167 * The assumption here is that the number of different tables that
168 * will be loaded is actually small, and there is minimal overhead
169 * in just keeping the table in case it is needed again.
170 *
171 * If this assumption changes in the future (perhaps on large
172 * machines with many table load/unload operations), tables will
173 * need to be unregistered when they are unloaded, and slots in the
174 * root table list should be reused when empty.
175 */
176
177 /*
178 * Table is already registered.
179 * We can delete the table that was passed as a parameter.
180 */
158 acpi_tb_delete_table(table_desc); 181 acpi_tb_delete_table(table_desc);
159 *table_index = i; 182 *table_index = i;
160 status = AE_ALREADY_EXISTS; 183
161 goto release; 184 if (acpi_gbl_root_table_list.tables[i].
185 flags & ACPI_TABLE_IS_LOADED) {
186
187 /* Table is still loaded, this is an error */
188
189 status = AE_ALREADY_EXISTS;
190 goto release;
191 } else {
192 /* Table was unloaded, allow it to be reloaded */
193
194 table_desc->pointer =
195 acpi_gbl_root_table_list.tables[i].pointer;
196 table_desc->address =
197 acpi_gbl_root_table_list.tables[i].address;
198 status = AE_OK;
199 goto print_header;
200 }
162 } 201 }
163 202
164 /* 203 /* Add the table to the global root table list */
165 * Add the table to the global table list 204
166 */
167 status = acpi_tb_store_table(table_desc->address, table_desc->pointer, 205 status = acpi_tb_store_table(table_desc->address, table_desc->pointer,
168 table_desc->length, table_desc->flags, 206 table_desc->length, table_desc->flags,
169 table_index); 207 table_index);
@@ -171,6 +209,7 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
171 goto release; 209 goto release;
172 } 210 }
173 211
212 print_header:
174 acpi_tb_print_table_header(table_desc->address, table_desc->pointer); 213 acpi_tb_print_table_header(table_desc->address, table_desc->pointer);
175 214
176 release: 215 release:
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 912703691d36..263ec08a9011 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -1213,8 +1213,8 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
1213 acpi_bus_private_data_handler, 1213 acpi_bus_private_data_handler,
1214 tz->thermal_zone); 1214 tz->thermal_zone);
1215 if (ACPI_FAILURE(status)) { 1215 if (ACPI_FAILURE(status)) {
1216 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1216 printk(KERN_ERR PREFIX
1217 "Error attaching device data\n")); 1217 "Error attaching device data\n");
1218 return -ENODEV; 1218 return -ENODEV;
1219 } 1219 }
1220 1220
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/utilities/utalloc.c
index 7dcb67e0b215..241c535c1753 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/utilities/utalloc.c
@@ -232,7 +232,7 @@ acpi_status acpi_ut_validate_buffer(struct acpi_buffer * buffer)
232 * RETURN: Status 232 * RETURN: Status
233 * 233 *
234 * DESCRIPTION: Validate that the buffer is of the required length or 234 * DESCRIPTION: Validate that the buffer is of the required length or
235 * allocate a new buffer. Returned buffer is always zeroed. 235 * allocate a new buffer. Returned buffer is always zeroed.
236 * 236 *
237 ******************************************************************************/ 237 ******************************************************************************/
238 238
@@ -240,7 +240,7 @@ acpi_status
240acpi_ut_initialize_buffer(struct acpi_buffer * buffer, 240acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
241 acpi_size required_length) 241 acpi_size required_length)
242{ 242{
243 acpi_status status = AE_OK; 243 acpi_size input_buffer_length;
244 244
245 /* Parameter validation */ 245 /* Parameter validation */
246 246
@@ -248,55 +248,58 @@ acpi_ut_initialize_buffer(struct acpi_buffer * buffer,
248 return (AE_BAD_PARAMETER); 248 return (AE_BAD_PARAMETER);
249 } 249 }
250 250
251 switch (buffer->length) { 251 /*
252 * Buffer->Length is used as both an input and output parameter. Get the
253 * input actual length and set the output required buffer length.
254 */
255 input_buffer_length = buffer->length;
256 buffer->length = required_length;
257
258 /*
259 * The input buffer length contains the actual buffer length, or the type
260 * of buffer to be allocated by this routine.
261 */
262 switch (input_buffer_length) {
252 case ACPI_NO_BUFFER: 263 case ACPI_NO_BUFFER:
253 264
254 /* Set the exception and returned the required length */ 265 /* Return the exception (and the required buffer length) */
255 266
256 status = AE_BUFFER_OVERFLOW; 267 return (AE_BUFFER_OVERFLOW);
257 break;
258 268
259 case ACPI_ALLOCATE_BUFFER: 269 case ACPI_ALLOCATE_BUFFER:
260 270
261 /* Allocate a new buffer */ 271 /* Allocate a new buffer */
262 272
263 buffer->pointer = acpi_os_allocate(required_length); 273 buffer->pointer = acpi_os_allocate(required_length);
264 if (!buffer->pointer) {
265 return (AE_NO_MEMORY);
266 }
267
268 /* Clear the buffer */
269
270 ACPI_MEMSET(buffer->pointer, 0, required_length);
271 break; 274 break;
272 275
273 case ACPI_ALLOCATE_LOCAL_BUFFER: 276 case ACPI_ALLOCATE_LOCAL_BUFFER:
274 277
275 /* Allocate a new buffer with local interface to allow tracking */ 278 /* Allocate a new buffer with local interface to allow tracking */
276 279
277 buffer->pointer = ACPI_ALLOCATE_ZEROED(required_length); 280 buffer->pointer = ACPI_ALLOCATE(required_length);
278 if (!buffer->pointer) {
279 return (AE_NO_MEMORY);
280 }
281 break; 281 break;
282 282
283 default: 283 default:
284 284
285 /* Existing buffer: Validate the size of the buffer */ 285 /* Existing buffer: Validate the size of the buffer */
286 286
287 if (buffer->length < required_length) { 287 if (input_buffer_length < required_length) {
288 status = AE_BUFFER_OVERFLOW; 288 return (AE_BUFFER_OVERFLOW);
289 break;
290 } 289 }
290 break;
291 }
291 292
292 /* Clear the buffer */ 293 /* Validate allocation from above or input buffer pointer */
293 294
294 ACPI_MEMSET(buffer->pointer, 0, required_length); 295 if (!buffer->pointer) {
295 break; 296 return (AE_NO_MEMORY);
296 } 297 }
297 298
298 buffer->length = required_length; 299 /* Have a valid buffer, clear it */
299 return (status); 300
301 ACPI_MEMSET(buffer->pointer, 0, required_length);
302 return (AE_OK);
300} 303}
301 304
302#ifdef NOT_USED_BY_LINUX 305#ifdef NOT_USED_BY_LINUX
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
index 53499ac90988..5b2f7c27b705 100644
--- a/drivers/acpi/utilities/utcopy.c
+++ b/drivers/acpi/utilities/utcopy.c
@@ -42,7 +42,6 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/amlcode.h>
46#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
47 46
48 47
@@ -176,20 +175,24 @@ acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
176 175
177 /* This is an object reference. */ 176 /* This is an object reference. */
178 177
179 switch (internal_object->reference.opcode) { 178 switch (internal_object->reference.class) {
180 case AML_INT_NAMEPATH_OP: 179 case ACPI_REFCLASS_NAME:
181
182 /* For namepath, return the object handle ("reference") */
183
184 default:
185
186 /* We are referring to the namespace node */
187 180
181 /*
182 * For namepath, return the object handle ("reference")
183 * We are referring to the namespace node
184 */
188 external_object->reference.handle = 185 external_object->reference.handle =
189 internal_object->reference.node; 186 internal_object->reference.node;
190 external_object->reference.actual_type = 187 external_object->reference.actual_type =
191 acpi_ns_get_type(internal_object->reference.node); 188 acpi_ns_get_type(internal_object->reference.node);
192 break; 189 break;
190
191 default:
192
193 /* All other reference types are unsupported */
194
195 return_ACPI_STATUS(AE_TYPE);
193 } 196 }
194 break; 197 break;
195 198
@@ -533,7 +536,7 @@ acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
533 536
534 /* TBD: should validate incoming handle */ 537 /* TBD: should validate incoming handle */
535 538
536 internal_object->reference.opcode = AML_INT_NAMEPATH_OP; 539 internal_object->reference.class = ACPI_REFCLASS_NAME;
537 internal_object->reference.node = 540 internal_object->reference.node =
538 external_object->reference.handle; 541 external_object->reference.handle;
539 break; 542 break;
@@ -743,11 +746,11 @@ acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
743 * We copied the reference object, so we now must add a reference 746 * We copied the reference object, so we now must add a reference
744 * to the object pointed to by the reference 747 * to the object pointed to by the reference
745 * 748 *
746 * DDBHandle reference (from Load/load_table is a special reference, 749 * DDBHandle reference (from Load/load_table) is a special reference,
747 * it's Reference.Object is the table index, so does not need to 750 * it does not have a Reference.Object, so does not need to
748 * increase the reference count 751 * increase the reference count
749 */ 752 */
750 if (source_desc->reference.opcode == AML_LOAD_OP) { 753 if (source_desc->reference.class == ACPI_REFCLASS_TABLE) {
751 break; 754 break;
752 } 755 }
753 756
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/utilities/utdelete.c
index 42609d3a8aa9..d197c6b29e17 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/utilities/utdelete.c
@@ -45,7 +45,6 @@
45#include <acpi/acinterp.h> 45#include <acpi/acinterp.h>
46#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
47#include <acpi/acevents.h> 47#include <acpi/acevents.h>
48#include <acpi/amlcode.h>
49 48
50#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
51ACPI_MODULE_NAME("utdelete") 50ACPI_MODULE_NAME("utdelete")
@@ -548,8 +547,8 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
548 * reference must track changes to the ref count of the index or 547 * reference must track changes to the ref count of the index or
549 * target object. 548 * target object.
550 */ 549 */
551 if ((object->reference.opcode == AML_INDEX_OP) || 550 if ((object->reference.class == ACPI_REFCLASS_INDEX) ||
552 (object->reference.opcode == AML_INT_NAMEPATH_OP)) { 551 (object->reference.class == ACPI_REFCLASS_NAME)) {
553 next_object = object->reference.object; 552 next_object = object->reference.object;
554 } 553 }
555 break; 554 break;
@@ -586,6 +585,13 @@ acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action)
586 ACPI_EXCEPTION((AE_INFO, status, 585 ACPI_EXCEPTION((AE_INFO, status,
587 "Could not update object reference count")); 586 "Could not update object reference count"));
588 587
588 /* Free any stacked Update State objects */
589
590 while (state_list) {
591 state = acpi_ut_pop_generic_state(&state_list);
592 acpi_ut_delete_generic_state(state);
593 }
594
589 return_ACPI_STATUS(status); 595 return_ACPI_STATUS(status);
590} 596}
591 597
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index a6e71b801d2d..670551b95e56 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -281,7 +281,6 @@ struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
281 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 281 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
282 ACPI_BITPOSITION_RT_CLOCK_ENABLE, 282 ACPI_BITPOSITION_RT_CLOCK_ENABLE,
283 ACPI_BITMASK_RT_CLOCK_ENABLE}, 283 ACPI_BITMASK_RT_CLOCK_ENABLE},
284 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
285 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, 284 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE,
286 ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, 285 ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,
287 ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, 286 ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
@@ -575,6 +574,47 @@ char *acpi_ut_get_descriptor_name(void *object)
575 574
576} 575}
577 576
577/*******************************************************************************
578 *
579 * FUNCTION: acpi_ut_get_reference_name
580 *
581 * PARAMETERS: Object - An ACPI reference object
582 *
583 * RETURN: Pointer to a string
584 *
585 * DESCRIPTION: Decode a reference object sub-type to a string.
586 *
587 ******************************************************************************/
588
589/* Printable names of reference object sub-types */
590
591static const char *acpi_gbl_ref_class_names[] = {
592 /* 00 */ "Local",
593 /* 01 */ "Argument",
594 /* 02 */ "RefOf",
595 /* 03 */ "Index",
596 /* 04 */ "DdbHandle",
597 /* 05 */ "Named Object",
598 /* 06 */ "Debug"
599};
600
601const char *acpi_ut_get_reference_name(union acpi_operand_object *object)
602{
603 if (!object)
604 return "NULL Object";
605
606 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND)
607 return "Not an Operand object";
608
609 if (object->common.type != ACPI_TYPE_LOCAL_REFERENCE)
610 return "Not a Reference object";
611
612 if (object->reference.class > ACPI_REFCLASS_MAX)
613 return "Unknown Reference class";
614
615 return acpi_gbl_ref_class_names[object->reference.class];
616}
617
578#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 618#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
579/* 619/*
580 * Strings and procedures used for debug only 620 * Strings and procedures used for debug only
@@ -677,14 +717,14 @@ u8 acpi_ut_valid_object_type(acpi_object_type type)
677 * 717 *
678 * PARAMETERS: None 718 * PARAMETERS: None
679 * 719 *
680 * RETURN: None 720 * RETURN: Status
681 * 721 *
682 * DESCRIPTION: Init library globals. All globals that require specific 722 * DESCRIPTION: Init library globals. All globals that require specific
683 * initialization should be initialized here! 723 * initialization should be initialized here!
684 * 724 *
685 ******************************************************************************/ 725 ******************************************************************************/
686 726
687void acpi_ut_init_globals(void) 727acpi_status acpi_ut_init_globals(void)
688{ 728{
689 acpi_status status; 729 acpi_status status;
690 u32 i; 730 u32 i;
@@ -695,7 +735,7 @@ void acpi_ut_init_globals(void)
695 735
696 status = acpi_ut_create_caches(); 736 status = acpi_ut_create_caches();
697 if (ACPI_FAILURE(status)) { 737 if (ACPI_FAILURE(status)) {
698 return; 738 return_ACPI_STATUS(status);
699 } 739 }
700 740
701 /* Mutex locked flags */ 741 /* Mutex locked flags */
@@ -772,8 +812,8 @@ void acpi_ut_init_globals(void)
772 acpi_gbl_display_final_mem_stats = FALSE; 812 acpi_gbl_display_final_mem_stats = FALSE;
773#endif 813#endif
774 814
775 return_VOID; 815 return_ACPI_STATUS(AE_OK);
776} 816}
777 817
778ACPI_EXPORT_SYMBOL(acpi_dbg_level) 818ACPI_EXPORT_SYMBOL(acpi_dbg_level)
779 ACPI_EXPORT_SYMBOL(acpi_dbg_layer) 819ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index f34be6773556..9089a158a874 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -995,6 +995,15 @@ acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
995 state->pkg. 995 state->pkg.
996 this_target_obj, 0); 996 this_target_obj, 0);
997 if (!state) { 997 if (!state) {
998
999 /* Free any stacked Update State objects */
1000
1001 while (state_list) {
1002 state =
1003 acpi_ut_pop_generic_state
1004 (&state_list);
1005 acpi_ut_delete_generic_state(state);
1006 }
998 return_ACPI_STATUS(AE_NO_MEMORY); 1007 return_ACPI_STATUS(AE_NO_MEMORY);
999 } 1008 }
1000 } 1009 }
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/utilities/utobject.c
index 916eff399eb3..c354e7a42bcd 100644
--- a/drivers/acpi/utilities/utobject.c
+++ b/drivers/acpi/utilities/utobject.c
@@ -43,7 +43,6 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include <acpi/acnamesp.h>
46#include <acpi/amlcode.h>
47 46
48#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utobject") 48ACPI_MODULE_NAME("utobject")
@@ -478,8 +477,8 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
478 477
479 case ACPI_TYPE_LOCAL_REFERENCE: 478 case ACPI_TYPE_LOCAL_REFERENCE:
480 479
481 switch (internal_object->reference.opcode) { 480 switch (internal_object->reference.class) {
482 case AML_INT_NAMEPATH_OP: 481 case ACPI_REFCLASS_NAME:
483 482
484 /* 483 /*
485 * Get the actual length of the full pathname to this object. 484 * Get the actual length of the full pathname to this object.
@@ -503,8 +502,10 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
503 * required eventually. 502 * required eventually.
504 */ 503 */
505 ACPI_ERROR((AE_INFO, 504 ACPI_ERROR((AE_INFO,
506 "Unsupported Reference opcode=%X in object %p", 505 "Cannot convert to external object - "
507 internal_object->reference.opcode, 506 "unsupported Reference Class [%s] %X in object %p",
507 acpi_ut_get_reference_name(internal_object),
508 internal_object->reference.class,
508 internal_object)); 509 internal_object));
509 status = AE_TYPE; 510 status = AE_TYPE;
510 break; 511 break;
@@ -513,7 +514,9 @@ acpi_ut_get_simple_object_size(union acpi_operand_object *internal_object,
513 514
514 default: 515 default:
515 516
516 ACPI_ERROR((AE_INFO, "Unsupported type=%X in object %p", 517 ACPI_ERROR((AE_INFO, "Cannot convert to external object - "
518 "unsupported type [%s] %X in object %p",
519 acpi_ut_get_object_type_name(internal_object),
517 ACPI_GET_OBJECT_TYPE(internal_object), 520 ACPI_GET_OBJECT_TYPE(internal_object),
518 internal_object)); 521 internal_object));
519 status = AE_TYPE; 522 status = AE_TYPE;
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/utilities/utxface.c
index f8bdadf3c32f..c198a4d40583 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/utilities/utxface.c
@@ -81,7 +81,12 @@ acpi_status __init acpi_initialize_subsystem(void)
81 81
82 /* Initialize all globals used by the subsystem */ 82 /* Initialize all globals used by the subsystem */
83 83
84 acpi_ut_init_globals(); 84 status = acpi_ut_init_globals();
85 if (ACPI_FAILURE(status)) {
86 ACPI_EXCEPTION((AE_INFO, status,
87 "During initialization of globals"));
88 return_ACPI_STATUS(status);
89 }
85 90
86 /* Create the default mutex objects */ 91 /* Create the default mutex objects */
87 92
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index e8a51a1700f7..4ae39ee8cdef 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -1530,8 +1530,8 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
1530 acpi_video_device_notify, 1530 acpi_video_device_notify,
1531 data); 1531 data);
1532 if (ACPI_FAILURE(status)) { 1532 if (ACPI_FAILURE(status)) {
1533 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 1533 printk(KERN_ERR PREFIX
1534 "Error installing notify handler\n")); 1534 "Error installing notify handler\n");
1535 if(data->brightness) 1535 if(data->brightness)
1536 kfree(data->brightness->levels); 1536 kfree(data->brightness->levels);
1537 kfree(data->brightness); 1537 kfree(data->brightness);
@@ -1745,8 +1745,8 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video,
1745 1745
1746 status = acpi_video_bus_get_one_device(dev, video); 1746 status = acpi_video_bus_get_one_device(dev, video);
1747 if (ACPI_FAILURE(status)) { 1747 if (ACPI_FAILURE(status)) {
1748 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 1748 printk(KERN_WARNING PREFIX
1749 "Cant attach device")); 1749 "Cant attach device");
1750 continue; 1750 continue;
1751 } 1751 }
1752 } 1752 }
@@ -2003,8 +2003,8 @@ static int acpi_video_bus_add(struct acpi_device *device)
2003 ACPI_DEVICE_NOTIFY, 2003 ACPI_DEVICE_NOTIFY,
2004 acpi_video_bus_notify, video); 2004 acpi_video_bus_notify, video);
2005 if (ACPI_FAILURE(status)) { 2005 if (ACPI_FAILURE(status)) {
2006 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 2006 printk(KERN_ERR PREFIX
2007 "Error installing notify handler\n")); 2007 "Error installing notify handler\n");
2008 error = -ENODEV; 2008 error = -ENODEV;
2009 goto err_stop_video; 2009 goto err_stop_video;
2010 } 2010 }
diff --git a/drivers/acpi/wmi.c b/drivers/acpi/wmi.c
index cfe2c833474d..47cd7baf9b1b 100644
--- a/drivers/acpi/wmi.c
+++ b/drivers/acpi/wmi.c
@@ -217,6 +217,35 @@ static bool find_guid(const char *guid_string, struct wmi_block **out)
217 return 0; 217 return 0;
218} 218}
219 219
220static acpi_status wmi_method_enable(struct wmi_block *wblock, int enable)
221{
222 struct guid_block *block = NULL;
223 char method[5];
224 struct acpi_object_list input;
225 union acpi_object params[1];
226 acpi_status status;
227 acpi_handle handle;
228
229 block = &wblock->gblock;
230 handle = wblock->handle;
231
232 if (!block)
233 return AE_NOT_EXIST;
234
235 input.count = 1;
236 input.pointer = params;
237 params[0].type = ACPI_TYPE_INTEGER;
238 params[0].integer.value = enable;
239
240 snprintf(method, 5, "WE%02X", block->notify_id);
241 status = acpi_evaluate_object(handle, method, &input, NULL);
242
243 if (status != AE_OK && status != AE_NOT_FOUND)
244 return status;
245 else
246 return AE_OK;
247}
248
220/* 249/*
221 * Exported WMI functions 250 * Exported WMI functions
222 */ 251 */
@@ -242,7 +271,7 @@ u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out)
242 char method[4] = "WM"; 271 char method[4] = "WM";
243 272
244 if (!find_guid(guid_string, &wblock)) 273 if (!find_guid(guid_string, &wblock))
245 return AE_BAD_ADDRESS; 274 return AE_ERROR;
246 275
247 block = &wblock->gblock; 276 block = &wblock->gblock;
248 handle = wblock->handle; 277 handle = wblock->handle;
@@ -304,7 +333,7 @@ struct acpi_buffer *out)
304 return AE_BAD_PARAMETER; 333 return AE_BAD_PARAMETER;
305 334
306 if (!find_guid(guid_string, &wblock)) 335 if (!find_guid(guid_string, &wblock))
307 return AE_BAD_ADDRESS; 336 return AE_ERROR;
308 337
309 block = &wblock->gblock; 338 block = &wblock->gblock;
310 handle = wblock->handle; 339 handle = wblock->handle;
@@ -314,7 +343,7 @@ struct acpi_buffer *out)
314 343
315 /* Check GUID is a data block */ 344 /* Check GUID is a data block */
316 if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD)) 345 if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD))
317 return AE_BAD_ADDRESS; 346 return AE_ERROR;
318 347
319 input.count = 1; 348 input.count = 1;
320 input.pointer = wq_params; 349 input.pointer = wq_params;
@@ -385,7 +414,7 @@ const struct acpi_buffer *in)
385 return AE_BAD_DATA; 414 return AE_BAD_DATA;
386 415
387 if (!find_guid(guid_string, &wblock)) 416 if (!find_guid(guid_string, &wblock))
388 return AE_BAD_ADDRESS; 417 return AE_ERROR;
389 418
390 block = &wblock->gblock; 419 block = &wblock->gblock;
391 handle = wblock->handle; 420 handle = wblock->handle;
@@ -395,7 +424,7 @@ const struct acpi_buffer *in)
395 424
396 /* Check GUID is a data block */ 425 /* Check GUID is a data block */
397 if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD)) 426 if (block->flags & (ACPI_WMI_EVENT | ACPI_WMI_METHOD))
398 return AE_BAD_ADDRESS; 427 return AE_ERROR;
399 428
400 input.count = 2; 429 input.count = 2;
401 input.pointer = params; 430 input.pointer = params;
@@ -427,6 +456,7 @@ acpi_status wmi_install_notify_handler(const char *guid,
427wmi_notify_handler handler, void *data) 456wmi_notify_handler handler, void *data)
428{ 457{
429 struct wmi_block *block; 458 struct wmi_block *block;
459 acpi_status status;
430 460
431 if (!guid || !handler) 461 if (!guid || !handler)
432 return AE_BAD_PARAMETER; 462 return AE_BAD_PARAMETER;
@@ -441,7 +471,9 @@ wmi_notify_handler handler, void *data)
441 block->handler = handler; 471 block->handler = handler;
442 block->handler_data = data; 472 block->handler_data = data;
443 473
444 return AE_OK; 474 status = wmi_method_enable(block, 1);
475
476 return status;
445} 477}
446EXPORT_SYMBOL_GPL(wmi_install_notify_handler); 478EXPORT_SYMBOL_GPL(wmi_install_notify_handler);
447 479
@@ -453,6 +485,7 @@ EXPORT_SYMBOL_GPL(wmi_install_notify_handler);
453acpi_status wmi_remove_notify_handler(const char *guid) 485acpi_status wmi_remove_notify_handler(const char *guid)
454{ 486{
455 struct wmi_block *block; 487 struct wmi_block *block;
488 acpi_status status;
456 489
457 if (!guid) 490 if (!guid)
458 return AE_BAD_PARAMETER; 491 return AE_BAD_PARAMETER;
@@ -464,10 +497,12 @@ acpi_status wmi_remove_notify_handler(const char *guid)
464 if (!block->handler) 497 if (!block->handler)
465 return AE_NULL_ENTRY; 498 return AE_NULL_ENTRY;
466 499
500 status = wmi_method_enable(block, 0);
501
467 block->handler = NULL; 502 block->handler = NULL;
468 block->handler_data = NULL; 503 block->handler_data = NULL;
469 504
470 return AE_OK; 505 return status;
471} 506}
472EXPORT_SYMBOL_GPL(wmi_remove_notify_handler); 507EXPORT_SYMBOL_GPL(wmi_remove_notify_handler);
473 508
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 1e1f3f3757ae..14601dc05e41 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -309,6 +309,8 @@ static void nv_nf2_freeze(struct ata_port *ap);
309static void nv_nf2_thaw(struct ata_port *ap); 309static void nv_nf2_thaw(struct ata_port *ap);
310static void nv_ck804_freeze(struct ata_port *ap); 310static void nv_ck804_freeze(struct ata_port *ap);
311static void nv_ck804_thaw(struct ata_port *ap); 311static void nv_ck804_thaw(struct ata_port *ap);
312static int nv_hardreset(struct ata_link *link, unsigned int *class,
313 unsigned long deadline);
312static int nv_adma_slave_config(struct scsi_device *sdev); 314static int nv_adma_slave_config(struct scsi_device *sdev);
313static int nv_adma_check_atapi_dma(struct ata_queued_cmd *qc); 315static int nv_adma_check_atapi_dma(struct ata_queued_cmd *qc);
314static void nv_adma_qc_prep(struct ata_queued_cmd *qc); 316static void nv_adma_qc_prep(struct ata_queued_cmd *qc);
@@ -403,28 +405,45 @@ static struct scsi_host_template nv_swncq_sht = {
403 .slave_configure = nv_swncq_slave_config, 405 .slave_configure = nv_swncq_slave_config,
404}; 406};
405 407
406static struct ata_port_operations nv_generic_ops = { 408/* OSDL bz3352 reports that some nv controllers can't determine device
409 * signature reliably and nv_hardreset is implemented to work around
410 * the problem. This was reported on nf3 and it's unclear whether any
411 * other controllers are affected. However, the workaround has been
412 * applied to all variants and there isn't much to gain by trying to
413 * find out exactly which ones are affected at this point especially
414 * because NV has moved over to ahci for newer controllers.
415 */
416static struct ata_port_operations nv_common_ops = {
407 .inherits = &ata_bmdma_port_ops, 417 .inherits = &ata_bmdma_port_ops,
408 .hardreset = ATA_OP_NULL, 418 .hardreset = nv_hardreset,
409 .scr_read = nv_scr_read, 419 .scr_read = nv_scr_read,
410 .scr_write = nv_scr_write, 420 .scr_write = nv_scr_write,
411}; 421};
412 422
423/* OSDL bz11195 reports that link doesn't come online after hardreset
424 * on generic nv's and there have been several other similar reports
425 * on linux-ide. Disable hardreset for generic nv's.
426 */
427static struct ata_port_operations nv_generic_ops = {
428 .inherits = &nv_common_ops,
429 .hardreset = ATA_OP_NULL,
430};
431
413static struct ata_port_operations nv_nf2_ops = { 432static struct ata_port_operations nv_nf2_ops = {
414 .inherits = &nv_generic_ops, 433 .inherits = &nv_common_ops,
415 .freeze = nv_nf2_freeze, 434 .freeze = nv_nf2_freeze,
416 .thaw = nv_nf2_thaw, 435 .thaw = nv_nf2_thaw,
417}; 436};
418 437
419static struct ata_port_operations nv_ck804_ops = { 438static struct ata_port_operations nv_ck804_ops = {
420 .inherits = &nv_generic_ops, 439 .inherits = &nv_common_ops,
421 .freeze = nv_ck804_freeze, 440 .freeze = nv_ck804_freeze,
422 .thaw = nv_ck804_thaw, 441 .thaw = nv_ck804_thaw,
423 .host_stop = nv_ck804_host_stop, 442 .host_stop = nv_ck804_host_stop,
424}; 443};
425 444
426static struct ata_port_operations nv_adma_ops = { 445static struct ata_port_operations nv_adma_ops = {
427 .inherits = &nv_generic_ops, 446 .inherits = &nv_common_ops,
428 447
429 .check_atapi_dma = nv_adma_check_atapi_dma, 448 .check_atapi_dma = nv_adma_check_atapi_dma,
430 .sff_tf_read = nv_adma_tf_read, 449 .sff_tf_read = nv_adma_tf_read,
@@ -448,7 +467,7 @@ static struct ata_port_operations nv_adma_ops = {
448}; 467};
449 468
450static struct ata_port_operations nv_swncq_ops = { 469static struct ata_port_operations nv_swncq_ops = {
451 .inherits = &nv_generic_ops, 470 .inherits = &nv_common_ops,
452 471
453 .qc_defer = ata_std_qc_defer, 472 .qc_defer = ata_std_qc_defer,
454 .qc_prep = nv_swncq_qc_prep, 473 .qc_prep = nv_swncq_qc_prep,
@@ -1586,6 +1605,21 @@ static void nv_mcp55_thaw(struct ata_port *ap)
1586 ata_sff_thaw(ap); 1605 ata_sff_thaw(ap);
1587} 1606}
1588 1607
1608static int nv_hardreset(struct ata_link *link, unsigned int *class,
1609 unsigned long deadline)
1610{
1611 int rc;
1612
1613 /* SATA hardreset fails to retrieve proper device signature on
1614 * some controllers. Request follow up SRST. For more info,
1615 * see http://bugzilla.kernel.org/show_bug.cgi?id=3352
1616 */
1617 rc = sata_sff_hardreset(link, class, deadline);
1618 if (rc)
1619 return rc;
1620 return -EAGAIN;
1621}
1622
1589static void nv_adma_error_handler(struct ata_port *ap) 1623static void nv_adma_error_handler(struct ata_port *ap)
1590{ 1624{
1591 struct nv_adma_port_priv *pp = ap->private_data; 1625 struct nv_adma_port_priv *pp = ap->private_data;
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index 1e55a658e6ce..32f3a8ed8d3d 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -256,7 +256,6 @@ static inline int bpa10x_submit_intr_urb(struct hci_dev *hdev)
256 BT_ERR("%s urb %p submission failed (%d)", 256 BT_ERR("%s urb %p submission failed (%d)",
257 hdev->name, urb, -err); 257 hdev->name, urb, -err);
258 usb_unanchor_urb(urb); 258 usb_unanchor_urb(urb);
259 kfree(buf);
260 } 259 }
261 260
262 usb_free_urb(urb); 261 usb_free_urb(urb);
@@ -298,7 +297,6 @@ static inline int bpa10x_submit_bulk_urb(struct hci_dev *hdev)
298 BT_ERR("%s urb %p submission failed (%d)", 297 BT_ERR("%s urb %p submission failed (%d)",
299 hdev->name, urb, -err); 298 hdev->name, urb, -err);
300 usb_unanchor_urb(urb); 299 usb_unanchor_urb(urb);
301 kfree(buf);
302 } 300 }
303 301
304 usb_free_urb(urb); 302 usb_free_urb(urb);
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 6a010681ecf3..af472e052732 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -102,14 +102,19 @@ static struct usb_device_id blacklist_table[] = {
102 { USB_DEVICE(0x0a5c, 0x2101), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 102 { USB_DEVICE(0x0a5c, 0x2101), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU },
103 103
104 /* Broadcom BCM2046 */ 104 /* Broadcom BCM2046 */
105 { USB_DEVICE(0x0a5c, 0x2146), .driver_info = BTUSB_RESET },
105 { USB_DEVICE(0x0a5c, 0x2151), .driver_info = BTUSB_RESET }, 106 { USB_DEVICE(0x0a5c, 0x2151), .driver_info = BTUSB_RESET },
106 107
108 /* Apple MacBook Pro with Broadcom chip */
109 { USB_DEVICE(0x05ac, 0x820f), .driver_info = BTUSB_RESET },
110
107 /* IBM/Lenovo ThinkPad with Broadcom chip */ 111 /* IBM/Lenovo ThinkPad with Broadcom chip */
108 { USB_DEVICE(0x0a5c, 0x201e), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 112 { USB_DEVICE(0x0a5c, 0x201e), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU },
109 { USB_DEVICE(0x0a5c, 0x2110), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 113 { USB_DEVICE(0x0a5c, 0x2110), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU },
110 114
111 /* Targus ACB10US */ 115 /* Targus ACB10US */
112 { USB_DEVICE(0x0a5c, 0x2100), .driver_info = BTUSB_RESET }, 116 { USB_DEVICE(0x0a5c, 0x2100), .driver_info = BTUSB_RESET },
117 { USB_DEVICE(0x0a5c, 0x2154), .driver_info = BTUSB_RESET },
113 118
114 /* ANYCOM Bluetooth USB-200 and USB-250 */ 119 /* ANYCOM Bluetooth USB-200 and USB-250 */
115 { USB_DEVICE(0x0a5c, 0x2111), .driver_info = BTUSB_RESET }, 120 { USB_DEVICE(0x0a5c, 0x2111), .driver_info = BTUSB_RESET },
@@ -147,6 +152,9 @@ static struct usb_device_id blacklist_table[] = {
147 { USB_DEVICE(0x050d, 0x0012), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 152 { USB_DEVICE(0x050d, 0x0012), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU },
148 { USB_DEVICE(0x050d, 0x0013), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU }, 153 { USB_DEVICE(0x050d, 0x0013), .driver_info = BTUSB_RESET | BTUSB_WRONG_SCO_MTU },
149 154
155 /* Belkin F8T016 device */
156 { USB_DEVICE(0x050d, 0x016a), .driver_info = BTUSB_RESET },
157
150 /* Digianswer devices */ 158 /* Digianswer devices */
151 { USB_DEVICE(0x08fd, 0x0001), .driver_info = BTUSB_DIGIANSWER }, 159 { USB_DEVICE(0x08fd, 0x0001), .driver_info = BTUSB_DIGIANSWER },
152 { USB_DEVICE(0x08fd, 0x0002), .driver_info = BTUSB_IGNORE }, 160 { USB_DEVICE(0x08fd, 0x0002), .driver_info = BTUSB_IGNORE },
@@ -169,6 +177,7 @@ static struct usb_device_id blacklist_table[] = {
169struct btusb_data { 177struct btusb_data {
170 struct hci_dev *hdev; 178 struct hci_dev *hdev;
171 struct usb_device *udev; 179 struct usb_device *udev;
180 struct usb_interface *intf;
172 struct usb_interface *isoc; 181 struct usb_interface *isoc;
173 182
174 spinlock_t lock; 183 spinlock_t lock;
@@ -267,7 +276,6 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev)
267 BT_ERR("%s urb %p submission failed (%d)", 276 BT_ERR("%s urb %p submission failed (%d)",
268 hdev->name, urb, -err); 277 hdev->name, urb, -err);
269 usb_unanchor_urb(urb); 278 usb_unanchor_urb(urb);
270 kfree(buf);
271 } 279 }
272 280
273 usb_free_urb(urb); 281 usb_free_urb(urb);
@@ -350,7 +358,6 @@ static int btusb_submit_bulk_urb(struct hci_dev *hdev)
350 BT_ERR("%s urb %p submission failed (%d)", 358 BT_ERR("%s urb %p submission failed (%d)",
351 hdev->name, urb, -err); 359 hdev->name, urb, -err);
352 usb_unanchor_urb(urb); 360 usb_unanchor_urb(urb);
353 kfree(buf);
354 } 361 }
355 362
356 usb_free_urb(urb); 363 usb_free_urb(urb);
@@ -471,7 +478,6 @@ static int btusb_submit_isoc_urb(struct hci_dev *hdev)
471 BT_ERR("%s urb %p submission failed (%d)", 478 BT_ERR("%s urb %p submission failed (%d)",
472 hdev->name, urb, -err); 479 hdev->name, urb, -err);
473 usb_unanchor_urb(urb); 480 usb_unanchor_urb(urb);
474 kfree(buf);
475 } 481 }
476 482
477 usb_free_urb(urb); 483 usb_free_urb(urb);
@@ -516,7 +522,7 @@ static int btusb_open(struct hci_dev *hdev)
516 522
517 err = btusb_submit_intr_urb(hdev); 523 err = btusb_submit_intr_urb(hdev);
518 if (err < 0) { 524 if (err < 0) {
519 clear_bit(BTUSB_INTR_RUNNING, &hdev->flags); 525 clear_bit(BTUSB_INTR_RUNNING, &data->flags);
520 clear_bit(HCI_RUNNING, &hdev->flags); 526 clear_bit(HCI_RUNNING, &hdev->flags);
521 } 527 }
522 528
@@ -532,8 +538,10 @@ static int btusb_close(struct hci_dev *hdev)
532 if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) 538 if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
533 return 0; 539 return 0;
534 540
541 cancel_work_sync(&data->work);
542
535 clear_bit(BTUSB_ISOC_RUNNING, &data->flags); 543 clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
536 usb_kill_anchored_urbs(&data->intr_anchor); 544 usb_kill_anchored_urbs(&data->isoc_anchor);
537 545
538 clear_bit(BTUSB_BULK_RUNNING, &data->flags); 546 clear_bit(BTUSB_BULK_RUNNING, &data->flags);
539 usb_kill_anchored_urbs(&data->bulk_anchor); 547 usb_kill_anchored_urbs(&data->bulk_anchor);
@@ -821,6 +829,7 @@ static int btusb_probe(struct usb_interface *intf,
821 } 829 }
822 830
823 data->udev = interface_to_usbdev(intf); 831 data->udev = interface_to_usbdev(intf);
832 data->intf = intf;
824 833
825 spin_lock_init(&data->lock); 834 spin_lock_init(&data->lock);
826 835
@@ -889,7 +898,7 @@ static int btusb_probe(struct usb_interface *intf,
889 898
890 if (data->isoc) { 899 if (data->isoc) {
891 err = usb_driver_claim_interface(&btusb_driver, 900 err = usb_driver_claim_interface(&btusb_driver,
892 data->isoc, NULL); 901 data->isoc, data);
893 if (err < 0) { 902 if (err < 0) {
894 hci_free_dev(hdev); 903 hci_free_dev(hdev);
895 kfree(data); 904 kfree(data);
@@ -921,13 +930,22 @@ static void btusb_disconnect(struct usb_interface *intf)
921 930
922 hdev = data->hdev; 931 hdev = data->hdev;
923 932
924 if (data->isoc) 933 __hci_dev_hold(hdev);
925 usb_driver_release_interface(&btusb_driver, data->isoc);
926 934
927 usb_set_intfdata(intf, NULL); 935 usb_set_intfdata(data->intf, NULL);
936
937 if (data->isoc)
938 usb_set_intfdata(data->isoc, NULL);
928 939
929 hci_unregister_dev(hdev); 940 hci_unregister_dev(hdev);
930 941
942 if (intf == data->isoc)
943 usb_driver_release_interface(&btusb_driver, data->intf);
944 else if (data->isoc)
945 usb_driver_release_interface(&btusb_driver, data->isoc);
946
947 __hci_dev_put(hdev);
948
931 hci_free_dev(hdev); 949 hci_free_dev(hdev);
932} 950}
933 951
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index daeb8f766971..e4dce8709541 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -695,13 +695,23 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line)
695{ 695{
696 struct tty_driver *p, *res = NULL; 696 struct tty_driver *p, *res = NULL;
697 int tty_line = 0; 697 int tty_line = 0;
698 int len;
698 char *str; 699 char *str;
699 700
701 for (str = name; *str; str++)
702 if ((*str >= '0' && *str <= '9') || *str == ',')
703 break;
704 if (!*str)
705 return NULL;
706
707 len = str - name;
708 tty_line = simple_strtoul(str, &str, 10);
709
700 mutex_lock(&tty_mutex); 710 mutex_lock(&tty_mutex);
701 /* Search through the tty devices to look for a match */ 711 /* Search through the tty devices to look for a match */
702 list_for_each_entry(p, &tty_drivers, tty_drivers) { 712 list_for_each_entry(p, &tty_drivers, tty_drivers) {
703 str = name + strlen(p->name); 713 if (strncmp(name, p->name, len) != 0)
704 tty_line = simple_strtoul(str, &str, 10); 714 continue;
705 if (*str == ',') 715 if (*str == ',')
706 str++; 716 str++;
707 if (*str == '\0') 717 if (*str == '\0')
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 5ce07b517c58..bb6e3b338043 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -56,7 +56,11 @@ static void cpuidle_idle_call(void)
56 if (pm_idle_old) 56 if (pm_idle_old)
57 pm_idle_old(); 57 pm_idle_old();
58 else 58 else
59#if defined(CONFIG_ARCH_HAS_DEFAULT_IDLE)
60 default_idle();
61#else
59 local_irq_enable(); 62 local_irq_enable();
63#endif
60 return; 64 return;
61 } 65 }
62 66
@@ -67,8 +71,11 @@ static void cpuidle_idle_call(void)
67 target_state = &dev->states[next_state]; 71 target_state = &dev->states[next_state];
68 72
69 /* enter the state and update stats */ 73 /* enter the state and update stats */
70 dev->last_residency = target_state->enter(dev, target_state);
71 dev->last_state = target_state; 74 dev->last_state = target_state;
75 dev->last_residency = target_state->enter(dev, target_state);
76 if (dev->last_state)
77 target_state = dev->last_state;
78
72 target_state->time += (unsigned long long)dev->last_residency; 79 target_state->time += (unsigned long long)dev->last_residency;
73 target_state->usage++; 80 target_state->usage++;
74 81
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 94df91771243..0778d99aea7c 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -364,7 +364,7 @@ static void dw_dma_tasklet(unsigned long data)
364 int i; 364 int i;
365 365
366 status_block = dma_readl(dw, RAW.BLOCK); 366 status_block = dma_readl(dw, RAW.BLOCK);
367 status_xfer = dma_readl(dw, RAW.BLOCK); 367 status_xfer = dma_readl(dw, RAW.XFER);
368 status_err = dma_readl(dw, RAW.ERROR); 368 status_err = dma_readl(dw, RAW.ERROR);
369 369
370 dev_vdbg(dw->dma.dev, "tasklet: status_block=%x status_err=%x\n", 370 dev_vdbg(dw->dma.dev, "tasklet: status_block=%x status_err=%x\n",
diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c
index d568c65c1370..d9e7a49d6cbf 100644
--- a/drivers/hwmon/abituguru3.c
+++ b/drivers/hwmon/abituguru3.c
@@ -279,7 +279,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
279 { "OTES1 Fan", 36, 2, 60, 1, 0 }, 279 { "OTES1 Fan", 36, 2, 60, 1, 0 },
280 { NULL, 0, 0, 0, 0, 0 } } 280 { NULL, 0, 0, 0, 0, 0 } }
281 }, 281 },
282 { 0x0011, NULL /* Abit AT8 32X, need DMI string */, { 282 { 0x0011, "AT8 32X(ATI RD580-ULI M1575)", {
283 { "CPU Core", 0, 0, 10, 1, 0 }, 283 { "CPU Core", 0, 0, 10, 1, 0 },
284 { "DDR", 1, 0, 20, 1, 0 }, 284 { "DDR", 1, 0, 20, 1, 0 },
285 { "DDR VTT", 2, 0, 10, 1, 0 }, 285 { "DDR VTT", 2, 0, 10, 1, 0 },
@@ -303,6 +303,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
303 { "SYS Fan", 34, 2, 60, 1, 0 }, 303 { "SYS Fan", 34, 2, 60, 1, 0 },
304 { "AUX1 Fan", 35, 2, 60, 1, 0 }, 304 { "AUX1 Fan", 35, 2, 60, 1, 0 },
305 { "AUX2 Fan", 36, 2, 60, 1, 0 }, 305 { "AUX2 Fan", 36, 2, 60, 1, 0 },
306 { "AUX3 Fan", 37, 2, 60, 1, 0 },
306 { NULL, 0, 0, 0, 0, 0 } } 307 { NULL, 0, 0, 0, 0, 0 } }
307 }, 308 },
308 { 0x0012, NULL /* Abit AN8 32X, need DMI string */, { 309 { 0x0012, NULL /* Abit AN8 32X, need DMI string */, {
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index f1133081cc42..d793cc011990 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -46,6 +46,8 @@
46#include <linux/err.h> 46#include <linux/err.h>
47#include <linux/mutex.h> 47#include <linux/mutex.h>
48#include <linux/sysfs.h> 48#include <linux/sysfs.h>
49#include <linux/string.h>
50#include <linux/dmi.h>
49#include <asm/io.h> 51#include <asm/io.h>
50 52
51#define DRVNAME "it87" 53#define DRVNAME "it87"
@@ -236,6 +238,8 @@ struct it87_sio_data {
236 /* Values read from Super-I/O config space */ 238 /* Values read from Super-I/O config space */
237 u8 revision; 239 u8 revision;
238 u8 vid_value; 240 u8 vid_value;
241 /* Values set based on DMI strings */
242 u8 skip_pwm;
239}; 243};
240 244
241/* For each registered chip, we need to keep some data in memory. 245/* For each registered chip, we need to keep some data in memory.
@@ -964,6 +968,7 @@ static int __init it87_find(unsigned short *address,
964{ 968{
965 int err = -ENODEV; 969 int err = -ENODEV;
966 u16 chip_type; 970 u16 chip_type;
971 const char *board_vendor, *board_name;
967 972
968 superio_enter(); 973 superio_enter();
969 chip_type = force_id ? force_id : superio_inw(DEVID); 974 chip_type = force_id ? force_id : superio_inw(DEVID);
@@ -1022,6 +1027,24 @@ static int __init it87_find(unsigned short *address,
1022 pr_info("it87: in7 is VCCH (+5V Stand-By)\n"); 1027 pr_info("it87: in7 is VCCH (+5V Stand-By)\n");
1023 } 1028 }
1024 1029
1030 /* Disable specific features based on DMI strings */
1031 board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
1032 board_name = dmi_get_system_info(DMI_BOARD_NAME);
1033 if (board_vendor && board_name) {
1034 if (strcmp(board_vendor, "nVIDIA") == 0
1035 && strcmp(board_name, "FN68PT") == 0) {
1036 /* On the Shuttle SN68PT, FAN_CTL2 is apparently not
1037 connected to a fan, but to something else. One user
1038 has reported instant system power-off when changing
1039 the PWM2 duty cycle, so we disable it.
1040 I use the board name string as the trigger in case
1041 the same board is ever used in other systems. */
1042 pr_info("it87: Disabling pwm2 due to "
1043 "hardware constraints\n");
1044 sio_data->skip_pwm = (1 << 1);
1045 }
1046 }
1047
1025exit: 1048exit:
1026 superio_exit(); 1049 superio_exit();
1027 return err; 1050 return err;
@@ -1168,25 +1191,33 @@ static int __devinit it87_probe(struct platform_device *pdev)
1168 } 1191 }
1169 1192
1170 if (enable_pwm_interface) { 1193 if (enable_pwm_interface) {
1171 if ((err = device_create_file(dev, 1194 if (!(sio_data->skip_pwm & (1 << 0))) {
1172 &sensor_dev_attr_pwm1_enable.dev_attr)) 1195 if ((err = device_create_file(dev,
1173 || (err = device_create_file(dev, 1196 &sensor_dev_attr_pwm1_enable.dev_attr))
1174 &sensor_dev_attr_pwm2_enable.dev_attr)) 1197 || (err = device_create_file(dev,
1175 || (err = device_create_file(dev, 1198 &sensor_dev_attr_pwm1.dev_attr))
1176 &sensor_dev_attr_pwm3_enable.dev_attr)) 1199 || (err = device_create_file(dev,
1177 || (err = device_create_file(dev, 1200 &dev_attr_pwm1_freq)))
1178 &sensor_dev_attr_pwm1.dev_attr)) 1201 goto ERROR4;
1179 || (err = device_create_file(dev, 1202 }
1180 &sensor_dev_attr_pwm2.dev_attr)) 1203 if (!(sio_data->skip_pwm & (1 << 1))) {
1181 || (err = device_create_file(dev, 1204 if ((err = device_create_file(dev,
1182 &sensor_dev_attr_pwm3.dev_attr)) 1205 &sensor_dev_attr_pwm2_enable.dev_attr))
1183 || (err = device_create_file(dev, 1206 || (err = device_create_file(dev,
1184 &dev_attr_pwm1_freq)) 1207 &sensor_dev_attr_pwm2.dev_attr))
1185 || (err = device_create_file(dev, 1208 || (err = device_create_file(dev,
1186 &dev_attr_pwm2_freq)) 1209 &dev_attr_pwm2_freq)))
1187 || (err = device_create_file(dev, 1210 goto ERROR4;
1188 &dev_attr_pwm3_freq))) 1211 }
1189 goto ERROR4; 1212 if (!(sio_data->skip_pwm & (1 << 2))) {
1213 if ((err = device_create_file(dev,
1214 &sensor_dev_attr_pwm3_enable.dev_attr))
1215 || (err = device_create_file(dev,
1216 &sensor_dev_attr_pwm3.dev_attr))
1217 || (err = device_create_file(dev,
1218 &dev_attr_pwm3_freq)))
1219 goto ERROR4;
1220 }
1190 } 1221 }
1191 1222
1192 if (data->type == it8712 || data->type == it8716 1223 if (data->type == it8712 || data->type == it8716
@@ -1546,6 +1577,7 @@ static int __init sm_it87_init(void)
1546 unsigned short isa_address=0; 1577 unsigned short isa_address=0;
1547 struct it87_sio_data sio_data; 1578 struct it87_sio_data sio_data;
1548 1579
1580 memset(&sio_data, 0, sizeof(struct it87_sio_data));
1549 err = it87_find(&isa_address, &sio_data); 1581 err = it87_find(&isa_address, &sio_data);
1550 if (err) 1582 if (err)
1551 return err; 1583 return err;
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
index 22f6d5c00d80..0e7b1c6724aa 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -180,7 +180,7 @@ static const struct i2c_algorithm i2c_powermac_algorithm = {
180}; 180};
181 181
182 182
183static int i2c_powermac_remove(struct platform_device *dev) 183static int __devexit i2c_powermac_remove(struct platform_device *dev)
184{ 184{
185 struct i2c_adapter *adapter = platform_get_drvdata(dev); 185 struct i2c_adapter *adapter = platform_get_drvdata(dev);
186 struct pmac_i2c_bus *bus = i2c_get_adapdata(adapter); 186 struct pmac_i2c_bus *bus = i2c_get_adapdata(adapter);
@@ -200,7 +200,7 @@ static int i2c_powermac_remove(struct platform_device *dev)
200} 200}
201 201
202 202
203static int __devexit i2c_powermac_probe(struct platform_device *dev) 203static int __devinit i2c_powermac_probe(struct platform_device *dev)
204{ 204{
205 struct pmac_i2c_bus *bus = dev->dev.platform_data; 205 struct pmac_i2c_bus *bus = dev->dev.platform_data;
206 struct device_node *parent = NULL; 206 struct device_node *parent = NULL;
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index af4491fa7e34..307d976c9b69 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -583,8 +583,10 @@ static int __init i2c_dev_init(void)
583 goto out; 583 goto out;
584 584
585 i2c_dev_class = class_create(THIS_MODULE, "i2c-dev"); 585 i2c_dev_class = class_create(THIS_MODULE, "i2c-dev");
586 if (IS_ERR(i2c_dev_class)) 586 if (IS_ERR(i2c_dev_class)) {
587 res = PTR_ERR(i2c_dev_class);
587 goto out_unreg_chrdev; 588 goto out_unreg_chrdev;
589 }
588 590
589 res = i2c_add_driver(&i2cdev_driver); 591 res = i2c_add_driver(&i2cdev_driver);
590 if (res) 592 if (res)
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index fc735ab08ff4..052879a6f853 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -292,6 +292,20 @@ config IDE_GENERIC
292 tristate "generic/default IDE chipset support" 292 tristate "generic/default IDE chipset support"
293 depends on ALPHA || X86 || IA64 || M32R || MIPS 293 depends on ALPHA || X86 || IA64 || M32R || MIPS
294 help 294 help
295 This is the generic IDE driver. This driver attaches to the
296 fixed legacy ports (e.g. on PCs 0x1f0/0x170, 0x1e8/0x168 and
297 so on). Please note that if this driver is built into the
298 kernel or loaded before other ATA (IDE or libata) drivers
299 and the controller is located at legacy ports, this driver
300 may grab those ports and thus can prevent the controller
301 specific driver from attaching.
302
303 Also, currently, IDE generic doesn't allow IRQ sharing
304 meaning that the IRQs it grabs won't be available to other
305 controllers sharing those IRQs which usually makes drivers
306 for those controllers fail. Generally, it's not a good idea
307 to load IDE generic driver on modern systems.
308
295 If unsure, say N. 309 If unsure, say N.
296 310
297config BLK_DEV_PLATFORM 311config BLK_DEV_PLATFORM
@@ -766,10 +780,6 @@ config BLK_DEV_IDEDMA_PMAC
766 to transfer data to and from memory. Saying Y is safe and improves 780 to transfer data to and from memory. Saying Y is safe and improves
767 performance. 781 performance.
768 782
769config BLK_DEV_IDE_SWARM
770 tristate "IDE for Sibyte evaluation boards"
771 depends on SIBYTE_SB1xxx_SOC
772
773config BLK_DEV_IDE_AU1XXX 783config BLK_DEV_IDE_AU1XXX
774 bool "IDE for AMD Alchemy Au1200" 784 bool "IDE for AMD Alchemy Au1200"
775 depends on SOC_AU1200 785 depends on SOC_AU1200
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 49a8c589e346..f16bb4667238 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1661,7 +1661,9 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1661 cdi->mask &= ~CDC_PLAY_AUDIO; 1661 cdi->mask &= ~CDC_PLAY_AUDIO;
1662 1662
1663 mechtype = buf[8 + 6] >> 5; 1663 mechtype = buf[8 + 6] >> 5;
1664 if (mechtype == mechtype_caddy || mechtype == mechtype_popup) 1664 if (mechtype == mechtype_caddy ||
1665 mechtype == mechtype_popup ||
1666 (drive->atapi_flags & IDE_AFLAG_NO_AUTOCLOSE))
1665 cdi->mask |= CDC_CLOSE_TRAY; 1667 cdi->mask |= CDC_CLOSE_TRAY;
1666 1668
1667 if (cdi->sanyo_slot > 0) { 1669 if (cdi->sanyo_slot > 0) {
@@ -1859,6 +1861,8 @@ static const struct cd_list_entry ide_cd_quirks_list[] = {
1859 { "MATSHITADVD-ROM SR-8176", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, 1861 { "MATSHITADVD-ROM SR-8176", NULL, IDE_AFLAG_PLAY_AUDIO_OK },
1860 { "MATSHITADVD-ROM SR-8174", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, 1862 { "MATSHITADVD-ROM SR-8174", NULL, IDE_AFLAG_PLAY_AUDIO_OK },
1861 { "Optiarc DVD RW AD-5200A", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, 1863 { "Optiarc DVD RW AD-5200A", NULL, IDE_AFLAG_PLAY_AUDIO_OK },
1864 { "Optiarc DVD RW AD-7200A", NULL, IDE_AFLAG_PLAY_AUDIO_OK },
1865 { "Optiarc DVD RW AD-7543A", NULL, IDE_AFLAG_NO_AUTOCLOSE },
1862 { NULL, NULL, 0 } 1866 { NULL, NULL, 0 }
1863}; 1867};
1864 1868
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index adc682755857..3fa07c0aeaa4 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -211,7 +211,7 @@ int ide_build_dmatable (ide_drive_t *drive, struct request *rq)
211 xcount = bcount & 0xffff; 211 xcount = bcount & 0xffff;
212 if (is_trm290) 212 if (is_trm290)
213 xcount = ((xcount >> 2) - 1) << 16; 213 xcount = ((xcount >> 2) - 1) << 16;
214 if (xcount == 0x0000) { 214 else if (xcount == 0x0000) {
215 /* 215 /*
216 * Most chipsets correctly interpret a length of 0x0000 as 64KB, 216 * Most chipsets correctly interpret a length of 0x0000 as 64KB,
217 * but at least one (e.g. CS5530) misinterprets it as zero (!). 217 * but at least one (e.g. CS5530) misinterprets it as zero (!).
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 994e41099b42..a51a30e9eab3 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1492,7 +1492,7 @@ static struct device_attribute *ide_port_attrs[] = {
1492 1492
1493static int ide_sysfs_register_port(ide_hwif_t *hwif) 1493static int ide_sysfs_register_port(ide_hwif_t *hwif)
1494{ 1494{
1495 int i, rc; 1495 int i, uninitialized_var(rc);
1496 1496
1497 for (i = 0; ide_port_attrs[i]; i++) { 1497 for (i = 0; ide_port_attrs[i]; i++) {
1498 rc = device_create_file(hwif->portdev, ide_port_attrs[i]); 1498 rc = device_create_file(hwif->portdev, ide_port_attrs[i]);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 1bce84b56630..3833189144ed 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2338,7 +2338,7 @@ static void idetape_get_inquiry_results(ide_drive_t *drive)
2338{ 2338{
2339 idetape_tape_t *tape = drive->driver_data; 2339 idetape_tape_t *tape = drive->driver_data;
2340 struct ide_atapi_pc pc; 2340 struct ide_atapi_pc pc;
2341 char fw_rev[6], vendor_id[10], product_id[18]; 2341 char fw_rev[4], vendor_id[8], product_id[16];
2342 2342
2343 idetape_create_inquiry_cmd(&pc); 2343 idetape_create_inquiry_cmd(&pc);
2344 if (idetape_queue_pc_tail(drive, &pc)) { 2344 if (idetape_queue_pc_tail(drive, &pc)) {
@@ -2350,11 +2350,11 @@ static void idetape_get_inquiry_results(ide_drive_t *drive)
2350 memcpy(product_id, &pc.buf[16], 16); 2350 memcpy(product_id, &pc.buf[16], 16);
2351 memcpy(fw_rev, &pc.buf[32], 4); 2351 memcpy(fw_rev, &pc.buf[32], 4);
2352 2352
2353 ide_fixstring(vendor_id, 10, 0); 2353 ide_fixstring(vendor_id, 8, 0);
2354 ide_fixstring(product_id, 18, 0); 2354 ide_fixstring(product_id, 16, 0);
2355 ide_fixstring(fw_rev, 6, 0); 2355 ide_fixstring(fw_rev, 4, 0);
2356 2356
2357 printk(KERN_INFO "ide-tape: %s <-> %s: %s %s rev %s\n", 2357 printk(KERN_INFO "ide-tape: %s <-> %s: %.8s %.16s rev %.4s\n",
2358 drive->name, tape->name, vendor_id, product_id, fw_rev); 2358 drive->name, tape->name, vendor_id, product_id, fw_rev);
2359} 2359}
2360 2360
diff --git a/drivers/ide/mips/Makefile b/drivers/ide/mips/Makefile
index 677c7b2bac92..5873fa0b8769 100644
--- a/drivers/ide/mips/Makefile
+++ b/drivers/ide/mips/Makefile
@@ -1,4 +1,3 @@
1obj-$(CONFIG_BLK_DEV_IDE_SWARM) += swarm.o
2obj-$(CONFIG_BLK_DEV_IDE_AU1XXX) += au1xxx-ide.o 1obj-$(CONFIG_BLK_DEV_IDE_AU1XXX) += au1xxx-ide.o
3 2
4EXTRA_CFLAGS := -Idrivers/ide 3EXTRA_CFLAGS := -Idrivers/ide
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c
deleted file mode 100644
index badf79fc9e3a..000000000000
--- a/drivers/ide/mips/swarm.c
+++ /dev/null
@@ -1,196 +0,0 @@
1/*
2 * Copyright (C) 2001, 2002, 2003 Broadcom Corporation
3 * Copyright (C) 2004 MontaVista Software Inc.
4 * Author: Manish Lachwani, mlachwani@mvista.com
5 * Copyright (C) 2004 MIPS Technologies, Inc. All rights reserved.
6 * Author: Maciej W. Rozycki <macro@mips.com>
7 * Copyright (c) 2006, 2008 Maciej W. Rozycki
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24/*
25 * Derived loosely from ide-pmac.c, so:
26 * Copyright (C) 1998 Paul Mackerras.
27 * Copyright (C) 1995-1998 Mark Lord
28 */
29
30/*
31 * Boards with SiByte processors so far have supported IDE devices via
32 * the Generic Bus, PCI bus, and built-in PCMCIA interface. In all
33 * cases, byte-swapping must be avoided for these devices (whereas
34 * other PCI devices, for example, will require swapping). Any
35 * SiByte-targetted kernel including IDE support will include this
36 * file. Probing of a Generic Bus for an IDE device is controlled by
37 * the definition of "SIBYTE_HAVE_IDE", which is provided by
38 * <asm/sibyte/board.h> for Broadcom boards.
39 */
40
41#include <linux/ide.h>
42#include <linux/ioport.h>
43#include <linux/kernel.h>
44#include <linux/types.h>
45#include <linux/platform_device.h>
46
47#include <asm/io.h>
48
49#include <asm/sibyte/board.h>
50#include <asm/sibyte/sb1250_genbus.h>
51#include <asm/sibyte/sb1250_regs.h>
52
53#define DRV_NAME "ide-swarm"
54
55static char swarm_ide_string[] = DRV_NAME;
56
57static struct resource swarm_ide_resource = {
58 .name = "SWARM GenBus IDE",
59 .flags = IORESOURCE_MEM,
60};
61
62static struct platform_device *swarm_ide_dev;
63
64static const struct ide_port_info swarm_port_info = {
65 .name = DRV_NAME,
66 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
67};
68
69/*
70 * swarm_ide_probe - if the board header indicates the existence of
71 * Generic Bus IDE, allocate a HWIF for it.
72 */
73static int __devinit swarm_ide_probe(struct device *dev)
74{
75 u8 __iomem *base;
76 struct ide_host *host;
77 phys_t offset, size;
78 int i, rc;
79 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
80
81 if (!SIBYTE_HAVE_IDE)
82 return -ENODEV;
83
84 base = ioremap(A_IO_EXT_BASE, 0x800);
85 offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS));
86 size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS));
87 iounmap(base);
88
89 offset = G_IO_START_ADDR(offset) << S_IO_ADDRBASE;
90 size = (G_IO_MULT_SIZE(size) + 1) << S_IO_REGSIZE;
91 if (offset < A_PHYS_GENBUS || offset >= A_PHYS_GENBUS_END) {
92 printk(KERN_INFO DRV_NAME
93 ": IDE interface at GenBus disabled\n");
94 return -EBUSY;
95 }
96
97 printk(KERN_INFO DRV_NAME ": IDE interface at GenBus slot %i\n",
98 IDE_CS);
99
100 swarm_ide_resource.start = offset;
101 swarm_ide_resource.end = offset + size - 1;
102 if (request_resource(&iomem_resource, &swarm_ide_resource)) {
103 printk(KERN_ERR DRV_NAME
104 ": can't request I/O memory resource\n");
105 return -EBUSY;
106 }
107
108 base = ioremap(offset, size);
109
110 for (i = 0; i <= 7; i++)
111 hw.io_ports_array[i] =
112 (unsigned long)(base + ((0x1f0 + i) << 5));
113 hw.io_ports.ctl_addr =
114 (unsigned long)(base + (0x3f6 << 5));
115 hw.irq = K_INT_GB_IDE;
116 hw.chipset = ide_generic;
117
118 rc = ide_host_add(&swarm_port_info, hws, &host);
119 if (rc)
120 goto err;
121
122 dev_set_drvdata(dev, host);
123
124 return 0;
125err:
126 release_resource(&swarm_ide_resource);
127 iounmap(base);
128 return rc;
129}
130
131static struct device_driver swarm_ide_driver = {
132 .name = swarm_ide_string,
133 .bus = &platform_bus_type,
134 .probe = swarm_ide_probe,
135};
136
137static void swarm_ide_platform_release(struct device *device)
138{
139 struct platform_device *pldev;
140
141 /* free device */
142 pldev = to_platform_device(device);
143 kfree(pldev);
144}
145
146static int __devinit swarm_ide_init_module(void)
147{
148 struct platform_device *pldev;
149 int err;
150
151 printk(KERN_INFO "SWARM IDE driver\n");
152
153 if (driver_register(&swarm_ide_driver)) {
154 printk(KERN_ERR "Driver registration failed\n");
155 err = -ENODEV;
156 goto out;
157 }
158
159 if (!(pldev = kzalloc(sizeof (*pldev), GFP_KERNEL))) {
160 err = -ENOMEM;
161 goto out_unregister_driver;
162 }
163
164 pldev->name = swarm_ide_string;
165 pldev->id = 0;
166 pldev->dev.release = swarm_ide_platform_release;
167
168 if (platform_device_register(pldev)) {
169 err = -ENODEV;
170 goto out_free_pldev;
171 }
172
173 if (!pldev->dev.driver) {
174 /*
175 * The driver was not bound to this device, there was
176 * no hardware at this address. Unregister it, as the
177 * release fuction will take care of freeing the
178 * allocated structure
179 */
180 platform_device_unregister (pldev);
181 }
182
183 swarm_ide_dev = pldev;
184
185 return 0;
186
187out_free_pldev:
188 kfree(pldev);
189
190out_unregister_driver:
191 driver_unregister(&swarm_ide_driver);
192out:
193 return err;
194}
195
196module_init(swarm_ide_init_module);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 1b1df5cc4113..e9ca3cb57d52 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -404,7 +404,7 @@ static void path_rec_completion(int status,
404 struct net_device *dev = path->dev; 404 struct net_device *dev = path->dev;
405 struct ipoib_dev_priv *priv = netdev_priv(dev); 405 struct ipoib_dev_priv *priv = netdev_priv(dev);
406 struct ipoib_ah *ah = NULL; 406 struct ipoib_ah *ah = NULL;
407 struct ipoib_ah *old_ah; 407 struct ipoib_ah *old_ah = NULL;
408 struct ipoib_neigh *neigh, *tn; 408 struct ipoib_neigh *neigh, *tn;
409 struct sk_buff_head skqueue; 409 struct sk_buff_head skqueue;
410 struct sk_buff *skb; 410 struct sk_buff *skb;
@@ -428,12 +428,12 @@ static void path_rec_completion(int status,
428 428
429 spin_lock_irqsave(&priv->lock, flags); 429 spin_lock_irqsave(&priv->lock, flags);
430 430
431 old_ah = path->ah;
432 path->ah = ah;
433
434 if (ah) { 431 if (ah) {
435 path->pathrec = *pathrec; 432 path->pathrec = *pathrec;
436 433
434 old_ah = path->ah;
435 path->ah = ah;
436
437 ipoib_dbg(priv, "created address handle %p for LID 0x%04x, SL %d\n", 437 ipoib_dbg(priv, "created address handle %p for LID 0x%04x, SL %d\n",
438 ah, be16_to_cpu(pathrec->dlid), pathrec->sl); 438 ah, be16_to_cpu(pathrec->dlid), pathrec->sl);
439 439
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index 18f4d7f6ce6d..2998a6ac9ae4 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -351,8 +351,9 @@ static int report_tp_state(struct bcm5974 *dev, int size)
351#define BCM5974_WELLSPRING_MODE_REQUEST_VALUE 0x300 351#define BCM5974_WELLSPRING_MODE_REQUEST_VALUE 0x300
352#define BCM5974_WELLSPRING_MODE_REQUEST_INDEX 0 352#define BCM5974_WELLSPRING_MODE_REQUEST_INDEX 0
353#define BCM5974_WELLSPRING_MODE_VENDOR_VALUE 0x01 353#define BCM5974_WELLSPRING_MODE_VENDOR_VALUE 0x01
354#define BCM5974_WELLSPRING_MODE_NORMAL_VALUE 0x08
354 355
355static int bcm5974_wellspring_mode(struct bcm5974 *dev) 356static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on)
356{ 357{
357 char *data = kmalloc(8, GFP_KERNEL); 358 char *data = kmalloc(8, GFP_KERNEL);
358 int retval = 0, size; 359 int retval = 0, size;
@@ -377,7 +378,9 @@ static int bcm5974_wellspring_mode(struct bcm5974 *dev)
377 } 378 }
378 379
379 /* apply the mode switch */ 380 /* apply the mode switch */
380 data[0] = BCM5974_WELLSPRING_MODE_VENDOR_VALUE; 381 data[0] = on ?
382 BCM5974_WELLSPRING_MODE_VENDOR_VALUE :
383 BCM5974_WELLSPRING_MODE_NORMAL_VALUE;
381 384
382 /* write configuration */ 385 /* write configuration */
383 size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), 386 size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
@@ -392,7 +395,8 @@ static int bcm5974_wellspring_mode(struct bcm5974 *dev)
392 goto out; 395 goto out;
393 } 396 }
394 397
395 dprintk(2, "bcm5974: switched to wellspring mode.\n"); 398 dprintk(2, "bcm5974: switched to %s mode.\n",
399 on ? "wellspring" : "normal");
396 400
397 out: 401 out:
398 kfree(data); 402 kfree(data);
@@ -481,7 +485,7 @@ exit:
481 */ 485 */
482static int bcm5974_start_traffic(struct bcm5974 *dev) 486static int bcm5974_start_traffic(struct bcm5974 *dev)
483{ 487{
484 if (bcm5974_wellspring_mode(dev)) { 488 if (bcm5974_wellspring_mode(dev, true)) {
485 dprintk(1, "bcm5974: mode switch failed\n"); 489 dprintk(1, "bcm5974: mode switch failed\n");
486 goto error; 490 goto error;
487 } 491 }
@@ -504,6 +508,7 @@ static void bcm5974_pause_traffic(struct bcm5974 *dev)
504{ 508{
505 usb_kill_urb(dev->tp_urb); 509 usb_kill_urb(dev->tp_urb);
506 usb_kill_urb(dev->bt_urb); 510 usb_kill_urb(dev->bt_urb);
511 bcm5974_wellspring_mode(dev, false);
507} 512}
508 513
509/* 514/*
diff --git a/drivers/input/touchscreen/jornada720_ts.c b/drivers/input/touchscreen/jornada720_ts.c
index bf44f9d68342..c8b7e8a45c4d 100644
--- a/drivers/input/touchscreen/jornada720_ts.c
+++ b/drivers/input/touchscreen/jornada720_ts.c
@@ -119,8 +119,8 @@ static int __devinit jornada720_ts_probe(struct platform_device *pdev)
119 input_dev->id.bustype = BUS_HOST; 119 input_dev->id.bustype = BUS_HOST;
120 input_dev->dev.parent = &pdev->dev; 120 input_dev->dev.parent = &pdev->dev;
121 121
122 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 122 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
123 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); 123 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
124 input_set_abs_params(input_dev, ABS_X, 270, 3900, 0, 0); 124 input_set_abs_params(input_dev, ABS_X, 270, 3900, 0, 0);
125 input_set_abs_params(input_dev, ABS_Y, 180, 3700, 0, 0); 125 input_set_abs_params(input_dev, ABS_Y, 180, 3700, 0, 0);
126 126
diff --git a/drivers/leds/leds-fsg.c b/drivers/leds/leds-fsg.c
index be0e12144b8b..34935155c1c0 100644
--- a/drivers/leds/leds-fsg.c
+++ b/drivers/leds/leds-fsg.c
@@ -161,6 +161,16 @@ static int fsg_led_probe(struct platform_device *pdev)
161{ 161{
162 int ret; 162 int ret;
163 163
164 /* Map the LED chip select address space */
165 latch_address = (unsigned short *) ioremap(IXP4XX_EXP_BUS_BASE(2), 512);
166 if (!latch_address) {
167 ret = -ENOMEM;
168 goto failremap;
169 }
170
171 latch_value = 0xffff;
172 *latch_address = latch_value;
173
164 ret = led_classdev_register(&pdev->dev, &fsg_wlan_led); 174 ret = led_classdev_register(&pdev->dev, &fsg_wlan_led);
165 if (ret < 0) 175 if (ret < 0)
166 goto failwlan; 176 goto failwlan;
@@ -185,20 +195,8 @@ static int fsg_led_probe(struct platform_device *pdev)
185 if (ret < 0) 195 if (ret < 0)
186 goto failring; 196 goto failring;
187 197
188 /* Map the LED chip select address space */
189 latch_address = (unsigned short *) ioremap(IXP4XX_EXP_BUS_BASE(2), 512);
190 if (!latch_address) {
191 ret = -ENOMEM;
192 goto failremap;
193 }
194
195 latch_value = 0xffff;
196 *latch_address = latch_value;
197
198 return ret; 198 return ret;
199 199
200 failremap:
201 led_classdev_unregister(&fsg_ring_led);
202 failring: 200 failring:
203 led_classdev_unregister(&fsg_sync_led); 201 led_classdev_unregister(&fsg_sync_led);
204 failsync: 202 failsync:
@@ -210,14 +208,14 @@ static int fsg_led_probe(struct platform_device *pdev)
210 failwan: 208 failwan:
211 led_classdev_unregister(&fsg_wlan_led); 209 led_classdev_unregister(&fsg_wlan_led);
212 failwlan: 210 failwlan:
211 iounmap(latch_address);
212 failremap:
213 213
214 return ret; 214 return ret;
215} 215}
216 216
217static int fsg_led_remove(struct platform_device *pdev) 217static int fsg_led_remove(struct platform_device *pdev)
218{ 218{
219 iounmap(latch_address);
220
221 led_classdev_unregister(&fsg_wlan_led); 219 led_classdev_unregister(&fsg_wlan_led);
222 led_classdev_unregister(&fsg_wan_led); 220 led_classdev_unregister(&fsg_wan_led);
223 led_classdev_unregister(&fsg_sata_led); 221 led_classdev_unregister(&fsg_sata_led);
@@ -225,6 +223,8 @@ static int fsg_led_remove(struct platform_device *pdev)
225 led_classdev_unregister(&fsg_sync_led); 223 led_classdev_unregister(&fsg_sync_led);
226 led_classdev_unregister(&fsg_ring_led); 224 led_classdev_unregister(&fsg_ring_led);
227 225
226 iounmap(latch_address);
227
228 return 0; 228 return 0;
229} 229}
230 230
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index 146c06972863..f508729123b5 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -248,11 +248,10 @@ static int __devinit pca955x_probe(struct i2c_client *client,
248 const struct i2c_device_id *id) 248 const struct i2c_device_id *id)
249{ 249{
250 struct pca955x_led *pca955x; 250 struct pca955x_led *pca955x;
251 int i;
252 int err = -ENODEV;
253 struct pca955x_chipdef *chip; 251 struct pca955x_chipdef *chip;
254 struct i2c_adapter *adapter; 252 struct i2c_adapter *adapter;
255 struct led_platform_data *pdata; 253 struct led_platform_data *pdata;
254 int i, err;
256 255
257 chip = &pca955x_chipdefs[id->driver_data]; 256 chip = &pca955x_chipdefs[id->driver_data];
258 adapter = to_i2c_adapter(client->dev.parent); 257 adapter = to_i2c_adapter(client->dev.parent);
@@ -282,43 +281,41 @@ static int __devinit pca955x_probe(struct i2c_client *client,
282 } 281 }
283 } 282 }
284 283
284 pca955x = kzalloc(sizeof(*pca955x) * chip->bits, GFP_KERNEL);
285 if (!pca955x)
286 return -ENOMEM;
287
288 i2c_set_clientdata(client, pca955x);
289
285 for (i = 0; i < chip->bits; i++) { 290 for (i = 0; i < chip->bits; i++) {
286 pca955x = kzalloc(sizeof(struct pca955x_led), GFP_KERNEL); 291 pca955x[i].chipdef = chip;
287 if (!pca955x) { 292 pca955x[i].client = client;
288 err = -ENOMEM; 293 pca955x[i].led_num = i;
289 goto exit;
290 }
291 294
292 pca955x->chipdef = chip;
293 pca955x->client = client;
294 pca955x->led_num = i;
295 /* Platform data can specify LED names and default triggers */ 295 /* Platform data can specify LED names and default triggers */
296 if (pdata) { 296 if (pdata) {
297 if (pdata->leds[i].name) 297 if (pdata->leds[i].name)
298 snprintf(pca955x->name, 32, "pca955x:%s", 298 snprintf(pca955x[i].name,
299 pdata->leds[i].name); 299 sizeof(pca955x[i].name), "pca955x:%s",
300 pdata->leds[i].name);
300 if (pdata->leds[i].default_trigger) 301 if (pdata->leds[i].default_trigger)
301 pca955x->led_cdev.default_trigger = 302 pca955x[i].led_cdev.default_trigger =
302 pdata->leds[i].default_trigger; 303 pdata->leds[i].default_trigger;
303 } else { 304 } else {
304 snprintf(pca955x->name, 32, "pca955x:%d", i); 305 snprintf(pca955x[i].name, sizeof(pca955x[i].name),
306 "pca955x:%d", i);
305 } 307 }
306 spin_lock_init(&pca955x->lock);
307 308
308 pca955x->led_cdev.name = pca955x->name; 309 spin_lock_init(&pca955x[i].lock);
309 pca955x->led_cdev.brightness_set =
310 pca955x_led_set;
311 310
312 /* 311 pca955x[i].led_cdev.name = pca955x[i].name;
313 * Client data is a pointer to the _first_ pca955x_led 312 pca955x[i].led_cdev.brightness_set = pca955x_led_set;
314 * struct
315 */
316 if (i == 0)
317 i2c_set_clientdata(client, pca955x);
318 313
319 INIT_WORK(&(pca955x->work), pca955x_led_work); 314 INIT_WORK(&pca955x[i].work, pca955x_led_work);
320 315
321 led_classdev_register(&client->dev, &(pca955x->led_cdev)); 316 err = led_classdev_register(&client->dev, &pca955x[i].led_cdev);
317 if (err < 0)
318 goto exit;
322 } 319 }
323 320
324 /* Turn off LEDs */ 321 /* Turn off LEDs */
@@ -336,23 +333,32 @@ static int __devinit pca955x_probe(struct i2c_client *client,
336 pca955x_write_psc(client, 1, 0); 333 pca955x_write_psc(client, 1, 0);
337 334
338 return 0; 335 return 0;
336
339exit: 337exit:
338 while (i--) {
339 led_classdev_unregister(&pca955x[i].led_cdev);
340 cancel_work_sync(&pca955x[i].work);
341 }
342
343 kfree(pca955x);
344 i2c_set_clientdata(client, NULL);
345
340 return err; 346 return err;
341} 347}
342 348
343static int __devexit pca955x_remove(struct i2c_client *client) 349static int __devexit pca955x_remove(struct i2c_client *client)
344{ 350{
345 struct pca955x_led *pca955x = i2c_get_clientdata(client); 351 struct pca955x_led *pca955x = i2c_get_clientdata(client);
346 int leds = pca955x->chipdef->bits;
347 int i; 352 int i;
348 353
349 for (i = 0; i < leds; i++) { 354 for (i = 0; i < pca955x->chipdef->bits; i++) {
350 led_classdev_unregister(&(pca955x->led_cdev)); 355 led_classdev_unregister(&pca955x[i].led_cdev);
351 cancel_work_sync(&(pca955x->work)); 356 cancel_work_sync(&pca955x[i].work);
352 kfree(pca955x);
353 pca955x = pca955x + 1;
354 } 357 }
355 358
359 kfree(pca955x);
360 i2c_set_clientdata(client, NULL);
361
356 return 0; 362 return 0;
357} 363}
358 364
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 71dd65aa31b6..c2fcf28b4c70 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -63,6 +63,7 @@ struct multipath {
63 63
64 const char *hw_handler_name; 64 const char *hw_handler_name;
65 struct work_struct activate_path; 65 struct work_struct activate_path;
66 struct pgpath *pgpath_to_activate;
66 unsigned nr_priority_groups; 67 unsigned nr_priority_groups;
67 struct list_head priority_groups; 68 struct list_head priority_groups;
68 unsigned pg_init_required; /* pg_init needs calling? */ 69 unsigned pg_init_required; /* pg_init needs calling? */
@@ -146,6 +147,7 @@ static struct priority_group *alloc_priority_group(void)
146 147
147static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti) 148static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti)
148{ 149{
150 unsigned long flags;
149 struct pgpath *pgpath, *tmp; 151 struct pgpath *pgpath, *tmp;
150 struct multipath *m = ti->private; 152 struct multipath *m = ti->private;
151 153
@@ -154,6 +156,10 @@ static void free_pgpaths(struct list_head *pgpaths, struct dm_target *ti)
154 if (m->hw_handler_name) 156 if (m->hw_handler_name)
155 scsi_dh_detach(bdev_get_queue(pgpath->path.dev->bdev)); 157 scsi_dh_detach(bdev_get_queue(pgpath->path.dev->bdev));
156 dm_put_device(ti, pgpath->path.dev); 158 dm_put_device(ti, pgpath->path.dev);
159 spin_lock_irqsave(&m->lock, flags);
160 if (m->pgpath_to_activate == pgpath)
161 m->pgpath_to_activate = NULL;
162 spin_unlock_irqrestore(&m->lock, flags);
157 free_pgpath(pgpath); 163 free_pgpath(pgpath);
158 } 164 }
159} 165}
@@ -421,6 +427,7 @@ static void process_queued_ios(struct work_struct *work)
421 __choose_pgpath(m); 427 __choose_pgpath(m);
422 428
423 pgpath = m->current_pgpath; 429 pgpath = m->current_pgpath;
430 m->pgpath_to_activate = m->current_pgpath;
424 431
425 if ((pgpath && !m->queue_io) || 432 if ((pgpath && !m->queue_io) ||
426 (!pgpath && !m->queue_if_no_path)) 433 (!pgpath && !m->queue_if_no_path))
@@ -1093,8 +1100,15 @@ static void activate_path(struct work_struct *work)
1093 int ret; 1100 int ret;
1094 struct multipath *m = 1101 struct multipath *m =
1095 container_of(work, struct multipath, activate_path); 1102 container_of(work, struct multipath, activate_path);
1096 struct dm_path *path = &m->current_pgpath->path; 1103 struct dm_path *path;
1104 unsigned long flags;
1097 1105
1106 spin_lock_irqsave(&m->lock, flags);
1107 path = &m->pgpath_to_activate->path;
1108 m->pgpath_to_activate = NULL;
1109 spin_unlock_irqrestore(&m->lock, flags);
1110 if (!path)
1111 return;
1098 ret = scsi_dh_activate(bdev_get_queue(path->dev->bdev)); 1112 ret = scsi_dh_activate(bdev_get_queue(path->dev->bdev));
1099 pg_init_done(path, ret); 1113 pg_init_done(path, ret);
1100} 1114}
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index bca448e11878..ace998ce59f6 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -837,12 +837,14 @@ static int dm_merge_bvec(struct request_queue *q,
837 struct dm_table *map = dm_get_table(md); 837 struct dm_table *map = dm_get_table(md);
838 struct dm_target *ti; 838 struct dm_target *ti;
839 sector_t max_sectors; 839 sector_t max_sectors;
840 int max_size; 840 int max_size = 0;
841 841
842 if (unlikely(!map)) 842 if (unlikely(!map))
843 return 0; 843 goto out;
844 844
845 ti = dm_table_find_target(map, bvm->bi_sector); 845 ti = dm_table_find_target(map, bvm->bi_sector);
846 if (!dm_target_is_valid(ti))
847 goto out_table;
846 848
847 /* 849 /*
848 * Find maximum amount of I/O that won't need splitting 850 * Find maximum amount of I/O that won't need splitting
@@ -861,14 +863,16 @@ static int dm_merge_bvec(struct request_queue *q,
861 if (max_size && ti->type->merge) 863 if (max_size && ti->type->merge)
862 max_size = ti->type->merge(ti, bvm, biovec, max_size); 864 max_size = ti->type->merge(ti, bvm, biovec, max_size);
863 865
866out_table:
867 dm_table_put(map);
868
869out:
864 /* 870 /*
865 * Always allow an entire first page 871 * Always allow an entire first page
866 */ 872 */
867 if (max_size <= biovec->bv_len && !(bvm->bi_size >> SECTOR_SHIFT)) 873 if (max_size <= biovec->bv_len && !(bvm->bi_size >> SECTOR_SHIFT))
868 max_size = biovec->bv_len; 874 max_size = biovec->bv_len;
869 875
870 dm_table_put(map);
871
872 return max_size; 876 return max_size;
873} 877}
874 878
diff --git a/drivers/media/common/tuners/tuner-xc2028.h b/drivers/media/common/tuners/tuner-xc2028.h
index 216025cf5d4b..2c5b6282b569 100644
--- a/drivers/media/common/tuners/tuner-xc2028.h
+++ b/drivers/media/common/tuners/tuner-xc2028.h
@@ -10,6 +10,7 @@
10#include "dvb_frontend.h" 10#include "dvb_frontend.h"
11 11
12#define XC2028_DEFAULT_FIRMWARE "xc3028-v27.fw" 12#define XC2028_DEFAULT_FIRMWARE "xc3028-v27.fw"
13#define XC3028L_DEFAULT_FIRMWARE "xc3028L-v36.fw"
13 14
14/* Dmoduler IF (kHz) */ 15/* Dmoduler IF (kHz) */
15#define XC3028_FE_DEFAULT 0 /* Don't load SCODE */ 16#define XC3028_FE_DEFAULT 0 /* Don't load SCODE */
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 4eed783f4bce..a127a4175c40 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -491,6 +491,7 @@ static struct s5h1420_config skystar2_rev2_7_s5h1420_config = {
491 .demod_address = 0x53, 491 .demod_address = 0x53,
492 .invert = 1, 492 .invert = 1,
493 .repeated_start_workaround = 1, 493 .repeated_start_workaround = 1,
494 .serial_mpeg = 1,
494}; 495};
495 496
496static struct itd1000_config skystar2_rev2_7_itd1000_config = { 497static struct itd1000_config skystar2_rev2_7_itd1000_config = {
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 069d847ba887..0c733c66a441 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -364,15 +364,16 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
364 enum dmx_success success) 364 enum dmx_success success)
365{ 365{
366 struct dmxdev_filter *dmxdevfilter = filter->priv; 366 struct dmxdev_filter *dmxdevfilter = filter->priv;
367 unsigned long flags;
367 int ret; 368 int ret;
368 369
369 if (dmxdevfilter->buffer.error) { 370 if (dmxdevfilter->buffer.error) {
370 wake_up(&dmxdevfilter->buffer.queue); 371 wake_up(&dmxdevfilter->buffer.queue);
371 return 0; 372 return 0;
372 } 373 }
373 spin_lock(&dmxdevfilter->dev->lock); 374 spin_lock_irqsave(&dmxdevfilter->dev->lock, flags);
374 if (dmxdevfilter->state != DMXDEV_STATE_GO) { 375 if (dmxdevfilter->state != DMXDEV_STATE_GO) {
375 spin_unlock(&dmxdevfilter->dev->lock); 376 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags);
376 return 0; 377 return 0;
377 } 378 }
378 del_timer(&dmxdevfilter->timer); 379 del_timer(&dmxdevfilter->timer);
@@ -391,7 +392,7 @@ static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
391 } 392 }
392 if (dmxdevfilter->params.sec.flags & DMX_ONESHOT) 393 if (dmxdevfilter->params.sec.flags & DMX_ONESHOT)
393 dmxdevfilter->state = DMXDEV_STATE_DONE; 394 dmxdevfilter->state = DMXDEV_STATE_DONE;
394 spin_unlock(&dmxdevfilter->dev->lock); 395 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags);
395 wake_up(&dmxdevfilter->buffer.queue); 396 wake_up(&dmxdevfilter->buffer.queue);
396 return 0; 397 return 0;
397} 398}
@@ -403,11 +404,12 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
403{ 404{
404 struct dmxdev_filter *dmxdevfilter = feed->priv; 405 struct dmxdev_filter *dmxdevfilter = feed->priv;
405 struct dvb_ringbuffer *buffer; 406 struct dvb_ringbuffer *buffer;
407 unsigned long flags;
406 int ret; 408 int ret;
407 409
408 spin_lock(&dmxdevfilter->dev->lock); 410 spin_lock_irqsave(&dmxdevfilter->dev->lock, flags);
409 if (dmxdevfilter->params.pes.output == DMX_OUT_DECODER) { 411 if (dmxdevfilter->params.pes.output == DMX_OUT_DECODER) {
410 spin_unlock(&dmxdevfilter->dev->lock); 412 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags);
411 return 0; 413 return 0;
412 } 414 }
413 415
@@ -417,7 +419,7 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
417 else 419 else
418 buffer = &dmxdevfilter->dev->dvr_buffer; 420 buffer = &dmxdevfilter->dev->dvr_buffer;
419 if (buffer->error) { 421 if (buffer->error) {
420 spin_unlock(&dmxdevfilter->dev->lock); 422 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags);
421 wake_up(&buffer->queue); 423 wake_up(&buffer->queue);
422 return 0; 424 return 0;
423 } 425 }
@@ -428,7 +430,7 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
428 dvb_ringbuffer_flush(buffer); 430 dvb_ringbuffer_flush(buffer);
429 buffer->error = ret; 431 buffer->error = ret;
430 } 432 }
431 spin_unlock(&dmxdevfilter->dev->lock); 433 spin_unlock_irqrestore(&dmxdevfilter->dev->lock, flags);
432 wake_up(&buffer->queue); 434 wake_up(&buffer->queue);
433 return 0; 435 return 0;
434} 436}
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
index e2eca0b1fe7c..a2c1fd5d2f67 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb/dvb-core/dvb_demux.c
@@ -399,7 +399,9 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
399void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf, 399void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf,
400 size_t count) 400 size_t count)
401{ 401{
402 spin_lock(&demux->lock); 402 unsigned long flags;
403
404 spin_lock_irqsave(&demux->lock, flags);
403 405
404 while (count--) { 406 while (count--) {
405 if (buf[0] == 0x47) 407 if (buf[0] == 0x47)
@@ -407,16 +409,17 @@ void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf,
407 buf += 188; 409 buf += 188;
408 } 410 }
409 411
410 spin_unlock(&demux->lock); 412 spin_unlock_irqrestore(&demux->lock, flags);
411} 413}
412 414
413EXPORT_SYMBOL(dvb_dmx_swfilter_packets); 415EXPORT_SYMBOL(dvb_dmx_swfilter_packets);
414 416
415void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count) 417void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
416{ 418{
419 unsigned long flags;
417 int p = 0, i, j; 420 int p = 0, i, j;
418 421
419 spin_lock(&demux->lock); 422 spin_lock_irqsave(&demux->lock, flags);
420 423
421 if (demux->tsbufp) { 424 if (demux->tsbufp) {
422 i = demux->tsbufp; 425 i = demux->tsbufp;
@@ -449,17 +452,18 @@ void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
449 } 452 }
450 453
451bailout: 454bailout:
452 spin_unlock(&demux->lock); 455 spin_unlock_irqrestore(&demux->lock, flags);
453} 456}
454 457
455EXPORT_SYMBOL(dvb_dmx_swfilter); 458EXPORT_SYMBOL(dvb_dmx_swfilter);
456 459
457void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count) 460void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count)
458{ 461{
462 unsigned long flags;
459 int p = 0, i, j; 463 int p = 0, i, j;
460 u8 tmppack[188]; 464 u8 tmppack[188];
461 465
462 spin_lock(&demux->lock); 466 spin_lock_irqsave(&demux->lock, flags);
463 467
464 if (demux->tsbufp) { 468 if (demux->tsbufp) {
465 i = demux->tsbufp; 469 i = demux->tsbufp;
@@ -500,7 +504,7 @@ void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count)
500 } 504 }
501 505
502bailout: 506bailout:
503 spin_unlock(&demux->lock); 507 spin_unlock_irqrestore(&demux->lock, flags);
504} 508}
505 509
506EXPORT_SYMBOL(dvb_dmx_swfilter_204); 510EXPORT_SYMBOL(dvb_dmx_swfilter_204);
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c
index 747d3fa2e5e5..2e9fd2893ede 100644
--- a/drivers/media/dvb/frontends/s5h1420.c
+++ b/drivers/media/dvb/frontends/s5h1420.c
@@ -59,7 +59,7 @@ struct s5h1420_state {
59 * it does not support repeated-start, workaround: write addr-1 59 * it does not support repeated-start, workaround: write addr-1
60 * and then read 60 * and then read
61 */ 61 */
62 u8 shadow[255]; 62 u8 shadow[256];
63}; 63};
64 64
65static u32 s5h1420_getsymbolrate(struct s5h1420_state* state); 65static u32 s5h1420_getsymbolrate(struct s5h1420_state* state);
@@ -94,8 +94,11 @@ static u8 s5h1420_readreg(struct s5h1420_state *state, u8 reg)
94 if (ret != 3) 94 if (ret != 3)
95 return ret; 95 return ret;
96 } else { 96 } else {
97 ret = i2c_transfer(state->i2c, &msg[1], 2); 97 ret = i2c_transfer(state->i2c, &msg[1], 1);
98 if (ret != 2) 98 if (ret != 1)
99 return ret;
100 ret = i2c_transfer(state->i2c, &msg[2], 1);
101 if (ret != 1)
99 return ret; 102 return ret;
100 } 103 }
101 104
@@ -823,7 +826,7 @@ static int s5h1420_init (struct dvb_frontend* fe)
823 struct s5h1420_state* state = fe->demodulator_priv; 826 struct s5h1420_state* state = fe->demodulator_priv;
824 827
825 /* disable power down and do reset */ 828 /* disable power down and do reset */
826 state->CON_1_val = 0x10; 829 state->CON_1_val = state->config->serial_mpeg << 4;
827 s5h1420_writereg(state, 0x02, state->CON_1_val); 830 s5h1420_writereg(state, 0x02, state->CON_1_val);
828 msleep(10); 831 msleep(10);
829 s5h1420_reset(state); 832 s5h1420_reset(state);
diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h
index 4c913f142bc4..ff308136d865 100644
--- a/drivers/media/dvb/frontends/s5h1420.h
+++ b/drivers/media/dvb/frontends/s5h1420.h
@@ -32,10 +32,12 @@ struct s5h1420_config
32 u8 demod_address; 32 u8 demod_address;
33 33
34 /* does the inversion require inversion? */ 34 /* does the inversion require inversion? */
35 u8 invert : 1; 35 u8 invert:1;
36 36
37 u8 repeated_start_workaround : 1; 37 u8 repeated_start_workaround:1;
38 u8 cdclk_polarity : 1; /* 1 == falling edge, 0 == raising edge */ 38 u8 cdclk_polarity:1; /* 1 == falling edge, 0 == raising edge */
39
40 u8 serial_mpeg:1;
39}; 41};
40 42
41#if defined(CONFIG_DVB_S5H1420) || (defined(CONFIG_DVB_S5H1420_MODULE) && defined(MODULE)) 43#if defined(CONFIG_DVB_S5H1420) || (defined(CONFIG_DVB_S5H1420_MODULE) && defined(MODULE))
diff --git a/drivers/media/dvb/siano/sms-cards.c b/drivers/media/dvb/siano/sms-cards.c
index cc5efb643f33..9da260fe3fd1 100644
--- a/drivers/media/dvb/siano/sms-cards.c
+++ b/drivers/media/dvb/siano/sms-cards.c
@@ -40,6 +40,8 @@ struct usb_device_id smsusb_id_table[] = {
40 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B }, 40 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B },
41 { USB_DEVICE(0x2040, 0x5500), 41 { USB_DEVICE(0x2040, 0x5500),
42 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 42 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
43 { USB_DEVICE(0x2040, 0x5510),
44 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
43 { USB_DEVICE(0x2040, 0x5580), 45 { USB_DEVICE(0x2040, 0x5580),
44 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM }, 46 .driver_info = SMS1XXX_BOARD_HAUPPAUGE_WINDHAM },
45 { USB_DEVICE(0x2040, 0x5590), 47 { USB_DEVICE(0x2040, 0x5590),
@@ -87,7 +89,7 @@ static struct sms_board sms_boards[] = {
87 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-nova-b-dvbt-01.fw", 89 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-nova-b-dvbt-01.fw",
88 }, 90 },
89 [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = { 91 [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = {
90 .name = "Hauppauge WinTV-Nova-T-MiniStick", 92 .name = "Hauppauge WinTV MiniStick",
91 .type = SMS_NOVA_B0, 93 .type = SMS_NOVA_B0,
92 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-01.fw", 94 .fw[DEVICE_MODE_DVBT_BDA] = "sms1xxx-hcw-55xxx-dvbt-01.fw",
93 }, 95 },
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 6ae4cc860efe..933eaef41ead 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -3431,7 +3431,7 @@ static int radio_open(struct inode *inode, struct file *file)
3431 dprintk("bttv: open minor=%d\n",minor); 3431 dprintk("bttv: open minor=%d\n",minor);
3432 3432
3433 for (i = 0; i < bttv_num; i++) { 3433 for (i = 0; i < bttv_num; i++) {
3434 if (bttvs[i].radio_dev->minor == minor) { 3434 if (bttvs[i].radio_dev && bttvs[i].radio_dev->minor == minor) {
3435 btv = &bttvs[i]; 3435 btv = &bttvs[i];
3436 break; 3436 break;
3437 } 3437 }
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index c149b7d712e5..5405c30dbb04 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -19,6 +19,7 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/mm.h>
22#include <linux/pci.h> 23#include <linux/pci.h>
23#include <linux/i2c.h> 24#include <linux/i2c.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
diff --git a/drivers/media/video/cpia2/cpia2_usb.c b/drivers/media/video/cpia2/cpia2_usb.c
index a4574740350d..a8a199047cbd 100644
--- a/drivers/media/video/cpia2/cpia2_usb.c
+++ b/drivers/media/video/cpia2/cpia2_usb.c
@@ -632,7 +632,7 @@ int cpia2_usb_transfer_cmd(struct camera_data *cam,
632static int submit_urbs(struct camera_data *cam) 632static int submit_urbs(struct camera_data *cam)
633{ 633{
634 struct urb *urb; 634 struct urb *urb;
635 int fx, err, i; 635 int fx, err, i, j;
636 636
637 for(i=0; i<NUM_SBUF; ++i) { 637 for(i=0; i<NUM_SBUF; ++i) {
638 if (cam->sbuf[i].data) 638 if (cam->sbuf[i].data)
@@ -657,6 +657,9 @@ static int submit_urbs(struct camera_data *cam)
657 } 657 }
658 urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL); 658 urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL);
659 if (!urb) { 659 if (!urb) {
660 ERR("%s: usb_alloc_urb error!\n", __func__);
661 for (j = 0; j < i; j++)
662 usb_free_urb(cam->sbuf[j].urb);
660 return -ENOMEM; 663 return -ENOMEM;
661 } 664 }
662 665
diff --git a/drivers/media/video/cx18/cx18-cards.c b/drivers/media/video/cx18/cx18-cards.c
index 8fe5f38c4d7c..3cb9734ec07b 100644
--- a/drivers/media/video/cx18/cx18-cards.c
+++ b/drivers/media/video/cx18/cx18-cards.c
@@ -163,7 +163,7 @@ static const struct cx18_card cx18_card_h900 = {
163 }, 163 },
164 .audio_inputs = { 164 .audio_inputs = {
165 { CX18_CARD_INPUT_AUD_TUNER, 165 { CX18_CARD_INPUT_AUD_TUNER,
166 CX18_AV_AUDIO8, 0 }, 166 CX18_AV_AUDIO5, 0 },
167 { CX18_CARD_INPUT_LINE_IN1, 167 { CX18_CARD_INPUT_LINE_IN1,
168 CX18_AV_AUDIO_SERIAL1, 0 }, 168 CX18_AV_AUDIO_SERIAL1, 0 },
169 }, 169 },
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c
index 3c006103c1eb..ac3292d7646c 100644
--- a/drivers/media/video/em28xx/em28xx-audio.c
+++ b/drivers/media/video/em28xx/em28xx-audio.c
@@ -117,10 +117,10 @@ static void em28xx_audio_isocirq(struct urb *urb)
117 117
118 if (oldptr + length >= runtime->buffer_size) { 118 if (oldptr + length >= runtime->buffer_size) {
119 unsigned int cnt = 119 unsigned int cnt =
120 runtime->buffer_size - oldptr - 1; 120 runtime->buffer_size - oldptr;
121 memcpy(runtime->dma_area + oldptr * stride, cp, 121 memcpy(runtime->dma_area + oldptr * stride, cp,
122 cnt * stride); 122 cnt * stride);
123 memcpy(runtime->dma_area, cp + cnt, 123 memcpy(runtime->dma_area, cp + cnt * stride,
124 length * stride - cnt * stride); 124 length * stride - cnt * stride);
125 } else { 125 } else {
126 memcpy(runtime->dma_area + oldptr * stride, cp, 126 memcpy(runtime->dma_area + oldptr * stride, cp,
@@ -161,8 +161,14 @@ static int em28xx_init_audio_isoc(struct em28xx *dev)
161 161
162 memset(dev->adev->transfer_buffer[i], 0x80, sb_size); 162 memset(dev->adev->transfer_buffer[i], 0x80, sb_size);
163 urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS, GFP_ATOMIC); 163 urb = usb_alloc_urb(EM28XX_NUM_AUDIO_PACKETS, GFP_ATOMIC);
164 if (!urb) 164 if (!urb) {
165 em28xx_errdev("usb_alloc_urb failed!\n");
166 for (j = 0; j < i; j++) {
167 usb_free_urb(dev->adev->urb[j]);
168 kfree(dev->adev->transfer_buffer[j]);
169 }
165 return -ENOMEM; 170 return -ENOMEM;
171 }
166 172
167 urb->dev = dev->udev; 173 urb->dev = dev->udev;
168 urb->context = dev; 174 urb->context = dev;
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 452da70e719f..de943cf6c169 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -93,28 +93,6 @@ struct em28xx_board em28xx_boards[] = {
93 .amux = 0, 93 .amux = 0,
94 } }, 94 } },
95 }, 95 },
96 [EM2800_BOARD_KWORLD_USB2800] = {
97 .name = "Kworld USB2800",
98 .valid = EM28XX_BOARD_NOT_VALIDATED,
99 .is_em2800 = 1,
100 .vchannels = 3,
101 .tuner_type = TUNER_PHILIPS_FCV1236D,
102 .tda9887_conf = TDA9887_PRESENT,
103 .decoder = EM28XX_SAA7113,
104 .input = { {
105 .type = EM28XX_VMUX_TELEVISION,
106 .vmux = SAA7115_COMPOSITE2,
107 .amux = 0,
108 }, {
109 .type = EM28XX_VMUX_COMPOSITE1,
110 .vmux = SAA7115_COMPOSITE0,
111 .amux = 1,
112 }, {
113 .type = EM28XX_VMUX_SVIDEO,
114 .vmux = SAA7115_SVIDEO3,
115 .amux = 1,
116 } },
117 },
118 [EM2820_BOARD_KWORLD_PVRTV2800RF] = { 96 [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
119 .name = "Kworld PVR TV 2800 RF", 97 .name = "Kworld PVR TV 2800 RF",
120 .is_em2800 = 0, 98 .is_em2800 = 0,
@@ -599,7 +577,7 @@ struct em28xx_board em28xx_boards[] = {
599 }, { 577 }, {
600 .type = EM28XX_VMUX_COMPOSITE1, 578 .type = EM28XX_VMUX_COMPOSITE1,
601 .vmux = TVP5150_COMPOSITE1, 579 .vmux = TVP5150_COMPOSITE1,
602 .amux = 1, 580 .amux = 3,
603 }, { 581 }, {
604 .type = EM28XX_VMUX_SVIDEO, 582 .type = EM28XX_VMUX_SVIDEO,
605 .vmux = TVP5150_SVIDEO, 583 .vmux = TVP5150_SVIDEO,
@@ -952,22 +930,23 @@ struct em28xx_board em28xx_boards[] = {
952 }, 930 },
953 [EM2880_BOARD_KWORLD_DVB_310U] = { 931 [EM2880_BOARD_KWORLD_DVB_310U] = {
954 .name = "KWorld DVB-T 310U", 932 .name = "KWorld DVB-T 310U",
955 .valid = EM28XX_BOARD_NOT_VALIDATED,
956 .vchannels = 3, 933 .vchannels = 3,
957 .tuner_type = TUNER_XC2028, 934 .tuner_type = TUNER_XC2028,
935 .has_dvb = 1,
936 .mts_firmware = 1,
958 .decoder = EM28XX_TVP5150, 937 .decoder = EM28XX_TVP5150,
959 .input = { { 938 .input = { {
960 .type = EM28XX_VMUX_TELEVISION, 939 .type = EM28XX_VMUX_TELEVISION,
961 .vmux = TVP5150_COMPOSITE0, 940 .vmux = TVP5150_COMPOSITE0,
962 .amux = 0, 941 .amux = EM28XX_AMUX_VIDEO,
963 }, { 942 }, {
964 .type = EM28XX_VMUX_COMPOSITE1, 943 .type = EM28XX_VMUX_COMPOSITE1,
965 .vmux = TVP5150_COMPOSITE1, 944 .vmux = TVP5150_COMPOSITE1,
966 .amux = 1, 945 .amux = EM28XX_AMUX_AC97_LINE_IN,
967 }, { 946 }, { /* S-video has not been tested yet */
968 .type = EM28XX_VMUX_SVIDEO, 947 .type = EM28XX_VMUX_SVIDEO,
969 .vmux = TVP5150_SVIDEO, 948 .vmux = TVP5150_SVIDEO,
970 .amux = 1, 949 .amux = EM28XX_AMUX_AC97_LINE_IN,
971 } }, 950 } },
972 }, 951 },
973 [EM2881_BOARD_DNT_DA2_HYBRID] = { 952 [EM2881_BOARD_DNT_DA2_HYBRID] = {
@@ -1282,6 +1261,7 @@ static struct em28xx_reg_seq em2882_terratec_hybrid_xs_digital[] = {
1282static struct em28xx_hash_table em28xx_eeprom_hash [] = { 1261static struct em28xx_hash_table em28xx_eeprom_hash [] = {
1283 /* P/N: SA 60002070465 Tuner: TVF7533-MF */ 1262 /* P/N: SA 60002070465 Tuner: TVF7533-MF */
1284 {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF}, 1263 {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
1264 {0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
1285}; 1265};
1286 1266
1287/* I2C devicelist hash table for devices with generic USB IDs */ 1267/* I2C devicelist hash table for devices with generic USB IDs */
@@ -1552,9 +1532,12 @@ static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
1552 /* djh - Not sure which demod we need here */ 1532 /* djh - Not sure which demod we need here */
1553 ctl->demod = XC3028_FE_DEFAULT; 1533 ctl->demod = XC3028_FE_DEFAULT;
1554 break; 1534 break;
1535 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
1536 ctl->demod = XC3028_FE_DEFAULT;
1537 ctl->fname = XC3028L_DEFAULT_FIRMWARE;
1538 break;
1555 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950: 1539 case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
1556 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO: 1540 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
1557 case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
1558 /* FIXME: Better to specify the needed IF */ 1541 /* FIXME: Better to specify the needed IF */
1559 ctl->demod = XC3028_FE_DEFAULT; 1542 ctl->demod = XC3028_FE_DEFAULT;
1560 break; 1543 break;
@@ -1764,6 +1747,20 @@ void em28xx_card_setup(struct em28xx *dev)
1764 break; 1747 break;
1765 case EM2820_BOARD_UNKNOWN: 1748 case EM2820_BOARD_UNKNOWN:
1766 case EM2800_BOARD_UNKNOWN: 1749 case EM2800_BOARD_UNKNOWN:
1750 /*
1751 * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
1752 *
1753 * This occurs because they share identical USB vendor and
1754 * product IDs.
1755 *
1756 * What we do here is look up the EEPROM hash of the K-WORLD
1757 * and if it is found then we decide that we do not have
1758 * a DIGIVOX and reset the device to the K-WORLD instead.
1759 *
1760 * This solution is only valid if they do not share eeprom
1761 * hash identities which has not been determined as yet.
1762 */
1763 case EM2880_BOARD_MSI_DIGIVOX_AD:
1767 if (!em28xx_hint_board(dev)) 1764 if (!em28xx_hint_board(dev))
1768 em28xx_set_model(dev); 1765 em28xx_set_model(dev);
1769 break; 1766 break;
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index 4b992bc0083c..d2b1a1a52689 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -452,6 +452,15 @@ static int dvb_init(struct em28xx *dev)
452 goto out_free; 452 goto out_free;
453 } 453 }
454 break; 454 break;
455 case EM2880_BOARD_KWORLD_DVB_310U:
456 dvb->frontend = dvb_attach(zl10353_attach,
457 &em28xx_zl10353_with_xc3028,
458 &dev->i2c_adap);
459 if (attach_xc3028(0x61, dev) < 0) {
460 result = -EINVAL;
461 goto out_free;
462 }
463 break;
455 default: 464 default:
456 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card" 465 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card"
457 " isn't supported yet\n", 466 " isn't supported yet\n",
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 7be69284da03..ac95c55887df 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -459,6 +459,7 @@ static int create_urbs(struct gspca_dev *gspca_dev,
459 urb = usb_alloc_urb(npkt, GFP_KERNEL); 459 urb = usb_alloc_urb(npkt, GFP_KERNEL);
460 if (!urb) { 460 if (!urb) {
461 err("usb_alloc_urb failed"); 461 err("usb_alloc_urb failed");
462 destroy_urbs(gspca_dev);
462 return -ENOMEM; 463 return -ENOMEM;
463 } 464 }
464 urb->transfer_buffer = usb_buffer_alloc(gspca_dev->dev, 465 urb->transfer_buffer = usb_buffer_alloc(gspca_dev->dev,
@@ -468,8 +469,8 @@ static int create_urbs(struct gspca_dev *gspca_dev,
468 469
469 if (urb->transfer_buffer == NULL) { 470 if (urb->transfer_buffer == NULL) {
470 usb_free_urb(urb); 471 usb_free_urb(urb);
471 destroy_urbs(gspca_dev);
472 err("usb_buffer_urb failed"); 472 err("usb_buffer_urb failed");
473 destroy_urbs(gspca_dev);
473 return -ENOMEM; 474 return -ENOMEM;
474 } 475 }
475 gspca_dev->urb[n] = urb; 476 gspca_dev->urb[n] = urb;
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index d4be51843286..ba865b7f1ed8 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -1063,6 +1063,7 @@ static __devinitdata struct usb_device_id device_table[] = {
1063 {USB_DEVICE(0x093a, 0x2621), .driver_info = SENSOR_PAC7302}, 1063 {USB_DEVICE(0x093a, 0x2621), .driver_info = SENSOR_PAC7302},
1064 {USB_DEVICE(0x093a, 0x2624), .driver_info = SENSOR_PAC7302}, 1064 {USB_DEVICE(0x093a, 0x2624), .driver_info = SENSOR_PAC7302},
1065 {USB_DEVICE(0x093a, 0x2626), .driver_info = SENSOR_PAC7302}, 1065 {USB_DEVICE(0x093a, 0x2626), .driver_info = SENSOR_PAC7302},
1066 {USB_DEVICE(0x093a, 0x262a), .driver_info = SENSOR_PAC7302},
1066 {} 1067 {}
1067}; 1068};
1068MODULE_DEVICE_TABLE(usb, device_table); 1069MODULE_DEVICE_TABLE(usb, device_table);
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c
index 5dd78c6766ea..12b81ae526b7 100644
--- a/drivers/media/video/gspca/sonixb.c
+++ b/drivers/media/video/gspca/sonixb.c
@@ -232,7 +232,7 @@ static struct ctrl sd_ctrls[] = {
232static struct v4l2_pix_format vga_mode[] = { 232static struct v4l2_pix_format vga_mode[] = {
233 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 233 {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
234 .bytesperline = 160, 234 .bytesperline = 160,
235 .sizeimage = 160 * 120 * 5 / 4, 235 .sizeimage = 160 * 120,
236 .colorspace = V4L2_COLORSPACE_SRGB, 236 .colorspace = V4L2_COLORSPACE_SRGB,
237 .priv = 2 | MODE_RAW}, 237 .priv = 2 | MODE_RAW},
238 {160, 120, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, 238 {160, 120, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE,
@@ -264,7 +264,7 @@ static struct v4l2_pix_format sif_mode[] = {
264 .priv = 1 | MODE_REDUCED_SIF}, 264 .priv = 1 | MODE_REDUCED_SIF},
265 {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, 265 {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
266 .bytesperline = 176, 266 .bytesperline = 176,
267 .sizeimage = 176 * 144 * 5 / 4, 267 .sizeimage = 176 * 144,
268 .colorspace = V4L2_COLORSPACE_SRGB, 268 .colorspace = V4L2_COLORSPACE_SRGB,
269 .priv = 1 | MODE_RAW}, 269 .priv = 1 | MODE_RAW},
270 {176, 144, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE, 270 {176, 144, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE,
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index d75b1d20b318..572b0f363b64 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -707,6 +707,7 @@ static void i2c_w8(struct gspca_dev *gspca_dev,
707 0x08, 0, /* value, index */ 707 0x08, 0, /* value, index */
708 gspca_dev->usb_buf, 8, 708 gspca_dev->usb_buf, 8,
709 500); 709 500);
710 msleep(2);
710} 711}
711 712
712/* read 5 bytes in gspca_dev->usb_buf */ 713/* read 5 bytes in gspca_dev->usb_buf */
@@ -976,13 +977,13 @@ static int sd_init(struct gspca_dev *gspca_dev)
976 case BRIDGE_SN9C105: 977 case BRIDGE_SN9C105:
977 if (regF1 != 0x11) 978 if (regF1 != 0x11)
978 return -ENODEV; 979 return -ENODEV;
979 reg_w(gspca_dev, 0x02, regGpio, 2); 980 reg_w(gspca_dev, 0x01, regGpio, 2);
980 break; 981 break;
981 case BRIDGE_SN9C120: 982 case BRIDGE_SN9C120:
982 if (regF1 != 0x12) 983 if (regF1 != 0x12)
983 return -ENODEV; 984 return -ENODEV;
984 regGpio[1] = 0x70; 985 regGpio[1] = 0x70;
985 reg_w(gspca_dev, 0x02, regGpio, 2); 986 reg_w(gspca_dev, 0x01, regGpio, 2);
986 break; 987 break;
987 default: 988 default:
988/* case BRIDGE_SN9C110: */ 989/* case BRIDGE_SN9C110: */
@@ -1183,7 +1184,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
1183 static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; 1184 static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec };
1184 static const __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ 1185 static const __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */
1185 static const __u8 CE_ov76xx[] = 1186 static const __u8 CE_ov76xx[] =
1186 { 0x32, 0xdd, 0x32, 0xdd }; /* OV7630/48 */ 1187 { 0x32, 0xdd, 0x32, 0xdd };
1187 1188
1188 sn9c1xx = sn_tb[(int) sd->sensor]; 1189 sn9c1xx = sn_tb[(int) sd->sensor];
1189 configure_gpio(gspca_dev, sn9c1xx); 1190 configure_gpio(gspca_dev, sn9c1xx);
@@ -1223,8 +1224,15 @@ static void sd_start(struct gspca_dev *gspca_dev)
1223 reg_w(gspca_dev, 0x20, gamma_def, sizeof gamma_def); 1224 reg_w(gspca_dev, 0x20, gamma_def, sizeof gamma_def);
1224 for (i = 0; i < 8; i++) 1225 for (i = 0; i < 8; i++)
1225 reg_w(gspca_dev, 0x84, reg84, sizeof reg84); 1226 reg_w(gspca_dev, 0x84, reg84, sizeof reg84);
1227 switch (sd->sensor) {
1228 case SENSOR_OV7660:
1229 reg_w1(gspca_dev, 0x9a, 0x05);
1230 break;
1231 default:
1226 reg_w1(gspca_dev, 0x9a, 0x08); 1232 reg_w1(gspca_dev, 0x9a, 0x08);
1227 reg_w1(gspca_dev, 0x99, 0x59); 1233 reg_w1(gspca_dev, 0x99, 0x59);
1234 break;
1235 }
1228 1236
1229 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 1237 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
1230 if (mode) 1238 if (mode)
@@ -1275,8 +1283,8 @@ static void sd_start(struct gspca_dev *gspca_dev)
1275/* reg1 = 0x44; */ 1283/* reg1 = 0x44; */
1276/* reg1 = 0x46; (done) */ 1284/* reg1 = 0x46; (done) */
1277 } else { 1285 } else {
1278 reg17 = 0x22; /* 640 MCKSIZE */ 1286 reg17 = 0xa2; /* 640 */
1279 reg1 = 0x06; 1287 reg1 = 0x44;
1280 } 1288 }
1281 break; 1289 break;
1282 } 1290 }
@@ -1285,6 +1293,7 @@ static void sd_start(struct gspca_dev *gspca_dev)
1285 switch (sd->sensor) { 1293 switch (sd->sensor) {
1286 case SENSOR_OV7630: 1294 case SENSOR_OV7630:
1287 case SENSOR_OV7648: 1295 case SENSOR_OV7648:
1296 case SENSOR_OV7660:
1288 reg_w(gspca_dev, 0xce, CE_ov76xx, 4); 1297 reg_w(gspca_dev, 0xce, CE_ov76xx, 4);
1289 break; 1298 break;
1290 default: 1299 default:
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c
index cfbc9ebc5c5d..95fcfcb9e31b 100644
--- a/drivers/media/video/gspca/spca561.c
+++ b/drivers/media/video/gspca/spca561.c
@@ -225,7 +225,7 @@ static int i2c_read(struct gspca_dev *gspca_dev, __u16 reg, __u8 mode)
225 reg_w_val(gspca_dev->dev, 0x8802, (mode | 0x01)); 225 reg_w_val(gspca_dev->dev, 0x8802, (mode | 0x01));
226 do { 226 do {
227 reg_r(gspca_dev, 0x8803, 1); 227 reg_r(gspca_dev, 0x8803, 1);
228 if (!gspca_dev->usb_buf) 228 if (!gspca_dev->usb_buf[0])
229 break; 229 break;
230 } while (--retry); 230 } while (--retry);
231 if (retry == 0) 231 if (retry == 0)
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 8d7c27e6ac77..d61ef727e0c2 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -6576,8 +6576,8 @@ static int setlightfreq(struct gspca_dev *gspca_dev)
6576 cs2102_60HZ, cs2102_60HZScale}, 6576 cs2102_60HZ, cs2102_60HZScale},
6577/* SENSOR_CS2102K 1 */ 6577/* SENSOR_CS2102K 1 */
6578 {cs2102_NoFliker, cs2102_NoFlikerScale, 6578 {cs2102_NoFliker, cs2102_NoFlikerScale,
6579 cs2102_50HZ, cs2102_50HZScale, 6579 NULL, NULL, /* currently disabled */
6580 cs2102_60HZ, cs2102_60HZScale}, 6580 NULL, NULL},
6581/* SENSOR_GC0305 2 */ 6581/* SENSOR_GC0305 2 */
6582 {gc0305_NoFliker, gc0305_NoFliker, 6582 {gc0305_NoFliker, gc0305_NoFliker,
6583 gc0305_50HZ, gc0305_50HZ, 6583 gc0305_50HZ, gc0305_50HZ,
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index 3d3c48db45d9..c6852402c5e9 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -3591,7 +3591,7 @@ static int
3591ov51x_init_isoc(struct usb_ov511 *ov) 3591ov51x_init_isoc(struct usb_ov511 *ov)
3592{ 3592{
3593 struct urb *urb; 3593 struct urb *urb;
3594 int fx, err, n, size; 3594 int fx, err, n, i, size;
3595 3595
3596 PDEBUG(3, "*** Initializing capture ***"); 3596 PDEBUG(3, "*** Initializing capture ***");
3597 3597
@@ -3662,6 +3662,8 @@ ov51x_init_isoc(struct usb_ov511 *ov)
3662 urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL); 3662 urb = usb_alloc_urb(FRAMES_PER_DESC, GFP_KERNEL);
3663 if (!urb) { 3663 if (!urb) {
3664 err("init isoc: usb_alloc_urb ret. NULL"); 3664 err("init isoc: usb_alloc_urb ret. NULL");
3665 for (i = 0; i < n; i++)
3666 usb_free_urb(ov->sbuf[i].urb);
3665 return -ENOMEM; 3667 return -ENOMEM;
3666 } 3668 }
3667 ov->sbuf[n].urb = urb; 3669 ov->sbuf[n].urb = urb;
@@ -5651,7 +5653,7 @@ static ssize_t show_exposure(struct device *cd,
5651 if (!ov->dev) 5653 if (!ov->dev)
5652 return -ENODEV; 5654 return -ENODEV;
5653 sensor_get_exposure(ov, &exp); 5655 sensor_get_exposure(ov, &exp);
5654 return sprintf(buf, "%d\n", exp >> 8); 5656 return sprintf(buf, "%d\n", exp);
5655} 5657}
5656static DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL); 5658static DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL);
5657 5659
diff --git a/drivers/media/video/pvrusb2/pvrusb2-devattr.c b/drivers/media/video/pvrusb2/pvrusb2-devattr.c
index 88e175168438..cbe2a3417851 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-devattr.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-devattr.c
@@ -489,6 +489,8 @@ static const struct pvr2_device_desc pvr2_device_751xx = {
489struct usb_device_id pvr2_device_table[] = { 489struct usb_device_id pvr2_device_table[] = {
490 { USB_DEVICE(0x2040, 0x2900), 490 { USB_DEVICE(0x2040, 0x2900),
491 .driver_info = (kernel_ulong_t)&pvr2_device_29xxx}, 491 .driver_info = (kernel_ulong_t)&pvr2_device_29xxx},
492 { USB_DEVICE(0x2040, 0x2950), /* Logically identical to 2900 */
493 .driver_info = (kernel_ulong_t)&pvr2_device_29xxx},
492 { USB_DEVICE(0x2040, 0x2400), 494 { USB_DEVICE(0x2040, 0x2400),
493 .driver_info = (kernel_ulong_t)&pvr2_device_24xxx}, 495 .driver_info = (kernel_ulong_t)&pvr2_device_24xxx},
494 { USB_DEVICE(0x1164, 0x0622), 496 { USB_DEVICE(0x1164, 0x0622),
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index b1d09d8e2b85..92b83feae366 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -669,7 +669,7 @@ static void s2255_fillbuff(struct s2255_dev *dev, struct s2255_buffer *buf,
669 (unsigned long)vbuf, pos); 669 (unsigned long)vbuf, pos);
670 /* tell v4l buffer was filled */ 670 /* tell v4l buffer was filled */
671 671
672 buf->vb.field_count++; 672 buf->vb.field_count = dev->frame_count[chn] * 2;
673 do_gettimeofday(&ts); 673 do_gettimeofday(&ts);
674 buf->vb.ts = ts; 674 buf->vb.ts = ts;
675 buf->vb.state = VIDEOBUF_DONE; 675 buf->vb.state = VIDEOBUF_DONE;
@@ -1268,6 +1268,7 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i)
1268 dev->last_frame[chn] = -1; 1268 dev->last_frame[chn] = -1;
1269 dev->bad_payload[chn] = 0; 1269 dev->bad_payload[chn] = 0;
1270 dev->cur_frame[chn] = 0; 1270 dev->cur_frame[chn] = 0;
1271 dev->frame_count[chn] = 0;
1271 for (j = 0; j < SYS_FRAMES; j++) { 1272 for (j = 0; j < SYS_FRAMES; j++) {
1272 dev->buffer[chn].frame[j].ulState = 0; 1273 dev->buffer[chn].frame[j].ulState = 0;
1273 dev->buffer[chn].frame[j].cur_size = 0; 1274 dev->buffer[chn].frame[j].cur_size = 0;
diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c
index 6ef3e5297de8..feab12aa2c7b 100644
--- a/drivers/media/video/uvc/uvc_ctrl.c
+++ b/drivers/media/video/uvc/uvc_ctrl.c
@@ -592,7 +592,7 @@ int uvc_query_v4l2_ctrl(struct uvc_video_device *video,
592 if (ctrl == NULL) 592 if (ctrl == NULL)
593 return -EINVAL; 593 return -EINVAL;
594 594
595 data = kmalloc(8, GFP_KERNEL); 595 data = kmalloc(ctrl->info->size, GFP_KERNEL);
596 if (data == NULL) 596 if (data == NULL)
597 return -ENOMEM; 597 return -ENOMEM;
598 598
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index 168baabe4659..11edf79f57be 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -911,7 +911,6 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
911 911
912 for (i = 0; i < W9968CF_URBS; i++) { 912 for (i = 0; i < W9968CF_URBS; i++) {
913 urb = usb_alloc_urb(W9968CF_ISO_PACKETS, GFP_KERNEL); 913 urb = usb_alloc_urb(W9968CF_ISO_PACKETS, GFP_KERNEL);
914 cam->urb[i] = urb;
915 if (!urb) { 914 if (!urb) {
916 for (j = 0; j < i; j++) 915 for (j = 0; j < i; j++)
917 usb_free_urb(cam->urb[j]); 916 usb_free_urb(cam->urb[j]);
@@ -919,6 +918,7 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
919 return -ENOMEM; 918 return -ENOMEM;
920 } 919 }
921 920
921 cam->urb[i] = urb;
922 urb->dev = udev; 922 urb->dev = udev;
923 urb->context = (void*)cam; 923 urb->context = (void*)cam;
924 urb->pipe = usb_rcvisocpipe(udev, 1); 924 urb->pipe = usb_rcvisocpipe(udev, 1);
diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c
index 95c79ad80487..54ac3fe26ec2 100644
--- a/drivers/media/video/wm8739.c
+++ b/drivers/media/video/wm8739.c
@@ -274,10 +274,8 @@ static int wm8739_probe(struct i2c_client *client,
274 client->addr << 1, client->adapter->name); 274 client->addr << 1, client->adapter->name);
275 275
276 state = kmalloc(sizeof(struct wm8739_state), GFP_KERNEL); 276 state = kmalloc(sizeof(struct wm8739_state), GFP_KERNEL);
277 if (state == NULL) { 277 if (state == NULL)
278 kfree(client);
279 return -ENOMEM; 278 return -ENOMEM;
280 }
281 state->vol_l = 0x17; /* 0dB */ 279 state->vol_l = 0x17; /* 0dB */
282 state->vol_r = 0x17; /* 0dB */ 280 state->vol_r = 0x17; /* 0dB */
283 state->muted = 0; 281 state->muted = 0;
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index d842a7cb99d2..3282be730298 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -988,7 +988,7 @@ zoran_open_init_params (struct zoran *zr)
988 zr->v4l_grab_seq = 0; 988 zr->v4l_grab_seq = 0;
989 zr->v4l_settings.width = 192; 989 zr->v4l_settings.width = 192;
990 zr->v4l_settings.height = 144; 990 zr->v4l_settings.height = 144;
991 zr->v4l_settings.format = &zoran_formats[4]; /* YUY2 - YUV-4:2:2 packed */ 991 zr->v4l_settings.format = &zoran_formats[7]; /* YUY2 - YUV-4:2:2 packed */
992 zr->v4l_settings.bytesperline = 992 zr->v4l_settings.bytesperline =
993 zr->v4l_settings.width * 993 zr->v4l_settings.width *
994 ((zr->v4l_settings.format->depth + 7) / 8); 994 ((zr->v4l_settings.format->depth + 7) / 8);
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index ec6f59674b10..2dab9eea4def 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -134,7 +134,7 @@ const struct zoran_format zoran_formats[] = {
134 }, { 134 }, {
135 .name = "16-bit RGB BE", 135 .name = "16-bit RGB BE",
136 ZFMT(-1, 136 ZFMT(-1,
137 V4L2_PIX_FMT_RGB565, V4L2_COLORSPACE_SRGB), 137 V4L2_PIX_FMT_RGB565X, V4L2_COLORSPACE_SRGB),
138 .depth = 16, 138 .depth = 16,
139 .flags = ZORAN_FORMAT_CAPTURE | 139 .flags = ZORAN_FORMAT_CAPTURE |
140 ZORAN_FORMAT_OVERLAY, 140 ZORAN_FORMAT_OVERLAY,
@@ -2737,7 +2737,8 @@ zoran_do_ioctl (struct inode *inode,
2737 fh->v4l_settings.format->fourcc; 2737 fh->v4l_settings.format->fourcc;
2738 fmt->fmt.pix.colorspace = 2738 fmt->fmt.pix.colorspace =
2739 fh->v4l_settings.format->colorspace; 2739 fh->v4l_settings.format->colorspace;
2740 fmt->fmt.pix.bytesperline = 0; 2740 fmt->fmt.pix.bytesperline =
2741 fh->v4l_settings.bytesperline;
2741 if (BUZ_MAX_HEIGHT < 2742 if (BUZ_MAX_HEIGHT <
2742 (fh->v4l_settings.height * 2)) 2743 (fh->v4l_settings.height * 2))
2743 fmt->fmt.pix.field = 2744 fmt->fmt.pix.field =
@@ -2833,13 +2834,6 @@ zoran_do_ioctl (struct inode *inode,
2833 fmt->fmt.pix.pixelformat, 2834 fmt->fmt.pix.pixelformat,
2834 (char *) &printformat); 2835 (char *) &printformat);
2835 2836
2836 if (fmt->fmt.pix.bytesperline > 0) {
2837 dprintk(5,
2838 KERN_ERR "%s: bpl not supported\n",
2839 ZR_DEVNAME(zr));
2840 return -EINVAL;
2841 }
2842
2843 /* we can be requested to do JPEG/raw playback/capture */ 2837 /* we can be requested to do JPEG/raw playback/capture */
2844 if (! 2838 if (!
2845 (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE || 2839 (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE ||
@@ -2923,6 +2917,7 @@ zoran_do_ioctl (struct inode *inode,
2923 fh->jpg_buffers.buffer_size = 2917 fh->jpg_buffers.buffer_size =
2924 zoran_v4l2_calc_bufsize(&fh-> 2918 zoran_v4l2_calc_bufsize(&fh->
2925 jpg_settings); 2919 jpg_settings);
2920 fmt->fmt.pix.bytesperline = 0;
2926 fmt->fmt.pix.sizeimage = 2921 fmt->fmt.pix.sizeimage =
2927 fh->jpg_buffers.buffer_size; 2922 fh->jpg_buffers.buffer_size;
2928 2923
@@ -2979,6 +2974,8 @@ zoran_do_ioctl (struct inode *inode,
2979 2974
2980 /* tell the user the 2975 /* tell the user the
2981 * results/missing stuff */ 2976 * results/missing stuff */
2977 fmt->fmt.pix.bytesperline =
2978 fh->v4l_settings.bytesperline;
2982 fmt->fmt.pix.sizeimage = 2979 fmt->fmt.pix.sizeimage =
2983 fh->v4l_settings.height * 2980 fh->v4l_settings.height *
2984 fh->v4l_settings.bytesperline; 2981 fh->v4l_settings.bytesperline;
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 10c44d3fe01a..68dc8d9eb24e 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -21,7 +21,7 @@ config MFD_SM501
21 21
22config MFD_SM501_GPIO 22config MFD_SM501_GPIO
23 bool "Export GPIO via GPIO layer" 23 bool "Export GPIO via GPIO layer"
24 depends on MFD_SM501 && HAVE_GPIO_LIB 24 depends on MFD_SM501 && GPIOLIB
25 ---help--- 25 ---help---
26 This option uses the gpio library layer to export the 64 GPIO 26 This option uses the gpio library layer to export the 64 GPIO
27 lines on the SM501. The platform data is used to supply the 27 lines on the SM501. The platform data is used to supply the
@@ -29,7 +29,7 @@ config MFD_SM501_GPIO
29 29
30config MFD_ASIC3 30config MFD_ASIC3
31 bool "Support for Compaq ASIC3" 31 bool "Support for Compaq ASIC3"
32 depends on GENERIC_HARDIRQS && HAVE_GPIO_LIB && ARM 32 depends on GENERIC_HARDIRQS && GPIOLIB && ARM
33 ---help--- 33 ---help---
34 This driver supports the ASIC3 multifunction chip found on many 34 This driver supports the ASIC3 multifunction chip found on many
35 PDAs (mainly iPAQ and HTC based ones) 35 PDAs (mainly iPAQ and HTC based ones)
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index bc2a807f210d..ba5aa2008273 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -312,7 +312,6 @@ static int __init asic3_irq_probe(struct platform_device *pdev)
312 struct asic3 *asic = platform_get_drvdata(pdev); 312 struct asic3 *asic = platform_get_drvdata(pdev);
313 unsigned long clksel = 0; 313 unsigned long clksel = 0;
314 unsigned int irq, irq_base; 314 unsigned int irq, irq_base;
315 int map_size;
316 int ret; 315 int ret;
317 316
318 ret = platform_get_irq(pdev, 0); 317 ret = platform_get_irq(pdev, 0);
@@ -534,6 +533,7 @@ static int __init asic3_probe(struct platform_device *pdev)
534 struct asic3 *asic; 533 struct asic3 *asic;
535 struct resource *mem; 534 struct resource *mem;
536 unsigned long clksel; 535 unsigned long clksel;
536 int map_size;
537 int ret = 0; 537 int ret = 0;
538 538
539 asic = kzalloc(sizeof(struct asic3), GFP_KERNEL); 539 asic = kzalloc(sizeof(struct asic3), GFP_KERNEL);
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index a726f3b01a6b..6abb95919c38 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -145,6 +145,7 @@ config ACER_WMI
145 depends on NEW_LEDS 145 depends on NEW_LEDS
146 depends on BACKLIGHT_CLASS_DEVICE 146 depends on BACKLIGHT_CLASS_DEVICE
147 depends on SERIO_I8042 147 depends on SERIO_I8042
148 depends on RFKILL
148 select ACPI_WMI 149 select ACPI_WMI
149 ---help--- 150 ---help---
150 This is a driver for newer Acer (and Wistron) laptops. It adds 151 This is a driver for newer Acer (and Wistron) laptops. It adds
diff --git a/drivers/misc/acer-wmi.c b/drivers/misc/acer-wmi.c
index d8b0d326e452..0532a2de2ce4 100644
--- a/drivers/misc/acer-wmi.c
+++ b/drivers/misc/acer-wmi.c
@@ -33,6 +33,8 @@
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/acpi.h> 34#include <linux/acpi.h>
35#include <linux/i8042.h> 35#include <linux/i8042.h>
36#include <linux/rfkill.h>
37#include <linux/workqueue.h>
36#include <linux/debugfs.h> 38#include <linux/debugfs.h>
37 39
38#include <acpi/acpi_drivers.h> 40#include <acpi/acpi_drivers.h>
@@ -123,21 +125,15 @@ enum interface_flags {
123 125
124static int max_brightness = 0xF; 126static int max_brightness = 0xF;
125 127
126static int wireless = -1;
127static int bluetooth = -1;
128static int mailled = -1; 128static int mailled = -1;
129static int brightness = -1; 129static int brightness = -1;
130static int threeg = -1; 130static int threeg = -1;
131static int force_series; 131static int force_series;
132 132
133module_param(mailled, int, 0444); 133module_param(mailled, int, 0444);
134module_param(wireless, int, 0444);
135module_param(bluetooth, int, 0444);
136module_param(brightness, int, 0444); 134module_param(brightness, int, 0444);
137module_param(threeg, int, 0444); 135module_param(threeg, int, 0444);
138module_param(force_series, int, 0444); 136module_param(force_series, int, 0444);
139MODULE_PARM_DESC(wireless, "Set initial state of Wireless hardware");
140MODULE_PARM_DESC(bluetooth, "Set initial state of Bluetooth hardware");
141MODULE_PARM_DESC(mailled, "Set initial state of Mail LED"); 137MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
142MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness"); 138MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
143MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware"); 139MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
@@ -145,8 +141,6 @@ MODULE_PARM_DESC(force_series, "Force a different laptop series");
145 141
146struct acer_data { 142struct acer_data {
147 int mailled; 143 int mailled;
148 int wireless;
149 int bluetooth;
150 int threeg; 144 int threeg;
151 int brightness; 145 int brightness;
152}; 146};
@@ -157,6 +151,9 @@ struct acer_debug {
157 u32 wmid_devices; 151 u32 wmid_devices;
158}; 152};
159 153
154static struct rfkill *wireless_rfkill;
155static struct rfkill *bluetooth_rfkill;
156
160/* Each low-level interface must define at least some of the following */ 157/* Each low-level interface must define at least some of the following */
161struct wmi_interface { 158struct wmi_interface {
162 /* The WMI device type */ 159 /* The WMI device type */
@@ -476,7 +473,7 @@ struct wmi_interface *iface)
476 } 473 }
477 break; 474 break;
478 default: 475 default:
479 return AE_BAD_ADDRESS; 476 return AE_ERROR;
480 } 477 }
481 return AE_OK; 478 return AE_OK;
482} 479}
@@ -514,7 +511,7 @@ static acpi_status AMW0_set_u32(u32 value, u32 cap, struct wmi_interface *iface)
514 break; 511 break;
515 } 512 }
516 default: 513 default:
517 return AE_BAD_ADDRESS; 514 return AE_ERROR;
518 } 515 }
519 516
520 /* Actually do the set */ 517 /* Actually do the set */
@@ -689,7 +686,7 @@ struct wmi_interface *iface)
689 return 0; 686 return 0;
690 } 687 }
691 default: 688 default:
692 return AE_BAD_ADDRESS; 689 return AE_ERROR;
693 } 690 }
694 status = WMI_execute_u32(method_id, 0, &result); 691 status = WMI_execute_u32(method_id, 0, &result);
695 692
@@ -735,7 +732,7 @@ static acpi_status WMID_set_u32(u32 value, u32 cap, struct wmi_interface *iface)
735 } 732 }
736 break; 733 break;
737 default: 734 default:
738 return AE_BAD_ADDRESS; 735 return AE_ERROR;
739 } 736 }
740 return WMI_execute_u32(method_id, (u32)value, NULL); 737 return WMI_execute_u32(method_id, (u32)value, NULL);
741} 738}
@@ -785,7 +782,7 @@ static struct wmi_interface wmid_interface = {
785 782
786static acpi_status get_u32(u32 *value, u32 cap) 783static acpi_status get_u32(u32 *value, u32 cap)
787{ 784{
788 acpi_status status = AE_BAD_ADDRESS; 785 acpi_status status = AE_ERROR;
789 786
790 switch (interface->type) { 787 switch (interface->type) {
791 case ACER_AMW0: 788 case ACER_AMW0:
@@ -846,8 +843,6 @@ static void __init acer_commandline_init(void)
846 * capability isn't available on the given interface 843 * capability isn't available on the given interface
847 */ 844 */
848 set_u32(mailled, ACER_CAP_MAILLED); 845 set_u32(mailled, ACER_CAP_MAILLED);
849 set_u32(wireless, ACER_CAP_WIRELESS);
850 set_u32(bluetooth, ACER_CAP_BLUETOOTH);
851 set_u32(threeg, ACER_CAP_THREEG); 846 set_u32(threeg, ACER_CAP_THREEG);
852 set_u32(brightness, ACER_CAP_BRIGHTNESS); 847 set_u32(brightness, ACER_CAP_BRIGHTNESS);
853} 848}
@@ -933,40 +928,135 @@ static void acer_backlight_exit(void)
933} 928}
934 929
935/* 930/*
936 * Read/ write bool sysfs macro 931 * Rfkill devices
937 */ 932 */
938#define show_set_bool(value, cap) \ 933static void acer_rfkill_update(struct work_struct *ignored);
939static ssize_t \ 934static DECLARE_DELAYED_WORK(acer_rfkill_work, acer_rfkill_update);
940show_bool_##value(struct device *dev, struct device_attribute *attr, \ 935static void acer_rfkill_update(struct work_struct *ignored)
941 char *buf) \ 936{
942{ \ 937 u32 state;
943 u32 result; \ 938 acpi_status status;
944 acpi_status status = get_u32(&result, cap); \ 939
945 if (ACPI_SUCCESS(status)) \ 940 status = get_u32(&state, ACER_CAP_WIRELESS);
946 return sprintf(buf, "%u\n", result); \ 941 if (ACPI_SUCCESS(status))
947 return sprintf(buf, "Read error\n"); \ 942 rfkill_force_state(wireless_rfkill, state ?
948} \ 943 RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED);
949\ 944
950static ssize_t \ 945 if (has_cap(ACER_CAP_BLUETOOTH)) {
951set_bool_##value(struct device *dev, struct device_attribute *attr, \ 946 status = get_u32(&state, ACER_CAP_BLUETOOTH);
952 const char *buf, size_t count) \ 947 if (ACPI_SUCCESS(status))
953{ \ 948 rfkill_force_state(bluetooth_rfkill, state ?
954 u32 tmp = simple_strtoul(buf, NULL, 10); \ 949 RFKILL_STATE_UNBLOCKED :
955 acpi_status status = set_u32(tmp, cap); \ 950 RFKILL_STATE_SOFT_BLOCKED);
956 if (ACPI_FAILURE(status)) \ 951 }
957 return -EINVAL; \ 952
958 return count; \ 953 schedule_delayed_work(&acer_rfkill_work, round_jiffies_relative(HZ));
959} \ 954}
960static DEVICE_ATTR(value, S_IWUGO | S_IRUGO | S_IWUSR, \ 955
961 show_bool_##value, set_bool_##value); 956static int acer_rfkill_set(void *data, enum rfkill_state state)
962 957{
963show_set_bool(wireless, ACER_CAP_WIRELESS); 958 acpi_status status;
964show_set_bool(bluetooth, ACER_CAP_BLUETOOTH); 959 u32 *cap = data;
965show_set_bool(threeg, ACER_CAP_THREEG); 960 status = set_u32((u32) (state == RFKILL_STATE_UNBLOCKED), *cap);
961 if (ACPI_FAILURE(status))
962 return -ENODEV;
963 return 0;
964}
965
966static struct rfkill * acer_rfkill_register(struct device *dev,
967enum rfkill_type type, char *name, u32 cap)
968{
969 int err;
970 u32 state;
971 u32 *data;
972 struct rfkill *rfkill_dev;
973
974 rfkill_dev = rfkill_allocate(dev, type);
975 if (!rfkill_dev)
976 return ERR_PTR(-ENOMEM);
977 rfkill_dev->name = name;
978 get_u32(&state, cap);
979 rfkill_dev->state = state ? RFKILL_STATE_UNBLOCKED :
980 RFKILL_STATE_SOFT_BLOCKED;
981 data = kzalloc(sizeof(u32), GFP_KERNEL);
982 if (!data) {
983 rfkill_free(rfkill_dev);
984 return ERR_PTR(-ENOMEM);
985 }
986 *data = cap;
987 rfkill_dev->data = data;
988 rfkill_dev->toggle_radio = acer_rfkill_set;
989 rfkill_dev->user_claim_unsupported = 1;
990
991 err = rfkill_register(rfkill_dev);
992 if (err) {
993 kfree(rfkill_dev->data);
994 rfkill_free(rfkill_dev);
995 return ERR_PTR(err);
996 }
997 return rfkill_dev;
998}
999
1000static int acer_rfkill_init(struct device *dev)
1001{
1002 wireless_rfkill = acer_rfkill_register(dev, RFKILL_TYPE_WLAN,
1003 "acer-wireless", ACER_CAP_WIRELESS);
1004 if (IS_ERR(wireless_rfkill))
1005 return PTR_ERR(wireless_rfkill);
1006
1007 if (has_cap(ACER_CAP_BLUETOOTH)) {
1008 bluetooth_rfkill = acer_rfkill_register(dev,
1009 RFKILL_TYPE_BLUETOOTH, "acer-bluetooth",
1010 ACER_CAP_BLUETOOTH);
1011 if (IS_ERR(bluetooth_rfkill)) {
1012 kfree(wireless_rfkill->data);
1013 rfkill_unregister(wireless_rfkill);
1014 return PTR_ERR(bluetooth_rfkill);
1015 }
1016 }
1017
1018 schedule_delayed_work(&acer_rfkill_work, round_jiffies_relative(HZ));
1019
1020 return 0;
1021}
1022
1023static void acer_rfkill_exit(void)
1024{
1025 cancel_delayed_work_sync(&acer_rfkill_work);
1026 kfree(wireless_rfkill->data);
1027 rfkill_unregister(wireless_rfkill);
1028 if (has_cap(ACER_CAP_BLUETOOTH)) {
1029 kfree(wireless_rfkill->data);
1030 rfkill_unregister(bluetooth_rfkill);
1031 }
1032 return;
1033}
966 1034
967/* 1035/*
968 * Read interface sysfs macro 1036 * sysfs interface
969 */ 1037 */
1038static ssize_t show_bool_threeg(struct device *dev,
1039 struct device_attribute *attr, char *buf)
1040{
1041 u32 result; \
1042 acpi_status status = get_u32(&result, ACER_CAP_THREEG);
1043 if (ACPI_SUCCESS(status))
1044 return sprintf(buf, "%u\n", result);
1045 return sprintf(buf, "Read error\n");
1046}
1047
1048static ssize_t set_bool_threeg(struct device *dev,
1049 struct device_attribute *attr, const char *buf, size_t count)
1050{
1051 u32 tmp = simple_strtoul(buf, NULL, 10);
1052 acpi_status status = set_u32(tmp, ACER_CAP_THREEG);
1053 if (ACPI_FAILURE(status))
1054 return -EINVAL;
1055 return count;
1056}
1057static DEVICE_ATTR(threeg, S_IWUGO | S_IRUGO | S_IWUSR, show_bool_threeg,
1058 set_bool_threeg);
1059
970static ssize_t show_interface(struct device *dev, struct device_attribute *attr, 1060static ssize_t show_interface(struct device *dev, struct device_attribute *attr,
971 char *buf) 1061 char *buf)
972{ 1062{
@@ -1026,7 +1116,9 @@ static int __devinit acer_platform_probe(struct platform_device *device)
1026 goto error_brightness; 1116 goto error_brightness;
1027 } 1117 }
1028 1118
1029 return 0; 1119 err = acer_rfkill_init(&device->dev);
1120
1121 return err;
1030 1122
1031error_brightness: 1123error_brightness:
1032 acer_led_exit(); 1124 acer_led_exit();
@@ -1040,6 +1132,8 @@ static int acer_platform_remove(struct platform_device *device)
1040 acer_led_exit(); 1132 acer_led_exit();
1041 if (has_cap(ACER_CAP_BRIGHTNESS)) 1133 if (has_cap(ACER_CAP_BRIGHTNESS))
1042 acer_backlight_exit(); 1134 acer_backlight_exit();
1135
1136 acer_rfkill_exit();
1043 return 0; 1137 return 0;
1044} 1138}
1045 1139
@@ -1052,16 +1146,6 @@ pm_message_t state)
1052 if (!data) 1146 if (!data)
1053 return -ENOMEM; 1147 return -ENOMEM;
1054 1148
1055 if (has_cap(ACER_CAP_WIRELESS)) {
1056 get_u32(&value, ACER_CAP_WIRELESS);
1057 data->wireless = value;
1058 }
1059
1060 if (has_cap(ACER_CAP_BLUETOOTH)) {
1061 get_u32(&value, ACER_CAP_BLUETOOTH);
1062 data->bluetooth = value;
1063 }
1064
1065 if (has_cap(ACER_CAP_MAILLED)) { 1149 if (has_cap(ACER_CAP_MAILLED)) {
1066 get_u32(&value, ACER_CAP_MAILLED); 1150 get_u32(&value, ACER_CAP_MAILLED);
1067 data->mailled = value; 1151 data->mailled = value;
@@ -1082,15 +1166,6 @@ static int acer_platform_resume(struct platform_device *device)
1082 if (!data) 1166 if (!data)
1083 return -ENOMEM; 1167 return -ENOMEM;
1084 1168
1085 if (has_cap(ACER_CAP_WIRELESS))
1086 set_u32(data->wireless, ACER_CAP_WIRELESS);
1087
1088 if (has_cap(ACER_CAP_BLUETOOTH))
1089 set_u32(data->bluetooth, ACER_CAP_BLUETOOTH);
1090
1091 if (has_cap(ACER_CAP_THREEG))
1092 set_u32(data->threeg, ACER_CAP_THREEG);
1093
1094 if (has_cap(ACER_CAP_MAILLED)) 1169 if (has_cap(ACER_CAP_MAILLED))
1095 set_u32(data->mailled, ACER_CAP_MAILLED); 1170 set_u32(data->mailled, ACER_CAP_MAILLED);
1096 1171
@@ -1115,12 +1190,6 @@ static struct platform_device *acer_platform_device;
1115 1190
1116static int remove_sysfs(struct platform_device *device) 1191static int remove_sysfs(struct platform_device *device)
1117{ 1192{
1118 if (has_cap(ACER_CAP_WIRELESS))
1119 device_remove_file(&device->dev, &dev_attr_wireless);
1120
1121 if (has_cap(ACER_CAP_BLUETOOTH))
1122 device_remove_file(&device->dev, &dev_attr_bluetooth);
1123
1124 if (has_cap(ACER_CAP_THREEG)) 1193 if (has_cap(ACER_CAP_THREEG))
1125 device_remove_file(&device->dev, &dev_attr_threeg); 1194 device_remove_file(&device->dev, &dev_attr_threeg);
1126 1195
@@ -1133,20 +1202,6 @@ static int create_sysfs(void)
1133{ 1202{
1134 int retval = -ENOMEM; 1203 int retval = -ENOMEM;
1135 1204
1136 if (has_cap(ACER_CAP_WIRELESS)) {
1137 retval = device_create_file(&acer_platform_device->dev,
1138 &dev_attr_wireless);
1139 if (retval)
1140 goto error_sysfs;
1141 }
1142
1143 if (has_cap(ACER_CAP_BLUETOOTH)) {
1144 retval = device_create_file(&acer_platform_device->dev,
1145 &dev_attr_bluetooth);
1146 if (retval)
1147 goto error_sysfs;
1148 }
1149
1150 if (has_cap(ACER_CAP_THREEG)) { 1205 if (has_cap(ACER_CAP_THREEG)) {
1151 retval = device_create_file(&acer_platform_device->dev, 1206 retval = device_create_file(&acer_platform_device->dev,
1152 &dev_attr_threeg); 1207 &dev_attr_threeg);
diff --git a/drivers/misc/eeepc-laptop.c b/drivers/misc/eeepc-laptop.c
index facdb9893c84..1ee8501e90f1 100644
--- a/drivers/misc/eeepc-laptop.c
+++ b/drivers/misc/eeepc-laptop.c
@@ -450,12 +450,14 @@ static int eeepc_get_fan_pwm(void)
450 int value = 0; 450 int value = 0;
451 451
452 read_acpi_int(NULL, EEEPC_EC_FAN_PWM, &value); 452 read_acpi_int(NULL, EEEPC_EC_FAN_PWM, &value);
453 value = value * 255 / 100;
453 return (value); 454 return (value);
454} 455}
455 456
456static void eeepc_set_fan_pwm(int value) 457static void eeepc_set_fan_pwm(int value)
457{ 458{
458 value = SENSORS_LIMIT(value, 0, 100); 459 value = SENSORS_LIMIT(value, 0, 255);
460 value = value * 100 / 255;
459 ec_write(EEEPC_EC_SC02, value); 461 ec_write(EEEPC_EC_SC02, value);
460} 462}
461 463
@@ -520,15 +522,23 @@ static ssize_t show_sys_hwmon(int (*get)(void), char *buf)
520 static SENSOR_DEVICE_ATTR(_name, _mode, show_##_name, store_##_name, 0); 522 static SENSOR_DEVICE_ATTR(_name, _mode, show_##_name, store_##_name, 0);
521 523
522EEEPC_CREATE_SENSOR_ATTR(fan1_input, S_IRUGO, eeepc_get_fan_rpm, NULL); 524EEEPC_CREATE_SENSOR_ATTR(fan1_input, S_IRUGO, eeepc_get_fan_rpm, NULL);
523EEEPC_CREATE_SENSOR_ATTR(fan1_pwm, S_IRUGO | S_IWUSR, 525EEEPC_CREATE_SENSOR_ATTR(pwm1, S_IRUGO | S_IWUSR,
524 eeepc_get_fan_pwm, eeepc_set_fan_pwm); 526 eeepc_get_fan_pwm, eeepc_set_fan_pwm);
525EEEPC_CREATE_SENSOR_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, 527EEEPC_CREATE_SENSOR_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
526 eeepc_get_fan_ctrl, eeepc_set_fan_ctrl); 528 eeepc_get_fan_ctrl, eeepc_set_fan_ctrl);
527 529
530static ssize_t
531show_name(struct device *dev, struct device_attribute *attr, char *buf)
532{
533 return sprintf(buf, "eeepc\n");
534}
535static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0);
536
528static struct attribute *hwmon_attributes[] = { 537static struct attribute *hwmon_attributes[] = {
529 &sensor_dev_attr_fan1_pwm.dev_attr.attr, 538 &sensor_dev_attr_pwm1.dev_attr.attr,
530 &sensor_dev_attr_fan1_input.dev_attr.attr, 539 &sensor_dev_attr_fan1_input.dev_attr.attr,
531 &sensor_dev_attr_pwm1_enable.dev_attr.attr, 540 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
541 &sensor_dev_attr_name.dev_attr.attr,
532 NULL 542 NULL
533}; 543};
534 544
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 917035e16da4..00008967ef7a 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -426,8 +426,6 @@ static u32 atmci_submit_data(struct mmc_host *mmc, struct mmc_data *data)
426 host->sg = NULL; 426 host->sg = NULL;
427 host->data = data; 427 host->data = data;
428 428
429 mci_writel(host, BLKR, MCI_BCNT(data->blocks)
430 | MCI_BLKLEN(data->blksz));
431 dev_vdbg(&mmc->class_dev, "BLKR=0x%08x\n", 429 dev_vdbg(&mmc->class_dev, "BLKR=0x%08x\n",
432 MCI_BCNT(data->blocks) | MCI_BLKLEN(data->blksz)); 430 MCI_BCNT(data->blocks) | MCI_BLKLEN(data->blksz));
433 431
@@ -483,6 +481,10 @@ static void atmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
483 if (data->blocks > 1 && data->blksz & 3) 481 if (data->blocks > 1 && data->blksz & 3)
484 goto fail; 482 goto fail;
485 atmci_set_timeout(host, data); 483 atmci_set_timeout(host, data);
484
485 /* Must set block count/size before sending command */
486 mci_writel(host, BLKR, MCI_BCNT(data->blocks)
487 | MCI_BLKLEN(data->blksz));
486 } 488 }
487 489
488 iflags = MCI_CMDRDY; 490 iflags = MCI_CMDRDY;
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index ac4e506b4f88..5ea6b60fa377 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -257,7 +257,6 @@ struct e1000_adapter {
257 struct net_device *netdev; 257 struct net_device *netdev;
258 struct pci_dev *pdev; 258 struct pci_dev *pdev;
259 struct net_device_stats net_stats; 259 struct net_device_stats net_stats;
260 spinlock_t stats_lock; /* prevent concurrent stats updates */
261 260
262 /* structs defined in e1000_hw.h */ 261 /* structs defined in e1000_hw.h */
263 struct e1000_hw hw; 262 struct e1000_hw hw;
@@ -284,6 +283,8 @@ struct e1000_adapter {
284 unsigned long led_status; 283 unsigned long led_status;
285 284
286 unsigned int flags; 285 unsigned int flags;
286 struct work_struct downshift_task;
287 struct work_struct update_phy_task;
287}; 288};
288 289
289struct e1000_info { 290struct e1000_info {
@@ -305,6 +306,7 @@ struct e1000_info {
305#define FLAG_HAS_CTRLEXT_ON_LOAD (1 << 5) 306#define FLAG_HAS_CTRLEXT_ON_LOAD (1 << 5)
306#define FLAG_HAS_SWSM_ON_LOAD (1 << 6) 307#define FLAG_HAS_SWSM_ON_LOAD (1 << 6)
307#define FLAG_HAS_JUMBO_FRAMES (1 << 7) 308#define FLAG_HAS_JUMBO_FRAMES (1 << 7)
309#define FLAG_READ_ONLY_NVM (1 << 8)
308#define FLAG_IS_ICH (1 << 9) 310#define FLAG_IS_ICH (1 << 9)
309#define FLAG_HAS_SMART_POWER_DOWN (1 << 11) 311#define FLAG_HAS_SMART_POWER_DOWN (1 << 11)
310#define FLAG_IS_QUAD_PORT_A (1 << 12) 312#define FLAG_IS_QUAD_PORT_A (1 << 12)
@@ -385,6 +387,7 @@ extern bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw);
385extern bool e1000e_get_laa_state_82571(struct e1000_hw *hw); 387extern bool e1000e_get_laa_state_82571(struct e1000_hw *hw);
386extern void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state); 388extern void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state);
387 389
390extern void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw);
388extern void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, 391extern void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
389 bool state); 392 bool state);
390extern void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw); 393extern void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw);
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index e21c9e0f3738..33a3ff17b5d0 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -432,6 +432,10 @@ static void e1000_get_regs(struct net_device *netdev,
432 regs_buff[11] = er32(TIDV); 432 regs_buff[11] = er32(TIDV);
433 433
434 regs_buff[12] = adapter->hw.phy.type; /* PHY type (IGP=1, M88=0) */ 434 regs_buff[12] = adapter->hw.phy.type; /* PHY type (IGP=1, M88=0) */
435
436 /* ethtool doesn't use anything past this point, so all this
437 * code is likely legacy junk for apps that may or may not
438 * exist */
435 if (hw->phy.type == e1000_phy_m88) { 439 if (hw->phy.type == e1000_phy_m88) {
436 e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); 440 e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
437 regs_buff[13] = (u32)phy_data; /* cable length */ 441 regs_buff[13] = (u32)phy_data; /* cable length */
@@ -447,7 +451,7 @@ static void e1000_get_regs(struct net_device *netdev,
447 regs_buff[22] = adapter->phy_stats.receive_errors; 451 regs_buff[22] = adapter->phy_stats.receive_errors;
448 regs_buff[23] = regs_buff[13]; /* mdix mode */ 452 regs_buff[23] = regs_buff[13]; /* mdix mode */
449 } 453 }
450 regs_buff[21] = adapter->phy_stats.idle_errors; /* phy idle errors */ 454 regs_buff[21] = 0; /* was idle_errors */
451 e1e_rphy(hw, PHY_1000T_STATUS, &phy_data); 455 e1e_rphy(hw, PHY_1000T_STATUS, &phy_data);
452 regs_buff[24] = (u32)phy_data; /* phy local receiver status */ 456 regs_buff[24] = (u32)phy_data; /* phy local receiver status */
453 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */ 457 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */
@@ -529,6 +533,9 @@ static int e1000_set_eeprom(struct net_device *netdev,
529 if (eeprom->magic != (adapter->pdev->vendor | (adapter->pdev->device << 16))) 533 if (eeprom->magic != (adapter->pdev->vendor | (adapter->pdev->device << 16)))
530 return -EFAULT; 534 return -EFAULT;
531 535
536 if (adapter->flags & FLAG_READ_ONLY_NVM)
537 return -EINVAL;
538
532 max_len = hw->nvm.word_size * 2; 539 max_len = hw->nvm.word_size * 2;
533 540
534 first_word = eeprom->offset >> 1; 541 first_word = eeprom->offset >> 1;
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 9e38452a738c..bcd2bc477af2 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -58,6 +58,7 @@
58#define ICH_FLASH_HSFCTL 0x0006 58#define ICH_FLASH_HSFCTL 0x0006
59#define ICH_FLASH_FADDR 0x0008 59#define ICH_FLASH_FADDR 0x0008
60#define ICH_FLASH_FDATA0 0x0010 60#define ICH_FLASH_FDATA0 0x0010
61#define ICH_FLASH_PR0 0x0074
61 62
62#define ICH_FLASH_READ_COMMAND_TIMEOUT 500 63#define ICH_FLASH_READ_COMMAND_TIMEOUT 500
63#define ICH_FLASH_WRITE_COMMAND_TIMEOUT 500 64#define ICH_FLASH_WRITE_COMMAND_TIMEOUT 500
@@ -150,6 +151,19 @@ union ich8_hws_flash_regacc {
150 u16 regval; 151 u16 regval;
151}; 152};
152 153
154/* ICH Flash Protected Region */
155union ich8_flash_protected_range {
156 struct ich8_pr {
157 u32 base:13; /* 0:12 Protected Range Base */
158 u32 reserved1:2; /* 13:14 Reserved */
159 u32 rpe:1; /* 15 Read Protection Enable */
160 u32 limit:13; /* 16:28 Protected Range Limit */
161 u32 reserved2:2; /* 29:30 Reserved */
162 u32 wpe:1; /* 31 Write Protection Enable */
163 } range;
164 u32 regval;
165};
166
153static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw); 167static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);
154static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw); 168static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);
155static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw); 169static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);
@@ -366,6 +380,9 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
366 return 0; 380 return 0;
367} 381}
368 382
383static DEFINE_MUTEX(nvm_mutex);
384static pid_t nvm_owner = -1;
385
369/** 386/**
370 * e1000_acquire_swflag_ich8lan - Acquire software control flag 387 * e1000_acquire_swflag_ich8lan - Acquire software control flag
371 * @hw: pointer to the HW structure 388 * @hw: pointer to the HW structure
@@ -379,6 +396,15 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
379 u32 extcnf_ctrl; 396 u32 extcnf_ctrl;
380 u32 timeout = PHY_CFG_TIMEOUT; 397 u32 timeout = PHY_CFG_TIMEOUT;
381 398
399 might_sleep();
400
401 if (!mutex_trylock(&nvm_mutex)) {
402 WARN(1, KERN_ERR "e1000e mutex contention. Owned by pid %d\n",
403 nvm_owner);
404 mutex_lock(&nvm_mutex);
405 }
406 nvm_owner = current->pid;
407
382 while (timeout) { 408 while (timeout) {
383 extcnf_ctrl = er32(EXTCNF_CTRL); 409 extcnf_ctrl = er32(EXTCNF_CTRL);
384 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG; 410 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
@@ -393,6 +419,8 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
393 419
394 if (!timeout) { 420 if (!timeout) {
395 hw_dbg(hw, "FW or HW has locked the resource for too long.\n"); 421 hw_dbg(hw, "FW or HW has locked the resource for too long.\n");
422 nvm_owner = -1;
423 mutex_unlock(&nvm_mutex);
396 return -E1000_ERR_CONFIG; 424 return -E1000_ERR_CONFIG;
397 } 425 }
398 426
@@ -414,6 +442,9 @@ static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
414 extcnf_ctrl = er32(EXTCNF_CTRL); 442 extcnf_ctrl = er32(EXTCNF_CTRL);
415 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 443 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
416 ew32(EXTCNF_CTRL, extcnf_ctrl); 444 ew32(EXTCNF_CTRL, extcnf_ctrl);
445
446 nvm_owner = -1;
447 mutex_unlock(&nvm_mutex);
417} 448}
418 449
419/** 450/**
@@ -1284,6 +1315,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
1284 * programming failed. 1315 * programming failed.
1285 */ 1316 */
1286 if (ret_val) { 1317 if (ret_val) {
1318 /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
1287 hw_dbg(hw, "Flash commit failed.\n"); 1319 hw_dbg(hw, "Flash commit failed.\n");
1288 e1000_release_swflag_ich8lan(hw); 1320 e1000_release_swflag_ich8lan(hw);
1289 return ret_val; 1321 return ret_val;
@@ -1374,6 +1406,49 @@ static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)
1374} 1406}
1375 1407
1376/** 1408/**
1409 * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
1410 * @hw: pointer to the HW structure
1411 *
1412 * To prevent malicious write/erase of the NVM, set it to be read-only
1413 * so that the hardware ignores all write/erase cycles of the NVM via
1414 * the flash control registers. The shadow-ram copy of the NVM will
1415 * still be updated, however any updates to this copy will not stick
1416 * across driver reloads.
1417 **/
1418void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw)
1419{
1420 union ich8_flash_protected_range pr0;
1421 union ich8_hws_flash_status hsfsts;
1422 u32 gfpreg;
1423 s32 ret_val;
1424
1425 ret_val = e1000_acquire_swflag_ich8lan(hw);
1426 if (ret_val)
1427 return;
1428
1429 gfpreg = er32flash(ICH_FLASH_GFPREG);
1430
1431 /* Write-protect GbE Sector of NVM */
1432 pr0.regval = er32flash(ICH_FLASH_PR0);
1433 pr0.range.base = gfpreg & FLASH_GFPREG_BASE_MASK;
1434 pr0.range.limit = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK);
1435 pr0.range.wpe = true;
1436 ew32flash(ICH_FLASH_PR0, pr0.regval);
1437
1438 /*
1439 * Lock down a subset of GbE Flash Control Registers, e.g.
1440 * PR0 to prevent the write-protection from being lifted.
1441 * Once FLOCKDN is set, the registers protected by it cannot
1442 * be written until FLOCKDN is cleared by a hardware reset.
1443 */
1444 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
1445 hsfsts.hsf_status.flockdn = true;
1446 ew32flash(ICH_FLASH_HSFSTS, hsfsts.regval);
1447
1448 e1000_release_swflag_ich8lan(hw);
1449}
1450
1451/**
1377 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM 1452 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
1378 * @hw: pointer to the HW structure 1453 * @hw: pointer to the HW structure
1379 * @offset: The offset (in bytes) of the byte/word to read. 1454 * @offset: The offset (in bytes) of the byte/word to read.
@@ -1720,6 +1795,9 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
1720 ew32(CTRL, (ctrl | E1000_CTRL_RST)); 1795 ew32(CTRL, (ctrl | E1000_CTRL_RST));
1721 msleep(20); 1796 msleep(20);
1722 1797
1798 /* release the swflag because it is not reset by hardware reset */
1799 e1000_release_swflag_ich8lan(hw);
1800
1723 ret_val = e1000e_get_auto_rd_done(hw); 1801 ret_val = e1000e_get_auto_rd_done(hw);
1724 if (ret_val) { 1802 if (ret_val) {
1725 /* 1803 /*
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index d266510c8a94..b81c4237b5d3 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -47,7 +47,7 @@
47 47
48#include "e1000.h" 48#include "e1000.h"
49 49
50#define DRV_VERSION "0.3.3.3-k2" 50#define DRV_VERSION "0.3.3.3-k6"
51char e1000e_driver_name[] = "e1000e"; 51char e1000e_driver_name[] = "e1000e";
52const char e1000e_driver_version[] = DRV_VERSION; 52const char e1000e_driver_version[] = DRV_VERSION;
53 53
@@ -1115,6 +1115,14 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter)
1115 writel(0, adapter->hw.hw_addr + rx_ring->tail); 1115 writel(0, adapter->hw.hw_addr + rx_ring->tail);
1116} 1116}
1117 1117
1118static void e1000e_downshift_workaround(struct work_struct *work)
1119{
1120 struct e1000_adapter *adapter = container_of(work,
1121 struct e1000_adapter, downshift_task);
1122
1123 e1000e_gig_downshift_workaround_ich8lan(&adapter->hw);
1124}
1125
1118/** 1126/**
1119 * e1000_intr_msi - Interrupt Handler 1127 * e1000_intr_msi - Interrupt Handler
1120 * @irq: interrupt number 1128 * @irq: interrupt number
@@ -1139,7 +1147,7 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)
1139 */ 1147 */
1140 if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) && 1148 if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) &&
1141 (!(er32(STATUS) & E1000_STATUS_LU))) 1149 (!(er32(STATUS) & E1000_STATUS_LU)))
1142 e1000e_gig_downshift_workaround_ich8lan(hw); 1150 schedule_work(&adapter->downshift_task);
1143 1151
1144 /* 1152 /*
1145 * 80003ES2LAN workaround-- For packet buffer work-around on 1153 * 80003ES2LAN workaround-- For packet buffer work-around on
@@ -1205,7 +1213,7 @@ static irqreturn_t e1000_intr(int irq, void *data)
1205 */ 1213 */
1206 if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) && 1214 if ((adapter->flags & FLAG_LSC_GIG_SPEED_DROP) &&
1207 (!(er32(STATUS) & E1000_STATUS_LU))) 1215 (!(er32(STATUS) & E1000_STATUS_LU)))
1208 e1000e_gig_downshift_workaround_ich8lan(hw); 1216 schedule_work(&adapter->downshift_task);
1209 1217
1210 /* 1218 /*
1211 * 80003ES2LAN workaround-- 1219 * 80003ES2LAN workaround--
@@ -2592,8 +2600,6 @@ static int __devinit e1000_sw_init(struct e1000_adapter *adapter)
2592 /* Explicitly disable IRQ since the NIC can be in any state. */ 2600 /* Explicitly disable IRQ since the NIC can be in any state. */
2593 e1000_irq_disable(adapter); 2601 e1000_irq_disable(adapter);
2594 2602
2595 spin_lock_init(&adapter->stats_lock);
2596
2597 set_bit(__E1000_DOWN, &adapter->state); 2603 set_bit(__E1000_DOWN, &adapter->state);
2598 return 0; 2604 return 0;
2599 2605
@@ -2912,6 +2918,21 @@ static int e1000_set_mac(struct net_device *netdev, void *p)
2912 return 0; 2918 return 0;
2913} 2919}
2914 2920
2921/**
2922 * e1000e_update_phy_task - work thread to update phy
2923 * @work: pointer to our work struct
2924 *
2925 * this worker thread exists because we must acquire a
2926 * semaphore to read the phy, which we could msleep while
2927 * waiting for it, and we can't msleep in a timer.
2928 **/
2929static void e1000e_update_phy_task(struct work_struct *work)
2930{
2931 struct e1000_adapter *adapter = container_of(work,
2932 struct e1000_adapter, update_phy_task);
2933 e1000_get_phy_info(&adapter->hw);
2934}
2935
2915/* 2936/*
2916 * Need to wait a few seconds after link up to get diagnostic information from 2937 * Need to wait a few seconds after link up to get diagnostic information from
2917 * the phy 2938 * the phy
@@ -2919,7 +2940,7 @@ static int e1000_set_mac(struct net_device *netdev, void *p)
2919static void e1000_update_phy_info(unsigned long data) 2940static void e1000_update_phy_info(unsigned long data)
2920{ 2941{
2921 struct e1000_adapter *adapter = (struct e1000_adapter *) data; 2942 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
2922 e1000_get_phy_info(&adapter->hw); 2943 schedule_work(&adapter->update_phy_task);
2923} 2944}
2924 2945
2925/** 2946/**
@@ -2930,10 +2951,6 @@ void e1000e_update_stats(struct e1000_adapter *adapter)
2930{ 2951{
2931 struct e1000_hw *hw = &adapter->hw; 2952 struct e1000_hw *hw = &adapter->hw;
2932 struct pci_dev *pdev = adapter->pdev; 2953 struct pci_dev *pdev = adapter->pdev;
2933 unsigned long irq_flags;
2934 u16 phy_tmp;
2935
2936#define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
2937 2954
2938 /* 2955 /*
2939 * Prevent stats update while adapter is being reset, or if the pci 2956 * Prevent stats update while adapter is being reset, or if the pci
@@ -2944,14 +2961,6 @@ void e1000e_update_stats(struct e1000_adapter *adapter)
2944 if (pci_channel_offline(pdev)) 2961 if (pci_channel_offline(pdev))
2945 return; 2962 return;
2946 2963
2947 spin_lock_irqsave(&adapter->stats_lock, irq_flags);
2948
2949 /*
2950 * these counters are modified from e1000_adjust_tbi_stats,
2951 * called from the interrupt context, so they must only
2952 * be written while holding adapter->stats_lock
2953 */
2954
2955 adapter->stats.crcerrs += er32(CRCERRS); 2964 adapter->stats.crcerrs += er32(CRCERRS);
2956 adapter->stats.gprc += er32(GPRC); 2965 adapter->stats.gprc += er32(GPRC);
2957 adapter->stats.gorc += er32(GORCL); 2966 adapter->stats.gorc += er32(GORCL);
@@ -3022,21 +3031,10 @@ void e1000e_update_stats(struct e1000_adapter *adapter)
3022 3031
3023 /* Tx Dropped needs to be maintained elsewhere */ 3032 /* Tx Dropped needs to be maintained elsewhere */
3024 3033
3025 /* Phy Stats */
3026 if (hw->phy.media_type == e1000_media_type_copper) {
3027 if ((adapter->link_speed == SPEED_1000) &&
3028 (!e1e_rphy(hw, PHY_1000T_STATUS, &phy_tmp))) {
3029 phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
3030 adapter->phy_stats.idle_errors += phy_tmp;
3031 }
3032 }
3033
3034 /* Management Stats */ 3034 /* Management Stats */
3035 adapter->stats.mgptc += er32(MGTPTC); 3035 adapter->stats.mgptc += er32(MGTPTC);
3036 adapter->stats.mgprc += er32(MGTPRC); 3036 adapter->stats.mgprc += er32(MGTPRC);
3037 adapter->stats.mgpdc += er32(MGTPDC); 3037 adapter->stats.mgpdc += er32(MGTPDC);
3038
3039 spin_unlock_irqrestore(&adapter->stats_lock, irq_flags);
3040} 3038}
3041 3039
3042/** 3040/**
@@ -3048,10 +3046,6 @@ static void e1000_phy_read_status(struct e1000_adapter *adapter)
3048 struct e1000_hw *hw = &adapter->hw; 3046 struct e1000_hw *hw = &adapter->hw;
3049 struct e1000_phy_regs *phy = &adapter->phy_regs; 3047 struct e1000_phy_regs *phy = &adapter->phy_regs;
3050 int ret_val; 3048 int ret_val;
3051 unsigned long irq_flags;
3052
3053
3054 spin_lock_irqsave(&adapter->stats_lock, irq_flags);
3055 3049
3056 if ((er32(STATUS) & E1000_STATUS_LU) && 3050 if ((er32(STATUS) & E1000_STATUS_LU) &&
3057 (adapter->hw.phy.media_type == e1000_media_type_copper)) { 3051 (adapter->hw.phy.media_type == e1000_media_type_copper)) {
@@ -3082,8 +3076,6 @@ static void e1000_phy_read_status(struct e1000_adapter *adapter)
3082 phy->stat1000 = 0; 3076 phy->stat1000 = 0;
3083 phy->estatus = (ESTATUS_1000_TFULL | ESTATUS_1000_THALF); 3077 phy->estatus = (ESTATUS_1000_TFULL | ESTATUS_1000_THALF);
3084 } 3078 }
3085
3086 spin_unlock_irqrestore(&adapter->stats_lock, irq_flags);
3087} 3079}
3088 3080
3089static void e1000_print_link_info(struct e1000_adapter *adapter) 3081static void e1000_print_link_info(struct e1000_adapter *adapter)
@@ -4467,6 +4459,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4467 4459
4468 adapter->bd_number = cards_found++; 4460 adapter->bd_number = cards_found++;
4469 4461
4462 e1000e_check_options(adapter);
4463
4470 /* setup adapter struct */ 4464 /* setup adapter struct */
4471 err = e1000_sw_init(adapter); 4465 err = e1000_sw_init(adapter);
4472 if (err) 4466 if (err)
@@ -4482,6 +4476,10 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4482 if (err) 4476 if (err)
4483 goto err_hw_init; 4477 goto err_hw_init;
4484 4478
4479 if ((adapter->flags & FLAG_IS_ICH) &&
4480 (adapter->flags & FLAG_READ_ONLY_NVM))
4481 e1000e_write_protect_nvm_ich8lan(&adapter->hw);
4482
4485 hw->mac.ops.get_bus_info(&adapter->hw); 4483 hw->mac.ops.get_bus_info(&adapter->hw);
4486 4484
4487 adapter->hw.phy.autoneg_wait_to_complete = 0; 4485 adapter->hw.phy.autoneg_wait_to_complete = 0;
@@ -4572,8 +4570,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4572 4570
4573 INIT_WORK(&adapter->reset_task, e1000_reset_task); 4571 INIT_WORK(&adapter->reset_task, e1000_reset_task);
4574 INIT_WORK(&adapter->watchdog_task, e1000_watchdog_task); 4572 INIT_WORK(&adapter->watchdog_task, e1000_watchdog_task);
4575 4573 INIT_WORK(&adapter->downshift_task, e1000e_downshift_workaround);
4576 e1000e_check_options(adapter); 4574 INIT_WORK(&adapter->update_phy_task, e1000e_update_phy_task);
4577 4575
4578 /* Initialize link parameters. User can change them with ethtool */ 4576 /* Initialize link parameters. User can change them with ethtool */
4579 adapter->hw.mac.autoneg = 1; 4577 adapter->hw.mac.autoneg = 1;
diff --git a/drivers/net/e1000e/param.c b/drivers/net/e1000e/param.c
index ed912e023a72..d91dbf7ba434 100644
--- a/drivers/net/e1000e/param.c
+++ b/drivers/net/e1000e/param.c
@@ -133,6 +133,15 @@ E1000_PARAM(SmartPowerDownEnable, "Enable PHY smart power down");
133 */ 133 */
134E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround"); 134E1000_PARAM(KumeranLockLoss, "Enable Kumeran lock loss workaround");
135 135
136/*
137 * Write Protect NVM
138 *
139 * Valid Range: 0, 1
140 *
141 * Default Value: 1 (enabled)
142 */
143E1000_PARAM(WriteProtectNVM, "Write-protect NVM [WARNING: disabling this can lead to corrupted NVM]");
144
136struct e1000_option { 145struct e1000_option {
137 enum { enable_option, range_option, list_option } type; 146 enum { enable_option, range_option, list_option } type;
138 const char *name; 147 const char *name;
@@ -388,4 +397,25 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
388 opt.def); 397 opt.def);
389 } 398 }
390 } 399 }
400 { /* Write-protect NVM */
401 const struct e1000_option opt = {
402 .type = enable_option,
403 .name = "Write-protect NVM",
404 .err = "defaulting to Enabled",
405 .def = OPTION_ENABLED
406 };
407
408 if (adapter->flags & FLAG_IS_ICH) {
409 if (num_WriteProtectNVM > bd) {
410 unsigned int write_protect_nvm = WriteProtectNVM[bd];
411 e1000_validate_option(&write_protect_nvm, &opt,
412 adapter);
413 if (write_protect_nvm)
414 adapter->flags |= FLAG_READ_ONLY_NVM;
415 } else {
416 if (opt.def)
417 adapter->flags |= FLAG_READ_ONLY_NVM;
418 }
419 }
420 }
391} 421}
diff --git a/drivers/net/wireless/ath9k/core.c b/drivers/net/wireless/ath9k/core.c
index f6c45288d0e7..87e37bc39145 100644
--- a/drivers/net/wireless/ath9k/core.c
+++ b/drivers/net/wireless/ath9k/core.c
@@ -294,8 +294,6 @@ static int ath_stop(struct ath_softc *sc)
294 * hardware is gone (invalid). 294 * hardware is gone (invalid).
295 */ 295 */
296 296
297 if (!sc->sc_invalid)
298 ath9k_hw_set_interrupts(ah, 0);
299 ath_draintxq(sc, false); 297 ath_draintxq(sc, false);
300 if (!sc->sc_invalid) { 298 if (!sc->sc_invalid) {
301 ath_stoprecv(sc); 299 ath_stoprecv(sc);
@@ -797,6 +795,12 @@ int ath_open(struct ath_softc *sc, struct ath9k_channel *initial_chan)
797 if (ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT) 795 if (ah->ah_caps.hw_caps & ATH9K_HW_CAP_HT)
798 sc->sc_imask |= ATH9K_INT_CST; 796 sc->sc_imask |= ATH9K_INT_CST;
799 797
798 /* Note: We disable MIB interrupts for now as we don't yet
799 * handle processing ANI, otherwise you will get an interrupt
800 * storm after about 7 hours of usage making the system unusable
801 * with huge latency. Once we do have ANI processing included
802 * we can re-enable this interrupt. */
803#if 0
800 /* 804 /*
801 * Enable MIB interrupts when there are hardware phy counters. 805 * Enable MIB interrupts when there are hardware phy counters.
802 * Note we only do this (at the moment) for station mode. 806 * Note we only do this (at the moment) for station mode.
@@ -804,6 +808,7 @@ int ath_open(struct ath_softc *sc, struct ath9k_channel *initial_chan)
804 if (ath9k_hw_phycounters(ah) && 808 if (ath9k_hw_phycounters(ah) &&
805 ((sc->sc_opmode == ATH9K_M_STA) || (sc->sc_opmode == ATH9K_M_IBSS))) 809 ((sc->sc_opmode == ATH9K_M_STA) || (sc->sc_opmode == ATH9K_M_IBSS)))
806 sc->sc_imask |= ATH9K_INT_MIB; 810 sc->sc_imask |= ATH9K_INT_MIB;
811#endif
807 /* 812 /*
808 * Some hardware processes the TIM IE and fires an 813 * Some hardware processes the TIM IE and fires an
809 * interrupt when the TIM bit is set. For hardware 814 * interrupt when the TIM bit is set. For hardware
@@ -1336,6 +1341,8 @@ void ath_deinit(struct ath_softc *sc)
1336 1341
1337 DPRINTF(sc, ATH_DBG_CONFIG, "%s\n", __func__); 1342 DPRINTF(sc, ATH_DBG_CONFIG, "%s\n", __func__);
1338 1343
1344 tasklet_kill(&sc->intr_tq);
1345 tasklet_kill(&sc->bcon_tasklet);
1339 ath_stop(sc); 1346 ath_stop(sc);
1340 if (!sc->sc_invalid) 1347 if (!sc->sc_invalid)
1341 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE); 1348 ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
diff --git a/drivers/net/wireless/ath9k/core.h b/drivers/net/wireless/ath9k/core.h
index 4ee695b76b88..2f84093331ee 100644
--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -974,7 +974,6 @@ struct ath_softc {
974 u32 sc_keymax; /* size of key cache */ 974 u32 sc_keymax; /* size of key cache */
975 DECLARE_BITMAP(sc_keymap, ATH_KEYMAX); /* key use bit map */ 975 DECLARE_BITMAP(sc_keymap, ATH_KEYMAX); /* key use bit map */
976 u8 sc_splitmic; /* split TKIP MIC keys */ 976 u8 sc_splitmic; /* split TKIP MIC keys */
977 int sc_keytype;
978 977
979 /* RX */ 978 /* RX */
980 struct list_head sc_rxbuf; 979 struct list_head sc_rxbuf;
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 99badf1404c3..acebdf1d20a8 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -206,8 +206,6 @@ static int ath_key_config(struct ath_softc *sc,
206 if (!ret) 206 if (!ret)
207 return -EIO; 207 return -EIO;
208 208
209 if (mac)
210 sc->sc_keytype = hk.kv_type;
211 return 0; 209 return 0;
212} 210}
213 211
@@ -778,7 +776,6 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
778 case DISABLE_KEY: 776 case DISABLE_KEY:
779 ath_key_delete(sc, key); 777 ath_key_delete(sc, key);
780 clear_bit(key->keyidx, sc->sc_keymap); 778 clear_bit(key->keyidx, sc->sc_keymap);
781 sc->sc_keytype = ATH9K_CIPHER_CLR;
782 break; 779 break;
783 default: 780 default:
784 ret = -EINVAL; 781 ret = -EINVAL;
@@ -1414,10 +1411,17 @@ static void ath_pci_remove(struct pci_dev *pdev)
1414{ 1411{
1415 struct ieee80211_hw *hw = pci_get_drvdata(pdev); 1412 struct ieee80211_hw *hw = pci_get_drvdata(pdev);
1416 struct ath_softc *sc = hw->priv; 1413 struct ath_softc *sc = hw->priv;
1414 enum ath9k_int status;
1417 1415
1418 if (pdev->irq) 1416 if (pdev->irq) {
1417 ath9k_hw_set_interrupts(sc->sc_ah, 0);
1418 /* clear the ISR */
1419 ath9k_hw_getisr(sc->sc_ah, &status);
1420 sc->sc_invalid = 1;
1419 free_irq(pdev->irq, sc); 1421 free_irq(pdev->irq, sc);
1422 }
1420 ath_detach(sc); 1423 ath_detach(sc);
1424
1421 pci_iounmap(pdev, sc->mem); 1425 pci_iounmap(pdev, sc->mem);
1422 pci_release_region(pdev, 0); 1426 pci_release_region(pdev, 0);
1423 pci_disable_device(pdev); 1427 pci_disable_device(pdev);
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath9k/xmit.c
index 550129f717e2..8b332e11a656 100644
--- a/drivers/net/wireless/ath9k/xmit.c
+++ b/drivers/net/wireless/ath9k/xmit.c
@@ -315,11 +315,11 @@ static int ath_tx_prepare(struct ath_softc *sc,
315 txctl->keyix = tx_info->control.hw_key->hw_key_idx; 315 txctl->keyix = tx_info->control.hw_key->hw_key_idx;
316 txctl->frmlen += tx_info->control.icv_len; 316 txctl->frmlen += tx_info->control.icv_len;
317 317
318 if (sc->sc_keytype == ATH9K_CIPHER_WEP) 318 if (tx_info->control.hw_key->alg == ALG_WEP)
319 txctl->keytype = ATH9K_KEY_TYPE_WEP; 319 txctl->keytype = ATH9K_KEY_TYPE_WEP;
320 else if (sc->sc_keytype == ATH9K_CIPHER_TKIP) 320 else if (tx_info->control.hw_key->alg == ALG_TKIP)
321 txctl->keytype = ATH9K_KEY_TYPE_TKIP; 321 txctl->keytype = ATH9K_KEY_TYPE_TKIP;
322 else if (sc->sc_keytype == ATH9K_CIPHER_AES_CCM) 322 else if (tx_info->control.hw_key->alg == ALG_CCMP)
323 txctl->keytype = ATH9K_KEY_TYPE_AES; 323 txctl->keytype = ATH9K_KEY_TYPE_AES;
324 } 324 }
325 325
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index da8b7433e3a6..a60ae86bd5c9 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -58,6 +58,7 @@ static struct usb_device_id usb_ids[] = {
58 { USB_DEVICE(0x0586, 0x3407), .driver_info = DEVICE_ZD1211 }, 58 { USB_DEVICE(0x0586, 0x3407), .driver_info = DEVICE_ZD1211 },
59 { USB_DEVICE(0x129b, 0x1666), .driver_info = DEVICE_ZD1211 }, 59 { USB_DEVICE(0x129b, 0x1666), .driver_info = DEVICE_ZD1211 },
60 { USB_DEVICE(0x157e, 0x300a), .driver_info = DEVICE_ZD1211 }, 60 { USB_DEVICE(0x157e, 0x300a), .driver_info = DEVICE_ZD1211 },
61 { USB_DEVICE(0x0105, 0x145f), .driver_info = DEVICE_ZD1211 },
61 /* ZD1211B */ 62 /* ZD1211B */
62 { USB_DEVICE(0x0ace, 0x1215), .driver_info = DEVICE_ZD1211B }, 63 { USB_DEVICE(0x0ace, 0x1215), .driver_info = DEVICE_ZD1211B },
63 { USB_DEVICE(0x157e, 0x300d), .driver_info = DEVICE_ZD1211B }, 64 { USB_DEVICE(0x157e, 0x300d), .driver_info = DEVICE_ZD1211B },
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 9c718583a237..77baff022f71 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -16,6 +16,7 @@
16 16
17 17
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/sched.h>
19#include <linux/pci.h> 20#include <linux/pci.h>
20#include <linux/stat.h> 21#include <linux/stat.h>
21#include <linux/topology.h> 22#include <linux/topology.h>
@@ -484,6 +485,21 @@ pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr,
484#endif /* HAVE_PCI_LEGACY */ 485#endif /* HAVE_PCI_LEGACY */
485 486
486#ifdef HAVE_PCI_MMAP 487#ifdef HAVE_PCI_MMAP
488
489static int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma)
490{
491 unsigned long nr, start, size;
492
493 nr = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
494 start = vma->vm_pgoff;
495 size = pci_resource_len(pdev, resno) >> PAGE_SHIFT;
496 if (start < size && size - start >= nr)
497 return 1;
498 WARN(1, "process \"%s\" tried to map 0x%08lx-0x%08lx on %s BAR %d (size 0x%08lx)\n",
499 current->comm, start, start+nr, pci_name(pdev), resno, size);
500 return 0;
501}
502
487/** 503/**
488 * pci_mmap_resource - map a PCI resource into user memory space 504 * pci_mmap_resource - map a PCI resource into user memory space
489 * @kobj: kobject for mapping 505 * @kobj: kobject for mapping
@@ -510,6 +526,9 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
510 if (i >= PCI_ROM_RESOURCE) 526 if (i >= PCI_ROM_RESOURCE)
511 return -ENODEV; 527 return -ENODEV;
512 528
529 if (!pci_mmap_fits(pdev, i, vma))
530 return -EINVAL;
531
513 /* pci_mmap_page_range() expects the same kind of entry as coming 532 /* pci_mmap_page_range() expects the same kind of entry as coming
514 * from /proc/bus/pci/ which is a "user visible" value. If this is 533 * from /proc/bus/pci/ which is a "user visible" value. If this is
515 * different from the resource itself, arch will do necessary fixup. 534 * different from the resource itself, arch will do necessary fixup.
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 9a7c9e1408a4..851f5b83cdbc 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -527,7 +527,7 @@ static int pcie_aspm_sanity_check(struct pci_dev *pdev)
527 */ 527 */
528 pci_read_config_dword(child_dev, child_pos + PCI_EXP_DEVCAP, 528 pci_read_config_dword(child_dev, child_pos + PCI_EXP_DEVCAP,
529 &reg32); 529 &reg32);
530 if (!(reg32 & PCI_EXP_DEVCAP_RBER && !aspm_force)) { 530 if (!(reg32 & PCI_EXP_DEVCAP_RBER) && !aspm_force) {
531 printk("Pre-1.1 PCIe device detected, " 531 printk("Pre-1.1 PCIe device detected, "
532 "disable ASPM for %s. It can be enabled forcedly" 532 "disable ASPM for %s. It can be enabled forcedly"
533 " with 'pcie_aspm=force'\n", pci_name(pdev)); 533 " with 'pcie_aspm=force'\n", pci_name(pdev));
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 3b3b5f178797..4edfc4731bd4 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -162,7 +162,7 @@ EXPORT_SYMBOL(pci_find_slot);
162 * time. 162 * time.
163 */ 163 */
164struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, 164struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device,
165 const struct pci_dev *from) 165 struct pci_dev *from)
166{ 166{
167 struct pci_dev *pdev; 167 struct pci_dev *pdev;
168 168
@@ -263,7 +263,7 @@ static int match_pci_dev_by_id(struct device *dev, void *data)
263 * this file. 263 * this file.
264 */ 264 */
265static struct pci_dev *pci_get_dev_by_id(const struct pci_device_id *id, 265static struct pci_dev *pci_get_dev_by_id(const struct pci_device_id *id,
266 const struct pci_dev *from) 266 struct pci_dev *from)
267{ 267{
268 struct device *dev; 268 struct device *dev;
269 struct device *dev_start = NULL; 269 struct device *dev_start = NULL;
@@ -303,7 +303,7 @@ static struct pci_dev *pci_get_dev_by_id(const struct pci_device_id *id,
303 */ 303 */
304struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device, 304struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
305 unsigned int ss_vendor, unsigned int ss_device, 305 unsigned int ss_vendor, unsigned int ss_device,
306 const struct pci_dev *from) 306 struct pci_dev *from)
307{ 307{
308 struct pci_dev *pdev; 308 struct pci_dev *pdev;
309 struct pci_device_id *id; 309 struct pci_device_id *id;
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 4174d9656e35..34c83d3ca0fa 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -427,6 +427,18 @@ static int pcmcia_device_probe(struct device * dev)
427 p_drv = to_pcmcia_drv(dev->driver); 427 p_drv = to_pcmcia_drv(dev->driver);
428 s = p_dev->socket; 428 s = p_dev->socket;
429 429
430 /* The PCMCIA code passes the match data in via dev->driver_data
431 * which is an ugly hack. Once the driver probe is called it may
432 * and often will overwrite the match data so we must save it first
433 *
434 * handle pseudo multifunction devices:
435 * there are at most two pseudo multifunction devices.
436 * if we're matching against the first, schedule a
437 * call which will then check whether there are two
438 * pseudo devices, and if not, add the second one.
439 */
440 did = p_dev->dev.driver_data;
441
430 ds_dbg(1, "trying to bind %s to %s\n", p_dev->dev.bus_id, 442 ds_dbg(1, "trying to bind %s to %s\n", p_dev->dev.bus_id,
431 p_drv->drv.name); 443 p_drv->drv.name);
432 444
@@ -455,21 +467,14 @@ static int pcmcia_device_probe(struct device * dev)
455 goto put_module; 467 goto put_module;
456 } 468 }
457 469
458 /* handle pseudo multifunction devices:
459 * there are at most two pseudo multifunction devices.
460 * if we're matching against the first, schedule a
461 * call which will then check whether there are two
462 * pseudo devices, and if not, add the second one.
463 */
464 did = p_dev->dev.driver_data;
465 if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) && 470 if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) &&
466 (p_dev->socket->device_count == 1) && (p_dev->device_no == 0)) 471 (p_dev->socket->device_count == 1) && (p_dev->device_no == 0))
467 pcmcia_add_device_later(p_dev->socket, 0); 472 pcmcia_add_device_later(p_dev->socket, 0);
468 473
469 put_module: 474put_module:
470 if (ret) 475 if (ret)
471 module_put(p_drv->owner); 476 module_put(p_drv->owner);
472 put_dev: 477put_dev:
473 if (ret) 478 if (ret)
474 put_device(dev); 479 put_device(dev);
475 return (ret); 480 return (ret);
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index c1b9ea34977b..98b9df7776e9 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -148,9 +148,13 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
148 acpi_status status; 148 acpi_status status;
149 struct pnp_dev *dev; 149 struct pnp_dev *dev;
150 150
151 /*
152 * If a PnPacpi device is not present , the device
153 * driver should not be loaded.
154 */
151 status = acpi_get_handle(device->handle, "_CRS", &temp); 155 status = acpi_get_handle(device->handle, "_CRS", &temp);
152 if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) || 156 if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) ||
153 is_exclusive_device(device)) 157 is_exclusive_device(device) || (!device->status.present))
154 return 0; 158 return 0;
155 159
156 dev = pnp_alloc_dev(&pnpacpi_protocol, num, acpi_device_hid(device)); 160 dev = pnp_alloc_dev(&pnpacpi_protocol, num, acpi_device_hid(device));
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index f118252f3a9f..52e2743b04ec 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -422,6 +422,12 @@ done:
422 return err; 422 return err;
423} 423}
424 424
425static int rtc_dev_fasync(int fd, struct file *file, int on)
426{
427 struct rtc_device *rtc = file->private_data;
428 return fasync_helper(fd, file, on, &rtc->async_queue);
429}
430
425static int rtc_dev_release(struct inode *inode, struct file *file) 431static int rtc_dev_release(struct inode *inode, struct file *file)
426{ 432{
427 struct rtc_device *rtc = file->private_data; 433 struct rtc_device *rtc = file->private_data;
@@ -434,16 +440,13 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
434 if (rtc->ops->release) 440 if (rtc->ops->release)
435 rtc->ops->release(rtc->dev.parent); 441 rtc->ops->release(rtc->dev.parent);
436 442
443 if (file->f_flags & FASYNC)
444 rtc_dev_fasync(-1, file, 0);
445
437 clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags); 446 clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags);
438 return 0; 447 return 0;
439} 448}
440 449
441static int rtc_dev_fasync(int fd, struct file *file, int on)
442{
443 struct rtc_device *rtc = file->private_data;
444 return fasync_helper(fd, file, on, &rtc->async_queue);
445}
446
447static const struct file_operations rtc_dev_fops = { 450static const struct file_operations rtc_dev_fops = {
448 .owner = THIS_MODULE, 451 .owner = THIS_MODULE,
449 .llseek = no_llseek, 452 .llseek = no_llseek,
diff --git a/drivers/s390/cio/qdio_setup.c b/drivers/s390/cio/qdio_setup.c
index 1679e2f91c94..a0b6b46e7466 100644
--- a/drivers/s390/cio/qdio_setup.c
+++ b/drivers/s390/cio/qdio_setup.c
@@ -447,51 +447,36 @@ void qdio_print_subchannel_info(struct qdio_irq *irq_ptr,
447{ 447{
448 char s[80]; 448 char s[80];
449 449
450 sprintf(s, "%s sc:%x ", cdev->dev.bus_id, irq_ptr->schid.sch_no); 450 sprintf(s, "qdio: %s ", dev_name(&cdev->dev));
451
452 switch (irq_ptr->qib.qfmt) { 451 switch (irq_ptr->qib.qfmt) {
453 case QDIO_QETH_QFMT: 452 case QDIO_QETH_QFMT:
454 sprintf(s + strlen(s), "OSADE "); 453 sprintf(s + strlen(s), "OSA ");
455 break; 454 break;
456 case QDIO_ZFCP_QFMT: 455 case QDIO_ZFCP_QFMT:
457 sprintf(s + strlen(s), "ZFCP "); 456 sprintf(s + strlen(s), "ZFCP ");
458 break; 457 break;
459 case QDIO_IQDIO_QFMT: 458 case QDIO_IQDIO_QFMT:
460 sprintf(s + strlen(s), "HiperSockets "); 459 sprintf(s + strlen(s), "HS ");
461 break; 460 break;
462 } 461 }
463 sprintf(s + strlen(s), "using: "); 462 sprintf(s + strlen(s), "on SC %x using ", irq_ptr->schid.sch_no);
464 463 sprintf(s + strlen(s), "AI:%d ", is_thinint_irq(irq_ptr));
465 if (!is_thinint_irq(irq_ptr)) 464 sprintf(s + strlen(s), "QEBSM:%d ", (irq_ptr->sch_token) ? 1 : 0);
466 sprintf(s + strlen(s), "no"); 465 sprintf(s + strlen(s), "PCI:%d ",
467 sprintf(s + strlen(s), "AdapterInterrupts "); 466 (irq_ptr->qib.ac & QIB_AC_OUTBOUND_PCI_SUPPORTED) ? 1 : 0);
468 if (!(irq_ptr->sch_token != 0)) 467 sprintf(s + strlen(s), "TDD:%d ", css_general_characteristics.aif_tdd);
469 sprintf(s + strlen(s), "no"); 468 sprintf(s + strlen(s), "SIGA:");
470 sprintf(s + strlen(s), "QEBSM "); 469 sprintf(s + strlen(s), "%s", (irq_ptr->siga_flag.input) ? "R" : " ");
471 if (!(irq_ptr->qib.ac & QIB_AC_OUTBOUND_PCI_SUPPORTED)) 470 sprintf(s + strlen(s), "%s", (irq_ptr->siga_flag.output) ? "W" : " ");
472 sprintf(s + strlen(s), "no"); 471 sprintf(s + strlen(s), "%s", (irq_ptr->siga_flag.sync) ? "S" : " ");
473 sprintf(s + strlen(s), "OutboundPCI "); 472 sprintf(s + strlen(s), "%s",
474 if (!css_general_characteristics.aif_tdd) 473 (!irq_ptr->siga_flag.no_sync_ti) ? "A" : " ");
475 sprintf(s + strlen(s), "no"); 474 sprintf(s + strlen(s), "%s",
476 sprintf(s + strlen(s), "TDD\n"); 475 (!irq_ptr->siga_flag.no_sync_out_ti) ? "O" : " ");
477 printk(KERN_INFO "qdio: %s", s); 476 sprintf(s + strlen(s), "%s",
478 477 (!irq_ptr->siga_flag.no_sync_out_pci) ? "P" : " ");
479 memset(s, 0, sizeof(s));
480 sprintf(s, "%s SIGA required: ", cdev->dev.bus_id);
481 if (irq_ptr->siga_flag.input)
482 sprintf(s + strlen(s), "Read ");
483 if (irq_ptr->siga_flag.output)
484 sprintf(s + strlen(s), "Write ");
485 if (irq_ptr->siga_flag.sync)
486 sprintf(s + strlen(s), "Sync ");
487 if (!irq_ptr->siga_flag.no_sync_ti)
488 sprintf(s + strlen(s), "SyncAI ");
489 if (!irq_ptr->siga_flag.no_sync_out_ti)
490 sprintf(s + strlen(s), "SyncOutAI ");
491 if (!irq_ptr->siga_flag.no_sync_out_pci)
492 sprintf(s + strlen(s), "SyncOutPCI");
493 sprintf(s + strlen(s), "\n"); 478 sprintf(s + strlen(s), "\n");
494 printk(KERN_INFO "qdio: %s", s); 479 printk(KERN_INFO "%s", s);
495} 480}
496 481
497int __init qdio_setup_init(void) 482int __init qdio_setup_init(void)
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 45a3b93eed57..bf41887cdd65 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1834,7 +1834,6 @@ clear_risc_ints:
1834 WRT_REG_WORD(&reg->isp.hccr, HCCR_CLR_HOST_INT); 1834 WRT_REG_WORD(&reg->isp.hccr, HCCR_CLR_HOST_INT);
1835 } 1835 }
1836 spin_unlock_irq(&ha->hardware_lock); 1836 spin_unlock_irq(&ha->hardware_lock);
1837 ha->isp_ops->enable_intrs(ha);
1838 1837
1839fail: 1838fail:
1840 return ret; 1839 return ret;
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 26afe44265c7..6d0f0e5f2827 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1740,6 +1740,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1740 if (ret) 1740 if (ret)
1741 goto probe_failed; 1741 goto probe_failed;
1742 1742
1743 ha->isp_ops->enable_intrs(ha);
1744
1743 scsi_scan_host(host); 1745 scsi_scan_host(host);
1744 1746
1745 qla2x00_alloc_sysfs_attr(ha); 1747 qla2x00_alloc_sysfs_attr(ha);
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index 4a1cf6377f6c..905350896725 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -914,6 +914,7 @@ static inline int load_cmd(struct scsi_cmnd *Cmnd, struct Command_Entry *cmd,
914 ds[i].d_count = sg_dma_len(s); 914 ds[i].d_count = sg_dma_len(s);
915 } 915 }
916 sg_count -= n; 916 sg_count -= n;
917 sg = s;
917 } 918 }
918 } else { 919 } else {
919 cmd->dataseg[0].d_base = 0; 920 cmd->dataseg[0].d_base = 0;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index ff5d56b3ee4d..62307bd794a9 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -852,7 +852,7 @@ static void scsi_end_bidi_request(struct scsi_cmnd *cmd)
852void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) 852void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
853{ 853{
854 int result = cmd->result; 854 int result = cmd->result;
855 int this_count = scsi_bufflen(cmd); 855 int this_count;
856 struct request_queue *q = cmd->device->request_queue; 856 struct request_queue *q = cmd->device->request_queue;
857 struct request *req = cmd->request; 857 struct request *req = cmd->request;
858 int error = 0; 858 int error = 0;
@@ -908,6 +908,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
908 */ 908 */
909 if (scsi_end_request(cmd, error, good_bytes, result == 0) == NULL) 909 if (scsi_end_request(cmd, error, good_bytes, result == 0) == NULL)
910 return; 910 return;
911 this_count = blk_rq_bytes(req);
911 912
912 /* good_bytes = 0, or (inclusive) there were leftovers and 913 /* good_bytes = 0, or (inclusive) there were leftovers and
913 * result = 0, so scsi_end_request couldn't retry. 914 * result = 0, so scsi_end_request couldn't retry.
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index 3a6da80b081c..61fb8b6d19af 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -131,7 +131,8 @@ struct atmel_uart_char {
131struct atmel_uart_port { 131struct atmel_uart_port {
132 struct uart_port uart; /* uart */ 132 struct uart_port uart; /* uart */
133 struct clk *clk; /* uart clock */ 133 struct clk *clk; /* uart clock */
134 unsigned short suspended; /* is port suspended? */ 134 int may_wakeup; /* cached value of device_may_wakeup for times we need to disable it */
135 u32 backup_imr; /* IMR saved during suspend */
135 int break_active; /* break being received */ 136 int break_active; /* break being received */
136 137
137 short use_dma_rx; /* enable PDC receiver */ 138 short use_dma_rx; /* enable PDC receiver */
@@ -984,8 +985,15 @@ static void atmel_serial_pm(struct uart_port *port, unsigned int state,
984 * This is called on uart_open() or a resume event. 985 * This is called on uart_open() or a resume event.
985 */ 986 */
986 clk_enable(atmel_port->clk); 987 clk_enable(atmel_port->clk);
988
989 /* re-enable interrupts if we disabled some on suspend */
990 UART_PUT_IER(port, atmel_port->backup_imr);
987 break; 991 break;
988 case 3: 992 case 3:
993 /* Back up the interrupt mask and disable all interrupts */
994 atmel_port->backup_imr = UART_GET_IMR(port);
995 UART_PUT_IDR(port, -1);
996
989 /* 997 /*
990 * Disable the peripheral clock for this serial port. 998 * Disable the peripheral clock for this serial port.
991 * This is called on uart_close() or a suspend event. 999 * This is called on uart_close() or a suspend event.
@@ -1475,13 +1483,12 @@ static int atmel_serial_suspend(struct platform_device *pdev,
1475 cpu_relax(); 1483 cpu_relax();
1476 } 1484 }
1477 1485
1478 if (device_may_wakeup(&pdev->dev) 1486 /* we can not wake up if we're running on slow clock */
1479 && !atmel_serial_clk_will_stop()) 1487 atmel_port->may_wakeup = device_may_wakeup(&pdev->dev);
1480 enable_irq_wake(port->irq); 1488 if (atmel_serial_clk_will_stop())
1481 else { 1489 device_set_wakeup_enable(&pdev->dev, 0);
1482 uart_suspend_port(&atmel_uart, port); 1490
1483 atmel_port->suspended = 1; 1491 uart_suspend_port(&atmel_uart, port);
1484 }
1485 1492
1486 return 0; 1493 return 0;
1487} 1494}
@@ -1491,11 +1498,8 @@ static int atmel_serial_resume(struct platform_device *pdev)
1491 struct uart_port *port = platform_get_drvdata(pdev); 1498 struct uart_port *port = platform_get_drvdata(pdev);
1492 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 1499 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
1493 1500
1494 if (atmel_port->suspended) { 1501 uart_resume_port(&atmel_uart, port);
1495 uart_resume_port(&atmel_uart, port); 1502 device_set_wakeup_enable(&pdev->dev, atmel_port->may_wakeup);
1496 atmel_port->suspended = 0;
1497 } else
1498 disable_irq_wake(port->irq);
1499 1503
1500 return 0; 1504 return 0;
1501} 1505}
@@ -1513,6 +1517,8 @@ static int __devinit atmel_serial_probe(struct platform_device *pdev)
1513 BUILD_BUG_ON(!is_power_of_2(ATMEL_SERIAL_RINGSIZE)); 1517 BUILD_BUG_ON(!is_power_of_2(ATMEL_SERIAL_RINGSIZE));
1514 1518
1515 port = &atmel_ports[pdev->id]; 1519 port = &atmel_ports[pdev->id];
1520 port->backup_imr = 0;
1521
1516 atmel_init_port(port, pdev); 1522 atmel_init_port(port, pdev);
1517 1523
1518 if (!atmel_use_dma_rx(&port->uart)) { 1524 if (!atmel_use_dma_rx(&port->uart)) {
diff --git a/drivers/spi/orion_spi.c b/drivers/spi/orion_spi.c
index c4eaacd6e553..b872bfaf4bd2 100644
--- a/drivers/spi/orion_spi.c
+++ b/drivers/spi/orion_spi.c
@@ -427,7 +427,7 @@ static int orion_spi_transfer(struct spi_device *spi, struct spi_message *m)
427 goto msg_rejected; 427 goto msg_rejected;
428 } 428 }
429 429
430 if (t->speed_hz < orion_spi->min_speed) { 430 if (t->speed_hz && t->speed_hz < orion_spi->min_speed) {
431 dev_err(&spi->dev, 431 dev_err(&spi->dev,
432 "message rejected : " 432 "message rejected : "
433 "device min speed (%d Hz) exceeds " 433 "device min speed (%d Hz) exceeds "
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 0e53354c1cfe..d47d3636227f 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -49,7 +49,7 @@ MODULE_ALIAS("platform:pxa2xx-spi");
49 49
50#define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR) 50#define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR)
51#define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK) 51#define RESET_DMA_CHANNEL (DCSR_NODESC | DMA_INT_MASK)
52#define IS_DMA_ALIGNED(x) (((x) & 0x07) == 0) 52#define IS_DMA_ALIGNED(x) ((((u32)(x)) & 0x07) == 0)
53#define MAX_DMA_LEN 8191 53#define MAX_DMA_LEN 8191
54 54
55/* 55/*
@@ -896,7 +896,7 @@ static void pump_transfers(unsigned long data)
896 || transfer->rx_dma || transfer->tx_dma) { 896 || transfer->rx_dma || transfer->tx_dma) {
897 dev_err(&drv_data->pdev->dev, 897 dev_err(&drv_data->pdev->dev,
898 "pump_transfers: mapped transfer length " 898 "pump_transfers: mapped transfer length "
899 "of %lu is greater than %d\n", 899 "of %u is greater than %d\n",
900 transfer->len, MAX_DMA_LEN); 900 transfer->len, MAX_DMA_LEN);
901 message->status = -EINVAL; 901 message->status = -EINVAL;
902 giveback(drv_data); 902 giveback(drv_data);
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index 87ab2443e66d..0ffabf5c0b60 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -471,6 +471,7 @@ static int ssb_devices_register(struct ssb_bus *bus)
471#endif 471#endif
472 break; 472 break;
473 case SSB_BUSTYPE_SSB: 473 case SSB_BUSTYPE_SSB:
474 dev->dma_mask = &dev->coherent_dma_mask;
474 break; 475 break;
475 } 476 }
476 477
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 8abd4e59bf4a..8ab389dca2b9 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1876,7 +1876,8 @@ int usb_add_hcd(struct usb_hcd *hcd,
1876 * with IRQF_SHARED. As usb_hcd_irq() will always disable 1876 * with IRQF_SHARED. As usb_hcd_irq() will always disable
1877 * interrupts we can remove it here. 1877 * interrupts we can remove it here.
1878 */ 1878 */
1879 irqflags &= ~IRQF_DISABLED; 1879 if (irqflags & IRQF_SHARED)
1880 irqflags &= ~IRQF_DISABLED;
1880 1881
1881 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", 1882 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d",
1882 hcd->driver->description, hcd->self.busnum); 1883 hcd->driver->description, hcd->self.busnum);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 6a5cb018383d..d99963873e37 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2683,35 +2683,17 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2683 USB_PORT_STAT_C_ENABLE); 2683 USB_PORT_STAT_C_ENABLE);
2684#endif 2684#endif
2685 2685
2686 /* Try to use the debounce delay for protection against
2687 * port-enable changes caused, for example, by EMI.
2688 */
2689 if (portchange & (USB_PORT_STAT_C_CONNECTION |
2690 USB_PORT_STAT_C_ENABLE)) {
2691 status = hub_port_debounce(hub, port1);
2692 if (status < 0) {
2693 if (printk_ratelimit())
2694 dev_err (hub_dev, "connect-debounce failed, "
2695 "port %d disabled\n", port1);
2696 portstatus &= ~USB_PORT_STAT_CONNECTION;
2697 } else {
2698 portstatus = status;
2699 }
2700 }
2701
2702 /* Try to resuscitate an existing device */ 2686 /* Try to resuscitate an existing device */
2703 udev = hdev->children[port1-1]; 2687 udev = hdev->children[port1-1];
2704 if ((portstatus & USB_PORT_STAT_CONNECTION) && udev && 2688 if ((portstatus & USB_PORT_STAT_CONNECTION) && udev &&
2705 udev->state != USB_STATE_NOTATTACHED) { 2689 udev->state != USB_STATE_NOTATTACHED) {
2706
2707 usb_lock_device(udev); 2690 usb_lock_device(udev);
2708 if (portstatus & USB_PORT_STAT_ENABLE) { 2691 if (portstatus & USB_PORT_STAT_ENABLE) {
2709 status = 0; /* Nothing to do */ 2692 status = 0; /* Nothing to do */
2710 } else if (!udev->persist_enabled) {
2711 status = -ENODEV; /* Mustn't resuscitate */
2712 2693
2713#ifdef CONFIG_USB_SUSPEND 2694#ifdef CONFIG_USB_SUSPEND
2714 } else if (udev->state == USB_STATE_SUSPENDED) { 2695 } else if (udev->state == USB_STATE_SUSPENDED &&
2696 udev->persist_enabled) {
2715 /* For a suspended device, treat this as a 2697 /* For a suspended device, treat this as a
2716 * remote wakeup event. 2698 * remote wakeup event.
2717 */ 2699 */
@@ -2726,7 +2708,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2726#endif 2708#endif
2727 2709
2728 } else { 2710 } else {
2729 status = usb_reset_device(udev); 2711 status = -ENODEV; /* Don't resuscitate */
2730 } 2712 }
2731 usb_unlock_device(udev); 2713 usb_unlock_device(udev);
2732 2714
@@ -2741,6 +2723,19 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2741 usb_disconnect(&hdev->children[port1-1]); 2723 usb_disconnect(&hdev->children[port1-1]);
2742 clear_bit(port1, hub->change_bits); 2724 clear_bit(port1, hub->change_bits);
2743 2725
2726 if (portchange & (USB_PORT_STAT_C_CONNECTION |
2727 USB_PORT_STAT_C_ENABLE)) {
2728 status = hub_port_debounce(hub, port1);
2729 if (status < 0) {
2730 if (printk_ratelimit())
2731 dev_err(hub_dev, "connect-debounce failed, "
2732 "port %d disabled\n", port1);
2733 portstatus &= ~USB_PORT_STAT_CONNECTION;
2734 } else {
2735 portstatus = status;
2736 }
2737 }
2738
2744 /* Return now if debouncing failed or nothing is connected */ 2739 /* Return now if debouncing failed or nothing is connected */
2745 if (!(portstatus & USB_PORT_STAT_CONNECTION)) { 2740 if (!(portstatus & USB_PORT_STAT_CONNECTION)) {
2746 2741
@@ -2748,7 +2743,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2748 if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2 2743 if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2
2749 && !(portstatus & (1 << USB_PORT_FEAT_POWER))) 2744 && !(portstatus & (1 << USB_PORT_FEAT_POWER)))
2750 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); 2745 set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
2751 2746
2752 if (portstatus & USB_PORT_STAT_ENABLE) 2747 if (portstatus & USB_PORT_STAT_ENABLE)
2753 goto done; 2748 goto done;
2754 return; 2749 return;
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c
index 1cfccf102a2d..45ad556169f1 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.c
+++ b/drivers/usb/gadget/fsl_usb2_udc.c
@@ -223,7 +223,7 @@ static int dr_controller_setup(struct fsl_udc *udc)
223 fsl_writel(tmp, &dr_regs->endpointlistaddr); 223 fsl_writel(tmp, &dr_regs->endpointlistaddr);
224 224
225 VDBG("vir[qh_base] is %p phy[qh_base] is 0x%8x reg is 0x%8x", 225 VDBG("vir[qh_base] is %p phy[qh_base] is 0x%8x reg is 0x%8x",
226 (int)udc->ep_qh, (int)tmp, 226 udc->ep_qh, (int)tmp,
227 fsl_readl(&dr_regs->endpointlistaddr)); 227 fsl_readl(&dr_regs->endpointlistaddr));
228 228
229 /* Config PHY interface */ 229 /* Config PHY interface */
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 574c53831a05..bb54cca4c543 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -787,7 +787,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel)
787 omap_set_dma_dest_params(ep->lch, 787 omap_set_dma_dest_params(ep->lch,
788 OMAP_DMA_PORT_TIPB, 788 OMAP_DMA_PORT_TIPB,
789 OMAP_DMA_AMODE_CONSTANT, 789 OMAP_DMA_AMODE_CONSTANT,
790 (unsigned long) io_v2p(UDC_DATA_DMA), 790 UDC_DATA_DMA,
791 0, 0); 791 0, 0);
792 } 792 }
793 } else { 793 } else {
@@ -804,7 +804,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel)
804 omap_set_dma_src_params(ep->lch, 804 omap_set_dma_src_params(ep->lch,
805 OMAP_DMA_PORT_TIPB, 805 OMAP_DMA_PORT_TIPB,
806 OMAP_DMA_AMODE_CONSTANT, 806 OMAP_DMA_AMODE_CONSTANT,
807 (unsigned long) io_v2p(UDC_DATA_DMA), 807 UDC_DATA_DMA,
808 0, 0); 808 0, 0);
809 /* EMIFF or SDRC */ 809 /* EMIFF or SDRC */
810 omap_set_dma_dest_burst_mode(ep->lch, 810 omap_set_dma_dest_burst_mode(ep->lch,
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index d9d53f289caf..8409e0705d63 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -145,16 +145,6 @@ static int handshake (struct ehci_hcd *ehci, void __iomem *ptr,
145 return -ETIMEDOUT; 145 return -ETIMEDOUT;
146} 146}
147 147
148static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr,
149 u32 mask, u32 done, int usec)
150{
151 int error = handshake(ehci, ptr, mask, done, usec);
152 if (error)
153 ehci_to_hcd(ehci)->state = HC_STATE_HALT;
154
155 return error;
156}
157
158/* force HC to halt state from unknown (EHCI spec section 2.3) */ 148/* force HC to halt state from unknown (EHCI spec section 2.3) */
159static int ehci_halt (struct ehci_hcd *ehci) 149static int ehci_halt (struct ehci_hcd *ehci)
160{ 150{
@@ -173,6 +163,22 @@ static int ehci_halt (struct ehci_hcd *ehci)
173 STS_HALT, STS_HALT, 16 * 125); 163 STS_HALT, STS_HALT, 16 * 125);
174} 164}
175 165
166static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr,
167 u32 mask, u32 done, int usec)
168{
169 int error;
170
171 error = handshake(ehci, ptr, mask, done, usec);
172 if (error) {
173 ehci_halt(ehci);
174 ehci_to_hcd(ehci)->state = HC_STATE_HALT;
175 ehci_err(ehci, "force halt; handhake %p %08x %08x -> %d\n",
176 ptr, mask, done, error);
177 }
178
179 return error;
180}
181
176/* put TDI/ARC silicon into EHCI mode */ 182/* put TDI/ARC silicon into EHCI mode */
177static void tdi_reset (struct ehci_hcd *ehci) 183static void tdi_reset (struct ehci_hcd *ehci)
178{ 184{
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index b7853c8bac0f..4a0c5a78b2ed 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -437,6 +437,9 @@ static int enable_periodic (struct ehci_hcd *ehci)
437 u32 cmd; 437 u32 cmd;
438 int status; 438 int status;
439 439
440 if (ehci->periodic_sched++)
441 return 0;
442
440 /* did clearing PSE did take effect yet? 443 /* did clearing PSE did take effect yet?
441 * takes effect only at frame boundaries... 444 * takes effect only at frame boundaries...
442 */ 445 */
@@ -461,6 +464,9 @@ static int disable_periodic (struct ehci_hcd *ehci)
461 u32 cmd; 464 u32 cmd;
462 int status; 465 int status;
463 466
467 if (--ehci->periodic_sched)
468 return 0;
469
464 /* did setting PSE not take effect yet? 470 /* did setting PSE not take effect yet?
465 * takes effect only at frame boundaries... 471 * takes effect only at frame boundaries...
466 */ 472 */
@@ -544,13 +550,10 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
544 : (qh->usecs * 8); 550 : (qh->usecs * 8);
545 551
546 /* maybe enable periodic schedule processing */ 552 /* maybe enable periodic schedule processing */
547 if (!ehci->periodic_sched++) 553 return enable_periodic(ehci);
548 return enable_periodic (ehci);
549
550 return 0;
551} 554}
552 555
553static void qh_unlink_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh) 556static int qh_unlink_periodic(struct ehci_hcd *ehci, struct ehci_qh *qh)
554{ 557{
555 unsigned i; 558 unsigned i;
556 unsigned period; 559 unsigned period;
@@ -586,9 +589,7 @@ static void qh_unlink_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
586 qh_put (qh); 589 qh_put (qh);
587 590
588 /* maybe turn off periodic schedule */ 591 /* maybe turn off periodic schedule */
589 ehci->periodic_sched--; 592 return disable_periodic(ehci);
590 if (!ehci->periodic_sched)
591 (void) disable_periodic (ehci);
592} 593}
593 594
594static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh) 595static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh)
@@ -1562,9 +1563,7 @@ itd_link_urb (
1562 urb->hcpriv = NULL; 1563 urb->hcpriv = NULL;
1563 1564
1564 timer_action (ehci, TIMER_IO_WATCHDOG); 1565 timer_action (ehci, TIMER_IO_WATCHDOG);
1565 if (unlikely (!ehci->periodic_sched++)) 1566 return enable_periodic(ehci);
1566 return enable_periodic (ehci);
1567 return 0;
1568} 1567}
1569 1568
1570#define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR) 1569#define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR)
@@ -1642,7 +1641,7 @@ itd_complete (
1642 ehci_urb_done(ehci, urb, 0); 1641 ehci_urb_done(ehci, urb, 0);
1643 retval = true; 1642 retval = true;
1644 urb = NULL; 1643 urb = NULL;
1645 ehci->periodic_sched--; 1644 (void) disable_periodic(ehci);
1646 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; 1645 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--;
1647 1646
1648 if (unlikely (list_empty (&stream->td_list))) { 1647 if (unlikely (list_empty (&stream->td_list))) {
@@ -1951,9 +1950,7 @@ sitd_link_urb (
1951 urb->hcpriv = NULL; 1950 urb->hcpriv = NULL;
1952 1951
1953 timer_action (ehci, TIMER_IO_WATCHDOG); 1952 timer_action (ehci, TIMER_IO_WATCHDOG);
1954 if (!ehci->periodic_sched++) 1953 return enable_periodic(ehci);
1955 return enable_periodic (ehci);
1956 return 0;
1957} 1954}
1958 1955
1959/*-------------------------------------------------------------------------*/ 1956/*-------------------------------------------------------------------------*/
@@ -2019,7 +2016,7 @@ sitd_complete (
2019 ehci_urb_done(ehci, urb, 0); 2016 ehci_urb_done(ehci, urb, 0);
2020 retval = true; 2017 retval = true;
2021 urb = NULL; 2018 urb = NULL;
2022 ehci->periodic_sched--; 2019 (void) disable_periodic(ehci);
2023 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; 2020 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--;
2024 2021
2025 if (list_empty (&stream->td_list)) { 2022 if (list_empty (&stream->td_list)) {
@@ -2243,8 +2240,7 @@ restart:
2243 if (unlikely (modified)) { 2240 if (unlikely (modified)) {
2244 if (likely(ehci->periodic_sched > 0)) 2241 if (likely(ehci->periodic_sched > 0))
2245 goto restart; 2242 goto restart;
2246 /* maybe we can short-circuit this scan! */ 2243 /* short-circuit this scan */
2247 disable_periodic(ehci);
2248 now_uframe = clock; 2244 now_uframe = clock;
2249 break; 2245 break;
2250 } 2246 }
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index a0017486ad4e..58b2b8fc9439 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -9,6 +9,7 @@ comment "Enable Host or Gadget support to see Inventra options"
9# (M)HDRC = (Multipoint) Highspeed Dual-Role Controller 9# (M)HDRC = (Multipoint) Highspeed Dual-Role Controller
10config USB_MUSB_HDRC 10config USB_MUSB_HDRC
11 depends on (USB || USB_GADGET) && HAVE_CLK 11 depends on (USB || USB_GADGET) && HAVE_CLK
12 depends on !SUPERH
12 select TWL4030_USB if MACH_OMAP_3430SDP 13 select TWL4030_USB if MACH_OMAP_3430SDP
13 tristate 'Inventra Highspeed Dual Role Controller (TI, ...)' 14 tristate 'Inventra Highspeed Dual Role Controller (TI, ...)'
14 help 15 help
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index c5b8f0296fcf..128e949db47c 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -100,8 +100,8 @@
100#include <linux/io.h> 100#include <linux/io.h>
101 101
102#ifdef CONFIG_ARM 102#ifdef CONFIG_ARM
103#include <asm/arch/hardware.h> 103#include <mach/hardware.h>
104#include <asm/arch/memory.h> 104#include <mach/memory.h>
105#include <asm/mach-types.h> 105#include <asm/mach-types.h>
106#endif 106#endif
107 107
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 298b22e6ad0d..9d2dcb121c5e 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -35,8 +35,8 @@
35#include <linux/io.h> 35#include <linux/io.h>
36 36
37#include <asm/mach-types.h> 37#include <asm/mach-types.h>
38#include <asm/arch/hardware.h> 38#include <mach/hardware.h>
39#include <asm/arch/mux.h> 39#include <mach/mux.h>
40 40
41#include "musb_core.h" 41#include "musb_core.h"
42#include "omap2430.h" 42#include "omap2430.h"
diff --git a/drivers/usb/musb/omap2430.h b/drivers/usb/musb/omap2430.h
index 786a62071f72..dc7670718cd2 100644
--- a/drivers/usb/musb/omap2430.h
+++ b/drivers/usb/musb/omap2430.h
@@ -11,8 +11,8 @@
11#define __MUSB_OMAP243X_H__ 11#define __MUSB_OMAP243X_H__
12 12
13#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430) 13#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
14#include <asm/arch/hardware.h> 14#include <mach/hardware.h>
15#include <asm/arch/usb.h> 15#include <mach/usb.h>
16 16
17/* 17/*
18 * OMAP2430-specific definitions 18 * OMAP2430-specific definitions
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index 442cba69cce5..1279553381e3 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -72,6 +72,7 @@ static struct usb_device_id id_table [] = {
72 { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */ 72 { USB_DEVICE(0x10C4, 0x80CA) }, /* Degree Controls Inc */
73 { USB_DEVICE(0x10C4, 0x80DD) }, /* Tracient RFID */ 73 { USB_DEVICE(0x10C4, 0x80DD) }, /* Tracient RFID */
74 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */ 74 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */
75 { USB_DEVICE(0x10C4, 0x8115) }, /* Arygon NFC/Mifare Reader */
75 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */ 76 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */
76 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */ 77 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */
77 { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */ 78 { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */
@@ -83,6 +84,7 @@ static struct usb_device_id id_table [] = {
83 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */ 84 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */
84 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ 85 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
85 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */ 86 { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */
87 { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
86 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 88 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
87 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ 89 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
88 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ 90 { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */
@@ -93,6 +95,7 @@ static struct usb_device_id id_table [] = {
93 { USB_DEVICE(0x13AD, 0x9999) }, /* Baltech card reader */ 95 { USB_DEVICE(0x13AD, 0x9999) }, /* Baltech card reader */
94 { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */ 96 { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */
95 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ 97 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */
98 { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
96 { } /* Terminating Entry */ 99 { } /* Terminating Entry */
97}; 100};
98 101
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 984f6eff4c47..3dc93b542b30 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -654,6 +654,9 @@ static struct usb_device_id id_table_combined [] = {
654 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 654 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
655 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) }, 655 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) },
656 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) }, 656 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) },
657 { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) },
658 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) },
659 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) },
657 { }, /* Optional parameter entry */ 660 { }, /* Optional parameter entry */
658 { } /* Terminating entry */ 661 { } /* Terminating entry */
659}; 662};
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 382265bba969..8a5b6df3a976 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -750,6 +750,7 @@
750 750
751#define PAPOUCH_VID 0x5050 /* Vendor ID */ 751#define PAPOUCH_VID 0x5050 /* Vendor ID */
752#define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */ 752#define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */
753#define PAPOUCH_QUIDO4x4_PID 0x0900 /* Quido 4/4 Module */
753 754
754/* 755/*
755 * ACG Identification Technologies GmbH products (http://www.acg.de/). 756 * ACG Identification Technologies GmbH products (http://www.acg.de/).
@@ -838,6 +839,10 @@
838/* Rig Expert Ukraine devices */ 839/* Rig Expert Ukraine devices */
839#define FTDI_REU_TINY_PID 0xED22 /* RigExpert Tiny */ 840#define FTDI_REU_TINY_PID 0xED22 /* RigExpert Tiny */
840 841
842/* Domintell products http://www.domintell.com */
843#define FTDI_DOMINTELL_DGQG_PID 0xEF50 /* Master */
844#define FTDI_DOMINTELL_DUSB_PID 0xEF51 /* DUSB01 module */
845
841/* Commands */ 846/* Commands */
842#define FTDI_SIO_RESET 0 /* Reset the port */ 847#define FTDI_SIO_RESET 0 /* Reset the port */
843#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 848#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 9f9cd36455f4..73f8277f88f2 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -218,6 +218,7 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
218/* ZTE PRODUCTS */ 218/* ZTE PRODUCTS */
219#define ZTE_VENDOR_ID 0x19d2 219#define ZTE_VENDOR_ID 0x19d2
220#define ZTE_PRODUCT_MF628 0x0015 220#define ZTE_PRODUCT_MF628 0x0015
221#define ZTE_PRODUCT_CDMA_TECH 0xfffe
221 222
222static struct usb_device_id option_ids[] = { 223static struct usb_device_id option_ids[] = {
223 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 224 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
@@ -347,6 +348,7 @@ static struct usb_device_id option_ids[] = {
347 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ 348 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */
348 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, 349 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) },
349 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, 350 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) },
351 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) },
350 { } /* Terminating entry */ 352 { } /* Terminating entry */
351}; 353};
352MODULE_DEVICE_TABLE(usb, option_ids); 354MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 706033753adb..ea1a103c99be 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -14,7 +14,7 @@
14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org> 14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
15*/ 15*/
16 16
17#define DRIVER_VERSION "v.1.2.13a" 17#define DRIVER_VERSION "v.1.3.2"
18#define DRIVER_AUTHOR "Kevin Lloyd <klloyd@sierrawireless.com>" 18#define DRIVER_AUTHOR "Kevin Lloyd <klloyd@sierrawireless.com>"
19#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" 19#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
20 20
@@ -30,9 +30,6 @@
30 30
31#define SWIMS_USB_REQUEST_SetPower 0x00 31#define SWIMS_USB_REQUEST_SetPower 0x00
32#define SWIMS_USB_REQUEST_SetNmea 0x07 32#define SWIMS_USB_REQUEST_SetNmea 0x07
33#define SWIMS_USB_REQUEST_SetMode 0x0B
34#define SWIMS_USB_REQUEST_GetSwocInfo 0x0A
35#define SWIMS_SET_MODE_Modem 0x0001
36 33
37/* per port private data */ 34/* per port private data */
38#define N_IN_URB 4 35#define N_IN_URB 4
@@ -163,7 +160,7 @@ static struct usb_device_id id_table [] = {
163 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */ 160 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
164 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ 161 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
165 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ 162 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
166 { USB_DEVICE(0x0f30, 0x1b1d) }, /* Sierra Wireless MC5720 */ 163 { USB_DEVICE(0x03f0, 0x1b1d) }, /* HP ev2200 a.k.a MC5720 */
167 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 164 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
168 { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */ 165 { USB_DEVICE(0x1199, 0x0024) }, /* Sierra Wireless MC5727 */
169 { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */ 166 { USB_DEVICE(0x1199, 0x0220) }, /* Sierra Wireless MC5725 */
@@ -175,6 +172,8 @@ static struct usb_device_id id_table [] = {
175 /* Sierra Wireless Device */ 172 /* Sierra Wireless Device */
176 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) }, 173 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x0025, 0xFF, 0xFF, 0xFF) },
177 { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless Device */ 174 { USB_DEVICE(0x1199, 0x0026) }, /* Sierra Wireless Device */
175 { USB_DEVICE(0x1199, 0x0027) }, /* Sierra Wireless Device */
176 { USB_DEVICE(0x1199, 0x0028) }, /* Sierra Wireless Device */
178 177
179 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 178 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
180 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */ 179 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 */
@@ -187,6 +186,7 @@ static struct usb_device_id id_table [] = {
187 { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */ 186 { USB_DEVICE(0x1199, 0x6821) }, /* Sierra Wireless AirCard 875U */
188 { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */ 187 { USB_DEVICE(0x1199, 0x6832) }, /* Sierra Wireless MC8780 */
189 { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */ 188 { USB_DEVICE(0x1199, 0x6833) }, /* Sierra Wireless MC8781 */
189 { USB_DEVICE(0x1199, 0x683A) }, /* Sierra Wireless MC8785 */
190 { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */ 190 { USB_DEVICE(0x1199, 0x683B) }, /* Sierra Wireless MC8785 Composite */
191 { USB_DEVICE(0x1199, 0x683C) }, /* Sierra Wireless MC8790 */ 191 { USB_DEVICE(0x1199, 0x683C) }, /* Sierra Wireless MC8790 */
192 { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8790 */ 192 { USB_DEVICE(0x1199, 0x683D) }, /* Sierra Wireless MC8790 */
@@ -204,6 +204,8 @@ static struct usb_device_id id_table [] = {
204 /* Sierra Wireless Device */ 204 /* Sierra Wireless Device */
205 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)}, 205 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6890, 0xFF, 0xFF, 0xFF)},
206 /* Sierra Wireless Device */ 206 /* Sierra Wireless Device */
207 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6891, 0xFF, 0xFF, 0xFF)},
208 /* Sierra Wireless Device */
207 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)}, 209 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x6892, 0xFF, 0xFF, 0xFF)},
208 210
209 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ 211 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index e39c779e4160..9a3e495c769c 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -1744,7 +1744,7 @@ static int ti_download_firmware(struct ti_device *tdev, int type)
1744 if (buffer) { 1744 if (buffer) {
1745 memcpy(buffer, fw_p->data, fw_p->size); 1745 memcpy(buffer, fw_p->data, fw_p->size);
1746 memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size); 1746 memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size);
1747 ti_do_download(dev, pipe, buffer, fw_p->size); 1747 status = ti_do_download(dev, pipe, buffer, fw_p->size);
1748 kfree(buffer); 1748 kfree(buffer);
1749 } 1749 }
1750 release_firmware(fw_p); 1750 release_firmware(fw_p);
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index b157c48e8b78..4f7f9e3ae0a4 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -733,7 +733,9 @@ int usb_serial_probe(struct usb_interface *interface,
733 ((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) && 733 ((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) &&
734 (le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID)) || 734 (le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID)) ||
735 ((le16_to_cpu(dev->descriptor.idVendor) == ALCOR_VENDOR_ID) && 735 ((le16_to_cpu(dev->descriptor.idVendor) == ALCOR_VENDOR_ID) &&
736 (le16_to_cpu(dev->descriptor.idProduct) == ALCOR_PRODUCT_ID))) { 736 (le16_to_cpu(dev->descriptor.idProduct) == ALCOR_PRODUCT_ID)) ||
737 ((le16_to_cpu(dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) &&
738 (le16_to_cpu(dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_EF81))) {
737 if (interface != dev->actconfig->interface[0]) { 739 if (interface != dev->actconfig->interface[0]) {
738 /* check out the endpoints of the other interface*/ 740 /* check out the endpoints of the other interface*/
739 iface_desc = dev->actconfig->interface[0]->cur_altsetting; 741 iface_desc = dev->actconfig->interface[0]->cur_altsetting;
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index c76034672c18..3d9249632ae1 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -146,18 +146,6 @@ config USB_STORAGE_KARMA
146 on the resulting scsi device node returns the Karma to normal 146 on the resulting scsi device node returns the Karma to normal
147 operation. 147 operation.
148 148
149config USB_STORAGE_SIERRA
150 bool "Sierra Wireless TRU-Install Feature Support"
151 depends on USB_STORAGE
152 help
153 Say Y here to include additional code to support Sierra Wireless
154 products with the TRU-Install feature (e.g., AC597E, AC881U).
155
156 This code switches the Sierra Wireless device from being in
157 Mass Storage mode to Modem mode. It also has the ability to
158 support host software upgrades should full Linux support be added
159 to TRU-Install.
160
161config USB_STORAGE_CYPRESS_ATACB 149config USB_STORAGE_CYPRESS_ATACB
162 bool "SAT emulation on Cypress USB/ATA Bridge with ATACB" 150 bool "SAT emulation on Cypress USB/ATA Bridge with ATACB"
163 depends on USB_STORAGE 151 depends on USB_STORAGE
diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
index bc3415b475c9..7f8beb5366ae 100644
--- a/drivers/usb/storage/Makefile
+++ b/drivers/usb/storage/Makefile
@@ -21,11 +21,10 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o
21usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o 21usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o
22usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o 22usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o
23usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o 23usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o
24usb-storage-obj-$(CONFIG_USB_STORAGE_SIERRA) += sierra_ms.o
25usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o 24usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o
26 25
27usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ 26usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \
28 initializers.o $(usb-storage-obj-y) 27 initializers.o sierra_ms.o $(usb-storage-obj-y)
29 28
30ifneq ($(CONFIG_USB_LIBUSUAL),) 29ifneq ($(CONFIG_USB_LIBUSUAL),)
31 obj-$(CONFIG_USB) += libusual.o 30 obj-$(CONFIG_USB) += libusual.o
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index ba412e68d474..cd155475cb6e 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -160,6 +160,13 @@ UNUSUAL_DEV( 0x0421, 0x0019, 0x0592, 0x0592,
160 US_SC_DEVICE, US_PR_DEVICE, NULL, 160 US_SC_DEVICE, US_PR_DEVICE, NULL,
161 US_FL_MAX_SECTORS_64 ), 161 US_FL_MAX_SECTORS_64 ),
162 162
163/* Reported by Filip Joelsson <filip@blueturtle.nu> */
164UNUSUAL_DEV( 0x0421, 0x005d, 0x0001, 0x0600,
165 "Nokia",
166 "Nokia 3110c",
167 US_SC_DEVICE, US_PR_DEVICE, NULL,
168 US_FL_FIX_CAPACITY ),
169
163/* Reported by Mario Rettig <mariorettig@web.de> */ 170/* Reported by Mario Rettig <mariorettig@web.de> */
164UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100, 171UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100,
165 "Nokia", 172 "Nokia",
@@ -232,6 +239,20 @@ UNUSUAL_DEV( 0x0421, 0x04b9, 0x0551, 0x0551,
232 US_SC_DEVICE, US_PR_DEVICE, NULL, 239 US_SC_DEVICE, US_PR_DEVICE, NULL,
233 US_FL_FIX_CAPACITY ), 240 US_FL_FIX_CAPACITY ),
234 241
242/* Reported by Richard Nauber <RichardNauber@web.de> */
243UNUSUAL_DEV( 0x0421, 0x04fa, 0x0601, 0x0601,
244 "Nokia",
245 "6300",
246 US_SC_DEVICE, US_PR_DEVICE, NULL,
247 US_FL_FIX_CAPACITY ),
248
249/* Patch for Nokia 5310 capacity */
250UNUSUAL_DEV( 0x0421, 0x006a, 0x0000, 0x0591,
251 "Nokia",
252 "5310",
253 US_SC_DEVICE, US_PR_DEVICE, NULL,
254 US_FL_FIX_CAPACITY ),
255
235/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ 256/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */
236UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, 257UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210,
237 "SMSC", 258 "SMSC",
@@ -987,6 +1008,13 @@ UNUSUAL_DEV( 0x069b, 0x3004, 0x0001, 0x0001,
987 US_SC_DEVICE, US_PR_DEVICE, NULL, 1008 US_SC_DEVICE, US_PR_DEVICE, NULL,
988 US_FL_FIX_CAPACITY ), 1009 US_FL_FIX_CAPACITY ),
989 1010
1011/* Reported by Adrian Pilchowiec <adi1981@epf.pl> */
1012UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000,
1013 "RockChip",
1014 "MP3",
1015 US_SC_DEVICE, US_PR_DEVICE, NULL,
1016 US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64),
1017
990/* Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com> 1018/* Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com>
991 * This USB MP3/AVI player device fails and disconnects if more than 128 1019 * This USB MP3/AVI player device fails and disconnects if more than 128
992 * sectors (64kB) are read/written in a single command, and may be present 1020 * sectors (64kB) are read/written in a single command, and may be present
@@ -1576,7 +1604,6 @@ UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100,
1576 US_SC_DEVICE, US_PR_DEVICE, NULL, 1604 US_SC_DEVICE, US_PR_DEVICE, NULL,
1577 0), 1605 0),
1578 1606
1579#ifdef CONFIG_USB_STORAGE_SIERRA
1580/* Reported by Kevin Lloyd <linux@sierrawireless.com> 1607/* Reported by Kevin Lloyd <linux@sierrawireless.com>
1581 * Entry is needed for the initializer function override, 1608 * Entry is needed for the initializer function override,
1582 * which instructs the device to load as a modem 1609 * which instructs the device to load as a modem
@@ -1587,7 +1614,6 @@ UNUSUAL_DEV( 0x1199, 0x0fff, 0x0000, 0x9999,
1587 "USB MMC Storage", 1614 "USB MMC Storage",
1588 US_SC_DEVICE, US_PR_DEVICE, sierra_ms_init, 1615 US_SC_DEVICE, US_PR_DEVICE, sierra_ms_init,
1589 0), 1616 0),
1590#endif
1591 1617
1592/* Reported by Jaco Kroon <jaco@kroon.co.za> 1618/* Reported by Jaco Kroon <jaco@kroon.co.za>
1593 * The usb-storage module found on the Digitech GNX4 (and supposedly other 1619 * The usb-storage module found on the Digitech GNX4 (and supposedly other
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 73679aa506de..27016fd2cad1 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -102,9 +102,7 @@
102#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB 102#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
103#include "cypress_atacb.h" 103#include "cypress_atacb.h"
104#endif 104#endif
105#ifdef CONFIG_USB_STORAGE_SIERRA
106#include "sierra_ms.h" 105#include "sierra_ms.h"
107#endif
108 106
109/* Some informational data */ 107/* Some informational data */
110MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>"); 108MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>");
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index c6299e8a041d..9cbff84b787d 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -2400,11 +2400,15 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
2400 2400
2401 if (!fbcon_is_inactive(vc, info)) { 2401 if (!fbcon_is_inactive(vc, info)) {
2402 if (ops->blank_state != blank) { 2402 if (ops->blank_state != blank) {
2403 int ret = 1;
2404
2403 ops->blank_state = blank; 2405 ops->blank_state = blank;
2404 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW); 2406 fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
2405 ops->cursor_flash = (!blank); 2407 ops->cursor_flash = (!blank);
2406 2408
2407 if (fb_blank(info, blank)) 2409 if (info->fbops->fb_blank)
2410 ret = info->fbops->fb_blank(blank, info);
2411 if (ret)
2408 fbcon_generic_blank(vc, info, blank); 2412 fbcon_generic_blank(vc, info, blank);
2409 } 2413 }
2410 2414
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h
index a6e38e9ea73f..89a346880ec0 100644
--- a/drivers/video/console/fbcon.h
+++ b/drivers/video/console/fbcon.h
@@ -110,7 +110,7 @@ static inline int mono_col(const struct fb_info *info)
110 __u32 max_len; 110 __u32 max_len;
111 max_len = max(info->var.green.length, info->var.red.length); 111 max_len = max(info->var.green.length, info->var.red.length);
112 max_len = max(info->var.blue.length, max_len); 112 max_len = max(info->var.blue.length, max_len);
113 return ~(0xfff << (max_len & 0xff)); 113 return (~(0xfff << max_len)) & 0xff;
114} 114}
115 115
116static inline int attr_col_ec(int shift, struct vc_data *vc, 116static inline int attr_col_ec(int shift, struct vc_data *vc,
diff --git a/drivers/watchdog/geodewdt.c b/drivers/watchdog/geodewdt.c
index 614a5c7017b6..6799a6de66fe 100644
--- a/drivers/watchdog/geodewdt.c
+++ b/drivers/watchdog/geodewdt.c
@@ -130,8 +130,8 @@ static ssize_t geodewdt_write(struct file *file, const char __user *data,
130 return len; 130 return len;
131} 131}
132 132
133static int geodewdt_ioctl(struct inode *inode, struct file *file, 133static long geodewdt_ioctl(struct file *file, unsigned int cmd,
134 unsigned int cmd, unsigned long arg) 134 unsigned long arg)
135{ 135{
136 void __user *argp = (void __user *)arg; 136 void __user *argp = (void __user *)arg;
137 int __user *p = argp; 137 int __user *p = argp;
@@ -198,7 +198,7 @@ static const struct file_operations geodewdt_fops = {
198 .owner = THIS_MODULE, 198 .owner = THIS_MODULE,
199 .llseek = no_llseek, 199 .llseek = no_llseek,
200 .write = geodewdt_write, 200 .write = geodewdt_write,
201 .ioctl = geodewdt_ioctl, 201 .unlocked_ioctl = geodewdt_ioctl,
202 .open = geodewdt_open, 202 .open = geodewdt_open,
203 .release = geodewdt_release, 203 .release = geodewdt_release,
204}; 204};
diff --git a/drivers/watchdog/ibmasr.c b/drivers/watchdog/ibmasr.c
index b82405cfb4cd..89fcefcc8510 100644
--- a/drivers/watchdog/ibmasr.c
+++ b/drivers/watchdog/ibmasr.c
@@ -85,7 +85,6 @@ static void __asr_toggle(void)
85 85
86 outb(reg & ~asr_toggle_mask, asr_write_addr); 86 outb(reg & ~asr_toggle_mask, asr_write_addr);
87 reg = inb(asr_read_addr); 87 reg = inb(asr_read_addr);
88 spin_unlock(&asr_lock);
89} 88}
90 89
91static void asr_toggle(void) 90static void asr_toggle(void)
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index 0ed84162437b..6d9f3d4a9987 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -173,8 +173,8 @@ static const struct watchdog_info ident = {
173 .identity = "PNX4008 Watchdog", 173 .identity = "PNX4008 Watchdog",
174}; 174};
175 175
176static long pnx4008_wdt_ioctl(struct inode *inode, struct file *file, 176static long pnx4008_wdt_ioctl(struct file *file, unsigned int cmd,
177 unsigned int cmd, unsigned long arg) 177 unsigned long arg)
178{ 178{
179 int ret = -ENOTTY; 179 int ret = -ENOTTY;
180 int time; 180 int time;
diff --git a/drivers/watchdog/rc32434_wdt.c b/drivers/watchdog/rc32434_wdt.c
index 6756bcb009ed..c9c73b69c5e5 100644
--- a/drivers/watchdog/rc32434_wdt.c
+++ b/drivers/watchdog/rc32434_wdt.c
@@ -182,8 +182,8 @@ static ssize_t rc32434_wdt_write(struct file *file, const char *data,
182 return 0; 182 return 0;
183} 183}
184 184
185static int rc32434_wdt_ioctl(struct inode *inode, struct file *file, 185static long rc32434_wdt_ioctl(struct file *file, unsigned int cmd,
186 unsigned int cmd, unsigned long arg) 186 unsigned long arg)
187{ 187{
188 void __user *argp = (void __user *)arg; 188 void __user *argp = (void __user *)arg;
189 int new_timeout; 189 int new_timeout;
@@ -242,7 +242,7 @@ static struct file_operations rc32434_wdt_fops = {
242 .owner = THIS_MODULE, 242 .owner = THIS_MODULE,
243 .llseek = no_llseek, 243 .llseek = no_llseek,
244 .write = rc32434_wdt_write, 244 .write = rc32434_wdt_write,
245 .ioctl = rc32434_wdt_ioctl, 245 .unlocked_ioctl = rc32434_wdt_ioctl,
246 .open = rc32434_wdt_open, 246 .open = rc32434_wdt_open,
247 .release = rc32434_wdt_release, 247 .release = rc32434_wdt_release,
248}; 248};
diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c
index 9108efa73e7d..bf92802f2bbe 100644
--- a/drivers/watchdog/rdc321x_wdt.c
+++ b/drivers/watchdog/rdc321x_wdt.c
@@ -144,8 +144,8 @@ static int rdc321x_wdt_release(struct inode *inode, struct file *file)
144 return 0; 144 return 0;
145} 145}
146 146
147static int rdc321x_wdt_ioctl(struct inode *inode, struct file *file, 147static long rdc321x_wdt_ioctl(struct file *file, unsigned int cmd,
148 unsigned int cmd, unsigned long arg) 148 unsigned long arg)
149{ 149{
150 void __user *argp = (void __user *)arg; 150 void __user *argp = (void __user *)arg;
151 unsigned int value; 151 unsigned int value;
@@ -204,7 +204,7 @@ static ssize_t rdc321x_wdt_write(struct file *file, const char __user *buf,
204static const struct file_operations rdc321x_wdt_fops = { 204static const struct file_operations rdc321x_wdt_fops = {
205 .owner = THIS_MODULE, 205 .owner = THIS_MODULE,
206 .llseek = no_llseek, 206 .llseek = no_llseek,
207 .ioctl = rdc321x_wdt_ioctl, 207 .unlocked_ioctl = rdc321x_wdt_ioctl,
208 .open = rdc321x_wdt_open, 208 .open = rdc321x_wdt_open,
209 .write = rdc321x_wdt_write, 209 .write = rdc321x_wdt_write,
210 .release = rdc321x_wdt_release, 210 .release = rdc321x_wdt_release,
diff --git a/drivers/watchdog/wdt285.c b/drivers/watchdog/wdt285.c
index db362c34958b..191ea6302107 100644
--- a/drivers/watchdog/wdt285.c
+++ b/drivers/watchdog/wdt285.c
@@ -115,8 +115,8 @@ static int watchdog_release(struct inode *inode, struct file *file)
115 return 0; 115 return 0;
116} 116}
117 117
118static ssize_t watchdog_write(struct file *file, const char *data, 118static ssize_t watchdog_write(struct file *file, const char __user *data,
119 size_t len, loff_t *ppos) 119 size_t len, loff_t *ppos)
120{ 120{
121 /* 121 /*
122 * Refresh the timer. 122 * Refresh the timer.
@@ -133,21 +133,22 @@ static const struct watchdog_info ident = {
133}; 133};
134 134
135static long watchdog_ioctl(struct file *file, unsigned int cmd, 135static long watchdog_ioctl(struct file *file, unsigned int cmd,
136 unsigned long arg) 136 unsigned long arg)
137{ 137{
138 unsigned int new_margin; 138 unsigned int new_margin;
139 int __user *int_arg = (int __user *)arg;
139 int ret = -ENOTTY; 140 int ret = -ENOTTY;
140 141
141 switch (cmd) { 142 switch (cmd) {
142 case WDIOC_GETSUPPORT: 143 case WDIOC_GETSUPPORT:
143 ret = 0; 144 ret = 0;
144 if (copy_to_user((void *)arg, &ident, sizeof(ident))) 145 if (copy_to_user((void __user *)arg, &ident, sizeof(ident)))
145 ret = -EFAULT; 146 ret = -EFAULT;
146 break; 147 break;
147 148
148 case WDIOC_GETSTATUS: 149 case WDIOC_GETSTATUS:
149 case WDIOC_GETBOOTSTATUS: 150 case WDIOC_GETBOOTSTATUS:
150 ret = put_user(0, (int *)arg); 151 ret = put_user(0, int_arg);
151 break; 152 break;
152 153
153 case WDIOC_KEEPALIVE: 154 case WDIOC_KEEPALIVE:
@@ -156,7 +157,7 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd,
156 break; 157 break;
157 158
158 case WDIOC_SETTIMEOUT: 159 case WDIOC_SETTIMEOUT:
159 ret = get_user(new_margin, (int *)arg); 160 ret = get_user(new_margin, int_arg);
160 if (ret) 161 if (ret)
161 break; 162 break;
162 163
@@ -171,7 +172,7 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd,
171 watchdog_ping(); 172 watchdog_ping();
172 /* Fall */ 173 /* Fall */
173 case WDIOC_GETTIMEOUT: 174 case WDIOC_GETTIMEOUT:
174 ret = put_user(soft_margin, (int *)arg); 175 ret = put_user(soft_margin, int_arg);
175 break; 176 break;
176 } 177 }
177 return ret; 178 return ret;