aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Kconfig6
-rw-r--r--drivers/acpi/asus_acpi.c67
-rw-r--r--drivers/acpi/battery.c14
-rw-r--r--drivers/acpi/ec.c1096
-rw-r--r--drivers/acpi/events/evmisc.c14
-rw-r--r--drivers/acpi/events/evrgnini.c13
-rw-r--r--drivers/acpi/ibm_acpi.c2
-rw-r--r--drivers/acpi/motherboard.c6
-rw-r--r--drivers/acpi/osl.c34
-rw-r--r--drivers/acpi/pci_link.c2
-rw-r--r--drivers/acpi/power.c9
-rw-r--r--drivers/acpi/processor_core.c2
-rw-r--r--drivers/acpi/processor_idle.c109
-rw-r--r--drivers/acpi/sbs.c20
-rw-r--r--drivers/acpi/tables/tbget.c2
-rw-r--r--drivers/acpi/tables/tbrsdt.c2
-rw-r--r--drivers/ata/libata-core.c6
-rw-r--r--drivers/ata/libata-scsi.c46
-rw-r--r--drivers/ata/pata_qdi.c2
-rw-r--r--drivers/ata/sata_promise.c1
-rw-r--r--drivers/block/DAC960.h4
-rw-r--r--drivers/block/amiflop.c13
-rw-r--r--drivers/block/rd.c12
-rw-r--r--drivers/block/xd.c2
-rw-r--r--drivers/block/z2ram.c28
-rw-r--r--drivers/bluetooth/bcm203x.c17
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/epca.c32
-rw-r--r--drivers/char/ip2/i2lib.c11
-rw-r--r--drivers/char/ip2/i2lib.h2
-rw-r--r--drivers/char/ip2/ip2main.c4
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c122
-rw-r--r--drivers/char/mem.c5
-rw-r--r--drivers/char/rio/rioctrl.c4
-rw-r--r--drivers/char/serial167.c52
-rw-r--r--drivers/char/specialix.c15
-rw-r--r--drivers/char/sx.c2
-rw-r--r--drivers/char/synclink.c4
-rw-r--r--drivers/char/tpm/tpm.c9
-rw-r--r--drivers/char/tpm/tpm_atmel.c10
-rw-r--r--drivers/char/tpm/tpm_nsc.c6
-rw-r--r--drivers/eisa/eisa-bus.c22
-rw-r--r--drivers/firmware/dell_rbu.c23
-rw-r--r--drivers/firmware/efivars.c7
-rw-r--r--drivers/ide/ide-cd.c7
-rw-r--r--drivers/ide/ide-taskfile.c13
-rw-r--r--drivers/ide/pci/generic.c10
-rw-r--r--drivers/ide/pci/sgiioc4.c2
-rw-r--r--drivers/input/misc/hp_sdc_rtc.c8
-rw-r--r--drivers/input/misc/wistron_btns.c2
-rw-r--r--drivers/input/serio/hil_mlc.c18
-rw-r--r--drivers/input/serio/hp_sdc.c4
-rw-r--r--drivers/isdn/capi/capidrv.c3
-rw-r--r--drivers/isdn/hisax/config.c6
-rw-r--r--drivers/isdn/hysdn/boardergo.c32
-rw-r--r--drivers/isdn/hysdn/hysdn_defs.h2
-rw-r--r--drivers/isdn/hysdn/hysdn_proclog.c17
-rw-r--r--drivers/isdn/hysdn/hysdn_sched.c9
-rw-r--r--drivers/isdn/i4l/isdn_common.c9
-rw-r--r--drivers/isdn/icn/icn.c3
-rw-r--r--drivers/isdn/isdnloop/isdnloop.c73
-rw-r--r--drivers/isdn/isdnloop/isdnloop.h1
-rw-r--r--drivers/isdn/pcbit/drv.c16
-rw-r--r--drivers/isdn/pcbit/layer2.c1
-rw-r--r--drivers/isdn/sc/init.c23
-rw-r--r--drivers/isdn/sc/packet.c14
-rw-r--r--drivers/isdn/sc/shmem.c2
-rw-r--r--drivers/leds/led-class.c26
-rw-r--r--drivers/leds/ledtrig-timer.c16
-rw-r--r--drivers/mca/mca-bus.c28
-rw-r--r--drivers/md/bitmap.c2
-rw-r--r--drivers/md/md.c1
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c4
-rw-r--r--drivers/media/dvb/dvb-core/Kconfig2
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c11
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb.h2
-rw-r--r--drivers/media/dvb/dvb-usb/nova-t-usb2.c3
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.c2
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.h3
-rw-r--r--drivers/media/dvb/frontends/tda10086.h9
-rw-r--r--drivers/media/dvb/frontends/tda826x.h19
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/cx25840/cx25840-vbi.c25
-rw-r--r--drivers/media/video/cx88/cx88-cards.c21
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c17
-rw-r--r--drivers/media/video/cx88/cx88-input.c2
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c37
-rw-r--r--drivers/media/video/ov511.c58
-rw-r--r--drivers/media/video/pwc/pwc-if.c41
-rw-r--r--drivers/media/video/saa7115.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c6
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c71
-rw-r--r--drivers/media/video/stv680.c53
-rw-r--r--drivers/media/video/tuner-types.c1
-rw-r--r--drivers/media/video/videodev.c16
-rw-r--r--drivers/media/video/vivi.c12
-rw-r--r--drivers/message/i2o/bus-osm.c12
-rw-r--r--drivers/message/i2o/exec-osm.c17
-rw-r--r--drivers/misc/Kconfig30
-rw-r--r--drivers/misc/Makefile2
-rw-r--r--drivers/misc/ioc4.c (renamed from drivers/sn/ioc4.c)47
-rw-r--r--drivers/misc/msi-laptop.c395
-rw-r--r--drivers/net/b44.c9
-rw-r--r--drivers/net/bonding/bond_alb.c4
-rw-r--r--drivers/net/ehea/ehea.h13
-rw-r--r--drivers/net/ehea/ehea_main.c6
-rw-r--r--drivers/net/ehea/ehea_phyp.c573
-rw-r--r--drivers/net/eth16i.c2
-rw-r--r--drivers/net/forcedeth.c31
-rw-r--r--drivers/net/ibmveth.c58
-rw-r--r--drivers/net/mv643xx_eth.c4
-rw-r--r--drivers/net/skge.c220
-rw-r--r--drivers/net/skge.h25
-rw-r--r--drivers/net/sky2.c36
-rw-r--r--drivers/net/sky2.h45
-rw-r--r--drivers/net/smc91x.h18
-rw-r--r--drivers/net/spider_net.c246
-rw-r--r--drivers/net/spider_net.h35
-rw-r--r--drivers/net/spider_net_ethtool.c6
-rw-r--r--drivers/net/sun3_82586.c2
-rw-r--r--drivers/net/sun3lance.c6
-rw-r--r--drivers/net/tulip/de2104x.c8
-rw-r--r--drivers/pci/Kconfig2
-rw-r--r--drivers/rtc/rtc-max6902.c2
-rw-r--r--drivers/rtc/rtc-sh.c6
-rw-r--r--drivers/rtc/rtc-v3020.c4
-rw-r--r--drivers/s390/char/monwriter.c2
-rw-r--r--drivers/s390/cio/chsc.c23
-rw-r--r--drivers/s390/cio/cio.c4
-rw-r--r--drivers/s390/cio/css.c2
-rw-r--r--drivers/s390/cio/css.h7
-rw-r--r--drivers/s390/cio/device.c48
-rw-r--r--drivers/s390/cio/device.h1
-rw-r--r--drivers/s390/cio/device_fsm.c113
-rw-r--r--drivers/s390/cio/device_id.c14
-rw-r--r--drivers/s390/cio/device_ops.c6
-rw-r--r--drivers/s390/cio/device_pgid.c23
-rw-r--r--drivers/s390/cio/device_status.c7
-rw-r--r--drivers/s390/cio/qdio.c10
-rw-r--r--drivers/sbus/char/bbc_envctrl.c4
-rw-r--r--drivers/sbus/char/envctrl.c8
-rw-r--r--drivers/scsi/aha152x.c2
-rw-r--r--drivers/scsi/dtc.c2
-rw-r--r--drivers/scsi/fdomain.c2
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c2
-rw-r--r--drivers/scsi/seagate.c2
-rw-r--r--drivers/scsi/t128.c2
-rw-r--r--drivers/scsi/wd7000.c2
-rw-r--r--drivers/serial/ioc4_serial.c2
-rw-r--r--drivers/serial/sh-sci.c4
-rw-r--r--drivers/serial/sunzilog.c6
-rw-r--r--drivers/sn/Kconfig13
-rw-r--r--drivers/sn/Makefile1
-rw-r--r--drivers/video/Kconfig1
-rw-r--r--drivers/video/nvidia/nv_i2c.c45
-rw-r--r--drivers/w1/Kconfig1
156 files changed, 2664 insertions, 2187 deletions
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 263e86ddc1a4..f39463418904 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -14,6 +14,10 @@ source "drivers/pnp/Kconfig"
14 14
15source "drivers/block/Kconfig" 15source "drivers/block/Kconfig"
16 16
17# misc before ide - BLK_DEV_SGIIOC4 depends on SGI_IOC4
18
19source "drivers/misc/Kconfig"
20
17source "drivers/ide/Kconfig" 21source "drivers/ide/Kconfig"
18 22
19source "drivers/scsi/Kconfig" 23source "drivers/scsi/Kconfig"
@@ -52,8 +56,6 @@ source "drivers/w1/Kconfig"
52 56
53source "drivers/hwmon/Kconfig" 57source "drivers/hwmon/Kconfig"
54 58
55source "drivers/misc/Kconfig"
56
57source "drivers/mfd/Kconfig" 59source "drivers/mfd/Kconfig"
58 60
59source "drivers/media/Kconfig" 61source "drivers/media/Kconfig"
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index e9ee4c52a5f6..c7ac9297a204 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -138,6 +138,7 @@ struct asus_hotk {
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 xxN, //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N 142 xxN, //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N
142 //(Centrino) 143 //(Centrino)
143 END_MODEL 144 END_MODEL
@@ -376,6 +377,17 @@ static struct model_data model_conf[END_MODEL] = {
376 .display_get = "\\ADVG"}, 377 .display_get = "\\ADVG"},
377 378
378 { 379 {
380 .name = "W3V",
381 .mt_mled = "MLED",
382 .mt_wled = "WLED",
383 .mt_lcd_switch = xxN_PREFIX "_Q10",
384 .lcd_status = "\\BKLT",
385 .brightness_set = "SPLV",
386 .brightness_get = "GPLV",
387 .display_set = "SDSP",
388 .display_get = "\\INFB"},
389
390 {
379 .name = "xxN", 391 .name = "xxN",
380 .mt_mled = "MLED", 392 .mt_mled = "MLED",
381/* WLED present, but not controlled by ACPI */ 393/* WLED present, but not controlled by ACPI */
@@ -555,11 +567,11 @@ static int
555write_led(const char __user * buffer, unsigned long count, 567write_led(const char __user * buffer, unsigned long count,
556 char *ledname, int ledmask, int invert) 568 char *ledname, int ledmask, int invert)
557{ 569{
558 int value; 570 int rv, value;
559 int led_out = 0; 571 int led_out = 0;
560 572
561 count = parse_arg(buffer, count, &value); 573 rv = parse_arg(buffer, count, &value);
562 if (count > 0) 574 if (rv > 0)
563 led_out = value ? 1 : 0; 575 led_out = value ? 1 : 0;
564 576
565 hotk->status = 577 hotk->status =
@@ -572,7 +584,7 @@ write_led(const char __user * buffer, unsigned long count,
572 printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n", 584 printk(KERN_WARNING "Asus ACPI: LED (%s) write failed\n",
573 ledname); 585 ledname);
574 586
575 return count; 587 return rv;
576} 588}
577 589
578/* 590/*
@@ -607,20 +619,18 @@ static int
607proc_write_ledd(struct file *file, const char __user * buffer, 619proc_write_ledd(struct file *file, const char __user * buffer,
608 unsigned long count, void *data) 620 unsigned long count, void *data)
609{ 621{
610 int value; 622 int rv, value;
611 623
612 count = parse_arg(buffer, count, &value); 624 rv = parse_arg(buffer, count, &value);
613 if (count > 0) { 625 if (rv > 0) {
614 if (!write_acpi_int 626 if (!write_acpi_int
615 (hotk->handle, hotk->methods->mt_ledd, value, NULL)) 627 (hotk->handle, hotk->methods->mt_ledd, value, NULL))
616 printk(KERN_WARNING 628 printk(KERN_WARNING
617 "Asus ACPI: LED display write failed\n"); 629 "Asus ACPI: LED display write failed\n");
618 else 630 else
619 hotk->ledd_status = (u32) value; 631 hotk->ledd_status = (u32) value;
620 } else if (count < 0) 632 }
621 printk(KERN_WARNING "Asus ACPI: Error reading user input\n"); 633 return rv;
622
623 return count;
624} 634}
625 635
626/* 636/*
@@ -761,12 +771,12 @@ static int
761proc_write_lcd(struct file *file, const char __user * buffer, 771proc_write_lcd(struct file *file, const char __user * buffer,
762 unsigned long count, void *data) 772 unsigned long count, void *data)
763{ 773{
764 int value; 774 int rv, value;
765 775
766 count = parse_arg(buffer, count, &value); 776 rv = parse_arg(buffer, count, &value);
767 if (count > 0) 777 if (rv > 0)
768 set_lcd_state(value); 778 set_lcd_state(value);
769 return count; 779 return rv;
770} 780}
771 781
772static int read_brightness(void) 782static int read_brightness(void)
@@ -830,18 +840,15 @@ static int
830proc_write_brn(struct file *file, const char __user * buffer, 840proc_write_brn(struct file *file, const char __user * buffer,
831 unsigned long count, void *data) 841 unsigned long count, void *data)
832{ 842{
833 int value; 843 int rv, value;
834 844
835 count = parse_arg(buffer, count, &value); 845 rv = parse_arg(buffer, count, &value);
836 if (count > 0) { 846 if (rv > 0) {
837 value = (0 < value) ? ((15 < value) ? 15 : value) : 0; 847 value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
838 /* 0 <= value <= 15 */ 848 /* 0 <= value <= 15 */
839 set_brightness(value); 849 set_brightness(value);
840 } else if (count < 0) {
841 printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
842 } 850 }
843 851 return rv;
844 return count;
845} 852}
846 853
847static void set_display(int value) 854static void set_display(int value)
@@ -880,15 +887,12 @@ static int
880proc_write_disp(struct file *file, const char __user * buffer, 887proc_write_disp(struct file *file, const char __user * buffer,
881 unsigned long count, void *data) 888 unsigned long count, void *data)
882{ 889{
883 int value; 890 int rv, value;
884 891
885 count = parse_arg(buffer, count, &value); 892 rv = parse_arg(buffer, count, &value);
886 if (count > 0) 893 if (rv > 0)
887 set_display(value); 894 set_display(value);
888 else if (count < 0) 895 return rv;
889 printk(KERN_WARNING "Asus ACPI: Error reading user input\n");
890
891 return count;
892} 896}
893 897
894typedef int (proc_readfunc) (char *page, char **start, off_t off, int count, 898typedef int (proc_readfunc) (char *page, char **start, off_t off, int count,
@@ -1097,6 +1101,8 @@ static int asus_model_match(char *model)
1097 return A4G; 1101 return A4G;
1098 else if (strncmp(model, "W1N", 3) == 0) 1102 else if (strncmp(model, "W1N", 3) == 0)
1099 return W1N; 1103 return W1N;
1104 else if (strncmp(model, "W3V", 3) == 0)
1105 return W3V;
1100 else if (strncmp(model, "W5A", 3) == 0) 1106 else if (strncmp(model, "W5A", 3) == 0)
1101 return W5A; 1107 return W5A;
1102 else 1108 else
@@ -1200,9 +1206,10 @@ static int asus_hotk_get_info(void)
1200 hotk->methods->mt_wled = NULL; 1206 hotk->methods->mt_wled = NULL;
1201 /* L5D's WLED is not controlled by ACPI */ 1207 /* L5D's WLED is not controlled by ACPI */
1202 else if (strncmp(string, "M2N", 3) == 0 || 1208 else if (strncmp(string, "M2N", 3) == 0 ||
1209 strncmp(string, "W3V", 3) == 0 ||
1203 strncmp(string, "S1N", 3) == 0) 1210 strncmp(string, "S1N", 3) == 0)
1204 hotk->methods->mt_wled = "WLED"; 1211 hotk->methods->mt_wled = "WLED";
1205 /* M2N and S1N have a usable WLED */ 1212 /* M2N, S1N and W3V have a usable WLED */
1206 else if (asus_info) { 1213 else if (asus_info) {
1207 if (strncmp(asus_info->oem_table_id, "L1", 2) == 0) 1214 if (strncmp(asus_info->oem_table_id, "L1", 2) == 0)
1208 hotk->methods->mled_status = NULL; 1215 hotk->methods->mled_status = NULL;
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 9810e2a55d0a..026e40755cdd 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -64,6 +64,7 @@ extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
64 64
65static int acpi_battery_add(struct acpi_device *device); 65static int acpi_battery_add(struct acpi_device *device);
66static int acpi_battery_remove(struct acpi_device *device, int type); 66static int acpi_battery_remove(struct acpi_device *device, int type);
67static int acpi_battery_resume(struct acpi_device *device, int status);
67 68
68static struct acpi_driver acpi_battery_driver = { 69static struct acpi_driver acpi_battery_driver = {
69 .name = ACPI_BATTERY_DRIVER_NAME, 70 .name = ACPI_BATTERY_DRIVER_NAME,
@@ -71,6 +72,7 @@ static struct acpi_driver acpi_battery_driver = {
71 .ids = ACPI_BATTERY_HID, 72 .ids = ACPI_BATTERY_HID,
72 .ops = { 73 .ops = {
73 .add = acpi_battery_add, 74 .add = acpi_battery_add,
75 .resume = acpi_battery_resume,
74 .remove = acpi_battery_remove, 76 .remove = acpi_battery_remove,
75 }, 77 },
76}; 78};
@@ -753,6 +755,18 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
753 return 0; 755 return 0;
754} 756}
755 757
758/* this is needed to learn about changes made in suspended state */
759static int acpi_battery_resume(struct acpi_device *device, int state)
760{
761 struct acpi_battery *battery;
762
763 if (!device)
764 return -EINVAL;
765
766 battery = device->driver_data;
767 return acpi_battery_check(battery);
768}
769
756static int __init acpi_battery_init(void) 770static int __init acpi_battery_init(void)
757{ 771{
758 int result; 772 int result;
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index e5d796362854..e6d4b084dca2 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -45,206 +45,143 @@ ACPI_MODULE_NAME("acpi_ec")
45#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" 45#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver"
46#define ACPI_EC_DEVICE_NAME "Embedded Controller" 46#define ACPI_EC_DEVICE_NAME "Embedded Controller"
47#define ACPI_EC_FILE_INFO "info" 47#define ACPI_EC_FILE_INFO "info"
48
49/* EC status register */
48#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ 50#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
49#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ 51#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
50#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ 52#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
51#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ 53#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
52#define ACPI_EC_EVENT_OBF 0x01 /* Output buffer full */ 54
53#define ACPI_EC_EVENT_IBE 0x02 /* Input buffer empty */ 55/* EC commands */
54#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */
55#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
56#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */
57#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */
58#define ACPI_EC_COMMAND_READ 0x80 56#define ACPI_EC_COMMAND_READ 0x80
59#define ACPI_EC_COMMAND_WRITE 0x81 57#define ACPI_EC_COMMAND_WRITE 0x81
60#define ACPI_EC_BURST_ENABLE 0x82 58#define ACPI_EC_BURST_ENABLE 0x82
61#define ACPI_EC_BURST_DISABLE 0x83 59#define ACPI_EC_BURST_DISABLE 0x83
62#define ACPI_EC_COMMAND_QUERY 0x84 60#define ACPI_EC_COMMAND_QUERY 0x84
63#define EC_POLL 0xFF 61
64#define EC_INTR 0x00 62/* EC events */
63enum {
64 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */
65 ACPI_EC_EVENT_IBF_0, /* Input buffer empty */
66};
67
68#define ACPI_EC_DELAY 50 /* Wait 50ms max. during EC ops */
69#define ACPI_EC_UDELAY_GLK 1000 /* Wait 1ms max. to get global lock */
70#define ACPI_EC_UDELAY 100 /* Poll @ 100us increments */
71#define ACPI_EC_UDELAY_COUNT 1000 /* Wait 10ms max. during EC ops */
72
73enum {
74 EC_INTR = 1, /* Output buffer full */
75 EC_POLL, /* Input buffer empty */
76};
77
65static int acpi_ec_remove(struct acpi_device *device, int type); 78static int acpi_ec_remove(struct acpi_device *device, int type);
66static int acpi_ec_start(struct acpi_device *device); 79static int acpi_ec_start(struct acpi_device *device);
67static int acpi_ec_stop(struct acpi_device *device, int type); 80static int acpi_ec_stop(struct acpi_device *device, int type);
68static int acpi_ec_intr_add(struct acpi_device *device); 81static int acpi_ec_add(struct acpi_device *device);
69static int acpi_ec_poll_add(struct acpi_device *device);
70 82
71static struct acpi_driver acpi_ec_driver = { 83static struct acpi_driver acpi_ec_driver = {
72 .name = ACPI_EC_DRIVER_NAME, 84 .name = ACPI_EC_DRIVER_NAME,
73 .class = ACPI_EC_CLASS, 85 .class = ACPI_EC_CLASS,
74 .ids = ACPI_EC_HID, 86 .ids = ACPI_EC_HID,
75 .ops = { 87 .ops = {
76 .add = acpi_ec_intr_add, 88 .add = acpi_ec_add,
77 .remove = acpi_ec_remove, 89 .remove = acpi_ec_remove,
78 .start = acpi_ec_start, 90 .start = acpi_ec_start,
79 .stop = acpi_ec_stop, 91 .stop = acpi_ec_stop,
80 }, 92 },
81}; 93};
82union acpi_ec {
83 struct {
84 u32 mode;
85 acpi_handle handle;
86 unsigned long uid;
87 unsigned long gpe_bit;
88 struct acpi_generic_address status_addr;
89 struct acpi_generic_address command_addr;
90 struct acpi_generic_address data_addr;
91 unsigned long global_lock;
92 } common;
93
94 struct {
95 u32 mode;
96 acpi_handle handle;
97 unsigned long uid;
98 unsigned long gpe_bit;
99 struct acpi_generic_address status_addr;
100 struct acpi_generic_address command_addr;
101 struct acpi_generic_address data_addr;
102 unsigned long global_lock;
103 unsigned int expect_event;
104 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */
105 atomic_t pending_gpe;
106 struct semaphore sem;
107 wait_queue_head_t wait;
108 } intr;
109
110 struct {
111 u32 mode;
112 acpi_handle handle;
113 unsigned long uid;
114 unsigned long gpe_bit;
115 struct acpi_generic_address status_addr;
116 struct acpi_generic_address command_addr;
117 struct acpi_generic_address data_addr;
118 unsigned long global_lock;
119 struct semaphore sem;
120 } poll;
121};
122 94
123static int acpi_ec_poll_wait(union acpi_ec *ec, u8 event);
124static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event);
125static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data);
126static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data);
127static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data);
128static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data);
129static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data);
130static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data);
131static void acpi_ec_gpe_poll_query(void *ec_cxt);
132static void acpi_ec_gpe_intr_query(void *ec_cxt);
133static u32 acpi_ec_gpe_poll_handler(void *data);
134static u32 acpi_ec_gpe_intr_handler(void *data);
135static acpi_status __init
136acpi_fake_ecdt_poll_callback(acpi_handle handle,
137 u32 Level, void *context, void **retval);
138
139static acpi_status __init
140acpi_fake_ecdt_intr_callback(acpi_handle handle,
141 u32 Level, void *context, void **retval);
142
143static int __init acpi_ec_poll_get_real_ecdt(void);
144static int __init acpi_ec_intr_get_real_ecdt(void);
145/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 95/* If we find an EC via the ECDT, we need to keep a ptr to its context */
146static union acpi_ec *ec_ecdt; 96struct acpi_ec {
97 acpi_handle handle;
98 unsigned long uid;
99 unsigned long gpe_bit;
100 unsigned long command_addr;
101 unsigned long data_addr;
102 unsigned long global_lock;
103 struct semaphore sem;
104 unsigned int expect_event;
105 atomic_t leaving_burst; /* 0 : No, 1 : Yes, 2: abort */
106 wait_queue_head_t wait;
107} *ec_ecdt;
147 108
148/* External interfaces use first EC only, so remember */ 109/* External interfaces use first EC only, so remember */
149static struct acpi_device *first_ec; 110static struct acpi_device *first_ec;
150static int acpi_ec_poll_mode = EC_INTR; 111static int acpi_ec_mode = EC_INTR;
151 112
152/* -------------------------------------------------------------------------- 113/* --------------------------------------------------------------------------
153 Transaction Management 114 Transaction Management
154 -------------------------------------------------------------------------- */ 115 -------------------------------------------------------------------------- */
155 116
156static u32 acpi_ec_read_status(union acpi_ec *ec) 117static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
157{ 118{
158 u32 status = 0; 119 return inb(ec->command_addr);
159
160 acpi_hw_low_level_read(8, &status, &ec->common.status_addr);
161 return status;
162} 120}
163 121
164static int acpi_ec_wait(union acpi_ec *ec, u8 event) 122static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
165{ 123{
166 if (acpi_ec_poll_mode) 124 return inb(ec->data_addr);
167 return acpi_ec_poll_wait(ec, event);
168 else
169 return acpi_ec_intr_wait(ec, event);
170} 125}
171 126
172static int acpi_ec_poll_wait(union acpi_ec *ec, u8 event) 127static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
173{ 128{
174 u32 acpi_ec_status = 0; 129 outb(command, ec->command_addr);
175 u32 i = ACPI_EC_UDELAY_COUNT; 130}
176 131
177 if (!ec) 132static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
178 return -EINVAL; 133{
134 outb(data, ec->data_addr);
135}
179 136
180 /* Poll the EC status register waiting for the event to occur. */ 137static int acpi_ec_check_status(u8 status, u8 event)
138{
181 switch (event) { 139 switch (event) {
182 case ACPI_EC_EVENT_OBF: 140 case ACPI_EC_EVENT_OBF_1:
183 do { 141 if (status & ACPI_EC_FLAG_OBF)
184 acpi_hw_low_level_read(8, &acpi_ec_status, 142 return 1;
185 &ec->common.status_addr);
186 if (acpi_ec_status & ACPI_EC_FLAG_OBF)
187 return 0;
188 udelay(ACPI_EC_UDELAY);
189 } while (--i > 0);
190 break; 143 break;
191 case ACPI_EC_EVENT_IBE: 144 case ACPI_EC_EVENT_IBF_0:
192 do { 145 if (!(status & ACPI_EC_FLAG_IBF))
193 acpi_hw_low_level_read(8, &acpi_ec_status, 146 return 1;
194 &ec->common.status_addr);
195 if (!(acpi_ec_status & ACPI_EC_FLAG_IBF))
196 return 0;
197 udelay(ACPI_EC_UDELAY);
198 } while (--i > 0);
199 break; 147 break;
200 default: 148 default:
201 return -EINVAL; 149 break;
202 } 150 }
203 151
204 return -ETIME; 152 return 0;
205} 153}
206static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event)
207{
208 int result = 0;
209
210 154
211 ec->intr.expect_event = event; 155static int acpi_ec_wait(struct acpi_ec *ec, u8 event)
212 smp_mb(); 156{
157 int i = (acpi_ec_mode == EC_POLL) ? ACPI_EC_UDELAY_COUNT : 0;
158 long time_left;
213 159
214 switch (event) { 160 ec->expect_event = event;
215 case ACPI_EC_EVENT_IBE: 161 if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) {
216 if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) { 162 ec->expect_event = 0;
217 ec->intr.expect_event = 0; 163 return 0;
218 return 0;
219 }
220 break;
221 default:
222 break;
223 } 164 }
224 165
225 result = wait_event_timeout(ec->intr.wait, 166 do {
226 !ec->intr.expect_event, 167 if (acpi_ec_mode == EC_POLL) {
168 udelay(ACPI_EC_UDELAY);
169 } else {
170 time_left = wait_event_timeout(ec->wait,
171 !ec->expect_event,
227 msecs_to_jiffies(ACPI_EC_DELAY)); 172 msecs_to_jiffies(ACPI_EC_DELAY));
228 173 if (time_left > 0) {
229 ec->intr.expect_event = 0; 174 ec->expect_event = 0;
230 smp_mb(); 175 return 0;
231 176 }
232 /* 177 }
233 * Verify that the event in question has actually happened by 178 if (acpi_ec_check_status(acpi_ec_read_status(ec), event)) {
234 * querying EC status. Do the check even if operation timed-out 179 ec->expect_event = 0;
235 * to make sure that we did not miss interrupt.
236 */
237 switch (event) {
238 case ACPI_EC_EVENT_OBF:
239 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_OBF)
240 return 0; 180 return 0;
241 break; 181 }
182 } while (--i > 0);
242 183
243 case ACPI_EC_EVENT_IBE: 184 ec->expect_event = 0;
244 if (~acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF)
245 return 0;
246 break;
247 }
248 185
249 return -ETIME; 186 return -ETIME;
250} 187}
@@ -254,272 +191,150 @@ static int acpi_ec_intr_wait(union acpi_ec *ec, unsigned int event)
254 * Note: samsung nv5000 doesn't work with ec burst mode. 191 * Note: samsung nv5000 doesn't work with ec burst mode.
255 * http://bugzilla.kernel.org/show_bug.cgi?id=4980 192 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
256 */ 193 */
257int acpi_ec_enter_burst_mode(union acpi_ec *ec) 194int acpi_ec_enter_burst_mode(struct acpi_ec *ec)
258{ 195{
259 u32 tmp = 0; 196 u8 tmp = 0;
260 int status = 0; 197 u8 status = 0;
261 198
262 199
263 status = acpi_ec_read_status(ec); 200 status = acpi_ec_read_status(ec);
264 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) { 201 if (status != -EINVAL && !(status & ACPI_EC_FLAG_BURST)) {
265 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 202 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
266 if (status) 203 if (status)
267 goto end; 204 goto end;
268 acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, 205 acpi_ec_write_cmd(ec, ACPI_EC_BURST_ENABLE);
269 &ec->common.command_addr); 206 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
270 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 207 tmp = acpi_ec_read_data(ec);
271 acpi_hw_low_level_read(8, &tmp, &ec->common.data_addr);
272 if (tmp != 0x90) { /* Burst ACK byte */ 208 if (tmp != 0x90) { /* Burst ACK byte */
273 return -EINVAL; 209 return -EINVAL;
274 } 210 }
275 } 211 }
276 212
277 atomic_set(&ec->intr.leaving_burst, 0); 213 atomic_set(&ec->leaving_burst, 0);
278 return 0; 214 return 0;
279 end: 215 end:
280 ACPI_EXCEPTION ((AE_INFO, status, "EC wait, burst mode"); 216 ACPI_EXCEPTION((AE_INFO, status, "EC wait, burst mode"));
281 return -1; 217 return -1;
282} 218}
283 219
284int acpi_ec_leave_burst_mode(union acpi_ec *ec) 220int acpi_ec_leave_burst_mode(struct acpi_ec *ec)
285{ 221{
286 int status = 0; 222 u8 status = 0;
287 223
288 224
289 status = acpi_ec_read_status(ec); 225 status = acpi_ec_read_status(ec);
290 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){ 226 if (status != -EINVAL && (status & ACPI_EC_FLAG_BURST)){
291 status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); 227 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
292 if(status) 228 if(status)
293 goto end; 229 goto end;
294 acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->common.command_addr); 230 acpi_ec_write_cmd(ec, ACPI_EC_BURST_DISABLE);
295 acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); 231 acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
296 } 232 }
297 atomic_set(&ec->intr.leaving_burst, 1); 233 atomic_set(&ec->leaving_burst, 1);
298 return 0; 234 return 0;
299end: 235 end:
300 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"); 236 ACPI_EXCEPTION((AE_INFO, status, "EC leave burst mode"));
301 return -1; 237 return -1;
302} 238}
303#endif /* ACPI_FUTURE_USAGE */ 239#endif /* ACPI_FUTURE_USAGE */
304 240
305static int acpi_ec_read(union acpi_ec *ec, u8 address, u32 * data) 241static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, u8 command,
306{ 242 const u8 *wdata, unsigned wdata_len,
307 if (acpi_ec_poll_mode) 243 u8 *rdata, unsigned rdata_len)
308 return acpi_ec_poll_read(ec, address, data);
309 else
310 return acpi_ec_intr_read(ec, address, data);
311}
312static int acpi_ec_write(union acpi_ec *ec, u8 address, u8 data)
313{
314 if (acpi_ec_poll_mode)
315 return acpi_ec_poll_write(ec, address, data);
316 else
317 return acpi_ec_intr_write(ec, address, data);
318}
319static int acpi_ec_poll_read(union acpi_ec *ec, u8 address, u32 * data)
320{ 244{
321 acpi_status status = AE_OK; 245 int result;
322 int result = 0;
323 u32 glk = 0;
324 246
247 acpi_ec_write_cmd(ec, command);
325 248
326 if (!ec || !data) 249 for (; wdata_len > 0; wdata_len --) {
327 return -EINVAL; 250 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
328 251 if (result)
329 *data = 0; 252 return result;
330 253 acpi_ec_write_data(ec, *(wdata++));
331 if (ec->common.global_lock) {
332 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
333 if (ACPI_FAILURE(status))
334 return -ENODEV;
335 } 254 }
336 255
337 if (down_interruptible(&ec->poll.sem)) { 256 if (command == ACPI_EC_COMMAND_WRITE) {
338 result = -ERESTARTSYS; 257 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
339 goto end_nosem; 258 if (result)
259 return result;
340 } 260 }
341
342 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ,
343 &ec->common.command_addr);
344 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
345 if (result)
346 goto end;
347
348 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
349 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
350 if (result)
351 goto end;
352
353 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
354
355 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
356 *data, address));
357
358 end:
359 up(&ec->poll.sem);
360end_nosem:
361 if (ec->common.global_lock)
362 acpi_release_global_lock(glk);
363
364 return result;
365}
366
367static int acpi_ec_poll_write(union acpi_ec *ec, u8 address, u8 data)
368{
369 int result = 0;
370 acpi_status status = AE_OK;
371 u32 glk = 0;
372 261
262 for (; rdata_len > 0; rdata_len --) {
263 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF_1);
264 if (result)
265 return result;
373 266
374 if (!ec) 267 *(rdata++) = acpi_ec_read_data(ec);
375 return -EINVAL;
376
377 if (ec->common.global_lock) {
378 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
379 if (ACPI_FAILURE(status))
380 return -ENODEV;
381 }
382
383 if (down_interruptible(&ec->poll.sem)) {
384 result = -ERESTARTSYS;
385 goto end_nosem;
386 } 268 }
387
388 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE,
389 &ec->common.command_addr);
390 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
391 if (result)
392 goto end;
393
394 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
395 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
396 if (result)
397 goto end;
398
399 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
400 result = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
401 if (result)
402 goto end;
403 269
404 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", 270 return 0;
405 data, address));
406
407 end:
408 up(&ec->poll.sem);
409end_nosem:
410 if (ec->common.global_lock)
411 acpi_release_global_lock(glk);
412
413 return result;
414} 271}
415 272
416static int acpi_ec_intr_read(union acpi_ec *ec, u8 address, u32 * data) 273static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
274 const u8 *wdata, unsigned wdata_len,
275 u8 *rdata, unsigned rdata_len)
417{ 276{
418 int status = 0; 277 int status;
419 u32 glk; 278 u32 glk;
420 279
421 280 if (!ec || (wdata_len && !wdata) || (rdata_len && !rdata))
422 if (!ec || !data)
423 return -EINVAL; 281 return -EINVAL;
424 282
425 *data = 0; 283 if (rdata)
284 memset(rdata, 0, rdata_len);
426 285
427 if (ec->common.global_lock) { 286 if (ec->global_lock) {
428 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk); 287 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
429 if (ACPI_FAILURE(status)) 288 if (ACPI_FAILURE(status))
430 return -ENODEV; 289 return -ENODEV;
431 } 290 }
291 down(&ec->sem);
432 292
433 WARN_ON(in_interrupt()); 293 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0);
434 down(&ec->intr.sem);
435
436 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
437 if (status) { 294 if (status) {
438 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n"); 295 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n");
439 goto end; 296 goto end;
440 } 297 }
441 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_READ,
442 &ec->common.command_addr);
443 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
444 if (status) {
445 printk(KERN_DEBUG PREFIX "read EC, IB not empty\n");
446 }
447 298
448 acpi_hw_low_level_write(8, address, &ec->common.data_addr); 299 status = acpi_ec_transaction_unlocked(ec, command,
449 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); 300 wdata, wdata_len,
450 if (status) { 301 rdata, rdata_len);
451 printk(KERN_DEBUG PREFIX "read EC, OB not full\n");
452 goto end;
453 }
454 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
455 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Read [%02x] from address [%02x]\n",
456 *data, address));
457 302
458 end: 303end:
459 up(&ec->intr.sem); 304 up(&ec->sem);
460 305
461 if (ec->common.global_lock) 306 if (ec->global_lock)
462 acpi_release_global_lock(glk); 307 acpi_release_global_lock(glk);
463 308
464 return status; 309 return status;
465} 310}
466 311
467static int acpi_ec_intr_write(union acpi_ec *ec, u8 address, u8 data) 312static int acpi_ec_read(struct acpi_ec *ec, u8 address, u8 *data)
468{ 313{
469 int status = 0; 314 int result;
470 u32 glk; 315 u8 d;
471
472
473 if (!ec)
474 return -EINVAL;
475
476 if (ec->common.global_lock) {
477 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
478 if (ACPI_FAILURE(status))
479 return -ENODEV;
480 }
481
482 WARN_ON(in_interrupt());
483 down(&ec->intr.sem);
484
485 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
486 if (status) {
487 printk(KERN_DEBUG PREFIX "write EC, IB not empty\n");
488 }
489 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_WRITE,
490 &ec->common.command_addr);
491 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
492 if (status) {
493 printk(KERN_DEBUG PREFIX "write EC, IB not empty\n");
494 }
495
496 acpi_hw_low_level_write(8, address, &ec->common.data_addr);
497 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE);
498 if (status) {
499 printk(KERN_DEBUG PREFIX "write EC, IB not empty\n");
500 }
501
502 acpi_hw_low_level_write(8, data, &ec->common.data_addr);
503 316
504 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Wrote [%02x] to address [%02x]\n", 317 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_READ,
505 data, address)); 318 &address, 1, &d, 1);
506 319 *data = d;
507 up(&ec->intr.sem); 320 return result;
508 321}
509 if (ec->common.global_lock)
510 acpi_release_global_lock(glk);
511 322
512 return status; 323static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
324{
325 u8 wdata[2] = { address, data };
326 return acpi_ec_transaction(ec, ACPI_EC_COMMAND_WRITE,
327 wdata, 2, NULL, 0);
513} 328}
514 329
515/* 330/*
516 * Externally callable EC access functions. For now, assume 1 EC only 331 * Externally callable EC access functions. For now, assume 1 EC only
517 */ 332 */
518int ec_read(u8 addr, u8 * val) 333int ec_read(u8 addr, u8 *val)
519{ 334{
520 union acpi_ec *ec; 335 struct acpi_ec *ec;
521 int err; 336 int err;
522 u32 temp_data; 337 u8 temp_data;
523 338
524 if (!first_ec) 339 if (!first_ec)
525 return -ENODEV; 340 return -ENODEV;
@@ -539,7 +354,7 @@ EXPORT_SYMBOL(ec_read);
539 354
540int ec_write(u8 addr, u8 val) 355int ec_write(u8 addr, u8 val)
541{ 356{
542 union acpi_ec *ec; 357 struct acpi_ec *ec;
543 int err; 358 int err;
544 359
545 if (!first_ec) 360 if (!first_ec)
@@ -554,255 +369,106 @@ int ec_write(u8 addr, u8 val)
554 369
555EXPORT_SYMBOL(ec_write); 370EXPORT_SYMBOL(ec_write);
556 371
557static int acpi_ec_query(union acpi_ec *ec, u32 * data) 372extern int ec_transaction(u8 command,
558{ 373 const u8 *wdata, unsigned wdata_len,
559 if (acpi_ec_poll_mode) 374 u8 *rdata, unsigned rdata_len)
560 return acpi_ec_poll_query(ec, data);
561 else
562 return acpi_ec_intr_query(ec, data);
563}
564static int acpi_ec_poll_query(union acpi_ec *ec, u32 * data)
565{ 375{
566 int result = 0; 376 struct acpi_ec *ec;
567 acpi_status status = AE_OK;
568 u32 glk = 0;
569
570
571 if (!ec || !data)
572 return -EINVAL;
573
574 *data = 0;
575
576 if (ec->common.global_lock) {
577 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
578 if (ACPI_FAILURE(status))
579 return -ENODEV;
580 }
581 377
582 /* 378 if (!first_ec)
583 * Query the EC to find out which _Qxx method we need to evaluate. 379 return -ENODEV;
584 * Note that successful completion of the query causes the ACPI_EC_SCI
585 * bit to be cleared (and thus clearing the interrupt source).
586 */
587 if (down_interruptible(&ec->poll.sem)) {
588 result = -ERESTARTSYS;
589 goto end_nosem;
590 }
591
592 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY,
593 &ec->common.command_addr);
594 result = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
595 if (result)
596 goto end;
597
598 acpi_hw_low_level_read(8, data, &ec->common.data_addr);
599 if (!*data)
600 result = -ENODATA;
601 380
602 end: 381 ec = acpi_driver_data(first_ec);
603 up(&ec->poll.sem);
604end_nosem:
605 if (ec->common.global_lock)
606 acpi_release_global_lock(glk);
607 382
608 return result; 383 return acpi_ec_transaction(ec, command, wdata,
384 wdata_len, rdata, rdata_len);
609} 385}
610static int acpi_ec_intr_query(union acpi_ec *ec, u32 * data)
611{
612 int status = 0;
613 u32 glk;
614
615 386
616 if (!ec || !data) 387EXPORT_SYMBOL(ec_transaction);
617 return -EINVAL;
618 *data = 0;
619
620 if (ec->common.global_lock) {
621 status = acpi_acquire_global_lock(ACPI_EC_UDELAY_GLK, &glk);
622 if (ACPI_FAILURE(status))
623 return -ENODEV;
624 }
625 388
626 down(&ec->intr.sem); 389static int acpi_ec_query(struct acpi_ec *ec, u8 *data)
390{
391 int result;
392 u8 d;
627 393
628 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBE); 394 if (!ec || !data)
629 if (status) { 395 return -EINVAL;
630 printk(KERN_DEBUG PREFIX "query EC, IB not empty\n");
631 goto end;
632 }
633 /*
634 * Query the EC to find out which _Qxx method we need to evaluate.
635 * Note that successful completion of the query causes the ACPI_EC_SCI
636 * bit to be cleared (and thus clearing the interrupt source).
637 */
638 acpi_hw_low_level_write(8, ACPI_EC_COMMAND_QUERY,
639 &ec->common.command_addr);
640 status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF);
641 if (status) {
642 printk(KERN_DEBUG PREFIX "query EC, OB not full\n");
643 goto end;
644 }
645 396
646 acpi_hw_low_level_read(8, data, &ec->common.data_addr); 397 /*
647 if (!*data) 398 * Query the EC to find out which _Qxx method we need to evaluate.
648 status = -ENODATA; 399 * Note that successful completion of the query causes the ACPI_EC_SCI
400 * bit to be cleared (and thus clearing the interrupt source).
401 */
649 402
650 end: 403 result = acpi_ec_transaction(ec, ACPI_EC_COMMAND_QUERY, NULL, 0, &d, 1);
651 up(&ec->intr.sem); 404 if (result)
405 return result;
652 406
653 if (ec->common.global_lock) 407 if (!d)
654 acpi_release_global_lock(glk); 408 return -ENODATA;
655 409
656 return status; 410 *data = d;
411 return 0;
657} 412}
658 413
659/* -------------------------------------------------------------------------- 414/* --------------------------------------------------------------------------
660 Event Management 415 Event Management
661 -------------------------------------------------------------------------- */ 416 -------------------------------------------------------------------------- */
662 417
663union acpi_ec_query_data { 418struct acpi_ec_query_data {
664 acpi_handle handle; 419 acpi_handle handle;
665 u8 data; 420 u8 data;
666}; 421};
667 422
668static void acpi_ec_gpe_query(void *ec_cxt) 423static void acpi_ec_gpe_query(void *ec_cxt)
669{ 424{
670 if (acpi_ec_poll_mode) 425 struct acpi_ec *ec = (struct acpi_ec *)ec_cxt;
671 acpi_ec_gpe_poll_query(ec_cxt); 426 u8 value = 0;
672 else 427 static char object_name[8];
673 acpi_ec_gpe_intr_query(ec_cxt);
674}
675
676static void acpi_ec_gpe_poll_query(void *ec_cxt)
677{
678 union acpi_ec *ec = (union acpi_ec *)ec_cxt;
679 u32 value = 0;
680 static char object_name[5] = { '_', 'Q', '0', '0', '\0' };
681 const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
682 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
683 };
684
685 428
686 if (!ec_cxt) 429 if (!ec)
687 goto end; 430 goto end;
688 431
689 if (down_interruptible (&ec->poll.sem)) { 432 value = acpi_ec_read_status(ec);
690 return; 433
691 }
692 acpi_hw_low_level_read(8, &value, &ec->common.command_addr);
693 up(&ec->poll.sem);
694
695 /* TBD: Implement asynch events!
696 * NOTE: All we care about are EC-SCI's. Other EC events are
697 * handled via polling (yuck!). This is because some systems
698 * treat EC-SCIs as level (versus EDGE!) triggered, preventing
699 * a purely interrupt-driven approach (grumble, grumble).
700 */
701 if (!(value & ACPI_EC_FLAG_SCI)) 434 if (!(value & ACPI_EC_FLAG_SCI))
702 goto end; 435 goto end;
703 436
704 if (acpi_ec_query(ec, &value)) 437 if (acpi_ec_query(ec, &value))
705 goto end; 438 goto end;
706 439
707 object_name[2] = hex[((value >> 4) & 0x0F)]; 440 snprintf(object_name, 8, "_Q%2.2X", value);
708 object_name[3] = hex[(value & 0x0F)];
709
710 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
711 441
712 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL); 442 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name));
713 443
714 end: 444 acpi_evaluate_object(ec->handle, object_name, NULL, NULL);
715 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR);
716}
717static void acpi_ec_gpe_intr_query(void *ec_cxt)
718{
719 union acpi_ec *ec = (union acpi_ec *)ec_cxt;
720 u32 value;
721 int result = -ENODATA;
722 static char object_name[5] = { '_', 'Q', '0', '0', '\0' };
723 const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
724 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
725 };
726 445
727
728 if (acpi_ec_read_status(ec) & ACPI_EC_FLAG_SCI)
729 result = acpi_ec_query(ec, &value);
730
731 if (result)
732 goto end;
733
734 object_name[2] = hex[((value >> 4) & 0x0F)];
735 object_name[3] = hex[(value & 0x0F)];
736
737 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s\n", object_name));
738
739 acpi_evaluate_object(ec->common.handle, object_name, NULL, NULL);
740 end: 446 end:
741 atomic_dec(&ec->intr.pending_gpe); 447 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
742 return;
743} 448}
744 449
745static u32 acpi_ec_gpe_handler(void *data) 450static u32 acpi_ec_gpe_handler(void *data)
746{ 451{
747 if (acpi_ec_poll_mode)
748 return acpi_ec_gpe_poll_handler(data);
749 else
750 return acpi_ec_gpe_intr_handler(data);
751}
752static u32 acpi_ec_gpe_poll_handler(void *data)
753{
754 acpi_status status = AE_OK; 452 acpi_status status = AE_OK;
755 union acpi_ec *ec = (union acpi_ec *)data; 453 u8 value;
756 454 struct acpi_ec *ec = (struct acpi_ec *)data;
757 if (!ec)
758 return ACPI_INTERRUPT_NOT_HANDLED;
759
760 acpi_disable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR);
761
762 status = acpi_os_execute(OSL_EC_POLL_HANDLER, acpi_ec_gpe_query, ec);
763
764 if (status == AE_OK)
765 return ACPI_INTERRUPT_HANDLED;
766 else
767 return ACPI_INTERRUPT_NOT_HANDLED;
768}
769static u32 acpi_ec_gpe_intr_handler(void *data)
770{
771 acpi_status status = AE_OK;
772 u32 value;
773 union acpi_ec *ec = (union acpi_ec *)data;
774
775 if (!ec)
776 return ACPI_INTERRUPT_NOT_HANDLED;
777 455
778 acpi_clear_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); 456 acpi_clear_gpe(NULL, ec->gpe_bit, ACPI_ISR);
779 value = acpi_ec_read_status(ec); 457 value = acpi_ec_read_status(ec);
780 458
781 switch (ec->intr.expect_event) { 459 if (acpi_ec_mode == EC_INTR) {
782 case ACPI_EC_EVENT_OBF: 460 if (acpi_ec_check_status(value, ec->expect_event)) {
783 if (!(value & ACPI_EC_FLAG_OBF)) 461 ec->expect_event = 0;
784 break; 462 wake_up(&ec->wait);
785 ec->intr.expect_event = 0; 463 }
786 wake_up(&ec->intr.wait);
787 break;
788 case ACPI_EC_EVENT_IBE:
789 if ((value & ACPI_EC_FLAG_IBF))
790 break;
791 ec->intr.expect_event = 0;
792 wake_up(&ec->intr.wait);
793 break;
794 default:
795 break;
796 } 464 }
797 465
798 if (value & ACPI_EC_FLAG_SCI) { 466 if (value & ACPI_EC_FLAG_SCI) {
799 atomic_add(1, &ec->intr.pending_gpe); 467 status = acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, ec);
800 status = acpi_os_execute(OSL_EC_BURST_HANDLER,
801 acpi_ec_gpe_query, ec);
802 return status == AE_OK ? 468 return status == AE_OK ?
803 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 469 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
804 } 470 }
805 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_ISR); 471 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_ISR);
806 return status == AE_OK ? 472 return status == AE_OK ?
807 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED; 473 ACPI_INTERRUPT_HANDLED : ACPI_INTERRUPT_NOT_HANDLED;
808} 474}
@@ -833,7 +499,7 @@ acpi_ec_space_handler(u32 function,
833 void *handler_context, void *region_context) 499 void *handler_context, void *region_context)
834{ 500{
835 int result = 0; 501 int result = 0;
836 union acpi_ec *ec = NULL; 502 struct acpi_ec *ec = NULL;
837 u64 temp = *value; 503 u64 temp = *value;
838 acpi_integer f_v = 0; 504 acpi_integer f_v = 0;
839 int i = 0; 505 int i = 0;
@@ -843,18 +509,16 @@ acpi_ec_space_handler(u32 function,
843 return AE_BAD_PARAMETER; 509 return AE_BAD_PARAMETER;
844 510
845 if (bit_width != 8 && acpi_strict) { 511 if (bit_width != 8 && acpi_strict) {
846 printk(KERN_WARNING PREFIX
847 "acpi_ec_space_handler: bit_width should be 8\n");
848 return AE_BAD_PARAMETER; 512 return AE_BAD_PARAMETER;
849 } 513 }
850 514
851 ec = (union acpi_ec *)handler_context; 515 ec = (struct acpi_ec *)handler_context;
852 516
853 next_byte: 517 next_byte:
854 switch (function) { 518 switch (function) {
855 case ACPI_READ: 519 case ACPI_READ:
856 temp = 0; 520 temp = 0;
857 result = acpi_ec_read(ec, (u8) address, (u32 *) & temp); 521 result = acpi_ec_read(ec, (u8) address, (u8 *) &temp);
858 break; 522 break;
859 case ACPI_WRITE: 523 case ACPI_WRITE:
860 result = acpi_ec_write(ec, (u8) address, (u8) temp); 524 result = acpi_ec_write(ec, (u8) address, (u8) temp);
@@ -905,20 +569,20 @@ static struct proc_dir_entry *acpi_ec_dir;
905 569
906static int acpi_ec_read_info(struct seq_file *seq, void *offset) 570static int acpi_ec_read_info(struct seq_file *seq, void *offset)
907{ 571{
908 union acpi_ec *ec = (union acpi_ec *)seq->private; 572 struct acpi_ec *ec = (struct acpi_ec *)seq->private;
909 573
910 574
911 if (!ec) 575 if (!ec)
912 goto end; 576 goto end;
913 577
914 seq_printf(seq, "gpe bit: 0x%02x\n", 578 seq_printf(seq, "gpe bit: 0x%02x\n",
915 (u32) ec->common.gpe_bit); 579 (u32) ec->gpe_bit);
916 seq_printf(seq, "ports: 0x%02x, 0x%02x\n", 580 seq_printf(seq, "ports: 0x%02x, 0x%02x\n",
917 (u32) ec->common.status_addr.address, 581 (u32) ec->command_addr,
918 (u32) ec->common.data_addr.address); 582 (u32) ec->data_addr);
919 seq_printf(seq, "use global lock: %s\n", 583 seq_printf(seq, "use global lock: %s\n",
920 ec->common.global_lock ? "yes" : "no"); 584 ec->global_lock ? "yes" : "no");
921 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 585 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
922 586
923 end: 587 end:
924 return 0; 588 return 0;
@@ -929,7 +593,7 @@ static int acpi_ec_info_open_fs(struct inode *inode, struct file *file)
929 return single_open(file, acpi_ec_read_info, PDE(inode)->data); 593 return single_open(file, acpi_ec_read_info, PDE(inode)->data);
930} 594}
931 595
932static const struct file_operations acpi_ec_info_ops = { 596static struct file_operations acpi_ec_info_ops = {
933 .open = acpi_ec_info_open_fs, 597 .open = acpi_ec_info_open_fs,
934 .read = seq_read, 598 .read = seq_read,
935 .llseek = seq_lseek, 599 .llseek = seq_lseek,
@@ -978,101 +642,35 @@ static int acpi_ec_remove_fs(struct acpi_device *device)
978 Driver Interface 642 Driver Interface
979 -------------------------------------------------------------------------- */ 643 -------------------------------------------------------------------------- */
980 644
981static int acpi_ec_poll_add(struct acpi_device *device) 645static int acpi_ec_add(struct acpi_device *device)
982{ 646{
983 int result = 0; 647 int result = 0;
984 acpi_status status = AE_OK; 648 acpi_status status = AE_OK;
985 union acpi_ec *ec = NULL; 649 struct acpi_ec *ec = NULL;
986 650
987 651
988 if (!device) 652 if (!device)
989 return -EINVAL; 653 return -EINVAL;
990 654
991 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); 655 ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
992 if (!ec) 656 if (!ec)
993 return -ENOMEM; 657 return -ENOMEM;
994 memset(ec, 0, sizeof(union acpi_ec)); 658 memset(ec, 0, sizeof(struct acpi_ec));
995 659
996 ec->common.handle = device->handle; 660 ec->handle = device->handle;
997 ec->common.uid = -1; 661 ec->uid = -1;
998 init_MUTEX(&ec->poll.sem); 662 init_MUTEX(&ec->sem);
999 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 663 if (acpi_ec_mode == EC_INTR) {
1000 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 664 atomic_set(&ec->leaving_burst, 1);
1001 acpi_driver_data(device) = ec; 665 init_waitqueue_head(&ec->wait);
1002
1003 /* Use the global lock for all EC transactions? */
1004 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL,
1005 &ec->common.global_lock);
1006
1007 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
1008 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
1009 if (ec_ecdt) {
1010 acpi_remove_address_space_handler(ACPI_ROOT_OBJECT,
1011 ACPI_ADR_SPACE_EC,
1012 &acpi_ec_space_handler);
1013
1014 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit,
1015 &acpi_ec_gpe_handler);
1016
1017 kfree(ec_ecdt);
1018 } 666 }
1019
1020 /* Get GPE bit assignment (EC events). */
1021 /* TODO: Add support for _GPE returning a package */
1022 status =
1023 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL,
1024 &ec->common.gpe_bit);
1025 if (ACPI_FAILURE(status)) {
1026 ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit"));
1027 result = -ENODEV;
1028 goto end;
1029 }
1030
1031 result = acpi_ec_add_fs(device);
1032 if (result)
1033 goto end;
1034
1035 printk(KERN_INFO PREFIX "%s [%s] (gpe %d) polling mode.\n",
1036 acpi_device_name(device), acpi_device_bid(device),
1037 (u32) ec->common.gpe_bit);
1038
1039 if (!first_ec)
1040 first_ec = device;
1041
1042 end:
1043 if (result)
1044 kfree(ec);
1045
1046 return result;
1047}
1048static int acpi_ec_intr_add(struct acpi_device *device)
1049{
1050 int result = 0;
1051 acpi_status status = AE_OK;
1052 union acpi_ec *ec = NULL;
1053
1054
1055 if (!device)
1056 return -EINVAL;
1057
1058 ec = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1059 if (!ec)
1060 return -ENOMEM;
1061 memset(ec, 0, sizeof(union acpi_ec));
1062
1063 ec->common.handle = device->handle;
1064 ec->common.uid = -1;
1065 atomic_set(&ec->intr.pending_gpe, 0);
1066 atomic_set(&ec->intr.leaving_burst, 1);
1067 init_MUTEX(&ec->intr.sem);
1068 init_waitqueue_head(&ec->intr.wait);
1069 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME); 667 strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
1070 strcpy(acpi_device_class(device), ACPI_EC_CLASS); 668 strcpy(acpi_device_class(device), ACPI_EC_CLASS);
1071 acpi_driver_data(device) = ec; 669 acpi_driver_data(device) = ec;
1072 670
1073 /* Use the global lock for all EC transactions? */ 671 /* Use the global lock for all EC transactions? */
1074 acpi_evaluate_integer(ec->common.handle, "_GLK", NULL, 672 acpi_evaluate_integer(ec->handle, "_GLK", NULL,
1075 &ec->common.global_lock); 673 &ec->global_lock);
1076 674
1077 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see: 675 /* XXX we don't test uids, because on some boxes ecdt uid = 0, see:
1078 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */ 676 http://bugzilla.kernel.org/show_bug.cgi?id=6111 */
@@ -1081,7 +679,7 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1081 ACPI_ADR_SPACE_EC, 679 ACPI_ADR_SPACE_EC,
1082 &acpi_ec_space_handler); 680 &acpi_ec_space_handler);
1083 681
1084 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, 682 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit,
1085 &acpi_ec_gpe_handler); 683 &acpi_ec_gpe_handler);
1086 684
1087 kfree(ec_ecdt); 685 kfree(ec_ecdt);
@@ -1090,10 +688,10 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1090 /* Get GPE bit assignment (EC events). */ 688 /* Get GPE bit assignment (EC events). */
1091 /* TODO: Add support for _GPE returning a package */ 689 /* TODO: Add support for _GPE returning a package */
1092 status = 690 status =
1093 acpi_evaluate_integer(ec->common.handle, "_GPE", NULL, 691 acpi_evaluate_integer(ec->handle, "_GPE", NULL,
1094 &ec->common.gpe_bit); 692 &ec->gpe_bit);
1095 if (ACPI_FAILURE(status)) { 693 if (ACPI_FAILURE(status)) {
1096 printk(KERN_ERR PREFIX "Obtaining GPE bit assignment\n"); 694 ACPI_EXCEPTION((AE_INFO, status, "Obtaining GPE bit assignment"));
1097 result = -ENODEV; 695 result = -ENODEV;
1098 goto end; 696 goto end;
1099 } 697 }
@@ -1102,14 +700,14 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1102 if (result) 700 if (result)
1103 goto end; 701 goto end;
1104 702
1105 printk(KERN_INFO PREFIX "%s [%s] (gpe %d) interrupt mode.\n", 703 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
1106 acpi_device_name(device), acpi_device_bid(device), 704 acpi_device_name(device), acpi_device_bid(device),
1107 (u32) ec->common.gpe_bit); 705 (u32) ec->gpe_bit));
1108 706
1109 if (!first_ec) 707 if (!first_ec)
1110 first_ec = device; 708 first_ec = device;
1111 709
1112 end: 710 end:
1113 if (result) 711 if (result)
1114 kfree(ec); 712 kfree(ec);
1115 713
@@ -1118,7 +716,7 @@ static int acpi_ec_intr_add(struct acpi_device *device)
1118 716
1119static int acpi_ec_remove(struct acpi_device *device, int type) 717static int acpi_ec_remove(struct acpi_device *device, int type)
1120{ 718{
1121 union acpi_ec *ec = NULL; 719 struct acpi_ec *ec = NULL;
1122 720
1123 721
1124 if (!device) 722 if (!device)
@@ -1136,8 +734,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
1136static acpi_status 734static acpi_status
1137acpi_ec_io_ports(struct acpi_resource *resource, void *context) 735acpi_ec_io_ports(struct acpi_resource *resource, void *context)
1138{ 736{
1139 union acpi_ec *ec = (union acpi_ec *)context; 737 struct acpi_ec *ec = (struct acpi_ec *)context;
1140 struct acpi_generic_address *addr;
1141 738
1142 if (resource->type != ACPI_RESOURCE_TYPE_IO) { 739 if (resource->type != ACPI_RESOURCE_TYPE_IO) {
1143 return AE_OK; 740 return AE_OK;
@@ -1148,26 +745,21 @@ acpi_ec_io_ports(struct acpi_resource *resource, void *context)
1148 * the second address region returned is the status/command 745 * the second address region returned is the status/command
1149 * port. 746 * port.
1150 */ 747 */
1151 if (ec->common.data_addr.register_bit_width == 0) { 748 if (ec->data_addr == 0) {
1152 addr = &ec->common.data_addr; 749 ec->data_addr = resource->data.io.minimum;
1153 } else if (ec->common.command_addr.register_bit_width == 0) { 750 } else if (ec->command_addr == 0) {
1154 addr = &ec->common.command_addr; 751 ec->command_addr = resource->data.io.minimum;
1155 } else { 752 } else {
1156 return AE_CTRL_TERMINATE; 753 return AE_CTRL_TERMINATE;
1157 } 754 }
1158 755
1159 addr->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO;
1160 addr->register_bit_width = 8;
1161 addr->register_bit_offset = 0;
1162 addr->address = resource->data.io.minimum;
1163
1164 return AE_OK; 756 return AE_OK;
1165} 757}
1166 758
1167static int acpi_ec_start(struct acpi_device *device) 759static int acpi_ec_start(struct acpi_device *device)
1168{ 760{
1169 acpi_status status = AE_OK; 761 acpi_status status = AE_OK;
1170 union acpi_ec *ec = NULL; 762 struct acpi_ec *ec = NULL;
1171 763
1172 764
1173 if (!device) 765 if (!device)
@@ -1181,39 +773,35 @@ static int acpi_ec_start(struct acpi_device *device)
1181 /* 773 /*
1182 * Get I/O port addresses. Convert to GAS format. 774 * Get I/O port addresses. Convert to GAS format.
1183 */ 775 */
1184 status = acpi_walk_resources(ec->common.handle, METHOD_NAME__CRS, 776 status = acpi_walk_resources(ec->handle, METHOD_NAME__CRS,
1185 acpi_ec_io_ports, ec); 777 acpi_ec_io_ports, ec);
1186 if (ACPI_FAILURE(status) 778 if (ACPI_FAILURE(status) || ec->command_addr == 0) {
1187 || ec->common.command_addr.register_bit_width == 0) { 779 ACPI_EXCEPTION((AE_INFO, status,
1188 printk(KERN_ERR PREFIX "Error getting I/O port addresses\n"); 780 "Error getting I/O port addresses"));
1189 return -ENODEV; 781 return -ENODEV;
1190 } 782 }
1191 783
1192 ec->common.status_addr = ec->common.command_addr; 784 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
1193 785 ec->gpe_bit, ec->command_addr, ec->data_addr));
1194 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02x, ports=0x%2x,0x%2x\n",
1195 (u32) ec->common.gpe_bit,
1196 (u32) ec->common.command_addr.address,
1197 (u32) ec->common.data_addr.address));
1198 786
1199 /* 787 /*
1200 * Install GPE handler 788 * Install GPE handler
1201 */ 789 */
1202 status = acpi_install_gpe_handler(NULL, ec->common.gpe_bit, 790 status = acpi_install_gpe_handler(NULL, ec->gpe_bit,
1203 ACPI_GPE_EDGE_TRIGGERED, 791 ACPI_GPE_EDGE_TRIGGERED,
1204 &acpi_ec_gpe_handler, ec); 792 &acpi_ec_gpe_handler, ec);
1205 if (ACPI_FAILURE(status)) { 793 if (ACPI_FAILURE(status)) {
1206 return -ENODEV; 794 return -ENODEV;
1207 } 795 }
1208 acpi_set_gpe_type(NULL, ec->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); 796 acpi_set_gpe_type(NULL, ec->gpe_bit, ACPI_GPE_TYPE_RUNTIME);
1209 acpi_enable_gpe(NULL, ec->common.gpe_bit, ACPI_NOT_ISR); 797 acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR);
1210 798
1211 status = acpi_install_address_space_handler(ec->common.handle, 799 status = acpi_install_address_space_handler(ec->handle,
1212 ACPI_ADR_SPACE_EC, 800 ACPI_ADR_SPACE_EC,
1213 &acpi_ec_space_handler, 801 &acpi_ec_space_handler,
1214 &acpi_ec_space_setup, ec); 802 &acpi_ec_space_setup, ec);
1215 if (ACPI_FAILURE(status)) { 803 if (ACPI_FAILURE(status)) {
1216 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, 804 acpi_remove_gpe_handler(NULL, ec->gpe_bit,
1217 &acpi_ec_gpe_handler); 805 &acpi_ec_gpe_handler);
1218 return -ENODEV; 806 return -ENODEV;
1219 } 807 }
@@ -1224,7 +812,7 @@ static int acpi_ec_start(struct acpi_device *device)
1224static int acpi_ec_stop(struct acpi_device *device, int type) 812static int acpi_ec_stop(struct acpi_device *device, int type)
1225{ 813{
1226 acpi_status status = AE_OK; 814 acpi_status status = AE_OK;
1227 union acpi_ec *ec = NULL; 815 struct acpi_ec *ec = NULL;
1228 816
1229 817
1230 if (!device) 818 if (!device)
@@ -1232,14 +820,14 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
1232 820
1233 ec = acpi_driver_data(device); 821 ec = acpi_driver_data(device);
1234 822
1235 status = acpi_remove_address_space_handler(ec->common.handle, 823 status = acpi_remove_address_space_handler(ec->handle,
1236 ACPI_ADR_SPACE_EC, 824 ACPI_ADR_SPACE_EC,
1237 &acpi_ec_space_handler); 825 &acpi_ec_space_handler);
1238 if (ACPI_FAILURE(status)) 826 if (ACPI_FAILURE(status))
1239 return -ENODEV; 827 return -ENODEV;
1240 828
1241 status = 829 status =
1242 acpi_remove_gpe_handler(NULL, ec->common.gpe_bit, 830 acpi_remove_gpe_handler(NULL, ec->gpe_bit,
1243 &acpi_ec_gpe_handler); 831 &acpi_ec_gpe_handler);
1244 if (ACPI_FAILURE(status)) 832 if (ACPI_FAILURE(status))
1245 return -ENODEV; 833 return -ENODEV;
@@ -1251,76 +839,30 @@ static acpi_status __init
1251acpi_fake_ecdt_callback(acpi_handle handle, 839acpi_fake_ecdt_callback(acpi_handle handle,
1252 u32 Level, void *context, void **retval) 840 u32 Level, void *context, void **retval)
1253{ 841{
1254
1255 if (acpi_ec_poll_mode)
1256 return acpi_fake_ecdt_poll_callback(handle,
1257 Level, context, retval);
1258 else
1259 return acpi_fake_ecdt_intr_callback(handle,
1260 Level, context, retval);
1261}
1262
1263static acpi_status __init
1264acpi_fake_ecdt_poll_callback(acpi_handle handle,
1265 u32 Level, void *context, void **retval)
1266{
1267 acpi_status status;
1268
1269 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1270 acpi_ec_io_ports, ec_ecdt);
1271 if (ACPI_FAILURE(status))
1272 return status;
1273 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
1274
1275 ec_ecdt->common.uid = -1;
1276 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid);
1277
1278 status =
1279 acpi_evaluate_integer(handle, "_GPE", NULL,
1280 &ec_ecdt->common.gpe_bit);
1281 if (ACPI_FAILURE(status))
1282 return status;
1283 init_MUTEX(&ec_ecdt->poll.sem);
1284 ec_ecdt->common.global_lock = TRUE;
1285 ec_ecdt->common.handle = handle;
1286
1287 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n",
1288 (u32) ec_ecdt->common.gpe_bit,
1289 (u32) ec_ecdt->common.command_addr.address,
1290 (u32) ec_ecdt->common.data_addr.address);
1291
1292 return AE_CTRL_TERMINATE;
1293}
1294
1295static acpi_status __init
1296acpi_fake_ecdt_intr_callback(acpi_handle handle,
1297 u32 Level, void *context, void **retval)
1298{
1299 acpi_status status; 842 acpi_status status;
1300 843
1301 init_MUTEX(&ec_ecdt->intr.sem); 844 init_MUTEX(&ec_ecdt->sem);
1302 init_waitqueue_head(&ec_ecdt->intr.wait); 845 if (acpi_ec_mode == EC_INTR) {
846 init_waitqueue_head(&ec_ecdt->wait);
847 }
1303 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 848 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
1304 acpi_ec_io_ports, ec_ecdt); 849 acpi_ec_io_ports, ec_ecdt);
1305 if (ACPI_FAILURE(status)) 850 if (ACPI_FAILURE(status))
1306 return status; 851 return status;
1307 ec_ecdt->common.status_addr = ec_ecdt->common.command_addr;
1308 852
1309 ec_ecdt->common.uid = -1; 853 ec_ecdt->uid = -1;
1310 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->common.uid); 854 acpi_evaluate_integer(handle, "_UID", NULL, &ec_ecdt->uid);
1311 855
1312 status = 856 status =
1313 acpi_evaluate_integer(handle, "_GPE", NULL, 857 acpi_evaluate_integer(handle, "_GPE", NULL,
1314 &ec_ecdt->common.gpe_bit); 858 &ec_ecdt->gpe_bit);
1315 if (ACPI_FAILURE(status)) 859 if (ACPI_FAILURE(status))
1316 return status; 860 return status;
1317 ec_ecdt->common.global_lock = TRUE; 861 ec_ecdt->global_lock = TRUE;
1318 ec_ecdt->common.handle = handle; 862 ec_ecdt->handle = handle;
1319 863
1320 printk(KERN_INFO PREFIX "GPE=0x%02x, ports=0x%2x, 0x%2x\n", 864 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
1321 (u32) ec_ecdt->common.gpe_bit, 865 ec_ecdt->gpe_bit, ec_ecdt->command_addr, ec_ecdt->data_addr));
1322 (u32) ec_ecdt->common.command_addr.address,
1323 (u32) ec_ecdt->common.data_addr.address);
1324 866
1325 return AE_CTRL_TERMINATE; 867 return AE_CTRL_TERMINATE;
1326} 868}
@@ -1340,14 +882,14 @@ static int __init acpi_ec_fake_ecdt(void)
1340 acpi_status status; 882 acpi_status status;
1341 int ret = 0; 883 int ret = 0;
1342 884
1343 printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); 885 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Try to make an fake ECDT"));
1344 886
1345 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); 887 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
1346 if (!ec_ecdt) { 888 if (!ec_ecdt) {
1347 ret = -ENOMEM; 889 ret = -ENOMEM;
1348 goto error; 890 goto error;
1349 } 891 }
1350 memset(ec_ecdt, 0, sizeof(union acpi_ec)); 892 memset(ec_ecdt, 0, sizeof(struct acpi_ec));
1351 893
1352 status = acpi_get_devices(ACPI_EC_HID, 894 status = acpi_get_devices(ACPI_EC_HID,
1353 acpi_fake_ecdt_callback, NULL, NULL); 895 acpi_fake_ecdt_callback, NULL, NULL);
@@ -1355,24 +897,16 @@ static int __init acpi_ec_fake_ecdt(void)
1355 kfree(ec_ecdt); 897 kfree(ec_ecdt);
1356 ec_ecdt = NULL; 898 ec_ecdt = NULL;
1357 ret = -ENODEV; 899 ret = -ENODEV;
900 ACPI_EXCEPTION((AE_INFO, status, "Can't make an fake ECDT"));
1358 goto error; 901 goto error;
1359 } 902 }
1360 return 0; 903 return 0;
1361 error: 904 error:
1362 printk(KERN_ERR PREFIX "Can't make an fake ECDT\n");
1363 return ret; 905 return ret;
1364} 906}
1365 907
1366static int __init acpi_ec_get_real_ecdt(void) 908static int __init acpi_ec_get_real_ecdt(void)
1367{ 909{
1368 if (acpi_ec_poll_mode)
1369 return acpi_ec_poll_get_real_ecdt();
1370 else
1371 return acpi_ec_intr_get_real_ecdt();
1372}
1373
1374static int __init acpi_ec_poll_get_real_ecdt(void)
1375{
1376 acpi_status status; 910 acpi_status status;
1377 struct acpi_table_ecdt *ecdt_ptr; 911 struct acpi_table_ecdt *ecdt_ptr;
1378 912
@@ -1382,80 +916,36 @@ static int __init acpi_ec_poll_get_real_ecdt(void)
1382 if (ACPI_FAILURE(status)) 916 if (ACPI_FAILURE(status))
1383 return -ENODEV; 917 return -ENODEV;
1384 918
1385 printk(KERN_INFO PREFIX "Found ECDT\n"); 919 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT"));
1386 920
1387 /* 921 /*
1388 * Generate a temporary ec context to use until the namespace is scanned 922 * Generate a temporary ec context to use until the namespace is scanned
1389 */ 923 */
1390 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL); 924 ec_ecdt = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
1391 if (!ec_ecdt) 925 if (!ec_ecdt)
1392 return -ENOMEM; 926 return -ENOMEM;
1393 memset(ec_ecdt, 0, sizeof(union acpi_ec)); 927 memset(ec_ecdt, 0, sizeof(struct acpi_ec));
1394
1395 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1396 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1397 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
1398 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit;
1399 init_MUTEX(&ec_ecdt->poll.sem);
1400 /* use the GL just to be safe */
1401 ec_ecdt->common.global_lock = TRUE;
1402 ec_ecdt->common.uid = ecdt_ptr->uid;
1403 928
1404 status = 929 init_MUTEX(&ec_ecdt->sem);
1405 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); 930 if (acpi_ec_mode == EC_INTR) {
1406 if (ACPI_FAILURE(status)) { 931 init_waitqueue_head(&ec_ecdt->wait);
1407 goto error;
1408 } 932 }
1409 933 ec_ecdt->command_addr = ecdt_ptr->ec_control.address;
1410 return 0; 934 ec_ecdt->data_addr = ecdt_ptr->ec_data.address;
1411 error: 935 ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit;
1412 printk(KERN_ERR PREFIX "Could not use ECDT\n");
1413 kfree(ec_ecdt);
1414 ec_ecdt = NULL;
1415
1416 return -ENODEV;
1417}
1418
1419static int __init acpi_ec_intr_get_real_ecdt(void)
1420{
1421 acpi_status status;
1422 struct acpi_table_ecdt *ecdt_ptr;
1423
1424 status = acpi_get_firmware_table("ECDT", 1, ACPI_LOGICAL_ADDRESSING,
1425 (struct acpi_table_header **)
1426 &ecdt_ptr);
1427 if (ACPI_FAILURE(status))
1428 return -ENODEV;
1429
1430 printk(KERN_INFO PREFIX "Found ECDT\n");
1431
1432 /*
1433 * Generate a temporary ec context to use until the namespace is scanned
1434 */
1435 ec_ecdt = kmalloc(sizeof(union acpi_ec), GFP_KERNEL);
1436 if (!ec_ecdt)
1437 return -ENOMEM;
1438 memset(ec_ecdt, 0, sizeof(union acpi_ec));
1439
1440 init_MUTEX(&ec_ecdt->intr.sem);
1441 init_waitqueue_head(&ec_ecdt->intr.wait);
1442 ec_ecdt->common.command_addr = ecdt_ptr->ec_control;
1443 ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
1444 ec_ecdt->common.data_addr = ecdt_ptr->ec_data;
1445 ec_ecdt->common.gpe_bit = ecdt_ptr->gpe_bit;
1446 /* use the GL just to be safe */ 936 /* use the GL just to be safe */
1447 ec_ecdt->common.global_lock = TRUE; 937 ec_ecdt->global_lock = TRUE;
1448 ec_ecdt->common.uid = ecdt_ptr->uid; 938 ec_ecdt->uid = ecdt_ptr->uid;
1449 939
1450 status = 940 status =
1451 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->common.handle); 941 acpi_get_handle(NULL, ecdt_ptr->ec_id, &ec_ecdt->handle);
1452 if (ACPI_FAILURE(status)) { 942 if (ACPI_FAILURE(status)) {
1453 goto error; 943 goto error;
1454 } 944 }
1455 945
1456 return 0; 946 return 0;
1457 error: 947 error:
1458 printk(KERN_ERR PREFIX "Could not use ECDT\n"); 948 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
1459 kfree(ec_ecdt); 949 kfree(ec_ecdt);
1460 ec_ecdt = NULL; 950 ec_ecdt = NULL;
1461 951
@@ -1480,14 +970,14 @@ int __init acpi_ec_ecdt_probe(void)
1480 /* 970 /*
1481 * Install GPE handler 971 * Install GPE handler
1482 */ 972 */
1483 status = acpi_install_gpe_handler(NULL, ec_ecdt->common.gpe_bit, 973 status = acpi_install_gpe_handler(NULL, ec_ecdt->gpe_bit,
1484 ACPI_GPE_EDGE_TRIGGERED, 974 ACPI_GPE_EDGE_TRIGGERED,
1485 &acpi_ec_gpe_handler, ec_ecdt); 975 &acpi_ec_gpe_handler, ec_ecdt);
1486 if (ACPI_FAILURE(status)) { 976 if (ACPI_FAILURE(status)) {
1487 goto error; 977 goto error;
1488 } 978 }
1489 acpi_set_gpe_type(NULL, ec_ecdt->common.gpe_bit, ACPI_GPE_TYPE_RUNTIME); 979 acpi_set_gpe_type(NULL, ec_ecdt->gpe_bit, ACPI_GPE_TYPE_RUNTIME);
1490 acpi_enable_gpe(NULL, ec_ecdt->common.gpe_bit, ACPI_NOT_ISR); 980 acpi_enable_gpe(NULL, ec_ecdt->gpe_bit, ACPI_NOT_ISR);
1491 981
1492 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT, 982 status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
1493 ACPI_ADR_SPACE_EC, 983 ACPI_ADR_SPACE_EC,
@@ -1495,7 +985,7 @@ int __init acpi_ec_ecdt_probe(void)
1495 &acpi_ec_space_setup, 985 &acpi_ec_space_setup,
1496 ec_ecdt); 986 ec_ecdt);
1497 if (ACPI_FAILURE(status)) { 987 if (ACPI_FAILURE(status)) {
1498 acpi_remove_gpe_handler(NULL, ec_ecdt->common.gpe_bit, 988 acpi_remove_gpe_handler(NULL, ec_ecdt->gpe_bit,
1499 &acpi_ec_gpe_handler); 989 &acpi_ec_gpe_handler);
1500 goto error; 990 goto error;
1501 } 991 }
@@ -1503,7 +993,7 @@ int __init acpi_ec_ecdt_probe(void)
1503 return 0; 993 return 0;
1504 994
1505 error: 995 error:
1506 printk(KERN_ERR PREFIX "Could not use ECDT\n"); 996 ACPI_EXCEPTION((AE_INFO, status, "Could not use ECDT"));
1507 kfree(ec_ecdt); 997 kfree(ec_ecdt);
1508 ec_ecdt = NULL; 998 ec_ecdt = NULL;
1509 999
@@ -1562,13 +1052,13 @@ static int __init acpi_ec_set_intr_mode(char *str)
1562 return 0; 1052 return 0;
1563 1053
1564 if (intr) { 1054 if (intr) {
1565 acpi_ec_poll_mode = EC_INTR; 1055 acpi_ec_mode = EC_INTR;
1566 acpi_ec_driver.ops.add = acpi_ec_intr_add;
1567 } else { 1056 } else {
1568 acpi_ec_poll_mode = EC_POLL; 1057 acpi_ec_mode = EC_POLL;
1569 acpi_ec_driver.ops.add = acpi_ec_poll_add;
1570 } 1058 }
1571 printk(KERN_INFO PREFIX "EC %s mode.\n", intr ? "interrupt" : "polling"); 1059 acpi_ec_driver.ops.add = acpi_ec_add;
1060 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "EC %s mode.\n", intr ? "interrupt" : "polling"));
1061
1572 return 1; 1062 return 1;
1573} 1063}
1574 1064
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/events/evmisc.c
index 6eef4efddcf6..ee2a10bf9077 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/events/evmisc.c
@@ -342,20 +342,8 @@ static u32 acpi_ev_global_lock_handler(void *context)
342 if (acquired) { 342 if (acquired) {
343 343
344 /* Got the lock, now wake all threads waiting for it */ 344 /* Got the lock, now wake all threads waiting for it */
345
346 acpi_gbl_global_lock_acquired = TRUE; 345 acpi_gbl_global_lock_acquired = TRUE;
347 346 acpi_ev_global_lock_thread(context);
348 /* Run the Global Lock thread which will signal all waiting threads */
349
350 status =
351 acpi_os_execute(OSL_GLOBAL_LOCK_HANDLER,
352 acpi_ev_global_lock_thread, context);
353 if (ACPI_FAILURE(status)) {
354 ACPI_EXCEPTION((AE_INFO, status,
355 "Could not queue Global Lock thread"));
356
357 return (ACPI_INTERRUPT_NOT_HANDLED);
358 }
359 } 347 }
360 348
361 return (ACPI_INTERRUPT_HANDLED); 349 return (ACPI_INTERRUPT_HANDLED);
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c
index 5b3c7a85eb9a..203d1359190a 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/events/evrgnini.c
@@ -225,13 +225,12 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
225 if (! 225 if (!
226 (ACPI_STRNCMP 226 (ACPI_STRNCMP
227 (object_hID.value, PCI_ROOT_HID_STRING, 227 (object_hID.value, PCI_ROOT_HID_STRING,
228 sizeof(PCI_ROOT_HID_STRING)) 228 sizeof(PCI_ROOT_HID_STRING)))
229 || 229 ||
230 !(ACPI_STRNCMP 230 !(ACPI_STRNCMP
231 (object_hID.value, 231 (object_hID.value,
232 PCI_EXPRESS_ROOT_HID_STRING, 232 PCI_EXPRESS_ROOT_HID_STRING,
233 sizeof(PCI_EXPRESS_ROOT_HID_STRING))))) 233 sizeof(PCI_EXPRESS_ROOT_HID_STRING)))) {
234 {
235 234
236 /* Install a handler for this PCI root bridge */ 235 /* Install a handler for this PCI root bridge */
237 236
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
index 15fc12482ba0..003a9876c968 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -1702,13 +1702,11 @@ static struct ibm_struct ibms[] = {
1702 .name = "brightness", 1702 .name = "brightness",
1703 .read = brightness_read, 1703 .read = brightness_read,
1704 .write = brightness_write, 1704 .write = brightness_write,
1705 .experimental = 1,
1706 }, 1705 },
1707 { 1706 {
1708 .name = "volume", 1707 .name = "volume",
1709 .read = volume_read, 1708 .read = volume_read,
1710 .write = volume_write, 1709 .write = volume_write,
1711 .experimental = 1,
1712 }, 1710 },
1713 { 1711 {
1714 .name = "fan", 1712 .name = "fan",
diff --git a/drivers/acpi/motherboard.c b/drivers/acpi/motherboard.c
index ec6b7f9ede34..2e17ec75af03 100644
--- a/drivers/acpi/motherboard.c
+++ b/drivers/acpi/motherboard.c
@@ -48,6 +48,12 @@ ACPI_MODULE_NAME("acpi_motherboard")
48 * the io ports if they really know they can use it, while 48 * the io ports if they really know they can use it, while
49 * still preventing hotplug PCI devices from using it. 49 * still preventing hotplug PCI devices from using it.
50 */ 50 */
51
52/*
53 * When CONFIG_PNP is enabled, pnp/system.c binds to PNP0C01
54 * and PNP0C02, redundant with acpi_reserve_io_ranges().
55 * But acpi_reserve_io_ranges() is necessary for !CONFIG_PNP.
56 */
51static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data) 57static acpi_status acpi_reserve_io_ranges(struct acpi_resource *res, void *data)
52{ 58{
53 struct resource *requested_res = NULL; 59 struct resource *requested_res = NULL;
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 068fe4f100b0..c84286cbbe25 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -73,6 +73,7 @@ static unsigned int acpi_irq_irq;
73static acpi_osd_handler acpi_irq_handler; 73static acpi_osd_handler acpi_irq_handler;
74static void *acpi_irq_context; 74static void *acpi_irq_context;
75static struct workqueue_struct *kacpid_wq; 75static struct workqueue_struct *kacpid_wq;
76static struct workqueue_struct *kacpi_notify_wq;
76 77
77acpi_status acpi_os_initialize(void) 78acpi_status acpi_os_initialize(void)
78{ 79{
@@ -91,8 +92,9 @@ acpi_status acpi_os_initialize1(void)
91 return AE_NULL_ENTRY; 92 return AE_NULL_ENTRY;
92 } 93 }
93 kacpid_wq = create_singlethread_workqueue("kacpid"); 94 kacpid_wq = create_singlethread_workqueue("kacpid");
95 kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify");
94 BUG_ON(!kacpid_wq); 96 BUG_ON(!kacpid_wq);
95 97 BUG_ON(!kacpi_notify_wq);
96 return AE_OK; 98 return AE_OK;
97} 99}
98 100
@@ -104,6 +106,7 @@ acpi_status acpi_os_terminate(void)
104 } 106 }
105 107
106 destroy_workqueue(kacpid_wq); 108 destroy_workqueue(kacpid_wq);
109 destroy_workqueue(kacpi_notify_wq);
107 110
108 return AE_OK; 111 return AE_OK;
109} 112}
@@ -566,10 +569,7 @@ void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
566 569
567static void acpi_os_execute_deferred(void *context) 570static void acpi_os_execute_deferred(void *context)
568{ 571{
569 struct acpi_os_dpc *dpc = NULL; 572 struct acpi_os_dpc *dpc = (struct acpi_os_dpc *)context;
570
571
572 dpc = (struct acpi_os_dpc *)context;
573 if (!dpc) { 573 if (!dpc) {
574 printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); 574 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
575 return; 575 return;
@@ -604,14 +604,12 @@ acpi_status acpi_os_execute(acpi_execute_type type,
604 struct acpi_os_dpc *dpc; 604 struct acpi_os_dpc *dpc;
605 struct work_struct *task; 605 struct work_struct *task;
606 606
607 ACPI_FUNCTION_TRACE("os_queue_for_execution");
608
609 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, 607 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
610 "Scheduling function [%p(%p)] for deferred execution.\n", 608 "Scheduling function [%p(%p)] for deferred execution.\n",
611 function, context)); 609 function, context));
612 610
613 if (!function) 611 if (!function)
614 return_ACPI_STATUS(AE_BAD_PARAMETER); 612 return AE_BAD_PARAMETER;
615 613
616 /* 614 /*
617 * Allocate/initialize DPC structure. Note that this memory will be 615 * Allocate/initialize DPC structure. Note that this memory will be
@@ -624,26 +622,20 @@ acpi_status acpi_os_execute(acpi_execute_type type,
624 * from the same memory. 622 * from the same memory.
625 */ 623 */
626 624
627 dpc = 625 dpc = kmalloc(sizeof(struct acpi_os_dpc) +
628 kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct), 626 sizeof(struct work_struct), GFP_ATOMIC);
629 GFP_ATOMIC);
630 if (!dpc) 627 if (!dpc)
631 return_ACPI_STATUS(AE_NO_MEMORY); 628 return AE_NO_MEMORY;
632
633 dpc->function = function; 629 dpc->function = function;
634 dpc->context = context; 630 dpc->context = context;
635
636 task = (void *)(dpc + 1); 631 task = (void *)(dpc + 1);
637 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc); 632 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc);
638 633 if (!queue_work((type == OSL_NOTIFY_HANDLER)?
639 if (!queue_work(kacpid_wq, task)) { 634 kacpi_notify_wq : kacpid_wq, task)) {
640 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
641 "Call to queue_work() failed.\n"));
642 kfree(dpc);
643 status = AE_ERROR; 635 status = AE_ERROR;
636 kfree(dpc);
644 } 637 }
645 638 return status;
646 return_ACPI_STATUS(status);
647} 639}
648 640
649EXPORT_SYMBOL(acpi_os_execute); 641EXPORT_SYMBOL(acpi_os_execute);
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 7f3e7e77e794..d53bd9878ca2 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -307,7 +307,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
307 if (!link || !irq) 307 if (!link || !irq)
308 return -EINVAL; 308 return -EINVAL;
309 309
310 resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC); 310 resource = kmalloc(sizeof(*resource) + 1, irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL);
311 if (!resource) 311 if (!resource)
312 return -ENOMEM; 312 return -ENOMEM;
313 313
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index fec225d1b6b7..fe67a8af520e 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -216,10 +216,8 @@ static int acpi_power_off_device(acpi_handle handle)
216{ 216{
217 int result = 0; 217 int result = 0;
218 acpi_status status = AE_OK; 218 acpi_status status = AE_OK;
219 struct acpi_device *device = NULL;
220 struct acpi_power_resource *resource = NULL; 219 struct acpi_power_resource *resource = NULL;
221 220
222
223 result = acpi_power_get_context(handle, &resource); 221 result = acpi_power_get_context(handle, &resource);
224 if (result) 222 if (result)
225 return result; 223 return result;
@@ -230,13 +228,13 @@ static int acpi_power_off_device(acpi_handle handle)
230 if (resource->references) { 228 if (resource->references) {
231 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 229 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
232 "Resource [%s] is still in use, dereferencing\n", 230 "Resource [%s] is still in use, dereferencing\n",
233 device->pnp.bus_id)); 231 resource->device->pnp.bus_id));
234 return 0; 232 return 0;
235 } 233 }
236 234
237 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) { 235 if (resource->state == ACPI_POWER_RESOURCE_STATE_OFF) {
238 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n", 236 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] already off\n",
239 device->pnp.bus_id)); 237 resource->device->pnp.bus_id));
240 return 0; 238 return 0;
241 } 239 }
242 240
@@ -251,8 +249,7 @@ static int acpi_power_off_device(acpi_handle handle)
251 return -ENOEXEC; 249 return -ENOEXEC;
252 250
253 /* Update the power resource's _device_ power state */ 251 /* Update the power resource's _device_ power state */
254 device = resource->device; 252 resource->device->power.state = ACPI_STATE_D3;
255 device->power.state = ACPI_STATE_D3;
256 253
257 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", 254 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n",
258 resource->name)); 255 resource->name));
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index b13d64415b7a..1908e0d20222 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -519,7 +519,7 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
519 519
520static void *processor_device_array[NR_CPUS]; 520static void *processor_device_array[NR_CPUS];
521 521
522static int acpi_processor_start(struct acpi_device *device) 522static int __cpuinit acpi_processor_start(struct acpi_device *device)
523{ 523{
524 int result = 0; 524 int result = 0;
525 acpi_status status = AE_OK; 525 acpi_status status = AE_OK;
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 0a395fca843b..e67144cf3c8b 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -219,6 +219,23 @@ static void acpi_safe_halt(void)
219 219
220static atomic_t c3_cpu_count; 220static atomic_t c3_cpu_count;
221 221
222/* Common C-state entry for C2, C3, .. */
223static void acpi_cstate_enter(struct acpi_processor_cx *cstate)
224{
225 if (cstate->space_id == ACPI_CSTATE_FFH) {
226 /* Call into architectural FFH based C-state */
227 acpi_processor_ffh_cstate_enter(cstate);
228 } else {
229 int unused;
230 /* IO port based C-state */
231 inb(cstate->address);
232 /* Dummy wait op - must do something useless after P_LVL2 read
233 because chipsets cannot guarantee that STPCLK# signal
234 gets asserted in time to freeze execution properly. */
235 unused = inl(acpi_fadt.xpm_tmr_blk.address);
236 }
237}
238
222static void acpi_processor_idle(void) 239static void acpi_processor_idle(void)
223{ 240{
224 struct acpi_processor *pr = NULL; 241 struct acpi_processor *pr = NULL;
@@ -361,11 +378,7 @@ static void acpi_processor_idle(void)
361 /* Get start time (ticks) */ 378 /* Get start time (ticks) */
362 t1 = inl(acpi_fadt.xpm_tmr_blk.address); 379 t1 = inl(acpi_fadt.xpm_tmr_blk.address);
363 /* Invoke C2 */ 380 /* Invoke C2 */
364 inb(cx->address); 381 acpi_cstate_enter(cx);
365 /* Dummy wait op - must do something useless after P_LVL2 read
366 because chipsets cannot guarantee that STPCLK# signal
367 gets asserted in time to freeze execution properly. */
368 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
369 /* Get end time (ticks) */ 382 /* Get end time (ticks) */
370 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 383 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
371 384
@@ -401,9 +414,7 @@ static void acpi_processor_idle(void)
401 /* Get start time (ticks) */ 414 /* Get start time (ticks) */
402 t1 = inl(acpi_fadt.xpm_tmr_blk.address); 415 t1 = inl(acpi_fadt.xpm_tmr_blk.address);
403 /* Invoke C3 */ 416 /* Invoke C3 */
404 inb(cx->address); 417 acpi_cstate_enter(cx);
405 /* Dummy wait op (see above) */
406 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
407 /* Get end time (ticks) */ 418 /* Get end time (ticks) */
408 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 419 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
409 if (pr->flags.bm_check) { 420 if (pr->flags.bm_check) {
@@ -628,20 +639,16 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
628 return 0; 639 return 0;
629} 640}
630 641
631static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr) 642static int acpi_processor_get_power_info_default(struct acpi_processor *pr)
632{ 643{
633 644 if (!pr->power.states[ACPI_STATE_C1].valid) {
634 /* Zero initialize all the C-states info. */ 645 /* set the first C-State to C1 */
635 memset(pr->power.states, 0, sizeof(pr->power.states)); 646 /* all processors need to support C1 */
636 647 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
637 /* set the first C-State to C1 */ 648 pr->power.states[ACPI_STATE_C1].valid = 1;
638 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1; 649 }
639 650 /* the C0 state only exists as a filler in our array */
640 /* the C0 state only exists as a filler in our array,
641 * and all processors need to support C1 */
642 pr->power.states[ACPI_STATE_C0].valid = 1; 651 pr->power.states[ACPI_STATE_C0].valid = 1;
643 pr->power.states[ACPI_STATE_C1].valid = 1;
644
645 return 0; 652 return 0;
646} 653}
647 654
@@ -658,12 +665,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
658 if (nocst) 665 if (nocst)
659 return -ENODEV; 666 return -ENODEV;
660 667
661 current_count = 1; 668 current_count = 0;
662
663 /* Zero initialize C2 onwards and prepare for fresh CST lookup */
664 for (i = 2; i < ACPI_PROCESSOR_MAX_POWER; i++)
665 memset(&(pr->power.states[i]), 0,
666 sizeof(struct acpi_processor_cx));
667 669
668 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer); 670 status = acpi_evaluate_object(pr->handle, "_CST", NULL, &buffer);
669 if (ACPI_FAILURE(status)) { 671 if (ACPI_FAILURE(status)) {
@@ -718,22 +720,39 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
718 (reg->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE)) 720 (reg->space_id != ACPI_ADR_SPACE_FIXED_HARDWARE))
719 continue; 721 continue;
720 722
721 cx.address = (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) ?
722 0 : reg->address;
723
724 /* There should be an easy way to extract an integer... */ 723 /* There should be an easy way to extract an integer... */
725 obj = (union acpi_object *)&(element->package.elements[1]); 724 obj = (union acpi_object *)&(element->package.elements[1]);
726 if (obj->type != ACPI_TYPE_INTEGER) 725 if (obj->type != ACPI_TYPE_INTEGER)
727 continue; 726 continue;
728 727
729 cx.type = obj->integer.value; 728 cx.type = obj->integer.value;
730 729 /*
731 if ((cx.type != ACPI_STATE_C1) && 730 * Some buggy BIOSes won't list C1 in _CST -
732 (reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO)) 731 * Let acpi_processor_get_power_info_default() handle them later
733 continue; 732 */
734 733 if (i == 1 && cx.type != ACPI_STATE_C1)
735 if ((cx.type < ACPI_STATE_C2) || (cx.type > ACPI_STATE_C3)) 734 current_count++;
736 continue; 735
736 cx.address = reg->address;
737 cx.index = current_count + 1;
738
739 cx.space_id = ACPI_CSTATE_SYSTEMIO;
740 if (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
741 if (acpi_processor_ffh_cstate_probe
742 (pr->id, &cx, reg) == 0) {
743 cx.space_id = ACPI_CSTATE_FFH;
744 } else if (cx.type != ACPI_STATE_C1) {
745 /*
746 * C1 is a special case where FIXED_HARDWARE
747 * can be handled in non-MWAIT way as well.
748 * In that case, save this _CST entry info.
749 * That is, we retain space_id of SYSTEM_IO for
750 * halt based C1.
751 * Otherwise, ignore this info and continue.
752 */
753 continue;
754 }
755 }
737 756
738 obj = (union acpi_object *)&(element->package.elements[2]); 757 obj = (union acpi_object *)&(element->package.elements[2]);
739 if (obj->type != ACPI_TYPE_INTEGER) 758 if (obj->type != ACPI_TYPE_INTEGER)
@@ -938,12 +957,18 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
938 /* NOTE: the idle thread may not be running while calling 957 /* NOTE: the idle thread may not be running while calling
939 * this function */ 958 * this function */
940 959
941 /* Adding C1 state */ 960 /* Zero initialize all the C-states info. */
942 acpi_processor_get_power_info_default_c1(pr); 961 memset(pr->power.states, 0, sizeof(pr->power.states));
962
943 result = acpi_processor_get_power_info_cst(pr); 963 result = acpi_processor_get_power_info_cst(pr);
944 if (result == -ENODEV) 964 if (result == -ENODEV)
945 acpi_processor_get_power_info_fadt(pr); 965 acpi_processor_get_power_info_fadt(pr);
946 966
967 if (result)
968 return result;
969
970 acpi_processor_get_power_info_default(pr);
971
947 pr->power.count = acpi_processor_power_verify(pr); 972 pr->power.count = acpi_processor_power_verify(pr);
948 973
949 /* 974 /*
@@ -1083,6 +1108,7 @@ static const struct file_operations acpi_processor_power_fops = {
1083 .release = single_release, 1108 .release = single_release,
1084}; 1109};
1085 1110
1111#ifdef CONFIG_SMP
1086static void smp_callback(void *v) 1112static void smp_callback(void *v)
1087{ 1113{
1088 /* we already woke the CPU up, nothing more to do */ 1114 /* we already woke the CPU up, nothing more to do */
@@ -1104,8 +1130,9 @@ static int acpi_processor_latency_notify(struct notifier_block *b,
1104static struct notifier_block acpi_processor_latency_notifier = { 1130static struct notifier_block acpi_processor_latency_notifier = {
1105 .notifier_call = acpi_processor_latency_notify, 1131 .notifier_call = acpi_processor_latency_notify,
1106}; 1132};
1133#endif
1107 1134
1108int acpi_processor_power_init(struct acpi_processor *pr, 1135int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1109 struct acpi_device *device) 1136 struct acpi_device *device)
1110{ 1137{
1111 acpi_status status = 0; 1138 acpi_status status = 0;
@@ -1121,7 +1148,9 @@ int acpi_processor_power_init(struct acpi_processor *pr,
1121 "ACPI: processor limited to max C-state %d\n", 1148 "ACPI: processor limited to max C-state %d\n",
1122 max_cstate); 1149 max_cstate);
1123 first_run++; 1150 first_run++;
1151#ifdef CONFIG_SMP
1124 register_latency_notifier(&acpi_processor_latency_notifier); 1152 register_latency_notifier(&acpi_processor_latency_notifier);
1153#endif
1125 } 1154 }
1126 1155
1127 if (!pr) 1156 if (!pr)
@@ -1193,7 +1222,9 @@ int acpi_processor_power_exit(struct acpi_processor *pr,
1193 * copies of pm_idle before proceeding. 1222 * copies of pm_idle before proceeding.
1194 */ 1223 */
1195 cpu_idle_wait(); 1224 cpu_idle_wait();
1225#ifdef CONFIG_SMP
1196 unregister_latency_notifier(&acpi_processor_latency_notifier); 1226 unregister_latency_notifier(&acpi_processor_latency_notifier);
1227#endif
1197 } 1228 }
1198 1229
1199 return 0; 1230 return 0;
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 62bef0b3b614..8908a975e575 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -98,11 +98,11 @@ static int update_info_mode = UPDATE_INFO_MODE;
98static int update_time = UPDATE_TIME; 98static int update_time = UPDATE_TIME;
99static int update_time2 = UPDATE_TIME2; 99static int update_time2 = UPDATE_TIME2;
100 100
101module_param(capacity_mode, int, CAPACITY_UNIT); 101module_param(capacity_mode, int, 0);
102module_param(update_mode, int, UPDATE_MODE); 102module_param(update_mode, int, 0);
103module_param(update_info_mode, int, UPDATE_INFO_MODE); 103module_param(update_info_mode, int, 0);
104module_param(update_time, int, UPDATE_TIME); 104module_param(update_time, int, 0);
105module_param(update_time2, int, UPDATE_TIME2); 105module_param(update_time2, int, 0);
106 106
107static int acpi_sbs_add(struct acpi_device *device); 107static int acpi_sbs_add(struct acpi_device *device);
108static int acpi_sbs_remove(struct acpi_device *device, int type); 108static int acpi_sbs_remove(struct acpi_device *device, int type);
@@ -1685,10 +1685,16 @@ static int acpi_sbs_add(struct acpi_device *device)
1685 1685
1686int acpi_sbs_remove(struct acpi_device *device, int type) 1686int acpi_sbs_remove(struct acpi_device *device, int type)
1687{ 1687{
1688 struct acpi_sbs *sbs = (struct acpi_sbs *)acpi_driver_data(device); 1688 struct acpi_sbs *sbs = NULL;
1689 int id; 1689 int id;
1690 1690
1691 if (!device || !sbs) { 1691 if (!device) {
1692 return -EINVAL;
1693 }
1694
1695 sbs = (struct acpi_sbs *)acpi_driver_data(device);
1696
1697 if (!sbs) {
1692 return -EINVAL; 1698 return -EINVAL;
1693 } 1699 }
1694 1700
diff --git a/drivers/acpi/tables/tbget.c b/drivers/acpi/tables/tbget.c
index 7856db759af0..11e2d4454e05 100644
--- a/drivers/acpi/tables/tbget.c
+++ b/drivers/acpi/tables/tbget.c
@@ -324,7 +324,7 @@ acpi_tb_get_this_table(struct acpi_pointer *address,
324 324
325 if (header->length < sizeof(struct acpi_table_header)) { 325 if (header->length < sizeof(struct acpi_table_header)) {
326 ACPI_ERROR((AE_INFO, 326 ACPI_ERROR((AE_INFO,
327 "Table length (%X) is smaller than minimum (%X)", 327 "Table length (%X) is smaller than minimum (%zX)",
328 header->length, sizeof(struct acpi_table_header))); 328 header->length, sizeof(struct acpi_table_header)));
329 329
330 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); 330 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index 0ad3dbb9ebca..86a5fca9b739 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -187,7 +187,7 @@ acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
187 187
188 if (table_ptr->length < sizeof(struct acpi_table_header)) { 188 if (table_ptr->length < sizeof(struct acpi_table_header)) {
189 ACPI_ERROR((AE_INFO, 189 ACPI_ERROR((AE_INFO,
190 "RSDT/XSDT length (%X) is smaller than minimum (%X)", 190 "RSDT/XSDT length (%X) is smaller than minimum (%zX)",
191 table_ptr->length, 191 table_ptr->length,
192 sizeof(struct acpi_table_header))); 192 sizeof(struct acpi_table_header)));
193 193
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 77138a39eb04..83728a9457ad 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -870,7 +870,11 @@ static unsigned int ata_id_xfermask(const u16 *id)
870 * the PIO timing number for the maximum. Turn it into 870 * the PIO timing number for the maximum. Turn it into
871 * a mask. 871 * a mask.
872 */ 872 */
873 pio_mask = (2 << (id[ATA_ID_OLD_PIO_MODES] & 0xFF)) - 1 ; 873 u8 mode = id[ATA_ID_OLD_PIO_MODES] & 0xFF;
874 if (mode < 5) /* Valid PIO range */
875 pio_mask = (2 << mode) - 1;
876 else
877 pio_mask = 1;
874 878
875 /* But wait.. there's more. Design your standards by 879 /* But wait.. there's more. Design your standards by
876 * committee and you too can get a free iordy field to 880 * committee and you too can get a free iordy field to
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index b0d0cc41f3e8..7af2a4ba4990 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -164,10 +164,10 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
164{ 164{
165 int rc = 0; 165 int rc = 0;
166 u8 scsi_cmd[MAX_COMMAND_SIZE]; 166 u8 scsi_cmd[MAX_COMMAND_SIZE];
167 u8 args[4], *argbuf = NULL; 167 u8 args[4], *argbuf = NULL, *sensebuf = NULL;
168 int argsize = 0; 168 int argsize = 0;
169 struct scsi_sense_hdr sshdr;
170 enum dma_data_direction data_dir; 169 enum dma_data_direction data_dir;
170 int cmd_result;
171 171
172 if (arg == NULL) 172 if (arg == NULL)
173 return -EINVAL; 173 return -EINVAL;
@@ -175,6 +175,10 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
175 if (copy_from_user(args, arg, sizeof(args))) 175 if (copy_from_user(args, arg, sizeof(args)))
176 return -EFAULT; 176 return -EFAULT;
177 177
178 sensebuf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_NOIO);
179 if (!sensebuf)
180 return -ENOMEM;
181
178 memset(scsi_cmd, 0, sizeof(scsi_cmd)); 182 memset(scsi_cmd, 0, sizeof(scsi_cmd));
179 183
180 if (args[3]) { 184 if (args[3]) {
@@ -191,7 +195,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
191 data_dir = DMA_FROM_DEVICE; 195 data_dir = DMA_FROM_DEVICE;
192 } else { 196 } else {
193 scsi_cmd[1] = (3 << 1); /* Non-data */ 197 scsi_cmd[1] = (3 << 1); /* Non-data */
194 /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */ 198 scsi_cmd[2] = 0x20; /* cc but no off.line or data xfer */
195 data_dir = DMA_NONE; 199 data_dir = DMA_NONE;
196 } 200 }
197 201
@@ -210,18 +214,46 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
210 214
211 /* Good values for timeout and retries? Values below 215 /* Good values for timeout and retries? Values below
212 from scsi_ioctl_send_command() for default case... */ 216 from scsi_ioctl_send_command() for default case... */
213 if (scsi_execute_req(scsidev, scsi_cmd, data_dir, argbuf, argsize, 217 cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize,
214 &sshdr, (10*HZ), 5)) { 218 sensebuf, (10*HZ), 5, 0);
219
220 if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */
221 u8 *desc = sensebuf + 8;
222 cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */
223
224 /* If we set cc then ATA pass-through will cause a
225 * check condition even if no error. Filter that. */
226 if (cmd_result & SAM_STAT_CHECK_CONDITION) {
227 struct scsi_sense_hdr sshdr;
228 scsi_normalize_sense(sensebuf, SCSI_SENSE_BUFFERSIZE,
229 &sshdr);
230 if (sshdr.sense_key==0 &&
231 sshdr.asc==0 && sshdr.ascq==0)
232 cmd_result &= ~SAM_STAT_CHECK_CONDITION;
233 }
234
235 /* Send userspace a few ATA registers (same as drivers/ide) */
236 if (sensebuf[0] == 0x72 && /* format is "descriptor" */
237 desc[0] == 0x09 ) { /* code is "ATA Descriptor" */
238 args[0] = desc[13]; /* status */
239 args[1] = desc[3]; /* error */
240 args[2] = desc[5]; /* sector count (0:7) */
241 if (copy_to_user(arg, args, sizeof(args)))
242 rc = -EFAULT;
243 }
244 }
245
246
247 if (cmd_result) {
215 rc = -EIO; 248 rc = -EIO;
216 goto error; 249 goto error;
217 } 250 }
218 251
219 /* Need code to retrieve data from check condition? */
220
221 if ((argbuf) 252 if ((argbuf)
222 && copy_to_user(arg + sizeof(args), argbuf, argsize)) 253 && copy_to_user(arg + sizeof(args), argbuf, argsize))
223 rc = -EFAULT; 254 rc = -EFAULT;
224error: 255error:
256 kfree(sensebuf);
225 kfree(argbuf); 257 kfree(argbuf);
226 return rc; 258 return rc;
227} 259}
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c
index 7977f471d5e9..2c3cc0ccc606 100644
--- a/drivers/ata/pata_qdi.c
+++ b/drivers/ata/pata_qdi.c
@@ -141,7 +141,7 @@ static void qdi_data_xfer(struct ata_device *adev, unsigned char *buf, unsigned
141 memcpy(&pad, buf + buflen - slop, slop); 141 memcpy(&pad, buf + buflen - slop, slop);
142 outl(le32_to_cpu(pad), ap->ioaddr.data_addr); 142 outl(le32_to_cpu(pad), ap->ioaddr.data_addr);
143 } else { 143 } else {
144 pad = cpu_to_le16(inl(ap->ioaddr.data_addr)); 144 pad = cpu_to_le32(inl(ap->ioaddr.data_addr));
145 memcpy(buf + buflen - slop, &pad, slop); 145 memcpy(buf + buflen - slop, &pad, slop);
146 } 146 }
147 } 147 }
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index 8bcdfa64667c..72eda5160fad 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -260,6 +260,7 @@ static const struct pci_device_id pdc_ata_pci_tbl[] = {
260#if 0 260#if 0
261 { PCI_VDEVICE(PROMISE, 0x3570), board_20771 }, 261 { PCI_VDEVICE(PROMISE, 0x3570), board_20771 },
262#endif 262#endif
263 { PCI_VDEVICE(PROMISE, 0x3577), board_20771 },
263 264
264 { } /* terminate list */ 265 { } /* terminate list */
265}; 266};
diff --git a/drivers/block/DAC960.h b/drivers/block/DAC960.h
index cec539e601fe..6148073532b2 100644
--- a/drivers/block/DAC960.h
+++ b/drivers/block/DAC960.h
@@ -4379,8 +4379,8 @@ static inline void DAC960_P_To_PD_TranslateEnquiry(void *Enquiry)
4379static inline void DAC960_P_To_PD_TranslateDeviceState(void *DeviceState) 4379static inline void DAC960_P_To_PD_TranslateDeviceState(void *DeviceState)
4380{ 4380{
4381 memcpy(DeviceState + 2, DeviceState + 3, 1); 4381 memcpy(DeviceState + 2, DeviceState + 3, 1);
4382 memcpy(DeviceState + 4, DeviceState + 5, 2); 4382 memmove(DeviceState + 4, DeviceState + 5, 2);
4383 memcpy(DeviceState + 6, DeviceState + 8, 4); 4383 memmove(DeviceState + 6, DeviceState + 8, 4);
4384} 4384}
4385 4385
4386static inline 4386static inline
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 5d254b714509..5d6562171533 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1709,10 +1709,13 @@ static struct kobject *floppy_find(dev_t dev, int *part, void *data)
1709 return get_disk(unit[drive].gendisk); 1709 return get_disk(unit[drive].gendisk);
1710} 1710}
1711 1711
1712int __init amiga_floppy_init(void) 1712static int __init amiga_floppy_init(void)
1713{ 1713{
1714 int i, ret; 1714 int i, ret;
1715 1715
1716 if (!MACH_IS_AMIGA)
1717 return -ENXIO;
1718
1716 if (!AMIGAHW_PRESENT(AMI_FLOPPY)) 1719 if (!AMIGAHW_PRESENT(AMI_FLOPPY))
1717 return -ENXIO; 1720 return -ENXIO;
1718 1721
@@ -1809,15 +1812,9 @@ out_blkdev:
1809 return ret; 1812 return ret;
1810} 1813}
1811 1814
1815module_init(amiga_floppy_init);
1812#ifdef MODULE 1816#ifdef MODULE
1813 1817
1814int init_module(void)
1815{
1816 if (!MACH_IS_AMIGA)
1817 return -ENXIO;
1818 return amiga_floppy_init();
1819}
1820
1821#if 0 /* not safe to unload */ 1818#if 0 /* not safe to unload */
1822void cleanup_module(void) 1819void cleanup_module(void)
1823{ 1820{
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index a3f64bfe6b58..485aa87e9bcd 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -432,6 +432,12 @@ static int __init rd_init(void)
432 rd_disks[i] = alloc_disk(1); 432 rd_disks[i] = alloc_disk(1);
433 if (!rd_disks[i]) 433 if (!rd_disks[i])
434 goto out; 434 goto out;
435
436 rd_queue[i] = blk_alloc_queue(GFP_KERNEL);
437 if (!rd_queue[i]) {
438 put_disk(rd_disks[i]);
439 goto out;
440 }
435 } 441 }
436 442
437 if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) { 443 if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) {
@@ -442,10 +448,6 @@ static int __init rd_init(void)
442 for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) { 448 for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) {
443 struct gendisk *disk = rd_disks[i]; 449 struct gendisk *disk = rd_disks[i];
444 450
445 rd_queue[i] = blk_alloc_queue(GFP_KERNEL);
446 if (!rd_queue[i])
447 goto out_queue;
448
449 blk_queue_make_request(rd_queue[i], &rd_make_request); 451 blk_queue_make_request(rd_queue[i], &rd_make_request);
450 blk_queue_hardsect_size(rd_queue[i], rd_blocksize); 452 blk_queue_hardsect_size(rd_queue[i], rd_blocksize);
451 453
@@ -466,8 +468,6 @@ static int __init rd_init(void)
466 CONFIG_BLK_DEV_RAM_COUNT, rd_size, rd_blocksize); 468 CONFIG_BLK_DEV_RAM_COUNT, rd_size, rd_blocksize);
467 469
468 return 0; 470 return 0;
469out_queue:
470 unregister_blkdev(RAMDISK_MAJOR, "ramdisk");
471out: 471out:
472 while (i--) { 472 while (i--) {
473 put_disk(rd_disks[i]); 473 put_disk(rd_disks[i]);
diff --git a/drivers/block/xd.c b/drivers/block/xd.c
index 10cc38783bdf..0d97b7eb818a 100644
--- a/drivers/block/xd.c
+++ b/drivers/block/xd.c
@@ -48,9 +48,9 @@
48#include <linux/blkdev.h> 48#include <linux/blkdev.h>
49#include <linux/blkpg.h> 49#include <linux/blkpg.h>
50#include <linux/delay.h> 50#include <linux/delay.h>
51#include <linux/io.h>
51 52
52#include <asm/system.h> 53#include <asm/system.h>
53#include <asm/io.h>
54#include <asm/uaccess.h> 54#include <asm/uaccess.h>
55#include <asm/dma.h> 55#include <asm/dma.h>
56 56
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index 82ddbdd7bd4b..7cc2685ca84a 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -329,7 +329,7 @@ static struct kobject *z2_find(dev_t dev, int *part, void *data)
329 329
330static struct request_queue *z2_queue; 330static struct request_queue *z2_queue;
331 331
332int __init 332static int __init
333z2_init(void) 333z2_init(void)
334{ 334{
335 int ret; 335 int ret;
@@ -370,26 +370,7 @@ err:
370 return ret; 370 return ret;
371} 371}
372 372
373#if defined(MODULE) 373static void __exit z2_exit(void)
374
375MODULE_LICENSE("GPL");
376
377int
378init_module( void )
379{
380 int error;
381
382 error = z2_init();
383 if ( error == 0 )
384 {
385 printk( KERN_INFO DEVICE_NAME ": loaded as module\n" );
386 }
387
388 return error;
389}
390
391void
392cleanup_module( void )
393{ 374{
394 int i, j; 375 int i, j;
395 blk_unregister_region(MKDEV(Z2RAM_MAJOR, 0), 256); 376 blk_unregister_region(MKDEV(Z2RAM_MAJOR, 0), 256);
@@ -425,4 +406,7 @@ cleanup_module( void )
425 406
426 return; 407 return;
427} 408}
428#endif 409
410module_init(z2_init);
411module_exit(z2_exit);
412MODULE_LICENSE("GPL");
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index 67cdda43f229..516751754aa9 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -29,7 +29,6 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <linux/timer.h>
33 32
34#include <linux/device.h> 33#include <linux/device.h>
35#include <linux/firmware.h> 34#include <linux/firmware.h>
@@ -43,7 +42,7 @@
43#define BT_DBG(D...) 42#define BT_DBG(D...)
44#endif 43#endif
45 44
46#define VERSION "1.0" 45#define VERSION "1.1"
47 46
48static int ignore = 0; 47static int ignore = 0;
49 48
@@ -72,7 +71,7 @@ struct bcm203x_data {
72 71
73 unsigned long state; 72 unsigned long state;
74 73
75 struct timer_list timer; 74 struct work_struct work;
76 75
77 struct urb *urb; 76 struct urb *urb;
78 unsigned char *buffer; 77 unsigned char *buffer;
@@ -105,7 +104,7 @@ static void bcm203x_complete(struct urb *urb)
105 104
106 data->state = BCM203X_SELECT_MEMORY; 105 data->state = BCM203X_SELECT_MEMORY;
107 106
108 mod_timer(&data->timer, jiffies + (HZ / 10)); 107 schedule_work(&data->work);
109 break; 108 break;
110 109
111 case BCM203X_SELECT_MEMORY: 110 case BCM203X_SELECT_MEMORY:
@@ -158,9 +157,9 @@ static void bcm203x_complete(struct urb *urb)
158 } 157 }
159} 158}
160 159
161static void bcm203x_timer(unsigned long user_data) 160static void bcm203x_work(void *user_data)
162{ 161{
163 struct bcm203x_data *data = (struct bcm203x_data *) user_data; 162 struct bcm203x_data *data = user_data;
164 163
165 if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0) 164 if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0)
166 BT_ERR("Can't submit URB"); 165 BT_ERR("Can't submit URB");
@@ -247,13 +246,11 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
247 246
248 release_firmware(firmware); 247 release_firmware(firmware);
249 248
250 init_timer(&data->timer); 249 INIT_WORK(&data->work, bcm203x_work, (void *) data);
251 data->timer.function = bcm203x_timer;
252 data->timer.data = (unsigned long) data;
253 250
254 usb_set_intfdata(intf, data); 251 usb_set_intfdata(intf, data);
255 252
256 mod_timer(&data->timer, jiffies + HZ); 253 schedule_work(&data->work);
257 254
258 return 0; 255 return 0;
259} 256}
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 0e6f35fcc2eb..39a9f8cc6412 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -1046,7 +1046,7 @@ source "drivers/char/tpm/Kconfig"
1046 1046
1047config TELCLOCK 1047config TELCLOCK
1048 tristate "Telecom clock driver for MPBL0010 ATCA SBC" 1048 tristate "Telecom clock driver for MPBL0010 ATCA SBC"
1049 depends on EXPERIMENTAL 1049 depends on EXPERIMENTAL && X86
1050 default n 1050 default n
1051 help 1051 help
1052 The telecom clock device is specific to the MPBL0010 ATCA computer and 1052 The telecom clock device is specific to the MPBL0010 ATCA computer and
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index c3f95583a120..706733c0b36a 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -1157,6 +1157,7 @@ static int __init pc_init(void)
1157 int crd; 1157 int crd;
1158 struct board_info *bd; 1158 struct board_info *bd;
1159 unsigned char board_id = 0; 1159 unsigned char board_id = 0;
1160 int err = -ENOMEM;
1160 1161
1161 int pci_boards_found, pci_count; 1162 int pci_boards_found, pci_count;
1162 1163
@@ -1164,13 +1165,11 @@ static int __init pc_init(void)
1164 1165
1165 pc_driver = alloc_tty_driver(MAX_ALLOC); 1166 pc_driver = alloc_tty_driver(MAX_ALLOC);
1166 if (!pc_driver) 1167 if (!pc_driver)
1167 return -ENOMEM; 1168 goto out1;
1168 1169
1169 pc_info = alloc_tty_driver(MAX_ALLOC); 1170 pc_info = alloc_tty_driver(MAX_ALLOC);
1170 if (!pc_info) { 1171 if (!pc_info)
1171 put_tty_driver(pc_driver); 1172 goto out2;
1172 return -ENOMEM;
1173 }
1174 1173
1175 /* ----------------------------------------------------------------------- 1174 /* -----------------------------------------------------------------------
1176 If epca_setup has not been ran by LILO set num_cards to defaults; copy 1175 If epca_setup has not been ran by LILO set num_cards to defaults; copy
@@ -1370,11 +1369,17 @@ static int __init pc_init(void)
1370 1369
1371 } /* End for each card */ 1370 } /* End for each card */
1372 1371
1373 if (tty_register_driver(pc_driver)) 1372 err = tty_register_driver(pc_driver);
1374 panic("Couldn't register Digi PC/ driver"); 1373 if (err) {
1374 printk(KERN_ERR "Couldn't register Digi PC/ driver");
1375 goto out3;
1376 }
1375 1377
1376 if (tty_register_driver(pc_info)) 1378 err = tty_register_driver(pc_info);
1377 panic("Couldn't register Digi PC/ info "); 1379 if (err) {
1380 printk(KERN_ERR "Couldn't register Digi PC/ info ");
1381 goto out4;
1382 }
1378 1383
1379 /* ------------------------------------------------------------------- 1384 /* -------------------------------------------------------------------
1380 Start up the poller to check for events on all enabled boards 1385 Start up the poller to check for events on all enabled boards
@@ -1385,6 +1390,15 @@ static int __init pc_init(void)
1385 mod_timer(&epca_timer, jiffies + HZ/25); 1390 mod_timer(&epca_timer, jiffies + HZ/25);
1386 return 0; 1391 return 0;
1387 1392
1393out4:
1394 tty_unregister_driver(pc_driver);
1395out3:
1396 put_tty_driver(pc_info);
1397out2:
1398 put_tty_driver(pc_driver);
1399out1:
1400 return err;
1401
1388} /* End pc_init */ 1402} /* End pc_init */
1389 1403
1390/* ------------------ Begin post_fep_init ---------------------- */ 1404/* ------------------ Begin post_fep_init ---------------------- */
diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c
index fc944d375be7..54d93f0345e8 100644
--- a/drivers/char/ip2/i2lib.c
+++ b/drivers/char/ip2/i2lib.c
@@ -1007,7 +1007,7 @@ i2InputAvailable(i2ChanStrPtr pCh)
1007// applications that one cannot break out of. 1007// applications that one cannot break out of.
1008//****************************************************************************** 1008//******************************************************************************
1009static int 1009static int
1010i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user ) 1010i2Output(i2ChanStrPtr pCh, const char *pSource, int count)
1011{ 1011{
1012 i2eBordStrPtr pB; 1012 i2eBordStrPtr pB;
1013 unsigned char *pInsert; 1013 unsigned char *pInsert;
@@ -1020,7 +1020,7 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user )
1020 1020
1021 int bailout = 10; 1021 int bailout = 10;
1022 1022
1023 ip2trace (CHANN, ITRC_OUTPUT, ITRC_ENTER, 2, count, user ); 1023 ip2trace (CHANN, ITRC_OUTPUT, ITRC_ENTER, 2, count, 0 );
1024 1024
1025 // Ensure channel structure seems real 1025 // Ensure channel structure seems real
1026 if ( !i2Validate ( pCh ) ) 1026 if ( !i2Validate ( pCh ) )
@@ -1087,12 +1087,7 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count, int user )
1087 DATA_COUNT_OF(pInsert) = amountToMove; 1087 DATA_COUNT_OF(pInsert) = amountToMove;
1088 1088
1089 // Move the data 1089 // Move the data
1090 if ( user ) { 1090 memcpy( (char*)(DATA_OF(pInsert)), pSource, amountToMove );
1091 rc = copy_from_user((char*)(DATA_OF(pInsert)), pSource,
1092 amountToMove );
1093 } else {
1094 memcpy( (char*)(DATA_OF(pInsert)), pSource, amountToMove );
1095 }
1096 // Adjust pointers and indices 1091 // Adjust pointers and indices
1097 pSource += amountToMove; 1092 pSource += amountToMove;
1098 pCh->Obuf_char_count += amountToMove; 1093 pCh->Obuf_char_count += amountToMove;
diff --git a/drivers/char/ip2/i2lib.h b/drivers/char/ip2/i2lib.h
index 952e113ccd8a..e559e9bac06d 100644
--- a/drivers/char/ip2/i2lib.h
+++ b/drivers/char/ip2/i2lib.h
@@ -332,7 +332,7 @@ static int i2QueueCommands(int, i2ChanStrPtr, int, int, cmdSyntaxPtr,...);
332static int i2GetStatus(i2ChanStrPtr, int); 332static int i2GetStatus(i2ChanStrPtr, int);
333static int i2Input(i2ChanStrPtr); 333static int i2Input(i2ChanStrPtr);
334static int i2InputFlush(i2ChanStrPtr); 334static int i2InputFlush(i2ChanStrPtr);
335static int i2Output(i2ChanStrPtr, const char *, int, int); 335static int i2Output(i2ChanStrPtr, const char *, int);
336static int i2OutputFree(i2ChanStrPtr); 336static int i2OutputFree(i2ChanStrPtr);
337static int i2ServiceBoard(i2eBordStrPtr); 337static int i2ServiceBoard(i2eBordStrPtr);
338static void i2DrainOutput(i2ChanStrPtr, int); 338static void i2DrainOutput(i2ChanStrPtr, int);
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 858ba5432c99..a3f32d46d2f8 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -1704,7 +1704,7 @@ ip2_write( PTTY tty, const unsigned char *pData, int count)
1704 1704
1705 /* This is the actual move bit. Make sure it does what we need!!!!! */ 1705 /* This is the actual move bit. Make sure it does what we need!!!!! */
1706 WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1706 WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags);
1707 bytesSent = i2Output( pCh, pData, count, 0 ); 1707 bytesSent = i2Output( pCh, pData, count);
1708 WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1708 WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags);
1709 1709
1710 ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent ); 1710 ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent );
@@ -1764,7 +1764,7 @@ ip2_flush_chars( PTTY tty )
1764 // 1764 //
1765 // We may need to restart i2Output if it does not fullfill this request 1765 // We may need to restart i2Output if it does not fullfill this request
1766 // 1766 //
1767 strip = i2Output( pCh, pCh->Pbuf, pCh->Pbuf_stuff, 0 ); 1767 strip = i2Output( pCh, pCh->Pbuf, pCh->Pbuf_stuff);
1768 if ( strip != pCh->Pbuf_stuff ) { 1768 if ( strip != pCh->Pbuf_stuff ) {
1769 memmove( pCh->Pbuf, &pCh->Pbuf[strip], pCh->Pbuf_stuff - strip ); 1769 memmove( pCh->Pbuf, &pCh->Pbuf[strip], pCh->Pbuf_stuff - strip );
1770 } 1770 }
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 2455e8d478ac..34a4fd13fa81 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -1928,13 +1928,8 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
1928 (long long) bmc->guid[8]); 1928 (long long) bmc->guid[8]);
1929} 1929}
1930 1930
1931static void 1931static void remove_files(struct bmc_device *bmc)
1932cleanup_bmc_device(struct kref *ref)
1933{ 1932{
1934 struct bmc_device *bmc;
1935
1936 bmc = container_of(ref, struct bmc_device, refcount);
1937
1938 device_remove_file(&bmc->dev->dev, 1933 device_remove_file(&bmc->dev->dev,
1939 &bmc->device_id_attr); 1934 &bmc->device_id_attr);
1940 device_remove_file(&bmc->dev->dev, 1935 device_remove_file(&bmc->dev->dev,
@@ -1951,12 +1946,23 @@ cleanup_bmc_device(struct kref *ref)
1951 &bmc->manufacturer_id_attr); 1946 &bmc->manufacturer_id_attr);
1952 device_remove_file(&bmc->dev->dev, 1947 device_remove_file(&bmc->dev->dev,
1953 &bmc->product_id_attr); 1948 &bmc->product_id_attr);
1949
1954 if (bmc->id.aux_firmware_revision_set) 1950 if (bmc->id.aux_firmware_revision_set)
1955 device_remove_file(&bmc->dev->dev, 1951 device_remove_file(&bmc->dev->dev,
1956 &bmc->aux_firmware_rev_attr); 1952 &bmc->aux_firmware_rev_attr);
1957 if (bmc->guid_set) 1953 if (bmc->guid_set)
1958 device_remove_file(&bmc->dev->dev, 1954 device_remove_file(&bmc->dev->dev,
1959 &bmc->guid_attr); 1955 &bmc->guid_attr);
1956}
1957
1958static void
1959cleanup_bmc_device(struct kref *ref)
1960{
1961 struct bmc_device *bmc;
1962
1963 bmc = container_of(ref, struct bmc_device, refcount);
1964
1965 remove_files(bmc);
1960 platform_device_unregister(bmc->dev); 1966 platform_device_unregister(bmc->dev);
1961 kfree(bmc); 1967 kfree(bmc);
1962} 1968}
@@ -1977,6 +1983,79 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
1977 mutex_unlock(&ipmidriver_mutex); 1983 mutex_unlock(&ipmidriver_mutex);
1978} 1984}
1979 1985
1986static int create_files(struct bmc_device *bmc)
1987{
1988 int err;
1989
1990 err = device_create_file(&bmc->dev->dev,
1991 &bmc->device_id_attr);
1992 if (err) goto out;
1993 err = device_create_file(&bmc->dev->dev,
1994 &bmc->provides_dev_sdrs_attr);
1995 if (err) goto out_devid;
1996 err = device_create_file(&bmc->dev->dev,
1997 &bmc->revision_attr);
1998 if (err) goto out_sdrs;
1999 err = device_create_file(&bmc->dev->dev,
2000 &bmc->firmware_rev_attr);
2001 if (err) goto out_rev;
2002 err = device_create_file(&bmc->dev->dev,
2003 &bmc->version_attr);
2004 if (err) goto out_firm;
2005 err = device_create_file(&bmc->dev->dev,
2006 &bmc->add_dev_support_attr);
2007 if (err) goto out_version;
2008 err = device_create_file(&bmc->dev->dev,
2009 &bmc->manufacturer_id_attr);
2010 if (err) goto out_add_dev;
2011 err = device_create_file(&bmc->dev->dev,
2012 &bmc->product_id_attr);
2013 if (err) goto out_manu;
2014 if (bmc->id.aux_firmware_revision_set) {
2015 err = device_create_file(&bmc->dev->dev,
2016 &bmc->aux_firmware_rev_attr);
2017 if (err) goto out_prod_id;
2018 }
2019 if (bmc->guid_set) {
2020 err = device_create_file(&bmc->dev->dev,
2021 &bmc->guid_attr);
2022 if (err) goto out_aux_firm;
2023 }
2024
2025 return 0;
2026
2027out_aux_firm:
2028 if (bmc->id.aux_firmware_revision_set)
2029 device_remove_file(&bmc->dev->dev,
2030 &bmc->aux_firmware_rev_attr);
2031out_prod_id:
2032 device_remove_file(&bmc->dev->dev,
2033 &bmc->product_id_attr);
2034out_manu:
2035 device_remove_file(&bmc->dev->dev,
2036 &bmc->manufacturer_id_attr);
2037out_add_dev:
2038 device_remove_file(&bmc->dev->dev,
2039 &bmc->add_dev_support_attr);
2040out_version:
2041 device_remove_file(&bmc->dev->dev,
2042 &bmc->version_attr);
2043out_firm:
2044 device_remove_file(&bmc->dev->dev,
2045 &bmc->firmware_rev_attr);
2046out_rev:
2047 device_remove_file(&bmc->dev->dev,
2048 &bmc->revision_attr);
2049out_sdrs:
2050 device_remove_file(&bmc->dev->dev,
2051 &bmc->provides_dev_sdrs_attr);
2052out_devid:
2053 device_remove_file(&bmc->dev->dev,
2054 &bmc->device_id_attr);
2055out:
2056 return err;
2057}
2058
1980static int ipmi_bmc_register(ipmi_smi_t intf) 2059static int ipmi_bmc_register(ipmi_smi_t intf)
1981{ 2060{
1982 int rv; 2061 int rv;
@@ -2051,7 +2130,6 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2051 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO; 2130 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
2052 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show; 2131 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
2053 2132
2054
2055 bmc->revision_attr.attr.name = "revision"; 2133 bmc->revision_attr.attr.name = "revision";
2056 bmc->revision_attr.attr.owner = THIS_MODULE; 2134 bmc->revision_attr.attr.owner = THIS_MODULE;
2057 bmc->revision_attr.attr.mode = S_IRUGO; 2135 bmc->revision_attr.attr.mode = S_IRUGO;
@@ -2093,28 +2171,14 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2093 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO; 2171 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
2094 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show; 2172 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
2095 2173
2096 device_create_file(&bmc->dev->dev, 2174 rv = create_files(bmc);
2097 &bmc->device_id_attr); 2175 if (rv) {
2098 device_create_file(&bmc->dev->dev, 2176 mutex_lock(&ipmidriver_mutex);
2099 &bmc->provides_dev_sdrs_attr); 2177 platform_device_unregister(bmc->dev);
2100 device_create_file(&bmc->dev->dev, 2178 mutex_unlock(&ipmidriver_mutex);
2101 &bmc->revision_attr); 2179
2102 device_create_file(&bmc->dev->dev, 2180 return rv;
2103 &bmc->firmware_rev_attr); 2181 }
2104 device_create_file(&bmc->dev->dev,
2105 &bmc->version_attr);
2106 device_create_file(&bmc->dev->dev,
2107 &bmc->add_dev_support_attr);
2108 device_create_file(&bmc->dev->dev,
2109 &bmc->manufacturer_id_attr);
2110 device_create_file(&bmc->dev->dev,
2111 &bmc->product_id_attr);
2112 if (bmc->id.aux_firmware_revision_set)
2113 device_create_file(&bmc->dev->dev,
2114 &bmc->aux_firmware_rev_attr);
2115 if (bmc->guid_set)
2116 device_create_file(&bmc->dev->dev,
2117 &bmc->guid_attr);
2118 2182
2119 printk(KERN_INFO 2183 printk(KERN_INFO
2120 "ipmi: Found new BMC (man_id: 0x%6.6x, " 2184 "ipmi: Found new BMC (man_id: 0x%6.6x, "
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 6511012cbdcd..55473371b7c6 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -26,6 +26,7 @@
26#include <linux/backing-dev.h> 26#include <linux/backing-dev.h>
27#include <linux/bootmem.h> 27#include <linux/bootmem.h>
28#include <linux/pipe_fs_i.h> 28#include <linux/pipe_fs_i.h>
29#include <linux/pfn.h>
29 30
30#include <asm/uaccess.h> 31#include <asm/uaccess.h>
31#include <asm/io.h> 32#include <asm/io.h>
@@ -292,8 +293,8 @@ static int mmap_kmem(struct file * file, struct vm_area_struct * vma)
292{ 293{
293 unsigned long pfn; 294 unsigned long pfn;
294 295
295 /* Turn a kernel-virtual address into a physical page frame */ 296 /* Turn a pfn offset into an absolute pfn */
296 pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT; 297 pfn = PFN_DOWN(virt_to_phys((void *)PAGE_OFFSET)) + vma->vm_pgoff;
297 298
298 /* 299 /*
299 * RED-PEN: on some architectures there is more mapped memory 300 * RED-PEN: on some architectures there is more mapped memory
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
index 052e8120a471..7ce77619707c 100644
--- a/drivers/char/rio/rioctrl.c
+++ b/drivers/char/rio/rioctrl.c
@@ -662,7 +662,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su
662 p->RIOError.Error = COPYIN_FAILED; 662 p->RIOError.Error = COPYIN_FAILED;
663 return -EFAULT; 663 return -EFAULT;
664 } 664 }
665 if (portStats.port >= RIO_PORTS) { 665 if (portStats.port < 0 || portStats.port >= RIO_PORTS) {
666 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 666 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
667 return -ENXIO; 667 return -ENXIO;
668 } 668 }
@@ -702,7 +702,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su
702 p->RIOError.Error = COPYIN_FAILED; 702 p->RIOError.Error = COPYIN_FAILED;
703 return -EFAULT; 703 return -EFAULT;
704 } 704 }
705 if (portStats.port >= RIO_PORTS) { 705 if (portStats.port < 0 || portStats.port >= RIO_PORTS) {
706 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 706 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
707 return -ENXIO; 707 return -ENXIO;
708 } 708 }
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index 461bfe0234c9..3af7f0958c5d 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -839,7 +839,7 @@ shutdown(struct cyclades_port * info)
839 local_irq_save(flags); 839 local_irq_save(flags);
840 if (info->xmit_buf){ 840 if (info->xmit_buf){
841 free_page((unsigned long) info->xmit_buf); 841 free_page((unsigned long) info->xmit_buf);
842 info->xmit_buf = 0; 842 info->xmit_buf = NULL;
843 } 843 }
844 844
845 base_addr[CyCAR] = (u_char)channel; 845 base_addr[CyCAR] = (u_char)channel;
@@ -1354,7 +1354,7 @@ cy_unthrottle(struct tty_struct * tty)
1354 1354
1355static int 1355static int
1356get_serial_info(struct cyclades_port * info, 1356get_serial_info(struct cyclades_port * info,
1357 struct serial_struct * retinfo) 1357 struct serial_struct __user * retinfo)
1358{ 1358{
1359 struct serial_struct tmp; 1359 struct serial_struct tmp;
1360 1360
@@ -1376,7 +1376,7 @@ get_serial_info(struct cyclades_port * info,
1376 1376
1377static int 1377static int
1378set_serial_info(struct cyclades_port * info, 1378set_serial_info(struct cyclades_port * info,
1379 struct serial_struct * new_info) 1379 struct serial_struct __user * new_info)
1380{ 1380{
1381 struct serial_struct new_serial; 1381 struct serial_struct new_serial;
1382 struct cyclades_port old_info; 1382 struct cyclades_port old_info;
@@ -1503,7 +1503,7 @@ send_break( struct cyclades_port * info, int duration)
1503} /* send_break */ 1503} /* send_break */
1504 1504
1505static int 1505static int
1506get_mon_info(struct cyclades_port * info, struct cyclades_monitor * mon) 1506get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon)
1507{ 1507{
1508 1508
1509 if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor))) 1509 if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
@@ -1516,7 +1516,7 @@ get_mon_info(struct cyclades_port * info, struct cyclades_monitor * mon)
1516} 1516}
1517 1517
1518static int 1518static int
1519set_threshold(struct cyclades_port * info, unsigned long *arg) 1519set_threshold(struct cyclades_port * info, unsigned long __user *arg)
1520{ 1520{
1521 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1521 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1522 unsigned long value; 1522 unsigned long value;
@@ -1533,7 +1533,7 @@ set_threshold(struct cyclades_port * info, unsigned long *arg)
1533} 1533}
1534 1534
1535static int 1535static int
1536get_threshold(struct cyclades_port * info, unsigned long *value) 1536get_threshold(struct cyclades_port * info, unsigned long __user *value)
1537{ 1537{
1538 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1538 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1539 int channel; 1539 int channel;
@@ -1546,7 +1546,7 @@ get_threshold(struct cyclades_port * info, unsigned long *value)
1546} 1546}
1547 1547
1548static int 1548static int
1549set_default_threshold(struct cyclades_port * info, unsigned long *arg) 1549set_default_threshold(struct cyclades_port * info, unsigned long __user *arg)
1550{ 1550{
1551 unsigned long value; 1551 unsigned long value;
1552 1552
@@ -1558,13 +1558,13 @@ set_default_threshold(struct cyclades_port * info, unsigned long *arg)
1558} 1558}
1559 1559
1560static int 1560static int
1561get_default_threshold(struct cyclades_port * info, unsigned long *value) 1561get_default_threshold(struct cyclades_port * info, unsigned long __user *value)
1562{ 1562{
1563 return put_user(info->default_threshold,value); 1563 return put_user(info->default_threshold,value);
1564} 1564}
1565 1565
1566static int 1566static int
1567set_timeout(struct cyclades_port * info, unsigned long *arg) 1567set_timeout(struct cyclades_port * info, unsigned long __user *arg)
1568{ 1568{
1569 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1569 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1570 int channel; 1570 int channel;
@@ -1581,7 +1581,7 @@ set_timeout(struct cyclades_port * info, unsigned long *arg)
1581} 1581}
1582 1582
1583static int 1583static int
1584get_timeout(struct cyclades_port * info, unsigned long *value) 1584get_timeout(struct cyclades_port * info, unsigned long __user *value)
1585{ 1585{
1586 volatile unsigned char *base_addr = (u_char *)BASE_ADDR; 1586 volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
1587 int channel; 1587 int channel;
@@ -1601,7 +1601,7 @@ set_default_timeout(struct cyclades_port * info, unsigned long value)
1601} 1601}
1602 1602
1603static int 1603static int
1604get_default_timeout(struct cyclades_port * info, unsigned long *value) 1604get_default_timeout(struct cyclades_port * info, unsigned long __user *value)
1605{ 1605{
1606 return put_user(info->default_timeout,value); 1606 return put_user(info->default_timeout,value);
1607} 1607}
@@ -1613,6 +1613,7 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
1613 unsigned long val; 1613 unsigned long val;
1614 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; 1614 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
1615 int ret_val = 0; 1615 int ret_val = 0;
1616 void __user *argp = (void __user *)arg;
1616 1617
1617#ifdef SERIAL_DEBUG_OTHER 1618#ifdef SERIAL_DEBUG_OTHER
1618 printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */ 1619 printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */
@@ -1620,28 +1621,28 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
1620 1621
1621 switch (cmd) { 1622 switch (cmd) {
1622 case CYGETMON: 1623 case CYGETMON:
1623 ret_val = get_mon_info(info, (struct cyclades_monitor *)arg); 1624 ret_val = get_mon_info(info, argp);
1624 break; 1625 break;
1625 case CYGETTHRESH: 1626 case CYGETTHRESH:
1626 ret_val = get_threshold(info, (unsigned long *)arg); 1627 ret_val = get_threshold(info, argp);
1627 break; 1628 break;
1628 case CYSETTHRESH: 1629 case CYSETTHRESH:
1629 ret_val = set_threshold(info, (unsigned long *)arg); 1630 ret_val = set_threshold(info, argp);
1630 break; 1631 break;
1631 case CYGETDEFTHRESH: 1632 case CYGETDEFTHRESH:
1632 ret_val = get_default_threshold(info, (unsigned long *)arg); 1633 ret_val = get_default_threshold(info, argp);
1633 break; 1634 break;
1634 case CYSETDEFTHRESH: 1635 case CYSETDEFTHRESH:
1635 ret_val = set_default_threshold(info, (unsigned long *)arg); 1636 ret_val = set_default_threshold(info, argp);
1636 break; 1637 break;
1637 case CYGETTIMEOUT: 1638 case CYGETTIMEOUT:
1638 ret_val = get_timeout(info, (unsigned long *)arg); 1639 ret_val = get_timeout(info, argp);
1639 break; 1640 break;
1640 case CYSETTIMEOUT: 1641 case CYSETTIMEOUT:
1641 ret_val = set_timeout(info, (unsigned long *)arg); 1642 ret_val = set_timeout(info, argp);
1642 break; 1643 break;
1643 case CYGETDEFTIMEOUT: 1644 case CYGETDEFTIMEOUT:
1644 ret_val = get_default_timeout(info, (unsigned long *)arg); 1645 ret_val = get_default_timeout(info, argp);
1645 break; 1646 break;
1646 case CYSETDEFTIMEOUT: 1647 case CYSETDEFTIMEOUT:
1647 ret_val = set_default_timeout(info, (unsigned long)arg); 1648 ret_val = set_default_timeout(info, (unsigned long)arg);
@@ -1664,21 +1665,20 @@ cy_ioctl(struct tty_struct *tty, struct file * file,
1664 1665
1665/* The following commands are incompletely implemented!!! */ 1666/* The following commands are incompletely implemented!!! */
1666 case TIOCGSOFTCAR: 1667 case TIOCGSOFTCAR:
1667 ret_val = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *) arg); 1668 ret_val = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) argp);
1668 break; 1669 break;
1669 case TIOCSSOFTCAR: 1670 case TIOCSSOFTCAR:
1670 ret_val = get_user(val, (unsigned long *) arg); 1671 ret_val = get_user(val, (unsigned long __user *) argp);
1671 if (ret_val) 1672 if (ret_val)
1672 break; 1673 break;
1673 tty->termios->c_cflag = 1674 tty->termios->c_cflag =
1674 ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0)); 1675 ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0));
1675 break; 1676 break;
1676 case TIOCGSERIAL: 1677 case TIOCGSERIAL:
1677 ret_val = get_serial_info(info, (struct serial_struct *) arg); 1678 ret_val = get_serial_info(info, argp);
1678 break; 1679 break;
1679 case TIOCSSERIAL: 1680 case TIOCSSERIAL:
1680 ret_val = set_serial_info(info, 1681 ret_val = set_serial_info(info, argp);
1681 (struct serial_struct *) arg);
1682 break; 1682 break;
1683 default: 1683 default:
1684 ret_val = -ENOIOCTLCMD; 1684 ret_val = -ENOIOCTLCMD;
@@ -1773,7 +1773,7 @@ cy_close(struct tty_struct * tty, struct file * filp)
1773 tty->driver->flush_buffer(tty); 1773 tty->driver->flush_buffer(tty);
1774 tty_ldisc_flush(tty); 1774 tty_ldisc_flush(tty);
1775 info->event = 0; 1775 info->event = 0;
1776 info->tty = 0; 1776 info->tty = NULL;
1777 if (info->blocked_open) { 1777 if (info->blocked_open) {
1778 if (info->close_delay) { 1778 if (info->close_delay) {
1779 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 1779 msleep_interruptible(jiffies_to_msecs(info->close_delay));
@@ -2250,7 +2250,7 @@ scrn[1] = '\0';
2250 info->card = index; 2250 info->card = index;
2251 info->line = port_num; 2251 info->line = port_num;
2252 info->flags = STD_COM_FLAGS; 2252 info->flags = STD_COM_FLAGS;
2253 info->tty = 0; 2253 info->tty = NULL;
2254 info->xmit_fifo_size = 12; 2254 info->xmit_fifo_size = 12;
2255 info->cor1 = CyPARITY_NONE|Cy_8_BITS; 2255 info->cor1 = CyPARITY_NONE|Cy_8_BITS;
2256 info->cor2 = CyETC; 2256 info->cor2 = CyETC;
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index d0b88d0e87fd..7e1bd9562c2a 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -183,11 +183,6 @@ static int sx_poll = HZ;
183 183
184static struct tty_driver *specialix_driver; 184static struct tty_driver *specialix_driver;
185 185
186static unsigned long baud_table[] = {
187 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
188 9600, 19200, 38400, 57600, 115200, 0,
189};
190
191static struct specialix_board sx_board[SX_NBOARD] = { 186static struct specialix_board sx_board[SX_NBOARD] = {
192 { 0, SX_IOBASE1, 9, }, 187 { 0, SX_IOBASE1, 9, },
193 { 0, SX_IOBASE2, 11, }, 188 { 0, SX_IOBASE2, 11, },
@@ -1090,9 +1085,9 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
1090 1085
1091 if (baud == 38400) { 1086 if (baud == 38400) {
1092 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 1087 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
1093 baud ++; 1088 baud = 57600;
1094 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 1089 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
1095 baud += 2; 1090 baud = 115200;
1096 } 1091 }
1097 1092
1098 if (!baud) { 1093 if (!baud) {
@@ -1150,11 +1145,9 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
1150 sx_out(bp, CD186x_RBPRL, tmp & 0xff); 1145 sx_out(bp, CD186x_RBPRL, tmp & 0xff);
1151 sx_out(bp, CD186x_TBPRL, tmp & 0xff); 1146 sx_out(bp, CD186x_TBPRL, tmp & 0xff);
1152 spin_unlock_irqrestore(&bp->lock, flags); 1147 spin_unlock_irqrestore(&bp->lock, flags);
1153 if (port->custom_divisor) { 1148 if (port->custom_divisor)
1154 baud = (SX_OSCFREQ + port->custom_divisor/2) / port->custom_divisor; 1149 baud = (SX_OSCFREQ + port->custom_divisor/2) / port->custom_divisor;
1155 baud = ( baud + 5 ) / 10; 1150 baud = (baud + 5) / 10; /* Estimated CPS */
1156 } else
1157 baud = (baud_table[baud] + 5) / 10; /* Estimated CPS */
1158 1151
1159 /* Two timer ticks seems enough to wakeup something like SLIP driver */ 1152 /* Two timer ticks seems enough to wakeup something like SLIP driver */
1160 tmp = ((baud + HZ/2) / HZ) * 2 - CD186x_NFIFO; 1153 tmp = ((baud + HZ/2) / HZ) * 2 - CD186x_NFIFO;
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 5fec626598cd..cc10af08cb05 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -2602,7 +2602,7 @@ static void __exit sx_exit (void)
2602 } 2602 }
2603 } 2603 }
2604 if (misc_deregister(&sx_fw_device) < 0) { 2604 if (misc_deregister(&sx_fw_device) < 0) {
2605 printk (KERN_INFO "sx: couldn't deregister firmware loader devic\n"); 2605 printk (KERN_INFO "sx: couldn't deregister firmware loader device\n");
2606 } 2606 }
2607 sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up drivers (%d)\n", sx_initialized); 2607 sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up drivers (%d)\n", sx_initialized);
2608 if (sx_initialized) 2608 if (sx_initialized)
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index f2864cc64240..06784adcc35c 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -133,8 +133,8 @@ static MGSL_PARAMS default_params = {
133}; 133};
134 134
135#define SHARED_MEM_ADDRESS_SIZE 0x40000 135#define SHARED_MEM_ADDRESS_SIZE 0x40000
136#define BUFFERLISTSIZE (PAGE_SIZE) 136#define BUFFERLISTSIZE 4096
137#define DMABUFFERSIZE (PAGE_SIZE) 137#define DMABUFFERSIZE 4096
138#define MAXRXFRAMES 7 138#define MAXRXFRAMES 7
139 139
140typedef struct _DMABUFFERENTRY 140typedef struct _DMABUFFERENTRY
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index a082a2e34252..6ad2d3bb945c 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1153,7 +1153,14 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
1153 1153
1154 spin_unlock(&driver_lock); 1154 spin_unlock(&driver_lock);
1155 1155
1156 sysfs_create_group(&dev->kobj, chip->vendor.attr_group); 1156 if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) {
1157 list_del(&chip->list);
1158 put_device(dev);
1159 clear_bit(chip->dev_num, dev_mask);
1160 kfree(chip);
1161 kfree(devname);
1162 return NULL;
1163 }
1157 1164
1158 chip->bios_dir = tpm_bios_log_setup(devname); 1165 chip->bios_dir = tpm_bios_log_setup(devname);
1159 1166
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index ad8ffe49256f..1ab0896070be 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -184,7 +184,9 @@ static int __init init_atmel(void)
184 unsigned long base; 184 unsigned long base;
185 struct tpm_chip *chip; 185 struct tpm_chip *chip;
186 186
187 driver_register(&atml_drv); 187 rc = driver_register(&atml_drv);
188 if (rc)
189 return rc;
188 190
189 if ((iobase = atmel_get_base_addr(&base, &region_size)) == NULL) { 191 if ((iobase = atmel_get_base_addr(&base, &region_size)) == NULL) {
190 rc = -ENODEV; 192 rc = -ENODEV;
@@ -195,10 +197,8 @@ static int __init init_atmel(void)
195 (atmel_request_region 197 (atmel_request_region
196 (tpm_atmel.base, region_size, "tpm_atmel0") == NULL) ? 0 : 1; 198 (tpm_atmel.base, region_size, "tpm_atmel0") == NULL) ? 0 : 1;
197 199
198 200 pdev = platform_device_register_simple("tpm_atmel", -1, NULL, 0);
199 if (IS_ERR 201 if (IS_ERR(pdev)) {
200 (pdev =
201 platform_device_register_simple("tpm_atmel", -1, NULL, 0))) {
202 rc = PTR_ERR(pdev); 202 rc = PTR_ERR(pdev);
203 goto err_rel_reg; 203 goto err_rel_reg;
204 } 204 }
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index 26287aace87d..608f73071bef 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -284,7 +284,7 @@ static struct device_driver nsc_drv = {
284static int __init init_nsc(void) 284static int __init init_nsc(void)
285{ 285{
286 int rc = 0; 286 int rc = 0;
287 int lo, hi; 287 int lo, hi, err;
288 int nscAddrBase = TPM_ADDR; 288 int nscAddrBase = TPM_ADDR;
289 struct tpm_chip *chip; 289 struct tpm_chip *chip;
290 unsigned long base; 290 unsigned long base;
@@ -297,7 +297,9 @@ static int __init init_nsc(void)
297 return -ENODEV; 297 return -ENODEV;
298 } 298 }
299 299
300 driver_register(&nsc_drv); 300 err = driver_register(&nsc_drv);
301 if (err)
302 return err;
301 303
302 hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI); 304 hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI);
303 lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO); 305 lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO);
diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
index 3a365e159d89..d944647c82c2 100644
--- a/drivers/eisa/eisa-bus.c
+++ b/drivers/eisa/eisa-bus.c
@@ -226,14 +226,26 @@ static int __init eisa_init_device (struct eisa_root_device *root,
226 226
227static int __init eisa_register_device (struct eisa_device *edev) 227static int __init eisa_register_device (struct eisa_device *edev)
228{ 228{
229 if (device_register (&edev->dev)) 229 int rc = device_register (&edev->dev);
230 return -1; 230 if (rc)
231 return rc;
231 232
232 device_create_file (&edev->dev, &dev_attr_signature); 233 rc = device_create_file (&edev->dev, &dev_attr_signature);
233 device_create_file (&edev->dev, &dev_attr_enabled); 234 if (rc) goto err_devreg;
234 device_create_file (&edev->dev, &dev_attr_modalias); 235 rc = device_create_file (&edev->dev, &dev_attr_enabled);
236 if (rc) goto err_sig;
237 rc = device_create_file (&edev->dev, &dev_attr_modalias);
238 if (rc) goto err_enab;
235 239
236 return 0; 240 return 0;
241
242err_enab:
243 device_remove_file (&edev->dev, &dev_attr_enabled);
244err_sig:
245 device_remove_file (&edev->dev, &dev_attr_signature);
246err_devreg:
247 device_unregister(&edev->dev);
248 return rc;
237} 249}
238 250
239static int __init eisa_request_resources (struct eisa_root_device *root, 251static int __init eisa_request_resources (struct eisa_root_device *root,
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index fc17599c905e..08b161798443 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -249,7 +249,7 @@ static int packetize_data(void *data, size_t length)
249 if ((rc = create_packet(temp, packet_length))) 249 if ((rc = create_packet(temp, packet_length)))
250 return rc; 250 return rc;
251 251
252 pr_debug("%p:%lu\n", temp, (end - temp)); 252 pr_debug("%p:%td\n", temp, (end - temp));
253 temp += packet_length; 253 temp += packet_length;
254 } 254 }
255 255
@@ -718,14 +718,27 @@ static int __init dcdrbu_init(void)
718 return -EIO; 718 return -EIO;
719 } 719 }
720 720
721 sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr); 721 rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
722 sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr); 722 if (rc)
723 sysfs_create_bin_file(&rbu_device->dev.kobj, 723 goto out_devreg;
724 rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr);
725 if (rc)
726 goto out_data;
727 rc = sysfs_create_bin_file(&rbu_device->dev.kobj,
724 &rbu_packet_size_attr); 728 &rbu_packet_size_attr);
729 if (rc)
730 goto out_imtype;
725 731
726 rbu_data.entry_created = 0; 732 rbu_data.entry_created = 0;
727 return rc; 733 return 0;
728 734
735out_imtype:
736 sysfs_remove_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr);
737out_data:
738 sysfs_remove_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);
739out_devreg:
740 platform_device_unregister(rbu_device);
741 return rc;
729} 742}
730 743
731static __exit void dcdrbu_exit(void) 744static __exit void dcdrbu_exit(void)
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 8ebce1c03ad7..5ab5e393b882 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -639,7 +639,12 @@ efivar_create_sysfs_entry(unsigned long variable_name_size,
639 639
640 kobject_set_name(&new_efivar->kobj, "%s", short_name); 640 kobject_set_name(&new_efivar->kobj, "%s", short_name);
641 kobj_set_kset_s(new_efivar, vars_subsys); 641 kobj_set_kset_s(new_efivar, vars_subsys);
642 kobject_register(&new_efivar->kobj); 642 i = kobject_register(&new_efivar->kobj);
643 if (i) {
644 kfree(short_name);
645 kfree(new_efivar);
646 return 1;
647 }
643 648
644 kfree(short_name); 649 kfree(short_name);
645 short_name = NULL; 650 short_name = NULL;
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 69bbb6206a00..bddfebdf91d8 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -597,7 +597,7 @@ static void cdrom_prepare_request(ide_drive_t *drive, struct request *rq)
597 struct cdrom_info *cd = drive->driver_data; 597 struct cdrom_info *cd = drive->driver_data;
598 598
599 ide_init_drive_cmd(rq); 599 ide_init_drive_cmd(rq);
600 rq->cmd_type = REQ_TYPE_BLOCK_PC; 600 rq->cmd_type = REQ_TYPE_ATA_PC;
601 rq->rq_disk = cd->disk; 601 rq->rq_disk = cd->disk;
602} 602}
603 603
@@ -716,7 +716,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
716 ide_error(drive, "request sense failure", stat); 716 ide_error(drive, "request sense failure", stat);
717 return 1; 717 return 1;
718 718
719 } else if (blk_pc_request(rq)) { 719 } else if (blk_pc_request(rq) || rq->cmd_type == REQ_TYPE_ATA_PC) {
720 /* All other functions, except for READ. */ 720 /* All other functions, except for READ. */
721 unsigned long flags; 721 unsigned long flags;
722 722
@@ -2023,7 +2023,8 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block)
2023 } 2023 }
2024 info->last_block = block; 2024 info->last_block = block;
2025 return action; 2025 return action;
2026 } else if (rq->cmd_type == REQ_TYPE_SENSE) { 2026 } else if (rq->cmd_type == REQ_TYPE_SENSE ||
2027 rq->cmd_type == REQ_TYPE_ATA_PC) {
2027 return cdrom_do_packet_command(drive); 2028 return cdrom_do_packet_command(drive);
2028 } else if (blk_pc_request(rq)) { 2029 } else if (blk_pc_request(rq)) {
2029 return cdrom_do_block_pc(drive, rq); 2030 return cdrom_do_block_pc(drive, rq);
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 1d0470c1f957..30175c7688e8 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -524,8 +524,8 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
524 task_ioreg_t *hobsptr = args.hobRegister; 524 task_ioreg_t *hobsptr = args.hobRegister;
525 int err = 0; 525 int err = 0;
526 int tasksize = sizeof(struct ide_task_request_s); 526 int tasksize = sizeof(struct ide_task_request_s);
527 int taskin = 0; 527 unsigned int taskin = 0;
528 int taskout = 0; 528 unsigned int taskout = 0;
529 u8 io_32bit = drive->io_32bit; 529 u8 io_32bit = drive->io_32bit;
530 char __user *buf = (char __user *)arg; 530 char __user *buf = (char __user *)arg;
531 531
@@ -538,8 +538,13 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
538 return -EFAULT; 538 return -EFAULT;
539 } 539 }
540 540
541 taskout = (int) req_task->out_size; 541 taskout = req_task->out_size;
542 taskin = (int) req_task->in_size; 542 taskin = req_task->in_size;
543
544 if (taskin > 65536 || taskout > 65536) {
545 err = -EINVAL;
546 goto abort;
547 }
543 548
544 if (taskout) { 549 if (taskout) {
545 int outtotal = tasksize; 550 int outtotal = tasksize;
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
index 965c43659e35..5b77a5bcbf0c 100644
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/pci/generic.c
@@ -237,10 +237,12 @@ static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_devi
237 if (dev->vendor == PCI_VENDOR_ID_JMICRON && PCI_FUNC(dev->devfn) != 1) 237 if (dev->vendor == PCI_VENDOR_ID_JMICRON && PCI_FUNC(dev->devfn) != 1)
238 goto out; 238 goto out;
239 239
240 pci_read_config_word(dev, PCI_COMMAND, &command); 240 if (dev->vendor != PCI_VENDOR_ID_JMICRON) {
241 if (!(command & PCI_COMMAND_IO)) { 241 pci_read_config_word(dev, PCI_COMMAND, &command);
242 printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name); 242 if (!(command & PCI_COMMAND_IO)) {
243 goto out; 243 printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name);
244 goto out;
245 }
244 } 246 }
245 ret = ide_setup_pci_device(dev, d); 247 ret = ide_setup_pci_device(dev, d);
246out: 248out:
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index f3fe287fbd89..244f7eb7006d 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -774,7 +774,7 @@ ioc4_ide_exit(void)
774 ioc4_unregister_submodule(&ioc4_ide_submodule); 774 ioc4_unregister_submodule(&ioc4_ide_submodule);
775} 775}
776 776
777module_init(ioc4_ide_init); 777late_initcall(ioc4_ide_init); /* Call only after IDE init is done */
778module_exit(ioc4_ide_exit); 778module_exit(ioc4_ide_exit);
779 779
780MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon"); 780MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon");
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index 1be963961c15..ab4da79ee560 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -60,7 +60,7 @@ static struct fasync_struct *hp_sdc_rtc_async_queue;
60 60
61static DECLARE_WAIT_QUEUE_HEAD(hp_sdc_rtc_wait); 61static DECLARE_WAIT_QUEUE_HEAD(hp_sdc_rtc_wait);
62 62
63static ssize_t hp_sdc_rtc_read(struct file *file, char *buf, 63static ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf,
64 size_t count, loff_t *ppos); 64 size_t count, loff_t *ppos);
65 65
66static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file, 66static int hp_sdc_rtc_ioctl(struct inode *inode, struct file *file,
@@ -385,14 +385,14 @@ static int hp_sdc_rtc_set_i8042timer (struct timeval *setto, uint8_t setcmd)
385 return 0; 385 return 0;
386} 386}
387 387
388static ssize_t hp_sdc_rtc_read(struct file *file, char *buf, 388static ssize_t hp_sdc_rtc_read(struct file *file, char __user *buf,
389 size_t count, loff_t *ppos) { 389 size_t count, loff_t *ppos) {
390 ssize_t retval; 390 ssize_t retval;
391 391
392 if (count < sizeof(unsigned long)) 392 if (count < sizeof(unsigned long))
393 return -EINVAL; 393 return -EINVAL;
394 394
395 retval = put_user(68, (unsigned long *)buf); 395 retval = put_user(68, (unsigned long __user *)buf);
396 return retval; 396 return retval;
397} 397}
398 398
@@ -696,7 +696,7 @@ static int __init hp_sdc_rtc_init(void)
696 if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr))) 696 if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
697 return ret; 697 return ret;
698 misc_register(&hp_sdc_rtc_dev); 698 misc_register(&hp_sdc_rtc_dev);
699 create_proc_read_entry ("driver/rtc", 0, 0, 699 create_proc_read_entry ("driver/rtc", 0, NULL,
700 hp_sdc_rtc_read_proc, NULL); 700 hp_sdc_rtc_read_proc, NULL);
701 701
702 printk(KERN_INFO "HP i8042 SDC + MSM-58321 RTC support loaded " 702 printk(KERN_INFO "HP i8042 SDC + MSM-58321 RTC support loaded "
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 4639537336fc..7b9d1c1da41a 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -17,7 +17,7 @@
17 * with this program; if not, write to the Free Software Foundation, Inc., 17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place Suite 330, Boston, MA 02111-1307, USA. 18 * 59 Temple Place Suite 330, Boston, MA 02111-1307, USA.
19 */ 19 */
20#include <asm/io.h> 20#include <linux/io.h>
21#include <linux/dmi.h> 21#include <linux/dmi.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/input.h> 23#include <linux/input.h>
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c
index bdfde046b741..49e11e2c1d5d 100644
--- a/drivers/input/serio/hil_mlc.c
+++ b/drivers/input/serio/hil_mlc.c
@@ -391,23 +391,23 @@ static int hilse_operate(hil_mlc *mlc, int repoll) {
391} 391}
392 392
393#define FUNC(funct, funct_arg, zero_rc, neg_rc, pos_rc) \ 393#define FUNC(funct, funct_arg, zero_rc, neg_rc, pos_rc) \
394{ HILSE_FUNC, { func: &funct }, funct_arg, zero_rc, neg_rc, pos_rc }, 394{ HILSE_FUNC, { .func = funct }, funct_arg, zero_rc, neg_rc, pos_rc },
395#define OUT(pack) \ 395#define OUT(pack) \
396{ HILSE_OUT, { packet: pack }, 0, HILSEN_NEXT, HILSEN_DOZE, 0 }, 396{ HILSE_OUT, { .packet = pack }, 0, HILSEN_NEXT, HILSEN_DOZE, 0 },
397#define CTS \ 397#define CTS \
398{ HILSE_CTS, { packet: 0 }, 0, HILSEN_NEXT | HILSEN_SCHED | HILSEN_BREAK, HILSEN_DOZE, 0 }, 398{ HILSE_CTS, { .packet = 0 }, 0, HILSEN_NEXT | HILSEN_SCHED | HILSEN_BREAK, HILSEN_DOZE, 0 },
399#define EXPECT(comp, to, got, got_wrong, timed_out) \ 399#define EXPECT(comp, to, got, got_wrong, timed_out) \
400{ HILSE_EXPECT, { packet: comp }, to, got, got_wrong, timed_out }, 400{ HILSE_EXPECT, { .packet = comp }, to, got, got_wrong, timed_out },
401#define EXPECT_LAST(comp, to, got, got_wrong, timed_out) \ 401#define EXPECT_LAST(comp, to, got, got_wrong, timed_out) \
402{ HILSE_EXPECT_LAST, { packet: comp }, to, got, got_wrong, timed_out }, 402{ HILSE_EXPECT_LAST, { .packet = comp }, to, got, got_wrong, timed_out },
403#define EXPECT_DISC(comp, to, got, got_wrong, timed_out) \ 403#define EXPECT_DISC(comp, to, got, got_wrong, timed_out) \
404{ HILSE_EXPECT_DISC, { packet: comp }, to, got, got_wrong, timed_out }, 404{ HILSE_EXPECT_DISC, { .packet = comp }, to, got, got_wrong, timed_out },
405#define IN(to, got, got_error, timed_out) \ 405#define IN(to, got, got_error, timed_out) \
406{ HILSE_IN, { packet: 0 }, to, got, got_error, timed_out }, 406{ HILSE_IN, { .packet = 0 }, to, got, got_error, timed_out },
407#define OUT_DISC(pack) \ 407#define OUT_DISC(pack) \
408{ HILSE_OUT_DISC, { packet: pack }, 0, 0, 0, 0 }, 408{ HILSE_OUT_DISC, { .packet = pack }, 0, 0, 0, 0 },
409#define OUT_LAST(pack) \ 409#define OUT_LAST(pack) \
410{ HILSE_OUT_LAST, { packet: pack }, 0, 0, 0, 0 }, 410{ HILSE_OUT_LAST, { .packet = pack }, 0, 0, 0, 0 },
411 411
412struct hilse_node hil_mlc_se[HILSEN_END] = { 412struct hilse_node hil_mlc_se[HILSEN_END] = {
413 413
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c
index ba7b920347e3..9907ad3bea23 100644
--- a/drivers/input/serio/hp_sdc.c
+++ b/drivers/input/serio/hp_sdc.c
@@ -310,7 +310,7 @@ static void hp_sdc_tasklet(unsigned long foo) {
310 * in tasklet/bh context. 310 * in tasklet/bh context.
311 */ 311 */
312 if (curr->act.irqhook) 312 if (curr->act.irqhook)
313 curr->act.irqhook(0, 0, 0, 0); 313 curr->act.irqhook(0, NULL, 0, 0);
314 } 314 }
315 curr->actidx = curr->idx; 315 curr->actidx = curr->idx;
316 curr->idx++; 316 curr->idx++;
@@ -525,7 +525,7 @@ actdone:
525 up(curr->act.semaphore); 525 up(curr->act.semaphore);
526 } 526 }
527 else if (act & HP_SDC_ACT_CALLBACK) { 527 else if (act & HP_SDC_ACT_CALLBACK) {
528 curr->act.irqhook(0,0,0,0); 528 curr->act.irqhook(0,NULL,0,0);
529 } 529 }
530 if (curr->idx >= curr->endidx) { /* This transaction is over. */ 530 if (curr->idx >= curr->endidx) { /* This transaction is over. */
531 if (act & HP_SDC_ACT_DEALLOC) kfree(curr); 531 if (act & HP_SDC_ACT_DEALLOC) kfree(curr);
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c
index d10c8b82e6aa..b6f9476c0501 100644
--- a/drivers/isdn/capi/capidrv.c
+++ b/drivers/isdn/capi/capidrv.c
@@ -1907,7 +1907,8 @@ static int if_readstat(u8 __user *buf, int len, int id, int channel)
1907 } 1907 }
1908 1908
1909 for (p=buf, count=0; count < len; p++, count++) { 1909 for (p=buf, count=0; count < len; p++, count++) {
1910 put_user(*card->q931_read++, p); 1910 if (put_user(*card->q931_read++, p))
1911 return -EFAULT;
1911 if (card->q931_read > card->q931_end) 1912 if (card->q931_read > card->q931_end)
1912 card->q931_read = card->q931_buf; 1913 card->q931_read = card->q931_buf;
1913 } 1914 }
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index e4823ab2b127..785b08554fca 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -631,7 +631,8 @@ static int HiSax_readstatus(u_char __user *buf, int len, int id, int channel)
631 count = cs->status_end - cs->status_read + 1; 631 count = cs->status_end - cs->status_read + 1;
632 if (count >= len) 632 if (count >= len)
633 count = len; 633 count = len;
634 copy_to_user(p, cs->status_read, count); 634 if (copy_to_user(p, cs->status_read, count))
635 return -EFAULT;
635 cs->status_read += count; 636 cs->status_read += count;
636 if (cs->status_read > cs->status_end) 637 if (cs->status_read > cs->status_end)
637 cs->status_read = cs->status_buf; 638 cs->status_read = cs->status_buf;
@@ -642,7 +643,8 @@ static int HiSax_readstatus(u_char __user *buf, int len, int id, int channel)
642 cnt = HISAX_STATUS_BUFSIZE; 643 cnt = HISAX_STATUS_BUFSIZE;
643 else 644 else
644 cnt = count; 645 cnt = count;
645 copy_to_user(p, cs->status_read, cnt); 646 if (copy_to_user(p, cs->status_read, cnt))
647 return -EFAULT;
646 p += cnt; 648 p += cnt;
647 cs->status_read += cnt % HISAX_STATUS_BUFSIZE; 649 cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
648 count -= cnt; 650 count -= cnt;
diff --git a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c
index 160f22fa5941..8bbe33ae06db 100644
--- a/drivers/isdn/hysdn/boardergo.c
+++ b/drivers/isdn/hysdn/boardergo.c
@@ -45,11 +45,10 @@ ergo_interrupt(int intno, void *dev_id)
45 if (!card->irq_enabled) 45 if (!card->irq_enabled)
46 return IRQ_NONE; /* other device interrupting or irq switched off */ 46 return IRQ_NONE; /* other device interrupting or irq switched off */
47 47
48 save_flags(flags); 48 spin_lock_irqsave(&card->hysdn_lock, flags); /* no further irqs allowed */
49 cli(); /* no further irqs allowed */
50 49
51 if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) { 50 if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) {
52 restore_flags(flags); /* restore old state */ 51 spin_unlock_irqrestore(&card->hysdn_lock, flags); /* restore old state */
53 return IRQ_NONE; /* no interrupt requested by E1 */ 52 return IRQ_NONE; /* no interrupt requested by E1 */
54 } 53 }
55 /* clear any pending ints on the board */ 54 /* clear any pending ints on the board */
@@ -61,7 +60,7 @@ ergo_interrupt(int intno, void *dev_id)
61 /* start kernel task immediately after leaving all interrupts */ 60 /* start kernel task immediately after leaving all interrupts */
62 if (!card->hw_lock) 61 if (!card->hw_lock)
63 schedule_work(&card->irq_queue); 62 schedule_work(&card->irq_queue);
64 restore_flags(flags); 63 spin_unlock_irqrestore(&card->hysdn_lock, flags);
65 return IRQ_HANDLED; 64 return IRQ_HANDLED;
66} /* ergo_interrupt */ 65} /* ergo_interrupt */
67 66
@@ -83,10 +82,9 @@ ergo_irq_bh(hysdn_card * card)
83 82
84 dpr = card->dpram; /* point to DPRAM */ 83 dpr = card->dpram; /* point to DPRAM */
85 84
86 save_flags(flags); 85 spin_lock_irqsave(&card->hysdn_lock, flags);
87 cli();
88 if (card->hw_lock) { 86 if (card->hw_lock) {
89 restore_flags(flags); /* hardware currently unavailable */ 87 spin_unlock_irqrestore(&card->hysdn_lock, flags); /* hardware currently unavailable */
90 return; 88 return;
91 } 89 }
92 card->hw_lock = 1; /* we now lock the hardware */ 90 card->hw_lock = 1; /* we now lock the hardware */
@@ -120,7 +118,7 @@ ergo_irq_bh(hysdn_card * card)
120 card->hw_lock = 0; /* free hardware again */ 118 card->hw_lock = 0; /* free hardware again */
121 } while (again); /* until nothing more to do */ 119 } while (again); /* until nothing more to do */
122 120
123 restore_flags(flags); 121 spin_unlock_irqrestore(&card->hysdn_lock, flags);
124} /* ergo_irq_bh */ 122} /* ergo_irq_bh */
125 123
126 124
@@ -137,8 +135,7 @@ ergo_stopcard(hysdn_card * card)
137#ifdef CONFIG_HYSDN_CAPI 135#ifdef CONFIG_HYSDN_CAPI
138 hycapi_capi_stop(card); 136 hycapi_capi_stop(card);
139#endif /* CONFIG_HYSDN_CAPI */ 137#endif /* CONFIG_HYSDN_CAPI */
140 save_flags(flags); 138 spin_lock_irqsave(&card->hysdn_lock, flags);
141 cli();
142 val = bytein(card->iobase + PCI9050_INTR_REG); /* get actual value */ 139 val = bytein(card->iobase + PCI9050_INTR_REG); /* get actual value */
143 val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1); /* mask irq */ 140 val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1); /* mask irq */
144 byteout(card->iobase + PCI9050_INTR_REG, val); 141 byteout(card->iobase + PCI9050_INTR_REG, val);
@@ -147,7 +144,7 @@ ergo_stopcard(hysdn_card * card)
147 card->state = CARD_STATE_UNUSED; 144 card->state = CARD_STATE_UNUSED;
148 card->err_log_state = ERRLOG_STATE_OFF; /* currently no log active */ 145 card->err_log_state = ERRLOG_STATE_OFF; /* currently no log active */
149 146
150 restore_flags(flags); 147 spin_unlock_irqrestore(&card->hysdn_lock, flags);
151} /* ergo_stopcard */ 148} /* ergo_stopcard */
152 149
153/**************************************************************************/ 150/**************************************************************************/
@@ -162,12 +159,11 @@ ergo_set_errlog_state(hysdn_card * card, int on)
162 card->err_log_state = ERRLOG_STATE_OFF; /* must be off */ 159 card->err_log_state = ERRLOG_STATE_OFF; /* must be off */
163 return; 160 return;
164 } 161 }
165 save_flags(flags); 162 spin_lock_irqsave(&card->hysdn_lock, flags);
166 cli();
167 163
168 if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) || 164 if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) ||
169 ((card->err_log_state == ERRLOG_STATE_ON) && on)) { 165 ((card->err_log_state == ERRLOG_STATE_ON) && on)) {
170 restore_flags(flags); 166 spin_unlock_irqrestore(&card->hysdn_lock, flags);
171 return; /* nothing to do */ 167 return; /* nothing to do */
172 } 168 }
173 if (on) 169 if (on)
@@ -175,7 +171,7 @@ ergo_set_errlog_state(hysdn_card * card, int on)
175 else 171 else
176 card->err_log_state = ERRLOG_STATE_STOP; /* request stop */ 172 card->err_log_state = ERRLOG_STATE_STOP; /* request stop */
177 173
178 restore_flags(flags); 174 spin_unlock_irqrestore(&card->hysdn_lock, flags);
179 schedule_work(&card->irq_queue); 175 schedule_work(&card->irq_queue);
180} /* ergo_set_errlog_state */ 176} /* ergo_set_errlog_state */
181 177
@@ -356,8 +352,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
356 352
357 if (card->debug_flags & LOG_POF_RECORD) 353 if (card->debug_flags & LOG_POF_RECORD)
358 hysdn_addlog(card, "ERGO: pof boot success"); 354 hysdn_addlog(card, "ERGO: pof boot success");
359 save_flags(flags); 355 spin_lock_irqsave(&card->hysdn_lock, flags);
360 cli();
361 356
362 card->state = CARD_STATE_RUN; /* now card is running */ 357 card->state = CARD_STATE_RUN; /* now card is running */
363 /* enable the cards interrupt */ 358 /* enable the cards interrupt */
@@ -370,7 +365,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
370 dpr->ToHyInt = 1; 365 dpr->ToHyInt = 1;
371 dpr->ToPcInt = 1; /* interrupt to E1 for all cards */ 366 dpr->ToPcInt = 1; /* interrupt to E1 for all cards */
372 367
373 restore_flags(flags); 368 spin_unlock_irqrestore(&card->hysdn_lock, flags);
374 if ((hynet_enable & (1 << card->myid)) 369 if ((hynet_enable & (1 << card->myid))
375 && (i = hysdn_net_create(card))) 370 && (i = hysdn_net_create(card)))
376 { 371 {
@@ -448,6 +443,7 @@ ergo_inithardware(hysdn_card * card)
448 card->waitpofready = ergo_waitpofready; 443 card->waitpofready = ergo_waitpofready;
449 card->set_errlog_state = ergo_set_errlog_state; 444 card->set_errlog_state = ergo_set_errlog_state;
450 INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card); 445 INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card);
446 card->hysdn_lock = SPIN_LOCK_UNLOCKED;
451 447
452 return (0); 448 return (0);
453} /* ergo_inithardware */ 449} /* ergo_inithardware */
diff --git a/drivers/isdn/hysdn/hysdn_defs.h b/drivers/isdn/hysdn/hysdn_defs.h
index 461e831592dd..729df4089385 100644
--- a/drivers/isdn/hysdn/hysdn_defs.h
+++ b/drivers/isdn/hysdn/hysdn_defs.h
@@ -188,6 +188,8 @@ typedef struct HYSDN_CARD {
188 /* init and deinit stopcard for booting, too */ 188 /* init and deinit stopcard for booting, too */
189 void (*stopcard) (struct HYSDN_CARD *); 189 void (*stopcard) (struct HYSDN_CARD *);
190 void (*releasehardware) (struct HYSDN_CARD *); 190 void (*releasehardware) (struct HYSDN_CARD *);
191
192 spinlock_t hysdn_lock;
191#ifdef CONFIG_HYSDN_CAPI 193#ifdef CONFIG_HYSDN_CAPI
192 struct hycapictrl_info { 194 struct hycapictrl_info {
193 char cardname[32]; 195 char cardname[32];
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index c4301e8338ef..fcd49920b220 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -116,8 +116,7 @@ put_log_buffer(hysdn_card * card, char *cp)
116 strcpy(ib->log_start, cp); /* set output string */ 116 strcpy(ib->log_start, cp); /* set output string */
117 ib->next = NULL; 117 ib->next = NULL;
118 ib->proc_ctrl = pd; /* point to own control structure */ 118 ib->proc_ctrl = pd; /* point to own control structure */
119 save_flags(flags); 119 spin_lock_irqsave(&card->hysdn_lock, flags);
120 cli();
121 ib->usage_cnt = pd->if_used; 120 ib->usage_cnt = pd->if_used;
122 if (!pd->log_head) 121 if (!pd->log_head)
123 pd->log_head = ib; /* new head */ 122 pd->log_head = ib; /* new head */
@@ -125,7 +124,7 @@ put_log_buffer(hysdn_card * card, char *cp)
125 pd->log_tail->next = ib; /* follows existing messages */ 124 pd->log_tail->next = ib; /* follows existing messages */
126 pd->log_tail = ib; /* new tail */ 125 pd->log_tail = ib; /* new tail */
127 i = pd->del_lock++; /* get lock state */ 126 i = pd->del_lock++; /* get lock state */
128 restore_flags(flags); 127 spin_unlock_irqrestore(&card->hysdn_lock, flags);
129 128
130 /* delete old entrys */ 129 /* delete old entrys */
131 if (!i) 130 if (!i)
@@ -270,14 +269,13 @@ hysdn_log_open(struct inode *ino, struct file *filep)
270 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { 269 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
271 270
272 /* read access -> log/debug read */ 271 /* read access -> log/debug read */
273 save_flags(flags); 272 spin_lock_irqsave(&card->hysdn_lock, flags);
274 cli();
275 pd->if_used++; 273 pd->if_used++;
276 if (pd->log_head) 274 if (pd->log_head)
277 filep->private_data = &pd->log_tail->next; 275 filep->private_data = &pd->log_tail->next;
278 else 276 else
279 filep->private_data = &pd->log_head; 277 filep->private_data = &pd->log_head;
280 restore_flags(flags); 278 spin_unlock_irqrestore(&card->hysdn_lock, flags);
281 } else { /* simultaneous read/write access forbidden ! */ 279 } else { /* simultaneous read/write access forbidden ! */
282 unlock_kernel(); 280 unlock_kernel();
283 return (-EPERM); /* no permission this time */ 281 return (-EPERM); /* no permission this time */
@@ -301,7 +299,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
301 hysdn_card *card; 299 hysdn_card *card;
302 int retval = 0; 300 int retval = 0;
303 unsigned long flags; 301 unsigned long flags;
304 302 spinlock_t hysdn_lock = SPIN_LOCK_UNLOCKED;
305 303
306 lock_kernel(); 304 lock_kernel();
307 if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) { 305 if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
@@ -311,8 +309,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
311 /* read access -> log/debug read, mark one further file as closed */ 309 /* read access -> log/debug read, mark one further file as closed */
312 310
313 pd = NULL; 311 pd = NULL;
314 save_flags(flags); 312 spin_lock_irqsave(&hysdn_lock, flags);
315 cli();
316 inf = *((struct log_data **) filep->private_data); /* get first log entry */ 313 inf = *((struct log_data **) filep->private_data); /* get first log entry */
317 if (inf) 314 if (inf)
318 pd = (struct procdata *) inf->proc_ctrl; /* still entries there */ 315 pd = (struct procdata *) inf->proc_ctrl; /* still entries there */
@@ -335,7 +332,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
335 inf->usage_cnt--; /* decrement usage count for buffers */ 332 inf->usage_cnt--; /* decrement usage count for buffers */
336 inf = inf->next; 333 inf = inf->next;
337 } 334 }
338 restore_flags(flags); 335 spin_unlock_irqrestore(&hysdn_lock, flags);
339 336
340 if (pd) 337 if (pd)
341 if (pd->if_used <= 0) /* delete buffers if last file closed */ 338 if (pd->if_used <= 0) /* delete buffers if last file closed */
diff --git a/drivers/isdn/hysdn/hysdn_sched.c b/drivers/isdn/hysdn/hysdn_sched.c
index 1c0d54ac12ab..1fadf0133e9b 100644
--- a/drivers/isdn/hysdn/hysdn_sched.c
+++ b/drivers/isdn/hysdn/hysdn_sched.c
@@ -155,8 +155,7 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
155 if (card->debug_flags & LOG_SCHED_ASYN) 155 if (card->debug_flags & LOG_SCHED_ASYN)
156 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1); 156 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1);
157 157
158 save_flags(flags); 158 spin_lock_irqsave(&card->hysdn_lock, flags);
159 cli();
160 while (card->async_busy) { 159 while (card->async_busy) {
161 sti(); 160 sti();
162 161
@@ -165,7 +164,7 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
165 164
166 msleep_interruptible(20); /* Timeout 20ms */ 165 msleep_interruptible(20); /* Timeout 20ms */
167 if (!--cnt) { 166 if (!--cnt) {
168 restore_flags(flags); 167 spin_unlock_irqrestore(&card->hysdn_lock, flags);
169 return (-ERR_ASYNC_TIME); /* timed out */ 168 return (-ERR_ASYNC_TIME); /* timed out */
170 } 169 }
171 cli(); 170 cli();
@@ -194,13 +193,13 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
194 193
195 msleep_interruptible(20); /* Timeout 20ms */ 194 msleep_interruptible(20); /* Timeout 20ms */
196 if (!--cnt) { 195 if (!--cnt) {
197 restore_flags(flags); 196 spin_unlock_irqrestore(&card->hysdn_lock, flags);
198 return (-ERR_ASYNC_TIME); /* timed out */ 197 return (-ERR_ASYNC_TIME); /* timed out */
199 } 198 }
200 cli(); 199 cli();
201 } /* wait for buffer to become free again */ 200 } /* wait for buffer to become free again */
202 201
203 restore_flags(flags); 202 spin_unlock_irqrestore(&card->hysdn_lock, flags);
204 203
205 if (card->debug_flags & LOG_SCHED_ASYN) 204 if (card->debug_flags & LOG_SCHED_ASYN)
206 hysdn_addlog(card, "async tx-cfg data send"); 205 hysdn_addlog(card, "async tx-cfg data send");
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index c3d79eef9e32..69aee2602aa6 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1134,9 +1134,12 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
1134 if (dev->drv[drvidx]->interface->readstat) { 1134 if (dev->drv[drvidx]->interface->readstat) {
1135 if (count > dev->drv[drvidx]->stavail) 1135 if (count > dev->drv[drvidx]->stavail)
1136 count = dev->drv[drvidx]->stavail; 1136 count = dev->drv[drvidx]->stavail;
1137 len = dev->drv[drvidx]->interface-> 1137 len = dev->drv[drvidx]->interface->readstat(buf, count,
1138 readstat(buf, count, drvidx, 1138 drvidx, isdn_minor2chan(minor));
1139 isdn_minor2chan(minor)); 1139 if (len < 0) {
1140 retval = len;
1141 goto out;
1142 }
1140 } else { 1143 } else {
1141 len = 0; 1144 len = 0;
1142 } 1145 }
diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
index 6649f8bc9951..730bbd07ebc7 100644
--- a/drivers/isdn/icn/icn.c
+++ b/drivers/isdn/icn/icn.c
@@ -1010,7 +1010,8 @@ icn_readstatus(u_char __user *buf, int len, icn_card * card)
1010 for (p = buf, count = 0; count < len; p++, count++) { 1010 for (p = buf, count = 0; count < len; p++, count++) {
1011 if (card->msg_buf_read == card->msg_buf_write) 1011 if (card->msg_buf_read == card->msg_buf_write)
1012 return count; 1012 return count;
1013 put_user(*card->msg_buf_read++, p); 1013 if (put_user(*card->msg_buf_read++, p))
1014 return -EFAULT;
1014 if (card->msg_buf_read > card->msg_buf_end) 1015 if (card->msg_buf_read > card->msg_buf_end)
1015 card->msg_buf_read = card->msg_buf; 1016 card->msg_buf_read = card->msg_buf;
1016 } 1017 }
diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
index fabbd461603e..c3ae2edaf6fa 100644
--- a/drivers/isdn/isdnloop/isdnloop.c
+++ b/drivers/isdn/isdnloop/isdnloop.c
@@ -100,12 +100,11 @@ isdnloop_pollbchan(unsigned long data)
100 isdnloop_bchan_send(card, 1); 100 isdnloop_bchan_send(card, 1);
101 if (card->flags & (ISDNLOOP_FLAGS_B1ACTIVE | ISDNLOOP_FLAGS_B2ACTIVE)) { 101 if (card->flags & (ISDNLOOP_FLAGS_B1ACTIVE | ISDNLOOP_FLAGS_B2ACTIVE)) {
102 /* schedule b-channel polling again */ 102 /* schedule b-channel polling again */
103 save_flags(flags); 103 spin_lock_irqsave(&card->isdnloop_lock, flags);
104 cli();
105 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD; 104 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD;
106 add_timer(&card->rb_timer); 105 add_timer(&card->rb_timer);
107 card->flags |= ISDNLOOP_FLAGS_RBTIMER; 106 card->flags |= ISDNLOOP_FLAGS_RBTIMER;
108 restore_flags(flags); 107 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
109 } else 108 } else
110 card->flags &= ~ISDNLOOP_FLAGS_RBTIMER; 109 card->flags &= ~ISDNLOOP_FLAGS_RBTIMER;
111} 110}
@@ -281,8 +280,7 @@ isdnloop_putmsg(isdnloop_card * card, unsigned char c)
281{ 280{
282 ulong flags; 281 ulong flags;
283 282
284 save_flags(flags); 283 spin_lock_irqsave(&card->isdnloop_lock, flags);
285 cli();
286 *card->msg_buf_write++ = (c == 0xff) ? '\n' : c; 284 *card->msg_buf_write++ = (c == 0xff) ? '\n' : c;
287 if (card->msg_buf_write == card->msg_buf_read) { 285 if (card->msg_buf_write == card->msg_buf_read) {
288 if (++card->msg_buf_read > card->msg_buf_end) 286 if (++card->msg_buf_read > card->msg_buf_end)
@@ -290,7 +288,7 @@ isdnloop_putmsg(isdnloop_card * card, unsigned char c)
290 } 288 }
291 if (card->msg_buf_write > card->msg_buf_end) 289 if (card->msg_buf_write > card->msg_buf_end)
292 card->msg_buf_write = card->msg_buf; 290 card->msg_buf_write = card->msg_buf;
293 restore_flags(flags); 291 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
294} 292}
295 293
296/* 294/*
@@ -372,21 +370,19 @@ isdnloop_polldchan(unsigned long data)
372 if (!(card->flags & ISDNLOOP_FLAGS_RBTIMER)) { 370 if (!(card->flags & ISDNLOOP_FLAGS_RBTIMER)) {
373 /* schedule b-channel polling */ 371 /* schedule b-channel polling */
374 card->flags |= ISDNLOOP_FLAGS_RBTIMER; 372 card->flags |= ISDNLOOP_FLAGS_RBTIMER;
375 save_flags(flags); 373 spin_lock_irqsave(&card->isdnloop_lock, flags);
376 cli();
377 del_timer(&card->rb_timer); 374 del_timer(&card->rb_timer);
378 card->rb_timer.function = isdnloop_pollbchan; 375 card->rb_timer.function = isdnloop_pollbchan;
379 card->rb_timer.data = (unsigned long) card; 376 card->rb_timer.data = (unsigned long) card;
380 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD; 377 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD;
381 add_timer(&card->rb_timer); 378 add_timer(&card->rb_timer);
382 restore_flags(flags); 379 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
383 } 380 }
384 /* schedule again */ 381 /* schedule again */
385 save_flags(flags); 382 spin_lock_irqsave(&card->isdnloop_lock, flags);
386 cli();
387 card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD; 383 card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD;
388 add_timer(&card->st_timer); 384 add_timer(&card->st_timer);
389 restore_flags(flags); 385 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
390} 386}
391 387
392/* 388/*
@@ -416,8 +412,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card)
416 return 0; 412 return 0;
417 if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE) 413 if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE)
418 return 0; 414 return 0;
419 save_flags(flags); 415 spin_lock_irqsave(&card->isdnloop_lock, flags);
420 cli();
421 nskb = dev_alloc_skb(skb->len); 416 nskb = dev_alloc_skb(skb->len);
422 if (nskb) { 417 if (nskb) {
423 memcpy(skb_put(nskb, len), skb->data, len); 418 memcpy(skb_put(nskb, len), skb->data, len);
@@ -426,7 +421,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card)
426 } else 421 } else
427 len = 0; 422 len = 0;
428 card->sndcount[channel] += len; 423 card->sndcount[channel] += len;
429 restore_flags(flags); 424 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
430 } 425 }
431 return len; 426 return len;
432} 427}
@@ -451,7 +446,8 @@ isdnloop_readstatus(u_char __user *buf, int len, isdnloop_card * card)
451 for (p = buf, count = 0; count < len; p++, count++) { 446 for (p = buf, count = 0; count < len; p++, count++) {
452 if (card->msg_buf_read == card->msg_buf_write) 447 if (card->msg_buf_read == card->msg_buf_write)
453 return count; 448 return count;
454 put_user(*card->msg_buf_read++, p); 449 if (put_user(*card->msg_buf_read++, p))
450 return -EFAULT;
455 if (card->msg_buf_read > card->msg_buf_end) 451 if (card->msg_buf_read > card->msg_buf_end)
456 card->msg_buf_read = card->msg_buf; 452 card->msg_buf_read = card->msg_buf;
457 } 453 }
@@ -576,8 +572,7 @@ isdnloop_atimeout(isdnloop_card * card, int ch)
576 unsigned long flags; 572 unsigned long flags;
577 char buf[60]; 573 char buf[60];
578 574
579 save_flags(flags); 575 spin_lock_irqsave(&card->isdnloop_lock, flags);
580 cli();
581 if (card->rcard) { 576 if (card->rcard) {
582 isdnloop_fake(card->rcard[ch], "DDIS_I", card->rch[ch] + 1); 577 isdnloop_fake(card->rcard[ch], "DDIS_I", card->rch[ch] + 1);
583 card->rcard[ch]->rcard[card->rch[ch]] = NULL; 578 card->rcard[ch]->rcard[card->rch[ch]] = NULL;
@@ -587,7 +582,7 @@ isdnloop_atimeout(isdnloop_card * card, int ch)
587 /* No user responding */ 582 /* No user responding */
588 sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 3)); 583 sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 3));
589 isdnloop_fake(card, buf, ch + 1); 584 isdnloop_fake(card, buf, ch + 1);
590 restore_flags(flags); 585 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
591} 586}
592 587
593/* 588/*
@@ -622,8 +617,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch)
622{ 617{
623 unsigned long flags; 618 unsigned long flags;
624 619
625 save_flags(flags); 620 spin_lock_irqsave(&card->isdnloop_lock, flags);
626 cli();
627 init_timer(&card->c_timer[ch]); 621 init_timer(&card->c_timer[ch]);
628 card->c_timer[ch].expires = jiffies + ISDNLOOP_TIMER_ALERTWAIT; 622 card->c_timer[ch].expires = jiffies + ISDNLOOP_TIMER_ALERTWAIT;
629 if (ch) 623 if (ch)
@@ -632,7 +626,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch)
632 card->c_timer[ch].function = isdnloop_atimeout0; 626 card->c_timer[ch].function = isdnloop_atimeout0;
633 card->c_timer[ch].data = (unsigned long) card; 627 card->c_timer[ch].data = (unsigned long) card;
634 add_timer(&card->c_timer[ch]); 628 add_timer(&card->c_timer[ch]);
635 restore_flags(flags); 629 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
636} 630}
637 631
638/* 632/*
@@ -647,10 +641,9 @@ isdnloop_kill_ctimer(isdnloop_card * card, int ch)
647{ 641{
648 unsigned long flags; 642 unsigned long flags;
649 643
650 save_flags(flags); 644 spin_lock_irqsave(&card->isdnloop_lock, flags);
651 cli();
652 del_timer(&card->c_timer[ch]); 645 del_timer(&card->c_timer[ch]);
653 restore_flags(flags); 646 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
654} 647}
655 648
656static u_char si2bit[] = 649static u_char si2bit[] =
@@ -706,13 +699,12 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd)
706 } 699 }
707 } 700 }
708 if (num_match) { 701 if (num_match) {
709 save_flags(flags); 702 spin_lock_irqsave(&card->isdnloop_lock, flags);
710 cli();
711 /* channel idle? */ 703 /* channel idle? */
712 if (!(cc->rcard[ch])) { 704 if (!(cc->rcard[ch])) {
713 /* Check SI */ 705 /* Check SI */
714 if (!(si2bit[cmd->parm.setup.si1] & cc->sil[ch])) { 706 if (!(si2bit[cmd->parm.setup.si1] & cc->sil[ch])) {
715 restore_flags(flags); 707 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
716 return 3; 708 return 3;
717 } 709 }
718 /* ch is idle, si and number matches */ 710 /* ch is idle, si and number matches */
@@ -720,10 +712,10 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd)
720 cc->rch[ch] = lch; 712 cc->rch[ch] = lch;
721 card->rcard[lch] = cc; 713 card->rcard[lch] = cc;
722 card->rch[lch] = ch; 714 card->rch[lch] = ch;
723 restore_flags(flags); 715 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
724 return 0; 716 return 0;
725 } else { 717 } else {
726 restore_flags(flags); 718 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
727 /* num matches, but busy */ 719 /* num matches, but busy */
728 if (ch == 1) 720 if (ch == 1)
729 return 1; 721 return 1;
@@ -1027,8 +1019,7 @@ isdnloop_stopcard(isdnloop_card * card)
1027 unsigned long flags; 1019 unsigned long flags;
1028 isdn_ctrl cmd; 1020 isdn_ctrl cmd;
1029 1021
1030 save_flags(flags); 1022 spin_lock_irqsave(&card->isdnloop_lock, flags);
1031 cli();
1032 if (card->flags & ISDNLOOP_FLAGS_RUNNING) { 1023 if (card->flags & ISDNLOOP_FLAGS_RUNNING) {
1033 card->flags &= ~ISDNLOOP_FLAGS_RUNNING; 1024 card->flags &= ~ISDNLOOP_FLAGS_RUNNING;
1034 del_timer(&card->st_timer); 1025 del_timer(&card->st_timer);
@@ -1039,7 +1030,7 @@ isdnloop_stopcard(isdnloop_card * card)
1039 cmd.driver = card->myid; 1030 cmd.driver = card->myid;
1040 card->interface.statcallb(&cmd); 1031 card->interface.statcallb(&cmd);
1041 } 1032 }
1042 restore_flags(flags); 1033 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1043} 1034}
1044 1035
1045/* 1036/*
@@ -1078,18 +1069,17 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1078 return -EBUSY; 1069 return -EBUSY;
1079 if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef))) 1070 if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef)))
1080 return -EFAULT; 1071 return -EFAULT;
1081 save_flags(flags); 1072 spin_lock_irqsave(&card->isdnloop_lock, flags);
1082 cli();
1083 switch (sdef.ptype) { 1073 switch (sdef.ptype) {
1084 case ISDN_PTYPE_EURO: 1074 case ISDN_PTYPE_EURO:
1085 if (isdnloop_fake(card, "DRV1.23EC-Q.931-CAPI-CNS-BASIS-20.02.96", 1075 if (isdnloop_fake(card, "DRV1.23EC-Q.931-CAPI-CNS-BASIS-20.02.96",
1086 -1)) { 1076 -1)) {
1087 restore_flags(flags); 1077 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1088 return -ENOMEM; 1078 return -ENOMEM;
1089 } 1079 }
1090 card->sil[0] = card->sil[1] = 4; 1080 card->sil[0] = card->sil[1] = 4;
1091 if (isdnloop_fake(card, "TEI OK", 0)) { 1081 if (isdnloop_fake(card, "TEI OK", 0)) {
1092 restore_flags(flags); 1082 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1093 return -ENOMEM; 1083 return -ENOMEM;
1094 } 1084 }
1095 for (i = 0; i < 3; i++) 1085 for (i = 0; i < 3; i++)
@@ -1098,12 +1088,12 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1098 case ISDN_PTYPE_1TR6: 1088 case ISDN_PTYPE_1TR6:
1099 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95", 1089 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
1100 -1)) { 1090 -1)) {
1101 restore_flags(flags); 1091 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1102 return -ENOMEM; 1092 return -ENOMEM;
1103 } 1093 }
1104 card->sil[0] = card->sil[1] = 4; 1094 card->sil[0] = card->sil[1] = 4;
1105 if (isdnloop_fake(card, "TEI OK", 0)) { 1095 if (isdnloop_fake(card, "TEI OK", 0)) {
1106 restore_flags(flags); 1096 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1107 return -ENOMEM; 1097 return -ENOMEM;
1108 } 1098 }
1109 strcpy(card->s0num[0], sdef.num[0]); 1099 strcpy(card->s0num[0], sdef.num[0]);
@@ -1111,7 +1101,7 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1111 card->s0num[2][0] = '\0'; 1101 card->s0num[2][0] = '\0';
1112 break; 1102 break;
1113 default: 1103 default:
1114 restore_flags(flags); 1104 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1115 printk(KERN_WARNING "isdnloop: Illegal D-channel protocol %d\n", 1105 printk(KERN_WARNING "isdnloop: Illegal D-channel protocol %d\n",
1116 sdef.ptype); 1106 sdef.ptype);
1117 return -EINVAL; 1107 return -EINVAL;
@@ -1122,7 +1112,7 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1122 card->st_timer.data = (unsigned long) card; 1112 card->st_timer.data = (unsigned long) card;
1123 add_timer(&card->st_timer); 1113 add_timer(&card->st_timer);
1124 card->flags |= ISDNLOOP_FLAGS_RUNNING; 1114 card->flags |= ISDNLOOP_FLAGS_RUNNING;
1125 restore_flags(flags); 1115 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1126 return 0; 1116 return 0;
1127} 1117}
1128 1118
@@ -1472,6 +1462,7 @@ isdnloop_initcard(char *id)
1472 skb_queue_head_init(&card->bqueue[i]); 1462 skb_queue_head_init(&card->bqueue[i]);
1473 } 1463 }
1474 skb_queue_head_init(&card->dqueue); 1464 skb_queue_head_init(&card->dqueue);
1465 card->isdnloop_lock = SPIN_LOCK_UNLOCKED;
1475 card->next = cards; 1466 card->next = cards;
1476 cards = card; 1467 cards = card;
1477 if (!register_isdn(&card->interface)) { 1468 if (!register_isdn(&card->interface)) {
diff --git a/drivers/isdn/isdnloop/isdnloop.h b/drivers/isdn/isdnloop/isdnloop.h
index d699fe53e1c3..0d458a86f529 100644
--- a/drivers/isdn/isdnloop/isdnloop.h
+++ b/drivers/isdn/isdnloop/isdnloop.h
@@ -94,6 +94,7 @@ typedef struct isdnloop_card {
94 struct sk_buff_head 94 struct sk_buff_head
95 bqueue[ISDNLOOP_BCH]; /* B-Channel queues */ 95 bqueue[ISDNLOOP_BCH]; /* B-Channel queues */
96 struct sk_buff_head dqueue; /* D-Channel queue */ 96 struct sk_buff_head dqueue; /* D-Channel queue */
97 spinlock_t isdnloop_lock;
97} isdnloop_card; 98} isdnloop_card;
98 99
99/* 100/*
diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c
index 94f21486bb24..6ead5e1508b7 100644
--- a/drivers/isdn/pcbit/drv.c
+++ b/drivers/isdn/pcbit/drv.c
@@ -725,23 +725,27 @@ static int pcbit_stat(u_char __user *buf, int len, int driver, int channel)
725 725
726 if (stat_st < stat_end) 726 if (stat_st < stat_end)
727 { 727 {
728 copy_to_user(buf, statbuf + stat_st, len); 728 if (copy_to_user(buf, statbuf + stat_st, len))
729 return -EFAULT;
729 stat_st += len; 730 stat_st += len;
730 } 731 }
731 else 732 else
732 { 733 {
733 if (len > STATBUF_LEN - stat_st) 734 if (len > STATBUF_LEN - stat_st)
734 { 735 {
735 copy_to_user(buf, statbuf + stat_st, 736 if (copy_to_user(buf, statbuf + stat_st,
736 STATBUF_LEN - stat_st); 737 STATBUF_LEN - stat_st))
737 copy_to_user(buf, statbuf, 738 return -EFAULT;
738 len - (STATBUF_LEN - stat_st)); 739 if (copy_to_user(buf, statbuf,
740 len - (STATBUF_LEN - stat_st)))
741 return -EFAULT;
739 742
740 stat_st = len - (STATBUF_LEN - stat_st); 743 stat_st = len - (STATBUF_LEN - stat_st);
741 } 744 }
742 else 745 else
743 { 746 {
744 copy_to_user(buf, statbuf + stat_st, len); 747 if (copy_to_user(buf, statbuf + stat_st, len))
748 return -EFAULT;
745 749
746 stat_st += len; 750 stat_st += len;
747 751
diff --git a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c
index 13e7d219d1c7..937fd2120381 100644
--- a/drivers/isdn/pcbit/layer2.c
+++ b/drivers/isdn/pcbit/layer2.c
@@ -311,6 +311,7 @@ pcbit_deliver(void *data)
311 dev->read_queue = frame->next; 311 dev->read_queue = frame->next;
312 spin_unlock_irqrestore(&dev->lock, flags); 312 spin_unlock_irqrestore(&dev->lock, flags);
313 313
314 msg = 0;
314 SET_MSG_CPU(msg, 0); 315 SET_MSG_CPU(msg, 0);
315 SET_MSG_PROC(msg, 0); 316 SET_MSG_PROC(msg, 0);
316 SET_MSG_CMD(msg, frame->skb->data[2]); 317 SET_MSG_CMD(msg, frame->skb->data[2]);
diff --git a/drivers/isdn/sc/init.c b/drivers/isdn/sc/init.c
index 222ca7c08baa..06c9872e8c6a 100644
--- a/drivers/isdn/sc/init.c
+++ b/drivers/isdn/sc/init.c
@@ -98,13 +98,14 @@ static int __init sc_init(void)
98 * Confirm the I/O Address with a test 98 * Confirm the I/O Address with a test
99 */ 99 */
100 if(io[b] == 0) { 100 if(io[b] == 0) {
101 pr_debug("I/O Address 0x%x is in use.\n"); 101 pr_debug("I/O Address invalid.\n");
102 continue; 102 continue;
103 } 103 }
104 104
105 outb(0x18, io[b] + 0x400 * EXP_PAGE0); 105 outb(0x18, io[b] + 0x400 * EXP_PAGE0);
106 if(inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) { 106 if(inb(io[b] + 0x400 * EXP_PAGE0) != 0x18) {
107 pr_debug("I/O Base 0x%x fails test\n"); 107 pr_debug("I/O Base 0x%x fails test\n",
108 io[b] + 0x400 * EXP_PAGE0);
108 continue; 109 continue;
109 } 110 }
110 } 111 }
@@ -158,8 +159,8 @@ static int __init sc_init(void)
158 outb(0xFF, io[b] + RESET_OFFSET); 159 outb(0xFF, io[b] + RESET_OFFSET);
159 msleep_interruptible(10000); 160 msleep_interruptible(10000);
160 } 161 }
161 pr_debug("RAM Base for board %d is 0x%x, %s probe\n", b, ram[b], 162 pr_debug("RAM Base for board %d is 0x%lx, %s probe\n", b,
162 ram[b] == 0 ? "will" : "won't"); 163 ram[b], ram[b] == 0 ? "will" : "won't");
163 164
164 if(ram[b]) { 165 if(ram[b]) {
165 /* 166 /*
@@ -168,7 +169,7 @@ static int __init sc_init(void)
168 * board model 169 * board model
169 */ 170 */
170 if(request_region(ram[b], SRAM_PAGESIZE, "sc test")) { 171 if(request_region(ram[b], SRAM_PAGESIZE, "sc test")) {
171 pr_debug("request_region for RAM base 0x%x succeeded\n", ram[b]); 172 pr_debug("request_region for RAM base 0x%lx succeeded\n", ram[b]);
172 model = identify_board(ram[b], io[b]); 173 model = identify_board(ram[b], io[b]);
173 release_region(ram[b], SRAM_PAGESIZE); 174 release_region(ram[b], SRAM_PAGESIZE);
174 } 175 }
@@ -204,7 +205,7 @@ static int __init sc_init(void)
204 * Nope, there was no place in RAM for the 205 * Nope, there was no place in RAM for the
205 * board, or it couldn't be identified 206 * board, or it couldn't be identified
206 */ 207 */
207 pr_debug("Failed to find an adapter at 0x%x\n", ram[b]); 208 pr_debug("Failed to find an adapter at 0x%lx\n", ram[b]);
208 continue; 209 continue;
209 } 210 }
210 211
@@ -451,7 +452,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
451 HWConfig_pl hwci; 452 HWConfig_pl hwci;
452 int x; 453 int x;
453 454
454 pr_debug("Attempting to identify adapter @ 0x%x io 0x%x\n", 455 pr_debug("Attempting to identify adapter @ 0x%lx io 0x%x\n",
455 rambase, iobase); 456 rambase, iobase);
456 457
457 /* 458 /*
@@ -490,7 +491,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
490 outb(PRI_BASEPG_VAL, pgport); 491 outb(PRI_BASEPG_VAL, pgport);
491 msleep_interruptible(1000); 492 msleep_interruptible(1000);
492 sig = readl(rambase + SIG_OFFSET); 493 sig = readl(rambase + SIG_OFFSET);
493 pr_debug("Looking for a signature, got 0x%x\n", sig); 494 pr_debug("Looking for a signature, got 0x%lx\n", sig);
494 if(sig == SIGNATURE) 495 if(sig == SIGNATURE)
495 return PRI_BOARD; 496 return PRI_BOARD;
496 497
@@ -500,7 +501,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
500 outb(BRI_BASEPG_VAL, pgport); 501 outb(BRI_BASEPG_VAL, pgport);
501 msleep_interruptible(1000); 502 msleep_interruptible(1000);
502 sig = readl(rambase + SIG_OFFSET); 503 sig = readl(rambase + SIG_OFFSET);
503 pr_debug("Looking for a signature, got 0x%x\n", sig); 504 pr_debug("Looking for a signature, got 0x%lx\n", sig);
504 if(sig == SIGNATURE) 505 if(sig == SIGNATURE)
505 return BRI_BOARD; 506 return BRI_BOARD;
506 507
@@ -510,7 +511,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
510 * Try to spot a card 511 * Try to spot a card
511 */ 512 */
512 sig = readl(rambase + SIG_OFFSET); 513 sig = readl(rambase + SIG_OFFSET);
513 pr_debug("Looking for a signature, got 0x%x\n", sig); 514 pr_debug("Looking for a signature, got 0x%lx\n", sig);
514 if(sig != SIGNATURE) 515 if(sig != SIGNATURE)
515 return -1; 516 return -1;
516 517
@@ -540,7 +541,7 @@ static int identify_board(unsigned long rambase, unsigned int iobase)
540 memcpy_fromio(&rcvmsg, &(dpm->rsp_queue[dpm->rsp_tail]), MSG_LEN); 541 memcpy_fromio(&rcvmsg, &(dpm->rsp_queue[dpm->rsp_tail]), MSG_LEN);
541 pr_debug("Got HWConfig response, status = 0x%x\n", rcvmsg.rsp_status); 542 pr_debug("Got HWConfig response, status = 0x%x\n", rcvmsg.rsp_status);
542 memcpy(&hwci, &(rcvmsg.msg_data.HWCresponse), sizeof(HWConfig_pl)); 543 memcpy(&hwci, &(rcvmsg.msg_data.HWCresponse), sizeof(HWConfig_pl));
543 pr_debug("Hardware Config: Interface: %s, RAM Size: %d, Serial: %s\n" 544 pr_debug("Hardware Config: Interface: %s, RAM Size: %ld, Serial: %s\n"
544 " Part: %s, Rev: %s\n", 545 " Part: %s, Rev: %s\n",
545 hwci.st_u_sense ? "S/T" : "U", hwci.ram_size, 546 hwci.st_u_sense ? "S/T" : "U", hwci.ram_size,
546 hwci.serial_no, hwci.part_no, hwci.rev_no); 547 hwci.serial_no, hwci.part_no, hwci.rev_no);
diff --git a/drivers/isdn/sc/packet.c b/drivers/isdn/sc/packet.c
index f50defc38ae5..1e04676b016b 100644
--- a/drivers/isdn/sc/packet.c
+++ b/drivers/isdn/sc/packet.c
@@ -44,7 +44,7 @@ int sndpkt(int devId, int channel, struct sk_buff *data)
44 return -ENODEV; 44 return -ENODEV;
45 } 45 }
46 46
47 pr_debug("%s: sndpkt: frst = 0x%x nxt = %d f = %d n = %d\n", 47 pr_debug("%s: sndpkt: frst = 0x%lx nxt = %d f = %d n = %d\n",
48 sc_adapter[card]->devicename, 48 sc_adapter[card]->devicename,
49 sc_adapter[card]->channel[channel].first_sendbuf, 49 sc_adapter[card]->channel[channel].first_sendbuf,
50 sc_adapter[card]->channel[channel].next_sendbuf, 50 sc_adapter[card]->channel[channel].next_sendbuf,
@@ -66,7 +66,7 @@ int sndpkt(int devId, int channel, struct sk_buff *data)
66 ReqLnkWrite.buff_offset = sc_adapter[card]->channel[channel].next_sendbuf * 66 ReqLnkWrite.buff_offset = sc_adapter[card]->channel[channel].next_sendbuf *
67 BUFFER_SIZE + sc_adapter[card]->channel[channel].first_sendbuf; 67 BUFFER_SIZE + sc_adapter[card]->channel[channel].first_sendbuf;
68 ReqLnkWrite.msg_len = data->len; /* sk_buff size */ 68 ReqLnkWrite.msg_len = data->len; /* sk_buff size */
69 pr_debug("%s: writing %d bytes to buffer offset 0x%x\n", 69 pr_debug("%s: writing %d bytes to buffer offset 0x%lx\n",
70 sc_adapter[card]->devicename, 70 sc_adapter[card]->devicename,
71 ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset); 71 ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset);
72 memcpy_toshmem(card, (char *)ReqLnkWrite.buff_offset, data->data, ReqLnkWrite.msg_len); 72 memcpy_toshmem(card, (char *)ReqLnkWrite.buff_offset, data->data, ReqLnkWrite.msg_len);
@@ -74,7 +74,7 @@ int sndpkt(int devId, int channel, struct sk_buff *data)
74 /* 74 /*
75 * sendmessage 75 * sendmessage
76 */ 76 */
77 pr_debug("%s: sndpkt size=%d, buf_offset=0x%x buf_indx=%d\n", 77 pr_debug("%s: sndpkt size=%d, buf_offset=0x%lx buf_indx=%d\n",
78 sc_adapter[card]->devicename, 78 sc_adapter[card]->devicename,
79 ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset, 79 ReqLnkWrite.msg_len, ReqLnkWrite.buff_offset,
80 sc_adapter[card]->channel[channel].next_sendbuf); 80 sc_adapter[card]->channel[channel].next_sendbuf);
@@ -124,7 +124,7 @@ void rcvpkt(int card, RspMessage *rcvmsg)
124 return; 124 return;
125 } 125 }
126 skb_put(skb, rcvmsg->msg_data.response.msg_len); 126 skb_put(skb, rcvmsg->msg_data.response.msg_len);
127 pr_debug("%s: getting data from offset: 0x%x\n", 127 pr_debug("%s: getting data from offset: 0x%lx\n",
128 sc_adapter[card]->devicename, 128 sc_adapter[card]->devicename,
129 rcvmsg->msg_data.response.buff_offset); 129 rcvmsg->msg_data.response.buff_offset);
130 memcpy_fromshmem(card, 130 memcpy_fromshmem(card,
@@ -143,7 +143,7 @@ void rcvpkt(int card, RspMessage *rcvmsg)
143/* memset_shmem(card, rcvmsg->msg_data.response.buff_offset, 0, BUFFER_SIZE); */ 143/* memset_shmem(card, rcvmsg->msg_data.response.buff_offset, 0, BUFFER_SIZE); */
144 newll.buff_offset = rcvmsg->msg_data.response.buff_offset; 144 newll.buff_offset = rcvmsg->msg_data.response.buff_offset;
145 newll.msg_len = BUFFER_SIZE; 145 newll.msg_len = BUFFER_SIZE;
146 pr_debug("%s: recycled buffer at offset 0x%x size %d\n", 146 pr_debug("%s: recycled buffer at offset 0x%lx size %d\n",
147 sc_adapter[card]->devicename, 147 sc_adapter[card]->devicename,
148 newll.buff_offset, newll.msg_len); 148 newll.buff_offset, newll.msg_len);
149 sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead, 149 sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead,
@@ -186,7 +186,7 @@ int setup_buffers(int card, int c)
186 sc_adapter[card]->channel[c-1].num_sendbufs = nBuffers / 2; 186 sc_adapter[card]->channel[c-1].num_sendbufs = nBuffers / 2;
187 sc_adapter[card]->channel[c-1].free_sendbufs = nBuffers / 2; 187 sc_adapter[card]->channel[c-1].free_sendbufs = nBuffers / 2;
188 sc_adapter[card]->channel[c-1].next_sendbuf = 0; 188 sc_adapter[card]->channel[c-1].next_sendbuf = 0;
189 pr_debug("%s: send buffer setup complete: first=0x%x n=%d f=%d, nxt=%d\n", 189 pr_debug("%s: send buffer setup complete: first=0x%lx n=%d f=%d, nxt=%d\n",
190 sc_adapter[card]->devicename, 190 sc_adapter[card]->devicename,
191 sc_adapter[card]->channel[c-1].first_sendbuf, 191 sc_adapter[card]->channel[c-1].first_sendbuf,
192 sc_adapter[card]->channel[c-1].num_sendbufs, 192 sc_adapter[card]->channel[c-1].num_sendbufs,
@@ -203,7 +203,7 @@ int setup_buffers(int card, int c)
203 ((sc_adapter[card]->channel[c-1].first_sendbuf + 203 ((sc_adapter[card]->channel[c-1].first_sendbuf +
204 (nBuffers / 2) * buffer_size) + (buffer_size * i)); 204 (nBuffers / 2) * buffer_size) + (buffer_size * i));
205 RcvBuffOffset.msg_len = buffer_size; 205 RcvBuffOffset.msg_len = buffer_size;
206 pr_debug("%s: adding RcvBuffer #%d offset=0x%x sz=%d bufsz:%d\n", 206 pr_debug("%s: adding RcvBuffer #%d offset=0x%lx sz=%d bufsz:%d\n",
207 sc_adapter[card]->devicename, 207 sc_adapter[card]->devicename,
208 i + 1, RcvBuffOffset.buff_offset, 208 i + 1, RcvBuffOffset.buff_offset,
209 RcvBuffOffset.msg_len,buffer_size); 209 RcvBuffOffset.msg_len,buffer_size);
diff --git a/drivers/isdn/sc/shmem.c b/drivers/isdn/sc/shmem.c
index 24854826ca45..6f58862992db 100644
--- a/drivers/isdn/sc/shmem.c
+++ b/drivers/isdn/sc/shmem.c
@@ -61,7 +61,7 @@ void memcpy_toshmem(int card, void *dest, const void *src, size_t n)
61 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); 61 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
62 pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename, 62 pr_debug("%s: set page to %#x\n",sc_adapter[card]->devicename,
63 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80); 63 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE)>>14)|0x80);
64 pr_debug("%s: copying %d bytes from %#x to %#x\n", 64 pr_debug("%s: copying %d bytes from %#lx to %#lx\n",
65 sc_adapter[card]->devicename, n, 65 sc_adapter[card]->devicename, n,
66 (unsigned long) src, 66 (unsigned long) src,
67 sc_adapter[card]->rambase + ((unsigned long) dest %0x4000)); 67 sc_adapter[card]->rambase + ((unsigned long) dest %0x4000));
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index aecbbe2e89a9..3c1711210e38 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -91,6 +91,8 @@ EXPORT_SYMBOL_GPL(led_classdev_resume);
91 */ 91 */
92int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) 92int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
93{ 93{
94 int rc;
95
94 led_cdev->class_dev = class_device_create(leds_class, NULL, 0, 96 led_cdev->class_dev = class_device_create(leds_class, NULL, 0,
95 parent, "%s", led_cdev->name); 97 parent, "%s", led_cdev->name);
96 if (unlikely(IS_ERR(led_cdev->class_dev))) 98 if (unlikely(IS_ERR(led_cdev->class_dev)))
@@ -99,8 +101,10 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
99 class_set_devdata(led_cdev->class_dev, led_cdev); 101 class_set_devdata(led_cdev->class_dev, led_cdev);
100 102
101 /* register the attributes */ 103 /* register the attributes */
102 class_device_create_file(led_cdev->class_dev, 104 rc = class_device_create_file(led_cdev->class_dev,
103 &class_device_attr_brightness); 105 &class_device_attr_brightness);
106 if (rc)
107 goto err_out;
104 108
105 /* add to the list of leds */ 109 /* add to the list of leds */
106 write_lock(&leds_list_lock); 110 write_lock(&leds_list_lock);
@@ -110,16 +114,28 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
110#ifdef CONFIG_LEDS_TRIGGERS 114#ifdef CONFIG_LEDS_TRIGGERS
111 rwlock_init(&led_cdev->trigger_lock); 115 rwlock_init(&led_cdev->trigger_lock);
112 116
113 led_trigger_set_default(led_cdev); 117 rc = class_device_create_file(led_cdev->class_dev,
118 &class_device_attr_trigger);
119 if (rc)
120 goto err_out_led_list;
114 121
115 class_device_create_file(led_cdev->class_dev, 122 led_trigger_set_default(led_cdev);
116 &class_device_attr_trigger);
117#endif 123#endif
118 124
119 printk(KERN_INFO "Registered led device: %s\n", 125 printk(KERN_INFO "Registered led device: %s\n",
120 led_cdev->class_dev->class_id); 126 led_cdev->class_dev->class_id);
121 127
122 return 0; 128 return 0;
129
130#ifdef CONFIG_LEDS_TRIGGERS
131err_out_led_list:
132 class_device_remove_file(led_cdev->class_dev,
133 &class_device_attr_brightness);
134 list_del(&led_cdev->node);
135#endif
136err_out:
137 class_device_unregister(led_cdev->class_dev);
138 return rc;
123} 139}
124EXPORT_SYMBOL_GPL(led_classdev_register); 140EXPORT_SYMBOL_GPL(led_classdev_register);
125 141
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index 179c2876b541..29a8818a32ec 100644
--- a/drivers/leds/ledtrig-timer.c
+++ b/drivers/leds/ledtrig-timer.c
@@ -123,6 +123,7 @@ static CLASS_DEVICE_ATTR(delay_off, 0644, led_delay_off_show,
123static void timer_trig_activate(struct led_classdev *led_cdev) 123static void timer_trig_activate(struct led_classdev *led_cdev)
124{ 124{
125 struct timer_trig_data *timer_data; 125 struct timer_trig_data *timer_data;
126 int rc;
126 127
127 timer_data = kzalloc(sizeof(struct timer_trig_data), GFP_KERNEL); 128 timer_data = kzalloc(sizeof(struct timer_trig_data), GFP_KERNEL);
128 if (!timer_data) 129 if (!timer_data)
@@ -134,10 +135,21 @@ static void timer_trig_activate(struct led_classdev *led_cdev)
134 timer_data->timer.function = led_timer_function; 135 timer_data->timer.function = led_timer_function;
135 timer_data->timer.data = (unsigned long) led_cdev; 136 timer_data->timer.data = (unsigned long) led_cdev;
136 137
137 class_device_create_file(led_cdev->class_dev, 138 rc = class_device_create_file(led_cdev->class_dev,
138 &class_device_attr_delay_on); 139 &class_device_attr_delay_on);
139 class_device_create_file(led_cdev->class_dev, 140 if (rc) goto err_out;
141 rc = class_device_create_file(led_cdev->class_dev,
140 &class_device_attr_delay_off); 142 &class_device_attr_delay_off);
143 if (rc) goto err_out_delayon;
144
145 return;
146
147err_out_delayon:
148 class_device_remove_file(led_cdev->class_dev,
149 &class_device_attr_delay_on);
150err_out:
151 led_cdev->trigger_data = NULL;
152 kfree(timer_data);
141} 153}
142 154
143static void timer_trig_deactivate(struct led_classdev *led_cdev) 155static void timer_trig_deactivate(struct led_classdev *led_cdev)
diff --git a/drivers/mca/mca-bus.c b/drivers/mca/mca-bus.c
index 09baa43b2599..da862e4632dd 100644
--- a/drivers/mca/mca-bus.c
+++ b/drivers/mca/mca-bus.c
@@ -100,6 +100,7 @@ static DEVICE_ATTR(pos, S_IRUGO, mca_show_pos, NULL);
100int __init mca_register_device(int bus, struct mca_device *mca_dev) 100int __init mca_register_device(int bus, struct mca_device *mca_dev)
101{ 101{
102 struct mca_bus *mca_bus = mca_root_busses[bus]; 102 struct mca_bus *mca_bus = mca_root_busses[bus];
103 int rc;
103 104
104 mca_dev->dev.parent = &mca_bus->dev; 105 mca_dev->dev.parent = &mca_bus->dev;
105 mca_dev->dev.bus = &mca_bus_type; 106 mca_dev->dev.bus = &mca_bus_type;
@@ -108,13 +109,23 @@ int __init mca_register_device(int bus, struct mca_device *mca_dev)
108 mca_dev->dev.dma_mask = &mca_dev->dma_mask; 109 mca_dev->dev.dma_mask = &mca_dev->dma_mask;
109 mca_dev->dev.coherent_dma_mask = mca_dev->dma_mask; 110 mca_dev->dev.coherent_dma_mask = mca_dev->dma_mask;
110 111
111 if (device_register(&mca_dev->dev)) 112 rc = device_register(&mca_dev->dev);
112 return 0; 113 if (rc)
114 goto err_out;
113 115
114 device_create_file(&mca_dev->dev, &dev_attr_id); 116 rc = device_create_file(&mca_dev->dev, &dev_attr_id);
115 device_create_file(&mca_dev->dev, &dev_attr_pos); 117 if (rc) goto err_out_devreg;
118 rc = device_create_file(&mca_dev->dev, &dev_attr_pos);
119 if (rc) goto err_out_id;
116 120
117 return 1; 121 return 1;
122
123err_out_id:
124 device_remove_file(&mca_dev->dev, &dev_attr_id);
125err_out_devreg:
126 device_unregister(&mca_dev->dev);
127err_out:
128 return 0;
118} 129}
119 130
120/* */ 131/* */
@@ -130,13 +141,16 @@ struct mca_bus * __devinit mca_attach_bus(int bus)
130 return NULL; 141 return NULL;
131 } 142 }
132 143
133 mca_bus = kmalloc(sizeof(struct mca_bus), GFP_KERNEL); 144 mca_bus = kzalloc(sizeof(struct mca_bus), GFP_KERNEL);
134 if (!mca_bus) 145 if (!mca_bus)
135 return NULL; 146 return NULL;
136 memset(mca_bus, 0, sizeof(struct mca_bus)); 147
137 sprintf(mca_bus->dev.bus_id,"mca%d",bus); 148 sprintf(mca_bus->dev.bus_id,"mca%d",bus);
138 sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary"); 149 sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary");
139 device_register(&mca_bus->dev); 150 if (device_register(&mca_bus->dev)) {
151 kfree(mca_bus);
152 return NULL;
153 }
140 154
141 mca_root_busses[bus] = mca_bus; 155 mca_root_busses[bus] = mca_bus;
142 156
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 8e67634e79a0..d47d38ac71b1 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1413,7 +1413,7 @@ int bitmap_create(mddev_t *mddev)
1413 int err; 1413 int err;
1414 sector_t start; 1414 sector_t start;
1415 1415
1416 BUG_ON(sizeof(bitmap_super_t) != 256); 1416 BUILD_BUG_ON(sizeof(bitmap_super_t) != 256);
1417 1417
1418 if (!file && !mddev->bitmap_offset) /* bitmap disabled, nothing to do */ 1418 if (!file && !mddev->bitmap_offset) /* bitmap disabled, nothing to do */
1419 return 0; 1419 return 0;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 57fa64f93e5f..f7f19088f3be 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4912,6 +4912,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
4912} 4912}
4913 4913
4914static struct file_operations md_seq_fops = { 4914static struct file_operations md_seq_fops = {
4915 .owner = THIS_MODULE,
4915 .open = md_seq_open, 4916 .open = md_seq_open,
4916 .read = seq_read, 4917 .read = seq_read,
4917 .llseek = seq_lseek, 4918 .llseek = seq_lseek,
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index fb6c4cc8477d..14e69a736eda 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -665,6 +665,10 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
665 case BTTV_BOARD_TWINHAN_DST: 665 case BTTV_BOARD_TWINHAN_DST:
666 /* DST is not a frontend driver !!! */ 666 /* DST is not a frontend driver !!! */
667 state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL); 667 state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
668 if (!state) {
669 printk("dvb_bt8xx: No memory\n");
670 break;
671 }
668 /* Setup the Card */ 672 /* Setup the Card */
669 state->config = &dst_config; 673 state->config = &dst_config;
670 state->i2c = card->i2c_adapter; 674 state->i2c = card->i2c_adapter;
diff --git a/drivers/media/dvb/dvb-core/Kconfig b/drivers/media/dvb/dvb-core/Kconfig
index e46eae3b9be2..1990eda10c46 100644
--- a/drivers/media/dvb/dvb-core/Kconfig
+++ b/drivers/media/dvb/dvb-core/Kconfig
@@ -19,6 +19,6 @@ config DVB_CORE_ATTACH
19 allow the card drivers to only load the frontend modules 19 allow the card drivers to only load the frontend modules
20 they require. This saves several KBytes of memory. 20 they require. This saves several KBytes of memory.
21 21
22 Note: You will need moudule-init-tools v3.2 or later for this feature. 22 Note: You will need module-init-tools v3.2 or later for this feature.
23 23
24 If unsure say Y. 24 If unsure say Y.
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index fd3a9902f98d..5143e426d283 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-common.c
@@ -169,7 +169,7 @@ EXPORT_SYMBOL(dibusb_read_eeprom_byte);
169// Config Adjacent channels Perf -cal22 169// Config Adjacent channels Perf -cal22
170static struct dibx000_agc_config dib3000p_mt2060_agc_config = { 170static struct dibx000_agc_config dib3000p_mt2060_agc_config = {
171 .band_caps = BAND_VHF | BAND_UHF, 171 .band_caps = BAND_VHF | BAND_UHF,
172 .setup = (0 << 15) | (0 << 14) | (1 << 13) | (1 << 12) | (29 << 0), 172 .setup = (1 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (0 << 2) | (2 << 0),
173 173
174 .agc1_max = 48497, 174 .agc1_max = 48497,
175 .agc1_min = 23593, 175 .agc1_min = 23593,
@@ -196,10 +196,14 @@ static struct dib3000mc_config stk3000p_dib3000p_config = {
196 .ln_adc_level = 0x1cc7, 196 .ln_adc_level = 0x1cc7,
197 197
198 .output_mpeg2_in_188_bytes = 1, 198 .output_mpeg2_in_188_bytes = 1,
199
200 .agc_command1 = 1,
201 .agc_command2 = 1,
199}; 202};
200 203
201static struct dibx000_agc_config dib3000p_panasonic_agc_config = { 204static struct dibx000_agc_config dib3000p_panasonic_agc_config = {
202 .setup = (0 << 15) | (0 << 14) | (1 << 13) | (1 << 12) | (29 << 0), 205 .band_caps = BAND_VHF | BAND_UHF,
206 .setup = (1 << 8) | (5 << 5) | (1 << 4) | (1 << 3) | (0 << 2) | (2 << 0),
203 207
204 .agc1_max = 56361, 208 .agc1_max = 56361,
205 .agc1_min = 22282, 209 .agc1_min = 22282,
@@ -226,6 +230,9 @@ static struct dib3000mc_config mod3000p_dib3000p_config = {
226 .ln_adc_level = 0x1cc7, 230 .ln_adc_level = 0x1cc7,
227 231
228 .output_mpeg2_in_188_bytes = 1, 232 .output_mpeg2_in_188_bytes = 1,
233
234 .agc_command1 = 1,
235 .agc_command2 = 1,
229}; 236};
230 237
231int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *adap) 238int dibusb_dib3000mc_frontend_attach(struct dvb_usb_adapter *adap)
diff --git a/drivers/media/dvb/dvb-usb/dibusb.h b/drivers/media/dvb/dvb-usb/dibusb.h
index 5153fb943da1..b60781032742 100644
--- a/drivers/media/dvb/dvb-usb/dibusb.h
+++ b/drivers/media/dvb/dvb-usb/dibusb.h
@@ -99,7 +99,9 @@
99struct dibusb_state { 99struct dibusb_state {
100 struct dib_fe_xfer_ops ops; 100 struct dib_fe_xfer_ops ops;
101 int mt2060_present; 101 int mt2060_present;
102};
102 103
104struct dibusb_device_state {
103 /* for RC5 remote control */ 105 /* for RC5 remote control */
104 int old_toggle; 106 int old_toggle;
105 int last_repeat_count; 107 int last_repeat_count;
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
index a9219bf69b89..a58874c790b2 100644
--- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c
+++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
@@ -75,7 +75,7 @@ static int nova_t_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
75 u8 key[5],cmd[2] = { DIBUSB_REQ_POLL_REMOTE, 0x35 }, data,toggle,custom; 75 u8 key[5],cmd[2] = { DIBUSB_REQ_POLL_REMOTE, 0x35 }, data,toggle,custom;
76 u16 raw; 76 u16 raw;
77 int i; 77 int i;
78 struct dibusb_state *st = d->priv; 78 struct dibusb_device_state *st = d->priv;
79 79
80 dvb_usb_generic_rw(d,cmd,2,key,5,0); 80 dvb_usb_generic_rw(d,cmd,2,key,5,0);
81 81
@@ -184,6 +184,7 @@ static struct dvb_usb_device_properties nova_t_properties = {
184 .size_of_priv = sizeof(struct dibusb_state), 184 .size_of_priv = sizeof(struct dibusb_state),
185 } 185 }
186 }, 186 },
187 .size_of_priv = sizeof(struct dibusb_device_state),
187 188
188 .power_ctrl = dibusb2_0_power_ctrl, 189 .power_ctrl = dibusb2_0_power_ctrl,
189 .read_mac_address = nova_t_read_mac_address, 190 .read_mac_address = nova_t_read_mac_address,
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c
index ccc813b525d6..3561a777568c 100644
--- a/drivers/media/dvb/frontends/dib3000mc.c
+++ b/drivers/media/dvb/frontends/dib3000mc.c
@@ -345,7 +345,7 @@ static int dib3000mc_init(struct dvb_frontend *demod)
345 345
346 /* agc */ 346 /* agc */
347 dib3000mc_write_word(state, 36, state->cfg->max_time); 347 dib3000mc_write_word(state, 36, state->cfg->max_time);
348 dib3000mc_write_word(state, 37, agc->setup); 348 dib3000mc_write_word(state, 37, (state->cfg->agc_command1 << 13) | (state->cfg->agc_command2 << 12) | (0x1d << 0));
349 dib3000mc_write_word(state, 38, state->cfg->pwm3_value); 349 dib3000mc_write_word(state, 38, state->cfg->pwm3_value);
350 dib3000mc_write_word(state, 39, state->cfg->ln_adc_level); 350 dib3000mc_write_word(state, 39, state->cfg->ln_adc_level);
351 351
diff --git a/drivers/media/dvb/frontends/dib3000mc.h b/drivers/media/dvb/frontends/dib3000mc.h
index b198cd5b1843..0d6fdef77538 100644
--- a/drivers/media/dvb/frontends/dib3000mc.h
+++ b/drivers/media/dvb/frontends/dib3000mc.h
@@ -28,6 +28,9 @@ struct dib3000mc_config {
28 u16 max_time; 28 u16 max_time;
29 u16 ln_adc_level; 29 u16 ln_adc_level;
30 30
31 u8 agc_command1 :1;
32 u8 agc_command2 :1;
33
31 u8 mobile_mode; 34 u8 mobile_mode;
32 35
33 u8 output_mpeg2_in_188_bytes; 36 u8 output_mpeg2_in_188_bytes;
diff --git a/drivers/media/dvb/frontends/tda10086.h b/drivers/media/dvb/frontends/tda10086.h
index e8061db11123..18457adee30b 100644
--- a/drivers/media/dvb/frontends/tda10086.h
+++ b/drivers/media/dvb/frontends/tda10086.h
@@ -35,7 +35,16 @@ struct tda10086_config
35 u8 invert; 35 u8 invert;
36}; 36};
37 37
38#if defined(CONFIG_DVB_TDA10086) || defined(CONFIG_DVB_TDA10086_MODULE)
38extern struct dvb_frontend* tda10086_attach(const struct tda10086_config* config, 39extern struct dvb_frontend* tda10086_attach(const struct tda10086_config* config,
39 struct i2c_adapter* i2c); 40 struct i2c_adapter* i2c);
41#else
42static inline struct dvb_frontend* tda10086_attach(const struct tda10086_config* config,
43 struct i2c_adapter* i2c)
44{
45 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
46 return NULL;
47}
48#endif // CONFIG_DVB_TDA10086
40 49
41#endif // TDA10086_H 50#endif // TDA10086_H
diff --git a/drivers/media/dvb/frontends/tda826x.h b/drivers/media/dvb/frontends/tda826x.h
index 3307607632b0..83998c001196 100644
--- a/drivers/media/dvb/frontends/tda826x.h
+++ b/drivers/media/dvb/frontends/tda826x.h
@@ -35,6 +35,19 @@
35 * @param has_loopthrough Set to 1 if the card has a loopthrough RF connector. 35 * @param has_loopthrough Set to 1 if the card has a loopthrough RF connector.
36 * @return FE pointer on success, NULL on failure. 36 * @return FE pointer on success, NULL on failure.
37 */ 37 */
38extern struct dvb_frontend *tda826x_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c, int has_loopthrough); 38#if defined(CONFIG_DVB_TDA826X) || defined(CONFIG_DVB_TDA826X_MODULE)
39 39extern struct dvb_frontend* tda826x_attach(struct dvb_frontend *fe, int addr,
40#endif 40 struct i2c_adapter *i2c,
41 int has_loopthrough);
42#else
43static inline struct dvb_frontend* tda826x_attach(struct dvb_frontend *fe,
44 int addr,
45 struct i2c_adapter *i2c,
46 int has_loopthrough)
47{
48 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__);
49 return NULL;
50}
51#endif // CONFIG_DVB_TDA826X
52
53#endif // __DVB_TDA826X_H__
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index afb734df6e05..fbe5b6168cc2 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -677,6 +677,8 @@ config VIDEO_M32R_AR_M64278
677menu "V4L USB devices" 677menu "V4L USB devices"
678 depends on USB && VIDEO_DEV 678 depends on USB && VIDEO_DEV
679 679
680source "drivers/media/video/pvrusb2/Kconfig"
681
680source "drivers/media/video/em28xx/Kconfig" 682source "drivers/media/video/em28xx/Kconfig"
681 683
682source "drivers/media/video/usbvideo/Kconfig" 684source "drivers/media/video/usbvideo/Kconfig"
diff --git a/drivers/media/video/cx25840/cx25840-vbi.c b/drivers/media/video/cx25840/cx25840-vbi.c
index 48014a254e15..f85f2084324f 100644
--- a/drivers/media/video/cx25840/cx25840-vbi.c
+++ b/drivers/media/video/cx25840/cx25840-vbi.c
@@ -235,6 +235,7 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
235 0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */ 235 0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */
236 0, 0, 0, 0 236 0, 0, 0, 0
237 }; 237 };
238 int is_pal = !(cx25840_get_v4lstd(client) & V4L2_STD_525_60);
238 int i; 239 int i;
239 240
240 fmt = arg; 241 fmt = arg;
@@ -246,13 +247,25 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
246 if ((cx25840_read(client, 0x404) & 0x10) == 0) 247 if ((cx25840_read(client, 0x404) & 0x10) == 0)
247 break; 248 break;
248 249
249 for (i = 7; i <= 23; i++) { 250 if (is_pal) {
250 u8 v = cx25840_read(client, 0x424 + i - 7); 251 for (i = 7; i <= 23; i++) {
252 u8 v = cx25840_read(client, 0x424 + i - 7);
253
254 svbi->service_lines[0][i] = lcr2vbi[v >> 4];
255 svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
256 svbi->service_set |=
257 svbi->service_lines[0][i] | svbi->service_lines[1][i];
258 }
259 }
260 else {
261 for (i = 10; i <= 21; i++) {
262 u8 v = cx25840_read(client, 0x424 + i - 10);
251 263
252 svbi->service_lines[0][i] = lcr2vbi[v >> 4]; 264 svbi->service_lines[0][i] = lcr2vbi[v >> 4];
253 svbi->service_lines[1][i] = lcr2vbi[v & 0xf]; 265 svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
254 svbi->service_set |= 266 svbi->service_set |=
255 svbi->service_lines[0][i] | svbi->service_lines[1][i]; 267 svbi->service_lines[0][i] | svbi->service_lines[1][i];
268 }
256 } 269 }
257 break; 270 break;
258 } 271 }
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index af71d4225c76..f764a57c56be 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1230,6 +1230,7 @@ struct cx88_board cx88_boards[] = {
1230 .vmux = 2, 1230 .vmux = 2,
1231 .gpio0 = 0x84bf, 1231 .gpio0 = 0x84bf,
1232 }}, 1232 }},
1233 .mpeg = CX88_MPEG_DVB,
1233 }, 1234 },
1234 [CX88_BOARD_NORWOOD_MICRO] = { 1235 [CX88_BOARD_NORWOOD_MICRO] = {
1235 .name = "Norwood Micro TV Tuner", 1236 .name = "Norwood Micro TV Tuner",
@@ -1590,6 +1591,18 @@ struct cx88_subid cx88_subids[] = {
1590 .subvendor = 0x0070, 1591 .subvendor = 0x0070,
1591 .subdevice = 0x9000, 1592 .subdevice = 0x9000,
1592 .card = CX88_BOARD_HAUPPAUGE_DVB_T1, 1593 .card = CX88_BOARD_HAUPPAUGE_DVB_T1,
1594 },{
1595 .subvendor = 0x0070,
1596 .subdevice = 0x1400,
1597 .card = CX88_BOARD_HAUPPAUGE_HVR3000,
1598 },{
1599 .subvendor = 0x0070,
1600 .subdevice = 0x1401,
1601 .card = CX88_BOARD_HAUPPAUGE_HVR3000,
1602 },{
1603 .subvendor = 0x0070,
1604 .subdevice = 0x1402,
1605 .card = CX88_BOARD_HAUPPAUGE_HVR3000,
1593 }, 1606 },
1594}; 1607};
1595const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids); 1608const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
@@ -1633,7 +1646,15 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
1633 /* Make sure we support the board model */ 1646 /* Make sure we support the board model */
1634 switch (tv.model) 1647 switch (tv.model)
1635 { 1648 {
1649 case 14009: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in) */
1650 case 14019: /* WinTV-HVR3000 (Retail, IR Blaster, b/panel video, 3.5mm audio in) */
1651 case 14029: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - 880 bridge) */
1652 case 14109: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - low profile) */
1653 case 14129: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - 880 bridge - LP) */
1654 case 14559: /* WinTV-HVR3000 (OEM, no IR, b/panel video, 3.5mm audio in) */
1636 case 14569: /* WinTV-HVR3000 (OEM, no IR, no back panel video) */ 1655 case 14569: /* WinTV-HVR3000 (OEM, no IR, no back panel video) */
1656 case 14659: /* WinTV-HVR3000 (OEM, no IR, b/panel video, RCA audio in - Low profile) */
1657 case 14669: /* WinTV-HVR3000 (OEM, no IR, no b/panel video - Low profile) */
1637 case 28552: /* WinTV-PVR 'Roslyn' (No IR) */ 1658 case 28552: /* WinTV-PVR 'Roslyn' (No IR) */
1638 case 34519: /* WinTV-PCI-FM */ 1659 case 34519: /* WinTV-PCI-FM */
1639 case 90002: /* Nova-T-PCI (9002) */ 1660 case 90002: /* Nova-T-PCI (9002) */
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index bd0c8797f26d..0ef13e7efa2e 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -315,15 +315,22 @@ static struct cx22702_config hauppauge_novat_config = {
315 .demod_address = 0x43, 315 .demod_address = 0x43,
316 .output_mode = CX22702_SERIAL_OUTPUT, 316 .output_mode = CX22702_SERIAL_OUTPUT,
317}; 317};
318
318static struct cx22702_config hauppauge_hvr1100_config = { 319static struct cx22702_config hauppauge_hvr1100_config = {
319 .demod_address = 0x63, 320 .demod_address = 0x63,
320 .output_mode = CX22702_SERIAL_OUTPUT, 321 .output_mode = CX22702_SERIAL_OUTPUT,
321}; 322};
323
322static struct cx22702_config hauppauge_hvr1300_config = { 324static struct cx22702_config hauppauge_hvr1300_config = {
323 .demod_address = 0x63, 325 .demod_address = 0x63,
324 .output_mode = CX22702_SERIAL_OUTPUT, 326 .output_mode = CX22702_SERIAL_OUTPUT,
325}; 327};
326 328
329static struct cx22702_config hauppauge_hvr3000_config = {
330 .demod_address = 0x63,
331 .output_mode = CX22702_SERIAL_OUTPUT,
332};
333
327static int or51132_set_ts_param(struct dvb_frontend* fe, 334static int or51132_set_ts_param(struct dvb_frontend* fe,
328 int is_punctured) 335 int is_punctured)
329{ 336{
@@ -558,6 +565,16 @@ static int dvb_register(struct cx8802_dev *dev)
558 &dvb_pll_fmd1216me); 565 &dvb_pll_fmd1216me);
559 } 566 }
560 break; 567 break;
568 case CX88_BOARD_HAUPPAUGE_HVR3000:
569 dev->dvb.frontend = dvb_attach(cx22702_attach,
570 &hauppauge_hvr3000_config,
571 &dev->core->i2c_adap);
572 if (dev->dvb.frontend != NULL) {
573 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
574 &dev->core->i2c_adap,
575 &dvb_pll_fmd1216me);
576 }
577 break;
561 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 578 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
562 dev->dvb.frontend = dvb_attach(mt352_attach, 579 dev->dvb.frontend = dvb_attach(mt352_attach,
563 &dvico_fusionhdtv, 580 &dvico_fusionhdtv,
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 83ebf7a3c054..ee48995a4ab5 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -196,6 +196,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
196 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 196 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
197 case CX88_BOARD_HAUPPAUGE_HVR1100: 197 case CX88_BOARD_HAUPPAUGE_HVR1100:
198 case CX88_BOARD_HAUPPAUGE_HVR1300: 198 case CX88_BOARD_HAUPPAUGE_HVR1300:
199 case CX88_BOARD_HAUPPAUGE_HVR3000:
199 ir_codes = ir_codes_hauppauge_new; 200 ir_codes = ir_codes_hauppauge_new;
200 ir_type = IR_TYPE_RC5; 201 ir_type = IR_TYPE_RC5;
201 ir->sampling = 1; 202 ir->sampling = 1;
@@ -419,6 +420,7 @@ void cx88_ir_irq(struct cx88_core *core)
419 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 420 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
420 case CX88_BOARD_HAUPPAUGE_HVR1100: 421 case CX88_BOARD_HAUPPAUGE_HVR1100:
421 case CX88_BOARD_HAUPPAUGE_HVR1300: 422 case CX88_BOARD_HAUPPAUGE_HVR1300:
423 case CX88_BOARD_HAUPPAUGE_HVR3000:
422 ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7); 424 ircode = ir_decode_biphase(ir->samples, ir->scount, 5, 7);
423 ir_dprintk("biphase decoded: %x\n", ircode); 425 ir_dprintk("biphase decoded: %x\n", ircode);
424 if ((ircode & 0xfffff000) != 0x3000) 426 if ((ircode & 0xfffff000) != 0x3000)
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index bc544cc7ccb8..f786ab11d2cd 100644
--- a/drivers/media/video/et61x251/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -973,16 +973,32 @@ static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
973 et61x251_show_i2c_val, et61x251_store_i2c_val); 973 et61x251_show_i2c_val, et61x251_store_i2c_val);
974 974
975 975
976static void et61x251_create_sysfs(struct et61x251_device* cam) 976static int et61x251_create_sysfs(struct et61x251_device* cam)
977{ 977{
978 struct video_device *v4ldev = cam->v4ldev; 978 struct video_device *v4ldev = cam->v4ldev;
979 int rc;
979 980
980 video_device_create_file(v4ldev, &class_device_attr_reg); 981 rc = video_device_create_file(v4ldev, &class_device_attr_reg);
981 video_device_create_file(v4ldev, &class_device_attr_val); 982 if (rc) goto err;
983 rc = video_device_create_file(v4ldev, &class_device_attr_val);
984 if (rc) goto err_reg;
982 if (cam->sensor.sysfs_ops) { 985 if (cam->sensor.sysfs_ops) {
983 video_device_create_file(v4ldev, &class_device_attr_i2c_reg); 986 rc = video_device_create_file(v4ldev, &class_device_attr_i2c_reg);
984 video_device_create_file(v4ldev, &class_device_attr_i2c_val); 987 if (rc) goto err_val;
988 rc = video_device_create_file(v4ldev, &class_device_attr_i2c_val);
989 if (rc) goto err_i2c_reg;
985 } 990 }
991
992 return 0;
993
994err_i2c_reg:
995 video_device_remove_file(v4ldev, &class_device_attr_i2c_reg);
996err_val:
997 video_device_remove_file(v4ldev, &class_device_attr_val);
998err_reg:
999 video_device_remove_file(v4ldev, &class_device_attr_reg);
1000err:
1001 return rc;
986} 1002}
987#endif /* CONFIG_VIDEO_ADV_DEBUG */ 1003#endif /* CONFIG_VIDEO_ADV_DEBUG */
988 1004
@@ -2534,7 +2550,9 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2534 dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0; 2550 dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0;
2535 2551
2536#ifdef CONFIG_VIDEO_ADV_DEBUG 2552#ifdef CONFIG_VIDEO_ADV_DEBUG
2537 et61x251_create_sysfs(cam); 2553 err = et61x251_create_sysfs(cam);
2554 if (err)
2555 goto fail2;
2538 DBG(2, "Optional device control through 'sysfs' interface ready"); 2556 DBG(2, "Optional device control through 'sysfs' interface ready");
2539#endif 2557#endif
2540 2558
@@ -2544,6 +2562,13 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2544 2562
2545 return 0; 2563 return 0;
2546 2564
2565#ifdef CONFIG_VIDEO_ADV_DEBUG
2566fail2:
2567 video_nr[dev_nr] = -1;
2568 dev_nr = (dev_nr < ET61X251_MAX_DEVICES-1) ? dev_nr+1 : 0;
2569 mutex_unlock(&cam->dev_mutex);
2570 video_unregister_device(cam->v4ldev);
2571#endif
2547fail: 2572fail:
2548 if (cam) { 2573 if (cam) {
2549 kfree(cam->control_buffer); 2574 kfree(cam->control_buffer);
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index ce4886f1528d..b4db2cbb5a84 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -5648,17 +5648,49 @@ static ssize_t show_exposure(struct class_device *cd, char *buf)
5648} 5648}
5649static CLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL); 5649static CLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL);
5650 5650
5651static void ov_create_sysfs(struct video_device *vdev) 5651static int ov_create_sysfs(struct video_device *vdev)
5652{ 5652{
5653 video_device_create_file(vdev, &class_device_attr_custom_id); 5653 int rc;
5654 video_device_create_file(vdev, &class_device_attr_model); 5654
5655 video_device_create_file(vdev, &class_device_attr_bridge); 5655 rc = video_device_create_file(vdev, &class_device_attr_custom_id);
5656 video_device_create_file(vdev, &class_device_attr_sensor); 5656 if (rc) goto err;
5657 video_device_create_file(vdev, &class_device_attr_brightness); 5657 rc = video_device_create_file(vdev, &class_device_attr_model);
5658 video_device_create_file(vdev, &class_device_attr_saturation); 5658 if (rc) goto err_id;
5659 video_device_create_file(vdev, &class_device_attr_contrast); 5659 rc = video_device_create_file(vdev, &class_device_attr_bridge);
5660 video_device_create_file(vdev, &class_device_attr_hue); 5660 if (rc) goto err_model;
5661 video_device_create_file(vdev, &class_device_attr_exposure); 5661 rc = video_device_create_file(vdev, &class_device_attr_sensor);
5662 if (rc) goto err_bridge;
5663 rc = video_device_create_file(vdev, &class_device_attr_brightness);
5664 if (rc) goto err_sensor;
5665 rc = video_device_create_file(vdev, &class_device_attr_saturation);
5666 if (rc) goto err_bright;
5667 rc = video_device_create_file(vdev, &class_device_attr_contrast);
5668 if (rc) goto err_sat;
5669 rc = video_device_create_file(vdev, &class_device_attr_hue);
5670 if (rc) goto err_contrast;
5671 rc = video_device_create_file(vdev, &class_device_attr_exposure);
5672 if (rc) goto err_hue;
5673
5674 return 0;
5675
5676err_hue:
5677 video_device_remove_file(vdev, &class_device_attr_hue);
5678err_contrast:
5679 video_device_remove_file(vdev, &class_device_attr_contrast);
5680err_sat:
5681 video_device_remove_file(vdev, &class_device_attr_saturation);
5682err_bright:
5683 video_device_remove_file(vdev, &class_device_attr_brightness);
5684err_sensor:
5685 video_device_remove_file(vdev, &class_device_attr_sensor);
5686err_bridge:
5687 video_device_remove_file(vdev, &class_device_attr_bridge);
5688err_model:
5689 video_device_remove_file(vdev, &class_device_attr_model);
5690err_id:
5691 video_device_remove_file(vdev, &class_device_attr_custom_id);
5692err:
5693 return rc;
5662} 5694}
5663 5695
5664/**************************************************************************** 5696/****************************************************************************
@@ -5817,7 +5849,11 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id)
5817 ov->vdev->minor); 5849 ov->vdev->minor);
5818 5850
5819 usb_set_intfdata(intf, ov); 5851 usb_set_intfdata(intf, ov);
5820 ov_create_sysfs(ov->vdev); 5852 if (ov_create_sysfs(ov->vdev)) {
5853 err("ov_create_sysfs failed");
5854 goto error;
5855 }
5856
5821 return 0; 5857 return 0;
5822 5858
5823error: 5859error:
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index c77b85cf3d80..46c114830884 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -1024,12 +1024,25 @@ static ssize_t show_snapshot_button_status(struct class_device *class_dev, char
1024static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status, 1024static CLASS_DEVICE_ATTR(button, S_IRUGO | S_IWUSR, show_snapshot_button_status,
1025 NULL); 1025 NULL);
1026 1026
1027static void pwc_create_sysfs_files(struct video_device *vdev) 1027static int pwc_create_sysfs_files(struct video_device *vdev)
1028{ 1028{
1029 struct pwc_device *pdev = video_get_drvdata(vdev); 1029 struct pwc_device *pdev = video_get_drvdata(vdev);
1030 if (pdev->features & FEATURE_MOTOR_PANTILT) 1030 int rc;
1031 video_device_create_file(vdev, &class_device_attr_pan_tilt); 1031
1032 video_device_create_file(vdev, &class_device_attr_button); 1032 rc = video_device_create_file(vdev, &class_device_attr_button);
1033 if (rc)
1034 goto err;
1035 if (pdev->features & FEATURE_MOTOR_PANTILT) {
1036 rc = video_device_create_file(vdev,&class_device_attr_pan_tilt);
1037 if (rc) goto err_button;
1038 }
1039
1040 return 0;
1041
1042err_button:
1043 video_device_remove_file(vdev, &class_device_attr_button);
1044err:
1045 return rc;
1033} 1046}
1034 1047
1035static void pwc_remove_sysfs_files(struct video_device *vdev) 1048static void pwc_remove_sysfs_files(struct video_device *vdev)
@@ -1408,7 +1421,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1408 struct usb_device *udev = interface_to_usbdev(intf); 1421 struct usb_device *udev = interface_to_usbdev(intf);
1409 struct pwc_device *pdev = NULL; 1422 struct pwc_device *pdev = NULL;
1410 int vendor_id, product_id, type_id; 1423 int vendor_id, product_id, type_id;
1411 int i, hint; 1424 int i, hint, rc;
1412 int features = 0; 1425 int features = 0;
1413 int video_nr = -1; /* default: use next available device */ 1426 int video_nr = -1; /* default: use next available device */
1414 char serial_number[30], *name; 1427 char serial_number[30], *name;
@@ -1709,9 +1722,8 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1709 i = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr); 1722 i = video_register_device(pdev->vdev, VFL_TYPE_GRABBER, video_nr);
1710 if (i < 0) { 1723 if (i < 0) {
1711 PWC_ERROR("Failed to register as video device (%d).\n", i); 1724 PWC_ERROR("Failed to register as video device (%d).\n", i);
1712 video_device_release(pdev->vdev); /* Drip... drip... drip... */ 1725 rc = i;
1713 kfree(pdev); /* Oops, no memory leaks please */ 1726 goto err;
1714 return -EIO;
1715 } 1727 }
1716 else { 1728 else {
1717 PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->minor & 0x3F); 1729 PWC_INFO("Registered as /dev/video%d.\n", pdev->vdev->minor & 0x3F);
@@ -1723,13 +1735,24 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1723 1735
1724 PWC_DEBUG_PROBE("probe() function returning struct at 0x%p.\n", pdev); 1736 PWC_DEBUG_PROBE("probe() function returning struct at 0x%p.\n", pdev);
1725 usb_set_intfdata (intf, pdev); 1737 usb_set_intfdata (intf, pdev);
1726 pwc_create_sysfs_files(pdev->vdev); 1738 rc = pwc_create_sysfs_files(pdev->vdev);
1739 if (rc)
1740 goto err_unreg;
1727 1741
1728 /* Set the leds off */ 1742 /* Set the leds off */
1729 pwc_set_leds(pdev, 0, 0); 1743 pwc_set_leds(pdev, 0, 0);
1730 pwc_camera_power(pdev, 0); 1744 pwc_camera_power(pdev, 0);
1731 1745
1732 return 0; 1746 return 0;
1747
1748err_unreg:
1749 if (hint < MAX_DEV_HINTS)
1750 device_hint[hint].pdev = NULL;
1751 video_unregister_device(pdev->vdev);
1752err:
1753 video_device_release(pdev->vdev); /* Drip... drip... drip... */
1754 kfree(pdev); /* Oops, no memory leaks please */
1755 return rc;
1733} 1756}
1734 1757
1735/* The user janked out the cable... */ 1758/* The user janked out the cable... */
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 974179d4d389..c5719f7bd1ac 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -960,6 +960,8 @@ static void saa711x_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
960 reg |= 0x10; 960 reg |= 0x10;
961 } else if (std == V4L2_STD_NTSC_M_JP) { 961 } else if (std == V4L2_STD_NTSC_M_JP) {
962 reg |= 0x40; 962 reg |= 0x40;
963 } else if (std == V4L2_STD_SECAM) {
964 reg |= 0x50;
963 } 965 }
964 saa711x_write(client, R_0E_CHROMA_CNTL_1, reg); 966 saa711x_write(client, R_0E_CHROMA_CNTL_1, reg);
965 } else { 967 } else {
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 203302f21827..830617ea81cc 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -2248,7 +2248,11 @@ static int radio_do_ioctl(struct inode *inode, struct file *file,
2248 t->type = V4L2_TUNER_RADIO; 2248 t->type = V4L2_TUNER_RADIO;
2249 2249
2250 saa7134_i2c_call_clients(dev, VIDIOC_G_TUNER, t); 2250 saa7134_i2c_call_clients(dev, VIDIOC_G_TUNER, t);
2251 2251 if (dev->input->amux == TV) {
2252 t->signal = 0xf800 - ((saa_readb(0x581) & 0x1f) << 11);
2253 t->rxsubchans = (saa_readb(0x529) & 0x08) ?
2254 V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO;
2255 }
2252 return 0; 2256 return 0;
2253 } 2257 }
2254 case VIDIOC_S_TUNER: 2258 case VIDIOC_S_TUNER:
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 3e0ff8a78468..a4702d3c2aca 100644
--- a/drivers/media/video/sn9c102/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -1240,23 +1240,53 @@ static CLASS_DEVICE_ATTR(frame_header, S_IRUGO,
1240 sn9c102_show_frame_header, NULL); 1240 sn9c102_show_frame_header, NULL);
1241 1241
1242 1242
1243static void sn9c102_create_sysfs(struct sn9c102_device* cam) 1243static int sn9c102_create_sysfs(struct sn9c102_device* cam)
1244{ 1244{
1245 struct video_device *v4ldev = cam->v4ldev; 1245 struct video_device *v4ldev = cam->v4ldev;
1246 int rc;
1247
1248 rc = video_device_create_file(v4ldev, &class_device_attr_reg);
1249 if (rc) goto err;
1250 rc = video_device_create_file(v4ldev, &class_device_attr_val);
1251 if (rc) goto err_reg;
1252 rc = video_device_create_file(v4ldev, &class_device_attr_frame_header);
1253 if (rc) goto err_val;
1246 1254
1247 video_device_create_file(v4ldev, &class_device_attr_reg);
1248 video_device_create_file(v4ldev, &class_device_attr_val);
1249 video_device_create_file(v4ldev, &class_device_attr_frame_header);
1250 if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102)
1251 video_device_create_file(v4ldev, &class_device_attr_green);
1252 else if (cam->bridge == BRIDGE_SN9C103) {
1253 video_device_create_file(v4ldev, &class_device_attr_blue);
1254 video_device_create_file(v4ldev, &class_device_attr_red);
1255 }
1256 if (cam->sensor.sysfs_ops) { 1255 if (cam->sensor.sysfs_ops) {
1257 video_device_create_file(v4ldev, &class_device_attr_i2c_reg); 1256 rc = video_device_create_file(v4ldev, &class_device_attr_i2c_reg);
1258 video_device_create_file(v4ldev, &class_device_attr_i2c_val); 1257 if (rc) goto err_frhead;
1258 rc = video_device_create_file(v4ldev, &class_device_attr_i2c_val);
1259 if (rc) goto err_i2c_reg;
1260 }
1261
1262 if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) {
1263 rc = video_device_create_file(v4ldev, &class_device_attr_green);
1264 if (rc) goto err_i2c_val;
1265 } else if (cam->bridge == BRIDGE_SN9C103) {
1266 rc = video_device_create_file(v4ldev, &class_device_attr_blue);
1267 if (rc) goto err_i2c_val;
1268 rc = video_device_create_file(v4ldev, &class_device_attr_red);
1269 if (rc) goto err_blue;
1259 } 1270 }
1271
1272 return 0;
1273
1274err_blue:
1275 video_device_remove_file(v4ldev, &class_device_attr_blue);
1276err_i2c_val:
1277 if (cam->sensor.sysfs_ops)
1278 video_device_remove_file(v4ldev, &class_device_attr_i2c_val);
1279err_i2c_reg:
1280 if (cam->sensor.sysfs_ops)
1281 video_device_remove_file(v4ldev, &class_device_attr_i2c_reg);
1282err_frhead:
1283 video_device_remove_file(v4ldev, &class_device_attr_frame_header);
1284err_val:
1285 video_device_remove_file(v4ldev, &class_device_attr_val);
1286err_reg:
1287 video_device_remove_file(v4ldev, &class_device_attr_reg);
1288err:
1289 return rc;
1260} 1290}
1261#endif /* CONFIG_VIDEO_ADV_DEBUG */ 1291#endif /* CONFIG_VIDEO_ADV_DEBUG */
1262 1292
@@ -2809,10 +2839,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2809 DBG(1, "V4L2 device registration failed"); 2839 DBG(1, "V4L2 device registration failed");
2810 if (err == -ENFILE && video_nr[dev_nr] == -1) 2840 if (err == -ENFILE && video_nr[dev_nr] == -1)
2811 DBG(1, "Free /dev/videoX node not found"); 2841 DBG(1, "Free /dev/videoX node not found");
2812 video_nr[dev_nr] = -1; 2842 goto fail2;
2813 dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0;
2814 mutex_unlock(&cam->dev_mutex);
2815 goto fail;
2816 } 2843 }
2817 2844
2818 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor); 2845 DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor);
@@ -2823,7 +2850,9 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2823 dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; 2850 dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0;
2824 2851
2825#ifdef CONFIG_VIDEO_ADV_DEBUG 2852#ifdef CONFIG_VIDEO_ADV_DEBUG
2826 sn9c102_create_sysfs(cam); 2853 err = sn9c102_create_sysfs(cam);
2854 if (err)
2855 goto fail3;
2827 DBG(2, "Optional device control through 'sysfs' interface ready"); 2856 DBG(2, "Optional device control through 'sysfs' interface ready");
2828#endif 2857#endif
2829 2858
@@ -2833,6 +2862,14 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2833 2862
2834 return 0; 2863 return 0;
2835 2864
2865#ifdef CONFIG_VIDEO_ADV_DEBUG
2866fail3:
2867 video_unregister_device(cam->v4ldev);
2868#endif
2869fail2:
2870 video_nr[dev_nr] = -1;
2871 dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0;
2872 mutex_unlock(&cam->dev_mutex);
2836fail: 2873fail:
2837 if (cam) { 2874 if (cam) {
2838 kfree(cam->control_buffer); 2875 kfree(cam->control_buffer);
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c
index 87e11300181d..6d1ef1e2e8ef 100644
--- a/drivers/media/video/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -516,16 +516,45 @@ stv680_file(frames_read, framecount, "%d\n");
516stv680_file(packets_dropped, dropped, "%d\n"); 516stv680_file(packets_dropped, dropped, "%d\n");
517stv680_file(decoding_errors, error, "%d\n"); 517stv680_file(decoding_errors, error, "%d\n");
518 518
519static void stv680_create_sysfs_files(struct video_device *vdev) 519static int stv680_create_sysfs_files(struct video_device *vdev)
520{ 520{
521 video_device_create_file(vdev, &class_device_attr_model); 521 int rc;
522 video_device_create_file(vdev, &class_device_attr_in_use); 522
523 video_device_create_file(vdev, &class_device_attr_streaming); 523 rc = video_device_create_file(vdev, &class_device_attr_model);
524 video_device_create_file(vdev, &class_device_attr_palette); 524 if (rc) goto err;
525 video_device_create_file(vdev, &class_device_attr_frames_total); 525 rc = video_device_create_file(vdev, &class_device_attr_in_use);
526 video_device_create_file(vdev, &class_device_attr_frames_read); 526 if (rc) goto err_model;
527 video_device_create_file(vdev, &class_device_attr_packets_dropped); 527 rc = video_device_create_file(vdev, &class_device_attr_streaming);
528 video_device_create_file(vdev, &class_device_attr_decoding_errors); 528 if (rc) goto err_inuse;
529 rc = video_device_create_file(vdev, &class_device_attr_palette);
530 if (rc) goto err_stream;
531 rc = video_device_create_file(vdev, &class_device_attr_frames_total);
532 if (rc) goto err_pal;
533 rc = video_device_create_file(vdev, &class_device_attr_frames_read);
534 if (rc) goto err_framtot;
535 rc = video_device_create_file(vdev, &class_device_attr_packets_dropped);
536 if (rc) goto err_framread;
537 rc = video_device_create_file(vdev, &class_device_attr_decoding_errors);
538 if (rc) goto err_dropped;
539
540 return 0;
541
542err_dropped:
543 video_device_remove_file(vdev, &class_device_attr_packets_dropped);
544err_framread:
545 video_device_remove_file(vdev, &class_device_attr_frames_read);
546err_framtot:
547 video_device_remove_file(vdev, &class_device_attr_frames_total);
548err_pal:
549 video_device_remove_file(vdev, &class_device_attr_palette);
550err_stream:
551 video_device_remove_file(vdev, &class_device_attr_streaming);
552err_inuse:
553 video_device_remove_file(vdev, &class_device_attr_in_use);
554err_model:
555 video_device_remove_file(vdev, &class_device_attr_model);
556err:
557 return rc;
529} 558}
530 559
531static void stv680_remove_sysfs_files(struct video_device *vdev) 560static void stv680_remove_sysfs_files(struct video_device *vdev)
@@ -1418,9 +1447,13 @@ static int stv680_probe (struct usb_interface *intf, const struct usb_device_id
1418 PDEBUG (0, "STV(i): registered new video device: video%d", stv680->vdev->minor); 1447 PDEBUG (0, "STV(i): registered new video device: video%d", stv680->vdev->minor);
1419 1448
1420 usb_set_intfdata (intf, stv680); 1449 usb_set_intfdata (intf, stv680);
1421 stv680_create_sysfs_files(stv680->vdev); 1450 retval = stv680_create_sysfs_files(stv680->vdev);
1451 if (retval)
1452 goto error_unreg;
1422 return 0; 1453 return 0;
1423 1454
1455error_unreg:
1456 video_unregister_device(stv680->vdev);
1424error_vdev: 1457error_vdev:
1425 video_device_release(stv680->vdev); 1458 video_device_release(stv680->vdev);
1426error: 1459error:
diff --git a/drivers/media/video/tuner-types.c b/drivers/media/video/tuner-types.c
index 8fff642fad56..781682373b61 100644
--- a/drivers/media/video/tuner-types.c
+++ b/drivers/media/video/tuner-types.c
@@ -1046,7 +1046,6 @@ static struct tuner_params tuner_samsung_tcpn_2121p30a_params[] = {
1046 .type = TUNER_PARAM_TYPE_NTSC, 1046 .type = TUNER_PARAM_TYPE_NTSC,
1047 .ranges = tuner_samsung_tcpn_2121p30a_ntsc_ranges, 1047 .ranges = tuner_samsung_tcpn_2121p30a_ntsc_ranges,
1048 .count = ARRAY_SIZE(tuner_samsung_tcpn_2121p30a_ntsc_ranges), 1048 .count = ARRAY_SIZE(tuner_samsung_tcpn_2121p30a_ntsc_ranges),
1049 .has_tda9887 = 1,
1050 }, 1049 },
1051}; 1050};
1052 1051
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 479a0675cf60..d424a4129d69 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -17,10 +17,11 @@
17 */ 17 */
18 18
19#define dbgarg(cmd, fmt, arg...) \ 19#define dbgarg(cmd, fmt, arg...) \
20 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ 20 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { \
21 printk (KERN_DEBUG "%s: ", vfd->name); \ 21 printk (KERN_DEBUG "%s: ", vfd->name); \
22 v4l_printk_ioctl(cmd); \ 22 v4l_printk_ioctl(cmd); \
23 printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg); 23 printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg); \
24 }
24 25
25#define dbgarg2(fmt, arg...) \ 26#define dbgarg2(fmt, arg...) \
26 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ 27 if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \
@@ -1287,6 +1288,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
1287 ret=vfd->vidioc_g_parm(file, fh, p); 1288 ret=vfd->vidioc_g_parm(file, fh, p);
1288 } else { 1289 } else {
1289 struct v4l2_standard s; 1290 struct v4l2_standard s;
1291 int i;
1290 1292
1291 if (!vfd->tvnormsize) { 1293 if (!vfd->tvnormsize) {
1292 printk (KERN_WARNING "%s: no TV norms defined!\n", 1294 printk (KERN_WARNING "%s: no TV norms defined!\n",
@@ -1297,8 +1299,14 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
1297 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1299 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1298 return -EINVAL; 1300 return -EINVAL;
1299 1301
1300 v4l2_video_std_construct(&s, vfd->tvnorms[vfd->current_norm].id, 1302 for (i = 0; i < vfd->tvnormsize; i++)
1301 vfd->tvnorms[vfd->current_norm].name); 1303 if (vfd->tvnorms[i].id == vfd->current_norm)
1304 break;
1305 if (i >= vfd->tvnormsize)
1306 return -EINVAL;
1307
1308 v4l2_video_std_construct(&s, vfd->current_norm,
1309 vfd->tvnorms[i].name);
1302 1310
1303 memset(p,0,sizeof(*p)); 1311 memset(p,0,sizeof(*p));
1304 1312
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index e7c01d560b64..3c8dc72dc8e9 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -272,7 +272,7 @@ static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
272 272
273 /* Get first addr pointed to pixel position */ 273 /* Get first addr pointed to pixel position */
274 oldpg=get_addr_pos(pos,pages,to_addr); 274 oldpg=get_addr_pos(pos,pages,to_addr);
275 pg=pfn_to_page(to_addr[oldpg].sg->dma_address >> PAGE_SHIFT); 275 pg=pfn_to_page(sg_dma_address(to_addr[oldpg].sg) >> PAGE_SHIFT);
276 basep = kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[oldpg].sg->offset; 276 basep = kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[oldpg].sg->offset;
277 277
278 /* We will just duplicate the second pixel at the packet */ 278 /* We will just duplicate the second pixel at the packet */
@@ -287,7 +287,7 @@ static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
287 for (color=0;color<4;color++) { 287 for (color=0;color<4;color++) {
288 pgpos=get_addr_pos(pos,pages,to_addr); 288 pgpos=get_addr_pos(pos,pages,to_addr);
289 if (pgpos!=oldpg) { 289 if (pgpos!=oldpg) {
290 pg=pfn_to_page(to_addr[pgpos].sg->dma_address >> PAGE_SHIFT); 290 pg=pfn_to_page(sg_dma_address(to_addr[pgpos].sg) >> PAGE_SHIFT);
291 kunmap_atomic(basep, KM_BOUNCE_READ); 291 kunmap_atomic(basep, KM_BOUNCE_READ);
292 basep= kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[pgpos].sg->offset; 292 basep= kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[pgpos].sg->offset;
293 oldpg=pgpos; 293 oldpg=pgpos;
@@ -339,8 +339,8 @@ static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
339 for (color=0;color<4;color++) { 339 for (color=0;color<4;color++) {
340 pgpos=get_addr_pos(pos,pages,to_addr); 340 pgpos=get_addr_pos(pos,pages,to_addr);
341 if (pgpos!=oldpg) { 341 if (pgpos!=oldpg) {
342 pg=pfn_to_page(to_addr[pgpos]. 342 pg=pfn_to_page(sg_dma_address(
343 sg->dma_address 343 to_addr[pgpos].sg)
344 >> PAGE_SHIFT); 344 >> PAGE_SHIFT);
345 kunmap_atomic(basep, 345 kunmap_atomic(basep,
346 KM_BOUNCE_READ); 346 KM_BOUNCE_READ);
@@ -386,7 +386,7 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
386 struct timeval ts; 386 struct timeval ts;
387 387
388 /* Test if DMA mapping is ready */ 388 /* Test if DMA mapping is ready */
389 if (!vb->dma.sglist[0].dma_address) 389 if (!sg_dma_address(&vb->dma.sglist[0]))
390 return; 390 return;
391 391
392 prep_to_addr(to_addr,vb); 392 prep_to_addr(to_addr,vb);
@@ -783,7 +783,7 @@ static int vivi_map_sg(void *dev, struct scatterlist *sg, int nents,
783 for (i = 0; i < nents; i++ ) { 783 for (i = 0; i < nents; i++ ) {
784 BUG_ON(!sg[i].page); 784 BUG_ON(!sg[i].page);
785 785
786 sg[i].dma_address = page_to_phys(sg[i].page) + sg[i].offset; 786 sg_dma_address(&sg[i]) = page_to_phys(sg[i].page) + sg[i].offset;
787 } 787 }
788 788
789 return nents; 789 return nents;
diff --git a/drivers/message/i2o/bus-osm.c b/drivers/message/i2o/bus-osm.c
index ac06f10c54ec..d96c687aee93 100644
--- a/drivers/message/i2o/bus-osm.c
+++ b/drivers/message/i2o/bus-osm.c
@@ -80,18 +80,26 @@ static DEVICE_ATTR(scan, S_IWUSR, NULL, i2o_bus_store_scan);
80 * @dev: device to verify if it is a I2O Bus Adapter device 80 * @dev: device to verify if it is a I2O Bus Adapter device
81 * 81 *
82 * Because we want all Bus Adapters always return 0. 82 * Because we want all Bus Adapters always return 0.
83 * Except when we fail. Then we are sad.
83 * 84 *
84 * Returns 0. 85 * Returns 0, except when we fail to excel.
85 */ 86 */
86static int i2o_bus_probe(struct device *dev) 87static int i2o_bus_probe(struct device *dev)
87{ 88{
88 struct i2o_device *i2o_dev = to_i2o_device(get_device(dev)); 89 struct i2o_device *i2o_dev = to_i2o_device(get_device(dev));
90 int rc;
89 91
90 device_create_file(dev, &dev_attr_scan); 92 rc = device_create_file(dev, &dev_attr_scan);
93 if (rc)
94 goto err_out;
91 95
92 osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid); 96 osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid);
93 97
94 return 0; 98 return 0;
99
100err_out:
101 put_device(dev);
102 return rc;
95}; 103};
96 104
97/** 105/**
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index 7bd4d85d0b42..91f95d172ca5 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -325,13 +325,24 @@ static DEVICE_ATTR(product_id, S_IRUGO, i2o_exec_show_product_id, NULL);
325static int i2o_exec_probe(struct device *dev) 325static int i2o_exec_probe(struct device *dev)
326{ 326{
327 struct i2o_device *i2o_dev = to_i2o_device(dev); 327 struct i2o_device *i2o_dev = to_i2o_device(dev);
328 int rc;
328 329
329 i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff); 330 rc = i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff);
331 if (rc) goto err_out;
330 332
331 device_create_file(dev, &dev_attr_vendor_id); 333 rc = device_create_file(dev, &dev_attr_vendor_id);
332 device_create_file(dev, &dev_attr_product_id); 334 if (rc) goto err_evtreg;
335 rc = device_create_file(dev, &dev_attr_product_id);
336 if (rc) goto err_vid;
333 337
334 return 0; 338 return 0;
339
340err_vid:
341 device_remove_file(dev, &dev_attr_vendor_id);
342err_evtreg:
343 i2o_event_register(to_i2o_device(dev), &i2o_exec_driver, 0, 0);
344err_out:
345 return rc;
335}; 346};
336 347
337/** 348/**
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 3df0e7a07c46..b6c045dc97b4 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -28,6 +28,17 @@ config IBM_ASM
28 28
29 If unsure, say N. 29 If unsure, say N.
30 30
31config SGI_IOC4
32 tristate "SGI IOC4 Base IO support"
33 ---help---
34 This option enables basic support for the IOC4 chip on certain
35 SGI IO controller cards (IO9, IO10, and PCI-RT). This option
36 does not enable any specific functions on such a card, but provides
37 necessary infrastructure for other drivers to utilize.
38
39 If you have an SGI Altix with an IOC4-based card say Y.
40 Otherwise say N.
41
31config TIFM_CORE 42config TIFM_CORE
32 tristate "TI Flash Media interface support (EXPERIMENTAL)" 43 tristate "TI Flash Media interface support (EXPERIMENTAL)"
33 depends on EXPERIMENTAL 44 depends on EXPERIMENTAL
@@ -57,4 +68,23 @@ config TIFM_7XX1
57 To compile this driver as a module, choose M here: the module will 68 To compile this driver as a module, choose M here: the module will
58 be called tifm_7xx1. 69 be called tifm_7xx1.
59 70
71config MSI_LAPTOP
72 tristate "MSI Laptop Extras"
73 depends on X86
74 depends on ACPI_EC
75 depends on BACKLIGHT_CLASS_DEVICE
76 ---help---
77 This is a driver for laptops built by MSI (MICRO-STAR
78 INTERNATIONAL):
79
80 MSI MegaBook S270 (MS-1013)
81 Cytron/TCM/Medion/Tchibo MD96100/SAM2000
82
83 It adds support for Bluetooth, WLAN and LCD brightness control.
84
85 More information about this driver is available at
86 <http://0pointer.de/lennart/tchibo.html>.
87
88 If you have an MSI S270 laptop, say Y or M here.
89
60endmenu 90endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index d65ece76095a..c9e98ab021c5 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -5,6 +5,8 @@ obj- := misc.o # Dummy rule to force built-in.o to be made
5 5
6obj-$(CONFIG_IBM_ASM) += ibmasm/ 6obj-$(CONFIG_IBM_ASM) += ibmasm/
7obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/ 7obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/
8obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
8obj-$(CONFIG_LKDTM) += lkdtm.o 9obj-$(CONFIG_LKDTM) += lkdtm.o
9obj-$(CONFIG_TIFM_CORE) += tifm_core.o 10obj-$(CONFIG_TIFM_CORE) += tifm_core.o
10obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o 11obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o
12obj-$(CONFIG_SGI_IOC4) += ioc4.o
diff --git a/drivers/sn/ioc4.c b/drivers/misc/ioc4.c
index 8562821e6498..1c3c14a3839c 100644
--- a/drivers/sn/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2005 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (C) 2005-2006 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9/* This file contains the master driver module for use by SGI IOC4 subdrivers. 9/* This file contains the master driver module for use by SGI IOC4 subdrivers.
@@ -29,12 +29,9 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/ioc4.h> 31#include <linux/ioc4.h>
32#include <linux/mmtimer.h> 32#include <linux/ktime.h>
33#include <linux/rtc.h>
34#include <linux/mutex.h> 33#include <linux/mutex.h>
35#include <asm/sn/addrs.h> 34#include <linux/time.h>
36#include <asm/sn/clksupport.h>
37#include <asm/sn/shub_mmr.h>
38 35
39/*************** 36/***************
40 * Definitions * 37 * Definitions *
@@ -43,7 +40,7 @@
43/* Tweakable values */ 40/* Tweakable values */
44 41
45/* PCI bus speed detection/calibration */ 42/* PCI bus speed detection/calibration */
46#define IOC4_CALIBRATE_COUNT 63 /* Calibration cycle period */ 43#define IOC4_CALIBRATE_COUNT 63 /* Calibration cycle period */
47#define IOC4_CALIBRATE_CYCLES 256 /* Average over this many cycles */ 44#define IOC4_CALIBRATE_CYCLES 256 /* Average over this many cycles */
48#define IOC4_CALIBRATE_DISCARD 2 /* Discard first few cycles */ 45#define IOC4_CALIBRATE_DISCARD 2 /* Discard first few cycles */
49#define IOC4_CALIBRATE_LOW_MHZ 25 /* Lower bound on bus speed sanity */ 46#define IOC4_CALIBRATE_LOW_MHZ 25 /* Lower bound on bus speed sanity */
@@ -143,11 +140,11 @@ ioc4_unregister_submodule(struct ioc4_submodule *is)
143static void 140static void
144ioc4_clock_calibrate(struct ioc4_driver_data *idd) 141ioc4_clock_calibrate(struct ioc4_driver_data *idd)
145{ 142{
146 extern unsigned long sn_rtc_cycles_per_second;
147 union ioc4_int_out int_out; 143 union ioc4_int_out int_out;
148 union ioc4_gpcr gpcr; 144 union ioc4_gpcr gpcr;
149 unsigned int state, last_state = 1; 145 unsigned int state, last_state = 1;
150 uint64_t start = 0, end, period; 146 struct timespec start_ts, end_ts;
147 uint64_t start, end, period;
151 unsigned int count = 0; 148 unsigned int count = 0;
152 149
153 /* Enable output */ 150 /* Enable output */
@@ -175,30 +172,28 @@ ioc4_clock_calibrate(struct ioc4_driver_data *idd)
175 if (!last_state && state) { 172 if (!last_state && state) {
176 count++; 173 count++;
177 if (count == IOC4_CALIBRATE_END) { 174 if (count == IOC4_CALIBRATE_END) {
178 end = rtc_time(); 175 ktime_get_ts(&end_ts);
179 break; 176 break;
180 } else if (count == IOC4_CALIBRATE_DISCARD) 177 } else if (count == IOC4_CALIBRATE_DISCARD)
181 start = rtc_time(); 178 ktime_get_ts(&start_ts);
182 } 179 }
183 last_state = state; 180 last_state = state;
184 } while (1); 181 } while (1);
185 182
186 /* Calculation rearranged to preserve intermediate precision. 183 /* Calculation rearranged to preserve intermediate precision.
187 * Logically: 184 * Logically:
188 * 1. "end - start" gives us number of RTC cycles over all the 185 * 1. "end - start" gives us the measurement period over all
189 * square wave cycles measured. 186 * the square wave cycles.
190 * 2. Divide by number of square wave cycles to get number of 187 * 2. Divide by number of square wave cycles to get the period
191 * RTC cycles per square wave cycle. 188 * of a square wave cycle.
192 * 3. Divide by 2*(int_out.fields.count+1), which is the formula 189 * 3. Divide by 2*(int_out.fields.count+1), which is the formula
193 * by which the IOC4 generates the square wave, to get the 190 * by which the IOC4 generates the square wave, to get the
194 * number of RTC cycles per IOC4 INT_OUT count. 191 * period of an IOC4 INT_OUT count.
195 * 4. Divide by sn_rtc_cycles_per_second to get seconds per
196 * count.
197 * 5. Multiply by 1E9 to get nanoseconds per count.
198 */ 192 */
199 period = ((end - start) * 1000000000) / 193 end = end_ts.tv_sec * NSEC_PER_SEC + end_ts.tv_nsec;
200 (IOC4_CALIBRATE_CYCLES * 2 * (IOC4_CALIBRATE_COUNT + 1) 194 start = start_ts.tv_sec * NSEC_PER_SEC + start_ts.tv_nsec;
201 * sn_rtc_cycles_per_second); 195 period = (end - start) /
196 (IOC4_CALIBRATE_CYCLES * 2 * (IOC4_CALIBRATE_COUNT + 1));
202 197
203 /* Bounds check the result. */ 198 /* Bounds check the result. */
204 if (period > IOC4_CALIBRATE_LOW_LIMIT || 199 if (period > IOC4_CALIBRATE_LOW_LIMIT ||
@@ -210,10 +205,12 @@ ioc4_clock_calibrate(struct ioc4_driver_data *idd)
210 IOC4_CALIBRATE_DEFAULT / IOC4_EXTINT_COUNT_DIVISOR); 205 IOC4_CALIBRATE_DEFAULT / IOC4_EXTINT_COUNT_DIVISOR);
211 period = IOC4_CALIBRATE_DEFAULT; 206 period = IOC4_CALIBRATE_DEFAULT;
212 } else { 207 } else {
208 u64 ns = period;
209
210 do_div(ns, IOC4_EXTINT_COUNT_DIVISOR);
213 printk(KERN_DEBUG 211 printk(KERN_DEBUG
214 "IOC4 %s: PCI clock is %ld ns.\n", 212 "IOC4 %s: PCI clock is %lld ns.\n",
215 pci_name(idd->idd_pdev), 213 pci_name(idd->idd_pdev), ns);
216 period / IOC4_EXTINT_COUNT_DIVISOR);
217 } 214 }
218 215
219 /* Remember results. We store the extint clock period rather 216 /* Remember results. We store the extint clock period rather
diff --git a/drivers/misc/msi-laptop.c b/drivers/misc/msi-laptop.c
new file mode 100644
index 000000000000..fdb7153f4426
--- /dev/null
+++ b/drivers/misc/msi-laptop.c
@@ -0,0 +1,395 @@
1/*-*-linux-c-*-*/
2
3/*
4 Copyright (C) 2006 Lennart Poettering <mzxreary (at) 0pointer (dot) de>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301, USA.
20 */
21
22/*
23 * msi-laptop.c - MSI S270 laptop support. This laptop is sold under
24 * various brands, including "Cytron/TCM/Medion/Tchibo MD96100".
25 *
26 * This driver exports a few files in /sys/devices/platform/msi-laptop-pf/:
27 *
28 * lcd_level - Screen brightness: contains a single integer in the
29 * range 0..8. (rw)
30 *
31 * auto_brightness - Enable automatic brightness control: contains
32 * either 0 or 1. If set to 1 the hardware adjusts the screen
33 * brightness automatically when the power cord is
34 * plugged/unplugged. (rw)
35 *
36 * wlan - WLAN subsystem enabled: contains either 0 or 1. (ro)
37 *
38 * bluetooth - Bluetooth subsystem enabled: contains either 0 or 1
39 * Please note that this file is constantly 0 if no Bluetooth
40 * hardware is available. (ro)
41 *
42 * In addition to these platform device attributes the driver
43 * registers itself in the Linux backlight control subsystem and is
44 * available to userspace under /sys/class/backlight/msi-laptop-bl/.
45 *
46 * This driver might work on other laptops produced by MSI. If you
47 * want to try it you can pass force=1 as argument to the module which
48 * will force it to load even when the DMI data doesn't identify the
49 * laptop as MSI S270. YMMV.
50 */
51
52#include <linux/module.h>
53#include <linux/kernel.h>
54#include <linux/init.h>
55#include <linux/acpi.h>
56#include <linux/dmi.h>
57#include <linux/backlight.h>
58#include <linux/platform_device.h>
59#include <linux/autoconf.h>
60
61#define MSI_DRIVER_VERSION "0.5"
62
63#define MSI_LCD_LEVEL_MAX 9
64
65#define MSI_EC_COMMAND_WIRELESS 0x10
66#define MSI_EC_COMMAND_LCD_LEVEL 0x11
67
68static int force;
69module_param(force, bool, 0);
70MODULE_PARM_DESC(force, "Force driver load, ignore DMI data");
71
72static int auto_brightness;
73module_param(auto_brightness, int, 0);
74MODULE_PARM_DESC(auto_brightness, "Enable automatic brightness control (0: disabled; 1: enabled; 2: don't touch)");
75
76/* Hardware access */
77
78static int set_lcd_level(int level)
79{
80 u8 buf[2];
81
82 if (level < 0 || level >= MSI_LCD_LEVEL_MAX)
83 return -EINVAL;
84
85 buf[0] = 0x80;
86 buf[1] = (u8) (level*31);
87
88 return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, buf, sizeof(buf), NULL, 0);
89}
90
91static int get_lcd_level(void)
92{
93 u8 wdata = 0, rdata;
94 int result;
95
96 result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, &wdata, 1, &rdata, 1);
97 if (result < 0)
98 return result;
99
100 return (int) rdata / 31;
101}
102
103static int get_auto_brightness(void)
104{
105 u8 wdata = 4, rdata;
106 int result;
107
108 result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, &wdata, 1, &rdata, 1);
109 if (result < 0)
110 return result;
111
112 return !!(rdata & 8);
113}
114
115static int set_auto_brightness(int enable)
116{
117 u8 wdata[2], rdata;
118 int result;
119
120 wdata[0] = 4;
121
122 result = ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 1, &rdata, 1);
123 if (result < 0)
124 return result;
125
126 wdata[0] = 0x84;
127 wdata[1] = (rdata & 0xF7) | (enable ? 8 : 0);
128
129 return ec_transaction(MSI_EC_COMMAND_LCD_LEVEL, wdata, 2, NULL, 0);
130}
131
132static int get_wireless_state(int *wlan, int *bluetooth)
133{
134 u8 wdata = 0, rdata;
135 int result;
136
137 result = ec_transaction(MSI_EC_COMMAND_WIRELESS, &wdata, 1, &rdata, 1);
138 if (result < 0)
139 return -1;
140
141 if (wlan)
142 *wlan = !!(rdata & 8);
143
144 if (bluetooth)
145 *bluetooth = !!(rdata & 128);
146
147 return 0;
148}
149
150/* Backlight device stuff */
151
152static int bl_get_brightness(struct backlight_device *b)
153{
154 return get_lcd_level();
155}
156
157
158static int bl_update_status(struct backlight_device *b)
159{
160 return set_lcd_level(b->props->brightness);
161}
162
163static struct backlight_properties msibl_props = {
164 .owner = THIS_MODULE,
165 .get_brightness = bl_get_brightness,
166 .update_status = bl_update_status,
167 .max_brightness = MSI_LCD_LEVEL_MAX-1,
168};
169
170static struct backlight_device *msibl_device;
171
172/* Platform device */
173
174static ssize_t show_wlan(struct device *dev,
175 struct device_attribute *attr, char *buf)
176{
177
178 int ret, enabled;
179
180 ret = get_wireless_state(&enabled, NULL);
181 if (ret < 0)
182 return ret;
183
184 return sprintf(buf, "%i\n", enabled);
185}
186
187static ssize_t show_bluetooth(struct device *dev,
188 struct device_attribute *attr, char *buf)
189{
190
191 int ret, enabled;
192
193 ret = get_wireless_state(NULL, &enabled);
194 if (ret < 0)
195 return ret;
196
197 return sprintf(buf, "%i\n", enabled);
198}
199
200static ssize_t show_lcd_level(struct device *dev,
201 struct device_attribute *attr, char *buf)
202{
203
204 int ret;
205
206 ret = get_lcd_level();
207 if (ret < 0)
208 return ret;
209
210 return sprintf(buf, "%i\n", ret);
211}
212
213static ssize_t store_lcd_level(struct device *dev,
214 struct device_attribute *attr, const char *buf, size_t count)
215{
216
217 int level, ret;
218
219 if (sscanf(buf, "%i", &level) != 1 || (level < 0 || level >= MSI_LCD_LEVEL_MAX))
220 return -EINVAL;
221
222 ret = set_lcd_level(level);
223 if (ret < 0)
224 return ret;
225
226 return count;
227}
228
229static ssize_t show_auto_brightness(struct device *dev,
230 struct device_attribute *attr, char *buf)
231{
232
233 int ret;
234
235 ret = get_auto_brightness();
236 if (ret < 0)
237 return ret;
238
239 return sprintf(buf, "%i\n", ret);
240}
241
242static ssize_t store_auto_brightness(struct device *dev,
243 struct device_attribute *attr, const char *buf, size_t count)
244{
245
246 int enable, ret;
247
248 if (sscanf(buf, "%i", &enable) != 1 || (enable != (enable & 1)))
249 return -EINVAL;
250
251 ret = set_auto_brightness(enable);
252 if (ret < 0)
253 return ret;
254
255 return count;
256}
257
258static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level);
259static DEVICE_ATTR(auto_brightness, 0644, show_auto_brightness, store_auto_brightness);
260static DEVICE_ATTR(bluetooth, 0444, show_bluetooth, NULL);
261static DEVICE_ATTR(wlan, 0444, show_wlan, NULL);
262
263static struct attribute *msipf_attributes[] = {
264 &dev_attr_lcd_level.attr,
265 &dev_attr_auto_brightness.attr,
266 &dev_attr_bluetooth.attr,
267 &dev_attr_wlan.attr,
268 NULL
269};
270
271static struct attribute_group msipf_attribute_group = {
272 .attrs = msipf_attributes
273};
274
275static struct platform_driver msipf_driver = {
276 .driver = {
277 .name = "msi-laptop-pf",
278 .owner = THIS_MODULE,
279 }
280};
281
282static struct platform_device *msipf_device;
283
284/* Initialization */
285
286static struct dmi_system_id __initdata msi_dmi_table[] = {
287 {
288 .ident = "MSI S270",
289 .matches = {
290 DMI_MATCH(DMI_SYS_VENDOR, "MICRO-STAR INT'L CO.,LTD"),
291 DMI_MATCH(DMI_PRODUCT_NAME, "MS-1013"),
292 }
293 },
294 {
295 .ident = "Medion MD96100",
296 .matches = {
297 DMI_MATCH(DMI_SYS_VENDOR, "NOTEBOOK"),
298 DMI_MATCH(DMI_PRODUCT_NAME, "SAM2000"),
299 }
300 },
301 { }
302};
303
304
305static int __init msi_init(void)
306{
307 int ret;
308
309 if (acpi_disabled)
310 return -ENODEV;
311
312 if (!force && !dmi_check_system(msi_dmi_table))
313 return -ENODEV;
314
315 if (auto_brightness < 0 || auto_brightness > 2)
316 return -EINVAL;
317
318 /* Register backlight stuff */
319
320 msibl_device = backlight_device_register("msi-laptop-bl", NULL, &msibl_props);
321 if (IS_ERR(msibl_device))
322 return PTR_ERR(msibl_device);
323
324 ret = platform_driver_register(&msipf_driver);
325 if (ret)
326 goto fail_backlight;
327
328 /* Register platform stuff */
329
330 msipf_device = platform_device_alloc("msi-laptop-pf", -1);
331 if (!msipf_device) {
332 ret = -ENOMEM;
333 goto fail_platform_driver;
334 }
335
336 ret = platform_device_add(msipf_device);
337 if (ret)
338 goto fail_platform_device1;
339
340 ret = sysfs_create_group(&msipf_device->dev.kobj, &msipf_attribute_group);
341 if (ret)
342 goto fail_platform_device2;
343
344 /* Disable automatic brightness control by default because
345 * this module was probably loaded to do brightness control in
346 * software. */
347
348 if (auto_brightness != 2)
349 set_auto_brightness(auto_brightness);
350
351 printk(KERN_INFO "msi-laptop: driver "MSI_DRIVER_VERSION" successfully loaded.\n");
352
353 return 0;
354
355fail_platform_device2:
356
357 platform_device_del(msipf_device);
358
359fail_platform_device1:
360
361 platform_device_put(msipf_device);
362
363fail_platform_driver:
364
365 platform_driver_unregister(&msipf_driver);
366
367fail_backlight:
368
369 backlight_device_unregister(msibl_device);
370
371 return ret;
372}
373
374static void __exit msi_cleanup(void)
375{
376
377 sysfs_remove_group(&msipf_device->dev.kobj, &msipf_attribute_group);
378 platform_device_unregister(msipf_device);
379 platform_driver_unregister(&msipf_driver);
380 backlight_device_unregister(msibl_device);
381
382 /* Enable automatic brightness control again */
383 if (auto_brightness != 2)
384 set_auto_brightness(1);
385
386 printk(KERN_INFO "msi-laptop: driver unloaded.\n");
387}
388
389module_init(msi_init);
390module_exit(msi_cleanup);
391
392MODULE_AUTHOR("Lennart Poettering");
393MODULE_DESCRIPTION("MSI Laptop Support");
394MODULE_VERSION(MSI_DRIVER_VERSION);
395MODULE_LICENSE("GPL");
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index b124eee4eb10..1ec217433b4c 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -1706,14 +1706,15 @@ static void __b44_set_rx_mode(struct net_device *dev)
1706 1706
1707 __b44_set_mac_addr(bp); 1707 __b44_set_mac_addr(bp);
1708 1708
1709 if (dev->flags & IFF_ALLMULTI) 1709 if ((dev->flags & IFF_ALLMULTI) ||
1710 (dev->mc_count > B44_MCAST_TABLE_SIZE))
1710 val |= RXCONFIG_ALLMULTI; 1711 val |= RXCONFIG_ALLMULTI;
1711 else 1712 else
1712 i = __b44_load_mcast(bp, dev); 1713 i = __b44_load_mcast(bp, dev);
1713 1714
1714 for (; i < 64; i++) { 1715 for (; i < 64; i++)
1715 __b44_cam_write(bp, zero, i); 1716 __b44_cam_write(bp, zero, i);
1716 } 1717
1717 bw32(bp, B44_RXCONFIG, val); 1718 bw32(bp, B44_RXCONFIG, val);
1718 val = br32(bp, B44_CAM_CTRL); 1719 val = br32(bp, B44_CAM_CTRL);
1719 bw32(bp, B44_CAM_CTRL, val | CAM_CTRL_ENABLE); 1720 bw32(bp, B44_CAM_CTRL, val | CAM_CTRL_ENABLE);
@@ -2055,7 +2056,7 @@ static int b44_read_eeprom(struct b44 *bp, u8 *data)
2055 u16 *ptr = (u16 *) data; 2056 u16 *ptr = (u16 *) data;
2056 2057
2057 for (i = 0; i < 128; i += 2) 2058 for (i = 0; i < 128; i += 2)
2058 ptr[i / 2] = readw(bp->regs + 4096 + i); 2059 ptr[i / 2] = cpu_to_le16(readw(bp->regs + 4096 + i));
2059 2060
2060 return 0; 2061 return 0;
2061} 2062}
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index e83bc825f6af..32923162179e 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -1433,7 +1433,7 @@ void bond_alb_monitor(struct bonding *bond)
1433 * write lock to protect from other code that also 1433 * write lock to protect from other code that also
1434 * sets the promiscuity. 1434 * sets the promiscuity.
1435 */ 1435 */
1436 write_lock(&bond->curr_slave_lock); 1436 write_lock_bh(&bond->curr_slave_lock);
1437 1437
1438 if (bond_info->primary_is_promisc && 1438 if (bond_info->primary_is_promisc &&
1439 (++bond_info->rlb_promisc_timeout_counter >= RLB_PROMISC_TIMEOUT)) { 1439 (++bond_info->rlb_promisc_timeout_counter >= RLB_PROMISC_TIMEOUT)) {
@@ -1448,7 +1448,7 @@ void bond_alb_monitor(struct bonding *bond)
1448 bond_info->primary_is_promisc = 0; 1448 bond_info->primary_is_promisc = 0;
1449 } 1449 }
1450 1450
1451 write_unlock(&bond->curr_slave_lock); 1451 write_unlock_bh(&bond->curr_slave_lock);
1452 1452
1453 if (bond_info->rlb_rebalance) { 1453 if (bond_info->rlb_rebalance) {
1454 bond_info->rlb_rebalance = 0; 1454 bond_info->rlb_rebalance = 0;
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 23b451a8ae12..b40724fc6b74 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -39,7 +39,7 @@
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41#define DRV_NAME "ehea" 41#define DRV_NAME "ehea"
42#define DRV_VERSION "EHEA_0028" 42#define DRV_VERSION "EHEA_0034"
43 43
44#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \ 44#define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \
45 | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR) 45 | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR)
@@ -50,6 +50,7 @@
50#define EHEA_MAX_ENTRIES_SQ 32767 50#define EHEA_MAX_ENTRIES_SQ 32767
51#define EHEA_MIN_ENTRIES_QP 127 51#define EHEA_MIN_ENTRIES_QP 127
52 52
53#define EHEA_SMALL_QUEUES
53#define EHEA_NUM_TX_QP 1 54#define EHEA_NUM_TX_QP 1
54 55
55#ifdef EHEA_SMALL_QUEUES 56#ifdef EHEA_SMALL_QUEUES
@@ -59,11 +60,11 @@
59#define EHEA_DEF_ENTRIES_RQ2 1023 60#define EHEA_DEF_ENTRIES_RQ2 1023
60#define EHEA_DEF_ENTRIES_RQ3 1023 61#define EHEA_DEF_ENTRIES_RQ3 1023
61#else 62#else
62#define EHEA_MAX_CQE_COUNT 32000 63#define EHEA_MAX_CQE_COUNT 4080
63#define EHEA_DEF_ENTRIES_SQ 16000 64#define EHEA_DEF_ENTRIES_SQ 4080
64#define EHEA_DEF_ENTRIES_RQ1 32080 65#define EHEA_DEF_ENTRIES_RQ1 8160
65#define EHEA_DEF_ENTRIES_RQ2 4020 66#define EHEA_DEF_ENTRIES_RQ2 2040
66#define EHEA_DEF_ENTRIES_RQ3 4020 67#define EHEA_DEF_ENTRIES_RQ3 2040
67#endif 68#endif
68 69
69#define EHEA_MAX_ENTRIES_EQ 20 70#define EHEA_MAX_ENTRIES_EQ 20
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index c6b31775e26b..eb7d44de59ff 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -766,7 +766,7 @@ static void ehea_parse_eqe(struct ehea_adapter *adapter, u64 eqe)
766 if (EHEA_BMASK_GET(NEQE_PORT_UP, eqe)) { 766 if (EHEA_BMASK_GET(NEQE_PORT_UP, eqe)) {
767 if (!netif_carrier_ok(port->netdev)) { 767 if (!netif_carrier_ok(port->netdev)) {
768 ret = ehea_sense_port_attr( 768 ret = ehea_sense_port_attr(
769 adapter->port[portnum]); 769 port);
770 if (ret) { 770 if (ret) {
771 ehea_error("failed resensing port " 771 ehea_error("failed resensing port "
772 "attributes"); 772 "attributes");
@@ -818,7 +818,7 @@ static void ehea_parse_eqe(struct ehea_adapter *adapter, u64 eqe)
818 netif_stop_queue(port->netdev); 818 netif_stop_queue(port->netdev);
819 break; 819 break;
820 default: 820 default:
821 ehea_error("unknown event code %x", ec); 821 ehea_error("unknown event code %x, eqe=0x%lX", ec, eqe);
822 break; 822 break;
823 } 823 }
824} 824}
@@ -1841,7 +1841,7 @@ static int ehea_start_xmit(struct sk_buff *skb, struct net_device *dev)
1841 1841
1842 if (netif_msg_tx_queued(port)) { 1842 if (netif_msg_tx_queued(port)) {
1843 ehea_info("post swqe on QP %d", pr->qp->init_attr.qp_nr); 1843 ehea_info("post swqe on QP %d", pr->qp->init_attr.qp_nr);
1844 ehea_dump(swqe, sizeof(*swqe), "swqe"); 1844 ehea_dump(swqe, 512, "swqe");
1845 } 1845 }
1846 1846
1847 ehea_post_swqe(pr->qp, swqe); 1847 ehea_post_swqe(pr->qp, swqe);
diff --git a/drivers/net/ehea/ehea_phyp.c b/drivers/net/ehea/ehea_phyp.c
index 4a85aca4c7e9..0b51a8cea077 100644
--- a/drivers/net/ehea/ehea_phyp.c
+++ b/drivers/net/ehea/ehea_phyp.c
@@ -44,71 +44,99 @@ static inline u16 get_order_of_qentries(u16 queue_entries)
44#define H_ALL_RES_TYPE_MR 5 44#define H_ALL_RES_TYPE_MR 5
45#define H_ALL_RES_TYPE_MW 6 45#define H_ALL_RES_TYPE_MW 6
46 46
47static long ehea_hcall_9arg_9ret(unsigned long opcode, 47static long ehea_plpar_hcall_norets(unsigned long opcode,
48 unsigned long arg1, unsigned long arg2, 48 unsigned long arg1,
49 unsigned long arg3, unsigned long arg4, 49 unsigned long arg2,
50 unsigned long arg5, unsigned long arg6, 50 unsigned long arg3,
51 unsigned long arg7, unsigned long arg8, 51 unsigned long arg4,
52 unsigned long arg9, unsigned long *out1, 52 unsigned long arg5,
53 unsigned long *out2,unsigned long *out3, 53 unsigned long arg6,
54 unsigned long *out4,unsigned long *out5, 54 unsigned long arg7)
55 unsigned long *out6,unsigned long *out7,
56 unsigned long *out8,unsigned long *out9)
57{ 55{
58 long hret; 56 long ret;
59 int i, sleep_msecs; 57 int i, sleep_msecs;
60 58
61 for (i = 0; i < 5; i++) { 59 for (i = 0; i < 5; i++) {
62 hret = plpar_hcall_9arg_9ret(opcode,arg1, arg2, arg3, arg4, 60 ret = plpar_hcall_norets(opcode, arg1, arg2, arg3, arg4,
63 arg5, arg6, arg7, arg8, arg9, out1, 61 arg5, arg6, arg7);
64 out2, out3, out4, out5, out6, out7, 62
65 out8, out9); 63 if (H_IS_LONG_BUSY(ret)) {
66 if (H_IS_LONG_BUSY(hret)) { 64 sleep_msecs = get_longbusy_msecs(ret);
67 sleep_msecs = get_longbusy_msecs(hret);
68 msleep_interruptible(sleep_msecs); 65 msleep_interruptible(sleep_msecs);
69 continue; 66 continue;
70 } 67 }
71 68
72 if (hret < H_SUCCESS) 69 if (ret < H_SUCCESS)
73 ehea_error("op=%lx hret=%lx " 70 ehea_error("opcode=%lx ret=%lx"
74 "i1=%lx i2=%lx i3=%lx i4=%lx i5=%lx i6=%lx " 71 " arg1=%lx arg2=%lx arg3=%lx arg4=%lx"
75 "i7=%lx i8=%lx i9=%lx " 72 " arg5=%lx arg6=%lx arg7=%lx ",
76 "o1=%lx o2=%lx o3=%lx o4=%lx o5=%lx o6=%lx " 73 opcode, ret,
77 "o7=%lx o8=%lx o9=%lx", 74 arg1, arg2, arg3, arg4, arg5,
78 opcode, hret, arg1, arg2, arg3, arg4, arg5, 75 arg6, arg7);
79 arg6, arg7, arg8, arg9, *out1, *out2, *out3, 76
80 *out4, *out5, *out6, *out7, *out8, *out9); 77 return ret;
81 return hret;
82 } 78 }
79
83 return H_BUSY; 80 return H_BUSY;
84} 81}
85 82
86u64 ehea_h_query_ehea_qp(const u64 adapter_handle, const u8 qp_category, 83static long ehea_plpar_hcall9(unsigned long opcode,
87 const u64 qp_handle, const u64 sel_mask, void *cb_addr) 84 unsigned long *outs, /* array of 9 outputs */
85 unsigned long arg1,
86 unsigned long arg2,
87 unsigned long arg3,
88 unsigned long arg4,
89 unsigned long arg5,
90 unsigned long arg6,
91 unsigned long arg7,
92 unsigned long arg8,
93 unsigned long arg9)
88{ 94{
89 u64 dummy; 95 long ret;
96 int i, sleep_msecs;
90 97
91 if ((((u64)cb_addr) & (PAGE_SIZE - 1)) != 0) { 98 for (i = 0; i < 5; i++) {
92 ehea_error("not on pageboundary"); 99 ret = plpar_hcall9(opcode, outs,
93 return H_PARAMETER; 100 arg1, arg2, arg3, arg4, arg5,
101 arg6, arg7, arg8, arg9);
102
103 if (H_IS_LONG_BUSY(ret)) {
104 sleep_msecs = get_longbusy_msecs(ret);
105 msleep_interruptible(sleep_msecs);
106 continue;
107 }
108
109 if (ret < H_SUCCESS)
110 ehea_error("opcode=%lx ret=%lx"
111 " arg1=%lx arg2=%lx arg3=%lx arg4=%lx"
112 " arg5=%lx arg6=%lx arg7=%lx arg8=%lx"
113 " arg9=%lx"
114 " out1=%lx out2=%lx out3=%lx out4=%lx"
115 " out5=%lx out6=%lx out7=%lx out8=%lx"
116 " out9=%lx",
117 opcode, ret,
118 arg1, arg2, arg3, arg4, arg5,
119 arg6, arg7, arg8, arg9,
120 outs[0], outs[1], outs[2], outs[3],
121 outs[4], outs[5], outs[6], outs[7],
122 outs[8]);
123
124 return ret;
94 } 125 }
95 126
96 return ehea_hcall_9arg_9ret(H_QUERY_HEA_QP, 127 return H_BUSY;
97 adapter_handle, /* R4 */ 128}
98 qp_category, /* R5 */ 129
99 qp_handle, /* R6 */ 130u64 ehea_h_query_ehea_qp(const u64 adapter_handle, const u8 qp_category,
100 sel_mask, /* R7 */ 131 const u64 qp_handle, const u64 sel_mask, void *cb_addr)
101 virt_to_abs(cb_addr), /* R8 */ 132{
102 0, 0, 0, 0, /* R9-R12 */ 133 return ehea_plpar_hcall_norets(H_QUERY_HEA_QP,
103 &dummy, /* R4 */ 134 adapter_handle, /* R4 */
104 &dummy, /* R5 */ 135 qp_category, /* R5 */
105 &dummy, /* R6 */ 136 qp_handle, /* R6 */
106 &dummy, /* R7 */ 137 sel_mask, /* R7 */
107 &dummy, /* R8 */ 138 virt_to_abs(cb_addr), /* R8 */
108 &dummy, /* R9 */ 139 0, 0);
109 &dummy, /* R10 */
110 &dummy, /* R11 */
111 &dummy); /* R12 */
112} 140}
113 141
114/* input param R5 */ 142/* input param R5 */
@@ -180,6 +208,7 @@ u64 ehea_h_alloc_resource_qp(const u64 adapter_handle,
180 u64 *qp_handle, struct h_epas *h_epas) 208 u64 *qp_handle, struct h_epas *h_epas)
181{ 209{
182 u64 hret; 210 u64 hret;
211 u64 outs[PLPAR_HCALL9_BUFSIZE];
183 212
184 u64 allocate_controls = 213 u64 allocate_controls =
185 EHEA_BMASK_SET(H_ALL_RES_QP_EQPO, init_attr->low_lat_rq1 ? 1 : 0) 214 EHEA_BMASK_SET(H_ALL_RES_QP_EQPO, init_attr->low_lat_rq1 ? 1 : 0)
@@ -219,45 +248,29 @@ u64 ehea_h_alloc_resource_qp(const u64 adapter_handle,
219 EHEA_BMASK_SET(H_ALL_RES_QP_TH_RQ2, init_attr->rq2_threshold) 248 EHEA_BMASK_SET(H_ALL_RES_QP_TH_RQ2, init_attr->rq2_threshold)
220 | EHEA_BMASK_SET(H_ALL_RES_QP_TH_RQ3, init_attr->rq3_threshold); 249 | EHEA_BMASK_SET(H_ALL_RES_QP_TH_RQ3, init_attr->rq3_threshold);
221 250
222 u64 r5_out = 0; 251 hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
223 u64 r6_out = 0; 252 outs,
224 u64 r7_out = 0; 253 adapter_handle, /* R4 */
225 u64 r8_out = 0; 254 allocate_controls, /* R5 */
226 u64 r9_out = 0; 255 init_attr->send_cq_handle, /* R6 */
227 u64 g_la_user_out = 0; 256 init_attr->recv_cq_handle, /* R7 */
228 u64 r11_out = 0; 257 init_attr->aff_eq_handle, /* R8 */
229 u64 r12_out = 0; 258 r9_reg, /* R9 */
230 259 max_r10_reg, /* R10 */
231 hret = ehea_hcall_9arg_9ret(H_ALLOC_HEA_RESOURCE, 260 r11_in, /* R11 */
232 adapter_handle, /* R4 */ 261 threshold); /* R12 */
233 allocate_controls, /* R5 */ 262
234 init_attr->send_cq_handle, /* R6 */ 263 *qp_handle = outs[0];
235 init_attr->recv_cq_handle, /* R7 */ 264 init_attr->qp_nr = (u32)outs[1];
236 init_attr->aff_eq_handle, /* R8 */
237 r9_reg, /* R9 */
238 max_r10_reg, /* R10 */
239 r11_in, /* R11 */
240 threshold, /* R12 */
241 qp_handle, /* R4 */
242 &r5_out, /* R5 */
243 &r6_out, /* R6 */
244 &r7_out, /* R7 */
245 &r8_out, /* R8 */
246 &r9_out, /* R9 */
247 &g_la_user_out, /* R10 */
248 &r11_out, /* R11 */
249 &r12_out); /* R12 */
250
251 init_attr->qp_nr = (u32)r5_out;
252 265
253 init_attr->act_nr_send_wqes = 266 init_attr->act_nr_send_wqes =
254 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_SWQE, r6_out); 267 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_SWQE, outs[2]);
255 init_attr->act_nr_rwqes_rq1 = 268 init_attr->act_nr_rwqes_rq1 =
256 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R1WQE, r6_out); 269 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R1WQE, outs[2]);
257 init_attr->act_nr_rwqes_rq2 = 270 init_attr->act_nr_rwqes_rq2 =
258 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R2WQE, r6_out); 271 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R2WQE, outs[2]);
259 init_attr->act_nr_rwqes_rq3 = 272 init_attr->act_nr_rwqes_rq3 =
260 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R3WQE, r6_out); 273 (u16)EHEA_BMASK_GET(H_ALL_RES_QP_ACT_R3WQE, outs[2]);
261 274
262 init_attr->act_wqe_size_enc_sq = init_attr->wqe_size_enc_sq; 275 init_attr->act_wqe_size_enc_sq = init_attr->wqe_size_enc_sq;
263 init_attr->act_wqe_size_enc_rq1 = init_attr->wqe_size_enc_rq1; 276 init_attr->act_wqe_size_enc_rq1 = init_attr->wqe_size_enc_rq1;
@@ -265,25 +278,25 @@ u64 ehea_h_alloc_resource_qp(const u64 adapter_handle,
265 init_attr->act_wqe_size_enc_rq3 = init_attr->wqe_size_enc_rq3; 278 init_attr->act_wqe_size_enc_rq3 = init_attr->wqe_size_enc_rq3;
266 279
267 init_attr->nr_sq_pages = 280 init_attr->nr_sq_pages =
268 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_SQ, r8_out); 281 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_SQ, outs[4]);
269 init_attr->nr_rq1_pages = 282 init_attr->nr_rq1_pages =
270 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ1, r8_out); 283 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ1, outs[4]);
271 init_attr->nr_rq2_pages = 284 init_attr->nr_rq2_pages =
272 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ2, r9_out); 285 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ2, outs[5]);
273 init_attr->nr_rq3_pages = 286 init_attr->nr_rq3_pages =
274 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ3, r9_out); 287 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_SIZE_RQ3, outs[5]);
275 288
276 init_attr->liobn_sq = 289 init_attr->liobn_sq =
277 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_SQ, r11_out); 290 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_SQ, outs[7]);
278 init_attr->liobn_rq1 = 291 init_attr->liobn_rq1 =
279 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ1, r11_out); 292 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ1, outs[7]);
280 init_attr->liobn_rq2 = 293 init_attr->liobn_rq2 =
281 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ2, r12_out); 294 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ2, outs[8]);
282 init_attr->liobn_rq3 = 295 init_attr->liobn_rq3 =
283 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ3, r12_out); 296 (u32)EHEA_BMASK_GET(H_ALL_RES_QP_LIOBN_RQ3, outs[8]);
284 297
285 if (!hret) 298 if (!hret)
286 hcp_epas_ctor(h_epas, g_la_user_out, g_la_user_out); 299 hcp_epas_ctor(h_epas, outs[6], outs[6]);
287 300
288 return hret; 301 return hret;
289} 302}
@@ -292,31 +305,24 @@ u64 ehea_h_alloc_resource_cq(const u64 adapter_handle,
292 struct ehea_cq_attr *cq_attr, 305 struct ehea_cq_attr *cq_attr,
293 u64 *cq_handle, struct h_epas *epas) 306 u64 *cq_handle, struct h_epas *epas)
294{ 307{
295 u64 hret, dummy, act_nr_of_cqes_out, act_pages_out; 308 u64 hret;
296 u64 g_la_privileged_out, g_la_user_out; 309 u64 outs[PLPAR_HCALL9_BUFSIZE];
297 310
298 hret = ehea_hcall_9arg_9ret(H_ALLOC_HEA_RESOURCE, 311 hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
299 adapter_handle, /* R4 */ 312 outs,
300 H_ALL_RES_TYPE_CQ, /* R5 */ 313 adapter_handle, /* R4 */
301 cq_attr->eq_handle, /* R6 */ 314 H_ALL_RES_TYPE_CQ, /* R5 */
302 cq_attr->cq_token, /* R7 */ 315 cq_attr->eq_handle, /* R6 */
303 cq_attr->max_nr_of_cqes, /* R8 */ 316 cq_attr->cq_token, /* R7 */
304 0, 0, 0, 0, /* R9-R12 */ 317 cq_attr->max_nr_of_cqes, /* R8 */
305 cq_handle, /* R4 */ 318 0, 0, 0, 0); /* R9-R12 */
306 &dummy, /* R5 */ 319
307 &dummy, /* R6 */ 320 *cq_handle = outs[0];
308 &act_nr_of_cqes_out, /* R7 */ 321 cq_attr->act_nr_of_cqes = outs[3];
309 &act_pages_out, /* R8 */ 322 cq_attr->nr_pages = outs[4];
310 &g_la_privileged_out, /* R9 */
311 &g_la_user_out, /* R10 */
312 &dummy, /* R11 */
313 &dummy); /* R12 */
314
315 cq_attr->act_nr_of_cqes = act_nr_of_cqes_out;
316 cq_attr->nr_pages = act_pages_out;
317 323
318 if (!hret) 324 if (!hret)
319 hcp_epas_ctor(epas, g_la_privileged_out, g_la_user_out); 325 hcp_epas_ctor(epas, outs[5], outs[6]);
320 326
321 return hret; 327 return hret;
322} 328}
@@ -361,9 +367,8 @@ u64 ehea_h_alloc_resource_cq(const u64 adapter_handle,
361u64 ehea_h_alloc_resource_eq(const u64 adapter_handle, 367u64 ehea_h_alloc_resource_eq(const u64 adapter_handle,
362 struct ehea_eq_attr *eq_attr, u64 *eq_handle) 368 struct ehea_eq_attr *eq_attr, u64 *eq_handle)
363{ 369{
364 u64 hret, dummy, eq_liobn, allocate_controls; 370 u64 hret, allocate_controls;
365 u64 ist1_out, ist2_out, ist3_out, ist4_out; 371 u64 outs[PLPAR_HCALL9_BUFSIZE];
366 u64 act_nr_of_eqes_out, act_pages_out;
367 372
368 /* resource type */ 373 /* resource type */
369 allocate_controls = 374 allocate_controls =
@@ -372,27 +377,20 @@ u64 ehea_h_alloc_resource_eq(const u64 adapter_handle,
372 | EHEA_BMASK_SET(H_ALL_RES_EQ_INH_EQE_GEN, !eq_attr->eqe_gen) 377 | EHEA_BMASK_SET(H_ALL_RES_EQ_INH_EQE_GEN, !eq_attr->eqe_gen)
373 | EHEA_BMASK_SET(H_ALL_RES_EQ_NON_NEQ_ISN, 1); 378 | EHEA_BMASK_SET(H_ALL_RES_EQ_NON_NEQ_ISN, 1);
374 379
375 hret = ehea_hcall_9arg_9ret(H_ALLOC_HEA_RESOURCE, 380 hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
376 adapter_handle, /* R4 */ 381 outs,
377 allocate_controls, /* R5 */ 382 adapter_handle, /* R4 */
378 eq_attr->max_nr_of_eqes, /* R6 */ 383 allocate_controls, /* R5 */
379 0, 0, 0, 0, 0, 0, /* R7-R10 */ 384 eq_attr->max_nr_of_eqes, /* R6 */
380 eq_handle, /* R4 */ 385 0, 0, 0, 0, 0, 0); /* R7-R10 */
381 &dummy, /* R5 */ 386
382 &eq_liobn, /* R6 */ 387 *eq_handle = outs[0];
383 &act_nr_of_eqes_out, /* R7 */ 388 eq_attr->act_nr_of_eqes = outs[3];
384 &act_pages_out, /* R8 */ 389 eq_attr->nr_pages = outs[4];
385 &ist1_out, /* R9 */ 390 eq_attr->ist1 = outs[5];
386 &ist2_out, /* R10 */ 391 eq_attr->ist2 = outs[6];
387 &ist3_out, /* R11 */ 392 eq_attr->ist3 = outs[7];
388 &ist4_out); /* R12 */ 393 eq_attr->ist4 = outs[8];
389
390 eq_attr->act_nr_of_eqes = act_nr_of_eqes_out;
391 eq_attr->nr_pages = act_pages_out;
392 eq_attr->ist1 = ist1_out;
393 eq_attr->ist2 = ist2_out;
394 eq_attr->ist3 = ist3_out;
395 eq_attr->ist4 = ist4_out;
396 394
397 return hret; 395 return hret;
398} 396}
@@ -402,31 +400,22 @@ u64 ehea_h_modify_ehea_qp(const u64 adapter_handle, const u8 cat,
402 void *cb_addr, u64 *inv_attr_id, u64 *proc_mask, 400 void *cb_addr, u64 *inv_attr_id, u64 *proc_mask,
403 u16 *out_swr, u16 *out_rwr) 401 u16 *out_swr, u16 *out_rwr)
404{ 402{
405 u64 hret, dummy, act_out_swr, act_out_rwr; 403 u64 hret;
406 404 u64 outs[PLPAR_HCALL9_BUFSIZE];
407 if ((((u64)cb_addr) & (PAGE_SIZE - 1)) != 0) { 405
408 ehea_error("not on page boundary"); 406 hret = ehea_plpar_hcall9(H_MODIFY_HEA_QP,
409 return H_PARAMETER; 407 outs,
410 } 408 adapter_handle, /* R4 */
411 409 (u64) cat, /* R5 */
412 hret = ehea_hcall_9arg_9ret(H_MODIFY_HEA_QP, 410 qp_handle, /* R6 */
413 adapter_handle, /* R4 */ 411 sel_mask, /* R7 */
414 (u64) cat, /* R5 */ 412 virt_to_abs(cb_addr), /* R8 */
415 qp_handle, /* R6 */ 413 0, 0, 0, 0); /* R9-R12 */
416 sel_mask, /* R7 */ 414
417 virt_to_abs(cb_addr), /* R8 */ 415 *inv_attr_id = outs[0];
418 0, 0, 0, 0, /* R9-R12 */ 416 *out_swr = outs[3];
419 inv_attr_id, /* R4 */ 417 *out_rwr = outs[4];
420 &dummy, /* R5 */ 418 *proc_mask = outs[5];
421 &dummy, /* R6 */
422 &act_out_swr, /* R7 */
423 &act_out_rwr, /* R8 */
424 proc_mask, /* R9 */
425 &dummy, /* R10 */
426 &dummy, /* R11 */
427 &dummy); /* R12 */
428 *out_swr = act_out_swr;
429 *out_rwr = act_out_rwr;
430 419
431 return hret; 420 return hret;
432} 421}
@@ -435,122 +424,81 @@ u64 ehea_h_register_rpage(const u64 adapter_handle, const u8 pagesize,
435 const u8 queue_type, const u64 resource_handle, 424 const u8 queue_type, const u64 resource_handle,
436 const u64 log_pageaddr, u64 count) 425 const u64 log_pageaddr, u64 count)
437{ 426{
438 u64 dummy, reg_control; 427 u64 reg_control;
439 428
440 reg_control = EHEA_BMASK_SET(H_REG_RPAGE_PAGE_SIZE, pagesize) 429 reg_control = EHEA_BMASK_SET(H_REG_RPAGE_PAGE_SIZE, pagesize)
441 | EHEA_BMASK_SET(H_REG_RPAGE_QT, queue_type); 430 | EHEA_BMASK_SET(H_REG_RPAGE_QT, queue_type);
442 431
443 return ehea_hcall_9arg_9ret(H_REGISTER_HEA_RPAGES, 432 return ehea_plpar_hcall_norets(H_REGISTER_HEA_RPAGES,
444 adapter_handle, /* R4 */ 433 adapter_handle, /* R4 */
445 reg_control, /* R5 */ 434 reg_control, /* R5 */
446 resource_handle, /* R6 */ 435 resource_handle, /* R6 */
447 log_pageaddr, /* R7 */ 436 log_pageaddr, /* R7 */
448 count, /* R8 */ 437 count, /* R8 */
449 0, 0, 0, 0, /* R9-R12 */ 438 0, 0); /* R9-R10 */
450 &dummy, /* R4 */
451 &dummy, /* R5 */
452 &dummy, /* R6 */
453 &dummy, /* R7 */
454 &dummy, /* R8 */
455 &dummy, /* R9 */
456 &dummy, /* R10 */
457 &dummy, /* R11 */
458 &dummy); /* R12 */
459} 439}
460 440
461u64 ehea_h_register_smr(const u64 adapter_handle, const u64 orig_mr_handle, 441u64 ehea_h_register_smr(const u64 adapter_handle, const u64 orig_mr_handle,
462 const u64 vaddr_in, const u32 access_ctrl, const u32 pd, 442 const u64 vaddr_in, const u32 access_ctrl, const u32 pd,
463 struct ehea_mr *mr) 443 struct ehea_mr *mr)
464{ 444{
465 u64 hret, dummy, lkey_out; 445 u64 hret;
466 446 u64 outs[PLPAR_HCALL9_BUFSIZE];
467 hret = ehea_hcall_9arg_9ret(H_REGISTER_SMR, 447
468 adapter_handle , /* R4 */ 448 hret = ehea_plpar_hcall9(H_REGISTER_SMR,
469 orig_mr_handle, /* R5 */ 449 outs,
470 vaddr_in, /* R6 */ 450 adapter_handle , /* R4 */
471 (((u64)access_ctrl) << 32ULL), /* R7 */ 451 orig_mr_handle, /* R5 */
472 pd, /* R8 */ 452 vaddr_in, /* R6 */
473 0, 0, 0, 0, /* R9-R12 */ 453 (((u64)access_ctrl) << 32ULL), /* R7 */
474 &mr->handle, /* R4 */ 454 pd, /* R8 */
475 &dummy, /* R5 */ 455 0, 0, 0, 0); /* R9-R12 */
476 &lkey_out, /* R6 */ 456
477 &dummy, /* R7 */ 457 mr->handle = outs[0];
478 &dummy, /* R8 */ 458 mr->lkey = (u32)outs[2];
479 &dummy, /* R9 */
480 &dummy, /* R10 */
481 &dummy, /* R11 */
482 &dummy); /* R12 */
483 mr->lkey = (u32)lkey_out;
484 459
485 return hret; 460 return hret;
486} 461}
487 462
488u64 ehea_h_disable_and_get_hea(const u64 adapter_handle, const u64 qp_handle) 463u64 ehea_h_disable_and_get_hea(const u64 adapter_handle, const u64 qp_handle)
489{ 464{
490 u64 hret, dummy, ladr_next_sq_wqe_out; 465 u64 outs[PLPAR_HCALL9_BUFSIZE];
491 u64 ladr_next_rq1_wqe_out, ladr_next_rq2_wqe_out, ladr_next_rq3_wqe_out; 466
492 467 return ehea_plpar_hcall9(H_DISABLE_AND_GET_HEA,
493 hret = ehea_hcall_9arg_9ret(H_DISABLE_AND_GET_HEA, 468 outs,
494 adapter_handle, /* R4 */ 469 adapter_handle, /* R4 */
495 H_DISABLE_GET_EHEA_WQE_P, /* R5 */ 470 H_DISABLE_GET_EHEA_WQE_P, /* R5 */
496 qp_handle, /* R6 */ 471 qp_handle, /* R6 */
497 0, 0, 0, 0, 0, 0, /* R7-R12 */ 472 0, 0, 0, 0, 0, 0); /* R7-R12 */
498 &ladr_next_sq_wqe_out, /* R4 */
499 &ladr_next_rq1_wqe_out, /* R5 */
500 &ladr_next_rq2_wqe_out, /* R6 */
501 &ladr_next_rq3_wqe_out, /* R7 */
502 &dummy, /* R8 */
503 &dummy, /* R9 */
504 &dummy, /* R10 */
505 &dummy, /* R11 */
506 &dummy); /* R12 */
507 return hret;
508} 473}
509 474
510u64 ehea_h_free_resource(const u64 adapter_handle, const u64 res_handle) 475u64 ehea_h_free_resource(const u64 adapter_handle, const u64 res_handle)
511{ 476{
512 u64 dummy; 477 return ehea_plpar_hcall_norets(H_FREE_RESOURCE,
513 478 adapter_handle, /* R4 */
514 return ehea_hcall_9arg_9ret(H_FREE_RESOURCE, 479 res_handle, /* R5 */
515 adapter_handle, /* R4 */ 480 0, 0, 0, 0, 0); /* R6-R10 */
516 res_handle, /* R5 */
517 0, 0, 0, 0, 0, 0, 0, /* R6-R12 */
518 &dummy, /* R4 */
519 &dummy, /* R5 */
520 &dummy, /* R6 */
521 &dummy, /* R7 */
522 &dummy, /* R8 */
523 &dummy, /* R9 */
524 &dummy, /* R10 */
525 &dummy, /* R11 */
526 &dummy); /* R12 */
527} 481}
528 482
529u64 ehea_h_alloc_resource_mr(const u64 adapter_handle, const u64 vaddr, 483u64 ehea_h_alloc_resource_mr(const u64 adapter_handle, const u64 vaddr,
530 const u64 length, const u32 access_ctrl, 484 const u64 length, const u32 access_ctrl,
531 const u32 pd, u64 *mr_handle, u32 *lkey) 485 const u32 pd, u64 *mr_handle, u32 *lkey)
532{ 486{
533 u64 hret, dummy, lkey_out; 487 u64 hret;
534 488 u64 outs[PLPAR_HCALL9_BUFSIZE];
535 hret = ehea_hcall_9arg_9ret(H_ALLOC_HEA_RESOURCE, 489
536 adapter_handle, /* R4 */ 490 hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
537 5, /* R5 */ 491 outs,
538 vaddr, /* R6 */ 492 adapter_handle, /* R4 */
539 length, /* R7 */ 493 5, /* R5 */
540 (((u64) access_ctrl) << 32ULL),/* R8 */ 494 vaddr, /* R6 */
541 pd, /* R9 */ 495 length, /* R7 */
542 0, 0, 0, /* R10-R12 */ 496 (((u64) access_ctrl) << 32ULL), /* R8 */
543 mr_handle, /* R4 */ 497 pd, /* R9 */
544 &dummy, /* R5 */ 498 0, 0, 0); /* R10-R12 */
545 &lkey_out, /* R6 */ 499
546 &dummy, /* R7 */ 500 *mr_handle = outs[0];
547 &dummy, /* R8 */ 501 *lkey = (u32)outs[2];
548 &dummy, /* R9 */
549 &dummy, /* R10 */
550 &dummy, /* R11 */
551 &dummy); /* R12 */
552 *lkey = (u32) lkey_out;
553
554 return hret; 502 return hret;
555} 503}
556 504
@@ -570,23 +518,14 @@ u64 ehea_h_register_rpage_mr(const u64 adapter_handle, const u64 mr_handle,
570 518
571u64 ehea_h_query_ehea(const u64 adapter_handle, void *cb_addr) 519u64 ehea_h_query_ehea(const u64 adapter_handle, void *cb_addr)
572{ 520{
573 u64 hret, dummy, cb_logaddr; 521 u64 hret, cb_logaddr;
574 522
575 cb_logaddr = virt_to_abs(cb_addr); 523 cb_logaddr = virt_to_abs(cb_addr);
576 524
577 hret = ehea_hcall_9arg_9ret(H_QUERY_HEA, 525 hret = ehea_plpar_hcall_norets(H_QUERY_HEA,
578 adapter_handle, /* R4 */ 526 adapter_handle, /* R4 */
579 cb_logaddr, /* R5 */ 527 cb_logaddr, /* R5 */
580 0, 0, 0, 0, 0, 0, 0, /* R6-R12 */ 528 0, 0, 0, 0, 0); /* R6-R10 */
581 &dummy, /* R4 */
582 &dummy, /* R5 */
583 &dummy, /* R6 */
584 &dummy, /* R7 */
585 &dummy, /* R8 */
586 &dummy, /* R9 */
587 &dummy, /* R10 */
588 &dummy, /* R11 */
589 &dummy); /* R12 */
590#ifdef DEBUG 529#ifdef DEBUG
591 ehea_dmp(cb_addr, sizeof(struct hcp_query_ehea), "hcp_query_ehea"); 530 ehea_dmp(cb_addr, sizeof(struct hcp_query_ehea), "hcp_query_ehea");
592#endif 531#endif
@@ -597,36 +536,28 @@ u64 ehea_h_query_ehea_port(const u64 adapter_handle, const u16 port_num,
597 const u8 cb_cat, const u64 select_mask, 536 const u8 cb_cat, const u64 select_mask,
598 void *cb_addr) 537 void *cb_addr)
599{ 538{
600 u64 port_info, dummy; 539 u64 port_info;
601 u64 cb_logaddr = virt_to_abs(cb_addr); 540 u64 cb_logaddr = virt_to_abs(cb_addr);
602 u64 arr_index = 0; 541 u64 arr_index = 0;
603 542
604 port_info = EHEA_BMASK_SET(H_MEHEAPORT_CAT, cb_cat) 543 port_info = EHEA_BMASK_SET(H_MEHEAPORT_CAT, cb_cat)
605 | EHEA_BMASK_SET(H_MEHEAPORT_PN, port_num); 544 | EHEA_BMASK_SET(H_MEHEAPORT_PN, port_num);
606 545
607 return ehea_hcall_9arg_9ret(H_QUERY_HEA_PORT, 546 return ehea_plpar_hcall_norets(H_QUERY_HEA_PORT,
608 adapter_handle, /* R4 */ 547 adapter_handle, /* R4 */
609 port_info, /* R5 */ 548 port_info, /* R5 */
610 select_mask, /* R6 */ 549 select_mask, /* R6 */
611 arr_index, /* R7 */ 550 arr_index, /* R7 */
612 cb_logaddr, /* R8 */ 551 cb_logaddr, /* R8 */
613 0, 0, 0, 0, /* R9-R12 */ 552 0, 0); /* R9-R10 */
614 &dummy, /* R4 */
615 &dummy, /* R5 */
616 &dummy, /* R6 */
617 &dummy, /* R7 */
618 &dummy, /* R8 */
619 &dummy, /* R9 */
620 &dummy, /* R10 */
621 &dummy, /* R11 */
622 &dummy); /* R12 */
623} 553}
624 554
625u64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num, 555u64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num,
626 const u8 cb_cat, const u64 select_mask, 556 const u8 cb_cat, const u64 select_mask,
627 void *cb_addr) 557 void *cb_addr)
628{ 558{
629 u64 port_info, dummy, inv_attr_ident, proc_mask; 559 u64 outs[PLPAR_HCALL9_BUFSIZE];
560 u64 port_info;
630 u64 arr_index = 0; 561 u64 arr_index = 0;
631 u64 cb_logaddr = virt_to_abs(cb_addr); 562 u64 cb_logaddr = virt_to_abs(cb_addr);
632 563
@@ -635,29 +566,21 @@ u64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num,
635#ifdef DEBUG 566#ifdef DEBUG
636 ehea_dump(cb_addr, sizeof(struct hcp_ehea_port_cb0), "Before HCALL"); 567 ehea_dump(cb_addr, sizeof(struct hcp_ehea_port_cb0), "Before HCALL");
637#endif 568#endif
638 return ehea_hcall_9arg_9ret(H_MODIFY_HEA_PORT, 569 return ehea_plpar_hcall9(H_MODIFY_HEA_PORT,
639 adapter_handle, /* R4 */ 570 outs,
640 port_info, /* R5 */ 571 adapter_handle, /* R4 */
641 select_mask, /* R6 */ 572 port_info, /* R5 */
642 arr_index, /* R7 */ 573 select_mask, /* R6 */
643 cb_logaddr, /* R8 */ 574 arr_index, /* R7 */
644 0, 0, 0, 0, /* R9-R12 */ 575 cb_logaddr, /* R8 */
645 &inv_attr_ident, /* R4 */ 576 0, 0, 0, 0); /* R9-R12 */
646 &proc_mask, /* R5 */
647 &dummy, /* R6 */
648 &dummy, /* R7 */
649 &dummy, /* R8 */
650 &dummy, /* R9 */
651 &dummy, /* R10 */
652 &dummy, /* R11 */
653 &dummy); /* R12 */
654} 577}
655 578
656u64 ehea_h_reg_dereg_bcmc(const u64 adapter_handle, const u16 port_num, 579u64 ehea_h_reg_dereg_bcmc(const u64 adapter_handle, const u16 port_num,
657 const u8 reg_type, const u64 mc_mac_addr, 580 const u8 reg_type, const u64 mc_mac_addr,
658 const u16 vlan_id, const u32 hcall_id) 581 const u16 vlan_id, const u32 hcall_id)
659{ 582{
660 u64 r5_port_num, r6_reg_type, r7_mc_mac_addr, r8_vlan_id, dummy; 583 u64 r5_port_num, r6_reg_type, r7_mc_mac_addr, r8_vlan_id;
661 u64 mac_addr = mc_mac_addr >> 16; 584 u64 mac_addr = mc_mac_addr >> 16;
662 585
663 r5_port_num = EHEA_BMASK_SET(H_REGBCMC_PN, port_num); 586 r5_port_num = EHEA_BMASK_SET(H_REGBCMC_PN, port_num);
@@ -665,41 +588,21 @@ u64 ehea_h_reg_dereg_bcmc(const u64 adapter_handle, const u16 port_num,
665 r7_mc_mac_addr = EHEA_BMASK_SET(H_REGBCMC_MACADDR, mac_addr); 588 r7_mc_mac_addr = EHEA_BMASK_SET(H_REGBCMC_MACADDR, mac_addr);
666 r8_vlan_id = EHEA_BMASK_SET(H_REGBCMC_VLANID, vlan_id); 589 r8_vlan_id = EHEA_BMASK_SET(H_REGBCMC_VLANID, vlan_id);
667 590
668 return ehea_hcall_9arg_9ret(hcall_id, 591 return ehea_plpar_hcall_norets(hcall_id,
669 adapter_handle, /* R4 */ 592 adapter_handle, /* R4 */
670 r5_port_num, /* R5 */ 593 r5_port_num, /* R5 */
671 r6_reg_type, /* R6 */ 594 r6_reg_type, /* R6 */
672 r7_mc_mac_addr, /* R7 */ 595 r7_mc_mac_addr, /* R7 */
673 r8_vlan_id, /* R8 */ 596 r8_vlan_id, /* R8 */
674 0, 0, 0, 0, /* R9-R12 */ 597 0, 0); /* R9-R12 */
675 &dummy, /* R4 */
676 &dummy, /* R5 */
677 &dummy, /* R6 */
678 &dummy, /* R7 */
679 &dummy, /* R8 */
680 &dummy, /* R9 */
681 &dummy, /* R10 */
682 &dummy, /* R11 */
683 &dummy); /* R12 */
684} 598}
685 599
686u64 ehea_h_reset_events(const u64 adapter_handle, const u64 neq_handle, 600u64 ehea_h_reset_events(const u64 adapter_handle, const u64 neq_handle,
687 const u64 event_mask) 601 const u64 event_mask)
688{ 602{
689 u64 dummy; 603 return ehea_plpar_hcall_norets(H_RESET_EVENTS,
690 604 adapter_handle, /* R4 */
691 return ehea_hcall_9arg_9ret(H_RESET_EVENTS, 605 neq_handle, /* R5 */
692 adapter_handle, /* R4 */ 606 event_mask, /* R6 */
693 neq_handle, /* R5 */ 607 0, 0, 0, 0); /* R7-R12 */
694 event_mask, /* R6 */
695 0, 0, 0, 0, 0, 0, /* R7-R12 */
696 &dummy, /* R4 */
697 &dummy, /* R5 */
698 &dummy, /* R6 */
699 &dummy, /* R7 */
700 &dummy, /* R8 */
701 &dummy, /* R9 */
702 &dummy, /* R10 */
703 &dummy, /* R11 */
704 &dummy); /* R12 */
705} 608}
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c
index 8cc3c331aca8..b7b8bc2a6307 100644
--- a/drivers/net/eth16i.c
+++ b/drivers/net/eth16i.c
@@ -162,9 +162,9 @@ static char *version =
162#include <linux/skbuff.h> 162#include <linux/skbuff.h>
163#include <linux/bitops.h> 163#include <linux/bitops.h>
164#include <linux/jiffies.h> 164#include <linux/jiffies.h>
165#include <linux/io.h>
165 166
166#include <asm/system.h> 167#include <asm/system.h>
167#include <asm/io.h>
168#include <asm/dma.h> 168#include <asm/dma.h>
169 169
170 170
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 99b7a411db28..c5ed635bce36 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -2497,6 +2497,7 @@ static irqreturn_t nv_nic_irq_tx(int foo, void *data)
2497 u8 __iomem *base = get_hwbase(dev); 2497 u8 __iomem *base = get_hwbase(dev);
2498 u32 events; 2498 u32 events;
2499 int i; 2499 int i;
2500 unsigned long flags;
2500 2501
2501 dprintk(KERN_DEBUG "%s: nv_nic_irq_tx\n", dev->name); 2502 dprintk(KERN_DEBUG "%s: nv_nic_irq_tx\n", dev->name);
2502 2503
@@ -2508,16 +2509,16 @@ static irqreturn_t nv_nic_irq_tx(int foo, void *data)
2508 if (!(events & np->irqmask)) 2509 if (!(events & np->irqmask))
2509 break; 2510 break;
2510 2511
2511 spin_lock_irq(&np->lock); 2512 spin_lock_irqsave(&np->lock, flags);
2512 nv_tx_done(dev); 2513 nv_tx_done(dev);
2513 spin_unlock_irq(&np->lock); 2514 spin_unlock_irqrestore(&np->lock, flags);
2514 2515
2515 if (events & (NVREG_IRQ_TX_ERR)) { 2516 if (events & (NVREG_IRQ_TX_ERR)) {
2516 dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n", 2517 dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n",
2517 dev->name, events); 2518 dev->name, events);
2518 } 2519 }
2519 if (i > max_interrupt_work) { 2520 if (i > max_interrupt_work) {
2520 spin_lock_irq(&np->lock); 2521 spin_lock_irqsave(&np->lock, flags);
2521 /* disable interrupts on the nic */ 2522 /* disable interrupts on the nic */
2522 writel(NVREG_IRQ_TX_ALL, base + NvRegIrqMask); 2523 writel(NVREG_IRQ_TX_ALL, base + NvRegIrqMask);
2523 pci_push(base); 2524 pci_push(base);
@@ -2527,7 +2528,7 @@ static irqreturn_t nv_nic_irq_tx(int foo, void *data)
2527 mod_timer(&np->nic_poll, jiffies + POLL_WAIT); 2528 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2528 } 2529 }
2529 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_tx.\n", dev->name, i); 2530 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_tx.\n", dev->name, i);
2530 spin_unlock_irq(&np->lock); 2531 spin_unlock_irqrestore(&np->lock, flags);
2531 break; 2532 break;
2532 } 2533 }
2533 2534
@@ -2601,6 +2602,7 @@ static irqreturn_t nv_nic_irq_rx(int foo, void *data)
2601 u8 __iomem *base = get_hwbase(dev); 2602 u8 __iomem *base = get_hwbase(dev);
2602 u32 events; 2603 u32 events;
2603 int i; 2604 int i;
2605 unsigned long flags;
2604 2606
2605 dprintk(KERN_DEBUG "%s: nv_nic_irq_rx\n", dev->name); 2607 dprintk(KERN_DEBUG "%s: nv_nic_irq_rx\n", dev->name);
2606 2608
@@ -2614,14 +2616,14 @@ static irqreturn_t nv_nic_irq_rx(int foo, void *data)
2614 2616
2615 nv_rx_process(dev, dev->weight); 2617 nv_rx_process(dev, dev->weight);
2616 if (nv_alloc_rx(dev)) { 2618 if (nv_alloc_rx(dev)) {
2617 spin_lock_irq(&np->lock); 2619 spin_lock_irqsave(&np->lock, flags);
2618 if (!np->in_shutdown) 2620 if (!np->in_shutdown)
2619 mod_timer(&np->oom_kick, jiffies + OOM_REFILL); 2621 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
2620 spin_unlock_irq(&np->lock); 2622 spin_unlock_irqrestore(&np->lock, flags);
2621 } 2623 }
2622 2624
2623 if (i > max_interrupt_work) { 2625 if (i > max_interrupt_work) {
2624 spin_lock_irq(&np->lock); 2626 spin_lock_irqsave(&np->lock, flags);
2625 /* disable interrupts on the nic */ 2627 /* disable interrupts on the nic */
2626 writel(NVREG_IRQ_RX_ALL, base + NvRegIrqMask); 2628 writel(NVREG_IRQ_RX_ALL, base + NvRegIrqMask);
2627 pci_push(base); 2629 pci_push(base);
@@ -2631,7 +2633,7 @@ static irqreturn_t nv_nic_irq_rx(int foo, void *data)
2631 mod_timer(&np->nic_poll, jiffies + POLL_WAIT); 2633 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2632 } 2634 }
2633 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_rx.\n", dev->name, i); 2635 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_rx.\n", dev->name, i);
2634 spin_unlock_irq(&np->lock); 2636 spin_unlock_irqrestore(&np->lock, flags);
2635 break; 2637 break;
2636 } 2638 }
2637 } 2639 }
@@ -2648,6 +2650,7 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data)
2648 u8 __iomem *base = get_hwbase(dev); 2650 u8 __iomem *base = get_hwbase(dev);
2649 u32 events; 2651 u32 events;
2650 int i; 2652 int i;
2653 unsigned long flags;
2651 2654
2652 dprintk(KERN_DEBUG "%s: nv_nic_irq_other\n", dev->name); 2655 dprintk(KERN_DEBUG "%s: nv_nic_irq_other\n", dev->name);
2653 2656
@@ -2660,14 +2663,14 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data)
2660 break; 2663 break;
2661 2664
2662 if (events & NVREG_IRQ_LINK) { 2665 if (events & NVREG_IRQ_LINK) {
2663 spin_lock_irq(&np->lock); 2666 spin_lock_irqsave(&np->lock, flags);
2664 nv_link_irq(dev); 2667 nv_link_irq(dev);
2665 spin_unlock_irq(&np->lock); 2668 spin_unlock_irqrestore(&np->lock, flags);
2666 } 2669 }
2667 if (np->need_linktimer && time_after(jiffies, np->link_timeout)) { 2670 if (np->need_linktimer && time_after(jiffies, np->link_timeout)) {
2668 spin_lock_irq(&np->lock); 2671 spin_lock_irqsave(&np->lock, flags);
2669 nv_linkchange(dev); 2672 nv_linkchange(dev);
2670 spin_unlock_irq(&np->lock); 2673 spin_unlock_irqrestore(&np->lock, flags);
2671 np->link_timeout = jiffies + LINK_TIMEOUT; 2674 np->link_timeout = jiffies + LINK_TIMEOUT;
2672 } 2675 }
2673 if (events & (NVREG_IRQ_UNKNOWN)) { 2676 if (events & (NVREG_IRQ_UNKNOWN)) {
@@ -2675,7 +2678,7 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data)
2675 dev->name, events); 2678 dev->name, events);
2676 } 2679 }
2677 if (i > max_interrupt_work) { 2680 if (i > max_interrupt_work) {
2678 spin_lock_irq(&np->lock); 2681 spin_lock_irqsave(&np->lock, flags);
2679 /* disable interrupts on the nic */ 2682 /* disable interrupts on the nic */
2680 writel(NVREG_IRQ_OTHER, base + NvRegIrqMask); 2683 writel(NVREG_IRQ_OTHER, base + NvRegIrqMask);
2681 pci_push(base); 2684 pci_push(base);
@@ -2685,7 +2688,7 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data)
2685 mod_timer(&np->nic_poll, jiffies + POLL_WAIT); 2688 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
2686 } 2689 }
2687 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_other.\n", dev->name, i); 2690 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_other.\n", dev->name, i);
2688 spin_unlock_irq(&np->lock); 2691 spin_unlock_irqrestore(&np->lock, flags);
2689 break; 2692 break;
2690 } 2693 }
2691 2694
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 4bac3cd8f235..2802db23d3cb 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -213,6 +213,7 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
213 } 213 }
214 214
215 free_index = pool->consumer_index++ % pool->size; 215 free_index = pool->consumer_index++ % pool->size;
216 pool->consumer_index = free_index;
216 index = pool->free_map[free_index]; 217 index = pool->free_map[free_index];
217 218
218 ibmveth_assert(index != IBM_VETH_INVALID_MAP); 219 ibmveth_assert(index != IBM_VETH_INVALID_MAP);
@@ -238,7 +239,10 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter, struc
238 if(lpar_rc != H_SUCCESS) { 239 if(lpar_rc != H_SUCCESS) {
239 pool->free_map[free_index] = index; 240 pool->free_map[free_index] = index;
240 pool->skbuff[index] = NULL; 241 pool->skbuff[index] = NULL;
241 pool->consumer_index--; 242 if (pool->consumer_index == 0)
243 pool->consumer_index = pool->size - 1;
244 else
245 pool->consumer_index--;
242 dma_unmap_single(&adapter->vdev->dev, 246 dma_unmap_single(&adapter->vdev->dev,
243 pool->dma_addr[index], pool->buff_size, 247 pool->dma_addr[index], pool->buff_size,
244 DMA_FROM_DEVICE); 248 DMA_FROM_DEVICE);
@@ -326,6 +330,7 @@ static void ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter, u64
326 DMA_FROM_DEVICE); 330 DMA_FROM_DEVICE);
327 331
328 free_index = adapter->rx_buff_pool[pool].producer_index++ % adapter->rx_buff_pool[pool].size; 332 free_index = adapter->rx_buff_pool[pool].producer_index++ % adapter->rx_buff_pool[pool].size;
333 adapter->rx_buff_pool[pool].producer_index = free_index;
329 adapter->rx_buff_pool[pool].free_map[free_index] = index; 334 adapter->rx_buff_pool[pool].free_map[free_index] = index;
330 335
331 mb(); 336 mb();
@@ -437,6 +442,31 @@ static void ibmveth_cleanup(struct ibmveth_adapter *adapter)
437 &adapter->rx_buff_pool[i]); 442 &adapter->rx_buff_pool[i]);
438} 443}
439 444
445static int ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
446 union ibmveth_buf_desc rxq_desc, u64 mac_address)
447{
448 int rc, try_again = 1;
449
450 /* After a kexec the adapter will still be open, so our attempt to
451 * open it will fail. So if we get a failure we free the adapter and
452 * try again, but only once. */
453retry:
454 rc = h_register_logical_lan(adapter->vdev->unit_address,
455 adapter->buffer_list_dma, rxq_desc.desc,
456 adapter->filter_list_dma, mac_address);
457
458 if (rc != H_SUCCESS && try_again) {
459 do {
460 rc = h_free_logical_lan(adapter->vdev->unit_address);
461 } while (H_IS_LONG_BUSY(rc) || (rc == H_BUSY));
462
463 try_again = 0;
464 goto retry;
465 }
466
467 return rc;
468}
469
440static int ibmveth_open(struct net_device *netdev) 470static int ibmveth_open(struct net_device *netdev)
441{ 471{
442 struct ibmveth_adapter *adapter = netdev->priv; 472 struct ibmveth_adapter *adapter = netdev->priv;
@@ -502,12 +532,9 @@ static int ibmveth_open(struct net_device *netdev)
502 ibmveth_debug_printk("filter list @ 0x%p\n", adapter->filter_list_addr); 532 ibmveth_debug_printk("filter list @ 0x%p\n", adapter->filter_list_addr);
503 ibmveth_debug_printk("receive q @ 0x%p\n", adapter->rx_queue.queue_addr); 533 ibmveth_debug_printk("receive q @ 0x%p\n", adapter->rx_queue.queue_addr);
504 534
535 h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_DISABLE);
505 536
506 lpar_rc = h_register_logical_lan(adapter->vdev->unit_address, 537 lpar_rc = ibmveth_register_logical_lan(adapter, rxq_desc, mac_address);
507 adapter->buffer_list_dma,
508 rxq_desc.desc,
509 adapter->filter_list_dma,
510 mac_address);
511 538
512 if(lpar_rc != H_SUCCESS) { 539 if(lpar_rc != H_SUCCESS) {
513 ibmveth_error_printk("h_register_logical_lan failed with %ld\n", lpar_rc); 540 ibmveth_error_printk("h_register_logical_lan failed with %ld\n", lpar_rc);
@@ -905,6 +932,14 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
905 return -EINVAL; 932 return -EINVAL;
906} 933}
907 934
935#ifdef CONFIG_NET_POLL_CONTROLLER
936static void ibmveth_poll_controller(struct net_device *dev)
937{
938 ibmveth_replenish_task(dev->priv);
939 ibmveth_interrupt(dev->irq, dev);
940}
941#endif
942
908static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) 943static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
909{ 944{
910 int rc, i; 945 int rc, i;
@@ -977,6 +1012,9 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
977 netdev->ethtool_ops = &netdev_ethtool_ops; 1012 netdev->ethtool_ops = &netdev_ethtool_ops;
978 netdev->change_mtu = ibmveth_change_mtu; 1013 netdev->change_mtu = ibmveth_change_mtu;
979 SET_NETDEV_DEV(netdev, &dev->dev); 1014 SET_NETDEV_DEV(netdev, &dev->dev);
1015#ifdef CONFIG_NET_POLL_CONTROLLER
1016 netdev->poll_controller = ibmveth_poll_controller;
1017#endif
980 netdev->features |= NETIF_F_LLTX; 1018 netdev->features |= NETIF_F_LLTX;
981 spin_lock_init(&adapter->stats_lock); 1019 spin_lock_init(&adapter->stats_lock);
982 1020
@@ -1132,7 +1170,9 @@ static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter)
1132{ 1170{
1133 struct proc_dir_entry *entry; 1171 struct proc_dir_entry *entry;
1134 if (ibmveth_proc_dir) { 1172 if (ibmveth_proc_dir) {
1135 entry = create_proc_entry(adapter->netdev->name, S_IFREG, ibmveth_proc_dir); 1173 char u_addr[10];
1174 sprintf(u_addr, "%x", adapter->vdev->unit_address);
1175 entry = create_proc_entry(u_addr, S_IFREG, ibmveth_proc_dir);
1136 if (!entry) { 1176 if (!entry) {
1137 ibmveth_error_printk("Cannot create adapter proc entry"); 1177 ibmveth_error_printk("Cannot create adapter proc entry");
1138 } else { 1178 } else {
@@ -1147,7 +1187,9 @@ static void ibmveth_proc_register_adapter(struct ibmveth_adapter *adapter)
1147static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter) 1187static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter)
1148{ 1188{
1149 if (ibmveth_proc_dir) { 1189 if (ibmveth_proc_dir) {
1150 remove_proc_entry(adapter->netdev->name, ibmveth_proc_dir); 1190 char u_addr[10];
1191 sprintf(u_addr, "%x", adapter->vdev->unit_address);
1192 remove_proc_entry(u_addr, ibmveth_proc_dir);
1151 } 1193 }
1152} 1194}
1153 1195
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 2ffa3a59e704..9997081c6dae 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -2155,7 +2155,7 @@ static void eth_update_mib_counters(struct mv643xx_private *mp)
2155 for (offset = ETH_MIB_BAD_OCTETS_RECEIVED; 2155 for (offset = ETH_MIB_BAD_OCTETS_RECEIVED;
2156 offset <= ETH_MIB_FRAMES_1024_TO_MAX_OCTETS; 2156 offset <= ETH_MIB_FRAMES_1024_TO_MAX_OCTETS;
2157 offset += 4) 2157 offset += 4)
2158 *(u32 *)((char *)p + offset) = read_mib(mp, offset); 2158 *(u32 *)((char *)p + offset) += read_mib(mp, offset);
2159 2159
2160 p->good_octets_sent += read_mib(mp, ETH_MIB_GOOD_OCTETS_SENT_LOW); 2160 p->good_octets_sent += read_mib(mp, ETH_MIB_GOOD_OCTETS_SENT_LOW);
2161 p->good_octets_sent += 2161 p->good_octets_sent +=
@@ -2164,7 +2164,7 @@ static void eth_update_mib_counters(struct mv643xx_private *mp)
2164 for (offset = ETH_MIB_GOOD_FRAMES_SENT; 2164 for (offset = ETH_MIB_GOOD_FRAMES_SENT;
2165 offset <= ETH_MIB_LATE_COLLISION; 2165 offset <= ETH_MIB_LATE_COLLISION;
2166 offset += 4) 2166 offset += 4)
2167 *(u32 *)((char *)p + offset) = read_mib(mp, offset); 2167 *(u32 *)((char *)p + offset) += read_mib(mp, offset);
2168} 2168}
2169 2169
2170/* 2170/*
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index a4a58e4e93a1..e7e414928f89 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -43,7 +43,7 @@
43#include "skge.h" 43#include "skge.h"
44 44
45#define DRV_NAME "skge" 45#define DRV_NAME "skge"
46#define DRV_VERSION "1.8" 46#define DRV_VERSION "1.9"
47#define PFX DRV_NAME " " 47#define PFX DRV_NAME " "
48 48
49#define DEFAULT_TX_RING_SIZE 128 49#define DEFAULT_TX_RING_SIZE 128
@@ -197,8 +197,8 @@ static u32 skge_supported_modes(const struct skge_hw *hw)
197 else if (hw->chip_id == CHIP_ID_YUKON) 197 else if (hw->chip_id == CHIP_ID_YUKON)
198 supported &= ~SUPPORTED_1000baseT_Half; 198 supported &= ~SUPPORTED_1000baseT_Half;
199 } else 199 } else
200 supported = SUPPORTED_1000baseT_Full | SUPPORTED_FIBRE 200 supported = SUPPORTED_1000baseT_Full | SUPPORTED_1000baseT_Half
201 | SUPPORTED_Autoneg; 201 | SUPPORTED_FIBRE | SUPPORTED_Autoneg;
202 202
203 return supported; 203 return supported;
204} 204}
@@ -487,31 +487,37 @@ static void skge_get_pauseparam(struct net_device *dev,
487{ 487{
488 struct skge_port *skge = netdev_priv(dev); 488 struct skge_port *skge = netdev_priv(dev);
489 489
490 ecmd->tx_pause = (skge->flow_control == FLOW_MODE_LOC_SEND) 490 ecmd->rx_pause = (skge->flow_control == FLOW_MODE_SYMMETRIC)
491 || (skge->flow_control == FLOW_MODE_SYMMETRIC); 491 || (skge->flow_control == FLOW_MODE_SYM_OR_REM);
492 ecmd->rx_pause = (skge->flow_control == FLOW_MODE_REM_SEND) 492 ecmd->tx_pause = ecmd->rx_pause || (skge->flow_control == FLOW_MODE_LOC_SEND);
493 || (skge->flow_control == FLOW_MODE_SYMMETRIC);
494 493
495 ecmd->autoneg = skge->autoneg; 494 ecmd->autoneg = ecmd->rx_pause || ecmd->tx_pause;
496} 495}
497 496
498static int skge_set_pauseparam(struct net_device *dev, 497static int skge_set_pauseparam(struct net_device *dev,
499 struct ethtool_pauseparam *ecmd) 498 struct ethtool_pauseparam *ecmd)
500{ 499{
501 struct skge_port *skge = netdev_priv(dev); 500 struct skge_port *skge = netdev_priv(dev);
501 struct ethtool_pauseparam old;
502 502
503 skge->autoneg = ecmd->autoneg; 503 skge_get_pauseparam(dev, &old);
504 if (ecmd->rx_pause && ecmd->tx_pause) 504
505 skge->flow_control = FLOW_MODE_SYMMETRIC; 505 if (ecmd->autoneg != old.autoneg)
506 else if (ecmd->rx_pause && !ecmd->tx_pause) 506 skge->flow_control = ecmd->autoneg ? FLOW_MODE_NONE : FLOW_MODE_SYMMETRIC;
507 skge->flow_control = FLOW_MODE_REM_SEND; 507 else {
508 else if (!ecmd->rx_pause && ecmd->tx_pause) 508 if (ecmd->rx_pause && ecmd->tx_pause)
509 skge->flow_control = FLOW_MODE_LOC_SEND; 509 skge->flow_control = FLOW_MODE_SYMMETRIC;
510 else 510 else if (ecmd->rx_pause && !ecmd->tx_pause)
511 skge->flow_control = FLOW_MODE_NONE; 511 skge->flow_control = FLOW_MODE_SYM_OR_REM;
512 else if (!ecmd->rx_pause && ecmd->tx_pause)
513 skge->flow_control = FLOW_MODE_LOC_SEND;
514 else
515 skge->flow_control = FLOW_MODE_NONE;
516 }
512 517
513 if (netif_running(dev)) 518 if (netif_running(dev))
514 skge_phy_reset(skge); 519 skge_phy_reset(skge);
520
515 return 0; 521 return 0;
516} 522}
517 523
@@ -854,6 +860,23 @@ static int skge_rx_fill(struct net_device *dev)
854 return 0; 860 return 0;
855} 861}
856 862
863static const char *skge_pause(enum pause_status status)
864{
865 switch(status) {
866 case FLOW_STAT_NONE:
867 return "none";
868 case FLOW_STAT_REM_SEND:
869 return "rx only";
870 case FLOW_STAT_LOC_SEND:
871 return "tx_only";
872 case FLOW_STAT_SYMMETRIC: /* Both station may send PAUSE */
873 return "both";
874 default:
875 return "indeterminated";
876 }
877}
878
879
857static void skge_link_up(struct skge_port *skge) 880static void skge_link_up(struct skge_port *skge)
858{ 881{
859 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), 882 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG),
@@ -862,16 +885,13 @@ static void skge_link_up(struct skge_port *skge)
862 netif_carrier_on(skge->netdev); 885 netif_carrier_on(skge->netdev);
863 netif_wake_queue(skge->netdev); 886 netif_wake_queue(skge->netdev);
864 887
865 if (netif_msg_link(skge)) 888 if (netif_msg_link(skge)) {
866 printk(KERN_INFO PFX 889 printk(KERN_INFO PFX
867 "%s: Link is up at %d Mbps, %s duplex, flow control %s\n", 890 "%s: Link is up at %d Mbps, %s duplex, flow control %s\n",
868 skge->netdev->name, skge->speed, 891 skge->netdev->name, skge->speed,
869 skge->duplex == DUPLEX_FULL ? "full" : "half", 892 skge->duplex == DUPLEX_FULL ? "full" : "half",
870 (skge->flow_control == FLOW_MODE_NONE) ? "none" : 893 skge_pause(skge->flow_status));
871 (skge->flow_control == FLOW_MODE_LOC_SEND) ? "tx only" : 894 }
872 (skge->flow_control == FLOW_MODE_REM_SEND) ? "rx only" :
873 (skge->flow_control == FLOW_MODE_SYMMETRIC) ? "tx and rx" :
874 "unknown");
875} 895}
876 896
877static void skge_link_down(struct skge_port *skge) 897static void skge_link_down(struct skge_port *skge)
@@ -884,6 +904,29 @@ static void skge_link_down(struct skge_port *skge)
884 printk(KERN_INFO PFX "%s: Link is down.\n", skge->netdev->name); 904 printk(KERN_INFO PFX "%s: Link is down.\n", skge->netdev->name);
885} 905}
886 906
907
908static void xm_link_down(struct skge_hw *hw, int port)
909{
910 struct net_device *dev = hw->dev[port];
911 struct skge_port *skge = netdev_priv(dev);
912 u16 cmd, msk;
913
914 if (hw->phy_type == SK_PHY_XMAC) {
915 msk = xm_read16(hw, port, XM_IMSK);
916 msk |= XM_IS_INP_ASS | XM_IS_LIPA_RC | XM_IS_RX_PAGE | XM_IS_AND;
917 xm_write16(hw, port, XM_IMSK, msk);
918 }
919
920 cmd = xm_read16(hw, port, XM_MMU_CMD);
921 cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
922 xm_write16(hw, port, XM_MMU_CMD, cmd);
923 /* dummy read to ensure writing */
924 (void) xm_read16(hw, port, XM_MMU_CMD);
925
926 if (netif_carrier_ok(dev))
927 skge_link_down(skge);
928}
929
887static int __xm_phy_read(struct skge_hw *hw, int port, u16 reg, u16 *val) 930static int __xm_phy_read(struct skge_hw *hw, int port, u16 reg, u16 *val)
888{ 931{
889 int i; 932 int i;
@@ -992,7 +1035,15 @@ static const u16 phy_pause_map[] = {
992 [FLOW_MODE_NONE] = 0, 1035 [FLOW_MODE_NONE] = 0,
993 [FLOW_MODE_LOC_SEND] = PHY_AN_PAUSE_ASYM, 1036 [FLOW_MODE_LOC_SEND] = PHY_AN_PAUSE_ASYM,
994 [FLOW_MODE_SYMMETRIC] = PHY_AN_PAUSE_CAP, 1037 [FLOW_MODE_SYMMETRIC] = PHY_AN_PAUSE_CAP,
995 [FLOW_MODE_REM_SEND] = PHY_AN_PAUSE_CAP | PHY_AN_PAUSE_ASYM, 1038 [FLOW_MODE_SYM_OR_REM] = PHY_AN_PAUSE_CAP | PHY_AN_PAUSE_ASYM,
1039};
1040
1041/* special defines for FIBER (88E1011S only) */
1042static const u16 fiber_pause_map[] = {
1043 [FLOW_MODE_NONE] = PHY_X_P_NO_PAUSE,
1044 [FLOW_MODE_LOC_SEND] = PHY_X_P_ASYM_MD,
1045 [FLOW_MODE_SYMMETRIC] = PHY_X_P_SYM_MD,
1046 [FLOW_MODE_SYM_OR_REM] = PHY_X_P_BOTH_MD,
996}; 1047};
997 1048
998 1049
@@ -1008,14 +1059,7 @@ static void bcom_check_link(struct skge_hw *hw, int port)
1008 status = xm_phy_read(hw, port, PHY_BCOM_STAT); 1059 status = xm_phy_read(hw, port, PHY_BCOM_STAT);
1009 1060
1010 if ((status & PHY_ST_LSYNC) == 0) { 1061 if ((status & PHY_ST_LSYNC) == 0) {
1011 u16 cmd = xm_read16(hw, port, XM_MMU_CMD); 1062 xm_link_down(hw, port);
1012 cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
1013 xm_write16(hw, port, XM_MMU_CMD, cmd);
1014 /* dummy read to ensure writing */
1015 (void) xm_read16(hw, port, XM_MMU_CMD);
1016
1017 if (netif_carrier_ok(dev))
1018 skge_link_down(skge);
1019 return; 1063 return;
1020 } 1064 }
1021 1065
@@ -1048,20 +1092,19 @@ static void bcom_check_link(struct skge_hw *hw, int port)
1048 return; 1092 return;
1049 } 1093 }
1050 1094
1051
1052 /* We are using IEEE 802.3z/D5.0 Table 37-4 */ 1095 /* We are using IEEE 802.3z/D5.0 Table 37-4 */
1053 switch (aux & PHY_B_AS_PAUSE_MSK) { 1096 switch (aux & PHY_B_AS_PAUSE_MSK) {
1054 case PHY_B_AS_PAUSE_MSK: 1097 case PHY_B_AS_PAUSE_MSK:
1055 skge->flow_control = FLOW_MODE_SYMMETRIC; 1098 skge->flow_status = FLOW_STAT_SYMMETRIC;
1056 break; 1099 break;
1057 case PHY_B_AS_PRR: 1100 case PHY_B_AS_PRR:
1058 skge->flow_control = FLOW_MODE_REM_SEND; 1101 skge->flow_status = FLOW_STAT_REM_SEND;
1059 break; 1102 break;
1060 case PHY_B_AS_PRT: 1103 case PHY_B_AS_PRT:
1061 skge->flow_control = FLOW_MODE_LOC_SEND; 1104 skge->flow_status = FLOW_STAT_LOC_SEND;
1062 break; 1105 break;
1063 default: 1106 default:
1064 skge->flow_control = FLOW_MODE_NONE; 1107 skge->flow_status = FLOW_STAT_NONE;
1065 } 1108 }
1066 skge->speed = SPEED_1000; 1109 skge->speed = SPEED_1000;
1067 } 1110 }
@@ -1191,17 +1234,7 @@ static void xm_phy_init(struct skge_port *skge)
1191 if (skge->advertising & ADVERTISED_1000baseT_Full) 1234 if (skge->advertising & ADVERTISED_1000baseT_Full)
1192 ctrl |= PHY_X_AN_FD; 1235 ctrl |= PHY_X_AN_FD;
1193 1236
1194 switch(skge->flow_control) { 1237 ctrl |= fiber_pause_map[skge->flow_control];
1195 case FLOW_MODE_NONE:
1196 ctrl |= PHY_X_P_NO_PAUSE;
1197 break;
1198 case FLOW_MODE_LOC_SEND:
1199 ctrl |= PHY_X_P_ASYM_MD;
1200 break;
1201 case FLOW_MODE_SYMMETRIC:
1202 ctrl |= PHY_X_P_BOTH_MD;
1203 break;
1204 }
1205 1238
1206 xm_phy_write(hw, port, PHY_XMAC_AUNE_ADV, ctrl); 1239 xm_phy_write(hw, port, PHY_XMAC_AUNE_ADV, ctrl);
1207 1240
@@ -1235,14 +1268,7 @@ static void xm_check_link(struct net_device *dev)
1235 status = xm_phy_read(hw, port, PHY_XMAC_STAT); 1268 status = xm_phy_read(hw, port, PHY_XMAC_STAT);
1236 1269
1237 if ((status & PHY_ST_LSYNC) == 0) { 1270 if ((status & PHY_ST_LSYNC) == 0) {
1238 u16 cmd = xm_read16(hw, port, XM_MMU_CMD); 1271 xm_link_down(hw, port);
1239 cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
1240 xm_write16(hw, port, XM_MMU_CMD, cmd);
1241 /* dummy read to ensure writing */
1242 (void) xm_read16(hw, port, XM_MMU_CMD);
1243
1244 if (netif_carrier_ok(dev))
1245 skge_link_down(skge);
1246 return; 1272 return;
1247 } 1273 }
1248 1274
@@ -1276,15 +1302,20 @@ static void xm_check_link(struct net_device *dev)
1276 } 1302 }
1277 1303
1278 /* We are using IEEE 802.3z/D5.0 Table 37-4 */ 1304 /* We are using IEEE 802.3z/D5.0 Table 37-4 */
1279 if (lpa & PHY_X_P_SYM_MD) 1305 if ((skge->flow_control == FLOW_MODE_SYMMETRIC ||
1280 skge->flow_control = FLOW_MODE_SYMMETRIC; 1306 skge->flow_control == FLOW_MODE_SYM_OR_REM) &&
1281 else if ((lpa & PHY_X_RS_PAUSE) == PHY_X_P_ASYM_MD) 1307 (lpa & PHY_X_P_SYM_MD))
1282 skge->flow_control = FLOW_MODE_REM_SEND; 1308 skge->flow_status = FLOW_STAT_SYMMETRIC;
1283 else if ((lpa & PHY_X_RS_PAUSE) == PHY_X_P_BOTH_MD) 1309 else if (skge->flow_control == FLOW_MODE_SYM_OR_REM &&
1284 skge->flow_control = FLOW_MODE_LOC_SEND; 1310 (lpa & PHY_X_RS_PAUSE) == PHY_X_P_ASYM_MD)
1311 /* Enable PAUSE receive, disable PAUSE transmit */
1312 skge->flow_status = FLOW_STAT_REM_SEND;
1313 else if (skge->flow_control == FLOW_MODE_LOC_SEND &&
1314 (lpa & PHY_X_RS_PAUSE) == PHY_X_P_BOTH_MD)
1315 /* Disable PAUSE receive, enable PAUSE transmit */
1316 skge->flow_status = FLOW_STAT_LOC_SEND;
1285 else 1317 else
1286 skge->flow_control = FLOW_MODE_NONE; 1318 skge->flow_status = FLOW_STAT_NONE;
1287
1288 1319
1289 skge->speed = SPEED_1000; 1320 skge->speed = SPEED_1000;
1290 } 1321 }
@@ -1568,6 +1599,10 @@ static void genesis_mac_intr(struct skge_hw *hw, int port)
1568 printk(KERN_DEBUG PFX "%s: mac interrupt status 0x%x\n", 1599 printk(KERN_DEBUG PFX "%s: mac interrupt status 0x%x\n",
1569 skge->netdev->name, status); 1600 skge->netdev->name, status);
1570 1601
1602 if (hw->phy_type == SK_PHY_XMAC &&
1603 (status & (XM_IS_INP_ASS | XM_IS_LIPA_RC)))
1604 xm_link_down(hw, port);
1605
1571 if (status & XM_IS_TXF_UR) { 1606 if (status & XM_IS_TXF_UR) {
1572 xm_write32(hw, port, XM_MODE, XM_MD_FTF); 1607 xm_write32(hw, port, XM_MODE, XM_MD_FTF);
1573 ++skge->net_stats.tx_fifo_errors; 1608 ++skge->net_stats.tx_fifo_errors;
@@ -1582,7 +1617,7 @@ static void genesis_link_up(struct skge_port *skge)
1582{ 1617{
1583 struct skge_hw *hw = skge->hw; 1618 struct skge_hw *hw = skge->hw;
1584 int port = skge->port; 1619 int port = skge->port;
1585 u16 cmd; 1620 u16 cmd, msk;
1586 u32 mode; 1621 u32 mode;
1587 1622
1588 cmd = xm_read16(hw, port, XM_MMU_CMD); 1623 cmd = xm_read16(hw, port, XM_MMU_CMD);
@@ -1591,8 +1626,8 @@ static void genesis_link_up(struct skge_port *skge)
1591 * enabling pause frame reception is required for 1000BT 1626 * enabling pause frame reception is required for 1000BT
1592 * because the XMAC is not reset if the link is going down 1627 * because the XMAC is not reset if the link is going down
1593 */ 1628 */
1594 if (skge->flow_control == FLOW_MODE_NONE || 1629 if (skge->flow_status == FLOW_STAT_NONE ||
1595 skge->flow_control == FLOW_MODE_LOC_SEND) 1630 skge->flow_status == FLOW_STAT_LOC_SEND)
1596 /* Disable Pause Frame Reception */ 1631 /* Disable Pause Frame Reception */
1597 cmd |= XM_MMU_IGN_PF; 1632 cmd |= XM_MMU_IGN_PF;
1598 else 1633 else
@@ -1602,8 +1637,8 @@ static void genesis_link_up(struct skge_port *skge)
1602 xm_write16(hw, port, XM_MMU_CMD, cmd); 1637 xm_write16(hw, port, XM_MMU_CMD, cmd);
1603 1638
1604 mode = xm_read32(hw, port, XM_MODE); 1639 mode = xm_read32(hw, port, XM_MODE);
1605 if (skge->flow_control == FLOW_MODE_SYMMETRIC || 1640 if (skge->flow_status== FLOW_STAT_SYMMETRIC ||
1606 skge->flow_control == FLOW_MODE_LOC_SEND) { 1641 skge->flow_status == FLOW_STAT_LOC_SEND) {
1607 /* 1642 /*
1608 * Configure Pause Frame Generation 1643 * Configure Pause Frame Generation
1609 * Use internal and external Pause Frame Generation. 1644 * Use internal and external Pause Frame Generation.
@@ -1631,7 +1666,11 @@ static void genesis_link_up(struct skge_port *skge)
1631 } 1666 }
1632 1667
1633 xm_write32(hw, port, XM_MODE, mode); 1668 xm_write32(hw, port, XM_MODE, mode);
1634 xm_write16(hw, port, XM_IMSK, XM_DEF_MSK); 1669 msk = XM_DEF_MSK;
1670 if (hw->phy_type != SK_PHY_XMAC)
1671 msk |= XM_IS_INP_ASS; /* disable GP0 interrupt bit */
1672
1673 xm_write16(hw, port, XM_IMSK, msk);
1635 xm_read16(hw, port, XM_ISRC); 1674 xm_read16(hw, port, XM_ISRC);
1636 1675
1637 /* get MMU Command Reg. */ 1676 /* get MMU Command Reg. */
@@ -1779,11 +1818,17 @@ static void yukon_init(struct skge_hw *hw, int port)
1779 adv |= PHY_M_AN_10_FD; 1818 adv |= PHY_M_AN_10_FD;
1780 if (skge->advertising & ADVERTISED_10baseT_Half) 1819 if (skge->advertising & ADVERTISED_10baseT_Half)
1781 adv |= PHY_M_AN_10_HD; 1820 adv |= PHY_M_AN_10_HD;
1782 } else /* special defines for FIBER (88E1011S only) */
1783 adv |= PHY_M_AN_1000X_AHD | PHY_M_AN_1000X_AFD;
1784 1821
1785 /* Set Flow-control capabilities */ 1822 /* Set Flow-control capabilities */
1786 adv |= phy_pause_map[skge->flow_control]; 1823 adv |= phy_pause_map[skge->flow_control];
1824 } else {
1825 if (skge->advertising & ADVERTISED_1000baseT_Full)
1826 adv |= PHY_M_AN_1000X_AFD;
1827 if (skge->advertising & ADVERTISED_1000baseT_Half)
1828 adv |= PHY_M_AN_1000X_AHD;
1829
1830 adv |= fiber_pause_map[skge->flow_control];
1831 }
1787 1832
1788 /* Restart Auto-negotiation */ 1833 /* Restart Auto-negotiation */
1789 ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG; 1834 ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG;
@@ -1917,6 +1962,11 @@ static void yukon_mac_init(struct skge_hw *hw, int port)
1917 case FLOW_MODE_LOC_SEND: 1962 case FLOW_MODE_LOC_SEND:
1918 /* disable Rx flow-control */ 1963 /* disable Rx flow-control */
1919 reg |= GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS; 1964 reg |= GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS;
1965 break;
1966 case FLOW_MODE_SYMMETRIC:
1967 case FLOW_MODE_SYM_OR_REM:
1968 /* enable Tx & Rx flow-control */
1969 break;
1920 } 1970 }
1921 1971
1922 gma_write16(hw, port, GM_GP_CTRL, reg); 1972 gma_write16(hw, port, GM_GP_CTRL, reg);
@@ -2111,13 +2161,11 @@ static void yukon_link_down(struct skge_port *skge)
2111 ctrl &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); 2161 ctrl &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
2112 gma_write16(hw, port, GM_GP_CTRL, ctrl); 2162 gma_write16(hw, port, GM_GP_CTRL, ctrl);
2113 2163
2114 if (skge->flow_control == FLOW_MODE_REM_SEND) { 2164 if (skge->flow_status == FLOW_STAT_REM_SEND) {
2165 ctrl = gm_phy_read(hw, port, PHY_MARV_AUNE_ADV);
2166 ctrl |= PHY_M_AN_ASP;
2115 /* restore Asymmetric Pause bit */ 2167 /* restore Asymmetric Pause bit */
2116 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, 2168 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, ctrl);
2117 gm_phy_read(hw, port,
2118 PHY_MARV_AUNE_ADV)
2119 | PHY_M_AN_ASP);
2120
2121 } 2169 }
2122 2170
2123 yukon_reset(hw, port); 2171 yukon_reset(hw, port);
@@ -2164,19 +2212,19 @@ static void yukon_phy_intr(struct skge_port *skge)
2164 /* We are using IEEE 802.3z/D5.0 Table 37-4 */ 2212 /* We are using IEEE 802.3z/D5.0 Table 37-4 */
2165 switch (phystat & PHY_M_PS_PAUSE_MSK) { 2213 switch (phystat & PHY_M_PS_PAUSE_MSK) {
2166 case PHY_M_PS_PAUSE_MSK: 2214 case PHY_M_PS_PAUSE_MSK:
2167 skge->flow_control = FLOW_MODE_SYMMETRIC; 2215 skge->flow_status = FLOW_STAT_SYMMETRIC;
2168 break; 2216 break;
2169 case PHY_M_PS_RX_P_EN: 2217 case PHY_M_PS_RX_P_EN:
2170 skge->flow_control = FLOW_MODE_REM_SEND; 2218 skge->flow_status = FLOW_STAT_REM_SEND;
2171 break; 2219 break;
2172 case PHY_M_PS_TX_P_EN: 2220 case PHY_M_PS_TX_P_EN:
2173 skge->flow_control = FLOW_MODE_LOC_SEND; 2221 skge->flow_status = FLOW_STAT_LOC_SEND;
2174 break; 2222 break;
2175 default: 2223 default:
2176 skge->flow_control = FLOW_MODE_NONE; 2224 skge->flow_status = FLOW_STAT_NONE;
2177 } 2225 }
2178 2226
2179 if (skge->flow_control == FLOW_MODE_NONE || 2227 if (skge->flow_status == FLOW_STAT_NONE ||
2180 (skge->speed < SPEED_1000 && skge->duplex == DUPLEX_HALF)) 2228 (skge->speed < SPEED_1000 && skge->duplex == DUPLEX_HALF))
2181 skge_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); 2229 skge_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
2182 else 2230 else
@@ -3399,7 +3447,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3399 3447
3400 /* Auto speed and flow control */ 3448 /* Auto speed and flow control */
3401 skge->autoneg = AUTONEG_ENABLE; 3449 skge->autoneg = AUTONEG_ENABLE;
3402 skge->flow_control = FLOW_MODE_SYMMETRIC; 3450 skge->flow_control = FLOW_MODE_SYM_OR_REM;
3403 skge->duplex = -1; 3451 skge->duplex = -1;
3404 skge->speed = -1; 3452 skge->speed = -1;
3405 skge->advertising = skge_supported_modes(hw); 3453 skge->advertising = skge_supported_modes(hw);
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index d0b47d46cf9d..537c0aaa1db8 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -2195,7 +2195,8 @@ enum {
2195 XM_IS_RX_COMP = 1<<0, /* Bit 0: Frame Rx Complete */ 2195 XM_IS_RX_COMP = 1<<0, /* Bit 0: Frame Rx Complete */
2196}; 2196};
2197 2197
2198#define XM_DEF_MSK (~(XM_IS_RXC_OV | XM_IS_TXC_OV | XM_IS_RXF_OV | XM_IS_TXF_UR)) 2198#define XM_DEF_MSK (~(XM_IS_INP_ASS | XM_IS_LIPA_RC | \
2199 XM_IS_RXF_OV | XM_IS_TXF_UR))
2199 2200
2200 2201
2201/* XM_HW_CFG 16 bit r/w Hardware Config Register */ 2202/* XM_HW_CFG 16 bit r/w Hardware Config Register */
@@ -2426,13 +2427,24 @@ struct skge_hw {
2426 struct mutex phy_mutex; 2427 struct mutex phy_mutex;
2427}; 2428};
2428 2429
2429enum { 2430enum pause_control {
2430 FLOW_MODE_NONE = 0, /* No Flow-Control */ 2431 FLOW_MODE_NONE = 1, /* No Flow-Control */
2431 FLOW_MODE_LOC_SEND = 1, /* Local station sends PAUSE */ 2432 FLOW_MODE_LOC_SEND = 2, /* Local station sends PAUSE */
2432 FLOW_MODE_REM_SEND = 2, /* Symmetric or just remote */
2433 FLOW_MODE_SYMMETRIC = 3, /* Both stations may send PAUSE */ 2433 FLOW_MODE_SYMMETRIC = 3, /* Both stations may send PAUSE */
2434 FLOW_MODE_SYM_OR_REM = 4, /* Both stations may send PAUSE or
2435 * just the remote station may send PAUSE
2436 */
2437};
2438
2439enum pause_status {
2440 FLOW_STAT_INDETERMINATED=0, /* indeterminated */
2441 FLOW_STAT_NONE, /* No Flow Control */
2442 FLOW_STAT_REM_SEND, /* Remote Station sends PAUSE */
2443 FLOW_STAT_LOC_SEND, /* Local station sends PAUSE */
2444 FLOW_STAT_SYMMETRIC, /* Both station may send PAUSE */
2434}; 2445};
2435 2446
2447
2436struct skge_port { 2448struct skge_port {
2437 u32 msg_enable; 2449 u32 msg_enable;
2438 struct skge_hw *hw; 2450 struct skge_hw *hw;
@@ -2445,9 +2457,10 @@ struct skge_port {
2445 struct net_device_stats net_stats; 2457 struct net_device_stats net_stats;
2446 2458
2447 struct work_struct link_thread; 2459 struct work_struct link_thread;
2460 enum pause_control flow_control;
2461 enum pause_status flow_status;
2448 u8 rx_csum; 2462 u8 rx_csum;
2449 u8 blink_on; 2463 u8 blink_on;
2450 u8 flow_control;
2451 u8 wol; 2464 u8 wol;
2452 u8 autoneg; /* AUTONEG_ENABLE, AUTONEG_DISABLE */ 2465 u8 autoneg; /* AUTONEG_ENABLE, AUTONEG_DISABLE */
2453 u8 duplex; /* DUPLEX_HALF, DUPLEX_FULL */ 2466 u8 duplex; /* DUPLEX_HALF, DUPLEX_FULL */
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 459c845d6648..c10e7f5faa5f 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -683,7 +683,7 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
683 sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON); 683 sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON);
684 684
685 if (hw->chip_id == CHIP_ID_YUKON_EC_U) { 685 if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
686 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8); 686 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 512/8);
687 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8); 687 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8);
688 if (hw->dev[port]->mtu > ETH_DATA_LEN) { 688 if (hw->dev[port]->mtu > ETH_DATA_LEN) {
689 /* set Tx GMAC FIFO Almost Empty Threshold */ 689 /* set Tx GMAC FIFO Almost Empty Threshold */
@@ -1907,7 +1907,7 @@ static struct sk_buff *receive_copy(struct sky2_port *sky2,
1907 pci_dma_sync_single_for_device(sky2->hw->pdev, re->data_addr, 1907 pci_dma_sync_single_for_device(sky2->hw->pdev, re->data_addr,
1908 length, PCI_DMA_FROMDEVICE); 1908 length, PCI_DMA_FROMDEVICE);
1909 re->skb->ip_summed = CHECKSUM_NONE; 1909 re->skb->ip_summed = CHECKSUM_NONE;
1910 __skb_put(skb, length); 1910 skb_put(skb, length);
1911 } 1911 }
1912 return skb; 1912 return skb;
1913} 1913}
@@ -1970,7 +1970,7 @@ static struct sk_buff *receive_new(struct sky2_port *sky2,
1970 if (skb_shinfo(skb)->nr_frags) 1970 if (skb_shinfo(skb)->nr_frags)
1971 skb_put_frags(skb, hdr_space, length); 1971 skb_put_frags(skb, hdr_space, length);
1972 else 1972 else
1973 skb_put(skb, hdr_space); 1973 skb_put(skb, length);
1974 return skb; 1974 return skb;
1975} 1975}
1976 1976
@@ -2220,8 +2220,7 @@ static void sky2_hw_intr(struct sky2_hw *hw)
2220 /* PCI-Express uncorrectable Error occurred */ 2220 /* PCI-Express uncorrectable Error occurred */
2221 u32 pex_err; 2221 u32 pex_err;
2222 2222
2223 pex_err = sky2_pci_read32(hw, 2223 pex_err = sky2_pci_read32(hw, PEX_UNC_ERR_STAT);
2224 hw->err_cap + PCI_ERR_UNCOR_STATUS);
2225 2224
2226 if (net_ratelimit()) 2225 if (net_ratelimit())
2227 printk(KERN_ERR PFX "%s: pci express error (0x%x)\n", 2226 printk(KERN_ERR PFX "%s: pci express error (0x%x)\n",
@@ -2229,20 +2228,15 @@ static void sky2_hw_intr(struct sky2_hw *hw)
2229 2228
2230 /* clear the interrupt */ 2229 /* clear the interrupt */
2231 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 2230 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2232 sky2_pci_write32(hw, 2231 sky2_pci_write32(hw, PEX_UNC_ERR_STAT,
2233 hw->err_cap + PCI_ERR_UNCOR_STATUS, 2232 0xffffffffUL);
2234 0xffffffffUL);
2235 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); 2233 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2236 2234
2237 2235 if (pex_err & PEX_FATAL_ERRORS) {
2238 /* In case of fatal error mask off to keep from getting stuck */
2239 if (pex_err & (PCI_ERR_UNC_POISON_TLP | PCI_ERR_UNC_FCP
2240 | PCI_ERR_UNC_DLP)) {
2241 u32 hwmsk = sky2_read32(hw, B0_HWE_IMSK); 2236 u32 hwmsk = sky2_read32(hw, B0_HWE_IMSK);
2242 hwmsk &= ~Y2_IS_PCI_EXP; 2237 hwmsk &= ~Y2_IS_PCI_EXP;
2243 sky2_write32(hw, B0_HWE_IMSK, hwmsk); 2238 sky2_write32(hw, B0_HWE_IMSK, hwmsk);
2244 } 2239 }
2245
2246 } 2240 }
2247 2241
2248 if (status & Y2_HWE_L1_MASK) 2242 if (status & Y2_HWE_L1_MASK)
@@ -2423,7 +2417,6 @@ static int sky2_reset(struct sky2_hw *hw)
2423 u16 status; 2417 u16 status;
2424 u8 t8; 2418 u8 t8;
2425 int i; 2419 int i;
2426 u32 msk;
2427 2420
2428 sky2_write8(hw, B0_CTST, CS_RST_CLR); 2421 sky2_write8(hw, B0_CTST, CS_RST_CLR);
2429 2422
@@ -2464,13 +2457,9 @@ static int sky2_reset(struct sky2_hw *hw)
2464 sky2_write8(hw, B0_CTST, CS_MRST_CLR); 2457 sky2_write8(hw, B0_CTST, CS_MRST_CLR);
2465 2458
2466 /* clear any PEX errors */ 2459 /* clear any PEX errors */
2467 if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP)) { 2460 if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP))
2468 hw->err_cap = pci_find_ext_capability(hw->pdev, PCI_EXT_CAP_ID_ERR); 2461 sky2_pci_write32(hw, PEX_UNC_ERR_STAT, 0xffffffffUL);
2469 if (hw->err_cap) 2462
2470 sky2_pci_write32(hw,
2471 hw->err_cap + PCI_ERR_UNCOR_STATUS,
2472 0xffffffffUL);
2473 }
2474 2463
2475 hw->pmd_type = sky2_read8(hw, B2_PMD_TYP); 2464 hw->pmd_type = sky2_read8(hw, B2_PMD_TYP);
2476 hw->ports = 1; 2465 hw->ports = 1;
@@ -2527,10 +2516,7 @@ static int sky2_reset(struct sky2_hw *hw)
2527 sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XS2), SK_RI_TO_53); 2516 sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XS2), SK_RI_TO_53);
2528 } 2517 }
2529 2518
2530 msk = Y2_HWE_ALL_MASK; 2519 sky2_write32(hw, B0_HWE_IMSK, Y2_HWE_ALL_MASK);
2531 if (!hw->err_cap)
2532 msk &= ~Y2_IS_PCI_EXP;
2533 sky2_write32(hw, B0_HWE_IMSK, msk);
2534 2520
2535 for (i = 0; i < hw->ports; i++) 2521 for (i = 0; i < hw->ports; i++)
2536 sky2_gmac_reset(hw, i); 2522 sky2_gmac_reset(hw, i);
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index f66109a96d95..43d2accf60e1 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -6,15 +6,24 @@
6 6
7#define ETH_JUMBO_MTU 9000 /* Maximum MTU supported */ 7#define ETH_JUMBO_MTU 9000 /* Maximum MTU supported */
8 8
9/* PCI device specific config registers */ 9/* PCI config registers */
10enum { 10enum {
11 PCI_DEV_REG1 = 0x40, 11 PCI_DEV_REG1 = 0x40,
12 PCI_DEV_REG2 = 0x44, 12 PCI_DEV_REG2 = 0x44,
13 PCI_DEV_STATUS = 0x7c,
13 PCI_DEV_REG3 = 0x80, 14 PCI_DEV_REG3 = 0x80,
14 PCI_DEV_REG4 = 0x84, 15 PCI_DEV_REG4 = 0x84,
15 PCI_DEV_REG5 = 0x88, 16 PCI_DEV_REG5 = 0x88,
16}; 17};
17 18
19enum {
20 PEX_DEV_CAP = 0xe4,
21 PEX_DEV_CTRL = 0xe8,
22 PEX_DEV_STA = 0xea,
23 PEX_LNK_STAT = 0xf2,
24 PEX_UNC_ERR_STAT= 0x104,
25};
26
18/* Yukon-2 */ 27/* Yukon-2 */
19enum pci_dev_reg_1 { 28enum pci_dev_reg_1 {
20 PCI_Y2_PIG_ENA = 1<<31, /* Enable Plug-in-Go (YUKON-2) */ 29 PCI_Y2_PIG_ENA = 1<<31, /* Enable Plug-in-Go (YUKON-2) */
@@ -63,6 +72,39 @@ enum pci_dev_reg_4 {
63 PCI_STATUS_REC_MASTER_ABORT | \ 72 PCI_STATUS_REC_MASTER_ABORT | \
64 PCI_STATUS_REC_TARGET_ABORT | \ 73 PCI_STATUS_REC_TARGET_ABORT | \
65 PCI_STATUS_PARITY) 74 PCI_STATUS_PARITY)
75
76enum pex_dev_ctrl {
77 PEX_DC_MAX_RRS_MSK = 7<<12, /* Bit 14..12: Max. Read Request Size */
78 PEX_DC_EN_NO_SNOOP = 1<<11,/* Enable No Snoop */
79 PEX_DC_EN_AUX_POW = 1<<10,/* Enable AUX Power */
80 PEX_DC_EN_PHANTOM = 1<<9, /* Enable Phantom Functions */
81 PEX_DC_EN_EXT_TAG = 1<<8, /* Enable Extended Tag Field */
82 PEX_DC_MAX_PLS_MSK = 7<<5, /* Bit 7.. 5: Max. Payload Size Mask */
83 PEX_DC_EN_REL_ORD = 1<<4, /* Enable Relaxed Ordering */
84 PEX_DC_EN_UNS_RQ_RP = 1<<3, /* Enable Unsupported Request Reporting */
85 PEX_DC_EN_FAT_ER_RP = 1<<2, /* Enable Fatal Error Reporting */
86 PEX_DC_EN_NFA_ER_RP = 1<<1, /* Enable Non-Fatal Error Reporting */
87 PEX_DC_EN_COR_ER_RP = 1<<0, /* Enable Correctable Error Reporting */
88};
89#define PEX_DC_MAX_RD_RQ_SIZE(x) (((x)<<12) & PEX_DC_MAX_RRS_MSK)
90
91/* PEX_UNC_ERR_STAT PEX Uncorrectable Errors Status Register (Yukon-2) */
92enum pex_err {
93 PEX_UNSUP_REQ = 1<<20, /* Unsupported Request Error */
94
95 PEX_MALFOR_TLP = 1<<18, /* Malformed TLP */
96
97 PEX_UNEXP_COMP = 1<<16, /* Unexpected Completion */
98
99 PEX_COMP_TO = 1<<14, /* Completion Timeout */
100 PEX_FLOW_CTRL_P = 1<<13, /* Flow Control Protocol Error */
101 PEX_POIS_TLP = 1<<12, /* Poisoned TLP */
102
103 PEX_DATA_LINK_P = 1<<4, /* Data Link Protocol Error */
104 PEX_FATAL_ERRORS= (PEX_MALFOR_TLP | PEX_FLOW_CTRL_P | PEX_DATA_LINK_P),
105};
106
107
66enum csr_regs { 108enum csr_regs {
67 B0_RAP = 0x0000, 109 B0_RAP = 0x0000,
68 B0_CTST = 0x0004, 110 B0_CTST = 0x0004,
@@ -1836,7 +1878,6 @@ struct sky2_hw {
1836 struct net_device *dev[2]; 1878 struct net_device *dev[2];
1837 1879
1838 int pm_cap; 1880 int pm_cap;
1839 int err_cap;
1840 u8 chip_id; 1881 u8 chip_id;
1841 u8 chip_rev; 1882 u8 chip_rev;
1842 u8 pmd_type; 1883 u8 pmd_type;
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 636dbfcdf8cb..0c9f1e7dab2e 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -398,6 +398,24 @@ static inline void LPD7_SMC_outsw (unsigned char* a, int r,
398 398
399#define SMC_IRQ_FLAGS (0) 399#define SMC_IRQ_FLAGS (0)
400 400
401#elif defined(CONFIG_ARCH_VERSATILE)
402
403#define SMC_CAN_USE_8BIT 1
404#define SMC_CAN_USE_16BIT 1
405#define SMC_CAN_USE_32BIT 1
406#define SMC_NOWAIT 1
407
408#define SMC_inb(a, r) readb((a) + (r))
409#define SMC_inw(a, r) readw((a) + (r))
410#define SMC_inl(a, r) readl((a) + (r))
411#define SMC_outb(v, a, r) writeb(v, (a) + (r))
412#define SMC_outw(v, a, r) writew(v, (a) + (r))
413#define SMC_outl(v, a, r) writel(v, (a) + (r))
414#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
415#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l)
416
417#define SMC_IRQ_FLAGS (0)
418
401#else 419#else
402 420
403#define SMC_CAN_USE_8BIT 1 421#define SMC_CAN_USE_8BIT 1
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 46a009085f7c..418138dd6c68 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -55,12 +55,13 @@ MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com> and Jens Osterkamp " \
55 "<Jens.Osterkamp@de.ibm.com>"); 55 "<Jens.Osterkamp@de.ibm.com>");
56MODULE_DESCRIPTION("Spider Southbridge Gigabit Ethernet driver"); 56MODULE_DESCRIPTION("Spider Southbridge Gigabit Ethernet driver");
57MODULE_LICENSE("GPL"); 57MODULE_LICENSE("GPL");
58MODULE_VERSION(VERSION);
58 59
59static int rx_descriptors = SPIDER_NET_RX_DESCRIPTORS_DEFAULT; 60static int rx_descriptors = SPIDER_NET_RX_DESCRIPTORS_DEFAULT;
60static int tx_descriptors = SPIDER_NET_TX_DESCRIPTORS_DEFAULT; 61static int tx_descriptors = SPIDER_NET_TX_DESCRIPTORS_DEFAULT;
61 62
62module_param(rx_descriptors, int, 0644); 63module_param(rx_descriptors, int, 0444);
63module_param(tx_descriptors, int, 0644); 64module_param(tx_descriptors, int, 0444);
64 65
65MODULE_PARM_DESC(rx_descriptors, "number of descriptors used " \ 66MODULE_PARM_DESC(rx_descriptors, "number of descriptors used " \
66 "in rx chains"); 67 "in rx chains");
@@ -300,7 +301,7 @@ static int
300spider_net_init_chain(struct spider_net_card *card, 301spider_net_init_chain(struct spider_net_card *card,
301 struct spider_net_descr_chain *chain, 302 struct spider_net_descr_chain *chain,
302 struct spider_net_descr *start_descr, 303 struct spider_net_descr *start_descr,
303 int direction, int no) 304 int no)
304{ 305{
305 int i; 306 int i;
306 struct spider_net_descr *descr; 307 struct spider_net_descr *descr;
@@ -315,7 +316,7 @@ spider_net_init_chain(struct spider_net_card *card,
315 316
316 buf = pci_map_single(card->pdev, descr, 317 buf = pci_map_single(card->pdev, descr,
317 SPIDER_NET_DESCR_SIZE, 318 SPIDER_NET_DESCR_SIZE,
318 direction); 319 PCI_DMA_BIDIRECTIONAL);
319 320
320 if (pci_dma_mapping_error(buf)) 321 if (pci_dma_mapping_error(buf))
321 goto iommu_error; 322 goto iommu_error;
@@ -329,11 +330,6 @@ spider_net_init_chain(struct spider_net_card *card,
329 (descr-1)->next = start_descr; 330 (descr-1)->next = start_descr;
330 start_descr->prev = descr-1; 331 start_descr->prev = descr-1;
331 332
332 descr = start_descr;
333 if (direction == PCI_DMA_FROMDEVICE)
334 for (i=0; i < no; i++, descr++)
335 descr->next_descr_addr = descr->next->bus_addr;
336
337 spin_lock_init(&chain->lock); 333 spin_lock_init(&chain->lock);
338 chain->head = start_descr; 334 chain->head = start_descr;
339 chain->tail = start_descr; 335 chain->tail = start_descr;
@@ -346,7 +342,7 @@ iommu_error:
346 if (descr->bus_addr) 342 if (descr->bus_addr)
347 pci_unmap_single(card->pdev, descr->bus_addr, 343 pci_unmap_single(card->pdev, descr->bus_addr,
348 SPIDER_NET_DESCR_SIZE, 344 SPIDER_NET_DESCR_SIZE,
349 direction); 345 PCI_DMA_BIDIRECTIONAL);
350 return -ENOMEM; 346 return -ENOMEM;
351} 347}
352 348
@@ -362,15 +358,15 @@ spider_net_free_rx_chain_contents(struct spider_net_card *card)
362 struct spider_net_descr *descr; 358 struct spider_net_descr *descr;
363 359
364 descr = card->rx_chain.head; 360 descr = card->rx_chain.head;
365 while (descr->next != card->rx_chain.head) { 361 do {
366 if (descr->skb) { 362 if (descr->skb) {
367 dev_kfree_skb(descr->skb); 363 dev_kfree_skb(descr->skb);
368 pci_unmap_single(card->pdev, descr->buf_addr, 364 pci_unmap_single(card->pdev, descr->buf_addr,
369 SPIDER_NET_MAX_FRAME, 365 SPIDER_NET_MAX_FRAME,
370 PCI_DMA_FROMDEVICE); 366 PCI_DMA_BIDIRECTIONAL);
371 } 367 }
372 descr = descr->next; 368 descr = descr->next;
373 } 369 } while (descr != card->rx_chain.head);
374} 370}
375 371
376/** 372/**
@@ -645,26 +641,41 @@ static int
645spider_net_prepare_tx_descr(struct spider_net_card *card, 641spider_net_prepare_tx_descr(struct spider_net_card *card,
646 struct sk_buff *skb) 642 struct sk_buff *skb)
647{ 643{
648 struct spider_net_descr *descr = card->tx_chain.head; 644 struct spider_net_descr *descr;
649 dma_addr_t buf; 645 dma_addr_t buf;
646 unsigned long flags;
647 int length;
650 648
651 buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); 649 length = skb->len;
650 if (length < ETH_ZLEN) {
651 if (skb_pad(skb, ETH_ZLEN-length))
652 return 0;
653 length = ETH_ZLEN;
654 }
655
656 buf = pci_map_single(card->pdev, skb->data, length, PCI_DMA_TODEVICE);
652 if (pci_dma_mapping_error(buf)) { 657 if (pci_dma_mapping_error(buf)) {
653 if (netif_msg_tx_err(card) && net_ratelimit()) 658 if (netif_msg_tx_err(card) && net_ratelimit())
654 pr_err("could not iommu-map packet (%p, %i). " 659 pr_err("could not iommu-map packet (%p, %i). "
655 "Dropping packet\n", skb->data, skb->len); 660 "Dropping packet\n", skb->data, length);
656 card->spider_stats.tx_iommu_map_error++; 661 card->spider_stats.tx_iommu_map_error++;
657 return -ENOMEM; 662 return -ENOMEM;
658 } 663 }
659 664
665 spin_lock_irqsave(&card->tx_chain.lock, flags);
666 descr = card->tx_chain.head;
667 card->tx_chain.head = descr->next;
668
660 descr->buf_addr = buf; 669 descr->buf_addr = buf;
661 descr->buf_size = skb->len; 670 descr->buf_size = length;
662 descr->next_descr_addr = 0; 671 descr->next_descr_addr = 0;
663 descr->skb = skb; 672 descr->skb = skb;
664 descr->data_status = 0; 673 descr->data_status = 0;
665 674
666 descr->dmac_cmd_status = 675 descr->dmac_cmd_status =
667 SPIDER_NET_DESCR_CARDOWNED | SPIDER_NET_DMAC_NOCS; 676 SPIDER_NET_DESCR_CARDOWNED | SPIDER_NET_DMAC_NOCS;
677 spin_unlock_irqrestore(&card->tx_chain.lock, flags);
678
668 if (skb->protocol == htons(ETH_P_IP)) 679 if (skb->protocol == htons(ETH_P_IP))
669 switch (skb->nh.iph->protocol) { 680 switch (skb->nh.iph->protocol) {
670 case IPPROTO_TCP: 681 case IPPROTO_TCP:
@@ -675,32 +686,51 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
675 break; 686 break;
676 } 687 }
677 688
689 /* Chain the bus address, so that the DMA engine finds this descr. */
678 descr->prev->next_descr_addr = descr->bus_addr; 690 descr->prev->next_descr_addr = descr->bus_addr;
679 691
692 card->netdev->trans_start = jiffies; /* set netdev watchdog timer */
680 return 0; 693 return 0;
681} 694}
682 695
683/** 696static int
684 * spider_net_release_tx_descr - processes a used tx descriptor 697spider_net_set_low_watermark(struct spider_net_card *card)
685 * @card: card structure
686 * @descr: descriptor to release
687 *
688 * releases a used tx descriptor (unmapping, freeing of skb)
689 */
690static inline void
691spider_net_release_tx_descr(struct spider_net_card *card)
692{ 698{
699 unsigned long flags;
700 int status;
701 int cnt=0;
702 int i;
693 struct spider_net_descr *descr = card->tx_chain.tail; 703 struct spider_net_descr *descr = card->tx_chain.tail;
694 struct sk_buff *skb;
695 704
696 card->tx_chain.tail = card->tx_chain.tail->next; 705 /* Measure the length of the queue. Measurement does not
697 descr->dmac_cmd_status |= SPIDER_NET_DESCR_NOT_IN_USE; 706 * need to be precise -- does not need a lock. */
707 while (descr != card->tx_chain.head) {
708 status = descr->dmac_cmd_status & SPIDER_NET_DESCR_NOT_IN_USE;
709 if (status == SPIDER_NET_DESCR_NOT_IN_USE)
710 break;
711 descr = descr->next;
712 cnt++;
713 }
698 714
699 /* unmap the skb */ 715 /* If TX queue is short, don't even bother with interrupts */
700 skb = descr->skb; 716 if (cnt < card->num_tx_desc/4)
701 pci_unmap_single(card->pdev, descr->buf_addr, skb->len, 717 return cnt;
702 PCI_DMA_TODEVICE); 718
703 dev_kfree_skb_any(skb); 719 /* Set low-watermark 3/4th's of the way into the queue. */
720 descr = card->tx_chain.tail;
721 cnt = (cnt*3)/4;
722 for (i=0;i<cnt; i++)
723 descr = descr->next;
724
725 /* Set the new watermark, clear the old watermark */
726 spin_lock_irqsave(&card->tx_chain.lock, flags);
727 descr->dmac_cmd_status |= SPIDER_NET_DESCR_TXDESFLG;
728 if (card->low_watermark && card->low_watermark != descr)
729 card->low_watermark->dmac_cmd_status =
730 card->low_watermark->dmac_cmd_status & ~SPIDER_NET_DESCR_TXDESFLG;
731 card->low_watermark = descr;
732 spin_unlock_irqrestore(&card->tx_chain.lock, flags);
733 return cnt;
704} 734}
705 735
706/** 736/**
@@ -719,21 +749,29 @@ static int
719spider_net_release_tx_chain(struct spider_net_card *card, int brutal) 749spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
720{ 750{
721 struct spider_net_descr_chain *chain = &card->tx_chain; 751 struct spider_net_descr_chain *chain = &card->tx_chain;
752 struct spider_net_descr *descr;
753 struct sk_buff *skb;
754 u32 buf_addr;
755 unsigned long flags;
722 int status; 756 int status;
723 757
724 spider_net_read_reg(card, SPIDER_NET_GDTDMACCNTR);
725
726 while (chain->tail != chain->head) { 758 while (chain->tail != chain->head) {
727 status = spider_net_get_descr_status(chain->tail); 759 spin_lock_irqsave(&chain->lock, flags);
760 descr = chain->tail;
761
762 status = spider_net_get_descr_status(descr);
728 switch (status) { 763 switch (status) {
729 case SPIDER_NET_DESCR_COMPLETE: 764 case SPIDER_NET_DESCR_COMPLETE:
730 card->netdev_stats.tx_packets++; 765 card->netdev_stats.tx_packets++;
731 card->netdev_stats.tx_bytes += chain->tail->skb->len; 766 card->netdev_stats.tx_bytes += descr->skb->len;
732 break; 767 break;
733 768
734 case SPIDER_NET_DESCR_CARDOWNED: 769 case SPIDER_NET_DESCR_CARDOWNED:
735 if (!brutal) 770 if (!brutal) {
771 spin_unlock_irqrestore(&chain->lock, flags);
736 return 1; 772 return 1;
773 }
774
737 /* fallthrough, if we release the descriptors 775 /* fallthrough, if we release the descriptors
738 * brutally (then we don't care about 776 * brutally (then we don't care about
739 * SPIDER_NET_DESCR_CARDOWNED) */ 777 * SPIDER_NET_DESCR_CARDOWNED) */
@@ -750,11 +788,25 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
750 788
751 default: 789 default:
752 card->netdev_stats.tx_dropped++; 790 card->netdev_stats.tx_dropped++;
753 return 1; 791 if (!brutal) {
792 spin_unlock_irqrestore(&chain->lock, flags);
793 return 1;
794 }
754 } 795 }
755 spider_net_release_tx_descr(card);
756 }
757 796
797 chain->tail = descr->next;
798 descr->dmac_cmd_status |= SPIDER_NET_DESCR_NOT_IN_USE;
799 skb = descr->skb;
800 buf_addr = descr->buf_addr;
801 spin_unlock_irqrestore(&chain->lock, flags);
802
803 /* unmap the skb */
804 if (skb) {
805 int len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len;
806 pci_unmap_single(card->pdev, buf_addr, len, PCI_DMA_TODEVICE);
807 dev_kfree_skb(skb);
808 }
809 }
758 return 0; 810 return 0;
759} 811}
760 812
@@ -763,8 +815,12 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
763 * @card: card structure 815 * @card: card structure
764 * @descr: descriptor address to enable TX processing at 816 * @descr: descriptor address to enable TX processing at
765 * 817 *
766 * spider_net_kick_tx_dma writes the current tx chain head as start address 818 * This routine will start the transmit DMA running if
767 * of the tx descriptor chain and enables the transmission DMA engine 819 * it is not already running. This routine ned only be
820 * called when queueing a new packet to an empty tx queue.
821 * Writes the current tx chain head as start address
822 * of the tx descriptor chain and enables the transmission
823 * DMA engine.
768 */ 824 */
769static inline void 825static inline void
770spider_net_kick_tx_dma(struct spider_net_card *card) 826spider_net_kick_tx_dma(struct spider_net_card *card)
@@ -804,65 +860,43 @@ out:
804static int 860static int
805spider_net_xmit(struct sk_buff *skb, struct net_device *netdev) 861spider_net_xmit(struct sk_buff *skb, struct net_device *netdev)
806{ 862{
863 int cnt;
807 struct spider_net_card *card = netdev_priv(netdev); 864 struct spider_net_card *card = netdev_priv(netdev);
808 struct spider_net_descr_chain *chain = &card->tx_chain; 865 struct spider_net_descr_chain *chain = &card->tx_chain;
809 struct spider_net_descr *descr = chain->head;
810 unsigned long flags;
811 int result;
812
813 spin_lock_irqsave(&chain->lock, flags);
814 866
815 spider_net_release_tx_chain(card, 0); 867 spider_net_release_tx_chain(card, 0);
816 868
817 if (chain->head->next == chain->tail->prev) { 869 if ((chain->head->next == chain->tail->prev) ||
818 card->netdev_stats.tx_dropped++; 870 (spider_net_prepare_tx_descr(card, skb) != 0)) {
819 result = NETDEV_TX_LOCKED;
820 goto out;
821 }
822 871
823 if (spider_net_get_descr_status(descr) != SPIDER_NET_DESCR_NOT_IN_USE) {
824 card->netdev_stats.tx_dropped++; 872 card->netdev_stats.tx_dropped++;
825 result = NETDEV_TX_LOCKED; 873 netif_stop_queue(netdev);
826 goto out; 874 return NETDEV_TX_BUSY;
827 } 875 }
828 876
829 if (spider_net_prepare_tx_descr(card, skb) != 0) { 877 cnt = spider_net_set_low_watermark(card);
830 card->netdev_stats.tx_dropped++; 878 if (cnt < 5)
831 result = NETDEV_TX_BUSY; 879 spider_net_kick_tx_dma(card);
832 goto out; 880 return NETDEV_TX_OK;
833 }
834
835 result = NETDEV_TX_OK;
836
837 spider_net_kick_tx_dma(card);
838 card->tx_chain.head = card->tx_chain.head->next;
839
840out:
841 spin_unlock_irqrestore(&chain->lock, flags);
842 netif_wake_queue(netdev);
843 return result;
844} 881}
845 882
846/** 883/**
847 * spider_net_cleanup_tx_ring - cleans up the TX ring 884 * spider_net_cleanup_tx_ring - cleans up the TX ring
848 * @card: card structure 885 * @card: card structure
849 * 886 *
850 * spider_net_cleanup_tx_ring is called by the tx_timer (as we don't use 887 * spider_net_cleanup_tx_ring is called by either the tx_timer
851 * interrupts to cleanup our TX ring) and returns sent packets to the stack 888 * or from the NAPI polling routine.
852 * by freeing them 889 * This routine releases resources associted with transmitted
890 * packets, including updating the queue tail pointer.
853 */ 891 */
854static void 892static void
855spider_net_cleanup_tx_ring(struct spider_net_card *card) 893spider_net_cleanup_tx_ring(struct spider_net_card *card)
856{ 894{
857 unsigned long flags;
858
859 spin_lock_irqsave(&card->tx_chain.lock, flags);
860
861 if ((spider_net_release_tx_chain(card, 0) != 0) && 895 if ((spider_net_release_tx_chain(card, 0) != 0) &&
862 (card->netdev->flags & IFF_UP)) 896 (card->netdev->flags & IFF_UP)) {
863 spider_net_kick_tx_dma(card); 897 spider_net_kick_tx_dma(card);
864 898 netif_wake_queue(card->netdev);
865 spin_unlock_irqrestore(&card->tx_chain.lock, flags); 899 }
866} 900}
867 901
868/** 902/**
@@ -1053,6 +1087,7 @@ spider_net_poll(struct net_device *netdev, int *budget)
1053 int packets_to_do, packets_done = 0; 1087 int packets_to_do, packets_done = 0;
1054 int no_more_packets = 0; 1088 int no_more_packets = 0;
1055 1089
1090 spider_net_cleanup_tx_ring(card);
1056 packets_to_do = min(*budget, netdev->quota); 1091 packets_to_do = min(*budget, netdev->quota);
1057 1092
1058 while (packets_to_do) { 1093 while (packets_to_do) {
@@ -1243,12 +1278,15 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg)
1243 case SPIDER_NET_PHYINT: 1278 case SPIDER_NET_PHYINT:
1244 case SPIDER_NET_GMAC2INT: 1279 case SPIDER_NET_GMAC2INT:
1245 case SPIDER_NET_GMAC1INT: 1280 case SPIDER_NET_GMAC1INT:
1246 case SPIDER_NET_GIPSINT:
1247 case SPIDER_NET_GFIFOINT: 1281 case SPIDER_NET_GFIFOINT:
1248 case SPIDER_NET_DMACINT: 1282 case SPIDER_NET_DMACINT:
1249 case SPIDER_NET_GSYSINT: 1283 case SPIDER_NET_GSYSINT:
1250 break; */ 1284 break; */
1251 1285
1286 case SPIDER_NET_GIPSINT:
1287 show_error = 0;
1288 break;
1289
1252 case SPIDER_NET_GPWOPCMPINT: 1290 case SPIDER_NET_GPWOPCMPINT:
1253 /* PHY write operation completed */ 1291 /* PHY write operation completed */
1254 show_error = 0; 1292 show_error = 0;
@@ -1307,9 +1345,10 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg)
1307 case SPIDER_NET_GDTDCEINT: 1345 case SPIDER_NET_GDTDCEINT:
1308 /* chain end. If a descriptor should be sent, kick off 1346 /* chain end. If a descriptor should be sent, kick off
1309 * tx dma 1347 * tx dma
1310 if (card->tx_chain.tail == card->tx_chain.head) 1348 if (card->tx_chain.tail != card->tx_chain.head)
1311 spider_net_kick_tx_dma(card); 1349 spider_net_kick_tx_dma(card);
1312 show_error = 0; */ 1350 */
1351 show_error = 0;
1313 break; 1352 break;
1314 1353
1315 /* case SPIDER_NET_G1TMCNTINT: not used. print a message */ 1354 /* case SPIDER_NET_G1TMCNTINT: not used. print a message */
@@ -1354,7 +1393,7 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg)
1354 if (netif_msg_intr(card)) 1393 if (netif_msg_intr(card))
1355 pr_err("got descriptor chain end interrupt, " 1394 pr_err("got descriptor chain end interrupt, "
1356 "restarting DMAC %c.\n", 1395 "restarting DMAC %c.\n",
1357 'D'+i-SPIDER_NET_GDDDCEINT); 1396 'D'-(i-SPIDER_NET_GDDDCEINT)/3);
1358 spider_net_refill_rx_chain(card); 1397 spider_net_refill_rx_chain(card);
1359 spider_net_enable_rxdmac(card); 1398 spider_net_enable_rxdmac(card);
1360 show_error = 0; 1399 show_error = 0;
@@ -1423,8 +1462,9 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg)
1423 } 1462 }
1424 1463
1425 if ((show_error) && (netif_msg_intr(card))) 1464 if ((show_error) && (netif_msg_intr(card)))
1426 pr_err("Got error interrupt, GHIINT0STS = 0x%08x, " 1465 pr_err("Got error interrupt on %s, GHIINT0STS = 0x%08x, "
1427 "GHIINT1STS = 0x%08x, GHIINT2STS = 0x%08x\n", 1466 "GHIINT1STS = 0x%08x, GHIINT2STS = 0x%08x\n",
1467 card->netdev->name,
1428 status_reg, error_reg1, error_reg2); 1468 status_reg, error_reg1, error_reg2);
1429 1469
1430 /* clear interrupt sources */ 1470 /* clear interrupt sources */
@@ -1460,6 +1500,8 @@ spider_net_interrupt(int irq, void *ptr)
1460 spider_net_rx_irq_off(card); 1500 spider_net_rx_irq_off(card);
1461 netif_rx_schedule(netdev); 1501 netif_rx_schedule(netdev);
1462 } 1502 }
1503 if (status_reg & SPIDER_NET_TXINT)
1504 netif_rx_schedule(netdev);
1463 1505
1464 if (status_reg & SPIDER_NET_ERRINT ) 1506 if (status_reg & SPIDER_NET_ERRINT )
1465 spider_net_handle_error_irq(card, status_reg); 1507 spider_net_handle_error_irq(card, status_reg);
@@ -1599,7 +1641,7 @@ spider_net_enable_card(struct spider_net_card *card)
1599 SPIDER_NET_INT2_MASK_VALUE); 1641 SPIDER_NET_INT2_MASK_VALUE);
1600 1642
1601 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, 1643 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR,
1602 SPIDER_NET_GDTDCEIDIS); 1644 SPIDER_NET_GDTBSTA | SPIDER_NET_GDTDCEIDIS);
1603} 1645}
1604 1646
1605/** 1647/**
@@ -1615,17 +1657,26 @@ int
1615spider_net_open(struct net_device *netdev) 1657spider_net_open(struct net_device *netdev)
1616{ 1658{
1617 struct spider_net_card *card = netdev_priv(netdev); 1659 struct spider_net_card *card = netdev_priv(netdev);
1618 int result; 1660 struct spider_net_descr *descr;
1661 int i, result;
1619 1662
1620 result = -ENOMEM; 1663 result = -ENOMEM;
1621 if (spider_net_init_chain(card, &card->tx_chain, card->descr, 1664 if (spider_net_init_chain(card, &card->tx_chain, card->descr,
1622 PCI_DMA_TODEVICE, card->tx_desc)) 1665 card->num_tx_desc))
1623 goto alloc_tx_failed; 1666 goto alloc_tx_failed;
1667
1668 card->low_watermark = NULL;
1669
1670 /* rx_chain is after tx_chain, so offset is descr + tx_count */
1624 if (spider_net_init_chain(card, &card->rx_chain, 1671 if (spider_net_init_chain(card, &card->rx_chain,
1625 card->descr + card->rx_desc, 1672 card->descr + card->num_tx_desc,
1626 PCI_DMA_FROMDEVICE, card->rx_desc)) 1673 card->num_rx_desc))
1627 goto alloc_rx_failed; 1674 goto alloc_rx_failed;
1628 1675
1676 descr = card->rx_chain.head;
1677 for (i=0; i < card->num_rx_desc; i++, descr++)
1678 descr->next_descr_addr = descr->next->bus_addr;
1679
1629 /* allocate rx skbs */ 1680 /* allocate rx skbs */
1630 if (spider_net_alloc_rx_skbs(card)) 1681 if (spider_net_alloc_rx_skbs(card))
1631 goto alloc_skbs_failed; 1682 goto alloc_skbs_failed;
@@ -1878,10 +1929,7 @@ spider_net_stop(struct net_device *netdev)
1878 spider_net_disable_rxdmac(card); 1929 spider_net_disable_rxdmac(card);
1879 1930
1880 /* release chains */ 1931 /* release chains */
1881 if (spin_trylock(&card->tx_chain.lock)) { 1932 spider_net_release_tx_chain(card, 1);
1882 spider_net_release_tx_chain(card, 1);
1883 spin_unlock(&card->tx_chain.lock);
1884 }
1885 1933
1886 spider_net_free_chain(card, &card->tx_chain); 1934 spider_net_free_chain(card, &card->tx_chain);
1887 spider_net_free_chain(card, &card->rx_chain); 1935 spider_net_free_chain(card, &card->rx_chain);
@@ -2012,8 +2060,8 @@ spider_net_setup_netdev(struct spider_net_card *card)
2012 2060
2013 card->options.rx_csum = SPIDER_NET_RX_CSUM_DEFAULT; 2061 card->options.rx_csum = SPIDER_NET_RX_CSUM_DEFAULT;
2014 2062
2015 card->tx_desc = tx_descriptors; 2063 card->num_tx_desc = tx_descriptors;
2016 card->rx_desc = rx_descriptors; 2064 card->num_rx_desc = rx_descriptors;
2017 2065
2018 spider_net_setup_netdev_ops(netdev); 2066 spider_net_setup_netdev_ops(netdev);
2019 2067
@@ -2252,6 +2300,8 @@ static struct pci_driver spider_net_driver = {
2252 */ 2300 */
2253static int __init spider_net_init(void) 2301static int __init spider_net_init(void)
2254{ 2302{
2303 printk(KERN_INFO "Spidernet version %s.\n", VERSION);
2304
2255 if (rx_descriptors < SPIDER_NET_RX_DESCRIPTORS_MIN) { 2305 if (rx_descriptors < SPIDER_NET_RX_DESCRIPTORS_MIN) {
2256 rx_descriptors = SPIDER_NET_RX_DESCRIPTORS_MIN; 2306 rx_descriptors = SPIDER_NET_RX_DESCRIPTORS_MIN;
2257 pr_info("adjusting rx descriptors to %i.\n", rx_descriptors); 2307 pr_info("adjusting rx descriptors to %i.\n", rx_descriptors);
diff --git a/drivers/net/spider_net.h b/drivers/net/spider_net.h
index a59deda2f95e..b3b46119b424 100644
--- a/drivers/net/spider_net.h
+++ b/drivers/net/spider_net.h
@@ -24,6 +24,8 @@
24#ifndef _SPIDER_NET_H 24#ifndef _SPIDER_NET_H
25#define _SPIDER_NET_H 25#define _SPIDER_NET_H
26 26
27#define VERSION "1.1 A"
28
27#include "sungem_phy.h" 29#include "sungem_phy.h"
28 30
29extern int spider_net_stop(struct net_device *netdev); 31extern int spider_net_stop(struct net_device *netdev);
@@ -47,7 +49,7 @@ extern char spider_net_driver_name[];
47#define SPIDER_NET_TX_DESCRIPTORS_MIN 16 49#define SPIDER_NET_TX_DESCRIPTORS_MIN 16
48#define SPIDER_NET_TX_DESCRIPTORS_MAX 512 50#define SPIDER_NET_TX_DESCRIPTORS_MAX 512
49 51
50#define SPIDER_NET_TX_TIMER 20 52#define SPIDER_NET_TX_TIMER (HZ/5)
51 53
52#define SPIDER_NET_RX_CSUM_DEFAULT 1 54#define SPIDER_NET_RX_CSUM_DEFAULT 1
53 55
@@ -189,7 +191,9 @@ extern char spider_net_driver_name[];
189#define SPIDER_NET_MACMODE_VALUE 0x00000001 191#define SPIDER_NET_MACMODE_VALUE 0x00000001
190#define SPIDER_NET_BURSTLMT_VALUE 0x00000200 /* about 16 us */ 192#define SPIDER_NET_BURSTLMT_VALUE 0x00000200 /* about 16 us */
191 193
192/* 1(0) enable r/tx dma 194/* DMAC control register GDMACCNTR
195 *
196 * 1(0) enable r/tx dma
193 * 0000000 fixed to 0 197 * 0000000 fixed to 0
194 * 198 *
195 * 000000 fixed to 0 199 * 000000 fixed to 0
@@ -198,6 +202,7 @@ extern char spider_net_driver_name[];
198 * 202 *
199 * 000000 fixed to 0 203 * 000000 fixed to 0
200 * 00 burst alignment: 128 bytes 204 * 00 burst alignment: 128 bytes
205 * 11 burst alignment: 1024 bytes
201 * 206 *
202 * 00000 fixed to 0 207 * 00000 fixed to 0
203 * 0 descr writeback size 32 bytes 208 * 0 descr writeback size 32 bytes
@@ -208,10 +213,13 @@ extern char spider_net_driver_name[];
208#define SPIDER_NET_DMA_RX_VALUE 0x80000000 213#define SPIDER_NET_DMA_RX_VALUE 0x80000000
209#define SPIDER_NET_DMA_RX_FEND_VALUE 0x00030003 214#define SPIDER_NET_DMA_RX_FEND_VALUE 0x00030003
210/* to set TX_DMA_EN */ 215/* to set TX_DMA_EN */
211#define SPIDER_NET_TX_DMA_EN 0x80000000 216#define SPIDER_NET_TX_DMA_EN 0x80000000
212#define SPIDER_NET_GDTDCEIDIS 0x00000002 217#define SPIDER_NET_GDTBSTA 0x00000300
213#define SPIDER_NET_DMA_TX_VALUE SPIDER_NET_TX_DMA_EN | \ 218#define SPIDER_NET_GDTDCEIDIS 0x00000002
214 SPIDER_NET_GDTDCEIDIS 219#define SPIDER_NET_DMA_TX_VALUE SPIDER_NET_TX_DMA_EN | \
220 SPIDER_NET_GDTBSTA | \
221 SPIDER_NET_GDTDCEIDIS
222
215#define SPIDER_NET_DMA_TX_FEND_VALUE 0x00030003 223#define SPIDER_NET_DMA_TX_FEND_VALUE 0x00030003
216 224
217/* SPIDER_NET_UA_DESCR_VALUE is OR'ed with the unicast address */ 225/* SPIDER_NET_UA_DESCR_VALUE is OR'ed with the unicast address */
@@ -320,13 +328,10 @@ enum spider_net_int2_status {
320 SPIDER_NET_GRISPDNGINT 328 SPIDER_NET_GRISPDNGINT
321}; 329};
322 330
323#define SPIDER_NET_TXINT ( (1 << SPIDER_NET_GTTEDINT) | \ 331#define SPIDER_NET_TXINT ( (1 << SPIDER_NET_GDTFDCINT) )
324 (1 << SPIDER_NET_GDTDCEINT) | \
325 (1 << SPIDER_NET_GDTFDCINT) )
326 332
327/* we rely on flagged descriptor interrupts*/ 333/* We rely on flagged descriptor interrupts */
328#define SPIDER_NET_RXINT ( (1 << SPIDER_NET_GDAFDCINT) | \ 334#define SPIDER_NET_RXINT ( (1 << SPIDER_NET_GDAFDCINT) )
329 (1 << SPIDER_NET_GRMFLLINT) )
330 335
331#define SPIDER_NET_ERRINT ( 0xffffffff & \ 336#define SPIDER_NET_ERRINT ( 0xffffffff & \
332 (~SPIDER_NET_TXINT) & \ 337 (~SPIDER_NET_TXINT) & \
@@ -349,6 +354,7 @@ enum spider_net_int2_status {
349#define SPIDER_NET_DESCR_FORCE_END 0x50000000 /* used in rx and tx */ 354#define SPIDER_NET_DESCR_FORCE_END 0x50000000 /* used in rx and tx */
350#define SPIDER_NET_DESCR_CARDOWNED 0xA0000000 /* used in rx and tx */ 355#define SPIDER_NET_DESCR_CARDOWNED 0xA0000000 /* used in rx and tx */
351#define SPIDER_NET_DESCR_NOT_IN_USE 0xF0000000 356#define SPIDER_NET_DESCR_NOT_IN_USE 0xF0000000
357#define SPIDER_NET_DESCR_TXDESFLG 0x00800000
352 358
353struct spider_net_descr { 359struct spider_net_descr {
354 /* as defined by the hardware */ 360 /* as defined by the hardware */
@@ -433,6 +439,7 @@ struct spider_net_card {
433 439
434 struct spider_net_descr_chain tx_chain; 440 struct spider_net_descr_chain tx_chain;
435 struct spider_net_descr_chain rx_chain; 441 struct spider_net_descr_chain rx_chain;
442 struct spider_net_descr *low_watermark;
436 443
437 struct net_device_stats netdev_stats; 444 struct net_device_stats netdev_stats;
438 445
@@ -448,8 +455,8 @@ struct spider_net_card {
448 455
449 /* for ethtool */ 456 /* for ethtool */
450 int msg_enable; 457 int msg_enable;
451 int rx_desc; 458 int num_rx_desc;
452 int tx_desc; 459 int num_tx_desc;
453 struct spider_net_extra_stats spider_stats; 460 struct spider_net_extra_stats spider_stats;
454 461
455 struct spider_net_descr descr[0]; 462 struct spider_net_descr descr[0];
diff --git a/drivers/net/spider_net_ethtool.c b/drivers/net/spider_net_ethtool.c
index 589e43658dee..91b995102915 100644
--- a/drivers/net/spider_net_ethtool.c
+++ b/drivers/net/spider_net_ethtool.c
@@ -76,7 +76,7 @@ spider_net_ethtool_get_drvinfo(struct net_device *netdev,
76 /* clear and fill out info */ 76 /* clear and fill out info */
77 memset(drvinfo, 0, sizeof(struct ethtool_drvinfo)); 77 memset(drvinfo, 0, sizeof(struct ethtool_drvinfo));
78 strncpy(drvinfo->driver, spider_net_driver_name, 32); 78 strncpy(drvinfo->driver, spider_net_driver_name, 32);
79 strncpy(drvinfo->version, "0.1", 32); 79 strncpy(drvinfo->version, VERSION, 32);
80 strcpy(drvinfo->fw_version, "no information"); 80 strcpy(drvinfo->fw_version, "no information");
81 strncpy(drvinfo->bus_info, pci_name(card->pdev), 32); 81 strncpy(drvinfo->bus_info, pci_name(card->pdev), 32);
82} 82}
@@ -158,9 +158,9 @@ spider_net_ethtool_get_ringparam(struct net_device *netdev,
158 struct spider_net_card *card = netdev->priv; 158 struct spider_net_card *card = netdev->priv;
159 159
160 ering->tx_max_pending = SPIDER_NET_TX_DESCRIPTORS_MAX; 160 ering->tx_max_pending = SPIDER_NET_TX_DESCRIPTORS_MAX;
161 ering->tx_pending = card->tx_desc; 161 ering->tx_pending = card->num_tx_desc;
162 ering->rx_max_pending = SPIDER_NET_RX_DESCRIPTORS_MAX; 162 ering->rx_max_pending = SPIDER_NET_RX_DESCRIPTORS_MAX;
163 ering->rx_pending = card->rx_desc; 163 ering->rx_pending = card->num_rx_desc;
164} 164}
165 165
166static int spider_net_get_stats_count(struct net_device *netdev) 166static int spider_net_get_stats_count(struct net_device *netdev)
diff --git a/drivers/net/sun3_82586.c b/drivers/net/sun3_82586.c
index d1d1885b0295..a3220a96524f 100644
--- a/drivers/net/sun3_82586.c
+++ b/drivers/net/sun3_82586.c
@@ -330,7 +330,7 @@ out2:
330out1: 330out1:
331 free_netdev(dev); 331 free_netdev(dev);
332out: 332out:
333 iounmap((void *)ioaddr); 333 iounmap((void __iomem *)ioaddr);
334 return ERR_PTR(err); 334 return ERR_PTR(err);
335} 335}
336 336
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
index 91c76544e4dd..b865db363ba0 100644
--- a/drivers/net/sun3lance.c
+++ b/drivers/net/sun3lance.c
@@ -286,7 +286,7 @@ struct net_device * __init sun3lance_probe(int unit)
286 286
287out1: 287out1:
288#ifdef CONFIG_SUN3 288#ifdef CONFIG_SUN3
289 iounmap((void *)dev->base_addr); 289 iounmap((void __iomem *)dev->base_addr);
290#endif 290#endif
291out: 291out:
292 free_netdev(dev); 292 free_netdev(dev);
@@ -326,7 +326,7 @@ static int __init lance_probe( struct net_device *dev)
326 ioaddr_probe[1] = tmp2; 326 ioaddr_probe[1] = tmp2;
327 327
328#ifdef CONFIG_SUN3 328#ifdef CONFIG_SUN3
329 iounmap((void *)ioaddr); 329 iounmap((void __iomem *)ioaddr);
330#endif 330#endif
331 return 0; 331 return 0;
332 } 332 }
@@ -956,7 +956,7 @@ void cleanup_module(void)
956{ 956{
957 unregister_netdev(sun3lance_dev); 957 unregister_netdev(sun3lance_dev);
958#ifdef CONFIG_SUN3 958#ifdef CONFIG_SUN3
959 iounmap((void *)sun3lance_dev->base_addr); 959 iounmap((void __iomem *)sun3lance_dev->base_addr);
960#endif 960#endif
961 free_netdev(sun3lance_dev); 961 free_netdev(sun3lance_dev);
962} 962}
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 2cfd9634895a..f6b3a94e97bf 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -1730,7 +1730,7 @@ static void __init de21040_get_media_info(struct de_private *de)
1730} 1730}
1731 1731
1732/* Note: this routine returns extra data bits for size detection. */ 1732/* Note: this routine returns extra data bits for size detection. */
1733static unsigned __init tulip_read_eeprom(void __iomem *regs, int location, int addr_len) 1733static unsigned __devinit tulip_read_eeprom(void __iomem *regs, int location, int addr_len)
1734{ 1734{
1735 int i; 1735 int i;
1736 unsigned retval = 0; 1736 unsigned retval = 0;
@@ -1926,7 +1926,7 @@ bad_srom:
1926 goto fill_defaults; 1926 goto fill_defaults;
1927} 1927}
1928 1928
1929static int __init de_init_one (struct pci_dev *pdev, 1929static int __devinit de_init_one (struct pci_dev *pdev,
1930 const struct pci_device_id *ent) 1930 const struct pci_device_id *ent)
1931{ 1931{
1932 struct net_device *dev; 1932 struct net_device *dev;
@@ -2082,7 +2082,7 @@ err_out_free:
2082 return rc; 2082 return rc;
2083} 2083}
2084 2084
2085static void __exit de_remove_one (struct pci_dev *pdev) 2085static void __devexit de_remove_one (struct pci_dev *pdev)
2086{ 2086{
2087 struct net_device *dev = pci_get_drvdata(pdev); 2087 struct net_device *dev = pci_get_drvdata(pdev);
2088 struct de_private *de = dev->priv; 2088 struct de_private *de = dev->priv;
@@ -2164,7 +2164,7 @@ static struct pci_driver de_driver = {
2164 .name = DRV_NAME, 2164 .name = DRV_NAME,
2165 .id_table = de_pci_tbl, 2165 .id_table = de_pci_tbl,
2166 .probe = de_init_one, 2166 .probe = de_init_one,
2167 .remove = __exit_p(de_remove_one), 2167 .remove = __devexit_p(de_remove_one),
2168#ifdef CONFIG_PM 2168#ifdef CONFIG_PM
2169 .suspend = de_suspend, 2169 .suspend = de_suspend,
2170 .resume = de_resume, 2170 .resume = de_resume,
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 30294127a0aa..ecc50db8585a 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -55,7 +55,7 @@ config PCI_DEBUG
55config HT_IRQ 55config HT_IRQ
56 bool "Interrupts on hypertransport devices" 56 bool "Interrupts on hypertransport devices"
57 default y 57 default y
58 depends on X86_LOCAL_APIC && X86_IO_APIC 58 depends on PCI && X86_LOCAL_APIC && X86_IO_APIC
59 help 59 help
60 This allows native hypertransport devices to use interrupts. 60 This allows native hypertransport devices to use interrupts.
61 61
diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c
index 0b20dfacbf59..d94170728075 100644
--- a/drivers/rtc/rtc-max6902.c
+++ b/drivers/rtc/rtc-max6902.c
@@ -136,7 +136,7 @@ static int max6902_get_datetime(struct device *dev, struct rtc_time *dt)
136 dt->tm_min = BCD2BIN(chip->buf[2]); 136 dt->tm_min = BCD2BIN(chip->buf[2]);
137 dt->tm_hour = BCD2BIN(chip->buf[3]); 137 dt->tm_hour = BCD2BIN(chip->buf[3]);
138 dt->tm_mday = BCD2BIN(chip->buf[4]); 138 dt->tm_mday = BCD2BIN(chip->buf[4]);
139 dt->tm_mon = BCD2BIN(chip->buf[5] - 1); 139 dt->tm_mon = BCD2BIN(chip->buf[5]) - 1;
140 dt->tm_wday = BCD2BIN(chip->buf[6]); 140 dt->tm_wday = BCD2BIN(chip->buf[6]);
141 dt->tm_year = BCD2BIN(chip->buf[7]); 141 dt->tm_year = BCD2BIN(chip->buf[7]);
142 142
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 8b6efcc05058..143302a8e79c 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -160,7 +160,7 @@ static int sh_rtc_open(struct device *dev)
160 tmp |= RCR1_CIE; 160 tmp |= RCR1_CIE;
161 writeb(tmp, rtc->regbase + RCR1); 161 writeb(tmp, rtc->regbase + RCR1);
162 162
163 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, SA_INTERRUPT, 163 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, IRQF_DISABLED,
164 "sh-rtc period", dev); 164 "sh-rtc period", dev);
165 if (unlikely(ret)) { 165 if (unlikely(ret)) {
166 dev_err(dev, "request period IRQ failed with %d, IRQ %d\n", 166 dev_err(dev, "request period IRQ failed with %d, IRQ %d\n",
@@ -168,7 +168,7 @@ static int sh_rtc_open(struct device *dev)
168 return ret; 168 return ret;
169 } 169 }
170 170
171 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, SA_INTERRUPT, 171 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, IRQF_DISABLED,
172 "sh-rtc carry", dev); 172 "sh-rtc carry", dev);
173 if (unlikely(ret)) { 173 if (unlikely(ret)) {
174 dev_err(dev, "request carry IRQ failed with %d, IRQ %d\n", 174 dev_err(dev, "request carry IRQ failed with %d, IRQ %d\n",
@@ -177,7 +177,7 @@ static int sh_rtc_open(struct device *dev)
177 goto err_bad_carry; 177 goto err_bad_carry;
178 } 178 }
179 179
180 ret = request_irq(rtc->alarm_irq, sh_rtc_interrupt, SA_INTERRUPT, 180 ret = request_irq(rtc->alarm_irq, sh_rtc_interrupt, IRQF_DISABLED,
181 "sh-rtc alarm", dev); 181 "sh-rtc alarm", dev);
182 if (unlikely(ret)) { 182 if (unlikely(ret)) {
183 dev_err(dev, "request alarm IRQ failed with %d, IRQ %d\n", 183 dev_err(dev, "request alarm IRQ failed with %d, IRQ %d\n",
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c
index 09b714f1cdc3..3b58d3d5d38a 100644
--- a/drivers/rtc/rtc-v3020.c
+++ b/drivers/rtc/rtc-v3020.c
@@ -195,9 +195,9 @@ static int rtc_probe(struct platform_device *pdev)
195 * are all disabled */ 195 * are all disabled */
196 v3020_set_reg(chip, V3020_STATUS_0, 0x0); 196 v3020_set_reg(chip, V3020_STATUS_0, 0x0);
197 197
198 dev_info(&pdev->dev, "Chip available at physical address 0x%p," 198 dev_info(&pdev->dev, "Chip available at physical address 0x%llx,"
199 "data connected to D%d\n", 199 "data connected to D%d\n",
200 (void*)pdev->resource[0].start, 200 (unsigned long long)pdev->resource[0].start,
201 chip->leftshift); 201 chip->leftshift);
202 202
203 platform_set_drvdata(pdev, chip); 203 platform_set_drvdata(pdev, chip);
diff --git a/drivers/s390/char/monwriter.c b/drivers/s390/char/monwriter.c
index 4362ff260244..abd02ed501cb 100644
--- a/drivers/s390/char/monwriter.c
+++ b/drivers/s390/char/monwriter.c
@@ -110,7 +110,7 @@ static int monwrite_new_hdr(struct mon_private *monpriv)
110 monbuf = kzalloc(sizeof(struct mon_buf), GFP_KERNEL); 110 monbuf = kzalloc(sizeof(struct mon_buf), GFP_KERNEL);
111 if (!monbuf) 111 if (!monbuf)
112 return -ENOMEM; 112 return -ENOMEM;
113 monbuf->data = kzalloc(monbuf->hdr.datalen, 113 monbuf->data = kzalloc(monhdr->datalen,
114 GFP_KERNEL | GFP_DMA); 114 GFP_KERNEL | GFP_DMA);
115 if (!monbuf->data) { 115 if (!monbuf->data) {
116 kfree(monbuf); 116 kfree(monbuf);
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index 07c7f19339d2..2d78f0f4a40f 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -370,7 +370,7 @@ __s390_process_res_acc(struct subchannel_id schid, void *data)
370 struct res_acc_data *res_data; 370 struct res_acc_data *res_data;
371 struct subchannel *sch; 371 struct subchannel *sch;
372 372
373 res_data = (struct res_acc_data *)data; 373 res_data = data;
374 sch = get_subchannel_by_schid(schid); 374 sch = get_subchannel_by_schid(schid);
375 if (!sch) 375 if (!sch)
376 /* Check if a subchannel is newly available. */ 376 /* Check if a subchannel is newly available. */
@@ -444,7 +444,7 @@ __get_chpid_from_lir(void *data)
444 u32 isinfo[28]; 444 u32 isinfo[28];
445 } *lir; 445 } *lir;
446 446
447 lir = (struct lir*) data; 447 lir = data;
448 if (!(lir->iq&0x80)) 448 if (!(lir->iq&0x80))
449 /* NULL link incident record */ 449 /* NULL link incident record */
450 return -EINVAL; 450 return -EINVAL;
@@ -628,7 +628,7 @@ __chp_add(struct subchannel_id schid, void *data)
628 struct channel_path *chp; 628 struct channel_path *chp;
629 struct subchannel *sch; 629 struct subchannel *sch;
630 630
631 chp = (struct channel_path *)data; 631 chp = data;
632 sch = get_subchannel_by_schid(schid); 632 sch = get_subchannel_by_schid(schid);
633 if (!sch) 633 if (!sch)
634 /* Check if the subchannel is now available. */ 634 /* Check if the subchannel is now available. */
@@ -707,8 +707,7 @@ chp_process_crw(int chpid, int on)
707 return chp_add(chpid); 707 return chp_add(chpid);
708} 708}
709 709
710static inline int 710static inline int check_for_io_on_path(struct subchannel *sch, int index)
711__check_for_io_and_kill(struct subchannel *sch, int index)
712{ 711{
713 int cc; 712 int cc;
714 713
@@ -718,10 +717,8 @@ __check_for_io_and_kill(struct subchannel *sch, int index)
718 cc = stsch(sch->schid, &sch->schib); 717 cc = stsch(sch->schid, &sch->schib);
719 if (cc) 718 if (cc)
720 return 0; 719 return 0;
721 if (sch->schib.scsw.actl && sch->schib.pmcw.lpum == (0x80 >> index)) { 720 if (sch->schib.scsw.actl && sch->schib.pmcw.lpum == (0x80 >> index))
722 device_set_waiting(sch);
723 return 1; 721 return 1;
724 }
725 return 0; 722 return 0;
726} 723}
727 724
@@ -750,12 +747,10 @@ __s390_subchannel_vary_chpid(struct subchannel *sch, __u8 chpid, int on)
750 } else { 747 } else {
751 sch->opm &= ~(0x80 >> chp); 748 sch->opm &= ~(0x80 >> chp);
752 sch->lpm &= ~(0x80 >> chp); 749 sch->lpm &= ~(0x80 >> chp);
753 /* 750 if (check_for_io_on_path(sch, chp))
754 * Give running I/O a grace period in which it 751 /* Path verification is done after killing. */
755 * can successfully terminate, even using the 752 device_kill_io(sch);
756 * just varied off path. Then kill it. 753 else if (!sch->lpm) {
757 */
758 if (!__check_for_io_and_kill(sch, chp) && !sch->lpm) {
759 if (css_enqueue_subchannel_slow(sch->schid)) { 754 if (css_enqueue_subchannel_slow(sch->schid)) {
760 css_clear_subchannel_slow_list(); 755 css_clear_subchannel_slow_list();
761 need_rescan = 1; 756 need_rescan = 1;
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index f18b1623cad7..8936e460a807 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -609,8 +609,8 @@ do_IRQ (struct pt_regs *regs)
609 struct irb *irb; 609 struct irb *irb;
610 struct pt_regs *old_regs; 610 struct pt_regs *old_regs;
611 611
612 irq_enter ();
613 old_regs = set_irq_regs(regs); 612 old_regs = set_irq_regs(regs);
613 irq_enter();
614 asm volatile ("mc 0,0"); 614 asm volatile ("mc 0,0");
615 if (S390_lowcore.int_clock >= S390_lowcore.jiffy_timer) 615 if (S390_lowcore.int_clock >= S390_lowcore.jiffy_timer)
616 /** 616 /**
@@ -655,8 +655,8 @@ do_IRQ (struct pt_regs *regs)
655 * out of the sie which costs more cycles than it saves. 655 * out of the sie which costs more cycles than it saves.
656 */ 656 */
657 } while (!MACHINE_IS_VM && tpi (NULL) != 0); 657 } while (!MACHINE_IS_VM && tpi (NULL) != 0);
658 irq_exit();
658 set_irq_regs(old_regs); 659 set_irq_regs(old_regs);
659 irq_exit ();
660} 660}
661 661
662#ifdef CONFIG_CCW_CONSOLE 662#ifdef CONFIG_CCW_CONSOLE
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 7086a74e9871..a2dee5bf5a17 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -177,7 +177,7 @@ get_subchannel_by_schid(struct subchannel_id schid)
177 struct device *dev; 177 struct device *dev;
178 178
179 dev = bus_find_device(&css_bus_type, NULL, 179 dev = bus_find_device(&css_bus_type, NULL,
180 (void *)&schid, check_subchannel); 180 &schid, check_subchannel);
181 181
182 return dev ? to_subchannel(dev) : NULL; 182 return dev ? to_subchannel(dev) : NULL;
183} 183}
diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h
index 8aabb4adeb5f..4c2ff8336288 100644
--- a/drivers/s390/cio/css.h
+++ b/drivers/s390/cio/css.h
@@ -76,9 +76,8 @@ struct ccw_device_private {
76 int state; /* device state */ 76 int state; /* device state */
77 atomic_t onoff; 77 atomic_t onoff;
78 unsigned long registered; 78 unsigned long registered;
79 __u16 devno; /* device number */ 79 struct ccw_dev_id dev_id; /* device id */
80 __u16 sch_no; /* subchannel number */ 80 struct subchannel_id schid; /* subchannel number */
81 __u8 ssid; /* subchannel set id */
82 __u8 imask; /* lpm mask for SNID/SID/SPGID */ 81 __u8 imask; /* lpm mask for SNID/SID/SPGID */
83 int iretry; /* retry counter SNID/SID/SPGID */ 82 int iretry; /* retry counter SNID/SID/SPGID */
84 struct { 83 struct {
@@ -171,7 +170,7 @@ void device_trigger_reprobe(struct subchannel *);
171 170
172/* Helper functions for vary on/off. */ 171/* Helper functions for vary on/off. */
173int device_is_online(struct subchannel *); 172int device_is_online(struct subchannel *);
174void device_set_waiting(struct subchannel *); 173void device_kill_io(struct subchannel *);
175 174
176/* Machine check helper function. */ 175/* Machine check helper function. */
177void device_kill_pending_timer(struct subchannel *); 176void device_kill_pending_timer(struct subchannel *);
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 688945662c15..94bdd4d8a4c9 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -552,21 +552,19 @@ ccw_device_register(struct ccw_device *cdev)
552} 552}
553 553
554struct match_data { 554struct match_data {
555 unsigned int devno; 555 struct ccw_dev_id dev_id;
556 unsigned int ssid;
557 struct ccw_device * sibling; 556 struct ccw_device * sibling;
558}; 557};
559 558
560static int 559static int
561match_devno(struct device * dev, void * data) 560match_devno(struct device * dev, void * data)
562{ 561{
563 struct match_data * d = (struct match_data *)data; 562 struct match_data * d = data;
564 struct ccw_device * cdev; 563 struct ccw_device * cdev;
565 564
566 cdev = to_ccwdev(dev); 565 cdev = to_ccwdev(dev);
567 if ((cdev->private->state == DEV_STATE_DISCONNECTED) && 566 if ((cdev->private->state == DEV_STATE_DISCONNECTED) &&
568 (cdev->private->devno == d->devno) && 567 ccw_dev_id_is_equal(&cdev->private->dev_id, &d->dev_id) &&
569 (cdev->private->ssid == d->ssid) &&
570 (cdev != d->sibling)) { 568 (cdev != d->sibling)) {
571 cdev->private->state = DEV_STATE_NOT_OPER; 569 cdev->private->state = DEV_STATE_NOT_OPER;
572 return 1; 570 return 1;
@@ -574,15 +572,13 @@ match_devno(struct device * dev, void * data)
574 return 0; 572 return 0;
575} 573}
576 574
577static struct ccw_device * 575static struct ccw_device * get_disc_ccwdev_by_dev_id(struct ccw_dev_id *dev_id,
578get_disc_ccwdev_by_devno(unsigned int devno, unsigned int ssid, 576 struct ccw_device *sibling)
579 struct ccw_device *sibling)
580{ 577{
581 struct device *dev; 578 struct device *dev;
582 struct match_data data; 579 struct match_data data;
583 580
584 data.devno = devno; 581 data.dev_id = *dev_id;
585 data.ssid = ssid;
586 data.sibling = sibling; 582 data.sibling = sibling;
587 dev = bus_find_device(&ccw_bus_type, NULL, &data, match_devno); 583 dev = bus_find_device(&ccw_bus_type, NULL, &data, match_devno);
588 584
@@ -595,7 +591,7 @@ ccw_device_add_changed(void *data)
595 591
596 struct ccw_device *cdev; 592 struct ccw_device *cdev;
597 593
598 cdev = (struct ccw_device *)data; 594 cdev = data;
599 if (device_add(&cdev->dev)) { 595 if (device_add(&cdev->dev)) {
600 put_device(&cdev->dev); 596 put_device(&cdev->dev);
601 return; 597 return;
@@ -616,9 +612,9 @@ ccw_device_do_unreg_rereg(void *data)
616 struct subchannel *sch; 612 struct subchannel *sch;
617 int need_rename; 613 int need_rename;
618 614
619 cdev = (struct ccw_device *)data; 615 cdev = data;
620 sch = to_subchannel(cdev->dev.parent); 616 sch = to_subchannel(cdev->dev.parent);
621 if (cdev->private->devno != sch->schib.pmcw.dev) { 617 if (cdev->private->dev_id.devno != sch->schib.pmcw.dev) {
622 /* 618 /*
623 * The device number has changed. This is usually only when 619 * The device number has changed. This is usually only when
624 * a device has been detached under VM and then re-appeared 620 * a device has been detached under VM and then re-appeared
@@ -633,10 +629,12 @@ ccw_device_do_unreg_rereg(void *data)
633 * get possibly sick... 629 * get possibly sick...
634 */ 630 */
635 struct ccw_device *other_cdev; 631 struct ccw_device *other_cdev;
632 struct ccw_dev_id dev_id;
636 633
637 need_rename = 1; 634 need_rename = 1;
638 other_cdev = get_disc_ccwdev_by_devno(sch->schib.pmcw.dev, 635 dev_id.devno = sch->schib.pmcw.dev;
639 sch->schid.ssid, cdev); 636 dev_id.ssid = sch->schid.ssid;
637 other_cdev = get_disc_ccwdev_by_dev_id(&dev_id, cdev);
640 if (other_cdev) { 638 if (other_cdev) {
641 struct subchannel *other_sch; 639 struct subchannel *other_sch;
642 640
@@ -652,7 +650,7 @@ ccw_device_do_unreg_rereg(void *data)
652 } 650 }
653 /* Update ssd info here. */ 651 /* Update ssd info here. */
654 css_get_ssd_info(sch); 652 css_get_ssd_info(sch);
655 cdev->private->devno = sch->schib.pmcw.dev; 653 cdev->private->dev_id.devno = sch->schib.pmcw.dev;
656 } else 654 } else
657 need_rename = 0; 655 need_rename = 0;
658 device_remove_files(&cdev->dev); 656 device_remove_files(&cdev->dev);
@@ -662,7 +660,7 @@ ccw_device_do_unreg_rereg(void *data)
662 snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x", 660 snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x",
663 sch->schid.ssid, sch->schib.pmcw.dev); 661 sch->schid.ssid, sch->schib.pmcw.dev);
664 PREPARE_WORK(&cdev->private->kick_work, 662 PREPARE_WORK(&cdev->private->kick_work,
665 ccw_device_add_changed, (void *)cdev); 663 ccw_device_add_changed, cdev);
666 queue_work(ccw_device_work, &cdev->private->kick_work); 664 queue_work(ccw_device_work, &cdev->private->kick_work);
667} 665}
668 666
@@ -687,7 +685,7 @@ io_subchannel_register(void *data)
687 int ret; 685 int ret;
688 unsigned long flags; 686 unsigned long flags;
689 687
690 cdev = (struct ccw_device *) data; 688 cdev = data;
691 sch = to_subchannel(cdev->dev.parent); 689 sch = to_subchannel(cdev->dev.parent);
692 690
693 if (klist_node_attached(&cdev->dev.knode_parent)) { 691 if (klist_node_attached(&cdev->dev.knode_parent)) {
@@ -759,7 +757,7 @@ io_subchannel_recog_done(struct ccw_device *cdev)
759 break; 757 break;
760 sch = to_subchannel(cdev->dev.parent); 758 sch = to_subchannel(cdev->dev.parent);
761 PREPARE_WORK(&cdev->private->kick_work, 759 PREPARE_WORK(&cdev->private->kick_work,
762 ccw_device_call_sch_unregister, (void *) cdev); 760 ccw_device_call_sch_unregister, cdev);
763 queue_work(slow_path_wq, &cdev->private->kick_work); 761 queue_work(slow_path_wq, &cdev->private->kick_work);
764 if (atomic_dec_and_test(&ccw_device_init_count)) 762 if (atomic_dec_and_test(&ccw_device_init_count))
765 wake_up(&ccw_device_init_wq); 763 wake_up(&ccw_device_init_wq);
@@ -774,7 +772,7 @@ io_subchannel_recog_done(struct ccw_device *cdev)
774 if (!get_device(&cdev->dev)) 772 if (!get_device(&cdev->dev))
775 break; 773 break;
776 PREPARE_WORK(&cdev->private->kick_work, 774 PREPARE_WORK(&cdev->private->kick_work,
777 io_subchannel_register, (void *) cdev); 775 io_subchannel_register, cdev);
778 queue_work(slow_path_wq, &cdev->private->kick_work); 776 queue_work(slow_path_wq, &cdev->private->kick_work);
779 break; 777 break;
780 } 778 }
@@ -792,9 +790,9 @@ io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch)
792 790
793 /* Init private data. */ 791 /* Init private data. */
794 priv = cdev->private; 792 priv = cdev->private;
795 priv->devno = sch->schib.pmcw.dev; 793 priv->dev_id.devno = sch->schib.pmcw.dev;
796 priv->ssid = sch->schid.ssid; 794 priv->dev_id.ssid = sch->schid.ssid;
797 priv->sch_no = sch->schid.sch_no; 795 priv->schid = sch->schid;
798 priv->state = DEV_STATE_NOT_OPER; 796 priv->state = DEV_STATE_NOT_OPER;
799 INIT_LIST_HEAD(&priv->cmb_list); 797 INIT_LIST_HEAD(&priv->cmb_list);
800 init_waitqueue_head(&priv->wait_q); 798 init_waitqueue_head(&priv->wait_q);
@@ -912,7 +910,7 @@ io_subchannel_remove (struct subchannel *sch)
912 */ 910 */
913 if (get_device(&cdev->dev)) { 911 if (get_device(&cdev->dev)) {
914 PREPARE_WORK(&cdev->private->kick_work, 912 PREPARE_WORK(&cdev->private->kick_work,
915 ccw_device_unregister, (void *) cdev); 913 ccw_device_unregister, cdev);
916 queue_work(ccw_device_work, &cdev->private->kick_work); 914 queue_work(ccw_device_work, &cdev->private->kick_work);
917 } 915 }
918 return 0; 916 return 0;
@@ -1055,7 +1053,7 @@ __ccwdev_check_busid(struct device *dev, void *id)
1055{ 1053{
1056 char *bus_id; 1054 char *bus_id;
1057 1055
1058 bus_id = (char *)id; 1056 bus_id = id;
1059 1057
1060 return (strncmp(bus_id, dev->bus_id, BUS_ID_SIZE) == 0); 1058 return (strncmp(bus_id, dev->bus_id, BUS_ID_SIZE) == 0);
1061} 1059}
diff --git a/drivers/s390/cio/device.h b/drivers/s390/cio/device.h
index 00be9a5b4acd..c6140cc97a80 100644
--- a/drivers/s390/cio/device.h
+++ b/drivers/s390/cio/device.h
@@ -21,7 +21,6 @@ enum dev_state {
21 /* states to wait for i/o completion before doing something */ 21 /* states to wait for i/o completion before doing something */
22 DEV_STATE_CLEAR_VERIFY, 22 DEV_STATE_CLEAR_VERIFY,
23 DEV_STATE_TIMEOUT_KILL, 23 DEV_STATE_TIMEOUT_KILL,
24 DEV_STATE_WAIT4IO,
25 DEV_STATE_QUIESCE, 24 DEV_STATE_QUIESCE,
26 /* special states for devices gone not operational */ 25 /* special states for devices gone not operational */
27 DEV_STATE_DISCONNECTED, 26 DEV_STATE_DISCONNECTED,
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index b67620208f36..fcaf28d7b4eb 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -59,18 +59,6 @@ device_set_disconnected(struct subchannel *sch)
59 cdev->private->state = DEV_STATE_DISCONNECTED; 59 cdev->private->state = DEV_STATE_DISCONNECTED;
60} 60}
61 61
62void
63device_set_waiting(struct subchannel *sch)
64{
65 struct ccw_device *cdev;
66
67 if (!sch->dev.driver_data)
68 return;
69 cdev = sch->dev.driver_data;
70 ccw_device_set_timeout(cdev, 10*HZ);
71 cdev->private->state = DEV_STATE_WAIT4IO;
72}
73
74/* 62/*
75 * Timeout function. It just triggers a DEV_EVENT_TIMEOUT. 63 * Timeout function. It just triggers a DEV_EVENT_TIMEOUT.
76 */ 64 */
@@ -183,9 +171,9 @@ ccw_device_handle_oper(struct ccw_device *cdev)
183 cdev->id.cu_model != cdev->private->senseid.cu_model || 171 cdev->id.cu_model != cdev->private->senseid.cu_model ||
184 cdev->id.dev_type != cdev->private->senseid.dev_type || 172 cdev->id.dev_type != cdev->private->senseid.dev_type ||
185 cdev->id.dev_model != cdev->private->senseid.dev_model || 173 cdev->id.dev_model != cdev->private->senseid.dev_model ||
186 cdev->private->devno != sch->schib.pmcw.dev) { 174 cdev->private->dev_id.devno != sch->schib.pmcw.dev) {
187 PREPARE_WORK(&cdev->private->kick_work, 175 PREPARE_WORK(&cdev->private->kick_work,
188 ccw_device_do_unreg_rereg, (void *)cdev); 176 ccw_device_do_unreg_rereg, cdev);
189 queue_work(ccw_device_work, &cdev->private->kick_work); 177 queue_work(ccw_device_work, &cdev->private->kick_work);
190 return 0; 178 return 0;
191 } 179 }
@@ -255,7 +243,7 @@ ccw_device_recog_done(struct ccw_device *cdev, int state)
255 case DEV_STATE_NOT_OPER: 243 case DEV_STATE_NOT_OPER:
256 CIO_DEBUG(KERN_WARNING, 2, 244 CIO_DEBUG(KERN_WARNING, 2,
257 "SenseID : unknown device %04x on subchannel " 245 "SenseID : unknown device %04x on subchannel "
258 "0.%x.%04x\n", cdev->private->devno, 246 "0.%x.%04x\n", cdev->private->dev_id.devno,
259 sch->schid.ssid, sch->schid.sch_no); 247 sch->schid.ssid, sch->schid.sch_no);
260 break; 248 break;
261 case DEV_STATE_OFFLINE: 249 case DEV_STATE_OFFLINE:
@@ -282,14 +270,15 @@ ccw_device_recog_done(struct ccw_device *cdev, int state)
282 CIO_DEBUG(KERN_INFO, 2, "SenseID : device 0.%x.%04x reports: " 270 CIO_DEBUG(KERN_INFO, 2, "SenseID : device 0.%x.%04x reports: "
283 "CU Type/Mod = %04X/%02X, Dev Type/Mod = " 271 "CU Type/Mod = %04X/%02X, Dev Type/Mod = "
284 "%04X/%02X\n", 272 "%04X/%02X\n",
285 cdev->private->ssid, cdev->private->devno, 273 cdev->private->dev_id.ssid,
274 cdev->private->dev_id.devno,
286 cdev->id.cu_type, cdev->id.cu_model, 275 cdev->id.cu_type, cdev->id.cu_model,
287 cdev->id.dev_type, cdev->id.dev_model); 276 cdev->id.dev_type, cdev->id.dev_model);
288 break; 277 break;
289 case DEV_STATE_BOXED: 278 case DEV_STATE_BOXED:
290 CIO_DEBUG(KERN_WARNING, 2, 279 CIO_DEBUG(KERN_WARNING, 2,
291 "SenseID : boxed device %04x on subchannel " 280 "SenseID : boxed device %04x on subchannel "
292 "0.%x.%04x\n", cdev->private->devno, 281 "0.%x.%04x\n", cdev->private->dev_id.devno,
293 sch->schid.ssid, sch->schid.sch_no); 282 sch->schid.ssid, sch->schid.sch_no);
294 break; 283 break;
295 } 284 }
@@ -325,13 +314,13 @@ ccw_device_oper_notify(void *data)
325 struct subchannel *sch; 314 struct subchannel *sch;
326 int ret; 315 int ret;
327 316
328 cdev = (struct ccw_device *)data; 317 cdev = data;
329 sch = to_subchannel(cdev->dev.parent); 318 sch = to_subchannel(cdev->dev.parent);
330 ret = (sch->driver && sch->driver->notify) ? 319 ret = (sch->driver && sch->driver->notify) ?
331 sch->driver->notify(&sch->dev, CIO_OPER) : 0; 320 sch->driver->notify(&sch->dev, CIO_OPER) : 0;
332 if (!ret) 321 if (!ret)
333 /* Driver doesn't want device back. */ 322 /* Driver doesn't want device back. */
334 ccw_device_do_unreg_rereg((void *)cdev); 323 ccw_device_do_unreg_rereg(cdev);
335 else { 324 else {
336 /* Reenable channel measurements, if needed. */ 325 /* Reenable channel measurements, if needed. */
337 cmf_reenable(cdev); 326 cmf_reenable(cdev);
@@ -363,12 +352,12 @@ ccw_device_done(struct ccw_device *cdev, int state)
363 if (state == DEV_STATE_BOXED) 352 if (state == DEV_STATE_BOXED)
364 CIO_DEBUG(KERN_WARNING, 2, 353 CIO_DEBUG(KERN_WARNING, 2,
365 "Boxed device %04x on subchannel %04x\n", 354 "Boxed device %04x on subchannel %04x\n",
366 cdev->private->devno, sch->schid.sch_no); 355 cdev->private->dev_id.devno, sch->schid.sch_no);
367 356
368 if (cdev->private->flags.donotify) { 357 if (cdev->private->flags.donotify) {
369 cdev->private->flags.donotify = 0; 358 cdev->private->flags.donotify = 0;
370 PREPARE_WORK(&cdev->private->kick_work, ccw_device_oper_notify, 359 PREPARE_WORK(&cdev->private->kick_work, ccw_device_oper_notify,
371 (void *)cdev); 360 cdev);
372 queue_work(ccw_device_notify_work, &cdev->private->kick_work); 361 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
373 } 362 }
374 wake_up(&cdev->private->wait_q); 363 wake_up(&cdev->private->wait_q);
@@ -412,7 +401,8 @@ static void __ccw_device_get_common_pgid(struct ccw_device *cdev)
412 /* PGID mismatch, can't pathgroup. */ 401 /* PGID mismatch, can't pathgroup. */
413 CIO_MSG_EVENT(0, "SNID - pgid mismatch for device " 402 CIO_MSG_EVENT(0, "SNID - pgid mismatch for device "
414 "0.%x.%04x, can't pathgroup\n", 403 "0.%x.%04x, can't pathgroup\n",
415 cdev->private->ssid, cdev->private->devno); 404 cdev->private->dev_id.ssid,
405 cdev->private->dev_id.devno);
416 cdev->private->options.pgroup = 0; 406 cdev->private->options.pgroup = 0;
417 return; 407 return;
418 } 408 }
@@ -523,7 +513,7 @@ ccw_device_nopath_notify(void *data)
523 struct subchannel *sch; 513 struct subchannel *sch;
524 int ret; 514 int ret;
525 515
526 cdev = (struct ccw_device *)data; 516 cdev = data;
527 sch = to_subchannel(cdev->dev.parent); 517 sch = to_subchannel(cdev->dev.parent);
528 /* Extra sanity. */ 518 /* Extra sanity. */
529 if (sch->lpm) 519 if (sch->lpm)
@@ -537,7 +527,7 @@ ccw_device_nopath_notify(void *data)
537 if (get_device(&cdev->dev)) { 527 if (get_device(&cdev->dev)) {
538 PREPARE_WORK(&cdev->private->kick_work, 528 PREPARE_WORK(&cdev->private->kick_work,
539 ccw_device_call_sch_unregister, 529 ccw_device_call_sch_unregister,
540 (void *)cdev); 530 cdev);
541 queue_work(ccw_device_work, 531 queue_work(ccw_device_work,
542 &cdev->private->kick_work); 532 &cdev->private->kick_work);
543 } else 533 } else
@@ -592,7 +582,7 @@ ccw_device_verify_done(struct ccw_device *cdev, int err)
592 break; 582 break;
593 default: 583 default:
594 PREPARE_WORK(&cdev->private->kick_work, 584 PREPARE_WORK(&cdev->private->kick_work,
595 ccw_device_nopath_notify, (void *)cdev); 585 ccw_device_nopath_notify, cdev);
596 queue_work(ccw_device_notify_work, &cdev->private->kick_work); 586 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
597 ccw_device_done(cdev, DEV_STATE_NOT_OPER); 587 ccw_device_done(cdev, DEV_STATE_NOT_OPER);
598 break; 588 break;
@@ -723,7 +713,7 @@ ccw_device_offline_notoper(struct ccw_device *cdev, enum dev_event dev_event)
723 sch = to_subchannel(cdev->dev.parent); 713 sch = to_subchannel(cdev->dev.parent);
724 if (get_device(&cdev->dev)) { 714 if (get_device(&cdev->dev)) {
725 PREPARE_WORK(&cdev->private->kick_work, 715 PREPARE_WORK(&cdev->private->kick_work,
726 ccw_device_call_sch_unregister, (void *)cdev); 716 ccw_device_call_sch_unregister, cdev);
727 queue_work(ccw_device_work, &cdev->private->kick_work); 717 queue_work(ccw_device_work, &cdev->private->kick_work);
728 } 718 }
729 wake_up(&cdev->private->wait_q); 719 wake_up(&cdev->private->wait_q);
@@ -754,7 +744,7 @@ ccw_device_online_notoper(struct ccw_device *cdev, enum dev_event dev_event)
754 } 744 }
755 if (get_device(&cdev->dev)) { 745 if (get_device(&cdev->dev)) {
756 PREPARE_WORK(&cdev->private->kick_work, 746 PREPARE_WORK(&cdev->private->kick_work,
757 ccw_device_call_sch_unregister, (void *)cdev); 747 ccw_device_call_sch_unregister, cdev);
758 queue_work(ccw_device_work, &cdev->private->kick_work); 748 queue_work(ccw_device_work, &cdev->private->kick_work);
759 } 749 }
760 wake_up(&cdev->private->wait_q); 750 wake_up(&cdev->private->wait_q);
@@ -859,7 +849,7 @@ ccw_device_online_timeout(struct ccw_device *cdev, enum dev_event dev_event)
859 sch = to_subchannel(cdev->dev.parent); 849 sch = to_subchannel(cdev->dev.parent);
860 if (!sch->lpm) { 850 if (!sch->lpm) {
861 PREPARE_WORK(&cdev->private->kick_work, 851 PREPARE_WORK(&cdev->private->kick_work,
862 ccw_device_nopath_notify, (void *)cdev); 852 ccw_device_nopath_notify, cdev);
863 queue_work(ccw_device_notify_work, 853 queue_work(ccw_device_notify_work,
864 &cdev->private->kick_work); 854 &cdev->private->kick_work);
865 } else 855 } else
@@ -885,7 +875,8 @@ ccw_device_w4sense(struct ccw_device *cdev, enum dev_event dev_event)
885 /* Basic sense hasn't started. Try again. */ 875 /* Basic sense hasn't started. Try again. */
886 ccw_device_do_sense(cdev, irb); 876 ccw_device_do_sense(cdev, irb);
887 else { 877 else {
888 printk("Huh? %s(%s): unsolicited interrupt...\n", 878 printk(KERN_INFO "Huh? %s(%s): unsolicited "
879 "interrupt...\n",
889 __FUNCTION__, cdev->dev.bus_id); 880 __FUNCTION__, cdev->dev.bus_id);
890 if (cdev->handler) 881 if (cdev->handler)
891 cdev->handler (cdev, 0, irb); 882 cdev->handler (cdev, 0, irb);
@@ -944,10 +935,10 @@ ccw_device_killing_irq(struct ccw_device *cdev, enum dev_event dev_event)
944 cdev->private->state = DEV_STATE_ONLINE; 935 cdev->private->state = DEV_STATE_ONLINE;
945 if (cdev->handler) 936 if (cdev->handler)
946 cdev->handler(cdev, cdev->private->intparm, 937 cdev->handler(cdev, cdev->private->intparm,
947 ERR_PTR(-ETIMEDOUT)); 938 ERR_PTR(-EIO));
948 if (!sch->lpm) { 939 if (!sch->lpm) {
949 PREPARE_WORK(&cdev->private->kick_work, 940 PREPARE_WORK(&cdev->private->kick_work,
950 ccw_device_nopath_notify, (void *)cdev); 941 ccw_device_nopath_notify, cdev);
951 queue_work(ccw_device_notify_work, &cdev->private->kick_work); 942 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
952 } else if (cdev->private->flags.doverify) 943 } else if (cdev->private->flags.doverify)
953 /* Start delayed path verification. */ 944 /* Start delayed path verification. */
@@ -970,7 +961,7 @@ ccw_device_killing_timeout(struct ccw_device *cdev, enum dev_event dev_event)
970 sch = to_subchannel(cdev->dev.parent); 961 sch = to_subchannel(cdev->dev.parent);
971 if (!sch->lpm) { 962 if (!sch->lpm) {
972 PREPARE_WORK(&cdev->private->kick_work, 963 PREPARE_WORK(&cdev->private->kick_work,
973 ccw_device_nopath_notify, (void *)cdev); 964 ccw_device_nopath_notify, cdev);
974 queue_work(ccw_device_notify_work, 965 queue_work(ccw_device_notify_work,
975 &cdev->private->kick_work); 966 &cdev->private->kick_work);
976 } else 967 } else
@@ -981,51 +972,15 @@ ccw_device_killing_timeout(struct ccw_device *cdev, enum dev_event dev_event)
981 cdev->private->state = DEV_STATE_ONLINE; 972 cdev->private->state = DEV_STATE_ONLINE;
982 if (cdev->handler) 973 if (cdev->handler)
983 cdev->handler(cdev, cdev->private->intparm, 974 cdev->handler(cdev, cdev->private->intparm,
984 ERR_PTR(-ETIMEDOUT)); 975 ERR_PTR(-EIO));
985}
986
987static void
988ccw_device_wait4io_irq(struct ccw_device *cdev, enum dev_event dev_event)
989{
990 struct irb *irb;
991 struct subchannel *sch;
992
993 irb = (struct irb *) __LC_IRB;
994 /*
995 * Accumulate status and find out if a basic sense is needed.
996 * This is fine since we have already adapted the lpm.
997 */
998 ccw_device_accumulate_irb(cdev, irb);
999 if (cdev->private->flags.dosense) {
1000 if (ccw_device_do_sense(cdev, irb) == 0) {
1001 cdev->private->state = DEV_STATE_W4SENSE;
1002 }
1003 return;
1004 }
1005
1006 /* Iff device is idle, reset timeout. */
1007 sch = to_subchannel(cdev->dev.parent);
1008 if (!stsch(sch->schid, &sch->schib))
1009 if (sch->schib.scsw.actl == 0)
1010 ccw_device_set_timeout(cdev, 0);
1011 /* Call the handler. */
1012 ccw_device_call_handler(cdev);
1013 if (!sch->lpm) {
1014 PREPARE_WORK(&cdev->private->kick_work,
1015 ccw_device_nopath_notify, (void *)cdev);
1016 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
1017 } else if (cdev->private->flags.doverify)
1018 ccw_device_online_verify(cdev, 0);
1019} 976}
1020 977
1021static void 978void device_kill_io(struct subchannel *sch)
1022ccw_device_wait4io_timeout(struct ccw_device *cdev, enum dev_event dev_event)
1023{ 979{
1024 int ret; 980 int ret;
1025 struct subchannel *sch; 981 struct ccw_device *cdev;
1026 982
1027 sch = to_subchannel(cdev->dev.parent); 983 cdev = sch->dev.driver_data;
1028 ccw_device_set_timeout(cdev, 0);
1029 ret = ccw_device_cancel_halt_clear(cdev); 984 ret = ccw_device_cancel_halt_clear(cdev);
1030 if (ret == -EBUSY) { 985 if (ret == -EBUSY) {
1031 ccw_device_set_timeout(cdev, 3*HZ); 986 ccw_device_set_timeout(cdev, 3*HZ);
@@ -1035,7 +990,7 @@ ccw_device_wait4io_timeout(struct ccw_device *cdev, enum dev_event dev_event)
1035 if (ret == -ENODEV) { 990 if (ret == -ENODEV) {
1036 if (!sch->lpm) { 991 if (!sch->lpm) {
1037 PREPARE_WORK(&cdev->private->kick_work, 992 PREPARE_WORK(&cdev->private->kick_work,
1038 ccw_device_nopath_notify, (void *)cdev); 993 ccw_device_nopath_notify, cdev);
1039 queue_work(ccw_device_notify_work, 994 queue_work(ccw_device_notify_work,
1040 &cdev->private->kick_work); 995 &cdev->private->kick_work);
1041 } else 996 } else
@@ -1044,12 +999,12 @@ ccw_device_wait4io_timeout(struct ccw_device *cdev, enum dev_event dev_event)
1044 } 999 }
1045 if (cdev->handler) 1000 if (cdev->handler)
1046 cdev->handler(cdev, cdev->private->intparm, 1001 cdev->handler(cdev, cdev->private->intparm,
1047 ERR_PTR(-ETIMEDOUT)); 1002 ERR_PTR(-EIO));
1048 if (!sch->lpm) { 1003 if (!sch->lpm) {
1049 PREPARE_WORK(&cdev->private->kick_work, 1004 PREPARE_WORK(&cdev->private->kick_work,
1050 ccw_device_nopath_notify, (void *)cdev); 1005 ccw_device_nopath_notify, cdev);
1051 queue_work(ccw_device_notify_work, &cdev->private->kick_work); 1006 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
1052 } else if (cdev->private->flags.doverify) 1007 } else
1053 /* Start delayed path verification. */ 1008 /* Start delayed path verification. */
1054 ccw_device_online_verify(cdev, 0); 1009 ccw_device_online_verify(cdev, 0);
1055} 1010}
@@ -1286,12 +1241,6 @@ fsm_func_t *dev_jumptable[NR_DEV_STATES][NR_DEV_EVENTS] = {
1286 [DEV_EVENT_TIMEOUT] = ccw_device_killing_timeout, 1241 [DEV_EVENT_TIMEOUT] = ccw_device_killing_timeout,
1287 [DEV_EVENT_VERIFY] = ccw_device_nop, //FIXME 1242 [DEV_EVENT_VERIFY] = ccw_device_nop, //FIXME
1288 }, 1243 },
1289 [DEV_STATE_WAIT4IO] = {
1290 [DEV_EVENT_NOTOPER] = ccw_device_online_notoper,
1291 [DEV_EVENT_INTERRUPT] = ccw_device_wait4io_irq,
1292 [DEV_EVENT_TIMEOUT] = ccw_device_wait4io_timeout,
1293 [DEV_EVENT_VERIFY] = ccw_device_delay_verify,
1294 },
1295 [DEV_STATE_QUIESCE] = { 1244 [DEV_STATE_QUIESCE] = {
1296 [DEV_EVENT_NOTOPER] = ccw_device_quiesce_done, 1245 [DEV_EVENT_NOTOPER] = ccw_device_quiesce_done,
1297 [DEV_EVENT_INTERRUPT] = ccw_device_quiesce_done, 1246 [DEV_EVENT_INTERRUPT] = ccw_device_quiesce_done,
diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c
index 1398367b5f68..a74785b9e4eb 100644
--- a/drivers/s390/cio/device_id.c
+++ b/drivers/s390/cio/device_id.c
@@ -251,7 +251,7 @@ ccw_device_check_sense_id(struct ccw_device *cdev)
251 */ 251 */
252 CIO_MSG_EVENT(2, "SenseID : device %04x on Subchannel " 252 CIO_MSG_EVENT(2, "SenseID : device %04x on Subchannel "
253 "0.%x.%04x reports cmd reject\n", 253 "0.%x.%04x reports cmd reject\n",
254 cdev->private->devno, sch->schid.ssid, 254 cdev->private->dev_id.devno, sch->schid.ssid,
255 sch->schid.sch_no); 255 sch->schid.sch_no);
256 return -EOPNOTSUPP; 256 return -EOPNOTSUPP;
257 } 257 }
@@ -259,7 +259,8 @@ ccw_device_check_sense_id(struct ccw_device *cdev)
259 CIO_MSG_EVENT(2, "SenseID : UC on dev 0.%x.%04x, " 259 CIO_MSG_EVENT(2, "SenseID : UC on dev 0.%x.%04x, "
260 "lpum %02X, cnt %02d, sns :" 260 "lpum %02X, cnt %02d, sns :"
261 " %02X%02X%02X%02X %02X%02X%02X%02X ...\n", 261 " %02X%02X%02X%02X %02X%02X%02X%02X ...\n",
262 cdev->private->ssid, cdev->private->devno, 262 cdev->private->dev_id.ssid,
263 cdev->private->dev_id.devno,
263 irb->esw.esw0.sublog.lpum, 264 irb->esw.esw0.sublog.lpum,
264 irb->esw.esw0.erw.scnt, 265 irb->esw.esw0.erw.scnt,
265 irb->ecw[0], irb->ecw[1], 266 irb->ecw[0], irb->ecw[1],
@@ -274,14 +275,15 @@ ccw_device_check_sense_id(struct ccw_device *cdev)
274 CIO_MSG_EVENT(2, "SenseID : path %02X for device %04x " 275 CIO_MSG_EVENT(2, "SenseID : path %02X for device %04x "
275 "on subchannel 0.%x.%04x is " 276 "on subchannel 0.%x.%04x is "
276 "'not operational'\n", sch->orb.lpm, 277 "'not operational'\n", sch->orb.lpm,
277 cdev->private->devno, sch->schid.ssid, 278 cdev->private->dev_id.devno,
278 sch->schid.sch_no); 279 sch->schid.ssid, sch->schid.sch_no);
279 return -EACCES; 280 return -EACCES;
280 } 281 }
281 /* Hmm, whatever happened, try again. */ 282 /* Hmm, whatever happened, try again. */
282 CIO_MSG_EVENT(2, "SenseID : start_IO() for device %04x on " 283 CIO_MSG_EVENT(2, "SenseID : start_IO() for device %04x on "
283 "subchannel 0.%x.%04x returns status %02X%02X\n", 284 "subchannel 0.%x.%04x returns status %02X%02X\n",
284 cdev->private->devno, sch->schid.ssid, sch->schid.sch_no, 285 cdev->private->dev_id.devno, sch->schid.ssid,
286 sch->schid.sch_no,
285 irb->scsw.dstat, irb->scsw.cstat); 287 irb->scsw.dstat, irb->scsw.cstat);
286 return -EAGAIN; 288 return -EAGAIN;
287} 289}
@@ -330,7 +332,7 @@ ccw_device_sense_id_irq(struct ccw_device *cdev, enum dev_event dev_event)
330 /* fall through. */ 332 /* fall through. */
331 default: /* Sense ID failed. Try asking VM. */ 333 default: /* Sense ID failed. Try asking VM. */
332 if (MACHINE_IS_VM) { 334 if (MACHINE_IS_VM) {
333 VM_virtual_device_info (cdev->private->devno, 335 VM_virtual_device_info (cdev->private->dev_id.devno,
334 &cdev->private->senseid); 336 &cdev->private->senseid);
335 if (cdev->private->senseid.cu_type != 0xFFFF) { 337 if (cdev->private->senseid.cu_type != 0xFFFF) {
336 /* Got the device information from VM. */ 338 /* Got the device information from VM. */
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 84b9b18eabc2..b39c1fa48acd 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -50,7 +50,6 @@ ccw_device_clear(struct ccw_device *cdev, unsigned long intparm)
50 if (cdev->private->state == DEV_STATE_NOT_OPER) 50 if (cdev->private->state == DEV_STATE_NOT_OPER)
51 return -ENODEV; 51 return -ENODEV;
52 if (cdev->private->state != DEV_STATE_ONLINE && 52 if (cdev->private->state != DEV_STATE_ONLINE &&
53 cdev->private->state != DEV_STATE_WAIT4IO &&
54 cdev->private->state != DEV_STATE_W4SENSE) 53 cdev->private->state != DEV_STATE_W4SENSE)
55 return -EINVAL; 54 return -EINVAL;
56 sch = to_subchannel(cdev->dev.parent); 55 sch = to_subchannel(cdev->dev.parent);
@@ -155,7 +154,6 @@ ccw_device_halt(struct ccw_device *cdev, unsigned long intparm)
155 if (cdev->private->state == DEV_STATE_NOT_OPER) 154 if (cdev->private->state == DEV_STATE_NOT_OPER)
156 return -ENODEV; 155 return -ENODEV;
157 if (cdev->private->state != DEV_STATE_ONLINE && 156 if (cdev->private->state != DEV_STATE_ONLINE &&
158 cdev->private->state != DEV_STATE_WAIT4IO &&
159 cdev->private->state != DEV_STATE_W4SENSE) 157 cdev->private->state != DEV_STATE_W4SENSE)
160 return -EINVAL; 158 return -EINVAL;
161 sch = to_subchannel(cdev->dev.parent); 159 sch = to_subchannel(cdev->dev.parent);
@@ -592,13 +590,13 @@ ccw_device_get_chp_desc(struct ccw_device *cdev, int chp_no)
592int 590int
593_ccw_device_get_subchannel_number(struct ccw_device *cdev) 591_ccw_device_get_subchannel_number(struct ccw_device *cdev)
594{ 592{
595 return cdev->private->sch_no; 593 return cdev->private->schid.sch_no;
596} 594}
597 595
598int 596int
599_ccw_device_get_device_number(struct ccw_device *cdev) 597_ccw_device_get_device_number(struct ccw_device *cdev)
600{ 598{
601 return cdev->private->devno; 599 return cdev->private->dev_id.devno;
602} 600}
603 601
604 602
diff --git a/drivers/s390/cio/device_pgid.c b/drivers/s390/cio/device_pgid.c
index 84917b39de45..2975ce888c19 100644
--- a/drivers/s390/cio/device_pgid.c
+++ b/drivers/s390/cio/device_pgid.c
@@ -79,7 +79,8 @@ __ccw_device_sense_pgid_start(struct ccw_device *cdev)
79 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel " 79 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel "
80 "0.%x.%04x, lpm %02X, became 'not " 80 "0.%x.%04x, lpm %02X, became 'not "
81 "operational'\n", 81 "operational'\n",
82 cdev->private->devno, sch->schid.ssid, 82 cdev->private->dev_id.devno,
83 sch->schid.ssid,
83 sch->schid.sch_no, cdev->private->imask); 84 sch->schid.sch_no, cdev->private->imask);
84 85
85 } 86 }
@@ -135,7 +136,8 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev)
135 CIO_MSG_EVENT(2, "SNID - device 0.%x.%04x, unit check, " 136 CIO_MSG_EVENT(2, "SNID - device 0.%x.%04x, unit check, "
136 "lpum %02X, cnt %02d, sns : " 137 "lpum %02X, cnt %02d, sns : "
137 "%02X%02X%02X%02X %02X%02X%02X%02X ...\n", 138 "%02X%02X%02X%02X %02X%02X%02X%02X ...\n",
138 cdev->private->ssid, cdev->private->devno, 139 cdev->private->dev_id.ssid,
140 cdev->private->dev_id.devno,
139 irb->esw.esw0.sublog.lpum, 141 irb->esw.esw0.sublog.lpum,
140 irb->esw.esw0.erw.scnt, 142 irb->esw.esw0.erw.scnt,
141 irb->ecw[0], irb->ecw[1], 143 irb->ecw[0], irb->ecw[1],
@@ -147,7 +149,7 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev)
147 if (irb->scsw.cc == 3) { 149 if (irb->scsw.cc == 3) {
148 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x," 150 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x,"
149 " lpm %02X, became 'not operational'\n", 151 " lpm %02X, became 'not operational'\n",
150 cdev->private->devno, sch->schid.ssid, 152 cdev->private->dev_id.devno, sch->schid.ssid,
151 sch->schid.sch_no, sch->orb.lpm); 153 sch->schid.sch_no, sch->orb.lpm);
152 return -EACCES; 154 return -EACCES;
153 } 155 }
@@ -155,7 +157,7 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev)
155 if (cdev->private->pgid[i].inf.ps.state2 == SNID_STATE2_RESVD_ELSE) { 157 if (cdev->private->pgid[i].inf.ps.state2 == SNID_STATE2_RESVD_ELSE) {
156 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x " 158 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x "
157 "is reserved by someone else\n", 159 "is reserved by someone else\n",
158 cdev->private->devno, sch->schid.ssid, 160 cdev->private->dev_id.devno, sch->schid.ssid,
159 sch->schid.sch_no); 161 sch->schid.sch_no);
160 return -EUSERS; 162 return -EUSERS;
161 } 163 }
@@ -261,7 +263,7 @@ __ccw_device_do_pgid(struct ccw_device *cdev, __u8 func)
261 /* PGID command failed on this path. */ 263 /* PGID command failed on this path. */
262 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel " 264 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel "
263 "0.%x.%04x, lpm %02X, became 'not operational'\n", 265 "0.%x.%04x, lpm %02X, became 'not operational'\n",
264 cdev->private->devno, sch->schid.ssid, 266 cdev->private->dev_id.devno, sch->schid.ssid,
265 sch->schid.sch_no, cdev->private->imask); 267 sch->schid.sch_no, cdev->private->imask);
266 return ret; 268 return ret;
267} 269}
@@ -301,7 +303,7 @@ static int __ccw_device_do_nop(struct ccw_device *cdev)
301 /* nop command failed on this path. */ 303 /* nop command failed on this path. */
302 CIO_MSG_EVENT(2, "NOP - Device %04x on Subchannel " 304 CIO_MSG_EVENT(2, "NOP - Device %04x on Subchannel "
303 "0.%x.%04x, lpm %02X, became 'not operational'\n", 305 "0.%x.%04x, lpm %02X, became 'not operational'\n",
304 cdev->private->devno, sch->schid.ssid, 306 cdev->private->dev_id.devno, sch->schid.ssid,
305 sch->schid.sch_no, cdev->private->imask); 307 sch->schid.sch_no, cdev->private->imask);
306 return ret; 308 return ret;
307} 309}
@@ -328,8 +330,9 @@ __ccw_device_check_pgid(struct ccw_device *cdev)
328 CIO_MSG_EVENT(2, "SPID - device 0.%x.%04x, unit check, " 330 CIO_MSG_EVENT(2, "SPID - device 0.%x.%04x, unit check, "
329 "cnt %02d, " 331 "cnt %02d, "
330 "sns : %02X%02X%02X%02X %02X%02X%02X%02X ...\n", 332 "sns : %02X%02X%02X%02X %02X%02X%02X%02X ...\n",
331 cdev->private->ssid, 333 cdev->private->dev_id.ssid,
332 cdev->private->devno, irb->esw.esw0.erw.scnt, 334 cdev->private->dev_id.devno,
335 irb->esw.esw0.erw.scnt,
333 irb->ecw[0], irb->ecw[1], 336 irb->ecw[0], irb->ecw[1],
334 irb->ecw[2], irb->ecw[3], 337 irb->ecw[2], irb->ecw[3],
335 irb->ecw[4], irb->ecw[5], 338 irb->ecw[4], irb->ecw[5],
@@ -339,7 +342,7 @@ __ccw_device_check_pgid(struct ccw_device *cdev)
339 if (irb->scsw.cc == 3) { 342 if (irb->scsw.cc == 3) {
340 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel 0.%x.%04x," 343 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel 0.%x.%04x,"
341 " lpm %02X, became 'not operational'\n", 344 " lpm %02X, became 'not operational'\n",
342 cdev->private->devno, sch->schid.ssid, 345 cdev->private->dev_id.devno, sch->schid.ssid,
343 sch->schid.sch_no, cdev->private->imask); 346 sch->schid.sch_no, cdev->private->imask);
344 return -EACCES; 347 return -EACCES;
345 } 348 }
@@ -362,7 +365,7 @@ static int __ccw_device_check_nop(struct ccw_device *cdev)
362 if (irb->scsw.cc == 3) { 365 if (irb->scsw.cc == 3) {
363 CIO_MSG_EVENT(2, "NOP - Device %04x on Subchannel 0.%x.%04x," 366 CIO_MSG_EVENT(2, "NOP - Device %04x on Subchannel 0.%x.%04x,"
364 " lpm %02X, became 'not operational'\n", 367 " lpm %02X, became 'not operational'\n",
365 cdev->private->devno, sch->schid.ssid, 368 cdev->private->dev_id.devno, sch->schid.ssid,
366 sch->schid.sch_no, cdev->private->imask); 369 sch->schid.sch_no, cdev->private->imask);
367 return -EACCES; 370 return -EACCES;
368 } 371 }
diff --git a/drivers/s390/cio/device_status.c b/drivers/s390/cio/device_status.c
index caf148d5caad..3f7cbce4cd87 100644
--- a/drivers/s390/cio/device_status.c
+++ b/drivers/s390/cio/device_status.c
@@ -32,19 +32,18 @@ ccw_device_msg_control_check(struct ccw_device *cdev, struct irb *irb)
32 SCHN_STAT_CHN_CTRL_CHK | 32 SCHN_STAT_CHN_CTRL_CHK |
33 SCHN_STAT_INTF_CTRL_CHK))) 33 SCHN_STAT_INTF_CTRL_CHK)))
34 return; 34 return;
35
36 CIO_MSG_EVENT(0, "Channel-Check or Interface-Control-Check " 35 CIO_MSG_EVENT(0, "Channel-Check or Interface-Control-Check "
37 "received" 36 "received"
38 " ... device %04x on subchannel 0.%x.%04x, dev_stat " 37 " ... device %04x on subchannel 0.%x.%04x, dev_stat "
39 ": %02X sch_stat : %02X\n", 38 ": %02X sch_stat : %02X\n",
40 cdev->private->devno, cdev->private->ssid, 39 cdev->private->dev_id.devno, cdev->private->schid.ssid,
41 cdev->private->sch_no, 40 cdev->private->schid.sch_no,
42 irb->scsw.dstat, irb->scsw.cstat); 41 irb->scsw.dstat, irb->scsw.cstat);
43 42
44 if (irb->scsw.cc != 3) { 43 if (irb->scsw.cc != 3) {
45 char dbf_text[15]; 44 char dbf_text[15];
46 45
47 sprintf(dbf_text, "chk%x", cdev->private->sch_no); 46 sprintf(dbf_text, "chk%x", cdev->private->schid.sch_no);
48 CIO_TRACE_EVENT(0, dbf_text); 47 CIO_TRACE_EVENT(0, dbf_text);
49 CIO_HEX_EVENT(0, irb, sizeof (struct irb)); 48 CIO_HEX_EVENT(0, irb, sizeof (struct irb));
50 } 49 }
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index cde822d8b5c8..0648ce5bb684 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -1741,7 +1741,7 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev,
1741 void *ptr; 1741 void *ptr;
1742 int available; 1742 int available;
1743 1743
1744 sprintf(dbf_text,"qfqs%4x",cdev->private->sch_no); 1744 sprintf(dbf_text,"qfqs%4x",cdev->private->schid.sch_no);
1745 QDIO_DBF_TEXT0(0,setup,dbf_text); 1745 QDIO_DBF_TEXT0(0,setup,dbf_text);
1746 for (i=0;i<no_input_qs;i++) { 1746 for (i=0;i<no_input_qs;i++) {
1747 q=irq_ptr->input_qs[i]; 1747 q=irq_ptr->input_qs[i];
@@ -2924,7 +2924,7 @@ qdio_establish_handle_irq(struct ccw_device *cdev, int cstat, int dstat)
2924 2924
2925 irq_ptr = cdev->private->qdio_data; 2925 irq_ptr = cdev->private->qdio_data;
2926 2926
2927 sprintf(dbf_text,"qehi%4x",cdev->private->sch_no); 2927 sprintf(dbf_text,"qehi%4x",cdev->private->schid.sch_no);
2928 QDIO_DBF_TEXT0(0,setup,dbf_text); 2928 QDIO_DBF_TEXT0(0,setup,dbf_text);
2929 QDIO_DBF_TEXT0(0,trace,dbf_text); 2929 QDIO_DBF_TEXT0(0,trace,dbf_text);
2930 2930
@@ -2943,7 +2943,7 @@ qdio_initialize(struct qdio_initialize *init_data)
2943 int rc; 2943 int rc;
2944 char dbf_text[15]; 2944 char dbf_text[15];
2945 2945
2946 sprintf(dbf_text,"qini%4x",init_data->cdev->private->sch_no); 2946 sprintf(dbf_text,"qini%4x",init_data->cdev->private->schid.sch_no);
2947 QDIO_DBF_TEXT0(0,setup,dbf_text); 2947 QDIO_DBF_TEXT0(0,setup,dbf_text);
2948 QDIO_DBF_TEXT0(0,trace,dbf_text); 2948 QDIO_DBF_TEXT0(0,trace,dbf_text);
2949 2949
@@ -2964,7 +2964,7 @@ qdio_allocate(struct qdio_initialize *init_data)
2964 struct qdio_irq *irq_ptr; 2964 struct qdio_irq *irq_ptr;
2965 char dbf_text[15]; 2965 char dbf_text[15];
2966 2966
2967 sprintf(dbf_text,"qalc%4x",init_data->cdev->private->sch_no); 2967 sprintf(dbf_text,"qalc%4x",init_data->cdev->private->schid.sch_no);
2968 QDIO_DBF_TEXT0(0,setup,dbf_text); 2968 QDIO_DBF_TEXT0(0,setup,dbf_text);
2969 QDIO_DBF_TEXT0(0,trace,dbf_text); 2969 QDIO_DBF_TEXT0(0,trace,dbf_text);
2970 if ( (init_data->no_input_qs>QDIO_MAX_QUEUES_PER_IRQ) || 2970 if ( (init_data->no_input_qs>QDIO_MAX_QUEUES_PER_IRQ) ||
@@ -3187,7 +3187,7 @@ qdio_establish(struct qdio_initialize *init_data)
3187 tiqdio_set_delay_target(irq_ptr,TIQDIO_DELAY_TARGET); 3187 tiqdio_set_delay_target(irq_ptr,TIQDIO_DELAY_TARGET);
3188 } 3188 }
3189 3189
3190 sprintf(dbf_text,"qest%4x",cdev->private->sch_no); 3190 sprintf(dbf_text,"qest%4x",cdev->private->schid.sch_no);
3191 QDIO_DBF_TEXT0(0,setup,dbf_text); 3191 QDIO_DBF_TEXT0(0,setup,dbf_text);
3192 QDIO_DBF_TEXT0(0,trace,dbf_text); 3192 QDIO_DBF_TEXT0(0,trace,dbf_text);
3193 3193
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
index d27e4f6d7045..0d3660c28f7d 100644
--- a/drivers/sbus/char/bbc_envctrl.c
+++ b/drivers/sbus/char/bbc_envctrl.c
@@ -4,10 +4,8 @@
4 * Copyright (C) 2001 David S. Miller (davem@redhat.com) 4 * Copyright (C) 2001 David S. Miller (davem@redhat.com)
5 */ 5 */
6 6
7#include <linux/kernel.h>
8#include <linux/kthread.h> 7#include <linux/kthread.h>
9#include <linux/sched.h> 8#include <linux/syscalls.h>
10#include <linux/slab.h>
11#include <linux/delay.h> 9#include <linux/delay.h>
12#include <asm/oplib.h> 10#include <asm/oplib.h>
13#include <asm/ebus.h> 11#include <asm/ebus.h>
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index 728a133d0fc5..6b6a855f3795 100644
--- a/drivers/sbus/char/envctrl.c
+++ b/drivers/sbus/char/envctrl.c
@@ -20,16 +20,12 @@
20 */ 20 */
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/sched.h> 23#include <linux/init.h>
24#include <linux/kthread.h> 24#include <linux/kthread.h>
25#include <linux/errno.h>
26#include <linux/delay.h> 25#include <linux/delay.h>
27#include <linux/ioport.h> 26#include <linux/ioport.h>
28#include <linux/init.h>
29#include <linux/miscdevice.h> 27#include <linux/miscdevice.h>
30#include <linux/mm.h> 28#include <linux/syscalls.h>
31#include <linux/slab.h>
32#include <linux/kernel.h>
33 29
34#include <asm/ebus.h> 30#include <asm/ebus.h>
35#include <asm/uaccess.h> 31#include <asm/uaccess.h>
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index a0d1cee0be77..306f46b85a55 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -238,7 +238,7 @@
238#include <linux/module.h> 238#include <linux/module.h>
239#include <linux/sched.h> 239#include <linux/sched.h>
240#include <asm/irq.h> 240#include <asm/irq.h>
241#include <asm/io.h> 241#include <linux/io.h>
242#include <linux/blkdev.h> 242#include <linux/blkdev.h>
243#include <asm/system.h> 243#include <asm/system.h>
244#include <linux/errno.h> 244#include <linux/errno.h>
diff --git a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c
index 0d5713dfa204..54756722dd5f 100644
--- a/drivers/scsi/dtc.c
+++ b/drivers/scsi/dtc.c
@@ -82,7 +82,7 @@
82#include <linux/string.h> 82#include <linux/string.h>
83#include <linux/init.h> 83#include <linux/init.h>
84#include <linux/interrupt.h> 84#include <linux/interrupt.h>
85#include <asm/io.h> 85#include <linux/io.h>
86#include "scsi.h" 86#include "scsi.h"
87#include <scsi/scsi_host.h> 87#include <scsi/scsi_host.h>
88#include "dtc.h" 88#include "dtc.h"
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index 41b05fc45380..72794a7b6dcc 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -278,9 +278,9 @@
278#include <linux/pci.h> 278#include <linux/pci.h>
279#include <linux/stat.h> 279#include <linux/stat.h>
280#include <linux/delay.h> 280#include <linux/delay.h>
281#include <linux/io.h>
281#include <scsi/scsicam.h> 282#include <scsi/scsicam.h>
282 283
283#include <asm/io.h>
284#include <asm/system.h> 284#include <asm/system.h>
285 285
286#include <scsi/scsi.h> 286#include <scsi/scsi.h>
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index c0edb662d863..7bac86dda88f 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -884,7 +884,7 @@ megaraid_init_mbox(adapter_t *adapter)
884 884
885 if (((magic64 == HBA_SIGNATURE_64_BIT) && 885 if (((magic64 == HBA_SIGNATURE_64_BIT) &&
886 ((adapter->pdev->subsystem_device != 886 ((adapter->pdev->subsystem_device !=
887 PCI_SUBSYS_ID_MEGARAID_SATA_150_6) || 887 PCI_SUBSYS_ID_MEGARAID_SATA_150_6) &&
888 (adapter->pdev->subsystem_device != 888 (adapter->pdev->subsystem_device !=
889 PCI_SUBSYS_ID_MEGARAID_SATA_150_4))) || 889 PCI_SUBSYS_ID_MEGARAID_SATA_150_4))) ||
890 (adapter->pdev->vendor == PCI_VENDOR_ID_LSI_LOGIC && 890 (adapter->pdev->vendor == PCI_VENDOR_ID_LSI_LOGIC &&
diff --git a/drivers/scsi/seagate.c b/drivers/scsi/seagate.c
index 8ff1f2866f7b..5ffec2721b28 100644
--- a/drivers/scsi/seagate.c
+++ b/drivers/scsi/seagate.c
@@ -97,8 +97,8 @@
97#include <linux/blkdev.h> 97#include <linux/blkdev.h>
98#include <linux/stat.h> 98#include <linux/stat.h>
99#include <linux/delay.h> 99#include <linux/delay.h>
100#include <linux/io.h>
100 101
101#include <asm/io.h>
102#include <asm/system.h> 102#include <asm/system.h>
103#include <asm/uaccess.h> 103#include <asm/uaccess.h>
104 104
diff --git a/drivers/scsi/t128.c b/drivers/scsi/t128.c
index 2df6747cb76f..0b7a70f61e0d 100644
--- a/drivers/scsi/t128.c
+++ b/drivers/scsi/t128.c
@@ -109,7 +109,7 @@
109#include <asm/system.h> 109#include <asm/system.h>
110#include <linux/signal.h> 110#include <linux/signal.h>
111#include <linux/sched.h> 111#include <linux/sched.h>
112#include <asm/io.h> 112#include <linux/io.h>
113#include <linux/blkdev.h> 113#include <linux/blkdev.h>
114#include <linux/interrupt.h> 114#include <linux/interrupt.h>
115#include <linux/stat.h> 115#include <linux/stat.h>
diff --git a/drivers/scsi/wd7000.c b/drivers/scsi/wd7000.c
index 331e1cf159b0..30be76514c43 100644
--- a/drivers/scsi/wd7000.c
+++ b/drivers/scsi/wd7000.c
@@ -178,10 +178,10 @@
178#include <linux/blkdev.h> 178#include <linux/blkdev.h>
179#include <linux/init.h> 179#include <linux/init.h>
180#include <linux/stat.h> 180#include <linux/stat.h>
181#include <linux/io.h>
181 182
182#include <asm/system.h> 183#include <asm/system.h>
183#include <asm/dma.h> 184#include <asm/dma.h>
184#include <asm/io.h>
185 185
186#include <scsi/scsi.h> 186#include <scsi/scsi.h>
187#include <scsi/scsi_cmnd.h> 187#include <scsi/scsi_cmnd.h>
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index 98ce88d80207..ff4fa25f9fd1 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -2935,7 +2935,7 @@ static void __devexit ioc4_serial_exit(void)
2935 uart_unregister_driver(&ioc4_uart_rs422); 2935 uart_unregister_driver(&ioc4_uart_rs422);
2936} 2936}
2937 2937
2938module_init(ioc4_serial_init); 2938late_initcall(ioc4_serial_init); /* Call only after tty init is done */
2939module_exit(ioc4_serial_exit); 2939module_exit(ioc4_serial_exit);
2940 2940
2941MODULE_AUTHOR("Pat Gefre - Silicon Graphics Inc. (SGI) <pfg@sgi.com>"); 2941MODULE_AUTHOR("Pat Gefre - Silicon Graphics Inc. (SGI) <pfg@sgi.com>");
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 266aa325569e..cfcc3caf49d8 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -808,7 +808,7 @@ static int sci_request_irq(struct sci_port *port)
808 } 808 }
809 809
810 if (request_irq(port->irqs[0], sci_mpxed_interrupt, 810 if (request_irq(port->irqs[0], sci_mpxed_interrupt,
811 SA_INTERRUPT, "sci", port)) { 811 IRQF_DISABLED, "sci", port)) {
812 printk(KERN_ERR "sci: Cannot allocate irq.\n"); 812 printk(KERN_ERR "sci: Cannot allocate irq.\n");
813 return -ENODEV; 813 return -ENODEV;
814 } 814 }
@@ -817,7 +817,7 @@ static int sci_request_irq(struct sci_port *port)
817 if (!port->irqs[i]) 817 if (!port->irqs[i])
818 continue; 818 continue;
819 if (request_irq(port->irqs[i], handlers[i], 819 if (request_irq(port->irqs[i], handlers[i],
820 SA_INTERRUPT, desc[i], port)) { 820 IRQF_DISABLED, desc[i], port)) {
821 printk(KERN_ERR "sci: Cannot allocate irq.\n"); 821 printk(KERN_ERR "sci: Cannot allocate irq.\n");
822 return -ENODEV; 822 return -ENODEV;
823 } 823 }
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index 73dd2eedaaad..b2cc703b2b9e 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -1182,7 +1182,7 @@ static int __init sunzilog_console_setup(struct console *con, char *options)
1182 return 0; 1182 return 0;
1183} 1183}
1184 1184
1185static struct console sunzilog_console = { 1185static struct console sunzilog_console_ops = {
1186 .name = "ttyS", 1186 .name = "ttyS",
1187 .write = sunzilog_console_write, 1187 .write = sunzilog_console_write,
1188 .device = uart_console_device, 1188 .device = uart_console_device,
@@ -1208,10 +1208,10 @@ static inline struct console *SUNZILOG_CONSOLE(void)
1208 if (i == NUM_CHANNELS) 1208 if (i == NUM_CHANNELS)
1209 return NULL; 1209 return NULL;
1210 1210
1211 sunzilog_console.index = i; 1211 sunzilog_console_ops.index = i;
1212 sunzilog_port_table[i].flags |= SUNZILOG_FLAG_IS_CONS; 1212 sunzilog_port_table[i].flags |= SUNZILOG_FLAG_IS_CONS;
1213 1213
1214 return &sunzilog_console; 1214 return &sunzilog_console_ops;
1215} 1215}
1216 1216
1217#else 1217#else
diff --git a/drivers/sn/Kconfig b/drivers/sn/Kconfig
index a34731625877..c66ba9ad833d 100644
--- a/drivers/sn/Kconfig
+++ b/drivers/sn/Kconfig
@@ -5,19 +5,6 @@
5menu "SN Devices" 5menu "SN Devices"
6 depends on SGI_SN 6 depends on SGI_SN
7 7
8config SGI_IOC4
9 tristate "SGI IOC4 Base IO support"
10 depends on MMTIMER
11 default m
12 ---help---
13 This option enables basic support for the SGI IOC4-based Base IO
14 controller card. This option does not enable any specific
15 functions on such a card, but provides necessary infrastructure
16 for other drivers to utilize.
17
18 If you have an SGI Altix with an IOC4-based
19 I/O controller say Y. Otherwise say N.
20
21config SGI_IOC3 8config SGI_IOC3
22 tristate "SGI IOC3 Base IO support" 9 tristate "SGI IOC3 Base IO support"
23 default m 10 default m
diff --git a/drivers/sn/Makefile b/drivers/sn/Makefile
index 2cda011597c0..693db8bb8d9c 100644
--- a/drivers/sn/Makefile
+++ b/drivers/sn/Makefile
@@ -3,5 +3,4 @@
3# 3#
4# 4#
5 5
6obj-$(CONFIG_SGI_IOC4) += ioc4.o
7obj-$(CONFIG_SGI_IOC3) += ioc3.o 6obj-$(CONFIG_SGI_IOC3) += ioc3.o
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index daaa486159cf..7a43020fa583 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -701,7 +701,6 @@ config FB_NVIDIA
701 depends on FB && PCI 701 depends on FB && PCI
702 select I2C_ALGOBIT if FB_NVIDIA_I2C 702 select I2C_ALGOBIT if FB_NVIDIA_I2C
703 select I2C if FB_NVIDIA_I2C 703 select I2C if FB_NVIDIA_I2C
704 select FB_DDC if FB_NVIDIA_I2C
705 select FB_MODE_HELPERS 704 select FB_MODE_HELPERS
706 select FB_CFB_FILLRECT 705 select FB_CFB_FILLRECT
707 select FB_CFB_COPYAREA 706 select FB_CFB_COPYAREA
diff --git a/drivers/video/nvidia/nv_i2c.c b/drivers/video/nvidia/nv_i2c.c
index e48de3c9fd13..19eef3a09023 100644
--- a/drivers/video/nvidia/nv_i2c.c
+++ b/drivers/video/nvidia/nv_i2c.c
@@ -160,12 +160,51 @@ void nvidia_delete_i2c_busses(struct nvidia_par *par)
160 160
161} 161}
162 162
163static u8 *nvidia_do_probe_i2c_edid(struct nvidia_i2c_chan *chan)
164{
165 u8 start = 0x0;
166 struct i2c_msg msgs[] = {
167 {
168 .addr = 0x50,
169 .len = 1,
170 .buf = &start,
171 }, {
172 .addr = 0x50,
173 .flags = I2C_M_RD,
174 .len = EDID_LENGTH,
175 },
176 };
177 u8 *buf;
178
179 if (!chan->par)
180 return NULL;
181
182 buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
183 if (!buf) {
184 dev_warn(&chan->par->pci_dev->dev, "Out of memory!\n");
185 return NULL;
186 }
187 msgs[1].buf = buf;
188
189 if (i2c_transfer(&chan->adapter, msgs, 2) == 2)
190 return buf;
191 dev_dbg(&chan->par->pci_dev->dev, "Unable to read EDID block.\n");
192 kfree(buf);
193 return NULL;
194}
195
163int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid) 196int nvidia_probe_i2c_connector(struct fb_info *info, int conn, u8 **out_edid)
164{ 197{
165 struct nvidia_par *par = info->par; 198 struct nvidia_par *par = info->par;
166 u8 *edid; 199 u8 *edid = NULL;
167 200 int i;
168 edid = fb_ddc_read(&par->chan[conn - 1].adapter); 201
202 for (i = 0; i < 3; i++) {
203 /* Do the real work */
204 edid = nvidia_do_probe_i2c_edid(&par->chan[conn - 1]);
205 if (edid)
206 break;
207 }
169 208
170 if (!edid && conn == 1) { 209 if (!edid && conn == 1) {
171 /* try to get from firmware */ 210 /* try to get from firmware */
diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig
index 27c9d05d03ef..c287a9ae4fdd 100644
--- a/drivers/w1/Kconfig
+++ b/drivers/w1/Kconfig
@@ -2,7 +2,6 @@ menu "Dallas's 1-wire bus"
2 2
3config W1 3config W1
4 tristate "Dallas's 1-wire support" 4 tristate "Dallas's 1-wire support"
5 depends on CONNECTOR
6 ---help--- 5 ---help---
7 Dallas' 1-wire bus is useful to connect slow 1-pin devices 6 Dallas' 1-wire bus is useful to connect slow 1-pin devices
8 such as iButtons and thermal sensors. 7 such as iButtons and thermal sensors.