aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2007-08-28 01:56:11 -0400
committerPaul Mackerras <paulus@samba.org>2007-08-28 01:56:11 -0400
commit35438c4327df18dbf5e7f597b69299119f4a14de (patch)
treea4589d731015db93f2eba8f84ffb1f48a8084020 /drivers
parent2f6c9d961081dc7b109eb19166244bcb2a5dfc28 (diff)
parentb07d68b5ca4d55a16fab223d63d5fb36f89ff42f (diff)
Merge branch 'linux-2.6' into for-2.6.24
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/Kconfig18
-rw-r--r--drivers/acpi/ac.c5
-rw-r--r--drivers/acpi/asus_acpi.c2
-rw-r--r--drivers/acpi/battery.c52
-rw-r--r--drivers/acpi/bus.c10
-rw-r--r--drivers/acpi/button.c2
-rw-r--r--drivers/acpi/ec.c47
-rw-r--r--drivers/acpi/event.c22
-rw-r--r--drivers/acpi/hardware/hwsleep.c19
-rw-r--r--drivers/acpi/namespace/nsxfeval.c2
-rw-r--r--drivers/acpi/processor_core.c13
-rw-r--r--drivers/acpi/processor_idle.c32
-rw-r--r--drivers/acpi/sbs.c3
-rw-r--r--drivers/acpi/scan.c5
-rw-r--r--drivers/acpi/sleep/main.c2
-rw-r--r--drivers/acpi/tables/tbutils.c71
-rw-r--r--drivers/acpi/thermal.c67
-rw-r--r--drivers/acpi/utilities/utglobal.c1
-rw-r--r--drivers/acpi/video.c109
-rw-r--r--drivers/ata/ata_piix.c9
-rw-r--r--drivers/ata/libata-core.c9
-rw-r--r--drivers/ata/pata_artop.c19
-rw-r--r--drivers/ata/pata_hpt37x.c20
-rw-r--r--drivers/ata/pata_hpt3x2n.c8
-rw-r--r--drivers/ata/pata_isapnp.c2
-rw-r--r--drivers/ata/pata_it821x.c2
-rw-r--r--drivers/ata/pata_pdc2027x.c18
-rw-r--r--drivers/ata/pata_sis.c1
-rw-r--r--drivers/ata/pata_via.c5
-rw-r--r--drivers/ata/sata_mv.c3
-rw-r--r--drivers/atm/Kconfig5
-rw-r--r--drivers/auxdisplay/Kconfig5
-rw-r--r--drivers/auxdisplay/cfag12864b.c2
-rw-r--r--drivers/block/Kconfig7
-rw-r--r--drivers/block/lguest_blk.c9
-rw-r--r--drivers/block/sunvdc.c2
-rw-r--r--drivers/char/agp/amd-k7-agp.c2
-rw-r--r--drivers/char/agp/ati-agp.c3
-rw-r--r--drivers/char/agp/efficeon-agp.c2
-rw-r--r--drivers/char/agp/hp-agp.c1
-rw-r--r--drivers/char/agp/i460-agp.c4
-rw-r--r--drivers/char/agp/intel-agp.c14
-rw-r--r--drivers/char/agp/nvidia-agp.c3
-rw-r--r--drivers/char/agp/via-agp.c5
-rw-r--r--drivers/char/drm/drm_bufs.c13
-rw-r--r--drivers/char/drm/via_dmablit.c2
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c2
-rw-r--r--drivers/char/keyboard.c4
-rw-r--r--drivers/char/lcd.c1
-rw-r--r--drivers/char/sonypi.c2
-rw-r--r--drivers/char/synclink_gt.c4
-rw-r--r--drivers/char/tpm/tpm.c2
-rw-r--r--drivers/char/tpm/tpm.h2
-rw-r--r--drivers/char/tpm/tpm_atmel.c2
-rw-r--r--drivers/char/tpm/tpm_atmel.h2
-rw-r--r--drivers/char/tpm/tpm_bios.c2
-rw-r--r--drivers/char/tpm/tpm_nsc.c2
-rw-r--r--drivers/char/tpm/tpm_tis.c2
-rw-r--r--drivers/char/tty_io.c6
-rw-r--r--drivers/char/watchdog/alim1535_wdt.c7
-rw-r--r--drivers/char/watchdog/eurotechwdt.c13
-rw-r--r--drivers/crypto/Kconfig5
-rw-r--r--drivers/dma/ioatdma.c25
-rw-r--r--drivers/dma/ioatdma.h3
-rw-r--r--drivers/firewire/fw-card.c6
-rw-r--r--drivers/firewire/fw-sbp2.c49
-rw-r--r--drivers/hid/Kconfig5
-rw-r--r--drivers/hwmon/smsc47m1.c2
-rw-r--r--drivers/hwmon/w83627ehf.c56
-rw-r--r--drivers/hwmon/w83781d.c4
-rw-r--r--drivers/ide/Kconfig12
-rw-r--r--drivers/ide/cris/ide-cris.c2
-rw-r--r--drivers/ide/ide-disk.c18
-rw-r--r--drivers/ide/ide-dma.c45
-rw-r--r--drivers/ide/ide-iops.c45
-rw-r--r--drivers/ide/pci/cs5530.c8
-rw-r--r--drivers/ide/pci/hpt34x.c6
-rw-r--r--drivers/ide/pci/ns87415.c9
-rw-r--r--drivers/ide/pci/pdc202xx_new.c10
-rw-r--r--drivers/ide/pci/pdc202xx_old.c9
-rw-r--r--drivers/ide/pci/triflex.c3
-rw-r--r--drivers/ide/ppc/pmac.c14
-rw-r--r--drivers/ieee1394/sbp2.c14
-rw-r--r--drivers/infiniband/core/agent.c24
-rw-r--r--drivers/infiniband/core/agent.h6
-rw-r--r--drivers/infiniband/core/device.c2
-rw-r--r--drivers/infiniband/core/mad.c25
-rw-r--r--drivers/infiniband/core/mad_rmpp.c8
-rw-r--r--drivers/infiniband/core/sa_query.c4
-rw-r--r--drivers/infiniband/core/umem.c5
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cm.c16
-rw-r--r--drivers/infiniband/hw/mlx4/cq.c2
-rw-r--r--drivers/infiniband/hw/mlx4/mad.c2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_verbs.c1
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c31
-rw-r--r--drivers/input/misc/Kconfig1
-rw-r--r--drivers/isdn/hisax/hfc_usb.c603
-rw-r--r--drivers/isdn/hisax/hfc_usb.h130
-rw-r--r--drivers/isdn/i4l/isdn_bsdcomp.c5
-rw-r--r--drivers/isdn/i4l/isdn_common.c2
-rw-r--r--drivers/kvm/Kconfig5
-rw-r--r--drivers/kvm/kvm_main.c4
-rw-r--r--drivers/lguest/Kconfig2
-rw-r--r--drivers/macintosh/Kconfig5
-rw-r--r--drivers/macintosh/adb.c4
-rw-r--r--drivers/macintosh/mac_hid.c1
-rw-r--r--drivers/macintosh/via-pmu.c34
-rw-r--r--drivers/macintosh/via-pmu68k.c240
-rw-r--r--drivers/md/Kconfig2
-rw-r--r--drivers/md/dm-mpath-rdac.c2
-rw-r--r--drivers/md/raid1.c25
-rw-r--r--drivers/media/dvb/b2c2/flexcop-i2c.c7
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c5
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c2
-rw-r--r--drivers/media/video/cafe_ccic.c35
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c1
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c3
-rw-r--r--drivers/media/video/ov7670.c5
-rw-r--r--drivers/media/video/pwc/pwc-if.c52
-rw-r--r--drivers/media/video/pwc/pwc.h1
-rw-r--r--drivers/misc/Kconfig5
-rw-r--r--drivers/misc/asus-laptop.c5
-rw-r--r--drivers/misc/sony-laptop.c28
-rw-r--r--drivers/misc/thinkpad_acpi.c26
-rw-r--r--drivers/mmc/core/bus.c4
-rw-r--r--drivers/mmc/core/host.c4
-rw-r--r--drivers/mmc/host/sdhci.c53
-rw-r--r--drivers/mmc/host/sdhci.h1
-rw-r--r--drivers/net/Kconfig15
-rw-r--r--drivers/net/bsd_comp.c6
-rw-r--r--drivers/net/dm9000.c25
-rw-r--r--drivers/net/ehea/ehea_main.c8
-rw-r--r--drivers/net/ehea/ehea_qmr.c6
-rw-r--r--drivers/net/eql.c2
-rw-r--r--drivers/net/forcedeth.c12
-rw-r--r--drivers/net/irda/kingsun-sir.c4
-rw-r--r--drivers/net/meth.c2
-rw-r--r--drivers/net/mlx4/reset.c3
-rw-r--r--drivers/net/myri10ge/myri10ge.c34
-rw-r--r--drivers/net/phy/phy_device.c2
-rw-r--r--drivers/net/ppp_generic.c2
-rw-r--r--drivers/net/sgiseeq.c4
-rw-r--r--drivers/net/sky2.c68
-rw-r--r--drivers/net/sky2.h3
-rw-r--r--drivers/net/slip.c2
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c7
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c4
-rw-r--r--drivers/pci/pci.h8
-rw-r--r--drivers/pci/probe.c18
-rw-r--r--drivers/pci/quirks.c7
-rw-r--r--drivers/pnp/card.c16
-rw-r--r--drivers/pnp/core.c7
-rw-r--r--drivers/pnp/driver.c6
-rw-r--r--drivers/pnp/interface.c9
-rw-r--r--drivers/pnp/isapnp/core.c24
-rw-r--r--drivers/pnp/isapnp/proc.c45
-rw-r--r--drivers/pnp/manager.c27
-rw-r--r--drivers/pnp/pnpacpi/core.c4
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c23
-rw-r--r--drivers/pnp/pnpbios/core.c44
-rw-r--r--drivers/pnp/pnpbios/proc.c2
-rw-r--r--drivers/pnp/pnpbios/rsparser.c9
-rw-r--r--drivers/pnp/resource.c26
-rw-r--r--drivers/rtc/rtc-m41t80.c2
-rw-r--r--drivers/rtc/rtc-max6902.c6
-rw-r--r--drivers/rtc/rtc-rs5c348.c2
-rw-r--r--drivers/s390/block/dasd_diag.c1
-rw-r--r--drivers/s390/char/raw3270.c1
-rw-r--r--drivers/s390/char/vmur.c250
-rw-r--r--drivers/s390/char/vmur.h1
-rw-r--r--drivers/s390/cio/cmf.c10
-rw-r--r--drivers/s390/cio/device.c5
-rw-r--r--drivers/s390/cio/device_id.c48
-rw-r--r--drivers/s390/cio/qdio.c5
-rw-r--r--drivers/scsi/Kconfig10
-rw-r--r--drivers/serial/8250.c85
-rw-r--r--drivers/serial/8250_pci.c192
-rw-r--r--drivers/serial/serial_core.c7
-rw-r--r--drivers/serial/serial_txx9.c14
-rw-r--r--drivers/serial/sunsu.c5
-rw-r--r--drivers/serial/sunzilog.c14
-rw-r--r--drivers/usb/Kconfig4
-rw-r--r--drivers/usb/atm/cxacru.c3
-rw-r--r--drivers/usb/atm/ueagle-atm.c5
-rw-r--r--drivers/usb/class/cdc-acm.c12
-rw-r--r--drivers/usb/core/driver.c9
-rw-r--r--drivers/usb/core/hub.c3
-rw-r--r--drivers/usb/core/message.c28
-rw-r--r--drivers/usb/core/quirks.c12
-rw-r--r--drivers/usb/gadget/dummy_hcd.c2
-rw-r--r--drivers/usb/gadget/file_storage.c10
-rw-r--r--drivers/usb/gadget/fsl_usb2_udc.c77
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c4
-rw-r--r--drivers/usb/host/Kconfig2
-rw-r--r--drivers/usb/host/ehci-au1xxx.c5
-rw-r--r--drivers/usb/host/ehci-hcd.c67
-rw-r--r--drivers/usb/host/ehci-mem.c3
-rw-r--r--drivers/usb/host/ehci-ppc-soc.c22
-rw-r--r--drivers/usb/host/ehci-q.c4
-rw-r--r--drivers/usb/host/ehci-sched.c127
-rw-r--r--drivers/usb/host/ehci.h14
-rw-r--r--drivers/usb/host/ohci-dbg.c2
-rw-r--r--drivers/usb/host/r8a66597-hcd.c2
-rw-r--r--drivers/usb/host/u132-hcd.c3
-rw-r--r--drivers/usb/serial/airprime.c1
-rw-r--r--drivers/usb/serial/belkin_sa.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.h3
-rw-r--r--drivers/usb/serial/garmin_gps.c93
-rw-r--r--drivers/usb/serial/ipaq.c1
-rw-r--r--drivers/usb/serial/option.c10
-rw-r--r--drivers/usb/serial/oti6858.c10
-rw-r--r--drivers/usb/serial/safe_serial.c6
-rw-r--r--drivers/usb/serial/visor.c2
-rw-r--r--drivers/usb/serial/visor.h3
-rw-r--r--drivers/usb/storage/unusual_devs.h2
-rw-r--r--drivers/usb/storage/usb.c33
-rw-r--r--drivers/usb/storage/usb.h1
-rw-r--r--drivers/video/au1100fb.c92
-rw-r--r--drivers/video/bw2.c22
-rw-r--r--drivers/video/cg3.c17
-rw-r--r--drivers/video/console/Kconfig2
-rw-r--r--drivers/video/console/newport_con.c3
-rw-r--r--drivers/video/console/sticore.c14
-rw-r--r--drivers/video/imsttfb.c2
-rw-r--r--drivers/video/pxafb.c2
-rw-r--r--drivers/w1/w1_int.c10
-rw-r--r--drivers/zorro/zorro-sysfs.c2
228 files changed, 2279 insertions, 2108 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index f1372de4ce79..4875f0149eb4 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -68,6 +68,24 @@ config ACPI_PROCFS
68 68
69 Say N to delete /proc/acpi/ files that have moved to /sys/ 69 Say N to delete /proc/acpi/ files that have moved to /sys/
70 70
71config ACPI_PROC_EVENT
72 bool "Deprecated /proc/acpi/event support"
73 depends on PROC_FS
74 default y
75 ---help---
76 A user-space daemon, acpi, typically read /proc/acpi/event
77 and handled all ACPI sub-system generated events.
78
79 These events are now delivered to user-space via
80 either the input layer, or as netlink events.
81
82 This build option enables the old code for legacy
83 user-space implementation. After some time, this will
84 be moved under CONFIG_ACPI_PROCFS, and then deleted.
85
86 Say Y here to retain the old behaviour. Say N if your
87 user-space is newer than kernel 2.6.23 (September 2007).
88
71config ACPI_AC 89config ACPI_AC
72 tristate "AC Adapter" 90 tristate "AC Adapter"
73 depends on X86 91 depends on X86
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index d8b35093527a..26d70702b313 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -204,7 +204,10 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
204 case ACPI_NOTIFY_BUS_CHECK: 204 case ACPI_NOTIFY_BUS_CHECK:
205 case ACPI_NOTIFY_DEVICE_CHECK: 205 case ACPI_NOTIFY_DEVICE_CHECK:
206 acpi_ac_get_state(ac); 206 acpi_ac_get_state(ac);
207 acpi_bus_generate_event(device, event, (u32) ac->state); 207 acpi_bus_generate_proc_event(device, event, (u32) ac->state);
208 acpi_bus_generate_netlink_event(device->pnp.device_class,
209 device->dev.bus_id, event,
210 (u32) ac->state);
208 break; 211 break;
209 default: 212 default:
210 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 213 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index 86fd142f4bf3..d915fec9bf63 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -1069,7 +1069,7 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
1069 hotk->brightness = (event & ~((u32) BR_DOWN)); 1069 hotk->brightness = (event & ~((u32) BR_DOWN));
1070 } 1070 }
1071 1071
1072 acpi_bus_generate_event(hotk->device, event, 1072 acpi_bus_generate_proc_event(hotk->device, event,
1073 hotk->event_count[event % 128]++); 1073 hotk->event_count[event % 128]++);
1074 1074
1075 return; 1075 return;
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index d7b499fe0cd9..9b2c0f74f869 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -113,7 +113,7 @@ struct acpi_battery_info {
113 acpi_string oem_info; 113 acpi_string oem_info;
114}; 114};
115 115
116enum acpi_battery_files { 116enum acpi_battery_files{
117 ACPI_BATTERY_INFO = 0, 117 ACPI_BATTERY_INFO = 0,
118 ACPI_BATTERY_STATE, 118 ACPI_BATTERY_STATE,
119 ACPI_BATTERY_ALARM, 119 ACPI_BATTERY_ALARM,
@@ -129,14 +129,13 @@ struct acpi_battery_flags {
129}; 129};
130 130
131struct acpi_battery { 131struct acpi_battery {
132 struct mutex mutex;
132 struct acpi_device *device; 133 struct acpi_device *device;
133 struct acpi_battery_flags flags; 134 struct acpi_battery_flags flags;
134 struct acpi_buffer bif_data; 135 struct acpi_buffer bif_data;
135 struct acpi_buffer bst_data; 136 struct acpi_buffer bst_data;
136 struct mutex lock;
137 unsigned long alarm; 137 unsigned long alarm;
138 unsigned long update_time[ACPI_BATTERY_NUMFILES]; 138 unsigned long update_time[ACPI_BATTERY_NUMFILES];
139
140}; 139};
141 140
142inline int acpi_battery_present(struct acpi_battery *battery) 141inline int acpi_battery_present(struct acpi_battery *battery)
@@ -236,10 +235,10 @@ static int acpi_battery_get_info(struct acpi_battery *battery)
236 return 0; 235 return 0;
237 236
238 /* Evaluate _BIF */ 237 /* Evaluate _BIF */
239 mutex_lock(&battery->lock); 238
240 status = acpi_evaluate_object(acpi_battery_handle(battery), "_BIF", 239 status =
241 NULL, &buffer); 240 acpi_evaluate_object(acpi_battery_handle(battery), "_BIF", NULL,
242 mutex_unlock(&battery->lock); 241 &buffer);
243 if (ACPI_FAILURE(status)) { 242 if (ACPI_FAILURE(status)) {
244 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); 243 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
245 return -ENODEV; 244 return -ENODEV;
@@ -286,10 +285,10 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
286 return 0; 285 return 0;
287 286
288 /* Evaluate _BST */ 287 /* Evaluate _BST */
289 mutex_lock(&battery->lock); 288
290 status = acpi_evaluate_object(acpi_battery_handle(battery), "_BST", 289 status =
291 NULL, &buffer); 290 acpi_evaluate_object(acpi_battery_handle(battery), "_BST", NULL,
292 mutex_unlock(&battery->lock); 291 &buffer);
293 if (ACPI_FAILURE(status)) { 292 if (ACPI_FAILURE(status)) {
294 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST")); 293 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
295 return -ENODEV; 294 return -ENODEV;
@@ -337,10 +336,9 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery,
337 336
338 arg0.integer.value = alarm; 337 arg0.integer.value = alarm;
339 338
340 mutex_lock(&battery->lock); 339 status =
341 status = acpi_evaluate_object(acpi_battery_handle(battery), "_BTP", 340 acpi_evaluate_object(acpi_battery_handle(battery), "_BTP",
342 &arg_list, NULL); 341 &arg_list, NULL);
343 mutex_unlock(&battery->lock);
344 if (ACPI_FAILURE(status)) 342 if (ACPI_FAILURE(status))
345 return -ENODEV; 343 return -ENODEV;
346 344
@@ -660,6 +658,8 @@ acpi_battery_write_alarm(struct file *file,
660 if (!battery || (count > sizeof(alarm_string) - 1)) 658 if (!battery || (count > sizeof(alarm_string) - 1))
661 return -EINVAL; 659 return -EINVAL;
662 660
661 mutex_lock(&battery->mutex);
662
663 result = acpi_battery_update(battery, 1, &update_result); 663 result = acpi_battery_update(battery, 1, &update_result);
664 if (result) { 664 if (result) {
665 result = -ENODEV; 665 result = -ENODEV;
@@ -688,7 +688,9 @@ acpi_battery_write_alarm(struct file *file,
688 acpi_battery_check_result(battery, result); 688 acpi_battery_check_result(battery, result);
689 689
690 if (!result) 690 if (!result)
691 return count; 691 result = count;
692
693 mutex_unlock(&battery->mutex);
692 694
693 return result; 695 return result;
694} 696}
@@ -712,6 +714,8 @@ static int acpi_battery_read(int fid, struct seq_file *seq)
712 int update_result = ACPI_BATTERY_NONE_UPDATE; 714 int update_result = ACPI_BATTERY_NONE_UPDATE;
713 int update = 0; 715 int update = 0;
714 716
717 mutex_lock(&battery->mutex);
718
715 update = (get_seconds() - battery->update_time[fid] >= update_time); 719 update = (get_seconds() - battery->update_time[fid] >= update_time);
716 update = (update | battery->flags.update[fid]); 720 update = (update | battery->flags.update[fid]);
717 721
@@ -729,6 +733,7 @@ static int acpi_battery_read(int fid, struct seq_file *seq)
729 result = acpi_read_funcs[fid].print(seq, result); 733 result = acpi_read_funcs[fid].print(seq, result);
730 acpi_battery_check_result(battery, result); 734 acpi_battery_check_result(battery, result);
731 battery->flags.update[fid] = result; 735 battery->flags.update[fid] = result;
736 mutex_unlock(&battery->mutex);
732 return result; 737 return result;
733} 738}
734 739
@@ -867,8 +872,11 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
867 case ACPI_NOTIFY_DEVICE_CHECK: 872 case ACPI_NOTIFY_DEVICE_CHECK:
868 device = battery->device; 873 device = battery->device;
869 acpi_battery_notify_update(battery); 874 acpi_battery_notify_update(battery);
870 acpi_bus_generate_event(device, event, 875 acpi_bus_generate_proc_event(device, event,
871 acpi_battery_present(battery)); 876 acpi_battery_present(battery));
877 acpi_bus_generate_netlink_event(device->pnp.device_class,
878 device->dev.bus_id, event,
879 acpi_battery_present(battery));
872 break; 880 break;
873 default: 881 default:
874 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 882 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -892,7 +900,10 @@ static int acpi_battery_add(struct acpi_device *device)
892 if (!battery) 900 if (!battery)
893 return -ENOMEM; 901 return -ENOMEM;
894 902
895 mutex_init(&battery->lock); 903 mutex_init(&battery->mutex);
904
905 mutex_lock(&battery->mutex);
906
896 battery->device = device; 907 battery->device = device;
897 strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); 908 strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
898 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); 909 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
@@ -928,6 +939,7 @@ static int acpi_battery_add(struct acpi_device *device)
928 kfree(battery); 939 kfree(battery);
929 } 940 }
930 941
942 mutex_unlock(&battery->mutex);
931 943
932 return result; 944 return result;
933} 945}
@@ -942,6 +954,8 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
942 954
943 battery = acpi_driver_data(device); 955 battery = acpi_driver_data(device);
944 956
957 mutex_lock(&battery->mutex);
958
945 status = acpi_remove_notify_handler(device->handle, 959 status = acpi_remove_notify_handler(device->handle,
946 ACPI_ALL_NOTIFY, 960 ACPI_ALL_NOTIFY,
947 acpi_battery_notify); 961 acpi_battery_notify);
@@ -952,7 +966,9 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
952 966
953 kfree(battery->bst_data.pointer); 967 kfree(battery->bst_data.pointer);
954 968
955 mutex_destroy(&battery->lock); 969 mutex_unlock(&battery->mutex);
970
971 mutex_destroy(&battery->mutex);
956 972
957 kfree(battery); 973 kfree(battery);
958 974
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 6b2658c96242..9ba778a2b484 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -276,6 +276,7 @@ EXPORT_SYMBOL(acpi_bus_set_power);
276 Event Management 276 Event Management
277 -------------------------------------------------------------------------- */ 277 -------------------------------------------------------------------------- */
278 278
279#ifdef CONFIG_ACPI_PROC_EVENT
279static DEFINE_SPINLOCK(acpi_bus_event_lock); 280static DEFINE_SPINLOCK(acpi_bus_event_lock);
280 281
281LIST_HEAD(acpi_bus_event_list); 282LIST_HEAD(acpi_bus_event_list);
@@ -283,7 +284,7 @@ DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue);
283 284
284extern int event_is_open; 285extern int event_is_open;
285 286
286int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data) 287int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data)
287{ 288{
288 struct acpi_bus_event *event = NULL; 289 struct acpi_bus_event *event = NULL;
289 unsigned long flags = 0; 290 unsigned long flags = 0;
@@ -292,10 +293,6 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
292 if (!device) 293 if (!device)
293 return -EINVAL; 294 return -EINVAL;
294 295
295 if (acpi_bus_generate_genetlink_event(device, type, data))
296 printk(KERN_WARNING PREFIX
297 "Failed to generate an ACPI event via genetlink!\n");
298
299 /* drop event on the floor if no one's listening */ 296 /* drop event on the floor if no one's listening */
300 if (!event_is_open) 297 if (!event_is_open)
301 return 0; 298 return 0;
@@ -318,7 +315,7 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
318 return 0; 315 return 0;
319} 316}
320 317
321EXPORT_SYMBOL(acpi_bus_generate_event); 318EXPORT_SYMBOL(acpi_bus_generate_proc_event);
322 319
323int acpi_bus_receive_event(struct acpi_bus_event *event) 320int acpi_bus_receive_event(struct acpi_bus_event *event)
324{ 321{
@@ -364,6 +361,7 @@ int acpi_bus_receive_event(struct acpi_bus_event *event)
364} 361}
365 362
366EXPORT_SYMBOL(acpi_bus_receive_event); 363EXPORT_SYMBOL(acpi_bus_receive_event);
364#endif /* CONFIG_ACPI_PROC_EVENT */
367 365
368/* -------------------------------------------------------------------------- 366/* --------------------------------------------------------------------------
369 Notification Handling 367 Notification Handling
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 540581338ef5..2e79a3395ecf 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -284,7 +284,7 @@ static void acpi_button_notify(acpi_handle handle, u32 event, void *data)
284 } 284 }
285 input_sync(input); 285 input_sync(input);
286 286
287 acpi_bus_generate_event(button->device, event, 287 acpi_bus_generate_proc_event(button->device, event,
288 ++button->pushed); 288 ++button->pushed);
289 break; 289 break;
290 default: 290 default:
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 56bee9e065cf..43749c86861f 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -696,14 +696,6 @@ ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
696 return AE_CTRL_TERMINATE; 696 return AE_CTRL_TERMINATE;
697} 697}
698 698
699static void ec_remove_handlers(struct acpi_ec *ec)
700{
701 acpi_remove_address_space_handler(ec->handle,
702 ACPI_ADR_SPACE_EC,
703 &acpi_ec_space_handler);
704 acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
705}
706
707static int acpi_ec_add(struct acpi_device *device) 699static int acpi_ec_add(struct acpi_device *device)
708{ 700{
709 struct acpi_ec *ec = NULL; 701 struct acpi_ec *ec = NULL;
@@ -727,13 +719,16 @@ static int acpi_ec_add(struct acpi_device *device)
727 /* Check if we found the boot EC */ 719 /* Check if we found the boot EC */
728 if (boot_ec) { 720 if (boot_ec) {
729 if (boot_ec->gpe == ec->gpe) { 721 if (boot_ec->gpe == ec->gpe) {
730 ec_remove_handlers(boot_ec); 722 /* We might have incorrect info for GL at boot time */
731 mutex_destroy(&boot_ec->lock); 723 mutex_lock(&boot_ec->lock);
732 kfree(boot_ec); 724 boot_ec->global_lock = ec->global_lock;
733 first_ec = boot_ec = NULL; 725 /* Copy handlers from new ec into boot ec */
726 list_splice(&ec->list, &boot_ec->list);
727 mutex_unlock(&boot_ec->lock);
728 kfree(ec);
729 ec = boot_ec;
734 } 730 }
735 } 731 } else
736 if (!first_ec)
737 first_ec = ec; 732 first_ec = ec;
738 ec->handle = device->handle; 733 ec->handle = device->handle;
739 acpi_driver_data(device) = ec; 734 acpi_driver_data(device) = ec;
@@ -762,6 +757,9 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
762 if (ec == first_ec) 757 if (ec == first_ec)
763 first_ec = NULL; 758 first_ec = NULL;
764 759
760 /* Don't touch boot EC */
761 if (boot_ec != ec)
762 kfree(ec);
765 return 0; 763 return 0;
766} 764}
767 765
@@ -825,7 +823,9 @@ static int acpi_ec_start(struct acpi_device *device)
825 if (!ec) 823 if (!ec)
826 return -EINVAL; 824 return -EINVAL;
827 825
828 ret = ec_install_handlers(ec); 826 /* Boot EC is already working */
827 if (ec != boot_ec)
828 ret = ec_install_handlers(ec);
829 829
830 /* EC is fully operational, allow queries */ 830 /* EC is fully operational, allow queries */
831 atomic_set(&ec->query_pending, 0); 831 atomic_set(&ec->query_pending, 0);
@@ -835,6 +835,7 @@ static int acpi_ec_start(struct acpi_device *device)
835 835
836static int acpi_ec_stop(struct acpi_device *device, int type) 836static int acpi_ec_stop(struct acpi_device *device, int type)
837{ 837{
838 acpi_status status;
838 struct acpi_ec *ec; 839 struct acpi_ec *ec;
839 840
840 if (!device) 841 if (!device)
@@ -843,7 +844,21 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
843 ec = acpi_driver_data(device); 844 ec = acpi_driver_data(device);
844 if (!ec) 845 if (!ec)
845 return -EINVAL; 846 return -EINVAL;
846 ec_remove_handlers(ec); 847
848 /* Don't touch boot EC */
849 if (ec == boot_ec)
850 return 0;
851
852 status = acpi_remove_address_space_handler(ec->handle,
853 ACPI_ADR_SPACE_EC,
854 &acpi_ec_space_handler);
855 if (ACPI_FAILURE(status))
856 return -ENODEV;
857
858 status = acpi_remove_gpe_handler(NULL, ec->gpe, &acpi_ec_gpe_handler);
859 if (ACPI_FAILURE(status))
860 return -ENODEV;
861
847 return 0; 862 return 0;
848} 863}
849 864
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index 95637a4ff782..a2b9304596ce 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -17,6 +17,7 @@
17#define _COMPONENT ACPI_SYSTEM_COMPONENT 17#define _COMPONENT ACPI_SYSTEM_COMPONENT
18ACPI_MODULE_NAME("event"); 18ACPI_MODULE_NAME("event");
19 19
20#ifdef CONFIG_ACPI_PROC_EVENT
20/* Global vars for handling event proc entry */ 21/* Global vars for handling event proc entry */
21static DEFINE_SPINLOCK(acpi_system_event_lock); 22static DEFINE_SPINLOCK(acpi_system_event_lock);
22int event_is_open = 0; 23int event_is_open = 0;
@@ -106,6 +107,7 @@ static const struct file_operations acpi_system_event_ops = {
106 .release = acpi_system_close_event, 107 .release = acpi_system_close_event,
107 .poll = acpi_system_poll_event, 108 .poll = acpi_system_poll_event,
108}; 109};
110#endif /* CONFIG_ACPI_PROC_EVENT */
109 111
110#ifdef CONFIG_NET 112#ifdef CONFIG_NET
111static unsigned int acpi_event_seqnum; 113static unsigned int acpi_event_seqnum;
@@ -147,7 +149,8 @@ static struct genl_multicast_group acpi_event_mcgrp = {
147 .name = ACPI_GENL_MCAST_GROUP_NAME, 149 .name = ACPI_GENL_MCAST_GROUP_NAME,
148}; 150};
149 151
150int acpi_bus_generate_genetlink_event(struct acpi_device *device, 152int acpi_bus_generate_netlink_event(const char *device_class,
153 const char *bus_id,
151 u8 type, int data) 154 u8 type, int data)
152{ 155{
153 struct sk_buff *skb; 156 struct sk_buff *skb;
@@ -191,8 +194,8 @@ int acpi_bus_generate_genetlink_event(struct acpi_device *device,
191 194
192 memset(event, 0, sizeof(struct acpi_genl_event)); 195 memset(event, 0, sizeof(struct acpi_genl_event));
193 196
194 strcpy(event->device_class, device->pnp.device_class); 197 strcpy(event->device_class, device_class);
195 strcpy(event->bus_id, device->dev.bus_id); 198 strcpy(event->bus_id, bus_id);
196 event->type = type; 199 event->type = type;
197 event->data = data; 200 event->data = data;
198 201
@@ -211,6 +214,8 @@ int acpi_bus_generate_genetlink_event(struct acpi_device *device,
211 return 0; 214 return 0;
212} 215}
213 216
217EXPORT_SYMBOL(acpi_bus_generate_netlink_event);
218
214static int acpi_event_genetlink_init(void) 219static int acpi_event_genetlink_init(void)
215{ 220{
216 int result; 221 int result;
@@ -228,12 +233,15 @@ static int acpi_event_genetlink_init(void)
228} 233}
229 234
230#else 235#else
231int acpi_bus_generate_genetlink_event(struct acpi_device *device, u8 type, 236int acpi_bus_generate_netlink_event(const char *device_class,
232 int data) 237 const char *bus_id,
238 u8 type, int data)
233{ 239{
234 return 0; 240 return 0;
235} 241}
236 242
243EXPORT_SYMBOL(acpi_generate_netlink_event);
244
237static int acpi_event_genetlink_init(void) 245static int acpi_event_genetlink_init(void)
238{ 246{
239 return -ENODEV; 247 return -ENODEV;
@@ -242,7 +250,9 @@ static int acpi_event_genetlink_init(void)
242 250
243static int __init acpi_event_init(void) 251static int __init acpi_event_init(void)
244{ 252{
253#ifdef CONFIG_ACPI_PROC_EVENT
245 struct proc_dir_entry *entry; 254 struct proc_dir_entry *entry;
255#endif
246 int error = 0; 256 int error = 0;
247 257
248 if (acpi_disabled) 258 if (acpi_disabled)
@@ -254,12 +264,14 @@ static int __init acpi_event_init(void)
254 printk(KERN_WARNING PREFIX 264 printk(KERN_WARNING PREFIX
255 "Failed to create genetlink family for ACPI event\n"); 265 "Failed to create genetlink family for ACPI event\n");
256 266
267#ifdef CONFIG_ACPI_PROC_EVENT
257 /* 'event' [R] */ 268 /* 'event' [R] */
258 entry = create_proc_entry("event", S_IRUSR, acpi_root_dir); 269 entry = create_proc_entry("event", S_IRUSR, acpi_root_dir);
259 if (entry) 270 if (entry)
260 entry->proc_fops = &acpi_system_event_ops; 271 entry->proc_fops = &acpi_system_event_ops;
261 else 272 else
262 return -ENODEV; 273 return -ENODEV;
274#endif
263 275
264 return 0; 276 return 0;
265} 277}
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index 76c525dc590b..cf69c0040a39 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -576,13 +576,10 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
576 ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS")); 576 ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
577 } 577 }
578 578
579 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
580 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
581 ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK"));
582 }
583 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
584
585 /* 579 /*
580 * GPEs must be enabled before _WAK is called as GPEs
581 * might get fired there
582 *
586 * Restore the GPEs: 583 * Restore the GPEs:
587 * 1) Disable/Clear all GPEs 584 * 1) Disable/Clear all GPEs
588 * 2) Enable all runtime GPEs 585 * 2) Enable all runtime GPEs
@@ -591,13 +588,19 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
591 if (ACPI_FAILURE(status)) { 588 if (ACPI_FAILURE(status)) {
592 return_ACPI_STATUS(status); 589 return_ACPI_STATUS(status);
593 } 590 }
594 acpi_gbl_system_awake_and_running = TRUE;
595
596 status = acpi_hw_enable_all_runtime_gpes(); 591 status = acpi_hw_enable_all_runtime_gpes();
597 if (ACPI_FAILURE(status)) { 592 if (ACPI_FAILURE(status)) {
598 return_ACPI_STATUS(status); 593 return_ACPI_STATUS(status);
599 } 594 }
600 595
596 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
597 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
598 ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK"));
599 }
600 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
601
602 acpi_gbl_system_awake_and_running = TRUE;
603
601 /* Enable power button */ 604 /* Enable power button */
602 605
603 (void) 606 (void)
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
index ab65b2c2560e..f39fbc6b9237 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/namespace/nsxfeval.c
@@ -540,7 +540,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
540 ******************************************************************************/ 540 ******************************************************************************/
541 541
542acpi_status 542acpi_status
543acpi_get_devices(char *HID, 543acpi_get_devices(const char *HID,
544 acpi_walk_callback user_function, 544 acpi_walk_callback user_function,
545 void *context, void **return_value) 545 void *context, void **return_value)
546{ 546{
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 498422343f38..e944aaee4e06 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -698,16 +698,23 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
698 switch (event) { 698 switch (event) {
699 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: 699 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
700 acpi_processor_ppc_has_changed(pr); 700 acpi_processor_ppc_has_changed(pr);
701 acpi_bus_generate_event(device, event, 701 acpi_bus_generate_proc_event(device, event,
702 pr->performance_platform_limit); 702 pr->performance_platform_limit);
703 acpi_bus_generate_netlink_event(device->pnp.device_class,
704 device->dev.bus_id, event,
705 pr->performance_platform_limit);
703 break; 706 break;
704 case ACPI_PROCESSOR_NOTIFY_POWER: 707 case ACPI_PROCESSOR_NOTIFY_POWER:
705 acpi_processor_cst_has_changed(pr); 708 acpi_processor_cst_has_changed(pr);
706 acpi_bus_generate_event(device, event, 0); 709 acpi_bus_generate_proc_event(device, event, 0);
710 acpi_bus_generate_netlink_event(device->pnp.device_class,
711 device->dev.bus_id, event, 0);
707 break; 712 break;
708 case ACPI_PROCESSOR_NOTIFY_THROTTLING: 713 case ACPI_PROCESSOR_NOTIFY_THROTTLING:
709 acpi_processor_tstate_has_changed(pr); 714 acpi_processor_tstate_has_changed(pr);
710 acpi_bus_generate_event(device, event, 0); 715 acpi_bus_generate_proc_event(device, event, 0);
716 acpi_bus_generate_netlink_event(device->pnp.device_class,
717 device->dev.bus_id, event, 0);
711 default: 718 default:
712 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 719 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
713 "Unsupported event [0x%x]\n", event)); 720 "Unsupported event [0x%x]\n", event));
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index a8634a0655fc..d9b8af763e1e 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -63,6 +63,7 @@
63ACPI_MODULE_NAME("processor_idle"); 63ACPI_MODULE_NAME("processor_idle");
64#define ACPI_PROCESSOR_FILE_POWER "power" 64#define ACPI_PROCESSOR_FILE_POWER "power"
65#define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000) 65#define US_TO_PM_TIMER_TICKS(t) ((t * (PM_TIMER_FREQUENCY/1000)) / 1000)
66#define PM_TIMER_TICK_NS (1000000000ULL/PM_TIMER_FREQUENCY)
66#define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */ 67#define C2_OVERHEAD 4 /* 1us (3.579 ticks per us) */
67#define C3_OVERHEAD 4 /* 1us (3.579 ticks per us) */ 68#define C3_OVERHEAD 4 /* 1us (3.579 ticks per us) */
68static void (*pm_idle_save) (void) __read_mostly; 69static void (*pm_idle_save) (void) __read_mostly;
@@ -462,6 +463,9 @@ static void acpi_processor_idle(void)
462 * TBD: Can't get time duration while in C1, as resumes 463 * TBD: Can't get time duration while in C1, as resumes
463 * go to an ISR rather than here. Need to instrument 464 * go to an ISR rather than here. Need to instrument
464 * base interrupt handler. 465 * base interrupt handler.
466 *
467 * Note: the TSC better not stop in C1, sched_clock() will
468 * skew otherwise.
465 */ 469 */
466 sleep_ticks = 0xFFFFFFFF; 470 sleep_ticks = 0xFFFFFFFF;
467 break; 471 break;
@@ -469,6 +473,8 @@ static void acpi_processor_idle(void)
469 case ACPI_STATE_C2: 473 case ACPI_STATE_C2:
470 /* Get start time (ticks) */ 474 /* Get start time (ticks) */
471 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); 475 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
476 /* Tell the scheduler that we are going deep-idle: */
477 sched_clock_idle_sleep_event();
472 /* Invoke C2 */ 478 /* Invoke C2 */
473 acpi_state_timer_broadcast(pr, cx, 1); 479 acpi_state_timer_broadcast(pr, cx, 1);
474 acpi_cstate_enter(cx); 480 acpi_cstate_enter(cx);
@@ -479,17 +485,22 @@ static void acpi_processor_idle(void)
479 /* TSC halts in C2, so notify users */ 485 /* TSC halts in C2, so notify users */
480 mark_tsc_unstable("possible TSC halt in C2"); 486 mark_tsc_unstable("possible TSC halt in C2");
481#endif 487#endif
488 /* Compute time (ticks) that we were actually asleep */
489 sleep_ticks = ticks_elapsed(t1, t2);
490
491 /* Tell the scheduler how much we idled: */
492 sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);
493
482 /* Re-enable interrupts */ 494 /* Re-enable interrupts */
483 local_irq_enable(); 495 local_irq_enable();
496 /* Do not account our idle-switching overhead: */
497 sleep_ticks -= cx->latency_ticks + C2_OVERHEAD;
498
484 current_thread_info()->status |= TS_POLLING; 499 current_thread_info()->status |= TS_POLLING;
485 /* Compute time (ticks) that we were actually asleep */
486 sleep_ticks =
487 ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD;
488 acpi_state_timer_broadcast(pr, cx, 0); 500 acpi_state_timer_broadcast(pr, cx, 0);
489 break; 501 break;
490 502
491 case ACPI_STATE_C3: 503 case ACPI_STATE_C3:
492
493 /* 504 /*
494 * disable bus master 505 * disable bus master
495 * bm_check implies we need ARB_DIS 506 * bm_check implies we need ARB_DIS
@@ -518,6 +529,8 @@ static void acpi_processor_idle(void)
518 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address); 529 t1 = inl(acpi_gbl_FADT.xpm_timer_block.address);
519 /* Invoke C3 */ 530 /* Invoke C3 */
520 acpi_state_timer_broadcast(pr, cx, 1); 531 acpi_state_timer_broadcast(pr, cx, 1);
532 /* Tell the scheduler that we are going deep-idle: */
533 sched_clock_idle_sleep_event();
521 acpi_cstate_enter(cx); 534 acpi_cstate_enter(cx);
522 /* Get end time (ticks) */ 535 /* Get end time (ticks) */
523 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); 536 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
@@ -531,12 +544,17 @@ static void acpi_processor_idle(void)
531 /* TSC halts in C3, so notify users */ 544 /* TSC halts in C3, so notify users */
532 mark_tsc_unstable("TSC halts in C3"); 545 mark_tsc_unstable("TSC halts in C3");
533#endif 546#endif
547 /* Compute time (ticks) that we were actually asleep */
548 sleep_ticks = ticks_elapsed(t1, t2);
549 /* Tell the scheduler how much we idled: */
550 sched_clock_idle_wakeup_event(sleep_ticks*PM_TIMER_TICK_NS);
551
534 /* Re-enable interrupts */ 552 /* Re-enable interrupts */
535 local_irq_enable(); 553 local_irq_enable();
554 /* Do not account our idle-switching overhead: */
555 sleep_ticks -= cx->latency_ticks + C3_OVERHEAD;
556
536 current_thread_info()->status |= TS_POLLING; 557 current_thread_info()->status |= TS_POLLING;
537 /* Compute time (ticks) that we were actually asleep */
538 sleep_ticks =
539 ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD;
540 acpi_state_timer_broadcast(pr, cx, 0); 558 acpi_state_timer_broadcast(pr, cx, 0);
541 break; 559 break;
542 560
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 82c3a550016d..a578986e3214 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -440,11 +440,12 @@ static int acpi_sbs_generate_event(struct acpi_device *device,
440 strcpy(acpi_device_bid(device), bid); 440 strcpy(acpi_device_bid(device), bid);
441 strcpy(acpi_device_class(device), class); 441 strcpy(acpi_device_class(device), class);
442 442
443 result = acpi_bus_generate_event(device, event, state); 443 result = acpi_bus_generate_proc_event(device, event, state);
444 444
445 strcpy(acpi_device_bid(device), bid_saved); 445 strcpy(acpi_device_bid(device), bid_saved);
446 strcpy(acpi_device_class(device), class_saved); 446 strcpy(acpi_device_class(device), class_saved);
447 447
448 acpi_bus_generate_netlink_event(class, bid, event, state);
448 return result; 449 return result;
449} 450}
450 451
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index be74347d1354..64620d668742 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -35,8 +35,9 @@ struct acpi_device_bus_id{
35 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get: 35 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get:
36 * char *modalias: "acpi:IBM0001:ACPI0001" 36 * char *modalias: "acpi:IBM0001:ACPI0001"
37*/ 37*/
38int create_modalias(struct acpi_device *acpi_dev, char *modalias, int size){ 38static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
39 39 int size)
40{
40 int len; 41 int len;
41 42
42 if (!acpi_dev->flags.hardware_id) 43 if (!acpi_dev->flags.hardware_id)
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index e8cff5dd4cbc..c52ade816fb4 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -305,7 +305,7 @@ int acpi_pm_device_sleep_state(struct device *dev, int wake, int *d_min_p)
305 unsigned long d_min, d_max; 305 unsigned long d_min, d_max;
306 306
307 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { 307 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
308 printk(KERN_ERR "ACPI handle has no context!\n"); 308 printk(KERN_DEBUG "ACPI handle has no context!\n");
309 return -ENODEV; 309 return -ENODEV;
310 } 310 }
311 311
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index 1da64b4518c0..8cc9492ffbf2 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -51,6 +51,65 @@ ACPI_MODULE_NAME("tbutils")
51static acpi_physical_address 51static acpi_physical_address
52acpi_tb_get_root_table_entry(u8 * table_entry, 52acpi_tb_get_root_table_entry(u8 * table_entry,
53 acpi_native_uint table_entry_size); 53 acpi_native_uint table_entry_size);
54/*******************************************************************************
55 *
56 * FUNCTION: acpi_tb_check_xsdt
57 *
58 * PARAMETERS: address - Pointer to the XSDT
59 *
60 * RETURN: status
61 * AE_OK - XSDT is okay
62 * AE_NO_MEMORY - can't map XSDT
63 * AE_INVALID_TABLE_LENGTH - invalid table length
64 * AE_NULL_ENTRY - XSDT has NULL entry
65 *
66 * DESCRIPTION: validate XSDT
67******************************************************************************/
68
69static acpi_status
70acpi_tb_check_xsdt(acpi_physical_address address)
71{
72 struct acpi_table_header *table;
73 u32 length;
74 u64 xsdt_entry_address;
75 u8 *table_entry;
76 u32 table_count;
77 int i;
78
79 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
80 if (!table)
81 return AE_NO_MEMORY;
82
83 length = table->length;
84 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
85 if (length < sizeof(struct acpi_table_header))
86 return AE_INVALID_TABLE_LENGTH;
87
88 table = acpi_os_map_memory(address, length);
89 if (!table)
90 return AE_NO_MEMORY;
91
92 /* Calculate the number of tables described in XSDT */
93 table_count =
94 (u32) ((table->length -
95 sizeof(struct acpi_table_header)) / sizeof(u64));
96 table_entry =
97 ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);
98 for (i = 0; i < table_count; i++) {
99 ACPI_MOVE_64_TO_64(&xsdt_entry_address, table_entry);
100 if (!xsdt_entry_address) {
101 /* XSDT has NULL entry */
102 break;
103 }
104 table_entry += sizeof(u64);
105 }
106 acpi_os_unmap_memory(table, length);
107
108 if (i < table_count)
109 return AE_NULL_ENTRY;
110 else
111 return AE_OK;
112}
54 113
55/******************************************************************************* 114/*******************************************************************************
56 * 115 *
@@ -341,6 +400,7 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
341 u32 table_count; 400 u32 table_count;
342 struct acpi_table_header *table; 401 struct acpi_table_header *table;
343 acpi_physical_address address; 402 acpi_physical_address address;
403 acpi_physical_address rsdt_address;
344 u32 length; 404 u32 length;
345 u8 *table_entry; 405 u8 *table_entry;
346 acpi_status status; 406 acpi_status status;
@@ -369,6 +429,8 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
369 */ 429 */
370 address = (acpi_physical_address) rsdp->xsdt_physical_address; 430 address = (acpi_physical_address) rsdp->xsdt_physical_address;
371 table_entry_size = sizeof(u64); 431 table_entry_size = sizeof(u64);
432 rsdt_address = (acpi_physical_address)
433 rsdp->rsdt_physical_address;
372 } else { 434 } else {
373 /* Root table is an RSDT (32-bit physical addresses) */ 435 /* Root table is an RSDT (32-bit physical addresses) */
374 436
@@ -382,6 +444,15 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
382 */ 444 */
383 acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp)); 445 acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp));
384 446
447 if (table_entry_size == sizeof(u64)) {
448 if (acpi_tb_check_xsdt(address) == AE_NULL_ENTRY) {
449 /* XSDT has NULL entry, RSDT is used */
450 address = rsdt_address;
451 table_entry_size = sizeof(u32);
452 ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry,"
453 "using RSDT"));
454 }
455 }
385 /* Map the RSDT/XSDT table header to get the full table length */ 456 /* Map the RSDT/XSDT table header to get the full table length */
386 457
387 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); 458 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 1e06159fd9c4..bc6d5866ef98 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -77,23 +77,27 @@ MODULE_LICENSE("GPL");
77 77
78static int act; 78static int act;
79module_param(act, int, 0644); 79module_param(act, int, 0644);
80MODULE_PARM_DESC(act, "Disable or override all lowest active trip points.\n"); 80MODULE_PARM_DESC(act, "Disable or override all lowest active trip points.");
81
82static int crt;
83module_param(crt, int, 0644);
84MODULE_PARM_DESC(crt, "Disable or lower all critical trip points.");
81 85
82static int tzp; 86static int tzp;
83module_param(tzp, int, 0444); 87module_param(tzp, int, 0444);
84MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.\n"); 88MODULE_PARM_DESC(tzp, "Thermal zone polling frequency, in 1/10 seconds.");
85 89
86static int nocrt; 90static int nocrt;
87module_param(nocrt, int, 0); 91module_param(nocrt, int, 0);
88MODULE_PARM_DESC(nocrt, "Set to disable action on ACPI thermal zone critical and hot trips.\n"); 92MODULE_PARM_DESC(nocrt, "Set to take no action upon ACPI thermal zone critical trips points.");
89 93
90static int off; 94static int off;
91module_param(off, int, 0); 95module_param(off, int, 0);
92MODULE_PARM_DESC(off, "Set to disable ACPI thermal support.\n"); 96MODULE_PARM_DESC(off, "Set to disable ACPI thermal support.");
93 97
94static int psv; 98static int psv;
95module_param(psv, int, 0644); 99module_param(psv, int, 0644);
96MODULE_PARM_DESC(psv, "Disable or override all passive trip points.\n"); 100MODULE_PARM_DESC(psv, "Disable or override all passive trip points.");
97 101
98static int acpi_thermal_add(struct acpi_device *device); 102static int acpi_thermal_add(struct acpi_device *device);
99static int acpi_thermal_remove(struct acpi_device *device, int type); 103static int acpi_thermal_remove(struct acpi_device *device, int type);
@@ -340,6 +344,20 @@ static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
340 tz->trips.critical.temperature)); 344 tz->trips.critical.temperature));
341 } 345 }
342 346
347 if (tz->trips.critical.flags.valid == 1) {
348 if (crt == -1) {
349 tz->trips.critical.flags.valid = 0;
350 } else if (crt > 0) {
351 unsigned long crt_k = CELSIUS_TO_KELVIN(crt);
352
353 /*
354 * Allow override to lower critical threshold
355 */
356 if (crt_k < tz->trips.critical.temperature)
357 tz->trips.critical.temperature = crt_k;
358 }
359 }
360
343 /* Critical Sleep (optional) */ 361 /* Critical Sleep (optional) */
344 362
345 status = 363 status =
@@ -485,8 +503,12 @@ static int acpi_thermal_critical(struct acpi_thermal *tz)
485 printk(KERN_EMERG 503 printk(KERN_EMERG
486 "Critical temperature reached (%ld C), shutting down.\n", 504 "Critical temperature reached (%ld C), shutting down.\n",
487 KELVIN_TO_CELSIUS(tz->temperature)); 505 KELVIN_TO_CELSIUS(tz->temperature));
488 acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL, 506 acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_CRITICAL,
489 tz->trips.critical.flags.enabled); 507 tz->trips.critical.flags.enabled);
508 acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
509 tz->device->dev.bus_id,
510 ACPI_THERMAL_NOTIFY_CRITICAL,
511 tz->trips.critical.flags.enabled);
490 512
491 orderly_poweroff(true); 513 orderly_poweroff(true);
492 514
@@ -504,8 +526,12 @@ static int acpi_thermal_hot(struct acpi_thermal *tz)
504 } else if (tz->trips.hot.flags.enabled) 526 } else if (tz->trips.hot.flags.enabled)
505 tz->trips.hot.flags.enabled = 0; 527 tz->trips.hot.flags.enabled = 0;
506 528
507 acpi_bus_generate_event(tz->device, ACPI_THERMAL_NOTIFY_HOT, 529 acpi_bus_generate_proc_event(tz->device, ACPI_THERMAL_NOTIFY_HOT,
508 tz->trips.hot.flags.enabled); 530 tz->trips.hot.flags.enabled);
531 acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
532 tz->device->dev.bus_id,
533 ACPI_THERMAL_NOTIFY_HOT,
534 tz->trips.hot.flags.enabled);
509 535
510 /* TBD: Call user-mode "sleep(S4)" function */ 536 /* TBD: Call user-mode "sleep(S4)" function */
511 537
@@ -1067,9 +1093,9 @@ static int acpi_thermal_add_fs(struct acpi_device *device)
1067 entry->owner = THIS_MODULE; 1093 entry->owner = THIS_MODULE;
1068 } 1094 }
1069 1095
1070 /* 'trip_points' [R/W] */ 1096 /* 'trip_points' [R] */
1071 entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS, 1097 entry = create_proc_entry(ACPI_THERMAL_FILE_TRIP_POINTS,
1072 S_IFREG | S_IRUGO | S_IWUSR, 1098 S_IRUGO,
1073 acpi_device_dir(device)); 1099 acpi_device_dir(device));
1074 if (!entry) 1100 if (!entry)
1075 return -ENODEV; 1101 return -ENODEV;
@@ -1149,12 +1175,16 @@ static void acpi_thermal_notify(acpi_handle handle, u32 event, void *data)
1149 case ACPI_THERMAL_NOTIFY_THRESHOLDS: 1175 case ACPI_THERMAL_NOTIFY_THRESHOLDS:
1150 acpi_thermal_get_trip_points(tz); 1176 acpi_thermal_get_trip_points(tz);
1151 acpi_thermal_check(tz); 1177 acpi_thermal_check(tz);
1152 acpi_bus_generate_event(device, event, 0); 1178 acpi_bus_generate_proc_event(device, event, 0);
1179 acpi_bus_generate_netlink_event(device->pnp.device_class,
1180 device->dev.bus_id, event, 0);
1153 break; 1181 break;
1154 case ACPI_THERMAL_NOTIFY_DEVICES: 1182 case ACPI_THERMAL_NOTIFY_DEVICES:
1155 if (tz->flags.devices) 1183 if (tz->flags.devices)
1156 acpi_thermal_get_devices(tz); 1184 acpi_thermal_get_devices(tz);
1157 acpi_bus_generate_event(device, event, 0); 1185 acpi_bus_generate_proc_event(device, event, 0);
1186 acpi_bus_generate_netlink_event(device->pnp.device_class,
1187 device->dev.bus_id, event, 0);
1158 break; 1188 break;
1159 default: 1189 default:
1160 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1190 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -1339,6 +1369,13 @@ static int thermal_act(struct dmi_system_id *d) {
1339 } 1369 }
1340 return 0; 1370 return 0;
1341} 1371}
1372static int thermal_nocrt(struct dmi_system_id *d) {
1373
1374 printk(KERN_NOTICE "ACPI: %s detected: "
1375 "disabling all critical thermal trip point actions.\n", d->ident);
1376 nocrt = 1;
1377 return 0;
1378}
1342static int thermal_tzp(struct dmi_system_id *d) { 1379static int thermal_tzp(struct dmi_system_id *d) {
1343 1380
1344 if (tzp == 0) { 1381 if (tzp == 0) {
@@ -1387,6 +1424,14 @@ static struct dmi_system_id thermal_dmi_table[] __initdata = {
1387 DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"), 1424 DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
1388 }, 1425 },
1389 }, 1426 },
1427 {
1428 .callback = thermal_nocrt,
1429 .ident = "Gigabyte GA-7ZX",
1430 .matches = {
1431 DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co., Ltd."),
1432 DMI_MATCH(DMI_BOARD_NAME, "7ZX"),
1433 },
1434 },
1390 {} 1435 {}
1391}; 1436};
1392#endif /* CONFIG_DMI */ 1437#endif /* CONFIG_DMI */
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 1621655d6e2b..93ea8290b4f7 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -126,6 +126,7 @@ const char *acpi_format_exception(acpi_status status)
126 "Unknown exception code: 0x%8.8X", status)); 126 "Unknown exception code: 0x%8.8X", status));
127 127
128 exception = "UNKNOWN_STATUS_CODE"; 128 exception = "UNKNOWN_STATUS_CODE";
129 dump_stack();
129 } 130 }
130 131
131 return (ACPI_CAST_PTR(const char, exception)); 132 return (ACPI_CAST_PTR(const char, exception));
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index d98701941981..3c9bb85a6a93 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -31,7 +31,7 @@
31#include <linux/list.h> 31#include <linux/list.h>
32#include <linux/proc_fs.h> 32#include <linux/proc_fs.h>
33#include <linux/seq_file.h> 33#include <linux/seq_file.h>
34 34#include <linux/input.h>
35#include <linux/backlight.h> 35#include <linux/backlight.h>
36#include <linux/video_output.h> 36#include <linux/video_output.h>
37#include <asm/uaccess.h> 37#include <asm/uaccess.h>
@@ -138,6 +138,8 @@ struct acpi_video_bus {
138 struct semaphore sem; 138 struct semaphore sem;
139 struct list_head video_device_list; 139 struct list_head video_device_list;
140 struct proc_dir_entry *dir; 140 struct proc_dir_entry *dir;
141 struct input_dev *input;
142 char phys[32]; /* for input device */
141}; 143};
142 144
143struct acpi_video_device_flags { 145struct acpi_video_device_flags {
@@ -1764,6 +1766,9 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1764{ 1766{
1765 struct acpi_video_bus *video = data; 1767 struct acpi_video_bus *video = data;
1766 struct acpi_device *device = NULL; 1768 struct acpi_device *device = NULL;
1769 struct input_dev *input;
1770 int keycode;
1771
1767 1772
1768 printk("video bus notify\n"); 1773 printk("video bus notify\n");
1769 1774
@@ -1771,11 +1776,13 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1771 return; 1776 return;
1772 1777
1773 device = video->device; 1778 device = video->device;
1779 input = video->input;
1774 1780
1775 switch (event) { 1781 switch (event) {
1776 case ACPI_VIDEO_NOTIFY_SWITCH: /* User requested a switch, 1782 case ACPI_VIDEO_NOTIFY_SWITCH: /* User requested a switch,
1777 * most likely via hotkey. */ 1783 * most likely via hotkey. */
1778 acpi_bus_generate_event(device, event, 0); 1784 acpi_bus_generate_proc_event(device, event, 0);
1785 keycode = KEY_SWITCHVIDEOMODE;
1779 break; 1786 break;
1780 1787
1781 case ACPI_VIDEO_NOTIFY_PROBE: /* User plugged in or removed a video 1788 case ACPI_VIDEO_NOTIFY_PROBE: /* User plugged in or removed a video
@@ -1783,22 +1790,38 @@ static void acpi_video_bus_notify(acpi_handle handle, u32 event, void *data)
1783 acpi_video_device_enumerate(video); 1790 acpi_video_device_enumerate(video);
1784 acpi_video_device_rebind(video); 1791 acpi_video_device_rebind(video);
1785 acpi_video_switch_output(video, event); 1792 acpi_video_switch_output(video, event);
1786 acpi_bus_generate_event(device, event, 0); 1793 acpi_bus_generate_proc_event(device, event, 0);
1794 keycode = KEY_SWITCHVIDEOMODE;
1787 break; 1795 break;
1788 1796
1789 case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */ 1797 case ACPI_VIDEO_NOTIFY_CYCLE: /* Cycle Display output hotkey pressed. */
1798 acpi_video_switch_output(video, event);
1799 acpi_bus_generate_proc_event(device, event, 0);
1800 keycode = KEY_SWITCHVIDEOMODE;
1801 break;
1790 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */ 1802 case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: /* Next Display output hotkey pressed. */
1803 acpi_video_switch_output(video, event);
1804 acpi_bus_generate_proc_event(device, event, 0);
1805 keycode = KEY_VIDEO_NEXT;
1806 break;
1791 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */ 1807 case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: /* previous Display output hotkey pressed. */
1792 acpi_video_switch_output(video, event); 1808 acpi_video_switch_output(video, event);
1793 acpi_bus_generate_event(device, event, 0); 1809 acpi_bus_generate_proc_event(device, event, 0);
1810 keycode = KEY_VIDEO_PREV;
1794 break; 1811 break;
1795 1812
1796 default: 1813 default:
1814 keycode = KEY_UNKNOWN;
1797 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1815 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1798 "Unsupported event [0x%x]\n", event)); 1816 "Unsupported event [0x%x]\n", event));
1799 break; 1817 break;
1800 } 1818 }
1801 1819
1820 input_report_key(input, keycode, 1);
1821 input_sync(input);
1822 input_report_key(input, keycode, 0);
1823 input_sync(input);
1824
1802 return; 1825 return;
1803} 1826}
1804 1827
@@ -1806,38 +1829,65 @@ static void acpi_video_device_notify(acpi_handle handle, u32 event, void *data)
1806{ 1829{
1807 struct acpi_video_device *video_device = data; 1830 struct acpi_video_device *video_device = data;
1808 struct acpi_device *device = NULL; 1831 struct acpi_device *device = NULL;
1832 struct acpi_video_bus *bus;
1833 struct input_dev *input;
1834 int keycode;
1809 1835
1810 if (!video_device) 1836 if (!video_device)
1811 return; 1837 return;
1812 1838
1813 device = video_device->dev; 1839 device = video_device->dev;
1840 bus = video_device->video;
1841 input = bus->input;
1814 1842
1815 switch (event) { 1843 switch (event) {
1816 case ACPI_VIDEO_NOTIFY_SWITCH: /* change in status (cycle output device) */
1817 case ACPI_VIDEO_NOTIFY_PROBE: /* change in status (output device status) */
1818 acpi_bus_generate_event(device, event, 0);
1819 break;
1820 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */ 1844 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS: /* Cycle brightness */
1845 acpi_video_switch_brightness(video_device, event);
1846 acpi_bus_generate_proc_event(device, event, 0);
1847 keycode = KEY_BRIGHTNESS_CYCLE;
1848 break;
1821 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */ 1849 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS: /* Increase brightness */
1850 acpi_video_switch_brightness(video_device, event);
1851 acpi_bus_generate_proc_event(device, event, 0);
1852 keycode = KEY_BRIGHTNESSUP;
1853 break;
1822 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */ 1854 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS: /* Decrease brightness */
1855 acpi_video_switch_brightness(video_device, event);
1856 acpi_bus_generate_proc_event(device, event, 0);
1857 keycode = KEY_BRIGHTNESSDOWN;
1858 break;
1823 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */ 1859 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS: /* zero brightnesss */
1860 acpi_video_switch_brightness(video_device, event);
1861 acpi_bus_generate_proc_event(device, event, 0);
1862 keycode = KEY_BRIGHTNESS_ZERO;
1863 break;
1824 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */ 1864 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF: /* display device off */
1825 acpi_video_switch_brightness(video_device, event); 1865 acpi_video_switch_brightness(video_device, event);
1826 acpi_bus_generate_event(device, event, 0); 1866 acpi_bus_generate_proc_event(device, event, 0);
1867 keycode = KEY_DISPLAY_OFF;
1827 break; 1868 break;
1828 default: 1869 default:
1870 keycode = KEY_UNKNOWN;
1829 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1871 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1830 "Unsupported event [0x%x]\n", event)); 1872 "Unsupported event [0x%x]\n", event));
1831 break; 1873 break;
1832 } 1874 }
1875
1876 input_report_key(input, keycode, 1);
1877 input_sync(input);
1878 input_report_key(input, keycode, 0);
1879 input_sync(input);
1880
1833 return; 1881 return;
1834} 1882}
1835 1883
1884static int instance;
1836static int acpi_video_bus_add(struct acpi_device *device) 1885static int acpi_video_bus_add(struct acpi_device *device)
1837{ 1886{
1838 int result = 0; 1887 int result = 0;
1839 acpi_status status = 0; 1888 acpi_status status = 0;
1840 struct acpi_video_bus *video = NULL; 1889 struct acpi_video_bus *video = NULL;
1890 struct input_dev *input;
1841 1891
1842 1892
1843 if (!device) 1893 if (!device)
@@ -1847,6 +1897,13 @@ static int acpi_video_bus_add(struct acpi_device *device)
1847 if (!video) 1897 if (!video)
1848 return -ENOMEM; 1898 return -ENOMEM;
1849 1899
1900 /* a hack to fix the duplicate name "VID" problem on T61 */
1901 if (!strcmp(device->pnp.bus_id, "VID")) {
1902 if (instance)
1903 device->pnp.bus_id[3] = '0' + instance;
1904 instance ++;
1905 }
1906
1850 video->device = device; 1907 video->device = device;
1851 strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME); 1908 strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
1852 strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS); 1909 strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
@@ -1881,6 +1938,39 @@ static int acpi_video_bus_add(struct acpi_device *device)
1881 goto end; 1938 goto end;
1882 } 1939 }
1883 1940
1941
1942 video->input = input = input_allocate_device();
1943
1944 snprintf(video->phys, sizeof(video->phys),
1945 "%s/video/input0", acpi_device_hid(video->device));
1946
1947 input->name = acpi_device_name(video->device);
1948 input->phys = video->phys;
1949 input->id.bustype = BUS_HOST;
1950 input->id.product = 0x06;
1951 input->evbit[0] = BIT(EV_KEY);
1952 set_bit(KEY_SWITCHVIDEOMODE, input->keybit);
1953 set_bit(KEY_VIDEO_NEXT, input->keybit);
1954 set_bit(KEY_VIDEO_PREV, input->keybit);
1955 set_bit(KEY_BRIGHTNESS_CYCLE, input->keybit);
1956 set_bit(KEY_BRIGHTNESSUP, input->keybit);
1957 set_bit(KEY_BRIGHTNESSDOWN, input->keybit);
1958 set_bit(KEY_BRIGHTNESS_ZERO, input->keybit);
1959 set_bit(KEY_DISPLAY_OFF, input->keybit);
1960 set_bit(KEY_UNKNOWN, input->keybit);
1961 result = input_register_device(input);
1962 if (result) {
1963 acpi_remove_notify_handler(video->device->handle,
1964 ACPI_DEVICE_NOTIFY,
1965 acpi_video_bus_notify);
1966 acpi_video_bus_stop_devices(video);
1967 acpi_video_bus_put_devices(video);
1968 kfree(video->attached_array);
1969 acpi_video_bus_remove_fs(device);
1970 goto end;
1971 }
1972
1973
1884 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n", 1974 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n",
1885 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), 1975 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
1886 video->flags.multihead ? "yes" : "no", 1976 video->flags.multihead ? "yes" : "no",
@@ -1914,6 +2004,7 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
1914 acpi_video_bus_put_devices(video); 2004 acpi_video_bus_put_devices(video);
1915 acpi_video_bus_remove_fs(device); 2005 acpi_video_bus_remove_fs(device);
1916 2006
2007 input_unregister_device(video->input);
1917 kfree(video->attached_array); 2008 kfree(video->attached_array);
1918 kfree(video); 2009 kfree(video);
1919 2010
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index a78832ea81fa..071d274afaab 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -436,7 +436,7 @@ static const struct piix_map_db ich8_map_db = {
436 /* PM PS SM SS MAP */ 436 /* PM PS SM SS MAP */
437 { P0, P2, P1, P3 }, /* 00b (hardwired when in AHCI) */ 437 { P0, P2, P1, P3 }, /* 00b (hardwired when in AHCI) */
438 { RV, RV, RV, RV }, 438 { RV, RV, RV, RV },
439 { IDE, IDE, NA, NA }, /* 10b (IDE mode) */ 439 { P0, P2, IDE, IDE }, /* 10b (IDE mode) */
440 { RV, RV, RV, RV }, 440 { RV, RV, RV, RV },
441 }, 441 },
442}; 442};
@@ -901,6 +901,13 @@ static int piix_broken_suspend(void)
901 }, 901 },
902 }, 902 },
903 { 903 {
904 .ident = "TECRA M7",
905 .matches = {
906 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
907 DMI_MATCH(DMI_PRODUCT_NAME, "TECRA M7"),
908 },
909 },
910 {
904 .ident = "Satellite U205", 911 .ident = "Satellite U205",
905 .matches = { 912 .matches = {
906 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"), 913 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 60e78bef469f..2ad4dda6d4a7 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1723,7 +1723,7 @@ int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
1723 tf.protocol = ATA_PROT_NODATA; 1723 tf.protocol = ATA_PROT_NODATA;
1724 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 1724 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
1725 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0); 1725 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0);
1726 if (err_mask) { 1726 if (err_mask && id[2] != 0x738c) {
1727 rc = -EIO; 1727 rc = -EIO;
1728 reason = "SPINUP failed"; 1728 reason = "SPINUP failed";
1729 goto err_out; 1729 goto err_out;
@@ -3700,11 +3700,16 @@ int ata_dev_revalidate(struct ata_device *dev, unsigned int readid_flags)
3700 goto fail; 3700 goto fail;
3701 3701
3702 /* verify n_sectors hasn't changed */ 3702 /* verify n_sectors hasn't changed */
3703 if (dev->class == ATA_DEV_ATA && dev->n_sectors != n_sectors) { 3703 if (dev->class == ATA_DEV_ATA && n_sectors &&
3704 dev->n_sectors != n_sectors) {
3704 ata_dev_printk(dev, KERN_INFO, "n_sectors mismatch " 3705 ata_dev_printk(dev, KERN_INFO, "n_sectors mismatch "
3705 "%llu != %llu\n", 3706 "%llu != %llu\n",
3706 (unsigned long long)n_sectors, 3707 (unsigned long long)n_sectors,
3707 (unsigned long long)dev->n_sectors); 3708 (unsigned long long)dev->n_sectors);
3709
3710 /* restore original n_sectors */
3711 dev->n_sectors = n_sectors;
3712
3708 rc = -ENODEV; 3713 rc = -ENODEV;
3709 goto fail; 3714 goto fail;
3710 } 3715 }
diff --git a/drivers/ata/pata_artop.c b/drivers/ata/pata_artop.c
index ce589d96ca42..b5352ebecef9 100644
--- a/drivers/ata/pata_artop.c
+++ b/drivers/ata/pata_artop.c
@@ -2,6 +2,7 @@
2 * pata_artop.c - ARTOP ATA controller driver 2 * pata_artop.c - ARTOP ATA controller driver
3 * 3 *
4 * (C) 2006 Red Hat <alan@redhat.com> 4 * (C) 2006 Red Hat <alan@redhat.com>
5 * (C) 2007 Bartlomiej Zolnierkiewicz
5 * 6 *
6 * Based in part on drivers/ide/pci/aec62xx.c 7 * Based in part on drivers/ide/pci/aec62xx.c
7 * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org> 8 * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org>
@@ -28,7 +29,7 @@
28#include <linux/ata.h> 29#include <linux/ata.h>
29 30
30#define DRV_NAME "pata_artop" 31#define DRV_NAME "pata_artop"
31#define DRV_VERSION "0.4.3" 32#define DRV_VERSION "0.4.4"
32 33
33/* 34/*
34 * The ARTOP has 33 Mhz and "over clocked" timing tables. Until we 35 * The ARTOP has 33 Mhz and "over clocked" timing tables. Until we
@@ -430,7 +431,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
430 .udma_mask = ATA_UDMA4, 431 .udma_mask = ATA_UDMA4,
431 .port_ops = &artop6260_ops, 432 .port_ops = &artop6260_ops,
432 }; 433 };
433 static const struct ata_port_info info_626x_fast = { 434 static const struct ata_port_info info_628x = {
434 .sht = &artop_sht, 435 .sht = &artop_sht,
435 .flags = ATA_FLAG_SLAVE_POSS, 436 .flags = ATA_FLAG_SLAVE_POSS,
436 .pio_mask = 0x1f, /* pio0-4 */ 437 .pio_mask = 0x1f, /* pio0-4 */
@@ -438,6 +439,14 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
438 .udma_mask = ATA_UDMA5, 439 .udma_mask = ATA_UDMA5,
439 .port_ops = &artop6260_ops, 440 .port_ops = &artop6260_ops,
440 }; 441 };
442 static const struct ata_port_info info_628x_fast = {
443 .sht = &artop_sht,
444 .flags = ATA_FLAG_SLAVE_POSS,
445 .pio_mask = 0x1f, /* pio0-4 */
446 .mwdma_mask = 0x07, /* mwdma0-2 */
447 .udma_mask = ATA_UDMA6,
448 .port_ops = &artop6260_ops,
449 };
441 const struct ata_port_info *ppi[] = { NULL, NULL }; 450 const struct ata_port_info *ppi[] = { NULL, NULL };
442 451
443 if (!printed_version++) 452 if (!printed_version++)
@@ -455,13 +464,13 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
455 } 464 }
456 else if (id->driver_data == 1) /* 6260 */ 465 else if (id->driver_data == 1) /* 6260 */
457 ppi[0] = &info_626x; 466 ppi[0] = &info_626x;
458 else if (id->driver_data == 2) { /* 6260 or 6260 + fast */ 467 else if (id->driver_data == 2) { /* 6280 or 6280 + fast */
459 unsigned long io = pci_resource_start(pdev, 4); 468 unsigned long io = pci_resource_start(pdev, 4);
460 u8 reg; 469 u8 reg;
461 470
462 ppi[0] = &info_626x; 471 ppi[0] = &info_628x;
463 if (inb(io) & 0x10) 472 if (inb(io) & 0x10)
464 ppi[0] = &info_626x_fast; 473 ppi[0] = &info_628x_fast;
465 /* Mac systems come up with some registers not set as we 474 /* Mac systems come up with some registers not set as we
466 will need them */ 475 will need them */
467 476
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index 84d9c5568567..c5ddd937dbf2 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -8,12 +8,10 @@
8 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> 8 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
9 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 9 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
10 * Portions Copyright (C) 2003 Red Hat Inc 10 * Portions Copyright (C) 2003 Red Hat Inc
11 * Portions Copyright (C) 2005-2006 MontaVista Software, Inc. 11 * Portions Copyright (C) 2005-2007 MontaVista Software, Inc.
12 * 12 *
13 * TODO 13 * TODO
14 * PLL mode 14 * Look into engine reset on timeout errors. Should not be required.
15 * Look into engine reset on timeout errors. Should not be
16 * required.
17 */ 15 */
18 16
19#include <linux/kernel.h> 17#include <linux/kernel.h>
@@ -26,7 +24,7 @@
26#include <linux/libata.h> 24#include <linux/libata.h>
27 25
28#define DRV_NAME "pata_hpt37x" 26#define DRV_NAME "pata_hpt37x"
29#define DRV_VERSION "0.6.7" 27#define DRV_VERSION "0.6.9"
30 28
31struct hpt_clock { 29struct hpt_clock {
32 u8 xfer_speed; 30 u8 xfer_speed;
@@ -1092,9 +1090,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1092 int dpll, adjust; 1090 int dpll, adjust;
1093 1091
1094 /* Compute DPLL */ 1092 /* Compute DPLL */
1095 dpll = 2; 1093 dpll = (port->udma_mask & 0xC0) ? 3 : 2;
1096 if (port->udma_mask & 0xE0)
1097 dpll = 3;
1098 1094
1099 f_low = (MHz[clock_slot] * 48) / MHz[dpll]; 1095 f_low = (MHz[clock_slot] * 48) / MHz[dpll];
1100 f_high = f_low + 2; 1096 f_high = f_low + 2;
@@ -1116,7 +1112,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1116 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low | 0x100); 1112 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low | 0x100);
1117 } 1113 }
1118 if (adjust == 8) { 1114 if (adjust == 8) {
1119 printk(KERN_WARNING "hpt37x: DPLL did not stabilize.\n"); 1115 printk(KERN_ERR "pata_hpt37x: DPLL did not stabilize!\n");
1120 return -ENODEV; 1116 return -ENODEV;
1121 } 1117 }
1122 if (dpll == 3) 1118 if (dpll == 3)
@@ -1124,7 +1120,8 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1124 else 1120 else
1125 private_data = (void *)hpt37x_timings_50; 1121 private_data = (void *)hpt37x_timings_50;
1126 1122
1127 printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[dpll]); 1123 printk(KERN_INFO "pata_hpt37x: bus clock %dMHz, using %dMHz DPLL.\n",
1124 MHz[clock_slot], MHz[dpll]);
1128 } else { 1125 } else {
1129 private_data = (void *)chip_table->clocks[clock_slot]; 1126 private_data = (void *)chip_table->clocks[clock_slot];
1130 /* 1127 /*
@@ -1137,7 +1134,8 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1137 port = &info_hpt370_33; 1134 port = &info_hpt370_33;
1138 if (clock_slot < 2 && port == &info_hpt370a) 1135 if (clock_slot < 2 && port == &info_hpt370a)
1139 port = &info_hpt370a_33; 1136 port = &info_hpt370a_33;
1140 printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]); 1137 printk(KERN_INFO "pata_hpt37x: %s using %dMHz bus clock.\n",
1138 chip_table->name, MHz[clock_slot]);
1141 } 1139 }
1142 1140
1143 /* Now kick off ATA set up */ 1141 /* Now kick off ATA set up */
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index aa29cde09f8b..f8f234bfc8ce 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -8,7 +8,7 @@
8 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> 8 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
9 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 9 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
10 * Portions Copyright (C) 2003 Red Hat Inc 10 * Portions Copyright (C) 2003 Red Hat Inc
11 * Portions Copyright (C) 2005-2006 MontaVista Software, Inc. 11 * Portions Copyright (C) 2005-2007 MontaVista Software, Inc.
12 * 12 *
13 * 13 *
14 * TODO 14 * TODO
@@ -25,7 +25,7 @@
25#include <linux/libata.h> 25#include <linux/libata.h>
26 26
27#define DRV_NAME "pata_hpt3x2n" 27#define DRV_NAME "pata_hpt3x2n"
28#define DRV_VERSION "0.3.3" 28#define DRV_VERSION "0.3.4"
29 29
30enum { 30enum {
31 HPT_PCI_FAST = (1 << 31), 31 HPT_PCI_FAST = (1 << 31),
@@ -579,10 +579,12 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
579 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low); 579 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low);
580 } 580 }
581 if (adjust == 8) { 581 if (adjust == 8) {
582 printk(KERN_WARNING "hpt3x2n: DPLL did not stabilize.\n"); 582 printk(KERN_ERR "pata_hpt3x2n: DPLL did not stabilize!\n");
583 return -ENODEV; 583 return -ENODEV;
584 } 584 }
585 585
586 printk(KERN_INFO "pata_hpt37x: bus clock %dMHz, using 66MHz DPLL.\n",
587 pci_mhz);
586 /* Set our private data up. We only need a few flags so we use 588 /* Set our private data up. We only need a few flags so we use
587 it directly */ 589 it directly */
588 port.private_data = NULL; 590 port.private_data = NULL;
diff --git a/drivers/ata/pata_isapnp.c b/drivers/ata/pata_isapnp.c
index 5525518204e6..91a396fa5b20 100644
--- a/drivers/ata/pata_isapnp.c
+++ b/drivers/ata/pata_isapnp.c
@@ -139,6 +139,8 @@ static struct pnp_device_id isapnp_devices[] = {
139 {.id = ""} 139 {.id = ""}
140}; 140};
141 141
142MODULE_DEVICE_TABLE(pnp, isapnp_devices);
143
142static struct pnp_driver isapnp_driver = { 144static struct pnp_driver isapnp_driver = {
143 .name = DRV_NAME, 145 .name = DRV_NAME,
144 .id_table = isapnp_devices, 146 .id_table = isapnp_devices,
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index 430673be1df7..7225124d96c2 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -587,7 +587,7 @@ static int it821x_port_start(struct ata_port *ap)
587 itdev->want[1][1] = ATA_ANY; 587 itdev->want[1][1] = ATA_ANY;
588 itdev->last_device = -1; 588 itdev->last_device = -1;
589 589
590 if (pdev->revision == 0x11) { 590 if (pdev->revision == 0x10) {
591 itdev->timing10 = 1; 591 itdev->timing10 = 1;
592 /* Need to disable ATAPI DMA for this case */ 592 /* Need to disable ATAPI DMA for this case */
593 if (!itdev->smart) 593 if (!itdev->smart)
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index 69a5aa4949f5..e3245b36269a 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -563,13 +563,13 @@ static long pdc_read_counter(struct ata_host *host)
563 u32 bccrl, bccrh, bccrlv, bccrhv; 563 u32 bccrl, bccrh, bccrlv, bccrhv;
564 564
565retry: 565retry:
566 bccrl = readl(mmio_base + PDC_BYTE_COUNT) & 0xffff; 566 bccrl = readl(mmio_base + PDC_BYTE_COUNT) & 0x7fff;
567 bccrh = readl(mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff; 567 bccrh = readl(mmio_base + PDC_BYTE_COUNT + 0x100) & 0x7fff;
568 rmb(); 568 rmb();
569 569
570 /* Read the counter values again for verification */ 570 /* Read the counter values again for verification */
571 bccrlv = readl(mmio_base + PDC_BYTE_COUNT) & 0xffff; 571 bccrlv = readl(mmio_base + PDC_BYTE_COUNT) & 0x7fff;
572 bccrhv = readl(mmio_base + PDC_BYTE_COUNT + 0x100) & 0xffff; 572 bccrhv = readl(mmio_base + PDC_BYTE_COUNT + 0x100) & 0x7fff;
573 rmb(); 573 rmb();
574 574
575 counter = (bccrh << 15) | bccrl; 575 counter = (bccrh << 15) | bccrl;
@@ -692,16 +692,16 @@ static long pdc_detect_pll_input_clock(struct ata_host *host)
692 struct timeval start_time, end_time; 692 struct timeval start_time, end_time;
693 long pll_clock, usec_elapsed; 693 long pll_clock, usec_elapsed;
694 694
695 /* Read current counter value */
696 start_count = pdc_read_counter(host);
697 do_gettimeofday(&start_time);
698
699 /* Start the test mode */ 695 /* Start the test mode */
700 scr = readl(mmio_base + PDC_SYS_CTL); 696 scr = readl(mmio_base + PDC_SYS_CTL);
701 PDPRINTK("scr[%X]\n", scr); 697 PDPRINTK("scr[%X]\n", scr);
702 writel(scr | (0x01 << 14), mmio_base + PDC_SYS_CTL); 698 writel(scr | (0x01 << 14), mmio_base + PDC_SYS_CTL);
703 readl(mmio_base + PDC_SYS_CTL); /* flush */ 699 readl(mmio_base + PDC_SYS_CTL); /* flush */
704 700
701 /* Read current counter value */
702 start_count = pdc_read_counter(host);
703 do_gettimeofday(&start_time);
704
705 /* Let the counter run for 100 ms. */ 705 /* Let the counter run for 100 ms. */
706 mdelay(100); 706 mdelay(100);
707 707
@@ -719,7 +719,7 @@ static long pdc_detect_pll_input_clock(struct ata_host *host)
719 usec_elapsed = (end_time.tv_sec - start_time.tv_sec) * 1000000 + 719 usec_elapsed = (end_time.tv_sec - start_time.tv_sec) * 1000000 +
720 (end_time.tv_usec - start_time.tv_usec); 720 (end_time.tv_usec - start_time.tv_usec);
721 721
722 pll_clock = (start_count - end_count) / 100 * 722 pll_clock = ((start_count - end_count) & 0x3fffffff) / 100 *
723 (100000000 / usec_elapsed); 723 (100000000 / usec_elapsed);
724 724
725 PDPRINTK("start[%ld] end[%ld] \n", start_count, end_count); 725 PDPRINTK("start[%ld] end[%ld] \n", start_count, end_count);
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index 66bd0e83ac07..2bd7645f1a88 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -54,6 +54,7 @@ struct sis_laptop {
54static const struct sis_laptop sis_laptop[] = { 54static const struct sis_laptop sis_laptop[] = {
55 /* devid, subvendor, subdev */ 55 /* devid, subvendor, subdev */
56 { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */ 56 { 0x5513, 0x1043, 0x1107 }, /* ASUS A6K */
57 { 0x5513, 0x1734, 0x105F }, /* FSC Amilo A1630 */
57 /* end marker */ 58 /* end marker */
58 { 0, } 59 { 0, }
59}; 60};
diff --git a/drivers/ata/pata_via.c b/drivers/ata/pata_via.c
index f645fe22cd1e..ea18e33f50ef 100644
--- a/drivers/ata/pata_via.c
+++ b/drivers/ata/pata_via.c
@@ -63,7 +63,7 @@
63#include <linux/dmi.h> 63#include <linux/dmi.h>
64 64
65#define DRV_NAME "pata_via" 65#define DRV_NAME "pata_via"
66#define DRV_VERSION "0.3.1" 66#define DRV_VERSION "0.3.2"
67 67
68/* 68/*
69 * The following comes directly from Vojtech Pavlik's ide/pci/via82cxxx 69 * The following comes directly from Vojtech Pavlik's ide/pci/via82cxxx
@@ -144,6 +144,9 @@ static int via_cable_override(struct pci_dev *pdev)
144 /* Systems by DMI */ 144 /* Systems by DMI */
145 if (dmi_check_system(cable_dmi_table)) 145 if (dmi_check_system(cable_dmi_table))
146 return 1; 146 return 1;
147 /* Arima W730-K8/Targa Visionary 811/... */
148 if (pdev->subsystem_vendor == 0x161F && pdev->subsystem_device == 0x2032)
149 return 1;
147 return 0; 150 return 0;
148} 151}
149 152
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 8ec520885b95..3acf65e75eb2 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -621,6 +621,9 @@ static const struct pci_device_id mv_pci_tbl[] = {
621 { PCI_VDEVICE(MARVELL, 0x5041), chip_504x }, 621 { PCI_VDEVICE(MARVELL, 0x5041), chip_504x },
622 { PCI_VDEVICE(MARVELL, 0x5080), chip_5080 }, 622 { PCI_VDEVICE(MARVELL, 0x5080), chip_5080 },
623 { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, 623 { PCI_VDEVICE(MARVELL, 0x5081), chip_508x },
624 /* RocketRAID 1740/174x have different identifiers */
625 { PCI_VDEVICE(TTI, 0x1740), chip_508x },
626 { PCI_VDEVICE(TTI, 0x1742), chip_508x },
624 627
625 { PCI_VDEVICE(MARVELL, 0x6040), chip_604x }, 628 { PCI_VDEVICE(MARVELL, 0x6040), chip_604x },
626 { PCI_VDEVICE(MARVELL, 0x6041), chip_604x }, 629 { PCI_VDEVICE(MARVELL, 0x6041), chip_604x },
diff --git a/drivers/atm/Kconfig b/drivers/atm/Kconfig
index bed9f58c2d5a..b554edac1ced 100644
--- a/drivers/atm/Kconfig
+++ b/drivers/atm/Kconfig
@@ -6,6 +6,11 @@ menuconfig ATM_DRIVERS
6 bool "ATM drivers" 6 bool "ATM drivers"
7 depends on NETDEVICES && ATM 7 depends on NETDEVICES && ATM
8 default y 8 default y
9 ---help---
10 Say Y here to get to see options for Asynchronous Transfer Mode
11 device drivers. This option alone does not add any kernel code.
12
13 If you say N, all options in this submenu will be skipped and disabled.
9 14
10if ATM_DRIVERS && NETDEVICES && ATM 15if ATM_DRIVERS && NETDEVICES && ATM
11 16
diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
index de2fcce10ba5..043353bd0600 100644
--- a/drivers/auxdisplay/Kconfig
+++ b/drivers/auxdisplay/Kconfig
@@ -8,6 +8,11 @@
8menuconfig AUXDISPLAY 8menuconfig AUXDISPLAY
9 depends on PARPORT 9 depends on PARPORT
10 bool "Auxiliary Display support" 10 bool "Auxiliary Display support"
11 ---help---
12 Say Y here to get to see options for auxiliary display drivers.
13 This option alone does not add any kernel code.
14
15 If you say N, all options in this submenu will be skipped and disabled.
11 16
12if AUXDISPLAY && PARPORT 17if AUXDISPLAY && PARPORT
13 18
diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
index cb44cb4f6a47..80bb06105387 100644
--- a/drivers/auxdisplay/cfag12864b.c
+++ b/drivers/auxdisplay/cfag12864b.c
@@ -355,7 +355,7 @@ static int __init cfag12864b_init(void)
355 355
356 cfag12864b_cache = kmalloc(sizeof(unsigned char) * 356 cfag12864b_cache = kmalloc(sizeof(unsigned char) *
357 CFAG12864B_SIZE, GFP_KERNEL); 357 CFAG12864B_SIZE, GFP_KERNEL);
358 if (cfag12864b_buffer == NULL) { 358 if (cfag12864b_cache == NULL) {
359 printk(KERN_ERR CFAG12864B_NAME ": ERROR: " 359 printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
360 "can't alloc cache buffer (%i bytes)\n", 360 "can't alloc cache buffer (%i bytes)\n",
361 CFAG12864B_SIZE); 361 CFAG12864B_SIZE);
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index a4a311992408..4245b7f80a49 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -6,6 +6,12 @@ menuconfig BLK_DEV
6 bool "Block devices" 6 bool "Block devices"
7 depends on BLOCK 7 depends on BLOCK
8 default y 8 default y
9 ---help---
10 Say Y here to get to see options for various different block device
11 drivers. This option alone does not add any kernel code.
12
13 If you say N, all options in this submenu will be skipped and disabled;
14 only do this if you know what you are doing.
9 15
10if BLK_DEV 16if BLK_DEV
11 17
@@ -62,6 +68,7 @@ config AMIGA_Z2RAM
62config BLK_DEV_XD 68config BLK_DEV_XD
63 tristate "XT hard disk support" 69 tristate "XT hard disk support"
64 depends on ISA && ISA_DMA_API 70 depends on ISA && ISA_DMA_API
71 select CHECK_SIGNATURE
65 help 72 help
66 Very old 8 bit hard disk controllers used in the IBM XT computer 73 Very old 8 bit hard disk controllers used in the IBM XT computer
67 will be supported if you say Y here. 74 will be supported if you say Y here.
diff --git a/drivers/block/lguest_blk.c b/drivers/block/lguest_blk.c
index 93e3c4001bf5..160cf14431ac 100644
--- a/drivers/block/lguest_blk.c
+++ b/drivers/block/lguest_blk.c
@@ -308,9 +308,12 @@ static int lguestblk_probe(struct lguest_device *lgdev)
308 } 308 }
309 309
310 /* This allocates a "struct gendisk" where we pack all the information 310 /* This allocates a "struct gendisk" where we pack all the information
311 * about the disk which the rest of Linux sees. We ask for one minor 311 * about the disk which the rest of Linux sees. The argument is the
312 * number; I do wonder if we should be asking for more. */ 312 * number of minor devices desired: we need one minor for the main
313 bd->disk = alloc_disk(1); 313 * disk, and one for each partition. Of course, we can't possibly know
314 * how many partitions are on the disk (add_disk does that).
315 */
316 bd->disk = alloc_disk(16);
314 if (!bd->disk) { 317 if (!bd->disk) {
315 err = -ENOMEM; 318 err = -ENOMEM;
316 goto out_unregister_blkdev; 319 goto out_unregister_blkdev;
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index 4dff49256ac2..317a790c153b 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -417,7 +417,7 @@ static int __send_request(struct request *req)
417 desc->req_id = port->req_id; 417 desc->req_id = port->req_id;
418 desc->operation = op; 418 desc->operation = op;
419 if (port->vdisk_type == VD_DISK_TYPE_DISK) { 419 if (port->vdisk_type == VD_DISK_TYPE_DISK) {
420 desc->slice = 2; 420 desc->slice = 0xff;
421 } else { 421 } else {
422 desc->slice = 0; 422 desc->slice = 0;
423 } 423 }
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index df0ddf14b85c..f60bca70d1fb 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -223,6 +223,8 @@ static int amd_irongate_configure(void)
223 pci_read_config_dword(agp_bridge->dev, AMD_MMBASE, &temp); 223 pci_read_config_dword(agp_bridge->dev, AMD_MMBASE, &temp);
224 temp = (temp & PCI_BASE_ADDRESS_MEM_MASK); 224 temp = (temp & PCI_BASE_ADDRESS_MEM_MASK);
225 amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096); 225 amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
226 if (!amd_irongate_private.registers)
227 return -ENOMEM;
226 228
227 /* Write out the address of the gatt table */ 229 /* Write out the address of the gatt table */
228 writel(agp_bridge->gatt_bus_addr, amd_irongate_private.registers+AMD_ATTBASE); 230 writel(agp_bridge->gatt_bus_addr, amd_irongate_private.registers+AMD_ATTBASE);
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index da7513d7b4e7..2d46b713c8f2 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -213,6 +213,9 @@ static int ati_configure(void)
213 temp = (temp & 0xfffff000); 213 temp = (temp & 0xfffff000);
214 ati_generic_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096); 214 ati_generic_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
215 215
216 if (!ati_generic_private.registers)
217 return -ENOMEM;
218
216 if (is_r200()) 219 if (is_r200())
217 pci_write_config_dword(agp_bridge->dev, ATI_RS100_IG_AGPMODE, 0x20000); 220 pci_write_config_dword(agp_bridge->dev, ATI_RS100_IG_AGPMODE, 0x20000);
218 else 221 else
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index df8da7262853..d78cd09186aa 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -375,6 +375,7 @@ static int __devinit agp_efficeon_probe(struct pci_dev *pdev,
375 if (!r->start && r->end) { 375 if (!r->start && r->end) {
376 if (pci_assign_resource(pdev, 0)) { 376 if (pci_assign_resource(pdev, 0)) {
377 printk(KERN_ERR PFX "could not assign resource 0\n"); 377 printk(KERN_ERR PFX "could not assign resource 0\n");
378 agp_put_bridge(bridge);
378 return -ENODEV; 379 return -ENODEV;
379 } 380 }
380 } 381 }
@@ -386,6 +387,7 @@ static int __devinit agp_efficeon_probe(struct pci_dev *pdev,
386 */ 387 */
387 if (pci_enable_device(pdev)) { 388 if (pci_enable_device(pdev)) {
388 printk(KERN_ERR PFX "Unable to Enable PCI device\n"); 389 printk(KERN_ERR PFX "Unable to Enable PCI device\n");
390 agp_put_bridge(bridge);
389 return -ENODEV; 391 return -ENODEV;
390 } 392 }
391 393
diff --git a/drivers/char/agp/hp-agp.c b/drivers/char/agp/hp-agp.c
index bcdb149c8179..313a133a1172 100644
--- a/drivers/char/agp/hp-agp.c
+++ b/drivers/char/agp/hp-agp.c
@@ -221,6 +221,7 @@ hp_zx1_lba_init (u64 hpa)
221 if (cap != PCI_CAP_ID_AGP) { 221 if (cap != PCI_CAP_ID_AGP) {
222 printk(KERN_ERR PFX "Invalid capability ID 0x%02x at 0x%x\n", 222 printk(KERN_ERR PFX "Invalid capability ID 0x%02x at 0x%x\n",
223 cap, hp->lba_cap_offset); 223 cap, hp->lba_cap_offset);
224 iounmap(hp->lba_regs);
224 return -ENODEV; 225 return -ENODEV;
225 } 226 }
226 227
diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c
index 53354bf83af7..75d2aca6353d 100644
--- a/drivers/char/agp/i460-agp.c
+++ b/drivers/char/agp/i460-agp.c
@@ -249,6 +249,10 @@ static int i460_create_gatt_table (struct agp_bridge_data *bridge)
249 num_entries = A_SIZE_8(temp)->num_entries; 249 num_entries = A_SIZE_8(temp)->num_entries;
250 250
251 i460.gatt = ioremap(INTEL_I460_ATTBASE, PAGE_SIZE << page_order); 251 i460.gatt = ioremap(INTEL_I460_ATTBASE, PAGE_SIZE << page_order);
252 if (!i460.gatt) {
253 printk(KERN_ERR PFX "ioremap failed\n");
254 return -ENOMEM;
255 }
252 256
253 /* These are no good, the should be removed from the agp_bridge strucure... */ 257 /* These are no good, the should be removed from the agp_bridge strucure... */
254 agp_bridge->gatt_table_real = NULL; 258 agp_bridge->gatt_table_real = NULL;
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 294cdbf4d44d..2c9ca2c64628 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -930,8 +930,10 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
930 temp &= 0xfff80000; 930 temp &= 0xfff80000;
931 931
932 intel_private.registers = ioremap(temp,128 * 4096); 932 intel_private.registers = ioremap(temp,128 * 4096);
933 if (!intel_private.registers) 933 if (!intel_private.registers) {
934 iounmap(intel_private.gtt);
934 return -ENOMEM; 935 return -ENOMEM;
936 }
935 937
936 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; 938 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
937 global_cache_flush(); /* FIXME: ? */ 939 global_cache_flush(); /* FIXME: ? */
@@ -985,13 +987,15 @@ static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
985 temp &= 0xfff00000; 987 temp &= 0xfff00000;
986 intel_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024); 988 intel_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024);
987 989
988 if (!intel_private.gtt) 990 if (!intel_private.gtt)
989 return -ENOMEM; 991 return -ENOMEM;
990 992
991 993
992 intel_private.registers = ioremap(temp,128 * 4096); 994 intel_private.registers = ioremap(temp,128 * 4096);
993 if (!intel_private.registers) 995 if (!intel_private.registers) {
994 return -ENOMEM; 996 iounmap(intel_private.gtt);
997 return -ENOMEM;
998 }
995 999
996 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; 1000 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
997 global_cache_flush(); /* FIXME: ? */ 1001 global_cache_flush(); /* FIXME: ? */
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 6cd7373dcdf4..225ed2a53d45 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -157,6 +157,9 @@ static int nvidia_configure(void)
157 nvidia_private.aperture = 157 nvidia_private.aperture =
158 (volatile u32 __iomem *) ioremap(apbase, 33 * PAGE_SIZE); 158 (volatile u32 __iomem *) ioremap(apbase, 33 * PAGE_SIZE);
159 159
160 if (!nvidia_private.aperture)
161 return -ENOMEM;
162
160 return 0; 163 return 0;
161} 164}
162 165
diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
index 9aaf401a8975..0ecc54d327bc 100644
--- a/drivers/char/agp/via-agp.c
+++ b/drivers/char/agp/via-agp.c
@@ -399,6 +399,11 @@ static struct agp_device_ids via_agp_device_ids[] __devinitdata =
399 .device_id = PCI_DEVICE_ID_VIA_P4M890, 399 .device_id = PCI_DEVICE_ID_VIA_P4M890,
400 .chipset_name = "P4M890", 400 .chipset_name = "P4M890",
401 }, 401 },
402 /* P4M900 */
403 {
404 .device_id = PCI_DEVICE_ID_VIA_VT3364,
405 .chipset_name = "P4M900",
406 },
402 { }, /* dummy final entry, always present */ 407 { }, /* dummy final entry, always present */
403}; 408};
404 409
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index 923174c54a1c..c115b39b8517 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -177,8 +177,14 @@ static int drm_addmap_core(struct drm_device * dev, unsigned int offset,
177 MTRR_TYPE_WRCOMB, 1); 177 MTRR_TYPE_WRCOMB, 1);
178 } 178 }
179 } 179 }
180 if (map->type == _DRM_REGISTERS) 180 if (map->type == _DRM_REGISTERS) {
181 map->handle = ioremap(map->offset, map->size); 181 map->handle = ioremap(map->offset, map->size);
182 if (!map->handle) {
183 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
184 return -ENOMEM;
185 }
186 }
187
182 break; 188 break;
183 case _DRM_SHM: 189 case _DRM_SHM:
184 list = drm_find_matching_map(dev, map); 190 list = drm_find_matching_map(dev, map);
@@ -479,11 +485,6 @@ int drm_rmmap_ioctl(struct inode *inode, struct file *filp,
479 return -EINVAL; 485 return -EINVAL;
480 } 486 }
481 487
482 if (!map) {
483 mutex_unlock(&dev->struct_mutex);
484 return -EINVAL;
485 }
486
487 /* Register and framebuffer maps are permanent */ 488 /* Register and framebuffer maps are permanent */
488 if ((map->type == _DRM_REGISTERS) || (map->type == _DRM_FRAME_BUFFER)) { 489 if ((map->type == _DRM_REGISTERS) || (map->type == _DRM_FRAME_BUFFER)) {
489 mutex_unlock(&dev->struct_mutex); 490 mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index 832de1d9ba7e..3dd1ed3d1bf5 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -560,7 +560,7 @@ via_init_dmablit(struct drm_device *dev)
560 blitq->head = 0; 560 blitq->head = 0;
561 blitq->cur = 0; 561 blitq->cur = 0;
562 blitq->serviced = 0; 562 blitq->serviced = 0;
563 blitq->num_free = VIA_NUM_BLIT_SLOTS; 563 blitq->num_free = VIA_NUM_BLIT_SLOTS - 1;
564 blitq->num_outstanding = 0; 564 blitq->num_outstanding = 0;
565 blitq->is_active = 0; 565 blitq->is_active = 0;
566 blitq->aborting = 0; 566 blitq->aborting = 0;
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index d57083a9e4e0..f2e5cb1bedf3 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2292,7 +2292,7 @@ static int __devinit ipmi_of_probe(struct of_device *dev,
2292 info->irq = irq_of_parse_and_map(dev->node, 0); 2292 info->irq = irq_of_parse_and_map(dev->node, 0);
2293 info->dev = &dev->dev; 2293 info->dev = &dev->dev;
2294 2294
2295 dev_dbg(&dev->dev, "addr 0x%lx regsize %ld spacing %ld irq %x\n", 2295 dev_dbg(&dev->dev, "addr 0x%lx regsize %d spacing %d irq %x\n",
2296 info->io.addr_data, info->io.regsize, info->io.regspacing, 2296 info->io.addr_data, info->io.regsize, info->io.regspacing,
2297 info->irq); 2297 info->irq);
2298 2298
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 2ce0af1bd588..d95f316afb5a 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -1022,10 +1022,6 @@ static const unsigned short x86_keycodes[256] =
1022 308,310,313,314,315,317,318,319,320,357,322,323,324,325,276,330, 1022 308,310,313,314,315,317,318,319,320,357,322,323,324,325,276,330,
1023 332,340,365,342,343,344,345,346,356,270,341,368,369,370,371,372 }; 1023 332,340,365,342,343,344,345,346,356,270,341,368,369,370,371,372 };
1024 1024
1025#ifdef CONFIG_MAC_EMUMOUSEBTN
1026extern int mac_hid_mouse_emulate_buttons(int, int, int);
1027#endif /* CONFIG_MAC_EMUMOUSEBTN */
1028
1029#ifdef CONFIG_SPARC 1025#ifdef CONFIG_SPARC
1030static int sparc_l1_a_state = 0; 1026static int sparc_l1_a_state = 0;
1031extern void sun_do_break(void); 1027extern void sun_do_break(void);
diff --git a/drivers/char/lcd.c b/drivers/char/lcd.c
index 1f0962616ee5..4fe9206f84de 100644
--- a/drivers/char/lcd.c
+++ b/drivers/char/lcd.c
@@ -25,7 +25,6 @@
25#include <asm/io.h> 25#include <asm/io.h>
26#include <asm/uaccess.h> 26#include <asm/uaccess.h>
27#include <asm/system.h> 27#include <asm/system.h>
28#include <linux/delay.h>
29 28
30#include "lcd.h" 29#include "lcd.h"
31 30
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index aeec67e27264..859858561ab6 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -875,7 +875,7 @@ found:
875 875
876#ifdef CONFIG_ACPI 876#ifdef CONFIG_ACPI
877 if (sonypi_acpi_device) 877 if (sonypi_acpi_device)
878 acpi_bus_generate_event(sonypi_acpi_device, 1, event); 878 acpi_bus_generate_proc_event(sonypi_acpi_device, 1, event);
879#endif 879#endif
880 880
881 kfifo_put(sonypi_device.fifo, (unsigned char *)&event, sizeof(event)); 881 kfifo_put(sonypi_device.fifo, (unsigned char *)&event, sizeof(event));
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index bbb7f1292665..2f97d2f8f916 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -1565,6 +1565,9 @@ static int hdlcdev_open(struct net_device *dev)
1565 int rc; 1565 int rc;
1566 unsigned long flags; 1566 unsigned long flags;
1567 1567
1568 if (!try_module_get(THIS_MODULE))
1569 return -EBUSY;
1570
1568 DBGINFO(("%s hdlcdev_open\n", dev->name)); 1571 DBGINFO(("%s hdlcdev_open\n", dev->name));
1569 1572
1570 /* generic HDLC layer open processing */ 1573 /* generic HDLC layer open processing */
@@ -1634,6 +1637,7 @@ static int hdlcdev_close(struct net_device *dev)
1634 info->netcount=0; 1637 info->netcount=0;
1635 spin_unlock_irqrestore(&info->netlock, flags); 1638 spin_unlock_irqrestore(&info->netlock, flags);
1636 1639
1640 module_put(THIS_MODULE);
1637 return 0; 1641 return 0;
1638} 1642}
1639 1643
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 9bb542913b86..39564b76d4a3 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -7,7 +7,7 @@
7 * Reiner Sailer <sailer@watson.ibm.com> 7 * Reiner Sailer <sailer@watson.ibm.com>
8 * Kylene Hall <kjhall@us.ibm.com> 8 * Kylene Hall <kjhall@us.ibm.com>
9 * 9 *
10 * Maintained by: <tpmdd_devel@lists.sourceforge.net> 10 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
11 * 11 *
12 * Device driver for TCG/TCPA TPM (trusted platform module). 12 * Device driver for TCG/TCPA TPM (trusted platform module).
13 * Specifications at www.trustedcomputinggroup.org 13 * Specifications at www.trustedcomputinggroup.org
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index b2e2b002a1bb..d15ccddc92eb 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -7,7 +7,7 @@
7 * Reiner Sailer <sailer@watson.ibm.com> 7 * Reiner Sailer <sailer@watson.ibm.com>
8 * Kylene Hall <kjhall@us.ibm.com> 8 * Kylene Hall <kjhall@us.ibm.com>
9 * 9 *
10 * Maintained by: <tpmdd_devel@lists.sourceforge.net> 10 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
11 * 11 *
12 * Device driver for TCG/TCPA TPM (trusted platform module). 12 * Device driver for TCG/TCPA TPM (trusted platform module).
13 * Specifications at www.trustedcomputinggroup.org 13 * Specifications at www.trustedcomputinggroup.org
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index 1ab0896070be..d0e7926eb486 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -7,7 +7,7 @@
7 * Reiner Sailer <sailer@watson.ibm.com> 7 * Reiner Sailer <sailer@watson.ibm.com>
8 * Kylene Hall <kjhall@us.ibm.com> 8 * Kylene Hall <kjhall@us.ibm.com>
9 * 9 *
10 * Maintained by: <tpmdd_devel@lists.sourceforge.net> 10 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
11 * 11 *
12 * Device driver for TCG/TCPA TPM (trusted platform module). 12 * Device driver for TCG/TCPA TPM (trusted platform module).
13 * Specifications at www.trustedcomputinggroup.org 13 * Specifications at www.trustedcomputinggroup.org
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h
index 9363bcf0a402..6c831f9466b7 100644
--- a/drivers/char/tpm/tpm_atmel.h
+++ b/drivers/char/tpm/tpm_atmel.h
@@ -4,7 +4,7 @@
4 * Authors: 4 * Authors:
5 * Kylene Hall <kjhall@us.ibm.com> 5 * Kylene Hall <kjhall@us.ibm.com>
6 * 6 *
7 * Maintained by: <tpmdd_devel@lists.sourceforge.net> 7 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
8 * 8 *
9 * Device driver for TCG/TCPA TPM (trusted platform module). 9 * Device driver for TCG/TCPA TPM (trusted platform module).
10 * Specifications at www.trustedcomputinggroup.org 10 * Specifications at www.trustedcomputinggroup.org
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index 8677fc6a545e..60a2d2630e36 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -7,6 +7,8 @@
7 * Reiner Sailer <sailer@watson.ibm.com> 7 * Reiner Sailer <sailer@watson.ibm.com>
8 * Kylene Hall <kjhall@us.ibm.com> 8 * Kylene Hall <kjhall@us.ibm.com>
9 * 9 *
10 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
11 *
10 * Access to the eventlog extended by the TCG BIOS of PC platform 12 * Access to the eventlog extended by the TCG BIOS of PC platform
11 * 13 *
12 * This program is free software; you can redistribute it and/or 14 * This program is free software; you can redistribute it and/or
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index 608f73071bef..6313326bc41f 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -7,7 +7,7 @@
7 * Reiner Sailer <sailer@watson.ibm.com> 7 * Reiner Sailer <sailer@watson.ibm.com>
8 * Kylene Hall <kjhall@us.ibm.com> 8 * Kylene Hall <kjhall@us.ibm.com>
9 * 9 *
10 * Maintained by: <tpmdd_devel@lists.sourceforge.net> 10 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
11 * 11 *
12 * Device driver for TCG/TCPA TPM (trusted platform module). 12 * Device driver for TCG/TCPA TPM (trusted platform module).
13 * Specifications at www.trustedcomputinggroup.org 13 * Specifications at www.trustedcomputinggroup.org
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 483f3f60013c..23fa18a6654c 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -5,6 +5,8 @@
5 * Leendert van Doorn <leendert@watson.ibm.com> 5 * Leendert van Doorn <leendert@watson.ibm.com>
6 * Kylene Hall <kjhall@us.ibm.com> 6 * Kylene Hall <kjhall@us.ibm.com>
7 * 7 *
8 * Maintained by: <tpmdd-devel@lists.sourceforge.net>
9 *
8 * Device driver for TCG/TCPA TPM (trusted platform module). 10 * Device driver for TCG/TCPA TPM (trusted platform module).
9 * Specifications at www.trustedcomputinggroup.org 11 * Specifications at www.trustedcomputinggroup.org
10 * 12 *
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 51ea93cab6c4..9c867cf6de64 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2063,8 +2063,7 @@ static int init_dev(struct tty_driver *driver, int idx,
2063 } 2063 }
2064 2064
2065 if (!*tp_loc) { 2065 if (!*tp_loc) {
2066 tp = (struct ktermios *) kmalloc(sizeof(struct ktermios), 2066 tp = kmalloc(sizeof(struct ktermios), GFP_KERNEL);
2067 GFP_KERNEL);
2068 if (!tp) 2067 if (!tp)
2069 goto free_mem_out; 2068 goto free_mem_out;
2070 *tp = driver->init_termios; 2069 *tp = driver->init_termios;
@@ -2094,8 +2093,7 @@ static int init_dev(struct tty_driver *driver, int idx,
2094 } 2093 }
2095 2094
2096 if (!*o_tp_loc) { 2095 if (!*o_tp_loc) {
2097 o_tp = (struct ktermios *) 2096 o_tp = kmalloc(sizeof(struct ktermios), GFP_KERNEL);
2098 kmalloc(sizeof(struct ktermios), GFP_KERNEL);
2099 if (!o_tp) 2097 if (!o_tp)
2100 goto free_mem_out; 2098 goto free_mem_out;
2101 *o_tp = driver->other->init_termios; 2099 *o_tp = driver->other->init_termios;
diff --git a/drivers/char/watchdog/alim1535_wdt.c b/drivers/char/watchdog/alim1535_wdt.c
index e3f6a7d0c83d..c404fc69e7e6 100644
--- a/drivers/char/watchdog/alim1535_wdt.c
+++ b/drivers/char/watchdog/alim1535_wdt.c
@@ -312,6 +312,7 @@ static int ali_notify_sys(struct notifier_block *this, unsigned long code, void
312 */ 312 */
313 313
314static struct pci_device_id ali_pci_tbl[] = { 314static struct pci_device_id ali_pci_tbl[] = {
315 { PCI_VENDOR_ID_AL, 0x1533, PCI_ANY_ID, PCI_ANY_ID,},
315 { PCI_VENDOR_ID_AL, 0x1535, PCI_ANY_ID, PCI_ANY_ID,}, 316 { PCI_VENDOR_ID_AL, 0x1535, PCI_ANY_ID, PCI_ANY_ID,},
316 { 0, }, 317 { 0, },
317}; 318};
@@ -329,9 +330,11 @@ static int __init ali_find_watchdog(void)
329 struct pci_dev *pdev; 330 struct pci_dev *pdev;
330 u32 wdog; 331 u32 wdog;
331 332
332 /* Check for a 1535 series bridge */ 333 /* Check for a 1533/1535 series bridge */
333 pdev = pci_get_device(PCI_VENDOR_ID_AL, 0x1535, NULL); 334 pdev = pci_get_device(PCI_VENDOR_ID_AL, 0x1535, NULL);
334 if(pdev == NULL) 335 if (pdev == NULL)
336 pdev = pci_get_device(PCI_VENDOR_ID_AL, 0x1533, NULL);
337 if (pdev == NULL)
335 return -ENODEV; 338 return -ENODEV;
336 pci_dev_put(pdev); 339 pci_dev_put(pdev);
337 340
diff --git a/drivers/char/watchdog/eurotechwdt.c b/drivers/char/watchdog/eurotechwdt.c
index b070324e27a6..b14e9d1f164d 100644
--- a/drivers/char/watchdog/eurotechwdt.c
+++ b/drivers/char/watchdog/eurotechwdt.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Eurotech CPU-1220/1410 on board WDT driver 2 * Eurotech CPU-1220/1410/1420 on board WDT driver
3 * 3 *
4 * (c) Copyright 2001 Ascensit <support@ascensit.com> 4 * (c) Copyright 2001 Ascensit <support@ascensit.com>
5 * (c) Copyright 2001 Rodolfo Giometti <giometti@ascensit.com> 5 * (c) Copyright 2001 Rodolfo Giometti <giometti@ascensit.com>
@@ -25,6 +25,9 @@
25 25
26/* Changelog: 26/* Changelog:
27 * 27 *
28 * 2001 - Rodolfo Giometti
29 * Initial release
30 *
28 * 2002/04/25 - Rob Radez 31 * 2002/04/25 - Rob Radez
29 * clean up #includes 32 * clean up #includes
30 * clean up locking 33 * clean up locking
@@ -33,13 +36,15 @@
33 * add WDIOC_GETSTATUS and WDIOC_SETOPTIONS ioctls 36 * add WDIOC_GETSTATUS and WDIOC_SETOPTIONS ioctls
34 * add expect_close support 37 * add expect_close support
35 * 38 *
36 * 2001 - Rodolfo Giometti
37 * Initial release
38 *
39 * 2002.05.30 - Joel Becker <joel.becker@oracle.com> 39 * 2002.05.30 - Joel Becker <joel.becker@oracle.com>
40 * Added Matt Domsch's nowayout module option. 40 * Added Matt Domsch's nowayout module option.
41 */ 41 */
42 42
43/*
44 * The eurotech CPU-1220/1410/1420's watchdog is a part
45 * of the on-board SUPER I/O device SMSC FDC 37B782.
46 */
47
43#include <linux/interrupt.h> 48#include <linux/interrupt.h>
44#include <linux/module.h> 49#include <linux/module.h>
45#include <linux/moduleparam.h> 50#include <linux/moduleparam.h>
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index 84ebfcc1ffb4..c0fc4aeb8596 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -2,6 +2,11 @@
2menuconfig CRYPTO_HW 2menuconfig CRYPTO_HW
3 bool "Hardware crypto devices" 3 bool "Hardware crypto devices"
4 default y 4 default y
5 ---help---
6 Say Y here to get to see options for hardware crypto devices and
7 processors. This option alone does not add any kernel code.
8
9 If you say N, all options in this submenu will be skipped and disabled.
5 10
6if CRYPTO_HW 11if CRYPTO_HW
7 12
diff --git a/drivers/dma/ioatdma.c b/drivers/dma/ioatdma.c
index 5fbe56b5cea0..41b18c5a3141 100644
--- a/drivers/dma/ioatdma.c
+++ b/drivers/dma/ioatdma.c
@@ -191,17 +191,12 @@ static int ioat_dma_alloc_chan_resources(struct dma_chan *chan)
191 int i; 191 int i;
192 LIST_HEAD(tmp_list); 192 LIST_HEAD(tmp_list);
193 193
194 /* 194 /* have we already been set up? */
195 * In-use bit automatically set by reading chanctrl 195 if (!list_empty(&ioat_chan->free_desc))
196 * If 0, we got it, if 1, someone else did 196 return INITIAL_IOAT_DESC_COUNT;
197 */
198 chanctrl = readw(ioat_chan->reg_base + IOAT_CHANCTRL_OFFSET);
199 if (chanctrl & IOAT_CHANCTRL_CHANNEL_IN_USE)
200 return -EBUSY;
201 197
202 /* Setup register to interrupt and write completion status on error */ 198 /* Setup register to interrupt and write completion status on error */
203 chanctrl = IOAT_CHANCTRL_CHANNEL_IN_USE | 199 chanctrl = IOAT_CHANCTRL_ERR_INT_EN |
204 IOAT_CHANCTRL_ERR_INT_EN |
205 IOAT_CHANCTRL_ANY_ERR_ABORT_EN | 200 IOAT_CHANCTRL_ANY_ERR_ABORT_EN |
206 IOAT_CHANCTRL_ERR_COMPLETION_EN; 201 IOAT_CHANCTRL_ERR_COMPLETION_EN;
207 writew(chanctrl, ioat_chan->reg_base + IOAT_CHANCTRL_OFFSET); 202 writew(chanctrl, ioat_chan->reg_base + IOAT_CHANCTRL_OFFSET);
@@ -282,11 +277,6 @@ static void ioat_dma_free_chan_resources(struct dma_chan *chan)
282 in_use_descs - 1); 277 in_use_descs - 1);
283 278
284 ioat_chan->last_completion = ioat_chan->completion_addr = 0; 279 ioat_chan->last_completion = ioat_chan->completion_addr = 0;
285
286 /* Tell hw the chan is free */
287 chanctrl = readw(ioat_chan->reg_base + IOAT_CHANCTRL_OFFSET);
288 chanctrl &= ~IOAT_CHANCTRL_CHANNEL_IN_USE;
289 writew(chanctrl, ioat_chan->reg_base + IOAT_CHANCTRL_OFFSET);
290} 280}
291 281
292static struct dma_async_tx_descriptor * 282static struct dma_async_tx_descriptor *
@@ -347,8 +337,7 @@ ioat_dma_prep_memcpy(struct dma_chan *chan, size_t len, int int_en)
347 new->async_tx.ack = 0; /* client is in control of this ack */ 337 new->async_tx.ack = 0; /* client is in control of this ack */
348 new->async_tx.cookie = -EBUSY; 338 new->async_tx.cookie = -EBUSY;
349 339
350 pci_unmap_len_set(new, src_len, orig_len); 340 pci_unmap_len_set(new, len, orig_len);
351 pci_unmap_len_set(new, dst_len, orig_len);
352 spin_unlock_bh(&ioat_chan->desc_lock); 341 spin_unlock_bh(&ioat_chan->desc_lock);
353 342
354 return new ? &new->async_tx : NULL; 343 return new ? &new->async_tx : NULL;
@@ -423,11 +412,11 @@ static void ioat_dma_memcpy_cleanup(struct ioat_dma_chan *chan)
423 */ 412 */
424 pci_unmap_page(chan->device->pdev, 413 pci_unmap_page(chan->device->pdev,
425 pci_unmap_addr(desc, dst), 414 pci_unmap_addr(desc, dst),
426 pci_unmap_len(desc, dst_len), 415 pci_unmap_len(desc, len),
427 PCI_DMA_FROMDEVICE); 416 PCI_DMA_FROMDEVICE);
428 pci_unmap_page(chan->device->pdev, 417 pci_unmap_page(chan->device->pdev,
429 pci_unmap_addr(desc, src), 418 pci_unmap_addr(desc, src),
430 pci_unmap_len(desc, src_len), 419 pci_unmap_len(desc, len),
431 PCI_DMA_TODEVICE); 420 PCI_DMA_TODEVICE);
432 } 421 }
433 422
diff --git a/drivers/dma/ioatdma.h b/drivers/dma/ioatdma.h
index d3726478031a..bf4dad70e0f5 100644
--- a/drivers/dma/ioatdma.h
+++ b/drivers/dma/ioatdma.h
@@ -111,10 +111,9 @@ struct ioat_desc_sw {
111 struct ioat_dma_descriptor *hw; 111 struct ioat_dma_descriptor *hw;
112 struct list_head node; 112 struct list_head node;
113 int tx_cnt; 113 int tx_cnt;
114 DECLARE_PCI_UNMAP_LEN(len)
114 DECLARE_PCI_UNMAP_ADDR(src) 115 DECLARE_PCI_UNMAP_ADDR(src)
115 DECLARE_PCI_UNMAP_LEN(src_len)
116 DECLARE_PCI_UNMAP_ADDR(dst) 116 DECLARE_PCI_UNMAP_ADDR(dst)
117 DECLARE_PCI_UNMAP_LEN(dst_len)
118 struct dma_async_tx_descriptor async_tx; 117 struct dma_async_tx_descriptor async_tx;
119}; 118};
120 119
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index 0aeab3218bb6..3e9719948a8e 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -510,9 +510,11 @@ fw_core_remove_card(struct fw_card *card)
510 /* Set up the dummy driver. */ 510 /* Set up the dummy driver. */
511 card->driver = &dummy_driver; 511 card->driver = &dummy_driver;
512 512
513 fw_flush_transactions(card);
514
515 fw_destroy_nodes(card); 513 fw_destroy_nodes(card);
514 flush_scheduled_work();
515
516 fw_flush_transactions(card);
517 del_timer_sync(&card->flush_timer);
516 518
517 fw_card_put(card); 519 fw_card_put(card);
518} 520}
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index ba816ef6def1..238730f75db1 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -159,6 +159,7 @@ struct sbp2_pointer {
159 159
160struct sbp2_orb { 160struct sbp2_orb {
161 struct fw_transaction t; 161 struct fw_transaction t;
162 struct kref kref;
162 dma_addr_t request_bus; 163 dma_addr_t request_bus;
163 int rcode; 164 int rcode;
164 struct sbp2_pointer pointer; 165 struct sbp2_pointer pointer;
@@ -280,6 +281,14 @@ static const struct {
280}; 281};
281 282
282static void 283static void
284free_orb(struct kref *kref)
285{
286 struct sbp2_orb *orb = container_of(kref, struct sbp2_orb, kref);
287
288 kfree(orb);
289}
290
291static void
283sbp2_status_write(struct fw_card *card, struct fw_request *request, 292sbp2_status_write(struct fw_card *card, struct fw_request *request,
284 int tcode, int destination, int source, 293 int tcode, int destination, int source,
285 int generation, int speed, 294 int generation, int speed,
@@ -312,8 +321,8 @@ sbp2_status_write(struct fw_card *card, struct fw_request *request,
312 spin_lock_irqsave(&card->lock, flags); 321 spin_lock_irqsave(&card->lock, flags);
313 list_for_each_entry(orb, &sd->orb_list, link) { 322 list_for_each_entry(orb, &sd->orb_list, link) {
314 if (STATUS_GET_ORB_HIGH(status) == 0 && 323 if (STATUS_GET_ORB_HIGH(status) == 0 &&
315 STATUS_GET_ORB_LOW(status) == orb->request_bus && 324 STATUS_GET_ORB_LOW(status) == orb->request_bus) {
316 orb->rcode == RCODE_COMPLETE) { 325 orb->rcode = RCODE_COMPLETE;
317 list_del(&orb->link); 326 list_del(&orb->link);
318 break; 327 break;
319 } 328 }
@@ -325,6 +334,8 @@ sbp2_status_write(struct fw_card *card, struct fw_request *request,
325 else 334 else
326 fw_error("status write for unknown orb\n"); 335 fw_error("status write for unknown orb\n");
327 336
337 kref_put(&orb->kref, free_orb);
338
328 fw_send_response(card, request, RCODE_COMPLETE); 339 fw_send_response(card, request, RCODE_COMPLETE);
329} 340}
330 341
@@ -335,13 +346,27 @@ complete_transaction(struct fw_card *card, int rcode,
335 struct sbp2_orb *orb = data; 346 struct sbp2_orb *orb = data;
336 unsigned long flags; 347 unsigned long flags;
337 348
338 orb->rcode = rcode; 349 /*
339 if (rcode != RCODE_COMPLETE) { 350 * This is a little tricky. We can get the status write for
340 spin_lock_irqsave(&card->lock, flags); 351 * the orb before we get this callback. The status write
352 * handler above will assume the orb pointer transaction was
353 * successful and set the rcode to RCODE_COMPLETE for the orb.
354 * So this callback only sets the rcode if it hasn't already
355 * been set and only does the cleanup if the transaction
356 * failed and we didn't already get a status write.
357 */
358 spin_lock_irqsave(&card->lock, flags);
359
360 if (orb->rcode == -1)
361 orb->rcode = rcode;
362 if (orb->rcode != RCODE_COMPLETE) {
341 list_del(&orb->link); 363 list_del(&orb->link);
342 spin_unlock_irqrestore(&card->lock, flags);
343 orb->callback(orb, NULL); 364 orb->callback(orb, NULL);
344 } 365 }
366
367 spin_unlock_irqrestore(&card->lock, flags);
368
369 kref_put(&orb->kref, free_orb);
345} 370}
346 371
347static void 372static void
@@ -360,6 +385,10 @@ sbp2_send_orb(struct sbp2_orb *orb, struct fw_unit *unit,
360 list_add_tail(&orb->link, &sd->orb_list); 385 list_add_tail(&orb->link, &sd->orb_list);
361 spin_unlock_irqrestore(&device->card->lock, flags); 386 spin_unlock_irqrestore(&device->card->lock, flags);
362 387
388 /* Take a ref for the orb list and for the transaction callback. */
389 kref_get(&orb->kref);
390 kref_get(&orb->kref);
391
363 fw_send_request(device->card, &orb->t, TCODE_WRITE_BLOCK_REQUEST, 392 fw_send_request(device->card, &orb->t, TCODE_WRITE_BLOCK_REQUEST,
364 node_id, generation, device->max_speed, offset, 393 node_id, generation, device->max_speed, offset,
365 &orb->pointer, sizeof(orb->pointer), 394 &orb->pointer, sizeof(orb->pointer),
@@ -416,6 +445,7 @@ sbp2_send_management_orb(struct fw_unit *unit, int node_id, int generation,
416 if (orb == NULL) 445 if (orb == NULL)
417 return -ENOMEM; 446 return -ENOMEM;
418 447
448 kref_init(&orb->base.kref);
419 orb->response_bus = 449 orb->response_bus =
420 dma_map_single(device->card->device, &orb->response, 450 dma_map_single(device->card->device, &orb->response,
421 sizeof(orb->response), DMA_FROM_DEVICE); 451 sizeof(orb->response), DMA_FROM_DEVICE);
@@ -490,7 +520,7 @@ sbp2_send_management_orb(struct fw_unit *unit, int node_id, int generation,
490 if (response) 520 if (response)
491 fw_memcpy_from_be32(response, 521 fw_memcpy_from_be32(response,
492 orb->response, sizeof(orb->response)); 522 orb->response, sizeof(orb->response));
493 kfree(orb); 523 kref_put(&orb->base.kref, free_orb);
494 524
495 return retval; 525 return retval;
496} 526}
@@ -886,7 +916,6 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
886 916
887 orb->cmd->result = result; 917 orb->cmd->result = result;
888 orb->done(orb->cmd); 918 orb->done(orb->cmd);
889 kfree(orb);
890} 919}
891 920
892static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb) 921static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb)
@@ -1005,6 +1034,7 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1005 1034
1006 /* Initialize rcode to something not RCODE_COMPLETE. */ 1035 /* Initialize rcode to something not RCODE_COMPLETE. */
1007 orb->base.rcode = -1; 1036 orb->base.rcode = -1;
1037 kref_init(&orb->base.kref);
1008 1038
1009 orb->unit = unit; 1039 orb->unit = unit;
1010 orb->done = done; 1040 orb->done = done;
@@ -1051,10 +1081,11 @@ static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done)
1051 sbp2_send_orb(&orb->base, unit, sd->node_id, sd->generation, 1081 sbp2_send_orb(&orb->base, unit, sd->node_id, sd->generation,
1052 sd->command_block_agent_address + SBP2_ORB_POINTER); 1082 sd->command_block_agent_address + SBP2_ORB_POINTER);
1053 1083
1084 kref_put(&orb->base.kref, free_orb);
1054 return 0; 1085 return 0;
1055 1086
1056 fail_mapping: 1087 fail_mapping:
1057 kfree(orb); 1088 kref_put(&orb->base.kref, free_orb);
1058 fail_alloc: 1089 fail_alloc:
1059 return SCSI_MLQUEUE_HOST_BUSY; 1090 return SCSI_MLQUEUE_HOST_BUSY;
1060} 1091}
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 3b63b0b78122..19667fcc722a 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -5,6 +5,11 @@ menuconfig HID_SUPPORT
5 bool "HID Devices" 5 bool "HID Devices"
6 depends on INPUT 6 depends on INPUT
7 default y 7 default y
8 ---help---
9 Say Y here to get to see options for various computer-human interface
10 device drivers. This option alone does not add any kernel code.
11
12 If you say N, all options in this submenu will be skipped and disabled.
8 13
9if HID_SUPPORT 14if HID_SUPPORT
10 15
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 338ee4f54614..d3181967f167 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -585,6 +585,8 @@ static int __devinit smsc47m1_probe(struct platform_device *pdev)
585 585
586 if ((err = device_create_file(dev, &dev_attr_alarms))) 586 if ((err = device_create_file(dev, &dev_attr_alarms)))
587 goto error_remove_files; 587 goto error_remove_files;
588 if ((err = device_create_file(dev, &dev_attr_name)))
589 goto error_remove_files;
588 590
589 data->class_dev = hwmon_device_register(dev); 591 data->class_dev = hwmon_device_register(dev);
590 if (IS_ERR(data->class_dev)) { 592 if (IS_ERR(data->class_dev)) {
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index c51ae2e17758..d9a9ec7dd84a 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -309,18 +309,16 @@ static inline int is_word_sized(u16 reg)
309 || (reg & 0x00ff) == 0x55)); 309 || (reg & 0x00ff) == 0x55));
310} 310}
311 311
312/* We assume that the default bank is 0, thus the following two functions do 312/* Registers 0x50-0x5f are banked */
313 nothing for registers which live in bank 0. For others, they respectively
314 set the bank register to the correct value (before the register is
315 accessed), and back to 0 (afterwards). */
316static inline void w83627ehf_set_bank(struct w83627ehf_data *data, u16 reg) 313static inline void w83627ehf_set_bank(struct w83627ehf_data *data, u16 reg)
317{ 314{
318 if (reg & 0xff00) { 315 if ((reg & 0x00f0) == 0x50) {
319 outb_p(W83627EHF_REG_BANK, data->addr + ADDR_REG_OFFSET); 316 outb_p(W83627EHF_REG_BANK, data->addr + ADDR_REG_OFFSET);
320 outb_p(reg >> 8, data->addr + DATA_REG_OFFSET); 317 outb_p(reg >> 8, data->addr + DATA_REG_OFFSET);
321 } 318 }
322} 319}
323 320
321/* Not strictly necessary, but play it safe for now */
324static inline void w83627ehf_reset_bank(struct w83627ehf_data *data, u16 reg) 322static inline void w83627ehf_reset_bank(struct w83627ehf_data *data, u16 reg)
325{ 323{
326 if (reg & 0xff00) { 324 if (reg & 0xff00) {
@@ -421,6 +419,31 @@ static void w83627ehf_write_fan_div(struct w83627ehf_data *data, int nr)
421 } 419 }
422} 420}
423 421
422static void w83627ehf_update_fan_div(struct w83627ehf_data *data)
423{
424 int i;
425
426 i = w83627ehf_read_value(data, W83627EHF_REG_FANDIV1);
427 data->fan_div[0] = (i >> 4) & 0x03;
428 data->fan_div[1] = (i >> 6) & 0x03;
429 i = w83627ehf_read_value(data, W83627EHF_REG_FANDIV2);
430 data->fan_div[2] = (i >> 6) & 0x03;
431 i = w83627ehf_read_value(data, W83627EHF_REG_VBAT);
432 data->fan_div[0] |= (i >> 3) & 0x04;
433 data->fan_div[1] |= (i >> 4) & 0x04;
434 data->fan_div[2] |= (i >> 5) & 0x04;
435 if (data->has_fan & ((1 << 3) | (1 << 4))) {
436 i = w83627ehf_read_value(data, W83627EHF_REG_DIODE);
437 data->fan_div[3] = i & 0x03;
438 data->fan_div[4] = ((i >> 2) & 0x03)
439 | ((i >> 5) & 0x04);
440 }
441 if (data->has_fan & (1 << 3)) {
442 i = w83627ehf_read_value(data, W83627EHF_REG_SMI_OVT);
443 data->fan_div[3] |= (i >> 5) & 0x04;
444 }
445}
446
424static struct w83627ehf_data *w83627ehf_update_device(struct device *dev) 447static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
425{ 448{
426 struct w83627ehf_data *data = dev_get_drvdata(dev); 449 struct w83627ehf_data *data = dev_get_drvdata(dev);
@@ -432,25 +455,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
432 if (time_after(jiffies, data->last_updated + HZ + HZ/2) 455 if (time_after(jiffies, data->last_updated + HZ + HZ/2)
433 || !data->valid) { 456 || !data->valid) {
434 /* Fan clock dividers */ 457 /* Fan clock dividers */
435 i = w83627ehf_read_value(data, W83627EHF_REG_FANDIV1); 458 w83627ehf_update_fan_div(data);
436 data->fan_div[0] = (i >> 4) & 0x03;
437 data->fan_div[1] = (i >> 6) & 0x03;
438 i = w83627ehf_read_value(data, W83627EHF_REG_FANDIV2);
439 data->fan_div[2] = (i >> 6) & 0x03;
440 i = w83627ehf_read_value(data, W83627EHF_REG_VBAT);
441 data->fan_div[0] |= (i >> 3) & 0x04;
442 data->fan_div[1] |= (i >> 4) & 0x04;
443 data->fan_div[2] |= (i >> 5) & 0x04;
444 if (data->has_fan & ((1 << 3) | (1 << 4))) {
445 i = w83627ehf_read_value(data, W83627EHF_REG_DIODE);
446 data->fan_div[3] = i & 0x03;
447 data->fan_div[4] = ((i >> 2) & 0x03)
448 | ((i >> 5) & 0x04);
449 }
450 if (data->has_fan & (1 << 3)) {
451 i = w83627ehf_read_value(data, W83627EHF_REG_SMI_OVT);
452 data->fan_div[3] |= (i >> 5) & 0x04;
453 }
454 459
455 /* Measured voltages and limits */ 460 /* Measured voltages and limits */
456 for (i = 0; i < data->in_num; i++) { 461 for (i = 0; i < data->in_num; i++) {
@@ -1312,6 +1317,9 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
1312 if (!(i & (1 << 1)) && (!fan5pin)) 1317 if (!(i & (1 << 1)) && (!fan5pin))
1313 data->has_fan |= (1 << 4); 1318 data->has_fan |= (1 << 4);
1314 1319
1320 /* Read fan clock dividers immediately */
1321 w83627ehf_update_fan_div(data);
1322
1315 /* Register sysfs hooks */ 1323 /* Register sysfs hooks */
1316 for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays); i++) 1324 for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays); i++)
1317 if ((err = device_create_file(dev, 1325 if ((err = device_create_file(dev,
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index f85b48fea1c4..c95909cc1d21 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -740,9 +740,9 @@ store_sensor(struct device *dev, struct device_attribute *da,
740static SENSOR_DEVICE_ATTR(temp1_type, S_IRUGO | S_IWUSR, 740static SENSOR_DEVICE_ATTR(temp1_type, S_IRUGO | S_IWUSR,
741 show_sensor, store_sensor, 0); 741 show_sensor, store_sensor, 0);
742static SENSOR_DEVICE_ATTR(temp2_type, S_IRUGO | S_IWUSR, 742static SENSOR_DEVICE_ATTR(temp2_type, S_IRUGO | S_IWUSR,
743 show_sensor, store_sensor, 0); 743 show_sensor, store_sensor, 1);
744static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO | S_IWUSR, 744static SENSOR_DEVICE_ATTR(temp3_type, S_IRUGO | S_IWUSR,
745 show_sensor, store_sensor, 0); 745 show_sensor, store_sensor, 2);
746 746
747/* I2C devices get this name attribute automatically, but for ISA devices 747/* I2C devices get this name attribute automatically, but for ISA devices
748 we must create it by ourselves. */ 748 we must create it by ourselves. */
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index e049f65bc3a2..7adb61bad6ad 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -304,9 +304,9 @@ comment "IDE chipset support/bugfixes"
304 304
305config IDE_GENERIC 305config IDE_GENERIC
306 tristate "generic/default IDE chipset support" 306 tristate "generic/default IDE chipset support"
307 default y 307 default H8300
308 help 308 help
309 If unsure, say Y. 309 If unsure, say N.
310 310
311config BLK_DEV_CMD640 311config BLK_DEV_CMD640
312 bool "CMD640 chipset bugfix/support" 312 bool "CMD640 chipset bugfix/support"
@@ -345,6 +345,7 @@ config BLK_DEV_CMD640_ENHANCED
345config BLK_DEV_IDEPNP 345config BLK_DEV_IDEPNP
346 bool "PNP EIDE support" 346 bool "PNP EIDE support"
347 depends on PNP 347 depends on PNP
348 select IDE_GENERIC
348 help 349 help
349 If you have a PnP (Plug and Play) compatible EIDE card and 350 If you have a PnP (Plug and Play) compatible EIDE card and
350 would like the kernel to automatically detect and activate 351 would like the kernel to automatically detect and activate
@@ -834,6 +835,7 @@ config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ
834 835
835config IDE_ARM 836config IDE_ARM
836 def_bool ARM && (ARCH_CLPS7500 || ARCH_RPC || ARCH_SHARK) 837 def_bool ARM && (ARCH_CLPS7500 || ARCH_RPC || ARCH_SHARK)
838 select IDE_GENERIC
837 839
838config BLK_DEV_IDE_ICSIDE 840config BLK_DEV_IDE_ICSIDE
839 tristate "ICS IDE interface support" 841 tristate "ICS IDE interface support"
@@ -867,6 +869,7 @@ config BLK_DEV_IDE_BAST
867config BLK_DEV_GAYLE 869config BLK_DEV_GAYLE
868 bool "Amiga Gayle IDE interface support" 870 bool "Amiga Gayle IDE interface support"
869 depends on AMIGA 871 depends on AMIGA
872 select IDE_GENERIC
870 help 873 help
871 This is the IDE driver for the Amiga Gayle IDE interface. It supports 874 This is the IDE driver for the Amiga Gayle IDE interface. It supports
872 both the `A1200 style' and `A4000 style' of the Gayle IDE interface, 875 both the `A1200 style' and `A4000 style' of the Gayle IDE interface,
@@ -898,6 +901,7 @@ config BLK_DEV_IDEDOUBLER
898config BLK_DEV_BUDDHA 901config BLK_DEV_BUDDHA
899 bool "Buddha/Catweasel/X-Surf IDE interface support (EXPERIMENTAL)" 902 bool "Buddha/Catweasel/X-Surf IDE interface support (EXPERIMENTAL)"
900 depends on ZORRO && EXPERIMENTAL 903 depends on ZORRO && EXPERIMENTAL
904 select IDE_GENERIC
901 help 905 help
902 This is the IDE driver for the IDE interfaces on the Buddha, 906 This is the IDE driver for the IDE interfaces on the Buddha,
903 Catweasel and X-Surf expansion boards. It supports up to two interfaces 907 Catweasel and X-Surf expansion boards. It supports up to two interfaces
@@ -910,6 +914,7 @@ config BLK_DEV_BUDDHA
910config BLK_DEV_FALCON_IDE 914config BLK_DEV_FALCON_IDE
911 bool "Falcon IDE interface support" 915 bool "Falcon IDE interface support"
912 depends on ATARI 916 depends on ATARI
917 select IDE_GENERIC
913 help 918 help
914 This is the IDE driver for the builtin IDE interface on the Atari 919 This is the IDE driver for the builtin IDE interface on the Atari
915 Falcon. Say Y if you have a Falcon and want to use IDE devices (hard 920 Falcon. Say Y if you have a Falcon and want to use IDE devices (hard
@@ -919,6 +924,7 @@ config BLK_DEV_FALCON_IDE
919config BLK_DEV_MAC_IDE 924config BLK_DEV_MAC_IDE
920 bool "Macintosh Quadra/Powerbook IDE interface support" 925 bool "Macintosh Quadra/Powerbook IDE interface support"
921 depends on MAC 926 depends on MAC
927 select IDE_GENERIC
922 help 928 help
923 This is the IDE driver for the builtin IDE interface on some m68k 929 This is the IDE driver for the builtin IDE interface on some m68k
924 Macintosh models. It supports both the `Quadra style' (used in 930 Macintosh models. It supports both the `Quadra style' (used in
@@ -932,6 +938,7 @@ config BLK_DEV_MAC_IDE
932config BLK_DEV_Q40IDE 938config BLK_DEV_Q40IDE
933 bool "Q40/Q60 IDE interface support" 939 bool "Q40/Q60 IDE interface support"
934 depends on Q40 940 depends on Q40
941 select IDE_GENERIC
935 help 942 help
936 Enable the on-board IDE controller in the Q40/Q60. This should 943 Enable the on-board IDE controller in the Q40/Q60. This should
937 normally be on; disable it only if you are running a custom hard 944 normally be on; disable it only if you are running a custom hard
@@ -940,6 +947,7 @@ config BLK_DEV_Q40IDE
940config BLK_DEV_MPC8xx_IDE 947config BLK_DEV_MPC8xx_IDE
941 bool "MPC8xx IDE support" 948 bool "MPC8xx IDE support"
942 depends on 8xx && IDE=y && BLK_DEV_IDE=y 949 depends on 8xx && IDE=y && BLK_DEV_IDE=y
950 select IDE_GENERIC
943 help 951 help
944 This option provides support for IDE on Motorola MPC8xx Systems. 952 This option provides support for IDE on Motorola MPC8xx Systems.
945 Please see 'Type of MPC8xx IDE interface' for details. 953 Please see 'Type of MPC8xx IDE interface' for details.
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index fbfea46a34f2..04636f7eaae7 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -718,6 +718,8 @@ static void tune_cris_ide(ide_drive_t *drive, u8 pio)
718 } 718 }
719 719
720 cris_ide_set_speed(TYPE_PIO, setup, strobe, hold); 720 cris_ide_set_speed(TYPE_PIO, setup, strobe, hold);
721
722 (void)ide_config_drive_speed(drive, XFER_PIO_0 + pio);
721} 723}
722 724
723static int speed_cris_ide(ide_drive_t *drive, u8 speed) 725static int speed_cris_ide(ide_drive_t *drive, u8 speed)
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 5ce4216f72a2..eba1adbc1b6a 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -481,6 +481,15 @@ static inline int idedisk_supports_lba48(const struct hd_driveid *id)
481 && id->lba_capacity_2; 481 && id->lba_capacity_2;
482} 482}
483 483
484/*
485 * Some disks report total number of sectors instead of
486 * maximum sector address. We list them here.
487 */
488static const struct drive_list_entry hpa_list[] = {
489 { "ST340823A", NULL },
490 { NULL, NULL }
491};
492
484static void idedisk_check_hpa(ide_drive_t *drive) 493static void idedisk_check_hpa(ide_drive_t *drive)
485{ 494{
486 unsigned long long capacity, set_max; 495 unsigned long long capacity, set_max;
@@ -492,6 +501,15 @@ static void idedisk_check_hpa(ide_drive_t *drive)
492 else 501 else
493 set_max = idedisk_read_native_max_address(drive); 502 set_max = idedisk_read_native_max_address(drive);
494 503
504 if (ide_in_drive_list(drive->id, hpa_list)) {
505 /*
506 * Since we are inclusive wrt to firmware revisions do this
507 * extra check and apply the workaround only when needed.
508 */
509 if (set_max == capacity + 1)
510 set_max--;
511 }
512
495 if (set_max <= capacity) 513 if (set_max <= capacity)
496 return; 514 return;
497 515
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 5fe1d72ab451..ff644a5e12cd 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -135,25 +135,6 @@ static const struct drive_list_entry drive_blacklist [] = {
135}; 135};
136 136
137/** 137/**
138 * ide_in_drive_list - look for drive in black/white list
139 * @id: drive identifier
140 * @drive_table: list to inspect
141 *
142 * Look for a drive in the blacklist and the whitelist tables
143 * Returns 1 if the drive is found in the table.
144 */
145
146int ide_in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table)
147{
148 for ( ; drive_table->id_model ; drive_table++)
149 if ((!strcmp(drive_table->id_model, id->model)) &&
150 (!drive_table->id_firmware ||
151 strstr(id->fw_rev, drive_table->id_firmware)))
152 return 1;
153 return 0;
154}
155
156/**
157 * ide_dma_intr - IDE DMA interrupt handler 138 * ide_dma_intr - IDE DMA interrupt handler
158 * @drive: the drive the interrupt is for 139 * @drive: the drive the interrupt is for
159 * 140 *
@@ -349,9 +330,17 @@ EXPORT_SYMBOL_GPL(ide_destroy_dmatable);
349 330
350static int config_drive_for_dma (ide_drive_t *drive) 331static int config_drive_for_dma (ide_drive_t *drive)
351{ 332{
333 ide_hwif_t *hwif = drive->hwif;
352 struct hd_driveid *id = drive->id; 334 struct hd_driveid *id = drive->id;
353 335
354 if ((id->capability & 1) && drive->hwif->autodma) { 336 /* consult the list of known "bad" drives */
337 if (__ide_dma_bad_drive(drive))
338 return -1;
339
340 if (drive->media != ide_disk && hwif->atapi_dma == 0)
341 return -1;
342
343 if ((id->capability & 1) && drive->autodma) {
355 /* 344 /*
356 * Enable DMA on any drive that has 345 * Enable DMA on any drive that has
357 * UltraDMA (mode 0/1/2/3/4/5/6) enabled 346 * UltraDMA (mode 0/1/2/3/4/5/6) enabled
@@ -514,20 +503,6 @@ int __ide_dma_on (ide_drive_t *drive)
514EXPORT_SYMBOL(__ide_dma_on); 503EXPORT_SYMBOL(__ide_dma_on);
515 504
516/** 505/**
517 * __ide_dma_check - check DMA setup
518 * @drive: drive to check
519 *
520 * Don't use - due for extermination
521 */
522
523int __ide_dma_check (ide_drive_t *drive)
524{
525 return config_drive_for_dma(drive);
526}
527
528EXPORT_SYMBOL(__ide_dma_check);
529
530/**
531 * ide_dma_setup - begin a DMA phase 506 * ide_dma_setup - begin a DMA phase
532 * @drive: target device 507 * @drive: target device
533 * 508 *
@@ -1021,7 +996,7 @@ void ide_setup_dma (ide_hwif_t *hwif, unsigned long dma_base, unsigned int num_p
1021 if (!hwif->dma_host_on) 996 if (!hwif->dma_host_on)
1022 hwif->dma_host_on = &ide_dma_host_on; 997 hwif->dma_host_on = &ide_dma_host_on;
1023 if (!hwif->ide_dma_check) 998 if (!hwif->ide_dma_check)
1024 hwif->ide_dma_check = &__ide_dma_check; 999 hwif->ide_dma_check = &config_drive_for_dma;
1025 if (!hwif->dma_setup) 1000 if (!hwif->dma_setup)
1026 hwif->dma_setup = &ide_dma_setup; 1001 hwif->dma_setup = &ide_dma_setup;
1027 if (!hwif->dma_exec_cmd) 1002 if (!hwif->dma_exec_cmd)
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 92578b6832e9..f4cd2700cae5 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -565,6 +565,36 @@ int ide_wait_stat (ide_startstop_t *startstop, ide_drive_t *drive, u8 good, u8 b
565 565
566EXPORT_SYMBOL(ide_wait_stat); 566EXPORT_SYMBOL(ide_wait_stat);
567 567
568/**
569 * ide_in_drive_list - look for drive in black/white list
570 * @id: drive identifier
571 * @drive_table: list to inspect
572 *
573 * Look for a drive in the blacklist and the whitelist tables
574 * Returns 1 if the drive is found in the table.
575 */
576
577int ide_in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table)
578{
579 for ( ; drive_table->id_model; drive_table++)
580 if ((!strcmp(drive_table->id_model, id->model)) &&
581 (!drive_table->id_firmware ||
582 strstr(id->fw_rev, drive_table->id_firmware)))
583 return 1;
584 return 0;
585}
586
587EXPORT_SYMBOL_GPL(ide_in_drive_list);
588
589/*
590 * Early UDMA66 devices don't set bit14 to 1, only bit13 is valid.
591 * We list them here and depend on the device side cable detection for them.
592 */
593static const struct drive_list_entry ivb_list[] = {
594 { "QUANTUM FIREBALLlct10 05" , "A03.0900" },
595 { NULL , NULL }
596};
597
568/* 598/*
569 * All hosts that use the 80c ribbon must use! 599 * All hosts that use the 80c ribbon must use!
570 * The name is derived from upper byte of word 93 and the 80c ribbon. 600 * The name is derived from upper byte of word 93 and the 80c ribbon.
@@ -573,11 +603,16 @@ u8 eighty_ninty_three (ide_drive_t *drive)
573{ 603{
574 ide_hwif_t *hwif = drive->hwif; 604 ide_hwif_t *hwif = drive->hwif;
575 struct hd_driveid *id = drive->id; 605 struct hd_driveid *id = drive->id;
606 int ivb = ide_in_drive_list(id, ivb_list);
576 607
577 if (hwif->cbl == ATA_CBL_PATA40_SHORT) 608 if (hwif->cbl == ATA_CBL_PATA40_SHORT)
578 return 1; 609 return 1;
579 610
580 if (hwif->cbl != ATA_CBL_PATA80) 611 if (ivb)
612 printk(KERN_DEBUG "%s: skipping word 93 validity check\n",
613 drive->name);
614
615 if (hwif->cbl != ATA_CBL_PATA80 && !ivb)
581 goto no_80w; 616 goto no_80w;
582 617
583 /* Check for SATA but only if we are ATA5 or higher */ 618 /* Check for SATA but only if we are ATA5 or higher */
@@ -587,11 +622,11 @@ u8 eighty_ninty_three (ide_drive_t *drive)
587 /* 622 /*
588 * FIXME: 623 * FIXME:
589 * - change master/slave IDENTIFY order 624 * - change master/slave IDENTIFY order
590 * - force bit13 (80c cable present) check 625 * - force bit13 (80c cable present) check also for !ivb devices
591 * (unless the slave device is pre-ATA3) 626 * (unless the slave device is pre-ATA3)
592 */ 627 */
593#ifndef CONFIG_IDEDMA_IVB 628#ifndef CONFIG_IDEDMA_IVB
594 if (id->hw_config & 0x4000) 629 if ((id->hw_config & 0x4000) || (ivb && (id->hw_config & 0x2000)))
595#else 630#else
596 if (id->hw_config & 0x6000) 631 if (id->hw_config & 0x6000)
597#endif 632#endif
@@ -795,7 +830,7 @@ int ide_config_drive_speed (ide_drive_t *drive, u8 speed)
795 hwif->OUTB(drive->ctl | 2, IDE_CONTROL_REG); 830 hwif->OUTB(drive->ctl | 2, IDE_CONTROL_REG);
796 hwif->OUTB(speed, IDE_NSECTOR_REG); 831 hwif->OUTB(speed, IDE_NSECTOR_REG);
797 hwif->OUTB(SETFEATURES_XFER, IDE_FEATURE_REG); 832 hwif->OUTB(SETFEATURES_XFER, IDE_FEATURE_REG);
798 hwif->OUTB(WIN_SETFEATURES, IDE_COMMAND_REG); 833 hwif->OUTBSYNC(drive, WIN_SETFEATURES, IDE_COMMAND_REG);
799 if ((IDE_CONTROL_REG) && (drive->quirk_list == 2)) 834 if ((IDE_CONTROL_REG) && (drive->quirk_list == 2))
800 hwif->OUTB(drive->ctl, IDE_CONTROL_REG); 835 hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
801 udelay(1); 836 udelay(1);
@@ -822,7 +857,7 @@ int ide_config_drive_speed (ide_drive_t *drive, u8 speed)
822 */ 857 */
823 for (i = 0; i < 10; i++) { 858 for (i = 0; i < 10; i++) {
824 udelay(1); 859 udelay(1);
825 if (OK_STAT((stat = hwif->INB(IDE_STATUS_REG)), DRIVE_READY, BUSY_STAT|DRQ_STAT|ERR_STAT)) { 860 if (OK_STAT((stat = hwif->INB(IDE_STATUS_REG)), drive->ready_stat, BUSY_STAT|DRQ_STAT|ERR_STAT)) {
826 error = 0; 861 error = 0;
827 break; 862 break;
828 } 863 }
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
index acaf71fd4c09..e5949b1d3fb0 100644
--- a/drivers/ide/pci/cs5530.c
+++ b/drivers/ide/pci/cs5530.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/cs5530.c Version 0.73 Mar 10 2007 2 * linux/drivers/ide/pci/cs5530.c Version 0.74 Jul 28 2007
3 * 3 *
4 * Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org>
5 * Copyright (C) 2000 Mark Lord <mlord@pobox.com> 5 * Copyright (C) 2000 Mark Lord <mlord@pobox.com>
@@ -207,6 +207,9 @@ static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const ch
207 struct pci_dev *master_0 = NULL, *cs5530_0 = NULL; 207 struct pci_dev *master_0 = NULL, *cs5530_0 = NULL;
208 unsigned long flags; 208 unsigned long flags;
209 209
210 if (pci_resource_start(dev, 4) == 0)
211 return -EFAULT;
212
210 dev = NULL; 213 dev = NULL;
211 while ((dev = pci_get_device(PCI_VENDOR_ID_CYRIX, PCI_ANY_ID, dev)) != NULL) { 214 while ((dev = pci_get_device(PCI_VENDOR_ID_CYRIX, PCI_ANY_ID, dev)) != NULL) {
212 switch (dev->device) { 215 switch (dev->device) {
@@ -325,6 +328,9 @@ static void __devinit init_hwif_cs5530 (ide_hwif_t *hwif)
325 /* needs autotuning later */ 328 /* needs autotuning later */
326 } 329 }
327 330
331 if (hwif->dma_base == 0)
332 return;
333
328 hwif->atapi_dma = 1; 334 hwif->atapi_dma = 1;
329 hwif->ultra_mask = 0x07; 335 hwif->ultra_mask = 0x07;
330 hwif->mwdma_mask = 0x07; 336 hwif->mwdma_mask = 0x07;
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
index 19778c5fe711..cb8fe5643d3b 100644
--- a/drivers/ide/pci/hpt34x.c
+++ b/drivers/ide/pci/hpt34x.c
@@ -89,11 +89,7 @@ static int hpt34x_config_drive_xfer_rate (ide_drive_t *drive)
89 drive->init_speed = 0; 89 drive->init_speed = 0;
90 90
91 if (ide_tune_dma(drive)) 91 if (ide_tune_dma(drive))
92#ifndef CONFIG_HPT34X_AUTODMA
93 return -1; 92 return -1;
94#else
95 return 0;
96#endif
97 93
98 if (ide_use_fast_pio(drive)) 94 if (ide_use_fast_pio(drive))
99 hpt34x_tune_drive(drive, 255); 95 hpt34x_tune_drive(drive, 255);
@@ -160,9 +156,11 @@ static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif)
160 if (!hwif->dma_base) 156 if (!hwif->dma_base)
161 return; 157 return;
162 158
159#ifdef CONFIG_HPT34X_AUTODMA
163 hwif->ultra_mask = 0x07; 160 hwif->ultra_mask = 0x07;
164 hwif->mwdma_mask = 0x07; 161 hwif->mwdma_mask = 0x07;
165 hwif->swdma_mask = 0x07; 162 hwif->swdma_mask = 0x07;
163#endif
166 164
167 hwif->ide_dma_check = &hpt34x_config_drive_xfer_rate; 165 hwif->ide_dma_check = &hpt34x_config_drive_xfer_rate;
168 if (!noautodma) 166 if (!noautodma)
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
index 09941f37d635..465c935fdf25 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -187,14 +187,6 @@ static int ns87415_ide_dma_setup(ide_drive_t *drive)
187 return 1; 187 return 1;
188} 188}
189 189
190static int ns87415_ide_dma_check (ide_drive_t *drive)
191{
192 if (drive->media != ide_disk)
193 return -1;
194
195 return __ide_dma_check(drive);
196}
197
198static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) 190static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
199{ 191{
200 struct pci_dev *dev = hwif->pci_dev; 192 struct pci_dev *dev = hwif->pci_dev;
@@ -266,7 +258,6 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
266 258
267 outb(0x60, hwif->dma_status); 259 outb(0x60, hwif->dma_status);
268 hwif->dma_setup = &ns87415_ide_dma_setup; 260 hwif->dma_setup = &ns87415_ide_dma_setup;
269 hwif->ide_dma_check = &ns87415_ide_dma_check;
270 hwif->ide_dma_end = &ns87415_ide_dma_end; 261 hwif->ide_dma_end = &ns87415_ide_dma_end;
271 262
272 if (!noautodma) 263 if (!noautodma)
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index 8a66a2871b3a..f6db2f37efad 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -378,6 +378,9 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha
378 int f, r; 378 int f, r;
379 u8 pll_ctl0, pll_ctl1; 379 u8 pll_ctl0, pll_ctl1;
380 380
381 if (dma_base == 0)
382 return -EFAULT;
383
381#ifdef CONFIG_PPC_PMAC 384#ifdef CONFIG_PPC_PMAC
382 apple_kiwi_init(dev); 385 apple_kiwi_init(dev);
383#endif 386#endif
@@ -494,15 +497,18 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
494 hwif->speedproc = &pdcnew_tune_chipset; 497 hwif->speedproc = &pdcnew_tune_chipset;
495 hwif->resetproc = &pdcnew_reset; 498 hwif->resetproc = &pdcnew_reset;
496 499
500 hwif->err_stops_fifo = 1;
501
497 hwif->drives[0].autotune = hwif->drives[1].autotune = 1; 502 hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
498 503
504 if (hwif->dma_base == 0)
505 return;
506
499 hwif->atapi_dma = 1; 507 hwif->atapi_dma = 1;
500 508
501 hwif->ultra_mask = hwif->cds->udma_mask; 509 hwif->ultra_mask = hwif->cds->udma_mask;
502 hwif->mwdma_mask = 0x07; 510 hwif->mwdma_mask = 0x07;
503 511
504 hwif->err_stops_fifo = 1;
505
506 hwif->ide_dma_check = &pdcnew_config_drive_xfer_rate; 512 hwif->ide_dma_check = &pdcnew_config_drive_xfer_rate;
507 513
508 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 514 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index fbcb0bb9c956..e19a891171cb 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/pdc202xx_old.c Version 0.50 Mar 3, 2007 2 * linux/drivers/ide/pci/pdc202xx_old.c Version 0.51 Jul 27, 2007
3 * 3 *
4 * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>
5 * Copyright (C) 2006-2007 MontaVista Software, Inc. 5 * Copyright (C) 2006-2007 MontaVista Software, Inc.
@@ -337,15 +337,18 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
337 337
338 hwif->speedproc = &pdc202xx_tune_chipset; 338 hwif->speedproc = &pdc202xx_tune_chipset;
339 339
340 hwif->err_stops_fifo = 1;
341
340 hwif->drives[0].autotune = hwif->drives[1].autotune = 1; 342 hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
341 343
344 if (hwif->dma_base == 0)
345 return;
346
342 hwif->ultra_mask = hwif->cds->udma_mask; 347 hwif->ultra_mask = hwif->cds->udma_mask;
343 hwif->mwdma_mask = 0x07; 348 hwif->mwdma_mask = 0x07;
344 hwif->swdma_mask = 0x07; 349 hwif->swdma_mask = 0x07;
345 hwif->atapi_dma = 1; 350 hwif->atapi_dma = 1;
346 351
347 hwif->err_stops_fifo = 1;
348
349 hwif->ide_dma_check = &pdc202xx_config_drive_xfer_rate; 352 hwif->ide_dma_check = &pdc202xx_config_drive_xfer_rate;
350 hwif->dma_lost_irq = &pdc202xx_dma_lost_irq; 353 hwif->dma_lost_irq = &pdc202xx_dma_lost_irq;
351 hwif->dma_timeout = &pdc202xx_dma_timeout; 354 hwif->dma_timeout = &pdc202xx_dma_timeout;
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
index 024bbfae0429..098692a6d615 100644
--- a/drivers/ide/pci/triflex.c
+++ b/drivers/ide/pci/triflex.c
@@ -115,6 +115,9 @@ static void __devinit init_hwif_triflex(ide_hwif_t *hwif)
115 hwif->tuneproc = &triflex_tune_drive; 115 hwif->tuneproc = &triflex_tune_drive;
116 hwif->speedproc = &triflex_tune_chipset; 116 hwif->speedproc = &triflex_tune_chipset;
117 117
118 if (hwif->dma_base == 0)
119 return;
120
118 hwif->atapi_dma = 1; 121 hwif->atapi_dma = 1;
119 hwif->mwdma_mask = 0x07; 122 hwif->mwdma_mask = 0x07;
120 hwif->swdma_mask = 0x07; 123 hwif->swdma_mask = 0x07;
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 33630ad3e794..4b13cd9a027d 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -604,6 +604,9 @@ out:
604 drive->id->dma_1word |= 0x0101; break; 604 drive->id->dma_1word |= 0x0101; break;
605 default: break; 605 default: break;
606 } 606 }
607 if (!drive->init_speed)
608 drive->init_speed = command;
609 drive->current_speed = command;
607 } 610 }
608 enable_irq(hwif->irq); 611 enable_irq(hwif->irq);
609 return result; 612 return result;
@@ -986,7 +989,6 @@ pmac_ide_tune_chipset (ide_drive_t *drive, byte speed)
986 return ret; 989 return ret;
987 990
988 pmac_ide_do_update_timings(drive); 991 pmac_ide_do_update_timings(drive);
989 drive->current_speed = speed;
990 992
991 return 0; 993 return 0;
992} 994}
@@ -1737,11 +1739,6 @@ pmac_ide_mdma_enable(ide_drive_t *drive, u16 mode)
1737 /* Apply timings to controller */ 1739 /* Apply timings to controller */
1738 *timings = timing_local[0]; 1740 *timings = timing_local[0];
1739 *timings2 = timing_local[1]; 1741 *timings2 = timing_local[1];
1740
1741 /* Set speed info in drive */
1742 drive->current_speed = mode;
1743 if (!drive->init_speed)
1744 drive->init_speed = mode;
1745 1742
1746 return 1; 1743 return 1;
1747} 1744}
@@ -1793,11 +1790,6 @@ pmac_ide_udma_enable(ide_drive_t *drive, u16 mode)
1793 *timings = timing_local[0]; 1790 *timings = timing_local[0];
1794 *timings2 = timing_local[1]; 1791 *timings2 = timing_local[1];
1795 1792
1796 /* Set speed info in drive */
1797 drive->current_speed = mode;
1798 if (!drive->init_speed)
1799 drive->init_speed = mode;
1800
1801 return 1; 1793 return 1;
1802} 1794}
1803 1795
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 47dbe8f17e82..a81ba8fca0db 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -513,9 +513,9 @@ static int sbp2util_create_command_orb_pool(struct sbp2_lu *lu)
513 return 0; 513 return 0;
514} 514}
515 515
516static void sbp2util_remove_command_orb_pool(struct sbp2_lu *lu) 516static void sbp2util_remove_command_orb_pool(struct sbp2_lu *lu,
517 struct hpsb_host *host)
517{ 518{
518 struct hpsb_host *host = lu->hi->host;
519 struct list_head *lh, *next; 519 struct list_head *lh, *next;
520 struct sbp2_command_info *cmd; 520 struct sbp2_command_info *cmd;
521 unsigned long flags; 521 unsigned long flags;
@@ -922,15 +922,16 @@ static void sbp2_remove_device(struct sbp2_lu *lu)
922 922
923 if (!lu) 923 if (!lu)
924 return; 924 return;
925
926 hi = lu->hi; 925 hi = lu->hi;
926 if (!hi)
927 goto no_hi;
927 928
928 if (lu->shost) { 929 if (lu->shost) {
929 scsi_remove_host(lu->shost); 930 scsi_remove_host(lu->shost);
930 scsi_host_put(lu->shost); 931 scsi_host_put(lu->shost);
931 } 932 }
932 flush_scheduled_work(); 933 flush_scheduled_work();
933 sbp2util_remove_command_orb_pool(lu); 934 sbp2util_remove_command_orb_pool(lu, hi->host);
934 935
935 list_del(&lu->lu_list); 936 list_del(&lu->lu_list);
936 937
@@ -971,9 +972,8 @@ static void sbp2_remove_device(struct sbp2_lu *lu)
971 972
972 lu->ud->device.driver_data = NULL; 973 lu->ud->device.driver_data = NULL;
973 974
974 if (hi) 975 module_put(hi->host->driver->owner);
975 module_put(hi->host->driver->owner); 976no_hi:
976
977 kfree(lu); 977 kfree(lu);
978} 978}
979 979
diff --git a/drivers/infiniband/core/agent.c b/drivers/infiniband/core/agent.c
index db2633e4aae6..ae7c2880e624 100644
--- a/drivers/infiniband/core/agent.c
+++ b/drivers/infiniband/core/agent.c
@@ -78,15 +78,14 @@ ib_get_agent_port(struct ib_device *device, int port_num)
78 return entry; 78 return entry;
79} 79}
80 80
81int agent_send_response(struct ib_mad *mad, struct ib_grh *grh, 81void agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
82 struct ib_wc *wc, struct ib_device *device, 82 struct ib_wc *wc, struct ib_device *device,
83 int port_num, int qpn) 83 int port_num, int qpn)
84{ 84{
85 struct ib_agent_port_private *port_priv; 85 struct ib_agent_port_private *port_priv;
86 struct ib_mad_agent *agent; 86 struct ib_mad_agent *agent;
87 struct ib_mad_send_buf *send_buf; 87 struct ib_mad_send_buf *send_buf;
88 struct ib_ah *ah; 88 struct ib_ah *ah;
89 int ret;
90 struct ib_mad_send_wr_private *mad_send_wr; 89 struct ib_mad_send_wr_private *mad_send_wr;
91 90
92 if (device->node_type == RDMA_NODE_IB_SWITCH) 91 if (device->node_type == RDMA_NODE_IB_SWITCH)
@@ -96,23 +95,21 @@ int agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
96 95
97 if (!port_priv) { 96 if (!port_priv) {
98 printk(KERN_ERR SPFX "Unable to find port agent\n"); 97 printk(KERN_ERR SPFX "Unable to find port agent\n");
99 return -ENODEV; 98 return;
100 } 99 }
101 100
102 agent = port_priv->agent[qpn]; 101 agent = port_priv->agent[qpn];
103 ah = ib_create_ah_from_wc(agent->qp->pd, wc, grh, port_num); 102 ah = ib_create_ah_from_wc(agent->qp->pd, wc, grh, port_num);
104 if (IS_ERR(ah)) { 103 if (IS_ERR(ah)) {
105 ret = PTR_ERR(ah); 104 printk(KERN_ERR SPFX "ib_create_ah_from_wc error\n");
106 printk(KERN_ERR SPFX "ib_create_ah_from_wc error:%d\n", ret); 105 return;
107 return ret;
108 } 106 }
109 107
110 send_buf = ib_create_send_mad(agent, wc->src_qp, wc->pkey_index, 0, 108 send_buf = ib_create_send_mad(agent, wc->src_qp, wc->pkey_index, 0,
111 IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA, 109 IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
112 GFP_KERNEL); 110 GFP_KERNEL);
113 if (IS_ERR(send_buf)) { 111 if (IS_ERR(send_buf)) {
114 ret = PTR_ERR(send_buf); 112 printk(KERN_ERR SPFX "ib_create_send_mad error\n");
115 printk(KERN_ERR SPFX "ib_create_send_mad error:%d\n", ret);
116 goto err1; 113 goto err1;
117 } 114 }
118 115
@@ -126,16 +123,15 @@ int agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
126 mad_send_wr->send_wr.wr.ud.port_num = port_num; 123 mad_send_wr->send_wr.wr.ud.port_num = port_num;
127 } 124 }
128 125
129 if ((ret = ib_post_send_mad(send_buf, NULL))) { 126 if (ib_post_send_mad(send_buf, NULL)) {
130 printk(KERN_ERR SPFX "ib_post_send_mad error:%d\n", ret); 127 printk(KERN_ERR SPFX "ib_post_send_mad error\n");
131 goto err2; 128 goto err2;
132 } 129 }
133 return 0; 130 return;
134err2: 131err2:
135 ib_free_send_mad(send_buf); 132 ib_free_send_mad(send_buf);
136err1: 133err1:
137 ib_destroy_ah(ah); 134 ib_destroy_ah(ah);
138 return ret;
139} 135}
140 136
141static void agent_send_handler(struct ib_mad_agent *mad_agent, 137static void agent_send_handler(struct ib_mad_agent *mad_agent,
diff --git a/drivers/infiniband/core/agent.h b/drivers/infiniband/core/agent.h
index 86d72fab37b0..fb9ed1489f95 100644
--- a/drivers/infiniband/core/agent.h
+++ b/drivers/infiniband/core/agent.h
@@ -46,8 +46,8 @@ extern int ib_agent_port_open(struct ib_device *device, int port_num);
46 46
47extern int ib_agent_port_close(struct ib_device *device, int port_num); 47extern int ib_agent_port_close(struct ib_device *device, int port_num);
48 48
49extern int agent_send_response(struct ib_mad *mad, struct ib_grh *grh, 49extern void agent_send_response(struct ib_mad *mad, struct ib_grh *grh,
50 struct ib_wc *wc, struct ib_device *device, 50 struct ib_wc *wc, struct ib_device *device,
51 int port_num, int qpn); 51 int port_num, int qpn);
52 52
53#endif /* __AGENT_H_ */ 53#endif /* __AGENT_H_ */
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 3ada17c0f239..2506c43ba041 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -702,7 +702,7 @@ int ib_find_pkey(struct ib_device *device,
702 if (ret) 702 if (ret)
703 return ret; 703 return ret;
704 704
705 if (pkey == tmp_pkey) { 705 if ((pkey & 0x7fff) == (tmp_pkey & 0x7fff)) {
706 *index = i; 706 *index = i;
707 return 0; 707 return 0;
708 } 708 }
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index bc547f1d34ba..6f4287716ab1 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -1842,16 +1842,11 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
1842{ 1842{
1843 struct ib_mad_qp_info *qp_info; 1843 struct ib_mad_qp_info *qp_info;
1844 struct ib_mad_private_header *mad_priv_hdr; 1844 struct ib_mad_private_header *mad_priv_hdr;
1845 struct ib_mad_private *recv, *response; 1845 struct ib_mad_private *recv, *response = NULL;
1846 struct ib_mad_list_head *mad_list; 1846 struct ib_mad_list_head *mad_list;
1847 struct ib_mad_agent_private *mad_agent; 1847 struct ib_mad_agent_private *mad_agent;
1848 int port_num; 1848 int port_num;
1849 1849
1850 response = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL);
1851 if (!response)
1852 printk(KERN_ERR PFX "ib_mad_recv_done_handler no memory "
1853 "for response buffer\n");
1854
1855 mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id; 1850 mad_list = (struct ib_mad_list_head *)(unsigned long)wc->wr_id;
1856 qp_info = mad_list->mad_queue->qp_info; 1851 qp_info = mad_list->mad_queue->qp_info;
1857 dequeue_mad(mad_list); 1852 dequeue_mad(mad_list);
@@ -1879,6 +1874,13 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
1879 if (!validate_mad(&recv->mad.mad, qp_info->qp->qp_num)) 1874 if (!validate_mad(&recv->mad.mad, qp_info->qp->qp_num))
1880 goto out; 1875 goto out;
1881 1876
1877 response = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL);
1878 if (!response) {
1879 printk(KERN_ERR PFX "ib_mad_recv_done_handler no memory "
1880 "for response buffer\n");
1881 goto out;
1882 }
1883
1882 if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH) 1884 if (port_priv->device->node_type == RDMA_NODE_IB_SWITCH)
1883 port_num = wc->port_num; 1885 port_num = wc->port_num;
1884 else 1886 else
@@ -1914,12 +1916,11 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
1914 response->header.recv_wc.recv_buf.mad = &response->mad.mad; 1916 response->header.recv_wc.recv_buf.mad = &response->mad.mad;
1915 response->header.recv_wc.recv_buf.grh = &response->grh; 1917 response->header.recv_wc.recv_buf.grh = &response->grh;
1916 1918
1917 if (!agent_send_response(&response->mad.mad, 1919 agent_send_response(&response->mad.mad,
1918 &response->grh, wc, 1920 &response->grh, wc,
1919 port_priv->device, 1921 port_priv->device,
1920 smi_get_fwd_port(&recv->mad.smp), 1922 smi_get_fwd_port(&recv->mad.smp),
1921 qp_info->qp->qp_num)) 1923 qp_info->qp->qp_num);
1922 response = NULL;
1923 1924
1924 goto out; 1925 goto out;
1925 } 1926 }
diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c
index 3663fd7022be..d43bc62005b3 100644
--- a/drivers/infiniband/core/mad_rmpp.c
+++ b/drivers/infiniband/core/mad_rmpp.c
@@ -163,8 +163,10 @@ static struct ib_mad_send_buf *alloc_response_msg(struct ib_mad_agent *agent,
163 hdr_len, 0, GFP_KERNEL); 163 hdr_len, 0, GFP_KERNEL);
164 if (IS_ERR(msg)) 164 if (IS_ERR(msg))
165 ib_destroy_ah(ah); 165 ib_destroy_ah(ah);
166 else 166 else {
167 msg->ah = ah; 167 msg->ah = ah;
168 msg->context[0] = ah;
169 }
168 170
169 return msg; 171 return msg;
170} 172}
@@ -197,9 +199,7 @@ static void ack_ds_ack(struct ib_mad_agent_private *agent,
197 199
198void ib_rmpp_send_handler(struct ib_mad_send_wc *mad_send_wc) 200void ib_rmpp_send_handler(struct ib_mad_send_wc *mad_send_wc)
199{ 201{
200 struct ib_rmpp_mad *rmpp_mad = mad_send_wc->send_buf->mad; 202 if (mad_send_wc->send_buf->context[0] == mad_send_wc->send_buf->ah)
201
202 if (rmpp_mad->rmpp_hdr.rmpp_type != IB_MGMT_RMPP_TYPE_ACK)
203 ib_destroy_ah(mad_send_wc->send_buf->ah); 203 ib_destroy_ah(mad_send_wc->send_buf->ah);
204 ib_free_send_mad(mad_send_wc->send_buf); 204 ib_free_send_mad(mad_send_wc->send_buf);
205} 205}
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 20ab6b3e484d..d271bd715c12 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -385,9 +385,7 @@ static void update_sm_ah(struct work_struct *work)
385 385
386 new_ah->pkey_index = 0; 386 new_ah->pkey_index = 0;
387 if (ib_find_pkey(port->agent->device, port->port_num, 387 if (ib_find_pkey(port->agent->device, port->port_num,
388 IB_DEFAULT_PKEY_FULL, &new_ah->pkey_index) && 388 IB_DEFAULT_PKEY_FULL, &new_ah->pkey_index))
389 ib_find_pkey(port->agent->device, port->port_num,
390 IB_DEFAULT_PKEY_PARTIAL, &new_ah->pkey_index))
391 printk(KERN_ERR "Couldn't find index for default PKey\n"); 389 printk(KERN_ERR "Couldn't find index for default PKey\n");
392 390
393 memset(&ah_attr, 0, sizeof ah_attr); 391 memset(&ah_attr, 0, sizeof ah_attr);
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 26d0470eef6e..664d2faa9e74 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -40,6 +40,11 @@
40 40
41#include "uverbs.h" 41#include "uverbs.h"
42 42
43#define IB_UMEM_MAX_PAGE_CHUNK \
44 ((PAGE_SIZE - offsetof(struct ib_umem_chunk, page_list)) / \
45 ((void *) &((struct ib_umem_chunk *) 0)->page_list[1] - \
46 (void *) &((struct ib_umem_chunk *) 0)->page_list[0]))
47
43static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int dirty) 48static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int dirty)
44{ 49{
45 struct ib_umem_chunk *chunk, *tmp; 50 struct ib_umem_chunk *chunk, *tmp;
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index 9574088f0d4e..1cdfcd43b0bc 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -139,7 +139,7 @@ static void release_tid(struct t3cdev *tdev, u32 hwtid, struct sk_buff *skb)
139 req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); 139 req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD));
140 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_TID_RELEASE, hwtid)); 140 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_TID_RELEASE, hwtid));
141 skb->priority = CPL_PRIORITY_SETUP; 141 skb->priority = CPL_PRIORITY_SETUP;
142 tdev->send(tdev, skb); 142 cxgb3_ofld_send(tdev, skb);
143 return; 143 return;
144} 144}
145 145
@@ -161,7 +161,7 @@ int iwch_quiesce_tid(struct iwch_ep *ep)
161 req->val = cpu_to_be64(1 << S_TCB_RX_QUIESCE); 161 req->val = cpu_to_be64(1 << S_TCB_RX_QUIESCE);
162 162
163 skb->priority = CPL_PRIORITY_DATA; 163 skb->priority = CPL_PRIORITY_DATA;
164 ep->com.tdev->send(ep->com.tdev, skb); 164 cxgb3_ofld_send(ep->com.tdev, skb);
165 return 0; 165 return 0;
166} 166}
167 167
@@ -183,7 +183,7 @@ int iwch_resume_tid(struct iwch_ep *ep)
183 req->val = 0; 183 req->val = 0;
184 184
185 skb->priority = CPL_PRIORITY_DATA; 185 skb->priority = CPL_PRIORITY_DATA;
186 ep->com.tdev->send(ep->com.tdev, skb); 186 cxgb3_ofld_send(ep->com.tdev, skb);
187 return 0; 187 return 0;
188} 188}
189 189
@@ -784,7 +784,7 @@ static int update_rx_credits(struct iwch_ep *ep, u32 credits)
784 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_RX_DATA_ACK, ep->hwtid)); 784 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_RX_DATA_ACK, ep->hwtid));
785 req->credit_dack = htonl(V_RX_CREDITS(credits) | V_RX_FORCE_ACK(1)); 785 req->credit_dack = htonl(V_RX_CREDITS(credits) | V_RX_FORCE_ACK(1));
786 skb->priority = CPL_PRIORITY_ACK; 786 skb->priority = CPL_PRIORITY_ACK;
787 ep->com.tdev->send(ep->com.tdev, skb); 787 cxgb3_ofld_send(ep->com.tdev, skb);
788 return credits; 788 return credits;
789} 789}
790 790
@@ -1152,7 +1152,7 @@ static int listen_start(struct iwch_listen_ep *ep)
1152 req->opt1 = htonl(V_CONN_POLICY(CPL_CONN_POLICY_ASK)); 1152 req->opt1 = htonl(V_CONN_POLICY(CPL_CONN_POLICY_ASK));
1153 1153
1154 skb->priority = 1; 1154 skb->priority = 1;
1155 ep->com.tdev->send(ep->com.tdev, skb); 1155 cxgb3_ofld_send(ep->com.tdev, skb);
1156 return 0; 1156 return 0;
1157} 1157}
1158 1158
@@ -1186,7 +1186,7 @@ static int listen_stop(struct iwch_listen_ep *ep)
1186 req->cpu_idx = 0; 1186 req->cpu_idx = 0;
1187 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_CLOSE_LISTSRV_REQ, ep->stid)); 1187 OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_CLOSE_LISTSRV_REQ, ep->stid));
1188 skb->priority = 1; 1188 skb->priority = 1;
1189 ep->com.tdev->send(ep->com.tdev, skb); 1189 cxgb3_ofld_send(ep->com.tdev, skb);
1190 return 0; 1190 return 0;
1191} 1191}
1192 1192
@@ -1264,7 +1264,7 @@ static void reject_cr(struct t3cdev *tdev, u32 hwtid, __be32 peer_ip,
1264 rpl->opt0l_status = htonl(CPL_PASS_OPEN_REJECT); 1264 rpl->opt0l_status = htonl(CPL_PASS_OPEN_REJECT);
1265 rpl->opt2 = 0; 1265 rpl->opt2 = 0;
1266 rpl->rsvd = rpl->opt2; 1266 rpl->rsvd = rpl->opt2;
1267 tdev->send(tdev, skb); 1267 cxgb3_ofld_send(tdev, skb);
1268 } 1268 }
1269} 1269}
1270 1270
@@ -1557,7 +1557,7 @@ static int peer_abort(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
1557 rpl->wr.wr_lo = htonl(V_WR_TID(ep->hwtid)); 1557 rpl->wr.wr_lo = htonl(V_WR_TID(ep->hwtid));
1558 OPCODE_TID(rpl) = htonl(MK_OPCODE_TID(CPL_ABORT_RPL, ep->hwtid)); 1558 OPCODE_TID(rpl) = htonl(MK_OPCODE_TID(CPL_ABORT_RPL, ep->hwtid));
1559 rpl->cmd = CPL_ABORT_NO_RST; 1559 rpl->cmd = CPL_ABORT_NO_RST;
1560 ep->com.tdev->send(ep->com.tdev, rpl_skb); 1560 cxgb3_ofld_send(ep->com.tdev, rpl_skb);
1561 if (state != ABORTING) { 1561 if (state != ABORTING) {
1562 state_set(&ep->com, DEAD); 1562 state_set(&ep->com, DEAD);
1563 release_ep_resources(ep); 1563 release_ep_resources(ep);
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 660b27aecae5..8bf44daf45ec 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -389,7 +389,7 @@ static int mlx4_ib_poll_one(struct mlx4_ib_cq *cq,
389 wc->opcode = IB_WC_SEND; 389 wc->opcode = IB_WC_SEND;
390 break; 390 break;
391 case MLX4_OPCODE_RDMA_READ: 391 case MLX4_OPCODE_RDMA_READ:
392 wc->opcode = IB_WC_SEND; 392 wc->opcode = IB_WC_RDMA_READ;
393 wc->byte_len = be32_to_cpu(cqe->byte_cnt); 393 wc->byte_len = be32_to_cpu(cqe->byte_cnt);
394 break; 394 break;
395 case MLX4_OPCODE_ATOMIC_CS: 395 case MLX4_OPCODE_ATOMIC_CS:
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 333091787c5f..0ed02b7834da 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -109,7 +109,7 @@ int mlx4_MAD_IFC(struct mlx4_ib_dev *dev, int ignore_mkey, int ignore_bkey,
109 in_modifier, op_modifier, 109 in_modifier, op_modifier,
110 MLX4_CMD_MAD_IFC, MLX4_CMD_TIME_CLASS_C); 110 MLX4_CMD_MAD_IFC, MLX4_CMD_TIME_CLASS_C);
111 111
112 if (!err); 112 if (!err)
113 memcpy(response_mad, outmailbox->buf, 256); 113 memcpy(response_mad, outmailbox->buf, 256);
114 114
115 mlx4_free_cmd_mailbox(dev->dev, inmailbox); 115 mlx4_free_cmd_mailbox(dev->dev, inmailbox);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
index 982eb88e27ec..563aeacf9e14 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
@@ -211,6 +211,7 @@ out_free_cq:
211 211
212out_free_mr: 212out_free_mr:
213 ib_dereg_mr(priv->mr); 213 ib_dereg_mr(priv->mr);
214 ipoib_cm_dev_cleanup(dev);
214 215
215out_free_pd: 216out_free_pd:
216 ib_dealloc_pd(priv->pd); 217 ib_dealloc_pd(priv->pd);
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index f01ca182f226..f6a051428144 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -75,16 +75,12 @@ module_param(topspin_workarounds, int, 0444);
75MODULE_PARM_DESC(topspin_workarounds, 75MODULE_PARM_DESC(topspin_workarounds,
76 "Enable workarounds for Topspin/Cisco SRP target bugs if != 0"); 76 "Enable workarounds for Topspin/Cisco SRP target bugs if != 0");
77 77
78static const u8 topspin_oui[3] = { 0x00, 0x05, 0xad };
79
80static int mellanox_workarounds = 1; 78static int mellanox_workarounds = 1;
81 79
82module_param(mellanox_workarounds, int, 0444); 80module_param(mellanox_workarounds, int, 0444);
83MODULE_PARM_DESC(mellanox_workarounds, 81MODULE_PARM_DESC(mellanox_workarounds,
84 "Enable workarounds for Mellanox SRP target bugs if != 0"); 82 "Enable workarounds for Mellanox SRP target bugs if != 0");
85 83
86static const u8 mellanox_oui[3] = { 0x00, 0x02, 0xc9 };
87
88static void srp_add_one(struct ib_device *device); 84static void srp_add_one(struct ib_device *device);
89static void srp_remove_one(struct ib_device *device); 85static void srp_remove_one(struct ib_device *device);
90static void srp_completion(struct ib_cq *cq, void *target_ptr); 86static void srp_completion(struct ib_cq *cq, void *target_ptr);
@@ -108,6 +104,24 @@ static const char *srp_target_info(struct Scsi_Host *host)
108 return host_to_target(host)->target_name; 104 return host_to_target(host)->target_name;
109} 105}
110 106
107static int srp_target_is_topspin(struct srp_target_port *target)
108{
109 static const u8 topspin_oui[3] = { 0x00, 0x05, 0xad };
110 static const u8 cisco_oui[3] = { 0x00, 0x1b, 0x0d };
111
112 return topspin_workarounds &&
113 (!memcmp(&target->ioc_guid, topspin_oui, sizeof topspin_oui) ||
114 !memcmp(&target->ioc_guid, cisco_oui, sizeof cisco_oui));
115}
116
117static int srp_target_is_mellanox(struct srp_target_port *target)
118{
119 static const u8 mellanox_oui[3] = { 0x00, 0x02, 0xc9 };
120
121 return mellanox_workarounds &&
122 !memcmp(&target->ioc_guid, mellanox_oui, sizeof mellanox_oui);
123}
124
111static struct srp_iu *srp_alloc_iu(struct srp_host *host, size_t size, 125static struct srp_iu *srp_alloc_iu(struct srp_host *host, size_t size,
112 gfp_t gfp_mask, 126 gfp_t gfp_mask,
113 enum dma_data_direction direction) 127 enum dma_data_direction direction)
@@ -360,7 +374,7 @@ static int srp_send_req(struct srp_target_port *target)
360 * zero out the first 8 bytes of our initiator port ID and set 374 * zero out the first 8 bytes of our initiator port ID and set
361 * the second 8 bytes to the local node GUID. 375 * the second 8 bytes to the local node GUID.
362 */ 376 */
363 if (topspin_workarounds && !memcmp(&target->ioc_guid, topspin_oui, 3)) { 377 if (srp_target_is_topspin(target)) {
364 printk(KERN_DEBUG PFX "Topspin/Cisco initiator port ID workaround " 378 printk(KERN_DEBUG PFX "Topspin/Cisco initiator port ID workaround "
365 "activated for target GUID %016llx\n", 379 "activated for target GUID %016llx\n",
366 (unsigned long long) be64_to_cpu(target->ioc_guid)); 380 (unsigned long long) be64_to_cpu(target->ioc_guid));
@@ -585,8 +599,8 @@ static int srp_map_fmr(struct srp_target_port *target, struct scatterlist *scat,
585 if (!dev->fmr_pool) 599 if (!dev->fmr_pool)
586 return -ENODEV; 600 return -ENODEV;
587 601
588 if ((ib_sg_dma_address(ibdev, &scat[0]) & ~dev->fmr_page_mask) && 602 if (srp_target_is_mellanox(target) &&
589 mellanox_workarounds && !memcmp(&target->ioc_guid, mellanox_oui, 3)) 603 (ib_sg_dma_address(ibdev, &scat[0]) & ~dev->fmr_page_mask))
590 return -EINVAL; 604 return -EINVAL;
591 605
592 len = page_cnt = 0; 606 len = page_cnt = 0;
@@ -1087,8 +1101,7 @@ static void srp_cm_rej_handler(struct ib_cm_id *cm_id,
1087 break; 1101 break;
1088 1102
1089 case IB_CM_REJ_PORT_REDIRECT: 1103 case IB_CM_REJ_PORT_REDIRECT:
1090 if (topspin_workarounds && 1104 if (srp_target_is_topspin(target)) {
1091 !memcmp(&target->ioc_guid, topspin_oui, 3)) {
1092 /* 1105 /*
1093 * Topspin/Cisco SRP gateways incorrectly send 1106 * Topspin/Cisco SRP gateways incorrectly send
1094 * reject reason code 25 when they mean 24 1107 * reject reason code 25 when they mean 24
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 9b26574f1466..d602b8fa7d46 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -68,6 +68,7 @@ config INPUT_WISTRON_BTNS
68 select INPUT_POLLDEV 68 select INPUT_POLLDEV
69 select NEW_LEDS 69 select NEW_LEDS
70 select LEDS_CLASS 70 select LEDS_CLASS
71 select CHECK_SIGNATURE
71 help 72 help
72 Say Y here for support of Winstron laptop button interface, used on 73 Say Y here for support of Winstron laptop button interface, used on
73 laptops of various brands, including Acer and Fujitsu-Siemens. If 74 laptops of various brands, including Acer and Fujitsu-Siemens. If
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c
index b1a26e02df02..60843b3f3b6f 100644
--- a/drivers/isdn/hisax/hfc_usb.c
+++ b/drivers/isdn/hisax/hfc_usb.c
@@ -1,12 +1,12 @@
1/* 1/*
2 * hfc_usb.c 2 * hfc_usb.c
3 * 3 *
4 * $Id: hfc_usb.c,v 2.3.2.13 2006/02/17 17:17:22 mbachem Exp $ 4 * $Id: hfc_usb.c,v 2.3.2.20 2007/08/20 14:07:54 mbachem Exp $
5 * 5 *
6 * modular HiSax ISDN driver for Colognechip HFC-S USB chip 6 * modular HiSax ISDN driver for Colognechip HFC-S USB chip
7 * 7 *
8 * Authors : Peter Sprenger (sprenger@moving-bytes.de) 8 * Authors : Peter Sprenger (sprenger@moving-bytes.de)
9 * Martin Bachem (info@colognechip.com) 9 * Martin Bachem (m.bachem@gmx.de, info@colognechip.com)
10 * 10 *
11 * based on the first hfc_usb driver of 11 * based on the first hfc_usb driver of
12 * Werner Cornelius (werner@isdn-development.de) 12 * Werner Cornelius (werner@isdn-development.de)
@@ -37,24 +37,25 @@
37#include <linux/kernel_stat.h> 37#include <linux/kernel_stat.h>
38#include <linux/usb.h> 38#include <linux/usb.h>
39#include <linux/kernel.h> 39#include <linux/kernel.h>
40#include <linux/smp_lock.h>
41#include <linux/sched.h>
42#include <linux/moduleparam.h>
40#include "hisax.h" 43#include "hisax.h"
41#include "hisax_if.h" 44#include "hisax_if.h"
42#include "hfc_usb.h" 45#include "hfc_usb.h"
43 46
44static const char *hfcusb_revision = 47static const char *hfcusb_revision =
45 "$Revision: 2.3.2.13 $ $Date: 2006/02/17 17:17:22 $ "; 48 "$Revision: 2.3.2.20 $ $Date: 2007/08/20 14:07:54 $ ";
46 49
47/* Hisax debug support 50/* Hisax debug support
48* use "modprobe debug=x" where x is bitfield of USB_DBG & ISDN_DBG 51* debug flags defined in hfc_usb.h as HFCUSB_DBG_[*]
49*/ 52*/
50#ifdef CONFIG_HISAX_DEBUG
51#include <linux/moduleparam.h>
52#define __debug_variable hfc_debug 53#define __debug_variable hfc_debug
53#include "hisax_debug.h" 54#include "hisax_debug.h"
54static u_int debug; 55static u_int debug;
55module_param(debug, uint, 0); 56module_param(debug, uint, 0);
56static int hfc_debug; 57static int hfc_debug;
57#endif 58
58 59
59/* private vendor specific data */ 60/* private vendor specific data */
60typedef struct { 61typedef struct {
@@ -63,9 +64,7 @@ typedef struct {
63 char *vend_name; // device name 64 char *vend_name; // device name
64} hfcsusb_vdata; 65} hfcsusb_vdata;
65 66
66/****************************************/ 67/* VID/PID device list */
67/* data defining the devices to be used */
68/****************************************/
69static struct usb_device_id hfcusb_idtab[] = { 68static struct usb_device_id hfcusb_idtab[] = {
70 { 69 {
71 USB_DEVICE(0x0959, 0x2bd0), 70 USB_DEVICE(0x0959, 0x2bd0),
@@ -90,49 +89,47 @@ static struct usb_device_id hfcusb_idtab[] = {
90 .driver_info = (unsigned long) &((hfcsusb_vdata) 89 .driver_info = (unsigned long) &((hfcsusb_vdata)
91 {LED_SCHEME1, {4, 0, 2, 1}, 90 {LED_SCHEME1, {4, 0, 2, 1},
92 "Stollmann USB TA"}), 91 "Stollmann USB TA"}),
93 }, 92 },
94 { 93 {
95 USB_DEVICE(0x0742, 0x2009), 94 USB_DEVICE(0x0742, 0x2009),
96 .driver_info = (unsigned long) &((hfcsusb_vdata) 95 .driver_info = (unsigned long) &((hfcsusb_vdata)
97 {LED_SCHEME1, {4, 0, 2, 1}, 96 {LED_SCHEME1, {4, 0, 2, 1},
98 "Aceex USB ISDN TA"}), 97 "Aceex USB ISDN TA"}),
99 }, 98 },
100 { 99 {
101 USB_DEVICE(0x0742, 0x200A), 100 USB_DEVICE(0x0742, 0x200A),
102 .driver_info = (unsigned long) &((hfcsusb_vdata) 101 .driver_info = (unsigned long) &((hfcsusb_vdata)
103 {LED_SCHEME1, {4, 0, 2, 1}, 102 {LED_SCHEME1, {4, 0, 2, 1},
104 "OEM USB ISDN TA"}), 103 "OEM USB ISDN TA"}),
105 }, 104 },
106 { 105 {
107 USB_DEVICE(0x08e3, 0x0301), 106 USB_DEVICE(0x08e3, 0x0301),
108 .driver_info = (unsigned long) &((hfcsusb_vdata) 107 .driver_info = (unsigned long) &((hfcsusb_vdata)
109 {LED_SCHEME1, {2, 0, 1, 4}, 108 {LED_SCHEME1, {2, 0, 1, 4},
110 "Olitec USB RNIS"}), 109 "Olitec USB RNIS"}),
111 }, 110 },
112 { 111 {
113 USB_DEVICE(0x07fa, 0x0846), 112 USB_DEVICE(0x07fa, 0x0846),
114 .driver_info = (unsigned long) &((hfcsusb_vdata) 113 .driver_info = (unsigned long) &((hfcsusb_vdata)
115 {LED_SCHEME1, {0x80, -64, -32, -16}, 114 {LED_SCHEME1, {0x80, -64, -32, -16},
116 "Bewan Modem RNIS USB"}), 115 "Bewan Modem RNIS USB"}),
117 }, 116 },
118 { 117 {
119 USB_DEVICE(0x07fa, 0x0847), 118 USB_DEVICE(0x07fa, 0x0847),
120 .driver_info = (unsigned long) &((hfcsusb_vdata) 119 .driver_info = (unsigned long) &((hfcsusb_vdata)
121 {LED_SCHEME1, {0x80, -64, -32, -16}, 120 {LED_SCHEME1, {0x80, -64, -32, -16},
122 "Djinn Numeris USB"}), 121 "Djinn Numeris USB"}),
123 }, 122 },
124 { 123 {
125 USB_DEVICE(0x07b0, 0x0006), 124 USB_DEVICE(0x07b0, 0x0006),
126 .driver_info = (unsigned long) &((hfcsusb_vdata) 125 .driver_info = (unsigned long) &((hfcsusb_vdata)
127 {LED_SCHEME1, {0x80, -64, -32, -16}, 126 {LED_SCHEME1, {0x80, -64, -32, -16},
128 "Twister ISDN TA"}), 127 "Twister ISDN TA"}),
129 }, 128 },
130 { } 129 { }
131}; 130};
132 131
133/***************************************************************/
134/* structure defining input+output fifos (interrupt/bulk mode) */ 132/* structure defining input+output fifos (interrupt/bulk mode) */
135/***************************************************************/
136struct usb_fifo; /* forward definition */ 133struct usb_fifo; /* forward definition */
137typedef struct iso_urb_struct { 134typedef struct iso_urb_struct {
138 struct urb *purb; 135 struct urb *purb;
@@ -140,8 +137,8 @@ typedef struct iso_urb_struct {
140 struct usb_fifo *owner_fifo; /* pointer to owner fifo */ 137 struct usb_fifo *owner_fifo; /* pointer to owner fifo */
141} iso_urb_struct; 138} iso_urb_struct;
142 139
143
144struct hfcusb_data; /* forward definition */ 140struct hfcusb_data; /* forward definition */
141
145typedef struct usb_fifo { 142typedef struct usb_fifo {
146 int fifonum; /* fifo index attached to this structure */ 143 int fifonum; /* fifo index attached to this structure */
147 int active; /* fifo is currently active */ 144 int active; /* fifo is currently active */
@@ -160,15 +157,12 @@ typedef struct usb_fifo {
160 struct hisax_if *hif; /* hisax interface */ 157 struct hisax_if *hif; /* hisax interface */
161 int delete_flg; /* only delete skbuff once */ 158 int delete_flg; /* only delete skbuff once */
162 int last_urblen; /* remember length of last packet */ 159 int last_urblen; /* remember length of last packet */
163
164} usb_fifo; 160} usb_fifo;
165 161
166/*********************************************/
167/* structure holding all data for one device */ 162/* structure holding all data for one device */
168/*********************************************/
169typedef struct hfcusb_data { 163typedef struct hfcusb_data {
170 /* HiSax Interface for loadable Layer1 drivers */ 164 /* HiSax Interface for loadable Layer1 drivers */
171 struct hisax_d_if d_if; /* see hisax_if.h */ 165 struct hisax_d_if d_if; /* see hisax_if.h */
172 struct hisax_b_if b_if[2]; /* see hisax_if.h */ 166 struct hisax_b_if b_if[2]; /* see hisax_if.h */
173 int protocol; 167 int protocol;
174 168
@@ -176,12 +170,13 @@ typedef struct hfcusb_data {
176 int if_used; /* used interface number */ 170 int if_used; /* used interface number */
177 int alt_used; /* used alternate config */ 171 int alt_used; /* used alternate config */
178 int ctrl_paksize; /* control pipe packet size */ 172 int ctrl_paksize; /* control pipe packet size */
179 int ctrl_in_pipe, ctrl_out_pipe; /* handles for control pipe */ 173 int ctrl_in_pipe, /* handles for control pipe */
174 ctrl_out_pipe;
180 int cfg_used; /* configuration index used */ 175 int cfg_used; /* configuration index used */
181 int vend_idx; /* vendor found */ 176 int vend_idx; /* vendor found */
182 int b_mode[2]; /* B-channel mode */ 177 int b_mode[2]; /* B-channel mode */
183 int l1_activated; /* layer 1 activated */ 178 int l1_activated; /* layer 1 activated */
184 int disc_flag; /* 'true' if device was disonnected to avoid some USB actions */ 179 int disc_flag; /* TRUE if device was disonnected to avoid some USB actions */
185 int packet_size, iso_packet_size; 180 int packet_size, iso_packet_size;
186 181
187 /* control pipe background handling */ 182 /* control pipe background handling */
@@ -208,7 +203,6 @@ typedef struct hfcusb_data {
208static void collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, 203static void collect_rx_frame(usb_fifo * fifo, __u8 * data, int len,
209 int finish); 204 int finish);
210 205
211
212static inline const char * 206static inline const char *
213symbolic(struct hfcusb_symbolic_list list[], const int num) 207symbolic(struct hfcusb_symbolic_list list[], const int num)
214{ 208{
@@ -219,10 +213,6 @@ symbolic(struct hfcusb_symbolic_list list[], const int num)
219 return "<unknown ERROR>"; 213 return "<unknown ERROR>";
220} 214}
221 215
222
223/******************************************************/
224/* start next background transfer for control channel */
225/******************************************************/
226static void 216static void
227ctrl_start_transfer(hfcusb_data * hfc) 217ctrl_start_transfer(hfcusb_data * hfc)
228{ 218{
@@ -240,10 +230,6 @@ ctrl_start_transfer(hfcusb_data * hfc)
240 } 230 }
241} /* ctrl_start_transfer */ 231} /* ctrl_start_transfer */
242 232
243/************************************/
244/* queue a control transfer request */
245/* return 0 on success. */
246/************************************/
247static int 233static int
248queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val, int action) 234queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val, int action)
249{ 235{
@@ -260,19 +246,8 @@ queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val, int action)
260 if (++hfc->ctrl_cnt == 1) 246 if (++hfc->ctrl_cnt == 1)
261 ctrl_start_transfer(hfc); 247 ctrl_start_transfer(hfc);
262 return (0); 248 return (0);
263} /* queue_control_request */
264
265static int
266control_action_handler(hfcusb_data * hfc, int reg, int val, int action)
267{
268 if (!action)
269 return (1); /* no action defined */
270 return (0);
271} 249}
272 250
273/***************************************************************/
274/* control completion routine handling background control cmds */
275/***************************************************************/
276static void 251static void
277ctrl_complete(struct urb *urb) 252ctrl_complete(struct urb *urb)
278{ 253{
@@ -282,9 +257,6 @@ ctrl_complete(struct urb *urb)
282 urb->dev = hfc->dev; 257 urb->dev = hfc->dev;
283 if (hfc->ctrl_cnt) { 258 if (hfc->ctrl_cnt) {
284 buf = &hfc->ctrl_buff[hfc->ctrl_out_idx]; 259 buf = &hfc->ctrl_buff[hfc->ctrl_out_idx];
285 control_action_handler(hfc, buf->hfc_reg, buf->reg_val,
286 buf->action);
287
288 hfc->ctrl_cnt--; /* decrement actual count */ 260 hfc->ctrl_cnt--; /* decrement actual count */
289 if (++hfc->ctrl_out_idx >= HFC_CTRL_BUFSIZE) 261 if (++hfc->ctrl_out_idx >= HFC_CTRL_BUFSIZE)
290 hfc->ctrl_out_idx = 0; /* pointer wrap */ 262 hfc->ctrl_out_idx = 0; /* pointer wrap */
@@ -293,9 +265,7 @@ ctrl_complete(struct urb *urb)
293 } 265 }
294} /* ctrl_complete */ 266} /* ctrl_complete */
295 267
296/***************************************************/
297/* write led data to auxport & invert if necessary */ 268/* write led data to auxport & invert if necessary */
298/***************************************************/
299static void 269static void
300write_led(hfcusb_data * hfc, __u8 led_state) 270write_led(hfcusb_data * hfc, __u8 led_state)
301{ 271{
@@ -305,9 +275,6 @@ write_led(hfcusb_data * hfc, __u8 led_state)
305 } 275 }
306} 276}
307 277
308/**************************/
309/* handle LED bits */
310/**************************/
311static void 278static void
312set_led_bit(hfcusb_data * hfc, signed short led_bits, int unset) 279set_led_bit(hfcusb_data * hfc, signed short led_bits, int unset)
313{ 280{
@@ -324,9 +291,7 @@ set_led_bit(hfcusb_data * hfc, signed short led_bits, int unset)
324 } 291 }
325} 292}
326 293
327/**************************/ 294/* handle LED requests */
328/* handle LED requests */
329/**************************/
330static void 295static void
331handle_led(hfcusb_data * hfc, int event) 296handle_led(hfcusb_data * hfc, int event)
332{ 297{
@@ -339,85 +304,73 @@ handle_led(hfcusb_data * hfc, int event)
339 304
340 switch (event) { 305 switch (event) {
341 case LED_POWER_ON: 306 case LED_POWER_ON:
342 set_led_bit(hfc, driver_info->led_bits[0], 307 set_led_bit(hfc, driver_info->led_bits[0], 0);
343 0); 308 set_led_bit(hfc, driver_info->led_bits[1], 1);
344 set_led_bit(hfc, driver_info->led_bits[1], 309 set_led_bit(hfc, driver_info->led_bits[2], 1);
345 1); 310 set_led_bit(hfc, driver_info->led_bits[3], 1);
346 set_led_bit(hfc, driver_info->led_bits[2],
347 1);
348 set_led_bit(hfc, driver_info->led_bits[3],
349 1);
350 break; 311 break;
351 case LED_POWER_OFF: /* no Power off handling */ 312 case LED_POWER_OFF:
313 set_led_bit(hfc, driver_info->led_bits[0], 1);
314 set_led_bit(hfc, driver_info->led_bits[1], 1);
315 set_led_bit(hfc, driver_info->led_bits[2], 1);
316 set_led_bit(hfc, driver_info->led_bits[3], 1);
352 break; 317 break;
353 case LED_S0_ON: 318 case LED_S0_ON:
354 set_led_bit(hfc, driver_info->led_bits[1], 319 set_led_bit(hfc, driver_info->led_bits[1], 0);
355 0);
356 break; 320 break;
357 case LED_S0_OFF: 321 case LED_S0_OFF:
358 set_led_bit(hfc, driver_info->led_bits[1], 322 set_led_bit(hfc, driver_info->led_bits[1], 1);
359 1);
360 break; 323 break;
361 case LED_B1_ON: 324 case LED_B1_ON:
362 set_led_bit(hfc, driver_info->led_bits[2], 325 set_led_bit(hfc, driver_info->led_bits[2], 0);
363 0);
364 break; 326 break;
365 case LED_B1_OFF: 327 case LED_B1_OFF:
366 set_led_bit(hfc, driver_info->led_bits[2], 328 set_led_bit(hfc, driver_info->led_bits[2], 1);
367 1);
368 break; 329 break;
369 case LED_B2_ON: 330 case LED_B2_ON:
370 set_led_bit(hfc, driver_info->led_bits[3], 331 set_led_bit(hfc, driver_info->led_bits[3], 0);
371 0);
372 break; 332 break;
373 case LED_B2_OFF: 333 case LED_B2_OFF:
374 set_led_bit(hfc, driver_info->led_bits[3], 334 set_led_bit(hfc, driver_info->led_bits[3], 1);
375 1);
376 break; 335 break;
377 } 336 }
378 write_led(hfc, hfc->led_state); 337 write_led(hfc, hfc->led_state);
379} 338}
380 339
381/********************************/ 340/* ISDN l1 timer T3 expires */
382/* called when timer t3 expires */
383/********************************/
384static void 341static void
385l1_timer_expire_t3(hfcusb_data * hfc) 342l1_timer_expire_t3(hfcusb_data * hfc)
386{ 343{
387 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION, 344 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION,
388 NULL); 345 NULL);
389#ifdef CONFIG_HISAX_DEBUG 346
390 DBG(ISDN_DBG, 347 DBG(HFCUSB_DBG_STATES,
391 "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T3 expire)"); 348 "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T3 expire)");
392#endif 349
393 hfc->l1_activated = false; 350 hfc->l1_activated = 0;
394 handle_led(hfc, LED_S0_OFF); 351 handle_led(hfc, LED_S0_OFF);
395 /* deactivate : */ 352 /* deactivate : */
396 queue_control_request(hfc, HFCUSB_STATES, 0x10, 1); 353 queue_control_request(hfc, HFCUSB_STATES, 0x10, 1);
397 queue_control_request(hfc, HFCUSB_STATES, 3, 1); 354 queue_control_request(hfc, HFCUSB_STATES, 3, 1);
398} 355}
399 356
400/********************************/ 357/* ISDN l1 timer T4 expires */
401/* called when timer t4 expires */
402/********************************/
403static void 358static void
404l1_timer_expire_t4(hfcusb_data * hfc) 359l1_timer_expire_t4(hfcusb_data * hfc)
405{ 360{
406 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION, 361 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, PH_DEACTIVATE | INDICATION,
407 NULL); 362 NULL);
408#ifdef CONFIG_HISAX_DEBUG 363
409 DBG(ISDN_DBG, 364 DBG(HFCUSB_DBG_STATES,
410 "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T4 expire)"); 365 "HFC-S USB: PH_DEACTIVATE | INDICATION sent (T4 expire)");
411#endif 366
412 hfc->l1_activated = false; 367 hfc->l1_activated = 0;
413 handle_led(hfc, LED_S0_OFF); 368 handle_led(hfc, LED_S0_OFF);
414} 369}
415 370
416/*****************************/ 371/* S0 state changed */
417/* handle S0 state changes */
418/*****************************/
419static void 372static void
420state_handler(hfcusb_data * hfc, __u8 state) 373s0_state_handler(hfcusb_data * hfc, __u8 state)
421{ 374{
422 __u8 old_state; 375 __u8 old_state;
423 376
@@ -425,38 +378,29 @@ state_handler(hfcusb_data * hfc, __u8 state)
425 if (state == old_state || state < 1 || state > 8) 378 if (state == old_state || state < 1 || state > 8)
426 return; 379 return;
427 380
428#ifdef CONFIG_HISAX_DEBUG 381 DBG(HFCUSB_DBG_STATES, "HFC-S USB: S0 statechange(%d -> %d)",
429 DBG(ISDN_DBG, "HFC-S USB: new S0 state:%d old_state:%d", state, 382 old_state, state);
430 old_state); 383
431#endif
432 if (state < 4 || state == 7 || state == 8) { 384 if (state < 4 || state == 7 || state == 8) {
433 if (timer_pending(&hfc->t3_timer)) 385 if (timer_pending(&hfc->t3_timer))
434 del_timer(&hfc->t3_timer); 386 del_timer(&hfc->t3_timer);
435#ifdef CONFIG_HISAX_DEBUG 387 DBG(HFCUSB_DBG_STATES, "HFC-S USB: T3 deactivated");
436 DBG(ISDN_DBG, "HFC-S USB: T3 deactivated");
437#endif
438 } 388 }
439 if (state >= 7) { 389 if (state >= 7) {
440 if (timer_pending(&hfc->t4_timer)) 390 if (timer_pending(&hfc->t4_timer))
441 del_timer(&hfc->t4_timer); 391 del_timer(&hfc->t4_timer);
442#ifdef CONFIG_HISAX_DEBUG 392 DBG(HFCUSB_DBG_STATES, "HFC-S USB: T4 deactivated");
443 DBG(ISDN_DBG, "HFC-S USB: T4 deactivated");
444#endif
445 } 393 }
446 394
447 if (state == 7 && !hfc->l1_activated) { 395 if (state == 7 && !hfc->l1_activated) {
448 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, 396 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,
449 PH_ACTIVATE | INDICATION, NULL); 397 PH_ACTIVATE | INDICATION, NULL);
450#ifdef CONFIG_HISAX_DEBUG 398 DBG(HFCUSB_DBG_STATES, "HFC-S USB: PH_ACTIVATE | INDICATION sent");
451 DBG(ISDN_DBG, "HFC-S USB: PH_ACTIVATE | INDICATION sent"); 399 hfc->l1_activated = 1;
452#endif
453 hfc->l1_activated = true;
454 handle_led(hfc, LED_S0_ON); 400 handle_led(hfc, LED_S0_ON);
455 } else if (state <= 3 /* && activated */ ) { 401 } else if (state <= 3 /* && activated */ ) {
456 if (old_state == 7 || old_state == 8) { 402 if (old_state == 7 || old_state == 8) {
457#ifdef CONFIG_HISAX_DEBUG 403 DBG(HFCUSB_DBG_STATES, "HFC-S USB: T4 activated");
458 DBG(ISDN_DBG, "HFC-S USB: T4 activated");
459#endif
460 if (!timer_pending(&hfc->t4_timer)) { 404 if (!timer_pending(&hfc->t4_timer)) {
461 hfc->t4_timer.expires = 405 hfc->t4_timer.expires =
462 jiffies + (HFC_TIMER_T4 * HZ) / 1000; 406 jiffies + (HFC_TIMER_T4 * HZ) / 1000;
@@ -466,18 +410,15 @@ state_handler(hfcusb_data * hfc, __u8 state)
466 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, 410 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,
467 PH_DEACTIVATE | INDICATION, 411 PH_DEACTIVATE | INDICATION,
468 NULL); 412 NULL);
469#ifdef CONFIG_HISAX_DEBUG 413 DBG(HFCUSB_DBG_STATES,
470 DBG(ISDN_DBG,
471 "HFC-S USB: PH_DEACTIVATE | INDICATION sent"); 414 "HFC-S USB: PH_DEACTIVATE | INDICATION sent");
472#endif 415 hfc->l1_activated = 0;
473 hfc->l1_activated = false;
474 handle_led(hfc, LED_S0_OFF); 416 handle_led(hfc, LED_S0_OFF);
475 } 417 }
476 } 418 }
477 hfc->l1_state = state; 419 hfc->l1_state = state;
478} 420}
479 421
480/* prepare iso urb */
481static void 422static void
482fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe, 423fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe,
483 void *buf, int num_packets, int packet_size, int interval, 424 void *buf, int num_packets, int packet_size, int interval,
@@ -503,15 +444,16 @@ fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe,
503} 444}
504 445
505/* allocs urbs and start isoc transfer with two pending urbs to avoid 446/* allocs urbs and start isoc transfer with two pending urbs to avoid
506 gaps in the transfer chain */ 447 * gaps in the transfer chain
448 */
507static int 449static int
508start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb, 450start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb,
509 usb_complete_t complete, int packet_size) 451 usb_complete_t complete, int packet_size)
510{ 452{
511 int i, k, errcode; 453 int i, k, errcode;
512 454
513 printk(KERN_INFO "HFC-S USB: starting ISO-chain for Fifo %i\n", 455 DBG(HFCUSB_DBG_INIT, "HFC-S USB: starting ISO-URBs for fifo:%d\n",
514 fifo->fifonum); 456 fifo->fifonum);
515 457
516 /* allocate Memory for Iso out Urbs */ 458 /* allocate Memory for Iso out Urbs */
517 for (i = 0; i < 2; i++) { 459 for (i = 0; i < 2; i++) {
@@ -556,10 +498,9 @@ start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb,
556 498
557 errcode = usb_submit_urb(fifo->iso[i].purb, GFP_KERNEL); 499 errcode = usb_submit_urb(fifo->iso[i].purb, GFP_KERNEL);
558 fifo->active = (errcode >= 0) ? 1 : 0; 500 fifo->active = (errcode >= 0) ? 1 : 0;
559 if (errcode < 0) { 501 if (errcode < 0)
560 printk(KERN_INFO "HFC-S USB: %s URB nr:%d\n", 502 printk(KERN_INFO "HFC-S USB: usb_submit_urb URB nr:%d, error(%i): '%s'\n",
561 symbolic(urb_errlist, errcode), i); 503 i, errcode, symbolic(urb_errlist, errcode));
562 };
563 } 504 }
564 return (fifo->active); 505 return (fifo->active);
565} 506}
@@ -572,16 +513,15 @@ stop_isoc_chain(usb_fifo * fifo)
572 513
573 for (i = 0; i < 2; i++) { 514 for (i = 0; i < 2; i++) {
574 if (fifo->iso[i].purb) { 515 if (fifo->iso[i].purb) {
575#ifdef CONFIG_HISAX_DEBUG 516 DBG(HFCUSB_DBG_INIT,
576 DBG(USB_DBG,
577 "HFC-S USB: Stopping iso chain for fifo %i.%i", 517 "HFC-S USB: Stopping iso chain for fifo %i.%i",
578 fifo->fifonum, i); 518 fifo->fifonum, i);
579#endif
580 usb_kill_urb(fifo->iso[i].purb); 519 usb_kill_urb(fifo->iso[i].purb);
581 usb_free_urb(fifo->iso[i].purb); 520 usb_free_urb(fifo->iso[i].purb);
582 fifo->iso[i].purb = NULL; 521 fifo->iso[i].purb = NULL;
583 } 522 }
584 } 523 }
524
585 usb_kill_urb(fifo->urb); 525 usb_kill_urb(fifo->urb);
586 usb_free_urb(fifo->urb); 526 usb_free_urb(fifo->urb);
587 fifo->urb = NULL; 527 fifo->urb = NULL;
@@ -594,9 +534,6 @@ static int iso_packets[8] =
594 ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D 534 ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D
595}; 535};
596 536
597/*****************************************************/
598/* transmit completion routine for all ISO tx fifos */
599/*****************************************************/
600static void 537static void
601tx_iso_complete(struct urb *urb) 538tx_iso_complete(struct urb *urb)
602{ 539{
@@ -607,20 +544,38 @@ tx_iso_complete(struct urb *urb)
607 errcode; 544 errcode;
608 int frame_complete, transp_mode, fifon, status; 545 int frame_complete, transp_mode, fifon, status;
609 __u8 threshbit; 546 __u8 threshbit;
610 __u8 threshtable[8] = { 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80 };
611 547
612 fifon = fifo->fifonum; 548 fifon = fifo->fifonum;
613 status = urb->status; 549 status = urb->status;
614 550
615 tx_offset = 0; 551 tx_offset = 0;
616 552
553 /* ISO transfer only partially completed,
554 look at individual frame status for details */
555 if (status == -EXDEV) {
556 DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: tx_iso_complete with -EXDEV"
557 ", urb->status %d, fifonum %d\n",
558 status, fifon);
559
560 for (k = 0; k < iso_packets[fifon]; ++k) {
561 errcode = urb->iso_frame_desc[k].status;
562 if (errcode)
563 DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: tx_iso_complete "
564 "packet %i, status: %i\n",
565 k, errcode);
566 }
567
568 // clear status, so go on with ISO transfers
569 status = 0;
570 }
571
617 if (fifo->active && !status) { 572 if (fifo->active && !status) {
618 transp_mode = 0; 573 transp_mode = 0;
619 if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS) 574 if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS)
620 transp_mode = true; 575 transp_mode = 1;
621 576
622 /* is FifoFull-threshold set for our channel? */ 577 /* is FifoFull-threshold set for our channel? */
623 threshbit = threshtable[fifon] & hfc->threshold_mask; 578 threshbit = (hfc->threshold_mask & (1 << fifon));
624 num_isoc_packets = iso_packets[fifon]; 579 num_isoc_packets = iso_packets[fifon];
625 580
626 /* predict dataflow to avoid fifo overflow */ 581 /* predict dataflow to avoid fifo overflow */
@@ -635,8 +590,9 @@ tx_iso_complete(struct urb *urb)
635 tx_iso_complete, urb->context); 590 tx_iso_complete, urb->context);
636 memset(context_iso_urb->buffer, 0, 591 memset(context_iso_urb->buffer, 0,
637 sizeof(context_iso_urb->buffer)); 592 sizeof(context_iso_urb->buffer));
638 frame_complete = false; 593 frame_complete = 0;
639 /* Generate next Iso Packets */ 594
595 /* Generate next ISO Packets */
640 for (k = 0; k < num_isoc_packets; ++k) { 596 for (k = 0; k < num_isoc_packets; ++k) {
641 if (fifo->skbuff) { 597 if (fifo->skbuff) {
642 len = fifo->skbuff->len; 598 len = fifo->skbuff->len;
@@ -661,7 +617,7 @@ tx_iso_complete(struct urb *urb)
661 /* add 2 byte flags and 16bit CRC at end of ISDN frame */ 617 /* add 2 byte flags and 16bit CRC at end of ISDN frame */
662 fifo->bit_line += 32; 618 fifo->bit_line += 32;
663 } 619 }
664 frame_complete = true; 620 frame_complete = 1;
665 } 621 }
666 622
667 memcpy(context_iso_urb->buffer + 623 memcpy(context_iso_urb->buffer +
@@ -688,7 +644,7 @@ tx_iso_complete(struct urb *urb)
688 } 644 }
689 645
690 if (frame_complete) { 646 if (frame_complete) {
691 fifo->delete_flg = true; 647 fifo->delete_flg = 1;
692 fifo->hif->l1l2(fifo->hif, 648 fifo->hif->l1l2(fifo->hif,
693 PH_DATA | CONFIRM, 649 PH_DATA | CONFIRM,
694 (void *) (unsigned long) fifo->skbuff-> 650 (void *) (unsigned long) fifo->skbuff->
@@ -696,30 +652,26 @@ tx_iso_complete(struct urb *urb)
696 if (fifo->skbuff && fifo->delete_flg) { 652 if (fifo->skbuff && fifo->delete_flg) {
697 dev_kfree_skb_any(fifo->skbuff); 653 dev_kfree_skb_any(fifo->skbuff);
698 fifo->skbuff = NULL; 654 fifo->skbuff = NULL;
699 fifo->delete_flg = false; 655 fifo->delete_flg = 0;
700 } 656 }
701 frame_complete = false; 657 frame_complete = 0;
702 } 658 }
703 } 659 }
704 errcode = usb_submit_urb(urb, GFP_ATOMIC); 660 errcode = usb_submit_urb(urb, GFP_ATOMIC);
705 if (errcode < 0) { 661 if (errcode < 0) {
706 printk(KERN_INFO 662 printk(KERN_INFO
707 "HFC-S USB: error submitting ISO URB: %d \n", 663 "HFC-S USB: error submitting ISO URB: %d\n",
708 errcode); 664 errcode);
709 } 665 }
710 } else { 666 } else {
711 if (status && !hfc->disc_flag) { 667 if (status && !hfc->disc_flag) {
712 printk(KERN_INFO 668 printk(KERN_INFO
713 "HFC-S USB: tx_iso_complete : urb->status %s (%i), fifonum=%d\n", 669 "HFC-S USB: tx_iso_complete: error(%i): '%s', fifonum=%d\n",
714 symbolic(urb_errlist, status), status, 670 status, symbolic(urb_errlist, status), fifon);
715 fifon);
716 } 671 }
717 } 672 }
718} /* tx_iso_complete */ 673}
719 674
720/*****************************************************/
721/* receive completion routine for all ISO tx fifos */
722/*****************************************************/
723static void 675static void
724rx_iso_complete(struct urb *urb) 676rx_iso_complete(struct urb *urb)
725{ 677{
@@ -731,21 +683,25 @@ rx_iso_complete(struct urb *urb)
731 unsigned int iso_status; 683 unsigned int iso_status;
732 __u8 *buf; 684 __u8 *buf;
733 static __u8 eof[8]; 685 static __u8 eof[8];
734#ifdef CONFIG_HISAX_DEBUG
735 __u8 i;
736#endif
737 686
738 fifon = fifo->fifonum; 687 fifon = fifo->fifonum;
739 status = urb->status; 688 status = urb->status;
740 689
741 if (urb->status == -EOVERFLOW) { 690 if (urb->status == -EOVERFLOW) {
742#ifdef CONFIG_HISAX_DEBUG 691 DBG(HFCUSB_DBG_VERBOSE_USB,
743 DBG(USB_DBG, 692 "HFC-USB: ignoring USB DATAOVERRUN fifo(%i)", fifon);
744 "HFC-USB: ignoring USB DATAOVERRUN for fifo %i \n", 693 status = 0;
745 fifon); 694 }
746#endif 695
696 /* ISO transfer only partially completed,
697 look at individual frame status for details */
698 if (status == -EXDEV) {
699 DBG(HFCUSB_DBG_VERBOSE_USB, "HFC-S USB: rx_iso_complete with -EXDEV "
700 "urb->status %d, fifonum %d\n",
701 status, fifon);
747 status = 0; 702 status = 0;
748 } 703 }
704
749 if (fifo->active && !status) { 705 if (fifo->active && !status) {
750 num_isoc_packets = iso_packets[fifon]; 706 num_isoc_packets = iso_packets[fifon];
751 maxlen = fifo->usb_packet_maxlen; 707 maxlen = fifo->usb_packet_maxlen;
@@ -754,40 +710,38 @@ rx_iso_complete(struct urb *urb)
754 offset = urb->iso_frame_desc[k].offset; 710 offset = urb->iso_frame_desc[k].offset;
755 buf = context_iso_urb->buffer + offset; 711 buf = context_iso_urb->buffer + offset;
756 iso_status = urb->iso_frame_desc[k].status; 712 iso_status = urb->iso_frame_desc[k].status;
757#ifdef CONFIG_HISAX_DEBUG 713
758 if (iso_status && !hfc->disc_flag) 714 if (iso_status && !hfc->disc_flag)
759 DBG(USB_DBG, 715 DBG(HFCUSB_DBG_VERBOSE_USB,
760 "HFC-S USB: ISO packet failure - status:%x", 716 "HFC-S USB: rx_iso_complete "
761 iso_status); 717 "ISO packet %i, status: %i\n",
718 k, iso_status);
762 719
763 if ((fifon == 5) && (debug > 1)) { 720 if (fifon == HFCUSB_D_RX) {
764 printk(KERN_INFO 721 DBG(HFCUSB_DBG_VERBOSE_USB,
765 "HFC-S USB: ISO-D-RX lst_urblen:%2d " 722 "HFC-S USB: ISO-D-RX lst_urblen:%2d "
766 "act_urblen:%2d max-urblen:%2d " 723 "act_urblen:%2d max-urblen:%2d EOF:0x%0x",
767 "EOF:0x%0x DATA: ",
768 fifo->last_urblen, len, maxlen, 724 fifo->last_urblen, len, maxlen,
769 eof[5]); 725 eof[5]);
770 for (i = 0; i < len; i++) 726
771 printk("%.2x ", buf[i]); 727 DBG_PACKET(HFCUSB_DBG_VERBOSE_USB, buf, len);
772 printk("\n");
773 } 728 }
774#endif 729
775 if (fifo->last_urblen != maxlen) { 730 if (fifo->last_urblen != maxlen) {
776 /* the threshold mask is in the 2nd status byte */ 731 /* the threshold mask is in the 2nd status byte */
777 hfc->threshold_mask = buf[1]; 732 hfc->threshold_mask = buf[1];
778 /* care for L1 state only for D-Channel 733 /* care for L1 state only for D-Channel
779 to avoid overlapped iso completions */ 734 to avoid overlapped iso completions */
780 if (fifon == 5) { 735 if (fifon == HFCUSB_D_RX) {
781 /* the S0 state is in the upper half 736 /* the S0 state is in the upper half
782 of the 1st status byte */ 737 of the 1st status byte */
783 state_handler(hfc, buf[0] >> 4); 738 s0_state_handler(hfc, buf[0] >> 4);
784 } 739 }
785 eof[fifon] = buf[0] & 1; 740 eof[fifon] = buf[0] & 1;
786 if (len > 2) 741 if (len > 2)
787 collect_rx_frame(fifo, buf + 2, 742 collect_rx_frame(fifo, buf + 2,
788 len - 2, 743 len - 2,
789 (len < 744 (len < maxlen) ?
790 maxlen) ?
791 eof[fifon] : 0); 745 eof[fifon] : 0);
792 } else { 746 } else {
793 collect_rx_frame(fifo, buf, len, 747 collect_rx_frame(fifo, buf, len,
@@ -804,41 +758,37 @@ rx_iso_complete(struct urb *urb)
804 rx_iso_complete, urb->context); 758 rx_iso_complete, urb->context);
805 errcode = usb_submit_urb(urb, GFP_ATOMIC); 759 errcode = usb_submit_urb(urb, GFP_ATOMIC);
806 if (errcode < 0) { 760 if (errcode < 0) {
807 printk(KERN_INFO 761 printk(KERN_ERR
808 "HFC-S USB: error submitting ISO URB: %d \n", 762 "HFC-S USB: error submitting ISO URB: %d\n",
809 errcode); 763 errcode);
810 } 764 }
811 } else { 765 } else {
812 if (status && !hfc->disc_flag) { 766 if (status && !hfc->disc_flag) {
813 printk(KERN_INFO 767 printk(KERN_ERR
814 "HFC-S USB: rx_iso_complete : " 768 "HFC-S USB: rx_iso_complete : "
815 "urb->status %d, fifonum %d\n", 769 "urb->status %d, fifonum %d\n",
816 status, fifon); 770 status, fifon);
817 } 771 }
818 } 772 }
819} /* rx_iso_complete */ 773}
820 774
821/*****************************************************/ 775/* collect rx data from INT- and ISO-URBs */
822/* collect data from interrupt or isochron in */
823/*****************************************************/
824static void 776static void
825collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish) 777collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
826{ 778{
827 hfcusb_data *hfc = fifo->hfc; 779 hfcusb_data *hfc = fifo->hfc;
828 int transp_mode, fifon; 780 int transp_mode, fifon;
829#ifdef CONFIG_HISAX_DEBUG 781
830 int i;
831#endif
832 fifon = fifo->fifonum; 782 fifon = fifo->fifonum;
833 transp_mode = 0; 783 transp_mode = 0;
834 if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS) 784 if (fifon < 4 && hfc->b_mode[fifon / 2] == L1_MODE_TRANS)
835 transp_mode = true; 785 transp_mode = 1;
836 786
837 if (!fifo->skbuff) { 787 if (!fifo->skbuff) {
838 fifo->skbuff = dev_alloc_skb(fifo->max_size + 3); 788 fifo->skbuff = dev_alloc_skb(fifo->max_size + 3);
839 if (!fifo->skbuff) { 789 if (!fifo->skbuff) {
840 printk(KERN_INFO 790 printk(KERN_ERR
841 "HFC-S USB: cannot allocate buffer (dev_alloc_skb) fifo:%d\n", 791 "HFC-S USB: cannot allocate buffer for fifo(%d)\n",
842 fifon); 792 fifon);
843 return; 793 return;
844 } 794 }
@@ -847,17 +797,11 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
847 if (fifo->skbuff->len + len < fifo->max_size) { 797 if (fifo->skbuff->len + len < fifo->max_size) {
848 memcpy(skb_put(fifo->skbuff, len), data, len); 798 memcpy(skb_put(fifo->skbuff, len), data, len);
849 } else { 799 } else {
850#ifdef CONFIG_HISAX_DEBUG 800 DBG(HFCUSB_DBG_FIFO_ERR,
851 printk(KERN_INFO "HFC-S USB: "); 801 "HCF-USB: got frame exceeded fifo->max_size(%d) fifo(%d)",
852 for (i = 0; i < 15; i++)
853 printk("%.2x ",
854 fifo->skbuff->data[fifo->skbuff->
855 len - 15 + i]);
856 printk("\n");
857#endif
858 printk(KERN_INFO
859 "HCF-USB: got frame exceeded fifo->max_size:%d on fifo:%d\n",
860 fifo->max_size, fifon); 802 fifo->max_size, fifon);
803 DBG_SKB(HFCUSB_DBG_VERBOSE_USB, fifo->skbuff);
804 skb_trim(fifo->skbuff, 0);
861 } 805 }
862 } 806 }
863 if (transp_mode && fifo->skbuff->len >= 128) { 807 if (transp_mode && fifo->skbuff->len >= 128) {
@@ -870,6 +814,13 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
870 if (finish) { 814 if (finish) {
871 if ((!fifo->skbuff->data[fifo->skbuff->len - 1]) 815 if ((!fifo->skbuff->data[fifo->skbuff->len - 1])
872 && (fifo->skbuff->len > 3)) { 816 && (fifo->skbuff->len > 3)) {
817
818 if (fifon == HFCUSB_D_RX) {
819 DBG(HFCUSB_DBG_DCHANNEL,
820 "HFC-S USB: D-RX len(%d)", fifo->skbuff->len);
821 DBG_SKB(HFCUSB_DBG_DCHANNEL, fifo->skbuff);
822 }
823
873 /* remove CRC & status */ 824 /* remove CRC & status */
874 skb_trim(fifo->skbuff, fifo->skbuff->len - 3); 825 skb_trim(fifo->skbuff, fifo->skbuff->len - 3);
875 if (fifon == HFCUSB_PCM_RX) { 826 if (fifon == HFCUSB_PCM_RX) {
@@ -882,39 +833,17 @@ collect_rx_frame(usb_fifo * fifo, __u8 * data, int len, int finish)
882 fifo->skbuff); 833 fifo->skbuff);
883 fifo->skbuff = NULL; /* buffer was freed from upper layer */ 834 fifo->skbuff = NULL; /* buffer was freed from upper layer */
884 } else { 835 } else {
885 if (fifo->skbuff->len > 3) { 836 DBG(HFCUSB_DBG_FIFO_ERR,
886 printk(KERN_INFO 837 "HFC-S USB: ERROR frame len(%d) fifo(%d)",
887 "HFC-S USB: got frame %d bytes but CRC ERROR on fifo:%d!!!\n", 838 fifo->skbuff->len, fifon);
888 fifo->skbuff->len, fifon); 839 DBG_SKB(HFCUSB_DBG_VERBOSE_USB, fifo->skbuff);
889#ifdef CONFIG_HISAX_DEBUG
890 if (debug > 1) {
891 printk(KERN_INFO "HFC-S USB: ");
892 for (i = 0; i < 15; i++)
893 printk("%.2x ",
894 fifo->skbuff->
895 data[fifo->skbuff->
896 len - 15 + i]);
897 printk("\n");
898 }
899#endif
900 }
901#ifdef CONFIG_HISAX_DEBUG
902 else {
903 printk(KERN_INFO
904 "HFC-S USB: frame to small (%d bytes)!!!\n",
905 fifo->skbuff->len);
906 }
907#endif
908 skb_trim(fifo->skbuff, 0); 840 skb_trim(fifo->skbuff, 0);
909 } 841 }
910 } 842 }
911} 843}
912 844
913/***********************************************/
914/* receive completion routine for all rx fifos */
915/***********************************************/
916static void 845static void
917rx_complete(struct urb *urb) 846rx_int_complete(struct urb *urb)
918{ 847{
919 int len; 848 int len;
920 int status; 849 int status;
@@ -922,18 +851,14 @@ rx_complete(struct urb *urb)
922 usb_fifo *fifo = (usb_fifo *) urb->context; 851 usb_fifo *fifo = (usb_fifo *) urb->context;
923 hfcusb_data *hfc = fifo->hfc; 852 hfcusb_data *hfc = fifo->hfc;
924 static __u8 eof[8]; 853 static __u8 eof[8];
925#ifdef CONFIG_HISAX_DEBUG
926 __u8 i;
927#endif
928 854
929 urb->dev = hfc->dev; /* security init */ 855 urb->dev = hfc->dev; /* security init */
930 856
931 fifon = fifo->fifonum; 857 fifon = fifo->fifonum;
932 if ((!fifo->active) || (urb->status)) { 858 if ((!fifo->active) || (urb->status)) {
933#ifdef CONFIG_HISAX_DEBUG 859 DBG(HFCUSB_DBG_INIT, "HFC-S USB: RX-Fifo %i is going down (%i)",
934 DBG(USB_DBG, "HFC-S USB: RX-Fifo %i is going down (%i)",
935 fifon, urb->status); 860 fifon, urb->status);
936#endif 861
937 fifo->urb->interval = 0; /* cancel automatic rescheduling */ 862 fifo->urb->interval = 0; /* cancel automatic rescheduling */
938 if (fifo->skbuff) { 863 if (fifo->skbuff) {
939 dev_kfree_skb_any(fifo->skbuff); 864 dev_kfree_skb_any(fifo->skbuff);
@@ -945,22 +870,20 @@ rx_complete(struct urb *urb)
945 buf = fifo->buffer; 870 buf = fifo->buffer;
946 maxlen = fifo->usb_packet_maxlen; 871 maxlen = fifo->usb_packet_maxlen;
947 872
948#ifdef CONFIG_HISAX_DEBUG 873 if (fifon == HFCUSB_D_RX) {
949 if ((fifon == 5) && (debug > 1)) { 874 DBG(HFCUSB_DBG_VERBOSE_USB,
950 printk(KERN_INFO 875 "HFC-S USB: INT-D-RX lst_urblen:%2d "
951 "HFC-S USB: INT-D-RX lst_urblen:%2d act_urblen:%2d max-urblen:%2d EOF:0x%0x DATA: ", 876 "act_urblen:%2d max-urblen:%2d EOF:0x%0x",
952 fifo->last_urblen, len, maxlen, eof[5]); 877 fifo->last_urblen, len, maxlen,
953 for (i = 0; i < len; i++) 878 eof[5]);
954 printk("%.2x ", buf[i]); 879 DBG_PACKET(HFCUSB_DBG_VERBOSE_USB, buf, len);
955 printk("\n");
956 } 880 }
957#endif
958 881
959 if (fifo->last_urblen != fifo->usb_packet_maxlen) { 882 if (fifo->last_urblen != fifo->usb_packet_maxlen) {
960 /* the threshold mask is in the 2nd status byte */ 883 /* the threshold mask is in the 2nd status byte */
961 hfc->threshold_mask = buf[1]; 884 hfc->threshold_mask = buf[1];
962 /* the S0 state is in the upper half of the 1st status byte */ 885 /* the S0 state is in the upper half of the 1st status byte */
963 state_handler(hfc, buf[0] >> 4); 886 s0_state_handler(hfc, buf[0] >> 4);
964 eof[fifon] = buf[0] & 1; 887 eof[fifon] = buf[0] & 1;
965 /* if we have more than the 2 status bytes -> collect data */ 888 /* if we have more than the 2 status bytes -> collect data */
966 if (len > 2) 889 if (len > 2)
@@ -975,20 +898,19 @@ rx_complete(struct urb *urb)
975 status = usb_submit_urb(urb, GFP_ATOMIC); 898 status = usb_submit_urb(urb, GFP_ATOMIC);
976 if (status) { 899 if (status) {
977 printk(KERN_INFO 900 printk(KERN_INFO
978 "HFC-S USB: error resubmitting URN at rx_complete...\n"); 901 "HFC-S USB: %s error resubmitting URB fifo(%d)\n",
902 __FUNCTION__, fifon);
979 } 903 }
980} /* rx_complete */ 904}
981 905
982/***************************************************/ 906/* start initial INT-URB for certain fifo */
983/* start the interrupt transfer for the given fifo */
984/***************************************************/
985static void 907static void
986start_int_fifo(usb_fifo * fifo) 908start_int_fifo(usb_fifo * fifo)
987{ 909{
988 int errcode; 910 int errcode;
989 911
990 printk(KERN_INFO "HFC-S USB: starting intr IN fifo:%d\n", 912 DBG(HFCUSB_DBG_INIT, "HFC-S USB: starting RX INT-URB for fifo:%d\n",
991 fifo->fifonum); 913 fifo->fifonum);
992 914
993 if (!fifo->urb) { 915 if (!fifo->urb) {
994 fifo->urb = usb_alloc_urb(0, GFP_KERNEL); 916 fifo->urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -997,33 +919,28 @@ start_int_fifo(usb_fifo * fifo)
997 } 919 }
998 usb_fill_int_urb(fifo->urb, fifo->hfc->dev, fifo->pipe, 920 usb_fill_int_urb(fifo->urb, fifo->hfc->dev, fifo->pipe,
999 fifo->buffer, fifo->usb_packet_maxlen, 921 fifo->buffer, fifo->usb_packet_maxlen,
1000 rx_complete, fifo, fifo->intervall); 922 rx_int_complete, fifo, fifo->intervall);
1001 fifo->active = 1; /* must be marked active */ 923 fifo->active = 1; /* must be marked active */
1002 errcode = usb_submit_urb(fifo->urb, GFP_KERNEL); 924 errcode = usb_submit_urb(fifo->urb, GFP_KERNEL);
1003 if (errcode) { 925 if (errcode) {
1004 printk(KERN_INFO 926 printk(KERN_ERR
1005 "HFC-S USB: submit URB error(start_int_info): status:%i\n", 927 "HFC-S USB: submit URB error(start_int_info): status:%i\n",
1006 errcode); 928 errcode);
1007 fifo->active = 0; 929 fifo->active = 0;
1008 fifo->skbuff = NULL; 930 fifo->skbuff = NULL;
1009 } 931 }
1010} /* start_int_fifo */ 932}
1011 933
1012/*****************************/
1013/* set the B-channel mode */
1014/*****************************/
1015static void 934static void
1016set_hfcmode(hfcusb_data * hfc, int channel, int mode) 935setup_bchannel(hfcusb_data * hfc, int channel, int mode)
1017{ 936{
1018 __u8 val, idx_table[2] = { 0, 2 }; 937 __u8 val, idx_table[2] = { 0, 2 };
1019 938
1020 if (hfc->disc_flag) { 939 if (hfc->disc_flag) {
1021 return; 940 return;
1022 } 941 }
1023#ifdef CONFIG_HISAX_DEBUG 942 DBG(HFCUSB_DBG_STATES, "HFC-S USB: setting channel %d to mode %d",
1024 DBG(ISDN_DBG, "HFC-S USB: setting channel %d to mode %d", channel, 943 channel, mode);
1025 mode);
1026#endif
1027 hfc->b_mode[channel] = mode; 944 hfc->b_mode[channel] = mode;
1028 945
1029 /* setup CON_HDLC */ 946 /* setup CON_HDLC */
@@ -1080,20 +997,17 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
1080 switch (pr) { 997 switch (pr) {
1081 case PH_ACTIVATE | REQUEST: 998 case PH_ACTIVATE | REQUEST:
1082 if (fifo->fifonum == HFCUSB_D_TX) { 999 if (fifo->fifonum == HFCUSB_D_TX) {
1083#ifdef CONFIG_HISAX_DEBUG 1000 DBG(HFCUSB_DBG_STATES,
1084 DBG(ISDN_DBG,
1085 "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_ACTIVATE | REQUEST"); 1001 "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_ACTIVATE | REQUEST");
1086#endif 1002
1087 if (hfc->l1_state != 3 1003 if (hfc->l1_state != 3
1088 && hfc->l1_state != 7) { 1004 && hfc->l1_state != 7) {
1089 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc, 1005 hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,
1090 PH_DEACTIVATE | 1006 PH_DEACTIVATE |
1091 INDICATION, 1007 INDICATION,
1092 NULL); 1008 NULL);
1093#ifdef CONFIG_HISAX_DEBUG 1009 DBG(HFCUSB_DBG_STATES,
1094 DBG(ISDN_DBG,
1095 "HFC-S USB: PH_DEACTIVATE | INDICATION sent (not state 3 or 7)"); 1010 "HFC-S USB: PH_DEACTIVATE | INDICATION sent (not state 3 or 7)");
1096#endif
1097 } else { 1011 } else {
1098 if (hfc->l1_state == 7) { /* l1 already active */ 1012 if (hfc->l1_state == 7) { /* l1 already active */
1099 hfc->d_if.ifc.l1l2(&hfc-> 1013 hfc->d_if.ifc.l1l2(&hfc->
@@ -1103,10 +1017,8 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
1103 | 1017 |
1104 INDICATION, 1018 INDICATION,
1105 NULL); 1019 NULL);
1106#ifdef CONFIG_HISAX_DEBUG 1020 DBG(HFCUSB_DBG_STATES,
1107 DBG(ISDN_DBG,
1108 "HFC-S USB: PH_ACTIVATE | INDICATION sent again ;)"); 1021 "HFC-S USB: PH_ACTIVATE | INDICATION sent again ;)");
1109#endif
1110 } else { 1022 } else {
1111 /* force sending sending INFO1 */ 1023 /* force sending sending INFO1 */
1112 queue_control_request(hfc, 1024 queue_control_request(hfc,
@@ -1132,11 +1044,9 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
1132 } 1044 }
1133 } 1045 }
1134 } else { 1046 } else {
1135#ifdef CONFIG_HISAX_DEBUG 1047 DBG(HFCUSB_DBG_STATES,
1136 DBG(ISDN_DBG, 1048 "HFC_USB: hfc_usb_d_l2l1 B-chan: PH_ACTIVATE | REQUEST");
1137 "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_ACTIVATE | REQUEST"); 1049 setup_bchannel(hfc,
1138#endif
1139 set_hfcmode(hfc,
1140 (fifo->fifonum == 1050 (fifo->fifonum ==
1141 HFCUSB_B1_TX) ? 0 : 1, 1051 HFCUSB_B1_TX) ? 0 : 1,
1142 (long) arg); 1052 (long) arg);
@@ -1147,18 +1057,12 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
1147 break; 1057 break;
1148 case PH_DEACTIVATE | REQUEST: 1058 case PH_DEACTIVATE | REQUEST:
1149 if (fifo->fifonum == HFCUSB_D_TX) { 1059 if (fifo->fifonum == HFCUSB_D_TX) {
1150#ifdef CONFIG_HISAX_DEBUG 1060 DBG(HFCUSB_DBG_STATES,
1151 DBG(ISDN_DBG,
1152 "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DEACTIVATE | REQUEST"); 1061 "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DEACTIVATE | REQUEST");
1153#endif
1154 printk(KERN_INFO
1155 "HFC-S USB: ISDN TE device should not deativate...\n");
1156 } else { 1062 } else {
1157#ifdef CONFIG_HISAX_DEBUG 1063 DBG(HFCUSB_DBG_STATES,
1158 DBG(ISDN_DBG,
1159 "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DEACTIVATE | REQUEST"); 1064 "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DEACTIVATE | REQUEST");
1160#endif 1065 setup_bchannel(hfc,
1161 set_hfcmode(hfc,
1162 (fifo->fifonum == 1066 (fifo->fifonum ==
1163 HFCUSB_B1_TX) ? 0 : 1, 1067 HFCUSB_B1_TX) ? 0 : 1,
1164 (int) L1_MODE_NULL); 1068 (int) L1_MODE_NULL);
@@ -1171,25 +1075,20 @@ hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg)
1171 if (fifo->skbuff && fifo->delete_flg) { 1075 if (fifo->skbuff && fifo->delete_flg) {
1172 dev_kfree_skb_any(fifo->skbuff); 1076 dev_kfree_skb_any(fifo->skbuff);
1173 fifo->skbuff = NULL; 1077 fifo->skbuff = NULL;
1174 fifo->delete_flg = false; 1078 fifo->delete_flg = 0;
1175 } 1079 }
1176 fifo->skbuff = arg; /* we have a new buffer */ 1080 fifo->skbuff = arg; /* we have a new buffer */
1177 break; 1081 break;
1178 default: 1082 default:
1179 printk(KERN_INFO 1083 DBG(HFCUSB_DBG_STATES,
1180 "HFC_USB: hfc_usb_d_l2l1: unkown state : %#x\n", 1084 "HFC_USB: hfc_usb_d_l2l1: unkown state : %#x", pr);
1181 pr);
1182 break; 1085 break;
1183 } 1086 }
1184} 1087}
1185 1088
1186/***************************************************************************/ 1089/* initial init HFC-S USB chip registers, HiSax interface, USB URBs */
1187/* usb_init is called once when a new matching device is detected to setup */
1188/* main parameters. It registers the driver at the main hisax module. */
1189/* on success 0 is returned. */
1190/***************************************************************************/
1191static int 1090static int
1192usb_init(hfcusb_data * hfc) 1091hfc_usb_init(hfcusb_data * hfc)
1193{ 1092{
1194 usb_fifo *fifo; 1093 usb_fifo *fifo;
1195 int i, err; 1094 int i, err;
@@ -1214,11 +1113,11 @@ usb_init(hfcusb_data * hfc)
1214 /* aux = output, reset off */ 1113 /* aux = output, reset off */
1215 write_usb(hfc, HFCUSB_CIRM, 0x10); 1114 write_usb(hfc, HFCUSB_CIRM, 0x10);
1216 1115
1217 /* set USB_SIZE to match the wMaxPacketSize for INT or BULK transfers */ 1116 /* set USB_SIZE to match wMaxPacketSize for INT or BULK transfers */
1218 write_usb(hfc, HFCUSB_USB_SIZE, 1117 write_usb(hfc, HFCUSB_USB_SIZE,
1219 (hfc->packet_size / 8) | ((hfc->packet_size / 8) << 4)); 1118 (hfc->packet_size / 8) | ((hfc->packet_size / 8) << 4));
1220 1119
1221 /* set USB_SIZE_I to match the wMaxPacketSize for ISO transfers */ 1120 /* set USB_SIZE_I to match wMaxPacketSize for ISO transfers */
1222 write_usb(hfc, HFCUSB_USB_SIZE_I, hfc->iso_packet_size); 1121 write_usb(hfc, HFCUSB_USB_SIZE_I, hfc->iso_packet_size);
1223 1122
1224 /* enable PCM/GCI master mode */ 1123 /* enable PCM/GCI master mode */
@@ -1257,8 +1156,8 @@ usb_init(hfcusb_data * hfc)
1257 hfc->b_mode[0] = L1_MODE_NULL; 1156 hfc->b_mode[0] = L1_MODE_NULL;
1258 hfc->b_mode[1] = L1_MODE_NULL; 1157 hfc->b_mode[1] = L1_MODE_NULL;
1259 1158
1260 hfc->l1_activated = false; 1159 hfc->l1_activated = 0;
1261 hfc->disc_flag = false; 1160 hfc->disc_flag = 0;
1262 hfc->led_state = 0; 1161 hfc->led_state = 0;
1263 hfc->led_new_data = 0; 1162 hfc->led_new_data = 0;
1264 hfc->old_led_state = 0; 1163 hfc->old_led_state = 0;
@@ -1349,11 +1248,9 @@ usb_init(hfcusb_data * hfc)
1349 handle_led(hfc, LED_POWER_ON); 1248 handle_led(hfc, LED_POWER_ON);
1350 1249
1351 return (0); 1250 return (0);
1352} /* usb_init */ 1251}
1353 1252
1354/*************************************************/ 1253/* initial callback for each plugged USB device */
1355/* function called to probe a new plugged device */
1356/*************************************************/
1357static int 1254static int
1358hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) 1255hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1359{ 1256{
@@ -1378,11 +1275,6 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1378 } 1275 }
1379 } 1276 }
1380 1277
1381#ifdef CONFIG_HISAX_DEBUG
1382 DBG(USB_DBG,
1383 "HFC-USB: probing interface(%d) actalt(%d) minor(%d)\n", ifnum,
1384 iface->desc.bAlternateSetting, intf->minor);
1385#endif
1386 printk(KERN_INFO 1278 printk(KERN_INFO
1387 "HFC-S USB: probing interface(%d) actalt(%d) minor(%d)\n", 1279 "HFC-S USB: probing interface(%d) actalt(%d) minor(%d)\n",
1388 ifnum, iface->desc.bAlternateSetting, intf->minor); 1280 ifnum, iface->desc.bAlternateSetting, intf->minor);
@@ -1403,15 +1295,11 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1403 1295
1404 /* check for config EOL element */ 1296 /* check for config EOL element */
1405 while (validconf[cfg_used][0]) { 1297 while (validconf[cfg_used][0]) {
1406 cfg_found = true; 1298 cfg_found = 1;
1407 vcf = validconf[cfg_used]; 1299 vcf = validconf[cfg_used];
1408 /* first endpoint descriptor */ 1300 /* first endpoint descriptor */
1409 ep = iface->endpoint; 1301 ep = iface->endpoint;
1410#ifdef CONFIG_HISAX_DEBUG 1302
1411 DBG(USB_DBG,
1412 "HFC-S USB: (if=%d alt=%d cfg_used=%d)\n",
1413 ifnum, probe_alt_setting, cfg_used);
1414#endif
1415 memcpy(cmptbl, vcf, 16 * sizeof(int)); 1303 memcpy(cmptbl, vcf, 16 * sizeof(int));
1416 1304
1417 /* check for all endpoints in this alternate setting */ 1305 /* check for all endpoints in this alternate setting */
@@ -1425,7 +1313,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1425 idx++; 1313 idx++;
1426 attr = ep->desc.bmAttributes; 1314 attr = ep->desc.bmAttributes;
1427 if (cmptbl[idx] == EP_NUL) { 1315 if (cmptbl[idx] == EP_NUL) {
1428 cfg_found = false; 1316 cfg_found = 0;
1429 } 1317 }
1430 if (attr == USB_ENDPOINT_XFER_INT 1318 if (attr == USB_ENDPOINT_XFER_INT
1431 && cmptbl[idx] == EP_INT) 1319 && cmptbl[idx] == EP_INT)
@@ -1438,16 +1326,9 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1438 cmptbl[idx] = EP_NUL; 1326 cmptbl[idx] = EP_NUL;
1439 1327
1440 /* check if all INT endpoints match minimum interval */ 1328 /* check if all INT endpoints match minimum interval */
1441 if (attr == USB_ENDPOINT_XFER_INT 1329 if ((attr == USB_ENDPOINT_XFER_INT)
1442 && ep->desc.bInterval < 1330 && (ep->desc.bInterval < vcf[17])) {
1443 vcf[17]) { 1331 cfg_found = 0;
1444#ifdef CONFIG_HISAX_DEBUG
1445 if (cfg_found)
1446 DBG(USB_DBG,
1447 "HFC-S USB: Interrupt Endpoint interval < %d found - skipping config",
1448 vcf[17]);
1449#endif
1450 cfg_found = false;
1451 } 1332 }
1452 ep++; 1333 ep++;
1453 } 1334 }
@@ -1455,7 +1336,7 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1455 /* all entries must be EP_NOP or EP_NUL for a valid config */ 1336 /* all entries must be EP_NOP or EP_NUL for a valid config */
1456 if (cmptbl[i] != EP_NOP 1337 if (cmptbl[i] != EP_NOP
1457 && cmptbl[i] != EP_NUL) 1338 && cmptbl[i] != EP_NUL)
1458 cfg_found = false; 1339 cfg_found = 0;
1459 } 1340 }
1460 if (cfg_found) { 1341 if (cfg_found) {
1461 if (cfg_used < small_match) { 1342 if (cfg_used < small_match) {
@@ -1464,23 +1345,16 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1464 probe_alt_setting; 1345 probe_alt_setting;
1465 iface_used = iface; 1346 iface_used = iface;
1466 } 1347 }
1467#ifdef CONFIG_HISAX_DEBUG
1468 DBG(USB_DBG,
1469 "HFC-USB: small_match=%x %x\n",
1470 small_match, alt_used);
1471#endif
1472 } 1348 }
1473 cfg_used++; 1349 cfg_used++;
1474 } 1350 }
1475 alt_idx++; 1351 alt_idx++;
1476 } /* (alt_idx < intf->num_altsetting) */ 1352 } /* (alt_idx < intf->num_altsetting) */
1477 1353
1478 /* found a valid USB Ta Endpint config */ 1354 /* found a valid USB Ta Endpint config */
1479 if (small_match != 0xffff) { 1355 if (small_match != 0xffff) {
1480 iface = iface_used; 1356 iface = iface_used;
1481 if (! 1357 if (!(context = kzalloc(sizeof(hfcusb_data), GFP_KERNEL)))
1482 (context =
1483 kzalloc(sizeof(hfcusb_data), GFP_KERNEL)))
1484 return (-ENOMEM); /* got no mem */ 1358 return (-ENOMEM); /* got no mem */
1485 1359
1486 ep = iface->endpoint; 1360 ep = iface->endpoint;
@@ -1613,20 +1487,15 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1613 driver_info; 1487 driver_info;
1614 printk(KERN_INFO "HFC-S USB: detected \"%s\"\n", 1488 printk(KERN_INFO "HFC-S USB: detected \"%s\"\n",
1615 driver_info->vend_name); 1489 driver_info->vend_name);
1616#ifdef CONFIG_HISAX_DEBUG 1490
1617 DBG(USB_DBG, 1491 DBG(HFCUSB_DBG_INIT,
1618 "HFC-S USB: Endpoint-Config: %s (if=%d alt=%d)\n", 1492 "HFC-S USB: Endpoint-Config: %s (if=%d alt=%d), E-Channel(%d)",
1619 conf_str[small_match], context->if_used, 1493 conf_str[small_match], context->if_used,
1620 context->alt_used); 1494 context->alt_used,
1621 printk(KERN_INFO 1495 validconf[small_match][18]);
1622 "HFC-S USB: E-channel (\"ECHO:\") logging "); 1496
1623 if (validconf[small_match][18])
1624 printk(" possible\n");
1625 else
1626 printk("NOT possible\n");
1627#endif
1628 /* init the chip and register the driver */ 1497 /* init the chip and register the driver */
1629 if (usb_init(context)) { 1498 if (hfc_usb_init(context)) {
1630 usb_kill_urb(context->ctrl_urb); 1499 usb_kill_urb(context->ctrl_urb);
1631 usb_free_urb(context->ctrl_urb); 1500 usb_free_urb(context->ctrl_urb);
1632 context->ctrl_urb = NULL; 1501 context->ctrl_urb = NULL;
@@ -1643,17 +1512,19 @@ hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1643 return (-EIO); 1512 return (-EIO);
1644} 1513}
1645 1514
1646/****************************************************/ 1515/* callback for unplugged USB device */
1647/* function called when an active device is removed */
1648/****************************************************/
1649static void 1516static void
1650hfc_usb_disconnect(struct usb_interface 1517hfc_usb_disconnect(struct usb_interface
1651 *intf) 1518 *intf)
1652{ 1519{
1653 hfcusb_data *context = usb_get_intfdata(intf); 1520 hfcusb_data *context = usb_get_intfdata(intf);
1654 int i; 1521 int i;
1522
1523 handle_led(context, LED_POWER_OFF);
1524 schedule_timeout((10 * HZ) / 1000);
1525
1655 printk(KERN_INFO "HFC-S USB: device disconnect\n"); 1526 printk(KERN_INFO "HFC-S USB: device disconnect\n");
1656 context->disc_flag = true; 1527 context->disc_flag = 1;
1657 usb_set_intfdata(intf, NULL); 1528 usb_set_intfdata(intf, NULL);
1658 if (!context) 1529 if (!context)
1659 return; 1530 return;
@@ -1661,25 +1532,22 @@ hfc_usb_disconnect(struct usb_interface
1661 del_timer(&context->t3_timer); 1532 del_timer(&context->t3_timer);
1662 if (timer_pending(&context->t4_timer)) 1533 if (timer_pending(&context->t4_timer))
1663 del_timer(&context->t4_timer); 1534 del_timer(&context->t4_timer);
1535
1664 /* tell all fifos to terminate */ 1536 /* tell all fifos to terminate */
1665 for (i = 0; i < HFCUSB_NUM_FIFOS; i++) { 1537 for (i = 0; i < HFCUSB_NUM_FIFOS; i++) {
1666 if (context->fifos[i].usb_transfer_mode == USB_ISOC) { 1538 if (context->fifos[i].usb_transfer_mode == USB_ISOC) {
1667 if (context->fifos[i].active > 0) { 1539 if (context->fifos[i].active > 0) {
1668 stop_isoc_chain(&context->fifos[i]); 1540 stop_isoc_chain(&context->fifos[i]);
1669#ifdef CONFIG_HISAX_DEBUG 1541 DBG(HFCUSB_DBG_INIT,
1670 DBG(USB_DBG, 1542 "HFC-S USB: %s stopping ISOC chain Fifo(%i)",
1671 "HFC-S USB: hfc_usb_disconnect: stopping ISOC chain Fifo no %i", 1543 __FUNCTION__, i);
1672 i);
1673#endif
1674 } 1544 }
1675 } else { 1545 } else {
1676 if (context->fifos[i].active > 0) { 1546 if (context->fifos[i].active > 0) {
1677 context->fifos[i].active = 0; 1547 context->fifos[i].active = 0;
1678#ifdef CONFIG_HISAX_DEBUG 1548 DBG(HFCUSB_DBG_INIT,
1679 DBG(USB_DBG, 1549 "HFC-S USB: %s unlinking URB for Fifo(%i)",
1680 "HFC-S USB: hfc_usb_disconnect: unlinking URB for Fifo no %i", 1550 __FUNCTION__, i);
1681 i);
1682#endif
1683 } 1551 }
1684 usb_kill_urb(context->fifos[i].urb); 1552 usb_kill_urb(context->fifos[i].urb);
1685 usb_free_urb(context->fifos[i].urb); 1553 usb_free_urb(context->fifos[i].urb);
@@ -1692,34 +1560,29 @@ hfc_usb_disconnect(struct usb_interface
1692 context->ctrl_urb = NULL; 1560 context->ctrl_urb = NULL;
1693 hisax_unregister(&context->d_if); 1561 hisax_unregister(&context->d_if);
1694 kfree(context); /* free our structure again */ 1562 kfree(context); /* free our structure again */
1695} /* hfc_usb_disconnect */ 1563}
1696 1564
1697/************************************/
1698/* our driver information structure */
1699/************************************/
1700static struct usb_driver hfc_drv = { 1565static struct usb_driver hfc_drv = {
1701 .name = "hfc_usb", 1566 .name = "hfc_usb",
1702 .id_table = hfcusb_idtab, 1567 .id_table = hfcusb_idtab,
1703 .probe = hfc_usb_probe, 1568 .probe = hfc_usb_probe,
1704 .disconnect = hfc_usb_disconnect, 1569 .disconnect = hfc_usb_disconnect,
1705}; 1570};
1571
1706static void __exit 1572static void __exit
1707hfc_usb_exit(void) 1573hfc_usb_mod_exit(void)
1708{ 1574{
1709#ifdef CONFIG_HISAX_DEBUG 1575 usb_deregister(&hfc_drv); /* release our driver */
1710 DBG(USB_DBG, "HFC-S USB: calling \"hfc_usb_exit\" ...");
1711#endif
1712 usb_deregister(&hfc_drv); /* release our driver */
1713 printk(KERN_INFO "HFC-S USB: module removed\n"); 1576 printk(KERN_INFO "HFC-S USB: module removed\n");
1714} 1577}
1715 1578
1716static int __init 1579static int __init
1717hfc_usb_init(void) 1580hfc_usb_mod_init(void)
1718{ 1581{
1582 char revstr[30], datestr[30], dummy[30];
1719#ifndef CONFIG_HISAX_DEBUG 1583#ifndef CONFIG_HISAX_DEBUG
1720 unsigned int debug = -1; 1584 hfc_debug = debug;
1721#endif 1585#endif
1722 char revstr[30], datestr[30], dummy[30];
1723 sscanf(hfcusb_revision, 1586 sscanf(hfcusb_revision,
1724 "%s %s $ %s %s %s $ ", dummy, revstr, 1587 "%s %s $ %s %s %s $ ", dummy, revstr,
1725 dummy, datestr, dummy); 1588 dummy, datestr, dummy);
@@ -1734,8 +1597,8 @@ hfc_usb_init(void)
1734 return (0); 1597 return (0);
1735} 1598}
1736 1599
1737module_init(hfc_usb_init); 1600module_init(hfc_usb_mod_init);
1738module_exit(hfc_usb_exit); 1601module_exit(hfc_usb_mod_exit);
1739MODULE_AUTHOR(DRIVER_AUTHOR); 1602MODULE_AUTHOR(DRIVER_AUTHOR);
1740MODULE_DESCRIPTION(DRIVER_DESC); 1603MODULE_DESCRIPTION(DRIVER_DESC);
1741MODULE_LICENSE("GPL"); 1604MODULE_LICENSE("GPL");
diff --git a/drivers/isdn/hisax/hfc_usb.h b/drivers/isdn/hisax/hfc_usb.h
index 471f2354dfde..e79f56568d30 100644
--- a/drivers/isdn/hisax/hfc_usb.h
+++ b/drivers/isdn/hisax/hfc_usb.h
@@ -1,8 +1,8 @@
1/* 1/*
2* hfc_usb.h 2 * hfc_usb.h
3* 3 *
4* $Id: hfc_usb.h,v 4.2 2005/04/07 15:27:17 martinb1 Exp $ 4 * $Id: hfc_usb.h,v 1.1.2.5 2007/08/20 14:36:03 mbachem Exp $
5*/ 5 */
6 6
7#ifndef __HFC_USB_H__ 7#ifndef __HFC_USB_H__
8#define __HFC_USB_H__ 8#define __HFC_USB_H__
@@ -10,25 +10,20 @@
10#define DRIVER_AUTHOR "Peter Sprenger (sprenger@moving-byters.de)" 10#define DRIVER_AUTHOR "Peter Sprenger (sprenger@moving-byters.de)"
11#define DRIVER_DESC "HFC-S USB based HiSAX ISDN driver" 11#define DRIVER_DESC "HFC-S USB based HiSAX ISDN driver"
12 12
13#define VERBOSE_USB_DEBUG
14 13
14#define HFC_CTRL_TIMEOUT 20 /* 5ms timeout writing/reading regs */
15#define HFC_TIMER_T3 8000 /* timeout for l1 activation timer */
16#define HFC_TIMER_T4 500 /* time for state change interval */
15 17
16/***********/ 18#define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */
17/* defines */ 19#define HFCUSB_L1_DRX 1 /* D-frame received */
18/***********/ 20#define HFCUSB_L1_ERX 2 /* E-frame received */
19#define HFC_CTRL_TIMEOUT 20 /* 5ms timeout writing/reading regs */ 21#define HFCUSB_L1_DTX 4 /* D-frames completed */
20#define HFC_TIMER_T3 8000 /* timeout for l1 activation timer */
21#define HFC_TIMER_T4 500 /* time for state change interval */
22 22
23#define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */ 23#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */
24#define HFCUSB_L1_DRX 1 /* D-frame received */
25#define HFCUSB_L1_ERX 2 /* E-frame received */
26#define HFCUSB_L1_DTX 4 /* D-frames completed */
27 24
28#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */ 25#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */
29 26#define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */
30#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */
31#define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */
32 27
33#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */ 28#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */
34#define HFCUSB_CIRM 0x00 /* cirm register index */ 29#define HFCUSB_CIRM 0x00 /* cirm register index */
@@ -52,9 +47,8 @@
52 47
53#define HFCUSB_CHIPID 0x40 /* ID value of HFC-S USB */ 48#define HFCUSB_CHIPID 0x40 /* ID value of HFC-S USB */
54 49
55/******************/ 50
56/* fifo registers */ 51/* fifo registers */
57/******************/
58#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */ 52#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */
59#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */ 53#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */
60#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */ 54#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */
@@ -66,9 +60,9 @@
66#define HFCUSB_PCM_RX 7 60#define HFCUSB_PCM_RX 7
67 61
68/* 62/*
69* used to switch snd_transfer_mode for different TA modes e.g. the Billion USB TA just 63 * used to switch snd_transfer_mode for different TA modes e.g. the Billion USB TA just
70* supports ISO out, while the Cologne Chip EVAL TA just supports BULK out 64 * supports ISO out, while the Cologne Chip EVAL TA just supports BULK out
71*/ 65 */
72#define USB_INT 0 66#define USB_INT 0
73#define USB_BULK 1 67#define USB_BULK 1
74#define USB_ISOC 2 68#define USB_ISOC 2
@@ -77,49 +71,36 @@
77#define ISOC_PACKETS_B 8 71#define ISOC_PACKETS_B 8
78#define ISO_BUFFER_SIZE 128 72#define ISO_BUFFER_SIZE 128
79 73
80// ISO send definitions 74/* Fifo flow Control for TX ISO */
81#define SINK_MAX 68 75#define SINK_MAX 68
82#define SINK_MIN 48 76#define SINK_MIN 48
83#define SINK_DMIN 12 77#define SINK_DMIN 12
84#define SINK_DMAX 18 78#define SINK_DMAX 18
85#define BITLINE_INF (-64*8) 79#define BITLINE_INF (-64*8)
86 80
87 81/* HFC-S USB register access by Control-URSs */
88/**********/
89/* macros */
90/**********/
91#define write_usb(a,b,c)usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),NULL,0,HFC_CTRL_TIMEOUT) 82#define write_usb(a,b,c)usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),NULL,0,HFC_CTRL_TIMEOUT)
92#define read_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT) 83#define read_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT)
93
94
95/*******************/
96/* Debugging Flags */
97/*******************/
98#define USB_DBG 1
99#define ISDN_DBG 2
100
101
102/* *********************/
103/* USB related defines */
104/***********************/
105#define HFC_CTRL_BUFSIZE 32 84#define HFC_CTRL_BUFSIZE 32
106 85
107
108
109/*************************************************/
110/* entry and size of output/input control buffer */ 86/* entry and size of output/input control buffer */
111/*************************************************/
112typedef struct { 87typedef struct {
113 __u8 hfc_reg; /* register number */ 88 __u8 hfc_reg; /* register number */
114 __u8 reg_val; /* value to be written (or read) */ 89 __u8 reg_val; /* value to be written (or read) */
115 int action; /* data for action handler */ 90 int action; /* data for action handler */
116} ctrl_buft; 91} ctrl_buft;
117 92
93/* Debugging Flags */
94#define HFCUSB_DBG_INIT 0x0001
95#define HFCUSB_DBG_STATES 0x0002
96#define HFCUSB_DBG_DCHANNEL 0x0080
97#define HFCUSB_DBG_FIFO_ERR 0x4000
98#define HFCUSB_DBG_VERBOSE_USB 0x8000
118 99
119/********************/ 100/*
120/* URB error codes: */ 101 * URB error codes:
121/********************/ 102 * Used to represent a list of values and their respective symbolic names
122/* Used to represent a list of values and their respective symbolic names */ 103 */
123struct hfcusb_symbolic_list { 104struct hfcusb_symbolic_list {
124 const int num; 105 const int num;
125 const char *name; 106 const char *name;
@@ -134,20 +115,20 @@ static struct hfcusb_symbolic_list urb_errlist[] = {
134 {-ENXIO, "URB already queued"}, 115 {-ENXIO, "URB already queued"},
135 {-EFBIG, "Too much ISO frames requested"}, 116 {-EFBIG, "Too much ISO frames requested"},
136 {-ENOSR, "Buffer error (overrun)"}, 117 {-ENOSR, "Buffer error (overrun)"},
137 {-EPIPE, "Specified endpoint is stalled"}, 118 {-EPIPE, "Specified endpoint is stalled (device not responding)"},
138 {-EOVERFLOW, "Babble (bad cable?)"}, 119 {-EOVERFLOW, "Babble (bad cable?)"},
139 {-EPROTO, "Bit-stuff error (bad cable?)"}, 120 {-EPROTO, "Bit-stuff error (bad cable?)"},
140 {-EILSEQ, "CRC or missing token"}, 121 {-EILSEQ, "CRC/Timeout"},
141 {-ETIME, "Device did not respond"}, 122 {-ETIMEDOUT, "NAK (device does not respond)"},
142 {-ESHUTDOWN, "Device unplugged"}, 123 {-ESHUTDOWN, "Device unplugged"},
143 {-1, NULL} 124 {-1, NULL}
144}; 125};
145 126
146 127
147/*****************************************************/ 128/*
148/* device dependant information to support different */ 129 * device dependant information to support different
149/* ISDN Ta's using the HFC-S USB chip */ 130 * ISDN Ta's using the HFC-S USB chip
150/*****************************************************/ 131 */
151 132
152/* USB descriptor need to contain one of the following EndPoint combination: */ 133/* USB descriptor need to contain one of the following EndPoint combination: */
153#define CNF_4INT3ISO 1 // 4 INT IN, 3 ISO OUT 134#define CNF_4INT3ISO 1 // 4 INT IN, 3 ISO OUT
@@ -155,16 +136,19 @@ static struct hfcusb_symbolic_list urb_errlist[] = {
155#define CNF_4ISO3ISO 3 // 4 ISO IN, 3 ISO OUT 136#define CNF_4ISO3ISO 3 // 4 ISO IN, 3 ISO OUT
156#define CNF_3ISO3ISO 4 // 3 ISO IN, 3 ISO OUT 137#define CNF_3ISO3ISO 4 // 3 ISO IN, 3 ISO OUT
157 138
158#define EP_NUL 1 // Endpoint at this position not allowed 139#define EP_NUL 1 // Endpoint at this position not allowed
159#define EP_NOP 2 // all type of endpoints allowed at this position 140#define EP_NOP 2 // all type of endpoints allowed at this position
160#define EP_ISO 3 // Isochron endpoint mandatory at this position 141#define EP_ISO 3 // Isochron endpoint mandatory at this position
161#define EP_BLK 4 // Bulk endpoint mandatory at this position 142#define EP_BLK 4 // Bulk endpoint mandatory at this position
162#define EP_INT 5 // Interrupt endpoint mandatory at this position 143#define EP_INT 5 // Interrupt endpoint mandatory at this position
163 144
164/* this array represents all endpoints possible in the HCF-USB the last 145/*
165* 3 entries are the configuration number, the minimum interval for 146 * List of all supported endpoint configuration sets, used to find the
166* Interrupt endpoints & boolean if E-channel logging possible 147 * best matching endpoint configuration within a devices' USB descriptor.
167*/ 148 * We need at least 3 RX endpoints, and 3 TX endpoints, either
149 * INT-in and ISO-out, or ISO-in and ISO-out)
150 * with 4 RX endpoints even E-Channel logging is possible
151 */
168static int validconf[][19] = { 152static int validconf[][19] = {
169 // INT in, ISO out config 153 // INT in, ISO out config
170 {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NOP, EP_INT, 154 {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NOP, EP_INT,
@@ -193,7 +177,6 @@ static char *conf_str[] = {
193}; 177};
194#endif 178#endif
195 179
196
197typedef struct { 180typedef struct {
198 int vendor; // vendor id 181 int vendor; // vendor id
199 int prod_id; // product id 182 int prod_id; // product id
@@ -202,9 +185,9 @@ typedef struct {
202 signed short led_bits[8]; // array of 8 possible LED bitmask settings 185 signed short led_bits[8]; // array of 8 possible LED bitmask settings
203} vendor_data; 186} vendor_data;
204 187
205#define LED_OFF 0 // no LED support 188#define LED_OFF 0 // no LED support
206#define LED_SCHEME1 1 // LED standard scheme 189#define LED_SCHEME1 1 // LED standard scheme
207#define LED_SCHEME2 2 // not used yet... 190#define LED_SCHEME2 2 // not used yet...
208 191
209#define LED_POWER_ON 1 192#define LED_POWER_ON 1
210#define LED_POWER_OFF 2 193#define LED_POWER_OFF 2
@@ -217,11 +200,8 @@ typedef struct {
217#define LED_B2_OFF 9 200#define LED_B2_OFF 9
218#define LED_B2_DATA 10 201#define LED_B2_DATA 10
219 202
220#define LED_NORMAL 0 // LEDs are normal 203#define LED_NORMAL 0 // LEDs are normal
221#define LED_INVERTED 1 // LEDs are inverted 204#define LED_INVERTED 1 // LEDs are inverted
222
223/* time in ms to perform a Flashing LED when B-Channel has traffic */
224#define LED_TIME 250
225 205
226 206
227#endif // __HFC_USB_H__ 207#endif // __HFC_USB_H__
diff --git a/drivers/isdn/i4l/isdn_bsdcomp.c b/drivers/isdn/i4l/isdn_bsdcomp.c
index 90a23795db7e..02d9918705dd 100644
--- a/drivers/isdn/i4l/isdn_bsdcomp.c
+++ b/drivers/isdn/i4l/isdn_bsdcomp.c
@@ -341,7 +341,7 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data)
341 * Allocate space for the dictionary. This may be more than one page in 341 * Allocate space for the dictionary. This may be more than one page in
342 * length. 342 * length.
343 */ 343 */
344 db->dict = (struct bsd_dict *) vmalloc (hsize * sizeof (struct bsd_dict)); 344 db->dict = vmalloc(hsize * sizeof(struct bsd_dict));
345 if (!db->dict) { 345 if (!db->dict) {
346 bsd_free (db); 346 bsd_free (db);
347 return NULL; 347 return NULL;
@@ -354,8 +354,7 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data)
354 if (!decomp) 354 if (!decomp)
355 db->lens = NULL; 355 db->lens = NULL;
356 else { 356 else {
357 db->lens = (unsigned short *) vmalloc ((maxmaxcode + 1) * 357 db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0]));
358 sizeof (db->lens[0]));
359 if (!db->lens) { 358 if (!db->lens) {
360 bsd_free (db); 359 bsd_free (db);
361 return (NULL); 360 return (NULL);
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index c97330b19877..ec5f4046412f 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -2291,7 +2291,7 @@ static int __init isdn_init(void)
2291 int i; 2291 int i;
2292 char tmprev[50]; 2292 char tmprev[50];
2293 2293
2294 if (!(dev = (isdn_dev *) vmalloc(sizeof(isdn_dev)))) { 2294 if (!(dev = vmalloc(sizeof(isdn_dev)))) {
2295 printk(KERN_WARNING "isdn: Could not allocate device-struct.\n"); 2295 printk(KERN_WARNING "isdn: Could not allocate device-struct.\n");
2296 return -EIO; 2296 return -EIO;
2297 } 2297 }
diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig
index 6cecc396e040..7b64fd4aa2f3 100644
--- a/drivers/kvm/Kconfig
+++ b/drivers/kvm/Kconfig
@@ -5,6 +5,11 @@ menuconfig VIRTUALIZATION
5 bool "Virtualization" 5 bool "Virtualization"
6 depends on X86 6 depends on X86
7 default y 7 default y
8 ---help---
9 Say Y here to get to see options for virtualization guest drivers.
10 This option alone does not add any kernel code.
11
12 If you say N, all options in this submenu will be skipped and disabled.
8 13
9if VIRTUALIZATION 14if VIRTUALIZATION
10 15
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 96856097d15b..cd0557954e50 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -2974,6 +2974,10 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val,
2974 switch (val) { 2974 switch (val) {
2975 case CPU_DYING: 2975 case CPU_DYING:
2976 case CPU_DYING_FROZEN: 2976 case CPU_DYING_FROZEN:
2977 printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n",
2978 cpu);
2979 hardware_disable(NULL);
2980 break;
2977 case CPU_UP_CANCELED: 2981 case CPU_UP_CANCELED:
2978 case CPU_UP_CANCELED_FROZEN: 2982 case CPU_UP_CANCELED_FROZEN:
2979 printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n", 2983 printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n",
diff --git a/drivers/lguest/Kconfig b/drivers/lguest/Kconfig
index fd6925f41647..41e2250613a1 100644
--- a/drivers/lguest/Kconfig
+++ b/drivers/lguest/Kconfig
@@ -1,6 +1,6 @@
1config LGUEST 1config LGUEST
2 tristate "Linux hypervisor example code" 2 tristate "Linux hypervisor example code"
3 depends on X86 && PARAVIRT && EXPERIMENTAL && !X86_PAE 3 depends on X86 && PARAVIRT && EXPERIMENTAL && !X86_PAE && FUTEX
4 select LGUEST_GUEST 4 select LGUEST_GUEST
5 select HVC_DRIVER 5 select HVC_DRIVER
6 ---help--- 6 ---help---
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index dbe96268866e..56cd8998fe4b 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -3,6 +3,11 @@ menuconfig MACINTOSH_DRIVERS
3 bool "Macintosh device drivers" 3 bool "Macintosh device drivers"
4 depends on PPC || MAC || X86 4 depends on PPC || MAC || X86
5 default y if (PPC_PMAC || MAC) 5 default y if (PPC_PMAC || MAC)
6 ---help---
7 Say Y here to get to see options for devices used with Macintosh
8 computers. This option alone does not add any kernel code.
9
10 If you say N, all options in this submenu will be skipped and disabled.
6 11
7if MACINTOSH_DRIVERS 12if MACINTOSH_DRIVERS
8 13
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index bc77c5e2ca9f..5c742a526082 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -89,7 +89,7 @@ static int sleepy_trackpad;
89static int autopoll_devs; 89static int autopoll_devs;
90int __adb_probe_sync; 90int __adb_probe_sync;
91 91
92#ifdef CONFIG_PM 92#ifdef CONFIG_PM_SLEEP
93static void adb_notify_sleep(struct pmu_sleep_notifier *self, int when); 93static void adb_notify_sleep(struct pmu_sleep_notifier *self, int when);
94static struct pmu_sleep_notifier adb_sleep_notifier = { 94static struct pmu_sleep_notifier adb_sleep_notifier = {
95 adb_notify_sleep, 95 adb_notify_sleep,
@@ -313,7 +313,7 @@ int __init adb_init(void)
313 printk(KERN_WARNING "Warning: no ADB interface detected\n"); 313 printk(KERN_WARNING "Warning: no ADB interface detected\n");
314 adb_controller = NULL; 314 adb_controller = NULL;
315 } else { 315 } else {
316#ifdef CONFIG_PM 316#ifdef CONFIG_PM_SLEEP
317 pmu_register_sleep_notifier(&adb_sleep_notifier); 317 pmu_register_sleep_notifier(&adb_sleep_notifier);
318#endif /* CONFIG_PM */ 318#endif /* CONFIG_PM */
319#ifdef CONFIG_PPC 319#ifdef CONFIG_PPC
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
index 76c1e8e4a487..33dee3a773ed 100644
--- a/drivers/macintosh/mac_hid.c
+++ b/drivers/macintosh/mac_hid.c
@@ -13,6 +13,7 @@
13#include <linux/sysctl.h> 13#include <linux/sysctl.h>
14#include <linux/input.h> 14#include <linux/input.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/kbd_kern.h>
16 17
17 18
18static struct input_dev *emumousebtn; 19static struct input_dev *emumousebtn;
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 5eee480245f3..f7c509b7a8ea 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -152,10 +152,10 @@ static spinlock_t pmu_lock;
152static u8 pmu_intr_mask; 152static u8 pmu_intr_mask;
153static int pmu_version; 153static int pmu_version;
154static int drop_interrupts; 154static int drop_interrupts;
155#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 155#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
156static int option_lid_wakeup = 1; 156static int option_lid_wakeup = 1;
157#endif /* CONFIG_PM && CONFIG_PPC32 */ 157#endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
158#if (defined(CONFIG_PM)&&defined(CONFIG_PPC32))||defined(CONFIG_PMAC_BACKLIGHT_LEGACY) 158#if (defined(CONFIG_PM_SLEEP)&&defined(CONFIG_PPC32))||defined(CONFIG_PMAC_BACKLIGHT_LEGACY)
159static int sleep_in_progress; 159static int sleep_in_progress;
160#endif 160#endif
161static unsigned long async_req_locks; 161static unsigned long async_req_locks;
@@ -875,7 +875,7 @@ proc_read_options(char *page, char **start, off_t off,
875{ 875{
876 char *p = page; 876 char *p = page;
877 877
878#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 878#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
879 if (pmu_kind == PMU_KEYLARGO_BASED && 879 if (pmu_kind == PMU_KEYLARGO_BASED &&
880 pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0) 880 pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0)
881 p += sprintf(p, "lid_wakeup=%d\n", option_lid_wakeup); 881 p += sprintf(p, "lid_wakeup=%d\n", option_lid_wakeup);
@@ -916,7 +916,7 @@ proc_write_options(struct file *file, const char __user *buffer,
916 *(val++) = 0; 916 *(val++) = 0;
917 while(*val == ' ') 917 while(*val == ' ')
918 val++; 918 val++;
919#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 919#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
920 if (pmu_kind == PMU_KEYLARGO_BASED && 920 if (pmu_kind == PMU_KEYLARGO_BASED &&
921 pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0) 921 pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0)
922 if (!strcmp(label, "lid_wakeup")) 922 if (!strcmp(label, "lid_wakeup"))
@@ -1738,7 +1738,7 @@ pmu_present(void)
1738 return via != 0; 1738 return via != 0;
1739} 1739}
1740 1740
1741#ifdef CONFIG_PM 1741#ifdef CONFIG_PM_SLEEP
1742 1742
1743static LIST_HEAD(sleep_notifiers); 1743static LIST_HEAD(sleep_notifiers);
1744 1744
@@ -1769,9 +1769,9 @@ pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* n)
1769 return 0; 1769 return 0;
1770} 1770}
1771EXPORT_SYMBOL(pmu_unregister_sleep_notifier); 1771EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
1772#endif /* CONFIG_PM */ 1772#endif /* CONFIG_PM_SLEEP */
1773 1773
1774#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 1774#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
1775 1775
1776/* Sleep is broadcast last-to-first */ 1776/* Sleep is broadcast last-to-first */
1777static void broadcast_sleep(int when) 1777static void broadcast_sleep(int when)
@@ -2390,7 +2390,7 @@ powerbook_sleep_3400(void)
2390 return 0; 2390 return 0;
2391} 2391}
2392 2392
2393#endif /* CONFIG_PM && CONFIG_PPC32 */ 2393#endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
2394 2394
2395/* 2395/*
2396 * Support for /dev/pmu device 2396 * Support for /dev/pmu device
@@ -2573,7 +2573,7 @@ pmu_ioctl(struct inode * inode, struct file *filp,
2573 int error = -EINVAL; 2573 int error = -EINVAL;
2574 2574
2575 switch (cmd) { 2575 switch (cmd) {
2576#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 2576#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
2577 case PMU_IOC_SLEEP: 2577 case PMU_IOC_SLEEP:
2578 if (!capable(CAP_SYS_ADMIN)) 2578 if (!capable(CAP_SYS_ADMIN))
2579 return -EACCES; 2579 return -EACCES;
@@ -2601,7 +2601,7 @@ pmu_ioctl(struct inode * inode, struct file *filp,
2601 return put_user(0, argp); 2601 return put_user(0, argp);
2602 else 2602 else
2603 return put_user(1, argp); 2603 return put_user(1, argp);
2604#endif /* CONFIG_PM && CONFIG_PPC32 */ 2604#endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
2605 2605
2606#ifdef CONFIG_PMAC_BACKLIGHT_LEGACY 2606#ifdef CONFIG_PMAC_BACKLIGHT_LEGACY
2607 /* Compatibility ioctl's for backlight */ 2607 /* Compatibility ioctl's for backlight */
@@ -2757,7 +2757,7 @@ pmu_polled_request(struct adb_request *req)
2757 * to do suspend-to-disk. 2757 * to do suspend-to-disk.
2758 */ 2758 */
2759 2759
2760#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 2760#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
2761 2761
2762int pmu_sys_suspended; 2762int pmu_sys_suspended;
2763 2763
@@ -2792,7 +2792,7 @@ static int pmu_sys_resume(struct sys_device *sysdev)
2792 return 0; 2792 return 0;
2793} 2793}
2794 2794
2795#endif /* CONFIG_PM && CONFIG_PPC32 */ 2795#endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
2796 2796
2797static struct sysdev_class pmu_sysclass = { 2797static struct sysdev_class pmu_sysclass = {
2798 set_kset_name("pmu"), 2798 set_kset_name("pmu"),
@@ -2803,10 +2803,10 @@ static struct sys_device device_pmu = {
2803}; 2803};
2804 2804
2805static struct sysdev_driver driver_pmu = { 2805static struct sysdev_driver driver_pmu = {
2806#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 2806#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
2807 .suspend = &pmu_sys_suspend, 2807 .suspend = &pmu_sys_suspend,
2808 .resume = &pmu_sys_resume, 2808 .resume = &pmu_sys_resume,
2809#endif /* CONFIG_PM && CONFIG_PPC32 */ 2809#endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
2810}; 2810};
2811 2811
2812static int __init init_pmu_sysfs(void) 2812static int __init init_pmu_sysfs(void)
@@ -2841,10 +2841,10 @@ EXPORT_SYMBOL(pmu_wait_complete);
2841EXPORT_SYMBOL(pmu_suspend); 2841EXPORT_SYMBOL(pmu_suspend);
2842EXPORT_SYMBOL(pmu_resume); 2842EXPORT_SYMBOL(pmu_resume);
2843EXPORT_SYMBOL(pmu_unlock); 2843EXPORT_SYMBOL(pmu_unlock);
2844#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 2844#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
2845EXPORT_SYMBOL(pmu_enable_irled); 2845EXPORT_SYMBOL(pmu_enable_irled);
2846EXPORT_SYMBOL(pmu_battery_count); 2846EXPORT_SYMBOL(pmu_battery_count);
2847EXPORT_SYMBOL(pmu_batteries); 2847EXPORT_SYMBOL(pmu_batteries);
2848EXPORT_SYMBOL(pmu_power_flags); 2848EXPORT_SYMBOL(pmu_power_flags);
2849#endif /* CONFIG_PM && CONFIG_PPC32 */ 2849#endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
2850 2850
diff --git a/drivers/macintosh/via-pmu68k.c b/drivers/macintosh/via-pmu68k.c
index dfdf11c1eec4..e2f84da09e7c 100644
--- a/drivers/macintosh/via-pmu68k.c
+++ b/drivers/macintosh/via-pmu68k.c
@@ -818,243 +818,3 @@ pmu_present(void)
818{ 818{
819 return (pmu_kind != PMU_UNKNOWN); 819 return (pmu_kind != PMU_UNKNOWN);
820} 820}
821
822#if 0 /* needs some work for 68K */
823
824/*
825 * This struct is used to store config register values for
826 * PCI devices which may get powered off when we sleep.
827 */
828static struct pci_save {
829 u16 command;
830 u16 cache_lat;
831 u16 intr;
832} *pbook_pci_saves;
833static int n_pbook_pci_saves;
834
835static inline void
836pbook_pci_save(void)
837{
838 int npci;
839 struct pci_dev *pd = NULL;
840 struct pci_save *ps;
841
842 npci = 0;
843 while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL)
844 ++npci;
845 n_pbook_pci_saves = npci;
846 if (npci == 0)
847 return;
848 ps = kmalloc(npci * sizeof(*ps), GFP_KERNEL);
849 pbook_pci_saves = ps;
850 if (ps == NULL)
851 return;
852
853 pd = NULL;
854 while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
855 pci_read_config_word(pd, PCI_COMMAND, &ps->command);
856 pci_read_config_word(pd, PCI_CACHE_LINE_SIZE, &ps->cache_lat);
857 pci_read_config_word(pd, PCI_INTERRUPT_LINE, &ps->intr);
858 ++ps;
859 --npci;
860 }
861}
862
863static inline void
864pbook_pci_restore(void)
865{
866 u16 cmd;
867 struct pci_save *ps = pbook_pci_saves;
868 struct pci_dev *pd = NULL;
869 int j;
870
871 while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
872 if (ps->command == 0)
873 continue;
874 pci_read_config_word(pd, PCI_COMMAND, &cmd);
875 if ((ps->command & ~cmd) == 0)
876 continue;
877 switch (pd->hdr_type) {
878 case PCI_HEADER_TYPE_NORMAL:
879 for (j = 0; j < 6; ++j)
880 pci_write_config_dword(pd,
881 PCI_BASE_ADDRESS_0 + j*4,
882 pd->resource[j].start);
883 pci_write_config_dword(pd, PCI_ROM_ADDRESS,
884 pd->resource[PCI_ROM_RESOURCE].start);
885 pci_write_config_word(pd, PCI_CACHE_LINE_SIZE,
886 ps->cache_lat);
887 pci_write_config_word(pd, PCI_INTERRUPT_LINE,
888 ps->intr);
889 pci_write_config_word(pd, PCI_COMMAND, ps->command);
890 break;
891 /* other header types not restored at present */
892 }
893 }
894}
895
896/*
897 * Put the powerbook to sleep.
898 */
899#define IRQ_ENABLE ((unsigned int *)0xf3000024)
900#define MEM_CTRL ((unsigned int *)0xf8000070)
901
902int powerbook_sleep(void)
903{
904 int ret, i, x;
905 static int save_backlight;
906 static unsigned int save_irqen;
907 unsigned long msr;
908 unsigned int hid0;
909 unsigned long p, wait;
910 struct adb_request sleep_req;
911
912 /* Notify device drivers */
913 ret = blocking_notifier_call_chain(&sleep_notifier_list,
914 PBOOK_SLEEP, NULL);
915 if (ret & NOTIFY_STOP_MASK)
916 return -EBUSY;
917
918 /* Sync the disks. */
919 /* XXX It would be nice to have some way to ensure that
920 * nobody is dirtying any new buffers while we wait. */
921 sys_sync();
922
923 /* Turn off the display backlight */
924 save_backlight = backlight_enabled;
925 if (save_backlight)
926 pmu_enable_backlight(0);
927
928 /* Give the disks a little time to actually finish writing */
929 for (wait = jiffies + (HZ/4); time_before(jiffies, wait); )
930 mb();
931
932 /* Disable all interrupts except pmu */
933 save_irqen = in_le32(IRQ_ENABLE);
934 for (i = 0; i < 32; ++i)
935 if (i != vias->intrs[0].line && (save_irqen & (1 << i)))
936 disable_irq(i);
937 asm volatile("mtdec %0" : : "r" (0x7fffffff));
938
939 /* Save the state of PCI config space for some slots */
940 pbook_pci_save();
941
942 /* Set the memory controller to keep the memory refreshed
943 while we're asleep */
944 for (i = 0x403f; i >= 0x4000; --i) {
945 out_be32(MEM_CTRL, i);
946 do {
947 x = (in_be32(MEM_CTRL) >> 16) & 0x3ff;
948 } while (x == 0);
949 if (x >= 0x100)
950 break;
951 }
952
953 /* Ask the PMU to put us to sleep */
954 pmu_request(&sleep_req, NULL, 5, PMU_SLEEP, 'M', 'A', 'T', 'T');
955 while (!sleep_req.complete)
956 mb();
957 /* displacement-flush the L2 cache - necessary? */
958 for (p = KERNELBASE; p < KERNELBASE + 0x100000; p += 0x1000)
959 i = *(volatile int *)p;
960 asleep = 1;
961
962 /* Put the CPU into sleep mode */
963 asm volatile("mfspr %0,1008" : "=r" (hid0) :);
964 hid0 = (hid0 & ~(HID0_NAP | HID0_DOZE)) | HID0_SLEEP;
965 asm volatile("mtspr 1008,%0" : : "r" (hid0));
966 local_save_flags(msr);
967 msr |= MSR_POW | MSR_EE;
968 local_irq_restore(msr);
969 udelay(10);
970
971 /* OK, we're awake again, start restoring things */
972 out_be32(MEM_CTRL, 0x3f);
973 pbook_pci_restore();
974
975 /* wait for the PMU interrupt sequence to complete */
976 while (asleep)
977 mb();
978
979 /* reenable interrupts */
980 for (i = 0; i < 32; ++i)
981 if (i != vias->intrs[0].line && (save_irqen & (1 << i)))
982 enable_irq(i);
983
984 /* Notify drivers */
985 blocking_notifier_call_chain(&sleep_notifier_list, PBOOK_WAKE, NULL);
986
987 /* reenable ADB autopoll */
988 pmu_adb_autopoll(adb_dev_map);
989
990 /* Turn on the screen backlight, if it was on before */
991 if (save_backlight)
992 pmu_enable_backlight(1);
993
994 /* Wait for the hard disk to spin up */
995
996 return 0;
997}
998
999/*
1000 * Support for /dev/pmu device
1001 */
1002static int pmu_open(struct inode *inode, struct file *file)
1003{
1004 return 0;
1005}
1006
1007static ssize_t pmu_read(struct file *file, char *buf,
1008 size_t count, loff_t *ppos)
1009{
1010 return 0;
1011}
1012
1013static ssize_t pmu_write(struct file *file, const char *buf,
1014 size_t count, loff_t *ppos)
1015{
1016 return 0;
1017}
1018
1019static int pmu_ioctl(struct inode * inode, struct file *filp,
1020 u_int cmd, u_long arg)
1021{
1022 int error;
1023 __u32 value;
1024
1025 switch (cmd) {
1026 case PMU_IOC_SLEEP:
1027 return -ENOSYS;
1028 case PMU_IOC_GET_BACKLIGHT:
1029 return put_user(backlight_level, (__u32 *)arg);
1030 case PMU_IOC_SET_BACKLIGHT:
1031 error = get_user(value, (__u32 *)arg);
1032 if (!error)
1033 pmu_set_brightness(value);
1034 return error;
1035 case PMU_IOC_GET_MODEL:
1036 return put_user(pmu_kind, (__u32 *)arg);
1037 }
1038 return -EINVAL;
1039}
1040
1041static const struct file_operations pmu_device_fops = {
1042 .read = pmu_read,
1043 .write = pmu_write,
1044 .ioctl = pmu_ioctl,
1045 .open = pmu_open,
1046};
1047
1048static struct miscdevice pmu_device = {
1049 PMU_MINOR, "pmu", &pmu_device_fops
1050};
1051
1052void pmu_device_init(void)
1053{
1054 if (!via)
1055 return;
1056 if (misc_register(&pmu_device) < 0)
1057 printk(KERN_ERR "via-pmu68k: cannot register misc device.\n");
1058}
1059#endif /* CONFIG_PMAC_PBOOK */
1060
diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig
index 531d4d17d011..34a8c60a254a 100644
--- a/drivers/md/Kconfig
+++ b/drivers/md/Kconfig
@@ -263,7 +263,7 @@ config DM_MULTIPATH_EMC
263 263
264config DM_MULTIPATH_RDAC 264config DM_MULTIPATH_RDAC
265 tristate "LSI/Engenio RDAC multipath support (EXPERIMENTAL)" 265 tristate "LSI/Engenio RDAC multipath support (EXPERIMENTAL)"
266 depends on DM_MULTIPATH && BLK_DEV_DM && EXPERIMENTAL 266 depends on DM_MULTIPATH && BLK_DEV_DM && SCSI && EXPERIMENTAL
267 ---help--- 267 ---help---
268 Multipath support for LSI/Engenio RDAC. 268 Multipath support for LSI/Engenio RDAC.
269 269
diff --git a/drivers/md/dm-mpath-rdac.c b/drivers/md/dm-mpath-rdac.c
index 8b776b8cb7f7..16b161345775 100644
--- a/drivers/md/dm-mpath-rdac.c
+++ b/drivers/md/dm-mpath-rdac.c
@@ -292,7 +292,7 @@ static struct request *get_rdac_req(struct rdac_handler *h,
292 rq->end_io_data = h; 292 rq->end_io_data = h;
293 rq->timeout = h->timeout; 293 rq->timeout = h->timeout;
294 rq->cmd_type = REQ_TYPE_BLOCK_PC; 294 rq->cmd_type = REQ_TYPE_BLOCK_PC;
295 rq->cmd_flags = REQ_FAILFAST | REQ_NOMERGE; 295 rq->cmd_flags |= REQ_FAILFAST | REQ_NOMERGE;
296 return rq; 296 return rq;
297} 297}
298 298
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 650991bddd8e..f33a729960ca 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1972,7 +1972,8 @@ static int run(mddev_t *mddev)
1972 !test_bit(In_sync, &disk->rdev->flags)) { 1972 !test_bit(In_sync, &disk->rdev->flags)) {
1973 disk->head_position = 0; 1973 disk->head_position = 0;
1974 mddev->degraded++; 1974 mddev->degraded++;
1975 conf->fullsync = 1; 1975 if (disk->rdev)
1976 conf->fullsync = 1;
1976 } 1977 }
1977 } 1978 }
1978 if (mddev->degraded == conf->raid_disks) { 1979 if (mddev->degraded == conf->raid_disks) {
@@ -2153,11 +2154,25 @@ static int raid1_reshape(mddev_t *mddev)
2153 oldpool = conf->r1bio_pool; 2154 oldpool = conf->r1bio_pool;
2154 conf->r1bio_pool = newpool; 2155 conf->r1bio_pool = newpool;
2155 2156
2156 for (d=d2=0; d < conf->raid_disks; d++) 2157 for (d = d2 = 0; d < conf->raid_disks; d++) {
2157 if (conf->mirrors[d].rdev) { 2158 mdk_rdev_t *rdev = conf->mirrors[d].rdev;
2158 conf->mirrors[d].rdev->raid_disk = d2; 2159 if (rdev && rdev->raid_disk != d2) {
2159 newmirrors[d2++].rdev = conf->mirrors[d].rdev; 2160 char nm[20];
2161 sprintf(nm, "rd%d", rdev->raid_disk);
2162 sysfs_remove_link(&mddev->kobj, nm);
2163 rdev->raid_disk = d2;
2164 sprintf(nm, "rd%d", rdev->raid_disk);
2165 sysfs_remove_link(&mddev->kobj, nm);
2166 if (sysfs_create_link(&mddev->kobj,
2167 &rdev->kobj, nm))
2168 printk(KERN_WARNING
2169 "md/raid1: cannot register "
2170 "%s for %s\n",
2171 nm, mdname(mddev));
2160 } 2172 }
2173 if (rdev)
2174 newmirrors[d2++].rdev = rdev;
2175 }
2161 kfree(conf->mirrors); 2176 kfree(conf->mirrors);
2162 conf->mirrors = newmirrors; 2177 conf->mirrors = newmirrors;
2163 kfree(conf->poolinfo); 2178 kfree(conf->poolinfo);
diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c
index 02a0ea6e1c17..6bf858a436c9 100644
--- a/drivers/media/dvb/b2c2/flexcop-i2c.c
+++ b/drivers/media/dvb/b2c2/flexcop-i2c.c
@@ -135,6 +135,13 @@ static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs
135 struct flexcop_device *fc = i2c_get_adapdata(i2c_adap); 135 struct flexcop_device *fc = i2c_get_adapdata(i2c_adap);
136 int i, ret = 0; 136 int i, ret = 0;
137 137
138 /* Some drivers use 1 byte or 0 byte reads as probes, which this
139 * driver doesn't support. These probes will always fail, so this
140 * hack makes them always succeed. If one knew how, it would of
141 * course be better to actually do the read. */
142 if (num == 1 && msgs[0].flags == I2C_M_RD && msgs[0].len <= 1)
143 return 1;
144
138 if (mutex_lock_interruptible(&fc->i2c_mutex)) 145 if (mutex_lock_interruptible(&fc->i2c_mutex))
139 return -ERESTARTSYS; 146 return -ERESTARTSYS;
140 147
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index acf026342ec5..bdd797071cb0 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -800,7 +800,8 @@ static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len,
800} 800}
801 801
802 802
803static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len) 803static void dvb_net_sec(struct net_device *dev, const u8 *pkt, int
804pkt_len)
804{ 805{
805 u8 *eth; 806 u8 *eth;
806 struct sk_buff *skb; 807 struct sk_buff *skb;
@@ -902,7 +903,7 @@ static int dvb_net_sec_callback(const u8 *buffer1, size_t buffer1_len,
902 * we rely on the DVB API definition where exactly one complete 903 * we rely on the DVB API definition where exactly one complete
903 * section is delivered in buffer1 904 * section is delivered in buffer1
904 */ 905 */
905 dvb_net_sec (dev, (u8*) buffer1, buffer1_len); 906 dvb_net_sec (dev, buffer1, buffer1_len);
906 return 0; 907 return 0;
907} 908}
908 909
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index ca99e439c97c..11f7d5939bd9 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -784,7 +784,7 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr,
784 strncpy(fe->ops.tuner_ops.info.name, desc->name, 784 strncpy(fe->ops.tuner_ops.info.name, desc->name,
785 sizeof(fe->ops.tuner_ops.info.name)); 785 sizeof(fe->ops.tuner_ops.info.name));
786 fe->ops.tuner_ops.info.frequency_min = desc->min; 786 fe->ops.tuner_ops.info.frequency_min = desc->min;
787 fe->ops.tuner_ops.info.frequency_min = desc->max; 787 fe->ops.tuner_ops.info.frequency_max = desc->max;
788 if (!desc->initdata) 788 if (!desc->initdata)
789 fe->ops.tuner_ops.init = NULL; 789 fe->ops.tuner_ops.init = NULL;
790 if (!desc->sleepdata) 790 if (!desc->sleepdata)
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index c08f650df423..ef5361824f87 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -356,6 +356,7 @@ static int cafe_smbus_write_data(struct cafe_camera *cam,
356{ 356{
357 unsigned int rval; 357 unsigned int rval;
358 unsigned long flags; 358 unsigned long flags;
359 DEFINE_WAIT(the_wait);
359 360
360 spin_lock_irqsave(&cam->dev_lock, flags); 361 spin_lock_irqsave(&cam->dev_lock, flags);
361 rval = TWSIC0_EN | ((addr << TWSIC0_SID_SHIFT) & TWSIC0_SID); 362 rval = TWSIC0_EN | ((addr << TWSIC0_SID_SHIFT) & TWSIC0_SID);
@@ -369,10 +370,29 @@ static int cafe_smbus_write_data(struct cafe_camera *cam,
369 rval = value | ((command << TWSIC1_ADDR_SHIFT) & TWSIC1_ADDR); 370 rval = value | ((command << TWSIC1_ADDR_SHIFT) & TWSIC1_ADDR);
370 cafe_reg_write(cam, REG_TWSIC1, rval); 371 cafe_reg_write(cam, REG_TWSIC1, rval);
371 spin_unlock_irqrestore(&cam->dev_lock, flags); 372 spin_unlock_irqrestore(&cam->dev_lock, flags);
372 msleep(2); /* Required or things flake */
373 373
374 /*
375 * Time to wait for the write to complete. THIS IS A RACY
376 * WAY TO DO IT, but the sad fact is that reading the TWSIC1
377 * register too quickly after starting the operation sends
378 * the device into a place that may be kinder and better, but
379 * which is absolutely useless for controlling the sensor. In
380 * practice we have plenty of time to get into our sleep state
381 * before the interrupt hits, and the worst case is that we
382 * time out and then see that things completed, so this seems
383 * the best way for now.
384 */
385 do {
386 prepare_to_wait(&cam->smbus_wait, &the_wait,
387 TASK_UNINTERRUPTIBLE);
388 schedule_timeout(1); /* even 1 jiffy is too long */
389 finish_wait(&cam->smbus_wait, &the_wait);
390 } while (!cafe_smbus_write_done(cam));
391
392#ifdef IF_THE_CAFE_HARDWARE_WORKED_RIGHT
374 wait_event_timeout(cam->smbus_wait, cafe_smbus_write_done(cam), 393 wait_event_timeout(cam->smbus_wait, cafe_smbus_write_done(cam),
375 CAFE_SMBUS_TIMEOUT); 394 CAFE_SMBUS_TIMEOUT);
395#endif
376 spin_lock_irqsave(&cam->dev_lock, flags); 396 spin_lock_irqsave(&cam->dev_lock, flags);
377 rval = cafe_reg_read(cam, REG_TWSIC1); 397 rval = cafe_reg_read(cam, REG_TWSIC1);
378 spin_unlock_irqrestore(&cam->dev_lock, flags); 398 spin_unlock_irqrestore(&cam->dev_lock, flags);
@@ -710,7 +730,7 @@ static void cafe_ctlr_init(struct cafe_camera *cam)
710 * Here we must wait a bit for the controller to come around. 730 * Here we must wait a bit for the controller to come around.
711 */ 731 */
712 spin_unlock_irqrestore(&cam->dev_lock, flags); 732 spin_unlock_irqrestore(&cam->dev_lock, flags);
713 mdelay(5); /* FIXME revisit this */ 733 msleep(5);
714 spin_lock_irqsave(&cam->dev_lock, flags); 734 spin_lock_irqsave(&cam->dev_lock, flags);
715 735
716 cafe_reg_write(cam, REG_GL_CSR, GCSR_CCIC_EN|GCSR_SRC|GCSR_MRC); 736 cafe_reg_write(cam, REG_GL_CSR, GCSR_CCIC_EN|GCSR_SRC|GCSR_MRC);
@@ -2233,12 +2253,21 @@ static int cafe_pci_resume(struct pci_dev *pdev)
2233 if (ret) 2253 if (ret)
2234 return ret; 2254 return ret;
2235 ret = pci_enable_device(pdev); 2255 ret = pci_enable_device(pdev);
2256
2236 if (ret) { 2257 if (ret) {
2237 cam_warn(cam, "Unable to re-enable device on resume!\n"); 2258 cam_warn(cam, "Unable to re-enable device on resume!\n");
2238 return ret; 2259 return ret;
2239 } 2260 }
2240 cafe_ctlr_init(cam); 2261 cafe_ctlr_init(cam);
2241 cafe_ctlr_power_up(cam); 2262 cafe_ctlr_power_down(cam);
2263
2264 mutex_lock(&cam->s_mutex);
2265 if (cam->users > 0) {
2266 cafe_ctlr_power_up(cam);
2267 __cafe_cam_reset(cam);
2268 }
2269 mutex_unlock(&cam->s_mutex);
2270
2242 set_bit(CF_CONFIG_NEEDED, &cam->flags); 2271 set_bit(CF_CONFIG_NEEDED, &cam->flags);
2243 if (cam->state == S_SPECREAD) 2272 if (cam->state == S_SPECREAD)
2244 cam->state = S_IDLE; /* Don't bother restarting */ 2273 cam->state = S_IDLE; /* Don't bother restarting */
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 2c7b158ce7e1..40307f3f6fe3 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1772,6 +1772,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
1772 if (dev->alt_max_pkt_size == NULL) { 1772 if (dev->alt_max_pkt_size == NULL) {
1773 em28xx_errdev("out of memory!\n"); 1773 em28xx_errdev("out of memory!\n");
1774 em28xx_devused&=~(1<<nr); 1774 em28xx_devused&=~(1<<nr);
1775 kfree(dev);
1775 return -ENOMEM; 1776 return -ENOMEM;
1776 } 1777 }
1777 1778
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 047624b9e271..5977a79619c2 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -1190,6 +1190,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
1190 itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0; 1190 itv->osd_global_alpha_state = (fb->flags & V4L2_FBUF_FLAG_GLOBAL_ALPHA) != 0;
1191 itv->osd_local_alpha_state = (fb->flags & V4L2_FBUF_FLAG_LOCAL_ALPHA) != 0; 1191 itv->osd_local_alpha_state = (fb->flags & V4L2_FBUF_FLAG_LOCAL_ALPHA) != 0;
1192 itv->osd_color_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0; 1192 itv->osd_color_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0;
1193 ivtv_set_osd_alpha(itv);
1193 break; 1194 break;
1194 } 1195 }
1195 1196
@@ -1234,7 +1235,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
1234 IVTV_INFO("Tuner: %s\n", 1235 IVTV_INFO("Tuner: %s\n",
1235 test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ? "Radio" : "TV"); 1236 test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags) ? "Radio" : "TV");
1236 cx2341x_log_status(&itv->params, itv->name); 1237 cx2341x_log_status(&itv->params, itv->name);
1237 IVTV_INFO("Status flags: 0x%08lx\n", itv->i_flags); 1238 IVTV_INFO("Version: %s Status flags: 0x%08lx\n", IVTV_VERSION, itv->i_flags);
1238 for (i = 0; i < IVTV_MAX_STREAMS; i++) { 1239 for (i = 0; i < IVTV_MAX_STREAMS; i++) {
1239 struct ivtv_stream *s = &itv->streams[i]; 1240 struct ivtv_stream *s = &itv->streams[i];
1240 1241
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c
index f8f21ddd9843..c4c5bd67f795 100644
--- a/drivers/media/video/ov7670.c
+++ b/drivers/media/video/ov7670.c
@@ -416,7 +416,10 @@ static int ov7670_read(struct i2c_client *c, unsigned char reg,
416static int ov7670_write(struct i2c_client *c, unsigned char reg, 416static int ov7670_write(struct i2c_client *c, unsigned char reg,
417 unsigned char value) 417 unsigned char value)
418{ 418{
419 return i2c_smbus_write_byte_data(c, reg, value); 419 int ret = i2c_smbus_write_byte_data(c, reg, value);
420 if (reg == REG_COM7 && (value & COM7_RESET))
421 msleep(2); /* Wait for reset to run */
422 return ret;
420} 423}
421 424
422 425
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 9c0e8d18c2f6..3d81966d8c42 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -1196,12 +1196,19 @@ static int pwc_video_open(struct inode *inode, struct file *file)
1196 return 0; 1196 return 0;
1197} 1197}
1198 1198
1199
1200static void pwc_cleanup(struct pwc_device *pdev)
1201{
1202 pwc_remove_sysfs_files(pdev->vdev);
1203 video_unregister_device(pdev->vdev);
1204}
1205
1199/* Note that all cleanup is done in the reverse order as in _open */ 1206/* Note that all cleanup is done in the reverse order as in _open */
1200static int pwc_video_close(struct inode *inode, struct file *file) 1207static int pwc_video_close(struct inode *inode, struct file *file)
1201{ 1208{
1202 struct video_device *vdev = file->private_data; 1209 struct video_device *vdev = file->private_data;
1203 struct pwc_device *pdev; 1210 struct pwc_device *pdev;
1204 int i; 1211 int i, hint;
1205 1212
1206 PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev); 1213 PWC_DEBUG_OPEN(">> video_close called(vdev = 0x%p).\n", vdev);
1207 1214
@@ -1224,8 +1231,9 @@ static int pwc_video_close(struct inode *inode, struct file *file)
1224 pwc_isoc_cleanup(pdev); 1231 pwc_isoc_cleanup(pdev);
1225 pwc_free_buffers(pdev); 1232 pwc_free_buffers(pdev);
1226 1233
1234 lock_kernel();
1227 /* Turn off LEDS and power down camera, but only when not unplugged */ 1235 /* Turn off LEDS and power down camera, but only when not unplugged */
1228 if (pdev->error_status != EPIPE) { 1236 if (!pdev->unplugged) {
1229 /* Turn LEDs off */ 1237 /* Turn LEDs off */
1230 if (pwc_set_leds(pdev, 0, 0) < 0) 1238 if (pwc_set_leds(pdev, 0, 0) < 0)
1231 PWC_DEBUG_MODULE("Failed to set LED on/off time.\n"); 1239 PWC_DEBUG_MODULE("Failed to set LED on/off time.\n");
@@ -1234,9 +1242,19 @@ static int pwc_video_close(struct inode *inode, struct file *file)
1234 if (i < 0) 1242 if (i < 0)
1235 PWC_ERROR("Failed to power down camera (%d)\n", i); 1243 PWC_ERROR("Failed to power down camera (%d)\n", i);
1236 } 1244 }
1245 pdev->vopen--;
1246 PWC_DEBUG_OPEN("<< video_close() vopen=%d\n", i);
1247 } else {
1248 pwc_cleanup(pdev);
1249 /* Free memory (don't set pdev to 0 just yet) */
1250 kfree(pdev);
1251 /* search device_hint[] table if we occupy a slot, by any chance */
1252 for (hint = 0; hint < MAX_DEV_HINTS; hint++)
1253 if (device_hint[hint].pdev == pdev)
1254 device_hint[hint].pdev = NULL;
1237 } 1255 }
1238 pdev->vopen--; 1256 unlock_kernel();
1239 PWC_DEBUG_OPEN("<< video_close() vopen=%d\n", pdev->vopen); 1257
1240 return 0; 1258 return 0;
1241} 1259}
1242 1260
@@ -1791,21 +1809,21 @@ static void usb_pwc_disconnect(struct usb_interface *intf)
1791 /* Alert waiting processes */ 1809 /* Alert waiting processes */
1792 wake_up_interruptible(&pdev->frameq); 1810 wake_up_interruptible(&pdev->frameq);
1793 /* Wait until device is closed */ 1811 /* Wait until device is closed */
1794 while (pdev->vopen) 1812 if(pdev->vopen) {
1795 schedule(); 1813 pdev->unplugged = 1;
1796 /* Device is now closed, so we can safely unregister it */ 1814 } else {
1797 PWC_DEBUG_PROBE("Unregistering video device in disconnect().\n"); 1815 /* Device is closed, so we can safely unregister it */
1798 pwc_remove_sysfs_files(pdev->vdev); 1816 PWC_DEBUG_PROBE("Unregistering video device in disconnect().\n");
1799 video_unregister_device(pdev->vdev); 1817 pwc_cleanup(pdev);
1800 1818 /* Free memory (don't set pdev to 0 just yet) */
1801 /* Free memory (don't set pdev to 0 just yet) */ 1819 kfree(pdev);
1802 kfree(pdev);
1803 1820
1804disconnect_out: 1821disconnect_out:
1805 /* search device_hint[] table if we occupy a slot, by any chance */ 1822 /* search device_hint[] table if we occupy a slot, by any chance */
1806 for (hint = 0; hint < MAX_DEV_HINTS; hint++) 1823 for (hint = 0; hint < MAX_DEV_HINTS; hint++)
1807 if (device_hint[hint].pdev == pdev) 1824 if (device_hint[hint].pdev == pdev)
1808 device_hint[hint].pdev = NULL; 1825 device_hint[hint].pdev = NULL;
1826 }
1809 1827
1810 unlock_kernel(); 1828 unlock_kernel();
1811} 1829}
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index 910a04f53920..8e8e5b27e77e 100644
--- a/drivers/media/video/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -193,6 +193,7 @@ struct pwc_device
193 char vsnapshot; /* snapshot mode */ 193 char vsnapshot; /* snapshot mode */
194 char vsync; /* used by isoc handler */ 194 char vsync; /* used by isoc handler */
195 char vmirror; /* for ToUCaM series */ 195 char vmirror; /* for ToUCaM series */
196 char unplugged;
196 197
197 int cmd_len; 198 int cmd_len;
198 unsigned char cmd_buf[13]; 199 unsigned char cmd_buf[13];
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 518d5d335464..a26655881e6a 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -5,6 +5,11 @@
5menuconfig MISC_DEVICES 5menuconfig MISC_DEVICES
6 bool "Misc devices" 6 bool "Misc devices"
7 default y 7 default y
8 ---help---
9 Say Y here to get to see options for device drivers from various
10 different categories. This option alone does not add any kernel code.
11
12 If you say N, all options in this submenu will be skipped and disabled.
8 13
9if MISC_DEVICES 14if MISC_DEVICES
10 15
diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c
index d0fc4fd212e6..7dce318df1bd 100644
--- a/drivers/misc/asus-laptop.c
+++ b/drivers/misc/asus-laptop.c
@@ -732,7 +732,7 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
732 lcd_blank(FB_BLANK_POWERDOWN); 732 lcd_blank(FB_BLANK_POWERDOWN);
733 } 733 }
734 734
735 acpi_bus_generate_event(hotk->device, event, 735 acpi_bus_generate_proc_event(hotk->device, event,
736 hotk->event_count[event % 128]++); 736 hotk->event_count[event % 128]++);
737 737
738 return; 738 return;
@@ -1072,7 +1072,8 @@ static void asus_backlight_exit(void)
1072} 1072}
1073 1073
1074#define ASUS_LED_UNREGISTER(object) \ 1074#define ASUS_LED_UNREGISTER(object) \
1075 led_classdev_unregister(&object##_led) 1075 if (object##_led.dev) \
1076 led_classdev_unregister(&object##_led)
1076 1077
1077static void asus_led_exit(void) 1078static void asus_led_exit(void)
1078{ 1079{
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index 91da6880ae93..d38ddce592c0 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -856,6 +856,15 @@ static struct dmi_system_id sony_nc_ids[] = {
856 }, 856 },
857 }, 857 },
858 { 858 {
859 .ident = "Sony Vaio FZ Series",
860 .callback = sony_nc_C_enable,
861 .driver_data = sony_C_events,
862 .matches = {
863 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
864 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ"),
865 },
866 },
867 {
859 .ident = "Sony Vaio C Series", 868 .ident = "Sony Vaio C Series",
860 .callback = sony_nc_C_enable, 869 .callback = sony_nc_C_enable,
861 .driver_data = sony_C_events, 870 .driver_data = sony_C_events,
@@ -904,7 +913,7 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
904 913
905 dprintk("sony_acpi_notify, event: 0x%.2x\n", ev); 914 dprintk("sony_acpi_notify, event: 0x%.2x\n", ev);
906 sony_laptop_report_input_event(ev); 915 sony_laptop_report_input_event(ev);
907 acpi_bus_generate_event(sony_nc_acpi_device, 1, ev); 916 acpi_bus_generate_proc_event(sony_nc_acpi_device, 1, ev);
908} 917}
909 918
910static acpi_status sony_walk_callback(acpi_handle handle, u32 level, 919static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
@@ -2292,7 +2301,7 @@ static irqreturn_t sony_pic_irq(int irq, void *dev_id)
2292 2301
2293found: 2302found:
2294 sony_laptop_report_input_event(device_event); 2303 sony_laptop_report_input_event(device_event);
2295 acpi_bus_generate_event(spic_dev.acpi_dev, 1, device_event); 2304 acpi_bus_generate_proc_event(spic_dev.acpi_dev, 1, device_event);
2296 sonypi_compat_report_event(device_event); 2305 sonypi_compat_report_event(device_event);
2297 2306
2298 return IRQ_HANDLED; 2307 return IRQ_HANDLED;
@@ -2308,8 +2317,6 @@ static int sony_pic_remove(struct acpi_device *device, int type)
2308 struct sony_pic_ioport *io, *tmp_io; 2317 struct sony_pic_ioport *io, *tmp_io;
2309 struct sony_pic_irq *irq, *tmp_irq; 2318 struct sony_pic_irq *irq, *tmp_irq;
2310 2319
2311 sonypi_compat_exit();
2312
2313 if (sony_pic_disable(device)) { 2320 if (sony_pic_disable(device)) {
2314 printk(KERN_ERR DRV_PFX "Couldn't disable device.\n"); 2321 printk(KERN_ERR DRV_PFX "Couldn't disable device.\n");
2315 return -ENXIO; 2322 return -ENXIO;
@@ -2319,6 +2326,8 @@ static int sony_pic_remove(struct acpi_device *device, int type)
2319 release_region(spic_dev.cur_ioport->io.minimum, 2326 release_region(spic_dev.cur_ioport->io.minimum,
2320 spic_dev.cur_ioport->io.address_length); 2327 spic_dev.cur_ioport->io.address_length);
2321 2328
2329 sonypi_compat_exit();
2330
2322 sony_laptop_remove_input(); 2331 sony_laptop_remove_input();
2323 2332
2324 /* pf attrs */ 2333 /* pf attrs */
@@ -2384,6 +2393,9 @@ static int sony_pic_add(struct acpi_device *device)
2384 goto err_free_resources; 2393 goto err_free_resources;
2385 } 2394 }
2386 2395
2396 if (sonypi_compat_init())
2397 goto err_remove_input;
2398
2387 /* request io port */ 2399 /* request io port */
2388 list_for_each_entry(io, &spic_dev.ioports, list) { 2400 list_for_each_entry(io, &spic_dev.ioports, list) {
2389 if (request_region(io->io.minimum, io->io.address_length, 2401 if (request_region(io->io.minimum, io->io.address_length,
@@ -2398,7 +2410,7 @@ static int sony_pic_add(struct acpi_device *device)
2398 if (!spic_dev.cur_ioport) { 2410 if (!spic_dev.cur_ioport) {
2399 printk(KERN_ERR DRV_PFX "Failed to request_region.\n"); 2411 printk(KERN_ERR DRV_PFX "Failed to request_region.\n");
2400 result = -ENODEV; 2412 result = -ENODEV;
2401 goto err_remove_input; 2413 goto err_remove_compat;
2402 } 2414 }
2403 2415
2404 /* request IRQ */ 2416 /* request IRQ */
@@ -2438,9 +2450,6 @@ static int sony_pic_add(struct acpi_device *device)
2438 if (result) 2450 if (result)
2439 goto err_remove_pf; 2451 goto err_remove_pf;
2440 2452
2441 if (sonypi_compat_init())
2442 goto err_remove_pf;
2443
2444 return 0; 2453 return 0;
2445 2454
2446err_remove_pf: 2455err_remove_pf:
@@ -2456,6 +2465,9 @@ err_release_region:
2456 release_region(spic_dev.cur_ioport->io.minimum, 2465 release_region(spic_dev.cur_ioport->io.minimum,
2457 spic_dev.cur_ioport->io.address_length); 2466 spic_dev.cur_ioport->io.address_length);
2458 2467
2468err_remove_compat:
2469 sonypi_compat_exit();
2470
2459err_remove_input: 2471err_remove_input:
2460 sony_laptop_remove_input(); 2472 sony_laptop_remove_input();
2461 2473
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index f6cd34a3dbac..bb8956d0c104 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -1190,10 +1190,10 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
1190 } 1190 }
1191 1191
1192 if (sendacpi) 1192 if (sendacpi)
1193 acpi_bus_generate_event(ibm->acpi->device, event, hkey); 1193 acpi_bus_generate_proc_event(ibm->acpi->device, event, hkey);
1194 } else { 1194 } else {
1195 printk(IBM_ERR "unknown hotkey notification event %d\n", event); 1195 printk(IBM_ERR "unknown hotkey notification event %d\n", event);
1196 acpi_bus_generate_event(ibm->acpi->device, event, 0); 1196 acpi_bus_generate_proc_event(ibm->acpi->device, event, 0);
1197 } 1197 }
1198} 1198}
1199 1199
@@ -2162,22 +2162,27 @@ static void dock_notify(struct ibm_struct *ibm, u32 event)
2162 int docked = dock_docked(); 2162 int docked = dock_docked();
2163 int pci = ibm->acpi->hid && ibm->acpi->device && 2163 int pci = ibm->acpi->hid && ibm->acpi->device &&
2164 acpi_match_device_ids(ibm->acpi->device, ibm_pci_device_ids); 2164 acpi_match_device_ids(ibm->acpi->device, ibm_pci_device_ids);
2165 int data;
2165 2166
2166 if (event == 1 && !pci) /* 570 */ 2167 if (event == 1 && !pci) /* 570 */
2167 acpi_bus_generate_event(ibm->acpi->device, event, 1); /* button */ 2168 data = 1; /* button */
2168 else if (event == 1 && pci) /* 570 */ 2169 else if (event == 1 && pci) /* 570 */
2169 acpi_bus_generate_event(ibm->acpi->device, event, 3); /* dock */ 2170 data = 3; /* dock */
2170 else if (event == 3 && docked) 2171 else if (event == 3 && docked)
2171 acpi_bus_generate_event(ibm->acpi->device, event, 1); /* button */ 2172 data = 1; /* button */
2172 else if (event == 3 && !docked) 2173 else if (event == 3 && !docked)
2173 acpi_bus_generate_event(ibm->acpi->device, event, 2); /* undock */ 2174 data = 2; /* undock */
2174 else if (event == 0 && docked) 2175 else if (event == 0 && docked)
2175 acpi_bus_generate_event(ibm->acpi->device, event, 3); /* dock */ 2176 data = 3; /* dock */
2176 else { 2177 else {
2177 printk(IBM_ERR "unknown dock event %d, status %d\n", 2178 printk(IBM_ERR "unknown dock event %d, status %d\n",
2178 event, _sta(dock_handle)); 2179 event, _sta(dock_handle));
2179 acpi_bus_generate_event(ibm->acpi->device, event, 0); /* unknown */ 2180 data = 0; /* unknown */
2180 } 2181 }
2182 acpi_bus_generate_proc_event(ibm->acpi->device, event, data);
2183 acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
2184 ibm->acpi->device->dev.bus_id,
2185 event, data);
2181} 2186}
2182 2187
2183static int dock_read(char *p) 2188static int dock_read(char *p)
@@ -2275,7 +2280,10 @@ static int __init bay_init(struct ibm_init_struct *iibm)
2275 2280
2276static void bay_notify(struct ibm_struct *ibm, u32 event) 2281static void bay_notify(struct ibm_struct *ibm, u32 event)
2277{ 2282{
2278 acpi_bus_generate_event(ibm->acpi->device, event, 0); 2283 acpi_bus_generate_proc_event(ibm->acpi->device, event, 0);
2284 acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
2285 ibm->acpi->device->dev.bus_id,
2286 event, 0);
2279} 2287}
2280 2288
2281#define bay_occupied(b) (_sta(b##_handle) & 1) 2289#define bay_occupied(b) (_sta(b##_handle) & 1)
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index fe0e785ed7d2..817a79462b3d 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -186,12 +186,10 @@ struct mmc_card *mmc_alloc_card(struct mmc_host *host)
186{ 186{
187 struct mmc_card *card; 187 struct mmc_card *card;
188 188
189 card = kmalloc(sizeof(struct mmc_card), GFP_KERNEL); 189 card = kzalloc(sizeof(struct mmc_card), GFP_KERNEL);
190 if (!card) 190 if (!card)
191 return ERR_PTR(-ENOMEM); 191 return ERR_PTR(-ENOMEM);
192 192
193 memset(card, 0, sizeof(struct mmc_card));
194
195 card->host = host; 193 card->host = host;
196 194
197 device_initialize(&card->dev); 195 device_initialize(&card->dev);
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 6a7e29849603..2c7ce8f43a9a 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -58,12 +58,10 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
58{ 58{
59 struct mmc_host *host; 59 struct mmc_host *host;
60 60
61 host = kmalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); 61 host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL);
62 if (!host) 62 if (!host)
63 return NULL; 63 return NULL;
64 64
65 memset(host, 0, sizeof(struct mmc_host) + extra);
66
67 host->parent = dev; 65 host->parent = dev;
68 host->class_dev.parent = dev; 66 host->class_dev.parent = dev;
69 host->class_dev.class = &mmc_host_class; 67 host->class_dev.class = &mmc_host_class;
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index f2bc87ac24f7..20a7d89e01ba 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -385,6 +385,9 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
385 BUG_ON(data->blksz > host->mmc->max_blk_size); 385 BUG_ON(data->blksz > host->mmc->max_blk_size);
386 BUG_ON(data->blocks > 65535); 386 BUG_ON(data->blocks > 65535);
387 387
388 host->data = data;
389 host->data_early = 0;
390
388 /* timeout in us */ 391 /* timeout in us */
389 target_timeout = data->timeout_ns / 1000 + 392 target_timeout = data->timeout_ns / 1000 +
390 data->timeout_clks / host->clock; 393 data->timeout_clks / host->clock;
@@ -443,11 +446,11 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host,
443{ 446{
444 u16 mode; 447 u16 mode;
445 448
446 WARN_ON(host->data);
447
448 if (data == NULL) 449 if (data == NULL)
449 return; 450 return;
450 451
452 WARN_ON(!host->data);
453
451 mode = SDHCI_TRNS_BLK_CNT_EN; 454 mode = SDHCI_TRNS_BLK_CNT_EN;
452 if (data->blocks > 1) 455 if (data->blocks > 1)
453 mode |= SDHCI_TRNS_MULTI; 456 mode |= SDHCI_TRNS_MULTI;
@@ -477,8 +480,8 @@ static void sdhci_finish_data(struct sdhci_host *host)
477 /* 480 /*
478 * Controller doesn't count down when in single block mode. 481 * Controller doesn't count down when in single block mode.
479 */ 482 */
480 if ((data->blocks == 1) && (data->error == MMC_ERR_NONE)) 483 if (data->blocks == 1)
481 blocks = 0; 484 blocks = (data->error == MMC_ERR_NONE) ? 0 : 1;
482 else 485 else
483 blocks = readw(host->ioaddr + SDHCI_BLOCK_COUNT); 486 blocks = readw(host->ioaddr + SDHCI_BLOCK_COUNT);
484 data->bytes_xfered = data->blksz * (data->blocks - blocks); 487 data->bytes_xfered = data->blksz * (data->blocks - blocks);
@@ -600,9 +603,10 @@ static void sdhci_finish_command(struct sdhci_host *host)
600 603
601 host->cmd->error = MMC_ERR_NONE; 604 host->cmd->error = MMC_ERR_NONE;
602 605
603 if (host->cmd->data) 606 if (host->data && host->data_early)
604 host->data = host->cmd->data; 607 sdhci_finish_data(host);
605 else 608
609 if (!host->cmd->data)
606 tasklet_schedule(&host->finish_tasklet); 610 tasklet_schedule(&host->finish_tasklet);
607 611
608 host->cmd = NULL; 612 host->cmd = NULL;
@@ -929,9 +933,9 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
929 BUG_ON(intmask == 0); 933 BUG_ON(intmask == 0);
930 934
931 if (!host->cmd) { 935 if (!host->cmd) {
932 printk(KERN_ERR "%s: Got command interrupt even though no " 936 printk(KERN_ERR "%s: Got command interrupt 0x%08x even "
933 "command operation was in progress.\n", 937 "though no command operation was in progress.\n",
934 mmc_hostname(host->mmc)); 938 mmc_hostname(host->mmc), (unsigned)intmask);
935 sdhci_dumpregs(host); 939 sdhci_dumpregs(host);
936 return; 940 return;
937 } 941 }
@@ -961,9 +965,9 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
961 if (intmask & SDHCI_INT_DATA_END) 965 if (intmask & SDHCI_INT_DATA_END)
962 return; 966 return;
963 967
964 printk(KERN_ERR "%s: Got data interrupt even though no " 968 printk(KERN_ERR "%s: Got data interrupt 0x%08x even "
965 "data operation was in progress.\n", 969 "though no data operation was in progress.\n",
966 mmc_hostname(host->mmc)); 970 mmc_hostname(host->mmc), (unsigned)intmask);
967 sdhci_dumpregs(host); 971 sdhci_dumpregs(host);
968 972
969 return; 973 return;
@@ -991,8 +995,18 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
991 writel(readl(host->ioaddr + SDHCI_DMA_ADDRESS), 995 writel(readl(host->ioaddr + SDHCI_DMA_ADDRESS),
992 host->ioaddr + SDHCI_DMA_ADDRESS); 996 host->ioaddr + SDHCI_DMA_ADDRESS);
993 997
994 if (intmask & SDHCI_INT_DATA_END) 998 if (intmask & SDHCI_INT_DATA_END) {
995 sdhci_finish_data(host); 999 if (host->cmd) {
1000 /*
1001 * Data managed to finish before the
1002 * command completed. Make sure we do
1003 * things in the proper order.
1004 */
1005 host->data_early = 1;
1006 } else {
1007 sdhci_finish_data(host);
1008 }
1009 }
996 } 1010 }
997} 1011}
998 1012
@@ -1347,12 +1361,11 @@ static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
1347 */ 1361 */
1348 mmc->max_blk_size = (caps & SDHCI_MAX_BLOCK_MASK) >> SDHCI_MAX_BLOCK_SHIFT; 1362 mmc->max_blk_size = (caps & SDHCI_MAX_BLOCK_MASK) >> SDHCI_MAX_BLOCK_SHIFT;
1349 if (mmc->max_blk_size >= 3) { 1363 if (mmc->max_blk_size >= 3) {
1350 printk(KERN_ERR "%s: Invalid maximum block size.\n", 1364 printk(KERN_WARNING "%s: Invalid maximum block size, assuming 512\n",
1351 host->slot_descr); 1365 host->slot_descr);
1352 ret = -ENODEV; 1366 mmc->max_blk_size = 512;
1353 goto unmap; 1367 } else
1354 } 1368 mmc->max_blk_size = 512 << mmc->max_blk_size;
1355 mmc->max_blk_size = 512 << mmc->max_blk_size;
1356 1369
1357 /* 1370 /*
1358 * Maximum block count. 1371 * Maximum block count.
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index d157776c1149..e28987d6d2eb 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -182,6 +182,7 @@ struct sdhci_host {
182 struct mmc_request *mrq; /* Current request */ 182 struct mmc_request *mrq; /* Current request */
183 struct mmc_command *cmd; /* Current command */ 183 struct mmc_command *cmd; /* Current command */
184 struct mmc_data *data; /* Current data request */ 184 struct mmc_data *data; /* Current data request */
185 int data_early:1; /* Data finished before cmd */
185 186
186 struct scatterlist *cur_sg; /* We're working on this */ 187 struct scatterlist *cur_sg; /* We're working on this */
187 int num_sg; /* Entries left */ 188 int num_sg; /* Entries left */
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 81ef81c9a584..5b9e17bf1749 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1968,6 +1968,16 @@ menuconfig NETDEV_1000
1968 bool "Ethernet (1000 Mbit)" 1968 bool "Ethernet (1000 Mbit)"
1969 depends on !UML 1969 depends on !UML
1970 default y 1970 default y
1971 ---help---
1972 Ethernet (also called IEEE 802.3 or ISO 8802-2) is the most common
1973 type of Local Area Network (LAN) in universities and companies.
1974
1975 Say Y here to get to see options for Gigabit Ethernet drivers.
1976 This option alone does not add any kernel code.
1977 Note that drivers supporting both 100 and 1000 MBit may be listed
1978 under "Ethernet (10 or 100MBit)" instead.
1979
1980 If you say N, all options in this submenu will be skipped and disabled.
1971 1981
1972if NETDEV_1000 1982if NETDEV_1000
1973 1983
@@ -2339,6 +2349,11 @@ menuconfig NETDEV_10000
2339 bool "Ethernet (10000 Mbit)" 2349 bool "Ethernet (10000 Mbit)"
2340 depends on !UML 2350 depends on !UML
2341 default y 2351 default y
2352 ---help---
2353 Say Y here to get to see options for 10 Gigabit Ethernet drivers.
2354 This option alone does not add any kernel code.
2355
2356 If you say N, all options in this submenu will be skipped and disabled.
2342 2357
2343if NETDEV_10000 2358if NETDEV_10000
2344 2359
diff --git a/drivers/net/bsd_comp.c b/drivers/net/bsd_comp.c
index 202d4a4ef751..88edb986691a 100644
--- a/drivers/net/bsd_comp.c
+++ b/drivers/net/bsd_comp.c
@@ -406,8 +406,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp)
406 * Allocate space for the dictionary. This may be more than one page in 406 * Allocate space for the dictionary. This may be more than one page in
407 * length. 407 * length.
408 */ 408 */
409 db->dict = (struct bsd_dict *) vmalloc (hsize * 409 db->dict = vmalloc(hsize * sizeof(struct bsd_dict));
410 sizeof (struct bsd_dict));
411 if (!db->dict) 410 if (!db->dict)
412 { 411 {
413 bsd_free (db); 412 bsd_free (db);
@@ -426,8 +425,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp)
426 */ 425 */
427 else 426 else
428 { 427 {
429 db->lens = (unsigned short *) vmalloc ((maxmaxcode + 1) * 428 db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0]));
430 sizeof (db->lens[0]));
431 if (!db->lens) 429 if (!db->lens)
432 { 430 {
433 bsd_free (db); 431 bsd_free (db);
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index c3de81bf090a..738aa5906514 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -700,6 +700,7 @@ dm9000_init_dm9000(struct net_device *dev)
700static int 700static int
701dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev) 701dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
702{ 702{
703 unsigned long flags;
703 board_info_t *db = (board_info_t *) dev->priv; 704 board_info_t *db = (board_info_t *) dev->priv;
704 705
705 PRINTK3("dm9000_start_xmit\n"); 706 PRINTK3("dm9000_start_xmit\n");
@@ -707,10 +708,7 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
707 if (db->tx_pkt_cnt > 1) 708 if (db->tx_pkt_cnt > 1)
708 return 1; 709 return 1;
709 710
710 netif_stop_queue(dev); 711 spin_lock_irqsave(&db->lock, flags);
711
712 /* Disable all interrupts */
713 iow(db, DM9000_IMR, IMR_PAR);
714 712
715 /* Move data to DM9000 TX RAM */ 713 /* Move data to DM9000 TX RAM */
716 writeb(DM9000_MWCMD, db->io_addr); 714 writeb(DM9000_MWCMD, db->io_addr);
@@ -718,12 +716,9 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
718 (db->outblk)(db->io_data, skb->data, skb->len); 716 (db->outblk)(db->io_data, skb->data, skb->len);
719 db->stats.tx_bytes += skb->len; 717 db->stats.tx_bytes += skb->len;
720 718
719 db->tx_pkt_cnt++;
721 /* TX control: First packet immediately send, second packet queue */ 720 /* TX control: First packet immediately send, second packet queue */
722 if (db->tx_pkt_cnt == 0) { 721 if (db->tx_pkt_cnt == 1) {
723
724 /* First Packet */
725 db->tx_pkt_cnt++;
726
727 /* Set TX length to DM9000 */ 722 /* Set TX length to DM9000 */
728 iow(db, DM9000_TXPLL, skb->len & 0xff); 723 iow(db, DM9000_TXPLL, skb->len & 0xff);
729 iow(db, DM9000_TXPLH, (skb->len >> 8) & 0xff); 724 iow(db, DM9000_TXPLH, (skb->len >> 8) & 0xff);
@@ -732,23 +727,17 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
732 iow(db, DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */ 727 iow(db, DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */
733 728
734 dev->trans_start = jiffies; /* save the time stamp */ 729 dev->trans_start = jiffies; /* save the time stamp */
735
736 } else { 730 } else {
737 /* Second packet */ 731 /* Second packet */
738 db->tx_pkt_cnt++;
739 db->queue_pkt_len = skb->len; 732 db->queue_pkt_len = skb->len;
733 netif_stop_queue(dev);
740 } 734 }
741 735
736 spin_unlock_irqrestore(&db->lock, flags);
737
742 /* free this SKB */ 738 /* free this SKB */
743 dev_kfree_skb(skb); 739 dev_kfree_skb(skb);
744 740
745 /* Re-enable resource check */
746 if (db->tx_pkt_cnt == 1)
747 netif_wake_queue(dev);
748
749 /* Re-enable interrupt */
750 iow(db, DM9000_IMR, IMR_PAR | IMR_PTM | IMR_PRM);
751
752 return 0; 741 return 0;
753} 742}
754 743
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 9756211e83ce..db5747490a07 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -76,7 +76,7 @@ MODULE_PARM_DESC(rq1_entries, "Number of entries for Receive Queue 1 "
76MODULE_PARM_DESC(sq_entries, " Number of entries for the Send Queue " 76MODULE_PARM_DESC(sq_entries, " Number of entries for the Send Queue "
77 "[2^x - 1], x = [6..14]. Default = " 77 "[2^x - 1], x = [6..14]. Default = "
78 __MODULE_STRING(EHEA_DEF_ENTRIES_SQ) ")"); 78 __MODULE_STRING(EHEA_DEF_ENTRIES_SQ) ")");
79MODULE_PARM_DESC(use_mcs, " 0:NAPI, 1:Multiple receive queues, Default = 1 "); 79MODULE_PARM_DESC(use_mcs, " 0:NAPI, 1:Multiple receive queues, Default = 0 ");
80 80
81static int port_name_cnt = 0; 81static int port_name_cnt = 0;
82static LIST_HEAD(adapter_list); 82static LIST_HEAD(adapter_list);
@@ -2490,7 +2490,7 @@ static ssize_t ehea_show_port_id(struct device *dev,
2490 struct device_attribute *attr, char *buf) 2490 struct device_attribute *attr, char *buf)
2491{ 2491{
2492 struct ehea_port *port = container_of(dev, struct ehea_port, ofdev.dev); 2492 struct ehea_port *port = container_of(dev, struct ehea_port, ofdev.dev);
2493 return sprintf(buf, "0x%X", port->logical_port_id); 2493 return sprintf(buf, "%d", port->logical_port_id);
2494} 2494}
2495 2495
2496static DEVICE_ATTR(log_port_id, S_IRUSR | S_IRGRP | S_IROTH, ehea_show_port_id, 2496static DEVICE_ATTR(log_port_id, S_IRUSR | S_IRGRP | S_IROTH, ehea_show_port_id,
@@ -2781,7 +2781,7 @@ static ssize_t ehea_probe_port(struct device *dev,
2781 2781
2782 u32 logical_port_id; 2782 u32 logical_port_id;
2783 2783
2784 sscanf(buf, "%X", &logical_port_id); 2784 sscanf(buf, "%d", &logical_port_id);
2785 2785
2786 port = ehea_get_port(adapter, logical_port_id); 2786 port = ehea_get_port(adapter, logical_port_id);
2787 2787
@@ -2834,7 +2834,7 @@ static ssize_t ehea_remove_port(struct device *dev,
2834 int i; 2834 int i;
2835 u32 logical_port_id; 2835 u32 logical_port_id;
2836 2836
2837 sscanf(buf, "%X", &logical_port_id); 2837 sscanf(buf, "%d", &logical_port_id);
2838 2838
2839 port = ehea_get_port(adapter, logical_port_id); 2839 port = ehea_get_port(adapter, logical_port_id);
2840 2840
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c
index a36fa6c23fdf..c82e24596074 100644
--- a/drivers/net/ehea/ehea_qmr.c
+++ b/drivers/net/ehea/ehea_qmr.c
@@ -235,6 +235,8 @@ int ehea_destroy_cq(struct ehea_cq *cq)
235 if (!cq) 235 if (!cq)
236 return 0; 236 return 0;
237 237
238 hcp_epas_dtor(&cq->epas);
239
238 if ((hret = ehea_destroy_cq_res(cq, NORMAL_FREE)) == H_R_STATE) { 240 if ((hret = ehea_destroy_cq_res(cq, NORMAL_FREE)) == H_R_STATE) {
239 ehea_error_data(cq->adapter, cq->fw_handle); 241 ehea_error_data(cq->adapter, cq->fw_handle);
240 hret = ehea_destroy_cq_res(cq, FORCE_FREE); 242 hret = ehea_destroy_cq_res(cq, FORCE_FREE);
@@ -361,6 +363,8 @@ int ehea_destroy_eq(struct ehea_eq *eq)
361 if (!eq) 363 if (!eq)
362 return 0; 364 return 0;
363 365
366 hcp_epas_dtor(&eq->epas);
367
364 if ((hret = ehea_destroy_eq_res(eq, NORMAL_FREE)) == H_R_STATE) { 368 if ((hret = ehea_destroy_eq_res(eq, NORMAL_FREE)) == H_R_STATE) {
365 ehea_error_data(eq->adapter, eq->fw_handle); 369 ehea_error_data(eq->adapter, eq->fw_handle);
366 hret = ehea_destroy_eq_res(eq, FORCE_FREE); 370 hret = ehea_destroy_eq_res(eq, FORCE_FREE);
@@ -541,6 +545,8 @@ int ehea_destroy_qp(struct ehea_qp *qp)
541 if (!qp) 545 if (!qp)
542 return 0; 546 return 0;
543 547
548 hcp_epas_dtor(&qp->epas);
549
544 if ((hret = ehea_destroy_qp_res(qp, NORMAL_FREE)) == H_R_STATE) { 550 if ((hret = ehea_destroy_qp_res(qp, NORMAL_FREE)) == H_R_STATE) {
545 ehea_error_data(qp->adapter, qp->fw_handle); 551 ehea_error_data(qp->adapter, qp->fw_handle);
546 hret = ehea_destroy_qp_res(qp, FORCE_FREE); 552 hret = ehea_destroy_qp_res(qp, FORCE_FREE);
diff --git a/drivers/net/eql.c b/drivers/net/eql.c
index a93700e5661a..102218c4a907 100644
--- a/drivers/net/eql.c
+++ b/drivers/net/eql.c
@@ -391,7 +391,7 @@ static int __eql_insert_slave(slave_queue_t *queue, slave_t *slave)
391 slave_t *duplicate_slave = NULL; 391 slave_t *duplicate_slave = NULL;
392 392
393 duplicate_slave = __eql_find_slave_dev(queue, slave->dev); 393 duplicate_slave = __eql_find_slave_dev(queue, slave->dev);
394 if (duplicate_slave != 0) 394 if (duplicate_slave)
395 eql_kill_one_slave(queue, duplicate_slave); 395 eql_kill_one_slave(queue, duplicate_slave);
396 396
397 list_add(&slave->list, &queue->all_slaves); 397 list_add(&slave->list, &queue->all_slaves);
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 69f5f365239a..1938d6dfc863 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -552,7 +552,7 @@ union ring_type {
552#define PHY_OUI_MARVELL 0x5043 552#define PHY_OUI_MARVELL 0x5043
553#define PHY_OUI_CICADA 0x03f1 553#define PHY_OUI_CICADA 0x03f1
554#define PHY_OUI_VITESSE 0x01c1 554#define PHY_OUI_VITESSE 0x01c1
555#define PHY_OUI_REALTEK 0x01c1 555#define PHY_OUI_REALTEK 0x0732
556#define PHYID1_OUI_MASK 0x03ff 556#define PHYID1_OUI_MASK 0x03ff
557#define PHYID1_OUI_SHFT 6 557#define PHYID1_OUI_SHFT 6
558#define PHYID2_OUI_MASK 0xfc00 558#define PHYID2_OUI_MASK 0xfc00
@@ -3068,8 +3068,8 @@ static irqreturn_t nv_nic_irq(int foo, void *data)
3068 np->nic_poll_irq = np->irqmask; 3068 np->nic_poll_irq = np->irqmask;
3069 mod_timer(&np->nic_poll, jiffies + POLL_WAIT); 3069 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
3070 } 3070 }
3071 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq.\n", dev->name, i);
3072 spin_unlock(&np->lock); 3071 spin_unlock(&np->lock);
3072 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq.\n", dev->name, i);
3073 break; 3073 break;
3074 } 3074 }
3075 3075
@@ -3186,8 +3186,8 @@ static irqreturn_t nv_nic_irq_optimized(int foo, void *data)
3186 np->nic_poll_irq = np->irqmask; 3186 np->nic_poll_irq = np->irqmask;
3187 mod_timer(&np->nic_poll, jiffies + POLL_WAIT); 3187 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
3188 } 3188 }
3189 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq.\n", dev->name, i);
3190 spin_unlock(&np->lock); 3189 spin_unlock(&np->lock);
3190 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq.\n", dev->name, i);
3191 break; 3191 break;
3192 } 3192 }
3193 3193
@@ -3233,8 +3233,8 @@ static irqreturn_t nv_nic_irq_tx(int foo, void *data)
3233 np->nic_poll_irq |= NVREG_IRQ_TX_ALL; 3233 np->nic_poll_irq |= NVREG_IRQ_TX_ALL;
3234 mod_timer(&np->nic_poll, jiffies + POLL_WAIT); 3234 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
3235 } 3235 }
3236 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_tx.\n", dev->name, i);
3237 spin_unlock_irqrestore(&np->lock, flags); 3236 spin_unlock_irqrestore(&np->lock, flags);
3237 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_tx.\n", dev->name, i);
3238 break; 3238 break;
3239 } 3239 }
3240 3240
@@ -3348,8 +3348,8 @@ static irqreturn_t nv_nic_irq_rx(int foo, void *data)
3348 np->nic_poll_irq |= NVREG_IRQ_RX_ALL; 3348 np->nic_poll_irq |= NVREG_IRQ_RX_ALL;
3349 mod_timer(&np->nic_poll, jiffies + POLL_WAIT); 3349 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
3350 } 3350 }
3351 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_rx.\n", dev->name, i);
3352 spin_unlock_irqrestore(&np->lock, flags); 3351 spin_unlock_irqrestore(&np->lock, flags);
3352 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_rx.\n", dev->name, i);
3353 break; 3353 break;
3354 } 3354 }
3355 } 3355 }
@@ -3421,8 +3421,8 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data)
3421 np->nic_poll_irq |= NVREG_IRQ_OTHER; 3421 np->nic_poll_irq |= NVREG_IRQ_OTHER;
3422 mod_timer(&np->nic_poll, jiffies + POLL_WAIT); 3422 mod_timer(&np->nic_poll, jiffies + POLL_WAIT);
3423 } 3423 }
3424 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_other.\n", dev->name, i);
3425 spin_unlock_irqrestore(&np->lock, flags); 3424 spin_unlock_irqrestore(&np->lock, flags);
3425 printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_other.\n", dev->name, i);
3426 break; 3426 break;
3427 } 3427 }
3428 3428
diff --git a/drivers/net/irda/kingsun-sir.c b/drivers/net/irda/kingsun-sir.c
index bdd5c979bead..4e5101a45c3c 100644
--- a/drivers/net/irda/kingsun-sir.c
+++ b/drivers/net/irda/kingsun-sir.c
@@ -509,12 +509,12 @@ static int kingsun_probe(struct usb_interface *intf,
509 spin_lock_init(&kingsun->lock); 509 spin_lock_init(&kingsun->lock);
510 510
511 /* Allocate input buffer */ 511 /* Allocate input buffer */
512 kingsun->in_buf = (__u8 *)kmalloc(kingsun->max_rx, GFP_KERNEL); 512 kingsun->in_buf = kmalloc(kingsun->max_rx, GFP_KERNEL);
513 if (!kingsun->in_buf) 513 if (!kingsun->in_buf)
514 goto free_mem; 514 goto free_mem;
515 515
516 /* Allocate output buffer */ 516 /* Allocate output buffer */
517 kingsun->out_buf = (__u8 *)kmalloc(KINGSUN_FIFO_SIZE, GFP_KERNEL); 517 kingsun->out_buf = kmalloc(KINGSUN_FIFO_SIZE, GFP_KERNEL);
518 if (!kingsun->out_buf) 518 if (!kingsun->out_buf)
519 goto free_mem; 519 goto free_mem;
520 520
diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index 92b403bf38b0..32bed6bc6c06 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -405,7 +405,7 @@ static void meth_rx(struct net_device* dev, unsigned long int_status)
405 priv->stats.rx_length_errors++; 405 priv->stats.rx_length_errors++;
406 skb = priv->rx_skbs[priv->rx_write]; 406 skb = priv->rx_skbs[priv->rx_write];
407 } else { 407 } else {
408 skb = alloc_skb(METH_RX_BUFF_SIZE, GFP_ATOMIC | GFP_DMA); 408 skb = alloc_skb(METH_RX_BUFF_SIZE, GFP_ATOMIC);
409 if (!skb) { 409 if (!skb) {
410 /* Ouch! No memory! Drop packet on the floor */ 410 /* Ouch! No memory! Drop packet on the floor */
411 DPRINTK("No mem: dropping packet\n"); 411 DPRINTK("No mem: dropping packet\n");
diff --git a/drivers/net/mlx4/reset.c b/drivers/net/mlx4/reset.c
index e4dfd4b11a4a..e199715fabd0 100644
--- a/drivers/net/mlx4/reset.c
+++ b/drivers/net/mlx4/reset.c
@@ -119,6 +119,9 @@ int mlx4_reset(struct mlx4_dev *dev)
119 writel(MLX4_RESET_VALUE, reset + MLX4_RESET_OFFSET); 119 writel(MLX4_RESET_VALUE, reset + MLX4_RESET_OFFSET);
120 iounmap(reset); 120 iounmap(reset);
121 121
122 /* Docs say to wait one second before accessing device */
123 msleep(1000);
124
122 end = jiffies + MLX4_RESET_TIMEOUT_JIFFIES; 125 end = jiffies + MLX4_RESET_TIMEOUT_JIFFIES;
123 do { 126 do {
124 if (!pci_read_config_word(dev->pdev, PCI_VENDOR_ID, &vendor) && 127 if (!pci_read_config_word(dev->pdev, PCI_VENDOR_ID, &vendor) &&
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index ae9bb7b7fd67..1c42266bf889 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -72,7 +72,7 @@
72#include "myri10ge_mcp.h" 72#include "myri10ge_mcp.h"
73#include "myri10ge_mcp_gen_header.h" 73#include "myri10ge_mcp_gen_header.h"
74 74
75#define MYRI10GE_VERSION_STR "1.3.1-1.248" 75#define MYRI10GE_VERSION_STR "1.3.2-1.269"
76 76
77MODULE_DESCRIPTION("Myricom 10G driver (10GbE)"); 77MODULE_DESCRIPTION("Myricom 10G driver (10GbE)");
78MODULE_AUTHOR("Maintainer: help@myri.com"); 78MODULE_AUTHOR("Maintainer: help@myri.com");
@@ -2514,26 +2514,20 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp)
2514{ 2514{
2515 struct pci_dev *pdev = mgp->pdev; 2515 struct pci_dev *pdev = mgp->pdev;
2516 struct device *dev = &pdev->dev; 2516 struct device *dev = &pdev->dev;
2517 int cap, status; 2517 int status;
2518 u16 val;
2519 2518
2520 mgp->tx.boundary = 4096; 2519 mgp->tx.boundary = 4096;
2521 /* 2520 /*
2522 * Verify the max read request size was set to 4KB 2521 * Verify the max read request size was set to 4KB
2523 * before trying the test with 4KB. 2522 * before trying the test with 4KB.
2524 */ 2523 */
2525 cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); 2524 status = pcie_get_readrq(pdev);
2526 if (cap < 64) { 2525 if (status < 0) {
2527 dev_err(dev, "Bad PCI_CAP_ID_EXP location %d\n", cap);
2528 goto abort;
2529 }
2530 status = pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &val);
2531 if (status != 0) {
2532 dev_err(dev, "Couldn't read max read req size: %d\n", status); 2526 dev_err(dev, "Couldn't read max read req size: %d\n", status);
2533 goto abort; 2527 goto abort;
2534 } 2528 }
2535 if ((val & (5 << 12)) != (5 << 12)) { 2529 if (status != 4096) {
2536 dev_warn(dev, "Max Read Request size != 4096 (0x%x)\n", val); 2530 dev_warn(dev, "Max Read Request size != 4096 (%d)\n", status);
2537 mgp->tx.boundary = 2048; 2531 mgp->tx.boundary = 2048;
2538 } 2532 }
2539 /* 2533 /*
@@ -2850,9 +2844,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2850 size_t bytes; 2844 size_t bytes;
2851 int i; 2845 int i;
2852 int status = -ENXIO; 2846 int status = -ENXIO;
2853 int cap;
2854 int dac_enabled; 2847 int dac_enabled;
2855 u16 val;
2856 2848
2857 netdev = alloc_etherdev(sizeof(*mgp)); 2849 netdev = alloc_etherdev(sizeof(*mgp));
2858 if (netdev == NULL) { 2850 if (netdev == NULL) {
@@ -2884,19 +2876,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2884 = pci_find_capability(pdev, PCI_CAP_ID_VNDR); 2876 = pci_find_capability(pdev, PCI_CAP_ID_VNDR);
2885 2877
2886 /* Set our max read request to 4KB */ 2878 /* Set our max read request to 4KB */
2887 cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); 2879 status = pcie_set_readrq(pdev, 4096);
2888 if (cap < 64) {
2889 dev_err(&pdev->dev, "Bad PCI_CAP_ID_EXP location %d\n", cap);
2890 goto abort_with_netdev;
2891 }
2892 status = pci_read_config_word(pdev, cap + PCI_EXP_DEVCTL, &val);
2893 if (status != 0) {
2894 dev_err(&pdev->dev, "Error %d reading PCI_EXP_DEVCTL\n",
2895 status);
2896 goto abort_with_netdev;
2897 }
2898 val = (val & ~PCI_EXP_DEVCTL_READRQ) | (5 << 12);
2899 status = pci_write_config_word(pdev, cap + PCI_EXP_DEVCTL, val);
2900 if (status != 0) { 2880 if (status != 0) {
2901 dev_err(&pdev->dev, "Error %d writing PCI_EXP_DEVCTL\n", 2881 dev_err(&pdev->dev, "Error %d writing PCI_EXP_DEVCTL\n",
2902 status); 2882 status);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index a8b74cdab1ea..e275df8c55bc 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -364,7 +364,7 @@ EXPORT_SYMBOL(genphy_config_advert);
364 */ 364 */
365int genphy_setup_forced(struct phy_device *phydev) 365int genphy_setup_forced(struct phy_device *phydev)
366{ 366{
367 int ctl = BMCR_RESET; 367 int ctl = 0;
368 368
369 phydev->pause = phydev->asym_pause = 0; 369 phydev->pause = phydev->asym_pause = 0;
370 370
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index ef3325b69233..9293c82ef2af 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -1726,7 +1726,7 @@ ppp_decompress_frame(struct ppp *ppp, struct sk_buff *skb)
1726 } 1726 }
1727 /* the decompressor still expects the A/C bytes in the hdr */ 1727 /* the decompressor still expects the A/C bytes in the hdr */
1728 len = ppp->rcomp->decompress(ppp->rc_state, skb->data - 2, 1728 len = ppp->rcomp->decompress(ppp->rc_state, skb->data - 2,
1729 skb->len + 2, ns->data, ppp->mru + PPP_HDRLEN); 1729 skb->len + 2, ns->data, obuff_size);
1730 if (len < 0) { 1730 if (len < 0) {
1731 /* Pass the compressed frame to pppd as an 1731 /* Pass the compressed frame to pppd as an
1732 error indication. */ 1732 error indication. */
diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c
index 384b4685e977..0fb74cb51c4b 100644
--- a/drivers/net/sgiseeq.c
+++ b/drivers/net/sgiseeq.c
@@ -726,7 +726,7 @@ err_out:
726 return err; 726 return err;
727} 727}
728 728
729static void __exit sgiseeq_remove(struct platform_device *pdev) 729static int __exit sgiseeq_remove(struct platform_device *pdev)
730{ 730{
731 struct net_device *dev = platform_get_drvdata(pdev); 731 struct net_device *dev = platform_get_drvdata(pdev);
732 struct sgiseeq_private *sp = netdev_priv(dev); 732 struct sgiseeq_private *sp = netdev_priv(dev);
@@ -735,6 +735,8 @@ static void __exit sgiseeq_remove(struct platform_device *pdev)
735 free_page((unsigned long) sp->srings); 735 free_page((unsigned long) sp->srings);
736 free_netdev(dev); 736 free_netdev(dev);
737 platform_set_drvdata(pdev, NULL); 737 platform_set_drvdata(pdev, NULL);
738
739 return 0;
738} 740}
739 741
740static struct platform_driver sgiseeq_driver = { 742static struct platform_driver sgiseeq_driver = {
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index e7a2eadcc3b0..e6d937ec6886 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -51,7 +51,7 @@
51#include "sky2.h" 51#include "sky2.h"
52 52
53#define DRV_NAME "sky2" 53#define DRV_NAME "sky2"
54#define DRV_VERSION "1.16" 54#define DRV_VERSION "1.17"
55#define PFX DRV_NAME " " 55#define PFX DRV_NAME " "
56 56
57/* 57/*
@@ -99,10 +99,6 @@ static int disable_msi = 0;
99module_param(disable_msi, int, 0); 99module_param(disable_msi, int, 0);
100MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)"); 100MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
101 101
102static int idle_timeout = 100;
103module_param(idle_timeout, int, 0);
104MODULE_PARM_DESC(idle_timeout, "Watchdog timer for lost interrupts (ms)");
105
106static const struct pci_device_id sky2_id_table[] = { 102static const struct pci_device_id sky2_id_table[] = {
107 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */ 103 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */
108 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */ 104 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */
@@ -219,9 +215,12 @@ static void sky2_power_on(struct sky2_hw *hw)
219 else 215 else
220 sky2_write8(hw, B2_Y2_CLK_GATE, 0); 216 sky2_write8(hw, B2_Y2_CLK_GATE, 0);
221 217
222 if (hw->chip_id == CHIP_ID_YUKON_EC_U || hw->chip_id == CHIP_ID_YUKON_EX) { 218 if (hw->chip_id == CHIP_ID_YUKON_EC_U ||
219 hw->chip_id == CHIP_ID_YUKON_EX) {
223 u32 reg; 220 u32 reg;
224 221
222 sky2_pci_write32(hw, PCI_DEV_REG3, 0);
223
225 reg = sky2_pci_read32(hw, PCI_DEV_REG4); 224 reg = sky2_pci_read32(hw, PCI_DEV_REG4);
226 /* set all bits to 0 except bits 15..12 and 8 */ 225 /* set all bits to 0 except bits 15..12 and 8 */
227 reg &= P_ASPM_CONTROL_MSK; 226 reg &= P_ASPM_CONTROL_MSK;
@@ -238,6 +237,8 @@ static void sky2_power_on(struct sky2_hw *hw)
238 reg = sky2_read32(hw, B2_GP_IO); 237 reg = sky2_read32(hw, B2_GP_IO);
239 reg |= GLB_GPIO_STAT_RACE_DIS; 238 reg |= GLB_GPIO_STAT_RACE_DIS;
240 sky2_write32(hw, B2_GP_IO, reg); 239 sky2_write32(hw, B2_GP_IO, reg);
240
241 sky2_read32(hw, B2_GP_IO);
241 } 242 }
242} 243}
243 244
@@ -696,8 +697,8 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
696 int i; 697 int i;
697 const u8 *addr = hw->dev[port]->dev_addr; 698 const u8 *addr = hw->dev[port]->dev_addr;
698 699
699 sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET); 700 sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET);
700 sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR); 701 sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR);
701 702
702 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR); 703 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR);
703 704
@@ -1619,6 +1620,9 @@ static int sky2_down(struct net_device *dev)
1619 if (netif_msg_ifdown(sky2)) 1620 if (netif_msg_ifdown(sky2))
1620 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); 1621 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
1621 1622
1623 if (netif_carrier_ok(dev) && --hw->active == 0)
1624 del_timer(&hw->watchdog_timer);
1625
1622 /* Stop more packets from being queued */ 1626 /* Stop more packets from being queued */
1623 netif_stop_queue(dev); 1627 netif_stop_queue(dev);
1624 1628
@@ -1739,6 +1743,10 @@ static void sky2_link_up(struct sky2_port *sky2)
1739 1743
1740 netif_carrier_on(sky2->netdev); 1744 netif_carrier_on(sky2->netdev);
1741 1745
1746 if (hw->active++ == 0)
1747 mod_timer(&hw->watchdog_timer, jiffies + 1);
1748
1749
1742 /* Turn on link LED */ 1750 /* Turn on link LED */
1743 sky2_write8(hw, SK_REG(port, LNK_LED_REG), 1751 sky2_write8(hw, SK_REG(port, LNK_LED_REG),
1744 LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF); 1752 LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF);
@@ -1790,6 +1798,11 @@ static void sky2_link_down(struct sky2_port *sky2)
1790 1798
1791 netif_carrier_off(sky2->netdev); 1799 netif_carrier_off(sky2->netdev);
1792 1800
1801 /* Stop watchdog if both ports are not active */
1802 if (--hw->active == 0)
1803 del_timer(&hw->watchdog_timer);
1804
1805
1793 /* Turn on link LED */ 1806 /* Turn on link LED */
1794 sky2_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF); 1807 sky2_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF);
1795 1808
@@ -2421,25 +2434,20 @@ static void sky2_le_error(struct sky2_hw *hw, unsigned port,
2421 sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_CLR_IRQ_CHK); 2434 sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_CLR_IRQ_CHK);
2422} 2435}
2423 2436
2424/* If idle then force a fake soft NAPI poll once a second 2437/* Check for lost IRQ once a second */
2425 * to work around cases where sharing an edge triggered interrupt. 2438static void sky2_watchdog(unsigned long arg)
2426 */
2427static inline void sky2_idle_start(struct sky2_hw *hw)
2428{
2429 if (idle_timeout > 0)
2430 mod_timer(&hw->idle_timer,
2431 jiffies + msecs_to_jiffies(idle_timeout));
2432}
2433
2434static void sky2_idle(unsigned long arg)
2435{ 2439{
2436 struct sky2_hw *hw = (struct sky2_hw *) arg; 2440 struct sky2_hw *hw = (struct sky2_hw *) arg;
2437 struct net_device *dev = hw->dev[0];
2438 2441
2439 if (__netif_rx_schedule_prep(dev)) 2442 if (sky2_read32(hw, B0_ISRC)) {
2440 __netif_rx_schedule(dev); 2443 struct net_device *dev = hw->dev[0];
2441 2444
2442 mod_timer(&hw->idle_timer, jiffies + msecs_to_jiffies(idle_timeout)); 2445 if (__netif_rx_schedule_prep(dev))
2446 __netif_rx_schedule(dev);
2447 }
2448
2449 if (hw->active > 0)
2450 mod_timer(&hw->watchdog_timer, round_jiffies(jiffies + HZ));
2443} 2451}
2444 2452
2445/* Hardware/software error handling */ 2453/* Hardware/software error handling */
@@ -2727,8 +2735,6 @@ static void sky2_restart(struct work_struct *work)
2727 struct net_device *dev; 2735 struct net_device *dev;
2728 int i, err; 2736 int i, err;
2729 2737
2730 del_timer_sync(&hw->idle_timer);
2731
2732 rtnl_lock(); 2738 rtnl_lock();
2733 sky2_write32(hw, B0_IMSK, 0); 2739 sky2_write32(hw, B0_IMSK, 0);
2734 sky2_read32(hw, B0_IMSK); 2740 sky2_read32(hw, B0_IMSK);
@@ -2757,8 +2763,6 @@ static void sky2_restart(struct work_struct *work)
2757 } 2763 }
2758 } 2764 }
2759 2765
2760 sky2_idle_start(hw);
2761
2762 rtnl_unlock(); 2766 rtnl_unlock();
2763} 2767}
2764 2768
@@ -4025,11 +4029,9 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
4025 sky2_show_addr(dev1); 4029 sky2_show_addr(dev1);
4026 } 4030 }
4027 4031
4028 setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) hw); 4032 setup_timer(&hw->watchdog_timer, sky2_watchdog, (unsigned long) hw);
4029 INIT_WORK(&hw->restart_work, sky2_restart); 4033 INIT_WORK(&hw->restart_work, sky2_restart);
4030 4034
4031 sky2_idle_start(hw);
4032
4033 pci_set_drvdata(pdev, hw); 4035 pci_set_drvdata(pdev, hw);
4034 4036
4035 return 0; 4037 return 0;
@@ -4064,7 +4066,7 @@ static void __devexit sky2_remove(struct pci_dev *pdev)
4064 if (!hw) 4066 if (!hw)
4065 return; 4067 return;
4066 4068
4067 del_timer_sync(&hw->idle_timer); 4069 del_timer_sync(&hw->watchdog_timer);
4068 4070
4069 flush_scheduled_work(); 4071 flush_scheduled_work();
4070 4072
@@ -4108,7 +4110,6 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
4108 if (!hw) 4110 if (!hw)
4109 return 0; 4111 return 0;
4110 4112
4111 del_timer_sync(&hw->idle_timer);
4112 netif_poll_disable(hw->dev[0]); 4113 netif_poll_disable(hw->dev[0]);
4113 4114
4114 for (i = 0; i < hw->ports; i++) { 4115 for (i = 0; i < hw->ports; i++) {
@@ -4174,7 +4175,7 @@ static int sky2_resume(struct pci_dev *pdev)
4174 } 4175 }
4175 4176
4176 netif_poll_enable(hw->dev[0]); 4177 netif_poll_enable(hw->dev[0]);
4177 sky2_idle_start(hw); 4178
4178 return 0; 4179 return 0;
4179out: 4180out:
4180 dev_err(&pdev->dev, "resume failed (%d)\n", err); 4181 dev_err(&pdev->dev, "resume failed (%d)\n", err);
@@ -4191,7 +4192,6 @@ static void sky2_shutdown(struct pci_dev *pdev)
4191 if (!hw) 4192 if (!hw)
4192 return; 4193 return;
4193 4194
4194 del_timer_sync(&hw->idle_timer);
4195 netif_poll_disable(hw->dev[0]); 4195 netif_poll_disable(hw->dev[0]);
4196 4196
4197 for (i = 0; i < hw->ports; i++) { 4197 for (i = 0; i < hw->ports; i++) {
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index dce4d276d443..72e12b7cfa40 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -2045,12 +2045,13 @@ struct sky2_hw {
2045 u8 chip_rev; 2045 u8 chip_rev;
2046 u8 pmd_type; 2046 u8 pmd_type;
2047 u8 ports; 2047 u8 ports;
2048 u8 active;
2048 2049
2049 struct sky2_status_le *st_le; 2050 struct sky2_status_le *st_le;
2050 u32 st_idx; 2051 u32 st_idx;
2051 dma_addr_t st_dma; 2052 dma_addr_t st_dma;
2052 2053
2053 struct timer_list idle_timer; 2054 struct timer_list watchdog_timer;
2054 struct work_struct restart_work; 2055 struct work_struct restart_work;
2055 int msi; 2056 int msi;
2056 wait_queue_head_t msi_wait; 2057 wait_queue_head_t msi_wait;
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 65bd20fac820..3fd4735006f5 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -957,7 +957,7 @@ slip_close(struct tty_struct *tty)
957 * STANDARD SLIP ENCAPSULATION * 957 * STANDARD SLIP ENCAPSULATION *
958 ************************************************************************/ 958 ************************************************************************/
959 959
960int 960static int
961slip_esc(unsigned char *s, unsigned char *d, int len) 961slip_esc(unsigned char *s, unsigned char *d, int len)
962{ 962{
963 unsigned char *ptr = d; 963 unsigned char *ptr = d;
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index 70db38c0ced9..56829f82be4a 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -267,7 +267,10 @@ static void ibm_handle_events(acpi_handle handle, u32 event, void *context)
267 267
268 if (subevent == 0x80) { 268 if (subevent == 0x80) {
269 dbg("%s: generationg bus event\n", __FUNCTION__); 269 dbg("%s: generationg bus event\n", __FUNCTION__);
270 acpi_bus_generate_event(note->device, note->event, detail); 270 acpi_bus_generate_proc_event(note->device, note->event, detail);
271 acpi_bus_generate_netlink_event(note->device->pnp.device_class,
272 note->device->dev.bus_id,
273 note->event, detail);
271 } else 274 } else
272 note->event = event; 275 note->event = event;
273} 276}
@@ -399,7 +402,7 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
399 402
400 status = acpi_get_object_info(handle, &info_buffer); 403 status = acpi_get_object_info(handle, &info_buffer);
401 if (ACPI_FAILURE(status)) { 404 if (ACPI_FAILURE(status)) {
402 err("%s: Failed to get device information", __FUNCTION__); 405 err("%s: Failed to get device information\n", __FUNCTION__);
403 return 0; 406 return 0;
404 } 407 }
405 info.hardware_id.value[sizeof(info.hardware_id.value) - 1] = '\0'; 408 info.hardware_id.value[sizeof(info.hardware_id.value) - 1] = '\0';
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index 79ff6b4de3a6..37d72f123a80 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -1746,10 +1746,8 @@ static void pushbutton_helper_thread(unsigned long data)
1746static int event_thread(void* data) 1746static int event_thread(void* data)
1747{ 1747{
1748 struct controller *ctrl; 1748 struct controller *ctrl;
1749 lock_kernel(); 1749
1750 daemonize("phpd_event"); 1750 daemonize("phpd_event");
1751
1752 unlock_kernel();
1753 1751
1754 while (1) { 1752 while (1) {
1755 dbg("!!!!event_thread sleeping\n"); 1753 dbg("!!!!event_thread sleeping\n");
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index c6e132d7c0f7..4c36e80f6d26 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -5,12 +5,7 @@ extern int pci_uevent(struct device *dev, char **envp, int num_envp,
5extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); 5extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
6extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev); 6extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
7extern void pci_cleanup_rom(struct pci_dev *dev); 7extern void pci_cleanup_rom(struct pci_dev *dev);
8extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, 8
9 resource_size_t size, resource_size_t align,
10 resource_size_t min, unsigned int type_mask,
11 void (*alignf)(void *, struct resource *,
12 resource_size_t, resource_size_t),
13 void *alignf_data);
14/* Firmware callbacks */ 9/* Firmware callbacks */
15extern pci_power_t (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state); 10extern pci_power_t (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
16extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t state); 11extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t state);
@@ -35,7 +30,6 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; }
35 30
36/* Functions for PCI Hotplug drivers to use */ 31/* Functions for PCI Hotplug drivers to use */
37extern unsigned int pci_do_scan_bus(struct pci_bus *bus); 32extern unsigned int pci_do_scan_bus(struct pci_bus *bus);
38extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap);
39 33
40extern void pci_remove_legacy_files(struct pci_bus *bus); 34extern void pci_remove_legacy_files(struct pci_bus *bus);
41 35
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 34b8dae0d90f..27e00b2d7b5b 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -653,20 +653,20 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass
653 653
654 sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number); 654 sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number);
655 655
656 /* Has only triggered on CardBus, fixup is in yenta_socket */
656 while (bus->parent) { 657 while (bus->parent) {
657 if ((child->subordinate > bus->subordinate) || 658 if ((child->subordinate > bus->subordinate) ||
658 (child->number > bus->subordinate) || 659 (child->number > bus->subordinate) ||
659 (child->number < bus->number) || 660 (child->number < bus->number) ||
660 (child->subordinate < bus->number)) { 661 (child->subordinate < bus->number)) {
661 printk(KERN_WARNING "PCI: Bus #%02x (-#%02x) is " 662 pr_debug("PCI: Bus #%02x (-#%02x) is %s"
662 "hidden behind%s bridge #%02x (-#%02x)%s\n", 663 "hidden behind%s bridge #%02x (-#%02x)\n",
663 child->number, child->subordinate, 664 child->number, child->subordinate,
664 bus->self->transparent ? " transparent" : " ", 665 (bus->number > child->subordinate &&
665 bus->number, bus->subordinate, 666 bus->subordinate < child->number) ?
666 pcibios_assign_all_busses() ? " " : 667 "wholly " : " partially",
667 " (try 'pci=assign-busses')"); 668 bus->self->transparent ? " transparent" : " ",
668 printk(KERN_WARNING "Please report the result to " 669 bus->number, bus->subordinate);
669 "<bk@suse.de> to fix this permanently\n");
670 } 670 }
671 bus = bus->parent; 671 bus = bus->parent;
672 } 672 }
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index c559085c89a5..2d40f437b9fc 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -947,7 +947,7 @@ static void k8t_sound_hostbridge(struct pci_dev *dev)
947 unsigned char val; 947 unsigned char val;
948 948
949 pci_read_config_byte(dev, 0x50, &val); 949 pci_read_config_byte(dev, 0x50, &val);
950 if (val == 0x88 || val == 0xc8) { 950 if (val == 0xc8) {
951 /* Assume it's probably a MSI-K8T-Neo2Fir */ 951 /* Assume it's probably a MSI-K8T-Neo2Fir */
952 printk(KERN_INFO "PCI: MSI-K8T-Neo2Fir, attempting to turn soundcard ON\n"); 952 printk(KERN_INFO "PCI: MSI-K8T-Neo2Fir, attempting to turn soundcard ON\n");
953 pci_write_config_byte(dev, 0x50, val & (~0x40)); 953 pci_write_config_byte(dev, 0x50, val & (~0x40));
@@ -1485,7 +1485,7 @@ static void __devinit quirk_e100_interrupt(struct pci_dev *dev)
1485 1485
1486 iounmap(csr); 1486 iounmap(csr);
1487} 1487}
1488DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_e100_interrupt); 1488DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, quirk_e100_interrupt);
1489 1489
1490static void __devinit fixup_rev1_53c810(struct pci_dev* dev) 1490static void __devinit fixup_rev1_53c810(struct pci_dev* dev)
1491{ 1491{
@@ -1650,6 +1650,9 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_GCN
1650DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000_PCIX, quirk_disable_all_msi); 1650DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000_PCIX, quirk_disable_all_msi);
1651DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS400_200, quirk_disable_all_msi); 1651DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS400_200, quirk_disable_all_msi);
1652DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS480, quirk_disable_all_msi); 1652DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS480, quirk_disable_all_msi);
1653DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RD580, quirk_disable_all_msi);
1654DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RX790, quirk_disable_all_msi);
1655DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS690, quirk_disable_all_msi);
1653DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT3351, quirk_disable_all_msi); 1656DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT3351, quirk_disable_all_msi);
1654 1657
1655/* Disable MSI on chipsets that are known to not support it */ 1658/* Disable MSI on chipsets that are known to not support it */
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index b6a4f02b01d1..6c0440c20e31 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -25,13 +25,13 @@ static const struct pnp_card_device_id *match_card(struct pnp_card_driver *drv,
25 int found; 25 int found;
26 struct pnp_dev *dev; 26 struct pnp_dev *dev;
27 27
28 if (i == PNP_MAX_DEVICES 28 if (i == PNP_MAX_DEVICES ||
29 || !*drv_id->devs[i].id) 29 !*drv_id->devs[i].id)
30 return drv_id; 30 return drv_id;
31 found = 0; 31 found = 0;
32 card_for_each_dev(card, dev) { 32 card_for_each_dev(card, dev) {
33 if (compare_pnp_id 33 if (compare_pnp_id(dev->id,
34 (dev->id, drv_id->devs[i].id)) { 34 drv_id->devs[i].id)) {
35 found = 1; 35 found = 1;
36 break; 36 break;
37 } 37 }
@@ -183,7 +183,7 @@ static int pnp_interface_attach_card(struct pnp_card *card)
183 183
184 return 0; 184 return 0;
185 185
186 err_name: 186err_name:
187 device_remove_file(&card->dev, &dev_attr_name); 187 device_remove_file(&card->dev, &dev_attr_name);
188 return rc; 188 return rc;
189} 189}
@@ -321,10 +321,10 @@ struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
321 pos = pos->next; 321 pos = pos->next;
322 } 322 }
323 323
324 done: 324done:
325 return NULL; 325 return NULL;
326 326
327 found: 327found:
328 dev->card_link = clink; 328 dev->card_link = clink;
329 dev->dev.driver = &drv->link.driver; 329 dev->dev.driver = &drv->link.driver;
330 if (pnp_bus_type.probe(&dev->dev)) 330 if (pnp_bus_type.probe(&dev->dev))
@@ -334,7 +334,7 @@ struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
334 334
335 return dev; 335 return dev;
336 336
337 err_out: 337err_out:
338 dev->dev.driver = NULL; 338 dev->dev.driver = NULL;
339 dev->card_link = NULL; 339 dev->card_link = NULL;
340 return NULL; 340 return NULL;
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index 61066fdb9e6d..d5964feb14de 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -52,9 +52,6 @@ int pnp_register_protocol(struct pnp_protocol *protocol)
52 int nodenum; 52 int nodenum;
53 struct list_head *pos; 53 struct list_head *pos;
54 54
55 if (!protocol)
56 return -EINVAL;
57
58 INIT_LIST_HEAD(&protocol->devices); 55 INIT_LIST_HEAD(&protocol->devices);
59 INIT_LIST_HEAD(&protocol->cards); 56 INIT_LIST_HEAD(&protocol->cards);
60 nodenum = 0; 57 nodenum = 0;
@@ -94,8 +91,6 @@ static void pnp_free_ids(struct pnp_dev *dev)
94 struct pnp_id *id; 91 struct pnp_id *id;
95 struct pnp_id *next; 92 struct pnp_id *next;
96 93
97 if (!dev)
98 return;
99 id = dev->id; 94 id = dev->id;
100 while (id) { 95 while (id) {
101 next = id->next; 96 next = id->next;
@@ -143,7 +138,7 @@ int __pnp_add_device(struct pnp_dev *dev)
143 */ 138 */
144int pnp_add_device(struct pnp_dev *dev) 139int pnp_add_device(struct pnp_dev *dev)
145{ 140{
146 if (!dev || !dev->protocol || dev->card) 141 if (dev->card)
147 return -EINVAL; 142 return -EINVAL;
148 dev->dev.parent = &dev->protocol->dev; 143 dev->dev.parent = &dev->protocol->dev;
149 sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number, 144 sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number,
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index 30b8f6f3258a..2fa64a6b25c8 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -118,7 +118,7 @@ static int pnp_device_probe(struct device *dev)
118 goto fail; 118 goto fail;
119 return error; 119 return error;
120 120
121 fail: 121fail:
122 pnp_device_detach(pnp_dev); 122 pnp_device_detach(pnp_dev);
123 return error; 123 return error;
124} 124}
@@ -232,10 +232,6 @@ int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev)
232{ 232{
233 struct pnp_id *ptr; 233 struct pnp_id *ptr;
234 234
235 if (!id)
236 return -EINVAL;
237 if (!dev)
238 return -EINVAL;
239 id->next = NULL; 235 id->next = NULL;
240 ptr = dev->id; 236 ptr = dev->id;
241 while (ptr && ptr->next) 237 while (ptr && ptr->next)
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index fe6684e13e82..a0cfb75bbb8d 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -459,7 +459,8 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
459 up(&pnp_res_mutex); 459 up(&pnp_res_mutex);
460 goto done; 460 goto done;
461 } 461 }
462 done: 462
463done:
463 if (retval < 0) 464 if (retval < 0)
464 return retval; 465 return retval;
465 return count; 466 return count;
@@ -499,10 +500,10 @@ int pnp_interface_attach_device(struct pnp_dev *dev)
499 500
500 return 0; 501 return 0;
501 502
502 err_res: 503err_res:
503 device_remove_file(&dev->dev, &dev_attr_resources); 504 device_remove_file(&dev->dev, &dev_attr_resources);
504 err_opt: 505err_opt:
505 device_remove_file(&dev->dev, &dev_attr_options); 506 device_remove_file(&dev->dev, &dev_attr_options);
506 err: 507err:
507 return rc; 508 return rc;
508} 509}
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index b4e2aa995b53..b035d60a1dcc 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -47,9 +47,6 @@
47#if 0 47#if 0
48#define ISAPNP_REGION_OK 48#define ISAPNP_REGION_OK
49#endif 49#endif
50#if 0
51#define ISAPNP_DEBUG
52#endif
53 50
54int isapnp_disable; /* Disable ISA PnP */ 51int isapnp_disable; /* Disable ISA PnP */
55static int isapnp_rdp; /* Read Data Port */ 52static int isapnp_rdp; /* Read Data Port */
@@ -93,7 +90,6 @@ MODULE_LICENSE("GPL");
93 90
94static unsigned char isapnp_checksum_value; 91static unsigned char isapnp_checksum_value;
95static DEFINE_MUTEX(isapnp_cfg_mutex); 92static DEFINE_MUTEX(isapnp_cfg_mutex);
96static int isapnp_detected;
97static int isapnp_csn_count; 93static int isapnp_csn_count;
98 94
99/* some prototypes */ 95/* some prototypes */
@@ -335,7 +331,7 @@ static int __init isapnp_isolate(void)
335 } else if (iteration > 1) { 331 } else if (iteration > 1) {
336 break; 332 break;
337 } 333 }
338 __next: 334__next:
339 if (csn == 255) 335 if (csn == 255)
340 break; 336 break;
341 checksum = 0x6a; 337 checksum = 0x6a;
@@ -733,7 +729,7 @@ static int __init isapnp_create_device(struct pnp_card *card,
733 "isapnp: unexpected or unknown tag type 0x%x for logical device %i (device %i), ignored\n", 729 "isapnp: unexpected or unknown tag type 0x%x for logical device %i (device %i), ignored\n",
734 type, dev->number, card->number); 730 type, dev->number, card->number);
735 } 731 }
736 __skip: 732__skip:
737 if (size > 0) 733 if (size > 0)
738 isapnp_skip_bytes(size); 734 isapnp_skip_bytes(size);
739 } 735 }
@@ -788,7 +784,7 @@ static void __init isapnp_parse_resource_map(struct pnp_card *card)
788 "isapnp: unexpected or unknown tag type 0x%x for device %i, ignored\n", 784 "isapnp: unexpected or unknown tag type 0x%x for device %i, ignored\n",
789 type, card->number); 785 type, card->number);
790 } 786 }
791 __skip: 787__skip:
792 if (size > 0) 788 if (size > 0)
793 isapnp_skip_bytes(size); 789 isapnp_skip_bytes(size);
794 } 790 }
@@ -940,9 +936,6 @@ EXPORT_SYMBOL(isapnp_protocol);
940EXPORT_SYMBOL(isapnp_present); 936EXPORT_SYMBOL(isapnp_present);
941EXPORT_SYMBOL(isapnp_cfg_begin); 937EXPORT_SYMBOL(isapnp_cfg_begin);
942EXPORT_SYMBOL(isapnp_cfg_end); 938EXPORT_SYMBOL(isapnp_cfg_end);
943#if 0
944EXPORT_SYMBOL(isapnp_read_byte);
945#endif
946EXPORT_SYMBOL(isapnp_write_byte); 939EXPORT_SYMBOL(isapnp_write_byte);
947 940
948static int isapnp_read_resources(struct pnp_dev *dev, 941static int isapnp_read_resources(struct pnp_dev *dev,
@@ -993,6 +986,7 @@ static int isapnp_get_resources(struct pnp_dev *dev,
993 struct pnp_resource_table *res) 986 struct pnp_resource_table *res)
994{ 987{
995 int ret; 988 int ret;
989
996 pnp_init_resource_table(res); 990 pnp_init_resource_table(res);
997 isapnp_cfg_begin(dev->card->number, dev->number); 991 isapnp_cfg_begin(dev->card->number, dev->number);
998 ret = isapnp_read_resources(dev, res); 992 ret = isapnp_read_resources(dev, res);
@@ -1046,7 +1040,7 @@ static int isapnp_set_resources(struct pnp_dev *dev,
1046 1040
1047static int isapnp_disable_resources(struct pnp_dev *dev) 1041static int isapnp_disable_resources(struct pnp_dev *dev)
1048{ 1042{
1049 if (!dev || !dev->active) 1043 if (!dev->active)
1050 return -EINVAL; 1044 return -EINVAL;
1051 isapnp_cfg_begin(dev->card->number, dev->number); 1045 isapnp_cfg_begin(dev->card->number, dev->number);
1052 isapnp_deactivate(dev->number); 1046 isapnp_deactivate(dev->number);
@@ -1069,7 +1063,6 @@ static int __init isapnp_init(void)
1069 struct pnp_dev *dev; 1063 struct pnp_dev *dev;
1070 1064
1071 if (isapnp_disable) { 1065 if (isapnp_disable) {
1072 isapnp_detected = 0;
1073 printk(KERN_INFO "isapnp: ISA Plug & Play support disabled\n"); 1066 printk(KERN_INFO "isapnp: ISA Plug & Play support disabled\n");
1074 return 0; 1067 return 0;
1075 } 1068 }
@@ -1117,7 +1110,6 @@ static int __init isapnp_init(void)
1117 } 1110 }
1118 isapnp_set_rdp(); 1111 isapnp_set_rdp();
1119 } 1112 }
1120 isapnp_detected = 1;
1121 if (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff) { 1113 if (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff) {
1122 cards = isapnp_isolate(); 1114 cards = isapnp_isolate();
1123 if (cards < 0 || (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff)) { 1115 if (cards < 0 || (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff)) {
@@ -1125,7 +1117,6 @@ static int __init isapnp_init(void)
1125 release_region(_PIDXR, 1); 1117 release_region(_PIDXR, 1);
1126#endif 1118#endif
1127 release_region(_PNPWRP, 1); 1119 release_region(_PNPWRP, 1);
1128 isapnp_detected = 0;
1129 printk(KERN_INFO 1120 printk(KERN_INFO
1130 "isapnp: No Plug & Play device found\n"); 1121 "isapnp: No Plug & Play device found\n");
1131 return 0; 1122 return 0;
@@ -1148,13 +1139,12 @@ static int __init isapnp_init(void)
1148 } 1139 }
1149 } 1140 }
1150 } 1141 }
1151 if (cards) { 1142 if (cards)
1152 printk(KERN_INFO 1143 printk(KERN_INFO
1153 "isapnp: %i Plug & Play card%s detected total\n", cards, 1144 "isapnp: %i Plug & Play card%s detected total\n", cards,
1154 cards > 1 ? "s" : ""); 1145 cards > 1 ? "s" : "");
1155 } else { 1146 else
1156 printk(KERN_INFO "isapnp: No Plug & Play card found\n"); 1147 printk(KERN_INFO "isapnp: No Plug & Play card found\n");
1157 }
1158 1148
1159 isapnp_proc_init(); 1149 isapnp_proc_init();
1160 return 0; 1150 return 0;
diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c
index 3fbc0f9ffc26..560ccb640816 100644
--- a/drivers/pnp/isapnp/proc.c
+++ b/drivers/pnp/isapnp/proc.c
@@ -112,33 +112,6 @@ static int isapnp_proc_attach_device(struct pnp_dev *dev)
112 return 0; 112 return 0;
113} 113}
114 114
115#ifdef MODULE
116static int __exit isapnp_proc_detach_device(struct pnp_dev *dev)
117{
118 struct pnp_card *bus = dev->card;
119 struct proc_dir_entry *de;
120 char name[16];
121
122 if (!(de = bus->procdir))
123 return -EINVAL;
124 sprintf(name, "%02x", dev->number);
125 remove_proc_entry(name, de);
126 return 0;
127}
128
129static int __exit isapnp_proc_detach_bus(struct pnp_card *bus)
130{
131 struct proc_dir_entry *de;
132 char name[16];
133
134 if (!(de = bus->procdir))
135 return -EINVAL;
136 sprintf(name, "%02x", bus->number);
137 remove_proc_entry(name, isapnp_proc_bus_dir);
138 return 0;
139}
140#endif /* MODULE */
141
142int __init isapnp_proc_init(void) 115int __init isapnp_proc_init(void)
143{ 116{
144 struct pnp_dev *dev; 117 struct pnp_dev *dev;
@@ -149,21 +122,3 @@ int __init isapnp_proc_init(void)
149 } 122 }
150 return 0; 123 return 0;
151} 124}
152
153#ifdef MODULE
154int __exit isapnp_proc_done(void)
155{
156 struct pnp_dev *dev;
157 struct pnp_bus *card;
158
159 isapnp_for_each_dev(dev) {
160 isapnp_proc_detach_device(dev);
161 }
162 isapnp_for_each_card(card) {
163 isapnp_proc_detach_bus(card);
164 }
165 if (isapnp_proc_bus_dir)
166 remove_proc_entry("isapnp", proc_bus);
167 return 0;
168}
169#endif /* MODULE */
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index 3bda513a6bd3..0826287eef53 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -21,9 +21,6 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
21 resource_size_t *start, *end; 21 resource_size_t *start, *end;
22 unsigned long *flags; 22 unsigned long *flags;
23 23
24 if (!dev || !rule)
25 return -EINVAL;
26
27 if (idx >= PNP_MAX_PORT) { 24 if (idx >= PNP_MAX_PORT) {
28 pnp_err 25 pnp_err
29 ("More than 4 ports is incompatible with pnp specifications."); 26 ("More than 4 ports is incompatible with pnp specifications.");
@@ -66,9 +63,6 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
66 resource_size_t *start, *end; 63 resource_size_t *start, *end;
67 unsigned long *flags; 64 unsigned long *flags;
68 65
69 if (!dev || !rule)
70 return -EINVAL;
71
72 if (idx >= PNP_MAX_MEM) { 66 if (idx >= PNP_MAX_MEM) {
73 pnp_err 67 pnp_err
74 ("More than 8 mems is incompatible with pnp specifications."); 68 ("More than 8 mems is incompatible with pnp specifications.");
@@ -127,9 +121,6 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx)
127 5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2 121 5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2
128 }; 122 };
129 123
130 if (!dev || !rule)
131 return -EINVAL;
132
133 if (idx >= PNP_MAX_IRQ) { 124 if (idx >= PNP_MAX_IRQ) {
134 pnp_err 125 pnp_err
135 ("More than 2 irqs is incompatible with pnp specifications."); 126 ("More than 2 irqs is incompatible with pnp specifications.");
@@ -181,9 +172,6 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)
181 1, 3, 5, 6, 7, 0, 2, 4 172 1, 3, 5, 6, 7, 0, 2, 4
182 }; 173 };
183 174
184 if (!dev || !rule)
185 return -EINVAL;
186
187 if (idx >= PNP_MAX_DMA) { 175 if (idx >= PNP_MAX_DMA) {
188 pnp_err 176 pnp_err
189 ("More than 2 dmas is incompatible with pnp specifications."); 177 ("More than 2 dmas is incompatible with pnp specifications.");
@@ -390,7 +378,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum)
390 up(&pnp_res_mutex); 378 up(&pnp_res_mutex);
391 return 1; 379 return 1;
392 380
393 fail: 381fail:
394 pnp_clean_resource_table(&dev->res); 382 pnp_clean_resource_table(&dev->res);
395 up(&pnp_res_mutex); 383 up(&pnp_res_mutex);
396 return 0; 384 return 0;
@@ -410,8 +398,6 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
410 int i; 398 int i;
411 struct pnp_resource_table *bak; 399 struct pnp_resource_table *bak;
412 400
413 if (!dev || !res)
414 return -EINVAL;
415 if (!pnp_can_configure(dev)) 401 if (!pnp_can_configure(dev))
416 return -ENODEV; 402 return -ENODEV;
417 bak = pnp_alloc(sizeof(struct pnp_resource_table)); 403 bak = pnp_alloc(sizeof(struct pnp_resource_table));
@@ -444,7 +430,7 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
444 kfree(bak); 430 kfree(bak);
445 return 0; 431 return 0;
446 432
447 fail: 433fail:
448 dev->res = *bak; 434 dev->res = *bak;
449 up(&pnp_res_mutex); 435 up(&pnp_res_mutex);
450 kfree(bak); 436 kfree(bak);
@@ -460,9 +446,6 @@ int pnp_auto_config_dev(struct pnp_dev *dev)
460 struct pnp_option *dep; 446 struct pnp_option *dep;
461 int i = 1; 447 int i = 1;
462 448
463 if (!dev)
464 return -EINVAL;
465
466 if (!pnp_can_configure(dev)) { 449 if (!pnp_can_configure(dev)) {
467 pnp_dbg("Device %s does not support resource configuration.", 450 pnp_dbg("Device %s does not support resource configuration.",
468 dev->dev.bus_id); 451 dev->dev.bus_id);
@@ -541,8 +524,6 @@ int pnp_activate_dev(struct pnp_dev *dev)
541{ 524{
542 int error; 525 int error;
543 526
544 if (!dev)
545 return -EINVAL;
546 if (dev->active) 527 if (dev->active)
547 return 0; /* the device is already active */ 528 return 0; /* the device is already active */
548 529
@@ -568,8 +549,6 @@ int pnp_disable_dev(struct pnp_dev *dev)
568{ 549{
569 int error; 550 int error;
570 551
571 if (!dev)
572 return -EINVAL;
573 if (!dev->active) 552 if (!dev->active)
574 return 0; /* the device is already disabled */ 553 return 0; /* the device is already disabled */
575 554
@@ -596,8 +575,6 @@ int pnp_disable_dev(struct pnp_dev *dev)
596void pnp_resource_change(struct resource *resource, resource_size_t start, 575void pnp_resource_change(struct resource *resource, resource_size_t start,
597 resource_size_t size) 576 resource_size_t size)
598{ 577{
599 if (resource == NULL)
600 return;
601 resource->flags &= ~(IORESOURCE_AUTO | IORESOURCE_UNSET); 578 resource->flags &= ~(IORESOURCE_AUTO | IORESOURCE_UNSET);
602 resource->start = start; 579 resource->start = start;
603 resource->end = start + size - 1; 580 resource->end = start + size - 1;
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 616fc72190bf..a5a372222d69 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -248,9 +248,9 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
248 num++; 248 num++;
249 249
250 return AE_OK; 250 return AE_OK;
251 err1: 251err1:
252 kfree(dev_id); 252 kfree(dev_id);
253 err: 253err:
254 kfree(dev); 254 kfree(dev);
255 return -EINVAL; 255 return -EINVAL;
256} 256}
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index ce5027feb3da..0e3b8d0ff06b 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -34,19 +34,17 @@
34 */ 34 */
35static int irq_flags(int triggering, int polarity) 35static int irq_flags(int triggering, int polarity)
36{ 36{
37 int flag;
38 if (triggering == ACPI_LEVEL_SENSITIVE) { 37 if (triggering == ACPI_LEVEL_SENSITIVE) {
39 if (polarity == ACPI_ACTIVE_LOW) 38 if (polarity == ACPI_ACTIVE_LOW)
40 flag = IORESOURCE_IRQ_LOWLEVEL; 39 return IORESOURCE_IRQ_LOWLEVEL;
41 else 40 else
42 flag = IORESOURCE_IRQ_HIGHLEVEL; 41 return IORESOURCE_IRQ_HIGHLEVEL;
43 } else { 42 } else {
44 if (polarity == ACPI_ACTIVE_LOW) 43 if (polarity == ACPI_ACTIVE_LOW)
45 flag = IORESOURCE_IRQ_LOWEDGE; 44 return IORESOURCE_IRQ_LOWEDGE;
46 else 45 else
47 flag = IORESOURCE_IRQ_HIGHEDGE; 46 return IORESOURCE_IRQ_HIGHEDGE;
48 } 47 }
49 return flag;
50} 48}
51 49
52static void decode_irq_flags(int flag, int *triggering, int *polarity) 50static void decode_irq_flags(int flag, int *triggering, int *polarity)
@@ -242,8 +240,7 @@ static void pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res
242static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 240static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
243 void *data) 241 void *data)
244{ 242{
245 struct pnp_resource_table *res_table = 243 struct pnp_resource_table *res_table = data;
246 (struct pnp_resource_table *)data;
247 int i; 244 int i;
248 245
249 switch (res->type) { 246 switch (res->type) {
@@ -566,8 +563,7 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
566 void *data) 563 void *data)
567{ 564{
568 int priority = 0; 565 int priority = 0;
569 struct acpipnp_parse_option_s *parse_data = 566 struct acpipnp_parse_option_s *parse_data = data;
570 (struct acpipnp_parse_option_s *)data;
571 struct pnp_dev *dev = parse_data->dev; 567 struct pnp_dev *dev = parse_data->dev;
572 struct pnp_option *option = parse_data->option; 568 struct pnp_option *option = parse_data->option;
573 569
@@ -705,7 +701,7 @@ static int pnpacpi_supported_resource(struct acpi_resource *res)
705static acpi_status pnpacpi_count_resources(struct acpi_resource *res, 701static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
706 void *data) 702 void *data)
707{ 703{
708 int *res_cnt = (int *)data; 704 int *res_cnt = data;
709 705
710 if (pnpacpi_supported_resource(res)) 706 if (pnpacpi_supported_resource(res))
711 (*res_cnt)++; 707 (*res_cnt)++;
@@ -714,7 +710,7 @@ static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
714 710
715static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data) 711static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data)
716{ 712{
717 struct acpi_resource **resource = (struct acpi_resource **)data; 713 struct acpi_resource **resource = data;
718 714
719 if (pnpacpi_supported_resource(res)) { 715 if (pnpacpi_supported_resource(res)) {
720 (*resource)->type = res->type; 716 (*resource)->type = res->type;
@@ -886,8 +882,7 @@ int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
886 int i = 0; 882 int i = 0;
887 /* pnpacpi_build_resource_template allocates extra mem */ 883 /* pnpacpi_build_resource_template allocates extra mem */
888 int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1; 884 int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1;
889 struct acpi_resource *resource = 885 struct acpi_resource *resource = buffer->pointer;
890 (struct acpi_resource *)buffer->pointer;
891 int port = 0, irq = 0, dma = 0, mem = 0; 886 int port = 0, irq = 0, dma = 0, mem = 0;
892 887
893 pnp_dbg("res cnt %d", res_cnt); 888 pnp_dbg("res cnt %d", res_cnt);
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index 3692a099b45f..0691f473e9d4 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -419,7 +419,6 @@ static void __init build_devlist(void)
419static int pnpbios_disabled; 419static int pnpbios_disabled;
420int pnpbios_dont_use_current_config; 420int pnpbios_dont_use_current_config;
421 421
422#ifndef MODULE
423static int __init pnpbios_setup(char *str) 422static int __init pnpbios_setup(char *str)
424{ 423{
425 int invert; 424 int invert;
@@ -443,7 +442,6 @@ static int __init pnpbios_setup(char *str)
443} 442}
444 443
445__setup("pnpbios=", pnpbios_setup); 444__setup("pnpbios=", pnpbios_setup);
446#endif
447 445
448/* PnP BIOS signature: "$PnP" */ 446/* PnP BIOS signature: "$PnP" */
449#define PNP_SIGNATURE (('$' << 0) + ('P' << 8) + ('n' << 16) + ('P' << 24)) 447#define PNP_SIGNATURE (('$' << 0) + ('P' << 8) + ('n' << 16) + ('P' << 24))
@@ -591,6 +589,7 @@ subsys_initcall(pnpbios_init);
591static int __init pnpbios_thread_init(void) 589static int __init pnpbios_thread_init(void)
592{ 590{
593 struct task_struct *task; 591 struct task_struct *task;
592
594#if defined(CONFIG_PPC_MERGE) 593#if defined(CONFIG_PPC_MERGE)
595 if (check_legacy_ioport(PNPBIOS_BASE)) 594 if (check_legacy_ioport(PNPBIOS_BASE))
596 return 0; 595 return 0;
@@ -606,48 +605,7 @@ static int __init pnpbios_thread_init(void)
606 return 0; 605 return 0;
607} 606}
608 607
609#ifndef MODULE
610
611/* init/main.c calls pnpbios_init early */
612
613/* Start the kernel thread later: */ 608/* Start the kernel thread later: */
614module_init(pnpbios_thread_init); 609module_init(pnpbios_thread_init);
615 610
616#else
617
618/*
619 * N.B.: Building pnpbios as a module hasn't been fully implemented
620 */
621
622MODULE_LICENSE("GPL");
623
624static int __init pnpbios_init_all(void)
625{
626 int r;
627
628 r = pnpbios_init();
629 if (r)
630 return r;
631 r = pnpbios_thread_init();
632 if (r)
633 return r;
634 return 0;
635}
636
637static void __exit pnpbios_exit(void)
638{
639#ifdef CONFIG_HOTPLUG
640 unloading = 1;
641 wait_for_completion(&unload_sem);
642#endif
643 pnpbios_proc_exit();
644 /* We ought to free resources here */
645 return;
646}
647
648module_init(pnpbios_init_all);
649module_exit(pnpbios_exit);
650
651#endif
652
653EXPORT_SYMBOL(pnpbios_protocol); 611EXPORT_SYMBOL(pnpbios_protocol);
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c
index 9c8c07701b65..9d9841f24a85 100644
--- a/drivers/pnp/pnpbios/proc.c
+++ b/drivers/pnp/pnpbios/proc.c
@@ -212,7 +212,7 @@ static int proc_write_node(struct file *file, const char __user * buf,
212 goto out; 212 goto out;
213 } 213 }
214 ret = count; 214 ret = count;
215 out: 215out:
216 kfree(node); 216 kfree(node);
217 return ret; 217 return ret;
218} 218}
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 04ecd7b67230..3fabf11b0027 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -238,7 +238,7 @@ static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p,
238 break; 238 break;
239 239
240 default: /* an unkown tag */ 240 default: /* an unkown tag */
241 len_err: 241len_err:
242 printk(KERN_ERR 242 printk(KERN_ERR
243 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", 243 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
244 tag, len); 244 tag, len);
@@ -298,6 +298,7 @@ static void pnpbios_parse_fixed_mem32_option(unsigned char *p, int size,
298 struct pnp_option *option) 298 struct pnp_option *option)
299{ 299{
300 struct pnp_mem *mem; 300 struct pnp_mem *mem;
301
301 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 302 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
302 if (!mem) 303 if (!mem)
303 return; 304 return;
@@ -468,7 +469,7 @@ static unsigned char *pnpbios_parse_resource_option_data(unsigned char *p,
468 return p + 2; 469 return p + 2;
469 470
470 default: /* an unkown tag */ 471 default: /* an unkown tag */
471 len_err: 472len_err:
472 printk(KERN_ERR 473 printk(KERN_ERR
473 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", 474 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
474 tag, len); 475 tag, len);
@@ -562,7 +563,7 @@ static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p,
562 break; 563 break;
563 564
564 default: /* an unkown tag */ 565 default: /* an unkown tag */
565 len_err: 566len_err:
566 printk(KERN_ERR 567 printk(KERN_ERR
567 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", 568 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
568 tag, len); 569 tag, len);
@@ -756,7 +757,7 @@ static unsigned char *pnpbios_encode_allocated_resource_data(unsigned char *p,
756 break; 757 break;
757 758
758 default: /* an unkown tag */ 759 default: /* an unkown tag */
759 len_err: 760len_err:
760 printk(KERN_ERR 761 printk(KERN_ERR
761 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", 762 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
762 tag, len); 763 tag, len);
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index ea6ec14a0559..ef1286900db3 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -47,9 +47,6 @@ struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev)
47{ 47{
48 struct pnp_option *option; 48 struct pnp_option *option;
49 49
50 if (!dev)
51 return NULL;
52
53 option = pnp_build_option(PNP_RES_PRIORITY_PREFERRED); 50 option = pnp_build_option(PNP_RES_PRIORITY_PREFERRED);
54 51
55 /* this should never happen but if it does we'll try to continue */ 52 /* this should never happen but if it does we'll try to continue */
@@ -64,9 +61,6 @@ struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
64{ 61{
65 struct pnp_option *option; 62 struct pnp_option *option;
66 63
67 if (!dev)
68 return NULL;
69
70 option = pnp_build_option(priority); 64 option = pnp_build_option(priority);
71 65
72 if (dev->dependent) { 66 if (dev->dependent) {
@@ -83,11 +77,6 @@ int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data)
83{ 77{
84 struct pnp_irq *ptr; 78 struct pnp_irq *ptr;
85 79
86 if (!option)
87 return -EINVAL;
88 if (!data)
89 return -EINVAL;
90
91 ptr = option->irq; 80 ptr = option->irq;
92 while (ptr && ptr->next) 81 while (ptr && ptr->next)
93 ptr = ptr->next; 82 ptr = ptr->next;
@@ -112,11 +101,6 @@ int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data)
112{ 101{
113 struct pnp_dma *ptr; 102 struct pnp_dma *ptr;
114 103
115 if (!option)
116 return -EINVAL;
117 if (!data)
118 return -EINVAL;
119
120 ptr = option->dma; 104 ptr = option->dma;
121 while (ptr && ptr->next) 105 while (ptr && ptr->next)
122 ptr = ptr->next; 106 ptr = ptr->next;
@@ -132,11 +116,6 @@ int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data)
132{ 116{
133 struct pnp_port *ptr; 117 struct pnp_port *ptr;
134 118
135 if (!option)
136 return -EINVAL;
137 if (!data)
138 return -EINVAL;
139
140 ptr = option->port; 119 ptr = option->port;
141 while (ptr && ptr->next) 120 while (ptr && ptr->next)
142 ptr = ptr->next; 121 ptr = ptr->next;
@@ -152,11 +131,6 @@ int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data)
152{ 131{
153 struct pnp_mem *ptr; 132 struct pnp_mem *ptr;
154 133
155 if (!option)
156 return -EINVAL;
157 if (!data)
158 return -EINVAL;
159
160 ptr = option->mem; 134 ptr = option->mem;
161 while (ptr && ptr->next) 135 while (ptr && ptr->next)
162 ptr = ptr->next; 136 ptr = ptr->next;
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 80c4a8463065..1cb33cac1237 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -892,7 +892,7 @@ static int m41t80_remove(struct i2c_client *client)
892 892
893static struct i2c_driver m41t80_driver = { 893static struct i2c_driver m41t80_driver = {
894 .driver = { 894 .driver = {
895 .name = "m41t80", 895 .name = "rtc-m41t80",
896 }, 896 },
897 .probe = m41t80_probe, 897 .probe = m41t80_probe,
898 .remove = m41t80_remove, 898 .remove = m41t80_remove,
diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c
index d94170728075..3e183cfee10f 100644
--- a/drivers/rtc/rtc-max6902.c
+++ b/drivers/rtc/rtc-max6902.c
@@ -13,7 +13,7 @@
13 * 13 *
14 * 24-May-2006: Raphael Assenat <raph@8d.com> 14 * 24-May-2006: Raphael Assenat <raph@8d.com>
15 * - Major rework 15 * - Major rework
16 * Converted to rtc_device and uses the SPI layer. 16 * Converted to rtc_device and uses the SPI layer.
17 * 17 *
18 * ??-???-2005: Someone at Compulab 18 * ??-???-2005: Someone at Compulab
19 * - Initial driver creation. 19 * - Initial driver creation.
@@ -259,11 +259,11 @@ static int __devexit max6902_remove(struct spi_device *spi)
259 259
260static struct spi_driver max6902_driver = { 260static struct spi_driver max6902_driver = {
261 .driver = { 261 .driver = {
262 .name = "max6902", 262 .name = "rtc-max6902",
263 .bus = &spi_bus_type, 263 .bus = &spi_bus_type,
264 .owner = THIS_MODULE, 264 .owner = THIS_MODULE,
265 }, 265 },
266 .probe = max6902_probe, 266 .probe = max6902_probe,
267 .remove = __devexit_p(max6902_remove), 267 .remove = __devexit_p(max6902_remove),
268}; 268};
269 269
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c
index f50f3fc353cd..839462659afa 100644
--- a/drivers/rtc/rtc-rs5c348.c
+++ b/drivers/rtc/rtc-rs5c348.c
@@ -226,7 +226,7 @@ static int __devexit rs5c348_remove(struct spi_device *spi)
226 226
227static struct spi_driver rs5c348_driver = { 227static struct spi_driver rs5c348_driver = {
228 .driver = { 228 .driver = {
229 .name = "rs5c348", 229 .name = "rtc-rs5c348",
230 .bus = &spi_bus_type, 230 .bus = &spi_bus_type,
231 .owner = THIS_MODULE, 231 .owner = THIS_MODULE,
232 }, 232 },
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index eccac1c3b71b..d32c60dbdd82 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -24,6 +24,7 @@
24#include <asm/s390_ext.h> 24#include <asm/s390_ext.h>
25#include <asm/todclk.h> 25#include <asm/todclk.h>
26#include <asm/vtoc.h> 26#include <asm/vtoc.h>
27#include <asm/diag.h>
27 28
28#include "dasd_int.h" 29#include "dasd_int.h"
29#include "dasd_diag.h" 30#include "dasd_diag.h"
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index 4f2f81b16cfa..2edd5fb6d3dc 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -21,6 +21,7 @@
21#include <asm/ccwdev.h> 21#include <asm/ccwdev.h>
22#include <asm/cio.h> 22#include <asm/cio.h>
23#include <asm/ebcdic.h> 23#include <asm/ebcdic.h>
24#include <asm/diag.h>
24 25
25#include "raw3270.h" 26#include "raw3270.h"
26 27
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index 04b19bdc09da..d70a6e65bf14 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -14,6 +14,7 @@
14#include <asm/cio.h> 14#include <asm/cio.h>
15#include <asm/ccwdev.h> 15#include <asm/ccwdev.h>
16#include <asm/debug.h> 16#include <asm/debug.h>
17#include <asm/diag.h>
17 18
18#include "vmur.h" 19#include "vmur.h"
19 20
@@ -68,8 +69,26 @@ static struct ccw_driver ur_driver = {
68 .set_offline = ur_set_offline, 69 .set_offline = ur_set_offline,
69}; 70};
70 71
72static DEFINE_MUTEX(vmur_mutex);
73
71/* 74/*
72 * Allocation, freeing, getting and putting of urdev structures 75 * Allocation, freeing, getting and putting of urdev structures
76 *
77 * Each ur device (urd) contains a reference to its corresponding ccw device
78 * (cdev) using the urd->cdev pointer. Each ccw device has a reference to the
79 * ur device using the cdev->dev.driver_data pointer.
80 *
81 * urd references:
82 * - ur_probe gets a urd reference, ur_remove drops the reference
83 * (cdev->dev.driver_data)
84 * - ur_open gets a urd reference, ur_relase drops the reference
85 * (urf->urd)
86 *
87 * cdev references:
88 * - urdev_alloc get a cdev reference (urd->cdev)
89 * - urdev_free drops the cdev reference (urd->cdev)
90 *
91 * Setting and clearing of cdev->dev.driver_data is protected by the ccwdev lock
73 */ 92 */
74static struct urdev *urdev_alloc(struct ccw_device *cdev) 93static struct urdev *urdev_alloc(struct ccw_device *cdev)
75{ 94{
@@ -78,42 +97,61 @@ static struct urdev *urdev_alloc(struct ccw_device *cdev)
78 urd = kzalloc(sizeof(struct urdev), GFP_KERNEL); 97 urd = kzalloc(sizeof(struct urdev), GFP_KERNEL);
79 if (!urd) 98 if (!urd)
80 return NULL; 99 return NULL;
81 urd->cdev = cdev;
82 urd->reclen = cdev->id.driver_info; 100 urd->reclen = cdev->id.driver_info;
83 ccw_device_get_id(cdev, &urd->dev_id); 101 ccw_device_get_id(cdev, &urd->dev_id);
84 mutex_init(&urd->io_mutex); 102 mutex_init(&urd->io_mutex);
85 mutex_init(&urd->open_mutex); 103 mutex_init(&urd->open_mutex);
104 atomic_set(&urd->ref_count, 1);
105 urd->cdev = cdev;
106 get_device(&cdev->dev);
86 return urd; 107 return urd;
87} 108}
88 109
89static void urdev_free(struct urdev *urd) 110static void urdev_free(struct urdev *urd)
90{ 111{
112 TRACE("urdev_free: %p\n", urd);
113 if (urd->cdev)
114 put_device(&urd->cdev->dev);
91 kfree(urd); 115 kfree(urd);
92} 116}
93 117
94/* 118static void urdev_get(struct urdev *urd)
95 * This is how the character device driver gets a reference to a 119{
96 * ur device. When this call returns successfully, a reference has 120 atomic_inc(&urd->ref_count);
97 * been taken (by get_device) on the underlying kobject. The recipient 121}
98 * of this urdev pointer must eventually drop it with urdev_put(urd) 122
99 * which does the corresponding put_device(). 123static struct urdev *urdev_get_from_cdev(struct ccw_device *cdev)
100 */ 124{
125 struct urdev *urd;
126 unsigned long flags;
127
128 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
129 urd = cdev->dev.driver_data;
130 if (urd)
131 urdev_get(urd);
132 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
133 return urd;
134}
135
101static struct urdev *urdev_get_from_devno(u16 devno) 136static struct urdev *urdev_get_from_devno(u16 devno)
102{ 137{
103 char bus_id[16]; 138 char bus_id[16];
104 struct ccw_device *cdev; 139 struct ccw_device *cdev;
140 struct urdev *urd;
105 141
106 sprintf(bus_id, "0.0.%04x", devno); 142 sprintf(bus_id, "0.0.%04x", devno);
107 cdev = get_ccwdev_by_busid(&ur_driver, bus_id); 143 cdev = get_ccwdev_by_busid(&ur_driver, bus_id);
108 if (!cdev) 144 if (!cdev)
109 return NULL; 145 return NULL;
110 146 urd = urdev_get_from_cdev(cdev);
111 return cdev->dev.driver_data; 147 put_device(&cdev->dev);
148 return urd;
112} 149}
113 150
114static void urdev_put(struct urdev *urd) 151static void urdev_put(struct urdev *urd)
115{ 152{
116 put_device(&urd->cdev->dev); 153 if (atomic_dec_and_test(&urd->ref_count))
154 urdev_free(urd);
117} 155}
118 156
119/* 157/*
@@ -245,6 +283,7 @@ static void ur_int_handler(struct ccw_device *cdev, unsigned long intparm,
245 return; 283 return;
246 } 284 }
247 urd = cdev->dev.driver_data; 285 urd = cdev->dev.driver_data;
286 BUG_ON(!urd);
248 /* On special conditions irb is an error pointer */ 287 /* On special conditions irb is an error pointer */
249 if (IS_ERR(irb)) 288 if (IS_ERR(irb))
250 urd->io_request_rc = PTR_ERR(irb); 289 urd->io_request_rc = PTR_ERR(irb);
@@ -262,9 +301,15 @@ static void ur_int_handler(struct ccw_device *cdev, unsigned long intparm,
262static ssize_t ur_attr_reclen_show(struct device *dev, 301static ssize_t ur_attr_reclen_show(struct device *dev,
263 struct device_attribute *attr, char *buf) 302 struct device_attribute *attr, char *buf)
264{ 303{
265 struct urdev *urd = dev->driver_data; 304 struct urdev *urd;
305 int rc;
266 306
267 return sprintf(buf, "%zu\n", urd->reclen); 307 urd = urdev_get_from_cdev(to_ccwdev(dev));
308 if (!urd)
309 return -ENODEV;
310 rc = sprintf(buf, "%zu\n", urd->reclen);
311 urdev_put(urd);
312 return rc;
268} 313}
269 314
270static DEVICE_ATTR(reclen, 0444, ur_attr_reclen_show, NULL); 315static DEVICE_ATTR(reclen, 0444, ur_attr_reclen_show, NULL);
@@ -379,31 +424,6 @@ static ssize_t ur_write(struct file *file, const char __user *udata,
379 return do_write(urf->urd, udata, count, urf->dev_reclen, ppos); 424 return do_write(urf->urd, udata, count, urf->dev_reclen, ppos);
380} 425}
381 426
382static int do_diag_14(unsigned long rx, unsigned long ry1,
383 unsigned long subcode)
384{
385 register unsigned long _ry1 asm("2") = ry1;
386 register unsigned long _ry2 asm("3") = subcode;
387 int rc = 0;
388
389 asm volatile(
390#ifdef CONFIG_64BIT
391 " sam31\n"
392 " diag %2,2,0x14\n"
393 " sam64\n"
394#else
395 " diag %2,2,0x14\n"
396#endif
397 " ipm %0\n"
398 " srl %0,28\n"
399 : "=d" (rc), "+d" (_ry2)
400 : "d" (rx), "d" (_ry1)
401 : "cc");
402
403 TRACE("diag 14: subcode=0x%lx, cc=%i\n", subcode, rc);
404 return rc;
405}
406
407/* 427/*
408 * diagnose code 0x14 subcode 0x0028 - position spool file to designated 428 * diagnose code 0x14 subcode 0x0028 - position spool file to designated
409 * record 429 * record
@@ -415,7 +435,7 @@ static int diag_position_to_record(int devno, int record)
415{ 435{
416 int cc; 436 int cc;
417 437
418 cc = do_diag_14(record, devno, 0x28); 438 cc = diag14(record, devno, 0x28);
419 switch (cc) { 439 switch (cc) {
420 case 0: 440 case 0:
421 return 0; 441 return 0;
@@ -440,7 +460,7 @@ static int diag_read_file(int devno, char *buf)
440{ 460{
441 int cc; 461 int cc;
442 462
443 cc = do_diag_14((unsigned long) buf, devno, 0x00); 463 cc = diag14((unsigned long) buf, devno, 0x00);
444 switch (cc) { 464 switch (cc) {
445 case 0: 465 case 0:
446 return 0; 466 return 0;
@@ -533,7 +553,7 @@ static int diag_read_next_file_info(struct file_control_block *buf, int spid)
533{ 553{
534 int cc; 554 int cc;
535 555
536 cc = do_diag_14((unsigned long) buf, spid, 0xfff); 556 cc = diag14((unsigned long) buf, spid, 0xfff);
537 switch (cc) { 557 switch (cc) {
538 case 0: 558 case 0:
539 return 0; 559 return 0;
@@ -750,64 +770,63 @@ static struct file_operations ur_fops = {
750 770
751/* 771/*
752 * ccw_device infrastructure: 772 * ccw_device infrastructure:
753 * ur_probe gets its own ref to the device (i.e. get_device), 773 * ur_probe creates the struct urdev (with refcount = 1), the device
754 * creates the struct urdev, the device attributes, sets up 774 * attributes, sets up the interrupt handler and validates the virtual
755 * the interrupt handler and validates the virtual unit record device. 775 * unit record device.
756 * ur_remove removes the device attributes, frees the struct urdev 776 * ur_remove removes the device attributes and drops the reference to
757 * and drops (put_device) the ref to the device we got in ur_probe. 777 * struct urdev.
778 *
779 * ur_probe, ur_remove, ur_set_online and ur_set_offline are serialized
780 * by the vmur_mutex lock.
781 *
782 * urd->char_device is used as indication that the online function has
783 * been completed successfully.
758 */ 784 */
759static int ur_probe(struct ccw_device *cdev) 785static int ur_probe(struct ccw_device *cdev)
760{ 786{
761 struct urdev *urd; 787 struct urdev *urd;
762 int rc; 788 int rc;
763 789
764 TRACE("ur_probe: cdev=%p state=%d\n", cdev, *(int *) cdev->private); 790 TRACE("ur_probe: cdev=%p\n", cdev);
765
766 if (!get_device(&cdev->dev))
767 return -ENODEV;
768 791
792 mutex_lock(&vmur_mutex);
769 urd = urdev_alloc(cdev); 793 urd = urdev_alloc(cdev);
770 if (!urd) { 794 if (!urd) {
771 rc = -ENOMEM; 795 rc = -ENOMEM;
772 goto fail; 796 goto fail_unlock;
773 } 797 }
798
774 rc = ur_create_attributes(&cdev->dev); 799 rc = ur_create_attributes(&cdev->dev);
775 if (rc) { 800 if (rc) {
776 rc = -ENOMEM; 801 rc = -ENOMEM;
777 goto fail; 802 goto fail_urdev_put;
778 } 803 }
779 cdev->dev.driver_data = urd;
780 cdev->handler = ur_int_handler; 804 cdev->handler = ur_int_handler;
781 805
782 /* validate virtual unit record device */ 806 /* validate virtual unit record device */
783 urd->class = get_urd_class(urd); 807 urd->class = get_urd_class(urd);
784 if (urd->class < 0) { 808 if (urd->class < 0) {
785 rc = urd->class; 809 rc = urd->class;
786 goto fail; 810 goto fail_remove_attr;
787 } 811 }
788 if ((urd->class != DEV_CLASS_UR_I) && (urd->class != DEV_CLASS_UR_O)) { 812 if ((urd->class != DEV_CLASS_UR_I) && (urd->class != DEV_CLASS_UR_O)) {
789 rc = -ENOTSUPP; 813 rc = -ENOTSUPP;
790 goto fail; 814 goto fail_remove_attr;
791 } 815 }
816 spin_lock_irq(get_ccwdev_lock(cdev));
817 cdev->dev.driver_data = urd;
818 spin_unlock_irq(get_ccwdev_lock(cdev));
792 819
820 mutex_unlock(&vmur_mutex);
793 return 0; 821 return 0;
794 822
795fail: 823fail_remove_attr:
796 urdev_free(urd);
797 put_device(&cdev->dev);
798 return rc;
799}
800
801static void ur_remove(struct ccw_device *cdev)
802{
803 struct urdev *urd = cdev->dev.driver_data;
804
805 TRACE("ur_remove\n");
806 if (cdev->online)
807 ur_set_offline(cdev);
808 ur_remove_attributes(&cdev->dev); 824 ur_remove_attributes(&cdev->dev);
809 urdev_free(urd); 825fail_urdev_put:
810 put_device(&cdev->dev); 826 urdev_put(urd);
827fail_unlock:
828 mutex_unlock(&vmur_mutex);
829 return rc;
811} 830}
812 831
813static int ur_set_online(struct ccw_device *cdev) 832static int ur_set_online(struct ccw_device *cdev)
@@ -816,20 +835,29 @@ static int ur_set_online(struct ccw_device *cdev)
816 int minor, major, rc; 835 int minor, major, rc;
817 char node_id[16]; 836 char node_id[16];
818 837
819 TRACE("ur_set_online: cdev=%p state=%d\n", cdev, 838 TRACE("ur_set_online: cdev=%p\n", cdev);
820 *(int *) cdev->private);
821 839
822 if (!try_module_get(ur_driver.owner)) 840 mutex_lock(&vmur_mutex);
823 return -EINVAL; 841 urd = urdev_get_from_cdev(cdev);
842 if (!urd) {
843 /* ur_remove already deleted our urd */
844 rc = -ENODEV;
845 goto fail_unlock;
846 }
847
848 if (urd->char_device) {
849 /* Another ur_set_online was faster */
850 rc = -EBUSY;
851 goto fail_urdev_put;
852 }
824 853
825 urd = (struct urdev *) cdev->dev.driver_data;
826 minor = urd->dev_id.devno; 854 minor = urd->dev_id.devno;
827 major = MAJOR(ur_first_dev_maj_min); 855 major = MAJOR(ur_first_dev_maj_min);
828 856
829 urd->char_device = cdev_alloc(); 857 urd->char_device = cdev_alloc();
830 if (!urd->char_device) { 858 if (!urd->char_device) {
831 rc = -ENOMEM; 859 rc = -ENOMEM;
832 goto fail_module_put; 860 goto fail_urdev_put;
833 } 861 }
834 862
835 cdev_init(urd->char_device, &ur_fops); 863 cdev_init(urd->char_device, &ur_fops);
@@ -858,29 +886,79 @@ static int ur_set_online(struct ccw_device *cdev)
858 TRACE("ur_set_online: device_create rc=%d\n", rc); 886 TRACE("ur_set_online: device_create rc=%d\n", rc);
859 goto fail_free_cdev; 887 goto fail_free_cdev;
860 } 888 }
861 889 urdev_put(urd);
890 mutex_unlock(&vmur_mutex);
862 return 0; 891 return 0;
863 892
864fail_free_cdev: 893fail_free_cdev:
865 cdev_del(urd->char_device); 894 cdev_del(urd->char_device);
866fail_module_put: 895 urd->char_device = NULL;
867 module_put(ur_driver.owner); 896fail_urdev_put:
868 897 urdev_put(urd);
898fail_unlock:
899 mutex_unlock(&vmur_mutex);
869 return rc; 900 return rc;
870} 901}
871 902
872static int ur_set_offline(struct ccw_device *cdev) 903static int ur_set_offline_force(struct ccw_device *cdev, int force)
873{ 904{
874 struct urdev *urd; 905 struct urdev *urd;
906 int rc;
875 907
876 TRACE("ur_set_offline: cdev=%p cdev->private=%p state=%d\n", 908 TRACE("ur_set_offline: cdev=%p\n", cdev);
877 cdev, cdev->private, *(int *) cdev->private); 909 urd = urdev_get_from_cdev(cdev);
878 urd = (struct urdev *) cdev->dev.driver_data; 910 if (!urd)
911 /* ur_remove already deleted our urd */
912 return -ENODEV;
913 if (!urd->char_device) {
914 /* Another ur_set_offline was faster */
915 rc = -EBUSY;
916 goto fail_urdev_put;
917 }
918 if (!force && (atomic_read(&urd->ref_count) > 2)) {
919 /* There is still a user of urd (e.g. ur_open) */
920 TRACE("ur_set_offline: BUSY\n");
921 rc = -EBUSY;
922 goto fail_urdev_put;
923 }
879 device_destroy(vmur_class, urd->char_device->dev); 924 device_destroy(vmur_class, urd->char_device->dev);
880 cdev_del(urd->char_device); 925 cdev_del(urd->char_device);
881 module_put(ur_driver.owner); 926 urd->char_device = NULL;
927 rc = 0;
882 928
883 return 0; 929fail_urdev_put:
930 urdev_put(urd);
931 return rc;
932}
933
934static int ur_set_offline(struct ccw_device *cdev)
935{
936 int rc;
937
938 mutex_lock(&vmur_mutex);
939 rc = ur_set_offline_force(cdev, 0);
940 mutex_unlock(&vmur_mutex);
941 return rc;
942}
943
944static void ur_remove(struct ccw_device *cdev)
945{
946 unsigned long flags;
947
948 TRACE("ur_remove\n");
949
950 mutex_lock(&vmur_mutex);
951
952 if (cdev->online)
953 ur_set_offline_force(cdev, 1);
954 ur_remove_attributes(&cdev->dev);
955
956 spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
957 urdev_put(cdev->dev.driver_data);
958 cdev->dev.driver_data = NULL;
959 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
960
961 mutex_unlock(&vmur_mutex);
884} 962}
885 963
886/* 964/*
diff --git a/drivers/s390/char/vmur.h b/drivers/s390/char/vmur.h
index 2b3c564e0472..fa959644735a 100644
--- a/drivers/s390/char/vmur.h
+++ b/drivers/s390/char/vmur.h
@@ -70,6 +70,7 @@ struct urdev {
70 size_t reclen; /* Record length for *write* CCWs */ 70 size_t reclen; /* Record length for *write* CCWs */
71 int class; /* VM device class */ 71 int class; /* VM device class */
72 int io_request_rc; /* return code from I/O request */ 72 int io_request_rc; /* return code from I/O request */
73 atomic_t ref_count; /* reference counter */
73}; 74};
74 75
75/* 76/*
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 02fd00b55e1b..34a796913b06 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -594,6 +594,9 @@ alloc_cmb (struct ccw_device *cdev)
594 free_pages((unsigned long)mem, get_order(size)); 594 free_pages((unsigned long)mem, get_order(size));
595 } else if (!mem) { 595 } else if (!mem) {
596 /* no luck */ 596 /* no luck */
597 printk(KERN_WARNING "cio: failed to allocate area "
598 "for measuring %d subchannels\n",
599 cmb_area.num_channels);
597 ret = -ENOMEM; 600 ret = -ENOMEM;
598 goto out; 601 goto out;
599 } else { 602 } else {
@@ -1279,13 +1282,6 @@ init_cmf(void)
1279 case CMF_BASIC: 1282 case CMF_BASIC:
1280 format_string = "basic"; 1283 format_string = "basic";
1281 cmbops = &cmbops_basic; 1284 cmbops = &cmbops_basic;
1282 if (cmb_area.num_channels > 4096 || cmb_area.num_channels < 1) {
1283 printk(KERN_ERR "cio: Basic channel measurement "
1284 "facility can only use 1 to 4096 devices\n"
1285 KERN_ERR "when the cmf driver is built"
1286 " as a loadable module\n");
1287 return 1;
1288 }
1289 break; 1285 break;
1290 case CMF_EXTENDED: 1286 case CMF_EXTENDED:
1291 format_string = "extended"; 1287 format_string = "extended";
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 297659fa0e26..e44d92eac8e9 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -117,7 +117,10 @@ static int ccw_uevent(struct device *dev, char **envp, int num_envp,
117 snprint_alias(modalias_buf, sizeof(modalias_buf), id, ""); 117 snprint_alias(modalias_buf, sizeof(modalias_buf), id, "");
118 ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, 118 ret = add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len,
119 "MODALIAS=%s", modalias_buf); 119 "MODALIAS=%s", modalias_buf);
120 return ret; 120 if (ret)
121 return ret;
122 envp[i] = NULL;
123 return 0;
121} 124}
122 125
123struct bus_type ccw_bus_type; 126struct bus_type ccw_bus_type;
diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c
index 60b9347f7c92..f232832f2b22 100644
--- a/drivers/s390/cio/device_id.c
+++ b/drivers/s390/cio/device_id.c
@@ -17,6 +17,7 @@
17#include <asm/delay.h> 17#include <asm/delay.h>
18#include <asm/cio.h> 18#include <asm/cio.h>
19#include <asm/lowcore.h> 19#include <asm/lowcore.h>
20#include <asm/diag.h>
20 21
21#include "cio.h" 22#include "cio.h"
22#include "cio_debug.h" 23#include "cio_debug.h"
@@ -25,51 +26,6 @@
25#include "ioasm.h" 26#include "ioasm.h"
26 27
27/* 28/*
28 * diag210 is used under VM to get information about a virtual device
29 */
30int
31diag210(struct diag210 * addr)
32{
33 /*
34 * diag 210 needs its data below the 2GB border, so we
35 * use a static data area to be sure
36 */
37 static struct diag210 diag210_tmp;
38 static DEFINE_SPINLOCK(diag210_lock);
39 unsigned long flags;
40 int ccode;
41
42 spin_lock_irqsave(&diag210_lock, flags);
43 diag210_tmp = *addr;
44
45#ifdef CONFIG_64BIT
46 asm volatile(
47 " lhi %0,-1\n"
48 " sam31\n"
49 " diag %1,0,0x210\n"
50 "0: ipm %0\n"
51 " srl %0,28\n"
52 "1: sam64\n"
53 EX_TABLE(0b,1b)
54 : "=&d" (ccode) : "a" (&diag210_tmp) : "cc", "memory");
55#else
56 asm volatile(
57 " lhi %0,-1\n"
58 " diag %1,0,0x210\n"
59 "0: ipm %0\n"
60 " srl %0,28\n"
61 "1:\n"
62 EX_TABLE(0b,1b)
63 : "=&d" (ccode) : "a" (&diag210_tmp) : "cc", "memory");
64#endif
65
66 *addr = diag210_tmp;
67 spin_unlock_irqrestore(&diag210_lock, flags);
68
69 return ccode;
70}
71
72/*
73 * Input : 29 * Input :
74 * devno - device number 30 * devno - device number
75 * ps - pointer to sense ID data area 31 * ps - pointer to sense ID data area
@@ -349,5 +305,3 @@ ccw_device_sense_id_irq(struct ccw_device *cdev, enum dev_event dev_event)
349 break; 305 break;
350 } 306 }
351} 307}
352
353EXPORT_SYMBOL(diag210);
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 03347aed2b3e..d8d479876ec7 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -195,6 +195,8 @@ qdio_do_eqbs(struct qdio_q *q, unsigned char *state,
195again: 195again:
196 ccq = do_eqbs(irq->sch_token, state, q_no, start, cnt); 196 ccq = do_eqbs(irq->sch_token, state, q_no, start, cnt);
197 rc = qdio_check_ccq(q, ccq); 197 rc = qdio_check_ccq(q, ccq);
198 if ((ccq == 96) && (tmp_cnt != *cnt))
199 rc = 0;
198 if (rc == 1) { 200 if (rc == 1) {
199 QDIO_DBF_TEXT5(1,trace,"eqAGAIN"); 201 QDIO_DBF_TEXT5(1,trace,"eqAGAIN");
200 goto again; 202 goto again;
@@ -740,7 +742,8 @@ qdio_get_outbound_buffer_frontier(struct qdio_q *q)
740 first_not_to_check=f+qdio_min(atomic_read(&q->number_of_buffers_used), 742 first_not_to_check=f+qdio_min(atomic_read(&q->number_of_buffers_used),
741 (QDIO_MAX_BUFFERS_PER_Q-1)); 743 (QDIO_MAX_BUFFERS_PER_Q-1));
742 744
743 if ((!q->is_iqdio_q)&&(!q->hydra_gives_outbound_pcis)) 745 if (((!q->is_iqdio_q) && (!q->hydra_gives_outbound_pcis)) ||
746 (q->queue_type == QDIO_IQDIO_QFMT_ASYNCH))
744 SYNC_MEMORY; 747 SYNC_MEMORY;
745 748
746check_next: 749check_next:
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index d2b3898b750a..6f2c71ef47ee 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -367,6 +367,7 @@ config SCSI_3W_9XXX
367config SCSI_7000FASST 367config SCSI_7000FASST
368 tristate "7000FASST SCSI support" 368 tristate "7000FASST SCSI support"
369 depends on ISA && SCSI && ISA_DMA_API 369 depends on ISA && SCSI && ISA_DMA_API
370 select CHECK_SIGNATURE
370 help 371 help
371 This driver supports the Western Digital 7000 SCSI host adapter 372 This driver supports the Western Digital 7000 SCSI host adapter
372 family. Some information is in the source: 373 family. Some information is in the source:
@@ -388,6 +389,7 @@ config SCSI_AHA152X
388 tristate "Adaptec AHA152X/2825 support" 389 tristate "Adaptec AHA152X/2825 support"
389 depends on ISA && SCSI && !64BIT 390 depends on ISA && SCSI && !64BIT
390 select SCSI_SPI_ATTRS 391 select SCSI_SPI_ATTRS
392 select CHECK_SIGNATURE
391 ---help--- 393 ---help---
392 This is a driver for the AHA-1510, AHA-1520, AHA-1522, and AHA-2825 394 This is a driver for the AHA-1510, AHA-1520, AHA-1522, and AHA-2825
393 SCSI host adapters. It also works for the AVA-1505, but the IRQ etc. 395 SCSI host adapters. It also works for the AVA-1505, but the IRQ etc.
@@ -583,6 +585,7 @@ config SCSI_DTC3280
583 tristate "DTC3180/3280 SCSI support" 585 tristate "DTC3180/3280 SCSI support"
584 depends on ISA && SCSI 586 depends on ISA && SCSI
585 select SCSI_SPI_ATTRS 587 select SCSI_SPI_ATTRS
588 select CHECK_SIGNATURE
586 help 589 help
587 This is support for DTC 3180/3280 SCSI Host Adapters. Please read 590 This is support for DTC 3180/3280 SCSI Host Adapters. Please read
588 the SCSI-HOWTO, available from 591 the SCSI-HOWTO, available from
@@ -657,6 +660,7 @@ config SCSI_EATA_PIO
657config SCSI_FUTURE_DOMAIN 660config SCSI_FUTURE_DOMAIN
658 tristate "Future Domain 16xx SCSI/AHA-2920A support" 661 tristate "Future Domain 16xx SCSI/AHA-2920A support"
659 depends on (ISA || PCI) && SCSI 662 depends on (ISA || PCI) && SCSI
663 select CHECK_SIGNATURE
660 ---help--- 664 ---help---
661 This is support for Future Domain's 16-bit SCSI host adapters 665 This is support for Future Domain's 16-bit SCSI host adapters
662 (TMC-1660/1680, TMC-1650/1670, TMC-3260, TMC-1610M/MER/MEX) and 666 (TMC-1660/1680, TMC-1650/1670, TMC-3260, TMC-1610M/MER/MEX) and
@@ -1324,6 +1328,7 @@ config SCSI_LPFC
1324config SCSI_SEAGATE 1328config SCSI_SEAGATE
1325 tristate "Seagate ST-02 and Future Domain TMC-8xx SCSI support" 1329 tristate "Seagate ST-02 and Future Domain TMC-8xx SCSI support"
1326 depends on X86 && ISA && SCSI 1330 depends on X86 && ISA && SCSI
1331 select CHECK_SIGNATURE
1327 ---help--- 1332 ---help---
1328 These are 8-bit SCSI controllers; the ST-01 is also supported by 1333 These are 8-bit SCSI controllers; the ST-01 is also supported by
1329 this driver. It is explained in section 3.9 of the SCSI-HOWTO, 1334 this driver. It is explained in section 3.9 of the SCSI-HOWTO,
@@ -1397,6 +1402,7 @@ config SCSI_T128
1397 tristate "Trantor T128/T128F/T228 SCSI support" 1402 tristate "Trantor T128/T128F/T228 SCSI support"
1398 depends on ISA && SCSI 1403 depends on ISA && SCSI
1399 select SCSI_SPI_ATTRS 1404 select SCSI_SPI_ATTRS
1405 select CHECK_SIGNATURE
1400 ---help--- 1406 ---help---
1401 This is support for a SCSI host adapter. It is explained in section 1407 This is support for a SCSI host adapter. It is explained in section
1402 3.11 of the SCSI-HOWTO, available from 1408 3.11 of the SCSI-HOWTO, available from
@@ -1561,7 +1567,7 @@ config A3000_SCSI
1561 built-in SCSI controller, say Y. Otherwise, say N. 1567 built-in SCSI controller, say Y. Otherwise, say N.
1562 1568
1563 To compile this driver as a module, choose M here: the 1569 To compile this driver as a module, choose M here: the
1564 module will be called wd33c93. 1570 module will be called a3000.
1565 1571
1566config A2091_SCSI 1572config A2091_SCSI
1567 tristate "A2091/A590 WD33C93A support" 1573 tristate "A2091/A590 WD33C93A support"
@@ -1571,7 +1577,7 @@ config A2091_SCSI
1571 say N. 1577 say N.
1572 1578
1573 To compile this driver as a module, choose M here: the 1579 To compile this driver as a module, choose M here: the
1574 module will be called wd33c93. 1580 module will be called a2091.
1575 1581
1576config GVP11_SCSI 1582config GVP11_SCSI
1577 tristate "GVP Series II WD33C93A support" 1583 tristate "GVP Series II WD33C93A support"
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 301313002f6b..f94109cbb46e 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -129,7 +129,16 @@ struct uart_8250_port {
129 unsigned char mcr; 129 unsigned char mcr;
130 unsigned char mcr_mask; /* mask of user bits */ 130 unsigned char mcr_mask; /* mask of user bits */
131 unsigned char mcr_force; /* mask of forced bits */ 131 unsigned char mcr_force; /* mask of forced bits */
132 unsigned char lsr_break_flag; 132
133 /*
134 * Some bits in registers are cleared on a read, so they must
135 * be saved whenever the register is read but the bits will not
136 * be immediately processed.
137 */
138#define LSR_SAVE_FLAGS UART_LSR_BRK_ERROR_BITS
139 unsigned char lsr_saved_flags;
140#define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA
141 unsigned char msr_saved_flags;
133 142
134 /* 143 /*
135 * We provide a per-port pm hook. 144 * We provide a per-port pm hook.
@@ -1238,6 +1247,7 @@ static void serial8250_start_tx(struct uart_port *port)
1238 if (up->bugs & UART_BUG_TXEN) { 1247 if (up->bugs & UART_BUG_TXEN) {
1239 unsigned char lsr, iir; 1248 unsigned char lsr, iir;
1240 lsr = serial_in(up, UART_LSR); 1249 lsr = serial_in(up, UART_LSR);
1250 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
1241 iir = serial_in(up, UART_IIR) & 0x0f; 1251 iir = serial_in(up, UART_IIR) & 0x0f;
1242 if ((up->port.type == PORT_RM9000) ? 1252 if ((up->port.type == PORT_RM9000) ?
1243 (lsr & UART_LSR_THRE && 1253 (lsr & UART_LSR_THRE &&
@@ -1290,18 +1300,10 @@ receive_chars(struct uart_8250_port *up, unsigned int *status)
1290 flag = TTY_NORMAL; 1300 flag = TTY_NORMAL;
1291 up->port.icount.rx++; 1301 up->port.icount.rx++;
1292 1302
1293#ifdef CONFIG_SERIAL_8250_CONSOLE 1303 lsr |= up->lsr_saved_flags;
1294 /* 1304 up->lsr_saved_flags = 0;
1295 * Recover the break flag from console xmit
1296 */
1297 if (up->port.line == up->port.cons->index) {
1298 lsr |= up->lsr_break_flag;
1299 up->lsr_break_flag = 0;
1300 }
1301#endif
1302 1305
1303 if (unlikely(lsr & (UART_LSR_BI | UART_LSR_PE | 1306 if (unlikely(lsr & UART_LSR_BRK_ERROR_BITS)) {
1304 UART_LSR_FE | UART_LSR_OE))) {
1305 /* 1307 /*
1306 * For statistics only 1308 * For statistics only
1307 */ 1309 */
@@ -1392,6 +1394,8 @@ static unsigned int check_modem_status(struct uart_8250_port *up)
1392{ 1394{
1393 unsigned int status = serial_in(up, UART_MSR); 1395 unsigned int status = serial_in(up, UART_MSR);
1394 1396
1397 status |= up->msr_saved_flags;
1398 up->msr_saved_flags = 0;
1395 if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI && 1399 if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI &&
1396 up->port.info != NULL) { 1400 up->port.info != NULL) {
1397 if (status & UART_MSR_TERI) 1401 if (status & UART_MSR_TERI)
@@ -1591,7 +1595,8 @@ static void serial8250_timeout(unsigned long data)
1591static void serial8250_backup_timeout(unsigned long data) 1595static void serial8250_backup_timeout(unsigned long data)
1592{ 1596{
1593 struct uart_8250_port *up = (struct uart_8250_port *)data; 1597 struct uart_8250_port *up = (struct uart_8250_port *)data;
1594 unsigned int iir, ier = 0; 1598 unsigned int iir, ier = 0, lsr;
1599 unsigned long flags;
1595 1600
1596 /* 1601 /*
1597 * Must disable interrupts or else we risk racing with the interrupt 1602 * Must disable interrupts or else we risk racing with the interrupt
@@ -1610,9 +1615,13 @@ static void serial8250_backup_timeout(unsigned long data)
1610 * the "Diva" UART used on the management processor on many HP 1615 * the "Diva" UART used on the management processor on many HP
1611 * ia64 and parisc boxes. 1616 * ia64 and parisc boxes.
1612 */ 1617 */
1618 spin_lock_irqsave(&up->port.lock, flags);
1619 lsr = serial_in(up, UART_LSR);
1620 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
1621 spin_unlock_irqrestore(&up->port.lock, flags);
1613 if ((iir & UART_IIR_NO_INT) && (up->ier & UART_IER_THRI) && 1622 if ((iir & UART_IIR_NO_INT) && (up->ier & UART_IER_THRI) &&
1614 (!uart_circ_empty(&up->port.info->xmit) || up->port.x_char) && 1623 (!uart_circ_empty(&up->port.info->xmit) || up->port.x_char) &&
1615 (serial_in(up, UART_LSR) & UART_LSR_THRE)) { 1624 (lsr & UART_LSR_THRE)) {
1616 iir &= ~(UART_IIR_ID | UART_IIR_NO_INT); 1625 iir &= ~(UART_IIR_ID | UART_IIR_NO_INT);
1617 iir |= UART_IIR_THRI; 1626 iir |= UART_IIR_THRI;
1618 } 1627 }
@@ -1631,13 +1640,14 @@ static unsigned int serial8250_tx_empty(struct uart_port *port)
1631{ 1640{
1632 struct uart_8250_port *up = (struct uart_8250_port *)port; 1641 struct uart_8250_port *up = (struct uart_8250_port *)port;
1633 unsigned long flags; 1642 unsigned long flags;
1634 unsigned int ret; 1643 unsigned int lsr;
1635 1644
1636 spin_lock_irqsave(&up->port.lock, flags); 1645 spin_lock_irqsave(&up->port.lock, flags);
1637 ret = serial_in(up, UART_LSR) & UART_LSR_TEMT ? TIOCSER_TEMT : 0; 1646 lsr = serial_in(up, UART_LSR);
1647 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
1638 spin_unlock_irqrestore(&up->port.lock, flags); 1648 spin_unlock_irqrestore(&up->port.lock, flags);
1639 1649
1640 return ret; 1650 return lsr & UART_LSR_TEMT ? TIOCSER_TEMT : 0;
1641} 1651}
1642 1652
1643static unsigned int serial8250_get_mctrl(struct uart_port *port) 1653static unsigned int serial8250_get_mctrl(struct uart_port *port)
@@ -1708,8 +1718,7 @@ static inline void wait_for_xmitr(struct uart_8250_port *up, int bits)
1708 do { 1718 do {
1709 status = serial_in(up, UART_LSR); 1719 status = serial_in(up, UART_LSR);
1710 1720
1711 if (status & UART_LSR_BI) 1721 up->lsr_saved_flags |= status & LSR_SAVE_FLAGS;
1712 up->lsr_break_flag = UART_LSR_BI;
1713 1722
1714 if (--tmout == 0) 1723 if (--tmout == 0)
1715 break; 1724 break;
@@ -1718,8 +1727,12 @@ static inline void wait_for_xmitr(struct uart_8250_port *up, int bits)
1718 1727
1719 /* Wait up to 1s for flow control if necessary */ 1728 /* Wait up to 1s for flow control if necessary */
1720 if (up->port.flags & UPF_CONS_FLOW) { 1729 if (up->port.flags & UPF_CONS_FLOW) {
1721 tmout = 1000000; 1730 unsigned int tmout;
1722 while (!(serial_in(up, UART_MSR) & UART_MSR_CTS) && --tmout) { 1731 for (tmout = 1000000; tmout; tmout--) {
1732 unsigned int msr = serial_in(up, UART_MSR);
1733 up->msr_saved_flags |= msr & MSR_SAVE_FLAGS;
1734 if (msr & UART_MSR_CTS)
1735 break;
1723 udelay(1); 1736 udelay(1);
1724 touch_nmi_watchdog(); 1737 touch_nmi_watchdog();
1725 } 1738 }
@@ -1889,6 +1902,18 @@ static int serial8250_startup(struct uart_port *port)
1889 spin_unlock_irqrestore(&up->port.lock, flags); 1902 spin_unlock_irqrestore(&up->port.lock, flags);
1890 1903
1891 /* 1904 /*
1905 * Clear the interrupt registers again for luck, and clear the
1906 * saved flags to avoid getting false values from polling
1907 * routines or the previous session.
1908 */
1909 serial_inp(up, UART_LSR);
1910 serial_inp(up, UART_RX);
1911 serial_inp(up, UART_IIR);
1912 serial_inp(up, UART_MSR);
1913 up->lsr_saved_flags = 0;
1914 up->msr_saved_flags = 0;
1915
1916 /*
1892 * Finally, enable interrupts. Note: Modem status interrupts 1917 * Finally, enable interrupts. Note: Modem status interrupts
1893 * are set via set_termios(), which will be occurring imminently 1918 * are set via set_termios(), which will be occurring imminently
1894 * anyway, so we don't enable them here. 1919 * anyway, so we don't enable them here.
@@ -1906,14 +1931,6 @@ static int serial8250_startup(struct uart_port *port)
1906 (void) inb_p(icp); 1931 (void) inb_p(icp);
1907 } 1932 }
1908 1933
1909 /*
1910 * And clear the interrupt registers again for luck.
1911 */
1912 (void) serial_inp(up, UART_LSR);
1913 (void) serial_inp(up, UART_RX);
1914 (void) serial_inp(up, UART_IIR);
1915 (void) serial_inp(up, UART_MSR);
1916
1917 return 0; 1934 return 0;
1918} 1935}
1919 1936
@@ -2484,6 +2501,16 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
2484 wait_for_xmitr(up, BOTH_EMPTY); 2501 wait_for_xmitr(up, BOTH_EMPTY);
2485 serial_out(up, UART_IER, ier); 2502 serial_out(up, UART_IER, ier);
2486 2503
2504 /*
2505 * The receive handling will happen properly because the
2506 * receive ready bit will still be set; it is not cleared
2507 * on read. However, modem control will not, we must
2508 * call it if we have saved something in the saved flags
2509 * while processing with interrupts off.
2510 */
2511 if (up->msr_saved_flags)
2512 check_modem_status(up);
2513
2487 if (locked) 2514 if (locked)
2488 spin_unlock(&up->port.lock); 2515 spin_unlock(&up->port.lock);
2489 local_irq_restore(flags); 2516 local_irq_restore(flags);
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 5e485876f54c..bd66339f7a3f 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -580,6 +580,138 @@ static int pci_netmos_init(struct pci_dev *dev)
580 return num_serial; 580 return num_serial;
581} 581}
582 582
583/*
584 * ITE support by Niels de Vos <niels.devos@wincor-nixdorf.com>
585 *
586 * These chips are available with optionally one parallel port and up to
587 * two serial ports. Unfortunately they all have the same product id.
588 *
589 * Basic configuration is done over a region of 32 I/O ports. The base
590 * ioport is called INTA or INTC, depending on docs/other drivers.
591 *
592 * The region of the 32 I/O ports is configured in POSIO0R...
593 */
594
595/* registers */
596#define ITE_887x_MISCR 0x9c
597#define ITE_887x_INTCBAR 0x78
598#define ITE_887x_UARTBAR 0x7c
599#define ITE_887x_PS0BAR 0x10
600#define ITE_887x_POSIO0 0x60
601
602/* I/O space size */
603#define ITE_887x_IOSIZE 32
604/* I/O space size (bits 26-24; 8 bytes = 011b) */
605#define ITE_887x_POSIO_IOSIZE_8 (3 << 24)
606/* I/O space size (bits 26-24; 32 bytes = 101b) */
607#define ITE_887x_POSIO_IOSIZE_32 (5 << 24)
608/* Decoding speed (1 = slow, 2 = medium, 3 = fast) */
609#define ITE_887x_POSIO_SPEED (3 << 29)
610/* enable IO_Space bit */
611#define ITE_887x_POSIO_ENABLE (1 << 31)
612
613static int __devinit pci_ite887x_init(struct pci_dev *dev)
614{
615 /* inta_addr are the configuration addresses of the ITE */
616 static const short inta_addr[] = { 0x2a0, 0x2c0, 0x220, 0x240, 0x1e0,
617 0x200, 0x280, 0 };
618 int ret, i, type;
619 struct resource *iobase = NULL;
620 u32 miscr, uartbar, ioport;
621
622 /* search for the base-ioport */
623 i = 0;
624 while (inta_addr[i] && iobase == NULL) {
625 iobase = request_region(inta_addr[i], ITE_887x_IOSIZE,
626 "ite887x");
627 if (iobase != NULL) {
628 /* write POSIO0R - speed | size | ioport */
629 pci_write_config_dword(dev, ITE_887x_POSIO0,
630 ITE_887x_POSIO_ENABLE | ITE_887x_POSIO_SPEED |
631 ITE_887x_POSIO_IOSIZE_32 | inta_addr[i]);
632 /* write INTCBAR - ioport */
633 pci_write_config_dword(dev, ITE_887x_INTCBAR, inta_addr[i]);
634 ret = inb(inta_addr[i]);
635 if (ret != 0xff) {
636 /* ioport connected */
637 break;
638 }
639 release_region(iobase->start, ITE_887x_IOSIZE);
640 iobase = NULL;
641 }
642 i++;
643 }
644
645 if (!inta_addr[i]) {
646 printk(KERN_ERR "ite887x: could not find iobase\n");
647 return -ENODEV;
648 }
649
650 /* start of undocumented type checking (see parport_pc.c) */
651 type = inb(iobase->start + 0x18) & 0x0f;
652
653 switch (type) {
654 case 0x2: /* ITE8871 (1P) */
655 case 0xa: /* ITE8875 (1P) */
656 ret = 0;
657 break;
658 case 0xe: /* ITE8872 (2S1P) */
659 ret = 2;
660 break;
661 case 0x6: /* ITE8873 (1S) */
662 ret = 1;
663 break;
664 case 0x8: /* ITE8874 (2S) */
665 ret = 2;
666 break;
667 default:
668 moan_device("Unknown ITE887x", dev);
669 ret = -ENODEV;
670 }
671
672 /* configure all serial ports */
673 for (i = 0; i < ret; i++) {
674 /* read the I/O port from the device */
675 pci_read_config_dword(dev, ITE_887x_PS0BAR + (0x4 * (i + 1)),
676 &ioport);
677 ioport &= 0x0000FF00; /* the actual base address */
678 pci_write_config_dword(dev, ITE_887x_POSIO0 + (0x4 * (i + 1)),
679 ITE_887x_POSIO_ENABLE | ITE_887x_POSIO_SPEED |
680 ITE_887x_POSIO_IOSIZE_8 | ioport);
681
682 /* write the ioport to the UARTBAR */
683 pci_read_config_dword(dev, ITE_887x_UARTBAR, &uartbar);
684 uartbar &= ~(0xffff << (16 * i)); /* clear half the reg */
685 uartbar |= (ioport << (16 * i)); /* set the ioport */
686 pci_write_config_dword(dev, ITE_887x_UARTBAR, uartbar);
687
688 /* get current config */
689 pci_read_config_dword(dev, ITE_887x_MISCR, &miscr);
690 /* disable interrupts (UARTx_Routing[3:0]) */
691 miscr &= ~(0xf << (12 - 4 * i));
692 /* activate the UART (UARTx_En) */
693 miscr |= 1 << (23 - i);
694 /* write new config with activated UART */
695 pci_write_config_dword(dev, ITE_887x_MISCR, miscr);
696 }
697
698 if (ret <= 0) {
699 /* the device has no UARTs if we get here */
700 release_region(iobase->start, ITE_887x_IOSIZE);
701 }
702
703 return ret;
704}
705
706static void __devexit pci_ite887x_exit(struct pci_dev *dev)
707{
708 u32 ioport;
709 /* the ioport is bit 0-15 in POSIO0R */
710 pci_read_config_dword(dev, ITE_887x_POSIO0, &ioport);
711 ioport &= 0xffff;
712 release_region(ioport, ITE_887x_IOSIZE);
713}
714
583static int 715static int
584pci_default_setup(struct serial_private *priv, struct pciserial_board *board, 716pci_default_setup(struct serial_private *priv, struct pciserial_board *board,
585 struct uart_port *port, int idx) 717 struct uart_port *port, int idx)
@@ -653,6 +785,18 @@ static struct pci_serial_quirk pci_serial_quirks[] = {
653 .setup = pci_default_setup, 785 .setup = pci_default_setup,
654 }, 786 },
655 /* 787 /*
788 * ITE
789 */
790 {
791 .vendor = PCI_VENDOR_ID_ITE,
792 .device = PCI_DEVICE_ID_ITE_8872,
793 .subvendor = PCI_ANY_ID,
794 .subdevice = PCI_ANY_ID,
795 .init = pci_ite887x_init,
796 .setup = pci_default_setup,
797 .exit = __devexit_p(pci_ite887x_exit),
798 },
799 /*
656 * Panacom 800 * Panacom
657 */ 801 */
658 { 802 {
@@ -933,6 +1077,7 @@ enum pci_board_num_t {
933 1077
934 pbn_b1_2_1250000, 1078 pbn_b1_2_1250000,
935 1079
1080 pbn_b1_bt_1_115200,
936 pbn_b1_bt_2_921600, 1081 pbn_b1_bt_2_921600,
937 1082
938 pbn_b1_1_1382400, 1083 pbn_b1_1_1382400,
@@ -983,6 +1128,7 @@ enum pci_board_num_t {
983 pbn_exar_XR17C152, 1128 pbn_exar_XR17C152,
984 pbn_exar_XR17C154, 1129 pbn_exar_XR17C154,
985 pbn_exar_XR17C158, 1130 pbn_exar_XR17C158,
1131 pbn_pasemi_1682M,
986}; 1132};
987 1133
988/* 1134/*
@@ -1211,6 +1357,13 @@ static struct pciserial_board pci_boards[] __devinitdata = {
1211 .uart_offset = 8, 1357 .uart_offset = 8,
1212 }, 1358 },
1213 1359
1360 [pbn_b1_bt_1_115200] = {
1361 .flags = FL_BASE1|FL_BASE_BARS,
1362 .num_ports = 1,
1363 .base_baud = 115200,
1364 .uart_offset = 8,
1365 },
1366
1214 [pbn_b1_bt_2_921600] = { 1367 [pbn_b1_bt_2_921600] = {
1215 .flags = FL_BASE1|FL_BASE_BARS, 1368 .flags = FL_BASE1|FL_BASE_BARS,
1216 .num_ports = 2, 1369 .num_ports = 2,
@@ -1498,6 +1651,18 @@ static struct pciserial_board pci_boards[] __devinitdata = {
1498 .base_baud = 921600, 1651 .base_baud = 921600,
1499 .uart_offset = 0x200, 1652 .uart_offset = 0x200,
1500 }, 1653 },
1654 /*
1655 * PA Semi PWRficient PA6T-1682M on-chip UART
1656 */
1657 [pbn_pasemi_1682M] = {
1658 .flags = FL_BASE0,
1659 .num_ports = 1,
1660 .base_baud = 8333333,
1661 },
1662};
1663
1664static const struct pci_device_id softmodem_blacklist[] = {
1665 { PCI_VDEVICE ( AL, 0x5457 ), }, /* ALi Corporation M5457 AC'97 Modem */
1501}; 1666};
1502 1667
1503/* 1668/*
@@ -1508,6 +1673,7 @@ static struct pciserial_board pci_boards[] __devinitdata = {
1508static int __devinit 1673static int __devinit
1509serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board) 1674serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board)
1510{ 1675{
1676 const struct pci_device_id *blacklist;
1511 int num_iomem, num_port, first_port = -1, i; 1677 int num_iomem, num_port, first_port = -1, i;
1512 1678
1513 /* 1679 /*
@@ -1522,6 +1688,18 @@ serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board)
1522 (dev->class & 0xff) > 6) 1688 (dev->class & 0xff) > 6)
1523 return -ENODEV; 1689 return -ENODEV;
1524 1690
1691 /*
1692 * Do not access blacklisted devices that are known not to
1693 * feature serial ports.
1694 */
1695 for (blacklist = softmodem_blacklist;
1696 blacklist < softmodem_blacklist + ARRAY_SIZE(softmodem_blacklist);
1697 blacklist++) {
1698 if (dev->vendor == blacklist->vendor &&
1699 dev->device == blacklist->device)
1700 return -ENODEV;
1701 }
1702
1525 num_iomem = num_port = 0; 1703 num_iomem = num_port = 0;
1526 for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) { 1704 for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) {
1527 if (pci_resource_flags(dev, i) & IORESOURCE_IO) { 1705 if (pci_resource_flags(dev, i) & IORESOURCE_IO) {
@@ -2364,6 +2542,13 @@ static struct pci_device_id serial_pci_tbl[] = {
2364 { PCI_VENDOR_ID_TOPIC, PCI_DEVICE_ID_TOPIC_TP560, 2542 { PCI_VENDOR_ID_TOPIC, PCI_DEVICE_ID_TOPIC_TP560,
2365 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2543 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2366 pbn_b0_1_115200 }, 2544 pbn_b0_1_115200 },
2545 /*
2546 * ITE
2547 */
2548 { PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8872,
2549 PCI_ANY_ID, PCI_ANY_ID,
2550 0, 0,
2551 pbn_b1_bt_1_115200 },
2367 2552
2368 /* 2553 /*
2369 * IntaShield IS-200 2554 * IntaShield IS-200
@@ -2382,6 +2567,13 @@ static struct pci_device_id serial_pci_tbl[] = {
2382 PCI_SUBVENDOR_ID_PERLE, PCI_SUBDEVICE_ID_PCI_RAS8, 2567 PCI_SUBVENDOR_ID_PERLE, PCI_SUBDEVICE_ID_PCI_RAS8,
2383 0, 0, pbn_b2_8_921600 }, 2568 0, 0, pbn_b2_8_921600 },
2384 /* 2569 /*
2570 * PA Semi PA6T-1682M on-chip UART
2571 */
2572 { PCI_VENDOR_ID_PASEMI, 0xa004,
2573 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2574 pbn_pasemi_1682M },
2575
2576 /*
2385 * These entries match devices with class COMMUNICATION_SERIAL, 2577 * These entries match devices with class COMMUNICATION_SERIAL,
2386 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL 2578 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL
2387 */ 2579 */
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 030a6063541d..a055f58f342f 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1146,11 +1146,14 @@ static void uart_set_termios(struct tty_struct *tty, struct ktermios *old_termio
1146 1146
1147 /* 1147 /*
1148 * These are the bits that are used to setup various 1148 * These are the bits that are used to setup various
1149 * flags in the low level driver. 1149 * flags in the low level driver. We can ignore the Bfoo
1150 * bits in c_cflag; c_[io]speed will always be set
1151 * appropriately by set_termios() in tty_ioctl.c
1150 */ 1152 */
1151#define RELEVANT_IFLAG(iflag) ((iflag) & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) 1153#define RELEVANT_IFLAG(iflag) ((iflag) & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
1152
1153 if ((cflag ^ old_termios->c_cflag) == 0 && 1154 if ((cflag ^ old_termios->c_cflag) == 0 &&
1155 tty->termios->c_ospeed == old_termios->c_ospeed &&
1156 tty->termios->c_ispeed == old_termios->c_ispeed &&
1154 RELEVANT_IFLAG(tty->termios->c_iflag ^ old_termios->c_iflag) == 0) 1157 RELEVANT_IFLAG(tty->termios->c_iflag ^ old_termios->c_iflag) == 0)
1155 return; 1158 return;
1156 1159
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
index b8f91e018b21..0930e2a85514 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/serial/serial_txx9.c
@@ -37,7 +37,7 @@
37 37
38#include <asm/io.h> 38#include <asm/io.h>
39 39
40static char *serial_version = "1.09"; 40static char *serial_version = "1.10";
41static char *serial_name = "TX39/49 Serial driver"; 41static char *serial_name = "TX39/49 Serial driver";
42 42
43#define PASS_LIMIT 256 43#define PASS_LIMIT 256
@@ -436,8 +436,10 @@ static unsigned int serial_txx9_get_mctrl(struct uart_port *port)
436 struct uart_txx9_port *up = (struct uart_txx9_port *)port; 436 struct uart_txx9_port *up = (struct uart_txx9_port *)port;
437 unsigned int ret; 437 unsigned int ret;
438 438
439 ret = ((sio_in(up, TXX9_SIFLCR) & TXX9_SIFLCR_RTSSC) ? 0 : TIOCM_RTS) 439 /* no modem control lines */
440 | ((sio_in(up, TXX9_SICISR) & TXX9_SICISR_CTSS) ? 0 : TIOCM_CTS); 440 ret = TIOCM_CAR | TIOCM_DSR;
441 ret |= (sio_in(up, TXX9_SIFLCR) & TXX9_SIFLCR_RTSSC) ? 0 : TIOCM_RTS;
442 ret |= (sio_in(up, TXX9_SICISR) & TXX9_SICISR_CTSS) ? 0 : TIOCM_CTS;
441 443
442 return ret; 444 return ret;
443} 445}
@@ -557,6 +559,12 @@ serial_txx9_set_termios(struct uart_port *port, struct ktermios *termios,
557 unsigned long flags; 559 unsigned long flags;
558 unsigned int baud, quot; 560 unsigned int baud, quot;
559 561
562 /*
563 * We don't support modem control lines.
564 */
565 termios->c_cflag &= ~(HUPCL | CMSPAR);
566 termios->c_cflag |= CLOCAL;
567
560 cval = sio_in(up, TXX9_SILCR); 568 cval = sio_in(up, TXX9_SILCR);
561 /* byte size and parity */ 569 /* byte size and parity */
562 cval &= ~TXX9_SILCR_UMODE_MASK; 570 cval &= ~TXX9_SILCR_UMODE_MASK;
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 79b13685bdfa..e074943feff5 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -1198,10 +1198,11 @@ static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up)
1198 if (up->port.type == PORT_UNKNOWN) 1198 if (up->port.type == PORT_UNKNOWN)
1199 return -ENODEV; 1199 return -ENODEV;
1200 1200
1201 printk("%s: %s port at %lx, irq %u\n", 1201 printk("%s: %s port at %llx, irq %u\n",
1202 to_of_device(up->port.dev)->node->full_name, 1202 to_of_device(up->port.dev)->node->full_name,
1203 (up->su_type == SU_PORT_KBD) ? "Keyboard" : "Mouse", 1203 (up->su_type == SU_PORT_KBD) ? "Keyboard" : "Mouse",
1204 up->port.mapbase, up->port.irq); 1204 (unsigned long long) up->port.mapbase,
1205 up->port.irq);
1205 1206
1206#ifdef CONFIG_SERIO 1207#ifdef CONFIG_SERIO
1207 serio = &up->serio; 1208 serio = &up->serio;
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index 1d262c0c613f..283bef0d24cb 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -1431,14 +1431,16 @@ static int __devinit zs_probe(struct of_device *op, const struct of_device_id *m
1431 return err; 1431 return err;
1432 } 1432 }
1433 } else { 1433 } else {
1434 printk(KERN_INFO "%s: Keyboard at MMIO 0x%lx (irq = %d) " 1434 printk(KERN_INFO "%s: Keyboard at MMIO 0x%llx (irq = %d) "
1435 "is a %s\n", 1435 "is a %s\n",
1436 op->dev.bus_id, up[0].port.mapbase, op->irqs[0], 1436 op->dev.bus_id,
1437 sunzilog_type (&up[0].port)); 1437 (unsigned long long) up[0].port.mapbase,
1438 printk(KERN_INFO "%s: Mouse at MMIO 0x%lx (irq = %d) " 1438 op->irqs[0], sunzilog_type(&up[0].port));
1439 printk(KERN_INFO "%s: Mouse at MMIO 0x%llx (irq = %d) "
1439 "is a %s\n", 1440 "is a %s\n",
1440 op->dev.bus_id, up[1].port.mapbase, op->irqs[0], 1441 op->dev.bus_id,
1441 sunzilog_type (&up[1].port)); 1442 (unsigned long long) up[1].port.mapbase,
1443 op->irqs[0], sunzilog_type(&up[1].port));
1442 } 1444 }
1443 1445
1444 dev_set_drvdata(&op->dev, &up[0]); 1446 dev_set_drvdata(&op->dev, &up[0]);
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 7dd73546bf43..7580aa5da0f8 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -6,6 +6,9 @@ menuconfig USB_SUPPORT
6 bool "USB support" 6 bool "USB support"
7 depends on HAS_IOMEM 7 depends on HAS_IOMEM
8 default y 8 default y
9 ---help---
10 This option adds core support for Universal Serial Bus (USB).
11 You will also need drivers from the following menu to make use of it.
9 12
10if USB_SUPPORT 13if USB_SUPPORT
11 14
@@ -18,6 +21,7 @@ config USB_ARCH_HAS_HCD
18 default y if USB_ARCH_HAS_EHCI 21 default y if USB_ARCH_HAS_EHCI
19 default y if PCMCIA && !M32R # sl811_cs 22 default y if PCMCIA && !M32R # sl811_cs
20 default y if ARM # SL-811 23 default y if ARM # SL-811
24 default y if SUPERH # r8a66597-hcd
21 default PCI 25 default PCI
22 26
23# many non-PCI SOC chips embed OHCI 27# many non-PCI SOC chips embed OHCI
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 02c52f8d5dbf..a73e714288e5 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -456,7 +456,6 @@ static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
456 int* actual_length) 456 int* actual_length)
457{ 457{
458 struct timer_list timer; 458 struct timer_list timer;
459 int status = urb->status;
460 459
461 init_timer(&timer); 460 init_timer(&timer);
462 timer.expires = jiffies + msecs_to_jiffies(CMD_TIMEOUT); 461 timer.expires = jiffies + msecs_to_jiffies(CMD_TIMEOUT);
@@ -468,7 +467,7 @@ static int cxacru_start_wait_urb(struct urb *urb, struct completion *done,
468 467
469 if (actual_length) 468 if (actual_length)
470 *actual_length = urb->actual_length; 469 *actual_length = urb->actual_length;
471 return status; 470 return urb->status; /* must read status after completion */
472} 471}
473 472
474static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm, 473static int cxacru_cm(struct cxacru_data *instance, enum cxacru_cm_request cm,
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index a1a1c9d467e0..29807d048b04 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -1721,9 +1721,12 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1721 1721
1722 ret = uea_boot(sc); 1722 ret = uea_boot(sc);
1723 if (ret < 0) 1723 if (ret < 0)
1724 goto error; 1724 goto error_rm_grp;
1725 1725
1726 return 0; 1726 return 0;
1727
1728error_rm_grp:
1729 sysfs_remove_group(&intf->dev.kobj, &attr_grp);
1727error: 1730error:
1728 kfree(sc); 1731 kfree(sc);
1729 return ret; 1732 return ret;
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index fe940e0536e0..f51e22490edf 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -921,6 +921,10 @@ skip_normal_probe:
921 return -EINVAL; 921 return -EINVAL;
922 } 922 }
923 } 923 }
924
925 /* Accept probe requests only for the control interface */
926 if (intf != control_interface)
927 return -ENODEV;
924 928
925 if (usb_interface_claimed(data_interface)) { /* valid in this context */ 929 if (usb_interface_claimed(data_interface)) { /* valid in this context */
926 dev_dbg(&intf->dev,"The data interface isn't available"); 930 dev_dbg(&intf->dev,"The data interface isn't available");
@@ -1109,10 +1113,12 @@ static void acm_disconnect(struct usb_interface *intf)
1109 return; 1113 return;
1110 } 1114 }
1111 if (acm->country_codes){ 1115 if (acm->country_codes){
1112 device_remove_file(&intf->dev, &dev_attr_wCountryCodes); 1116 device_remove_file(&acm->control->dev,
1113 device_remove_file(&intf->dev, &dev_attr_iCountryCodeRelDate); 1117 &dev_attr_wCountryCodes);
1118 device_remove_file(&acm->control->dev,
1119 &dev_attr_iCountryCodeRelDate);
1114 } 1120 }
1115 device_remove_file(&intf->dev, &dev_attr_bmCapabilities); 1121 device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities);
1116 acm->dev = NULL; 1122 acm->dev = NULL;
1117 usb_set_intfdata(acm->control, NULL); 1123 usb_set_intfdata(acm->control, NULL);
1118 usb_set_intfdata(acm->data, NULL); 1124 usb_set_intfdata(acm->data, NULL);
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 654857493a82..a1ad11d0c47c 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1224,6 +1224,8 @@ static int usb_autopm_do_device(struct usb_device *udev, int inc_usage_cnt)
1224 udev->auto_pm = 1; 1224 udev->auto_pm = 1;
1225 udev->pm_usage_cnt += inc_usage_cnt; 1225 udev->pm_usage_cnt += inc_usage_cnt;
1226 WARN_ON(udev->pm_usage_cnt < 0); 1226 WARN_ON(udev->pm_usage_cnt < 0);
1227 if (inc_usage_cnt)
1228 udev->last_busy = jiffies;
1227 if (inc_usage_cnt >= 0 && udev->pm_usage_cnt > 0) { 1229 if (inc_usage_cnt >= 0 && udev->pm_usage_cnt > 0) {
1228 if (udev->state == USB_STATE_SUSPENDED) 1230 if (udev->state == USB_STATE_SUSPENDED)
1229 status = usb_resume_both(udev); 1231 status = usb_resume_both(udev);
@@ -1232,8 +1234,6 @@ static int usb_autopm_do_device(struct usb_device *udev, int inc_usage_cnt)
1232 else if (inc_usage_cnt) 1234 else if (inc_usage_cnt)
1233 udev->last_busy = jiffies; 1235 udev->last_busy = jiffies;
1234 } else if (inc_usage_cnt <= 0 && udev->pm_usage_cnt <= 0) { 1236 } else if (inc_usage_cnt <= 0 && udev->pm_usage_cnt <= 0) {
1235 if (inc_usage_cnt)
1236 udev->last_busy = jiffies;
1237 status = usb_suspend_both(udev, PMSG_SUSPEND); 1237 status = usb_suspend_both(udev, PMSG_SUSPEND);
1238 } 1238 }
1239 usb_pm_unlock(udev); 1239 usb_pm_unlock(udev);
@@ -1342,16 +1342,15 @@ static int usb_autopm_do_interface(struct usb_interface *intf,
1342 else { 1342 else {
1343 udev->auto_pm = 1; 1343 udev->auto_pm = 1;
1344 intf->pm_usage_cnt += inc_usage_cnt; 1344 intf->pm_usage_cnt += inc_usage_cnt;
1345 udev->last_busy = jiffies;
1345 if (inc_usage_cnt >= 0 && intf->pm_usage_cnt > 0) { 1346 if (inc_usage_cnt >= 0 && intf->pm_usage_cnt > 0) {
1346 if (udev->state == USB_STATE_SUSPENDED) 1347 if (udev->state == USB_STATE_SUSPENDED)
1347 status = usb_resume_both(udev); 1348 status = usb_resume_both(udev);
1348 if (status != 0) 1349 if (status != 0)
1349 intf->pm_usage_cnt -= inc_usage_cnt; 1350 intf->pm_usage_cnt -= inc_usage_cnt;
1350 else if (inc_usage_cnt) 1351 else
1351 udev->last_busy = jiffies; 1352 udev->last_busy = jiffies;
1352 } else if (inc_usage_cnt <= 0 && intf->pm_usage_cnt <= 0) { 1353 } else if (inc_usage_cnt <= 0 && intf->pm_usage_cnt <= 0) {
1353 if (inc_usage_cnt)
1354 udev->last_busy = jiffies;
1355 status = usb_suspend_both(udev, PMSG_SUSPEND); 1354 status = usb_suspend_both(udev, PMSG_SUSPEND);
1356 } 1355 }
1357 } 1356 }
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index e341a1da517f..f7b337feb3ea 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1644,9 +1644,10 @@ static int finish_port_resume(struct usb_device *udev)
1644 * and device drivers will know about any resume quirks. 1644 * and device drivers will know about any resume quirks.
1645 */ 1645 */
1646 if (status == 0) { 1646 if (status == 0) {
1647 devstatus = 0;
1647 status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus); 1648 status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus);
1648 if (status >= 0) 1649 if (status >= 0)
1649 status = (status == 2 ? 0 : -ENODEV); 1650 status = (status > 0 ? 0 : -ENODEV);
1650 } 1651 }
1651 1652
1652 if (status) { 1653 if (status) {
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index b6bd05e3d439..d8f7b089a8f0 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -637,12 +637,12 @@ int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char
637 memset(buf,0,size); // Make sure we parse really received data 637 memset(buf,0,size); // Make sure we parse really received data
638 638
639 for (i = 0; i < 3; ++i) { 639 for (i = 0; i < 3; ++i) {
640 /* retry on length 0 or stall; some devices are flakey */ 640 /* retry on length 0 or error; some devices are flakey */
641 result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 641 result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
642 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, 642 USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
643 (type << 8) + index, 0, buf, size, 643 (type << 8) + index, 0, buf, size,
644 USB_CTRL_GET_TIMEOUT); 644 USB_CTRL_GET_TIMEOUT);
645 if (result == 0 || result == -EPIPE) 645 if (result <= 0 && result != -ETIMEDOUT)
646 continue; 646 continue;
647 if (result > 1 && ((u8 *)buf)[1] != type) { 647 if (result > 1 && ((u8 *)buf)[1] != type) {
648 result = -EPROTO; 648 result = -EPROTO;
@@ -1358,6 +1358,30 @@ static int usb_if_uevent(struct device *dev, char **envp, int num_envp,
1358 usb_dev = interface_to_usbdev(intf); 1358 usb_dev = interface_to_usbdev(intf);
1359 alt = intf->cur_altsetting; 1359 alt = intf->cur_altsetting;
1360 1360
1361#ifdef CONFIG_USB_DEVICEFS
1362 if (add_uevent_var(envp, num_envp, &i,
1363 buffer, buffer_size, &length,
1364 "DEVICE=/proc/bus/usb/%03d/%03d",
1365 usb_dev->bus->busnum, usb_dev->devnum))
1366 return -ENOMEM;
1367#endif
1368
1369 if (add_uevent_var(envp, num_envp, &i,
1370 buffer, buffer_size, &length,
1371 "PRODUCT=%x/%x/%x",
1372 le16_to_cpu(usb_dev->descriptor.idVendor),
1373 le16_to_cpu(usb_dev->descriptor.idProduct),
1374 le16_to_cpu(usb_dev->descriptor.bcdDevice)))
1375 return -ENOMEM;
1376
1377 if (add_uevent_var(envp, num_envp, &i,
1378 buffer, buffer_size, &length,
1379 "TYPE=%d/%d/%d",
1380 usb_dev->descriptor.bDeviceClass,
1381 usb_dev->descriptor.bDeviceSubClass,
1382 usb_dev->descriptor.bDeviceProtocol))
1383 return -ENOMEM;
1384
1361 if (add_uevent_var(envp, num_envp, &i, 1385 if (add_uevent_var(envp, num_envp, &i,
1362 buffer, buffer_size, &length, 1386 buffer, buffer_size, &length,
1363 "INTERFACE=%d/%d/%d", 1387 "INTERFACE=%d/%d/%d",
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index b7917c5a3c6f..9e467118dc94 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -30,6 +30,8 @@
30static const struct usb_device_id usb_quirk_list[] = { 30static const struct usb_device_id usb_quirk_list[] = {
31 /* HP 5300/5370C scanner */ 31 /* HP 5300/5370C scanner */
32 { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 }, 32 { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 },
33 /* Hewlett-Packard PhotoSmart 720 / PhotoSmart 935 (storage) */
34 { USB_DEVICE(0x03f0, 0x4002), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
33 /* Acer Peripherals Inc. (now BenQ Corp.) Prisa 640BU */ 35 /* Acer Peripherals Inc. (now BenQ Corp.) Prisa 640BU */
34 { USB_DEVICE(0x04a5, 0x207e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 36 { USB_DEVICE(0x04a5, 0x207e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
35 /* Benq S2W 3300U */ 37 /* Benq S2W 3300U */
@@ -56,6 +58,8 @@ static const struct usb_device_id usb_quirk_list[] = {
56 { USB_DEVICE(0x04b8, 0x0121), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 58 { USB_DEVICE(0x04b8, 0x0121), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
57 /* Seiko Epson Corp.*/ 59 /* Seiko Epson Corp.*/
58 { USB_DEVICE(0x04b8, 0x0122), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 60 { USB_DEVICE(0x04b8, 0x0122), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
61 /* Samsung ML-2010 printer */
62 { USB_DEVICE(0x04e8, 0x326c), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
59 /* Samsung ML-2510 Series printer */ 63 /* Samsung ML-2510 Series printer */
60 { USB_DEVICE(0x04e8, 0x327e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 64 { USB_DEVICE(0x04e8, 0x327e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
61 /* Elsa MicroLink 56k (V.250) */ 65 /* Elsa MicroLink 56k (V.250) */
@@ -64,12 +68,20 @@ static const struct usb_device_id usb_quirk_list[] = {
64 { USB_DEVICE(0x05d8, 0x4005), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 68 { USB_DEVICE(0x05d8, 0x4005), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
65 /* Agfa Snapscan1212u */ 69 /* Agfa Snapscan1212u */
66 { USB_DEVICE(0x06bd, 0x2061), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 70 { USB_DEVICE(0x06bd, 0x2061), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
71 /* Seagate RSS LLC */
72 { USB_DEVICE(0x0bc2, 0x3000), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
67 /* Umax [hex] Astra 3400U */ 73 /* Umax [hex] Astra 3400U */
68 { USB_DEVICE(0x1606, 0x0060), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 74 { USB_DEVICE(0x1606, 0x0060), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
69 75
70 /* Philips PSC805 audio device */ 76 /* Philips PSC805 audio device */
71 { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME }, 77 { USB_DEVICE(0x0471, 0x0155), .driver_info = USB_QUIRK_RESET_RESUME },
72 78
79 /* Alcor multi-card reader */
80 { USB_DEVICE(0x058f, 0x6366), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
81
82 /* Canon EOS 5D in PC Connection mode */
83 { USB_DEVICE(0x04a9, 0x3101), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
84
73 /* RIM Blackberry */ 85 /* RIM Blackberry */
74 { USB_DEVICE(0x0fca, 0x0001), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 86 { USB_DEVICE(0x0fca, 0x0001), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
75 { USB_DEVICE(0x0fca, 0x0004), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 87 { USB_DEVICE(0x0fca, 0x0004), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index f2fbdc7fe376..d008d1360a7a 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -34,8 +34,6 @@
34 * bypassing some hardware (and driver) issues. UML could help too. 34 * bypassing some hardware (and driver) issues. UML could help too.
35 */ 35 */
36 36
37#define DEBUG
38
39#include <linux/module.h> 37#include <linux/module.h>
40#include <linux/kernel.h> 38#include <linux/kernel.h>
41#include <linux/delay.h> 39#include <linux/delay.h>
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index be7a1bd2823b..965ad7bec7b7 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -599,7 +599,6 @@ enum fsg_buffer_state {
599 599
600struct fsg_buffhd { 600struct fsg_buffhd {
601 void *buf; 601 void *buf;
602 dma_addr_t dma;
603 enum fsg_buffer_state state; 602 enum fsg_buffer_state state;
604 struct fsg_buffhd *next; 603 struct fsg_buffhd *next;
605 604
@@ -1295,6 +1294,7 @@ static int class_setup_req(struct fsg_dev *fsg,
1295 struct usb_request *req = fsg->ep0req; 1294 struct usb_request *req = fsg->ep0req;
1296 int value = -EOPNOTSUPP; 1295 int value = -EOPNOTSUPP;
1297 u16 w_index = le16_to_cpu(ctrl->wIndex); 1296 u16 w_index = le16_to_cpu(ctrl->wIndex);
1297 u16 w_value = le16_to_cpu(ctrl->wValue);
1298 u16 w_length = le16_to_cpu(ctrl->wLength); 1298 u16 w_length = le16_to_cpu(ctrl->wLength);
1299 1299
1300 if (!fsg->config) 1300 if (!fsg->config)
@@ -1308,7 +1308,7 @@ static int class_setup_req(struct fsg_dev *fsg,
1308 if (ctrl->bRequestType != (USB_DIR_OUT | 1308 if (ctrl->bRequestType != (USB_DIR_OUT |
1309 USB_TYPE_CLASS | USB_RECIP_INTERFACE)) 1309 USB_TYPE_CLASS | USB_RECIP_INTERFACE))
1310 break; 1310 break;
1311 if (w_index != 0) { 1311 if (w_index != 0 || w_value != 0) {
1312 value = -EDOM; 1312 value = -EDOM;
1313 break; 1313 break;
1314 } 1314 }
@@ -1324,7 +1324,7 @@ static int class_setup_req(struct fsg_dev *fsg,
1324 if (ctrl->bRequestType != (USB_DIR_IN | 1324 if (ctrl->bRequestType != (USB_DIR_IN |
1325 USB_TYPE_CLASS | USB_RECIP_INTERFACE)) 1325 USB_TYPE_CLASS | USB_RECIP_INTERFACE))
1326 break; 1326 break;
1327 if (w_index != 0) { 1327 if (w_index != 0 || w_value != 0) {
1328 value = -EDOM; 1328 value = -EDOM;
1329 break; 1329 break;
1330 } 1330 }
@@ -1343,7 +1343,7 @@ static int class_setup_req(struct fsg_dev *fsg,
1343 if (ctrl->bRequestType != (USB_DIR_OUT | 1343 if (ctrl->bRequestType != (USB_DIR_OUT |
1344 USB_TYPE_CLASS | USB_RECIP_INTERFACE)) 1344 USB_TYPE_CLASS | USB_RECIP_INTERFACE))
1345 break; 1345 break;
1346 if (w_index != 0) { 1346 if (w_index != 0 || w_value != 0) {
1347 value = -EDOM; 1347 value = -EDOM;
1348 break; 1348 break;
1349 } 1349 }
@@ -2611,7 +2611,6 @@ static int send_status(struct fsg_dev *fsg)
2611 2611
2612 fsg->intr_buffhd = bh; // Point to the right buffhd 2612 fsg->intr_buffhd = bh; // Point to the right buffhd
2613 fsg->intreq->buf = bh->inreq->buf; 2613 fsg->intreq->buf = bh->inreq->buf;
2614 fsg->intreq->dma = bh->inreq->dma;
2615 fsg->intreq->context = bh; 2614 fsg->intreq->context = bh;
2616 start_transfer(fsg, fsg->intr_in, fsg->intreq, 2615 start_transfer(fsg, fsg->intr_in, fsg->intreq,
2617 &fsg->intreq_busy, &bh->state); 2616 &fsg->intreq_busy, &bh->state);
@@ -3200,7 +3199,6 @@ reset:
3200 if ((rc = alloc_request(fsg, fsg->bulk_out, &bh->outreq)) != 0) 3199 if ((rc = alloc_request(fsg, fsg->bulk_out, &bh->outreq)) != 0)
3201 goto reset; 3200 goto reset;
3202 bh->inreq->buf = bh->outreq->buf = bh->buf; 3201 bh->inreq->buf = bh->outreq->buf = bh->buf;
3203 bh->inreq->dma = bh->outreq->dma = bh->dma;
3204 bh->inreq->context = bh->outreq->context = bh; 3202 bh->inreq->context = bh->outreq->context = bh;
3205 bh->inreq->complete = bulk_in_complete; 3203 bh->inreq->complete = bulk_in_complete;
3206 bh->outreq->complete = bulk_out_complete; 3204 bh->outreq->complete = bulk_out_complete;
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c
index 10b2b33b8698..d57bcfbc08a5 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.c
+++ b/drivers/usb/gadget/fsl_usb2_udc.c
@@ -1277,31 +1277,32 @@ static void setup_received_irq(struct fsl_udc *udc,
1277 1277
1278 udc_reset_ep_queue(udc, 0); 1278 udc_reset_ep_queue(udc, 0);
1279 1279
1280 /* We process some stardard setup requests here */
1280 switch (setup->bRequest) { 1281 switch (setup->bRequest) {
1281 /* Request that need Data+Status phase from udc */
1282 case USB_REQ_GET_STATUS: 1282 case USB_REQ_GET_STATUS:
1283 if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_STANDARD)) 1283 /* Data+Status phase from udc */
1284 if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_MASK))
1284 != (USB_DIR_IN | USB_TYPE_STANDARD)) 1285 != (USB_DIR_IN | USB_TYPE_STANDARD))
1285 break; 1286 break;
1286 ch9getstatus(udc, setup->bRequestType, wValue, wIndex, wLength); 1287 ch9getstatus(udc, setup->bRequestType, wValue, wIndex, wLength);
1287 break; 1288 return;
1288 1289
1289 /* Requests that need Status phase from udc */
1290 case USB_REQ_SET_ADDRESS: 1290 case USB_REQ_SET_ADDRESS:
1291 /* Status phase from udc */
1291 if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD 1292 if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD
1292 | USB_RECIP_DEVICE)) 1293 | USB_RECIP_DEVICE))
1293 break; 1294 break;
1294 ch9setaddress(udc, wValue, wIndex, wLength); 1295 ch9setaddress(udc, wValue, wIndex, wLength);
1295 break; 1296 return;
1296 1297
1297 /* Handled by udc, no data, status by udc */
1298 case USB_REQ_CLEAR_FEATURE: 1298 case USB_REQ_CLEAR_FEATURE:
1299 case USB_REQ_SET_FEATURE: 1299 case USB_REQ_SET_FEATURE:
1300 { /* status transaction */ 1300 /* Status phase from udc */
1301 {
1301 int rc = -EOPNOTSUPP; 1302 int rc = -EOPNOTSUPP;
1302 1303
1303 if ((setup->bRequestType & USB_RECIP_MASK) 1304 if ((setup->bRequestType & (USB_RECIP_MASK | USB_TYPE_MASK))
1304 == USB_RECIP_ENDPOINT) { 1305 == (USB_RECIP_ENDPOINT | USB_TYPE_STANDARD)) {
1305 int pipe = get_pipe_by_windex(wIndex); 1306 int pipe = get_pipe_by_windex(wIndex);
1306 struct fsl_ep *ep; 1307 struct fsl_ep *ep;
1307 1308
@@ -1315,8 +1316,9 @@ static void setup_received_irq(struct fsl_udc *udc,
1315 ? 1 : 0); 1316 ? 1 : 0);
1316 spin_lock(&udc->lock); 1317 spin_lock(&udc->lock);
1317 1318
1318 } else if ((setup->bRequestType & USB_RECIP_MASK) 1319 } else if ((setup->bRequestType & (USB_RECIP_MASK
1319 == USB_RECIP_DEVICE) { 1320 | USB_TYPE_MASK)) == (USB_RECIP_DEVICE
1321 | USB_TYPE_STANDARD)) {
1320 /* Note: The driver has not include OTG support yet. 1322 /* Note: The driver has not include OTG support yet.
1321 * This will be set when OTG support is added */ 1323 * This will be set when OTG support is added */
1322 if (!udc->gadget.is_otg) 1324 if (!udc->gadget.is_otg)
@@ -1329,39 +1331,42 @@ static void setup_received_irq(struct fsl_udc *udc,
1329 USB_DEVICE_A_ALT_HNP_SUPPORT) 1331 USB_DEVICE_A_ALT_HNP_SUPPORT)
1330 udc->gadget.a_alt_hnp_support = 1; 1332 udc->gadget.a_alt_hnp_support = 1;
1331 rc = 0; 1333 rc = 0;
1332 } 1334 } else
1335 break;
1336
1333 if (rc == 0) { 1337 if (rc == 0) {
1334 if (ep0_prime_status(udc, EP_DIR_IN)) 1338 if (ep0_prime_status(udc, EP_DIR_IN))
1335 ep0stall(udc); 1339 ep0stall(udc);
1336 } 1340 }
1337 break; 1341 return;
1338 } 1342 }
1339 /* Requests handled by gadget */
1340 default:
1341 if (wLength) {
1342 /* Data phase from gadget, status phase from udc */
1343 udc->ep0_dir = (setup->bRequestType & USB_DIR_IN)
1344 ? USB_DIR_IN : USB_DIR_OUT;
1345 spin_unlock(&udc->lock);
1346 if (udc->driver->setup(&udc->gadget,
1347 &udc->local_setup_buff) < 0)
1348 ep0stall(udc);
1349 spin_lock(&udc->lock);
1350 udc->ep0_state = (setup->bRequestType & USB_DIR_IN)
1351 ? DATA_STATE_XMIT : DATA_STATE_RECV;
1352 1343
1353 } else { 1344 default:
1354 /* No data phase, IN status from gadget */
1355 udc->ep0_dir = USB_DIR_IN;
1356 spin_unlock(&udc->lock);
1357 if (udc->driver->setup(&udc->gadget,
1358 &udc->local_setup_buff) < 0)
1359 ep0stall(udc);
1360 spin_lock(&udc->lock);
1361 udc->ep0_state = WAIT_FOR_OUT_STATUS;
1362 }
1363 break; 1345 break;
1364 } 1346 }
1347
1348 /* Requests handled by gadget */
1349 if (wLength) {
1350 /* Data phase from gadget, status phase from udc */
1351 udc->ep0_dir = (setup->bRequestType & USB_DIR_IN)
1352 ? USB_DIR_IN : USB_DIR_OUT;
1353 spin_unlock(&udc->lock);
1354 if (udc->driver->setup(&udc->gadget,
1355 &udc->local_setup_buff) < 0)
1356 ep0stall(udc);
1357 spin_lock(&udc->lock);
1358 udc->ep0_state = (setup->bRequestType & USB_DIR_IN)
1359 ? DATA_STATE_XMIT : DATA_STATE_RECV;
1360 } else {
1361 /* No data phase, IN status from gadget */
1362 udc->ep0_dir = USB_DIR_IN;
1363 spin_unlock(&udc->lock);
1364 if (udc->driver->setup(&udc->gadget,
1365 &udc->local_setup_buff) < 0)
1366 ep0stall(udc);
1367 spin_lock(&udc->lock);
1368 udc->ep0_state = WAIT_FOR_OUT_STATUS;
1369 }
1365} 1370}
1366 1371
1367/* Process request for Data or Status phase of ep0 1372/* Process request for Data or Status phase of ep0
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 72b4ebbf132d..1407ad1c8128 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -967,7 +967,7 @@ static int pxa2xx_udc_pullup(struct usb_gadget *_gadget, int is_active)
967 udc = container_of(_gadget, struct pxa2xx_udc, gadget); 967 udc = container_of(_gadget, struct pxa2xx_udc, gadget);
968 968
969 /* not all boards support pullup control */ 969 /* not all boards support pullup control */
970 if (!udc->mach->udc_command) 970 if (!udc->mach->gpio_pullup && !udc->mach->udc_command)
971 return -EOPNOTSUPP; 971 return -EOPNOTSUPP;
972 972
973 is_active = (is_active != 0); 973 is_active = (is_active != 0);
@@ -2309,7 +2309,7 @@ static int pxa2xx_udc_suspend(struct platform_device *dev, pm_message_t state)
2309{ 2309{
2310 struct pxa2xx_udc *udc = platform_get_drvdata(dev); 2310 struct pxa2xx_udc *udc = platform_get_drvdata(dev);
2311 2311
2312 if (!udc->mach->udc_command) 2312 if (!udc->mach->gpio_pullup && !udc->mach->udc_command)
2313 WARN("USB host won't detect disconnect!\n"); 2313 WARN("USB host won't detect disconnect!\n");
2314 pullup(udc, 0); 2314 pullup(udc, 0);
2315 2315
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 2f529828c74d..565d6ef4c4cf 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -237,7 +237,7 @@ config USB_SL811_CS
237 module will be called "sl811_cs". 237 module will be called "sl811_cs".
238 238
239config USB_R8A66597_HCD 239config USB_R8A66597_HCD
240 tristate "R8A66597 HCD suppoort" 240 tristate "R8A66597 HCD support"
241 depends on USB 241 depends on USB
242 help 242 help
243 The R8A66597 is a USB 2.0 host and peripheral controller. 243 The R8A66597 is a USB 2.0 host and peripheral controller.
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
index 5d1b12aad776..b1d19268cb23 100644
--- a/drivers/usb/host/ehci-au1xxx.c
+++ b/drivers/usb/host/ehci-au1xxx.c
@@ -1,8 +1,6 @@
1/* 1/*
2 * EHCI HCD (Host Controller Driver) for USB. 2 * EHCI HCD (Host Controller Driver) for USB.
3 * 3 *
4 * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net>
5 *
6 * Bus Glue for AMD Alchemy Au1xxx 4 * Bus Glue for AMD Alchemy Au1xxx
7 * 5 *
8 * Based on "ohci-au1xxx.c" by Matt Porter <mporter@kernel.crashing.org> 6 * Based on "ohci-au1xxx.c" by Matt Porter <mporter@kernel.crashing.org>
@@ -196,6 +194,9 @@ static const struct hc_driver ehci_au1xxx_hc_driver = {
196 194
197 /* 195 /*
198 * basic lifecycle operations 196 * basic lifecycle operations
197 *
198 * FIXME -- ehci_init() doesn't do enough here.
199 * See ehci-ppc-soc for a complete implementation.
199 */ 200 */
200 .reset = ehci_init, 201 .reset = ehci_init,
201 .start = ehci_run, 202 .start = ehci_run,
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index c4e15ed1405a..35cdba10411b 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -275,58 +275,6 @@ static void ehci_work(struct ehci_hcd *ehci);
275 275
276/*-------------------------------------------------------------------------*/ 276/*-------------------------------------------------------------------------*/
277 277
278#ifdef CONFIG_CPU_FREQ
279
280#include <linux/cpufreq.h>
281
282static void ehci_cpufreq_pause (struct ehci_hcd *ehci)
283{
284 unsigned long flags;
285
286 spin_lock_irqsave(&ehci->lock, flags);
287 if (!ehci->cpufreq_changing++)
288 qh_inactivate_split_intr_qhs(ehci);
289 spin_unlock_irqrestore(&ehci->lock, flags);
290}
291
292static void ehci_cpufreq_unpause (struct ehci_hcd *ehci)
293{
294 unsigned long flags;
295
296 spin_lock_irqsave(&ehci->lock, flags);
297 if (!--ehci->cpufreq_changing)
298 qh_reactivate_split_intr_qhs(ehci);
299 spin_unlock_irqrestore(&ehci->lock, flags);
300}
301
302/*
303 * ehci_cpufreq_notifier is needed to avoid MMF errors that occur when
304 * EHCI controllers that don't cache many uframes get delayed trying to
305 * read main memory during CPU frequency transitions. This can cause
306 * split interrupt transactions to not be completed in the required uframe.
307 * This has been observed on the Broadcom/ServerWorks HT1000 controller.
308 */
309static int ehci_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
310 void *data)
311{
312 struct ehci_hcd *ehci = container_of(nb, struct ehci_hcd,
313 cpufreq_transition);
314
315 switch (val) {
316 case CPUFREQ_PRECHANGE:
317 ehci_cpufreq_pause(ehci);
318 break;
319 case CPUFREQ_POSTCHANGE:
320 ehci_cpufreq_unpause(ehci);
321 break;
322 }
323 return 0;
324}
325
326#endif
327
328/*-------------------------------------------------------------------------*/
329
330static void ehci_watchdog (unsigned long param) 278static void ehci_watchdog (unsigned long param)
331{ 279{
332 struct ehci_hcd *ehci = (struct ehci_hcd *) param; 280 struct ehci_hcd *ehci = (struct ehci_hcd *) param;
@@ -460,10 +408,6 @@ static void ehci_stop (struct usb_hcd *hcd)
460 ehci_writel(ehci, 0, &ehci->regs->intr_enable); 408 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
461 spin_unlock_irq(&ehci->lock); 409 spin_unlock_irq(&ehci->lock);
462 410
463#ifdef CONFIG_CPU_FREQ
464 cpufreq_unregister_notifier(&ehci->cpufreq_transition,
465 CPUFREQ_TRANSITION_NOTIFIER);
466#endif
467 /* let companion controllers work when we aren't */ 411 /* let companion controllers work when we aren't */
468 ehci_writel(ehci, 0, &ehci->regs->configured_flag); 412 ehci_writel(ehci, 0, &ehci->regs->configured_flag);
469 413
@@ -569,17 +513,6 @@ static int ehci_init(struct usb_hcd *hcd)
569 } 513 }
570 ehci->command = temp; 514 ehci->command = temp;
571 515
572#ifdef CONFIG_CPU_FREQ
573 INIT_LIST_HEAD(&ehci->split_intr_qhs);
574 /*
575 * If the EHCI controller caches enough uframes, this probably
576 * isn't needed unless there are so many low/full speed devices
577 * that the controller's can't cache it all.
578 */
579 ehci->cpufreq_transition.notifier_call = ehci_cpufreq_notifier;
580 cpufreq_register_notifier(&ehci->cpufreq_transition,
581 CPUFREQ_TRANSITION_NOTIFIER);
582#endif
583 return 0; 516 return 0;
584} 517}
585 518
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c
index 8816d09903d0..0431397836f6 100644
--- a/drivers/usb/host/ehci-mem.c
+++ b/drivers/usb/host/ehci-mem.c
@@ -94,9 +94,6 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, gfp_t flags)
94 qh->qh_dma = dma; 94 qh->qh_dma = dma;
95 // INIT_LIST_HEAD (&qh->qh_list); 95 // INIT_LIST_HEAD (&qh->qh_list);
96 INIT_LIST_HEAD (&qh->qtd_list); 96 INIT_LIST_HEAD (&qh->qtd_list);
97#ifdef CONFIG_CPU_FREQ
98 INIT_LIST_HEAD (&qh->split_intr_qhs);
99#endif
100 97
101 /* dummy td enables safe urb queuing */ 98 /* dummy td enables safe urb queuing */
102 qh->dummy = ehci_qtd_alloc (ehci, flags); 99 qh->dummy = ehci_qtd_alloc (ehci, flags);
diff --git a/drivers/usb/host/ehci-ppc-soc.c b/drivers/usb/host/ehci-ppc-soc.c
index c2cedb09ed8b..4f99b0eb27bc 100644
--- a/drivers/usb/host/ehci-ppc-soc.c
+++ b/drivers/usb/host/ehci-ppc-soc.c
@@ -6,7 +6,7 @@
6 * Bus Glue for PPC On-Chip EHCI driver 6 * Bus Glue for PPC On-Chip EHCI driver
7 * Tested on AMCC 440EPx 7 * Tested on AMCC 440EPx
8 * 8 *
9 * Based on "ehci-au12xx.c" by David Brownell <dbrownell@users.sourceforge.net> 9 * Based on "ehci-au1xxx.c" by K.Boge <karsten.boge@amd.com>
10 * 10 *
11 * This file is licenced under the GPL. 11 * This file is licenced under the GPL.
12 */ 12 */
@@ -15,6 +15,24 @@
15 15
16extern int usb_disabled(void); 16extern int usb_disabled(void);
17 17
18/* called during probe() after chip reset completes */
19static int ehci_ppc_soc_setup(struct usb_hcd *hcd)
20{
21 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
22 int retval;
23
24 retval = ehci_halt(ehci);
25 if (retval)
26 return retval;
27
28 retval = ehci_init(hcd);
29 if (retval)
30 return retval;
31
32 ehci->sbrn = 0x20;
33 return ehci_reset(ehci);
34}
35
18/** 36/**
19 * usb_ehci_ppc_soc_probe - initialize PPC-SoC-based HCDs 37 * usb_ehci_ppc_soc_probe - initialize PPC-SoC-based HCDs
20 * Context: !in_interrupt() 38 * Context: !in_interrupt()
@@ -120,7 +138,7 @@ static const struct hc_driver ehci_ppc_soc_hc_driver = {
120 /* 138 /*
121 * basic lifecycle operations 139 * basic lifecycle operations
122 */ 140 */
123 .reset = ehci_init, 141 .reset = ehci_ppc_soc_setup,
124 .start = ehci_run, 142 .start = ehci_run,
125 .stop = ehci_stop, 143 .stop = ehci_stop,
126 .shutdown = ehci_shutdown, 144 .shutdown = ehci_shutdown,
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 2284028f8aa5..140bfa423e07 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -312,10 +312,6 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
312 struct urb *urb; 312 struct urb *urb;
313 u32 token = 0; 313 u32 token = 0;
314 314
315 /* ignore QHs that are currently inactive */
316 if (qh->hw_info1 & __constant_cpu_to_le32(QH_INACTIVATE))
317 break;
318
319 qtd = list_entry (entry, struct ehci_qtd, qtd_list); 315 qtd = list_entry (entry, struct ehci_qtd, qtd_list);
320 urb = qtd->urb; 316 urb = qtd->urb;
321 317
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index d4a8ace49676..e682f2342ef8 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -479,109 +479,6 @@ static int disable_periodic (struct ehci_hcd *ehci)
479} 479}
480 480
481/*-------------------------------------------------------------------------*/ 481/*-------------------------------------------------------------------------*/
482#ifdef CONFIG_CPU_FREQ
483
484static int safe_to_modify_i (struct ehci_hcd *ehci, struct ehci_qh *qh)
485{
486 int now; /* current (frame * 8) + uframe */
487 int prev_start, next_start; /* uframes from/to split start */
488 int start_uframe = ffs(le32_to_cpup (&qh->hw_info2) & QH_SMASK);
489 int end_uframe = fls((le32_to_cpup (&qh->hw_info2) & QH_CMASK) >> 8);
490 int split_duration = end_uframe - start_uframe;
491
492 now = readl(&ehci->regs->frame_index) % (ehci->periodic_size << 3);
493
494 next_start = ((1024 << 3) + (qh->start << 3) + start_uframe - now)
495 % (qh->period << 3);
496 prev_start = (qh->period << 3) - next_start;
497
498 /*
499 * Make sure there will be at least one uframe when qh is safe.
500 */
501 if ((qh->period << 3) <= (ehci->i_thresh + 2 + split_duration))
502 /* never safe */
503 return -EINVAL;
504
505 /*
506 * Wait 1 uframe after transaction should have started, to make
507 * sure controller has time to write back overlay, so we can
508 * check QTD_STS_STS to see if transaction is in progress.
509 */
510 if ((next_start > ehci->i_thresh) && (prev_start > 1))
511 /* safe to set "i" bit if split isn't in progress */
512 return (qh->hw_token & STATUS_BIT(ehci)) ? 0 : 1;
513 else
514 return 0;
515}
516
517/* Set inactivate bit for all the split interrupt QHs. */
518static void qh_inactivate_split_intr_qhs (struct ehci_hcd *ehci)
519{
520 struct ehci_qh *qh;
521 int not_done, safe;
522 u32 inactivate = INACTIVATE_BIT(ehci);
523 u32 active = ACTIVE_BIT(ehci);
524
525 do {
526 not_done = 0;
527 list_for_each_entry(qh, &ehci->split_intr_qhs,
528 split_intr_qhs) {
529 if (qh->hw_info1 & inactivate)
530 /* already off */
531 continue;
532 /*
533 * To avoid setting "I" after the start split happens,
534 * don't set it if the QH might be cached in the
535 * controller. Some HCs (Broadcom/ServerWorks HT1000)
536 * will stop in the middle of a split transaction when
537 * the "I" bit is set.
538 */
539 safe = safe_to_modify_i(ehci, qh);
540 if (safe == 0) {
541 not_done = 1;
542 } else if (safe > 0) {
543 qh->was_active = qh->hw_token & active;
544 qh->hw_info1 |= inactivate;
545 }
546 }
547 } while (not_done);
548 wmb();
549}
550
551static void qh_reactivate_split_intr_qhs (struct ehci_hcd *ehci)
552{
553 struct ehci_qh *qh;
554 u32 token;
555 int not_done, safe;
556 u32 inactivate = INACTIVATE_BIT(ehci);
557 u32 active = ACTIVE_BIT(ehci);
558 u32 halt = HALT_BIT(ehci);
559
560 do {
561 not_done = 0;
562 list_for_each_entry(qh, &ehci->split_intr_qhs, split_intr_qhs) {
563 if (!(qh->hw_info1 & inactivate)) /* already on */
564 continue;
565 /*
566 * Don't reactivate if cached, or controller might
567 * overwrite overlay after we modify it!
568 */
569 safe = safe_to_modify_i(ehci, qh);
570 if (safe == 0) {
571 not_done = 1;
572 } else if (safe > 0) {
573 /* See EHCI 1.0 section 4.15.2.4. */
574 token = qh->hw_token;
575 qh->hw_token = (token | halt) & ~active;
576 wmb();
577 qh->hw_info1 &= ~inactivate;
578 wmb();
579 qh->hw_token = (token & ~halt) | qh->was_active;
580 }
581 }
582 } while (not_done);
583}
584#endif
585 482
586/* periodic schedule slots have iso tds (normal or split) first, then a 483/* periodic schedule slots have iso tds (normal or split) first, then a
587 * sparse tree for active interrupt transfers. 484 * sparse tree for active interrupt transfers.
@@ -599,17 +496,6 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
599 period, hc32_to_cpup(ehci, &qh->hw_info2) & (QH_CMASK | QH_SMASK), 496 period, hc32_to_cpup(ehci, &qh->hw_info2) & (QH_CMASK | QH_SMASK),
600 qh, qh->start, qh->usecs, qh->c_usecs); 497 qh, qh->start, qh->usecs, qh->c_usecs);
601 498
602#ifdef CONFIG_CPU_FREQ
603 /*
604 * If low/full speed interrupt QHs are inactive (because of
605 * cpufreq changing processor speeds), start QH with I flag set--
606 * it will automatically be cleared when cpufreq is done.
607 */
608 if (ehci->cpufreq_changing)
609 if (!(qh->hw_info1 & (cpu_to_le32(1 << 13))))
610 qh->hw_info1 |= INACTIVATE_BIT(ehci);
611#endif
612
613 /* high bandwidth, or otherwise every microframe */ 499 /* high bandwidth, or otherwise every microframe */
614 if (period == 0) 500 if (period == 0)
615 period = 1; 501 period = 1;
@@ -658,12 +544,6 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
658 ? ((qh->usecs + qh->c_usecs) / qh->period) 544 ? ((qh->usecs + qh->c_usecs) / qh->period)
659 : (qh->usecs * 8); 545 : (qh->usecs * 8);
660 546
661#ifdef CONFIG_CPU_FREQ
662 /* add qh to list of low/full speed interrupt QHs, if applicable */
663 if (!(qh->hw_info1 & (cpu_to_le32(1 << 13)))) {
664 list_add(&qh->split_intr_qhs, &ehci->split_intr_qhs);
665 }
666#endif
667 /* maybe enable periodic schedule processing */ 547 /* maybe enable periodic schedule processing */
668 if (!ehci->periodic_sched++) 548 if (!ehci->periodic_sched++)
669 return enable_periodic (ehci); 549 return enable_periodic (ehci);
@@ -683,13 +563,6 @@ static void qh_unlink_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
683 // THEN 563 // THEN
684 // qh->hw_info1 |= __constant_cpu_to_hc32(1 << 7 /* "ignore" */); 564 // qh->hw_info1 |= __constant_cpu_to_hc32(1 << 7 /* "ignore" */);
685 565
686#ifdef CONFIG_CPU_FREQ
687 /* remove qh from list of low/full speed interrupt QHs */
688 if (!(qh->hw_info1 & (cpu_to_le32(1 << 13)))) {
689 list_del_init(&qh->split_intr_qhs);
690 }
691#endif
692
693 /* high bandwidth, or otherwise part of every microframe */ 566 /* high bandwidth, or otherwise part of every microframe */
694 if ((period = qh->period) == 0) 567 if ((period = qh->period) == 0)
695 period = 1; 568 period = 1;
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 2c68a04230c1..951d69fec513 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -71,12 +71,6 @@ struct ehci_hcd { /* one per controller */
71 __u32 hcs_params; /* cached register copy */ 71 __u32 hcs_params; /* cached register copy */
72 spinlock_t lock; 72 spinlock_t lock;
73 73
74#ifdef CONFIG_CPU_FREQ
75 struct notifier_block cpufreq_transition;
76 int cpufreq_changing;
77 struct list_head split_intr_qhs;
78#endif
79
80 /* async schedule support */ 74 /* async schedule support */
81 struct ehci_qh *async; 75 struct ehci_qh *async;
82 struct ehci_qh *reclaim; 76 struct ehci_qh *reclaim;
@@ -439,10 +433,6 @@ struct ehci_qh {
439 __hc32 hw_next; /* see EHCI 3.6.1 */ 433 __hc32 hw_next; /* see EHCI 3.6.1 */
440 __hc32 hw_info1; /* see EHCI 3.6.2 */ 434 __hc32 hw_info1; /* see EHCI 3.6.2 */
441#define QH_HEAD 0x00008000 435#define QH_HEAD 0x00008000
442#define QH_INACTIVATE 0x00000080
443
444#define INACTIVATE_BIT(ehci) cpu_to_hc32(ehci, QH_INACTIVATE)
445
446 __hc32 hw_info2; /* see EHCI 3.6.2 */ 436 __hc32 hw_info2; /* see EHCI 3.6.2 */
447#define QH_SMASK 0x000000ff 437#define QH_SMASK 0x000000ff
448#define QH_CMASK 0x0000ff00 438#define QH_CMASK 0x0000ff00
@@ -492,10 +482,6 @@ struct ehci_qh {
492 unsigned short start; /* where polling starts */ 482 unsigned short start; /* where polling starts */
493#define NO_FRAME ((unsigned short)~0) /* pick new start */ 483#define NO_FRAME ((unsigned short)~0) /* pick new start */
494 struct usb_device *dev; /* access to TT */ 484 struct usb_device *dev; /* access to TT */
495#ifdef CONFIG_CPU_FREQ
496 struct list_head split_intr_qhs; /* list of split qhs */
497 __le32 was_active; /* active bit before "i" set */
498#endif
499} __attribute__ ((aligned (32))); 485} __attribute__ ((aligned (32)));
500 486
501/*-------------------------------------------------------------------------*/ 487/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 6f9e43e9a6ca..f61c6cdd06f2 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -74,7 +74,7 @@ urb_print (struct urb * urb, char * str, int small)
74 74
75#define ohci_dbg_sw(ohci, next, size, format, arg...) \ 75#define ohci_dbg_sw(ohci, next, size, format, arg...) \
76 do { \ 76 do { \
77 if (next) { \ 77 if (next != NULL) { \
78 unsigned s_len; \ 78 unsigned s_len; \
79 s_len = scnprintf (*next, *size, format, ## arg ); \ 79 s_len = scnprintf (*next, *size, format, ## arg ); \
80 *size -= s_len; *next += s_len; \ 80 *size -= s_len; *next += s_len; \
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index d60f1985320c..40a1de4c256e 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -2208,8 +2208,6 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2208clean_up: 2208clean_up:
2209 if (reg) 2209 if (reg)
2210 iounmap(reg); 2210 iounmap(reg);
2211 if (res)
2212 release_mem_region(res->start, 1);
2213 2211
2214 return ret; 2212 return ret;
2215} 2213}
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index 7f765ec038cd..b88eb3c62c02 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -1520,12 +1520,15 @@ static void u132_hcd_endp_work_scheduler(struct work_struct *work)
1520 } 1520 }
1521 } 1521 }
1522} 1522}
1523#ifdef CONFIG_PM
1523 1524
1524static void port_power(struct u132 *u132, int pn, int is_on) 1525static void port_power(struct u132 *u132, int pn, int is_on)
1525{ 1526{
1526 u132->port[pn].power = is_on; 1527 u132->port[pn].power = is_on;
1527} 1528}
1528 1529
1530#endif
1531
1529static void u132_power(struct u132 *u132, int is_on) 1532static void u132_power(struct u132 *u132, int is_on)
1530{ 1533{
1531 struct usb_hcd *hcd = u132_to_hcd(u132) 1534 struct usb_hcd *hcd = u132_to_hcd(u132)
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index cff6fd190a28..77bb893bf2e9 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -18,7 +18,6 @@
18 18
19static struct usb_device_id id_table [] = { 19static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ 20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
21 { USB_DEVICE(0x413c, 0x8115) }, /* Dell Wireless HSDPA 5500 */
22 { }, 21 { },
23}; 22};
24MODULE_DEVICE_TABLE(usb, id_table); 23MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index e67ce25f7512..86724e885704 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -383,6 +383,10 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
383 } 383 }
384 384
385 baud = tty_get_baud_rate(port->tty); 385 baud = tty_get_baud_rate(port->tty);
386 if (baud == 0) {
387 dbg("%s - tty_get_baud_rate says 0 baud", __FUNCTION__);
388 return;
389 }
386 urb_value = BELKIN_SA_BAUD(baud); 390 urb_value = BELKIN_SA_BAUD(baud);
387 /* Clip to maximum speed */ 391 /* Clip to maximum speed */
388 if (urb_value == 0) 392 if (urb_value == 0)
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 7b1673a44077..1370c423d7c2 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -538,6 +538,8 @@ static struct usb_device_id id_table_combined [] = {
538 { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_VCP_PID) }, 538 { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_VCP_PID) },
539 { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_D2XX_PID) }, 539 { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_D2XX_PID) },
540 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, 540 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) },
541 { USB_DEVICE(EVOLUTION_VID, EVO_HYBRID_PID) },
542 { USB_DEVICE(EVOLUTION_VID, EVO_RCM4_PID) },
541 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, 543 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) },
542 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, 544 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) },
543 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) }, 545 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16C_PID) },
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index d9e49716db13..c70e1de6389e 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -430,6 +430,9 @@
430 */ 430 */
431#define EVOLUTION_VID 0xDEEE /* Vendor ID */ 431#define EVOLUTION_VID 0xDEEE /* Vendor ID */
432#define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */ 432#define EVOLUTION_ER1_PID 0x0300 /* ER1 Control Module */
433#define EVO_8U232AM_PID 0x02FF /* Evolution robotics RCM2 (FT232AM)*/
434#define EVO_HYBRID_PID 0x0302 /* Evolution robotics RCM4 PID (FT232BM)*/
435#define EVO_RCM4_PID 0x0303 /* Evolution robotics RCM4 PID */
433 436
434/* Pyramid Computer GmbH */ 437/* Pyramid Computer GmbH */
435#define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */ 438#define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 04bd3b7a2985..f1c90cfe7251 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Garmin GPS driver 2 * Garmin GPS driver
3 * 3 *
4 * Copyright (C) 2006 Hermann Kneissel herkne@users.sourceforge.net 4 * Copyright (C) 2006,2007 Hermann Kneissel herkne@users.sourceforge.net
5 * 5 *
6 * The latest version of the driver can be found at 6 * The latest version of the driver can be found at
7 * http://sourceforge.net/projects/garmin-gps/ 7 * http://sourceforge.net/projects/garmin-gps/
@@ -34,6 +34,7 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36#include <asm/uaccess.h> 36#include <asm/uaccess.h>
37#include <asm/atomic.h>
37#include <linux/usb.h> 38#include <linux/usb.h>
38#include <linux/usb/serial.h> 39#include <linux/usb/serial.h>
39 40
@@ -52,7 +53,7 @@ static int debug = 0;
52 */ 53 */
53 54
54#define VERSION_MAJOR 0 55#define VERSION_MAJOR 0
55#define VERSION_MINOR 28 56#define VERSION_MINOR 31
56 57
57#define _STR(s) #s 58#define _STR(s) #s
58#define _DRIVER_VERSION(a,b) "v" _STR(a) "." _STR(b) 59#define _DRIVER_VERSION(a,b) "v" _STR(a) "." _STR(b)
@@ -141,6 +142,8 @@ struct garmin_data {
141 __u8 inbuffer [GPS_IN_BUFSIZ]; /* tty -> usb */ 142 __u8 inbuffer [GPS_IN_BUFSIZ]; /* tty -> usb */
142 __u8 outbuffer[GPS_OUT_BUFSIZ]; /* usb -> tty */ 143 __u8 outbuffer[GPS_OUT_BUFSIZ]; /* usb -> tty */
143 __u8 privpkt[4*6]; 144 __u8 privpkt[4*6];
145 atomic_t req_count;
146 atomic_t resp_count;
144 spinlock_t lock; 147 spinlock_t lock;
145 struct list_head pktlist; 148 struct list_head pktlist;
146}; 149};
@@ -171,8 +174,6 @@ struct garmin_data {
171#define CLEAR_HALT_REQUIRED 0x0001 174#define CLEAR_HALT_REQUIRED 0x0001
172 175
173#define FLAGS_QUEUING 0x0100 176#define FLAGS_QUEUING 0x0100
174#define FLAGS_APP_RESP_SEEN 0x0200
175#define FLAGS_APP_REQ_SEEN 0x0400
176#define FLAGS_DROP_DATA 0x0800 177#define FLAGS_DROP_DATA 0x0800
177 178
178#define FLAGS_GSP_SKIP 0x1000 179#define FLAGS_GSP_SKIP 0x1000
@@ -186,7 +187,8 @@ struct garmin_data {
186/* function prototypes */ 187/* function prototypes */
187static void gsp_next_packet(struct garmin_data * garmin_data_p); 188static void gsp_next_packet(struct garmin_data * garmin_data_p);
188static int garmin_write_bulk(struct usb_serial_port *port, 189static int garmin_write_bulk(struct usb_serial_port *port,
189 const unsigned char *buf, int count); 190 const unsigned char *buf, int count,
191 int dismiss_ack);
190 192
191/* some special packets to be send or received */ 193/* some special packets to be send or received */
192static unsigned char const GARMIN_START_SESSION_REQ[] 194static unsigned char const GARMIN_START_SESSION_REQ[]
@@ -233,9 +235,7 @@ static struct usb_driver garmin_driver = {
233 235
234static inline int noResponseFromAppLayer(struct garmin_data * garmin_data_p) 236static inline int noResponseFromAppLayer(struct garmin_data * garmin_data_p)
235{ 237{
236 return ((garmin_data_p->flags 238 return atomic_read(&garmin_data_p->req_count) == atomic_read(&garmin_data_p->resp_count);
237 & (FLAGS_APP_REQ_SEEN|FLAGS_APP_RESP_SEEN))
238 == FLAGS_APP_REQ_SEEN);
239} 239}
240 240
241 241
@@ -463,7 +463,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
463 usbdata[2] = __cpu_to_le32(size); 463 usbdata[2] = __cpu_to_le32(size);
464 464
465 garmin_write_bulk (garmin_data_p->port, garmin_data_p->inbuffer, 465 garmin_write_bulk (garmin_data_p->port, garmin_data_p->inbuffer,
466 GARMIN_PKTHDR_LENGTH+size); 466 GARMIN_PKTHDR_LENGTH+size, 0);
467 467
468 /* if this was an abort-transfer command, flush all 468 /* if this was an abort-transfer command, flush all
469 queued data. */ 469 queued data. */
@@ -818,7 +818,7 @@ static int nat_receive(struct garmin_data * garmin_data_p,
818 if (garmin_data_p->insize >= len) { 818 if (garmin_data_p->insize >= len) {
819 garmin_write_bulk (garmin_data_p->port, 819 garmin_write_bulk (garmin_data_p->port,
820 garmin_data_p->inbuffer, 820 garmin_data_p->inbuffer,
821 len); 821 len, 0);
822 garmin_data_p->insize = 0; 822 garmin_data_p->insize = 0;
823 823
824 /* if this was an abort-transfer command, 824 /* if this was an abort-transfer command,
@@ -893,10 +893,11 @@ static int garmin_clear(struct garmin_data * garmin_data_p)
893 893
894 struct usb_serial_port *port = garmin_data_p->port; 894 struct usb_serial_port *port = garmin_data_p->port;
895 895
896 if (port != NULL && garmin_data_p->flags & FLAGS_APP_RESP_SEEN) { 896 if (port != NULL && atomic_read(&garmin_data_p->resp_count)) {
897 /* send a terminate command */ 897 /* send a terminate command */
898 status = garmin_write_bulk(port, GARMIN_STOP_TRANSFER_REQ, 898 status = garmin_write_bulk(port, GARMIN_STOP_TRANSFER_REQ,
899 sizeof(GARMIN_STOP_TRANSFER_REQ)); 899 sizeof(GARMIN_STOP_TRANSFER_REQ),
900 1);
900 } 901 }
901 902
902 /* flush all queued data */ 903 /* flush all queued data */
@@ -939,7 +940,8 @@ static int garmin_init_session(struct usb_serial_port *port)
939 dbg("%s - starting session ...", __FUNCTION__); 940 dbg("%s - starting session ...", __FUNCTION__);
940 garmin_data_p->state = STATE_ACTIVE; 941 garmin_data_p->state = STATE_ACTIVE;
941 status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ, 942 status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ,
942 sizeof(GARMIN_START_SESSION_REQ)); 943 sizeof(GARMIN_START_SESSION_REQ),
944 0);
943 945
944 if (status >= 0) { 946 if (status >= 0) {
945 947
@@ -950,7 +952,8 @@ static int garmin_init_session(struct usb_serial_port *port)
950 /* not needed, but the win32 driver does it too ... */ 952 /* not needed, but the win32 driver does it too ... */
951 status = garmin_write_bulk(port, 953 status = garmin_write_bulk(port,
952 GARMIN_START_SESSION_REQ2, 954 GARMIN_START_SESSION_REQ2,
953 sizeof(GARMIN_START_SESSION_REQ2)); 955 sizeof(GARMIN_START_SESSION_REQ2),
956 0);
954 if (status >= 0) { 957 if (status >= 0) {
955 status = 0; 958 status = 0;
956 spin_lock_irqsave(&garmin_data_p->lock, flags); 959 spin_lock_irqsave(&garmin_data_p->lock, flags);
@@ -987,6 +990,8 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp)
987 garmin_data_p->mode = initial_mode; 990 garmin_data_p->mode = initial_mode;
988 garmin_data_p->count = 0; 991 garmin_data_p->count = 0;
989 garmin_data_p->flags = 0; 992 garmin_data_p->flags = 0;
993 atomic_set(&garmin_data_p->req_count, 0);
994 atomic_set(&garmin_data_p->resp_count, 0);
990 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 995 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
991 996
992 /* shutdown any bulk reads that might be going on */ 997 /* shutdown any bulk reads that might be going on */
@@ -1035,28 +1040,39 @@ static void garmin_write_bulk_callback (struct urb *urb)
1035{ 1040{
1036 unsigned long flags; 1041 unsigned long flags;
1037 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1042 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1038 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1039 int status = urb->status; 1043 int status = urb->status;
1040 1044
1041 /* free up the transfer buffer, as usb_free_urb() does not do this */ 1045 if (port) {
1042 kfree (urb->transfer_buffer); 1046 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1043 1047
1044 dbg("%s - port %d", __FUNCTION__, port->number); 1048 dbg("%s - port %d", __FUNCTION__, port->number);
1045 1049
1046 if (status) { 1050 if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer)
1047 dbg("%s - nonzero write bulk status received: %d", 1051 && (garmin_data_p->mode == MODE_GARMIN_SERIAL)) {
1048 __FUNCTION__, status); 1052 gsp_send_ack(garmin_data_p, ((__u8 *)urb->transfer_buffer)[4]);
1049 spin_lock_irqsave(&garmin_data_p->lock, flags); 1053 }
1050 garmin_data_p->flags |= CLEAR_HALT_REQUIRED; 1054
1051 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 1055 if (status) {
1056 dbg("%s - nonzero write bulk status received: %d",
1057 __FUNCTION__, urb->status);
1058 spin_lock_irqsave(&garmin_data_p->lock, flags);
1059 garmin_data_p->flags |= CLEAR_HALT_REQUIRED;
1060 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1061 }
1062
1063 usb_serial_port_softint(port);
1052 } 1064 }
1053 1065
1054 usb_serial_port_softint(port); 1066 /* Ignore errors that resulted from garmin_write_bulk with dismiss_ack=1 */
1067
1068 /* free up the transfer buffer, as usb_free_urb() does not do this */
1069 kfree (urb->transfer_buffer);
1055} 1070}
1056 1071
1057 1072
1058static int garmin_write_bulk (struct usb_serial_port *port, 1073static int garmin_write_bulk (struct usb_serial_port *port,
1059 const unsigned char *buf, int count) 1074 const unsigned char *buf, int count,
1075 int dismiss_ack)
1060{ 1076{
1061 unsigned long flags; 1077 unsigned long flags;
1062 struct usb_serial *serial = port->serial; 1078 struct usb_serial *serial = port->serial;
@@ -1093,13 +1109,12 @@ static int garmin_write_bulk (struct usb_serial_port *port,
1093 usb_sndbulkpipe (serial->dev, 1109 usb_sndbulkpipe (serial->dev,
1094 port->bulk_out_endpointAddress), 1110 port->bulk_out_endpointAddress),
1095 buffer, count, 1111 buffer, count,
1096 garmin_write_bulk_callback, port); 1112 garmin_write_bulk_callback,
1113 dismiss_ack ? NULL : port);
1097 urb->transfer_flags |= URB_ZERO_PACKET; 1114 urb->transfer_flags |= URB_ZERO_PACKET;
1098 1115
1099 if (GARMIN_LAYERID_APPL == getLayerId(buffer)) { 1116 if (GARMIN_LAYERID_APPL == getLayerId(buffer)) {
1100 spin_lock_irqsave(&garmin_data_p->lock, flags); 1117 atomic_inc(&garmin_data_p->req_count);
1101 garmin_data_p->flags |= FLAGS_APP_REQ_SEEN;
1102 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1103 if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { 1118 if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
1104 pkt_clear(garmin_data_p); 1119 pkt_clear(garmin_data_p);
1105 garmin_data_p->state = STATE_GSP_WAIT_DATA; 1120 garmin_data_p->state = STATE_GSP_WAIT_DATA;
@@ -1114,13 +1129,6 @@ static int garmin_write_bulk (struct usb_serial_port *port,
1114 "failed with status = %d\n", 1129 "failed with status = %d\n",
1115 __FUNCTION__, status); 1130 __FUNCTION__, status);
1116 count = status; 1131 count = status;
1117 } else {
1118
1119 if (GARMIN_LAYERID_APPL == getLayerId(buffer)
1120 && (garmin_data_p->mode == MODE_GARMIN_SERIAL)) {
1121
1122 gsp_send_ack(garmin_data_p, buffer[4]);
1123 }
1124 } 1132 }
1125 1133
1126 /* we are done with this urb, so let the host driver 1134 /* we are done with this urb, so let the host driver
@@ -1135,7 +1143,6 @@ static int garmin_write_bulk (struct usb_serial_port *port,
1135static int garmin_write (struct usb_serial_port *port, 1143static int garmin_write (struct usb_serial_port *port,
1136 const unsigned char *buf, int count) 1144 const unsigned char *buf, int count)
1137{ 1145{
1138 unsigned long flags;
1139 int pktid, pktsiz, len; 1146 int pktid, pktsiz, len;
1140 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1147 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1141 __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; 1148 __le32 *privpkt = (__le32 *)garmin_data_p->privpkt;
@@ -1186,9 +1193,7 @@ static int garmin_write (struct usb_serial_port *port,
1186 break; 1193 break;
1187 1194
1188 case PRIV_PKTID_RESET_REQ: 1195 case PRIV_PKTID_RESET_REQ:
1189 spin_lock_irqsave(&garmin_data_p->lock, flags); 1196 atomic_inc(&garmin_data_p->req_count);
1190 garmin_data_p->flags |= FLAGS_APP_REQ_SEEN;
1191 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1192 break; 1197 break;
1193 1198
1194 case PRIV_PKTID_SET_DEF_MODE: 1199 case PRIV_PKTID_SET_DEF_MODE:
@@ -1241,8 +1246,6 @@ static int garmin_chars_in_buffer (struct usb_serial_port *port)
1241static void garmin_read_process(struct garmin_data * garmin_data_p, 1246static void garmin_read_process(struct garmin_data * garmin_data_p,
1242 unsigned char *data, unsigned data_length) 1247 unsigned char *data, unsigned data_length)
1243{ 1248{
1244 unsigned long flags;
1245
1246 if (garmin_data_p->flags & FLAGS_DROP_DATA) { 1249 if (garmin_data_p->flags & FLAGS_DROP_DATA) {
1247 /* abort-transfer cmd is actice */ 1250 /* abort-transfer cmd is actice */
1248 dbg("%s - pkt dropped", __FUNCTION__); 1251 dbg("%s - pkt dropped", __FUNCTION__);
@@ -1254,9 +1257,7 @@ static void garmin_read_process(struct garmin_data * garmin_data_p,
1254 the device */ 1257 the device */
1255 if (0 == memcmp(data, GARMIN_APP_LAYER_REPLY, 1258 if (0 == memcmp(data, GARMIN_APP_LAYER_REPLY,
1256 sizeof(GARMIN_APP_LAYER_REPLY))) { 1259 sizeof(GARMIN_APP_LAYER_REPLY))) {
1257 spin_lock_irqsave(&garmin_data_p->lock, flags); 1260 atomic_inc(&garmin_data_p->resp_count);
1258 garmin_data_p->flags |= FLAGS_APP_RESP_SEEN;
1259 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1260 } 1261 }
1261 1262
1262 /* if throttling is active or postprecessing is required 1263 /* if throttling is active or postprecessing is required
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 0455c1552ae9..6a3a704b5849 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -545,6 +545,7 @@ static struct usb_device_id ipaq_id_table [] = {
545 { USB_DEVICE(0x413C, 0x4009) }, /* Dell Axim USB Sync */ 545 { USB_DEVICE(0x413C, 0x4009) }, /* Dell Axim USB Sync */
546 { USB_DEVICE(0x4505, 0x0010) }, /* Smartphone */ 546 { USB_DEVICE(0x4505, 0x0010) }, /* Smartphone */
547 { USB_DEVICE(0x5E04, 0xCE00) }, /* SAGEM Wireless Assistant */ 547 { USB_DEVICE(0x5E04, 0xCE00) }, /* SAGEM Wireless Assistant */
548 { USB_DEVICE(0x0BB4, 0x00CF) }, /* HTC smartphone modems */
548 { } /* Terminating entry */ 549 { } /* Terminating entry */
549}; 550};
550 551
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 84c12b5f1271..4cb3c165742b 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -110,6 +110,7 @@ static int option_send_setup(struct usb_serial_port *port);
110#define HUAWEI_PRODUCT_E220 0x1003 110#define HUAWEI_PRODUCT_E220 0x1003
111 111
112#define NOVATELWIRELESS_VENDOR_ID 0x1410 112#define NOVATELWIRELESS_VENDOR_ID 0x1410
113#define DELL_VENDOR_ID 0x413C
113 114
114#define ANYDATA_VENDOR_ID 0x16d5 115#define ANYDATA_VENDOR_ID 0x16d5
115#define ANYDATA_PRODUCT_ADU_E100A 0x6501 116#define ANYDATA_PRODUCT_ADU_E100A 0x6501
@@ -119,8 +120,6 @@ static int option_send_setup(struct usb_serial_port *port);
119#define BANDRICH_PRODUCT_C100_1 0x1002 120#define BANDRICH_PRODUCT_C100_1 0x1002
120#define BANDRICH_PRODUCT_C100_2 0x1003 121#define BANDRICH_PRODUCT_C100_2 0x1003
121 122
122#define DELL_VENDOR_ID 0x413C
123
124static struct usb_device_id option_ids[] = { 123static struct usb_device_id option_ids[] = {
125 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 124 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
126 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 125 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
@@ -171,11 +170,16 @@ static struct usb_device_id option_ids[] = {
171 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2110) }, /* Novatel Merlin ES620 / Merlin ES720 / Ovation U720 */ 170 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2110) }, /* Novatel Merlin ES620 / Merlin ES720 / Ovation U720 */
172 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */ 171 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2130) }, /* Novatel Merlin ES620 SM Bus */
173 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */ 172 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, 0x2410) }, /* Novatel EU740 */
173 { USB_DEVICE(DELL_VENDOR_ID, 0x8114) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */
174 { USB_DEVICE(DELL_VENDOR_ID, 0x8115) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */
175 { USB_DEVICE(DELL_VENDOR_ID, 0x8116) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */
176 { USB_DEVICE(DELL_VENDOR_ID, 0x8117) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */
177 { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */
178 { USB_DEVICE(DELL_VENDOR_ID, 0x8128) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */
174 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, 179 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) },
175 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, 180 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) },
176 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, 181 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) },
177 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, 182 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) },
178 { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard */
179 { } /* Terminating entry */ 183 { } /* Terminating entry */
180}; 184};
181MODULE_DEVICE_TABLE(usb, option_ids); 185MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index d7db71eca520..833ada47fc54 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -818,19 +818,17 @@ static int oti6858_ioctl(struct usb_serial_port *port, struct file *file,
818 818
819 switch (cmd) { 819 switch (cmd) {
820 case TCGETS: 820 case TCGETS:
821 if (copy_to_user(user_arg, port->tty->termios, 821 if (kernel_termios_to_user_termios((struct ktermios __user *)arg,
822 sizeof(struct ktermios))) { 822 port->tty->termios))
823 return -EFAULT; 823 return -EFAULT;
824 }
825 return 0; 824 return 0;
826 825
827 case TCSETS: 826 case TCSETS:
828 case TCSETSW: /* FIXME: this is not the same! */ 827 case TCSETSW: /* FIXME: this is not the same! */
829 case TCSETSF: /* FIXME: this is not the same! */ 828 case TCSETSF: /* FIXME: this is not the same! */
830 if (copy_from_user(port->tty->termios, user_arg, 829 if (user_termios_to_kernel_termios(port->tty->termios,
831 sizeof(struct ktermios))) { 830 (struct ktermios __user *)arg))
832 return -EFAULT; 831 return -EFAULT;
833 }
834 oti6858_set_termios(port, NULL); 832 oti6858_set_termios(port, NULL);
835 return 0; 833 return 0;
836 834
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 86899d55d8d8..51669b7622bb 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -74,13 +74,13 @@
74#include <linux/usb/serial.h> 74#include <linux/usb/serial.h>
75 75
76 76
77#ifndef CONFIG_USB_SAFE_PADDED 77#ifndef CONFIG_USB_SERIAL_SAFE_PADDED
78#define CONFIG_USB_SAFE_PADDED 0 78#define CONFIG_USB_SERIAL_SAFE_PADDED 0
79#endif 79#endif
80 80
81static int debug; 81static int debug;
82static int safe = 1; 82static int safe = 1;
83static int padded = CONFIG_USB_SAFE_PADDED; 83static int padded = CONFIG_USB_SERIAL_SAFE_PADDED;
84 84
85#define DRIVER_VERSION "v0.0b" 85#define DRIVER_VERSION "v0.0b"
86#define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com" 86#define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com"
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 7d84a7647e81..30e08c0bcdc2 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -104,6 +104,8 @@ static struct usb_device_id id_table [] = {
104 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 104 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
105 { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_TJ25_ID), 105 { USB_DEVICE(SONY_VENDOR_ID, SONY_CLIE_TJ25_ID),
106 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 106 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
107 { USB_DEVICE(ACER_VENDOR_ID, ACER_S10_ID),
108 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
107 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), 109 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID),
108 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 110 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
109 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), 111 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID),
diff --git a/drivers/usb/serial/visor.h b/drivers/usb/serial/visor.h
index 4ce6f62a6f39..57229cf66477 100644
--- a/drivers/usb/serial/visor.h
+++ b/drivers/usb/serial/visor.h
@@ -48,6 +48,9 @@
48#define SONY_CLIE_UX50_ID 0x0144 48#define SONY_CLIE_UX50_ID 0x0144
49#define SONY_CLIE_TJ25_ID 0x0169 49#define SONY_CLIE_TJ25_ID 0x0169
50 50
51#define ACER_VENDOR_ID 0x0502
52#define ACER_S10_ID 0x0001
53
51#define SAMSUNG_VENDOR_ID 0x04E8 54#define SAMSUNG_VENDOR_ID 0x04E8
52#define SAMSUNG_SCH_I330_ID 0x8001 55#define SAMSUNG_SCH_I330_ID 0x8001
53#define SAMSUNG_SPH_I500_ID 0x6601 56#define SAMSUNG_SPH_I500_ID 0x6601
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index d8d008d42946..2d92ce31018f 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -342,7 +342,7 @@ UNUSUAL_DEV( 0x04b0, 0x040d, 0x0100, 0x0100,
342 US_FL_FIX_CAPACITY), 342 US_FL_FIX_CAPACITY),
343 343
344/* Reported by Emil Larsson <emil@swip.net> */ 344/* Reported by Emil Larsson <emil@swip.net> */
345UNUSUAL_DEV( 0x04b0, 0x0411, 0x0100, 0x0100, 345UNUSUAL_DEV( 0x04b0, 0x0411, 0x0100, 0x0101,
346 "NIKON", 346 "NIKON",
347 "NIKON DSC D80", 347 "NIKON DSC D80",
348 US_SC_DEVICE, US_PR_DEVICE, NULL, 348 US_SC_DEVICE, US_PR_DEVICE, NULL,
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 28842d208bb0..25e557d4fe6b 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -112,13 +112,6 @@ module_param(delay_use, uint, S_IRUGO | S_IWUSR);
112MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device"); 112MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device");
113 113
114 114
115/* These are used to make sure the module doesn't unload before all the
116 * threads have exited.
117 */
118static atomic_t total_threads = ATOMIC_INIT(0);
119static DECLARE_COMPLETION(threads_gone);
120
121
122/* 115/*
123 * The entries in this table correspond, line for line, 116 * The entries in this table correspond, line for line,
124 * with the entries of us_unusual_dev_list[]. 117 * with the entries of us_unusual_dev_list[].
@@ -879,9 +872,6 @@ static void quiesce_and_remove_host(struct us_data *us)
879 usb_stor_stop_transport(us); 872 usb_stor_stop_transport(us);
880 wake_up(&us->delay_wait); 873 wake_up(&us->delay_wait);
881 874
882 /* It doesn't matter if the SCSI-scanning thread is still running.
883 * The thread will exit when it sees the DISCONNECTING flag. */
884
885 /* queuecommand won't accept any new commands and the control 875 /* queuecommand won't accept any new commands and the control
886 * thread won't execute a previously-queued command. If there 876 * thread won't execute a previously-queued command. If there
887 * is such a command pending, complete it with an error. */ 877 * is such a command pending, complete it with an error. */
@@ -891,12 +881,16 @@ static void quiesce_and_remove_host(struct us_data *us)
891 scsi_lock(host); 881 scsi_lock(host);
892 us->srb->scsi_done(us->srb); 882 us->srb->scsi_done(us->srb);
893 us->srb = NULL; 883 us->srb = NULL;
884 complete(&us->notify); /* in case of an abort */
894 scsi_unlock(host); 885 scsi_unlock(host);
895 } 886 }
896 mutex_unlock(&us->dev_mutex); 887 mutex_unlock(&us->dev_mutex);
897 888
898 /* Now we own no commands so it's safe to remove the SCSI host */ 889 /* Now we own no commands so it's safe to remove the SCSI host */
899 scsi_remove_host(host); 890 scsi_remove_host(host);
891
892 /* Wait for the SCSI-scanning thread to stop */
893 wait_for_completion(&us->scanning_done);
900} 894}
901 895
902/* Second stage of disconnect processing: deallocate all resources */ 896/* Second stage of disconnect processing: deallocate all resources */
@@ -947,9 +941,8 @@ retry:
947 /* Should we unbind if no devices were detected? */ 941 /* Should we unbind if no devices were detected? */
948 } 942 }
949 943
950 scsi_host_put(us_to_host(us));
951 usb_autopm_put_interface(us->pusb_intf); 944 usb_autopm_put_interface(us->pusb_intf);
952 complete_and_exit(&threads_gone, 0); 945 complete_and_exit(&us->scanning_done, 0);
953} 946}
954 947
955 948
@@ -984,6 +977,7 @@ static int storage_probe(struct usb_interface *intf,
984 init_MUTEX_LOCKED(&(us->sema)); 977 init_MUTEX_LOCKED(&(us->sema));
985 init_completion(&(us->notify)); 978 init_completion(&(us->notify));
986 init_waitqueue_head(&us->delay_wait); 979 init_waitqueue_head(&us->delay_wait);
980 init_completion(&us->scanning_done);
987 981
988 /* Associate the us_data structure with the USB device */ 982 /* Associate the us_data structure with the USB device */
989 result = associate_dev(us, intf); 983 result = associate_dev(us, intf);
@@ -1033,11 +1027,6 @@ static int storage_probe(struct usb_interface *intf,
1033 goto BadDevice; 1027 goto BadDevice;
1034 } 1028 }
1035 1029
1036 /* Take a reference to the host for the scanning thread and
1037 * count it among all the threads we have launched. Then
1038 * start it up. */
1039 scsi_host_get(us_to_host(us));
1040 atomic_inc(&total_threads);
1041 usb_autopm_get_interface(intf); /* dropped in the scanning thread */ 1030 usb_autopm_get_interface(intf); /* dropped in the scanning thread */
1042 wake_up_process(th); 1031 wake_up_process(th);
1043 1032
@@ -1104,16 +1093,6 @@ static void __exit usb_stor_exit(void)
1104 US_DEBUGP("-- calling usb_deregister()\n"); 1093 US_DEBUGP("-- calling usb_deregister()\n");
1105 usb_deregister(&usb_storage_driver) ; 1094 usb_deregister(&usb_storage_driver) ;
1106 1095
1107 /* Don't return until all of our control and scanning threads
1108 * have exited. Since each thread signals threads_gone as its
1109 * last act, we have to call wait_for_completion the right number
1110 * of times.
1111 */
1112 while (atomic_read(&total_threads) > 0) {
1113 wait_for_completion(&threads_gone);
1114 atomic_dec(&total_threads);
1115 }
1116
1117 usb_usual_clear_present(USB_US_TYPE_STOR); 1096 usb_usual_clear_present(USB_US_TYPE_STOR);
1118} 1097}
1119 1098
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 6445665b1577..8d87503e2560 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -150,6 +150,7 @@ struct us_data {
150 struct semaphore sema; /* to sleep thread on */ 150 struct semaphore sema; /* to sleep thread on */
151 struct completion notify; /* thread begin/end */ 151 struct completion notify; /* thread begin/end */
152 wait_queue_head_t delay_wait; /* wait during scan, reset */ 152 wait_queue_head_t delay_wait; /* wait during scan, reset */
153 struct completion scanning_done; /* wait for scan thread */
153 154
154 /* subdriver information */ 155 /* subdriver information */
155 void *extra; /* Any extra data */ 156 void *extra; /* Any extra data */
diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
index 80a81eccad36..832e4613673a 100644
--- a/drivers/video/au1100fb.c
+++ b/drivers/video/au1100fb.c
@@ -115,6 +115,52 @@ static int nocursor = 0;
115module_param(nocursor, int, 0644); 115module_param(nocursor, int, 0644);
116MODULE_PARM_DESC(nocursor, "cursor enable/disable"); 116MODULE_PARM_DESC(nocursor, "cursor enable/disable");
117 117
118/* fb_blank
119 * Blank the screen. Depending on the mode, the screen will be
120 * activated with the backlight color, or desactivated
121 */
122static int au1100fb_fb_blank(int blank_mode, struct fb_info *fbi)
123{
124 struct au1100fb_device *fbdev = to_au1100fb_device(fbi);
125
126 print_dbg("fb_blank %d %p", blank_mode, fbi);
127
128 switch (blank_mode) {
129
130 case VESA_NO_BLANKING:
131 /* Turn on panel */
132 fbdev->regs->lcd_control |= LCD_CONTROL_GO;
133#ifdef CONFIG_MIPS_PB1100
134 if (drv_info.panel_idx == 1) {
135 au_writew(au_readw(PB1100_G_CONTROL)
136 | (PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD),
137 PB1100_G_CONTROL);
138 }
139#endif
140 au_sync();
141 break;
142
143 case VESA_VSYNC_SUSPEND:
144 case VESA_HSYNC_SUSPEND:
145 case VESA_POWERDOWN:
146 /* Turn off panel */
147 fbdev->regs->lcd_control &= ~LCD_CONTROL_GO;
148#ifdef CONFIG_MIPS_PB1100
149 if (drv_info.panel_idx == 1) {
150 au_writew(au_readw(PB1100_G_CONTROL)
151 & ~(PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD),
152 PB1100_G_CONTROL);
153 }
154#endif
155 au_sync();
156 break;
157 default:
158 break;
159
160 }
161 return 0;
162}
163
118/* 164/*
119 * Set hardware with var settings. This will enable the controller with a specific 165 * Set hardware with var settings. This will enable the controller with a specific
120 * mode, normally validated with the fb_check_var method 166 * mode, normally validated with the fb_check_var method
@@ -272,52 +318,6 @@ int au1100fb_fb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned
272 return 0; 318 return 0;
273} 319}
274 320
275/* fb_blank
276 * Blank the screen. Depending on the mode, the screen will be
277 * activated with the backlight color, or desactivated
278 */
279int au1100fb_fb_blank(int blank_mode, struct fb_info *fbi)
280{
281 struct au1100fb_device *fbdev = to_au1100fb_device(fbi);
282
283 print_dbg("fb_blank %d %p", blank_mode, fbi);
284
285 switch (blank_mode) {
286
287 case VESA_NO_BLANKING:
288 /* Turn on panel */
289 fbdev->regs->lcd_control |= LCD_CONTROL_GO;
290#ifdef CONFIG_MIPS_PB1100
291 if (drv_info.panel_idx == 1) {
292 au_writew(au_readw(PB1100_G_CONTROL)
293 | (PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD),
294 PB1100_G_CONTROL);
295 }
296#endif
297 au_sync();
298 break;
299
300 case VESA_VSYNC_SUSPEND:
301 case VESA_HSYNC_SUSPEND:
302 case VESA_POWERDOWN:
303 /* Turn off panel */
304 fbdev->regs->lcd_control &= ~LCD_CONTROL_GO;
305#ifdef CONFIG_MIPS_PB1100
306 if (drv_info.panel_idx == 1) {
307 au_writew(au_readw(PB1100_G_CONTROL)
308 & ~(PB1100_G_CONTROL_BL | PB1100_G_CONTROL_VDD),
309 PB1100_G_CONTROL);
310 }
311#endif
312 au_sync();
313 break;
314 default:
315 break;
316
317 }
318 return 0;
319}
320
321/* fb_pan_display 321/* fb_pan_display
322 * Pan display in x and/or y as specified 322 * Pan display in x and/or y as specified
323 */ 323 */
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c
index 718b9f83736e..833b10c84064 100644
--- a/drivers/video/bw2.c
+++ b/drivers/video/bw2.c
@@ -233,9 +233,9 @@ static u8 bw2regs_66hz[] __devinitdata = {
233 0x10, 0x20, 0 233 0x10, 0x20, 0
234}; 234};
235 235
236static void __devinit bw2_do_default_mode(struct bw2_par *par, 236static int __devinit bw2_do_default_mode(struct bw2_par *par,
237 struct fb_info *info, 237 struct fb_info *info,
238 int *linebytes) 238 int *linebytes)
239{ 239{
240 u8 status, mon; 240 u8 status, mon;
241 u8 *p; 241 u8 *p;
@@ -266,17 +266,18 @@ static void __devinit bw2_do_default_mode(struct bw2_par *par,
266 break; 266 break;
267 267
268 case BWTWO_SR_ID_NOCONN: 268 case BWTWO_SR_ID_NOCONN:
269 return; 269 return 0;
270 270
271 default: 271 default:
272 prom_printf("bw2: can't handle SR %02x\n", 272 printk(KERN_ERR "bw2: can't handle SR %02x\n",
273 status); 273 status);
274 prom_halt(); 274 return -EINVAL;
275 } 275 }
276 for ( ; *p; p += 2) { 276 for ( ; *p; p += 2) {
277 u8 __iomem *regp = &((u8 __iomem *)par->regs)[p[0]]; 277 u8 __iomem *regp = &((u8 __iomem *)par->regs)[p[0]];
278 sbus_writeb(p[1], regp); 278 sbus_writeb(p[1], regp);
279 } 279 }
280 return 0;
280} 281}
281 282
282static int __devinit bw2_probe(struct of_device *op, const struct of_device_id *match) 283static int __devinit bw2_probe(struct of_device *op, const struct of_device_id *match)
@@ -312,8 +313,11 @@ static int __devinit bw2_probe(struct of_device *op, const struct of_device_id *
312 if (!par->regs) 313 if (!par->regs)
313 goto out_release_fb; 314 goto out_release_fb;
314 315
315 if (!of_find_property(dp, "width", NULL)) 316 if (!of_find_property(dp, "width", NULL)) {
316 bw2_do_default_mode(par, info, &linebytes); 317 err = bw2_do_default_mode(par, info, &linebytes);
318 if (err)
319 goto out_unmap_regs;
320 }
317 321
318 par->fbsize = PAGE_ALIGN(linebytes * info->var.yres); 322 par->fbsize = PAGE_ALIGN(linebytes * info->var.yres);
319 323
diff --git a/drivers/video/cg3.c b/drivers/video/cg3.c
index 5741b46ade1b..a5c7fb331527 100644
--- a/drivers/video/cg3.c
+++ b/drivers/video/cg3.c
@@ -315,7 +315,7 @@ static u_char cg3_dacvals[] __devinitdata = {
315 4, 0xff, 5, 0x00, 6, 0x70, 7, 0x00, 0 315 4, 0xff, 5, 0x00, 6, 0x70, 7, 0x00, 0
316}; 316};
317 317
318static void __devinit cg3_do_default_mode(struct cg3_par *par) 318static int __devinit cg3_do_default_mode(struct cg3_par *par)
319{ 319{
320 enum cg3_type type; 320 enum cg3_type type;
321 u8 *p; 321 u8 *p;
@@ -332,10 +332,9 @@ static void __devinit cg3_do_default_mode(struct cg3_par *par)
332 else 332 else
333 type = CG3_AT_66HZ; 333 type = CG3_AT_66HZ;
334 } else { 334 } else {
335 prom_printf("cgthree: can't handle SR %02x\n", 335 printk(KERN_ERR "cgthree: can't handle SR %02x\n",
336 status); 336 status);
337 prom_halt(); 337 return -EINVAL;
338 return;
339 } 338 }
340 } 339 }
341 340
@@ -351,6 +350,7 @@ static void __devinit cg3_do_default_mode(struct cg3_par *par)
351 regp = (u8 __iomem *)&par->regs->cmap.control; 350 regp = (u8 __iomem *)&par->regs->cmap.control;
352 sbus_writeb(p[1], regp); 351 sbus_writeb(p[1], regp);
353 } 352 }
353 return 0;
354} 354}
355 355
356static int __devinit cg3_probe(struct of_device *op, 356static int __devinit cg3_probe(struct of_device *op,
@@ -400,8 +400,11 @@ static int __devinit cg3_probe(struct of_device *op,
400 400
401 cg3_blank(0, info); 401 cg3_blank(0, info);
402 402
403 if (!of_find_property(dp, "width", NULL)) 403 if (!of_find_property(dp, "width", NULL)) {
404 cg3_do_default_mode(par); 404 err = cg3_do_default_mode(par);
405 if (err)
406 goto out_unmap_screen;
407 }
405 408
406 if (fb_alloc_cmap(&info->cmap, 256, 0)) 409 if (fb_alloc_cmap(&info->cmap, 256, 0))
407 goto out_unmap_screen; 410 goto out_unmap_screen;
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index 49643969f9f8..5db6b1e489b0 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -145,7 +145,7 @@ config FRAMEBUFFER_CONSOLE_ROTATION
145 oriented. 145 oriented.
146 146
147config STI_CONSOLE 147config STI_CONSOLE
148 tristate "STI text console" 148 bool "STI text console"
149 depends on PARISC 149 depends on PARISC
150 default y 150 default y
151 help 151 help
diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c
index 7fa1afeae8dc..dda0586ab3f3 100644
--- a/drivers/video/console/newport_con.c
+++ b/drivers/video/console/newport_con.c
@@ -738,9 +738,8 @@ const struct consw newport_con = {
738#ifdef MODULE 738#ifdef MODULE
739static int __init newport_console_init(void) 739static int __init newport_console_init(void)
740{ 740{
741
742 if (!sgi_gfxaddr) 741 if (!sgi_gfxaddr)
743 return NULL; 742 return 0;
744 743
745 if (!npregs) 744 if (!npregs)
746 npregs = (struct newport_regs *)/* ioremap cannot fail */ 745 npregs = (struct newport_regs *)/* ioremap cannot fail */
diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c
index 870017d44970..e9ab657f0bb7 100644
--- a/drivers/video/console/sticore.c
+++ b/drivers/video/console/sticore.c
@@ -232,18 +232,14 @@ sti_bmove(struct sti_struct *sti, int src_y, int src_x,
232} 232}
233 233
234 234
235/* FIXME: Do we have another solution for this ? */ 235static void sti_flush(unsigned long start, unsigned long end)
236static void sti_flush(unsigned long from, unsigned long len)
237{ 236{
238 flush_data_cache(); 237 flush_icache_range(start, end);
239 flush_kernel_dcache_range(from, len);
240 flush_icache_range(from, from+len);
241} 238}
242 239
243void __devinit 240void __devinit
244sti_rom_copy(unsigned long base, unsigned long count, void *dest) 241sti_rom_copy(unsigned long base, unsigned long count, void *dest)
245{ 242{
246 unsigned long dest_len = count;
247 unsigned long dest_start = (unsigned long) dest; 243 unsigned long dest_start = (unsigned long) dest;
248 244
249 /* this still needs to be revisited (see arch/parisc/mm/init.c:246) ! */ 245 /* this still needs to be revisited (see arch/parisc/mm/init.c:246) ! */
@@ -260,7 +256,7 @@ sti_rom_copy(unsigned long base, unsigned long count, void *dest)
260 dest++; 256 dest++;
261 } 257 }
262 258
263 sti_flush(dest_start, dest_len); 259 sti_flush(dest_start, (unsigned long)dest);
264} 260}
265 261
266 262
@@ -663,7 +659,6 @@ sti_bmode_font_raw(struct sti_cooked_font *f)
663static void __devinit 659static void __devinit
664sti_bmode_rom_copy(unsigned long base, unsigned long count, void *dest) 660sti_bmode_rom_copy(unsigned long base, unsigned long count, void *dest)
665{ 661{
666 unsigned long dest_len = count;
667 unsigned long dest_start = (unsigned long) dest; 662 unsigned long dest_start = (unsigned long) dest;
668 663
669 while (count) { 664 while (count) {
@@ -672,7 +667,8 @@ sti_bmode_rom_copy(unsigned long base, unsigned long count, void *dest)
672 base += 4; 667 base += 4;
673 dest++; 668 dest++;
674 } 669 }
675 sti_flush(dest_start, dest_len); 670
671 sti_flush(dest_start, (unsigned long)dest);
676} 672}
677 673
678static struct sti_rom * __devinit 674static struct sti_rom * __devinit
diff --git a/drivers/video/imsttfb.c b/drivers/video/imsttfb.c
index 5715b8ad0ddc..94f4511023d8 100644
--- a/drivers/video/imsttfb.c
+++ b/drivers/video/imsttfb.c
@@ -1391,7 +1391,7 @@ init_imstt(struct fb_info *info)
1391 } 1391 }
1392 } 1392 }
1393 1393
1394#if USE_NV_MODES && defined(CONFIG_PPC) 1394#if USE_NV_MODES && defined(CONFIG_PPC32)
1395 { 1395 {
1396 int vmode = init_vmode, cmode = init_cmode; 1396 int vmode = init_vmode, cmode = init_cmode;
1397 1397
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 81e571d59b50..a280a52f8efe 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -66,7 +66,7 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state);
66 66
67#ifdef CONFIG_FB_PXA_PARAMETERS 67#ifdef CONFIG_FB_PXA_PARAMETERS
68#define PXAFB_OPTIONS_SIZE 256 68#define PXAFB_OPTIONS_SIZE 256
69static char g_options[PXAFB_OPTIONS_SIZE] __initdata = ""; 69static char g_options[PXAFB_OPTIONS_SIZE] __devinitdata = "";
70#endif 70#endif
71 71
72static inline void pxafb_schedule_work(struct pxafb_info *fbi, u_int state) 72static inline void pxafb_schedule_work(struct pxafb_info *fbi, u_int state)
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 2fbd8dd16df5..6840dfebe4d4 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -170,22 +170,24 @@ void __w1_remove_master_device(struct w1_master *dev)
170 170
171void w1_remove_master_device(struct w1_bus_master *bm) 171void w1_remove_master_device(struct w1_bus_master *bm)
172{ 172{
173 struct w1_master *dev = NULL; 173 struct w1_master *dev, *found = NULL;
174 174
175 list_for_each_entry(dev, &w1_masters, w1_master_entry) { 175 list_for_each_entry(dev, &w1_masters, w1_master_entry) {
176 if (!dev->initialized) 176 if (!dev->initialized)
177 continue; 177 continue;
178 178
179 if (dev->bus_master->data == bm->data) 179 if (dev->bus_master->data == bm->data) {
180 found = dev;
180 break; 181 break;
182 }
181 } 183 }
182 184
183 if (!dev) { 185 if (!found) {
184 printk(KERN_ERR "Device doesn't exist.\n"); 186 printk(KERN_ERR "Device doesn't exist.\n");
185 return; 187 return;
186 } 188 }
187 189
188 __w1_remove_master_device(dev); 190 __w1_remove_master_device(found);
189} 191}
190 192
191EXPORT_SYMBOL(w1_add_master_device); 193EXPORT_SYMBOL(w1_add_master_device);
diff --git a/drivers/zorro/zorro-sysfs.c b/drivers/zorro/zorro-sysfs.c
index 9130f1c12c26..808b4f8675c5 100644
--- a/drivers/zorro/zorro-sysfs.c
+++ b/drivers/zorro/zorro-sysfs.c
@@ -78,7 +78,7 @@ static ssize_t zorro_read_config(struct kobject *kobj,
78static struct bin_attribute zorro_config_attr = { 78static struct bin_attribute zorro_config_attr = {
79 .attr = { 79 .attr = {
80 .name = "config", 80 .name = "config",
81 .mode = S_IRUGO | S_IWUSR, 81 .mode = S_IRUGO,
82 }, 82 },
83 .size = sizeof(struct ConfigDev), 83 .size = sizeof(struct ConfigDev),
84 .read = zorro_read_config, 84 .read = zorro_read_config,