aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJames Bottomley <jejb@titanic.(none)>2005-05-20 16:27:44 -0400
committerJames Bottomley <jejb@titanic.(none)>2005-05-20 16:27:44 -0400
commitad34ea2cc3845ef4dcd7d12fb0fa8484734bd672 (patch)
treead434400f5ecaa33b433c8f830e40792d8d6c05c /drivers
parent90356ac3194bf91a441a5f9c3067af386ef62462 (diff)
parent88d7bd8cb9eb8d64bf7997600b0d64f7834047c5 (diff)
merge by hand - fix up rejections in Documentation/DocBook/Makefile
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/processor_idle.c2
-rw-r--r--drivers/acpi/scan.c4
-rw-r--r--drivers/atm/eni.c27
-rw-r--r--drivers/atm/fore200e.c4
-rw-r--r--drivers/atm/he.c3
-rw-r--r--drivers/atm/he.h2
-rw-r--r--drivers/base/bus.c5
-rw-r--r--drivers/base/core.c2
-rw-r--r--drivers/base/platform.c4
-rw-r--r--drivers/block/DAC960.c132
-rw-r--r--drivers/block/DAC960.h317
-rw-r--r--drivers/block/Kconfig4
-rw-r--r--drivers/block/aoe/aoe.h2
-rw-r--r--drivers/block/aoe/aoeblk.c13
-rw-r--r--drivers/block/aoe/aoedev.c11
-rw-r--r--drivers/block/aoe/aoenet.c17
-rw-r--r--drivers/block/floppy.c2
-rw-r--r--drivers/block/genhd.c4
-rw-r--r--drivers/block/nbd.c16
-rw-r--r--drivers/block/noop-iosched.c27
-rw-r--r--drivers/cdrom/cdrom.c2
-rw-r--r--drivers/cdrom/cdu31a.c6
-rw-r--r--drivers/cdrom/mcdx.c28
-rw-r--r--drivers/cdrom/sbpcd.c2
-rw-r--r--drivers/char/Kconfig20
-rw-r--r--drivers/char/Makefile3
-rw-r--r--drivers/char/agp/ali-agp.c4
-rw-r--r--drivers/char/agp/amd-k7-agp.c2
-rw-r--r--drivers/char/agp/amd64-agp.c2
-rw-r--r--drivers/char/agp/ati-agp.c2
-rw-r--r--drivers/char/agp/backend.c4
-rw-r--r--drivers/char/agp/efficeon-agp.c2
-rw-r--r--drivers/char/agp/frontend.c6
-rw-r--r--drivers/char/agp/nvidia-agp.c2
-rw-r--r--drivers/char/agp/sis-agp.c2
-rw-r--r--drivers/char/agp/sworks-agp.c2
-rw-r--r--drivers/char/agp/via-agp.c4
-rw-r--r--drivers/char/dtlk.c2
-rw-r--r--drivers/char/hangcheck-timer.c104
-rw-r--r--drivers/char/ipmi/ipmi_bt_sm.c1
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c36
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c97
-rw-r--r--drivers/char/ipmi/ipmi_si_sm.h2
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c2
-rw-r--r--drivers/char/keyboard.c3
-rw-r--r--drivers/char/mbcs.c849
-rw-r--r--drivers/char/mbcs.h553
-rw-r--r--drivers/char/rio/rio_linux.c2
-rw-r--r--drivers/char/s3c2410-rtc.c8
-rw-r--r--drivers/char/snsc.c8
-rw-r--r--drivers/char/snsc.h40
-rw-r--r--drivers/char/snsc_event.c304
-rw-r--r--drivers/char/sonypi.c6
-rw-r--r--drivers/char/specialix.c11
-rw-r--r--drivers/char/stallion.c4
-rw-r--r--drivers/char/tpm/tpm.c6
-rw-r--r--drivers/char/tty_io.c2
-rw-r--r--drivers/char/vt_ioctl.c3
-rw-r--r--drivers/cpufreq/cpufreq.c97
-rw-r--r--drivers/i2c/busses/Kconfig2
-rw-r--r--drivers/i2c/busses/i2c-mpc.c4
-rw-r--r--drivers/ide/pci/sis5513.c6
-rw-r--r--drivers/ide/ppc/pmac.c7
-rw-r--r--drivers/ieee1394/ohci1394.c69
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c2
-rw-r--r--drivers/input/joystick/spaceorb.c2
-rw-r--r--drivers/input/keyboard/atkbd.c2
-rw-r--r--drivers/isdn/capi/capi.c10
-rw-r--r--drivers/isdn/capi/kcapi_proc.c10
-rw-r--r--drivers/isdn/divert/isdn_divert.c10
-rw-r--r--drivers/isdn/hisax/hfc4s8s_l1.c1
-rw-r--r--drivers/macintosh/adbhid.c40
-rw-r--r--drivers/macintosh/via-pmu.c9
-rw-r--r--drivers/md/dm-crypt.c19
-rw-r--r--drivers/md/dm-emc.c6
-rw-r--r--drivers/md/dm-hw-handler.c2
-rw-r--r--drivers/md/dm-mpath.c32
-rw-r--r--drivers/md/dm-path-selector.c2
-rw-r--r--drivers/md/dm-table.c2
-rw-r--r--drivers/md/dm-zero.c4
-rw-r--r--drivers/md/dm.c96
-rw-r--r--drivers/md/md.c14
-rw-r--r--drivers/md/multipath.c5
-rw-r--r--drivers/md/raid1.c2
-rw-r--r--drivers/md/raid10.c2
-rw-r--r--drivers/md/raid5.c2
-rw-r--r--drivers/md/raid6main.c2
-rw-r--r--drivers/media/common/ir-common.c18
-rw-r--r--drivers/media/dvb/frontends/cx22702.c15
-rw-r--r--drivers/media/dvb/frontends/cx22702.h3
-rw-r--r--drivers/media/video/Kconfig1
-rw-r--r--drivers/media/video/bttv-driver.c6
-rw-r--r--drivers/media/video/bttv-i2c.c14
-rw-r--r--drivers/media/video/cx88/cx88-core.c5
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c16
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c4
-rw-r--r--drivers/media/video/cx88/cx88-vbi.c6
-rw-r--r--drivers/media/video/cx88/cx88-video.c12
-rw-r--r--drivers/media/video/cx88/cx88.h4
-rw-r--r--drivers/media/video/msp3400.c28
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c89
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c21
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c20
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c1
-rw-r--r--drivers/media/video/tuner-core.c14
-rw-r--r--drivers/media/video/tvaudio.c2
-rw-r--r--drivers/mmc/Kconfig2
-rw-r--r--drivers/net/3c59x.c9
-rw-r--r--drivers/net/Kconfig10
-rw-r--r--drivers/net/Space.c2
-rw-r--r--drivers/net/appletalk/Kconfig2
-rw-r--r--drivers/net/appletalk/cops.c4
-rw-r--r--drivers/net/appletalk/cops_ffdrv.h2
-rw-r--r--drivers/net/appletalk/cops_ltdrv.h2
-rw-r--r--drivers/net/appletalk/ltpc.c2
-rw-r--r--drivers/net/arcnet/capmode.c2
-rw-r--r--drivers/net/gt96100eth.h4
-rw-r--r--drivers/net/hamradio/6pack.c4
-rw-r--r--drivers/net/hamradio/Kconfig4
-rw-r--r--drivers/net/hamradio/baycom_epp.c4
-rw-r--r--drivers/net/hamradio/bpqether.c10
-rw-r--r--drivers/net/hamradio/dmascc.c4
-rw-r--r--drivers/net/hamradio/hdlcdrv.c4
-rw-r--r--drivers/net/hamradio/mkiss.c4
-rw-r--r--drivers/net/hamradio/scc.c5
-rw-r--r--drivers/net/hamradio/yam.c4
-rw-r--r--drivers/net/hp100.c4
-rw-r--r--drivers/net/irda/Kconfig10
-rw-r--r--drivers/net/loopback.c2
-rw-r--r--drivers/net/mv643xx_eth.c4
-rw-r--r--drivers/net/ppp_deflate.c6
-rw-r--r--drivers/net/ppp_generic.c12
-rw-r--r--drivers/net/r8169.c2
-rw-r--r--drivers/net/slip.c30
-rw-r--r--drivers/net/sunbmac.c13
-rw-r--r--drivers/net/sunhme.c16
-rw-r--r--drivers/net/sunlance.c17
-rw-r--r--drivers/net/sunqe.c17
-rw-r--r--drivers/net/tg3.c662
-rw-r--r--drivers/net/tg3.h25
-rw-r--r--drivers/net/wan/Kconfig6
-rw-r--r--drivers/net/wan/cycx_x25.c8
-rw-r--r--drivers/net/wan/pc300_drv.c22
-rw-r--r--drivers/net/wan/pc300_tty.c27
-rw-r--r--drivers/net/wan/sdla_chdlc.c13
-rw-r--r--drivers/net/wan/x25_asy.c20
-rw-r--r--drivers/oprofile/oprofile_files.c4
-rw-r--r--drivers/parport/Kconfig2
-rw-r--r--drivers/parport/parport_pc.c34
-rw-r--r--drivers/pci/hotplug.c4
-rw-r--r--drivers/pci/hotplug/ibmphp.h2
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c6
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c7
-rw-r--r--drivers/pci/hotplug/pci_hotplug.h2
-rw-r--r--drivers/pci/hotplug/pciehp_core.c23
-rw-r--r--drivers/pci/hotplug/pcihp_skeleton.c2
-rw-r--r--drivers/pci/msi.c6
-rw-r--r--drivers/pci/pci-acpi.c2
-rw-r--r--drivers/pci/pci-driver.c11
-rw-r--r--drivers/pci/pci-sysfs.c82
-rw-r--r--drivers/pci/pci.c20
-rw-r--r--drivers/pci/probe.c1
-rw-r--r--drivers/pci/proc.c1
-rw-r--r--drivers/pci/quirks.c2
-rw-r--r--drivers/pci/rom.c14
-rw-r--r--drivers/pcmcia/pd6729.c2
-rw-r--r--drivers/pcmcia/ti113x.h40
-rw-r--r--drivers/pnp/manager.c2
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c4
-rw-r--r--drivers/pnp/pnpbios/rsparser.c4
-rw-r--r--drivers/s390/block/dasd.c21
-rw-r--r--drivers/s390/block/dasd_cmb.c19
-rw-r--r--drivers/s390/block/dasd_devmap.c59
-rw-r--r--drivers/s390/block/dasd_eckd.c5
-rw-r--r--drivers/s390/block/dasd_genhd.c10
-rw-r--r--drivers/s390/block/dasd_int.h7
-rw-r--r--drivers/s390/block/dasd_ioctl.c31
-rw-r--r--drivers/s390/block/dasd_proc.c8
-rw-r--r--drivers/s390/cio/airq.c4
-rw-r--r--drivers/s390/cio/cio.c4
-rw-r--r--drivers/s390/cio/device_ops.c6
-rw-r--r--drivers/s390/cio/qdio.h6
-rw-r--r--drivers/s390/crypto/z90main.c140
-rw-r--r--drivers/s390/net/smsgiucv.c19
-rw-r--r--drivers/s390/net/smsgiucv.h4
-rw-r--r--drivers/sbus/char/rtc.c109
-rw-r--r--drivers/scsi/Kconfig12
-rw-r--r--drivers/scsi/NCR53C9x.c5
-rw-r--r--drivers/scsi/aacraid/linit.c2
-rw-r--r--drivers/scsi/esp.c11
-rw-r--r--drivers/scsi/pas16.c6
-rw-r--r--drivers/scsi/pluto.c2
-rw-r--r--drivers/scsi/scsi.c2
-rw-r--r--drivers/scsi/scsi_error.c2
-rw-r--r--drivers/scsi/scsi_scan.c2
-rw-r--r--drivers/scsi/scsi_transport_spi.c49
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c5
-rw-r--r--drivers/serial/21285.c2
-rw-r--r--drivers/serial/8250.c2
-rw-r--r--drivers/serial/8250_hp300.c53
-rw-r--r--drivers/serial/8250_pci.c2
-rw-r--r--drivers/serial/amba-pl010.c2
-rw-r--r--drivers/serial/amba-pl011.c2
-rw-r--r--drivers/serial/clps711x.c65
-rw-r--r--drivers/serial/imx.c68
-rw-r--r--drivers/serial/ioc4_serial.c50
-rw-r--r--drivers/serial/jsm/jsm.h1
-rw-r--r--drivers/serial/jsm/jsm_neo.c2
-rw-r--r--drivers/serial/jsm/jsm_tty.c4
-rw-r--r--drivers/serial/mpsc.c14
-rw-r--r--drivers/serial/mpsc.h10
-rw-r--r--drivers/serial/s3c2410.c2
-rw-r--r--drivers/serial/sa1100.c65
-rw-r--r--drivers/serial/serial_cs.c173
-rw-r--r--drivers/serial/serial_lh7a40x.c2
-rw-r--r--drivers/serial/sn_console.c4
-rw-r--r--drivers/serial/sunsab.c16
-rw-r--r--drivers/serial/sunsu.c11
-rw-r--r--drivers/telephony/ixj.c18
-rw-r--r--drivers/telephony/ixj.h2
-rw-r--r--drivers/usb/core/message.c4
-rw-r--r--drivers/usb/core/urb.c6
-rw-r--r--drivers/usb/core/usb.c6
-rw-r--r--drivers/usb/gadget/ether.c2
-rw-r--r--drivers/usb/gadget/inode.c2
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c2
-rw-r--r--drivers/usb/gadget/serial.c2
-rw-r--r--drivers/usb/host/ehci-hcd.c65
-rw-r--r--drivers/usb/host/ehci-hub.c2
-rw-r--r--drivers/usb/host/ehci.h19
-rw-r--r--drivers/usb/host/hc_crisv10.c2
-rw-r--r--drivers/usb/host/sl811-hcd.c4
-rw-r--r--drivers/usb/image/mdc800.c2
-rw-r--r--drivers/usb/image/microtek.c2
-rw-r--r--drivers/usb/input/aiptek.c2
-rw-r--r--drivers/usb/input/ati_remote.c2
-rw-r--r--drivers/usb/input/mtouchusb.c2
-rw-r--r--drivers/usb/input/usbkbd.c3
-rw-r--r--drivers/usb/media/ov511.c2
-rw-r--r--drivers/usb/media/pwc/pwc-ctrl.c80
-rw-r--r--drivers/usb/media/pwc/pwc-if.c12
-rw-r--r--drivers/usb/media/pwc/pwc-ioctl.h2
-rw-r--r--drivers/usb/media/pwc/pwc.h6
-rw-r--r--drivers/usb/media/sn9c102_core.c4
-rw-r--r--drivers/usb/media/sn9c102_sensor.h2
-rw-r--r--drivers/usb/misc/legousbtower.c2
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.c3
-rw-r--r--drivers/usb/net/pegasus.c4
-rw-r--r--drivers/usb/net/usbnet.c432
-rw-r--r--drivers/usb/net/zd1201.c28
-rw-r--r--drivers/usb/serial/Kconfig18
-rw-r--r--drivers/usb/serial/Makefile2
-rw-r--r--drivers/usb/serial/airprime.c63
-rw-r--r--drivers/usb/serial/cypress_m8.c187
-rw-r--r--drivers/usb/serial/ftdi_sio.c46
-rw-r--r--drivers/usb/serial/ftdi_sio.h36
-rw-r--r--drivers/usb/serial/hp4x.c85
-rw-r--r--drivers/usb/serial/io_usbvend.h2
-rw-r--r--drivers/usb/serial/keyspan_usa90msg.h2
-rw-r--r--drivers/usb/storage/debug.c1
-rw-r--r--drivers/usb/storage/shuttle_usbat.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h39
-rw-r--r--drivers/video/Kconfig8
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/amba-clcd.c22
-rw-r--r--drivers/video/aty/radeon_base.c118
-rw-r--r--drivers/video/console/fbcon.c5
-rw-r--r--drivers/video/console/vgacon.c2
-rw-r--r--drivers/video/cyber2000fb.c8
-rw-r--r--drivers/video/fbcmap.c32
-rw-r--r--drivers/video/fbmem.c7
-rw-r--r--drivers/video/fbmon.c1
-rw-r--r--drivers/video/fbsysfs.c2
-rw-r--r--drivers/video/i810/i810_main.c14
-rw-r--r--drivers/video/imsttfb.c4
-rw-r--r--drivers/video/imxfb.c695
-rw-r--r--drivers/video/imxfb.h72
-rw-r--r--drivers/video/intelfb/intelfbdrv.c38
-rw-r--r--drivers/video/intelfb/intelfbdrv.h68
-rw-r--r--drivers/video/logo/Kconfig2
-rw-r--r--drivers/video/nvidia/nvidia.c26
-rw-r--r--drivers/video/radeonfb.c2
-rw-r--r--drivers/video/savage/savagefb_driver.c6
-rw-r--r--drivers/video/sis/init.c4
-rw-r--r--drivers/video/sis/init.h3
-rw-r--r--drivers/video/sis/init301.c9
-rw-r--r--drivers/video/sis/init301.h4
-rw-r--r--drivers/video/sis/sis_main.c5
-rw-r--r--drivers/video/tcx.c14
-rw-r--r--drivers/video/tdfxfb.c88
-rw-r--r--drivers/video/tgafb.c4
-rw-r--r--drivers/video/vesafb.c3
293 files changed, 6461 insertions, 1868 deletions
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 05a17812d521..ff64d333e95f 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -838,7 +838,7 @@ int acpi_processor_cst_has_changed (struct acpi_processor *pr)
838 838
839 /* Fall back to the default idle loop */ 839 /* Fall back to the default idle loop */
840 pm_idle = pm_idle_save; 840 pm_idle = pm_idle_save;
841 synchronize_kernel(); 841 synchronize_sched(); /* Relies on interrupts forcing exit from idle. */
842 842
843 pr->flags.power = 0; 843 pr->flags.power = 0;
844 result = acpi_processor_get_power_info(pr); 844 result = acpi_processor_get_power_info(pr);
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index e7ca06626566..119c94093a13 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -379,8 +379,8 @@ ACPI_DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store);
379 379
380/** 380/**
381 * setup_sys_fs_device_files - sets up the device files under device namespace 381 * setup_sys_fs_device_files - sets up the device files under device namespace
382 * @@dev: acpi_device object 382 * @dev: acpi_device object
383 * @@func: function pointer to create or destroy the device file 383 * @func: function pointer to create or destroy the device file
384 */ 384 */
385static void 385static void
386setup_sys_fs_device_files ( 386setup_sys_fs_device_files (
diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
index 78e34ee79df8..10da36934769 100644
--- a/drivers/atm/eni.c
+++ b/drivers/atm/eni.c
@@ -59,7 +59,6 @@
59 * - doesn't support OAM cells 59 * - doesn't support OAM cells
60 * - eni_put_free may hang if not putting memory fragments that _complete_ 60 * - eni_put_free may hang if not putting memory fragments that _complete_
61 * 2^n block (never happens in real life, though) 61 * 2^n block (never happens in real life, though)
62 * - keeps IRQ even if initialization fails
63 */ 62 */
64 63
65 64
@@ -1802,22 +1801,22 @@ static int __devinit eni_start(struct atm_dev *dev)
1802 if (request_irq(eni_dev->irq,&eni_int,SA_SHIRQ,DEV_LABEL,dev)) { 1801 if (request_irq(eni_dev->irq,&eni_int,SA_SHIRQ,DEV_LABEL,dev)) {
1803 printk(KERN_ERR DEV_LABEL "(itf %d): IRQ%d is already in use\n", 1802 printk(KERN_ERR DEV_LABEL "(itf %d): IRQ%d is already in use\n",
1804 dev->number,eni_dev->irq); 1803 dev->number,eni_dev->irq);
1805 return -EAGAIN; 1804 error = -EAGAIN;
1805 goto out;
1806 } 1806 }
1807 /* @@@ should release IRQ on error */
1808 pci_set_master(eni_dev->pci_dev); 1807 pci_set_master(eni_dev->pci_dev);
1809 if ((error = pci_write_config_word(eni_dev->pci_dev,PCI_COMMAND, 1808 if ((error = pci_write_config_word(eni_dev->pci_dev,PCI_COMMAND,
1810 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | 1809 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
1811 (eni_dev->asic ? PCI_COMMAND_PARITY | PCI_COMMAND_SERR : 0)))) { 1810 (eni_dev->asic ? PCI_COMMAND_PARITY | PCI_COMMAND_SERR : 0)))) {
1812 printk(KERN_ERR DEV_LABEL "(itf %d): can't enable memory+" 1811 printk(KERN_ERR DEV_LABEL "(itf %d): can't enable memory+"
1813 "master (0x%02x)\n",dev->number,error); 1812 "master (0x%02x)\n",dev->number,error);
1814 return error; 1813 goto free_irq;
1815 } 1814 }
1816 if ((error = pci_write_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL, 1815 if ((error = pci_write_config_byte(eni_dev->pci_dev,PCI_TONGA_CTRL,
1817 END_SWAP_DMA))) { 1816 END_SWAP_DMA))) {
1818 printk(KERN_ERR DEV_LABEL "(itf %d): can't set endian swap " 1817 printk(KERN_ERR DEV_LABEL "(itf %d): can't set endian swap "
1819 "(0x%02x)\n",dev->number,error); 1818 "(0x%02x)\n",dev->number,error);
1820 return error; 1819 goto free_irq;
1821 } 1820 }
1822 /* determine addresses of internal tables */ 1821 /* determine addresses of internal tables */
1823 eni_dev->vci = eni_dev->ram; 1822 eni_dev->vci = eni_dev->ram;
@@ -1839,7 +1838,8 @@ static int __devinit eni_start(struct atm_dev *dev)
1839 if (!eni_dev->free_list) { 1838 if (!eni_dev->free_list) {
1840 printk(KERN_ERR DEV_LABEL "(itf %d): couldn't get free page\n", 1839 printk(KERN_ERR DEV_LABEL "(itf %d): couldn't get free page\n",
1841 dev->number); 1840 dev->number);
1842 return -ENOMEM; 1841 error = -ENOMEM;
1842 goto free_irq;
1843 } 1843 }
1844 eni_dev->free_len = 0; 1844 eni_dev->free_len = 0;
1845 eni_put_free(eni_dev,buf,buffer_mem); 1845 eni_put_free(eni_dev,buf,buffer_mem);
@@ -1855,17 +1855,26 @@ static int __devinit eni_start(struct atm_dev *dev)
1855 */ 1855 */
1856 eni_out(0xffffffff,MID_IE); 1856 eni_out(0xffffffff,MID_IE);
1857 error = start_tx(dev); 1857 error = start_tx(dev);
1858 if (error) return error; 1858 if (error) goto free_list;
1859 error = start_rx(dev); 1859 error = start_rx(dev);
1860 if (error) return error; 1860 if (error) goto free_list;
1861 error = dev->phy->start(dev); 1861 error = dev->phy->start(dev);
1862 if (error) return error; 1862 if (error) goto free_list;
1863 eni_out(eni_in(MID_MC_S) | (1 << MID_INT_SEL_SHIFT) | 1863 eni_out(eni_in(MID_MC_S) | (1 << MID_INT_SEL_SHIFT) |
1864 MID_TX_LOCK_MODE | MID_DMA_ENABLE | MID_TX_ENABLE | MID_RX_ENABLE, 1864 MID_TX_LOCK_MODE | MID_DMA_ENABLE | MID_TX_ENABLE | MID_RX_ENABLE,
1865 MID_MC_S); 1865 MID_MC_S);
1866 /* Tonga uses SBus INTReq1 */ 1866 /* Tonga uses SBus INTReq1 */
1867 (void) eni_in(MID_ISA); /* clear Midway interrupts */ 1867 (void) eni_in(MID_ISA); /* clear Midway interrupts */
1868 return 0; 1868 return 0;
1869
1870free_list:
1871 kfree(eni_dev->free_list);
1872
1873free_irq:
1874 free_irq(eni_dev->irq, eni_dev);
1875
1876out:
1877 return error;
1869} 1878}
1870 1879
1871 1880
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index 196b33644627..9e65bfb85ba3 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -2792,8 +2792,6 @@ static void __devexit fore200e_pca_remove_one(struct pci_dev *pci_dev)
2792 2792
2793 fore200e = pci_get_drvdata(pci_dev); 2793 fore200e = pci_get_drvdata(pci_dev);
2794 2794
2795 list_del(&fore200e->entry);
2796
2797 fore200e_shutdown(fore200e); 2795 fore200e_shutdown(fore200e);
2798 kfree(fore200e); 2796 kfree(fore200e);
2799 pci_disable_device(pci_dev); 2797 pci_disable_device(pci_dev);
@@ -2850,7 +2848,7 @@ fore200e_module_init(void)
2850 } 2848 }
2851 2849
2852#ifdef CONFIG_ATM_FORE200E_PCA 2850#ifdef CONFIG_ATM_FORE200E_PCA
2853 if (!pci_module_init(&fore200e_pca_driver)) 2851 if (!pci_register_driver(&fore200e_pca_driver))
2854 return 0; 2852 return 0;
2855#endif 2853#endif
2856 2854
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index c2c31a5f4513..3022c548a132 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -70,6 +70,7 @@
70#include <linux/sched.h> 70#include <linux/sched.h>
71#include <linux/timer.h> 71#include <linux/timer.h>
72#include <linux/interrupt.h> 72#include <linux/interrupt.h>
73#include <linux/dma-mapping.h>
73#include <asm/io.h> 74#include <asm/io.h>
74#include <asm/byteorder.h> 75#include <asm/byteorder.h>
75#include <asm/uaccess.h> 76#include <asm/uaccess.h>
@@ -371,7 +372,7 @@ he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
371 372
372 if (pci_enable_device(pci_dev)) 373 if (pci_enable_device(pci_dev))
373 return -EIO; 374 return -EIO;
374 if (pci_set_dma_mask(pci_dev, HE_DMA_MASK) != 0) { 375 if (pci_set_dma_mask(pci_dev, DMA_32BIT_MASK) != 0) {
375 printk(KERN_WARNING "he: no suitable dma available\n"); 376 printk(KERN_WARNING "he: no suitable dma available\n");
376 err = -EIO; 377 err = -EIO;
377 goto init_one_failure; 378 goto init_one_failure;
diff --git a/drivers/atm/he.h b/drivers/atm/he.h
index 1a903859343a..1dc277547a73 100644
--- a/drivers/atm/he.h
+++ b/drivers/atm/he.h
@@ -380,8 +380,6 @@ struct he_vcc
380#define PCI_VENDOR_ID_FORE 0x1127 380#define PCI_VENDOR_ID_FORE 0x1127
381#define PCI_DEVICE_ID_FORE_HE 0x400 381#define PCI_DEVICE_ID_FORE_HE 0x400
382 382
383#define HE_DMA_MASK 0xffffffff
384
385#define GEN_CNTL_0 0x40 383#define GEN_CNTL_0 0x40
386#define INT_PROC_ENBL (1<<25) 384#define INT_PROC_ENBL (1<<25)
387#define SLAVE_ENDIAN_MODE (1<<16) 385#define SLAVE_ENDIAN_MODE (1<<16)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index f4fa27315fb4..2b3902c867da 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -405,9 +405,8 @@ void device_release_driver(struct device * dev)
405 405
406static void driver_detach(struct device_driver * drv) 406static void driver_detach(struct device_driver * drv)
407{ 407{
408 struct list_head * entry, * next; 408 while (!list_empty(&drv->devices)) {
409 list_for_each_safe(entry, next, &drv->devices) { 409 struct device * dev = container_of(drv->devices.next, struct device, driver_list);
410 struct device * dev = container_of(entry, struct device, driver_list);
411 device_release_driver(dev); 410 device_release_driver(dev);
412 } 411 }
413} 412}
diff --git a/drivers/base/core.c b/drivers/base/core.c
index a7cedd8cefe5..268a9c8d168b 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -139,7 +139,7 @@ static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
139 buffer = &buffer[length]; 139 buffer = &buffer[length];
140 buffer_size -= length; 140 buffer_size -= length;
141 141
142 if (dev->bus->hotplug) { 142 if (dev->bus && dev->bus->hotplug) {
143 /* have the bus specific function add its stuff */ 143 /* have the bus specific function add its stuff */
144 retval = dev->bus->hotplug (dev, envp, num_envp, buffer, buffer_size); 144 retval = dev->bus->hotplug (dev, envp, num_envp, buffer, buffer_size);
145 if (retval) { 145 if (retval) {
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index cd6453905a9b..3a5f4c991797 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -115,7 +115,7 @@ int platform_add_devices(struct platform_device **devs, int num)
115 115
116/** 116/**
117 * platform_device_register - add a platform-level device 117 * platform_device_register - add a platform-level device
118 * @dev: platform device we're adding 118 * @pdev: platform device we're adding
119 * 119 *
120 */ 120 */
121int platform_device_register(struct platform_device * pdev) 121int platform_device_register(struct platform_device * pdev)
@@ -174,7 +174,7 @@ int platform_device_register(struct platform_device * pdev)
174 174
175/** 175/**
176 * platform_device_unregister - remove a platform-level device 176 * platform_device_unregister - remove a platform-level device
177 * @dev: platform device we're removing 177 * @pdev: platform device we're removing
178 * 178 *
179 * Note that this function will also release all memory- and port-based 179 * Note that this function will also release all memory- and port-based
180 * resources owned by the device (@dev->resource). 180 * resources owned by the device (@dev->resource).
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 423bbf2000d2..3760edfdc65c 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -3,6 +3,7 @@
3 Linux Driver for Mylex DAC960/AcceleRAID/eXtremeRAID PCI RAID Controllers 3 Linux Driver for Mylex DAC960/AcceleRAID/eXtremeRAID PCI RAID Controllers
4 4
5 Copyright 1998-2001 by Leonard N. Zubkoff <lnz@dandelion.com> 5 Copyright 1998-2001 by Leonard N. Zubkoff <lnz@dandelion.com>
6 Portions Copyright 2002 by Mylex (An IBM Business Unit)
6 7
7 This program is free software; you may redistribute and/or modify it under 8 This program is free software; you may redistribute and/or modify it under
8 the terms of the GNU General Public License Version 2 as published by the 9 the terms of the GNU General Public License Version 2 as published by the
@@ -532,6 +533,34 @@ static void DAC960_WaitForCommand(DAC960_Controller_T *Controller)
532 spin_lock_irq(&Controller->queue_lock); 533 spin_lock_irq(&Controller->queue_lock);
533} 534}
534 535
536/*
537 DAC960_GEM_QueueCommand queues Command for DAC960 GEM Series Controllers.
538*/
539
540static void DAC960_GEM_QueueCommand(DAC960_Command_T *Command)
541{
542 DAC960_Controller_T *Controller = Command->Controller;
543 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
544 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
545 DAC960_V2_CommandMailbox_T *NextCommandMailbox =
546 Controller->V2.NextCommandMailbox;
547
548 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
549 DAC960_GEM_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
550
551 if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 ||
552 Controller->V2.PreviousCommandMailbox2->Words[0] == 0)
553 DAC960_GEM_MemoryMailboxNewCommand(ControllerBaseAddress);
554
555 Controller->V2.PreviousCommandMailbox2 =
556 Controller->V2.PreviousCommandMailbox1;
557 Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox;
558
559 if (++NextCommandMailbox > Controller->V2.LastCommandMailbox)
560 NextCommandMailbox = Controller->V2.FirstCommandMailbox;
561
562 Controller->V2.NextCommandMailbox = NextCommandMailbox;
563}
535 564
536/* 565/*
537 DAC960_BA_QueueCommand queues Command for DAC960 BA Series Controllers. 566 DAC960_BA_QueueCommand queues Command for DAC960 BA Series Controllers.
@@ -1464,6 +1493,17 @@ static boolean DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T
1464 Controller->V2.FirstStatusMailboxDMA; 1493 Controller->V2.FirstStatusMailboxDMA;
1465 switch (Controller->HardwareType) 1494 switch (Controller->HardwareType)
1466 { 1495 {
1496 case DAC960_GEM_Controller:
1497 while (DAC960_GEM_HardwareMailboxFullP(ControllerBaseAddress))
1498 udelay(1);
1499 DAC960_GEM_WriteHardwareMailbox(ControllerBaseAddress, CommandMailboxDMA);
1500 DAC960_GEM_HardwareMailboxNewCommand(ControllerBaseAddress);
1501 while (!DAC960_GEM_HardwareMailboxStatusAvailableP(ControllerBaseAddress))
1502 udelay(1);
1503 CommandStatus = DAC960_GEM_ReadCommandStatus(ControllerBaseAddress);
1504 DAC960_GEM_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1505 DAC960_GEM_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1506 break;
1467 case DAC960_BA_Controller: 1507 case DAC960_BA_Controller:
1468 while (DAC960_BA_HardwareMailboxFullP(ControllerBaseAddress)) 1508 while (DAC960_BA_HardwareMailboxFullP(ControllerBaseAddress))
1469 udelay(1); 1509 udelay(1);
@@ -2627,6 +2667,9 @@ static void DAC960_DetectCleanup(DAC960_Controller_T *Controller)
2627 if (Controller->MemoryMappedAddress) { 2667 if (Controller->MemoryMappedAddress) {
2628 switch(Controller->HardwareType) 2668 switch(Controller->HardwareType)
2629 { 2669 {
2670 case DAC960_GEM_Controller:
2671 DAC960_GEM_DisableInterrupts(Controller->BaseAddress);
2672 break;
2630 case DAC960_BA_Controller: 2673 case DAC960_BA_Controller:
2631 DAC960_BA_DisableInterrupts(Controller->BaseAddress); 2674 DAC960_BA_DisableInterrupts(Controller->BaseAddress);
2632 break; 2675 break;
@@ -2705,6 +2748,9 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
2705 2748
2706 switch (Controller->HardwareType) 2749 switch (Controller->HardwareType)
2707 { 2750 {
2751 case DAC960_GEM_Controller:
2752 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2753 break;
2708 case DAC960_BA_Controller: 2754 case DAC960_BA_Controller:
2709 Controller->PCI_Address = pci_resource_start(PCI_Device, 0); 2755 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2710 break; 2756 break;
@@ -2756,6 +2802,36 @@ DAC960_DetectController(struct pci_dev *PCI_Device,
2756 BaseAddress = Controller->BaseAddress; 2802 BaseAddress = Controller->BaseAddress;
2757 switch (Controller->HardwareType) 2803 switch (Controller->HardwareType)
2758 { 2804 {
2805 case DAC960_GEM_Controller:
2806 DAC960_GEM_DisableInterrupts(BaseAddress);
2807 DAC960_GEM_AcknowledgeHardwareMailboxStatus(BaseAddress);
2808 udelay(1000);
2809 while (DAC960_GEM_InitializationInProgressP(BaseAddress))
2810 {
2811 if (DAC960_GEM_ReadErrorStatus(BaseAddress, &ErrorStatus,
2812 &Parameter0, &Parameter1) &&
2813 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2814 Parameter0, Parameter1))
2815 goto Failure;
2816 udelay(10);
2817 }
2818 if (!DAC960_V2_EnableMemoryMailboxInterface(Controller))
2819 {
2820 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2821 "for Controller at\n", Controller);
2822 goto Failure;
2823 }
2824 DAC960_GEM_EnableInterrupts(BaseAddress);
2825 Controller->QueueCommand = DAC960_GEM_QueueCommand;
2826 Controller->ReadControllerConfiguration =
2827 DAC960_V2_ReadControllerConfiguration;
2828 Controller->ReadDeviceConfiguration =
2829 DAC960_V2_ReadDeviceConfiguration;
2830 Controller->ReportDeviceConfiguration =
2831 DAC960_V2_ReportDeviceConfiguration;
2832 Controller->QueueReadWriteCommand =
2833 DAC960_V2_QueueReadWriteCommand;
2834 break;
2759 case DAC960_BA_Controller: 2835 case DAC960_BA_Controller:
2760 DAC960_BA_DisableInterrupts(BaseAddress); 2836 DAC960_BA_DisableInterrupts(BaseAddress);
2761 DAC960_BA_AcknowledgeHardwareMailboxStatus(BaseAddress); 2837 DAC960_BA_AcknowledgeHardwareMailboxStatus(BaseAddress);
@@ -5189,6 +5265,47 @@ static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
5189 wake_up(&Controller->CommandWaitQueue); 5265 wake_up(&Controller->CommandWaitQueue);
5190} 5266}
5191 5267
5268/*
5269 DAC960_GEM_InterruptHandler handles hardware interrupts from DAC960 GEM Series
5270 Controllers.
5271*/
5272
5273static irqreturn_t DAC960_GEM_InterruptHandler(int IRQ_Channel,
5274 void *DeviceIdentifier,
5275 struct pt_regs *InterruptRegisters)
5276{
5277 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5278 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5279 DAC960_V2_StatusMailbox_T *NextStatusMailbox;
5280 unsigned long flags;
5281
5282 spin_lock_irqsave(&Controller->queue_lock, flags);
5283 DAC960_GEM_AcknowledgeInterrupt(ControllerBaseAddress);
5284 NextStatusMailbox = Controller->V2.NextStatusMailbox;
5285 while (NextStatusMailbox->Fields.CommandIdentifier > 0)
5286 {
5287 DAC960_V2_CommandIdentifier_T CommandIdentifier =
5288 NextStatusMailbox->Fields.CommandIdentifier;
5289 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5290 Command->V2.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5291 Command->V2.RequestSenseLength =
5292 NextStatusMailbox->Fields.RequestSenseLength;
5293 Command->V2.DataTransferResidue =
5294 NextStatusMailbox->Fields.DataTransferResidue;
5295 NextStatusMailbox->Words[0] = 0;
5296 if (++NextStatusMailbox > Controller->V2.LastStatusMailbox)
5297 NextStatusMailbox = Controller->V2.FirstStatusMailbox;
5298 DAC960_V2_ProcessCompletedCommand(Command);
5299 }
5300 Controller->V2.NextStatusMailbox = NextStatusMailbox;
5301 /*
5302 Attempt to remove additional I/O Requests from the Controller's
5303 I/O Request Queue and queue them to the Controller.
5304 */
5305 DAC960_ProcessRequest(Controller);
5306 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5307 return IRQ_HANDLED;
5308}
5192 5309
5193/* 5310/*
5194 DAC960_BA_InterruptHandler handles hardware interrupts from DAC960 BA Series 5311 DAC960_BA_InterruptHandler handles hardware interrupts from DAC960 BA Series
@@ -6962,6 +7079,14 @@ static void DAC960_gam_cleanup(void)
6962 7079
6963#endif /* DAC960_GAM_MINOR */ 7080#endif /* DAC960_GAM_MINOR */
6964 7081
7082static struct DAC960_privdata DAC960_GEM_privdata = {
7083 .HardwareType = DAC960_GEM_Controller,
7084 .FirmwareType = DAC960_V2_Controller,
7085 .InterruptHandler = DAC960_GEM_InterruptHandler,
7086 .MemoryWindowSize = DAC960_GEM_RegisterWindowSize,
7087};
7088
7089
6965static struct DAC960_privdata DAC960_BA_privdata = { 7090static struct DAC960_privdata DAC960_BA_privdata = {
6966 .HardwareType = DAC960_BA_Controller, 7091 .HardwareType = DAC960_BA_Controller,
6967 .FirmwareType = DAC960_V2_Controller, 7092 .FirmwareType = DAC960_V2_Controller,
@@ -7007,6 +7132,13 @@ static struct DAC960_privdata DAC960_P_privdata = {
7007static struct pci_device_id DAC960_id_table[] = { 7132static struct pci_device_id DAC960_id_table[] = {
7008 { 7133 {
7009 .vendor = PCI_VENDOR_ID_MYLEX, 7134 .vendor = PCI_VENDOR_ID_MYLEX,
7135 .device = PCI_DEVICE_ID_MYLEX_DAC960_GEM,
7136 .subvendor = PCI_ANY_ID,
7137 .subdevice = PCI_ANY_ID,
7138 .driver_data = (unsigned long) &DAC960_GEM_privdata,
7139 },
7140 {
7141 .vendor = PCI_VENDOR_ID_MYLEX,
7010 .device = PCI_DEVICE_ID_MYLEX_DAC960_BA, 7142 .device = PCI_DEVICE_ID_MYLEX_DAC960_BA,
7011 .subvendor = PCI_ANY_ID, 7143 .subvendor = PCI_ANY_ID,
7012 .subdevice = PCI_ANY_ID, 7144 .subdevice = PCI_ANY_ID,
diff --git a/drivers/block/DAC960.h b/drivers/block/DAC960.h
index d5e8e7190c90..a82f37f749a5 100644
--- a/drivers/block/DAC960.h
+++ b/drivers/block/DAC960.h
@@ -2114,7 +2114,8 @@ typedef enum
2114 DAC960_LA_Controller = 3, /* DAC1164P */ 2114 DAC960_LA_Controller = 3, /* DAC1164P */
2115 DAC960_PG_Controller = 4, /* DAC960PTL/PJ/PG */ 2115 DAC960_PG_Controller = 4, /* DAC960PTL/PJ/PG */
2116 DAC960_PD_Controller = 5, /* DAC960PU/PD/PL/P */ 2116 DAC960_PD_Controller = 5, /* DAC960PU/PD/PL/P */
2117 DAC960_P_Controller = 6 /* DAC960PU/PD/PL/P */ 2117 DAC960_P_Controller = 6, /* DAC960PU/PD/PL/P */
2118 DAC960_GEM_Controller = 7, /* AcceleRAID 4/5/600 */
2118} 2119}
2119DAC960_HardwareType_T; 2120DAC960_HardwareType_T;
2120 2121
@@ -2541,6 +2542,320 @@ void dma_addr_writeql(dma_addr_t addr, void __iomem *write_address)
2541} 2542}
2542 2543
2543/* 2544/*
2545 Define the DAC960 GEM Series Controller Interface Register Offsets.
2546 */
2547
2548#define DAC960_GEM_RegisterWindowSize 0x600
2549
2550typedef enum
2551{
2552 DAC960_GEM_InboundDoorBellRegisterReadSetOffset = 0x214,
2553 DAC960_GEM_InboundDoorBellRegisterClearOffset = 0x218,
2554 DAC960_GEM_OutboundDoorBellRegisterReadSetOffset = 0x224,
2555 DAC960_GEM_OutboundDoorBellRegisterClearOffset = 0x228,
2556 DAC960_GEM_InterruptStatusRegisterOffset = 0x208,
2557 DAC960_GEM_InterruptMaskRegisterReadSetOffset = 0x22C,
2558 DAC960_GEM_InterruptMaskRegisterClearOffset = 0x230,
2559 DAC960_GEM_CommandMailboxBusAddressOffset = 0x510,
2560 DAC960_GEM_CommandStatusOffset = 0x518,
2561 DAC960_GEM_ErrorStatusRegisterReadSetOffset = 0x224,
2562 DAC960_GEM_ErrorStatusRegisterClearOffset = 0x228,
2563}
2564DAC960_GEM_RegisterOffsets_T;
2565
2566/*
2567 Define the structure of the DAC960 GEM Series Inbound Door Bell
2568 */
2569
2570typedef union DAC960_GEM_InboundDoorBellRegister
2571{
2572 unsigned int All;
2573 struct {
2574 unsigned int :24;
2575 boolean HardwareMailboxNewCommand:1;
2576 boolean AcknowledgeHardwareMailboxStatus:1;
2577 boolean GenerateInterrupt:1;
2578 boolean ControllerReset:1;
2579 boolean MemoryMailboxNewCommand:1;
2580 unsigned int :3;
2581 } Write;
2582 struct {
2583 unsigned int :24;
2584 boolean HardwareMailboxFull:1;
2585 boolean InitializationInProgress:1;
2586 unsigned int :6;
2587 } Read;
2588}
2589DAC960_GEM_InboundDoorBellRegister_T;
2590
2591/*
2592 Define the structure of the DAC960 GEM Series Outbound Door Bell Register.
2593 */
2594typedef union DAC960_GEM_OutboundDoorBellRegister
2595{
2596 unsigned int All;
2597 struct {
2598 unsigned int :24;
2599 boolean AcknowledgeHardwareMailboxInterrupt:1;
2600 boolean AcknowledgeMemoryMailboxInterrupt:1;
2601 unsigned int :6;
2602 } Write;
2603 struct {
2604 unsigned int :24;
2605 boolean HardwareMailboxStatusAvailable:1;
2606 boolean MemoryMailboxStatusAvailable:1;
2607 unsigned int :6;
2608 } Read;
2609}
2610DAC960_GEM_OutboundDoorBellRegister_T;
2611
2612/*
2613 Define the structure of the DAC960 GEM Series Interrupt Mask Register.
2614 */
2615typedef union DAC960_GEM_InterruptMaskRegister
2616{
2617 unsigned int All;
2618 struct {
2619 unsigned int :16;
2620 unsigned int :8;
2621 unsigned int HardwareMailboxInterrupt:1;
2622 unsigned int MemoryMailboxInterrupt:1;
2623 unsigned int :6;
2624 } Bits;
2625}
2626DAC960_GEM_InterruptMaskRegister_T;
2627
2628/*
2629 Define the structure of the DAC960 GEM Series Error Status Register.
2630 */
2631
2632typedef union DAC960_GEM_ErrorStatusRegister
2633{
2634 unsigned int All;
2635 struct {
2636 unsigned int :24;
2637 unsigned int :5;
2638 boolean ErrorStatusPending:1;
2639 unsigned int :2;
2640 } Bits;
2641}
2642DAC960_GEM_ErrorStatusRegister_T;
2643
2644/*
2645 Define inline functions to provide an abstraction for reading and writing the
2646 DAC960 GEM Series Controller Interface Registers.
2647*/
2648
2649static inline
2650void DAC960_GEM_HardwareMailboxNewCommand(void __iomem *ControllerBaseAddress)
2651{
2652 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2653 InboundDoorBellRegister.All = 0;
2654 InboundDoorBellRegister.Write.HardwareMailboxNewCommand = true;
2655 writel(InboundDoorBellRegister.All,
2656 ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
2657}
2658
2659static inline
2660void DAC960_GEM_AcknowledgeHardwareMailboxStatus(void __iomem *ControllerBaseAddress)
2661{
2662 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2663 InboundDoorBellRegister.All = 0;
2664 InboundDoorBellRegister.Write.AcknowledgeHardwareMailboxStatus = true;
2665 writel(InboundDoorBellRegister.All,
2666 ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterClearOffset);
2667}
2668
2669static inline
2670void DAC960_GEM_GenerateInterrupt(void __iomem *ControllerBaseAddress)
2671{
2672 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2673 InboundDoorBellRegister.All = 0;
2674 InboundDoorBellRegister.Write.GenerateInterrupt = true;
2675 writel(InboundDoorBellRegister.All,
2676 ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
2677}
2678
2679static inline
2680void DAC960_GEM_ControllerReset(void __iomem *ControllerBaseAddress)
2681{
2682 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2683 InboundDoorBellRegister.All = 0;
2684 InboundDoorBellRegister.Write.ControllerReset = true;
2685 writel(InboundDoorBellRegister.All,
2686 ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
2687}
2688
2689static inline
2690void DAC960_GEM_MemoryMailboxNewCommand(void __iomem *ControllerBaseAddress)
2691{
2692 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2693 InboundDoorBellRegister.All = 0;
2694 InboundDoorBellRegister.Write.MemoryMailboxNewCommand = true;
2695 writel(InboundDoorBellRegister.All,
2696 ControllerBaseAddress + DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
2697}
2698
2699static inline
2700boolean DAC960_GEM_HardwareMailboxFullP(void __iomem *ControllerBaseAddress)
2701{
2702 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2703 InboundDoorBellRegister.All =
2704 readl(ControllerBaseAddress +
2705 DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
2706 return InboundDoorBellRegister.Read.HardwareMailboxFull;
2707}
2708
2709static inline
2710boolean DAC960_GEM_InitializationInProgressP(void __iomem *ControllerBaseAddress)
2711{
2712 DAC960_GEM_InboundDoorBellRegister_T InboundDoorBellRegister;
2713 InboundDoorBellRegister.All =
2714 readl(ControllerBaseAddress +
2715 DAC960_GEM_InboundDoorBellRegisterReadSetOffset);
2716 return InboundDoorBellRegister.Read.InitializationInProgress;
2717}
2718
2719static inline
2720void DAC960_GEM_AcknowledgeHardwareMailboxInterrupt(void __iomem *ControllerBaseAddress)
2721{
2722 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
2723 OutboundDoorBellRegister.All = 0;
2724 OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
2725 writel(OutboundDoorBellRegister.All,
2726 ControllerBaseAddress + DAC960_GEM_OutboundDoorBellRegisterClearOffset);
2727}
2728
2729static inline
2730void DAC960_GEM_AcknowledgeMemoryMailboxInterrupt(void __iomem *ControllerBaseAddress)
2731{
2732 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
2733 OutboundDoorBellRegister.All = 0;
2734 OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
2735 writel(OutboundDoorBellRegister.All,
2736 ControllerBaseAddress + DAC960_GEM_OutboundDoorBellRegisterClearOffset);
2737}
2738
2739static inline
2740void DAC960_GEM_AcknowledgeInterrupt(void __iomem *ControllerBaseAddress)
2741{
2742 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
2743 OutboundDoorBellRegister.All = 0;
2744 OutboundDoorBellRegister.Write.AcknowledgeHardwareMailboxInterrupt = true;
2745 OutboundDoorBellRegister.Write.AcknowledgeMemoryMailboxInterrupt = true;
2746 writel(OutboundDoorBellRegister.All,
2747 ControllerBaseAddress + DAC960_GEM_OutboundDoorBellRegisterClearOffset);
2748}
2749
2750static inline
2751boolean DAC960_GEM_HardwareMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
2752{
2753 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
2754 OutboundDoorBellRegister.All =
2755 readl(ControllerBaseAddress +
2756 DAC960_GEM_OutboundDoorBellRegisterReadSetOffset);
2757 return OutboundDoorBellRegister.Read.HardwareMailboxStatusAvailable;
2758}
2759
2760static inline
2761boolean DAC960_GEM_MemoryMailboxStatusAvailableP(void __iomem *ControllerBaseAddress)
2762{
2763 DAC960_GEM_OutboundDoorBellRegister_T OutboundDoorBellRegister;
2764 OutboundDoorBellRegister.All =
2765 readl(ControllerBaseAddress +
2766 DAC960_GEM_OutboundDoorBellRegisterReadSetOffset);
2767 return OutboundDoorBellRegister.Read.MemoryMailboxStatusAvailable;
2768}
2769
2770static inline
2771void DAC960_GEM_EnableInterrupts(void __iomem *ControllerBaseAddress)
2772{
2773 DAC960_GEM_InterruptMaskRegister_T InterruptMaskRegister;
2774 InterruptMaskRegister.All = 0;
2775 InterruptMaskRegister.Bits.HardwareMailboxInterrupt = true;
2776 InterruptMaskRegister.Bits.MemoryMailboxInterrupt = true;
2777 writel(InterruptMaskRegister.All,
2778 ControllerBaseAddress + DAC960_GEM_InterruptMaskRegisterClearOffset);
2779}
2780
2781static inline
2782void DAC960_GEM_DisableInterrupts(void __iomem *ControllerBaseAddress)
2783{
2784 DAC960_GEM_InterruptMaskRegister_T InterruptMaskRegister;
2785 InterruptMaskRegister.All = 0;
2786 InterruptMaskRegister.Bits.HardwareMailboxInterrupt = true;
2787 InterruptMaskRegister.Bits.MemoryMailboxInterrupt = true;
2788 writel(InterruptMaskRegister.All,
2789 ControllerBaseAddress + DAC960_GEM_InterruptMaskRegisterReadSetOffset);
2790}
2791
2792static inline
2793boolean DAC960_GEM_InterruptsEnabledP(void __iomem *ControllerBaseAddress)
2794{
2795 DAC960_GEM_InterruptMaskRegister_T InterruptMaskRegister;
2796 InterruptMaskRegister.All =
2797 readl(ControllerBaseAddress +
2798 DAC960_GEM_InterruptMaskRegisterReadSetOffset);
2799 return !(InterruptMaskRegister.Bits.HardwareMailboxInterrupt ||
2800 InterruptMaskRegister.Bits.MemoryMailboxInterrupt);
2801}
2802
2803static inline
2804void DAC960_GEM_WriteCommandMailbox(DAC960_V2_CommandMailbox_T
2805 *MemoryCommandMailbox,
2806 DAC960_V2_CommandMailbox_T
2807 *CommandMailbox)
2808{
2809 memcpy(&MemoryCommandMailbox->Words[1], &CommandMailbox->Words[1],
2810 sizeof(DAC960_V2_CommandMailbox_T) - sizeof(unsigned int));
2811 wmb();
2812 MemoryCommandMailbox->Words[0] = CommandMailbox->Words[0];
2813 mb();
2814}
2815
2816static inline
2817void DAC960_GEM_WriteHardwareMailbox(void __iomem *ControllerBaseAddress,
2818 dma_addr_t CommandMailboxDMA)
2819{
2820 dma_addr_writeql(CommandMailboxDMA,
2821 ControllerBaseAddress +
2822 DAC960_GEM_CommandMailboxBusAddressOffset);
2823}
2824
2825static inline DAC960_V2_CommandIdentifier_T
2826DAC960_GEM_ReadCommandIdentifier(void __iomem *ControllerBaseAddress)
2827{
2828 return readw(ControllerBaseAddress + DAC960_GEM_CommandStatusOffset);
2829}
2830
2831static inline DAC960_V2_CommandStatus_T
2832DAC960_GEM_ReadCommandStatus(void __iomem *ControllerBaseAddress)
2833{
2834 return readw(ControllerBaseAddress + DAC960_GEM_CommandStatusOffset + 2);
2835}
2836
2837static inline boolean
2838DAC960_GEM_ReadErrorStatus(void __iomem *ControllerBaseAddress,
2839 unsigned char *ErrorStatus,
2840 unsigned char *Parameter0,
2841 unsigned char *Parameter1)
2842{
2843 DAC960_GEM_ErrorStatusRegister_T ErrorStatusRegister;
2844 ErrorStatusRegister.All =
2845 readl(ControllerBaseAddress + DAC960_GEM_ErrorStatusRegisterReadSetOffset);
2846 if (!ErrorStatusRegister.Bits.ErrorStatusPending) return false;
2847 ErrorStatusRegister.Bits.ErrorStatusPending = false;
2848 *ErrorStatus = ErrorStatusRegister.All;
2849 *Parameter0 =
2850 readb(ControllerBaseAddress + DAC960_GEM_CommandMailboxBusAddressOffset + 0);
2851 *Parameter1 =
2852 readb(ControllerBaseAddress + DAC960_GEM_CommandMailboxBusAddressOffset + 1);
2853 writel(0x03000000, ControllerBaseAddress +
2854 DAC960_GEM_ErrorStatusRegisterClearOffset);
2855 return true;
2856}
2857
2858/*
2544 Define the DAC960 BA Series Controller Interface Register Offsets. 2859 Define the DAC960 BA Series Controller Interface Register Offsets.
2545*/ 2860*/
2546 2861
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index e830be1a3ae6..b594768b0241 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -6,7 +6,7 @@ menu "Block devices"
6 6
7config BLK_DEV_FD 7config BLK_DEV_FD
8 tristate "Normal floppy disk support" 8 tristate "Normal floppy disk support"
9 depends on (!ARCH_S390 && !M68K && !IA64 && !UML) || Q40 || (SUN3X && BROKEN) || ARCH_RPC || ARCH_EBSA285 9 depends on (!ARCH_S390 && !M68K && !IA64 && !UML && !ARM) || Q40 || (SUN3X && BROKEN) || ARCH_RPC || ARCH_EBSA285
10 ---help--- 10 ---help---
11 If you want to use the floppy disk drive(s) of your PC under Linux, 11 If you want to use the floppy disk drive(s) of your PC under Linux,
12 say Y. Information about this driver, especially important for IBM 12 say Y. Information about this driver, especially important for IBM
@@ -105,7 +105,7 @@ config ATARI_SLM
105 105
106config BLK_DEV_XD 106config BLK_DEV_XD
107 tristate "XT hard disk support" 107 tristate "XT hard disk support"
108 depends on ISA 108 depends on ISA && ISA_DMA_API
109 help 109 help
110 Very old 8 bit hard disk controllers used in the IBM XT computer 110 Very old 8 bit hard disk controllers used in the IBM XT computer
111 will be supported if you say Y here. 111 will be supported if you say Y here.
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index aa8b547ffafa..721ba8086043 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) 2004 Coraid, Inc. See COPYING for GPL terms. */
2#define VERSION "6" 2#define VERSION "10"
3#define AOE_MAJOR 152 3#define AOE_MAJOR 152
4#define DEVICE_NAME "aoe" 4#define DEVICE_NAME "aoe"
5 5
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 4780f7926d42..0e97fcb9f3a1 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -37,6 +37,13 @@ static ssize_t aoedisk_show_netif(struct gendisk * disk, char *page)
37 37
38 return snprintf(page, PAGE_SIZE, "%s\n", d->ifp->name); 38 return snprintf(page, PAGE_SIZE, "%s\n", d->ifp->name);
39} 39}
40/* firmware version */
41static ssize_t aoedisk_show_fwver(struct gendisk * disk, char *page)
42{
43 struct aoedev *d = disk->private_data;
44
45 return snprintf(page, PAGE_SIZE, "0x%04x\n", (unsigned int) d->fw_ver);
46}
40 47
41static struct disk_attribute disk_attr_state = { 48static struct disk_attribute disk_attr_state = {
42 .attr = {.name = "state", .mode = S_IRUGO }, 49 .attr = {.name = "state", .mode = S_IRUGO },
@@ -50,6 +57,10 @@ static struct disk_attribute disk_attr_netif = {
50 .attr = {.name = "netif", .mode = S_IRUGO }, 57 .attr = {.name = "netif", .mode = S_IRUGO },
51 .show = aoedisk_show_netif 58 .show = aoedisk_show_netif
52}; 59};
60static struct disk_attribute disk_attr_fwver = {
61 .attr = {.name = "firmware-version", .mode = S_IRUGO },
62 .show = aoedisk_show_fwver
63};
53 64
54static void 65static void
55aoedisk_add_sysfs(struct aoedev *d) 66aoedisk_add_sysfs(struct aoedev *d)
@@ -57,6 +68,7 @@ aoedisk_add_sysfs(struct aoedev *d)
57 sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr); 68 sysfs_create_file(&d->gd->kobj, &disk_attr_state.attr);
58 sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr); 69 sysfs_create_file(&d->gd->kobj, &disk_attr_mac.attr);
59 sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr); 70 sysfs_create_file(&d->gd->kobj, &disk_attr_netif.attr);
71 sysfs_create_file(&d->gd->kobj, &disk_attr_fwver.attr);
60} 72}
61void 73void
62aoedisk_rm_sysfs(struct aoedev *d) 74aoedisk_rm_sysfs(struct aoedev *d)
@@ -64,6 +76,7 @@ aoedisk_rm_sysfs(struct aoedev *d)
64 sysfs_remove_link(&d->gd->kobj, "state"); 76 sysfs_remove_link(&d->gd->kobj, "state");
65 sysfs_remove_link(&d->gd->kobj, "mac"); 77 sysfs_remove_link(&d->gd->kobj, "mac");
66 sysfs_remove_link(&d->gd->kobj, "netif"); 78 sysfs_remove_link(&d->gd->kobj, "netif");
79 sysfs_remove_link(&d->gd->kobj, "firmware-version");
67} 80}
68 81
69static int 82static int
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index ec16c64dd114..6e231c5a1199 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -109,25 +109,22 @@ aoedev_set(ulong sysminor, unsigned char *addr, struct net_device *ifp, ulong bu
109 spin_lock_irqsave(&devlist_lock, flags); 109 spin_lock_irqsave(&devlist_lock, flags);
110 110
111 for (d=devlist; d; d=d->next) 111 for (d=devlist; d; d=d->next)
112 if (d->sysminor == sysminor 112 if (d->sysminor == sysminor)
113 || memcmp(d->addr, addr, sizeof d->addr) == 0)
114 break; 113 break;
115 114
116 if (d == NULL && (d = aoedev_newdev(bufcnt)) == NULL) { 115 if (d == NULL && (d = aoedev_newdev(bufcnt)) == NULL) {
117 spin_unlock_irqrestore(&devlist_lock, flags); 116 spin_unlock_irqrestore(&devlist_lock, flags);
118 printk(KERN_INFO "aoe: aoedev_set: aoedev_newdev failure.\n"); 117 printk(KERN_INFO "aoe: aoedev_set: aoedev_newdev failure.\n");
119 return NULL; 118 return NULL;
120 } 119 } /* if newdev, (d->flags & DEVFL_UP) == 0 for below */
121 120
122 spin_unlock_irqrestore(&devlist_lock, flags); 121 spin_unlock_irqrestore(&devlist_lock, flags);
123 spin_lock_irqsave(&d->lock, flags); 122 spin_lock_irqsave(&d->lock, flags);
124 123
125 d->ifp = ifp; 124 d->ifp = ifp;
126 125 memcpy(d->addr, addr, sizeof d->addr);
127 if (d->sysminor != sysminor 126 if ((d->flags & DEVFL_UP) == 0) {
128 || (d->flags & DEVFL_UP) == 0) {
129 aoedev_downdev(d); /* flushes outstanding frames */ 127 aoedev_downdev(d); /* flushes outstanding frames */
130 memcpy(d->addr, addr, sizeof d->addr);
131 d->sysminor = sysminor; 128 d->sysminor = sysminor;
132 d->aoemajor = AOEMAJOR(sysminor); 129 d->aoemajor = AOEMAJOR(sysminor);
133 d->aoeminor = AOEMINOR(sysminor); 130 d->aoeminor = AOEMINOR(sysminor);
diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index bc92aacb6dad..9e6f51c528b0 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -7,6 +7,7 @@
7#include <linux/hdreg.h> 7#include <linux/hdreg.h>
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <linux/netdevice.h> 9#include <linux/netdevice.h>
10#include <linux/moduleparam.h>
10#include "aoe.h" 11#include "aoe.h"
11 12
12#define NECODES 5 13#define NECODES 5
@@ -26,6 +27,19 @@ enum {
26}; 27};
27 28
28static char aoe_iflist[IFLISTSZ]; 29static char aoe_iflist[IFLISTSZ];
30module_param_string(aoe_iflist, aoe_iflist, IFLISTSZ, 0600);
31MODULE_PARM_DESC(aoe_iflist, "aoe_iflist=\"dev1 [dev2 ...]\"\n");
32
33#ifndef MODULE
34static int __init aoe_iflist_setup(char *str)
35{
36 strncpy(aoe_iflist, str, IFLISTSZ);
37 aoe_iflist[IFLISTSZ - 1] = '\0';
38 return 1;
39}
40
41__setup("aoe_iflist=", aoe_iflist_setup);
42#endif
29 43
30int 44int
31is_aoe_netif(struct net_device *ifp) 45is_aoe_netif(struct net_device *ifp)
@@ -36,7 +50,8 @@ is_aoe_netif(struct net_device *ifp)
36 if (aoe_iflist[0] == '\0') 50 if (aoe_iflist[0] == '\0')
37 return 1; 51 return 1;
38 52
39 for (p = aoe_iflist; *p; p = q + strspn(q, WHITESPACE)) { 53 p = aoe_iflist + strspn(aoe_iflist, WHITESPACE);
54 for (; *p; p = q + strspn(q, WHITESPACE)) {
40 q = p + strcspn(p, WHITESPACE); 55 q = p + strcspn(p, WHITESPACE);
41 if (q != p) 56 if (q != p)
42 len = q - p; 57 len = q - p;
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 42dfa281a880..f0c1084b840f 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3345,7 +3345,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
3345 struct block_device *bdev = opened_bdev[cnt]; 3345 struct block_device *bdev = opened_bdev[cnt];
3346 if (!bdev || ITYPE(drive_state[cnt].fd_device) != type) 3346 if (!bdev || ITYPE(drive_state[cnt].fd_device) != type)
3347 continue; 3347 continue;
3348 __invalidate_device(bdev, 0); 3348 __invalidate_device(bdev);
3349 } 3349 }
3350 up(&open_lock); 3350 up(&open_lock);
3351 } else { 3351 } else {
diff --git a/drivers/block/genhd.c b/drivers/block/genhd.c
index ab4db71375e0..8bbe01d4b487 100644
--- a/drivers/block/genhd.c
+++ b/drivers/block/genhd.c
@@ -14,6 +14,7 @@
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/kmod.h> 15#include <linux/kmod.h>
16#include <linux/kobj_map.h> 16#include <linux/kobj_map.h>
17#include <linux/buffer_head.h>
17 18
18#define MAX_PROBE_HASH 255 /* random */ 19#define MAX_PROBE_HASH 255 /* random */
19 20
@@ -676,7 +677,8 @@ int invalidate_partition(struct gendisk *disk, int index)
676 int res = 0; 677 int res = 0;
677 struct block_device *bdev = bdget_disk(disk, index); 678 struct block_device *bdev = bdget_disk(disk, index);
678 if (bdev) { 679 if (bdev) {
679 res = __invalidate_device(bdev, 1); 680 fsync_bdev(bdev);
681 res = __invalidate_device(bdev);
680 bdput(bdev); 682 bdput(bdev);
681 } 683 }
682 return res; 684 return res;
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index efdf04450bf7..9e268ddedfbd 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -78,6 +78,7 @@
78#define DBG_RX 0x0200 78#define DBG_RX 0x0200
79#define DBG_TX 0x0400 79#define DBG_TX 0x0400
80static unsigned int debugflags; 80static unsigned int debugflags;
81static unsigned int nbds_max = 16;
81#endif /* NDEBUG */ 82#endif /* NDEBUG */
82 83
83static struct nbd_device nbd_dev[MAX_NBD]; 84static struct nbd_device nbd_dev[MAX_NBD];
@@ -647,7 +648,13 @@ static int __init nbd_init(void)
647 return -EIO; 648 return -EIO;
648 } 649 }
649 650
650 for (i = 0; i < MAX_NBD; i++) { 651 if (nbds_max > MAX_NBD) {
652 printk(KERN_CRIT "nbd: cannot allocate more than %u nbds; %u requested.\n", MAX_NBD,
653 nbds_max);
654 return -EINVAL;
655 }
656
657 for (i = 0; i < nbds_max; i++) {
651 struct gendisk *disk = alloc_disk(1); 658 struct gendisk *disk = alloc_disk(1);
652 if (!disk) 659 if (!disk)
653 goto out; 660 goto out;
@@ -673,7 +680,7 @@ static int __init nbd_init(void)
673 dprintk(DBG_INIT, "nbd: debugflags=0x%x\n", debugflags); 680 dprintk(DBG_INIT, "nbd: debugflags=0x%x\n", debugflags);
674 681
675 devfs_mk_dir("nbd"); 682 devfs_mk_dir("nbd");
676 for (i = 0; i < MAX_NBD; i++) { 683 for (i = 0; i < nbds_max; i++) {
677 struct gendisk *disk = nbd_dev[i].disk; 684 struct gendisk *disk = nbd_dev[i].disk;
678 nbd_dev[i].file = NULL; 685 nbd_dev[i].file = NULL;
679 nbd_dev[i].magic = LO_MAGIC; 686 nbd_dev[i].magic = LO_MAGIC;
@@ -706,8 +713,9 @@ out:
706static void __exit nbd_cleanup(void) 713static void __exit nbd_cleanup(void)
707{ 714{
708 int i; 715 int i;
709 for (i = 0; i < MAX_NBD; i++) { 716 for (i = 0; i < nbds_max; i++) {
710 struct gendisk *disk = nbd_dev[i].disk; 717 struct gendisk *disk = nbd_dev[i].disk;
718 nbd_dev[i].magic = 0;
711 if (disk) { 719 if (disk) {
712 del_gendisk(disk); 720 del_gendisk(disk);
713 blk_cleanup_queue(disk->queue); 721 blk_cleanup_queue(disk->queue);
@@ -725,6 +733,8 @@ module_exit(nbd_cleanup);
725MODULE_DESCRIPTION("Network Block Device"); 733MODULE_DESCRIPTION("Network Block Device");
726MODULE_LICENSE("GPL"); 734MODULE_LICENSE("GPL");
727 735
736module_param(nbds_max, int, 0444);
737MODULE_PARM_DESC(nbds_max, "How many network block devices to initialize.");
728#ifndef NDEBUG 738#ifndef NDEBUG
729module_param(debugflags, int, 0644); 739module_param(debugflags, int, 0644);
730MODULE_PARM_DESC(debugflags, "flags for controlling debug output"); 740MODULE_PARM_DESC(debugflags, "flags for controlling debug output");
diff --git a/drivers/block/noop-iosched.c b/drivers/block/noop-iosched.c
index 888c477e02b3..b1730b62c37e 100644
--- a/drivers/block/noop-iosched.c
+++ b/drivers/block/noop-iosched.c
@@ -13,34 +13,13 @@
13static int elevator_noop_merge(request_queue_t *q, struct request **req, 13static int elevator_noop_merge(request_queue_t *q, struct request **req,
14 struct bio *bio) 14 struct bio *bio)
15{ 15{
16 struct list_head *entry = &q->queue_head;
17 struct request *__rq;
18 int ret; 16 int ret;
19 17
20 if ((ret = elv_try_last_merge(q, bio))) { 18 ret = elv_try_last_merge(q, bio);
19 if (ret != ELEVATOR_NO_MERGE)
21 *req = q->last_merge; 20 *req = q->last_merge;
22 return ret;
23 }
24 21
25 while ((entry = entry->prev) != &q->queue_head) { 22 return ret;
26 __rq = list_entry_rq(entry);
27
28 if (__rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER))
29 break;
30 else if (__rq->flags & REQ_STARTED)
31 break;
32
33 if (!blk_fs_request(__rq))
34 continue;
35
36 if ((ret = elv_try_merge(__rq, bio))) {
37 *req = __rq;
38 q->last_merge = __rq;
39 return ret;
40 }
41 }
42
43 return ELEVATOR_NO_MERGE;
44} 23}
45 24
46static void elevator_noop_merge_requests(request_queue_t *q, struct request *req, 25static void elevator_noop_merge_requests(request_queue_t *q, struct request *req,
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 9deca49c71f0..beaa561f2ed8 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -645,7 +645,7 @@ static int cdrom_mrw_exit(struct cdrom_device_info *cdi)
645 ret = cdrom_mrw_bgformat_susp(cdi, 0); 645 ret = cdrom_mrw_bgformat_susp(cdi, 0);
646 } 646 }
647 647
648 if (!ret) 648 if (!ret && cdi->media_written)
649 ret = cdrom_flush_cache(cdi); 649 ret = cdrom_flush_cache(cdi);
650 650
651 return ret; 651 return ret;
diff --git a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c
index 647a71b12a2a..ac96de15d833 100644
--- a/drivers/cdrom/cdu31a.c
+++ b/drivers/cdrom/cdu31a.c
@@ -292,7 +292,7 @@ module_param(cdu31a_irq, int, 0);
292 292
293/* The interrupt handler will wake this queue up when it gets an 293/* The interrupt handler will wake this queue up when it gets an
294 interrupts. */ 294 interrupts. */
295DECLARE_WAIT_QUEUE_HEAD(cdu31a_irq_wait); 295static DECLARE_WAIT_QUEUE_HEAD(cdu31a_irq_wait);
296static int irq_flag = 0; 296static int irq_flag = 0;
297 297
298static int curr_control_reg = 0; /* Current value of the control register */ 298static int curr_control_reg = 0; /* Current value of the control register */
@@ -2947,7 +2947,7 @@ static int scd_block_media_changed(struct gendisk *disk)
2947 return cdrom_media_changed(&scd_info); 2947 return cdrom_media_changed(&scd_info);
2948} 2948}
2949 2949
2950struct block_device_operations scd_bdops = 2950static struct block_device_operations scd_bdops =
2951{ 2951{
2952 .owner = THIS_MODULE, 2952 .owner = THIS_MODULE,
2953 .open = scd_block_open, 2953 .open = scd_block_open,
@@ -3216,7 +3216,7 @@ errout3:
3216} 3216}
3217 3217
3218 3218
3219void __exit cdu31a_exit(void) 3219static void __exit cdu31a_exit(void)
3220{ 3220{
3221 del_gendisk(scd_gendisk); 3221 del_gendisk(scd_gendisk);
3222 put_disk(scd_gendisk); 3222 put_disk(scd_gendisk);
diff --git a/drivers/cdrom/mcdx.c b/drivers/cdrom/mcdx.c
index ccde7ab491d4..07bbd24e3c18 100644
--- a/drivers/cdrom/mcdx.c
+++ b/drivers/cdrom/mcdx.c
@@ -107,20 +107,20 @@ static const char *mcdx_c_version
107 The _direct_ size is the number of sectors we're allowed to skip 107 The _direct_ size is the number of sectors we're allowed to skip
108 directly (performing a read instead of requesting the new sector 108 directly (performing a read instead of requesting the new sector
109 needed */ 109 needed */
110const int REQUEST_SIZE = 800; /* should be less then 255 * 4 */ 110static const int REQUEST_SIZE = 800; /* should be less then 255 * 4 */
111const int DIRECT_SIZE = 400; /* should be less then REQUEST_SIZE */ 111static const int DIRECT_SIZE = 400; /* should be less then REQUEST_SIZE */
112 112
113enum drivemodes { TOC, DATA, RAW, COOKED }; 113enum drivemodes { TOC, DATA, RAW, COOKED };
114enum datamodes { MODE0, MODE1, MODE2 }; 114enum datamodes { MODE0, MODE1, MODE2 };
115enum resetmodes { SOFT, HARD }; 115enum resetmodes { SOFT, HARD };
116 116
117const int SINGLE = 0x01; /* single speed drive (FX001S, LU) */ 117static const int SINGLE = 0x01; /* single speed drive (FX001S, LU) */
118const int DOUBLE = 0x02; /* double speed drive (FX001D, ..? */ 118static const int DOUBLE = 0x02; /* double speed drive (FX001D, ..? */
119const int DOOR = 0x04; /* door locking capability */ 119static const int DOOR = 0x04; /* door locking capability */
120const int MULTI = 0x08; /* multi session capability */ 120static const int MULTI = 0x08; /* multi session capability */
121 121
122const unsigned char READ1X = 0xc0; 122static const unsigned char READ1X = 0xc0;
123const unsigned char READ2X = 0xc1; 123static const unsigned char READ2X = 0xc1;
124 124
125 125
126/* DECLARATIONS ****************************************************/ 126/* DECLARATIONS ****************************************************/
@@ -210,9 +210,7 @@ struct s_drive_stuff {
210 repeated here to show what's going on. And to sense, if they're 210 repeated here to show what's going on. And to sense, if they're
211 changed elsewhere. */ 211 changed elsewhere. */
212 212
213/* declared in blk.h */ 213static int mcdx_init(void);
214int mcdx_init(void);
215void do_mcdx_request(request_queue_t * q);
216 214
217static int mcdx_block_open(struct inode *inode, struct file *file) 215static int mcdx_block_open(struct inode *inode, struct file *file)
218{ 216{
@@ -569,7 +567,7 @@ static int mcdx_audio_ioctl(struct cdrom_device_info *cdi,
569 } 567 }
570} 568}
571 569
572void do_mcdx_request(request_queue_t * q) 570static void do_mcdx_request(request_queue_t * q)
573{ 571{
574 struct s_drive_stuff *stuffp; 572 struct s_drive_stuff *stuffp;
575 struct request *req; 573 struct request *req;
@@ -1028,7 +1026,7 @@ int __mcdx_init(void)
1028 return 0; 1026 return 0;
1029} 1027}
1030 1028
1031void __exit mcdx_exit(void) 1029static void __exit mcdx_exit(void)
1032{ 1030{
1033 int i; 1031 int i;
1034 1032
@@ -1075,7 +1073,7 @@ module_exit(mcdx_exit);
1075 1073
1076/* Support functions ************************************************/ 1074/* Support functions ************************************************/
1077 1075
1078int __init mcdx_init_drive(int drive) 1076static int __init mcdx_init_drive(int drive)
1079{ 1077{
1080 struct s_version version; 1078 struct s_version version;
1081 struct gendisk *disk; 1079 struct gendisk *disk;
@@ -1261,7 +1259,7 @@ int __init mcdx_init_drive(int drive)
1261 return 0; 1259 return 0;
1262} 1260}
1263 1261
1264int __init mcdx_init(void) 1262static int __init mcdx_init(void)
1265{ 1263{
1266 int drive; 1264 int drive;
1267 xwarn("Version 2.14(hs) \n"); 1265 xwarn("Version 2.14(hs) \n");
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
index fc2c433f6a29..452d34675159 100644
--- a/drivers/cdrom/sbpcd.c
+++ b/drivers/cdrom/sbpcd.c
@@ -5895,7 +5895,7 @@ int __init sbpcd_init(void)
5895} 5895}
5896/*==========================================================================*/ 5896/*==========================================================================*/
5897#ifdef MODULE 5897#ifdef MODULE
5898void sbpcd_exit(void) 5898static void sbpcd_exit(void)
5899{ 5899{
5900 int j; 5900 int j;
5901 5901
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 096a1202ea07..5ed6515ae01f 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -153,7 +153,7 @@ config DIGIEPCA
153 153
154config ESPSERIAL 154config ESPSERIAL
155 tristate "Hayes ESP serial port support" 155 tristate "Hayes ESP serial port support"
156 depends on SERIAL_NONSTANDARD && ISA && BROKEN_ON_SMP 156 depends on SERIAL_NONSTANDARD && ISA && BROKEN_ON_SMP && ISA_DMA_API
157 help 157 help
158 This is a driver which supports Hayes ESP serial ports. Both single 158 This is a driver which supports Hayes ESP serial ports. Both single
159 port cards and multiport cards are supported. Make sure to read 159 port cards and multiport cards are supported. Make sure to read
@@ -195,7 +195,7 @@ config ISI
195 195
196config SYNCLINK 196config SYNCLINK
197 tristate "Microgate SyncLink card support" 197 tristate "Microgate SyncLink card support"
198 depends on SERIAL_NONSTANDARD && PCI 198 depends on SERIAL_NONSTANDARD && PCI && ISA_DMA_API
199 help 199 help
200 Provides support for the SyncLink ISA and PCI multiprotocol serial 200 Provides support for the SyncLink ISA and PCI multiprotocol serial
201 adapters. These adapters support asynchronous and HDLC bit 201 adapters. These adapters support asynchronous and HDLC bit
@@ -399,6 +399,20 @@ config SGI_SNSC
399 controller communication from user space (you want this!), 399 controller communication from user space (you want this!),
400 say Y. Otherwise, say N. 400 say Y. Otherwise, say N.
401 401
402config SGI_TIOCX
403 bool "SGI TIO CX driver support"
404 depends on (IA64_SGI_SN2 || IA64_GENERIC)
405 help
406 If you have an SGI Altix and you have fpga devices attached
407 to your TIO, say Y here, otherwise say N.
408
409config SGI_MBCS
410 tristate "SGI FPGA Core Services driver support"
411 depends on SGI_TIOCX
412 help
413 If you have an SGI Altix with an attached SABrick
414 say Y or M here, otherwise say N.
415
402source "drivers/serial/Kconfig" 416source "drivers/serial/Kconfig"
403 417
404config UNIX98_PTYS 418config UNIX98_PTYS
@@ -968,7 +982,7 @@ config MAX_RAW_DEVS
968 982
969config HANGCHECK_TIMER 983config HANGCHECK_TIMER
970 tristate "Hangcheck timer" 984 tristate "Hangcheck timer"
971 depends on X86_64 || X86 985 depends on X86_64 || X86 || IA64 || PPC64 || ARCH_S390
972 help 986 help
973 The hangcheck-timer module detects when the system has gone 987 The hangcheck-timer module detects when the system has gone
974 out to lunch past a certain margin. It can reboot the system 988 out to lunch past a certain margin. It can reboot the system
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 54ed76af1a47..e3f5c32aac55 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -42,11 +42,12 @@ obj-$(CONFIG_SX) += sx.o generic_serial.o
42obj-$(CONFIG_RIO) += rio/ generic_serial.o 42obj-$(CONFIG_RIO) += rio/ generic_serial.o
43obj-$(CONFIG_HVC_CONSOLE) += hvc_console.o hvsi.o 43obj-$(CONFIG_HVC_CONSOLE) += hvc_console.o hvsi.o
44obj-$(CONFIG_RAW_DRIVER) += raw.o 44obj-$(CONFIG_RAW_DRIVER) += raw.o
45obj-$(CONFIG_SGI_SNSC) += snsc.o 45obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
46obj-$(CONFIG_MMTIMER) += mmtimer.o 46obj-$(CONFIG_MMTIMER) += mmtimer.o
47obj-$(CONFIG_VIOCONS) += viocons.o 47obj-$(CONFIG_VIOCONS) += viocons.o
48obj-$(CONFIG_VIOTAPE) += viotape.o 48obj-$(CONFIG_VIOTAPE) += viotape.o
49obj-$(CONFIG_HVCS) += hvcs.o 49obj-$(CONFIG_HVCS) += hvcs.o
50obj-$(CONFIG_SGI_MBCS) += mbcs.o
50 51
51obj-$(CONFIG_PRINTER) += lp.o 52obj-$(CONFIG_PRINTER) += lp.o
52obj-$(CONFIG_TIPAR) += tipar.o 53obj-$(CONFIG_TIPAR) += tipar.o
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index c86a22c5499b..0212febda654 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -192,7 +192,7 @@ static struct aper_size_info_32 ali_generic_sizes[7] =
192 {4, 1024, 0, 3} 192 {4, 1024, 0, 3}
193}; 193};
194 194
195struct agp_bridge_driver ali_generic_bridge = { 195static struct agp_bridge_driver ali_generic_bridge = {
196 .owner = THIS_MODULE, 196 .owner = THIS_MODULE,
197 .aperture_sizes = ali_generic_sizes, 197 .aperture_sizes = ali_generic_sizes,
198 .size_type = U32_APER_SIZE, 198 .size_type = U32_APER_SIZE,
@@ -215,7 +215,7 @@ struct agp_bridge_driver ali_generic_bridge = {
215 .agp_destroy_page = ali_destroy_page, 215 .agp_destroy_page = ali_destroy_page,
216}; 216};
217 217
218struct agp_bridge_driver ali_m1541_bridge = { 218static struct agp_bridge_driver ali_m1541_bridge = {
219 .owner = THIS_MODULE, 219 .owner = THIS_MODULE,
220 .aperture_sizes = ali_generic_sizes, 220 .aperture_sizes = ali_generic_sizes,
221 .size_type = U32_APER_SIZE, 221 .size_type = U32_APER_SIZE,
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index f1ea87ea6b65..e62a3c2c44a9 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -358,7 +358,7 @@ static struct gatt_mask amd_irongate_masks[] =
358 {.mask = 1, .type = 0} 358 {.mask = 1, .type = 0}
359}; 359};
360 360
361struct agp_bridge_driver amd_irongate_driver = { 361static struct agp_bridge_driver amd_irongate_driver = {
362 .owner = THIS_MODULE, 362 .owner = THIS_MODULE,
363 .aperture_sizes = amd_irongate_sizes, 363 .aperture_sizes = amd_irongate_sizes,
364 .size_type = LVL2_APER_SIZE, 364 .size_type = LVL2_APER_SIZE,
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 905f0629c44f..399c042f68f0 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -243,7 +243,7 @@ static void amd64_cleanup(void)
243} 243}
244 244
245 245
246struct agp_bridge_driver amd_8151_driver = { 246static struct agp_bridge_driver amd_8151_driver = {
247 .owner = THIS_MODULE, 247 .owner = THIS_MODULE,
248 .aperture_sizes = amd_8151_sizes, 248 .aperture_sizes = amd_8151_sizes,
249 .size_type = U32_APER_SIZE, 249 .size_type = U32_APER_SIZE,
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 757dde006fc9..a65f8827c283 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -393,7 +393,7 @@ static int ati_free_gatt_table(struct agp_bridge_data *bridge)
393 return 0; 393 return 0;
394} 394}
395 395
396struct agp_bridge_driver ati_generic_bridge = { 396static struct agp_bridge_driver ati_generic_bridge = {
397 .owner = THIS_MODULE, 397 .owner = THIS_MODULE,
398 .aperture_sizes = ati_generic_sizes, 398 .aperture_sizes = ati_generic_sizes,
399 .size_type = LVL2_APER_SIZE, 399 .size_type = LVL2_APER_SIZE,
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index c3442f3c6480..2f3dfb63bdc6 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -97,7 +97,7 @@ void agp_backend_release(struct agp_bridge_data *bridge)
97EXPORT_SYMBOL(agp_backend_release); 97EXPORT_SYMBOL(agp_backend_release);
98 98
99 99
100struct { int mem, agp; } maxes_table[] = { 100static struct { int mem, agp; } maxes_table[] = {
101 {0, 0}, 101 {0, 0},
102 {32, 4}, 102 {32, 4},
103 {64, 28}, 103 {64, 28},
@@ -322,7 +322,7 @@ static int __init agp_init(void)
322 return 0; 322 return 0;
323} 323}
324 324
325void __exit agp_exit(void) 325static void __exit agp_exit(void)
326{ 326{
327} 327}
328 328
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index 2a87cecdc912..1383c3165ea1 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -303,7 +303,7 @@ static int efficeon_remove_memory(struct agp_memory * mem, off_t pg_start, int t
303} 303}
304 304
305 305
306struct agp_bridge_driver efficeon_driver = { 306static struct agp_bridge_driver efficeon_driver = {
307 .owner = THIS_MODULE, 307 .owner = THIS_MODULE,
308 .aperture_sizes = efficeon_generic_sizes, 308 .aperture_sizes = efficeon_generic_sizes,
309 .size_type = LVL2_APER_SIZE, 309 .size_type = LVL2_APER_SIZE,
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index f633623ac802..3dfb6648547b 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -235,7 +235,7 @@ static void agp_insert_into_pool(struct agp_memory * temp)
235 235
236/* File private list routines */ 236/* File private list routines */
237 237
238struct agp_file_private *agp_find_private(pid_t pid) 238static struct agp_file_private *agp_find_private(pid_t pid)
239{ 239{
240 struct agp_file_private *curr; 240 struct agp_file_private *curr;
241 241
@@ -250,7 +250,7 @@ struct agp_file_private *agp_find_private(pid_t pid)
250 return NULL; 250 return NULL;
251} 251}
252 252
253void agp_insert_file_private(struct agp_file_private * priv) 253static void agp_insert_file_private(struct agp_file_private * priv)
254{ 254{
255 struct agp_file_private *prev; 255 struct agp_file_private *prev;
256 256
@@ -262,7 +262,7 @@ void agp_insert_file_private(struct agp_file_private * priv)
262 agp_fe.file_priv_list = priv; 262 agp_fe.file_priv_list = priv;
263} 263}
264 264
265void agp_remove_file_private(struct agp_file_private * priv) 265static void agp_remove_file_private(struct agp_file_private * priv)
266{ 266{
267 struct agp_file_private *next; 267 struct agp_file_private *next;
268 struct agp_file_private *prev; 268 struct agp_file_private *prev;
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 4f7a3e8bc919..80dafa3030bd 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -288,7 +288,7 @@ static struct gatt_mask nvidia_generic_masks[] =
288}; 288};
289 289
290 290
291struct agp_bridge_driver nvidia_driver = { 291static struct agp_bridge_driver nvidia_driver = {
292 .owner = THIS_MODULE, 292 .owner = THIS_MODULE,
293 .aperture_sizes = nvidia_generic_sizes, 293 .aperture_sizes = nvidia_generic_sizes,
294 .size_type = U8_APER_SIZE, 294 .size_type = U8_APER_SIZE,
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
index cfccacb2a647..ebc05554045c 100644
--- a/drivers/char/agp/sis-agp.c
+++ b/drivers/char/agp/sis-agp.c
@@ -119,7 +119,7 @@ static struct aper_size_info_8 sis_generic_sizes[7] =
119 {4, 1024, 0, 3} 119 {4, 1024, 0, 3}
120}; 120};
121 121
122struct agp_bridge_driver sis_driver = { 122static struct agp_bridge_driver sis_driver = {
123 .owner = THIS_MODULE, 123 .owner = THIS_MODULE,
124 .aperture_sizes = sis_generic_sizes, 124 .aperture_sizes = sis_generic_sizes,
125 .size_type = U8_APER_SIZE, 125 .size_type = U8_APER_SIZE,
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index bb338d9134e0..10c23302dd84 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -409,7 +409,7 @@ static void serverworks_agp_enable(struct agp_bridge_data *bridge, u32 mode)
409 agp_device_command(command, 0); 409 agp_device_command(command, 0);
410} 410}
411 411
412struct agp_bridge_driver sworks_driver = { 412static struct agp_bridge_driver sworks_driver = {
413 .owner = THIS_MODULE, 413 .owner = THIS_MODULE,
414 .aperture_sizes = serverworks_sizes, 414 .aperture_sizes = serverworks_sizes,
415 .size_type = LVL2_APER_SIZE, 415 .size_type = LVL2_APER_SIZE,
diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
index e1451dd9b6a7..c847df575cf5 100644
--- a/drivers/char/agp/via-agp.c
+++ b/drivers/char/agp/via-agp.c
@@ -170,7 +170,7 @@ static void via_tlbflush_agp3(struct agp_memory *mem)
170} 170}
171 171
172 172
173struct agp_bridge_driver via_agp3_driver = { 173static struct agp_bridge_driver via_agp3_driver = {
174 .owner = THIS_MODULE, 174 .owner = THIS_MODULE,
175 .aperture_sizes = agp3_generic_sizes, 175 .aperture_sizes = agp3_generic_sizes,
176 .size_type = U8_APER_SIZE, 176 .size_type = U8_APER_SIZE,
@@ -193,7 +193,7 @@ struct agp_bridge_driver via_agp3_driver = {
193 .agp_destroy_page = agp_generic_destroy_page, 193 .agp_destroy_page = agp_generic_destroy_page,
194}; 194};
195 195
196struct agp_bridge_driver via_driver = { 196static struct agp_bridge_driver via_driver = {
197 .owner = THIS_MODULE, 197 .owner = THIS_MODULE,
198 .aperture_sizes = via_generic_sizes, 198 .aperture_sizes = via_generic_sizes,
199 .size_type = U8_APER_SIZE, 199 .size_type = U8_APER_SIZE,
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index 903e4c3cc209..a229915ce1b2 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -52,7 +52,7 @@
52#define KERNEL 52#define KERNEL
53#include <linux/types.h> 53#include <linux/types.h>
54#include <linux/fs.h> 54#include <linux/fs.h>
55#include <linux/mm.h> /* for verify_area */ 55#include <linux/mm.h>
56#include <linux/errno.h> /* for -EBUSY */ 56#include <linux/errno.h> /* for -EBUSY */
57#include <linux/ioport.h> /* for request_region */ 57#include <linux/ioport.h> /* for request_region */
58#include <linux/delay.h> /* for loops_per_jiffy */ 58#include <linux/delay.h> /* for loops_per_jiffy */
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c
index 83d6b37b36cd..78e650fc5b41 100644
--- a/drivers/char/hangcheck-timer.c
+++ b/drivers/char/hangcheck-timer.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Driver for a little io fencing timer. 4 * Driver for a little io fencing timer.
5 * 5 *
6 * Copyright (C) 2002 Oracle Corporation. All rights reserved. 6 * Copyright (C) 2002, 2003 Oracle. All rights reserved.
7 * 7 *
8 * Author: Joel Becker <joel.becker@oracle.com> 8 * Author: Joel Becker <joel.becker@oracle.com>
9 * 9 *
@@ -44,11 +44,14 @@
44#include <linux/fs.h> 44#include <linux/fs.h>
45#include <linux/mm.h> 45#include <linux/mm.h>
46#include <linux/reboot.h> 46#include <linux/reboot.h>
47#include <linux/smp_lock.h>
47#include <linux/init.h> 48#include <linux/init.h>
49#include <linux/delay.h>
48#include <asm/uaccess.h> 50#include <asm/uaccess.h>
51#include <linux/sysrq.h>
49 52
50 53
51#define VERSION_STR "0.5.0" 54#define VERSION_STR "0.9.0"
52 55
53#define DEFAULT_IOFENCE_MARGIN 60 /* Default fudge factor, in seconds */ 56#define DEFAULT_IOFENCE_MARGIN 60 /* Default fudge factor, in seconds */
54#define DEFAULT_IOFENCE_TICK 180 /* Default timer timeout, in seconds */ 57#define DEFAULT_IOFENCE_TICK 180 /* Default timer timeout, in seconds */
@@ -56,18 +59,89 @@
56static int hangcheck_tick = DEFAULT_IOFENCE_TICK; 59static int hangcheck_tick = DEFAULT_IOFENCE_TICK;
57static int hangcheck_margin = DEFAULT_IOFENCE_MARGIN; 60static int hangcheck_margin = DEFAULT_IOFENCE_MARGIN;
58static int hangcheck_reboot; /* Defaults to not reboot */ 61static int hangcheck_reboot; /* Defaults to not reboot */
62static int hangcheck_dump_tasks; /* Defaults to not dumping SysRQ T */
59 63
60/* Driver options */ 64/* options - modular */
61module_param(hangcheck_tick, int, 0); 65module_param(hangcheck_tick, int, 0);
62MODULE_PARM_DESC(hangcheck_tick, "Timer delay."); 66MODULE_PARM_DESC(hangcheck_tick, "Timer delay.");
63module_param(hangcheck_margin, int, 0); 67module_param(hangcheck_margin, int, 0);
64MODULE_PARM_DESC(hangcheck_margin, "If the hangcheck timer has been delayed more than hangcheck_margin seconds, the driver will fire."); 68MODULE_PARM_DESC(hangcheck_margin, "If the hangcheck timer has been delayed more than hangcheck_margin seconds, the driver will fire.");
65module_param(hangcheck_reboot, int, 0); 69module_param(hangcheck_reboot, int, 0);
66MODULE_PARM_DESC(hangcheck_reboot, "If nonzero, the machine will reboot when the timer margin is exceeded."); 70MODULE_PARM_DESC(hangcheck_reboot, "If nonzero, the machine will reboot when the timer margin is exceeded.");
71module_param(hangcheck_dump_tasks, int, 0);
72MODULE_PARM_DESC(hangcheck_dump_tasks, "If nonzero, the machine will dump the system task state when the timer margin is exceeded.");
67 73
68MODULE_AUTHOR("Joel Becker"); 74MODULE_AUTHOR("Oracle");
69MODULE_DESCRIPTION("Hangcheck-timer detects when the system has gone out to lunch past a certain margin."); 75MODULE_DESCRIPTION("Hangcheck-timer detects when the system has gone out to lunch past a certain margin.");
70MODULE_LICENSE("GPL"); 76MODULE_LICENSE("GPL");
77MODULE_VERSION(VERSION_STR);
78
79/* options - nonmodular */
80#ifndef MODULE
81
82static int __init hangcheck_parse_tick(char *str)
83{
84 int par;
85 if (get_option(&str,&par))
86 hangcheck_tick = par;
87 return 1;
88}
89
90static int __init hangcheck_parse_margin(char *str)
91{
92 int par;
93 if (get_option(&str,&par))
94 hangcheck_margin = par;
95 return 1;
96}
97
98static int __init hangcheck_parse_reboot(char *str)
99{
100 int par;
101 if (get_option(&str,&par))
102 hangcheck_reboot = par;
103 return 1;
104}
105
106static int __init hangcheck_parse_dump_tasks(char *str)
107{
108 int par;
109 if (get_option(&str,&par))
110 hangcheck_dump_tasks = par;
111 return 1;
112}
113
114__setup("hcheck_tick", hangcheck_parse_tick);
115__setup("hcheck_margin", hangcheck_parse_margin);
116__setup("hcheck_reboot", hangcheck_parse_reboot);
117__setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks);
118#endif /* not MODULE */
119
120#if defined(CONFIG_X86) || defined(CONFIG_X86_64)
121# define HAVE_MONOTONIC
122# define TIMER_FREQ 1000000000ULL
123#elif defined(CONFIG_ARCH_S390)
124/* FA240000 is 1 Second in the IBM time universe (Page 4-38 Principles of Op for zSeries */
125# define TIMER_FREQ 0xFA240000ULL
126#elif defined(CONFIG_IA64)
127# define TIMER_FREQ ((unsigned long long)local_cpu_data->itc_freq)
128#elif defined(CONFIG_PPC64)
129# define TIMER_FREQ (HZ*loops_per_jiffy)
130#endif
131
132#ifdef HAVE_MONOTONIC
133extern unsigned long long monotonic_clock(void);
134#else
135static inline unsigned long long monotonic_clock(void)
136{
137# ifdef __s390__
138 /* returns the TOD. see 4-38 Principles of Op of zSeries */
139 return get_clock();
140# else
141 return get_cycles();
142# endif /* __s390__ */
143}
144#endif /* HAVE_MONOTONIC */
71 145
72 146
73/* Last time scheduled */ 147/* Last time scheduled */
@@ -78,7 +152,6 @@ static void hangcheck_fire(unsigned long);
78static struct timer_list hangcheck_ticktock = 152static struct timer_list hangcheck_ticktock =
79 TIMER_INITIALIZER(hangcheck_fire, 0, 0); 153 TIMER_INITIALIZER(hangcheck_fire, 0, 0);
80 154
81extern unsigned long long monotonic_clock(void);
82 155
83static void hangcheck_fire(unsigned long data) 156static void hangcheck_fire(unsigned long data)
84{ 157{
@@ -92,6 +165,12 @@ static void hangcheck_fire(unsigned long data)
92 tsc_diff = (cur_tsc + (~0ULL - hangcheck_tsc)); /* or something */ 165 tsc_diff = (cur_tsc + (~0ULL - hangcheck_tsc)); /* or something */
93 166
94 if (tsc_diff > hangcheck_tsc_margin) { 167 if (tsc_diff > hangcheck_tsc_margin) {
168 if (hangcheck_dump_tasks) {
169 printk(KERN_CRIT "Hangcheck: Task state:\n");
170#ifdef CONFIG_MAGIC_SYSRQ
171 handle_sysrq('t', NULL, NULL);
172#endif /* CONFIG_MAGIC_SYSRQ */
173 }
95 if (hangcheck_reboot) { 174 if (hangcheck_reboot) {
96 printk(KERN_CRIT "Hangcheck: hangcheck is restarting the machine.\n"); 175 printk(KERN_CRIT "Hangcheck: hangcheck is restarting the machine.\n");
97 machine_restart(NULL); 176 machine_restart(NULL);
@@ -108,10 +187,16 @@ static int __init hangcheck_init(void)
108{ 187{
109 printk("Hangcheck: starting hangcheck timer %s (tick is %d seconds, margin is %d seconds).\n", 188 printk("Hangcheck: starting hangcheck timer %s (tick is %d seconds, margin is %d seconds).\n",
110 VERSION_STR, hangcheck_tick, hangcheck_margin); 189 VERSION_STR, hangcheck_tick, hangcheck_margin);
111 190#if defined (HAVE_MONOTONIC)
112 hangcheck_tsc_margin = hangcheck_margin + hangcheck_tick; 191 printk("Hangcheck: Using monotonic_clock().\n");
113 hangcheck_tsc_margin *= 1000000000; 192#elif defined(__s390__)
114 193 printk("Hangcheck: Using TOD.\n");
194#else
195 printk("Hangcheck: Using get_cycles().\n");
196#endif /* HAVE_MONOTONIC */
197 hangcheck_tsc_margin =
198 (unsigned long long)(hangcheck_margin + hangcheck_tick);
199 hangcheck_tsc_margin *= (unsigned long long)TIMER_FREQ;
115 200
116 hangcheck_tsc = monotonic_clock(); 201 hangcheck_tsc = monotonic_clock();
117 mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ)); 202 mod_timer(&hangcheck_ticktock, jiffies + (hangcheck_tick*HZ));
@@ -123,6 +208,7 @@ static int __init hangcheck_init(void)
123static void __exit hangcheck_exit(void) 208static void __exit hangcheck_exit(void)
124{ 209{
125 del_timer_sync(&hangcheck_ticktock); 210 del_timer_sync(&hangcheck_ticktock);
211 printk("Hangcheck: Stopped hangcheck timer.\n");
126} 212}
127 213
128module_init(hangcheck_init); 214module_init(hangcheck_init);
diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
index 225b330115bb..5ce9c6269033 100644
--- a/drivers/char/ipmi/ipmi_bt_sm.c
+++ b/drivers/char/ipmi/ipmi_bt_sm.c
@@ -235,7 +235,6 @@ static void reset_flags(struct si_sm_data *bt)
235 if (BT_STATUS & BT_B_BUSY) BT_CONTROL(BT_B_BUSY); 235 if (BT_STATUS & BT_B_BUSY) BT_CONTROL(BT_B_BUSY);
236 BT_CONTROL(BT_CLR_WR_PTR); 236 BT_CONTROL(BT_CLR_WR_PTR);
237 BT_CONTROL(BT_SMS_ATN); 237 BT_CONTROL(BT_SMS_ATN);
238 BT_INTMASK_W(BT_BMC_HWRST);
239#ifdef DEVELOPMENT_ONLY_NOT_FOR_PRODUCTION 238#ifdef DEVELOPMENT_ONLY_NOT_FOR_PRODUCTION
240 if (BT_STATUS & BT_B2H_ATN) { 239 if (BT_STATUS & BT_B2H_ATN) {
241 int i; 240 int i;
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index a6606a1aced7..d7fb452af7f9 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2588,28 +2588,20 @@ handle_msg_timeout(struct ipmi_recv_msg *msg)
2588 deliver_response(msg); 2588 deliver_response(msg);
2589} 2589}
2590 2590
2591static void 2591static struct ipmi_smi_msg *
2592send_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg, 2592smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
2593 struct ipmi_smi_msg *smi_msg, 2593 unsigned char seq, long seqid)
2594 unsigned char seq, long seqid)
2595{ 2594{
2596 if (!smi_msg) 2595 struct ipmi_smi_msg *smi_msg = ipmi_alloc_smi_msg();
2597 smi_msg = ipmi_alloc_smi_msg();
2598 if (!smi_msg) 2596 if (!smi_msg)
2599 /* If we can't allocate the message, then just return, we 2597 /* If we can't allocate the message, then just return, we
2600 get 4 retries, so this should be ok. */ 2598 get 4 retries, so this should be ok. */
2601 return; 2599 return NULL;
2602 2600
2603 memcpy(smi_msg->data, recv_msg->msg.data, recv_msg->msg.data_len); 2601 memcpy(smi_msg->data, recv_msg->msg.data, recv_msg->msg.data_len);
2604 smi_msg->data_size = recv_msg->msg.data_len; 2602 smi_msg->data_size = recv_msg->msg.data_len;
2605 smi_msg->msgid = STORE_SEQ_IN_MSGID(seq, seqid); 2603 smi_msg->msgid = STORE_SEQ_IN_MSGID(seq, seqid);
2606 2604
2607 /* Send the new message. We send with a zero priority. It
2608 timed out, I doubt time is that critical now, and high
2609 priority messages are really only for messages to the local
2610 MC, which don't get resent. */
2611 intf->handlers->sender(intf->send_info, smi_msg, 0);
2612
2613#ifdef DEBUG_MSGING 2605#ifdef DEBUG_MSGING
2614 { 2606 {
2615 int m; 2607 int m;
@@ -2619,6 +2611,7 @@ send_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
2619 printk("\n"); 2611 printk("\n");
2620 } 2612 }
2621#endif 2613#endif
2614 return smi_msg;
2622} 2615}
2623 2616
2624static void 2617static void
@@ -2683,14 +2676,13 @@ ipmi_timeout_handler(long timeout_period)
2683 intf->timed_out_ipmb_commands++; 2676 intf->timed_out_ipmb_commands++;
2684 spin_unlock(&intf->counter_lock); 2677 spin_unlock(&intf->counter_lock);
2685 } else { 2678 } else {
2679 struct ipmi_smi_msg *smi_msg;
2686 /* More retries, send again. */ 2680 /* More retries, send again. */
2687 2681
2688 /* Start with the max timer, set to normal 2682 /* Start with the max timer, set to normal
2689 timer after the message is sent. */ 2683 timer after the message is sent. */
2690 ent->timeout = MAX_MSG_TIMEOUT; 2684 ent->timeout = MAX_MSG_TIMEOUT;
2691 ent->retries_left--; 2685 ent->retries_left--;
2692 send_from_recv_msg(intf, ent->recv_msg, NULL,
2693 j, ent->seqid);
2694 spin_lock(&intf->counter_lock); 2686 spin_lock(&intf->counter_lock);
2695 if (ent->recv_msg->addr.addr_type 2687 if (ent->recv_msg->addr.addr_type
2696 == IPMI_LAN_ADDR_TYPE) 2688 == IPMI_LAN_ADDR_TYPE)
@@ -2698,6 +2690,20 @@ ipmi_timeout_handler(long timeout_period)
2698 else 2690 else
2699 intf->retransmitted_ipmb_commands++; 2691 intf->retransmitted_ipmb_commands++;
2700 spin_unlock(&intf->counter_lock); 2692 spin_unlock(&intf->counter_lock);
2693 smi_msg = smi_from_recv_msg(intf,
2694 ent->recv_msg, j, ent->seqid);
2695 if(!smi_msg)
2696 continue;
2697
2698 spin_unlock_irqrestore(&(intf->seq_lock),flags);
2699 /* Send the new message. We send with a zero
2700 * priority. It timed out, I doubt time is
2701 * that critical now, and high priority
2702 * messages are really only for messages to the
2703 * local MC, which don't get resent. */
2704 intf->handlers->sender(intf->send_info,
2705 smi_msg, 0);
2706 spin_lock_irqsave(&(intf->seq_lock), flags);
2701 } 2707 }
2702 } 2708 }
2703 spin_unlock_irqrestore(&(intf->seq_lock), flags); 2709 spin_unlock_irqrestore(&(intf->seq_lock), flags);
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 29de259a981e..298574e16061 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -100,6 +100,11 @@ enum si_intf_state {
100 /* FIXME - add watchdog stuff. */ 100 /* FIXME - add watchdog stuff. */
101}; 101};
102 102
103/* Some BT-specific defines we need here. */
104#define IPMI_BT_INTMASK_REG 2
105#define IPMI_BT_INTMASK_CLEAR_IRQ_BIT 2
106#define IPMI_BT_INTMASK_ENABLE_IRQ_BIT 1
107
103enum si_type { 108enum si_type {
104 SI_KCS, SI_SMIC, SI_BT 109 SI_KCS, SI_SMIC, SI_BT
105}; 110};
@@ -875,6 +880,17 @@ static irqreturn_t si_irq_handler(int irq, void *data, struct pt_regs *regs)
875 return IRQ_HANDLED; 880 return IRQ_HANDLED;
876} 881}
877 882
883static irqreturn_t si_bt_irq_handler(int irq, void *data, struct pt_regs *regs)
884{
885 struct smi_info *smi_info = data;
886 /* We need to clear the IRQ flag for the BT interface. */
887 smi_info->io.outputb(&smi_info->io, IPMI_BT_INTMASK_REG,
888 IPMI_BT_INTMASK_CLEAR_IRQ_BIT
889 | IPMI_BT_INTMASK_ENABLE_IRQ_BIT);
890 return si_irq_handler(irq, data, regs);
891}
892
893
878static struct ipmi_smi_handlers handlers = 894static struct ipmi_smi_handlers handlers =
879{ 895{
880 .owner = THIS_MODULE, 896 .owner = THIS_MODULE,
@@ -1001,11 +1017,22 @@ static int std_irq_setup(struct smi_info *info)
1001 if (!info->irq) 1017 if (!info->irq)
1002 return 0; 1018 return 0;
1003 1019
1004 rv = request_irq(info->irq, 1020 if (info->si_type == SI_BT) {
1005 si_irq_handler, 1021 rv = request_irq(info->irq,
1006 SA_INTERRUPT, 1022 si_bt_irq_handler,
1007 DEVICE_NAME, 1023 SA_INTERRUPT,
1008 info); 1024 DEVICE_NAME,
1025 info);
1026 if (!rv)
1027 /* Enable the interrupt in the BT interface. */
1028 info->io.outputb(&info->io, IPMI_BT_INTMASK_REG,
1029 IPMI_BT_INTMASK_ENABLE_IRQ_BIT);
1030 } else
1031 rv = request_irq(info->irq,
1032 si_irq_handler,
1033 SA_INTERRUPT,
1034 DEVICE_NAME,
1035 info);
1009 if (rv) { 1036 if (rv) {
1010 printk(KERN_WARNING 1037 printk(KERN_WARNING
1011 "ipmi_si: %s unable to claim interrupt %d," 1038 "ipmi_si: %s unable to claim interrupt %d,"
@@ -1024,6 +1051,9 @@ static void std_irq_cleanup(struct smi_info *info)
1024 if (!info->irq) 1051 if (!info->irq)
1025 return; 1052 return;
1026 1053
1054 if (info->si_type == SI_BT)
1055 /* Disable the interrupt in the BT interface. */
1056 info->io.outputb(&info->io, IPMI_BT_INTMASK_REG, 0);
1027 free_irq(info->irq, info); 1057 free_irq(info->irq, info);
1028} 1058}
1029 1059
@@ -1526,8 +1556,17 @@ static int try_init_acpi(int intf_num, struct smi_info **new_info)
1526 info->irq_setup = NULL; 1556 info->irq_setup = NULL;
1527 } 1557 }
1528 1558
1529 regspacings[intf_num] = spmi->addr.register_bit_width / 8; 1559 if (spmi->addr.register_bit_width) {
1530 info->io.regspacing = spmi->addr.register_bit_width / 8; 1560 /* A (hopefully) properly formed register bit width. */
1561 regspacings[intf_num] = spmi->addr.register_bit_width / 8;
1562 info->io.regspacing = spmi->addr.register_bit_width / 8;
1563 } else {
1564 /* Some broken systems get this wrong and set the value
1565 * to zero. Assume it is the default spacing. If that
1566 * is wrong, too bad, the vendor should fix the tables. */
1567 regspacings[intf_num] = DEFAULT_REGSPACING;
1568 info->io.regspacing = DEFAULT_REGSPACING;
1569 }
1531 regsizes[intf_num] = regspacings[intf_num]; 1570 regsizes[intf_num] = regspacings[intf_num];
1532 info->io.regsize = regsizes[intf_num]; 1571 info->io.regsize = regsizes[intf_num];
1533 regshifts[intf_num] = spmi->addr.register_bit_offset; 1572 regshifts[intf_num] = spmi->addr.register_bit_offset;
@@ -1578,15 +1617,15 @@ typedef struct dmi_header
1578 u16 handle; 1617 u16 handle;
1579} dmi_header_t; 1618} dmi_header_t;
1580 1619
1581static int decode_dmi(dmi_header_t *dm, int intf_num) 1620static int decode_dmi(dmi_header_t __iomem *dm, int intf_num)
1582{ 1621{
1583 u8 *data = (u8 *)dm; 1622 u8 __iomem *data = (u8 __iomem *)dm;
1584 unsigned long base_addr; 1623 unsigned long base_addr;
1585 u8 reg_spacing; 1624 u8 reg_spacing;
1586 u8 len = dm->length; 1625 u8 len = readb(&dm->length);
1587 dmi_ipmi_data_t *ipmi_data = dmi_data+intf_num; 1626 dmi_ipmi_data_t *ipmi_data = dmi_data+intf_num;
1588 1627
1589 ipmi_data->type = data[4]; 1628 ipmi_data->type = readb(&data[4]);
1590 1629
1591 memcpy(&base_addr, data+8, sizeof(unsigned long)); 1630 memcpy(&base_addr, data+8, sizeof(unsigned long));
1592 if (len >= 0x11) { 1631 if (len >= 0x11) {
@@ -1601,12 +1640,12 @@ static int decode_dmi(dmi_header_t *dm, int intf_num)
1601 } 1640 }
1602 /* If bit 4 of byte 0x10 is set, then the lsb for the address 1641 /* If bit 4 of byte 0x10 is set, then the lsb for the address
1603 is odd. */ 1642 is odd. */
1604 ipmi_data->base_addr = base_addr | ((data[0x10] & 0x10) >> 4); 1643 ipmi_data->base_addr = base_addr | ((readb(&data[0x10]) & 0x10) >> 4);
1605 1644
1606 ipmi_data->irq = data[0x11]; 1645 ipmi_data->irq = readb(&data[0x11]);
1607 1646
1608 /* The top two bits of byte 0x10 hold the register spacing. */ 1647 /* The top two bits of byte 0x10 hold the register spacing. */
1609 reg_spacing = (data[0x10] & 0xC0) >> 6; 1648 reg_spacing = (readb(&data[0x10]) & 0xC0) >> 6;
1610 switch(reg_spacing){ 1649 switch(reg_spacing){
1611 case 0x00: /* Byte boundaries */ 1650 case 0x00: /* Byte boundaries */
1612 ipmi_data->offset = 1; 1651 ipmi_data->offset = 1;
@@ -1623,12 +1662,18 @@ static int decode_dmi(dmi_header_t *dm, int intf_num)
1623 } 1662 }
1624 } else { 1663 } else {
1625 /* Old DMI spec. */ 1664 /* Old DMI spec. */
1626 ipmi_data->base_addr = base_addr; 1665 /* Note that technically, the lower bit of the base
1666 * address should be 1 if the address is I/O and 0 if
1667 * the address is in memory. So many systems get that
1668 * wrong (and all that I have seen are I/O) so we just
1669 * ignore that bit and assume I/O. Systems that use
1670 * memory should use the newer spec, anyway. */
1671 ipmi_data->base_addr = base_addr & 0xfffe;
1627 ipmi_data->addr_space = IPMI_IO_ADDR_SPACE; 1672 ipmi_data->addr_space = IPMI_IO_ADDR_SPACE;
1628 ipmi_data->offset = 1; 1673 ipmi_data->offset = 1;
1629 } 1674 }
1630 1675
1631 ipmi_data->slave_addr = data[6]; 1676 ipmi_data->slave_addr = readb(&data[6]);
1632 1677
1633 if (is_new_interface(-1, ipmi_data->addr_space,ipmi_data->base_addr)) { 1678 if (is_new_interface(-1, ipmi_data->addr_space,ipmi_data->base_addr)) {
1634 dmi_data_entries++; 1679 dmi_data_entries++;
@@ -1642,9 +1687,9 @@ static int decode_dmi(dmi_header_t *dm, int intf_num)
1642 1687
1643static int dmi_table(u32 base, int len, int num) 1688static int dmi_table(u32 base, int len, int num)
1644{ 1689{
1645 u8 *buf; 1690 u8 __iomem *buf;
1646 struct dmi_header *dm; 1691 struct dmi_header __iomem *dm;
1647 u8 *data; 1692 u8 __iomem *data;
1648 int i=1; 1693 int i=1;
1649 int status=-1; 1694 int status=-1;
1650 int intf_num = 0; 1695 int intf_num = 0;
@@ -1657,12 +1702,12 @@ static int dmi_table(u32 base, int len, int num)
1657 1702
1658 while(i<num && (data - buf) < len) 1703 while(i<num && (data - buf) < len)
1659 { 1704 {
1660 dm=(dmi_header_t *)data; 1705 dm=(dmi_header_t __iomem *)data;
1661 1706
1662 if((data-buf+dm->length) >= len) 1707 if((data-buf+readb(&dm->length)) >= len)
1663 break; 1708 break;
1664 1709
1665 if (dm->type == 38) { 1710 if (readb(&dm->type) == 38) {
1666 if (decode_dmi(dm, intf_num) == 0) { 1711 if (decode_dmi(dm, intf_num) == 0) {
1667 intf_num++; 1712 intf_num++;
1668 if (intf_num >= SI_MAX_DRIVERS) 1713 if (intf_num >= SI_MAX_DRIVERS)
@@ -1670,8 +1715,8 @@ static int dmi_table(u32 base, int len, int num)
1670 } 1715 }
1671 } 1716 }
1672 1717
1673 data+=dm->length; 1718 data+=readb(&dm->length);
1674 while((data-buf) < len && (*data || data[1])) 1719 while((data-buf) < len && (readb(data)||readb(data+1)))
1675 data++; 1720 data++;
1676 data+=2; 1721 data+=2;
1677 i++; 1722 i++;
@@ -2199,7 +2244,7 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2199 /* Wait until we know that we are out of any interrupt 2244 /* Wait until we know that we are out of any interrupt
2200 handlers might have been running before we freed the 2245 handlers might have been running before we freed the
2201 interrupt. */ 2246 interrupt. */
2202 synchronize_kernel(); 2247 synchronize_sched();
2203 2248
2204 if (new_smi->si_sm) { 2249 if (new_smi->si_sm) {
2205 if (new_smi->handlers) 2250 if (new_smi->handlers)
@@ -2312,7 +2357,7 @@ static void __exit cleanup_one_si(struct smi_info *to_clean)
2312 /* Wait until we know that we are out of any interrupt 2357 /* Wait until we know that we are out of any interrupt
2313 handlers might have been running before we freed the 2358 handlers might have been running before we freed the
2314 interrupt. */ 2359 interrupt. */
2315 synchronize_kernel(); 2360 synchronize_sched();
2316 2361
2317 /* Wait for the timer to stop. This avoids problems with race 2362 /* Wait for the timer to stop. This avoids problems with race
2318 conditions removing the timer here. */ 2363 conditions removing the timer here. */
diff --git a/drivers/char/ipmi/ipmi_si_sm.h b/drivers/char/ipmi/ipmi_si_sm.h
index a0212b004016..62791dd42985 100644
--- a/drivers/char/ipmi/ipmi_si_sm.h
+++ b/drivers/char/ipmi/ipmi_si_sm.h
@@ -51,7 +51,7 @@ struct si_sm_io
51 /* Generic info used by the actual handling routines, the 51 /* Generic info used by the actual handling routines, the
52 state machine shouldn't touch these. */ 52 state machine shouldn't touch these. */
53 void *info; 53 void *info;
54 void *addr; 54 void __iomem *addr;
55 int regspacing; 55 int regspacing;
56 int regsize; 56 int regsize;
57 int regshift; 57 int regshift;
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index fd7093879c66..fcd1c02a32cb 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -709,11 +709,11 @@ static int ipmi_close(struct inode *ino, struct file *filep)
709 if (expect_close == 42) { 709 if (expect_close == 42) {
710 ipmi_watchdog_state = WDOG_TIMEOUT_NONE; 710 ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
711 ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB); 711 ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB);
712 clear_bit(0, &ipmi_wdog_open);
713 } else { 712 } else {
714 printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); 713 printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
715 ipmi_heartbeat(); 714 ipmi_heartbeat();
716 } 715 }
716 clear_bit(0, &ipmi_wdog_open);
717 } 717 }
718 718
719 ipmi_fasync (-1, filep, 0); 719 ipmi_fasync (-1, filep, 0);
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 3ce51c6a1b18..7b19e02f112f 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -1026,7 +1026,8 @@ static void kbd_rawcode(unsigned char data)
1026 put_queue(vc, data); 1026 put_queue(vc, data);
1027} 1027}
1028 1028
1029void kbd_keycode(unsigned int keycode, int down, int hw_raw, struct pt_regs *regs) 1029static void kbd_keycode(unsigned int keycode, int down,
1030 int hw_raw, struct pt_regs *regs)
1030{ 1031{
1031 struct vc_data *vc = vc_cons[fg_console].d; 1032 struct vc_data *vc = vc_cons[fg_console].d;
1032 unsigned short keysym, *key_map; 1033 unsigned short keysym, *key_map;
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c
new file mode 100644
index 000000000000..ac9cfa9701ea
--- /dev/null
+++ b/drivers/char/mbcs.c
@@ -0,0 +1,849 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2005 Silicon Graphics, Inc. All rights reserved.
7 */
8
9/*
10 * MOATB Core Services driver.
11 */
12
13#include <linux/config.h>
14#include <linux/interrupt.h>
15#include <linux/module.h>
16#include <linux/moduleparam.h>
17#include <linux/types.h>
18#include <linux/ioport.h>
19#include <linux/notifier.h>
20#include <linux/reboot.h>
21#include <linux/init.h>
22#include <linux/fs.h>
23#include <linux/delay.h>
24#include <linux/device.h>
25#include <linux/mm.h>
26#include <linux/uio.h>
27#include <asm/io.h>
28#include <asm/uaccess.h>
29#include <asm/system.h>
30#include <asm/pgtable.h>
31#include <asm/sn/addrs.h>
32#include <asm/sn/intr.h>
33#include <asm/sn/tiocx.h>
34#include "mbcs.h"
35
36#define MBCS_DEBUG 0
37#if MBCS_DEBUG
38#define DBG(fmt...) printk(KERN_ALERT fmt)
39#else
40#define DBG(fmt...)
41#endif
42int mbcs_major;
43
44LIST_HEAD(soft_list);
45
46/*
47 * file operations
48 */
49struct file_operations mbcs_ops = {
50 .open = mbcs_open,
51 .llseek = mbcs_sram_llseek,
52 .read = mbcs_sram_read,
53 .write = mbcs_sram_write,
54 .mmap = mbcs_gscr_mmap,
55};
56
57struct mbcs_callback_arg {
58 int minor;
59 struct cx_dev *cx_dev;
60};
61
62static inline void mbcs_getdma_init(struct getdma *gdma)
63{
64 memset(gdma, 0, sizeof(struct getdma));
65 gdma->DoneIntEnable = 1;
66}
67
68static inline void mbcs_putdma_init(struct putdma *pdma)
69{
70 memset(pdma, 0, sizeof(struct putdma));
71 pdma->DoneIntEnable = 1;
72}
73
74static inline void mbcs_algo_init(struct algoblock *algo_soft)
75{
76 memset(algo_soft, 0, sizeof(struct algoblock));
77}
78
79static inline void mbcs_getdma_set(void *mmr,
80 uint64_t hostAddr,
81 uint64_t localAddr,
82 uint64_t localRamSel,
83 uint64_t numPkts,
84 uint64_t amoEnable,
85 uint64_t intrEnable,
86 uint64_t peerIO,
87 uint64_t amoHostDest,
88 uint64_t amoModType, uint64_t intrHostDest,
89 uint64_t intrVector)
90{
91 union dma_control rdma_control;
92 union dma_amo_dest amo_dest;
93 union intr_dest intr_dest;
94 union dma_localaddr local_addr;
95 union dma_hostaddr host_addr;
96
97 rdma_control.dma_control_reg = 0;
98 amo_dest.dma_amo_dest_reg = 0;
99 intr_dest.intr_dest_reg = 0;
100 local_addr.dma_localaddr_reg = 0;
101 host_addr.dma_hostaddr_reg = 0;
102
103 host_addr.dma_sys_addr = hostAddr;
104 MBCS_MMR_SET(mmr, MBCS_RD_DMA_SYS_ADDR, host_addr.dma_hostaddr_reg);
105
106 local_addr.dma_ram_addr = localAddr;
107 local_addr.dma_ram_sel = localRamSel;
108 MBCS_MMR_SET(mmr, MBCS_RD_DMA_LOC_ADDR, local_addr.dma_localaddr_reg);
109
110 rdma_control.dma_op_length = numPkts;
111 rdma_control.done_amo_en = amoEnable;
112 rdma_control.done_int_en = intrEnable;
113 rdma_control.pio_mem_n = peerIO;
114 MBCS_MMR_SET(mmr, MBCS_RD_DMA_CTRL, rdma_control.dma_control_reg);
115
116 amo_dest.dma_amo_sys_addr = amoHostDest;
117 amo_dest.dma_amo_mod_type = amoModType;
118 MBCS_MMR_SET(mmr, MBCS_RD_DMA_AMO_DEST, amo_dest.dma_amo_dest_reg);
119
120 intr_dest.address = intrHostDest;
121 intr_dest.int_vector = intrVector;
122 MBCS_MMR_SET(mmr, MBCS_RD_DMA_INT_DEST, intr_dest.intr_dest_reg);
123
124}
125
126static inline void mbcs_putdma_set(void *mmr,
127 uint64_t hostAddr,
128 uint64_t localAddr,
129 uint64_t localRamSel,
130 uint64_t numPkts,
131 uint64_t amoEnable,
132 uint64_t intrEnable,
133 uint64_t peerIO,
134 uint64_t amoHostDest,
135 uint64_t amoModType,
136 uint64_t intrHostDest, uint64_t intrVector)
137{
138 union dma_control wdma_control;
139 union dma_amo_dest amo_dest;
140 union intr_dest intr_dest;
141 union dma_localaddr local_addr;
142 union dma_hostaddr host_addr;
143
144 wdma_control.dma_control_reg = 0;
145 amo_dest.dma_amo_dest_reg = 0;
146 intr_dest.intr_dest_reg = 0;
147 local_addr.dma_localaddr_reg = 0;
148 host_addr.dma_hostaddr_reg = 0;
149
150 host_addr.dma_sys_addr = hostAddr;
151 MBCS_MMR_SET(mmr, MBCS_WR_DMA_SYS_ADDR, host_addr.dma_hostaddr_reg);
152
153 local_addr.dma_ram_addr = localAddr;
154 local_addr.dma_ram_sel = localRamSel;
155 MBCS_MMR_SET(mmr, MBCS_WR_DMA_LOC_ADDR, local_addr.dma_localaddr_reg);
156
157 wdma_control.dma_op_length = numPkts;
158 wdma_control.done_amo_en = amoEnable;
159 wdma_control.done_int_en = intrEnable;
160 wdma_control.pio_mem_n = peerIO;
161 MBCS_MMR_SET(mmr, MBCS_WR_DMA_CTRL, wdma_control.dma_control_reg);
162
163 amo_dest.dma_amo_sys_addr = amoHostDest;
164 amo_dest.dma_amo_mod_type = amoModType;
165 MBCS_MMR_SET(mmr, MBCS_WR_DMA_AMO_DEST, amo_dest.dma_amo_dest_reg);
166
167 intr_dest.address = intrHostDest;
168 intr_dest.int_vector = intrVector;
169 MBCS_MMR_SET(mmr, MBCS_WR_DMA_INT_DEST, intr_dest.intr_dest_reg);
170
171}
172
173static inline void mbcs_algo_set(void *mmr,
174 uint64_t amoHostDest,
175 uint64_t amoModType,
176 uint64_t intrHostDest,
177 uint64_t intrVector, uint64_t algoStepCount)
178{
179 union dma_amo_dest amo_dest;
180 union intr_dest intr_dest;
181 union algo_step step;
182
183 step.algo_step_reg = 0;
184 intr_dest.intr_dest_reg = 0;
185 amo_dest.dma_amo_dest_reg = 0;
186
187 amo_dest.dma_amo_sys_addr = amoHostDest;
188 amo_dest.dma_amo_mod_type = amoModType;
189 MBCS_MMR_SET(mmr, MBCS_ALG_AMO_DEST, amo_dest.dma_amo_dest_reg);
190
191 intr_dest.address = intrHostDest;
192 intr_dest.int_vector = intrVector;
193 MBCS_MMR_SET(mmr, MBCS_ALG_INT_DEST, intr_dest.intr_dest_reg);
194
195 step.alg_step_cnt = algoStepCount;
196 MBCS_MMR_SET(mmr, MBCS_ALG_STEP, step.algo_step_reg);
197}
198
199static inline int mbcs_getdma_start(struct mbcs_soft *soft)
200{
201 void *mmr_base;
202 struct getdma *gdma;
203 uint64_t numPkts;
204 union cm_control cm_control;
205
206 mmr_base = soft->mmr_base;
207 gdma = &soft->getdma;
208
209 /* check that host address got setup */
210 if (!gdma->hostAddr)
211 return -1;
212
213 numPkts =
214 (gdma->bytes + (MBCS_CACHELINE_SIZE - 1)) / MBCS_CACHELINE_SIZE;
215
216 /* program engine */
217 mbcs_getdma_set(mmr_base, tiocx_dma_addr(gdma->hostAddr),
218 gdma->localAddr,
219 (gdma->localAddr < MB2) ? 0 :
220 (gdma->localAddr < MB4) ? 1 :
221 (gdma->localAddr < MB6) ? 2 : 3,
222 numPkts,
223 gdma->DoneAmoEnable,
224 gdma->DoneIntEnable,
225 gdma->peerIO,
226 gdma->amoHostDest,
227 gdma->amoModType,
228 gdma->intrHostDest, gdma->intrVector);
229
230 /* start engine */
231 cm_control.cm_control_reg = MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
232 cm_control.rd_dma_go = 1;
233 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL, cm_control.cm_control_reg);
234
235 return 0;
236
237}
238
239static inline int mbcs_putdma_start(struct mbcs_soft *soft)
240{
241 void *mmr_base;
242 struct putdma *pdma;
243 uint64_t numPkts;
244 union cm_control cm_control;
245
246 mmr_base = soft->mmr_base;
247 pdma = &soft->putdma;
248
249 /* check that host address got setup */
250 if (!pdma->hostAddr)
251 return -1;
252
253 numPkts =
254 (pdma->bytes + (MBCS_CACHELINE_SIZE - 1)) / MBCS_CACHELINE_SIZE;
255
256 /* program engine */
257 mbcs_putdma_set(mmr_base, tiocx_dma_addr(pdma->hostAddr),
258 pdma->localAddr,
259 (pdma->localAddr < MB2) ? 0 :
260 (pdma->localAddr < MB4) ? 1 :
261 (pdma->localAddr < MB6) ? 2 : 3,
262 numPkts,
263 pdma->DoneAmoEnable,
264 pdma->DoneIntEnable,
265 pdma->peerIO,
266 pdma->amoHostDest,
267 pdma->amoModType,
268 pdma->intrHostDest, pdma->intrVector);
269
270 /* start engine */
271 cm_control.cm_control_reg = MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
272 cm_control.wr_dma_go = 1;
273 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL, cm_control.cm_control_reg);
274
275 return 0;
276
277}
278
279static inline int mbcs_algo_start(struct mbcs_soft *soft)
280{
281 struct algoblock *algo_soft = &soft->algo;
282 void *mmr_base = soft->mmr_base;
283 union cm_control cm_control;
284
285 if (down_interruptible(&soft->algolock))
286 return -ERESTARTSYS;
287
288 atomic_set(&soft->algo_done, 0);
289
290 mbcs_algo_set(mmr_base,
291 algo_soft->amoHostDest,
292 algo_soft->amoModType,
293 algo_soft->intrHostDest,
294 algo_soft->intrVector, algo_soft->algoStepCount);
295
296 /* start algorithm */
297 cm_control.cm_control_reg = MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
298 cm_control.alg_done_int_en = 1;
299 cm_control.alg_go = 1;
300 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL, cm_control.cm_control_reg);
301
302 up(&soft->algolock);
303
304 return 0;
305}
306
307static inline ssize_t
308do_mbcs_sram_dmawrite(struct mbcs_soft *soft, uint64_t hostAddr,
309 size_t len, loff_t * off)
310{
311 int rv = 0;
312
313 if (down_interruptible(&soft->dmawritelock))
314 return -ERESTARTSYS;
315
316 atomic_set(&soft->dmawrite_done, 0);
317
318 soft->putdma.hostAddr = hostAddr;
319 soft->putdma.localAddr = *off;
320 soft->putdma.bytes = len;
321
322 if (mbcs_putdma_start(soft) < 0) {
323 DBG(KERN_ALERT "do_mbcs_sram_dmawrite: "
324 "mbcs_putdma_start failed\n");
325 rv = -EAGAIN;
326 goto dmawrite_exit;
327 }
328
329 if (wait_event_interruptible(soft->dmawrite_queue,
330 atomic_read(&soft->dmawrite_done))) {
331 rv = -ERESTARTSYS;
332 goto dmawrite_exit;
333 }
334
335 rv = len;
336 *off += len;
337
338dmawrite_exit:
339 up(&soft->dmawritelock);
340
341 return rv;
342}
343
344static inline ssize_t
345do_mbcs_sram_dmaread(struct mbcs_soft *soft, uint64_t hostAddr,
346 size_t len, loff_t * off)
347{
348 int rv = 0;
349
350 if (down_interruptible(&soft->dmareadlock))
351 return -ERESTARTSYS;
352
353 atomic_set(&soft->dmawrite_done, 0);
354
355 soft->getdma.hostAddr = hostAddr;
356 soft->getdma.localAddr = *off;
357 soft->getdma.bytes = len;
358
359 if (mbcs_getdma_start(soft) < 0) {
360 DBG(KERN_ALERT "mbcs_strategy: mbcs_getdma_start failed\n");
361 rv = -EAGAIN;
362 goto dmaread_exit;
363 }
364
365 if (wait_event_interruptible(soft->dmaread_queue,
366 atomic_read(&soft->dmaread_done))) {
367 rv = -ERESTARTSYS;
368 goto dmaread_exit;
369 }
370
371 rv = len;
372 *off += len;
373
374dmaread_exit:
375 up(&soft->dmareadlock);
376
377 return rv;
378}
379
380int mbcs_open(struct inode *ip, struct file *fp)
381{
382 struct mbcs_soft *soft;
383 int minor;
384
385 minor = iminor(ip);
386
387 list_for_each_entry(soft, &soft_list, list) {
388 if (soft->nasid == minor) {
389 fp->private_data = soft->cxdev;
390 return 0;
391 }
392 }
393
394 return -ENODEV;
395}
396
397ssize_t mbcs_sram_read(struct file * fp, char __user *buf, size_t len, loff_t * off)
398{
399 struct cx_dev *cx_dev = fp->private_data;
400 struct mbcs_soft *soft = cx_dev->soft;
401 uint64_t hostAddr;
402 int rv = 0;
403
404 hostAddr = __get_dma_pages(GFP_KERNEL, get_order(len));
405 if (hostAddr == 0)
406 return -ENOMEM;
407
408 rv = do_mbcs_sram_dmawrite(soft, hostAddr, len, off);
409 if (rv < 0)
410 goto exit;
411
412 if (copy_to_user(buf, (void *)hostAddr, len))
413 rv = -EFAULT;
414
415 exit:
416 free_pages(hostAddr, get_order(len));
417
418 return rv;
419}
420
421ssize_t
422mbcs_sram_write(struct file * fp, const char __user *buf, size_t len, loff_t * off)
423{
424 struct cx_dev *cx_dev = fp->private_data;
425 struct mbcs_soft *soft = cx_dev->soft;
426 uint64_t hostAddr;
427 int rv = 0;
428
429 hostAddr = __get_dma_pages(GFP_KERNEL, get_order(len));
430 if (hostAddr == 0)
431 return -ENOMEM;
432
433 if (copy_from_user((void *)hostAddr, buf, len)) {
434 rv = -EFAULT;
435 goto exit;
436 }
437
438 rv = do_mbcs_sram_dmaread(soft, hostAddr, len, off);
439
440 exit:
441 free_pages(hostAddr, get_order(len));
442
443 return rv;
444}
445
446loff_t mbcs_sram_llseek(struct file * filp, loff_t off, int whence)
447{
448 loff_t newpos;
449
450 switch (whence) {
451 case 0: /* SEEK_SET */
452 newpos = off;
453 break;
454
455 case 1: /* SEEK_CUR */
456 newpos = filp->f_pos + off;
457 break;
458
459 case 2: /* SEEK_END */
460 newpos = MBCS_SRAM_SIZE + off;
461 break;
462
463 default: /* can't happen */
464 return -EINVAL;
465 }
466
467 if (newpos < 0)
468 return -EINVAL;
469
470 filp->f_pos = newpos;
471
472 return newpos;
473}
474
475static uint64_t mbcs_pioaddr(struct mbcs_soft *soft, uint64_t offset)
476{
477 uint64_t mmr_base;
478
479 mmr_base = (uint64_t) (soft->mmr_base + offset);
480
481 return mmr_base;
482}
483
484static void mbcs_debug_pioaddr_set(struct mbcs_soft *soft)
485{
486 soft->debug_addr = mbcs_pioaddr(soft, MBCS_DEBUG_START);
487}
488
489static void mbcs_gscr_pioaddr_set(struct mbcs_soft *soft)
490{
491 soft->gscr_addr = mbcs_pioaddr(soft, MBCS_GSCR_START);
492}
493
494int mbcs_gscr_mmap(struct file *fp, struct vm_area_struct *vma)
495{
496 struct cx_dev *cx_dev = fp->private_data;
497 struct mbcs_soft *soft = cx_dev->soft;
498
499 if (vma->vm_pgoff != 0)
500 return -EINVAL;
501
502 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
503
504 /* Remap-pfn-range will mark the range VM_IO and VM_RESERVED */
505 if (remap_pfn_range(vma,
506 vma->vm_start,
507 __pa(soft->gscr_addr) >> PAGE_SHIFT,
508 PAGE_SIZE,
509 vma->vm_page_prot))
510 return -EAGAIN;
511
512 return 0;
513}
514
515/**
516 * mbcs_completion_intr_handler - Primary completion handler.
517 * @irq: irq
518 * @arg: soft struct for device
519 * @ep: regs
520 *
521 */
522static irqreturn_t
523mbcs_completion_intr_handler(int irq, void *arg, struct pt_regs *ep)
524{
525 struct mbcs_soft *soft = (struct mbcs_soft *)arg;
526 void *mmr_base;
527 union cm_status cm_status;
528 union cm_control cm_control;
529
530 mmr_base = soft->mmr_base;
531 cm_status.cm_status_reg = MBCS_MMR_GET(mmr_base, MBCS_CM_STATUS);
532
533 if (cm_status.rd_dma_done) {
534 /* stop dma-read engine, clear status */
535 cm_control.cm_control_reg =
536 MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
537 cm_control.rd_dma_clr = 1;
538 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL,
539 cm_control.cm_control_reg);
540 atomic_set(&soft->dmaread_done, 1);
541 wake_up(&soft->dmaread_queue);
542 }
543 if (cm_status.wr_dma_done) {
544 /* stop dma-write engine, clear status */
545 cm_control.cm_control_reg =
546 MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
547 cm_control.wr_dma_clr = 1;
548 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL,
549 cm_control.cm_control_reg);
550 atomic_set(&soft->dmawrite_done, 1);
551 wake_up(&soft->dmawrite_queue);
552 }
553 if (cm_status.alg_done) {
554 /* clear status */
555 cm_control.cm_control_reg =
556 MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
557 cm_control.alg_done_clr = 1;
558 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL,
559 cm_control.cm_control_reg);
560 atomic_set(&soft->algo_done, 1);
561 wake_up(&soft->algo_queue);
562 }
563
564 return IRQ_HANDLED;
565}
566
567/**
568 * mbcs_intr_alloc - Allocate interrupts.
569 * @dev: device pointer
570 *
571 */
572static int mbcs_intr_alloc(struct cx_dev *dev)
573{
574 struct sn_irq_info *sn_irq;
575 struct mbcs_soft *soft;
576 struct getdma *getdma;
577 struct putdma *putdma;
578 struct algoblock *algo;
579
580 soft = dev->soft;
581 getdma = &soft->getdma;
582 putdma = &soft->putdma;
583 algo = &soft->algo;
584
585 soft->get_sn_irq = NULL;
586 soft->put_sn_irq = NULL;
587 soft->algo_sn_irq = NULL;
588
589 sn_irq = tiocx_irq_alloc(dev->cx_id.nasid, TIOCX_CORELET, -1, -1, -1);
590 if (sn_irq == NULL)
591 return -EAGAIN;
592 soft->get_sn_irq = sn_irq;
593 getdma->intrHostDest = sn_irq->irq_xtalkaddr;
594 getdma->intrVector = sn_irq->irq_irq;
595 if (request_irq(sn_irq->irq_irq,
596 (void *)mbcs_completion_intr_handler, SA_SHIRQ,
597 "MBCS get intr", (void *)soft)) {
598 tiocx_irq_free(soft->get_sn_irq);
599 return -EAGAIN;
600 }
601
602 sn_irq = tiocx_irq_alloc(dev->cx_id.nasid, TIOCX_CORELET, -1, -1, -1);
603 if (sn_irq == NULL) {
604 free_irq(soft->get_sn_irq->irq_irq, soft);
605 tiocx_irq_free(soft->get_sn_irq);
606 return -EAGAIN;
607 }
608 soft->put_sn_irq = sn_irq;
609 putdma->intrHostDest = sn_irq->irq_xtalkaddr;
610 putdma->intrVector = sn_irq->irq_irq;
611 if (request_irq(sn_irq->irq_irq,
612 (void *)mbcs_completion_intr_handler, SA_SHIRQ,
613 "MBCS put intr", (void *)soft)) {
614 tiocx_irq_free(soft->put_sn_irq);
615 free_irq(soft->get_sn_irq->irq_irq, soft);
616 tiocx_irq_free(soft->get_sn_irq);
617 return -EAGAIN;
618 }
619
620 sn_irq = tiocx_irq_alloc(dev->cx_id.nasid, TIOCX_CORELET, -1, -1, -1);
621 if (sn_irq == NULL) {
622 free_irq(soft->put_sn_irq->irq_irq, soft);
623 tiocx_irq_free(soft->put_sn_irq);
624 free_irq(soft->get_sn_irq->irq_irq, soft);
625 tiocx_irq_free(soft->get_sn_irq);
626 return -EAGAIN;
627 }
628 soft->algo_sn_irq = sn_irq;
629 algo->intrHostDest = sn_irq->irq_xtalkaddr;
630 algo->intrVector = sn_irq->irq_irq;
631 if (request_irq(sn_irq->irq_irq,
632 (void *)mbcs_completion_intr_handler, SA_SHIRQ,
633 "MBCS algo intr", (void *)soft)) {
634 tiocx_irq_free(soft->algo_sn_irq);
635 free_irq(soft->put_sn_irq->irq_irq, soft);
636 tiocx_irq_free(soft->put_sn_irq);
637 free_irq(soft->get_sn_irq->irq_irq, soft);
638 tiocx_irq_free(soft->get_sn_irq);
639 return -EAGAIN;
640 }
641
642 return 0;
643}
644
645/**
646 * mbcs_intr_dealloc - Remove interrupts.
647 * @dev: device pointer
648 *
649 */
650static void mbcs_intr_dealloc(struct cx_dev *dev)
651{
652 struct mbcs_soft *soft;
653
654 soft = dev->soft;
655
656 free_irq(soft->get_sn_irq->irq_irq, soft);
657 tiocx_irq_free(soft->get_sn_irq);
658 free_irq(soft->put_sn_irq->irq_irq, soft);
659 tiocx_irq_free(soft->put_sn_irq);
660 free_irq(soft->algo_sn_irq->irq_irq, soft);
661 tiocx_irq_free(soft->algo_sn_irq);
662}
663
664static inline int mbcs_hw_init(struct mbcs_soft *soft)
665{
666 void *mmr_base = soft->mmr_base;
667 union cm_control cm_control;
668 union cm_req_timeout cm_req_timeout;
669 uint64_t err_stat;
670
671 cm_req_timeout.cm_req_timeout_reg =
672 MBCS_MMR_GET(mmr_base, MBCS_CM_REQ_TOUT);
673
674 cm_req_timeout.time_out = MBCS_CM_CONTROL_REQ_TOUT_MASK;
675 MBCS_MMR_SET(mmr_base, MBCS_CM_REQ_TOUT,
676 cm_req_timeout.cm_req_timeout_reg);
677
678 mbcs_gscr_pioaddr_set(soft);
679 mbcs_debug_pioaddr_set(soft);
680
681 /* clear errors */
682 err_stat = MBCS_MMR_GET(mmr_base, MBCS_CM_ERR_STAT);
683 MBCS_MMR_SET(mmr_base, MBCS_CM_CLR_ERR_STAT, err_stat);
684 MBCS_MMR_ZERO(mmr_base, MBCS_CM_ERROR_DETAIL1);
685
686 /* enable interrupts */
687 /* turn off 2^23 (INT_EN_PIO_REQ_ADDR_INV) */
688 MBCS_MMR_SET(mmr_base, MBCS_CM_ERR_INT_EN, 0x3ffffff7e00ffUL);
689
690 /* arm status regs and clear engines */
691 cm_control.cm_control_reg = MBCS_MMR_GET(mmr_base, MBCS_CM_CONTROL);
692 cm_control.rearm_stat_regs = 1;
693 cm_control.alg_clr = 1;
694 cm_control.wr_dma_clr = 1;
695 cm_control.rd_dma_clr = 1;
696
697 MBCS_MMR_SET(mmr_base, MBCS_CM_CONTROL, cm_control.cm_control_reg);
698
699 return 0;
700}
701
702static ssize_t show_algo(struct device *dev, char *buf)
703{
704 struct cx_dev *cx_dev = to_cx_dev(dev);
705 struct mbcs_soft *soft = cx_dev->soft;
706 uint64_t debug0;
707
708 /*
709 * By convention, the first debug register contains the
710 * algorithm number and revision.
711 */
712 debug0 = *(uint64_t *) soft->debug_addr;
713
714 return sprintf(buf, "0x%lx 0x%lx\n",
715 (debug0 >> 32), (debug0 & 0xffffffff));
716}
717
718static ssize_t store_algo(struct device *dev, const char *buf, size_t count)
719{
720 int n;
721 struct cx_dev *cx_dev = to_cx_dev(dev);
722 struct mbcs_soft *soft = cx_dev->soft;
723
724 if (count <= 0)
725 return 0;
726
727 n = simple_strtoul(buf, NULL, 0);
728
729 if (n == 1) {
730 mbcs_algo_start(soft);
731 if (wait_event_interruptible(soft->algo_queue,
732 atomic_read(&soft->algo_done)))
733 return -ERESTARTSYS;
734 }
735
736 return count;
737}
738
739DEVICE_ATTR(algo, 0644, show_algo, store_algo);
740
741/**
742 * mbcs_probe - Initialize for device
743 * @dev: device pointer
744 * @device_id: id table pointer
745 *
746 */
747static int mbcs_probe(struct cx_dev *dev, const struct cx_device_id *id)
748{
749 struct mbcs_soft *soft;
750
751 dev->soft = NULL;
752
753 soft = kcalloc(1, sizeof(struct mbcs_soft), GFP_KERNEL);
754 if (soft == NULL)
755 return -ENOMEM;
756
757 soft->nasid = dev->cx_id.nasid;
758 list_add(&soft->list, &soft_list);
759 soft->mmr_base = (void *)tiocx_swin_base(dev->cx_id.nasid);
760 dev->soft = soft;
761 soft->cxdev = dev;
762
763 init_waitqueue_head(&soft->dmawrite_queue);
764 init_waitqueue_head(&soft->dmaread_queue);
765 init_waitqueue_head(&soft->algo_queue);
766
767 init_MUTEX(&soft->dmawritelock);
768 init_MUTEX(&soft->dmareadlock);
769 init_MUTEX(&soft->algolock);
770
771 mbcs_getdma_init(&soft->getdma);
772 mbcs_putdma_init(&soft->putdma);
773 mbcs_algo_init(&soft->algo);
774
775 mbcs_hw_init(soft);
776
777 /* Allocate interrupts */
778 mbcs_intr_alloc(dev);
779
780 device_create_file(&dev->dev, &dev_attr_algo);
781
782 return 0;
783}
784
785static int mbcs_remove(struct cx_dev *dev)
786{
787 if (dev->soft) {
788 mbcs_intr_dealloc(dev);
789 kfree(dev->soft);
790 }
791
792 device_remove_file(&dev->dev, &dev_attr_algo);
793
794 return 0;
795}
796
797const struct cx_device_id __devinitdata mbcs_id_table[] = {
798 {
799 .part_num = MBCS_PART_NUM,
800 .mfg_num = MBCS_MFG_NUM,
801 },
802 {
803 .part_num = MBCS_PART_NUM_ALG0,
804 .mfg_num = MBCS_MFG_NUM,
805 },
806 {0, 0}
807};
808
809MODULE_DEVICE_TABLE(cx, mbcs_id_table);
810
811struct cx_drv mbcs_driver = {
812 .name = DEVICE_NAME,
813 .id_table = mbcs_id_table,
814 .probe = mbcs_probe,
815 .remove = mbcs_remove,
816};
817
818static void __exit mbcs_exit(void)
819{
820 int rv;
821
822 rv = unregister_chrdev(mbcs_major, DEVICE_NAME);
823 if (rv < 0)
824 DBG(KERN_ALERT "Error in unregister_chrdev: %d\n", rv);
825
826 cx_driver_unregister(&mbcs_driver);
827}
828
829static int __init mbcs_init(void)
830{
831 int rv;
832
833 // Put driver into chrdevs[]. Get major number.
834 rv = register_chrdev(mbcs_major, DEVICE_NAME, &mbcs_ops);
835 if (rv < 0) {
836 DBG(KERN_ALERT "mbcs_init: can't get major number. %d\n", rv);
837 return rv;
838 }
839 mbcs_major = rv;
840
841 return cx_driver_register(&mbcs_driver);
842}
843
844module_init(mbcs_init);
845module_exit(mbcs_exit);
846
847MODULE_AUTHOR("Bruce Losure <blosure@sgi.com>");
848MODULE_DESCRIPTION("Driver for MOATB Core Services");
849MODULE_LICENSE("GPL");
diff --git a/drivers/char/mbcs.h b/drivers/char/mbcs.h
new file mode 100644
index 000000000000..e7fd47e43257
--- /dev/null
+++ b/drivers/char/mbcs.h
@@ -0,0 +1,553 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2005 Silicon Graphics, Inc. All rights reserved.
7 */
8
9#ifndef __MBCS_H__
10#define __MBCS_H__
11
12/*
13 * General macros
14 */
15#define MB (1024*1024)
16#define MB2 (2*MB)
17#define MB4 (4*MB)
18#define MB6 (6*MB)
19
20/*
21 * Offsets and masks
22 */
23#define MBCS_CM_ID 0x0000 /* Identification */
24#define MBCS_CM_STATUS 0x0008 /* Status */
25#define MBCS_CM_ERROR_DETAIL1 0x0010 /* Error Detail1 */
26#define MBCS_CM_ERROR_DETAIL2 0x0018 /* Error Detail2 */
27#define MBCS_CM_CONTROL 0x0020 /* Control */
28#define MBCS_CM_REQ_TOUT 0x0028 /* Request Time-out */
29#define MBCS_CM_ERR_INT_DEST 0x0038 /* Error Interrupt Destination */
30#define MBCS_CM_TARG_FL 0x0050 /* Target Flush */
31#define MBCS_CM_ERR_STAT 0x0060 /* Error Status */
32#define MBCS_CM_CLR_ERR_STAT 0x0068 /* Clear Error Status */
33#define MBCS_CM_ERR_INT_EN 0x0070 /* Error Interrupt Enable */
34#define MBCS_RD_DMA_SYS_ADDR 0x0100 /* Read DMA System Address */
35#define MBCS_RD_DMA_LOC_ADDR 0x0108 /* Read DMA Local Address */
36#define MBCS_RD_DMA_CTRL 0x0110 /* Read DMA Control */
37#define MBCS_RD_DMA_AMO_DEST 0x0118 /* Read DMA AMO Destination */
38#define MBCS_RD_DMA_INT_DEST 0x0120 /* Read DMA Interrupt Destination */
39#define MBCS_RD_DMA_AUX_STAT 0x0130 /* Read DMA Auxillary Status */
40#define MBCS_WR_DMA_SYS_ADDR 0x0200 /* Write DMA System Address */
41#define MBCS_WR_DMA_LOC_ADDR 0x0208 /* Write DMA Local Address */
42#define MBCS_WR_DMA_CTRL 0x0210 /* Write DMA Control */
43#define MBCS_WR_DMA_AMO_DEST 0x0218 /* Write DMA AMO Destination */
44#define MBCS_WR_DMA_INT_DEST 0x0220 /* Write DMA Interrupt Destination */
45#define MBCS_WR_DMA_AUX_STAT 0x0230 /* Write DMA Auxillary Status */
46#define MBCS_ALG_AMO_DEST 0x0300 /* Algorithm AMO Destination */
47#define MBCS_ALG_INT_DEST 0x0308 /* Algorithm Interrupt Destination */
48#define MBCS_ALG_OFFSETS 0x0310
49#define MBCS_ALG_STEP 0x0318 /* Algorithm Step */
50
51#define MBCS_GSCR_START 0x0000000
52#define MBCS_DEBUG_START 0x0100000
53#define MBCS_RAM0_START 0x0200000
54#define MBCS_RAM1_START 0x0400000
55#define MBCS_RAM2_START 0x0600000
56
57#define MBCS_CM_CONTROL_REQ_TOUT_MASK 0x0000000000ffffffUL
58//#define PIO_BASE_ADDR_BASE_OFFSET_MASK 0x00fffffffff00000UL
59
60#define MBCS_SRAM_SIZE (1024*1024)
61#define MBCS_CACHELINE_SIZE 128
62
63/*
64 * MMR get's and put's
65 */
66#define MBCS_MMR_ADDR(mmr_base, offset)((uint64_t *)(mmr_base + offset))
67#define MBCS_MMR_SET(mmr_base, offset, value) { \
68 uint64_t *mbcs_mmr_set_u64p, readback; \
69 mbcs_mmr_set_u64p = (uint64_t *)(mmr_base + offset); \
70 *mbcs_mmr_set_u64p = value; \
71 readback = *mbcs_mmr_set_u64p; \
72}
73#define MBCS_MMR_GET(mmr_base, offset) *(uint64_t *)(mmr_base + offset)
74#define MBCS_MMR_ZERO(mmr_base, offset) MBCS_MMR_SET(mmr_base, offset, 0)
75
76/*
77 * MBCS mmr structures
78 */
79union cm_id {
80 uint64_t cm_id_reg;
81 struct {
82 uint64_t always_one:1, // 0
83 mfg_id:11, // 11:1
84 part_num:16, // 27:12
85 bitstream_rev:8, // 35:28
86 :28; // 63:36
87 };
88};
89
90union cm_status {
91 uint64_t cm_status_reg;
92 struct {
93 uint64_t pending_reads:8, // 7:0
94 pending_writes:8, // 15:8
95 ice_rsp_credits:8, // 23:16
96 ice_req_credits:8, // 31:24
97 cm_req_credits:8, // 39:32
98 :1, // 40
99 rd_dma_in_progress:1, // 41
100 rd_dma_done:1, // 42
101 :1, // 43
102 wr_dma_in_progress:1, // 44
103 wr_dma_done:1, // 45
104 alg_waiting:1, // 46
105 alg_pipe_running:1, // 47
106 alg_done:1, // 48
107 :3, // 51:49
108 pending_int_reqs:8, // 59:52
109 :3, // 62:60
110 alg_half_speed_sel:1; // 63
111 };
112};
113
114union cm_error_detail1 {
115 uint64_t cm_error_detail1_reg;
116 struct {
117 uint64_t packet_type:4, // 3:0
118 source_id:2, // 5:4
119 data_size:2, // 7:6
120 tnum:8, // 15:8
121 byte_enable:8, // 23:16
122 gfx_cred:8, // 31:24
123 read_type:2, // 33:32
124 pio_or_memory:1, // 34
125 head_cw_error:1, // 35
126 :12, // 47:36
127 head_error_bit:1, // 48
128 data_error_bit:1, // 49
129 :13, // 62:50
130 valid:1; // 63
131 };
132};
133
134union cm_error_detail2 {
135 uint64_t cm_error_detail2_reg;
136 struct {
137 uint64_t address:56, // 55:0
138 :8; // 63:56
139 };
140};
141
142union cm_control {
143 uint64_t cm_control_reg;
144 struct {
145 uint64_t cm_id:2, // 1:0
146 :2, // 3:2
147 max_trans:5, // 8:4
148 :3, // 11:9
149 address_mode:1, // 12
150 :7, // 19:13
151 credit_limit:8, // 27:20
152 :5, // 32:28
153 rearm_stat_regs:1, // 33
154 prescalar_byp:1, // 34
155 force_gap_war:1, // 35
156 rd_dma_go:1, // 36
157 wr_dma_go:1, // 37
158 alg_go:1, // 38
159 rd_dma_clr:1, // 39
160 wr_dma_clr:1, // 40
161 alg_clr:1, // 41
162 :2, // 43:42
163 alg_wait_step:1, // 44
164 alg_done_amo_en:1, // 45
165 alg_done_int_en:1, // 46
166 :1, // 47
167 alg_sram0_locked:1, // 48
168 alg_sram1_locked:1, // 49
169 alg_sram2_locked:1, // 50
170 alg_done_clr:1, // 51
171 :12; // 63:52
172 };
173};
174
175union cm_req_timeout {
176 uint64_t cm_req_timeout_reg;
177 struct {
178 uint64_t time_out:24, // 23:0
179 :40; // 63:24
180 };
181};
182
183union intr_dest {
184 uint64_t intr_dest_reg;
185 struct {
186 uint64_t address:56, // 55:0
187 int_vector:8; // 63:56
188 };
189};
190
191union cm_error_status {
192 uint64_t cm_error_status_reg;
193 struct {
194 uint64_t ecc_sbe:1, // 0
195 ecc_mbe:1, // 1
196 unsupported_req:1, // 2
197 unexpected_rsp:1, // 3
198 bad_length:1, // 4
199 bad_datavalid:1, // 5
200 buffer_overflow:1, // 6
201 request_timeout:1, // 7
202 :8, // 15:8
203 head_inv_data_size:1, // 16
204 rsp_pactype_inv:1, // 17
205 head_sb_err:1, // 18
206 missing_head:1, // 19
207 head_inv_rd_type:1, // 20
208 head_cmd_err_bit:1, // 21
209 req_addr_align_inv:1, // 22
210 pio_req_addr_inv:1, // 23
211 req_range_dsize_inv:1, // 24
212 early_term:1, // 25
213 early_tail:1, // 26
214 missing_tail:1, // 27
215 data_flit_sb_err:1, // 28
216 cm2hcm_req_cred_of:1, // 29
217 cm2hcm_rsp_cred_of:1, // 30
218 rx_bad_didn:1, // 31
219 rd_dma_err_rsp:1, // 32
220 rd_dma_tnum_tout:1, // 33
221 rd_dma_multi_tnum_tou:1, // 34
222 wr_dma_err_rsp:1, // 35
223 wr_dma_tnum_tout:1, // 36
224 wr_dma_multi_tnum_tou:1, // 37
225 alg_data_overflow:1, // 38
226 alg_data_underflow:1, // 39
227 ram0_access_conflict:1, // 40
228 ram1_access_conflict:1, // 41
229 ram2_access_conflict:1, // 42
230 ram0_perr:1, // 43
231 ram1_perr:1, // 44
232 ram2_perr:1, // 45
233 int_gen_rsp_err:1, // 46
234 int_gen_tnum_tout:1, // 47
235 rd_dma_prog_err:1, // 48
236 wr_dma_prog_err:1, // 49
237 :14; // 63:50
238 };
239};
240
241union cm_clr_error_status {
242 uint64_t cm_clr_error_status_reg;
243 struct {
244 uint64_t clr_ecc_sbe:1, // 0
245 clr_ecc_mbe:1, // 1
246 clr_unsupported_req:1, // 2
247 clr_unexpected_rsp:1, // 3
248 clr_bad_length:1, // 4
249 clr_bad_datavalid:1, // 5
250 clr_buffer_overflow:1, // 6
251 clr_request_timeout:1, // 7
252 :8, // 15:8
253 clr_head_inv_data_siz:1, // 16
254 clr_rsp_pactype_inv:1, // 17
255 clr_head_sb_err:1, // 18
256 clr_missing_head:1, // 19
257 clr_head_inv_rd_type:1, // 20
258 clr_head_cmd_err_bit:1, // 21
259 clr_req_addr_align_in:1, // 22
260 clr_pio_req_addr_inv:1, // 23
261 clr_req_range_dsize_i:1, // 24
262 clr_early_term:1, // 25
263 clr_early_tail:1, // 26
264 clr_missing_tail:1, // 27
265 clr_data_flit_sb_err:1, // 28
266 clr_cm2hcm_req_cred_o:1, // 29
267 clr_cm2hcm_rsp_cred_o:1, // 30
268 clr_rx_bad_didn:1, // 31
269 clr_rd_dma_err_rsp:1, // 32
270 clr_rd_dma_tnum_tout:1, // 33
271 clr_rd_dma_multi_tnum:1, // 34
272 clr_wr_dma_err_rsp:1, // 35
273 clr_wr_dma_tnum_tout:1, // 36
274 clr_wr_dma_multi_tnum:1, // 37
275 clr_alg_data_overflow:1, // 38
276 clr_alg_data_underflo:1, // 39
277 clr_ram0_access_confl:1, // 40
278 clr_ram1_access_confl:1, // 41
279 clr_ram2_access_confl:1, // 42
280 clr_ram0_perr:1, // 43
281 clr_ram1_perr:1, // 44
282 clr_ram2_perr:1, // 45
283 clr_int_gen_rsp_err:1, // 46
284 clr_int_gen_tnum_tout:1, // 47
285 clr_rd_dma_prog_err:1, // 48
286 clr_wr_dma_prog_err:1, // 49
287 :14; // 63:50
288 };
289};
290
291union cm_error_intr_enable {
292 uint64_t cm_error_intr_enable_reg;
293 struct {
294 uint64_t int_en_ecc_sbe:1, // 0
295 int_en_ecc_mbe:1, // 1
296 int_en_unsupported_re:1, // 2
297 int_en_unexpected_rsp:1, // 3
298 int_en_bad_length:1, // 4
299 int_en_bad_datavalid:1, // 5
300 int_en_buffer_overflo:1, // 6
301 int_en_request_timeou:1, // 7
302 :8, // 15:8
303 int_en_head_inv_data_:1, // 16
304 int_en_rsp_pactype_in:1, // 17
305 int_en_head_sb_err:1, // 18
306 int_en_missing_head:1, // 19
307 int_en_head_inv_rd_ty:1, // 20
308 int_en_head_cmd_err_b:1, // 21
309 int_en_req_addr_align:1, // 22
310 int_en_pio_req_addr_i:1, // 23
311 int_en_req_range_dsiz:1, // 24
312 int_en_early_term:1, // 25
313 int_en_early_tail:1, // 26
314 int_en_missing_tail:1, // 27
315 int_en_data_flit_sb_e:1, // 28
316 int_en_cm2hcm_req_cre:1, // 29
317 int_en_cm2hcm_rsp_cre:1, // 30
318 int_en_rx_bad_didn:1, // 31
319 int_en_rd_dma_err_rsp:1, // 32
320 int_en_rd_dma_tnum_to:1, // 33
321 int_en_rd_dma_multi_t:1, // 34
322 int_en_wr_dma_err_rsp:1, // 35
323 int_en_wr_dma_tnum_to:1, // 36
324 int_en_wr_dma_multi_t:1, // 37
325 int_en_alg_data_overf:1, // 38
326 int_en_alg_data_under:1, // 39
327 int_en_ram0_access_co:1, // 40
328 int_en_ram1_access_co:1, // 41
329 int_en_ram2_access_co:1, // 42
330 int_en_ram0_perr:1, // 43
331 int_en_ram1_perr:1, // 44
332 int_en_ram2_perr:1, // 45
333 int_en_int_gen_rsp_er:1, // 46
334 int_en_int_gen_tnum_t:1, // 47
335 int_en_rd_dma_prog_er:1, // 48
336 int_en_wr_dma_prog_er:1, // 49
337 :14; // 63:50
338 };
339};
340
341struct cm_mmr {
342 union cm_id id;
343 union cm_status status;
344 union cm_error_detail1 err_detail1;
345 union cm_error_detail2 err_detail2;
346 union cm_control control;
347 union cm_req_timeout req_timeout;
348 uint64_t reserved1[1];
349 union intr_dest int_dest;
350 uint64_t reserved2[2];
351 uint64_t targ_flush;
352 uint64_t reserved3[1];
353 union cm_error_status err_status;
354 union cm_clr_error_status clr_err_status;
355 union cm_error_intr_enable int_enable;
356};
357
358union dma_hostaddr {
359 uint64_t dma_hostaddr_reg;
360 struct {
361 uint64_t dma_sys_addr:56, // 55:0
362 :8; // 63:56
363 };
364};
365
366union dma_localaddr {
367 uint64_t dma_localaddr_reg;
368 struct {
369 uint64_t dma_ram_addr:21, // 20:0
370 dma_ram_sel:2, // 22:21
371 :41; // 63:23
372 };
373};
374
375union dma_control {
376 uint64_t dma_control_reg;
377 struct {
378 uint64_t dma_op_length:16, // 15:0
379 :18, // 33:16
380 done_amo_en:1, // 34
381 done_int_en:1, // 35
382 :1, // 36
383 pio_mem_n:1, // 37
384 :26; // 63:38
385 };
386};
387
388union dma_amo_dest {
389 uint64_t dma_amo_dest_reg;
390 struct {
391 uint64_t dma_amo_sys_addr:56, // 55:0
392 dma_amo_mod_type:3, // 58:56
393 :5; // 63:59
394 };
395};
396
397union rdma_aux_status {
398 uint64_t rdma_aux_status_reg;
399 struct {
400 uint64_t op_num_pacs_left:17, // 16:0
401 :5, // 21:17
402 lrsp_buff_empty:1, // 22
403 :17, // 39:23
404 pending_reqs_left:6, // 45:40
405 :18; // 63:46
406 };
407};
408
409struct rdma_mmr {
410 union dma_hostaddr host_addr;
411 union dma_localaddr local_addr;
412 union dma_control control;
413 union dma_amo_dest amo_dest;
414 union intr_dest intr_dest;
415 union rdma_aux_status aux_status;
416};
417
418union wdma_aux_status {
419 uint64_t wdma_aux_status_reg;
420 struct {
421 uint64_t op_num_pacs_left:17, // 16:0
422 :4, // 20:17
423 lreq_buff_empty:1, // 21
424 :18, // 39:22
425 pending_reqs_left:6, // 45:40
426 :18; // 63:46
427 };
428};
429
430struct wdma_mmr {
431 union dma_hostaddr host_addr;
432 union dma_localaddr local_addr;
433 union dma_control control;
434 union dma_amo_dest amo_dest;
435 union intr_dest intr_dest;
436 union wdma_aux_status aux_status;
437};
438
439union algo_step {
440 uint64_t algo_step_reg;
441 struct {
442 uint64_t alg_step_cnt:16, // 15:0
443 :48; // 63:16
444 };
445};
446
447struct algo_mmr {
448 union dma_amo_dest amo_dest;
449 union intr_dest intr_dest;
450 union {
451 uint64_t algo_offset_reg;
452 struct {
453 uint64_t sram0_offset:7, // 6:0
454 reserved0:1, // 7
455 sram1_offset:7, // 14:8
456 reserved1:1, // 15
457 sram2_offset:7, // 22:16
458 reserved2:14; // 63:23
459 };
460 } sram_offset;
461 union algo_step step;
462};
463
464struct mbcs_mmr {
465 struct cm_mmr cm;
466 uint64_t reserved1[17];
467 struct rdma_mmr rdDma;
468 uint64_t reserved2[25];
469 struct wdma_mmr wrDma;
470 uint64_t reserved3[25];
471 struct algo_mmr algo;
472 uint64_t reserved4[156];
473};
474
475/*
476 * defines
477 */
478#define DEVICE_NAME "mbcs"
479#define MBCS_PART_NUM 0xfff0
480#define MBCS_PART_NUM_ALG0 0xf001
481#define MBCS_MFG_NUM 0x1
482
483struct algoblock {
484 uint64_t amoHostDest;
485 uint64_t amoModType;
486 uint64_t intrHostDest;
487 uint64_t intrVector;
488 uint64_t algoStepCount;
489};
490
491struct getdma {
492 uint64_t hostAddr;
493 uint64_t localAddr;
494 uint64_t bytes;
495 uint64_t DoneAmoEnable;
496 uint64_t DoneIntEnable;
497 uint64_t peerIO;
498 uint64_t amoHostDest;
499 uint64_t amoModType;
500 uint64_t intrHostDest;
501 uint64_t intrVector;
502};
503
504struct putdma {
505 uint64_t hostAddr;
506 uint64_t localAddr;
507 uint64_t bytes;
508 uint64_t DoneAmoEnable;
509 uint64_t DoneIntEnable;
510 uint64_t peerIO;
511 uint64_t amoHostDest;
512 uint64_t amoModType;
513 uint64_t intrHostDest;
514 uint64_t intrVector;
515};
516
517struct mbcs_soft {
518 struct list_head list;
519 struct cx_dev *cxdev;
520 int major;
521 int nasid;
522 void *mmr_base;
523 wait_queue_head_t dmawrite_queue;
524 wait_queue_head_t dmaread_queue;
525 wait_queue_head_t algo_queue;
526 struct sn_irq_info *get_sn_irq;
527 struct sn_irq_info *put_sn_irq;
528 struct sn_irq_info *algo_sn_irq;
529 struct getdma getdma;
530 struct putdma putdma;
531 struct algoblock algo;
532 uint64_t gscr_addr; // pio addr
533 uint64_t ram0_addr; // pio addr
534 uint64_t ram1_addr; // pio addr
535 uint64_t ram2_addr; // pio addr
536 uint64_t debug_addr; // pio addr
537 atomic_t dmawrite_done;
538 atomic_t dmaread_done;
539 atomic_t algo_done;
540 struct semaphore dmawritelock;
541 struct semaphore dmareadlock;
542 struct semaphore algolock;
543};
544
545extern int mbcs_open(struct inode *ip, struct file *fp);
546extern ssize_t mbcs_sram_read(struct file *fp, char __user *buf, size_t len,
547 loff_t * off);
548extern ssize_t mbcs_sram_write(struct file *fp, const char __user *buf, size_t len,
549 loff_t * off);
550extern loff_t mbcs_sram_llseek(struct file *filp, loff_t off, int whence);
551extern int mbcs_gscr_mmap(struct file *fp, struct vm_area_struct *vma);
552
553#endif // __MBCS_H__
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index a91ae271cf0a..763893e289b3 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -221,7 +221,7 @@ static int rio_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000};
221/* Set the mask to all-ones. This alas, only supports 32 interrupts. 221/* Set the mask to all-ones. This alas, only supports 32 interrupts.
222 Some architectures may need more. -- Changed to LONG to 222 Some architectures may need more. -- Changed to LONG to
223 support up to 64 bits on 64bit architectures. -- REW 20/06/99 */ 223 support up to 64 bits on 64bit architectures. -- REW 20/06/99 */
224long rio_irqmask = -1; 224static long rio_irqmask = -1;
225 225
226MODULE_AUTHOR("Rogier Wolff <R.E.Wolff@bitwizard.nl>, Patrick van de Lageweg <patrick@bitwizard.nl>"); 226MODULE_AUTHOR("Rogier Wolff <R.E.Wolff@bitwizard.nl>, Patrick van de Lageweg <patrick@bitwizard.nl>");
227MODULE_DESCRIPTION("RIO driver"); 227MODULE_DESCRIPTION("RIO driver");
diff --git a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c
index 8e61be34a1d3..ed867db550a9 100644
--- a/drivers/char/s3c2410-rtc.c
+++ b/drivers/char/s3c2410-rtc.c
@@ -116,7 +116,7 @@ static void s3c2410_rtc_setfreq(int freq)
116 116
117/* Time read/write */ 117/* Time read/write */
118 118
119static void s3c2410_rtc_gettime(struct rtc_time *rtc_tm) 119static int s3c2410_rtc_gettime(struct rtc_time *rtc_tm)
120{ 120{
121 unsigned int have_retried = 0; 121 unsigned int have_retried = 0;
122 122
@@ -151,6 +151,8 @@ static void s3c2410_rtc_gettime(struct rtc_time *rtc_tm)
151 151
152 rtc_tm->tm_year += 100; 152 rtc_tm->tm_year += 100;
153 rtc_tm->tm_mon -= 1; 153 rtc_tm->tm_mon -= 1;
154
155 return 0;
154} 156}
155 157
156 158
@@ -171,7 +173,7 @@ static int s3c2410_rtc_settime(struct rtc_time *tm)
171 return 0; 173 return 0;
172} 174}
173 175
174static void s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm) 176static int s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm)
175{ 177{
176 struct rtc_time *alm_tm = &alrm->time; 178 struct rtc_time *alm_tm = &alrm->time;
177 unsigned int alm_en; 179 unsigned int alm_en;
@@ -231,6 +233,8 @@ static void s3c2410_rtc_getalarm(struct rtc_wkalrm *alrm)
231 } 233 }
232 234
233 /* todo - set alrm->enabled ? */ 235 /* todo - set alrm->enabled ? */
236
237 return 0;
234} 238}
235 239
236static int s3c2410_rtc_setalarm(struct rtc_wkalrm *alrm) 240static int s3c2410_rtc_setalarm(struct rtc_wkalrm *alrm)
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index ffb9143376bb..e3c0b52d943f 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -374,6 +374,7 @@ scdrv_init(void)
374 void *salbuf; 374 void *salbuf;
375 struct class_simple *snsc_class; 375 struct class_simple *snsc_class;
376 dev_t first_dev, dev; 376 dev_t first_dev, dev;
377 nasid_t event_nasid = ia64_sn_get_console_nasid();
377 378
378 if (alloc_chrdev_region(&first_dev, 0, numionodes, 379 if (alloc_chrdev_region(&first_dev, 0, numionodes,
379 SYSCTL_BASENAME) < 0) { 380 SYSCTL_BASENAME) < 0) {
@@ -441,6 +442,13 @@ scdrv_init(void)
441 ia64_sn_irtr_intr_enable(scd->scd_nasid, 442 ia64_sn_irtr_intr_enable(scd->scd_nasid,
442 0 /*ignored */ , 443 0 /*ignored */ ,
443 SAL_IROUTER_INTR_RECV); 444 SAL_IROUTER_INTR_RECV);
445
446 /* on the console nasid, prepare to receive
447 * system controller environmental events
448 */
449 if(scd->scd_nasid == event_nasid) {
450 scdrv_event_init(scd);
451 }
444 } 452 }
445 return 0; 453 return 0;
446} 454}
diff --git a/drivers/char/snsc.h b/drivers/char/snsc.h
index c22c6c55e254..a9efc13cc858 100644
--- a/drivers/char/snsc.h
+++ b/drivers/char/snsc.h
@@ -47,4 +47,44 @@ struct sysctl_data_s {
47 nasid_t scd_nasid; /* Node on which subchannels are opened. */ 47 nasid_t scd_nasid; /* Node on which subchannels are opened. */
48}; 48};
49 49
50
51/* argument types */
52#define IR_ARG_INT 0x00 /* 4-byte integer (big-endian) */
53#define IR_ARG_ASCII 0x01 /* null-terminated ASCII string */
54#define IR_ARG_UNKNOWN 0x80 /* unknown data type. The low
55 * 7 bits will contain the data
56 * length. */
57#define IR_ARG_UNKNOWN_LENGTH_MASK 0x7f
58
59
60/* system controller event codes */
61#define EV_CLASS_MASK 0xf000ul
62#define EV_SEVERITY_MASK 0x0f00ul
63#define EV_COMPONENT_MASK 0x00fful
64
65#define EV_CLASS_POWER 0x1000ul
66#define EV_CLASS_FAN 0x2000ul
67#define EV_CLASS_TEMP 0x3000ul
68#define EV_CLASS_ENV 0x4000ul
69#define EV_CLASS_TEST_FAULT 0x5000ul
70#define EV_CLASS_TEST_WARNING 0x6000ul
71#define EV_CLASS_PWRD_NOTIFY 0x8000ul
72
73#define EV_SEVERITY_POWER_STABLE 0x0000ul
74#define EV_SEVERITY_POWER_LOW_WARNING 0x0100ul
75#define EV_SEVERITY_POWER_HIGH_WARNING 0x0200ul
76#define EV_SEVERITY_POWER_HIGH_FAULT 0x0300ul
77#define EV_SEVERITY_POWER_LOW_FAULT 0x0400ul
78
79#define EV_SEVERITY_FAN_STABLE 0x0000ul
80#define EV_SEVERITY_FAN_WARNING 0x0100ul
81#define EV_SEVERITY_FAN_FAULT 0x0200ul
82
83#define EV_SEVERITY_TEMP_STABLE 0x0000ul
84#define EV_SEVERITY_TEMP_ADVISORY 0x0100ul
85#define EV_SEVERITY_TEMP_CRITICAL 0x0200ul
86#define EV_SEVERITY_TEMP_FAULT 0x0300ul
87
88void scdrv_event_init(struct sysctl_data_s *);
89
50#endif /* _SN_SYSCTL_H_ */ 90#endif /* _SN_SYSCTL_H_ */
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c
new file mode 100644
index 000000000000..d692af57213a
--- /dev/null
+++ b/drivers/char/snsc_event.c
@@ -0,0 +1,304 @@
1/*
2 * SN Platform system controller communication support
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved.
9 */
10
11/*
12 * System controller event handler
13 *
14 * These routines deal with environmental events arriving from the
15 * system controllers.
16 */
17
18#include <linux/interrupt.h>
19#include <linux/sched.h>
20#include <linux/byteorder/generic.h>
21#include <asm/sn/sn_sal.h>
22#include "snsc.h"
23
24static struct subch_data_s *event_sd;
25
26void scdrv_event(unsigned long);
27DECLARE_TASKLET(sn_sysctl_event, scdrv_event, 0);
28
29/*
30 * scdrv_event_interrupt
31 *
32 * Pull incoming environmental events off the physical link to the
33 * system controller and put them in a temporary holding area in SAL.
34 * Schedule scdrv_event() to move them along to their ultimate
35 * destination.
36 */
37static irqreturn_t
38scdrv_event_interrupt(int irq, void *subch_data, struct pt_regs *regs)
39{
40 struct subch_data_s *sd = subch_data;
41 unsigned long flags;
42 int status;
43
44 spin_lock_irqsave(&sd->sd_rlock, flags);
45 status = ia64_sn_irtr_intr(sd->sd_nasid, sd->sd_subch);
46
47 if ((status > 0) && (status & SAL_IROUTER_INTR_RECV)) {
48 tasklet_schedule(&sn_sysctl_event);
49 }
50 spin_unlock_irqrestore(&sd->sd_rlock, flags);
51 return IRQ_HANDLED;
52}
53
54
55/*
56 * scdrv_parse_event
57 *
58 * Break an event (as read from SAL) into useful pieces so we can decide
59 * what to do with it.
60 */
61static int
62scdrv_parse_event(char *event, int *src, int *code, int *esp_code, char *desc)
63{
64 char *desc_end;
65
66 /* record event source address */
67 *src = be32_to_cpup((__be32 *)event);
68 event += 4; /* move on to event code */
69
70 /* record the system controller's event code */
71 *code = be32_to_cpup((__be32 *)event);
72 event += 4; /* move on to event arguments */
73
74 /* how many arguments are in the packet? */
75 if (*event++ != 2) {
76 /* if not 2, give up */
77 return -1;
78 }
79
80 /* parse out the ESP code */
81 if (*event++ != IR_ARG_INT) {
82 /* not an integer argument, so give up */
83 return -1;
84 }
85 *esp_code = be32_to_cpup((__be32 *)event);
86 event += 4;
87
88 /* parse out the event description */
89 if (*event++ != IR_ARG_ASCII) {
90 /* not an ASCII string, so give up */
91 return -1;
92 }
93 event[CHUNKSIZE-1] = '\0'; /* ensure this string ends! */
94 event += 2; /* skip leading CR/LF */
95 desc_end = desc + sprintf(desc, "%s", event);
96
97 /* strip trailing CR/LF (if any) */
98 for (desc_end--;
99 (desc_end != desc) && ((*desc_end == 0xd) || (*desc_end == 0xa));
100 desc_end--) {
101 *desc_end = '\0';
102 }
103
104 return 0;
105}
106
107
108/*
109 * scdrv_event_severity
110 *
111 * Figure out how urgent a message we should write to the console/syslog
112 * via printk.
113 */
114static char *
115scdrv_event_severity(int code)
116{
117 int ev_class = (code & EV_CLASS_MASK);
118 int ev_severity = (code & EV_SEVERITY_MASK);
119 char *pk_severity = KERN_NOTICE;
120
121 switch (ev_class) {
122 case EV_CLASS_POWER:
123 switch (ev_severity) {
124 case EV_SEVERITY_POWER_LOW_WARNING:
125 case EV_SEVERITY_POWER_HIGH_WARNING:
126 pk_severity = KERN_WARNING;
127 break;
128 case EV_SEVERITY_POWER_HIGH_FAULT:
129 case EV_SEVERITY_POWER_LOW_FAULT:
130 pk_severity = KERN_ALERT;
131 break;
132 }
133 break;
134 case EV_CLASS_FAN:
135 switch (ev_severity) {
136 case EV_SEVERITY_FAN_WARNING:
137 pk_severity = KERN_WARNING;
138 break;
139 case EV_SEVERITY_FAN_FAULT:
140 pk_severity = KERN_CRIT;
141 break;
142 }
143 break;
144 case EV_CLASS_TEMP:
145 switch (ev_severity) {
146 case EV_SEVERITY_TEMP_ADVISORY:
147 pk_severity = KERN_WARNING;
148 break;
149 case EV_SEVERITY_TEMP_CRITICAL:
150 pk_severity = KERN_CRIT;
151 break;
152 case EV_SEVERITY_TEMP_FAULT:
153 pk_severity = KERN_ALERT;
154 break;
155 }
156 break;
157 case EV_CLASS_ENV:
158 pk_severity = KERN_ALERT;
159 break;
160 case EV_CLASS_TEST_FAULT:
161 pk_severity = KERN_ALERT;
162 break;
163 case EV_CLASS_TEST_WARNING:
164 pk_severity = KERN_WARNING;
165 break;
166 case EV_CLASS_PWRD_NOTIFY:
167 pk_severity = KERN_ALERT;
168 break;
169 }
170
171 return pk_severity;
172}
173
174
175/*
176 * scdrv_dispatch_event
177 *
178 * Do the right thing with an incoming event. That's often nothing
179 * more than printing it to the system log. For power-down notifications
180 * we start a graceful shutdown.
181 */
182static void
183scdrv_dispatch_event(char *event, int len)
184{
185 int code, esp_code, src;
186 char desc[CHUNKSIZE];
187 char *severity;
188
189 if (scdrv_parse_event(event, &src, &code, &esp_code, desc) < 0) {
190 /* ignore uninterpretible event */
191 return;
192 }
193
194 /* how urgent is the message? */
195 severity = scdrv_event_severity(code);
196
197 if ((code & EV_CLASS_MASK) == EV_CLASS_PWRD_NOTIFY) {
198 struct task_struct *p;
199
200 /* give a SIGPWR signal to init proc */
201
202 /* first find init's task */
203 read_lock(&tasklist_lock);
204 for_each_process(p) {
205 if (p->pid == 1)
206 break;
207 }
208 if (p) { /* we found init's task */
209 printk(KERN_EMERG "Power off indication received. Initiating power fail sequence...\n");
210 force_sig(SIGPWR, p);
211 } else { /* failed to find init's task - just give message(s) */
212 printk(KERN_WARNING "Failed to find init proc to handle power off!\n");
213 printk("%s|$(0x%x)%s\n", severity, esp_code, desc);
214 }
215 read_unlock(&tasklist_lock);
216 } else {
217 /* print to system log */
218 printk("%s|$(0x%x)%s\n", severity, esp_code, desc);
219 }
220}
221
222
223/*
224 * scdrv_event
225 *
226 * Called as a tasklet when an event arrives from the L1. Read the event
227 * from where it's temporarily stored in SAL and call scdrv_dispatch_event()
228 * to send it on its way. Keep trying to read events until SAL indicates
229 * that there are no more immediately available.
230 */
231void
232scdrv_event(unsigned long dummy)
233{
234 int status;
235 int len;
236 unsigned long flags;
237 struct subch_data_s *sd = event_sd;
238
239 /* anything to read? */
240 len = CHUNKSIZE;
241 spin_lock_irqsave(&sd->sd_rlock, flags);
242 status = ia64_sn_irtr_recv(sd->sd_nasid, sd->sd_subch,
243 sd->sd_rb, &len);
244
245 while (!(status < 0)) {
246 spin_unlock_irqrestore(&sd->sd_rlock, flags);
247 scdrv_dispatch_event(sd->sd_rb, len);
248 len = CHUNKSIZE;
249 spin_lock_irqsave(&sd->sd_rlock, flags);
250 status = ia64_sn_irtr_recv(sd->sd_nasid, sd->sd_subch,
251 sd->sd_rb, &len);
252 }
253 spin_unlock_irqrestore(&sd->sd_rlock, flags);
254}
255
256
257/*
258 * scdrv_event_init
259 *
260 * Sets up a system controller subchannel to begin receiving event
261 * messages. This is sort of a specialized version of scdrv_open()
262 * in drivers/char/sn_sysctl.c.
263 */
264void
265scdrv_event_init(struct sysctl_data_s *scd)
266{
267 int rv;
268
269 event_sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL);
270 if (event_sd == NULL) {
271 printk(KERN_WARNING "%s: couldn't allocate subchannel info"
272 " for event monitoring\n", __FUNCTION__);
273 return;
274 }
275
276 /* initialize subch_data_s fields */
277 memset(event_sd, 0, sizeof (struct subch_data_s));
278 event_sd->sd_nasid = scd->scd_nasid;
279 spin_lock_init(&event_sd->sd_rlock);
280
281 /* ask the system controllers to send events to this node */
282 event_sd->sd_subch = ia64_sn_sysctl_event_init(scd->scd_nasid);
283
284 if (event_sd->sd_subch < 0) {
285 kfree(event_sd);
286 printk(KERN_WARNING "%s: couldn't open event subchannel\n",
287 __FUNCTION__);
288 return;
289 }
290
291 /* hook event subchannel up to the system controller interrupt */
292 rv = request_irq(SGI_UART_VECTOR, scdrv_event_interrupt,
293 SA_SHIRQ | SA_INTERRUPT,
294 "system controller events", event_sd);
295 if (rv) {
296 printk(KERN_WARNING "%s: irq request failed (%d)\n",
297 __FUNCTION__, rv);
298 ia64_sn_irtr_close(event_sd->sd_nasid, event_sd->sd_subch);
299 kfree(event_sd);
300 return;
301 }
302}
303
304
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index c812191417c3..fd042060809a 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -1021,11 +1021,11 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
1021 ret = -EIO; 1021 ret = -EIO;
1022 break; 1022 break;
1023 } 1023 }
1024 if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) 1024 if (copy_to_user(argp, &val8, sizeof(val8)))
1025 ret = -EFAULT; 1025 ret = -EFAULT;
1026 break; 1026 break;
1027 case SONYPI_IOCSFAN: 1027 case SONYPI_IOCSFAN:
1028 if (copy_from_user(&val8, (u8 *)arg, sizeof(val8))) { 1028 if (copy_from_user(&val8, argp, sizeof(val8))) {
1029 ret = -EFAULT; 1029 ret = -EFAULT;
1030 break; 1030 break;
1031 } 1031 }
@@ -1038,7 +1038,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
1038 ret = -EIO; 1038 ret = -EIO;
1039 break; 1039 break;
1040 } 1040 }
1041 if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) 1041 if (copy_to_user(argp, &val8, sizeof(val8)))
1042 ret = -EFAULT; 1042 ret = -EFAULT;
1043 break; 1043 break;
1044 default: 1044 default:
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index c789d5ceac76..50e0b612a8a2 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -1987,10 +1987,9 @@ static inline int sx_set_serial_info(struct specialix_port * port,
1987 1987
1988 func_enter(); 1988 func_enter();
1989 /* 1989 /*
1990 error = verify_area(VERIFY_READ, (void *) newinfo, sizeof(tmp)); 1990 if (!access_ok(VERIFY_READ, (void *) newinfo, sizeof(tmp))) {
1991 if (error) {
1992 func_exit(); 1991 func_exit();
1993 return error; 1992 return -EFAULT;
1994 } 1993 }
1995 */ 1994 */
1996 if (copy_from_user(&tmp, newinfo, sizeof(tmp))) { 1995 if (copy_from_user(&tmp, newinfo, sizeof(tmp))) {
@@ -2046,14 +2045,12 @@ static inline int sx_get_serial_info(struct specialix_port * port,
2046{ 2045{
2047 struct serial_struct tmp; 2046 struct serial_struct tmp;
2048 struct specialix_board *bp = port_Board(port); 2047 struct specialix_board *bp = port_Board(port);
2049 // int error;
2050 2048
2051 func_enter(); 2049 func_enter();
2052 2050
2053 /* 2051 /*
2054 error = verify_area(VERIFY_WRITE, (void *) retinfo, sizeof(tmp)); 2052 if (!access_ok(VERIFY_WRITE, (void *) retinfo, sizeof(tmp)))
2055 if (error) 2053 return -EFAULT;
2056 return error;
2057 */ 2054 */
2058 2055
2059 memset(&tmp, 0, sizeof(tmp)); 2056 memset(&tmp, 0, sizeof(tmp));
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index de166608c59e..b8899f560b5e 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -466,7 +466,7 @@ static int stl_parsebrd(stlconf_t *confp, char **argp);
466 466
467static unsigned long stl_atol(char *str); 467static unsigned long stl_atol(char *str);
468 468
469int stl_init(void); 469static int stl_init(void);
470static int stl_open(struct tty_struct *tty, struct file *filp); 470static int stl_open(struct tty_struct *tty, struct file *filp);
471static void stl_close(struct tty_struct *tty, struct file *filp); 471static void stl_close(struct tty_struct *tty, struct file *filp);
472static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count); 472static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count);
@@ -3063,7 +3063,7 @@ static struct tty_operations stl_ops = {
3063 3063
3064/*****************************************************************************/ 3064/*****************************************************************************/
3065 3065
3066int __init stl_init(void) 3066static int __init stl_init(void)
3067{ 3067{
3068 int i; 3068 int i;
3069 printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion); 3069 printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion);
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index ca36087d4f8a..87235330fdbe 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -143,7 +143,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
143 return -ENODATA; 143 return -ENODATA;
144 if (count > bufsiz) { 144 if (count > bufsiz) {
145 dev_err(&chip->pci_dev->dev, 145 dev_err(&chip->pci_dev->dev,
146 "invalid count value %x %x \n", count, bufsiz); 146 "invalid count value %x %zx \n", count, bufsiz);
147 return -E2BIG; 147 return -E2BIG;
148 } 148 }
149 149
@@ -151,7 +151,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
151 151
152 if ((len = chip->vendor->send(chip, (u8 *) buf, count)) < 0) { 152 if ((len = chip->vendor->send(chip, (u8 *) buf, count)) < 0) {
153 dev_err(&chip->pci_dev->dev, 153 dev_err(&chip->pci_dev->dev,
154 "tpm_transmit: tpm_send: error %d\n", len); 154 "tpm_transmit: tpm_send: error %zd\n", len);
155 return len; 155 return len;
156 } 156 }
157 157
@@ -188,7 +188,7 @@ out_recv:
188 len = chip->vendor->recv(chip, (u8 *) buf, bufsiz); 188 len = chip->vendor->recv(chip, (u8 *) buf, bufsiz);
189 if (len < 0) 189 if (len < 0)
190 dev_err(&chip->pci_dev->dev, 190 dev_err(&chip->pci_dev->dev,
191 "tpm_transmit: tpm_recv: error %d\n", len); 191 "tpm_transmit: tpm_recv: error %zd\n", len);
192 up(&chip->tpm_mutex); 192 up(&chip->tpm_mutex);
193 return len; 193 return len;
194} 194}
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 06e5a3f1836d..26e5e19ed854 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -185,7 +185,7 @@ char *tty_name(struct tty_struct *tty, char *buf)
185 185
186EXPORT_SYMBOL(tty_name); 186EXPORT_SYMBOL(tty_name);
187 187
188inline int tty_paranoia_check(struct tty_struct *tty, struct inode *inode, 188int tty_paranoia_check(struct tty_struct *tty, struct inode *inode,
189 const char *routine) 189 const char *routine)
190{ 190{
191#ifdef TTY_PARANOIA_CHECK 191#ifdef TTY_PARANOIA_CHECK
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index 5d386f4bea49..8971484b956b 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -24,6 +24,7 @@
24#include <linux/major.h> 24#include <linux/major.h>
25#include <linux/fs.h> 25#include <linux/fs.h>
26#include <linux/console.h> 26#include <linux/console.h>
27#include <linux/signal.h>
27 28
28#include <asm/io.h> 29#include <asm/io.h>
29#include <asm/uaccess.h> 30#include <asm/uaccess.h>
@@ -641,7 +642,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
641 extern int spawnpid, spawnsig; 642 extern int spawnpid, spawnsig;
642 if (!perm || !capable(CAP_KILL)) 643 if (!perm || !capable(CAP_KILL))
643 return -EPERM; 644 return -EPERM;
644 if (arg < 1 || arg > _NSIG || arg == SIGKILL) 645 if (!valid_signal(arg) || arg < 1 || arg == SIGKILL)
645 return -EINVAL; 646 return -EINVAL;
646 spawnpid = current->pid; 647 spawnpid = current->pid;
647 spawnsig = arg; 648 spawnsig = arg;
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index b30001f31610..8e561313d094 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -223,7 +223,7 @@ static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
223 } 223 }
224 if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) || 224 if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) ||
225 (val == CPUFREQ_POSTCHANGE && ci->old > ci->new) || 225 (val == CPUFREQ_POSTCHANGE && ci->old > ci->new) ||
226 (val == CPUFREQ_RESUMECHANGE)) { 226 (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) {
227 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, ci->new); 227 loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, ci->new);
228 dprintk("scaling loops_per_jiffy to %lu for frequency %u kHz\n", loops_per_jiffy, ci->new); 228 dprintk("scaling loops_per_jiffy to %lu for frequency %u kHz\n", loops_per_jiffy, ci->new);
229 } 229 }
@@ -866,11 +866,90 @@ EXPORT_SYMBOL(cpufreq_get);
866 866
867 867
868/** 868/**
869 * cpufreq_suspend - let the low level driver prepare for suspend
870 */
871
872static int cpufreq_suspend(struct sys_device * sysdev, u32 state)
873{
874 int cpu = sysdev->id;
875 unsigned int ret = 0;
876 unsigned int cur_freq = 0;
877 struct cpufreq_policy *cpu_policy;
878
879 dprintk("resuming cpu %u\n", cpu);
880
881 if (!cpu_online(cpu))
882 return 0;
883
884 /* we may be lax here as interrupts are off. Nonetheless
885 * we need to grab the correct cpu policy, as to check
886 * whether we really run on this CPU.
887 */
888
889 cpu_policy = cpufreq_cpu_get(cpu);
890 if (!cpu_policy)
891 return -EINVAL;
892
893 /* only handle each CPU group once */
894 if (unlikely(cpu_policy->cpu != cpu)) {
895 cpufreq_cpu_put(cpu_policy);
896 return 0;
897 }
898
899 if (cpufreq_driver->suspend) {
900 ret = cpufreq_driver->suspend(cpu_policy, state);
901 if (ret) {
902 printk(KERN_ERR "cpufreq: suspend failed in ->suspend "
903 "step on CPU %u\n", cpu_policy->cpu);
904 cpufreq_cpu_put(cpu_policy);
905 return ret;
906 }
907 }
908
909
910 if (cpufreq_driver->flags & CPUFREQ_CONST_LOOPS)
911 goto out;
912
913 if (cpufreq_driver->get)
914 cur_freq = cpufreq_driver->get(cpu_policy->cpu);
915
916 if (!cur_freq || !cpu_policy->cur) {
917 printk(KERN_ERR "cpufreq: suspend failed to assert current "
918 "frequency is what timing core thinks it is.\n");
919 goto out;
920 }
921
922 if (unlikely(cur_freq != cpu_policy->cur)) {
923 struct cpufreq_freqs freqs;
924
925 if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN))
926 printk(KERN_DEBUG "Warning: CPU frequency is %u, "
927 "cpufreq assumed %u kHz.\n",
928 cur_freq, cpu_policy->cur);
929
930 freqs.cpu = cpu;
931 freqs.old = cpu_policy->cur;
932 freqs.new = cur_freq;
933
934 notifier_call_chain(&cpufreq_transition_notifier_list,
935 CPUFREQ_SUSPENDCHANGE, &freqs);
936 adjust_jiffies(CPUFREQ_SUSPENDCHANGE, &freqs);
937
938 cpu_policy->cur = cur_freq;
939 }
940
941 out:
942 cpufreq_cpu_put(cpu_policy);
943 return 0;
944}
945
946/**
869 * cpufreq_resume - restore proper CPU frequency handling after resume 947 * cpufreq_resume - restore proper CPU frequency handling after resume
870 * 948 *
871 * 1.) resume CPUfreq hardware support (cpufreq_driver->resume()) 949 * 1.) resume CPUfreq hardware support (cpufreq_driver->resume())
872 * 2.) if ->target and !CPUFREQ_CONST_LOOPS: verify we're in sync 950 * 2.) if ->target and !CPUFREQ_CONST_LOOPS: verify we're in sync
873 * 3.) schedule call cpufreq_update_policy() ASAP as interrupts are restored. 951 * 3.) schedule call cpufreq_update_policy() ASAP as interrupts are
952 * restored.
874 */ 953 */
875static int cpufreq_resume(struct sys_device * sysdev) 954static int cpufreq_resume(struct sys_device * sysdev)
876{ 955{
@@ -915,21 +994,26 @@ static int cpufreq_resume(struct sys_device * sysdev)
915 cur_freq = cpufreq_driver->get(cpu_policy->cpu); 994 cur_freq = cpufreq_driver->get(cpu_policy->cpu);
916 995
917 if (!cur_freq || !cpu_policy->cur) { 996 if (!cur_freq || !cpu_policy->cur) {
918 printk(KERN_ERR "cpufreq: resume failed to assert current frequency is what timing core thinks it is.\n"); 997 printk(KERN_ERR "cpufreq: resume failed to assert "
998 "current frequency is what timing core "
999 "thinks it is.\n");
919 goto out; 1000 goto out;
920 } 1001 }
921 1002
922 if (unlikely(cur_freq != cpu_policy->cur)) { 1003 if (unlikely(cur_freq != cpu_policy->cur)) {
923 struct cpufreq_freqs freqs; 1004 struct cpufreq_freqs freqs;
924 1005
925 printk(KERN_WARNING "Warning: CPU frequency is %u, " 1006 if (!(cpufreq_driver->flags & CPUFREQ_PM_NO_WARN))
926 "cpufreq assumed %u kHz.\n", cur_freq, cpu_policy->cur); 1007 printk(KERN_WARNING "Warning: CPU frequency"
1008 "is %u, cpufreq assumed %u kHz.\n",
1009 cur_freq, cpu_policy->cur);
927 1010
928 freqs.cpu = cpu; 1011 freqs.cpu = cpu;
929 freqs.old = cpu_policy->cur; 1012 freqs.old = cpu_policy->cur;
930 freqs.new = cur_freq; 1013 freqs.new = cur_freq;
931 1014
932 notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_RESUMECHANGE, &freqs); 1015 notifier_call_chain(&cpufreq_transition_notifier_list,
1016 CPUFREQ_RESUMECHANGE, &freqs);
933 adjust_jiffies(CPUFREQ_RESUMECHANGE, &freqs); 1017 adjust_jiffies(CPUFREQ_RESUMECHANGE, &freqs);
934 1018
935 cpu_policy->cur = cur_freq; 1019 cpu_policy->cur = cur_freq;
@@ -945,6 +1029,7 @@ out:
945static struct sysdev_driver cpufreq_sysdev_driver = { 1029static struct sysdev_driver cpufreq_sysdev_driver = {
946 .add = cpufreq_add_dev, 1030 .add = cpufreq_add_dev,
947 .remove = cpufreq_remove_dev, 1031 .remove = cpufreq_remove_dev,
1032 .suspend = cpufreq_suspend,
948 .resume = cpufreq_resume, 1033 .resume = cpufreq_resume,
949}; 1034};
950 1035
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index a2827e43f0fe..a0018de3bef4 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -237,7 +237,7 @@ config I2C_KEYWEST
237 237
238config I2C_MPC 238config I2C_MPC
239 tristate "MPC107/824x/85xx/52xx" 239 tristate "MPC107/824x/85xx/52xx"
240 depends on I2C && PPC 240 depends on I2C && PPC32
241 help 241 help
242 If you say yes to this option, support will be included for the 242 If you say yes to this option, support will be included for the
243 built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and 243 built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 75b8d867dae1..6f33496d31c3 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -55,7 +55,7 @@
55#define CSR_RXAK 0x01 55#define CSR_RXAK 0x01
56 56
57struct mpc_i2c { 57struct mpc_i2c {
58 char *base; 58 void __iomem *base;
59 u32 interrupt; 59 u32 interrupt;
60 wait_queue_head_t queue; 60 wait_queue_head_t queue;
61 struct i2c_adapter adap; 61 struct i2c_adapter adap;
@@ -444,7 +444,7 @@ static int fsl_i2c_probe(struct device *device)
444 444
445 fail_add: 445 fail_add:
446 if (i2c->irq != 0) 446 if (i2c->irq != 0)
447 free_irq(i2c->irq, 0); 447 free_irq(i2c->irq, NULL);
448 fail_irq: 448 fail_irq:
449 iounmap(i2c->base); 449 iounmap(i2c->base);
450 fail_map: 450 fail_map:
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index 9d70ba5ea59b..16b3e2d8bfb1 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -726,7 +726,7 @@ static int sis5513_config_xfer_rate (ide_drive_t *drive)
726*/ 726*/
727 727
728/* Chip detection and general config */ 728/* Chip detection and general config */
729static unsigned int __init init_chipset_sis5513 (struct pci_dev *dev, const char *name) 729static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const char *name)
730{ 730{
731 struct pci_dev *host; 731 struct pci_dev *host;
732 int i = 0; 732 int i = 0;
@@ -879,7 +879,7 @@ static unsigned int __init init_chipset_sis5513 (struct pci_dev *dev, const char
879 return 0; 879 return 0;
880} 880}
881 881
882static unsigned int __init ata66_sis5513 (ide_hwif_t *hwif) 882static unsigned int __devinit ata66_sis5513 (ide_hwif_t *hwif)
883{ 883{
884 u8 ata66 = 0; 884 u8 ata66 = 0;
885 885
@@ -897,7 +897,7 @@ static unsigned int __init ata66_sis5513 (ide_hwif_t *hwif)
897 return ata66; 897 return ata66;
898} 898}
899 899
900static void __init init_hwif_sis5513 (ide_hwif_t *hwif) 900static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif)
901{ 901{
902 hwif->autodma = 0; 902 hwif->autodma = 0;
903 903
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 6dc273a81327..569f16767442 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1204,6 +1204,8 @@ pmac_ide_do_suspend(ide_hwif_t *hwif)
1204 } 1204 }
1205#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */ 1205#endif /* CONFIG_BLK_DEV_IDE_PMAC_BLINK */
1206 1206
1207 disable_irq(pmif->irq);
1208
1207 /* The media bay will handle itself just fine */ 1209 /* The media bay will handle itself just fine */
1208 if (pmif->mediabay) 1210 if (pmif->mediabay)
1209 return 0; 1211 return 0;
@@ -1236,7 +1238,6 @@ pmac_ide_do_resume(ide_hwif_t *hwif)
1236 ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 1); 1238 ppc_md.feature_call(PMAC_FTR_IDE_ENABLE, pmif->node, pmif->aapl_bus_id, 1);
1237 msleep(10); 1239 msleep(10);
1238 ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 0); 1240 ppc_md.feature_call(PMAC_FTR_IDE_RESET, pmif->node, pmif->aapl_bus_id, 0);
1239 msleep(jiffies_to_msecs(IDE_WAKEUP_DELAY));
1240 1241
1241 /* Kauai has it different */ 1242 /* Kauai has it different */
1242 if (pmif->kauai_fcr) { 1243 if (pmif->kauai_fcr) {
@@ -1244,11 +1245,15 @@ pmac_ide_do_resume(ide_hwif_t *hwif)
1244 fcr |= KAUAI_FCR_UATA_RESET_N | KAUAI_FCR_UATA_ENABLE; 1245 fcr |= KAUAI_FCR_UATA_RESET_N | KAUAI_FCR_UATA_ENABLE;
1245 writel(fcr, pmif->kauai_fcr); 1246 writel(fcr, pmif->kauai_fcr);
1246 } 1247 }
1248
1249 msleep(jiffies_to_msecs(IDE_WAKEUP_DELAY));
1247 } 1250 }
1248 1251
1249 /* Sanitize drive timings */ 1252 /* Sanitize drive timings */
1250 sanitize_timings(pmif); 1253 sanitize_timings(pmif);
1251 1254
1255 enable_irq(pmif->irq);
1256
1252 return 0; 1257 return 0;
1253} 1258}
1254 1259
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index 97ff364c0434..6cb0b586c297 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -539,10 +539,8 @@ static void ohci_initialize(struct ti_ohci *ohci)
539 initialize_dma_trm_ctx(&ohci->at_req_context); 539 initialize_dma_trm_ctx(&ohci->at_req_context);
540 initialize_dma_trm_ctx(&ohci->at_resp_context); 540 initialize_dma_trm_ctx(&ohci->at_resp_context);
541 541
542 /* Initialize IR Legacy DMA */ 542 /* Initialize IR Legacy DMA channel mask */
543 ohci->ir_legacy_channels = 0; 543 ohci->ir_legacy_channels = 0;
544 initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1);
545 DBGMSG("ISO receive legacy context activated");
546 544
547 /* 545 /*
548 * Accept AT requests from all nodes. This probably 546 * Accept AT requests from all nodes. This probably
@@ -1032,6 +1030,8 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
1032 case ISO_LISTEN_CHANNEL: 1030 case ISO_LISTEN_CHANNEL:
1033 { 1031 {
1034 u64 mask; 1032 u64 mask;
1033 struct dma_rcv_ctx *d = &ohci->ir_legacy_context;
1034 int ir_legacy_active;
1035 1035
1036 if (arg<0 || arg>63) { 1036 if (arg<0 || arg>63) {
1037 PRINT(KERN_ERR, 1037 PRINT(KERN_ERR,
@@ -1052,9 +1052,37 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
1052 return -EFAULT; 1052 return -EFAULT;
1053 } 1053 }
1054 1054
1055 ir_legacy_active = ohci->ir_legacy_channels;
1056
1055 ohci->ISO_channel_usage |= mask; 1057 ohci->ISO_channel_usage |= mask;
1056 ohci->ir_legacy_channels |= mask; 1058 ohci->ir_legacy_channels |= mask;
1057 1059
1060 spin_unlock_irqrestore(&ohci->IR_channel_lock, flags);
1061
1062 if (!ir_legacy_active) {
1063 if (ohci1394_register_iso_tasklet(ohci,
1064 &ohci->ir_legacy_tasklet) < 0) {
1065 PRINT(KERN_ERR, "No IR DMA context available");
1066 return -EBUSY;
1067 }
1068
1069 /* the IR context can be assigned to any DMA context
1070 * by ohci1394_register_iso_tasklet */
1071 d->ctx = ohci->ir_legacy_tasklet.context;
1072 d->ctrlSet = OHCI1394_IsoRcvContextControlSet +
1073 32*d->ctx;
1074 d->ctrlClear = OHCI1394_IsoRcvContextControlClear +
1075 32*d->ctx;
1076 d->cmdPtr = OHCI1394_IsoRcvCommandPtr + 32*d->ctx;
1077 d->ctxtMatch = OHCI1394_IsoRcvContextMatch + 32*d->ctx;
1078
1079 initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1);
1080
1081 PRINT(KERN_ERR, "IR legacy activated");
1082 }
1083
1084 spin_lock_irqsave(&ohci->IR_channel_lock, flags);
1085
1058 if (arg>31) 1086 if (arg>31)
1059 reg_write(ohci, OHCI1394_IRMultiChanMaskHiSet, 1087 reg_write(ohci, OHCI1394_IRMultiChanMaskHiSet,
1060 1<<(arg-32)); 1088 1<<(arg-32));
@@ -1101,6 +1129,12 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
1101 1129
1102 spin_unlock_irqrestore(&ohci->IR_channel_lock, flags); 1130 spin_unlock_irqrestore(&ohci->IR_channel_lock, flags);
1103 DBGMSG("Listening disabled on channel %d", arg); 1131 DBGMSG("Listening disabled on channel %d", arg);
1132
1133 if (ohci->ir_legacy_channels == 0) {
1134 stop_dma_rcv_ctx(&ohci->ir_legacy_context);
1135 DBGMSG("ISO legacy receive context stopped");
1136 }
1137
1104 break; 1138 break;
1105 } 1139 }
1106 default: 1140 default:
@@ -1270,8 +1304,10 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
1270 OHCI_ISO_RECEIVE, 1304 OHCI_ISO_RECEIVE,
1271 ohci_iso_recv_task, (unsigned long) iso); 1305 ohci_iso_recv_task, (unsigned long) iso);
1272 1306
1273 if (ohci1394_register_iso_tasklet(recv->ohci, &recv->task) < 0) 1307 if (ohci1394_register_iso_tasklet(recv->ohci, &recv->task) < 0) {
1308 ret = -EBUSY;
1274 goto err; 1309 goto err;
1310 }
1275 1311
1276 recv->task_active = 1; 1312 recv->task_active = 1;
1277 1313
@@ -1896,8 +1932,10 @@ static int ohci_iso_xmit_init(struct hpsb_iso *iso)
1896 ohci1394_init_iso_tasklet(&xmit->task, OHCI_ISO_TRANSMIT, 1932 ohci1394_init_iso_tasklet(&xmit->task, OHCI_ISO_TRANSMIT,
1897 ohci_iso_xmit_task, (unsigned long) iso); 1933 ohci_iso_xmit_task, (unsigned long) iso);
1898 1934
1899 if (ohci1394_register_iso_tasklet(xmit->ohci, &xmit->task) < 0) 1935 if (ohci1394_register_iso_tasklet(xmit->ohci, &xmit->task) < 0) {
1936 ret = -EBUSY;
1900 goto err; 1937 goto err;
1938 }
1901 1939
1902 xmit->task_active = 1; 1940 xmit->task_active = 1;
1903 1941
@@ -2691,7 +2729,7 @@ static void dma_rcv_tasklet (unsigned long data)
2691 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>16)&0x1f, 2729 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>16)&0x1f,
2692 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>21)&0x3, 2730 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>21)&0x3,
2693 tcode, length, d->ctx, 2731 tcode, length, d->ctx,
2694 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>10)&0x3f); 2732 (cond_le32_to_cpu(d->spb[0], ohci->no_swap_incoming)>>10)&0x3f);
2695 2733
2696 ack = (((cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>16)&0x1f) 2734 ack = (((cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>16)&0x1f)
2697 == 0x11) ? 1 : 0; 2735 == 0x11) ? 1 : 0;
@@ -2754,7 +2792,7 @@ static void dma_trm_tasklet (unsigned long data)
2754 d->ctx); 2792 d->ctx);
2755 else 2793 else
2756 DBGMSG("Packet sent to node %d tcode=0x%X tLabel=" 2794 DBGMSG("Packet sent to node %d tcode=0x%X tLabel="
2757 "0x%02X ack=0x%X spd=%d dataLength=%d ctx=%d", 2795 "%d ack=0x%X spd=%d dataLength=%d ctx=%d",
2758 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1])>>16)&0x3f, 2796 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1])>>16)&0x3f,
2759 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>4)&0xf, 2797 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>4)&0xf,
2760 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>10)&0x3f, 2798 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>10)&0x3f,
@@ -2763,7 +2801,7 @@ static void dma_trm_tasklet (unsigned long data)
2763 d->ctx); 2801 d->ctx);
2764 else 2802 else
2765 DBGMSG("Packet sent to node %d tcode=0x%X tLabel=" 2803 DBGMSG("Packet sent to node %d tcode=0x%X tLabel="
2766 "0x%02X ack=0x%X spd=%d data=0x%08X ctx=%d", 2804 "%d ack=0x%X spd=%d data=0x%08X ctx=%d",
2767 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1]) 2805 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1])
2768 >>16)&0x3f, 2806 >>16)&0x3f,
2769 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0]) 2807 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])
@@ -2999,20 +3037,6 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
2999 ohci1394_init_iso_tasklet(&ohci->ir_legacy_tasklet, 3037 ohci1394_init_iso_tasklet(&ohci->ir_legacy_tasklet,
3000 OHCI_ISO_MULTICHANNEL_RECEIVE, 3038 OHCI_ISO_MULTICHANNEL_RECEIVE,
3001 dma_rcv_tasklet, (unsigned long) d); 3039 dma_rcv_tasklet, (unsigned long) d);
3002 if (ohci1394_register_iso_tasklet(ohci,
3003 &ohci->ir_legacy_tasklet) < 0) {
3004 PRINT(KERN_ERR, "No IR DMA context available");
3005 free_dma_rcv_ctx(d);
3006 return -EBUSY;
3007 }
3008
3009 /* the IR context can be assigned to any DMA context
3010 * by ohci1394_register_iso_tasklet */
3011 d->ctx = ohci->ir_legacy_tasklet.context;
3012 d->ctrlSet = OHCI1394_IsoRcvContextControlSet + 32*d->ctx;
3013 d->ctrlClear = OHCI1394_IsoRcvContextControlClear + 32*d->ctx;
3014 d->cmdPtr = OHCI1394_IsoRcvCommandPtr + 32*d->ctx;
3015 d->ctxtMatch = OHCI1394_IsoRcvContextMatch + 32*d->ctx;
3016 } else { 3040 } else {
3017 d->ctrlSet = context_base + OHCI1394_ContextControlSet; 3041 d->ctrlSet = context_base + OHCI1394_ContextControlSet;
3018 d->ctrlClear = context_base + OHCI1394_ContextControlClear; 3042 d->ctrlClear = context_base + OHCI1394_ContextControlClear;
@@ -3413,7 +3437,6 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
3413 3437
3414 switch (ohci->init_state) { 3438 switch (ohci->init_state) {
3415 case OHCI_INIT_DONE: 3439 case OHCI_INIT_DONE:
3416 stop_dma_rcv_ctx(&ohci->ir_legacy_context);
3417 hpsb_remove_host(ohci->host); 3440 hpsb_remove_host(ohci->host);
3418 3441
3419 /* Clear out BUS Options */ 3442 /* Clear out BUS Options */
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 5824b6d3769f..637b30e35592 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -32,6 +32,8 @@
32 * $Id$ 32 * $Id$
33 */ 33 */
34 34
35#include <linux/mm.h>
36
35#include "mthca_memfree.h" 37#include "mthca_memfree.h"
36#include "mthca_dev.h" 38#include "mthca_dev.h"
37#include "mthca_cmd.h" 39#include "mthca_cmd.h"
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
index c76cf8ff29c0..874367bfab08 100644
--- a/drivers/input/joystick/spaceorb.c
+++ b/drivers/input/joystick/spaceorb.c
@@ -116,7 +116,7 @@ static void spaceorb_process_packet(struct spaceorb *spaceorb, struct pt_regs *r
116 116
117 case 'K': /* Button data */ 117 case 'K': /* Button data */
118 if (spaceorb->idx != 5) return; 118 if (spaceorb->idx != 5) return;
119 for (i = 0; i < 7; i++) 119 for (i = 0; i < 6; i++)
120 input_report_key(dev, spaceorb_buttons[i], (data[2] >> i) & 1); 120 input_report_key(dev, spaceorb_buttons[i], (data[2] >> i) & 1);
121 121
122 break; 122 break;
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index f7304f0ce542..ff66ed4ee2cd 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -678,7 +678,7 @@ static void atkbd_disconnect(struct serio *serio)
678 atkbd_disable(atkbd); 678 atkbd_disable(atkbd);
679 679
680 /* make sure we don't have a command in flight */ 680 /* make sure we don't have a command in flight */
681 synchronize_kernel(); 681 synchronize_sched(); /* Allow atkbd_interrupt()s to complete. */
682 flush_scheduled_work(); 682 flush_scheduled_work();
683 683
684 device_remove_file(&serio->dev, &atkbd_attr_extra); 684 device_remove_file(&serio->dev, &atkbd_attr_extra);
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 06163538bb20..12dee8e9fbbe 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -60,12 +60,12 @@ MODULE_LICENSE("GPL");
60 60
61static struct class_simple *capi_class; 61static struct class_simple *capi_class;
62 62
63int capi_major = 68; /* allocated */ 63static int capi_major = 68; /* allocated */
64#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 64#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
65#define CAPINC_NR_PORTS 32 65#define CAPINC_NR_PORTS 32
66#define CAPINC_MAX_PORTS 256 66#define CAPINC_MAX_PORTS 256
67int capi_ttymajor = 191; 67static int capi_ttymajor = 191;
68int capi_ttyminors = CAPINC_NR_PORTS; 68static int capi_ttyminors = CAPINC_NR_PORTS;
69#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ 69#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
70 70
71module_param_named(major, capi_major, uint, 0); 71module_param_named(major, capi_major, uint, 0);
@@ -268,7 +268,7 @@ static void capiminor_free(struct capiminor *mp)
268 kfree(mp); 268 kfree(mp);
269} 269}
270 270
271struct capiminor *capiminor_find(unsigned int minor) 271static struct capiminor *capiminor_find(unsigned int minor)
272{ 272{
273 struct list_head *l; 273 struct list_head *l;
274 struct capiminor *p = NULL; 274 struct capiminor *p = NULL;
@@ -1166,7 +1166,7 @@ static int capinc_tty_write_room(struct tty_struct *tty)
1166 return room; 1166 return room;
1167} 1167}
1168 1168
1169int capinc_tty_chars_in_buffer(struct tty_struct *tty) 1169static int capinc_tty_chars_in_buffer(struct tty_struct *tty)
1170{ 1170{
1171 struct capiminor *mp = (struct capiminor *)tty->driver_data; 1171 struct capiminor *mp = (struct capiminor *)tty->driver_data;
1172 if (!mp || !mp->nccip) { 1172 if (!mp || !mp->nccip) {
diff --git a/drivers/isdn/capi/kcapi_proc.c b/drivers/isdn/capi/kcapi_proc.c
index 16dc5418ff41..2cc8b27e4c3b 100644
--- a/drivers/isdn/capi/kcapi_proc.c
+++ b/drivers/isdn/capi/kcapi_proc.c
@@ -89,14 +89,14 @@ static int contrstats_show(struct seq_file *seq, void *v)
89 return 0; 89 return 0;
90} 90}
91 91
92struct seq_operations seq_controller_ops = { 92static struct seq_operations seq_controller_ops = {
93 .start = controller_start, 93 .start = controller_start,
94 .next = controller_next, 94 .next = controller_next,
95 .stop = controller_stop, 95 .stop = controller_stop,
96 .show = controller_show, 96 .show = controller_show,
97}; 97};
98 98
99struct seq_operations seq_contrstats_ops = { 99static struct seq_operations seq_contrstats_ops = {
100 .start = controller_start, 100 .start = controller_start,
101 .next = controller_next, 101 .next = controller_next,
102 .stop = controller_stop, 102 .stop = controller_stop,
@@ -192,14 +192,14 @@ applstats_show(struct seq_file *seq, void *v)
192 return 0; 192 return 0;
193} 193}
194 194
195struct seq_operations seq_applications_ops = { 195static struct seq_operations seq_applications_ops = {
196 .start = applications_start, 196 .start = applications_start,
197 .next = applications_next, 197 .next = applications_next,
198 .stop = applications_stop, 198 .stop = applications_stop,
199 .show = applications_show, 199 .show = applications_show,
200}; 200};
201 201
202struct seq_operations seq_applstats_ops = { 202static struct seq_operations seq_applstats_ops = {
203 .start = applications_start, 203 .start = applications_start,
204 .next = applications_next, 204 .next = applications_next,
205 .stop = applications_stop, 205 .stop = applications_stop,
@@ -287,7 +287,7 @@ static int capi_driver_show(struct seq_file *seq, void *v)
287 return 0; 287 return 0;
288} 288}
289 289
290struct seq_operations seq_capi_driver_ops = { 290static struct seq_operations seq_capi_driver_ops = {
291 .start = capi_driver_start, 291 .start = capi_driver_start,
292 .next = capi_driver_next, 292 .next = capi_driver_next,
293 .stop = capi_driver_stop, 293 .stop = capi_driver_stop,
diff --git a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c
index 1eb112213f0c..0bfd698726a6 100644
--- a/drivers/isdn/divert/isdn_divert.c
+++ b/drivers/isdn/divert/isdn_divert.c
@@ -383,7 +383,7 @@ divert_rule *getruleptr(int idx)
383/*************************************************/ 383/*************************************************/
384/* called from common module on an incoming call */ 384/* called from common module on an incoming call */
385/*************************************************/ 385/*************************************************/
386int isdn_divert_icall(isdn_ctrl *ic) 386static int isdn_divert_icall(isdn_ctrl *ic)
387{ int retval = 0; 387{ int retval = 0;
388 unsigned long flags; 388 unsigned long flags;
389 struct call_struc *cs = NULL; 389 struct call_struc *cs = NULL;
@@ -552,7 +552,7 @@ void deleteprocs(void)
552/****************************************************/ 552/****************************************************/
553/* put a address including address type into buffer */ 553/* put a address including address type into buffer */
554/****************************************************/ 554/****************************************************/
555int put_address(char *st, u_char *p, int len) 555static int put_address(char *st, u_char *p, int len)
556{ u_char retval = 0; 556{ u_char retval = 0;
557 u_char adr_typ = 0; /* network standard */ 557 u_char adr_typ = 0; /* network standard */
558 558
@@ -595,7 +595,7 @@ int put_address(char *st, u_char *p, int len)
595/*************************************/ 595/*************************************/
596/* report a succesfull interrogation */ 596/* report a succesfull interrogation */
597/*************************************/ 597/*************************************/
598int interrogate_success(isdn_ctrl *ic, struct call_struc *cs) 598static int interrogate_success(isdn_ctrl *ic, struct call_struc *cs)
599{ char *src = ic->parm.dss1_io.data; 599{ char *src = ic->parm.dss1_io.data;
600 int restlen = ic->parm.dss1_io.datalen; 600 int restlen = ic->parm.dss1_io.datalen;
601 int cnt = 1; 601 int cnt = 1;
@@ -689,7 +689,7 @@ int interrogate_success(isdn_ctrl *ic, struct call_struc *cs)
689/*********************************************/ 689/*********************************************/
690/* callback for protocol specific extensions */ 690/* callback for protocol specific extensions */
691/*********************************************/ 691/*********************************************/
692int prot_stat_callback(isdn_ctrl *ic) 692static int prot_stat_callback(isdn_ctrl *ic)
693{ struct call_struc *cs, *cs1; 693{ struct call_struc *cs, *cs1;
694 int i; 694 int i;
695 unsigned long flags; 695 unsigned long flags;
@@ -781,7 +781,7 @@ int prot_stat_callback(isdn_ctrl *ic)
781/***************************/ 781/***************************/
782/* status callback from HL */ 782/* status callback from HL */
783/***************************/ 783/***************************/
784int isdn_divert_stat_callback(isdn_ctrl *ic) 784static int isdn_divert_stat_callback(isdn_ctrl *ic)
785{ struct call_struc *cs, *cs1; 785{ struct call_struc *cs, *cs1;
786 unsigned long flags; 786 unsigned long flags;
787 int retval; 787 int retval;
diff --git a/drivers/isdn/hisax/hfc4s8s_l1.c b/drivers/isdn/hisax/hfc4s8s_l1.c
index 1ac46c26b936..ba1d028343ec 100644
--- a/drivers/isdn/hisax/hfc4s8s_l1.c
+++ b/drivers/isdn/hisax/hfc4s8s_l1.c
@@ -29,6 +29,7 @@
29#include <linux/timer.h> 29#include <linux/timer.h>
30#include <linux/skbuff.h> 30#include <linux/skbuff.h>
31#include <linux/wait.h> 31#include <linux/wait.h>
32#include <asm/io.h>
32#include "hisax_if.h" 33#include "hisax_if.h"
33#include "hfc4s8s_l1.h" 34#include "hfc4s8s_l1.h"
34 35
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c
index 8f93d01d8928..db654e8bd67e 100644
--- a/drivers/macintosh/adbhid.c
+++ b/drivers/macintosh/adbhid.c
@@ -555,6 +555,42 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
555#endif /* CONFIG_PMAC_BACKLIGHT */ 555#endif /* CONFIG_PMAC_BACKLIGHT */
556 input_report_key(&adbhid[id]->input, KEY_BRIGHTNESSUP, down); 556 input_report_key(&adbhid[id]->input, KEY_BRIGHTNESSUP, down);
557 break; 557 break;
558
559 case 0xc: /* videomode switch */
560 input_report_key(&adbhid[id]->input, KEY_SWITCHVIDEOMODE, down);
561 break;
562
563 case 0xd: /* keyboard illumination toggle */
564 input_report_key(&adbhid[id]->input, KEY_KBDILLUMTOGGLE, down);
565 break;
566
567 case 0xe: /* keyboard illumination decrease */
568 input_report_key(&adbhid[id]->input, KEY_KBDILLUMDOWN, down);
569 break;
570
571 case 0xf:
572 switch (data[1]) {
573 case 0x8f:
574 case 0x0f:
575 /* keyboard illumination increase */
576 input_report_key(&adbhid[id]->input, KEY_KBDILLUMUP, down);
577 break;
578
579 case 0x7f:
580 case 0xff:
581 /* keypad overlay toogle */
582 break;
583
584 default:
585 printk(KERN_INFO "Unhandled ADB_MISC event %02x, %02x, %02x, %02x\n",
586 data[0], data[1], data[2], data[3]);
587 break;
588 }
589 break;
590 default:
591 printk(KERN_INFO "Unhandled ADB_MISC event %02x, %02x, %02x, %02x\n",
592 data[0], data[1], data[2], data[3]);
593 break;
558 } 594 }
559 } 595 }
560 break; 596 break;
@@ -775,6 +811,10 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
775 set_bit(KEY_BRIGHTNESSUP, adbhid[id]->input.keybit); 811 set_bit(KEY_BRIGHTNESSUP, adbhid[id]->input.keybit);
776 set_bit(KEY_BRIGHTNESSDOWN, adbhid[id]->input.keybit); 812 set_bit(KEY_BRIGHTNESSDOWN, adbhid[id]->input.keybit);
777 set_bit(KEY_EJECTCD, adbhid[id]->input.keybit); 813 set_bit(KEY_EJECTCD, adbhid[id]->input.keybit);
814 set_bit(KEY_SWITCHVIDEOMODE, adbhid[id]->input.keybit);
815 set_bit(KEY_KBDILLUMTOGGLE, adbhid[id]->input.keybit);
816 set_bit(KEY_KBDILLUMDOWN, adbhid[id]->input.keybit);
817 set_bit(KEY_KBDILLUMUP, adbhid[id]->input.keybit);
778 break; 818 break;
779 } 819 }
780 if (adbhid[id]->name[0]) 820 if (adbhid[id]->name[0])
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index fdea1a3a631d..e654aa5eecd4 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -2351,6 +2351,10 @@ pmac_suspend_devices(void)
2351 return -EBUSY; 2351 return -EBUSY;
2352 } 2352 }
2353 2353
2354 /* Disable clock spreading on some machines */
2355 pmac_tweak_clock_spreading(0);
2356
2357 /* Stop preemption */
2354 preempt_disable(); 2358 preempt_disable();
2355 2359
2356 /* Make sure the decrementer won't interrupt us */ 2360 /* Make sure the decrementer won't interrupt us */
@@ -2417,11 +2421,12 @@ pmac_wakeup_devices(void)
2417 2421
2418 /* Re-enable local CPU interrupts */ 2422 /* Re-enable local CPU interrupts */
2419 local_irq_enable(); 2423 local_irq_enable();
2420
2421 mdelay(100); 2424 mdelay(100);
2422
2423 preempt_enable(); 2425 preempt_enable();
2424 2426
2427 /* Re-enable clock spreading on some machines */
2428 pmac_tweak_clock_spreading(1);
2429
2425 /* Resume devices */ 2430 /* Resume devices */
2426 device_resume(); 2431 device_resume();
2427 2432
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 77619a56e2bf..0dd6c2b5391b 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -331,25 +331,19 @@ crypt_alloc_buffer(struct crypt_config *cc, unsigned int size,
331 struct bio *bio; 331 struct bio *bio;
332 unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; 332 unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
333 int gfp_mask = GFP_NOIO | __GFP_HIGHMEM; 333 int gfp_mask = GFP_NOIO | __GFP_HIGHMEM;
334 unsigned long flags = current->flags;
335 unsigned int i; 334 unsigned int i;
336 335
337 /* 336 /*
338 * Tell VM to act less aggressively and fail earlier. 337 * Use __GFP_NOMEMALLOC to tell the VM to act less aggressively and
339 * This is not necessary but increases throughput. 338 * to fail earlier. This is not necessary but increases throughput.
340 * FIXME: Is this really intelligent? 339 * FIXME: Is this really intelligent?
341 */ 340 */
342 current->flags &= ~PF_MEMALLOC;
343
344 if (base_bio) 341 if (base_bio)
345 bio = bio_clone(base_bio, GFP_NOIO); 342 bio = bio_clone(base_bio, GFP_NOIO|__GFP_NOMEMALLOC);
346 else 343 else
347 bio = bio_alloc(GFP_NOIO, nr_iovecs); 344 bio = bio_alloc(GFP_NOIO|__GFP_NOMEMALLOC, nr_iovecs);
348 if (!bio) { 345 if (!bio)
349 if (flags & PF_MEMALLOC)
350 current->flags |= PF_MEMALLOC;
351 return NULL; 346 return NULL;
352 }
353 347
354 /* if the last bio was not complete, continue where that one ended */ 348 /* if the last bio was not complete, continue where that one ended */
355 bio->bi_idx = *bio_vec_idx; 349 bio->bi_idx = *bio_vec_idx;
@@ -386,9 +380,6 @@ crypt_alloc_buffer(struct crypt_config *cc, unsigned int size,
386 size -= bv->bv_len; 380 size -= bv->bv_len;
387 } 381 }
388 382
389 if (flags & PF_MEMALLOC)
390 current->flags |= PF_MEMALLOC;
391
392 if (!bio->bi_size) { 383 if (!bio->bi_size) {
393 bio_put(bio); 384 bio_put(bio);
394 return NULL; 385 return NULL;
diff --git a/drivers/md/dm-emc.c b/drivers/md/dm-emc.c
index 700658664594..c7067674dcb7 100644
--- a/drivers/md/dm-emc.c
+++ b/drivers/md/dm-emc.c
@@ -223,8 +223,10 @@ static struct emc_handler *alloc_emc_handler(void)
223{ 223{
224 struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL); 224 struct emc_handler *h = kmalloc(sizeof(*h), GFP_KERNEL);
225 225
226 if (h) 226 if (h) {
227 memset(h, 0, sizeof(*h));
227 spin_lock_init(&h->lock); 228 spin_lock_init(&h->lock);
229 }
228 230
229 return h; 231 return h;
230} 232}
@@ -259,8 +261,6 @@ static int emc_create(struct hw_handler *hwh, unsigned argc, char **argv)
259 if (!h) 261 if (!h)
260 return -ENOMEM; 262 return -ENOMEM;
261 263
262 memset(h, 0, sizeof(*h));
263
264 hwh->context = h; 264 hwh->context = h;
265 265
266 if ((h->short_trespass = short_trespass)) 266 if ((h->short_trespass = short_trespass))
diff --git a/drivers/md/dm-hw-handler.c b/drivers/md/dm-hw-handler.c
index ae63772e44c9..4cc0010e0156 100644
--- a/drivers/md/dm-hw-handler.c
+++ b/drivers/md/dm-hw-handler.c
@@ -23,7 +23,7 @@ struct hwh_internal {
23static LIST_HEAD(_hw_handlers); 23static LIST_HEAD(_hw_handlers);
24static DECLARE_RWSEM(_hwh_lock); 24static DECLARE_RWSEM(_hwh_lock);
25 25
26struct hwh_internal *__find_hw_handler_type(const char *name) 26static struct hwh_internal *__find_hw_handler_type(const char *name)
27{ 27{
28 struct hwh_internal *hwhi; 28 struct hwh_internal *hwhi;
29 29
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 43763a0bd096..1e97b3c12bd5 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -101,6 +101,7 @@ typedef int (*action_fn) (struct pgpath *pgpath);
101 101
102static kmem_cache_t *_mpio_cache; 102static kmem_cache_t *_mpio_cache;
103 103
104struct workqueue_struct *kmultipathd;
104static void process_queued_ios(void *data); 105static void process_queued_ios(void *data);
105static void trigger_event(void *data); 106static void trigger_event(void *data);
106 107
@@ -308,7 +309,7 @@ static int map_io(struct multipath *m, struct bio *bio, struct mpath_io *mpio,
308 bio_list_add(&m->queued_ios, bio); 309 bio_list_add(&m->queued_ios, bio);
309 m->queue_size++; 310 m->queue_size++;
310 if (m->pg_init_required || !m->queue_io) 311 if (m->pg_init_required || !m->queue_io)
311 schedule_work(&m->process_queued_ios); 312 queue_work(kmultipathd, &m->process_queued_ios);
312 pgpath = NULL; 313 pgpath = NULL;
313 r = 0; 314 r = 0;
314 } else if (!pgpath) 315 } else if (!pgpath)
@@ -334,7 +335,7 @@ static int queue_if_no_path(struct multipath *m, unsigned queue_if_no_path)
334 335
335 m->queue_if_no_path = queue_if_no_path; 336 m->queue_if_no_path = queue_if_no_path;
336 if (!m->queue_if_no_path) 337 if (!m->queue_if_no_path)
337 schedule_work(&m->process_queued_ios); 338 queue_work(kmultipathd, &m->process_queued_ios);
338 339
339 spin_unlock_irqrestore(&m->lock, flags); 340 spin_unlock_irqrestore(&m->lock, flags);
340 341
@@ -800,7 +801,7 @@ static int fail_path(struct pgpath *pgpath)
800 if (pgpath == m->current_pgpath) 801 if (pgpath == m->current_pgpath)
801 m->current_pgpath = NULL; 802 m->current_pgpath = NULL;
802 803
803 schedule_work(&m->trigger_event); 804 queue_work(kmultipathd, &m->trigger_event);
804 805
805out: 806out:
806 spin_unlock_irqrestore(&m->lock, flags); 807 spin_unlock_irqrestore(&m->lock, flags);
@@ -837,9 +838,9 @@ static int reinstate_path(struct pgpath *pgpath)
837 838
838 m->current_pgpath = NULL; 839 m->current_pgpath = NULL;
839 if (!m->nr_valid_paths++) 840 if (!m->nr_valid_paths++)
840 schedule_work(&m->process_queued_ios); 841 queue_work(kmultipathd, &m->process_queued_ios);
841 842
842 schedule_work(&m->trigger_event); 843 queue_work(kmultipathd, &m->trigger_event);
843 844
844out: 845out:
845 spin_unlock_irqrestore(&m->lock, flags); 846 spin_unlock_irqrestore(&m->lock, flags);
@@ -883,7 +884,7 @@ static void bypass_pg(struct multipath *m, struct priority_group *pg,
883 884
884 spin_unlock_irqrestore(&m->lock, flags); 885 spin_unlock_irqrestore(&m->lock, flags);
885 886
886 schedule_work(&m->trigger_event); 887 queue_work(kmultipathd, &m->trigger_event);
887} 888}
888 889
889/* 890/*
@@ -913,7 +914,7 @@ static int switch_pg_num(struct multipath *m, const char *pgstr)
913 } 914 }
914 spin_unlock_irqrestore(&m->lock, flags); 915 spin_unlock_irqrestore(&m->lock, flags);
915 916
916 schedule_work(&m->trigger_event); 917 queue_work(kmultipathd, &m->trigger_event);
917 return 0; 918 return 0;
918} 919}
919 920
@@ -968,7 +969,7 @@ void dm_pg_init_complete(struct path *path, unsigned err_flags)
968 m->current_pgpath = NULL; 969 m->current_pgpath = NULL;
969 m->current_pg = NULL; 970 m->current_pg = NULL;
970 } 971 }
971 schedule_work(&m->process_queued_ios); 972 queue_work(kmultipathd, &m->process_queued_ios);
972 spin_unlock_irqrestore(&m->lock, flags); 973 spin_unlock_irqrestore(&m->lock, flags);
973} 974}
974 975
@@ -1018,7 +1019,7 @@ static int do_end_io(struct multipath *m, struct bio *bio,
1018 bio_list_add(&m->queued_ios, bio); 1019 bio_list_add(&m->queued_ios, bio);
1019 m->queue_size++; 1020 m->queue_size++;
1020 if (!m->queue_io) 1021 if (!m->queue_io)
1021 schedule_work(&m->process_queued_ios); 1022 queue_work(kmultipathd, &m->process_queued_ios);
1022 spin_unlock(&m->lock); 1023 spin_unlock(&m->lock);
1023 1024
1024 return 1; /* io not complete */ 1025 return 1; /* io not complete */
@@ -1057,7 +1058,7 @@ static void multipath_presuspend(struct dm_target *ti)
1057 spin_lock_irqsave(&m->lock, flags); 1058 spin_lock_irqsave(&m->lock, flags);
1058 m->suspended = 1; 1059 m->suspended = 1;
1059 if (m->queue_if_no_path) 1060 if (m->queue_if_no_path)
1060 schedule_work(&m->process_queued_ios); 1061 queue_work(kmultipathd, &m->process_queued_ios);
1061 spin_unlock_irqrestore(&m->lock, flags); 1062 spin_unlock_irqrestore(&m->lock, flags);
1062} 1063}
1063 1064
@@ -1274,6 +1275,15 @@ static int __init dm_multipath_init(void)
1274 return -EINVAL; 1275 return -EINVAL;
1275 } 1276 }
1276 1277
1278 kmultipathd = create_workqueue("kmpathd");
1279 if (!kmultipathd) {
1280 DMERR("%s: failed to create workqueue kmpathd",
1281 multipath_target.name);
1282 dm_unregister_target(&multipath_target);
1283 kmem_cache_destroy(_mpio_cache);
1284 return -ENOMEM;
1285 }
1286
1277 DMINFO("dm-multipath version %u.%u.%u loaded", 1287 DMINFO("dm-multipath version %u.%u.%u loaded",
1278 multipath_target.version[0], multipath_target.version[1], 1288 multipath_target.version[0], multipath_target.version[1],
1279 multipath_target.version[2]); 1289 multipath_target.version[2]);
@@ -1285,6 +1295,8 @@ static void __exit dm_multipath_exit(void)
1285{ 1295{
1286 int r; 1296 int r;
1287 1297
1298 destroy_workqueue(kmultipathd);
1299
1288 r = dm_unregister_target(&multipath_target); 1300 r = dm_unregister_target(&multipath_target);
1289 if (r < 0) 1301 if (r < 0)
1290 DMERR("%s: target unregister failed %d", 1302 DMERR("%s: target unregister failed %d",
diff --git a/drivers/md/dm-path-selector.c b/drivers/md/dm-path-selector.c
index ac5c4bbec6c1..a28c1c2b4ef5 100644
--- a/drivers/md/dm-path-selector.c
+++ b/drivers/md/dm-path-selector.c
@@ -26,7 +26,7 @@ struct ps_internal {
26static LIST_HEAD(_path_selectors); 26static LIST_HEAD(_path_selectors);
27static DECLARE_RWSEM(_ps_lock); 27static DECLARE_RWSEM(_ps_lock);
28 28
29struct ps_internal *__find_path_selector_type(const char *name) 29static struct ps_internal *__find_path_selector_type(const char *name)
30{ 30{
31 struct ps_internal *psi; 31 struct ps_internal *psi;
32 32
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index ee175d4906c4..18e9b9953fcd 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -242,7 +242,7 @@ static void free_devices(struct list_head *devices)
242 } 242 }
243} 243}
244 244
245void table_destroy(struct dm_table *t) 245static void table_destroy(struct dm_table *t)
246{ 246{
247 unsigned int i; 247 unsigned int i;
248 248
diff --git a/drivers/md/dm-zero.c b/drivers/md/dm-zero.c
index 7febc2cac73d..51c0639b2487 100644
--- a/drivers/md/dm-zero.c
+++ b/drivers/md/dm-zero.c
@@ -55,7 +55,7 @@ static struct target_type zero_target = {
55 .map = zero_map, 55 .map = zero_map,
56}; 56};
57 57
58int __init dm_zero_init(void) 58static int __init dm_zero_init(void)
59{ 59{
60 int r = dm_register_target(&zero_target); 60 int r = dm_register_target(&zero_target);
61 61
@@ -65,7 +65,7 @@ int __init dm_zero_init(void)
65 return r; 65 return r;
66} 66}
67 67
68void __exit dm_zero_exit(void) 68static void __exit dm_zero_exit(void)
69{ 69{
70 int r = dm_unregister_target(&zero_target); 70 int r = dm_unregister_target(&zero_target);
71 71
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 243ff6884e83..f6b03957efc7 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -97,6 +97,7 @@ struct mapped_device {
97 * freeze/thaw support require holding onto a super block 97 * freeze/thaw support require holding onto a super block
98 */ 98 */
99 struct super_block *frozen_sb; 99 struct super_block *frozen_sb;
100 struct block_device *frozen_bdev;
100}; 101};
101 102
102#define MIN_IOS 256 103#define MIN_IOS 256
@@ -990,44 +991,50 @@ int dm_swap_table(struct mapped_device *md, struct dm_table *table)
990 */ 991 */
991static int __lock_fs(struct mapped_device *md) 992static int __lock_fs(struct mapped_device *md)
992{ 993{
993 struct block_device *bdev; 994 int error = -ENOMEM;
994 995
995 if (test_and_set_bit(DMF_FS_LOCKED, &md->flags)) 996 if (test_and_set_bit(DMF_FS_LOCKED, &md->flags))
996 return 0; 997 return 0;
997 998
998 bdev = bdget_disk(md->disk, 0); 999 md->frozen_bdev = bdget_disk(md->disk, 0);
999 if (!bdev) { 1000 if (!md->frozen_bdev) {
1000 DMWARN("bdget failed in __lock_fs"); 1001 DMWARN("bdget failed in __lock_fs");
1001 return -ENOMEM; 1002 goto out;
1002 } 1003 }
1003 1004
1004 WARN_ON(md->frozen_sb); 1005 WARN_ON(md->frozen_sb);
1005 md->frozen_sb = freeze_bdev(bdev); 1006
1007 md->frozen_sb = freeze_bdev(md->frozen_bdev);
1008 if (IS_ERR(md->frozen_sb)) {
1009 error = PTR_ERR(md->frozen_sb);
1010 goto out_bdput;
1011 }
1012
1006 /* don't bdput right now, we don't want the bdev 1013 /* don't bdput right now, we don't want the bdev
1007 * to go away while it is locked. We'll bdput 1014 * to go away while it is locked. We'll bdput
1008 * in __unlock_fs 1015 * in __unlock_fs
1009 */ 1016 */
1010 return 0; 1017 return 0;
1018
1019out_bdput:
1020 bdput(md->frozen_bdev);
1021 md->frozen_sb = NULL;
1022 md->frozen_bdev = NULL;
1023out:
1024 clear_bit(DMF_FS_LOCKED, &md->flags);
1025 return error;
1011} 1026}
1012 1027
1013static int __unlock_fs(struct mapped_device *md) 1028static void __unlock_fs(struct mapped_device *md)
1014{ 1029{
1015 struct block_device *bdev;
1016
1017 if (!test_and_clear_bit(DMF_FS_LOCKED, &md->flags)) 1030 if (!test_and_clear_bit(DMF_FS_LOCKED, &md->flags))
1018 return 0; 1031 return;
1019 1032
1020 bdev = bdget_disk(md->disk, 0); 1033 thaw_bdev(md->frozen_bdev, md->frozen_sb);
1021 if (!bdev) { 1034 bdput(md->frozen_bdev);
1022 DMWARN("bdget failed in __unlock_fs");
1023 return -ENOMEM;
1024 }
1025 1035
1026 thaw_bdev(bdev, md->frozen_sb);
1027 md->frozen_sb = NULL; 1036 md->frozen_sb = NULL;
1028 bdput(bdev); 1037 md->frozen_bdev = NULL;
1029 bdput(bdev);
1030 return 0;
1031} 1038}
1032 1039
1033/* 1040/*
@@ -1041,37 +1048,37 @@ int dm_suspend(struct mapped_device *md)
1041{ 1048{
1042 struct dm_table *map; 1049 struct dm_table *map;
1043 DECLARE_WAITQUEUE(wait, current); 1050 DECLARE_WAITQUEUE(wait, current);
1051 int error = -EINVAL;
1044 1052
1045 /* Flush I/O to the device. */ 1053 /* Flush I/O to the device. */
1046 down_read(&md->lock); 1054 down_read(&md->lock);
1047 if (test_bit(DMF_BLOCK_IO, &md->flags)) { 1055 if (test_bit(DMF_BLOCK_IO, &md->flags))
1048 up_read(&md->lock); 1056 goto out_read_unlock;
1049 return -EINVAL; 1057
1050 } 1058 error = __lock_fs(md);
1059 if (error)
1060 goto out_read_unlock;
1051 1061
1052 map = dm_get_table(md); 1062 map = dm_get_table(md);
1053 if (map) 1063 if (map)
1054 dm_table_presuspend_targets(map); 1064 dm_table_presuspend_targets(map);
1055 __lock_fs(md);
1056 1065
1057 up_read(&md->lock); 1066 up_read(&md->lock);
1058 1067
1059 /* 1068 /*
1060 * First we set the BLOCK_IO flag so no more ios will be 1069 * First we set the BLOCK_IO flag so no more ios will be mapped.
1061 * mapped. 1070 *
1071 * If the flag is already set we know another thread is trying to
1072 * suspend as well, so we leave the fs locked for this thread.
1062 */ 1073 */
1074 error = -EINVAL;
1063 down_write(&md->lock); 1075 down_write(&md->lock);
1064 if (test_bit(DMF_BLOCK_IO, &md->flags)) { 1076 if (test_and_set_bit(DMF_BLOCK_IO, &md->flags)) {
1065 /* 1077 if (map)
1066 * If we get here we know another thread is 1078 dm_table_put(map);
1067 * trying to suspend as well, so we leave the fs 1079 goto out_write_unlock;
1068 * locked for this thread.
1069 */
1070 up_write(&md->lock);
1071 return -EINVAL;
1072 } 1080 }
1073 1081
1074 set_bit(DMF_BLOCK_IO, &md->flags);
1075 add_wait_queue(&md->wait, &wait); 1082 add_wait_queue(&md->wait, &wait);
1076 up_write(&md->lock); 1083 up_write(&md->lock);
1077 1084
@@ -1099,12 +1106,9 @@ int dm_suspend(struct mapped_device *md)
1099 remove_wait_queue(&md->wait, &wait); 1106 remove_wait_queue(&md->wait, &wait);
1100 1107
1101 /* were we interrupted ? */ 1108 /* were we interrupted ? */
1102 if (atomic_read(&md->pending)) { 1109 error = -EINTR;
1103 __unlock_fs(md); 1110 if (atomic_read(&md->pending))
1104 clear_bit(DMF_BLOCK_IO, &md->flags); 1111 goto out_unfreeze;
1105 up_write(&md->lock);
1106 return -EINTR;
1107 }
1108 1112
1109 set_bit(DMF_SUSPENDED, &md->flags); 1113 set_bit(DMF_SUSPENDED, &md->flags);
1110 1114
@@ -1115,6 +1119,18 @@ int dm_suspend(struct mapped_device *md)
1115 up_write(&md->lock); 1119 up_write(&md->lock);
1116 1120
1117 return 0; 1121 return 0;
1122
1123out_unfreeze:
1124 /* FIXME Undo dm_table_presuspend_targets */
1125 __unlock_fs(md);
1126 clear_bit(DMF_BLOCK_IO, &md->flags);
1127out_write_unlock:
1128 up_write(&md->lock);
1129 return error;
1130
1131out_read_unlock:
1132 up_read(&md->lock);
1133 return error;
1118} 1134}
1119 1135
1120int dm_resume(struct mapped_device *md) 1136int dm_resume(struct mapped_device *md)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 97af857d8a88..d899204d3743 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -957,7 +957,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
957} 957}
958 958
959 959
960struct super_type super_types[] = { 960static struct super_type super_types[] = {
961 [0] = { 961 [0] = {
962 .name = "0.90.0", 962 .name = "0.90.0",
963 .owner = THIS_MODULE, 963 .owner = THIS_MODULE,
@@ -2740,7 +2740,7 @@ static struct block_device_operations md_fops =
2740 .revalidate_disk= md_revalidate, 2740 .revalidate_disk= md_revalidate,
2741}; 2741};
2742 2742
2743int md_thread(void * arg) 2743static int md_thread(void * arg)
2744{ 2744{
2745 mdk_thread_t *thread = arg; 2745 mdk_thread_t *thread = arg;
2746 2746
@@ -3232,7 +3232,7 @@ void md_handle_safemode(mddev_t *mddev)
3232} 3232}
3233 3233
3234 3234
3235DECLARE_WAIT_QUEUE_HEAD(resync_wait); 3235static DECLARE_WAIT_QUEUE_HEAD(resync_wait);
3236 3236
3237#define SYNC_MARKS 10 3237#define SYNC_MARKS 10
3238#define SYNC_MARK_STEP (3*HZ) 3238#define SYNC_MARK_STEP (3*HZ)
@@ -3575,8 +3575,8 @@ void md_check_recovery(mddev_t *mddev)
3575 } 3575 }
3576} 3576}
3577 3577
3578int md_notify_reboot(struct notifier_block *this, 3578static int md_notify_reboot(struct notifier_block *this,
3579 unsigned long code, void *x) 3579 unsigned long code, void *x)
3580{ 3580{
3581 struct list_head *tmp; 3581 struct list_head *tmp;
3582 mddev_t *mddev; 3582 mddev_t *mddev;
@@ -3599,7 +3599,7 @@ int md_notify_reboot(struct notifier_block *this,
3599 return NOTIFY_DONE; 3599 return NOTIFY_DONE;
3600} 3600}
3601 3601
3602struct notifier_block md_notifier = { 3602static struct notifier_block md_notifier = {
3603 .notifier_call = md_notify_reboot, 3603 .notifier_call = md_notify_reboot,
3604 .next = NULL, 3604 .next = NULL,
3605 .priority = INT_MAX, /* before any real devices */ 3605 .priority = INT_MAX, /* before any real devices */
@@ -3616,7 +3616,7 @@ static void md_geninit(void)
3616 p->proc_fops = &md_seq_fops; 3616 p->proc_fops = &md_seq_fops;
3617} 3617}
3618 3618
3619int __init md_init(void) 3619static int __init md_init(void)
3620{ 3620{
3621 int minor; 3621 int minor;
3622 3622
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index c9b134cd1532..4e4bfde3db5d 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -103,7 +103,8 @@ static void multipath_end_bh_io (struct multipath_bh *mp_bh, int err)
103 mempool_free(mp_bh, conf->pool); 103 mempool_free(mp_bh, conf->pool);
104} 104}
105 105
106int multipath_end_request(struct bio *bio, unsigned int bytes_done, int error) 106static int multipath_end_request(struct bio *bio, unsigned int bytes_done,
107 int error)
107{ 108{
108 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 109 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
109 struct multipath_bh * mp_bh = (struct multipath_bh *)(bio->bi_private); 110 struct multipath_bh * mp_bh = (struct multipath_bh *)(bio->bi_private);
@@ -355,7 +356,7 @@ static int multipath_remove_disk(mddev_t *mddev, int number)
355 goto abort; 356 goto abort;
356 } 357 }
357 p->rdev = NULL; 358 p->rdev = NULL;
358 synchronize_kernel(); 359 synchronize_rcu();
359 if (atomic_read(&rdev->nr_pending)) { 360 if (atomic_read(&rdev->nr_pending)) {
360 /* lost the race, try later */ 361 /* lost the race, try later */
361 err = -EBUSY; 362 err = -EBUSY;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index a389394b52f6..83380b5d6593 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -797,7 +797,7 @@ static int raid1_remove_disk(mddev_t *mddev, int number)
797 goto abort; 797 goto abort;
798 } 798 }
799 p->rdev = NULL; 799 p->rdev = NULL;
800 synchronize_kernel(); 800 synchronize_rcu();
801 if (atomic_read(&rdev->nr_pending)) { 801 if (atomic_read(&rdev->nr_pending)) {
802 /* lost the race, try later */ 802 /* lost the race, try later */
803 err = -EBUSY; 803 err = -EBUSY;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index b100bfe4fdca..e9dc2876a626 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -977,7 +977,7 @@ static int raid10_remove_disk(mddev_t *mddev, int number)
977 goto abort; 977 goto abort;
978 } 978 }
979 p->rdev = NULL; 979 p->rdev = NULL;
980 synchronize_kernel(); 980 synchronize_rcu();
981 if (atomic_read(&rdev->nr_pending)) { 981 if (atomic_read(&rdev->nr_pending)) {
982 /* lost the race, try later */ 982 /* lost the race, try later */
983 err = -EBUSY; 983 err = -EBUSY;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 52c3a81c4aa7..e96e2a10a9c9 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1873,7 +1873,7 @@ static int raid5_remove_disk(mddev_t *mddev, int number)
1873 goto abort; 1873 goto abort;
1874 } 1874 }
1875 p->rdev = NULL; 1875 p->rdev = NULL;
1876 synchronize_kernel(); 1876 synchronize_rcu();
1877 if (atomic_read(&rdev->nr_pending)) { 1877 if (atomic_read(&rdev->nr_pending)) {
1878 /* lost the race, try later */ 1878 /* lost the race, try later */
1879 err = -EBUSY; 1879 err = -EBUSY;
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index 7e30ab29691a..8a33f351e092 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -2038,7 +2038,7 @@ static int raid6_remove_disk(mddev_t *mddev, int number)
2038 goto abort; 2038 goto abort;
2039 } 2039 }
2040 p->rdev = NULL; 2040 p->rdev = NULL;
2041 synchronize_kernel(); 2041 synchronize_rcu();
2042 if (atomic_read(&rdev->nr_pending)) { 2042 if (atomic_read(&rdev->nr_pending)) {
2043 /* lost the race, try later */ 2043 /* lost the race, try later */
2044 err = -EBUSY; 2044 err = -EBUSY;
diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c
index 8c842e2f59a2..84a49d2ec919 100644
--- a/drivers/media/common/ir-common.c
+++ b/drivers/media/common/ir-common.c
@@ -131,10 +131,10 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
131 [ 18 ] = KEY_KP0, 131 [ 18 ] = KEY_KP0,
132 132
133 [ 0 ] = KEY_POWER, 133 [ 0 ] = KEY_POWER,
134// [ 27 ] = MTS button 134 [ 27 ] = KEY_LANGUAGE, //MTS button
135 [ 2 ] = KEY_TUNER, // TV/FM 135 [ 2 ] = KEY_TUNER, // TV/FM
136 [ 30 ] = KEY_VIDEO, 136 [ 30 ] = KEY_VIDEO,
137// [ 22 ] = display button 137 [ 22 ] = KEY_INFO, //display button
138 [ 4 ] = KEY_VOLUMEUP, 138 [ 4 ] = KEY_VOLUMEUP,
139 [ 8 ] = KEY_VOLUMEDOWN, 139 [ 8 ] = KEY_VOLUMEDOWN,
140 [ 12 ] = KEY_CHANNELUP, 140 [ 12 ] = KEY_CHANNELUP,
@@ -142,7 +142,7 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
142 [ 3 ] = KEY_ZOOM, // fullscreen 142 [ 3 ] = KEY_ZOOM, // fullscreen
143 [ 31 ] = KEY_SUBTITLE, // closed caption/teletext 143 [ 31 ] = KEY_SUBTITLE, // closed caption/teletext
144 [ 32 ] = KEY_SLEEP, 144 [ 32 ] = KEY_SLEEP,
145// [ 41 ] = boss key 145 [ 41 ] = KEY_SEARCH, //boss key
146 [ 20 ] = KEY_MUTE, 146 [ 20 ] = KEY_MUTE,
147 [ 43 ] = KEY_RED, 147 [ 43 ] = KEY_RED,
148 [ 44 ] = KEY_GREEN, 148 [ 44 ] = KEY_GREEN,
@@ -150,17 +150,17 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
150 [ 46 ] = KEY_BLUE, 150 [ 46 ] = KEY_BLUE,
151 [ 24 ] = KEY_KPPLUS, //fine tune + 151 [ 24 ] = KEY_KPPLUS, //fine tune +
152 [ 25 ] = KEY_KPMINUS, //fine tune - 152 [ 25 ] = KEY_KPMINUS, //fine tune -
153// [ 42 ] = picture in picture 153 [ 42 ] = KEY_ANGLE, //picture in picture
154 [ 33 ] = KEY_KPDOT, 154 [ 33 ] = KEY_KPDOT,
155 [ 19 ] = KEY_KPENTER, 155 [ 19 ] = KEY_KPENTER,
156// [ 17 ] = recall 156 [ 17 ] = KEY_AGAIN, //recall
157 [ 34 ] = KEY_BACK, 157 [ 34 ] = KEY_BACK,
158 [ 35 ] = KEY_PLAYPAUSE, 158 [ 35 ] = KEY_PLAYPAUSE,
159 [ 36 ] = KEY_NEXT, 159 [ 36 ] = KEY_NEXT,
160// [ 37 ] = time shifting 160 [ 37 ] = KEY_T, //time shifting
161 [ 38 ] = KEY_STOP, 161 [ 38 ] = KEY_STOP,
162 [ 39 ] = KEY_RECORD 162 [ 39 ] = KEY_RECORD,
163// [ 40 ] = snapshot 163 [ 40 ] = KEY_SHUFFLE //snapshot
164}; 164};
165EXPORT_SYMBOL_GPL(ir_codes_winfast); 165EXPORT_SYMBOL_GPL(ir_codes_winfast);
166 166
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
index 1930b513eefa..011860ce36cc 100644
--- a/drivers/media/dvb/frontends/cx22702.c
+++ b/drivers/media/dvb/frontends/cx22702.c
@@ -32,6 +32,7 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include "dvb_frontend.h" 34#include "dvb_frontend.h"
35#include "dvb-pll.h"
35#include "cx22702.h" 36#include "cx22702.h"
36 37
37 38
@@ -203,7 +204,19 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet
203 204
204 /* set PLL */ 205 /* set PLL */
205 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe); 206 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) &0xfe);
206 state->config->pll_set(fe, p); 207 if (state->config->pll_set) {
208 state->config->pll_set(fe, p);
209 } else if (state->config->pll_desc) {
210 u8 pllbuf[4];
211 struct i2c_msg msg = { .addr = state->config->pll_address,
212 .buf = pllbuf, .len = 4 };
213 dvb_pll_configure(state->config->pll_desc, pllbuf,
214 p->frequency,
215 p->u.ofdm.bandwidth);
216 i2c_transfer(state->i2c, &msg, 1);
217 } else {
218 BUG();
219 }
207 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1); 220 cx22702_writereg (state, 0x0D, cx22702_readreg(state,0x0D) | 1);
208 221
209 /* set inversion */ 222 /* set inversion */
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
index 6e34f997aba2..559fdb906669 100644
--- a/drivers/media/dvb/frontends/cx22702.h
+++ b/drivers/media/dvb/frontends/cx22702.h
@@ -36,6 +36,9 @@ struct cx22702_config
36 u8 demod_address; 36 u8 demod_address;
37 37
38 /* PLL maintenance */ 38 /* PLL maintenance */
39 u8 pll_address;
40 struct dvb_pll_desc *pll_desc;
41
39 int (*pll_init)(struct dvb_frontend* fe); 42 int (*pll_init)(struct dvb_frontend* fe);
40 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); 43 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
41}; 44};
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index c1b3542dad88..d3dd4228b72d 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -252,6 +252,7 @@ config VIDEO_SAA7134_DVB
252 depends on VIDEO_SAA7134 && DVB_CORE 252 depends on VIDEO_SAA7134 && DVB_CORE
253 select VIDEO_BUF_DVB 253 select VIDEO_BUF_DVB
254 select DVB_MT352 254 select DVB_MT352
255 select DVB_CX22702
255 ---help--- 256 ---help---
256 This adds support for DVB cards based on the 257 This adds support for DVB cards based on the
257 Philips saa7134 chip. 258 Philips saa7134 chip.
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index c13f222fe6bd..033cc5498f23 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -3169,7 +3169,7 @@ static struct video_device radio_template =
3169/* ----------------------------------------------------------------------- */ 3169/* ----------------------------------------------------------------------- */
3170/* some debug code */ 3170/* some debug code */
3171 3171
3172int bttv_risc_decode(u32 risc) 3172static int bttv_risc_decode(u32 risc)
3173{ 3173{
3174 static char *instr[16] = { 3174 static char *instr[16] = {
3175 [ BT848_RISC_WRITE >> 28 ] = "write", 3175 [ BT848_RISC_WRITE >> 28 ] = "write",
@@ -3206,8 +3206,8 @@ int bttv_risc_decode(u32 risc)
3206 return incr[risc >> 28] ? incr[risc >> 28] : 1; 3206 return incr[risc >> 28] ? incr[risc >> 28] : 1;
3207} 3207}
3208 3208
3209void bttv_risc_disasm(struct bttv *btv, 3209static void bttv_risc_disasm(struct bttv *btv,
3210 struct btcx_riscmem *risc) 3210 struct btcx_riscmem *risc)
3211{ 3211{
3212 unsigned int i,j,n; 3212 unsigned int i,j,n;
3213 3213
diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c
index e42f1ec13f3e..e3f477dff827 100644
--- a/drivers/media/video/bttv-i2c.c
+++ b/drivers/media/video/bttv-i2c.c
@@ -29,6 +29,7 @@
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/jiffies.h>
32#include <asm/io.h> 33#include <asm/io.h>
33 34
34#include "bttvp.h" 35#include "bttvp.h"
@@ -130,17 +131,14 @@ static u32 functionality(struct i2c_adapter *adap)
130static int 131static int
131bttv_i2c_wait_done(struct bttv *btv) 132bttv_i2c_wait_done(struct bttv *btv)
132{ 133{
133 DECLARE_WAITQUEUE(wait, current);
134 int rc = 0; 134 int rc = 0;
135 135
136 add_wait_queue(&btv->i2c_queue, &wait); 136 /* timeout */
137 if (0 == btv->i2c_done) 137 if (wait_event_interruptible_timeout(btv->i2c_queue,
138 msleep_interruptible(20); 138 btv->i2c_done, msecs_to_jiffies(85)) == -ERESTARTSYS)
139 remove_wait_queue(&btv->i2c_queue, &wait); 139
140 rc = -EIO;
140 141
141 if (0 == btv->i2c_done)
142 /* timeout */
143 rc = -EIO;
144 if (btv->i2c_done & BT848_INT_RACK) 142 if (btv->i2c_done & BT848_INT_RACK)
145 rc = 1; 143 rc = 1;
146 btv->i2c_done = 0; 144 btv->i2c_done = 0;
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 26a6138015cb..1ff79b5a8835 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -429,7 +429,7 @@ int cx88_sram_channel_setup(struct cx88_core *core,
429/* ------------------------------------------------------------------ */ 429/* ------------------------------------------------------------------ */
430/* debug helper code */ 430/* debug helper code */
431 431
432int cx88_risc_decode(u32 risc) 432static int cx88_risc_decode(u32 risc)
433{ 433{
434 static char *instr[16] = { 434 static char *instr[16] = {
435 [ RISC_SYNC >> 28 ] = "sync", 435 [ RISC_SYNC >> 28 ] = "sync",
@@ -542,7 +542,7 @@ void cx88_sram_channel_dump(struct cx88_core *core,
542 core->name,cx_read(ch->cnt2_reg)); 542 core->name,cx_read(ch->cnt2_reg));
543} 543}
544 544
545char *cx88_pci_irqs[32] = { 545static char *cx88_pci_irqs[32] = {
546 "vid", "aud", "ts", "vip", "hst", "5", "6", "tm1", 546 "vid", "aud", "ts", "vip", "hst", "5", "6", "tm1",
547 "src_dma", "dst_dma", "risc_rd_err", "risc_wr_err", 547 "src_dma", "dst_dma", "risc_rd_err", "risc_wr_err",
548 "brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err", 548 "brdg_err", "src_dma_err", "dst_dma_err", "ipb_dma_err",
@@ -1206,7 +1206,6 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
1206/* ------------------------------------------------------------------ */ 1206/* ------------------------------------------------------------------ */
1207 1207
1208EXPORT_SYMBOL(cx88_print_ioctl); 1208EXPORT_SYMBOL(cx88_print_ioctl);
1209EXPORT_SYMBOL(cx88_pci_irqs);
1210EXPORT_SYMBOL(cx88_vid_irqs); 1209EXPORT_SYMBOL(cx88_vid_irqs);
1211EXPORT_SYMBOL(cx88_mpeg_irqs); 1210EXPORT_SYMBOL(cx88_mpeg_irqs);
1212EXPORT_SYMBOL(cx88_print_irqbits); 1211EXPORT_SYMBOL(cx88_print_irqbits);
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index bc6f18c45357..9d15d3d5a2b7 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -31,7 +31,7 @@
31#include <linux/suspend.h> 31#include <linux/suspend.h>
32 32
33/* those two frontends need merging via linuxtv cvs ... */ 33/* those two frontends need merging via linuxtv cvs ... */
34#define HAVE_CX22702 0 34#define HAVE_CX22702 1
35#define HAVE_OR51132 1 35#define HAVE_OR51132 1
36 36
37#include "cx88.h" 37#include "cx88.h"
@@ -91,7 +91,7 @@ static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb
91 cx88_free_buffer(dev->pci, (struct cx88_buffer*)vb); 91 cx88_free_buffer(dev->pci, (struct cx88_buffer*)vb);
92} 92}
93 93
94struct videobuf_queue_ops dvb_qops = { 94static struct videobuf_queue_ops dvb_qops = {
95 .buf_setup = dvb_buf_setup, 95 .buf_setup = dvb_buf_setup,
96 .buf_prepare = dvb_buf_prepare, 96 .buf_prepare = dvb_buf_prepare,
97 .buf_queue = dvb_buf_queue, 97 .buf_queue = dvb_buf_queue,
@@ -191,7 +191,7 @@ static int or51132_set_ts_param(struct dvb_frontend* fe,
191 return 0; 191 return 0;
192} 192}
193 193
194struct or51132_config pchdtv_hd3000 = { 194static struct or51132_config pchdtv_hd3000 = {
195 .demod_address = 0x15, 195 .demod_address = 0x15,
196 .pll_address = 0x61, 196 .pll_address = 0x61,
197 .pll_desc = &dvb_pll_thomson_dtt7610, 197 .pll_desc = &dvb_pll_thomson_dtt7610,
@@ -243,10 +243,8 @@ static int dvb_register(struct cx8802_dev *dev)
243 break; 243 break;
244#endif 244#endif
245 default: 245 default:
246 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n" 246 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
247 "%s: you might want to look out for patches here:\n" 247 dev->core->name);
248 "%s: http://dl.bytesex.org/patches/\n",
249 dev->core->name, dev->core->name, dev->core->name);
250 break; 248 break;
251 } 249 }
252 if (NULL == dev->dvb.frontend) { 250 if (NULL == dev->dvb.frontend) {
@@ -308,9 +306,11 @@ static int __devinit dvb_probe(struct pci_dev *pci_dev,
308 dev); 306 dev);
309 err = dvb_register(dev); 307 err = dvb_register(dev);
310 if (0 != err) 308 if (0 != err)
311 goto fail_free; 309 goto fail_fini;
312 return 0; 310 return 0;
313 311
312 fail_fini:
313 cx8802_fini_common(dev);
314 fail_free: 314 fail_free:
315 kfree(dev); 315 kfree(dev);
316 fail_core: 316 fail_core:
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index 60800172c026..0725b1288f4f 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -45,7 +45,7 @@ MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
45 45
46/* ----------------------------------------------------------------------- */ 46/* ----------------------------------------------------------------------- */
47 47
48void cx8800_bit_setscl(void *data, int state) 48static void cx8800_bit_setscl(void *data, int state)
49{ 49{
50 struct cx88_core *core = data; 50 struct cx88_core *core = data;
51 51
@@ -57,7 +57,7 @@ void cx8800_bit_setscl(void *data, int state)
57 cx_read(MO_I2C); 57 cx_read(MO_I2C);
58} 58}
59 59
60void cx8800_bit_setsda(void *data, int state) 60static void cx8800_bit_setsda(void *data, int state)
61{ 61{
62 struct cx88_core *core = data; 62 struct cx88_core *core = data;
63 63
diff --git a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c
index 471e508b0746..0584ff476387 100644
--- a/drivers/media/video/cx88/cx88-vbi.c
+++ b/drivers/media/video/cx88/cx88-vbi.c
@@ -46,9 +46,9 @@ void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f)
46 } 46 }
47} 47}
48 48
49int cx8800_start_vbi_dma(struct cx8800_dev *dev, 49static int cx8800_start_vbi_dma(struct cx8800_dev *dev,
50 struct cx88_dmaqueue *q, 50 struct cx88_dmaqueue *q,
51 struct cx88_buffer *buf) 51 struct cx88_buffer *buf)
52{ 52{
53 struct cx88_core *core = dev->core; 53 struct cx88_core *core = dev->core;
54 54
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 701f594e1816..d1f5c92f0ce5 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -325,7 +325,7 @@ static struct cx88_ctrl cx8800_ctls[] = {
325 .shift = 0, 325 .shift = 0,
326 } 326 }
327}; 327};
328const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls); 328static const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls);
329 329
330/* ------------------------------------------------------------------- */ 330/* ------------------------------------------------------------------- */
331/* resource management */ 331/* resource management */
@@ -665,7 +665,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
665 cx88_free_buffer(fh->dev->pci,buf); 665 cx88_free_buffer(fh->dev->pci,buf);
666} 666}
667 667
668struct videobuf_queue_ops cx8800_video_qops = { 668static struct videobuf_queue_ops cx8800_video_qops = {
669 .buf_setup = buffer_setup, 669 .buf_setup = buffer_setup,
670 .buf_prepare = buffer_prepare, 670 .buf_prepare = buffer_prepare,
671 .buf_queue = buffer_queue, 671 .buf_queue = buffer_queue,
@@ -1924,7 +1924,7 @@ static struct file_operations video_fops =
1924 .llseek = no_llseek, 1924 .llseek = no_llseek,
1925}; 1925};
1926 1926
1927struct video_device cx8800_video_template = 1927static struct video_device cx8800_video_template =
1928{ 1928{
1929 .name = "cx8800-video", 1929 .name = "cx8800-video",
1930 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES, 1930 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES,
@@ -1933,7 +1933,7 @@ struct video_device cx8800_video_template =
1933 .minor = -1, 1933 .minor = -1,
1934}; 1934};
1935 1935
1936struct video_device cx8800_vbi_template = 1936static struct video_device cx8800_vbi_template =
1937{ 1937{
1938 .name = "cx8800-vbi", 1938 .name = "cx8800-vbi",
1939 .type = VID_TYPE_TELETEXT|VID_TYPE_TUNER, 1939 .type = VID_TYPE_TELETEXT|VID_TYPE_TUNER,
@@ -1951,7 +1951,7 @@ static struct file_operations radio_fops =
1951 .llseek = no_llseek, 1951 .llseek = no_llseek,
1952}; 1952};
1953 1953
1954struct video_device cx8800_radio_template = 1954static struct video_device cx8800_radio_template =
1955{ 1955{
1956 .name = "cx8800-radio", 1956 .name = "cx8800-radio",
1957 .type = VID_TYPE_TUNER, 1957 .type = VID_TYPE_TUNER,
@@ -2226,7 +2226,7 @@ static int cx8800_resume(struct pci_dev *pci_dev)
2226 2226
2227/* ----------------------------------------------------------- */ 2227/* ----------------------------------------------------------- */
2228 2228
2229struct pci_device_id cx8800_pci_tbl[] = { 2229static struct pci_device_id cx8800_pci_tbl[] = {
2230 { 2230 {
2231 .vendor = 0x14f1, 2231 .vendor = 0x14f1,
2232 .device = 0x8800, 2232 .device = 0x8800,
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index b351d9eae615..88eaaaba5ad8 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -420,7 +420,6 @@ struct cx8802_dev {
420/* ----------------------------------------------------------- */ 420/* ----------------------------------------------------------- */
421/* cx88-core.c */ 421/* cx88-core.c */
422 422
423extern char *cx88_pci_irqs[32];
424extern char *cx88_vid_irqs[32]; 423extern char *cx88_vid_irqs[32];
425extern char *cx88_mpeg_irqs[32]; 424extern char *cx88_mpeg_irqs[32];
426extern void cx88_print_irqbits(char *name, char *tag, char **strings, 425extern void cx88_print_irqbits(char *name, char *tag, char **strings,
@@ -472,9 +471,6 @@ extern void cx88_core_put(struct cx88_core *core,
472/* cx88-vbi.c */ 471/* cx88-vbi.c */
473 472
474void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f); 473void cx8800_vbi_fmt(struct cx8800_dev *dev, struct v4l2_format *f);
475int cx8800_start_vbi_dma(struct cx8800_dev *dev,
476 struct cx88_dmaqueue *q,
477 struct cx88_buffer *buf);
478int cx8800_stop_vbi_dma(struct cx8800_dev *dev); 474int cx8800_stop_vbi_dma(struct cx8800_dev *dev);
479int cx8800_restart_vbi_queue(struct cx8800_dev *dev, 475int cx8800_restart_vbi_queue(struct cx8800_dev *dev,
480 struct cx88_dmaqueue *q); 476 struct cx88_dmaqueue *q);
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index c97df705df5e..7fbb8581a87d 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -380,7 +380,9 @@ static void msp3400c_setvolume(struct i2c_client *client,
380 int val = 0, bal = 0; 380 int val = 0, bal = 0;
381 381
382 if (!muted) { 382 if (!muted) {
383 val = (volume * 0x7F / 65535) << 8; 383 /* 0x7f instead if 0x73 here has sound quality issues,
384 * probably due to overmodulation + clipping ... */
385 val = (volume * 0x73 / 65535) << 8;
384 } 386 }
385 if (val) { 387 if (val) {
386 bal = (balance / 256) - 128; 388 bal = (balance / 256) - 128;
@@ -997,7 +999,13 @@ static int msp34xx_modus(int norm)
997{ 999{
998 switch (norm) { 1000 switch (norm) {
999 case VIDEO_MODE_PAL: 1001 case VIDEO_MODE_PAL:
1002#if 1
1003 /* experimental: not sure this works with all chip versions */
1004 return 0x7003;
1005#else
1006 /* previous value, try this if it breaks ... */
1000 return 0x1003; 1007 return 0x1003;
1008#endif
1001 case VIDEO_MODE_NTSC: /* BTSC */ 1009 case VIDEO_MODE_NTSC: /* BTSC */
1002 return 0x2003; 1010 return 0x2003;
1003 case VIDEO_MODE_SECAM: 1011 case VIDEO_MODE_SECAM:
@@ -1264,6 +1272,7 @@ static int msp34xxg_thread(void *data)
1264 int val, std, i; 1272 int val, std, i;
1265 1273
1266 printk("msp34xxg: daemon started\n"); 1274 printk("msp34xxg: daemon started\n");
1275 msp->source = 1; /* default */
1267 for (;;) { 1276 for (;;) {
1268 d2printk(KERN_DEBUG "msp34xxg: thread: sleep\n"); 1277 d2printk(KERN_DEBUG "msp34xxg: thread: sleep\n");
1269 msp34xx_sleep(msp,-1); 1278 msp34xx_sleep(msp,-1);
@@ -1334,8 +1343,9 @@ static void msp34xxg_set_source(struct i2c_client *client, int source)
1334 1343
1335 /* fix matrix mode to stereo and let the msp choose what 1344 /* fix matrix mode to stereo and let the msp choose what
1336 * to output according to 'source', as recommended 1345 * to output according to 'source', as recommended
1346 * for MONO (source==0) downmixing set bit[7:0] to 0x30
1337 */ 1347 */
1338 int value = (source&0x07)<<8|(source==0 ? 0x00:0x20); 1348 int value = (source&0x07)<<8|(source==0 ? 0x30:0x20);
1339 dprintk("msp34xxg: set source to %d (0x%x)\n", source, value); 1349 dprintk("msp34xxg: set source to %d (0x%x)\n", source, value);
1340 msp3400c_write(client, 1350 msp3400c_write(client,
1341 I2C_MSP3400C_DFP, 1351 I2C_MSP3400C_DFP,
@@ -1359,7 +1369,7 @@ static void msp34xxg_set_source(struct i2c_client *client, int source)
1359 msp3400c_write(client, 1369 msp3400c_write(client,
1360 I2C_MSP3400C_DEM, 1370 I2C_MSP3400C_DEM,
1361 0x22, /* a2 threshold for stereo/bilingual */ 1371 0x22, /* a2 threshold for stereo/bilingual */
1362 source==0 ? 0x7f0:stereo_threshold); 1372 stereo_threshold);
1363 msp->source=source; 1373 msp->source=source;
1364} 1374}
1365 1375
@@ -1394,7 +1404,7 @@ static void msp34xxg_detect_stereo(struct i2c_client *client)
1394static void msp34xxg_set_audmode(struct i2c_client *client, int audmode) 1404static void msp34xxg_set_audmode(struct i2c_client *client, int audmode)
1395{ 1405{
1396 struct msp3400c *msp = i2c_get_clientdata(client); 1406 struct msp3400c *msp = i2c_get_clientdata(client);
1397 int source = 0; 1407 int source;
1398 1408
1399 switch (audmode) { 1409 switch (audmode) {
1400 case V4L2_TUNER_MODE_MONO: 1410 case V4L2_TUNER_MODE_MONO:
@@ -1410,9 +1420,10 @@ static void msp34xxg_set_audmode(struct i2c_client *client, int audmode)
1410 case V4L2_TUNER_MODE_LANG2: 1420 case V4L2_TUNER_MODE_LANG2:
1411 source=4; /* stereo or B */ 1421 source=4; /* stereo or B */
1412 break; 1422 break;
1413 default: /* doing nothing: a safe, sane default */ 1423 default:
1414 audmode = 0; 1424 audmode = 0;
1415 return; 1425 source = 1;
1426 break;
1416 } 1427 }
1417 msp->audmode = audmode; 1428 msp->audmode = audmode;
1418 msp34xxg_set_source(client, source); 1429 msp34xxg_set_source(client, source);
@@ -1514,12 +1525,9 @@ static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
1514 1525
1515 msp->opmode = opmode; 1526 msp->opmode = opmode;
1516 if (OPMODE_AUTO == msp->opmode) { 1527 if (OPMODE_AUTO == msp->opmode) {
1517#if 0 /* seems to work for ivtv only, disable by default for now ... */
1518 if (HAVE_SIMPLER(msp)) 1528 if (HAVE_SIMPLER(msp))
1519 msp->opmode = OPMODE_SIMPLER; 1529 msp->opmode = OPMODE_SIMPLER;
1520 else 1530 else if (HAVE_SIMPLE(msp))
1521#endif
1522 if (HAVE_SIMPLE(msp))
1523 msp->opmode = OPMODE_SIMPLE; 1531 msp->opmode = OPMODE_SIMPLE;
1524 else 1532 else
1525 msp->opmode = OPMODE_MANUAL; 1533 msp->opmode = OPMODE_MANUAL;
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index cee13584c9cf..fe6abe34168c 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -32,9 +32,32 @@ MODULE_LICENSE("GPL");
32static struct i2c_driver driver; 32static struct i2c_driver driver;
33static struct i2c_client client_template; 33static struct i2c_client client_template;
34 34
35enum saa6752hs_videoformat {
36 SAA6752HS_VF_D1 = 0, /* standard D1 video format: 720x576 */
37 SAA6752HS_VF_2_3_D1 = 1,/* 2/3D1 video format: 480x576 */
38 SAA6752HS_VF_1_2_D1 = 2,/* 1/2D1 video format: 352x576 */
39 SAA6752HS_VF_SIF = 3, /* SIF video format: 352x288 */
40 SAA6752HS_VF_UNKNOWN,
41};
42
43static const struct v4l2_format v4l2_format_table[] =
44{
45 [SAA6752HS_VF_D1] = {
46 .fmt.pix.width = 720, .fmt.pix.height = 576 },
47 [SAA6752HS_VF_2_3_D1] = {
48 .fmt.pix.width = 480, .fmt.pix.height = 576 },
49 [SAA6752HS_VF_1_2_D1] = {
50 .fmt.pix.width = 352, .fmt.pix.height = 576 },
51 [SAA6752HS_VF_SIF] = {
52 .fmt.pix.width = 352, .fmt.pix.height = 288 },
53 [SAA6752HS_VF_UNKNOWN] = {
54 .fmt.pix.width = 0, .fmt.pix.height = 0},
55};
56
35struct saa6752hs_state { 57struct saa6752hs_state {
36 struct i2c_client client; 58 struct i2c_client client;
37 struct v4l2_mpeg_compression params; 59 struct v4l2_mpeg_compression params;
60 enum saa6752hs_videoformat video_format;
38}; 61};
39 62
40enum saa6752hs_command { 63enum saa6752hs_command {
@@ -256,6 +279,51 @@ static int saa6752hs_set_bitrate(struct i2c_client* client,
256 return 0; 279 return 0;
257} 280}
258 281
282static void saa6752hs_set_subsampling(struct i2c_client* client,
283 struct v4l2_format* f)
284{
285 struct saa6752hs_state *h = i2c_get_clientdata(client);
286 int dist_352, dist_480, dist_720;
287
288 /*
289 FIXME: translate and round width/height into EMPRESS
290 subsample type:
291
292 type | PAL | NTSC
293 ---------------------------
294 SIF | 352x288 | 352x240
295 1/2 D1 | 352x576 | 352x480
296 2/3 D1 | 480x576 | 480x480
297 D1 | 720x576 | 720x480
298 */
299
300 dist_352 = abs(f->fmt.pix.width - 352);
301 dist_480 = abs(f->fmt.pix.width - 480);
302 dist_720 = abs(f->fmt.pix.width - 720);
303 if (dist_720 < dist_480) {
304 f->fmt.pix.width = 720;
305 f->fmt.pix.height = 576;
306 h->video_format = SAA6752HS_VF_D1;
307 }
308 else if (dist_480 < dist_352) {
309 f->fmt.pix.width = 480;
310 f->fmt.pix.height = 576;
311 h->video_format = SAA6752HS_VF_2_3_D1;
312 }
313 else {
314 f->fmt.pix.width = 352;
315 if (abs(f->fmt.pix.height - 576) <
316 abs(f->fmt.pix.height - 288)) {
317 f->fmt.pix.height = 576;
318 h->video_format = SAA6752HS_VF_1_2_D1;
319 }
320 else {
321 f->fmt.pix.height = 288;
322 h->video_format = SAA6752HS_VF_SIF;
323 }
324 }
325}
326
259 327
260static void saa6752hs_set_params(struct i2c_client* client, 328static void saa6752hs_set_params(struct i2c_client* client,
261 struct v4l2_mpeg_compression* params) 329 struct v4l2_mpeg_compression* params)
@@ -315,7 +383,7 @@ static int saa6752hs_init(struct i2c_client* client)
315 383
316 // Set video format - must be done first as it resets other settings 384 // Set video format - must be done first as it resets other settings
317 buf[0] = 0x41; 385 buf[0] = 0x41;
318 buf[1] = 0 /* MPEG_VIDEO_FORMAT_D1 */; 386 buf[1] = h->video_format;
319 i2c_master_send(client, buf, 2); 387 i2c_master_send(client, buf, 2);
320 388
321 // set bitrate 389 // set bitrate
@@ -494,6 +562,25 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
494 case VIDIOC_G_MPEGCOMP: 562 case VIDIOC_G_MPEGCOMP:
495 *params = h->params; 563 *params = h->params;
496 break; 564 break;
565 case VIDIOC_G_FMT:
566 {
567 struct v4l2_format *f = arg;
568
569 if (h->video_format == SAA6752HS_VF_UNKNOWN)
570 h->video_format = SAA6752HS_VF_D1;
571 f->fmt.pix.width =
572 v4l2_format_table[h->video_format].fmt.pix.width;
573 f->fmt.pix.height =
574 v4l2_format_table[h->video_format].fmt.pix.height;
575 break ;
576 }
577 case VIDIOC_S_FMT:
578 {
579 struct v4l2_format *f = arg;
580
581 saa6752hs_set_subsampling(client, f);
582 break;
583 }
497 default: 584 default:
498 /* nothing */ 585 /* nothing */
499 break; 586 break;
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 180d3175ea5b..c51eb7f078d3 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -183,12 +183,12 @@ struct saa7134_board saa7134_boards[] = {
183 .name = "LifeView FlyTV Platinum FM", 183 .name = "LifeView FlyTV Platinum FM",
184 .audio_clock = 0x00200000, 184 .audio_clock = 0x00200000,
185 .tuner_type = TUNER_PHILIPS_TDA8290, 185 .tuner_type = TUNER_PHILIPS_TDA8290,
186// .gpiomask = 0xe000, 186 .gpiomask = 0x1E000, /* Set GP16 and unused 15,14,13 to Output */
187 .inputs = {{ 187 .inputs = {{
188 .name = name_tv, 188 .name = name_tv,
189 .vmux = 1, 189 .vmux = 1,
190 .amux = TV, 190 .amux = TV,
191// .gpio = 0x0000, 191 .gpio = 0x10000, /* GP16=1 selects TV input */
192 .tv = 1, 192 .tv = 1,
193 },{ 193 },{
194/* .name = name_tv_mono, 194/* .name = name_tv_mono,
@@ -212,12 +212,12 @@ struct saa7134_board saa7134_boards[] = {
212 .amux = LINE2, 212 .amux = LINE2,
213// .gpio = 0x4000, 213// .gpio = 0x4000,
214 }}, 214 }},
215/* .radio = { 215 .radio = {
216 .name = name_radio, 216 .name = name_radio,
217 .amux = LINE2, 217 .amux = TV,
218 .gpio = 0x2000, 218 .gpio = 0x00000, /* GP16=0 selects FM radio antenna */
219 }, 219 },
220*/ }, 220 },
221 [SAA7134_BOARD_EMPRESS] = { 221 [SAA7134_BOARD_EMPRESS] = {
222 /* "Gert Vervoort" <gert.vervoort@philips.com> */ 222 /* "Gert Vervoort" <gert.vervoort@philips.com> */
223 .name = "EMPRESS", 223 .name = "EMPRESS",
@@ -1628,11 +1628,17 @@ struct pci_device_id saa7134_pci_tbl[] = {
1628 },{ 1628 },{
1629 .vendor = PCI_VENDOR_ID_PHILIPS, 1629 .vendor = PCI_VENDOR_ID_PHILIPS,
1630 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 1630 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1631 .subvendor = 0x5168, 1631 .subvendor = 0x5168, /* Animation Technologies (LifeView) */
1632 .subdevice = 0x0214, /* Standard PCI, LR214WF */ 1632 .subdevice = 0x0214, /* Standard PCI, LR214WF */
1633 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, 1633 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM,
1634 },{ 1634 },{
1635 .vendor = PCI_VENDOR_ID_PHILIPS, 1635 .vendor = PCI_VENDOR_ID_PHILIPS,
1636 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
1637 .subvendor = 0x1489, /* KYE */
1638 .subdevice = 0x0214, /* Genius VideoWonder ProTV */
1639 .driver_data = SAA7134_BOARD_FLYTVPLATINUM_FM, /* is an LR214WF actually */
1640 },{
1641 .vendor = PCI_VENDOR_ID_PHILIPS,
1636 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 1642 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
1637 .subvendor = 0x16be, 1643 .subvendor = 0x16be,
1638 .subdevice = 0x0003, 1644 .subdevice = 0x0003,
@@ -1948,6 +1954,7 @@ int saa7134_board_init1(struct saa7134_dev *dev)
1948 dev->has_remote = 1; 1954 dev->has_remote = 1;
1949 board_flyvideo(dev); 1955 board_flyvideo(dev);
1950 break; 1956 break;
1957 case SAA7134_BOARD_FLYTVPLATINUM_FM:
1951 case SAA7134_BOARD_CINERGY400: 1958 case SAA7134_BOARD_CINERGY400:
1952 case SAA7134_BOARD_CINERGY600: 1959 case SAA7134_BOARD_CINERGY600:
1953 case SAA7134_BOARD_CINERGY600_MK3: 1960 case SAA7134_BOARD_CINERGY600_MK3:
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index dd4a6c8ee65f..c2873ae029f9 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -172,7 +172,7 @@ static int fe_request_firmware(struct dvb_frontend* fe,
172 return request_firmware(fw, name, &dev->pci->dev); 172 return request_firmware(fw, name, &dev->pci->dev);
173} 173}
174 174
175struct tda1004x_config medion_cardbus = { 175static struct tda1004x_config medion_cardbus = {
176 .demod_address = 0x08, /* not sure this is correct */ 176 .demod_address = 0x08, /* not sure this is correct */
177 .invert = 0, 177 .invert = 0,
178 .invert_oclk = 0, 178 .invert_oclk = 0,
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 2021e099e35a..fa1357336907 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -233,10 +233,7 @@ static int ts_do_ioctl(struct inode *inode, struct file *file,
233 memset(f,0,sizeof(*f)); 233 memset(f,0,sizeof(*f));
234 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 234 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
235 235
236 /* FIXME: translate subsampling type EMPRESS into 236 saa7134_i2c_call_clients(dev, cmd, arg);
237 * width/height: */
238 f->fmt.pix.width = 720; /* D1 */
239 f->fmt.pix.height = 576;
240 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; 237 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
241 f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; 238 f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
242 return 0; 239 return 0;
@@ -249,20 +246,7 @@ static int ts_do_ioctl(struct inode *inode, struct file *file,
249 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 246 if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
250 return -EINVAL; 247 return -EINVAL;
251 248
252 /* 249 saa7134_i2c_call_clients(dev, cmd, arg);
253 FIXME: translate and round width/height into EMPRESS
254 subsample type:
255
256 type | PAL | NTSC
257 ---------------------------
258 SIF | 352x288 | 352x240
259 1/2 D1 | 352x576 | 352x480
260 2/3 D1 | 480x576 | 480x480
261 D1 | 720x576 | 720x480
262 */
263
264 f->fmt.pix.width = 720; /* D1 */
265 f->fmt.pix.height = 576;
266 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; 250 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
267 f->fmt.pix.sizeimage = TS_PACKET_SIZE* dev->ts.nr_packets; 251 f->fmt.pix.sizeimage = TS_PACKET_SIZE* dev->ts.nr_packets;
268 return 0; 252 return 0;
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 727d437e07df..ca50cf531f20 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -379,6 +379,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
379 switch (dev->board) { 379 switch (dev->board) {
380 case SAA7134_BOARD_FLYVIDEO2000: 380 case SAA7134_BOARD_FLYVIDEO2000:
381 case SAA7134_BOARD_FLYVIDEO3000: 381 case SAA7134_BOARD_FLYVIDEO3000:
382 case SAA7134_BOARD_FLYTVPLATINUM_FM:
382 ir_codes = flyvideo_codes; 383 ir_codes = flyvideo_codes;
383 mask_keycode = 0xEC00000; 384 mask_keycode = 0xEC00000;
384 mask_keydown = 0x0040000; 385 mask_keydown = 0x0040000;
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 881a0539fc17..6212388edb75 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -357,8 +357,16 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
357 V4L2_TUNER_RADIO != t->mode) 357 V4L2_TUNER_RADIO != t->mode)
358 set_tv_freq(client,400*16); 358 set_tv_freq(client,400*16);
359 t->mode = f->type; 359 t->mode = f->type;
360 t->freq = f->frequency; 360 set_freq(client,f->frequency);
361 set_freq(client,t->freq); 361 break;
362 }
363 case VIDIOC_G_FREQUENCY:
364 {
365 struct v4l2_frequency *f = arg;
366
367 SWITCH_V4L2;
368 f->type = t->mode;
369 f->frequency = t->freq;
362 break; 370 break;
363 } 371 }
364 case VIDIOC_G_TUNER: 372 case VIDIOC_G_TUNER:
@@ -368,6 +376,8 @@ tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
368 SWITCH_V4L2; 376 SWITCH_V4L2;
369 if (V4L2_TUNER_RADIO == t->mode && t->has_signal) 377 if (V4L2_TUNER_RADIO == t->mode && t->has_signal)
370 tuner->signal = t->has_signal(client); 378 tuner->signal = t->has_signal(client);
379 tuner->rangelow = tv_range[0] * 16;
380 tuner->rangehigh = tv_range[1] * 16;
371 break; 381 break;
372 } 382 }
373 default: 383 default:
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 065eb4007b1d..80dc34f18c2c 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -991,7 +991,7 @@ static int tda9874a_initialize(struct CHIPSTATE *chip)
991{ 991{
992 if (tda9874a_SIF > 2) 992 if (tda9874a_SIF > 2)
993 tda9874a_SIF = 1; 993 tda9874a_SIF = 1;
994 if (tda9874a_STD >= 8) 994 if (tda9874a_STD > 8)
995 tda9874a_STD = 0; 995 tda9874a_STD = 0;
996 if(tda9874a_AMSEL > 1) 996 if(tda9874a_AMSEL > 1)
997 tda9874a_AMSEL = 0; 997 tda9874a_AMSEL = 0;
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 72f2b466b816..2e70d74fbdee 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -51,7 +51,7 @@ config MMC_PXA
51 51
52config MMC_WBSD 52config MMC_WBSD
53 tristate "Winbond W83L51xD SD/MMC Card Interface support" 53 tristate "Winbond W83L51xD SD/MMC Card Interface support"
54 depends on MMC && ISA 54 depends on MMC && ISA && ISA_DMA_API
55 help 55 help
56 This selects the Winbond(R) W83L51xD Secure digital and 56 This selects the Winbond(R) W83L51xD Secure digital and
57 Multimedia card Interface. 57 Multimedia card Interface.
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 43e2ac532f82..b5e076043431 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -1581,7 +1581,8 @@ vortex_up(struct net_device *dev)
1581 1581
1582 if (VORTEX_PCI(vp)) { 1582 if (VORTEX_PCI(vp)) {
1583 pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */ 1583 pci_set_power_state(VORTEX_PCI(vp), PCI_D0); /* Go active */
1584 pci_restore_state(VORTEX_PCI(vp)); 1584 if (vp->pm_state_valid)
1585 pci_restore_state(VORTEX_PCI(vp));
1585 pci_enable_device(VORTEX_PCI(vp)); 1586 pci_enable_device(VORTEX_PCI(vp));
1586 } 1587 }
1587 1588
@@ -2741,6 +2742,7 @@ vortex_down(struct net_device *dev, int final_down)
2741 outl(0, ioaddr + DownListPtr); 2742 outl(0, ioaddr + DownListPtr);
2742 2743
2743 if (final_down && VORTEX_PCI(vp)) { 2744 if (final_down && VORTEX_PCI(vp)) {
2745 vp->pm_state_valid = 1;
2744 pci_save_state(VORTEX_PCI(vp)); 2746 pci_save_state(VORTEX_PCI(vp));
2745 acpi_set_WOL(dev); 2747 acpi_set_WOL(dev);
2746 } 2748 }
@@ -3243,9 +3245,10 @@ static void acpi_set_WOL(struct net_device *dev)
3243 outw(RxEnable, ioaddr + EL3_CMD); 3245 outw(RxEnable, ioaddr + EL3_CMD);
3244 3246
3245 pci_enable_wake(VORTEX_PCI(vp), 0, 1); 3247 pci_enable_wake(VORTEX_PCI(vp), 0, 1);
3248
3249 /* Change the power state to D3; RxEnable doesn't take effect. */
3250 pci_set_power_state(VORTEX_PCI(vp), PCI_D3hot);
3246 } 3251 }
3247 /* Change the power state to D3; RxEnable doesn't take effect. */
3248 pci_set_power_state(VORTEX_PCI(vp), PCI_D3hot);
3249} 3252}
3250 3253
3251 3254
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 68242bda4b9c..3a0a55b62aaf 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -589,7 +589,7 @@ config EL2
589 589
590config ELPLUS 590config ELPLUS
591 tristate "3c505 \"EtherLink Plus\" support" 591 tristate "3c505 \"EtherLink Plus\" support"
592 depends on NET_VENDOR_3COM && ISA 592 depends on NET_VENDOR_3COM && ISA && ISA_DMA_API
593 ---help--- 593 ---help---
594 Information about this network (Ethernet) card can be found in 594 Information about this network (Ethernet) card can be found in
595 <file:Documentation/networking/3c505.txt>. If you have a card of 595 <file:Documentation/networking/3c505.txt>. If you have a card of
@@ -630,7 +630,7 @@ config EL3
630 630
631config 3C515 631config 3C515
632 tristate "3c515 ISA \"Fast EtherLink\"" 632 tristate "3c515 ISA \"Fast EtherLink\""
633 depends on NET_VENDOR_3COM && (ISA || EISA) 633 depends on NET_VENDOR_3COM && (ISA || EISA) && ISA_DMA_API
634 help 634 help
635 If you have a 3Com ISA EtherLink XL "Corkscrew" 3c515 Fast Ethernet 635 If you have a 3Com ISA EtherLink XL "Corkscrew" 3c515 Fast Ethernet
636 network card, say Y and read the Ethernet-HOWTO, available from 636 network card, say Y and read the Ethernet-HOWTO, available from
@@ -708,7 +708,7 @@ config TYPHOON
708 708
709config LANCE 709config LANCE
710 tristate "AMD LANCE and PCnet (AT1500 and NE2100) support" 710 tristate "AMD LANCE and PCnet (AT1500 and NE2100) support"
711 depends on NET_ETHERNET && ISA 711 depends on NET_ETHERNET && ISA && ISA_DMA_API
712 help 712 help
713 If you have a network (Ethernet) card of this type, say Y and read 713 If you have a network (Ethernet) card of this type, say Y and read
714 the Ethernet-HOWTO, available from 714 the Ethernet-HOWTO, available from
@@ -864,7 +864,7 @@ config NI52
864 864
865config NI65 865config NI65
866 tristate "NI6510 support" 866 tristate "NI6510 support"
867 depends on NET_VENDOR_RACAL && ISA 867 depends on NET_VENDOR_RACAL && ISA && ISA_DMA_API
868 help 868 help
869 If you have a network (Ethernet) card of this type, say Y and read 869 If you have a network (Ethernet) card of this type, say Y and read
870 the Ethernet-HOWTO, available from 870 the Ethernet-HOWTO, available from
@@ -1072,7 +1072,7 @@ config NE2000
1072 1072
1073config ZNET 1073config ZNET
1074 tristate "Zenith Z-Note support (EXPERIMENTAL)" 1074 tristate "Zenith Z-Note support (EXPERIMENTAL)"
1075 depends on NET_ISA && EXPERIMENTAL 1075 depends on NET_ISA && EXPERIMENTAL && ISA_DMA_API
1076 help 1076 help
1077 The Zenith Z-Note notebook computer has a built-in network 1077 The Zenith Z-Note notebook computer has a built-in network
1078 (Ethernet) card, and this is the Linux driver for it. Note that the 1078 (Ethernet) card, and this is the Linux driver for it. Note that the
diff --git a/drivers/net/Space.c b/drivers/net/Space.c
index fc519377b5aa..fb433325aa27 100644
--- a/drivers/net/Space.c
+++ b/drivers/net/Space.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)Space.c 1.0.7 08/12/93 8 * Version: @(#)Space.c 1.0.7 08/12/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Donald J. Becker, <becker@scyld.com> 12 * Donald J. Becker, <becker@scyld.com>
13 * 13 *
diff --git a/drivers/net/appletalk/Kconfig b/drivers/net/appletalk/Kconfig
index 60b19679ca5c..69c488d933a2 100644
--- a/drivers/net/appletalk/Kconfig
+++ b/drivers/net/appletalk/Kconfig
@@ -13,7 +13,7 @@ config DEV_APPLETALK
13 13
14config LTPC 14config LTPC
15 tristate "Apple/Farallon LocalTalk PC support" 15 tristate "Apple/Farallon LocalTalk PC support"
16 depends on DEV_APPLETALK && (ISA || EISA) 16 depends on DEV_APPLETALK && (ISA || EISA) && ISA_DMA_API
17 help 17 help
18 This allows you to use the AppleTalk PC card to connect to LocalTalk 18 This allows you to use the AppleTalk PC card to connect to LocalTalk
19 networks. The card is also known as the Farallon PhoneNet PC card. 19 networks. The card is also known as the Farallon PhoneNet PC card.
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index 2161c2d585f0..9edaa183227a 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -65,7 +65,7 @@ static const char *version =
65#include <linux/etherdevice.h> 65#include <linux/etherdevice.h>
66#include <linux/skbuff.h> 66#include <linux/skbuff.h>
67#include <linux/if_arp.h> 67#include <linux/if_arp.h>
68#include <linux/if_ltalk.h> /* For ltalk_setup() */ 68#include <linux/if_ltalk.h>
69#include <linux/delay.h> /* For udelay() */ 69#include <linux/delay.h> /* For udelay() */
70#include <linux/atalk.h> 70#include <linux/atalk.h>
71#include <linux/spinlock.h> 71#include <linux/spinlock.h>
@@ -223,7 +223,7 @@ struct net_device * __init cops_probe(int unit)
223 int base_addr; 223 int base_addr;
224 int err = 0; 224 int err = 0;
225 225
226 dev = alloc_netdev(sizeof(struct cops_local), "lt%d", ltalk_setup); 226 dev = alloc_ltalkdev(sizeof(struct cops_local));
227 if (!dev) 227 if (!dev)
228 return ERR_PTR(-ENOMEM); 228 return ERR_PTR(-ENOMEM);
229 229
diff --git a/drivers/net/appletalk/cops_ffdrv.h b/drivers/net/appletalk/cops_ffdrv.h
index 4131b4a7a65b..31cf8c9c947f 100644
--- a/drivers/net/appletalk/cops_ffdrv.h
+++ b/drivers/net/appletalk/cops_ffdrv.h
@@ -28,7 +28,7 @@
28 28
29#ifdef CONFIG_COPS_DAYNA 29#ifdef CONFIG_COPS_DAYNA
30 30
31unsigned char ffdrv_code[] = { 31static const unsigned char ffdrv_code[] = {
32 58,3,0,50,228,149,33,255,255,34,226,149, 32 58,3,0,50,228,149,33,255,255,34,226,149,
33 249,17,40,152,33,202,154,183,237,82,77,68, 33 249,17,40,152,33,202,154,183,237,82,77,68,
34 11,107,98,19,54,0,237,176,175,50,80,0, 34 11,107,98,19,54,0,237,176,175,50,80,0,
diff --git a/drivers/net/appletalk/cops_ltdrv.h b/drivers/net/appletalk/cops_ltdrv.h
index 05de66dd9206..4afb8e18ba65 100644
--- a/drivers/net/appletalk/cops_ltdrv.h
+++ b/drivers/net/appletalk/cops_ltdrv.h
@@ -27,7 +27,7 @@
27 27
28#ifdef CONFIG_COPS_TANGENT 28#ifdef CONFIG_COPS_TANGENT
29 29
30unsigned char ltdrv_code[] = { 30static const unsigned char ltdrv_code[] = {
31 58,3,0,50,148,10,33,143,15,62,85,119, 31 58,3,0,50,148,10,33,143,15,62,85,119,
32 190,32,9,62,170,119,190,32,3,35,24,241, 32 190,32,9,62,170,119,190,32,3,35,24,241,
33 34,146,10,249,17,150,10,33,143,15,183,237, 33 34,146,10,249,17,150,10,33,143,15,183,237,
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c
index ad8e943231a1..db4f369637b6 100644
--- a/drivers/net/appletalk/ltpc.c
+++ b/drivers/net/appletalk/ltpc.c
@@ -1039,7 +1039,7 @@ struct net_device * __init ltpc_probe(void)
1039 unsigned long f; 1039 unsigned long f;
1040 unsigned long timeout; 1040 unsigned long timeout;
1041 1041
1042 dev = alloc_netdev(sizeof(struct ltpc_private), "lt%d", ltalk_setup); 1042 dev = alloc_ltalkdev(sizeof(struct ltpc_private));
1043 if (!dev) 1043 if (!dev)
1044 goto out; 1044 goto out;
1045 1045
diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index 16e155b04129..66485585ab39 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -48,7 +48,7 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
48static int ack_tx(struct net_device *dev, int acked); 48static int ack_tx(struct net_device *dev, int acked);
49 49
50 50
51struct ArcProto capmode_proto = 51static struct ArcProto capmode_proto =
52{ 52{
53 'r', 53 'r',
54 XMTU, 54 XMTU,
diff --git a/drivers/net/gt96100eth.h b/drivers/net/gt96100eth.h
index 2f4bfd4dacbe..395869c5ed3e 100644
--- a/drivers/net/gt96100eth.h
+++ b/drivers/net/gt96100eth.h
@@ -214,7 +214,7 @@ typedef struct {
214 u32 cmdstat; 214 u32 cmdstat;
215 u32 next; 215 u32 next;
216 u32 buff_ptr; 216 u32 buff_ptr;
217} gt96100_td_t __attribute__ ((packed)); 217} __attribute__ ((packed)) gt96100_td_t;
218 218
219typedef struct { 219typedef struct {
220#ifdef DESC_BE 220#ifdef DESC_BE
@@ -227,7 +227,7 @@ typedef struct {
227 u32 cmdstat; 227 u32 cmdstat;
228 u32 next; 228 u32 next;
229 u32 buff_ptr; 229 u32 buff_ptr;
230} gt96100_rd_t __attribute__ ((packed)); 230} __attribute__ ((packed)) gt96100_rd_t;
231 231
232 232
233/* Values for the Tx command-status descriptor entry. */ 233/* Values for the Tx command-status descriptor entry. */
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 067b353e1cbd..89454915b857 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -394,13 +394,11 @@ static void sp_bump(struct sixpack *sp, char cmd)
394 if ((skb = dev_alloc_skb(count)) == NULL) 394 if ((skb = dev_alloc_skb(count)) == NULL)
395 goto out_mem; 395 goto out_mem;
396 396
397 skb->dev = sp->dev;
398 ptr = skb_put(skb, count); 397 ptr = skb_put(skb, count);
399 *ptr++ = cmd; /* KISS command */ 398 *ptr++ = cmd; /* KISS command */
400 399
401 memcpy(ptr, sp->cooked_buf + 1, count); 400 memcpy(ptr, sp->cooked_buf + 1, count);
402 skb->mac.raw = skb->data; 401 skb->protocol = ax25_type_trans(skb, sp->dev);
403 skb->protocol = htons(ETH_P_AX25);
404 netif_rx(skb); 402 netif_rx(skb);
405 sp->dev->last_rx = jiffies; 403 sp->dev->last_rx = jiffies;
406 sp->stats.rx_packets++; 404 sp->stats.rx_packets++;
diff --git a/drivers/net/hamradio/Kconfig b/drivers/net/hamradio/Kconfig
index 34068f81d45e..7cdebe1a0b61 100644
--- a/drivers/net/hamradio/Kconfig
+++ b/drivers/net/hamradio/Kconfig
@@ -45,7 +45,7 @@ config BPQETHER
45 45
46config DMASCC 46config DMASCC
47 tristate "High-speed (DMA) SCC driver for AX.25" 47 tristate "High-speed (DMA) SCC driver for AX.25"
48 depends on ISA && AX25 && BROKEN_ON_SMP 48 depends on ISA && AX25 && BROKEN_ON_SMP && ISA_DMA_API
49 ---help--- 49 ---help---
50 This is a driver for high-speed SCC boards, i.e. those supporting 50 This is a driver for high-speed SCC boards, i.e. those supporting
51 DMA on one port. You usually use those boards to connect your 51 DMA on one port. You usually use those boards to connect your
@@ -78,7 +78,7 @@ config DMASCC
78 78
79config SCC 79config SCC
80 tristate "Z8530 SCC driver" 80 tristate "Z8530 SCC driver"
81 depends on ISA && AX25 81 depends on ISA && AX25 && ISA_DMA_API
82 ---help--- 82 ---help---
83 These cards are used to connect your Linux box to an amateur radio 83 These cards are used to connect your Linux box to an amateur radio
84 in order to communicate with other computers. If you want to use 84 in order to communicate with other computers. If you want to use
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index e8cb87d906fc..1c563f905a59 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -601,12 +601,10 @@ static void do_rxpacket(struct net_device *dev)
601 bc->stats.rx_dropped++; 601 bc->stats.rx_dropped++;
602 return; 602 return;
603 } 603 }
604 skb->dev = dev;
605 cp = skb_put(skb, pktlen); 604 cp = skb_put(skb, pktlen);
606 *cp++ = 0; /* KISS kludge */ 605 *cp++ = 0; /* KISS kludge */
607 memcpy(cp, bc->hdlcrx.buf, pktlen - 1); 606 memcpy(cp, bc->hdlcrx.buf, pktlen - 1);
608 skb->protocol = htons(ETH_P_AX25); 607 skb->protocol = ax25_type_trans(skb, dev);
609 skb->mac.raw = skb->data;
610 netif_rx(skb); 608 netif_rx(skb);
611 dev->last_rx = jiffies; 609 dev->last_rx = jiffies;
612 bc->stats.rx_packets++; 610 bc->stats.rx_packets++;
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index ef1a359e2273..ba9f0580e1f9 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -211,11 +211,7 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
211 ptr = skb_push(skb, 1); 211 ptr = skb_push(skb, 1);
212 *ptr = 0; 212 *ptr = 0;
213 213
214 skb->dev = dev; 214 skb->protocol = ax25_type_trans(skb, dev);
215 skb->protocol = htons(ETH_P_AX25);
216 skb->mac.raw = skb->data;
217 skb->pkt_type = PACKET_HOST;
218
219 netif_rx(skb); 215 netif_rx(skb);
220 dev->last_rx = jiffies; 216 dev->last_rx = jiffies;
221unlock: 217unlock:
@@ -272,8 +268,6 @@ static int bpq_xmit(struct sk_buff *skb, struct net_device *dev)
272 skb = newskb; 268 skb = newskb;
273 } 269 }
274 270
275 skb->protocol = htons(ETH_P_AX25);
276
277 ptr = skb_push(skb, 2); 271 ptr = skb_push(skb, 2);
278 272
279 *ptr++ = (size + 5) % 256; 273 *ptr++ = (size + 5) % 256;
@@ -287,7 +281,7 @@ static int bpq_xmit(struct sk_buff *skb, struct net_device *dev)
287 return -ENODEV; 281 return -ENODEV;
288 } 282 }
289 283
290 skb->dev = dev; 284 skb->protocol = ax25_type_trans(skb, dev);
291 skb->nh.raw = skb->data; 285 skb->nh.raw = skb->data;
292 dev->hard_header(skb, dev, ETH_P_BPQ, bpq->dest_addr, NULL, 0); 286 dev->hard_header(skb, dev, ETH_P_BPQ, bpq->dest_addr, NULL, 0);
293 bpq->stats.tx_packets++; 287 bpq->stats.tx_packets++;
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index f3269b70a8c5..f515245a3fd0 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -1306,9 +1306,7 @@ static void rx_bh(void *arg)
1306 data = skb_put(skb, cb + 1); 1306 data = skb_put(skb, cb + 1);
1307 data[0] = 0; 1307 data[0] = 0;
1308 memcpy(&data[1], priv->rx_buf[i], cb); 1308 memcpy(&data[1], priv->rx_buf[i], cb);
1309 skb->dev = priv->dev; 1309 skb->protocol = ax25_type_trans(skb, priv->dev);
1310 skb->protocol = ntohs(ETH_P_AX25);
1311 skb->mac.raw = skb->data;
1312 netif_rx(skb); 1310 netif_rx(skb);
1313 priv->dev->last_rx = jiffies; 1311 priv->dev->last_rx = jiffies;
1314 priv->stats.rx_packets++; 1312 priv->stats.rx_packets++;
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index b89959a596d7..b4c836e4fe86 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -174,12 +174,10 @@ static void hdlc_rx_flag(struct net_device *dev, struct hdlcdrv_state *s)
174 s->stats.rx_dropped++; 174 s->stats.rx_dropped++;
175 return; 175 return;
176 } 176 }
177 skb->dev = dev;
178 cp = skb_put(skb, pkt_len); 177 cp = skb_put(skb, pkt_len);
179 *cp++ = 0; /* KISS kludge */ 178 *cp++ = 0; /* KISS kludge */
180 memcpy(cp, s->hdlcrx.buffer, pkt_len - 1); 179 memcpy(cp, s->hdlcrx.buffer, pkt_len - 1);
181 skb->protocol = htons(ETH_P_AX25); 180 skb->protocol = ax25_type_trans(skb, dev);
182 skb->mac.raw = skb->data;
183 netif_rx(skb); 181 netif_rx(skb);
184 dev->last_rx = jiffies; 182 dev->last_rx = jiffies;
185 s->stats.rx_packets++; 183 s->stats.rx_packets++;
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index d9ea080aea0f..62790511098f 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -332,12 +332,10 @@ static void ax_bump(struct ax_disp *ax)
332 return; 332 return;
333 } 333 }
334 334
335 skb->dev = ax->dev;
336 spin_lock_bh(&ax->buflock); 335 spin_lock_bh(&ax->buflock);
337 memcpy(skb_put(skb,count), ax->rbuff, count); 336 memcpy(skb_put(skb,count), ax->rbuff, count);
338 spin_unlock_bh(&ax->buflock); 337 spin_unlock_bh(&ax->buflock);
339 skb->mac.raw = skb->data; 338 skb->protocol = ax25_type_trans(skb, ax->dev);
340 skb->protocol = htons(ETH_P_AX25);
341 netif_rx(skb); 339 netif_rx(skb);
342 ax->dev->last_rx = jiffies; 340 ax->dev->last_rx = jiffies;
343 ax->rx_packets++; 341 ax->rx_packets++;
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index ce9e7af020da..ece1b1a13186 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -1630,10 +1630,7 @@ static void scc_net_rx(struct scc_channel *scc, struct sk_buff *skb)
1630 scc->dev_stat.rx_packets++; 1630 scc->dev_stat.rx_packets++;
1631 scc->dev_stat.rx_bytes += skb->len; 1631 scc->dev_stat.rx_bytes += skb->len;
1632 1632
1633 skb->dev = scc->dev; 1633 skb->protocol = ax25_type_trans(skb, scc->dev);
1634 skb->protocol = htons(ETH_P_AX25);
1635 skb->mac.raw = skb->data;
1636 skb->pkt_type = PACKET_HOST;
1637 1634
1638 netif_rx(skb); 1635 netif_rx(skb);
1639 scc->dev->last_rx = jiffies; 1636 scc->dev->last_rx = jiffies;
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index fd7b00fe38e5..41213ef602dc 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -522,12 +522,10 @@ static inline void yam_rx_flag(struct net_device *dev, struct yam_port *yp)
522 ++yp->stats.rx_dropped; 522 ++yp->stats.rx_dropped;
523 } else { 523 } else {
524 unsigned char *cp; 524 unsigned char *cp;
525 skb->dev = dev;
526 cp = skb_put(skb, pkt_len); 525 cp = skb_put(skb, pkt_len);
527 *cp++ = 0; /* KISS kludge */ 526 *cp++ = 0; /* KISS kludge */
528 memcpy(cp, yp->rx_buf, pkt_len - 1); 527 memcpy(cp, yp->rx_buf, pkt_len - 1);
529 skb->protocol = htons(ETH_P_AX25); 528 skb->protocol = ax25_type_trans(skb, dev);
530 skb->mac.raw = skb->data;
531 netif_rx(skb); 529 netif_rx(skb);
532 dev->last_rx = jiffies; 530 dev->last_rx = jiffies;
533 ++yp->stats.rx_packets; 531 ++yp->stats.rx_packets;
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index acb170152bbd..b3a898c5a585 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -13,8 +13,8 @@
13** This driver has only been tested with 13** This driver has only been tested with
14** -- HP J2585B 10/100 Mbit/s PCI Busmaster 14** -- HP J2585B 10/100 Mbit/s PCI Busmaster
15** -- HP J2585A 10/100 Mbit/s PCI 15** -- HP J2585A 10/100 Mbit/s PCI
16** -- HP J2970 10 Mbit/s PCI Combo 10base-T/BNC 16** -- HP J2970A 10 Mbit/s PCI Combo 10base-T/BNC
17** -- HP J2973 10 Mbit/s PCI 10base-T 17** -- HP J2973A 10 Mbit/s PCI 10base-T
18** -- HP J2573 10/100 ISA 18** -- HP J2573 10/100 ISA
19** -- Compex ReadyLink ENET100-VG4 10/100 Mbit/s PCI / EISA 19** -- Compex ReadyLink ENET100-VG4 10/100 Mbit/s PCI / EISA
20** -- Compex FreedomLine 100/VG 10/100 Mbit/s ISA / EISA / PCI 20** -- Compex FreedomLine 100/VG 10/100 Mbit/s ISA / EISA / PCI
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index 6bf76a444d48..1c553d7efdd9 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -310,7 +310,7 @@ config SIGMATEL_FIR
310 310
311config NSC_FIR 311config NSC_FIR
312 tristate "NSC PC87108/PC87338" 312 tristate "NSC PC87108/PC87338"
313 depends on IRDA 313 depends on IRDA && ISA_DMA_API
314 help 314 help
315 Say Y here if you want to build support for the NSC PC87108 and 315 Say Y here if you want to build support for the NSC PC87108 and
316 PC87338 IrDA chipsets. This driver supports SIR, 316 PC87338 IrDA chipsets. This driver supports SIR,
@@ -321,7 +321,7 @@ config NSC_FIR
321 321
322config WINBOND_FIR 322config WINBOND_FIR
323 tristate "Winbond W83977AF (IR)" 323 tristate "Winbond W83977AF (IR)"
324 depends on IRDA 324 depends on IRDA && ISA_DMA_API
325 help 325 help
326 Say Y here if you want to build IrDA support for the Winbond 326 Say Y here if you want to build IrDA support for the Winbond
327 W83977AF super-io chipset. This driver should be used for the IrDA 327 W83977AF super-io chipset. This driver should be used for the IrDA
@@ -347,7 +347,7 @@ config AU1000_FIR
347 347
348config SMC_IRCC_FIR 348config SMC_IRCC_FIR
349 tristate "SMSC IrCC (EXPERIMENTAL)" 349 tristate "SMSC IrCC (EXPERIMENTAL)"
350 depends on EXPERIMENTAL && IRDA 350 depends on EXPERIMENTAL && IRDA && ISA_DMA_API
351 help 351 help
352 Say Y here if you want to build support for the SMC Infrared 352 Say Y here if you want to build support for the SMC Infrared
353 Communications Controller. It is used in a wide variety of 353 Communications Controller. It is used in a wide variety of
@@ -357,7 +357,7 @@ config SMC_IRCC_FIR
357 357
358config ALI_FIR 358config ALI_FIR
359 tristate "ALi M5123 FIR (EXPERIMENTAL)" 359 tristate "ALi M5123 FIR (EXPERIMENTAL)"
360 depends on EXPERIMENTAL && IRDA 360 depends on EXPERIMENTAL && IRDA && ISA_DMA_API
361 help 361 help
362 Say Y here if you want to build support for the ALi M5123 FIR 362 Say Y here if you want to build support for the ALi M5123 FIR
363 Controller. The ALi M5123 FIR Controller is embedded in ALi M1543C, 363 Controller. The ALi M5123 FIR Controller is embedded in ALi M1543C,
@@ -385,7 +385,7 @@ config SA1100_FIR
385 385
386config VIA_FIR 386config VIA_FIR
387 tristate "VIA VT8231/VT1211 SIR/MIR/FIR" 387 tristate "VIA VT8231/VT1211 SIR/MIR/FIR"
388 depends on IRDA 388 depends on IRDA && ISA_DMA_API
389 help 389 help
390 Say Y here if you want to build support for the VIA VT8231 390 Say Y here if you want to build support for the VIA VT8231
391 and VIA VT1211 IrDA controllers, found on the motherboards using 391 and VIA VT1211 IrDA controllers, found on the motherboards using
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 2ffc31708d5f..b33111e21313 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Version: @(#)loopback.c 1.0.4b 08/16/93 8 * Version: @(#)loopback.c 1.0.4b 08/16/93
9 * 9 *
10 * Authors: Ross Biro, <bir7@leland.Stanford.Edu> 10 * Authors: Ross Biro
11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 11 * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
12 * Donald Becker, <becker@scyld.com> 12 * Donald Becker, <becker@scyld.com>
13 * 13 *
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 7e94d455533c..0405e1f0d3df 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -99,7 +99,7 @@ static spinlock_t mv643xx_eth_phy_lock = SPIN_LOCK_UNLOCKED;
99 99
100static inline u32 mv_read(int offset) 100static inline u32 mv_read(int offset)
101{ 101{
102 void *__iomem reg_base; 102 void __iomem *reg_base;
103 103
104 reg_base = mv643xx_eth_shared_base - MV643XX_ETH_SHARED_REGS; 104 reg_base = mv643xx_eth_shared_base - MV643XX_ETH_SHARED_REGS;
105 105
@@ -108,7 +108,7 @@ static inline u32 mv_read(int offset)
108 108
109static inline void mv_write(int offset, u32 data) 109static inline void mv_write(int offset, u32 data)
110{ 110{
111 void * __iomem reg_base; 111 void __iomem *reg_base;
112 112
113 reg_base = mv643xx_eth_shared_base - MV643XX_ETH_SHARED_REGS; 113 reg_base = mv643xx_eth_shared_base - MV643XX_ETH_SHARED_REGS;
114 writel(data, reg_base + offset); 114 writel(data, reg_base + offset);
diff --git a/drivers/net/ppp_deflate.c b/drivers/net/ppp_deflate.c
index 507d6328d4eb..3872088fdd10 100644
--- a/drivers/net/ppp_deflate.c
+++ b/drivers/net/ppp_deflate.c
@@ -87,8 +87,7 @@ static void z_comp_free(void *arg)
87 87
88 if (state) { 88 if (state) {
89 zlib_deflateEnd(&state->strm); 89 zlib_deflateEnd(&state->strm);
90 if (state->strm.workspace) 90 vfree(state->strm.workspace);
91 vfree(state->strm.workspace);
92 kfree(state); 91 kfree(state);
93 } 92 }
94} 93}
@@ -308,8 +307,7 @@ static void z_decomp_free(void *arg)
308 307
309 if (state) { 308 if (state) {
310 zlib_inflateEnd(&state->strm); 309 zlib_inflateEnd(&state->strm);
311 if (state->strm.workspace) 310 kfree(state->strm.workspace);
312 kfree(state->strm.workspace);
313 kfree(state); 311 kfree(state);
314 } 312 }
315} 313}
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index c456dc81b873..3b377f6cd4a0 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -2467,14 +2467,10 @@ static void ppp_destroy_interface(struct ppp *ppp)
2467 skb_queue_purge(&ppp->mrq); 2467 skb_queue_purge(&ppp->mrq);
2468#endif /* CONFIG_PPP_MULTILINK */ 2468#endif /* CONFIG_PPP_MULTILINK */
2469#ifdef CONFIG_PPP_FILTER 2469#ifdef CONFIG_PPP_FILTER
2470 if (ppp->pass_filter) { 2470 kfree(ppp->pass_filter);
2471 kfree(ppp->pass_filter); 2471 ppp->pass_filter = NULL;
2472 ppp->pass_filter = NULL; 2472 kfree(ppp->active_filter);
2473 } 2473 ppp->active_filter = NULL;
2474 if (ppp->active_filter) {
2475 kfree(ppp->active_filter);
2476 ppp->active_filter = NULL;
2477 }
2478#endif /* CONFIG_PPP_FILTER */ 2474#endif /* CONFIG_PPP_FILTER */
2479 2475
2480 kfree(ppp); 2476 kfree(ppp);
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 07e2df09491f..c59507f8a76b 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -2385,7 +2385,7 @@ core_down:
2385 } 2385 }
2386 2386
2387 /* Give a racing hard_start_xmit a few cycles to complete. */ 2387 /* Give a racing hard_start_xmit a few cycles to complete. */
2388 synchronize_kernel(); 2388 synchronize_sched(); /* FIXME: should this be synchronize_irq()? */
2389 2389
2390 /* 2390 /*
2391 * And now for the 50k$ question: are IRQ disabled or not ? 2391 * And now for the 50k$ question: are IRQ disabled or not ?
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 4ce52f5f2419..8f7841c0374d 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -185,15 +185,12 @@ sl_alloc_bufs(struct slip *sl, int mtu)
185 /* Cleanup */ 185 /* Cleanup */
186err_exit: 186err_exit:
187#ifdef SL_INCLUDE_CSLIP 187#ifdef SL_INCLUDE_CSLIP
188 if (cbuff) 188 kfree(cbuff);
189 kfree(cbuff);
190 if (slcomp) 189 if (slcomp)
191 slhc_free(slcomp); 190 slhc_free(slcomp);
192#endif 191#endif
193 if (xbuff) 192 kfree(xbuff);
194 kfree(xbuff); 193 kfree(rbuff);
195 if (rbuff)
196 kfree(rbuff);
197 return err; 194 return err;
198} 195}
199 196
@@ -204,13 +201,13 @@ sl_free_bufs(struct slip *sl)
204 void * tmp; 201 void * tmp;
205 202
206 /* Free all SLIP frame buffers. */ 203 /* Free all SLIP frame buffers. */
207 if ((tmp = xchg(&sl->rbuff, NULL)) != NULL) 204 tmp = xchg(&sl->rbuff, NULL);
208 kfree(tmp); 205 kfree(tmp);
209 if ((tmp = xchg(&sl->xbuff, NULL)) != NULL) 206 tmp = xchg(&sl->xbuff, NULL);
210 kfree(tmp); 207 kfree(tmp);
211#ifdef SL_INCLUDE_CSLIP 208#ifdef SL_INCLUDE_CSLIP
212 if ((tmp = xchg(&sl->cbuff, NULL)) != NULL) 209 tmp = xchg(&sl->cbuff, NULL);
213 kfree(tmp); 210 kfree(tmp);
214 if ((tmp = xchg(&sl->slcomp, NULL)) != NULL) 211 if ((tmp = xchg(&sl->slcomp, NULL)) != NULL)
215 slhc_free(tmp); 212 slhc_free(tmp);
216#endif 213#endif
@@ -297,13 +294,10 @@ done_on_bh:
297 spin_unlock_bh(&sl->lock); 294 spin_unlock_bh(&sl->lock);
298 295
299done: 296done:
300 if (xbuff) 297 kfree(xbuff);
301 kfree(xbuff); 298 kfree(rbuff);
302 if (rbuff)
303 kfree(rbuff);
304#ifdef SL_INCLUDE_CSLIP 299#ifdef SL_INCLUDE_CSLIP
305 if (cbuff) 300 kfree(cbuff);
306 kfree(cbuff);
307#endif 301#endif
308 return err; 302 return err;
309} 303}
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index 025dcd867eaa..f88f5e32b714 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -37,8 +37,18 @@
37 37
38#include "sunbmac.h" 38#include "sunbmac.h"
39 39
40#define DRV_NAME "sunbmac"
41#define DRV_VERSION "2.0"
42#define DRV_RELDATE "11/24/03"
43#define DRV_AUTHOR "David S. Miller (davem@redhat.com)"
44
40static char version[] __initdata = 45static char version[] __initdata =
41 "sunbmac.c:v2.0 24/Nov/03 David S. Miller (davem@redhat.com)\n"; 46 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
47
48MODULE_VERSION(DRV_VERSION);
49MODULE_AUTHOR(DRV_AUTHOR);
50MODULE_DESCRIPTION("Sun BigMAC 100baseT ethernet driver");
51MODULE_LICENSE("GPL");
42 52
43#undef DEBUG_PROBE 53#undef DEBUG_PROBE
44#undef DEBUG_TX 54#undef DEBUG_TX
@@ -1321,4 +1331,3 @@ static void __exit bigmac_cleanup(void)
1321 1331
1322module_init(bigmac_probe); 1332module_init(bigmac_probe);
1323module_exit(bigmac_cleanup); 1333module_exit(bigmac_cleanup);
1324MODULE_LICENSE("GPL");
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index d837b3c35723..f02fe4119b2c 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -13,9 +13,6 @@
13 * argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50 13 * argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50
14 */ 14 */
15 15
16static char version[] =
17 "sunhme.c:v2.02 24/Aug/2003 David S. Miller (davem@redhat.com)\n";
18
19#include <linux/config.h> 16#include <linux/config.h>
20#include <linux/module.h> 17#include <linux/module.h>
21#include <linux/kernel.h> 18#include <linux/kernel.h>
@@ -67,15 +64,24 @@ static char version[] =
67 64
68#include "sunhme.h" 65#include "sunhme.h"
69 66
67#define DRV_NAME "sunhme"
68#define DRV_VERSION "2.02"
69#define DRV_RELDATE "8/24/03"
70#define DRV_AUTHOR "David S. Miller (davem@redhat.com)"
71
72static char version[] =
73 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
70 74
71#define DRV_NAME "sunhme" 75MODULE_VERSION(DRV_VERSION);
76MODULE_AUTHOR(DRV_AUTHOR);
77MODULE_DESCRIPTION("Sun HappyMealEthernet(HME) 10/100baseT ethernet driver");
78MODULE_LICENSE("GPL");
72 79
73static int macaddr[6]; 80static int macaddr[6];
74 81
75/* accept MAC address of the form macaddr=0x08,0x00,0x20,0x30,0x40,0x50 */ 82/* accept MAC address of the form macaddr=0x08,0x00,0x20,0x30,0x40,0x50 */
76module_param_array(macaddr, int, NULL, 0); 83module_param_array(macaddr, int, NULL, 0);
77MODULE_PARM_DESC(macaddr, "Happy Meal MAC address to set"); 84MODULE_PARM_DESC(macaddr, "Happy Meal MAC address to set");
78MODULE_LICENSE("GPL");
79 85
80static struct happy_meal *root_happy_dev; 86static struct happy_meal *root_happy_dev;
81 87
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c
index 62d464c7ef51..b7d87d4690b4 100644
--- a/drivers/net/sunlance.c
+++ b/drivers/net/sunlance.c
@@ -69,9 +69,6 @@
69 69
70#undef DEBUG_DRIVER 70#undef DEBUG_DRIVER
71 71
72static char version[] =
73 "sunlance.c:v2.02 24/Aug/03 Miguel de Icaza (miguel@nuclecu.unam.mx)\n";
74
75static char lancestr[] = "LANCE"; 72static char lancestr[] = "LANCE";
76 73
77#include <linux/config.h> 74#include <linux/config.h>
@@ -108,6 +105,19 @@ static char lancestr[] = "LANCE";
108#include <asm/auxio.h> /* For tpe-link-test? setting */ 105#include <asm/auxio.h> /* For tpe-link-test? setting */
109#include <asm/irq.h> 106#include <asm/irq.h>
110 107
108#define DRV_NAME "sunlance"
109#define DRV_VERSION "2.02"
110#define DRV_RELDATE "8/24/03"
111#define DRV_AUTHOR "Miguel de Icaza (miguel@nuclecu.unam.mx)"
112
113static char version[] =
114 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
115
116MODULE_VERSION(DRV_VERSION);
117MODULE_AUTHOR(DRV_AUTHOR);
118MODULE_DESCRIPTION("Sun Lance ethernet driver");
119MODULE_LICENSE("GPL");
120
111/* Define: 2^4 Tx buffers and 2^4 Rx buffers */ 121/* Define: 2^4 Tx buffers and 2^4 Rx buffers */
112#ifndef LANCE_LOG_TX_BUFFERS 122#ifndef LANCE_LOG_TX_BUFFERS
113#define LANCE_LOG_TX_BUFFERS 4 123#define LANCE_LOG_TX_BUFFERS 4
@@ -1611,4 +1621,3 @@ static void __exit sparc_lance_cleanup(void)
1611 1621
1612module_init(sparc_lance_probe); 1622module_init(sparc_lance_probe);
1613module_exit(sparc_lance_cleanup); 1623module_exit(sparc_lance_cleanup);
1614MODULE_LICENSE("GPL");
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c
index 37ef1b82a6cb..1f2323be60d4 100644
--- a/drivers/net/sunqe.c
+++ b/drivers/net/sunqe.c
@@ -7,9 +7,6 @@
7 * Copyright (C) 1996, 1999, 2003 David S. Miller (davem@redhat.com) 7 * Copyright (C) 1996, 1999, 2003 David S. Miller (davem@redhat.com)
8 */ 8 */
9 9
10static char version[] =
11 "sunqe.c:v3.0 8/24/03 David S. Miller (davem@redhat.com)\n";
12
13#include <linux/module.h> 10#include <linux/module.h>
14#include <linux/kernel.h> 11#include <linux/kernel.h>
15#include <linux/types.h> 12#include <linux/types.h>
@@ -43,6 +40,19 @@ static char version[] =
43 40
44#include "sunqe.h" 41#include "sunqe.h"
45 42
43#define DRV_NAME "sunqe"
44#define DRV_VERSION "3.0"
45#define DRV_RELDATE "8/24/03"
46#define DRV_AUTHOR "David S. Miller (davem@redhat.com)"
47
48static char version[] =
49 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
50
51MODULE_VERSION(DRV_VERSION);
52MODULE_AUTHOR(DRV_AUTHOR);
53MODULE_DESCRIPTION("Sun QuadEthernet 10baseT SBUS card driver");
54MODULE_LICENSE("GPL");
55
46static struct sunqec *root_qec_dev; 56static struct sunqec *root_qec_dev;
47 57
48static void qe_set_multicast(struct net_device *dev); 58static void qe_set_multicast(struct net_device *dev);
@@ -1040,4 +1050,3 @@ static void __exit qec_cleanup(void)
1040 1050
1041module_init(qec_probe); 1051module_init(qec_probe);
1042module_exit(qec_cleanup); 1052module_exit(qec_cleanup);
1043MODULE_LICENSE("GPL");
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 12de80884b1a..f79b02e80e75 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -61,8 +61,8 @@
61 61
62#define DRV_MODULE_NAME "tg3" 62#define DRV_MODULE_NAME "tg3"
63#define PFX DRV_MODULE_NAME ": " 63#define PFX DRV_MODULE_NAME ": "
64#define DRV_MODULE_VERSION "3.25" 64#define DRV_MODULE_VERSION "3.27"
65#define DRV_MODULE_RELDATE "March 24, 2005" 65#define DRV_MODULE_RELDATE "May 5, 2005"
66 66
67#define TG3_DEF_MAC_MODE 0 67#define TG3_DEF_MAC_MODE 0
68#define TG3_DEF_RX_MODE 0 68#define TG3_DEF_RX_MODE 0
@@ -85,8 +85,7 @@
85/* hardware minimum and maximum for a single frame's data payload */ 85/* hardware minimum and maximum for a single frame's data payload */
86#define TG3_MIN_MTU 60 86#define TG3_MIN_MTU 60
87#define TG3_MAX_MTU(tp) \ 87#define TG3_MAX_MTU(tp) \
88 ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && \ 88 (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS) ? 9000 : 1500)
89 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) ? 9000 : 1500)
90 89
91/* These numbers seem to be hard coded in the NIC firmware somehow. 90/* These numbers seem to be hard coded in the NIC firmware somehow.
92 * You can't change the ring sizes, but you can change where you place 91 * You can't change the ring sizes, but you can change where you place
@@ -205,6 +204,8 @@ static struct pci_device_id tg3_pci_tbl[] = {
205 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 204 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
206 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5751F, 205 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5751F,
207 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 206 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
207 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5752,
208 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
208 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753, 209 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753,
209 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 210 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
210 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753M, 211 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5753M,
@@ -425,9 +426,30 @@ static void tg3_enable_ints(struct tg3 *tp)
425 tg3_cond_int(tp); 426 tg3_cond_int(tp);
426} 427}
427 428
429static inline unsigned int tg3_has_work(struct tg3 *tp)
430{
431 struct tg3_hw_status *sblk = tp->hw_status;
432 unsigned int work_exists = 0;
433
434 /* check for phy events */
435 if (!(tp->tg3_flags &
436 (TG3_FLAG_USE_LINKCHG_REG |
437 TG3_FLAG_POLL_SERDES))) {
438 if (sblk->status & SD_STATUS_LINK_CHG)
439 work_exists = 1;
440 }
441 /* check for RX/TX work to do */
442 if (sblk->idx[0].tx_consumer != tp->tx_cons ||
443 sblk->idx[0].rx_producer != tp->rx_rcb_ptr)
444 work_exists = 1;
445
446 return work_exists;
447}
448
428/* tg3_restart_ints 449/* tg3_restart_ints
429 * similar to tg3_enable_ints, but it can return without flushing the 450 * similar to tg3_enable_ints, but it accurately determines whether there
430 * PIO write which reenables interrupts 451 * is new work pending and can return without flushing the PIO write
452 * which reenables interrupts
431 */ 453 */
432static void tg3_restart_ints(struct tg3 *tp) 454static void tg3_restart_ints(struct tg3 *tp)
433{ 455{
@@ -436,7 +458,9 @@ static void tg3_restart_ints(struct tg3 *tp)
436 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000); 458 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000000);
437 mmiowb(); 459 mmiowb();
438 460
439 tg3_cond_int(tp); 461 if (tg3_has_work(tp))
462 tw32(HOSTCC_MODE, tp->coalesce_mode |
463 (HOSTCC_MODE_ENABLE | HOSTCC_MODE_NOW));
440} 464}
441 465
442static inline void tg3_netif_stop(struct tg3 *tp) 466static inline void tg3_netif_stop(struct tg3 *tp)
@@ -860,8 +884,7 @@ out:
860 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) { 884 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) {
861 /* Cannot do read-modify-write on 5401 */ 885 /* Cannot do read-modify-write on 5401 */
862 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20); 886 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x4c20);
863 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && 887 } else if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
864 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
865 u32 phy_reg; 888 u32 phy_reg;
866 889
867 /* Set bit 14 with read-modify-write to preserve other bits */ 890 /* Set bit 14 with read-modify-write to preserve other bits */
@@ -873,8 +896,7 @@ out:
873 /* Set phy register 0x10 bit 0 to high fifo elasticity to support 896 /* Set phy register 0x10 bit 0 to high fifo elasticity to support
874 * jumbo frames transmission. 897 * jumbo frames transmission.
875 */ 898 */
876 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && 899 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
877 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) {
878 u32 phy_reg; 900 u32 phy_reg;
879 901
880 if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg)) 902 if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &phy_reg))
@@ -1006,8 +1028,13 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1006 pci_write_config_word(tp->pdev, 1028 pci_write_config_word(tp->pdev,
1007 pm + PCI_PM_CTRL, 1029 pm + PCI_PM_CTRL,
1008 power_control); 1030 power_control);
1009 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 1031 udelay(100); /* Delay after power state change */
1010 udelay(100); 1032
1033 /* Switch out of Vaux if it is not a LOM */
1034 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)) {
1035 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
1036 udelay(100);
1037 }
1011 1038
1012 return 0; 1039 return 0;
1013 1040
@@ -1068,7 +1095,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1068 mac_mode = MAC_MODE_PORT_MODE_TBI; 1095 mac_mode = MAC_MODE_PORT_MODE_TBI;
1069 } 1096 }
1070 1097
1071 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750) 1098 if (!(tp->tg3_flags2 & TG3_FLG2_5750_PLUS))
1072 tw32(MAC_LED_CTRL, tp->led_ctrl); 1099 tw32(MAC_LED_CTRL, tp->led_ctrl);
1073 1100
1074 if (((power_caps & PCI_PM_CAP_PME_D3cold) && 1101 if (((power_caps & PCI_PM_CAP_PME_D3cold) &&
@@ -1095,7 +1122,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1095 CLOCK_CTRL_ALTCLK | 1122 CLOCK_CTRL_ALTCLK |
1096 CLOCK_CTRL_PWRDOWN_PLL133); 1123 CLOCK_CTRL_PWRDOWN_PLL133);
1097 udelay(40); 1124 udelay(40);
1098 } else if (!((GET_ASIC_REV(tp->pci_chip_rev_id) == 5750) && 1125 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
1099 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF))) { 1126 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF))) {
1100 u32 newbits1, newbits2; 1127 u32 newbits1, newbits2;
1101 1128
@@ -1152,6 +1179,7 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1152 1179
1153 /* Finally, set the new power state. */ 1180 /* Finally, set the new power state. */
1154 pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control); 1181 pci_write_config_word(tp->pdev, pm + PCI_PM_CTRL, power_control);
1182 udelay(100); /* Delay after power state change */
1155 1183
1156 tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN); 1184 tg3_write_sig_post_reset(tp, RESET_KIND_SHUTDOWN);
1157 1185
@@ -2681,8 +2709,8 @@ static int tg3_vlan_rx(struct tg3 *tp, struct sk_buff *skb, u16 vlan_tag)
2681static int tg3_rx(struct tg3 *tp, int budget) 2709static int tg3_rx(struct tg3 *tp, int budget)
2682{ 2710{
2683 u32 work_mask; 2711 u32 work_mask;
2684 u32 rx_rcb_ptr = tp->rx_rcb_ptr; 2712 u32 sw_idx = tp->rx_rcb_ptr;
2685 u16 hw_idx, sw_idx; 2713 u16 hw_idx;
2686 int received; 2714 int received;
2687 2715
2688 hw_idx = tp->hw_status->idx[0].rx_producer; 2716 hw_idx = tp->hw_status->idx[0].rx_producer;
@@ -2691,7 +2719,6 @@ static int tg3_rx(struct tg3 *tp, int budget)
2691 * the opaque cookie. 2719 * the opaque cookie.
2692 */ 2720 */
2693 rmb(); 2721 rmb();
2694 sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp);
2695 work_mask = 0; 2722 work_mask = 0;
2696 received = 0; 2723 received = 0;
2697 while (sw_idx != hw_idx && budget > 0) { 2724 while (sw_idx != hw_idx && budget > 0) {
@@ -2796,14 +2823,19 @@ static int tg3_rx(struct tg3 *tp, int budget)
2796next_pkt: 2823next_pkt:
2797 (*post_ptr)++; 2824 (*post_ptr)++;
2798next_pkt_nopost: 2825next_pkt_nopost:
2799 rx_rcb_ptr++; 2826 sw_idx++;
2800 sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp); 2827 sw_idx %= TG3_RX_RCB_RING_SIZE(tp);
2828
2829 /* Refresh hw_idx to see if there is new work */
2830 if (sw_idx == hw_idx) {
2831 hw_idx = tp->hw_status->idx[0].rx_producer;
2832 rmb();
2833 }
2801 } 2834 }
2802 2835
2803 /* ACK the status ring. */ 2836 /* ACK the status ring. */
2804 tp->rx_rcb_ptr = rx_rcb_ptr; 2837 tp->rx_rcb_ptr = sw_idx;
2805 tw32_rx_mbox(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW, 2838 tw32_rx_mbox(MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW, sw_idx);
2806 (rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp)));
2807 2839
2808 /* Refill RX ring(s). */ 2840 /* Refill RX ring(s). */
2809 if (work_mask & RXD_OPAQUE_RING_STD) { 2841 if (work_mask & RXD_OPAQUE_RING_STD) {
@@ -2882,24 +2914,41 @@ static int tg3_poll(struct net_device *netdev, int *budget)
2882 return (done ? 0 : 1); 2914 return (done ? 0 : 1);
2883} 2915}
2884 2916
2885static inline unsigned int tg3_has_work(struct net_device *dev, struct tg3 *tp) 2917/* MSI ISR - No need to check for interrupt sharing and no need to
2918 * flush status block and interrupt mailbox. PCI ordering rules
2919 * guarantee that MSI will arrive after the status block.
2920 */
2921static irqreturn_t tg3_msi(int irq, void *dev_id, struct pt_regs *regs)
2886{ 2922{
2923 struct net_device *dev = dev_id;
2924 struct tg3 *tp = netdev_priv(dev);
2887 struct tg3_hw_status *sblk = tp->hw_status; 2925 struct tg3_hw_status *sblk = tp->hw_status;
2888 unsigned int work_exists = 0; 2926 unsigned long flags;
2889 2927
2890 /* check for phy events */ 2928 spin_lock_irqsave(&tp->lock, flags);
2891 if (!(tp->tg3_flags & 2929
2892 (TG3_FLAG_USE_LINKCHG_REG | 2930 /*
2893 TG3_FLAG_POLL_SERDES))) { 2931 * writing any value to intr-mbox-0 clears PCI INTA# and
2894 if (sblk->status & SD_STATUS_LINK_CHG) 2932 * chip-internal interrupt pending events.
2895 work_exists = 1; 2933 * writing non-zero to intr-mbox-0 additional tells the
2934 * NIC to stop sending us irqs, engaging "in-intr-handler"
2935 * event coalescing.
2936 */
2937 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW, 0x00000001);
2938 sblk->status &= ~SD_STATUS_UPDATED;
2939
2940 if (likely(tg3_has_work(tp)))
2941 netif_rx_schedule(dev); /* schedule NAPI poll */
2942 else {
2943 /* no work, re-enable interrupts
2944 */
2945 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
2946 0x00000000);
2896 } 2947 }
2897 /* check for RX/TX work to do */
2898 if (sblk->idx[0].tx_consumer != tp->tx_cons ||
2899 sblk->idx[0].rx_producer != tp->rx_rcb_ptr)
2900 work_exists = 1;
2901 2948
2902 return work_exists; 2949 spin_unlock_irqrestore(&tp->lock, flags);
2950
2951 return IRQ_RETVAL(1);
2903} 2952}
2904 2953
2905static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs) 2954static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
@@ -2935,7 +2984,7 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2935 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW); 2984 tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
2936 sblk->status &= ~SD_STATUS_UPDATED; 2985 sblk->status &= ~SD_STATUS_UPDATED;
2937 2986
2938 if (likely(tg3_has_work(dev, tp))) 2987 if (likely(tg3_has_work(tp)))
2939 netif_rx_schedule(dev); /* schedule NAPI poll */ 2988 netif_rx_schedule(dev); /* schedule NAPI poll */
2940 else { 2989 else {
2941 /* no work, shared interrupt perhaps? re-enable 2990 /* no work, shared interrupt perhaps? re-enable
@@ -2954,13 +3003,31 @@ static irqreturn_t tg3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
2954 return IRQ_RETVAL(handled); 3003 return IRQ_RETVAL(handled);
2955} 3004}
2956 3005
3006/* ISR for interrupt test */
3007static irqreturn_t tg3_test_isr(int irq, void *dev_id,
3008 struct pt_regs *regs)
3009{
3010 struct net_device *dev = dev_id;
3011 struct tg3 *tp = netdev_priv(dev);
3012 struct tg3_hw_status *sblk = tp->hw_status;
3013
3014 if (sblk->status & SD_STATUS_UPDATED) {
3015 tw32_mailbox(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW,
3016 0x00000001);
3017 return IRQ_RETVAL(1);
3018 }
3019 return IRQ_RETVAL(0);
3020}
3021
2957static int tg3_init_hw(struct tg3 *); 3022static int tg3_init_hw(struct tg3 *);
2958static int tg3_halt(struct tg3 *); 3023static int tg3_halt(struct tg3 *, int);
2959 3024
2960#ifdef CONFIG_NET_POLL_CONTROLLER 3025#ifdef CONFIG_NET_POLL_CONTROLLER
2961static void tg3_poll_controller(struct net_device *dev) 3026static void tg3_poll_controller(struct net_device *dev)
2962{ 3027{
2963 tg3_interrupt(dev->irq, dev, NULL); 3028 struct tg3 *tp = netdev_priv(dev);
3029
3030 tg3_interrupt(tp->pdev->irq, dev, NULL);
2964} 3031}
2965#endif 3032#endif
2966 3033
@@ -2977,7 +3044,7 @@ static void tg3_reset_task(void *_data)
2977 restart_timer = tp->tg3_flags2 & TG3_FLG2_RESTART_TIMER; 3044 restart_timer = tp->tg3_flags2 & TG3_FLG2_RESTART_TIMER;
2978 tp->tg3_flags2 &= ~TG3_FLG2_RESTART_TIMER; 3045 tp->tg3_flags2 &= ~TG3_FLG2_RESTART_TIMER;
2979 3046
2980 tg3_halt(tp); 3047 tg3_halt(tp, 0);
2981 tg3_init_hw(tp); 3048 tg3_init_hw(tp);
2982 3049
2983 tg3_netif_start(tp); 3050 tg3_netif_start(tp);
@@ -3323,7 +3390,7 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu)
3323 spin_lock_irq(&tp->lock); 3390 spin_lock_irq(&tp->lock);
3324 spin_lock(&tp->tx_lock); 3391 spin_lock(&tp->tx_lock);
3325 3392
3326 tg3_halt(tp); 3393 tg3_halt(tp, 1);
3327 3394
3328 tg3_set_mtu(dev, tp, new_mtu); 3395 tg3_set_mtu(dev, tp, new_mtu);
3329 3396
@@ -3590,7 +3657,7 @@ err_out:
3590/* To stop a block, clear the enable bit and poll till it 3657/* To stop a block, clear the enable bit and poll till it
3591 * clears. tp->lock is held. 3658 * clears. tp->lock is held.
3592 */ 3659 */
3593static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit) 3660static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit, int silent)
3594{ 3661{
3595 unsigned int i; 3662 unsigned int i;
3596 u32 val; 3663 u32 val;
@@ -3623,7 +3690,7 @@ static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit)
3623 break; 3690 break;
3624 } 3691 }
3625 3692
3626 if (i == MAX_WAIT_CNT) { 3693 if (i == MAX_WAIT_CNT && !silent) {
3627 printk(KERN_ERR PFX "tg3_stop_block timed out, " 3694 printk(KERN_ERR PFX "tg3_stop_block timed out, "
3628 "ofs=%lx enable_bit=%x\n", 3695 "ofs=%lx enable_bit=%x\n",
3629 ofs, enable_bit); 3696 ofs, enable_bit);
@@ -3634,7 +3701,7 @@ static int tg3_stop_block(struct tg3 *tp, unsigned long ofs, u32 enable_bit)
3634} 3701}
3635 3702
3636/* tp->lock is held. */ 3703/* tp->lock is held. */
3637static int tg3_abort_hw(struct tg3 *tp) 3704static int tg3_abort_hw(struct tg3 *tp, int silent)
3638{ 3705{
3639 int i, err; 3706 int i, err;
3640 3707
@@ -3644,22 +3711,20 @@ static int tg3_abort_hw(struct tg3 *tp)
3644 tw32_f(MAC_RX_MODE, tp->rx_mode); 3711 tw32_f(MAC_RX_MODE, tp->rx_mode);
3645 udelay(10); 3712 udelay(10);
3646 3713
3647 err = tg3_stop_block(tp, RCVBDI_MODE, RCVBDI_MODE_ENABLE); 3714 err = tg3_stop_block(tp, RCVBDI_MODE, RCVBDI_MODE_ENABLE, silent);
3648 err |= tg3_stop_block(tp, RCVLPC_MODE, RCVLPC_MODE_ENABLE); 3715 err |= tg3_stop_block(tp, RCVLPC_MODE, RCVLPC_MODE_ENABLE, silent);
3649 err |= tg3_stop_block(tp, RCVLSC_MODE, RCVLSC_MODE_ENABLE); 3716 err |= tg3_stop_block(tp, RCVLSC_MODE, RCVLSC_MODE_ENABLE, silent);
3650 err |= tg3_stop_block(tp, RCVDBDI_MODE, RCVDBDI_MODE_ENABLE); 3717 err |= tg3_stop_block(tp, RCVDBDI_MODE, RCVDBDI_MODE_ENABLE, silent);
3651 err |= tg3_stop_block(tp, RCVDCC_MODE, RCVDCC_MODE_ENABLE); 3718 err |= tg3_stop_block(tp, RCVDCC_MODE, RCVDCC_MODE_ENABLE, silent);
3652 err |= tg3_stop_block(tp, RCVCC_MODE, RCVCC_MODE_ENABLE); 3719 err |= tg3_stop_block(tp, RCVCC_MODE, RCVCC_MODE_ENABLE, silent);
3653 3720
3654 err |= tg3_stop_block(tp, SNDBDS_MODE, SNDBDS_MODE_ENABLE); 3721 err |= tg3_stop_block(tp, SNDBDS_MODE, SNDBDS_MODE_ENABLE, silent);
3655 err |= tg3_stop_block(tp, SNDBDI_MODE, SNDBDI_MODE_ENABLE); 3722 err |= tg3_stop_block(tp, SNDBDI_MODE, SNDBDI_MODE_ENABLE, silent);
3656 err |= tg3_stop_block(tp, SNDDATAI_MODE, SNDDATAI_MODE_ENABLE); 3723 err |= tg3_stop_block(tp, SNDDATAI_MODE, SNDDATAI_MODE_ENABLE, silent);
3657 err |= tg3_stop_block(tp, RDMAC_MODE, RDMAC_MODE_ENABLE); 3724 err |= tg3_stop_block(tp, RDMAC_MODE, RDMAC_MODE_ENABLE, silent);
3658 err |= tg3_stop_block(tp, SNDDATAC_MODE, SNDDATAC_MODE_ENABLE); 3725 err |= tg3_stop_block(tp, SNDDATAC_MODE, SNDDATAC_MODE_ENABLE, silent);
3659 err |= tg3_stop_block(tp, DMAC_MODE, DMAC_MODE_ENABLE); 3726 err |= tg3_stop_block(tp, DMAC_MODE, DMAC_MODE_ENABLE, silent);
3660 err |= tg3_stop_block(tp, SNDBDC_MODE, SNDBDC_MODE_ENABLE); 3727 err |= tg3_stop_block(tp, SNDBDC_MODE, SNDBDC_MODE_ENABLE, silent);
3661 if (err)
3662 goto out;
3663 3728
3664 tp->mac_mode &= ~MAC_MODE_TDE_ENABLE; 3729 tp->mac_mode &= ~MAC_MODE_TDE_ENABLE;
3665 tw32_f(MAC_MODE, tp->mac_mode); 3730 tw32_f(MAC_MODE, tp->mac_mode);
@@ -3677,27 +3742,24 @@ static int tg3_abort_hw(struct tg3 *tp)
3677 printk(KERN_ERR PFX "tg3_abort_hw timed out for %s, " 3742 printk(KERN_ERR PFX "tg3_abort_hw timed out for %s, "
3678 "TX_MODE_ENABLE will not clear MAC_TX_MODE=%08x\n", 3743 "TX_MODE_ENABLE will not clear MAC_TX_MODE=%08x\n",
3679 tp->dev->name, tr32(MAC_TX_MODE)); 3744 tp->dev->name, tr32(MAC_TX_MODE));
3680 return -ENODEV; 3745 err |= -ENODEV;
3681 } 3746 }
3682 3747
3683 err = tg3_stop_block(tp, HOSTCC_MODE, HOSTCC_MODE_ENABLE); 3748 err |= tg3_stop_block(tp, HOSTCC_MODE, HOSTCC_MODE_ENABLE, silent);
3684 err |= tg3_stop_block(tp, WDMAC_MODE, WDMAC_MODE_ENABLE); 3749 err |= tg3_stop_block(tp, WDMAC_MODE, WDMAC_MODE_ENABLE, silent);
3685 err |= tg3_stop_block(tp, MBFREE_MODE, MBFREE_MODE_ENABLE); 3750 err |= tg3_stop_block(tp, MBFREE_MODE, MBFREE_MODE_ENABLE, silent);
3686 3751
3687 tw32(FTQ_RESET, 0xffffffff); 3752 tw32(FTQ_RESET, 0xffffffff);
3688 tw32(FTQ_RESET, 0x00000000); 3753 tw32(FTQ_RESET, 0x00000000);
3689 3754
3690 err |= tg3_stop_block(tp, BUFMGR_MODE, BUFMGR_MODE_ENABLE); 3755 err |= tg3_stop_block(tp, BUFMGR_MODE, BUFMGR_MODE_ENABLE, silent);
3691 err |= tg3_stop_block(tp, MEMARB_MODE, MEMARB_MODE_ENABLE); 3756 err |= tg3_stop_block(tp, MEMARB_MODE, MEMARB_MODE_ENABLE, silent);
3692 if (err)
3693 goto out;
3694 3757
3695 if (tp->hw_status) 3758 if (tp->hw_status)
3696 memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE); 3759 memset(tp->hw_status, 0, TG3_HW_STATUS_SIZE);
3697 if (tp->hw_stats) 3760 if (tp->hw_stats)
3698 memset(tp->hw_stats, 0, sizeof(struct tg3_hw_stats)); 3761 memset(tp->hw_stats, 0, sizeof(struct tg3_hw_stats));
3699 3762
3700out:
3701 return err; 3763 return err;
3702} 3764}
3703 3765
@@ -3727,6 +3789,28 @@ static void tg3_nvram_unlock(struct tg3 *tp)
3727} 3789}
3728 3790
3729/* tp->lock is held. */ 3791/* tp->lock is held. */
3792static void tg3_enable_nvram_access(struct tg3 *tp)
3793{
3794 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
3795 !(tp->tg3_flags2 & TG3_FLG2_PROTECTED_NVRAM)) {
3796 u32 nvaccess = tr32(NVRAM_ACCESS);
3797
3798 tw32(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE);
3799 }
3800}
3801
3802/* tp->lock is held. */
3803static void tg3_disable_nvram_access(struct tg3 *tp)
3804{
3805 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
3806 !(tp->tg3_flags2 & TG3_FLG2_PROTECTED_NVRAM)) {
3807 u32 nvaccess = tr32(NVRAM_ACCESS);
3808
3809 tw32(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE);
3810 }
3811}
3812
3813/* tp->lock is held. */
3730static void tg3_write_sig_pre_reset(struct tg3 *tp, int kind) 3814static void tg3_write_sig_pre_reset(struct tg3 *tp, int kind)
3731{ 3815{
3732 if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X)) 3816 if (!(tp->tg3_flags2 & TG3_FLG2_SUN_570X))
@@ -3967,7 +4051,7 @@ static int tg3_chip_reset(struct tg3 *tp)
3967 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg); 4051 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg);
3968 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) { 4052 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) {
3969 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF; 4053 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
3970 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) 4054 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
3971 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE; 4055 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE;
3972 } 4056 }
3973 } 4057 }
@@ -3997,7 +4081,7 @@ static void tg3_stop_fw(struct tg3 *tp)
3997} 4081}
3998 4082
3999/* tp->lock is held. */ 4083/* tp->lock is held. */
4000static int tg3_halt(struct tg3 *tp) 4084static int tg3_halt(struct tg3 *tp, int silent)
4001{ 4085{
4002 int err; 4086 int err;
4003 4087
@@ -4005,7 +4089,7 @@ static int tg3_halt(struct tg3 *tp)
4005 4089
4006 tg3_write_sig_pre_reset(tp, RESET_KIND_SHUTDOWN); 4090 tg3_write_sig_pre_reset(tp, RESET_KIND_SHUTDOWN);
4007 4091
4008 tg3_abort_hw(tp); 4092 tg3_abort_hw(tp, silent);
4009 err = tg3_chip_reset(tp); 4093 err = tg3_chip_reset(tp);
4010 4094
4011 tg3_write_sig_legacy(tp, RESET_KIND_SHUTDOWN); 4095 tg3_write_sig_legacy(tp, RESET_KIND_SHUTDOWN);
@@ -4974,9 +5058,7 @@ static int tg3_reset_hw(struct tg3 *tp)
4974 tg3_write_sig_pre_reset(tp, RESET_KIND_INIT); 5058 tg3_write_sig_pre_reset(tp, RESET_KIND_INIT);
4975 5059
4976 if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) { 5060 if (tp->tg3_flags & TG3_FLAG_INIT_COMPLETE) {
4977 err = tg3_abort_hw(tp); 5061 tg3_abort_hw(tp, 1);
4978 if (err)
4979 return err;
4980 } 5062 }
4981 5063
4982 err = tg3_chip_reset(tp); 5064 err = tg3_chip_reset(tp);
@@ -5041,7 +5123,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5041 tw32(GRC_MISC_CFG, val); 5123 tw32(GRC_MISC_CFG, val);
5042 5124
5043 /* Initialize MBUF/DESC pool. */ 5125 /* Initialize MBUF/DESC pool. */
5044 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 5126 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) {
5045 /* Do nothing. */ 5127 /* Do nothing. */
5046 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) { 5128 } else if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705) {
5047 tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE); 5129 tw32(BUFMGR_MB_POOL_ADDR, NIC_SRAM_MBUF_POOL_BASE);
@@ -5238,6 +5320,8 @@ static int tg3_reset_hw(struct tg3 *tp)
5238 RDMAC_MODE_LNGREAD_ENAB); 5320 RDMAC_MODE_LNGREAD_ENAB);
5239 if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE) 5321 if (tp->tg3_flags & TG3_FLAG_SPLIT_MODE)
5240 rdmac_mode |= RDMAC_MODE_SPLIT_ENABLE; 5322 rdmac_mode |= RDMAC_MODE_SPLIT_ENABLE;
5323
5324 /* If statement applies to 5705 and 5750 PCI devices only */
5241 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 && 5325 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
5242 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) || 5326 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) ||
5243 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) { 5327 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) {
@@ -5251,6 +5335,9 @@ static int tg3_reset_hw(struct tg3 *tp)
5251 } 5335 }
5252 } 5336 }
5253 5337
5338 if (tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS)
5339 rdmac_mode |= RDMAC_MODE_FIFO_LONG_BURST;
5340
5254#if TG3_TSO_SUPPORT != 0 5341#if TG3_TSO_SUPPORT != 0
5255 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) 5342 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO)
5256 rdmac_mode |= (1 << 27); 5343 rdmac_mode |= (1 << 27);
@@ -5332,10 +5419,28 @@ static int tg3_reset_hw(struct tg3 *tp)
5332 tw32_f(MAC_MODE, tp->mac_mode | MAC_MODE_RXSTAT_CLEAR | MAC_MODE_TXSTAT_CLEAR); 5419 tw32_f(MAC_MODE, tp->mac_mode | MAC_MODE_RXSTAT_CLEAR | MAC_MODE_TXSTAT_CLEAR);
5333 udelay(40); 5420 udelay(40);
5334 5421
5335 tp->grc_local_ctrl = GRC_LCLCTRL_INT_ON_ATTN | GRC_LCLCTRL_AUTO_SEEPROM; 5422 /* tp->grc_local_ctrl is partially set up during tg3_get_invariants().
5336 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) 5423 * If TG3_FLAG_EEPROM_WRITE_PROT is set, we should read the
5424 * register to preserve the GPIO settings for LOMs. The GPIOs,
5425 * whether used as inputs or outputs, are set by boot code after
5426 * reset.
5427 */
5428 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
5429 u32 gpio_mask;
5430
5431 gpio_mask = GRC_LCLCTRL_GPIO_OE0 | GRC_LCLCTRL_GPIO_OE2 |
5432 GRC_LCLCTRL_GPIO_OUTPUT0 | GRC_LCLCTRL_GPIO_OUTPUT2;
5433
5434 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
5435 gpio_mask |= GRC_LCLCTRL_GPIO_OE3 |
5436 GRC_LCLCTRL_GPIO_OUTPUT3;
5437
5438 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask;
5439
5440 /* GPIO1 must be driven high for eeprom write protect */
5337 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 | 5441 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
5338 GRC_LCLCTRL_GPIO_OUTPUT1); 5442 GRC_LCLCTRL_GPIO_OUTPUT1);
5443 }
5339 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 5444 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
5340 udelay(100); 5445 udelay(100);
5341 5446
@@ -5353,6 +5458,7 @@ static int tg3_reset_hw(struct tg3 *tp)
5353 WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB | 5458 WDMAC_MODE_FIFOURUN_ENAB | WDMAC_MODE_FIFOOREAD_ENAB |
5354 WDMAC_MODE_LNGREAD_ENAB); 5459 WDMAC_MODE_LNGREAD_ENAB);
5355 5460
5461 /* If statement applies to 5705 and 5750 PCI devices only */
5356 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 && 5462 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 &&
5357 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) || 5463 tp->pci_chip_rev_id != CHIPREV_ID_5705_A0) ||
5358 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 5464 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) {
@@ -5706,6 +5812,118 @@ static void tg3_timer(unsigned long __opaque)
5706 add_timer(&tp->timer); 5812 add_timer(&tp->timer);
5707} 5813}
5708 5814
5815static int tg3_test_interrupt(struct tg3 *tp)
5816{
5817 struct net_device *dev = tp->dev;
5818 int err, i;
5819 u32 int_mbox = 0;
5820
5821 tg3_disable_ints(tp);
5822
5823 free_irq(tp->pdev->irq, dev);
5824
5825 err = request_irq(tp->pdev->irq, tg3_test_isr,
5826 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
5827 if (err)
5828 return err;
5829
5830 tg3_enable_ints(tp);
5831
5832 tw32_f(HOSTCC_MODE, tp->coalesce_mode | HOSTCC_MODE_ENABLE |
5833 HOSTCC_MODE_NOW);
5834
5835 for (i = 0; i < 5; i++) {
5836 int_mbox = tr32(MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW);
5837 if (int_mbox != 0)
5838 break;
5839 msleep(10);
5840 }
5841
5842 tg3_disable_ints(tp);
5843
5844 free_irq(tp->pdev->irq, dev);
5845
5846 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI)
5847 err = request_irq(tp->pdev->irq, tg3_msi,
5848 SA_SAMPLE_RANDOM, dev->name, dev);
5849 else
5850 err = request_irq(tp->pdev->irq, tg3_interrupt,
5851 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
5852
5853 if (err)
5854 return err;
5855
5856 if (int_mbox != 0)
5857 return 0;
5858
5859 return -EIO;
5860}
5861
5862/* Returns 0 if MSI test succeeds or MSI test fails and INTx mode is
5863 * successfully restored
5864 */
5865static int tg3_test_msi(struct tg3 *tp)
5866{
5867 struct net_device *dev = tp->dev;
5868 int err;
5869 u16 pci_cmd;
5870
5871 if (!(tp->tg3_flags2 & TG3_FLG2_USING_MSI))
5872 return 0;
5873
5874 /* Turn off SERR reporting in case MSI terminates with Master
5875 * Abort.
5876 */
5877 pci_read_config_word(tp->pdev, PCI_COMMAND, &pci_cmd);
5878 pci_write_config_word(tp->pdev, PCI_COMMAND,
5879 pci_cmd & ~PCI_COMMAND_SERR);
5880
5881 err = tg3_test_interrupt(tp);
5882
5883 pci_write_config_word(tp->pdev, PCI_COMMAND, pci_cmd);
5884
5885 if (!err)
5886 return 0;
5887
5888 /* other failures */
5889 if (err != -EIO)
5890 return err;
5891
5892 /* MSI test failed, go back to INTx mode */
5893 printk(KERN_WARNING PFX "%s: No interrupt was generated using MSI, "
5894 "switching to INTx mode. Please report this failure to "
5895 "the PCI maintainer and include system chipset information.\n",
5896 tp->dev->name);
5897
5898 free_irq(tp->pdev->irq, dev);
5899 pci_disable_msi(tp->pdev);
5900
5901 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
5902
5903 err = request_irq(tp->pdev->irq, tg3_interrupt,
5904 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
5905
5906 if (err)
5907 return err;
5908
5909 /* Need to reset the chip because the MSI cycle may have terminated
5910 * with Master Abort.
5911 */
5912 spin_lock_irq(&tp->lock);
5913 spin_lock(&tp->tx_lock);
5914
5915 tg3_halt(tp, 1);
5916 err = tg3_init_hw(tp);
5917
5918 spin_unlock(&tp->tx_lock);
5919 spin_unlock_irq(&tp->lock);
5920
5921 if (err)
5922 free_irq(tp->pdev->irq, dev);
5923
5924 return err;
5925}
5926
5709static int tg3_open(struct net_device *dev) 5927static int tg3_open(struct net_device *dev)
5710{ 5928{
5711 struct tg3 *tp = netdev_priv(dev); 5929 struct tg3 *tp = netdev_priv(dev);
@@ -5727,10 +5945,29 @@ static int tg3_open(struct net_device *dev)
5727 if (err) 5945 if (err)
5728 return err; 5946 return err;
5729 5947
5730 err = request_irq(dev->irq, tg3_interrupt, 5948 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
5731 SA_SHIRQ, dev->name, dev); 5949 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_AX) &&
5950 (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5750_BX)) {
5951 if (pci_enable_msi(tp->pdev) == 0) {
5952 u32 msi_mode;
5953
5954 msi_mode = tr32(MSGINT_MODE);
5955 tw32(MSGINT_MODE, msi_mode | MSGINT_MODE_ENABLE);
5956 tp->tg3_flags2 |= TG3_FLG2_USING_MSI;
5957 }
5958 }
5959 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI)
5960 err = request_irq(tp->pdev->irq, tg3_msi,
5961 SA_SAMPLE_RANDOM, dev->name, dev);
5962 else
5963 err = request_irq(tp->pdev->irq, tg3_interrupt,
5964 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev);
5732 5965
5733 if (err) { 5966 if (err) {
5967 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
5968 pci_disable_msi(tp->pdev);
5969 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
5970 }
5734 tg3_free_consistent(tp); 5971 tg3_free_consistent(tp);
5735 return err; 5972 return err;
5736 } 5973 }
@@ -5740,7 +5977,7 @@ static int tg3_open(struct net_device *dev)
5740 5977
5741 err = tg3_init_hw(tp); 5978 err = tg3_init_hw(tp);
5742 if (err) { 5979 if (err) {
5743 tg3_halt(tp); 5980 tg3_halt(tp, 1);
5744 tg3_free_rings(tp); 5981 tg3_free_rings(tp);
5745 } else { 5982 } else {
5746 tp->timer_offset = HZ / 10; 5983 tp->timer_offset = HZ / 10;
@@ -5751,23 +5988,47 @@ static int tg3_open(struct net_device *dev)
5751 tp->timer.expires = jiffies + tp->timer_offset; 5988 tp->timer.expires = jiffies + tp->timer_offset;
5752 tp->timer.data = (unsigned long) tp; 5989 tp->timer.data = (unsigned long) tp;
5753 tp->timer.function = tg3_timer; 5990 tp->timer.function = tg3_timer;
5754 add_timer(&tp->timer);
5755
5756 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
5757 } 5991 }
5758 5992
5759 spin_unlock(&tp->tx_lock); 5993 spin_unlock(&tp->tx_lock);
5760 spin_unlock_irq(&tp->lock); 5994 spin_unlock_irq(&tp->lock);
5761 5995
5762 if (err) { 5996 if (err) {
5763 free_irq(dev->irq, dev); 5997 free_irq(tp->pdev->irq, dev);
5998 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
5999 pci_disable_msi(tp->pdev);
6000 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
6001 }
5764 tg3_free_consistent(tp); 6002 tg3_free_consistent(tp);
5765 return err; 6003 return err;
5766 } 6004 }
5767 6005
6006 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
6007 err = tg3_test_msi(tp);
6008 if (err) {
6009 spin_lock_irq(&tp->lock);
6010 spin_lock(&tp->tx_lock);
6011
6012 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
6013 pci_disable_msi(tp->pdev);
6014 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
6015 }
6016 tg3_halt(tp, 1);
6017 tg3_free_rings(tp);
6018 tg3_free_consistent(tp);
6019
6020 spin_unlock(&tp->tx_lock);
6021 spin_unlock_irq(&tp->lock);
6022
6023 return err;
6024 }
6025 }
6026
5768 spin_lock_irq(&tp->lock); 6027 spin_lock_irq(&tp->lock);
5769 spin_lock(&tp->tx_lock); 6028 spin_lock(&tp->tx_lock);
5770 6029
6030 add_timer(&tp->timer);
6031 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
5771 tg3_enable_ints(tp); 6032 tg3_enable_ints(tp);
5772 6033
5773 spin_unlock(&tp->tx_lock); 6034 spin_unlock(&tp->tx_lock);
@@ -6025,7 +6286,7 @@ static int tg3_close(struct net_device *dev)
6025 6286
6026 tg3_disable_ints(tp); 6287 tg3_disable_ints(tp);
6027 6288
6028 tg3_halt(tp); 6289 tg3_halt(tp, 1);
6029 tg3_free_rings(tp); 6290 tg3_free_rings(tp);
6030 tp->tg3_flags &= 6291 tp->tg3_flags &=
6031 ~(TG3_FLAG_INIT_COMPLETE | 6292 ~(TG3_FLAG_INIT_COMPLETE |
@@ -6035,7 +6296,11 @@ static int tg3_close(struct net_device *dev)
6035 spin_unlock(&tp->tx_lock); 6296 spin_unlock(&tp->tx_lock);
6036 spin_unlock_irq(&tp->lock); 6297 spin_unlock_irq(&tp->lock);
6037 6298
6038 free_irq(dev->irq, dev); 6299 free_irq(tp->pdev->irq, dev);
6300 if (tp->tg3_flags2 & TG3_FLG2_USING_MSI) {
6301 pci_disable_msi(tp->pdev);
6302 tp->tg3_flags2 &= ~TG3_FLG2_USING_MSI;
6303 }
6039 6304
6040 memcpy(&tp->net_stats_prev, tg3_get_stats(tp->dev), 6305 memcpy(&tp->net_stats_prev, tg3_get_stats(tp->dev),
6041 sizeof(tp->net_stats_prev)); 6306 sizeof(tp->net_stats_prev));
@@ -6509,10 +6774,12 @@ static int tg3_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
6509 start = cpu_to_le32(start); 6774 start = cpu_to_le32(start);
6510 len += b_offset; 6775 len += b_offset;
6511 offset &= ~3; 6776 offset &= ~3;
6777 if (len < 4)
6778 len = 4;
6512 } 6779 }
6513 6780
6514 odd_len = 0; 6781 odd_len = 0;
6515 if ((len & 3) && ((len > 4) || (b_offset == 0))) { 6782 if (len & 3) {
6516 /* adjustments to end on required 4 byte boundary */ 6783 /* adjustments to end on required 4 byte boundary */
6517 odd_len = 1; 6784 odd_len = 1;
6518 len = (len + 3) & ~3; 6785 len = (len + 3) & ~3;
@@ -6739,7 +7006,7 @@ static int tg3_set_ringparam(struct net_device *dev, struct ethtool_ringparam *e
6739 tp->tx_pending = ering->tx_pending; 7006 tp->tx_pending = ering->tx_pending;
6740 7007
6741 if (netif_running(dev)) { 7008 if (netif_running(dev)) {
6742 tg3_halt(tp); 7009 tg3_halt(tp, 1);
6743 tg3_init_hw(tp); 7010 tg3_init_hw(tp);
6744 tg3_netif_start(tp); 7011 tg3_netif_start(tp);
6745 } 7012 }
@@ -6782,7 +7049,7 @@ static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam
6782 tp->tg3_flags &= ~TG3_FLAG_TX_PAUSE; 7049 tp->tg3_flags &= ~TG3_FLAG_TX_PAUSE;
6783 7050
6784 if (netif_running(dev)) { 7051 if (netif_running(dev)) {
6785 tg3_halt(tp); 7052 tg3_halt(tp, 1);
6786 tg3_init_hw(tp); 7053 tg3_init_hw(tp);
6787 tg3_netif_start(tp); 7054 tg3_netif_start(tp);
6788 } 7055 }
@@ -7067,6 +7334,67 @@ static void __devinit tg3_get_nvram_info(struct tg3 *tp)
7067 } 7334 }
7068} 7335}
7069 7336
7337static void __devinit tg3_get_5752_nvram_info(struct tg3 *tp)
7338{
7339 u32 nvcfg1;
7340
7341 nvcfg1 = tr32(NVRAM_CFG1);
7342
7343 /* NVRAM protection for TPM */
7344 if (nvcfg1 & (1 << 27))
7345 tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM;
7346
7347 switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) {
7348 case FLASH_5752VENDOR_ATMEL_EEPROM_64KHZ:
7349 case FLASH_5752VENDOR_ATMEL_EEPROM_376KHZ:
7350 tp->nvram_jedecnum = JEDEC_ATMEL;
7351 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
7352 break;
7353 case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED:
7354 tp->nvram_jedecnum = JEDEC_ATMEL;
7355 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
7356 tp->tg3_flags2 |= TG3_FLG2_FLASH;
7357 break;
7358 case FLASH_5752VENDOR_ST_M45PE10:
7359 case FLASH_5752VENDOR_ST_M45PE20:
7360 case FLASH_5752VENDOR_ST_M45PE40:
7361 tp->nvram_jedecnum = JEDEC_ST;
7362 tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
7363 tp->tg3_flags2 |= TG3_FLG2_FLASH;
7364 break;
7365 }
7366
7367 if (tp->tg3_flags2 & TG3_FLG2_FLASH) {
7368 switch (nvcfg1 & NVRAM_CFG1_5752PAGE_SIZE_MASK) {
7369 case FLASH_5752PAGE_SIZE_256:
7370 tp->nvram_pagesize = 256;
7371 break;
7372 case FLASH_5752PAGE_SIZE_512:
7373 tp->nvram_pagesize = 512;
7374 break;
7375 case FLASH_5752PAGE_SIZE_1K:
7376 tp->nvram_pagesize = 1024;
7377 break;
7378 case FLASH_5752PAGE_SIZE_2K:
7379 tp->nvram_pagesize = 2048;
7380 break;
7381 case FLASH_5752PAGE_SIZE_4K:
7382 tp->nvram_pagesize = 4096;
7383 break;
7384 case FLASH_5752PAGE_SIZE_264:
7385 tp->nvram_pagesize = 264;
7386 break;
7387 }
7388 }
7389 else {
7390 /* For eeprom, set pagesize to maximum eeprom size */
7391 tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE;
7392
7393 nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS;
7394 tw32(NVRAM_CFG1, nvcfg1);
7395 }
7396}
7397
7070/* Chips other than 5700/5701 use the NVRAM for fetching info. */ 7398/* Chips other than 5700/5701 use the NVRAM for fetching info. */
7071static void __devinit tg3_nvram_init(struct tg3 *tp) 7399static void __devinit tg3_nvram_init(struct tg3 *tp)
7072{ 7400{
@@ -7093,20 +7421,16 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
7093 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) { 7421 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) {
7094 tp->tg3_flags |= TG3_FLAG_NVRAM; 7422 tp->tg3_flags |= TG3_FLAG_NVRAM;
7095 7423
7096 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7424 tg3_enable_nvram_access(tp);
7097 u32 nvaccess = tr32(NVRAM_ACCESS);
7098 7425
7099 tw32(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE); 7426 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
7100 } 7427 tg3_get_5752_nvram_info(tp);
7428 else
7429 tg3_get_nvram_info(tp);
7101 7430
7102 tg3_get_nvram_info(tp);
7103 tg3_get_nvram_size(tp); 7431 tg3_get_nvram_size(tp);
7104 7432
7105 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7433 tg3_disable_nvram_access(tp);
7106 u32 nvaccess = tr32(NVRAM_ACCESS);
7107
7108 tw32(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE);
7109 }
7110 7434
7111 } else { 7435 } else {
7112 tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED); 7436 tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
@@ -7195,11 +7519,7 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val)
7195 7519
7196 tg3_nvram_lock(tp); 7520 tg3_nvram_lock(tp);
7197 7521
7198 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7522 tg3_enable_nvram_access(tp);
7199 u32 nvaccess = tr32(NVRAM_ACCESS);
7200
7201 tw32_f(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE);
7202 }
7203 7523
7204 tw32(NVRAM_ADDR, offset); 7524 tw32(NVRAM_ADDR, offset);
7205 ret = tg3_nvram_exec_cmd(tp, NVRAM_CMD_RD | NVRAM_CMD_GO | 7525 ret = tg3_nvram_exec_cmd(tp, NVRAM_CMD_RD | NVRAM_CMD_GO |
@@ -7210,11 +7530,7 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val)
7210 7530
7211 tg3_nvram_unlock(tp); 7531 tg3_nvram_unlock(tp);
7212 7532
7213 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7533 tg3_disable_nvram_access(tp);
7214 u32 nvaccess = tr32(NVRAM_ACCESS);
7215
7216 tw32_f(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE);
7217 }
7218 7534
7219 return ret; 7535 return ret;
7220} 7536}
@@ -7277,7 +7593,7 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
7277 7593
7278 while (len) { 7594 while (len) {
7279 int j; 7595 int j;
7280 u32 phy_addr, page_off, size, nvaccess; 7596 u32 phy_addr, page_off, size;
7281 7597
7282 phy_addr = offset & ~pagemask; 7598 phy_addr = offset & ~pagemask;
7283 7599
@@ -7300,8 +7616,7 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
7300 7616
7301 offset = offset + (pagesize - page_off); 7617 offset = offset + (pagesize - page_off);
7302 7618
7303 nvaccess = tr32(NVRAM_ACCESS); 7619 tg3_enable_nvram_access(tp);
7304 tw32_f(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE);
7305 7620
7306 /* 7621 /*
7307 * Before we can erase the flash page, we need 7622 * Before we can erase the flash page, we need
@@ -7425,8 +7740,8 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
7425 } 7740 }
7426 7741
7427 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) { 7742 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
7428 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 7743 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl &
7429 GRC_LCLCTRL_GPIO_OE1); 7744 ~GRC_LCLCTRL_GPIO_OUTPUT1);
7430 udelay(40); 7745 udelay(40);
7431 } 7746 }
7432 7747
@@ -7438,13 +7753,10 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
7438 7753
7439 tg3_nvram_lock(tp); 7754 tg3_nvram_lock(tp);
7440 7755
7441 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7756 tg3_enable_nvram_access(tp);
7442 u32 nvaccess = tr32(NVRAM_ACCESS); 7757 if ((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
7443 7758 !(tp->tg3_flags2 & TG3_FLG2_PROTECTED_NVRAM))
7444 tw32(NVRAM_ACCESS, nvaccess | ACCESS_ENABLE);
7445
7446 tw32(NVRAM_WRITE1, 0x406); 7759 tw32(NVRAM_WRITE1, 0x406);
7447 }
7448 7760
7449 grc_mode = tr32(GRC_MODE); 7761 grc_mode = tr32(GRC_MODE);
7450 tw32(GRC_MODE, grc_mode | GRC_MODE_NVRAM_WR_ENABLE); 7762 tw32(GRC_MODE, grc_mode | GRC_MODE_NVRAM_WR_ENABLE);
@@ -7463,17 +7775,12 @@ static int tg3_nvram_write_block(struct tg3 *tp, u32 offset, u32 len, u8 *buf)
7463 grc_mode = tr32(GRC_MODE); 7775 grc_mode = tr32(GRC_MODE);
7464 tw32(GRC_MODE, grc_mode & ~GRC_MODE_NVRAM_WR_ENABLE); 7776 tw32(GRC_MODE, grc_mode & ~GRC_MODE_NVRAM_WR_ENABLE);
7465 7777
7466 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7778 tg3_disable_nvram_access(tp);
7467 u32 nvaccess = tr32(NVRAM_ACCESS);
7468
7469 tw32(NVRAM_ACCESS, nvaccess & ~ACCESS_ENABLE);
7470 }
7471 tg3_nvram_unlock(tp); 7779 tg3_nvram_unlock(tp);
7472 } 7780 }
7473 7781
7474 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) { 7782 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) {
7475 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 7783 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
7476 GRC_LCLCTRL_GPIO_OE1 | GRC_LCLCTRL_GPIO_OUTPUT1);
7477 udelay(40); 7784 udelay(40);
7478 } 7785 }
7479 7786
@@ -7537,21 +7844,27 @@ static inline struct subsys_tbl_ent *lookup_by_subsys(struct tg3 *tp)
7537 return NULL; 7844 return NULL;
7538} 7845}
7539 7846
7540static int __devinit tg3_phy_probe(struct tg3 *tp) 7847/* Since this function may be called in D3-hot power state during
7848 * tg3_init_one(), only config cycles are allowed.
7849 */
7850static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
7541{ 7851{
7542 u32 eeprom_phy_id, hw_phy_id_1, hw_phy_id_2;
7543 u32 hw_phy_id, hw_phy_id_masked;
7544 u32 val; 7852 u32 val;
7545 int eeprom_signature_found, eeprom_phy_serdes, err; 7853
7854 /* Make sure register accesses (indirect or otherwise)
7855 * will function correctly.
7856 */
7857 pci_write_config_dword(tp->pdev, TG3PCI_MISC_HOST_CTRL,
7858 tp->misc_host_ctrl);
7546 7859
7547 tp->phy_id = PHY_ID_INVALID; 7860 tp->phy_id = PHY_ID_INVALID;
7548 eeprom_phy_id = PHY_ID_INVALID; 7861 tp->led_ctrl = LED_CTRL_MODE_PHY_1;
7549 eeprom_phy_serdes = 0; 7862
7550 eeprom_signature_found = 0;
7551 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val); 7863 tg3_read_mem(tp, NIC_SRAM_DATA_SIG, &val);
7552 if (val == NIC_SRAM_DATA_SIG_MAGIC) { 7864 if (val == NIC_SRAM_DATA_SIG_MAGIC) {
7553 u32 nic_cfg, led_cfg; 7865 u32 nic_cfg, led_cfg;
7554 u32 nic_phy_id, ver, cfg2 = 0; 7866 u32 nic_phy_id, ver, cfg2 = 0, eeprom_phy_id;
7867 int eeprom_phy_serdes = 0;
7555 7868
7556 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg); 7869 tg3_read_mem(tp, NIC_SRAM_DATA_CFG, &nic_cfg);
7557 tp->nic_sram_data_cfg = nic_cfg; 7870 tp->nic_sram_data_cfg = nic_cfg;
@@ -7564,8 +7877,6 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7564 (ver > 0) && (ver < 0x100)) 7877 (ver > 0) && (ver < 0x100))
7565 tg3_read_mem(tp, NIC_SRAM_DATA_CFG_2, &cfg2); 7878 tg3_read_mem(tp, NIC_SRAM_DATA_CFG_2, &cfg2);
7566 7879
7567 eeprom_signature_found = 1;
7568
7569 if ((nic_cfg & NIC_SRAM_DATA_CFG_PHY_TYPE_MASK) == 7880 if ((nic_cfg & NIC_SRAM_DATA_CFG_PHY_TYPE_MASK) ==
7570 NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER) 7881 NIC_SRAM_DATA_CFG_PHY_TYPE_FIBER)
7571 eeprom_phy_serdes = 1; 7882 eeprom_phy_serdes = 1;
@@ -7581,10 +7892,14 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7581 } else 7892 } else
7582 eeprom_phy_id = 0; 7893 eeprom_phy_id = 0;
7583 7894
7584 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) { 7895 tp->phy_id = eeprom_phy_id;
7896 if (eeprom_phy_serdes)
7897 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES;
7898
7899 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
7585 led_cfg = cfg2 & (NIC_SRAM_DATA_CFG_LED_MODE_MASK | 7900 led_cfg = cfg2 & (NIC_SRAM_DATA_CFG_LED_MODE_MASK |
7586 SHASTA_EXT_LED_MODE_MASK); 7901 SHASTA_EXT_LED_MODE_MASK);
7587 } else 7902 else
7588 led_cfg = nic_cfg & NIC_SRAM_DATA_CFG_LED_MODE_MASK; 7903 led_cfg = nic_cfg & NIC_SRAM_DATA_CFG_LED_MODE_MASK;
7589 7904
7590 switch (led_cfg) { 7905 switch (led_cfg) {
@@ -7634,7 +7949,7 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7634 7949
7635 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) { 7950 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) {
7636 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF; 7951 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
7637 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) 7952 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
7638 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE; 7953 tp->tg3_flags2 |= TG3_FLG2_ASF_NEW_HANDSHAKE;
7639 } 7954 }
7640 if (nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL) 7955 if (nic_cfg & NIC_SRAM_DATA_CFG_FIBER_WOL)
@@ -7648,6 +7963,13 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7648 if (cfg2 & (1 << 18)) 7963 if (cfg2 & (1 << 18))
7649 tp->tg3_flags2 |= TG3_FLG2_SERDES_PREEMPHASIS; 7964 tp->tg3_flags2 |= TG3_FLG2_SERDES_PREEMPHASIS;
7650 } 7965 }
7966}
7967
7968static int __devinit tg3_phy_probe(struct tg3 *tp)
7969{
7970 u32 hw_phy_id_1, hw_phy_id_2;
7971 u32 hw_phy_id, hw_phy_id_masked;
7972 int err;
7651 7973
7652 /* Reading the PHY ID register can conflict with ASF 7974 /* Reading the PHY ID register can conflict with ASF
7653 * firwmare access to the PHY hardware. 7975 * firwmare access to the PHY hardware.
@@ -7676,10 +7998,10 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
7676 if (hw_phy_id_masked == PHY_ID_BCM8002) 7998 if (hw_phy_id_masked == PHY_ID_BCM8002)
7677 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES; 7999 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES;
7678 } else { 8000 } else {
7679 if (eeprom_signature_found) { 8001 if (tp->phy_id != PHY_ID_INVALID) {
7680 tp->phy_id = eeprom_phy_id; 8002 /* Do nothing, phy ID already set up in
7681 if (eeprom_phy_serdes) 8003 * tg3_get_eeprom_hw_cfg().
7682 tp->tg3_flags2 |= TG3_FLG2_PHY_SERDES; 8004 */
7683 } else { 8005 } else {
7684 struct subsys_tbl_ent *p; 8006 struct subsys_tbl_ent *p;
7685 8007
@@ -7750,9 +8072,6 @@ skip_phy_reset:
7750 err = tg3_init_5401phy_dsp(tp); 8072 err = tg3_init_5401phy_dsp(tp);
7751 } 8073 }
7752 8074
7753 if (!eeprom_signature_found)
7754 tp->led_ctrl = LED_CTRL_MODE_PHY_1;
7755
7756 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES) 8075 if (tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)
7757 tp->link_config.advertising = 8076 tp->link_config.advertising =
7758 (ADVERTISED_1000baseT_Half | 8077 (ADVERTISED_1000baseT_Half |
@@ -7917,6 +8236,12 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
7917 tp->pci_chip_rev_id = (misc_ctrl_reg >> 8236 tp->pci_chip_rev_id = (misc_ctrl_reg >>
7918 MISC_HOST_CTRL_CHIPREV_SHIFT); 8237 MISC_HOST_CTRL_CHIPREV_SHIFT);
7919 8238
8239 /* Wrong chip ID in 5752 A0. This code can be removed later
8240 * as A0 is not in production.
8241 */
8242 if (tp->pci_chip_rev_id == CHIPREV_ID_5752_A0_HW)
8243 tp->pci_chip_rev_id = CHIPREV_ID_5752_A0;
8244
7920 /* Initialize misc host control in PCI block. */ 8245 /* Initialize misc host control in PCI block. */
7921 tp->misc_host_ctrl |= (misc_ctrl_reg & 8246 tp->misc_host_ctrl |= (misc_ctrl_reg &
7922 MISC_HOST_CTRL_CHIPREV); 8247 MISC_HOST_CTRL_CHIPREV);
@@ -7931,11 +8256,15 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
7931 tp->pci_hdr_type = (cacheline_sz_reg >> 16) & 0xff; 8256 tp->pci_hdr_type = (cacheline_sz_reg >> 16) & 0xff;
7932 tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff; 8257 tp->pci_bist = (cacheline_sz_reg >> 24) & 0xff;
7933 8258
8259 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 ||
8260 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
8261 tp->tg3_flags2 |= TG3_FLG2_5750_PLUS;
8262
7934 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) || 8263 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) ||
7935 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)) 8264 (tp->tg3_flags2 & TG3_FLG2_5750_PLUS))
7936 tp->tg3_flags2 |= TG3_FLG2_5705_PLUS; 8265 tp->tg3_flags2 |= TG3_FLG2_5705_PLUS;
7937 8266
7938 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750) 8267 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS)
7939 tp->tg3_flags2 |= TG3_FLG2_HW_TSO; 8268 tp->tg3_flags2 |= TG3_FLG2_HW_TSO;
7940 8269
7941 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0) 8270 if (pci_find_capability(tp->pdev, PCI_CAP_ID_EXP) != 0)
@@ -8013,6 +8342,31 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
8013 pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, pci_state_reg); 8342 pci_write_config_dword(tp->pdev, TG3PCI_PCISTATE, pci_state_reg);
8014 } 8343 }
8015 8344
8345 /* Get eeprom hw config before calling tg3_set_power_state().
8346 * In particular, the TG3_FLAG_EEPROM_WRITE_PROT flag must be
8347 * determined before calling tg3_set_power_state() so that
8348 * we know whether or not to switch out of Vaux power.
8349 * When the flag is set, it means that GPIO1 is used for eeprom
8350 * write protect and also implies that it is a LOM where GPIOs
8351 * are not used to switch power.
8352 */
8353 tg3_get_eeprom_hw_cfg(tp);
8354
8355 /* Set up tp->grc_local_ctrl before calling tg3_set_power_state().
8356 * GPIO1 driven high will bring 5700's external PHY out of reset.
8357 * It is also used as eeprom write protect on LOMs.
8358 */
8359 tp->grc_local_ctrl = GRC_LCLCTRL_INT_ON_ATTN | GRC_LCLCTRL_AUTO_SEEPROM;
8360 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700) ||
8361 (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT))
8362 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
8363 GRC_LCLCTRL_GPIO_OUTPUT1);
8364 /* Unused GPIO3 must be driven as output on 5752 because there
8365 * are no pull-up resistors on unused GPIO pins.
8366 */
8367 else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
8368 tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3;
8369
8016 /* Force the chip into D0. */ 8370 /* Force the chip into D0. */
8017 err = tg3_set_power_state(tp, 0); 8371 err = tg3_set_power_state(tp, 0);
8018 if (err) { 8372 if (err) {
@@ -8065,8 +8419,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
8065 if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0) 8419 if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0)
8066 tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; 8420 tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG;
8067 8421
8068 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705 || 8422 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS)
8069 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750)
8070 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; 8423 tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG;
8071 8424
8072 /* Only 5701 and later support tagged irq status mode. 8425 /* Only 5701 and later support tagged irq status mode.
@@ -8628,6 +8981,7 @@ static char * __devinit tg3_phy_string(struct tg3 *tp)
8628 case PHY_ID_BCM5704: return "5704"; 8981 case PHY_ID_BCM5704: return "5704";
8629 case PHY_ID_BCM5705: return "5705"; 8982 case PHY_ID_BCM5705: return "5705";
8630 case PHY_ID_BCM5750: return "5750"; 8983 case PHY_ID_BCM5750: return "5750";
8984 case PHY_ID_BCM5752: return "5752";
8631 case PHY_ID_BCM8002: return "8002/serdes"; 8985 case PHY_ID_BCM8002: return "8002/serdes";
8632 case 0: return "serdes"; 8986 case 0: return "serdes";
8633 default: return "unknown"; 8987 default: return "unknown";
@@ -8878,7 +9232,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
8878 (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) { 9232 (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) {
8879 pci_save_state(tp->pdev); 9233 pci_save_state(tp->pdev);
8880 tw32(MEMARB_MODE, MEMARB_MODE_ENABLE); 9234 tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
8881 tg3_halt(tp); 9235 tg3_halt(tp, 1);
8882 } 9236 }
8883 9237
8884 err = tg3_test_dma(tp); 9238 err = tg3_test_dma(tp);
@@ -9001,7 +9355,7 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
9001 9355
9002 spin_lock_irq(&tp->lock); 9356 spin_lock_irq(&tp->lock);
9003 spin_lock(&tp->tx_lock); 9357 spin_lock(&tp->tx_lock);
9004 tg3_halt(tp); 9358 tg3_halt(tp, 1);
9005 spin_unlock(&tp->tx_lock); 9359 spin_unlock(&tp->tx_lock);
9006 spin_unlock_irq(&tp->lock); 9360 spin_unlock_irq(&tp->lock);
9007 9361
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index d48887d90325..8de6f21037ba 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -125,6 +125,9 @@
125#define CHIPREV_ID_5750_A0 0x4000 125#define CHIPREV_ID_5750_A0 0x4000
126#define CHIPREV_ID_5750_A1 0x4001 126#define CHIPREV_ID_5750_A1 0x4001
127#define CHIPREV_ID_5750_A3 0x4003 127#define CHIPREV_ID_5750_A3 0x4003
128#define CHIPREV_ID_5752_A0_HW 0x5000
129#define CHIPREV_ID_5752_A0 0x6000
130#define CHIPREV_ID_5752_A1 0x6001
128#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12) 131#define GET_ASIC_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 12)
129#define ASIC_REV_5700 0x07 132#define ASIC_REV_5700 0x07
130#define ASIC_REV_5701 0x00 133#define ASIC_REV_5701 0x00
@@ -132,6 +135,7 @@
132#define ASIC_REV_5704 0x02 135#define ASIC_REV_5704 0x02
133#define ASIC_REV_5705 0x03 136#define ASIC_REV_5705 0x03
134#define ASIC_REV_5750 0x04 137#define ASIC_REV_5750 0x04
138#define ASIC_REV_5752 0x06
135#define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8) 139#define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8)
136#define CHIPREV_5700_AX 0x70 140#define CHIPREV_5700_AX 0x70
137#define CHIPREV_5700_BX 0x71 141#define CHIPREV_5700_BX 0x71
@@ -1307,6 +1311,9 @@
1307#define GRC_LCLCTRL_CLEARINT 0x00000002 1311#define GRC_LCLCTRL_CLEARINT 0x00000002
1308#define GRC_LCLCTRL_SETINT 0x00000004 1312#define GRC_LCLCTRL_SETINT 0x00000004
1309#define GRC_LCLCTRL_INT_ON_ATTN 0x00000008 1313#define GRC_LCLCTRL_INT_ON_ATTN 0x00000008
1314#define GRC_LCLCTRL_GPIO_INPUT3 0x00000020
1315#define GRC_LCLCTRL_GPIO_OE3 0x00000040
1316#define GRC_LCLCTRL_GPIO_OUTPUT3 0x00000080
1310#define GRC_LCLCTRL_GPIO_INPUT0 0x00000100 1317#define GRC_LCLCTRL_GPIO_INPUT0 0x00000100
1311#define GRC_LCLCTRL_GPIO_INPUT1 0x00000200 1318#define GRC_LCLCTRL_GPIO_INPUT1 0x00000200
1312#define GRC_LCLCTRL_GPIO_INPUT2 0x00000400 1319#define GRC_LCLCTRL_GPIO_INPUT2 0x00000400
@@ -1392,6 +1399,20 @@
1392#define FLASH_VENDOR_SAIFUN 0x01000003 1399#define FLASH_VENDOR_SAIFUN 0x01000003
1393#define FLASH_VENDOR_SST_SMALL 0x00000001 1400#define FLASH_VENDOR_SST_SMALL 0x00000001
1394#define FLASH_VENDOR_SST_LARGE 0x02000001 1401#define FLASH_VENDOR_SST_LARGE 0x02000001
1402#define NVRAM_CFG1_5752VENDOR_MASK 0x03c00003
1403#define FLASH_5752VENDOR_ATMEL_EEPROM_64KHZ 0x00000000
1404#define FLASH_5752VENDOR_ATMEL_EEPROM_376KHZ 0x02000000
1405#define FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED 0x02000003
1406#define FLASH_5752VENDOR_ST_M45PE10 0x02400000
1407#define FLASH_5752VENDOR_ST_M45PE20 0x02400002
1408#define FLASH_5752VENDOR_ST_M45PE40 0x02400001
1409#define NVRAM_CFG1_5752PAGE_SIZE_MASK 0x70000000
1410#define FLASH_5752PAGE_SIZE_256 0x00000000
1411#define FLASH_5752PAGE_SIZE_512 0x10000000
1412#define FLASH_5752PAGE_SIZE_1K 0x20000000
1413#define FLASH_5752PAGE_SIZE_2K 0x30000000
1414#define FLASH_5752PAGE_SIZE_4K 0x40000000
1415#define FLASH_5752PAGE_SIZE_264 0x50000000
1395#define NVRAM_CFG2 0x00007018 1416#define NVRAM_CFG2 0x00007018
1396#define NVRAM_CFG3 0x0000701c 1417#define NVRAM_CFG3 0x0000701c
1397#define NVRAM_SWARB 0x00007020 1418#define NVRAM_SWARB 0x00007020
@@ -2100,6 +2121,9 @@ struct tg3 {
2100#define TG3_FLG2_HW_TSO 0x00010000 2121#define TG3_FLG2_HW_TSO 0x00010000
2101#define TG3_FLG2_SERDES_PREEMPHASIS 0x00020000 2122#define TG3_FLG2_SERDES_PREEMPHASIS 0x00020000
2102#define TG3_FLG2_5705_PLUS 0x00040000 2123#define TG3_FLG2_5705_PLUS 0x00040000
2124#define TG3_FLG2_5750_PLUS 0x00080000
2125#define TG3_FLG2_PROTECTED_NVRAM 0x00100000
2126#define TG3_FLG2_USING_MSI 0x00200000
2103 2127
2104 u32 split_mode_max_reqs; 2128 u32 split_mode_max_reqs;
2105#define SPLIT_MODE_5704_MAX_REQ 3 2129#define SPLIT_MODE_5704_MAX_REQ 3
@@ -2145,6 +2169,7 @@ struct tg3 {
2145#define PHY_ID_BCM5704 0x60008190 2169#define PHY_ID_BCM5704 0x60008190
2146#define PHY_ID_BCM5705 0x600081a0 2170#define PHY_ID_BCM5705 0x600081a0
2147#define PHY_ID_BCM5750 0x60008180 2171#define PHY_ID_BCM5750 0x60008180
2172#define PHY_ID_BCM5752 0x60008100
2148#define PHY_ID_BCM8002 0x60010140 2173#define PHY_ID_BCM8002 0x60010140
2149#define PHY_ID_INVALID 0xffffffff 2174#define PHY_ID_INVALID 0xffffffff
2150#define PHY_ID_REV_MASK 0x0000000f 2175#define PHY_ID_REV_MASK 0x0000000f
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 35791934a602..66b94668ddd8 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -26,7 +26,7 @@ config WAN
26# There is no way to detect a comtrol sv11 - force it modular for now. 26# There is no way to detect a comtrol sv11 - force it modular for now.
27config HOSTESS_SV11 27config HOSTESS_SV11
28 tristate "Comtrol Hostess SV-11 support" 28 tristate "Comtrol Hostess SV-11 support"
29 depends on WAN && ISA && m 29 depends on WAN && ISA && m && ISA_DMA_API
30 help 30 help
31 Driver for Comtrol Hostess SV-11 network card which 31 Driver for Comtrol Hostess SV-11 network card which
32 operates on low speed synchronous serial links at up to 32 operates on low speed synchronous serial links at up to
@@ -38,7 +38,7 @@ config HOSTESS_SV11
38# The COSA/SRP driver has not been tested as non-modular yet. 38# The COSA/SRP driver has not been tested as non-modular yet.
39config COSA 39config COSA
40 tristate "COSA/SRP sync serial boards support" 40 tristate "COSA/SRP sync serial boards support"
41 depends on WAN && ISA && m 41 depends on WAN && ISA && m && ISA_DMA_API
42 ---help--- 42 ---help---
43 Driver for COSA and SRP synchronous serial boards. 43 Driver for COSA and SRP synchronous serial boards.
44 44
@@ -127,7 +127,7 @@ config LANMEDIA
127# There is no way to detect a Sealevel board. Force it modular 127# There is no way to detect a Sealevel board. Force it modular
128config SEALEVEL_4021 128config SEALEVEL_4021
129 tristate "Sealevel Systems 4021 support" 129 tristate "Sealevel Systems 4021 support"
130 depends on WAN && ISA && m 130 depends on WAN && ISA && m && ISA_DMA_API
131 help 131 help
132 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. 132 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter.
133 133
diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c
index 5b48cd8568f5..02d57c0b4243 100644
--- a/drivers/net/wan/cycx_x25.c
+++ b/drivers/net/wan/cycx_x25.c
@@ -436,9 +436,7 @@ static int cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev,
436 } 436 }
437 437
438 if (err) { 438 if (err) {
439 if (chan->local_addr) 439 kfree(chan->local_addr);
440 kfree(chan->local_addr);
441
442 kfree(chan); 440 kfree(chan);
443 return err; 441 return err;
444 } 442 }
@@ -458,9 +456,7 @@ static int cycx_wan_del_if(struct wan_device *wandev, struct net_device *dev)
458 struct cycx_x25_channel *chan = dev->priv; 456 struct cycx_x25_channel *chan = dev->priv;
459 457
460 if (chan->svc) { 458 if (chan->svc) {
461 if (chan->local_addr) 459 kfree(chan->local_addr);
462 kfree(chan->local_addr);
463
464 if (chan->state == WAN_CONNECTED) 460 if (chan->state == WAN_CONNECTED)
465 del_timer(&chan->timer); 461 del_timer(&chan->timer);
466 } 462 }
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index d67be2587d4d..3e7753b10717 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -3427,7 +3427,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3427{ 3427{
3428 static int first_time = 1; 3428 static int first_time = 1;
3429 ucchar cpc_rev_id; 3429 ucchar cpc_rev_id;
3430 int err = 0, eeprom_outdated = 0; 3430 int err, eeprom_outdated = 0;
3431 ucshort device_id; 3431 ucshort device_id;
3432 pc300_t *card; 3432 pc300_t *card;
3433 3433
@@ -3439,15 +3439,21 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3439#endif 3439#endif
3440 } 3440 }
3441 3441
3442 if ((err = pci_enable_device(pdev)) < 0)
3443 return err;
3444
3442 card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL); 3445 card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL);
3443 if (card == NULL) { 3446 if (card == NULL) {
3444 printk("PC300 found at RAM 0x%08lx, " 3447 printk("PC300 found at RAM 0x%08lx, "
3445 "but could not allocate card structure.\n", 3448 "but could not allocate card structure.\n",
3446 pci_resource_start(pdev, 3)); 3449 pci_resource_start(pdev, 3));
3447 return -ENOMEM; 3450 err = -ENOMEM;
3451 goto err_disable_dev;
3448 } 3452 }
3449 memset(card, 0, sizeof(pc300_t)); 3453 memset(card, 0, sizeof(pc300_t));
3450 3454
3455 err = -ENODEV;
3456
3451 /* read PCI configuration area */ 3457 /* read PCI configuration area */
3452 device_id = ent->device; 3458 device_id = ent->device;
3453 card->hw.irq = pdev->irq; 3459 card->hw.irq = pdev->irq;
@@ -3507,7 +3513,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3507 printk("PC300 found at RAM 0x%08x, " 3513 printk("PC300 found at RAM 0x%08x, "
3508 "but could not allocate PLX mem region.\n", 3514 "but could not allocate PLX mem region.\n",
3509 card->hw.ramphys); 3515 card->hw.ramphys);
3510 err = -ENODEV;
3511 goto err_release_io; 3516 goto err_release_io;
3512 } 3517 }
3513 if (!request_mem_region(card->hw.ramphys, card->hw.alloc_ramsize, 3518 if (!request_mem_region(card->hw.ramphys, card->hw.alloc_ramsize,
@@ -3515,7 +3520,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3515 printk("PC300 found at RAM 0x%08x, " 3520 printk("PC300 found at RAM 0x%08x, "
3516 "but could not allocate RAM mem region.\n", 3521 "but could not allocate RAM mem region.\n",
3517 card->hw.ramphys); 3522 card->hw.ramphys);
3518 err = -ENODEV;
3519 goto err_release_plx; 3523 goto err_release_plx;
3520 } 3524 }
3521 if (!request_mem_region(card->hw.scaphys, card->hw.scasize, 3525 if (!request_mem_region(card->hw.scaphys, card->hw.scasize,
@@ -3523,13 +3527,9 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3523 printk("PC300 found at RAM 0x%08x, " 3527 printk("PC300 found at RAM 0x%08x, "
3524 "but could not allocate SCA mem region.\n", 3528 "but could not allocate SCA mem region.\n",
3525 card->hw.ramphys); 3529 card->hw.ramphys);
3526 err = -ENODEV;
3527 goto err_release_ram; 3530 goto err_release_ram;
3528 } 3531 }
3529 3532
3530 if ((err = pci_enable_device(pdev)) != 0)
3531 goto err_release_sca;
3532
3533 card->hw.plxbase = ioremap(card->hw.plxphys, card->hw.plxsize); 3533 card->hw.plxbase = ioremap(card->hw.plxphys, card->hw.plxsize);
3534 card->hw.rambase = ioremap(card->hw.ramphys, card->hw.alloc_ramsize); 3534 card->hw.rambase = ioremap(card->hw.ramphys, card->hw.alloc_ramsize);
3535 card->hw.scabase = ioremap(card->hw.scaphys, card->hw.scasize); 3535 card->hw.scabase = ioremap(card->hw.scaphys, card->hw.scasize);
@@ -3619,7 +3619,6 @@ err_io_unmap:
3619 iounmap(card->hw.falcbase); 3619 iounmap(card->hw.falcbase);
3620 release_mem_region(card->hw.falcphys, card->hw.falcsize); 3620 release_mem_region(card->hw.falcphys, card->hw.falcsize);
3621 } 3621 }
3622err_release_sca:
3623 release_mem_region(card->hw.scaphys, card->hw.scasize); 3622 release_mem_region(card->hw.scaphys, card->hw.scasize);
3624err_release_ram: 3623err_release_ram:
3625 release_mem_region(card->hw.ramphys, card->hw.alloc_ramsize); 3624 release_mem_region(card->hw.ramphys, card->hw.alloc_ramsize);
@@ -3628,7 +3627,9 @@ err_release_plx:
3628err_release_io: 3627err_release_io:
3629 release_region(card->hw.iophys, card->hw.iosize); 3628 release_region(card->hw.iophys, card->hw.iosize);
3630 kfree(card); 3629 kfree(card);
3631 return -ENODEV; 3630err_disable_dev:
3631 pci_disable_device(pdev);
3632 return err;
3632} 3633}
3633 3634
3634static void __devexit cpc_remove_one(struct pci_dev *pdev) 3635static void __devexit cpc_remove_one(struct pci_dev *pdev)
@@ -3662,6 +3663,7 @@ static void __devexit cpc_remove_one(struct pci_dev *pdev)
3662 if (card->hw.irq) 3663 if (card->hw.irq)
3663 free_irq(card->hw.irq, card); 3664 free_irq(card->hw.irq, card);
3664 kfree(card); 3665 kfree(card);
3666 pci_disable_device(pdev);
3665 } 3667 }
3666} 3668}
3667 3669
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 29f84ad08730..8454bf6caaa7 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -400,10 +400,8 @@ static void cpc_tty_close(struct tty_struct *tty, struct file *flip)
400 cpc_tty->buf_rx.last = NULL; 400 cpc_tty->buf_rx.last = NULL;
401 } 401 }
402 402
403 if (cpc_tty->buf_tx) { 403 kfree(cpc_tty->buf_tx);
404 kfree(cpc_tty->buf_tx); 404 cpc_tty->buf_tx = NULL;
405 cpc_tty->buf_tx = NULL;
406 }
407 405
408 CPC_TTY_DBG("%s: TTY closed\n",cpc_tty->name); 406 CPC_TTY_DBG("%s: TTY closed\n",cpc_tty->name);
409 407
@@ -666,7 +664,7 @@ static void cpc_tty_rx_work(void * data)
666 unsigned long port; 664 unsigned long port;
667 int i, j; 665 int i, j;
668 st_cpc_tty_area *cpc_tty; 666 st_cpc_tty_area *cpc_tty;
669 volatile st_cpc_rx_buf * buf; 667 volatile st_cpc_rx_buf *buf;
670 char flags=0,flg_rx=1; 668 char flags=0,flg_rx=1;
671 struct tty_ldisc *ld; 669 struct tty_ldisc *ld;
672 670
@@ -680,9 +678,9 @@ static void cpc_tty_rx_work(void * data)
680 cpc_tty = &cpc_tty_area[port]; 678 cpc_tty = &cpc_tty_area[port];
681 679
682 if ((buf=cpc_tty->buf_rx.first) != 0) { 680 if ((buf=cpc_tty->buf_rx.first) != 0) {
683 if(cpc_tty->tty) { 681 if (cpc_tty->tty) {
684 ld = tty_ldisc_ref(cpc_tty->tty); 682 ld = tty_ldisc_ref(cpc_tty->tty);
685 if(ld) { 683 if (ld) {
686 if (ld->receive_buf) { 684 if (ld->receive_buf) {
687 CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name); 685 CPC_TTY_DBG("%s: call line disc. receive_buf\n",cpc_tty->name);
688 ld->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size); 686 ld->receive_buf(cpc_tty->tty, (char *)(buf->data), &flags, buf->size);
@@ -691,7 +689,7 @@ static void cpc_tty_rx_work(void * data)
691 } 689 }
692 } 690 }
693 cpc_tty->buf_rx.first = cpc_tty->buf_rx.first->next; 691 cpc_tty->buf_rx.first = cpc_tty->buf_rx.first->next;
694 kfree((unsigned char *)buf); 692 kfree(buf);
695 buf = cpc_tty->buf_rx.first; 693 buf = cpc_tty->buf_rx.first;
696 flg_rx = 1; 694 flg_rx = 1;
697 } 695 }
@@ -733,7 +731,7 @@ static void cpc_tty_rx_disc_frame(pc300ch_t *pc300chan)
733 731
734void cpc_tty_receive(pc300dev_t *pc300dev) 732void cpc_tty_receive(pc300dev_t *pc300dev)
735{ 733{
736 st_cpc_tty_area *cpc_tty; 734 st_cpc_tty_area *cpc_tty;
737 pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan; 735 pc300ch_t *pc300chan = (pc300ch_t *)pc300dev->chan;
738 pc300_t *card = (pc300_t *)pc300chan->card; 736 pc300_t *card = (pc300_t *)pc300chan->card;
739 int ch = pc300chan->channel; 737 int ch = pc300chan->channel;
@@ -742,7 +740,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
742 int rx_len, rx_aux; 740 int rx_len, rx_aux;
743 volatile unsigned char status; 741 volatile unsigned char status;
744 unsigned short first_bd = pc300chan->rx_first_bd; 742 unsigned short first_bd = pc300chan->rx_first_bd;
745 st_cpc_rx_buf *new=NULL; 743 st_cpc_rx_buf *new = NULL;
746 unsigned char dsr_rx; 744 unsigned char dsr_rx;
747 745
748 if (pc300dev->cpc_tty == NULL) { 746 if (pc300dev->cpc_tty == NULL) {
@@ -762,7 +760,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
762 if (status & DST_EOM) { 760 if (status & DST_EOM) {
763 break; 761 break;
764 } 762 }
765 ptdescr=(pcsca_bd_t __iomem *)(card->hw.rambase+cpc_readl(&ptdescr->next)); 763 ptdescr = (pcsca_bd_t __iomem *)(card->hw.rambase+cpc_readl(&ptdescr->next));
766 } 764 }
767 765
768 if (!rx_len) { 766 if (!rx_len) {
@@ -771,10 +769,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
771 cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch), 769 cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch),
772 RX_BD_ADDR(ch, pc300chan->rx_last_bd)); 770 RX_BD_ADDR(ch, pc300chan->rx_last_bd));
773 } 771 }
774 if (new) { 772 kfree(new);
775 kfree(new);
776 new = NULL;
777 }
778 return; 773 return;
779 } 774 }
780 775
@@ -787,7 +782,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
787 continue; 782 continue;
788 } 783 }
789 784
790 new = (st_cpc_rx_buf *) kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC); 785 new = (st_cpc_rx_buf *)kmalloc(rx_len + sizeof(st_cpc_rx_buf), GFP_ATOMIC);
791 if (new == 0) { 786 if (new == 0) {
792 cpc_tty_rx_disc_frame(pc300chan); 787 cpc_tty_rx_disc_frame(pc300chan);
793 continue; 788 continue;
diff --git a/drivers/net/wan/sdla_chdlc.c b/drivers/net/wan/sdla_chdlc.c
index afbe0024e3e1..496d29237e92 100644
--- a/drivers/net/wan/sdla_chdlc.c
+++ b/drivers/net/wan/sdla_chdlc.c
@@ -3664,15 +3664,10 @@ static void wanpipe_tty_close(struct tty_struct *tty, struct file * filp)
3664 chdlc_disable_comm_shutdown(card); 3664 chdlc_disable_comm_shutdown(card);
3665 unlock_adapter_irq(&card->wandev.lock,&smp_flags); 3665 unlock_adapter_irq(&card->wandev.lock,&smp_flags);
3666 3666
3667 if (card->tty_buf){ 3667 kfree(card->tty_buf);
3668 kfree(card->tty_buf); 3668 card->tty_buf = NULL;
3669 card->tty_buf=NULL; 3669 kfree(card->tty_rx);
3670 } 3670 card->tty_rx = NULL;
3671
3672 if (card->tty_rx){
3673 kfree(card->tty_rx);
3674 card->tty_rx=NULL;
3675 }
3676 } 3671 }
3677 return; 3672 return;
3678} 3673}
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 8c5cfcb55826..1c540d825551 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -107,13 +107,9 @@ static struct x25_asy *x25_asy_alloc(void)
107static void x25_asy_free(struct x25_asy *sl) 107static void x25_asy_free(struct x25_asy *sl)
108{ 108{
109 /* Free all X.25 frame buffers. */ 109 /* Free all X.25 frame buffers. */
110 if (sl->rbuff) { 110 kfree(sl->rbuff);
111 kfree(sl->rbuff);
112 }
113 sl->rbuff = NULL; 111 sl->rbuff = NULL;
114 if (sl->xbuff) { 112 kfree(sl->xbuff);
115 kfree(sl->xbuff);
116 }
117 sl->xbuff = NULL; 113 sl->xbuff = NULL;
118 114
119 if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) { 115 if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) {
@@ -134,10 +130,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
134 { 130 {
135 printk("%s: unable to grow X.25 buffers, MTU change cancelled.\n", 131 printk("%s: unable to grow X.25 buffers, MTU change cancelled.\n",
136 dev->name); 132 dev->name);
137 if (xbuff != NULL) 133 kfree(xbuff);
138 kfree(xbuff); 134 kfree(rbuff);
139 if (rbuff != NULL)
140 kfree(rbuff);
141 return -ENOMEM; 135 return -ENOMEM;
142 } 136 }
143 137
@@ -169,10 +163,8 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
169 163
170 spin_unlock_bh(&sl->lock); 164 spin_unlock_bh(&sl->lock);
171 165
172 if (xbuff != NULL) 166 kfree(xbuff);
173 kfree(xbuff); 167 kfree(rbuff);
174 if (rbuff != NULL)
175 kfree(rbuff);
176 return 0; 168 return 0;
177} 169}
178 170
diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
index 9abedeaa567c..a72006c08f2b 100644
--- a/drivers/oprofile/oprofile_files.c
+++ b/drivers/oprofile/oprofile_files.c
@@ -18,13 +18,13 @@ unsigned long fs_buffer_size = 131072;
18unsigned long fs_cpu_buffer_size = 8192; 18unsigned long fs_cpu_buffer_size = 8192;
19unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */ 19unsigned long fs_buffer_watershed = 32768; /* FIXME: tune */
20 20
21static ssize_t depth_read(struct file * file, char * buf, size_t count, loff_t * offset) 21static ssize_t depth_read(struct file * file, char __user * buf, size_t count, loff_t * offset)
22{ 22{
23 return oprofilefs_ulong_to_user(backtrace_depth, buf, count, offset); 23 return oprofilefs_ulong_to_user(backtrace_depth, buf, count, offset);
24} 24}
25 25
26 26
27static ssize_t depth_write(struct file * file, char const * buf, size_t count, loff_t * offset) 27static ssize_t depth_write(struct file * file, char const __user * buf, size_t count, loff_t * offset)
28{ 28{
29 unsigned long val; 29 unsigned long val;
30 int retval; 30 int retval;
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig
index 731010e0e6f6..16a2e6ae37f4 100644
--- a/drivers/parport/Kconfig
+++ b/drivers/parport/Kconfig
@@ -34,7 +34,7 @@ config PARPORT
34 34
35config PARPORT_PC 35config PARPORT_PC
36 tristate "PC-style hardware" 36 tristate "PC-style hardware"
37 depends on PARPORT && (!SPARC64 || PCI) && (!SPARC32 || BROKEN) 37 depends on PARPORT && (!SPARC64 || PCI) && !SPARC32
38 ---help--- 38 ---help---
39 You should say Y here if you have a PC-style parallel port. All 39 You should say Y here if you have a PC-style parallel port. All
40 IBM PC compatible computers and some Alphas have PC-style 40 IBM PC compatible computers and some Alphas have PC-style
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index c5774e7855d0..e7f3bcb79000 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -67,6 +67,10 @@
67 67
68#define PARPORT_PC_MAX_PORTS PARPORT_MAX 68#define PARPORT_PC_MAX_PORTS PARPORT_MAX
69 69
70#ifdef CONFIG_ISA_DMA_API
71#define HAS_DMA
72#endif
73
70/* ECR modes */ 74/* ECR modes */
71#define ECR_SPP 00 75#define ECR_SPP 00
72#define ECR_PS2 01 76#define ECR_PS2 01
@@ -610,6 +614,7 @@ dump_parport_state ("leave fifo_write_block_pio", port);
610 return length - left; 614 return length - left;
611} 615}
612 616
617#ifdef HAS_DMA
613static size_t parport_pc_fifo_write_block_dma (struct parport *port, 618static size_t parport_pc_fifo_write_block_dma (struct parport *port,
614 const void *buf, size_t length) 619 const void *buf, size_t length)
615{ 620{
@@ -732,6 +737,17 @@ dump_parport_state ("enter fifo_write_block_dma", port);
732dump_parport_state ("leave fifo_write_block_dma", port); 737dump_parport_state ("leave fifo_write_block_dma", port);
733 return length - left; 738 return length - left;
734} 739}
740#endif
741
742static inline size_t parport_pc_fifo_write_block(struct parport *port,
743 const void *buf, size_t length)
744{
745#ifdef HAS_DMA
746 if (port->dma != PARPORT_DMA_NONE)
747 return parport_pc_fifo_write_block_dma (port, buf, length);
748#endif
749 return parport_pc_fifo_write_block_pio (port, buf, length);
750}
735 751
736/* Parallel Port FIFO mode (ECP chipsets) */ 752/* Parallel Port FIFO mode (ECP chipsets) */
737static size_t parport_pc_compat_write_block_pio (struct parport *port, 753static size_t parport_pc_compat_write_block_pio (struct parport *port,
@@ -758,10 +774,7 @@ static size_t parport_pc_compat_write_block_pio (struct parport *port,
758 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA; 774 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
759 775
760 /* Write the data to the FIFO. */ 776 /* Write the data to the FIFO. */
761 if (port->dma != PARPORT_DMA_NONE) 777 written = parport_pc_fifo_write_block(port, buf, length);
762 written = parport_pc_fifo_write_block_dma (port, buf, length);
763 else
764 written = parport_pc_fifo_write_block_pio (port, buf, length);
765 778
766 /* Finish up. */ 779 /* Finish up. */
767 /* For some hardware we don't want to touch the mode until 780 /* For some hardware we don't want to touch the mode until
@@ -856,10 +869,7 @@ static size_t parport_pc_ecp_write_block_pio (struct parport *port,
856 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA; 869 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
857 870
858 /* Write the data to the FIFO. */ 871 /* Write the data to the FIFO. */
859 if (port->dma != PARPORT_DMA_NONE) 872 written = parport_pc_fifo_write_block(port, buf, length);
860 written = parport_pc_fifo_write_block_dma (port, buf, length);
861 else
862 written = parport_pc_fifo_write_block_pio (port, buf, length);
863 873
864 /* Finish up. */ 874 /* Finish up. */
865 /* For some hardware we don't want to touch the mode until 875 /* For some hardware we don't want to touch the mode until
@@ -2285,6 +2295,7 @@ struct parport *parport_pc_probe_port (unsigned long int base,
2285 } 2295 }
2286 2296
2287#ifdef CONFIG_PARPORT_PC_FIFO 2297#ifdef CONFIG_PARPORT_PC_FIFO
2298#ifdef HAS_DMA
2288 if (p->dma != PARPORT_DMA_NONE) { 2299 if (p->dma != PARPORT_DMA_NONE) {
2289 if (request_dma (p->dma, p->name)) { 2300 if (request_dma (p->dma, p->name)) {
2290 printk (KERN_WARNING "%s: dma %d in use, " 2301 printk (KERN_WARNING "%s: dma %d in use, "
@@ -2306,7 +2317,8 @@ struct parport *parport_pc_probe_port (unsigned long int base,
2306 } 2317 }
2307 } 2318 }
2308 } 2319 }
2309#endif /* CONFIG_PARPORT_PC_FIFO */ 2320#endif
2321#endif
2310 } 2322 }
2311 2323
2312 /* Done probing. Now put the port into a sensible start-up state. */ 2324 /* Done probing. Now put the port into a sensible start-up state. */
@@ -2367,11 +2379,13 @@ void parport_pc_unregister_port (struct parport *p)
2367 if (p->modes & PARPORT_MODE_ECP) 2379 if (p->modes & PARPORT_MODE_ECP)
2368 release_region(p->base_hi, 3); 2380 release_region(p->base_hi, 3);
2369#ifdef CONFIG_PARPORT_PC_FIFO 2381#ifdef CONFIG_PARPORT_PC_FIFO
2382#ifdef HAS_DMA
2370 if (priv->dma_buf) 2383 if (priv->dma_buf)
2371 pci_free_consistent(priv->dev, PAGE_SIZE, 2384 pci_free_consistent(priv->dev, PAGE_SIZE,
2372 priv->dma_buf, 2385 priv->dma_buf,
2373 priv->dma_handle); 2386 priv->dma_handle);
2374#endif /* CONFIG_PARPORT_PC_FIFO */ 2387#endif
2388#endif
2375 kfree (p->private_data); 2389 kfree (p->private_data);
2376 parport_put_port(p); 2390 parport_put_port(p);
2377 kfree (ops); /* hope no-one cached it */ 2391 kfree (ops); /* hope no-one cached it */
diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
index d471b3ea5d12..021d0f76bc4c 100644
--- a/drivers/pci/hotplug.c
+++ b/drivers/pci/hotplug.c
@@ -120,6 +120,10 @@ static int pci_visit_bridge (struct pci_visit * fn,
120 120
121/** 121/**
122 * pci_visit_dev - scans the pci buses. 122 * pci_visit_dev - scans the pci buses.
123 * @fn: callback functions that are called while visiting
124 * @wrapped_dev: the device to scan
125 * @wrapped_parent: the bus where @wrapped_dev is connected to
126 *
123 * Every bus and every function is presented to a custom 127 * Every bus and every function is presented to a custom
124 * function that can act upon it. 128 * function that can act upon it.
125 */ 129 */
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h
index 5bc039da647f..c22e0284d7b1 100644
--- a/drivers/pci/hotplug/ibmphp.h
+++ b/drivers/pci/hotplug/ibmphp.h
@@ -196,7 +196,7 @@ struct ebda_hpc_bus {
196 196
197 197
198/******************************************************************** 198/********************************************************************
199* THREE TYPE OF HOT PLUG CONTROLER * 199* THREE TYPE OF HOT PLUG CONTROLLER *
200********************************************************************/ 200********************************************************************/
201 201
202struct isa_ctlr_access { 202struct isa_ctlr_access {
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index 6894b548c8ca..1a3eb8d3d4cb 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -64,7 +64,7 @@ static int to_debug = FALSE;
64#define WPG_I2C_OR 0x2000 // I2C OR operation 64#define WPG_I2C_OR 0x2000 // I2C OR operation
65 65
66//---------------------------------------------------------------------------- 66//----------------------------------------------------------------------------
67// Command set for I2C Master Operation Setup Regisetr 67// Command set for I2C Master Operation Setup Register
68//---------------------------------------------------------------------------- 68//----------------------------------------------------------------------------
69#define WPG_READATADDR_MASK 0x00010000 // read,bytes,I2C shifted,index 69#define WPG_READATADDR_MASK 0x00010000 // read,bytes,I2C shifted,index
70#define WPG_WRITEATADDR_MASK 0x40010000 // write,bytes,I2C shifted,index 70#define WPG_WRITEATADDR_MASK 0x40010000 // write,bytes,I2C shifted,index
@@ -835,7 +835,7 @@ static void poll_hpc (void)
835 if (ibmphp_shutdown) 835 if (ibmphp_shutdown)
836 break; 836 break;
837 837
838 /* try to get the lock to do some kind of harware access */ 838 /* try to get the lock to do some kind of hardware access */
839 down (&semOperations); 839 down (&semOperations);
840 840
841 switch (poll_state) { 841 switch (poll_state) {
@@ -906,7 +906,7 @@ static void poll_hpc (void)
906 poll_state = POLL_LATCH_REGISTER; 906 poll_state = POLL_LATCH_REGISTER;
907 break; 907 break;
908 } 908 }
909 /* give up the harware semaphore */ 909 /* give up the hardware semaphore */
910 up (&semOperations); 910 up (&semOperations);
911 /* sleep for a short time just for good measure */ 911 /* sleep for a short time just for good measure */
912 msleep(100); 912 msleep(100);
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index 2335fac65fb4..8122fe734aa7 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -1308,10 +1308,10 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function)
1308 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ 1308 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */
1309 } else { 1309 } else {
1310 /* This is Memory */ 1310 /* This is Memory */
1311 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1312 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { 1311 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) {
1313 /* pfmem */ 1312 /* pfmem */
1314 debug ("start address of pfmem is %x\n", start_address); 1313 debug ("start address of pfmem is %x\n", start_address);
1314 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1315 1315
1316 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { 1316 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) {
1317 err ("cannot find corresponding PFMEM resource to remove\n"); 1317 err ("cannot find corresponding PFMEM resource to remove\n");
@@ -1325,6 +1325,8 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function)
1325 } else { 1325 } else {
1326 /* regular memory */ 1326 /* regular memory */
1327 debug ("start address of mem is %x\n", start_address); 1327 debug ("start address of mem is %x\n", start_address);
1328 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1329
1328 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { 1330 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) {
1329 err ("cannot find corresponding MEM resource to remove\n"); 1331 err ("cannot find corresponding MEM resource to remove\n");
1330 return -EIO; 1332 return -EIO;
@@ -1422,9 +1424,9 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1422 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ 1424 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */
1423 } else { 1425 } else {
1424 /* This is Memory */ 1426 /* This is Memory */
1425 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1426 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { 1427 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) {
1427 /* pfmem */ 1428 /* pfmem */
1429 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1428 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { 1430 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) {
1429 err ("cannot find corresponding PFMEM resource to remove\n"); 1431 err ("cannot find corresponding PFMEM resource to remove\n");
1430 return -EINVAL; 1432 return -EINVAL;
@@ -1436,6 +1438,7 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1436 } 1438 }
1437 } else { 1439 } else {
1438 /* regular memory */ 1440 /* regular memory */
1441 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1439 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { 1442 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) {
1440 err ("cannot find corresponding MEM resource to remove\n"); 1443 err ("cannot find corresponding MEM resource to remove\n");
1441 return -EINVAL; 1444 return -EINVAL;
diff --git a/drivers/pci/hotplug/pci_hotplug.h b/drivers/pci/hotplug/pci_hotplug.h
index 57ace325168d..88d44f7fef29 100644
--- a/drivers/pci/hotplug/pci_hotplug.h
+++ b/drivers/pci/hotplug/pci_hotplug.h
@@ -150,7 +150,7 @@ struct hotplug_slot_info {
150 * @name: the name of the slot being registered. This string must 150 * @name: the name of the slot being registered. This string must
151 * be unique amoung slots registered on this system. 151 * be unique amoung slots registered on this system.
152 * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot 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 inital values for 153 * @info: pointer to the &struct hotplug_slot_info for the initial values for
154 * this slot. 154 * this slot.
155 * @release: called during pci_hp_deregister to free memory allocated in a 155 * @release: called during pci_hp_deregister to free memory allocated in a
156 * hotplug_slot structure. 156 * hotplug_slot structure.
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 72baf749e65e..ed1fd8d6178d 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -90,6 +90,22 @@ static struct hotplug_slot_ops pciehp_hotplug_slot_ops = {
90 .get_cur_bus_speed = get_cur_bus_speed, 90 .get_cur_bus_speed = get_cur_bus_speed,
91}; 91};
92 92
93/**
94 * release_slot - free up the memory used by a slot
95 * @hotplug_slot: slot to free
96 */
97static void release_slot(struct hotplug_slot *hotplug_slot)
98{
99 struct slot *slot = hotplug_slot->private;
100
101 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
102
103 kfree(slot->hotplug_slot->info);
104 kfree(slot->hotplug_slot->name);
105 kfree(slot->hotplug_slot);
106 kfree(slot);
107}
108
93static int init_slots(struct controller *ctrl) 109static int init_slots(struct controller *ctrl)
94{ 110{
95 struct slot *new_slot; 111 struct slot *new_slot;
@@ -139,7 +155,8 @@ static int init_slots(struct controller *ctrl)
139 155
140 /* register this slot with the hotplug pci core */ 156 /* register this slot with the hotplug pci core */
141 new_slot->hotplug_slot->private = new_slot; 157 new_slot->hotplug_slot->private = new_slot;
142 make_slot_name (new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); 158 new_slot->hotplug_slot->release = &release_slot;
159 make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot);
143 new_slot->hotplug_slot->ops = &pciehp_hotplug_slot_ops; 160 new_slot->hotplug_slot->ops = &pciehp_hotplug_slot_ops;
144 161
145 new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status)); 162 new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status));
@@ -188,10 +205,6 @@ static int cleanup_slots (struct controller * ctrl)
188 while (old_slot) { 205 while (old_slot) {
189 next_slot = old_slot->next; 206 next_slot = old_slot->next;
190 pci_hp_deregister (old_slot->hotplug_slot); 207 pci_hp_deregister (old_slot->hotplug_slot);
191 kfree(old_slot->hotplug_slot->info);
192 kfree(old_slot->hotplug_slot->name);
193 kfree(old_slot->hotplug_slot);
194 kfree(old_slot);
195 old_slot = next_slot; 208 old_slot = next_slot;
196 } 209 }
197 210
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c
index 6605d6bda529..3194d51c6ec9 100644
--- a/drivers/pci/hotplug/pcihp_skeleton.c
+++ b/drivers/pci/hotplug/pcihp_skeleton.c
@@ -297,7 +297,7 @@ static int __init init_slots(void)
297 hotplug_slot->ops = &skel_hotplug_slot_ops; 297 hotplug_slot->ops = &skel_hotplug_slot_ops;
298 298
299 /* 299 /*
300 * Initilize the slot info structure with some known 300 * Initialize the slot info structure with some known
301 * good values. 301 * good values.
302 */ 302 */
303 info->power_status = get_power_status(slot); 303 info->power_status = get_power_status(slot);
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 22ecd3b058be..30206ac43c44 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -522,7 +522,7 @@ void pci_scan_msi_device(struct pci_dev *dev)
522 * msi_capability_init - configure device's MSI capability structure 522 * msi_capability_init - configure device's MSI capability structure
523 * @dev: pointer to the pci_dev data structure of MSI device function 523 * @dev: pointer to the pci_dev data structure of MSI device function
524 * 524 *
525 * Setup the MSI capability structure of device funtion with a single 525 * Setup the MSI capability structure of device function with a single
526 * MSI vector, regardless of device function is capable of handling 526 * MSI vector, regardless of device function is capable of handling
527 * multiple messages. A return of zero indicates the successful setup 527 * multiple messages. A return of zero indicates the successful setup
528 * of an entry zero with the new MSI vector or non-zero for otherwise. 528 * of an entry zero with the new MSI vector or non-zero for otherwise.
@@ -599,7 +599,7 @@ static int msi_capability_init(struct pci_dev *dev)
599 * msix_capability_init - configure device's MSI-X capability 599 * msix_capability_init - configure device's MSI-X capability
600 * @dev: pointer to the pci_dev data structure of MSI-X device function 600 * @dev: pointer to the pci_dev data structure of MSI-X device function
601 * 601 *
602 * Setup the MSI-X capability structure of device funtion with a 602 * Setup the MSI-X capability structure of device function with a
603 * single MSI-X vector. A return of zero indicates the successful setup of 603 * single MSI-X vector. A return of zero indicates the successful setup of
604 * requested MSI-X entries with allocated vectors or non-zero for otherwise. 604 * requested MSI-X entries with allocated vectors or non-zero for otherwise.
605 **/ 605 **/
@@ -1074,7 +1074,7 @@ void pci_disable_msix(struct pci_dev* dev)
1074 * msi_remove_pci_irq_vectors - reclaim MSI(X) vectors to unused state 1074 * msi_remove_pci_irq_vectors - reclaim MSI(X) vectors to unused state
1075 * @dev: pointer to the pci_dev data structure of MSI(X) device function 1075 * @dev: pointer to the pci_dev data structure of MSI(X) device function
1076 * 1076 *
1077 * Being called during hotplug remove, from which the device funciton 1077 * Being called during hotplug remove, from which the device function
1078 * is hot-removed. All previous assigned MSI/MSI-X vectors, if 1078 * is hot-removed. All previous assigned MSI/MSI-X vectors, if
1079 * allocated for this device function, are reclaimed to unused state, 1079 * allocated for this device function, are reclaimed to unused state,
1080 * which may be used later on. 1080 * which may be used later on.
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 968eb32f292d..bc01d34e2634 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -19,7 +19,7 @@
19 19
20static u32 ctrlset_buf[3] = {0, 0, 0}; 20static u32 ctrlset_buf[3] = {0, 0, 0};
21static u32 global_ctrlsets = 0; 21static u32 global_ctrlsets = 0;
22u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; 22static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
23 23
24static acpi_status 24static acpi_status
25acpi_query_osc ( 25acpi_query_osc (
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 37b7961efc44..fe98553c978f 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -318,6 +318,14 @@ static int pci_device_resume(struct device * dev)
318 return 0; 318 return 0;
319} 319}
320 320
321static void pci_device_shutdown(struct device *dev)
322{
323 struct pci_dev *pci_dev = to_pci_dev(dev);
324 struct pci_driver *drv = pci_dev->driver;
325
326 if (drv && drv->shutdown)
327 drv->shutdown(pci_dev);
328}
321 329
322#define kobj_to_pci_driver(obj) container_of(obj, struct device_driver, kobj) 330#define kobj_to_pci_driver(obj) container_of(obj, struct device_driver, kobj)
323#define attr_to_driver_attribute(obj) container_of(obj, struct driver_attribute, attr) 331#define attr_to_driver_attribute(obj) container_of(obj, struct driver_attribute, attr)
@@ -373,7 +381,7 @@ pci_populate_driver_dir(struct pci_driver *drv)
373 * 381 *
374 * Adds the driver structure to the list of registered drivers. 382 * Adds the driver structure to the list of registered drivers.
375 * Returns a negative value on error, otherwise 0. 383 * Returns a negative value on error, otherwise 0.
376 * If no error occured, the driver remains registered even if 384 * If no error occurred, the driver remains registered even if
377 * no device was claimed during registration. 385 * no device was claimed during registration.
378 */ 386 */
379int pci_register_driver(struct pci_driver *drv) 387int pci_register_driver(struct pci_driver *drv)
@@ -385,6 +393,7 @@ int pci_register_driver(struct pci_driver *drv)
385 drv->driver.bus = &pci_bus_type; 393 drv->driver.bus = &pci_bus_type;
386 drv->driver.probe = pci_device_probe; 394 drv->driver.probe = pci_device_probe;
387 drv->driver.remove = pci_device_remove; 395 drv->driver.remove = pci_device_remove;
396 drv->driver.shutdown = pci_device_shutdown,
388 drv->driver.owner = drv->owner; 397 drv->driver.owner = drv->owner;
389 drv->driver.kobj.ktype = &pci_driver_kobj_type; 398 drv->driver.kobj.ktype = &pci_driver_kobj_type;
390 pci_init_dynids(&drv->dynids); 399 pci_init_dynids(&drv->dynids);
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index d57ae71d32b1..8568b207f189 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -91,6 +91,7 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
91 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); 91 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj));
92 unsigned int size = 64; 92 unsigned int size = 64;
93 loff_t init_off = off; 93 loff_t init_off = off;
94 u8 *data = (u8*) buf;
94 95
95 /* Several chips lock up trying to read undefined config space */ 96 /* Several chips lock up trying to read undefined config space */
96 if (capable(CAP_SYS_ADMIN)) { 97 if (capable(CAP_SYS_ADMIN)) {
@@ -108,30 +109,47 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
108 size = count; 109 size = count;
109 } 110 }
110 111
111 while (off & 3) { 112 if ((off & 1) && size) {
112 unsigned char val; 113 u8 val;
113 pci_read_config_byte(dev, off, &val); 114 pci_read_config_byte(dev, off, &val);
114 buf[off - init_off] = val; 115 data[off - init_off] = val;
115 off++; 116 off++;
116 if (--size == 0) 117 size--;
117 break; 118 }
119
120 if ((off & 3) && size > 2) {
121 u16 val;
122 pci_read_config_word(dev, off, &val);
123 data[off - init_off] = val & 0xff;
124 data[off - init_off + 1] = (val >> 8) & 0xff;
125 off += 2;
126 size -= 2;
118 } 127 }
119 128
120 while (size > 3) { 129 while (size > 3) {
121 unsigned int val; 130 u32 val;
122 pci_read_config_dword(dev, off, &val); 131 pci_read_config_dword(dev, off, &val);
123 buf[off - init_off] = val & 0xff; 132 data[off - init_off] = val & 0xff;
124 buf[off - init_off + 1] = (val >> 8) & 0xff; 133 data[off - init_off + 1] = (val >> 8) & 0xff;
125 buf[off - init_off + 2] = (val >> 16) & 0xff; 134 data[off - init_off + 2] = (val >> 16) & 0xff;
126 buf[off - init_off + 3] = (val >> 24) & 0xff; 135 data[off - init_off + 3] = (val >> 24) & 0xff;
127 off += 4; 136 off += 4;
128 size -= 4; 137 size -= 4;
129 } 138 }
130 139
131 while (size > 0) { 140 if (size >= 2) {
132 unsigned char val; 141 u16 val;
142 pci_read_config_word(dev, off, &val);
143 data[off - init_off] = val & 0xff;
144 data[off - init_off + 1] = (val >> 8) & 0xff;
145 off += 2;
146 size -= 2;
147 }
148
149 if (size > 0) {
150 u8 val;
133 pci_read_config_byte(dev, off, &val); 151 pci_read_config_byte(dev, off, &val);
134 buf[off - init_off] = val; 152 data[off - init_off] = val;
135 off++; 153 off++;
136 --size; 154 --size;
137 } 155 }
@@ -145,6 +163,7 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
145 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); 163 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj));
146 unsigned int size = count; 164 unsigned int size = count;
147 loff_t init_off = off; 165 loff_t init_off = off;
166 u8 *data = (u8*) buf;
148 167
149 if (off > dev->cfg_size) 168 if (off > dev->cfg_size)
150 return 0; 169 return 0;
@@ -152,26 +171,41 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
152 size = dev->cfg_size - off; 171 size = dev->cfg_size - off;
153 count = size; 172 count = size;
154 } 173 }
155 174
156 while (off & 3) { 175 if ((off & 1) && size) {
157 pci_write_config_byte(dev, off, buf[off - init_off]); 176 pci_write_config_byte(dev, off, data[off - init_off]);
158 off++; 177 off++;
159 if (--size == 0) 178 size--;
160 break;
161 } 179 }
180
181 if ((off & 3) && size > 2) {
182 u16 val = data[off - init_off];
183 val |= (u16) data[off - init_off + 1] << 8;
184 pci_write_config_word(dev, off, val);
185 off += 2;
186 size -= 2;
187 }
162 188
163 while (size > 3) { 189 while (size > 3) {
164 unsigned int val = buf[off - init_off]; 190 u32 val = data[off - init_off];
165 val |= (unsigned int) buf[off - init_off + 1] << 8; 191 val |= (u32) data[off - init_off + 1] << 8;
166 val |= (unsigned int) buf[off - init_off + 2] << 16; 192 val |= (u32) data[off - init_off + 2] << 16;
167 val |= (unsigned int) buf[off - init_off + 3] << 24; 193 val |= (u32) data[off - init_off + 3] << 24;
168 pci_write_config_dword(dev, off, val); 194 pci_write_config_dword(dev, off, val);
169 off += 4; 195 off += 4;
170 size -= 4; 196 size -= 4;
171 } 197 }
198
199 if (size >= 2) {
200 u16 val = data[off - init_off];
201 val |= (u16) data[off - init_off + 1] << 8;
202 pci_write_config_word(dev, off, val);
203 off += 2;
204 size -= 2;
205 }
172 206
173 while (size > 0) { 207 if (size) {
174 pci_write_config_byte(dev, off, buf[off - init_off]); 208 pci_write_config_byte(dev, off, data[off - init_off]);
175 off++; 209 off++;
176 --size; 210 --size;
177 } 211 }
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index bfbff8335268..f04b9ffe4153 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -16,6 +16,7 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <asm/dma.h> /* isa_dma_bridge_buggy */ 18#include <asm/dma.h> /* isa_dma_bridge_buggy */
19#include "pci.h"
19 20
20 21
21/** 22/**
@@ -398,10 +399,10 @@ pci_enable_device(struct pci_dev *dev)
398{ 399{
399 int err; 400 int err;
400 401
401 dev->is_enabled = 1;
402 if ((err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1))) 402 if ((err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1)))
403 return err; 403 return err;
404 pci_fixup_device(pci_fixup_enable, dev); 404 pci_fixup_device(pci_fixup_enable, dev);
405 dev->is_enabled = 1;
405 return 0; 406 return 0;
406} 407}
407 408
@@ -427,16 +428,15 @@ pci_disable_device(struct pci_dev *dev)
427{ 428{
428 u16 pci_command; 429 u16 pci_command;
429 430
430 dev->is_enabled = 0;
431 dev->is_busmaster = 0;
432
433 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 431 pci_read_config_word(dev, PCI_COMMAND, &pci_command);
434 if (pci_command & PCI_COMMAND_MASTER) { 432 if (pci_command & PCI_COMMAND_MASTER) {
435 pci_command &= ~PCI_COMMAND_MASTER; 433 pci_command &= ~PCI_COMMAND_MASTER;
436 pci_write_config_word(dev, PCI_COMMAND, pci_command); 434 pci_write_config_word(dev, PCI_COMMAND, pci_command);
437 } 435 }
436 dev->is_busmaster = 0;
438 437
439 pcibios_disable_device(dev); 438 pcibios_disable_device(dev);
439 dev->is_enabled = 0;
440} 440}
441 441
442/** 442/**
@@ -749,17 +749,6 @@ pci_set_dma_mask(struct pci_dev *dev, u64 mask)
749} 749}
750 750
751int 751int
752pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask)
753{
754 if (!pci_dac_dma_supported(dev, mask))
755 return -EIO;
756
757 dev->dma_mask = mask;
758
759 return 0;
760}
761
762int
763pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) 752pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
764{ 753{
765 if (!pci_dma_supported(dev, mask)) 754 if (!pci_dma_supported(dev, mask))
@@ -821,7 +810,6 @@ EXPORT_SYMBOL(pci_set_master);
821EXPORT_SYMBOL(pci_set_mwi); 810EXPORT_SYMBOL(pci_set_mwi);
822EXPORT_SYMBOL(pci_clear_mwi); 811EXPORT_SYMBOL(pci_clear_mwi);
823EXPORT_SYMBOL(pci_set_dma_mask); 812EXPORT_SYMBOL(pci_set_dma_mask);
824EXPORT_SYMBOL(pci_dac_set_dma_mask);
825EXPORT_SYMBOL(pci_set_consistent_dma_mask); 813EXPORT_SYMBOL(pci_set_consistent_dma_mask);
826EXPORT_SYMBOL(pci_assign_resource); 814EXPORT_SYMBOL(pci_assign_resource);
827EXPORT_SYMBOL(pci_find_parent_resource); 815EXPORT_SYMBOL(pci_find_parent_resource);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6f0edadd132c..b7ae87823c69 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -9,6 +9,7 @@
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/cpumask.h> 11#include <linux/cpumask.h>
12#include "pci.h"
12 13
13#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ 14#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */
14#define CARDBUS_RESERVE_BUSNR 3 15#define CARDBUS_RESERVE_BUSNR 3
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 84cc4f620d8d..e68bbfb1e7c3 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -15,6 +15,7 @@
15 15
16#include <asm/uaccess.h> 16#include <asm/uaccess.h>
17#include <asm/byteorder.h> 17#include <asm/byteorder.h>
18#include "pci.h"
18 19
19static int proc_initialized; /* = 0 */ 20static int proc_initialized; /* = 0 */
20 21
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 15a398051682..026aa04669a2 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -18,6 +18,7 @@
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include "pci.h"
21 22
22/* Deal with broken BIOS'es that neglect to enable passive release, 23/* Deal with broken BIOS'es that neglect to enable passive release,
23 which can cause problems in combination with the 82441FX/PPro MTRRs */ 24 which can cause problems in combination with the 82441FX/PPro MTRRs */
@@ -328,6 +329,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12,
328DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, quirk_ich4_lpc_acpi ); 329DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, quirk_ich4_lpc_acpi );
329DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, quirk_ich4_lpc_acpi ); 330DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, quirk_ich4_lpc_acpi );
330DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi ); 331DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi );
332DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, quirk_ich4_lpc_acpi );
331 333
332/* 334/*
333 * VIA ACPI: One IO region pointed to by longword at 335 * VIA ACPI: One IO region pointed to by longword at
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index 3e64ff64b38c..838575e3fac6 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -14,7 +14,7 @@
14 14
15/** 15/**
16 * pci_enable_rom - enable ROM decoding for a PCI device 16 * pci_enable_rom - enable ROM decoding for a PCI device
17 * @dev: PCI device to enable 17 * @pdev: PCI device to enable
18 * 18 *
19 * Enable ROM decoding on @dev. This involves simply turning on the last 19 * Enable ROM decoding on @dev. This involves simply turning on the last
20 * bit of the PCI ROM BAR. Note that some cards may share address decoders 20 * bit of the PCI ROM BAR. Note that some cards may share address decoders
@@ -32,7 +32,7 @@ static void pci_enable_rom(struct pci_dev *pdev)
32 32
33/** 33/**
34 * pci_disable_rom - disable ROM decoding for a PCI device 34 * pci_disable_rom - disable ROM decoding for a PCI device
35 * @dev: PCI device to disable 35 * @pdev: PCI device to disable
36 * 36 *
37 * Disable ROM decoding on a PCI device by turning off the last bit in the 37 * Disable ROM decoding on a PCI device by turning off the last bit in the
38 * ROM BAR. 38 * ROM BAR.
@@ -47,7 +47,7 @@ static void pci_disable_rom(struct pci_dev *pdev)
47 47
48/** 48/**
49 * pci_map_rom - map a PCI ROM to kernel space 49 * pci_map_rom - map a PCI ROM to kernel space
50 * @dev: pointer to pci device struct 50 * @pdev: pointer to pci device struct
51 * @size: pointer to receive size of pci window over ROM 51 * @size: pointer to receive size of pci window over ROM
52 * @return: kernel virtual pointer to image of ROM 52 * @return: kernel virtual pointer to image of ROM
53 * 53 *
@@ -132,7 +132,7 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
132 132
133/** 133/**
134 * pci_map_rom_copy - map a PCI ROM to kernel space, create a copy 134 * pci_map_rom_copy - map a PCI ROM to kernel space, create a copy
135 * @dev: pointer to pci device struct 135 * @pdev: pointer to pci device struct
136 * @size: pointer to receive size of pci window over ROM 136 * @size: pointer to receive size of pci window over ROM
137 * @return: kernel virtual pointer to image of ROM 137 * @return: kernel virtual pointer to image of ROM
138 * 138 *
@@ -166,7 +166,7 @@ void __iomem *pci_map_rom_copy(struct pci_dev *pdev, size_t *size)
166 166
167/** 167/**
168 * pci_unmap_rom - unmap the ROM from kernel space 168 * pci_unmap_rom - unmap the ROM from kernel space
169 * @dev: pointer to pci device struct 169 * @pdev: pointer to pci device struct
170 * @rom: virtual address of the previous mapping 170 * @rom: virtual address of the previous mapping
171 * 171 *
172 * Remove a mapping of a previously mapped ROM 172 * Remove a mapping of a previously mapped ROM
@@ -187,7 +187,7 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
187 187
188/** 188/**
189 * pci_remove_rom - disable the ROM and remove its sysfs attribute 189 * pci_remove_rom - disable the ROM and remove its sysfs attribute
190 * @dev: pointer to pci device struct 190 * @pdev: pointer to pci device struct
191 * 191 *
192 * Remove the rom file in sysfs and disable ROM decoding. 192 * Remove the rom file in sysfs and disable ROM decoding.
193 */ 193 */
@@ -206,7 +206,7 @@ void pci_remove_rom(struct pci_dev *pdev)
206/** 206/**
207 * pci_cleanup_rom - internal routine for freeing the ROM copy created 207 * pci_cleanup_rom - internal routine for freeing the ROM copy created
208 * by pci_map_rom_copy called from remove.c 208 * by pci_map_rom_copy called from remove.c
209 * @dev: pointer to pci device struct 209 * @pdev: pointer to pci device struct
210 * 210 *
211 * Free the copied ROM if we allocated one. 211 * Free the copied ROM if we allocated one.
212 */ 212 */
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index 3f4364341d8d..20642f0e7bfe 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -744,7 +744,7 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
744 744
745 for (i = 0; i < MAX_SOCKETS; i++) { 745 for (i = 0; i < MAX_SOCKETS; i++) {
746 socket[i].io_base = pci_resource_start(dev, 0); 746 socket[i].io_base = pci_resource_start(dev, 0);
747 socket[i].socket.features |= SS_CAP_PCCARD; 747 socket[i].socket.features |= SS_CAP_PAGE_REGS | SS_CAP_PCCARD;
748 socket[i].socket.map_size = 0x1000; 748 socket[i].socket.map_size = 0x1000;
749 socket[i].socket.irq_mask = mask; 749 socket[i].socket.irq_mask = mask;
750 socket[i].socket.pci_irq = dev->irq; 750 socket[i].socket.pci_irq = dev->irq;
diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
index 52c073a9d7e4..a8a1d104524a 100644
--- a/drivers/pcmcia/ti113x.h
+++ b/drivers/pcmcia/ti113x.h
@@ -442,6 +442,25 @@ out:
442} 442}
443 443
444 444
445/* changes the irq of func1 to match that of func0 */
446static int ti12xx_align_irqs(struct yenta_socket *socket, int *old_irq)
447{
448 struct pci_dev *func0;
449
450 /* find func0 device */
451 func0 = pci_get_slot(socket->dev->bus, socket->dev->devfn & ~0x07);
452 if (!func0)
453 return 0;
454
455 if (old_irq)
456 *old_irq = socket->cb_irq;
457 socket->cb_irq = socket->dev->irq = func0->irq;
458
459 pci_dev_put(func0);
460
461 return 1;
462}
463
445/* 464/*
446 * ties INTA and INTB together. also changes the devices irq to that of 465 * ties INTA and INTB together. also changes the devices irq to that of
447 * the function 0 device. call from func1 only. 466 * the function 0 device. call from func1 only.
@@ -449,26 +468,22 @@ out:
449 */ 468 */
450static int ti12xx_tie_interrupts(struct yenta_socket *socket, int *old_irq) 469static int ti12xx_tie_interrupts(struct yenta_socket *socket, int *old_irq)
451{ 470{
452 struct pci_dev *func0;
453 u32 sysctl; 471 u32 sysctl;
472 int ret;
454 473
455 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL); 474 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL);
456 if (sysctl & TI122X_SCR_INTRTIE) 475 if (sysctl & TI122X_SCR_INTRTIE)
457 return 0; 476 return 0;
458 477
459 /* find func0 device */ 478 /* align */
460 func0 = pci_get_slot(socket->dev->bus, socket->dev->devfn & ~0x07); 479 ret = ti12xx_align_irqs(socket, old_irq);
461 if (!func0) 480 if (!ret)
462 return 0; 481 return 0;
463 482
464 /* change the interrupt to match func0, tie 'em up */ 483 /* tie */
465 *old_irq = socket->cb_irq;
466 socket->cb_irq = socket->dev->irq = func0->irq;
467 sysctl |= TI122X_SCR_INTRTIE; 484 sysctl |= TI122X_SCR_INTRTIE;
468 config_writel(socket, TI113X_SYSTEM_CONTROL, sysctl); 485 config_writel(socket, TI113X_SYSTEM_CONTROL, sysctl);
469 486
470 pci_dev_put(func0);
471
472 return 1; 487 return 1;
473} 488}
474 489
@@ -489,7 +504,7 @@ static void ti12xx_untie_interrupts(struct yenta_socket *socket, int old_irq)
489 */ 504 */
490static void ti12xx_irqroute_func1(struct yenta_socket *socket) 505static void ti12xx_irqroute_func1(struct yenta_socket *socket)
491{ 506{
492 u32 mfunc, mfunc_old, devctl; 507 u32 mfunc, mfunc_old, devctl, sysctl;
493 int pci_irq_status; 508 int pci_irq_status;
494 509
495 mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC); 510 mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC);
@@ -497,6 +512,11 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket)
497 printk(KERN_INFO "Yenta TI: socket %s, mfunc 0x%08x, devctl 0x%02x\n", 512 printk(KERN_INFO "Yenta TI: socket %s, mfunc 0x%08x, devctl 0x%02x\n",
498 pci_name(socket->dev), mfunc, devctl); 513 pci_name(socket->dev), mfunc, devctl);
499 514
515 /* if IRQs are configured as tied, align irq of func1 with func0 */
516 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL);
517 if (sysctl & TI122X_SCR_INTRTIE)
518 ti12xx_align_irqs(socket, NULL);
519
500 /* make sure PCI interrupts are enabled before probing */ 520 /* make sure PCI interrupts are enabled before probing */
501 ti_init(socket); 521 ti_init(socket);
502 522
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index 639e04253482..65ecef738537 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -253,7 +253,7 @@ void pnp_init_resource_table(struct pnp_resource_table *table)
253 253
254/** 254/**
255 * pnp_clean_resources - clears resources that were not manually set 255 * pnp_clean_resources - clears resources that were not manually set
256 * @res - the resources to clean 256 * @res: the resources to clean
257 * 257 *
258 */ 258 */
259static void pnp_clean_resource_table(struct pnp_resource_table * res) 259static void pnp_clean_resource_table(struct pnp_resource_table * res)
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index c0ddb1eb8c4d..dd61e09029b1 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -94,8 +94,8 @@ static void
94pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma) 94pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma)
95{ 95{
96 int i = 0; 96 int i = 0;
97 while (!(res->dma_resource[i].flags & IORESOURCE_UNSET) && 97 while (i < PNP_MAX_DMA &&
98 i < PNP_MAX_DMA) 98 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
99 i++; 99 i++;
100 if (i < PNP_MAX_DMA) { 100 if (i < PNP_MAX_DMA) {
101 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag 101 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 618ac15a9e90..79bce7b75740 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -72,7 +72,9 @@ static void
72pnpbios_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma) 72pnpbios_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma)
73{ 73{
74 int i = 0; 74 int i = 0;
75 while (!(res->dma_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_DMA) i++; 75 while (i < PNP_MAX_DMA &&
76 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
77 i++;
76 if (i < PNP_MAX_DMA) { 78 if (i < PNP_MAX_DMA) {
77 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag 79 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
78 if (dma == -1) { 80 if (dma == -1) {
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index b755bac6ccbc..02cfe244e069 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -7,7 +7,7 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.158 $ 10 * $Revision: 1.161 $
11 */ 11 */
12 12
13#include <linux/config.h> 13#include <linux/config.h>
@@ -1131,13 +1131,17 @@ __dasd_process_blk_queue(struct dasd_device * device)
1131 request_queue_t *queue; 1131 request_queue_t *queue;
1132 struct request *req; 1132 struct request *req;
1133 struct dasd_ccw_req *cqr; 1133 struct dasd_ccw_req *cqr;
1134 int nr_queued; 1134 int nr_queued, feature_ro;
1135 1135
1136 queue = device->request_queue; 1136 queue = device->request_queue;
1137 /* No queue ? Then there is nothing to do. */ 1137 /* No queue ? Then there is nothing to do. */
1138 if (queue == NULL) 1138 if (queue == NULL)
1139 return; 1139 return;
1140 1140
1141 feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
1142 if (feature_ro < 0) /* no devmap */
1143 return;
1144
1141 /* 1145 /*
1142 * We requeue request from the block device queue to the ccw 1146 * We requeue request from the block device queue to the ccw
1143 * queue only in two states. In state DASD_STATE_READY the 1147 * queue only in two states. In state DASD_STATE_READY the
@@ -1157,8 +1161,8 @@ __dasd_process_blk_queue(struct dasd_device * device)
1157 elv_next_request(queue) && 1161 elv_next_request(queue) &&
1158 nr_queued < DASD_CHANQ_MAX_SIZE) { 1162 nr_queued < DASD_CHANQ_MAX_SIZE) {
1159 req = elv_next_request(queue); 1163 req = elv_next_request(queue);
1160 if (test_bit(DASD_FLAG_RO, &device->flags) && 1164
1161 rq_data_dir(req) == WRITE) { 1165 if (feature_ro && rq_data_dir(req) == WRITE) {
1162 DBF_DEV_EVENT(DBF_ERR, device, 1166 DBF_DEV_EVENT(DBF_ERR, device,
1163 "Rejecting write request %p", 1167 "Rejecting write request %p",
1164 req); 1168 req);
@@ -1631,6 +1635,7 @@ dasd_setup_queue(struct dasd_device * device)
1631 blk_queue_max_hw_segments(device->request_queue, -1L); 1635 blk_queue_max_hw_segments(device->request_queue, -1L);
1632 blk_queue_max_segment_size(device->request_queue, -1L); 1636 blk_queue_max_segment_size(device->request_queue, -1L);
1633 blk_queue_segment_boundary(device->request_queue, -1L); 1637 blk_queue_segment_boundary(device->request_queue, -1L);
1638 blk_queue_ordered(device->request_queue, 1);
1634} 1639}
1635 1640
1636/* 1641/*
@@ -1803,13 +1808,17 @@ dasd_generic_set_online (struct ccw_device *cdev,
1803 1808
1804{ 1809{
1805 struct dasd_device *device; 1810 struct dasd_device *device;
1806 int rc; 1811 int feature_diag, rc;
1812
1813 feature_diag = dasd_get_feature(cdev, DASD_FEATURE_USEDIAG);
1814 if (feature_diag < 0)
1815 return feature_diag;
1807 1816
1808 device = dasd_create_device(cdev); 1817 device = dasd_create_device(cdev);
1809 if (IS_ERR(device)) 1818 if (IS_ERR(device))
1810 return PTR_ERR(device); 1819 return PTR_ERR(device);
1811 1820
1812 if (test_bit(DASD_FLAG_USE_DIAG, &device->flags)) { 1821 if (feature_diag) {
1813 if (!dasd_diag_discipline_pointer) { 1822 if (!dasd_diag_discipline_pointer) {
1814 printk (KERN_WARNING 1823 printk (KERN_WARNING
1815 "dasd_generic couldn't online device %s " 1824 "dasd_generic couldn't online device %s "
diff --git a/drivers/s390/block/dasd_cmb.c b/drivers/s390/block/dasd_cmb.c
index ed1ab474c0c6..4f365bff275c 100644
--- a/drivers/s390/block/dasd_cmb.c
+++ b/drivers/s390/block/dasd_cmb.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/s390/block/dasd_cmb.c ($Revision: 1.6 $) 2 * linux/drivers/s390/block/dasd_cmb.c ($Revision: 1.9 $)
3 * 3 *
4 * Linux on zSeries Channel Measurement Facility support 4 * Linux on zSeries Channel Measurement Facility support
5 * (dasd device driver interface) 5 * (dasd device driver interface)
@@ -23,7 +23,6 @@
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/ioctl32.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <asm/ccwdev.h> 27#include <asm/ccwdev.h>
29#include <asm/cmb.h> 28#include <asm/cmb.h>
@@ -84,27 +83,13 @@ dasd_ioctl_readall_cmb(struct block_device *bdev, int no, long args)
84static inline int 83static inline int
85ioctl_reg(unsigned int no, dasd_ioctl_fn_t handler) 84ioctl_reg(unsigned int no, dasd_ioctl_fn_t handler)
86{ 85{
87 int ret; 86 return dasd_ioctl_no_register(THIS_MODULE, no, handler);
88 ret = dasd_ioctl_no_register(THIS_MODULE, no, handler);
89#ifdef CONFIG_COMPAT
90 if (ret)
91 return ret;
92
93 ret = register_ioctl32_conversion(no, NULL);
94 if (ret)
95 dasd_ioctl_no_unregister(THIS_MODULE, no, handler);
96#endif
97 return ret;
98} 87}
99 88
100static inline void 89static inline void
101ioctl_unreg(unsigned int no, dasd_ioctl_fn_t handler) 90ioctl_unreg(unsigned int no, dasd_ioctl_fn_t handler)
102{ 91{
103 dasd_ioctl_no_unregister(THIS_MODULE, no, handler); 92 dasd_ioctl_no_unregister(THIS_MODULE, no, handler);
104#ifdef CONFIG_COMPAT
105 unregister_ioctl32_conversion(no);
106#endif
107
108} 93}
109 94
110static void 95static void
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index ad1841a96c87..1aedc48e5f85 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -11,7 +11,7 @@
11 * functions may not be called from interrupt context. In particular 11 * functions may not be called from interrupt context. In particular
12 * dasd_get_device is a no-no from interrupt context. 12 * dasd_get_device is a no-no from interrupt context.
13 * 13 *
14 * $Revision: 1.37 $ 14 * $Revision: 1.40 $
15 */ 15 */
16 16
17#include <linux/config.h> 17#include <linux/config.h>
@@ -513,14 +513,6 @@ dasd_create_device(struct ccw_device *cdev)
513 if (!devmap->device) { 513 if (!devmap->device) {
514 devmap->device = device; 514 devmap->device = device;
515 device->devindex = devmap->devindex; 515 device->devindex = devmap->devindex;
516 if (devmap->features & DASD_FEATURE_READONLY)
517 set_bit(DASD_FLAG_RO, &device->flags);
518 else
519 clear_bit(DASD_FLAG_RO, &device->flags);
520 if (devmap->features & DASD_FEATURE_USEDIAG)
521 set_bit(DASD_FLAG_USE_DIAG, &device->flags);
522 else
523 clear_bit(DASD_FLAG_USE_DIAG, &device->flags);
524 get_device(&cdev->dev); 516 get_device(&cdev->dev);
525 device->cdev = cdev; 517 device->cdev = cdev;
526 rc = 0; 518 rc = 0;
@@ -651,14 +643,8 @@ dasd_ro_store(struct device *dev, const char *buf, size_t count)
651 devmap->features |= DASD_FEATURE_READONLY; 643 devmap->features |= DASD_FEATURE_READONLY;
652 else 644 else
653 devmap->features &= ~DASD_FEATURE_READONLY; 645 devmap->features &= ~DASD_FEATURE_READONLY;
654 if (devmap->device) { 646 if (devmap->device && devmap->device->gdp)
655 if (devmap->device->gdp) 647 set_disk_ro(devmap->device->gdp, ro_flag);
656 set_disk_ro(devmap->device->gdp, ro_flag);
657 if (ro_flag)
658 set_bit(DASD_FLAG_RO, &devmap->device->flags);
659 else
660 clear_bit(DASD_FLAG_RO, &devmap->device->flags);
661 }
662 spin_unlock(&dasd_devmap_lock); 648 spin_unlock(&dasd_devmap_lock);
663 return count; 649 return count;
664} 650}
@@ -739,6 +725,45 @@ static struct attribute_group dasd_attr_group = {
739 .attrs = dasd_attrs, 725 .attrs = dasd_attrs,
740}; 726};
741 727
728/*
729 * Return value of the specified feature.
730 */
731int
732dasd_get_feature(struct ccw_device *cdev, int feature)
733{
734 struct dasd_devmap *devmap;
735
736 devmap = dasd_find_busid(cdev->dev.bus_id);
737 if (IS_ERR(devmap))
738 return (int) PTR_ERR(devmap);
739
740 return ((devmap->features & feature) != 0);
741}
742
743/*
744 * Set / reset given feature.
745 * Flag indicates wether to set (!=0) or the reset (=0) the feature.
746 */
747int
748dasd_set_feature(struct ccw_device *cdev, int feature, int flag)
749{
750 struct dasd_devmap *devmap;
751
752 devmap = dasd_find_busid(cdev->dev.bus_id);
753 if (IS_ERR(devmap))
754 return (int) PTR_ERR(devmap);
755
756 spin_lock(&dasd_devmap_lock);
757 if (flag)
758 devmap->features |= feature;
759 else
760 devmap->features &= ~feature;
761
762 spin_unlock(&dasd_devmap_lock);
763 return 0;
764}
765
766
742int 767int
743dasd_add_sysfs_files(struct ccw_device *cdev) 768dasd_add_sysfs_files(struct ccw_device *cdev)
744{ 769{
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 838aedf78a56..811060e10c00 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -7,7 +7,7 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
9 * 9 *
10 * $Revision: 1.69 $ 10 * $Revision: 1.71 $
11 */ 11 */
12 12
13#include <linux/config.h> 13#include <linux/config.h>
@@ -1101,7 +1101,8 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
1101 if (dasd_eckd_cdl_special(blk_per_trk, recid)){ 1101 if (dasd_eckd_cdl_special(blk_per_trk, recid)){
1102 rcmd |= 0x8; 1102 rcmd |= 0x8;
1103 count = dasd_eckd_cdl_reclen(recid); 1103 count = dasd_eckd_cdl_reclen(recid);
1104 if (count < blksize) 1104 if (count < blksize &&
1105 rq_data_dir(req) == READ)
1105 memset(dst + count, 0xe5, 1106 memset(dst + count, 0xe5,
1106 blksize - count); 1107 blksize - count);
1107 } 1108 }
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index 1d52db406b2e..96c49349701f 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -9,7 +9,7 @@
9 * 9 *
10 * gendisk related functions for the dasd driver. 10 * gendisk related functions for the dasd driver.
11 * 11 *
12 * $Revision: 1.48 $ 12 * $Revision: 1.50 $
13 */ 13 */
14 14
15#include <linux/config.h> 15#include <linux/config.h>
@@ -31,12 +31,16 @@ int
31dasd_gendisk_alloc(struct dasd_device *device) 31dasd_gendisk_alloc(struct dasd_device *device)
32{ 32{
33 struct gendisk *gdp; 33 struct gendisk *gdp;
34 int len; 34 int len, feature_ro;
35 35
36 /* Make sure the minor for this device exists. */ 36 /* Make sure the minor for this device exists. */
37 if (device->devindex >= DASD_PER_MAJOR) 37 if (device->devindex >= DASD_PER_MAJOR)
38 return -EBUSY; 38 return -EBUSY;
39 39
40 feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
41 if (feature_ro < 0)
42 return feature_ro;
43
40 gdp = alloc_disk(1 << DASD_PARTN_BITS); 44 gdp = alloc_disk(1 << DASD_PARTN_BITS);
41 if (!gdp) 45 if (!gdp)
42 return -ENOMEM; 46 return -ENOMEM;
@@ -71,7 +75,7 @@ dasd_gendisk_alloc(struct dasd_device *device)
71 75
72 sprintf(gdp->devfs_name, "dasd/%s", device->cdev->dev.bus_id); 76 sprintf(gdp->devfs_name, "dasd/%s", device->cdev->dev.bus_id);
73 77
74 if (test_bit(DASD_FLAG_RO, &device->flags)) 78 if (feature_ro)
75 set_disk_ro(gdp, 1); 79 set_disk_ro(gdp, 1);
76 gdp->private_data = device; 80 gdp->private_data = device;
77 gdp->queue = device->request_queue; 81 gdp->queue = device->request_queue;
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 4586e0ecc526..a9f38b235981 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -6,7 +6,7 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.63 $ 9 * $Revision: 1.64 $
10 */ 10 */
11 11
12#ifndef DASD_INT_H 12#ifndef DASD_INT_H
@@ -329,8 +329,6 @@ struct dasd_device {
329#define DASD_STOPPED_DC_EIO 16 /* disconnected, return -EIO */ 329#define DASD_STOPPED_DC_EIO 16 /* disconnected, return -EIO */
330 330
331/* per device flags */ 331/* per device flags */
332#define DASD_FLAG_RO 0 /* device is read-only */
333#define DASD_FLAG_USE_DIAG 1 /* use diag disciplnie */
334#define DASD_FLAG_DSC_ERROR 2 /* return -EIO when disconnected */ 332#define DASD_FLAG_DSC_ERROR 2 /* return -EIO when disconnected */
335#define DASD_FLAG_OFFLINE 3 /* device is in offline processing */ 333#define DASD_FLAG_OFFLINE 3 /* device is in offline processing */
336 334
@@ -501,6 +499,9 @@ void dasd_devmap_exit(void);
501struct dasd_device *dasd_create_device(struct ccw_device *); 499struct dasd_device *dasd_create_device(struct ccw_device *);
502void dasd_delete_device(struct dasd_device *); 500void dasd_delete_device(struct dasd_device *);
503 501
502int dasd_get_feature(struct ccw_device *, int);
503int dasd_set_feature(struct ccw_device *, int, int);
504
504int dasd_add_sysfs_files(struct ccw_device *); 505int dasd_add_sysfs_files(struct ccw_device *);
505void dasd_remove_sysfs_files(struct ccw_device *); 506void dasd_remove_sysfs_files(struct ccw_device *);
506 507
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index f1892baa3b18..980c555aa538 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -7,6 +7,8 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.45 $
11 *
10 * i/o controls for the dasd driver. 12 * i/o controls for the dasd driver.
11 */ 13 */
12#include <linux/config.h> 14#include <linux/config.h>
@@ -294,6 +296,7 @@ dasd_ioctl_format(struct block_device *bdev, int no, long args)
294{ 296{
295 struct dasd_device *device; 297 struct dasd_device *device;
296 struct format_data_t fdata; 298 struct format_data_t fdata;
299 int feature_ro;
297 300
298 if (!capable(CAP_SYS_ADMIN)) 301 if (!capable(CAP_SYS_ADMIN))
299 return -EACCES; 302 return -EACCES;
@@ -304,7 +307,11 @@ dasd_ioctl_format(struct block_device *bdev, int no, long args)
304 307
305 if (device == NULL) 308 if (device == NULL)
306 return -ENODEV; 309 return -ENODEV;
307 if (test_bit(DASD_FLAG_RO, &device->flags)) 310
311 feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
312 if (feature_ro < 0)
313 return feature_ro;
314 if (feature_ro)
308 return -EROFS; 315 return -EROFS;
309 if (copy_from_user(&fdata, (void __user *) args, 316 if (copy_from_user(&fdata, (void __user *) args,
310 sizeof (struct format_data_t))) 317 sizeof (struct format_data_t)))
@@ -377,7 +384,7 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
377 struct dasd_device *device; 384 struct dasd_device *device;
378 struct dasd_information2_t *dasd_info; 385 struct dasd_information2_t *dasd_info;
379 unsigned long flags; 386 unsigned long flags;
380 int rc; 387 int rc, feature_ro;
381 struct ccw_device *cdev; 388 struct ccw_device *cdev;
382 389
383 device = bdev->bd_disk->private_data; 390 device = bdev->bd_disk->private_data;
@@ -387,6 +394,10 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
387 if (!device->discipline->fill_info) 394 if (!device->discipline->fill_info)
388 return -EINVAL; 395 return -EINVAL;
389 396
397 feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
398 if (feature_ro < 0)
399 return feature_ro;
400
390 dasd_info = kmalloc(sizeof(struct dasd_information2_t), GFP_KERNEL); 401 dasd_info = kmalloc(sizeof(struct dasd_information2_t), GFP_KERNEL);
391 if (dasd_info == NULL) 402 if (dasd_info == NULL)
392 return -ENOMEM; 403 return -ENOMEM;
@@ -415,9 +426,8 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
415 if ((device->state < DASD_STATE_READY) || 426 if ((device->state < DASD_STATE_READY) ||
416 (dasd_check_blocksize(device->bp_block))) 427 (dasd_check_blocksize(device->bp_block)))
417 dasd_info->format = DASD_FORMAT_NONE; 428 dasd_info->format = DASD_FORMAT_NONE;
418 429
419 dasd_info->features |= test_bit(DASD_FLAG_RO, &device->flags) ? 430 dasd_info->features |= feature_ro;
420 DASD_FEATURE_READONLY : DASD_FEATURE_DEFAULT;
421 431
422 if (device->discipline) 432 if (device->discipline)
423 memcpy(dasd_info->type, device->discipline->name, 4); 433 memcpy(dasd_info->type, device->discipline->name, 4);
@@ -460,7 +470,7 @@ static int
460dasd_ioctl_set_ro(struct block_device *bdev, int no, long args) 470dasd_ioctl_set_ro(struct block_device *bdev, int no, long args)
461{ 471{
462 struct dasd_device *device; 472 struct dasd_device *device;
463 int intval; 473 int intval, rc;
464 474
465 if (!capable(CAP_SYS_ADMIN)) 475 if (!capable(CAP_SYS_ADMIN))
466 return -EACCES; 476 return -EACCES;
@@ -472,12 +482,11 @@ dasd_ioctl_set_ro(struct block_device *bdev, int no, long args)
472 device = bdev->bd_disk->private_data; 482 device = bdev->bd_disk->private_data;
473 if (device == NULL) 483 if (device == NULL)
474 return -ENODEV; 484 return -ENODEV;
485
475 set_disk_ro(bdev->bd_disk, intval); 486 set_disk_ro(bdev->bd_disk, intval);
476 if (intval) 487 rc = dasd_set_feature(device->cdev, DASD_FEATURE_READONLY, intval);
477 set_bit(DASD_FLAG_RO, &device->flags); 488
478 else 489 return rc;
479 clear_bit(DASD_FLAG_RO, &device->flags);
480 return 0;
481} 490}
482 491
483/* 492/*
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index 353d41118c62..d7f19745911f 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -9,7 +9,7 @@
9 * 9 *
10 * /proc interface for the dasd driver. 10 * /proc interface for the dasd driver.
11 * 11 *
12 * $Revision: 1.30 $ 12 * $Revision: 1.31 $
13 */ 13 */
14 14
15#include <linux/config.h> 15#include <linux/config.h>
@@ -54,6 +54,7 @@ dasd_devices_show(struct seq_file *m, void *v)
54{ 54{
55 struct dasd_device *device; 55 struct dasd_device *device;
56 char *substr; 56 char *substr;
57 int feature;
57 58
58 device = dasd_device_from_devindex((unsigned long) v - 1); 59 device = dasd_device_from_devindex((unsigned long) v - 1);
59 if (IS_ERR(device)) 60 if (IS_ERR(device))
@@ -77,7 +78,10 @@ dasd_devices_show(struct seq_file *m, void *v)
77 else 78 else
78 seq_printf(m, " is ????????"); 79 seq_printf(m, " is ????????");
79 /* Print devices features. */ 80 /* Print devices features. */
80 substr = test_bit(DASD_FLAG_RO, &device->flags) ? "(ro)" : " "; 81 feature = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
82 if (feature < 0)
83 return 0;
84 substr = feature ? "(ro)" : " ";
81 seq_printf(m, "%4s: ", substr); 85 seq_printf(m, "%4s: ", substr);
82 /* Print device status information. */ 86 /* Print device status information. */
83 switch ((device != NULL) ? device->state : -1) { 87 switch ((device != NULL) ? device->state : -1) {
diff --git a/drivers/s390/cio/airq.c b/drivers/s390/cio/airq.c
index 3720e77b465f..83e6a060668e 100644
--- a/drivers/s390/cio/airq.c
+++ b/drivers/s390/cio/airq.c
@@ -45,7 +45,7 @@ s390_register_adapter_interrupt (adapter_int_handler_t handler)
45 else 45 else
46 ret = (cmpxchg(&adapter_handler, NULL, handler) ? -EBUSY : 0); 46 ret = (cmpxchg(&adapter_handler, NULL, handler) ? -EBUSY : 0);
47 if (!ret) 47 if (!ret)
48 synchronize_kernel(); 48 synchronize_sched(); /* Allow interrupts to complete. */
49 49
50 sprintf (dbf_txt, "ret:%d", ret); 50 sprintf (dbf_txt, "ret:%d", ret);
51 CIO_TRACE_EVENT (4, dbf_txt); 51 CIO_TRACE_EVENT (4, dbf_txt);
@@ -65,7 +65,7 @@ s390_unregister_adapter_interrupt (adapter_int_handler_t handler)
65 ret = -EINVAL; 65 ret = -EINVAL;
66 else { 66 else {
67 adapter_handler = NULL; 67 adapter_handler = NULL;
68 synchronize_kernel(); 68 synchronize_sched(); /* Allow interrupts to complete. */
69 ret = 0; 69 ret = 0;
70 } 70 }
71 sprintf (dbf_txt, "ret:%d", ret); 71 sprintf (dbf_txt, "ret:%d", ret);
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 99ce5a567982..1d9b3f18d8de 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/cio.c 2 * drivers/s390/cio/cio.c
3 * S/390 common I/O routines -- low level i/o calls 3 * S/390 common I/O routines -- low level i/o calls
4 * $Revision: 1.131 $ 4 * $Revision: 1.133 $
5 * 5 *
6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -228,7 +228,7 @@ cio_start_key (struct subchannel *sch, /* subchannel structure */
228int 228int
229cio_start (struct subchannel *sch, struct ccw1 *cpa, __u8 lpm) 229cio_start (struct subchannel *sch, struct ccw1 *cpa, __u8 lpm)
230{ 230{
231 return cio_start_key(sch, cpa, lpm, default_storage_key); 231 return cio_start_key(sch, cpa, lpm, PAGE_DEFAULT_KEY);
232} 232}
233 233
234/* 234/*
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 11e260e0b9c9..02d01a0de16c 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/device_ops.c 2 * drivers/s390/cio/device_ops.c
3 * 3 *
4 * $Revision: 1.55 $ 4 * $Revision: 1.56 $
5 * 5 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -128,7 +128,7 @@ ccw_device_start(struct ccw_device *cdev, struct ccw1 *cpa,
128 unsigned long intparm, __u8 lpm, unsigned long flags) 128 unsigned long intparm, __u8 lpm, unsigned long flags)
129{ 129{
130 return ccw_device_start_key(cdev, cpa, intparm, lpm, 130 return ccw_device_start_key(cdev, cpa, intparm, lpm,
131 default_storage_key, flags); 131 PAGE_DEFAULT_KEY, flags);
132} 132}
133 133
134int 134int
@@ -137,7 +137,7 @@ ccw_device_start_timeout(struct ccw_device *cdev, struct ccw1 *cpa,
137 int expires) 137 int expires)
138{ 138{
139 return ccw_device_start_timeout_key(cdev, cpa, intparm, lpm, 139 return ccw_device_start_timeout_key(cdev, cpa, intparm, lpm,
140 default_storage_key, flags, 140 PAGE_DEFAULT_KEY, flags,
141 expires); 141 expires);
142} 142}
143 143
diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h
index 9ad14db24143..b6daadac4e8b 100644
--- a/drivers/s390/cio/qdio.h
+++ b/drivers/s390/cio/qdio.h
@@ -1,7 +1,9 @@
1#ifndef _CIO_QDIO_H 1#ifndef _CIO_QDIO_H
2#define _CIO_QDIO_H 2#define _CIO_QDIO_H
3 3
4#define VERSION_CIO_QDIO_H "$Revision: 1.26 $" 4#include <asm/page.h>
5
6#define VERSION_CIO_QDIO_H "$Revision: 1.32 $"
5 7
6#ifdef CONFIG_QDIO_DEBUG 8#ifdef CONFIG_QDIO_DEBUG
7#define QDIO_VERBOSE_LEVEL 9 9#define QDIO_VERBOSE_LEVEL 9
@@ -42,7 +44,7 @@
42 44
43#define QDIO_Q_LAPS 5 45#define QDIO_Q_LAPS 5
44 46
45#define QDIO_STORAGE_KEY 0 47#define QDIO_STORAGE_KEY PAGE_DEFAULT_KEY
46 48
47#define L2_CACHELINE_SIZE 256 49#define L2_CACHELINE_SIZE 256
48#define INDICATORS_PER_CACHELINE (L2_CACHELINE_SIZE/sizeof(__u32)) 50#define INDICATORS_PER_CACHELINE (L2_CACHELINE_SIZE/sizeof(__u32))
diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c
index a98c00c02559..9ec29bb41b28 100644
--- a/drivers/s390/crypto/z90main.c
+++ b/drivers/s390/crypto/z90main.c
@@ -385,8 +385,8 @@ static int z90crypt_release(struct inode *, struct file *);
385static ssize_t z90crypt_read(struct file *, char __user *, size_t, loff_t *); 385static ssize_t z90crypt_read(struct file *, char __user *, size_t, loff_t *);
386static ssize_t z90crypt_write(struct file *, const char __user *, 386static ssize_t z90crypt_write(struct file *, const char __user *,
387 size_t, loff_t *); 387 size_t, loff_t *);
388static int z90crypt_ioctl(struct inode *, struct file *, 388static long z90crypt_unlocked_ioctl(struct file *, unsigned int, unsigned long);
389 unsigned int, unsigned long); 389static long z90crypt_compat_ioctl(struct file *, unsigned int, unsigned long);
390 390
391static void z90crypt_reader_task(unsigned long); 391static void z90crypt_reader_task(unsigned long);
392static void z90crypt_schedule_reader_task(unsigned long); 392static void z90crypt_schedule_reader_task(unsigned long);
@@ -433,12 +433,15 @@ static atomic_t total_open;
433static atomic_t z90crypt_step; 433static atomic_t z90crypt_step;
434 434
435static struct file_operations z90crypt_fops = { 435static struct file_operations z90crypt_fops = {
436 .owner = THIS_MODULE, 436 .owner = THIS_MODULE,
437 .read = z90crypt_read, 437 .read = z90crypt_read,
438 .write = z90crypt_write, 438 .write = z90crypt_write,
439 .ioctl = z90crypt_ioctl, 439 .unlocked_ioctl = z90crypt_unlocked_ioctl,
440 .open = z90crypt_open, 440#ifdef CONFIG_COMPAT
441 .release = z90crypt_release 441 .compat_ioctl = z90crypt_compat_ioctl,
442#endif
443 .open = z90crypt_open,
444 .release = z90crypt_release
442}; 445};
443 446
444#ifndef Z90CRYPT_USE_HOTPLUG 447#ifndef Z90CRYPT_USE_HOTPLUG
@@ -474,14 +477,13 @@ struct ica_rsa_modexpo_32 { // For 32-bit callers
474 compat_uptr_t n_modulus; 477 compat_uptr_t n_modulus;
475}; 478};
476 479
477static int 480static long
478trans_modexpo32(unsigned int fd, unsigned int cmd, unsigned long arg, 481trans_modexpo32(struct file *filp, unsigned int cmd, unsigned long arg)
479 struct file *file)
480{ 482{
481 struct ica_rsa_modexpo_32 __user *mex32u = compat_ptr(arg); 483 struct ica_rsa_modexpo_32 __user *mex32u = compat_ptr(arg);
482 struct ica_rsa_modexpo_32 mex32k; 484 struct ica_rsa_modexpo_32 mex32k;
483 struct ica_rsa_modexpo __user *mex64; 485 struct ica_rsa_modexpo __user *mex64;
484 int ret = 0; 486 long ret = 0;
485 unsigned int i; 487 unsigned int i;
486 488
487 if (!access_ok(VERIFY_WRITE, mex32u, sizeof(struct ica_rsa_modexpo_32))) 489 if (!access_ok(VERIFY_WRITE, mex32u, sizeof(struct ica_rsa_modexpo_32)))
@@ -498,7 +500,7 @@ trans_modexpo32(unsigned int fd, unsigned int cmd, unsigned long arg,
498 __put_user(compat_ptr(mex32k.b_key), &mex64->b_key) || 500 __put_user(compat_ptr(mex32k.b_key), &mex64->b_key) ||
499 __put_user(compat_ptr(mex32k.n_modulus), &mex64->n_modulus)) 501 __put_user(compat_ptr(mex32k.n_modulus), &mex64->n_modulus))
500 return -EFAULT; 502 return -EFAULT;
501 ret = sys_ioctl(fd, cmd, (unsigned long)mex64); 503 ret = z90crypt_unlocked_ioctl(filp, cmd, (unsigned long)mex64);
502 if (!ret) 504 if (!ret)
503 if (__get_user(i, &mex64->outputdatalength) || 505 if (__get_user(i, &mex64->outputdatalength) ||
504 __put_user(i, &mex32u->outputdatalength)) 506 __put_user(i, &mex32u->outputdatalength))
@@ -518,14 +520,13 @@ struct ica_rsa_modexpo_crt_32 { // For 32-bit callers
518 compat_uptr_t u_mult_inv; 520 compat_uptr_t u_mult_inv;
519}; 521};
520 522
521static int 523static long
522trans_modexpo_crt32(unsigned int fd, unsigned int cmd, unsigned long arg, 524trans_modexpo_crt32(struct file *filp, unsigned int cmd, unsigned long arg)
523 struct file *file)
524{ 525{
525 struct ica_rsa_modexpo_crt_32 __user *crt32u = compat_ptr(arg); 526 struct ica_rsa_modexpo_crt_32 __user *crt32u = compat_ptr(arg);
526 struct ica_rsa_modexpo_crt_32 crt32k; 527 struct ica_rsa_modexpo_crt_32 crt32k;
527 struct ica_rsa_modexpo_crt __user *crt64; 528 struct ica_rsa_modexpo_crt __user *crt64;
528 int ret = 0; 529 long ret = 0;
529 unsigned int i; 530 unsigned int i;
530 531
531 if (!access_ok(VERIFY_WRITE, crt32u, 532 if (!access_ok(VERIFY_WRITE, crt32u,
@@ -546,9 +547,8 @@ trans_modexpo_crt32(unsigned int fd, unsigned int cmd, unsigned long arg,
546 __put_user(compat_ptr(crt32k.np_prime), &crt64->np_prime) || 547 __put_user(compat_ptr(crt32k.np_prime), &crt64->np_prime) ||
547 __put_user(compat_ptr(crt32k.nq_prime), &crt64->nq_prime) || 548 __put_user(compat_ptr(crt32k.nq_prime), &crt64->nq_prime) ||
548 __put_user(compat_ptr(crt32k.u_mult_inv), &crt64->u_mult_inv)) 549 __put_user(compat_ptr(crt32k.u_mult_inv), &crt64->u_mult_inv))
549 ret = -EFAULT; 550 return -EFAULT;
550 if (!ret) 551 ret = z90crypt_unlocked_ioctl(filp, cmd, (unsigned long)crt64);
551 ret = sys_ioctl(fd, cmd, (unsigned long)crt64);
552 if (!ret) 552 if (!ret)
553 if (__get_user(i, &crt64->outputdatalength) || 553 if (__get_user(i, &crt64->outputdatalength) ||
554 __put_user(i, &crt32u->outputdatalength)) 554 __put_user(i, &crt32u->outputdatalength))
@@ -556,66 +556,34 @@ trans_modexpo_crt32(unsigned int fd, unsigned int cmd, unsigned long arg,
556 return ret; 556 return ret;
557} 557}
558 558
559static int compatible_ioctls[] = { 559static long
560 ICAZ90STATUS, Z90QUIESCE, Z90STAT_TOTALCOUNT, Z90STAT_PCICACOUNT, 560z90crypt_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
561 Z90STAT_PCICCCOUNT, Z90STAT_PCIXCCCOUNT, Z90STAT_PCIXCCMCL2COUNT,
562 Z90STAT_PCIXCCMCL3COUNT, Z90STAT_CEX2CCOUNT, Z90STAT_REQUESTQ_COUNT,
563 Z90STAT_PENDINGQ_COUNT, Z90STAT_TOTALOPEN_COUNT, Z90STAT_DOMAIN_INDEX,
564 Z90STAT_STATUS_MASK, Z90STAT_QDEPTH_MASK, Z90STAT_PERDEV_REQCNT,
565};
566
567static void z90_unregister_ioctl32s(void)
568{
569 int i;
570
571 unregister_ioctl32_conversion(ICARSAMODEXPO);
572 unregister_ioctl32_conversion(ICARSACRT);
573
574 for(i = 0; i < ARRAY_SIZE(compatible_ioctls); i++)
575 unregister_ioctl32_conversion(compatible_ioctls[i]);
576}
577
578static int z90_register_ioctl32s(void)
579{
580 int result, i;
581
582 result = register_ioctl32_conversion(ICARSAMODEXPO, trans_modexpo32);
583 if (result == -EBUSY) {
584 unregister_ioctl32_conversion(ICARSAMODEXPO);
585 result = register_ioctl32_conversion(ICARSAMODEXPO,
586 trans_modexpo32);
587 }
588 if (result)
589 return result;
590 result = register_ioctl32_conversion(ICARSACRT, trans_modexpo_crt32);
591 if (result == -EBUSY) {
592 unregister_ioctl32_conversion(ICARSACRT);
593 result = register_ioctl32_conversion(ICARSACRT,
594 trans_modexpo_crt32);
595 }
596 if (result)
597 return result;
598
599 for(i = 0; i < ARRAY_SIZE(compatible_ioctls); i++) {
600 result = register_ioctl32_conversion(compatible_ioctls[i], 0);
601 if (result == -EBUSY) {
602 unregister_ioctl32_conversion(compatible_ioctls[i]);
603 result = register_ioctl32_conversion(
604 compatible_ioctls[i], 0);
605 }
606 if (result)
607 return result;
608 }
609 return 0;
610}
611#else // !CONFIG_COMPAT
612static inline void z90_unregister_ioctl32s(void)
613{
614}
615
616static inline int z90_register_ioctl32s(void)
617{ 561{
618 return 0; 562 switch (cmd) {
563 case ICAZ90STATUS:
564 case Z90QUIESCE:
565 case Z90STAT_TOTALCOUNT:
566 case Z90STAT_PCICACOUNT:
567 case Z90STAT_PCICCCOUNT:
568 case Z90STAT_PCIXCCCOUNT:
569 case Z90STAT_PCIXCCMCL2COUNT:
570 case Z90STAT_PCIXCCMCL3COUNT:
571 case Z90STAT_CEX2CCOUNT:
572 case Z90STAT_REQUESTQ_COUNT:
573 case Z90STAT_PENDINGQ_COUNT:
574 case Z90STAT_TOTALOPEN_COUNT:
575 case Z90STAT_DOMAIN_INDEX:
576 case Z90STAT_STATUS_MASK:
577 case Z90STAT_QDEPTH_MASK:
578 case Z90STAT_PERDEV_REQCNT:
579 return z90crypt_unlocked_ioctl(filp, cmd, arg);
580 case ICARSAMODEXPO:
581 return trans_modexpo32(filp, cmd, arg);
582 case ICARSACRT:
583 return trans_modexpo_crt32(filp, cmd, arg);
584 default:
585 return -ENOIOCTLCMD;
586 }
619} 587}
620#endif 588#endif
621 589
@@ -730,14 +698,9 @@ z90crypt_init_module(void)
730 reader_timer.expires = jiffies + (READERTIME * HZ / 1000); 698 reader_timer.expires = jiffies + (READERTIME * HZ / 1000);
731 add_timer(&reader_timer); 699 add_timer(&reader_timer);
732 700
733 if ((result = z90_register_ioctl32s()))
734 goto init_module_cleanup;
735
736 return 0; // success 701 return 0; // success
737 702
738init_module_cleanup: 703init_module_cleanup:
739 z90_unregister_ioctl32s();
740
741#ifndef Z90CRYPT_USE_HOTPLUG 704#ifndef Z90CRYPT_USE_HOTPLUG
742 if ((nresult = misc_deregister(&z90crypt_misc_device))) 705 if ((nresult = misc_deregister(&z90crypt_misc_device)))
743 PRINTK("misc_deregister failed with %d.\n", nresult); 706 PRINTK("misc_deregister failed with %d.\n", nresult);
@@ -763,8 +726,6 @@ z90crypt_cleanup_module(void)
763 726
764 PDEBUG("PID %d\n", PID()); 727 PDEBUG("PID %d\n", PID());
765 728
766 z90_unregister_ioctl32s();
767
768 remove_proc_entry("driver/z90crypt", 0); 729 remove_proc_entry("driver/z90crypt", 0);
769 730
770#ifndef Z90CRYPT_USE_HOTPLUG 731#ifndef Z90CRYPT_USE_HOTPLUG
@@ -800,7 +761,7 @@ z90crypt_cleanup_module(void)
800 * z90crypt_release 761 * z90crypt_release
801 * z90crypt_read 762 * z90crypt_read
802 * z90crypt_write 763 * z90crypt_write
803 * z90crypt_ioctl 764 * z90crypt_unlocked_ioctl
804 * z90crypt_status 765 * z90crypt_status
805 * z90crypt_status_write 766 * z90crypt_status_write
806 * disable_card 767 * disable_card
@@ -1804,9 +1765,8 @@ z90crypt_rsa(struct priv_data *private_data_p, pid_t pid,
1804 * This function is a little long, but it's really just one large switch 1765 * This function is a little long, but it's really just one large switch
1805 * statement. 1766 * statement.
1806 */ 1767 */
1807static int 1768static long
1808z90crypt_ioctl(struct inode *inode, struct file *filp, 1769z90crypt_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
1809 unsigned int cmd, unsigned long arg)
1810{ 1770{
1811 struct priv_data *private_data_p = filp->private_data; 1771 struct priv_data *private_data_p = filp->private_data;
1812 unsigned char *status; 1772 unsigned char *status;
diff --git a/drivers/s390/net/smsgiucv.c b/drivers/s390/net/smsgiucv.c
index a3d285859564..1e3f7f3c662f 100644
--- a/drivers/s390/net/smsgiucv.c
+++ b/drivers/s390/net/smsgiucv.c
@@ -32,7 +32,7 @@ struct smsg_callback {
32 struct list_head list; 32 struct list_head list;
33 char *prefix; 33 char *prefix;
34 int len; 34 int len;
35 void (*callback)(char *str); 35 void (*callback)(char *from, char *str);
36}; 36};
37 37
38MODULE_AUTHOR 38MODULE_AUTHOR
@@ -55,8 +55,9 @@ smsg_message_pending(iucv_MessagePending *eib, void *pgm_data)
55{ 55{
56 struct smsg_callback *cb; 56 struct smsg_callback *cb;
57 unsigned char *msg; 57 unsigned char *msg;
58 unsigned char sender[9];
58 unsigned short len; 59 unsigned short len;
59 int rc; 60 int rc, i;
60 61
61 len = eib->ln1msg2.ipbfln1f; 62 len = eib->ln1msg2.ipbfln1f;
62 msg = kmalloc(len + 1, GFP_ATOMIC|GFP_DMA); 63 msg = kmalloc(len + 1, GFP_ATOMIC|GFP_DMA);
@@ -69,10 +70,18 @@ smsg_message_pending(iucv_MessagePending *eib, void *pgm_data)
69 if (rc == 0) { 70 if (rc == 0) {
70 msg[len] = 0; 71 msg[len] = 0;
71 EBCASC(msg, len); 72 EBCASC(msg, len);
73 memcpy(sender, msg, 8);
74 sender[8] = 0;
75 /* Remove trailing whitespace from the sender name. */
76 for (i = 7; i >= 0; i--) {
77 if (sender[i] != ' ' && sender[i] != '\t')
78 break;
79 sender[i] = 0;
80 }
72 spin_lock(&smsg_list_lock); 81 spin_lock(&smsg_list_lock);
73 list_for_each_entry(cb, &smsg_list, list) 82 list_for_each_entry(cb, &smsg_list, list)
74 if (strncmp(msg + 8, cb->prefix, cb->len) == 0) { 83 if (strncmp(msg + 8, cb->prefix, cb->len) == 0) {
75 cb->callback(msg + 8); 84 cb->callback(sender, msg + 8);
76 break; 85 break;
77 } 86 }
78 spin_unlock(&smsg_list_lock); 87 spin_unlock(&smsg_list_lock);
@@ -91,7 +100,7 @@ static struct device_driver smsg_driver = {
91}; 100};
92 101
93int 102int
94smsg_register_callback(char *prefix, void (*callback)(char *str)) 103smsg_register_callback(char *prefix, void (*callback)(char *from, char *str))
95{ 104{
96 struct smsg_callback *cb; 105 struct smsg_callback *cb;
97 106
@@ -108,7 +117,7 @@ smsg_register_callback(char *prefix, void (*callback)(char *str))
108} 117}
109 118
110void 119void
111smsg_unregister_callback(char *prefix, void (*callback)(char *str)) 120smsg_unregister_callback(char *prefix, void (*callback)(char *from, char *str))
112{ 121{
113 struct smsg_callback *cb, *tmp; 122 struct smsg_callback *cb, *tmp;
114 123
diff --git a/drivers/s390/net/smsgiucv.h b/drivers/s390/net/smsgiucv.h
index 04cd87152964..67f5d4f8378d 100644
--- a/drivers/s390/net/smsgiucv.h
+++ b/drivers/s390/net/smsgiucv.h
@@ -5,6 +5,6 @@
5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 5 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
6 */ 6 */
7 7
8int smsg_register_callback(char *, void (*)(char *)); 8int smsg_register_callback(char *, void (*)(char *, char *));
9void smsg_unregister_callback(char *, void (*)(char *)); 9void smsg_unregister_callback(char *, void (*)(char *, char *));
10 10
diff --git a/drivers/sbus/char/rtc.c b/drivers/sbus/char/rtc.c
index bf3273eb1c8b..9b988baf0b51 100644
--- a/drivers/sbus/char/rtc.c
+++ b/drivers/sbus/char/rtc.c
@@ -28,10 +28,46 @@
28 28
29static int rtc_busy = 0; 29static int rtc_busy = 0;
30 30
31/* This is the structure layout used by drivers/char/rtc.c, we
32 * support that driver's ioctls so that things are less messy in
33 * userspace.
34 */
35struct rtc_time_generic {
36 int tm_sec;
37 int tm_min;
38 int tm_hour;
39 int tm_mday;
40 int tm_mon;
41 int tm_year;
42 int tm_wday;
43 int tm_yday;
44 int tm_isdst;
45};
46#define RTC_AIE_ON _IO('p', 0x01) /* Alarm int. enable on */
47#define RTC_AIE_OFF _IO('p', 0x02) /* ... off */
48#define RTC_UIE_ON _IO('p', 0x03) /* Update int. enable on */
49#define RTC_UIE_OFF _IO('p', 0x04) /* ... off */
50#define RTC_PIE_ON _IO('p', 0x05) /* Periodic int. enable on */
51#define RTC_PIE_OFF _IO('p', 0x06) /* ... off */
52#define RTC_WIE_ON _IO('p', 0x0f) /* Watchdog int. enable on */
53#define RTC_WIE_OFF _IO('p', 0x10) /* ... off */
54#define RTC_RD_TIME _IOR('p', 0x09, struct rtc_time_generic) /* Read RTC time */
55#define RTC_SET_TIME _IOW('p', 0x0a, struct rtc_time_generic) /* Set RTC time */
56#define RTC_ALM_SET _IOW('p', 0x07, struct rtc_time) /* Set alarm time */
57#define RTC_ALM_READ _IOR('p', 0x08, struct rtc_time) /* Read alarm time */
58#define RTC_IRQP_READ _IOR('p', 0x0b, unsigned long) /* Read IRQ rate */
59#define RTC_IRQP_SET _IOW('p', 0x0c, unsigned long) /* Set IRQ rate */
60#define RTC_EPOCH_READ _IOR('p', 0x0d, unsigned long) /* Read epoch */
61#define RTC_EPOCH_SET _IOW('p', 0x0e, unsigned long) /* Set epoch */
62#define RTC_WKALM_SET _IOW('p', 0x0f, struct rtc_wkalrm)/* Set wakeup alarm*/
63#define RTC_WKALM_RD _IOR('p', 0x10, struct rtc_wkalrm)/* Get wakeup alarm*/
64#define RTC_PLL_GET _IOR('p', 0x11, struct rtc_pll_info) /* Get PLL correction */
65#define RTC_PLL_SET _IOW('p', 0x12, struct rtc_pll_info) /* Set PLL correction */
66
31/* Retrieve the current date and time from the real time clock. */ 67/* Retrieve the current date and time from the real time clock. */
32static void get_rtc_time(struct rtc_time *t) 68static void get_rtc_time(struct rtc_time *t)
33{ 69{
34 void * __iomem regs = mstk48t02_regs; 70 void __iomem *regs = mstk48t02_regs;
35 u8 tmp; 71 u8 tmp;
36 72
37 spin_lock_irq(&mostek_lock); 73 spin_lock_irq(&mostek_lock);
@@ -58,7 +94,7 @@ static void get_rtc_time(struct rtc_time *t)
58/* Set the current date and time inthe real time clock. */ 94/* Set the current date and time inthe real time clock. */
59void set_rtc_time(struct rtc_time *t) 95void set_rtc_time(struct rtc_time *t)
60{ 96{
61 void * __iomem regs = mstk48t02_regs; 97 void __iomem *regs = mstk48t02_regs;
62 u8 tmp; 98 u8 tmp;
63 99
64 spin_lock_irq(&mostek_lock); 100 spin_lock_irq(&mostek_lock);
@@ -82,29 +118,87 @@ void set_rtc_time(struct rtc_time *t)
82 spin_unlock_irq(&mostek_lock); 118 spin_unlock_irq(&mostek_lock);
83} 119}
84 120
121static int put_rtc_time_generic(void __user *argp, struct rtc_time *tm)
122{
123 struct rtc_time_generic __user *utm = argp;
124
125 if (__put_user(tm->sec, &utm->tm_sec) ||
126 __put_user(tm->min, &utm->tm_min) ||
127 __put_user(tm->hour, &utm->tm_hour) ||
128 __put_user(tm->dom, &utm->tm_mday) ||
129 __put_user(tm->month, &utm->tm_mon) ||
130 __put_user(tm->year, &utm->tm_year) ||
131 __put_user(tm->dow, &utm->tm_wday) ||
132 __put_user(0, &utm->tm_yday) ||
133 __put_user(0, &utm->tm_isdst))
134 return -EFAULT;
135
136 return 0;
137}
138
139static int get_rtc_time_generic(struct rtc_time *tm, void __user *argp)
140{
141 struct rtc_time_generic __user *utm = argp;
142
143 if (__get_user(tm->sec, &utm->tm_sec) ||
144 __get_user(tm->min, &utm->tm_min) ||
145 __get_user(tm->hour, &utm->tm_hour) ||
146 __get_user(tm->dom, &utm->tm_mday) ||
147 __get_user(tm->month, &utm->tm_mon) ||
148 __get_user(tm->year, &utm->tm_year) ||
149 __get_user(tm->dow, &utm->tm_wday))
150 return -EFAULT;
151
152 return 0;
153}
154
85static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 155static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
86 unsigned long arg) 156 unsigned long arg)
87{ 157{
88 struct rtc_time rtc_tm; 158 struct rtc_time rtc_tm;
89 void __user *argp = (void __user *)arg; 159 void __user *argp = (void __user *)arg;
90 160
91 switch (cmd) 161 switch (cmd) {
92 { 162 /* No interrupt support, return an error
163 * compatible with drivers/char/rtc.c
164 */
165 case RTC_AIE_OFF:
166 case RTC_AIE_ON:
167 case RTC_PIE_OFF:
168 case RTC_PIE_ON:
169 case RTC_UIE_OFF:
170 case RTC_UIE_ON:
171 case RTC_IRQP_READ:
172 case RTC_IRQP_SET:
173 case RTC_EPOCH_SET:
174 case RTC_EPOCH_READ:
175 return -EINVAL;
176
93 case RTCGET: 177 case RTCGET:
178 case RTC_RD_TIME:
94 memset(&rtc_tm, 0, sizeof(struct rtc_time)); 179 memset(&rtc_tm, 0, sizeof(struct rtc_time));
95 get_rtc_time(&rtc_tm); 180 get_rtc_time(&rtc_tm);
96 181
97 if (copy_to_user(argp, &rtc_tm, sizeof(struct rtc_time))) 182 if (cmd == RTCGET) {
183 if (copy_to_user(argp, &rtc_tm,
184 sizeof(struct rtc_time)))
185 return -EFAULT;
186 } else if (put_rtc_time_generic(argp, &rtc_tm))
98 return -EFAULT; 187 return -EFAULT;
99 188
100 return 0; 189 return 0;
101 190
102 191
103 case RTCSET: 192 case RTCSET:
193 case RTC_SET_TIME:
104 if (!capable(CAP_SYS_TIME)) 194 if (!capable(CAP_SYS_TIME))
105 return -EPERM; 195 return -EPERM;
106 196
107 if (copy_from_user(&rtc_tm, argp, sizeof(struct rtc_time))) 197 if (cmd == RTCSET) {
198 if (copy_from_user(&rtc_tm, argp,
199 sizeof(struct rtc_time)))
200 return -EFAULT;
201 } else if (get_rtc_time_generic(&rtc_tm, argp))
108 return -EFAULT; 202 return -EFAULT;
109 203
110 set_rtc_time(&rtc_tm); 204 set_rtc_time(&rtc_tm);
@@ -156,7 +250,7 @@ static int __init rtc_sun_init(void)
156 /* It is possible we are being driven by some other RTC chip 250 /* It is possible we are being driven by some other RTC chip
157 * and thus another RTC driver is handling things. 251 * and thus another RTC driver is handling things.
158 */ 252 */
159 if (mstk48t02_regs == 0) 253 if (!mstk48t02_regs)
160 return -ENODEV; 254 return -ENODEV;
161 255
162 error = misc_register(&rtc_dev); 256 error = misc_register(&rtc_dev);
@@ -164,6 +258,7 @@ static int __init rtc_sun_init(void)
164 printk(KERN_ERR "rtc: unable to get misc minor for Mostek\n"); 258 printk(KERN_ERR "rtc: unable to get misc minor for Mostek\n");
165 return error; 259 return error;
166 } 260 }
261 printk("rtc_sun_init: Registered Mostek RTC driver.\n");
167 262
168 return 0; 263 return 0;
169} 264}
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index ba88be399a59..88e34095ca4e 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -278,7 +278,7 @@ config SCSI_3W_9XXX
278 278
279config SCSI_7000FASST 279config SCSI_7000FASST
280 tristate "7000FASST SCSI support" 280 tristate "7000FASST SCSI support"
281 depends on ISA && SCSI 281 depends on ISA && SCSI && ISA_DMA_API
282 help 282 help
283 This driver supports the Western Digital 7000 SCSI host adapter 283 This driver supports the Western Digital 7000 SCSI host adapter
284 family. Some information is in the source: 284 family. Some information is in the source:
@@ -313,7 +313,7 @@ config SCSI_AHA152X
313 313
314config SCSI_AHA1542 314config SCSI_AHA1542
315 tristate "Adaptec AHA1542 support" 315 tristate "Adaptec AHA1542 support"
316 depends on ISA && SCSI 316 depends on ISA && SCSI && ISA_DMA_API
317 ---help--- 317 ---help---
318 This is support for a SCSI host adapter. It is explained in section 318 This is support for a SCSI host adapter. It is explained in section
319 3.4 of the SCSI-HOWTO, available from 319 3.4 of the SCSI-HOWTO, available from
@@ -533,7 +533,7 @@ config SCSI_SATA_VITESSE
533 533
534config SCSI_BUSLOGIC 534config SCSI_BUSLOGIC
535 tristate "BusLogic SCSI support" 535 tristate "BusLogic SCSI support"
536 depends on (PCI || ISA || MCA) && SCSI && (BROKEN || !SPARC64) 536 depends on (PCI || ISA || MCA) && SCSI && ISA_DMA_API
537 ---help--- 537 ---help---
538 This is support for BusLogic MultiMaster and FlashPoint SCSI Host 538 This is support for BusLogic MultiMaster and FlashPoint SCSI Host
539 Adapters. Consult the SCSI-HOWTO, available from 539 Adapters. Consult the SCSI-HOWTO, available from
@@ -589,7 +589,7 @@ config SCSI_DTC3280
589 589
590config SCSI_EATA 590config SCSI_EATA
591 tristate "EATA ISA/EISA/PCI (DPT and generic EATA/DMA-compliant boards) support" 591 tristate "EATA ISA/EISA/PCI (DPT and generic EATA/DMA-compliant boards) support"
592 depends on (ISA || EISA || PCI) && SCSI && (BROKEN || !SPARC64) 592 depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
593 ---help--- 593 ---help---
594 This driver supports all EATA/DMA-compliant SCSI host adapters. DPT 594 This driver supports all EATA/DMA-compliant SCSI host adapters. DPT
595 ISA and all EISA I/O addresses are probed looking for the "EATA" 595 ISA and all EISA I/O addresses are probed looking for the "EATA"
@@ -683,7 +683,7 @@ config SCSI_FD_MCS
683 683
684config SCSI_GDTH 684config SCSI_GDTH
685 tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support" 685 tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support"
686 depends on (ISA || EISA || PCI) && SCSI && (BROKEN || !SPARC64) 686 depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
687 ---help--- 687 ---help---
688 Formerly called GDT SCSI Disk Array Controller Support. 688 Formerly called GDT SCSI Disk Array Controller Support.
689 689
@@ -1412,7 +1412,7 @@ config SCSI_T128
1412 1412
1413config SCSI_U14_34F 1413config SCSI_U14_34F
1414 tristate "UltraStor 14F/34F support" 1414 tristate "UltraStor 14F/34F support"
1415 depends on ISA && SCSI 1415 depends on ISA && SCSI && ISA_DMA_API
1416 ---help--- 1416 ---help---
1417 This is support for the UltraStor 14F and 34F SCSI-2 host adapters. 1417 This is support for the UltraStor 14F and 34F SCSI-2 host adapters.
1418 The source at <file:drivers/scsi/u14-34f.c> contains some 1418 The source at <file:drivers/scsi/u14-34f.c> contains some
diff --git a/drivers/scsi/NCR53C9x.c b/drivers/scsi/NCR53C9x.c
index 74293f62a622..064781a2cb1a 100644
--- a/drivers/scsi/NCR53C9x.c
+++ b/drivers/scsi/NCR53C9x.c
@@ -1824,7 +1824,10 @@ static int esp_do_data(struct NCR_ESP *esp, struct ESP_regs *eregs)
1824 /* loop */ 1824 /* loop */
1825 while (hmuch) { 1825 while (hmuch) {
1826 int j, fifo_stuck = 0, newphase; 1826 int j, fifo_stuck = 0, newphase;
1827 unsigned long flags, timeout; 1827 unsigned long timeout;
1828#if 0
1829 unsigned long flags;
1830#endif
1828#if 0 1831#if 0
1829 if ( i % 10 ) 1832 if ( i % 10 )
1830 ESPDATA(("\r")); 1833 ESPDATA(("\r"));
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 7e9e6b3186ae..5fd8f3ee9804 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -450,7 +450,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file)
450 } 450 }
451 } 451 }
452 452
453 return 0; 453 return err;
454} 454}
455 455
456/** 456/**
diff --git a/drivers/scsi/esp.c b/drivers/scsi/esp.c
index d8ab73b68031..f6900538be90 100644
--- a/drivers/scsi/esp.c
+++ b/drivers/scsi/esp.c
@@ -49,6 +49,8 @@
49#include <scsi/scsi_host.h> 49#include <scsi/scsi_host.h>
50#include <scsi/scsi_tcq.h> 50#include <scsi/scsi_tcq.h>
51 51
52#define DRV_VERSION "1.101"
53
52#define DEBUG_ESP 54#define DEBUG_ESP
53/* #define DEBUG_ESP_HME */ 55/* #define DEBUG_ESP_HME */
54/* #define DEBUG_ESP_DATA */ 56/* #define DEBUG_ESP_DATA */
@@ -1145,7 +1147,7 @@ static int __init esp_detect(struct scsi_host_template *tpnt)
1145 static struct sbus_dev esp_dev; 1147 static struct sbus_dev esp_dev;
1146 int esps_in_use = 0; 1148 int esps_in_use = 0;
1147 1149
1148 espchain = 0; 1150 espchain = NULL;
1149 1151
1150 if (sun4_esp_physaddr) { 1152 if (sun4_esp_physaddr) {
1151 memset (&esp_dev, 0, sizeof(esp_dev)); 1153 memset (&esp_dev, 0, sizeof(esp_dev));
@@ -2511,7 +2513,7 @@ static inline void esp_reconnect(struct esp *esp, struct scsi_cmnd *sp)
2511 ESPLOG(("esp%d: Weird, being reselected but disconnected " 2513 ESPLOG(("esp%d: Weird, being reselected but disconnected "
2512 "command queue is empty.\n", esp->esp_id)); 2514 "command queue is empty.\n", esp->esp_id));
2513 esp->snip = 0; 2515 esp->snip = 0;
2514 esp->current_SC = 0; 2516 esp->current_SC = NULL;
2515 sp->SCp.phase = not_issued; 2517 sp->SCp.phase = not_issued;
2516 append_SC(&esp->issue_SC, sp); 2518 append_SC(&esp->issue_SC, sp);
2517} 2519}
@@ -4146,7 +4148,7 @@ static int esp_work_bus(struct esp *esp)
4146} 4148}
4147 4149
4148static espfunc_t isvc_vector[] = { 4150static espfunc_t isvc_vector[] = {
4149 0, 4151 NULL,
4150 esp_do_phase_determine, 4152 esp_do_phase_determine,
4151 esp_do_resetbus, 4153 esp_do_resetbus,
4152 esp_finish_reset, 4154 esp_finish_reset,
@@ -4398,5 +4400,8 @@ static struct scsi_host_template driver_template = {
4398 4400
4399#include "scsi_module.c" 4401#include "scsi_module.c"
4400 4402
4403MODULE_DESCRIPTION("EnhancedScsiProcessor Sun SCSI driver");
4404MODULE_AUTHOR("David S. Miller (davem@redhat.com)");
4401MODULE_LICENSE("GPL"); 4405MODULE_LICENSE("GPL");
4406MODULE_VERSION(DRV_VERSION);
4402 4407
diff --git a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c
index e70dedb0d0a5..7976947c0322 100644
--- a/drivers/scsi/pas16.c
+++ b/drivers/scsi/pas16.c
@@ -137,7 +137,7 @@ static unsigned short pas16_addr = 0;
137static int pas16_irq = 0; 137static int pas16_irq = 0;
138 138
139 139
140int scsi_irq_translate[] = 140static const int scsi_irq_translate[] =
141 { 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 7, 8, 9, 0, 10, 11 }; 141 { 0, 0, 1, 2, 3, 4, 5, 6, 0, 0, 7, 8, 9, 0, 10, 11 };
142 142
143/* The default_irqs array contains values used to set the irq into the 143/* The default_irqs array contains values used to set the irq into the
@@ -145,7 +145,7 @@ int scsi_irq_translate[] =
145 * irq jumpers on the board). The first value in the array will be 145 * irq jumpers on the board). The first value in the array will be
146 * assigned to logical board 0, the next to board 1, etc. 146 * assigned to logical board 0, the next to board 1, etc.
147 */ 147 */
148int default_irqs[] __initdata = 148static int default_irqs[] __initdata =
149 { PAS16_DEFAULT_BOARD_1_IRQ, 149 { PAS16_DEFAULT_BOARD_1_IRQ,
150 PAS16_DEFAULT_BOARD_2_IRQ, 150 PAS16_DEFAULT_BOARD_2_IRQ,
151 PAS16_DEFAULT_BOARD_3_IRQ, 151 PAS16_DEFAULT_BOARD_3_IRQ,
@@ -177,7 +177,7 @@ static struct base {
177 177
178#define NO_BASES (sizeof (bases) / sizeof (struct base)) 178#define NO_BASES (sizeof (bases) / sizeof (struct base))
179 179
180unsigned short pas16_offset[ 8 ] = 180static const unsigned short pas16_offset[ 8 ] =
181 { 181 {
182 0x1c00, /* OUTPUT_DATA_REG */ 182 0x1c00, /* OUTPUT_DATA_REG */
183 0x1c01, /* INITIATOR_COMMAND_REG */ 183 0x1c01, /* INITIATOR_COMMAND_REG */
diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c
index 7bb0a2e56743..c01b7191fcf5 100644
--- a/drivers/scsi/pluto.c
+++ b/drivers/scsi/pluto.c
@@ -45,7 +45,7 @@ static struct ctrl_inquiry {
45 Scsi_Cmnd cmd; 45 Scsi_Cmnd cmd;
46 char inquiry[256]; 46 char inquiry[256];
47 fc_channel *fc; 47 fc_channel *fc;
48} *fcs __initdata = { 0 }; 48} *fcs __initdata;
49static int fcscount __initdata = 0; 49static int fcscount __initdata = 0;
50static atomic_t fcss __initdata = ATOMIC_INIT(0); 50static atomic_t fcss __initdata = ATOMIC_INIT(0);
51DECLARE_MUTEX_LOCKED(fc_sem); 51DECLARE_MUTEX_LOCKED(fc_sem);
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 0d730f646bce..5578ae9a9e45 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -542,7 +542,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
542 * that the device is no longer present */ 542 * that the device is no longer present */
543 cmd->result = DID_NO_CONNECT << 16; 543 cmd->result = DID_NO_CONNECT << 16;
544 atomic_inc(&cmd->device->iorequest_cnt); 544 atomic_inc(&cmd->device->iorequest_cnt);
545 scsi_done(cmd); 545 __scsi_done(cmd);
546 /* return 0 (because the command has been processed) */ 546 /* return 0 (because the command has been processed) */
547 goto out; 547 goto out;
548 } 548 }
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 103558574662..cb789c35262c 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -582,7 +582,7 @@ static int scsi_request_sense(struct scsi_cmnd *scmd)
582 582
583 memcpy(scmd->cmnd, generic_sense, sizeof(generic_sense)); 583 memcpy(scmd->cmnd, generic_sense, sizeof(generic_sense));
584 584
585 scsi_result = kmalloc(252, GFP_ATOMIC | (scmd->device->host->hostt->unchecked_isa_dma) ? __GFP_DMA : 0); 585 scsi_result = kmalloc(252, GFP_ATOMIC | ((scmd->device->host->hostt->unchecked_isa_dma) ? __GFP_DMA : 0));
586 586
587 587
588 if (unlikely(!scsi_result)) { 588 if (unlikely(!scsi_result)) {
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 287d197a7c17..cca772624ae7 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -801,7 +801,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
801 if (!sreq) 801 if (!sreq)
802 goto out_free_sdev; 802 goto out_free_sdev;
803 result = kmalloc(256, GFP_ATOMIC | 803 result = kmalloc(256, GFP_ATOMIC |
804 (shost->unchecked_isa_dma) ? __GFP_DMA : 0); 804 ((shost->unchecked_isa_dma) ? __GFP_DMA : 0));
805 if (!result) 805 if (!result)
806 goto out_free_sreq; 806 goto out_free_sreq;
807 807
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 303d7656f710..28966d05435c 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -22,6 +22,7 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/workqueue.h> 24#include <linux/workqueue.h>
25#include <linux/blkdev.h>
25#include <asm/semaphore.h> 26#include <asm/semaphore.h>
26#include <scsi/scsi.h> 27#include <scsi/scsi.h>
27#include "scsi_priv.h" 28#include "scsi_priv.h"
@@ -41,6 +42,11 @@
41 42
42#define SPI_MAX_ECHO_BUFFER_SIZE 4096 43#define SPI_MAX_ECHO_BUFFER_SIZE 4096
43 44
45#define DV_LOOPS 3
46#define DV_TIMEOUT (10*HZ)
47#define DV_RETRIES 3 /* should only need at most
48 * two cc/ua clears */
49
44/* Private data accessors (keep these out of the header file) */ 50/* Private data accessors (keep these out of the header file) */
45#define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending) 51#define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending)
46#define spi_dv_sem(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_sem) 52#define spi_dv_sem(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_sem)
@@ -100,6 +106,29 @@ static int sprint_frac(char *dest, int value, int denom)
100 return result; 106 return result;
101} 107}
102 108
109/* Modification of scsi_wait_req that will clear UNIT ATTENTION conditions
110 * resulting from (likely) bus and device resets */
111static void spi_wait_req(struct scsi_request *sreq, const void *cmd,
112 void *buffer, unsigned bufflen)
113{
114 int i;
115
116 for(i = 0; i < DV_RETRIES; i++) {
117 sreq->sr_request->flags |= REQ_FAILFAST;
118
119 scsi_wait_req(sreq, cmd, buffer, bufflen,
120 DV_TIMEOUT, /* retries */ 1);
121 if (sreq->sr_result & DRIVER_SENSE) {
122 struct scsi_sense_hdr sshdr;
123
124 if (scsi_request_normalize_sense(sreq, &sshdr)
125 && sshdr.sense_key == UNIT_ATTENTION)
126 continue;
127 }
128 break;
129 }
130}
131
103static struct { 132static struct {
104 enum spi_signal_type value; 133 enum spi_signal_type value;
105 char *name; 134 char *name;
@@ -378,11 +407,6 @@ static CLASS_DEVICE_ATTR(signalling, S_IRUGO | S_IWUSR,
378 if(i->f->set_##x) \ 407 if(i->f->set_##x) \
379 i->f->set_##x(sdev->sdev_target, y) 408 i->f->set_##x(sdev->sdev_target, y)
380 409
381#define DV_LOOPS 3
382#define DV_TIMEOUT (10*HZ)
383#define DV_RETRIES 3 /* should only need at most
384 * two cc/ua clears */
385
386enum spi_compare_returns { 410enum spi_compare_returns {
387 SPI_COMPARE_SUCCESS, 411 SPI_COMPARE_SUCCESS,
388 SPI_COMPARE_FAILURE, 412 SPI_COMPARE_FAILURE,
@@ -446,8 +470,7 @@ spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer,
446 for (r = 0; r < retries; r++) { 470 for (r = 0; r < retries; r++) {
447 sreq->sr_cmd_len = 0; /* wait_req to fill in */ 471 sreq->sr_cmd_len = 0; /* wait_req to fill in */
448 sreq->sr_data_direction = DMA_TO_DEVICE; 472 sreq->sr_data_direction = DMA_TO_DEVICE;
449 scsi_wait_req(sreq, spi_write_buffer, buffer, len, 473 spi_wait_req(sreq, spi_write_buffer, buffer, len);
450 DV_TIMEOUT, DV_RETRIES);
451 if(sreq->sr_result || !scsi_device_online(sdev)) { 474 if(sreq->sr_result || !scsi_device_online(sdev)) {
452 struct scsi_sense_hdr sshdr; 475 struct scsi_sense_hdr sshdr;
453 476
@@ -471,8 +494,7 @@ spi_dv_device_echo_buffer(struct scsi_request *sreq, u8 *buffer,
471 memset(ptr, 0, len); 494 memset(ptr, 0, len);
472 sreq->sr_cmd_len = 0; /* wait_req to fill in */ 495 sreq->sr_cmd_len = 0; /* wait_req to fill in */
473 sreq->sr_data_direction = DMA_FROM_DEVICE; 496 sreq->sr_data_direction = DMA_FROM_DEVICE;
474 scsi_wait_req(sreq, spi_read_buffer, ptr, len, 497 spi_wait_req(sreq, spi_read_buffer, ptr, len);
475 DV_TIMEOUT, DV_RETRIES);
476 scsi_device_set_state(sdev, SDEV_QUIESCE); 498 scsi_device_set_state(sdev, SDEV_QUIESCE);
477 499
478 if (memcmp(buffer, ptr, len) != 0) 500 if (memcmp(buffer, ptr, len) != 0)
@@ -500,8 +522,7 @@ spi_dv_device_compare_inquiry(struct scsi_request *sreq, u8 *buffer,
500 522
501 memset(ptr, 0, len); 523 memset(ptr, 0, len);
502 524
503 scsi_wait_req(sreq, spi_inquiry, ptr, len, 525 spi_wait_req(sreq, spi_inquiry, ptr, len);
504 DV_TIMEOUT, DV_RETRIES);
505 526
506 if(sreq->sr_result || !scsi_device_online(sdev)) { 527 if(sreq->sr_result || !scsi_device_online(sdev)) {
507 scsi_device_set_state(sdev, SDEV_QUIESCE); 528 scsi_device_set_state(sdev, SDEV_QUIESCE);
@@ -593,8 +614,7 @@ spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer)
593 * (reservation conflict, device not ready, etc) just 614 * (reservation conflict, device not ready, etc) just
594 * skip the write tests */ 615 * skip the write tests */
595 for (l = 0; ; l++) { 616 for (l = 0; ; l++) {
596 scsi_wait_req(sreq, spi_test_unit_ready, NULL, 0, 617 spi_wait_req(sreq, spi_test_unit_ready, NULL, 0);
597 DV_TIMEOUT, DV_RETRIES);
598 618
599 if(sreq->sr_result) { 619 if(sreq->sr_result) {
600 if(l >= 3) 620 if(l >= 3)
@@ -608,8 +628,7 @@ spi_dv_device_get_echo_buffer(struct scsi_request *sreq, u8 *buffer)
608 sreq->sr_cmd_len = 0; 628 sreq->sr_cmd_len = 0;
609 sreq->sr_data_direction = DMA_FROM_DEVICE; 629 sreq->sr_data_direction = DMA_FROM_DEVICE;
610 630
611 scsi_wait_req(sreq, spi_read_buffer_descriptor, buffer, 4, 631 spi_wait_req(sreq, spi_read_buffer_descriptor, buffer, 4);
612 DV_TIMEOUT, DV_RETRIES);
613 632
614 if (sreq->sr_result) 633 if (sreq->sr_result)
615 /* Device has no echo buffer */ 634 /* Device has no echo buffer */
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 5ff83d214f12..5b07c6ec3ecc 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -2038,8 +2038,9 @@ static void sym2_set_period(struct scsi_target *starget, int period)
2038 struct sym_hcb *np = sym_get_hcb(shost); 2038 struct sym_hcb *np = sym_get_hcb(shost);
2039 struct sym_tcb *tp = &np->target[starget->id]; 2039 struct sym_tcb *tp = &np->target[starget->id];
2040 2040
2041 /* have to have DT for these transfers */ 2041 /* have to have DT for these transfers, but DT will also
2042 if (period <= np->minsync) 2042 * set width, so check that this is allowed */
2043 if (period <= np->minsync && spi_width(starget))
2043 tp->tgoal.dt = 1; 2044 tp->tgoal.dt = 1;
2044 2045
2045 tp->tgoal.period = period; 2046 tp->tgoal.period = period;
diff --git a/drivers/serial/21285.c b/drivers/serial/21285.c
index f8504b0adebc..33fbda79f350 100644
--- a/drivers/serial/21285.c
+++ b/drivers/serial/21285.c
@@ -110,7 +110,7 @@ static irqreturn_t serial21285_rx_chars(int irq, void *dev_id, struct pt_regs *r
110 port->icount.rx++; 110 port->icount.rx++;
111 111
112 rxs = *CSR_RXSTAT | RXSTAT_DUMMY_READ; 112 rxs = *CSR_RXSTAT | RXSTAT_DUMMY_READ;
113 if (rxs & RXSTAT_ANYERR) { 113 if (unlikely(rxs & RXSTAT_ANYERR)) {
114 if (rxs & RXSTAT_PARITY) 114 if (rxs & RXSTAT_PARITY)
115 port->icount.parity++; 115 port->icount.parity++;
116 else if (rxs & RXSTAT_FRAME) 116 else if (rxs & RXSTAT_FRAME)
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 218b69372c0b..0d9358608fdf 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -51,7 +51,7 @@
51 * share_irqs - whether we pass SA_SHIRQ to request_irq(). This option 51 * share_irqs - whether we pass SA_SHIRQ to request_irq(). This option
52 * is unsafe when used on edge-triggered interrupts. 52 * is unsafe when used on edge-triggered interrupts.
53 */ 53 */
54unsigned int share_irqs = SERIAL8250_SHARE_IRQS; 54static unsigned int share_irqs = SERIAL8250_SHARE_IRQS;
55 55
56/* 56/*
57 * Debugging. 57 * Debugging.
diff --git a/drivers/serial/8250_hp300.c b/drivers/serial/8250_hp300.c
index b8d51eb56bff..4315afe9c080 100644
--- a/drivers/serial/8250_hp300.c
+++ b/drivers/serial/8250_hp300.c
@@ -9,15 +9,15 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/string.h> 10#include <linux/string.h>
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/tty.h>
13#include <linux/serial.h> 12#include <linux/serial.h>
14#include <linux/serialP.h>
15#include <linux/serial_core.h> 13#include <linux/serial_core.h>
16#include <linux/delay.h> 14#include <linux/delay.h>
17#include <linux/dio.h> 15#include <linux/dio.h>
18#include <linux/console.h> 16#include <linux/console.h>
19#include <asm/io.h> 17#include <asm/io.h>
20 18
19#include "8250.h"
20
21#if !defined(CONFIG_HPDCA) && !defined(CONFIG_HPAPCI) 21#if !defined(CONFIG_HPDCA) && !defined(CONFIG_HPAPCI)
22#warning CONFIG_8250 defined but neither CONFIG_HPDCA nor CONFIG_HPAPCI defined, are you sure? 22#warning CONFIG_8250 defined but neither CONFIG_HPDCA nor CONFIG_HPAPCI defined, are you sure?
23#endif 23#endif
@@ -163,7 +163,7 @@ int __init hp300_setup_serial_console(void)
163static int __devinit hpdca_init_one(struct dio_dev *d, 163static int __devinit hpdca_init_one(struct dio_dev *d,
164 const struct dio_device_id *ent) 164 const struct dio_device_id *ent)
165{ 165{
166 struct serial_struct serial_req; 166 struct uart_port port;
167 int line; 167 int line;
168 168
169#ifdef CONFIG_SERIAL_8250_CONSOLE 169#ifdef CONFIG_SERIAL_8250_CONSOLE
@@ -172,21 +172,22 @@ static int __devinit hpdca_init_one(struct dio_dev *d,
172 return 0; 172 return 0;
173 } 173 }
174#endif 174#endif
175 memset(&serial_req, 0, sizeof(struct serial_struct)); 175 memset(&port, 0, sizeof(struct uart_port));
176 176
177 /* Memory mapped I/O */ 177 /* Memory mapped I/O */
178 serial_req.io_type = SERIAL_IO_MEM; 178 port.iotype = UPIO_MEM;
179 serial_req.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF; 179 port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF;
180 serial_req.irq = d->ipl; 180 port.irq = d->ipl;
181 serial_req.baud_base = HPDCA_BAUD_BASE; 181 port.uartclk = HPDCA_BAUD_BASE * 16;
182 serial_req.iomap_base = (d->resource.start + UART_OFFSET); 182 port.mapbase = (d->resource.start + UART_OFFSET);
183 serial_req.iomem_base = (char *)(serial_req.iomap_base + DIO_VIRADDRBASE); 183 port.membase = (char *)(port.mapbase + DIO_VIRADDRBASE);
184 serial_req.iomem_reg_shift = 1; 184 port.regshift = 1;
185 line = register_serial(&serial_req); 185 port.dev = &d->dev;
186 line = serial8250_register_port(&port);
186 187
187 if (line < 0) { 188 if (line < 0) {
188 printk(KERN_NOTICE "8250_hp300: register_serial() DCA scode %d" 189 printk(KERN_NOTICE "8250_hp300: register_serial() DCA scode %d"
189 " irq %d failed\n", d->scode, serial_req.irq); 190 " irq %d failed\n", d->scode, port.irq);
190 return -ENOMEM; 191 return -ENOMEM;
191 } 192 }
192 193
@@ -209,7 +210,7 @@ static int __init hp300_8250_init(void)
209#ifdef CONFIG_HPAPCI 210#ifdef CONFIG_HPAPCI
210 int line; 211 int line;
211 unsigned long base; 212 unsigned long base;
212 struct serial_struct serial_req; 213 struct uart_port uport;
213 struct hp300_port *port; 214 struct hp300_port *port;
214 int i; 215 int i;
215#endif 216#endif
@@ -251,25 +252,25 @@ static int __init hp300_8250_init(void)
251 if (!port) 252 if (!port)
252 return -ENOMEM; 253 return -ENOMEM;
253 254
254 memset(&serial_req, 0, sizeof(struct serial_struct)); 255 memset(&uport, 0, sizeof(struct uart_port));
255 256
256 base = (FRODO_BASE + FRODO_APCI_OFFSET(i)); 257 base = (FRODO_BASE + FRODO_APCI_OFFSET(i));
257 258
258 /* Memory mapped I/O */ 259 /* Memory mapped I/O */
259 serial_req.io_type = SERIAL_IO_MEM; 260 uport.iotype = UPIO_MEM;
260 serial_req.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF; 261 uport.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF;
261 /* XXX - no interrupt support yet */ 262 /* XXX - no interrupt support yet */
262 serial_req.irq = 0; 263 uport.irq = 0;
263 serial_req.baud_base = HPAPCI_BAUD_BASE; 264 uport.uartclk = HPAPCI_BAUD_BASE * 16;
264 serial_req.iomap_base = base; 265 uport.mapbase = base;
265 serial_req.iomem_base = (char *)(serial_req.iomap_base + DIO_VIRADDRBASE); 266 uport.membase = (char *)(base + DIO_VIRADDRBASE);
266 serial_req.iomem_reg_shift = 2; 267 uport.regshift = 2;
267 268
268 line = register_serial(&serial_req); 269 line = serial8250_register_port(&uport);
269 270
270 if (line < 0) { 271 if (line < 0) {
271 printk(KERN_NOTICE "8250_hp300: register_serial() APCI %d" 272 printk(KERN_NOTICE "8250_hp300: register_serial() APCI %d"
272 " irq %d failed\n", i, serial_req.irq); 273 " irq %d failed\n", i, uport.irq);
273 kfree(port); 274 kfree(port);
274 continue; 275 continue;
275 } 276 }
@@ -299,7 +300,7 @@ static void __devexit hpdca_remove_one(struct dio_dev *d)
299 /* Disable board-interrupts */ 300 /* Disable board-interrupts */
300 out_8(d->resource.start + DIO_VIRADDRBASE + DCA_IC, 0); 301 out_8(d->resource.start + DIO_VIRADDRBASE + DCA_IC, 0);
301 } 302 }
302 unregister_serial(line); 303 serial8250_unregister_port(line);
303} 304}
304#endif 305#endif
305 306
@@ -309,7 +310,7 @@ static void __exit hp300_8250_exit(void)
309 struct hp300_port *port, *to_free; 310 struct hp300_port *port, *to_free;
310 311
311 for (port = hp300_ports; port; ) { 312 for (port = hp300_ports; port; ) {
312 unregister_serial(port->line); 313 serial8250_unregister_port(port->line);
313 to_free = port; 314 to_free = port;
314 port = port->next; 315 port = port->next;
315 kfree(to_free); 316 kfree(to_free);
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index f8d90d0ecfea..de54bdc5398b 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -1009,6 +1009,8 @@ get_pci_irq(struct pci_dev *dev, struct pci_board *board, int idx)
1009 * n = number of serial ports 1009 * n = number of serial ports
1010 * baud = baud rate 1010 * baud = baud rate
1011 * 1011 *
1012 * This table is sorted by (in order): baud, bt, bn, n.
1013 *
1012 * Please note: in theory if n = 1, _bt infix should make no difference. 1014 * Please note: in theory if n = 1, _bt infix should make no difference.
1013 * ie, pbn_b0_1_115200 is the same as pbn_b0_bt_1_115200 1015 * ie, pbn_b0_1_115200 is the same as pbn_b0_bt_1_115200
1014 */ 1016 */
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 484f6fb900b5..f2a5e2933c47 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -172,7 +172,7 @@ pl010_rx_chars(struct uart_port *port)
172 * out of the main execution path 172 * out of the main execution path
173 */ 173 */
174 rsr = UART_GET_RSR(port) | UART_DUMMY_RSR_RX; 174 rsr = UART_GET_RSR(port) | UART_DUMMY_RSR_RX;
175 if (rsr & UART01x_RSR_ANY) { 175 if (unlikely(rsr & UART01x_RSR_ANY)) {
176 if (rsr & UART01x_RSR_BE) { 176 if (rsr & UART01x_RSR_BE) {
177 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE); 177 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
178 port->icount.brk++; 178 port->icount.brk++;
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index ff658a830f34..d5cbef3fe8b6 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -137,7 +137,7 @@ pl011_rx_chars(struct uart_amba_port *uap)
137 * out of the main execution path 137 * out of the main execution path
138 */ 138 */
139 rsr = readw(uap->port.membase + UART01x_RSR) | UART_DUMMY_RSR_RX; 139 rsr = readw(uap->port.membase + UART01x_RSR) | UART_DUMMY_RSR_RX;
140 if (rsr & UART01x_RSR_ANY) { 140 if (unlikely(rsr & UART01x_RSR_ANY)) {
141 if (rsr & UART01x_RSR_BE) { 141 if (rsr & UART01x_RSR_BE) {
142 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE); 142 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
143 uap->port.icount.brk++; 143 uap->port.icount.brk++;
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
index 16592fae47f3..6242f3090a96 100644
--- a/drivers/serial/clps711x.c
+++ b/drivers/serial/clps711x.c
@@ -116,54 +116,43 @@ static irqreturn_t clps711xuart_int_rx(int irq, void *dev_id, struct pt_regs *re
116 * Note that the error handling code is 116 * Note that the error handling code is
117 * out of the main execution path 117 * out of the main execution path
118 */ 118 */
119 if (ch & UART_ANY_ERR) 119 if (unlikely(ch & UART_ANY_ERR)) {
120 goto handle_error; 120 if (ch & UARTDR_PARERR)
121 port->icount.parity++;
122 else if (ch & UARTDR_FRMERR)
123 port->icount.frame++;
124 if (ch & UARTDR_OVERR)
125 port->icount.overrun++;
121 126
122 if (uart_handle_sysrq_char(port, ch, regs)) 127 ch &= port->read_status_mask;
123 goto ignore_char;
124 128
125 error_return: 129 if (ch & UARTDR_PARERR)
126 tty_insert_flip_char(tty, ch, flg); 130 flg = TTY_PARITY;
127 ignore_char: 131 else if (ch & UARTDR_FRMERR)
128 status = clps_readl(SYSFLG(port)); 132 flg = TTY_FRAME;
129 }
130 out:
131 tty_flip_buffer_push(tty);
132 return IRQ_HANDLED;
133 133
134 handle_error: 134#ifdef SUPPORT_SYSRQ
135 if (ch & UARTDR_PARERR) 135 port->sysrq = 0;
136 port->icount.parity++; 136#endif
137 else if (ch & UARTDR_FRMERR) 137 }
138 port->icount.frame++;
139 if (ch & UARTDR_OVERR)
140 port->icount.overrun++;
141
142 if (ch & port->ignore_status_mask) {
143 if (++ignored > 100)
144 goto out;
145 goto ignore_char;
146 }
147 ch &= port->read_status_mask;
148 138
149 if (ch & UARTDR_PARERR) 139 if (uart_handle_sysrq_char(port, ch, regs))
150 flg = TTY_PARITY; 140 goto ignore_char;
151 else if (ch & UARTDR_FRMERR)
152 flg = TTY_FRAME;
153 141
154 if (ch & UARTDR_OVERR) {
155 /* 142 /*
156 * CHECK: does overrun affect the current character? 143 * CHECK: does overrun affect the current character?
157 * ASSUMPTION: it does not. 144 * ASSUMPTION: it does not.
158 */ 145 */
159 tty_insert_flip_char(tty, ch, flg); 146 if ((ch & port->ignore_status_mask & ~RXSTAT_OVERRUN) == 0)
160 ch = 0; 147 tty_insert_flip_char(tty, ch, flg);
161 flg = TTY_OVERRUN; 148 if ((ch & ~port->ignore_status_mask & RXSTAT_OVERRUN) == 0)
149 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
150
151 ignore_char:
152 status = clps_readl(SYSFLG(port));
162 } 153 }
163#ifdef SUPPORT_SYSRQ 154 tty_flip_buffer_push(tty);
164 port->sysrq = 0; 155 return IRQ_HANDLED;
165#endif
166 goto error_return;
167} 156}
168 157
169static irqreturn_t clps711xuart_int_tx(int irq, void *dev_id, struct pt_regs *regs) 158static irqreturn_t clps711xuart_int_tx(int irq, void *dev_id, struct pt_regs *regs)
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index c682c6308cde..01a8726a3f97 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -321,18 +321,39 @@ static void imx_break_ctl(struct uart_port *port, int break_state)
321#define TXTL 2 /* reset default */ 321#define TXTL 2 /* reset default */
322#define RXTL 1 /* reset default */ 322#define RXTL 1 /* reset default */
323 323
324static int imx_setup_ufcr(struct imx_port *sport, unsigned int mode)
325{
326 unsigned int val;
327 unsigned int ufcr_rfdiv;
328
329 /* set receiver / transmitter trigger level.
330 * RFDIV is set such way to satisfy requested uartclk value
331 */
332 val = TXTL<<10 | RXTL;
333 ufcr_rfdiv = (imx_get_perclk1() + sport->port.uartclk / 2) / sport->port.uartclk;
334
335 if(!ufcr_rfdiv)
336 ufcr_rfdiv = 1;
337
338 if(ufcr_rfdiv >= 7)
339 ufcr_rfdiv = 6;
340 else
341 ufcr_rfdiv = 6 - ufcr_rfdiv;
342
343 val |= UFCR_RFDIV & (ufcr_rfdiv << 7);
344
345 UFCR((u32)sport->port.membase) = val;
346
347 return 0;
348}
349
324static int imx_startup(struct uart_port *port) 350static int imx_startup(struct uart_port *port)
325{ 351{
326 struct imx_port *sport = (struct imx_port *)port; 352 struct imx_port *sport = (struct imx_port *)port;
327 int retval; 353 int retval;
328 unsigned int val;
329 unsigned long flags; 354 unsigned long flags;
330 355
331 /* set receiver / transmitter trigger level. We assume 356 imx_setup_ufcr(sport, 0);
332 * that RFDIV has been set by the arch setup or by the bootloader.
333 */
334 val = (UFCR((u32)sport->port.membase) & UFCR_RFDIV) | TXTL<<10 | RXTL;
335 UFCR((u32)sport->port.membase) = val;
336 357
337 /* disable the DREN bit (Data Ready interrupt enable) before 358 /* disable the DREN bit (Data Ready interrupt enable) before
338 * requesting IRQs 359 * requesting IRQs
@@ -737,9 +758,12 @@ static void __init
737imx_console_get_options(struct imx_port *sport, int *baud, 758imx_console_get_options(struct imx_port *sport, int *baud,
738 int *parity, int *bits) 759 int *parity, int *bits)
739{ 760{
761
740 if ( UCR1((u32)sport->port.membase) | UCR1_UARTEN ) { 762 if ( UCR1((u32)sport->port.membase) | UCR1_UARTEN ) {
741 /* ok, the port was enabled */ 763 /* ok, the port was enabled */
742 unsigned int ucr2, ubir,ubmr, uartclk; 764 unsigned int ucr2, ubir,ubmr, uartclk;
765 unsigned int baud_raw;
766 unsigned int ucfr_rfdiv;
743 767
744 ucr2 = UCR2((u32)sport->port.membase); 768 ucr2 = UCR2((u32)sport->port.membase);
745 769
@@ -758,9 +782,35 @@ imx_console_get_options(struct imx_port *sport, int *baud,
758 782
759 ubir = UBIR((u32)sport->port.membase) & 0xffff; 783 ubir = UBIR((u32)sport->port.membase) & 0xffff;
760 ubmr = UBMR((u32)sport->port.membase) & 0xffff; 784 ubmr = UBMR((u32)sport->port.membase) & 0xffff;
761 uartclk = sport->port.uartclk;
762 785
763 *baud = ((uartclk/16) * (ubir + 1)) / (ubmr + 1); 786
787 ucfr_rfdiv = (UFCR((u32)sport->port.membase) & UFCR_RFDIV) >> 7;
788 if (ucfr_rfdiv == 6)
789 ucfr_rfdiv = 7;
790 else
791 ucfr_rfdiv = 6 - ucfr_rfdiv;
792
793 uartclk = imx_get_perclk1();
794 uartclk /= ucfr_rfdiv;
795
796 { /*
797 * The next code provides exact computation of
798 * baud_raw = round(((uartclk/16) * (ubir + 1)) / (ubmr + 1))
799 * without need of float support or long long division,
800 * which would be required to prevent 32bit arithmetic overflow
801 */
802 unsigned int mul = ubir + 1;
803 unsigned int div = 16 * (ubmr + 1);
804 unsigned int rem = uartclk % div;
805
806 baud_raw = (uartclk / div) * mul;
807 baud_raw += (rem * mul + div / 2) / div;
808 *baud = (baud_raw + 50) / 100 * 100;
809 }
810
811 if(*baud != baud_raw)
812 printk(KERN_INFO "Serial: Console IMX rounded baud rate from %d to %d\n",
813 baud_raw, *baud);
764 } 814 }
765} 815}
766 816
@@ -787,6 +837,8 @@ imx_console_setup(struct console *co, char *options)
787 else 837 else
788 imx_console_get_options(sport, &baud, &parity, &bits); 838 imx_console_get_options(sport, &baud, &parity, &bits);
789 839
840 imx_setup_ufcr(sport, 0);
841
790 return uart_set_options(&sport->port, co, baud, parity, bits, flow); 842 return uart_set_options(&sport->port, co, baud, parity, bits, flow);
791} 843}
792 844
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index d054f1265701..ba4e13a22a50 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -838,7 +838,7 @@ static int inline port_init(struct ioc4_port *port)
838 port->ip_tx_prod = readl(&port->ip_serial_regs->stcir) & PROD_CONS_MASK; 838 port->ip_tx_prod = readl(&port->ip_serial_regs->stcir) & PROD_CONS_MASK;
839 writel(port->ip_tx_prod, &port->ip_serial_regs->stpir); 839 writel(port->ip_tx_prod, &port->ip_serial_regs->stpir);
840 port->ip_rx_cons = readl(&port->ip_serial_regs->srpir) & PROD_CONS_MASK; 840 port->ip_rx_cons = readl(&port->ip_serial_regs->srpir) & PROD_CONS_MASK;
841 writel(port->ip_rx_cons, &port->ip_serial_regs->srcir); 841 writel(port->ip_rx_cons | IOC4_SRCIR_ARM, &port->ip_serial_regs->srcir);
842 842
843 /* Disable interrupts for this 16550 */ 843 /* Disable interrupts for this 16550 */
844 uart = port->ip_uart_regs; 844 uart = port->ip_uart_regs;
@@ -1272,8 +1272,9 @@ static inline int set_rx_timeout(struct ioc4_port *port, int timeout)
1272 * and set the rx threshold to that amount. There are 4 chars 1272 * and set the rx threshold to that amount. There are 4 chars
1273 * per ring entry, so we'll divide the number of chars that will 1273 * per ring entry, so we'll divide the number of chars that will
1274 * arrive in timeout by 4. 1274 * arrive in timeout by 4.
1275 * So .... timeout * baud / 10 / HZ / 4, with HZ = 100.
1275 */ 1276 */
1276 threshold = timeout * port->ip_baud / 10 / HZ / 4; 1277 threshold = timeout * port->ip_baud / 4000;
1277 if (threshold == 0) 1278 if (threshold == 0)
1278 threshold = 1; /* otherwise we'll intr all the time! */ 1279 threshold = 1; /* otherwise we'll intr all the time! */
1279 1280
@@ -1285,8 +1286,10 @@ static inline int set_rx_timeout(struct ioc4_port *port, int timeout)
1285 1286
1286 writel(port->ip_sscr, &port->ip_serial_regs->sscr); 1287 writel(port->ip_sscr, &port->ip_serial_regs->sscr);
1287 1288
1288 /* Now set the rx timeout to the given value */ 1289 /* Now set the rx timeout to the given value
1289 timeout = timeout * IOC4_SRTR_HZ / HZ; 1290 * again timeout * IOC4_SRTR_HZ / HZ
1291 */
1292 timeout = timeout * IOC4_SRTR_HZ / 100;
1290 if (timeout > IOC4_SRTR_CNT) 1293 if (timeout > IOC4_SRTR_CNT)
1291 timeout = IOC4_SRTR_CNT; 1294 timeout = IOC4_SRTR_CNT;
1292 1295
@@ -1380,7 +1383,7 @@ config_port(struct ioc4_port *port,
1380 if (port->ip_tx_lowat == 0) 1383 if (port->ip_tx_lowat == 0)
1381 port->ip_tx_lowat = 1; 1384 port->ip_tx_lowat = 1;
1382 1385
1383 set_rx_timeout(port, port->ip_rx_timeout); 1386 set_rx_timeout(port, 2);
1384 1387
1385 return 0; 1388 return 0;
1386} 1389}
@@ -1685,8 +1688,8 @@ ioc4_change_speed(struct uart_port *the_port,
1685{ 1688{
1686 struct ioc4_port *port = get_ioc4_port(the_port); 1689 struct ioc4_port *port = get_ioc4_port(the_port);
1687 int baud, bits; 1690 int baud, bits;
1688 unsigned cflag, cval; 1691 unsigned cflag;
1689 int new_parity = 0, new_parity_enable = 0, new_stop = 1, new_data = 8; 1692 int new_parity = 0, new_parity_enable = 0, new_stop = 0, new_data = 8;
1690 struct uart_info *info = the_port->info; 1693 struct uart_info *info = the_port->info;
1691 1694
1692 cflag = new_termios->c_cflag; 1695 cflag = new_termios->c_cflag;
@@ -1694,48 +1697,35 @@ ioc4_change_speed(struct uart_port *the_port,
1694 switch (cflag & CSIZE) { 1697 switch (cflag & CSIZE) {
1695 case CS5: 1698 case CS5:
1696 new_data = 5; 1699 new_data = 5;
1697 cval = 0x00;
1698 bits = 7; 1700 bits = 7;
1699 break; 1701 break;
1700 case CS6: 1702 case CS6:
1701 new_data = 6; 1703 new_data = 6;
1702 cval = 0x01;
1703 bits = 8; 1704 bits = 8;
1704 break; 1705 break;
1705 case CS7: 1706 case CS7:
1706 new_data = 7; 1707 new_data = 7;
1707 cval = 0x02;
1708 bits = 9; 1708 bits = 9;
1709 break; 1709 break;
1710 case CS8: 1710 case CS8:
1711 new_data = 8; 1711 new_data = 8;
1712 cval = 0x03;
1713 bits = 10; 1712 bits = 10;
1714 break; 1713 break;
1715 default: 1714 default:
1716 /* cuz we always need a default ... */ 1715 /* cuz we always need a default ... */
1717 new_data = 5; 1716 new_data = 5;
1718 cval = 0x00;
1719 bits = 7; 1717 bits = 7;
1720 break; 1718 break;
1721 } 1719 }
1722 if (cflag & CSTOPB) { 1720 if (cflag & CSTOPB) {
1723 cval |= 0x04;
1724 bits++; 1721 bits++;
1725 new_stop = 1; 1722 new_stop = 1;
1726 } 1723 }
1727 if (cflag & PARENB) { 1724 if (cflag & PARENB) {
1728 cval |= UART_LCR_PARITY;
1729 bits++; 1725 bits++;
1730 new_parity_enable = 1; 1726 new_parity_enable = 1;
1731 } 1727 if (cflag & PARODD)
1732 if (cflag & PARODD) { 1728 new_parity = 1;
1733 cval |= UART_LCR_EPAR;
1734 new_parity = 1;
1735 }
1736 if (cflag & IGNPAR) {
1737 cval &= ~UART_LCR_PARITY;
1738 new_parity_enable = 0;
1739 } 1729 }
1740 baud = uart_get_baud_rate(the_port, new_termios, old_termios, 1730 baud = uart_get_baud_rate(the_port, new_termios, old_termios,
1741 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED); 1731 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED);
@@ -1765,10 +1755,15 @@ ioc4_change_speed(struct uart_port *the_port,
1765 the_port->ignore_status_mask &= ~N_DATA_READY; 1755 the_port->ignore_status_mask &= ~N_DATA_READY;
1766 } 1756 }
1767 1757
1768 if (cflag & CRTSCTS) 1758 if (cflag & CRTSCTS) {
1769 info->flags |= ASYNC_CTS_FLOW; 1759 info->flags |= ASYNC_CTS_FLOW;
1770 else 1760 port->ip_sscr |= IOC4_SSCR_HFC_EN;
1761 }
1762 else {
1771 info->flags &= ~ASYNC_CTS_FLOW; 1763 info->flags &= ~ASYNC_CTS_FLOW;
1764 port->ip_sscr &= ~IOC4_SSCR_HFC_EN;
1765 }
1766 writel(port->ip_sscr, &port->ip_serial_regs->sscr);
1772 1767
1773 /* Set the configuration and proper notification call */ 1768 /* Set the configuration and proper notification call */
1774 DPRINT_CONFIG(("%s : port 0x%p cflag 0%o " 1769 DPRINT_CONFIG(("%s : port 0x%p cflag 0%o "
@@ -1825,12 +1820,6 @@ static inline int ic4_startup_local(struct uart_port *the_port)
1825 /* set the speed of the serial port */ 1820 /* set the speed of the serial port */
1826 ioc4_change_speed(the_port, info->tty->termios, (struct termios *)0); 1821 ioc4_change_speed(the_port, info->tty->termios, (struct termios *)0);
1827 1822
1828 /* enable hardware flow control - after ioc4_change_speed because
1829 * ASYNC_CTS_FLOW is set there */
1830 if (info->flags & ASYNC_CTS_FLOW) {
1831 port->ip_sscr |= IOC4_SSCR_HFC_EN;
1832 writel(port->ip_sscr, &port->ip_serial_regs->sscr);
1833 }
1834 info->flags |= UIF_INITIALIZED; 1823 info->flags |= UIF_INITIALIZED;
1835 return 0; 1824 return 0;
1836} 1825}
@@ -1847,7 +1836,6 @@ static void ioc4_cb_output_lowat(struct ioc4_port *port)
1847 } 1836 }
1848} 1837}
1849 1838
1850
1851/** 1839/**
1852 * handle_intr - service any interrupts for the given port - 2nd level 1840 * handle_intr - service any interrupts for the given port - 2nd level
1853 * called via sd_intr 1841 * called via sd_intr
diff --git a/drivers/serial/jsm/jsm.h b/drivers/serial/jsm/jsm.h
index e0717611c940..777829fa3300 100644
--- a/drivers/serial/jsm/jsm.h
+++ b/drivers/serial/jsm/jsm.h
@@ -393,7 +393,6 @@ int jsm_tty_init(struct jsm_board *);
393int jsm_uart_port_init(struct jsm_board *); 393int jsm_uart_port_init(struct jsm_board *);
394int jsm_remove_uart_port(struct jsm_board *); 394int jsm_remove_uart_port(struct jsm_board *);
395void jsm_input(struct jsm_channel *ch); 395void jsm_input(struct jsm_channel *ch);
396void jsm_carrier(struct jsm_channel *ch);
397void jsm_check_queue_flow_control(struct jsm_channel *ch); 396void jsm_check_queue_flow_control(struct jsm_channel *ch);
398 397
399#endif 398#endif
diff --git a/drivers/serial/jsm/jsm_neo.c b/drivers/serial/jsm/jsm_neo.c
index 9b79c1ff6c72..3a11a69feb44 100644
--- a/drivers/serial/jsm/jsm_neo.c
+++ b/drivers/serial/jsm/jsm_neo.c
@@ -688,7 +688,7 @@ static void neo_flush_uart_read(struct jsm_channel *ch)
688/* 688/*
689 * No locks are assumed to be held when calling this function. 689 * No locks are assumed to be held when calling this function.
690 */ 690 */
691void neo_clear_break(struct jsm_channel *ch, int force) 691static void neo_clear_break(struct jsm_channel *ch, int force)
692{ 692{
693 unsigned long lock_flags; 693 unsigned long lock_flags;
694 694
diff --git a/drivers/serial/jsm/jsm_tty.c b/drivers/serial/jsm/jsm_tty.c
index 24fe76c28833..98de2258fd06 100644
--- a/drivers/serial/jsm/jsm_tty.c
+++ b/drivers/serial/jsm/jsm_tty.c
@@ -31,6 +31,8 @@
31 31
32#include "jsm.h" 32#include "jsm.h"
33 33
34static void jsm_carrier(struct jsm_channel *ch);
35
34static inline int jsm_get_mstat(struct jsm_channel *ch) 36static inline int jsm_get_mstat(struct jsm_channel *ch)
35{ 37{
36 unsigned char mstat; 38 unsigned char mstat;
@@ -755,7 +757,7 @@ void jsm_input(struct jsm_channel *ch)
755 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n"); 757 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n");
756} 758}
757 759
758void jsm_carrier(struct jsm_channel *ch) 760static void jsm_carrier(struct jsm_channel *ch)
759{ 761{
760 struct jsm_board *bd; 762 struct jsm_board *bd;
761 763
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
index d0dfc3cf9245..a8314aee2ab8 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -329,8 +329,8 @@ mpsc_sdma_stop(struct mpsc_port_info *pi)
329 mpsc_sdma_cmd(pi, SDMA_SDCM_AR | SDMA_SDCM_AT); 329 mpsc_sdma_cmd(pi, SDMA_SDCM_AR | SDMA_SDCM_AT);
330 330
331 /* Clear the SDMA current and first TX and RX pointers */ 331 /* Clear the SDMA current and first TX and RX pointers */
332 mpsc_sdma_set_tx_ring(pi, 0); 332 mpsc_sdma_set_tx_ring(pi, NULL);
333 mpsc_sdma_set_rx_ring(pi, 0); 333 mpsc_sdma_set_rx_ring(pi, NULL);
334 334
335 /* Disable interrupts */ 335 /* Disable interrupts */
336 mpsc_sdma_intr_mask(pi, 0xf); 336 mpsc_sdma_intr_mask(pi, 0xf);
@@ -1540,8 +1540,8 @@ mpsc_shared_unmap_regs(void)
1540 MPSC_SDMA_INTR_REG_BLOCK_SIZE); 1540 MPSC_SDMA_INTR_REG_BLOCK_SIZE);
1541 } 1541 }
1542 1542
1543 mpsc_shared_regs.mpsc_routing_base = 0; 1543 mpsc_shared_regs.mpsc_routing_base = NULL;
1544 mpsc_shared_regs.sdma_intr_base = 0; 1544 mpsc_shared_regs.sdma_intr_base = NULL;
1545 1545
1546 mpsc_shared_regs.mpsc_routing_base_p = 0; 1546 mpsc_shared_regs.mpsc_routing_base_p = 0;
1547 mpsc_shared_regs.sdma_intr_base_p = 0; 1547 mpsc_shared_regs.sdma_intr_base_p = 0;
@@ -1678,9 +1678,9 @@ mpsc_drv_unmap_regs(struct mpsc_port_info *pi)
1678 release_mem_region(pi->brg_base_p, MPSC_BRG_REG_BLOCK_SIZE); 1678 release_mem_region(pi->brg_base_p, MPSC_BRG_REG_BLOCK_SIZE);
1679 } 1679 }
1680 1680
1681 pi->mpsc_base = 0; 1681 pi->mpsc_base = NULL;
1682 pi->sdma_base = 0; 1682 pi->sdma_base = NULL;
1683 pi->brg_base = 0; 1683 pi->brg_base = NULL;
1684 1684
1685 pi->mpsc_base_p = 0; 1685 pi->mpsc_base_p = 0;
1686 pi->sdma_base_p = 0; 1686 pi->sdma_base_p = 0;
diff --git a/drivers/serial/mpsc.h b/drivers/serial/mpsc.h
index 1f7294b7095f..678dbcf06c8f 100644
--- a/drivers/serial/mpsc.h
+++ b/drivers/serial/mpsc.h
@@ -83,8 +83,8 @@ struct mpsc_shared_regs {
83 phys_addr_t mpsc_routing_base_p; 83 phys_addr_t mpsc_routing_base_p;
84 phys_addr_t sdma_intr_base_p; 84 phys_addr_t sdma_intr_base_p;
85 85
86 void *mpsc_routing_base; 86 void __iomem *mpsc_routing_base;
87 void *sdma_intr_base; 87 void __iomem *sdma_intr_base;
88 88
89 u32 MPSC_MRR_m; 89 u32 MPSC_MRR_m;
90 u32 MPSC_RCRR_m; 90 u32 MPSC_RCRR_m;
@@ -120,9 +120,9 @@ struct mpsc_port_info {
120 phys_addr_t brg_base_p; 120 phys_addr_t brg_base_p;
121 121
122 /* Virtual addresses of various blocks of registers (from platform) */ 122 /* Virtual addresses of various blocks of registers (from platform) */
123 void *mpsc_base; 123 void __iomem *mpsc_base;
124 void *sdma_base; 124 void __iomem *sdma_base;
125 void *brg_base; 125 void __iomem *brg_base;
126 126
127 /* Descriptor ring and buffer allocations */ 127 /* Descriptor ring and buffer allocations */
128 void *dma_region; 128 void *dma_region;
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index bd6782aeb831..435750d40a47 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -364,7 +364,7 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id, struct pt_regs *regs)
364 flag = TTY_NORMAL; 364 flag = TTY_NORMAL;
365 port->icount.rx++; 365 port->icount.rx++;
366 366
367 if (uerstat & S3C2410_UERSTAT_ANY) { 367 if (unlikely(uerstat & S3C2410_UERSTAT_ANY)) {
368 dbg("rxerr: port ch=0x%02x, rxs=0x%08x\n", 368 dbg("rxerr: port ch=0x%02x, rxs=0x%08x\n",
369 ch, uerstat); 369 ch, uerstat);
370 370
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index 086065210d1e..157218bc6c6f 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -214,56 +214,39 @@ sa1100_rx_chars(struct sa1100_port *sport, struct pt_regs *regs)
214 * note that the error handling code is 214 * note that the error handling code is
215 * out of the main execution path 215 * out of the main execution path
216 */ 216 */
217 if (status & UTSR1_TO_SM(UTSR1_PRE | UTSR1_FRE | UTSR1_ROR)) 217 if (status & UTSR1_TO_SM(UTSR1_PRE | UTSR1_FRE | UTSR1_ROR)) {
218 goto handle_error; 218 if (status & UTSR1_TO_SM(UTSR1_PRE))
219 sport->port.icount.parity++;
220 else if (status & UTSR1_TO_SM(UTSR1_FRE))
221 sport->port.icount.frame++;
222 if (status & UTSR1_TO_SM(UTSR1_ROR))
223 sport->port.icount.overrun++;
224
225 status &= sport->port.read_status_mask;
226
227 if (status & UTSR1_TO_SM(UTSR1_PRE))
228 flg = TTY_PARITY;
229 else if (status & UTSR1_TO_SM(UTSR1_FRE))
230 flg = TTY_FRAME;
231
232#ifdef SUPPORT_SYSRQ
233 sport->port.sysrq = 0;
234#endif
235 }
219 236
220 if (uart_handle_sysrq_char(&sport->port, ch, regs)) 237 if (uart_handle_sysrq_char(&sport->port, ch, regs))
221 goto ignore_char; 238 goto ignore_char;
222 239
223 error_return: 240 if ((status & port->ignore_status_mask & ~UTSR1_TO_SM(UTSR1_ROR)) == 0)
224 tty_insert_flip_char(tty, ch, flg); 241 tty_insert_flip_char(tty, ch, flg);
242 if (status & ~port->ignore_status_mask & UTSR1_TO_SM(UTSR1_ROR))
243 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
244
225 ignore_char: 245 ignore_char:
226 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | 246 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) |
227 UTSR0_TO_SM(UART_GET_UTSR0(sport)); 247 UTSR0_TO_SM(UART_GET_UTSR0(sport));
228 } 248 }
229 out:
230 tty_flip_buffer_push(tty); 249 tty_flip_buffer_push(tty);
231 return;
232
233 handle_error:
234 if (status & UTSR1_TO_SM(UTSR1_PRE))
235 sport->port.icount.parity++;
236 else if (status & UTSR1_TO_SM(UTSR1_FRE))
237 sport->port.icount.frame++;
238 if (status & UTSR1_TO_SM(UTSR1_ROR))
239 sport->port.icount.overrun++;
240
241 if (status & sport->port.ignore_status_mask) {
242 if (++ignored > 100)
243 goto out;
244 goto ignore_char;
245 }
246
247 status &= sport->port.read_status_mask;
248
249 if (status & UTSR1_TO_SM(UTSR1_PRE))
250 flg = TTY_PARITY;
251 else if (status & UTSR1_TO_SM(UTSR1_FRE))
252 flg = TTY_FRAME;
253
254 if (status & UTSR1_TO_SM(UTSR1_ROR)) {
255 /*
256 * overrun does *not* affect the character
257 * we read from the FIFO
258 */
259 tty_insert_flip_char(tty, ch, flg);
260 ch = 0;
261 flg = TTY_OVERRUN;
262 }
263#ifdef SUPPORT_SYSRQ
264 sport->port.sysrq = 0;
265#endif
266 goto error_return;
267} 250}
268 251
269static void sa1100_tx_chars(struct sa1100_port *sport) 252static void sa1100_tx_chars(struct sa1100_port *sport)
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 9034f9ad37c7..6eeb48f6a482 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -107,6 +107,13 @@ struct serial_info {
107 int line[4]; 107 int line[4];
108}; 108};
109 109
110struct serial_cfg_mem {
111 tuple_t tuple;
112 cisparse_t parse;
113 u_char buf[256];
114};
115
116
110static void serial_config(dev_link_t * link); 117static void serial_config(dev_link_t * link);
111static int serial_event(event_t event, int priority, 118static int serial_event(event_t event, int priority,
112 event_callback_args_t * args); 119 event_callback_args_t * args);
@@ -357,14 +364,24 @@ static int simple_config(dev_link_t *link)
357 static int size_table[2] = { 8, 16 }; 364 static int size_table[2] = { 8, 16 };
358 client_handle_t handle = link->handle; 365 client_handle_t handle = link->handle;
359 struct serial_info *info = link->priv; 366 struct serial_info *info = link->priv;
360 tuple_t tuple; 367 struct serial_cfg_mem *cfg_mem;
361 u_char buf[256]; 368 tuple_t *tuple;
362 cisparse_t parse; 369 u_char *buf;
363 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 370 cisparse_t *parse;
371 cistpl_cftable_entry_t *cf;
364 config_info_t config; 372 config_info_t config;
365 int i, j, try; 373 int i, j, try;
366 int s; 374 int s;
367 375
376 cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL);
377 if (!cfg_mem)
378 return -1;
379
380 tuple = &cfg_mem->tuple;
381 parse = &cfg_mem->parse;
382 cf = &parse->cftable_entry;
383 buf = cfg_mem->buf;
384
368 /* If the card is already configured, look up the port and irq */ 385 /* If the card is already configured, look up the port and irq */
369 i = pcmcia_get_configuration_info(handle, &config); 386 i = pcmcia_get_configuration_info(handle, &config);
370 if ((i == CS_SUCCESS) && (config.Attributes & CONF_VALID_CLIENT)) { 387 if ((i == CS_SUCCESS) && (config.Attributes & CONF_VALID_CLIENT)) {
@@ -377,21 +394,23 @@ static int simple_config(dev_link_t *link)
377 port = config.BasePort1 + 0x28; 394 port = config.BasePort1 + 0x28;
378 info->slave = 1; 395 info->slave = 1;
379 } 396 }
380 if (info->slave) 397 if (info->slave) {
398 kfree(cfg_mem);
381 return setup_serial(handle, info, port, config.AssignedIRQ); 399 return setup_serial(handle, info, port, config.AssignedIRQ);
400 }
382 } 401 }
383 link->conf.Vcc = config.Vcc; 402 link->conf.Vcc = config.Vcc;
384 403
385 /* First pass: look for a config entry that looks normal. */ 404 /* First pass: look for a config entry that looks normal. */
386 tuple.TupleData = (cisdata_t *) buf; 405 tuple->TupleData = (cisdata_t *) buf;
387 tuple.TupleOffset = 0; 406 tuple->TupleOffset = 0;
388 tuple.TupleDataMax = 255; 407 tuple->TupleDataMax = 255;
389 tuple.Attributes = 0; 408 tuple->Attributes = 0;
390 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 409 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
391 /* Two tries: without IO aliases, then with aliases */ 410 /* Two tries: without IO aliases, then with aliases */
392 for (s = 0; s < 2; s++) { 411 for (s = 0; s < 2; s++) {
393 for (try = 0; try < 2; try++) { 412 for (try = 0; try < 2; try++) {
394 i = first_tuple(handle, &tuple, &parse); 413 i = first_tuple(handle, tuple, parse);
395 while (i != CS_NO_MORE_ITEMS) { 414 while (i != CS_NO_MORE_ITEMS) {
396 if (i != CS_SUCCESS) 415 if (i != CS_SUCCESS)
397 goto next_entry; 416 goto next_entry;
@@ -409,14 +428,14 @@ static int simple_config(dev_link_t *link)
409 goto found_port; 428 goto found_port;
410 } 429 }
411next_entry: 430next_entry:
412 i = next_tuple(handle, &tuple, &parse); 431 i = next_tuple(handle, tuple, parse);
413 } 432 }
414 } 433 }
415 } 434 }
416 /* Second pass: try to find an entry that isn't picky about 435 /* Second pass: try to find an entry that isn't picky about
417 its base address, then try to grab any standard serial port 436 its base address, then try to grab any standard serial port
418 address, and finally try to get any free port. */ 437 address, and finally try to get any free port. */
419 i = first_tuple(handle, &tuple, &parse); 438 i = first_tuple(handle, tuple, parse);
420 while (i != CS_NO_MORE_ITEMS) { 439 while (i != CS_NO_MORE_ITEMS) {
421 if ((i == CS_SUCCESS) && (cf->io.nwin > 0) && 440 if ((i == CS_SUCCESS) && (cf->io.nwin > 0) &&
422 ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 441 ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) {
@@ -429,7 +448,7 @@ next_entry:
429 goto found_port; 448 goto found_port;
430 } 449 }
431 } 450 }
432 i = next_tuple(handle, &tuple, &parse); 451 i = next_tuple(handle, tuple, parse);
433 } 452 }
434 453
435 found_port: 454 found_port:
@@ -437,6 +456,7 @@ next_entry:
437 printk(KERN_NOTICE 456 printk(KERN_NOTICE
438 "serial_cs: no usable port range found, giving up\n"); 457 "serial_cs: no usable port range found, giving up\n");
439 cs_error(link->handle, RequestIO, i); 458 cs_error(link->handle, RequestIO, i);
459 kfree(cfg_mem);
440 return -1; 460 return -1;
441 } 461 }
442 462
@@ -450,9 +470,10 @@ next_entry:
450 i = pcmcia_request_configuration(link->handle, &link->conf); 470 i = pcmcia_request_configuration(link->handle, &link->conf);
451 if (i != CS_SUCCESS) { 471 if (i != CS_SUCCESS) {
452 cs_error(link->handle, RequestConfiguration, i); 472 cs_error(link->handle, RequestConfiguration, i);
473 kfree(cfg_mem);
453 return -1; 474 return -1;
454 } 475 }
455 476 kfree(cfg_mem);
456 return setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ); 477 return setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ);
457} 478}
458 479
@@ -460,29 +481,39 @@ static int multi_config(dev_link_t * link)
460{ 481{
461 client_handle_t handle = link->handle; 482 client_handle_t handle = link->handle;
462 struct serial_info *info = link->priv; 483 struct serial_info *info = link->priv;
463 tuple_t tuple; 484 struct serial_cfg_mem *cfg_mem;
464 u_char buf[256]; 485 tuple_t *tuple;
465 cisparse_t parse; 486 u_char *buf;
466 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 487 cisparse_t *parse;
488 cistpl_cftable_entry_t *cf;
467 config_info_t config; 489 config_info_t config;
468 int i, base2 = 0; 490 int i, rc, base2 = 0;
491
492 cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL);
493 if (!cfg_mem)
494 return -1;
495 tuple = &cfg_mem->tuple;
496 parse = &cfg_mem->parse;
497 cf = &parse->cftable_entry;
498 buf = cfg_mem->buf;
469 499
470 i = pcmcia_get_configuration_info(handle, &config); 500 i = pcmcia_get_configuration_info(handle, &config);
471 if (i != CS_SUCCESS) { 501 if (i != CS_SUCCESS) {
472 cs_error(handle, GetConfigurationInfo, i); 502 cs_error(handle, GetConfigurationInfo, i);
473 return -1; 503 rc = -1;
504 goto free_cfg_mem;
474 } 505 }
475 link->conf.Vcc = config.Vcc; 506 link->conf.Vcc = config.Vcc;
476 507
477 tuple.TupleData = (cisdata_t *) buf; 508 tuple->TupleData = (cisdata_t *) buf;
478 tuple.TupleOffset = 0; 509 tuple->TupleOffset = 0;
479 tuple.TupleDataMax = 255; 510 tuple->TupleDataMax = 255;
480 tuple.Attributes = 0; 511 tuple->Attributes = 0;
481 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 512 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
482 513
483 /* First, look for a generic full-sized window */ 514 /* First, look for a generic full-sized window */
484 link->io.NumPorts1 = info->multi * 8; 515 link->io.NumPorts1 = info->multi * 8;
485 i = first_tuple(handle, &tuple, &parse); 516 i = first_tuple(handle, tuple, parse);
486 while (i != CS_NO_MORE_ITEMS) { 517 while (i != CS_NO_MORE_ITEMS) {
487 /* The quad port cards have bad CIS's, so just look for a 518 /* The quad port cards have bad CIS's, so just look for a
488 window larger than 8 ports and assume it will be right */ 519 window larger than 8 ports and assume it will be right */
@@ -497,14 +528,14 @@ static int multi_config(dev_link_t * link)
497 if (i == CS_SUCCESS) 528 if (i == CS_SUCCESS)
498 break; 529 break;
499 } 530 }
500 i = next_tuple(handle, &tuple, &parse); 531 i = next_tuple(handle, tuple, parse);
501 } 532 }
502 533
503 /* If that didn't work, look for two windows */ 534 /* If that didn't work, look for two windows */
504 if (i != CS_SUCCESS) { 535 if (i != CS_SUCCESS) {
505 link->io.NumPorts1 = link->io.NumPorts2 = 8; 536 link->io.NumPorts1 = link->io.NumPorts2 = 8;
506 info->multi = 2; 537 info->multi = 2;
507 i = first_tuple(handle, &tuple, &parse); 538 i = first_tuple(handle, tuple, parse);
508 while (i != CS_NO_MORE_ITEMS) { 539 while (i != CS_NO_MORE_ITEMS) {
509 if ((i == CS_SUCCESS) && (cf->io.nwin == 2)) { 540 if ((i == CS_SUCCESS) && (cf->io.nwin == 2)) {
510 link->conf.ConfigIndex = cf->index; 541 link->conf.ConfigIndex = cf->index;
@@ -517,13 +548,14 @@ static int multi_config(dev_link_t * link)
517 if (i == CS_SUCCESS) 548 if (i == CS_SUCCESS)
518 break; 549 break;
519 } 550 }
520 i = next_tuple(handle, &tuple, &parse); 551 i = next_tuple(handle, tuple, parse);
521 } 552 }
522 } 553 }
523 554
524 if (i != CS_SUCCESS) { 555 if (i != CS_SUCCESS) {
525 cs_error(link->handle, RequestIO, i); 556 cs_error(link->handle, RequestIO, i);
526 return -1; 557 rc = -1;
558 goto free_cfg_mem;
527 } 559 }
528 560
529 i = pcmcia_request_irq(link->handle, &link->irq); 561 i = pcmcia_request_irq(link->handle, &link->irq);
@@ -541,7 +573,8 @@ static int multi_config(dev_link_t * link)
541 i = pcmcia_request_configuration(link->handle, &link->conf); 573 i = pcmcia_request_configuration(link->handle, &link->conf);
542 if (i != CS_SUCCESS) { 574 if (i != CS_SUCCESS) {
543 cs_error(link->handle, RequestConfiguration, i); 575 cs_error(link->handle, RequestConfiguration, i);
544 return -1; 576 rc = -1;
577 goto free_cfg_mem;
545 } 578 }
546 579
547 /* The Oxford Semiconductor OXCF950 cards are in fact single-port: 580 /* The Oxford Semiconductor OXCF950 cards are in fact single-port:
@@ -554,17 +587,23 @@ static int multi_config(dev_link_t * link)
554 setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ); 587 setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ);
555 outb(12, base2 + 1); 588 outb(12, base2 + 1);
556 } 589 }
557 return 0; 590 rc = 0;
591 goto free_cfg_mem;
558 } 592 }
559 593
560 setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ); 594 setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ);
561 /* The Nokia cards are not really multiport cards */ 595 /* The Nokia cards are not really multiport cards */
562 if (info->manfid == MANFID_NOKIA) 596 if (info->manfid == MANFID_NOKIA) {
563 return 0; 597 rc = 0;
598 goto free_cfg_mem;
599 }
564 for (i = 0; i < info->multi - 1; i++) 600 for (i = 0; i < info->multi - 1; i++)
565 setup_serial(handle, info, base2 + (8 * i), link->irq.AssignedIRQ); 601 setup_serial(handle, info, base2 + (8 * i),
566 602 link->irq.AssignedIRQ);
567 return 0; 603 rc = 0;
604free_cfg_mem:
605 kfree(cfg_mem);
606 return rc;
568} 607}
569 608
570/*====================================================================== 609/*======================================================================
@@ -579,39 +618,49 @@ void serial_config(dev_link_t * link)
579{ 618{
580 client_handle_t handle = link->handle; 619 client_handle_t handle = link->handle;
581 struct serial_info *info = link->priv; 620 struct serial_info *info = link->priv;
582 tuple_t tuple; 621 struct serial_cfg_mem *cfg_mem;
583 u_short buf[128]; 622 tuple_t *tuple;
584 cisparse_t parse; 623 u_char *buf;
585 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 624 cisparse_t *parse;
625 cistpl_cftable_entry_t *cf;
586 int i, last_ret, last_fn; 626 int i, last_ret, last_fn;
587 627
588 DEBUG(0, "serial_config(0x%p)\n", link); 628 DEBUG(0, "serial_config(0x%p)\n", link);
589 629
590 tuple.TupleData = (cisdata_t *) buf; 630 cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL);
591 tuple.TupleOffset = 0; 631 if (!cfg_mem)
592 tuple.TupleDataMax = 255; 632 goto failed;
593 tuple.Attributes = 0; 633
634 tuple = &cfg_mem->tuple;
635 parse = &cfg_mem->parse;
636 cf = &parse->cftable_entry;
637 buf = cfg_mem->buf;
638
639 tuple->TupleData = (cisdata_t *) buf;
640 tuple->TupleOffset = 0;
641 tuple->TupleDataMax = 255;
642 tuple->Attributes = 0;
594 /* Get configuration register information */ 643 /* Get configuration register information */
595 tuple.DesiredTuple = CISTPL_CONFIG; 644 tuple->DesiredTuple = CISTPL_CONFIG;
596 last_ret = first_tuple(handle, &tuple, &parse); 645 last_ret = first_tuple(handle, tuple, parse);
597 if (last_ret != CS_SUCCESS) { 646 if (last_ret != CS_SUCCESS) {
598 last_fn = ParseTuple; 647 last_fn = ParseTuple;
599 goto cs_failed; 648 goto cs_failed;
600 } 649 }
601 link->conf.ConfigBase = parse.config.base; 650 link->conf.ConfigBase = parse->config.base;
602 link->conf.Present = parse.config.rmask[0]; 651 link->conf.Present = parse->config.rmask[0];
603 652
604 /* Configure card */ 653 /* Configure card */
605 link->state |= DEV_CONFIG; 654 link->state |= DEV_CONFIG;
606 655
607 /* Is this a compliant multifunction card? */ 656 /* Is this a compliant multifunction card? */
608 tuple.DesiredTuple = CISTPL_LONGLINK_MFC; 657 tuple->DesiredTuple = CISTPL_LONGLINK_MFC;
609 tuple.Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK; 658 tuple->Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK;
610 info->multi = (first_tuple(handle, &tuple, &parse) == CS_SUCCESS); 659 info->multi = (first_tuple(handle, tuple, parse) == CS_SUCCESS);
611 660
612 /* Is this a multiport card? */ 661 /* Is this a multiport card? */
613 tuple.DesiredTuple = CISTPL_MANFID; 662 tuple->DesiredTuple = CISTPL_MANFID;
614 if (first_tuple(handle, &tuple, &parse) == CS_SUCCESS) { 663 if (first_tuple(handle, tuple, parse) == CS_SUCCESS) {
615 info->manfid = le16_to_cpu(buf[0]); 664 info->manfid = le16_to_cpu(buf[0]);
616 for (i = 0; i < MULTI_COUNT; i++) 665 for (i = 0; i < MULTI_COUNT; i++)
617 if ((info->manfid == multi_id[i].manfid) && 666 if ((info->manfid == multi_id[i].manfid) &&
@@ -623,13 +672,13 @@ void serial_config(dev_link_t * link)
623 672
624 /* Another check for dual-serial cards: look for either serial or 673 /* Another check for dual-serial cards: look for either serial or
625 multifunction cards that ask for appropriate IO port ranges */ 674 multifunction cards that ask for appropriate IO port ranges */
626 tuple.DesiredTuple = CISTPL_FUNCID; 675 tuple->DesiredTuple = CISTPL_FUNCID;
627 if ((info->multi == 0) && 676 if ((info->multi == 0) &&
628 ((first_tuple(handle, &tuple, &parse) != CS_SUCCESS) || 677 ((first_tuple(handle, tuple, parse) != CS_SUCCESS) ||
629 (parse.funcid.func == CISTPL_FUNCID_MULTI) || 678 (parse->funcid.func == CISTPL_FUNCID_MULTI) ||
630 (parse.funcid.func == CISTPL_FUNCID_SERIAL))) { 679 (parse->funcid.func == CISTPL_FUNCID_SERIAL))) {
631 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 680 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
632 if (first_tuple(handle, &tuple, &parse) == CS_SUCCESS) { 681 if (first_tuple(handle, tuple, parse) == CS_SUCCESS) {
633 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0)) 682 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0))
634 info->multi = cf->io.win[0].len >> 3; 683 info->multi = cf->io.win[0].len >> 3;
635 if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) && 684 if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) &&
@@ -664,6 +713,7 @@ void serial_config(dev_link_t * link)
664 713
665 link->dev = &info->node[0]; 714 link->dev = &info->node[0];
666 link->state &= ~DEV_CONFIG_PENDING; 715 link->state &= ~DEV_CONFIG_PENDING;
716 kfree(cfg_mem);
667 return; 717 return;
668 718
669 cs_failed: 719 cs_failed:
@@ -671,6 +721,7 @@ void serial_config(dev_link_t * link)
671 failed: 721 failed:
672 serial_remove(link); 722 serial_remove(link);
673 link->state &= ~DEV_CONFIG_PENDING; 723 link->state &= ~DEV_CONFIG_PENDING;
724 kfree(cfg_mem);
674} 725}
675 726
676/*====================================================================== 727/*======================================================================
diff --git a/drivers/serial/serial_lh7a40x.c b/drivers/serial/serial_lh7a40x.c
index 4ce3a41f1611..85cfa08d3bad 100644
--- a/drivers/serial/serial_lh7a40x.c
+++ b/drivers/serial/serial_lh7a40x.c
@@ -162,7 +162,7 @@ lh7a40xuart_rx_chars (struct uart_port* port)
162 flag = TTY_NORMAL; 162 flag = TTY_NORMAL;
163 ++port->icount.rx; 163 ++port->icount.rx;
164 164
165 if (data & RxError) { /* Quick check, short-circuit */ 165 if (unlikely(data & RxError)) { /* Quick check, short-circuit */
166 if (data & RxBreak) { 166 if (data & RxBreak) {
167 data &= ~(RxFramingError | RxParityError); 167 data &= ~(RxFramingError | RxParityError);
168 ++port->icount.brk; 168 ++port->icount.brk;
diff --git a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
index ffaab9b90fd8..fee6418e84c4 100644
--- a/drivers/serial/sn_console.c
+++ b/drivers/serial/sn_console.c
@@ -787,7 +787,7 @@ static void __init sn_sal_switch_to_interrupts(struct sn_cons_port *port)
787 787
788static void sn_sal_console_write(struct console *, const char *, unsigned); 788static void sn_sal_console_write(struct console *, const char *, unsigned);
789static int __init sn_sal_console_setup(struct console *, char *); 789static int __init sn_sal_console_setup(struct console *, char *);
790extern struct uart_driver sal_console_uart; 790static struct uart_driver sal_console_uart;
791extern struct tty_driver *uart_console_device(struct console *, int *); 791extern struct tty_driver *uart_console_device(struct console *, int *);
792 792
793static struct console sal_console = { 793static struct console sal_console = {
@@ -801,7 +801,7 @@ static struct console sal_console = {
801 801
802#define SAL_CONSOLE &sal_console 802#define SAL_CONSOLE &sal_console
803 803
804struct uart_driver sal_console_uart = { 804static struct uart_driver sal_console_uart = {
805 .owner = THIS_MODULE, 805 .owner = THIS_MODULE,
806 .driver_name = "sn_console", 806 .driver_name = "sn_console",
807 .dev_name = DEVICE_NAME, 807 .dev_name = DEVICE_NAME,
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c
index 8caaf2e5e47c..39b788d95e39 100644
--- a/drivers/serial/sunsab.c
+++ b/drivers/serial/sunsab.c
@@ -682,7 +682,8 @@ static void calc_ebrg(int baud, int *n_ret, int *m_ret)
682 682
683/* Internal routine, port->lock is held and local interrupts are disabled. */ 683/* Internal routine, port->lock is held and local interrupts are disabled. */
684static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cflag, 684static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cflag,
685 unsigned int iflag, int baud) 685 unsigned int iflag, unsigned int baud,
686 unsigned int quot)
686{ 687{
687 unsigned int ebrg; 688 unsigned int ebrg;
688 unsigned char dafo; 689 unsigned char dafo;
@@ -766,6 +767,9 @@ static void sunsab_convert_to_sab(struct uart_sunsab_port *up, unsigned int cfla
766 up->port.ignore_status_mask |= (SAB82532_ISR0_RPF | 767 up->port.ignore_status_mask |= (SAB82532_ISR0_RPF |
767 SAB82532_ISR0_TCD); 768 SAB82532_ISR0_TCD);
768 769
770 uart_update_timeout(&up->port, cflag,
771 (up->port.uartclk / (16 * quot)));
772
769 /* Now bang the new settings into the chip. */ 773 /* Now bang the new settings into the chip. */
770 sunsab_cec_wait(up); 774 sunsab_cec_wait(up);
771 sunsab_tec_wait(up); 775 sunsab_tec_wait(up);
@@ -784,10 +788,11 @@ static void sunsab_set_termios(struct uart_port *port, struct termios *termios,
784{ 788{
785 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port; 789 struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
786 unsigned long flags; 790 unsigned long flags;
787 int baud = uart_get_baud_rate(port, termios, old, 0, 4000000); 791 unsigned int baud = uart_get_baud_rate(port, termios, old, 0, 4000000);
792 unsigned int quot = uart_get_divisor(port, baud);
788 793
789 spin_lock_irqsave(&up->port.lock, flags); 794 spin_lock_irqsave(&up->port.lock, flags);
790 sunsab_convert_to_sab(up, termios->c_cflag, termios->c_iflag, baud); 795 sunsab_convert_to_sab(up, termios->c_cflag, termios->c_iflag, baud, quot);
791 spin_unlock_irqrestore(&up->port.lock, flags); 796 spin_unlock_irqrestore(&up->port.lock, flags);
792} 797}
793 798
@@ -880,7 +885,7 @@ static int sunsab_console_setup(struct console *con, char *options)
880{ 885{
881 struct uart_sunsab_port *up = &sunsab_ports[con->index]; 886 struct uart_sunsab_port *up = &sunsab_ports[con->index];
882 unsigned long flags; 887 unsigned long flags;
883 int baud; 888 unsigned int baud, quot;
884 889
885 printk("Console: ttyS%d (SAB82532)\n", 890 printk("Console: ttyS%d (SAB82532)\n",
886 (sunsab_reg.minor - 64) + con->index); 891 (sunsab_reg.minor - 64) + con->index);
@@ -926,7 +931,8 @@ static int sunsab_console_setup(struct console *con, char *options)
926 SAB82532_IMR1_XPR; 931 SAB82532_IMR1_XPR;
927 writeb(up->interrupt_mask1, &up->regs->w.imr1); 932 writeb(up->interrupt_mask1, &up->regs->w.imr1);
928 933
929 sunsab_convert_to_sab(up, con->cflag, 0, baud); 934 quot = uart_get_divisor(&up->port, baud);
935 sunsab_convert_to_sab(up, con->cflag, 0, baud, quot);
930 sunsab_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS); 936 sunsab_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS);
931 937
932 spin_unlock_irqrestore(&up->port.lock, flags); 938 spin_unlock_irqrestore(&up->port.lock, flags);
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 23d19d394320..ddc97c905e14 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -1285,6 +1285,7 @@ static struct uart_driver sunsu_reg = {
1285 1285
1286static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel) 1286static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel)
1287{ 1287{
1288 int quot, baud;
1288#ifdef CONFIG_SERIO 1289#ifdef CONFIG_SERIO
1289 struct serio *serio; 1290 struct serio *serio;
1290#endif 1291#endif
@@ -1293,10 +1294,14 @@ static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel)
1293 up->port.type = PORT_UNKNOWN; 1294 up->port.type = PORT_UNKNOWN;
1294 up->port.uartclk = (SU_BASE_BAUD * 16); 1295 up->port.uartclk = (SU_BASE_BAUD * 16);
1295 1296
1296 if (up->su_type == SU_PORT_KBD) 1297 if (up->su_type == SU_PORT_KBD) {
1297 up->cflag = B1200 | CS8 | CLOCAL | CREAD; 1298 up->cflag = B1200 | CS8 | CLOCAL | CREAD;
1298 else 1299 baud = 1200;
1300 } else {
1299 up->cflag = B4800 | CS8 | CLOCAL | CREAD; 1301 up->cflag = B4800 | CS8 | CLOCAL | CREAD;
1302 baud = 4800;
1303 }
1304 quot = up->port.uartclk / (16 * baud);
1300 1305
1301 sunsu_autoconfig(up); 1306 sunsu_autoconfig(up);
1302 if (up->port.type == PORT_UNKNOWN) 1307 if (up->port.type == PORT_UNKNOWN)
@@ -1337,6 +1342,8 @@ static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel)
1337 } 1342 }
1338#endif 1343#endif
1339 1344
1345 sunsu_change_speed(&up->port, up->cflag, 0, quot);
1346
1340 sunsu_startup(&up->port); 1347 sunsu_startup(&up->port);
1341 return 0; 1348 return 0;
1342} 1349}
diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c
index 5538756f13ba..d5863b8b56ee 100644
--- a/drivers/telephony/ixj.c
+++ b/drivers/telephony/ixj.c
@@ -41,9 +41,6 @@
41 * 41 *
42 ***************************************************************************/ 42 ***************************************************************************/
43 43
44static char ixj_c_rcsid[] = "$Id: ixj.c,v 4.7 2001/08/13 06:19:33 craigs Exp $";
45static char ixj_c_revision[] = "$Revision: 4.7 $";
46
47/* 44/*
48 * $Log: ixj.c,v $ 45 * $Log: ixj.c,v $
49 * 46 *
@@ -6172,8 +6169,14 @@ static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd,
6172 retval = j->serial; 6169 retval = j->serial;
6173 break; 6170 break;
6174 case IXJCTL_VERSION: 6171 case IXJCTL_VERSION:
6175 if (copy_to_user(argp, ixj_c_revision, strlen(ixj_c_revision))) 6172 {
6176 retval = -EFAULT; 6173 char arg_str[100];
6174 snprintf(arg_str, sizeof(arg_str),
6175 "\nDriver version %i.%i.%i", IXJ_VER_MAJOR,
6176 IXJ_VER_MINOR, IXJ_BLD_VER);
6177 if (copy_to_user(argp, arg_str, strlen(arg_str)))
6178 retval = -EFAULT;
6179 }
6177 break; 6180 break;
6178 case PHONE_RING_CADENCE: 6181 case PHONE_RING_CADENCE:
6179 j->ring_cadence = arg; 6182 j->ring_cadence = arg;
@@ -7168,9 +7171,6 @@ static int ixj_get_status_proc(char *buf)
7168 int cnt; 7171 int cnt;
7169 IXJ *j; 7172 IXJ *j;
7170 len = 0; 7173 len = 0;
7171 len += sprintf(buf + len, "%s", ixj_c_rcsid);
7172 len += sprintf(buf + len, "\n%s", ixj_h_rcsid);
7173 len += sprintf(buf + len, "\n%s", ixjuser_h_rcsid);
7174 len += sprintf(buf + len, "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, IXJ_VER_MINOR, IXJ_BLD_VER); 7174 len += sprintf(buf + len, "\nDriver version %i.%i.%i", IXJ_VER_MAJOR, IXJ_VER_MINOR, IXJ_BLD_VER);
7175 len += sprintf(buf + len, "\nsizeof IXJ struct %Zd bytes", sizeof(IXJ)); 7175 len += sprintf(buf + len, "\nsizeof IXJ struct %Zd bytes", sizeof(IXJ));
7176 len += sprintf(buf + len, "\nsizeof DAA struct %Zd bytes", sizeof(DAA_REGS)); 7176 len += sprintf(buf + len, "\nsizeof DAA struct %Zd bytes", sizeof(DAA_REGS));
@@ -7790,7 +7790,7 @@ static int __init ixj_init(void)
7790 if ((probe = ixj_probe_pci(&cnt)) < 0) { 7790 if ((probe = ixj_probe_pci(&cnt)) < 0) {
7791 return probe; 7791 return probe;
7792 } 7792 }
7793 printk("%s\n", ixj_c_rcsid); 7793 printk(KERN_INFO "ixj driver initialized.\n");
7794 create_proc_read_entry ("ixj", 0, NULL, ixj_read_proc, NULL); 7794 create_proc_read_entry ("ixj", 0, NULL, ixj_read_proc, NULL);
7795 return probe; 7795 return probe;
7796} 7796}
diff --git a/drivers/telephony/ixj.h b/drivers/telephony/ixj.h
index 143818a56121..51e3f7f6597b 100644
--- a/drivers/telephony/ixj.h
+++ b/drivers/telephony/ixj.h
@@ -38,8 +38,6 @@
38 * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 38 * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
39 * 39 *
40 *****************************************************************************/ 40 *****************************************************************************/
41static char ixj_h_rcsid[] = "$Id: ixj.h,v 4.1 2001/08/04 14:49:27 craigs Exp $";
42
43#define IXJ_VERSION 3031 41#define IXJ_VERSION 3031
44 42
45#include <linux/version.h> 43#include <linux/version.h>
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index e12c5be1e0a3..f50aaf25c98e 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -431,7 +431,7 @@ nomem:
431 * (2) error, where io->status is a negative errno value. The number 431 * (2) error, where io->status is a negative errno value. The number
432 * of io->bytes transferred before the error is usually less 432 * of io->bytes transferred before the error is usually less
433 * than requested, and can be nonzero. 433 * than requested, and can be nonzero.
434 * (3) cancelation, a type of error with status -ECONNRESET that 434 * (3) cancellation, a type of error with status -ECONNRESET that
435 * is initiated by usb_sg_cancel(). 435 * is initiated by usb_sg_cancel().
436 * 436 *
437 * When this function returns, all memory allocated through usb_sg_init() or 437 * When this function returns, all memory allocated through usb_sg_init() or
@@ -1282,7 +1282,7 @@ static void release_interface(struct device *dev)
1282 * bus rwsem; usb device driver probe() methods cannot use this routine. 1282 * bus rwsem; usb device driver probe() methods cannot use this routine.
1283 * 1283 *
1284 * Returns zero on success, or else the status code returned by the 1284 * Returns zero on success, or else the status code returned by the
1285 * underlying call that failed. On succesful completion, each interface 1285 * underlying call that failed. On successful completion, each interface
1286 * in the original device configuration has been destroyed, and each one 1286 * in the original device configuration has been destroyed, and each one
1287 * in the new configuration has been probed by all relevant usb device 1287 * in the new configuration has been probed by all relevant usb device
1288 * drivers currently known to the kernel. 1288 * drivers currently known to the kernel.
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 16972159a57a..0faf18d511de 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -121,7 +121,7 @@ struct urb * usb_get_urb(struct urb *urb)
121 * describing that request to the USB subsystem. Request completion will 121 * describing that request to the USB subsystem. Request completion will
122 * be indicated later, asynchronously, by calling the completion handler. 122 * be indicated later, asynchronously, by calling the completion handler.
123 * The three types of completion are success, error, and unlink 123 * The three types of completion are success, error, and unlink
124 * (a software-induced fault, also called "request cancelation"). 124 * (a software-induced fault, also called "request cancellation").
125 * 125 *
126 * URBs may be submitted in interrupt context. 126 * URBs may be submitted in interrupt context.
127 * 127 *
@@ -170,7 +170,7 @@ struct urb * usb_get_urb(struct urb *urb)
170 * As of Linux 2.6, all USB endpoint transfer queues support depths greater 170 * As of Linux 2.6, all USB endpoint transfer queues support depths greater
171 * than one. This was previously a HCD-specific behavior, except for ISO 171 * than one. This was previously a HCD-specific behavior, except for ISO
172 * transfers. Non-isochronous endpoint queues are inactive during cleanup 172 * transfers. Non-isochronous endpoint queues are inactive during cleanup
173 * after faults (transfer errors or cancelation). 173 * after faults (transfer errors or cancellation).
174 * 174 *
175 * Reserved Bandwidth Transfers: 175 * Reserved Bandwidth Transfers:
176 * 176 *
@@ -395,7 +395,7 @@ int usb_submit_urb(struct urb *urb, int mem_flags)
395 * 395 *
396 * This routine cancels an in-progress request. URBs complete only 396 * This routine cancels an in-progress request. URBs complete only
397 * once per submission, and may be canceled only once per submission. 397 * once per submission, and may be canceled only once per submission.
398 * Successful cancelation means the requests's completion handler will 398 * Successful cancellation means the requests's completion handler will
399 * be called with a status code indicating that the request has been 399 * be called with a status code indicating that the request has been
400 * canceled (rather than any other code) and will quickly be removed 400 * canceled (rather than any other code) and will quickly be removed
401 * from host controller data structures. 401 * from host controller data structures.
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index c231b4bef314..25cf7e9eccfa 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -611,11 +611,10 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
611 611
612 if (add_hotplug_env_var(envp, num_envp, &i, 612 if (add_hotplug_env_var(envp, num_envp, &i,
613 buffer, buffer_size, &length, 613 buffer, buffer_size, &length,
614 "MODALIAS=usb:v%04Xp%04Xdl%04Xdh%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", 614 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
615 le16_to_cpu(usb_dev->descriptor.idVendor), 615 le16_to_cpu(usb_dev->descriptor.idVendor),
616 le16_to_cpu(usb_dev->descriptor.idProduct), 616 le16_to_cpu(usb_dev->descriptor.idProduct),
617 le16_to_cpu(usb_dev->descriptor.bcdDevice), 617 le16_to_cpu(usb_dev->descriptor.bcdDevice),
618 le16_to_cpu(usb_dev->descriptor.bcdDevice),
619 usb_dev->descriptor.bDeviceClass, 618 usb_dev->descriptor.bDeviceClass,
620 usb_dev->descriptor.bDeviceSubClass, 619 usb_dev->descriptor.bDeviceSubClass,
621 usb_dev->descriptor.bDeviceProtocol, 620 usb_dev->descriptor.bDeviceProtocol,
@@ -626,11 +625,10 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
626 } else { 625 } else {
627 if (add_hotplug_env_var(envp, num_envp, &i, 626 if (add_hotplug_env_var(envp, num_envp, &i,
628 buffer, buffer_size, &length, 627 buffer, buffer_size, &length,
629 "MODALIAS=usb:v%04Xp%04Xdl%04Xdh%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*", 628 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic*isc*ip*",
630 le16_to_cpu(usb_dev->descriptor.idVendor), 629 le16_to_cpu(usb_dev->descriptor.idVendor),
631 le16_to_cpu(usb_dev->descriptor.idProduct), 630 le16_to_cpu(usb_dev->descriptor.idProduct),
632 le16_to_cpu(usb_dev->descriptor.bcdDevice), 631 le16_to_cpu(usb_dev->descriptor.bcdDevice),
633 le16_to_cpu(usb_dev->descriptor.bcdDevice),
634 usb_dev->descriptor.bDeviceClass, 632 usb_dev->descriptor.bDeviceClass,
635 usb_dev->descriptor.bDeviceSubClass, 633 usb_dev->descriptor.bDeviceSubClass,
636 usb_dev->descriptor.bDeviceProtocol)) 634 usb_dev->descriptor.bDeviceProtocol))
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 3993156c2e82..3f783cbdc7c3 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -569,7 +569,7 @@ static const struct usb_cdc_ether_desc ether_desc = {
569 569
570/* include the status endpoint if we can, even where it's optional. 570/* include the status endpoint if we can, even where it's optional.
571 * use wMaxPacketSize big enough to fit CDC_NOTIFY_SPEED_CHANGE in one 571 * use wMaxPacketSize big enough to fit CDC_NOTIFY_SPEED_CHANGE in one
572 * packet, to simplify cancelation; and a big transfer interval, to 572 * packet, to simplify cancellation; and a big transfer interval, to
573 * waste less bandwidth. 573 * waste less bandwidth.
574 * 574 *
575 * some drivers (like Linux 2.4 cdc-ether!) "need" it to exist even 575 * some drivers (like Linux 2.4 cdc-ether!) "need" it to exist even
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 2cff67ccce45..1e5e6ddef787 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -275,7 +275,7 @@ static const char *CHIP;
275 * 275 *
276 * After opening, configure non-control endpoints. Then use normal 276 * After opening, configure non-control endpoints. Then use normal
277 * stream read() and write() requests; and maybe ioctl() to get more 277 * stream read() and write() requests; and maybe ioctl() to get more
278 * precise FIFO status when recovering from cancelation. 278 * precise FIFO status when recovering from cancellation.
279 */ 279 */
280 280
281static void epio_complete (struct usb_ep *ep, struct usb_request *req) 281static void epio_complete (struct usb_ep *ep, struct usb_request *req)
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 0def9f70e889..df75ab65a5ec 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -705,7 +705,7 @@ void nuke(struct lh7a40x_ep *ep, int status)
705 done(ep, req, status); 705 done(ep, req, status);
706 } 706 }
707 707
708 /* Disable IRQ if EP is enabled (has decriptor) */ 708 /* Disable IRQ if EP is enabled (has descriptor) */
709 if (ep->desc) 709 if (ep->desc)
710 pio_irq_disable(ep_index(ep)); 710 pio_irq_disable(ep_index(ep));
711} 711}
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index f1762ed6db63..4d591c764e38 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -240,7 +240,7 @@ struct gs_dev {
240 struct usb_ep *dev_notify_ep; /* address of notify endpoint */ 240 struct usb_ep *dev_notify_ep; /* address of notify endpoint */
241 struct usb_ep *dev_in_ep; /* address of in endpoint */ 241 struct usb_ep *dev_in_ep; /* address of in endpoint */
242 struct usb_ep *dev_out_ep; /* address of out endpoint */ 242 struct usb_ep *dev_out_ep; /* address of out endpoint */
243 struct usb_endpoint_descriptor /* desciptor of notify ep */ 243 struct usb_endpoint_descriptor /* descriptor of notify ep */
244 *dev_notify_ep_desc; 244 *dev_notify_ep_desc;
245 struct usb_endpoint_descriptor /* descriptor of in endpoint */ 245 struct usb_endpoint_descriptor /* descriptor of in endpoint */
246 *dev_in_ep_desc; 246 *dev_in_ep_desc;
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 84d2b93aca37..bc69bd7acebe 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -346,6 +346,22 @@ ehci_reboot (struct notifier_block *self, unsigned long code, void *null)
346 return 0; 346 return 0;
347} 347}
348 348
349static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
350{
351 unsigned port;
352
353 if (!HCS_PPC (ehci->hcs_params))
354 return;
355
356 ehci_dbg (ehci, "...power%s ports...\n", is_on ? "up" : "down");
357 for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; )
358 (void) ehci_hub_control(ehci_to_hcd(ehci),
359 is_on ? SetPortFeature : ClearPortFeature,
360 USB_PORT_FEAT_POWER,
361 port--, NULL, 0);
362 msleep(20);
363}
364
349 365
350/* called by khubd or root hub init threads */ 366/* called by khubd or root hub init threads */
351 367
@@ -362,8 +378,10 @@ static int ehci_hc_reset (struct usb_hcd *hcd)
362 dbg_hcs_params (ehci, "reset"); 378 dbg_hcs_params (ehci, "reset");
363 dbg_hcc_params (ehci, "reset"); 379 dbg_hcc_params (ehci, "reset");
364 380
381 /* cache this readonly data; minimize chip reads */
382 ehci->hcs_params = readl (&ehci->caps->hcs_params);
383
365#ifdef CONFIG_PCI 384#ifdef CONFIG_PCI
366 /* EHCI 0.96 and later may have "extended capabilities" */
367 if (hcd->self.controller->bus == &pci_bus_type) { 385 if (hcd->self.controller->bus == &pci_bus_type) {
368 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 386 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
369 387
@@ -383,9 +401,30 @@ static int ehci_hc_reset (struct usb_hcd *hcd)
383 break; 401 break;
384 } 402 }
385 403
404 /* optional debug port, normally in the first BAR */
405 temp = pci_find_capability (pdev, 0x0a);
406 if (temp) {
407 pci_read_config_dword(pdev, temp, &temp);
408 temp >>= 16;
409 if ((temp & (3 << 13)) == (1 << 13)) {
410 temp &= 0x1fff;
411 ehci->debug = hcd->regs + temp;
412 temp = readl (&ehci->debug->control);
413 ehci_info (ehci, "debug port %d%s\n",
414 HCS_DEBUG_PORT(ehci->hcs_params),
415 (temp & DBGP_ENABLED)
416 ? " IN USE"
417 : "");
418 if (!(temp & DBGP_ENABLED))
419 ehci->debug = NULL;
420 }
421 }
422
386 temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params)); 423 temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params));
387 } else 424 } else
388 temp = 0; 425 temp = 0;
426
427 /* EHCI 0.96 and later may have "extended capabilities" */
389 while (temp && count--) { 428 while (temp && count--) {
390 u32 cap; 429 u32 cap;
391 430
@@ -414,8 +453,7 @@ static int ehci_hc_reset (struct usb_hcd *hcd)
414 ehci_reset (ehci); 453 ehci_reset (ehci);
415#endif 454#endif
416 455
417 /* cache this readonly data; minimize PCI reads */ 456 ehci_port_power (ehci, 0);
418 ehci->hcs_params = readl (&ehci->caps->hcs_params);
419 457
420 /* at least the Genesys GL880S needs fixup here */ 458 /* at least the Genesys GL880S needs fixup here */
421 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); 459 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params);
@@ -657,16 +695,11 @@ done2:
657static void ehci_stop (struct usb_hcd *hcd) 695static void ehci_stop (struct usb_hcd *hcd)
658{ 696{
659 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 697 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
660 u8 rh_ports, port;
661 698
662 ehci_dbg (ehci, "stop\n"); 699 ehci_dbg (ehci, "stop\n");
663 700
664 /* Turn off port power on all root hub ports. */ 701 /* Turn off port power on all root hub ports. */
665 rh_ports = HCS_N_PORTS (ehci->hcs_params); 702 ehci_port_power (ehci, 0);
666 for (port = 1; port <= rh_ports; port++)
667 (void) ehci_hub_control(hcd,
668 ClearPortFeature, USB_PORT_FEAT_POWER,
669 port, NULL, 0);
670 703
671 /* no more interrupts ... */ 704 /* no more interrupts ... */
672 del_timer_sync (&ehci->watchdog); 705 del_timer_sync (&ehci->watchdog);
@@ -748,7 +781,6 @@ static int ehci_resume (struct usb_hcd *hcd)
748 unsigned port; 781 unsigned port;
749 struct usb_device *root = hcd->self.root_hub; 782 struct usb_device *root = hcd->self.root_hub;
750 int retval = -EINVAL; 783 int retval = -EINVAL;
751 int powerup = 0;
752 784
753 // maybe restore (PCI) FLADJ 785 // maybe restore (PCI) FLADJ
754 786
@@ -766,8 +798,6 @@ static int ehci_resume (struct usb_hcd *hcd)
766 up (&hcd->self.root_hub->serialize); 798 up (&hcd->self.root_hub->serialize);
767 break; 799 break;
768 } 800 }
769 if ((status & PORT_POWER) == 0)
770 powerup = 1;
771 if (!root->children [port]) 801 if (!root->children [port])
772 continue; 802 continue;
773 dbg_port (ehci, __FUNCTION__, port + 1, status); 803 dbg_port (ehci, __FUNCTION__, port + 1, status);
@@ -794,16 +824,9 @@ static int ehci_resume (struct usb_hcd *hcd)
794 retval = ehci_start (hcd); 824 retval = ehci_start (hcd);
795 825
796 /* here we "know" root ports should always stay powered; 826 /* here we "know" root ports should always stay powered;
797 * but some controllers may lost all power. 827 * but some controllers may lose all power.
798 */ 828 */
799 if (powerup) { 829 ehci_port_power (ehci, 1);
800 ehci_dbg (ehci, "...powerup ports...\n");
801 for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; )
802 (void) ehci_hub_control(hcd,
803 SetPortFeature, USB_PORT_FEAT_POWER,
804 port--, NULL, 0);
805 msleep(20);
806 }
807 } 830 }
808 831
809 return retval; 832 return retval;
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 2373537fabed..02fefab3501e 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -281,6 +281,8 @@ ehci_hub_descriptor (
281 temp = 0x0008; /* per-port overcurrent reporting */ 281 temp = 0x0008; /* per-port overcurrent reporting */
282 if (HCS_PPC (ehci->hcs_params)) 282 if (HCS_PPC (ehci->hcs_params))
283 temp |= 0x0001; /* per-port power control */ 283 temp |= 0x0001; /* per-port power control */
284 else
285 temp |= 0x0002; /* no power switching */
284#if 0 286#if 0
285// re-enable when we support USB_PORT_FEAT_INDICATOR below. 287// re-enable when we support USB_PORT_FEAT_INDICATOR below.
286 if (HCS_INDICATOR (ehci->hcs_params)) 288 if (HCS_INDICATOR (ehci->hcs_params))
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index e763a8399a75..4df498231752 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -47,6 +47,12 @@ struct ehci_stats {
47#define EHCI_MAX_ROOT_PORTS 15 /* see HCS_N_PORTS */ 47#define EHCI_MAX_ROOT_PORTS 15 /* see HCS_N_PORTS */
48 48
49struct ehci_hcd { /* one per controller */ 49struct ehci_hcd { /* one per controller */
50 /* glue to PCI and HCD framework */
51 struct ehci_caps __iomem *caps;
52 struct ehci_regs __iomem *regs;
53 struct ehci_dbg_port __iomem *debug;
54
55 __u32 hcs_params; /* cached register copy */
50 spinlock_t lock; 56 spinlock_t lock;
51 57
52 /* async schedule support */ 58 /* async schedule support */
@@ -84,11 +90,6 @@ struct ehci_hcd { /* one per controller */
84 90
85 unsigned is_tdi_rh_tt:1; /* TDI roothub with TT */ 91 unsigned is_tdi_rh_tt:1; /* TDI roothub with TT */
86 92
87 /* glue to PCI and HCD framework */
88 struct ehci_caps __iomem *caps;
89 struct ehci_regs __iomem *regs;
90 __u32 hcs_params; /* cached register copy */
91
92 /* irq statistics */ 93 /* irq statistics */
93#ifdef EHCI_STATS 94#ifdef EHCI_STATS
94 struct ehci_stats stats; 95 struct ehci_stats stats;
@@ -165,7 +166,7 @@ struct ehci_caps {
165 /* these fields are specified as 8 and 16 bit registers, 166 /* these fields are specified as 8 and 16 bit registers,
166 * but some hosts can't perform 8 or 16 bit PCI accesses. 167 * but some hosts can't perform 8 or 16 bit PCI accesses.
167 */ 168 */
168 u32 hc_capbase; 169 u32 hc_capbase;
169#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */ 170#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */
170#define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */ 171#define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */
171 u32 hcs_params; /* HCSPARAMS - offset 0x4 */ 172 u32 hcs_params; /* HCSPARAMS - offset 0x4 */
@@ -273,7 +274,7 @@ struct ehci_dbg_port {
273#define DBGP_ENABLED (1<<28) 274#define DBGP_ENABLED (1<<28)
274#define DBGP_DONE (1<<16) 275#define DBGP_DONE (1<<16)
275#define DBGP_INUSE (1<<10) 276#define DBGP_INUSE (1<<10)
276#define DBGP_ERRCODE(x) (((x)>>7)&0x0f) 277#define DBGP_ERRCODE(x) (((x)>>7)&0x07)
277# define DBGP_ERR_BAD 1 278# define DBGP_ERR_BAD 1
278# define DBGP_ERR_SIGNAL 2 279# define DBGP_ERR_SIGNAL 2
279#define DBGP_ERROR (1<<6) 280#define DBGP_ERROR (1<<6)
@@ -282,11 +283,11 @@ struct ehci_dbg_port {
282#define DBGP_LEN(x) (((x)>>0)&0x0f) 283#define DBGP_LEN(x) (((x)>>0)&0x0f)
283 u32 pids; 284 u32 pids;
284#define DBGP_PID_GET(x) (((x)>>16)&0xff) 285#define DBGP_PID_GET(x) (((x)>>16)&0xff)
285#define DBGP_PID_SET(data,tok) (((data)<<8)|(tok)); 286#define DBGP_PID_SET(data,tok) (((data)<<8)|(tok))
286 u32 data03; 287 u32 data03;
287 u32 data47; 288 u32 data47;
288 u32 address; 289 u32 address;
289#define DBGP_EPADDR(dev,ep) (((dev)<<8)|(ep)); 290#define DBGP_EPADDR(dev,ep) (((dev)<<8)|(ep))
290} __attribute__ ((packed)); 291} __attribute__ ((packed));
291 292
292/*-------------------------------------------------------------------------*/ 293/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index 376f8a034f65..d9883d774d3a 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -4329,7 +4329,7 @@ static int __init etrax_usb_hc_init(void)
4329 bus->bus_name="ETRAX 100LX"; 4329 bus->bus_name="ETRAX 100LX";
4330 bus->hcpriv = hc; 4330 bus->hcpriv = hc;
4331 4331
4332 /* Initalize RH to the default address. 4332 /* Initialize RH to the default address.
4333 And make sure that we have no status change indication */ 4333 And make sure that we have no status change indication */
4334 hc->rh.numports = 2; /* The RH has two ports */ 4334 hc->rh.numports = 2; /* The RH has two ports */
4335 hc->rh.devnum = 1; 4335 hc->rh.devnum = 1;
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index d309e292198e..a374b7692073 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -134,7 +134,7 @@ static void port_power(struct sl811 *sl811, int is_on)
134 134
135/* This is a PIO-only HCD. Queueing appends URBs to the endpoint's queue, 135/* This is a PIO-only HCD. Queueing appends URBs to the endpoint's queue,
136 * and may start I/O. Endpoint queues are scanned during completion irq 136 * and may start I/O. Endpoint queues are scanned during completion irq
137 * handlers (one per packet: ACK, NAK, faults, etc) and urb cancelation. 137 * handlers (one per packet: ACK, NAK, faults, etc) and urb cancellation.
138 * 138 *
139 * Using an external DMA engine to copy a packet at a time could work, 139 * Using an external DMA engine to copy a packet at a time could work,
140 * though setup/teardown costs may be too big to make it worthwhile. 140 * though setup/teardown costs may be too big to make it worthwhile.
@@ -738,7 +738,7 @@ retry:
738 } 738 }
739#endif 739#endif
740 740
741 /* port status seems wierd until after reset, so 741 /* port status seems weird until after reset, so
742 * force the reset and make khubd clean up later. 742 * force the reset and make khubd clean up later.
743 */ 743 */
744 sl811->port1 |= (1 << USB_PORT_FEAT_C_CONNECTION) 744 sl811->port1 |= (1 << USB_PORT_FEAT_C_CONNECTION)
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index 5791723e6083..a330a4b50e16 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -23,7 +23,7 @@
23 * 23 *
24 * 24 *
25 * The driver brings the USB functions of the MDC800 to Linux. 25 * The driver brings the USB functions of the MDC800 to Linux.
26 * To use the Camera you must support the USB Protocoll of the camera 26 * To use the Camera you must support the USB Protocol of the camera
27 * to the Kernel Node. 27 * to the Kernel Node.
28 * The Driver uses a misc device Node. Create it with : 28 * The Driver uses a misc device Node. Create it with :
29 * mknod /dev/mustek c 180 32 29 * mknod /dev/mustek c 180 32
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index cab89a970c7f..7d21a4f5c425 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -335,7 +335,7 @@ static int mts_scsi_abort (Scsi_Cmnd *srb)
335 335
336 mts_urb_abort(desc); 336 mts_urb_abort(desc);
337 337
338 return FAILURE; 338 return FAILED;
339} 339}
340 340
341static int mts_scsi_host_reset (Scsi_Cmnd *srb) 341static int mts_scsi_host_reset (Scsi_Cmnd *srb)
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index 2d76be62f4e0..94ce2a9ad50f 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -386,7 +386,7 @@ static int aiptek_convert_from_2s_complement(unsigned char c)
386 * convention above.) I therefore have taken over REL_MISC and ABS_MISC 386 * convention above.) I therefore have taken over REL_MISC and ABS_MISC
387 * (for relative and absolute reports, respectively) for communicating 387 * (for relative and absolute reports, respectively) for communicating
388 * Proximity. Why two events? I thought it interesting to know if the 388 * Proximity. Why two events? I thought it interesting to know if the
389 * Proximity event occured while the tablet was in absolute or relative 389 * Proximity event occurred while the tablet was in absolute or relative
390 * mode. 390 * mode.
391 * 391 *
392 * Other tablets use the notion of a certain minimum stylus pressure 392 * Other tablets use the notion of a certain minimum stylus pressure
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index 355add5c29f5..860df26323b1 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -619,7 +619,7 @@ static void ati_remote_delete(struct ati_remote *ati_remote)
619 619
620 if (ati_remote->outbuf) 620 if (ati_remote->outbuf)
621 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE, 621 usb_buffer_free(ati_remote->udev, DATA_BUFSIZE,
622 ati_remote->inbuf, ati_remote->outbuf_dma); 622 ati_remote->outbuf, ati_remote->outbuf_dma);
623 623
624 if (ati_remote->irq_urb) 624 if (ati_remote->irq_urb)
625 usb_free_urb(ati_remote->irq_urb); 625 usb_free_urb(ati_remote->irq_urb);
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index 6b45a66d58c1..ab1a2a30ce7c 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -32,7 +32,7 @@
32 * Changed reset from standard USB dev reset to vendor reset 32 * Changed reset from standard USB dev reset to vendor reset
33 * Changed data sent to host from compensated to raw coordinates 33 * Changed data sent to host from compensated to raw coordinates
34 * Eliminated vendor/product module params 34 * Eliminated vendor/product module params
35 * Performed multiple successfull tests with an EXII-5010UC 35 * Performed multiple successful tests with an EXII-5010UC
36 * 36 *
37 * 1.5 02/27/2005 ddstreet@ieee.org 37 * 1.5 02/27/2005 ddstreet@ieee.org
38 * Added module parameter to select raw or hw-calibrated coordinate reporting 38 * Added module parameter to select raw or hw-calibrated coordinate reporting
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index 01514b0551b8..7038fb9d1ced 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.c
@@ -133,7 +133,8 @@ resubmit:
133 kbd->usbdev->devpath, i); 133 kbd->usbdev->devpath, i);
134} 134}
135 135
136int usb_kbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 136static int usb_kbd_event(struct input_dev *dev, unsigned int type,
137 unsigned int code, int value)
137{ 138{
138 struct usb_kbd *kbd = dev->private; 139 struct usb_kbd *kbd = dev->private;
139 140
diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c
index d6051822416e..036c485d1d1e 100644
--- a/drivers/usb/media/ov511.c
+++ b/drivers/usb/media/ov511.c
@@ -5041,7 +5041,7 @@ ov6xx0_configure(struct usb_ov511 *ov)
5041 { OV511_I2C_BUS, 0x2a, 0x04 }, /* Disable framerate adjust */ 5041 { OV511_I2C_BUS, 0x2a, 0x04 }, /* Disable framerate adjust */
5042// { OV511_I2C_BUS, 0x2b, 0xac }, /* Framerate; Set 2a[7] first */ 5042// { OV511_I2C_BUS, 0x2b, 0xac }, /* Framerate; Set 2a[7] first */
5043 { OV511_I2C_BUS, 0x2d, 0x99 }, 5043 { OV511_I2C_BUS, 0x2d, 0x99 },
5044 { OV511_I2C_BUS, 0x33, 0xa0 }, /* Color Procesing Parameter */ 5044 { OV511_I2C_BUS, 0x33, 0xa0 }, /* Color Processing Parameter */
5045 { OV511_I2C_BUS, 0x34, 0xd2 }, /* Max A/D range */ 5045 { OV511_I2C_BUS, 0x34, 0xd2 }, /* Max A/D range */
5046 { OV511_I2C_BUS, 0x38, 0x8b }, 5046 { OV511_I2C_BUS, 0x38, 0x8b },
5047 { OV511_I2C_BUS, 0x39, 0x40 }, 5047 { OV511_I2C_BUS, 0x39, 0x40 },
diff --git a/drivers/usb/media/pwc/pwc-ctrl.c b/drivers/usb/media/pwc/pwc-ctrl.c
index 26aa914bc541..42ec468d52d6 100644
--- a/drivers/usb/media/pwc/pwc-ctrl.c
+++ b/drivers/usb/media/pwc/pwc-ctrl.c
@@ -418,6 +418,44 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr
418 418
419 419
420 420
421static void pwc_set_image_buffer_size(struct pwc_device *pdev)
422{
423 int i, factor = 0, filler = 0;
424
425 /* for PALETTE_YUV420P */
426 switch(pdev->vpalette)
427 {
428 case VIDEO_PALETTE_YUV420P:
429 factor = 6;
430 filler = 128;
431 break;
432 case VIDEO_PALETTE_RAW:
433 factor = 6; /* can be uncompressed YUV420P */
434 filler = 0;
435 break;
436 }
437
438 /* Set sizes in bytes */
439 pdev->image.size = pdev->image.x * pdev->image.y * factor / 4;
440 pdev->view.size = pdev->view.x * pdev->view.y * factor / 4;
441
442 /* Align offset, or you'll get some very weird results in
443 YUV420 mode... x must be multiple of 4 (to get the Y's in
444 place), and y even (or you'll mixup U & V). This is less of a
445 problem for YUV420P.
446 */
447 pdev->offset.x = ((pdev->view.x - pdev->image.x) / 2) & 0xFFFC;
448 pdev->offset.y = ((pdev->view.y - pdev->image.y) / 2) & 0xFFFE;
449
450 /* Fill buffers with gray or black */
451 for (i = 0; i < MAX_IMAGES; i++) {
452 if (pdev->image_ptr[i] != NULL)
453 memset(pdev->image_ptr[i], filler, pdev->view.size);
454 }
455}
456
457
458
421/** 459/**
422 @pdev: device structure 460 @pdev: device structure
423 @width: viewport width 461 @width: viewport width
@@ -475,44 +513,6 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
475} 513}
476 514
477 515
478void pwc_set_image_buffer_size(struct pwc_device *pdev)
479{
480 int i, factor = 0, filler = 0;
481
482 /* for PALETTE_YUV420P */
483 switch(pdev->vpalette)
484 {
485 case VIDEO_PALETTE_YUV420P:
486 factor = 6;
487 filler = 128;
488 break;
489 case VIDEO_PALETTE_RAW:
490 factor = 6; /* can be uncompressed YUV420P */
491 filler = 0;
492 break;
493 }
494
495 /* Set sizes in bytes */
496 pdev->image.size = pdev->image.x * pdev->image.y * factor / 4;
497 pdev->view.size = pdev->view.x * pdev->view.y * factor / 4;
498
499 /* Align offset, or you'll get some very weird results in
500 YUV420 mode... x must be multiple of 4 (to get the Y's in
501 place), and y even (or you'll mixup U & V). This is less of a
502 problem for YUV420P.
503 */
504 pdev->offset.x = ((pdev->view.x - pdev->image.x) / 2) & 0xFFFC;
505 pdev->offset.y = ((pdev->view.y - pdev->image.y) / 2) & 0xFFFE;
506
507 /* Fill buffers with gray or black */
508 for (i = 0; i < MAX_IMAGES; i++) {
509 if (pdev->image_ptr[i] != NULL)
510 memset(pdev->image_ptr[i], filler, pdev->view.size);
511 }
512}
513
514
515
516/* BRIGHTNESS */ 516/* BRIGHTNESS */
517 517
518int pwc_get_brightness(struct pwc_device *pdev) 518int pwc_get_brightness(struct pwc_device *pdev)
@@ -949,7 +949,7 @@ int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value)
949 return SendControlMsg(SET_STATUS_CTL, LED_FORMATTER, 2); 949 return SendControlMsg(SET_STATUS_CTL, LED_FORMATTER, 2);
950} 950}
951 951
952int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value) 952static int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value)
953{ 953{
954 unsigned char buf[2]; 954 unsigned char buf[2];
955 int ret; 955 int ret;
@@ -1100,7 +1100,7 @@ static inline int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt)
1100 unsigned char buf[4]; 1100 unsigned char buf[4];
1101 1101
1102 /* set new relative angle; angles are expressed in degrees * 100, 1102 /* set new relative angle; angles are expressed in degrees * 100,
1103 but cam as .5 degree resolution, hence devide by 200. Also 1103 but cam as .5 degree resolution, hence divide by 200. Also
1104 the angle must be multiplied by 64 before it's send to 1104 the angle must be multiplied by 64 before it's send to
1105 the cam (??) 1105 the cam (??)
1106 */ 1106 */
diff --git a/drivers/usb/media/pwc/pwc-if.c b/drivers/usb/media/pwc/pwc-if.c
index 100a5a4f03a3..cca47f480a8b 100644
--- a/drivers/usb/media/pwc/pwc-if.c
+++ b/drivers/usb/media/pwc/pwc-if.c
@@ -129,7 +129,7 @@ static int default_mbufs = 2; /* Default number of mmap() buffers */
129 int pwc_trace = TRACE_MODULE | TRACE_FLOW | TRACE_PWCX; 129 int pwc_trace = TRACE_MODULE | TRACE_FLOW | TRACE_PWCX;
130static int power_save = 0; 130static int power_save = 0;
131static int led_on = 100, led_off = 0; /* defaults to LED that is on while in use */ 131static int led_on = 100, led_off = 0; /* defaults to LED that is on while in use */
132 int pwc_preferred_compression = 2; /* 0..3 = uncompressed..high */ 132static int pwc_preferred_compression = 2; /* 0..3 = uncompressed..high */
133static struct { 133static struct {
134 int type; 134 int type;
135 char serial_number[30]; 135 char serial_number[30];
@@ -272,7 +272,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
272 return -ENXIO; 272 return -ENXIO;
273 } 273 }
274#endif 274#endif
275 /* Allocate Isochronuous pipe buffers */ 275 /* Allocate Isochronous pipe buffers */
276 for (i = 0; i < MAX_ISO_BUFS; i++) { 276 for (i = 0; i < MAX_ISO_BUFS; i++) {
277 if (pdev->sbuf[i].data == NULL) { 277 if (pdev->sbuf[i].data == NULL) {
278 kbuf = kmalloc(ISO_BUFFER_SIZE, GFP_KERNEL); 278 kbuf = kmalloc(ISO_BUFFER_SIZE, GFP_KERNEL);
@@ -322,7 +322,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
322 case 730: 322 case 730:
323 case 740: 323 case 740:
324 case 750: 324 case 750:
325 Trace(TRACE_MEMORY,"private_data(%Zd)\n",sizeof(struct pwc_dec23_private)); 325 Trace(TRACE_MEMORY,"private_data(%zu)\n",sizeof(struct pwc_dec23_private));
326 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); /* Timon & Kiara */ 326 kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); /* Timon & Kiara */
327 break; 327 break;
328 case 645: 328 case 645:
@@ -850,7 +850,7 @@ static int pwc_isoc_init(struct pwc_device *pdev)
850 850
851 if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) { 851 if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) {
852 Err("Failed to find packet size for video endpoint in current alternate setting.\n"); 852 Err("Failed to find packet size for video endpoint in current alternate setting.\n");
853 return -ENFILE; /* Odd error, that should be noticable */ 853 return -ENFILE; /* Odd error, that should be noticeable */
854 } 854 }
855 855
856 /* Set alternate interface */ 856 /* Set alternate interface */
@@ -1179,7 +1179,7 @@ static ssize_t pwc_video_read(struct file *file, char __user * buf,
1179 DECLARE_WAITQUEUE(wait, current); 1179 DECLARE_WAITQUEUE(wait, current);
1180 int bytes_to_read; 1180 int bytes_to_read;
1181 1181
1182 Trace(TRACE_READ, "video_read(0x%p, %p, %Zd) called.\n", vdev, buf, count); 1182 Trace(TRACE_READ, "video_read(0x%p, %p, %zu) called.\n", vdev, buf, count);
1183 if (vdev == NULL) 1183 if (vdev == NULL)
1184 return -EFAULT; 1184 return -EFAULT;
1185 pdev = vdev->priv; 1185 pdev = vdev->priv;
@@ -2128,7 +2128,7 @@ static int __init usb_pwc_init(void)
2128 if (leds[1] >= 0) 2128 if (leds[1] >= 0)
2129 led_off = leds[1]; 2129 led_off = leds[1];
2130 2130
2131 /* Big device node whoopla. Basicly, it allows you to assign a 2131 /* Big device node whoopla. Basically, it allows you to assign a
2132 device node (/dev/videoX) to a camera, based on its type 2132 device node (/dev/videoX) to a camera, based on its type
2133 & serial number. The format is [type[.serialnumber]:]node. 2133 & serial number. The format is [type[.serialnumber]:]node.
2134 2134
diff --git a/drivers/usb/media/pwc/pwc-ioctl.h b/drivers/usb/media/pwc/pwc-ioctl.h
index 65805eaa9a1c..5f9cb08bc02e 100644
--- a/drivers/usb/media/pwc/pwc-ioctl.h
+++ b/drivers/usb/media/pwc/pwc-ioctl.h
@@ -75,7 +75,7 @@
75#define PWC_FPS_SNAPSHOT 0x00400000 75#define PWC_FPS_SNAPSHOT 0x00400000
76 76
77 77
78/* structure for transfering x & y coordinates */ 78/* structure for transferring x & y coordinates */
79struct pwc_coord 79struct pwc_coord
80{ 80{
81 int x, y; /* guess what */ 81 int x, y; /* guess what */
diff --git a/drivers/usb/media/pwc/pwc.h b/drivers/usb/media/pwc/pwc.h
index 53b516d29cf5..267869dab185 100644
--- a/drivers/usb/media/pwc/pwc.h
+++ b/drivers/usb/media/pwc/pwc.h
@@ -226,9 +226,8 @@ struct pwc_device
226extern "C" { 226extern "C" {
227#endif 227#endif
228 228
229/* Global variables */ 229/* Global variable */
230extern int pwc_trace; 230extern int pwc_trace;
231extern int pwc_preferred_compression;
232 231
233/** functions in pwc-if.c */ 232/** functions in pwc-if.c */
234int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_fps, int new_compression, int new_snapshot); 233int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_fps, int new_compression, int new_snapshot);
@@ -243,8 +242,6 @@ void pwc_construct(struct pwc_device *pdev);
243/** Functions in pwc-ctrl.c */ 242/** Functions in pwc-ctrl.c */
244/* Request a certain video mode. Returns < 0 if not possible */ 243/* Request a certain video mode. Returns < 0 if not possible */
245extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot); 244extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot);
246/* Calculate the number of bytes per image (not frame) */
247extern void pwc_set_image_buffer_size(struct pwc_device *pdev);
248 245
249/* Various controls; should be obvious. Value 0..65535, or < 0 on error */ 246/* Various controls; should be obvious. Value 0..65535, or < 0 on error */
250extern int pwc_get_brightness(struct pwc_device *pdev); 247extern int pwc_get_brightness(struct pwc_device *pdev);
@@ -256,7 +253,6 @@ extern int pwc_set_gamma(struct pwc_device *pdev, int value);
256extern int pwc_get_saturation(struct pwc_device *pdev); 253extern int pwc_get_saturation(struct pwc_device *pdev);
257extern int pwc_set_saturation(struct pwc_device *pdev, int value); 254extern int pwc_set_saturation(struct pwc_device *pdev, int value);
258extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value); 255extern int pwc_set_leds(struct pwc_device *pdev, int on_value, int off_value);
259extern int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value);
260extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor); 256extern int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor);
261 257
262/* Power down or up the camera; not supported by all models */ 258/* Power down or up the camera; not supported by all models */
diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c
index 898401cf7dcc..31d57400d5be 100644
--- a/drivers/usb/media/sn9c102_core.c
+++ b/drivers/usb/media/sn9c102_core.c
@@ -429,7 +429,7 @@ sn9c102_i2c_try_read(struct sn9c102_device* cam,
429} 429}
430 430
431 431
432int 432static int
433sn9c102_i2c_try_write(struct sn9c102_device* cam, 433sn9c102_i2c_try_write(struct sn9c102_device* cam,
434 struct sn9c102_sensor* sensor, u8 address, u8 value) 434 struct sn9c102_sensor* sensor, u8 address, u8 value)
435{ 435{
@@ -785,7 +785,7 @@ static int sn9c102_stop_transfer(struct sn9c102_device* cam)
785} 785}
786 786
787 787
788int sn9c102_stream_interrupt(struct sn9c102_device* cam) 788static int sn9c102_stream_interrupt(struct sn9c102_device* cam)
789{ 789{
790 int err = 0; 790 int err = 0;
791 791
diff --git a/drivers/usb/media/sn9c102_sensor.h b/drivers/usb/media/sn9c102_sensor.h
index 16f7483559f0..6a7adebcb4bf 100644
--- a/drivers/usb/media/sn9c102_sensor.h
+++ b/drivers/usb/media/sn9c102_sensor.h
@@ -145,8 +145,6 @@ static const struct usb_device_id sn9c102_id_table[] = { \
145*/ 145*/
146 146
147/* The "try" I2C I/O versions are used when probing the sensor */ 147/* The "try" I2C I/O versions are used when probing the sensor */
148extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*,
149 u8 address, u8 value);
150extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*, 148extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
151 u8 address); 149 u8 address);
152 150
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index dd4580cb57e0..7d06105763d4 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -859,7 +859,7 @@ static int tower_probe (struct usb_interface *interface, const struct usb_device
859 info ("udev is NULL."); 859 info ("udev is NULL.");
860 } 860 }
861 861
862 /* allocate memory for our device state and intialize it */ 862 /* allocate memory for our device state and initialize it */
863 863
864 dev = kmalloc (sizeof(struct lego_usb_tower), GFP_KERNEL); 864 dev = kmalloc (sizeof(struct lego_usb_tower), GFP_KERNEL);
865 865
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 57b82d53a940..2fd12264fd53 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -983,7 +983,7 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
983 msgcount++; 983 msgcount++;
984 if (msgcount < 500) 984 if (msgcount < 500)
985 printk(KERN_ERR 985 printk(KERN_ERR
986 "sisusbvga[%d]: Wrote %Zd of " 986 "sisusbvga[%d]: Wrote %zd of "
987 "%d bytes, error %d\n", 987 "%d bytes, error %d\n",
988 sisusb->minor, *bytes_written, 988 sisusb->minor, *bytes_written,
989 length, ret); 989 length, ret);
@@ -3105,6 +3105,7 @@ static void sisusb_disconnect(struct usb_interface *intf)
3105static struct usb_device_id sisusb_table [] = { 3105static struct usb_device_id sisusb_table [] = {
3106 { USB_DEVICE(0x0711, 0x0900) }, 3106 { USB_DEVICE(0x0711, 0x0900) },
3107 { USB_DEVICE(0x182d, 0x021c) }, 3107 { USB_DEVICE(0x182d, 0x021c) },
3108 { USB_DEVICE(0x182d, 0x0269) },
3108 { } 3109 { }
3109}; 3110};
3110 3111
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index a02be795d63e..d976790312aa 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -1388,11 +1388,11 @@ static int pegasus_resume (struct usb_interface *intf)
1388 if (netif_running(pegasus->net)) { 1388 if (netif_running(pegasus->net)) {
1389 pegasus->rx_urb->status = 0; 1389 pegasus->rx_urb->status = 0;
1390 pegasus->rx_urb->actual_length = 0; 1390 pegasus->rx_urb->actual_length = 0;
1391 read_bulk_callback(pegasus->rx_urb, 0); 1391 read_bulk_callback(pegasus->rx_urb, NULL);
1392 1392
1393 pegasus->intr_urb->status = 0; 1393 pegasus->intr_urb->status = 0;
1394 pegasus->intr_urb->actual_length = 0; 1394 pegasus->intr_urb->actual_length = 0;
1395 intr_callback(pegasus->intr_urb, 0); 1395 intr_callback(pegasus->intr_urb, NULL);
1396 1396
1397 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, 1397 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check,
1398 CARRIER_CHECK_DELAY); 1398 CARRIER_CHECK_DELAY);
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index bbaef047d532..f6bc6b3b333c 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * USB Networking Links 2 * USB Networking Links
3 * Copyright (C) 2000-2003 by David Brownell <dbrownell@users.sourceforge.net> 3 * Copyright (C) 2000-2005 by David Brownell <dbrownell@users.sourceforge.net>
4 * Copyright (C) 2002 Pavel Machek <pavel@ucw.cz> 4 * Copyright (C) 2002 Pavel Machek <pavel@ucw.cz>
5 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com> 5 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
6 * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net> 6 * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
@@ -210,6 +210,7 @@ struct usbnet {
210# define EVENT_RX_HALT 1 210# define EVENT_RX_HALT 1
211# define EVENT_RX_MEMORY 2 211# define EVENT_RX_MEMORY 2
212# define EVENT_STS_SPLIT 3 212# define EVENT_STS_SPLIT 3
213# define EVENT_LINK_RESET 4
213}; 214};
214 215
215// device-specific info used by the driver 216// device-specific info used by the driver
@@ -243,6 +244,9 @@ struct driver_info {
243 /* for status polling */ 244 /* for status polling */
244 void (*status)(struct usbnet *, struct urb *); 245 void (*status)(struct usbnet *, struct urb *);
245 246
247 /* link reset handling, called from defer_kevent */
248 int (*link_reset)(struct usbnet *);
249
246 /* fixup rx packet (strip framing) */ 250 /* fixup rx packet (strip framing) */
247 int (*rx_fixup)(struct usbnet *dev, struct sk_buff *skb); 251 int (*rx_fixup)(struct usbnet *dev, struct sk_buff *skb);
248 252
@@ -304,6 +308,7 @@ static void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *);
304static u32 usbnet_get_link (struct net_device *); 308static u32 usbnet_get_link (struct net_device *);
305static u32 usbnet_get_msglevel (struct net_device *); 309static u32 usbnet_get_msglevel (struct net_device *);
306static void usbnet_set_msglevel (struct net_device *, u32); 310static void usbnet_set_msglevel (struct net_device *, u32);
311static void defer_kevent (struct usbnet *, int);
307 312
308/* mostly for PDA style devices, which are always connected if present */ 313/* mostly for PDA style devices, which are always connected if present */
309static int always_connected (struct usbnet *dev) 314static int always_connected (struct usbnet *dev)
@@ -426,7 +431,7 @@ static void skb_return (struct usbnet *dev, struct sk_buff *skb)
426 dev->stats.rx_bytes += skb->len; 431 dev->stats.rx_bytes += skb->len;
427 432
428 if (netif_msg_rx_status (dev)) 433 if (netif_msg_rx_status (dev))
429 devdbg (dev, "< rx, len %zd, type 0x%x", 434 devdbg (dev, "< rx, len %zu, type 0x%x",
430 skb->len + sizeof (struct ethhdr), skb->protocol); 435 skb->len + sizeof (struct ethhdr), skb->protocol);
431 memset (skb->cb, 0, sizeof (struct skb_data)); 436 memset (skb->cb, 0, sizeof (struct skb_data));
432 status = netif_rx (skb); 437 status = netif_rx (skb);
@@ -501,6 +506,7 @@ static const struct driver_info an2720_info = {
501#define AX_CMD_WRITE_MULTI_FILTER 0x16 506#define AX_CMD_WRITE_MULTI_FILTER 0x16
502#define AX_CMD_READ_NODE_ID 0x17 507#define AX_CMD_READ_NODE_ID 0x17
503#define AX_CMD_READ_PHY_ID 0x19 508#define AX_CMD_READ_PHY_ID 0x19
509#define AX_CMD_READ_MEDIUM_STATUS 0x1a
504#define AX_CMD_WRITE_MEDIUM_MODE 0x1b 510#define AX_CMD_WRITE_MEDIUM_MODE 0x1b
505#define AX_CMD_READ_MONITOR_MODE 0x1c 511#define AX_CMD_READ_MONITOR_MODE 0x1c
506#define AX_CMD_WRITE_MONITOR_MODE 0x1d 512#define AX_CMD_WRITE_MONITOR_MODE 0x1d
@@ -515,11 +521,14 @@ static const struct driver_info an2720_info = {
515#define AX_MONITOR_MAGIC 0x04 521#define AX_MONITOR_MAGIC 0x04
516#define AX_MONITOR_HSFS 0x10 522#define AX_MONITOR_HSFS 0x10
517 523
524/* AX88172 Medium Status Register values */
525#define AX_MEDIUM_FULL_DUPLEX 0x02
526#define AX_MEDIUM_TX_ABORT_ALLOW 0x04
527#define AX_MEDIUM_FLOW_CONTROL_EN 0x10
528
518#define AX_MCAST_FILTER_SIZE 8 529#define AX_MCAST_FILTER_SIZE 8
519#define AX_MAX_MCAST 64 530#define AX_MAX_MCAST 64
520 531
521#define AX_INTERRUPT_BUFSIZE 8
522
523#define AX_EEPROM_LEN 0x40 532#define AX_EEPROM_LEN 0x40
524 533
525#define AX_SWRESET_CLEAR 0x00 534#define AX_SWRESET_CLEAR 0x00
@@ -535,15 +544,33 @@ static const struct driver_info an2720_info = {
535#define AX88772_IPG1_DEFAULT 0x0c 544#define AX88772_IPG1_DEFAULT 0x0c
536#define AX88772_IPG2_DEFAULT 0x12 545#define AX88772_IPG2_DEFAULT 0x12
537 546
547#define AX88772_MEDIUM_FULL_DUPLEX 0x0002
548#define AX88772_MEDIUM_RESERVED 0x0004
549#define AX88772_MEDIUM_RX_FC_ENABLE 0x0010
550#define AX88772_MEDIUM_TX_FC_ENABLE 0x0020
551#define AX88772_MEDIUM_PAUSE_FORMAT 0x0080
552#define AX88772_MEDIUM_RX_ENABLE 0x0100
553#define AX88772_MEDIUM_100MB 0x0200
554#define AX88772_MEDIUM_DEFAULT \
555 (AX88772_MEDIUM_FULL_DUPLEX | AX88772_MEDIUM_RX_FC_ENABLE | \
556 AX88772_MEDIUM_TX_FC_ENABLE | AX88772_MEDIUM_100MB | \
557 AX88772_MEDIUM_RESERVED | AX88772_MEDIUM_RX_ENABLE )
558
538#define AX_EEPROM_MAGIC 0xdeadbeef 559#define AX_EEPROM_MAGIC 0xdeadbeef
539 560
540/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ 561/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
541struct ax8817x_data { 562struct ax8817x_data {
542 u8 multi_filter[AX_MCAST_FILTER_SIZE]; 563 u8 multi_filter[AX_MCAST_FILTER_SIZE];
543 struct urb *int_urb;
544 u8 *int_buf;
545}; 564};
546 565
566struct ax88172_int_data {
567 u16 res1;
568 u8 link;
569 u16 res2;
570 u8 status;
571 u16 res3;
572} __attribute__ ((packed));
573
547static int ax8817x_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 574static int ax8817x_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
548 u16 size, void *data) 575 u16 size, void *data)
549{ 576{
@@ -586,25 +613,23 @@ static void ax8817x_async_cmd_callback(struct urb *urb, struct pt_regs *regs)
586 usb_free_urb(urb); 613 usb_free_urb(urb);
587} 614}
588 615
589static void ax8817x_interrupt_complete(struct urb *urb, struct pt_regs *regs) 616static void ax8817x_status(struct usbnet *dev, struct urb *urb)
590{ 617{
591 struct usbnet *dev = (struct usbnet *)urb->context; 618 struct ax88172_int_data *event;
592 struct ax8817x_data *data = (struct ax8817x_data *)&dev->data;
593 int link; 619 int link;
594 620
595 if (urb->status < 0) { 621 if (urb->actual_length < 8)
596 devdbg(dev,"ax8817x_interrupt_complete() failed with %d", 622 return;
597 urb->status); 623
598 } else { 624 event = urb->transfer_buffer;
599 link = data->int_buf[2] & 0x01; 625 link = event->link & 0x01;
600 if (netif_carrier_ok(dev->net) != link) { 626 if (netif_carrier_ok(dev->net) != link) {
601 if (link) 627 if (link) {
602 netif_carrier_on(dev->net); 628 netif_carrier_on(dev->net);
603 else 629 defer_kevent (dev, EVENT_LINK_RESET );
604 netif_carrier_off(dev->net); 630 } else
605 devdbg(dev, "ax8817x - Link Status is: %d", link); 631 netif_carrier_off(dev->net);
606 } 632 devdbg(dev, "ax8817x - Link Status is: %d", link);
607 usb_submit_urb(data->int_urb, GFP_ATOMIC);
608 } 633 }
609} 634}
610 635
@@ -711,6 +736,20 @@ static void ax8817x_mdio_write(struct net_device *netdev, int phy_id, int loc, i
711 ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf); 736 ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf);
712} 737}
713 738
739static int ax88172_link_reset(struct usbnet *dev)
740{
741 u16 lpa;
742 u8 mode;
743
744 mode = AX_MEDIUM_TX_ABORT_ALLOW | AX_MEDIUM_FLOW_CONTROL_EN;
745 lpa = ax8817x_mdio_read(dev->net, dev->mii.phy_id, MII_LPA);
746 if (lpa & LPA_DUPLEX)
747 mode |= AX_MEDIUM_FULL_DUPLEX;
748 ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL);
749
750 return 0;
751}
752
714static void ax8817x_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) 753static void ax8817x_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
715{ 754{
716 struct usbnet *dev = netdev_priv(net); 755 struct usbnet *dev = netdev_priv(net);
@@ -824,35 +863,13 @@ static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
824 void *buf; 863 void *buf;
825 int i; 864 int i;
826 unsigned long gpio_bits = dev->driver_info->data; 865 unsigned long gpio_bits = dev->driver_info->data;
827 struct ax8817x_data *data = (struct ax8817x_data *)dev->data;
828 866
829 get_endpoints(dev,intf); 867 get_endpoints(dev,intf);
830 868
831 if ((data->int_urb = usb_alloc_urb (0, GFP_KERNEL)) == NULL) {
832 dbg ("%s: cannot allocate interrupt URB",
833 dev->net->name);
834 ret = -ENOMEM;
835 goto out1;
836 }
837
838 if ((data->int_buf = kmalloc(AX_INTERRUPT_BUFSIZE, GFP_KERNEL)) == NULL) {
839 dbg ("%s: cannot allocate memory for interrupt buffer",
840 dev->net->name);
841 ret = -ENOMEM;
842 goto out1;
843 }
844 memset(data->int_buf, 0, AX_INTERRUPT_BUFSIZE);
845
846 usb_fill_int_urb (data->int_urb, dev->udev,
847 usb_rcvintpipe (dev->udev, 1),
848 data->int_buf, AX_INTERRUPT_BUFSIZE,
849 ax8817x_interrupt_complete, dev,
850 dev->udev->speed == USB_SPEED_HIGH ? 8 : 100);
851
852 buf = kmalloc(ETH_ALEN, GFP_KERNEL); 869 buf = kmalloc(ETH_ALEN, GFP_KERNEL);
853 if(!buf) { 870 if(!buf) {
854 ret = -ENOMEM; 871 ret = -ENOMEM;
855 goto out2; 872 goto out1;
856 } 873 }
857 874
858 /* Toggle the GPIOs in a manufacturer/model specific way */ 875 /* Toggle the GPIOs in a manufacturer/model specific way */
@@ -860,32 +877,32 @@ static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
860 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS, 877 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
861 (gpio_bits >> (i * 8)) & 0xff, 0, 0, 878 (gpio_bits >> (i * 8)) & 0xff, 0, 0,
862 buf)) < 0) 879 buf)) < 0)
863 goto out3; 880 goto out2;
864 msleep(5); 881 msleep(5);
865 } 882 }
866 883
867 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x80, 0, 0, buf)) < 0) { 884 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x80, 0, 0, buf)) < 0) {
868 dbg("send AX_CMD_WRITE_RX_CTL failed: %d", ret); 885 dbg("send AX_CMD_WRITE_RX_CTL failed: %d", ret);
869 goto out3; 886 goto out2;
870 } 887 }
871 888
872 /* Get the MAC address */ 889 /* Get the MAC address */
873 memset(buf, 0, ETH_ALEN); 890 memset(buf, 0, ETH_ALEN);
874 if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, 6, buf)) < 0) { 891 if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, 6, buf)) < 0) {
875 dbg("read AX_CMD_READ_NODE_ID failed: %d", ret); 892 dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
876 goto out3; 893 goto out2;
877 } 894 }
878 memcpy(dev->net->dev_addr, buf, ETH_ALEN); 895 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
879 896
880 /* Get the PHY id */ 897 /* Get the PHY id */
881 if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf)) < 0) { 898 if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf)) < 0) {
882 dbg("error on read AX_CMD_READ_PHY_ID: %02x", ret); 899 dbg("error on read AX_CMD_READ_PHY_ID: %02x", ret);
883 goto out3; 900 goto out2;
884 } else if (ret < 2) { 901 } else if (ret < 2) {
885 /* this should always return 2 bytes */ 902 /* this should always return 2 bytes */
886 dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x", ret); 903 dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x", ret);
887 ret = -EIO; 904 ret = -EIO;
888 goto out3; 905 goto out2;
889 } 906 }
890 907
891 /* Initialize MII structure */ 908 /* Initialize MII structure */
@@ -899,36 +916,18 @@ static int ax8817x_bind(struct usbnet *dev, struct usb_interface *intf)
899 dev->net->set_multicast_list = ax8817x_set_multicast; 916 dev->net->set_multicast_list = ax8817x_set_multicast;
900 dev->net->ethtool_ops = &ax8817x_ethtool_ops; 917 dev->net->ethtool_ops = &ax8817x_ethtool_ops;
901 918
902 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, 919 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
903 cpu_to_le16(BMCR_RESET));
904 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, 920 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
905 cpu_to_le16(ADVERTISE_ALL | ADVERTISE_CSMA | 0x0400)); 921 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
906 mii_nway_restart(&dev->mii); 922 mii_nway_restart(&dev->mii);
907 923
908 if((ret = usb_submit_urb(data->int_urb, GFP_KERNEL)) < 0) {
909 dbg("Failed to submit interrupt URB: %02x", ret);
910 goto out2;
911 }
912
913 return 0; 924 return 0;
914out3:
915 kfree(buf);
916out2: 925out2:
917 kfree(data->int_buf); 926 kfree(buf);
918out1: 927out1:
919 usb_free_urb(data->int_urb);
920 return ret; 928 return ret;
921} 929}
922 930
923static void ax8817x_unbind(struct usbnet *dev, struct usb_interface *intf)
924{
925 struct ax8817x_data *data = (struct ax8817x_data *)dev->data;
926
927 usb_kill_urb(data->int_urb);
928 usb_free_urb(data->int_urb);
929 kfree(data->int_buf);
930}
931
932static struct ethtool_ops ax88772_ethtool_ops = { 931static struct ethtool_ops ax88772_ethtool_ops = {
933 .get_drvinfo = ax8817x_get_drvinfo, 932 .get_drvinfo = ax8817x_get_drvinfo,
934 .get_link = ethtool_op_get_link, 933 .get_link = ethtool_op_get_link,
@@ -946,64 +945,44 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
946{ 945{
947 int ret; 946 int ret;
948 void *buf; 947 void *buf;
949 struct ax8817x_data *data = (struct ax8817x_data *)dev->data;
950 948
951 get_endpoints(dev,intf); 949 get_endpoints(dev,intf);
952 950
953 if ((data->int_urb = usb_alloc_urb (0, GFP_KERNEL)) == 0) {
954 dbg ("Cannot allocate interrupt URB");
955 ret = -ENOMEM;
956 goto out1;
957 }
958
959 if ((data->int_buf = kmalloc(AX_INTERRUPT_BUFSIZE, GFP_KERNEL)) == NULL) {
960 dbg ("Cannot allocate memory for interrupt buffer");
961 ret = -ENOMEM;
962 goto out1;
963 }
964 memset(data->int_buf, 0, AX_INTERRUPT_BUFSIZE);
965
966 usb_fill_int_urb (data->int_urb, dev->udev,
967 usb_rcvintpipe (dev->udev, 1),
968 data->int_buf, AX_INTERRUPT_BUFSIZE,
969 ax8817x_interrupt_complete, dev,
970 dev->udev->speed == USB_SPEED_HIGH ? 8 : 100);
971
972 buf = kmalloc(6, GFP_KERNEL); 951 buf = kmalloc(6, GFP_KERNEL);
973 if(!buf) { 952 if(!buf) {
974 dbg ("Cannot allocate memory for buffer"); 953 dbg ("Cannot allocate memory for buffer");
975 ret = -ENOMEM; 954 ret = -ENOMEM;
976 goto out2; 955 goto out1;
977 } 956 }
978 957
979 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS, 958 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_GPIOS,
980 0x00B0, 0, 0, buf)) < 0) 959 0x00B0, 0, 0, buf)) < 0)
981 goto out3; 960 goto out2;
982 961
983 msleep(5); 962 msleep(5);
984 if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0x0001, 0, 0, buf)) < 0) { 963 if ((ret = ax8817x_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0x0001, 0, 0, buf)) < 0) {
985 dbg("Select PHY #1 failed: %d", ret); 964 dbg("Select PHY #1 failed: %d", ret);
986 goto out3; 965 goto out2;
987 } 966 }
988 967
989 if ((ret = 968 if ((ret =
990 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPPD, 0, 0, buf)) < 0) { 969 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPPD, 0, 0, buf)) < 0) {
991 dbg("Failed to power down internal PHY: %d", ret); 970 dbg("Failed to power down internal PHY: %d", ret);
992 goto out3; 971 goto out2;
993 } 972 }
994 973
995 msleep(150); 974 msleep(150);
996 if ((ret = 975 if ((ret =
997 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_CLEAR, 0, 0, buf)) < 0) { 976 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_CLEAR, 0, 0, buf)) < 0) {
998 dbg("Failed to perform software reset: %d", ret); 977 dbg("Failed to perform software reset: %d", ret);
999 goto out3; 978 goto out2;
1000 } 979 }
1001 980
1002 msleep(150); 981 msleep(150);
1003 if ((ret = 982 if ((ret =
1004 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL | AX_SWRESET_PRL, 0, 0, buf)) < 0) { 983 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL | AX_SWRESET_PRL, 0, 0, buf)) < 0) {
1005 dbg("Failed to set Internal/External PHY reset control: %d", ret); 984 dbg("Failed to set Internal/External PHY reset control: %d", ret);
1006 goto out3; 985 goto out2;
1007 } 986 }
1008 987
1009 msleep(150); 988 msleep(150);
@@ -1011,27 +990,27 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
1011 ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0000, 0, 0, 990 ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0000, 0, 0,
1012 buf)) < 0) { 991 buf)) < 0) {
1013 dbg("Failed to reset RX_CTL: %d", ret); 992 dbg("Failed to reset RX_CTL: %d", ret);
1014 goto out3; 993 goto out2;
1015 } 994 }
1016 995
1017 /* Get the MAC address */ 996 /* Get the MAC address */
1018 memset(buf, 0, ETH_ALEN); 997 memset(buf, 0, ETH_ALEN);
1019 if ((ret = ax8817x_read_cmd(dev, AX88772_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf)) < 0) { 998 if ((ret = ax8817x_read_cmd(dev, AX88772_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf)) < 0) {
1020 dbg("Failed to read MAC address: %d", ret); 999 dbg("Failed to read MAC address: %d", ret);
1021 goto out3; 1000 goto out2;
1022 } 1001 }
1023 memcpy(dev->net->dev_addr, buf, ETH_ALEN); 1002 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
1024 1003
1025 if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, buf)) < 0) { 1004 if ((ret = ax8817x_write_cmd(dev, AX_CMD_SET_SW_MII, 0, 0, 0, buf)) < 0) {
1026 dbg("Enabling software MII failed: %d", ret); 1005 dbg("Enabling software MII failed: %d", ret);
1027 goto out3; 1006 goto out2;
1028 } 1007 }
1029 1008
1030 if (((ret = 1009 if (((ret =
1031 ax8817x_read_cmd(dev, AX_CMD_READ_MII_REG, 0x0010, 2, 2, buf)) < 0) 1010 ax8817x_read_cmd(dev, AX_CMD_READ_MII_REG, 0x0010, 2, 2, buf)) < 0)
1032 || (*((u16 *)buf) != 0x003b)) { 1011 || (*((u16 *)buf) != 0x003b)) {
1033 dbg("Read PHY register 2 must be 0x3b00: %d", ret); 1012 dbg("Read PHY register 2 must be 0x3b00: %d", ret);
1034 goto out3; 1013 goto out2;
1035 } 1014 }
1036 1015
1037 /* Initialize MII structure */ 1016 /* Initialize MII structure */
@@ -1044,26 +1023,26 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
1044 /* Get the PHY id */ 1023 /* Get the PHY id */
1045 if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf)) < 0) { 1024 if ((ret = ax8817x_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf)) < 0) {
1046 dbg("Error reading PHY ID: %02x", ret); 1025 dbg("Error reading PHY ID: %02x", ret);
1047 goto out3; 1026 goto out2;
1048 } else if (ret < 2) { 1027 } else if (ret < 2) {
1049 /* this should always return 2 bytes */ 1028 /* this should always return 2 bytes */
1050 dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x", 1029 dbg("AX_CMD_READ_PHY_ID returned less than 2 bytes: ret=%02x",
1051 ret); 1030 ret);
1052 ret = -EIO; 1031 ret = -EIO;
1053 goto out3; 1032 goto out2;
1054 } 1033 }
1055 dev->mii.phy_id = *((u8 *)buf + 1); 1034 dev->mii.phy_id = *((u8 *)buf + 1);
1056 1035
1057 if ((ret = 1036 if ((ret =
1058 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_PRL, 0, 0, buf)) < 0) { 1037 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_PRL, 0, 0, buf)) < 0) {
1059 dbg("Set external PHY reset pin level: %d", ret); 1038 dbg("Set external PHY reset pin level: %d", ret);
1060 goto out3; 1039 goto out2;
1061 } 1040 }
1062 msleep(150); 1041 msleep(150);
1063 if ((ret = 1042 if ((ret =
1064 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL | AX_SWRESET_PRL, 0, 0, buf)) < 0) { 1043 ax8817x_write_cmd(dev, AX_CMD_SW_RESET, AX_SWRESET_IPRL | AX_SWRESET_PRL, 0, 0, buf)) < 0) {
1065 dbg("Set Internal/External PHY reset control: %d", ret); 1044 dbg("Set Internal/External PHY reset control: %d", ret);
1066 goto out3; 1045 goto out2;
1067 } 1046 }
1068 msleep(150); 1047 msleep(150);
1069 1048
@@ -1071,25 +1050,24 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
1071 dev->net->set_multicast_list = ax8817x_set_multicast; 1050 dev->net->set_multicast_list = ax8817x_set_multicast;
1072 dev->net->ethtool_ops = &ax88772_ethtool_ops; 1051 dev->net->ethtool_ops = &ax88772_ethtool_ops;
1073 1052
1074 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, 1053 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
1075 cpu_to_le16(BMCR_RESET));
1076 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, 1054 ax8817x_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
1077 cpu_to_le16(ADVERTISE_ALL | ADVERTISE_CSMA)); 1055 ADVERTISE_ALL | ADVERTISE_CSMA);
1078 mii_nway_restart(&dev->mii); 1056 mii_nway_restart(&dev->mii);
1079 1057
1080 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, 0x0336, 0, 0, buf)) < 0) { 1058 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, AX88772_MEDIUM_DEFAULT, 0, 0, buf)) < 0) {
1081 dbg("Write medium mode register: %d", ret); 1059 dbg("Write medium mode register: %d", ret);
1082 goto out3; 1060 goto out2;
1083 } 1061 }
1084 1062
1085 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0, AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,AX88772_IPG2_DEFAULT, 0, buf)) < 0) { 1063 if ((ret = ax8817x_write_cmd(dev, AX_CMD_WRITE_IPG0, AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,AX88772_IPG2_DEFAULT, 0, buf)) < 0) {
1086 dbg("Write IPG,IPG1,IPG2 failed: %d", ret); 1064 dbg("Write IPG,IPG1,IPG2 failed: %d", ret);
1087 goto out3; 1065 goto out2;
1088 } 1066 }
1089 if ((ret = 1067 if ((ret =
1090 ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf)) < 0) { 1068 ax8817x_write_cmd(dev, AX_CMD_SET_HW_MII, 0, 0, 0, &buf)) < 0) {
1091 dbg("Failed to set hardware MII: %02x", ret); 1069 dbg("Failed to set hardware MII: %02x", ret);
1092 goto out3; 1070 goto out2;
1093 } 1071 }
1094 1072
1095 /* Set RX_CTL to default values with 2k buffer, and enable cactus */ 1073 /* Set RX_CTL to default values with 2k buffer, and enable cactus */
@@ -1097,25 +1075,16 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
1097 ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0088, 0, 0, 1075 ax8817x_write_cmd(dev, AX_CMD_WRITE_RX_CTL, 0x0088, 0, 0,
1098 buf)) < 0) { 1076 buf)) < 0) {
1099 dbg("Reset RX_CTL failed: %d", ret); 1077 dbg("Reset RX_CTL failed: %d", ret);
1100 goto out3; 1078 goto out2;
1101 }
1102
1103 if((ret = usb_submit_urb(data->int_urb, GFP_KERNEL)) < 0) {
1104 dbg("Failed to submit interrupt URB: %02x", ret);
1105 goto out3;
1106 } 1079 }
1107 1080
1108 kfree(buf); 1081 kfree(buf);
1109 1082
1110 return 0; 1083 return 0;
1111 1084
1112out3:
1113 kfree(buf);
1114out2: 1085out2:
1115 kfree(data->int_buf); 1086 kfree(buf);
1116out1: 1087out1:
1117 usb_free_urb(data->int_urb);
1118
1119 return ret; 1088 return ret;
1120} 1089}
1121 1090
@@ -1213,10 +1182,29 @@ static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
1213 return skb; 1182 return skb;
1214} 1183}
1215 1184
1185static int ax88772_link_reset(struct usbnet *dev)
1186{
1187 u16 lpa;
1188 u16 mode;
1189
1190 mode = AX88772_MEDIUM_DEFAULT;
1191 lpa = ax8817x_mdio_read(dev->net, dev->mii.phy_id, MII_LPA);
1192
1193 if ((lpa & LPA_DUPLEX) == 0)
1194 mode &= ~AX88772_MEDIUM_FULL_DUPLEX;
1195 if ((lpa & LPA_100) == 0)
1196 mode &= ~AX88772_MEDIUM_100MB;
1197 ax8817x_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL);
1198
1199 return 0;
1200}
1201
1216static const struct driver_info ax8817x_info = { 1202static const struct driver_info ax8817x_info = {
1217 .description = "ASIX AX8817x USB 2.0 Ethernet", 1203 .description = "ASIX AX8817x USB 2.0 Ethernet",
1218 .bind = ax8817x_bind, 1204 .bind = ax8817x_bind,
1219 .unbind = ax8817x_unbind, 1205 .status = ax8817x_status,
1206 .link_reset = ax88172_link_reset,
1207 .reset = ax88172_link_reset,
1220 .flags = FLAG_ETHER, 1208 .flags = FLAG_ETHER,
1221 .data = 0x00130103, 1209 .data = 0x00130103,
1222}; 1210};
@@ -1224,7 +1212,9 @@ static const struct driver_info ax8817x_info = {
1224static const struct driver_info dlink_dub_e100_info = { 1212static const struct driver_info dlink_dub_e100_info = {
1225 .description = "DLink DUB-E100 USB Ethernet", 1213 .description = "DLink DUB-E100 USB Ethernet",
1226 .bind = ax8817x_bind, 1214 .bind = ax8817x_bind,
1227 .unbind = ax8817x_unbind, 1215 .status = ax8817x_status,
1216 .link_reset = ax88172_link_reset,
1217 .reset = ax88172_link_reset,
1228 .flags = FLAG_ETHER, 1218 .flags = FLAG_ETHER,
1229 .data = 0x009f9d9f, 1219 .data = 0x009f9d9f,
1230}; 1220};
@@ -1232,7 +1222,9 @@ static const struct driver_info dlink_dub_e100_info = {
1232static const struct driver_info netgear_fa120_info = { 1222static const struct driver_info netgear_fa120_info = {
1233 .description = "Netgear FA-120 USB Ethernet", 1223 .description = "Netgear FA-120 USB Ethernet",
1234 .bind = ax8817x_bind, 1224 .bind = ax8817x_bind,
1235 .unbind = ax8817x_unbind, 1225 .status = ax8817x_status,
1226 .link_reset = ax88172_link_reset,
1227 .reset = ax88172_link_reset,
1236 .flags = FLAG_ETHER, 1228 .flags = FLAG_ETHER,
1237 .data = 0x00130103, 1229 .data = 0x00130103,
1238}; 1230};
@@ -1240,7 +1232,9 @@ static const struct driver_info netgear_fa120_info = {
1240static const struct driver_info hawking_uf200_info = { 1232static const struct driver_info hawking_uf200_info = {
1241 .description = "Hawking UF200 USB Ethernet", 1233 .description = "Hawking UF200 USB Ethernet",
1242 .bind = ax8817x_bind, 1234 .bind = ax8817x_bind,
1243 .unbind = ax8817x_unbind, 1235 .status = ax8817x_status,
1236 .link_reset = ax88172_link_reset,
1237 .reset = ax88172_link_reset,
1244 .flags = FLAG_ETHER, 1238 .flags = FLAG_ETHER,
1245 .data = 0x001f1d1f, 1239 .data = 0x001f1d1f,
1246}; 1240};
@@ -1248,7 +1242,9 @@ static const struct driver_info hawking_uf200_info = {
1248static const struct driver_info ax88772_info = { 1242static const struct driver_info ax88772_info = {
1249 .description = "ASIX AX88772 USB 2.0 Ethernet", 1243 .description = "ASIX AX88772 USB 2.0 Ethernet",
1250 .bind = ax88772_bind, 1244 .bind = ax88772_bind,
1251 .unbind = ax8817x_unbind, 1245 .status = ax8817x_status,
1246 .link_reset = ax88772_link_reset,
1247 .reset = ax88772_link_reset,
1252 .flags = FLAG_ETHER | FLAG_FRAMING_AX, 1248 .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1253 .rx_fixup = ax88772_rx_fixup, 1249 .rx_fixup = ax88772_rx_fixup,
1254 .tx_fixup = ax88772_tx_fixup, 1250 .tx_fixup = ax88772_tx_fixup,
@@ -2661,7 +2657,7 @@ static const struct driver_info blob_info = {
2661 * All known Zaurii lie about their standards conformance. Most lie by 2657 * All known Zaurii lie about their standards conformance. Most lie by
2662 * saying they support CDC Ethernet. Some lie and say they support CDC 2658 * saying they support CDC Ethernet. Some lie and say they support CDC
2663 * MDLM (as if for access to cell phone modems). Someone, please beat 2659 * MDLM (as if for access to cell phone modems). Someone, please beat
2664 * on Sharp for a while with a cluestick. 2660 * on Sharp (and other such vendors) for a while with a cluestick.
2665 * 2661 *
2666 *-------------------------------------------------------------------------*/ 2662 *-------------------------------------------------------------------------*/
2667 2663
@@ -2714,13 +2710,6 @@ static const struct driver_info zaurus_pxa_info = {
2714}; 2710};
2715#define ZAURUS_PXA_INFO ((unsigned long)&zaurus_pxa_info) 2711#define ZAURUS_PXA_INFO ((unsigned long)&zaurus_pxa_info)
2716 2712
2717static const struct driver_info zaurus_pxa_mdlm_info = {
2718 .description = "Sharp Zaurus, PXA-255 based",
2719 .flags = FLAG_FRAMING_Z,
2720 .check_connect = always_connected,
2721 .tx_fixup = zaurus_tx_fixup,
2722};
2723
2724static const struct driver_info olympus_mxl_info = { 2713static const struct driver_info olympus_mxl_info = {
2725 .description = "Olympus R1000", 2714 .description = "Olympus R1000",
2726 .flags = FLAG_FRAMING_Z, 2715 .flags = FLAG_FRAMING_Z,
@@ -2731,6 +2720,133 @@ static const struct driver_info olympus_mxl_info = {
2731}; 2720};
2732#define OLYMPUS_MXL_INFO ((unsigned long)&olympus_mxl_info) 2721#define OLYMPUS_MXL_INFO ((unsigned long)&olympus_mxl_info)
2733 2722
2723
2724/* Some more recent products using Lineo/Belcarra code will wrongly claim
2725 * CDC MDLM conformance. They aren't conformant: data endpoints live
2726 * in the control interface, there's no data interface, and it's not used
2727 * to talk to a cell phone radio. But at least we can detect these two
2728 * pseudo-classes, rather than growing this product list with entries for
2729 * each new nonconformant product (sigh).
2730 */
2731static const u8 safe_guid[16] = {
2732 0x5d, 0x34, 0xcf, 0x66, 0x11, 0x18, 0x11, 0xd6,
2733 0xa2, 0x1a, 0x00, 0x01, 0x02, 0xca, 0x9a, 0x7f,
2734};
2735static const u8 blan_guid[16] = {
2736 0x74, 0xf0, 0x3d, 0xbd, 0x1e, 0xc1, 0x44, 0x70,
2737 0xa3, 0x67, 0x71, 0x34, 0xc9, 0xf5, 0x54, 0x37,
2738};
2739
2740static int blan_mdlm_bind (struct usbnet *dev, struct usb_interface *intf)
2741{
2742 u8 *buf = intf->cur_altsetting->extra;
2743 int len = intf->cur_altsetting->extralen;
2744 struct usb_cdc_mdlm_desc *desc = NULL;
2745 struct usb_cdc_mdlm_detail_desc *detail = NULL;
2746
2747 while (len > 3) {
2748 if (buf [1] != USB_DT_CS_INTERFACE)
2749 goto next_desc;
2750
2751 /* use bDescriptorSubType, and just verify that we get a
2752 * "BLAN" (or "SAFE") descriptor.
2753 */
2754 switch (buf [2]) {
2755 case USB_CDC_MDLM_TYPE:
2756 if (desc) {
2757 dev_dbg (&intf->dev, "extra MDLM\n");
2758 goto bad_desc;
2759 }
2760 desc = (void *) buf;
2761 if (desc->bLength != sizeof *desc) {
2762 dev_dbg (&intf->dev, "MDLM len %u\n",
2763 desc->bLength);
2764 goto bad_desc;
2765 }
2766 /* expect bcdVersion 1.0, ignore */
2767 if (memcmp(&desc->bGUID, blan_guid, 16)
2768 || memcmp(&desc->bGUID, blan_guid, 16) ) {
2769 /* hey, this one might _really_ be MDLM! */
2770 dev_dbg (&intf->dev, "MDLM guid\n");
2771 goto bad_desc;
2772 }
2773 break;
2774 case USB_CDC_MDLM_DETAIL_TYPE:
2775 if (detail) {
2776 dev_dbg (&intf->dev, "extra MDLM detail\n");
2777 goto bad_desc;
2778 }
2779 detail = (void *) buf;
2780 switch (detail->bGuidDescriptorType) {
2781 case 0: /* "SAFE" */
2782 if (detail->bLength != (sizeof *detail + 2))
2783 goto bad_detail;
2784 break;
2785 case 1: /* "BLAN" */
2786 if (detail->bLength != (sizeof *detail + 3))
2787 goto bad_detail;
2788 break;
2789 default:
2790 goto bad_detail;
2791 }
2792
2793 /* assuming we either noticed BLAN already, or will
2794 * find it soon, there are some data bytes here:
2795 * - bmNetworkCapabilities (unused)
2796 * - bmDataCapabilities (bits, see below)
2797 * - bPad (ignored, for PADAFTER -- BLAN-only)
2798 * bits are:
2799 * - 0x01 -- Zaurus framing (add CRC)
2800 * - 0x02 -- PADBEFORE
2801 * - 0x04 -- PADAFTER
2802 * - 0x08 -- "fermat" packet mangling (for hw bugs)
2803 */
2804 if (detail->bDetailData[1] != 0x01) {
2805 /* bmDataCapabilites == 0 would be fine too,
2806 * but framing is minidriver-coupled for now.
2807 */
2808bad_detail:
2809 dev_dbg (&intf->dev,
2810 "bad MDLM detail, %d %d %d\n",
2811 detail->bLength,
2812 detail->bDetailData[0],
2813 detail->bDetailData[2]);
2814 goto bad_desc;
2815 }
2816 break;
2817 }
2818next_desc:
2819 len -= buf [0]; /* bLength */
2820 buf += buf [0];
2821 }
2822
2823 if (!desc || !detail) {
2824 dev_dbg (&intf->dev, "missing cdc mdlm %s%sdescriptor\n",
2825 desc ? "" : "func ",
2826 detail ? "" : "detail ");
2827 goto bad_desc;
2828 }
2829
2830 /* There's probably a CDC Ethernet descriptor there, but we can't
2831 * rely on the Ethernet address it provides since not all vendors
2832 * bother to make it unique. Likewise there's no point in tracking
2833 * of the CDC event notifications.
2834 */
2835 return get_endpoints (dev, intf);
2836
2837bad_desc:
2838 dev_info (&dev->udev->dev, "unsupported MDLM descriptors\n");
2839 return -ENODEV;
2840}
2841
2842static const struct driver_info bogus_mdlm_info = {
2843 .description = "pseudo-MDLM (BLAN) device",
2844 .flags = FLAG_FRAMING_Z,
2845 .check_connect = always_connected,
2846 .tx_fixup = zaurus_tx_fixup,
2847 .bind = blan_mdlm_bind,
2848};
2849
2734#else 2850#else
2735 2851
2736/* blacklist all those devices */ 2852/* blacklist all those devices */
@@ -3307,6 +3423,19 @@ kevent (void *data)
3307 } 3423 }
3308 } 3424 }
3309 3425
3426 if (test_bit (EVENT_LINK_RESET, &dev->flags)) {
3427 struct driver_info *info = dev->driver_info;
3428 int retval = 0;
3429
3430 clear_bit (EVENT_LINK_RESET, &dev->flags);
3431 if(info->link_reset && (retval = info->link_reset(dev)) < 0) {
3432 devinfo(dev, "link reset failed (%d) usbnet usb-%s-%s, %s",
3433 retval,
3434 dev->udev->bus->bus_name, dev->udev->devpath,
3435 info->description);
3436 }
3437 }
3438
3310 if (dev->flags) 3439 if (dev->flags)
3311 devdbg (dev, "kevent done, flags = 0x%lx", 3440 devdbg (dev, "kevent done, flags = 0x%lx",
3312 dev->flags); 3441 dev->flags);
@@ -3942,6 +4071,9 @@ static const struct usb_device_id products [] = {
3942 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader 4071 USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader
3943 .driver_info = (unsigned long) &blob_info, 4072 .driver_info = (unsigned long) &blob_info,
3944}, { 4073}, {
4074 USB_DEVICE (0x22b8, 0x600c), // USBNET Motorola E680
4075 .driver_info = (unsigned long) &linuxdev_info,
4076}, {
3945 // Linux Ethernet/RNDIS gadget on pxa210/25x/26x 4077 // Linux Ethernet/RNDIS gadget on pxa210/25x/26x
3946 // e.g. Gumstix, current OpenZaurus, ... 4078 // e.g. Gumstix, current OpenZaurus, ...
3947 USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203), 4079 USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203),
@@ -4020,30 +4152,14 @@ static const struct usb_device_id products [] = {
4020}, 4152},
4021 4153
4022#ifdef CONFIG_USB_ZAURUS 4154#ifdef CONFIG_USB_ZAURUS
4023 /* at least some (reports vary) PXA units have very different 4155 /* At least some (reports vary) PXA units have very different lies
4024 * lies about their standards support: they claim to be cell 4156 * about their standards support: they claim to be cell phones with
4025 * phones giving direct radio access (which they aren't). 4157 * direct access to their radios. (They don't conform to CDC MDLM.)
4026 */ 4158 */
4027{ 4159{
4028 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO 4160 USB_INTERFACE_INFO (USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM,
4029 | USB_DEVICE_ID_MATCH_DEVICE, 4161 USB_CDC_PROTO_NONE),
4030 .idVendor = 0x04DD, 4162 .driver_info = (unsigned long) &bogus_mdlm_info,
4031 /* Sharp ROM v1.32 */
4032 .idProduct = 0x8006, /* SL-5600 */
4033 .bInterfaceClass = USB_CLASS_COMM,
4034 .bInterfaceSubClass = USB_CDC_SUBCLASS_MDLM,
4035 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
4036 .driver_info = (unsigned long) &zaurus_pxa_mdlm_info,
4037}, {
4038 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
4039 | USB_DEVICE_ID_MATCH_DEVICE,
4040 .idVendor = 0x04DD,
4041 /* reported with some C860 units */
4042 .idProduct = 0x9031, /* C-860 */
4043 .bInterfaceClass = USB_CLASS_COMM,
4044 .bInterfaceSubClass = USB_CDC_SUBCLASS_MDLM,
4045 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
4046 .driver_info = (unsigned long) &zaurus_pxa_mdlm_info,
4047}, 4163},
4048#endif 4164#endif
4049 4165
diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c
index c81cd0a619bf..341ae5f732dd 100644
--- a/drivers/usb/net/zd1201.c
+++ b/drivers/usb/net/zd1201.c
@@ -45,7 +45,7 @@ MODULE_PARM_DESC(ap, "If non-zero Access Point firmware will be loaded");
45MODULE_DEVICE_TABLE(usb, zd1201_table); 45MODULE_DEVICE_TABLE(usb, zd1201_table);
46 46
47 47
48int zd1201_fw_upload(struct usb_device *dev, int apfw) 48static int zd1201_fw_upload(struct usb_device *dev, int apfw)
49{ 49{
50 const struct firmware *fw_entry; 50 const struct firmware *fw_entry;
51 char* data; 51 char* data;
@@ -111,7 +111,7 @@ exit:
111 return err; 111 return err;
112} 112}
113 113
114void zd1201_usbfree(struct urb *urb, struct pt_regs *regs) 114static void zd1201_usbfree(struct urb *urb, struct pt_regs *regs)
115{ 115{
116 struct zd1201 *zd = urb->context; 116 struct zd1201 *zd = urb->context;
117 117
@@ -142,7 +142,8 @@ void zd1201_usbfree(struct urb *urb, struct pt_regs *regs)
142 142
143 total: 4 + 2 + 2 + 2 + 2 + 4 = 16 143 total: 4 + 2 + 2 + 2 + 2 + 4 = 16
144*/ 144*/
145int zd1201_docmd(struct zd1201 *zd, int cmd, int parm0, int parm1, int parm2) 145static int zd1201_docmd(struct zd1201 *zd, int cmd, int parm0,
146 int parm1, int parm2)
146{ 147{
147 unsigned char *command; 148 unsigned char *command;
148 int ret; 149 int ret;
@@ -175,15 +176,15 @@ int zd1201_docmd(struct zd1201 *zd, int cmd, int parm0, int parm1, int parm2)
175} 176}
176 177
177/* Callback after sending out a packet */ 178/* Callback after sending out a packet */
178void zd1201_usbtx(struct urb *urb, struct pt_regs *regs) 179static void zd1201_usbtx(struct urb *urb, struct pt_regs *regs)
179{ 180{
180 struct zd1201 *zd = urb->context; 181 struct zd1201 *zd = urb->context;
181 netif_wake_queue(zd->dev); 182 netif_wake_queue(zd->dev);
182 return; 183 return;
183} 184}
184 185
185/* Incomming data */ 186/* Incoming data */
186void zd1201_usbrx(struct urb *urb, struct pt_regs *regs) 187static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
187{ 188{
188 struct zd1201 *zd = urb->context; 189 struct zd1201 *zd = urb->context;
189 int free = 0; 190 int free = 0;
@@ -613,7 +614,7 @@ static inline int zd1201_setconfig16(struct zd1201 *zd, int rid, short val)
613 return (zd1201_setconfig(zd, rid, &zdval, sizeof(__le16), 1)); 614 return (zd1201_setconfig(zd, rid, &zdval, sizeof(__le16), 1));
614} 615}
615 616
616int zd1201_drvr_start(struct zd1201 *zd) 617static int zd1201_drvr_start(struct zd1201 *zd)
617{ 618{
618 int err, i; 619 int err, i;
619 short max; 620 short max;
@@ -771,7 +772,7 @@ static int zd1201_net_stop(struct net_device *dev)
771/* 772/*
772 RFC 1042 encapsulates Ethernet frames in 802.11 frames 773 RFC 1042 encapsulates Ethernet frames in 802.11 frames
773 by prefixing them with 0xaa, 0xaa, 0x03) followed by a SNAP OID of 0 774 by prefixing them with 0xaa, 0xaa, 0x03) followed by a SNAP OID of 0
774 (0x00, 0x00, 0x00). Zd requires an additionnal padding, copy 775 (0x00, 0x00, 0x00). Zd requires an additional padding, copy
775 of ethernet addresses, length of the standard RFC 1042 packet 776 of ethernet addresses, length of the standard RFC 1042 packet
776 and a command byte (which is nul for tx). 777 and a command byte (which is nul for tx).
777 778
@@ -1097,7 +1098,7 @@ static int zd1201_get_range(struct net_device *dev,
1097 1098
1098/* Little bit of magic here: we only get the quality if we poll 1099/* Little bit of magic here: we only get the quality if we poll
1099 * for it, and we never get an actual request to trigger such 1100 * for it, and we never get an actual request to trigger such
1100 * a poll. Therefore we 'asume' that the user will soon ask for 1101 * a poll. Therefore we 'assume' that the user will soon ask for
1101 * the stats after asking the bssid. 1102 * the stats after asking the bssid.
1102 */ 1103 */
1103static int zd1201_get_wap(struct net_device *dev, 1104static int zd1201_get_wap(struct net_device *dev,
@@ -1107,7 +1108,7 @@ static int zd1201_get_wap(struct net_device *dev,
1107 unsigned char buffer[6]; 1108 unsigned char buffer[6];
1108 1109
1109 if (!zd1201_getconfig(zd, ZD1201_RID_COMMSQUALITY, buffer, 6)) { 1110 if (!zd1201_getconfig(zd, ZD1201_RID_COMMSQUALITY, buffer, 6)) {
1110 /* Unfortunatly the quality and noise reported is useless. 1111 /* Unfortunately the quality and noise reported is useless.
1111 they seem to be accumulators that increase until you 1112 they seem to be accumulators that increase until you
1112 read them, unless we poll on a fixed interval we can't 1113 read them, unless we poll on a fixed interval we can't
1113 use them 1114 use them
@@ -1739,7 +1740,8 @@ static const struct iw_handler_def zd1201_iw_handlers = {
1739 .private_args = (struct iw_priv_args *) zd1201_private_args, 1740 .private_args = (struct iw_priv_args *) zd1201_private_args,
1740}; 1741};
1741 1742
1742int zd1201_probe(struct usb_interface *interface, const struct usb_device_id *id) 1743static int zd1201_probe(struct usb_interface *interface,
1744 const struct usb_device_id *id)
1743{ 1745{
1744 struct zd1201 *zd; 1746 struct zd1201 *zd;
1745 struct usb_device *usb; 1747 struct usb_device *usb;
@@ -1851,7 +1853,7 @@ err_zd:
1851 return err; 1853 return err;
1852} 1854}
1853 1855
1854void zd1201_disconnect(struct usb_interface *interface) 1856static void zd1201_disconnect(struct usb_interface *interface)
1855{ 1857{
1856 struct zd1201 *zd=(struct zd1201 *)usb_get_intfdata(interface); 1858 struct zd1201 *zd=(struct zd1201 *)usb_get_intfdata(interface);
1857 struct hlist_node *node, *node2; 1859 struct hlist_node *node, *node2;
@@ -1882,7 +1884,7 @@ void zd1201_disconnect(struct usb_interface *interface)
1882 kfree(zd); 1884 kfree(zd);
1883} 1885}
1884 1886
1885struct usb_driver zd1201_usb = { 1887static struct usb_driver zd1201_usb = {
1886 .owner = THIS_MODULE, 1888 .owner = THIS_MODULE,
1887 .name = "zd1201", 1889 .name = "zd1201",
1888 .probe = zd1201_probe, 1890 .probe = zd1201_probe,
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index b869076d9c7c..bc798edf0358 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -53,6 +53,15 @@ config USB_SERIAL_GENERIC
53 support" be compiled as a module for this driver to be used 53 support" be compiled as a module for this driver to be used
54 properly. 54 properly.
55 55
56config USB_SERIAL_AIRPRIME
57 tristate "USB AirPrime CDMA Wireless Driver"
58 depends on USB_SERIAL
59 help
60 Say Y here if you want to use a AirPrime CDMA Wireless PC card.
61
62 To compile this driver as a module, choose M here: the
63 module will be called airprime.
64
56config USB_SERIAL_BELKIN 65config USB_SERIAL_BELKIN
57 tristate "USB Belkin and Peracom Single Port Serial Driver" 66 tristate "USB Belkin and Peracom Single Port Serial Driver"
58 depends on USB_SERIAL 67 depends on USB_SERIAL
@@ -395,6 +404,15 @@ config USB_SERIAL_PL2303
395 To compile this driver as a module, choose M here: the 404 To compile this driver as a module, choose M here: the
396 module will be called pl2303. 405 module will be called pl2303.
397 406
407config USB_SERIAL_HP4X
408 tristate "USB HP4x Calculators support"
409 depends on USB_SERIAL
410 help
411 Say Y here if you want to use an Hewlett-Packard 4x Calculator.
412
413 To compile this driver as a module, choose M here: the
414 module will be called hp4x.
415
398config USB_SERIAL_SAFE 416config USB_SERIAL_SAFE
399 tristate "USB Safe Serial (Encapsulated) Driver (EXPERIMENTAL)" 417 tristate "USB Safe Serial (Encapsulated) Driver (EXPERIMENTAL)"
400 depends on USB_SERIAL && EXPERIMENTAL 418 depends on USB_SERIAL && EXPERIMENTAL
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 351b81855b18..d56ff6d86cce 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -11,6 +11,7 @@ usbserial-obj-$(CONFIG_USB_EZUSB) += ezusb.o
11 11
12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) 12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y)
13 13
14obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o
14obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o 15obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o
15obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o 16obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o
16obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o 17obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o
@@ -21,6 +22,7 @@ obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o
21obj-$(CONFIG_USB_SERIAL_EMPEG) += empeg.o 22obj-$(CONFIG_USB_SERIAL_EMPEG) += empeg.o
22obj-$(CONFIG_USB_SERIAL_FTDI_SIO) += ftdi_sio.o 23obj-$(CONFIG_USB_SERIAL_FTDI_SIO) += ftdi_sio.o
23obj-$(CONFIG_USB_SERIAL_GARMIN) += garmin_gps.o 24obj-$(CONFIG_USB_SERIAL_GARMIN) += garmin_gps.o
25obj-$(CONFIG_USB_SERIAL_HP4X) += hp4x.o
24obj-$(CONFIG_USB_SERIAL_IPAQ) += ipaq.o 26obj-$(CONFIG_USB_SERIAL_IPAQ) += ipaq.o
25obj-$(CONFIG_USB_SERIAL_IPW) += ipw.o 27obj-$(CONFIG_USB_SERIAL_IPW) += ipw.o
26obj-$(CONFIG_USB_SERIAL_IR) += ir-usb.o 28obj-$(CONFIG_USB_SERIAL_IR) += ir-usb.o
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
new file mode 100644
index 000000000000..a4ce0008d69b
--- /dev/null
+++ b/drivers/usb/serial/airprime.c
@@ -0,0 +1,63 @@
1/*
2 * AirPrime CDMA Wireless Serial USB driver
3 *
4 * Copyright (C) 2005 Greg Kroah-Hartman <gregkh@suse.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/tty.h>
14#include <linux/module.h>
15#include <linux/usb.h>
16#include "usb-serial.h"
17
18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0xf3d, 0x0112) },
20 { },
21};
22MODULE_DEVICE_TABLE(usb, id_table);
23
24static struct usb_driver airprime_driver = {
25 .owner = THIS_MODULE,
26 .name = "airprime",
27 .probe = usb_serial_probe,
28 .disconnect = usb_serial_disconnect,
29 .id_table = id_table,
30};
31
32static struct usb_serial_device_type airprime_device = {
33 .owner = THIS_MODULE,
34 .name = "airprime",
35 .id_table = id_table,
36 .num_interrupt_in = NUM_DONT_CARE,
37 .num_bulk_in = NUM_DONT_CARE,
38 .num_bulk_out = NUM_DONT_CARE,
39 .num_ports = 1,
40};
41
42static int __init airprime_init(void)
43{
44 int retval;
45
46 retval = usb_serial_register(&airprime_device);
47 if (retval)
48 return retval;
49 retval = usb_register(&airprime_driver);
50 if (retval)
51 usb_serial_deregister(&airprime_device);
52 return retval;
53}
54
55static void __exit airprime_exit(void)
56{
57 usb_deregister(&airprime_driver);
58 usb_serial_deregister(&airprime_device);
59}
60
61module_init(airprime_init);
62module_exit(airprime_exit);
63MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index d165f42d560d..f34a9bb6a219 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -16,6 +16,14 @@
16 * See http://geocities.com/i0xox0i for information on this driver and the 16 * See http://geocities.com/i0xox0i for information on this driver and the
17 * earthmate usb device. 17 * earthmate usb device.
18 * 18 *
19 * Lonnie Mendez <dignome@gmail.com>
20 * 4-29-2005
21 * Fixed problem where setting or retreiving the serial config would fail with
22 * EPIPE. Removed CRTS toggling so the driver behaves more like other usbserial
23 * adapters. Issued new interval of 1ms instead of the default 10ms. As a
24 * result, transfer speed has been substantially increased. From avg. 850bps to
25 * avg. 3300bps. initial termios has also been modified. Cleaned up code and
26 * formatting issues so it is more readable. Replaced the C++ style comments.
19 * 27 *
20 * Lonnie Mendez <dignome@gmail.com> 28 * Lonnie Mendez <dignome@gmail.com>
21 * 12-15-2004 29 * 12-15-2004
@@ -32,12 +40,6 @@
32 * 10-2003 40 * 10-2003
33 * Driver first released. 41 * Driver first released.
34 * 42 *
35 *
36 * Long Term TODO:
37 * Improve transfer speeds - both read/write are somewhat slow
38 * at this point.
39 * Improve debugging. Show modem line status with debug output and
40 * implement filtering for certain data as a module parameter.
41 */ 43 */
42 44
43/* Thanks to Neil Whelchel for writing the first cypress m8 implementation for linux. */ 45/* Thanks to Neil Whelchel for writing the first cypress m8 implementation for linux. */
@@ -72,11 +74,12 @@
72 static int debug; 74 static int debug;
73#endif 75#endif
74static int stats; 76static int stats;
77static int interval;
75 78
76/* 79/*
77 * Version Information 80 * Version Information
78 */ 81 */
79#define DRIVER_VERSION "v1.08" 82#define DRIVER_VERSION "v1.09"
80#define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>" 83#define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>"
81#define DRIVER_DESC "Cypress USB to Serial Driver" 84#define DRIVER_DESC "Cypress USB to Serial Driver"
82 85
@@ -130,7 +133,6 @@ struct cypress_private {
130 char prev_status, diff_status; /* used for TIOCMIWAIT */ 133 char prev_status, diff_status; /* used for TIOCMIWAIT */
131 /* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */ 134 /* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */
132 struct termios tmp_termios; /* stores the old termios settings */ 135 struct termios tmp_termios; /* stores the old termios settings */
133 char calledfromopen; /* used when issuing lines on open - fixes rts drop bug */
134}; 136};
135 137
136/* write buffer structure */ 138/* write buffer structure */
@@ -168,10 +170,8 @@ static void cypress_buf_free(struct cypress_buf *cb);
168static void cypress_buf_clear(struct cypress_buf *cb); 170static void cypress_buf_clear(struct cypress_buf *cb);
169static unsigned int cypress_buf_data_avail(struct cypress_buf *cb); 171static unsigned int cypress_buf_data_avail(struct cypress_buf *cb);
170static unsigned int cypress_buf_space_avail(struct cypress_buf *cb); 172static unsigned int cypress_buf_space_avail(struct cypress_buf *cb);
171static unsigned int cypress_buf_put(struct cypress_buf *cb, const char *buf, 173static unsigned int cypress_buf_put(struct cypress_buf *cb, const char *buf, unsigned int count);
172 unsigned int count); 174static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf, unsigned int count);
173static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf,
174 unsigned int count);
175 175
176 176
177static struct usb_serial_device_type cypress_earthmate_device = { 177static struct usb_serial_device_type cypress_earthmate_device = {
@@ -234,14 +234,13 @@ static struct usb_serial_device_type cypress_hidcom_device = {
234 *****************************************************************************/ 234 *****************************************************************************/
235 235
236 236
237/* This function can either set or retreive the current serial line settings */ 237/* This function can either set or retrieve the current serial line settings */
238static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits, 238static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_mask, int data_bits, int stop_bits,
239 int parity_enable, int parity_type, int reset, int cypress_request_type) 239 int parity_enable, int parity_type, int reset, int cypress_request_type)
240{ 240{
241 int i, n_baud_rate = 0, retval = 0; 241 int new_baudrate = 0, retval = 0, tries = 0;
242 struct cypress_private *priv; 242 struct cypress_private *priv;
243 __u8 feature_buffer[5]; 243 __u8 feature_buffer[8];
244 __u8 config;
245 unsigned long flags; 244 unsigned long flags;
246 245
247 dbg("%s", __FUNCTION__); 246 dbg("%s", __FUNCTION__);
@@ -256,7 +255,8 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
256 * of 57600bps (I have no idea whether DeLorme chose to use the general purpose 255 * of 57600bps (I have no idea whether DeLorme chose to use the general purpose
257 * firmware or not), if you need to modify this speed setting for your own 256 * firmware or not), if you need to modify this speed setting for your own
258 * project please add your own chiptype and modify the code likewise. The 257 * project please add your own chiptype and modify the code likewise. The
259 * Cypress HID->COM device will work successfully up to 115200bps. 258 * Cypress HID->COM device will work successfully up to 115200bps (but the
259 * actual throughput is around 3kBps).
260 */ 260 */
261 if (baud_mask != priv->cbr_mask) { 261 if (baud_mask != priv->cbr_mask) {
262 dbg("%s - baud rate is changing", __FUNCTION__); 262 dbg("%s - baud rate is changing", __FUNCTION__);
@@ -265,109 +265,114 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
265 * but are not used with NMEA and SiRF protocols */ 265 * but are not used with NMEA and SiRF protocols */
266 266
267 if ( (baud_mask == B300) || (baud_mask == B600) ) { 267 if ( (baud_mask == B300) || (baud_mask == B600) ) {
268 err("%s - failed setting baud rate, unsupported speed (default to 4800)", 268 err("%s - failed setting baud rate, unsupported speed",
269 __FUNCTION__); 269 __FUNCTION__);
270 n_baud_rate = 4800; 270 new_baudrate = priv->baud_rate;
271 } else if ( (n_baud_rate = mask_to_rate(baud_mask)) == -1) { 271 } else if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
272 err("%s - failed setting baud rate, unsupported speed (default to 4800)", 272 err("%s - failed setting baud rate, unsupported speed",
273 __FUNCTION__); 273 __FUNCTION__);
274 n_baud_rate = 4800; 274 new_baudrate = priv->baud_rate;
275 } 275 }
276 } else if (priv->chiptype == CT_CYPHIDCOM) { 276 } else if (priv->chiptype == CT_CYPHIDCOM) {
277 if ( (n_baud_rate = mask_to_rate(baud_mask)) == -1) { 277 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
278 err("%s - failed setting baud rate, unsupported speed (default to 4800)", 278 err("%s - failed setting baud rate, unsupported speed",
279 __FUNCTION__); 279 __FUNCTION__);
280 n_baud_rate = 4800; 280 new_baudrate = priv->baud_rate;
281 } 281 }
282 } else if (priv->chiptype == CT_GENERIC) { 282 } else if (priv->chiptype == CT_GENERIC) {
283 if ( (n_baud_rate = mask_to_rate(baud_mask)) == -1) { 283 if ( (new_baudrate = mask_to_rate(baud_mask)) == -1) {
284 err("%s - failed setting baud rate, unsupported speed (default to 4800)", 284 err("%s - failed setting baud rate, unsupported speed",
285 __FUNCTION__); 285 __FUNCTION__);
286 n_baud_rate = 4800; 286 new_baudrate = priv->baud_rate;
287 } 287 }
288 } else { 288 } else {
289 info("%s - please define your chiptype, using 4800bps default", __FUNCTION__); 289 info("%s - please define your chiptype", __FUNCTION__);
290 n_baud_rate = 4800; 290 new_baudrate = priv->baud_rate;
291 } 291 }
292 } else { /* baud rate not changing, keep the old */ 292 } else { /* baud rate not changing, keep the old */
293 n_baud_rate = priv->baud_rate; 293 new_baudrate = priv->baud_rate;
294 } 294 }
295 dbg("%s - baud rate is being sent as %d", __FUNCTION__, n_baud_rate); 295 dbg("%s - baud rate is being sent as %d", __FUNCTION__, new_baudrate);
296
297 296
298 /* 297 memset(feature_buffer, 0, 8);
299 * This algorithm accredited to Jiang Jay Zhang... thanks for all the help! 298 /* fill the feature_buffer with new configuration */
300 */ 299 *((u_int32_t *)feature_buffer) = new_baudrate;
301 for (i = 0; i < 4; ++i) {
302 feature_buffer[i] = ( n_baud_rate >> (i*8) & 0xFF );
303 }
304 300
305 config = 0; // reset config byte 301 feature_buffer[4] |= data_bits; /* assign data bits in 2 bit space ( max 3 ) */
306 config |= data_bits; // assign data bits in 2 bit space ( max 3 )
307 /* 1 bit gap */ 302 /* 1 bit gap */
308 config |= (stop_bits << 3); // assign stop bits in 1 bit space 303 feature_buffer[4] |= (stop_bits << 3); /* assign stop bits in 1 bit space */
309 config |= (parity_enable << 4); // assign parity flag in 1 bit space 304 feature_buffer[4] |= (parity_enable << 4); /* assign parity flag in 1 bit space */
310 config |= (parity_type << 5); // assign parity type in 1 bit space 305 feature_buffer[4] |= (parity_type << 5); /* assign parity type in 1 bit space */
311 /* 1 bit gap */ 306 /* 1 bit gap */
312 config |= (reset << 7); // assign reset at end of byte, 1 bit space 307 feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */
313
314 feature_buffer[4] = config;
315 308
316 dbg("%s - device is being sent this feature report:", __FUNCTION__); 309 dbg("%s - device is being sent this feature report:", __FUNCTION__);
317 dbg("%s - %02X - %02X - %02X - %02X - %02X", __FUNCTION__, feature_buffer[0], feature_buffer[1], 310 dbg("%s - %02X - %02X - %02X - %02X - %02X", __FUNCTION__, feature_buffer[0], feature_buffer[1],
318 feature_buffer[2], feature_buffer[3], feature_buffer[4]); 311 feature_buffer[2], feature_buffer[3], feature_buffer[4]);
319 312
313 do {
320 retval = usb_control_msg (port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), 314 retval = usb_control_msg (port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
321 HID_REQ_SET_REPORT, USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 315 HID_REQ_SET_REPORT, USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
322 0x0300, 0, feature_buffer, 5, 500); 316 0x0300, 0, feature_buffer, 8, 500);
317
318 if (tries++ >= 3)
319 break;
323 320
324 if (retval != 5) 321 if (retval == EPIPE)
322 usb_clear_halt(port->serial->dev, 0x00);
323 } while (retval != 8 && retval != ENODEV);
324
325 if (retval != 8)
325 err("%s - failed sending serial line settings - %d", __FUNCTION__, retval); 326 err("%s - failed sending serial line settings - %d", __FUNCTION__, retval);
326 else { 327 else {
327 spin_lock_irqsave(&priv->lock, flags); 328 spin_lock_irqsave(&priv->lock, flags);
328 priv->baud_rate = n_baud_rate; 329 priv->baud_rate = new_baudrate;
329 priv->cbr_mask = baud_mask; 330 priv->cbr_mask = baud_mask;
330 priv->current_config = config; 331 priv->current_config = feature_buffer[4];
331 ++priv->cmd_count;
332 spin_unlock_irqrestore(&priv->lock, flags); 332 spin_unlock_irqrestore(&priv->lock, flags);
333 } 333 }
334 break; 334 break;
335 case CYPRESS_GET_CONFIG: 335 case CYPRESS_GET_CONFIG:
336 dbg("%s - retreiving serial line settings", __FUNCTION__); 336 dbg("%s - retreiving serial line settings", __FUNCTION__);
337 /* reset values in feature buffer */ 337 /* set initial values in feature buffer */
338 memset(feature_buffer, 0, 5); 338 memset(feature_buffer, 0, 8);
339 339
340 do {
340 retval = usb_control_msg (port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0), 341 retval = usb_control_msg (port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0),
341 HID_REQ_GET_REPORT, USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, 342 HID_REQ_GET_REPORT, USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
342 0x0300, 0, feature_buffer, 5, 500); 343 0x0300, 0, feature_buffer, 8, 500);
344
345 if (tries++ >= 3)
346 break;
347
348 if (retval == EPIPE)
349 usb_clear_halt(port->serial->dev, 0x00);
350 } while (retval != 5 && retval != ENODEV);
351
343 if (retval != 5) { 352 if (retval != 5) {
344 err("%s - failed to retreive serial line settings - %d", __FUNCTION__, retval); 353 err("%s - failed to retreive serial line settings - %d", __FUNCTION__, retval);
345 return retval; 354 return retval;
346 } else { 355 } else {
347 spin_lock_irqsave(&priv->lock, flags); 356 spin_lock_irqsave(&priv->lock, flags);
357
348 /* store the config in one byte, and later use bit masks to check values */ 358 /* store the config in one byte, and later use bit masks to check values */
349 priv->current_config = feature_buffer[4]; 359 priv->current_config = feature_buffer[4];
350 /* reverse the process above to get the baud_mask value */ 360 priv->baud_rate = *((u_int32_t *)feature_buffer);
351 n_baud_rate = 0; // reset bits
352 for (i = 0; i < 4; ++i) {
353 n_baud_rate |= ( feature_buffer[i] << (i*8) );
354 }
355 361
356 priv->baud_rate = n_baud_rate; 362 if ( (priv->cbr_mask = rate_to_mask(priv->baud_rate)) == 0x40)
357 if ( (priv->cbr_mask = rate_to_mask(n_baud_rate)) == 0x40)
358 dbg("%s - failed setting the baud mask (not defined)", __FUNCTION__); 363 dbg("%s - failed setting the baud mask (not defined)", __FUNCTION__);
359 ++priv->cmd_count;
360 spin_unlock_irqrestore(&priv->lock, flags); 364 spin_unlock_irqrestore(&priv->lock, flags);
361 } 365 }
362 break;
363 default:
364 err("%s - unsupported serial control command issued", __FUNCTION__);
365 } 366 }
367 spin_lock_irqsave(&priv->lock, flags);
368 ++priv->cmd_count;
369 spin_unlock_irqrestore(&priv->lock, flags);
370
366 return retval; 371 return retval;
367} /* cypress_serial_control */ 372} /* cypress_serial_control */
368 373
369 374
370/* given a baud mask, it will return speed on success */ 375/* given a baud mask, it will return integer baud on success */
371static int mask_to_rate (unsigned mask) 376static int mask_to_rate (unsigned mask)
372{ 377{
373 int rate; 378 int rate;
@@ -438,11 +443,12 @@ static int generic_startup (struct usb_serial *serial)
438 443
439 usb_reset_configuration (serial->dev); 444 usb_reset_configuration (serial->dev);
440 445
446 interval = 1;
441 priv->cmd_ctrl = 0; 447 priv->cmd_ctrl = 0;
442 priv->line_control = 0; 448 priv->line_control = 0;
443 priv->termios_initialized = 0; 449 priv->termios_initialized = 0;
444 priv->calledfromopen = 0;
445 priv->rx_flags = 0; 450 priv->rx_flags = 0;
451 priv->cbr_mask = B300;
446 usb_set_serial_port_data(serial->port[0], priv); 452 usb_set_serial_port_data(serial->port[0], priv);
447 453
448 return (0); 454 return (0);
@@ -513,7 +519,6 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
513 dbg("%s - port %d", __FUNCTION__, port->number); 519 dbg("%s - port %d", __FUNCTION__, port->number);
514 520
515 /* clear halts before open */ 521 /* clear halts before open */
516 usb_clear_halt(serial->dev, 0x00);
517 usb_clear_halt(serial->dev, 0x81); 522 usb_clear_halt(serial->dev, 0x81);
518 usb_clear_halt(serial->dev, 0x02); 523 usb_clear_halt(serial->dev, 0x02);
519 524
@@ -531,7 +536,6 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
531 /* raise both lines and set termios */ 536 /* raise both lines and set termios */
532 spin_lock_irqsave(&priv->lock, flags); 537 spin_lock_irqsave(&priv->lock, flags);
533 priv->line_control = CONTROL_DTR | CONTROL_RTS; 538 priv->line_control = CONTROL_DTR | CONTROL_RTS;
534 priv->calledfromopen = 1;
535 priv->cmd_ctrl = 1; 539 priv->cmd_ctrl = 1;
536 spin_unlock_irqrestore(&priv->lock, flags); 540 spin_unlock_irqrestore(&priv->lock, flags);
537 result = cypress_write(port, NULL, 0); 541 result = cypress_write(port, NULL, 0);
@@ -553,7 +557,7 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
553 usb_fill_int_urb(port->interrupt_in_urb, serial->dev, 557 usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
554 usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress), 558 usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress),
555 port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length, 559 port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length,
556 cypress_read_int_callback, port, port->interrupt_in_urb->interval); 560 cypress_read_int_callback, port, interval);
557 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 561 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
558 562
559 if (result){ 563 if (result){
@@ -680,12 +684,12 @@ static void cypress_send(struct usb_serial_port *port)
680 spin_lock_irqsave(&priv->lock, flags); 684 spin_lock_irqsave(&priv->lock, flags);
681 switch (port->interrupt_out_size) { 685 switch (port->interrupt_out_size) {
682 case 32: 686 case 32:
683 // this is for the CY7C64013... 687 /* this is for the CY7C64013... */
684 offset = 2; 688 offset = 2;
685 port->interrupt_out_buffer[0] = priv->line_control; 689 port->interrupt_out_buffer[0] = priv->line_control;
686 break; 690 break;
687 case 8: 691 case 8:
688 // this is for the CY7C63743... 692 /* this is for the CY7C63743... */
689 offset = 1; 693 offset = 1;
690 port->interrupt_out_buffer[0] = priv->line_control; 694 port->interrupt_out_buffer[0] = priv->line_control;
691 break; 695 break;
@@ -738,6 +742,7 @@ send:
738 742
739 port->interrupt_out_urb->transfer_buffer_length = actual_size; 743 port->interrupt_out_urb->transfer_buffer_length = actual_size;
740 port->interrupt_out_urb->dev = port->serial->dev; 744 port->interrupt_out_urb->dev = port->serial->dev;
745 port->interrupt_out_urb->interval = interval;
741 result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC); 746 result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC);
742 if (result) { 747 if (result) {
743 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, 748 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__,
@@ -910,7 +915,7 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
910 unsigned cflag, iflag, baud_mask; 915 unsigned cflag, iflag, baud_mask;
911 unsigned long flags; 916 unsigned long flags;
912 __u8 oldlines; 917 __u8 oldlines;
913 int linechange; 918 int linechange = 0;
914 919
915 dbg("%s - port %d", __FUNCTION__, port->number); 920 dbg("%s - port %d", __FUNCTION__, port->number);
916 921
@@ -996,15 +1001,7 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
996 case B115200: dbg("%s - setting baud 115200bps", __FUNCTION__); break; 1001 case B115200: dbg("%s - setting baud 115200bps", __FUNCTION__); break;
997 default: dbg("%s - unknown masked baud rate", __FUNCTION__); 1002 default: dbg("%s - unknown masked baud rate", __FUNCTION__);
998 } 1003 }
999 priv->line_control |= CONTROL_DTR; 1004 priv->line_control = (CONTROL_DTR | CONTROL_RTS);
1000
1001 /* toggle CRTSCTS? - don't do this if being called from cypress_open */
1002 if (!priv->calledfromopen) {
1003 if (cflag & CRTSCTS)
1004 priv->line_control |= CONTROL_RTS;
1005 else
1006 priv->line_control &= ~CONTROL_RTS;
1007 }
1008 } 1005 }
1009 spin_unlock_irqrestore(&priv->lock, flags); 1006 spin_unlock_irqrestore(&priv->lock, flags);
1010 1007
@@ -1014,8 +1011,6 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
1014 cypress_serial_control(port, baud_mask, data_bits, stop_bits, parity_enable, 1011 cypress_serial_control(port, baud_mask, data_bits, stop_bits, parity_enable,
1015 parity_type, 0, CYPRESS_SET_CONFIG); 1012 parity_type, 0, CYPRESS_SET_CONFIG);
1016 1013
1017 msleep(50); /* give some time between change and read (50ms) */
1018
1019 /* we perform a CYPRESS_GET_CONFIG so that the current settings are filled into the private structure 1014 /* we perform a CYPRESS_GET_CONFIG so that the current settings are filled into the private structure
1020 * this should confirm that all is working if it returns what we just set */ 1015 * this should confirm that all is working if it returns what we just set */
1021 cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG); 1016 cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG);
@@ -1031,7 +1026,6 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
1031 dbg("Using custom termios settings for a baud rate of 4800bps."); 1026 dbg("Using custom termios settings for a baud rate of 4800bps.");
1032 /* define custom termios settings for NMEA protocol */ 1027 /* define custom termios settings for NMEA protocol */
1033 1028
1034
1035 tty->termios->c_iflag /* input modes - */ 1029 tty->termios->c_iflag /* input modes - */
1036 &= ~(IGNBRK /* disable ignore break */ 1030 &= ~(IGNBRK /* disable ignore break */
1037 | BRKINT /* disable break causes interrupt */ 1031 | BRKINT /* disable break causes interrupt */
@@ -1052,23 +1046,16 @@ static void cypress_set_termios (struct usb_serial_port *port, struct termios *o
1052 | ISIG /* disable interrupt, quit, and suspend special characters */ 1046 | ISIG /* disable interrupt, quit, and suspend special characters */
1053 | IEXTEN); /* disable non-POSIX special characters */ 1047 | IEXTEN); /* disable non-POSIX special characters */
1054 1048
1055 } else if (priv->chiptype == CT_CYPHIDCOM) { 1049 } /* CT_CYPHIDCOM: Application should handle this for device */
1056
1057 // Software app handling it for device...
1058 1050
1059 }
1060 linechange = (priv->line_control != oldlines); 1051 linechange = (priv->line_control != oldlines);
1061 spin_unlock_irqrestore(&priv->lock, flags); 1052 spin_unlock_irqrestore(&priv->lock, flags);
1062 1053
1063 /* if necessary, set lines */ 1054 /* if necessary, set lines */
1064 if (!priv->calledfromopen && linechange) { 1055 if (linechange) {
1065 priv->cmd_ctrl = 1; 1056 priv->cmd_ctrl = 1;
1066 cypress_write(port, NULL, 0); 1057 cypress_write(port, NULL, 0);
1067 } 1058 }
1068
1069 if (priv->calledfromopen)
1070 priv->calledfromopen = 0;
1071
1072} /* cypress_set_termios */ 1059} /* cypress_set_termios */
1073 1060
1074 1061
@@ -1164,7 +1151,7 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
1164 spin_lock_irqsave(&priv->lock, flags); 1151 spin_lock_irqsave(&priv->lock, flags);
1165 switch(urb->actual_length) { 1152 switch(urb->actual_length) {
1166 case 32: 1153 case 32:
1167 // This is for the CY7C64013... 1154 /* This is for the CY7C64013... */
1168 priv->current_status = data[0] & 0xF8; 1155 priv->current_status = data[0] & 0xF8;
1169 bytes = data[1]+2; 1156 bytes = data[1]+2;
1170 i=2; 1157 i=2;
@@ -1172,7 +1159,7 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
1172 havedata = 1; 1159 havedata = 1;
1173 break; 1160 break;
1174 case 8: 1161 case 8:
1175 // This is for the CY7C63743... 1162 /* This is for the CY7C63743... */
1176 priv->current_status = data[0] & 0xF8; 1163 priv->current_status = data[0] & 0xF8;
1177 bytes = (data[0] & 0x07)+1; 1164 bytes = (data[0] & 0x07)+1;
1178 i=1; 1165 i=1;
@@ -1245,7 +1232,7 @@ continue_read:
1245 port->interrupt_in_urb->transfer_buffer, 1232 port->interrupt_in_urb->transfer_buffer,
1246 port->interrupt_in_urb->transfer_buffer_length, 1233 port->interrupt_in_urb->transfer_buffer_length,
1247 cypress_read_int_callback, port, 1234 cypress_read_int_callback, port,
1248 port->interrupt_in_urb->interval); 1235 interval);
1249 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1236 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1250 if (result) 1237 if (result)
1251 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 1238 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
@@ -1274,6 +1261,8 @@ static void cypress_write_int_callback(struct urb *urb, struct pt_regs *regs)
1274 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); 1261 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
1275 priv->write_urb_in_use = 0; 1262 priv->write_urb_in_use = 0;
1276 return; 1263 return;
1264 case -EPIPE: /* no break needed */
1265 usb_clear_halt(port->serial->dev, 0x02);
1277 default: 1266 default:
1278 /* error in the urb, so we have to resubmit it */ 1267 /* error in the urb, so we have to resubmit it */
1279 dbg("%s - Overflow in write", __FUNCTION__); 1268 dbg("%s - Overflow in write", __FUNCTION__);
@@ -1535,3 +1524,5 @@ module_param(debug, bool, S_IRUGO | S_IWUSR);
1535MODULE_PARM_DESC(debug, "Debug enabled or not"); 1524MODULE_PARM_DESC(debug, "Debug enabled or not");
1536module_param(stats, bool, S_IRUGO | S_IWUSR); 1525module_param(stats, bool, S_IRUGO | S_IWUSR);
1537MODULE_PARM_DESC(stats, "Enable statistics or not"); 1526MODULE_PARM_DESC(stats, "Enable statistics or not");
1527module_param(interval, int, S_IRUGO | S_IWUSR);
1528MODULE_PARM_DESC(interval, "Overrides interrupt interval");
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 4c788c767a97..52394f08a947 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -76,7 +76,7 @@
76 * Defererence pointers after any paranoid checks, not before. 76 * Defererence pointers after any paranoid checks, not before.
77 * 77 *
78 * (21/Jun/2003) Erik Nygren 78 * (21/Jun/2003) Erik Nygren
79 * Added support for Home Electronics Tira-1 IR tranceiver 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.
@@ -91,7 +91,7 @@
91 * Minor whitespace and comment changes. 91 * Minor whitespace and comment changes.
92 * 92 *
93 * (12/Jun/2003) David Norwood 93 * (12/Jun/2003) David Norwood
94 * Added support for USB-UIRT IR tranceiver using 8U232AM chip. 94 * Added support for USB-UIRT IR transceiver using 8U232AM chip.
95 * See <http://home.earthlink.net/~jrhees/USBUIRT/index.htm>. Only 95 * See <http://home.earthlink.net/~jrhees/USBUIRT/index.htm>. Only
96 * operates properly at 312500, so set custom divisor mode on startup. 96 * operates properly at 312500, so set custom divisor mode on startup.
97 * 97 *
@@ -272,6 +272,7 @@ static int debug;
272 272
273static struct usb_device_id id_table_sio [] = { 273static struct usb_device_id id_table_sio [] = {
274 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 274 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
275 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
275 { } /* Terminating entry */ 276 { } /* Terminating entry */
276}; 277};
277 278
@@ -296,7 +297,6 @@ static struct usb_device_id id_table_8U232AM [] = {
296 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0, 0x3ff) }, 297 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0, 0x3ff) },
297 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0, 0x3ff) }, 298 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0, 0x3ff) },
298 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0, 0x3ff) }, 299 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0, 0x3ff) },
299 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_ALT_PID, 0, 0x3ff) },
300 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0, 0x3ff) }, 300 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0, 0x3ff) },
301 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 301 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
302 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, 302 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
@@ -369,11 +369,14 @@ static struct usb_device_id id_table_8U232AM [] = {
369 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) }, 369 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0, 0x3ff) },
370 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0, 0x3ff) }, 370 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0, 0x3ff) },
371 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0, 0x3ff) }, 371 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0, 0x3ff) },
372 { USB_DEVICE_VER(FTDI_RM_VID, FTDI_RMCANVIEW_PID, 0, 0x3ff) }, 372 { USB_DEVICE_VER(FTDI_VID, FTDI_RM_CANVIEW_PID, 0, 0x3ff) },
373 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0, 0x3ff) }, 373 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0, 0x3ff) },
374 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0, 0x3ff) }, 374 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0, 0x3ff) },
375 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0, 0x3ff) }, 375 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0, 0x3ff) },
376 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0, 0x3ff) }, 376 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0, 0x3ff) },
377 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID, 0, 0x3ff) },
378 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID, 0, 0x3ff) },
379 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID, 0, 0x3ff) },
377 { } /* Terminating entry */ 380 { } /* Terminating entry */
378}; 381};
379 382
@@ -382,7 +385,6 @@ static struct usb_device_id id_table_FT232BM [] = {
382 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0x400, 0xffff) }, 385 { USB_DEVICE_VER(FTDI_VID, FTDI_IRTRANS_PID, 0x400, 0xffff) },
383 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0x400, 0xffff) }, 386 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_PID, 0x400, 0xffff) },
384 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0x400, 0xffff) }, 387 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_PID, 0x400, 0xffff) },
385 { USB_DEVICE_VER(FTDI_VID, FTDI_8U232AM_ALT_ALT_PID, 0x400, 0xffff) },
386 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0x400, 0xffff) }, 388 { USB_DEVICE_VER(FTDI_VID, FTDI_RELAIS_PID, 0x400, 0xffff) },
387 { USB_DEVICE_VER(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID, 0x400, 0xffff) }, 389 { USB_DEVICE_VER(FTDI_NF_RIC_VID, FTDI_NF_RIC_PID, 0x400, 0xffff) },
388 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_632_PID, 0x400, 0xffff) }, 390 { USB_DEVICE_VER(FTDI_VID, FTDI_XF_632_PID, 0x400, 0xffff) },
@@ -485,11 +487,15 @@ static struct usb_device_id id_table_FT232BM [] = {
485 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0x400, 0xffff) }, 487 { USB_DEVICE_VER(INTREPID_VID, INTREPID_NEOVI_PID, 0x400, 0xffff) },
486 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0x400, 0xffff) }, 488 { USB_DEVICE_VER(FALCOM_VID, FALCOM_TWIST_PID, 0x400, 0xffff) },
487 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0x400, 0xffff) }, 489 { USB_DEVICE_VER(FTDI_VID, FTDI_SUUNTO_SPORTS_PID, 0x400, 0xffff) },
488 { USB_DEVICE_VER(FTDI_RM_VID, FTDI_RMCANVIEW_PID, 0x400, 0xffff) }, 490 { USB_DEVICE_VER(FTDI_VID, FTDI_RM_CANVIEW_PID, 0x400, 0xffff) },
489 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0x400, 0xffff) }, 491 { USB_DEVICE_VER(BANDB_VID, BANDB_USOTL4_PID, 0x400, 0xffff) },
490 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0x400, 0xffff) }, 492 { USB_DEVICE_VER(BANDB_VID, BANDB_USTL4_PID, 0x400, 0xffff) },
491 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0x400, 0xffff) }, 493 { USB_DEVICE_VER(BANDB_VID, BANDB_USO9ML2_PID, 0x400, 0xffff) },
492 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0x400, 0xffff) }, 494 { USB_DEVICE_VER(FTDI_VID, EVER_ECO_PRO_CDS, 0x400, 0xffff) },
495 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID, 0x400, 0xffff) },
496 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID, 0x400, 0xffff) },
497 { USB_DEVICE_VER(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID, 0x400, 0xffff) },
498 { USB_DEVICE_VER(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID, 0x400, 0xffff) },
493 { } /* Terminating entry */ 499 { } /* Terminating entry */
494}; 500};
495 501
@@ -517,7 +523,6 @@ static struct usb_device_id id_table_combined [] = {
517 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 523 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
518 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, 524 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
519 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, 525 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
520 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_ALT_PID) },
521 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) }, 526 { USB_DEVICE(FTDI_VID, FTDI_8U2232C_PID) },
522 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, 527 { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) },
523 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, 528 { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
@@ -596,6 +601,22 @@ static struct usb_device_id id_table_combined [] = {
596 { USB_DEVICE(FTDI_VID, PROTEGO_R2X0) }, 601 { USB_DEVICE(FTDI_VID, PROTEGO_R2X0) },
597 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) }, 602 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_3) },
598 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_4) }, 603 { USB_DEVICE(FTDI_VID, PROTEGO_SPECIAL_4) },
604 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E808_PID, 0x400, 0xffff) },
605 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E809_PID, 0x400, 0xffff) },
606 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80A_PID, 0x400, 0xffff) },
607 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80B_PID, 0x400, 0xffff) },
608 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80C_PID, 0x400, 0xffff) },
609 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80D_PID, 0x400, 0xffff) },
610 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80E_PID, 0x400, 0xffff) },
611 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E80F_PID, 0x400, 0xffff) },
612 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E888_PID, 0x400, 0xffff) },
613 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E889_PID, 0x400, 0xffff) },
614 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88A_PID, 0x400, 0xffff) },
615 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88B_PID, 0x400, 0xffff) },
616 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88C_PID, 0x400, 0xffff) },
617 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88D_PID, 0x400, 0xffff) },
618 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88E_PID, 0x400, 0xffff) },
619 { USB_DEVICE_VER(FTDI_VID, FTDI_GUDEADS_E88F_PID, 0x400, 0xffff) },
599 { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) }, 620 { USB_DEVICE(FTDI_VID, FTDI_ELV_UO100_PID) },
600 { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) }, 621 { USB_DEVICE_VER(FTDI_VID, LINX_SDMUSBQSS_PID, 0x400, 0xffff) },
601 { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) }, 622 { USB_DEVICE_VER(FTDI_VID, LINX_MASTERDEVEL2_PID, 0x400, 0xffff) },
@@ -609,11 +630,16 @@ static struct usb_device_id id_table_combined [] = {
609 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) }, 630 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) },
610 { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) }, 631 { USB_DEVICE(FALCOM_VID, FALCOM_TWIST_PID) },
611 { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) }, 632 { USB_DEVICE(FTDI_VID, FTDI_SUUNTO_SPORTS_PID) },
612 { USB_DEVICE(FTDI_RM_VID, FTDI_RMCANVIEW_PID) }, 633 { USB_DEVICE(FTDI_VID, FTDI_RM_CANVIEW_PID) },
613 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) }, 634 { USB_DEVICE(BANDB_VID, BANDB_USOTL4_PID) },
614 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) }, 635 { USB_DEVICE(BANDB_VID, BANDB_USTL4_PID) },
615 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) }, 636 { USB_DEVICE(BANDB_VID, BANDB_USO9ML2_PID) },
616 { USB_DEVICE(FTDI_VID, EVER_ECO_PRO_CDS) }, 637 { USB_DEVICE(FTDI_VID, EVER_ECO_PRO_CDS) },
638 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_0_PID) },
639 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_1_PID) },
640 { USB_DEVICE(FTDI_VID, FTDI_4N_GALAXY_DE_2_PID) },
641 { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
642 { USB_DEVICE_VER(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID, 0x400, 0xffff) },
617 { } /* Terminating entry */ 643 { } /* Terminating entry */
618}; 644};
619 645
@@ -1457,10 +1483,10 @@ static int ftdi_FT2232C_startup (struct usb_serial *serial)
1457 inter = serial->interface->altsetting->desc.bInterfaceNumber; 1483 inter = serial->interface->altsetting->desc.bInterfaceNumber;
1458 1484
1459 if (inter) { 1485 if (inter) {
1460 priv->interface = INTERFACE_B; 1486 priv->interface = PIT_SIOB;
1461 } 1487 }
1462 else { 1488 else {
1463 priv->interface = INTERFACE_A; 1489 priv->interface = PIT_SIOA;
1464 } 1490 }
1465 priv->baud_base = 48000000 / 2; /* Would be / 16, but FT2232C supports multiple of 0.125 divisor fractions! */ 1491 priv->baud_base = 48000000 / 2; /* Would be / 16, but FT2232C supports multiple of 0.125 divisor fractions! */
1466 1492
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index be5d60bf90b9..a52bb13a9ce4 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -26,7 +26,6 @@
26#define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */ 26#define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */
27#define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */ 27#define FTDI_8U232AM_PID 0x6001 /* Similar device to SIO above */
28#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */ 28#define FTDI_8U232AM_ALT_PID 0x6006 /* FTDI's alternate PID for above */
29#define FTDI_8U232AM_ALT_ALT_PID 0xf3c0 /* FTDI's second alternate PID for above */
30#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ 29#define FTDI_8U2232C_PID 0x6010 /* Dual channel device */
31#define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */ 30#define FTDI_RELAIS_PID 0xFA10 /* Relais device from Rudolf Gugler */
32#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */ 31#define FTDI_NF_RIC_VID 0x0DCD /* Vendor Id */
@@ -137,7 +136,7 @@
137/* 136/*
138 * Home Electronics (www.home-electro.com) USB gadgets 137 * Home Electronics (www.home-electro.com) USB gadgets
139 */ 138 */
140#define FTDI_HE_TIRA1_PID 0xFA78 /* Tira-1 IR tranceiver */ 139#define FTDI_HE_TIRA1_PID 0xFA78 /* Tira-1 IR transceiver */
141 140
142/* USB-UIRT - An infrared receiver and transmitter using the 8U232AM chip */ 141/* USB-UIRT - An infrared receiver and transmitter using the 8U232AM chip */
143/* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */ 142/* http://home.earthlink.net/~jrhees/USBUIRT/index.htm */
@@ -157,7 +156,8 @@
157 */ 156 */
158#define OCT_VID 0x0B39 /* OCT vendor ID */ 157#define OCT_VID 0x0B39 /* OCT vendor ID */
159/* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */ 158/* Note: OCT US101 is also rebadged as Dick Smith Electronics (NZ) XH6381 */
160/* Also rebadged as SIIG Inc. model US2308 */ 159/* Also rebadged as Dick Smith Electronics (Aus) XH6451 */
160/* Also rebadged as SIIG Inc. model US2308 hardware version 1 */
161#define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */ 161#define OCT_US101_PID 0x0421 /* OCT US101 USB to RS-232 */
162 162
163/* an infrared receiver for user access control with IR tags */ 163/* an infrared receiver for user access control with IR tags */
@@ -236,10 +236,10 @@
236 236
237/* 237/*
238 * RM Michaelides CANview USB (http://www.rmcan.com) 238 * RM Michaelides CANview USB (http://www.rmcan.com)
239 * CAN filedbus interface adapter, addad by port GmbH www.port.de) 239 * CAN fieldbus interface adapter, added by port GmbH www.port.de)
240 * Ian Abbott changed the macro names for consistency.
240 */ 241 */
241#define FTDI_RM_VID 0x0403 /* Vendor Id */ 242#define FTDI_RM_CANVIEW_PID 0xfd60 /* Product Id */
242#define FTDI_RMCANVIEW_PID 0xfd60 /* Product Id */
243 243
244/* 244/*
245 * EVER Eco Pro UPS (http://www.ever.com.pl/) 245 * EVER Eco Pro UPS (http://www.ever.com.pl/)
@@ -247,6 +247,26 @@
247 247
248#define EVER_ECO_PRO_CDS 0xe520 /* RS-232 converter */ 248#define EVER_ECO_PRO_CDS 0xe520 /* RS-232 converter */
249 249
250/*
251 * 4N-GALAXY.DE PIDs for CAN-USB, USB-RS232, USB-RS422, USB-RS485,
252 * USB-TTY activ, USB-TTY passiv. Some PIDs are used by several devices
253 * and I'm not entirely sure which are used by which.
254 */
255#define FTDI_4N_GALAXY_DE_0_PID 0x8372
256#define FTDI_4N_GALAXY_DE_1_PID 0xF3C0
257#define FTDI_4N_GALAXY_DE_2_PID 0xF3C1
258
259/*
260 * Mobility Electronics products.
261 */
262#define MOBILITY_VID 0x1342
263#define MOBILITY_USB_SERIAL_PID 0x0202 /* EasiDock USB 200 serial */
264
265/*
266 * Active Robots product ids.
267 */
268#define FTDI_ACTIVE_ROBOTS_PID 0xE548 /* USB comms board */
269
250/* Commands */ 270/* Commands */
251#define FTDI_SIO_RESET 0 /* Reset the port */ 271#define FTDI_SIO_RESET 0 /* Reset the port */
252#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 272#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
@@ -259,10 +279,6 @@
259#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */ 279#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */
260#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */ 280#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */
261 281
262/* Port interface code for FT2232C */
263#define INTERFACE_A 1
264#define INTERFACE_B 2
265
266 282
267/* 283/*
268 * BmRequestType: 1100 0000b 284 * BmRequestType: 1100 0000b
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c
new file mode 100644
index 000000000000..64d55fbd206e
--- /dev/null
+++ b/drivers/usb/serial/hp4x.c
@@ -0,0 +1,85 @@
1/*
2 * HP4x Calculators Serial USB driver
3 *
4 * Copyright (C) 2005 Arthur Huillet (ahuillet@users.sf.net)
5 * Copyright (C) 2001-2005 Greg Kroah-Hartman (greg@kroah.com)
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; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * See Documentation/usb/usb-serial.txt for more information on using this driver
13 */
14
15#include <linux/config.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/tty.h>
19#include <linux/module.h>
20#include <linux/usb.h>
21#include "usb-serial.h"
22
23/*
24 * Version Information
25 */
26#define DRIVER_VERSION "v1.00"
27#define DRIVER_DESC "HP4x (48/49) Generic Serial driver"
28
29#define HP_VENDOR_ID 0x03f0
30#define HP49GP_PRODUCT_ID 0x0121
31
32static struct usb_device_id id_table [] = {
33 { USB_DEVICE(HP_VENDOR_ID, HP49GP_PRODUCT_ID) },
34 { } /* Terminating entry */
35};
36
37MODULE_DEVICE_TABLE(usb, id_table);
38
39static struct usb_driver hp49gp_driver = {
40 .owner = THIS_MODULE,
41 .name = "HP4X",
42 .probe = usb_serial_probe,
43 .disconnect = usb_serial_disconnect,
44 .id_table = id_table,
45};
46
47static struct usb_serial_device_type hp49gp_device = {
48 .owner = THIS_MODULE,
49 .name = "HP4X",
50 .id_table = id_table,
51 .num_interrupt_in = NUM_DONT_CARE,
52 .num_bulk_in = NUM_DONT_CARE,
53 .num_bulk_out = NUM_DONT_CARE,
54 .num_ports = 1,
55};
56
57static int __init hp49gp_init(void)
58{
59 int retval;
60 retval = usb_serial_register(&hp49gp_device);
61 if (retval)
62 goto failed_usb_serial_register;
63 retval = usb_register(&hp49gp_driver);
64 if (retval)
65 goto failed_usb_register;
66 info(DRIVER_DESC " " DRIVER_VERSION);
67 return 0;
68failed_usb_register:
69 usb_serial_deregister(&hp49gp_device);
70failed_usb_serial_register:
71 return retval;
72}
73
74static void __exit hp49gp_exit(void)
75{
76 usb_deregister(&hp49gp_driver);
77 usb_serial_deregister(&hp49gp_device);
78}
79
80module_init(hp49gp_init);
81module_exit(hp49gp_exit);
82
83MODULE_DESCRIPTION(DRIVER_DESC);
84MODULE_VERSION(DRIVER_VERSION);
85MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/io_usbvend.h b/drivers/usb/serial/io_usbvend.h
index 8c1fa5e722b1..f1804fd5a3dd 100644
--- a/drivers/usb/serial/io_usbvend.h
+++ b/drivers/usb/serial/io_usbvend.h
@@ -289,7 +289,7 @@
289// 289//
290 290
291// 291//
292// Edgeport Compatiblity Descriptor 292// Edgeport Compatibility Descriptor
293// 293//
294// This descriptor is only returned by Edgeport-compatible devices 294// This descriptor is only returned by Edgeport-compatible devices
295// supporting the EPiC spec. True ION devices do not return this 295// supporting the EPiC spec. True ION devices do not return this
diff --git a/drivers/usb/serial/keyspan_usa90msg.h b/drivers/usb/serial/keyspan_usa90msg.h
index dd935b62c1a8..86708ecd8735 100644
--- a/drivers/usb/serial/keyspan_usa90msg.h
+++ b/drivers/usb/serial/keyspan_usa90msg.h
@@ -19,7 +19,7 @@
19 19
20 This file is available under a BSD-style copyright 20 This file is available under a BSD-style copyright
21 21
22 2. The name of InnoSys Incorprated may not be used to endorse or promote 22 2. The name of InnoSys Incorporated may not be used to endorse or promote
23 products derived from this software without specific prior written 23 products derived from this software without specific prior written
24 permission. 24 permission.
25 25
diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c
index d76483706bc9..5a9321705a74 100644
--- a/drivers/usb/storage/debug.c
+++ b/drivers/usb/storage/debug.c
@@ -47,6 +47,7 @@
47#include <linux/cdrom.h> 47#include <linux/cdrom.h>
48#include <scsi/scsi.h> 48#include <scsi/scsi.h>
49#include <scsi/scsi_cmnd.h> 49#include <scsi/scsi_cmnd.h>
50#include <scsi/scsi_dbg.h>
50 51
51#include "debug.h" 52#include "debug.h"
52#include "scsi.h" 53#include "scsi.h"
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index 7eff03d9b041..f3b60288696c 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -786,7 +786,7 @@ static int usbat_flash_check_media(struct us_data *us,
786 if (rc != USB_STOR_XFER_GOOD) 786 if (rc != USB_STOR_XFER_GOOD)
787 return USB_STOR_TRANSPORT_ERROR; 787 return USB_STOR_TRANSPORT_ERROR;
788 788
789 // Check for media existance 789 // Check for media existence
790 rc = usbat_flash_check_media_present(uio); 790 rc = usbat_flash_check_media_present(uio);
791 if (rc == USBAT_FLASH_MEDIA_NONE) { 791 if (rc == USBAT_FLASH_MEDIA_NONE) {
792 info->sense_key = 0x02; 792 info->sense_key = 0x02;
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index fa68dea6bc6f..d2891f475793 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1,5 +1,5 @@
1/* Driver for USB Mass Storage compliant devices 1/* Driver for USB Mass Storage compliant devices
2 * Ununsual Devices File 2 * Unusual Devices File
3 * 3 *
4 * $Id: unusual_devs.h,v 1.32 2002/02/25 02:41:24 mdharm Exp $ 4 * $Id: unusual_devs.h,v 1.32 2002/02/25 02:41:24 mdharm Exp $
5 * 5 *
@@ -48,6 +48,14 @@
48 * USB development list <linux-usb-devel@lists.sourceforge.net>. 48 * USB development list <linux-usb-devel@lists.sourceforge.net>.
49 */ 49 */
50 50
51/* patch submitted by Vivian Bregier <Vivian.Bregier@imag.fr>
52 */
53UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100,
54 "ATMEL",
55 "SND1 Storage",
56 US_SC_DEVICE, US_PR_DEVICE, NULL,
57 US_FL_IGNORE_RESIDUE),
58
51UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0100, 59UNUSUAL_DEV( 0x03ee, 0x6901, 0x0000, 0x0100,
52 "Mitsumi", 60 "Mitsumi",
53 "USB FDD", 61 "USB FDD",
@@ -517,14 +525,32 @@ UNUSUAL_DEV( 0x05ab, 0x5701, 0x0100, 0x0110,
517 0 ), 525 0 ),
518#endif 526#endif
519 527
528/* Submitted by Sven Anderson <sven-linux@anderson.de>
529 * There are at least four ProductIDs used for iPods, so I added 0x1202 and
530 * 0x1204. They just need the US_FL_FIX_CAPACITY. As the bcdDevice appears
531 * to change with firmware updates, I changed the range to maximum for all
532 * iPod entries.
533 */
534UNUSUAL_DEV( 0x05ac, 0x1202, 0x0000, 0x9999,
535 "Apple",
536 "iPod",
537 US_SC_DEVICE, US_PR_DEVICE, NULL,
538 US_FL_FIX_CAPACITY ),
539
520/* Reported by Avi Kivity <avi@argo.co.il> */ 540/* Reported by Avi Kivity <avi@argo.co.il> */
521UNUSUAL_DEV( 0x05ac, 0x1203, 0x0001, 0x0001, 541UNUSUAL_DEV( 0x05ac, 0x1203, 0x0000, 0x9999,
522 "Apple", 542 "Apple",
523 "iPod", 543 "iPod",
524 US_SC_DEVICE, US_PR_DEVICE, NULL, 544 US_SC_DEVICE, US_PR_DEVICE, NULL,
525 US_FL_FIX_CAPACITY ), 545 US_FL_FIX_CAPACITY ),
526 546
527UNUSUAL_DEV( 0x05ac, 0x1205, 0x0001, 0x0001, 547UNUSUAL_DEV( 0x05ac, 0x1204, 0x0000, 0x9999,
548 "Apple",
549 "iPod",
550 US_SC_DEVICE, US_PR_DEVICE, NULL,
551 US_FL_FIX_CAPACITY ),
552
553UNUSUAL_DEV( 0x05ac, 0x1205, 0x0000, 0x9999,
528 "Apple", 554 "Apple",
529 "iPod", 555 "iPod",
530 US_SC_DEVICE, US_PR_DEVICE, NULL, 556 US_SC_DEVICE, US_PR_DEVICE, NULL,
@@ -976,6 +1002,13 @@ UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x9999,
976 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, 1002 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init,
977 0 ), 1003 0 ),
978 1004
1005/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */
1006UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001,
1007 "Minolta",
1008 "Dimage Z10",
1009 US_SC_DEVICE, US_PR_DEVICE, NULL,
1010 0 ),
1011
979/* Reported by Kotrla Vitezslav <kotrla@ceb.cz> */ 1012/* Reported by Kotrla Vitezslav <kotrla@ceb.cz> */
980UNUSUAL_DEV( 0x1370, 0x6828, 0x0110, 0x0110, 1013UNUSUAL_DEV( 0x1370, 0x6828, 0x0110, 0x0110,
981 "SWISSBIT", 1014 "SWISSBIT",
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 2a1c5965de22..6be8fbec0a0e 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -198,6 +198,14 @@ config FB_SA1100
198 If you plan to use the LCD display with your SA-1100 system, say 198 If you plan to use the LCD display with your SA-1100 system, say
199 Y here. 199 Y here.
200 200
201config FB_IMX
202 tristate "Motorola i.MX LCD support"
203 depends on FB && ARM && ARCH_IMX
204 select FB_CFB_FILLRECT
205 select FB_CFB_COPYAREA
206 select FB_CFB_IMAGEBLIT
207 select FB_SOFT_CURSOR
208
201config FB_CYBER2000 209config FB_CYBER2000
202 tristate "CyberPro 2000/2010/5000 support" 210 tristate "CyberPro 2000/2010/5000 support"
203 depends on FB && PCI && (BROKEN || !SPARC64) 211 depends on FB && PCI && (BROKEN || !SPARC64)
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 92265b741dc3..bd8dc0ffe723 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -90,6 +90,7 @@ obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o
90obj-$(CONFIG_FB_MAXINE) += maxinefb.o 90obj-$(CONFIG_FB_MAXINE) += maxinefb.o
91obj-$(CONFIG_FB_TX3912) += tx3912fb.o 91obj-$(CONFIG_FB_TX3912) += tx3912fb.o
92obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o 92obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o
93obj-$(CONFIG_FB_IMX) += imxfb.o
93 94
94# Platform or fallback drivers go here 95# Platform or fallback drivers go here
95obj-$(CONFIG_FB_VESA) += vesafb.o 96obj-$(CONFIG_FB_VESA) += vesafb.o
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index acdba0c67fb8..321dbe91dc14 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -125,28 +125,28 @@ clcdfb_set_bitfields(struct clcd_fb *fb, struct fb_var_screeninfo *var)
125 case 2: 125 case 2:
126 case 4: 126 case 4:
127 case 8: 127 case 8:
128 var->red.length = 8; 128 var->red.length = var->bits_per_pixel;
129 var->red.offset = 0; 129 var->red.offset = 0;
130 var->green.length = 8; 130 var->green.length = var->bits_per_pixel;
131 var->green.offset = 0; 131 var->green.offset = 0;
132 var->blue.length = 8; 132 var->blue.length = var->bits_per_pixel;
133 var->blue.offset = 0; 133 var->blue.offset = 0;
134 break; 134 break;
135 case 16: 135 case 16:
136 var->red.length = 5; 136 var->red.length = 5;
137 var->green.length = 5; 137 var->green.length = 6;
138 var->blue.length = 5; 138 var->blue.length = 5;
139 if (fb->panel->cntl & CNTL_BGR) { 139 if (fb->panel->cntl & CNTL_BGR) {
140 var->red.offset = 10; 140 var->red.offset = 11;
141 var->green.offset = 5; 141 var->green.offset = 5;
142 var->blue.offset = 0; 142 var->blue.offset = 0;
143 } else { 143 } else {
144 var->red.offset = 0; 144 var->red.offset = 0;
145 var->green.offset = 5; 145 var->green.offset = 5;
146 var->blue.offset = 10; 146 var->blue.offset = 11;
147 } 147 }
148 break; 148 break;
149 case 24: 149 case 32:
150 if (fb->panel->cntl & CNTL_LCDTFT) { 150 if (fb->panel->cntl & CNTL_LCDTFT) {
151 var->red.length = 8; 151 var->red.length = 8;
152 var->green.length = 8; 152 var->green.length = 8;
@@ -178,6 +178,12 @@ static int clcdfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
178 178
179 if (fb->board->check) 179 if (fb->board->check)
180 ret = fb->board->check(fb, var); 180 ret = fb->board->check(fb, var);
181
182 if (ret == 0 &&
183 var->xres_virtual * var->bits_per_pixel / 8 *
184 var->yres_virtual > fb->fb.fix.smem_len)
185 ret = -EINVAL;
186
181 if (ret == 0) 187 if (ret == 0)
182 ret = clcdfb_set_bitfields(fb, var); 188 ret = clcdfb_set_bitfields(fb, var);
183 189
@@ -250,7 +256,7 @@ clcdfb_setcolreg(unsigned int regno, unsigned int red, unsigned int green,
250 convert_bitfield(green, &fb->fb.var.green) | 256 convert_bitfield(green, &fb->fb.var.green) |
251 convert_bitfield(red, &fb->fb.var.red); 257 convert_bitfield(red, &fb->fb.var.red);
252 258
253 if (fb->fb.var.bits_per_pixel == 8 && regno < 256) { 259 if (fb->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR && regno < 256) {
254 int hw_reg = CLCD_PALETTE + ((regno * 2) & ~3); 260 int hw_reg = CLCD_PALETTE + ((regno * 2) & ~3);
255 u32 val, mask, newval; 261 u32 val, mask, newval;
256 262
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index e8eb124754b1..ee25b9e8db60 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -1057,13 +1057,14 @@ static int radeonfb_blank (int blank, struct fb_info *info)
1057 return radeon_screen_blank(rinfo, blank, 0); 1057 return radeon_screen_blank(rinfo, blank, 0);
1058} 1058}
1059 1059
1060static int radeonfb_setcolreg (unsigned regno, unsigned red, unsigned green, 1060static int radeon_setcolreg (unsigned regno, unsigned red, unsigned green,
1061 unsigned blue, unsigned transp, struct fb_info *info) 1061 unsigned blue, unsigned transp,
1062 struct radeonfb_info *rinfo)
1062{ 1063{
1063 struct radeonfb_info *rinfo = info->par;
1064 u32 pindex; 1064 u32 pindex;
1065 unsigned int i; 1065 unsigned int i;
1066 1066
1067
1067 if (regno > 255) 1068 if (regno > 255)
1068 return 1; 1069 return 1;
1069 1070
@@ -1078,20 +1079,7 @@ static int radeonfb_setcolreg (unsigned regno, unsigned red, unsigned green,
1078 pindex = regno; 1079 pindex = regno;
1079 1080
1080 if (!rinfo->asleep) { 1081 if (!rinfo->asleep) {
1081 u32 dac_cntl2, vclk_cntl = 0;
1082
1083 radeon_fifo_wait(9); 1082 radeon_fifo_wait(9);
1084 if (rinfo->is_mobility) {
1085 vclk_cntl = INPLL(VCLK_ECP_CNTL);
1086 OUTPLL(VCLK_ECP_CNTL, vclk_cntl & ~PIXCLK_DAC_ALWAYS_ONb);
1087 }
1088
1089 /* Make sure we are on first palette */
1090 if (rinfo->has_CRTC2) {
1091 dac_cntl2 = INREG(DAC_CNTL2);
1092 dac_cntl2 &= ~DAC2_PALETTE_ACCESS_CNTL;
1093 OUTREG(DAC_CNTL2, dac_cntl2);
1094 }
1095 1083
1096 if (rinfo->bpp == 16) { 1084 if (rinfo->bpp == 16) {
1097 pindex = regno * 8; 1085 pindex = regno * 8;
@@ -1101,24 +1089,27 @@ static int radeonfb_setcolreg (unsigned regno, unsigned red, unsigned green,
1101 if (rinfo->depth == 15 && regno > 31) 1089 if (rinfo->depth == 15 && regno > 31)
1102 return 1; 1090 return 1;
1103 1091
1104 /* For 565, the green component is mixed one order below */ 1092 /* For 565, the green component is mixed one order
1093 * below
1094 */
1105 if (rinfo->depth == 16) { 1095 if (rinfo->depth == 16) {
1106 OUTREG(PALETTE_INDEX, pindex>>1); 1096 OUTREG(PALETTE_INDEX, pindex>>1);
1107 OUTREG(PALETTE_DATA, (rinfo->palette[regno>>1].red << 16) | 1097 OUTREG(PALETTE_DATA,
1108 (green << 8) | (rinfo->palette[regno>>1].blue)); 1098 (rinfo->palette[regno>>1].red << 16) |
1099 (green << 8) |
1100 (rinfo->palette[regno>>1].blue));
1109 green = rinfo->palette[regno<<1].green; 1101 green = rinfo->palette[regno<<1].green;
1110 } 1102 }
1111 } 1103 }
1112 1104
1113 if (rinfo->depth != 16 || regno < 32) { 1105 if (rinfo->depth != 16 || regno < 32) {
1114 OUTREG(PALETTE_INDEX, pindex); 1106 OUTREG(PALETTE_INDEX, pindex);
1115 OUTREG(PALETTE_DATA, (red << 16) | (green << 8) | blue); 1107 OUTREG(PALETTE_DATA, (red << 16) |
1108 (green << 8) | blue);
1116 } 1109 }
1117 if (rinfo->is_mobility)
1118 OUTPLL(VCLK_ECP_CNTL, vclk_cntl);
1119 } 1110 }
1120 if (regno < 16) { 1111 if (regno < 16) {
1121 u32 *pal = info->pseudo_palette; 1112 u32 *pal = rinfo->info->pseudo_palette;
1122 switch (rinfo->depth) { 1113 switch (rinfo->depth) {
1123 case 15: 1114 case 15:
1124 pal[regno] = (regno << 10) | (regno << 5) | regno; 1115 pal[regno] = (regno << 10) | (regno << 5) | regno;
@@ -1138,6 +1129,84 @@ static int radeonfb_setcolreg (unsigned regno, unsigned red, unsigned green,
1138 return 0; 1129 return 0;
1139} 1130}
1140 1131
1132static int radeonfb_setcolreg (unsigned regno, unsigned red, unsigned green,
1133 unsigned blue, unsigned transp,
1134 struct fb_info *info)
1135{
1136 struct radeonfb_info *rinfo = info->par;
1137 u32 dac_cntl2, vclk_cntl = 0;
1138 int rc;
1139
1140 if (!rinfo->asleep) {
1141 if (rinfo->is_mobility) {
1142 vclk_cntl = INPLL(VCLK_ECP_CNTL);
1143 OUTPLL(VCLK_ECP_CNTL,
1144 vclk_cntl & ~PIXCLK_DAC_ALWAYS_ONb);
1145 }
1146
1147 /* Make sure we are on first palette */
1148 if (rinfo->has_CRTC2) {
1149 dac_cntl2 = INREG(DAC_CNTL2);
1150 dac_cntl2 &= ~DAC2_PALETTE_ACCESS_CNTL;
1151 OUTREG(DAC_CNTL2, dac_cntl2);
1152 }
1153 }
1154
1155 rc = radeon_setcolreg (regno, red, green, blue, transp, rinfo);
1156
1157 if (!rinfo->asleep && rinfo->is_mobility)
1158 OUTPLL(VCLK_ECP_CNTL, vclk_cntl);
1159
1160 return rc;
1161}
1162
1163static int radeonfb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
1164{
1165 struct radeonfb_info *rinfo = info->par;
1166 u16 *red, *green, *blue, *transp;
1167 u32 dac_cntl2, vclk_cntl = 0;
1168 int i, start, rc = 0;
1169
1170 if (!rinfo->asleep) {
1171 if (rinfo->is_mobility) {
1172 vclk_cntl = INPLL(VCLK_ECP_CNTL);
1173 OUTPLL(VCLK_ECP_CNTL,
1174 vclk_cntl & ~PIXCLK_DAC_ALWAYS_ONb);
1175 }
1176
1177 /* Make sure we are on first palette */
1178 if (rinfo->has_CRTC2) {
1179 dac_cntl2 = INREG(DAC_CNTL2);
1180 dac_cntl2 &= ~DAC2_PALETTE_ACCESS_CNTL;
1181 OUTREG(DAC_CNTL2, dac_cntl2);
1182 }
1183 }
1184
1185 red = cmap->red;
1186 green = cmap->green;
1187 blue = cmap->blue;
1188 transp = cmap->transp;
1189 start = cmap->start;
1190
1191 for (i = 0; i < cmap->len; i++) {
1192 u_int hred, hgreen, hblue, htransp = 0xffff;
1193
1194 hred = *red++;
1195 hgreen = *green++;
1196 hblue = *blue++;
1197 if (transp)
1198 htransp = *transp++;
1199 rc = radeon_setcolreg (start++, hred, hgreen, hblue, htransp,
1200 rinfo);
1201 if (rc)
1202 break;
1203 }
1204
1205 if (!rinfo->asleep && rinfo->is_mobility)
1206 OUTPLL(VCLK_ECP_CNTL, vclk_cntl);
1207
1208 return rc;
1209}
1141 1210
1142static void radeon_save_state (struct radeonfb_info *rinfo, 1211static void radeon_save_state (struct radeonfb_info *rinfo,
1143 struct radeon_regs *save) 1212 struct radeon_regs *save)
@@ -1796,6 +1865,7 @@ static struct fb_ops radeonfb_ops = {
1796 .fb_check_var = radeonfb_check_var, 1865 .fb_check_var = radeonfb_check_var,
1797 .fb_set_par = radeonfb_set_par, 1866 .fb_set_par = radeonfb_set_par,
1798 .fb_setcolreg = radeonfb_setcolreg, 1867 .fb_setcolreg = radeonfb_setcolreg,
1868 .fb_setcmap = radeonfb_setcmap,
1799 .fb_pan_display = radeonfb_pan_display, 1869 .fb_pan_display = radeonfb_pan_display,
1800 .fb_blank = radeonfb_blank, 1870 .fb_blank = radeonfb_blank,
1801 .fb_ioctl = radeonfb_ioctl, 1871 .fb_ioctl = radeonfb_ioctl,
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 59e3b4b4e7e3..b209adbd508a 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -906,10 +906,13 @@ static void fbcon_init(struct vc_data *vc, int init)
906 struct vc_data *svc = *default_mode; 906 struct vc_data *svc = *default_mode;
907 struct display *t, *p = &fb_display[vc->vc_num]; 907 struct display *t, *p = &fb_display[vc->vc_num];
908 int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256; 908 int logo = 1, new_rows, new_cols, rows, cols, charcnt = 256;
909 int cap = info->flags; 909 int cap;
910 910
911 if (info_idx == -1 || info == NULL) 911 if (info_idx == -1 || info == NULL)
912 return; 912 return;
913
914 cap = info->flags;
915
913 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW || 916 if (vc != svc || logo_shown == FBCON_LOGO_DONTSHOW ||
914 (info->fix.type == FB_TYPE_TEXT)) 917 (info->fix.type == FB_TYPE_TEXT))
915 logo = 0; 918 logo = 0;
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 7d1ae06667c6..bcf59b28a14f 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -337,6 +337,8 @@ static void vgacon_init(struct vc_data *c, int init)
337 c->vc_scan_lines = vga_scan_lines; 337 c->vc_scan_lines = vga_scan_lines;
338 c->vc_font.height = vga_video_font_height; 338 c->vc_font.height = vga_video_font_height;
339 c->vc_complement_mask = 0x7700; 339 c->vc_complement_mask = 0x7700;
340 if (vga_512_chars)
341 c->vc_hi_font_mask = 0x0800;
340 p = *c->vc_uni_pagedir_loc; 342 p = *c->vc_uni_pagedir_loc;
341 if (c->vc_uni_pagedir_loc == &c->vc_uni_pagedir || 343 if (c->vc_uni_pagedir_loc == &c->vc_uni_pagedir ||
342 !--c->vc_uni_pagedir_loc[1]) 344 !--c->vc_uni_pagedir_loc[1])
diff --git a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c
index 8b1b7c687a99..3894b2a501d6 100644
--- a/drivers/video/cyber2000fb.c
+++ b/drivers/video/cyber2000fb.c
@@ -90,6 +90,8 @@ struct cfb_info {
90 */ 90 */
91 u_char ramdac_ctrl; 91 u_char ramdac_ctrl;
92 u_char ramdac_powerdown; 92 u_char ramdac_powerdown;
93
94 u32 pseudo_palette[16];
93}; 95};
94 96
95static char *default_font = "Acorn8x8"; 97static char *default_font = "Acorn8x8";
@@ -1223,9 +1225,7 @@ cyberpro_alloc_fb_info(unsigned int id, char *name)
1223{ 1225{
1224 struct cfb_info *cfb; 1226 struct cfb_info *cfb;
1225 1227
1226 cfb = kmalloc(sizeof(struct cfb_info) + 1228 cfb = kmalloc(sizeof(struct cfb_info), GFP_KERNEL);
1227 sizeof(u32) * 16, GFP_KERNEL);
1228
1229 if (!cfb) 1229 if (!cfb)
1230 return NULL; 1230 return NULL;
1231 1231
@@ -1281,7 +1281,7 @@ cyberpro_alloc_fb_info(unsigned int id, char *name)
1281 1281
1282 cfb->fb.fbops = &cyber2000fb_ops; 1282 cfb->fb.fbops = &cyber2000fb_ops;
1283 cfb->fb.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; 1283 cfb->fb.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
1284 cfb->fb.pseudo_palette = (void *)(cfb + 1); 1284 cfb->fb.pseudo_palette = cfb->pseudo_palette;
1285 1285
1286 fb_alloc_cmap(&cfb->fb.cmap, NR_PALETTE, 0); 1286 fb_alloc_cmap(&cfb->fb.cmap, NR_PALETTE, 0);
1287 1287
diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
index c51f8fb5c1de..4e5ce8f7d65e 100644
--- a/drivers/video/fbcmap.c
+++ b/drivers/video/fbcmap.c
@@ -222,8 +222,11 @@ int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *info)
222 transp = cmap->transp; 222 transp = cmap->transp;
223 start = cmap->start; 223 start = cmap->start;
224 224
225 if (start < 0 || !info->fbops->fb_setcolreg) 225 if (start < 0 || (!info->fbops->fb_setcolreg &&
226 !info->fbops->fb_setcmap))
226 return -EINVAL; 227 return -EINVAL;
228 if (info->fbops->fb_setcmap)
229 return info->fbops->fb_setcmap(cmap, info);
227 for (i = 0; i < cmap->len; i++) { 230 for (i = 0; i < cmap->len; i++) {
228 hred = *red++; 231 hred = *red++;
229 hgreen = *green++; 232 hgreen = *green++;
@@ -250,8 +253,33 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
250 transp = cmap->transp; 253 transp = cmap->transp;
251 start = cmap->start; 254 start = cmap->start;
252 255
253 if (start < 0 || !info->fbops->fb_setcolreg) 256 if (start < 0 || (!info->fbops->fb_setcolreg &&
257 !info->fbops->fb_setcmap))
254 return -EINVAL; 258 return -EINVAL;
259
260 /* If we can batch, do it */
261 if (info->fbops->fb_setcmap && cmap->len > 1) {
262 struct fb_cmap umap;
263 int size = cmap->len * sizeof(u16);
264 int rc;
265
266 memset(&umap, 0, sizeof(struct fb_cmap));
267 rc = fb_alloc_cmap(&umap, cmap->len, transp != NULL);
268 if (rc)
269 return rc;
270 if (copy_from_user(umap.red, red, size) ||
271 copy_from_user(umap.green, green, size) ||
272 copy_from_user(umap.blue, blue, size) ||
273 (transp && copy_from_user(umap.transp, transp, size))) {
274 rc = -EFAULT;
275 }
276 umap.start = start;
277 if (rc == 0)
278 rc = info->fbops->fb_setcmap(&umap, info);
279 fb_dealloc_cmap(&umap);
280 return rc;
281 }
282
255 for (i = 0; i < cmap->len; i++, red++, blue++, green++) { 283 for (i = 0; i < cmap->len; i++, red++, blue++, green++) {
256 if (get_user(hred, red) || 284 if (get_user(hred, red) ||
257 get_user(hgreen, green) || 285 get_user(hgreen, green) ||
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 25f460ca0daf..7705070191d9 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1257,6 +1257,8 @@ int fb_new_modelist(struct fb_info *info)
1257static char *video_options[FB_MAX]; 1257static char *video_options[FB_MAX];
1258static int ofonly; 1258static int ofonly;
1259 1259
1260extern const char *global_mode_option;
1261
1260/** 1262/**
1261 * fb_get_options - get kernel boot parameters 1263 * fb_get_options - get kernel boot parameters
1262 * @name: framebuffer name as it would appear in 1264 * @name: framebuffer name as it would appear in
@@ -1297,9 +1299,6 @@ int fb_get_options(char *name, char **option)
1297 return retval; 1299 return retval;
1298} 1300}
1299 1301
1300
1301extern const char *global_mode_option;
1302
1303/** 1302/**
1304 * video_setup - process command line options 1303 * video_setup - process command line options
1305 * @options: string of options 1304 * @options: string of options
@@ -1313,7 +1312,7 @@ extern const char *global_mode_option;
1313 * Returns zero. 1312 * Returns zero.
1314 * 1313 *
1315 */ 1314 */
1316int __init video_setup(char *options) 1315static int __init video_setup(char *options)
1317{ 1316{
1318 int i, global = 0; 1317 int i, global = 0;
1319 1318
diff --git a/drivers/video/fbmon.c b/drivers/video/fbmon.c
index 978def013587..6cd1976548d4 100644
--- a/drivers/video/fbmon.c
+++ b/drivers/video/fbmon.c
@@ -34,7 +34,6 @@
34#include <asm/prom.h> 34#include <asm/prom.h>
35#include <asm/pci-bridge.h> 35#include <asm/pci-bridge.h>
36#endif 36#endif
37#include <video/edid.h>
38#include "edid.h" 37#include "edid.h"
39 38
40/* 39/*
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 2bdda4010b81..c78a2c5961d3 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -354,7 +354,7 @@ static ssize_t show_pan(struct class_device *class_device, char *buf)
354 fb_info->var.xoffset); 354 fb_info->var.xoffset);
355} 355}
356 356
357struct class_device_attribute class_device_attrs[] = { 357static struct class_device_attribute class_device_attrs[] = {
358 __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp), 358 __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp),
359 __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank), 359 __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank),
360 __ATTR(color_map, S_IRUGO|S_IWUSR, show_cmap, store_cmap), 360 __ATTR(color_map, S_IRUGO|S_IWUSR, show_cmap, store_cmap),
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index 9ec8781794c0..a9a618f2aa6a 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -999,8 +999,16 @@ static int i810_check_params(struct fb_var_screeninfo *var,
999 info->monspecs.dclkmin = 15000000; 999 info->monspecs.dclkmin = 15000000;
1000 1000
1001 if (fb_validate_mode(var, info)) { 1001 if (fb_validate_mode(var, info)) {
1002 if (fb_get_mode(FB_MAXTIMINGS, 0, var, info)) 1002 if (fb_get_mode(FB_MAXTIMINGS, 0, var, info)) {
1003 int default_sync = (info->monspecs.hfmin-HFMIN)
1004 |(info->monspecs.hfmax-HFMAX)
1005 |(info->monspecs.vfmin-VFMIN)
1006 |(info->monspecs.vfmax-VFMAX);
1007 printk("i810fb: invalid video mode%s\n",
1008 default_sync ? "" :
1009 ". Specifying vsyncN/hsyncN parameters may help");
1003 return -EINVAL; 1010 return -EINVAL;
1011 }
1004 } 1012 }
1005 1013
1006 var->xres = xres; 1014 var->xres = xres;
@@ -2023,10 +2031,10 @@ MODULE_PARM_DESC(vyres, "Virtual vertical resolution in scanlines"
2023 " (default = 480)"); 2031 " (default = 480)");
2024module_param(hsync1, int, 0); 2032module_param(hsync1, int, 0);
2025MODULE_PARM_DESC(hsync1, "Minimum horizontal frequency of monitor in KHz" 2033MODULE_PARM_DESC(hsync1, "Minimum horizontal frequency of monitor in KHz"
2026 " (default = 31)"); 2034 " (default = 29)");
2027module_param(hsync2, int, 0); 2035module_param(hsync2, int, 0);
2028MODULE_PARM_DESC(hsync2, "Maximum horizontal frequency of monitor in KHz" 2036MODULE_PARM_DESC(hsync2, "Maximum horizontal frequency of monitor in KHz"
2029 " (default = 31)"); 2037 " (default = 30)");
2030module_param(vsync1, int, 0); 2038module_param(vsync1, int, 0);
2031MODULE_PARM_DESC(vsync1, "Minimum vertical frequency of monitor in Hz" 2039MODULE_PARM_DESC(vsync1, "Minimum vertical frequency of monitor in Hz"
2032 " (default = 50)"); 2040 " (default = 50)");
diff --git a/drivers/video/imsttfb.c b/drivers/video/imsttfb.c
index 5a72ca3c0138..7b9bf45ab6fe 100644
--- a/drivers/video/imsttfb.c
+++ b/drivers/video/imsttfb.c
@@ -1287,12 +1287,12 @@ imsttfb_ioctl(struct inode *inode, struct file *file, u_int cmd,
1287 case FBIMSTT_SETCMAPREG: 1287 case FBIMSTT_SETCMAPREG:
1288 if (copy_from_user(reg, argp, 8) || reg[0] > (0x1000 - sizeof(reg[0])) / sizeof(reg[0])) 1288 if (copy_from_user(reg, argp, 8) || reg[0] > (0x1000 - sizeof(reg[0])) / sizeof(reg[0]))
1289 return -EFAULT; 1289 return -EFAULT;
1290 write_reg_le32(((u_int *)par->cmap_regs), reg[0], reg[1]); 1290 write_reg_le32(((u_int __iomem *)par->cmap_regs), reg[0], reg[1]);
1291 return 0; 1291 return 0;
1292 case FBIMSTT_GETCMAPREG: 1292 case FBIMSTT_GETCMAPREG:
1293 if (copy_from_user(reg, argp, 4) || reg[0] > (0x1000 - sizeof(reg[0])) / sizeof(reg[0])) 1293 if (copy_from_user(reg, argp, 4) || reg[0] > (0x1000 - sizeof(reg[0])) / sizeof(reg[0]))
1294 return -EFAULT; 1294 return -EFAULT;
1295 reg[1] = read_reg_le32(((u_int *)par->cmap_regs), reg[0]); 1295 reg[1] = read_reg_le32(((u_int __iomem *)par->cmap_regs), reg[0]);
1296 if (copy_to_user((void __user *)(arg + 4), &reg[1], 4)) 1296 if (copy_to_user((void __user *)(arg + 4), &reg[1], 4))
1297 return -EFAULT; 1297 return -EFAULT;
1298 return 0; 1298 return 0;
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
new file mode 100644
index 000000000000..8fe1c12a17bd
--- /dev/null
+++ b/drivers/video/imxfb.c
@@ -0,0 +1,695 @@
1/*
2 * linux/drivers/video/imxfb.c
3 *
4 * Freescale i.MX Frame Buffer device driver
5 *
6 * Copyright (C) 2004 Sascha Hauer, Pengutronix
7 * Based on acornfb.c Copyright (C) Russell King.
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file COPYING in the main directory of this archive for
11 * more details.
12 *
13 * Please direct your questions and comments on this driver to the following
14 * email address:
15 *
16 * linux-arm-kernel@lists.arm.linux.org.uk
17 */
18
19//#define DEBUG 1
20
21#include <linux/config.h>
22#include <linux/module.h>
23#include <linux/kernel.h>
24#include <linux/sched.h>
25#include <linux/errno.h>
26#include <linux/string.h>
27#include <linux/interrupt.h>
28#include <linux/slab.h>
29#include <linux/fb.h>
30#include <linux/delay.h>
31#include <linux/init.h>
32#include <linux/ioport.h>
33#include <linux/cpufreq.h>
34#include <linux/device.h>
35#include <linux/dma-mapping.h>
36
37#include <asm/hardware.h>
38#include <asm/io.h>
39#include <asm/mach-types.h>
40#include <asm/uaccess.h>
41#include <asm/arch/imxfb.h>
42
43/*
44 * Complain if VAR is out of range.
45 */
46#define DEBUG_VAR 1
47
48#include "imxfb.h"
49
50static struct imxfb_rgb def_rgb_16 = {
51 .red = { .offset = 8, .length = 4, },
52 .green = { .offset = 4, .length = 4, },
53 .blue = { .offset = 0, .length = 4, },
54 .transp = { .offset = 0, .length = 0, },
55};
56
57static struct imxfb_rgb def_rgb_8 = {
58 .red = { .offset = 0, .length = 8, },
59 .green = { .offset = 0, .length = 8, },
60 .blue = { .offset = 0, .length = 8, },
61 .transp = { .offset = 0, .length = 0, },
62};
63
64static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *info);
65
66static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf)
67{
68 chan &= 0xffff;
69 chan >>= 16 - bf->length;
70 return chan << bf->offset;
71}
72
73#define LCDC_PALETTE(x) __REG2(IMX_LCDC_BASE+0x800, (x)<<2)
74static int
75imxfb_setpalettereg(u_int regno, u_int red, u_int green, u_int blue,
76 u_int trans, struct fb_info *info)
77{
78 struct imxfb_info *fbi = info->par;
79 u_int val, ret = 1;
80
81#define CNVT_TOHW(val,width) ((((val)<<(width))+0x7FFF-(val))>>16)
82 if (regno < fbi->palette_size) {
83 val = (CNVT_TOHW(red, 4) << 8) |
84 (CNVT_TOHW(green,4) << 4) |
85 CNVT_TOHW(blue, 4);
86
87 LCDC_PALETTE(regno) = val;
88 ret = 0;
89 }
90 return ret;
91}
92
93static int
94imxfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
95 u_int trans, struct fb_info *info)
96{
97 struct imxfb_info *fbi = info->par;
98 unsigned int val;
99 int ret = 1;
100
101 /*
102 * If inverse mode was selected, invert all the colours
103 * rather than the register number. The register number
104 * is what you poke into the framebuffer to produce the
105 * colour you requested.
106 */
107 if (fbi->cmap_inverse) {
108 red = 0xffff - red;
109 green = 0xffff - green;
110 blue = 0xffff - blue;
111 }
112
113 /*
114 * If greyscale is true, then we convert the RGB value
115 * to greyscale no mater what visual we are using.
116 */
117 if (info->var.grayscale)
118 red = green = blue = (19595 * red + 38470 * green +
119 7471 * blue) >> 16;
120
121 switch (info->fix.visual) {
122 case FB_VISUAL_TRUECOLOR:
123 /*
124 * 12 or 16-bit True Colour. We encode the RGB value
125 * according to the RGB bitfield information.
126 */
127 if (regno < 16) {
128 u32 *pal = info->pseudo_palette;
129
130 val = chan_to_field(red, &info->var.red);
131 val |= chan_to_field(green, &info->var.green);
132 val |= chan_to_field(blue, &info->var.blue);
133
134 pal[regno] = val;
135 ret = 0;
136 }
137 break;
138
139 case FB_VISUAL_STATIC_PSEUDOCOLOR:
140 case FB_VISUAL_PSEUDOCOLOR:
141 ret = imxfb_setpalettereg(regno, red, green, blue, trans, info);
142 break;
143 }
144
145 return ret;
146}
147
148/*
149 * imxfb_check_var():
150 * Round up in the following order: bits_per_pixel, xres,
151 * yres, xres_virtual, yres_virtual, xoffset, yoffset, grayscale,
152 * bitfields, horizontal timing, vertical timing.
153 */
154static int
155imxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
156{
157 struct imxfb_info *fbi = info->par;
158 int rgbidx;
159
160 if (var->xres < MIN_XRES)
161 var->xres = MIN_XRES;
162 if (var->yres < MIN_YRES)
163 var->yres = MIN_YRES;
164 if (var->xres > fbi->max_xres)
165 var->xres = fbi->max_xres;
166 if (var->yres > fbi->max_yres)
167 var->yres = fbi->max_yres;
168 var->xres_virtual = max(var->xres_virtual, var->xres);
169 var->yres_virtual = max(var->yres_virtual, var->yres);
170
171 pr_debug("var->bits_per_pixel=%d\n", var->bits_per_pixel);
172 switch (var->bits_per_pixel) {
173 case 16:
174 rgbidx = RGB_16;
175 break;
176 case 8:
177 rgbidx = RGB_8;
178 break;
179 default:
180 rgbidx = RGB_16;
181 }
182
183 /*
184 * Copy the RGB parameters for this display
185 * from the machine specific parameters.
186 */
187 var->red = fbi->rgb[rgbidx]->red;
188 var->green = fbi->rgb[rgbidx]->green;
189 var->blue = fbi->rgb[rgbidx]->blue;
190 var->transp = fbi->rgb[rgbidx]->transp;
191
192 pr_debug("RGBT length = %d:%d:%d:%d\n",
193 var->red.length, var->green.length, var->blue.length,
194 var->transp.length);
195
196 pr_debug("RGBT offset = %d:%d:%d:%d\n",
197 var->red.offset, var->green.offset, var->blue.offset,
198 var->transp.offset);
199
200 return 0;
201}
202
203/*
204 * imxfb_set_par():
205 * Set the user defined part of the display for the specified console
206 */
207static int imxfb_set_par(struct fb_info *info)
208{
209 struct imxfb_info *fbi = info->par;
210 struct fb_var_screeninfo *var = &info->var;
211
212 pr_debug("set_par\n");
213
214 if (var->bits_per_pixel == 16)
215 info->fix.visual = FB_VISUAL_TRUECOLOR;
216 else if (!fbi->cmap_static)
217 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
218 else {
219 /*
220 * Some people have weird ideas about wanting static
221 * pseudocolor maps. I suspect their user space
222 * applications are broken.
223 */
224 info->fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR;
225 }
226
227 info->fix.line_length = var->xres_virtual *
228 var->bits_per_pixel / 8;
229 fbi->palette_size = var->bits_per_pixel == 8 ? 256 : 16;
230
231 imxfb_activate_var(var, info);
232
233 return 0;
234}
235
236static void imxfb_enable_controller(struct imxfb_info *fbi)
237{
238 pr_debug("Enabling LCD controller\n");
239
240 /* initialize LCDC */
241 LCDC_RMCR &= ~RMCR_LCDC_EN; /* just to be safe... */
242
243 LCDC_SSA = fbi->screen_dma;
244 /* physical screen start address */
245 LCDC_VPW = VPW_VPW(fbi->max_xres * fbi->max_bpp / 8 / 4);
246
247 LCDC_POS = 0x00000000; /* panning offset 0 (0 pixel offset) */
248
249 /* disable hardware cursor */
250 LCDC_CPOS &= ~(CPOS_CC0 | CPOS_CC1);
251
252 /* fixed burst length (see erratum 11) */
253 LCDC_DMACR = DMACR_BURST | DMACR_HM(8) | DMACR_TM(2);
254
255 LCDC_RMCR = RMCR_LCDC_EN;
256
257 if(fbi->backlight_power)
258 fbi->backlight_power(1);
259 if(fbi->lcd_power)
260 fbi->lcd_power(1);
261}
262
263static void imxfb_disable_controller(struct imxfb_info *fbi)
264{
265 pr_debug("Disabling LCD controller\n");
266
267 if(fbi->backlight_power)
268 fbi->backlight_power(0);
269 if(fbi->lcd_power)
270 fbi->lcd_power(0);
271
272 LCDC_RMCR = 0;
273}
274
275static int imxfb_blank(int blank, struct fb_info *info)
276{
277 struct imxfb_info *fbi = info->par;
278
279 pr_debug("imxfb_blank: blank=%d\n", blank);
280
281 switch (blank) {
282 case FB_BLANK_POWERDOWN:
283 case FB_BLANK_VSYNC_SUSPEND:
284 case FB_BLANK_HSYNC_SUSPEND:
285 case FB_BLANK_NORMAL:
286 imxfb_disable_controller(fbi);
287 break;
288
289 case FB_BLANK_UNBLANK:
290 imxfb_enable_controller(fbi);
291 break;
292 }
293 return 0;
294}
295
296static struct fb_ops imxfb_ops = {
297 .owner = THIS_MODULE,
298 .fb_check_var = imxfb_check_var,
299 .fb_set_par = imxfb_set_par,
300 .fb_setcolreg = imxfb_setcolreg,
301 .fb_fillrect = cfb_fillrect,
302 .fb_copyarea = cfb_copyarea,
303 .fb_imageblit = cfb_imageblit,
304 .fb_blank = imxfb_blank,
305 .fb_cursor = soft_cursor, /* FIXME: i.MX can do hardware cursor */
306};
307
308/*
309 * imxfb_activate_var():
310 * Configures LCD Controller based on entries in var parameter. Settings are
311 * only written to the controller if changes were made.
312 */
313static int imxfb_activate_var(struct fb_var_screeninfo *var, struct fb_info *info)
314{
315 struct imxfb_info *fbi = info->par;
316 pr_debug("var: xres=%d hslen=%d lm=%d rm=%d\n",
317 var->xres, var->hsync_len,
318 var->left_margin, var->right_margin);
319 pr_debug("var: yres=%d vslen=%d um=%d bm=%d\n",
320 var->yres, var->vsync_len,
321 var->upper_margin, var->lower_margin);
322
323#if DEBUG_VAR
324 if (var->xres < 16 || var->xres > 1024)
325 printk(KERN_ERR "%s: invalid xres %d\n",
326 info->fix.id, var->xres);
327 if (var->hsync_len < 1 || var->hsync_len > 64)
328 printk(KERN_ERR "%s: invalid hsync_len %d\n",
329 info->fix.id, var->hsync_len);
330 if (var->left_margin > 255)
331 printk(KERN_ERR "%s: invalid left_margin %d\n",
332 info->fix.id, var->left_margin);
333 if (var->right_margin > 255)
334 printk(KERN_ERR "%s: invalid right_margin %d\n",
335 info->fix.id, var->right_margin);
336 if (var->yres < 1 || var->yres > 511)
337 printk(KERN_ERR "%s: invalid yres %d\n",
338 info->fix.id, var->yres);
339 if (var->vsync_len > 100)
340 printk(KERN_ERR "%s: invalid vsync_len %d\n",
341 info->fix.id, var->vsync_len);
342 if (var->upper_margin > 63)
343 printk(KERN_ERR "%s: invalid upper_margin %d\n",
344 info->fix.id, var->upper_margin);
345 if (var->lower_margin > 255)
346 printk(KERN_ERR "%s: invalid lower_margin %d\n",
347 info->fix.id, var->lower_margin);
348#endif
349
350 LCDC_HCR = HCR_H_WIDTH(var->hsync_len) |
351 HCR_H_WAIT_1(var->left_margin) |
352 HCR_H_WAIT_2(var->right_margin);
353
354 LCDC_VCR = VCR_V_WIDTH(var->vsync_len) |
355 VCR_V_WAIT_1(var->upper_margin) |
356 VCR_V_WAIT_2(var->lower_margin);
357
358 LCDC_SIZE = SIZE_XMAX(var->xres) | SIZE_YMAX(var->yres);
359 LCDC_PCR = fbi->pcr;
360 LCDC_PWMR = fbi->pwmr;
361 LCDC_LSCR1 = fbi->lscr1;
362
363 return 0;
364}
365
366static void imxfb_setup_gpio(struct imxfb_info *fbi)
367{
368 int width;
369
370 LCDC_RMCR &= ~(RMCR_LCDC_EN | RMCR_SELF_REF);
371
372 if( fbi->pcr & PCR_TFT )
373 width = 16;
374 else
375 width = 1 << ((fbi->pcr >> 28) & 0x3);
376
377 switch(width) {
378 case 16:
379 imx_gpio_mode(PD30_PF_LD15);
380 imx_gpio_mode(PD29_PF_LD14);
381 imx_gpio_mode(PD28_PF_LD13);
382 imx_gpio_mode(PD27_PF_LD12);
383 imx_gpio_mode(PD26_PF_LD11);
384 imx_gpio_mode(PD25_PF_LD10);
385 imx_gpio_mode(PD24_PF_LD9);
386 imx_gpio_mode(PD23_PF_LD8);
387 case 8:
388 imx_gpio_mode(PD22_PF_LD7);
389 imx_gpio_mode(PD21_PF_LD6);
390 imx_gpio_mode(PD20_PF_LD5);
391 imx_gpio_mode(PD19_PF_LD4);
392 case 4:
393 imx_gpio_mode(PD18_PF_LD3);
394 imx_gpio_mode(PD17_PF_LD2);
395 case 2:
396 imx_gpio_mode(PD16_PF_LD1);
397 case 1:
398 imx_gpio_mode(PD15_PF_LD0);
399 }
400
401 /* initialize GPIOs */
402 imx_gpio_mode(PD6_PF_LSCLK);
403 imx_gpio_mode(PD10_PF_SPL_SPR);
404 imx_gpio_mode(PD11_PF_CONTRAST);
405 imx_gpio_mode(PD14_PF_FLM_VSYNC);
406 imx_gpio_mode(PD13_PF_LP_HSYNC);
407 imx_gpio_mode(PD7_PF_REV);
408 imx_gpio_mode(PD8_PF_CLS);
409
410#ifndef CONFIG_MACH_PIMX1
411 /* on PiMX1 used as buffers enable signal
412 */
413 imx_gpio_mode(PD9_PF_PS);
414#endif
415
416#ifndef CONFIG_MACH_MX1FS2
417 /* on mx1fs2 this pin is used to (de)activate the display, so we need
418 * it as a normal gpio
419 */
420 imx_gpio_mode(PD12_PF_ACD_OE);
421#endif
422
423}
424
425#ifdef CONFIG_PM
426/*
427 * Power management hooks. Note that we won't be called from IRQ context,
428 * unlike the blank functions above, so we may sleep.
429 */
430static int imxfb_suspend(struct device *dev, u32 state, u32 level)
431{
432 struct imxfb_info *fbi = dev_get_drvdata(dev);
433 pr_debug("%s\n",__FUNCTION__);
434
435 if (level == SUSPEND_DISABLE || level == SUSPEND_POWER_DOWN)
436 imxfb_disable_controller(fbi);
437 return 0;
438}
439
440static int imxfb_resume(struct device *dev, u32 level)
441{
442 struct imxfb_info *fbi = dev_get_drvdata(dev);
443 pr_debug("%s\n",__FUNCTION__);
444
445 if (level == RESUME_ENABLE)
446 imxfb_enable_controller(fbi);
447 return 0;
448}
449#else
450#define imxfb_suspend NULL
451#define imxfb_resume NULL
452#endif
453
454static int __init imxfb_init_fbinfo(struct device *dev)
455{
456 struct imxfb_mach_info *inf = dev->platform_data;
457 struct fb_info *info = dev_get_drvdata(dev);
458 struct imxfb_info *fbi = info->par;
459
460 pr_debug("%s\n",__FUNCTION__);
461
462 info->pseudo_palette = kmalloc( sizeof(u32) * 16, GFP_KERNEL);
463 if (!info->pseudo_palette)
464 return -ENOMEM;
465
466 memset(fbi, 0, sizeof(struct imxfb_info));
467 fbi->dev = dev;
468
469 strlcpy(info->fix.id, IMX_NAME, sizeof(info->fix.id));
470
471 info->fix.type = FB_TYPE_PACKED_PIXELS;
472 info->fix.type_aux = 0;
473 info->fix.xpanstep = 0;
474 info->fix.ypanstep = 0;
475 info->fix.ywrapstep = 0;
476 info->fix.accel = FB_ACCEL_NONE;
477
478 info->var.nonstd = 0;
479 info->var.activate = FB_ACTIVATE_NOW;
480 info->var.height = -1;
481 info->var.width = -1;
482 info->var.accel_flags = 0;
483 info->var.vmode = FB_VMODE_NONINTERLACED;
484
485 info->fbops = &imxfb_ops;
486 info->flags = FBINFO_FLAG_DEFAULT;
487 info->pseudo_palette = (fbi + 1);
488
489 fbi->rgb[RGB_16] = &def_rgb_16;
490 fbi->rgb[RGB_8] = &def_rgb_8;
491
492 fbi->max_xres = inf->xres;
493 info->var.xres = inf->xres;
494 info->var.xres_virtual = inf->xres;
495 fbi->max_yres = inf->yres;
496 info->var.yres = inf->yres;
497 info->var.yres_virtual = inf->yres;
498 fbi->max_bpp = inf->bpp;
499 info->var.bits_per_pixel = inf->bpp;
500 info->var.pixclock = inf->pixclock;
501 info->var.hsync_len = inf->hsync_len;
502 info->var.left_margin = inf->left_margin;
503 info->var.right_margin = inf->right_margin;
504 info->var.vsync_len = inf->vsync_len;
505 info->var.upper_margin = inf->upper_margin;
506 info->var.lower_margin = inf->lower_margin;
507 info->var.sync = inf->sync;
508 info->var.grayscale = inf->cmap_greyscale;
509 fbi->cmap_inverse = inf->cmap_inverse;
510 fbi->pcr = inf->pcr;
511 fbi->lscr1 = inf->lscr1;
512 fbi->pwmr = inf->pwmr;
513 fbi->lcd_power = inf->lcd_power;
514 fbi->backlight_power = inf->backlight_power;
515 info->fix.smem_len = fbi->max_xres * fbi->max_yres *
516 fbi->max_bpp / 8;
517
518 return 0;
519}
520
521/*
522 * Allocates the DRAM memory for the frame buffer. This buffer is
523 * remapped into a non-cached, non-buffered, memory region to
524 * allow pixel writes to occur without flushing the cache.
525 * Once this area is remapped, all virtual memory access to the
526 * video memory should occur at the new region.
527 */
528static int __init imxfb_map_video_memory(struct fb_info *info)
529{
530 struct imxfb_info *fbi = info->par;
531
532 fbi->map_size = PAGE_ALIGN(info->fix.smem_len);
533 fbi->map_cpu = dma_alloc_writecombine(fbi->dev, fbi->map_size,
534 &fbi->map_dma,GFP_KERNEL);
535
536 if (fbi->map_cpu) {
537 info->screen_base = fbi->map_cpu;
538 fbi->screen_cpu = fbi->map_cpu;
539 fbi->screen_dma = fbi->map_dma;
540 info->fix.smem_start = fbi->screen_dma;
541 }
542
543 return fbi->map_cpu ? 0 : -ENOMEM;
544}
545
546static int __init imxfb_probe(struct device *dev)
547{
548 struct platform_device *pdev = to_platform_device(dev);
549 struct imxfb_info *fbi;
550 struct fb_info *info;
551 struct imxfb_mach_info *inf;
552 struct resource *res;
553 int ret;
554
555 printk("i.MX Framebuffer driver\n");
556
557 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
558 if(!res)
559 return -ENODEV;
560
561 inf = dev->platform_data;
562 if(!inf) {
563 dev_err(dev,"No platform_data available\n");
564 return -ENOMEM;
565 }
566
567 info = framebuffer_alloc(sizeof(struct imxfb_info), dev);
568 if(!info)
569 return -ENOMEM;
570
571 fbi = info->par;
572
573 dev_set_drvdata(dev, info);
574
575 ret = imxfb_init_fbinfo(dev);
576 if( ret < 0 )
577 goto failed_init;
578
579 res = request_mem_region(res->start, res->end - res->start + 1, "IMXFB");
580 if (!res) {
581 ret = -EBUSY;
582 goto failed_regs;
583 }
584
585 if (!inf->fixed_screen_cpu) {
586 ret = imxfb_map_video_memory(info);
587 if (ret) {
588 dev_err(dev, "Failed to allocate video RAM: %d\n", ret);
589 ret = -ENOMEM;
590 goto failed_map;
591 }
592 } else {
593 /* Fixed framebuffer mapping enables location of the screen in eSRAM */
594 fbi->map_cpu = inf->fixed_screen_cpu;
595 fbi->map_dma = inf->fixed_screen_dma;
596 info->screen_base = fbi->map_cpu;
597 fbi->screen_cpu = fbi->map_cpu;
598 fbi->screen_dma = fbi->map_dma;
599 info->fix.smem_start = fbi->screen_dma;
600 }
601
602 /*
603 * This makes sure that our colour bitfield
604 * descriptors are correctly initialised.
605 */
606 imxfb_check_var(&info->var, info);
607
608 ret = fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0);
609 if (ret < 0)
610 goto failed_cmap;
611
612 imxfb_setup_gpio(fbi);
613
614 imxfb_set_par(info);
615 ret = register_framebuffer(info);
616 if (ret < 0) {
617 dev_err(dev, "failed to register framebuffer\n");
618 goto failed_register;
619 }
620
621 imxfb_enable_controller(fbi);
622
623 return 0;
624
625failed_register:
626 fb_dealloc_cmap(&info->cmap);
627failed_cmap:
628 if (!inf->fixed_screen_cpu)
629 dma_free_writecombine(dev,fbi->map_size,fbi->map_cpu,
630 fbi->map_dma);
631failed_map:
632 kfree(info->pseudo_palette);
633failed_regs:
634 release_mem_region(res->start, res->end - res->start);
635failed_init:
636 dev_set_drvdata(dev, NULL);
637 framebuffer_release(info);
638 return ret;
639}
640
641static int imxfb_remove(struct device *dev)
642{
643 struct platform_device *pdev = to_platform_device(dev);
644 struct fb_info *info = dev_get_drvdata(dev);
645 struct resource *res;
646
647 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
648
649 /* disable LCD controller */
650 LCDC_RMCR &= ~RMCR_LCDC_EN;
651
652 unregister_framebuffer(info);
653
654 fb_dealloc_cmap(&info->cmap);
655 kfree(info->pseudo_palette);
656 framebuffer_release(info);
657
658 release_mem_region(res->start, res->end - res->start + 1);
659 dev_set_drvdata(dev, NULL);
660
661 return 0;
662}
663
664void imxfb_shutdown(struct device * dev)
665{
666 /* disable LCD Controller */
667 LCDC_RMCR &= ~RMCR_LCDC_EN;
668}
669
670static struct device_driver imxfb_driver = {
671 .name = "imx-fb",
672 .bus = &platform_bus_type,
673 .probe = imxfb_probe,
674 .suspend = imxfb_suspend,
675 .resume = imxfb_resume,
676 .remove = imxfb_remove,
677 .shutdown = imxfb_shutdown,
678};
679
680int __init imxfb_init(void)
681{
682 return driver_register(&imxfb_driver);
683}
684
685static void __exit imxfb_cleanup(void)
686{
687 driver_unregister(&imxfb_driver);
688}
689
690module_init(imxfb_init);
691module_exit(imxfb_cleanup);
692
693MODULE_DESCRIPTION("Motorola i.MX framebuffer driver");
694MODULE_AUTHOR("Sascha Hauer, Pengutronix");
695MODULE_LICENSE("GPL");
diff --git a/drivers/video/imxfb.h b/drivers/video/imxfb.h
new file mode 100644
index 000000000000..128c3ee515c7
--- /dev/null
+++ b/drivers/video/imxfb.h
@@ -0,0 +1,72 @@
1/*
2 * linux/drivers/video/imxfb.h
3 *
4 * Freescale i.MX Frame Buffer device driver
5 *
6 * Copyright (C) 2004 S.Hauer, Pengutronix
7 *
8 * Copyright (C) 1999 Eric A. Thomas
9 * Based on acornfb.c Copyright (C) Russell King.
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file COPYING in the main directory of this archive
13 * for more details.
14 */
15
16/*
17 * These are the bitfields for each
18 * display depth that we support.
19 */
20struct imxfb_rgb {
21 struct fb_bitfield red;
22 struct fb_bitfield green;
23 struct fb_bitfield blue;
24 struct fb_bitfield transp;
25};
26
27#define RGB_16 (0)
28#define RGB_8 (1)
29#define NR_RGB 2
30
31struct imxfb_info {
32 struct device *dev;
33 struct imxfb_rgb *rgb[NR_RGB];
34
35 u_int max_bpp;
36 u_int max_xres;
37 u_int max_yres;
38
39 /*
40 * These are the addresses we mapped
41 * the framebuffer memory region to.
42 */
43 dma_addr_t map_dma;
44 u_char * map_cpu;
45 u_int map_size;
46
47 u_char * screen_cpu;
48 dma_addr_t screen_dma;
49 u_int palette_size;
50
51 dma_addr_t dbar1;
52 dma_addr_t dbar2;
53
54 u_int pcr;
55 u_int pwmr;
56 u_int lscr1;
57 u_int cmap_inverse:1,
58 cmap_static:1,
59 unused:30;
60
61 void (*lcd_power)(int);
62 void (*backlight_power)(int);
63};
64
65#define IMX_NAME "IMX"
66
67/*
68 * Minimum X and Y resolutions
69 */
70#define MIN_XRES 64
71#define MIN_YRES 64
72
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index 6a05b7000830..549e22939260 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -135,9 +135,45 @@
135#endif 135#endif
136 136
137#include "intelfb.h" 137#include "intelfb.h"
138#include "intelfbdrv.h"
139#include "intelfbhw.h" 138#include "intelfbhw.h"
140 139
140static void __devinit get_initial_mode(struct intelfb_info *dinfo);
141static void update_dinfo(struct intelfb_info *dinfo,
142 struct fb_var_screeninfo *var);
143static int intelfb_get_fix(struct fb_fix_screeninfo *fix,
144 struct fb_info *info);
145
146static int intelfb_check_var(struct fb_var_screeninfo *var,
147 struct fb_info *info);
148static int intelfb_set_par(struct fb_info *info);
149static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
150 unsigned blue, unsigned transp,
151 struct fb_info *info);
152
153static int intelfb_blank(int blank, struct fb_info *info);
154static int intelfb_pan_display(struct fb_var_screeninfo *var,
155 struct fb_info *info);
156
157static void intelfb_fillrect(struct fb_info *info,
158 const struct fb_fillrect *rect);
159static void intelfb_copyarea(struct fb_info *info,
160 const struct fb_copyarea *region);
161static void intelfb_imageblit(struct fb_info *info,
162 const struct fb_image *image);
163static int intelfb_cursor(struct fb_info *info,
164 struct fb_cursor *cursor);
165
166static int intelfb_sync(struct fb_info *info);
167
168static int intelfb_ioctl(struct inode *inode, struct file *file,
169 unsigned int cmd, unsigned long arg,
170 struct fb_info *info);
171
172static int __devinit intelfb_pci_register(struct pci_dev *pdev,
173 const struct pci_device_id *ent);
174static void __devexit intelfb_pci_unregister(struct pci_dev *pdev);
175static int __devinit intelfb_set_fbinfo(struct intelfb_info *dinfo);
176
141/* 177/*
142 * Limiting the class to PCI_CLASS_DISPLAY_VGA prevents function 1 of the 178 * Limiting the class to PCI_CLASS_DISPLAY_VGA prevents function 1 of the
143 * mobile chipsets from being registered. 179 * mobile chipsets from being registered.
diff --git a/drivers/video/intelfb/intelfbdrv.h b/drivers/video/intelfb/intelfbdrv.h
deleted file mode 100644
index cc3058128884..000000000000
--- a/drivers/video/intelfb/intelfbdrv.h
+++ /dev/null
@@ -1,68 +0,0 @@
1#ifndef _INTELFBDRV_H
2#define _INTELFBDRV_H
3
4/*
5 ******************************************************************************
6 * intelfb
7 *
8 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G
9 * integrated graphics chips.
10 *
11 * Copyright © 2004 Sylvain Meyer
12 *
13 * Author: Sylvain Meyer
14 *
15 ******************************************************************************
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29*/
30
31static void __devinit get_initial_mode(struct intelfb_info *dinfo);
32static void update_dinfo(struct intelfb_info *dinfo,
33 struct fb_var_screeninfo *var);
34static int intelfb_get_fix(struct fb_fix_screeninfo *fix,
35 struct fb_info *info);
36
37static int intelfb_check_var(struct fb_var_screeninfo *var,
38 struct fb_info *info);
39static int intelfb_set_par(struct fb_info *info);
40static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green,
41 unsigned blue, unsigned transp,
42 struct fb_info *info);
43
44static int intelfb_blank(int blank, struct fb_info *info);
45static int intelfb_pan_display(struct fb_var_screeninfo *var,
46 struct fb_info *info);
47
48static void intelfb_fillrect(struct fb_info *info,
49 const struct fb_fillrect *rect);
50static void intelfb_copyarea(struct fb_info *info,
51 const struct fb_copyarea *region);
52static void intelfb_imageblit(struct fb_info *info,
53 const struct fb_image *image);
54static int intelfb_cursor(struct fb_info *info,
55 struct fb_cursor *cursor);
56
57static int intelfb_sync(struct fb_info *info);
58
59static int intelfb_ioctl(struct inode *inode, struct file *file,
60 unsigned int cmd, unsigned long arg,
61 struct fb_info *info);
62
63static int __devinit intelfb_pci_register(struct pci_dev *pdev,
64 const struct pci_device_id *ent);
65static void __devexit intelfb_pci_unregister(struct pci_dev *pdev);
66static int __devinit intelfb_set_fbinfo(struct intelfb_info *dinfo);
67
68#endif
diff --git a/drivers/video/logo/Kconfig b/drivers/video/logo/Kconfig
index 849b47b210ec..6ba10e3aceff 100644
--- a/drivers/video/logo/Kconfig
+++ b/drivers/video/logo/Kconfig
@@ -45,7 +45,7 @@ config LOGO_SGI_CLUT224
45 45
46config LOGO_SUN_CLUT224 46config LOGO_SUN_CLUT224
47 bool "224-color Sun Linux logo" 47 bool "224-color Sun Linux logo"
48 depends on LOGO && (SPARC || SPARC64) 48 depends on LOGO && (SPARC32 || SPARC64)
49 default y 49 default y
50 50
51config LOGO_SUPERH_MONO 51config LOGO_SUPERH_MONO
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index 3a6555a8aaa2..47733f58153b 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -408,6 +408,7 @@ static int hwcur __devinitdata = 0;
408static int noaccel __devinitdata = 0; 408static int noaccel __devinitdata = 0;
409static int noscale __devinitdata = 0; 409static int noscale __devinitdata = 0;
410static int paneltweak __devinitdata = 0; 410static int paneltweak __devinitdata = 0;
411static int vram __devinitdata = 0;
411#ifdef CONFIG_MTRR 412#ifdef CONFIG_MTRR
412static int nomtrr __devinitdata = 0; 413static int nomtrr __devinitdata = 0;
413#endif 414#endif
@@ -1180,7 +1181,7 @@ static int nvidiafb_check_var(struct fb_var_screeninfo *var,
1180 1181
1181 var->xres_virtual = (var->xres_virtual + 63) & ~63; 1182 var->xres_virtual = (var->xres_virtual + 63) & ~63;
1182 1183
1183 vramlen = info->fix.smem_len; 1184 vramlen = info->screen_size;
1184 pitch = ((var->xres_virtual * var->bits_per_pixel) + 7) / 8; 1185 pitch = ((var->xres_virtual * var->bits_per_pixel) + 7) / 8;
1185 memlen = pitch * var->yres_virtual; 1186 memlen = pitch * var->yres_virtual;
1186 1187
@@ -1343,7 +1344,7 @@ static int __devinit nvidia_set_fbinfo(struct fb_info *info)
1343 /* maximize virtual vertical length */ 1344 /* maximize virtual vertical length */
1344 lpitch = info->var.xres_virtual * 1345 lpitch = info->var.xres_virtual *
1345 ((info->var.bits_per_pixel + 7) >> 3); 1346 ((info->var.bits_per_pixel + 7) >> 3);
1346 info->var.yres_virtual = info->fix.smem_len / lpitch; 1347 info->var.yres_virtual = info->screen_size / lpitch;
1347 1348
1348 info->pixmap.scan_align = 4; 1349 info->pixmap.scan_align = 4;
1349 info->pixmap.buf_align = 4; 1350 info->pixmap.buf_align = 4;
@@ -1507,12 +1508,20 @@ static int __devinit nvidiafb_probe(struct pci_dev *pd,
1507 1508
1508 par->FbAddress = nvidiafb_fix.smem_start; 1509 par->FbAddress = nvidiafb_fix.smem_start;
1509 par->FbMapSize = par->RamAmountKBytes * 1024; 1510 par->FbMapSize = par->RamAmountKBytes * 1024;
1511 if (vram && vram * 1024 * 1024 < par->FbMapSize)
1512 par->FbMapSize = vram * 1024 * 1024;
1513
1514 /* Limit amount of vram to 64 MB */
1515 if (par->FbMapSize > 64 * 1024 * 1024)
1516 par->FbMapSize = 64 * 1024 * 1024;
1517
1510 par->FbUsableSize = par->FbMapSize - (128 * 1024); 1518 par->FbUsableSize = par->FbMapSize - (128 * 1024);
1511 par->ScratchBufferSize = (par->Architecture < NV_ARCH_10) ? 8 * 1024 : 1519 par->ScratchBufferSize = (par->Architecture < NV_ARCH_10) ? 8 * 1024 :
1512 16 * 1024; 1520 16 * 1024;
1513 par->ScratchBufferStart = par->FbUsableSize - par->ScratchBufferSize; 1521 par->ScratchBufferStart = par->FbUsableSize - par->ScratchBufferSize;
1514 info->screen_base = ioremap(nvidiafb_fix.smem_start, par->FbMapSize); 1522 info->screen_base = ioremap(nvidiafb_fix.smem_start, par->FbMapSize);
1515 nvidiafb_fix.smem_len = par->FbUsableSize; 1523 info->screen_size = par->FbUsableSize;
1524 nvidiafb_fix.smem_len = par->RamAmountKBytes * 1024;
1516 1525
1517 if (!info->screen_base) { 1526 if (!info->screen_base) {
1518 printk(KERN_ERR PFX "cannot ioremap FB base\n"); 1527 printk(KERN_ERR PFX "cannot ioremap FB base\n");
@@ -1524,7 +1533,8 @@ static int __devinit nvidiafb_probe(struct pci_dev *pd,
1524#ifdef CONFIG_MTRR 1533#ifdef CONFIG_MTRR
1525 if (!nomtrr) { 1534 if (!nomtrr) {
1526 par->mtrr.vram = mtrr_add(nvidiafb_fix.smem_start, 1535 par->mtrr.vram = mtrr_add(nvidiafb_fix.smem_start,
1527 par->FbMapSize, MTRR_TYPE_WRCOMB, 1); 1536 par->RamAmountKBytes * 1024,
1537 MTRR_TYPE_WRCOMB, 1);
1528 if (par->mtrr.vram < 0) { 1538 if (par->mtrr.vram < 0) {
1529 printk(KERN_ERR PFX "unable to setup MTRR\n"); 1539 printk(KERN_ERR PFX "unable to setup MTRR\n");
1530 } else { 1540 } else {
@@ -1566,9 +1576,9 @@ static int __devinit nvidiafb_probe(struct pci_dev *pd,
1566 1576
1567 err_out_iounmap_fb: 1577 err_out_iounmap_fb:
1568 iounmap(info->screen_base); 1578 iounmap(info->screen_base);
1579 err_out_free_base1:
1569 fb_destroy_modedb(info->monspecs.modedb); 1580 fb_destroy_modedb(info->monspecs.modedb);
1570 nvidia_delete_i2c_busses(par); 1581 nvidia_delete_i2c_busses(par);
1571 err_out_free_base1:
1572 iounmap(par->REGS); 1582 iounmap(par->REGS);
1573 err_out_free_base0: 1583 err_out_free_base0:
1574 pci_release_regions(pd); 1584 pci_release_regions(pd);
@@ -1645,6 +1655,8 @@ static int __devinit nvidiafb_setup(char *options)
1645 noscale = 1; 1655 noscale = 1;
1646 } else if (!strncmp(this_opt, "paneltweak:", 11)) { 1656 } else if (!strncmp(this_opt, "paneltweak:", 11)) {
1647 paneltweak = simple_strtoul(this_opt+11, NULL, 0); 1657 paneltweak = simple_strtoul(this_opt+11, NULL, 0);
1658 } else if (!strncmp(this_opt, "vram:", 5)) {
1659 vram = simple_strtoul(this_opt+5, NULL, 0);
1648#ifdef CONFIG_MTRR 1660#ifdef CONFIG_MTRR
1649 } else if (!strncmp(this_opt, "nomtrr", 6)) { 1661 } else if (!strncmp(this_opt, "nomtrr", 6)) {
1650 nomtrr = 1; 1662 nomtrr = 1;
@@ -1716,6 +1728,10 @@ module_param(forceCRTC, int, 0);
1716MODULE_PARM_DESC(forceCRTC, 1728MODULE_PARM_DESC(forceCRTC,
1717 "Forces usage of a particular CRTC in case autodetection " 1729 "Forces usage of a particular CRTC in case autodetection "
1718 "fails. (0 or 1) (default=autodetect)"); 1730 "fails. (0 or 1) (default=autodetect)");
1731module_param(vram, int, 0);
1732MODULE_PARM_DESC(vram,
1733 "amount of framebuffer memory to remap in MiB"
1734 "(default=0 - remap entire memory)");
1719#ifdef CONFIG_MTRR 1735#ifdef CONFIG_MTRR
1720module_param(nomtrr, bool, 0); 1736module_param(nomtrr, bool, 0);
1721MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) " 1737MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) "
diff --git a/drivers/video/radeonfb.c b/drivers/video/radeonfb.c
index d9a084e77a63..c46387024b1d 100644
--- a/drivers/video/radeonfb.c
+++ b/drivers/video/radeonfb.c
@@ -2107,7 +2107,7 @@ static void radeon_write_mode (struct radeonfb_info *rinfo,
2107 2107
2108 2108
2109 if (rinfo->arch == RADEON_M6) { 2109 if (rinfo->arch == RADEON_M6) {
2110 for (i=0; i<8; i++) 2110 for (i=0; i<7; i++)
2111 OUTREG(common_regs_m6[i].reg, common_regs_m6[i].val); 2111 OUTREG(common_regs_m6[i].reg, common_regs_m6[i].val);
2112 } else { 2112 } else {
2113 for (i=0; i<9; i++) 2113 for (i=0; i<9; i++)
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c
index 5bb8d60f35c4..03d74e8ee067 100644
--- a/drivers/video/savage/savagefb_driver.c
+++ b/drivers/video/savage/savagefb_driver.c
@@ -1498,7 +1498,7 @@ static int __devinit savage_map_mmio (struct fb_info *info)
1498 info->fix.mmio_start = par->mmio.pbase; 1498 info->fix.mmio_start = par->mmio.pbase;
1499 info->fix.mmio_len = par->mmio.len; 1499 info->fix.mmio_len = par->mmio.len;
1500 1500
1501 par->bci_base = (u32*)(par->mmio.vbase + BCI_BUFFER_OFFSET); 1501 par->bci_base = (u32 __iomem *)(par->mmio.vbase + BCI_BUFFER_OFFSET);
1502 par->bci_ptr = 0; 1502 par->bci_ptr = 0;
1503 1503
1504 savage_enable_mmio (par); 1504 savage_enable_mmio (par);
@@ -1514,7 +1514,7 @@ static void __devinit savage_unmap_mmio (struct fb_info *info)
1514 savage_disable_mmio(par); 1514 savage_disable_mmio(par);
1515 1515
1516 if (par->mmio.vbase) { 1516 if (par->mmio.vbase) {
1517 iounmap ((void *)par->mmio.vbase); 1517 iounmap(par->mmio.vbase);
1518 par->mmio.vbase = NULL; 1518 par->mmio.vbase = NULL;
1519 } 1519 }
1520} 1520}
@@ -1553,7 +1553,7 @@ static int __devinit savage_map_video (struct fb_info *info,
1553#endif 1553#endif
1554 1554
1555 /* Clear framebuffer, it's all white in memory after boot */ 1555 /* Clear framebuffer, it's all white in memory after boot */
1556 memset (par->video.vbase, 0, par->video.len); 1556 memset_io (par->video.vbase, 0, par->video.len);
1557 1557
1558 return 0; 1558 return 0;
1559} 1559}
diff --git a/drivers/video/sis/init.c b/drivers/video/sis/init.c
index 1994054d45ff..ecfd72178dbb 100644
--- a/drivers/video/sis/init.c
+++ b/drivers/video/sis/init.c
@@ -1384,7 +1384,7 @@ SiSInitPCIetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1384/* HELPER: SetLVDSetc */ 1384/* HELPER: SetLVDSetc */
1385/*********************************************/ 1385/*********************************************/
1386 1386
1387void 1387static void
1388SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 1388SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1389{ 1389{
1390 USHORT temp; 1390 USHORT temp;
@@ -1625,7 +1625,7 @@ SiS_ResetSegmentRegisters(SiS_Private *SiS_Pr,PSIS_HW_INFO HwInfo)
1625/* HELPER: GetVBType */ 1625/* HELPER: GetVBType */
1626/*********************************************/ 1626/*********************************************/
1627 1627
1628void 1628static void
1629SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 1629SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
1630{ 1630{
1631 USHORT flag=0, rev=0, nolcd=0, p4_0f, p4_25, p4_27; 1631 USHORT flag=0, rev=0, nolcd=0, p4_0f, p4_25, p4_27;
diff --git a/drivers/video/sis/init.h b/drivers/video/sis/init.h
index 35030d300431..7e36b7ac1470 100644
--- a/drivers/video/sis/init.h
+++ b/drivers/video/sis/init.h
@@ -2394,11 +2394,9 @@ void SiS_SetRegOR(SISIOADDRESS Port,USHORT Index, USHORT DataOR);
2394void SiS_DisplayOn(SiS_Private *SiS_Pr); 2394void SiS_DisplayOn(SiS_Private *SiS_Pr);
2395void SiS_DisplayOff(SiS_Private *SiS_Pr); 2395void SiS_DisplayOff(SiS_Private *SiS_Pr);
2396void SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr); 2396void SiSRegInit(SiS_Private *SiS_Pr, SISIOADDRESS BaseAddr);
2397void SiSSetLVDSetc(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2398BOOLEAN SiSDetermineROMLayout661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 2397BOOLEAN SiSDetermineROMLayout661(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2399void SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable); 2398void SiS_SetEnableDstn(SiS_Private *SiS_Pr, int enable);
2400void SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable); 2399void SiS_SetEnableFstn(SiS_Private *SiS_Pr, int enable);
2401void SiS_GetVBType(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2402BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex); 2400BOOLEAN SiS_SearchModeID(SiS_Private *SiS_Pr, USHORT *ModeNo, USHORT *ModeIdIndex);
2403UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); 2401UCHAR SiS_GetModePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex);
2404USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex); 2402USHORT SiS_GetColorDepth(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex);
@@ -2444,7 +2442,6 @@ extern void SiS_GetLCDResInfo(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT Mod
2444extern void SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 2442extern void SiS_SetYPbPr(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2445extern void SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); 2443extern void SiS_SetTVMode(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo);
2446extern void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 2444extern void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2447extern void SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
2448extern void SiS_DisableBridge(SiS_Private *, PSIS_HW_INFO); 2445extern void SiS_DisableBridge(SiS_Private *, PSIS_HW_INFO);
2449extern BOOLEAN SiS_SetCRT2Group(SiS_Private *, PSIS_HW_INFO, USHORT); 2446extern BOOLEAN SiS_SetCRT2Group(SiS_Private *, PSIS_HW_INFO, USHORT);
2450extern USHORT SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, 2447extern USHORT SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
diff --git a/drivers/video/sis/init301.c b/drivers/video/sis/init301.c
index 2bc5b8097910..274dacd54bb8 100644
--- a/drivers/video/sis/init301.c
+++ b/drivers/video/sis/init301.c
@@ -86,6 +86,7 @@
86#define SiS_I2CDELAYSHORT 150 86#define SiS_I2CDELAYSHORT 150
87 87
88static USHORT SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr); 88static USHORT SiS_GetBIOSLCDResInfo(SiS_Private *SiS_Pr);
89static void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx);
89 90
90/*********************************************/ 91/*********************************************/
91/* HELPER: Lock/Unlock CRT2 */ 92/* HELPER: Lock/Unlock CRT2 */
@@ -100,7 +101,7 @@ SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
100 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01); 101 SiS_SetRegOR(SiS_Pr->SiS_Part1Port,0x24,0x01);
101} 102}
102 103
103void 104static void
104SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 105SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
105{ 106{
106 if(HwInfo->jChipType >= SIS_315H) 107 if(HwInfo->jChipType >= SIS_315H)
@@ -4236,7 +4237,7 @@ SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4236 * from outside the context of a mode switch! 4237 * from outside the context of a mode switch!
4237 * MUST call getVBType before calling this 4238 * MUST call getVBType before calling this
4238 */ 4239 */
4239void 4240static void
4240SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo) 4241SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo)
4241{ 4242{
4242 USHORT temp=0,tempah; 4243 USHORT temp=0,tempah;
@@ -9219,7 +9220,7 @@ SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempbx)
9219 SiS_SetChReg(SiS_Pr, tempbx, 0); 9220 SiS_SetChReg(SiS_Pr, tempbx, 0);
9220} 9221}
9221 9222
9222void 9223static void
9223SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) 9224SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx)
9224{ 9225{
9225 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) 9226 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1)
@@ -9323,7 +9324,7 @@ SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempbx)
9323 9324
9324/* Read from Chrontel 70xx */ 9325/* Read from Chrontel 70xx */
9325/* Parameter is [Register no (S7-S0)] */ 9326/* Parameter is [Register no (S7-S0)] */
9326USHORT 9327static USHORT
9327SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx) 9328SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempbx)
9328{ 9329{
9329 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1) 9330 if(SiS_Pr->SiS_IF_DEF_CH70xx == 1)
diff --git a/drivers/video/sis/init301.h b/drivers/video/sis/init301.h
index f05aebc994b4..f84eb54164a5 100644
--- a/drivers/video/sis/init301.h
+++ b/drivers/video/sis/init301.h
@@ -293,7 +293,6 @@ static UCHAR SiS300_TrumpionData[7][80] = {
293#endif 293#endif
294 294
295void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 295void SiS_UnLockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
296void SiS_LockCRT2(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
297void SiS_EnableCRT2(SiS_Private *SiS_Pr); 296void SiS_EnableCRT2(SiS_Private *SiS_Pr);
298USHORT SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo); 297USHORT SiS_GetRatePtr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex, PSIS_HW_INFO HwInfo);
299void SiS_WaitRetrace1(SiS_Private *SiS_Pr); 298void SiS_WaitRetrace1(SiS_Private *SiS_Pr);
@@ -310,7 +309,6 @@ USHORT SiS_GetVCLK2Ptr(SiS_Private *SiS_Pr, USHORT ModeNo, USHORT ModeIdIndex,
310 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo); 309 USHORT RefreshRateTableIndex, PSIS_HW_INFO HwInfo);
311USHORT SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex); 310USHORT SiS_GetResInfo(SiS_Private *SiS_Pr,USHORT ModeNo,USHORT ModeIdIndex);
312void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 311void SiS_DisableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
313void SiS_EnableBridge(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
314BOOLEAN SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo); 312BOOLEAN SiS_SetCRT2Group(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo, USHORT ModeNo);
315void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 313void SiS_SiS30xBLOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
316void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 314void SiS_SiS30xBLOff(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
@@ -319,8 +317,6 @@ void SiS_SetCH700x(SiS_Private *SiS_Pr, USHORT tempax);
319USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax); 317USHORT SiS_GetCH700x(SiS_Private *SiS_Pr, USHORT tempax);
320void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempax); 318void SiS_SetCH701x(SiS_Private *SiS_Pr, USHORT tempax);
321USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempax); 319USHORT SiS_GetCH701x(SiS_Private *SiS_Pr, USHORT tempax);
322void SiS_SetCH70xx(SiS_Private *SiS_Pr, USHORT tempax);
323USHORT SiS_GetCH70xx(SiS_Private *SiS_Pr, USHORT tempax);
324void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh); 320void SiS_SetCH70xxANDOR(SiS_Private *SiS_Pr, USHORT tempax,USHORT tempbh);
325#ifdef SIS315H 321#ifdef SIS315H
326static void SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo); 322static void SiS_Chrontel701xOn(SiS_Private *SiS_Pr, PSIS_HW_INFO HwInfo);
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
index b773c98f6513..698266036819 100644
--- a/drivers/video/sis/sis_main.c
+++ b/drivers/video/sis/sis_main.c
@@ -4762,7 +4762,8 @@ static void __devinit sisfb_post_sis315330(struct pci_dev *pdev)
4762#endif 4762#endif
4763 4763
4764 4764
4765int __devinit sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 4765static int __devinit sisfb_probe(struct pci_dev *pdev,
4766 const struct pci_device_id *ent)
4766{ 4767{
4767 struct sisfb_chip_info *chipinfo = &sisfb_chip_info[ent->driver_data]; 4768 struct sisfb_chip_info *chipinfo = &sisfb_chip_info[ent->driver_data];
4768 struct sis_video_info *ivideo = NULL; 4769 struct sis_video_info *ivideo = NULL;
@@ -5940,7 +5941,7 @@ MODULE_PARM_DESC(videoram,
5940#endif 5941#endif
5941#endif 5942#endif
5942 5943
5943int __devinit sisfb_init_module(void) 5944static int __devinit sisfb_init_module(void)
5944{ 5945{
5945 sisfb_setdefaultparms(); 5946 sisfb_setdefaultparms();
5946 5947
diff --git a/drivers/video/tcx.c b/drivers/video/tcx.c
index e2fa9e1ddc3b..1986a8b3833c 100644
--- a/drivers/video/tcx.c
+++ b/drivers/video/tcx.c
@@ -36,6 +36,7 @@ static int tcx_blank(int, struct fb_info *);
36static int tcx_mmap(struct fb_info *, struct file *, struct vm_area_struct *); 36static int tcx_mmap(struct fb_info *, struct file *, struct vm_area_struct *);
37static int tcx_ioctl(struct inode *, struct file *, unsigned int, 37static int tcx_ioctl(struct inode *, struct file *, unsigned int,
38 unsigned long, struct fb_info *); 38 unsigned long, struct fb_info *);
39static int tcx_pan_display(struct fb_var_screeninfo *, struct fb_info *);
39 40
40/* 41/*
41 * Frame buffer operations 42 * Frame buffer operations
@@ -45,6 +46,7 @@ static struct fb_ops tcx_ops = {
45 .owner = THIS_MODULE, 46 .owner = THIS_MODULE,
46 .fb_setcolreg = tcx_setcolreg, 47 .fb_setcolreg = tcx_setcolreg,
47 .fb_blank = tcx_blank, 48 .fb_blank = tcx_blank,
49 .fb_pan_display = tcx_pan_display,
48 .fb_fillrect = cfb_fillrect, 50 .fb_fillrect = cfb_fillrect,
49 .fb_copyarea = cfb_copyarea, 51 .fb_copyarea = cfb_copyarea,
50 .fb_imageblit = cfb_imageblit, 52 .fb_imageblit = cfb_imageblit,
@@ -153,6 +155,12 @@ static void tcx_reset (struct fb_info *info)
153 spin_unlock_irqrestore(&par->lock, flags); 155 spin_unlock_irqrestore(&par->lock, flags);
154} 156}
155 157
158static int tcx_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
159{
160 tcx_reset(info);
161 return 0;
162}
163
156/** 164/**
157 * tcx_setcolreg - Optional function. Sets a color register. 165 * tcx_setcolreg - Optional function. Sets a color register.
158 * @regno: boolean, 0 copy local, 1 get_user() function 166 * @regno: boolean, 0 copy local, 1 get_user() function
@@ -366,6 +374,9 @@ static void tcx_init_one(struct sbus_dev *sdev)
366 all->par.lowdepth = prom_getbool(sdev->prom_node, "tcx-8-bit"); 374 all->par.lowdepth = prom_getbool(sdev->prom_node, "tcx-8-bit");
367 375
368 sbusfb_fill_var(&all->info.var, sdev->prom_node, 8); 376 sbusfb_fill_var(&all->info.var, sdev->prom_node, 8);
377 all->info.var.red.length = 8;
378 all->info.var.green.length = 8;
379 all->info.var.blue.length = 8;
369 380
370 linebytes = prom_getintdefault(sdev->prom_node, "linebytes", 381 linebytes = prom_getintdefault(sdev->prom_node, "linebytes",
371 all->info.var.xres); 382 all->info.var.xres);
@@ -439,6 +450,7 @@ static void tcx_init_one(struct sbus_dev *sdev)
439 return; 450 return;
440 } 451 }
441 452
453 fb_set_cmap(&all->info.cmap, &all->info);
442 tcx_init_fix(&all->info, linebytes); 454 tcx_init_fix(&all->info, linebytes);
443 455
444 if (register_framebuffer(&all->info) < 0) { 456 if (register_framebuffer(&all->info) < 0) {
@@ -466,7 +478,7 @@ int __init tcx_init(void)
466 return -ENODEV; 478 return -ENODEV;
467 479
468 for_all_sbusdev(sdev, sbus) { 480 for_all_sbusdev(sdev, sbus) {
469 if (!strcmp(sdev->prom_name, "tcx")) 481 if (!strcmp(sdev->prom_name, "SUNW,tcx"))
470 tcx_init_one(sdev); 482 tcx_init_one(sdev);
471 } 483 }
472 484
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c
index c34ba39b6f7e..7044226c5d4c 100644
--- a/drivers/video/tdfxfb.c
+++ b/drivers/video/tdfxfb.c
@@ -317,30 +317,49 @@ static inline void do_setpalentry(struct tdfx_par *par, unsigned regno, u32 c)
317 317
318static u32 do_calc_pll(int freq, int* freq_out) 318static u32 do_calc_pll(int freq, int* freq_out)
319{ 319{
320 int m, n, k, best_m, best_n, best_k, f_cur, best_error; 320 int m, n, k, best_m, best_n, best_k, best_error;
321 int fref = 14318; 321 int fref = 14318;
322 322
323 /* this really could be done with more intelligence --
324 255*63*4 = 64260 iterations is silly */
325 best_error = freq; 323 best_error = freq;
326 best_n = best_m = best_k = 0; 324 best_n = best_m = best_k = 0;
327 for (n = 1; n < 256; n++) { 325
328 for (m = 1; m < 64; m++) { 326 for (k = 3; k >= 0; k--) {
329 for (k = 0; k < 4; k++) { 327 for (m = 63; m >= 0; m--) {
330 f_cur = fref*(n + 2)/(m + 2)/(1 << k); 328 /*
331 if (abs(f_cur - freq) < best_error) { 329 * Estimate value of n that produces target frequency
332 best_error = abs(f_cur-freq); 330 * with current m and k
333 best_n = n; 331 */
334 best_m = m; 332 int n_estimated = (freq * (m + 2) * (1 << k) / fref) - 2;
335 best_k = k; 333
334 /* Search neighborhood of estimated n */
335 for (n = max(0, n_estimated - 1);
336 n <= min(255, n_estimated + 1); n++) {
337 /*
338 * Calculate PLL freqency with current m, k and
339 * estimated n
340 */
341 int f = fref * (n + 2) / (m + 2) / (1 << k);
342 int error = abs (f - freq);
343
344 /*
345 * If this is the closest we've come to the
346 * target frequency then remember n, m and k
347 */
348 if (error < best_error) {
349 best_error = error;
350 best_n = n;
351 best_m = m;
352 best_k = k;
336 } 353 }
337 } 354 }
338 } 355 }
339 } 356 }
357
340 n = best_n; 358 n = best_n;
341 m = best_m; 359 m = best_m;
342 k = best_k; 360 k = best_k;
343 *freq_out = fref*(n + 2)/(m + 2)/(1 << k); 361 *freq_out = fref*(n + 2)/(m + 2)/(1 << k);
362
344 return (n << 8) | (m << 2) | k; 363 return (n << 8) | (m << 2) | k;
345} 364}
346 365
@@ -411,36 +430,35 @@ static void do_write_regs(struct fb_info *info, struct banshee_reg* reg)
411 430
412static unsigned long do_lfb_size(struct tdfx_par *par, unsigned short dev_id) 431static unsigned long do_lfb_size(struct tdfx_par *par, unsigned short dev_id)
413{ 432{
414 u32 draminit0 = 0; 433 u32 draminit0;
415 u32 draminit1 = 0; 434 u32 draminit1;
416 u32 miscinit1 = 0; 435 u32 miscinit1;
417 u32 lfbsize = 0; 436
418 int sgram_p = 0; 437 int num_chips;
438 int chip_size; /* in MB */
439 u32 lfbsize;
440 int has_sgram;
419 441
420 draminit0 = tdfx_inl(par, DRAMINIT0); 442 draminit0 = tdfx_inl(par, DRAMINIT0);
421 draminit1 = tdfx_inl(par, DRAMINIT1); 443 draminit1 = tdfx_inl(par, DRAMINIT1);
444
445 num_chips = (draminit0 & DRAMINIT0_SGRAM_NUM) ? 8 : 4;
422 446
423 if ((dev_id == PCI_DEVICE_ID_3DFX_BANSHEE) || 447 if (dev_id < PCI_DEVICE_ID_3DFX_VOODOO5) {
424 (dev_id == PCI_DEVICE_ID_3DFX_VOODOO3)) { 448 /* Banshee/Voodoo3 */
425 sgram_p = (draminit1 & DRAMINIT1_MEM_SDRAM) ? 0 : 1; 449 has_sgram = draminit1 & DRAMINIT1_MEM_SDRAM;
426 450 chip_size = has_sgram ? ((draminit0 & DRAMINIT0_SGRAM_TYPE) ? 2 : 1)
427 lfbsize = sgram_p ? 451 : 2;
428 (((draminit0 & DRAMINIT0_SGRAM_NUM) ? 2 : 1) *
429 ((draminit0 & DRAMINIT0_SGRAM_TYPE) ? 8 : 4) * 1024 * 1024) :
430 16 * 1024 * 1024;
431 } else { 452 } else {
432 /* Voodoo4/5 */ 453 /* Voodoo4/5 */
433 u32 chips, psize, banks; 454 has_sgram = 0;
434 455 chip_size = 1 << ((draminit0 & DRAMINIT0_SGRAM_TYPE_MASK) >> DRAMINIT0_SGRAM_TYPE_SHIFT);
435 chips = ((draminit0 & (1 << 26)) == 0) ? 4 : 8; 456 }
436 psize = 1 << ((draminit0 & 0x38000000) >> 28); 457 lfbsize = num_chips * chip_size * 1024 * 1024;
437 banks = ((draminit0 & (1 << 30)) == 0) ? 2 : 4; 458
438 lfbsize = chips * psize * banks; 459 /* disable block writes for SDRAM */
439 lfbsize <<= 20;
440 }
441 /* disable block writes for SDRAM (why?) */
442 miscinit1 = tdfx_inl(par, MISCINIT1); 460 miscinit1 = tdfx_inl(par, MISCINIT1);
443 miscinit1 |= sgram_p ? 0 : MISCINIT1_2DBLOCK_DIS; 461 miscinit1 |= has_sgram ? 0 : MISCINIT1_2DBLOCK_DIS;
444 miscinit1 |= MISCINIT1_CLUT_INV; 462 miscinit1 |= MISCINIT1_CLUT_INV;
445 463
446 banshee_make_room(par, 1); 464 banshee_make_room(par, 1);
diff --git a/drivers/video/tgafb.c b/drivers/video/tgafb.c
index 3099630d0c3d..9d9d2009ad8c 100644
--- a/drivers/video/tgafb.c
+++ b/drivers/video/tgafb.c
@@ -45,9 +45,7 @@ static void tgafb_fillrect(struct fb_info *, const struct fb_fillrect *);
45static void tgafb_copyarea(struct fb_info *, const struct fb_copyarea *); 45static void tgafb_copyarea(struct fb_info *, const struct fb_copyarea *);
46 46
47static int tgafb_pci_register(struct pci_dev *, const struct pci_device_id *); 47static int tgafb_pci_register(struct pci_dev *, const struct pci_device_id *);
48#ifdef MODULE
49static void tgafb_pci_unregister(struct pci_dev *); 48static void tgafb_pci_unregister(struct pci_dev *);
50#endif
51 49
52static const char *mode_option = "640x480@60"; 50static const char *mode_option = "640x480@60";
53 51
@@ -1484,7 +1482,6 @@ tgafb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
1484 return ret; 1482 return ret;
1485} 1483}
1486 1484
1487#ifdef MODULE
1488static void __exit 1485static void __exit
1489tgafb_pci_unregister(struct pci_dev *pdev) 1486tgafb_pci_unregister(struct pci_dev *pdev)
1490{ 1487{
@@ -1500,6 +1497,7 @@ tgafb_pci_unregister(struct pci_dev *pdev)
1500 kfree(info); 1497 kfree(info);
1501} 1498}
1502 1499
1500#ifdef MODULE
1503static void __exit 1501static void __exit
1504tgafb_exit(void) 1502tgafb_exit(void)
1505{ 1503{
diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
index 8fc1278d7fbd..3027841f9c24 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -19,9 +19,6 @@
19#include <linux/fb.h> 19#include <linux/fb.h>
20#include <linux/ioport.h> 20#include <linux/ioport.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#ifdef __i386__
23#include <video/edid.h>
24#endif
25#include <asm/io.h> 22#include <asm/io.h>
26#include <asm/mtrr.h> 23#include <asm/mtrr.h>
27 24