aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Kconfig6
-rw-r--r--drivers/acpi/acpi_memhotplug.c14
-rw-r--r--drivers/acpi/processor_idle.c8
-rw-r--r--drivers/base/bus.c108
-rw-r--r--drivers/base/class.c5
-rw-r--r--drivers/base/core.c26
-rw-r--r--drivers/base/dd.c4
-rw-r--r--drivers/base/dmapool.c13
-rw-r--r--drivers/base/topology.c3
-rw-r--r--drivers/block/aoe/aoe.h30
-rw-r--r--drivers/block/aoe/aoeblk.c44
-rw-r--r--drivers/block/aoe/aoechr.c18
-rw-r--r--drivers/block/aoe/aoecmd.c303
-rw-r--r--drivers/block/aoe/aoedev.c52
-rw-r--r--drivers/block/aoe/aoemain.c10
-rw-r--r--drivers/block/aoe/aoenet.c9
-rw-r--r--drivers/block/rd.c12
-rw-r--r--drivers/bluetooth/bcm203x.c17
-rw-r--r--drivers/bluetooth/dtl1_cs.c1
-rw-r--r--drivers/bluetooth/hci_usb.c3
-rw-r--r--drivers/char/Kconfig2
-rw-r--r--drivers/char/epca.c32
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c4
-rw-r--r--drivers/char/random.c1
-rw-r--r--drivers/char/rio/rioctrl.c4
-rw-r--r--drivers/char/specialix.c15
-rw-r--r--drivers/char/sx.c2
-rw-r--r--drivers/char/synclink.c4
-rw-r--r--drivers/char/watchdog/alim7101_wdt.c13
-rw-r--r--drivers/firmware/dcdbas.c7
-rw-r--r--drivers/hwmon/Kconfig10
-rw-r--r--drivers/hwmon/adm9240.c4
-rw-r--r--drivers/hwmon/lm78.c12
-rw-r--r--drivers/hwmon/smsc47m1.c11
-rw-r--r--drivers/hwmon/w83627ehf.c11
-rw-r--r--drivers/hwmon/w83781d.c30
-rw-r--r--drivers/hwmon/w83791d.c85
-rw-r--r--drivers/i2c/busses/i2c-isa.c2
-rw-r--r--drivers/ide/ide-taskfile.c13
-rw-r--r--drivers/ide/pci/sgiioc4.c2
-rw-r--r--drivers/infiniband/hw/amso1100/c2.c2
-rw-r--r--drivers/infiniband/hw/amso1100/c2_rnic.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_diag.c65
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c10
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c7
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c19
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c8
-rw-r--r--drivers/input/gameport/fm801-gp.c22
-rw-r--r--drivers/input/gameport/gameport.c18
-rw-r--r--drivers/input/keyboard/atkbd.c54
-rw-r--r--drivers/input/keyboard/corgikbd.c2
-rw-r--r--drivers/input/keyboard/locomokbd.c2
-rw-r--r--drivers/input/keyboard/spitzkbd.c2
-rw-r--r--drivers/input/serio/i8042.c13
-rw-r--r--drivers/input/serio/libps2.c3
-rw-r--r--drivers/input/serio/serio.c22
-rw-r--r--drivers/input/touchscreen/corgi_ts.c4
-rw-r--r--drivers/isdn/capi/capidrv.c3
-rw-r--r--drivers/isdn/hisax/config.c6
-rw-r--r--drivers/isdn/hisax/diva.c26
-rw-r--r--drivers/isdn/hysdn/boardergo.c34
-rw-r--r--drivers/isdn/hysdn/hysdn_defs.h2
-rw-r--r--drivers/isdn/hysdn/hysdn_proclog.c17
-rw-r--r--drivers/isdn/hysdn/hysdn_sched.c9
-rw-r--r--drivers/isdn/i4l/isdn_common.c9
-rw-r--r--drivers/isdn/icn/icn.c3
-rw-r--r--drivers/isdn/isdnloop/isdnloop.c73
-rw-r--r--drivers/isdn/isdnloop/isdnloop.h1
-rw-r--r--drivers/isdn/pcbit/drv.c16
-rw-r--r--drivers/leds/led-class.c26
-rw-r--r--drivers/leds/ledtrig-timer.c16
-rw-r--r--drivers/md/dm-crypt.c3
-rw-r--r--drivers/md/md.c1
-rw-r--r--drivers/message/i2o/bus-osm.c12
-rw-r--r--drivers/message/i2o/exec-osm.c17
-rw-r--r--drivers/misc/Kconfig11
-rw-r--r--drivers/misc/Makefile1
-rw-r--r--drivers/misc/ioc4.c (renamed from drivers/sn/ioc4.c)47
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/e100.c50
-rw-r--r--drivers/net/e1000/e1000_main.c4
-rw-r--r--drivers/net/ioc3-eth.c4
-rw-r--r--drivers/net/loopback.c39
-rw-r--r--drivers/net/myri_code.h8
-rw-r--r--drivers/net/myri_sbus.c4
-rw-r--r--drivers/net/r8169.c7
-rw-r--r--drivers/net/sb1250-mac.c2
-rw-r--r--drivers/net/sky2.c233
-rw-r--r--drivers/net/sky2.h15
-rw-r--r--drivers/net/smc91x.h18
-rw-r--r--drivers/net/sunbmac.c2
-rw-r--r--drivers/net/tg3.c19
-rw-r--r--drivers/net/ucc_geth.c633
-rw-r--r--drivers/net/ucc_geth.h248
-rw-r--r--drivers/net/ucc_geth_phy.c26
-rw-r--r--drivers/net/ucc_geth_phy.h2
-rw-r--r--drivers/net/wan/pc300_drv.c24
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c2
-rw-r--r--drivers/pci/hotplug/acpiphp.h2
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c2
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c2
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c1
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_core.c2
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_pci.c2
-rw-r--r--drivers/pci/hotplug/cpcihp_generic.c4
-rw-r--r--drivers/pci/hotplug/cpqphp.h1
-rw-r--r--drivers/pci/hotplug/cpqphp_core.c1
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c1
-rw-r--r--drivers/pci/hotplug/cpqphp_nvram.c1
-rw-r--r--drivers/pci/hotplug/cpqphp_pci.c1
-rw-r--r--drivers/pci/hotplug/cpqphp_sysfs.c1
-rw-r--r--drivers/pci/hotplug/fakephp.c13
-rw-r--r--drivers/pci/hotplug/ibmphp.h2
-rw-r--r--drivers/pci/hotplug/pci_hotplug.h236
-rw-r--r--drivers/pci/hotplug/pci_hotplug_core.c11
-rw-r--r--drivers/pci/hotplug/pciehp.h11
-rw-r--r--drivers/pci/hotplug/pciehp_core.c6
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c104
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c2
-rw-r--r--drivers/pci/hotplug/pcihp_skeleton.c2
-rw-r--r--drivers/pci/hotplug/rpadlpar_sysfs.c2
-rw-r--r--drivers/pci/hotplug/rpaphp.h2
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c2
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c2
-rw-r--r--drivers/pci/hotplug/shpchp.h4
-rw-r--r--drivers/pci/hotplug/shpchp_hpc.c82
-rw-r--r--drivers/pci/msi.c16
-rw-r--r--drivers/pci/pcie/portdrv.h4
-rw-r--r--drivers/pci/pcie/portdrv_core.c3
-rw-r--r--drivers/pci/pcie/portdrv_pci.c2
-rw-r--r--drivers/pci/probe.c92
-rw-r--r--drivers/pci/quirks.c97
-rw-r--r--drivers/pci/rom.c5
-rw-r--r--drivers/pci/search.c72
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c41
-rw-r--r--drivers/rtc/rtc-max6902.c2
-rw-r--r--drivers/rtc/rtc-v3020.c4
-rw-r--r--drivers/s390/block/dasd.c1
-rw-r--r--drivers/s390/char/monwriter.c14
-rw-r--r--drivers/s390/cio/device_fsm.c4
-rw-r--r--drivers/s390/cio/qdio.c2
-rw-r--r--drivers/sbus/char/bbc_envctrl.c4
-rw-r--r--drivers/sbus/char/envctrl.c4
-rw-r--r--drivers/scsi/BusLogic.c11
-rw-r--r--drivers/scsi/eata_pio.c2
-rw-r--r--drivers/scsi/fdomain.c9
-rw-r--r--drivers/scsi/initio.c19
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c2
-rw-r--r--drivers/scsi/qlogicpti.c2
-rw-r--r--drivers/scsi/qlogicpti_asm.c4
-rw-r--r--drivers/serial/Kconfig12
-rw-r--r--drivers/serial/ioc4_serial.c2
-rw-r--r--drivers/sn/Kconfig13
-rw-r--r--drivers/sn/Makefile1
-rw-r--r--drivers/telephony/ixj.c11
-rw-r--r--drivers/usb/Makefile2
-rw-r--r--drivers/usb/atm/cxacru.c3
-rw-r--r--drivers/usb/atm/speedtch.c93
-rw-r--r--drivers/usb/atm/ueagle-atm.c83
-rw-r--r--drivers/usb/atm/usbatm.c5
-rw-r--r--drivers/usb/class/cdc-acm.c29
-rw-r--r--drivers/usb/class/usblp.c79
-rw-r--r--drivers/usb/core/devio.c8
-rw-r--r--drivers/usb/core/endpoint.c22
-rw-r--r--drivers/usb/gadget/net2280.c24
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c2
-rw-r--r--drivers/usb/host/ehci-dbg.c4
-rw-r--r--drivers/usb/host/ehci-hcd.c70
-rw-r--r--drivers/usb/host/ehci-hub.c2
-rw-r--r--drivers/usb/host/ehci-pci.c2
-rw-r--r--drivers/usb/host/ehci-q.c6
-rw-r--r--drivers/usb/host/ehci.h22
-rw-r--r--drivers/usb/host/ohci-pnx4008.c9
-rw-r--r--drivers/usb/host/uhci-hcd.c44
-rw-r--r--drivers/usb/input/Kconfig10
-rw-r--r--drivers/usb/input/Makefile3
-rw-r--r--drivers/usb/input/hid-core.c29
-rw-r--r--drivers/usb/input/usbtouchscreen.c4
-rw-r--r--drivers/usb/input/wacom.h2
-rw-r--r--drivers/usb/input/wacom_sys.c20
-rw-r--r--drivers/usb/input/wacom_wac.c121
-rw-r--r--drivers/usb/input/wacom_wac.h2
-rw-r--r--drivers/usb/input/xpad.c139
-rw-r--r--drivers/usb/misc/Kconfig10
-rw-r--r--drivers/usb/misc/Makefile1
-rw-r--r--drivers/usb/misc/adutux.c3
-rw-r--r--drivers/usb/misc/ftdi-elan.c36
-rw-r--r--drivers/usb/misc/trancevibrator.c (renamed from drivers/usb/input/trancevibrator.c)0
-rw-r--r--drivers/usb/net/Kconfig8
-rw-r--r--drivers/usb/net/Makefile1
-rw-r--r--drivers/usb/net/asix.c48
-rw-r--r--drivers/usb/net/cdc_ether.c2
-rw-r--r--drivers/usb/net/kaweth.c204
-rw-r--r--drivers/usb/net/mcs7830.c534
-rw-r--r--drivers/usb/net/usbnet.c55
-rw-r--r--drivers/usb/net/usbnet.h5
-rw-r--r--drivers/usb/serial/Kconfig13
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/airprime.c7
-rw-r--r--drivers/usb/serial/cp2101.c1
-rw-r--r--drivers/usb/serial/ftdi_sio.c254
-rw-r--r--drivers/usb/serial/mos7720.c1683
-rw-r--r--drivers/usb/serial/mos7840.c3
-rw-r--r--drivers/usb/serial/sierra.c697
-rw-r--r--drivers/usb/storage/unusual_devs.h24
-rw-r--r--drivers/video/controlfb.c8
-rw-r--r--drivers/video/igafb.c7
-rw-r--r--drivers/video/platinumfb.c5
-rw-r--r--drivers/video/valkyriefb.c4
-rw-r--r--drivers/w1/Kconfig1
211 files changed, 6062 insertions, 2234 deletions
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 263e86ddc1a4..f39463418904 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -14,6 +14,10 @@ source "drivers/pnp/Kconfig"
14 14
15source "drivers/block/Kconfig" 15source "drivers/block/Kconfig"
16 16
17# misc before ide - BLK_DEV_SGIIOC4 depends on SGI_IOC4
18
19source "drivers/misc/Kconfig"
20
17source "drivers/ide/Kconfig" 21source "drivers/ide/Kconfig"
18 22
19source "drivers/scsi/Kconfig" 23source "drivers/scsi/Kconfig"
@@ -52,8 +56,6 @@ source "drivers/w1/Kconfig"
52 56
53source "drivers/hwmon/Kconfig" 57source "drivers/hwmon/Kconfig"
54 58
55source "drivers/misc/Kconfig"
56
57source "drivers/mfd/Kconfig" 59source "drivers/mfd/Kconfig"
58 60
59source "drivers/media/Kconfig" 61source "drivers/media/Kconfig"
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 98099de59b45..6bcd9e8e7bcb 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -85,6 +85,8 @@ struct acpi_memory_device {
85 struct list_head res_list; 85 struct list_head res_list;
86}; 86};
87 87
88static int acpi_hotmem_initialized;
89
88static acpi_status 90static acpi_status
89acpi_memory_get_resource(struct acpi_resource *resource, void *context) 91acpi_memory_get_resource(struct acpi_resource *resource, void *context)
90{ 92{
@@ -414,7 +416,7 @@ static int acpi_memory_device_add(struct acpi_device *device)
414 /* Set the device state */ 416 /* Set the device state */
415 mem_device->state = MEMORY_POWER_ON_STATE; 417 mem_device->state = MEMORY_POWER_ON_STATE;
416 418
417 printk(KERN_INFO "%s \n", acpi_device_name(device)); 419 printk(KERN_DEBUG "%s \n", acpi_device_name(device));
418 420
419 return result; 421 return result;
420} 422}
@@ -438,6 +440,15 @@ static int acpi_memory_device_start (struct acpi_device *device)
438 struct acpi_memory_device *mem_device; 440 struct acpi_memory_device *mem_device;
439 int result = 0; 441 int result = 0;
440 442
443 /*
444 * Early boot code has recognized memory area by EFI/E820.
445 * If DSDT shows these memory devices on boot, hotplug is not necessary
446 * for them. So, it just returns until completion of this driver's
447 * start up.
448 */
449 if (!acpi_hotmem_initialized)
450 return 0;
451
441 mem_device = acpi_driver_data(device); 452 mem_device = acpi_driver_data(device);
442 453
443 if (!acpi_memory_check_device(mem_device)) { 454 if (!acpi_memory_check_device(mem_device)) {
@@ -537,6 +548,7 @@ static int __init acpi_memory_device_init(void)
537 return -ENODEV; 548 return -ENODEV;
538 } 549 }
539 550
551 acpi_hotmem_initialized = 1;
540 return 0; 552 return 0;
541} 553}
542 554
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 526387dc3799..65b3f056ad89 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -962,7 +962,7 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
962 962
963 result = acpi_processor_get_power_info_cst(pr); 963 result = acpi_processor_get_power_info_cst(pr);
964 if (result == -ENODEV) 964 if (result == -ENODEV)
965 acpi_processor_get_power_info_fadt(pr); 965 result = acpi_processor_get_power_info_fadt(pr);
966 966
967 if (result) 967 if (result)
968 return result; 968 return result;
@@ -1108,6 +1108,7 @@ static const struct file_operations acpi_processor_power_fops = {
1108 .release = single_release, 1108 .release = single_release,
1109}; 1109};
1110 1110
1111#ifdef CONFIG_SMP
1111static void smp_callback(void *v) 1112static void smp_callback(void *v)
1112{ 1113{
1113 /* we already woke the CPU up, nothing more to do */ 1114 /* we already woke the CPU up, nothing more to do */
@@ -1129,6 +1130,7 @@ static int acpi_processor_latency_notify(struct notifier_block *b,
1129static struct notifier_block acpi_processor_latency_notifier = { 1130static struct notifier_block acpi_processor_latency_notifier = {
1130 .notifier_call = acpi_processor_latency_notify, 1131 .notifier_call = acpi_processor_latency_notify,
1131}; 1132};
1133#endif
1132 1134
1133int __cpuinit acpi_processor_power_init(struct acpi_processor *pr, 1135int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1134 struct acpi_device *device) 1136 struct acpi_device *device)
@@ -1146,7 +1148,9 @@ int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
1146 "ACPI: processor limited to max C-state %d\n", 1148 "ACPI: processor limited to max C-state %d\n",
1147 max_cstate); 1149 max_cstate);
1148 first_run++; 1150 first_run++;
1151#ifdef CONFIG_SMP
1149 register_latency_notifier(&acpi_processor_latency_notifier); 1152 register_latency_notifier(&acpi_processor_latency_notifier);
1153#endif
1150 } 1154 }
1151 1155
1152 if (!pr) 1156 if (!pr)
@@ -1218,7 +1222,9 @@ int acpi_processor_power_exit(struct acpi_processor *pr,
1218 * copies of pm_idle before proceeding. 1222 * copies of pm_idle before proceeding.
1219 */ 1223 */
1220 cpu_idle_wait(); 1224 cpu_idle_wait();
1225#ifdef CONFIG_SMP
1221 unregister_latency_notifier(&acpi_processor_latency_notifier); 1226 unregister_latency_notifier(&acpi_processor_latency_notifier);
1227#endif
1222 } 1228 }
1223 1229
1224 return 0; 1230 return 0;
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 12173d16bea7..7d8a7ce73fb3 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -372,19 +372,30 @@ int bus_add_device(struct device * dev)
372 pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id); 372 pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
373 error = device_add_attrs(bus, dev); 373 error = device_add_attrs(bus, dev);
374 if (error) 374 if (error)
375 goto out; 375 goto out_put;
376 error = sysfs_create_link(&bus->devices.kobj, 376 error = sysfs_create_link(&bus->devices.kobj,
377 &dev->kobj, dev->bus_id); 377 &dev->kobj, dev->bus_id);
378 if (error) 378 if (error)
379 goto out; 379 goto out_id;
380 error = sysfs_create_link(&dev->kobj, 380 error = sysfs_create_link(&dev->kobj,
381 &dev->bus->subsys.kset.kobj, "subsystem"); 381 &dev->bus->subsys.kset.kobj, "subsystem");
382 if (error) 382 if (error)
383 goto out; 383 goto out_subsys;
384 error = sysfs_create_link(&dev->kobj, 384 error = sysfs_create_link(&dev->kobj,
385 &dev->bus->subsys.kset.kobj, "bus"); 385 &dev->bus->subsys.kset.kobj, "bus");
386 if (error)
387 goto out_deprecated;
386 } 388 }
387out: 389 return 0;
390
391out_deprecated:
392 sysfs_remove_link(&dev->kobj, "subsystem");
393out_subsys:
394 sysfs_remove_link(&bus->devices.kobj, dev->bus_id);
395out_id:
396 device_remove_attrs(bus, dev);
397out_put:
398 put_bus(dev->bus);
388 return error; 399 return error;
389} 400}
390 401
@@ -428,8 +439,10 @@ void bus_remove_device(struct device * dev)
428 sysfs_remove_link(&dev->kobj, "bus"); 439 sysfs_remove_link(&dev->kobj, "bus");
429 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); 440 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
430 device_remove_attrs(dev->bus, dev); 441 device_remove_attrs(dev->bus, dev);
431 dev->is_registered = 0; 442 if (dev->is_registered) {
432 klist_del(&dev->knode_bus); 443 dev->is_registered = 0;
444 klist_del(&dev->knode_bus);
445 }
433 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id); 446 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id);
434 device_release_driver(dev); 447 device_release_driver(dev);
435 put_bus(dev->bus); 448 put_bus(dev->bus);
@@ -505,34 +518,36 @@ int bus_add_driver(struct device_driver *drv)
505 struct bus_type * bus = get_bus(drv->bus); 518 struct bus_type * bus = get_bus(drv->bus);
506 int error = 0; 519 int error = 0;
507 520
508 if (bus) { 521 if (!bus)
509 pr_debug("bus %s: add driver %s\n", bus->name, drv->name); 522 return 0;
510 error = kobject_set_name(&drv->kobj, "%s", drv->name); 523
511 if (error) 524 pr_debug("bus %s: add driver %s\n", bus->name, drv->name);
512 goto out_put_bus; 525 error = kobject_set_name(&drv->kobj, "%s", drv->name);
513 drv->kobj.kset = &bus->drivers; 526 if (error)
514 if ((error = kobject_register(&drv->kobj))) 527 goto out_put_bus;
515 goto out_put_bus; 528 drv->kobj.kset = &bus->drivers;
516 529 if ((error = kobject_register(&drv->kobj)))
517 error = driver_attach(drv); 530 goto out_put_bus;
518 if (error) 531
519 goto out_unregister; 532 error = driver_attach(drv);
520 klist_add_tail(&drv->knode_bus, &bus->klist_drivers); 533 if (error)
521 module_add_driver(drv->owner, drv); 534 goto out_unregister;
522 535 klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
523 error = driver_add_attrs(bus, drv); 536 module_add_driver(drv->owner, drv);
524 if (error) { 537
525 /* How the hell do we get out of this pickle? Give up */ 538 error = driver_add_attrs(bus, drv);
526 printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n", 539 if (error) {
527 __FUNCTION__, drv->name); 540 /* How the hell do we get out of this pickle? Give up */
528 } 541 printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n",
529 error = add_bind_files(drv); 542 __FUNCTION__, drv->name);
530 if (error) {
531 /* Ditto */
532 printk(KERN_ERR "%s: add_bind_files(%s) failed\n",
533 __FUNCTION__, drv->name);
534 }
535 } 543 }
544 error = add_bind_files(drv);
545 if (error) {
546 /* Ditto */
547 printk(KERN_ERR "%s: add_bind_files(%s) failed\n",
548 __FUNCTION__, drv->name);
549 }
550
536 return error; 551 return error;
537out_unregister: 552out_unregister:
538 kobject_unregister(&drv->kobj); 553 kobject_unregister(&drv->kobj);
@@ -552,16 +567,17 @@ out_put_bus:
552 567
553void bus_remove_driver(struct device_driver * drv) 568void bus_remove_driver(struct device_driver * drv)
554{ 569{
555 if (drv->bus) { 570 if (!drv->bus)
556 remove_bind_files(drv); 571 return;
557 driver_remove_attrs(drv->bus, drv); 572
558 klist_remove(&drv->knode_bus); 573 remove_bind_files(drv);
559 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name); 574 driver_remove_attrs(drv->bus, drv);
560 driver_detach(drv); 575 klist_remove(&drv->knode_bus);
561 module_remove_driver(drv); 576 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
562 kobject_unregister(&drv->kobj); 577 driver_detach(drv);
563 put_bus(drv->bus); 578 module_remove_driver(drv);
564 } 579 kobject_unregister(&drv->kobj);
580 put_bus(drv->bus);
565} 581}
566 582
567 583
@@ -732,11 +748,15 @@ int bus_register(struct bus_type * bus)
732 748
733 klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put); 749 klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put);
734 klist_init(&bus->klist_drivers, NULL, NULL); 750 klist_init(&bus->klist_drivers, NULL, NULL);
735 bus_add_attrs(bus); 751 retval = bus_add_attrs(bus);
752 if (retval)
753 goto bus_attrs_fail;
736 754
737 pr_debug("bus type '%s' registered\n", bus->name); 755 pr_debug("bus type '%s' registered\n", bus->name);
738 return 0; 756 return 0;
739 757
758bus_attrs_fail:
759 kset_unregister(&bus->drivers);
740bus_drivers_fail: 760bus_drivers_fail:
741 kset_unregister(&bus->devices); 761 kset_unregister(&bus->devices);
742bus_devices_fail: 762bus_devices_fail:
diff --git a/drivers/base/class.c b/drivers/base/class.c
index b32b77ff2dcd..0ff267a248db 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -562,7 +562,10 @@ int class_device_add(struct class_device *class_dev)
562 goto out2; 562 goto out2;
563 563
564 /* add the needed attributes to this device */ 564 /* add the needed attributes to this device */
565 sysfs_create_link(&class_dev->kobj, &parent_class->subsys.kset.kobj, "subsystem"); 565 error = sysfs_create_link(&class_dev->kobj,
566 &parent_class->subsys.kset.kobj, "subsystem");
567 if (error)
568 goto out3;
566 class_dev->uevent_attr.attr.name = "uevent"; 569 class_dev->uevent_attr.attr.name = "uevent";
567 class_dev->uevent_attr.attr.mode = S_IWUSR; 570 class_dev->uevent_attr.attr.mode = S_IWUSR;
568 class_dev->uevent_attr.attr.owner = parent_class->owner; 571 class_dev->uevent_attr.attr.owner = parent_class->owner;
diff --git a/drivers/base/core.c b/drivers/base/core.c
index b224bb43ff63..68ad11af22b4 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -44,7 +44,7 @@ const char *dev_driver_string(struct device *dev)
44 return dev->driver ? dev->driver->name : 44 return dev->driver ? dev->driver->name :
45 (dev->bus ? dev->bus->name : ""); 45 (dev->bus ? dev->bus->name : "");
46} 46}
47EXPORT_SYMBOL_GPL(dev_driver_string); 47EXPORT_SYMBOL(dev_driver_string);
48 48
49#define to_dev(obj) container_of(obj, struct device, kobj) 49#define to_dev(obj) container_of(obj, struct device, kobj)
50#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) 50#define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr)
@@ -433,14 +433,16 @@ int device_add(struct device *dev)
433 if (dev->driver) 433 if (dev->driver)
434 dev->uevent_attr.attr.owner = dev->driver->owner; 434 dev->uevent_attr.attr.owner = dev->driver->owner;
435 dev->uevent_attr.store = store_uevent; 435 dev->uevent_attr.store = store_uevent;
436 device_create_file(dev, &dev->uevent_attr); 436 error = device_create_file(dev, &dev->uevent_attr);
437 if (error)
438 goto attrError;
437 439
438 if (MAJOR(dev->devt)) { 440 if (MAJOR(dev->devt)) {
439 struct device_attribute *attr; 441 struct device_attribute *attr;
440 attr = kzalloc(sizeof(*attr), GFP_KERNEL); 442 attr = kzalloc(sizeof(*attr), GFP_KERNEL);
441 if (!attr) { 443 if (!attr) {
442 error = -ENOMEM; 444 error = -ENOMEM;
443 goto PMError; 445 goto ueventattrError;
444 } 446 }
445 attr->attr.name = "dev"; 447 attr->attr.name = "dev";
446 attr->attr.mode = S_IRUGO; 448 attr->attr.mode = S_IRUGO;
@@ -450,7 +452,7 @@ int device_add(struct device *dev)
450 error = device_create_file(dev, attr); 452 error = device_create_file(dev, attr);
451 if (error) { 453 if (error) {
452 kfree(attr); 454 kfree(attr);
453 goto attrError; 455 goto ueventattrError;
454 } 456 }
455 457
456 dev->devt_attr = attr; 458 dev->devt_attr = attr;
@@ -477,7 +479,8 @@ int device_add(struct device *dev)
477 if ((error = bus_add_device(dev))) 479 if ((error = bus_add_device(dev)))
478 goto BusError; 480 goto BusError;
479 kobject_uevent(&dev->kobj, KOBJ_ADD); 481 kobject_uevent(&dev->kobj, KOBJ_ADD);
480 bus_attach_device(dev); 482 if ((error = bus_attach_device(dev)))
483 goto AttachError;
481 if (parent) 484 if (parent)
482 klist_add_tail(&dev->knode_parent, &parent->klist_children); 485 klist_add_tail(&dev->knode_parent, &parent->klist_children);
483 486
@@ -496,6 +499,8 @@ int device_add(struct device *dev)
496 kfree(class_name); 499 kfree(class_name);
497 put_device(dev); 500 put_device(dev);
498 return error; 501 return error;
502 AttachError:
503 bus_remove_device(dev);
499 BusError: 504 BusError:
500 device_pm_remove(dev); 505 device_pm_remove(dev);
501 PMError: 506 PMError:
@@ -507,6 +512,8 @@ int device_add(struct device *dev)
507 device_remove_file(dev, dev->devt_attr); 512 device_remove_file(dev, dev->devt_attr);
508 kfree(dev->devt_attr); 513 kfree(dev->devt_attr);
509 } 514 }
515 ueventattrError:
516 device_remove_file(dev, &dev->uevent_attr);
510 attrError: 517 attrError:
511 kobject_uevent(&dev->kobj, KOBJ_REMOVE); 518 kobject_uevent(&dev->kobj, KOBJ_REMOVE);
512 kobject_del(&dev->kobj); 519 kobject_del(&dev->kobj);
@@ -805,8 +812,10 @@ int device_rename(struct device *dev, char *new_name)
805 812
806 if (dev->class) { 813 if (dev->class) {
807 old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL); 814 old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL);
808 if (!old_symlink_name) 815 if (!old_symlink_name) {
809 return -ENOMEM; 816 error = -ENOMEM;
817 goto out_free_old_class;
818 }
810 strlcpy(old_symlink_name, dev->bus_id, BUS_ID_SIZE); 819 strlcpy(old_symlink_name, dev->bus_id, BUS_ID_SIZE);
811 } 820 }
812 821
@@ -830,9 +839,10 @@ int device_rename(struct device *dev, char *new_name)
830 } 839 }
831 put_device(dev); 840 put_device(dev);
832 841
833 kfree(old_class_name);
834 kfree(new_class_name); 842 kfree(new_class_name);
835 kfree(old_symlink_name); 843 kfree(old_symlink_name);
844 out_free_old_class:
845 kfree(old_class_name);
836 846
837 return error; 847 return error;
838} 848}
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index b5f43c3e44fa..db01b95a47a5 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -171,6 +171,8 @@ int driver_probe_device(struct device_driver * drv, struct device * dev)
171 drv->bus->name, dev->bus_id, drv->name); 171 drv->bus->name, dev->bus_id, drv->name);
172 172
173 data = kmalloc(sizeof(*data), GFP_KERNEL); 173 data = kmalloc(sizeof(*data), GFP_KERNEL);
174 if (!data)
175 return -ENOMEM;
174 data->drv = drv; 176 data->drv = drv;
175 data->dev = dev; 177 data->dev = dev;
176 178
@@ -178,7 +180,7 @@ int driver_probe_device(struct device_driver * drv, struct device * dev)
178 probe_task = kthread_run(really_probe, data, 180 probe_task = kthread_run(really_probe, data,
179 "probe-%s", dev->bus_id); 181 "probe-%s", dev->bus_id);
180 if (IS_ERR(probe_task)) 182 if (IS_ERR(probe_task))
181 ret = PTR_ERR(probe_task); 183 ret = really_probe(data);
182 } else 184 } else
183 ret = really_probe(data); 185 ret = really_probe(data);
184 186
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index 33c5cce1560b..b2efbd4cf710 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -141,11 +141,20 @@ dma_pool_create (const char *name, struct device *dev,
141 init_waitqueue_head (&retval->waitq); 141 init_waitqueue_head (&retval->waitq);
142 142
143 if (dev) { 143 if (dev) {
144 int ret;
145
144 down (&pools_lock); 146 down (&pools_lock);
145 if (list_empty (&dev->dma_pools)) 147 if (list_empty (&dev->dma_pools))
146 device_create_file (dev, &dev_attr_pools); 148 ret = device_create_file (dev, &dev_attr_pools);
149 else
150 ret = 0;
147 /* note: not currently insisting "name" be unique */ 151 /* note: not currently insisting "name" be unique */
148 list_add (&retval->pools, &dev->dma_pools); 152 if (!ret)
153 list_add (&retval->pools, &dev->dma_pools);
154 else {
155 kfree(retval);
156 retval = NULL;
157 }
149 up (&pools_lock); 158 up (&pools_lock);
150 } else 159 } else
151 INIT_LIST_HEAD (&retval->pools); 160 INIT_LIST_HEAD (&retval->pools);
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 3ef9d514b916..28dccb730af9 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -97,8 +97,7 @@ static struct attribute_group topology_attr_group = {
97/* Add/Remove cpu_topology interface for CPU device */ 97/* Add/Remove cpu_topology interface for CPU device */
98static int __cpuinit topology_add_dev(struct sys_device * sys_dev) 98static int __cpuinit topology_add_dev(struct sys_device * sys_dev)
99{ 99{
100 sysfs_create_group(&sys_dev->kobj, &topology_attr_group); 100 return sysfs_create_group(&sys_dev->kobj, &topology_attr_group);
101 return 0;
102} 101}
103 102
104static int __cpuinit topology_remove_dev(struct sys_device * sys_dev) 103static int __cpuinit topology_remove_dev(struct sys_device * sys_dev)
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 6eebcb7be97e..6d111228cfac 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -1,5 +1,5 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2#define VERSION "22" 2#define VERSION "32"
3#define AOE_MAJOR 152 3#define AOE_MAJOR 152
4#define DEVICE_NAME "aoe" 4#define DEVICE_NAME "aoe"
5 5
@@ -65,7 +65,7 @@ struct aoe_atahdr {
65struct aoe_cfghdr { 65struct aoe_cfghdr {
66 __be16 bufcnt; 66 __be16 bufcnt;
67 __be16 fwver; 67 __be16 fwver;
68 unsigned char res; 68 unsigned char scnt;
69 unsigned char aoeccmd; 69 unsigned char aoeccmd;
70 unsigned char cslen[2]; 70 unsigned char cslen[2];
71}; 71};
@@ -78,12 +78,14 @@ enum {
78 DEVFL_GDALLOC = (1<<4), /* need to alloc gendisk */ 78 DEVFL_GDALLOC = (1<<4), /* need to alloc gendisk */
79 DEVFL_PAUSE = (1<<5), 79 DEVFL_PAUSE = (1<<5),
80 DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */ 80 DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */
81 DEVFL_MAXBCNT = (1<<7), /* d->maxbcnt is not changeable */
82 DEVFL_KICKME = (1<<8),
81 83
82 BUFFL_FAIL = 1, 84 BUFFL_FAIL = 1,
83}; 85};
84 86
85enum { 87enum {
86 MAXATADATA = 1024, 88 DEFAULTBCNT = 2 * 512, /* 2 sectors */
87 NPERSHELF = 16, /* number of slots per shelf address */ 89 NPERSHELF = 16, /* number of slots per shelf address */
88 FREETAG = -1, 90 FREETAG = -1,
89 MIN_BUFS = 8, 91 MIN_BUFS = 8,
@@ -107,11 +109,9 @@ struct frame {
107 ulong waited; 109 ulong waited;
108 struct buf *buf; 110 struct buf *buf;
109 char *bufaddr; 111 char *bufaddr;
110 int writedatalen; 112 ulong bcnt;
111 int ndata; 113 sector_t lba;
112 114 struct sk_buff *skb;
113 /* largest possible */
114 unsigned char data[sizeof(struct aoe_hdr) + sizeof(struct aoe_atahdr)];
115}; 115};
116 116
117struct aoedev { 117struct aoedev {
@@ -121,9 +121,12 @@ struct aoedev {
121 ulong sysminor; 121 ulong sysminor;
122 ulong aoemajor; 122 ulong aoemajor;
123 ulong aoeminor; 123 ulong aoeminor;
124 ulong nopen; /* (bd_openers isn't available without sleeping) */ 124 u16 nopen; /* (bd_openers isn't available without sleeping) */
125 ulong rttavg; /* round trip average of requests/responses */ 125 u16 lasttag; /* last tag sent */
126 u16 rttavg; /* round trip average of requests/responses */
127 u16 mintimer;
126 u16 fw_ver; /* version of blade's firmware */ 128 u16 fw_ver; /* version of blade's firmware */
129 u16 maxbcnt;
127 struct work_struct work;/* disk create work struct */ 130 struct work_struct work;/* disk create work struct */
128 struct gendisk *gd; 131 struct gendisk *gd;
129 request_queue_t blkq; 132 request_queue_t blkq;
@@ -137,8 +140,8 @@ struct aoedev {
137 mempool_t *bufpool; /* for deadlock-free Buf allocation */ 140 mempool_t *bufpool; /* for deadlock-free Buf allocation */
138 struct list_head bufq; /* queue of bios to work on */ 141 struct list_head bufq; /* queue of bios to work on */
139 struct buf *inprocess; /* the one we're currently working on */ 142 struct buf *inprocess; /* the one we're currently working on */
140 ulong lasttag; /* last tag sent */ 143 ushort lostjumbo;
141 ulong nframes; /* number of frames below */ 144 ushort nframes; /* number of frames below */
142 struct frame *frames; 145 struct frame *frames;
143}; 146};
144 147
@@ -157,6 +160,7 @@ void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
157void aoecmd_ata_rsp(struct sk_buff *); 160void aoecmd_ata_rsp(struct sk_buff *);
158void aoecmd_cfg_rsp(struct sk_buff *); 161void aoecmd_cfg_rsp(struct sk_buff *);
159void aoecmd_sleepwork(void *vp); 162void aoecmd_sleepwork(void *vp);
163struct sk_buff *new_skb(ulong);
160 164
161int aoedev_init(void); 165int aoedev_init(void);
162void aoedev_exit(void); 166void aoedev_exit(void);
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 393b86a3dbf8..d433f27e0ce2 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoeblk.c 3 * aoeblk.c
4 * block device routines 4 * block device routines
@@ -14,7 +14,6 @@
14 14
15static kmem_cache_t *buf_pool_cache; 15static kmem_cache_t *buf_pool_cache;
16 16
17/* add attributes for our block devices in sysfs */
18static ssize_t aoedisk_show_state(struct gendisk * disk, char *page) 17static ssize_t aoedisk_show_state(struct gendisk * disk, char *page)
19{ 18{
20 struct aoedev *d = disk->private_data; 19 struct aoedev *d = disk->private_data;
@@ -64,21 +63,26 @@ static struct disk_attribute disk_attr_fwver = {
64 .show = aoedisk_show_fwver 63 .show = aoedisk_show_fwver
65}; 64};
66 65
67static void 66static struct attribute *aoe_attrs[] = {
67 &disk_attr_state.attr,
68 &disk_attr_mac.attr,
69 &disk_attr_netif.attr,
70 &disk_attr_fwver.attr,
71};
72
73static const struct attribute_group attr_group = {
74 .attrs = aoe_attrs,
75};
76
77static int
68aoedisk_add_sysfs(struct aoedev *d) 78aoedisk_add_sysfs(struct aoedev *d)
69{ 79{
70 sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr); 80 return sysfs_create_group(&d->gd->kobj, &attr_group);
71 sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr);
72 sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr);
73 sysfs_create_file(&d->gd->kobj, &disk_attr_fwver.attr);
74} 81}
75void 82void
76aoedisk_rm_sysfs(struct aoedev *d) 83aoedisk_rm_sysfs(struct aoedev *d)
77{ 84{
78 sysfs_remove_link(&d->gd->kobj, "state"); 85 sysfs_remove_group(&d->gd->kobj, &attr_group);
79 sysfs_remove_link(&d->gd->kobj, "mac");
80 sysfs_remove_link(&d->gd->kobj, "netif");
81 sysfs_remove_link(&d->gd->kobj, "firmware-version");
82} 86}
83 87
84static int 88static int
@@ -132,8 +136,7 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio)
132 d = bio->bi_bdev->bd_disk->private_data; 136 d = bio->bi_bdev->bd_disk->private_data;
133 buf = mempool_alloc(d->bufpool, GFP_NOIO); 137 buf = mempool_alloc(d->bufpool, GFP_NOIO);
134 if (buf == NULL) { 138 if (buf == NULL) {
135 printk(KERN_INFO "aoe: aoeblk_make_request: buf allocation " 139 printk(KERN_INFO "aoe: buf allocation failure\n");
136 "failure\n");
137 bio_endio(bio, bio->bi_size, -ENOMEM); 140 bio_endio(bio, bio->bi_size, -ENOMEM);
138 return 0; 141 return 0;
139 } 142 }
@@ -143,14 +146,15 @@ aoeblk_make_request(request_queue_t *q, struct bio *bio)
143 buf->bio = bio; 146 buf->bio = bio;
144 buf->resid = bio->bi_size; 147 buf->resid = bio->bi_size;
145 buf->sector = bio->bi_sector; 148 buf->sector = bio->bi_sector;
146 buf->bv = buf->bio->bi_io_vec; 149 buf->bv = &bio->bi_io_vec[bio->bi_idx];
150 WARN_ON(buf->bv->bv_len == 0);
147 buf->bv_resid = buf->bv->bv_len; 151 buf->bv_resid = buf->bv->bv_len;
148 buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset; 152 buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset;
149 153
150 spin_lock_irqsave(&d->lock, flags); 154 spin_lock_irqsave(&d->lock, flags);
151 155
152 if ((d->flags & DEVFL_UP) == 0) { 156 if ((d->flags & DEVFL_UP) == 0) {
153 printk(KERN_INFO "aoe: aoeblk_make_request: device %ld.%ld is not up\n", 157 printk(KERN_INFO "aoe: device %ld.%ld is not up\n",
154 d->aoemajor, d->aoeminor); 158 d->aoemajor, d->aoeminor);
155 spin_unlock_irqrestore(&d->lock, flags); 159 spin_unlock_irqrestore(&d->lock, flags);
156 mempool_free(buf, d->bufpool); 160 mempool_free(buf, d->bufpool);
@@ -176,7 +180,7 @@ aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
176 struct aoedev *d = bdev->bd_disk->private_data; 180 struct aoedev *d = bdev->bd_disk->private_data;
177 181
178 if ((d->flags & DEVFL_UP) == 0) { 182 if ((d->flags & DEVFL_UP) == 0) {
179 printk(KERN_ERR "aoe: aoeblk_ioctl: disk not up\n"); 183 printk(KERN_ERR "aoe: disk not up\n");
180 return -ENODEV; 184 return -ENODEV;
181 } 185 }
182 186
@@ -203,8 +207,8 @@ aoeblk_gdalloc(void *vp)
203 207
204 gd = alloc_disk(AOE_PARTITIONS); 208 gd = alloc_disk(AOE_PARTITIONS);
205 if (gd == NULL) { 209 if (gd == NULL) {
206 printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate disk " 210 printk(KERN_ERR "aoe: cannot allocate disk structure for %ld.%ld\n",
207 "structure for %ld.%ld\n", d->aoemajor, d->aoeminor); 211 d->aoemajor, d->aoeminor);
208 spin_lock_irqsave(&d->lock, flags); 212 spin_lock_irqsave(&d->lock, flags);
209 d->flags &= ~DEVFL_GDALLOC; 213 d->flags &= ~DEVFL_GDALLOC;
210 spin_unlock_irqrestore(&d->lock, flags); 214 spin_unlock_irqrestore(&d->lock, flags);
@@ -213,8 +217,8 @@ aoeblk_gdalloc(void *vp)
213 217
214 d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache); 218 d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache);
215 if (d->bufpool == NULL) { 219 if (d->bufpool == NULL) {
216 printk(KERN_ERR "aoe: aoeblk_gdalloc: cannot allocate bufpool " 220 printk(KERN_ERR "aoe: cannot allocate bufpool for %ld.%ld\n",
217 "for %ld.%ld\n", d->aoemajor, d->aoeminor); 221 d->aoemajor, d->aoeminor);
218 put_disk(gd); 222 put_disk(gd);
219 spin_lock_irqsave(&d->lock, flags); 223 spin_lock_irqsave(&d->lock, flags);
220 d->flags &= ~DEVFL_GDALLOC; 224 d->flags &= ~DEVFL_GDALLOC;
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index 1bc1cf9603f1..e22b4c9520a9 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoechr.c 3 * aoechr.c
4 * AoE character device driver 4 * AoE character device driver
@@ -15,7 +15,6 @@ enum {
15 MINOR_INTERFACES, 15 MINOR_INTERFACES,
16 MINOR_REVALIDATE, 16 MINOR_REVALIDATE,
17 MSGSZ = 2048, 17 MSGSZ = 2048,
18 NARGS = 10,
19 NMSG = 100, /* message backlog to retain */ 18 NMSG = 100, /* message backlog to retain */
20}; 19};
21 20
@@ -56,9 +55,8 @@ static int
56interfaces(const char __user *str, size_t size) 55interfaces(const char __user *str, size_t size)
57{ 56{
58 if (set_aoe_iflist(str, size)) { 57 if (set_aoe_iflist(str, size)) {
59 printk(KERN_CRIT 58 printk(KERN_ERR
60 "%s: could not set interface list: %s\n", 59 "aoe: could not set interface list: too many interfaces\n");
61 __FUNCTION__, "too many interfaces");
62 return -EINVAL; 60 return -EINVAL;
63 } 61 }
64 return 0; 62 return 0;
@@ -81,8 +79,7 @@ revalidate(const char __user *str, size_t size)
81 /* should be e%d.%d format */ 79 /* should be e%d.%d format */
82 n = sscanf(buf, "e%d.%d", &major, &minor); 80 n = sscanf(buf, "e%d.%d", &major, &minor);
83 if (n != 2) { 81 if (n != 2) {
84 printk(KERN_ERR "aoe: %s: invalid device specification\n", 82 printk(KERN_ERR "aoe: invalid device specification\n");
85 __FUNCTION__);
86 return -EINVAL; 83 return -EINVAL;
87 } 84 }
88 d = aoedev_by_aoeaddr(major, minor); 85 d = aoedev_by_aoeaddr(major, minor);
@@ -90,6 +87,7 @@ revalidate(const char __user *str, size_t size)
90 return -EINVAL; 87 return -EINVAL;
91 88
92 spin_lock_irqsave(&d->lock, flags); 89 spin_lock_irqsave(&d->lock, flags);
90 d->flags &= ~DEVFL_MAXBCNT;
93 d->flags |= DEVFL_PAUSE; 91 d->flags |= DEVFL_PAUSE;
94 spin_unlock_irqrestore(&d->lock, flags); 92 spin_unlock_irqrestore(&d->lock, flags);
95 aoecmd_cfg(major, minor); 93 aoecmd_cfg(major, minor);
@@ -116,7 +114,7 @@ bail: spin_unlock_irqrestore(&emsgs_lock, flags);
116 114
117 mp = kmalloc(n, GFP_ATOMIC); 115 mp = kmalloc(n, GFP_ATOMIC);
118 if (mp == NULL) { 116 if (mp == NULL) {
119 printk(KERN_CRIT "aoe: aoechr_error: allocation failure, len=%ld\n", n); 117 printk(KERN_ERR "aoe: allocation failure, len=%ld\n", n);
120 goto bail; 118 goto bail;
121 } 119 }
122 120
@@ -141,7 +139,7 @@ aoechr_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offp
141 139
142 switch ((unsigned long) filp->private_data) { 140 switch ((unsigned long) filp->private_data) {
143 default: 141 default:
144 printk(KERN_INFO "aoe: aoechr_write: can't write to that file.\n"); 142 printk(KERN_INFO "aoe: can't write to that file.\n");
145 break; 143 break;
146 case MINOR_DISCOVER: 144 case MINOR_DISCOVER:
147 ret = discover(); 145 ret = discover();
@@ -250,7 +248,7 @@ aoechr_init(void)
250 248
251 n = register_chrdev(AOE_MAJOR, "aoechr", &aoe_fops); 249 n = register_chrdev(AOE_MAJOR, "aoechr", &aoe_fops);
252 if (n < 0) { 250 if (n < 0) {
253 printk(KERN_ERR "aoe: aoechr_init: can't register char device\n"); 251 printk(KERN_ERR "aoe: can't register char device\n");
254 return n; 252 return n;
255 } 253 }
256 sema_init(&emsgs_sema, 0); 254 sema_init(&emsgs_sema, 0);
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 39da28d344fe..8a13b1af8bab 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoecmd.c 3 * aoecmd.c
4 * Filesystem request handling methods 4 * Filesystem request handling methods
@@ -15,17 +15,19 @@
15#define TIMERTICK (HZ / 10) 15#define TIMERTICK (HZ / 10)
16#define MINTIMER (2 * TIMERTICK) 16#define MINTIMER (2 * TIMERTICK)
17#define MAXTIMER (HZ << 1) 17#define MAXTIMER (HZ << 1)
18#define MAXWAIT (60 * 3) /* After MAXWAIT seconds, give up and fail dev */
19 18
20static struct sk_buff * 19static int aoe_deadsecs = 60 * 3;
21new_skb(struct net_device *if_dev, ulong len) 20module_param(aoe_deadsecs, int, 0644);
21MODULE_PARM_DESC(aoe_deadsecs, "After aoe_deadsecs seconds, give up and fail dev.");
22
23struct sk_buff *
24new_skb(ulong len)
22{ 25{
23 struct sk_buff *skb; 26 struct sk_buff *skb;
24 27
25 skb = alloc_skb(len, GFP_ATOMIC); 28 skb = alloc_skb(len, GFP_ATOMIC);
26 if (skb) { 29 if (skb) {
27 skb->nh.raw = skb->mac.raw = skb->data; 30 skb->nh.raw = skb->mac.raw = skb->data;
28 skb->dev = if_dev;
29 skb->protocol = __constant_htons(ETH_P_AOE); 31 skb->protocol = __constant_htons(ETH_P_AOE);
30 skb->priority = 0; 32 skb->priority = 0;
31 skb_put(skb, len); 33 skb_put(skb, len);
@@ -40,29 +42,6 @@ new_skb(struct net_device *if_dev, ulong len)
40 return skb; 42 return skb;
41} 43}
42 44
43static struct sk_buff *
44skb_prepare(struct aoedev *d, struct frame *f)
45{
46 struct sk_buff *skb;
47 char *p;
48
49 skb = new_skb(d->ifp, f->ndata + f->writedatalen);
50 if (!skb) {
51 printk(KERN_INFO "aoe: skb_prepare: failure to allocate skb\n");
52 return NULL;
53 }
54
55 p = skb->mac.raw;
56 memcpy(p, f->data, f->ndata);
57
58 if (f->writedatalen) {
59 p += sizeof(struct aoe_hdr) + sizeof(struct aoe_atahdr);
60 memcpy(p, f->bufaddr, f->writedatalen);
61 }
62
63 return skb;
64}
65
66static struct frame * 45static struct frame *
67getframe(struct aoedev *d, int tag) 46getframe(struct aoedev *d, int tag)
68{ 47{
@@ -107,6 +86,17 @@ aoehdr_atainit(struct aoedev *d, struct aoe_hdr *h)
107 return host_tag; 86 return host_tag;
108} 87}
109 88
89static inline void
90put_lba(struct aoe_atahdr *ah, sector_t lba)
91{
92 ah->lba0 = lba;
93 ah->lba1 = lba >>= 8;
94 ah->lba2 = lba >>= 8;
95 ah->lba3 = lba >>= 8;
96 ah->lba4 = lba >>= 8;
97 ah->lba5 = lba >>= 8;
98}
99
110static void 100static void
111aoecmd_ata_rw(struct aoedev *d, struct frame *f) 101aoecmd_ata_rw(struct aoedev *d, struct frame *f)
112{ 102{
@@ -125,29 +115,27 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f)
125 115
126 sector = buf->sector; 116 sector = buf->sector;
127 bcnt = buf->bv_resid; 117 bcnt = buf->bv_resid;
128 if (bcnt > MAXATADATA) 118 if (bcnt > d->maxbcnt)
129 bcnt = MAXATADATA; 119 bcnt = d->maxbcnt;
130 120
131 /* initialize the headers & frame */ 121 /* initialize the headers & frame */
132 h = (struct aoe_hdr *) f->data; 122 skb = f->skb;
123 h = (struct aoe_hdr *) skb->mac.raw;
133 ah = (struct aoe_atahdr *) (h+1); 124 ah = (struct aoe_atahdr *) (h+1);
134 f->ndata = sizeof *h + sizeof *ah; 125 skb->len = sizeof *h + sizeof *ah;
135 memset(h, 0, f->ndata); 126 memset(h, 0, ETH_ZLEN);
136 f->tag = aoehdr_atainit(d, h); 127 f->tag = aoehdr_atainit(d, h);
137 f->waited = 0; 128 f->waited = 0;
138 f->buf = buf; 129 f->buf = buf;
139 f->bufaddr = buf->bufaddr; 130 f->bufaddr = buf->bufaddr;
131 f->bcnt = bcnt;
132 f->lba = sector;
140 133
141 /* set up ata header */ 134 /* set up ata header */
142 ah->scnt = bcnt >> 9; 135 ah->scnt = bcnt >> 9;
143 ah->lba0 = sector; 136 put_lba(ah, sector);
144 ah->lba1 = sector >>= 8;
145 ah->lba2 = sector >>= 8;
146 ah->lba3 = sector >>= 8;
147 if (d->flags & DEVFL_EXT) { 137 if (d->flags & DEVFL_EXT) {
148 ah->aflags |= AOEAFL_EXT; 138 ah->aflags |= AOEAFL_EXT;
149 ah->lba4 = sector >>= 8;
150 ah->lba5 = sector >>= 8;
151 } else { 139 } else {
152 extbit = 0; 140 extbit = 0;
153 ah->lba3 &= 0x0f; 141 ah->lba3 &= 0x0f;
@@ -155,11 +143,14 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f)
155 } 143 }
156 144
157 if (bio_data_dir(buf->bio) == WRITE) { 145 if (bio_data_dir(buf->bio) == WRITE) {
146 skb_fill_page_desc(skb, 0, virt_to_page(f->bufaddr),
147 offset_in_page(f->bufaddr), bcnt);
158 ah->aflags |= AOEAFL_WRITE; 148 ah->aflags |= AOEAFL_WRITE;
159 f->writedatalen = bcnt; 149 skb->len += bcnt;
150 skb->data_len = bcnt;
160 } else { 151 } else {
152 skb->len = ETH_ZLEN;
161 writebit = 0; 153 writebit = 0;
162 f->writedatalen = 0;
163 } 154 }
164 155
165 ah->cmdstat = WIN_READ | writebit | extbit; 156 ah->cmdstat = WIN_READ | writebit | extbit;
@@ -168,26 +159,27 @@ aoecmd_ata_rw(struct aoedev *d, struct frame *f)
168 buf->nframesout += 1; 159 buf->nframesout += 1;
169 buf->bufaddr += bcnt; 160 buf->bufaddr += bcnt;
170 buf->bv_resid -= bcnt; 161 buf->bv_resid -= bcnt;
171/* printk(KERN_INFO "aoe: bv_resid=%ld\n", buf->bv_resid); */ 162/* printk(KERN_DEBUG "aoe: bv_resid=%ld\n", buf->bv_resid); */
172 buf->resid -= bcnt; 163 buf->resid -= bcnt;
173 buf->sector += bcnt >> 9; 164 buf->sector += bcnt >> 9;
174 if (buf->resid == 0) { 165 if (buf->resid == 0) {
175 d->inprocess = NULL; 166 d->inprocess = NULL;
176 } else if (buf->bv_resid == 0) { 167 } else if (buf->bv_resid == 0) {
177 buf->bv++; 168 buf->bv++;
169 WARN_ON(buf->bv->bv_len == 0);
178 buf->bv_resid = buf->bv->bv_len; 170 buf->bv_resid = buf->bv->bv_len;
179 buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset; 171 buf->bufaddr = page_address(buf->bv->bv_page) + buf->bv->bv_offset;
180 } 172 }
181 173
182 skb = skb_prepare(d, f); 174 skb->dev = d->ifp;
183 if (skb) { 175 skb = skb_clone(skb, GFP_ATOMIC);
184 skb->next = NULL; 176 if (skb == NULL)
185 if (d->sendq_hd) 177 return;
186 d->sendq_tl->next = skb; 178 if (d->sendq_hd)
187 else 179 d->sendq_tl->next = skb;
188 d->sendq_hd = skb; 180 else
189 d->sendq_tl = skb; 181 d->sendq_hd = skb;
190 } 182 d->sendq_tl = skb;
191} 183}
192 184
193/* some callers cannot sleep, and they can call this function, 185/* some callers cannot sleep, and they can call this function,
@@ -209,11 +201,12 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
209 if (!is_aoe_netif(ifp)) 201 if (!is_aoe_netif(ifp))
210 continue; 202 continue;
211 203
212 skb = new_skb(ifp, sizeof *h + sizeof *ch); 204 skb = new_skb(sizeof *h + sizeof *ch);
213 if (skb == NULL) { 205 if (skb == NULL) {
214 printk(KERN_INFO "aoe: aoecmd_cfg: skb alloc failure\n"); 206 printk(KERN_INFO "aoe: skb alloc failure\n");
215 continue; 207 continue;
216 } 208 }
209 skb->dev = ifp;
217 if (sl_tail == NULL) 210 if (sl_tail == NULL)
218 sl_tail = skb; 211 sl_tail = skb;
219 h = (struct aoe_hdr *) skb->mac.raw; 212 h = (struct aoe_hdr *) skb->mac.raw;
@@ -237,6 +230,29 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
237 return sl; 230 return sl;
238} 231}
239 232
233static struct frame *
234freeframe(struct aoedev *d)
235{
236 struct frame *f, *e;
237 int n = 0;
238
239 f = d->frames;
240 e = f + d->nframes;
241 for (; f<e; f++) {
242 if (f->tag != FREETAG)
243 continue;
244 if (atomic_read(&skb_shinfo(f->skb)->dataref) == 1) {
245 skb_shinfo(f->skb)->nr_frags = f->skb->data_len = 0;
246 return f;
247 }
248 n++;
249 }
250 if (n == d->nframes) /* wait for network layer */
251 d->flags |= DEVFL_KICKME;
252
253 return NULL;
254}
255
240/* enters with d->lock held */ 256/* enters with d->lock held */
241void 257void
242aoecmd_work(struct aoedev *d) 258aoecmd_work(struct aoedev *d)
@@ -252,7 +268,7 @@ aoecmd_work(struct aoedev *d)
252 } 268 }
253 269
254loop: 270loop:
255 f = getframe(d, FREETAG); 271 f = freeframe(d);
256 if (f == NULL) 272 if (f == NULL)
257 return; 273 return;
258 if (d->inprocess == NULL) { 274 if (d->inprocess == NULL) {
@@ -260,7 +276,7 @@ loop:
260 return; 276 return;
261 buf = container_of(d->bufq.next, struct buf, bufs); 277 buf = container_of(d->bufq.next, struct buf, bufs);
262 list_del(d->bufq.next); 278 list_del(d->bufq.next);
263/*printk(KERN_INFO "aoecmd_work: bi_size=%ld\n", buf->bio->bi_size); */ 279/*printk(KERN_DEBUG "aoe: bi_size=%ld\n", buf->bio->bi_size); */
264 d->inprocess = buf; 280 d->inprocess = buf;
265 } 281 }
266 aoecmd_ata_rw(d, f); 282 aoecmd_ata_rw(d, f);
@@ -272,6 +288,7 @@ rexmit(struct aoedev *d, struct frame *f)
272{ 288{
273 struct sk_buff *skb; 289 struct sk_buff *skb;
274 struct aoe_hdr *h; 290 struct aoe_hdr *h;
291 struct aoe_atahdr *ah;
275 char buf[128]; 292 char buf[128];
276 u32 n; 293 u32 n;
277 294
@@ -283,21 +300,41 @@ rexmit(struct aoedev *d, struct frame *f)
283 d->aoemajor, d->aoeminor, f->tag, jiffies, n); 300 d->aoemajor, d->aoeminor, f->tag, jiffies, n);
284 aoechr_error(buf); 301 aoechr_error(buf);
285 302
286 h = (struct aoe_hdr *) f->data; 303 skb = f->skb;
304 h = (struct aoe_hdr *) skb->mac.raw;
305 ah = (struct aoe_atahdr *) (h+1);
287 f->tag = n; 306 f->tag = n;
288 h->tag = cpu_to_be32(n); 307 h->tag = cpu_to_be32(n);
289 memcpy(h->dst, d->addr, sizeof h->dst); 308 memcpy(h->dst, d->addr, sizeof h->dst);
290 memcpy(h->src, d->ifp->dev_addr, sizeof h->src); 309 memcpy(h->src, d->ifp->dev_addr, sizeof h->src);
291 310
292 skb = skb_prepare(d, f); 311 n = DEFAULTBCNT / 512;
293 if (skb) { 312 if (ah->scnt > n) {
294 skb->next = NULL; 313 ah->scnt = n;
295 if (d->sendq_hd) 314 if (ah->aflags & AOEAFL_WRITE) {
296 d->sendq_tl->next = skb; 315 skb_fill_page_desc(skb, 0, virt_to_page(f->bufaddr),
297 else 316 offset_in_page(f->bufaddr), DEFAULTBCNT);
298 d->sendq_hd = skb; 317 skb->len = sizeof *h + sizeof *ah + DEFAULTBCNT;
299 d->sendq_tl = skb; 318 skb->data_len = DEFAULTBCNT;
319 }
320 if (++d->lostjumbo > (d->nframes << 1))
321 if (d->maxbcnt != DEFAULTBCNT) {
322 printk(KERN_INFO "aoe: e%ld.%ld: too many lost jumbo on %s - using 1KB frames.\n",
323 d->aoemajor, d->aoeminor, d->ifp->name);
324 d->maxbcnt = DEFAULTBCNT;
325 d->flags |= DEVFL_MAXBCNT;
326 }
300 } 327 }
328
329 skb->dev = d->ifp;
330 skb = skb_clone(skb, GFP_ATOMIC);
331 if (skb == NULL)
332 return;
333 if (d->sendq_hd)
334 d->sendq_tl->next = skb;
335 else
336 d->sendq_hd = skb;
337 d->sendq_tl = skb;
301} 338}
302 339
303static int 340static int
@@ -340,13 +377,17 @@ rexmit_timer(ulong vp)
340 if (f->tag != FREETAG && tsince(f->tag) >= timeout) { 377 if (f->tag != FREETAG && tsince(f->tag) >= timeout) {
341 n = f->waited += timeout; 378 n = f->waited += timeout;
342 n /= HZ; 379 n /= HZ;
343 if (n > MAXWAIT) { /* waited too long. device failure. */ 380 if (n > aoe_deadsecs) { /* waited too long for response */
344 aoedev_downdev(d); 381 aoedev_downdev(d);
345 break; 382 break;
346 } 383 }
347 rexmit(d, f); 384 rexmit(d, f);
348 } 385 }
349 } 386 }
387 if (d->flags & DEVFL_KICKME) {
388 d->flags &= ~DEVFL_KICKME;
389 aoecmd_work(d);
390 }
350 391
351 sl = d->sendq_hd; 392 sl = d->sendq_hd;
352 d->sendq_hd = d->sendq_tl = NULL; 393 d->sendq_hd = d->sendq_tl = NULL;
@@ -431,8 +472,8 @@ ataid_complete(struct aoedev *d, unsigned char *id)
431 } 472 }
432 473
433 if (d->ssize != ssize) 474 if (d->ssize != ssize)
434 printk(KERN_INFO "aoe: %012llx e%lu.%lu v%04x has %llu " 475 printk(KERN_INFO "aoe: %012llx e%lu.%lu v%04x has %llu sectors\n",
435 "sectors\n", (unsigned long long)mac_addr(d->addr), 476 (unsigned long long)mac_addr(d->addr),
436 d->aoemajor, d->aoeminor, 477 d->aoemajor, d->aoeminor,
437 d->fw_ver, (long long)ssize); 478 d->fw_ver, (long long)ssize);
438 d->ssize = ssize; 479 d->ssize = ssize;
@@ -442,11 +483,9 @@ ataid_complete(struct aoedev *d, unsigned char *id)
442 d->flags |= DEVFL_NEWSIZE; 483 d->flags |= DEVFL_NEWSIZE;
443 } else { 484 } else {
444 if (d->flags & DEVFL_GDALLOC) { 485 if (d->flags & DEVFL_GDALLOC) {
445 printk(KERN_INFO "aoe: %s: %s e%lu.%lu, %s\n", 486 printk(KERN_ERR "aoe: can't schedule work for e%lu.%lu, %s\n",
446 __FUNCTION__,
447 "can't schedule work for",
448 d->aoemajor, d->aoeminor, 487 d->aoemajor, d->aoeminor,
449 "it's already on! (This really shouldn't happen).\n"); 488 "it's already on! This shouldn't happen.\n");
450 return; 489 return;
451 } 490 }
452 d->flags |= DEVFL_GDALLOC; 491 d->flags |= DEVFL_GDALLOC;
@@ -460,8 +499,15 @@ calc_rttavg(struct aoedev *d, int rtt)
460 register long n; 499 register long n;
461 500
462 n = rtt; 501 n = rtt;
463 if (n < MINTIMER) 502 if (n < 0) {
464 n = MINTIMER; 503 n = -rtt;
504 if (n < MINTIMER)
505 n = MINTIMER;
506 else if (n > MAXTIMER)
507 n = MAXTIMER;
508 d->mintimer += (n - d->mintimer) >> 1;
509 } else if (n < d->mintimer)
510 n = d->mintimer;
465 else if (n > MAXTIMER) 511 else if (n > MAXTIMER)
466 n = MAXTIMER; 512 n = MAXTIMER;
467 513
@@ -474,7 +520,7 @@ void
474aoecmd_ata_rsp(struct sk_buff *skb) 520aoecmd_ata_rsp(struct sk_buff *skb)
475{ 521{
476 struct aoedev *d; 522 struct aoedev *d;
477 struct aoe_hdr *hin; 523 struct aoe_hdr *hin, *hout;
478 struct aoe_atahdr *ahin, *ahout; 524 struct aoe_atahdr *ahin, *ahout;
479 struct frame *f; 525 struct frame *f;
480 struct buf *buf; 526 struct buf *buf;
@@ -497,8 +543,10 @@ aoecmd_ata_rsp(struct sk_buff *skb)
497 543
498 spin_lock_irqsave(&d->lock, flags); 544 spin_lock_irqsave(&d->lock, flags);
499 545
500 f = getframe(d, be32_to_cpu(hin->tag)); 546 n = be32_to_cpu(hin->tag);
547 f = getframe(d, n);
501 if (f == NULL) { 548 if (f == NULL) {
549 calc_rttavg(d, -tsince(n));
502 spin_unlock_irqrestore(&d->lock, flags); 550 spin_unlock_irqrestore(&d->lock, flags);
503 snprintf(ebuf, sizeof ebuf, 551 snprintf(ebuf, sizeof ebuf,
504 "%15s e%d.%d tag=%08x@%08lx\n", 552 "%15s e%d.%d tag=%08x@%08lx\n",
@@ -514,26 +562,27 @@ aoecmd_ata_rsp(struct sk_buff *skb)
514 calc_rttavg(d, tsince(f->tag)); 562 calc_rttavg(d, tsince(f->tag));
515 563
516 ahin = (struct aoe_atahdr *) (hin+1); 564 ahin = (struct aoe_atahdr *) (hin+1);
517 ahout = (struct aoe_atahdr *) (f->data + sizeof(struct aoe_hdr)); 565 hout = (struct aoe_hdr *) f->skb->mac.raw;
566 ahout = (struct aoe_atahdr *) (hout+1);
518 buf = f->buf; 567 buf = f->buf;
519 568
520 if (ahout->cmdstat == WIN_IDENTIFY) 569 if (ahout->cmdstat == WIN_IDENTIFY)
521 d->flags &= ~DEVFL_PAUSE; 570 d->flags &= ~DEVFL_PAUSE;
522 if (ahin->cmdstat & 0xa9) { /* these bits cleared on success */ 571 if (ahin->cmdstat & 0xa9) { /* these bits cleared on success */
523 printk(KERN_CRIT "aoe: aoecmd_ata_rsp: ata error cmd=%2.2Xh " 572 printk(KERN_ERR
524 "stat=%2.2Xh from e%ld.%ld\n", 573 "aoe: ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%ld\n",
525 ahout->cmdstat, ahin->cmdstat, 574 ahout->cmdstat, ahin->cmdstat,
526 d->aoemajor, d->aoeminor); 575 d->aoemajor, d->aoeminor);
527 if (buf) 576 if (buf)
528 buf->flags |= BUFFL_FAIL; 577 buf->flags |= BUFFL_FAIL;
529 } else { 578 } else {
579 n = ahout->scnt << 9;
530 switch (ahout->cmdstat) { 580 switch (ahout->cmdstat) {
531 case WIN_READ: 581 case WIN_READ:
532 case WIN_READ_EXT: 582 case WIN_READ_EXT:
533 n = ahout->scnt << 9;
534 if (skb->len - sizeof *hin - sizeof *ahin < n) { 583 if (skb->len - sizeof *hin - sizeof *ahin < n) {
535 printk(KERN_CRIT "aoe: aoecmd_ata_rsp: runt " 584 printk(KERN_ERR
536 "ata data size in read. skb->len=%d\n", 585 "aoe: runt data size in read. skb->len=%d\n",
537 skb->len); 586 skb->len);
538 /* fail frame f? just returning will rexmit. */ 587 /* fail frame f? just returning will rexmit. */
539 spin_unlock_irqrestore(&d->lock, flags); 588 spin_unlock_irqrestore(&d->lock, flags);
@@ -542,22 +591,49 @@ aoecmd_ata_rsp(struct sk_buff *skb)
542 memcpy(f->bufaddr, ahin+1, n); 591 memcpy(f->bufaddr, ahin+1, n);
543 case WIN_WRITE: 592 case WIN_WRITE:
544 case WIN_WRITE_EXT: 593 case WIN_WRITE_EXT:
594 if (f->bcnt -= n) {
595 skb = f->skb;
596 f->bufaddr += n;
597 put_lba(ahout, f->lba += ahout->scnt);
598 n = f->bcnt;
599 if (n > DEFAULTBCNT)
600 n = DEFAULTBCNT;
601 ahout->scnt = n >> 9;
602 if (ahout->aflags & AOEAFL_WRITE) {
603 skb_fill_page_desc(skb, 0,
604 virt_to_page(f->bufaddr),
605 offset_in_page(f->bufaddr), n);
606 skb->len = sizeof *hout + sizeof *ahout + n;
607 skb->data_len = n;
608 }
609 f->tag = newtag(d);
610 hout->tag = cpu_to_be32(f->tag);
611 skb->dev = d->ifp;
612 skb = skb_clone(skb, GFP_ATOMIC);
613 spin_unlock_irqrestore(&d->lock, flags);
614 if (skb)
615 aoenet_xmit(skb);
616 return;
617 }
618 if (n > DEFAULTBCNT)
619 d->lostjumbo = 0;
545 break; 620 break;
546 case WIN_IDENTIFY: 621 case WIN_IDENTIFY:
547 if (skb->len - sizeof *hin - sizeof *ahin < 512) { 622 if (skb->len - sizeof *hin - sizeof *ahin < 512) {
548 printk(KERN_INFO "aoe: aoecmd_ata_rsp: runt data size " 623 printk(KERN_INFO
549 "in ataid. skb->len=%d\n", skb->len); 624 "aoe: runt data size in ataid. skb->len=%d\n",
625 skb->len);
550 spin_unlock_irqrestore(&d->lock, flags); 626 spin_unlock_irqrestore(&d->lock, flags);
551 return; 627 return;
552 } 628 }
553 ataid_complete(d, (char *) (ahin+1)); 629 ataid_complete(d, (char *) (ahin+1));
554 break; 630 break;
555 default: 631 default:
556 printk(KERN_INFO "aoe: aoecmd_ata_rsp: unrecognized " 632 printk(KERN_INFO
557 "outbound ata command %2.2Xh for %d.%d\n", 633 "aoe: unrecognized ata command %2.2Xh for %d.%d\n",
558 ahout->cmdstat, 634 ahout->cmdstat,
559 be16_to_cpu(hin->major), 635 be16_to_cpu(hin->major),
560 hin->minor); 636 hin->minor);
561 } 637 }
562 } 638 }
563 639
@@ -612,33 +688,32 @@ aoecmd_ata_id(struct aoedev *d)
612 struct frame *f; 688 struct frame *f;
613 struct sk_buff *skb; 689 struct sk_buff *skb;
614 690
615 f = getframe(d, FREETAG); 691 f = freeframe(d);
616 if (f == NULL) { 692 if (f == NULL) {
617 printk(KERN_CRIT "aoe: aoecmd_ata_id: can't get a frame. " 693 printk(KERN_ERR "aoe: can't get a frame. This shouldn't happen.\n");
618 "This shouldn't happen.\n");
619 return NULL; 694 return NULL;
620 } 695 }
621 696
622 /* initialize the headers & frame */ 697 /* initialize the headers & frame */
623 h = (struct aoe_hdr *) f->data; 698 skb = f->skb;
699 h = (struct aoe_hdr *) skb->mac.raw;
624 ah = (struct aoe_atahdr *) (h+1); 700 ah = (struct aoe_atahdr *) (h+1);
625 f->ndata = sizeof *h + sizeof *ah; 701 skb->len = ETH_ZLEN;
626 memset(h, 0, f->ndata); 702 memset(h, 0, ETH_ZLEN);
627 f->tag = aoehdr_atainit(d, h); 703 f->tag = aoehdr_atainit(d, h);
628 f->waited = 0; 704 f->waited = 0;
629 f->writedatalen = 0;
630 705
631 /* set up ata header */ 706 /* set up ata header */
632 ah->scnt = 1; 707 ah->scnt = 1;
633 ah->cmdstat = WIN_IDENTIFY; 708 ah->cmdstat = WIN_IDENTIFY;
634 ah->lba3 = 0xa0; 709 ah->lba3 = 0xa0;
635 710
636 skb = skb_prepare(d, f); 711 skb->dev = d->ifp;
637 712
638 d->rttavg = MAXTIMER; 713 d->rttavg = MAXTIMER;
639 d->timer.function = rexmit_timer; 714 d->timer.function = rexmit_timer;
640 715
641 return skb; 716 return skb_clone(skb, GFP_ATOMIC);
642} 717}
643 718
644void 719void
@@ -648,9 +723,9 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
648 struct aoe_hdr *h; 723 struct aoe_hdr *h;
649 struct aoe_cfghdr *ch; 724 struct aoe_cfghdr *ch;
650 ulong flags, sysminor, aoemajor; 725 ulong flags, sysminor, aoemajor;
651 u16 bufcnt;
652 struct sk_buff *sl; 726 struct sk_buff *sl;
653 enum { MAXFRAMES = 16 }; 727 enum { MAXFRAMES = 16 };
728 u16 n;
654 729
655 h = (struct aoe_hdr *) skb->mac.raw; 730 h = (struct aoe_hdr *) skb->mac.raw;
656 ch = (struct aoe_cfghdr *) (h+1); 731 ch = (struct aoe_cfghdr *) (h+1);
@@ -661,26 +736,25 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
661 */ 736 */
662 aoemajor = be16_to_cpu(h->major); 737 aoemajor = be16_to_cpu(h->major);
663 if (aoemajor == 0xfff) { 738 if (aoemajor == 0xfff) {
664 printk(KERN_CRIT "aoe: aoecmd_cfg_rsp: Warning: shelf " 739 printk(KERN_ERR "aoe: Warning: shelf address is all ones. "
665 "address is all ones. Check shelf dip switches\n"); 740 "Check shelf dip switches.\n");
666 return; 741 return;
667 } 742 }
668 743
669 sysminor = SYSMINOR(aoemajor, h->minor); 744 sysminor = SYSMINOR(aoemajor, h->minor);
670 if (sysminor * AOE_PARTITIONS + AOE_PARTITIONS > MINORMASK) { 745 if (sysminor * AOE_PARTITIONS + AOE_PARTITIONS > MINORMASK) {
671 printk(KERN_INFO 746 printk(KERN_INFO "aoe: e%ld.%d: minor number too large\n",
672 "aoe: e%ld.%d: minor number too large\n",
673 aoemajor, (int) h->minor); 747 aoemajor, (int) h->minor);
674 return; 748 return;
675 } 749 }
676 750
677 bufcnt = be16_to_cpu(ch->bufcnt); 751 n = be16_to_cpu(ch->bufcnt);
678 if (bufcnt > MAXFRAMES) /* keep it reasonable */ 752 if (n > MAXFRAMES) /* keep it reasonable */
679 bufcnt = MAXFRAMES; 753 n = MAXFRAMES;
680 754
681 d = aoedev_by_sysminor_m(sysminor, bufcnt); 755 d = aoedev_by_sysminor_m(sysminor, n);
682 if (d == NULL) { 756 if (d == NULL) {
683 printk(KERN_INFO "aoe: aoecmd_cfg_rsp: device sysminor_m failure\n"); 757 printk(KERN_INFO "aoe: device sysminor_m failure\n");
684 return; 758 return;
685 } 759 }
686 760
@@ -689,6 +763,20 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
689 /* permit device to migrate mac and network interface */ 763 /* permit device to migrate mac and network interface */
690 d->ifp = skb->dev; 764 d->ifp = skb->dev;
691 memcpy(d->addr, h->src, sizeof d->addr); 765 memcpy(d->addr, h->src, sizeof d->addr);
766 if (!(d->flags & DEVFL_MAXBCNT)) {
767 n = d->ifp->mtu;
768 n -= sizeof (struct aoe_hdr) + sizeof (struct aoe_atahdr);
769 n /= 512;
770 if (n > ch->scnt)
771 n = ch->scnt;
772 n = n ? n * 512 : DEFAULTBCNT;
773 if (n != d->maxbcnt) {
774 printk(KERN_INFO
775 "aoe: e%ld.%ld: setting %d byte data frames on %s\n",
776 d->aoemajor, d->aoeminor, n, d->ifp->name);
777 d->maxbcnt = n;
778 }
779 }
692 780
693 /* don't change users' perspective */ 781 /* don't change users' perspective */
694 if (d->nopen && !(d->flags & DEVFL_PAUSE)) { 782 if (d->nopen && !(d->flags & DEVFL_PAUSE)) {
@@ -696,6 +784,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
696 return; 784 return;
697 } 785 }
698 d->flags |= DEVFL_PAUSE; /* force pause */ 786 d->flags |= DEVFL_PAUSE; /* force pause */
787 d->mintimer = MINTIMER;
699 d->fw_ver = be16_to_cpu(ch->fwver); 788 d->fw_ver = be16_to_cpu(ch->fwver);
700 789
701 /* check for already outstanding ataid */ 790 /* check for already outstanding ataid */
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index ed4258a62df5..6125921bbec4 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoedev.c 3 * aoedev.c
4 * AoE device utility functions; maintains device list. 4 * AoE device utility functions; maintains device list.
@@ -20,11 +20,8 @@ aoedev_isbusy(struct aoedev *d)
20 f = d->frames; 20 f = d->frames;
21 e = f + d->nframes; 21 e = f + d->nframes;
22 do { 22 do {
23 if (f->tag != FREETAG) { 23 if (f->tag != FREETAG)
24 printk(KERN_DEBUG "aoe: %ld.%ld isbusy\n",
25 d->aoemajor, d->aoeminor);
26 return 1; 24 return 1;
27 }
28 } while (++f < e); 25 } while (++f < e);
29 26
30 return 0; 27 return 0;
@@ -66,22 +63,32 @@ aoedev_newdev(ulong nframes)
66 struct frame *f, *e; 63 struct frame *f, *e;
67 64
68 d = kzalloc(sizeof *d, GFP_ATOMIC); 65 d = kzalloc(sizeof *d, GFP_ATOMIC);
69 if (d == NULL)
70 return NULL;
71 f = kcalloc(nframes, sizeof *f, GFP_ATOMIC); 66 f = kcalloc(nframes, sizeof *f, GFP_ATOMIC);
72 if (f == NULL) { 67 switch (!d || !f) {
73 kfree(d); 68 case 0:
69 d->nframes = nframes;
70 d->frames = f;
71 e = f + nframes;
72 for (; f<e; f++) {
73 f->tag = FREETAG;
74 f->skb = new_skb(ETH_ZLEN);
75 if (!f->skb)
76 break;
77 }
78 if (f == e)
79 break;
80 while (f > d->frames) {
81 f--;
82 dev_kfree_skb(f->skb);
83 }
84 default:
85 if (f)
86 kfree(f);
87 if (d)
88 kfree(d);
74 return NULL; 89 return NULL;
75 } 90 }
76
77 INIT_WORK(&d->work, aoecmd_sleepwork, d); 91 INIT_WORK(&d->work, aoecmd_sleepwork, d);
78
79 d->nframes = nframes;
80 d->frames = f;
81 e = f + nframes;
82 for (; f<e; f++)
83 f->tag = FREETAG;
84
85 spin_lock_init(&d->lock); 92 spin_lock_init(&d->lock);
86 init_timer(&d->timer); 93 init_timer(&d->timer);
87 d->timer.data = (ulong) d; 94 d->timer.data = (ulong) d;
@@ -114,6 +121,7 @@ aoedev_downdev(struct aoedev *d)
114 mempool_free(buf, d->bufpool); 121 mempool_free(buf, d->bufpool);
115 bio_endio(bio, bio->bi_size, -EIO); 122 bio_endio(bio, bio->bi_size, -EIO);
116 } 123 }
124 skb_shinfo(f->skb)->nr_frags = f->skb->data_len = 0;
117 } 125 }
118 d->inprocess = NULL; 126 d->inprocess = NULL;
119 127
@@ -148,7 +156,7 @@ aoedev_by_sysminor_m(ulong sysminor, ulong bufcnt)
148 d = aoedev_newdev(bufcnt); 156 d = aoedev_newdev(bufcnt);
149 if (d == NULL) { 157 if (d == NULL) {
150 spin_unlock_irqrestore(&devlist_lock, flags); 158 spin_unlock_irqrestore(&devlist_lock, flags);
151 printk(KERN_INFO "aoe: aoedev_set: aoedev_newdev failure.\n"); 159 printk(KERN_INFO "aoe: aoedev_newdev failure.\n");
152 return NULL; 160 return NULL;
153 } 161 }
154 d->sysminor = sysminor; 162 d->sysminor = sysminor;
@@ -163,11 +171,19 @@ aoedev_by_sysminor_m(ulong sysminor, ulong bufcnt)
163static void 171static void
164aoedev_freedev(struct aoedev *d) 172aoedev_freedev(struct aoedev *d)
165{ 173{
174 struct frame *f, *e;
175
166 if (d->gd) { 176 if (d->gd) {
167 aoedisk_rm_sysfs(d); 177 aoedisk_rm_sysfs(d);
168 del_gendisk(d->gd); 178 del_gendisk(d->gd);
169 put_disk(d->gd); 179 put_disk(d->gd);
170 } 180 }
181 f = d->frames;
182 e = f + d->nframes;
183 for (; f<e; f++) {
184 skb_shinfo(f->skb)->nr_frags = 0;
185 dev_kfree_skb(f->skb);
186 }
171 kfree(d->frames); 187 kfree(d->frames);
172 if (d->bufpool) 188 if (d->bufpool)
173 mempool_destroy(d->bufpool); 189 mempool_destroy(d->bufpool);
diff --git a/drivers/block/aoe/aoemain.c b/drivers/block/aoe/aoemain.c
index de08491ebe66..a04b7d613299 100644
--- a/drivers/block/aoe/aoemain.c
+++ b/drivers/block/aoe/aoemain.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoemain.c 3 * aoemain.c
4 * Module initialization routines, discover timer 4 * Module initialization routines, discover timer
@@ -84,13 +84,11 @@ aoe_init(void)
84 goto net_fail; 84 goto net_fail;
85 ret = register_blkdev(AOE_MAJOR, DEVICE_NAME); 85 ret = register_blkdev(AOE_MAJOR, DEVICE_NAME);
86 if (ret < 0) { 86 if (ret < 0) {
87 printk(KERN_ERR "aoe: aoeblk_init: can't register major\n"); 87 printk(KERN_ERR "aoe: can't register major\n");
88 goto blkreg_fail; 88 goto blkreg_fail;
89 } 89 }
90 90
91 printk(KERN_INFO 91 printk(KERN_INFO "aoe: AoE v%s initialised.\n", VERSION);
92 "aoe: aoe_init: AoE v%s initialised.\n",
93 VERSION);
94 discover_timer(TINIT); 92 discover_timer(TINIT);
95 return 0; 93 return 0;
96 94
@@ -103,7 +101,7 @@ aoe_init(void)
103 chr_fail: 101 chr_fail:
104 aoedev_exit(); 102 aoedev_exit();
105 103
106 printk(KERN_INFO "aoe: aoe_init: initialisation failure.\n"); 104 printk(KERN_INFO "aoe: initialisation failure.\n");
107 return ret; 105 return ret;
108} 106}
109 107
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index c1434ed11880..9626e0f5da9d 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -1,4 +1,4 @@
1/* Copyright (c) 2004 Coraid, Inc. See COPYING for GPL terms. */ 1/* Copyright (c) 2006 Coraid, Inc. See COPYING for GPL terms. */
2/* 2/*
3 * aoenet.c 3 * aoenet.c
4 * Ethernet portion of AoE driver 4 * Ethernet portion of AoE driver
@@ -74,7 +74,7 @@ set_aoe_iflist(const char __user *user_str, size_t size)
74 return -EINVAL; 74 return -EINVAL;
75 75
76 if (copy_from_user(aoe_iflist, user_str, size)) { 76 if (copy_from_user(aoe_iflist, user_str, size)) {
77 printk(KERN_INFO "aoe: %s: copy from user failed\n", __FUNCTION__); 77 printk(KERN_INFO "aoe: copy from user failed\n");
78 return -EFAULT; 78 return -EFAULT;
79 } 79 }
80 aoe_iflist[size] = 0x00; 80 aoe_iflist[size] = 0x00;
@@ -132,8 +132,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
132 if (n > NECODES) 132 if (n > NECODES)
133 n = 0; 133 n = 0;
134 if (net_ratelimit()) 134 if (net_ratelimit())
135 printk(KERN_ERR "aoe: aoenet_rcv: error packet from %d.%d; " 135 printk(KERN_ERR "aoe: error packet from %d.%d; ecode=%d '%s'\n",
136 "ecode=%d '%s'\n",
137 be16_to_cpu(h->major), h->minor, 136 be16_to_cpu(h->major), h->minor,
138 h->err, aoe_errlist[n]); 137 h->err, aoe_errlist[n]);
139 goto exit; 138 goto exit;
@@ -147,7 +146,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
147 aoecmd_cfg_rsp(skb); 146 aoecmd_cfg_rsp(skb);
148 break; 147 break;
149 default: 148 default:
150 printk(KERN_INFO "aoe: aoenet_rcv: unknown cmd %d\n", h->cmd); 149 printk(KERN_INFO "aoe: unknown cmd %d\n", h->cmd);
151 } 150 }
152exit: 151exit:
153 dev_kfree_skb(skb); 152 dev_kfree_skb(skb);
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index a3f64bfe6b58..485aa87e9bcd 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -432,6 +432,12 @@ static int __init rd_init(void)
432 rd_disks[i] = alloc_disk(1); 432 rd_disks[i] = alloc_disk(1);
433 if (!rd_disks[i]) 433 if (!rd_disks[i])
434 goto out; 434 goto out;
435
436 rd_queue[i] = blk_alloc_queue(GFP_KERNEL);
437 if (!rd_queue[i]) {
438 put_disk(rd_disks[i]);
439 goto out;
440 }
435 } 441 }
436 442
437 if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) { 443 if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) {
@@ -442,10 +448,6 @@ static int __init rd_init(void)
442 for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) { 448 for (i = 0; i < CONFIG_BLK_DEV_RAM_COUNT; i++) {
443 struct gendisk *disk = rd_disks[i]; 449 struct gendisk *disk = rd_disks[i];
444 450
445 rd_queue[i] = blk_alloc_queue(GFP_KERNEL);
446 if (!rd_queue[i])
447 goto out_queue;
448
449 blk_queue_make_request(rd_queue[i], &rd_make_request); 451 blk_queue_make_request(rd_queue[i], &rd_make_request);
450 blk_queue_hardsect_size(rd_queue[i], rd_blocksize); 452 blk_queue_hardsect_size(rd_queue[i], rd_blocksize);
451 453
@@ -466,8 +468,6 @@ static int __init rd_init(void)
466 CONFIG_BLK_DEV_RAM_COUNT, rd_size, rd_blocksize); 468 CONFIG_BLK_DEV_RAM_COUNT, rd_size, rd_blocksize);
467 469
468 return 0; 470 return 0;
469out_queue:
470 unregister_blkdev(RAMDISK_MAJOR, "ramdisk");
471out: 471out:
472 while (i--) { 472 while (i--) {
473 put_disk(rd_disks[i]); 473 put_disk(rd_disks[i]);
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index 67cdda43f229..516751754aa9 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -29,7 +29,6 @@
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/errno.h> 31#include <linux/errno.h>
32#include <linux/timer.h>
33 32
34#include <linux/device.h> 33#include <linux/device.h>
35#include <linux/firmware.h> 34#include <linux/firmware.h>
@@ -43,7 +42,7 @@
43#define BT_DBG(D...) 42#define BT_DBG(D...)
44#endif 43#endif
45 44
46#define VERSION "1.0" 45#define VERSION "1.1"
47 46
48static int ignore = 0; 47static int ignore = 0;
49 48
@@ -72,7 +71,7 @@ struct bcm203x_data {
72 71
73 unsigned long state; 72 unsigned long state;
74 73
75 struct timer_list timer; 74 struct work_struct work;
76 75
77 struct urb *urb; 76 struct urb *urb;
78 unsigned char *buffer; 77 unsigned char *buffer;
@@ -105,7 +104,7 @@ static void bcm203x_complete(struct urb *urb)
105 104
106 data->state = BCM203X_SELECT_MEMORY; 105 data->state = BCM203X_SELECT_MEMORY;
107 106
108 mod_timer(&data->timer, jiffies + (HZ / 10)); 107 schedule_work(&data->work);
109 break; 108 break;
110 109
111 case BCM203X_SELECT_MEMORY: 110 case BCM203X_SELECT_MEMORY:
@@ -158,9 +157,9 @@ static void bcm203x_complete(struct urb *urb)
158 } 157 }
159} 158}
160 159
161static void bcm203x_timer(unsigned long user_data) 160static void bcm203x_work(void *user_data)
162{ 161{
163 struct bcm203x_data *data = (struct bcm203x_data *) user_data; 162 struct bcm203x_data *data = user_data;
164 163
165 if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0) 164 if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0)
166 BT_ERR("Can't submit URB"); 165 BT_ERR("Can't submit URB");
@@ -247,13 +246,11 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
247 246
248 release_firmware(firmware); 247 release_firmware(firmware);
249 248
250 init_timer(&data->timer); 249 INIT_WORK(&data->work, bcm203x_work, (void *) data);
251 data->timer.function = bcm203x_timer;
252 data->timer.data = (unsigned long) data;
253 250
254 usb_set_intfdata(intf, data); 251 usb_set_intfdata(intf, data);
255 252
256 mod_timer(&data->timer, jiffies + HZ); 253 schedule_work(&data->work);
257 254
258 return 0; 255 return 0;
259} 256}
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index e7c800f4c3ad..07eafbc5dc3a 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -711,6 +711,7 @@ static void dtl1_release(struct pcmcia_device *link)
711 711
712static struct pcmcia_device_id dtl1_ids[] = { 712static struct pcmcia_device_id dtl1_ids[] = {
713 PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d), 713 PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d),
714 PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-4", 0xe1bfdd64, 0x9102bc82),
714 PCMCIA_DEVICE_PROD_ID12("Socket", "CF", 0xb38bcc2e, 0x44ebf863), 715 PCMCIA_DEVICE_PROD_ID12("Socket", "CF", 0xb38bcc2e, 0x44ebf863),
715 PCMCIA_DEVICE_PROD_ID12("Socket", "CF+ Personal Network Card", 0xb38bcc2e, 0xe732bae3), 716 PCMCIA_DEVICE_PROD_ID12("Socket", "CF+ Personal Network Card", 0xb38bcc2e, 0xe732bae3),
716 PCMCIA_DEVICE_NULL 717 PCMCIA_DEVICE_NULL
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
index 7565642a007a..fdea58ae16b2 100644
--- a/drivers/bluetooth/hci_usb.c
+++ b/drivers/bluetooth/hci_usb.c
@@ -118,6 +118,9 @@ static struct usb_device_id blacklist_ids[] = {
118 /* IBM/Lenovo ThinkPad with Broadcom chip */ 118 /* IBM/Lenovo ThinkPad with Broadcom chip */
119 { USB_DEVICE(0x0a5c, 0x201e), .driver_info = HCI_WRONG_SCO_MTU }, 119 { USB_DEVICE(0x0a5c, 0x201e), .driver_info = HCI_WRONG_SCO_MTU },
120 120
121 /* ANYCOM Bluetooth USB-200 and USB-250 */
122 { USB_DEVICE(0x0a5c, 0x2111), .driver_info = HCI_RESET },
123
121 /* Microsoft Wireless Transceiver for Bluetooth 2.0 */ 124 /* Microsoft Wireless Transceiver for Bluetooth 2.0 */
122 { USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET }, 125 { USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET },
123 126
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 0e6f35fcc2eb..39a9f8cc6412 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -1046,7 +1046,7 @@ source "drivers/char/tpm/Kconfig"
1046 1046
1047config TELCLOCK 1047config TELCLOCK
1048 tristate "Telecom clock driver for MPBL0010 ATCA SBC" 1048 tristate "Telecom clock driver for MPBL0010 ATCA SBC"
1049 depends on EXPERIMENTAL 1049 depends on EXPERIMENTAL && X86
1050 default n 1050 default n
1051 help 1051 help
1052 The telecom clock device is specific to the MPBL0010 ATCA computer and 1052 The telecom clock device is specific to the MPBL0010 ATCA computer and
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index c3f95583a120..706733c0b36a 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -1157,6 +1157,7 @@ static int __init pc_init(void)
1157 int crd; 1157 int crd;
1158 struct board_info *bd; 1158 struct board_info *bd;
1159 unsigned char board_id = 0; 1159 unsigned char board_id = 0;
1160 int err = -ENOMEM;
1160 1161
1161 int pci_boards_found, pci_count; 1162 int pci_boards_found, pci_count;
1162 1163
@@ -1164,13 +1165,11 @@ static int __init pc_init(void)
1164 1165
1165 pc_driver = alloc_tty_driver(MAX_ALLOC); 1166 pc_driver = alloc_tty_driver(MAX_ALLOC);
1166 if (!pc_driver) 1167 if (!pc_driver)
1167 return -ENOMEM; 1168 goto out1;
1168 1169
1169 pc_info = alloc_tty_driver(MAX_ALLOC); 1170 pc_info = alloc_tty_driver(MAX_ALLOC);
1170 if (!pc_info) { 1171 if (!pc_info)
1171 put_tty_driver(pc_driver); 1172 goto out2;
1172 return -ENOMEM;
1173 }
1174 1173
1175 /* ----------------------------------------------------------------------- 1174 /* -----------------------------------------------------------------------
1176 If epca_setup has not been ran by LILO set num_cards to defaults; copy 1175 If epca_setup has not been ran by LILO set num_cards to defaults; copy
@@ -1370,11 +1369,17 @@ static int __init pc_init(void)
1370 1369
1371 } /* End for each card */ 1370 } /* End for each card */
1372 1371
1373 if (tty_register_driver(pc_driver)) 1372 err = tty_register_driver(pc_driver);
1374 panic("Couldn't register Digi PC/ driver"); 1373 if (err) {
1374 printk(KERN_ERR "Couldn't register Digi PC/ driver");
1375 goto out3;
1376 }
1375 1377
1376 if (tty_register_driver(pc_info)) 1378 err = tty_register_driver(pc_info);
1377 panic("Couldn't register Digi PC/ info "); 1379 if (err) {
1380 printk(KERN_ERR "Couldn't register Digi PC/ info ");
1381 goto out4;
1382 }
1378 1383
1379 /* ------------------------------------------------------------------- 1384 /* -------------------------------------------------------------------
1380 Start up the poller to check for events on all enabled boards 1385 Start up the poller to check for events on all enabled boards
@@ -1385,6 +1390,15 @@ static int __init pc_init(void)
1385 mod_timer(&epca_timer, jiffies + HZ/25); 1390 mod_timer(&epca_timer, jiffies + HZ/25);
1386 return 0; 1391 return 0;
1387 1392
1393out4:
1394 tty_unregister_driver(pc_driver);
1395out3:
1396 put_tty_driver(pc_info);
1397out2:
1398 put_tty_driver(pc_driver);
1399out1:
1400 return err;
1401
1388} /* End pc_init */ 1402} /* End pc_init */
1389 1403
1390/* ------------------ Begin post_fep_init ---------------------- */ 1404/* ------------------ Begin post_fep_init ---------------------- */
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 24825bdca8f4..e5cfb1fa47d1 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -1789,7 +1789,7 @@ static int __devinit ipmi_pci_probe(struct pci_dev *pdev,
1789 1789
1790 info = kzalloc(sizeof(*info), GFP_KERNEL); 1790 info = kzalloc(sizeof(*info), GFP_KERNEL);
1791 if (!info) 1791 if (!info)
1792 return ENOMEM; 1792 return -ENOMEM;
1793 1793
1794 info->addr_source = "PCI"; 1794 info->addr_source = "PCI";
1795 1795
@@ -1810,7 +1810,7 @@ static int __devinit ipmi_pci_probe(struct pci_dev *pdev,
1810 kfree(info); 1810 kfree(info);
1811 printk(KERN_INFO "ipmi_si: %s: Unknown IPMI type: %d\n", 1811 printk(KERN_INFO "ipmi_si: %s: Unknown IPMI type: %d\n",
1812 pci_name(pdev), class_type); 1812 pci_name(pdev), class_type);
1813 return ENOMEM; 1813 return -ENOMEM;
1814 } 1814 }
1815 1815
1816 rv = pci_enable_device(pdev); 1816 rv = pci_enable_device(pdev);
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 07f47a0208a7..eb6b13f4211a 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -645,6 +645,7 @@ void add_input_randomness(unsigned int type, unsigned int code,
645 add_timer_randomness(&input_timer_state, 645 add_timer_randomness(&input_timer_state,
646 (type << 4) ^ code ^ (code >> 4) ^ value); 646 (type << 4) ^ code ^ (code >> 4) ^ value);
647} 647}
648EXPORT_SYMBOL_GPL(add_input_randomness);
648 649
649void add_interrupt_randomness(int irq) 650void add_interrupt_randomness(int irq)
650{ 651{
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
index 052e8120a471..7ce77619707c 100644
--- a/drivers/char/rio/rioctrl.c
+++ b/drivers/char/rio/rioctrl.c
@@ -662,7 +662,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su
662 p->RIOError.Error = COPYIN_FAILED; 662 p->RIOError.Error = COPYIN_FAILED;
663 return -EFAULT; 663 return -EFAULT;
664 } 664 }
665 if (portStats.port >= RIO_PORTS) { 665 if (portStats.port < 0 || portStats.port >= RIO_PORTS) {
666 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 666 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
667 return -ENXIO; 667 return -ENXIO;
668 } 668 }
@@ -702,7 +702,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su
702 p->RIOError.Error = COPYIN_FAILED; 702 p->RIOError.Error = COPYIN_FAILED;
703 return -EFAULT; 703 return -EFAULT;
704 } 704 }
705 if (portStats.port >= RIO_PORTS) { 705 if (portStats.port < 0 || portStats.port >= RIO_PORTS) {
706 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE; 706 p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
707 return -ENXIO; 707 return -ENXIO;
708 } 708 }
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index d0b88d0e87fd..7e1bd9562c2a 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -183,11 +183,6 @@ static int sx_poll = HZ;
183 183
184static struct tty_driver *specialix_driver; 184static struct tty_driver *specialix_driver;
185 185
186static unsigned long baud_table[] = {
187 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
188 9600, 19200, 38400, 57600, 115200, 0,
189};
190
191static struct specialix_board sx_board[SX_NBOARD] = { 186static struct specialix_board sx_board[SX_NBOARD] = {
192 { 0, SX_IOBASE1, 9, }, 187 { 0, SX_IOBASE1, 9, },
193 { 0, SX_IOBASE2, 11, }, 188 { 0, SX_IOBASE2, 11, },
@@ -1090,9 +1085,9 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
1090 1085
1091 if (baud == 38400) { 1086 if (baud == 38400) {
1092 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 1087 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
1093 baud ++; 1088 baud = 57600;
1094 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 1089 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
1095 baud += 2; 1090 baud = 115200;
1096 } 1091 }
1097 1092
1098 if (!baud) { 1093 if (!baud) {
@@ -1150,11 +1145,9 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
1150 sx_out(bp, CD186x_RBPRL, tmp & 0xff); 1145 sx_out(bp, CD186x_RBPRL, tmp & 0xff);
1151 sx_out(bp, CD186x_TBPRL, tmp & 0xff); 1146 sx_out(bp, CD186x_TBPRL, tmp & 0xff);
1152 spin_unlock_irqrestore(&bp->lock, flags); 1147 spin_unlock_irqrestore(&bp->lock, flags);
1153 if (port->custom_divisor) { 1148 if (port->custom_divisor)
1154 baud = (SX_OSCFREQ + port->custom_divisor/2) / port->custom_divisor; 1149 baud = (SX_OSCFREQ + port->custom_divisor/2) / port->custom_divisor;
1155 baud = ( baud + 5 ) / 10; 1150 baud = (baud + 5) / 10; /* Estimated CPS */
1156 } else
1157 baud = (baud_table[baud] + 5) / 10; /* Estimated CPS */
1158 1151
1159 /* Two timer ticks seems enough to wakeup something like SLIP driver */ 1152 /* Two timer ticks seems enough to wakeup something like SLIP driver */
1160 tmp = ((baud + HZ/2) / HZ) * 2 - CD186x_NFIFO; 1153 tmp = ((baud + HZ/2) / HZ) * 2 - CD186x_NFIFO;
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 5fec626598cd..cc10af08cb05 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -2602,7 +2602,7 @@ static void __exit sx_exit (void)
2602 } 2602 }
2603 } 2603 }
2604 if (misc_deregister(&sx_fw_device) < 0) { 2604 if (misc_deregister(&sx_fw_device) < 0) {
2605 printk (KERN_INFO "sx: couldn't deregister firmware loader devic\n"); 2605 printk (KERN_INFO "sx: couldn't deregister firmware loader device\n");
2606 } 2606 }
2607 sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up drivers (%d)\n", sx_initialized); 2607 sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up drivers (%d)\n", sx_initialized);
2608 if (sx_initialized) 2608 if (sx_initialized)
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index f2864cc64240..06784adcc35c 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -133,8 +133,8 @@ static MGSL_PARAMS default_params = {
133}; 133};
134 134
135#define SHARED_MEM_ADDRESS_SIZE 0x40000 135#define SHARED_MEM_ADDRESS_SIZE 0x40000
136#define BUFFERLISTSIZE (PAGE_SIZE) 136#define BUFFERLISTSIZE 4096
137#define DMABUFFERSIZE (PAGE_SIZE) 137#define DMABUFFERSIZE 4096
138#define MAXRXFRAMES 7 138#define MAXRXFRAMES 7
139 139
140typedef struct _DMABUFFERENTRY 140typedef struct _DMABUFFERENTRY
diff --git a/drivers/char/watchdog/alim7101_wdt.c b/drivers/char/watchdog/alim7101_wdt.c
index 5948863b592b..bf25d0a55a99 100644
--- a/drivers/char/watchdog/alim7101_wdt.c
+++ b/drivers/char/watchdog/alim7101_wdt.c
@@ -77,7 +77,8 @@ static struct pci_dev *alim7101_pmu;
77 77
78static int nowayout = WATCHDOG_NOWAYOUT; 78static int nowayout = WATCHDOG_NOWAYOUT;
79module_param(nowayout, int, 0); 79module_param(nowayout, int, 0);
80MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); 80MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
81 __stringify(CONFIG_WATCHDOG_NOWAYOUT) ")");
81 82
82/* 83/*
83 * Whack the dog 84 * Whack the dog
@@ -415,6 +416,16 @@ err_out:
415module_init(alim7101_wdt_init); 416module_init(alim7101_wdt_init);
416module_exit(alim7101_wdt_unload); 417module_exit(alim7101_wdt_unload);
417 418
419static struct pci_device_id alim7101_pci_tbl[] __devinitdata = {
420 { PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533,
421 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
422 { PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101,
423 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
424 { }
425};
426
427MODULE_DEVICE_TABLE(pci, alim7101_pci_tbl);
428
418MODULE_AUTHOR("Steve Hill"); 429MODULE_AUTHOR("Steve Hill");
419MODULE_DESCRIPTION("ALi M7101 PMU Computer Watchdog Timer driver"); 430MODULE_DESCRIPTION("ALi M7101 PMU Computer Watchdog Timer driver");
420MODULE_LICENSE("GPL"); 431MODULE_LICENSE("GPL");
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 8bcb58cd4ac0..1865b56fb141 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -8,7 +8,7 @@
8 * 8 *
9 * See Documentation/dcdbas.txt for more information. 9 * See Documentation/dcdbas.txt for more information.
10 * 10 *
11 * Copyright (C) 1995-2005 Dell Inc. 11 * Copyright (C) 1995-2006 Dell Inc.
12 * 12 *
13 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License v2.0 as published by 14 * it under the terms of the GNU General Public License v2.0 as published by
@@ -40,7 +40,7 @@
40#include "dcdbas.h" 40#include "dcdbas.h"
41 41
42#define DRIVER_NAME "dcdbas" 42#define DRIVER_NAME "dcdbas"
43#define DRIVER_VERSION "5.6.0-2" 43#define DRIVER_VERSION "5.6.0-3.2"
44#define DRIVER_DESCRIPTION "Dell Systems Management Base Driver" 44#define DRIVER_DESCRIPTION "Dell Systems Management Base Driver"
45 45
46static struct platform_device *dcdbas_pdev; 46static struct platform_device *dcdbas_pdev;
@@ -175,6 +175,9 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos,
175{ 175{
176 ssize_t ret; 176 ssize_t ret;
177 177
178 if ((pos + count) > MAX_SMI_DATA_BUF_SIZE)
179 return -EINVAL;
180
178 mutex_lock(&smi_data_lock); 181 mutex_lock(&smi_data_lock);
179 182
180 ret = smi_data_buf_realloc(pos + count); 183 ret = smi_data_buf_realloc(pos + count);
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 9b88b25b6edb..e76d91906c99 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -95,11 +95,13 @@ config SENSORS_ADM9240
95 will be called adm9240. 95 will be called adm9240.
96 96
97config SENSORS_K8TEMP 97config SENSORS_K8TEMP
98 tristate "AMD K8 processor sensor" 98 tristate "AMD Athlon64/FX or Opteron temperature sensor"
99 depends on HWMON && X86 && PCI && EXPERIMENTAL 99 depends on HWMON && X86 && PCI && EXPERIMENTAL
100 help 100 help
101 If you say yes here you get support for the temperature 101 If you say yes here you get support for the temperature
102 sensor(s) inside your AMD K8 CPU. 102 sensor(s) inside your CPU. Supported is whole AMD K8
103 microarchitecture. Please note that you will need at least
104 lm-sensors 2.10.1 for proper userspace support.
103 105
104 This driver can also be built as a module. If so, the module 106 This driver can also be built as a module. If so, the module
105 will be called k8temp. 107 will be called k8temp.
@@ -369,8 +371,8 @@ config SENSORS_SMSC47M1
369 help 371 help
370 If you say yes here you get support for the integrated fan 372 If you say yes here you get support for the integrated fan
371 monitoring and control capabilities of the SMSC LPC47B27x, 373 monitoring and control capabilities of the SMSC LPC47B27x,
372 LPC47M10x, LPC47M13x, LPC47M14x, LPC47M15x, LPC47M192 and 374 LPC47M10x, LPC47M112, LPC47M13x, LPC47M14x, LPC47M15x,
373 LPC47M997 chips. 375 LPC47M192 and LPC47M997 chips.
374 376
375 The temperature and voltage sensor features of the LPC47M192 377 The temperature and voltage sensor features of the LPC47M192
376 and LPC47M997 are supported by another driver, select also 378 and LPC47M997 are supported by another driver, select also
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index 377961c4a41e..aad594adf0c7 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -5,7 +5,7 @@
5 * Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl> 5 * Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl>
6 * Philip Edelbrock <phil@netroedge.com> 6 * Philip Edelbrock <phil@netroedge.com>
7 * Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl> 7 * Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl>
8 * Copyright (C) 2005 Grant Coady <gcoady@gmail.com> with valuable 8 * Copyright (C) 2005 Grant Coady <gcoady.lk@gmail.com> with valuable
9 * guidance from Jean Delvare 9 * guidance from Jean Delvare
10 * 10 *
11 * Driver supports Analog Devices ADM9240 11 * Driver supports Analog Devices ADM9240
@@ -774,7 +774,7 @@ static void __exit sensors_adm9240_exit(void)
774} 774}
775 775
776MODULE_AUTHOR("Michiel Rook <michiel@grendelproject.nl>, " 776MODULE_AUTHOR("Michiel Rook <michiel@grendelproject.nl>, "
777 "Grant Coady <gcoady@gmail.com> and others"); 777 "Grant Coady <gcoady.lk@gmail.com> and others");
778MODULE_DESCRIPTION("ADM9240/DS1780/LM81 driver"); 778MODULE_DESCRIPTION("ADM9240/DS1780/LM81 driver");
779MODULE_LICENSE("GPL"); 779MODULE_LICENSE("GPL");
780 780
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index ac1b746df6d0..73bc2ffc598d 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -815,18 +815,18 @@ static int __init sm_lm78_init(void)
815 if (res) 815 if (res)
816 return res; 816 return res;
817 817
818 res = i2c_isa_add_driver(&lm78_isa_driver); 818 /* Don't exit if this one fails, we still want the I2C variants
819 if (res) { 819 to work! */
820 i2c_del_driver(&lm78_driver); 820 if (i2c_isa_add_driver(&lm78_isa_driver))
821 return res; 821 isa_address = 0;
822 }
823 822
824 return 0; 823 return 0;
825} 824}
826 825
827static void __exit sm_lm78_exit(void) 826static void __exit sm_lm78_exit(void)
828{ 827{
829 i2c_isa_del_driver(&lm78_isa_driver); 828 if (isa_address)
829 i2c_isa_del_driver(&lm78_isa_driver);
830 i2c_del_driver(&lm78_driver); 830 i2c_del_driver(&lm78_driver);
831} 831}
832 832
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 47132fd26b1b..beb881c4b2e8 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -2,8 +2,8 @@
2 smsc47m1.c - Part of lm_sensors, Linux kernel modules 2 smsc47m1.c - Part of lm_sensors, Linux kernel modules
3 for hardware monitoring 3 for hardware monitoring
4 4
5 Supports the SMSC LPC47B27x, LPC47M10x, LPC47M13x, LPC47M14x, 5 Supports the SMSC LPC47B27x, LPC47M10x, LPC47M112, LPC47M13x,
6 LPC47M15x, LPC47M192 and LPC47M997 Super-I/O chips. 6 LPC47M14x, LPC47M15x, LPC47M192 and LPC47M997 Super-I/O chips.
7 7
8 Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com> 8 Copyright (C) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
9 Copyright (C) 2004 Jean Delvare <khali@linux-fr.org> 9 Copyright (C) 2004 Jean Delvare <khali@linux-fr.org>
@@ -380,8 +380,8 @@ static int __init smsc47m1_find(unsigned short *addr)
380 val = superio_inb(SUPERIO_REG_DEVID); 380 val = superio_inb(SUPERIO_REG_DEVID);
381 381
382 /* 382 /*
383 * SMSC LPC47M10x/LPC47M13x (device id 0x59), LPC47M14x (device id 383 * SMSC LPC47M10x/LPC47M112/LPC47M13x (device id 0x59), LPC47M14x
384 * 0x5F) and LPC47B27x (device id 0x51) have fan control. 384 * (device id 0x5F) and LPC47B27x (device id 0x51) have fan control.
385 * The LPC47M15x and LPC47M192 chips "with hardware monitoring block" 385 * The LPC47M15x and LPC47M192 chips "with hardware monitoring block"
386 * can do much more besides (device id 0x60). 386 * can do much more besides (device id 0x60).
387 * The LPC47M997 is undocumented, but seems to be compatible with 387 * The LPC47M997 is undocumented, but seems to be compatible with
@@ -390,7 +390,8 @@ static int __init smsc47m1_find(unsigned short *addr)
390 if (val == 0x51) 390 if (val == 0x51)
391 printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n"); 391 printk(KERN_INFO "smsc47m1: Found SMSC LPC47B27x\n");
392 else if (val == 0x59) 392 else if (val == 0x59)
393 printk(KERN_INFO "smsc47m1: Found SMSC LPC47M10x/LPC47M13x\n"); 393 printk(KERN_INFO "smsc47m1: Found SMSC "
394 "LPC47M10x/LPC47M112/LPC47M13x\n");
394 else if (val == 0x5F) 395 else if (val == 0x5F)
395 printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n"); 396 printk(KERN_INFO "smsc47m1: Found SMSC LPC47M14x\n");
396 else if (val == 0x60) 397 else if (val == 0x60)
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 833faa275ffa..2257806d0102 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -354,6 +354,8 @@ static void w83627ehf_write_fan_div(struct i2c_client *client, int nr)
354 case 0: 354 case 0:
355 reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0xcf) 355 reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0xcf)
356 | ((data->fan_div[0] & 0x03) << 4); 356 | ((data->fan_div[0] & 0x03) << 4);
357 /* fan5 input control bit is write only, compute the value */
358 reg |= (data->has_fan & (1 << 4)) ? 1 : 0;
357 w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg); 359 w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg);
358 reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xdf) 360 reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xdf)
359 | ((data->fan_div[0] & 0x04) << 3); 361 | ((data->fan_div[0] & 0x04) << 3);
@@ -362,6 +364,8 @@ static void w83627ehf_write_fan_div(struct i2c_client *client, int nr)
362 case 1: 364 case 1:
363 reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0x3f) 365 reg = (w83627ehf_read_value(client, W83627EHF_REG_FANDIV1) & 0x3f)
364 | ((data->fan_div[1] & 0x03) << 6); 366 | ((data->fan_div[1] & 0x03) << 6);
367 /* fan5 input control bit is write only, compute the value */
368 reg |= (data->has_fan & (1 << 4)) ? 1 : 0;
365 w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg); 369 w83627ehf_write_value(client, W83627EHF_REG_FANDIV1, reg);
366 reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xbf) 370 reg = (w83627ehf_read_value(client, W83627EHF_REG_VBAT) & 0xbf)
367 | ((data->fan_div[1] & 0x04) << 4); 371 | ((data->fan_div[1] & 0x04) << 4);
@@ -1216,13 +1220,16 @@ static int w83627ehf_detect(struct i2c_adapter *adapter)
1216 superio_exit(); 1220 superio_exit();
1217 1221
1218 /* It looks like fan4 and fan5 pins can be alternatively used 1222 /* It looks like fan4 and fan5 pins can be alternatively used
1219 as fan on/off switches */ 1223 as fan on/off switches, but fan5 control is write only :/
1224 We assume that if the serial interface is disabled, designers
1225 connected fan5 as input unless they are emitting log 1, which
1226 is not the default. */
1220 1227
1221 data->has_fan = 0x07; /* fan1, fan2 and fan3 */ 1228 data->has_fan = 0x07; /* fan1, fan2 and fan3 */
1222 i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1); 1229 i = w83627ehf_read_value(client, W83627EHF_REG_FANDIV1);
1223 if ((i & (1 << 2)) && (!fan4pin)) 1230 if ((i & (1 << 2)) && (!fan4pin))
1224 data->has_fan |= (1 << 3); 1231 data->has_fan |= (1 << 3);
1225 if ((i & (1 << 0)) && (!fan5pin)) 1232 if (!(i & (1 << 1)) && (!fan5pin))
1226 data->has_fan |= (1 << 4); 1233 data->has_fan |= (1 << 4);
1227 1234
1228 /* Register sysfs hooks */ 1235 /* Register sysfs hooks */
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index a4584ec69842..1232171c3aad 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -1099,7 +1099,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1099 bank. */ 1099 bank. */
1100 if (kind < 0) { 1100 if (kind < 0) {
1101 if (w83781d_read_value(client, W83781D_REG_CONFIG) & 0x80) { 1101 if (w83781d_read_value(client, W83781D_REG_CONFIG) & 0x80) {
1102 dev_dbg(dev, "Detection failed at step 3\n"); 1102 dev_dbg(&adapter->dev, "Detection of w83781d chip "
1103 "failed at step 3\n");
1103 err = -ENODEV; 1104 err = -ENODEV;
1104 goto ERROR2; 1105 goto ERROR2;
1105 } 1106 }
@@ -1109,7 +1110,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1109 if ((!(val1 & 0x07)) && 1110 if ((!(val1 & 0x07)) &&
1110 (((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3)) 1111 (((!(val1 & 0x80)) && (val2 != 0xa3) && (val2 != 0xc3))
1111 || ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12)))) { 1112 || ((val1 & 0x80) && (val2 != 0x5c) && (val2 != 0x12)))) {
1112 dev_dbg(dev, "Detection failed at step 4\n"); 1113 dev_dbg(&adapter->dev, "Detection of w83781d chip "
1114 "failed at step 4\n");
1113 err = -ENODEV; 1115 err = -ENODEV;
1114 goto ERROR2; 1116 goto ERROR2;
1115 } 1117 }
@@ -1119,7 +1121,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1119 ((val1 & 0x80) && (val2 == 0x5c)))) { 1121 ((val1 & 0x80) && (val2 == 0x5c)))) {
1120 if (w83781d_read_value 1122 if (w83781d_read_value
1121 (client, W83781D_REG_I2C_ADDR) != address) { 1123 (client, W83781D_REG_I2C_ADDR) != address) {
1122 dev_dbg(dev, "Detection failed at step 5\n"); 1124 dev_dbg(&adapter->dev, "Detection of w83781d "
1125 "chip failed at step 5\n");
1123 err = -ENODEV; 1126 err = -ENODEV;
1124 goto ERROR2; 1127 goto ERROR2;
1125 } 1128 }
@@ -1141,8 +1144,8 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1141 else if (val2 == 0x12) 1144 else if (val2 == 0x12)
1142 vendid = asus; 1145 vendid = asus;
1143 else { 1146 else {
1144 dev_dbg(dev, "Chip was made by neither " 1147 dev_dbg(&adapter->dev, "w83781d chip vendor is "
1145 "Winbond nor Asus?\n"); 1148 "neither Winbond nor Asus\n");
1146 err = -ENODEV; 1149 err = -ENODEV;
1147 goto ERROR2; 1150 goto ERROR2;
1148 } 1151 }
@@ -1161,10 +1164,9 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1161 kind = as99127f; 1164 kind = as99127f;
1162 else { 1165 else {
1163 if (kind == 0) 1166 if (kind == 0)
1164 dev_warn(dev, "Ignoring 'force' " 1167 dev_warn(&adapter->dev, "Ignoring 'force' "
1165 "parameter for unknown chip at " 1168 "parameter for unknown chip at "
1166 "adapter %d, address 0x%02x\n", 1169 "address 0x%02x\n", address);
1167 i2c_adapter_id(adapter), address);
1168 err = -EINVAL; 1170 err = -EINVAL;
1169 goto ERROR2; 1171 goto ERROR2;
1170 } 1172 }
@@ -1685,11 +1687,10 @@ sensors_w83781d_init(void)
1685 if (res) 1687 if (res)
1686 return res; 1688 return res;
1687 1689
1688 res = i2c_isa_add_driver(&w83781d_isa_driver); 1690 /* Don't exit if this one fails, we still want the I2C variants
1689 if (res) { 1691 to work! */
1690 i2c_del_driver(&w83781d_driver); 1692 if (i2c_isa_add_driver(&w83781d_isa_driver))
1691 return res; 1693 isa_address = 0;
1692 }
1693 1694
1694 return 0; 1695 return 0;
1695} 1696}
@@ -1697,7 +1698,8 @@ sensors_w83781d_init(void)
1697static void __exit 1698static void __exit
1698sensors_w83781d_exit(void) 1699sensors_w83781d_exit(void)
1699{ 1700{
1700 i2c_isa_del_driver(&w83781d_isa_driver); 1701 if (isa_address)
1702 i2c_isa_del_driver(&w83781d_isa_driver);
1701 i2c_del_driver(&w83781d_driver); 1703 i2c_del_driver(&w83781d_driver);
1702} 1704}
1703 1705
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c
index 371ed4f69a97..9e5f885368b4 100644
--- a/drivers/hwmon/w83791d.c
+++ b/drivers/hwmon/w83791d.c
@@ -746,6 +746,52 @@ static ssize_t store_vrm_reg(struct device *dev,
746 746
747static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); 747static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg);
748 748
749#define IN_UNIT_ATTRS(X) \
750 &sda_in_input[X].dev_attr.attr, \
751 &sda_in_min[X].dev_attr.attr, \
752 &sda_in_max[X].dev_attr.attr
753
754#define FAN_UNIT_ATTRS(X) \
755 &sda_fan_input[X].dev_attr.attr, \
756 &sda_fan_min[X].dev_attr.attr, \
757 &sda_fan_div[X].dev_attr.attr
758
759#define TEMP_UNIT_ATTRS(X) \
760 &sda_temp_input[X].dev_attr.attr, \
761 &sda_temp_max[X].dev_attr.attr, \
762 &sda_temp_max_hyst[X].dev_attr.attr
763
764static struct attribute *w83791d_attributes[] = {
765 IN_UNIT_ATTRS(0),
766 IN_UNIT_ATTRS(1),
767 IN_UNIT_ATTRS(2),
768 IN_UNIT_ATTRS(3),
769 IN_UNIT_ATTRS(4),
770 IN_UNIT_ATTRS(5),
771 IN_UNIT_ATTRS(6),
772 IN_UNIT_ATTRS(7),
773 IN_UNIT_ATTRS(8),
774 IN_UNIT_ATTRS(9),
775 FAN_UNIT_ATTRS(0),
776 FAN_UNIT_ATTRS(1),
777 FAN_UNIT_ATTRS(2),
778 FAN_UNIT_ATTRS(3),
779 FAN_UNIT_ATTRS(4),
780 TEMP_UNIT_ATTRS(0),
781 TEMP_UNIT_ATTRS(1),
782 TEMP_UNIT_ATTRS(2),
783 &dev_attr_alarms.attr,
784 &sda_beep_ctrl[0].dev_attr.attr,
785 &sda_beep_ctrl[1].dev_attr.attr,
786 &dev_attr_cpu0_vid.attr,
787 &dev_attr_vrm.attr,
788 NULL
789};
790
791static const struct attribute_group w83791d_group = {
792 .attrs = w83791d_attributes,
793};
794
749/* This function is called when: 795/* This function is called when:
750 * w83791d_driver is inserted (when this module is loaded), for each 796 * w83791d_driver is inserted (when this module is loaded), for each
751 available adapter 797 available adapter
@@ -967,41 +1013,20 @@ static int w83791d_detect(struct i2c_adapter *adapter, int address, int kind)
967 } 1013 }
968 1014
969 /* Register sysfs hooks */ 1015 /* Register sysfs hooks */
1016 if ((err = sysfs_create_group(&client->dev.kobj, &w83791d_group)))
1017 goto error3;
1018
1019 /* Everything is ready, now register the working device */
970 data->class_dev = hwmon_device_register(dev); 1020 data->class_dev = hwmon_device_register(dev);
971 if (IS_ERR(data->class_dev)) { 1021 if (IS_ERR(data->class_dev)) {
972 err = PTR_ERR(data->class_dev); 1022 err = PTR_ERR(data->class_dev);
973 goto error3; 1023 goto error4;
974 } 1024 }
975 1025
976 for (i = 0; i < NUMBER_OF_VIN; i++) {
977 device_create_file(dev, &sda_in_input[i].dev_attr);
978 device_create_file(dev, &sda_in_min[i].dev_attr);
979 device_create_file(dev, &sda_in_max[i].dev_attr);
980 }
981
982 for (i = 0; i < NUMBER_OF_FANIN; i++) {
983 device_create_file(dev, &sda_fan_input[i].dev_attr);
984 device_create_file(dev, &sda_fan_div[i].dev_attr);
985 device_create_file(dev, &sda_fan_min[i].dev_attr);
986 }
987
988 for (i = 0; i < NUMBER_OF_TEMPIN; i++) {
989 device_create_file(dev, &sda_temp_input[i].dev_attr);
990 device_create_file(dev, &sda_temp_max[i].dev_attr);
991 device_create_file(dev, &sda_temp_max_hyst[i].dev_attr);
992 }
993
994 device_create_file(dev, &dev_attr_alarms);
995
996 for (i = 0; i < ARRAY_SIZE(sda_beep_ctrl); i++) {
997 device_create_file(dev, &sda_beep_ctrl[i].dev_attr);
998 }
999
1000 device_create_file(dev, &dev_attr_cpu0_vid);
1001 device_create_file(dev, &dev_attr_vrm);
1002
1003 return 0; 1026 return 0;
1004 1027
1028error4:
1029 sysfs_remove_group(&client->dev.kobj, &w83791d_group);
1005error3: 1030error3:
1006 if (data->lm75[0] != NULL) { 1031 if (data->lm75[0] != NULL) {
1007 i2c_detach_client(data->lm75[0]); 1032 i2c_detach_client(data->lm75[0]);
@@ -1025,8 +1050,10 @@ static int w83791d_detach_client(struct i2c_client *client)
1025 int err; 1050 int err;
1026 1051
1027 /* main client */ 1052 /* main client */
1028 if (data) 1053 if (data) {
1029 hwmon_device_unregister(data->class_dev); 1054 hwmon_device_unregister(data->class_dev);
1055 sysfs_remove_group(&client->dev.kobj, &w83791d_group);
1056 }
1030 1057
1031 if ((err = i2c_detach_client(client))) 1058 if ((err = i2c_detach_client(client)))
1032 return err; 1059 return err;
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c
index 4380653748a4..8ed59a2dff53 100644
--- a/drivers/i2c/busses/i2c-isa.c
+++ b/drivers/i2c/busses/i2c-isa.c
@@ -91,7 +91,7 @@ int i2c_isa_add_driver(struct i2c_driver *driver)
91 /* Now look for clients */ 91 /* Now look for clients */
92 res = driver->attach_adapter(&isa_adapter); 92 res = driver->attach_adapter(&isa_adapter);
93 if (res) { 93 if (res) {
94 dev_err(&isa_adapter.dev, 94 dev_dbg(&isa_adapter.dev,
95 "Driver %s failed to attach adapter, unregistering\n", 95 "Driver %s failed to attach adapter, unregistering\n",
96 driver->driver.name); 96 driver->driver.name);
97 driver_unregister(&driver->driver); 97 driver_unregister(&driver->driver);
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 1d0470c1f957..30175c7688e8 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -524,8 +524,8 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
524 task_ioreg_t *hobsptr = args.hobRegister; 524 task_ioreg_t *hobsptr = args.hobRegister;
525 int err = 0; 525 int err = 0;
526 int tasksize = sizeof(struct ide_task_request_s); 526 int tasksize = sizeof(struct ide_task_request_s);
527 int taskin = 0; 527 unsigned int taskin = 0;
528 int taskout = 0; 528 unsigned int taskout = 0;
529 u8 io_32bit = drive->io_32bit; 529 u8 io_32bit = drive->io_32bit;
530 char __user *buf = (char __user *)arg; 530 char __user *buf = (char __user *)arg;
531 531
@@ -538,8 +538,13 @@ int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
538 return -EFAULT; 538 return -EFAULT;
539 } 539 }
540 540
541 taskout = (int) req_task->out_size; 541 taskout = req_task->out_size;
542 taskin = (int) req_task->in_size; 542 taskin = req_task->in_size;
543
544 if (taskin > 65536 || taskout > 65536) {
545 err = -EINVAL;
546 goto abort;
547 }
543 548
544 if (taskout) { 549 if (taskout) {
545 int outtotal = tasksize; 550 int outtotal = tasksize;
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index f3fe287fbd89..244f7eb7006d 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -774,7 +774,7 @@ ioc4_ide_exit(void)
774 ioc4_unregister_submodule(&ioc4_ide_submodule); 774 ioc4_unregister_submodule(&ioc4_ide_submodule);
775} 775}
776 776
777module_init(ioc4_ide_init); 777late_initcall(ioc4_ide_init); /* Call only after IDE init is done */
778module_exit(ioc4_ide_exit); 778module_exit(ioc4_ide_exit);
779 779
780MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon"); 780MODULE_AUTHOR("Aniket Malatpure/Jeremy Higdon");
diff --git a/drivers/infiniband/hw/amso1100/c2.c b/drivers/infiniband/hw/amso1100/c2.c
index dc1ebeac35c7..9e7bd94b958a 100644
--- a/drivers/infiniband/hw/amso1100/c2.c
+++ b/drivers/infiniband/hw/amso1100/c2.c
@@ -1243,7 +1243,7 @@ static struct pci_driver c2_pci_driver = {
1243 1243
1244static int __init c2_init_module(void) 1244static int __init c2_init_module(void)
1245{ 1245{
1246 return pci_module_init(&c2_pci_driver); 1246 return pci_register_driver(&c2_pci_driver);
1247} 1247}
1248 1248
1249static void __exit c2_exit_module(void) 1249static void __exit c2_exit_module(void)
diff --git a/drivers/infiniband/hw/amso1100/c2_rnic.c b/drivers/infiniband/hw/amso1100/c2_rnic.c
index e37c5688c214..30409e179606 100644
--- a/drivers/infiniband/hw/amso1100/c2_rnic.c
+++ b/drivers/infiniband/hw/amso1100/c2_rnic.c
@@ -150,8 +150,8 @@ static int c2_rnic_query(struct c2_dev *c2dev, struct ib_device_attr *props)
150 (struct c2wr_rnic_query_rep *) (unsigned long) (vq_req->reply_msg); 150 (struct c2wr_rnic_query_rep *) (unsigned long) (vq_req->reply_msg);
151 if (!reply) 151 if (!reply)
152 err = -ENOMEM; 152 err = -ENOMEM;
153 153 else
154 err = c2_errno(reply); 154 err = c2_errno(reply);
155 if (err) 155 if (err)
156 goto bail2; 156 goto bail2;
157 157
diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c
index 29958b6e0214..28c087b824c2 100644
--- a/drivers/infiniband/hw/ipath/ipath_diag.c
+++ b/drivers/infiniband/hw/ipath/ipath_diag.c
@@ -67,19 +67,54 @@ static struct file_operations diag_file_ops = {
67 .release = ipath_diag_release 67 .release = ipath_diag_release
68}; 68};
69 69
70static ssize_t ipath_diagpkt_write(struct file *fp,
71 const char __user *data,
72 size_t count, loff_t *off);
73
74static struct file_operations diagpkt_file_ops = {
75 .owner = THIS_MODULE,
76 .write = ipath_diagpkt_write,
77};
78
79static atomic_t diagpkt_count = ATOMIC_INIT(0);
80static struct cdev *diagpkt_cdev;
81static struct class_device *diagpkt_class_dev;
82
70int ipath_diag_add(struct ipath_devdata *dd) 83int ipath_diag_add(struct ipath_devdata *dd)
71{ 84{
72 char name[16]; 85 char name[16];
86 int ret = 0;
87
88 if (atomic_inc_return(&diagpkt_count) == 1) {
89 ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR,
90 "ipath_diagpkt", &diagpkt_file_ops,
91 &diagpkt_cdev, &diagpkt_class_dev);
92
93 if (ret) {
94 ipath_dev_err(dd, "Couldn't create ipath_diagpkt "
95 "device: %d", ret);
96 goto done;
97 }
98 }
73 99
74 snprintf(name, sizeof(name), "ipath_diag%d", dd->ipath_unit); 100 snprintf(name, sizeof(name), "ipath_diag%d", dd->ipath_unit);
75 101
76 return ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name, 102 ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name,
77 &diag_file_ops, &dd->diag_cdev, 103 &diag_file_ops, &dd->diag_cdev,
78 &dd->diag_class_dev); 104 &dd->diag_class_dev);
105 if (ret)
106 ipath_dev_err(dd, "Couldn't create %s device: %d",
107 name, ret);
108
109done:
110 return ret;
79} 111}
80 112
81void ipath_diag_remove(struct ipath_devdata *dd) 113void ipath_diag_remove(struct ipath_devdata *dd)
82{ 114{
115 if (atomic_dec_and_test(&diagpkt_count))
116 ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev);
117
83 ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev); 118 ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev);
84} 119}
85 120
@@ -275,30 +310,6 @@ bail:
275 return ret; 310 return ret;
276} 311}
277 312
278static ssize_t ipath_diagpkt_write(struct file *fp,
279 const char __user *data,
280 size_t count, loff_t *off);
281
282static struct file_operations diagpkt_file_ops = {
283 .owner = THIS_MODULE,
284 .write = ipath_diagpkt_write,
285};
286
287static struct cdev *diagpkt_cdev;
288static struct class_device *diagpkt_class_dev;
289
290int __init ipath_diagpkt_add(void)
291{
292 return ipath_cdev_init(IPATH_DIAGPKT_MINOR,
293 "ipath_diagpkt", &diagpkt_file_ops,
294 &diagpkt_cdev, &diagpkt_class_dev);
295}
296
297void __exit ipath_diagpkt_remove(void)
298{
299 ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev);
300}
301
302/** 313/**
303 * ipath_diagpkt_write - write an IB packet 314 * ipath_diagpkt_write - write an IB packet
304 * @fp: the diag data device file pointer 315 * @fp: the diag data device file pointer
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index 12cefa658f3b..b4ffaa7bcbb7 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -2005,18 +2005,8 @@ static int __init infinipath_init(void)
2005 goto bail_group; 2005 goto bail_group;
2006 } 2006 }
2007 2007
2008 ret = ipath_diagpkt_add();
2009 if (ret < 0) {
2010 printk(KERN_ERR IPATH_DRV_NAME ": Unable to create "
2011 "diag data device: error %d\n", -ret);
2012 goto bail_ipathfs;
2013 }
2014
2015 goto bail; 2008 goto bail;
2016 2009
2017bail_ipathfs:
2018 ipath_exit_ipathfs();
2019
2020bail_group: 2010bail_group:
2021 ipath_driver_remove_group(&ipath_driver.driver); 2011 ipath_driver_remove_group(&ipath_driver.driver);
2022 2012
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index 7c436697d0e4..06d5020a2f60 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -869,9 +869,6 @@ int ipath_device_create_group(struct device *, struct ipath_devdata *);
869void ipath_device_remove_group(struct device *, struct ipath_devdata *); 869void ipath_device_remove_group(struct device *, struct ipath_devdata *);
870int ipath_expose_reset(struct device *); 870int ipath_expose_reset(struct device *);
871 871
872int ipath_diagpkt_add(void);
873void ipath_diagpkt_remove(void);
874
875int ipath_init_ipathfs(void); 872int ipath_init_ipathfs(void);
876void ipath_exit_ipathfs(void); 873void ipath_exit_ipathfs(void);
877int ipathfs_add_device(struct ipath_devdata *); 874int ipathfs_add_device(struct ipath_devdata *);
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index e393681ba7d4..149b36901239 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -39,6 +39,8 @@
39#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/hardirq.h> 40#include <linux/hardirq.h>
41 41
42#include <asm/io.h>
43
42#include <rdma/ib_pack.h> 44#include <rdma/ib_pack.h>
43 45
44#include "mthca_dev.h" 46#include "mthca_dev.h"
@@ -210,6 +212,11 @@ static inline void update_cons_index(struct mthca_dev *dev, struct mthca_cq *cq,
210 mthca_write64(doorbell, 212 mthca_write64(doorbell,
211 dev->kar + MTHCA_CQ_DOORBELL, 213 dev->kar + MTHCA_CQ_DOORBELL,
212 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); 214 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
215 /*
216 * Make sure doorbells don't leak out of CQ spinlock
217 * and reach the HCA out of order:
218 */
219 mmiowb();
213 } 220 }
214} 221}
215 222
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 5e5c58b9920b..6a7822e0fc19 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -39,6 +39,8 @@
39#include <linux/string.h> 39#include <linux/string.h>
40#include <linux/slab.h> 40#include <linux/slab.h>
41 41
42#include <asm/io.h>
43
42#include <rdma/ib_verbs.h> 44#include <rdma/ib_verbs.h>
43#include <rdma/ib_cache.h> 45#include <rdma/ib_cache.h>
44#include <rdma/ib_pack.h> 46#include <rdma/ib_pack.h>
@@ -1732,6 +1734,11 @@ out:
1732 mthca_write64(doorbell, 1734 mthca_write64(doorbell,
1733 dev->kar + MTHCA_SEND_DOORBELL, 1735 dev->kar + MTHCA_SEND_DOORBELL,
1734 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); 1736 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
1737 /*
1738 * Make sure doorbells don't leak out of SQ spinlock
1739 * and reach the HCA out of order:
1740 */
1741 mmiowb();
1735 } 1742 }
1736 1743
1737 qp->sq.next_ind = ind; 1744 qp->sq.next_ind = ind;
@@ -1851,6 +1858,12 @@ out:
1851 qp->rq.next_ind = ind; 1858 qp->rq.next_ind = ind;
1852 qp->rq.head += nreq; 1859 qp->rq.head += nreq;
1853 1860
1861 /*
1862 * Make sure doorbells don't leak out of RQ spinlock and reach
1863 * the HCA out of order:
1864 */
1865 mmiowb();
1866
1854 spin_unlock_irqrestore(&qp->rq.lock, flags); 1867 spin_unlock_irqrestore(&qp->rq.lock, flags);
1855 return err; 1868 return err;
1856} 1869}
@@ -2112,6 +2125,12 @@ out:
2112 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); 2125 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
2113 } 2126 }
2114 2127
2128 /*
2129 * Make sure doorbells don't leak out of SQ spinlock and reach
2130 * the HCA out of order:
2131 */
2132 mmiowb();
2133
2115 spin_unlock_irqrestore(&qp->sq.lock, flags); 2134 spin_unlock_irqrestore(&qp->sq.lock, flags);
2116 return err; 2135 return err;
2117} 2136}
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index 92a72f521528..f5d7677d1079 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -35,6 +35,8 @@
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/string.h> 36#include <linux/string.h>
37 37
38#include <asm/io.h>
39
38#include "mthca_dev.h" 40#include "mthca_dev.h"
39#include "mthca_cmd.h" 41#include "mthca_cmd.h"
40#include "mthca_memfree.h" 42#include "mthca_memfree.h"
@@ -595,6 +597,12 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
595 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock)); 597 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
596 } 598 }
597 599
600 /*
601 * Make sure doorbells don't leak out of SRQ spinlock and
602 * reach the HCA out of order:
603 */
604 mmiowb();
605
598 spin_unlock_irqrestore(&srq->lock, flags); 606 spin_unlock_irqrestore(&srq->lock, flags);
599 return err; 607 return err;
600} 608}
diff --git a/drivers/input/gameport/fm801-gp.c b/drivers/input/gameport/fm801-gp.c
index 90de5afe03c2..1dec00e20dbc 100644
--- a/drivers/input/gameport/fm801-gp.c
+++ b/drivers/input/gameport/fm801-gp.c
@@ -82,17 +82,19 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
82{ 82{
83 struct fm801_gp *gp; 83 struct fm801_gp *gp;
84 struct gameport *port; 84 struct gameport *port;
85 int error;
85 86
86 gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL); 87 gp = kzalloc(sizeof(struct fm801_gp), GFP_KERNEL);
87 port = gameport_allocate_port(); 88 port = gameport_allocate_port();
88 if (!gp || !port) { 89 if (!gp || !port) {
89 printk(KERN_ERR "fm801-gp: Memory allocation failed\n"); 90 printk(KERN_ERR "fm801-gp: Memory allocation failed\n");
90 kfree(gp); 91 error = -ENOMEM;
91 gameport_free_port(port); 92 goto err_out_free;
92 return -ENOMEM;
93 } 93 }
94 94
95 pci_enable_device(pci); 95 error = pci_enable_device(pci);
96 if (error)
97 goto err_out_free;
96 98
97 port->open = fm801_gp_open; 99 port->open = fm801_gp_open;
98#ifdef HAVE_COOKED 100#ifdef HAVE_COOKED
@@ -108,9 +110,8 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
108 if (!gp->res_port) { 110 if (!gp->res_port) {
109 printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n", 111 printk(KERN_DEBUG "fm801-gp: unable to grab region 0x%x-0x%x\n",
110 port->io, port->io + 0x0f); 112 port->io, port->io + 0x0f);
111 gameport_free_port(port); 113 error = -EBUSY;
112 kfree(gp); 114 goto err_out_disable_dev;
113 return -EBUSY;
114 } 115 }
115 116
116 pci_set_drvdata(pci, gp); 117 pci_set_drvdata(pci, gp);
@@ -119,6 +120,13 @@ static int __devinit fm801_gp_probe(struct pci_dev *pci, const struct pci_device
119 gameport_register_port(port); 120 gameport_register_port(port);
120 121
121 return 0; 122 return 0;
123
124 err_out_disable_dev:
125 pci_disable_device(pci);
126 err_out_free:
127 gameport_free_port(port);
128 kfree(gp);
129 return error;
122} 130}
123 131
124static void __devexit fm801_gp_remove(struct pci_dev *pci) 132static void __devexit fm801_gp_remove(struct pci_dev *pci)
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index 3f47ae55c6f3..a0af97efe6ac 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -191,6 +191,8 @@ static void gameport_run_poll_handler(unsigned long d)
191 191
192static void gameport_bind_driver(struct gameport *gameport, struct gameport_driver *drv) 192static void gameport_bind_driver(struct gameport *gameport, struct gameport_driver *drv)
193{ 193{
194 int error;
195
194 down_write(&gameport_bus.subsys.rwsem); 196 down_write(&gameport_bus.subsys.rwsem);
195 197
196 gameport->dev.driver = &drv->driver; 198 gameport->dev.driver = &drv->driver;
@@ -198,8 +200,20 @@ static void gameport_bind_driver(struct gameport *gameport, struct gameport_driv
198 gameport->dev.driver = NULL; 200 gameport->dev.driver = NULL;
199 goto out; 201 goto out;
200 } 202 }
201 device_bind_driver(&gameport->dev); 203
202out: 204 error = device_bind_driver(&gameport->dev);
205 if (error) {
206 printk(KERN_WARNING
207 "gameport: device_bind_driver() failed "
208 "for %s (%s) and %s, error: %d\n",
209 gameport->phys, gameport->name,
210 drv->description, error);
211 drv->disconnect(gameport);
212 gameport->dev.driver = NULL;
213 goto out;
214 }
215
216 out:
203 up_write(&gameport_bus.subsys.rwsem); 217 up_write(&gameport_bus.subsys.rwsem);
204} 218}
205 219
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index b6ef9eaad1dc..cbb93669d1ce 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -221,6 +221,7 @@ struct atkbd {
221 unsigned long xl_bit; 221 unsigned long xl_bit;
222 unsigned int last; 222 unsigned int last;
223 unsigned long time; 223 unsigned long time;
224 unsigned long err_count;
224 225
225 struct work_struct event_work; 226 struct work_struct event_work;
226 struct mutex event_mutex; 227 struct mutex event_mutex;
@@ -234,11 +235,13 @@ static ssize_t atkbd_attr_set_helper(struct device *dev, const char *buf, size_t
234#define ATKBD_DEFINE_ATTR(_name) \ 235#define ATKBD_DEFINE_ATTR(_name) \
235static ssize_t atkbd_show_##_name(struct atkbd *, char *); \ 236static ssize_t atkbd_show_##_name(struct atkbd *, char *); \
236static ssize_t atkbd_set_##_name(struct atkbd *, const char *, size_t); \ 237static ssize_t atkbd_set_##_name(struct atkbd *, const char *, size_t); \
237static ssize_t atkbd_do_show_##_name(struct device *d, struct device_attribute *attr, char *b) \ 238static ssize_t atkbd_do_show_##_name(struct device *d, \
239 struct device_attribute *attr, char *b) \
238{ \ 240{ \
239 return atkbd_attr_show_helper(d, b, atkbd_show_##_name); \ 241 return atkbd_attr_show_helper(d, b, atkbd_show_##_name); \
240} \ 242} \
241static ssize_t atkbd_do_set_##_name(struct device *d, struct device_attribute *attr, const char *b, size_t s) \ 243static ssize_t atkbd_do_set_##_name(struct device *d, \
244 struct device_attribute *attr, const char *b, size_t s) \
242{ \ 245{ \
243 return atkbd_attr_set_helper(d, b, s, atkbd_set_##_name); \ 246 return atkbd_attr_set_helper(d, b, s, atkbd_set_##_name); \
244} \ 247} \
@@ -251,6 +254,32 @@ ATKBD_DEFINE_ATTR(set);
251ATKBD_DEFINE_ATTR(softrepeat); 254ATKBD_DEFINE_ATTR(softrepeat);
252ATKBD_DEFINE_ATTR(softraw); 255ATKBD_DEFINE_ATTR(softraw);
253 256
257#define ATKBD_DEFINE_RO_ATTR(_name) \
258static ssize_t atkbd_show_##_name(struct atkbd *, char *); \
259static ssize_t atkbd_do_show_##_name(struct device *d, \
260 struct device_attribute *attr, char *b) \
261{ \
262 return atkbd_attr_show_helper(d, b, atkbd_show_##_name); \
263} \
264static struct device_attribute atkbd_attr_##_name = \
265 __ATTR(_name, S_IRUGO, atkbd_do_show_##_name, NULL);
266
267ATKBD_DEFINE_RO_ATTR(err_count);
268
269static struct attribute *atkbd_attributes[] = {
270 &atkbd_attr_extra.attr,
271 &atkbd_attr_scroll.attr,
272 &atkbd_attr_set.attr,
273 &atkbd_attr_softrepeat.attr,
274 &atkbd_attr_softraw.attr,
275 &atkbd_attr_err_count.attr,
276 NULL
277};
278
279static struct attribute_group atkbd_attribute_group = {
280 .attrs = atkbd_attributes,
281};
282
254static const unsigned int xl_table[] = { 283static const unsigned int xl_table[] = {
255 ATKBD_RET_BAT, ATKBD_RET_ERR, ATKBD_RET_ACK, 284 ATKBD_RET_BAT, ATKBD_RET_ERR, ATKBD_RET_ACK,
256 ATKBD_RET_NAK, ATKBD_RET_HANJA, ATKBD_RET_HANGEUL, 285 ATKBD_RET_NAK, ATKBD_RET_HANJA, ATKBD_RET_HANGEUL,
@@ -396,7 +425,10 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data,
396 add_release_event = 1; 425 add_release_event = 1;
397 break; 426 break;
398 case ATKBD_RET_ERR: 427 case ATKBD_RET_ERR:
428 atkbd->err_count++;
429#ifdef ATKBD_DEBUG
399 printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); 430 printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys);
431#endif
400 goto out; 432 goto out;
401 } 433 }
402 434
@@ -786,12 +818,7 @@ static void atkbd_disconnect(struct serio *serio)
786 synchronize_sched(); /* Allow atkbd_interrupt()s to complete. */ 818 synchronize_sched(); /* Allow atkbd_interrupt()s to complete. */
787 flush_scheduled_work(); 819 flush_scheduled_work();
788 820
789 device_remove_file(&serio->dev, &atkbd_attr_extra); 821 sysfs_remove_group(&serio->dev.kobj, &atkbd_attribute_group);
790 device_remove_file(&serio->dev, &atkbd_attr_scroll);
791 device_remove_file(&serio->dev, &atkbd_attr_set);
792 device_remove_file(&serio->dev, &atkbd_attr_softrepeat);
793 device_remove_file(&serio->dev, &atkbd_attr_softraw);
794
795 input_unregister_device(atkbd->dev); 822 input_unregister_device(atkbd->dev);
796 serio_close(serio); 823 serio_close(serio);
797 serio_set_drvdata(serio, NULL); 824 serio_set_drvdata(serio, NULL);
@@ -961,11 +988,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
961 atkbd_set_keycode_table(atkbd); 988 atkbd_set_keycode_table(atkbd);
962 atkbd_set_device_attrs(atkbd); 989 atkbd_set_device_attrs(atkbd);
963 990
964 device_create_file(&serio->dev, &atkbd_attr_extra); 991 sysfs_create_group(&serio->dev.kobj, &atkbd_attribute_group);
965 device_create_file(&serio->dev, &atkbd_attr_scroll);
966 device_create_file(&serio->dev, &atkbd_attr_set);
967 device_create_file(&serio->dev, &atkbd_attr_softrepeat);
968 device_create_file(&serio->dev, &atkbd_attr_softraw);
969 992
970 atkbd_enable(atkbd); 993 atkbd_enable(atkbd);
971 994
@@ -1259,6 +1282,11 @@ static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t co
1259 return count; 1282 return count;
1260} 1283}
1261 1284
1285static ssize_t atkbd_show_err_count(struct atkbd *atkbd, char *buf)
1286{
1287 return sprintf(buf, "%lu\n", atkbd->err_count);
1288}
1289
1262 1290
1263static int __init atkbd_init(void) 1291static int __init atkbd_init(void)
1264{ 1292{
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
index cb70970625b5..befdd6006b50 100644
--- a/drivers/input/keyboard/corgikbd.c
+++ b/drivers/input/keyboard/corgikbd.c
@@ -207,7 +207,7 @@ static irqreturn_t corgikbd_interrupt(int irq, void *dev_id)
207static void corgikbd_timer_callback(unsigned long data) 207static void corgikbd_timer_callback(unsigned long data)
208{ 208{
209 struct corgikbd *corgikbd_data = (struct corgikbd *) data; 209 struct corgikbd *corgikbd_data = (struct corgikbd *) data;
210 corgikbd_scankeyboard(corgikbd_data, NULL); 210 corgikbd_scankeyboard(corgikbd_data);
211} 211}
212 212
213/* 213/*
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c
index fd33c9cc3272..5788dbc317bb 100644
--- a/drivers/input/keyboard/locomokbd.c
+++ b/drivers/input/keyboard/locomokbd.c
@@ -186,7 +186,7 @@ static irqreturn_t locomokbd_interrupt(int irq, void *dev_id)
186static void locomokbd_timer_callback(unsigned long data) 186static void locomokbd_timer_callback(unsigned long data)
187{ 187{
188 struct locomokbd *locomokbd = (struct locomokbd *) data; 188 struct locomokbd *locomokbd = (struct locomokbd *) data;
189 locomokbd_scankeyboard(locomokbd, NULL); 189 locomokbd_scankeyboard(locomokbd);
190} 190}
191 191
192static int locomokbd_probe(struct locomo_dev *dev) 192static int locomokbd_probe(struct locomo_dev *dev)
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 8b18c009e3e0..28b2748e82d0 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -257,7 +257,7 @@ static void spitzkbd_timer_callback(unsigned long data)
257{ 257{
258 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data; 258 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data;
259 259
260 spitzkbd_scankeyboard(spitzkbd_data, NULL); 260 spitzkbd_scankeyboard(spitzkbd_data);
261} 261}
262 262
263/* 263/*
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 09b06e605b50..7e3141f37e32 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -106,6 +106,7 @@ static unsigned char i8042_ctr;
106static unsigned char i8042_mux_present; 106static unsigned char i8042_mux_present;
107static unsigned char i8042_kbd_irq_registered; 107static unsigned char i8042_kbd_irq_registered;
108static unsigned char i8042_aux_irq_registered; 108static unsigned char i8042_aux_irq_registered;
109static unsigned char i8042_suppress_kbd_ack;
109static struct platform_device *i8042_platform_device; 110static struct platform_device *i8042_platform_device;
110 111
111static irqreturn_t i8042_interrupt(int irq, void *dev_id); 112static irqreturn_t i8042_interrupt(int irq, void *dev_id);
@@ -316,7 +317,7 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id)
316 unsigned char str, data; 317 unsigned char str, data;
317 unsigned int dfl; 318 unsigned int dfl;
318 unsigned int port_no; 319 unsigned int port_no;
319 int ret; 320 int ret = 1;
320 321
321 spin_lock_irqsave(&i8042_lock, flags); 322 spin_lock_irqsave(&i8042_lock, flags);
322 str = i8042_read_status(); 323 str = i8042_read_status();
@@ -378,10 +379,16 @@ static irqreturn_t i8042_interrupt(int irq, void *dev_id)
378 dfl & SERIO_PARITY ? ", bad parity" : "", 379 dfl & SERIO_PARITY ? ", bad parity" : "",
379 dfl & SERIO_TIMEOUT ? ", timeout" : ""); 380 dfl & SERIO_TIMEOUT ? ", timeout" : "");
380 381
382 if (unlikely(i8042_suppress_kbd_ack))
383 if (port_no == I8042_KBD_PORT_NO &&
384 (data == 0xfa || data == 0xfe)) {
385 i8042_suppress_kbd_ack = 0;
386 goto out;
387 }
388
381 if (likely(port->exists)) 389 if (likely(port->exists))
382 serio_interrupt(port->serio, data, dfl); 390 serio_interrupt(port->serio, data, dfl);
383 391
384 ret = 1;
385 out: 392 out:
386 return IRQ_RETVAL(ret); 393 return IRQ_RETVAL(ret);
387} 394}
@@ -842,11 +849,13 @@ static long i8042_panic_blink(long count)
842 led ^= 0x01 | 0x04; 849 led ^= 0x01 | 0x04;
843 while (i8042_read_status() & I8042_STR_IBF) 850 while (i8042_read_status() & I8042_STR_IBF)
844 DELAY; 851 DELAY;
852 i8042_suppress_kbd_ack = 1;
845 i8042_write_data(0xed); /* set leds */ 853 i8042_write_data(0xed); /* set leds */
846 DELAY; 854 DELAY;
847 while (i8042_read_status() & I8042_STR_IBF) 855 while (i8042_read_status() & I8042_STR_IBF)
848 DELAY; 856 DELAY;
849 DELAY; 857 DELAY;
858 i8042_suppress_kbd_ack = 1;
850 i8042_write_data(led); 859 i8042_write_data(led);
851 DELAY; 860 DELAY;
852 last_blink = count; 861 last_blink = count;
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index dcb16b5cbec0..e5b1b60757bb 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -189,7 +189,7 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
189 return -1; 189 return -1;
190 } 190 }
191 191
192 mutex_lock_nested(&ps2dev->cmd_mutex, SINGLE_DEPTH_NESTING); 192 mutex_lock(&ps2dev->cmd_mutex);
193 193
194 serio_pause_rx(ps2dev->serio); 194 serio_pause_rx(ps2dev->serio);
195 ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0; 195 ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0;
@@ -296,6 +296,7 @@ EXPORT_SYMBOL(ps2_schedule_command);
296void ps2_init(struct ps2dev *ps2dev, struct serio *serio) 296void ps2_init(struct ps2dev *ps2dev, struct serio *serio)
297{ 297{
298 mutex_init(&ps2dev->cmd_mutex); 298 mutex_init(&ps2dev->cmd_mutex);
299 lockdep_set_subclass(&ps2dev->cmd_mutex, serio->depth);
299 init_waitqueue_head(&ps2dev->wait); 300 init_waitqueue_head(&ps2dev->wait);
300 ps2dev->serio = serio; 301 ps2dev->serio = serio;
301} 302}
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 960fae3c3cea..211943f85cb6 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -118,6 +118,8 @@ static int serio_match_port(const struct serio_device_id *ids, struct serio *ser
118 118
119static void serio_bind_driver(struct serio *serio, struct serio_driver *drv) 119static void serio_bind_driver(struct serio *serio, struct serio_driver *drv)
120{ 120{
121 int error;
122
121 down_write(&serio_bus.subsys.rwsem); 123 down_write(&serio_bus.subsys.rwsem);
122 124
123 if (serio_match_port(drv->id_table, serio)) { 125 if (serio_match_port(drv->id_table, serio)) {
@@ -126,9 +128,19 @@ static void serio_bind_driver(struct serio *serio, struct serio_driver *drv)
126 serio->dev.driver = NULL; 128 serio->dev.driver = NULL;
127 goto out; 129 goto out;
128 } 130 }
129 device_bind_driver(&serio->dev); 131 error = device_bind_driver(&serio->dev);
132 if (error) {
133 printk(KERN_WARNING
134 "serio: device_bind_driver() failed "
135 "for %s (%s) and %s, error: %d\n",
136 serio->phys, serio->name,
137 drv->description, error);
138 serio_disconnect_driver(serio);
139 serio->dev.driver = NULL;
140 goto out;
141 }
130 } 142 }
131out: 143 out:
132 up_write(&serio_bus.subsys.rwsem); 144 up_write(&serio_bus.subsys.rwsem);
133} 145}
134 146
@@ -538,8 +550,12 @@ static void serio_init_port(struct serio *serio)
538 "serio%ld", (long)atomic_inc_return(&serio_no) - 1); 550 "serio%ld", (long)atomic_inc_return(&serio_no) - 1);
539 serio->dev.bus = &serio_bus; 551 serio->dev.bus = &serio_bus;
540 serio->dev.release = serio_release_port; 552 serio->dev.release = serio_release_port;
541 if (serio->parent) 553 if (serio->parent) {
542 serio->dev.parent = &serio->parent->dev; 554 serio->dev.parent = &serio->parent->dev;
555 serio->depth = serio->parent->depth + 1;
556 } else
557 serio->depth = 0;
558 lockdep_set_subclass(&serio->lock, serio->depth);
543} 559}
544 560
545/* 561/*
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
index ca79b2246195..66121f6a89ad 100644
--- a/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -219,7 +219,7 @@ static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer)
219static void corgi_ts_timer(unsigned long data) 219static void corgi_ts_timer(unsigned long data)
220{ 220{
221 struct corgi_ts *corgits_data = (struct corgi_ts *) data; 221 struct corgi_ts *corgits_data = (struct corgi_ts *) data;
222 ts_interrupt_main(corgits_data, 1, NULL); 222 ts_interrupt_main(corgits_data, 1);
223} 223}
224 224
225static irqreturn_t ts_interrupt(int irq, void *dev_id) 225static irqreturn_t ts_interrupt(int irq, void *dev_id)
@@ -237,7 +237,7 @@ static int corgits_suspend(struct platform_device *dev, pm_message_t state)
237 if (corgi_ts->pendown) { 237 if (corgi_ts->pendown) {
238 del_timer_sync(&corgi_ts->timer); 238 del_timer_sync(&corgi_ts->timer);
239 corgi_ts->tc.pressure = 0; 239 corgi_ts->tc.pressure = 0;
240 new_data(corgi_ts, NULL); 240 new_data(corgi_ts);
241 corgi_ts->pendown = 0; 241 corgi_ts->pendown = 0;
242 } 242 }
243 corgi_ts->power_mode = PWR_MODE_SUSPEND; 243 corgi_ts->power_mode = PWR_MODE_SUSPEND;
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c
index d10c8b82e6aa..b6f9476c0501 100644
--- a/drivers/isdn/capi/capidrv.c
+++ b/drivers/isdn/capi/capidrv.c
@@ -1907,7 +1907,8 @@ static int if_readstat(u8 __user *buf, int len, int id, int channel)
1907 } 1907 }
1908 1908
1909 for (p=buf, count=0; count < len; p++, count++) { 1909 for (p=buf, count=0; count < len; p++, count++) {
1910 put_user(*card->q931_read++, p); 1910 if (put_user(*card->q931_read++, p))
1911 return -EFAULT;
1911 if (card->q931_read > card->q931_end) 1912 if (card->q931_read > card->q931_end)
1912 card->q931_read = card->q931_buf; 1913 card->q931_read = card->q931_buf;
1913 } 1914 }
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index e4823ab2b127..785b08554fca 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -631,7 +631,8 @@ static int HiSax_readstatus(u_char __user *buf, int len, int id, int channel)
631 count = cs->status_end - cs->status_read + 1; 631 count = cs->status_end - cs->status_read + 1;
632 if (count >= len) 632 if (count >= len)
633 count = len; 633 count = len;
634 copy_to_user(p, cs->status_read, count); 634 if (copy_to_user(p, cs->status_read, count))
635 return -EFAULT;
635 cs->status_read += count; 636 cs->status_read += count;
636 if (cs->status_read > cs->status_end) 637 if (cs->status_read > cs->status_end)
637 cs->status_read = cs->status_buf; 638 cs->status_read = cs->status_buf;
@@ -642,7 +643,8 @@ static int HiSax_readstatus(u_char __user *buf, int len, int id, int channel)
642 cnt = HISAX_STATUS_BUFSIZE; 643 cnt = HISAX_STATUS_BUFSIZE;
643 else 644 else
644 cnt = count; 645 cnt = count;
645 copy_to_user(p, cs->status_read, cnt); 646 if (copy_to_user(p, cs->status_read, cnt))
647 return -EFAULT;
646 p += cnt; 648 p += cnt;
647 cs->status_read += cnt % HISAX_STATUS_BUFSIZE; 649 cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
648 count -= cnt; 650 count -= cnt;
diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
index 7e95f04f13da..3dacfff93f5f 100644
--- a/drivers/isdn/hisax/diva.c
+++ b/drivers/isdn/hisax/diva.c
@@ -716,8 +716,10 @@ release_io_diva(struct IsdnCardState *cs)
716 716
717 *cfg = 0; /* disable INT0/1 */ 717 *cfg = 0; /* disable INT0/1 */
718 *cfg = 2; /* reset pending INT0 */ 718 *cfg = 2; /* reset pending INT0 */
719 iounmap((void *)cs->hw.diva.cfg_reg); 719 if (cs->hw.diva.cfg_reg)
720 iounmap((void *)cs->hw.diva.pci_cfg); 720 iounmap((void *)cs->hw.diva.cfg_reg);
721 if (cs->hw.diva.pci_cfg)
722 iounmap((void *)cs->hw.diva.pci_cfg);
721 return; 723 return;
722 } else if (cs->subtyp != DIVA_IPAC_ISA) { 724 } else if (cs->subtyp != DIVA_IPAC_ISA) {
723 del_timer(&cs->hw.diva.tl); 725 del_timer(&cs->hw.diva.tl);
@@ -734,6 +736,23 @@ release_io_diva(struct IsdnCardState *cs)
734} 736}
735 737
736static void 738static void
739iounmap_diva(struct IsdnCardState *cs)
740{
741 if ((cs->subtyp == DIVA_IPAC_PCI) || (cs->subtyp == DIVA_IPACX_PCI)) {
742 if (cs->hw.diva.cfg_reg) {
743 iounmap((void *)cs->hw.diva.cfg_reg);
744 cs->hw.diva.cfg_reg = 0;
745 }
746 if (cs->hw.diva.pci_cfg) {
747 iounmap((void *)cs->hw.diva.pci_cfg);
748 cs->hw.diva.pci_cfg = 0;
749 }
750 }
751
752 return;
753}
754
755static void
737reset_diva(struct IsdnCardState *cs) 756reset_diva(struct IsdnCardState *cs)
738{ 757{
739 if (cs->subtyp == DIVA_IPAC_ISA) { 758 if (cs->subtyp == DIVA_IPAC_ISA) {
@@ -1069,11 +1088,13 @@ setup_diva(struct IsdnCard *card)
1069 1088
1070 if (!cs->irq) { 1089 if (!cs->irq) {
1071 printk(KERN_WARNING "Diva: No IRQ for PCI card found\n"); 1090 printk(KERN_WARNING "Diva: No IRQ for PCI card found\n");
1091 iounmap_diva(cs);
1072 return(0); 1092 return(0);
1073 } 1093 }
1074 1094
1075 if (!cs->hw.diva.cfg_reg) { 1095 if (!cs->hw.diva.cfg_reg) {
1076 printk(KERN_WARNING "Diva: No IO-Adr for PCI card found\n"); 1096 printk(KERN_WARNING "Diva: No IO-Adr for PCI card found\n");
1097 iounmap_diva(cs);
1077 return(0); 1098 return(0);
1078 } 1099 }
1079 cs->irq_flags |= IRQF_SHARED; 1100 cs->irq_flags |= IRQF_SHARED;
@@ -1123,6 +1144,7 @@ ready:
1123 CardType[card->typ], 1144 CardType[card->typ],
1124 cs->hw.diva.cfg_reg, 1145 cs->hw.diva.cfg_reg,
1125 cs->hw.diva.cfg_reg + bytecnt); 1146 cs->hw.diva.cfg_reg + bytecnt);
1147 iounmap_diva(cs);
1126 return (0); 1148 return (0);
1127 } 1149 }
1128 } 1150 }
diff --git a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c
index 160f22fa5941..82e42a80dc4b 100644
--- a/drivers/isdn/hysdn/boardergo.c
+++ b/drivers/isdn/hysdn/boardergo.c
@@ -45,11 +45,10 @@ ergo_interrupt(int intno, void *dev_id)
45 if (!card->irq_enabled) 45 if (!card->irq_enabled)
46 return IRQ_NONE; /* other device interrupting or irq switched off */ 46 return IRQ_NONE; /* other device interrupting or irq switched off */
47 47
48 save_flags(flags); 48 spin_lock_irqsave(&card->hysdn_lock, flags); /* no further irqs allowed */
49 cli(); /* no further irqs allowed */
50 49
51 if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) { 50 if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) {
52 restore_flags(flags); /* restore old state */ 51 spin_unlock_irqrestore(&card->hysdn_lock, flags); /* restore old state */
53 return IRQ_NONE; /* no interrupt requested by E1 */ 52 return IRQ_NONE; /* no interrupt requested by E1 */
54 } 53 }
55 /* clear any pending ints on the board */ 54 /* clear any pending ints on the board */
@@ -61,7 +60,7 @@ ergo_interrupt(int intno, void *dev_id)
61 /* start kernel task immediately after leaving all interrupts */ 60 /* start kernel task immediately after leaving all interrupts */
62 if (!card->hw_lock) 61 if (!card->hw_lock)
63 schedule_work(&card->irq_queue); 62 schedule_work(&card->irq_queue);
64 restore_flags(flags); 63 spin_unlock_irqrestore(&card->hysdn_lock, flags);
65 return IRQ_HANDLED; 64 return IRQ_HANDLED;
66} /* ergo_interrupt */ 65} /* ergo_interrupt */
67 66
@@ -83,10 +82,9 @@ ergo_irq_bh(hysdn_card * card)
83 82
84 dpr = card->dpram; /* point to DPRAM */ 83 dpr = card->dpram; /* point to DPRAM */
85 84
86 save_flags(flags); 85 spin_lock_irqsave(&card->hysdn_lock, flags);
87 cli();
88 if (card->hw_lock) { 86 if (card->hw_lock) {
89 restore_flags(flags); /* hardware currently unavailable */ 87 spin_unlock_irqrestore(&card->hysdn_lock, flags); /* hardware currently unavailable */
90 return; 88 return;
91 } 89 }
92 card->hw_lock = 1; /* we now lock the hardware */ 90 card->hw_lock = 1; /* we now lock the hardware */
@@ -120,7 +118,7 @@ ergo_irq_bh(hysdn_card * card)
120 card->hw_lock = 0; /* free hardware again */ 118 card->hw_lock = 0; /* free hardware again */
121 } while (again); /* until nothing more to do */ 119 } while (again); /* until nothing more to do */
122 120
123 restore_flags(flags); 121 spin_unlock_irqrestore(&card->hysdn_lock, flags);
124} /* ergo_irq_bh */ 122} /* ergo_irq_bh */
125 123
126 124
@@ -137,8 +135,7 @@ ergo_stopcard(hysdn_card * card)
137#ifdef CONFIG_HYSDN_CAPI 135#ifdef CONFIG_HYSDN_CAPI
138 hycapi_capi_stop(card); 136 hycapi_capi_stop(card);
139#endif /* CONFIG_HYSDN_CAPI */ 137#endif /* CONFIG_HYSDN_CAPI */
140 save_flags(flags); 138 spin_lock_irqsave(&card->hysdn_lock, flags);
141 cli();
142 val = bytein(card->iobase + PCI9050_INTR_REG); /* get actual value */ 139 val = bytein(card->iobase + PCI9050_INTR_REG); /* get actual value */
143 val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1); /* mask irq */ 140 val &= ~(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1); /* mask irq */
144 byteout(card->iobase + PCI9050_INTR_REG, val); 141 byteout(card->iobase + PCI9050_INTR_REG, val);
@@ -147,7 +144,7 @@ ergo_stopcard(hysdn_card * card)
147 card->state = CARD_STATE_UNUSED; 144 card->state = CARD_STATE_UNUSED;
148 card->err_log_state = ERRLOG_STATE_OFF; /* currently no log active */ 145 card->err_log_state = ERRLOG_STATE_OFF; /* currently no log active */
149 146
150 restore_flags(flags); 147 spin_unlock_irqrestore(&card->hysdn_lock, flags);
151} /* ergo_stopcard */ 148} /* ergo_stopcard */
152 149
153/**************************************************************************/ 150/**************************************************************************/
@@ -162,12 +159,11 @@ ergo_set_errlog_state(hysdn_card * card, int on)
162 card->err_log_state = ERRLOG_STATE_OFF; /* must be off */ 159 card->err_log_state = ERRLOG_STATE_OFF; /* must be off */
163 return; 160 return;
164 } 161 }
165 save_flags(flags); 162 spin_lock_irqsave(&card->hysdn_lock, flags);
166 cli();
167 163
168 if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) || 164 if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) ||
169 ((card->err_log_state == ERRLOG_STATE_ON) && on)) { 165 ((card->err_log_state == ERRLOG_STATE_ON) && on)) {
170 restore_flags(flags); 166 spin_unlock_irqrestore(&card->hysdn_lock, flags);
171 return; /* nothing to do */ 167 return; /* nothing to do */
172 } 168 }
173 if (on) 169 if (on)
@@ -175,7 +171,7 @@ ergo_set_errlog_state(hysdn_card * card, int on)
175 else 171 else
176 card->err_log_state = ERRLOG_STATE_STOP; /* request stop */ 172 card->err_log_state = ERRLOG_STATE_STOP; /* request stop */
177 173
178 restore_flags(flags); 174 spin_unlock_irqrestore(&card->hysdn_lock, flags);
179 schedule_work(&card->irq_queue); 175 schedule_work(&card->irq_queue);
180} /* ergo_set_errlog_state */ 176} /* ergo_set_errlog_state */
181 177
@@ -356,8 +352,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
356 352
357 if (card->debug_flags & LOG_POF_RECORD) 353 if (card->debug_flags & LOG_POF_RECORD)
358 hysdn_addlog(card, "ERGO: pof boot success"); 354 hysdn_addlog(card, "ERGO: pof boot success");
359 save_flags(flags); 355 spin_lock_irqsave(&card->hysdn_lock, flags);
360 cli();
361 356
362 card->state = CARD_STATE_RUN; /* now card is running */ 357 card->state = CARD_STATE_RUN; /* now card is running */
363 /* enable the cards interrupt */ 358 /* enable the cards interrupt */
@@ -370,7 +365,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
370 dpr->ToHyInt = 1; 365 dpr->ToHyInt = 1;
371 dpr->ToPcInt = 1; /* interrupt to E1 for all cards */ 366 dpr->ToPcInt = 1; /* interrupt to E1 for all cards */
372 367
373 restore_flags(flags); 368 spin_unlock_irqrestore(&card->hysdn_lock, flags);
374 if ((hynet_enable & (1 << card->myid)) 369 if ((hynet_enable & (1 << card->myid))
375 && (i = hysdn_net_create(card))) 370 && (i = hysdn_net_create(card)))
376 { 371 {
@@ -408,7 +403,7 @@ ergo_releasehardware(hysdn_card * card)
408 free_irq(card->irq, card); /* release interrupt */ 403 free_irq(card->irq, card); /* release interrupt */
409 release_region(card->iobase + PCI9050_INTR_REG, 1); /* release all io ports */ 404 release_region(card->iobase + PCI9050_INTR_REG, 1); /* release all io ports */
410 release_region(card->iobase + PCI9050_USER_IO, 1); 405 release_region(card->iobase + PCI9050_USER_IO, 1);
411 vfree(card->dpram); 406 iounmap(card->dpram);
412 card->dpram = NULL; /* release shared mem */ 407 card->dpram = NULL; /* release shared mem */
413} /* ergo_releasehardware */ 408} /* ergo_releasehardware */
414 409
@@ -448,6 +443,7 @@ ergo_inithardware(hysdn_card * card)
448 card->waitpofready = ergo_waitpofready; 443 card->waitpofready = ergo_waitpofready;
449 card->set_errlog_state = ergo_set_errlog_state; 444 card->set_errlog_state = ergo_set_errlog_state;
450 INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card); 445 INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card);
446 card->hysdn_lock = SPIN_LOCK_UNLOCKED;
451 447
452 return (0); 448 return (0);
453} /* ergo_inithardware */ 449} /* ergo_inithardware */
diff --git a/drivers/isdn/hysdn/hysdn_defs.h b/drivers/isdn/hysdn/hysdn_defs.h
index 461e831592dd..729df4089385 100644
--- a/drivers/isdn/hysdn/hysdn_defs.h
+++ b/drivers/isdn/hysdn/hysdn_defs.h
@@ -188,6 +188,8 @@ typedef struct HYSDN_CARD {
188 /* init and deinit stopcard for booting, too */ 188 /* init and deinit stopcard for booting, too */
189 void (*stopcard) (struct HYSDN_CARD *); 189 void (*stopcard) (struct HYSDN_CARD *);
190 void (*releasehardware) (struct HYSDN_CARD *); 190 void (*releasehardware) (struct HYSDN_CARD *);
191
192 spinlock_t hysdn_lock;
191#ifdef CONFIG_HYSDN_CAPI 193#ifdef CONFIG_HYSDN_CAPI
192 struct hycapictrl_info { 194 struct hycapictrl_info {
193 char cardname[32]; 195 char cardname[32];
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index c4301e8338ef..fcd49920b220 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -116,8 +116,7 @@ put_log_buffer(hysdn_card * card, char *cp)
116 strcpy(ib->log_start, cp); /* set output string */ 116 strcpy(ib->log_start, cp); /* set output string */
117 ib->next = NULL; 117 ib->next = NULL;
118 ib->proc_ctrl = pd; /* point to own control structure */ 118 ib->proc_ctrl = pd; /* point to own control structure */
119 save_flags(flags); 119 spin_lock_irqsave(&card->hysdn_lock, flags);
120 cli();
121 ib->usage_cnt = pd->if_used; 120 ib->usage_cnt = pd->if_used;
122 if (!pd->log_head) 121 if (!pd->log_head)
123 pd->log_head = ib; /* new head */ 122 pd->log_head = ib; /* new head */
@@ -125,7 +124,7 @@ put_log_buffer(hysdn_card * card, char *cp)
125 pd->log_tail->next = ib; /* follows existing messages */ 124 pd->log_tail->next = ib; /* follows existing messages */
126 pd->log_tail = ib; /* new tail */ 125 pd->log_tail = ib; /* new tail */
127 i = pd->del_lock++; /* get lock state */ 126 i = pd->del_lock++; /* get lock state */
128 restore_flags(flags); 127 spin_unlock_irqrestore(&card->hysdn_lock, flags);
129 128
130 /* delete old entrys */ 129 /* delete old entrys */
131 if (!i) 130 if (!i)
@@ -270,14 +269,13 @@ hysdn_log_open(struct inode *ino, struct file *filep)
270 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { 269 } else if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
271 270
272 /* read access -> log/debug read */ 271 /* read access -> log/debug read */
273 save_flags(flags); 272 spin_lock_irqsave(&card->hysdn_lock, flags);
274 cli();
275 pd->if_used++; 273 pd->if_used++;
276 if (pd->log_head) 274 if (pd->log_head)
277 filep->private_data = &pd->log_tail->next; 275 filep->private_data = &pd->log_tail->next;
278 else 276 else
279 filep->private_data = &pd->log_head; 277 filep->private_data = &pd->log_head;
280 restore_flags(flags); 278 spin_unlock_irqrestore(&card->hysdn_lock, flags);
281 } else { /* simultaneous read/write access forbidden ! */ 279 } else { /* simultaneous read/write access forbidden ! */
282 unlock_kernel(); 280 unlock_kernel();
283 return (-EPERM); /* no permission this time */ 281 return (-EPERM); /* no permission this time */
@@ -301,7 +299,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
301 hysdn_card *card; 299 hysdn_card *card;
302 int retval = 0; 300 int retval = 0;
303 unsigned long flags; 301 unsigned long flags;
304 302 spinlock_t hysdn_lock = SPIN_LOCK_UNLOCKED;
305 303
306 lock_kernel(); 304 lock_kernel();
307 if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) { 305 if ((filep->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_WRITE) {
@@ -311,8 +309,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
311 /* read access -> log/debug read, mark one further file as closed */ 309 /* read access -> log/debug read, mark one further file as closed */
312 310
313 pd = NULL; 311 pd = NULL;
314 save_flags(flags); 312 spin_lock_irqsave(&hysdn_lock, flags);
315 cli();
316 inf = *((struct log_data **) filep->private_data); /* get first log entry */ 313 inf = *((struct log_data **) filep->private_data); /* get first log entry */
317 if (inf) 314 if (inf)
318 pd = (struct procdata *) inf->proc_ctrl; /* still entries there */ 315 pd = (struct procdata *) inf->proc_ctrl; /* still entries there */
@@ -335,7 +332,7 @@ hysdn_log_close(struct inode *ino, struct file *filep)
335 inf->usage_cnt--; /* decrement usage count for buffers */ 332 inf->usage_cnt--; /* decrement usage count for buffers */
336 inf = inf->next; 333 inf = inf->next;
337 } 334 }
338 restore_flags(flags); 335 spin_unlock_irqrestore(&hysdn_lock, flags);
339 336
340 if (pd) 337 if (pd)
341 if (pd->if_used <= 0) /* delete buffers if last file closed */ 338 if (pd->if_used <= 0) /* delete buffers if last file closed */
diff --git a/drivers/isdn/hysdn/hysdn_sched.c b/drivers/isdn/hysdn/hysdn_sched.c
index 1c0d54ac12ab..1fadf0133e9b 100644
--- a/drivers/isdn/hysdn/hysdn_sched.c
+++ b/drivers/isdn/hysdn/hysdn_sched.c
@@ -155,8 +155,7 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
155 if (card->debug_flags & LOG_SCHED_ASYN) 155 if (card->debug_flags & LOG_SCHED_ASYN)
156 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1); 156 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1);
157 157
158 save_flags(flags); 158 spin_lock_irqsave(&card->hysdn_lock, flags);
159 cli();
160 while (card->async_busy) { 159 while (card->async_busy) {
161 sti(); 160 sti();
162 161
@@ -165,7 +164,7 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
165 164
166 msleep_interruptible(20); /* Timeout 20ms */ 165 msleep_interruptible(20); /* Timeout 20ms */
167 if (!--cnt) { 166 if (!--cnt) {
168 restore_flags(flags); 167 spin_unlock_irqrestore(&card->hysdn_lock, flags);
169 return (-ERR_ASYNC_TIME); /* timed out */ 168 return (-ERR_ASYNC_TIME); /* timed out */
170 } 169 }
171 cli(); 170 cli();
@@ -194,13 +193,13 @@ hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
194 193
195 msleep_interruptible(20); /* Timeout 20ms */ 194 msleep_interruptible(20); /* Timeout 20ms */
196 if (!--cnt) { 195 if (!--cnt) {
197 restore_flags(flags); 196 spin_unlock_irqrestore(&card->hysdn_lock, flags);
198 return (-ERR_ASYNC_TIME); /* timed out */ 197 return (-ERR_ASYNC_TIME); /* timed out */
199 } 198 }
200 cli(); 199 cli();
201 } /* wait for buffer to become free again */ 200 } /* wait for buffer to become free again */
202 201
203 restore_flags(flags); 202 spin_unlock_irqrestore(&card->hysdn_lock, flags);
204 203
205 if (card->debug_flags & LOG_SCHED_ASYN) 204 if (card->debug_flags & LOG_SCHED_ASYN)
206 hysdn_addlog(card, "async tx-cfg data send"); 205 hysdn_addlog(card, "async tx-cfg data send");
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index c3d79eef9e32..69aee2602aa6 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1134,9 +1134,12 @@ isdn_read(struct file *file, char __user *buf, size_t count, loff_t * off)
1134 if (dev->drv[drvidx]->interface->readstat) { 1134 if (dev->drv[drvidx]->interface->readstat) {
1135 if (count > dev->drv[drvidx]->stavail) 1135 if (count > dev->drv[drvidx]->stavail)
1136 count = dev->drv[drvidx]->stavail; 1136 count = dev->drv[drvidx]->stavail;
1137 len = dev->drv[drvidx]->interface-> 1137 len = dev->drv[drvidx]->interface->readstat(buf, count,
1138 readstat(buf, count, drvidx, 1138 drvidx, isdn_minor2chan(minor));
1139 isdn_minor2chan(minor)); 1139 if (len < 0) {
1140 retval = len;
1141 goto out;
1142 }
1140 } else { 1143 } else {
1141 len = 0; 1144 len = 0;
1142 } 1145 }
diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
index 6649f8bc9951..730bbd07ebc7 100644
--- a/drivers/isdn/icn/icn.c
+++ b/drivers/isdn/icn/icn.c
@@ -1010,7 +1010,8 @@ icn_readstatus(u_char __user *buf, int len, icn_card * card)
1010 for (p = buf, count = 0; count < len; p++, count++) { 1010 for (p = buf, count = 0; count < len; p++, count++) {
1011 if (card->msg_buf_read == card->msg_buf_write) 1011 if (card->msg_buf_read == card->msg_buf_write)
1012 return count; 1012 return count;
1013 put_user(*card->msg_buf_read++, p); 1013 if (put_user(*card->msg_buf_read++, p))
1014 return -EFAULT;
1014 if (card->msg_buf_read > card->msg_buf_end) 1015 if (card->msg_buf_read > card->msg_buf_end)
1015 card->msg_buf_read = card->msg_buf; 1016 card->msg_buf_read = card->msg_buf;
1016 } 1017 }
diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
index fabbd461603e..c3ae2edaf6fa 100644
--- a/drivers/isdn/isdnloop/isdnloop.c
+++ b/drivers/isdn/isdnloop/isdnloop.c
@@ -100,12 +100,11 @@ isdnloop_pollbchan(unsigned long data)
100 isdnloop_bchan_send(card, 1); 100 isdnloop_bchan_send(card, 1);
101 if (card->flags & (ISDNLOOP_FLAGS_B1ACTIVE | ISDNLOOP_FLAGS_B2ACTIVE)) { 101 if (card->flags & (ISDNLOOP_FLAGS_B1ACTIVE | ISDNLOOP_FLAGS_B2ACTIVE)) {
102 /* schedule b-channel polling again */ 102 /* schedule b-channel polling again */
103 save_flags(flags); 103 spin_lock_irqsave(&card->isdnloop_lock, flags);
104 cli();
105 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD; 104 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD;
106 add_timer(&card->rb_timer); 105 add_timer(&card->rb_timer);
107 card->flags |= ISDNLOOP_FLAGS_RBTIMER; 106 card->flags |= ISDNLOOP_FLAGS_RBTIMER;
108 restore_flags(flags); 107 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
109 } else 108 } else
110 card->flags &= ~ISDNLOOP_FLAGS_RBTIMER; 109 card->flags &= ~ISDNLOOP_FLAGS_RBTIMER;
111} 110}
@@ -281,8 +280,7 @@ isdnloop_putmsg(isdnloop_card * card, unsigned char c)
281{ 280{
282 ulong flags; 281 ulong flags;
283 282
284 save_flags(flags); 283 spin_lock_irqsave(&card->isdnloop_lock, flags);
285 cli();
286 *card->msg_buf_write++ = (c == 0xff) ? '\n' : c; 284 *card->msg_buf_write++ = (c == 0xff) ? '\n' : c;
287 if (card->msg_buf_write == card->msg_buf_read) { 285 if (card->msg_buf_write == card->msg_buf_read) {
288 if (++card->msg_buf_read > card->msg_buf_end) 286 if (++card->msg_buf_read > card->msg_buf_end)
@@ -290,7 +288,7 @@ isdnloop_putmsg(isdnloop_card * card, unsigned char c)
290 } 288 }
291 if (card->msg_buf_write > card->msg_buf_end) 289 if (card->msg_buf_write > card->msg_buf_end)
292 card->msg_buf_write = card->msg_buf; 290 card->msg_buf_write = card->msg_buf;
293 restore_flags(flags); 291 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
294} 292}
295 293
296/* 294/*
@@ -372,21 +370,19 @@ isdnloop_polldchan(unsigned long data)
372 if (!(card->flags & ISDNLOOP_FLAGS_RBTIMER)) { 370 if (!(card->flags & ISDNLOOP_FLAGS_RBTIMER)) {
373 /* schedule b-channel polling */ 371 /* schedule b-channel polling */
374 card->flags |= ISDNLOOP_FLAGS_RBTIMER; 372 card->flags |= ISDNLOOP_FLAGS_RBTIMER;
375 save_flags(flags); 373 spin_lock_irqsave(&card->isdnloop_lock, flags);
376 cli();
377 del_timer(&card->rb_timer); 374 del_timer(&card->rb_timer);
378 card->rb_timer.function = isdnloop_pollbchan; 375 card->rb_timer.function = isdnloop_pollbchan;
379 card->rb_timer.data = (unsigned long) card; 376 card->rb_timer.data = (unsigned long) card;
380 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD; 377 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD;
381 add_timer(&card->rb_timer); 378 add_timer(&card->rb_timer);
382 restore_flags(flags); 379 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
383 } 380 }
384 /* schedule again */ 381 /* schedule again */
385 save_flags(flags); 382 spin_lock_irqsave(&card->isdnloop_lock, flags);
386 cli();
387 card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD; 383 card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD;
388 add_timer(&card->st_timer); 384 add_timer(&card->st_timer);
389 restore_flags(flags); 385 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
390} 386}
391 387
392/* 388/*
@@ -416,8 +412,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card)
416 return 0; 412 return 0;
417 if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE) 413 if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE)
418 return 0; 414 return 0;
419 save_flags(flags); 415 spin_lock_irqsave(&card->isdnloop_lock, flags);
420 cli();
421 nskb = dev_alloc_skb(skb->len); 416 nskb = dev_alloc_skb(skb->len);
422 if (nskb) { 417 if (nskb) {
423 memcpy(skb_put(nskb, len), skb->data, len); 418 memcpy(skb_put(nskb, len), skb->data, len);
@@ -426,7 +421,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card)
426 } else 421 } else
427 len = 0; 422 len = 0;
428 card->sndcount[channel] += len; 423 card->sndcount[channel] += len;
429 restore_flags(flags); 424 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
430 } 425 }
431 return len; 426 return len;
432} 427}
@@ -451,7 +446,8 @@ isdnloop_readstatus(u_char __user *buf, int len, isdnloop_card * card)
451 for (p = buf, count = 0; count < len; p++, count++) { 446 for (p = buf, count = 0; count < len; p++, count++) {
452 if (card->msg_buf_read == card->msg_buf_write) 447 if (card->msg_buf_read == card->msg_buf_write)
453 return count; 448 return count;
454 put_user(*card->msg_buf_read++, p); 449 if (put_user(*card->msg_buf_read++, p))
450 return -EFAULT;
455 if (card->msg_buf_read > card->msg_buf_end) 451 if (card->msg_buf_read > card->msg_buf_end)
456 card->msg_buf_read = card->msg_buf; 452 card->msg_buf_read = card->msg_buf;
457 } 453 }
@@ -576,8 +572,7 @@ isdnloop_atimeout(isdnloop_card * card, int ch)
576 unsigned long flags; 572 unsigned long flags;
577 char buf[60]; 573 char buf[60];
578 574
579 save_flags(flags); 575 spin_lock_irqsave(&card->isdnloop_lock, flags);
580 cli();
581 if (card->rcard) { 576 if (card->rcard) {
582 isdnloop_fake(card->rcard[ch], "DDIS_I", card->rch[ch] + 1); 577 isdnloop_fake(card->rcard[ch], "DDIS_I", card->rch[ch] + 1);
583 card->rcard[ch]->rcard[card->rch[ch]] = NULL; 578 card->rcard[ch]->rcard[card->rch[ch]] = NULL;
@@ -587,7 +582,7 @@ isdnloop_atimeout(isdnloop_card * card, int ch)
587 /* No user responding */ 582 /* No user responding */
588 sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 3)); 583 sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 3));
589 isdnloop_fake(card, buf, ch + 1); 584 isdnloop_fake(card, buf, ch + 1);
590 restore_flags(flags); 585 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
591} 586}
592 587
593/* 588/*
@@ -622,8 +617,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch)
622{ 617{
623 unsigned long flags; 618 unsigned long flags;
624 619
625 save_flags(flags); 620 spin_lock_irqsave(&card->isdnloop_lock, flags);
626 cli();
627 init_timer(&card->c_timer[ch]); 621 init_timer(&card->c_timer[ch]);
628 card->c_timer[ch].expires = jiffies + ISDNLOOP_TIMER_ALERTWAIT; 622 card->c_timer[ch].expires = jiffies + ISDNLOOP_TIMER_ALERTWAIT;
629 if (ch) 623 if (ch)
@@ -632,7 +626,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch)
632 card->c_timer[ch].function = isdnloop_atimeout0; 626 card->c_timer[ch].function = isdnloop_atimeout0;
633 card->c_timer[ch].data = (unsigned long) card; 627 card->c_timer[ch].data = (unsigned long) card;
634 add_timer(&card->c_timer[ch]); 628 add_timer(&card->c_timer[ch]);
635 restore_flags(flags); 629 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
636} 630}
637 631
638/* 632/*
@@ -647,10 +641,9 @@ isdnloop_kill_ctimer(isdnloop_card * card, int ch)
647{ 641{
648 unsigned long flags; 642 unsigned long flags;
649 643
650 save_flags(flags); 644 spin_lock_irqsave(&card->isdnloop_lock, flags);
651 cli();
652 del_timer(&card->c_timer[ch]); 645 del_timer(&card->c_timer[ch]);
653 restore_flags(flags); 646 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
654} 647}
655 648
656static u_char si2bit[] = 649static u_char si2bit[] =
@@ -706,13 +699,12 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd)
706 } 699 }
707 } 700 }
708 if (num_match) { 701 if (num_match) {
709 save_flags(flags); 702 spin_lock_irqsave(&card->isdnloop_lock, flags);
710 cli();
711 /* channel idle? */ 703 /* channel idle? */
712 if (!(cc->rcard[ch])) { 704 if (!(cc->rcard[ch])) {
713 /* Check SI */ 705 /* Check SI */
714 if (!(si2bit[cmd->parm.setup.si1] & cc->sil[ch])) { 706 if (!(si2bit[cmd->parm.setup.si1] & cc->sil[ch])) {
715 restore_flags(flags); 707 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
716 return 3; 708 return 3;
717 } 709 }
718 /* ch is idle, si and number matches */ 710 /* ch is idle, si and number matches */
@@ -720,10 +712,10 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd)
720 cc->rch[ch] = lch; 712 cc->rch[ch] = lch;
721 card->rcard[lch] = cc; 713 card->rcard[lch] = cc;
722 card->rch[lch] = ch; 714 card->rch[lch] = ch;
723 restore_flags(flags); 715 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
724 return 0; 716 return 0;
725 } else { 717 } else {
726 restore_flags(flags); 718 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
727 /* num matches, but busy */ 719 /* num matches, but busy */
728 if (ch == 1) 720 if (ch == 1)
729 return 1; 721 return 1;
@@ -1027,8 +1019,7 @@ isdnloop_stopcard(isdnloop_card * card)
1027 unsigned long flags; 1019 unsigned long flags;
1028 isdn_ctrl cmd; 1020 isdn_ctrl cmd;
1029 1021
1030 save_flags(flags); 1022 spin_lock_irqsave(&card->isdnloop_lock, flags);
1031 cli();
1032 if (card->flags & ISDNLOOP_FLAGS_RUNNING) { 1023 if (card->flags & ISDNLOOP_FLAGS_RUNNING) {
1033 card->flags &= ~ISDNLOOP_FLAGS_RUNNING; 1024 card->flags &= ~ISDNLOOP_FLAGS_RUNNING;
1034 del_timer(&card->st_timer); 1025 del_timer(&card->st_timer);
@@ -1039,7 +1030,7 @@ isdnloop_stopcard(isdnloop_card * card)
1039 cmd.driver = card->myid; 1030 cmd.driver = card->myid;
1040 card->interface.statcallb(&cmd); 1031 card->interface.statcallb(&cmd);
1041 } 1032 }
1042 restore_flags(flags); 1033 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1043} 1034}
1044 1035
1045/* 1036/*
@@ -1078,18 +1069,17 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1078 return -EBUSY; 1069 return -EBUSY;
1079 if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef))) 1070 if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef)))
1080 return -EFAULT; 1071 return -EFAULT;
1081 save_flags(flags); 1072 spin_lock_irqsave(&card->isdnloop_lock, flags);
1082 cli();
1083 switch (sdef.ptype) { 1073 switch (sdef.ptype) {
1084 case ISDN_PTYPE_EURO: 1074 case ISDN_PTYPE_EURO:
1085 if (isdnloop_fake(card, "DRV1.23EC-Q.931-CAPI-CNS-BASIS-20.02.96", 1075 if (isdnloop_fake(card, "DRV1.23EC-Q.931-CAPI-CNS-BASIS-20.02.96",
1086 -1)) { 1076 -1)) {
1087 restore_flags(flags); 1077 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1088 return -ENOMEM; 1078 return -ENOMEM;
1089 } 1079 }
1090 card->sil[0] = card->sil[1] = 4; 1080 card->sil[0] = card->sil[1] = 4;
1091 if (isdnloop_fake(card, "TEI OK", 0)) { 1081 if (isdnloop_fake(card, "TEI OK", 0)) {
1092 restore_flags(flags); 1082 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1093 return -ENOMEM; 1083 return -ENOMEM;
1094 } 1084 }
1095 for (i = 0; i < 3; i++) 1085 for (i = 0; i < 3; i++)
@@ -1098,12 +1088,12 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1098 case ISDN_PTYPE_1TR6: 1088 case ISDN_PTYPE_1TR6:
1099 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95", 1089 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
1100 -1)) { 1090 -1)) {
1101 restore_flags(flags); 1091 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1102 return -ENOMEM; 1092 return -ENOMEM;
1103 } 1093 }
1104 card->sil[0] = card->sil[1] = 4; 1094 card->sil[0] = card->sil[1] = 4;
1105 if (isdnloop_fake(card, "TEI OK", 0)) { 1095 if (isdnloop_fake(card, "TEI OK", 0)) {
1106 restore_flags(flags); 1096 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1107 return -ENOMEM; 1097 return -ENOMEM;
1108 } 1098 }
1109 strcpy(card->s0num[0], sdef.num[0]); 1099 strcpy(card->s0num[0], sdef.num[0]);
@@ -1111,7 +1101,7 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1111 card->s0num[2][0] = '\0'; 1101 card->s0num[2][0] = '\0';
1112 break; 1102 break;
1113 default: 1103 default:
1114 restore_flags(flags); 1104 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1115 printk(KERN_WARNING "isdnloop: Illegal D-channel protocol %d\n", 1105 printk(KERN_WARNING "isdnloop: Illegal D-channel protocol %d\n",
1116 sdef.ptype); 1106 sdef.ptype);
1117 return -EINVAL; 1107 return -EINVAL;
@@ -1122,7 +1112,7 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
1122 card->st_timer.data = (unsigned long) card; 1112 card->st_timer.data = (unsigned long) card;
1123 add_timer(&card->st_timer); 1113 add_timer(&card->st_timer);
1124 card->flags |= ISDNLOOP_FLAGS_RUNNING; 1114 card->flags |= ISDNLOOP_FLAGS_RUNNING;
1125 restore_flags(flags); 1115 spin_unlock_irqrestore(&card->isdnloop_lock, flags);
1126 return 0; 1116 return 0;
1127} 1117}
1128 1118
@@ -1472,6 +1462,7 @@ isdnloop_initcard(char *id)
1472 skb_queue_head_init(&card->bqueue[i]); 1462 skb_queue_head_init(&card->bqueue[i]);
1473 } 1463 }
1474 skb_queue_head_init(&card->dqueue); 1464 skb_queue_head_init(&card->dqueue);
1465 card->isdnloop_lock = SPIN_LOCK_UNLOCKED;
1475 card->next = cards; 1466 card->next = cards;
1476 cards = card; 1467 cards = card;
1477 if (!register_isdn(&card->interface)) { 1468 if (!register_isdn(&card->interface)) {
diff --git a/drivers/isdn/isdnloop/isdnloop.h b/drivers/isdn/isdnloop/isdnloop.h
index d699fe53e1c3..0d458a86f529 100644
--- a/drivers/isdn/isdnloop/isdnloop.h
+++ b/drivers/isdn/isdnloop/isdnloop.h
@@ -94,6 +94,7 @@ typedef struct isdnloop_card {
94 struct sk_buff_head 94 struct sk_buff_head
95 bqueue[ISDNLOOP_BCH]; /* B-Channel queues */ 95 bqueue[ISDNLOOP_BCH]; /* B-Channel queues */
96 struct sk_buff_head dqueue; /* D-Channel queue */ 96 struct sk_buff_head dqueue; /* D-Channel queue */
97 spinlock_t isdnloop_lock;
97} isdnloop_card; 98} isdnloop_card;
98 99
99/* 100/*
diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c
index 94f21486bb24..6ead5e1508b7 100644
--- a/drivers/isdn/pcbit/drv.c
+++ b/drivers/isdn/pcbit/drv.c
@@ -725,23 +725,27 @@ static int pcbit_stat(u_char __user *buf, int len, int driver, int channel)
725 725
726 if (stat_st < stat_end) 726 if (stat_st < stat_end)
727 { 727 {
728 copy_to_user(buf, statbuf + stat_st, len); 728 if (copy_to_user(buf, statbuf + stat_st, len))
729 return -EFAULT;
729 stat_st += len; 730 stat_st += len;
730 } 731 }
731 else 732 else
732 { 733 {
733 if (len > STATBUF_LEN - stat_st) 734 if (len > STATBUF_LEN - stat_st)
734 { 735 {
735 copy_to_user(buf, statbuf + stat_st, 736 if (copy_to_user(buf, statbuf + stat_st,
736 STATBUF_LEN - stat_st); 737 STATBUF_LEN - stat_st))
737 copy_to_user(buf, statbuf, 738 return -EFAULT;
738 len - (STATBUF_LEN - stat_st)); 739 if (copy_to_user(buf, statbuf,
740 len - (STATBUF_LEN - stat_st)))
741 return -EFAULT;
739 742
740 stat_st = len - (STATBUF_LEN - stat_st); 743 stat_st = len - (STATBUF_LEN - stat_st);
741 } 744 }
742 else 745 else
743 { 746 {
744 copy_to_user(buf, statbuf + stat_st, len); 747 if (copy_to_user(buf, statbuf + stat_st, len))
748 return -EFAULT;
745 749
746 stat_st += len; 750 stat_st += len;
747 751
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index aecbbe2e89a9..3c1711210e38 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -91,6 +91,8 @@ EXPORT_SYMBOL_GPL(led_classdev_resume);
91 */ 91 */
92int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) 92int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
93{ 93{
94 int rc;
95
94 led_cdev->class_dev = class_device_create(leds_class, NULL, 0, 96 led_cdev->class_dev = class_device_create(leds_class, NULL, 0,
95 parent, "%s", led_cdev->name); 97 parent, "%s", led_cdev->name);
96 if (unlikely(IS_ERR(led_cdev->class_dev))) 98 if (unlikely(IS_ERR(led_cdev->class_dev)))
@@ -99,8 +101,10 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
99 class_set_devdata(led_cdev->class_dev, led_cdev); 101 class_set_devdata(led_cdev->class_dev, led_cdev);
100 102
101 /* register the attributes */ 103 /* register the attributes */
102 class_device_create_file(led_cdev->class_dev, 104 rc = class_device_create_file(led_cdev->class_dev,
103 &class_device_attr_brightness); 105 &class_device_attr_brightness);
106 if (rc)
107 goto err_out;
104 108
105 /* add to the list of leds */ 109 /* add to the list of leds */
106 write_lock(&leds_list_lock); 110 write_lock(&leds_list_lock);
@@ -110,16 +114,28 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
110#ifdef CONFIG_LEDS_TRIGGERS 114#ifdef CONFIG_LEDS_TRIGGERS
111 rwlock_init(&led_cdev->trigger_lock); 115 rwlock_init(&led_cdev->trigger_lock);
112 116
113 led_trigger_set_default(led_cdev); 117 rc = class_device_create_file(led_cdev->class_dev,
118 &class_device_attr_trigger);
119 if (rc)
120 goto err_out_led_list;
114 121
115 class_device_create_file(led_cdev->class_dev, 122 led_trigger_set_default(led_cdev);
116 &class_device_attr_trigger);
117#endif 123#endif
118 124
119 printk(KERN_INFO "Registered led device: %s\n", 125 printk(KERN_INFO "Registered led device: %s\n",
120 led_cdev->class_dev->class_id); 126 led_cdev->class_dev->class_id);
121 127
122 return 0; 128 return 0;
129
130#ifdef CONFIG_LEDS_TRIGGERS
131err_out_led_list:
132 class_device_remove_file(led_cdev->class_dev,
133 &class_device_attr_brightness);
134 list_del(&led_cdev->node);
135#endif
136err_out:
137 class_device_unregister(led_cdev->class_dev);
138 return rc;
123} 139}
124EXPORT_SYMBOL_GPL(led_classdev_register); 140EXPORT_SYMBOL_GPL(led_classdev_register);
125 141
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index 179c2876b541..29a8818a32ec 100644
--- a/drivers/leds/ledtrig-timer.c
+++ b/drivers/leds/ledtrig-timer.c
@@ -123,6 +123,7 @@ static CLASS_DEVICE_ATTR(delay_off, 0644, led_delay_off_show,
123static void timer_trig_activate(struct led_classdev *led_cdev) 123static void timer_trig_activate(struct led_classdev *led_cdev)
124{ 124{
125 struct timer_trig_data *timer_data; 125 struct timer_trig_data *timer_data;
126 int rc;
126 127
127 timer_data = kzalloc(sizeof(struct timer_trig_data), GFP_KERNEL); 128 timer_data = kzalloc(sizeof(struct timer_trig_data), GFP_KERNEL);
128 if (!timer_data) 129 if (!timer_data)
@@ -134,10 +135,21 @@ static void timer_trig_activate(struct led_classdev *led_cdev)
134 timer_data->timer.function = led_timer_function; 135 timer_data->timer.function = led_timer_function;
135 timer_data->timer.data = (unsigned long) led_cdev; 136 timer_data->timer.data = (unsigned long) led_cdev;
136 137
137 class_device_create_file(led_cdev->class_dev, 138 rc = class_device_create_file(led_cdev->class_dev,
138 &class_device_attr_delay_on); 139 &class_device_attr_delay_on);
139 class_device_create_file(led_cdev->class_dev, 140 if (rc) goto err_out;
141 rc = class_device_create_file(led_cdev->class_dev,
140 &class_device_attr_delay_off); 142 &class_device_attr_delay_off);
143 if (rc) goto err_out_delayon;
144
145 return;
146
147err_out_delayon:
148 class_device_remove_file(led_cdev->class_dev,
149 &class_device_attr_delay_on);
150err_out:
151 led_cdev->trigger_data = NULL;
152 kfree(timer_data);
141} 153}
142 154
143static void timer_trig_deactivate(struct led_classdev *led_cdev) 155static void timer_trig_deactivate(struct led_classdev *led_cdev)
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 655d816760e5..a625576fdeeb 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -16,6 +16,7 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/crypto.h> 17#include <linux/crypto.h>
18#include <linux/workqueue.h> 18#include <linux/workqueue.h>
19#include <linux/backing-dev.h>
19#include <asm/atomic.h> 20#include <asm/atomic.h>
20#include <linux/scatterlist.h> 21#include <linux/scatterlist.h>
21#include <asm/page.h> 22#include <asm/page.h>
@@ -602,7 +603,7 @@ static void process_write(struct crypt_io *io)
602 603
603 /* out of memory -> run queues */ 604 /* out of memory -> run queues */
604 if (remaining) 605 if (remaining)
605 blk_congestion_wait(bio_data_dir(clone), HZ/100); 606 congestion_wait(bio_data_dir(clone), HZ/100);
606 } 607 }
607} 608}
608 609
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 57fa64f93e5f..f7f19088f3be 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4912,6 +4912,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
4912} 4912}
4913 4913
4914static struct file_operations md_seq_fops = { 4914static struct file_operations md_seq_fops = {
4915 .owner = THIS_MODULE,
4915 .open = md_seq_open, 4916 .open = md_seq_open,
4916 .read = seq_read, 4917 .read = seq_read,
4917 .llseek = seq_lseek, 4918 .llseek = seq_lseek,
diff --git a/drivers/message/i2o/bus-osm.c b/drivers/message/i2o/bus-osm.c
index ac06f10c54ec..d96c687aee93 100644
--- a/drivers/message/i2o/bus-osm.c
+++ b/drivers/message/i2o/bus-osm.c
@@ -80,18 +80,26 @@ static DEVICE_ATTR(scan, S_IWUSR, NULL, i2o_bus_store_scan);
80 * @dev: device to verify if it is a I2O Bus Adapter device 80 * @dev: device to verify if it is a I2O Bus Adapter device
81 * 81 *
82 * Because we want all Bus Adapters always return 0. 82 * Because we want all Bus Adapters always return 0.
83 * Except when we fail. Then we are sad.
83 * 84 *
84 * Returns 0. 85 * Returns 0, except when we fail to excel.
85 */ 86 */
86static int i2o_bus_probe(struct device *dev) 87static int i2o_bus_probe(struct device *dev)
87{ 88{
88 struct i2o_device *i2o_dev = to_i2o_device(get_device(dev)); 89 struct i2o_device *i2o_dev = to_i2o_device(get_device(dev));
90 int rc;
89 91
90 device_create_file(dev, &dev_attr_scan); 92 rc = device_create_file(dev, &dev_attr_scan);
93 if (rc)
94 goto err_out;
91 95
92 osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid); 96 osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid);
93 97
94 return 0; 98 return 0;
99
100err_out:
101 put_device(dev);
102 return rc;
95}; 103};
96 104
97/** 105/**
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index 7bd4d85d0b42..91f95d172ca5 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -325,13 +325,24 @@ static DEVICE_ATTR(product_id, S_IRUGO, i2o_exec_show_product_id, NULL);
325static int i2o_exec_probe(struct device *dev) 325static int i2o_exec_probe(struct device *dev)
326{ 326{
327 struct i2o_device *i2o_dev = to_i2o_device(dev); 327 struct i2o_device *i2o_dev = to_i2o_device(dev);
328 int rc;
328 329
329 i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff); 330 rc = i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff);
331 if (rc) goto err_out;
330 332
331 device_create_file(dev, &dev_attr_vendor_id); 333 rc = device_create_file(dev, &dev_attr_vendor_id);
332 device_create_file(dev, &dev_attr_product_id); 334 if (rc) goto err_evtreg;
335 rc = device_create_file(dev, &dev_attr_product_id);
336 if (rc) goto err_vid;
333 337
334 return 0; 338 return 0;
339
340err_vid:
341 device_remove_file(dev, &dev_attr_vendor_id);
342err_evtreg:
343 i2o_event_register(to_i2o_device(dev), &i2o_exec_driver, 0, 0);
344err_out:
345 return rc;
335}; 346};
336 347
337/** 348/**
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index fa7acc2c5c6d..b6c045dc97b4 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -28,6 +28,17 @@ config IBM_ASM
28 28
29 If unsure, say N. 29 If unsure, say N.
30 30
31config SGI_IOC4
32 tristate "SGI IOC4 Base IO support"
33 ---help---
34 This option enables basic support for the IOC4 chip on certain
35 SGI IO controller cards (IO9, IO10, and PCI-RT). This option
36 does not enable any specific functions on such a card, but provides
37 necessary infrastructure for other drivers to utilize.
38
39 If you have an SGI Altix with an IOC4-based card say Y.
40 Otherwise say N.
41
31config TIFM_CORE 42config TIFM_CORE
32 tristate "TI Flash Media interface support (EXPERIMENTAL)" 43 tristate "TI Flash Media interface support (EXPERIMENTAL)"
33 depends on EXPERIMENTAL 44 depends on EXPERIMENTAL
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 9a91c1ee8497..c9e98ab021c5 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
9obj-$(CONFIG_LKDTM) += lkdtm.o 9obj-$(CONFIG_LKDTM) += lkdtm.o
10obj-$(CONFIG_TIFM_CORE) += tifm_core.o 10obj-$(CONFIG_TIFM_CORE) += tifm_core.o
11obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o 11obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o
12obj-$(CONFIG_SGI_IOC4) += ioc4.o
diff --git a/drivers/sn/ioc4.c b/drivers/misc/ioc4.c
index 8562821e6498..1c3c14a3839c 100644
--- a/drivers/sn/ioc4.c
+++ b/drivers/misc/ioc4.c
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2005 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (C) 2005-2006 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9/* This file contains the master driver module for use by SGI IOC4 subdrivers. 9/* This file contains the master driver module for use by SGI IOC4 subdrivers.
@@ -29,12 +29,9 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/ioc4.h> 31#include <linux/ioc4.h>
32#include <linux/mmtimer.h> 32#include <linux/ktime.h>
33#include <linux/rtc.h>
34#include <linux/mutex.h> 33#include <linux/mutex.h>
35#include <asm/sn/addrs.h> 34#include <linux/time.h>
36#include <asm/sn/clksupport.h>
37#include <asm/sn/shub_mmr.h>
38 35
39/*************** 36/***************
40 * Definitions * 37 * Definitions *
@@ -43,7 +40,7 @@
43/* Tweakable values */ 40/* Tweakable values */
44 41
45/* PCI bus speed detection/calibration */ 42/* PCI bus speed detection/calibration */
46#define IOC4_CALIBRATE_COUNT 63 /* Calibration cycle period */ 43#define IOC4_CALIBRATE_COUNT 63 /* Calibration cycle period */
47#define IOC4_CALIBRATE_CYCLES 256 /* Average over this many cycles */ 44#define IOC4_CALIBRATE_CYCLES 256 /* Average over this many cycles */
48#define IOC4_CALIBRATE_DISCARD 2 /* Discard first few cycles */ 45#define IOC4_CALIBRATE_DISCARD 2 /* Discard first few cycles */
49#define IOC4_CALIBRATE_LOW_MHZ 25 /* Lower bound on bus speed sanity */ 46#define IOC4_CALIBRATE_LOW_MHZ 25 /* Lower bound on bus speed sanity */
@@ -143,11 +140,11 @@ ioc4_unregister_submodule(struct ioc4_submodule *is)
143static void 140static void
144ioc4_clock_calibrate(struct ioc4_driver_data *idd) 141ioc4_clock_calibrate(struct ioc4_driver_data *idd)
145{ 142{
146 extern unsigned long sn_rtc_cycles_per_second;
147 union ioc4_int_out int_out; 143 union ioc4_int_out int_out;
148 union ioc4_gpcr gpcr; 144 union ioc4_gpcr gpcr;
149 unsigned int state, last_state = 1; 145 unsigned int state, last_state = 1;
150 uint64_t start = 0, end, period; 146 struct timespec start_ts, end_ts;
147 uint64_t start, end, period;
151 unsigned int count = 0; 148 unsigned int count = 0;
152 149
153 /* Enable output */ 150 /* Enable output */
@@ -175,30 +172,28 @@ ioc4_clock_calibrate(struct ioc4_driver_data *idd)
175 if (!last_state && state) { 172 if (!last_state && state) {
176 count++; 173 count++;
177 if (count == IOC4_CALIBRATE_END) { 174 if (count == IOC4_CALIBRATE_END) {
178 end = rtc_time(); 175 ktime_get_ts(&end_ts);
179 break; 176 break;
180 } else if (count == IOC4_CALIBRATE_DISCARD) 177 } else if (count == IOC4_CALIBRATE_DISCARD)
181 start = rtc_time(); 178 ktime_get_ts(&start_ts);
182 } 179 }
183 last_state = state; 180 last_state = state;
184 } while (1); 181 } while (1);
185 182
186 /* Calculation rearranged to preserve intermediate precision. 183 /* Calculation rearranged to preserve intermediate precision.
187 * Logically: 184 * Logically:
188 * 1. "end - start" gives us number of RTC cycles over all the 185 * 1. "end - start" gives us the measurement period over all
189 * square wave cycles measured. 186 * the square wave cycles.
190 * 2. Divide by number of square wave cycles to get number of 187 * 2. Divide by number of square wave cycles to get the period
191 * RTC cycles per square wave cycle. 188 * of a square wave cycle.
192 * 3. Divide by 2*(int_out.fields.count+1), which is the formula 189 * 3. Divide by 2*(int_out.fields.count+1), which is the formula
193 * by which the IOC4 generates the square wave, to get the 190 * by which the IOC4 generates the square wave, to get the
194 * number of RTC cycles per IOC4 INT_OUT count. 191 * period of an IOC4 INT_OUT count.
195 * 4. Divide by sn_rtc_cycles_per_second to get seconds per
196 * count.
197 * 5. Multiply by 1E9 to get nanoseconds per count.
198 */ 192 */
199 period = ((end - start) * 1000000000) / 193 end = end_ts.tv_sec * NSEC_PER_SEC + end_ts.tv_nsec;
200 (IOC4_CALIBRATE_CYCLES * 2 * (IOC4_CALIBRATE_COUNT + 1) 194 start = start_ts.tv_sec * NSEC_PER_SEC + start_ts.tv_nsec;
201 * sn_rtc_cycles_per_second); 195 period = (end - start) /
196 (IOC4_CALIBRATE_CYCLES * 2 * (IOC4_CALIBRATE_COUNT + 1));
202 197
203 /* Bounds check the result. */ 198 /* Bounds check the result. */
204 if (period > IOC4_CALIBRATE_LOW_LIMIT || 199 if (period > IOC4_CALIBRATE_LOW_LIMIT ||
@@ -210,10 +205,12 @@ ioc4_clock_calibrate(struct ioc4_driver_data *idd)
210 IOC4_CALIBRATE_DEFAULT / IOC4_EXTINT_COUNT_DIVISOR); 205 IOC4_CALIBRATE_DEFAULT / IOC4_EXTINT_COUNT_DIVISOR);
211 period = IOC4_CALIBRATE_DEFAULT; 206 period = IOC4_CALIBRATE_DEFAULT;
212 } else { 207 } else {
208 u64 ns = period;
209
210 do_div(ns, IOC4_EXTINT_COUNT_DIVISOR);
213 printk(KERN_DEBUG 211 printk(KERN_DEBUG
214 "IOC4 %s: PCI clock is %ld ns.\n", 212 "IOC4 %s: PCI clock is %lld ns.\n",
215 pci_name(idd->idd_pdev), 213 pci_name(idd->idd_pdev), ns);
216 period / IOC4_EXTINT_COUNT_DIVISOR);
217 } 214 }
218 215
219 /* Remember results. We store the extint clock period rather 216 /* Remember results. We store the extint clock period rather
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ab92cc794c64..e2ed24918a58 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2288,7 +2288,7 @@ config UGETH_TX_ON_DEMOND
2288 2288
2289config UGETH_HAS_GIGA 2289config UGETH_HAS_GIGA
2290 bool 2290 bool
2291 depends on UCC_GETH && MPC836x 2291 depends on UCC_GETH && PPC_MPC836x
2292 2292
2293config MV643XX_ETH 2293config MV643XX_ETH
2294 tristate "MV-643XX Ethernet support" 2294 tristate "MV-643XX Ethernet support"
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 27d5d2f02533..a3a08a5dd185 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2039,7 +2039,6 @@ static int e100_change_mtu(struct net_device *netdev, int new_mtu)
2039 return 0; 2039 return 0;
2040} 2040}
2041 2041
2042#ifdef CONFIG_PM
2043static int e100_asf(struct nic *nic) 2042static int e100_asf(struct nic *nic)
2044{ 2043{
2045 /* ASF can be enabled from eeprom */ 2044 /* ASF can be enabled from eeprom */
@@ -2048,7 +2047,6 @@ static int e100_asf(struct nic *nic)
2048 !(nic->eeprom[eeprom_config_asf] & eeprom_gcl) && 2047 !(nic->eeprom[eeprom_config_asf] & eeprom_gcl) &&
2049 ((nic->eeprom[eeprom_smbus_addr] & 0xFF) != 0xFE)); 2048 ((nic->eeprom[eeprom_smbus_addr] & 0xFF) != 0xFE));
2050} 2049}
2051#endif
2052 2050
2053static int e100_up(struct nic *nic) 2051static int e100_up(struct nic *nic)
2054{ 2052{
@@ -2715,34 +2713,32 @@ static void __devexit e100_remove(struct pci_dev *pdev)
2715 } 2713 }
2716} 2714}
2717 2715
2716#ifdef CONFIG_PM
2718static int e100_suspend(struct pci_dev *pdev, pm_message_t state) 2717static int e100_suspend(struct pci_dev *pdev, pm_message_t state)
2719{ 2718{
2720 struct net_device *netdev = pci_get_drvdata(pdev); 2719 struct net_device *netdev = pci_get_drvdata(pdev);
2721 struct nic *nic = netdev_priv(netdev); 2720 struct nic *nic = netdev_priv(netdev);
2722 2721
2723 if (netif_running(netdev)) 2722 netif_poll_disable(nic->netdev);
2724 e100_down(nic); 2723 del_timer_sync(&nic->watchdog);
2725 e100_hw_reset(nic); 2724 netif_carrier_off(nic->netdev);
2726 netif_device_detach(netdev);
2727 2725
2728#ifdef CONFIG_PM
2729 pci_save_state(pdev); 2726 pci_save_state(pdev);
2730 if (nic->flags & (wol_magic | e100_asf(nic))) 2727
2731#else 2728 if ((nic->flags & wol_magic) | e100_asf(nic)) {
2732 if (nic->flags & (wol_magic)) 2729 pci_enable_wake(pdev, PCI_D3hot, 1);
2733#endif 2730 pci_enable_wake(pdev, PCI_D3cold, 1);
2734 pci_enable_wake(pdev, pci_choose_state(pdev, state), 1); 2731 } else {
2735 else 2732 pci_enable_wake(pdev, PCI_D3hot, 0);
2736 /* disable PME */ 2733 pci_enable_wake(pdev, PCI_D3cold, 0);
2737 pci_enable_wake(pdev, 0, 0); 2734 }
2738 2735
2739 pci_disable_device(pdev); 2736 pci_disable_device(pdev);
2740 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 2737 pci_set_power_state(pdev, PCI_D3hot);
2741 2738
2742 return 0; 2739 return 0;
2743} 2740}
2744 2741
2745#ifdef CONFIG_PM
2746static int e100_resume(struct pci_dev *pdev) 2742static int e100_resume(struct pci_dev *pdev)
2747{ 2743{
2748 struct net_device *netdev = pci_get_drvdata(pdev); 2744 struct net_device *netdev = pci_get_drvdata(pdev);
@@ -2764,7 +2760,23 @@ static int e100_resume(struct pci_dev *pdev)
2764 2760
2765static void e100_shutdown(struct pci_dev *pdev) 2761static void e100_shutdown(struct pci_dev *pdev)
2766{ 2762{
2767 e100_suspend(pdev, PMSG_SUSPEND); 2763 struct net_device *netdev = pci_get_drvdata(pdev);
2764 struct nic *nic = netdev_priv(netdev);
2765
2766 netif_poll_disable(nic->netdev);
2767 del_timer_sync(&nic->watchdog);
2768 netif_carrier_off(nic->netdev);
2769
2770 if ((nic->flags & wol_magic) | e100_asf(nic)) {
2771 pci_enable_wake(pdev, PCI_D3hot, 1);
2772 pci_enable_wake(pdev, PCI_D3cold, 1);
2773 } else {
2774 pci_enable_wake(pdev, PCI_D3hot, 0);
2775 pci_enable_wake(pdev, PCI_D3cold, 0);
2776 }
2777
2778 pci_disable_device(pdev);
2779 pci_set_power_state(pdev, PCI_D3hot);
2768} 2780}
2769 2781
2770/* ------------------ PCI Error Recovery infrastructure -------------- */ 2782/* ------------------ PCI Error Recovery infrastructure -------------- */
@@ -2848,9 +2860,9 @@ static struct pci_driver e100_driver = {
2848 .id_table = e100_id_table, 2860 .id_table = e100_id_table,
2849 .probe = e100_probe, 2861 .probe = e100_probe,
2850 .remove = __devexit_p(e100_remove), 2862 .remove = __devexit_p(e100_remove),
2863#ifdef CONFIG_PM
2851 /* Power Management hooks */ 2864 /* Power Management hooks */
2852 .suspend = e100_suspend, 2865 .suspend = e100_suspend,
2853#ifdef CONFIG_PM
2854 .resume = e100_resume, 2866 .resume = e100_resume,
2855#endif 2867#endif
2856 .shutdown = e100_shutdown, 2868 .shutdown = e100_shutdown,
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index ce0d35fe3947..fa849831d099 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -4914,10 +4914,6 @@ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
4914 pci_enable_wake(pdev, PCI_D3hot, 0); 4914 pci_enable_wake(pdev, PCI_D3hot, 0);
4915 pci_enable_wake(pdev, PCI_D3cold, 0); 4915 pci_enable_wake(pdev, PCI_D3cold, 0);
4916 4916
4917 /* Perform card reset only on one instance of the card */
4918 if (PCI_FUNC (pdev->devfn) != 0)
4919 return PCI_ERS_RESULT_RECOVERED;
4920
4921 e1000_reset(adapter); 4917 e1000_reset(adapter);
4922 E1000_WRITE_REG(&adapter->hw, WUS, ~0); 4918 E1000_WRITE_REG(&adapter->hw, WUS, ~0);
4923 4919
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index e963dbf816be..f56b00ee385e 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -1017,7 +1017,7 @@ static void ioc3_init(struct net_device *dev)
1017 struct ioc3_private *ip = netdev_priv(dev); 1017 struct ioc3_private *ip = netdev_priv(dev);
1018 struct ioc3 *ioc3 = ip->regs; 1018 struct ioc3 *ioc3 = ip->regs;
1019 1019
1020 del_timer(&ip->ioc3_timer); /* Kill if running */ 1020 del_timer_sync(&ip->ioc3_timer); /* Kill if running */
1021 1021
1022 ioc3_w_emcr(EMCR_RST); /* Reset */ 1022 ioc3_w_emcr(EMCR_RST); /* Reset */
1023 (void) ioc3_r_emcr(); /* Flush WB */ 1023 (void) ioc3_r_emcr(); /* Flush WB */
@@ -1081,7 +1081,7 @@ static int ioc3_close(struct net_device *dev)
1081{ 1081{
1082 struct ioc3_private *ip = netdev_priv(dev); 1082 struct ioc3_private *ip = netdev_priv(dev);
1083 1083
1084 del_timer(&ip->ioc3_timer); 1084 del_timer_sync(&ip->ioc3_timer);
1085 1085
1086 netif_stop_queue(dev); 1086 netif_stop_queue(dev);
1087 1087
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 4178b4b1d2df..82c10dec1b5a 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -58,7 +58,11 @@
58#include <linux/tcp.h> 58#include <linux/tcp.h>
59#include <linux/percpu.h> 59#include <linux/percpu.h>
60 60
61static DEFINE_PER_CPU(struct net_device_stats, loopback_stats); 61struct pcpu_lstats {
62 unsigned long packets;
63 unsigned long bytes;
64};
65static DEFINE_PER_CPU(struct pcpu_lstats, pcpu_lstats);
62 66
63#define LOOPBACK_OVERHEAD (128 + MAX_HEADER + 16 + 16) 67#define LOOPBACK_OVERHEAD (128 + MAX_HEADER + 16 + 16)
64 68
@@ -128,7 +132,7 @@ static void emulate_large_send_offload(struct sk_buff *skb)
128 */ 132 */
129static int loopback_xmit(struct sk_buff *skb, struct net_device *dev) 133static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
130{ 134{
131 struct net_device_stats *lb_stats; 135 struct pcpu_lstats *lb_stats;
132 136
133 skb_orphan(skb); 137 skb_orphan(skb);
134 138
@@ -149,16 +153,14 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
149#endif 153#endif
150 dev->last_rx = jiffies; 154 dev->last_rx = jiffies;
151 155
152 lb_stats = &per_cpu(loopback_stats, get_cpu()); 156 /* it's OK to use __get_cpu_var() because BHs are off */
153 lb_stats->rx_bytes += skb->len; 157 lb_stats = &__get_cpu_var(pcpu_lstats);
154 lb_stats->tx_bytes = lb_stats->rx_bytes; 158 lb_stats->bytes += skb->len;
155 lb_stats->rx_packets++; 159 lb_stats->packets++;
156 lb_stats->tx_packets = lb_stats->rx_packets;
157 put_cpu();
158 160
159 netif_rx(skb); 161 netif_rx(skb);
160 162
161 return(0); 163 return 0;
162} 164}
163 165
164static struct net_device_stats loopback_stats; 166static struct net_device_stats loopback_stats;
@@ -166,20 +168,21 @@ static struct net_device_stats loopback_stats;
166static struct net_device_stats *get_stats(struct net_device *dev) 168static struct net_device_stats *get_stats(struct net_device *dev)
167{ 169{
168 struct net_device_stats *stats = &loopback_stats; 170 struct net_device_stats *stats = &loopback_stats;
171 unsigned long bytes = 0;
172 unsigned long packets = 0;
169 int i; 173 int i;
170 174
171 memset(stats, 0, sizeof(struct net_device_stats));
172
173 for_each_possible_cpu(i) { 175 for_each_possible_cpu(i) {
174 struct net_device_stats *lb_stats; 176 const struct pcpu_lstats *lb_stats;
175 177
176 lb_stats = &per_cpu(loopback_stats, i); 178 lb_stats = &per_cpu(pcpu_lstats, i);
177 stats->rx_bytes += lb_stats->rx_bytes; 179 bytes += lb_stats->bytes;
178 stats->tx_bytes += lb_stats->tx_bytes; 180 packets += lb_stats->packets;
179 stats->rx_packets += lb_stats->rx_packets;
180 stats->tx_packets += lb_stats->tx_packets;
181 } 181 }
182 182 stats->rx_packets = packets;
183 stats->tx_packets = packets;
184 stats->rx_bytes = bytes;
185 stats->tx_bytes = bytes;
183 return stats; 186 return stats;
184} 187}
185 188
diff --git a/drivers/net/myri_code.h b/drivers/net/myri_code.h
index e21ec9b2c706..ba7b8652c501 100644
--- a/drivers/net/myri_code.h
+++ b/drivers/net/myri_code.h
@@ -1,8 +1,8 @@
1/* This is the Myrinet MCP code for LANai4.x */ 1/* This is the Myrinet MCP code for LANai4.x */
2/* Generated by cat $MYRI_HOME/lib/lanai/mcp4.dat > myri_code4.h */ 2/* Generated by cat $MYRI_HOME/lib/lanai/mcp4.dat > myri_code4.h */
3 3
4static unsigned int lanai4_code_off = 0x0000; /* half-word offset */ 4static unsigned int __devinitdata lanai4_code_off = 0x0000; /* half-word offset */
5static unsigned char lanai4_code[76256] __initdata = { 5static unsigned char __devinitdata lanai4_code[76256] = {
60xF2,0x0E, 60xF2,0x0E,
70xFE,0x00, 0xC2,0x90, 0x00,0x00, 0x07,0x88, 0x00,0x08, 0xE0,0x01, 0x01,0x4C, 0x97,0x93, 70xFE,0x00, 0xC2,0x90, 0x00,0x00, 0x07,0x88, 0x00,0x08, 0xE0,0x01, 0x01,0x4C, 0x97,0x93,
80xFF,0xFC, 0xE0,0x00, 0x00,0x14, 0x00,0x00, 0x00,0x01, 0x00,0x00, 0x00,0x00, 0x92,0x93, 80xFF,0xFC, 0xE0,0x00, 0x00,0x14, 0x00,0x00, 0x00,0x01, 0x00,0x00, 0x00,0x00, 0x92,0x93,
@@ -4774,8 +4774,8 @@ static unsigned char lanai4_code[76256] __initdata = {
4774 4774
4775/* This is the LANai data */ 4775/* This is the LANai data */
4776 4776
4777static unsigned int lanai4_data_off = 0x94F0; /* half-word offset */ 4777static unsigned int __devinitdata lanai4_data_off = 0x94F0; /* half-word offset */
4778static unsigned char lanai4_data[20472] __initdata; 4778static unsigned char __devinitdata lanai4_data[20472];
4779 4779
4780 4780
4781#ifdef SYMBOL_DEFINES_COMPILED 4781#ifdef SYMBOL_DEFINES_COMPILED
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index 466b484c9fa4..7747bfd99f91 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -168,7 +168,7 @@ static int myri_do_handshake(struct myri_eth *mp)
168 return 0; 168 return 0;
169} 169}
170 170
171static int myri_load_lanai(struct myri_eth *mp) 171static int __devinit myri_load_lanai(struct myri_eth *mp)
172{ 172{
173 struct net_device *dev = mp->dev; 173 struct net_device *dev = mp->dev;
174 struct myri_shmem __iomem *shmem = mp->shmem; 174 struct myri_shmem __iomem *shmem = mp->shmem;
@@ -891,7 +891,7 @@ static void dump_eeprom(struct myri_eth *mp)
891} 891}
892#endif 892#endif
893 893
894static int __init myri_ether_init(struct sbus_dev *sdev) 894static int __devinit myri_ether_init(struct sbus_dev *sdev)
895{ 895{
896 static int num; 896 static int num;
897 static unsigned version_printed; 897 static unsigned version_printed;
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index f1c75751cab7..d132fe7d475e 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -214,6 +214,7 @@ static struct pci_device_id rtl8169_pci_tbl[] = {
214 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_2 }, 214 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_2 },
215 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 }, 215 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 },
216 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 }, 216 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 },
217 { PCI_DEVICE(0x1259, 0xc107), 0, 0, RTL_CFG_0 },
217 { PCI_DEVICE(0x16ec, 0x0116), 0, 0, RTL_CFG_0 }, 218 { PCI_DEVICE(0x16ec, 0x0116), 0, 0, RTL_CFG_0 },
218 { PCI_VENDOR_ID_LINKSYS, 0x1032, 219 { PCI_VENDOR_ID_LINKSYS, 0x1032,
219 PCI_ANY_ID, 0x0024, 0, 0, RTL_CFG_0 }, 220 PCI_ANY_ID, 0x0024, 0, 0, RTL_CFG_0 },
@@ -2700,6 +2701,7 @@ static void rtl8169_down(struct net_device *dev)
2700 struct rtl8169_private *tp = netdev_priv(dev); 2701 struct rtl8169_private *tp = netdev_priv(dev);
2701 void __iomem *ioaddr = tp->mmio_addr; 2702 void __iomem *ioaddr = tp->mmio_addr;
2702 unsigned int poll_locked = 0; 2703 unsigned int poll_locked = 0;
2704 unsigned int intrmask;
2703 2705
2704 rtl8169_delete_timer(dev); 2706 rtl8169_delete_timer(dev);
2705 2707
@@ -2738,8 +2740,11 @@ core_down:
2738 * 2) dev->change_mtu 2740 * 2) dev->change_mtu
2739 * -> rtl8169_poll can not be issued again and re-enable the 2741 * -> rtl8169_poll can not be issued again and re-enable the
2740 * interruptions. Let's simply issue the IRQ down sequence again. 2742 * interruptions. Let's simply issue the IRQ down sequence again.
2743 *
2744 * No loop if hotpluged or major error (0xffff).
2741 */ 2745 */
2742 if (RTL_R16(IntrMask)) 2746 intrmask = RTL_R16(IntrMask);
2747 if (intrmask && (intrmask != 0xffff))
2743 goto core_down; 2748 goto core_down;
2744 2749
2745 rtl8169_tx_clear(tp); 2750 rtl8169_tx_clear(tp);
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index db2324939b69..1eae16b72b4b 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -2903,7 +2903,7 @@ sbmac_init_module(void)
2903 2903
2904 dev = alloc_etherdev(sizeof(struct sbmac_softc)); 2904 dev = alloc_etherdev(sizeof(struct sbmac_softc));
2905 if (!dev) 2905 if (!dev)
2906 return -ENOMEM; /* return ENOMEM */ 2906 return -ENOMEM;
2907 2907
2908 printk(KERN_DEBUG "sbmac: configuring MAC at %lx\n", port); 2908 printk(KERN_DEBUG "sbmac: configuring MAC at %lx\n", port);
2909 2909
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index c10e7f5faa5f..95efdb5bbbe1 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -50,7 +50,7 @@
50#include "sky2.h" 50#include "sky2.h"
51 51
52#define DRV_NAME "sky2" 52#define DRV_NAME "sky2"
53#define DRV_VERSION "1.9" 53#define DRV_VERSION "1.10"
54#define PFX DRV_NAME " " 54#define PFX DRV_NAME " "
55 55
56/* 56/*
@@ -96,9 +96,9 @@ static int disable_msi = 0;
96module_param(disable_msi, int, 0); 96module_param(disable_msi, int, 0);
97MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)"); 97MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
98 98
99static int idle_timeout = 100; 99static int idle_timeout = 0;
100module_param(idle_timeout, int, 0); 100module_param(idle_timeout, int, 0);
101MODULE_PARM_DESC(idle_timeout, "Idle timeout workaround for lost interrupts (ms)"); 101MODULE_PARM_DESC(idle_timeout, "Watchdog timer for lost interrupts (ms)");
102 102
103static const struct pci_device_id sky2_id_table[] = { 103static const struct pci_device_id sky2_id_table[] = {
104 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, 104 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) },
@@ -284,6 +284,31 @@ static void sky2_gmac_reset(struct sky2_hw *hw, unsigned port)
284 gma_write16(hw, port, GM_RX_CTRL, reg); 284 gma_write16(hw, port, GM_RX_CTRL, reg);
285} 285}
286 286
287/* flow control to advertise bits */
288static const u16 copper_fc_adv[] = {
289 [FC_NONE] = 0,
290 [FC_TX] = PHY_M_AN_ASP,
291 [FC_RX] = PHY_M_AN_PC,
292 [FC_BOTH] = PHY_M_AN_PC | PHY_M_AN_ASP,
293};
294
295/* flow control to advertise bits when using 1000BaseX */
296static const u16 fiber_fc_adv[] = {
297 [FC_BOTH] = PHY_M_P_BOTH_MD_X,
298 [FC_TX] = PHY_M_P_ASYM_MD_X,
299 [FC_RX] = PHY_M_P_SYM_MD_X,
300 [FC_NONE] = PHY_M_P_NO_PAUSE_X,
301};
302
303/* flow control to GMA disable bits */
304static const u16 gm_fc_disable[] = {
305 [FC_NONE] = GM_GPCR_FC_RX_DIS | GM_GPCR_FC_TX_DIS,
306 [FC_TX] = GM_GPCR_FC_RX_DIS,
307 [FC_RX] = GM_GPCR_FC_TX_DIS,
308 [FC_BOTH] = 0,
309};
310
311
287static void sky2_phy_init(struct sky2_hw *hw, unsigned port) 312static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
288{ 313{
289 struct sky2_port *sky2 = netdev_priv(hw->dev[port]); 314 struct sky2_port *sky2 = netdev_priv(hw->dev[port]);
@@ -356,16 +381,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
356 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); 381 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
357 } 382 }
358 383
359 ctrl = gm_phy_read(hw, port, PHY_MARV_CTRL); 384 ctrl = PHY_CT_RESET;
360 if (sky2->autoneg == AUTONEG_DISABLE)
361 ctrl &= ~PHY_CT_ANE;
362 else
363 ctrl |= PHY_CT_ANE;
364
365 ctrl |= PHY_CT_RESET;
366 gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl);
367
368 ctrl = 0;
369 ct1000 = 0; 385 ct1000 = 0;
370 adv = PHY_AN_CSMA; 386 adv = PHY_AN_CSMA;
371 reg = 0; 387 reg = 0;
@@ -384,20 +400,16 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
384 adv |= PHY_M_AN_10_FD; 400 adv |= PHY_M_AN_10_FD;
385 if (sky2->advertising & ADVERTISED_10baseT_Half) 401 if (sky2->advertising & ADVERTISED_10baseT_Half)
386 adv |= PHY_M_AN_10_HD; 402 adv |= PHY_M_AN_10_HD;
403
404 adv |= copper_fc_adv[sky2->flow_mode];
387 } else { /* special defines for FIBER (88E1040S only) */ 405 } else { /* special defines for FIBER (88E1040S only) */
388 if (sky2->advertising & ADVERTISED_1000baseT_Full) 406 if (sky2->advertising & ADVERTISED_1000baseT_Full)
389 adv |= PHY_M_AN_1000X_AFD; 407 adv |= PHY_M_AN_1000X_AFD;
390 if (sky2->advertising & ADVERTISED_1000baseT_Half) 408 if (sky2->advertising & ADVERTISED_1000baseT_Half)
391 adv |= PHY_M_AN_1000X_AHD; 409 adv |= PHY_M_AN_1000X_AHD;
392 }
393 410
394 /* Set Flow-control capabilities */ 411 adv |= fiber_fc_adv[sky2->flow_mode];
395 if (sky2->tx_pause && sky2->rx_pause) 412 }
396 adv |= PHY_AN_PAUSE_CAP; /* symmetric */
397 else if (sky2->rx_pause && !sky2->tx_pause)
398 adv |= PHY_AN_PAUSE_ASYM | PHY_AN_PAUSE_CAP;
399 else if (!sky2->rx_pause && sky2->tx_pause)
400 adv |= PHY_AN_PAUSE_ASYM; /* local */
401 413
402 /* Restart Auto-negotiation */ 414 /* Restart Auto-negotiation */
403 ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG; 415 ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG;
@@ -422,25 +434,17 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
422 if (sky2->duplex == DUPLEX_FULL) { 434 if (sky2->duplex == DUPLEX_FULL) {
423 reg |= GM_GPCR_DUP_FULL; 435 reg |= GM_GPCR_DUP_FULL;
424 ctrl |= PHY_CT_DUP_MD; 436 ctrl |= PHY_CT_DUP_MD;
425 } else if (sky2->speed != SPEED_1000 && hw->chip_id != CHIP_ID_YUKON_EC_U) { 437 } else if (sky2->speed < SPEED_1000)
426 /* Turn off flow control for 10/100mbps */ 438 sky2->flow_mode = FC_NONE;
427 sky2->rx_pause = 0;
428 sky2->tx_pause = 0;
429 }
430 439
431 if (!sky2->rx_pause)
432 reg |= GM_GPCR_FC_RX_DIS;
433 440
434 if (!sky2->tx_pause) 441 reg |= gm_fc_disable[sky2->flow_mode];
435 reg |= GM_GPCR_FC_TX_DIS;
436 442
437 /* Forward pause packets to GMAC? */ 443 /* Forward pause packets to GMAC? */
438 if (sky2->tx_pause || sky2->rx_pause) 444 if (sky2->flow_mode & FC_RX)
439 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON); 445 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON);
440 else 446 else
441 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); 447 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
442
443 ctrl |= PHY_CT_RESET;
444 } 448 }
445 449
446 gma_write16(hw, port, GM_GP_CTRL, reg); 450 gma_write16(hw, port, GM_GP_CTRL, reg);
@@ -695,16 +699,10 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
695 699
696} 700}
697 701
698/* Assign Ram Buffer allocation. 702/* Assign Ram Buffer allocation in units of 64bit (8 bytes) */
699 * start and end are in units of 4k bytes 703static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end)
700 * ram registers are in units of 64bit words
701 */
702static void sky2_ramset(struct sky2_hw *hw, u16 q, u8 startk, u8 endk)
703{ 704{
704 u32 start, end; 705 pr_debug(PFX "q %d %#x %#x\n", q, start, end);
705
706 start = startk * 4096/8;
707 end = (endk * 4096/8) - 1;
708 706
709 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR); 707 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR);
710 sky2_write32(hw, RB_ADDR(q, RB_START), start); 708 sky2_write32(hw, RB_ADDR(q, RB_START), start);
@@ -713,7 +711,7 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u8 startk, u8 endk)
713 sky2_write32(hw, RB_ADDR(q, RB_RP), start); 711 sky2_write32(hw, RB_ADDR(q, RB_RP), start);
714 712
715 if (q == Q_R1 || q == Q_R2) { 713 if (q == Q_R1 || q == Q_R2) {
716 u32 space = (endk - startk) * 4096/8; 714 u32 space = end - start + 1;
717 u32 tp = space - space/4; 715 u32 tp = space - space/4;
718 716
719 /* On receive queue's set the thresholds 717 /* On receive queue's set the thresholds
@@ -1195,19 +1193,16 @@ static int sky2_up(struct net_device *dev)
1195 1193
1196 sky2_mac_init(hw, port); 1194 sky2_mac_init(hw, port);
1197 1195
1198 /* Determine available ram buffer space (in 4K blocks). 1196 /* Determine available ram buffer space in qwords. */
1199 * Note: not sure about the FE setting below yet 1197 ramsize = sky2_read8(hw, B2_E_0) * 4096/8;
1200 */
1201 if (hw->chip_id == CHIP_ID_YUKON_FE)
1202 ramsize = 4;
1203 else
1204 ramsize = sky2_read8(hw, B2_E_0);
1205 1198
1206 /* Give transmitter one third (rounded up) */ 1199 if (ramsize > 6*1024/8)
1207 rxspace = ramsize - (ramsize + 2) / 3; 1200 rxspace = ramsize - (ramsize + 2) / 3;
1201 else
1202 rxspace = ramsize / 2;
1208 1203
1209 sky2_ramset(hw, rxqaddr[port], 0, rxspace); 1204 sky2_ramset(hw, rxqaddr[port], 0, rxspace-1);
1210 sky2_ramset(hw, txqaddr[port], rxspace, ramsize); 1205 sky2_ramset(hw, txqaddr[port], rxspace, ramsize-1);
1211 1206
1212 /* Make sure SyncQ is disabled */ 1207 /* Make sure SyncQ is disabled */
1213 sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL), 1208 sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL),
@@ -1499,6 +1494,11 @@ static int sky2_down(struct net_device *dev)
1499 /* Stop more packets from being queued */ 1494 /* Stop more packets from being queued */
1500 netif_stop_queue(dev); 1495 netif_stop_queue(dev);
1501 1496
1497 /* Disable port IRQ */
1498 imask = sky2_read32(hw, B0_IMSK);
1499 imask &= ~portirq_msk[port];
1500 sky2_write32(hw, B0_IMSK, imask);
1501
1502 sky2_gmac_reset(hw, port); 1502 sky2_gmac_reset(hw, port);
1503 1503
1504 /* Stop transmitter */ 1504 /* Stop transmitter */
@@ -1549,11 +1549,6 @@ static int sky2_down(struct net_device *dev)
1549 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET); 1549 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
1550 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET); 1550 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET);
1551 1551
1552 /* Disable port IRQ */
1553 imask = sky2_read32(hw, B0_IMSK);
1554 imask &= ~portirq_msk[port];
1555 sky2_write32(hw, B0_IMSK, imask);
1556
1557 sky2_phy_power(hw, port, 0); 1552 sky2_phy_power(hw, port, 0);
1558 1553
1559 /* turn off LED's */ 1554 /* turn off LED's */
@@ -1605,6 +1600,12 @@ static void sky2_link_up(struct sky2_port *sky2)
1605 struct sky2_hw *hw = sky2->hw; 1600 struct sky2_hw *hw = sky2->hw;
1606 unsigned port = sky2->port; 1601 unsigned port = sky2->port;
1607 u16 reg; 1602 u16 reg;
1603 static const char *fc_name[] = {
1604 [FC_NONE] = "none",
1605 [FC_TX] = "tx",
1606 [FC_RX] = "rx",
1607 [FC_BOTH] = "both",
1608 };
1608 1609
1609 /* enable Rx/Tx */ 1610 /* enable Rx/Tx */
1610 reg = gma_read16(hw, port, GM_GP_CTRL); 1611 reg = gma_read16(hw, port, GM_GP_CTRL);
@@ -1648,8 +1649,7 @@ static void sky2_link_up(struct sky2_port *sky2)
1648 "%s: Link is up at %d Mbps, %s duplex, flow control %s\n", 1649 "%s: Link is up at %d Mbps, %s duplex, flow control %s\n",
1649 sky2->netdev->name, sky2->speed, 1650 sky2->netdev->name, sky2->speed,
1650 sky2->duplex == DUPLEX_FULL ? "full" : "half", 1651 sky2->duplex == DUPLEX_FULL ? "full" : "half",
1651 (sky2->tx_pause && sky2->rx_pause) ? "both" : 1652 fc_name[sky2->flow_status]);
1652 sky2->tx_pause ? "tx" : sky2->rx_pause ? "rx" : "none");
1653} 1653}
1654 1654
1655static void sky2_link_down(struct sky2_port *sky2) 1655static void sky2_link_down(struct sky2_port *sky2)
@@ -1664,7 +1664,7 @@ static void sky2_link_down(struct sky2_port *sky2)
1664 reg &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); 1664 reg &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
1665 gma_write16(hw, port, GM_GP_CTRL, reg); 1665 gma_write16(hw, port, GM_GP_CTRL, reg);
1666 1666
1667 if (sky2->rx_pause && !sky2->tx_pause) { 1667 if (sky2->flow_status == FC_RX) {
1668 /* restore Asymmetric Pause bit */ 1668 /* restore Asymmetric Pause bit */
1669 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, 1669 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV,
1670 gm_phy_read(hw, port, PHY_MARV_AUNE_ADV) 1670 gm_phy_read(hw, port, PHY_MARV_AUNE_ADV)
@@ -1683,6 +1683,14 @@ static void sky2_link_down(struct sky2_port *sky2)
1683 sky2_phy_init(hw, port); 1683 sky2_phy_init(hw, port);
1684} 1684}
1685 1685
1686static enum flow_control sky2_flow(int rx, int tx)
1687{
1688 if (rx)
1689 return tx ? FC_BOTH : FC_RX;
1690 else
1691 return tx ? FC_TX : FC_NONE;
1692}
1693
1686static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux) 1694static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux)
1687{ 1695{
1688 struct sky2_hw *hw = sky2->hw; 1696 struct sky2_hw *hw = sky2->hw;
@@ -1703,39 +1711,20 @@ static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux)
1703 } 1711 }
1704 1712
1705 sky2->speed = sky2_phy_speed(hw, aux); 1713 sky2->speed = sky2_phy_speed(hw, aux);
1706 if (sky2->speed == SPEED_1000) { 1714 sky2->duplex = (aux & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF;
1707 u16 ctl2 = gm_phy_read(hw, port, PHY_MARV_1000T_CTRL);
1708 u16 lpa2 = gm_phy_read(hw, port, PHY_MARV_1000T_STAT);
1709 if (lpa2 & PHY_B_1000S_MSF) {
1710 printk(KERN_ERR PFX "%s: master/slave fault",
1711 sky2->netdev->name);
1712 return -1;
1713 }
1714
1715 if ((ctl2 & PHY_M_1000C_AFD) && (lpa2 & PHY_B_1000S_LP_FD))
1716 sky2->duplex = DUPLEX_FULL;
1717 else
1718 sky2->duplex = DUPLEX_HALF;
1719 } else {
1720 u16 adv = gm_phy_read(hw, port, PHY_MARV_AUNE_ADV);
1721 if ((aux & adv) & PHY_AN_FULL)
1722 sky2->duplex = DUPLEX_FULL;
1723 else
1724 sky2->duplex = DUPLEX_HALF;
1725 }
1726 1715
1727 /* Pause bits are offset (9..8) */ 1716 /* Pause bits are offset (9..8) */
1728 if (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U) 1717 if (hw->chip_id == CHIP_ID_YUKON_XL || hw->chip_id == CHIP_ID_YUKON_EC_U)
1729 aux >>= 6; 1718 aux >>= 6;
1730 1719
1731 sky2->rx_pause = (aux & PHY_M_PS_RX_P_EN) != 0; 1720 sky2->flow_status = sky2_flow(aux & PHY_M_PS_RX_P_EN,
1732 sky2->tx_pause = (aux & PHY_M_PS_TX_P_EN) != 0; 1721 aux & PHY_M_PS_TX_P_EN);
1733 1722
1734 if (sky2->duplex == DUPLEX_HALF && sky2->speed != SPEED_1000 1723 if (sky2->duplex == DUPLEX_HALF && sky2->speed < SPEED_1000
1735 && hw->chip_id != CHIP_ID_YUKON_EC_U) 1724 && hw->chip_id != CHIP_ID_YUKON_EC_U)
1736 sky2->rx_pause = sky2->tx_pause = 0; 1725 sky2->flow_status = FC_NONE;
1737 1726
1738 if (sky2->rx_pause || sky2->tx_pause) 1727 if (aux & PHY_M_PS_RX_P_EN)
1739 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON); 1728 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON);
1740 else 1729 else
1741 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); 1730 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
@@ -1750,13 +1739,13 @@ static void sky2_phy_intr(struct sky2_hw *hw, unsigned port)
1750 struct sky2_port *sky2 = netdev_priv(dev); 1739 struct sky2_port *sky2 = netdev_priv(dev);
1751 u16 istatus, phystat; 1740 u16 istatus, phystat;
1752 1741
1742 if (!netif_running(dev))
1743 return;
1744
1753 spin_lock(&sky2->phy_lock); 1745 spin_lock(&sky2->phy_lock);
1754 istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT); 1746 istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT);
1755 phystat = gm_phy_read(hw, port, PHY_MARV_PHY_STAT); 1747 phystat = gm_phy_read(hw, port, PHY_MARV_PHY_STAT);
1756 1748
1757 if (!netif_running(dev))
1758 goto out;
1759
1760 if (netif_msg_intr(sky2)) 1749 if (netif_msg_intr(sky2))
1761 printk(KERN_INFO PFX "%s: phy interrupt status 0x%x 0x%x\n", 1750 printk(KERN_INFO PFX "%s: phy interrupt status 0x%x 0x%x\n",
1762 sky2->netdev->name, istatus, phystat); 1751 sky2->netdev->name, istatus, phystat);
@@ -2016,6 +2005,10 @@ oversize:
2016 2005
2017error: 2006error:
2018 ++sky2->net_stats.rx_errors; 2007 ++sky2->net_stats.rx_errors;
2008 if (status & GMR_FS_RX_FF_OV) {
2009 sky2->net_stats.rx_fifo_errors++;
2010 goto resubmit;
2011 }
2019 2012
2020 if (netif_msg_rx_err(sky2) && net_ratelimit()) 2013 if (netif_msg_rx_err(sky2) && net_ratelimit())
2021 printk(KERN_INFO PFX "%s: rx error, status 0x%x length %d\n", 2014 printk(KERN_INFO PFX "%s: rx error, status 0x%x length %d\n",
@@ -2027,8 +2020,6 @@ error:
2027 sky2->net_stats.rx_frame_errors++; 2020 sky2->net_stats.rx_frame_errors++;
2028 if (status & GMR_FS_CRC_ERR) 2021 if (status & GMR_FS_CRC_ERR)
2029 sky2->net_stats.rx_crc_errors++; 2022 sky2->net_stats.rx_crc_errors++;
2030 if (status & GMR_FS_RX_FF_OV)
2031 sky2->net_stats.rx_fifo_errors++;
2032 2023
2033 goto resubmit; 2024 goto resubmit;
2034} 2025}
@@ -2748,7 +2739,7 @@ static int sky2_nway_reset(struct net_device *dev)
2748{ 2739{
2749 struct sky2_port *sky2 = netdev_priv(dev); 2740 struct sky2_port *sky2 = netdev_priv(dev);
2750 2741
2751 if (sky2->autoneg != AUTONEG_ENABLE) 2742 if (!netif_running(dev) || sky2->autoneg != AUTONEG_ENABLE)
2752 return -EINVAL; 2743 return -EINVAL;
2753 2744
2754 sky2_phy_reinit(sky2); 2745 sky2_phy_reinit(sky2);
@@ -2850,6 +2841,14 @@ static int sky2_set_mac_address(struct net_device *dev, void *p)
2850 return 0; 2841 return 0;
2851} 2842}
2852 2843
2844static void inline sky2_add_filter(u8 filter[8], const u8 *addr)
2845{
2846 u32 bit;
2847
2848 bit = ether_crc(ETH_ALEN, addr) & 63;
2849 filter[bit >> 3] |= 1 << (bit & 7);
2850}
2851
2853static void sky2_set_multicast(struct net_device *dev) 2852static void sky2_set_multicast(struct net_device *dev)
2854{ 2853{
2855 struct sky2_port *sky2 = netdev_priv(dev); 2854 struct sky2_port *sky2 = netdev_priv(dev);
@@ -2858,7 +2857,10 @@ static void sky2_set_multicast(struct net_device *dev)
2858 struct dev_mc_list *list = dev->mc_list; 2857 struct dev_mc_list *list = dev->mc_list;
2859 u16 reg; 2858 u16 reg;
2860 u8 filter[8]; 2859 u8 filter[8];
2860 int rx_pause;
2861 static const u8 pause_mc_addr[ETH_ALEN] = { 0x1, 0x80, 0xc2, 0x0, 0x0, 0x1 };
2861 2862
2863 rx_pause = (sky2->flow_status == FC_RX || sky2->flow_status == FC_BOTH);
2862 memset(filter, 0, sizeof(filter)); 2864 memset(filter, 0, sizeof(filter));
2863 2865
2864 reg = gma_read16(hw, port, GM_RX_CTRL); 2866 reg = gma_read16(hw, port, GM_RX_CTRL);
@@ -2866,18 +2868,19 @@ static void sky2_set_multicast(struct net_device *dev)
2866 2868
2867 if (dev->flags & IFF_PROMISC) /* promiscuous */ 2869 if (dev->flags & IFF_PROMISC) /* promiscuous */
2868 reg &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); 2870 reg &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA);
2869 else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > 16) /* all multicast */ 2871 else if (dev->flags & IFF_ALLMULTI)
2870 memset(filter, 0xff, sizeof(filter)); 2872 memset(filter, 0xff, sizeof(filter));
2871 else if (dev->mc_count == 0) /* no multicast */ 2873 else if (dev->mc_count == 0 && !rx_pause)
2872 reg &= ~GM_RXCR_MCF_ENA; 2874 reg &= ~GM_RXCR_MCF_ENA;
2873 else { 2875 else {
2874 int i; 2876 int i;
2875 reg |= GM_RXCR_MCF_ENA; 2877 reg |= GM_RXCR_MCF_ENA;
2876 2878
2877 for (i = 0; list && i < dev->mc_count; i++, list = list->next) { 2879 if (rx_pause)
2878 u32 bit = ether_crc(ETH_ALEN, list->dmi_addr) & 0x3f; 2880 sky2_add_filter(filter, pause_mc_addr);
2879 filter[bit / 8] |= 1 << (bit % 8); 2881
2880 } 2882 for (i = 0; list && i < dev->mc_count; i++, list = list->next)
2883 sky2_add_filter(filter, list->dmi_addr);
2881 } 2884 }
2882 2885
2883 gma_write16(hw, port, GM_MC_ADDR_H1, 2886 gma_write16(hw, port, GM_MC_ADDR_H1,
@@ -2990,8 +2993,20 @@ static void sky2_get_pauseparam(struct net_device *dev,
2990{ 2993{
2991 struct sky2_port *sky2 = netdev_priv(dev); 2994 struct sky2_port *sky2 = netdev_priv(dev);
2992 2995
2993 ecmd->tx_pause = sky2->tx_pause; 2996 switch (sky2->flow_mode) {
2994 ecmd->rx_pause = sky2->rx_pause; 2997 case FC_NONE:
2998 ecmd->tx_pause = ecmd->rx_pause = 0;
2999 break;
3000 case FC_TX:
3001 ecmd->tx_pause = 1, ecmd->rx_pause = 0;
3002 break;
3003 case FC_RX:
3004 ecmd->tx_pause = 0, ecmd->rx_pause = 1;
3005 break;
3006 case FC_BOTH:
3007 ecmd->tx_pause = ecmd->rx_pause = 1;
3008 }
3009
2995 ecmd->autoneg = sky2->autoneg; 3010 ecmd->autoneg = sky2->autoneg;
2996} 3011}
2997 3012
@@ -3001,10 +3016,10 @@ static int sky2_set_pauseparam(struct net_device *dev,
3001 struct sky2_port *sky2 = netdev_priv(dev); 3016 struct sky2_port *sky2 = netdev_priv(dev);
3002 3017
3003 sky2->autoneg = ecmd->autoneg; 3018 sky2->autoneg = ecmd->autoneg;
3004 sky2->tx_pause = ecmd->tx_pause != 0; 3019 sky2->flow_mode = sky2_flow(ecmd->rx_pause, ecmd->tx_pause);
3005 sky2->rx_pause = ecmd->rx_pause != 0;
3006 3020
3007 sky2_phy_reinit(sky2); 3021 if (netif_running(dev))
3022 sky2_phy_reinit(sky2);
3008 3023
3009 return 0; 3024 return 0;
3010} 3025}
@@ -3234,8 +3249,8 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
3234 3249
3235 /* Auto speed and flow control */ 3250 /* Auto speed and flow control */
3236 sky2->autoneg = AUTONEG_ENABLE; 3251 sky2->autoneg = AUTONEG_ENABLE;
3237 sky2->tx_pause = 1; 3252 sky2->flow_mode = FC_BOTH;
3238 sky2->rx_pause = 1; 3253
3239 sky2->duplex = -1; 3254 sky2->duplex = -1;
3240 sky2->speed = -1; 3255 sky2->speed = -1;
3241 sky2->advertising = sky2_supported_modes(hw); 3256 sky2->advertising = sky2_supported_modes(hw);
@@ -3326,9 +3341,8 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
3326 3341
3327 if (!hw->msi_detected) { 3342 if (!hw->msi_detected) {
3328 /* MSI test failed, go back to INTx mode */ 3343 /* MSI test failed, go back to INTx mode */
3329 printk(KERN_WARNING PFX "%s: No interrupt was generated using MSI, " 3344 printk(KERN_INFO PFX "%s: No interrupt generated using MSI, "
3330 "switching to INTx mode. Please report this failure to " 3345 "switching to INTx mode.\n",
3331 "the PCI maintainer and include system chipset information.\n",
3332 pci_name(pdev)); 3346 pci_name(pdev));
3333 3347
3334 err = -EOPNOTSUPP; 3348 err = -EOPNOTSUPP;
@@ -3336,6 +3350,7 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
3336 } 3350 }
3337 3351
3338 sky2_write32(hw, B0_IMSK, 0); 3352 sky2_write32(hw, B0_IMSK, 0);
3353 sky2_read32(hw, B0_IMSK);
3339 3354
3340 free_irq(pdev->irq, hw); 3355 free_irq(pdev->irq, hw);
3341 3356
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 43d2accf60e1..6d2a23f66c9a 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1576,7 +1576,7 @@ enum {
1576 1576
1577 GMR_FS_ANY_ERR = GMR_FS_RX_FF_OV | GMR_FS_CRC_ERR | 1577 GMR_FS_ANY_ERR = GMR_FS_RX_FF_OV | GMR_FS_CRC_ERR |
1578 GMR_FS_FRAGMENT | GMR_FS_LONG_ERR | 1578 GMR_FS_FRAGMENT | GMR_FS_LONG_ERR |
1579 GMR_FS_MII_ERR | GMR_FS_BAD_FC | 1579 GMR_FS_MII_ERR | GMR_FS_GOOD_FC | GMR_FS_BAD_FC |
1580 GMR_FS_UN_SIZE | GMR_FS_JABBER, 1580 GMR_FS_UN_SIZE | GMR_FS_JABBER,
1581}; 1581};
1582 1582
@@ -1828,6 +1828,13 @@ struct rx_ring_info {
1828 dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT]; 1828 dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT];
1829}; 1829};
1830 1830
1831enum flow_control {
1832 FC_NONE = 0,
1833 FC_TX = 1,
1834 FC_RX = 2,
1835 FC_BOTH = 3,
1836};
1837
1831struct sky2_port { 1838struct sky2_port {
1832 struct sky2_hw *hw; 1839 struct sky2_hw *hw;
1833 struct net_device *netdev; 1840 struct net_device *netdev;
@@ -1860,13 +1867,13 @@ struct sky2_port {
1860 1867
1861 dma_addr_t rx_le_map; 1868 dma_addr_t rx_le_map;
1862 dma_addr_t tx_le_map; 1869 dma_addr_t tx_le_map;
1863 u32 advertising; /* ADVERTISED_ bits */ 1870 u16 advertising; /* ADVERTISED_ bits */
1864 u16 speed; /* SPEED_1000, SPEED_100, ... */ 1871 u16 speed; /* SPEED_1000, SPEED_100, ... */
1865 u8 autoneg; /* AUTONEG_ENABLE, AUTONEG_DISABLE */ 1872 u8 autoneg; /* AUTONEG_ENABLE, AUTONEG_DISABLE */
1866 u8 duplex; /* DUPLEX_HALF, DUPLEX_FULL */ 1873 u8 duplex; /* DUPLEX_HALF, DUPLEX_FULL */
1867 u8 rx_pause;
1868 u8 tx_pause;
1869 u8 rx_csum; 1874 u8 rx_csum;
1875 enum flow_control flow_mode;
1876 enum flow_control flow_status;
1870 1877
1871 struct net_device_stats net_stats; 1878 struct net_device_stats net_stats;
1872 1879
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 0c9f1e7dab2e..a8640169fc77 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -416,6 +416,24 @@ static inline void LPD7_SMC_outsw (unsigned char* a, int r,
416 416
417#define SMC_IRQ_FLAGS (0) 417#define SMC_IRQ_FLAGS (0)
418 418
419#elif defined(CONFIG_ARCH_VERSATILE)
420
421#define SMC_CAN_USE_8BIT 1
422#define SMC_CAN_USE_16BIT 1
423#define SMC_CAN_USE_32BIT 1
424#define SMC_NOWAIT 1
425
426#define SMC_inb(a, r) readb((a) + (r))
427#define SMC_inw(a, r) readw((a) + (r))
428#define SMC_inl(a, r) readl((a) + (r))
429#define SMC_outb(v, a, r) writeb(v, (a) + (r))
430#define SMC_outw(v, a, r) writew(v, (a) + (r))
431#define SMC_outl(v, a, r) writel(v, (a) + (r))
432#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
433#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l)
434
435#define SMC_IRQ_FLAGS (0)
436
419#else 437#else
420 438
421#define SMC_CAN_USE_8BIT 1 439#define SMC_CAN_USE_8BIT 1
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index 6439b0cef1e4..18f88853e1e5 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -42,7 +42,7 @@
42#define DRV_RELDATE "11/24/03" 42#define DRV_RELDATE "11/24/03"
43#define DRV_AUTHOR "David S. Miller (davem@redhat.com)" 43#define DRV_AUTHOR "David S. Miller (davem@redhat.com)"
44 44
45static char version[] __initdata = 45static char version[] =
46 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; 46 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
47 47
48MODULE_VERSION(DRV_VERSION); 48MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 327836b1014e..8e398499c045 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -68,8 +68,8 @@
68 68
69#define DRV_MODULE_NAME "tg3" 69#define DRV_MODULE_NAME "tg3"
70#define PFX DRV_MODULE_NAME ": " 70#define PFX DRV_MODULE_NAME ": "
71#define DRV_MODULE_VERSION "3.66" 71#define DRV_MODULE_VERSION "3.67"
72#define DRV_MODULE_RELDATE "September 23, 2006" 72#define DRV_MODULE_RELDATE "October 18, 2006"
73 73
74#define TG3_DEF_MAC_MODE 0 74#define TG3_DEF_MAC_MODE 0
75#define TG3_DEF_RX_MODE 0 75#define TG3_DEF_RX_MODE 0
@@ -129,7 +129,7 @@
129#define RX_JUMBO_PKT_BUF_SZ (9046 + tp->rx_offset + 64) 129#define RX_JUMBO_PKT_BUF_SZ (9046 + tp->rx_offset + 64)
130 130
131/* minimum number of free TX descriptors required to wake up TX process */ 131/* minimum number of free TX descriptors required to wake up TX process */
132#define TG3_TX_WAKEUP_THRESH (TG3_TX_RING_SIZE / 4) 132#define TG3_TX_WAKEUP_THRESH(tp) ((tp)->tx_pending / 4)
133 133
134/* number of ETHTOOL_GSTATS u64's */ 134/* number of ETHTOOL_GSTATS u64's */
135#define TG3_NUM_STATS (sizeof(struct tg3_ethtool_stats)/sizeof(u64)) 135#define TG3_NUM_STATS (sizeof(struct tg3_ethtool_stats)/sizeof(u64))
@@ -3075,10 +3075,10 @@ static void tg3_tx(struct tg3 *tp)
3075 smp_mb(); 3075 smp_mb();
3076 3076
3077 if (unlikely(netif_queue_stopped(tp->dev) && 3077 if (unlikely(netif_queue_stopped(tp->dev) &&
3078 (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH))) { 3078 (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH(tp)))) {
3079 netif_tx_lock(tp->dev); 3079 netif_tx_lock(tp->dev);
3080 if (netif_queue_stopped(tp->dev) && 3080 if (netif_queue_stopped(tp->dev) &&
3081 (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH)) 3081 (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH(tp)))
3082 netif_wake_queue(tp->dev); 3082 netif_wake_queue(tp->dev);
3083 netif_tx_unlock(tp->dev); 3083 netif_tx_unlock(tp->dev);
3084 } 3084 }
@@ -3928,7 +3928,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3928 tp->tx_prod = entry; 3928 tp->tx_prod = entry;
3929 if (unlikely(tg3_tx_avail(tp) <= (MAX_SKB_FRAGS + 1))) { 3929 if (unlikely(tg3_tx_avail(tp) <= (MAX_SKB_FRAGS + 1))) {
3930 netif_stop_queue(dev); 3930 netif_stop_queue(dev);
3931 if (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH) 3931 if (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH(tp))
3932 netif_wake_queue(tp->dev); 3932 netif_wake_queue(tp->dev);
3933 } 3933 }
3934 3934
@@ -4143,7 +4143,7 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
4143 tp->tx_prod = entry; 4143 tp->tx_prod = entry;
4144 if (unlikely(tg3_tx_avail(tp) <= (MAX_SKB_FRAGS + 1))) { 4144 if (unlikely(tg3_tx_avail(tp) <= (MAX_SKB_FRAGS + 1))) {
4145 netif_stop_queue(dev); 4145 netif_stop_queue(dev);
4146 if (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH) 4146 if (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH(tp))
4147 netif_wake_queue(tp->dev); 4147 netif_wake_queue(tp->dev);
4148 } 4148 }
4149 4149
@@ -8106,7 +8106,10 @@ static int tg3_set_ringparam(struct net_device *dev, struct ethtool_ringparam *e
8106 8106
8107 if ((ering->rx_pending > TG3_RX_RING_SIZE - 1) || 8107 if ((ering->rx_pending > TG3_RX_RING_SIZE - 1) ||
8108 (ering->rx_jumbo_pending > TG3_RX_JUMBO_RING_SIZE - 1) || 8108 (ering->rx_jumbo_pending > TG3_RX_JUMBO_RING_SIZE - 1) ||
8109 (ering->tx_pending > TG3_TX_RING_SIZE - 1)) 8109 (ering->tx_pending > TG3_TX_RING_SIZE - 1) ||
8110 (ering->tx_pending <= MAX_SKB_FRAGS) ||
8111 ((tp->tg3_flags2 & TG3_FLG2_HW_TSO_1_BUG) &&
8112 (ering->tx_pending <= (MAX_SKB_FRAGS * 3))))
8110 return -EINVAL; 8113 return -EINVAL;
8111 8114
8112 if (netif_running(dev)) { 8115 if (netif_running(dev)) {
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 12cd7b561f35..b37888011067 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -2,14 +2,11 @@
2 * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved. 2 * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.
3 * 3 *
4 * Author: Shlomi Gridish <gridish@freescale.com> 4 * Author: Shlomi Gridish <gridish@freescale.com>
5 * Li Yang <leoli@freescale.com>
5 * 6 *
6 * Description: 7 * Description:
7 * QE UCC Gigabit Ethernet Driver 8 * QE UCC Gigabit Ethernet Driver
8 * 9 *
9 * Changelog:
10 * Jul 6, 2006 Li Yang <LeoLi@freescale.com>
11 * - Rearrange code and style fixes
12 *
13 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the 11 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your 12 * Free Software Foundation; either version 2 of the License, or (at your
@@ -31,9 +28,9 @@
31#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
32#include <linux/fsl_devices.h> 29#include <linux/fsl_devices.h>
33#include <linux/ethtool.h> 30#include <linux/ethtool.h>
34#include <linux/platform_device.h>
35#include <linux/mii.h> 31#include <linux/mii.h>
36 32
33#include <asm/of_device.h>
37#include <asm/uaccess.h> 34#include <asm/uaccess.h>
38#include <asm/irq.h> 35#include <asm/irq.h>
39#include <asm/io.h> 36#include <asm/io.h>
@@ -70,7 +67,7 @@
70 67
71static DEFINE_SPINLOCK(ugeth_lock); 68static DEFINE_SPINLOCK(ugeth_lock);
72 69
73static ucc_geth_info_t ugeth_primary_info = { 70static struct ucc_geth_info ugeth_primary_info = {
74 .uf_info = { 71 .uf_info = {
75 .bd_mem_part = MEM_PART_SYSTEM, 72 .bd_mem_part = MEM_PART_SYSTEM,
76 .rtsm = UCC_FAST_SEND_IDLES_BETWEEN_FRAMES, 73 .rtsm = UCC_FAST_SEND_IDLES_BETWEEN_FRAMES,
@@ -163,7 +160,7 @@ static ucc_geth_info_t ugeth_primary_info = {
163 .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2, 160 .riscRx = QE_RISC_ALLOCATION_RISC1_AND_RISC2,
164}; 161};
165 162
166static ucc_geth_info_t ugeth_info[8]; 163static struct ucc_geth_info ugeth_info[8];
167 164
168#ifdef DEBUG 165#ifdef DEBUG
169static void mem_disp(u8 *addr, int size) 166static void mem_disp(u8 *addr, int size)
@@ -219,8 +216,8 @@ static struct list_head *dequeue(struct list_head *lh)
219 } 216 }
220} 217}
221 218
222static int get_interface_details(enet_interface_e enet_interface, 219static int get_interface_details(enum enet_interface enet_interface,
223 enet_speed_e *speed, 220 enum enet_speed *speed,
224 int *r10m, 221 int *r10m,
225 int *rmm, 222 int *rmm,
226 int *rpm, 223 int *rpm,
@@ -283,7 +280,7 @@ static int get_interface_details(enet_interface_e enet_interface,
283 return 0; 280 return 0;
284} 281}
285 282
286static struct sk_buff *get_new_skb(ucc_geth_private_t *ugeth, u8 *bd) 283static struct sk_buff *get_new_skb(struct ucc_geth_private *ugeth, u8 *bd)
287{ 284{
288 struct sk_buff *skb = NULL; 285 struct sk_buff *skb = NULL;
289 286
@@ -303,21 +300,19 @@ static struct sk_buff *get_new_skb(ucc_geth_private_t *ugeth, u8 *bd)
303 300
304 skb->dev = ugeth->dev; 301 skb->dev = ugeth->dev;
305 302
306 BD_BUFFER_SET(bd, 303 out_be32(&((struct qe_bd *)bd)->buf,
307 dma_map_single(NULL, 304 dma_map_single(NULL,
308 skb->data, 305 skb->data,
309 ugeth->ug_info->uf_info.max_rx_buf_length + 306 ugeth->ug_info->uf_info.max_rx_buf_length +
310 UCC_GETH_RX_DATA_BUF_ALIGNMENT, 307 UCC_GETH_RX_DATA_BUF_ALIGNMENT,
311 DMA_FROM_DEVICE)); 308 DMA_FROM_DEVICE));
312 309
313 BD_STATUS_AND_LENGTH_SET(bd, 310 out_be32((u32 *)bd, (R_E | R_I | (in_be32((u32 *)bd) & R_W)));
314 (R_E | R_I |
315 (BD_STATUS_AND_LENGTH(bd) & R_W)));
316 311
317 return skb; 312 return skb;
318} 313}
319 314
320static int rx_bd_buffer_set(ucc_geth_private_t *ugeth, u8 rxQ) 315static int rx_bd_buffer_set(struct ucc_geth_private *ugeth, u8 rxQ)
321{ 316{
322 u8 *bd; 317 u8 *bd;
323 u32 bd_status; 318 u32 bd_status;
@@ -328,7 +323,7 @@ static int rx_bd_buffer_set(ucc_geth_private_t *ugeth, u8 rxQ)
328 i = 0; 323 i = 0;
329 324
330 do { 325 do {
331 bd_status = BD_STATUS_AND_LENGTH(bd); 326 bd_status = in_be32((u32*)bd);
332 skb = get_new_skb(ugeth, bd); 327 skb = get_new_skb(ugeth, bd);
333 328
334 if (!skb) /* If can not allocate data buffer, 329 if (!skb) /* If can not allocate data buffer,
@@ -338,19 +333,19 @@ static int rx_bd_buffer_set(ucc_geth_private_t *ugeth, u8 rxQ)
338 ugeth->rx_skbuff[rxQ][i] = skb; 333 ugeth->rx_skbuff[rxQ][i] = skb;
339 334
340 /* advance the BD pointer */ 335 /* advance the BD pointer */
341 bd += UCC_GETH_SIZE_OF_BD; 336 bd += sizeof(struct qe_bd);
342 i++; 337 i++;
343 } while (!(bd_status & R_W)); 338 } while (!(bd_status & R_W));
344 339
345 return 0; 340 return 0;
346} 341}
347 342
348static int fill_init_enet_entries(ucc_geth_private_t *ugeth, 343static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
349 volatile u32 *p_start, 344 volatile u32 *p_start,
350 u8 num_entries, 345 u8 num_entries,
351 u32 thread_size, 346 u32 thread_size,
352 u32 thread_alignment, 347 u32 thread_alignment,
353 qe_risc_allocation_e risc, 348 enum qe_risc_allocation risc,
354 int skip_page_for_first_entry) 349 int skip_page_for_first_entry)
355{ 350{
356 u32 init_enet_offset; 351 u32 init_enet_offset;
@@ -383,10 +378,10 @@ static int fill_init_enet_entries(ucc_geth_private_t *ugeth,
383 return 0; 378 return 0;
384} 379}
385 380
386static int return_init_enet_entries(ucc_geth_private_t *ugeth, 381static int return_init_enet_entries(struct ucc_geth_private *ugeth,
387 volatile u32 *p_start, 382 volatile u32 *p_start,
388 u8 num_entries, 383 u8 num_entries,
389 qe_risc_allocation_e risc, 384 enum qe_risc_allocation risc,
390 int skip_page_for_first_entry) 385 int skip_page_for_first_entry)
391{ 386{
392 u32 init_enet_offset; 387 u32 init_enet_offset;
@@ -416,11 +411,11 @@ static int return_init_enet_entries(ucc_geth_private_t *ugeth,
416} 411}
417 412
418#ifdef DEBUG 413#ifdef DEBUG
419static int dump_init_enet_entries(ucc_geth_private_t *ugeth, 414static int dump_init_enet_entries(struct ucc_geth_private *ugeth,
420 volatile u32 *p_start, 415 volatile u32 *p_start,
421 u8 num_entries, 416 u8 num_entries,
422 u32 thread_size, 417 u32 thread_size,
423 qe_risc_allocation_e risc, 418 enum qe_risc_allocation risc,
424 int skip_page_for_first_entry) 419 int skip_page_for_first_entry)
425{ 420{
426 u32 init_enet_offset; 421 u32 init_enet_offset;
@@ -456,14 +451,14 @@ static int dump_init_enet_entries(ucc_geth_private_t *ugeth,
456#endif 451#endif
457 452
458#ifdef CONFIG_UGETH_FILTERING 453#ifdef CONFIG_UGETH_FILTERING
459static enet_addr_container_t *get_enet_addr_container(void) 454static struct enet_addr_container *get_enet_addr_container(void)
460{ 455{
461 enet_addr_container_t *enet_addr_cont; 456 struct enet_addr_container *enet_addr_cont;
462 457
463 /* allocate memory */ 458 /* allocate memory */
464 enet_addr_cont = kmalloc(sizeof(enet_addr_container_t), GFP_KERNEL); 459 enet_addr_cont = kmalloc(sizeof(struct enet_addr_container), GFP_KERNEL);
465 if (!enet_addr_cont) { 460 if (!enet_addr_cont) {
466 ugeth_err("%s: No memory for enet_addr_container_t object.", 461 ugeth_err("%s: No memory for enet_addr_container object.",
467 __FUNCTION__); 462 __FUNCTION__);
468 return NULL; 463 return NULL;
469 } 464 }
@@ -472,45 +467,43 @@ static enet_addr_container_t *get_enet_addr_container(void)
472} 467}
473#endif /* CONFIG_UGETH_FILTERING */ 468#endif /* CONFIG_UGETH_FILTERING */
474 469
475static void put_enet_addr_container(enet_addr_container_t *enet_addr_cont) 470static void put_enet_addr_container(struct enet_addr_container *enet_addr_cont)
476{ 471{
477 kfree(enet_addr_cont); 472 kfree(enet_addr_cont);
478} 473}
479 474
475static int set_mac_addr(__be16 __iomem *reg, u8 *mac)
476{
477 out_be16(&reg[0], ((u16)mac[5] << 8) | mac[4]);
478 out_be16(&reg[1], ((u16)mac[3] << 8) | mac[2]);
479 out_be16(&reg[2], ((u16)mac[1] << 8) | mac[0]);
480}
481
480#ifdef CONFIG_UGETH_FILTERING 482#ifdef CONFIG_UGETH_FILTERING
481static int hw_add_addr_in_paddr(ucc_geth_private_t *ugeth, 483static int hw_add_addr_in_paddr(struct ucc_geth_private *ugeth,
482 enet_addr_t *p_enet_addr, u8 paddr_num) 484 u8 *p_enet_addr, u8 paddr_num)
483{ 485{
484 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 486 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
485 487
486 if (!(paddr_num < NUM_OF_PADDRS)) { 488 if (!(paddr_num < NUM_OF_PADDRS)) {
487 ugeth_warn("%s: Illagel paddr_num.", __FUNCTION__); 489 ugeth_warn("%s: Illegal paddr_num.", __FUNCTION__);
488 return -EINVAL; 490 return -EINVAL;
489 } 491 }
490 492
491 p_82xx_addr_filt = 493 p_82xx_addr_filt =
492 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 494 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
493 addressfiltering; 495 addressfiltering;
494 496
495 /* Ethernet frames are defined in Little Endian mode, */ 497 /* Ethernet frames are defined in Little Endian mode, */
496 /* therefore to insert the address we reverse the bytes. */ 498 /* therefore to insert the address we reverse the bytes. */
497 out_be16(&p_82xx_addr_filt->paddr[paddr_num].h, 499 set_mac_addr(&p_82xx_addr_filt->paddr[paddr_num].h, p_enet_addr);
498 (u16) (((u16) (((u16) ((*p_enet_addr)[5])) << 8)) |
499 (u16) (*p_enet_addr)[4]));
500 out_be16(&p_82xx_addr_filt->paddr[paddr_num].m,
501 (u16) (((u16) (((u16) ((*p_enet_addr)[3])) << 8)) |
502 (u16) (*p_enet_addr)[2]));
503 out_be16(&p_82xx_addr_filt->paddr[paddr_num].l,
504 (u16) (((u16) (((u16) ((*p_enet_addr)[1])) << 8)) |
505 (u16) (*p_enet_addr)[0]));
506
507 return 0; 500 return 0;
508} 501}
509#endif /* CONFIG_UGETH_FILTERING */ 502#endif /* CONFIG_UGETH_FILTERING */
510 503
511static int hw_clear_addr_in_paddr(ucc_geth_private_t *ugeth, u8 paddr_num) 504static int hw_clear_addr_in_paddr(struct ucc_geth_private *ugeth, u8 paddr_num)
512{ 505{
513 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 506 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
514 507
515 if (!(paddr_num < NUM_OF_PADDRS)) { 508 if (!(paddr_num < NUM_OF_PADDRS)) {
516 ugeth_warn("%s: Illagel paddr_num.", __FUNCTION__); 509 ugeth_warn("%s: Illagel paddr_num.", __FUNCTION__);
@@ -518,7 +511,7 @@ static int hw_clear_addr_in_paddr(ucc_geth_private_t *ugeth, u8 paddr_num)
518 } 511 }
519 512
520 p_82xx_addr_filt = 513 p_82xx_addr_filt =
521 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 514 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
522 addressfiltering; 515 addressfiltering;
523 516
524 /* Writing address ff.ff.ff.ff.ff.ff disables address 517 /* Writing address ff.ff.ff.ff.ff.ff disables address
@@ -530,14 +523,14 @@ static int hw_clear_addr_in_paddr(ucc_geth_private_t *ugeth, u8 paddr_num)
530 return 0; 523 return 0;
531} 524}
532 525
533static void hw_add_addr_in_hash(ucc_geth_private_t *ugeth, 526static void hw_add_addr_in_hash(struct ucc_geth_private *ugeth,
534 enet_addr_t *p_enet_addr) 527 u8 *p_enet_addr)
535{ 528{
536 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 529 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
537 u32 cecr_subblock; 530 u32 cecr_subblock;
538 531
539 p_82xx_addr_filt = 532 p_82xx_addr_filt =
540 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 533 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
541 addressfiltering; 534 addressfiltering;
542 535
543 cecr_subblock = 536 cecr_subblock =
@@ -546,25 +539,18 @@ static void hw_add_addr_in_hash(ucc_geth_private_t *ugeth,
546 /* Ethernet frames are defined in Little Endian mode, 539 /* Ethernet frames are defined in Little Endian mode,
547 therefor to insert */ 540 therefor to insert */
548 /* the address to the hash (Big Endian mode), we reverse the bytes.*/ 541 /* the address to the hash (Big Endian mode), we reverse the bytes.*/
549 out_be16(&p_82xx_addr_filt->taddr.h, 542
550 (u16) (((u16) (((u16) ((*p_enet_addr)[5])) << 8)) | 543 set_mac_addr(&p_82xx_addr_filt->taddr.h, p_enet_addr);
551 (u16) (*p_enet_addr)[4]));
552 out_be16(&p_82xx_addr_filt->taddr.m,
553 (u16) (((u16) (((u16) ((*p_enet_addr)[3])) << 8)) |
554 (u16) (*p_enet_addr)[2]));
555 out_be16(&p_82xx_addr_filt->taddr.l,
556 (u16) (((u16) (((u16) ((*p_enet_addr)[1])) << 8)) |
557 (u16) (*p_enet_addr)[0]));
558 544
559 qe_issue_cmd(QE_SET_GROUP_ADDRESS, cecr_subblock, 545 qe_issue_cmd(QE_SET_GROUP_ADDRESS, cecr_subblock,
560 (u8) QE_CR_PROTOCOL_ETHERNET, 0); 546 QE_CR_PROTOCOL_ETHERNET, 0);
561} 547}
562 548
563#ifdef CONFIG_UGETH_MAGIC_PACKET 549#ifdef CONFIG_UGETH_MAGIC_PACKET
564static void magic_packet_detection_enable(ucc_geth_private_t *ugeth) 550static void magic_packet_detection_enable(struct ucc_geth_private *ugeth)
565{ 551{
566 ucc_fast_private_t *uccf; 552 struct ucc_fast_private *uccf;
567 ucc_geth_t *ug_regs; 553 struct ucc_geth *ug_regs;
568 u32 maccfg2, uccm; 554 u32 maccfg2, uccm;
569 555
570 uccf = ugeth->uccf; 556 uccf = ugeth->uccf;
@@ -581,10 +567,10 @@ static void magic_packet_detection_enable(ucc_geth_private_t *ugeth)
581 out_be32(&ug_regs->maccfg2, maccfg2); 567 out_be32(&ug_regs->maccfg2, maccfg2);
582} 568}
583 569
584static void magic_packet_detection_disable(ucc_geth_private_t *ugeth) 570static void magic_packet_detection_disable(struct ucc_geth_private *ugeth)
585{ 571{
586 ucc_fast_private_t *uccf; 572 struct ucc_fast_private *uccf;
587 ucc_geth_t *ug_regs; 573 struct ucc_geth *ug_regs;
588 u32 maccfg2, uccm; 574 u32 maccfg2, uccm;
589 575
590 uccf = ugeth->uccf; 576 uccf = ugeth->uccf;
@@ -602,26 +588,26 @@ static void magic_packet_detection_disable(ucc_geth_private_t *ugeth)
602} 588}
603#endif /* MAGIC_PACKET */ 589#endif /* MAGIC_PACKET */
604 590
605static inline int compare_addr(enet_addr_t *addr1, enet_addr_t *addr2) 591static inline int compare_addr(u8 **addr1, u8 **addr2)
606{ 592{
607 return memcmp(addr1, addr2, ENET_NUM_OCTETS_PER_ADDRESS); 593 return memcmp(addr1, addr2, ENET_NUM_OCTETS_PER_ADDRESS);
608} 594}
609 595
610#ifdef DEBUG 596#ifdef DEBUG
611static void get_statistics(ucc_geth_private_t *ugeth, 597static void get_statistics(struct ucc_geth_private *ugeth,
612 ucc_geth_tx_firmware_statistics_t * 598 struct ucc_geth_tx_firmware_statistics *
613 tx_firmware_statistics, 599 tx_firmware_statistics,
614 ucc_geth_rx_firmware_statistics_t * 600 struct ucc_geth_rx_firmware_statistics *
615 rx_firmware_statistics, 601 rx_firmware_statistics,
616 ucc_geth_hardware_statistics_t *hardware_statistics) 602 struct ucc_geth_hardware_statistics *hardware_statistics)
617{ 603{
618 ucc_fast_t *uf_regs; 604 struct ucc_fast *uf_regs;
619 ucc_geth_t *ug_regs; 605 struct ucc_geth *ug_regs;
620 ucc_geth_tx_firmware_statistics_pram_t *p_tx_fw_statistics_pram; 606 struct ucc_geth_tx_firmware_statistics_pram *p_tx_fw_statistics_pram;
621 ucc_geth_rx_firmware_statistics_pram_t *p_rx_fw_statistics_pram; 607 struct ucc_geth_rx_firmware_statistics_pram *p_rx_fw_statistics_pram;
622 608
623 ug_regs = ugeth->ug_regs; 609 ug_regs = ugeth->ug_regs;
624 uf_regs = (ucc_fast_t *) ug_regs; 610 uf_regs = (struct ucc_fast *) ug_regs;
625 p_tx_fw_statistics_pram = ugeth->p_tx_fw_statistics_pram; 611 p_tx_fw_statistics_pram = ugeth->p_tx_fw_statistics_pram;
626 p_rx_fw_statistics_pram = ugeth->p_rx_fw_statistics_pram; 612 p_rx_fw_statistics_pram = ugeth->p_rx_fw_statistics_pram;
627 613
@@ -727,7 +713,7 @@ static void get_statistics(ucc_geth_private_t *ugeth,
727 } 713 }
728} 714}
729 715
730static void dump_bds(ucc_geth_private_t *ugeth) 716static void dump_bds(struct ucc_geth_private *ugeth)
731{ 717{
732 int i; 718 int i;
733 int length; 719 int length;
@@ -736,7 +722,7 @@ static void dump_bds(ucc_geth_private_t *ugeth)
736 if (ugeth->p_tx_bd_ring[i]) { 722 if (ugeth->p_tx_bd_ring[i]) {
737 length = 723 length =
738 (ugeth->ug_info->bdRingLenTx[i] * 724 (ugeth->ug_info->bdRingLenTx[i] *
739 UCC_GETH_SIZE_OF_BD); 725 sizeof(struct qe_bd));
740 ugeth_info("TX BDs[%d]", i); 726 ugeth_info("TX BDs[%d]", i);
741 mem_disp(ugeth->p_tx_bd_ring[i], length); 727 mem_disp(ugeth->p_tx_bd_ring[i], length);
742 } 728 }
@@ -745,14 +731,14 @@ static void dump_bds(ucc_geth_private_t *ugeth)
745 if (ugeth->p_rx_bd_ring[i]) { 731 if (ugeth->p_rx_bd_ring[i]) {
746 length = 732 length =
747 (ugeth->ug_info->bdRingLenRx[i] * 733 (ugeth->ug_info->bdRingLenRx[i] *
748 UCC_GETH_SIZE_OF_BD); 734 sizeof(struct qe_bd));
749 ugeth_info("RX BDs[%d]", i); 735 ugeth_info("RX BDs[%d]", i);
750 mem_disp(ugeth->p_rx_bd_ring[i], length); 736 mem_disp(ugeth->p_rx_bd_ring[i], length);
751 } 737 }
752 } 738 }
753} 739}
754 740
755static void dump_regs(ucc_geth_private_t *ugeth) 741static void dump_regs(struct ucc_geth_private *ugeth)
756{ 742{
757 int i; 743 int i;
758 744
@@ -893,7 +879,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
893 ugeth_info("Base address: 0x%08x", 879 ugeth_info("Base address: 0x%08x",
894 (u32) & ugeth->p_thread_data_tx[i]); 880 (u32) & ugeth->p_thread_data_tx[i]);
895 mem_disp((u8 *) & ugeth->p_thread_data_tx[i], 881 mem_disp((u8 *) & ugeth->p_thread_data_tx[i],
896 sizeof(ucc_geth_thread_data_tx_t)); 882 sizeof(struct ucc_geth_thread_data_tx));
897 } 883 }
898 } 884 }
899 if (ugeth->p_thread_data_rx) { 885 if (ugeth->p_thread_data_rx) {
@@ -927,7 +913,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
927 ugeth_info("Base address: 0x%08x", 913 ugeth_info("Base address: 0x%08x",
928 (u32) & ugeth->p_thread_data_rx[i]); 914 (u32) & ugeth->p_thread_data_rx[i]);
929 mem_disp((u8 *) & ugeth->p_thread_data_rx[i], 915 mem_disp((u8 *) & ugeth->p_thread_data_rx[i],
930 sizeof(ucc_geth_thread_data_rx_t)); 916 sizeof(struct ucc_geth_thread_data_rx));
931 } 917 }
932 } 918 }
933 if (ugeth->p_exf_glbl_param) { 919 if (ugeth->p_exf_glbl_param) {
@@ -1105,7 +1091,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
1105 ugeth_info("Base address: 0x%08x", 1091 ugeth_info("Base address: 0x%08x",
1106 (u32) & ugeth->p_send_q_mem_reg->sqqd[i]); 1092 (u32) & ugeth->p_send_q_mem_reg->sqqd[i]);
1107 mem_disp((u8 *) & ugeth->p_send_q_mem_reg->sqqd[i], 1093 mem_disp((u8 *) & ugeth->p_send_q_mem_reg->sqqd[i],
1108 sizeof(ucc_geth_send_queue_qd_t)); 1094 sizeof(struct ucc_geth_send_queue_qd));
1109 } 1095 }
1110 } 1096 }
1111 if (ugeth->p_scheduler) { 1097 if (ugeth->p_scheduler) {
@@ -1187,7 +1173,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
1187 qe_muram_addr(in_be32 1173 qe_muram_addr(in_be32
1188 (&ugeth->p_rx_bd_qs_tbl[i]. 1174 (&ugeth->p_rx_bd_qs_tbl[i].
1189 bdbaseptr)), 1175 bdbaseptr)),
1190 sizeof(ucc_geth_rx_prefetched_bds_t)); 1176 sizeof(struct ucc_geth_rx_prefetched_bds));
1191 } 1177 }
1192 } 1178 }
1193 if (ugeth->p_init_enet_param_shadow) { 1179 if (ugeth->p_init_enet_param_shadow) {
@@ -1198,7 +1184,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
1198 mem_disp((u8 *) ugeth->p_init_enet_param_shadow, 1184 mem_disp((u8 *) ugeth->p_init_enet_param_shadow,
1199 sizeof(*ugeth->p_init_enet_param_shadow)); 1185 sizeof(*ugeth->p_init_enet_param_shadow));
1200 1186
1201 size = sizeof(ucc_geth_thread_rx_pram_t); 1187 size = sizeof(struct ucc_geth_thread_rx_pram);
1202 if (ugeth->ug_info->rxExtendedFiltering) { 1188 if (ugeth->ug_info->rxExtendedFiltering) {
1203 size += 1189 size +=
1204 THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING; 1190 THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING;
@@ -1216,7 +1202,7 @@ static void dump_regs(ucc_geth_private_t *ugeth)
1216 &(ugeth->p_init_enet_param_shadow-> 1202 &(ugeth->p_init_enet_param_shadow->
1217 txthread[0]), 1203 txthread[0]),
1218 ENET_INIT_PARAM_MAX_ENTRIES_TX, 1204 ENET_INIT_PARAM_MAX_ENTRIES_TX,
1219 sizeof(ucc_geth_thread_tx_pram_t), 1205 sizeof(struct ucc_geth_thread_tx_pram),
1220 ugeth->ug_info->riscTx, 0); 1206 ugeth->ug_info->riscTx, 0);
1221 dump_init_enet_entries(ugeth, 1207 dump_init_enet_entries(ugeth,
1222 &(ugeth->p_init_enet_param_shadow-> 1208 &(ugeth->p_init_enet_param_shadow->
@@ -1578,12 +1564,12 @@ static int init_min_frame_len(u16 min_frame_length,
1578 return 0; 1564 return 0;
1579} 1565}
1580 1566
1581static int adjust_enet_interface(ucc_geth_private_t *ugeth) 1567static int adjust_enet_interface(struct ucc_geth_private *ugeth)
1582{ 1568{
1583 ucc_geth_info_t *ug_info; 1569 struct ucc_geth_info *ug_info;
1584 ucc_geth_t *ug_regs; 1570 struct ucc_geth *ug_regs;
1585 ucc_fast_t *uf_regs; 1571 struct ucc_fast *uf_regs;
1586 enet_speed_e speed; 1572 enum enet_speed speed;
1587 int ret_val, rpm = 0, tbi = 0, r10m = 0, rmm = 1573 int ret_val, rpm = 0, tbi = 0, r10m = 0, rmm =
1588 0, limited_to_full_duplex = 0; 1574 0, limited_to_full_duplex = 0;
1589 u32 upsmr, maccfg2, utbipar, tbiBaseAddress; 1575 u32 upsmr, maccfg2, utbipar, tbiBaseAddress;
@@ -1691,8 +1677,8 @@ static int adjust_enet_interface(ucc_geth_private_t *ugeth)
1691 */ 1677 */
1692static void adjust_link(struct net_device *dev) 1678static void adjust_link(struct net_device *dev)
1693{ 1679{
1694 ucc_geth_private_t *ugeth = netdev_priv(dev); 1680 struct ucc_geth_private *ugeth = netdev_priv(dev);
1695 ucc_geth_t *ug_regs; 1681 struct ucc_geth *ug_regs;
1696 u32 tempval; 1682 u32 tempval;
1697 struct ugeth_mii_info *mii_info = ugeth->mii_info; 1683 struct ugeth_mii_info *mii_info = ugeth->mii_info;
1698 1684
@@ -1722,7 +1708,7 @@ static void adjust_link(struct net_device *dev)
1722 if (mii_info->speed != ugeth->oldspeed) { 1708 if (mii_info->speed != ugeth->oldspeed) {
1723 switch (mii_info->speed) { 1709 switch (mii_info->speed) {
1724 case 1000: 1710 case 1000:
1725#ifdef CONFIG_MPC836x 1711#ifdef CONFIG_PPC_MPC836x
1726/* FIXME: This code is for 100Mbs BUG fixing, 1712/* FIXME: This code is for 100Mbs BUG fixing,
1727remove this when it is fixed!!! */ 1713remove this when it is fixed!!! */
1728 if (ugeth->ug_info->enet_interface == 1714 if (ugeth->ug_info->enet_interface ==
@@ -1768,7 +1754,7 @@ remove this when it is fixed!!! */
1768 break; 1754 break;
1769 case 100: 1755 case 100:
1770 case 10: 1756 case 10:
1771#ifdef CONFIG_MPC836x 1757#ifdef CONFIG_PPC_MPC836x
1772/* FIXME: This code is for 100Mbs BUG fixing, 1758/* FIXME: This code is for 100Mbs BUG fixing,
1773remove this lines when it will be fixed!!! */ 1759remove this lines when it will be fixed!!! */
1774 ugeth->ug_info->enet_interface = ENET_100_RGMII; 1760 ugeth->ug_info->enet_interface = ENET_100_RGMII;
@@ -1827,9 +1813,9 @@ remove this lines when it will be fixed!!! */
1827 */ 1813 */
1828static int init_phy(struct net_device *dev) 1814static int init_phy(struct net_device *dev)
1829{ 1815{
1830 ucc_geth_private_t *ugeth = netdev_priv(dev); 1816 struct ucc_geth_private *ugeth = netdev_priv(dev);
1831 struct phy_info *curphy; 1817 struct phy_info *curphy;
1832 ucc_mii_mng_t *mii_regs; 1818 struct ucc_mii_mng *mii_regs;
1833 struct ugeth_mii_info *mii_info; 1819 struct ugeth_mii_info *mii_info;
1834 int err; 1820 int err;
1835 1821
@@ -1914,17 +1900,17 @@ static int init_phy(struct net_device *dev)
1914} 1900}
1915 1901
1916#ifdef CONFIG_UGETH_TX_ON_DEMOND 1902#ifdef CONFIG_UGETH_TX_ON_DEMOND
1917static int ugeth_transmit_on_demand(ucc_geth_private_t *ugeth) 1903static int ugeth_transmit_on_demand(struct ucc_geth_private *ugeth)
1918{ 1904{
1919 ucc_fast_transmit_on_demand(ugeth->uccf); 1905 struct ucc_fastransmit_on_demand(ugeth->uccf);
1920 1906
1921 return 0; 1907 return 0;
1922} 1908}
1923#endif 1909#endif
1924 1910
1925static int ugeth_graceful_stop_tx(ucc_geth_private_t *ugeth) 1911static int ugeth_graceful_stop_tx(struct ucc_geth_private *ugeth)
1926{ 1912{
1927 ucc_fast_private_t *uccf; 1913 struct ucc_fast_private *uccf;
1928 u32 cecr_subblock; 1914 u32 cecr_subblock;
1929 u32 temp; 1915 u32 temp;
1930 1916
@@ -1940,7 +1926,7 @@ static int ugeth_graceful_stop_tx(ucc_geth_private_t *ugeth)
1940 cecr_subblock = 1926 cecr_subblock =
1941 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num); 1927 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num);
1942 qe_issue_cmd(QE_GRACEFUL_STOP_TX, cecr_subblock, 1928 qe_issue_cmd(QE_GRACEFUL_STOP_TX, cecr_subblock,
1943 (u8) QE_CR_PROTOCOL_ETHERNET, 0); 1929 QE_CR_PROTOCOL_ETHERNET, 0);
1944 1930
1945 /* Wait for command to complete */ 1931 /* Wait for command to complete */
1946 do { 1932 do {
@@ -1952,9 +1938,9 @@ static int ugeth_graceful_stop_tx(ucc_geth_private_t *ugeth)
1952 return 0; 1938 return 0;
1953} 1939}
1954 1940
1955static int ugeth_graceful_stop_rx(ucc_geth_private_t * ugeth) 1941static int ugeth_graceful_stop_rx(struct ucc_geth_private * ugeth)
1956{ 1942{
1957 ucc_fast_private_t *uccf; 1943 struct ucc_fast_private *uccf;
1958 u32 cecr_subblock; 1944 u32 cecr_subblock;
1959 u8 temp; 1945 u8 temp;
1960 1946
@@ -1973,7 +1959,7 @@ static int ugeth_graceful_stop_rx(ucc_geth_private_t * ugeth)
1973 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info. 1959 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.
1974 ucc_num); 1960 ucc_num);
1975 qe_issue_cmd(QE_GRACEFUL_STOP_RX, cecr_subblock, 1961 qe_issue_cmd(QE_GRACEFUL_STOP_RX, cecr_subblock,
1976 (u8) QE_CR_PROTOCOL_ETHERNET, 0); 1962 QE_CR_PROTOCOL_ETHERNET, 0);
1977 1963
1978 temp = ugeth->p_rx_glbl_pram->rxgstpack; 1964 temp = ugeth->p_rx_glbl_pram->rxgstpack;
1979 } while (!(temp & GRACEFUL_STOP_ACKNOWLEDGE_RX)); 1965 } while (!(temp & GRACEFUL_STOP_ACKNOWLEDGE_RX));
@@ -1983,41 +1969,40 @@ static int ugeth_graceful_stop_rx(ucc_geth_private_t * ugeth)
1983 return 0; 1969 return 0;
1984} 1970}
1985 1971
1986static int ugeth_restart_tx(ucc_geth_private_t *ugeth) 1972static int ugeth_restart_tx(struct ucc_geth_private *ugeth)
1987{ 1973{
1988 ucc_fast_private_t *uccf; 1974 struct ucc_fast_private *uccf;
1989 u32 cecr_subblock; 1975 u32 cecr_subblock;
1990 1976
1991 uccf = ugeth->uccf; 1977 uccf = ugeth->uccf;
1992 1978
1993 cecr_subblock = 1979 cecr_subblock =
1994 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num); 1980 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num);
1995 qe_issue_cmd(QE_RESTART_TX, cecr_subblock, (u8) QE_CR_PROTOCOL_ETHERNET, 1981 qe_issue_cmd(QE_RESTART_TX, cecr_subblock, QE_CR_PROTOCOL_ETHERNET, 0);
1996 0);
1997 uccf->stopped_tx = 0; 1982 uccf->stopped_tx = 0;
1998 1983
1999 return 0; 1984 return 0;
2000} 1985}
2001 1986
2002static int ugeth_restart_rx(ucc_geth_private_t *ugeth) 1987static int ugeth_restart_rx(struct ucc_geth_private *ugeth)
2003{ 1988{
2004 ucc_fast_private_t *uccf; 1989 struct ucc_fast_private *uccf;
2005 u32 cecr_subblock; 1990 u32 cecr_subblock;
2006 1991
2007 uccf = ugeth->uccf; 1992 uccf = ugeth->uccf;
2008 1993
2009 cecr_subblock = 1994 cecr_subblock =
2010 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num); 1995 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num);
2011 qe_issue_cmd(QE_RESTART_RX, cecr_subblock, (u8) QE_CR_PROTOCOL_ETHERNET, 1996 qe_issue_cmd(QE_RESTART_RX, cecr_subblock, QE_CR_PROTOCOL_ETHERNET,
2012 0); 1997 0);
2013 uccf->stopped_rx = 0; 1998 uccf->stopped_rx = 0;
2014 1999
2015 return 0; 2000 return 0;
2016} 2001}
2017 2002
2018static int ugeth_enable(ucc_geth_private_t *ugeth, comm_dir_e mode) 2003static int ugeth_enable(struct ucc_geth_private *ugeth, enum comm_dir mode)
2019{ 2004{
2020 ucc_fast_private_t *uccf; 2005 struct ucc_fast_private *uccf;
2021 int enabled_tx, enabled_rx; 2006 int enabled_tx, enabled_rx;
2022 2007
2023 uccf = ugeth->uccf; 2008 uccf = ugeth->uccf;
@@ -2044,9 +2029,9 @@ static int ugeth_enable(ucc_geth_private_t *ugeth, comm_dir_e mode)
2044 2029
2045} 2030}
2046 2031
2047static int ugeth_disable(ucc_geth_private_t * ugeth, comm_dir_e mode) 2032static int ugeth_disable(struct ucc_geth_private * ugeth, enum comm_dir mode)
2048{ 2033{
2049 ucc_fast_private_t *uccf; 2034 struct ucc_fast_private *uccf;
2050 2035
2051 uccf = ugeth->uccf; 2036 uccf = ugeth->uccf;
2052 2037
@@ -2069,7 +2054,7 @@ static int ugeth_disable(ucc_geth_private_t * ugeth, comm_dir_e mode)
2069 return 0; 2054 return 0;
2070} 2055}
2071 2056
2072static void ugeth_dump_regs(ucc_geth_private_t *ugeth) 2057static void ugeth_dump_regs(struct ucc_geth_private *ugeth)
2073{ 2058{
2074#ifdef DEBUG 2059#ifdef DEBUG
2075 ucc_fast_dump_regs(ugeth->uccf); 2060 ucc_fast_dump_regs(ugeth->uccf);
@@ -2079,9 +2064,9 @@ static void ugeth_dump_regs(ucc_geth_private_t *ugeth)
2079} 2064}
2080 2065
2081#ifdef CONFIG_UGETH_FILTERING 2066#ifdef CONFIG_UGETH_FILTERING
2082static int ugeth_ext_filtering_serialize_tad(ucc_geth_tad_params_t * 2067static int ugeth_ext_filtering_serialize_tad(struct ucc_geth_tad_params *
2083 p_UccGethTadParams, 2068 p_UccGethTadParams,
2084 qe_fltr_tad_t *qe_fltr_tad) 2069 struct qe_fltr_tad *qe_fltr_tad)
2085{ 2070{
2086 u16 temp; 2071 u16 temp;
2087 2072
@@ -2119,11 +2104,11 @@ static int ugeth_ext_filtering_serialize_tad(ucc_geth_tad_params_t *
2119 return 0; 2104 return 0;
2120} 2105}
2121 2106
2122static enet_addr_container_t 2107static struct enet_addr_container_t
2123 *ugeth_82xx_filtering_get_match_addr_in_hash(ucc_geth_private_t *ugeth, 2108 *ugeth_82xx_filtering_get_match_addr_in_hash(struct ucc_geth_private *ugeth,
2124 enet_addr_t *p_enet_addr) 2109 struct enet_addr *p_enet_addr)
2125{ 2110{
2126 enet_addr_container_t *enet_addr_cont; 2111 struct enet_addr_container *enet_addr_cont;
2127 struct list_head *p_lh; 2112 struct list_head *p_lh;
2128 u16 i, num; 2113 u16 i, num;
2129 int32_t j; 2114 int32_t j;
@@ -2144,7 +2129,7 @@ static enet_addr_container_t
2144 2129
2145 for (i = 0; i < num; i++) { 2130 for (i = 0; i < num; i++) {
2146 enet_addr_cont = 2131 enet_addr_cont =
2147 (enet_addr_container_t *) 2132 (struct enet_addr_container *)
2148 ENET_ADDR_CONT_ENTRY(dequeue(p_lh)); 2133 ENET_ADDR_CONT_ENTRY(dequeue(p_lh));
2149 for (j = ENET_NUM_OCTETS_PER_ADDRESS - 1; j >= 0; j--) { 2134 for (j = ENET_NUM_OCTETS_PER_ADDRESS - 1; j >= 0; j--) {
2150 if ((*p_enet_addr)[j] != (enet_addr_cont->address)[j]) 2135 if ((*p_enet_addr)[j] != (enet_addr_cont->address)[j])
@@ -2157,11 +2142,11 @@ static enet_addr_container_t
2157 return NULL; 2142 return NULL;
2158} 2143}
2159 2144
2160static int ugeth_82xx_filtering_add_addr_in_hash(ucc_geth_private_t *ugeth, 2145static int ugeth_82xx_filtering_add_addr_in_hash(struct ucc_geth_private *ugeth,
2161 enet_addr_t *p_enet_addr) 2146 struct enet_addr *p_enet_addr)
2162{ 2147{
2163 ucc_geth_enet_address_recognition_location_e location; 2148 enum ucc_geth_enet_address_recognition_location location;
2164 enet_addr_container_t *enet_addr_cont; 2149 struct enet_addr_container *enet_addr_cont;
2165 struct list_head *p_lh; 2150 struct list_head *p_lh;
2166 u8 i; 2151 u8 i;
2167 u32 limit; 2152 u32 limit;
@@ -2196,18 +2181,17 @@ static int ugeth_82xx_filtering_add_addr_in_hash(ucc_geth_private_t *ugeth,
2196 enqueue(p_lh, &enet_addr_cont->node); /* Put it back */ 2181 enqueue(p_lh, &enet_addr_cont->node); /* Put it back */
2197 ++(*p_counter); 2182 ++(*p_counter);
2198 2183
2199 hw_add_addr_in_hash(ugeth, &(enet_addr_cont->address)); 2184 hw_add_addr_in_hash(ugeth, enet_addr_cont->address);
2200
2201 return 0; 2185 return 0;
2202} 2186}
2203 2187
2204static int ugeth_82xx_filtering_clear_addr_in_hash(ucc_geth_private_t *ugeth, 2188static int ugeth_82xx_filtering_clear_addr_in_hash(struct ucc_geth_private *ugeth,
2205 enet_addr_t *p_enet_addr) 2189 struct enet_addr *p_enet_addr)
2206{ 2190{
2207 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 2191 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
2208 enet_addr_container_t *enet_addr_cont; 2192 struct enet_addr_container *enet_addr_cont;
2209 ucc_fast_private_t *uccf; 2193 struct ucc_fast_private *uccf;
2210 comm_dir_e comm_dir; 2194 enum comm_dir comm_dir;
2211 u16 i, num; 2195 u16 i, num;
2212 struct list_head *p_lh; 2196 struct list_head *p_lh;
2213 u32 *addr_h, *addr_l; 2197 u32 *addr_h, *addr_l;
@@ -2216,7 +2200,7 @@ static int ugeth_82xx_filtering_clear_addr_in_hash(ucc_geth_private_t *ugeth,
2216 uccf = ugeth->uccf; 2200 uccf = ugeth->uccf;
2217 2201
2218 p_82xx_addr_filt = 2202 p_82xx_addr_filt =
2219 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 2203 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
2220 addressfiltering; 2204 addressfiltering;
2221 2205
2222 if (! 2206 if (!
@@ -2256,9 +2240,9 @@ static int ugeth_82xx_filtering_clear_addr_in_hash(ucc_geth_private_t *ugeth,
2256 num = --(*p_counter); 2240 num = --(*p_counter);
2257 for (i = 0; i < num; i++) { 2241 for (i = 0; i < num; i++) {
2258 enet_addr_cont = 2242 enet_addr_cont =
2259 (enet_addr_container_t *) 2243 (struct enet_addr_container *)
2260 ENET_ADDR_CONT_ENTRY(dequeue(p_lh)); 2244 ENET_ADDR_CONT_ENTRY(dequeue(p_lh));
2261 hw_add_addr_in_hash(ugeth, &(enet_addr_cont->address)); 2245 hw_add_addr_in_hash(ugeth, enet_addr_cont->address);
2262 enqueue(p_lh, &enet_addr_cont->node); /* Put it back */ 2246 enqueue(p_lh, &enet_addr_cont->node); /* Put it back */
2263 } 2247 }
2264 2248
@@ -2269,14 +2253,14 @@ static int ugeth_82xx_filtering_clear_addr_in_hash(ucc_geth_private_t *ugeth,
2269} 2253}
2270#endif /* CONFIG_UGETH_FILTERING */ 2254#endif /* CONFIG_UGETH_FILTERING */
2271 2255
2272static int ugeth_82xx_filtering_clear_all_addr_in_hash(ucc_geth_private_t * 2256static int ugeth_82xx_filtering_clear_all_addr_in_hash(struct ucc_geth_private *
2273 ugeth, 2257 ugeth,
2274 enet_addr_type_e 2258 enum enet_addr_type
2275 enet_addr_type) 2259 enet_addr_type)
2276{ 2260{
2277 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 2261 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
2278 ucc_fast_private_t *uccf; 2262 struct ucc_fast_private *uccf;
2279 comm_dir_e comm_dir; 2263 enum comm_dir comm_dir;
2280 struct list_head *p_lh; 2264 struct list_head *p_lh;
2281 u16 i, num; 2265 u16 i, num;
2282 u32 *addr_h, *addr_l; 2266 u32 *addr_h, *addr_l;
@@ -2285,7 +2269,7 @@ static int ugeth_82xx_filtering_clear_all_addr_in_hash(ucc_geth_private_t *
2285 uccf = ugeth->uccf; 2269 uccf = ugeth->uccf;
2286 2270
2287 p_82xx_addr_filt = 2271 p_82xx_addr_filt =
2288 (ucc_geth_82xx_address_filtering_pram_t *) ugeth->p_rx_glbl_pram-> 2272 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram->
2289 addressfiltering; 2273 addressfiltering;
2290 2274
2291 if (enet_addr_type == ENET_ADDR_TYPE_GROUP) { 2275 if (enet_addr_type == ENET_ADDR_TYPE_GROUP) {
@@ -2331,8 +2315,8 @@ static int ugeth_82xx_filtering_clear_all_addr_in_hash(ucc_geth_private_t *
2331} 2315}
2332 2316
2333#ifdef CONFIG_UGETH_FILTERING 2317#ifdef CONFIG_UGETH_FILTERING
2334static int ugeth_82xx_filtering_add_addr_in_paddr(ucc_geth_private_t *ugeth, 2318static int ugeth_82xx_filtering_add_addr_in_paddr(struct ucc_geth_private *ugeth,
2335 enet_addr_t *p_enet_addr, 2319 struct enet_addr *p_enet_addr,
2336 u8 paddr_num) 2320 u8 paddr_num)
2337{ 2321{
2338 int i; 2322 int i;
@@ -2352,14 +2336,14 @@ static int ugeth_82xx_filtering_add_addr_in_paddr(ucc_geth_private_t *ugeth,
2352} 2336}
2353#endif /* CONFIG_UGETH_FILTERING */ 2337#endif /* CONFIG_UGETH_FILTERING */
2354 2338
2355static int ugeth_82xx_filtering_clear_addr_in_paddr(ucc_geth_private_t *ugeth, 2339static int ugeth_82xx_filtering_clear_addr_in_paddr(struct ucc_geth_private *ugeth,
2356 u8 paddr_num) 2340 u8 paddr_num)
2357{ 2341{
2358 ugeth->indAddrRegUsed[paddr_num] = 0; /* mark this paddr as not used */ 2342 ugeth->indAddrRegUsed[paddr_num] = 0; /* mark this paddr as not used */
2359 return hw_clear_addr_in_paddr(ugeth, paddr_num);/* clear in hardware */ 2343 return hw_clear_addr_in_paddr(ugeth, paddr_num);/* clear in hardware */
2360} 2344}
2361 2345
2362static void ucc_geth_memclean(ucc_geth_private_t *ugeth) 2346static void ucc_geth_memclean(struct ucc_geth_private *ugeth)
2363{ 2347{
2364 u16 i, j; 2348 u16 i, j;
2365 u8 *bd; 2349 u8 *bd;
@@ -2433,8 +2417,8 @@ static void ucc_geth_memclean(ucc_geth_private_t *ugeth)
2433 for (j = 0; j < ugeth->ug_info->bdRingLenTx[i]; j++) { 2417 for (j = 0; j < ugeth->ug_info->bdRingLenTx[i]; j++) {
2434 if (ugeth->tx_skbuff[i][j]) { 2418 if (ugeth->tx_skbuff[i][j]) {
2435 dma_unmap_single(NULL, 2419 dma_unmap_single(NULL,
2436 BD_BUFFER_ARG(bd), 2420 ((qe_bd_t *)bd)->buf,
2437 (BD_STATUS_AND_LENGTH(bd) & 2421 (in_be32((u32 *)bd) &
2438 BD_LENGTH_MASK), 2422 BD_LENGTH_MASK),
2439 DMA_TO_DEVICE); 2423 DMA_TO_DEVICE);
2440 dev_kfree_skb_any(ugeth->tx_skbuff[i][j]); 2424 dev_kfree_skb_any(ugeth->tx_skbuff[i][j]);
@@ -2460,18 +2444,17 @@ static void ucc_geth_memclean(ucc_geth_private_t *ugeth)
2460 bd = ugeth->p_rx_bd_ring[i]; 2444 bd = ugeth->p_rx_bd_ring[i];
2461 for (j = 0; j < ugeth->ug_info->bdRingLenRx[i]; j++) { 2445 for (j = 0; j < ugeth->ug_info->bdRingLenRx[i]; j++) {
2462 if (ugeth->rx_skbuff[i][j]) { 2446 if (ugeth->rx_skbuff[i][j]) {
2463 dma_unmap_single(NULL, BD_BUFFER(bd), 2447 dma_unmap_single(NULL,
2464 ugeth->ug_info-> 2448 ((struct qe_bd *)bd)->buf,
2465 uf_info. 2449 ugeth->ug_info->
2466 max_rx_buf_length + 2450 uf_info.max_rx_buf_length +
2467 UCC_GETH_RX_DATA_BUF_ALIGNMENT, 2451 UCC_GETH_RX_DATA_BUF_ALIGNMENT,
2468 DMA_FROM_DEVICE); 2452 DMA_FROM_DEVICE);
2469 2453 dev_kfree_skb_any(
2470 dev_kfree_skb_any(ugeth-> 2454 ugeth->rx_skbuff[i][j]);
2471 rx_skbuff[i][j]);
2472 ugeth->rx_skbuff[i][j] = NULL; 2455 ugeth->rx_skbuff[i][j] = NULL;
2473 } 2456 }
2474 bd += UCC_GETH_SIZE_OF_BD; 2457 bd += sizeof(struct qe_bd);
2475 } 2458 }
2476 2459
2477 kfree(ugeth->rx_skbuff[i]); 2460 kfree(ugeth->rx_skbuff[i]);
@@ -2496,11 +2479,11 @@ static void ucc_geth_memclean(ucc_geth_private_t *ugeth)
2496 2479
2497static void ucc_geth_set_multi(struct net_device *dev) 2480static void ucc_geth_set_multi(struct net_device *dev)
2498{ 2481{
2499 ucc_geth_private_t *ugeth; 2482 struct ucc_geth_private *ugeth;
2500 struct dev_mc_list *dmi; 2483 struct dev_mc_list *dmi;
2501 ucc_fast_t *uf_regs; 2484 struct ucc_fast *uf_regs;
2502 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 2485 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
2503 enet_addr_t tempaddr; 2486 u8 tempaddr[6];
2504 u8 *mcptr, *tdptr; 2487 u8 *mcptr, *tdptr;
2505 int i, j; 2488 int i, j;
2506 2489
@@ -2517,7 +2500,7 @@ static void ucc_geth_set_multi(struct net_device *dev)
2517 uf_regs->upsmr &= ~UPSMR_PRO; 2500 uf_regs->upsmr &= ~UPSMR_PRO;
2518 2501
2519 p_82xx_addr_filt = 2502 p_82xx_addr_filt =
2520 (ucc_geth_82xx_address_filtering_pram_t *) ugeth-> 2503 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->
2521 p_rx_glbl_pram->addressfiltering; 2504 p_rx_glbl_pram->addressfiltering;
2522 2505
2523 if (dev->flags & IFF_ALLMULTI) { 2506 if (dev->flags & IFF_ALLMULTI) {
@@ -2546,23 +2529,22 @@ static void ucc_geth_set_multi(struct net_device *dev)
2546 * copy bytes MSB first from dmi_addr. 2529 * copy bytes MSB first from dmi_addr.
2547 */ 2530 */
2548 mcptr = (u8 *) dmi->dmi_addr + 5; 2531 mcptr = (u8 *) dmi->dmi_addr + 5;
2549 tdptr = (u8 *) & tempaddr; 2532 tdptr = (u8 *) tempaddr;
2550 for (j = 0; j < 6; j++) 2533 for (j = 0; j < 6; j++)
2551 *tdptr++ = *mcptr--; 2534 *tdptr++ = *mcptr--;
2552 2535
2553 /* Ask CPM to run CRC and set bit in 2536 /* Ask CPM to run CRC and set bit in
2554 * filter mask. 2537 * filter mask.
2555 */ 2538 */
2556 hw_add_addr_in_hash(ugeth, &tempaddr); 2539 hw_add_addr_in_hash(ugeth, tempaddr);
2557
2558 } 2540 }
2559 } 2541 }
2560 } 2542 }
2561} 2543}
2562 2544
2563static void ucc_geth_stop(ucc_geth_private_t *ugeth) 2545static void ucc_geth_stop(struct ucc_geth_private *ugeth)
2564{ 2546{
2565 ucc_geth_t *ug_regs = ugeth->ug_regs; 2547 struct ucc_geth *ug_regs = ugeth->ug_regs;
2566 u32 tempval; 2548 u32 tempval;
2567 2549
2568 ugeth_vdbg("%s: IN", __FUNCTION__); 2550 ugeth_vdbg("%s: IN", __FUNCTION__);
@@ -2605,15 +2587,15 @@ static void ucc_geth_stop(ucc_geth_private_t *ugeth)
2605 ucc_geth_memclean(ugeth); 2587 ucc_geth_memclean(ugeth);
2606} 2588}
2607 2589
2608static int ucc_geth_startup(ucc_geth_private_t *ugeth) 2590static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2609{ 2591{
2610 ucc_geth_82xx_address_filtering_pram_t *p_82xx_addr_filt; 2592 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt;
2611 ucc_geth_init_pram_t *p_init_enet_pram; 2593 struct ucc_geth_init_pram *p_init_enet_pram;
2612 ucc_fast_private_t *uccf; 2594 struct ucc_fast_private *uccf;
2613 ucc_geth_info_t *ug_info; 2595 struct ucc_geth_info *ug_info;
2614 ucc_fast_info_t *uf_info; 2596 struct ucc_fast_info *uf_info;
2615 ucc_fast_t *uf_regs; 2597 struct ucc_fast *uf_regs;
2616 ucc_geth_t *ug_regs; 2598 struct ucc_geth *ug_regs;
2617 int ret_val = -EINVAL; 2599 int ret_val = -EINVAL;
2618 u32 remoder = UCC_GETH_REMODER_INIT; 2600 u32 remoder = UCC_GETH_REMODER_INIT;
2619 u32 init_enet_pram_offset, cecr_subblock, command, maccfg1; 2601 u32 init_enet_pram_offset, cecr_subblock, command, maccfg1;
@@ -2788,7 +2770,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2788 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP); 2770 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP);
2789 2771
2790 uf_regs = uccf->uf_regs; 2772 uf_regs = uccf->uf_regs;
2791 ug_regs = (ucc_geth_t *) (uccf->uf_regs); 2773 ug_regs = (struct ucc_geth *) (uccf->uf_regs);
2792 ugeth->ug_regs = ug_regs; 2774 ugeth->ug_regs = ug_regs;
2793 2775
2794 init_default_reg_vals(&uf_regs->upsmr, 2776 init_default_reg_vals(&uf_regs->upsmr,
@@ -2869,10 +2851,10 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2869 /* Allocate in multiple of 2851 /* Allocate in multiple of
2870 UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT, 2852 UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT,
2871 according to spec */ 2853 according to spec */
2872 length = ((ug_info->bdRingLenTx[j] * UCC_GETH_SIZE_OF_BD) 2854 length = ((ug_info->bdRingLenTx[j] * sizeof(struct qe_bd))
2873 / UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) 2855 / UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT)
2874 * UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; 2856 * UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT;
2875 if ((ug_info->bdRingLenTx[j] * UCC_GETH_SIZE_OF_BD) % 2857 if ((ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)) %
2876 UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT) 2858 UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT)
2877 length += UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT; 2859 length += UCC_GETH_TX_BD_RING_SIZE_MEMORY_ALIGNMENT;
2878 if (uf_info->bd_mem_part == MEM_PART_SYSTEM) { 2860 if (uf_info->bd_mem_part == MEM_PART_SYSTEM) {
@@ -2904,13 +2886,13 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2904 } 2886 }
2905 /* Zero unused end of bd ring, according to spec */ 2887 /* Zero unused end of bd ring, according to spec */
2906 memset(ugeth->p_tx_bd_ring[j] + 2888 memset(ugeth->p_tx_bd_ring[j] +
2907 ug_info->bdRingLenTx[j] * UCC_GETH_SIZE_OF_BD, 0, 2889 ug_info->bdRingLenTx[j] * sizeof(struct qe_bd), 0,
2908 length - ug_info->bdRingLenTx[j] * UCC_GETH_SIZE_OF_BD); 2890 length - ug_info->bdRingLenTx[j] * sizeof(struct qe_bd));
2909 } 2891 }
2910 2892
2911 /* Allocate Rx bds */ 2893 /* Allocate Rx bds */
2912 for (j = 0; j < ug_info->numQueuesRx; j++) { 2894 for (j = 0; j < ug_info->numQueuesRx; j++) {
2913 length = ug_info->bdRingLenRx[j] * UCC_GETH_SIZE_OF_BD; 2895 length = ug_info->bdRingLenRx[j] * sizeof(struct qe_bd);
2914 if (uf_info->bd_mem_part == MEM_PART_SYSTEM) { 2896 if (uf_info->bd_mem_part == MEM_PART_SYSTEM) {
2915 u32 align = 4; 2897 u32 align = 4;
2916 if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4) 2898 if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4)
@@ -2960,12 +2942,15 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2960 ugeth->skb_curtx[j] = ugeth->skb_dirtytx[j] = 0; 2942 ugeth->skb_curtx[j] = ugeth->skb_dirtytx[j] = 0;
2961 bd = ugeth->confBd[j] = ugeth->txBd[j] = ugeth->p_tx_bd_ring[j]; 2943 bd = ugeth->confBd[j] = ugeth->txBd[j] = ugeth->p_tx_bd_ring[j];
2962 for (i = 0; i < ug_info->bdRingLenTx[j]; i++) { 2944 for (i = 0; i < ug_info->bdRingLenTx[j]; i++) {
2963 BD_BUFFER_CLEAR(bd); 2945 /* clear bd buffer */
2964 BD_STATUS_AND_LENGTH_SET(bd, 0); 2946 out_be32(&((struct qe_bd *)bd)->buf, 0);
2965 bd += UCC_GETH_SIZE_OF_BD; 2947 /* set bd status and length */
2948 out_be32((u32 *)bd, 0);
2949 bd += sizeof(struct qe_bd);
2966 } 2950 }
2967 bd -= UCC_GETH_SIZE_OF_BD; 2951 bd -= sizeof(struct qe_bd);
2968 BD_STATUS_AND_LENGTH_SET(bd, T_W);/* for last BD set Wrap bit */ 2952 /* set bd status and length */
2953 out_be32((u32 *)bd, T_W); /* for last BD set Wrap bit */
2969 } 2954 }
2970 2955
2971 /* Init Rx bds */ 2956 /* Init Rx bds */
@@ -2989,12 +2974,15 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
2989 ugeth->skb_currx[j] = 0; 2974 ugeth->skb_currx[j] = 0;
2990 bd = ugeth->rxBd[j] = ugeth->p_rx_bd_ring[j]; 2975 bd = ugeth->rxBd[j] = ugeth->p_rx_bd_ring[j];
2991 for (i = 0; i < ug_info->bdRingLenRx[j]; i++) { 2976 for (i = 0; i < ug_info->bdRingLenRx[j]; i++) {
2992 BD_STATUS_AND_LENGTH_SET(bd, R_I); 2977 /* set bd status and length */
2993 BD_BUFFER_CLEAR(bd); 2978 out_be32((u32 *)bd, R_I);
2994 bd += UCC_GETH_SIZE_OF_BD; 2979 /* clear bd buffer */
2980 out_be32(&((struct qe_bd *)bd)->buf, 0);
2981 bd += sizeof(struct qe_bd);
2995 } 2982 }
2996 bd -= UCC_GETH_SIZE_OF_BD; 2983 bd -= sizeof(struct qe_bd);
2997 BD_STATUS_AND_LENGTH_SET(bd, R_W);/* for last BD set Wrap bit */ 2984 /* set bd status and length */
2985 out_be32((u32 *)bd, R_W); /* for last BD set Wrap bit */
2998 } 2986 }
2999 2987
3000 /* 2988 /*
@@ -3003,7 +2991,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3003 /* Tx global PRAM */ 2991 /* Tx global PRAM */
3004 /* Allocate global tx parameter RAM page */ 2992 /* Allocate global tx parameter RAM page */
3005 ugeth->tx_glbl_pram_offset = 2993 ugeth->tx_glbl_pram_offset =
3006 qe_muram_alloc(sizeof(ucc_geth_tx_global_pram_t), 2994 qe_muram_alloc(sizeof(struct ucc_geth_tx_global_pram),
3007 UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT); 2995 UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT);
3008 if (IS_MURAM_ERR(ugeth->tx_glbl_pram_offset)) { 2996 if (IS_MURAM_ERR(ugeth->tx_glbl_pram_offset)) {
3009 ugeth_err 2997 ugeth_err
@@ -3013,10 +3001,10 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3013 return -ENOMEM; 3001 return -ENOMEM;
3014 } 3002 }
3015 ugeth->p_tx_glbl_pram = 3003 ugeth->p_tx_glbl_pram =
3016 (ucc_geth_tx_global_pram_t *) qe_muram_addr(ugeth-> 3004 (struct ucc_geth_tx_global_pram *) qe_muram_addr(ugeth->
3017 tx_glbl_pram_offset); 3005 tx_glbl_pram_offset);
3018 /* Zero out p_tx_glbl_pram */ 3006 /* Zero out p_tx_glbl_pram */
3019 memset(ugeth->p_tx_glbl_pram, 0, sizeof(ucc_geth_tx_global_pram_t)); 3007 memset(ugeth->p_tx_glbl_pram, 0, sizeof(struct ucc_geth_tx_global_pram));
3020 3008
3021 /* Fill global PRAM */ 3009 /* Fill global PRAM */
3022 3010
@@ -3024,7 +3012,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3024 /* Size varies with number of Tx threads */ 3012 /* Size varies with number of Tx threads */
3025 ugeth->thread_dat_tx_offset = 3013 ugeth->thread_dat_tx_offset =
3026 qe_muram_alloc(numThreadsTxNumerical * 3014 qe_muram_alloc(numThreadsTxNumerical *
3027 sizeof(ucc_geth_thread_data_tx_t) + 3015 sizeof(struct ucc_geth_thread_data_tx) +
3028 32 * (numThreadsTxNumerical == 1), 3016 32 * (numThreadsTxNumerical == 1),
3029 UCC_GETH_THREAD_DATA_ALIGNMENT); 3017 UCC_GETH_THREAD_DATA_ALIGNMENT);
3030 if (IS_MURAM_ERR(ugeth->thread_dat_tx_offset)) { 3018 if (IS_MURAM_ERR(ugeth->thread_dat_tx_offset)) {
@@ -3036,7 +3024,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3036 } 3024 }
3037 3025
3038 ugeth->p_thread_data_tx = 3026 ugeth->p_thread_data_tx =
3039 (ucc_geth_thread_data_tx_t *) qe_muram_addr(ugeth-> 3027 (struct ucc_geth_thread_data_tx *) qe_muram_addr(ugeth->
3040 thread_dat_tx_offset); 3028 thread_dat_tx_offset);
3041 out_be32(&ugeth->p_tx_glbl_pram->tqptr, ugeth->thread_dat_tx_offset); 3029 out_be32(&ugeth->p_tx_glbl_pram->tqptr, ugeth->thread_dat_tx_offset);
3042 3030
@@ -3053,7 +3041,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3053 /* Size varies with number of Tx queues */ 3041 /* Size varies with number of Tx queues */
3054 ugeth->send_q_mem_reg_offset = 3042 ugeth->send_q_mem_reg_offset =
3055 qe_muram_alloc(ug_info->numQueuesTx * 3043 qe_muram_alloc(ug_info->numQueuesTx *
3056 sizeof(ucc_geth_send_queue_qd_t), 3044 sizeof(struct ucc_geth_send_queue_qd),
3057 UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT); 3045 UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT);
3058 if (IS_MURAM_ERR(ugeth->send_q_mem_reg_offset)) { 3046 if (IS_MURAM_ERR(ugeth->send_q_mem_reg_offset)) {
3059 ugeth_err 3047 ugeth_err
@@ -3064,7 +3052,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3064 } 3052 }
3065 3053
3066 ugeth->p_send_q_mem_reg = 3054 ugeth->p_send_q_mem_reg =
3067 (ucc_geth_send_queue_mem_region_t *) qe_muram_addr(ugeth-> 3055 (struct ucc_geth_send_queue_mem_region *) qe_muram_addr(ugeth->
3068 send_q_mem_reg_offset); 3056 send_q_mem_reg_offset);
3069 out_be32(&ugeth->p_tx_glbl_pram->sqptr, ugeth->send_q_mem_reg_offset); 3057 out_be32(&ugeth->p_tx_glbl_pram->sqptr, ugeth->send_q_mem_reg_offset);
3070 3058
@@ -3073,7 +3061,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3073 for (i = 0; i < ug_info->numQueuesTx; i++) { 3061 for (i = 0; i < ug_info->numQueuesTx; i++) {
3074 endOfRing = 3062 endOfRing =
3075 ugeth->p_tx_bd_ring[i] + (ug_info->bdRingLenTx[i] - 3063 ugeth->p_tx_bd_ring[i] + (ug_info->bdRingLenTx[i] -
3076 1) * UCC_GETH_SIZE_OF_BD; 3064 1) * sizeof(struct qe_bd);
3077 if (ugeth->ug_info->uf_info.bd_mem_part == MEM_PART_SYSTEM) { 3065 if (ugeth->ug_info->uf_info.bd_mem_part == MEM_PART_SYSTEM) {
3078 out_be32(&ugeth->p_send_q_mem_reg->sqqd[i].bd_ring_base, 3066 out_be32(&ugeth->p_send_q_mem_reg->sqqd[i].bd_ring_base,
3079 (u32) virt_to_phys(ugeth->p_tx_bd_ring[i])); 3067 (u32) virt_to_phys(ugeth->p_tx_bd_ring[i]));
@@ -3096,7 +3084,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3096 if (ug_info->numQueuesTx > 1) { 3084 if (ug_info->numQueuesTx > 1) {
3097 /* scheduler exists only if more than 1 tx queue */ 3085 /* scheduler exists only if more than 1 tx queue */
3098 ugeth->scheduler_offset = 3086 ugeth->scheduler_offset =
3099 qe_muram_alloc(sizeof(ucc_geth_scheduler_t), 3087 qe_muram_alloc(sizeof(struct ucc_geth_scheduler),
3100 UCC_GETH_SCHEDULER_ALIGNMENT); 3088 UCC_GETH_SCHEDULER_ALIGNMENT);
3101 if (IS_MURAM_ERR(ugeth->scheduler_offset)) { 3089 if (IS_MURAM_ERR(ugeth->scheduler_offset)) {
3102 ugeth_err 3090 ugeth_err
@@ -3107,12 +3095,12 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3107 } 3095 }
3108 3096
3109 ugeth->p_scheduler = 3097 ugeth->p_scheduler =
3110 (ucc_geth_scheduler_t *) qe_muram_addr(ugeth-> 3098 (struct ucc_geth_scheduler *) qe_muram_addr(ugeth->
3111 scheduler_offset); 3099 scheduler_offset);
3112 out_be32(&ugeth->p_tx_glbl_pram->schedulerbasepointer, 3100 out_be32(&ugeth->p_tx_glbl_pram->schedulerbasepointer,
3113 ugeth->scheduler_offset); 3101 ugeth->scheduler_offset);
3114 /* Zero out p_scheduler */ 3102 /* Zero out p_scheduler */
3115 memset(ugeth->p_scheduler, 0, sizeof(ucc_geth_scheduler_t)); 3103 memset(ugeth->p_scheduler, 0, sizeof(struct ucc_geth_scheduler));
3116 3104
3117 /* Set values in scheduler */ 3105 /* Set values in scheduler */
3118 out_be32(&ugeth->p_scheduler->mblinterval, 3106 out_be32(&ugeth->p_scheduler->mblinterval,
@@ -3144,7 +3132,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3144 statisticsMode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) { 3132 statisticsMode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) {
3145 ugeth->tx_fw_statistics_pram_offset = 3133 ugeth->tx_fw_statistics_pram_offset =
3146 qe_muram_alloc(sizeof 3134 qe_muram_alloc(sizeof
3147 (ucc_geth_tx_firmware_statistics_pram_t), 3135 (struct ucc_geth_tx_firmware_statistics_pram),
3148 UCC_GETH_TX_STATISTICS_ALIGNMENT); 3136 UCC_GETH_TX_STATISTICS_ALIGNMENT);
3149 if (IS_MURAM_ERR(ugeth->tx_fw_statistics_pram_offset)) { 3137 if (IS_MURAM_ERR(ugeth->tx_fw_statistics_pram_offset)) {
3150 ugeth_err 3138 ugeth_err
@@ -3154,11 +3142,11 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3154 return -ENOMEM; 3142 return -ENOMEM;
3155 } 3143 }
3156 ugeth->p_tx_fw_statistics_pram = 3144 ugeth->p_tx_fw_statistics_pram =
3157 (ucc_geth_tx_firmware_statistics_pram_t *) 3145 (struct ucc_geth_tx_firmware_statistics_pram *)
3158 qe_muram_addr(ugeth->tx_fw_statistics_pram_offset); 3146 qe_muram_addr(ugeth->tx_fw_statistics_pram_offset);
3159 /* Zero out p_tx_fw_statistics_pram */ 3147 /* Zero out p_tx_fw_statistics_pram */
3160 memset(ugeth->p_tx_fw_statistics_pram, 3148 memset(ugeth->p_tx_fw_statistics_pram,
3161 0, sizeof(ucc_geth_tx_firmware_statistics_pram_t)); 3149 0, sizeof(struct ucc_geth_tx_firmware_statistics_pram));
3162 } 3150 }
3163 3151
3164 /* temoder */ 3152 /* temoder */
@@ -3183,7 +3171,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3183 /* Rx global PRAM */ 3171 /* Rx global PRAM */
3184 /* Allocate global rx parameter RAM page */ 3172 /* Allocate global rx parameter RAM page */
3185 ugeth->rx_glbl_pram_offset = 3173 ugeth->rx_glbl_pram_offset =
3186 qe_muram_alloc(sizeof(ucc_geth_rx_global_pram_t), 3174 qe_muram_alloc(sizeof(struct ucc_geth_rx_global_pram),
3187 UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT); 3175 UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT);
3188 if (IS_MURAM_ERR(ugeth->rx_glbl_pram_offset)) { 3176 if (IS_MURAM_ERR(ugeth->rx_glbl_pram_offset)) {
3189 ugeth_err 3177 ugeth_err
@@ -3193,10 +3181,10 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3193 return -ENOMEM; 3181 return -ENOMEM;
3194 } 3182 }
3195 ugeth->p_rx_glbl_pram = 3183 ugeth->p_rx_glbl_pram =
3196 (ucc_geth_rx_global_pram_t *) qe_muram_addr(ugeth-> 3184 (struct ucc_geth_rx_global_pram *) qe_muram_addr(ugeth->
3197 rx_glbl_pram_offset); 3185 rx_glbl_pram_offset);
3198 /* Zero out p_rx_glbl_pram */ 3186 /* Zero out p_rx_glbl_pram */
3199 memset(ugeth->p_rx_glbl_pram, 0, sizeof(ucc_geth_rx_global_pram_t)); 3187 memset(ugeth->p_rx_glbl_pram, 0, sizeof(struct ucc_geth_rx_global_pram));
3200 3188
3201 /* Fill global PRAM */ 3189 /* Fill global PRAM */
3202 3190
@@ -3204,7 +3192,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3204 /* Size varies with number of Rx threads */ 3192 /* Size varies with number of Rx threads */
3205 ugeth->thread_dat_rx_offset = 3193 ugeth->thread_dat_rx_offset =
3206 qe_muram_alloc(numThreadsRxNumerical * 3194 qe_muram_alloc(numThreadsRxNumerical *
3207 sizeof(ucc_geth_thread_data_rx_t), 3195 sizeof(struct ucc_geth_thread_data_rx),
3208 UCC_GETH_THREAD_DATA_ALIGNMENT); 3196 UCC_GETH_THREAD_DATA_ALIGNMENT);
3209 if (IS_MURAM_ERR(ugeth->thread_dat_rx_offset)) { 3197 if (IS_MURAM_ERR(ugeth->thread_dat_rx_offset)) {
3210 ugeth_err 3198 ugeth_err
@@ -3215,7 +3203,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3215 } 3203 }
3216 3204
3217 ugeth->p_thread_data_rx = 3205 ugeth->p_thread_data_rx =
3218 (ucc_geth_thread_data_rx_t *) qe_muram_addr(ugeth-> 3206 (struct ucc_geth_thread_data_rx *) qe_muram_addr(ugeth->
3219 thread_dat_rx_offset); 3207 thread_dat_rx_offset);
3220 out_be32(&ugeth->p_rx_glbl_pram->rqptr, ugeth->thread_dat_rx_offset); 3208 out_be32(&ugeth->p_rx_glbl_pram->rqptr, ugeth->thread_dat_rx_offset);
3221 3209
@@ -3227,7 +3215,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3227 statisticsMode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) { 3215 statisticsMode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) {
3228 ugeth->rx_fw_statistics_pram_offset = 3216 ugeth->rx_fw_statistics_pram_offset =
3229 qe_muram_alloc(sizeof 3217 qe_muram_alloc(sizeof
3230 (ucc_geth_rx_firmware_statistics_pram_t), 3218 (struct ucc_geth_rx_firmware_statistics_pram),
3231 UCC_GETH_RX_STATISTICS_ALIGNMENT); 3219 UCC_GETH_RX_STATISTICS_ALIGNMENT);
3232 if (IS_MURAM_ERR(ugeth->rx_fw_statistics_pram_offset)) { 3220 if (IS_MURAM_ERR(ugeth->rx_fw_statistics_pram_offset)) {
3233 ugeth_err 3221 ugeth_err
@@ -3237,11 +3225,11 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3237 return -ENOMEM; 3225 return -ENOMEM;
3238 } 3226 }
3239 ugeth->p_rx_fw_statistics_pram = 3227 ugeth->p_rx_fw_statistics_pram =
3240 (ucc_geth_rx_firmware_statistics_pram_t *) 3228 (struct ucc_geth_rx_firmware_statistics_pram *)
3241 qe_muram_addr(ugeth->rx_fw_statistics_pram_offset); 3229 qe_muram_addr(ugeth->rx_fw_statistics_pram_offset);
3242 /* Zero out p_rx_fw_statistics_pram */ 3230 /* Zero out p_rx_fw_statistics_pram */
3243 memset(ugeth->p_rx_fw_statistics_pram, 0, 3231 memset(ugeth->p_rx_fw_statistics_pram, 0,
3244 sizeof(ucc_geth_rx_firmware_statistics_pram_t)); 3232 sizeof(struct ucc_geth_rx_firmware_statistics_pram));
3245 } 3233 }
3246 3234
3247 /* intCoalescingPtr */ 3235 /* intCoalescingPtr */
@@ -3249,7 +3237,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3249 /* Size varies with number of Rx queues */ 3237 /* Size varies with number of Rx queues */
3250 ugeth->rx_irq_coalescing_tbl_offset = 3238 ugeth->rx_irq_coalescing_tbl_offset =
3251 qe_muram_alloc(ug_info->numQueuesRx * 3239 qe_muram_alloc(ug_info->numQueuesRx *
3252 sizeof(ucc_geth_rx_interrupt_coalescing_entry_t), 3240 sizeof(struct ucc_geth_rx_interrupt_coalescing_entry),
3253 UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT); 3241 UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT);
3254 if (IS_MURAM_ERR(ugeth->rx_irq_coalescing_tbl_offset)) { 3242 if (IS_MURAM_ERR(ugeth->rx_irq_coalescing_tbl_offset)) {
3255 ugeth_err 3243 ugeth_err
@@ -3260,7 +3248,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3260 } 3248 }
3261 3249
3262 ugeth->p_rx_irq_coalescing_tbl = 3250 ugeth->p_rx_irq_coalescing_tbl =
3263 (ucc_geth_rx_interrupt_coalescing_table_t *) 3251 (struct ucc_geth_rx_interrupt_coalescing_table *)
3264 qe_muram_addr(ugeth->rx_irq_coalescing_tbl_offset); 3252 qe_muram_addr(ugeth->rx_irq_coalescing_tbl_offset);
3265 out_be32(&ugeth->p_rx_glbl_pram->intcoalescingptr, 3253 out_be32(&ugeth->p_rx_glbl_pram->intcoalescingptr,
3266 ugeth->rx_irq_coalescing_tbl_offset); 3254 ugeth->rx_irq_coalescing_tbl_offset);
@@ -3300,7 +3288,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3300 l3qt = 0; 3288 l3qt = 0;
3301 for (i = 0; i < 8; i++) 3289 for (i = 0; i < 8; i++)
3302 l3qt |= (ug_info->l3qt[j + i] << (28 - 4 * i)); 3290 l3qt |= (ug_info->l3qt[j + i] << (28 - 4 * i));
3303 out_be32(&ugeth->p_rx_glbl_pram->l3qt[j], l3qt); 3291 out_be32(&ugeth->p_rx_glbl_pram->l3qt[j/8], l3qt);
3304 } 3292 }
3305 3293
3306 /* vlantype */ 3294 /* vlantype */
@@ -3316,8 +3304,8 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3316 /* Size varies with number of Rx queues */ 3304 /* Size varies with number of Rx queues */
3317 ugeth->rx_bd_qs_tbl_offset = 3305 ugeth->rx_bd_qs_tbl_offset =
3318 qe_muram_alloc(ug_info->numQueuesRx * 3306 qe_muram_alloc(ug_info->numQueuesRx *
3319 (sizeof(ucc_geth_rx_bd_queues_entry_t) + 3307 (sizeof(struct ucc_geth_rx_bd_queues_entry) +
3320 sizeof(ucc_geth_rx_prefetched_bds_t)), 3308 sizeof(struct ucc_geth_rx_prefetched_bds)),
3321 UCC_GETH_RX_BD_QUEUES_ALIGNMENT); 3309 UCC_GETH_RX_BD_QUEUES_ALIGNMENT);
3322 if (IS_MURAM_ERR(ugeth->rx_bd_qs_tbl_offset)) { 3310 if (IS_MURAM_ERR(ugeth->rx_bd_qs_tbl_offset)) {
3323 ugeth_err 3311 ugeth_err
@@ -3328,14 +3316,14 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3328 } 3316 }
3329 3317
3330 ugeth->p_rx_bd_qs_tbl = 3318 ugeth->p_rx_bd_qs_tbl =
3331 (ucc_geth_rx_bd_queues_entry_t *) qe_muram_addr(ugeth-> 3319 (struct ucc_geth_rx_bd_queues_entry *) qe_muram_addr(ugeth->
3332 rx_bd_qs_tbl_offset); 3320 rx_bd_qs_tbl_offset);
3333 out_be32(&ugeth->p_rx_glbl_pram->rbdqptr, ugeth->rx_bd_qs_tbl_offset); 3321 out_be32(&ugeth->p_rx_glbl_pram->rbdqptr, ugeth->rx_bd_qs_tbl_offset);
3334 /* Zero out p_rx_bd_qs_tbl */ 3322 /* Zero out p_rx_bd_qs_tbl */
3335 memset(ugeth->p_rx_bd_qs_tbl, 3323 memset(ugeth->p_rx_bd_qs_tbl,
3336 0, 3324 0,
3337 ug_info->numQueuesRx * (sizeof(ucc_geth_rx_bd_queues_entry_t) + 3325 ug_info->numQueuesRx * (sizeof(struct ucc_geth_rx_bd_queues_entry) +
3338 sizeof(ucc_geth_rx_prefetched_bds_t))); 3326 sizeof(struct ucc_geth_rx_prefetched_bds)));
3339 3327
3340 /* Setup the table */ 3328 /* Setup the table */
3341 /* Assume BD rings are already established */ 3329 /* Assume BD rings are already established */
@@ -3406,7 +3394,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3406 /* Allocate memory for extended filtering Mode Global 3394 /* Allocate memory for extended filtering Mode Global
3407 Parameters */ 3395 Parameters */
3408 ugeth->exf_glbl_param_offset = 3396 ugeth->exf_glbl_param_offset =
3409 qe_muram_alloc(sizeof(ucc_geth_exf_global_pram_t), 3397 qe_muram_alloc(sizeof(struct ucc_geth_exf_global_pram),
3410 UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT); 3398 UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT);
3411 if (IS_MURAM_ERR(ugeth->exf_glbl_param_offset)) { 3399 if (IS_MURAM_ERR(ugeth->exf_glbl_param_offset)) {
3412 ugeth_err 3400 ugeth_err
@@ -3417,7 +3405,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3417 } 3405 }
3418 3406
3419 ugeth->p_exf_glbl_param = 3407 ugeth->p_exf_glbl_param =
3420 (ucc_geth_exf_global_pram_t *) qe_muram_addr(ugeth-> 3408 (struct ucc_geth_exf_global_pram *) qe_muram_addr(ugeth->
3421 exf_glbl_param_offset); 3409 exf_glbl_param_offset);
3422 out_be32(&ugeth->p_rx_glbl_pram->exfGlobalParam, 3410 out_be32(&ugeth->p_rx_glbl_pram->exfGlobalParam,
3423 ugeth->exf_glbl_param_offset); 3411 ugeth->exf_glbl_param_offset);
@@ -3439,7 +3427,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3439 INIT_LIST_HEAD(&ugeth->ind_hash_q); 3427 INIT_LIST_HEAD(&ugeth->ind_hash_q);
3440 } 3428 }
3441 p_82xx_addr_filt = 3429 p_82xx_addr_filt =
3442 (ucc_geth_82xx_address_filtering_pram_t *) ugeth-> 3430 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->
3443 p_rx_glbl_pram->addressfiltering; 3431 p_rx_glbl_pram->addressfiltering;
3444 3432
3445 ugeth_82xx_filtering_clear_all_addr_in_hash(ugeth, 3433 ugeth_82xx_filtering_clear_all_addr_in_hash(ugeth,
@@ -3462,7 +3450,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3462 * allocated resources can be released when the channel is freed. 3450 * allocated resources can be released when the channel is freed.
3463 */ 3451 */
3464 if (!(ugeth->p_init_enet_param_shadow = 3452 if (!(ugeth->p_init_enet_param_shadow =
3465 (ucc_geth_init_pram_t *) kmalloc(sizeof(ucc_geth_init_pram_t), 3453 (struct ucc_geth_init_pram *) kmalloc(sizeof(struct ucc_geth_init_pram),
3466 GFP_KERNEL))) { 3454 GFP_KERNEL))) {
3467 ugeth_err 3455 ugeth_err
3468 ("%s: Can not allocate memory for" 3456 ("%s: Can not allocate memory for"
@@ -3472,7 +3460,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3472 } 3460 }
3473 /* Zero out *p_init_enet_param_shadow */ 3461 /* Zero out *p_init_enet_param_shadow */
3474 memset((char *)ugeth->p_init_enet_param_shadow, 3462 memset((char *)ugeth->p_init_enet_param_shadow,
3475 0, sizeof(ucc_geth_init_pram_t)); 3463 0, sizeof(struct ucc_geth_init_pram));
3476 3464
3477 /* Fill shadow InitEnet command parameter structure */ 3465 /* Fill shadow InitEnet command parameter structure */
3478 3466
@@ -3506,7 +3494,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3506 } 3494 }
3507 ugeth->p_init_enet_param_shadow->largestexternallookupkeysize = 3495 ugeth->p_init_enet_param_shadow->largestexternallookupkeysize =
3508 ug_info->largestexternallookupkeysize; 3496 ug_info->largestexternallookupkeysize;
3509 size = sizeof(ucc_geth_thread_rx_pram_t); 3497 size = sizeof(struct ucc_geth_thread_rx_pram);
3510 if (ug_info->rxExtendedFiltering) { 3498 if (ug_info->rxExtendedFiltering) {
3511 size += THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING; 3499 size += THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING;
3512 if (ug_info->largestexternallookupkeysize == 3500 if (ug_info->largestexternallookupkeysize ==
@@ -3537,7 +3525,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3537 fill_init_enet_entries(ugeth, 3525 fill_init_enet_entries(ugeth,
3538 &(ugeth->p_init_enet_param_shadow-> 3526 &(ugeth->p_init_enet_param_shadow->
3539 txthread[0]), numThreadsTxNumerical, 3527 txthread[0]), numThreadsTxNumerical,
3540 sizeof(ucc_geth_thread_tx_pram_t), 3528 sizeof(struct ucc_geth_thread_tx_pram),
3541 UCC_GETH_THREAD_TX_PRAM_ALIGNMENT, 3529 UCC_GETH_THREAD_TX_PRAM_ALIGNMENT,
3542 ug_info->riscTx, 0)) != 0) { 3530 ug_info->riscTx, 0)) != 0) {
3543 ugeth_err("%s: Can not fill p_init_enet_param_shadow.", 3531 ugeth_err("%s: Can not fill p_init_enet_param_shadow.",
@@ -3557,7 +3545,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3557 } 3545 }
3558 3546
3559 /* Allocate InitEnet command parameter structure */ 3547 /* Allocate InitEnet command parameter structure */
3560 init_enet_pram_offset = qe_muram_alloc(sizeof(ucc_geth_init_pram_t), 4); 3548 init_enet_pram_offset = qe_muram_alloc(sizeof(struct ucc_geth_init_pram), 4);
3561 if (IS_MURAM_ERR(init_enet_pram_offset)) { 3549 if (IS_MURAM_ERR(init_enet_pram_offset)) {
3562 ugeth_err 3550 ugeth_err
3563 ("%s: Can not allocate DPRAM memory for p_init_enet_pram.", 3551 ("%s: Can not allocate DPRAM memory for p_init_enet_pram.",
@@ -3566,7 +3554,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3566 return -ENOMEM; 3554 return -ENOMEM;
3567 } 3555 }
3568 p_init_enet_pram = 3556 p_init_enet_pram =
3569 (ucc_geth_init_pram_t *) qe_muram_addr(init_enet_pram_offset); 3557 (struct ucc_geth_init_pram *) qe_muram_addr(init_enet_pram_offset);
3570 3558
3571 /* Copy shadow InitEnet command parameter structure into PRAM */ 3559 /* Copy shadow InitEnet command parameter structure into PRAM */
3572 p_init_enet_pram->resinit1 = ugeth->p_init_enet_param_shadow->resinit1; 3560 p_init_enet_pram->resinit1 = ugeth->p_init_enet_param_shadow->resinit1;
@@ -3591,7 +3579,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3591 /* Issue QE command */ 3579 /* Issue QE command */
3592 cecr_subblock = 3580 cecr_subblock =
3593 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num); 3581 ucc_fast_get_qe_cr_subblock(ugeth->ug_info->uf_info.ucc_num);
3594 qe_issue_cmd(command, cecr_subblock, (u8) QE_CR_PROTOCOL_ETHERNET, 3582 qe_issue_cmd(command, cecr_subblock, QE_CR_PROTOCOL_ETHERNET,
3595 init_enet_pram_offset); 3583 init_enet_pram_offset);
3596 3584
3597 /* Free InitEnet command parameter */ 3585 /* Free InitEnet command parameter */
@@ -3603,7 +3591,7 @@ static int ucc_geth_startup(ucc_geth_private_t *ugeth)
3603/* returns a net_device_stats structure pointer */ 3591/* returns a net_device_stats structure pointer */
3604static struct net_device_stats *ucc_geth_get_stats(struct net_device *dev) 3592static struct net_device_stats *ucc_geth_get_stats(struct net_device *dev)
3605{ 3593{
3606 ucc_geth_private_t *ugeth = netdev_priv(dev); 3594 struct ucc_geth_private *ugeth = netdev_priv(dev);
3607 3595
3608 return &(ugeth->stats); 3596 return &(ugeth->stats);
3609} 3597}
@@ -3614,7 +3602,7 @@ static struct net_device_stats *ucc_geth_get_stats(struct net_device *dev)
3614 * starting over will fix the problem. */ 3602 * starting over will fix the problem. */
3615static void ucc_geth_timeout(struct net_device *dev) 3603static void ucc_geth_timeout(struct net_device *dev)
3616{ 3604{
3617 ucc_geth_private_t *ugeth = netdev_priv(dev); 3605 struct ucc_geth_private *ugeth = netdev_priv(dev);
3618 3606
3619 ugeth_vdbg("%s: IN", __FUNCTION__); 3607 ugeth_vdbg("%s: IN", __FUNCTION__);
3620 3608
@@ -3634,7 +3622,7 @@ static void ucc_geth_timeout(struct net_device *dev)
3634/* It is pointed to by the dev->hard_start_xmit function pointer */ 3622/* It is pointed to by the dev->hard_start_xmit function pointer */
3635static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev) 3623static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3636{ 3624{
3637 ucc_geth_private_t *ugeth = netdev_priv(dev); 3625 struct ucc_geth_private *ugeth = netdev_priv(dev);
3638 u8 *bd; /* BD pointer */ 3626 u8 *bd; /* BD pointer */
3639 u32 bd_status; 3627 u32 bd_status;
3640 u8 txQ = 0; 3628 u8 txQ = 0;
@@ -3647,7 +3635,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3647 3635
3648 /* Start from the next BD that should be filled */ 3636 /* Start from the next BD that should be filled */
3649 bd = ugeth->txBd[txQ]; 3637 bd = ugeth->txBd[txQ];
3650 bd_status = BD_STATUS_AND_LENGTH(bd); 3638 bd_status = in_be32((u32 *)bd);
3651 /* Save the skb pointer so we can free it later */ 3639 /* Save the skb pointer so we can free it later */
3652 ugeth->tx_skbuff[txQ][ugeth->skb_curtx[txQ]] = skb; 3640 ugeth->tx_skbuff[txQ][ugeth->skb_curtx[txQ]] = skb;
3653 3641
@@ -3657,20 +3645,21 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3657 1) & TX_RING_MOD_MASK(ugeth->ug_info->bdRingLenTx[txQ]); 3645 1) & TX_RING_MOD_MASK(ugeth->ug_info->bdRingLenTx[txQ]);
3658 3646
3659 /* set up the buffer descriptor */ 3647 /* set up the buffer descriptor */
3660 BD_BUFFER_SET(bd, 3648 out_be32(&((struct qe_bd *)bd)->buf,
3661 dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE)); 3649 dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE));
3662 3650
3663 //printk(KERN_DEBUG"skb->data is 0x%x\n",skb->data); 3651 /* printk(KERN_DEBUG"skb->data is 0x%x\n",skb->data); */
3664 3652
3665 bd_status = (bd_status & T_W) | T_R | T_I | T_L | skb->len; 3653 bd_status = (bd_status & T_W) | T_R | T_I | T_L | skb->len;
3666 3654
3667 BD_STATUS_AND_LENGTH_SET(bd, bd_status); 3655 /* set bd status and length */
3656 out_be32((u32 *)bd, bd_status);
3668 3657
3669 dev->trans_start = jiffies; 3658 dev->trans_start = jiffies;
3670 3659
3671 /* Move to next BD in the ring */ 3660 /* Move to next BD in the ring */
3672 if (!(bd_status & T_W)) 3661 if (!(bd_status & T_W))
3673 ugeth->txBd[txQ] = bd + UCC_GETH_SIZE_OF_BD; 3662 ugeth->txBd[txQ] = bd + sizeof(struct qe_bd);
3674 else 3663 else
3675 ugeth->txBd[txQ] = ugeth->p_tx_bd_ring[txQ]; 3664 ugeth->txBd[txQ] = ugeth->p_tx_bd_ring[txQ];
3676 3665
@@ -3695,7 +3684,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3695 return 0; 3684 return 0;
3696} 3685}
3697 3686
3698static int ucc_geth_rx(ucc_geth_private_t *ugeth, u8 rxQ, int rx_work_limit) 3687static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit)
3699{ 3688{
3700 struct sk_buff *skb; 3689 struct sk_buff *skb;
3701 u8 *bd; 3690 u8 *bd;
@@ -3709,11 +3698,11 @@ static int ucc_geth_rx(ucc_geth_private_t *ugeth, u8 rxQ, int rx_work_limit)
3709 /* collect received buffers */ 3698 /* collect received buffers */
3710 bd = ugeth->rxBd[rxQ]; 3699 bd = ugeth->rxBd[rxQ];
3711 3700
3712 bd_status = BD_STATUS_AND_LENGTH(bd); 3701 bd_status = in_be32((u32 *)bd);
3713 3702
3714 /* while there are received buffers and BD is full (~R_E) */ 3703 /* while there are received buffers and BD is full (~R_E) */
3715 while (!((bd_status & (R_E)) || (--rx_work_limit < 0))) { 3704 while (!((bd_status & (R_E)) || (--rx_work_limit < 0))) {
3716 bdBuffer = (u8 *) BD_BUFFER(bd); 3705 bdBuffer = (u8 *) in_be32(&((struct qe_bd *)bd)->buf);
3717 length = (u16) ((bd_status & BD_LENGTH_MASK) - 4); 3706 length = (u16) ((bd_status & BD_LENGTH_MASK) - 4);
3718 skb = ugeth->rx_skbuff[rxQ][ugeth->skb_currx[rxQ]]; 3707 skb = ugeth->rx_skbuff[rxQ][ugeth->skb_currx[rxQ]];
3719 3708
@@ -3768,9 +3757,9 @@ static int ucc_geth_rx(ucc_geth_private_t *ugeth, u8 rxQ, int rx_work_limit)
3768 if (bd_status & R_W) 3757 if (bd_status & R_W)
3769 bd = ugeth->p_rx_bd_ring[rxQ]; 3758 bd = ugeth->p_rx_bd_ring[rxQ];
3770 else 3759 else
3771 bd += UCC_GETH_SIZE_OF_BD; 3760 bd += sizeof(struct qe_bd);
3772 3761
3773 bd_status = BD_STATUS_AND_LENGTH(bd); 3762 bd_status = in_be32((u32 *)bd);
3774 } 3763 }
3775 3764
3776 ugeth->rxBd[rxQ] = bd; 3765 ugeth->rxBd[rxQ] = bd;
@@ -3781,12 +3770,12 @@ static int ucc_geth_rx(ucc_geth_private_t *ugeth, u8 rxQ, int rx_work_limit)
3781static int ucc_geth_tx(struct net_device *dev, u8 txQ) 3770static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3782{ 3771{
3783 /* Start from the next BD that should be filled */ 3772 /* Start from the next BD that should be filled */
3784 ucc_geth_private_t *ugeth = netdev_priv(dev); 3773 struct ucc_geth_private *ugeth = netdev_priv(dev);
3785 u8 *bd; /* BD pointer */ 3774 u8 *bd; /* BD pointer */
3786 u32 bd_status; 3775 u32 bd_status;
3787 3776
3788 bd = ugeth->confBd[txQ]; 3777 bd = ugeth->confBd[txQ];
3789 bd_status = BD_STATUS_AND_LENGTH(bd); 3778 bd_status = in_be32((u32 *)bd);
3790 3779
3791 /* Normal processing. */ 3780 /* Normal processing. */
3792 while ((bd_status & T_R) == 0) { 3781 while ((bd_status & T_R) == 0) {
@@ -3813,7 +3802,7 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3813 3802
3814 /* Advance the confirmation BD pointer */ 3803 /* Advance the confirmation BD pointer */
3815 if (!(bd_status & T_W)) 3804 if (!(bd_status & T_W))
3816 ugeth->confBd[txQ] += UCC_GETH_SIZE_OF_BD; 3805 ugeth->confBd[txQ] += sizeof(struct qe_bd);
3817 else 3806 else
3818 ugeth->confBd[txQ] = ugeth->p_tx_bd_ring[txQ]; 3807 ugeth->confBd[txQ] = ugeth->p_tx_bd_ring[txQ];
3819 } 3808 }
@@ -3823,7 +3812,7 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3823#ifdef CONFIG_UGETH_NAPI 3812#ifdef CONFIG_UGETH_NAPI
3824static int ucc_geth_poll(struct net_device *dev, int *budget) 3813static int ucc_geth_poll(struct net_device *dev, int *budget)
3825{ 3814{
3826 ucc_geth_private_t *ugeth = netdev_priv(dev); 3815 struct ucc_geth_private *ugeth = netdev_priv(dev);
3827 int howmany; 3816 int howmany;
3828 int rx_work_limit = *budget; 3817 int rx_work_limit = *budget;
3829 u8 rxQ = 0; 3818 u8 rxQ = 0;
@@ -3847,9 +3836,9 @@ static int ucc_geth_poll(struct net_device *dev, int *budget)
3847static irqreturn_t ucc_geth_irq_handler(int irq, void *info) 3836static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
3848{ 3837{
3849 struct net_device *dev = (struct net_device *)info; 3838 struct net_device *dev = (struct net_device *)info;
3850 ucc_geth_private_t *ugeth = netdev_priv(dev); 3839 struct ucc_geth_private *ugeth = netdev_priv(dev);
3851 ucc_fast_private_t *uccf; 3840 struct ucc_fast_private *uccf;
3852 ucc_geth_info_t *ug_info; 3841 struct ucc_geth_info *ug_info;
3853 register u32 ucce = 0; 3842 register u32 ucce = 0;
3854 register u32 bit_mask = UCCE_RXBF_SINGLE_MASK; 3843 register u32 bit_mask = UCCE_RXBF_SINGLE_MASK;
3855 register u32 tx_mask = UCCE_TXBF_SINGLE_MASK; 3844 register u32 tx_mask = UCCE_TXBF_SINGLE_MASK;
@@ -3912,7 +3901,7 @@ static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
3912static irqreturn_t phy_interrupt(int irq, void *dev_id) 3901static irqreturn_t phy_interrupt(int irq, void *dev_id)
3913{ 3902{
3914 struct net_device *dev = (struct net_device *)dev_id; 3903 struct net_device *dev = (struct net_device *)dev_id;
3915 ucc_geth_private_t *ugeth = netdev_priv(dev); 3904 struct ucc_geth_private *ugeth = netdev_priv(dev);
3916 3905
3917 ugeth_vdbg("%s: IN", __FUNCTION__); 3906 ugeth_vdbg("%s: IN", __FUNCTION__);
3918 3907
@@ -3932,8 +3921,8 @@ static irqreturn_t phy_interrupt(int irq, void *dev_id)
3932static void ugeth_phy_change(void *data) 3921static void ugeth_phy_change(void *data)
3933{ 3922{
3934 struct net_device *dev = (struct net_device *)data; 3923 struct net_device *dev = (struct net_device *)data;
3935 ucc_geth_private_t *ugeth = netdev_priv(dev); 3924 struct ucc_geth_private *ugeth = netdev_priv(dev);
3936 ucc_geth_t *ug_regs; 3925 struct ucc_geth *ug_regs;
3937 int result = 0; 3926 int result = 0;
3938 3927
3939 ugeth_vdbg("%s: IN", __FUNCTION__); 3928 ugeth_vdbg("%s: IN", __FUNCTION__);
@@ -3963,7 +3952,7 @@ static void ugeth_phy_change(void *data)
3963static void ugeth_phy_timer(unsigned long data) 3952static void ugeth_phy_timer(unsigned long data)
3964{ 3953{
3965 struct net_device *dev = (struct net_device *)data; 3954 struct net_device *dev = (struct net_device *)data;
3966 ucc_geth_private_t *ugeth = netdev_priv(dev); 3955 struct ucc_geth_private *ugeth = netdev_priv(dev);
3967 3956
3968 schedule_work(&ugeth->tq); 3957 schedule_work(&ugeth->tq);
3969 3958
@@ -3979,7 +3968,7 @@ static void ugeth_phy_timer(unsigned long data)
3979static void ugeth_phy_startup_timer(unsigned long data) 3968static void ugeth_phy_startup_timer(unsigned long data)
3980{ 3969{
3981 struct ugeth_mii_info *mii_info = (struct ugeth_mii_info *)data; 3970 struct ugeth_mii_info *mii_info = (struct ugeth_mii_info *)data;
3982 ucc_geth_private_t *ugeth = netdev_priv(mii_info->dev); 3971 struct ucc_geth_private *ugeth = netdev_priv(mii_info->dev);
3983 static int secondary = UGETH_AN_TIMEOUT; 3972 static int secondary = UGETH_AN_TIMEOUT;
3984 int result; 3973 int result;
3985 3974
@@ -4034,7 +4023,7 @@ static void ugeth_phy_startup_timer(unsigned long data)
4034/* Returns 0 for success. */ 4023/* Returns 0 for success. */
4035static int ucc_geth_open(struct net_device *dev) 4024static int ucc_geth_open(struct net_device *dev)
4036{ 4025{
4037 ucc_geth_private_t *ugeth = netdev_priv(dev); 4026 struct ucc_geth_private *ugeth = netdev_priv(dev);
4038 int err; 4027 int err;
4039 4028
4040 ugeth_vdbg("%s: IN", __FUNCTION__); 4029 ugeth_vdbg("%s: IN", __FUNCTION__);
@@ -4111,7 +4100,7 @@ static int ucc_geth_open(struct net_device *dev)
4111/* Stops the kernel queue, and halts the controller */ 4100/* Stops the kernel queue, and halts the controller */
4112static int ucc_geth_close(struct net_device *dev) 4101static int ucc_geth_close(struct net_device *dev)
4113{ 4102{
4114 ucc_geth_private_t *ugeth = netdev_priv(dev); 4103 struct ucc_geth_private *ugeth = netdev_priv(dev);
4115 4104
4116 ugeth_vdbg("%s: IN", __FUNCTION__); 4105 ugeth_vdbg("%s: IN", __FUNCTION__);
4117 4106
@@ -4130,30 +4119,53 @@ static int ucc_geth_close(struct net_device *dev)
4130 4119
4131const struct ethtool_ops ucc_geth_ethtool_ops = { }; 4120const struct ethtool_ops ucc_geth_ethtool_ops = { };
4132 4121
4133static int ucc_geth_probe(struct device *device) 4122static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *match)
4134{ 4123{
4135 struct platform_device *pdev = to_platform_device(device); 4124 struct device *device = &ofdev->dev;
4136 struct ucc_geth_platform_data *ugeth_pdata; 4125 struct device_node *np = ofdev->node;
4137 struct net_device *dev = NULL; 4126 struct net_device *dev = NULL;
4138 struct ucc_geth_private *ugeth = NULL; 4127 struct ucc_geth_private *ugeth = NULL;
4139 struct ucc_geth_info *ug_info; 4128 struct ucc_geth_info *ug_info;
4140 int err; 4129 struct resource res;
4130 struct device_node *phy;
4131 int err, ucc_num, phy_interface;
4141 static int mii_mng_configured = 0; 4132 static int mii_mng_configured = 0;
4133 const phandle *ph;
4134 const unsigned int *prop;
4142 4135
4143 ugeth_vdbg("%s: IN", __FUNCTION__); 4136 ugeth_vdbg("%s: IN", __FUNCTION__);
4144 4137
4145 ugeth_pdata = (struct ucc_geth_platform_data *)pdev->dev.platform_data; 4138 prop = get_property(np, "device-id", NULL);
4139 ucc_num = *prop - 1;
4140 if ((ucc_num < 0) || (ucc_num > 7))
4141 return -ENODEV;
4142
4143 ug_info = &ugeth_info[ucc_num];
4144 ug_info->uf_info.ucc_num = ucc_num;
4145 prop = get_property(np, "rx-clock", NULL);
4146 ug_info->uf_info.rx_clock = *prop;
4147 prop = get_property(np, "tx-clock", NULL);
4148 ug_info->uf_info.tx_clock = *prop;
4149 err = of_address_to_resource(np, 0, &res);
4150 if (err)
4151 return -EINVAL;
4152
4153 ug_info->uf_info.regs = res.start;
4154 ug_info->uf_info.irq = irq_of_parse_and_map(np, 0);
4155
4156 ph = get_property(np, "phy-handle", NULL);
4157 phy = of_find_node_by_phandle(*ph);
4146 4158
4147 ug_info = &ugeth_info[pdev->id]; 4159 if (phy == NULL)
4148 ug_info->uf_info.ucc_num = pdev->id; 4160 return -ENODEV;
4149 ug_info->uf_info.rx_clock = ugeth_pdata->rx_clock; 4161
4150 ug_info->uf_info.tx_clock = ugeth_pdata->tx_clock; 4162 prop = get_property(phy, "reg", NULL);
4151 ug_info->uf_info.regs = ugeth_pdata->phy_reg_addr; 4163 ug_info->phy_address = *prop;
4152 ug_info->uf_info.irq = platform_get_irq(pdev, 0); 4164 prop = get_property(phy, "interface", NULL);
4153 ug_info->phy_address = ugeth_pdata->phy_id; 4165 ug_info->enet_interface = *prop;
4154 ug_info->enet_interface = ugeth_pdata->phy_interface; 4166 ug_info->phy_interrupt = irq_of_parse_and_map(phy, 0);
4155 ug_info->board_flags = ugeth_pdata->board_flags; 4167 ug_info->board_flags = (ug_info->phy_interrupt == NO_IRQ)?
4156 ug_info->phy_interrupt = ugeth_pdata->phy_interrupt; 4168 0:FSL_UGETH_BRD_HAS_PHY_INTR;
4157 4169
4158 printk(KERN_INFO "ucc_geth: UCC%1d at 0x%8x (irq = %d) \n", 4170 printk(KERN_INFO "ucc_geth: UCC%1d at 0x%8x (irq = %d) \n",
4159 ug_info->uf_info.ucc_num + 1, ug_info->uf_info.regs, 4171 ug_info->uf_info.ucc_num + 1, ug_info->uf_info.regs,
@@ -4161,12 +4173,44 @@ static int ucc_geth_probe(struct device *device)
4161 4173
4162 if (ug_info == NULL) { 4174 if (ug_info == NULL) {
4163 ugeth_err("%s: [%d] Missing additional data!", __FUNCTION__, 4175 ugeth_err("%s: [%d] Missing additional data!", __FUNCTION__,
4164 pdev->id); 4176 ucc_num);
4165 return -ENODEV; 4177 return -ENODEV;
4166 } 4178 }
4167 4179
4180 /* FIXME: Work around for early chip rev. */
4181 /* There's a bug in initial chip rev(s) in the RGMII ac */
4182 /* timing. */
4183 /* The following compensates by writing to the reserved */
4184 /* QE Port Output Hold Registers (CPOH1?). */
4185 prop = get_property(phy, "interface", NULL);
4186 phy_interface = *prop;
4187 if ((phy_interface == ENET_1000_RGMII) ||
4188 (phy_interface == ENET_100_RGMII) ||
4189 (phy_interface == ENET_10_RGMII)) {
4190 struct device_node *soc;
4191 phys_addr_t immrbase = -1;
4192 u32 *tmp_reg;
4193 u32 tmp_val;
4194
4195 soc = of_find_node_by_type(NULL, "soc");
4196 if (soc) {
4197 unsigned int size;
4198 const void *prop = get_property(soc, "reg", &size);
4199 immrbase = of_translate_address(soc, prop);
4200 of_node_put(soc);
4201 };
4202
4203 tmp_reg = (u32 *) ioremap(immrbase + 0x14A8, 0x4);
4204 tmp_val = in_be32(tmp_reg);
4205 if (ucc_num == 1)
4206 out_be32(tmp_reg, tmp_val | 0x00003000);
4207 else if (ucc_num == 2)
4208 out_be32(tmp_reg, tmp_val | 0x0c000000);
4209 iounmap(tmp_reg);
4210 }
4211
4168 if (!mii_mng_configured) { 4212 if (!mii_mng_configured) {
4169 ucc_set_qe_mux_mii_mng(ug_info->uf_info.ucc_num); 4213 ucc_set_qe_mux_mii_mng(ucc_num);
4170 mii_mng_configured = 1; 4214 mii_mng_configured = 1;
4171 } 4215 }
4172 4216
@@ -4213,13 +4257,14 @@ static int ucc_geth_probe(struct device *device)
4213 4257
4214 ugeth->ug_info = ug_info; 4258 ugeth->ug_info = ug_info;
4215 ugeth->dev = dev; 4259 ugeth->dev = dev;
4216 memcpy(dev->dev_addr, ugeth_pdata->mac_addr, 6); 4260 memcpy(dev->dev_addr, get_property(np, "mac-address", NULL), 6);
4217 4261
4218 return 0; 4262 return 0;
4219} 4263}
4220 4264
4221static int ucc_geth_remove(struct device *device) 4265static int ucc_geth_remove(struct of_device* ofdev)
4222{ 4266{
4267 struct device *device = &ofdev->dev;
4223 struct net_device *dev = dev_get_drvdata(device); 4268 struct net_device *dev = dev_get_drvdata(device);
4224 struct ucc_geth_private *ugeth = netdev_priv(dev); 4269 struct ucc_geth_private *ugeth = netdev_priv(dev);
4225 4270
@@ -4230,28 +4275,38 @@ static int ucc_geth_remove(struct device *device)
4230 return 0; 4275 return 0;
4231} 4276}
4232 4277
4233/* Structure for a device driver */ 4278static struct of_device_id ucc_geth_match[] = {
4234static struct device_driver ucc_geth_driver = { 4279 {
4235 .name = DRV_NAME, 4280 .type = "network",
4236 .bus = &platform_bus_type, 4281 .compatible = "ucc_geth",
4237 .probe = ucc_geth_probe, 4282 },
4238 .remove = ucc_geth_remove, 4283 {},
4284};
4285
4286MODULE_DEVICE_TABLE(of, ucc_geth_match);
4287
4288static struct of_platform_driver ucc_geth_driver = {
4289 .name = DRV_NAME,
4290 .match_table = ucc_geth_match,
4291 .probe = ucc_geth_probe,
4292 .remove = ucc_geth_remove,
4239}; 4293};
4240 4294
4241static int __init ucc_geth_init(void) 4295static int __init ucc_geth_init(void)
4242{ 4296{
4243 int i; 4297 int i;
4298
4244 printk(KERN_INFO "ucc_geth: " DRV_DESC "\n"); 4299 printk(KERN_INFO "ucc_geth: " DRV_DESC "\n");
4245 for (i = 0; i < 8; i++) 4300 for (i = 0; i < 8; i++)
4246 memcpy(&(ugeth_info[i]), &ugeth_primary_info, 4301 memcpy(&(ugeth_info[i]), &ugeth_primary_info,
4247 sizeof(ugeth_primary_info)); 4302 sizeof(ugeth_primary_info));
4248 4303
4249 return driver_register(&ucc_geth_driver); 4304 return of_register_driver(&ucc_geth_driver);
4250} 4305}
4251 4306
4252static void __exit ucc_geth_exit(void) 4307static void __exit ucc_geth_exit(void)
4253{ 4308{
4254 driver_unregister(&ucc_geth_driver); 4309 of_unregister_driver(&ucc_geth_driver);
4255} 4310}
4256 4311
4257module_init(ucc_geth_init); 4312module_init(ucc_geth_init);
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h
index 005965f5dd9b..a66561253593 100644
--- a/drivers/net/ucc_geth.h
+++ b/drivers/net/ucc_geth.h
@@ -36,24 +36,24 @@
36#define ENET_INIT_PARAM_MAX_ENTRIES_RX 9 36#define ENET_INIT_PARAM_MAX_ENTRIES_RX 9
37#define ENET_INIT_PARAM_MAX_ENTRIES_TX 8 37#define ENET_INIT_PARAM_MAX_ENTRIES_TX 8
38 38
39typedef struct ucc_mii_mng { 39struct ucc_mii_mng {
40 u32 miimcfg; /* MII management configuration reg */ 40 u32 miimcfg; /* MII management configuration reg */
41 u32 miimcom; /* MII management command reg */ 41 u32 miimcom; /* MII management command reg */
42 u32 miimadd; /* MII management address reg */ 42 u32 miimadd; /* MII management address reg */
43 u32 miimcon; /* MII management control reg */ 43 u32 miimcon; /* MII management control reg */
44 u32 miimstat; /* MII management status reg */ 44 u32 miimstat; /* MII management status reg */
45 u32 miimind; /* MII management indication reg */ 45 u32 miimind; /* MII management indication reg */
46} __attribute__ ((packed)) ucc_mii_mng_t; 46} __attribute__ ((packed));
47 47
48typedef struct ucc_geth { 48struct ucc_geth {
49 ucc_fast_t uccf; 49 struct ucc_fast uccf;
50 50
51 u32 maccfg1; /* mac configuration reg. 1 */ 51 u32 maccfg1; /* mac configuration reg. 1 */
52 u32 maccfg2; /* mac configuration reg. 2 */ 52 u32 maccfg2; /* mac configuration reg. 2 */
53 u32 ipgifg; /* interframe gap reg. */ 53 u32 ipgifg; /* interframe gap reg. */
54 u32 hafdup; /* half-duplex reg. */ 54 u32 hafdup; /* half-duplex reg. */
55 u8 res1[0x10]; 55 u8 res1[0x10];
56 ucc_mii_mng_t miimng; /* MII management structure */ 56 struct ucc_mii_mng miimng; /* MII management structure */
57 u32 ifctl; /* interface control reg */ 57 u32 ifctl; /* interface control reg */
58 u32 ifstat; /* interface statux reg */ 58 u32 ifstat; /* interface statux reg */
59 u32 macstnaddr1; /* mac station address part 1 reg */ 59 u32 macstnaddr1; /* mac station address part 1 reg */
@@ -111,7 +111,7 @@ typedef struct ucc_geth {
111 u32 scar; /* Statistics carry register */ 111 u32 scar; /* Statistics carry register */
112 u32 scam; /* Statistics caryy mask register */ 112 u32 scam; /* Statistics caryy mask register */
113 u8 res5[0x200 - 0x1c4]; 113 u8 res5[0x200 - 0x1c4];
114} __attribute__ ((packed)) ucc_geth_t; 114} __attribute__ ((packed));
115 115
116/* UCC GETH TEMODR Register */ 116/* UCC GETH TEMODR Register */
117#define TEMODER_TX_RMON_STATISTICS_ENABLE 0x0100 /* enable Tx statistics 117#define TEMODER_TX_RMON_STATISTICS_ENABLE 0x0100 /* enable Tx statistics
@@ -508,39 +508,39 @@ typedef struct ucc_geth {
508/* UCC GETH UDSR (Data Synchronization Register) */ 508/* UCC GETH UDSR (Data Synchronization Register) */
509#define UDSR_MAGIC 0x067E 509#define UDSR_MAGIC 0x067E
510 510
511typedef struct ucc_geth_thread_data_tx { 511struct ucc_geth_thread_data_tx {
512 u8 res0[104]; 512 u8 res0[104];
513} __attribute__ ((packed)) ucc_geth_thread_data_tx_t; 513} __attribute__ ((packed));
514 514
515typedef struct ucc_geth_thread_data_rx { 515struct ucc_geth_thread_data_rx {
516 u8 res0[40]; 516 u8 res0[40];
517} __attribute__ ((packed)) ucc_geth_thread_data_rx_t; 517} __attribute__ ((packed));
518 518
519/* Send Queue Queue-Descriptor */ 519/* Send Queue Queue-Descriptor */
520typedef struct ucc_geth_send_queue_qd { 520struct ucc_geth_send_queue_qd {
521 u32 bd_ring_base; /* pointer to BD ring base address */ 521 u32 bd_ring_base; /* pointer to BD ring base address */
522 u8 res0[0x8]; 522 u8 res0[0x8];
523 u32 last_bd_completed_address;/* initialize to last entry in BD ring */ 523 u32 last_bd_completed_address;/* initialize to last entry in BD ring */
524 u8 res1[0x30]; 524 u8 res1[0x30];
525} __attribute__ ((packed)) ucc_geth_send_queue_qd_t; 525} __attribute__ ((packed));
526 526
527typedef struct ucc_geth_send_queue_mem_region { 527struct ucc_geth_send_queue_mem_region {
528 ucc_geth_send_queue_qd_t sqqd[NUM_TX_QUEUES]; 528 struct ucc_geth_send_queue_qd sqqd[NUM_TX_QUEUES];
529} __attribute__ ((packed)) ucc_geth_send_queue_mem_region_t; 529} __attribute__ ((packed));
530 530
531typedef struct ucc_geth_thread_tx_pram { 531struct ucc_geth_thread_tx_pram {
532 u8 res0[64]; 532 u8 res0[64];
533} __attribute__ ((packed)) ucc_geth_thread_tx_pram_t; 533} __attribute__ ((packed));
534 534
535typedef struct ucc_geth_thread_rx_pram { 535struct ucc_geth_thread_rx_pram {
536 u8 res0[128]; 536 u8 res0[128];
537} __attribute__ ((packed)) ucc_geth_thread_rx_pram_t; 537} __attribute__ ((packed));
538 538
539#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING 64 539#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING 64
540#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_8 64 540#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_8 64
541#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_16 96 541#define THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_16 96
542 542
543typedef struct ucc_geth_scheduler { 543struct ucc_geth_scheduler {
544 u16 cpucount0; /* CPU packet counter */ 544 u16 cpucount0; /* CPU packet counter */
545 u16 cpucount1; /* CPU packet counter */ 545 u16 cpucount1; /* CPU packet counter */
546 u16 cecount0; /* QE packet counter */ 546 u16 cecount0; /* QE packet counter */
@@ -574,9 +574,9 @@ typedef struct ucc_geth_scheduler {
574 /**< weight factor for queues */ 574 /**< weight factor for queues */
575 u32 minw; /* temporary variable handled by QE */ 575 u32 minw; /* temporary variable handled by QE */
576 u8 res1[0x70 - 0x64]; 576 u8 res1[0x70 - 0x64];
577} __attribute__ ((packed)) ucc_geth_scheduler_t; 577} __attribute__ ((packed));
578 578
579typedef struct ucc_geth_tx_firmware_statistics_pram { 579struct ucc_geth_tx_firmware_statistics_pram {
580 u32 sicoltx; /* single collision */ 580 u32 sicoltx; /* single collision */
581 u32 mulcoltx; /* multiple collision */ 581 u32 mulcoltx; /* multiple collision */
582 u32 latecoltxfr; /* late collision */ 582 u32 latecoltxfr; /* late collision */
@@ -596,9 +596,9 @@ typedef struct ucc_geth_tx_firmware_statistics_pram {
596 and 1518 octets */ 596 and 1518 octets */
597 u32 txpktsjumbo; /* total packets (including bad) between 1024 597 u32 txpktsjumbo; /* total packets (including bad) between 1024
598 and MAXLength octets */ 598 and MAXLength octets */
599} __attribute__ ((packed)) ucc_geth_tx_firmware_statistics_pram_t; 599} __attribute__ ((packed));
600 600
601typedef struct ucc_geth_rx_firmware_statistics_pram { 601struct ucc_geth_rx_firmware_statistics_pram {
602 u32 frrxfcser; /* frames with crc error */ 602 u32 frrxfcser; /* frames with crc error */
603 u32 fraligner; /* frames with alignment error */ 603 u32 fraligner; /* frames with alignment error */
604 u32 inrangelenrxer; /* in range length error */ 604 u32 inrangelenrxer; /* in range length error */
@@ -630,33 +630,33 @@ typedef struct ucc_geth_rx_firmware_statistics_pram {
630 replaced */ 630 replaced */
631 u32 insertvlan; /* total frames that had their VLAN tag 631 u32 insertvlan; /* total frames that had their VLAN tag
632 inserted */ 632 inserted */
633} __attribute__ ((packed)) ucc_geth_rx_firmware_statistics_pram_t; 633} __attribute__ ((packed));
634 634
635typedef struct ucc_geth_rx_interrupt_coalescing_entry { 635struct ucc_geth_rx_interrupt_coalescing_entry {
636 u32 interruptcoalescingmaxvalue; /* interrupt coalescing max 636 u32 interruptcoalescingmaxvalue; /* interrupt coalescing max
637 value */ 637 value */
638 u32 interruptcoalescingcounter; /* interrupt coalescing counter, 638 u32 interruptcoalescingcounter; /* interrupt coalescing counter,
639 initialize to 639 initialize to
640 interruptcoalescingmaxvalue */ 640 interruptcoalescingmaxvalue */
641} __attribute__ ((packed)) ucc_geth_rx_interrupt_coalescing_entry_t; 641} __attribute__ ((packed));
642 642
643typedef struct ucc_geth_rx_interrupt_coalescing_table { 643struct ucc_geth_rx_interrupt_coalescing_table {
644 ucc_geth_rx_interrupt_coalescing_entry_t coalescingentry[NUM_RX_QUEUES]; 644 struct ucc_geth_rx_interrupt_coalescing_entry coalescingentry[NUM_RX_QUEUES];
645 /**< interrupt coalescing entry */ 645 /**< interrupt coalescing entry */
646} __attribute__ ((packed)) ucc_geth_rx_interrupt_coalescing_table_t; 646} __attribute__ ((packed));
647 647
648typedef struct ucc_geth_rx_prefetched_bds { 648struct ucc_geth_rx_prefetched_bds {
649 qe_bd_t bd[NUM_BDS_IN_PREFETCHED_BDS]; /* prefetched bd */ 649 struct qe_bd bd[NUM_BDS_IN_PREFETCHED_BDS]; /* prefetched bd */
650} __attribute__ ((packed)) ucc_geth_rx_prefetched_bds_t; 650} __attribute__ ((packed));
651 651
652typedef struct ucc_geth_rx_bd_queues_entry { 652struct ucc_geth_rx_bd_queues_entry {
653 u32 bdbaseptr; /* BD base pointer */ 653 u32 bdbaseptr; /* BD base pointer */
654 u32 bdptr; /* BD pointer */ 654 u32 bdptr; /* BD pointer */
655 u32 externalbdbaseptr; /* external BD base pointer */ 655 u32 externalbdbaseptr; /* external BD base pointer */
656 u32 externalbdptr; /* external BD pointer */ 656 u32 externalbdptr; /* external BD pointer */
657} __attribute__ ((packed)) ucc_geth_rx_bd_queues_entry_t; 657} __attribute__ ((packed));
658 658
659typedef struct ucc_geth_tx_global_pram { 659struct ucc_geth_tx_global_pram {
660 u16 temoder; 660 u16 temoder;
661 u8 res0[0x38 - 0x02]; 661 u8 res0[0x38 - 0x02];
662 u32 sqptr; /* a base pointer to send queue memory region */ 662 u32 sqptr; /* a base pointer to send queue memory region */
@@ -670,15 +670,15 @@ typedef struct ucc_geth_tx_global_pram {
670 u32 tqptr; /* a base pointer to the Tx Queues Memory 670 u32 tqptr; /* a base pointer to the Tx Queues Memory
671 Region */ 671 Region */
672 u8 res2[0x80 - 0x74]; 672 u8 res2[0x80 - 0x74];
673} __attribute__ ((packed)) ucc_geth_tx_global_pram_t; 673} __attribute__ ((packed));
674 674
675/* structure representing Extended Filtering Global Parameters in PRAM */ 675/* structure representing Extended Filtering Global Parameters in PRAM */
676typedef struct ucc_geth_exf_global_pram { 676struct ucc_geth_exf_global_pram {
677 u32 l2pcdptr; /* individual address filter, high */ 677 u32 l2pcdptr; /* individual address filter, high */
678 u8 res0[0x10 - 0x04]; 678 u8 res0[0x10 - 0x04];
679} __attribute__ ((packed)) ucc_geth_exf_global_pram_t; 679} __attribute__ ((packed));
680 680
681typedef struct ucc_geth_rx_global_pram { 681struct ucc_geth_rx_global_pram {
682 u32 remoder; /* ethernet mode reg. */ 682 u32 remoder; /* ethernet mode reg. */
683 u32 rqptr; /* base pointer to the Rx Queues Memory Region*/ 683 u32 rqptr; /* base pointer to the Rx Queues Memory Region*/
684 u32 res0[0x1]; 684 u32 res0[0x1];
@@ -710,12 +710,12 @@ typedef struct ucc_geth_rx_global_pram {
710 u32 exfGlobalParam; /* base address for extended filtering global 710 u32 exfGlobalParam; /* base address for extended filtering global
711 parameters */ 711 parameters */
712 u8 res6[0x100 - 0xC4]; /* Initialize to zero */ 712 u8 res6[0x100 - 0xC4]; /* Initialize to zero */
713} __attribute__ ((packed)) ucc_geth_rx_global_pram_t; 713} __attribute__ ((packed));
714 714
715#define GRACEFUL_STOP_ACKNOWLEDGE_RX 0x01 715#define GRACEFUL_STOP_ACKNOWLEDGE_RX 0x01
716 716
717/* structure representing InitEnet command */ 717/* structure representing InitEnet command */
718typedef struct ucc_geth_init_pram { 718struct ucc_geth_init_pram {
719 u8 resinit1; 719 u8 resinit1;
720 u8 resinit2; 720 u8 resinit2;
721 u8 resinit3; 721 u8 resinit3;
@@ -729,7 +729,7 @@ typedef struct ucc_geth_init_pram {
729 u32 txglobal; /* tx global */ 729 u32 txglobal; /* tx global */
730 u32 txthread[ENET_INIT_PARAM_MAX_ENTRIES_TX]; /* tx threads */ 730 u32 txthread[ENET_INIT_PARAM_MAX_ENTRIES_TX]; /* tx threads */
731 u8 res3[0x1]; 731 u8 res3[0x1];
732} __attribute__ ((packed)) ucc_geth_init_pram_t; 732} __attribute__ ((packed));
733 733
734#define ENET_INIT_PARAM_RGF_SHIFT (32 - 4) 734#define ENET_INIT_PARAM_RGF_SHIFT (32 - 4)
735#define ENET_INIT_PARAM_TGF_SHIFT (32 - 8) 735#define ENET_INIT_PARAM_TGF_SHIFT (32 - 8)
@@ -746,27 +746,27 @@ typedef struct ucc_geth_init_pram {
746#define ENET_INIT_PARAM_MAGIC_RES_INIT5 0x0400 746#define ENET_INIT_PARAM_MAGIC_RES_INIT5 0x0400
747 747
748/* structure representing 82xx Address Filtering Enet Address in PRAM */ 748/* structure representing 82xx Address Filtering Enet Address in PRAM */
749typedef struct ucc_geth_82xx_enet_address { 749struct ucc_geth_82xx_enet_address {
750 u8 res1[0x2]; 750 u8 res1[0x2];
751 u16 h; /* address (MSB) */ 751 u16 h; /* address (MSB) */
752 u16 m; /* address */ 752 u16 m; /* address */
753 u16 l; /* address (LSB) */ 753 u16 l; /* address (LSB) */
754} __attribute__ ((packed)) ucc_geth_82xx_enet_address_t; 754} __attribute__ ((packed));
755 755
756/* structure representing 82xx Address Filtering PRAM */ 756/* structure representing 82xx Address Filtering PRAM */
757typedef struct ucc_geth_82xx_address_filtering_pram { 757struct ucc_geth_82xx_address_filtering_pram {
758 u32 iaddr_h; /* individual address filter, high */ 758 u32 iaddr_h; /* individual address filter, high */
759 u32 iaddr_l; /* individual address filter, low */ 759 u32 iaddr_l; /* individual address filter, low */
760 u32 gaddr_h; /* group address filter, high */ 760 u32 gaddr_h; /* group address filter, high */
761 u32 gaddr_l; /* group address filter, low */ 761 u32 gaddr_l; /* group address filter, low */
762 ucc_geth_82xx_enet_address_t taddr; 762 struct ucc_geth_82xx_enet_address taddr;
763 ucc_geth_82xx_enet_address_t paddr[NUM_OF_PADDRS]; 763 struct ucc_geth_82xx_enet_address paddr[NUM_OF_PADDRS];
764 u8 res0[0x40 - 0x38]; 764 u8 res0[0x40 - 0x38];
765} __attribute__ ((packed)) ucc_geth_82xx_address_filtering_pram_t; 765} __attribute__ ((packed));
766 766
767/* GETH Tx firmware statistics structure, used when calling 767/* GETH Tx firmware statistics structure, used when calling
768 UCC_GETH_GetStatistics. */ 768 UCC_GETH_GetStatistics. */
769typedef struct ucc_geth_tx_firmware_statistics { 769struct ucc_geth_tx_firmware_statistics {
770 u32 sicoltx; /* single collision */ 770 u32 sicoltx; /* single collision */
771 u32 mulcoltx; /* multiple collision */ 771 u32 mulcoltx; /* multiple collision */
772 u32 latecoltxfr; /* late collision */ 772 u32 latecoltxfr; /* late collision */
@@ -786,11 +786,11 @@ typedef struct ucc_geth_tx_firmware_statistics {
786 and 1518 octets */ 786 and 1518 octets */
787 u32 txpktsjumbo; /* total packets (including bad) between 1024 787 u32 txpktsjumbo; /* total packets (including bad) between 1024
788 and MAXLength octets */ 788 and MAXLength octets */
789} __attribute__ ((packed)) ucc_geth_tx_firmware_statistics_t; 789} __attribute__ ((packed));
790 790
791/* GETH Rx firmware statistics structure, used when calling 791/* GETH Rx firmware statistics structure, used when calling
792 UCC_GETH_GetStatistics. */ 792 UCC_GETH_GetStatistics. */
793typedef struct ucc_geth_rx_firmware_statistics { 793struct ucc_geth_rx_firmware_statistics {
794 u32 frrxfcser; /* frames with crc error */ 794 u32 frrxfcser; /* frames with crc error */
795 u32 fraligner; /* frames with alignment error */ 795 u32 fraligner; /* frames with alignment error */
796 u32 inrangelenrxer; /* in range length error */ 796 u32 inrangelenrxer; /* in range length error */
@@ -822,11 +822,11 @@ typedef struct ucc_geth_rx_firmware_statistics {
822 replaced */ 822 replaced */
823 u32 insertvlan; /* total frames that had their VLAN tag 823 u32 insertvlan; /* total frames that had their VLAN tag
824 inserted */ 824 inserted */
825} __attribute__ ((packed)) ucc_geth_rx_firmware_statistics_t; 825} __attribute__ ((packed));
826 826
827/* GETH hardware statistics structure, used when calling 827/* GETH hardware statistics structure, used when calling
828 UCC_GETH_GetStatistics. */ 828 UCC_GETH_GetStatistics. */
829typedef struct ucc_geth_hardware_statistics { 829struct ucc_geth_hardware_statistics {
830 u32 tx64; /* Total number of frames (including bad 830 u32 tx64; /* Total number of frames (including bad
831 frames) transmitted that were exactly of the 831 frames) transmitted that were exactly of the
832 minimal length (64 for un tagged, 68 for 832 minimal length (64 for un tagged, 68 for
@@ -871,7 +871,7 @@ typedef struct ucc_geth_hardware_statistics {
871 u32 rbca; /* Total number of frames received succesfully 871 u32 rbca; /* Total number of frames received succesfully
872 that had destination address equal to the 872 that had destination address equal to the
873 broadcast address */ 873 broadcast address */
874} __attribute__ ((packed)) ucc_geth_hardware_statistics_t; 874} __attribute__ ((packed));
875 875
876/* UCC GETH Tx errors returned via TxConf callback */ 876/* UCC GETH Tx errors returned via TxConf callback */
877#define TX_ERRORS_DEF 0x0200 877#define TX_ERRORS_DEF 0x0200
@@ -1013,21 +1013,21 @@ typedef struct ucc_geth_hardware_statistics {
1013 (MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_112) 1013 (MIIMCFG_MANAGEMENT_CLOCK_DIVIDE_BY_112)
1014 1014
1015/* Ethernet speed */ 1015/* Ethernet speed */
1016typedef enum enet_speed { 1016enum enet_speed {
1017 ENET_SPEED_10BT, /* 10 Base T */ 1017 ENET_SPEED_10BT, /* 10 Base T */
1018 ENET_SPEED_100BT, /* 100 Base T */ 1018 ENET_SPEED_100BT, /* 100 Base T */
1019 ENET_SPEED_1000BT /* 1000 Base T */ 1019 ENET_SPEED_1000BT /* 1000 Base T */
1020} enet_speed_e; 1020};
1021 1021
1022/* Ethernet Address Type. */ 1022/* Ethernet Address Type. */
1023typedef enum enet_addr_type { 1023enum enet_addr_type {
1024 ENET_ADDR_TYPE_INDIVIDUAL, 1024 ENET_ADDR_TYPE_INDIVIDUAL,
1025 ENET_ADDR_TYPE_GROUP, 1025 ENET_ADDR_TYPE_GROUP,
1026 ENET_ADDR_TYPE_BROADCAST 1026 ENET_ADDR_TYPE_BROADCAST
1027} enet_addr_type_e; 1027};
1028 1028
1029/* TBI / MII Set Register */ 1029/* TBI / MII Set Register */
1030typedef enum enet_tbi_mii_reg { 1030enum enet_tbi_mii_reg {
1031 ENET_TBI_MII_CR = 0x00, /* Control (CR ) */ 1031 ENET_TBI_MII_CR = 0x00, /* Control (CR ) */
1032 ENET_TBI_MII_SR = 0x01, /* Status (SR ) */ 1032 ENET_TBI_MII_SR = 0x01, /* Status (SR ) */
1033 ENET_TBI_MII_ANA = 0x04, /* AN advertisement (ANA ) */ 1033 ENET_TBI_MII_ANA = 0x04, /* AN advertisement (ANA ) */
@@ -1040,10 +1040,10 @@ typedef enum enet_tbi_mii_reg {
1040 ENET_TBI_MII_EXST = 0x0F, /* Extended status (EXST ) */ 1040 ENET_TBI_MII_EXST = 0x0F, /* Extended status (EXST ) */
1041 ENET_TBI_MII_JD = 0x10, /* Jitter diagnostics (JD ) */ 1041 ENET_TBI_MII_JD = 0x10, /* Jitter diagnostics (JD ) */
1042 ENET_TBI_MII_TBICON = 0x11 /* TBI control (TBICON ) */ 1042 ENET_TBI_MII_TBICON = 0x11 /* TBI control (TBICON ) */
1043} enet_tbi_mii_reg_e; 1043};
1044 1044
1045/* UCC GETH 82xx Ethernet Address Recognition Location */ 1045/* UCC GETH 82xx Ethernet Address Recognition Location */
1046typedef enum ucc_geth_enet_address_recognition_location { 1046enum ucc_geth_enet_address_recognition_location {
1047 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_STATION_ADDRESS,/* station 1047 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_STATION_ADDRESS,/* station
1048 address */ 1048 address */
1049 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR_FIRST, /* additional 1049 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_PADDR_FIRST, /* additional
@@ -1065,10 +1065,10 @@ typedef enum ucc_geth_enet_address_recognition_location {
1065 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_GROUP_HASH, /* group hash */ 1065 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_GROUP_HASH, /* group hash */
1066 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_INDIVIDUAL_HASH /* individual 1066 UCC_GETH_ENET_ADDRESS_RECOGNITION_LOCATION_INDIVIDUAL_HASH /* individual
1067 hash */ 1067 hash */
1068} ucc_geth_enet_address_recognition_location_e; 1068};
1069 1069
1070/* UCC GETH vlan operation tagged */ 1070/* UCC GETH vlan operation tagged */
1071typedef enum ucc_geth_vlan_operation_tagged { 1071enum ucc_geth_vlan_operation_tagged {
1072 UCC_GETH_VLAN_OPERATION_TAGGED_NOP = 0x0, /* Tagged - nop */ 1072 UCC_GETH_VLAN_OPERATION_TAGGED_NOP = 0x0, /* Tagged - nop */
1073 UCC_GETH_VLAN_OPERATION_TAGGED_REPLACE_VID_PORTION_OF_Q_TAG 1073 UCC_GETH_VLAN_OPERATION_TAGGED_REPLACE_VID_PORTION_OF_Q_TAG
1074 = 0x1, /* Tagged - replace vid portion of q tag */ 1074 = 0x1, /* Tagged - replace vid portion of q tag */
@@ -1076,18 +1076,18 @@ typedef enum ucc_geth_vlan_operation_tagged {
1076 = 0x2, /* Tagged - if vid0 replace vid with default value */ 1076 = 0x2, /* Tagged - if vid0 replace vid with default value */
1077 UCC_GETH_VLAN_OPERATION_TAGGED_EXTRACT_Q_TAG_FROM_FRAME 1077 UCC_GETH_VLAN_OPERATION_TAGGED_EXTRACT_Q_TAG_FROM_FRAME
1078 = 0x3 /* Tagged - extract q tag from frame */ 1078 = 0x3 /* Tagged - extract q tag from frame */
1079} ucc_geth_vlan_operation_tagged_e; 1079};
1080 1080
1081/* UCC GETH vlan operation non-tagged */ 1081/* UCC GETH vlan operation non-tagged */
1082typedef enum ucc_geth_vlan_operation_non_tagged { 1082enum ucc_geth_vlan_operation_non_tagged {
1083 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP = 0x0, /* Non tagged - nop */ 1083 UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP = 0x0, /* Non tagged - nop */
1084 UCC_GETH_VLAN_OPERATION_NON_TAGGED_Q_TAG_INSERT = 0x1 /* Non tagged - 1084 UCC_GETH_VLAN_OPERATION_NON_TAGGED_Q_TAG_INSERT = 0x1 /* Non tagged -
1085 q tag insert 1085 q tag insert
1086 */ 1086 */
1087} ucc_geth_vlan_operation_non_tagged_e; 1087};
1088 1088
1089/* UCC GETH Rx Quality of Service Mode */ 1089/* UCC GETH Rx Quality of Service Mode */
1090typedef enum ucc_geth_qos_mode { 1090enum ucc_geth_qos_mode {
1091 UCC_GETH_QOS_MODE_DEFAULT = 0x0, /* default queue */ 1091 UCC_GETH_QOS_MODE_DEFAULT = 0x0, /* default queue */
1092 UCC_GETH_QOS_MODE_QUEUE_NUM_FROM_L2_CRITERIA = 0x1, /* queue 1092 UCC_GETH_QOS_MODE_QUEUE_NUM_FROM_L2_CRITERIA = 0x1, /* queue
1093 determined 1093 determined
@@ -1097,11 +1097,11 @@ typedef enum ucc_geth_qos_mode {
1097 determined 1097 determined
1098 by L3 1098 by L3
1099 criteria */ 1099 criteria */
1100} ucc_geth_qos_mode_e; 1100};
1101 1101
1102/* UCC GETH Statistics Gathering Mode - These are bit flags, 'or' them together 1102/* UCC GETH Statistics Gathering Mode - These are bit flags, 'or' them together
1103 for combined functionality */ 1103 for combined functionality */
1104typedef enum ucc_geth_statistics_gathering_mode { 1104enum ucc_geth_statistics_gathering_mode {
1105 UCC_GETH_STATISTICS_GATHERING_MODE_NONE = 0x00000000, /* No 1105 UCC_GETH_STATISTICS_GATHERING_MODE_NONE = 0x00000000, /* No
1106 statistics 1106 statistics
1107 gathering */ 1107 gathering */
@@ -1122,10 +1122,10 @@ typedef enum ucc_geth_statistics_gathering_mode {
1122 statistics 1122 statistics
1123 gathering 1123 gathering
1124 */ 1124 */
1125} ucc_geth_statistics_gathering_mode_e; 1125};
1126 1126
1127/* UCC GETH Pad and CRC Mode - Note, Padding without CRC is not possible */ 1127/* UCC GETH Pad and CRC Mode - Note, Padding without CRC is not possible */
1128typedef enum ucc_geth_maccfg2_pad_and_crc_mode { 1128enum ucc_geth_maccfg2_pad_and_crc_mode {
1129 UCC_GETH_PAD_AND_CRC_MODE_NONE 1129 UCC_GETH_PAD_AND_CRC_MODE_NONE
1130 = MACCFG2_PAD_AND_CRC_MODE_NONE, /* Neither Padding 1130 = MACCFG2_PAD_AND_CRC_MODE_NONE, /* Neither Padding
1131 short frames 1131 short frames
@@ -1135,61 +1135,59 @@ typedef enum ucc_geth_maccfg2_pad_and_crc_mode {
1135 CRC only */ 1135 CRC only */
1136 UCC_GETH_PAD_AND_CRC_MODE_PAD_AND_CRC = 1136 UCC_GETH_PAD_AND_CRC_MODE_PAD_AND_CRC =
1137 MACCFG2_PAD_AND_CRC_MODE_PAD_AND_CRC 1137 MACCFG2_PAD_AND_CRC_MODE_PAD_AND_CRC
1138} ucc_geth_maccfg2_pad_and_crc_mode_e; 1138};
1139 1139
1140/* UCC GETH upsmr Flow Control Mode */ 1140/* UCC GETH upsmr Flow Control Mode */
1141typedef enum ucc_geth_flow_control_mode { 1141enum ucc_geth_flow_control_mode {
1142 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_NONE = 0x00000000, /* No automatic 1142 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_NONE = 0x00000000, /* No automatic
1143 flow control 1143 flow control
1144 */ 1144 */
1145 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_PAUSE_WHEN_EMERGENCY 1145 UPSMR_AUTOMATIC_FLOW_CONTROL_MODE_PAUSE_WHEN_EMERGENCY
1146 = 0x00004000 /* Send pause frame when RxFIFO reaches its 1146 = 0x00004000 /* Send pause frame when RxFIFO reaches its
1147 emergency threshold */ 1147 emergency threshold */
1148} ucc_geth_flow_control_mode_e; 1148};
1149 1149
1150/* UCC GETH number of threads */ 1150/* UCC GETH number of threads */
1151typedef enum ucc_geth_num_of_threads { 1151enum ucc_geth_num_of_threads {
1152 UCC_GETH_NUM_OF_THREADS_1 = 0x1, /* 1 */ 1152 UCC_GETH_NUM_OF_THREADS_1 = 0x1, /* 1 */
1153 UCC_GETH_NUM_OF_THREADS_2 = 0x2, /* 2 */ 1153 UCC_GETH_NUM_OF_THREADS_2 = 0x2, /* 2 */
1154 UCC_GETH_NUM_OF_THREADS_4 = 0x0, /* 4 */ 1154 UCC_GETH_NUM_OF_THREADS_4 = 0x0, /* 4 */
1155 UCC_GETH_NUM_OF_THREADS_6 = 0x3, /* 6 */ 1155 UCC_GETH_NUM_OF_THREADS_6 = 0x3, /* 6 */
1156 UCC_GETH_NUM_OF_THREADS_8 = 0x4 /* 8 */ 1156 UCC_GETH_NUM_OF_THREADS_8 = 0x4 /* 8 */
1157} ucc_geth_num_of_threads_e; 1157};
1158 1158
1159/* UCC GETH number of station addresses */ 1159/* UCC GETH number of station addresses */
1160typedef enum ucc_geth_num_of_station_addresses { 1160enum ucc_geth_num_of_station_addresses {
1161 UCC_GETH_NUM_OF_STATION_ADDRESSES_1, /* 1 */ 1161 UCC_GETH_NUM_OF_STATION_ADDRESSES_1, /* 1 */
1162 UCC_GETH_NUM_OF_STATION_ADDRESSES_5 /* 5 */ 1162 UCC_GETH_NUM_OF_STATION_ADDRESSES_5 /* 5 */
1163} ucc_geth_num_of_station_addresses_e; 1163};
1164
1165typedef u8 enet_addr_t[ENET_NUM_OCTETS_PER_ADDRESS];
1166 1164
1167/* UCC GETH 82xx Ethernet Address Container */ 1165/* UCC GETH 82xx Ethernet Address Container */
1168typedef struct enet_addr_container { 1166struct enet_addr_container {
1169 enet_addr_t address; /* ethernet address */ 1167 u8 address[ENET_NUM_OCTETS_PER_ADDRESS]; /* ethernet address */
1170 ucc_geth_enet_address_recognition_location_e location; /* location in 1168 enum ucc_geth_enet_address_recognition_location location; /* location in
1171 82xx address 1169 82xx address
1172 recognition 1170 recognition
1173 hardware */ 1171 hardware */
1174 struct list_head node; 1172 struct list_head node;
1175} enet_addr_container_t; 1173};
1176 1174
1177#define ENET_ADDR_CONT_ENTRY(ptr) list_entry(ptr, enet_addr_container_t, node) 1175#define ENET_ADDR_CONT_ENTRY(ptr) list_entry(ptr, struct enet_addr_container, node)
1178 1176
1179/* UCC GETH Termination Action Descriptor (TAD) structure. */ 1177/* UCC GETH Termination Action Descriptor (TAD) structure. */
1180typedef struct ucc_geth_tad_params { 1178struct ucc_geth_tad_params {
1181 int rx_non_dynamic_extended_features_mode; 1179 int rx_non_dynamic_extended_features_mode;
1182 int reject_frame; 1180 int reject_frame;
1183 ucc_geth_vlan_operation_tagged_e vtag_op; 1181 enum ucc_geth_vlan_operation_tagged vtag_op;
1184 ucc_geth_vlan_operation_non_tagged_e vnontag_op; 1182 enum ucc_geth_vlan_operation_non_tagged vnontag_op;
1185 ucc_geth_qos_mode_e rqos; 1183 enum ucc_geth_qos_mode rqos;
1186 u8 vpri; 1184 u8 vpri;
1187 u16 vid; 1185 u16 vid;
1188} ucc_geth_tad_params_t; 1186};
1189 1187
1190/* GETH protocol initialization structure */ 1188/* GETH protocol initialization structure */
1191typedef struct ucc_geth_info { 1189struct ucc_geth_info {
1192 ucc_fast_info_t uf_info; 1190 struct ucc_fast_info uf_info;
1193 u8 numQueuesTx; 1191 u8 numQueuesTx;
1194 u8 numQueuesRx; 1192 u8 numQueuesRx;
1195 int ipCheckSumCheck; 1193 int ipCheckSumCheck;
@@ -1251,51 +1249,51 @@ typedef struct ucc_geth_info {
1251 u8 iphoffset[TX_IP_OFFSET_ENTRY_MAX]; 1249 u8 iphoffset[TX_IP_OFFSET_ENTRY_MAX];
1252 u16 bdRingLenTx[NUM_TX_QUEUES]; 1250 u16 bdRingLenTx[NUM_TX_QUEUES];
1253 u16 bdRingLenRx[NUM_RX_QUEUES]; 1251 u16 bdRingLenRx[NUM_RX_QUEUES];
1254 enet_interface_e enet_interface; 1252 enum enet_interface enet_interface;
1255 ucc_geth_num_of_station_addresses_e numStationAddresses; 1253 enum ucc_geth_num_of_station_addresses numStationAddresses;
1256 qe_fltr_largest_external_tbl_lookup_key_size_e 1254 enum qe_fltr_largest_external_tbl_lookup_key_size
1257 largestexternallookupkeysize; 1255 largestexternallookupkeysize;
1258 ucc_geth_statistics_gathering_mode_e statisticsMode; 1256 enum ucc_geth_statistics_gathering_mode statisticsMode;
1259 ucc_geth_vlan_operation_tagged_e vlanOperationTagged; 1257 enum ucc_geth_vlan_operation_tagged vlanOperationTagged;
1260 ucc_geth_vlan_operation_non_tagged_e vlanOperationNonTagged; 1258 enum ucc_geth_vlan_operation_non_tagged vlanOperationNonTagged;
1261 ucc_geth_qos_mode_e rxQoSMode; 1259 enum ucc_geth_qos_mode rxQoSMode;
1262 ucc_geth_flow_control_mode_e aufc; 1260 enum ucc_geth_flow_control_mode aufc;
1263 ucc_geth_maccfg2_pad_and_crc_mode_e padAndCrc; 1261 enum ucc_geth_maccfg2_pad_and_crc_mode padAndCrc;
1264 ucc_geth_num_of_threads_e numThreadsTx; 1262 enum ucc_geth_num_of_threads numThreadsTx;
1265 ucc_geth_num_of_threads_e numThreadsRx; 1263 enum ucc_geth_num_of_threads numThreadsRx;
1266 qe_risc_allocation_e riscTx; 1264 enum qe_risc_allocation riscTx;
1267 qe_risc_allocation_e riscRx; 1265 enum qe_risc_allocation riscRx;
1268} ucc_geth_info_t; 1266};
1269 1267
1270/* structure representing UCC GETH */ 1268/* structure representing UCC GETH */
1271typedef struct ucc_geth_private { 1269struct ucc_geth_private {
1272 ucc_geth_info_t *ug_info; 1270 struct ucc_geth_info *ug_info;
1273 ucc_fast_private_t *uccf; 1271 struct ucc_fast_private *uccf;
1274 struct net_device *dev; 1272 struct net_device *dev;
1275 struct net_device_stats stats; /* linux network statistics */ 1273 struct net_device_stats stats; /* linux network statistics */
1276 ucc_geth_t *ug_regs; 1274 struct ucc_geth *ug_regs;
1277 ucc_geth_init_pram_t *p_init_enet_param_shadow; 1275 struct ucc_geth_init_pram *p_init_enet_param_shadow;
1278 ucc_geth_exf_global_pram_t *p_exf_glbl_param; 1276 struct ucc_geth_exf_global_pram *p_exf_glbl_param;
1279 u32 exf_glbl_param_offset; 1277 u32 exf_glbl_param_offset;
1280 ucc_geth_rx_global_pram_t *p_rx_glbl_pram; 1278 struct ucc_geth_rx_global_pram *p_rx_glbl_pram;
1281 u32 rx_glbl_pram_offset; 1279 u32 rx_glbl_pram_offset;
1282 ucc_geth_tx_global_pram_t *p_tx_glbl_pram; 1280 struct ucc_geth_tx_global_pram *p_tx_glbl_pram;
1283 u32 tx_glbl_pram_offset; 1281 u32 tx_glbl_pram_offset;
1284 ucc_geth_send_queue_mem_region_t *p_send_q_mem_reg; 1282 struct ucc_geth_send_queue_mem_region *p_send_q_mem_reg;
1285 u32 send_q_mem_reg_offset; 1283 u32 send_q_mem_reg_offset;
1286 ucc_geth_thread_data_tx_t *p_thread_data_tx; 1284 struct ucc_geth_thread_data_tx *p_thread_data_tx;
1287 u32 thread_dat_tx_offset; 1285 u32 thread_dat_tx_offset;
1288 ucc_geth_thread_data_rx_t *p_thread_data_rx; 1286 struct ucc_geth_thread_data_rx *p_thread_data_rx;
1289 u32 thread_dat_rx_offset; 1287 u32 thread_dat_rx_offset;
1290 ucc_geth_scheduler_t *p_scheduler; 1288 struct ucc_geth_scheduler *p_scheduler;
1291 u32 scheduler_offset; 1289 u32 scheduler_offset;
1292 ucc_geth_tx_firmware_statistics_pram_t *p_tx_fw_statistics_pram; 1290 struct ucc_geth_tx_firmware_statistics_pram *p_tx_fw_statistics_pram;
1293 u32 tx_fw_statistics_pram_offset; 1291 u32 tx_fw_statistics_pram_offset;
1294 ucc_geth_rx_firmware_statistics_pram_t *p_rx_fw_statistics_pram; 1292 struct ucc_geth_rx_firmware_statistics_pram *p_rx_fw_statistics_pram;
1295 u32 rx_fw_statistics_pram_offset; 1293 u32 rx_fw_statistics_pram_offset;
1296 ucc_geth_rx_interrupt_coalescing_table_t *p_rx_irq_coalescing_tbl; 1294 struct ucc_geth_rx_interrupt_coalescing_table *p_rx_irq_coalescing_tbl;
1297 u32 rx_irq_coalescing_tbl_offset; 1295 u32 rx_irq_coalescing_tbl_offset;
1298 ucc_geth_rx_bd_queues_entry_t *p_rx_bd_qs_tbl; 1296 struct ucc_geth_rx_bd_queues_entry *p_rx_bd_qs_tbl;
1299 u32 rx_bd_qs_tbl_offset; 1297 u32 rx_bd_qs_tbl_offset;
1300 u8 *p_tx_bd_ring[NUM_TX_QUEUES]; 1298 u8 *p_tx_bd_ring[NUM_TX_QUEUES];
1301 u32 tx_bd_ring_offset[NUM_TX_QUEUES]; 1299 u32 tx_bd_ring_offset[NUM_TX_QUEUES];
@@ -1308,7 +1306,7 @@ typedef struct ucc_geth_private {
1308 u16 cpucount[NUM_TX_QUEUES]; 1306 u16 cpucount[NUM_TX_QUEUES];
1309 volatile u16 *p_cpucount[NUM_TX_QUEUES]; 1307 volatile u16 *p_cpucount[NUM_TX_QUEUES];
1310 int indAddrRegUsed[NUM_OF_PADDRS]; 1308 int indAddrRegUsed[NUM_OF_PADDRS];
1311 enet_addr_t paddr[NUM_OF_PADDRS]; 1309 u8 paddr[NUM_OF_PADDRS][ENET_NUM_OCTETS_PER_ADDRESS]; /* ethernet address */
1312 u8 numGroupAddrInHash; 1310 u8 numGroupAddrInHash;
1313 u8 numIndAddrInHash; 1311 u8 numIndAddrInHash;
1314 u8 numIndAddrInReg; 1312 u8 numIndAddrInReg;
@@ -1334,6 +1332,6 @@ typedef struct ucc_geth_private {
1334 int oldspeed; 1332 int oldspeed;
1335 int oldduplex; 1333 int oldduplex;
1336 int oldlink; 1334 int oldlink;
1337} ucc_geth_private_t; 1335};
1338 1336
1339#endif /* __UCC_GETH_H__ */ 1337#endif /* __UCC_GETH_H__ */
diff --git a/drivers/net/ucc_geth_phy.c b/drivers/net/ucc_geth_phy.c
index 67260eb3188a..5360ec05eaa3 100644
--- a/drivers/net/ucc_geth_phy.c
+++ b/drivers/net/ucc_geth_phy.c
@@ -42,7 +42,6 @@
42 42
43#include "ucc_geth.h" 43#include "ucc_geth.h"
44#include "ucc_geth_phy.h" 44#include "ucc_geth_phy.h"
45#include <platforms/83xx/mpc8360e_pb.h>
46 45
47#define ugphy_printk(level, format, arg...) \ 46#define ugphy_printk(level, format, arg...) \
48 printk(level format "\n", ## arg) 47 printk(level format "\n", ## arg)
@@ -72,16 +71,14 @@ static int genmii_read_status(struct ugeth_mii_info *mii_info);
72u16 phy_read(struct ugeth_mii_info *mii_info, u16 regnum); 71u16 phy_read(struct ugeth_mii_info *mii_info, u16 regnum);
73void phy_write(struct ugeth_mii_info *mii_info, u16 regnum, u16 val); 72void phy_write(struct ugeth_mii_info *mii_info, u16 regnum, u16 val);
74 73
75static u8 *bcsr_regs = NULL;
76
77/* Write value to the PHY for this device to the register at regnum, */ 74/* Write value to the PHY for this device to the register at regnum, */
78/* waiting until the write is done before it returns. All PHY */ 75/* waiting until the write is done before it returns. All PHY */
79/* configuration has to be done through the TSEC1 MIIM regs */ 76/* configuration has to be done through the TSEC1 MIIM regs */
80void write_phy_reg(struct net_device *dev, int mii_id, int regnum, int value) 77void write_phy_reg(struct net_device *dev, int mii_id, int regnum, int value)
81{ 78{
82 ucc_geth_private_t *ugeth = netdev_priv(dev); 79 struct ucc_geth_private *ugeth = netdev_priv(dev);
83 ucc_mii_mng_t *mii_regs; 80 struct ucc_mii_mng *mii_regs;
84 enet_tbi_mii_reg_e mii_reg = (enet_tbi_mii_reg_e) regnum; 81 enum enet_tbi_mii_reg mii_reg = (enum enet_tbi_mii_reg) regnum;
85 u32 tmp_reg; 82 u32 tmp_reg;
86 83
87 ugphy_vdbg("%s: IN", __FUNCTION__); 84 ugphy_vdbg("%s: IN", __FUNCTION__);
@@ -116,9 +113,9 @@ void write_phy_reg(struct net_device *dev, int mii_id, int regnum, int value)
116/* configuration has to be done through the TSEC1 MIIM regs */ 113/* configuration has to be done through the TSEC1 MIIM regs */
117int read_phy_reg(struct net_device *dev, int mii_id, int regnum) 114int read_phy_reg(struct net_device *dev, int mii_id, int regnum)
118{ 115{
119 ucc_geth_private_t *ugeth = netdev_priv(dev); 116 struct ucc_geth_private *ugeth = netdev_priv(dev);
120 ucc_mii_mng_t *mii_regs; 117 struct ucc_mii_mng *mii_regs;
121 enet_tbi_mii_reg_e mii_reg = (enet_tbi_mii_reg_e) regnum; 118 enum enet_tbi_mii_reg mii_reg = (enum enet_tbi_mii_reg) regnum;
122 u32 tmp_reg; 119 u32 tmp_reg;
123 u16 value; 120 u16 value;
124 121
@@ -634,11 +631,6 @@ static void dm9161_close(struct ugeth_mii_info *mii_info)
634 631
635static int dm9161_ack_interrupt(struct ugeth_mii_info *mii_info) 632static int dm9161_ack_interrupt(struct ugeth_mii_info *mii_info)
636{ 633{
637/* FIXME: This lines are for BUG fixing in the mpc8325.
638Remove this from here when it's fixed */
639 if (bcsr_regs == NULL)
640 bcsr_regs = (u8 *) ioremap(BCSR_PHYS_ADDR, BCSR_SIZE);
641 bcsr_regs[14] |= 0x40;
642 ugphy_vdbg("%s: IN", __FUNCTION__); 634 ugphy_vdbg("%s: IN", __FUNCTION__);
643 635
644 /* Clear the interrupts by reading the reg */ 636 /* Clear the interrupts by reading the reg */
@@ -650,12 +642,6 @@ Remove this from here when it's fixed */
650 642
651static int dm9161_config_intr(struct ugeth_mii_info *mii_info) 643static int dm9161_config_intr(struct ugeth_mii_info *mii_info)
652{ 644{
653/* FIXME: This lines are for BUG fixing in the mpc8325.
654Remove this from here when it's fixed */
655 if (bcsr_regs == NULL) {
656 bcsr_regs = (u8 *) ioremap(BCSR_PHYS_ADDR, BCSR_SIZE);
657 bcsr_regs[14] &= ~0x40;
658 }
659 ugphy_vdbg("%s: IN", __FUNCTION__); 645 ugphy_vdbg("%s: IN", __FUNCTION__);
660 646
661 if (mii_info->interrupts == MII_INTERRUPT_ENABLED) 647 if (mii_info->interrupts == MII_INTERRUPT_ENABLED)
diff --git a/drivers/net/ucc_geth_phy.h b/drivers/net/ucc_geth_phy.h
index 2f98b8f1bb0a..f5740783670f 100644
--- a/drivers/net/ucc_geth_phy.h
+++ b/drivers/net/ucc_geth_phy.h
@@ -126,7 +126,7 @@ struct ugeth_mii_info {
126 /* And management functions */ 126 /* And management functions */
127 struct phy_info *phyinfo; 127 struct phy_info *phyinfo;
128 128
129 ucc_mii_mng_t *mii_regs; 129 struct ucc_mii_mng *mii_regs;
130 130
131 /* forced speed & duplex (no autoneg) 131 /* forced speed & duplex (no autoneg)
132 * partner speed & duplex & pause (autoneg) 132 * partner speed & duplex & pause (autoneg)
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index 5823e3bca178..36d1c3ff7078 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -2867,7 +2867,6 @@ static int ch_config(pc300dev_t * d)
2867 uclong clktype = chan->conf.phys_settings.clock_type; 2867 uclong clktype = chan->conf.phys_settings.clock_type;
2868 ucshort encoding = chan->conf.proto_settings.encoding; 2868 ucshort encoding = chan->conf.proto_settings.encoding;
2869 ucshort parity = chan->conf.proto_settings.parity; 2869 ucshort parity = chan->conf.proto_settings.parity;
2870 int tmc, br;
2871 ucchar md0, md2; 2870 ucchar md0, md2;
2872 2871
2873 /* Reset the channel */ 2872 /* Reset the channel */
@@ -2940,8 +2939,12 @@ static int ch_config(pc300dev_t * d)
2940 case PC300_RSV: 2939 case PC300_RSV:
2941 case PC300_X21: 2940 case PC300_X21:
2942 if (clktype == CLOCK_INT || clktype == CLOCK_TXINT) { 2941 if (clktype == CLOCK_INT || clktype == CLOCK_TXINT) {
2942 int tmc, br;
2943
2943 /* Calculate the clkrate parameters */ 2944 /* Calculate the clkrate parameters */
2944 tmc = clock_rate_calc(clkrate, card->hw.clock, &br); 2945 tmc = clock_rate_calc(clkrate, card->hw.clock, &br);
2946 if (tmc < 0)
2947 return -EIO;
2945 cpc_writeb(scabase + M_REG(TMCT, ch), tmc); 2948 cpc_writeb(scabase + M_REG(TMCT, ch), tmc);
2946 cpc_writeb(scabase + M_REG(TXS, ch), 2949 cpc_writeb(scabase + M_REG(TXS, ch),
2947 (TXS_DTRXC | TXS_IBRG | br)); 2950 (TXS_DTRXC | TXS_IBRG | br));
@@ -3097,14 +3100,16 @@ static int cpc_attach(struct net_device *dev, unsigned short encoding,
3097 return 0; 3100 return 0;
3098} 3101}
3099 3102
3100static void cpc_opench(pc300dev_t * d) 3103static int cpc_opench(pc300dev_t * d)
3101{ 3104{
3102 pc300ch_t *chan = (pc300ch_t *) d->chan; 3105 pc300ch_t *chan = (pc300ch_t *) d->chan;
3103 pc300_t *card = (pc300_t *) chan->card; 3106 pc300_t *card = (pc300_t *) chan->card;
3104 int ch = chan->channel; 3107 int ch = chan->channel, rc;
3105 void __iomem *scabase = card->hw.scabase; 3108 void __iomem *scabase = card->hw.scabase;
3106 3109
3107 ch_config(d); 3110 rc = ch_config(d);
3111 if (rc)
3112 return rc;
3108 3113
3109 rx_config(d); 3114 rx_config(d);
3110 3115
@@ -3113,6 +3118,8 @@ static void cpc_opench(pc300dev_t * d)
3113 /* Assert RTS and DTR */ 3118 /* Assert RTS and DTR */
3114 cpc_writeb(scabase + M_REG(CTL, ch), 3119 cpc_writeb(scabase + M_REG(CTL, ch),
3115 cpc_readb(scabase + M_REG(CTL, ch)) & ~(CTL_RTS | CTL_DTR)); 3120 cpc_readb(scabase + M_REG(CTL, ch)) & ~(CTL_RTS | CTL_DTR));
3121
3122 return 0;
3116} 3123}
3117 3124
3118static void cpc_closech(pc300dev_t * d) 3125static void cpc_closech(pc300dev_t * d)
@@ -3168,9 +3175,16 @@ int cpc_open(struct net_device *dev)
3168 } 3175 }
3169 3176
3170 sprintf(ifr.ifr_name, "%s", dev->name); 3177 sprintf(ifr.ifr_name, "%s", dev->name);
3171 cpc_opench(d); 3178 result = cpc_opench(d);
3179 if (result)
3180 goto err_out;
3181
3172 netif_start_queue(dev); 3182 netif_start_queue(dev);
3173 return 0; 3183 return 0;
3184
3185err_out:
3186 hdlc_close(dev);
3187 return result;
3174} 3188}
3175 3189
3176static int cpc_close(struct net_device *dev) 3190static int cpc_close(struct net_device *dev)
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index 51cb9f817c22..270a33cc08f6 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -29,10 +29,10 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/pci_hotplug.h>
32#include <acpi/acpi.h> 33#include <acpi/acpi.h>
33#include <acpi/acpi_bus.h> 34#include <acpi/acpi_bus.h>
34#include <acpi/actypes.h> 35#include <acpi/actypes.h>
35#include "pci_hotplug.h"
36 36
37#define MY_NAME "acpi_pcihp" 37#define MY_NAME "acpi_pcihp"
38 38
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 7fff07e877c7..59c5b242d86d 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -38,7 +38,7 @@
38#include <linux/acpi.h> 38#include <linux/acpi.h>
39#include <linux/kobject.h> /* for KOBJ_NAME_LEN */ 39#include <linux/kobject.h> /* for KOBJ_NAME_LEN */
40#include <linux/mutex.h> 40#include <linux/mutex.h>
41#include "pci_hotplug.h" 41#include <linux/pci_hotplug.h>
42 42
43#define dbg(format, arg...) \ 43#define dbg(format, arg...) \
44 do { \ 44 do { \
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index e2fef60c2d06..c57d9d5ce84e 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -37,10 +37,10 @@
37 37
38#include <linux/kernel.h> 38#include <linux/kernel.h>
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/pci_hotplug.h>
40#include <linux/slab.h> 41#include <linux/slab.h>
41#include <linux/smp.h> 42#include <linux/smp.h>
42#include <linux/smp_lock.h> 43#include <linux/smp_lock.h>
43#include "pci_hotplug.h"
44#include "acpiphp.h" 44#include "acpiphp.h"
45 45
46#define MY_NAME "acpiphp" 46#define MY_NAME "acpiphp"
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 83e8e4412de5..c44311ac2fd3 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -45,11 +45,11 @@
45 45
46#include <linux/kernel.h> 46#include <linux/kernel.h>
47#include <linux/pci.h> 47#include <linux/pci.h>
48#include <linux/pci_hotplug.h>
48#include <linux/smp_lock.h> 49#include <linux/smp_lock.h>
49#include <linux/mutex.h> 50#include <linux/mutex.h>
50 51
51#include "../pci.h" 52#include "../pci.h"
52#include "pci_hotplug.h"
53#include "acpiphp.h" 53#include "acpiphp.h"
54 54
55static LIST_HEAD(bridge_list); 55static LIST_HEAD(bridge_list);
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index d0a07d9ab30c..bd40aee10e16 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -35,7 +35,6 @@
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36 36
37#include "acpiphp.h" 37#include "acpiphp.h"
38#include "pci_hotplug.h"
39 38
40#define DRIVER_VERSION "1.0.1" 39#define DRIVER_VERSION "1.0.1"
41#define DRIVER_AUTHOR "Irene Zubarev <zubarev@us.ibm.com>, Vernon Mauery <vernux@us.ibm.com>" 40#define DRIVER_AUTHOR "Irene Zubarev <zubarev@us.ibm.com>, Vernon Mauery <vernux@us.ibm.com>"
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index d06ab4045134..684551559d44 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -29,12 +29,12 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <linux/pci_hotplug.h>
32#include <linux/init.h> 33#include <linux/init.h>
33#include <linux/interrupt.h> 34#include <linux/interrupt.h>
34#include <linux/smp_lock.h> 35#include <linux/smp_lock.h>
35#include <asm/atomic.h> 36#include <asm/atomic.h>
36#include <linux/delay.h> 37#include <linux/delay.h>
37#include "pci_hotplug.h"
38#include "cpci_hotplug.h" 38#include "cpci_hotplug.h"
39 39
40#define DRIVER_AUTHOR "Scott Murray <scottm@somanetworks.com>" 40#define DRIVER_AUTHOR "Scott Murray <scottm@somanetworks.com>"
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index 4afcaffd031c..7b1beaad2752 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -26,9 +26,9 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/pci_hotplug.h>
29#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
30#include "../pci.h" 31#include "../pci.h"
31#include "pci_hotplug.h"
32#include "cpci_hotplug.h" 32#include "cpci_hotplug.h"
33 33
34#define MY_NAME "cpci_hotplug" 34#define MY_NAME "cpci_hotplug"
diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
index e847f0d6c7fe..f3852a6b74ea 100644
--- a/drivers/pci/hotplug/cpcihp_generic.c
+++ b/drivers/pci/hotplug/cpcihp_generic.c
@@ -84,7 +84,7 @@ static int __init validate_parameters(void)
84 84
85 if(!bridge) { 85 if(!bridge) {
86 info("not configured, disabling."); 86 info("not configured, disabling.");
87 return 1; 87 return -EINVAL;
88 } 88 }
89 str = bridge; 89 str = bridge;
90 if(!*str) 90 if(!*str)
@@ -147,7 +147,7 @@ static int __init cpcihp_generic_init(void)
147 147
148 info(DRIVER_DESC " version: " DRIVER_VERSION); 148 info(DRIVER_DESC " version: " DRIVER_VERSION);
149 status = validate_parameters(); 149 status = validate_parameters();
150 if(status != 0) 150 if (status)
151 return status; 151 return status;
152 152
153 r = request_region(port, 1, "#ENUM hotswap signal register"); 153 r = request_region(port, 1, "#ENUM hotswap signal register");
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h
index ea040c32f47d..298ad7f3f4f4 100644
--- a/drivers/pci/hotplug/cpqphp.h
+++ b/drivers/pci/hotplug/cpqphp.h
@@ -28,7 +28,6 @@
28#ifndef _CPQPHP_H 28#ifndef _CPQPHP_H
29#define _CPQPHP_H 29#define _CPQPHP_H
30 30
31#include "pci_hotplug.h"
32#include <linux/interrupt.h> 31#include <linux/interrupt.h>
33#include <asm/io.h> /* for read? and write? functions */ 32#include <asm/io.h> /* for read? and write? functions */
34#include <linux/delay.h> /* for delays */ 33#include <linux/delay.h> /* for delays */
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index 1fc259913b68..5617cfdadc5c 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -37,6 +37,7 @@
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/workqueue.h> 38#include <linux/workqueue.h>
39#include <linux/pci.h> 39#include <linux/pci.h>
40#include <linux/pci_hotplug.h>
40#include <linux/init.h> 41#include <linux/init.h>
41#include <linux/interrupt.h> 42#include <linux/interrupt.h>
42 43
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index 3ec2ad7db49a..79ff6b4de3a6 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -36,6 +36,7 @@
36#include <linux/wait.h> 36#include <linux/wait.h>
37#include <linux/smp_lock.h> 37#include <linux/smp_lock.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/pci_hotplug.h>
39#include "cpqphp.h" 40#include "cpqphp.h"
40 41
41static u32 configure_new_device(struct controller* ctrl, struct pci_func *func, 42static u32 configure_new_device(struct controller* ctrl, struct pci_func *func,
diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
index cf0878917537..298a6cfd8406 100644
--- a/drivers/pci/hotplug/cpqphp_nvram.c
+++ b/drivers/pci/hotplug/cpqphp_nvram.c
@@ -33,6 +33,7 @@
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/workqueue.h> 34#include <linux/workqueue.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/pci_hotplug.h>
36#include <linux/init.h> 37#include <linux/init.h>
37#include <asm/uaccess.h> 38#include <asm/uaccess.h>
38#include "cpqphp.h" 39#include "cpqphp.h"
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index 0d9688952f4a..fc7c74d72595 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -33,6 +33,7 @@
33#include <linux/workqueue.h> 33#include <linux/workqueue.h>
34#include <linux/proc_fs.h> 34#include <linux/proc_fs.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/pci_hotplug.h>
36#include "../pci.h" 37#include "../pci.h"
37#include "cpqphp.h" 38#include "cpqphp.h"
38#include "cpqphp_nvram.h" 39#include "cpqphp_nvram.h"
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c
index 5bab666cd67e..634f74d919d3 100644
--- a/drivers/pci/hotplug/cpqphp_sysfs.c
+++ b/drivers/pci/hotplug/cpqphp_sysfs.c
@@ -32,6 +32,7 @@
32#include <linux/proc_fs.h> 32#include <linux/proc_fs.h>
33#include <linux/workqueue.h> 33#include <linux/workqueue.h>
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/pci_hotplug.h>
35#include <linux/debugfs.h> 36#include <linux/debugfs.h>
36#include "cpqphp.h" 37#include "cpqphp.h"
37 38
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 05a4f0f90186..e27907c91d92 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -35,10 +35,10 @@
35#include <linux/kernel.h> 35#include <linux/kernel.h>
36#include <linux/module.h> 36#include <linux/module.h>
37#include <linux/pci.h> 37#include <linux/pci.h>
38#include <linux/pci_hotplug.h>
38#include <linux/init.h> 39#include <linux/init.h>
39#include <linux/string.h> 40#include <linux/string.h>
40#include <linux/slab.h> 41#include <linux/slab.h>
41#include "pci_hotplug.h"
42#include "../pci.h" 42#include "../pci.h"
43 43
44#if !defined(MODULE) 44#if !defined(MODULE)
@@ -181,7 +181,9 @@ static void pci_rescan_slot(struct pci_dev *temp)
181 181
182 if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) { 182 if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) {
183 temp->hdr_type = hdr_type & 0x7f; 183 temp->hdr_type = hdr_type & 0x7f;
184 if (!pci_find_slot(bus->number, temp->devfn)) { 184 if ((dev = pci_get_slot(bus, temp->devfn)) != NULL)
185 pci_dev_put(dev);
186 else {
185 dev = pci_scan_single_device(bus, temp->devfn); 187 dev = pci_scan_single_device(bus, temp->devfn);
186 if (dev) { 188 if (dev) {
187 dbg("New device on %s function %x:%x\n", 189 dbg("New device on %s function %x:%x\n",
@@ -205,7 +207,9 @@ static void pci_rescan_slot(struct pci_dev *temp)
205 continue; 207 continue;
206 temp->hdr_type = hdr_type & 0x7f; 208 temp->hdr_type = hdr_type & 0x7f;
207 209
208 if (!pci_find_slot(bus->number, temp->devfn)) { 210 if ((dev = pci_get_slot(bus, temp->devfn)) != NULL)
211 pci_dev_put(dev);
212 else {
209 dev = pci_scan_single_device(bus, temp->devfn); 213 dev = pci_scan_single_device(bus, temp->devfn);
210 if (dev) { 214 if (dev) {
211 dbg("New device on %s function %x:%x\n", 215 dbg("New device on %s function %x:%x\n",
@@ -305,7 +309,7 @@ static int disable_slot(struct hotplug_slot *slot)
305 /* search for subfunctions and disable them first */ 309 /* search for subfunctions and disable them first */
306 if (!(dslot->dev->devfn & 7)) { 310 if (!(dslot->dev->devfn & 7)) {
307 for (func = 1; func < 8; func++) { 311 for (func = 1; func < 8; func++) {
308 dev = pci_find_slot(dslot->dev->bus->number, 312 dev = pci_get_slot(dslot->dev->bus,
309 dslot->dev->devfn + func); 313 dslot->dev->devfn + func);
310 if (dev) { 314 if (dev) {
311 hslot = get_slot_from_dev(dev); 315 hslot = get_slot_from_dev(dev);
@@ -315,6 +319,7 @@ static int disable_slot(struct hotplug_slot *slot)
315 err("Hotplug slot not found for subfunction of PCI device\n"); 319 err("Hotplug slot not found for subfunction of PCI device\n");
316 return -ENODEV; 320 return -ENODEV;
317 } 321 }
322 pci_dev_put(dev);
318 } else 323 } else
319 dbg("No device in slot found\n"); 324 dbg("No device in slot found\n");
320 } 325 }
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h
index dba6d8ca9bda..612d96301509 100644
--- a/drivers/pci/hotplug/ibmphp.h
+++ b/drivers/pci/hotplug/ibmphp.h
@@ -30,7 +30,7 @@
30 * 30 *
31 */ 31 */
32 32
33#include "pci_hotplug.h" 33#include <linux/pci_hotplug.h>
34 34
35extern int ibmphp_debug; 35extern int ibmphp_debug;
36 36
diff --git a/drivers/pci/hotplug/pci_hotplug.h b/drivers/pci/hotplug/pci_hotplug.h
deleted file mode 100644
index 772523dc3860..000000000000
--- a/drivers/pci/hotplug/pci_hotplug.h
+++ /dev/null
@@ -1,236 +0,0 @@
1/*
2 * PCI HotPlug Core Functions
3 *
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 *
8 * All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or (at
13 * your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * Send feedback to <greg@kroah.com>
26 *
27 */
28#ifndef _PCI_HOTPLUG_H
29#define _PCI_HOTPLUG_H
30
31
32/* These values come from the PCI Hotplug Spec */
33enum pci_bus_speed {
34 PCI_SPEED_33MHz = 0x00,
35 PCI_SPEED_66MHz = 0x01,
36 PCI_SPEED_66MHz_PCIX = 0x02,
37 PCI_SPEED_100MHz_PCIX = 0x03,
38 PCI_SPEED_133MHz_PCIX = 0x04,
39 PCI_SPEED_66MHz_PCIX_ECC = 0x05,
40 PCI_SPEED_100MHz_PCIX_ECC = 0x06,
41 PCI_SPEED_133MHz_PCIX_ECC = 0x07,
42 PCI_SPEED_66MHz_PCIX_266 = 0x09,
43 PCI_SPEED_100MHz_PCIX_266 = 0x0a,
44 PCI_SPEED_133MHz_PCIX_266 = 0x0b,
45 PCI_SPEED_66MHz_PCIX_533 = 0x11,
46 PCI_SPEED_100MHz_PCIX_533 = 0x12,
47 PCI_SPEED_133MHz_PCIX_533 = 0x13,
48 PCI_SPEED_UNKNOWN = 0xff,
49};
50
51/* These values come from the PCI Express Spec */
52enum pcie_link_width {
53 PCIE_LNK_WIDTH_RESRV = 0x00,
54 PCIE_LNK_X1 = 0x01,
55 PCIE_LNK_X2 = 0x02,
56 PCIE_LNK_X4 = 0x04,
57 PCIE_LNK_X8 = 0x08,
58 PCIE_LNK_X12 = 0x0C,
59 PCIE_LNK_X16 = 0x10,
60 PCIE_LNK_X32 = 0x20,
61 PCIE_LNK_WIDTH_UNKNOWN = 0xFF,
62};
63
64enum pcie_link_speed {
65 PCIE_2PT5GB = 0x14,
66 PCIE_LNK_SPEED_UNKNOWN = 0xFF,
67};
68
69struct hotplug_slot;
70struct hotplug_slot_attribute {
71 struct attribute attr;
72 ssize_t (*show)(struct hotplug_slot *, char *);
73 ssize_t (*store)(struct hotplug_slot *, const char *, size_t);
74};
75#define to_hotplug_attr(n) container_of(n, struct hotplug_slot_attribute, attr);
76
77/**
78 * struct hotplug_slot_ops -the callbacks that the hotplug pci core can use
79 * @owner: The module owner of this structure
80 * @enable_slot: Called when the user wants to enable a specific pci slot
81 * @disable_slot: Called when the user wants to disable a specific pci slot
82 * @set_attention_status: Called to set the specific slot's attention LED to
83 * the specified value
84 * @hardware_test: Called to run a specified hardware test on the specified
85 * slot.
86 * @get_power_status: Called to get the current power status of a slot.
87 * If this field is NULL, the value passed in the struct hotplug_slot_info
88 * will be used when this value is requested by a user.
89 * @get_attention_status: Called to get the current attention status of a slot.
90 * If this field is NULL, the value passed in the struct hotplug_slot_info
91 * will be used when this value is requested by a user.
92 * @get_latch_status: Called to get the current latch status of a slot.
93 * If this field is NULL, the value passed in the struct hotplug_slot_info
94 * will be used when this value is requested by a user.
95 * @get_adapter_status: Called to get see if an adapter is present in the slot or not.
96 * If this field is NULL, the value passed in the struct hotplug_slot_info
97 * will be used when this value is requested by a user.
98 * @get_address: Called to get pci address of a slot.
99 * If this field is NULL, the value passed in the struct hotplug_slot_info
100 * will be used when this value is requested by a user.
101 * @get_max_bus_speed: Called to get the max bus speed for a slot.
102 * If this field is NULL, the value passed in the struct hotplug_slot_info
103 * will be used when this value is requested by a user.
104 * @get_cur_bus_speed: Called to get the current bus speed for a slot.
105 * If this field is NULL, the value passed in the struct hotplug_slot_info
106 * will be used when this value is requested by a user.
107 *
108 * The table of function pointers that is passed to the hotplug pci core by a
109 * hotplug pci driver. These functions are called by the hotplug pci core when
110 * the user wants to do something to a specific slot (query it for information,
111 * set an LED, enable / disable power, etc.)
112 */
113struct hotplug_slot_ops {
114 struct module *owner;
115 int (*enable_slot) (struct hotplug_slot *slot);
116 int (*disable_slot) (struct hotplug_slot *slot);
117 int (*set_attention_status) (struct hotplug_slot *slot, u8 value);
118 int (*hardware_test) (struct hotplug_slot *slot, u32 value);
119 int (*get_power_status) (struct hotplug_slot *slot, u8 *value);
120 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
121 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
122 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
123 int (*get_address) (struct hotplug_slot *slot, u32 *value);
124 int (*get_max_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value);
125 int (*get_cur_bus_speed) (struct hotplug_slot *slot, enum pci_bus_speed *value);
126};
127
128/**
129 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
130 * @power: if power is enabled or not (1/0)
131 * @attention_status: if the attention light is enabled or not (1/0)
132 * @latch_status: if the latch (if any) is open or closed (1/0)
133 * @adapter_present: if there is a pci board present in the slot or not (1/0)
134 * @address: (domain << 16 | bus << 8 | dev)
135 *
136 * Used to notify the hotplug pci core of the status of a specific slot.
137 */
138struct hotplug_slot_info {
139 u8 power_status;
140 u8 attention_status;
141 u8 latch_status;
142 u8 adapter_status;
143 u32 address;
144 enum pci_bus_speed max_bus_speed;
145 enum pci_bus_speed cur_bus_speed;
146};
147
148/**
149 * struct hotplug_slot - used to register a physical slot with the hotplug pci core
150 * @name: the name of the slot being registered. This string must
151 * be unique amoung slots registered on this system.
152 * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot
153 * @info: pointer to the &struct hotplug_slot_info for the initial values for
154 * this slot.
155 * @release: called during pci_hp_deregister to free memory allocated in a
156 * hotplug_slot structure.
157 * @private: used by the hotplug pci controller driver to store whatever it
158 * needs.
159 */
160struct hotplug_slot {
161 char *name;
162 struct hotplug_slot_ops *ops;
163 struct hotplug_slot_info *info;
164 void (*release) (struct hotplug_slot *slot);
165 void *private;
166
167 /* Variables below this are for use only by the hotplug pci core. */
168 struct list_head slot_list;
169 struct kobject kobj;
170};
171#define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj)
172
173extern int pci_hp_register (struct hotplug_slot *slot);
174extern int pci_hp_deregister (struct hotplug_slot *slot);
175extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot,
176 struct hotplug_slot_info *info);
177extern struct subsystem pci_hotplug_slots_subsys;
178
179/* PCI Setting Record (Type 0) */
180struct hpp_type0 {
181 u32 revision;
182 u8 cache_line_size;
183 u8 latency_timer;
184 u8 enable_serr;
185 u8 enable_perr;
186};
187
188/* PCI-X Setting Record (Type 1) */
189struct hpp_type1 {
190 u32 revision;
191 u8 max_mem_read;
192 u8 avg_max_split;
193 u16 tot_max_split;
194};
195
196/* PCI Express Setting Record (Type 2) */
197struct hpp_type2 {
198 u32 revision;
199 u32 unc_err_mask_and;
200 u32 unc_err_mask_or;
201 u32 unc_err_sever_and;
202 u32 unc_err_sever_or;
203 u32 cor_err_mask_and;
204 u32 cor_err_mask_or;
205 u32 adv_err_cap_and;
206 u32 adv_err_cap_or;
207 u16 pci_exp_devctl_and;
208 u16 pci_exp_devctl_or;
209 u16 pci_exp_lnkctl_and;
210 u16 pci_exp_lnkctl_or;
211 u32 sec_unc_err_sever_and;
212 u32 sec_unc_err_sever_or;
213 u32 sec_unc_err_mask_and;
214 u32 sec_unc_err_mask_or;
215};
216
217struct hotplug_params {
218 struct hpp_type0 *t0; /* Type0: NULL if not available */
219 struct hpp_type1 *t1; /* Type1: NULL if not available */
220 struct hpp_type2 *t2; /* Type2: NULL if not available */
221 struct hpp_type0 type0_data;
222 struct hpp_type1 type1_data;
223 struct hpp_type2 type2_data;
224};
225
226#ifdef CONFIG_ACPI
227#include <acpi/acpi.h>
228#include <acpi/acpi_bus.h>
229#include <acpi/actypes.h>
230extern acpi_status acpi_run_oshp(acpi_handle handle);
231extern acpi_status acpi_get_hp_params_from_firmware(struct pci_bus *bus,
232 struct hotplug_params *hpp);
233int acpi_root_bridge(acpi_handle handle);
234#endif
235#endif
236
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index e2823ea9c4ed..f5d632e72323 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -21,9 +21,7 @@
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * 23 *
24 * Send feedback to <greg@kroah.com> 24 * Send feedback to <kristen.c.accardi@intel.com>
25 *
26 * Filesystem portion based on work done by Pat Mochel on ddfs/driverfs
27 * 25 *
28 */ 26 */
29 27
@@ -32,6 +30,8 @@
32#include <linux/kernel.h> 30#include <linux/kernel.h>
33#include <linux/types.h> 31#include <linux/types.h>
34#include <linux/list.h> 32#include <linux/list.h>
33#include <linux/kobject.h>
34#include <linux/sysfs.h>
35#include <linux/pagemap.h> 35#include <linux/pagemap.h>
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/smp_lock.h> 37#include <linux/smp_lock.h>
@@ -39,11 +39,8 @@
39#include <linux/mount.h> 39#include <linux/mount.h>
40#include <linux/namei.h> 40#include <linux/namei.h>
41#include <linux/pci.h> 41#include <linux/pci.h>
42#include <linux/pci_hotplug.h>
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43#include <linux/kobject.h>
44#include <linux/sysfs.h>
45#include "pci_hotplug.h"
46
47 44
48#define MY_NAME "pci_hotplug" 45#define MY_NAME "pci_hotplug"
49 46
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index eaea9d36a1bb..4fb12fcda563 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -31,11 +31,11 @@
31 31
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/pci_hotplug.h>
34#include <linux/delay.h> 35#include <linux/delay.h>
35#include <linux/sched.h> /* signal_pending() */ 36#include <linux/sched.h> /* signal_pending() */
36#include <linux/pcieport_if.h> 37#include <linux/pcieport_if.h>
37#include <linux/mutex.h> 38#include <linux/mutex.h>
38#include "pci_hotplug.h"
39 39
40#define MY_NAME "pciehp" 40#define MY_NAME "pciehp"
41 41
@@ -92,6 +92,7 @@ struct php_ctlr_state_s {
92struct controller { 92struct controller {
93 struct controller *next; 93 struct controller *next;
94 struct mutex crit_sect; /* critical section mutex */ 94 struct mutex crit_sect; /* critical section mutex */
95 struct mutex ctrl_lock; /* controller lock */
95 struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ 96 struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
96 int num_slots; /* Number of slots on ctlr */ 97 int num_slots; /* Number of slots on ctlr */
97 int slot_num_inc; /* 1 or -1 */ 98 int slot_num_inc; /* 1 or -1 */
@@ -166,10 +167,10 @@ struct controller {
166 * error Messages 167 * error Messages
167 */ 168 */
168#define msg_initialization_err "Initialization failure, error=%d\n" 169#define msg_initialization_err "Initialization failure, error=%d\n"
169#define msg_button_on "PCI slot #%d - powering on due to button press.\n" 170#define msg_button_on "PCI slot #%s - powering on due to button press.\n"
170#define msg_button_off "PCI slot #%d - powering off due to button press.\n" 171#define msg_button_off "PCI slot #%s - powering off due to button press.\n"
171#define msg_button_cancel "PCI slot #%d - action canceled due to button press.\n" 172#define msg_button_cancel "PCI slot #%s - action canceled due to button press.\n"
172#define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n" 173#define msg_button_ignore "PCI slot #%s - button press ignored. (action in progress...)\n"
173 174
174/* controller functions */ 175/* controller functions */
175extern int pciehp_event_start_thread (void); 176extern int pciehp_event_start_thread (void);
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index c67b7c3f1ddf..f93e81e2d2c7 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -448,7 +448,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
448 } 448 }
449 449
450 /* Wait for exclusive access to hardware */ 450 /* Wait for exclusive access to hardware */
451 mutex_lock(&ctrl->crit_sect); 451 mutex_lock(&ctrl->ctrl_lock);
452 452
453 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */ 453 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
454 454
@@ -456,7 +456,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
456 rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/ 456 rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
457 if (rc) { 457 if (rc) {
458 /* Done with exclusive hardware access */ 458 /* Done with exclusive hardware access */
459 mutex_unlock(&ctrl->crit_sect); 459 mutex_unlock(&ctrl->ctrl_lock);
460 goto err_out_free_ctrl_slot; 460 goto err_out_free_ctrl_slot;
461 } else 461 } else
462 /* Wait for the command to complete */ 462 /* Wait for the command to complete */
@@ -464,7 +464,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
464 } 464 }
465 465
466 /* Done with exclusive hardware access */ 466 /* Done with exclusive hardware access */
467 mutex_unlock(&ctrl->crit_sect); 467 mutex_unlock(&ctrl->ctrl_lock);
468 468
469 return 0; 469 return 0;
470 470
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 41290a106bd8..372c63e35aa9 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -43,6 +43,11 @@ static int event_finished;
43static unsigned long pushbutton_pending; /* = 0 */ 43static unsigned long pushbutton_pending; /* = 0 */
44static unsigned long surprise_rm_pending; /* = 0 */ 44static unsigned long surprise_rm_pending; /* = 0 */
45 45
46static inline char *slot_name(struct slot *p_slot)
47{
48 return p_slot->hotplug_slot->name;
49}
50
46u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id) 51u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
47{ 52{
48 struct controller *ctrl = (struct controller *) inst_id; 53 struct controller *ctrl = (struct controller *) inst_id;
@@ -68,7 +73,7 @@ u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
68 /* 73 /*
69 * Button pressed - See if need to TAKE ACTION!!! 74 * Button pressed - See if need to TAKE ACTION!!!
70 */ 75 */
71 info("Button pressed on Slot(%d)\n", ctrl->first_slot + hp_slot); 76 info("Button pressed on Slot(%s)\n", slot_name(p_slot));
72 taskInfo->event_type = INT_BUTTON_PRESS; 77 taskInfo->event_type = INT_BUTTON_PRESS;
73 78
74 if ((p_slot->state == BLINKINGON_STATE) 79 if ((p_slot->state == BLINKINGON_STATE)
@@ -78,7 +83,7 @@ u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
78 * or hot-remove 83 * or hot-remove
79 */ 84 */
80 taskInfo->event_type = INT_BUTTON_CANCEL; 85 taskInfo->event_type = INT_BUTTON_CANCEL;
81 info("Button cancel on Slot(%d)\n", ctrl->first_slot + hp_slot); 86 info("Button cancel on Slot(%s)\n", slot_name(p_slot));
82 } else if ((p_slot->state == POWERON_STATE) 87 } else if ((p_slot->state == POWERON_STATE)
83 || (p_slot->state == POWEROFF_STATE)) { 88 || (p_slot->state == POWEROFF_STATE)) {
84 /* Ignore if the slot is on power-on or power-off state; this 89 /* Ignore if the slot is on power-on or power-off state; this
@@ -86,7 +91,7 @@ u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
86 * hot-remove is undergoing 91 * hot-remove is undergoing
87 */ 92 */
88 taskInfo->event_type = INT_BUTTON_IGNORE; 93 taskInfo->event_type = INT_BUTTON_IGNORE;
89 info("Button ignore on Slot(%d)\n", ctrl->first_slot + hp_slot); 94 info("Button ignore on Slot(%s)\n", slot_name(p_slot));
90 } 95 }
91 96
92 if (rc) 97 if (rc)
@@ -122,13 +127,13 @@ u8 pciehp_handle_switch_change(u8 hp_slot, void *inst_id)
122 /* 127 /*
123 * Switch opened 128 * Switch opened
124 */ 129 */
125 info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot); 130 info("Latch open on Slot(%s)\n", slot_name(p_slot));
126 taskInfo->event_type = INT_SWITCH_OPEN; 131 taskInfo->event_type = INT_SWITCH_OPEN;
127 } else { 132 } else {
128 /* 133 /*
129 * Switch closed 134 * Switch closed
130 */ 135 */
131 info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot); 136 info("Latch close on Slot(%s)\n", slot_name(p_slot));
132 taskInfo->event_type = INT_SWITCH_CLOSE; 137 taskInfo->event_type = INT_SWITCH_CLOSE;
133 } 138 }
134 139
@@ -166,13 +171,13 @@ u8 pciehp_handle_presence_change(u8 hp_slot, void *inst_id)
166 /* 171 /*
167 * Card Present 172 * Card Present
168 */ 173 */
169 info("Card present on Slot(%d)\n", ctrl->first_slot + hp_slot); 174 info("Card present on Slot(%s)\n", slot_name(p_slot));
170 taskInfo->event_type = INT_PRESENCE_ON; 175 taskInfo->event_type = INT_PRESENCE_ON;
171 } else { 176 } else {
172 /* 177 /*
173 * Not Present 178 * Not Present
174 */ 179 */
175 info("Card not present on Slot(%d)\n", ctrl->first_slot + hp_slot); 180 info("Card not present on Slot(%s)\n", slot_name(p_slot));
176 taskInfo->event_type = INT_PRESENCE_OFF; 181 taskInfo->event_type = INT_PRESENCE_OFF;
177 } 182 }
178 183
@@ -206,13 +211,13 @@ u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id)
206 /* 211 /*
207 * power fault Cleared 212 * power fault Cleared
208 */ 213 */
209 info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot); 214 info("Power fault cleared on Slot(%s)\n", slot_name(p_slot));
210 taskInfo->event_type = INT_POWER_FAULT_CLEAR; 215 taskInfo->event_type = INT_POWER_FAULT_CLEAR;
211 } else { 216 } else {
212 /* 217 /*
213 * power fault 218 * power fault
214 */ 219 */
215 info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot); 220 info("Power fault on Slot(%s)\n", slot_name(p_slot));
216 taskInfo->event_type = INT_POWER_FAULT; 221 taskInfo->event_type = INT_POWER_FAULT;
217 info("power fault bit %x set\n", hp_slot); 222 info("power fault bit %x set\n", hp_slot);
218 } 223 }
@@ -229,13 +234,13 @@ u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id)
229static void set_slot_off(struct controller *ctrl, struct slot * pslot) 234static void set_slot_off(struct controller *ctrl, struct slot * pslot)
230{ 235{
231 /* Wait for exclusive access to hardware */ 236 /* Wait for exclusive access to hardware */
232 mutex_lock(&ctrl->crit_sect); 237 mutex_lock(&ctrl->ctrl_lock);
233 238
234 /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ 239 /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
235 if (POWER_CTRL(ctrl->ctrlcap)) { 240 if (POWER_CTRL(ctrl->ctrlcap)) {
236 if (pslot->hpc_ops->power_off_slot(pslot)) { 241 if (pslot->hpc_ops->power_off_slot(pslot)) {
237 err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__); 242 err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__);
238 mutex_unlock(&ctrl->crit_sect); 243 mutex_unlock(&ctrl->ctrl_lock);
239 return; 244 return;
240 } 245 }
241 wait_for_ctrl_irq (ctrl); 246 wait_for_ctrl_irq (ctrl);
@@ -249,14 +254,14 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
249 if (ATTN_LED(ctrl->ctrlcap)) { 254 if (ATTN_LED(ctrl->ctrlcap)) {
250 if (pslot->hpc_ops->set_attention_status(pslot, 1)) { 255 if (pslot->hpc_ops->set_attention_status(pslot, 1)) {
251 err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__); 256 err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__);
252 mutex_unlock(&ctrl->crit_sect); 257 mutex_unlock(&ctrl->ctrl_lock);
253 return; 258 return;
254 } 259 }
255 wait_for_ctrl_irq (ctrl); 260 wait_for_ctrl_irq (ctrl);
256 } 261 }
257 262
258 /* Done with exclusive hardware access */ 263 /* Done with exclusive hardware access */
259 mutex_unlock(&ctrl->crit_sect); 264 mutex_unlock(&ctrl->ctrl_lock);
260} 265}
261 266
262/** 267/**
@@ -279,13 +284,13 @@ static int board_added(struct slot *p_slot)
279 ctrl->slot_device_offset, hp_slot); 284 ctrl->slot_device_offset, hp_slot);
280 285
281 /* Wait for exclusive access to hardware */ 286 /* Wait for exclusive access to hardware */
282 mutex_lock(&ctrl->crit_sect); 287 mutex_lock(&ctrl->ctrl_lock);
283 288
284 if (POWER_CTRL(ctrl->ctrlcap)) { 289 if (POWER_CTRL(ctrl->ctrlcap)) {
285 /* Power on slot */ 290 /* Power on slot */
286 rc = p_slot->hpc_ops->power_on_slot(p_slot); 291 rc = p_slot->hpc_ops->power_on_slot(p_slot);
287 if (rc) { 292 if (rc) {
288 mutex_unlock(&ctrl->crit_sect); 293 mutex_unlock(&ctrl->ctrl_lock);
289 return -1; 294 return -1;
290 } 295 }
291 296
@@ -301,7 +306,7 @@ static int board_added(struct slot *p_slot)
301 } 306 }
302 307
303 /* Done with exclusive hardware access */ 308 /* Done with exclusive hardware access */
304 mutex_unlock(&ctrl->crit_sect); 309 mutex_unlock(&ctrl->ctrl_lock);
305 310
306 /* Wait for ~1 second */ 311 /* Wait for ~1 second */
307 wait_for_ctrl_irq (ctrl); 312 wait_for_ctrl_irq (ctrl);
@@ -335,7 +340,7 @@ static int board_added(struct slot *p_slot)
335 pci_fixup_device(pci_fixup_final, ctrl->pci_dev); 340 pci_fixup_device(pci_fixup_final, ctrl->pci_dev);
336 if (PWR_LED(ctrl->ctrlcap)) { 341 if (PWR_LED(ctrl->ctrlcap)) {
337 /* Wait for exclusive access to hardware */ 342 /* Wait for exclusive access to hardware */
338 mutex_lock(&ctrl->crit_sect); 343 mutex_lock(&ctrl->ctrl_lock);
339 344
340 p_slot->hpc_ops->green_led_on(p_slot); 345 p_slot->hpc_ops->green_led_on(p_slot);
341 346
@@ -343,7 +348,7 @@ static int board_added(struct slot *p_slot)
343 wait_for_ctrl_irq (ctrl); 348 wait_for_ctrl_irq (ctrl);
344 349
345 /* Done with exclusive hardware access */ 350 /* Done with exclusive hardware access */
346 mutex_unlock(&ctrl->crit_sect); 351 mutex_unlock(&ctrl->ctrl_lock);
347 } 352 }
348 return 0; 353 return 0;
349 354
@@ -375,14 +380,14 @@ static int remove_board(struct slot *p_slot)
375 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot); 380 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot);
376 381
377 /* Wait for exclusive access to hardware */ 382 /* Wait for exclusive access to hardware */
378 mutex_lock(&ctrl->crit_sect); 383 mutex_lock(&ctrl->ctrl_lock);
379 384
380 if (POWER_CTRL(ctrl->ctrlcap)) { 385 if (POWER_CTRL(ctrl->ctrlcap)) {
381 /* power off slot */ 386 /* power off slot */
382 rc = p_slot->hpc_ops->power_off_slot(p_slot); 387 rc = p_slot->hpc_ops->power_off_slot(p_slot);
383 if (rc) { 388 if (rc) {
384 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); 389 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
385 mutex_unlock(&ctrl->crit_sect); 390 mutex_unlock(&ctrl->ctrl_lock);
386 return rc; 391 return rc;
387 } 392 }
388 /* Wait for the command to complete */ 393 /* Wait for the command to complete */
@@ -398,7 +403,7 @@ static int remove_board(struct slot *p_slot)
398 } 403 }
399 404
400 /* Done with exclusive hardware access */ 405 /* Done with exclusive hardware access */
401 mutex_unlock(&ctrl->crit_sect); 406 mutex_unlock(&ctrl->ctrl_lock);
402 407
403 return 0; 408 return 0;
404} 409}
@@ -445,7 +450,7 @@ static void pciehp_pushbutton_thread(unsigned long slot)
445 450
446 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { 451 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
447 /* Wait for exclusive access to hardware */ 452 /* Wait for exclusive access to hardware */
448 mutex_lock(&p_slot->ctrl->crit_sect); 453 mutex_lock(&p_slot->ctrl->ctrl_lock);
449 454
450 p_slot->hpc_ops->green_led_off(p_slot); 455 p_slot->hpc_ops->green_led_off(p_slot);
451 456
@@ -453,7 +458,7 @@ static void pciehp_pushbutton_thread(unsigned long slot)
453 wait_for_ctrl_irq (p_slot->ctrl); 458 wait_for_ctrl_irq (p_slot->ctrl);
454 459
455 /* Done with exclusive hardware access */ 460 /* Done with exclusive hardware access */
456 mutex_unlock(&p_slot->ctrl->crit_sect); 461 mutex_unlock(&p_slot->ctrl->ctrl_lock);
457 } 462 }
458 p_slot->state = STATIC_STATE; 463 p_slot->state = STATIC_STATE;
459 } 464 }
@@ -495,7 +500,7 @@ static void pciehp_surprise_rm_thread(unsigned long slot)
495 500
496 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { 501 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
497 /* Wait for exclusive access to hardware */ 502 /* Wait for exclusive access to hardware */
498 mutex_lock(&p_slot->ctrl->crit_sect); 503 mutex_lock(&p_slot->ctrl->ctrl_lock);
499 504
500 p_slot->hpc_ops->green_led_off(p_slot); 505 p_slot->hpc_ops->green_led_off(p_slot);
501 506
@@ -503,7 +508,7 @@ static void pciehp_surprise_rm_thread(unsigned long slot)
503 wait_for_ctrl_irq (p_slot->ctrl); 508 wait_for_ctrl_irq (p_slot->ctrl);
504 509
505 /* Done with exclusive hardware access */ 510 /* Done with exclusive hardware access */
506 mutex_unlock(&p_slot->ctrl->crit_sect); 511 mutex_unlock(&p_slot->ctrl->ctrl_lock);
507 } 512 }
508 p_slot->state = STATIC_STATE; 513 p_slot->state = STATIC_STATE;
509 } 514 }
@@ -616,7 +621,7 @@ static void interrupt_event_handler(struct controller *ctrl)
616 switch (p_slot->state) { 621 switch (p_slot->state) {
617 case BLINKINGOFF_STATE: 622 case BLINKINGOFF_STATE:
618 /* Wait for exclusive access to hardware */ 623 /* Wait for exclusive access to hardware */
619 mutex_lock(&ctrl->crit_sect); 624 mutex_lock(&ctrl->ctrl_lock);
620 625
621 if (PWR_LED(ctrl->ctrlcap)) { 626 if (PWR_LED(ctrl->ctrlcap)) {
622 p_slot->hpc_ops->green_led_on(p_slot); 627 p_slot->hpc_ops->green_led_on(p_slot);
@@ -630,11 +635,11 @@ static void interrupt_event_handler(struct controller *ctrl)
630 wait_for_ctrl_irq (ctrl); 635 wait_for_ctrl_irq (ctrl);
631 } 636 }
632 /* Done with exclusive hardware access */ 637 /* Done with exclusive hardware access */
633 mutex_unlock(&ctrl->crit_sect); 638 mutex_unlock(&ctrl->ctrl_lock);
634 break; 639 break;
635 case BLINKINGON_STATE: 640 case BLINKINGON_STATE:
636 /* Wait for exclusive access to hardware */ 641 /* Wait for exclusive access to hardware */
637 mutex_lock(&ctrl->crit_sect); 642 mutex_lock(&ctrl->ctrl_lock);
638 643
639 if (PWR_LED(ctrl->ctrlcap)) { 644 if (PWR_LED(ctrl->ctrlcap)) {
640 p_slot->hpc_ops->green_led_off(p_slot); 645 p_slot->hpc_ops->green_led_off(p_slot);
@@ -647,14 +652,14 @@ static void interrupt_event_handler(struct controller *ctrl)
647 wait_for_ctrl_irq (ctrl); 652 wait_for_ctrl_irq (ctrl);
648 } 653 }
649 /* Done with exclusive hardware access */ 654 /* Done with exclusive hardware access */
650 mutex_unlock(&ctrl->crit_sect); 655 mutex_unlock(&ctrl->ctrl_lock);
651 656
652 break; 657 break;
653 default: 658 default:
654 warn("Not a valid state\n"); 659 warn("Not a valid state\n");
655 return; 660 return;
656 } 661 }
657 info(msg_button_cancel, p_slot->number); 662 info(msg_button_cancel, slot_name(p_slot));
658 p_slot->state = STATIC_STATE; 663 p_slot->state = STATIC_STATE;
659 } 664 }
660 /* ***********Button Pressed (No action on 1st press...) */ 665 /* ***********Button Pressed (No action on 1st press...) */
@@ -667,16 +672,16 @@ static void interrupt_event_handler(struct controller *ctrl)
667 /* slot is on */ 672 /* slot is on */
668 dbg("slot is on\n"); 673 dbg("slot is on\n");
669 p_slot->state = BLINKINGOFF_STATE; 674 p_slot->state = BLINKINGOFF_STATE;
670 info(msg_button_off, p_slot->number); 675 info(msg_button_off, slot_name(p_slot));
671 } else { 676 } else {
672 /* slot is off */ 677 /* slot is off */
673 dbg("slot is off\n"); 678 dbg("slot is off\n");
674 p_slot->state = BLINKINGON_STATE; 679 p_slot->state = BLINKINGON_STATE;
675 info(msg_button_on, p_slot->number); 680 info(msg_button_on, slot_name(p_slot));
676 } 681 }
677 682
678 /* Wait for exclusive access to hardware */ 683 /* Wait for exclusive access to hardware */
679 mutex_lock(&ctrl->crit_sect); 684 mutex_lock(&ctrl->ctrl_lock);
680 685
681 /* blink green LED and turn off amber */ 686 /* blink green LED and turn off amber */
682 if (PWR_LED(ctrl->ctrlcap)) { 687 if (PWR_LED(ctrl->ctrlcap)) {
@@ -693,7 +698,7 @@ static void interrupt_event_handler(struct controller *ctrl)
693 } 698 }
694 699
695 /* Done with exclusive hardware access */ 700 /* Done with exclusive hardware access */
696 mutex_unlock(&ctrl->crit_sect); 701 mutex_unlock(&ctrl->ctrl_lock);
697 702
698 init_timer(&p_slot->task_event); 703 init_timer(&p_slot->task_event);
699 p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */ 704 p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */
@@ -708,7 +713,7 @@ static void interrupt_event_handler(struct controller *ctrl)
708 if (POWER_CTRL(ctrl->ctrlcap)) { 713 if (POWER_CTRL(ctrl->ctrlcap)) {
709 dbg("power fault\n"); 714 dbg("power fault\n");
710 /* Wait for exclusive access to hardware */ 715 /* Wait for exclusive access to hardware */
711 mutex_lock(&ctrl->crit_sect); 716 mutex_lock(&ctrl->ctrl_lock);
712 717
713 if (ATTN_LED(ctrl->ctrlcap)) { 718 if (ATTN_LED(ctrl->ctrlcap)) {
714 p_slot->hpc_ops->set_attention_status(p_slot, 1); 719 p_slot->hpc_ops->set_attention_status(p_slot, 1);
@@ -721,7 +726,7 @@ static void interrupt_event_handler(struct controller *ctrl)
721 } 726 }
722 727
723 /* Done with exclusive hardware access */ 728 /* Done with exclusive hardware access */
724 mutex_unlock(&ctrl->crit_sect); 729 mutex_unlock(&ctrl->ctrl_lock);
725 } 730 }
726 } 731 }
727 /***********SURPRISE REMOVAL********************/ 732 /***********SURPRISE REMOVAL********************/
@@ -760,14 +765,16 @@ int pciehp_enable_slot(struct slot *p_slot)
760 765
761 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 766 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
762 if (rc || !getstatus) { 767 if (rc || !getstatus) {
763 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 768 info("%s: no adapter on slot(%s)\n", __FUNCTION__,
769 slot_name(p_slot));
764 mutex_unlock(&p_slot->ctrl->crit_sect); 770 mutex_unlock(&p_slot->ctrl->crit_sect);
765 return -ENODEV; 771 return -ENODEV;
766 } 772 }
767 if (MRL_SENS(p_slot->ctrl->ctrlcap)) { 773 if (MRL_SENS(p_slot->ctrl->ctrlcap)) {
768 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 774 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
769 if (rc || getstatus) { 775 if (rc || getstatus) {
770 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 776 info("%s: latch open on slot(%s)\n", __FUNCTION__,
777 slot_name(p_slot));
771 mutex_unlock(&p_slot->ctrl->crit_sect); 778 mutex_unlock(&p_slot->ctrl->crit_sect);
772 return -ENODEV; 779 return -ENODEV;
773 } 780 }
@@ -776,12 +783,12 @@ int pciehp_enable_slot(struct slot *p_slot)
776 if (POWER_CTRL(p_slot->ctrl->ctrlcap)) { 783 if (POWER_CTRL(p_slot->ctrl->ctrlcap)) {
777 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 784 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
778 if (rc || getstatus) { 785 if (rc || getstatus) {
779 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); 786 info("%s: already enabled on slot(%s)\n", __FUNCTION__,
787 slot_name(p_slot));
780 mutex_unlock(&p_slot->ctrl->crit_sect); 788 mutex_unlock(&p_slot->ctrl->crit_sect);
781 return -EINVAL; 789 return -EINVAL;
782 } 790 }
783 } 791 }
784 mutex_unlock(&p_slot->ctrl->crit_sect);
785 792
786 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 793 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
787 794
@@ -790,9 +797,9 @@ int pciehp_enable_slot(struct slot *p_slot)
790 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 797 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
791 } 798 }
792 799
793 if (p_slot) 800 update_slot_info(p_slot);
794 update_slot_info(p_slot);
795 801
802 mutex_unlock(&p_slot->ctrl->crit_sect);
796 return rc; 803 return rc;
797} 804}
798 805
@@ -811,7 +818,8 @@ int pciehp_disable_slot(struct slot *p_slot)
811 if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) { 818 if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) {
812 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 819 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
813 if (ret || !getstatus) { 820 if (ret || !getstatus) {
814 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 821 info("%s: no adapter on slot(%s)\n", __FUNCTION__,
822 slot_name(p_slot));
815 mutex_unlock(&p_slot->ctrl->crit_sect); 823 mutex_unlock(&p_slot->ctrl->crit_sect);
816 return -ENODEV; 824 return -ENODEV;
817 } 825 }
@@ -820,7 +828,8 @@ int pciehp_disable_slot(struct slot *p_slot)
820 if (MRL_SENS(p_slot->ctrl->ctrlcap)) { 828 if (MRL_SENS(p_slot->ctrl->ctrlcap)) {
821 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 829 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
822 if (ret || getstatus) { 830 if (ret || getstatus) {
823 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 831 info("%s: latch open on slot(%s)\n", __FUNCTION__,
832 slot_name(p_slot));
824 mutex_unlock(&p_slot->ctrl->crit_sect); 833 mutex_unlock(&p_slot->ctrl->crit_sect);
825 return -ENODEV; 834 return -ENODEV;
826 } 835 }
@@ -829,16 +838,17 @@ int pciehp_disable_slot(struct slot *p_slot)
829 if (POWER_CTRL(p_slot->ctrl->ctrlcap)) { 838 if (POWER_CTRL(p_slot->ctrl->ctrlcap)) {
830 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 839 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
831 if (ret || !getstatus) { 840 if (ret || !getstatus) {
832 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); 841 info("%s: already disabled slot(%s)\n", __FUNCTION__,
842 slot_name(p_slot));
833 mutex_unlock(&p_slot->ctrl->crit_sect); 843 mutex_unlock(&p_slot->ctrl->crit_sect);
834 return -EINVAL; 844 return -EINVAL;
835 } 845 }
836 } 846 }
837 847
838 mutex_unlock(&p_slot->ctrl->crit_sect);
839
840 ret = remove_board(p_slot); 848 ret = remove_board(p_slot);
841 update_slot_info(p_slot); 849 update_slot_info(p_slot);
850
851 mutex_unlock(&p_slot->ctrl->crit_sect);
842 return ret; 852 return ret;
843} 853}
844 854
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 703a64a39fe8..1c551c697c35 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -1402,6 +1402,8 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1402 pdev->subsystem_vendor, pdev->subsystem_device); 1402 pdev->subsystem_vendor, pdev->subsystem_device);
1403 1403
1404 mutex_init(&ctrl->crit_sect); 1404 mutex_init(&ctrl->crit_sect);
1405 mutex_init(&ctrl->ctrl_lock);
1406
1405 /* setup wait queue */ 1407 /* setup wait queue */
1406 init_waitqueue_head(&ctrl->queue); 1408 init_waitqueue_head(&ctrl->queue);
1407 1409
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c
index 2b9e10e38613..50bcd3fe61da 100644
--- a/drivers/pci/hotplug/pcihp_skeleton.c
+++ b/drivers/pci/hotplug/pcihp_skeleton.c
@@ -33,8 +33,8 @@
33#include <linux/kernel.h> 33#include <linux/kernel.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/pci_hotplug.h>
36#include <linux/init.h> 37#include <linux/init.h>
37#include "pci_hotplug.h"
38 38
39#define SLOT_NAME_SIZE 10 39#define SLOT_NAME_SIZE 10
40struct slot { 40struct slot {
diff --git a/drivers/pci/hotplug/rpadlpar_sysfs.c b/drivers/pci/hotplug/rpadlpar_sysfs.c
index db69be85b458..6c5be3ff578c 100644
--- a/drivers/pci/hotplug/rpadlpar_sysfs.c
+++ b/drivers/pci/hotplug/rpadlpar_sysfs.c
@@ -14,7 +14,7 @@
14 */ 14 */
15#include <linux/kobject.h> 15#include <linux/kobject.h>
16#include <linux/string.h> 16#include <linux/string.h>
17#include "pci_hotplug.h" 17#include <linux/pci_hotplug.h>
18#include "rpadlpar.h" 18#include "rpadlpar.h"
19 19
20#define DLPAR_KOBJ_NAME "control" 20#define DLPAR_KOBJ_NAME "control"
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index 310b6186c0e5..2e7accf0f734 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -28,7 +28,7 @@
28#define _PPC64PHP_H 28#define _PPC64PHP_H
29 29
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include "pci_hotplug.h" 31#include <linux/pci_hotplug.h>
32 32
33#define DR_INDICATOR 9002 33#define DR_INDICATOR 9002
34#define DR_ENTITY_SENSE 9003 34#define DR_ENTITY_SENSE 9003
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 7288a3eccfb3..141486df235b 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -26,6 +26,7 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/moduleparam.h> 27#include <linux/moduleparam.h>
28#include <linux/pci.h> 28#include <linux/pci.h>
29#include <linux/pci_hotplug.h>
29#include <linux/slab.h> 30#include <linux/slab.h>
30#include <linux/smp.h> 31#include <linux/smp.h>
31#include <linux/smp_lock.h> 32#include <linux/smp_lock.h>
@@ -36,7 +37,6 @@
36#include "../pci.h" /* for pci_add_new_bus */ 37#include "../pci.h" /* for pci_add_new_bus */
37 /* and pci_do_scan_bus */ 38 /* and pci_do_scan_bus */
38#include "rpaphp.h" 39#include "rpaphp.h"
39#include "pci_hotplug.h"
40 40
41int debug; 41int debug;
42static struct semaphore rpaphp_sem; 42static struct semaphore rpaphp_sem;
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index f31d83c2c633..b62ad31a9739 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -13,6 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/pci.h> 15#include <linux/pci.h>
16#include <linux/pci_hotplug.h>
16#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
17#include <linux/types.h> 18#include <linux/types.h>
18#include <linux/mutex.h> 19#include <linux/mutex.h>
@@ -29,7 +30,6 @@
29#include <asm/sn/types.h> 30#include <asm/sn/types.h>
30 31
31#include "../pci.h" 32#include "../pci.h"
32#include "pci_hotplug.h"
33 33
34MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
35MODULE_AUTHOR("SGI (prarit@sgi.com, dickie@sgi.com, habeck@sgi.com)"); 35MODULE_AUTHOR("SGI (prarit@sgi.com, dickie@sgi.com, habeck@sgi.com)");
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index c7103ac5cd06..ea2087c34149 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -31,12 +31,11 @@
31 31
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/pci_hotplug.h>
34#include <linux/delay.h> 35#include <linux/delay.h>
35#include <linux/sched.h> /* signal_pending(), struct timer_list */ 36#include <linux/sched.h> /* signal_pending(), struct timer_list */
36#include <linux/mutex.h> 37#include <linux/mutex.h>
37 38
38#include "pci_hotplug.h"
39
40#if !defined(MODULE) 39#if !defined(MODULE)
41 #define MY_NAME "shpchp" 40 #define MY_NAME "shpchp"
42#else 41#else
@@ -103,7 +102,6 @@ struct controller {
103 u32 cap_offset; 102 u32 cap_offset;
104 unsigned long mmio_base; 103 unsigned long mmio_base;
105 unsigned long mmio_size; 104 unsigned long mmio_size;
106 volatile int cmd_busy;
107}; 105};
108 106
109 107
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
index 4d8aee119134..83a5226ba9ed 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -302,21 +302,51 @@ static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int sec)
302 add_timer(&php_ctlr->int_poll_timer); 302 add_timer(&php_ctlr->int_poll_timer);
303} 303}
304 304
305static inline int is_ctrl_busy(struct controller *ctrl)
306{
307 u16 cmd_status = shpc_readw(ctrl, CMD_STATUS);
308 return cmd_status & 0x1;
309}
310
311/*
312 * Returns 1 if SHPC finishes executing a command within 1 sec,
313 * otherwise returns 0.
314 */
315static inline int shpc_poll_ctrl_busy(struct controller *ctrl)
316{
317 int i;
318
319 if (!is_ctrl_busy(ctrl))
320 return 1;
321
322 /* Check every 0.1 sec for a total of 1 sec */
323 for (i = 0; i < 10; i++) {
324 msleep(100);
325 if (!is_ctrl_busy(ctrl))
326 return 1;
327 }
328
329 return 0;
330}
331
305static inline int shpc_wait_cmd(struct controller *ctrl) 332static inline int shpc_wait_cmd(struct controller *ctrl)
306{ 333{
307 int retval = 0; 334 int retval = 0;
308 unsigned int timeout_msec = shpchp_poll_mode ? 2000 : 1000; 335 unsigned long timeout = msecs_to_jiffies(1000);
309 unsigned long timeout = msecs_to_jiffies(timeout_msec); 336 int rc;
310 int rc = wait_event_interruptible_timeout(ctrl->queue, 337
311 !ctrl->cmd_busy, timeout); 338 if (shpchp_poll_mode)
312 if (!rc) { 339 rc = shpc_poll_ctrl_busy(ctrl);
340 else
341 rc = wait_event_interruptible_timeout(ctrl->queue,
342 !is_ctrl_busy(ctrl), timeout);
343 if (!rc && is_ctrl_busy(ctrl)) {
313 retval = -EIO; 344 retval = -EIO;
314 err("Command not completed in %d msec\n", timeout_msec); 345 err("Command not completed in 1000 msec\n");
315 } else if (rc < 0) { 346 } else if (rc < 0) {
316 retval = -EINTR; 347 retval = -EINTR;
317 info("Command was interrupted by a signal\n"); 348 info("Command was interrupted by a signal\n");
318 } 349 }
319 ctrl->cmd_busy = 0;
320 350
321 return retval; 351 return retval;
322} 352}
@@ -327,26 +357,15 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
327 u16 cmd_status; 357 u16 cmd_status;
328 int retval = 0; 358 int retval = 0;
329 u16 temp_word; 359 u16 temp_word;
330 int i;
331 360
332 DBG_ENTER_ROUTINE 361 DBG_ENTER_ROUTINE
333 362
334 mutex_lock(&slot->ctrl->cmd_lock); 363 mutex_lock(&slot->ctrl->cmd_lock);
335 364
336 for (i = 0; i < 10; i++) { 365 if (!shpc_poll_ctrl_busy(ctrl)) {
337 cmd_status = shpc_readw(ctrl, CMD_STATUS);
338
339 if (!(cmd_status & 0x1))
340 break;
341 /* Check every 0.1 sec for a total of 1 sec*/
342 msleep(100);
343 }
344
345 cmd_status = shpc_readw(ctrl, CMD_STATUS);
346
347 if (cmd_status & 0x1) {
348 /* After 1 sec and and the controller is still busy */ 366 /* After 1 sec and and the controller is still busy */
349 err("%s : Controller is still busy after 1 sec.\n", __FUNCTION__); 367 err("%s : Controller is still busy after 1 sec.\n",
368 __FUNCTION__);
350 retval = -EBUSY; 369 retval = -EBUSY;
351 goto out; 370 goto out;
352 } 371 }
@@ -358,7 +377,6 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
358 /* To make sure the Controller Busy bit is 0 before we send out the 377 /* To make sure the Controller Busy bit is 0 before we send out the
359 * command. 378 * command.
360 */ 379 */
361 slot->ctrl->cmd_busy = 1;
362 shpc_writew(ctrl, CMD, temp_word); 380 shpc_writew(ctrl, CMD, temp_word);
363 381
364 /* 382 /*
@@ -908,7 +926,6 @@ static irqreturn_t shpc_isr(int irq, void *dev_id)
908 serr_int &= ~SERR_INTR_RSVDZ_MASK; 926 serr_int &= ~SERR_INTR_RSVDZ_MASK;
909 shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int); 927 shpc_writel(ctrl, SERR_INTR_ENABLE, serr_int);
910 928
911 ctrl->cmd_busy = 0;
912 wake_up_interruptible(&ctrl->queue); 929 wake_up_interruptible(&ctrl->queue);
913 } 930 }
914 931
@@ -1101,7 +1118,7 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1101{ 1118{
1102 struct php_ctlr_state_s *php_ctlr, *p; 1119 struct php_ctlr_state_s *php_ctlr, *p;
1103 void *instance_id = ctrl; 1120 void *instance_id = ctrl;
1104 int rc, num_slots = 0; 1121 int rc = -1, num_slots = 0;
1105 u8 hp_slot; 1122 u8 hp_slot;
1106 u32 shpc_base_offset; 1123 u32 shpc_base_offset;
1107 u32 tempdword, slot_reg, slot_config; 1124 u32 tempdword, slot_reg, slot_config;
@@ -1167,11 +1184,15 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1167 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor, 1184 info("HPC vendor_id %x device_id %x ss_vid %x ss_did %x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor,
1168 pdev->subsystem_device); 1185 pdev->subsystem_device);
1169 1186
1170 if (pci_enable_device(pdev)) 1187 rc = pci_enable_device(pdev);
1188 if (rc) {
1189 err("%s: pci_enable_device failed\n", __FUNCTION__);
1171 goto abort_free_ctlr; 1190 goto abort_free_ctlr;
1191 }
1172 1192
1173 if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) { 1193 if (!request_mem_region(ctrl->mmio_base, ctrl->mmio_size, MY_NAME)) {
1174 err("%s: cannot reserve MMIO region\n", __FUNCTION__); 1194 err("%s: cannot reserve MMIO region\n", __FUNCTION__);
1195 rc = -1;
1175 goto abort_free_ctlr; 1196 goto abort_free_ctlr;
1176 } 1197 }
1177 1198
@@ -1180,6 +1201,7 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1180 err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__, 1201 err("%s: cannot remap MMIO region %lx @ %lx\n", __FUNCTION__,
1181 ctrl->mmio_size, ctrl->mmio_base); 1202 ctrl->mmio_size, ctrl->mmio_base);
1182 release_mem_region(ctrl->mmio_base, ctrl->mmio_size); 1203 release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
1204 rc = -1;
1183 goto abort_free_ctlr; 1205 goto abort_free_ctlr;
1184 } 1206 }
1185 dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg); 1207 dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg);
@@ -1282,8 +1304,10 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1282 */ 1304 */
1283 if (atomic_add_return(1, &shpchp_num_controllers) == 1) { 1305 if (atomic_add_return(1, &shpchp_num_controllers) == 1) {
1284 shpchp_wq = create_singlethread_workqueue("shpchpd"); 1306 shpchp_wq = create_singlethread_workqueue("shpchpd");
1285 if (!shpchp_wq) 1307 if (!shpchp_wq) {
1286 return -ENOMEM; 1308 rc = -ENOMEM;
1309 goto abort_free_ctlr;
1310 }
1287 } 1311 }
1288 1312
1289 /* 1313 /*
@@ -1313,8 +1337,10 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
1313 1337
1314 /* We end up here for the many possible ways to fail this API. */ 1338 /* We end up here for the many possible ways to fail this API. */
1315abort_free_ctlr: 1339abort_free_ctlr:
1340 if (php_ctlr->creg)
1341 iounmap(php_ctlr->creg);
1316 kfree(php_ctlr); 1342 kfree(php_ctlr);
1317abort: 1343abort:
1318 DBG_LEAVE_ROUTINE 1344 DBG_LEAVE_ROUTINE
1319 return -1; 1345 return rc;
1320} 1346}
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index f9fdc54473c4..9fc9a34ef24a 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -627,22 +627,24 @@ static int msix_capability_init(struct pci_dev *dev,
627 * pci_msi_supported - check whether MSI may be enabled on device 627 * pci_msi_supported - check whether MSI may be enabled on device
628 * @dev: pointer to the pci_dev data structure of MSI device function 628 * @dev: pointer to the pci_dev data structure of MSI device function
629 * 629 *
630 * MSI must be globally enabled and supported by the device and its root 630 * Look at global flags, the device itself, and its parent busses
631 * bus. But, the root bus is not easy to find since some architectures 631 * to return 0 if MSI are supported for the device.
632 * have virtual busses on top of the PCI hierarchy (for instance the
633 * hypertransport bus), while the actual bus where MSI must be supported
634 * is below. So we test the MSI flag on all parent busses and assume
635 * that no quirk will ever set the NO_MSI flag on a non-root bus.
636 **/ 632 **/
637static 633static
638int pci_msi_supported(struct pci_dev * dev) 634int pci_msi_supported(struct pci_dev * dev)
639{ 635{
640 struct pci_bus *bus; 636 struct pci_bus *bus;
641 637
638 /* MSI must be globally enabled and supported by the device */
642 if (!pci_msi_enable || !dev || dev->no_msi) 639 if (!pci_msi_enable || !dev || dev->no_msi)
643 return -EINVAL; 640 return -EINVAL;
644 641
645 /* check MSI flags of all parent busses */ 642 /* Any bridge which does NOT route MSI transactions from it's
643 * secondary bus to it's primary bus must set NO_MSI flag on
644 * the secondary pci_bus.
645 * We expect only arch-specific PCI host bus controller driver
646 * or quirks for specific PCI bridges to be setting NO_MSI.
647 */
646 for (bus = dev->bus; bus; bus = bus->parent) 648 for (bus = dev->bus; bus; bus = bus->parent)
647 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI) 649 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI)
648 return -EINVAL; 650 return -EINVAL;
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h
index 67fcd176babd..3656e0349dd1 100644
--- a/drivers/pci/pcie/portdrv.h
+++ b/drivers/pci/pcie/portdrv.h
@@ -9,6 +9,8 @@
9#ifndef _PORTDRV_H_ 9#ifndef _PORTDRV_H_
10#define _PORTDRV_H_ 10#define _PORTDRV_H_
11 11
12#include <linux/compiler.h>
13
12#if !defined(PCI_CAP_ID_PME) 14#if !defined(PCI_CAP_ID_PME)
13#define PCI_CAP_ID_PME 1 15#define PCI_CAP_ID_PME 1
14#endif 16#endif
@@ -39,7 +41,7 @@ extern int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state);
39extern int pcie_port_device_resume(struct pci_dev *dev); 41extern int pcie_port_device_resume(struct pci_dev *dev);
40#endif 42#endif
41extern void pcie_port_device_remove(struct pci_dev *dev); 43extern void pcie_port_device_remove(struct pci_dev *dev);
42extern int pcie_port_bus_register(void); 44extern int __must_check pcie_port_bus_register(void);
43extern void pcie_port_bus_unregister(void); 45extern void pcie_port_bus_unregister(void);
44 46
45#endif /* _PORTDRV_H_ */ 47#endif /* _PORTDRV_H_ */
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index bd6615b4d40e..b20a9b81dae2 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -6,7 +6,6 @@
6 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com) 6 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
7 */ 7 */
8 8
9#include <linux/compiler.h>
10#include <linux/module.h> 9#include <linux/module.h>
11#include <linux/pci.h> 10#include <linux/pci.h>
12#include <linux/kernel.h> 11#include <linux/kernel.h>
@@ -401,7 +400,7 @@ void pcie_port_device_remove(struct pci_dev *dev)
401 pci_disable_msi(dev); 400 pci_disable_msi(dev);
402} 401}
403 402
404int __must_check pcie_port_bus_register(void) 403int pcie_port_bus_register(void)
405{ 404{
406 return bus_register(&pcie_port_bus_type); 405 return bus_register(&pcie_port_bus_type);
407} 406}
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 037690e08f5f..b4da7954611e 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -37,7 +37,6 @@ static int pcie_portdrv_save_config(struct pci_dev *dev)
37 return pci_save_state(dev); 37 return pci_save_state(dev);
38} 38}
39 39
40#ifdef CONFIG_PM
41static int pcie_portdrv_restore_config(struct pci_dev *dev) 40static int pcie_portdrv_restore_config(struct pci_dev *dev)
42{ 41{
43 int retval; 42 int retval;
@@ -50,6 +49,7 @@ static int pcie_portdrv_restore_config(struct pci_dev *dev)
50 return 0; 49 return 0;
51} 50}
52 51
52#ifdef CONFIG_PM
53static int pcie_portdrv_suspend(struct pci_dev *dev, pm_message_t state) 53static int pcie_portdrv_suspend(struct pci_dev *dev, pm_message_t state)
54{ 54{
55 int ret = pcie_port_device_suspend(dev, state); 55 int ret = pcie_port_device_suspend(dev, state);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index a3b0a5eb5054..e159d6604494 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1067,3 +1067,95 @@ EXPORT_SYMBOL(pci_scan_bridge);
1067EXPORT_SYMBOL(pci_scan_single_device); 1067EXPORT_SYMBOL(pci_scan_single_device);
1068EXPORT_SYMBOL_GPL(pci_scan_child_bus); 1068EXPORT_SYMBOL_GPL(pci_scan_child_bus);
1069#endif 1069#endif
1070
1071static int __init pci_sort_bf_cmp(const struct pci_dev *a, const struct pci_dev *b)
1072{
1073 if (pci_domain_nr(a->bus) < pci_domain_nr(b->bus)) return -1;
1074 else if (pci_domain_nr(a->bus) > pci_domain_nr(b->bus)) return 1;
1075
1076 if (a->bus->number < b->bus->number) return -1;
1077 else if (a->bus->number > b->bus->number) return 1;
1078
1079 if (a->devfn < b->devfn) return -1;
1080 else if (a->devfn > b->devfn) return 1;
1081
1082 return 0;
1083}
1084
1085/*
1086 * Yes, this forcably breaks the klist abstraction temporarily. It
1087 * just wants to sort the klist, not change reference counts and
1088 * take/drop locks rapidly in the process. It does all this while
1089 * holding the lock for the list, so objects can't otherwise be
1090 * added/removed while we're swizzling.
1091 */
1092static void __init pci_insertion_sort_klist(struct pci_dev *a, struct list_head *list)
1093{
1094 struct list_head *pos;
1095 struct klist_node *n;
1096 struct device *dev;
1097 struct pci_dev *b;
1098
1099 list_for_each(pos, list) {
1100 n = container_of(pos, struct klist_node, n_node);
1101 dev = container_of(n, struct device, knode_bus);
1102 b = to_pci_dev(dev);
1103 if (pci_sort_bf_cmp(a, b) <= 0) {
1104 list_move_tail(&a->dev.knode_bus.n_node, &b->dev.knode_bus.n_node);
1105 return;
1106 }
1107 }
1108 list_move_tail(&a->dev.knode_bus.n_node, list);
1109}
1110
1111static void __init pci_sort_breadthfirst_klist(void)
1112{
1113 LIST_HEAD(sorted_devices);
1114 struct list_head *pos, *tmp;
1115 struct klist_node *n;
1116 struct device *dev;
1117 struct pci_dev *pdev;
1118
1119 spin_lock(&pci_bus_type.klist_devices.k_lock);
1120 list_for_each_safe(pos, tmp, &pci_bus_type.klist_devices.k_list) {
1121 n = container_of(pos, struct klist_node, n_node);
1122 dev = container_of(n, struct device, knode_bus);
1123 pdev = to_pci_dev(dev);
1124 pci_insertion_sort_klist(pdev, &sorted_devices);
1125 }
1126 list_splice(&sorted_devices, &pci_bus_type.klist_devices.k_list);
1127 spin_unlock(&pci_bus_type.klist_devices.k_lock);
1128}
1129
1130static void __init pci_insertion_sort_devices(struct pci_dev *a, struct list_head *list)
1131{
1132 struct pci_dev *b;
1133
1134 list_for_each_entry(b, list, global_list) {
1135 if (pci_sort_bf_cmp(a, b) <= 0) {
1136 list_move_tail(&a->global_list, &b->global_list);
1137 return;
1138 }
1139 }
1140 list_move_tail(&a->global_list, list);
1141}
1142
1143static void __init pci_sort_breadthfirst_devices(void)
1144{
1145 LIST_HEAD(sorted_devices);
1146 struct pci_dev *dev, *tmp;
1147
1148 down_write(&pci_bus_sem);
1149 list_for_each_entry_safe(dev, tmp, &pci_devices, global_list) {
1150 pci_insertion_sort_devices(dev, &sorted_devices);
1151 }
1152 list_splice(&sorted_devices, &pci_devices);
1153 up_write(&pci_bus_sem);
1154}
1155
1156void __init pci_sort_breadthfirst(void)
1157{
1158 pci_sort_breadthfirst_devices();
1159 pci_sort_breadthfirst_klist();
1160}
1161
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 23b599d6a9d5..e8a7f1b1b2bc 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -453,6 +453,12 @@ static void __devinit quirk_ich6_lpc_acpi(struct pci_dev *dev)
453} 453}
454DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0, quirk_ich6_lpc_acpi ); 454DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0, quirk_ich6_lpc_acpi );
455DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, quirk_ich6_lpc_acpi ); 455DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, quirk_ich6_lpc_acpi );
456DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, quirk_ich6_lpc_acpi );
457DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, quirk_ich6_lpc_acpi );
458DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31, quirk_ich6_lpc_acpi );
459DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_0, quirk_ich6_lpc_acpi );
460DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_2, quirk_ich6_lpc_acpi );
461DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_3, quirk_ich6_lpc_acpi );
456 462
457/* 463/*
458 * VIA ACPI: One IO region pointed to by longword at 464 * VIA ACPI: One IO region pointed to by longword at
@@ -648,11 +654,43 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_vi
648 * Some of the on-chip devices are actually '586 devices' so they are 654 * Some of the on-chip devices are actually '586 devices' so they are
649 * listed here. 655 * listed here.
650 */ 656 */
657
658static int via_irq_fixup_needed = -1;
659
660/*
661 * As some VIA hardware is available in PCI-card form, we need to restrict
662 * this quirk to VIA PCI hardware built onto VIA-based motherboards only.
663 * We try to locate a VIA southbridge before deciding whether the quirk
664 * should be applied.
665 */
666static const struct pci_device_id via_irq_fixup_tbl[] = {
667 {
668 .vendor = PCI_VENDOR_ID_VIA,
669 .device = PCI_ANY_ID,
670 .subvendor = PCI_ANY_ID,
671 .subdevice = PCI_ANY_ID,
672 .class = PCI_CLASS_BRIDGE_ISA << 8,
673 .class_mask = 0xffff00,
674 },
675 { 0, },
676};
677
651static void quirk_via_irq(struct pci_dev *dev) 678static void quirk_via_irq(struct pci_dev *dev)
652{ 679{
653 u8 irq, new_irq; 680 u8 irq, new_irq;
654 681
655 new_irq = dev->irq & 0xf; 682 if (via_irq_fixup_needed == -1)
683 via_irq_fixup_needed = pci_dev_present(via_irq_fixup_tbl);
684
685 if (!via_irq_fixup_needed)
686 return;
687
688 new_irq = dev->irq;
689
690 /* Don't quirk interrupts outside the legacy IRQ range */
691 if (!new_irq || new_irq > 15)
692 return;
693
656 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); 694 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
657 if (new_irq != irq) { 695 if (new_irq != irq) {
658 printk(KERN_INFO "PCI: VIA IRQ fixup for %s, from %d to %d\n", 696 printk(KERN_INFO "PCI: VIA IRQ fixup for %s, from %d to %d\n",
@@ -661,14 +699,7 @@ static void quirk_via_irq(struct pci_dev *dev)
661 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq); 699 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq);
662 } 700 }
663} 701}
664DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_0, quirk_via_irq); 702DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_irq);
665DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, quirk_via_irq);
666DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_2, quirk_via_irq);
667DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_via_irq);
668DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235_USB_2, quirk_via_irq);
669DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_irq);
670DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_irq);
671DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_5, quirk_via_irq);
672 703
673/* 704/*
674 * VIA VT82C598 has its device ID settable and many BIOSes 705 * VIA VT82C598 has its device ID settable and many BIOSes
@@ -1588,6 +1619,51 @@ static void __devinit fixup_rev1_53c810(struct pci_dev* dev)
1588} 1619}
1589DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810); 1620DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810);
1590 1621
1622/*
1623 * Fixup to mark boot BIOS video selected by BIOS before it changes
1624 *
1625 * From information provided by "Jon Smirl" <jonsmirl@gmail.com>
1626 *
1627 * The standard boot ROM sequence for an x86 machine uses the BIOS
1628 * to select an initial video card for boot display. This boot video
1629 * card will have it's BIOS copied to C0000 in system RAM.
1630 * IORESOURCE_ROM_SHADOW is used to associate the boot video
1631 * card with this copy. On laptops this copy has to be used since
1632 * the main ROM may be compressed or combined with another image.
1633 * See pci_map_rom() for use of this flag. IORESOURCE_ROM_SHADOW
1634 * is marked here since the boot video device will be the only enabled
1635 * video device at this point.
1636 */
1637
1638static void __devinit fixup_video(struct pci_dev *pdev)
1639{
1640 struct pci_dev *bridge;
1641 struct pci_bus *bus;
1642 u16 config;
1643
1644 if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
1645 return;
1646
1647 /* Is VGA routed to us? */
1648 bus = pdev->bus;
1649 while (bus) {
1650 bridge = bus->self;
1651 if (bridge) {
1652 pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
1653 &config);
1654 if (!(config & PCI_BRIDGE_CTL_VGA))
1655 return;
1656 }
1657 bus = bus->parent;
1658 }
1659 pci_read_config_word(pdev, PCI_COMMAND, &config);
1660 if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
1661 pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
1662 printk(KERN_DEBUG "Boot video device is %s\n", pci_name(pdev));
1663 }
1664}
1665DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, fixup_video);
1666
1591 1667
1592static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end) 1668static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end)
1593{ 1669{
@@ -1764,7 +1840,7 @@ static void __devinit quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev)
1764 /* check HT MSI cap on this chipset and the root one. 1840 /* check HT MSI cap on this chipset and the root one.
1765 * a single one having MSI is enough to be sure that MSI are supported. 1841 * a single one having MSI is enough to be sure that MSI are supported.
1766 */ 1842 */
1767 pdev = pci_find_slot(dev->bus->number, 0); 1843 pdev = pci_get_slot(dev->bus, 0);
1768 if (dev->subordinate && !msi_ht_cap_enabled(dev) 1844 if (dev->subordinate && !msi_ht_cap_enabled(dev)
1769 && !msi_ht_cap_enabled(pdev)) { 1845 && !msi_ht_cap_enabled(pdev)) {
1770 printk(KERN_WARNING "PCI: MSI quirk detected. " 1846 printk(KERN_WARNING "PCI: MSI quirk detected. "
@@ -1772,6 +1848,7 @@ static void __devinit quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev)
1772 pci_name(dev)); 1848 pci_name(dev));
1773 dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; 1849 dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI;
1774 } 1850 }
1851 pci_dev_put(pdev);
1775} 1852}
1776DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE, 1853DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE,
1777 quirk_nvidia_ck804_msi_ht_cap); 1854 quirk_nvidia_ck804_msi_ht_cap);
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index f5ee7ce16fa6..43e4a49f2cc4 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -71,7 +71,10 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
71 void __iomem *image; 71 void __iomem *image;
72 int last_image; 72 int last_image;
73 73
74 /* IORESOURCE_ROM_SHADOW only set on x86 */ 74 /*
75 * IORESOURCE_ROM_SHADOW set if the VGA enable bit of the Bridge Control
76 * register is set for embedded VGA.
77 */
75 if (res->flags & IORESOURCE_ROM_SHADOW) { 78 if (res->flags & IORESOURCE_ROM_SHADOW) {
76 /* primary video rom always starts here */ 79 /* primary video rom always starts here */
77 start = (loff_t)0xC0000; 80 start = (loff_t)0xC0000;
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index d529462d1b53..2f13eba5d5ae 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -140,6 +140,31 @@ struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn)
140} 140}
141 141
142/** 142/**
143 * pci_get_bus_and_slot - locate PCI device from a given PCI slot
144 * @bus: number of PCI bus on which desired PCI device resides
145 * @devfn: encodes number of PCI slot in which the desired PCI
146 * device resides and the logical device number within that slot
147 * in case of multi-function devices.
148 *
149 * Given a PCI bus and slot/function number, the desired PCI device
150 * is located in system global list of PCI devices. If the device
151 * is found, a pointer to its data structure is returned. If no
152 * device is found, %NULL is returned. The returned device has its
153 * reference count bumped by one.
154 */
155
156struct pci_dev * pci_get_bus_and_slot(unsigned int bus, unsigned int devfn)
157{
158 struct pci_dev *dev = NULL;
159
160 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
161 if (dev->bus->number == bus && dev->devfn == devfn)
162 return dev;
163 }
164 return NULL;
165}
166
167/**
143 * pci_find_subsys - begin or continue searching for a PCI device by vendor/subvendor/device/subdevice id 168 * pci_find_subsys - begin or continue searching for a PCI device by vendor/subvendor/device/subdevice id
144 * @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids 169 * @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids
145 * @device: PCI device id to match, or %PCI_ANY_ID to match all device ids 170 * @device: PCI device id to match, or %PCI_ANY_ID to match all device ids
@@ -274,6 +299,45 @@ pci_get_device(unsigned int vendor, unsigned int device, struct pci_dev *from)
274 return pci_get_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from); 299 return pci_get_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from);
275} 300}
276 301
302/**
303 * pci_get_device_reverse - begin or continue searching for a PCI device by vendor/device id
304 * @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids
305 * @device: PCI device id to match, or %PCI_ANY_ID to match all device ids
306 * @from: Previous PCI device found in search, or %NULL for new search.
307 *
308 * Iterates through the list of known PCI devices in the reverse order of
309 * pci_get_device.
310 * If a PCI device is found with a matching @vendor and @device, the reference
311 * count to the device is incremented and a pointer to its device structure
312 * is returned Otherwise, %NULL is returned. A new search is initiated by
313 * passing %NULL as the @from argument. Otherwise if @from is not %NULL,
314 * searches continue from next device on the global list. The reference
315 * count for @from is always decremented if it is not %NULL.
316 */
317struct pci_dev *
318pci_get_device_reverse(unsigned int vendor, unsigned int device, struct pci_dev *from)
319{
320 struct list_head *n;
321 struct pci_dev *dev;
322
323 WARN_ON(in_interrupt());
324 down_read(&pci_bus_sem);
325 n = from ? from->global_list.prev : pci_devices.prev;
326
327 while (n && (n != &pci_devices)) {
328 dev = pci_dev_g(n);
329 if ((vendor == PCI_ANY_ID || dev->vendor == vendor) &&
330 (device == PCI_ANY_ID || dev->device == device))
331 goto exit;
332 n = n->prev;
333 }
334 dev = NULL;
335exit:
336 dev = pci_dev_get(dev);
337 up_read(&pci_bus_sem);
338 pci_dev_put(from);
339 return dev;
340}
277 341
278/** 342/**
279 * pci_find_device_reverse - begin or continue searching for a PCI device by vendor/device id 343 * pci_find_device_reverse - begin or continue searching for a PCI device by vendor/device id
@@ -382,12 +446,16 @@ exit:
382} 446}
383EXPORT_SYMBOL(pci_dev_present); 447EXPORT_SYMBOL(pci_dev_present);
384 448
385EXPORT_SYMBOL(pci_find_bus);
386EXPORT_SYMBOL(pci_find_next_bus);
387EXPORT_SYMBOL(pci_find_device); 449EXPORT_SYMBOL(pci_find_device);
388EXPORT_SYMBOL(pci_find_device_reverse); 450EXPORT_SYMBOL(pci_find_device_reverse);
389EXPORT_SYMBOL(pci_find_slot); 451EXPORT_SYMBOL(pci_find_slot);
452/* For boot time work */
453EXPORT_SYMBOL(pci_find_bus);
454EXPORT_SYMBOL(pci_find_next_bus);
455/* For everyone */
390EXPORT_SYMBOL(pci_get_device); 456EXPORT_SYMBOL(pci_get_device);
457EXPORT_SYMBOL(pci_get_device_reverse);
391EXPORT_SYMBOL(pci_get_subsys); 458EXPORT_SYMBOL(pci_get_subsys);
392EXPORT_SYMBOL(pci_get_slot); 459EXPORT_SYMBOL(pci_get_slot);
460EXPORT_SYMBOL(pci_get_bus_and_slot);
393EXPORT_SYMBOL(pci_get_class); 461EXPORT_SYMBOL(pci_get_class);
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index dc79b0a0059f..379048fdf05d 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -776,21 +776,32 @@ static void pnpacpi_encode_dma(struct acpi_resource *resource,
776 struct resource *p) 776 struct resource *p)
777{ 777{
778 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ 778 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
779 if (p->flags & IORESOURCE_DMA_COMPATIBLE) 779 switch (p->flags & IORESOURCE_DMA_SPEED_MASK) {
780 resource->data.dma.type = ACPI_COMPATIBILITY; 780 case IORESOURCE_DMA_TYPEA:
781 else if (p->flags & IORESOURCE_DMA_TYPEA) 781 resource->data.dma.type = ACPI_TYPE_A;
782 resource->data.dma.type = ACPI_TYPE_A; 782 break;
783 else if (p->flags & IORESOURCE_DMA_TYPEB) 783 case IORESOURCE_DMA_TYPEB:
784 resource->data.dma.type = ACPI_TYPE_B; 784 resource->data.dma.type = ACPI_TYPE_B;
785 else if (p->flags & IORESOURCE_DMA_TYPEF) 785 break;
786 resource->data.dma.type = ACPI_TYPE_F; 786 case IORESOURCE_DMA_TYPEF:
787 if (p->flags & IORESOURCE_DMA_8BIT) 787 resource->data.dma.type = ACPI_TYPE_F;
788 resource->data.dma.transfer = ACPI_TRANSFER_8; 788 break;
789 else if (p->flags & IORESOURCE_DMA_8AND16BIT) 789 default:
790 resource->data.dma.transfer = ACPI_TRANSFER_8_16; 790 resource->data.dma.type = ACPI_COMPATIBILITY;
791 else if (p->flags & IORESOURCE_DMA_16BIT) 791 }
792 resource->data.dma.transfer = ACPI_TRANSFER_16; 792
793 resource->data.dma.bus_master = p->flags & IORESOURCE_DMA_MASTER; 793 switch (p->flags & IORESOURCE_DMA_TYPE_MASK) {
794 case IORESOURCE_DMA_8BIT:
795 resource->data.dma.transfer = ACPI_TRANSFER_8;
796 break;
797 case IORESOURCE_DMA_8AND16BIT:
798 resource->data.dma.transfer = ACPI_TRANSFER_8_16;
799 break;
800 default:
801 resource->data.dma.transfer = ACPI_TRANSFER_16;
802 }
803
804 resource->data.dma.bus_master = !!(p->flags & IORESOURCE_DMA_MASTER);
794 resource->data.dma.channel_count = 1; 805 resource->data.dma.channel_count = 1;
795 resource->data.dma.channels[0] = p->start; 806 resource->data.dma.channels[0] = p->start;
796} 807}
diff --git a/drivers/rtc/rtc-max6902.c b/drivers/rtc/rtc-max6902.c
index 0b20dfacbf59..d94170728075 100644
--- a/drivers/rtc/rtc-max6902.c
+++ b/drivers/rtc/rtc-max6902.c
@@ -136,7 +136,7 @@ static int max6902_get_datetime(struct device *dev, struct rtc_time *dt)
136 dt->tm_min = BCD2BIN(chip->buf[2]); 136 dt->tm_min = BCD2BIN(chip->buf[2]);
137 dt->tm_hour = BCD2BIN(chip->buf[3]); 137 dt->tm_hour = BCD2BIN(chip->buf[3]);
138 dt->tm_mday = BCD2BIN(chip->buf[4]); 138 dt->tm_mday = BCD2BIN(chip->buf[4]);
139 dt->tm_mon = BCD2BIN(chip->buf[5] - 1); 139 dt->tm_mon = BCD2BIN(chip->buf[5]) - 1;
140 dt->tm_wday = BCD2BIN(chip->buf[6]); 140 dt->tm_wday = BCD2BIN(chip->buf[6]);
141 dt->tm_year = BCD2BIN(chip->buf[7]); 141 dt->tm_year = BCD2BIN(chip->buf[7]);
142 142
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c
index 09b714f1cdc3..3b58d3d5d38a 100644
--- a/drivers/rtc/rtc-v3020.c
+++ b/drivers/rtc/rtc-v3020.c
@@ -195,9 +195,9 @@ static int rtc_probe(struct platform_device *pdev)
195 * are all disabled */ 195 * are all disabled */
196 v3020_set_reg(chip, V3020_STATUS_0, 0x0); 196 v3020_set_reg(chip, V3020_STATUS_0, 0x0);
197 197
198 dev_info(&pdev->dev, "Chip available at physical address 0x%p," 198 dev_info(&pdev->dev, "Chip available at physical address 0x%llx,"
199 "data connected to D%d\n", 199 "data connected to D%d\n",
200 (void*)pdev->resource[0].start, 200 (unsigned long long)pdev->resource[0].start,
201 chip->leftshift); 201 chip->leftshift);
202 202
203 platform_set_drvdata(pdev, chip); 203 platform_set_drvdata(pdev, chip);
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index d0647d116eaa..79ffef6bfaf8 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -203,6 +203,7 @@ dasd_state_basic_to_known(struct dasd_device * device)
203 rc = dasd_flush_ccw_queue(device, 1); 203 rc = dasd_flush_ccw_queue(device, 1);
204 if (rc) 204 if (rc)
205 return rc; 205 return rc;
206 dasd_clear_timer(device);
206 207
207 DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device); 208 DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device);
208 if (device->debug_area != NULL) { 209 if (device->debug_area != NULL) {
diff --git a/drivers/s390/char/monwriter.c b/drivers/s390/char/monwriter.c
index abd02ed501cb..b9b0fc3f812b 100644
--- a/drivers/s390/char/monwriter.c
+++ b/drivers/s390/char/monwriter.c
@@ -73,12 +73,15 @@ static inline struct mon_buf *monwrite_find_hdr(struct mon_private *monpriv,
73 struct mon_buf *entry, *next; 73 struct mon_buf *entry, *next;
74 74
75 list_for_each_entry_safe(entry, next, &monpriv->list, list) 75 list_for_each_entry_safe(entry, next, &monpriv->list, list)
76 if (entry->hdr.applid == monhdr->applid && 76 if ((entry->hdr.mon_function == monhdr->mon_function ||
77 monhdr->mon_function == MONWRITE_STOP_INTERVAL) &&
78 entry->hdr.applid == monhdr->applid &&
77 entry->hdr.record_num == monhdr->record_num && 79 entry->hdr.record_num == monhdr->record_num &&
78 entry->hdr.version == monhdr->version && 80 entry->hdr.version == monhdr->version &&
79 entry->hdr.release == monhdr->release && 81 entry->hdr.release == monhdr->release &&
80 entry->hdr.mod_level == monhdr->mod_level) 82 entry->hdr.mod_level == monhdr->mod_level)
81 return entry; 83 return entry;
84
82 return NULL; 85 return NULL;
83} 86}
84 87
@@ -92,7 +95,9 @@ static int monwrite_new_hdr(struct mon_private *monpriv)
92 monhdr->mon_function > MONWRITE_START_CONFIG || 95 monhdr->mon_function > MONWRITE_START_CONFIG ||
93 monhdr->hdrlen != sizeof(struct monwrite_hdr)) 96 monhdr->hdrlen != sizeof(struct monwrite_hdr))
94 return -EINVAL; 97 return -EINVAL;
95 monbuf = monwrite_find_hdr(monpriv, monhdr); 98 monbuf = NULL;
99 if (monhdr->mon_function != MONWRITE_GEN_EVENT)
100 monbuf = monwrite_find_hdr(monpriv, monhdr);
96 if (monbuf) { 101 if (monbuf) {
97 if (monhdr->mon_function == MONWRITE_STOP_INTERVAL) { 102 if (monhdr->mon_function == MONWRITE_STOP_INTERVAL) {
98 monhdr->datalen = monbuf->hdr.datalen; 103 monhdr->datalen = monbuf->hdr.datalen;
@@ -104,7 +109,7 @@ static int monwrite_new_hdr(struct mon_private *monpriv)
104 kfree(monbuf); 109 kfree(monbuf);
105 monbuf = NULL; 110 monbuf = NULL;
106 } 111 }
107 } else { 112 } else if (monhdr->mon_function != MONWRITE_STOP_INTERVAL) {
108 if (mon_buf_count >= mon_max_bufs) 113 if (mon_buf_count >= mon_max_bufs)
109 return -ENOSPC; 114 return -ENOSPC;
110 monbuf = kzalloc(sizeof(struct mon_buf), GFP_KERNEL); 115 monbuf = kzalloc(sizeof(struct mon_buf), GFP_KERNEL);
@@ -118,7 +123,8 @@ static int monwrite_new_hdr(struct mon_private *monpriv)
118 } 123 }
119 monbuf->hdr = *monhdr; 124 monbuf->hdr = *monhdr;
120 list_add_tail(&monbuf->list, &monpriv->list); 125 list_add_tail(&monbuf->list, &monpriv->list);
121 mon_buf_count++; 126 if (monhdr->mon_function != MONWRITE_GEN_EVENT)
127 mon_buf_count++;
122 } 128 }
123 monpriv->current_buf = monbuf; 129 monpriv->current_buf = monbuf;
124 return 0; 130 return 0;
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index fcaf28d7b4eb..de3d0857db9f 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -578,9 +578,13 @@ ccw_device_verify_done(struct ccw_device *cdev, int err)
578 } 578 }
579 break; 579 break;
580 case -ETIME: 580 case -ETIME:
581 /* Reset oper notify indication after verify error. */
582 cdev->private->flags.donotify = 0;
581 ccw_device_done(cdev, DEV_STATE_BOXED); 583 ccw_device_done(cdev, DEV_STATE_BOXED);
582 break; 584 break;
583 default: 585 default:
586 /* Reset oper notify indication after verify error. */
587 cdev->private->flags.donotify = 0;
584 PREPARE_WORK(&cdev->private->kick_work, 588 PREPARE_WORK(&cdev->private->kick_work,
585 ccw_device_nopath_notify, cdev); 589 ccw_device_nopath_notify, cdev);
586 queue_work(ccw_device_notify_work, &cdev->private->kick_work); 590 queue_work(ccw_device_notify_work, &cdev->private->kick_work);
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 0648ce5bb684..476aa1da5cbc 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -3529,7 +3529,7 @@ do_QDIO(struct ccw_device *cdev,unsigned int callflags,
3529#ifdef CONFIG_QDIO_DEBUG 3529#ifdef CONFIG_QDIO_DEBUG
3530 char dbf_text[20]; 3530 char dbf_text[20];
3531 3531
3532 sprintf(dbf_text,"doQD%04x",cdev->private->sch_no); 3532 sprintf(dbf_text,"doQD%04x",cdev->private->schid.sch_no);
3533 QDIO_DBF_TEXT3(0,trace,dbf_text); 3533 QDIO_DBF_TEXT3(0,trace,dbf_text);
3534#endif /* CONFIG_QDIO_DEBUG */ 3534#endif /* CONFIG_QDIO_DEBUG */
3535 3535
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
index 0d3660c28f7d..a54e4140683a 100644
--- a/drivers/sbus/char/bbc_envctrl.c
+++ b/drivers/sbus/char/bbc_envctrl.c
@@ -5,8 +5,8 @@
5 */ 5 */
6 6
7#include <linux/kthread.h> 7#include <linux/kthread.h>
8#include <linux/syscalls.h>
9#include <linux/delay.h> 8#include <linux/delay.h>
9#include <linux/kmod.h>
10#include <asm/oplib.h> 10#include <asm/oplib.h>
11#include <asm/ebus.h> 11#include <asm/ebus.h>
12 12
@@ -195,7 +195,7 @@ static void do_envctrl_shutdown(struct bbc_cpu_temperature *tp)
195 printk(KERN_CRIT "kenvctrld: Shutting down the system now.\n"); 195 printk(KERN_CRIT "kenvctrld: Shutting down the system now.\n");
196 196
197 shutting_down = 1; 197 shutting_down = 1;
198 if (kernel_execve("/sbin/shutdown", argv, envp) < 0) 198 if (call_usermodehelper("/sbin/shutdown", argv, envp, 0) < 0)
199 printk(KERN_CRIT "envctrl: shutdown execution failed\n"); 199 printk(KERN_CRIT "envctrl: shutdown execution failed\n");
200} 200}
201 201
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c
index 6b6a855f3795..fff4660cdf96 100644
--- a/drivers/sbus/char/envctrl.c
+++ b/drivers/sbus/char/envctrl.c
@@ -25,7 +25,7 @@
25#include <linux/delay.h> 25#include <linux/delay.h>
26#include <linux/ioport.h> 26#include <linux/ioport.h>
27#include <linux/miscdevice.h> 27#include <linux/miscdevice.h>
28#include <linux/syscalls.h> 28#include <linux/kmod.h>
29 29
30#include <asm/ebus.h> 30#include <asm/ebus.h>
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
@@ -976,7 +976,7 @@ static void envctrl_do_shutdown(void)
976 976
977 inprog = 1; 977 inprog = 1;
978 printk(KERN_CRIT "kenvctrld: WARNING: Shutting down the system now.\n"); 978 printk(KERN_CRIT "kenvctrld: WARNING: Shutting down the system now.\n");
979 ret = kernel_execve("/sbin/shutdown", argv, envp); 979 ret = call_usermodehelper("/sbin/shutdown", argv, envp, 0);
980 if (ret < 0) { 980 if (ret < 0) {
981 printk(KERN_CRIT "kenvctrld: WARNING: system shutdown failed!\n"); 981 printk(KERN_CRIT "kenvctrld: WARNING: system shutdown failed!\n");
982 inprog = 0; /* unlikely to succeed, but we could try again */ 982 inprog = 0; /* unlikely to succeed, but we could try again */
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index 7c59bba98798..cdd033724786 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -3600,5 +3600,16 @@ static void __exit BusLogic_exit(void)
3600 3600
3601__setup("BusLogic=", BusLogic_Setup); 3601__setup("BusLogic=", BusLogic_Setup);
3602 3602
3603static struct pci_device_id BusLogic_pci_tbl[] __devinitdata = {
3604 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER,
3605 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
3606 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC,
3607 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
3608 { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT,
3609 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
3610 { }
3611};
3612MODULE_DEVICE_TABLE(pci, BusLogic_pci_tbl);
3613
3603module_init(BusLogic_init); 3614module_init(BusLogic_init);
3604module_exit(BusLogic_exit); 3615module_exit(BusLogic_exit);
diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c
index 811d8840707e..2dbb66d2f0a7 100644
--- a/drivers/scsi/eata_pio.c
+++ b/drivers/scsi/eata_pio.c
@@ -203,7 +203,7 @@ static irqreturn_t do_eata_pio_int_handler(int irq, void *dev_id)
203 irqreturn_t ret; 203 irqreturn_t ret;
204 204
205 spin_lock_irqsave(dev->host_lock, flags); 205 spin_lock_irqsave(dev->host_lock, flags);
206 ret = eata_pio_int_handler(irq, dev_id, regs); 206 ret = eata_pio_int_handler(irq, dev_id);
207 spin_unlock_irqrestore(dev->host_lock, flags); 207 spin_unlock_irqrestore(dev->host_lock, flags);
208 return ret; 208 return ret;
209} 209}
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index 72794a7b6dcc..65e6e7b7ba07 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -1736,6 +1736,15 @@ struct scsi_host_template fdomain_driver_template = {
1736}; 1736};
1737 1737
1738#ifndef PCMCIA 1738#ifndef PCMCIA
1739
1740static struct pci_device_id fdomain_pci_tbl[] __devinitdata = {
1741 { PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70,
1742 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
1743 { }
1744};
1745MODULE_DEVICE_TABLE(pci, fdomain_pci_tbl);
1746
1739#define driver_template fdomain_driver_template 1747#define driver_template fdomain_driver_template
1740#include "scsi_module.c" 1748#include "scsi_module.c"
1749
1741#endif 1750#endif
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index 911f2ff4a1f2..afed293dd7b9 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -142,8 +142,6 @@
142#define i91u_MAXQUEUE 2 142#define i91u_MAXQUEUE 2
143#define i91u_REVID "Initio INI-9X00U/UW SCSI device driver; Revision: 1.04a" 143#define i91u_REVID "Initio INI-9X00U/UW SCSI device driver; Revision: 1.04a"
144 144
145#define INI_VENDOR_ID 0x1101 /* Initio's PCI vendor ID */
146#define DMX_VENDOR_ID 0x134a /* Domex's PCI vendor ID */
147#define I950_DEVICE_ID 0x9500 /* Initio's inic-950 product ID */ 145#define I950_DEVICE_ID 0x9500 /* Initio's inic-950 product ID */
148#define I940_DEVICE_ID 0x9400 /* Initio's inic-940 product ID */ 146#define I940_DEVICE_ID 0x9400 /* Initio's inic-940 product ID */
149#define I935_DEVICE_ID 0x9401 /* Initio's inic-935 product ID */ 147#define I935_DEVICE_ID 0x9401 /* Initio's inic-935 product ID */
@@ -171,13 +169,16 @@ static int setup_debug = 0;
171 169
172static void i91uSCBPost(BYTE * pHcb, BYTE * pScb); 170static void i91uSCBPost(BYTE * pHcb, BYTE * pScb);
173 171
174static const PCI_ID i91u_pci_devices[] = { 172/* PCI Devices supported by this driver */
175 { INI_VENDOR_ID, I950_DEVICE_ID }, 173static struct pci_device_id i91u_pci_devices[] __devinitdata = {
176 { INI_VENDOR_ID, I940_DEVICE_ID }, 174 { PCI_VENDOR_ID_INIT, I950_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
177 { INI_VENDOR_ID, I935_DEVICE_ID }, 175 { PCI_VENDOR_ID_INIT, I940_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
178 { INI_VENDOR_ID, I920_DEVICE_ID }, 176 { PCI_VENDOR_ID_INIT, I935_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
179 { DMX_VENDOR_ID, I920_DEVICE_ID }, 177 { PCI_VENDOR_ID_INIT, I920_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
178 { PCI_VENDOR_ID_DOMEX, I920_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
179 { }
180}; 180};
181MODULE_DEVICE_TABLE(pci, i91u_pci_devices);
181 182
182#define DEBUG_INTERRUPT 0 183#define DEBUG_INTERRUPT 0
183#define DEBUG_QUEUE 0 184#define DEBUG_QUEUE 0
@@ -2771,7 +2772,7 @@ static int tul_NewReturnNumberOfAdapters(void)
2771 2772
2772 for (i = 0; i < ARRAY_SIZE(i91u_pci_devices); i++) 2773 for (i = 0; i < ARRAY_SIZE(i91u_pci_devices); i++)
2773 { 2774 {
2774 while ((pDev = pci_find_device(i91u_pci_devices[i].vendor_id, i91u_pci_devices[i].device_id, pDev)) != NULL) { 2775 while ((pDev = pci_find_device(i91u_pci_devices[i].vendor, i91u_pci_devices[i].device, pDev)) != NULL) {
2775 if (pci_enable_device(pDev)) 2776 if (pci_enable_device(pDev))
2776 continue; 2777 continue;
2777 pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue); 2778 pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue);
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index c0edb662d863..7bac86dda88f 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -884,7 +884,7 @@ megaraid_init_mbox(adapter_t *adapter)
884 884
885 if (((magic64 == HBA_SIGNATURE_64_BIT) && 885 if (((magic64 == HBA_SIGNATURE_64_BIT) &&
886 ((adapter->pdev->subsystem_device != 886 ((adapter->pdev->subsystem_device !=
887 PCI_SUBSYS_ID_MEGARAID_SATA_150_6) || 887 PCI_SUBSYS_ID_MEGARAID_SATA_150_6) &&
888 (adapter->pdev->subsystem_device != 888 (adapter->pdev->subsystem_device !=
889 PCI_SUBSYS_ID_MEGARAID_SATA_150_4))) || 889 PCI_SUBSYS_ID_MEGARAID_SATA_150_4))) ||
890 (adapter->pdev->vendor == PCI_VENDOR_ID_LSI_LOGIC && 890 (adapter->pdev->vendor == PCI_VENDOR_ID_LSI_LOGIC &&
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index ed58bb489889..9b827ceec501 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -461,7 +461,7 @@ static int qlogicpti_reset_hardware(struct Scsi_Host *host)
461 461
462#define PTI_RESET_LIMIT 400 462#define PTI_RESET_LIMIT 400
463 463
464static int __init qlogicpti_load_firmware(struct qlogicpti *qpti) 464static int __devinit qlogicpti_load_firmware(struct qlogicpti *qpti)
465{ 465{
466 struct Scsi_Host *host = qpti->qhost; 466 struct Scsi_Host *host = qpti->qhost;
467 unsigned short csum = 0; 467 unsigned short csum = 0;
diff --git a/drivers/scsi/qlogicpti_asm.c b/drivers/scsi/qlogicpti_asm.c
index 1545b30681b4..19aa84f46018 100644
--- a/drivers/scsi/qlogicpti_asm.c
+++ b/drivers/scsi/qlogicpti_asm.c
@@ -1,5 +1,5 @@
1/* Version 1.31.00 ISP1000 Initiator RISC firmware */ 1/* Version 1.31.00 ISP1000 Initiator RISC firmware */
2unsigned short sbus_risc_code01[] __initdata = { 2unsigned short sbus_risc_code01[] __devinitdata = {
3 0x0078, 0x1030, 0x0000, 0x2419, 0x0000, 0x12ff, 0x2043, 0x4f50, 3 0x0078, 0x1030, 0x0000, 0x2419, 0x0000, 0x12ff, 0x2043, 0x4f50,
4 0x5952, 0x4947, 0x4854, 0x2031, 0x3939, 0x312c, 0x3139, 0x3932, 4 0x5952, 0x4947, 0x4854, 0x2031, 0x3939, 0x312c, 0x3139, 0x3932,
5 0x2c31, 0x3939, 0x332c, 0x3139, 0x3934, 0x2051, 0x4c4f, 0x4749, 5 0x2c31, 0x3939, 0x332c, 0x3139, 0x3934, 0x2051, 0x4c4f, 0x4749,
@@ -1157,4 +1157,4 @@ unsigned short sbus_risc_code01[] __initdata = {
1157 0x003c, 0x0040, 0x3415, 0x2019, 0x2626, 0x7b22, 0x7b26, 0x007c, 1157 0x003c, 0x0040, 0x3415, 0x2019, 0x2626, 0x7b22, 0x7b26, 0x007c,
1158 0x92a7 1158 0x92a7
1159}; 1159};
1160unsigned short sbus_risc_code_length01 = 0x2419; 1160unsigned short __devinitdata sbus_risc_code_length01 = 0x2419;
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index b0d502622d94..0b71e7d18903 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -767,37 +767,37 @@ config SERIAL_CPM_SCC1
767 bool "Support for SCC1 serial port" 767 bool "Support for SCC1 serial port"
768 depends on SERIAL_CPM=y 768 depends on SERIAL_CPM=y
769 help 769 help
770 Select the is option to use SCC1 as a serial port 770 Select this option to use SCC1 as a serial port
771 771
772config SERIAL_CPM_SCC2 772config SERIAL_CPM_SCC2
773 bool "Support for SCC2 serial port" 773 bool "Support for SCC2 serial port"
774 depends on SERIAL_CPM=y 774 depends on SERIAL_CPM=y
775 help 775 help
776 Select the is option to use SCC2 as a serial port 776 Select this option to use SCC2 as a serial port
777 777
778config SERIAL_CPM_SCC3 778config SERIAL_CPM_SCC3
779 bool "Support for SCC3 serial port" 779 bool "Support for SCC3 serial port"
780 depends on SERIAL_CPM=y 780 depends on SERIAL_CPM=y
781 help 781 help
782 Select the is option to use SCC3 as a serial port 782 Select this option to use SCC3 as a serial port
783 783
784config SERIAL_CPM_SCC4 784config SERIAL_CPM_SCC4
785 bool "Support for SCC4 serial port" 785 bool "Support for SCC4 serial port"
786 depends on SERIAL_CPM=y 786 depends on SERIAL_CPM=y
787 help 787 help
788 Select the is option to use SCC4 as a serial port 788 Select this option to use SCC4 as a serial port
789 789
790config SERIAL_CPM_SMC1 790config SERIAL_CPM_SMC1
791 bool "Support for SMC1 serial port" 791 bool "Support for SMC1 serial port"
792 depends on SERIAL_CPM=y 792 depends on SERIAL_CPM=y
793 help 793 help
794 Select the is option to use SMC1 as a serial port 794 Select this option to use SMC1 as a serial port
795 795
796config SERIAL_CPM_SMC2 796config SERIAL_CPM_SMC2
797 bool "Support for SMC2 serial port" 797 bool "Support for SMC2 serial port"
798 depends on SERIAL_CPM=y 798 depends on SERIAL_CPM=y
799 help 799 help
800 Select the is option to use SMC2 as a serial port 800 Select this option to use SMC2 as a serial port
801 801
802config SERIAL_SGI_L1_CONSOLE 802config SERIAL_SGI_L1_CONSOLE
803 bool "SGI Altix L1 serial console support" 803 bool "SGI Altix L1 serial console support"
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index 98ce88d80207..ff4fa25f9fd1 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -2935,7 +2935,7 @@ static void __devexit ioc4_serial_exit(void)
2935 uart_unregister_driver(&ioc4_uart_rs422); 2935 uart_unregister_driver(&ioc4_uart_rs422);
2936} 2936}
2937 2937
2938module_init(ioc4_serial_init); 2938late_initcall(ioc4_serial_init); /* Call only after tty init is done */
2939module_exit(ioc4_serial_exit); 2939module_exit(ioc4_serial_exit);
2940 2940
2941MODULE_AUTHOR("Pat Gefre - Silicon Graphics Inc. (SGI) <pfg@sgi.com>"); 2941MODULE_AUTHOR("Pat Gefre - Silicon Graphics Inc. (SGI) <pfg@sgi.com>");
diff --git a/drivers/sn/Kconfig b/drivers/sn/Kconfig
index a34731625877..c66ba9ad833d 100644
--- a/drivers/sn/Kconfig
+++ b/drivers/sn/Kconfig
@@ -5,19 +5,6 @@
5menu "SN Devices" 5menu "SN Devices"
6 depends on SGI_SN 6 depends on SGI_SN
7 7
8config SGI_IOC4
9 tristate "SGI IOC4 Base IO support"
10 depends on MMTIMER
11 default m
12 ---help---
13 This option enables basic support for the SGI IOC4-based Base IO
14 controller card. This option does not enable any specific
15 functions on such a card, but provides necessary infrastructure
16 for other drivers to utilize.
17
18 If you have an SGI Altix with an IOC4-based
19 I/O controller say Y. Otherwise say N.
20
21config SGI_IOC3 8config SGI_IOC3
22 tristate "SGI IOC3 Base IO support" 9 tristate "SGI IOC3 Base IO support"
23 default m 10 default m
diff --git a/drivers/sn/Makefile b/drivers/sn/Makefile
index 2cda011597c0..693db8bb8d9c 100644
--- a/drivers/sn/Makefile
+++ b/drivers/sn/Makefile
@@ -3,5 +3,4 @@
3# 3#
4# 4#
5 5
6obj-$(CONFIG_SGI_IOC4) += ioc4.o
7obj-$(CONFIG_SGI_IOC3) += ioc3.o 6obj-$(CONFIG_SGI_IOC3) += ioc3.o
diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
index f6b2948ab288..1b601b6cf2a2 100644
--- a/drivers/telephony/ixj.c
+++ b/drivers/telephony/ixj.c
@@ -284,6 +284,14 @@ static int samplerate = 100;
284 284
285module_param(ixjdebug, int, 0); 285module_param(ixjdebug, int, 0);
286 286
287static struct pci_device_id ixj_pci_tbl[] __devinitdata = {
288 { PCI_VENDOR_ID_QUICKNET, PCI_DEVICE_ID_QUICKNET_XJ,
289 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
290 { }
291};
292
293MODULE_DEVICE_TABLE(pci, ixj_pci_tbl);
294
287/************************************************************************ 295/************************************************************************
288* 296*
289* ixjdebug meanings are now bit mapped instead of level based 297* ixjdebug meanings are now bit mapped instead of level based
@@ -7683,7 +7691,8 @@ static int __init ixj_probe_pci(int *cnt)
7683 IXJ *j = NULL; 7691 IXJ *j = NULL;
7684 7692
7685 for (i = 0; i < IXJMAX - *cnt; i++) { 7693 for (i = 0; i < IXJMAX - *cnt; i++) {
7686 pci = pci_find_device(0x15E2, 0x0500, pci); 7694 pci = pci_find_device(PCI_VENDOR_ID_QUICKNET,
7695 PCI_DEVICE_ID_QUICKNET_XJ, pci);
7687 if (!pci) 7696 if (!pci)
7688 break; 7697 break;
7689 7698
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 97d57cfc343b..825bf884537a 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -33,7 +33,6 @@ obj-$(CONFIG_USB_KBTAB) += input/
33obj-$(CONFIG_USB_MOUSE) += input/ 33obj-$(CONFIG_USB_MOUSE) += input/
34obj-$(CONFIG_USB_MTOUCH) += input/ 34obj-$(CONFIG_USB_MTOUCH) += input/
35obj-$(CONFIG_USB_POWERMATE) += input/ 35obj-$(CONFIG_USB_POWERMATE) += input/
36obj-$(CONFIG_USB_TRANCEVIBRATOR)+= input/
37obj-$(CONFIG_USB_WACOM) += input/ 36obj-$(CONFIG_USB_WACOM) += input/
38obj-$(CONFIG_USB_XPAD) += input/ 37obj-$(CONFIG_USB_XPAD) += input/
39 38
@@ -66,6 +65,7 @@ obj-$(CONFIG_USB_PHIDGETSERVO) += misc/
66obj-$(CONFIG_USB_RIO500) += misc/ 65obj-$(CONFIG_USB_RIO500) += misc/
67obj-$(CONFIG_USB_SISUSBVGA) += misc/ 66obj-$(CONFIG_USB_SISUSBVGA) += misc/
68obj-$(CONFIG_USB_TEST) += misc/ 67obj-$(CONFIG_USB_TEST) += misc/
68obj-$(CONFIG_USB_TRANCEVIBRATOR)+= misc/
69obj-$(CONFIG_USB_USS720) += misc/ 69obj-$(CONFIG_USB_USS720) += misc/
70 70
71obj-$(CONFIG_USB_ATM) += atm/ 71obj-$(CONFIG_USB_ATM) += atm/
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 3892a9e9aee3..e6565633ba0f 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -793,6 +793,9 @@ static const struct usb_device_id cxacru_usb_ids[] = {
793 { /* V = Conexant P = ADSL modem */ 793 { /* V = Conexant P = ADSL modem */
794 USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00 794 USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00
795 }, 795 },
796 { /* V = Conexant P = ADSL modem (ZTE ZXDSL 852) */
797 USB_DEVICE(0x0572, 0xcb07), .driver_info = (unsigned long) &cxacru_cb00
798 },
796 { /* V = Olitec P = ADSL modem version 2 */ 799 { /* V = Olitec P = ADSL modem version 2 */
797 USB_DEVICE(0x08e3, 0x0100), .driver_info = (unsigned long) &cxacru_cafe 800 USB_DEVICE(0x08e3, 0x0100), .driver_info = (unsigned long) &cxacru_cafe
798 }, 801 },
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index 7c7b507af29d..c870c804470f 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -55,7 +55,6 @@ static const char speedtch_driver_name[] = "speedtch";
55#define OFFSET_d 9 /* size 4 */ 55#define OFFSET_d 9 /* size 4 */
56#define OFFSET_e 13 /* size 1 */ 56#define OFFSET_e 13 /* size 1 */
57#define OFFSET_f 14 /* size 1 */ 57#define OFFSET_f 14 /* size 1 */
58#define TOTAL 15
59 58
60#define SIZE_7 1 59#define SIZE_7 1
61#define SIZE_b 8 60#define SIZE_b 8
@@ -79,6 +78,18 @@ static int dl_512_first = DEFAULT_DL_512_FIRST;
79static int enable_isoc = DEFAULT_ENABLE_ISOC; 78static int enable_isoc = DEFAULT_ENABLE_ISOC;
80static int sw_buffering = DEFAULT_SW_BUFFERING; 79static int sw_buffering = DEFAULT_SW_BUFFERING;
81 80
81#define DEFAULT_B_MAX_DSL 8128
82#define DEFAULT_MODEM_MODE 11
83#define MODEM_OPTION_LENGTH 16
84static const unsigned char DEFAULT_MODEM_OPTION[MODEM_OPTION_LENGTH] = {
85 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
86};
87
88static unsigned int BMaxDSL = DEFAULT_B_MAX_DSL;
89static unsigned char ModemMode = DEFAULT_MODEM_MODE;
90static unsigned char ModemOption[MODEM_OPTION_LENGTH];
91static int num_ModemOption;
92
82module_param(altsetting, uint, S_IRUGO | S_IWUSR); 93module_param(altsetting, uint, S_IRUGO | S_IWUSR);
83MODULE_PARM_DESC(altsetting, 94MODULE_PARM_DESC(altsetting,
84 "Alternative setting for data interface (bulk_default: " 95 "Alternative setting for data interface (bulk_default: "
@@ -100,6 +111,17 @@ MODULE_PARM_DESC(sw_buffering,
100 "Enable software buffering (default: " 111 "Enable software buffering (default: "
101 __MODULE_STRING(DEFAULT_SW_BUFFERING) ")"); 112 __MODULE_STRING(DEFAULT_SW_BUFFERING) ")");
102 113
114module_param(BMaxDSL, uint, S_IRUGO | S_IWUSR);
115MODULE_PARM_DESC(BMaxDSL,
116 "default: " __MODULE_STRING(DEFAULT_B_MAX_DSL));
117
118module_param(ModemMode, byte, S_IRUGO | S_IWUSR);
119MODULE_PARM_DESC(ModemMode,
120 "default: " __MODULE_STRING(DEFAULT_MODEM_MODE));
121
122module_param_array(ModemOption, byte, &num_ModemOption, S_IRUGO);
123MODULE_PARM_DESC(ModemOption, "default: 0x10,0x00,0x00,0x00,0x20");
124
103#define INTERFACE_DATA 1 125#define INTERFACE_DATA 1
104#define ENDPOINT_INT 0x81 126#define ENDPOINT_INT 0x81
105#define ENDPOINT_BULK_DATA 0x07 127#define ENDPOINT_BULK_DATA 0x07
@@ -108,10 +130,17 @@ MODULE_PARM_DESC(sw_buffering,
108 130
109#define hex2int(c) ( (c >= '0') && (c <= '9') ? (c - '0') : ((c & 0xf) + 9) ) 131#define hex2int(c) ( (c >= '0') && (c <= '9') ? (c - '0') : ((c & 0xf) + 9) )
110 132
133struct speedtch_params {
134 unsigned int altsetting;
135 unsigned int BMaxDSL;
136 unsigned char ModemMode;
137 unsigned char ModemOption[MODEM_OPTION_LENGTH];
138};
139
111struct speedtch_instance_data { 140struct speedtch_instance_data {
112 struct usbatm_data *usbatm; 141 struct usbatm_data *usbatm;
113 142
114 unsigned int altsetting; 143 struct speedtch_params params; /* set in probe, constant afterwards */
115 144
116 struct work_struct status_checker; 145 struct work_struct status_checker;
117 146
@@ -123,7 +152,7 @@ struct speedtch_instance_data {
123 struct urb *int_urb; 152 struct urb *int_urb;
124 unsigned char int_data[16]; 153 unsigned char int_data[16];
125 154
126 unsigned char scratch_buffer[TOTAL]; 155 unsigned char scratch_buffer[16];
127}; 156};
128 157
129/*************** 158/***************
@@ -186,6 +215,34 @@ static void speedtch_test_sequence(struct speedtch_instance_data *instance)
186 0x01, 0x40, 0x04, 0x00, buf, 3, CTRL_TIMEOUT); 215 0x01, 0x40, 0x04, 0x00, buf, 3, CTRL_TIMEOUT);
187 if (ret < 0) 216 if (ret < 0)
188 usb_warn(usbatm, "%s failed on URB150: %d\n", __func__, ret); 217 usb_warn(usbatm, "%s failed on URB150: %d\n", __func__, ret);
218
219 /* Extra initialisation in recent drivers - gives higher speeds */
220
221 /* URBext1 */
222 buf[0] = instance->params.ModemMode;
223 ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
224 0x01, 0x40, 0x11, 0x00, buf, 1, CTRL_TIMEOUT);
225 if (ret < 0)
226 usb_warn(usbatm, "%s failed on URBext1: %d\n", __func__, ret);
227
228 /* URBext2 */
229 /* This seems to be the one which actually triggers the higher sync
230 rate -- it does require the new firmware too, although it works OK
231 with older firmware */
232 ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
233 0x01, 0x40, 0x14, 0x00,
234 instance->params.ModemOption,
235 MODEM_OPTION_LENGTH, CTRL_TIMEOUT);
236 if (ret < 0)
237 usb_warn(usbatm, "%s failed on URBext2: %d\n", __func__, ret);
238
239 /* URBext3 */
240 buf[0] = instance->params.BMaxDSL & 0xff;
241 buf[1] = instance->params.BMaxDSL >> 8;
242 ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0),
243 0x01, 0x40, 0x12, 0x00, buf, 2, CTRL_TIMEOUT);
244 if (ret < 0)
245 usb_warn(usbatm, "%s failed on URBext3: %d\n", __func__, ret);
189} 246}
190 247
191static int speedtch_upload_firmware(struct speedtch_instance_data *instance, 248static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
@@ -285,8 +342,8 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
285 because we're in our own kernel thread anyway. */ 342 because we're in our own kernel thread anyway. */
286 msleep_interruptible(1000); 343 msleep_interruptible(1000);
287 344
288 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->altsetting)) < 0) { 345 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) {
289 usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->altsetting, ret); 346 usb_err(usbatm, "%s: setting interface to %d failed (%d)!\n", __func__, instance->params.altsetting, ret);
290 goto out_free; 347 goto out_free;
291 } 348 }
292 349
@@ -372,7 +429,7 @@ static int speedtch_read_status(struct speedtch_instance_data *instance)
372 unsigned char *buf = instance->scratch_buffer; 429 unsigned char *buf = instance->scratch_buffer;
373 int ret; 430 int ret;
374 431
375 memset(buf, 0, TOTAL); 432 memset(buf, 0, 16);
376 433
377 ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), 434 ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0),
378 0x12, 0xc0, 0x07, 0x00, buf + OFFSET_7, SIZE_7, 435 0x12, 0xc0, 0x07, 0x00, buf + OFFSET_7, SIZE_7,
@@ -746,17 +803,21 @@ static int speedtch_bind(struct usbatm_data *usbatm,
746 803
747 instance->usbatm = usbatm; 804 instance->usbatm = usbatm;
748 805
749 /* altsetting and enable_isoc may change at any moment, so take a snapshot */ 806 /* module parameters may change at any moment, so take a snapshot */
750 instance->altsetting = altsetting; 807 instance->params.altsetting = altsetting;
808 instance->params.BMaxDSL = BMaxDSL;
809 instance->params.ModemMode = ModemMode;
810 memcpy(instance->params.ModemOption, DEFAULT_MODEM_OPTION, MODEM_OPTION_LENGTH);
811 memcpy(instance->params.ModemOption, ModemOption, num_ModemOption);
751 use_isoc = enable_isoc; 812 use_isoc = enable_isoc;
752 813
753 if (instance->altsetting) 814 if (instance->params.altsetting)
754 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->altsetting)) < 0) { 815 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, instance->params.altsetting)) < 0) {
755 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->altsetting, ret); 816 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, instance->params.altsetting, ret);
756 instance->altsetting = 0; /* fall back to default */ 817 instance->params.altsetting = 0; /* fall back to default */
757 } 818 }
758 819
759 if (!instance->altsetting && use_isoc) 820 if (!instance->params.altsetting && use_isoc)
760 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_ISOC_ALTSETTING)) < 0) { 821 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_ISOC_ALTSETTING)) < 0) {
761 usb_dbg(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_ISOC_ALTSETTING, ret); 822 usb_dbg(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_ISOC_ALTSETTING, ret);
762 use_isoc = 0; /* fall back to bulk */ 823 use_isoc = 0; /* fall back to bulk */
@@ -783,14 +844,14 @@ static int speedtch_bind(struct usbatm_data *usbatm,
783 usb_info(usbatm, "isochronous transfer not supported - using bulk\n"); 844 usb_info(usbatm, "isochronous transfer not supported - using bulk\n");
784 } 845 }
785 846
786 if (!use_isoc && !instance->altsetting) 847 if (!use_isoc && !instance->params.altsetting)
787 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_BULK_ALTSETTING)) < 0) { 848 if ((ret = usb_set_interface(usb_dev, INTERFACE_DATA, DEFAULT_BULK_ALTSETTING)) < 0) {
788 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_BULK_ALTSETTING, ret); 849 usb_err(usbatm, "%s: setting interface to %2d failed (%d)!\n", __func__, DEFAULT_BULK_ALTSETTING, ret);
789 goto fail_free; 850 goto fail_free;
790 } 851 }
791 852
792 if (!instance->altsetting) 853 if (!instance->params.altsetting)
793 instance->altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING; 854 instance->params.altsetting = use_isoc ? DEFAULT_ISOC_ALTSETTING : DEFAULT_BULK_ALTSETTING;
794 855
795 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0); 856 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0);
796 857
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index f5434b1cbb1e..f6b9f7e1f716 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -68,7 +68,7 @@
68 68
69#include "usbatm.h" 69#include "usbatm.h"
70 70
71#define EAGLEUSBVERSION "ueagle 1.3" 71#define EAGLEUSBVERSION "ueagle 1.4"
72 72
73 73
74/* 74/*
@@ -80,14 +80,14 @@
80 dev_dbg(&(usb_dev)->dev, \ 80 dev_dbg(&(usb_dev)->dev, \
81 "[ueagle-atm dbg] %s: " format, \ 81 "[ueagle-atm dbg] %s: " format, \
82 __FUNCTION__, ##args); \ 82 __FUNCTION__, ##args); \
83 } while (0) 83 } while (0)
84 84
85#define uea_vdbg(usb_dev, format, args...) \ 85#define uea_vdbg(usb_dev, format, args...) \
86 do { \ 86 do { \
87 if (debug >= 2) \ 87 if (debug >= 2) \
88 dev_dbg(&(usb_dev)->dev, \ 88 dev_dbg(&(usb_dev)->dev, \
89 "[ueagle-atm vdbg] " format, ##args); \ 89 "[ueagle-atm vdbg] " format, ##args); \
90 } while (0) 90 } while (0)
91 91
92#define uea_enters(usb_dev) \ 92#define uea_enters(usb_dev) \
93 uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__) 93 uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__)
@@ -218,8 +218,8 @@ enum {
218#define UEA_CHIP_VERSION(x) \ 218#define UEA_CHIP_VERSION(x) \
219 ((x)->driver_info & 0xf) 219 ((x)->driver_info & 0xf)
220 220
221#define IS_ISDN(sc) \ 221#define IS_ISDN(usb_dev) \
222 (le16_to_cpu(sc->usb_dev->descriptor.bcdDevice) & 0x80) 222 (le16_to_cpu((usb_dev)->descriptor.bcdDevice) & 0x80)
223 223
224#define INS_TO_USBDEV(ins) ins->usb_dev 224#define INS_TO_USBDEV(ins) ins->usb_dev
225 225
@@ -625,12 +625,12 @@ static int request_dsp(struct uea_softc *sc)
625 char *dsp_name; 625 char *dsp_name;
626 626
627 if (UEA_CHIP_VERSION(sc) == ADI930) { 627 if (UEA_CHIP_VERSION(sc) == ADI930) {
628 if (IS_ISDN(sc)) 628 if (IS_ISDN(sc->usb_dev))
629 dsp_name = FW_DIR "DSP9i.bin"; 629 dsp_name = FW_DIR "DSP9i.bin";
630 else 630 else
631 dsp_name = FW_DIR "DSP9p.bin"; 631 dsp_name = FW_DIR "DSP9p.bin";
632 } else { 632 } else {
633 if (IS_ISDN(sc)) 633 if (IS_ISDN(sc->usb_dev))
634 dsp_name = FW_DIR "DSPei.bin"; 634 dsp_name = FW_DIR "DSPei.bin";
635 else 635 else
636 dsp_name = FW_DIR "DSPep.bin"; 636 dsp_name = FW_DIR "DSPep.bin";
@@ -744,7 +744,7 @@ static inline void wake_up_cmv_ack(struct uea_softc *sc)
744 744
745static inline int wait_cmv_ack(struct uea_softc *sc) 745static inline int wait_cmv_ack(struct uea_softc *sc)
746{ 746{
747 int ret = wait_event_timeout(sc->cmv_ack_wait, 747 int ret = wait_event_interruptible_timeout(sc->cmv_ack_wait,
748 sc->cmv_ack, ACK_TIMEOUT); 748 sc->cmv_ack, ACK_TIMEOUT);
749 sc->cmv_ack = 0; 749 sc->cmv_ack = 0;
750 750
@@ -885,7 +885,8 @@ static int uea_stat(struct uea_softc *sc)
885 break; 885 break;
886 886
887 case 3: /* fail ... */ 887 case 3: /* fail ... */
888 uea_info(INS_TO_USBDEV(sc), "modem synchronization failed\n"); 888 uea_info(INS_TO_USBDEV(sc), "modem synchronization failed"
889 " (may be try other cmv/dsp)\n");
889 return -EAGAIN; 890 return -EAGAIN;
890 891
891 case 4 ... 6: /* test state */ 892 case 4 ... 6: /* test state */
@@ -913,12 +914,6 @@ static int uea_stat(struct uea_softc *sc)
913 release_firmware(sc->dsp_firm); 914 release_firmware(sc->dsp_firm);
914 sc->dsp_firm = NULL; 915 sc->dsp_firm = NULL;
915 } 916 }
916
917 ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid);
918 if (ret < 0)
919 return ret;
920 uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
921 sc->stats.phy.firmid);
922 } 917 }
923 918
924 /* always update it as atm layer could not be init when we switch to 919 /* always update it as atm layer could not be init when we switch to
@@ -1033,9 +1028,9 @@ static int request_cmvs(struct uea_softc *sc,
1033 1028
1034 if (cmv_file[sc->modem_index] == NULL) { 1029 if (cmv_file[sc->modem_index] == NULL) {
1035 if (UEA_CHIP_VERSION(sc) == ADI930) 1030 if (UEA_CHIP_VERSION(sc) == ADI930)
1036 file = (IS_ISDN(sc)) ? "CMV9i.bin" : "CMV9p.bin"; 1031 file = (IS_ISDN(sc->usb_dev)) ? "CMV9i.bin" : "CMV9p.bin";
1037 else 1032 else
1038 file = (IS_ISDN(sc)) ? "CMVei.bin" : "CMVep.bin"; 1033 file = (IS_ISDN(sc->usb_dev)) ? "CMVei.bin" : "CMVep.bin";
1039 } else 1034 } else
1040 file = cmv_file[sc->modem_index]; 1035 file = cmv_file[sc->modem_index];
1041 1036
@@ -1131,6 +1126,13 @@ static int uea_start_reset(struct uea_softc *sc)
1131 if (ret < 0) 1126 if (ret < 0)
1132 return ret; 1127 return ret;
1133 1128
1129 /* Dump firmware version */
1130 ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid);
1131 if (ret < 0)
1132 return ret;
1133 uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
1134 sc->stats.phy.firmid);
1135
1134 /* get options */ 1136 /* get options */
1135 ret = len = request_cmvs(sc, &cmvs, &cmvs_fw); 1137 ret = len = request_cmvs(sc, &cmvs, &cmvs_fw);
1136 if (ret < 0) 1138 if (ret < 0)
@@ -1147,6 +1149,8 @@ static int uea_start_reset(struct uea_softc *sc)
1147 /* Enter in R-ACT-REQ */ 1149 /* Enter in R-ACT-REQ */
1148 ret = uea_write_cmv(sc, SA_CNTL, 0, 2); 1150 ret = uea_write_cmv(sc, SA_CNTL, 0, 2);
1149 uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n"); 1151 uea_vdbg(INS_TO_USBDEV(sc), "Entering in R-ACT-REQ state\n");
1152 uea_info(INS_TO_USBDEV(sc), "Modem started, "
1153 "waiting synchronization\n");
1150out: 1154out:
1151 release_firmware(cmvs_fw); 1155 release_firmware(cmvs_fw);
1152 sc->reset = 0; 1156 sc->reset = 0;
@@ -1172,7 +1176,10 @@ static int uea_kthread(void *data)
1172 if (!ret) 1176 if (!ret)
1173 ret = uea_stat(sc); 1177 ret = uea_stat(sc);
1174 if (ret != -EAGAIN) 1178 if (ret != -EAGAIN)
1175 msleep(1000); 1179 msleep_interruptible(1000);
1180 if (try_to_freeze())
1181 uea_err(INS_TO_USBDEV(sc), "suspend/resume not supported, "
1182 "please unplug/replug your modem\n");
1176 } 1183 }
1177 uea_leaves(INS_TO_USBDEV(sc)); 1184 uea_leaves(INS_TO_USBDEV(sc));
1178 return ret; 1185 return ret;
@@ -1566,6 +1573,7 @@ UEA_ATTR(uscorr, 0);
1566UEA_ATTR(dscorr, 0); 1573UEA_ATTR(dscorr, 0);
1567UEA_ATTR(usunc, 0); 1574UEA_ATTR(usunc, 0);
1568UEA_ATTR(dsunc, 0); 1575UEA_ATTR(dsunc, 0);
1576UEA_ATTR(firmid, 0);
1569 1577
1570/* Retrieve the device End System Identifier (MAC) */ 1578/* Retrieve the device End System Identifier (MAC) */
1571 1579
@@ -1597,7 +1605,7 @@ static int uea_heavy(struct usbatm_data *usbatm, struct usb_interface *intf)
1597{ 1605{
1598 struct uea_softc *sc = usbatm->driver_data; 1606 struct uea_softc *sc = usbatm->driver_data;
1599 1607
1600 wait_event(sc->sync_q, IS_OPERATIONAL(sc)); 1608 wait_event_interruptible(sc->sync_q, IS_OPERATIONAL(sc));
1601 1609
1602 return 0; 1610 return 0;
1603 1611
@@ -1639,16 +1647,13 @@ static struct attribute *attrs[] = {
1639 &dev_attr_stat_dscorr.attr, 1647 &dev_attr_stat_dscorr.attr,
1640 &dev_attr_stat_usunc.attr, 1648 &dev_attr_stat_usunc.attr,
1641 &dev_attr_stat_dsunc.attr, 1649 &dev_attr_stat_dsunc.attr,
1650 &dev_attr_stat_firmid.attr,
1651 NULL,
1642}; 1652};
1643static struct attribute_group attr_grp = { 1653static struct attribute_group attr_grp = {
1644 .attrs = attrs, 1654 .attrs = attrs,
1645}; 1655};
1646 1656
1647static int create_fs_entries(struct usb_interface *intf)
1648{
1649 return sysfs_create_group(&intf->dev.kobj, &attr_grp);
1650}
1651
1652static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, 1657static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1653 const struct usb_device_id *id) 1658 const struct usb_device_id *id)
1654{ 1659{
@@ -1708,31 +1713,25 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1708 } 1713 }
1709 } 1714 }
1710 1715
1716 ret = sysfs_create_group(&intf->dev.kobj, &attr_grp);
1717 if (ret < 0)
1718 goto error;
1719
1711 ret = uea_boot(sc); 1720 ret = uea_boot(sc);
1712 if (ret < 0) { 1721 if (ret < 0)
1713 kfree(sc); 1722 goto error;
1714 return ret;
1715 }
1716 1723
1717 ret = create_fs_entries(intf);
1718 if (ret) {
1719 uea_stop(sc);
1720 kfree(sc);
1721 return ret;
1722 }
1723 return 0; 1724 return 0;
1724} 1725error:
1725 1726 kfree(sc);
1726static void destroy_fs_entries(struct usb_interface *intf) 1727 return ret;
1727{
1728 sysfs_remove_group(&intf->dev.kobj, &attr_grp);
1729} 1728}
1730 1729
1731static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf) 1730static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
1732{ 1731{
1733 struct uea_softc *sc = usbatm->driver_data; 1732 struct uea_softc *sc = usbatm->driver_data;
1734 1733
1735 destroy_fs_entries(intf); 1734 sysfs_remove_group(&intf->dev.kobj, &attr_grp);
1736 uea_stop(sc); 1735 uea_stop(sc);
1737 kfree(sc); 1736 kfree(sc);
1738} 1737}
@@ -1753,10 +1752,10 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
1753 struct usb_device *usb = interface_to_usbdev(intf); 1752 struct usb_device *usb = interface_to_usbdev(intf);
1754 1753
1755 uea_enters(usb); 1754 uea_enters(usb);
1756 uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s\n", 1755 uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s %s\n",
1757 le16_to_cpu(usb->descriptor.idVendor), 1756 le16_to_cpu(usb->descriptor.idVendor),
1758 le16_to_cpu(usb->descriptor.idProduct), 1757 le16_to_cpu(usb->descriptor.idProduct),
1759 chip_name[UEA_CHIP_VERSION(id)]); 1758 chip_name[UEA_CHIP_VERSION(id)], IS_ISDN(usb)?"isdn":"pots");
1760 1759
1761 usb_reset_device(usb); 1760 usb_reset_device(usb);
1762 1761
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 309073f6433a..ec63b0ee0743 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -1001,6 +1001,7 @@ static int usbatm_do_heavy_init(void *arg)
1001 1001
1002 daemonize(instance->driver->driver_name); 1002 daemonize(instance->driver->driver_name);
1003 allow_signal(SIGTERM); 1003 allow_signal(SIGTERM);
1004 instance->thread_pid = current->pid;
1004 1005
1005 complete(&instance->thread_started); 1006 complete(&instance->thread_started);
1006 1007
@@ -1025,10 +1026,6 @@ static int usbatm_heavy_init(struct usbatm_data *instance)
1025 return ret; 1026 return ret;
1026 } 1027 }
1027 1028
1028 mutex_lock(&instance->serialize);
1029 instance->thread_pid = ret;
1030 mutex_unlock(&instance->serialize);
1031
1032 wait_for_completion(&instance->thread_started); 1029 wait_for_completion(&instance->thread_started);
1033 1030
1034 return 0; 1031 return 0;
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index ec4d1d756725..9a9012fd284b 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -325,7 +325,7 @@ static void acm_rx_tasklet(unsigned long _acm)
325 struct acm_rb *buf; 325 struct acm_rb *buf;
326 struct tty_struct *tty = acm->tty; 326 struct tty_struct *tty = acm->tty;
327 struct acm_ru *rcv; 327 struct acm_ru *rcv;
328 //unsigned long flags; 328 unsigned long flags;
329 int i = 0; 329 int i = 0;
330 dbg("Entering acm_rx_tasklet"); 330 dbg("Entering acm_rx_tasklet");
331 331
@@ -333,15 +333,15 @@ static void acm_rx_tasklet(unsigned long _acm)
333 return; 333 return;
334 334
335next_buffer: 335next_buffer:
336 spin_lock(&acm->read_lock); 336 spin_lock_irqsave(&acm->read_lock, flags);
337 if (list_empty(&acm->filled_read_bufs)) { 337 if (list_empty(&acm->filled_read_bufs)) {
338 spin_unlock(&acm->read_lock); 338 spin_unlock_irqrestore(&acm->read_lock, flags);
339 goto urbs; 339 goto urbs;
340 } 340 }
341 buf = list_entry(acm->filled_read_bufs.next, 341 buf = list_entry(acm->filled_read_bufs.next,
342 struct acm_rb, list); 342 struct acm_rb, list);
343 list_del(&buf->list); 343 list_del(&buf->list);
344 spin_unlock(&acm->read_lock); 344 spin_unlock_irqrestore(&acm->read_lock, flags);
345 345
346 dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d", buf, buf->size); 346 dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d", buf, buf->size);
347 347
@@ -356,29 +356,29 @@ next_buffer:
356 memmove(buf->base, buf->base + i, buf->size - i); 356 memmove(buf->base, buf->base + i, buf->size - i);
357 buf->size -= i; 357 buf->size -= i;
358 spin_unlock(&acm->throttle_lock); 358 spin_unlock(&acm->throttle_lock);
359 spin_lock(&acm->read_lock); 359 spin_lock_irqsave(&acm->read_lock, flags);
360 list_add(&buf->list, &acm->filled_read_bufs); 360 list_add(&buf->list, &acm->filled_read_bufs);
361 spin_unlock(&acm->read_lock); 361 spin_unlock_irqrestore(&acm->read_lock, flags);
362 return; 362 return;
363 } 363 }
364 spin_unlock(&acm->throttle_lock); 364 spin_unlock(&acm->throttle_lock);
365 365
366 spin_lock(&acm->read_lock); 366 spin_lock_irqsave(&acm->read_lock, flags);
367 list_add(&buf->list, &acm->spare_read_bufs); 367 list_add(&buf->list, &acm->spare_read_bufs);
368 spin_unlock(&acm->read_lock); 368 spin_unlock_irqrestore(&acm->read_lock, flags);
369 goto next_buffer; 369 goto next_buffer;
370 370
371urbs: 371urbs:
372 while (!list_empty(&acm->spare_read_bufs)) { 372 while (!list_empty(&acm->spare_read_bufs)) {
373 spin_lock(&acm->read_lock); 373 spin_lock_irqsave(&acm->read_lock, flags);
374 if (list_empty(&acm->spare_read_urbs)) { 374 if (list_empty(&acm->spare_read_urbs)) {
375 spin_unlock(&acm->read_lock); 375 spin_unlock_irqrestore(&acm->read_lock, flags);
376 return; 376 return;
377 } 377 }
378 rcv = list_entry(acm->spare_read_urbs.next, 378 rcv = list_entry(acm->spare_read_urbs.next,
379 struct acm_ru, list); 379 struct acm_ru, list);
380 list_del(&rcv->list); 380 list_del(&rcv->list);
381 spin_unlock(&acm->read_lock); 381 spin_unlock_irqrestore(&acm->read_lock, flags);
382 382
383 buf = list_entry(acm->spare_read_bufs.next, 383 buf = list_entry(acm->spare_read_bufs.next,
384 struct acm_rb, list); 384 struct acm_rb, list);
@@ -400,9 +400,9 @@ urbs:
400 free-urbs-pool and resubmited ASAP */ 400 free-urbs-pool and resubmited ASAP */
401 if (usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) { 401 if (usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) {
402 list_add(&buf->list, &acm->spare_read_bufs); 402 list_add(&buf->list, &acm->spare_read_bufs);
403 spin_lock(&acm->read_lock); 403 spin_lock_irqsave(&acm->read_lock, flags);
404 list_add(&rcv->list, &acm->spare_read_urbs); 404 list_add(&rcv->list, &acm->spare_read_urbs);
405 spin_unlock(&acm->read_lock); 405 spin_unlock_irqrestore(&acm->read_lock, flags);
406 return; 406 return;
407 } 407 }
408 } 408 }
@@ -1083,6 +1083,9 @@ static struct usb_device_id acm_ids[] = {
1083 { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */ 1083 { USB_DEVICE(0x0482, 0x0203), /* KYOCERA AH-K3001V */
1084 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1084 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1085 }, 1085 },
1086 { USB_DEVICE(0x079b, 0x000f), /* BT On-Air USB MODEM */
1087 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1088 },
1086 { USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */ 1089 { USB_DEVICE(0x0ace, 0x1608), /* ZyDAS 56K USB MODEM */
1087 .driver_info = SINGLE_RX_URB, /* firmware bug */ 1090 .driver_info = SINGLE_RX_URB, /* firmware bug */
1088 }, 1091 },
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index a161d70e1e42..809d465eb257 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -154,6 +154,7 @@ struct usblp {
154 unsigned char used; /* True if open */ 154 unsigned char used; /* True if open */
155 unsigned char present; /* True if not disconnected */ 155 unsigned char present; /* True if not disconnected */
156 unsigned char bidir; /* interface is bidirectional */ 156 unsigned char bidir; /* interface is bidirectional */
157 unsigned char sleeping; /* interface is suspended */
157 unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string (ptr) */ 158 unsigned char *device_id_string; /* IEEE 1284 DEVICE ID string (ptr) */
158 /* first 2 bytes are (big-endian) length */ 159 /* first 2 bytes are (big-endian) length */
159}; 160};
@@ -183,6 +184,7 @@ static void usblp_dump(struct usblp *usblp) {
183 dbg("quirks=%d", usblp->quirks); 184 dbg("quirks=%d", usblp->quirks);
184 dbg("used=%d", usblp->used); 185 dbg("used=%d", usblp->used);
185 dbg("bidir=%d", usblp->bidir); 186 dbg("bidir=%d", usblp->bidir);
187 dbg("sleeping=%d", usblp->sleeping);
186 dbg("device_id_string=\"%s\"", 188 dbg("device_id_string=\"%s\"",
187 usblp->device_id_string ? 189 usblp->device_id_string ?
188 usblp->device_id_string + 2 : 190 usblp->device_id_string + 2 :
@@ -338,6 +340,20 @@ static int usblp_check_status(struct usblp *usblp, int err)
338 return newerr; 340 return newerr;
339} 341}
340 342
343static int handle_bidir (struct usblp *usblp)
344{
345 if (usblp->bidir && usblp->used && !usblp->sleeping) {
346 usblp->readcount = 0;
347 usblp->readurb->dev = usblp->dev;
348 if (usb_submit_urb(usblp->readurb, GFP_KERNEL) < 0) {
349 usblp->used = 0;
350 return -EIO;
351 }
352 }
353
354 return 0;
355}
356
341/* 357/*
342 * File op functions. 358 * File op functions.
343 */ 359 */
@@ -390,14 +406,9 @@ static int usblp_open(struct inode *inode, struct file *file)
390 usblp->writeurb->status = 0; 406 usblp->writeurb->status = 0;
391 usblp->readurb->status = 0; 407 usblp->readurb->status = 0;
392 408
393 if (usblp->bidir) { 409 if (handle_bidir(usblp) < 0) {
394 usblp->readcount = 0; 410 file->private_data = NULL;
395 usblp->readurb->dev = usblp->dev; 411 retval = -EIO;
396 if (usb_submit_urb(usblp->readurb, GFP_KERNEL) < 0) {
397 retval = -EIO;
398 usblp->used = 0;
399 file->private_data = NULL;
400 }
401 } 412 }
402out: 413out:
403 mutex_unlock (&usblp_mutex); 414 mutex_unlock (&usblp_mutex);
@@ -460,6 +471,11 @@ static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
460 goto done; 471 goto done;
461 } 472 }
462 473
474 if (usblp->sleeping) {
475 retval = -ENODEV;
476 goto done;
477 }
478
463 dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd), 479 dbg("usblp_ioctl: cmd=0x%x (%c nr=%d len=%d dir=%d)", cmd, _IOC_TYPE(cmd),
464 _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd) ); 480 _IOC_NR(cmd), _IOC_SIZE(cmd), _IOC_DIR(cmd) );
465 481
@@ -658,6 +674,11 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
658 return -ENODEV; 674 return -ENODEV;
659 } 675 }
660 676
677 if (usblp->sleeping) {
678 up (&usblp->sem);
679 return writecount ? writecount : -ENODEV;
680 }
681
661 if (usblp->writeurb->status != 0) { 682 if (usblp->writeurb->status != 0) {
662 if (usblp->quirks & USBLP_QUIRK_BIDIR) { 683 if (usblp->quirks & USBLP_QUIRK_BIDIR) {
663 if (!usblp->wcomplete) 684 if (!usblp->wcomplete)
@@ -749,6 +770,11 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count,
749 goto done; 770 goto done;
750 } 771 }
751 772
773 if (usblp->sleeping) {
774 count = -ENODEV;
775 goto done;
776 }
777
752 if (usblp->readurb->status) { 778 if (usblp->readurb->status) {
753 err("usblp%d: error %d reading from printer", 779 err("usblp%d: error %d reading from printer",
754 usblp->minor, usblp->readurb->status); 780 usblp->minor, usblp->readurb->status);
@@ -1167,6 +1193,41 @@ static void usblp_disconnect(struct usb_interface *intf)
1167 mutex_unlock (&usblp_mutex); 1193 mutex_unlock (&usblp_mutex);
1168} 1194}
1169 1195
1196static int usblp_suspend (struct usb_interface *intf, pm_message_t message)
1197{
1198 struct usblp *usblp = usb_get_intfdata (intf);
1199
1200 /* this races against normal access and open */
1201 mutex_lock (&usblp_mutex);
1202 down (&usblp->sem);
1203 /* we take no more IO */
1204 usblp->sleeping = 1;
1205 /* we wait for anything printing */
1206 wait_event (usblp->wait, usblp->wcomplete || !usblp->present);
1207 usblp_unlink_urbs(usblp);
1208 up (&usblp->sem);
1209 mutex_unlock (&usblp_mutex);
1210
1211 return 0;
1212}
1213
1214static int usblp_resume (struct usb_interface *intf)
1215{
1216 struct usblp *usblp = usb_get_intfdata (intf);
1217 int r;
1218
1219 mutex_lock (&usblp_mutex);
1220 down (&usblp->sem);
1221
1222 usblp->sleeping = 0;
1223 r = handle_bidir (usblp);
1224
1225 up (&usblp->sem);
1226 mutex_unlock (&usblp_mutex);
1227
1228 return r;
1229}
1230
1170static struct usb_device_id usblp_ids [] = { 1231static struct usb_device_id usblp_ids [] = {
1171 { USB_DEVICE_INFO(7, 1, 1) }, 1232 { USB_DEVICE_INFO(7, 1, 1) },
1172 { USB_DEVICE_INFO(7, 1, 2) }, 1233 { USB_DEVICE_INFO(7, 1, 2) },
@@ -1183,6 +1244,8 @@ static struct usb_driver usblp_driver = {
1183 .name = "usblp", 1244 .name = "usblp",
1184 .probe = usblp_probe, 1245 .probe = usblp_probe,
1185 .disconnect = usblp_disconnect, 1246 .disconnect = usblp_disconnect,
1247 .suspend = usblp_suspend,
1248 .resume = usblp_resume,
1186 .id_table = usblp_ids, 1249 .id_table = usblp_ids,
1187}; 1250};
1188 1251
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 724822cac2b1..fed92be63b5e 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1588,15 +1588,18 @@ const struct file_operations usbfs_device_file_operations = {
1588 .release = usbdev_release, 1588 .release = usbdev_release,
1589}; 1589};
1590 1590
1591static void usbdev_add(struct usb_device *dev) 1591static int usbdev_add(struct usb_device *dev)
1592{ 1592{
1593 int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); 1593 int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1);
1594 1594
1595 dev->class_dev = class_device_create(usb_device_class, NULL, 1595 dev->class_dev = class_device_create(usb_device_class, NULL,
1596 MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, 1596 MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev,
1597 "usbdev%d.%d", dev->bus->busnum, dev->devnum); 1597 "usbdev%d.%d", dev->bus->busnum, dev->devnum);
1598 if (IS_ERR(dev->class_dev))
1599 return PTR_ERR(dev->class_dev);
1598 1600
1599 dev->class_dev->class_data = dev; 1601 dev->class_dev->class_data = dev;
1602 return 0;
1600} 1603}
1601 1604
1602static void usbdev_remove(struct usb_device *dev) 1605static void usbdev_remove(struct usb_device *dev)
@@ -1609,7 +1612,8 @@ static int usbdev_notify(struct notifier_block *self, unsigned long action,
1609{ 1612{
1610 switch (action) { 1613 switch (action) {
1611 case USB_DEVICE_ADD: 1614 case USB_DEVICE_ADD:
1612 usbdev_add(dev); 1615 if (usbdev_add(dev))
1616 return NOTIFY_BAD;
1613 break; 1617 break;
1614 case USB_DEVICE_REMOVE: 1618 case USB_DEVICE_REMOVE:
1615 usbdev_remove(dev); 1619 usbdev_remove(dev);
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 3ebb90149e93..3b2d137912be 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -223,7 +223,7 @@ int usb_create_ep_files(struct device *parent,
223 ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL); 223 ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL);
224 if (!ep_dev) { 224 if (!ep_dev) {
225 retval = -ENOMEM; 225 retval = -ENOMEM;
226 goto exit; 226 goto error_alloc;
227 } 227 }
228 228
229 /* fun calculation to determine the minor of this endpoint */ 229 /* fun calculation to determine the minor of this endpoint */
@@ -241,33 +241,31 @@ int usb_create_ep_files(struct device *parent,
241 241
242 retval = device_register(&ep_dev->dev); 242 retval = device_register(&ep_dev->dev);
243 if (retval) 243 if (retval)
244 goto error; 244 goto error_register;
245 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 245 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
246 if (retval) 246 if (retval)
247 goto error_group; 247 goto error_group;
248 248
249 endpoint->ep_dev = ep_dev;
250
251 /* create the symlink to the old-style "ep_XX" directory */ 249 /* create the symlink to the old-style "ep_XX" directory */
252 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 250 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
253 retval = sysfs_create_link(&parent->kobj, 251 retval = sysfs_create_link(&parent->kobj, &ep_dev->dev.kobj, name);
254 &endpoint->ep_dev->dev.kobj, name);
255 if (retval) 252 if (retval)
256 goto error_link; 253 goto error_link;
257exit: 254 endpoint->ep_dev = ep_dev;
258 return retval; 255 return retval;
259 256
260error_link: 257error_link:
261 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 258 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
262
263error_group: 259error_group:
264 device_unregister(&ep_dev->dev); 260 device_unregister(&ep_dev->dev);
265 endpoint->ep_dev = NULL;
266 destroy_endpoint_class(); 261 destroy_endpoint_class();
267 return retval; 262 return retval;
268error: 263
264error_register:
269 kfree(ep_dev); 265 kfree(ep_dev);
266error_alloc:
270 destroy_endpoint_class(); 267 destroy_endpoint_class();
268exit:
271 return retval; 269 return retval;
272} 270}
273 271
@@ -282,8 +280,6 @@ void usb_remove_ep_files(struct usb_host_endpoint *endpoint)
282 sysfs_remove_group(&endpoint->ep_dev->dev.kobj, &ep_dev_attr_grp); 280 sysfs_remove_group(&endpoint->ep_dev->dev.kobj, &ep_dev_attr_grp);
283 device_unregister(&endpoint->ep_dev->dev); 281 device_unregister(&endpoint->ep_dev->dev);
284 endpoint->ep_dev = NULL; 282 endpoint->ep_dev = NULL;
283 destroy_endpoint_class();
285 } 284 }
286 destroy_endpoint_class();
287} 285}
288
289
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index d954daa8e9e0..3acc896a5d4c 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -1774,8 +1774,8 @@ static DEVICE_ATTR (queues, S_IRUGO, show_queues, NULL);
1774 1774
1775#else 1775#else
1776 1776
1777#define device_create_file(a,b) do {} while (0) 1777#define device_create_file(a,b) (0)
1778#define device_remove_file device_create_file 1778#define device_remove_file(a,b) do { } while (0)
1779 1779
1780#endif 1780#endif
1781 1781
@@ -2044,8 +2044,10 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
2044 return retval; 2044 return retval;
2045 } 2045 }
2046 2046
2047 device_create_file (&dev->pdev->dev, &dev_attr_function); 2047 retval = device_create_file (&dev->pdev->dev, &dev_attr_function);
2048 device_create_file (&dev->pdev->dev, &dev_attr_queues); 2048 if (retval) goto err_unbind;
2049 retval = device_create_file (&dev->pdev->dev, &dev_attr_queues);
2050 if (retval) goto err_func;
2049 2051
2050 /* ... then enable host detection and ep0; and we're ready 2052 /* ... then enable host detection and ep0; and we're ready
2051 * for set_configuration as well as eventual disconnect. 2053 * for set_configuration as well as eventual disconnect.
@@ -2060,6 +2062,14 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
2060 2062
2061 /* pci writes may still be posted */ 2063 /* pci writes may still be posted */
2062 return 0; 2064 return 0;
2065
2066err_func:
2067 device_remove_file (&dev->pdev->dev, &dev_attr_function);
2068err_unbind:
2069 driver->unbind (&dev->gadget);
2070 dev->gadget.dev.driver = NULL;
2071 dev->driver = NULL;
2072 return retval;
2063} 2073}
2064EXPORT_SYMBOL (usb_gadget_register_driver); 2074EXPORT_SYMBOL (usb_gadget_register_driver);
2065 2075
@@ -2974,8 +2984,10 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
2974 : "disabled"); 2984 : "disabled");
2975 the_controller = dev; 2985 the_controller = dev;
2976 2986
2977 device_register (&dev->gadget.dev); 2987 retval = device_register (&dev->gadget.dev);
2978 device_create_file (&pdev->dev, &dev_attr_registers); 2988 if (retval) goto done;
2989 retval = device_create_file (&pdev->dev, &dev_attr_registers);
2990 if (retval) goto done;
2979 2991
2980 return 0; 2992 return 0;
2981 2993
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index f42c00ef0bca..671c24bc6d75 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -43,11 +43,11 @@
43#include <linux/mm.h> 43#include <linux/mm.h>
44#include <linux/platform_device.h> 44#include <linux/platform_device.h>
45#include <linux/dma-mapping.h> 45#include <linux/dma-mapping.h>
46#include <linux/irq.h>
46 47
47#include <asm/byteorder.h> 48#include <asm/byteorder.h>
48#include <asm/dma.h> 49#include <asm/dma.h>
49#include <asm/io.h> 50#include <asm/io.h>
50#include <asm/irq.h>
51#include <asm/system.h> 51#include <asm/system.h>
52#include <asm/mach-types.h> 52#include <asm/mach-types.h>
53#include <asm/unaligned.h> 53#include <asm/unaligned.h>
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 23b95b2bfe15..34b7a31cd85b 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -754,7 +754,9 @@ show_registers (struct class_device *class_dev, char *buf)
754 } 754 }
755 755
756 if (ehci->reclaim) { 756 if (ehci->reclaim) {
757 temp = scnprintf (next, size, "reclaim qh %p\n", ehci->reclaim); 757 temp = scnprintf (next, size, "reclaim qh %p%s\n",
758 ehci->reclaim,
759 ehci->reclaim_ready ? " ready" : "");
758 size -= temp; 760 size -= temp;
759 next += temp; 761 next += temp;
760 } 762 }
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index aac6ec5dd7cf..9030994aba98 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -111,7 +111,7 @@ static const char hcd_name [] = "ehci_hcd";
111#define EHCI_TUNE_MULT_TT 1 111#define EHCI_TUNE_MULT_TT 1
112#define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */ 112#define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */
113 113
114#define EHCI_IAA_MSECS 10 /* arbitrary */ 114#define EHCI_IAA_JIFFIES (HZ/100) /* arbitrary; ~10 msec */
115#define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ 115#define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */
116#define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ 116#define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */
117#define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */ 117#define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */
@@ -254,7 +254,6 @@ static void ehci_quiesce (struct ehci_hcd *ehci)
254 254
255/*-------------------------------------------------------------------------*/ 255/*-------------------------------------------------------------------------*/
256 256
257static void end_unlink_async (struct ehci_hcd *ehci);
258static void ehci_work(struct ehci_hcd *ehci); 257static void ehci_work(struct ehci_hcd *ehci);
259 258
260#include "ehci-hub.c" 259#include "ehci-hub.c"
@@ -264,37 +263,25 @@ static void ehci_work(struct ehci_hcd *ehci);
264 263
265/*-------------------------------------------------------------------------*/ 264/*-------------------------------------------------------------------------*/
266 265
267static void ehci_iaa_watchdog (unsigned long param) 266static void ehci_watchdog (unsigned long param)
268{ 267{
269 struct ehci_hcd *ehci = (struct ehci_hcd *) param; 268 struct ehci_hcd *ehci = (struct ehci_hcd *) param;
270 unsigned long flags; 269 unsigned long flags;
271 u32 status;
272 270
273 spin_lock_irqsave (&ehci->lock, flags); 271 spin_lock_irqsave (&ehci->lock, flags);
274 WARN_ON(!ehci->reclaim);
275 272
276 /* lost IAA irqs wedge things badly; seen first with a vt8235 */ 273 /* lost IAA irqs wedge things badly; seen with a vt8235 */
277 if (ehci->reclaim) { 274 if (ehci->reclaim) {
278 status = readl (&ehci->regs->status); 275 u32 status = readl (&ehci->regs->status);
279 if (status & STS_IAA) { 276 if (status & STS_IAA) {
280 ehci_vdbg (ehci, "lost IAA\n"); 277 ehci_vdbg (ehci, "lost IAA\n");
281 COUNT (ehci->stats.lost_iaa); 278 COUNT (ehci->stats.lost_iaa);
282 writel (STS_IAA, &ehci->regs->status); 279 writel (STS_IAA, &ehci->regs->status);
283 end_unlink_async (ehci); 280 ehci->reclaim_ready = 1;
284 } 281 }
285 } 282 }
286 283
287 spin_unlock_irqrestore (&ehci->lock, flags); 284 /* stop async processing after it's idled a bit */
288}
289
290static void ehci_watchdog (unsigned long param)
291{
292 struct ehci_hcd *ehci = (struct ehci_hcd *) param;
293 unsigned long flags;
294
295 spin_lock_irqsave (&ehci->lock, flags);
296
297 /* stop async processing after it's idled a bit */
298 if (test_bit (TIMER_ASYNC_OFF, &ehci->actions)) 285 if (test_bit (TIMER_ASYNC_OFF, &ehci->actions))
299 start_unlink_async (ehci, ehci->async); 286 start_unlink_async (ehci, ehci->async);
300 287
@@ -345,6 +332,8 @@ static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
345static void ehci_work (struct ehci_hcd *ehci) 332static void ehci_work (struct ehci_hcd *ehci)
346{ 333{
347 timer_action_done (ehci, TIMER_IO_WATCHDOG); 334 timer_action_done (ehci, TIMER_IO_WATCHDOG);
335 if (ehci->reclaim_ready)
336 end_unlink_async (ehci);
348 337
349 /* another CPU may drop ehci->lock during a schedule scan while 338 /* another CPU may drop ehci->lock during a schedule scan while
350 * it reports urb completions. this flag guards against bogus 339 * it reports urb completions. this flag guards against bogus
@@ -379,7 +368,6 @@ static void ehci_stop (struct usb_hcd *hcd)
379 368
380 /* no more interrupts ... */ 369 /* no more interrupts ... */
381 del_timer_sync (&ehci->watchdog); 370 del_timer_sync (&ehci->watchdog);
382 del_timer_sync (&ehci->iaa_watchdog);
383 371
384 spin_lock_irq(&ehci->lock); 372 spin_lock_irq(&ehci->lock);
385 if (HC_IS_RUNNING (hcd->state)) 373 if (HC_IS_RUNNING (hcd->state))
@@ -426,10 +414,6 @@ static int ehci_init(struct usb_hcd *hcd)
426 ehci->watchdog.function = ehci_watchdog; 414 ehci->watchdog.function = ehci_watchdog;
427 ehci->watchdog.data = (unsigned long) ehci; 415 ehci->watchdog.data = (unsigned long) ehci;
428 416
429 init_timer(&ehci->iaa_watchdog);
430 ehci->iaa_watchdog.function = ehci_iaa_watchdog;
431 ehci->iaa_watchdog.data = (unsigned long) ehci;
432
433 /* 417 /*
434 * hw default: 1K periodic list heads, one per frame. 418 * hw default: 1K periodic list heads, one per frame.
435 * periodic_size can shrink by USBCMD update if hcc_params allows. 419 * periodic_size can shrink by USBCMD update if hcc_params allows.
@@ -446,6 +430,7 @@ static int ehci_init(struct usb_hcd *hcd)
446 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); 430 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
447 431
448 ehci->reclaim = NULL; 432 ehci->reclaim = NULL;
433 ehci->reclaim_ready = 0;
449 ehci->next_uframe = -1; 434 ehci->next_uframe = -1;
450 435
451 /* 436 /*
@@ -619,7 +604,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
619 /* complete the unlinking of some qh [4.15.2.3] */ 604 /* complete the unlinking of some qh [4.15.2.3] */
620 if (status & STS_IAA) { 605 if (status & STS_IAA) {
621 COUNT (ehci->stats.reclaim); 606 COUNT (ehci->stats.reclaim);
622 end_unlink_async (ehci); 607 ehci->reclaim_ready = 1;
623 bh = 1; 608 bh = 1;
624 } 609 }
625 610
@@ -723,14 +708,10 @@ static int ehci_urb_enqueue (
723 708
724static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) 709static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
725{ 710{
726 // BUG_ON(qh->qh_state != QH_STATE_LINKED); 711 /* if we need to use IAA and it's busy, defer */
727 712 if (qh->qh_state == QH_STATE_LINKED
728 /* failfast */ 713 && ehci->reclaim
729 if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) 714 && HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) {
730 end_unlink_async (ehci);
731
732 /* defer till later if busy */
733 else if (ehci->reclaim) {
734 struct ehci_qh *last; 715 struct ehci_qh *last;
735 716
736 for (last = ehci->reclaim; 717 for (last = ehci->reclaim;
@@ -740,8 +721,12 @@ static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
740 qh->qh_state = QH_STATE_UNLINK_WAIT; 721 qh->qh_state = QH_STATE_UNLINK_WAIT;
741 last->reclaim = qh; 722 last->reclaim = qh;
742 723
743 /* start IAA cycle */ 724 /* bypass IAA if the hc can't care */
744 } else 725 } else if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && ehci->reclaim)
726 end_unlink_async (ehci);
727
728 /* something else might have unlinked the qh by now */
729 if (qh->qh_state == QH_STATE_LINKED)
745 start_unlink_async (ehci, qh); 730 start_unlink_async (ehci, qh);
746} 731}
747 732
@@ -763,19 +748,7 @@ static int ehci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
763 qh = (struct ehci_qh *) urb->hcpriv; 748 qh = (struct ehci_qh *) urb->hcpriv;
764 if (!qh) 749 if (!qh)
765 break; 750 break;
766 switch (qh->qh_state) { 751 unlink_async (ehci, qh);
767 case QH_STATE_LINKED:
768 case QH_STATE_COMPLETING:
769 unlink_async (ehci, qh);
770 break;
771 case QH_STATE_UNLINK:
772 case QH_STATE_UNLINK_WAIT:
773 /* already started */
774 break;
775 case QH_STATE_IDLE:
776 WARN_ON(1);
777 break;
778 }
779 break; 752 break;
780 753
781 case PIPE_INTERRUPT: 754 case PIPE_INTERRUPT:
@@ -867,7 +840,6 @@ rescan:
867 unlink_async (ehci, qh); 840 unlink_async (ehci, qh);
868 /* FALL THROUGH */ 841 /* FALL THROUGH */
869 case QH_STATE_UNLINK: /* wait for hw to finish? */ 842 case QH_STATE_UNLINK: /* wait for hw to finish? */
870 case QH_STATE_UNLINK_WAIT:
871idle_timeout: 843idle_timeout:
872 spin_unlock_irqrestore (&ehci->lock, flags); 844 spin_unlock_irqrestore (&ehci->lock, flags);
873 schedule_timeout_uninterruptible(1); 845 schedule_timeout_uninterruptible(1);
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 2012213c0a25..1b20722c102b 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -48,7 +48,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
48 } 48 }
49 ehci->command = readl (&ehci->regs->command); 49 ehci->command = readl (&ehci->regs->command);
50 if (ehci->reclaim) 50 if (ehci->reclaim)
51 end_unlink_async (ehci); 51 ehci->reclaim_ready = 1;
52 ehci_work(ehci); 52 ehci_work(ehci);
53 53
54 /* suspend any active/unsuspended ports, maybe allow wakeup */ 54 /* suspend any active/unsuspended ports, maybe allow wakeup */
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 35e3fab6fc4e..e51c1ed81ac4 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -303,7 +303,7 @@ restart:
303 /* emptying the schedule aborts any urbs */ 303 /* emptying the schedule aborts any urbs */
304 spin_lock_irq(&ehci->lock); 304 spin_lock_irq(&ehci->lock);
305 if (ehci->reclaim) 305 if (ehci->reclaim)
306 end_unlink_async (ehci); 306 ehci->reclaim_ready = 1;
307 ehci_work(ehci); 307 ehci_work(ehci);
308 spin_unlock_irq(&ehci->lock); 308 spin_unlock_irq(&ehci->lock);
309 309
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 46327272f614..62e46dc60e86 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -967,7 +967,7 @@ static void end_unlink_async (struct ehci_hcd *ehci)
967 struct ehci_qh *qh = ehci->reclaim; 967 struct ehci_qh *qh = ehci->reclaim;
968 struct ehci_qh *next; 968 struct ehci_qh *next;
969 969
970 iaa_watchdog_done (ehci); 970 timer_action_done (ehci, TIMER_IAA_WATCHDOG);
971 971
972 // qh->hw_next = cpu_to_le32 (qh->qh_dma); 972 // qh->hw_next = cpu_to_le32 (qh->qh_dma);
973 qh->qh_state = QH_STATE_IDLE; 973 qh->qh_state = QH_STATE_IDLE;
@@ -977,6 +977,7 @@ static void end_unlink_async (struct ehci_hcd *ehci)
977 /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */ 977 /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */
978 next = qh->reclaim; 978 next = qh->reclaim;
979 ehci->reclaim = next; 979 ehci->reclaim = next;
980 ehci->reclaim_ready = 0;
980 qh->reclaim = NULL; 981 qh->reclaim = NULL;
981 982
982 qh_completions (ehci, qh); 983 qh_completions (ehci, qh);
@@ -1051,10 +1052,11 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
1051 return; 1052 return;
1052 } 1053 }
1053 1054
1055 ehci->reclaim_ready = 0;
1054 cmd |= CMD_IAAD; 1056 cmd |= CMD_IAAD;
1055 writel (cmd, &ehci->regs->command); 1057 writel (cmd, &ehci->regs->command);
1056 (void) readl (&ehci->regs->command); 1058 (void) readl (&ehci->regs->command);
1057 iaa_watchdog_start (ehci); 1059 timer_action (ehci, TIMER_IAA_WATCHDOG);
1058} 1060}
1059 1061
1060/*-------------------------------------------------------------------------*/ 1062/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 6aac39f50e07..bbc3082a73d7 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -58,6 +58,7 @@ struct ehci_hcd { /* one per controller */
58 /* async schedule support */ 58 /* async schedule support */
59 struct ehci_qh *async; 59 struct ehci_qh *async;
60 struct ehci_qh *reclaim; 60 struct ehci_qh *reclaim;
61 unsigned reclaim_ready : 1;
61 unsigned scanning : 1; 62 unsigned scanning : 1;
62 63
63 /* periodic schedule support */ 64 /* periodic schedule support */
@@ -80,7 +81,6 @@ struct ehci_hcd { /* one per controller */
80 struct dma_pool *itd_pool; /* itd per iso urb */ 81 struct dma_pool *itd_pool; /* itd per iso urb */
81 struct dma_pool *sitd_pool; /* sitd per split iso urb */ 82 struct dma_pool *sitd_pool; /* sitd per split iso urb */
82 83
83 struct timer_list iaa_watchdog;
84 struct timer_list watchdog; 84 struct timer_list watchdog;
85 unsigned long actions; 85 unsigned long actions;
86 unsigned stamp; 86 unsigned stamp;
@@ -114,21 +114,9 @@ static inline struct usb_hcd *ehci_to_hcd (struct ehci_hcd *ehci)
114} 114}
115 115
116 116
117static inline void
118iaa_watchdog_start (struct ehci_hcd *ehci)
119{
120 WARN_ON(timer_pending(&ehci->iaa_watchdog));
121 mod_timer (&ehci->iaa_watchdog,
122 jiffies + msecs_to_jiffies(EHCI_IAA_MSECS));
123}
124
125static inline void iaa_watchdog_done (struct ehci_hcd *ehci)
126{
127 del_timer (&ehci->iaa_watchdog);
128}
129
130enum ehci_timer_action { 117enum ehci_timer_action {
131 TIMER_IO_WATCHDOG, 118 TIMER_IO_WATCHDOG,
119 TIMER_IAA_WATCHDOG,
132 TIMER_ASYNC_SHRINK, 120 TIMER_ASYNC_SHRINK,
133 TIMER_ASYNC_OFF, 121 TIMER_ASYNC_OFF,
134}; 122};
@@ -146,6 +134,9 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
146 unsigned long t; 134 unsigned long t;
147 135
148 switch (action) { 136 switch (action) {
137 case TIMER_IAA_WATCHDOG:
138 t = EHCI_IAA_JIFFIES;
139 break;
149 case TIMER_IO_WATCHDOG: 140 case TIMER_IO_WATCHDOG:
150 t = EHCI_IO_JIFFIES; 141 t = EHCI_IO_JIFFIES;
151 break; 142 break;
@@ -162,7 +153,8 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
162 // async queue SHRINK often precedes IAA. while it's ready 153 // async queue SHRINK often precedes IAA. while it's ready
163 // to go OFF neither can matter, and afterwards the IO 154 // to go OFF neither can matter, and afterwards the IO
164 // watchdog stops unless there's still periodic traffic. 155 // watchdog stops unless there's still periodic traffic.
165 if (time_before_eq(t, ehci->watchdog.expires) 156 if (action != TIMER_IAA_WATCHDOG
157 && t > ehci->watchdog.expires
166 && timer_pending (&ehci->watchdog)) 158 && timer_pending (&ehci->watchdog))
167 return; 159 return;
168 mod_timer (&ehci->watchdog, t); 160 mod_timer (&ehci->watchdog, t);
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 82cb22f002e7..2dbb77414905 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -262,6 +262,7 @@ static const struct hc_driver ohci_pnx4008_hc_driver = {
262 */ 262 */
263 .start = ohci_pnx4008_start, 263 .start = ohci_pnx4008_start,
264 .stop = ohci_stop, 264 .stop = ohci_stop,
265 .shutdown = ohci_shutdown,
265 266
266 /* 267 /*
267 * managing i/o requests and associated device resources 268 * managing i/o requests and associated device resources
@@ -280,7 +281,11 @@ static const struct hc_driver ohci_pnx4008_hc_driver = {
280 */ 281 */
281 .hub_status_data = ohci_hub_status_data, 282 .hub_status_data = ohci_hub_status_data,
282 .hub_control = ohci_hub_control, 283 .hub_control = ohci_hub_control,
283 284 .hub_irq_enable = ohci_rhsc_enable,
285#ifdef CONFIG_PM
286 .bus_suspend = ohci_bus_suspend,
287 .bus_resume = ohci_bus_resume,
288#endif
284 .start_port_reset = ohci_start_port_reset, 289 .start_port_reset = ohci_start_port_reset,
285}; 290};
286 291
@@ -410,8 +415,6 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev)
410 goto out4; 415 goto out4;
411 } 416 }
412 417
413 hcd->self.hcpriv = (void *)hcd;
414
415 pnx4008_start_hc(); 418 pnx4008_start_hc();
416 platform_set_drvdata(pdev, hcd); 419 platform_set_drvdata(pdev, hcd);
417 ohci = hcd_to_ohci(hcd); 420 ohci = hcd_to_ohci(hcd);
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 45ee6920a850..226bf3de8edd 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -40,6 +40,7 @@
40#include <linux/dma-mapping.h> 40#include <linux/dma-mapping.h>
41#include <linux/usb.h> 41#include <linux/usb.h>
42#include <linux/bitops.h> 42#include <linux/bitops.h>
43#include <linux/dmi.h>
43 44
44#include <asm/uaccess.h> 45#include <asm/uaccess.h>
45#include <asm/io.h> 46#include <asm/io.h>
@@ -196,12 +197,42 @@ static int resume_detect_interrupts_are_broken(struct uhci_hcd *uhci)
196 return 0; 197 return 0;
197} 198}
198 199
200static int remote_wakeup_is_broken(struct uhci_hcd *uhci)
201{
202 static struct dmi_system_id broken_wakeup_table[] = {
203 {
204 .ident = "Asus A7V8X",
205 .matches = {
206 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK"),
207 DMI_MATCH(DMI_BOARD_NAME, "A7V8X"),
208 DMI_MATCH(DMI_BOARD_VERSION, "REV 1.xx"),
209 }
210 },
211 { }
212 };
213 int port;
214
215 /* One of Asus's motherboards has a bug which causes it to
216 * wake up immediately from suspend-to-RAM if any of the ports
217 * are connected. In such cases we will not set EGSM.
218 */
219 if (dmi_check_system(broken_wakeup_table)) {
220 for (port = 0; port < uhci->rh_numports; ++port) {
221 if (inw(uhci->io_addr + USBPORTSC1 + port * 2) &
222 USBPORTSC_CCS)
223 return 1;
224 }
225 }
226
227 return 0;
228}
229
199static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state) 230static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state)
200__releases(uhci->lock) 231__releases(uhci->lock)
201__acquires(uhci->lock) 232__acquires(uhci->lock)
202{ 233{
203 int auto_stop; 234 int auto_stop;
204 int int_enable; 235 int int_enable, egsm_enable;
205 236
206 auto_stop = (new_state == UHCI_RH_AUTO_STOPPED); 237 auto_stop = (new_state == UHCI_RH_AUTO_STOPPED);
207 dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev, 238 dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev,
@@ -217,15 +248,18 @@ __acquires(uhci->lock)
217 } 248 }
218 249
219 /* Enable resume-detect interrupts if they work. 250 /* Enable resume-detect interrupts if they work.
220 * Then enter Global Suspend mode, still configured. 251 * Then enter Global Suspend mode if _it_ works, still configured.
221 */ 252 */
253 egsm_enable = USBCMD_EGSM;
222 uhci->working_RD = 1; 254 uhci->working_RD = 1;
223 int_enable = USBINTR_RESUME; 255 int_enable = USBINTR_RESUME;
224 if (resume_detect_interrupts_are_broken(uhci)) { 256 if (remote_wakeup_is_broken(uhci))
257 egsm_enable = 0;
258 if (resume_detect_interrupts_are_broken(uhci) || !egsm_enable)
225 uhci->working_RD = int_enable = 0; 259 uhci->working_RD = int_enable = 0;
226 } 260
227 outw(int_enable, uhci->io_addr + USBINTR); 261 outw(int_enable, uhci->io_addr + USBINTR);
228 outw(USBCMD_EGSM | USBCMD_CF, uhci->io_addr + USBCMD); 262 outw(egsm_enable | USBCMD_CF, uhci->io_addr + USBCMD);
229 mb(); 263 mb();
230 udelay(5); 264 udelay(5);
231 265
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
index 21cd22640080..20db36448ab3 100644
--- a/drivers/usb/input/Kconfig
+++ b/drivers/usb/input/Kconfig
@@ -348,13 +348,3 @@ config USB_APPLETOUCH
348 348
349 To compile this driver as a module, choose M here: the 349 To compile this driver as a module, choose M here: the
350 module will be called appletouch. 350 module will be called appletouch.
351
352config USB_TRANCEVIBRATOR
353 tristate "PlayStation 2 Trance Vibrator driver support"
354 depends on USB
355 help
356 Say Y here if you want to connect a PlayStation 2 Trance Vibrator
357 device to your computer's USB port.
358
359 To compile this driver as a module, choose M here: the
360 module will be called trancevibrator.
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile
index 295f459d1079..d946d5213b30 100644
--- a/drivers/usb/input/Makefile
+++ b/drivers/usb/input/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5# Multipart objects. 5# Multipart objects.
6wacom-objs := wacom_sys.o wacom_wac.o 6wacom-objs := wacom_wac.o wacom_sys.o
7usbhid-objs := hid-core.o 7usbhid-objs := hid-core.o
8 8
9# Optional parts of multipart objects. 9# Optional parts of multipart objects.
@@ -48,7 +48,6 @@ obj-$(CONFIG_USB_ACECAD) += acecad.o
48obj-$(CONFIG_USB_YEALINK) += yealink.o 48obj-$(CONFIG_USB_YEALINK) += yealink.o
49obj-$(CONFIG_USB_XPAD) += xpad.o 49obj-$(CONFIG_USB_XPAD) += xpad.o
50obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o 50obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o
51obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
52 51
53ifeq ($(CONFIG_USB_DEBUG),y) 52ifeq ($(CONFIG_USB_DEBUG),y)
54EXTRA_CFLAGS += -DDEBUG 53EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index a6738a83ff5b..45f44fe33bfe 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -750,21 +750,31 @@ static __inline__ __u32 s32ton(__s32 value, unsigned n)
750} 750}
751 751
752/* 752/*
753 * Extract/implement a data field from/to a report. 753 * Extract/implement a data field from/to a little endian report (bit array).
754 */ 754 */
755 755
756static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) 756static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n)
757{ 757{
758 report += (offset >> 5) << 2; offset &= 31; 758 u32 x;
759 return (le64_to_cpu(get_unaligned((__le64*)report)) >> offset) & ((1ULL << n) - 1); 759
760 report += offset >> 3; /* adjust byte index */
761 offset &= 8 - 1;
762 x = get_unaligned((u32 *) report);
763 x = le32_to_cpu(x);
764 x = (x >> offset) & ((1 << n) - 1);
765 return x;
760} 766}
761 767
762static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value) 768static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value)
763{ 769{
764 report += (offset >> 5) << 2; offset &= 31; 770 u32 x;
765 put_unaligned((get_unaligned((__le64*)report) 771
766 & cpu_to_le64(~((((__u64) 1 << n) - 1) << offset))) 772 report += offset >> 3;
767 | cpu_to_le64((__u64)value << offset), (__le64*)report); 773 offset &= 8 - 1;
774 x = get_unaligned((u32 *)report);
775 x &= cpu_to_le32(~((((__u32) 1 << n) - 1) << offset));
776 x |= cpu_to_le32(value << offset);
777 put_unaligned(x,(u32 *)report);
768} 778}
769 779
770/* 780/*
@@ -1381,6 +1391,9 @@ void hid_close(struct hid_device *hid)
1381 1391
1382#define USB_VENDOR_ID_PANJIT 0x134c 1392#define USB_VENDOR_ID_PANJIT 0x134c
1383 1393
1394#define USB_VENDOR_ID_TURBOX 0x062a
1395#define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201
1396
1384/* 1397/*
1385 * Initialize all reports 1398 * Initialize all reports
1386 */ 1399 */
@@ -1768,6 +1781,8 @@ static const struct hid_blacklist {
1768 { USB_VENDOR_ID_PANJIT, 0x0003, HID_QUIRK_IGNORE }, 1781 { USB_VENDOR_ID_PANJIT, 0x0003, HID_QUIRK_IGNORE },
1769 { USB_VENDOR_ID_PANJIT, 0x0004, HID_QUIRK_IGNORE }, 1782 { USB_VENDOR_ID_PANJIT, 0x0004, HID_QUIRK_IGNORE },
1770 1783
1784 { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET },
1785
1771 { 0, 0 } 1786 { 0, 0 }
1772}; 1787};
1773 1788
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c
index f26c1cd1129f..2902742895ad 100644
--- a/drivers/usb/input/usbtouchscreen.c
+++ b/drivers/usb/input/usbtouchscreen.c
@@ -256,10 +256,10 @@ static int itm_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *pr
256{ 256{
257 *x = ((pkt[0] & 0x1F) << 7) | (pkt[3] & 0x7F); 257 *x = ((pkt[0] & 0x1F) << 7) | (pkt[3] & 0x7F);
258 *y = ((pkt[1] & 0x1F) << 7) | (pkt[4] & 0x7F); 258 *y = ((pkt[1] & 0x1F) << 7) | (pkt[4] & 0x7F);
259 *press = ((pkt[2] & 0x1F) << 7) | (pkt[5] & 0x7F); 259 *press = ((pkt[2] & 0x01) << 7) | (pkt[5] & 0x7F);
260 *touch = ~pkt[7] & 0x20; 260 *touch = ~pkt[7] & 0x20;
261 261
262 return 1; 262 return *touch;
263} 263}
264#endif 264#endif
265 265
diff --git a/drivers/usb/input/wacom.h b/drivers/usb/input/wacom.h
index 7b3840e378a8..1cf08f02c50e 100644
--- a/drivers/usb/input/wacom.h
+++ b/drivers/usb/input/wacom.h
@@ -63,6 +63,7 @@
63 * v1.46 (pc) - Split wacom.c into wacom_sys.c and wacom_wac.c, 63 * v1.46 (pc) - Split wacom.c into wacom_sys.c and wacom_wac.c,
64 * - where wacom_sys.c deals with system specific code, 64 * - where wacom_sys.c deals with system specific code,
65 * - and wacom_wac.c deals with Wacom specific code 65 * - and wacom_wac.c deals with Wacom specific code
66 * - Support Intuos3 4x6
66 */ 67 */
67 68
68/* 69/*
@@ -118,6 +119,7 @@ extern void wacom_input_sync(void *wcombo);
118extern void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 119extern void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
119extern void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 120extern void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
120extern void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 121extern void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
122extern void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
121extern void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 123extern void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
122extern void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 124extern void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
123extern void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac); 125extern void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
diff --git a/drivers/usb/input/wacom_sys.c b/drivers/usb/input/wacom_sys.c
index d233c37bd533..3498b893b53b 100644
--- a/drivers/usb/input/wacom_sys.c
+++ b/drivers/usb/input/wacom_sys.c
@@ -110,7 +110,7 @@ __u16 wacom_be16_to_cpu(unsigned char *data)
110__u16 wacom_le16_to_cpu(unsigned char *data) 110__u16 wacom_le16_to_cpu(unsigned char *data)
111{ 111{
112 __u16 value; 112 __u16 value;
113 value = be16_to_cpu(*(__be16 *) data); 113 value = le16_to_cpu(*(__le16 *) data);
114 return value; 114 return value;
115} 115}
116 116
@@ -143,7 +143,7 @@ void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
143 input_dev->evbit[0] |= BIT(EV_MSC); 143 input_dev->evbit[0] |= BIT(EV_MSC);
144 input_dev->mscbit[0] |= BIT(MSC_SERIAL); 144 input_dev->mscbit[0] |= BIT(MSC_SERIAL);
145 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); 145 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
146 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); 146 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_4);
147} 147}
148 148
149void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 149void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
@@ -155,11 +155,16 @@ void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
155 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0); 155 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0);
156} 156}
157 157
158void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 158void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
159{ 159{
160 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); 160 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
161 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); 161 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3);
162 input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0); 162 input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0);
163}
164
165void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
166{
167 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);
163 input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0); 168 input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0);
164} 169}
165 170
@@ -218,8 +223,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
218 strlcat(wacom->phys, "/input0", sizeof(wacom->phys)); 223 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
219 224
220 wacom_wac->features = get_wacom_feature(id); 225 wacom_wac->features = get_wacom_feature(id);
221 if (wacom_wac->features->pktlen > 10) 226 BUG_ON(wacom_wac->features->pktlen > 10);
222 BUG();
223 227
224 input_dev->name = wacom_wac->features->name; 228 input_dev->name = wacom_wac->features->name;
225 wacom->wacom_wac = wacom_wac; 229 wacom->wacom_wac = wacom_wac;
@@ -244,7 +248,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
244 usb_fill_int_urb(wacom->irq, dev, 248 usb_fill_int_urb(wacom->irq, dev,
245 usb_rcvintpipe(dev, endpoint->bEndpointAddress), 249 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
246 wacom_wac->data, wacom_wac->features->pktlen, 250 wacom_wac->data, wacom_wac->features->pktlen,
247 wacom_wac->features->irq, wacom, endpoint->bInterval); 251 wacom_sys_irq, wacom, endpoint->bInterval);
248 wacom->irq->transfer_dma = wacom->data_dma; 252 wacom->irq->transfer_dma = wacom->data_dma;
249 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 253 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
250 254
@@ -278,8 +282,8 @@ static void wacom_disconnect(struct usb_interface *intf)
278 input_unregister_device(wacom->dev); 282 input_unregister_device(wacom->dev);
279 usb_free_urb(wacom->irq); 283 usb_free_urb(wacom->irq);
280 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->wacom_wac->data, wacom->data_dma); 284 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->wacom_wac->data, wacom->data_dma);
281 kfree(wacom);
282 kfree(wacom->wacom_wac); 285 kfree(wacom->wacom_wac);
286 kfree(wacom);
283 } 287 }
284} 288}
285 289
diff --git a/drivers/usb/input/wacom_wac.c b/drivers/usb/input/wacom_wac.c
index aa31d22d4f05..92726fe89379 100644
--- a/drivers/usb/input/wacom_wac.c
+++ b/drivers/usb/input/wacom_wac.c
@@ -191,9 +191,9 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
191 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01); 191 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
192 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02); 192 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
193 if (wacom->features->type == WACOM_G4) 193 if (wacom->features->type == WACOM_G4)
194 wacom_report_abs(wcombo, ABS_DISTANCE, data[6]); 194 wacom_report_abs(wcombo, ABS_DISTANCE, data[6] & 0x3f);
195 else 195 else
196 wacom_report_abs(wcombo, ABS_DISTANCE, data[7]); 196 wacom_report_abs(wcombo, ABS_DISTANCE, data[7] & 0x3f);
197 break; 197 break;
198 } 198 }
199 } 199 }
@@ -303,8 +303,9 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
303 wacom->tool[idx] = BTN_TOOL_PEN; 303 wacom->tool[idx] = BTN_TOOL_PEN;
304 } 304 }
305 /* only large I3 support Lens Cursor */ 305 /* only large I3 support Lens Cursor */
306 if(!((wacom->tool[idx] == BTN_TOOL_LENS) && 306 if(!((wacom->tool[idx] == BTN_TOOL_LENS)
307 (wacom->features->type == INTUOS3))) { 307 && ((wacom->features->type == INTUOS3)
308 || (wacom->features->type == INTUOS3S)))) {
308 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */ 309 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
309 wacom_report_key(wcombo, wacom->tool[idx], 1); 310 wacom_report_key(wcombo, wacom->tool[idx], 1);
310 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]); 311 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
@@ -315,10 +316,14 @@ static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
315 316
316 /* Exit report */ 317 /* Exit report */
317 if ((data[1] & 0xfe) == 0x80) { 318 if ((data[1] & 0xfe) == 0x80) {
318 wacom_report_key(wcombo, wacom->tool[idx], 0); 319 if(!((wacom->tool[idx] == BTN_TOOL_LENS)
319 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */ 320 && ((wacom->features->type == INTUOS3)
320 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]); 321 || (wacom->features->type == INTUOS3S)))) {
321 return 2; 322 wacom_report_key(wcombo, wacom->tool[idx], 0);
323 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
324 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
325 return 2;
326 }
322 } 327 }
323 return 0; 328 return 0;
324} 329}
@@ -382,7 +387,8 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
382 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]); 387 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
383 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]); 388 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
384 389
385 if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) | data[2]) 390 if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) |
391 data[2] | (data[3] & 0x1f) | data[4])
386 wacom_report_key(wcombo, wacom->tool[1], 1); 392 wacom_report_key(wcombo, wacom->tool[1], 1);
387 else 393 else
388 wacom_report_key(wcombo, wacom->tool[1], 0); 394 wacom_report_key(wcombo, wacom->tool[1], 0);
@@ -432,7 +438,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
432 ((t - 1) / 2) : -t / 2); 438 ((t - 1) / 2) : -t / 2);
433 } 439 }
434 440
435 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3) { 441 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3S) {
436 /* 4D mouse packet */ 442 /* 4D mouse packet */
437 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 443 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
438 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); 444 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
@@ -452,12 +458,12 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
452 - ((data[8] & 0x02) >> 1)); 458 - ((data[8] & 0x02) >> 1));
453 459
454 /* I3 2D mouse side buttons */ 460 /* I3 2D mouse side buttons */
455 if (wacom->features->type == INTUOS3) { 461 if (wacom->features->type >= INTUOS3S && wacom->features->type <= INTUOS3L) {
456 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40); 462 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
457 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20); 463 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
458 } 464 }
459 465
460 } else if (wacom->features->type < INTUOS3) { 466 } else if (wacom->features->type < INTUOS3S || wacom->features->type == INTUOS3L) {
461 /* Lens cursor packets */ 467 /* Lens cursor packets */
462 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01); 468 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
463 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02); 469 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
@@ -490,6 +496,7 @@ int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
490 return (wacom_ptu_irq(wacom_wac, wcombo)); 496 return (wacom_ptu_irq(wacom_wac, wcombo));
491 break; 497 break;
492 case INTUOS: 498 case INTUOS:
499 case INTUOS3S:
493 case INTUOS3: 500 case INTUOS3:
494 case INTUOS3L: 501 case INTUOS3L:
495 case CINTIQ: 502 case CINTIQ:
@@ -515,6 +522,8 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
515 case CINTIQ: 522 case CINTIQ:
516 input_dev_i3(input_dev, wacom_wac); 523 input_dev_i3(input_dev, wacom_wac);
517 /* fall through */ 524 /* fall through */
525 case INTUOS3S:
526 input_dev_i3s(input_dev, wacom_wac);
518 case INTUOS: 527 case INTUOS:
519 input_dev_i(input_dev, wacom_wac); 528 input_dev_i(input_dev, wacom_wac);
520 break; 529 break;
@@ -530,49 +539,50 @@ void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_w
530} 539}
531 540
532static struct wacom_features wacom_features[] = { 541static struct wacom_features wacom_features[] = {
533 { "Wacom Penpartner", 7, 5040, 3780, 255, 32, PENPARTNER, wacom_sys_irq }, 542 { "Wacom Penpartner", 7, 5040, 3780, 255, 0, PENPARTNER },
534 { "Wacom Graphire", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_sys_irq }, 543 { "Wacom Graphire", 8, 10206, 7422, 511, 63, GRAPHIRE },
535 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_sys_irq }, 544 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 63, GRAPHIRE },
536 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE, wacom_sys_irq }, 545 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 63, GRAPHIRE },
537 { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE, wacom_sys_irq }, 546 { "Wacom Graphire3", 8, 10208, 7424, 511, 63, GRAPHIRE },
538 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE, wacom_sys_irq }, 547 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 63, GRAPHIRE },
539 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 32, WACOM_G4, wacom_sys_irq }, 548 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 63, WACOM_G4 },
540 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 32, WACOM_G4, wacom_sys_irq }, 549 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 },
541 { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_sys_irq }, 550 { "Wacom Volito", 8, 5104, 3712, 511, 0, GRAPHIRE },
542 { "Wacom PenStation2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_sys_irq }, 551 { "Wacom PenStation2", 8, 3250, 2320, 255, 0, GRAPHIRE },
543 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_sys_irq }, 552 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 0, GRAPHIRE },
544 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 32, GRAPHIRE, wacom_sys_irq }, 553 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 0, GRAPHIRE },
545 { "Wacom PenPartner2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_sys_irq }, 554 { "Wacom PenPartner2", 8, 3250, 2320, 255, 0, GRAPHIRE },
546 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_sys_irq}, 555 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 63, INTUOS },
547 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq }, 556 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
548 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_sys_irq }, 557 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 63, INTUOS },
549 { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_sys_irq }, 558 { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 63, INTUOS },
550 { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_sys_irq}, 559 { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 63, INTUOS },
551 { "Wacom PL400", 8, 5408, 4056, 255, 32, PL, wacom_sys_irq }, 560 { "Wacom PL400", 8, 5408, 4056, 255, 0, PL },
552 { "Wacom PL500", 8, 6144, 4608, 255, 32, PL, wacom_sys_irq }, 561 { "Wacom PL500", 8, 6144, 4608, 255, 0, PL },
553 { "Wacom PL600", 8, 6126, 4604, 255, 32, PL, wacom_sys_irq }, 562 { "Wacom PL600", 8, 6126, 4604, 255, 0, PL },
554 { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL, wacom_sys_irq }, 563 { "Wacom PL600SX", 8, 6260, 5016, 255, 0, PL },
555 { "Wacom PL550", 8, 6144, 4608, 511, 32, PL, wacom_sys_irq }, 564 { "Wacom PL550", 8, 6144, 4608, 511, 0, PL },
556 { "Wacom PL800", 8, 7220, 5780, 511, 32, PL, wacom_sys_irq }, 565 { "Wacom PL800", 8, 7220, 5780, 511, 0, PL },
557 { "Wacom PL700", 8, 6758, 5406, 511, 32, PL, wacom_sys_irq }, 566 { "Wacom PL700", 8, 6758, 5406, 511, 0, PL },
558 { "Wacom PL510", 8, 6282, 4762, 511, 32, PL, wacom_sys_irq }, 567 { "Wacom PL510", 8, 6282, 4762, 511, 0, PL },
559 { "Wacom DTU710", 8, 34080, 27660, 511, 32, PL, wacom_sys_irq }, 568 { "Wacom DTU710", 8, 34080, 27660, 511, 0, PL },
560 { "Wacom DTF521", 8, 6282, 4762, 511, 32, PL, wacom_sys_irq }, 569 { "Wacom DTF521", 8, 6282, 4762, 511, 0, PL },
561 { "Wacom DTF720", 8, 6858, 5506, 511, 32, PL, wacom_sys_irq }, 570 { "Wacom DTF720", 8, 6858, 5506, 511, 0, PL },
562 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PTU, wacom_sys_irq }, 571 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 0, PTU },
563 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_sys_irq }, 572 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 63, INTUOS },
564 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq }, 573 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
565 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_sys_irq }, 574 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 63, INTUOS },
566 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_sys_irq }, 575 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 63, INTUOS },
567 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_sys_irq }, 576 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 63, INTUOS },
568 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3, wacom_sys_irq }, 577 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 63, INTUOS3S },
569 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3, wacom_sys_irq }, 578 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 63, INTUOS3 },
570 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3, wacom_sys_irq }, 579 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 63, INTUOS3 },
571 { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 15, INTUOS3L, wacom_sys_irq }, 580 { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 63, INTUOS3L },
572 { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 15, INTUOS3L, wacom_sys_irq }, 581 { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 63, INTUOS3L },
573 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 15, INTUOS3, wacom_sys_irq }, 582 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 63, INTUOS3 },
574 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ, wacom_sys_irq }, 583 { "Wacom Intuos3 4x6", 10, 31496, 19685, 1023, 15, INTUOS3S },
575 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq }, 584 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ },
585 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
576 { } 586 { }
577}; 587};
578 588
@@ -618,6 +628,7 @@ static struct usb_device_id wacom_ids[] = {
618 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) }, 628 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
619 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) }, 629 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
620 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) }, 630 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
631 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB7) },
621 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, 632 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
622 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, 633 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
623 { } 634 { }
diff --git a/drivers/usb/input/wacom_wac.h b/drivers/usb/input/wacom_wac.h
index ceae7bf59d9f..a1d9ce007970 100644
--- a/drivers/usb/input/wacom_wac.h
+++ b/drivers/usb/input/wacom_wac.h
@@ -20,6 +20,7 @@ enum {
20 PTU, 20 PTU,
21 PL, 21 PL,
22 INTUOS, 22 INTUOS,
23 INTUOS3S,
23 INTUOS3, 24 INTUOS3,
24 INTUOS3L, 25 INTUOS3L,
25 CINTIQ, 26 CINTIQ,
@@ -34,7 +35,6 @@ struct wacom_features {
34 int pressure_max; 35 int pressure_max;
35 int distance_max; 36 int distance_max;
36 int type; 37 int type;
37 usb_complete_t irq;
38}; 38};
39 39
40struct wacom_wac { 40struct wacom_wac {
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index cebb6c463bfb..6a12a943b938 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -1,8 +1,9 @@
1/* 1/*
2 * X-Box gamepad - v0.0.5 2 * X-Box gamepad - v0.0.6
3 * 3 *
4 * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de> 4 * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de>
5 * 5 * 2005 Dominic Cerquetti <binary1230@yahoo.com>
6 * 2006 Adam Buchbinder <adam.buchbinder@gmail.com>
6 * 7 *
7 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as 9 * modify it under the terms of the GNU General Public License as
@@ -30,9 +31,10 @@
30 * - Greg Kroah-Hartman - usb-skeleton driver 31 * - Greg Kroah-Hartman - usb-skeleton driver
31 * 32 *
32 * TODO: 33 * TODO:
33 * - fine tune axes 34 * - fine tune axes (especially trigger axes)
34 * - fix "analog" buttons (reported as digital now) 35 * - fix "analog" buttons (reported as digital now)
35 * - get rumble working 36 * - get rumble working
37 * - need USB IDs for other dance pads
36 * 38 *
37 * History: 39 * History:
38 * 40 *
@@ -57,25 +59,40 @@
57#include <linux/kernel.h> 59#include <linux/kernel.h>
58#include <linux/init.h> 60#include <linux/init.h>
59#include <linux/slab.h> 61#include <linux/slab.h>
62#include <linux/stat.h>
60#include <linux/module.h> 63#include <linux/module.h>
64#include <linux/moduleparam.h>
61#include <linux/smp_lock.h> 65#include <linux/smp_lock.h>
62#include <linux/usb/input.h> 66#include <linux/usb/input.h>
63 67
64#define DRIVER_VERSION "v0.0.5" 68#define DRIVER_VERSION "v0.0.6"
65#define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>" 69#define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>"
66#define DRIVER_DESC "X-Box pad driver" 70#define DRIVER_DESC "X-Box pad driver"
67 71
68#define XPAD_PKT_LEN 32 72#define XPAD_PKT_LEN 32
69 73
74/* xbox d-pads should map to buttons, as is required for DDR pads
75 but we map them to axes when possible to simplify things */
76#define MAP_DPAD_TO_BUTTONS 0
77#define MAP_DPAD_TO_AXES 1
78#define MAP_DPAD_UNKNOWN -1
79
80static int dpad_to_buttons;
81module_param(dpad_to_buttons, bool, S_IRUGO);
82MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads");
83
70static const struct xpad_device { 84static const struct xpad_device {
71 u16 idVendor; 85 u16 idVendor;
72 u16 idProduct; 86 u16 idProduct;
73 char *name; 87 char *name;
88 u8 dpad_mapping;
74} xpad_device[] = { 89} xpad_device[] = {
75 { 0x045e, 0x0202, "Microsoft X-Box pad (US)" }, 90 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", MAP_DPAD_TO_AXES },
76 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)" }, 91 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES },
77 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)" }, 92 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", MAP_DPAD_TO_AXES },
78 { 0x0000, 0x0000, "X-Box pad" } 93 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", MAP_DPAD_TO_AXES },
94 { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS },
95 { 0x0000, 0x0000, "Generic X-Box pad", MAP_DPAD_UNKNOWN }
79}; 96};
80 97
81static const signed short xpad_btn[] = { 98static const signed short xpad_btn[] = {
@@ -84,11 +101,23 @@ static const signed short xpad_btn[] = {
84 -1 /* terminating entry */ 101 -1 /* terminating entry */
85}; 102};
86 103
104/* only used if MAP_DPAD_TO_BUTTONS */
105static const signed short xpad_btn_pad[] = {
106 BTN_LEFT, BTN_RIGHT, /* d-pad left, right */
107 BTN_0, BTN_1, /* d-pad up, down (XXX names??) */
108 -1 /* terminating entry */
109};
110
87static const signed short xpad_abs[] = { 111static const signed short xpad_abs[] = {
88 ABS_X, ABS_Y, /* left stick */ 112 ABS_X, ABS_Y, /* left stick */
89 ABS_RX, ABS_RY, /* right stick */ 113 ABS_RX, ABS_RY, /* right stick */
90 ABS_Z, ABS_RZ, /* triggers left/right */ 114 ABS_Z, ABS_RZ, /* triggers left/right */
91 ABS_HAT0X, ABS_HAT0Y, /* digital pad */ 115 -1 /* terminating entry */
116};
117
118/* only used if MAP_DPAD_TO_AXES */
119static const signed short xpad_abs_pad[] = {
120 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */
92 -1 /* terminating entry */ 121 -1 /* terminating entry */
93}; 122};
94 123
@@ -100,14 +129,16 @@ static struct usb_device_id xpad_table [] = {
100MODULE_DEVICE_TABLE (usb, xpad_table); 129MODULE_DEVICE_TABLE (usb, xpad_table);
101 130
102struct usb_xpad { 131struct usb_xpad {
103 struct input_dev *dev; /* input device interface */ 132 struct input_dev *dev; /* input device interface */
104 struct usb_device *udev; /* usb device */ 133 struct usb_device *udev; /* usb device */
105 134
106 struct urb *irq_in; /* urb for interrupt in report */ 135 struct urb *irq_in; /* urb for interrupt in report */
107 unsigned char *idata; /* input data */ 136 unsigned char *idata; /* input data */
108 dma_addr_t idata_dma; 137 dma_addr_t idata_dma;
109 138
110 char phys[65]; /* physical device path */ 139 char phys[65]; /* physical device path */
140
141 int dpad_mapping; /* map d-pad to buttons or to axes */
111}; 142};
112 143
113/* 144/*
@@ -137,14 +168,21 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
137 input_report_abs(dev, ABS_RZ, data[11]); 168 input_report_abs(dev, ABS_RZ, data[11]);
138 169
139 /* digital pad */ 170 /* digital pad */
140 input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04)); 171 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) {
141 input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x02) - !!(data[2] & 0x01)); 172 input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04));
173 input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x02) - !!(data[2] & 0x01));
174 } else /* xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS */ {
175 input_report_key(dev, BTN_LEFT, data[2] & 0x04);
176 input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
177 input_report_key(dev, BTN_0, data[2] & 0x01); // up
178 input_report_key(dev, BTN_1, data[2] & 0x02); // down
179 }
142 180
143 /* start/back buttons and stick press left/right */ 181 /* start/back buttons and stick press left/right */
144 input_report_key(dev, BTN_START, (data[2] & 0x10) >> 4); 182 input_report_key(dev, BTN_START, data[2] & 0x10);
145 input_report_key(dev, BTN_BACK, (data[2] & 0x20) >> 5); 183 input_report_key(dev, BTN_BACK, data[2] & 0x20);
146 input_report_key(dev, BTN_THUMBL, (data[2] & 0x40) >> 6); 184 input_report_key(dev, BTN_THUMBL, data[2] & 0x40);
147 input_report_key(dev, BTN_THUMBR, data[2] >> 7); 185 input_report_key(dev, BTN_THUMBR, data[2] & 0x80);
148 186
149 /* "analog" buttons A, B, X, Y */ 187 /* "analog" buttons A, B, X, Y */
150 input_report_key(dev, BTN_A, data[4]); 188 input_report_key(dev, BTN_A, data[4]);
@@ -206,6 +244,28 @@ static void xpad_close (struct input_dev *dev)
206 usb_kill_urb(xpad->irq_in); 244 usb_kill_urb(xpad->irq_in);
207} 245}
208 246
247static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
248{
249 set_bit(abs, input_dev->absbit);
250
251 switch (abs) {
252 case ABS_X:
253 case ABS_Y:
254 case ABS_RX:
255 case ABS_RY: /* the two sticks */
256 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128);
257 break;
258 case ABS_Z:
259 case ABS_RZ: /* the triggers */
260 input_set_abs_params(input_dev, abs, 0, 255, 0, 0);
261 break;
262 case ABS_HAT0X:
263 case ABS_HAT0Y: /* the d-pad (only if MAP_DPAD_TO_AXES) */
264 input_set_abs_params(input_dev, abs, -1, 1, 0, 0);
265 break;
266 }
267}
268
209static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id) 269static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id)
210{ 270{
211 struct usb_device *udev = interface_to_usbdev (intf); 271 struct usb_device *udev = interface_to_usbdev (intf);
@@ -235,6 +295,9 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
235 goto fail2; 295 goto fail2;
236 296
237 xpad->udev = udev; 297 xpad->udev = udev;
298 xpad->dpad_mapping = xpad_device[i].dpad_mapping;
299 if (xpad->dpad_mapping == MAP_DPAD_UNKNOWN)
300 xpad->dpad_mapping = dpad_to_buttons;
238 xpad->dev = input_dev; 301 xpad->dev = input_dev;
239 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); 302 usb_make_path(udev, xpad->phys, sizeof(xpad->phys));
240 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); 303 strlcat(xpad->phys, "/input0", sizeof(xpad->phys));
@@ -249,32 +312,19 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
249 312
250 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 313 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
251 314
315 /* set up buttons */
252 for (i = 0; xpad_btn[i] >= 0; i++) 316 for (i = 0; xpad_btn[i] >= 0; i++)
253 set_bit(xpad_btn[i], input_dev->keybit); 317 set_bit(xpad_btn[i], input_dev->keybit);
318 if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS)
319 for (i = 0; xpad_btn_pad[i] >= 0; i++)
320 set_bit(xpad_btn_pad[i], input_dev->keybit);
254 321
255 for (i = 0; xpad_abs[i] >= 0; i++) { 322 /* set up axes */
256 323 for (i = 0; xpad_abs[i] >= 0; i++)
257 signed short t = xpad_abs[i]; 324 xpad_set_up_abs(input_dev, xpad_abs[i]);
258 325 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES)
259 set_bit(t, input_dev->absbit); 326 for (i = 0; xpad_abs_pad[i] >= 0; i++)
260 327 xpad_set_up_abs(input_dev, xpad_abs_pad[i]);
261 switch (t) {
262 case ABS_X:
263 case ABS_Y:
264 case ABS_RX:
265 case ABS_RY: /* the two sticks */
266 input_set_abs_params(input_dev, t, -32768, 32767, 16, 128);
267 break;
268 case ABS_Z:
269 case ABS_RZ: /* the triggers */
270 input_set_abs_params(input_dev, t, 0, 255, 0, 0);
271 break;
272 case ABS_HAT0X:
273 case ABS_HAT0Y: /* the d-pad */
274 input_set_abs_params(input_dev, t, -1, 1, 0, 0);
275 break;
276 }
277 }
278 328
279 ep_irq_in = &intf->cur_altsetting->endpoint[0].desc; 329 ep_irq_in = &intf->cur_altsetting->endpoint[0].desc;
280 usb_fill_int_urb(xpad->irq_in, udev, 330 usb_fill_int_urb(xpad->irq_in, udev,
@@ -305,7 +355,8 @@ static void xpad_disconnect(struct usb_interface *intf)
305 usb_kill_urb(xpad->irq_in); 355 usb_kill_urb(xpad->irq_in);
306 input_unregister_device(xpad->dev); 356 input_unregister_device(xpad->dev);
307 usb_free_urb(xpad->irq_in); 357 usb_free_urb(xpad->irq_in);
308 usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); 358 usb_buffer_free(interface_to_usbdev(intf), XPAD_PKT_LEN,
359 xpad->idata, xpad->idata_dma);
309 kfree(xpad); 360 kfree(xpad);
310 } 361 }
311} 362}
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index c29658f69e2a..a74bf8617e7f 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -223,6 +223,16 @@ config USB_LD
223 To compile this driver as a module, choose M here: the 223 To compile this driver as a module, choose M here: the
224 module will be called ldusb. 224 module will be called ldusb.
225 225
226config USB_TRANCEVIBRATOR
227 tristate "PlayStation 2 Trance Vibrator driver support"
228 depends on USB
229 help
230 Say Y here if you want to connect a PlayStation 2 Trance Vibrator
231 device to your computer's USB port.
232
233 To compile this driver as a module, choose M here: the
234 module will be called trancevibrator.
235
226config USB_TEST 236config USB_TEST
227 tristate "USB testing driver (DEVELOPMENT)" 237 tristate "USB testing driver (DEVELOPMENT)"
228 depends on USB && USB_DEVICEFS && EXPERIMENTAL 238 depends on USB && USB_DEVICEFS && EXPERIMENTAL
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 2be70fa259bf..11dc59540cda 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_USB_PHIDGETMOTORCONTROL) += phidgetmotorcontrol.o
21obj-$(CONFIG_USB_PHIDGETSERVO) += phidgetservo.o 21obj-$(CONFIG_USB_PHIDGETSERVO) += phidgetservo.o
22obj-$(CONFIG_USB_RIO500) += rio500.o 22obj-$(CONFIG_USB_RIO500) += rio500.o
23obj-$(CONFIG_USB_TEST) += usbtest.o 23obj-$(CONFIG_USB_TEST) += usbtest.o
24obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
24obj-$(CONFIG_USB_USS720) += uss720.o 25obj-$(CONFIG_USB_USS720) += uss720.o
25 26
26obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ 27obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index aecd633fe9f6..af2934e016a7 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -370,7 +370,8 @@ static int adu_release(struct inode *inode, struct file *file)
370 retval = adu_release_internal(dev); 370 retval = adu_release_internal(dev);
371 371
372exit: 372exit:
373 up(&dev->sem); 373 if (dev)
374 up(&dev->sem);
374 dbg(2," %s : leave, return value %d", __FUNCTION__, retval); 375 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
375 return retval; 376 return retval;
376} 377}
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index 0eb26a26115b..9b591b8b9369 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -513,8 +513,6 @@ static void ftdi_elan_respond_work(void *data)
513 ftdi->disconnected += 1; 513 ftdi->disconnected += 1;
514 } else if (retval == -ENODEV) { 514 } else if (retval == -ENODEV) {
515 ftdi->disconnected += 1; 515 ftdi->disconnected += 1;
516 } else if (retval == -ENODEV) {
517 ftdi->disconnected += 1;
518 } else if (retval == -EILSEQ) { 516 } else if (retval == -EILSEQ) {
519 ftdi->disconnected += 1; 517 ftdi->disconnected += 1;
520 } else { 518 } else {
@@ -1186,11 +1184,8 @@ static ssize_t ftdi_elan_write(struct file *file,
1186 int retval = 0; 1184 int retval = 0;
1187 struct urb *urb; 1185 struct urb *urb;
1188 char *buf; 1186 char *buf;
1189 char data[30 *3 + 4]; 1187 struct usb_ftdi *ftdi = file->private_data;
1190 char *d = data; 1188
1191 const char __user *s = user_buffer;
1192 int m = (sizeof(data) - 1) / 3;
1193 struct usb_ftdi *ftdi = (struct usb_ftdi *)file->private_data;
1194 if (ftdi->disconnected > 0) { 1189 if (ftdi->disconnected > 0) {
1195 return -ENODEV; 1190 return -ENODEV;
1196 } 1191 }
@@ -1220,27 +1215,18 @@ static ssize_t ftdi_elan_write(struct file *file,
1220 if (retval) { 1215 if (retval) {
1221 dev_err(&ftdi->udev->dev, "failed submitting write urb, error %" 1216 dev_err(&ftdi->udev->dev, "failed submitting write urb, error %"
1222 "d\n", retval); 1217 "d\n", retval);
1223 goto error_4; 1218 goto error_3;
1224 } 1219 }
1225 usb_free_urb(urb); 1220 usb_free_urb(urb);
1226 exit:; 1221
1227 if (count > m) { 1222exit:
1228 int I = m - 1;
1229 while (I-- > 0) {
1230 d += sprintf(d, " %02X", 0x000000FF & *s++);
1231 }
1232 d += sprintf(d, " ..");
1233 } else {
1234 int I = count;
1235 while (I-- > 0) {
1236 d += sprintf(d, " %02X", 0x000000FF & *s++);
1237 }
1238 }
1239 return count; 1223 return count;
1240 error_4: error_3:usb_buffer_free(ftdi->udev, count, buf, 1224error_3:
1241 urb->transfer_dma); 1225 usb_buffer_free(ftdi->udev, count, buf, urb->transfer_dma);
1242 error_2:usb_free_urb(urb); 1226error_2:
1243 error_1:return retval; 1227 usb_free_urb(urb);
1228error_1:
1229 return retval;
1244} 1230}
1245 1231
1246static struct file_operations ftdi_elan_fops = { 1232static struct file_operations ftdi_elan_fops = {
diff --git a/drivers/usb/input/trancevibrator.c b/drivers/usb/misc/trancevibrator.c
index 33cd91d11eca..33cd91d11eca 100644
--- a/drivers/usb/input/trancevibrator.c
+++ b/drivers/usb/misc/trancevibrator.c
diff --git a/drivers/usb/net/Kconfig b/drivers/usb/net/Kconfig
index 054059632a21..454a186b64ad 100644
--- a/drivers/usb/net/Kconfig
+++ b/drivers/usb/net/Kconfig
@@ -207,6 +207,14 @@ config USB_NET_PLUSB
207 Choose this option if you're using a host-to-host cable 207 Choose this option if you're using a host-to-host cable
208 with one of these chips. 208 with one of these chips.
209 209
210config USB_NET_MCS7830
211 tristate "MosChip MCS7830 based Ethernet adapters"
212 depends on USB_USBNET
213 help
214 Choose this option if you're using a 10/100 Ethernet USB2
215 adapter based on the MosChip 7830 controller. This includes
216 adapters marketed under the DeLOCK brand.
217
210config USB_NET_RNDIS_HOST 218config USB_NET_RNDIS_HOST
211 tristate "Host for RNDIS devices (EXPERIMENTAL)" 219 tristate "Host for RNDIS devices (EXPERIMENTAL)"
212 depends on USB_USBNET && EXPERIMENTAL 220 depends on USB_USBNET && EXPERIMENTAL
diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile
index 160f19dbdf12..7b51964de171 100644
--- a/drivers/usb/net/Makefile
+++ b/drivers/usb/net/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_USB_NET_PLUSB) += plusb.o
14obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o 14obj-$(CONFIG_USB_NET_RNDIS_HOST) += rndis_host.o
15obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o 15obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o
16obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o 16obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o
17obj-$(CONFIG_USB_NET_MCS7830) += mcs7830.o
17obj-$(CONFIG_USB_USBNET) += usbnet.o 18obj-$(CONFIG_USB_USBNET) += usbnet.o
18 19
19ifeq ($(CONFIG_USB_DEBUG),y) 20ifeq ($(CONFIG_USB_DEBUG),y)
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c
index c73dd224aa76..881841e600de 100644
--- a/drivers/usb/net/asix.c
+++ b/drivers/usb/net/asix.c
@@ -569,10 +569,12 @@ static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
569 struct usbnet *dev = netdev_priv(netdev); 569 struct usbnet *dev = netdev_priv(netdev);
570 u16 res; 570 u16 res;
571 571
572 mutex_lock(&dev->phy_mutex);
572 asix_set_sw_mii(dev); 573 asix_set_sw_mii(dev);
573 asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, 574 asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id,
574 (__u16)loc, 2, (u16 *)&res); 575 (__u16)loc, 2, (u16 *)&res);
575 asix_set_hw_mii(dev); 576 asix_set_hw_mii(dev);
577 mutex_unlock(&dev->phy_mutex);
576 578
577 devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res & 0xffff)); 579 devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res & 0xffff));
578 580
@@ -586,10 +588,12 @@ asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
586 u16 res = cpu_to_le16(val); 588 u16 res = cpu_to_le16(val);
587 589
588 devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val); 590 devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val);
591 mutex_lock(&dev->phy_mutex);
589 asix_set_sw_mii(dev); 592 asix_set_sw_mii(dev);
590 asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, 593 asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id,
591 (__u16)loc, 2, (u16 *)&res); 594 (__u16)loc, 2, (u16 *)&res);
592 asix_set_hw_mii(dev); 595 asix_set_hw_mii(dev);
596 mutex_unlock(&dev->phy_mutex);
593} 597}
594 598
595/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ 599/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */
@@ -700,32 +704,6 @@ static void asix_get_drvinfo (struct net_device *net,
700 info->eedump_len = data->eeprom_len; 704 info->eedump_len = data->eeprom_len;
701} 705}
702 706
703static int asix_get_settings(struct net_device *net, struct ethtool_cmd *cmd)
704{
705 struct usbnet *dev = netdev_priv(net);
706
707 return mii_ethtool_gset(&dev->mii,cmd);
708}
709
710static int asix_set_settings(struct net_device *net, struct ethtool_cmd *cmd)
711{
712 struct usbnet *dev = netdev_priv(net);
713 int res = mii_ethtool_sset(&dev->mii,cmd);
714
715 /* link speed/duplex might have changed */
716 if (dev->driver_info->link_reset)
717 dev->driver_info->link_reset(dev);
718
719 return res;
720}
721
722static int asix_nway_reset(struct net_device *net)
723{
724 struct usbnet *dev = netdev_priv(net);
725
726 return mii_nway_restart(&dev->mii);
727}
728
729static u32 asix_get_link(struct net_device *net) 707static u32 asix_get_link(struct net_device *net)
730{ 708{
731 struct usbnet *dev = netdev_priv(net); 709 struct usbnet *dev = netdev_priv(net);
@@ -746,15 +724,15 @@ static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
746static struct ethtool_ops ax88172_ethtool_ops = { 724static struct ethtool_ops ax88172_ethtool_ops = {
747 .get_drvinfo = asix_get_drvinfo, 725 .get_drvinfo = asix_get_drvinfo,
748 .get_link = asix_get_link, 726 .get_link = asix_get_link,
749 .nway_reset = asix_nway_reset,
750 .get_msglevel = usbnet_get_msglevel, 727 .get_msglevel = usbnet_get_msglevel,
751 .set_msglevel = usbnet_set_msglevel, 728 .set_msglevel = usbnet_set_msglevel,
752 .get_wol = asix_get_wol, 729 .get_wol = asix_get_wol,
753 .set_wol = asix_set_wol, 730 .set_wol = asix_set_wol,
754 .get_eeprom_len = asix_get_eeprom_len, 731 .get_eeprom_len = asix_get_eeprom_len,
755 .get_eeprom = asix_get_eeprom, 732 .get_eeprom = asix_get_eeprom,
756 .get_settings = asix_get_settings, 733 .get_settings = usbnet_get_settings,
757 .set_settings = asix_set_settings, 734 .set_settings = usbnet_set_settings,
735 .nway_reset = usbnet_nway_reset,
758}; 736};
759 737
760static void ax88172_set_multicast(struct net_device *net) 738static void ax88172_set_multicast(struct net_device *net)
@@ -885,15 +863,15 @@ out1:
885static struct ethtool_ops ax88772_ethtool_ops = { 863static struct ethtool_ops ax88772_ethtool_ops = {
886 .get_drvinfo = asix_get_drvinfo, 864 .get_drvinfo = asix_get_drvinfo,
887 .get_link = asix_get_link, 865 .get_link = asix_get_link,
888 .nway_reset = asix_nway_reset,
889 .get_msglevel = usbnet_get_msglevel, 866 .get_msglevel = usbnet_get_msglevel,
890 .set_msglevel = usbnet_set_msglevel, 867 .set_msglevel = usbnet_set_msglevel,
891 .get_wol = asix_get_wol, 868 .get_wol = asix_get_wol,
892 .set_wol = asix_set_wol, 869 .set_wol = asix_set_wol,
893 .get_eeprom_len = asix_get_eeprom_len, 870 .get_eeprom_len = asix_get_eeprom_len,
894 .get_eeprom = asix_get_eeprom, 871 .get_eeprom = asix_get_eeprom,
895 .get_settings = asix_get_settings, 872 .get_settings = usbnet_get_settings,
896 .set_settings = asix_set_settings, 873 .set_settings = usbnet_set_settings,
874 .nway_reset = usbnet_nway_reset,
897}; 875};
898 876
899static int ax88772_link_reset(struct usbnet *dev) 877static int ax88772_link_reset(struct usbnet *dev)
@@ -1046,15 +1024,15 @@ out1:
1046static struct ethtool_ops ax88178_ethtool_ops = { 1024static struct ethtool_ops ax88178_ethtool_ops = {
1047 .get_drvinfo = asix_get_drvinfo, 1025 .get_drvinfo = asix_get_drvinfo,
1048 .get_link = asix_get_link, 1026 .get_link = asix_get_link,
1049 .nway_reset = asix_nway_reset,
1050 .get_msglevel = usbnet_get_msglevel, 1027 .get_msglevel = usbnet_get_msglevel,
1051 .set_msglevel = usbnet_set_msglevel, 1028 .set_msglevel = usbnet_set_msglevel,
1052 .get_wol = asix_get_wol, 1029 .get_wol = asix_get_wol,
1053 .set_wol = asix_set_wol, 1030 .set_wol = asix_set_wol,
1054 .get_eeprom_len = asix_get_eeprom_len, 1031 .get_eeprom_len = asix_get_eeprom_len,
1055 .get_eeprom = asix_get_eeprom, 1032 .get_eeprom = asix_get_eeprom,
1056 .get_settings = asix_get_settings, 1033 .get_settings = usbnet_get_settings,
1057 .set_settings = asix_set_settings, 1034 .set_settings = usbnet_set_settings,
1035 .nway_reset = usbnet_nway_reset,
1058}; 1036};
1059 1037
1060static int marvell_phy_init(struct usbnet *dev) 1038static int marvell_phy_init(struct usbnet *dev)
diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c
index 82ce0358d9a3..f6971b88349d 100644
--- a/drivers/usb/net/cdc_ether.c
+++ b/drivers/usb/net/cdc_ether.c
@@ -498,7 +498,7 @@ static struct usb_driver cdc_driver = {
498 498
499static int __init cdc_init(void) 499static int __init cdc_init(void)
500{ 500{
501 BUG_ON((sizeof(((struct usbnet *)0)->data) 501 BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data)
502 < sizeof(struct cdc_state))); 502 < sizeof(struct cdc_state)));
503 503
504 return usb_register(&cdc_driver); 504 return usb_register(&cdc_driver);
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index 957d4ad316f9..7c906a43e497 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -65,16 +65,6 @@
65 65
66#undef DEBUG 66#undef DEBUG
67 67
68#ifdef DEBUG
69#define kaweth_dbg(format, arg...) printk(KERN_DEBUG __FILE__ ": " format "\n" ,##arg)
70#else
71#define kaweth_dbg(format, arg...) do {} while (0)
72#endif
73#define kaweth_err(format, arg...) printk(KERN_ERR __FILE__ ": " format "\n" ,##arg)
74#define kaweth_info(format, arg...) printk(KERN_INFO __FILE__ ": " format "\n" , ##arg)
75#define kaweth_warn(format, arg...) printk(KERN_WARNING __FILE__ ": " format "\n" , ##arg)
76
77
78#include "kawethfw.h" 68#include "kawethfw.h"
79 69
80#define KAWETH_MTU 1514 70#define KAWETH_MTU 1514
@@ -86,6 +76,9 @@
86 76
87#define KAWETH_STATUS_BROKEN 0x0000001 77#define KAWETH_STATUS_BROKEN 0x0000001
88#define KAWETH_STATUS_CLOSING 0x0000002 78#define KAWETH_STATUS_CLOSING 0x0000002
79#define KAWETH_STATUS_SUSPENDING 0x0000004
80
81#define KAWETH_STATUS_BLOCKED (KAWETH_STATUS_CLOSING | KAWETH_STATUS_SUSPENDING)
89 82
90#define KAWETH_PACKET_FILTER_PROMISCUOUS 0x01 83#define KAWETH_PACKET_FILTER_PROMISCUOUS 0x01
91#define KAWETH_PACKET_FILTER_ALL_MULTICAST 0x02 84#define KAWETH_PACKET_FILTER_ALL_MULTICAST 0x02
@@ -112,6 +105,8 @@
112#define STATE_MASK 0x40 105#define STATE_MASK 0x40
113#define STATE_SHIFT 5 106#define STATE_SHIFT 5
114 107
108#define IS_BLOCKED(s) (s & KAWETH_STATUS_BLOCKED)
109
115 110
116MODULE_AUTHOR("Michael Zappe <zapman@interlan.net>, Stephane Alnet <stephane@u-picardie.fr>, Brad Hards <bhards@bigpond.net.au> and Oliver Neukum <oliver@neukum.org>"); 111MODULE_AUTHOR("Michael Zappe <zapman@interlan.net>, Stephane Alnet <stephane@u-picardie.fr>, Brad Hards <bhards@bigpond.net.au> and Oliver Neukum <oliver@neukum.org>");
117MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver"); 112MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver");
@@ -128,6 +123,8 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev,
128 unsigned int pipe, 123 unsigned int pipe,
129 struct usb_ctrlrequest *cmd, void *data, 124 struct usb_ctrlrequest *cmd, void *data,
130 int len, int timeout); 125 int len, int timeout);
126static int kaweth_suspend(struct usb_interface *intf, pm_message_t message);
127static int kaweth_resume(struct usb_interface *intf);
131 128
132/**************************************************************** 129/****************************************************************
133 * usb_device_id 130 * usb_device_id
@@ -179,6 +176,8 @@ static struct usb_driver kaweth_driver = {
179 .name = driver_name, 176 .name = driver_name,
180 .probe = kaweth_probe, 177 .probe = kaweth_probe,
181 .disconnect = kaweth_disconnect, 178 .disconnect = kaweth_disconnect,
179 .suspend = kaweth_suspend,
180 .resume = kaweth_resume,
182 .id_table = usb_klsi_table, 181 .id_table = usb_klsi_table,
183}; 182};
184 183
@@ -222,6 +221,7 @@ struct kaweth_device
222 int suspend_lowmem_rx; 221 int suspend_lowmem_rx;
223 int suspend_lowmem_ctrl; 222 int suspend_lowmem_ctrl;
224 int linkstate; 223 int linkstate;
224 int opened;
225 struct work_struct lowmem_work; 225 struct work_struct lowmem_work;
226 226
227 struct usb_device *dev; 227 struct usb_device *dev;
@@ -265,17 +265,17 @@ static int kaweth_control(struct kaweth_device *kaweth,
265{ 265{
266 struct usb_ctrlrequest *dr; 266 struct usb_ctrlrequest *dr;
267 267
268 kaweth_dbg("kaweth_control()"); 268 dbg("kaweth_control()");
269 269
270 if(in_interrupt()) { 270 if(in_interrupt()) {
271 kaweth_dbg("in_interrupt()"); 271 dbg("in_interrupt()");
272 return -EBUSY; 272 return -EBUSY;
273 } 273 }
274 274
275 dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); 275 dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
276 276
277 if (!dr) { 277 if (!dr) {
278 kaweth_dbg("kmalloc() failed"); 278 dbg("kmalloc() failed");
279 return -ENOMEM; 279 return -ENOMEM;
280 } 280 }
281 281
@@ -300,7 +300,7 @@ static int kaweth_read_configuration(struct kaweth_device *kaweth)
300{ 300{
301 int retval; 301 int retval;
302 302
303 kaweth_dbg("Reading kaweth configuration"); 303 dbg("Reading kaweth configuration");
304 304
305 retval = kaweth_control(kaweth, 305 retval = kaweth_control(kaweth,
306 usb_rcvctrlpipe(kaweth->dev, 0), 306 usb_rcvctrlpipe(kaweth->dev, 0),
@@ -322,7 +322,7 @@ static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size)
322{ 322{
323 int retval; 323 int retval;
324 324
325 kaweth_dbg("Setting URB size to %d", (unsigned)urb_size); 325 dbg("Setting URB size to %d", (unsigned)urb_size);
326 326
327 retval = kaweth_control(kaweth, 327 retval = kaweth_control(kaweth,
328 usb_sndctrlpipe(kaweth->dev, 0), 328 usb_sndctrlpipe(kaweth->dev, 0),
@@ -344,7 +344,7 @@ static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait)
344{ 344{
345 int retval; 345 int retval;
346 346
347 kaweth_dbg("Set SOFS wait to %d", (unsigned)sofs_wait); 347 dbg("Set SOFS wait to %d", (unsigned)sofs_wait);
348 348
349 retval = kaweth_control(kaweth, 349 retval = kaweth_control(kaweth,
350 usb_sndctrlpipe(kaweth->dev, 0), 350 usb_sndctrlpipe(kaweth->dev, 0),
@@ -367,7 +367,7 @@ static int kaweth_set_receive_filter(struct kaweth_device *kaweth,
367{ 367{
368 int retval; 368 int retval;
369 369
370 kaweth_dbg("Set receive filter to %d", (unsigned)receive_filter); 370 dbg("Set receive filter to %d", (unsigned)receive_filter);
371 371
372 retval = kaweth_control(kaweth, 372 retval = kaweth_control(kaweth,
373 usb_sndctrlpipe(kaweth->dev, 0), 373 usb_sndctrlpipe(kaweth->dev, 0),
@@ -392,7 +392,7 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
392 __u8 type) 392 __u8 type)
393{ 393{
394 if(data_len > KAWETH_FIRMWARE_BUF_SIZE) { 394 if(data_len > KAWETH_FIRMWARE_BUF_SIZE) {
395 kaweth_err("Firmware too big: %d", data_len); 395 err("Firmware too big: %d", data_len);
396 return -ENOSPC; 396 return -ENOSPC;
397 } 397 }
398 398
@@ -403,13 +403,13 @@ static int kaweth_download_firmware(struct kaweth_device *kaweth,
403 kaweth->firmware_buf[4] = type; 403 kaweth->firmware_buf[4] = type;
404 kaweth->firmware_buf[5] = interrupt; 404 kaweth->firmware_buf[5] = interrupt;
405 405
406 kaweth_dbg("High: %i, Low:%i", kaweth->firmware_buf[3], 406 dbg("High: %i, Low:%i", kaweth->firmware_buf[3],
407 kaweth->firmware_buf[2]); 407 kaweth->firmware_buf[2]);
408 408
409 kaweth_dbg("Downloading firmware at %p to kaweth device at %p", 409 dbg("Downloading firmware at %p to kaweth device at %p",
410 data, 410 data,
411 kaweth); 411 kaweth);
412 kaweth_dbg("Firmware length: %d", data_len); 412 dbg("Firmware length: %d", data_len);
413 413
414 return kaweth_control(kaweth, 414 return kaweth_control(kaweth,
415 usb_sndctrlpipe(kaweth->dev, 0), 415 usb_sndctrlpipe(kaweth->dev, 0),
@@ -437,7 +437,7 @@ static int kaweth_trigger_firmware(struct kaweth_device *kaweth,
437 kaweth->firmware_buf[6] = 0x00; 437 kaweth->firmware_buf[6] = 0x00;
438 kaweth->firmware_buf[7] = 0x00; 438 kaweth->firmware_buf[7] = 0x00;
439 439
440 kaweth_dbg("Triggering firmware"); 440 dbg("Triggering firmware");
441 441
442 return kaweth_control(kaweth, 442 return kaweth_control(kaweth,
443 usb_sndctrlpipe(kaweth->dev, 0), 443 usb_sndctrlpipe(kaweth->dev, 0),
@@ -457,7 +457,7 @@ static int kaweth_reset(struct kaweth_device *kaweth)
457{ 457{
458 int result; 458 int result;
459 459
460 kaweth_dbg("kaweth_reset(%p)", kaweth); 460 dbg("kaweth_reset(%p)", kaweth);
461 result = kaweth_control(kaweth, 461 result = kaweth_control(kaweth,
462 usb_sndctrlpipe(kaweth->dev, 0), 462 usb_sndctrlpipe(kaweth->dev, 0),
463 USB_REQ_SET_CONFIGURATION, 463 USB_REQ_SET_CONFIGURATION,
@@ -470,7 +470,7 @@ static int kaweth_reset(struct kaweth_device *kaweth)
470 470
471 mdelay(10); 471 mdelay(10);
472 472
473 kaweth_dbg("kaweth_reset() returns %d.",result); 473 dbg("kaweth_reset() returns %d.",result);
474 474
475 return result; 475 return result;
476} 476}
@@ -534,7 +534,7 @@ static void kaweth_resubmit_tl(void *d)
534{ 534{
535 struct kaweth_device *kaweth = (struct kaweth_device *)d; 535 struct kaweth_device *kaweth = (struct kaweth_device *)d;
536 536
537 if (kaweth->status | KAWETH_STATUS_CLOSING) 537 if (IS_BLOCKED(kaweth->status))
538 return; 538 return;
539 539
540 if (kaweth->suspend_lowmem_rx) 540 if (kaweth->suspend_lowmem_rx)
@@ -568,7 +568,7 @@ static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth,
568 kaweth->suspend_lowmem_rx = 1; 568 kaweth->suspend_lowmem_rx = 1;
569 schedule_delayed_work(&kaweth->lowmem_work, HZ/4); 569 schedule_delayed_work(&kaweth->lowmem_work, HZ/4);
570 } 570 }
571 kaweth_err("resubmitting rx_urb %d failed", result); 571 err("resubmitting rx_urb %d failed", result);
572 } else { 572 } else {
573 kaweth->suspend_lowmem_rx = 0; 573 kaweth->suspend_lowmem_rx = 0;
574 } 574 }
@@ -601,11 +601,15 @@ static void kaweth_usb_receive(struct urb *urb)
601 return; 601 return;
602 } 602 }
603 603
604 if (kaweth->status & KAWETH_STATUS_CLOSING) 604 spin_lock(&kaweth->device_lock);
605 if (IS_BLOCKED(kaweth->status)) {
606 spin_unlock(&kaweth->device_lock);
605 return; 607 return;
608 }
609 spin_unlock(&kaweth->device_lock);
606 610
607 if(urb->status && urb->status != -EREMOTEIO && count != 1) { 611 if(urb->status && urb->status != -EREMOTEIO && count != 1) {
608 kaweth_err("%s RX status: %d count: %d packet_len: %d", 612 err("%s RX status: %d count: %d packet_len: %d",
609 net->name, 613 net->name,
610 urb->status, 614 urb->status,
611 count, 615 count,
@@ -616,9 +620,9 @@ static void kaweth_usb_receive(struct urb *urb)
616 620
617 if(kaweth->net && (count > 2)) { 621 if(kaweth->net && (count > 2)) {
618 if(pkt_len > (count - 2)) { 622 if(pkt_len > (count - 2)) {
619 kaweth_err("Packet length too long for USB frame (pkt_len: %x, count: %x)",pkt_len, count); 623 err("Packet length too long for USB frame (pkt_len: %x, count: %x)",pkt_len, count);
620 kaweth_err("Packet len & 2047: %x", pkt_len & 2047); 624 err("Packet len & 2047: %x", pkt_len & 2047);
621 kaweth_err("Count 2: %x", count2); 625 err("Count 2: %x", count2);
622 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); 626 kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC);
623 return; 627 return;
624 } 628 }
@@ -655,7 +659,7 @@ static int kaweth_open(struct net_device *net)
655 struct kaweth_device *kaweth = netdev_priv(net); 659 struct kaweth_device *kaweth = netdev_priv(net);
656 int res; 660 int res;
657 661
658 kaweth_dbg("Opening network device."); 662 dbg("Opening network device.");
659 663
660 res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL); 664 res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL);
661 if (res) 665 if (res)
@@ -678,6 +682,7 @@ static int kaweth_open(struct net_device *net)
678 usb_kill_urb(kaweth->rx_urb); 682 usb_kill_urb(kaweth->rx_urb);
679 return -EIO; 683 return -EIO;
680 } 684 }
685 kaweth->opened = 1;
681 686
682 netif_start_queue(net); 687 netif_start_queue(net);
683 688
@@ -688,14 +693,8 @@ static int kaweth_open(struct net_device *net)
688/**************************************************************** 693/****************************************************************
689 * kaweth_close 694 * kaweth_close
690 ****************************************************************/ 695 ****************************************************************/
691static int kaweth_close(struct net_device *net) 696static void kaweth_kill_urbs(struct kaweth_device *kaweth)
692{ 697{
693 struct kaweth_device *kaweth = netdev_priv(net);
694
695 netif_stop_queue(net);
696
697 kaweth->status |= KAWETH_STATUS_CLOSING;
698
699 usb_kill_urb(kaweth->irq_urb); 698 usb_kill_urb(kaweth->irq_urb);
700 usb_kill_urb(kaweth->rx_urb); 699 usb_kill_urb(kaweth->rx_urb);
701 usb_kill_urb(kaweth->tx_urb); 700 usb_kill_urb(kaweth->tx_urb);
@@ -706,6 +705,21 @@ static int kaweth_close(struct net_device *net)
706 we hit them again */ 705 we hit them again */
707 usb_kill_urb(kaweth->irq_urb); 706 usb_kill_urb(kaweth->irq_urb);
708 usb_kill_urb(kaweth->rx_urb); 707 usb_kill_urb(kaweth->rx_urb);
708}
709
710/****************************************************************
711 * kaweth_close
712 ****************************************************************/
713static int kaweth_close(struct net_device *net)
714{
715 struct kaweth_device *kaweth = netdev_priv(net);
716
717 netif_stop_queue(net);
718 kaweth->opened = 0;
719
720 kaweth->status |= KAWETH_STATUS_CLOSING;
721
722 kaweth_kill_urbs(kaweth);
709 723
710 kaweth->status &= ~KAWETH_STATUS_CLOSING; 724 kaweth->status &= ~KAWETH_STATUS_CLOSING;
711 725
@@ -732,7 +746,7 @@ static void kaweth_usb_transmit_complete(struct urb *urb)
732 746
733 if (unlikely(urb->status != 0)) 747 if (unlikely(urb->status != 0))
734 if (urb->status != -ENOENT) 748 if (urb->status != -ENOENT)
735 kaweth_dbg("%s: TX status %d.", kaweth->net->name, urb->status); 749 dbg("%s: TX status %d.", kaweth->net->name, urb->status);
736 750
737 netif_wake_queue(kaweth->net); 751 netif_wake_queue(kaweth->net);
738 dev_kfree_skb_irq(skb); 752 dev_kfree_skb_irq(skb);
@@ -752,6 +766,9 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net)
752 766
753 kaweth_async_set_rx_mode(kaweth); 767 kaweth_async_set_rx_mode(kaweth);
754 netif_stop_queue(net); 768 netif_stop_queue(net);
769 if (IS_BLOCKED(kaweth->status)) {
770 goto skip;
771 }
755 772
756 /* We now decide whether we can put our special header into the sk_buff */ 773 /* We now decide whether we can put our special header into the sk_buff */
757 if (skb_cloned(skb) || skb_headroom(skb) < 2) { 774 if (skb_cloned(skb) || skb_headroom(skb) < 2) {
@@ -783,7 +800,8 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net)
783 800
784 if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) 801 if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC)))
785 { 802 {
786 kaweth_warn("kaweth failed tx_urb %d", res); 803 warn("kaweth failed tx_urb %d", res);
804skip:
787 kaweth->stats.tx_errors++; 805 kaweth->stats.tx_errors++;
788 806
789 netif_start_queue(net); 807 netif_start_queue(net);
@@ -812,7 +830,7 @@ static void kaweth_set_rx_mode(struct net_device *net)
812 KAWETH_PACKET_FILTER_BROADCAST | 830 KAWETH_PACKET_FILTER_BROADCAST |
813 KAWETH_PACKET_FILTER_MULTICAST; 831 KAWETH_PACKET_FILTER_MULTICAST;
814 832
815 kaweth_dbg("Setting Rx mode to %d", packet_filter_bitmap); 833 dbg("Setting Rx mode to %d", packet_filter_bitmap);
816 834
817 netif_stop_queue(net); 835 netif_stop_queue(net);
818 836
@@ -850,10 +868,10 @@ static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth)
850 KAWETH_CONTROL_TIMEOUT); 868 KAWETH_CONTROL_TIMEOUT);
851 869
852 if(result < 0) { 870 if(result < 0) {
853 kaweth_err("Failed to set Rx mode: %d", result); 871 err("Failed to set Rx mode: %d", result);
854 } 872 }
855 else { 873 else {
856 kaweth_dbg("Set Rx mode to %d", packet_filter_bitmap); 874 dbg("Set Rx mode to %d", packet_filter_bitmap);
857 } 875 }
858 } 876 }
859} 877}
@@ -874,7 +892,7 @@ static void kaweth_tx_timeout(struct net_device *net)
874{ 892{
875 struct kaweth_device *kaweth = netdev_priv(net); 893 struct kaweth_device *kaweth = netdev_priv(net);
876 894
877 kaweth_warn("%s: Tx timed out. Resetting.", net->name); 895 warn("%s: Tx timed out. Resetting.", net->name);
878 kaweth->stats.tx_errors++; 896 kaweth->stats.tx_errors++;
879 net->trans_start = jiffies; 897 net->trans_start = jiffies;
880 898
@@ -882,6 +900,42 @@ static void kaweth_tx_timeout(struct net_device *net)
882} 900}
883 901
884/**************************************************************** 902/****************************************************************
903 * kaweth_suspend
904 ****************************************************************/
905static int kaweth_suspend(struct usb_interface *intf, pm_message_t message)
906{
907 struct kaweth_device *kaweth = usb_get_intfdata(intf);
908 unsigned long flags;
909
910 spin_lock_irqsave(&kaweth->device_lock, flags);
911 kaweth->status |= KAWETH_STATUS_SUSPENDING;
912 spin_unlock_irqrestore(&kaweth->device_lock, flags);
913
914 kaweth_kill_urbs(kaweth);
915 return 0;
916}
917
918/****************************************************************
919 * kaweth_resume
920 ****************************************************************/
921static int kaweth_resume(struct usb_interface *intf)
922{
923 struct kaweth_device *kaweth = usb_get_intfdata(intf);
924 unsigned long flags;
925
926 spin_lock_irqsave(&kaweth->device_lock, flags);
927 kaweth->status &= ~KAWETH_STATUS_SUSPENDING;
928 spin_unlock_irqrestore(&kaweth->device_lock, flags);
929
930 if (!kaweth->opened)
931 return 0;
932 kaweth_resubmit_rx_urb(kaweth, GFP_NOIO);
933 kaweth_resubmit_int_urb(kaweth, GFP_NOIO);
934
935 return 0;
936}
937
938/****************************************************************
885 * kaweth_probe 939 * kaweth_probe
886 ****************************************************************/ 940 ****************************************************************/
887static int kaweth_probe( 941static int kaweth_probe(
@@ -895,15 +949,15 @@ static int kaweth_probe(
895 const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 949 const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
896 int result = 0; 950 int result = 0;
897 951
898 kaweth_dbg("Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x", 952 dbg("Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x",
899 dev->devnum, 953 dev->devnum,
900 le16_to_cpu(dev->descriptor.idVendor), 954 le16_to_cpu(dev->descriptor.idVendor),
901 le16_to_cpu(dev->descriptor.idProduct), 955 le16_to_cpu(dev->descriptor.idProduct),
902 le16_to_cpu(dev->descriptor.bcdDevice)); 956 le16_to_cpu(dev->descriptor.bcdDevice));
903 957
904 kaweth_dbg("Device at %p", dev); 958 dbg("Device at %p", dev);
905 959
906 kaweth_dbg("Descriptor length: %x type: %x", 960 dbg("Descriptor length: %x type: %x",
907 (int)dev->descriptor.bLength, 961 (int)dev->descriptor.bLength,
908 (int)dev->descriptor.bDescriptorType); 962 (int)dev->descriptor.bDescriptorType);
909 963
@@ -918,7 +972,7 @@ static int kaweth_probe(
918 spin_lock_init(&kaweth->device_lock); 972 spin_lock_init(&kaweth->device_lock);
919 init_waitqueue_head(&kaweth->term_wait); 973 init_waitqueue_head(&kaweth->term_wait);
920 974
921 kaweth_dbg("Resetting."); 975 dbg("Resetting.");
922 976
923 kaweth_reset(kaweth); 977 kaweth_reset(kaweth);
924 978
@@ -928,17 +982,17 @@ static int kaweth_probe(
928 */ 982 */
929 983
930 if (le16_to_cpu(dev->descriptor.bcdDevice) >> 8) { 984 if (le16_to_cpu(dev->descriptor.bcdDevice) >> 8) {
931 kaweth_info("Firmware present in device."); 985 info("Firmware present in device.");
932 } else { 986 } else {
933 /* Download the firmware */ 987 /* Download the firmware */
934 kaweth_info("Downloading firmware..."); 988 info("Downloading firmware...");
935 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); 989 kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL);
936 if ((result = kaweth_download_firmware(kaweth, 990 if ((result = kaweth_download_firmware(kaweth,
937 kaweth_new_code, 991 kaweth_new_code,
938 len_kaweth_new_code, 992 len_kaweth_new_code,
939 100, 993 100,
940 2)) < 0) { 994 2)) < 0) {
941 kaweth_err("Error downloading firmware (%d)", result); 995 err("Error downloading firmware (%d)", result);
942 goto err_fw; 996 goto err_fw;
943 } 997 }
944 998
@@ -947,7 +1001,7 @@ static int kaweth_probe(
947 len_kaweth_new_code_fix, 1001 len_kaweth_new_code_fix,
948 100, 1002 100,
949 3)) < 0) { 1003 3)) < 0) {
950 kaweth_err("Error downloading firmware fix (%d)", result); 1004 err("Error downloading firmware fix (%d)", result);
951 goto err_fw; 1005 goto err_fw;
952 } 1006 }
953 1007
@@ -956,7 +1010,7 @@ static int kaweth_probe(
956 len_kaweth_trigger_code, 1010 len_kaweth_trigger_code,
957 126, 1011 126,
958 2)) < 0) { 1012 2)) < 0) {
959 kaweth_err("Error downloading trigger code (%d)", result); 1013 err("Error downloading trigger code (%d)", result);
960 goto err_fw; 1014 goto err_fw;
961 1015
962 } 1016 }
@@ -966,18 +1020,18 @@ static int kaweth_probe(
966 len_kaweth_trigger_code_fix, 1020 len_kaweth_trigger_code_fix,
967 126, 1021 126,
968 3)) < 0) { 1022 3)) < 0) {
969 kaweth_err("Error downloading trigger code fix (%d)", result); 1023 err("Error downloading trigger code fix (%d)", result);
970 goto err_fw; 1024 goto err_fw;
971 } 1025 }
972 1026
973 1027
974 if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) { 1028 if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) {
975 kaweth_err("Error triggering firmware (%d)", result); 1029 err("Error triggering firmware (%d)", result);
976 goto err_fw; 1030 goto err_fw;
977 } 1031 }
978 1032
979 /* Device will now disappear for a moment... */ 1033 /* Device will now disappear for a moment... */
980 kaweth_info("Firmware loaded. I'll be back..."); 1034 info("Firmware loaded. I'll be back...");
981err_fw: 1035err_fw:
982 free_page((unsigned long)kaweth->firmware_buf); 1036 free_page((unsigned long)kaweth->firmware_buf);
983 free_netdev(netdev); 1037 free_netdev(netdev);
@@ -987,14 +1041,14 @@ err_fw:
987 result = kaweth_read_configuration(kaweth); 1041 result = kaweth_read_configuration(kaweth);
988 1042
989 if(result < 0) { 1043 if(result < 0) {
990 kaweth_err("Error reading configuration (%d), no net device created", result); 1044 err("Error reading configuration (%d), no net device created", result);
991 goto err_free_netdev; 1045 goto err_free_netdev;
992 } 1046 }
993 1047
994 kaweth_info("Statistics collection: %x", kaweth->configuration.statistics_mask); 1048 info("Statistics collection: %x", kaweth->configuration.statistics_mask);
995 kaweth_info("Multicast filter limit: %x", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); 1049 info("Multicast filter limit: %x", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1));
996 kaweth_info("MTU: %d", le16_to_cpu(kaweth->configuration.segment_size)); 1050 info("MTU: %d", le16_to_cpu(kaweth->configuration.segment_size));
997 kaweth_info("Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x", 1051 info("Read MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
998 (int)kaweth->configuration.hw_addr[0], 1052 (int)kaweth->configuration.hw_addr[0],
999 (int)kaweth->configuration.hw_addr[1], 1053 (int)kaweth->configuration.hw_addr[1],
1000 (int)kaweth->configuration.hw_addr[2], 1054 (int)kaweth->configuration.hw_addr[2],
@@ -1005,17 +1059,17 @@ err_fw:
1005 if(!memcmp(&kaweth->configuration.hw_addr, 1059 if(!memcmp(&kaweth->configuration.hw_addr,
1006 &bcast_addr, 1060 &bcast_addr,
1007 sizeof(bcast_addr))) { 1061 sizeof(bcast_addr))) {
1008 kaweth_err("Firmware not functioning properly, no net device created"); 1062 err("Firmware not functioning properly, no net device created");
1009 goto err_free_netdev; 1063 goto err_free_netdev;
1010 } 1064 }
1011 1065
1012 if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) { 1066 if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) {
1013 kaweth_dbg("Error setting URB size"); 1067 dbg("Error setting URB size");
1014 goto err_free_netdev; 1068 goto err_free_netdev;
1015 } 1069 }
1016 1070
1017 if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) { 1071 if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) {
1018 kaweth_err("Error setting SOFS wait"); 1072 err("Error setting SOFS wait");
1019 goto err_free_netdev; 1073 goto err_free_netdev;
1020 } 1074 }
1021 1075
@@ -1025,11 +1079,11 @@ err_fw:
1025 KAWETH_PACKET_FILTER_MULTICAST); 1079 KAWETH_PACKET_FILTER_MULTICAST);
1026 1080
1027 if(result < 0) { 1081 if(result < 0) {
1028 kaweth_err("Error setting receive filter"); 1082 err("Error setting receive filter");
1029 goto err_free_netdev; 1083 goto err_free_netdev;
1030 } 1084 }
1031 1085
1032 kaweth_dbg("Initializing net device."); 1086 dbg("Initializing net device.");
1033 1087
1034 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); 1088 kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
1035 if (!kaweth->tx_urb) 1089 if (!kaweth->tx_urb)
@@ -1086,13 +1140,13 @@ err_fw:
1086 1140
1087 SET_NETDEV_DEV(netdev, &intf->dev); 1141 SET_NETDEV_DEV(netdev, &intf->dev);
1088 if (register_netdev(netdev) != 0) { 1142 if (register_netdev(netdev) != 0) {
1089 kaweth_err("Error registering netdev."); 1143 err("Error registering netdev.");
1090 goto err_intfdata; 1144 goto err_intfdata;
1091 } 1145 }
1092 1146
1093 kaweth_info("kaweth interface created at %s", kaweth->net->name); 1147 info("kaweth interface created at %s", kaweth->net->name);
1094 1148
1095 kaweth_dbg("Kaweth probe returning."); 1149 dbg("Kaweth probe returning.");
1096 1150
1097 return 0; 1151 return 0;
1098 1152
@@ -1121,16 +1175,16 @@ static void kaweth_disconnect(struct usb_interface *intf)
1121 struct kaweth_device *kaweth = usb_get_intfdata(intf); 1175 struct kaweth_device *kaweth = usb_get_intfdata(intf);
1122 struct net_device *netdev; 1176 struct net_device *netdev;
1123 1177
1124 kaweth_info("Unregistering"); 1178 info("Unregistering");
1125 1179
1126 usb_set_intfdata(intf, NULL); 1180 usb_set_intfdata(intf, NULL);
1127 if (!kaweth) { 1181 if (!kaweth) {
1128 kaweth_warn("unregistering non-existant device"); 1182 warn("unregistering non-existant device");
1129 return; 1183 return;
1130 } 1184 }
1131 netdev = kaweth->net; 1185 netdev = kaweth->net;
1132 1186
1133 kaweth_dbg("Unregistering net device"); 1187 dbg("Unregistering net device");
1134 unregister_netdev(netdev); 1188 unregister_netdev(netdev);
1135 1189
1136 usb_free_urb(kaweth->rx_urb); 1190 usb_free_urb(kaweth->rx_urb);
@@ -1185,7 +1239,7 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int* actual_length)
1185 1239
1186 if (!wait_event_timeout(awd.wqh, awd.done, timeout)) { 1240 if (!wait_event_timeout(awd.wqh, awd.done, timeout)) {
1187 // timeout 1241 // timeout
1188 kaweth_warn("usb_control/bulk_msg: timeout"); 1242 warn("usb_control/bulk_msg: timeout");
1189 usb_kill_urb(urb); // remove urb safely 1243 usb_kill_urb(urb); // remove urb safely
1190 status = -ETIMEDOUT; 1244 status = -ETIMEDOUT;
1191 } 1245 }
@@ -1234,7 +1288,7 @@ static int kaweth_internal_control_msg(struct usb_device *usb_dev,
1234 ****************************************************************/ 1288 ****************************************************************/
1235static int __init kaweth_init(void) 1289static int __init kaweth_init(void)
1236{ 1290{
1237 kaweth_dbg("Driver loading"); 1291 dbg("Driver loading");
1238 return usb_register(&kaweth_driver); 1292 return usb_register(&kaweth_driver);
1239} 1293}
1240 1294
diff --git a/drivers/usb/net/mcs7830.c b/drivers/usb/net/mcs7830.c
new file mode 100644
index 000000000000..6240b978fe3d
--- /dev/null
+++ b/drivers/usb/net/mcs7830.c
@@ -0,0 +1,534 @@
1/*
2 * MosChips MCS7830 based USB 2.0 Ethernet Devices
3 *
4 * based on usbnet.c, asix.c and the vendor provided mcs7830 driver
5 *
6 * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>
7 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
8 * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
9 * Copyright (c) 2002-2003 TiVo Inc.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
26#include <linux/crc32.h>
27#include <linux/etherdevice.h>
28#include <linux/ethtool.h>
29#include <linux/init.h>
30#include <linux/mii.h>
31#include <linux/module.h>
32#include <linux/netdevice.h>
33#include <linux/usb.h>
34
35#include "usbnet.h"
36
37/* requests */
38#define MCS7830_RD_BMREQ (USB_DIR_IN | USB_TYPE_VENDOR | \
39 USB_RECIP_DEVICE)
40#define MCS7830_WR_BMREQ (USB_DIR_OUT | USB_TYPE_VENDOR | \
41 USB_RECIP_DEVICE)
42#define MCS7830_RD_BREQ 0x0E
43#define MCS7830_WR_BREQ 0x0D
44
45#define MCS7830_CTRL_TIMEOUT 1000
46#define MCS7830_MAX_MCAST 64
47
48#define MCS7830_VENDOR_ID 0x9710
49#define MCS7830_PRODUCT_ID 0x7830
50
51#define MCS7830_MII_ADVERTISE (ADVERTISE_PAUSE_CAP | ADVERTISE_100FULL | \
52 ADVERTISE_100HALF | ADVERTISE_10FULL | \
53 ADVERTISE_10HALF | ADVERTISE_CSMA)
54
55/* HIF_REG_XX coressponding index value */
56enum {
57 HIF_REG_MULTICAST_HASH = 0x00,
58 HIF_REG_PACKET_GAP1 = 0x08,
59 HIF_REG_PACKET_GAP2 = 0x09,
60 HIF_REG_PHY_DATA = 0x0a,
61 HIF_REG_PHY_CMD1 = 0x0c,
62 HIF_REG_PHY_CMD1_READ = 0x40,
63 HIF_REG_PHY_CMD1_WRITE = 0x20,
64 HIF_REG_PHY_CMD1_PHYADDR = 0x01,
65 HIF_REG_PHY_CMD2 = 0x0d,
66 HIF_REG_PHY_CMD2_PEND_FLAG_BIT = 0x80,
67 HIF_REG_PHY_CMD2_READY_FLAG_BIT = 0x40,
68 HIF_REG_CONFIG = 0x0e,
69 HIF_REG_CONFIG_CFG = 0x80,
70 HIF_REG_CONFIG_SPEED100 = 0x40,
71 HIF_REG_CONFIG_FULLDUPLEX_ENABLE = 0x20,
72 HIF_REG_CONFIG_RXENABLE = 0x10,
73 HIF_REG_CONFIG_TXENABLE = 0x08,
74 HIF_REG_CONFIG_SLEEPMODE = 0x04,
75 HIF_REG_CONFIG_ALLMULTICAST = 0x02,
76 HIF_REG_CONFIG_PROMISCIOUS = 0x01,
77 HIF_REG_ETHERNET_ADDR = 0x0f,
78 HIF_REG_22 = 0x15,
79 HIF_REG_PAUSE_THRESHOLD = 0x16,
80 HIF_REG_PAUSE_THRESHOLD_DEFAULT = 0,
81};
82
83struct mcs7830_data {
84 u8 multi_filter[8];
85 u8 config;
86};
87
88static const char driver_name[] = "MOSCHIP usb-ethernet driver";
89
90static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data)
91{
92 struct usb_device *xdev = dev->udev;
93 int ret;
94
95 ret = usb_control_msg(xdev, usb_rcvctrlpipe(xdev, 0), MCS7830_RD_BREQ,
96 MCS7830_RD_BMREQ, 0x0000, index, data,
97 size, msecs_to_jiffies(MCS7830_CTRL_TIMEOUT));
98 return ret;
99}
100
101static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, void *data)
102{
103 struct usb_device *xdev = dev->udev;
104 int ret;
105
106 ret = usb_control_msg(xdev, usb_sndctrlpipe(xdev, 0), MCS7830_WR_BREQ,
107 MCS7830_WR_BMREQ, 0x0000, index, data,
108 size, msecs_to_jiffies(MCS7830_CTRL_TIMEOUT));
109 return ret;
110}
111
112static void mcs7830_async_cmd_callback(struct urb *urb)
113{
114 struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
115
116 if (urb->status < 0)
117 printk(KERN_DEBUG "mcs7830_async_cmd_callback() failed with %d",
118 urb->status);
119
120 kfree(req);
121 usb_free_urb(urb);
122}
123
124static void mcs7830_set_reg_async(struct usbnet *dev, u16 index, u16 size, void *data)
125{
126 struct usb_ctrlrequest *req;
127 int ret;
128 struct urb *urb;
129
130 urb = usb_alloc_urb(0, GFP_ATOMIC);
131 if (!urb) {
132 dev_dbg(&dev->udev->dev, "Error allocating URB "
133 "in write_cmd_async!");
134 return;
135 }
136
137 req = kmalloc(sizeof *req, GFP_ATOMIC);
138 if (!req) {
139 dev_err(&dev->udev->dev, "Failed to allocate memory for "
140 "control request");
141 goto out;
142 }
143 req->bRequestType = MCS7830_WR_BMREQ;
144 req->bRequest = MCS7830_WR_BREQ;
145 req->wValue = 0;
146 req->wIndex = cpu_to_le16(index);
147 req->wLength = cpu_to_le16(size);
148
149 usb_fill_control_urb(urb, dev->udev,
150 usb_sndctrlpipe(dev->udev, 0),
151 (void *)req, data, size,
152 mcs7830_async_cmd_callback, req);
153
154 ret = usb_submit_urb(urb, GFP_ATOMIC);
155 if (ret < 0) {
156 dev_err(&dev->udev->dev, "Error submitting the control "
157 "message: ret=%d", ret);
158 goto out;
159 }
160 return;
161out:
162 kfree(req);
163 usb_free_urb(urb);
164}
165
166static int mcs7830_get_address(struct usbnet *dev)
167{
168 int ret;
169 ret = mcs7830_get_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN,
170 dev->net->dev_addr);
171 if (ret < 0)
172 return ret;
173 return 0;
174}
175
176static int mcs7830_read_phy(struct usbnet *dev, u8 index)
177{
178 int ret;
179 int i;
180 __le16 val;
181
182 u8 cmd[2] = {
183 HIF_REG_PHY_CMD1_READ | HIF_REG_PHY_CMD1_PHYADDR,
184 HIF_REG_PHY_CMD2_PEND_FLAG_BIT | index,
185 };
186
187 mutex_lock(&dev->phy_mutex);
188 /* write the MII command */
189 ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
190 if (ret < 0)
191 goto out;
192
193 /* wait for the data to become valid, should be within < 1ms */
194 for (i = 0; i < 10; i++) {
195 ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
196 if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT))
197 break;
198 ret = -EIO;
199 msleep(1);
200 }
201 if (ret < 0)
202 goto out;
203
204 /* read actual register contents */
205 ret = mcs7830_get_reg(dev, HIF_REG_PHY_DATA, 2, &val);
206 if (ret < 0)
207 goto out;
208 ret = le16_to_cpu(val);
209 dev_dbg(&dev->udev->dev, "read PHY reg %02x: %04x (%d tries)\n",
210 index, val, i);
211out:
212 mutex_unlock(&dev->phy_mutex);
213 return ret;
214}
215
216static int mcs7830_write_phy(struct usbnet *dev, u8 index, u16 val)
217{
218 int ret;
219 int i;
220 __le16 le_val;
221
222 u8 cmd[2] = {
223 HIF_REG_PHY_CMD1_WRITE | HIF_REG_PHY_CMD1_PHYADDR,
224 HIF_REG_PHY_CMD2_PEND_FLAG_BIT | (index & 0x1F),
225 };
226
227 mutex_lock(&dev->phy_mutex);
228
229 /* write the new register contents */
230 le_val = cpu_to_le16(val);
231 ret = mcs7830_set_reg(dev, HIF_REG_PHY_DATA, 2, &le_val);
232 if (ret < 0)
233 goto out;
234
235 /* write the MII command */
236 ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
237 if (ret < 0)
238 goto out;
239
240 /* wait for the command to be accepted by the PHY */
241 for (i = 0; i < 10; i++) {
242 ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd);
243 if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT))
244 break;
245 ret = -EIO;
246 msleep(1);
247 }
248 if (ret < 0)
249 goto out;
250
251 ret = 0;
252 dev_dbg(&dev->udev->dev, "write PHY reg %02x: %04x (%d tries)\n",
253 index, val, i);
254out:
255 mutex_unlock(&dev->phy_mutex);
256 return ret;
257}
258
259/*
260 * This algorithm comes from the original mcs7830 version 1.4 driver,
261 * not sure if it is needed.
262 */
263static int mcs7830_set_autoneg(struct usbnet *dev, int ptrUserPhyMode)
264{
265 int ret;
266 /* Enable all media types */
267 ret = mcs7830_write_phy(dev, MII_ADVERTISE, MCS7830_MII_ADVERTISE);
268
269 /* First reset BMCR */
270 if (!ret)
271 ret = mcs7830_write_phy(dev, MII_BMCR, 0x0000);
272 /* Enable Auto Neg */
273 if (!ret)
274 ret = mcs7830_write_phy(dev, MII_BMCR, BMCR_ANENABLE);
275 /* Restart Auto Neg (Keep the Enable Auto Neg Bit Set) */
276 if (!ret)
277 ret = mcs7830_write_phy(dev, MII_BMCR,
278 BMCR_ANENABLE | BMCR_ANRESTART );
279 return ret < 0 ? : 0;
280}
281
282
283/*
284 * if we can read register 22, the chip revision is C or higher
285 */
286static int mcs7830_get_rev(struct usbnet *dev)
287{
288 u8 dummy[2];
289 int ret;
290 ret = mcs7830_get_reg(dev, HIF_REG_22, 2, dummy);
291 if (ret > 0)
292 return 2; /* Rev C or later */
293 return 1; /* earlier revision */
294}
295
296/*
297 * On rev. C we need to set the pause threshold
298 */
299static void mcs7830_rev_C_fixup(struct usbnet *dev)
300{
301 u8 pause_threshold = HIF_REG_PAUSE_THRESHOLD_DEFAULT;
302 int retry;
303
304 for (retry = 0; retry < 2; retry++) {
305 if (mcs7830_get_rev(dev) == 2) {
306 dev_info(&dev->udev->dev, "applying rev.C fixup\n");
307 mcs7830_set_reg(dev, HIF_REG_PAUSE_THRESHOLD,
308 1, &pause_threshold);
309 }
310 msleep(1);
311 }
312}
313
314static int mcs7830_init_dev(struct usbnet *dev)
315{
316 int ret;
317 int retry;
318
319 /* Read MAC address from EEPROM */
320 ret = -EINVAL;
321 for (retry = 0; retry < 5 && ret; retry++)
322 ret = mcs7830_get_address(dev);
323 if (ret) {
324 dev_warn(&dev->udev->dev, "Cannot read MAC address\n");
325 goto out;
326 }
327
328 /* Set up PHY */
329 ret = mcs7830_set_autoneg(dev, 0);
330 if (ret) {
331 dev_info(&dev->udev->dev, "Cannot set autoneg\n");
332 goto out;
333 }
334
335 mcs7830_rev_C_fixup(dev);
336 ret = 0;
337out:
338 return ret;
339}
340
341static int mcs7830_mdio_read(struct net_device *netdev, int phy_id,
342 int location)
343{
344 struct usbnet *dev = netdev->priv;
345 return mcs7830_read_phy(dev, location);
346}
347
348static void mcs7830_mdio_write(struct net_device *netdev, int phy_id,
349 int location, int val)
350{
351 struct usbnet *dev = netdev->priv;
352 mcs7830_write_phy(dev, location, val);
353}
354
355static int mcs7830_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
356{
357 struct usbnet *dev = netdev_priv(net);
358 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
359}
360
361/* credits go to asix_set_multicast */
362static void mcs7830_set_multicast(struct net_device *net)
363{
364 struct usbnet *dev = netdev_priv(net);
365 struct mcs7830_data *data = (struct mcs7830_data *)&dev->data;
366
367 data->config = HIF_REG_CONFIG_TXENABLE;
368
369 /* this should not be needed, but it doesn't work otherwise */
370 data->config |= HIF_REG_CONFIG_ALLMULTICAST;
371
372 if (net->flags & IFF_PROMISC) {
373 data->config |= HIF_REG_CONFIG_PROMISCIOUS;
374 } else if (net->flags & IFF_ALLMULTI
375 || net->mc_count > MCS7830_MAX_MCAST) {
376 data->config |= HIF_REG_CONFIG_ALLMULTICAST;
377 } else if (net->mc_count == 0) {
378 /* just broadcast and directed */
379 } else {
380 /* We use the 20 byte dev->data
381 * for our 8 byte filter buffer
382 * to avoid allocating memory that
383 * is tricky to free later */
384 struct dev_mc_list *mc_list = net->mc_list;
385 u32 crc_bits;
386 int i;
387
388 memset(data->multi_filter, 0, sizeof data->multi_filter);
389
390 /* Build the multicast hash filter. */
391 for (i = 0; i < net->mc_count; i++) {
392 crc_bits = ether_crc(ETH_ALEN, mc_list->dmi_addr) >> 26;
393 data->multi_filter[crc_bits >> 3] |= 1 << (crc_bits & 7);
394 mc_list = mc_list->next;
395 }
396
397 mcs7830_set_reg_async(dev, HIF_REG_MULTICAST_HASH,
398 sizeof data->multi_filter,
399 data->multi_filter);
400 }
401
402 mcs7830_set_reg_async(dev, HIF_REG_CONFIG, 1, &data->config);
403}
404
405static int mcs7830_get_regs_len(struct net_device *net)
406{
407 struct usbnet *dev = netdev_priv(net);
408
409 switch (mcs7830_get_rev(dev)) {
410 case 1:
411 return 21;
412 case 2:
413 return 32;
414 }
415 return 0;
416}
417
418static void mcs7830_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *drvinfo)
419{
420 usbnet_get_drvinfo(net, drvinfo);
421 drvinfo->regdump_len = mcs7830_get_regs_len(net);
422}
423
424static void mcs7830_get_regs(struct net_device *net, struct ethtool_regs *regs, void *data)
425{
426 struct usbnet *dev = netdev_priv(net);
427
428 regs->version = mcs7830_get_rev(dev);
429 mcs7830_get_reg(dev, 0, regs->len, data);
430}
431
432static struct ethtool_ops mcs7830_ethtool_ops = {
433 .get_drvinfo = mcs7830_get_drvinfo,
434 .get_regs_len = mcs7830_get_regs_len,
435 .get_regs = mcs7830_get_regs,
436
437 /* common usbnet calls */
438 .get_link = usbnet_get_link,
439 .get_msglevel = usbnet_get_msglevel,
440 .set_msglevel = usbnet_set_msglevel,
441 .get_settings = usbnet_get_settings,
442 .set_settings = usbnet_set_settings,
443 .nway_reset = usbnet_nway_reset,
444};
445
446static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev)
447{
448 struct net_device *net = dev->net;
449 int ret;
450
451 ret = mcs7830_init_dev(dev);
452 if (ret)
453 goto out;
454
455 net->do_ioctl = mcs7830_ioctl;
456 net->ethtool_ops = &mcs7830_ethtool_ops;
457 net->set_multicast_list = mcs7830_set_multicast;
458 mcs7830_set_multicast(net);
459
460 /* reserve space for the status byte on rx */
461 dev->rx_urb_size = ETH_FRAME_LEN + 1;
462
463 dev->mii.mdio_read = mcs7830_mdio_read;
464 dev->mii.mdio_write = mcs7830_mdio_write;
465 dev->mii.dev = net;
466 dev->mii.phy_id_mask = 0x3f;
467 dev->mii.reg_num_mask = 0x1f;
468 dev->mii.phy_id = *((u8 *) net->dev_addr + 1);
469
470 ret = usbnet_get_endpoints(dev, udev);
471out:
472 return ret;
473}
474
475/* The chip always appends a status bytes that we need to strip */
476static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
477{
478 u8 status;
479
480 if (skb->len == 0) {
481 dev_err(&dev->udev->dev, "unexpected empty rx frame\n");
482 return 0;
483 }
484
485 skb_trim(skb, skb->len - 1);
486 status = skb->data[skb->len];
487
488 if (status != 0x20)
489 dev_dbg(&dev->udev->dev, "rx fixup status %x\n", status);
490
491 return skb->len > 0;
492}
493
494static const struct driver_info moschip_info = {
495 .description = "MOSCHIP 7830 usb-NET adapter",
496 .bind = mcs7830_bind,
497 .rx_fixup = mcs7830_rx_fixup,
498 .flags = FLAG_ETHER,
499 .in = 1,
500 .out = 2,
501};
502
503static const struct usb_device_id products[] = {
504 {
505 USB_DEVICE(MCS7830_VENDOR_ID, MCS7830_PRODUCT_ID),
506 .driver_info = (unsigned long) &moschip_info,
507 },
508 {},
509};
510MODULE_DEVICE_TABLE(usb, products);
511
512static struct usb_driver mcs7830_driver = {
513 .name = driver_name,
514 .id_table = products,
515 .probe = usbnet_probe,
516 .disconnect = usbnet_disconnect,
517 .suspend = usbnet_suspend,
518 .resume = usbnet_resume,
519};
520
521static int __init mcs7830_init(void)
522{
523 return usb_register(&mcs7830_driver);
524}
525module_init(mcs7830_init);
526
527static void __exit mcs7830_exit(void)
528{
529 usb_deregister(&mcs7830_driver);
530}
531module_exit(mcs7830_exit);
532
533MODULE_DESCRIPTION("USB to network adapter MCS7830)");
534MODULE_LICENSE("GPL");
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 24bd3486ee63..cf3d20eb781c 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -669,6 +669,37 @@ done:
669 * they'll probably want to use this base set. 669 * they'll probably want to use this base set.
670 */ 670 */
671 671
672int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd)
673{
674 struct usbnet *dev = netdev_priv(net);
675
676 if (!dev->mii.mdio_read)
677 return -EOPNOTSUPP;
678
679 return mii_ethtool_gset(&dev->mii, cmd);
680}
681EXPORT_SYMBOL_GPL(usbnet_get_settings);
682
683int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd)
684{
685 struct usbnet *dev = netdev_priv(net);
686 int retval;
687
688 if (!dev->mii.mdio_write)
689 return -EOPNOTSUPP;
690
691 retval = mii_ethtool_sset(&dev->mii, cmd);
692
693 /* link speed/duplex might have changed */
694 if (dev->driver_info->link_reset)
695 dev->driver_info->link_reset(dev);
696
697 return retval;
698
699}
700EXPORT_SYMBOL_GPL(usbnet_set_settings);
701
702
672void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info) 703void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
673{ 704{
674 struct usbnet *dev = netdev_priv(net); 705 struct usbnet *dev = netdev_priv(net);
@@ -682,7 +713,7 @@ void usbnet_get_drvinfo (struct net_device *net, struct ethtool_drvinfo *info)
682} 713}
683EXPORT_SYMBOL_GPL(usbnet_get_drvinfo); 714EXPORT_SYMBOL_GPL(usbnet_get_drvinfo);
684 715
685static u32 usbnet_get_link (struct net_device *net) 716u32 usbnet_get_link (struct net_device *net)
686{ 717{
687 struct usbnet *dev = netdev_priv(net); 718 struct usbnet *dev = netdev_priv(net);
688 719
@@ -690,9 +721,14 @@ static u32 usbnet_get_link (struct net_device *net)
690 if (dev->driver_info->check_connect) 721 if (dev->driver_info->check_connect)
691 return dev->driver_info->check_connect (dev) == 0; 722 return dev->driver_info->check_connect (dev) == 0;
692 723
724 /* if the device has mii operations, use those */
725 if (dev->mii.mdio_read)
726 return mii_link_ok(&dev->mii);
727
693 /* Otherwise, say we're up (to avoid breaking scripts) */ 728 /* Otherwise, say we're up (to avoid breaking scripts) */
694 return 1; 729 return 1;
695} 730}
731EXPORT_SYMBOL_GPL(usbnet_get_link);
696 732
697u32 usbnet_get_msglevel (struct net_device *net) 733u32 usbnet_get_msglevel (struct net_device *net)
698{ 734{
@@ -710,10 +746,24 @@ void usbnet_set_msglevel (struct net_device *net, u32 level)
710} 746}
711EXPORT_SYMBOL_GPL(usbnet_set_msglevel); 747EXPORT_SYMBOL_GPL(usbnet_set_msglevel);
712 748
749int usbnet_nway_reset(struct net_device *net)
750{
751 struct usbnet *dev = netdev_priv(net);
752
753 if (!dev->mii.mdio_write)
754 return -EOPNOTSUPP;
755
756 return mii_nway_restart(&dev->mii);
757}
758EXPORT_SYMBOL_GPL(usbnet_nway_reset);
759
713/* drivers may override default ethtool_ops in their bind() routine */ 760/* drivers may override default ethtool_ops in their bind() routine */
714static struct ethtool_ops usbnet_ethtool_ops = { 761static struct ethtool_ops usbnet_ethtool_ops = {
762 .get_settings = usbnet_get_settings,
763 .set_settings = usbnet_set_settings,
715 .get_drvinfo = usbnet_get_drvinfo, 764 .get_drvinfo = usbnet_get_drvinfo,
716 .get_link = usbnet_get_link, 765 .get_link = usbnet_get_link,
766 .nway_reset = usbnet_nway_reset,
717 .get_msglevel = usbnet_get_msglevel, 767 .get_msglevel = usbnet_get_msglevel,
718 .set_msglevel = usbnet_set_msglevel, 768 .set_msglevel = usbnet_set_msglevel,
719}; 769};
@@ -1094,6 +1144,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1094 dev->delay.function = usbnet_bh; 1144 dev->delay.function = usbnet_bh;
1095 dev->delay.data = (unsigned long) dev; 1145 dev->delay.data = (unsigned long) dev;
1096 init_timer (&dev->delay); 1146 init_timer (&dev->delay);
1147 mutex_init (&dev->phy_mutex);
1097 1148
1098 SET_MODULE_OWNER (net); 1149 SET_MODULE_OWNER (net);
1099 dev->net = net; 1150 dev->net = net;
@@ -1225,7 +1276,7 @@ EXPORT_SYMBOL_GPL(usbnet_resume);
1225static int __init usbnet_init(void) 1276static int __init usbnet_init(void)
1226{ 1277{
1227 /* compiler should optimize this out */ 1278 /* compiler should optimize this out */
1228 BUG_ON (sizeof (((struct sk_buff *)0)->cb) 1279 BUILD_BUG_ON (sizeof (((struct sk_buff *)0)->cb)
1229 < sizeof (struct skb_data)); 1280 < sizeof (struct skb_data));
1230 1281
1231 random_ether_addr(node_id); 1282 random_ether_addr(node_id);
diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h
index c0746f0454af..07c70abbe0ec 100644
--- a/drivers/usb/net/usbnet.h
+++ b/drivers/usb/net/usbnet.h
@@ -30,6 +30,7 @@ struct usbnet {
30 struct usb_device *udev; 30 struct usb_device *udev;
31 struct driver_info *driver_info; 31 struct driver_info *driver_info;
32 wait_queue_head_t *wait; 32 wait_queue_head_t *wait;
33 struct mutex phy_mutex;
33 34
34 /* i/o info: pipes etc */ 35 /* i/o info: pipes etc */
35 unsigned in, out; 36 unsigned in, out;
@@ -168,9 +169,13 @@ extern void usbnet_defer_kevent (struct usbnet *, int);
168extern void usbnet_skb_return (struct usbnet *, struct sk_buff *); 169extern void usbnet_skb_return (struct usbnet *, struct sk_buff *);
169extern void usbnet_unlink_rx_urbs(struct usbnet *); 170extern void usbnet_unlink_rx_urbs(struct usbnet *);
170 171
172extern int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd);
173extern int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd);
174extern u32 usbnet_get_link (struct net_device *net);
171extern u32 usbnet_get_msglevel (struct net_device *); 175extern u32 usbnet_get_msglevel (struct net_device *);
172extern void usbnet_set_msglevel (struct net_device *, u32); 176extern void usbnet_set_msglevel (struct net_device *, u32);
173extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *); 177extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *);
178extern int usbnet_nway_reset(struct net_device *net);
174 179
175/* messaging support includes the interface name, so it must not be 180/* messaging support includes the interface name, so it must not be
176 * used before it has one ... notably, in minidriver bind() calls. 181 * used before it has one ... notably, in minidriver bind() calls.
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 5076b9d97057..9a6ec1b5e3d5 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -422,6 +422,16 @@ config USB_SERIAL_MCT_U232
422 To compile this driver as a module, choose M here: the 422 To compile this driver as a module, choose M here: the
423 module will be called mct_u232. 423 module will be called mct_u232.
424 424
425config USB_SERIAL_MOS7720
426 tristate "USB Moschip 7720 Single Port Serial Driver"
427 depends on USB_SERIAL
428 ---help---
429 Say Y here if you want to use a USB Serial single port adapter from
430 Moschip Semiconductor Tech.
431
432 To compile this driver as a module, choose M here: the
433 module will be called mos7720.
434
425config USB_SERIAL_MOS7840 435config USB_SERIAL_MOS7840
426 tristate "USB Moschip 7840/7820 USB Serial Driver" 436 tristate "USB Moschip 7840/7820 USB Serial Driver"
427 depends on USB_SERIAL 437 depends on USB_SERIAL
@@ -527,8 +537,7 @@ config USB_SERIAL_OPTION
527 The USB bus on these cards is not accessible externally. 537 The USB bus on these cards is not accessible externally.
528 538
529 Supported devices include (some of?) those made by: 539 Supported devices include (some of?) those made by:
530 Option, Huawei, Audiovox, Sierra Wireless, Novatel Wireless, or 540 Option, Huawei, Audiovox, Novatel Wireless, or Anydata.
531 Anydata.
532 541
533 To compile this driver as a module, choose M here: the 542 To compile this driver as a module, choose M here: the
534 module will be called option. 543 module will be called option.
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 8dce83340e31..a5047dc599bb 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o
34obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o 34obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o
35obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o 35obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o
36obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o 36obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o
37obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o
37obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o 38obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o
38obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o 39obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o
39obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o 40obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 2c19f19b255c..7f5d546da39a 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -18,12 +18,8 @@
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(0x0f3d, 0x0112) }, /* AirPrime CDMA Wireless PC Card */
22 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
23 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
24 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless Aircard 580 */
25 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
26 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */ 21 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */
22 { USB_DEVICE(0x1410, 0x1100) }, /* ExpressCard34 Qualcomm 3G CDMA */
27 { }, 23 { },
28}; 24};
29MODULE_DEVICE_TABLE(usb, id_table); 25MODULE_DEVICE_TABLE(usb, id_table);
@@ -133,6 +129,7 @@ static int airprime_open(struct usb_serial_port *port, struct file *filp)
133 } 129 }
134 urb = usb_alloc_urb(0, GFP_KERNEL); 130 urb = usb_alloc_urb(0, GFP_KERNEL);
135 if (!urb) { 131 if (!urb) {
132 kfree(buffer);
136 dev_err(&port->dev, "%s - no more urbs?\n", 133 dev_err(&port->dev, "%s - no more urbs?\n",
137 __FUNCTION__); 134 __FUNCTION__);
138 result = -ENOMEM; 135 result = -ENOMEM;
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index 486c7411b9a7..bbf6532c26e5 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -65,6 +65,7 @@ static struct usb_device_id id_table [] = {
65 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */ 65 { USB_DEVICE(0x10C4, 0x813D) }, /* Burnside Telecom Deskmobile */
66 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */ 66 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */
67 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 67 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
68 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
68 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ 69 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */
69 { } /* Terminating Entry */ 70 { } /* Terminating Entry */
70}; 71};
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index d3dc1a15ec6c..bd76b4c11fcc 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1,16 +1,16 @@
1/* 1/*
2 * USB FTDI SIO driver 2 * USB FTDI SIO driver
3 * 3 *
4 * Copyright (C) 1999 - 2001 4 * Copyright (C) 1999 - 2001
5 * Greg Kroah-Hartman (greg@kroah.com) 5 * Greg Kroah-Hartman (greg@kroah.com)
6 * Bill Ryder (bryder@sgi.com) 6 * Bill Ryder (bryder@sgi.com)
7 * Copyright (C) 2002 7 * Copyright (C) 2002
8 * Kuba Ober (kuba@mareimbrium.org) 8 * Kuba Ober (kuba@mareimbrium.org)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or 12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. 13 * (at your option) any later version.
14 * 14 *
15 * See Documentation/usb/usb-serial.txt for more information on using this driver 15 * See Documentation/usb/usb-serial.txt for more information on using this driver
16 * 16 *
@@ -32,7 +32,7 @@
32 * Changed full name of USB-UIRT device to avoid "/" character. 32 * Changed full name of USB-UIRT device to avoid "/" character.
33 * Added FTDI's alternate PID (0x6006) for FT232/245 devices. 33 * Added FTDI's alternate PID (0x6006) for FT232/245 devices.
34 * Added PID for "ELV USB Module UO100" from Stefan Frings. 34 * Added PID for "ELV USB Module UO100" from Stefan Frings.
35 * 35 *
36 * (21/Oct/2003) Ian Abbott 36 * (21/Oct/2003) Ian Abbott
37 * Renamed some VID/PID macros for Matrix Orbital and Perle Systems 37 * Renamed some VID/PID macros for Matrix Orbital and Perle Systems
38 * devices. Removed Matrix Orbital and Perle Systems devices from the 38 * devices. Removed Matrix Orbital and Perle Systems devices from the
@@ -69,7 +69,7 @@
69 * does not incure any measurable overhead. This also relies on the fact 69 * does not incure any measurable overhead. This also relies on the fact
70 * that we have proper reference counting logic for urbs. I nicked this 70 * that we have proper reference counting logic for urbs. I nicked this
71 * from Greg KH's Visor driver. 71 * from Greg KH's Visor driver.
72 * 72 *
73 * (23/Jun/2003) Ian Abbott 73 * (23/Jun/2003) Ian Abbott
74 * Reduced flip buffer pushes and corrected a data length test in 74 * Reduced flip buffer pushes and corrected a data length test in
75 * ftdi_read_bulk_callback. 75 * ftdi_read_bulk_callback.
@@ -77,7 +77,7 @@
77 * 77 *
78 * (21/Jun/2003) Erik Nygren 78 * (21/Jun/2003) Erik Nygren
79 * Added support for Home Electronics Tira-1 IR transceiver using FT232BM chip. 79 * Added support for Home Electronics Tira-1 IR transceiver using FT232BM chip.
80 * See <http://www.home-electro.com/tira1.htm>. Only operates properly 80 * See <http://www.home-electro.com/tira1.htm>. Only operates properly
81 * at 100000 and RTS-CTS, so set custom divisor mode on startup. 81 * at 100000 and RTS-CTS, so set custom divisor mode on startup.
82 * Also force the Tira-1 and USB-UIRT to only use their custom baud rates. 82 * Also force the Tira-1 and USB-UIRT to only use their custom baud rates.
83 * 83 *
@@ -137,17 +137,17 @@
137 * (17/Feb/2003) Bill Ryder 137 * (17/Feb/2003) Bill Ryder
138 * Added write urb buffer pool on a per device basis 138 * Added write urb buffer pool on a per device basis
139 * Added more checking for open file on callbacks (fixed OOPS) 139 * Added more checking for open file on callbacks (fixed OOPS)
140 * Added CrystalFontz 632 and 634 PIDs 140 * Added CrystalFontz 632 and 634 PIDs
141 * (thanx to CrystalFontz for the sample devices - they flushed out 141 * (thanx to CrystalFontz for the sample devices - they flushed out
142 * some driver bugs) 142 * some driver bugs)
143 * Minor debugging message changes 143 * Minor debugging message changes
144 * Added throttle, unthrottle and chars_in_buffer functions 144 * Added throttle, unthrottle and chars_in_buffer functions
145 * Fixed FTDI_SIO (the original device) bug 145 * Fixed FTDI_SIO (the original device) bug
146 * Fixed some shutdown handling 146 * Fixed some shutdown handling
147 * 147 *
148 * 148 *
149 * 149 *
150 * 150 *
151 * (07/Jun/2002) Kuba Ober 151 * (07/Jun/2002) Kuba Ober
152 * Changed FTDI_SIO_BASE_BAUD_TO_DIVISOR macro into ftdi_baud_to_divisor 152 * Changed FTDI_SIO_BASE_BAUD_TO_DIVISOR macro into ftdi_baud_to_divisor
153 * function. It was getting too complex. 153 * function. It was getting too complex.
@@ -158,7 +158,7 @@
158 * 158 *
159 * (25/Jul/2002) Bill Ryder inserted Dmitri's TIOCMIWAIT patch 159 * (25/Jul/2002) Bill Ryder inserted Dmitri's TIOCMIWAIT patch
160 * Not tested by me but it doesn't break anything I use. 160 * Not tested by me but it doesn't break anything I use.
161 * 161 *
162 * (04/Jan/2002) Kuba Ober 162 * (04/Jan/2002) Kuba Ober
163 * Implemented 38400 baudrate kludge, where it can be substituted with other 163 * Implemented 38400 baudrate kludge, where it can be substituted with other
164 * values. That's the only way to set custom baudrates. 164 * values. That's the only way to set custom baudrates.
@@ -179,7 +179,7 @@
179 * (the previous version caused panics) 179 * (the previous version caused panics)
180 * Removed port iteration code since the device only has one I/O port and it 180 * Removed port iteration code since the device only has one I/O port and it
181 * was wrong anyway. 181 * was wrong anyway.
182 * 182 *
183 * (31/May/2001) gkh 183 * (31/May/2001) gkh
184 * Switched from using spinlock to a semaphore, which fixes lots of problems. 184 * Switched from using spinlock to a semaphore, which fixes lots of problems.
185 * 185 *
@@ -188,16 +188,16 @@
188 * Cleaned up comments for 8U232 188 * Cleaned up comments for 8U232
189 * Added parity, framing and overrun error handling 189 * Added parity, framing and overrun error handling
190 * Added receive break handling. 190 * Added receive break handling.
191 * 191 *
192 * (04/08/2001) gb 192 * (04/08/2001) gb
193 * Identify version on module load. 193 * Identify version on module load.
194 * 194 *
195 * (18/March/2001) Bill Ryder 195 * (18/March/2001) Bill Ryder
196 * (Not released) 196 * (Not released)
197 * Added send break handling. (requires kernel patch too) 197 * Added send break handling. (requires kernel patch too)
198 * Fixed 8U232AM hardware RTS/CTS etc status reporting. 198 * Fixed 8U232AM hardware RTS/CTS etc status reporting.
199 * Added flipbuf fix copied from generic device 199 * Added flipbuf fix copied from generic device
200 * 200 *
201 * (12/3/2000) Bill Ryder 201 * (12/3/2000) Bill Ryder
202 * Added support for 8U232AM device. 202 * Added support for 8U232AM device.
203 * Moved PID and VIDs into header file only. 203 * Moved PID and VIDs into header file only.
@@ -211,14 +211,14 @@
211 * Cleaned up comments. Removed multiple PID/VID definitions. 211 * Cleaned up comments. Removed multiple PID/VID definitions.
212 * Factorised cts/dtr code 212 * Factorised cts/dtr code
213 * Made use of __FUNCTION__ in dbg's 213 * Made use of __FUNCTION__ in dbg's
214 * 214 *
215 * (11/01/2000) Adam J. Richter 215 * (11/01/2000) Adam J. Richter
216 * usb_device_id table support 216 * usb_device_id table support
217 * 217 *
218 * (10/05/2000) gkh 218 * (10/05/2000) gkh
219 * Fixed bug with urb->dev not being set properly, now that the usb 219 * Fixed bug with urb->dev not being set properly, now that the usb
220 * core needs it. 220 * core needs it.
221 * 221 *
222 * (09/11/2000) gkh 222 * (09/11/2000) gkh
223 * Removed DEBUG #ifdefs with call to usb_serial_debug_data 223 * Removed DEBUG #ifdefs with call to usb_serial_debug_data
224 * 224 *
@@ -226,11 +226,11 @@
226 * Added module_init and module_exit functions to handle the fact that this 226 * Added module_init and module_exit functions to handle the fact that this
227 * driver is a loadable module now. 227 * driver is a loadable module now.
228 * 228 *
229 * (04/04/2000) Bill Ryder 229 * (04/04/2000) Bill Ryder
230 * Fixed bugs in TCGET/TCSET ioctls (by removing them - they are 230 * Fixed bugs in TCGET/TCSET ioctls (by removing them - they are
231 * handled elsewhere in the tty io driver chain). 231 * handled elsewhere in the tty io driver chain).
232 * 232 *
233 * (03/30/2000) Bill Ryder 233 * (03/30/2000) Bill Ryder
234 * Implemented lots of ioctls 234 * Implemented lots of ioctls
235 * Fixed a race condition in write 235 * Fixed a race condition in write
236 * Changed some dbg's to errs 236 * Changed some dbg's to errs
@@ -444,13 +444,13 @@ static struct usb_device_id id_table_combined [] = {
444 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, */ 444 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, */
445 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, */ 445 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, */
446 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, */ 446 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, */
447 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, 447 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) },
448 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, 448 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) },
449 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, 449 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) },
450 { USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) }, 450 { USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) },
451 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) }, 451 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) },
452 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) }, 452 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) },
453 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) }, 453 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) },
454 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) }, 454 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) },
455 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) }, 455 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) },
456 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) }, 456 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) },
@@ -522,7 +522,7 @@ static struct usb_driver ftdi_driver = {
522 .probe = usb_serial_probe, 522 .probe = usb_serial_probe,
523 .disconnect = usb_serial_disconnect, 523 .disconnect = usb_serial_disconnect,
524 .id_table = id_table_combined, 524 .id_table = id_table_combined,
525 .no_dynamic_id = 1, 525 .no_dynamic_id = 1,
526}; 526};
527 527
528static const char *ftdi_chip_name[] = { 528static const char *ftdi_chip_name[] = {
@@ -548,13 +548,13 @@ struct ftdi_private {
548 int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */ 548 int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */
549 __u16 last_set_data_urb_value ; 549 __u16 last_set_data_urb_value ;
550 /* the last data state set - needed for doing a break */ 550 /* the last data state set - needed for doing a break */
551 int write_offset; /* This is the offset in the usb data block to write the serial data - 551 int write_offset; /* This is the offset in the usb data block to write the serial data -
552 * it is different between devices 552 * it is different between devices
553 */ 553 */
554 int flags; /* some ASYNC_xxxx flags are supported */ 554 int flags; /* some ASYNC_xxxx flags are supported */
555 unsigned long last_dtr_rts; /* saved modem control outputs */ 555 unsigned long last_dtr_rts; /* saved modem control outputs */
556 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ 556 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
557 char prev_status, diff_status; /* Used for TIOCMIWAIT */ 557 char prev_status, diff_status; /* Used for TIOCMIWAIT */
558 __u8 rx_flags; /* receive state flags (throttling) */ 558 __u8 rx_flags; /* receive state flags (throttling) */
559 spinlock_t rx_lock; /* spinlock for receive state */ 559 spinlock_t rx_lock; /* spinlock for receive state */
560 struct work_struct rx_work; 560 struct work_struct rx_work;
@@ -721,7 +721,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned
721 urb_value |= FTDI_SIO_SET_RTS_HIGH; 721 urb_value |= FTDI_SIO_SET_RTS_HIGH;
722 rv = usb_control_msg(port->serial->dev, 722 rv = usb_control_msg(port->serial->dev,
723 usb_sndctrlpipe(port->serial->dev, 0), 723 usb_sndctrlpipe(port->serial->dev, 0),
724 FTDI_SIO_SET_MODEM_CTRL_REQUEST, 724 FTDI_SIO_SET_MODEM_CTRL_REQUEST,
725 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, 725 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE,
726 urb_value, priv->interface, 726 urb_value, priv->interface,
727 buf, 0, WDR_TIMEOUT); 727 buf, 0, WDR_TIMEOUT);
@@ -768,7 +768,7 @@ static int change_speed(struct usb_serial_port *port)
768 if (priv->interface) { /* FT2232C */ 768 if (priv->interface) { /* FT2232C */
769 urb_index = (__u16)((urb_index << 8) | priv->interface); 769 urb_index = (__u16)((urb_index << 8) | priv->interface);
770 } 770 }
771 771
772 rv = usb_control_msg(port->serial->dev, 772 rv = usb_control_msg(port->serial->dev,
773 usb_sndctrlpipe(port->serial->dev, 0), 773 usb_sndctrlpipe(port->serial->dev, 0),
774 FTDI_SIO_SET_BAUDRATE_REQUEST, 774 FTDI_SIO_SET_BAUDRATE_REQUEST,
@@ -827,7 +827,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
827 827
828 /* 3. Convert baudrate to device-specific divisor */ 828 /* 3. Convert baudrate to device-specific divisor */
829 829
830 if (!baud) baud = 9600; 830 if (!baud) baud = 9600;
831 switch(priv->chip_type) { 831 switch(priv->chip_type) {
832 case SIO: /* SIO chip */ 832 case SIO: /* SIO chip */
833 switch(baud) { 833 switch(baud) {
@@ -843,7 +843,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
843 case 115200: div_value = ftdi_sio_b115200; break; 843 case 115200: div_value = ftdi_sio_b115200; break;
844 } /* baud */ 844 } /* baud */
845 if (div_value == 0) { 845 if (div_value == 0) {
846 dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); 846 dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud);
847 div_value = ftdi_sio_b9600; 847 div_value = ftdi_sio_b9600;
848 div_okay = 0; 848 div_okay = 0;
849 } 849 }
@@ -925,7 +925,7 @@ static int set_serial_info(struct usb_serial_port * port, struct serial_struct _
925 /* Make the changes - these are privileged changes! */ 925 /* Make the changes - these are privileged changes! */
926 926
927 priv->flags = ((priv->flags & ~ASYNC_FLAGS) | 927 priv->flags = ((priv->flags & ~ASYNC_FLAGS) |
928 (new_serial.flags & ASYNC_FLAGS)); 928 (new_serial.flags & ASYNC_FLAGS));
929 priv->custom_divisor = new_serial.custom_divisor; 929 priv->custom_divisor = new_serial.custom_divisor;
930 930
931 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 931 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
@@ -950,7 +950,7 @@ check_and_exit:
950 (old_priv.custom_divisor != priv->custom_divisor))) { 950 (old_priv.custom_divisor != priv->custom_divisor))) {
951 change_speed(port); 951 change_speed(port);
952 } 952 }
953 953
954 return (0); 954 return (0);
955 955
956} /* set_serial_info */ 956} /* set_serial_info */
@@ -1022,18 +1022,18 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a
1022 struct usb_device *udev; 1022 struct usb_device *udev;
1023 unsigned short latency = 0; 1023 unsigned short latency = 0;
1024 int rv = 0; 1024 int rv = 0;
1025 1025
1026 udev = to_usb_device(dev); 1026 udev = to_usb_device(dev);
1027 1027
1028 dbg("%s",__FUNCTION__); 1028 dbg("%s",__FUNCTION__);
1029 1029
1030 rv = usb_control_msg(udev, 1030 rv = usb_control_msg(udev,
1031 usb_rcvctrlpipe(udev, 0), 1031 usb_rcvctrlpipe(udev, 0),
1032 FTDI_SIO_GET_LATENCY_TIMER_REQUEST, 1032 FTDI_SIO_GET_LATENCY_TIMER_REQUEST,
1033 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 1033 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
1034 0, priv->interface, 1034 0, priv->interface,
1035 (char*) &latency, 1, WDR_TIMEOUT); 1035 (char*) &latency, 1, WDR_TIMEOUT);
1036 1036
1037 if (rv < 0) { 1037 if (rv < 0) {
1038 dev_err(dev, "Unable to read latency timer: %i", rv); 1038 dev_err(dev, "Unable to read latency timer: %i", rv);
1039 return -EIO; 1039 return -EIO;
@@ -1051,23 +1051,23 @@ static ssize_t store_latency_timer(struct device *dev, struct device_attribute *
1051 char buf[1]; 1051 char buf[1];
1052 int v = simple_strtoul(valbuf, NULL, 10); 1052 int v = simple_strtoul(valbuf, NULL, 10);
1053 int rv = 0; 1053 int rv = 0;
1054 1054
1055 udev = to_usb_device(dev); 1055 udev = to_usb_device(dev);
1056 1056
1057 dbg("%s: setting latency timer = %i", __FUNCTION__, v); 1057 dbg("%s: setting latency timer = %i", __FUNCTION__, v);
1058 1058
1059 rv = usb_control_msg(udev, 1059 rv = usb_control_msg(udev,
1060 usb_sndctrlpipe(udev, 0), 1060 usb_sndctrlpipe(udev, 0),
1061 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1061 FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1062 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1062 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
1063 v, priv->interface, 1063 v, priv->interface,
1064 buf, 0, WDR_TIMEOUT); 1064 buf, 0, WDR_TIMEOUT);
1065 1065
1066 if (rv < 0) { 1066 if (rv < 0) {
1067 dev_err(dev, "Unable to write latency timer: %i", rv); 1067 dev_err(dev, "Unable to write latency timer: %i", rv);
1068 return -EIO; 1068 return -EIO;
1069 } 1069 }
1070 1070
1071 return count; 1071 return count;
1072} 1072}
1073 1073
@@ -1082,23 +1082,23 @@ static ssize_t store_event_char(struct device *dev, struct device_attribute *att
1082 char buf[1]; 1082 char buf[1];
1083 int v = simple_strtoul(valbuf, NULL, 10); 1083 int v = simple_strtoul(valbuf, NULL, 10);
1084 int rv = 0; 1084 int rv = 0;
1085 1085
1086 udev = to_usb_device(dev); 1086 udev = to_usb_device(dev);
1087 1087
1088 dbg("%s: setting event char = %i", __FUNCTION__, v); 1088 dbg("%s: setting event char = %i", __FUNCTION__, v);
1089 1089
1090 rv = usb_control_msg(udev, 1090 rv = usb_control_msg(udev,
1091 usb_sndctrlpipe(udev, 0), 1091 usb_sndctrlpipe(udev, 0),
1092 FTDI_SIO_SET_EVENT_CHAR_REQUEST, 1092 FTDI_SIO_SET_EVENT_CHAR_REQUEST,
1093 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, 1093 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE,
1094 v, priv->interface, 1094 v, priv->interface,
1095 buf, 0, WDR_TIMEOUT); 1095 buf, 0, WDR_TIMEOUT);
1096 1096
1097 if (rv < 0) { 1097 if (rv < 0) {
1098 dbg("Unable to write event character: %i", rv); 1098 dbg("Unable to write event character: %i", rv);
1099 return -EIO; 1099 return -EIO;
1100 } 1100 }
1101 1101
1102 return count; 1102 return count;
1103} 1103}
1104 1104
@@ -1135,11 +1135,11 @@ static void remove_sysfs_attrs(struct usb_serial *serial)
1135 struct ftdi_private *priv; 1135 struct ftdi_private *priv;
1136 struct usb_device *udev; 1136 struct usb_device *udev;
1137 1137
1138 dbg("%s",__FUNCTION__); 1138 dbg("%s",__FUNCTION__);
1139 1139
1140 priv = usb_get_serial_port_data(serial->port[0]); 1140 priv = usb_get_serial_port_data(serial->port[0]);
1141 udev = serial->dev; 1141 udev = serial->dev;
1142 1142
1143 /* XXX see create_sysfs_attrs */ 1143 /* XXX see create_sysfs_attrs */
1144 if (priv->chip_type != SIO) { 1144 if (priv->chip_type != SIO) {
1145 device_remove_file(&udev->dev, &dev_attr_event_char); 1145 device_remove_file(&udev->dev, &dev_attr_event_char);
@@ -1147,7 +1147,7 @@ static void remove_sysfs_attrs(struct usb_serial *serial)
1147 device_remove_file(&udev->dev, &dev_attr_latency_timer); 1147 device_remove_file(&udev->dev, &dev_attr_latency_timer);
1148 } 1148 }
1149 } 1149 }
1150 1150
1151} 1151}
1152 1152
1153/* 1153/*
@@ -1258,7 +1258,7 @@ static void ftdi_HE_TIRA1_setup (struct usb_serial *serial)
1258} /* ftdi_HE_TIRA1_setup */ 1258} /* ftdi_HE_TIRA1_setup */
1259 1259
1260 1260
1261/* ftdi_shutdown is called from usbserial:usb_serial_disconnect 1261/* ftdi_shutdown is called from usbserial:usb_serial_disconnect
1262 * it is called when the usb device is disconnected 1262 * it is called when the usb device is disconnected
1263 * 1263 *
1264 * usbserial:usb_serial_disconnect 1264 * usbserial:usb_serial_disconnect
@@ -1269,16 +1269,16 @@ static void ftdi_HE_TIRA1_setup (struct usb_serial *serial)
1269 1269
1270static void ftdi_shutdown (struct usb_serial *serial) 1270static void ftdi_shutdown (struct usb_serial *serial)
1271{ /* ftdi_shutdown */ 1271{ /* ftdi_shutdown */
1272 1272
1273 struct usb_serial_port *port = serial->port[0]; 1273 struct usb_serial_port *port = serial->port[0];
1274 struct ftdi_private *priv = usb_get_serial_port_data(port); 1274 struct ftdi_private *priv = usb_get_serial_port_data(port);
1275 1275
1276 dbg("%s", __FUNCTION__); 1276 dbg("%s", __FUNCTION__);
1277 1277
1278 remove_sysfs_attrs(serial); 1278 remove_sysfs_attrs(serial);
1279 1279
1280 /* all open ports are closed at this point 1280 /* all open ports are closed at this point
1281 * (by usbserial.c:__serial_close, which calls ftdi_close) 1281 * (by usbserial.c:__serial_close, which calls ftdi_close)
1282 */ 1282 */
1283 1283
1284 if (priv) { 1284 if (priv) {
@@ -1293,7 +1293,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1293 struct usb_device *dev = port->serial->dev; 1293 struct usb_device *dev = port->serial->dev;
1294 struct ftdi_private *priv = usb_get_serial_port_data(port); 1294 struct ftdi_private *priv = usb_get_serial_port_data(port);
1295 unsigned long flags; 1295 unsigned long flags;
1296 1296
1297 int result = 0; 1297 int result = 0;
1298 char buf[1]; /* Needed for the usb_control_msg I think */ 1298 char buf[1]; /* Needed for the usb_control_msg I think */
1299 1299
@@ -1312,8 +1312,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1312 /* No error checking for this (will get errors later anyway) */ 1312 /* No error checking for this (will get errors later anyway) */
1313 /* See ftdi_sio.h for description of what is reset */ 1313 /* See ftdi_sio.h for description of what is reset */
1314 usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1314 usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1315 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE, 1315 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE,
1316 FTDI_SIO_RESET_SIO, 1316 FTDI_SIO_RESET_SIO,
1317 priv->interface, buf, 0, WDR_TIMEOUT); 1317 priv->interface, buf, 0, WDR_TIMEOUT);
1318 1318
1319 /* Termios defaults are set by usb_serial_init. We don't change 1319 /* Termios defaults are set by usb_serial_init. We don't change
@@ -1350,12 +1350,12 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1350 1350
1351 1351
1352 1352
1353/* 1353/*
1354 * usbserial:__serial_close only calls ftdi_close if the point is open 1354 * usbserial:__serial_close only calls ftdi_close if the point is open
1355 * 1355 *
1356 * This only gets called when it is the last close 1356 * This only gets called when it is the last close
1357 * 1357 *
1358 * 1358 *
1359 */ 1359 */
1360 1360
1361static void ftdi_close (struct usb_serial_port *port, struct file *filp) 1361static void ftdi_close (struct usb_serial_port *port, struct file *filp)
@@ -1368,14 +1368,14 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1368 1368
1369 if (c_cflag & HUPCL){ 1369 if (c_cflag & HUPCL){
1370 /* Disable flow control */ 1370 /* Disable flow control */
1371 if (usb_control_msg(port->serial->dev, 1371 if (usb_control_msg(port->serial->dev,
1372 usb_sndctrlpipe(port->serial->dev, 0), 1372 usb_sndctrlpipe(port->serial->dev, 0),
1373 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1373 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1374 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1374 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1375 0, priv->interface, buf, 0, 1375 0, priv->interface, buf, 0,
1376 WDR_TIMEOUT) < 0) { 1376 WDR_TIMEOUT) < 0) {
1377 err("error from flowcontrol urb"); 1377 err("error from flowcontrol urb");
1378 } 1378 }
1379 1379
1380 /* drop RTS and DTR */ 1380 /* drop RTS and DTR */
1381 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 1381 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
@@ -1384,14 +1384,14 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1384 /* cancel any scheduled reading */ 1384 /* cancel any scheduled reading */
1385 cancel_delayed_work(&priv->rx_work); 1385 cancel_delayed_work(&priv->rx_work);
1386 flush_scheduled_work(); 1386 flush_scheduled_work();
1387 1387
1388 /* shutdown our bulk read */ 1388 /* shutdown our bulk read */
1389 if (port->read_urb) 1389 if (port->read_urb)
1390 usb_kill_urb(port->read_urb); 1390 usb_kill_urb(port->read_urb);
1391} /* ftdi_close */ 1391} /* ftdi_close */
1392 1392
1393 1393
1394 1394
1395/* The SIO requires the first byte to have: 1395/* The SIO requires the first byte to have:
1396 * B0 1 1396 * B0 1
1397 * B1 0 1397 * B1 0
@@ -1423,7 +1423,7 @@ static int ftdi_write (struct usb_serial_port *port,
1423 return 0; 1423 return 0;
1424 } 1424 }
1425 spin_unlock_irqrestore(&priv->tx_lock, flags); 1425 spin_unlock_irqrestore(&priv->tx_lock, flags);
1426 1426
1427 data_offset = priv->write_offset; 1427 data_offset = priv->write_offset;
1428 dbg("data_offset set to %d",data_offset); 1428 dbg("data_offset set to %d",data_offset);
1429 1429
@@ -1462,7 +1462,7 @@ static int ftdi_write (struct usb_serial_port *port,
1462 user_pktsz = todo; 1462 user_pktsz = todo;
1463 } 1463 }
1464 /* Write the control byte at the front of the packet*/ 1464 /* Write the control byte at the front of the packet*/
1465 *first_byte = 1 | ((user_pktsz) << 2); 1465 *first_byte = 1 | ((user_pktsz) << 2);
1466 /* Copy data for packet */ 1466 /* Copy data for packet */
1467 memcpy (first_byte + data_offset, 1467 memcpy (first_byte + data_offset,
1468 current_position, user_pktsz); 1468 current_position, user_pktsz);
@@ -1479,7 +1479,7 @@ static int ftdi_write (struct usb_serial_port *port,
1479 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, buffer); 1479 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, buffer);
1480 1480
1481 /* fill the buffer and send it */ 1481 /* fill the buffer and send it */
1482 usb_fill_bulk_urb(urb, port->serial->dev, 1482 usb_fill_bulk_urb(urb, port->serial->dev,
1483 usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), 1483 usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress),
1484 buffer, transfer_size, 1484 buffer, transfer_size,
1485 ftdi_write_bulk_callback, port); 1485 ftdi_write_bulk_callback, port);
@@ -1520,7 +1520,7 @@ static void ftdi_write_bulk_callback (struct urb *urb)
1520 kfree (urb->transfer_buffer); 1520 kfree (urb->transfer_buffer);
1521 1521
1522 dbg("%s - port %d", __FUNCTION__, port->number); 1522 dbg("%s - port %d", __FUNCTION__, port->number);
1523 1523
1524 if (urb->status) { 1524 if (urb->status) {
1525 dbg("nonzero write bulk status received: %d", urb->status); 1525 dbg("nonzero write bulk status received: %d", urb->status);
1526 return; 1526 return;
@@ -1651,7 +1651,7 @@ static void ftdi_process_read (void *param)
1651 struct tty_struct *tty; 1651 struct tty_struct *tty;
1652 struct ftdi_private *priv; 1652 struct ftdi_private *priv;
1653 char error_flag; 1653 char error_flag;
1654 unsigned char *data; 1654 unsigned char *data;
1655 1655
1656 int i; 1656 int i;
1657 int result; 1657 int result;
@@ -1759,7 +1759,7 @@ static void ftdi_process_read (void *param)
1759 } 1759 }
1760 if (length > 0) { 1760 if (length > 0) {
1761 for (i = 2; i < length+2; i++) { 1761 for (i = 2; i < length+2; i++) {
1762 /* Note that the error flag is duplicated for 1762 /* Note that the error flag is duplicated for
1763 every character received since we don't know 1763 every character received since we don't know
1764 which character it applied to */ 1764 which character it applied to */
1765 tty_insert_flip_char(tty, data[packet_offset+i], error_flag); 1765 tty_insert_flip_char(tty, data[packet_offset+i], error_flag);
@@ -1773,7 +1773,7 @@ static void ftdi_process_read (void *param)
1773 This doesn't work well since the application receives a never 1773 This doesn't work well since the application receives a never
1774 ending stream of bad data - even though new data hasn't been sent. 1774 ending stream of bad data - even though new data hasn't been sent.
1775 Therefore I (bill) have taken this out. 1775 Therefore I (bill) have taken this out.
1776 However - this might make sense for framing errors and so on 1776 However - this might make sense for framing errors and so on
1777 so I am leaving the code in for now. 1777 so I am leaving the code in for now.
1778 */ 1778 */
1779 else { 1779 else {
@@ -1827,7 +1827,7 @@ static void ftdi_process_read (void *param)
1827 /* if the port is closed stop trying to read */ 1827 /* if the port is closed stop trying to read */
1828 if (port->open_count > 0){ 1828 if (port->open_count > 0){
1829 /* Continue trying to always read */ 1829 /* Continue trying to always read */
1830 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 1830 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
1831 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), 1831 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
1832 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, 1832 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
1833 ftdi_read_bulk_callback, port); 1833 ftdi_read_bulk_callback, port);
@@ -1844,9 +1844,9 @@ static void ftdi_process_read (void *param)
1844static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) 1844static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
1845{ 1845{
1846 struct ftdi_private *priv = usb_get_serial_port_data(port); 1846 struct ftdi_private *priv = usb_get_serial_port_data(port);
1847 __u16 urb_value = 0; 1847 __u16 urb_value = 0;
1848 char buf[1]; 1848 char buf[1];
1849 1849
1850 /* break_state = -1 to turn on break, and 0 to turn off break */ 1850 /* break_state = -1 to turn on break, and 0 to turn off break */
1851 /* see drivers/char/tty_io.c to see it used */ 1851 /* see drivers/char/tty_io.c to see it used */
1852 /* last_set_data_urb_value NEVER has the break bit set in it */ 1852 /* last_set_data_urb_value NEVER has the break bit set in it */
@@ -1854,20 +1854,20 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
1854 if (break_state) { 1854 if (break_state) {
1855 urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK; 1855 urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK;
1856 } else { 1856 } else {
1857 urb_value = priv->last_set_data_urb_value; 1857 urb_value = priv->last_set_data_urb_value;
1858 } 1858 }
1859 1859
1860 1860
1861 if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), 1861 if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
1862 FTDI_SIO_SET_DATA_REQUEST, 1862 FTDI_SIO_SET_DATA_REQUEST,
1863 FTDI_SIO_SET_DATA_REQUEST_TYPE, 1863 FTDI_SIO_SET_DATA_REQUEST_TYPE,
1864 urb_value , priv->interface, 1864 urb_value , priv->interface,
1865 buf, 0, WDR_TIMEOUT) < 0) { 1865 buf, 0, WDR_TIMEOUT) < 0) {
1866 err("%s FAILED to enable/disable break state (state was %d)", __FUNCTION__,break_state); 1866 err("%s FAILED to enable/disable break state (state was %d)", __FUNCTION__,break_state);
1867 } 1867 }
1868 1868
1869 dbg("%s break state is %d - urb is %d", __FUNCTION__,break_state, urb_value); 1869 dbg("%s break state is %d - urb is %d", __FUNCTION__,break_state, urb_value);
1870 1870
1871} 1871}
1872 1872
1873 1873
@@ -1883,12 +1883,12 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1883 struct ftdi_private *priv = usb_get_serial_port_data(port); 1883 struct ftdi_private *priv = usb_get_serial_port_data(port);
1884 __u16 urb_value; /* will hold the new flags */ 1884 __u16 urb_value; /* will hold the new flags */
1885 char buf[1]; /* Perhaps I should dynamically alloc this? */ 1885 char buf[1]; /* Perhaps I should dynamically alloc this? */
1886 1886
1887 // Added for xon/xoff support 1887 // Added for xon/xoff support
1888 unsigned int iflag = port->tty->termios->c_iflag; 1888 unsigned int iflag = port->tty->termios->c_iflag;
1889 unsigned char vstop; 1889 unsigned char vstop;
1890 unsigned char vstart; 1890 unsigned char vstart;
1891 1891
1892 dbg("%s", __FUNCTION__); 1892 dbg("%s", __FUNCTION__);
1893 1893
1894 /* Force baud rate if this device requires it, unless it is set to B0. */ 1894 /* Force baud rate if this device requires it, unless it is set to B0. */
@@ -1906,20 +1906,20 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1906 1906
1907 cflag = port->tty->termios->c_cflag; 1907 cflag = port->tty->termios->c_cflag;
1908 1908
1909 /* FIXME -For this cut I don't care if the line is really changing or 1909 /* FIXME -For this cut I don't care if the line is really changing or
1910 not - so just do the change regardless - should be able to 1910 not - so just do the change regardless - should be able to
1911 compare old_termios and tty->termios */ 1911 compare old_termios and tty->termios */
1912 /* NOTE These routines can get interrupted by 1912 /* NOTE These routines can get interrupted by
1913 ftdi_sio_read_bulk_callback - need to examine what this 1913 ftdi_sio_read_bulk_callback - need to examine what this
1914 means - don't see any problems yet */ 1914 means - don't see any problems yet */
1915 1915
1916 /* Set number of data bits, parity, stop bits */ 1916 /* Set number of data bits, parity, stop bits */
1917 1917
1918 urb_value = 0; 1918 urb_value = 0;
1919 urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : 1919 urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 :
1920 FTDI_SIO_SET_DATA_STOP_BITS_1); 1920 FTDI_SIO_SET_DATA_STOP_BITS_1);
1921 urb_value |= (cflag & PARENB ? 1921 urb_value |= (cflag & PARENB ?
1922 (cflag & PARODD ? FTDI_SIO_SET_DATA_PARITY_ODD : 1922 (cflag & PARODD ? FTDI_SIO_SET_DATA_PARITY_ODD :
1923 FTDI_SIO_SET_DATA_PARITY_EVEN) : 1923 FTDI_SIO_SET_DATA_PARITY_EVEN) :
1924 FTDI_SIO_SET_DATA_PARITY_NONE); 1924 FTDI_SIO_SET_DATA_PARITY_NONE);
1925 if (cflag & CSIZE) { 1925 if (cflag & CSIZE) {
@@ -1936,25 +1936,25 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1936 /* This is needed by the break command since it uses the same command - but is 1936 /* This is needed by the break command since it uses the same command - but is
1937 * or'ed with this value */ 1937 * or'ed with this value */
1938 priv->last_set_data_urb_value = urb_value; 1938 priv->last_set_data_urb_value = urb_value;
1939 1939
1940 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1940 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1941 FTDI_SIO_SET_DATA_REQUEST, 1941 FTDI_SIO_SET_DATA_REQUEST,
1942 FTDI_SIO_SET_DATA_REQUEST_TYPE, 1942 FTDI_SIO_SET_DATA_REQUEST_TYPE,
1943 urb_value , priv->interface, 1943 urb_value , priv->interface,
1944 buf, 0, WDR_SHORT_TIMEOUT) < 0) { 1944 buf, 0, WDR_SHORT_TIMEOUT) < 0) {
1945 err("%s FAILED to set databits/stopbits/parity", __FUNCTION__); 1945 err("%s FAILED to set databits/stopbits/parity", __FUNCTION__);
1946 } 1946 }
1947 1947
1948 /* Now do the baudrate */ 1948 /* Now do the baudrate */
1949 if ((cflag & CBAUD) == B0 ) { 1949 if ((cflag & CBAUD) == B0 ) {
1950 /* Disable flow control */ 1950 /* Disable flow control */
1951 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1951 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1952 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1952 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1953 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1953 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1954 0, priv->interface, 1954 0, priv->interface,
1955 buf, 0, WDR_TIMEOUT) < 0) { 1955 buf, 0, WDR_TIMEOUT) < 0) {
1956 err("%s error from disable flowcontrol urb", __FUNCTION__); 1956 err("%s error from disable flowcontrol urb", __FUNCTION__);
1957 } 1957 }
1958 /* Drop RTS and DTR */ 1958 /* Drop RTS and DTR */
1959 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 1959 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1960 } else { 1960 } else {
@@ -1972,16 +1972,16 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1972 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ 1972 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */
1973 if (cflag & CRTSCTS) { 1973 if (cflag & CRTSCTS) {
1974 dbg("%s Setting to CRTSCTS flow control", __FUNCTION__); 1974 dbg("%s Setting to CRTSCTS flow control", __FUNCTION__);
1975 if (usb_control_msg(dev, 1975 if (usb_control_msg(dev,
1976 usb_sndctrlpipe(dev, 0), 1976 usb_sndctrlpipe(dev, 0),
1977 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1977 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1978 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1978 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1979 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), 1979 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface),
1980 buf, 0, WDR_TIMEOUT) < 0) { 1980 buf, 0, WDR_TIMEOUT) < 0) {
1981 err("urb failed to set to rts/cts flow control"); 1981 err("urb failed to set to rts/cts flow control");
1982 } 1982 }
1983 1983
1984 } else { 1984 } else {
1985 /* 1985 /*
1986 * Xon/Xoff code 1986 * Xon/Xoff code
1987 * 1987 *
@@ -2011,16 +2011,16 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
2011 /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */ 2011 /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */
2012 /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */ 2012 /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */
2013 dbg("%s Turning off hardware flow control", __FUNCTION__); 2013 dbg("%s Turning off hardware flow control", __FUNCTION__);
2014 if (usb_control_msg(dev, 2014 if (usb_control_msg(dev,
2015 usb_sndctrlpipe(dev, 0), 2015 usb_sndctrlpipe(dev, 0),
2016 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2016 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2017 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2017 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2018 0, priv->interface, 2018 0, priv->interface,
2019 buf, 0, WDR_TIMEOUT) < 0) { 2019 buf, 0, WDR_TIMEOUT) < 0) {
2020 err("urb failed to clear flow control"); 2020 err("urb failed to clear flow control");
2021 } 2021 }
2022 } 2022 }
2023 2023
2024 } 2024 }
2025 return; 2025 return;
2026} /* ftdi_termios */ 2026} /* ftdi_termios */
@@ -2036,11 +2036,11 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2036 switch (priv->chip_type) { 2036 switch (priv->chip_type) {
2037 case SIO: 2037 case SIO:
2038 /* Request the status from the device */ 2038 /* Request the status from the device */
2039 if ((ret = usb_control_msg(port->serial->dev, 2039 if ((ret = usb_control_msg(port->serial->dev,
2040 usb_rcvctrlpipe(port->serial->dev, 0), 2040 usb_rcvctrlpipe(port->serial->dev, 0),
2041 FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2041 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2042 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2042 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2043 0, 0, 2043 0, 0,
2044 buf, 1, WDR_TIMEOUT)) < 0 ) { 2044 buf, 1, WDR_TIMEOUT)) < 0 ) {
2045 err("%s Could not get modem status of device - err: %d", __FUNCTION__, 2045 err("%s Could not get modem status of device - err: %d", __FUNCTION__,
2046 ret); 2046 ret);
@@ -2052,11 +2052,11 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2052 case FT2232C: 2052 case FT2232C:
2053 /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same 2053 /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same
2054 format as the data returned from the in point */ 2054 format as the data returned from the in point */
2055 if ((ret = usb_control_msg(port->serial->dev, 2055 if ((ret = usb_control_msg(port->serial->dev,
2056 usb_rcvctrlpipe(port->serial->dev, 0), 2056 usb_rcvctrlpipe(port->serial->dev, 0),
2057 FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2057 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2058 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2058 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2059 0, priv->interface, 2059 0, priv->interface,
2060 buf, 2, WDR_TIMEOUT)) < 0 ) { 2060 buf, 2, WDR_TIMEOUT)) < 0 ) {
2061 err("%s Could not get modem status of device - err: %d", __FUNCTION__, 2061 err("%s Could not get modem status of device - err: %d", __FUNCTION__,
2062 ret); 2062 ret);
@@ -2067,12 +2067,12 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2067 return -EFAULT; 2067 return -EFAULT;
2068 break; 2068 break;
2069 } 2069 }
2070 2070
2071 return (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | 2071 return (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
2072 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | 2072 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
2073 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | 2073 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |
2074 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | 2074 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) |
2075 priv->last_dtr_rts; 2075 priv->last_dtr_rts;
2076} 2076}
2077 2077
2078static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear) 2078static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear)
@@ -2138,11 +2138,11 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
2138 break; 2138 break;
2139 default: 2139 default:
2140 break; 2140 break;
2141 2141
2142 } 2142 }
2143 2143
2144 2144
2145 /* This is not necessarily an error - turns out the higher layers will do 2145 /* This is not necessarily an error - turns out the higher layers will do
2146 * some ioctls itself (see comment above) 2146 * some ioctls itself (see comment above)
2147 */ 2147 */
2148 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __FUNCTION__, cmd); 2148 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __FUNCTION__, cmd);
@@ -2199,7 +2199,7 @@ static int __init ftdi_init (void)
2199 if (retval) 2199 if (retval)
2200 goto failed_sio_register; 2200 goto failed_sio_register;
2201 retval = usb_register(&ftdi_driver); 2201 retval = usb_register(&ftdi_driver);
2202 if (retval) 2202 if (retval)
2203 goto failed_usb_register; 2203 goto failed_usb_register;
2204 2204
2205 info(DRIVER_VERSION ":" DRIVER_DESC); 2205 info(DRIVER_VERSION ":" DRIVER_DESC);
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
new file mode 100644
index 000000000000..82cd15b894b0
--- /dev/null
+++ b/drivers/usb/serial/mos7720.c
@@ -0,0 +1,1683 @@
1/*
2 * mos7720.c
3 * Controls the Moschip 7720 usb to dual port serial convertor
4 *
5 * Copyright 2006 Moschip Semiconductor Tech. Ltd.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, version 2 of the License.
10 *
11 * Developed by:
12 * VijayaKumar.G.N. <vijaykumar@aspirecom.net>
13 * AjayKumar <ajay@aspirecom.net>
14 * Gurudeva.N. <gurudev@aspirecom.net>
15 *
16 * Cleaned up from the original by:
17 * Greg Kroah-Hartman <gregkh@suse.de>
18 *
19 * Originally based on drivers/usb/serial/io_edgeport.c which is:
20 * Copyright (C) 2000 Inside Out Networks, All rights reserved.
21 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
22 */
23#include <linux/kernel.h>
24#include <linux/errno.h>
25#include <linux/init.h>
26#include <linux/slab.h>
27#include <linux/tty.h>
28#include <linux/tty_driver.h>
29#include <linux/tty_flip.h>
30#include <linux/module.h>
31#include <linux/spinlock.h>
32#include <linux/serial.h>
33#include <linux/serial_reg.h>
34#include <linux/usb.h>
35#include <linux/usb/serial.h>
36#include <asm/uaccess.h>
37
38
39/*
40 * Version Information
41 */
42#define DRIVER_VERSION "1.0.0.4F"
43#define DRIVER_AUTHOR "Aspire Communications pvt Ltd."
44#define DRIVER_DESC "Moschip USB Serial Driver"
45
46/* default urb timeout */
47#define MOS_WDR_TIMEOUT (HZ * 5)
48
49#define MOS_PORT1 0x0200
50#define MOS_PORT2 0x0300
51#define MOS_VENREG 0x0000
52#define MOS_MAX_PORT 0x02
53#define MOS_WRITE 0x0E
54#define MOS_READ 0x0D
55
56/* Interrupt Rotinue Defines */
57#define SERIAL_IIR_RLS 0x06
58#define SERIAL_IIR_RDA 0x04
59#define SERIAL_IIR_CTI 0x0c
60#define SERIAL_IIR_THR 0x02
61#define SERIAL_IIR_MS 0x00
62
63#define NUM_URBS 16 /* URB Count */
64#define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */
65
66/* This structure holds all of the local port information */
67struct moschip_port
68{
69 __u8 shadowLCR; /* last LCR value received */
70 __u8 shadowMCR; /* last MCR value received */
71 __u8 shadowMSR; /* last MSR value received */
72 char open;
73 struct async_icount icount;
74 struct usb_serial_port *port; /* loop back to the owner */
75 struct urb *write_urb_pool[NUM_URBS];
76};
77
78/* This structure holds all of the individual serial device information */
79struct moschip_serial
80{
81 int interrupt_started;
82};
83
84static int debug;
85
86#define USB_VENDOR_ID_MOSCHIP 0x9710
87#define MOSCHIP_DEVICE_ID_7720 0x7720
88#define MOSCHIP_DEVICE_ID_7715 0x7715
89
90static struct usb_device_id moschip_port_id_table [] = {
91 { USB_DEVICE(USB_VENDOR_ID_MOSCHIP,MOSCHIP_DEVICE_ID_7720) },
92 { } /* terminating entry */
93};
94MODULE_DEVICE_TABLE(usb, moschip_port_id_table);
95
96
97/*
98 * mos7720_interrupt_callback
99 * this is the callback function for when we have received data on the
100 * interrupt endpoint.
101 */
102static void mos7720_interrupt_callback(struct urb *urb)
103{
104 int result;
105 int length;
106 __u32 *data;
107 unsigned int status;
108 __u8 sp1;
109 __u8 sp2;
110 __u8 st;
111
112 dbg("%s"," : Entering\n");
113
114 if (!urb) {
115 dbg("%s","Invalid Pointer !!!!:\n");
116 return;
117 }
118
119 switch (urb->status) {
120 case 0:
121 /* success */
122 break;
123 case -ECONNRESET:
124 case -ENOENT:
125 case -ESHUTDOWN:
126 /* this urb is terminated, clean up */
127 dbg("%s - urb shutting down with status: %d", __FUNCTION__,
128 urb->status);
129 return;
130 default:
131 dbg("%s - nonzero urb status received: %d", __FUNCTION__,
132 urb->status);
133 goto exit;
134 }
135
136 length = urb->actual_length;
137 data = urb->transfer_buffer;
138
139 /* Moschip get 4 bytes
140 * Byte 1 IIR Port 1 (port.number is 0)
141 * Byte 2 IIR Port 2 (port.number is 1)
142 * Byte 3 --------------
143 * Byte 4 FIFO status for both */
144 if (length && length > 4) {
145 dbg("Wrong data !!!");
146 return;
147 }
148
149 status = *data;
150
151 sp1 = (status & 0xff000000)>>24;
152 sp2 = (status & 0x00ff0000)>>16;
153 st = status & 0x000000ff;
154
155 if ((sp1 & 0x01) || (sp2 & 0x01)) {
156 /* No Interrupt Pending in both the ports */
157 dbg("No Interrupt !!!");
158 } else {
159 switch (sp1 & 0x0f) {
160 case SERIAL_IIR_RLS:
161 dbg("Serial Port 1: Receiver status error or address "
162 "bit detected in 9-bit mode\n");
163 break;
164 case SERIAL_IIR_CTI:
165 dbg("Serial Port 1: Receiver time out");
166 break;
167 case SERIAL_IIR_MS:
168 dbg("Serial Port 1: Modem status change");
169 break;
170 }
171
172 switch (sp2 & 0x0f) {
173 case SERIAL_IIR_RLS:
174 dbg("Serial Port 2: Receiver status error or address "
175 "bit detected in 9-bit mode");
176 break;
177 case SERIAL_IIR_CTI:
178 dbg("Serial Port 2: Receiver time out");
179 break;
180 case SERIAL_IIR_MS:
181 dbg("Serial Port 2: Modem status change");
182 break;
183 }
184 }
185
186exit:
187 result = usb_submit_urb(urb, GFP_ATOMIC);
188 if (result)
189 dev_err(&urb->dev->dev,
190 "%s - Error %d submitting control urb\n",
191 __FUNCTION__, result);
192 return;
193}
194
195/*
196 * mos7720_bulk_in_callback
197 * this is the callback function for when we have received data on the
198 * bulk in endpoint.
199 */
200static void mos7720_bulk_in_callback(struct urb *urb)
201{
202 int status;
203 unsigned char *data ;
204 struct usb_serial_port *port;
205 struct moschip_port *mos7720_port;
206 struct tty_struct *tty;
207
208 if (urb->status) {
209 dbg("nonzero read bulk status received: %d",urb->status);
210 return;
211 }
212
213 mos7720_port = urb->context;
214 if (!mos7720_port) {
215 dbg("%s","NULL mos7720_port pointer \n");
216 return ;
217 }
218
219 port = mos7720_port->port;
220
221 dbg("Entering...%s", __FUNCTION__);
222
223 data = urb->transfer_buffer;
224
225 tty = port->tty;
226 if (tty && urb->actual_length) {
227 tty_buffer_request_room(tty, urb->actual_length);
228 tty_insert_flip_string(tty, data, urb->actual_length);
229 tty_flip_buffer_push(tty);
230 }
231
232 if (!port->read_urb) {
233 dbg("URB KILLED !!!");
234 return;
235 }
236
237 if (port->read_urb->status != -EINPROGRESS) {
238 port->read_urb->dev = port->serial->dev;
239
240 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
241 if (status)
242 dbg("usb_submit_urb(read bulk) failed, status = %d",
243 status);
244 }
245}
246
247/*
248 * mos7720_bulk_out_data_callback
249 * this is the callback function for when we have finished sending serial
250 * data on the bulk out endpoint.
251 */
252static void mos7720_bulk_out_data_callback(struct urb *urb)
253{
254 struct moschip_port *mos7720_port;
255 struct tty_struct *tty;
256
257 if (urb->status) {
258 dbg("nonzero write bulk status received:%d", urb->status);
259 return;
260 }
261
262 mos7720_port = urb->context;
263 if (!mos7720_port) {
264 dbg("NULL mos7720_port pointer");
265 return ;
266 }
267
268 dbg("Entering .........");
269
270 tty = mos7720_port->port->tty;
271
272 if (tty && mos7720_port->open) {
273 /* let the tty driver wakeup if it has a special *
274 * write_wakeup function */
275 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
276 tty->ldisc.write_wakeup)
277 (tty->ldisc.write_wakeup)(tty);
278
279 /* tell the tty driver that something has changed */
280 wake_up_interruptible(&tty->write_wait);
281 }
282
283 /* schedule_work(&mos7720_port->port->work); */
284}
285
286/*
287 * send_mos_cmd
288 * this function will be used for sending command to device
289 */
290static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
291 __u16 index, void *data)
292{
293 int status;
294 unsigned int pipe;
295 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
296 __u8 requesttype;
297 __u16 size = 0x0000;
298
299 if (value < MOS_MAX_PORT) {
300 if (product == MOSCHIP_DEVICE_ID_7715) {
301 value = value*0x100+0x100;
302 } else {
303 value = value*0x100+0x200;
304 }
305 } else {
306 value = 0x0000;
307 if ((product == MOSCHIP_DEVICE_ID_7715) &&
308 (index != 0x08)) {
309 dbg("serial->product== MOSCHIP_DEVICE_ID_7715");
310 //index = 0x01 ;
311 }
312 }
313
314 if (request == MOS_WRITE) {
315 request = (__u8)MOS_WRITE;
316 requesttype = (__u8)0x40;
317 value = value + (__u16)*((unsigned char *)data);
318 data = NULL;
319 pipe = usb_sndctrlpipe(serial->dev, 0);
320 } else {
321 request = (__u8)MOS_READ;
322 requesttype = (__u8)0xC0;
323 size = 0x01;
324 pipe = usb_rcvctrlpipe(serial->dev,0);
325 }
326
327 status = usb_control_msg(serial->dev, pipe, request, requesttype,
328 value, index, data, size, MOS_WDR_TIMEOUT);
329
330 if (status < 0)
331 dbg("Command Write failed Value %x index %x\n",value,index);
332
333 return status;
334}
335
336static int mos7720_open(struct usb_serial_port *port, struct file * filp)
337{
338 struct usb_serial *serial;
339 struct usb_serial_port *port0;
340 struct urb *urb;
341 struct moschip_serial *mos7720_serial;
342 struct moschip_port *mos7720_port;
343 int response;
344 int port_number;
345 char data;
346 int j;
347
348 serial = port->serial;
349
350 mos7720_port = usb_get_serial_port_data(port);
351 if (mos7720_port == NULL)
352 return -ENODEV;
353
354 port0 = serial->port[0];
355
356 mos7720_serial = usb_get_serial_data(serial);
357
358 if (mos7720_serial == NULL || port0 == NULL)
359 return -ENODEV;
360
361 usb_clear_halt(serial->dev, port->write_urb->pipe);
362 usb_clear_halt(serial->dev, port->read_urb->pipe);
363
364 /* Initialising the write urb pool */
365 for (j = 0; j < NUM_URBS; ++j) {
366 urb = usb_alloc_urb(0,SLAB_ATOMIC);
367 mos7720_port->write_urb_pool[j] = urb;
368
369 if (urb == NULL) {
370 err("No more urbs???");
371 continue;
372 }
373
374 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
375 GFP_KERNEL);
376 if (!urb->transfer_buffer) {
377 err("%s-out of memory for urb buffers.", __FUNCTION__);
378 continue;
379 }
380 }
381
382 /* Initialize MCS7720 -- Write Init values to corresponding Registers
383 *
384 * Register Index
385 * 1 : IER
386 * 2 : FCR
387 * 3 : LCR
388 * 4 : MCR
389 *
390 * 0x08 : SP1/2 Control Reg
391 */
392 port_number = port->number - port->serial->minor;
393 send_mos_cmd(port->serial, MOS_READ, port_number, UART_LSR, &data);
394 dbg("SS::%p LSR:%x\n",mos7720_port, data);
395
396 dbg("Check:Sending Command ..........");
397
398 data = 0x02;
399 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x01, &data);
400 data = 0x02;
401 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x02, &data);
402
403 data = 0x00;
404 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
405 data = 0x00;
406 send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data);
407
408 data = 0xCF;
409 send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data);
410 data = 0x03;
411 mos7720_port->shadowLCR = data;
412 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
413 data = 0x0b;
414 mos7720_port->shadowMCR = data;
415 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
416 data = 0x0b;
417 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
418
419 data = 0x00;
420 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
421 data = 0x00;
422 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
423
424/* data = 0x00;
425 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, port_number + 1, &data);
426 data = 0x03;
427 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);
428 data = 0x00;
429 send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);
430*/
431 data = 0x00;
432 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
433
434 data = data | (port->number - port->serial->minor + 1);
435 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
436
437 data = 0x83;
438 mos7720_port->shadowLCR = data;
439 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
440 data = 0x0c;
441 send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data);
442 data = 0x00;
443 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
444 data = 0x03;
445 mos7720_port->shadowLCR = data;
446 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
447 data = 0x0c;
448 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
449 data = 0x0c;
450 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
451
452//Matrix
453
454 /* force low_latency on so that our tty_push actually forces *
455 * the data through,otherwise it is scheduled, and with *
456 * high data rates (like with OHCI) data can get lost. */
457
458 if (port->tty)
459 port->tty->low_latency = 1;
460
461 /* see if we've set up our endpoint info yet *
462 * (can't set it up in mos7720_startup as the *
463 * structures were not set up at that time.) */
464 if (!mos7720_serial->interrupt_started) {
465 dbg("Interrupt buffer NULL !!!");
466
467 /* not set up yet, so do it now */
468 mos7720_serial->interrupt_started = 1;
469
470 dbg("To Submit URB !!!");
471
472 /* set up our interrupt urb */
473 usb_fill_int_urb(port0->interrupt_in_urb, serial->dev,
474 usb_rcvintpipe(serial->dev,
475 port->interrupt_in_endpointAddress),
476 port0->interrupt_in_buffer,
477 port0->interrupt_in_urb->transfer_buffer_length,
478 mos7720_interrupt_callback, mos7720_port,
479 port0->interrupt_in_urb->interval);
480
481 /* start interrupt read for this mos7720 this interrupt *
482 * will continue as long as the mos7720 is connected */
483 dbg("Submit URB over !!!");
484 response = usb_submit_urb(port0->interrupt_in_urb, GFP_KERNEL);
485 if (response)
486 dev_err(&port->dev,
487 "%s - Error %d submitting control urb",
488 __FUNCTION__, response);
489 }
490
491 /* set up our bulk in urb */
492 usb_fill_bulk_urb(port->read_urb, serial->dev,
493 usb_rcvbulkpipe(serial->dev,
494 port->bulk_in_endpointAddress),
495 port->bulk_in_buffer,
496 port->read_urb->transfer_buffer_length,
497 mos7720_bulk_in_callback, mos7720_port);
498 response = usb_submit_urb(port->read_urb, GFP_KERNEL);
499 if (response)
500 dev_err(&port->dev,
501 "%s - Error %d submitting read urb", __FUNCTION__, response);
502
503 /* initialize our icount structure */
504 memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount));
505
506 /* initialize our port settings */
507 mos7720_port->shadowMCR = UART_MCR_OUT2; /* Must set to enable ints! */
508
509 /* send a open port command */
510 mos7720_port->open = 1;
511
512 return 0;
513}
514
515/*
516 * mos7720_chars_in_buffer
517 * this function is called by the tty driver when it wants to know how many
518 * bytes of data we currently have outstanding in the port (data that has
519 * been written, but hasn't made it out the port yet)
520 * If successful, we return the number of bytes left to be written in the
521 * system,
522 * Otherwise we return a negative error number.
523 */
524static int mos7720_chars_in_buffer(struct usb_serial_port *port)
525{
526 int i;
527 int chars = 0;
528 struct moschip_port *mos7720_port;
529
530 dbg("%s:entering ...........", __FUNCTION__);
531
532 mos7720_port = usb_get_serial_port_data(port);
533 if (mos7720_port == NULL) {
534 dbg("%s:leaving ...........", __FUNCTION__);
535 return -ENODEV;
536 }
537
538 for (i = 0; i < NUM_URBS; ++i) {
539 if (mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
540 chars += URB_TRANSFER_BUFFER_SIZE;
541 }
542 dbg("%s - returns %d", __FUNCTION__, chars);
543 return chars;
544}
545
546static void mos7720_close(struct usb_serial_port *port, struct file *filp)
547{
548 struct usb_serial *serial;
549 struct moschip_port *mos7720_port;
550 char data;
551 int j;
552
553 dbg("mos7720_close:entering...");
554
555 serial = port->serial;
556
557 mos7720_port = usb_get_serial_port_data(port);
558 if (mos7720_port == NULL)
559 return;
560
561 for (j = 0; j < NUM_URBS; ++j)
562 usb_kill_urb(mos7720_port->write_urb_pool[j]);
563
564 /* Freeing Write URBs */
565 for (j = 0; j < NUM_URBS; ++j) {
566 if (mos7720_port->write_urb_pool[j]) {
567 kfree(mos7720_port->write_urb_pool[j]->transfer_buffer);
568 usb_free_urb(mos7720_port->write_urb_pool[j]);
569 }
570 }
571
572 /* While closing port, shutdown all bulk read, write *
573 * and interrupt read if they exists */
574 if (serial->dev) {
575 dbg("Shutdown bulk write");
576 usb_kill_urb(port->write_urb);
577 dbg("Shutdown bulk read");
578 usb_kill_urb(port->read_urb);
579 }
580
581 data = 0x00;
582 send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
583 0x04, &data);
584
585 data = 0x00;
586 send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
587 0x01, &data);
588
589 mos7720_port->open = 0;
590
591 dbg("Leaving %s", __FUNCTION__);
592}
593
594static void mos7720_break(struct usb_serial_port *port, int break_state)
595{
596 unsigned char data;
597 struct usb_serial *serial;
598 struct moschip_port *mos7720_port;
599
600 dbg("Entering %s", __FUNCTION__);
601
602 serial = port->serial;
603
604 mos7720_port = usb_get_serial_port_data(port);
605 if (mos7720_port == NULL)
606 return;
607
608 if (break_state == -1)
609 data = mos7720_port->shadowLCR | UART_LCR_SBC;
610 else
611 data = mos7720_port->shadowLCR & ~UART_LCR_SBC;
612
613 mos7720_port->shadowLCR = data;
614 send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
615 0x03, &data);
616
617 return;
618}
619
620/*
621 * mos7720_write_room
622 * this function is called by the tty driver when it wants to know how many
623 * bytes of data we can accept for a specific port.
624 * If successful, we return the amount of room that we have for this port
625 * Otherwise we return a negative error number.
626 */
627static int mos7720_write_room(struct usb_serial_port *port)
628{
629 struct moschip_port *mos7720_port;
630 int room = 0;
631 int i;
632
633 dbg("%s:entering ...........", __FUNCTION__);
634
635 mos7720_port = usb_get_serial_port_data(port);
636 if (mos7720_port == NULL) {
637 dbg("%s:leaving ...........", __FUNCTION__);
638 return -ENODEV;
639 }
640
641 for (i = 0; i < NUM_URBS; ++i) {
642 if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
643 room += URB_TRANSFER_BUFFER_SIZE;
644 }
645
646 dbg("%s - returns %d", __FUNCTION__, room);
647 return room;
648}
649
650static int mos7720_write(struct usb_serial_port *port,
651 const unsigned char *data, int count)
652{
653 int status;
654 int i;
655 int bytes_sent = 0;
656 int transfer_size;
657
658 struct moschip_port *mos7720_port;
659 struct usb_serial *serial;
660 struct urb *urb;
661 const unsigned char *current_position = data;
662
663 dbg("%s:entering ...........", __FUNCTION__);
664
665 serial = port->serial;
666
667 mos7720_port = usb_get_serial_port_data(port);
668 if (mos7720_port == NULL) {
669 dbg("mos7720_port is NULL");
670 return -ENODEV;
671 }
672
673 /* try to find a free urb in the list */
674 urb = NULL;
675
676 for (i = 0; i < NUM_URBS; ++i) {
677 if (mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
678 urb = mos7720_port->write_urb_pool[i];
679 dbg("URB:%d",i);
680 break;
681 }
682 }
683
684 if (urb == NULL) {
685 dbg("%s - no more free urbs", __FUNCTION__);
686 goto exit;
687 }
688
689 if (urb->transfer_buffer == NULL) {
690 urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
691 GFP_KERNEL);
692 if (urb->transfer_buffer == NULL) {
693 err("%s no more kernel memory...", __FUNCTION__);
694 goto exit;
695 }
696 }
697 transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE);
698
699 memcpy(urb->transfer_buffer, current_position, transfer_size);
700 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size,
701 urb->transfer_buffer);
702
703 /* fill urb with data and submit */
704 usb_fill_bulk_urb(urb, serial->dev,
705 usb_sndbulkpipe(serial->dev,
706 port->bulk_out_endpointAddress),
707 urb->transfer_buffer, transfer_size,
708 mos7720_bulk_out_data_callback, mos7720_port);
709
710 /* send it down the pipe */
711 status = usb_submit_urb(urb,GFP_ATOMIC);
712 if (status) {
713 err("%s - usb_submit_urb(write bulk) failed with status = %d",
714 __FUNCTION__, status);
715 bytes_sent = status;
716 goto exit;
717 }
718 bytes_sent = transfer_size;
719
720exit:
721 return bytes_sent;
722}
723
724static void mos7720_throttle(struct usb_serial_port *port)
725{
726 struct moschip_port *mos7720_port;
727 struct tty_struct *tty;
728 int status;
729
730 dbg("%s- port %d\n", __FUNCTION__, port->number);
731
732 mos7720_port = usb_get_serial_port_data(port);
733
734 if (mos7720_port == NULL)
735 return;
736
737 if (!mos7720_port->open) {
738 dbg("port not opened");
739 return;
740 }
741
742 dbg("%s: Entering ..........", __FUNCTION__);
743
744 tty = port->tty;
745 if (!tty) {
746 dbg("%s - no tty available", __FUNCTION__);
747 return;
748 }
749
750 /* if we are implementing XON/XOFF, send the stop character */
751 if (I_IXOFF(tty)) {
752 unsigned char stop_char = STOP_CHAR(tty);
753 status = mos7720_write(port, &stop_char, 1);
754 if (status <= 0)
755 return;
756 }
757
758 /* if we are implementing RTS/CTS, toggle that line */
759 if (tty->termios->c_cflag & CRTSCTS) {
760 mos7720_port->shadowMCR &= ~UART_MCR_RTS;
761 status = send_mos_cmd(port->serial, MOS_WRITE,
762 port->number - port->serial->minor,
763 UART_MCR, &mos7720_port->shadowMCR);
764 if (status != 0)
765 return;
766 }
767}
768
769static void mos7720_unthrottle(struct usb_serial_port *port)
770{
771 struct tty_struct *tty;
772 int status;
773 struct moschip_port *mos7720_port = usb_get_serial_port_data(port);
774
775 if (mos7720_port == NULL)
776 return;
777
778 if (!mos7720_port->open) {
779 dbg("%s - port not opened", __FUNCTION__);
780 return;
781 }
782
783 dbg("%s: Entering ..........", __FUNCTION__);
784
785 tty = port->tty;
786 if (!tty) {
787 dbg("%s - no tty available", __FUNCTION__);
788 return;
789 }
790
791 /* if we are implementing XON/XOFF, send the start character */
792 if (I_IXOFF(tty)) {
793 unsigned char start_char = START_CHAR(tty);
794 status = mos7720_write(port, &start_char, 1);
795 if (status <= 0)
796 return;
797 }
798
799 /* if we are implementing RTS/CTS, toggle that line */
800 if (tty->termios->c_cflag & CRTSCTS) {
801 mos7720_port->shadowMCR |= UART_MCR_RTS;
802 status = send_mos_cmd(port->serial, MOS_WRITE,
803 port->number - port->serial->minor,
804 UART_MCR, &mos7720_port->shadowMCR);
805 if (status != 0)
806 return;
807 }
808}
809
810static int set_higher_rates(struct moschip_port *mos7720_port,
811 unsigned int baud)
812{
813 unsigned char data;
814 struct usb_serial_port *port;
815 struct usb_serial *serial;
816 int port_number;
817
818 if (mos7720_port == NULL)
819 return -EINVAL;
820
821 port = mos7720_port->port;
822 serial = port->serial;
823
824 /***********************************************
825 * Init Sequence for higher rates
826 ***********************************************/
827 dbg("Sending Setting Commands ..........");
828 port_number = port->number - port->serial->minor;
829
830 data = 0x000;
831 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
832 data = 0x000;
833 send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data);
834 data = 0x0CF;
835 send_mos_cmd(serial, MOS_WRITE, port->number, 0x02, &data);
836 data = 0x00b;
837 mos7720_port->shadowMCR = data;
838 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
839 data = 0x00b;
840 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
841
842 data = 0x000;
843 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
844 data = 0x000;
845 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
846
847
848 /***********************************************
849 * Set for higher rates *
850 ***********************************************/
851
852 data = baud * 0x10;
853 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1,&data);
854
855 data = 0x003;
856 send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
857 data = 0x003;
858 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
859
860 data = 0x02b;
861 mos7720_port->shadowMCR = data;
862 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
863 data = 0x02b;
864 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
865
866 /***********************************************
867 * Set DLL/DLM
868 ***********************************************/
869
870 data = mos7720_port->shadowLCR | UART_LCR_DLAB;
871 mos7720_port->shadowLCR = data;
872 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
873
874 data = 0x001; /* DLL */
875 send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data);
876 data = 0x000; /* DLM */
877 send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
878
879 data = mos7720_port->shadowLCR & ~UART_LCR_DLAB;
880 mos7720_port->shadowLCR = data;
881 send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
882
883 return 0;
884}
885
886/* baud rate information */
887struct divisor_table_entry
888{
889 __u32 baudrate;
890 __u16 divisor;
891};
892
893/* Define table of divisors for moschip 7720 hardware *
894 * These assume a 3.6864MHz crystal, the standard /16, and *
895 * MCR.7 = 0. */
896static struct divisor_table_entry divisor_table[] = {
897 { 50, 2304},
898 { 110, 1047}, /* 2094.545455 => 230450 => .0217 % over */
899 { 134, 857}, /* 1713.011152 => 230398.5 => .00065% under */
900 { 150, 768},
901 { 300, 384},
902 { 600, 192},
903 { 1200, 96},
904 { 1800, 64},
905 { 2400, 48},
906 { 4800, 24},
907 { 7200, 16},
908 { 9600, 12},
909 { 19200, 6},
910 { 38400, 3},
911 { 57600, 2},
912 { 115200, 1},
913};
914
915/*****************************************************************************
916 * calc_baud_rate_divisor
917 * this function calculates the proper baud rate divisor for the specified
918 * baud rate.
919 *****************************************************************************/
920static int calc_baud_rate_divisor(int baudrate, int *divisor)
921{
922 int i;
923 __u16 custom;
924 __u16 round1;
925 __u16 round;
926
927
928 dbg("%s - %d", __FUNCTION__, baudrate);
929
930 for (i = 0; i < ARRAY_SIZE(divisor_table); i++) {
931 if (divisor_table[i].baudrate == baudrate) {
932 *divisor = divisor_table[i].divisor;
933 return 0;
934 }
935 }
936
937 /* After trying for all the standard baud rates *
938 * Try calculating the divisor for this baud rate */
939 if (baudrate > 75 && baudrate < 230400) {
940 /* get the divisor */
941 custom = (__u16)(230400L / baudrate);
942
943 /* Check for round off */
944 round1 = (__u16)(2304000L / baudrate);
945 round = (__u16)(round1 - (custom * 10));
946 if (round > 4)
947 custom++;
948 *divisor = custom;
949
950 dbg("Baud %d = %d",baudrate, custom);
951 return 0;
952 }
953
954 dbg("Baud calculation Failed...");
955 return -EINVAL;
956}
957
958/*
959 * send_cmd_write_baud_rate
960 * this function sends the proper command to change the baud rate of the
961 * specified port.
962 */
963static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port,
964 int baudrate)
965{
966 struct usb_serial_port *port;
967 struct usb_serial *serial;
968 int divisor;
969 int status;
970 unsigned char data;
971 unsigned char number;
972
973 if (mos7720_port == NULL)
974 return -1;
975
976 port = mos7720_port->port;
977 serial = port->serial;
978
979 dbg("%s: Entering ..........", __FUNCTION__);
980
981 number = port->number - port->serial->minor;
982 dbg("%s - port = %d, baud = %d", __FUNCTION__, port->number, baudrate);
983
984 /* Calculate the Divisor */
985 status = calc_baud_rate_divisor(baudrate, &divisor);
986 if (status) {
987 err("%s - bad baud rate", __FUNCTION__);
988 return status;
989 }
990
991 /* Enable access to divisor latch */
992 data = mos7720_port->shadowLCR | UART_LCR_DLAB;
993 mos7720_port->shadowLCR = data;
994 send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data);
995
996 /* Write the divisor */
997 data = ((unsigned char)(divisor & 0xff));
998 send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data);
999
1000 data = ((unsigned char)((divisor & 0xff00) >> 8));
1001 send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data);
1002
1003 /* Disable access to divisor latch */
1004 data = mos7720_port->shadowLCR & ~UART_LCR_DLAB;
1005 mos7720_port->shadowLCR = data;
1006 send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data);
1007
1008 return status;
1009}
1010
1011/*
1012 * change_port_settings
1013 * This routine is called to set the UART on the device to match
1014 * the specified new settings.
1015 */
1016static void change_port_settings(struct moschip_port *mos7720_port,
1017 struct termios *old_termios)
1018{
1019 struct usb_serial_port *port;
1020 struct usb_serial *serial;
1021 struct tty_struct *tty;
1022 int baud;
1023 unsigned cflag;
1024 unsigned iflag;
1025 __u8 mask = 0xff;
1026 __u8 lData;
1027 __u8 lParity;
1028 __u8 lStop;
1029 int status;
1030 int port_number;
1031 char data;
1032
1033 if (mos7720_port == NULL)
1034 return ;
1035
1036 port = mos7720_port->port;
1037 serial = port->serial;
1038 port_number = port->number - port->serial->minor;
1039
1040 dbg("%s - port %d", __FUNCTION__, port->number);
1041
1042 if (!mos7720_port->open) {
1043 dbg("%s - port not opened", __FUNCTION__);
1044 return;
1045 }
1046
1047 tty = mos7720_port->port->tty;
1048
1049 if ((!tty) || (!tty->termios)) {
1050 dbg("%s - no tty structures", __FUNCTION__);
1051 return;
1052 }
1053
1054 dbg("%s: Entering ..........", __FUNCTION__);
1055
1056 lData = UART_LCR_WLEN8;
1057 lStop = 0x00; /* 1 stop bit */
1058 lParity = 0x00; /* No parity */
1059
1060 cflag = tty->termios->c_cflag;
1061 iflag = tty->termios->c_iflag;
1062
1063 /* Change the number of bits */
1064 switch (cflag & CSIZE) {
1065 case CS5:
1066 lData = UART_LCR_WLEN5;
1067 mask = 0x1f;
1068 break;
1069
1070 case CS6:
1071 lData = UART_LCR_WLEN6;
1072 mask = 0x3f;
1073 break;
1074
1075 case CS7:
1076 lData = UART_LCR_WLEN7;
1077 mask = 0x7f;
1078 break;
1079 default:
1080 case CS8:
1081 lData = UART_LCR_WLEN8;
1082 break;
1083 }
1084
1085 /* Change the Parity bit */
1086 if (cflag & PARENB) {
1087 if (cflag & PARODD) {
1088 lParity = UART_LCR_PARITY;
1089 dbg("%s - parity = odd", __FUNCTION__);
1090 } else {
1091 lParity = (UART_LCR_EPAR | UART_LCR_PARITY);
1092 dbg("%s - parity = even", __FUNCTION__);
1093 }
1094
1095 } else {
1096 dbg("%s - parity = none", __FUNCTION__);
1097 }
1098
1099 if (cflag & CMSPAR)
1100 lParity = lParity | 0x20;
1101
1102 /* Change the Stop bit */
1103 if (cflag & CSTOPB) {
1104 lStop = UART_LCR_STOP;
1105 dbg("%s - stop bits = 2", __FUNCTION__);
1106 } else {
1107 lStop = 0x00;
1108 dbg("%s - stop bits = 1", __FUNCTION__);
1109 }
1110
1111#define LCR_BITS_MASK 0x03 /* Mask for bits/char field */
1112#define LCR_STOP_MASK 0x04 /* Mask for stop bits field */
1113#define LCR_PAR_MASK 0x38 /* Mask for parity field */
1114
1115 /* Update the LCR with the correct value */
1116 mos7720_port->shadowLCR &= ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK);
1117 mos7720_port->shadowLCR |= (lData | lParity | lStop);
1118
1119
1120 /* Disable Interrupts */
1121 data = 0x00;
1122 send_mos_cmd(serial,MOS_WRITE,port->number - port->serial->minor, UART_IER, &data);
1123
1124 data = 0x00;
1125 send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
1126
1127 data = 0xcf;
1128 send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
1129
1130 /* Send the updated LCR value to the mos7720 */
1131 data = mos7720_port->shadowLCR;
1132 send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data);
1133
1134 data = 0x00b;
1135 mos7720_port->shadowMCR = data;
1136 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
1137 data = 0x00b;
1138 send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
1139
1140 /* set up the MCR register and send it to the mos7720 */
1141 mos7720_port->shadowMCR = UART_MCR_OUT2;
1142 if (cflag & CBAUD)
1143 mos7720_port->shadowMCR |= (UART_MCR_DTR | UART_MCR_RTS);
1144
1145 if (cflag & CRTSCTS) {
1146 mos7720_port->shadowMCR |= (UART_MCR_XONANY);
1147
1148 /* To set hardware flow control to the specified *
1149 * serial port, in SP1/2_CONTROL_REG */
1150 if (port->number) {
1151 data = 0x001;
1152 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT,
1153 0x08, &data);
1154 } else {
1155 data = 0x002;
1156 send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT,
1157 0x08, &data);
1158 }
1159 } else {
1160 mos7720_port->shadowMCR &= ~(UART_MCR_XONANY);
1161 }
1162
1163 data = mos7720_port->shadowMCR;
1164 send_mos_cmd(serial, MOS_WRITE, port_number, UART_MCR, &data);
1165
1166 /* Determine divisor based on baud rate */
1167 baud = tty_get_baud_rate(tty);
1168 if (!baud) {
1169 /* pick a default, any default... */
1170 dbg("Picked default baud...");
1171 baud = 9600;
1172 }
1173
1174 if (baud >= 230400) {
1175 set_higher_rates(mos7720_port, baud);
1176 /* Enable Interrupts */
1177 data = 0x0c;
1178 send_mos_cmd(serial, MOS_WRITE, port_number, UART_IER, &data);
1179 return;
1180 }
1181
1182 dbg("%s - baud rate = %d", __FUNCTION__, baud);
1183 status = send_cmd_write_baud_rate(mos7720_port, baud);
1184
1185 /* Enable Interrupts */
1186 data = 0x0c;
1187 send_mos_cmd(serial, MOS_WRITE, port_number, UART_IER, &data);
1188
1189 if (port->read_urb->status != -EINPROGRESS) {
1190 port->read_urb->dev = serial->dev;
1191
1192 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1193 if (status)
1194 dbg("usb_submit_urb(read bulk) failed, status = %d",
1195 status);
1196 }
1197 return;
1198}
1199
1200/*
1201 * mos7720_set_termios
1202 * this function is called by the tty driver when it wants to change the
1203 * termios structure.
1204 */
1205static void mos7720_set_termios(struct usb_serial_port *port,
1206 struct termios *old_termios)
1207{
1208 int status;
1209 unsigned int cflag;
1210 struct usb_serial *serial;
1211 struct moschip_port *mos7720_port;
1212 struct tty_struct *tty;
1213
1214 serial = port->serial;
1215
1216 mos7720_port = usb_get_serial_port_data(port);
1217
1218 if (mos7720_port == NULL)
1219 return;
1220
1221 tty = port->tty;
1222
1223 if (!port->tty || !port->tty->termios) {
1224 dbg("%s - no tty or termios", __FUNCTION__);
1225 return;
1226 }
1227
1228 if (!mos7720_port->open) {
1229 dbg("%s - port not opened", __FUNCTION__);
1230 return;
1231 }
1232
1233 dbg("%s\n","setting termios - ASPIRE");
1234
1235 cflag = tty->termios->c_cflag;
1236
1237 if (!cflag) {
1238 printk("%s %s\n",__FUNCTION__,"cflag is NULL");
1239 return;
1240 }
1241
1242 /* check that they really want us to change something */
1243 if (old_termios) {
1244 if ((cflag == old_termios->c_cflag) &&
1245 (RELEVANT_IFLAG(tty->termios->c_iflag) ==
1246 RELEVANT_IFLAG(old_termios->c_iflag))) {
1247 dbg("Nothing to change");
1248 return;
1249 }
1250 }
1251
1252 dbg("%s - clfag %08x iflag %08x", __FUNCTION__,
1253 tty->termios->c_cflag,
1254 RELEVANT_IFLAG(tty->termios->c_iflag));
1255
1256 if (old_termios)
1257 dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__,
1258 old_termios->c_cflag,
1259 RELEVANT_IFLAG(old_termios->c_iflag));
1260
1261 dbg("%s - port %d", __FUNCTION__, port->number);
1262
1263 /* change the port settings to the new ones specified */
1264 change_port_settings(mos7720_port, old_termios);
1265
1266 if(!port->read_urb) {
1267 dbg("%s","URB KILLED !!!!!\n");
1268 return;
1269 }
1270
1271 if(port->read_urb->status != -EINPROGRESS) {
1272 port->read_urb->dev = serial->dev;
1273 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1274 if (status)
1275 dbg("usb_submit_urb(read bulk) failed, status = %d",
1276 status);
1277 }
1278 return;
1279}
1280
1281/*
1282 * get_lsr_info - get line status register info
1283 *
1284 * Purpose: Let user call ioctl() to get info when the UART physically
1285 * is emptied. On bus types like RS485, the transmitter must
1286 * release the bus after transmitting. This must be done when
1287 * the transmit shift register is empty, not be done when the
1288 * transmit holding register is empty. This functionality
1289 * allows an RS485 driver to be written in user space.
1290 */
1291static int get_lsr_info(struct moschip_port *mos7720_port,
1292 unsigned int __user *value)
1293{
1294 int count;
1295 unsigned int result = 0;
1296
1297 count = mos7720_chars_in_buffer(mos7720_port->port);
1298 if (count == 0) {
1299 dbg("%s -- Empty", __FUNCTION__);
1300 result = TIOCSER_TEMT;
1301 }
1302
1303 if (copy_to_user(value, &result, sizeof(int)))
1304 return -EFAULT;
1305 return 0;
1306}
1307
1308/*
1309 * get_number_bytes_avail - get number of bytes available
1310 *
1311 * Purpose: Let user call ioctl to get the count of number of bytes available.
1312 */
1313static int get_number_bytes_avail(struct moschip_port *mos7720_port,
1314 unsigned int __user *value)
1315{
1316 unsigned int result = 0;
1317 struct tty_struct *tty = mos7720_port->port->tty;
1318
1319 if (!tty)
1320 return -ENOIOCTLCMD;
1321
1322 result = tty->read_cnt;
1323
1324 dbg("%s(%d) = %d", __FUNCTION__, mos7720_port->port->number, result);
1325 if (copy_to_user(value, &result, sizeof(int)))
1326 return -EFAULT;
1327
1328 return -ENOIOCTLCMD;
1329}
1330
1331static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd,
1332 unsigned int __user *value)
1333{
1334 unsigned int mcr ;
1335 unsigned int arg;
1336 unsigned char data;
1337
1338 struct usb_serial_port *port;
1339
1340 if (mos7720_port == NULL)
1341 return -1;
1342
1343 port = (struct usb_serial_port*)mos7720_port->port;
1344 mcr = mos7720_port->shadowMCR;
1345
1346 if (copy_from_user(&arg, value, sizeof(int)))
1347 return -EFAULT;
1348
1349 switch (cmd) {
1350 case TIOCMBIS:
1351 if (arg & TIOCM_RTS)
1352 mcr |= UART_MCR_RTS;
1353 if (arg & TIOCM_DTR)
1354 mcr |= UART_MCR_RTS;
1355 if (arg & TIOCM_LOOP)
1356 mcr |= UART_MCR_LOOP;
1357 break;
1358
1359 case TIOCMBIC:
1360 if (arg & TIOCM_RTS)
1361 mcr &= ~UART_MCR_RTS;
1362 if (arg & TIOCM_DTR)
1363 mcr &= ~UART_MCR_RTS;
1364 if (arg & TIOCM_LOOP)
1365 mcr &= ~UART_MCR_LOOP;
1366 break;
1367
1368 case TIOCMSET:
1369 /* turn off the RTS and DTR and LOOPBACK
1370 * and then only turn on what was asked to */
1371 mcr &= ~(UART_MCR_RTS | UART_MCR_DTR | UART_MCR_LOOP);
1372 mcr |= ((arg & TIOCM_RTS) ? UART_MCR_RTS : 0);
1373 mcr |= ((arg & TIOCM_DTR) ? UART_MCR_DTR : 0);
1374 mcr |= ((arg & TIOCM_LOOP) ? UART_MCR_LOOP : 0);
1375 break;
1376 }
1377
1378 mos7720_port->shadowMCR = mcr;
1379
1380 data = mos7720_port->shadowMCR;
1381 send_mos_cmd(port->serial, MOS_WRITE,
1382 port->number - port->serial->minor, UART_MCR, &data);
1383
1384 return 0;
1385}
1386
1387static int get_modem_info(struct moschip_port *mos7720_port,
1388 unsigned int __user *value)
1389{
1390 unsigned int result = 0;
1391 unsigned int msr = mos7720_port->shadowMSR;
1392 unsigned int mcr = mos7720_port->shadowMCR;
1393
1394 result = ((mcr & UART_MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */
1395 | ((mcr & UART_MCR_RTS) ? TIOCM_RTS: 0) /* 0x004 */
1396 | ((msr & UART_MSR_CTS) ? TIOCM_CTS: 0) /* 0x020 */
1397 | ((msr & UART_MSR_DCD) ? TIOCM_CAR: 0) /* 0x040 */
1398 | ((msr & UART_MSR_RI) ? TIOCM_RI: 0) /* 0x080 */
1399 | ((msr & UART_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */
1400
1401
1402 dbg("%s -- %x", __FUNCTION__, result);
1403
1404 if (copy_to_user(value, &result, sizeof(int)))
1405 return -EFAULT;
1406 return 0;
1407}
1408
1409static int get_serial_info(struct moschip_port *mos7720_port,
1410 struct serial_struct __user *retinfo)
1411{
1412 struct serial_struct tmp;
1413
1414 if (!retinfo)
1415 return -EFAULT;
1416
1417 memset(&tmp, 0, sizeof(tmp));
1418
1419 tmp.type = PORT_16550A;
1420 tmp.line = mos7720_port->port->serial->minor;
1421 tmp.port = mos7720_port->port->number;
1422 tmp.irq = 0;
1423 tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
1424 tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
1425 tmp.baud_base = 9600;
1426 tmp.close_delay = 5*HZ;
1427 tmp.closing_wait = 30*HZ;
1428
1429 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
1430 return -EFAULT;
1431 return 0;
1432}
1433
1434static int mos7720_ioctl(struct usb_serial_port *port, struct file *file,
1435 unsigned int cmd, unsigned long arg)
1436{
1437 struct moschip_port *mos7720_port;
1438 struct async_icount cnow;
1439 struct async_icount cprev;
1440 struct serial_icounter_struct icount;
1441
1442 mos7720_port = usb_get_serial_port_data(port);
1443 if (mos7720_port == NULL)
1444 return -ENODEV;
1445
1446 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd);
1447
1448 switch (cmd) {
1449 case TIOCINQ:
1450 /* return number of bytes available */
1451 dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number);
1452 return get_number_bytes_avail(mos7720_port,
1453 (unsigned int __user *)arg);
1454 break;
1455
1456 case TIOCSERGETLSR:
1457 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number);
1458 return get_lsr_info(mos7720_port, (unsigned int __user *)arg);
1459 return 0;
1460
1461 case TIOCMBIS:
1462 case TIOCMBIC:
1463 case TIOCMSET:
1464 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__,
1465 port->number);
1466 return set_modem_info(mos7720_port, cmd,
1467 (unsigned int __user *)arg);
1468
1469 case TIOCMGET:
1470 dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
1471 return get_modem_info(mos7720_port,
1472 (unsigned int __user *)arg);
1473
1474 case TIOCGSERIAL:
1475 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number);
1476 return get_serial_info(mos7720_port,
1477 (struct serial_struct __user *)arg);
1478
1479 case TIOCSSERIAL:
1480 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number);
1481 break;
1482
1483 case TIOCMIWAIT:
1484 dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number);
1485 cprev = mos7720_port->icount;
1486 while (1) {
1487 if (signal_pending(current))
1488 return -ERESTARTSYS;
1489 cnow = mos7720_port->icount;
1490 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
1491 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
1492 return -EIO; /* no change => error */
1493 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
1494 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
1495 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
1496 ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
1497 return 0;
1498 }
1499 cprev = cnow;
1500 }
1501 /* NOTREACHED */
1502 break;
1503
1504 case TIOCGICOUNT:
1505 cnow = mos7720_port->icount;
1506 icount.cts = cnow.cts;
1507 icount.dsr = cnow.dsr;
1508 icount.rng = cnow.rng;
1509 icount.dcd = cnow.dcd;
1510 icount.rx = cnow.rx;
1511 icount.tx = cnow.tx;
1512 icount.frame = cnow.frame;
1513 icount.overrun = cnow.overrun;
1514 icount.parity = cnow.parity;
1515 icount.brk = cnow.brk;
1516 icount.buf_overrun = cnow.buf_overrun;
1517
1518 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__,
1519 port->number, icount.rx, icount.tx );
1520 if (copy_to_user((void __user *)arg, &icount, sizeof(icount)))
1521 return -EFAULT;
1522 return 0;
1523 }
1524
1525 return -ENOIOCTLCMD;
1526}
1527
1528static int mos7720_startup(struct usb_serial *serial)
1529{
1530 struct moschip_serial *mos7720_serial;
1531 struct moschip_port *mos7720_port;
1532 struct usb_device *dev;
1533 int i;
1534 char data;
1535
1536 dbg("%s: Entering ..........", __FUNCTION__);
1537
1538 if (!serial) {
1539 dbg("Invalid Handler");
1540 return -ENODEV;
1541 }
1542
1543 dev = serial->dev;
1544
1545 /* create our private serial structure */
1546 mos7720_serial = kzalloc(sizeof(struct moschip_serial), GFP_KERNEL);
1547 if (mos7720_serial == NULL) {
1548 err("%s - Out of memory", __FUNCTION__);
1549 return -ENOMEM;
1550 }
1551
1552 usb_set_serial_data(serial, mos7720_serial);
1553
1554 /* we set up the pointers to the endpoints in the mos7720_open *
1555 * function, as the structures aren't created yet. */
1556
1557 /* set up port private structures */
1558 for (i = 0; i < serial->num_ports; ++i) {
1559 mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
1560 if (mos7720_port == NULL) {
1561 err("%s - Out of memory", __FUNCTION__);
1562 usb_set_serial_data(serial, NULL);
1563 kfree(mos7720_serial);
1564 return -ENOMEM;
1565 }
1566
1567 /* Initialize all port interrupt end point to port 0 int
1568 * endpoint. Our device has only one interrupt endpoint
1569 * comman to all ports */
1570 serial->port[i]->interrupt_in_endpointAddress = serial->port[0]->interrupt_in_endpointAddress;
1571
1572 mos7720_port->port = serial->port[i];
1573 usb_set_serial_port_data(serial->port[i], mos7720_port);
1574
1575 dbg("port number is %d", serial->port[i]->number);
1576 dbg("serial number is %d", serial->minor);
1577 }
1578
1579
1580 /* setting configuration feature to one */
1581 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
1582 (__u8)0x03, 0x00,0x01,0x00, NULL, 0x00, 5*HZ);
1583
1584 send_mos_cmd(serial,MOS_READ,0x00, UART_LSR, &data); // LSR For Port 1
1585 dbg("LSR:%x",data);
1586
1587 send_mos_cmd(serial,MOS_READ,0x01, UART_LSR, &data); // LSR For Port 2
1588 dbg("LSR:%x",data);
1589
1590 return 0;
1591}
1592
1593static void mos7720_shutdown(struct usb_serial *serial)
1594{
1595 int i;
1596
1597 /* free private structure allocated for serial port */
1598 for (i=0; i < serial->num_ports; ++i) {
1599 kfree(usb_get_serial_port_data(serial->port[i]));
1600 usb_set_serial_port_data(serial->port[i], NULL);
1601 }
1602
1603 /* free private structure allocated for serial device */
1604 kfree(usb_get_serial_data(serial));
1605 usb_set_serial_data(serial, NULL);
1606}
1607
1608static struct usb_serial_driver moschip7720_2port_driver = {
1609 .driver = {
1610 .owner = THIS_MODULE,
1611 .name = "moschip7720",
1612 },
1613 .description = "Moschip 2 port adapter",
1614 .id_table = moschip_port_id_table,
1615 .num_interrupt_in = 1,
1616 .num_bulk_in = 2,
1617 .num_bulk_out = 2,
1618 .num_ports = 2,
1619 .open = mos7720_open,
1620 .close = mos7720_close,
1621 .throttle = mos7720_throttle,
1622 .unthrottle = mos7720_unthrottle,
1623 .attach = mos7720_startup,
1624 .shutdown = mos7720_shutdown,
1625 .ioctl = mos7720_ioctl,
1626 .set_termios = mos7720_set_termios,
1627 .write = mos7720_write,
1628 .write_room = mos7720_write_room,
1629 .chars_in_buffer = mos7720_chars_in_buffer,
1630 .break_ctl = mos7720_break,
1631 .read_bulk_callback = mos7720_bulk_in_callback,
1632};
1633
1634static struct usb_driver usb_driver = {
1635 .name = "moschip7720",
1636 .probe = usb_serial_probe,
1637 .disconnect = usb_serial_disconnect,
1638 .id_table = moschip_port_id_table,
1639};
1640
1641static int __init moschip7720_init(void)
1642{
1643 int retval;
1644
1645 dbg("%s: Entering ..........", __FUNCTION__);
1646
1647 /* Register with the usb serial */
1648 retval = usb_serial_register(&moschip7720_2port_driver);
1649 if (retval)
1650 goto failed_port_device_register;
1651
1652 info(DRIVER_DESC " " DRIVER_VERSION);
1653
1654 /* Register with the usb */
1655 retval = usb_register(&usb_driver);
1656 if (retval)
1657 goto failed_usb_register;
1658
1659 return 0;
1660
1661failed_usb_register:
1662 usb_serial_deregister(&moschip7720_2port_driver);
1663
1664failed_port_device_register:
1665 return retval;
1666}
1667
1668static void __exit moschip7720_exit(void)
1669{
1670 usb_deregister(&usb_driver);
1671 usb_serial_deregister(&moschip7720_2port_driver);
1672}
1673
1674module_init(moschip7720_init);
1675module_exit(moschip7720_exit);
1676
1677/* Module information */
1678MODULE_AUTHOR( DRIVER_AUTHOR );
1679MODULE_DESCRIPTION( DRIVER_DESC );
1680MODULE_LICENSE("GPL");
1681
1682module_param(debug, bool, S_IRUGO | S_IWUSR);
1683MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 021be39fe16e..5b71962d0351 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -2413,11 +2413,12 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2413 } 2413 }
2414 2414
2415 mos7840_port = mos7840_get_port_private(port); 2415 mos7840_port = mos7840_get_port_private(port);
2416 tty = mos7840_port->port->tty;
2417 2416
2418 if (mos7840_port == NULL) 2417 if (mos7840_port == NULL)
2419 return -1; 2418 return -1;
2420 2419
2420 tty = mos7840_port->port->tty;
2421
2421 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd); 2422 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd);
2422 2423
2423 switch (cmd) { 2424 switch (cmd) {
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index d29638daa987..ea16572d19f8 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -1,21 +1,35 @@
1/* 1/*
2 * Sierra Wireless CDMA Wireless Serial USB driver 2 USB Driver for Sierra Wireless
3 * 3
4 * Current Copy modified by: Kevin Lloyd <linux@sierrawireless.com> 4 Copyright (C) 2006 Kevin Lloyd <linux@sierrawireless.com>
5 * Original Copyright (C) 2005-2006 Greg Kroah-Hartman <gregkh@suse.de> 5
6 * 6 IMPORTANT DISCLAIMER: This driver is not commercially supported by
7 * This program is free software; you can redistribute it and/or 7 Sierra Wireless. Use at your own risk.
8 * modify it under the terms of the GNU General Public License version 8
9 * 2 as published by the Free Software Foundation. 9 This driver is free software; you can redistribute it and/or modify
10 */ 10 it under the terms of Version 2 of the GNU General Public License as
11 published by the Free Software Foundation.
12
13 Portions based on the option driver by Matthias Urlichs <smurf@smurf.noris.de>
14 Whom based his on the Keyspan driver by Hugh Blemings <hugh@blemings.org>
15
16 History:
17*/
18
19#define DRIVER_VERSION "v.1.0.5"
20#define DRIVER_AUTHOR "Kevin Lloyd <linux@sierrawireless.com>"
21#define DRIVER_DESC "USB Driver for Sierra Wireless USB modems"
11 22
12#include <linux/kernel.h> 23#include <linux/kernel.h>
13#include <linux/init.h> 24#include <linux/jiffies.h>
25#include <linux/errno.h>
14#include <linux/tty.h> 26#include <linux/tty.h>
27#include <linux/tty_flip.h>
15#include <linux/module.h> 28#include <linux/module.h>
16#include <linux/usb.h> 29#include <linux/usb.h>
17#include <linux/usb/serial.h> 30#include <linux/usb/serial.h>
18 31
32
19static struct usb_device_id id_table [] = { 33static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ 34 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
21 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */ 35 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
@@ -23,53 +37,674 @@ static struct usb_device_id id_table [] = {
23 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */ 37 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
24 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */ 38 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
25 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */ 39 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
40 { USB_DEVICE(0x1199, 0x6804) }, /* Sierra Wireless MC8755 for Europe */
26 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */ 41 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
27 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */ 42 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
28 /* Following devices are supported in the airprime.c driver */ 43
29 /* { USB_DEVICE(0x1199, 0x0112) }, */ /* Sierra Wireless AirCard 580 */ 44 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
30 /* { USB_DEVICE(0x0F3D, 0x0112) }, */ /* AirPrime/Sierra PC 5220 */ 45 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
31 { } 46 { }
32}; 47};
33MODULE_DEVICE_TABLE(usb, id_table); 48MODULE_DEVICE_TABLE(usb, id_table);
34 49
50static struct usb_device_id id_table_1port [] = {
51 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
52 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
53 { }
54};
55
56static struct usb_device_id id_table_3port [] = {
57 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
58 { USB_DEVICE(0x1199, 0x0020) }, /* Sierra Wireless MC5725 */
59 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
60 { USB_DEVICE(0x1199, 0x0019) }, /* Sierra Wireless AirCard 595 */
61 { USB_DEVICE(0x1199, 0x6802) }, /* Sierra Wireless MC8755 */
62 { USB_DEVICE(0x1199, 0x6803) }, /* Sierra Wireless MC8765 */
63 { USB_DEVICE(0x1199, 0x6812) }, /* Sierra Wireless MC8775 */
64 { USB_DEVICE(0x1199, 0x6820) }, /* Sierra Wireless AirCard 875 */
65 { }
66};
67
35static struct usb_driver sierra_driver = { 68static struct usb_driver sierra_driver = {
36 .name = "sierra_wireless", 69 .name = "sierra",
37 .probe = usb_serial_probe, 70 .probe = usb_serial_probe,
38 .disconnect = usb_serial_disconnect, 71 .disconnect = usb_serial_disconnect,
39 .id_table = id_table, 72 .id_table = id_table,
73 .no_dynamic_id = 1,
74};
75
76
77static int debug;
78
79/* per port private data */
80#define N_IN_URB 4
81#define N_OUT_URB 1
82#define IN_BUFLEN 4096
83#define OUT_BUFLEN 128
84
85struct sierra_port_private {
86 /* Input endpoints and buffer for this port */
87 struct urb *in_urbs[N_IN_URB];
88 char in_buffer[N_IN_URB][IN_BUFLEN];
89 /* Output endpoints and buffer for this port */
90 struct urb *out_urbs[N_OUT_URB];
91 char out_buffer[N_OUT_URB][OUT_BUFLEN];
92
93 /* Settings for the port */
94 int rts_state; /* Handshaking pins (outputs) */
95 int dtr_state;
96 int cts_state; /* Handshaking pins (inputs) */
97 int dsr_state;
98 int dcd_state;
99 int ri_state;
100
101 unsigned long tx_start_time[N_OUT_URB];
102};
103
104static int sierra_send_setup(struct usb_serial_port *port)
105{
106 struct usb_serial *serial = port->serial;
107 struct sierra_port_private *portdata;
108
109 dbg("%s", __FUNCTION__);
110
111 portdata = usb_get_serial_port_data(port);
112
113 if (port->tty) {
114 int val = 0;
115 if (portdata->dtr_state)
116 val |= 0x01;
117 if (portdata->rts_state)
118 val |= 0x02;
119
120 return usb_control_msg(serial->dev,
121 usb_rcvctrlpipe(serial->dev, 0),
122 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT);
123 }
124
125 return 0;
126}
127
128static void sierra_rx_throttle(struct usb_serial_port *port)
129{
130 dbg("%s", __FUNCTION__);
131}
132
133static void sierra_rx_unthrottle(struct usb_serial_port *port)
134{
135 dbg("%s", __FUNCTION__);
136}
137
138static void sierra_break_ctl(struct usb_serial_port *port, int break_state)
139{
140 /* Unfortunately, I don't know how to send a break */
141 dbg("%s", __FUNCTION__);
142}
143
144static void sierra_set_termios(struct usb_serial_port *port,
145 struct termios *old_termios)
146{
147 dbg("%s", __FUNCTION__);
148
149 sierra_send_setup(port);
150}
151
152static int sierra_tiocmget(struct usb_serial_port *port, struct file *file)
153{
154 unsigned int value;
155 struct sierra_port_private *portdata;
156
157 portdata = usb_get_serial_port_data(port);
158
159 value = ((portdata->rts_state) ? TIOCM_RTS : 0) |
160 ((portdata->dtr_state) ? TIOCM_DTR : 0) |
161 ((portdata->cts_state) ? TIOCM_CTS : 0) |
162 ((portdata->dsr_state) ? TIOCM_DSR : 0) |
163 ((portdata->dcd_state) ? TIOCM_CAR : 0) |
164 ((portdata->ri_state) ? TIOCM_RNG : 0);
165
166 return value;
167}
168
169static int sierra_tiocmset(struct usb_serial_port *port, struct file *file,
170 unsigned int set, unsigned int clear)
171{
172 struct sierra_port_private *portdata;
173
174 portdata = usb_get_serial_port_data(port);
175
176 if (set & TIOCM_RTS)
177 portdata->rts_state = 1;
178 if (set & TIOCM_DTR)
179 portdata->dtr_state = 1;
180
181 if (clear & TIOCM_RTS)
182 portdata->rts_state = 0;
183 if (clear & TIOCM_DTR)
184 portdata->dtr_state = 0;
185 return sierra_send_setup(port);
186}
187
188static int sierra_ioctl(struct usb_serial_port *port, struct file *file,
189 unsigned int cmd, unsigned long arg)
190{
191 return -ENOIOCTLCMD;
192}
193
194/* Write */
195static int sierra_write(struct usb_serial_port *port,
196 const unsigned char *buf, int count)
197{
198 struct sierra_port_private *portdata;
199 int i;
200 int left, todo;
201 struct urb *this_urb = NULL; /* spurious */
202 int err;
203
204 portdata = usb_get_serial_port_data(port);
205
206 dbg("%s: write (%d chars)", __FUNCTION__, count);
207
208 i = 0;
209 left = count;
210 for (i=0; left > 0 && i < N_OUT_URB; i++) {
211 todo = left;
212 if (todo > OUT_BUFLEN)
213 todo = OUT_BUFLEN;
214
215 this_urb = portdata->out_urbs[i];
216 if (this_urb->status == -EINPROGRESS) {
217 if (time_before(jiffies,
218 portdata->tx_start_time[i] + 10 * HZ))
219 continue;
220 usb_unlink_urb(this_urb);
221 continue;
222 }
223 if (this_urb->status != 0)
224 dbg("usb_write %p failed (err=%d)",
225 this_urb, this_urb->status);
226
227 dbg("%s: endpoint %d buf %d", __FUNCTION__,
228 usb_pipeendpoint(this_urb->pipe), i);
229
230 /* send the data */
231 memcpy (this_urb->transfer_buffer, buf, todo);
232 this_urb->transfer_buffer_length = todo;
233
234 this_urb->dev = port->serial->dev;
235 err = usb_submit_urb(this_urb, GFP_ATOMIC);
236 if (err) {
237 dbg("usb_submit_urb %p (write bulk) failed "
238 "(%d, has %d)", this_urb,
239 err, this_urb->status);
240 continue;
241 }
242 portdata->tx_start_time[i] = jiffies;
243 buf += todo;
244 left -= todo;
245 }
246
247 count -= left;
248 dbg("%s: wrote (did %d)", __FUNCTION__, count);
249 return count;
250}
251
252static void sierra_indat_callback(struct urb *urb)
253{
254 int err;
255 int endpoint;
256 struct usb_serial_port *port;
257 struct tty_struct *tty;
258 unsigned char *data = urb->transfer_buffer;
259
260 dbg("%s: %p", __FUNCTION__, urb);
261
262 endpoint = usb_pipeendpoint(urb->pipe);
263 port = (struct usb_serial_port *) urb->context;
264
265 if (urb->status) {
266 dbg("%s: nonzero status: %d on endpoint %02x.",
267 __FUNCTION__, urb->status, endpoint);
268 } else {
269 tty = port->tty;
270 if (urb->actual_length) {
271 tty_buffer_request_room(tty, urb->actual_length);
272 tty_insert_flip_string(tty, data, urb->actual_length);
273 tty_flip_buffer_push(tty);
274 } else {
275 dbg("%s: empty read urb received", __FUNCTION__);
276 }
277
278 /* Resubmit urb so we continue receiving */
279 if (port->open_count && urb->status != -ESHUTDOWN) {
280 err = usb_submit_urb(urb, GFP_ATOMIC);
281 if (err)
282 printk(KERN_ERR "%s: resubmit read urb failed. "
283 "(%d)", __FUNCTION__, err);
284 }
285 }
286 return;
287}
288
289static void sierra_outdat_callback(struct urb *urb)
290{
291 struct usb_serial_port *port;
292
293 dbg("%s", __FUNCTION__);
294
295 port = (struct usb_serial_port *) urb->context;
296
297 usb_serial_port_softint(port);
298}
299
300static void sierra_instat_callback(struct urb *urb)
301{
302 int err;
303 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
304 struct sierra_port_private *portdata = usb_get_serial_port_data(port);
305 struct usb_serial *serial = port->serial;
306
307 dbg("%s", __FUNCTION__);
308 dbg("%s: urb %p port %p has data %p", __FUNCTION__,urb,port,portdata);
309
310 if (urb->status == 0) {
311 struct usb_ctrlrequest *req_pkt =
312 (struct usb_ctrlrequest *)urb->transfer_buffer;
313
314 if (!req_pkt) {
315 dbg("%s: NULL req_pkt\n", __FUNCTION__);
316 return;
317 }
318 if ((req_pkt->bRequestType == 0xA1) &&
319 (req_pkt->bRequest == 0x20)) {
320 int old_dcd_state;
321 unsigned char signals = *((unsigned char *)
322 urb->transfer_buffer +
323 sizeof(struct usb_ctrlrequest));
324
325 dbg("%s: signal x%x", __FUNCTION__, signals);
326
327 old_dcd_state = portdata->dcd_state;
328 portdata->cts_state = 1;
329 portdata->dcd_state = ((signals & 0x01) ? 1 : 0);
330 portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
331 portdata->ri_state = ((signals & 0x08) ? 1 : 0);
332
333 if (port->tty && !C_CLOCAL(port->tty) &&
334 old_dcd_state && !portdata->dcd_state)
335 tty_hangup(port->tty);
336 } else {
337 dbg("%s: type %x req %x", __FUNCTION__,
338 req_pkt->bRequestType,req_pkt->bRequest);
339 }
340 } else
341 dbg("%s: error %d", __FUNCTION__, urb->status);
342
343 /* Resubmit urb so we continue receiving IRQ data */
344 if (urb->status != -ESHUTDOWN) {
345 urb->dev = serial->dev;
346 err = usb_submit_urb(urb, GFP_ATOMIC);
347 if (err)
348 dbg("%s: resubmit intr urb failed. (%d)",
349 __FUNCTION__, err);
350 }
351}
352
353static int sierra_write_room(struct usb_serial_port *port)
354{
355 struct sierra_port_private *portdata;
356 int i;
357 int data_len = 0;
358 struct urb *this_urb;
359
360 portdata = usb_get_serial_port_data(port);
361
362 for (i=0; i < N_OUT_URB; i++) {
363 this_urb = portdata->out_urbs[i];
364 if (this_urb && this_urb->status != -EINPROGRESS)
365 data_len += OUT_BUFLEN;
366 }
367
368 dbg("%s: %d", __FUNCTION__, data_len);
369 return data_len;
370}
371
372static int sierra_chars_in_buffer(struct usb_serial_port *port)
373{
374 struct sierra_port_private *portdata;
375 int i;
376 int data_len = 0;
377 struct urb *this_urb;
378
379 portdata = usb_get_serial_port_data(port);
380
381 for (i=0; i < N_OUT_URB; i++) {
382 this_urb = portdata->out_urbs[i];
383 if (this_urb && this_urb->status == -EINPROGRESS)
384 data_len += this_urb->transfer_buffer_length;
385 }
386 dbg("%s: %d", __FUNCTION__, data_len);
387 return data_len;
388}
389
390static int sierra_open(struct usb_serial_port *port, struct file *filp)
391{
392 struct sierra_port_private *portdata;
393 struct usb_serial *serial = port->serial;
394 int i, err;
395 struct urb *urb;
396
397 portdata = usb_get_serial_port_data(port);
398
399 dbg("%s", __FUNCTION__);
400
401 /* Set some sane defaults */
402 portdata->rts_state = 1;
403 portdata->dtr_state = 1;
404
405 /* Reset low level data toggle and start reading from endpoints */
406 for (i = 0; i < N_IN_URB; i++) {
407 urb = portdata->in_urbs[i];
408 if (! urb)
409 continue;
410 if (urb->dev != serial->dev) {
411 dbg("%s: dev %p != %p", __FUNCTION__,
412 urb->dev, serial->dev);
413 continue;
414 }
415
416 /*
417 * make sure endpoint data toggle is synchronized with the
418 * device
419 */
420 usb_clear_halt(urb->dev, urb->pipe);
421
422 err = usb_submit_urb(urb, GFP_KERNEL);
423 if (err) {
424 dbg("%s: submit urb %d failed (%d) %d",
425 __FUNCTION__, i, err,
426 urb->transfer_buffer_length);
427 }
428 }
429
430 /* Reset low level data toggle on out endpoints */
431 for (i = 0; i < N_OUT_URB; i++) {
432 urb = portdata->out_urbs[i];
433 if (! urb)
434 continue;
435 urb->dev = serial->dev;
436 /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
437 usb_pipeout(urb->pipe), 0); */
438 }
439
440 port->tty->low_latency = 1;
441
442 sierra_send_setup(port);
443
444 return (0);
445}
446
447static inline void stop_urb(struct urb *urb)
448{
449 if (urb && urb->status == -EINPROGRESS)
450 usb_kill_urb(urb);
451}
452
453static void sierra_close(struct usb_serial_port *port, struct file *filp)
454{
455 int i;
456 struct usb_serial *serial = port->serial;
457 struct sierra_port_private *portdata;
458
459 dbg("%s", __FUNCTION__);
460 portdata = usb_get_serial_port_data(port);
461
462 portdata->rts_state = 0;
463 portdata->dtr_state = 0;
464
465 if (serial->dev) {
466 sierra_send_setup(port);
467
468 /* Stop reading/writing urbs */
469 for (i = 0; i < N_IN_URB; i++)
470 stop_urb(portdata->in_urbs[i]);
471 for (i = 0; i < N_OUT_URB; i++)
472 stop_urb(portdata->out_urbs[i]);
473 }
474 port->tty = NULL;
475}
476
477/* Helper functions used by sierra_setup_urbs */
478static struct urb *sierra_setup_urb(struct usb_serial *serial, int endpoint,
479 int dir, void *ctx, char *buf, int len,
480 usb_complete_t callback)
481{
482 struct urb *urb;
483
484 if (endpoint == -1)
485 return NULL; /* endpoint not needed */
486
487 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
488 if (urb == NULL) {
489 dbg("%s: alloc for endpoint %d failed.", __FUNCTION__, endpoint);
490 return NULL;
491 }
492
493 /* Fill URB using supplied data. */
494 usb_fill_bulk_urb(urb, serial->dev,
495 usb_sndbulkpipe(serial->dev, endpoint) | dir,
496 buf, len, callback, ctx);
497
498 return urb;
499}
500
501/* Setup urbs */
502static void sierra_setup_urbs(struct usb_serial *serial)
503{
504 int i,j;
505 struct usb_serial_port *port;
506 struct sierra_port_private *portdata;
507
508 dbg("%s", __FUNCTION__);
509
510 for (i = 0; i < serial->num_ports; i++) {
511 port = serial->port[i];
512 portdata = usb_get_serial_port_data(port);
513
514 /* Do indat endpoints first */
515 for (j = 0; j < N_IN_URB; ++j) {
516 portdata->in_urbs[j] = sierra_setup_urb (serial,
517 port->bulk_in_endpointAddress, USB_DIR_IN, port,
518 portdata->in_buffer[j], IN_BUFLEN, sierra_indat_callback);
519 }
520
521 /* outdat endpoints */
522 for (j = 0; j < N_OUT_URB; ++j) {
523 portdata->out_urbs[j] = sierra_setup_urb (serial,
524 port->bulk_out_endpointAddress, USB_DIR_OUT, port,
525 portdata->out_buffer[j], OUT_BUFLEN, sierra_outdat_callback);
526 }
527 }
528}
529
530static int sierra_startup(struct usb_serial *serial)
531{
532 int i, err;
533 struct usb_serial_port *port;
534 struct sierra_port_private *portdata;
535
536 dbg("%s", __FUNCTION__);
537
538 /* Now setup per port private data */
539 for (i = 0; i < serial->num_ports; i++) {
540 port = serial->port[i];
541 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
542 if (!portdata) {
543 dbg("%s: kmalloc for sierra_port_private (%d) failed!.",
544 __FUNCTION__, i);
545 return (1);
546 }
547
548 usb_set_serial_port_data(port, portdata);
549
550 if (! port->interrupt_in_urb)
551 continue;
552 err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
553 if (err)
554 dbg("%s: submit irq_in urb failed %d",
555 __FUNCTION__, err);
556 }
557
558 sierra_setup_urbs(serial);
559
560 return (0);
561}
562
563static void sierra_shutdown(struct usb_serial *serial)
564{
565 int i, j;
566 struct usb_serial_port *port;
567 struct sierra_port_private *portdata;
568
569 dbg("%s", __FUNCTION__);
570
571 /* Stop reading/writing urbs */
572 for (i = 0; i < serial->num_ports; ++i) {
573 port = serial->port[i];
574 portdata = usb_get_serial_port_data(port);
575 for (j = 0; j < N_IN_URB; j++)
576 stop_urb(portdata->in_urbs[j]);
577 for (j = 0; j < N_OUT_URB; j++)
578 stop_urb(portdata->out_urbs[j]);
579 }
580
581 /* Now free them */
582 for (i = 0; i < serial->num_ports; ++i) {
583 port = serial->port[i];
584 portdata = usb_get_serial_port_data(port);
585
586 for (j = 0; j < N_IN_URB; j++) {
587 if (portdata->in_urbs[j]) {
588 usb_free_urb(portdata->in_urbs[j]);
589 portdata->in_urbs[j] = NULL;
590 }
591 }
592 for (j = 0; j < N_OUT_URB; j++) {
593 if (portdata->out_urbs[j]) {
594 usb_free_urb(portdata->out_urbs[j]);
595 portdata->out_urbs[j] = NULL;
596 }
597 }
598 }
599
600 /* Now free per port private data */
601 for (i = 0; i < serial->num_ports; i++) {
602 port = serial->port[i];
603 kfree(usb_get_serial_port_data(port));
604 }
605}
606
607static struct usb_serial_driver sierra_1port_device = {
608 .driver = {
609 .owner = THIS_MODULE,
610 .name = "sierra1",
611 },
612 .description = "Sierra USB modem (1 port)",
613 .id_table = id_table_1port,
614 .num_interrupt_in = NUM_DONT_CARE,
615 .num_bulk_in = 1,
616 .num_bulk_out = 1,
617 .num_ports = 1,
618 .open = sierra_open,
619 .close = sierra_close,
620 .write = sierra_write,
621 .write_room = sierra_write_room,
622 .chars_in_buffer = sierra_chars_in_buffer,
623 .throttle = sierra_rx_throttle,
624 .unthrottle = sierra_rx_unthrottle,
625 .ioctl = sierra_ioctl,
626 .set_termios = sierra_set_termios,
627 .break_ctl = sierra_break_ctl,
628 .tiocmget = sierra_tiocmget,
629 .tiocmset = sierra_tiocmset,
630 .attach = sierra_startup,
631 .shutdown = sierra_shutdown,
632 .read_int_callback = sierra_instat_callback,
40}; 633};
41 634
42static struct usb_serial_driver sierra_device = { 635static struct usb_serial_driver sierra_3port_device = {
43 .driver = { 636 .driver = {
44 .owner = THIS_MODULE, 637 .owner = THIS_MODULE,
45 .name = "Sierra_Wireless", 638 .name = "sierra3",
46 }, 639 },
47 .id_table = id_table, 640 .description = "Sierra USB modem (3 port)",
48 .num_interrupt_in = NUM_DONT_CARE, 641 .id_table = id_table_3port,
49 .num_bulk_in = NUM_DONT_CARE, 642 .num_interrupt_in = NUM_DONT_CARE,
50 .num_bulk_out = NUM_DONT_CARE, 643 .num_bulk_in = 3,
51 .num_ports = 3, 644 .num_bulk_out = 3,
645 .num_ports = 3,
646 .open = sierra_open,
647 .close = sierra_close,
648 .write = sierra_write,
649 .write_room = sierra_write_room,
650 .chars_in_buffer = sierra_chars_in_buffer,
651 .throttle = sierra_rx_throttle,
652 .unthrottle = sierra_rx_unthrottle,
653 .ioctl = sierra_ioctl,
654 .set_termios = sierra_set_termios,
655 .break_ctl = sierra_break_ctl,
656 .tiocmget = sierra_tiocmget,
657 .tiocmset = sierra_tiocmset,
658 .attach = sierra_startup,
659 .shutdown = sierra_shutdown,
660 .read_int_callback = sierra_instat_callback,
52}; 661};
53 662
663/* Functions used by new usb-serial code. */
54static int __init sierra_init(void) 664static int __init sierra_init(void)
55{ 665{
56 int retval; 666 int retval;
57 667 retval = usb_serial_register(&sierra_1port_device);
58 retval = usb_serial_register(&sierra_device); 668 if (retval)
669 goto failed_1port_device_register;
670 retval = usb_serial_register(&sierra_3port_device);
59 if (retval) 671 if (retval)
60 return retval; 672 goto failed_3port_device_register;
673
674
61 retval = usb_register(&sierra_driver); 675 retval = usb_register(&sierra_driver);
62 if (retval) 676 if (retval)
63 usb_serial_deregister(&sierra_device); 677 goto failed_driver_register;
678
679 info(DRIVER_DESC ": " DRIVER_VERSION);
680
681 return 0;
682
683failed_driver_register:
684 usb_serial_deregister(&sierra_3port_device);
685failed_3port_device_register:
686 usb_serial_deregister(&sierra_1port_device);
687failed_1port_device_register:
64 return retval; 688 return retval;
65} 689}
66 690
67static void __exit sierra_exit(void) 691static void __exit sierra_exit(void)
68{ 692{
69 usb_deregister(&sierra_driver); 693 usb_deregister (&sierra_driver);
70 usb_serial_deregister(&sierra_device); 694 usb_serial_deregister(&sierra_1port_device);
695 usb_serial_deregister(&sierra_3port_device);
71} 696}
72 697
73module_init(sierra_init); 698module_init(sierra_init);
74module_exit(sierra_exit); 699module_exit(sierra_exit);
700
701MODULE_AUTHOR(DRIVER_AUTHOR);
702MODULE_DESCRIPTION(DRIVER_DESC);
703MODULE_VERSION(DRIVER_VERSION);
75MODULE_LICENSE("GPL"); 704MODULE_LICENSE("GPL");
705
706#ifdef CONFIG_USB_DEBUG
707module_param(debug, bool, S_IRUGO | S_IWUSR);
708MODULE_PARM_DESC(debug, "Debug messages");
709#endif
710
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index c9a8d50106d1..37ed8e0f2dc8 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -55,7 +55,8 @@ UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100,
55 US_SC_DEVICE, US_PR_DEVICE, NULL, 55 US_SC_DEVICE, US_PR_DEVICE, NULL,
56 US_FL_IGNORE_RESIDUE), 56 US_FL_IGNORE_RESIDUE),
57 57
58UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0100, 58/* modified by Tobias Lorenz <tobias.lorenz@gmx.net> */
59UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0200,
59 "Mitsumi", 60 "Mitsumi",
60 "USB FDD", 61 "USB FDD",
61 US_SC_DEVICE, US_PR_DEVICE, NULL, 62 US_SC_DEVICE, US_PR_DEVICE, NULL,
@@ -182,6 +183,20 @@ UNUSUAL_DEV( 0x0421, 0x044e, 0x0100, 0x0100,
182 US_SC_DEVICE, US_PR_DEVICE, NULL, 183 US_SC_DEVICE, US_PR_DEVICE, NULL,
183 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), 184 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
184 185
186/* Reported by Bardur Arantsson <bardur@scientician.net> */
187UNUSUAL_DEV( 0x0421, 0x047c, 0x0370, 0x0370,
188 "Nokia",
189 "6131",
190 US_SC_DEVICE, US_PR_DEVICE, NULL,
191 US_FL_MAX_SECTORS_64 ),
192
193/* Reported by Alex Corcoles <alex@corcoles.net> */
194UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370,
195 "Nokia",
196 "6234",
197 US_SC_DEVICE, US_PR_DEVICE, NULL,
198 US_FL_MAX_SECTORS_64 ),
199
185/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ 200/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */
186UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, 201UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210,
187 "SMSC", 202 "SMSC",
@@ -1291,6 +1306,13 @@ UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1291 US_SC_DEVICE, US_PR_DEVICE, NULL, 1306 US_SC_DEVICE, US_PR_DEVICE, NULL,
1292 US_FL_FIX_CAPACITY ), 1307 US_FL_FIX_CAPACITY ),
1293 1308
1309/* Reported by Jan Mate <mate@fiit.stuba.sk> */
1310UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1311 "Sony Ericsson",
1312 "P990i",
1313 US_SC_DEVICE, US_PR_DEVICE, NULL,
1314 US_FL_FIX_CAPACITY ),
1315
1294/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu> 1316/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu>
1295 * Tested on hardware version 1.10. 1317 * Tested on hardware version 1.10.
1296 * Entry is needed only for the initializer function override. 1318 * Entry is needed only for the initializer function override.
diff --git a/drivers/video/controlfb.c b/drivers/video/controlfb.c
index 8cc6c0e2d27a..04c6d928189b 100644
--- a/drivers/video/controlfb.c
+++ b/drivers/video/controlfb.c
@@ -415,13 +415,15 @@ static int __init init_control(struct fb_info_control *p)
415 full = p->total_vram == 0x400000; 415 full = p->total_vram == 0x400000;
416 416
417 /* Try to pick a video mode out of NVRAM if we have one. */ 417 /* Try to pick a video mode out of NVRAM if we have one. */
418#ifdef CONFIG_NVRAM
418 if (default_cmode == CMODE_NVRAM){ 419 if (default_cmode == CMODE_NVRAM){
419 cmode = nvram_read_byte(NV_CMODE); 420 cmode = nvram_read_byte(NV_CMODE);
420 if(cmode < CMODE_8 || cmode > CMODE_32) 421 if(cmode < CMODE_8 || cmode > CMODE_32)
421 cmode = CMODE_8; 422 cmode = CMODE_8;
422 } else 423 } else
424#endif
423 cmode=default_cmode; 425 cmode=default_cmode;
424 426#ifdef CONFIG_NVRAM
425 if (default_vmode == VMODE_NVRAM) { 427 if (default_vmode == VMODE_NVRAM) {
426 vmode = nvram_read_byte(NV_VMODE); 428 vmode = nvram_read_byte(NV_VMODE);
427 if (vmode < 1 || vmode > VMODE_MAX || 429 if (vmode < 1 || vmode > VMODE_MAX ||
@@ -432,7 +434,9 @@ static int __init init_control(struct fb_info_control *p)
432 if (control_mac_modes[vmode - 1].m[full] < cmode) 434 if (control_mac_modes[vmode - 1].m[full] < cmode)
433 vmode = VMODE_640_480_60; 435 vmode = VMODE_640_480_60;
434 } 436 }
435 } else { 437 } else
438#endif
439 {
436 vmode=default_vmode; 440 vmode=default_vmode;
437 if (control_mac_modes[vmode - 1].m[full] < cmode) { 441 if (control_mac_modes[vmode - 1].m[full] < cmode) {
438 if (cmode > CMODE_8) 442 if (cmode > CMODE_8)
diff --git a/drivers/video/igafb.c b/drivers/video/igafb.c
index 67f384f86758..e6df492c22a5 100644
--- a/drivers/video/igafb.c
+++ b/drivers/video/igafb.c
@@ -573,3 +573,10 @@ int __init igafb_setup(char *options)
573 573
574module_init(igafb_init); 574module_init(igafb_init);
575MODULE_LICENSE("GPL"); 575MODULE_LICENSE("GPL");
576static struct pci_device_id igafb_pci_tbl[] __devinitdata = {
577 { PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_1682,
578 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
579 { }
580};
581
582MODULE_DEVICE_TABLE(pci, igafb_pci_tbl);
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index 983be3ec2345..fdb33cd21a27 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -339,11 +339,12 @@ static int __devinit platinum_init_fb(struct fb_info *info)
339 339
340 sense = read_platinum_sense(pinfo); 340 sense = read_platinum_sense(pinfo);
341 printk(KERN_INFO "platinumfb: Monitor sense value = 0x%x, ", sense); 341 printk(KERN_INFO "platinumfb: Monitor sense value = 0x%x, ", sense);
342
343 if (default_vmode == VMODE_NVRAM) { 342 if (default_vmode == VMODE_NVRAM) {
343#ifdef CONFIG_NVRAM
344 default_vmode = nvram_read_byte(NV_VMODE); 344 default_vmode = nvram_read_byte(NV_VMODE);
345 if (default_vmode <= 0 || default_vmode > VMODE_MAX || 345 if (default_vmode <= 0 || default_vmode > VMODE_MAX ||
346 !platinum_reg_init[default_vmode-1]) 346 !platinum_reg_init[default_vmode-1])
347#endif
347 default_vmode = VMODE_CHOOSE; 348 default_vmode = VMODE_CHOOSE;
348 } 349 }
349 if (default_vmode == VMODE_CHOOSE) { 350 if (default_vmode == VMODE_CHOOSE) {
@@ -351,8 +352,10 @@ static int __devinit platinum_init_fb(struct fb_info *info)
351 } 352 }
352 if (default_vmode <= 0 || default_vmode > VMODE_MAX) 353 if (default_vmode <= 0 || default_vmode > VMODE_MAX)
353 default_vmode = VMODE_640_480_60; 354 default_vmode = VMODE_640_480_60;
355#ifdef CONFIG_NVRAM
354 if (default_cmode == CMODE_NVRAM) 356 if (default_cmode == CMODE_NVRAM)
355 default_cmode = nvram_read_byte(NV_CMODE); 357 default_cmode = nvram_read_byte(NV_CMODE);
358#endif
356 if (default_cmode < CMODE_8 || default_cmode > CMODE_32) 359 if (default_cmode < CMODE_8 || default_cmode > CMODE_32)
357 default_cmode = CMODE_8; 360 default_cmode = CMODE_8;
358 /* 361 /*
diff --git a/drivers/video/valkyriefb.c b/drivers/video/valkyriefb.c
index 47f27924a7d7..06fc19a61192 100644
--- a/drivers/video/valkyriefb.c
+++ b/drivers/video/valkyriefb.c
@@ -284,7 +284,7 @@ static void __init valkyrie_choose_mode(struct fb_info_valkyrie *p)
284 printk(KERN_INFO "Monitor sense value = 0x%x\n", p->sense); 284 printk(KERN_INFO "Monitor sense value = 0x%x\n", p->sense);
285 285
286 /* Try to pick a video mode out of NVRAM if we have one. */ 286 /* Try to pick a video mode out of NVRAM if we have one. */
287#ifndef CONFIG_MAC 287#if !defined(CONFIG_MAC) && defined(CONFIG_NVRAM)
288 if (default_vmode == VMODE_NVRAM) { 288 if (default_vmode == VMODE_NVRAM) {
289 default_vmode = nvram_read_byte(NV_VMODE); 289 default_vmode = nvram_read_byte(NV_VMODE);
290 if (default_vmode <= 0 290 if (default_vmode <= 0
@@ -297,7 +297,7 @@ static void __init valkyrie_choose_mode(struct fb_info_valkyrie *p)
297 default_vmode = mac_map_monitor_sense(p->sense); 297 default_vmode = mac_map_monitor_sense(p->sense);
298 if (!valkyrie_reg_init[default_vmode - 1]) 298 if (!valkyrie_reg_init[default_vmode - 1])
299 default_vmode = VMODE_640_480_67; 299 default_vmode = VMODE_640_480_67;
300#ifndef CONFIG_MAC 300#if !defined(CONFIG_MAC) && defined(CONFIG_NVRAM)
301 if (default_cmode == CMODE_NVRAM) 301 if (default_cmode == CMODE_NVRAM)
302 default_cmode = nvram_read_byte(NV_CMODE); 302 default_cmode = nvram_read_byte(NV_CMODE);
303#endif 303#endif
diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig
index 27c9d05d03ef..c287a9ae4fdd 100644
--- a/drivers/w1/Kconfig
+++ b/drivers/w1/Kconfig
@@ -2,7 +2,6 @@ menu "Dallas's 1-wire bus"
2 2
3config W1 3config W1
4 tristate "Dallas's 1-wire support" 4 tristate "Dallas's 1-wire support"
5 depends on CONNECTOR
6 ---help--- 5 ---help---
7 Dallas' 1-wire bus is useful to connect slow 1-pin devices 6 Dallas' 1-wire bus is useful to connect slow 1-pin devices
8 such as iButtons and thermal sensors. 7 such as iButtons and thermal sensors.