Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Jul 2008 20:17:15 +0000 (13:17 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Jul 2008 20:17:15 +0000 (13:17 -0700)
* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus:
  remove CONFIG_KMOD from core kernel code
  remove CONFIG_KMOD from lib
  remove CONFIG_KMOD from sparc64
  rework try_then_request_module to do less in non-modular kernels
  remove mention of CONFIG_KMOD from documentation
  make CONFIG_KMOD invisible
  modules: Take a shortcut for checking if an address is in a module
  module: turn longs into ints for module sizes
  Shrink struct module: CONFIG_UNUSED_SYMBOLS ifdefs
  module: reorder struct module to save space on 64 bit builds
  module: generic each_symbol iterator function
  module: don't use stop_machine for waiting rmmod

380 files changed:
Documentation/ABI/testing/sysfs-dev [new file with mode: 0644]
Documentation/DMA-attributes.txt
Documentation/DocBook/uio-howto.tmpl
Documentation/HOWTO
Documentation/filesystems/sysfs.txt
Documentation/powerpc/booting-without-of.txt
Documentation/powerpc/dts-bindings/fsl/cpm_qe/gpio.txt [new file with mode: 0644]
Documentation/powerpc/dts-bindings/fsl/cpm_qe/qe/usb.txt
Documentation/powerpc/dts-bindings/fsl/mcu-mpc8349emitx.txt [new file with mode: 0644]
Documentation/powerpc/dts-bindings/fsl/pmc.txt [new file with mode: 0644]
Documentation/powerpc/dts-bindings/fsl/tsec.txt
Documentation/powerpc/dts-bindings/fsl/upm-nand.txt [new file with mode: 0644]
Documentation/powerpc/dts-bindings/gpio/led.txt [new file with mode: 0644]
Documentation/specialix.txt
Documentation/sysfs-rules.txt
MAINTAINERS
Makefile
arch/arm/common/dmabounce.c
arch/arm/common/locomo.c
arch/arm/common/sa1111.c
arch/arm/common/scoop.c
arch/arm/kernel/ecard.c
arch/arm/kernel/time.c
arch/arm/mach-integrator/impd1.c
arch/arm/mach-integrator/lm.c
arch/arm/plat-omap/mailbox.c
arch/avr32/kernel/cpu.c
arch/ia64/kernel/err_inject.c
arch/mips/kernel/rtlx.c
arch/mips/sibyte/common/sb_tbprof.c
arch/powerpc/Kconfig
arch/powerpc/boot/Makefile
arch/powerpc/boot/dts/mpc7448hpc2.dts
arch/powerpc/boot/dts/mpc8313erdb.dts
arch/powerpc/boot/dts/mpc8610_hpcd.dts
arch/powerpc/configs/85xx/mpc8544_ds_defconfig
arch/powerpc/configs/85xx/mpc8572_ds_defconfig
arch/powerpc/configs/mpc85xx_defconfig
arch/powerpc/configs/mpc8610_hpcd_defconfig
arch/powerpc/configs/mpc8641_hpcn_defconfig
arch/powerpc/configs/ppc6xx_defconfig [new file with mode: 0644]
arch/powerpc/configs/ps3_defconfig
arch/powerpc/kernel/cputable.c
arch/powerpc/kernel/head_fsl_booke.S
arch/powerpc/kernel/iommu.c
arch/powerpc/kernel/pci-common.c
arch/powerpc/kernel/prom_parse.c
arch/powerpc/kernel/stacktrace.c
arch/powerpc/kernel/sysfs.c
arch/powerpc/kernel/vmlinux.lds.S
arch/powerpc/lib/feature-fixups.c
arch/powerpc/lib/string.S
arch/powerpc/platforms/52xx/Kconfig
arch/powerpc/platforms/82xx/Kconfig
arch/powerpc/platforms/82xx/ep8248e.c
arch/powerpc/platforms/83xx/Kconfig
arch/powerpc/platforms/83xx/Makefile
arch/powerpc/platforms/83xx/mpc831x_rdb.c
arch/powerpc/platforms/83xx/mpc832x_mds.c
arch/powerpc/platforms/83xx/mpc832x_rdb.c
arch/powerpc/platforms/83xx/mpc834x_itx.c
arch/powerpc/platforms/83xx/mpc834x_mds.c
arch/powerpc/platforms/83xx/mpc836x_mds.c
arch/powerpc/platforms/83xx/mpc836x_rdk.c
arch/powerpc/platforms/83xx/mpc837x_mds.c
arch/powerpc/platforms/83xx/mpc837x_rdb.c
arch/powerpc/platforms/83xx/mpc83xx.h
arch/powerpc/platforms/83xx/pci.c [deleted file]
arch/powerpc/platforms/83xx/sbc834x.c
arch/powerpc/platforms/83xx/suspend-asm.S [new file with mode: 0644]
arch/powerpc/platforms/83xx/suspend.c [new file with mode: 0644]
arch/powerpc/platforms/83xx/usb.c
arch/powerpc/platforms/85xx/Kconfig
arch/powerpc/platforms/85xx/mpc85xx_ds.c
arch/powerpc/platforms/86xx/Kconfig
arch/powerpc/platforms/86xx/mpc8610_hpcd.c
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
arch/powerpc/platforms/Kconfig
arch/powerpc/platforms/Kconfig.cputype
arch/powerpc/platforms/cell/Kconfig
arch/powerpc/platforms/cell/Makefile
arch/powerpc/platforms/cell/cbe_powerbutton.c [new file with mode: 0644]
arch/powerpc/platforms/cell/cbe_thermal.c
arch/powerpc/platforms/cell/cpufreq_spudemand.c [new file with mode: 0644]
arch/powerpc/platforms/cell/iommu.c
arch/powerpc/platforms/cell/pervasive.c
arch/powerpc/platforms/cell/pervasive.h
arch/powerpc/platforms/cell/ras.c
arch/powerpc/platforms/cell/spu_base.c
arch/powerpc/platforms/chrp/pci.c
arch/powerpc/platforms/fsl_uli1575.c
arch/powerpc/platforms/iseries/Kconfig
arch/powerpc/platforms/iseries/iommu.c
arch/powerpc/platforms/pasemi/iommu.c
arch/powerpc/platforms/ps3/Kconfig
arch/powerpc/platforms/ps3/device-init.c
arch/powerpc/platforms/ps3/system-bus.c
arch/powerpc/platforms/pseries/Kconfig
arch/powerpc/platforms/pseries/eeh.c
arch/powerpc/platforms/pseries/iommu.c
arch/powerpc/sysdev/axonram.c
arch/powerpc/sysdev/dart_iommu.c
arch/powerpc/sysdev/fsl_pci.c
arch/powerpc/sysdev/fsl_pci.h
arch/powerpc/sysdev/fsl_soc.c
arch/powerpc/sysdev/fsl_soc.h
arch/powerpc/sysdev/ipic.c
arch/powerpc/sysdev/qe_lib/qe.c
arch/powerpc/sysdev/qe_lib/ucc.c
arch/powerpc/sysdev/qe_lib/ucc_fast.c
arch/s390/kernel/smp.c
arch/s390/kernel/time.c
arch/sh/drivers/dma/dma-sysfs.c
arch/sparc64/kernel/ebus.c
arch/sparc64/kernel/of_device.c
arch/sparc64/kernel/pci.c
arch/sparc64/kernel/sysfs.c
arch/sparc64/kernel/vio.c
arch/x86/kernel/cpu/mcheck/mce_64.c
arch/x86/kernel/cpu/mcheck/therm_throt.c
arch/x86/kernel/cpuid.c
arch/x86/kernel/microcode.c
arch/x86/kernel/msr.c
arch/x86/kernel/pci-dma.c
arch/x86/kernel/pci-gart_64.c
block/bsg.c
block/genhd.c
drivers/acpi/fan.c
drivers/acpi/glue.c
drivers/acpi/processor_core.c
drivers/acpi/scan.c
drivers/acpi/thermal.c
drivers/acpi/video.c
drivers/base/Kconfig
drivers/base/base.h
drivers/base/class.c
drivers/base/core.c
drivers/base/cpu.c
drivers/base/memory.c
drivers/base/node.c
drivers/base/power/trace.c
drivers/base/sys.c
drivers/base/topology.c
drivers/block/aoe/aoechr.c
drivers/block/paride/pg.c
drivers/block/paride/pt.c
drivers/block/pktcdvd.c
drivers/char/Kconfig
drivers/char/Makefile
drivers/char/amiserial.c
drivers/char/cyclades.c
drivers/char/dsp56k.c
drivers/char/epca.c
drivers/char/esp.c
drivers/char/ip2/ip2main.c
drivers/char/ipmi/ipmi_devintf.c
drivers/char/isicom.c
drivers/char/istallion.c
drivers/char/lp.c
drivers/char/mem.c
drivers/char/misc.c
drivers/char/moxa.c
drivers/char/mxser.c
drivers/char/n_hdlc.c
drivers/char/pcmcia/cm4000_cs.c
drivers/char/pcmcia/cm4040_cs.c
drivers/char/pcmcia/synclink_cs.c
drivers/char/ppdev.c
drivers/char/raw.c
drivers/char/riscom8.c
drivers/char/rocket.c
drivers/char/snsc.c
drivers/char/specialix.c
drivers/char/stallion.c
drivers/char/sx.c
drivers/char/synclink.c
drivers/char/synclink_gt.c
drivers/char/synclinkmp.c
drivers/char/tty_io.c
drivers/char/tty_ldisc.c [new file with mode: 0644]
drivers/char/vc_screen.c
drivers/char/viotape.c
drivers/char/vme_scc.c
drivers/char/vt.c
drivers/char/xilinx_hwicap/xilinx_hwicap.c
drivers/cpuidle/sysfs.c
drivers/dca/dca-sysfs.c
drivers/edac/cell_edac.c
drivers/eisa/Makefile
drivers/eisa/eisa-bus.c
drivers/gpio/Kconfig
drivers/gpio/Makefile
drivers/gpio/max7301.c [new file with mode: 0644]
drivers/gpio/pcf857x.c
drivers/hid/hidraw.c
drivers/hwmon/hwmon.c
drivers/i2c/i2c-core.c
drivers/i2c/i2c-dev.c
drivers/ide/ide-tape.c
drivers/ieee1394/dv1394.c
drivers/ieee1394/nodemgr.c
drivers/ieee1394/raw1394.c
drivers/ieee1394/video1394.c
drivers/infiniband/core/cm.c
drivers/infiniband/hw/ipath/ipath_file_ops.c
drivers/isdn/capi/capi.c
drivers/macintosh/adb.c
drivers/mca/mca-bus.c
drivers/media/dvb/dvb-core/dvbdev.c
drivers/memstick/host/jmb38x_ms.c
drivers/message/fusion/mptbase.c
drivers/message/fusion/mptbase.h
drivers/message/fusion/mptfc.c
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/hpilo.c [new file with mode: 0644]
drivers/misc/hpilo.h [new file with mode: 0644]
drivers/misc/phantom.c
drivers/mtd/devices/block2mtd.c
drivers/mtd/mtdchar.c
drivers/net/3c59x.c
drivers/net/arm/at91_ether.c
drivers/net/arm/ep93xx_eth.c
drivers/net/arm/etherh.c
drivers/net/fs_enet/Makefile
drivers/net/fs_enet/fs_enet-main.c
drivers/net/fs_enet/fs_enet.h
drivers/net/fs_enet/mac-fcc.c
drivers/net/fs_enet/mac-fec.c
drivers/net/fs_enet/mac-scc.c
drivers/net/fs_enet/mii-bitbang.c
drivers/net/fs_enet/mii-fec.c
drivers/net/gianfar.c
drivers/net/gianfar.h
drivers/net/gianfar_ethtool.c
drivers/net/ppp_generic.c
drivers/net/wan/cosa.c
drivers/pci/hotplug/acpiphp.h
drivers/power/apm_power.c
drivers/power/power_supply_core.c
drivers/rtc/interface.c
drivers/s390/char/raw3270.c
drivers/s390/char/tape_class.c
drivers/s390/char/vmur.c
drivers/sbus/sbus.c
drivers/scsi/dpt_i2o.c
drivers/scsi/hosts.c
drivers/scsi/scsi_transport_fc.c
drivers/scsi/scsi_transport_iscsi.c
drivers/serial/8250.c
drivers/serial/cpm_uart/cpm_uart_core.c
drivers/serial/icom.c
drivers/serial/samsung.c
drivers/serial/serial_core.c
drivers/serial/serial_txx9.c
drivers/spi/spi.c
drivers/spi/spidev.c
drivers/uio/Kconfig
drivers/uio/Makefile
drivers/uio/uio.c
drivers/uio/uio_pdrv.c [new file with mode: 0644]
drivers/usb/class/cdc-acm.c
drivers/usb/core/devio.c
drivers/usb/core/file.c
drivers/usb/gadget/printer.c
drivers/usb/mon/mon_bin.c
drivers/usb/serial/aircable.c
drivers/usb/serial/airprime.c [new file with mode: 0644]
drivers/usb/serial/ark3116.c
drivers/usb/serial/belkin_sa.c
drivers/usb/serial/belkin_sa.h
drivers/usb/serial/bus.c
drivers/usb/serial/ch341.c
drivers/usb/serial/console.c
drivers/usb/serial/cp2101.c
drivers/usb/serial/cyberjack.c
drivers/usb/serial/cypress_m8.c
drivers/usb/serial/cypress_m8.h
drivers/usb/serial/digi_acceleport.c
drivers/usb/serial/empeg.c
drivers/usb/serial/ezusb.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/ftdi_sio.h
drivers/usb/serial/funsoft.c
drivers/usb/serial/garmin_gps.c
drivers/usb/serial/generic.c
drivers/usb/serial/hp4x.c
drivers/usb/serial/io_edgeport.c
drivers/usb/serial/io_tables.h
drivers/usb/serial/io_ti.c
drivers/usb/serial/ipaq.c
drivers/usb/serial/ipw.c
drivers/usb/serial/ir-usb.c
drivers/usb/serial/iuu_phoenix.c
drivers/usb/serial/keyspan.c
drivers/usb/serial/keyspan.h
drivers/usb/serial/keyspan_pda.c
drivers/usb/serial/kl5kusb105.c
drivers/usb/serial/kobil_sct.c
drivers/usb/serial/mct_u232.c
drivers/usb/serial/mos7720.c
drivers/usb/serial/mos7840.c
drivers/usb/serial/navman.c
drivers/usb/serial/omninet.c
drivers/usb/serial/option.c
drivers/usb/serial/oti6858.c
drivers/usb/serial/pl2303.c
drivers/usb/serial/safe_serial.c
drivers/usb/serial/sierra.c
drivers/usb/serial/spcp8x5.c
drivers/usb/serial/ti_usb_3410_5052.c
drivers/usb/serial/usb-serial.c
drivers/usb/serial/usb_debug.c
drivers/usb/serial/visor.c
drivers/usb/serial/whiteheat.c
drivers/usb/serial/whiteheat.h
drivers/video/aty/aty128fb.c
drivers/video/aty/radeonfb.h
drivers/video/console/fbcon.c
drivers/video/fbmem.c
drivers/video/offb.c
drivers/video/ps3fb.c
drivers/xen/balloon.c
fs/binfmt_elf.c
fs/coda/psdev.c
fs/debugfs/inode.c
fs/partitions/check.c
fs/proc/task_mmu.c
fs/sysfs/dir.c
fs/sysfs/file.c
fs/sysfs/symlink.c
fs/sysfs/sysfs.h
include/asm-powerpc/asm-compat.h
include/asm-powerpc/machdep.h
include/asm-powerpc/pgtable-ppc32.h
include/asm-powerpc/pmi.h
include/asm-powerpc/ps3.h
include/asm-powerpc/reg.h
include/asm-powerpc/uaccess.h
include/asm-powerpc/ucc_fast.h
include/linux/auxvec.h
include/linux/debugfs.h
include/linux/device.h
include/linux/dma-attrs.h
include/linux/eisa.h
include/linux/fs_enet_pd.h
include/linux/fsl_devices.h
include/linux/kobject.h
include/linux/mtd/map.h
include/linux/mtd/mtd.h
include/linux/of_gpio.h
include/linux/spi/max7301.h [new file with mode: 0644]
include/linux/spi/spi.h
include/linux/synclink.h
include/linux/sysdev.h
include/linux/sysfs.h
include/linux/tty.h
include/linux/tty_driver.h
include/linux/uio_driver.h
include/linux/usb/serial.h
include/scsi/scsi_host.h
include/scsi/scsi_transport_fc.h
include/scsi/scsi_transport_iscsi.h
kernel/cpuset.c
kernel/rtmutex-tester.c
kernel/sched.c
kernel/sys_ni.c
kernel/time/clocksource.c
lib/Kconfig.debug
lib/kobject.c
lib/kobject_uevent.c
net/bluetooth/hci_sysfs.c
samples/firmware_class/firmware_sample_firmware_class.c
samples/kobject/kset-example.c
scripts/Makefile.modpost
scripts/mod/file2alias.c
scripts/mod/modpost.c
sound/core/init.c
sound/oss/soundcard.c
sound/sound_core.c

diff --git a/Documentation/ABI/testing/sysfs-dev b/Documentation/ABI/testing/sysfs-dev
new file mode 100644 (file)
index 0000000..a9f2b8b
--- /dev/null
@@ -0,0 +1,20 @@
+What:          /sys/dev
+Date:          April 2008
+KernelVersion: 2.6.26
+Contact:       Dan Williams <dan.j.williams@intel.com>
+Description:   The /sys/dev tree provides a method to look up the sysfs
+               path for a device using the information returned from
+               stat(2).  There are two directories, 'block' and 'char',
+               beneath /sys/dev containing symbolic links with names of
+               the form "<major>:<minor>".  These links point to the
+               corresponding sysfs path for the given device.
+
+               Example:
+               $ readlink /sys/dev/block/8:32
+               ../../block/sdc
+
+               Entries in /sys/dev/char and /sys/dev/block will be
+               dynamically created and destroyed as devices enter and
+               leave the system.
+
+Users:         mdadm <linux-raid@vger.kernel.org>
index 6d772f8..b768cc0 100644 (file)
@@ -22,3 +22,12 @@ ready and available in memory.  The DMA of the "completion indication"
 could race with data DMA.  Mapping the memory used for completion
 indications with DMA_ATTR_WRITE_BARRIER would prevent the race.
 
+DMA_ATTR_WEAK_ORDERING
+----------------------
+
+DMA_ATTR_WEAK_ORDERING specifies that reads and writes to the mapping
+may be weakly ordered, that is that reads and writes may pass each other.
+
+Since it is optional for platforms to implement DMA_ATTR_WEAK_ORDERING,
+those that do not will simply ignore the attribute and exhibit default
+behavior.
index fdd7f4f..df87d1b 100644 (file)
     </affiliation>
 </author>
 
+<copyright>
+       <year>2006-2008</year>
+       <holder>Hans-Jürgen Koch.</holder>
+</copyright>
+
+<legalnotice>
+<para>
+This documentation is Free Software licensed under the terms of the
+GPL version 2.
+</para>
+</legalnotice>
+
 <pubdate>2006-12-11</pubdate>
 
 <abstract>
 </abstract>
 
 <revhistory>
+       <revision>
+       <revnumber>0.5</revnumber>
+       <date>2008-05-22</date>
+       <authorinitials>hjk</authorinitials>
+       <revremark>Added description of write() function.</revremark>
+       </revision>
        <revision>
        <revnumber>0.4</revnumber>
        <date>2007-11-26</date>
 </bookinfo>
 
 <chapter id="aboutthisdoc">
-<?dbhtml filename="about.html"?>
+<?dbhtml filename="aboutthis.html"?>
 <title>About this document</title>
 
-<sect1 id="copyright">
-<?dbhtml filename="copyright.html"?>
-<title>Copyright and License</title>
-<para>
-      Copyright (c) 2006 by Hans-Jürgen Koch.</para>
-<para>
-This documentation is Free Software licensed under the terms of the
-GPL version 2.
-</para>
-</sect1>
-
 <sect1 id="translations">
 <?dbhtml filename="translations.html"?>
 <title>Translations</title>
@@ -189,6 +196,30 @@ interested in translating it, please email me
        represents the total interrupt count. You can use this number
        to figure out if you missed some interrupts.
        </para>
+       <para>
+       For some hardware that has more than one interrupt source internally,
+       but not separate IRQ mask and status registers, there might be
+       situations where userspace cannot determine what the interrupt source
+       was if the kernel handler disables them by writing to the chip's IRQ
+       register. In such a case, the kernel has to disable the IRQ completely
+       to leave the chip's register untouched. Now the userspace part can
+       determine the cause of the interrupt, but it cannot re-enable
+       interrupts. Another cornercase is chips where re-enabling interrupts
+       is a read-modify-write operation to a combined IRQ status/acknowledge
+       register. This would be racy if a new interrupt occurred
+       simultaneously.
+       </para>
+       <para>
+       To address these problems, UIO also implements a write() function. It
+       is normally not used and can be ignored for hardware that has only a
+       single interrupt source or has separate IRQ mask and status registers.
+       If you need it, however, a write to <filename>/dev/uioX</filename>
+       will call the <function>irqcontrol()</function> function implemented
+       by the driver. You have to write a 32-bit value that is usually either
+       0 or 1 to disable or enable interrupts. If a driver does not implement
+       <function>irqcontrol()</function>, <function>write()</function> will
+       return with <varname>-ENOSYS</varname>.
+       </para>
 
        <para>
        To handle interrupts properly, your custom kernel module can
@@ -362,6 +393,14 @@ device is actually used.
 <function>open()</function>, you will probably also want a custom
 <function>release()</function> function.
 </para></listitem>
+
+<listitem><para>
+<varname>int (*irqcontrol)(struct uio_info *info, s32 irq_on)
+</varname>: Optional. If you need to be able to enable or disable
+interrupts from userspace by writing to <filename>/dev/uioX</filename>,
+you can implement this function. The parameter <varname>irq_on</varname>
+will be 0 to disable interrupts and 1 to enable them.
+</para></listitem>
 </itemizedlist>
 
 <para>
index 619e8ca..c2371c5 100644 (file)
@@ -358,7 +358,7 @@ Here is a list of some of the different kernel trees available:
     - pcmcia, Dominik Brodowski <linux@dominikbrodowski.net>
        git.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6.git
 
-    - SCSI, James Bottomley <James.Bottomley@SteelEye.com>
+    - SCSI, James Bottomley <James.Bottomley@hansenpartnership.com>
        git.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git
 
     - x86, Ingo Molnar <mingo@elte.hu>
index 7f27b8f..9e9c348 100644 (file)
@@ -248,6 +248,7 @@ The top level sysfs directory looks like:
 block/
 bus/
 class/
+dev/
 devices/
 firmware/
 net/
@@ -274,6 +275,11 @@ fs/ contains a directory for some filesystems.  Currently each
 filesystem wanting to export attributes must create its own hierarchy
 below fs/ (see ./fuse.txt for an example).
 
+dev/ contains two directories char/ and block/. Inside these two
+directories there are symlinks named <major>:<minor>.  These symlinks
+point to the sysfs directory for the given device.  /sys/dev provides a
+quick way to lookup the sysfs interface for a device from the result of
+a stat(2) operation.
 
 More information can driver-model specific features can be found in
 Documentation/driver-model/. 
index aee243a..ea1b70b 100644 (file)
@@ -89,10 +89,12 @@ Table of Contents
     3) OpenPIC Interrupt Controllers
     4) ISA Interrupt Controllers
 
-  VIII - Specifying GPIO information for devices
+  IX - Specifying GPIO information for devices
     1) gpios property
     2) gpio-controller nodes
 
+  X - Specifying device power management information (sleep property)
+
   Appendix A - Sample SOC node for MPC8540
 
 
@@ -2488,8 +2490,8 @@ encodings listed below:
        2 =  high to low edge sensitive type enabled
        3 =  low to high edge sensitive type enabled
 
-VIII - Specifying GPIO information for devices
-==============================================
+IX - Specifying GPIO information for devices
+============================================
 
 1) gpios property
 -----------------
@@ -2537,116 +2539,151 @@ Example of two SOC GPIO banks defined as gpio-controller nodes:
                gpio-controller;
        };
 
+X - Specifying Device Power Management Information (sleep property)
+===================================================================
+
+Devices on SOCs often have mechanisms for placing devices into low-power
+states that are decoupled from the devices' own register blocks.  Sometimes,
+this information is more complicated than a cell-index property can
+reasonably describe.  Thus, each device controlled in such a manner
+may contain a "sleep" property which describes these connections.
+
+The sleep property consists of one or more sleep resources, each of
+which consists of a phandle to a sleep controller, followed by a
+controller-specific sleep specifier of zero or more cells.
+
+The semantics of what type of low power modes are possible are defined
+by the sleep controller.  Some examples of the types of low power modes
+that may be supported are:
+
+ - Dynamic: The device may be disabled or enabled at any time.
+ - System Suspend: The device may request to be disabled or remain
+   awake during system suspend, but will not be disabled until then.
+ - Permanent: The device is disabled permanently (until the next hard
+   reset).
+
+Some devices may share a clock domain with each other, such that they should
+only be suspended when none of the devices are in use.  Where reasonable,
+such nodes should be placed on a virtual bus, where the bus has the sleep
+property.  If the clock domain is shared among devices that cannot be
+reasonably grouped in this manner, then create a virtual sleep controller
+(similar to an interrupt nexus, except that defining a standardized
+sleep-map should wait until its necessity is demonstrated).
+
 Appendix A - Sample SOC node for MPC8540
 ========================================
 
-Note that the #address-cells and #size-cells for the SoC node
-in this example have been explicitly listed; these are likely
-not necessary as they are usually the same as the root node.
-
-       soc8540@e0000000 {
+       soc@e0000000 {
                #address-cells = <1>;
                #size-cells = <1>;
-               #interrupt-cells = <2>;
+               compatible = "fsl,mpc8540-ccsr", "simple-bus";
                device_type = "soc";
-               ranges = <00000000 e0000000 00100000>
-               reg = <e0000000 00003000>;
+               ranges = <0x00000000 0xe0000000 0x00100000>
                bus-frequency = <0>;
-
-               mdio@24520 {
-                       reg = <24520 20>;
-                       device_type = "mdio";
-                       compatible = "gianfar";
-
-                       ethernet-phy@0 {
-                               linux,phandle = <2452000>
-                               interrupt-parent = <40000>;
-                               interrupts = <35 1>;
-                               reg = <0>;
-                               device_type = "ethernet-phy";
-                       };
-
-                       ethernet-phy@1 {
-                               linux,phandle = <2452001>
-                               interrupt-parent = <40000>;
-                               interrupts = <35 1>;
-                               reg = <1>;
-                               device_type = "ethernet-phy";
-                       };
-
-                       ethernet-phy@3 {
-                               linux,phandle = <2452002>
-                               interrupt-parent = <40000>;
-                               interrupts = <35 1>;
-                               reg = <3>;
-                               device_type = "ethernet-phy";
-                       };
-
-               };
+               interrupt-parent = <&pic>;
 
                ethernet@24000 {
-                       #size-cells = <0>;
+                       #address-cells = <1>;
+                       #size-cells = <1>;
                        device_type = "network";
                        model = "TSEC";
-                       compatible = "gianfar";
-                       reg = <24000 1000>;
-                       mac-address = [ 00 E0 0C 00 73 00 ];
-                       interrupts = <d 3 e 3 12 3>;
-                       interrupt-parent = <40000>;
-                       phy-handle = <2452000>;
+                       compatible = "gianfar", "simple-bus";
+                       reg = <0x24000 0x1000>;
+                       local-mac-address = [ 00 E0 0C 00 73 00 ];
+                       interrupts = <29 2 30 2 34 2>;
+                       phy-handle = <&phy0>;
+                       sleep = <&pmc 00000080>;
+                       ranges;
+
+                       mdio@24520 {
+                               reg = <0x24520 0x20>;
+                               compatible = "fsl,gianfar-mdio";
+
+                               phy0: ethernet-phy@0 {
+                                       interrupts = <5 1>;
+                                       reg = <0>;
+                                       device_type = "ethernet-phy";
+                               };
+
+                               phy1: ethernet-phy@1 {
+                                       interrupts = <5 1>;
+                                       reg = <1>;
+                                       device_type = "ethernet-phy";
+                               };
+
+                               phy3: ethernet-phy@3 {
+                                       interrupts = <7 1>;
+                                       reg = <3>;
+                                       device_type = "ethernet-phy";
+                               };
+                       };
                };
 
                ethernet@25000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
                        device_type = "network";
                        model = "TSEC";
                        compatible = "gianfar";
-                       reg = <25000 1000>;
-                       mac-address = [ 00 E0 0C 00 73 01 ];
-                       interrupts = <13 3 14 3 18 3>;
-                       interrupt-parent = <40000>;
-                       phy-handle = <2452001>;
+                       reg = <0x25000 0x1000>;
+                       local-mac-address = [ 00 E0 0C 00 73 01 ];
+                       interrupts = <13 2 14 2 18 2>;
+                       phy-handle = <&phy1>;
+                       sleep = <&pmc 00000040>;
                };
 
                ethernet@26000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
                        device_type = "network";
                        model = "FEC";
                        compatible = "gianfar";
-                       reg = <26000 1000>;
-                       mac-address = [ 00 E0 0C 00 73 02 ];
-                       interrupts = <19 3>;
-                       interrupt-parent = <40000>;
-                       phy-handle = <2452002>;
+                       reg = <0x26000 0x1000>;
+                       local-mac-address = [ 00 E0 0C 00 73 02 ];
+                       interrupts = <41 2>;
+                       phy-handle = <&phy3>;
+                       sleep = <&pmc 00000020>;
                };
 
                serial@4500 {
-                       device_type = "serial";
-                       compatible = "ns16550";
-                       reg = <4500 100>;
-                       clock-frequency = <0>;
-                       interrupts = <1a 3>;
-                       interrupt-parent = <40000>;
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       compatible = "fsl,mpc8540-duart", "simple-bus";
+                       sleep = <&pmc 00000002>;
+                       ranges;
+
+                       serial@4500 {
+                               device_type = "serial";
+                               compatible = "ns16550";
+                               reg = <0x4500 0x100>;
+                               clock-frequency = <0>;
+                               interrupts = <42 2>;
+                       };
+
+                       serial@4600 {
+                               device_type = "serial";
+                               compatible = "ns16550";
+                               reg = <0x4600 0x100>;
+                               clock-frequency = <0>;
+                               interrupts = <42 2>;
+                       };
                };
 
-               pic@40000 {
-                       linux,phandle = <40000>;
+               pic: pic@40000 {
                        interrupt-controller;
                        #address-cells = <0>;
-                       reg = <40000 40000>;
+                       #interrupt-cells = <2>;
+                       reg = <0x40000 0x40000>;
                        compatible = "chrp,open-pic";
                        device_type = "open-pic";
                };
 
                i2c@3000 {
-                       interrupt-parent = <40000>;
-                       interrupts = <1b 3>;
-                       reg = <3000 18>;
-                       device_type = "i2c";
+                       interrupts = <43 2>;
+                       reg = <0x3000 0x100>;
                        compatible  = "fsl-i2c";
                        dfsrr;
+                       sleep = <&pmc 00000004>;
                };
 
+               pmc: power@e0070 {
+                       compatible = "fsl,mpc8540-pmc", "fsl,mpc8548-pmc";
+                       reg = <0xe0070 0x20>;
+               };
        };
diff --git a/Documentation/powerpc/dts-bindings/fsl/cpm_qe/gpio.txt b/Documentation/powerpc/dts-bindings/fsl/cpm_qe/gpio.txt
new file mode 100644 (file)
index 0000000..1815dfe
--- /dev/null
@@ -0,0 +1,38 @@
+Every GPIO controller node must have #gpio-cells property defined,
+this information will be used to translate gpio-specifiers.
+
+On CPM1 devices, all ports are using slightly different register layouts.
+Ports A, C and D are 16bit ports and Ports B and E are 32bit ports.
+
+On CPM2 devices, all ports are 32bit ports and use a common register layout.
+
+Required properties:
+- compatible : "fsl,cpm1-pario-bank-a", "fsl,cpm1-pario-bank-b",
+  "fsl,cpm1-pario-bank-c", "fsl,cpm1-pario-bank-d",
+  "fsl,cpm1-pario-bank-e", "fsl,cpm2-pario-bank"
+- #gpio-cells : Should be two. The first cell is the pin number and the
+  second cell is used to specify optional paramters (currently unused).
+- gpio-controller : Marks the port as GPIO controller.
+
+Example of three SOC GPIO banks defined as gpio-controller nodes:
+
+       CPM1_PIO_A: gpio-controller@950 {
+               #gpio-cells = <2>;
+               compatible = "fsl,cpm1-pario-bank-a";
+               reg = <0x950 0x10>;
+               gpio-controller;
+       };
+
+       CPM1_PIO_B: gpio-controller@ab8 {
+               #gpio-cells = <2>;
+               compatible = "fsl,cpm1-pario-bank-b";
+               reg = <0xab8 0x10>;
+               gpio-controller;
+       };
+
+       CPM1_PIO_E: gpio-controller@ac8 {
+               #gpio-cells = <2>;
+               compatible = "fsl,cpm1-pario-bank-e";
+               reg = <0xac8 0x18>;
+               gpio-controller;
+       };
index c8f44d6..9ccd5f3 100644 (file)
@@ -1,22 +1,37 @@
-* USB (Universal Serial Bus Controller)
+Freescale QUICC Engine USB Controller
 
 Required properties:
-- compatible : could be "qe_udc" or "fhci-hcd".
-- mode : the could be "host" or "slave".
-- reg : Offset and length of the register set for the device
-- interrupts : <a b> where a is the interrupt number and b is a
-  field that represents an encoding of the sense and level
-  information for the interrupt.  This should be encoded based on
-  the information in section 2) depending on the type of interrupt
-  controller you have.
-- interrupt-parent : the phandle for the interrupt controller that
-  services interrupts for this device.
+- compatible : should be "fsl,<chip>-qe-usb", "fsl,mpc8323-qe-usb".
+- reg : the first two cells should contain usb registers location and
+  length, the next two two cells should contain PRAM location and
+  length.
+- interrupts : should contain USB interrupt.
+- interrupt-parent : interrupt source phandle.
+- fsl,fullspeed-clock : specifies the full speed USB clock source:
+  "none": clock source is disabled
+  "brg1" through "brg16": clock source is BRG1-BRG16, respectively
+  "clk1" through "clk24": clock source is CLK1-CLK24, respectively
+- fsl,lowspeed-clock : specifies the low speed USB clock source:
+  "none": clock source is disabled
+  "brg1" through "brg16": clock source is BRG1-BRG16, respectively
+  "clk1" through "clk24": clock source is CLK1-CLK24, respectively
+- hub-power-budget : USB power budget for the root hub, in mA.
+- gpios : should specify GPIOs in this order: USBOE, USBTP, USBTN, USBRP,
+  USBRN, SPEED (optional), and POWER (optional).
 
-Example(slave):
-       usb@6c0 {
-               compatible = "qe_udc";
-               reg = <6c0 40>;
-               interrupts = <8b 0>;
-               interrupt-parent = <700>;
-               mode = "slave";
-       };
+Example:
+
+usb@6c0 {
+       compatible = "fsl,mpc8360-qe-usb", "fsl,mpc8323-qe-usb";
+       reg = <0x6c0 0x40 0x8b00 0x100>;
+       interrupts = <11>;
+       interrupt-parent = <&qeic>;
+       fsl,fullspeed-clock = "clk21";
+       gpios = <&qe_pio_b  2 0 /* USBOE */
+                &qe_pio_b  3 0 /* USBTP */
+                &qe_pio_b  8 0 /* USBTN */
+                &qe_pio_b  9 0 /* USBRP */
+                &qe_pio_b 11 0 /* USBRN */
+                &qe_pio_e 20 0 /* SPEED */
+                &qe_pio_e 21 0 /* POWER */>;
+};
diff --git a/Documentation/powerpc/dts-bindings/fsl/mcu-mpc8349emitx.txt b/Documentation/powerpc/dts-bindings/fsl/mcu-mpc8349emitx.txt
new file mode 100644 (file)
index 0000000..0f76633
--- /dev/null
@@ -0,0 +1,17 @@
+Freescale MPC8349E-mITX-compatible Power Management Micro Controller Unit (MCU)
+
+Required properties:
+- compatible : "fsl,<mcu-chip>-<board>", "fsl,mcu-mpc8349emitx".
+- reg : should specify I2C address (0x0a).
+- #gpio-cells : should be 2.
+- gpio-controller : should be present.
+
+Example:
+
+mcu@0a {
+       #gpio-cells = <2>;
+       compatible = "fsl,mc9s08qg8-mpc8349emitx",
+                    "fsl,mcu-mpc8349emitx";
+       reg = <0x0a>;
+       gpio-controller;
+};
diff --git a/Documentation/powerpc/dts-bindings/fsl/pmc.txt b/Documentation/powerpc/dts-bindings/fsl/pmc.txt
new file mode 100644 (file)
index 0000000..02f6f43
--- /dev/null
@@ -0,0 +1,63 @@
+* Power Management Controller
+
+Properties:
+- compatible: "fsl,<chip>-pmc".
+
+  "fsl,mpc8349-pmc" should be listed for any chip whose PMC is
+  compatible.  "fsl,mpc8313-pmc" should also be listed for any chip
+  whose PMC is compatible, and implies deep-sleep capability.
+
+  "fsl,mpc8548-pmc" should be listed for any chip whose PMC is
+  compatible.  "fsl,mpc8536-pmc" should also be listed for any chip
+  whose PMC is compatible, and implies deep-sleep capability.
+
+  "fsl,mpc8641d-pmc" should be listed for any chip whose PMC is
+  compatible; all statements below that apply to "fsl,mpc8548-pmc" also
+  apply to "fsl,mpc8641d-pmc".
+
+  Compatibility does not include bit assigments in SCCR/PMCDR/DEVDISR; these
+  bit assigments are indicated via the sleep specifier in each device's
+  sleep property.
+
+- reg: For devices compatible with "fsl,mpc8349-pmc", the first resource
+  is the PMC block, and the second resource is the Clock Configuration
+  block.
+
+  For devices compatible with "fsl,mpc8548-pmc", the first resource
+  is a 32-byte block beginning with DEVDISR.
+
+- interrupts: For "fsl,mpc8349-pmc"-compatible devices, the first
+  resource is the PMC block interrupt.
+
+- fsl,mpc8313-wakeup-timer: For "fsl,mpc8313-pmc"-compatible devices,
+  this is a phandle to an "fsl,gtm" node on which timer 4 can be used as
+  a wakeup source from deep sleep.
+
+Sleep specifiers:
+
+  fsl,mpc8349-pmc: Sleep specifiers consist of one cell.  For each bit
+  that is set in the cell, the corresponding bit in SCCR will be saved
+  and cleared on suspend, and restored on resume.  This sleep controller
+  supports disabling and resuming devices at any time.
+
+  fsl,mpc8536-pmc: Sleep specifiers consist of three cells, the third of
+  which will be ORed into PMCDR upon suspend, and cleared from PMCDR
+  upon resume.  The first two cells are as described for fsl,mpc8578-pmc.
+  This sleep controller only supports disabling devices during system
+  sleep, or permanently.
+
+  fsl,mpc8548-pmc: Sleep specifiers consist of one or two cells, the
+  first of which will be ORed into DEVDISR (and the second into
+  DEVDISR2, if present -- this cell should be zero or absent if the
+  hardware does not have DEVDISR2) upon a request for permanent device
+  disabling.  This sleep controller does not support configuring devices
+  to disable during system sleep (unless supported by another compatible
+  match), or dynamically.
+
+Example:
+
+       power@b00 {
+               compatible = "fsl,mpc8313-pmc", "fsl,mpc8349-pmc";
+               reg = <0xb00 0x100 0xa00 0x100>;
+               interrupts = <80 8>;
+       };
index 583ef6b..cf55fa4 100644 (file)
@@ -24,46 +24,39 @@ Example:
 
 * Gianfar-compatible ethernet nodes
 
-Required properties:
+Properties:
 
   - device_type : Should be "network"
   - model : Model of the device.  Can be "TSEC", "eTSEC", or "FEC"
   - compatible : Should be "gianfar"
   - reg : Offset and length of the register set for the device
-  - mac-address : List of bytes representing the ethernet address of
+  - local-mac-address : List of bytes representing the ethernet address of
     this controller
-  - interrupts : <a b> where a is the interrupt number and b is a
-    field that represents an encoding of the sense and level
-    information for the interrupt.  This should be encoded based on
-    the information in section 2) depending on the type of interrupt
-    controller you have.
-  - interrupt-parent : the phandle for the interrupt controller that
-    services interrupts for this device.
+  - interrupts : For FEC devices, the first interrupt is the device's
+    interrupt.  For TSEC and eTSEC devices, the first interrupt is
+    transmit, the second is receive, and the third is error.
   - phy-handle : The phandle for the PHY connected to this ethernet
     controller.
   - fixed-link : <a b c d e> where a is emulated phy id - choose any,
     but unique to the all specified fixed-links, b is duplex - 0 half,
     1 full, c is link speed - d#10/d#100/d#1000, d is pause - 0 no
     pause, 1 pause, e is asym_pause - 0 no asym_pause, 1 asym_pause.
-
-Recommended properties:
-
   - phy-connection-type : a string naming the controller/PHY interface type,
     i.e., "mii" (default), "rmii", "gmii", "rgmii", "rgmii-id", "sgmii",
     "tbi", or "rtbi".  This property is only really needed if the connection
     is of type "rgmii-id", as all other connection types are detected by
     hardware.
-
+  - fsl,magic-packet : If present, indicates that the hardware supports
+    waking up via magic packet.
 
 Example:
        ethernet@24000 {
-               #size-cells = <0>;
                device_type = "network";
                model = "TSEC";
                compatible = "gianfar";
-               reg = <24000 1000>;
-               mac-address = [ 00 E0 0C 00 73 00 ];
-               interrupts = <d 3 e 3 12 3>;
-               interrupt-parent = <40000>;
-               phy-handle = <2452000>
+               reg = <0x24000 0x1000>;
+               local-mac-address = [ 00 E0 0C 00 73 00 ];
+               interrupts = <29 2 30 2 34 2>;
+               interrupt-parent = <&mpic>;
+               phy-handle = <&phy0>
        };
diff --git a/Documentation/powerpc/dts-bindings/fsl/upm-nand.txt b/Documentation/powerpc/dts-bindings/fsl/upm-nand.txt
new file mode 100644 (file)
index 0000000..84a04d5
--- /dev/null
@@ -0,0 +1,28 @@
+Freescale Localbus UPM programmed to work with NAND flash
+
+Required properties:
+- compatible : "fsl,upm-nand".
+- reg : should specify localbus chip select and size used for the chip.
+- fsl,upm-addr-offset : UPM pattern offset for the address latch.
+- fsl,upm-cmd-offset : UPM pattern offset for the command latch.
+- gpios : may specify optional GPIO connected to the Ready-Not-Busy pin.
+
+Example:
+
+upm@1,0 {
+       compatible = "fsl,upm-nand";
+       reg = <1 0 1>;
+       fsl,upm-addr-offset = <16>;
+       fsl,upm-cmd-offset = <8>;
+       gpios = <&qe_pio_e 18 0>;
+
+       flash {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "...";
+
+               partition@0 {
+                       ...
+               };
+       };
+};
diff --git a/Documentation/powerpc/dts-bindings/gpio/led.txt b/Documentation/powerpc/dts-bindings/gpio/led.txt
new file mode 100644 (file)
index 0000000..ff51f4c
--- /dev/null
@@ -0,0 +1,15 @@
+LED connected to GPIO
+
+Required properties:
+- compatible : should be "gpio-led".
+- label : (optional) the label for this LED. If omitted, the label is
+  taken from the node name (excluding the unit address).
+- gpios : should specify LED GPIO.
+
+Example:
+
+led@0 {
+       compatible = "gpio-led";
+       label = "hdd";
+       gpios = <&mcu_pio 0 1>;
+};
index 4a4b428..6eb6f3a 100644 (file)
@@ -270,8 +270,8 @@ The pinout of the connectors on the IO8+ is:
 Hardware handshaking issues.
 ============================
 
-The driver can be compiled in two different ways. The default
-("Specialix DTR/RTS pin is RTS" is off) the pin behaves as DTR when
+The driver can be told to operate in two different ways. The default
+behaviour is specialix.sx_rtscts = 0 where the pin behaves as DTR when
 hardware handshaking is off. It behaves as the RTS hardware
 handshaking signal when hardware handshaking is selected.
 
@@ -280,7 +280,7 @@ cable will either be compatible with hardware handshaking or with
 software handshaking. So switching on the fly is not really an
 option.
 
-I actually prefer to use the "Specialix DTR/RTS pin is RTS" option.
+I actually prefer to use the "specialix.sx_rtscts=1" option.
 This makes the DTR/RTS pin always an RTS pin, and ioctls to
 change DTR are always ignored. I have a cable that is configured
 for this. 
@@ -379,7 +379,5 @@ it doesn't fit in your computer, bring back the card.
             You have to WRITE to the address register to even 
             read-probe a CD186x register. Disable autodetection?
          -- Specialix: any suggestions?
-       - Arbitrary baud rates are not implemented yet. 
-            If you need this, bug me about it. 
 
 
index 80ef562..6049a2a 100644 (file)
@@ -3,9 +3,8 @@ Rules on how to access information in the Linux kernel sysfs
 The kernel-exported sysfs exports internal kernel implementation details
 and depends on internal kernel structures and layout. It is agreed upon
 by the kernel developers that the Linux kernel does not provide a stable
-internal API. As sysfs is a direct export of kernel internal
-structures, the sysfs interface cannot provide a stable interface either;
-it may always change along with internal kernel changes.
+internal API. Therefore, there are aspects of the sysfs interface that
+may not be stable across kernel releases.
 
 To minimize the risk of breaking users of sysfs, which are in most cases
 low-level userspace applications, with a new kernel release, the users
index df3fa0e..11944b4 100644 (file)
@@ -4047,9 +4047,10 @@ W:       http://www.buzzard.org.uk/toshiba/
 S:     Maintained
 
 TPM DEVICE DRIVER
-P:     Debora Velarde
-P:     Rajiv Andrade
-M:     tpmdd-devel@lists.sourceforge.net
+P:     Debora Velarde
+M:     debora@linux.vnet.ibm.com
+P:     Rajiv Andrade
+M:     srajiv@linux.vnet.ibm.com
 W:     http://tpmdd.sourceforge.net
 P:     Marcel Selhorst
 M:     tpm@selhorst.net
index 6192922..4bcd1cf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1148,7 +1148,8 @@ clean: archclean $(clean-dirs)
        @find . $(RCS_FIND_IGNORE) \
                \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
                -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
-               -o -name '*.symtypes' -o -name 'modules.order' \) \
+               -o -name '*.symtypes' -o -name 'modules.order' \
+               -o -name 'Module.markers' \) \
                -type f -print | xargs rm -f
 
 # mrproper - Delete all generated files, including .config
index 2744673..dd29473 100644 (file)
@@ -554,9 +554,8 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size,
 
        device_info = kmalloc(sizeof(struct dmabounce_device_info), GFP_ATOMIC);
        if (!device_info) {
-               printk(KERN_ERR
-                       "Could not allocated dmabounce_device_info for %s",
-                       dev->bus_id);
+               dev_err(dev,
+                       "Could not allocated dmabounce_device_info\n");
                return -ENOMEM;
        }
 
@@ -594,8 +593,7 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size,
 
        dev->archdata.dmabounce = device_info;
 
-       printk(KERN_INFO "dmabounce: registered device %s on %s bus\n",
-               dev->bus_id, dev->bus->name);
+       dev_info(dev, "dmabounce: registered device\n");
 
        return 0;
 
@@ -614,16 +612,15 @@ dmabounce_unregister_dev(struct device *dev)
        dev->archdata.dmabounce = NULL;
 
        if (!device_info) {
-               printk(KERN_WARNING
-                       "%s: Never registered with dmabounce but attempting" \
-                       "to unregister!\n", dev->bus_id);
+               dev_warn(dev,
+                        "Never registered with dmabounce but attempting"
+                        "to unregister!\n");
                return;
        }
 
        if (!list_empty(&device_info->safe_buffers)) {
-               printk(KERN_ERR
-                       "%s: Removing from dmabounce with pending buffers!\n",
-                       dev->bus_id);
+               dev_err(dev,
+                       "Removing from dmabounce with pending buffers!\n");
                BUG();
        }
 
@@ -639,8 +636,7 @@ dmabounce_unregister_dev(struct device *dev)
 
        kfree(device_info);
 
-       printk(KERN_INFO "dmabounce: device %s on %s bus unregistered\n",
-               dev->bus_id, dev->bus->name);
+       dev_info(dev, "dmabounce: device unregistered\n");
 }
 
 
index d973c98..c3c3a33 100644 (file)
@@ -543,7 +543,6 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info)
                goto out;
        }
 
-       strncpy(dev->dev.bus_id, info->name, sizeof(dev->dev.bus_id));
        /*
         * If the parent device has a DMA mask associated with it,
         * propagate it down to the children.
@@ -553,6 +552,7 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info)
                dev->dev.dma_mask = &dev->dma_mask;
        }
 
+       dev_set_name(&dev->dev, "%s", info->name);
        dev->devid       = info->devid;
        dev->dev.parent  = lchip->dev;
        dev->dev.bus     = &locomo_bus_type;
index eb06d0b..c8e8f0e 100644 (file)
@@ -550,9 +550,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
                goto out;
        }
 
-       snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id),
-                "%4.4lx", info->offset);
-
+       dev_set_name(&dev->dev, "%4.4lx", info->offset);
        dev->devid       = info->devid;
        dev->dev.parent  = sachip->dev;
        dev->dev.bus     = &sa1111_bus_type;
@@ -560,7 +558,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
        dev->dev.coherent_dma_mask = sachip->dev->coherent_dma_mask;
        dev->res.start   = sachip->phys + info->offset;
        dev->res.end     = dev->res.start + 511;
-       dev->res.name    = dev->dev.bus_id;
+       dev->res.name    = dev_name(&dev->dev);
        dev->res.flags   = IORESOURCE_MEM;
        dev->mapbase     = sachip->base + info->offset;
        dev->skpcr_mask  = info->skpcr_mask;
@@ -570,6 +568,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
        if (ret) {
                printk("SA1111: failed to allocate resource for %s\n",
                        dev->res.name);
+               dev_set_name(&dev->dev, NULL);
                kfree(dev);
                goto out;
        }
@@ -593,7 +592,8 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
                if (dev->dma_mask != 0xffffffffUL) {
                        ret = dmabounce_register_dev(&dev->dev, 1024, 4096);
                        if (ret) {
-                               printk("SA1111: Failed to register %s with dmabounce", dev->dev.bus_id);
+                               dev_err(&dev->dev, "SA1111: Failed to register"
+                                       " with dmabounce\n");
                                device_unregister(&dev->dev);
                        }
                }
index bc299b0..ae39553 100644 (file)
@@ -247,7 +247,7 @@ static int __devinit scoop_probe(struct platform_device *pdev)
        devptr->gpio.base = -1;
 
        if (inf->gpio_base != 0) {
-               devptr->gpio.label = pdev->dev.bus_id;
+               devptr->gpio.label = dev_name(&pdev->dev);
                devptr->gpio.base = inf->gpio_base;
                devptr->gpio.ngpio = 12; /* PA11 = 0, PA12 = 1, etc. up to PA22 = 11 */
                devptr->gpio.set = scoop_gpio_set;
index 8bfd299..f5cfdab 100644 (file)
@@ -783,7 +783,7 @@ static void ecard_proc_init(void)
 
 #define ec_set_resource(ec,nr,st,sz)                           \
        do {                                                    \
-               (ec)->resource[nr].name = ec->dev.bus_id;       \
+               (ec)->resource[nr].name = dev_name(&ec->dev);   \
                (ec)->resource[nr].start = st;                  \
                (ec)->resource[nr].end = (st) + (sz) - 1;       \
                (ec)->resource[nr].flags = IORESOURCE_MEM;      \
@@ -853,8 +853,7 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
        for (i = 0; i < ECARD_NUM_RESOURCES; i++) {
                if (ec->resource[i].flags &&
                    request_resource(&iomem_resource, &ec->resource[i])) {
-                       printk(KERN_ERR "%s: resource(s) not available\n",
-                               ec->dev.bus_id);
+                       dev_err(&ec->dev, "resource(s) not available\n");
                        ec->resource[i].end -= ec->resource[i].start;
                        ec->resource[i].start = 0;
                        ec->resource[i].flags = 0;
index cc5145b..368d171 100644 (file)
@@ -130,7 +130,9 @@ static const struct leds_evt_name evt_names[] = {
        { "red",   led_red_on,   led_red_off   },
 };
 
-static ssize_t leds_store(struct sys_device *dev, const char *buf, size_t size)
+static ssize_t leds_store(struct sys_device *dev,
+                       struct sysdev_attribute *attr,
+                       const char *buf, size_t size)
 {
        int ret = -EINVAL, len = strcspn(buf, " ");
 
index 62e653a..5a1588c 100644 (file)
@@ -393,9 +393,7 @@ static int impd1_probe(struct lm_device *dev)
                if (!d)
                        continue;
 
-               snprintf(d->dev.bus_id, sizeof(d->dev.bus_id),
-                        "lm%x:%5.5lx", dev->id, idev->offset >> 12);
-
+               dev_set_name(&d->dev, "lm%x:%5.5lx", dev->id, idev->offset >> 12);
                d->dev.parent   = &dev->dev;
                d->res.start    = dev->resource.start + idev->offset;
                d->res.end      = d->res.start + SZ_4K - 1;
@@ -407,8 +405,7 @@ static int impd1_probe(struct lm_device *dev)
 
                ret = amba_device_register(d, &dev->resource);
                if (ret) {
-                       printk("unable to register device %s: %d\n",
-                               d->dev.bus_id, ret);
+                       dev_err(&d->dev, "unable to register device: %d\n");
                        kfree(d);
                }
        }
index 622cdc4..f939c50 100644 (file)
@@ -81,8 +81,10 @@ int lm_device_register(struct lm_device *dev)
        dev->dev.release = lm_device_release;
        dev->dev.bus = &lm_bustype;
 
-       snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id), "lm%d", dev->id);
-       dev->resource.name = dev->dev.bus_id;
+       ret = dev_set_name(&dev->dev, "lm%d", dev->id);
+       if (ret)
+               return ret;
+       dev->resource.name = dev_name(&dev->dev);
 
        ret = request_resource(&iomem_resource, &dev->resource);
        if (ret == 0) {
index 6f33f58..ff1413e 100644 (file)
@@ -334,7 +334,7 @@ static int omap_mbox_init(struct omap_mbox *mbox)
        }
 
        mbox->dev.class = &omap_mbox_class;
-       strlcpy(mbox->dev.bus_id, mbox->name, KOBJ_NAME_LEN);
+       dev_set_name(&mbox->dev, "%s", mbox->name);
        dev_set_drvdata(&mbox->dev, mbox);
 
        ret = device_register(&mbox->dev);
index b8409ca..e84faff 100644 (file)
@@ -26,14 +26,16 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
  * XXX: If/when a SMP-capable implementation of AVR32 will ever be
  * made, we must make sure that the code executes on the correct CPU.
  */
-static ssize_t show_pc0event(struct sys_device *dev, char *buf)
+static ssize_t show_pc0event(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        unsigned long pccr;
 
        pccr = sysreg_read(PCCR);
        return sprintf(buf, "0x%lx\n", (pccr >> 12) & 0x3f);
 }
-static ssize_t store_pc0event(struct sys_device *dev, const char *buf,
+static ssize_t store_pc0event(struct sys_device *dev,
+                       struct sysdev_attribute *attr, const char *buf,
                              size_t count)
 {
        unsigned long val;
@@ -46,15 +48,17 @@ static ssize_t store_pc0event(struct sys_device *dev, const char *buf,
        sysreg_write(PCCR, val);
        return count;
 }
-static ssize_t show_pc0count(struct sys_device *dev, char *buf)
+static ssize_t show_pc0count(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        unsigned long pcnt0;
 
        pcnt0 = sysreg_read(PCNT0);
        return sprintf(buf, "%lu\n", pcnt0);
 }
-static ssize_t store_pc0count(struct sys_device *dev, const char *buf,
-                             size_t count)
+static ssize_t store_pc0count(struct sys_device *dev,
+                               struct sysdev_attribute *attr,
+                               const char *buf, size_t count)
 {
        unsigned long val;
        char *endp;
@@ -67,14 +71,16 @@ static ssize_t store_pc0count(struct sys_device *dev, const char *buf,
        return count;
 }
 
-static ssize_t show_pc1event(struct sys_device *dev, char *buf)
+static ssize_t show_pc1event(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        unsigned long pccr;
 
        pccr = sysreg_read(PCCR);
        return sprintf(buf, "0x%lx\n", (pccr >> 18) & 0x3f);
 }
-static ssize_t store_pc1event(struct sys_device *dev, const char *buf,
+static ssize_t store_pc1event(struct sys_device *dev,
+                             struct sysdev_attribute *attr, const char *buf,
                              size_t count)
 {
        unsigned long val;
@@ -87,14 +93,16 @@ static ssize_t store_pc1event(struct sys_device *dev, const char *buf,
        sysreg_write(PCCR, val);
        return count;
 }
-static ssize_t show_pc1count(struct sys_device *dev, char *buf)
+static ssize_t show_pc1count(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        unsigned long pcnt1;
 
        pcnt1 = sysreg_read(PCNT1);
        return sprintf(buf, "%lu\n", pcnt1);
 }
-static ssize_t store_pc1count(struct sys_device *dev, const char *buf,
+static ssize_t store_pc1count(struct sys_device *dev,
+                               struct sysdev_attribute *attr, const char *buf,
                              size_t count)
 {
        unsigned long val;
@@ -108,14 +116,16 @@ static ssize_t store_pc1count(struct sys_device *dev, const char *buf,
        return count;
 }
 
-static ssize_t show_pccycles(struct sys_device *dev, char *buf)
+static ssize_t show_pccycles(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        unsigned long pccnt;
 
        pccnt = sysreg_read(PCCNT);
        return sprintf(buf, "%lu\n", pccnt);
 }
-static ssize_t store_pccycles(struct sys_device *dev, const char *buf,
+static ssize_t store_pccycles(struct sys_device *dev,
+                               struct sysdev_attribute *attr, const char *buf,
                              size_t count)
 {
        unsigned long val;
@@ -129,14 +139,16 @@ static ssize_t store_pccycles(struct sys_device *dev, const char *buf,
        return count;
 }
 
-static ssize_t show_pcenable(struct sys_device *dev, char *buf)
+static ssize_t show_pcenable(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        unsigned long pccr;
 
        pccr = sysreg_read(PCCR);
        return sprintf(buf, "%c\n", (pccr & 1)?'1':'0');
 }
-static ssize_t store_pcenable(struct sys_device *dev, const char *buf,
+static ssize_t store_pcenable(struct sys_device *dev,
+                             struct sysdev_attribute *attr, const char *buf,
                              size_t count)
 {
        unsigned long pccr, val;
index b642648..c539c68 100644 (file)
@@ -55,7 +55,8 @@ static u64 resources[NR_CPUS];
 
 #define show(name)                                                     \
 static ssize_t                                                                 \
-show_##name(struct sys_device *dev, char *buf)                         \
+show_##name(struct sys_device *dev, struct sysdev_attribute *attr,     \
+               char *buf)                                              \
 {                                                                      \
        u32 cpu=dev->id;                                                \
        return sprintf(buf, "%lx\n", name[cpu]);                        \
@@ -63,7 +64,8 @@ show_##name(struct sys_device *dev, char *buf)                                \
 
 #define store(name)                                                    \
 static ssize_t                                                                 \
-store_##name(struct sys_device *dev, const char *buf, size_t size)     \
+store_##name(struct sys_device *dev, struct sysdev_attribute *attr,    \
+                                       const char *buf, size_t size)   \
 {                                                                      \
        unsigned int cpu=dev->id;                                       \
        name[cpu] = simple_strtoull(buf, NULL, 16);                     \
@@ -76,7 +78,8 @@ show(call_start)
  * processor. The cpu number in driver is only used for storing data.
  */
 static ssize_t
-store_call_start(struct sys_device *dev, const char *buf, size_t size)
+store_call_start(struct sys_device *dev, struct sysdev_attribute *attr,
+               const char *buf, size_t size)
 {
        unsigned int cpu=dev->id;
        unsigned long call_start = simple_strtoull(buf, NULL, 16);
@@ -124,14 +127,16 @@ show(err_type_info)
 store(err_type_info)
 
 static ssize_t
-show_virtual_to_phys(struct sys_device *dev, char *buf)
+show_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr,
+                       char *buf)
 {
        unsigned int cpu=dev->id;
        return sprintf(buf, "%lx\n", phys_addr[cpu]);
 }
 
 static ssize_t
-store_virtual_to_phys(struct sys_device *dev, const char *buf, size_t size)
+store_virtual_to_phys(struct sys_device *dev, struct sysdev_attribute *attr,
+                       const char *buf, size_t size)
 {
        unsigned int cpu=dev->id;
        u64 virt_addr=simple_strtoull(buf, NULL, 16);
@@ -154,7 +159,8 @@ show(err_struct_info)
 store(err_struct_info)
 
 static ssize_t
-show_err_data_buffer(struct sys_device *dev, char *buf)
+show_err_data_buffer(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        unsigned int cpu=dev->id;
 
@@ -165,7 +171,9 @@ show_err_data_buffer(struct sys_device *dev, char *buf)
 }
 
 static ssize_t
-store_err_data_buffer(struct sys_device *dev, const char *buf, size_t size)
+store_err_data_buffer(struct sys_device *dev,
+                       struct sysdev_attribute *attr,
+                       const char *buf, size_t size)
 {
        unsigned int cpu=dev->id;
        int ret;
index b556419..dfd868b 100644 (file)
@@ -522,8 +522,8 @@ static int __init rtlx_module_init(void)
                atomic_set(&channel_wqs[i].in_open, 0);
                mutex_init(&channel_wqs[i].mutex);
 
-               dev = device_create(mt_class, NULL, MKDEV(major, i),
-                                   "%s%d", module_name, i);
+               dev = device_create_drvdata(mt_class, NULL, MKDEV(major, i),
+                                           NULL, "%s%d", module_name, i);
                if (IS_ERR(dev)) {
                        err = PTR_ERR(dev);
                        goto out_chrdev;
index 28b012a..66e3e3f 100644 (file)
@@ -576,7 +576,8 @@ static int __init sbprof_tb_init(void)
 
        tb_class = tbc;
 
-       dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), "tb");
+       dev = device_create_drvdata(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0),
+                                   NULL, "tb");
        if (IS_ERR(dev)) {
                err = PTR_ERR(dev);
                goto out_class;
index de88972..4c22242 100644 (file)
@@ -199,7 +199,7 @@ config ARCH_HIBERNATION_POSSIBLE
 
 config ARCH_SUSPEND_POSSIBLE
        def_bool y
-       depends on ADB_PMU || PPC_EFIKA || PPC_LITE5200
+       depends on ADB_PMU || PPC_EFIKA || PPC_LITE5200 || PPC_83xx
 
 config PPC_DCR_NATIVE
        bool
@@ -568,11 +568,15 @@ config FSL_GTM
 config MCA
        bool
 
+# Platforms that what PCI turned unconditionally just do select PCI
+# in their config node.  Platforms that want to choose at config
+# time should select PPC_PCI_CHOICE
+config PPC_PCI_CHOICE
+       bool
+
 config PCI
-       bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_86xx \
-               || PPC_MPC52xx || (EMBEDDED && (PPC_PSERIES || PPC_ISERIES)) \
-               || PPC_PS3 || 44x
-       default y if !40x && !CPM2 && !8xx && !PPC_MPC512x && !PPC_83xx \
+       bool "PCI support" if PPC_PCI_CHOICE
+       default y if !40x && !CPM2 && !8xx && !PPC_83xx \
                && !PPC_85xx && !PPC_86xx
        default PCI_PERMEDIA if !4xx && !CPM2 && !8xx
        default PCI_QSPAN if !4xx && !CPM2 && 8xx
index 19f83c8..14174aa 100644 (file)
@@ -163,12 +163,12 @@ quiet_cmd_flex = FLEX    $@
       cmd_flex = $(FLEX) -o$@ $<; cp $@ $@_shipped
 
 $(obj)/dtc-src/dtc-parser.tab.c: $(src)/dtc-src/dtc-parser.y FORCE
-     $(call if_changed,bison)
+       $(call if_changed,bison)
 
 $(obj)/dtc-src/dtc-parser.tab.h: $(obj)/dtc-src/dtc-parser.tab.c
 
 $(obj)/dtc-src/dtc-lexer.lex.c: $(src)/dtc-src/dtc-lexer.l FORCE
-     $(call if_changed,flex)
+       $(call if_changed,flex)
 endif
 
 #############
index 705c23c..2544f3e 100644 (file)
        #address-cells = <1>;
        #size-cells = <1>;
 
+       aliases {
+               ethernet0 = &enet0;
+               ethernet1 = &enet1;
+
+               serial0 = &serial0;
+               serial1 = &serial1;
+
+               pci0 = &pci0;
+       };
+
        cpus {
                #address-cells = <1>;
                #size-cells =<0>;
@@ -78,7 +88,7 @@
 
                };
 
-               ethernet@6200 {
+               enet0: ethernet@6200 {
                        linux,network-index = <0>;
                        #size-cells = <0>;
                        device_type = "network";
                        phy-handle = <&phy8>;
                };
 
-               ethernet@6600 {
+               enet1: ethernet@6600 {
                        linux,network-index = <1>;
                        #address-cells = <1>;
                        #size-cells = <0>;
                        phy-handle = <&phy9>;
                };
 
-               serial@7808 {
+               serial0: serial@7808 {
                        device_type = "serial";
                        compatible = "ns16550";
                        reg = <0x7808 0x200>;
                        interrupt-parent = <&mpic>;
                };
 
-               serial@7c08 {
+               serial1: serial@7c08 {
                        device_type = "serial";
                        compatible = "ns16550";
                        reg = <0x7c08 0x200>;
                        compatible = "chrp,open-pic";
                        device_type = "open-pic";
                };
-               pci@1000 {
+               pci0: pci@1000 {
                        compatible = "tsi108-pci";
                        device_type = "pci";
                        #interrupt-cells = <1>;
                        };
                };
        };
-       chosen {
-               linux,stdout-path = "/tsi108@c0000000/serial@7808";
-       };
-
 };
index 3664fb5..2a94ae0 100644 (file)
                        reg = <0x200 0x100>;
                };
 
-               i2c@3000 {
+               sleep-nexus {
                        #address-cells = <1>;
-                       #size-cells = <0>;
-                       cell-index = <0>;
-                       compatible = "fsl-i2c";
-                       reg = <0x3000 0x100>;
-                       interrupts = <14 0x8>;
-                       interrupt-parent = <&ipic>;
-                       dfsrr;
-                       rtc@68 {
-                               compatible = "dallas,ds1339";
-                               reg = <0x68>;
+                       #size-cells = <1>;
+                       compatible = "simple-bus";
+                       sleep = <&pmc 0x03000000>;
+                       ranges;
+
+                       i2c@3000 {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               cell-index = <0>;
+                               compatible = "fsl-i2c";
+                               reg = <0x3000 0x100>;
+                               interrupts = <14 0x8>;
+                               interrupt-parent = <&ipic>;
+                               dfsrr;
+                               rtc@68 {
+                                       compatible = "dallas,ds1339";
+                                       reg = <0x68>;
+                               };
+                       };
+
+                       crypto@30000 {
+                               compatible = "fsl,sec2.2", "fsl,sec2.1",
+                                            "fsl,sec2.0";
+                               reg = <0x30000 0x10000>;
+                               interrupts = <11 0x8>;
+                               interrupt-parent = <&ipic>;
+                               fsl,num-channels = <1>;
+                               fsl,channel-fifo-len = <24>;
+                               fsl,exec-units-mask = <0x4c>;
+                               fsl,descriptor-types-mask = <0x0122003f>;
                        };
                };
 
                        interrupt-parent = <&ipic>;
                        interrupts = <38 0x8>;
                        phy_type = "utmi_wide";
+                       sleep = <&pmc 0x00300000>;
                };
 
-               mdio@24520 {
+               enet0: ethernet@24000 {
                        #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "fsl,gianfar-mdio";
-                       reg = <0x24520 0x20>;
-                       phy1: ethernet-phy@1 {
-                               interrupt-parent = <&ipic>;
-                               interrupts = <19 0x8>;
-                               reg = <0x1>;
-                               device_type = "ethernet-phy";
-                       };
-                       phy4: ethernet-phy@4 {
-                               interrupt-parent = <&ipic>;
-                               interrupts = <20 0x8>;
-                               reg = <0x4>;
-                               device_type = "ethernet-phy";
-                       };
-               };
+                       #size-cells = <1>;
+                       sleep = <&pmc 0x20000000>;
+                       ranges;
 
-               enet0: ethernet@24000 {
                        cell-index = <0>;
                        device_type = "network";
                        model = "eTSEC";
-                       compatible = "gianfar";
+                       compatible = "gianfar", "simple-bus";
                        reg = <0x24000 0x1000>;
                        local-mac-address = [ 00 00 00 00 00 00 ];
                        interrupts = <37 0x8 36 0x8 35 0x8>;
                        interrupt-parent = <&ipic>;
                        phy-handle = < &phy1 >;
+                       fsl,magic-packet;
+
+                       mdio@24520 {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               compatible = "fsl,gianfar-mdio";
+                               reg = <0x24520 0x20>;
+                               phy1: ethernet-phy@1 {
+                                       interrupt-parent = <&ipic>;
+                                       interrupts = <19 0x8>;
+                                       reg = <0x1>;
+                                       device_type = "ethernet-phy";
+                               };
+                               phy4: ethernet-phy@4 {
+                                       interrupt-parent = <&ipic>;
+                                       interrupts = <20 0x8>;
+                                       reg = <0x4>;
+                                       device_type = "ethernet-phy";
+                               };
+                       };
                };
 
                enet1: ethernet@25000 {
                        interrupts = <34 0x8 33 0x8 32 0x8>;
                        interrupt-parent = <&ipic>;
                        phy-handle = < &phy4 >;
+                       sleep = <&pmc 0x10000000>;
+                       fsl,magic-packet;
                };
 
                serial0: serial@4500 {
                        interrupt-parent = <&ipic>;
                };
 
-               crypto@30000 {
-                       compatible = "fsl,sec2.2", "fsl,sec2.1", "fsl,sec2.0";
-                       reg = <0x30000 0x10000>;
-                       interrupts = <11 0x8>;
-                       interrupt-parent = <&ipic>;
-                       fsl,num-channels = <1>;
-                       fsl,channel-fifo-len = <24>;
-                       fsl,exec-units-mask = <0x4c>;
-                       fsl,descriptor-types-mask = <0x0122003f>;
-               };
-
                /* IPIC
                 * interrupts cell = <intr #, sense>
                 * sense values match linux IORESOURCE_IRQ_* defines:
                        reg = <0x700 0x100>;
                        device_type = "ipic";
                };
+
+               pmc: power@b00 {
+                       compatible = "fsl,mpc8313-pmc", "fsl,mpc8349-pmc";
+                       reg = <0xb00 0x100 0xa00 0x100>;
+                       interrupts = <80 8>;
+                       interrupt-parent = <&ipic>;
+                       fsl,mpc8313-wakeup-timer = <&gtm1>;
+
+                       /* Remove this (or change to "okay") if you have
+                        * a REVA3 or later board, if you apply one of the
+                        * workarounds listed in section 8.5 of the board
+                        * manual, or if you are adapting this device tree
+                        * to a different board.
+                        */
+                       status = "fail";
+               };
+
+               gtm1: timer@500 {
+                       compatible = "fsl,mpc8313-gtm", "fsl,gtm";
+                       reg = <0x500 0x100>;
+                       interrupts = <90 8 78 8 84 8 72 8>;
+                       interrupt-parent = <&ipic>;
+               };
+
+               timer@600 {
+                       compatible = "fsl,mpc8313-gtm", "fsl,gtm";
+                       reg = <0x600 0x100>;
+                       interrupts = <91 8 79 8 85 8 73 8>;
+                       interrupt-parent = <&ipic>;
+               };
        };
 
-       pci0: pci@e0008500 {
-               cell-index = <1>;
-               interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
-               interrupt-map = <
-
-                               /* IDSEL 0x0E -mini PCI */
-                                0x7000 0x0 0x0 0x1 &ipic 18 0x8
-                                0x7000 0x0 0x0 0x2 &ipic 18 0x8
-                                0x7000 0x0 0x0 0x3 &ipic 18 0x8
-                                0x7000 0x0 0x0 0x4 &ipic 18 0x8
-
-                               /* IDSEL 0x0F - PCI slot */
-                                0x7800 0x0 0x0 0x1 &ipic 17 0x8
-                                0x7800 0x0 0x0 0x2 &ipic 18 0x8
-                                0x7800 0x0 0x0 0x3 &ipic 17 0x8
-                                0x7800 0x0 0x0 0x4 &ipic 18 0x8>;
-               interrupt-parent = <&ipic>;
-               interrupts = <66 0x8>;
-               bus-range = <0x0 0x0>;
-               ranges = <0x02000000 0x0 0x90000000 0x90000000 0x0 0x10000000
-                         0x42000000 0x0 0x80000000 0x80000000 0x0 0x10000000
-                         0x01000000 0x0 0x00000000 0xe2000000 0x0 0x00100000>;
-               clock-frequency = <66666666>;
-               #interrupt-cells = <1>;
-               #size-cells = <2>;
-               #address-cells = <3>;
-               reg = <0xe0008500 0x100>;
-               compatible = "fsl,mpc8349-pci";
-               device_type = "pci";
+       sleep-nexus {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "simple-bus";
+               sleep = <&pmc 0x00010000>;
+               ranges;
+
+               pci0: pci@e0008500 {
+                       cell-index = <1>;
+                       interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
+                       interrupt-map = <
+                                       /* IDSEL 0x0E -mini PCI */
+                                        0x7000 0x0 0x0 0x1 &ipic 18 0x8
+                                        0x7000 0x0 0x0 0x2 &ipic 18 0x8
+                                        0x7000 0x0 0x0 0x3 &ipic 18 0x8
+                                        0x7000 0x0 0x0 0x4 &ipic 18 0x8
+
+                                       /* IDSEL 0x0F - PCI slot */
+                                        0x7800 0x0 0x0 0x1 &ipic 17 0x8
+                                        0x7800 0x0 0x0 0x2 &ipic 18 0x8
+                                        0x7800 0x0 0x0 0x3 &ipic 17 0x8
+                                        0x7800 0x0 0x0 0x4 &ipic 18 0x8>;
+                       interrupt-parent = <&ipic>;
+                       interrupts = <66 0x8>;
+                       bus-range = <0x0 0x0>;
+                       ranges = <0x02000000 0x0 0x90000000 0x90000000 0x0 0x10000000
+                                 0x42000000 0x0 0x80000000 0x80000000 0x0 0x10000000
+                                 0x01000000 0x0 0x00000000 0xe2000000 0x0 0x00100000>;
+                       clock-frequency = <66666666>;
+                       #interrupt-cells = <1>;
+                       #size-cells = <2>;
+                       #address-cells = <3>;
+                       reg = <0xe0008500 0x100>;
+                       compatible = "fsl,mpc8349-pci";
+                       device_type = "pci";
+               };
+
+               dma@82a8 {
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       compatible = "fsl,mpc8313-dma", "fsl,elo-dma";
+                       reg = <0xe00082a8 4>;
+                       ranges = <0 0xe0008100 0x1a8>;
+                       interrupt-parent = <&ipic>;
+                       interrupts = <71 8>;
+
+                       dma-channel@0 {
+                               compatible = "fsl,mpc8313-dma-channel",
+                                            "fsl,elo-dma-channel";
+                               reg = <0 0x28>;
+                               interrupt-parent = <&ipic>;
+                               interrupts = <71 8>;
+                               cell-index = <0>;
+                       };
+
+                       dma-channel@80 {
+                               compatible = "fsl,mpc8313-dma-channel",
+                                            "fsl,elo-dma-channel";
+                               reg = <0x80 0x28>;
+                               interrupt-parent = <&ipic>;
+                               interrupts = <71 8>;
+                               cell-index = <1>;
+                       };
+
+                       dma-channel@100 {
+                               compatible = "fsl,mpc8313-dma-channel",
+                                            "fsl,elo-dma-channel";
+                               reg = <0x100 0x28>;
+                               interrupt-parent = <&ipic>;
+                               interrupts = <71 8>;
+                               cell-index = <2>;
+                       };
+
+                       dma-channel@180 {
+                               compatible = "fsl,mpc8313-dma-channel",
+                                            "fsl,elo-dma-channel";
+                               reg = <0x180 0x28>;
+                               interrupt-parent = <&ipic>;
+                               interrupts = <71 8>;
+                               cell-index = <3>;
+                       };
+               };
        };
 };
index 981941e..666185f 100644 (file)
                                          0x01000000 0x0 0x00000000
                                          0x01000000 0x0 0x00000000
                                          0x0 0x00100000>;
+
+                               isa@1e {
+                                       device_type = "isa";
+                                       #size-cells = <1>;
+                                       #address-cells = <2>;
+                                       reg = <0xf000 0 0 0 0>;
+                                       ranges = <1 0 0x01000000 0 0
+                                                 0x00001000>;
+
+                                       rtc@70 {
+                                               compatible = "pnpPNP,b00";
+                                               reg = <1 0x70 2>;
+                                       };
+                               };
                        };
                };
        };
index 042a85e..a0583e5 100644 (file)
@@ -997,10 +997,12 @@ CONFIG_SND=y
 CONFIG_SND_TIMER=y
 CONFIG_SND_PCM=y
 # CONFIG_SND_SEQUENCER is not set
-# CONFIG_SND_MIXER_OSS is not set
-# CONFIG_SND_PCM_OSS is not set
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=y
+CONFIG_SND_PCM_OSS=y
+CONFIG_SND_PCM_OSS_PLUGINS=y
 # CONFIG_SND_DYNAMIC_MINORS is not set
-CONFIG_SND_SUPPORT_OLD_API=y
+# CONFIG_SND_SUPPORT_OLD_API is not set
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
index 03627cf..164fd96 100644 (file)
@@ -997,10 +997,12 @@ CONFIG_SND=y
 CONFIG_SND_TIMER=y
 CONFIG_SND_PCM=y
 # CONFIG_SND_SEQUENCER is not set
-# CONFIG_SND_MIXER_OSS is not set
-# CONFIG_SND_PCM_OSS is not set
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=y
+CONFIG_SND_PCM_OSS=y
+CONFIG_SND_PCM_OSS_PLUGINS=y
 # CONFIG_SND_DYNAMIC_MINORS is not set
-CONFIG_SND_SUPPORT_OLD_API=y
+# CONFIG_SND_SUPPORT_OLD_API is not set
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
index 3efab71..fa01705 100644 (file)
@@ -1005,10 +1005,12 @@ CONFIG_SND=y
 CONFIG_SND_TIMER=y
 CONFIG_SND_PCM=y
 # CONFIG_SND_SEQUENCER is not set
-# CONFIG_SND_MIXER_OSS is not set
-# CONFIG_SND_PCM_OSS is not set
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=y
+CONFIG_SND_PCM_OSS=y
+CONFIG_SND_PCM_OSS_PLUGINS=y
 # CONFIG_SND_DYNAMIC_MINORS is not set
-CONFIG_SND_SUPPORT_OLD_API=y
+# CONFIG_SND_SUPPORT_OLD_API is not set
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
index 5612d40..cdf98ae 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.26-rc5
-# Mon Jun  9 08:50:24 2008
+# Linux kernel version: 2.6.26
+# Tue Jul 15 08:31:01 2008
 #
 # CONFIG_PPC64 is not set
 
@@ -51,6 +51,8 @@ CONFIG_PPC_UDBG_16550=y
 CONFIG_AUDIT_ARCH=y
 CONFIG_GENERIC_BUG=y
 CONFIG_DEFAULT_UIMAGE=y
+CONFIG_HIBERNATE_32=y
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
 # CONFIG_PPC_DCR_NATIVE is not set
 # CONFIG_PPC_DCR_MMIO is not set
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
@@ -97,6 +99,7 @@ CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
 # CONFIG_ELF_CORE is not set
+CONFIG_PCSPKR_PLATFORM=y
 CONFIG_COMPAT_BRK=y
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
@@ -117,7 +120,7 @@ CONFIG_HAVE_OPROFILE=y
 # CONFIG_KPROBES is not set
 CONFIG_HAVE_KPROBES=y
 CONFIG_HAVE_KRETPROBES=y
-# CONFIG_HAVE_DMA_ATTRS is not set
+CONFIG_HAVE_DMA_ATTRS=y
 CONFIG_PROC_PAGE_MONITOR=y
 CONFIG_SLABINFO=y
 CONFIG_RT_MUTEXES=y
@@ -153,31 +156,43 @@ CONFIG_CLASSIC_RCU=y
 #
 # Platform support
 #
-# CONFIG_PPC_MULTIPLATFORM is not set
-# CONFIG_PPC_82xx is not set
-# CONFIG_PPC_83xx is not set
-CONFIG_PPC_86xx=y
+CONFIG_PPC_MULTIPLATFORM=y
+CONFIG_CLASSIC32=y
+CONFIG_PPC_CHRP=y
 # CONFIG_PPC_MPC512x is not set
 # CONFIG_PPC_MPC5121 is not set
+# CONFIG_MPC5121_ADS is not set
+# CONFIG_PPC_MPC52xx is not set
+CONFIG_PPC_PMAC=y
 # CONFIG_PPC_CELL is not set
 # CONFIG_PPC_CELL_NATIVE is not set
+# CONFIG_PPC_82xx is not set
 # CONFIG_PQ2ADS is not set
+# CONFIG_PPC_83xx is not set
+CONFIG_PPC_86xx=y
 # CONFIG_MPC8641_HPCN is not set
 # CONFIG_SBC8641D is not set
 CONFIG_MPC8610_HPCD=y
 CONFIG_MPC8610=y
+# CONFIG_EMBEDDED6xx is not set
+CONFIG_PPC_NATIVE=y
+# CONFIG_UDBG_RTAS_CONSOLE is not set
 # CONFIG_IPIC is not set
 CONFIG_MPIC=y
 # CONFIG_MPIC_WEIRD is not set
-# CONFIG_PPC_I8259 is not set
-# CONFIG_PPC_RTAS is not set
+CONFIG_PPC_I8259=y
+CONFIG_PPC_RTAS=y
+# CONFIG_RTAS_ERROR_LOGGING is not set
+CONFIG_RTAS_PROC=y
 # CONFIG_MMIO_NVRAM is not set
-# CONFIG_PPC_MPC106 is not set
+CONFIG_PPC_MPC106=y
 # CONFIG_PPC_970_NAP is not set
 # CONFIG_PPC_INDIRECT_IO is not set
 # CONFIG_GENERIC_IOMAP is not set
 # CONFIG_CPU_FREQ is not set
-# CONFIG_FSL_ULI1575 is not set
+# CONFIG_PPC601_SYNC_FIX is not set
+# CONFIG_TAU is not set
+CONFIG_FSL_ULI1575=y
 
 #
 # Kernel options
@@ -202,6 +217,7 @@ CONFIG_BINFMT_ELF=y
 CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
 CONFIG_ARCH_HAS_WALK_MEMORY=y
 CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
+# CONFIG_KEXEC is not set
 CONFIG_ARCH_FLATMEM_ENABLE=y
 CONFIG_ARCH_POPULATES_NODE_MAP=y
 CONFIG_SELECT_MEMORY_MODEL=y
@@ -228,11 +244,13 @@ CONFIG_ISA_DMA_API=y
 #
 # Bus options
 #
+# CONFIG_ISA is not set
 CONFIG_ZONE_DMA=y
 CONFIG_GENERIC_ISA_DMA=y
 CONFIG_PPC_INDIRECT_PCI=y
 CONFIG_FSL_SOC=y
 CONFIG_FSL_PCI=y
+CONFIG_PPC_PCI_CHOICE=y
 CONFIG_PCI=y
 CONFIG_PCI_DOMAINS=y
 CONFIG_PCI_SYSCALL=y
@@ -469,6 +487,7 @@ CONFIG_OF_I2C=y
 # CONFIG_PARPORT is not set
 CONFIG_BLK_DEV=y
 # CONFIG_BLK_DEV_FD is not set
+# CONFIG_MAC_FLOPPY is not set
 # CONFIG_BLK_CPQ_DA is not set
 # CONFIG_BLK_CPQ_CISS_DA is not set
 # CONFIG_BLK_DEV_DAC960 is not set
@@ -571,6 +590,8 @@ CONFIG_SCSI_LOWLEVEL=y
 # CONFIG_SCSI_DC390T is not set
 # CONFIG_SCSI_NSP32 is not set
 # CONFIG_SCSI_DEBUG is not set
+# CONFIG_SCSI_MESH is not set
+# CONFIG_SCSI_MAC53C94 is not set
 # CONFIG_SCSI_SRP is not set
 CONFIG_ATA=y
 # CONFIG_ATA_NONSTANDARD is not set
@@ -639,6 +660,10 @@ CONFIG_PATA_ALI=y
 #
 # IEEE 1394 (FireWire) support
 #
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
 # CONFIG_FIREWIRE is not set
 # CONFIG_IEEE1394 is not set
 # CONFIG_I2O is not set
@@ -655,6 +680,8 @@ CONFIG_DUMMY=y
 # CONFIG_PHYLIB is not set
 CONFIG_NET_ETHERNET=y
 # CONFIG_MII is not set
+# CONFIG_MACE is not set
+# CONFIG_BMAC is not set
 # CONFIG_HAPPYMEAL is not set
 # CONFIG_SUNGEM is not set
 # CONFIG_CASSINI is not set
@@ -762,14 +789,16 @@ CONFIG_SERIAL_8250_RSA=y
 # CONFIG_SERIAL_UARTLITE is not set
 CONFIG_SERIAL_CORE=y
 CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_SERIAL_PMACZILOG is not set
 # CONFIG_SERIAL_JSM is not set
 # CONFIG_SERIAL_OF_PLATFORM is not set
 CONFIG_UNIX98_PTYS=y
 # CONFIG_LEGACY_PTYS is not set
+# CONFIG_BRIQ_PANEL is not set
+# CONFIG_HVC_RTAS is not set
 # CONFIG_IPMI_HANDLER is not set
 # CONFIG_HW_RANDOM is not set
 # CONFIG_NVRAM is not set
-# CONFIG_GEN_RTC is not set
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
 # CONFIG_RAW_DRIVER is not set
@@ -787,9 +816,11 @@ CONFIG_I2C_BOARDINFO=y
 # CONFIG_I2C_ALI15X3 is not set
 # CONFIG_I2C_AMD756 is not set
 # CONFIG_I2C_AMD8111 is not set
+# CONFIG_I2C_HYDRA is not set
 # CONFIG_I2C_I801 is not set
 # CONFIG_I2C_I810 is not set
 # CONFIG_I2C_PIIX4 is not set
+CONFIG_I2C_POWERMAC=y
 CONFIG_I2C_MPC=y
 # CONFIG_I2C_NFORCE2 is not set
 # CONFIG_I2C_OCORES is not set
@@ -826,6 +857,7 @@ CONFIG_I2C_MPC=y
 # CONFIG_POWER_SUPPLY is not set
 # CONFIG_HWMON is not set
 # CONFIG_THERMAL is not set
+# CONFIG_THERMAL_HWMON is not set
 # CONFIG_WATCHDOG is not set
 
 #
@@ -888,6 +920,9 @@ CONFIG_FB_CFB_IMAGEBLIT=y
 # CONFIG_FB_PM2 is not set
 # CONFIG_FB_CYBER2000 is not set
 # CONFIG_FB_OF is not set
+# CONFIG_FB_CONTROL is not set
+# CONFIG_FB_PLATINUM is not set
+# CONFIG_FB_VALKYRIE is not set
 # CONFIG_FB_CT65550 is not set
 # CONFIG_FB_ASILIANT is not set
 # CONFIG_FB_IMSTT is not set
@@ -1027,11 +1062,18 @@ CONFIG_SND_VERBOSE_PROCFS=y
 #
 # ALSA PowerMac devices
 #
+# CONFIG_SND_POWERMAC is not set
 
 #
 # ALSA PowerPC devices
 #
 
+#
+# Apple Onboard Audio driver
+#
+# CONFIG_SND_AOA is not set
+# CONFIG_SND_AOA_SOUNDBUS is not set
+
 #
 # System on Chip audio support
 #
@@ -1075,7 +1117,57 @@ CONFIG_USB_ARCH_HAS_EHCI=y
 # CONFIG_ACCESSIBILITY is not set
 # CONFIG_INFINIBAND is not set
 # CONFIG_EDAC is not set
-# CONFIG_RTC_CLASS is not set
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_HCTOSYS=y
+CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
+# CONFIG_RTC_DEBUG is not set
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# I2C RTC drivers
+#
+# CONFIG_RTC_DRV_DS1307 is not set
+# CONFIG_RTC_DRV_DS1374 is not set
+# CONFIG_RTC_DRV_DS1672 is not set
+# CONFIG_RTC_DRV_MAX6900 is not set
+# CONFIG_RTC_DRV_RS5C372 is not set
+# CONFIG_RTC_DRV_ISL1208 is not set
+# CONFIG_RTC_DRV_X1205 is not set
+# CONFIG_RTC_DRV_PCF8563 is not set
+# CONFIG_RTC_DRV_PCF8583 is not set
+# CONFIG_RTC_DRV_M41T80 is not set
+# CONFIG_RTC_DRV_S35390A is not set
+# CONFIG_RTC_DRV_FM3130 is not set
+
+#
+# SPI RTC drivers
+#
+
+#
+# Platform RTC drivers
+#
+CONFIG_RTC_DRV_CMOS=y
+# CONFIG_RTC_DRV_DS1511 is not set
+# CONFIG_RTC_DRV_DS1553 is not set
+# CONFIG_RTC_DRV_DS1742 is not set
+# CONFIG_RTC_DRV_STK17TA8 is not set
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_V3020 is not set
+
+#
+# on-CPU RTC drivers
+#
+# CONFIG_RTC_DRV_PPC is not set
 # CONFIG_DMADEVICES is not set
 # CONFIG_UIO is not set
 
@@ -1295,8 +1387,11 @@ CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_STACK_USAGE is not set
 # CONFIG_DEBUG_PAGEALLOC is not set
 # CONFIG_DEBUGGER is not set
+# CONFIG_CODE_PATCHING_SELFTEST is not set
+# CONFIG_FTR_FIXUP_SELFTEST is not set
 # CONFIG_IRQSTACKS is not set
 # CONFIG_BDI_SWITCH is not set
+# CONFIG_BOOTX_TEXT is not set
 # CONFIG_PPC_EARLY_DEBUG is not set
 
 #
index 4a81715..867b8c0 100644 (file)
@@ -991,10 +991,12 @@ CONFIG_SND=y
 CONFIG_SND_TIMER=y
 CONFIG_SND_PCM=y
 # CONFIG_SND_SEQUENCER is not set
-# CONFIG_SND_MIXER_OSS is not set
-# CONFIG_SND_PCM_OSS is not set
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=y
+CONFIG_SND_PCM_OSS=y
+CONFIG_SND_PCM_OSS_PLUGINS=y
 # CONFIG_SND_DYNAMIC_MINORS is not set
-CONFIG_SND_SUPPORT_OLD_API=y
+# CONFIG_SND_SUPPORT_OLD_API is not set
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig
new file mode 100644 (file)
index 0000000..e6e91c8
--- /dev/null
@@ -0,0 +1,3304 @@
+# powerpc
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.26-git2
+# Tue Jul 15 23:54:18 2008
+#
+# CONFIG_PPC64 is not set
+
+#
+# Processor support
+#
+CONFIG_6xx=y
+# CONFIG_PPC_85xx is not set
+# CONFIG_PPC_8xx is not set
+# CONFIG_40x is not set
+# CONFIG_44x is not set
+# CONFIG_E200 is not set
+CONFIG_PPC_FPU=y
+CONFIG_FSL_EMB_PERFMON=y
+CONFIG_ALTIVEC=y
+CONFIG_PPC_STD_MMU=y
+CONFIG_PPC_STD_MMU_32=y
+# CONFIG_PPC_MM_SLICES is not set
+# CONFIG_SMP is not set
+CONFIG_PPC32=y
+CONFIG_WORD_SIZE=32
+CONFIG_PPC_MERGE=y
+CONFIG_MMU=y
+CONFIG_GENERIC_CMOS_UPDATE=y
+CONFIG_GENERIC_TIME=y
+CONFIG_GENERIC_TIME_VSYSCALL=y
+CONFIG_GENERIC_CLOCKEVENTS=y
+CONFIG_GENERIC_HARDIRQS=y
+# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
+CONFIG_IRQ_PER_CPU=y
+CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
+CONFIG_LOCKDEP_SUPPORT=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_ARCH_HAS_ILOG2_U32=y
+CONFIG_GENERIC_HWEIGHT=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_GENERIC_FIND_NEXT_BIT=y
+CONFIG_GENERIC_GPIO=y
+# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
+CONFIG_PPC=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_GENERIC_NVRAM=y
+CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_PPC_OF=y
+CONFIG_OF=y
+CONFIG_PPC_UDBG_16550=y
+# CONFIG_GENERIC_TBSYNC is not set
+CONFIG_AUDIT_ARCH=y
+CONFIG_GENERIC_BUG=y
+CONFIG_SYS_SUPPORTS_APM_EMULATION=y
+CONFIG_DEFAULT_UIMAGE=y
+CONFIG_REDBOOT=y
+CONFIG_HIBERNATE_32=y
+CONFIG_ARCH_HIBERNATION_POSSIBLE=y
+CONFIG_ARCH_SUSPEND_POSSIBLE=y
+# CONFIG_PPC_DCR_NATIVE is not set
+# CONFIG_PPC_DCR_MMIO is not set
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
+
+#
+# General setup
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+CONFIG_LOCALVERSION=""
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_POSIX_MQUEUE=y
+CONFIG_BSD_PROCESS_ACCT=y
+# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+CONFIG_TASKSTATS=y
+CONFIG_TASK_DELAY_ACCT=y
+CONFIG_TASK_XACCT=y
+CONFIG_TASK_IO_ACCOUNTING=y
+CONFIG_AUDIT=y
+CONFIG_AUDITSYSCALL=y
+CONFIG_AUDIT_TREE=y
+# CONFIG_IKCONFIG is not set
+CONFIG_LOG_BUF_SHIFT=17
+CONFIG_CGROUPS=y
+# CONFIG_CGROUP_DEBUG is not set
+CONFIG_CGROUP_NS=y
+CONFIG_CGROUP_DEVICE=y
+CONFIG_GROUP_SCHED=y
+CONFIG_FAIR_GROUP_SCHED=y
+CONFIG_RT_GROUP_SCHED=y
+# CONFIG_USER_SCHED is not set
+CONFIG_CGROUP_SCHED=y
+CONFIG_CGROUP_CPUACCT=y
+CONFIG_RESOURCE_COUNTERS=y
+# CONFIG_CGROUP_MEM_RES_CTLR is not set
+# CONFIG_SYSFS_DEPRECATED_V2 is not set
+CONFIG_RELAY=y
+CONFIG_NAMESPACES=y
+CONFIG_UTS_NS=y
+CONFIG_IPC_NS=y
+CONFIG_USER_NS=y
+CONFIG_PID_NS=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
+# CONFIG_EMBEDDED is not set
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_SYSCTL_SYSCALL_CHECK=y
+CONFIG_KALLSYMS=y
+CONFIG_KALLSYMS_ALL=y
+CONFIG_KALLSYMS_EXTRA_PASS=y
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_PCSPKR_PLATFORM=y
+# CONFIG_COMPAT_BRK is not set
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_ANON_INODES=y
+CONFIG_EPOLL=y
+CONFIG_SIGNALFD=y
+CONFIG_TIMERFD=y
+CONFIG_EVENTFD=y
+CONFIG_SHMEM=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_SLUB_DEBUG=y
+# CONFIG_SLAB is not set
+CONFIG_SLUB=y
+# CONFIG_SLOB is not set
+CONFIG_PROFILING=y
+CONFIG_MARKERS=y
+CONFIG_OPROFILE=m
+CONFIG_HAVE_OPROFILE=y
+CONFIG_KPROBES=y
+CONFIG_KRETPROBES=y
+CONFIG_HAVE_KPROBES=y
+CONFIG_HAVE_KRETPROBES=y
+# CONFIG_HAVE_DMA_ATTRS is not set
+# CONFIG_USE_GENERIC_SMP_HELPERS is not set
+CONFIG_PROC_PAGE_MONITOR=y
+CONFIG_SLABINFO=y
+CONFIG_RT_MUTEXES=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
+CONFIG_MODULE_UNLOAD=y
+# CONFIG_MODULE_FORCE_UNLOAD is not set
+# CONFIG_MODVERSIONS is not set
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_KMOD=y
+CONFIG_BLOCK=y
+CONFIG_LBD=y
+CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_LSF=y
+CONFIG_BLK_DEV_BSG=y
+CONFIG_BLK_DEV_INTEGRITY=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+CONFIG_CLASSIC_RCU=y
+
+#
+# Platform support
+#
+CONFIG_PPC_MULTIPLATFORM=y
+CONFIG_CLASSIC32=y
+CONFIG_PPC_CHRP=y
+# CONFIG_MPC5121_ADS is not set
+# CONFIG_MPC5121_GENERIC is not set
+CONFIG_PPC_MPC52xx=y
+# CONFIG_PPC_MPC5200_SIMPLE is not set
+CONFIG_PPC_EFIKA=y
+# CONFIG_PPC_LITE5200 is not set
+CONFIG_PPC_MPC5200_BUGFIX=y
+CONFIG_PPC_MPC5200_GPIO=y
+CONFIG_PPC_PMAC=y
+# CONFIG_PPC_CELL is not set
+# CONFIG_PPC_CELL_NATIVE is not set
+CONFIG_PPC_82xx=y
+CONFIG_MPC8272_ADS=y
+CONFIG_PQ2FADS=y
+CONFIG_EP8248E=y
+CONFIG_PQ2ADS=y
+CONFIG_8260=y
+CONFIG_8272=y
+CONFIG_PQ2_ADS_PCI_PIC=y
+CONFIG_PPC_83xx=y
+CONFIG_MPC831x_RDB=y
+CONFIG_MPC832x_MDS=y
+CONFIG_MPC832x_RDB=y
+CONFIG_MPC834x_MDS=y
+CONFIG_MPC834x_ITX=y
+CONFIG_MPC836x_MDS=y
+CONFIG_MPC836x_RDK=y
+CONFIG_MPC837x_MDS=y
+CONFIG_MPC837x_RDB=y
+CONFIG_SBC834x=y
+CONFIG_ASP834x=y
+CONFIG_PPC_MPC831x=y
+CONFIG_PPC_MPC832x=y
+CONFIG_PPC_MPC834x=y
+CONFIG_PPC_MPC837x=y
+CONFIG_PPC_86xx=y
+CONFIG_MPC8641_HPCN=y
+CONFIG_SBC8641D=y
+CONFIG_MPC8610_HPCD=y
+CONFIG_MPC8641=y
+CONFIG_MPC8610=y
+# CONFIG_EMBEDDED6xx is not set
+CONFIG_PPC_NATIVE=y
+# CONFIG_UDBG_RTAS_CONSOLE is not set
+CONFIG_IPIC=y
+CONFIG_MPIC=y
+# CONFIG_MPIC_WEIRD is not set
+CONFIG_PPC_I8259=y
+CONFIG_PPC_RTAS=y
+# CONFIG_RTAS_ERROR_LOGGING is not set
+CONFIG_RTAS_PROC=y
+# CONFIG_MMIO_NVRAM is not set
+CONFIG_PPC_MPC106=y
+# CONFIG_PPC_970_NAP is not set
+# CONFIG_PPC_INDIRECT_IO is not set
+# CONFIG_GENERIC_IOMAP is not set
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_TABLE=y
+CONFIG_CPU_FREQ_DEBUG=y
+CONFIG_CPU_FREQ_STAT=m
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
+CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y
+# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
+# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=m
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=m
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
+
+#
+# CPU Frequency drivers
+#
+CONFIG_CPU_FREQ_PMAC=y
+# CONFIG_PPC601_SYNC_FIX is not set
+CONFIG_TAU=y
+# CONFIG_TAU_INT is not set
+CONFIG_TAU_AVERAGE=y
+CONFIG_QUICC_ENGINE=y
+CONFIG_CPM2=y
+CONFIG_PPC_CPM_NEW_BINDING=y
+CONFIG_FSL_ULI1575=y
+CONFIG_CPM=y
+CONFIG_PPC_BESTCOMM=y
+CONFIG_PPC_BESTCOMM_ATA=m
+CONFIG_PPC_BESTCOMM_FEC=m
+CONFIG_PPC_BESTCOMM_GEN_BD=m
+
+#
+# Kernel options
+#
+CONFIG_HIGHMEM=y
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
+# CONFIG_HZ_100 is not set
+# CONFIG_HZ_250 is not set
+# CONFIG_HZ_300 is not set
+CONFIG_HZ_1000=y
+CONFIG_HZ=1000
+# CONFIG_SCHED_HRTICK is not set
+# CONFIG_PREEMPT_NONE is not set
+CONFIG_PREEMPT_VOLUNTARY=y
+# CONFIG_PREEMPT is not set
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_MISC=y
+# CONFIG_MATH_EMULATION is not set
+# CONFIG_IOMMU_HELPER is not set
+CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
+CONFIG_ARCH_HAS_WALK_MEMORY=y
+CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
+# CONFIG_KEXEC is not set
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_ARCH_POPULATES_NODE_MAP=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
+CONFIG_PAGEFLAGS_EXTENDED=y
+CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_RESOURCES_64BIT=y
+CONFIG_ZONE_DMA_FLAG=1
+CONFIG_BOUNCE=y
+CONFIG_VIRT_TO_BUS=y
+CONFIG_FORCE_MAX_ZONEORDER=11
+CONFIG_PROC_DEVICETREE=y
+# CONFIG_CMDLINE_BOOL is not set
+CONFIG_EXTRA_TARGETS=""
+CONFIG_ARCH_WANTS_FREEZER_CONTROL=y
+CONFIG_PM=y
+CONFIG_PM_DEBUG=y
+# CONFIG_PM_VERBOSE is not set
+CONFIG_CAN_PM_TRACE=y
+CONFIG_PM_SLEEP=y
+CONFIG_SUSPEND=y
+CONFIG_SUSPEND_FREEZER=y
+CONFIG_HIBERNATION=y
+CONFIG_PM_STD_PARTITION=""
+CONFIG_APM_EMULATION=y
+CONFIG_SECCOMP=y
+CONFIG_ISA_DMA_API=y
+
+#
+# Bus options
+#
+CONFIG_ISA=y
+CONFIG_ZONE_DMA=y
+CONFIG_GENERIC_ISA_DMA=y
+CONFIG_PPC_INDIRECT_PCI=y
+CONFIG_FSL_SOC=y
+CONFIG_FSL_PCI=y
+CONFIG_FSL_LBC=y
+CONFIG_FSL_GTM=y
+CONFIG_PCI=y
+CONFIG_PCI_DOMAINS=y
+CONFIG_PCI_SYSCALL=y
+CONFIG_PCI_8260=y
+CONFIG_PCIEPORTBUS=y
+CONFIG_PCIEAER=y
+CONFIG_PCIEASPM=y
+# CONFIG_PCIEASPM_DEBUG is not set
+CONFIG_ARCH_SUPPORTS_MSI=y
+CONFIG_PCI_MSI=y
+CONFIG_PCI_LEGACY=y
+# CONFIG_PCI_DEBUG is not set
+CONFIG_PCCARD=y
+# CONFIG_PCMCIA_DEBUG is not set
+CONFIG_PCMCIA=y
+CONFIG_PCMCIA_LOAD_CIS=y
+CONFIG_PCMCIA_IOCTL=y
+CONFIG_CARDBUS=y
+
+#
+# PC-card bridges
+#
+CONFIG_YENTA=y
+CONFIG_YENTA_O2=y
+CONFIG_YENTA_RICOH=y
+CONFIG_YENTA_TI=y
+CONFIG_YENTA_ENE_TUNE=y
+CONFIG_YENTA_TOSHIBA=y
+CONFIG_PD6729=m
+CONFIG_I82092=m
+CONFIG_I82365=m
+# CONFIG_TCIC is not set
+CONFIG_PCMCIA_PROBE=y
+CONFIG_PCCARD_NONSTATIC=y
+# CONFIG_HOTPLUG_PCI is not set
+CONFIG_HAS_RAPIDIO=y
+# CONFIG_RAPIDIO is not set
+
+#
+# Advanced setup
+#
+CONFIG_ADVANCED_OPTIONS=y
+# CONFIG_LOWMEM_SIZE_BOOL is not set
+CONFIG_LOWMEM_SIZE=0x30000000
+# CONFIG_PAGE_OFFSET_BOOL is not set
+CONFIG_PAGE_OFFSET=0xc0000000
+# CONFIG_KERNEL_START_BOOL is not set
+CONFIG_KERNEL_START=0xc0000000
+CONFIG_PHYSICAL_START=0x00000000
+# CONFIG_TASK_SIZE_BOOL is not set
+CONFIG_TASK_SIZE=0xc0000000
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+CONFIG_XFRM=y
+CONFIG_XFRM_USER=y
+CONFIG_XFRM_SUB_POLICY=y
+CONFIG_XFRM_MIGRATE=y
+CONFIG_XFRM_STATISTICS=y
+CONFIG_NET_KEY=m
+CONFIG_NET_KEY_MIGRATE=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_ASK_IP_FIB_HASH=y
+# CONFIG_IP_FIB_TRIE is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_MULTIPLE_TABLES=y
+CONFIG_IP_ROUTE_MULTIPATH=y
+CONFIG_IP_ROUTE_VERBOSE=y
+# CONFIG_IP_PNP is not set
+CONFIG_NET_IPIP=m
+CONFIG_NET_IPGRE=m
+CONFIG_NET_IPGRE_BROADCAST=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+CONFIG_INET_AH=m
+CONFIG_INET_ESP=m
+CONFIG_INET_IPCOMP=m
+CONFIG_INET_XFRM_TUNNEL=m
+CONFIG_INET_TUNNEL=m
+CONFIG_INET_XFRM_MODE_TRANSPORT=m
+CONFIG_INET_XFRM_MODE_TUNNEL=m
+CONFIG_INET_XFRM_MODE_BEET=m
+CONFIG_INET_LRO=y
+CONFIG_INET_DIAG=m
+CONFIG_INET_TCP_DIAG=m
+CONFIG_TCP_CONG_ADVANCED=y
+CONFIG_TCP_CONG_BIC=m
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_TCP_CONG_WESTWOOD=m
+CONFIG_TCP_CONG_HTCP=m
+CONFIG_TCP_CONG_HSTCP=m
+CONFIG_TCP_CONG_HYBLA=m
+CONFIG_TCP_CONG_VEGAS=m
+CONFIG_TCP_CONG_SCALABLE=m
+CONFIG_TCP_CONG_LP=m
+CONFIG_TCP_CONG_VENO=m
+CONFIG_TCP_CONG_YEAH=m
+CONFIG_TCP_CONG_ILLINOIS=m
+# CONFIG_DEFAULT_BIC is not set
+CONFIG_DEFAULT_CUBIC=y
+# CONFIG_DEFAULT_HTCP is not set
+# CONFIG_DEFAULT_VEGAS is not set
+# CONFIG_DEFAULT_WESTWOOD is not set
+# CONFIG_DEFAULT_RENO is not set
+CONFIG_DEFAULT_TCP_CONG="cubic"
+CONFIG_TCP_MD5SIG=y
+# CONFIG_IP_VS is not set
+CONFIG_IPV6=m
+CONFIG_IPV6_PRIVACY=y
+CONFIG_IPV6_ROUTER_PREF=y
+CONFIG_IPV6_ROUTE_INFO=y
+CONFIG_IPV6_OPTIMISTIC_DAD=y
+CONFIG_INET6_AH=m
+CONFIG_INET6_ESP=m
+CONFIG_INET6_IPCOMP=m
+CONFIG_IPV6_MIP6=m
+CONFIG_INET6_XFRM_TUNNEL=m
+CONFIG_INET6_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_TRANSPORT=m
+CONFIG_INET6_XFRM_MODE_TUNNEL=m
+CONFIG_INET6_XFRM_MODE_BEET=m
+CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
+CONFIG_IPV6_SIT=m
+CONFIG_IPV6_NDISC_NODETYPE=y
+CONFIG_IPV6_TUNNEL=m
+CONFIG_IPV6_MULTIPLE_TABLES=y
+CONFIG_IPV6_SUBTREES=y
+CONFIG_IPV6_MROUTE=y
+CONFIG_IPV6_PIMSM_V2=y
+CONFIG_NETLABEL=y
+CONFIG_NETWORK_SECMARK=y
+CONFIG_NETFILTER=y
+# CONFIG_NETFILTER_DEBUG is not set
+CONFIG_NETFILTER_ADVANCED=y
+CONFIG_BRIDGE_NETFILTER=y
+
+#
+# Core Netfilter Configuration
+#
+CONFIG_NETFILTER_NETLINK=m
+CONFIG_NETFILTER_NETLINK_QUEUE=m
+CONFIG_NETFILTER_NETLINK_LOG=m
+CONFIG_NF_CONNTRACK=m
+CONFIG_NF_CT_ACCT=y
+CONFIG_NF_CONNTRACK_MARK=y
+CONFIG_NF_CONNTRACK_SECMARK=y
+CONFIG_NF_CONNTRACK_EVENTS=y
+CONFIG_NF_CT_PROTO_DCCP=m
+CONFIG_NF_CT_PROTO_GRE=m
+CONFIG_NF_CT_PROTO_SCTP=m
+CONFIG_NF_CT_PROTO_UDPLITE=m
+CONFIG_NF_CONNTRACK_AMANDA=m
+CONFIG_NF_CONNTRACK_FTP=m
+CONFIG_NF_CONNTRACK_H323=m
+CONFIG_NF_CONNTRACK_IRC=m
+CONFIG_NF_CONNTRACK_NETBIOS_NS=m
+CONFIG_NF_CONNTRACK_PPTP=m
+CONFIG_NF_CONNTRACK_SANE=m
+CONFIG_NF_CONNTRACK_SIP=m
+CONFIG_NF_CONNTRACK_TFTP=m
+CONFIG_NF_CT_NETLINK=m
+CONFIG_NETFILTER_XTABLES=m
+CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
+CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
+CONFIG_NETFILTER_XT_TARGET_DSCP=m
+CONFIG_NETFILTER_XT_TARGET_MARK=m
+CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
+CONFIG_NETFILTER_XT_TARGET_NFLOG=m
+CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
+CONFIG_NETFILTER_XT_TARGET_RATEEST=m
+CONFIG_NETFILTER_XT_TARGET_TRACE=m
+CONFIG_NETFILTER_XT_TARGET_SECMARK=m
+CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
+CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
+CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP=m
+CONFIG_NETFILTER_XT_MATCH_COMMENT=m
+CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
+CONFIG_NETFILTER_XT_MATCH_CONNLIMIT=m
+CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
+CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
+CONFIG_NETFILTER_XT_MATCH_DCCP=m
+CONFIG_NETFILTER_XT_MATCH_DSCP=m
+CONFIG_NETFILTER_XT_MATCH_ESP=m
+CONFIG_NETFILTER_XT_MATCH_HELPER=m
+CONFIG_NETFILTER_XT_MATCH_IPRANGE=m
+CONFIG_NETFILTER_XT_MATCH_LENGTH=m
+CONFIG_NETFILTER_XT_MATCH_LIMIT=m
+CONFIG_NETFILTER_XT_MATCH_MAC=m
+CONFIG_NETFILTER_XT_MATCH_MARK=m
+CONFIG_NETFILTER_XT_MATCH_OWNER=m
+CONFIG_NETFILTER_XT_MATCH_POLICY=m
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
+CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
+CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
+CONFIG_NETFILTER_XT_MATCH_QUOTA=m
+CONFIG_NETFILTER_XT_MATCH_RATEEST=m
+CONFIG_NETFILTER_XT_MATCH_REALM=m
+CONFIG_NETFILTER_XT_MATCH_SCTP=m
+CONFIG_NETFILTER_XT_MATCH_STATE=m
+CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
+CONFIG_NETFILTER_XT_MATCH_STRING=m
+CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
+CONFIG_NETFILTER_XT_MATCH_TIME=m
+CONFIG_NETFILTER_XT_MATCH_U32=m
+CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
+
+#
+# IP: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV4=m
+# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
+CONFIG_IP_NF_QUEUE=m
+CONFIG_IP_NF_IPTABLES=m
+CONFIG_IP_NF_MATCH_RECENT=m
+CONFIG_IP_NF_MATCH_ECN=m
+CONFIG_IP_NF_MATCH_AH=m
+CONFIG_IP_NF_MATCH_TTL=m
+CONFIG_IP_NF_MATCH_ADDRTYPE=m
+CONFIG_IP_NF_FILTER=m
+CONFIG_IP_NF_TARGET_REJECT=m
+CONFIG_IP_NF_TARGET_LOG=m
+CONFIG_IP_NF_TARGET_ULOG=m
+CONFIG_NF_NAT=m
+CONFIG_NF_NAT_NEEDED=y
+CONFIG_IP_NF_TARGET_MASQUERADE=m
+CONFIG_IP_NF_TARGET_REDIRECT=m
+CONFIG_IP_NF_TARGET_NETMAP=m
+CONFIG_NF_NAT_SNMP_BASIC=m
+CONFIG_NF_NAT_PROTO_DCCP=m
+CONFIG_NF_NAT_PROTO_GRE=m
+CONFIG_NF_NAT_PROTO_UDPLITE=m
+CONFIG_NF_NAT_PROTO_SCTP=m
+CONFIG_NF_NAT_FTP=m
+CONFIG_NF_NAT_IRC=m
+CONFIG_NF_NAT_TFTP=m
+CONFIG_NF_NAT_AMANDA=m
+CONFIG_NF_NAT_PPTP=m
+CONFIG_NF_NAT_H323=m
+CONFIG_NF_NAT_SIP=m
+CONFIG_IP_NF_MANGLE=m
+CONFIG_IP_NF_TARGET_ECN=m
+CONFIG_IP_NF_TARGET_TTL=m
+CONFIG_IP_NF_TARGET_CLUSTERIP=m
+CONFIG_IP_NF_RAW=m
+CONFIG_IP_NF_ARPTABLES=m
+CONFIG_IP_NF_ARPFILTER=m
+CONFIG_IP_NF_ARP_MANGLE=m
+
+#
+# IPv6: Netfilter Configuration
+#
+CONFIG_NF_CONNTRACK_IPV6=m
+CONFIG_IP6_NF_QUEUE=m
+CONFIG_IP6_NF_IPTABLES=m
+CONFIG_IP6_NF_MATCH_RT=m
+CONFIG_IP6_NF_MATCH_OPTS=m
+CONFIG_IP6_NF_MATCH_FRAG=m
+CONFIG_IP6_NF_MATCH_HL=m
+CONFIG_IP6_NF_MATCH_IPV6HEADER=m
+CONFIG_IP6_NF_MATCH_AH=m
+CONFIG_IP6_NF_MATCH_MH=m
+CONFIG_IP6_NF_MATCH_EUI64=m
+CONFIG_IP6_NF_FILTER=m
+CONFIG_IP6_NF_TARGET_LOG=m
+CONFIG_IP6_NF_TARGET_REJECT=m
+CONFIG_IP6_NF_MANGLE=m
+CONFIG_IP6_NF_TARGET_HL=m
+CONFIG_IP6_NF_RAW=m
+
+#
+# DECnet: Netfilter Configuration
+#
+# CONFIG_DECNET_NF_GRABULATOR is not set
+
+#
+# Bridge: Netfilter Configuration
+#
+CONFIG_BRIDGE_NF_EBTABLES=m
+CONFIG_BRIDGE_EBT_BROUTE=m
+CONFIG_BRIDGE_EBT_T_FILTER=m
+CONFIG_BRIDGE_EBT_T_NAT=m
+CONFIG_BRIDGE_EBT_802_3=m
+CONFIG_BRIDGE_EBT_AMONG=m
+CONFIG_BRIDGE_EBT_ARP=m
+CONFIG_BRIDGE_EBT_IP=m
+CONFIG_BRIDGE_EBT_LIMIT=m
+CONFIG_BRIDGE_EBT_MARK=m
+CONFIG_BRIDGE_EBT_PKTTYPE=m
+CONFIG_BRIDGE_EBT_STP=m
+CONFIG_BRIDGE_EBT_VLAN=m
+CONFIG_BRIDGE_EBT_ARPREPLY=m
+CONFIG_BRIDGE_EBT_DNAT=m
+CONFIG_BRIDGE_EBT_MARK_T=m
+CONFIG_BRIDGE_EBT_REDIRECT=m
+CONFIG_BRIDGE_EBT_SNAT=m
+CONFIG_BRIDGE_EBT_LOG=m
+CONFIG_BRIDGE_EBT_ULOG=m
+CONFIG_BRIDGE_EBT_NFLOG=m
+CONFIG_IP_DCCP=m
+CONFIG_INET_DCCP_DIAG=m
+CONFIG_IP_DCCP_ACKVEC=y
+
+#
+# DCCP CCIDs Configuration (EXPERIMENTAL)
+#
+CONFIG_IP_DCCP_CCID2=m
+# CONFIG_IP_DCCP_CCID2_DEBUG is not set
+CONFIG_IP_DCCP_CCID3=m
+# CONFIG_IP_DCCP_CCID3_DEBUG is not set
+CONFIG_IP_DCCP_CCID3_RTO=100
+CONFIG_IP_DCCP_TFRC_LIB=m
+
+#
+# DCCP Kernel Hacking
+#
+# CONFIG_IP_DCCP_DEBUG is not set
+CONFIG_NET_DCCPPROBE=m
+CONFIG_IP_SCTP=m
+# CONFIG_SCTP_DBG_MSG is not set
+# CONFIG_SCTP_DBG_OBJCNT is not set
+# CONFIG_SCTP_HMAC_NONE is not set
+# CONFIG_SCTP_HMAC_SHA1 is not set
+CONFIG_SCTP_HMAC_MD5=y
+CONFIG_TIPC=m
+# CONFIG_TIPC_ADVANCED is not set
+# CONFIG_TIPC_DEBUG is not set
+CONFIG_ATM=m
+CONFIG_ATM_CLIP=m
+# CONFIG_ATM_CLIP_NO_ICMP is not set
+CONFIG_ATM_LANE=m
+# CONFIG_ATM_MPOA is not set
+CONFIG_ATM_BR2684=m
+# CONFIG_ATM_BR2684_IPFILTER is not set
+CONFIG_BRIDGE=m
+CONFIG_VLAN_8021Q=m
+CONFIG_DECNET=m
+CONFIG_DECNET_ROUTER=y
+CONFIG_LLC=m
+# CONFIG_LLC2 is not set
+CONFIG_IPX=m
+# CONFIG_IPX_INTERN is not set
+CONFIG_ATALK=m
+CONFIG_DEV_APPLETALK=m
+# CONFIG_LTPC is not set
+# CONFIG_COPS is not set
+CONFIG_IPDDP=m
+CONFIG_IPDDP_ENCAP=y
+CONFIG_IPDDP_DECAP=y
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_ECONET is not set
+CONFIG_WAN_ROUTER=m
+CONFIG_NET_SCHED=y
+
+#
+# Queueing/Scheduling
+#
+CONFIG_NET_SCH_CBQ=m
+CONFIG_NET_SCH_HTB=m
+CONFIG_NET_SCH_HFSC=m
+CONFIG_NET_SCH_ATM=m
+CONFIG_NET_SCH_PRIO=m
+CONFIG_NET_SCH_RED=m
+CONFIG_NET_SCH_SFQ=m
+CONFIG_NET_SCH_TEQL=m
+CONFIG_NET_SCH_TBF=m
+CONFIG_NET_SCH_GRED=m
+CONFIG_NET_SCH_DSMARK=m
+CONFIG_NET_SCH_NETEM=m
+CONFIG_NET_SCH_INGRESS=m
+
+#
+# Classification
+#
+CONFIG_NET_CLS=y
+CONFIG_NET_CLS_BASIC=m
+CONFIG_NET_CLS_TCINDEX=m
+CONFIG_NET_CLS_ROUTE4=m
+CONFIG_NET_CLS_ROUTE=y
+CONFIG_NET_CLS_FW=m
+CONFIG_NET_CLS_U32=m
+CONFIG_CLS_U32_PERF=y
+CONFIG_CLS_U32_MARK=y
+CONFIG_NET_CLS_RSVP=m
+CONFIG_NET_CLS_RSVP6=m
+CONFIG_NET_CLS_FLOW=m
+CONFIG_NET_EMATCH=y
+CONFIG_NET_EMATCH_STACK=32
+CONFIG_NET_EMATCH_CMP=m
+CONFIG_NET_EMATCH_NBYTE=m
+CONFIG_NET_EMATCH_U32=m
+CONFIG_NET_EMATCH_META=m
+CONFIG_NET_EMATCH_TEXT=m
+CONFIG_NET_CLS_ACT=y
+CONFIG_NET_ACT_POLICE=m
+CONFIG_NET_ACT_GACT=m
+CONFIG_GACT_PROB=y
+CONFIG_NET_ACT_MIRRED=m
+CONFIG_NET_ACT_IPT=m
+CONFIG_NET_ACT_NAT=m
+CONFIG_NET_ACT_PEDIT=m
+CONFIG_NET_ACT_SIMP=m
+CONFIG_NET_CLS_IND=y
+CONFIG_NET_SCH_FIFO=y
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_NET_TCPPROBE is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_CAN is not set
+CONFIG_IRDA=m
+
+#
+# IrDA protocols
+#
+CONFIG_IRLAN=m
+CONFIG_IRNET=m
+CONFIG_IRCOMM=m
+# CONFIG_IRDA_ULTRA is not set
+
+#
+# IrDA options
+#
+CONFIG_IRDA_CACHE_LAST_LSAP=y
+CONFIG_IRDA_FAST_RR=y
+# CONFIG_IRDA_DEBUG is not set
+
+#
+# Infrared-port device drivers
+#
+
+#
+# SIR device drivers
+#
+CONFIG_IRTTY_SIR=m
+
+#
+# Dongle support
+#
+# CONFIG_DONGLE is not set
+CONFIG_KINGSUN_DONGLE=m
+CONFIG_KSDAZZLE_DONGLE=m
+CONFIG_KS959_DONGLE=m
+
+#
+# FIR device drivers
+#
+CONFIG_USB_IRDA=m
+CONFIG_SIGMATEL_FIR=m
+CONFIG_NSC_FIR=m
+CONFIG_WINBOND_FIR=m
+CONFIG_TOSHIBA_FIR=m
+CONFIG_SMC_IRCC_FIR=m
+CONFIG_ALI_FIR=m
+CONFIG_VLSI_FIR=m
+CONFIG_VIA_FIR=m
+CONFIG_MCS_FIR=m
+CONFIG_BT=m
+CONFIG_BT_L2CAP=m
+CONFIG_BT_SCO=m
+CONFIG_BT_RFCOMM=m
+CONFIG_BT_RFCOMM_TTY=y
+CONFIG_BT_BNEP=m
+CONFIG_BT_BNEP_MC_FILTER=y
+CONFIG_BT_BNEP_PROTO_FILTER=y
+CONFIG_BT_HIDP=m
+
+#
+# Bluetooth device drivers
+#
+CONFIG_BT_HCIUSB=m
+CONFIG_BT_HCIUSB_SCO=y
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIUART_LL=y
+CONFIG_BT_HCIBCM203X=m
+CONFIG_BT_HCIBPA10X=m
+CONFIG_BT_HCIBFUSB=m
+CONFIG_BT_HCIDTL1=m
+CONFIG_BT_HCIBT3C=m
+CONFIG_BT_HCIBLUECARD=m
+CONFIG_BT_HCIBTUART=m
+CONFIG_BT_HCIVHCI=m
+# CONFIG_AF_RXRPC is not set
+CONFIG_FIB_RULES=y
+
+#
+# Wireless
+#
+CONFIG_CFG80211=m
+CONFIG_NL80211=y
+CONFIG_WIRELESS_EXT=y
+CONFIG_WIRELESS_EXT_SYSFS=y
+CONFIG_MAC80211=m
+CONFIG_MAC80211_QOS=y
+
+#
+# Rate control algorithm selection
+#
+CONFIG_MAC80211_RC_PID=y
+CONFIG_MAC80211_RC_DEFAULT_PID=y
+CONFIG_MAC80211_RC_DEFAULT="pid"
+CONFIG_MAC80211_MESH=y
+CONFIG_MAC80211_LEDS=y
+CONFIG_MAC80211_DEBUGFS=y
+# CONFIG_MAC80211_DEBUG_MENU is not set
+CONFIG_IEEE80211=m
+CONFIG_IEEE80211_DEBUG=y
+CONFIG_IEEE80211_CRYPT_WEP=m
+CONFIG_IEEE80211_CRYPT_CCMP=m
+CONFIG_IEEE80211_CRYPT_TKIP=m
+# CONFIG_RFKILL is not set
+CONFIG_NET_9P=m
+CONFIG_NET_9P_VIRTIO=m
+# CONFIG_NET_9P_DEBUG is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+CONFIG_FW_LOADER=y
+# CONFIG_FIRMWARE_IN_KERNEL is not set
+CONFIG_EXTRA_FIRMWARE=""
+# CONFIG_DEBUG_DRIVER is not set
+CONFIG_DEBUG_DEVRES=y
+# CONFIG_SYS_HYPERVISOR is not set
+CONFIG_CONNECTOR=y
+CONFIG_PROC_EVENTS=y
+# CONFIG_MTD is not set
+CONFIG_OF_DEVICE=y
+CONFIG_OF_GPIO=y
+CONFIG_OF_I2C=y
+CONFIG_PARPORT=m
+CONFIG_PARPORT_PC=m
+CONFIG_PARPORT_SERIAL=m
+# CONFIG_PARPORT_PC_FIFO is not set
+# CONFIG_PARPORT_PC_SUPERIO is not set
+# CONFIG_PARPORT_PC_PCMCIA is not set
+# CONFIG_PARPORT_GSC is not set
+# CONFIG_PARPORT_AX88796 is not set
+CONFIG_PARPORT_1284=y
+CONFIG_PARPORT_NOT_PC=y
+CONFIG_PNP=y
+# CONFIG_PNP_DEBUG is not set
+
+#
+# Protocols
+#
+CONFIG_ISAPNP=y
+# CONFIG_PNPACPI is not set
+CONFIG_BLK_DEV=y
+# CONFIG_BLK_DEV_FD is not set
+CONFIG_MAC_FLOPPY=m
+# CONFIG_BLK_DEV_XD is not set
+# CONFIG_PARIDE is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=m
+CONFIG_BLK_DEV_CRYPTOLOOP=m
+CONFIG_BLK_DEV_NBD=m
+# CONFIG_BLK_DEV_SX8 is not set
+# CONFIG_BLK_DEV_UB is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=16384
+# CONFIG_BLK_DEV_XIP is not set
+CONFIG_CDROM_PKTCDVD=m
+CONFIG_CDROM_PKTCDVD_BUFFERS=8
+# CONFIG_CDROM_PKTCDVD_WCACHE is not set
+# CONFIG_ATA_OVER_ETH is not set
+CONFIG_VIRTIO_BLK=m
+CONFIG_MISC_DEVICES=y
+# CONFIG_PHANTOM is not set
+CONFIG_EEPROM_93CX6=m
+# CONFIG_SGI_IOC4 is not set
+# CONFIG_TIFM_CORE is not set
+CONFIG_ENCLOSURE_SERVICES=m
+CONFIG_HAVE_IDE=y
+CONFIG_IDE=y
+CONFIG_BLK_DEV_IDE=y
+
+#
+# Please see Documentation/ide/ide.txt for help/info on IDE drives
+#
+CONFIG_IDE_ATAPI=y
+# CONFIG_BLK_DEV_IDE_SATA is not set
+CONFIG_BLK_DEV_IDEDISK=y
+CONFIG_IDEDISK_MULTI_MODE=y
+# CONFIG_BLK_DEV_IDECS is not set
+# CONFIG_BLK_DEV_DELKIN is not set
+CONFIG_BLK_DEV_IDECD=m
+CONFIG_BLK_DEV_IDECD_VERBOSE_ERRORS=y
+# CONFIG_BLK_DEV_IDETAPE is not set
+CONFIG_BLK_DEV_IDEFLOPPY=m
+# CONFIG_BLK_DEV_IDESCSI is not set
+CONFIG_IDE_TASK_IOCTL=y
+CONFIG_IDE_PROC_FS=y
+
+#
+# IDE chipset support/bugfixes
+#
+# CONFIG_IDE_GENERIC is not set
+# CONFIG_BLK_DEV_PLATFORM is not set
+# CONFIG_BLK_DEV_IDEPNP is not set
+CONFIG_BLK_DEV_IDEDMA_SFF=y
+
+#
+# PCI IDE chipsets support
+#
+CONFIG_BLK_DEV_IDEPCI=y
+# CONFIG_IDEPCI_PCIBUS_ORDER is not set
+# CONFIG_BLK_DEV_OFFBOARD is not set
+CONFIG_BLK_DEV_GENERIC=y
+# CONFIG_BLK_DEV_OPTI621 is not set
+CONFIG_BLK_DEV_IDEDMA_PCI=y
+# CONFIG_BLK_DEV_AEC62XX is not set
+# CONFIG_BLK_DEV_ALI15X3 is not set
+# CONFIG_BLK_DEV_AMD74XX is not set
+# CONFIG_BLK_DEV_CMD64X is not set
+# CONFIG_BLK_DEV_TRIFLEX is not set
+# CONFIG_BLK_DEV_CY82C693 is not set
+# CONFIG_BLK_DEV_CS5520 is not set
+# CONFIG_BLK_DEV_CS5530 is not set
+# CONFIG_BLK_DEV_HPT34X is not set
+# CONFIG_BLK_DEV_HPT366 is not set
+# CONFIG_BLK_DEV_JMICRON is not set
+# CONFIG_BLK_DEV_SC1200 is not set
+# CONFIG_BLK_DEV_PIIX is not set
+# CONFIG_BLK_DEV_IT8213 is not set
+# CONFIG_BLK_DEV_IT821X is not set
+# CONFIG_BLK_DEV_NS87415 is not set
+# CONFIG_BLK_DEV_PDC202XX_OLD is not set
+# CONFIG_BLK_DEV_PDC202XX_NEW is not set
+# CONFIG_BLK_DEV_SVWKS is not set
+# CONFIG_BLK_DEV_SIIMAGE is not set
+# CONFIG_BLK_DEV_SL82C105 is not set
+# CONFIG_BLK_DEV_SLC90E66 is not set
+# CONFIG_BLK_DEV_TRM290 is not set
+# CONFIG_BLK_DEV_VIA82CXXX is not set
+# CONFIG_BLK_DEV_TC86C001 is not set
+CONFIG_BLK_DEV_IDE_PMAC=y
+CONFIG_BLK_DEV_IDE_PMAC_ATA100FIRST=y
+CONFIG_BLK_DEV_IDEDMA_PMAC=y
+CONFIG_BLK_DEV_IDEDMA=y
+CONFIG_BLK_DEV_HD_ONLY=y
+CONFIG_BLK_DEV_HD=y
+
+#
+# SCSI device support
+#
+CONFIG_RAID_ATTRS=m
+CONFIG_SCSI=y
+CONFIG_SCSI_DMA=y
+CONFIG_SCSI_TGT=m
+# CONFIG_SCSI_NETLINK is not set
+CONFIG_SCSI_PROC_FS=y
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+CONFIG_CHR_DEV_ST=m
+CONFIG_CHR_DEV_OSST=m
+CONFIG_BLK_DEV_SR=m
+CONFIG_BLK_DEV_SR_VENDOR=y
+CONFIG_CHR_DEV_SG=y
+CONFIG_CHR_DEV_SCH=m
+CONFIG_SCSI_ENCLOSURE=m
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+CONFIG_SCSI_MULTI_LUN=y
+CONFIG_SCSI_CONSTANTS=y
+CONFIG_SCSI_LOGGING=y
+CONFIG_SCSI_SCAN_ASYNC=y
+CONFIG_SCSI_WAIT_SCAN=m
+
+#
+# SCSI Transports
+#
+CONFIG_SCSI_SPI_ATTRS=m
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+# CONFIG_SCSI_SAS_LIBSAS is not set
+CONFIG_SCSI_SRP_ATTRS=m
+CONFIG_SCSI_SRP_TGT_ATTRS=y
+CONFIG_SCSI_LOWLEVEL=y
+# CONFIG_ISCSI_TCP is not set
+# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
+# CONFIG_SCSI_3W_9XXX is not set
+# CONFIG_SCSI_7000FASST is not set
+# CONFIG_SCSI_ACARD is not set
+# CONFIG_SCSI_AHA152X is not set
+# CONFIG_SCSI_AHA1542 is not set
+# CONFIG_SCSI_AACRAID is not set
+# CONFIG_SCSI_AIC7XXX is not set
+# CONFIG_SCSI_AIC7XXX_OLD is not set
+# CONFIG_SCSI_AIC79XX is not set
+# CONFIG_SCSI_AIC94XX is not set
+# CONFIG_SCSI_DPT_I2O is not set
+# CONFIG_SCSI_ADVANSYS is not set
+# CONFIG_SCSI_IN2000 is not set
+# CONFIG_SCSI_ARCMSR is not set
+# CONFIG_MEGARAID_NEWGEN is not set
+# CONFIG_MEGARAID_LEGACY is not set
+# CONFIG_MEGARAID_SAS is not set
+# CONFIG_SCSI_HPTIOP is not set
+# CONFIG_SCSI_BUSLOGIC is not set
+# CONFIG_SCSI_DMX3191D is not set
+# CONFIG_SCSI_DTC3280 is not set
+# CONFIG_SCSI_EATA is not set
+# CONFIG_SCSI_FUTURE_DOMAIN is not set
+# CONFIG_SCSI_GDTH is not set
+# CONFIG_SCSI_GENERIC_NCR5380 is not set
+# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
+# CONFIG_SCSI_IPS is not set
+# CONFIG_SCSI_INITIO is not set
+# CONFIG_SCSI_INIA100 is not set
+# CONFIG_SCSI_PPA is not set
+# CONFIG_SCSI_IMM is not set
+# CONFIG_SCSI_MVSAS is not set
+# CONFIG_SCSI_NCR53C406A is not set
+# CONFIG_SCSI_STEX is not set
+# CONFIG_SCSI_SYM53C8XX_2 is not set
+# CONFIG_SCSI_IPR is not set
+# CONFIG_SCSI_PAS16 is not set
+# CONFIG_SCSI_QLOGIC_FAS is not set
+# CONFIG_SCSI_QLOGIC_1280 is not set
+# CONFIG_SCSI_QLA_FC is not set
+# CONFIG_SCSI_QLA_ISCSI is not set
+# CONFIG_SCSI_LPFC is not set
+# CONFIG_SCSI_SYM53C416 is not set
+# CONFIG_SCSI_DC395x is not set
+# CONFIG_SCSI_DC390T is not set
+# CONFIG_SCSI_T128 is not set
+# CONFIG_SCSI_U14_34F is not set
+# CONFIG_SCSI_NSP32 is not set
+# CONFIG_SCSI_DEBUG is not set
+CONFIG_SCSI_MESH=m
+CONFIG_SCSI_MESH_SYNC_RATE=5
+CONFIG_SCSI_MESH_RESET_DELAY_MS=4000
+CONFIG_SCSI_MAC53C94=m
+CONFIG_SCSI_SRP=m
+CONFIG_SCSI_LOWLEVEL_PCMCIA=y
+# CONFIG_PCMCIA_AHA152X is not set
+# CONFIG_PCMCIA_FDOMAIN is not set
+# CONFIG_PCMCIA_NINJA_SCSI is not set
+# CONFIG_PCMCIA_QLOGIC is not set
+# CONFIG_PCMCIA_SYM53C500 is not set
+CONFIG_SCSI_DH=y
+CONFIG_SCSI_DH_RDAC=m
+CONFIG_SCSI_DH_HP_SW=m
+CONFIG_SCSI_DH_EMC=m
+CONFIG_ATA=y
+# CONFIG_ATA_NONSTANDARD is not set
+# CONFIG_SATA_PMP is not set
+# CONFIG_SATA_AHCI is not set
+# CONFIG_SATA_SIL24 is not set
+CONFIG_SATA_FSL=m
+CONFIG_ATA_SFF=y
+# CONFIG_SATA_SVW is not set
+CONFIG_ATA_PIIX=m
+# CONFIG_SATA_MV is not set
+# CONFIG_SATA_NV is not set
+CONFIG_PDC_ADMA=m
+# CONFIG_SATA_QSTOR is not set
+# CONFIG_SATA_PROMISE is not set
+# CONFIG_SATA_SX4 is not set
+# CONFIG_SATA_SIL is not set
+# CONFIG_SATA_SIS is not set
+# CONFIG_SATA_ULI is not set
+# CONFIG_SATA_VIA is not set
+# CONFIG_SATA_VITESSE is not set
+# CONFIG_SATA_INIC162X is not set
+# CONFIG_PATA_ALI is not set
+# CONFIG_PATA_AMD is not set
+# CONFIG_PATA_ARTOP is not set
+# CONFIG_PATA_ATIIXP is not set
+# CONFIG_PATA_CMD640_PCI is not set
+# CONFIG_PATA_CMD64X is not set
+# CONFIG_PATA_CS5520 is not set
+# CONFIG_PATA_CS5530 is not set
+# CONFIG_PATA_CYPRESS is not set
+# CONFIG_PATA_EFAR is not set
+CONFIG_ATA_GENERIC=m
+# CONFIG_PATA_HPT366 is not set
+# CONFIG_PATA_HPT37X is not set
+# CONFIG_PATA_HPT3X2N is not set
+# CONFIG_PATA_HPT3X3 is not set
+# CONFIG_PATA_ISAPNP is not set
+# CONFIG_PATA_IT821X is not set
+# CONFIG_PATA_IT8213 is not set
+# CONFIG_PATA_JMICRON is not set
+# CONFIG_PATA_LEGACY is not set
+# CONFIG_PATA_TRIFLEX is not set
+# CONFIG_PATA_MARVELL is not set
+CONFIG_PATA_MPC52xx=m
+# CONFIG_PATA_MPIIX is not set
+# CONFIG_PATA_OLDPIIX is not set
+# CONFIG_PATA_NETCELL is not set
+# CONFIG_PATA_NINJA32 is not set
+# CONFIG_PATA_NS87410 is not set
+# CONFIG_PATA_NS87415 is not set
+# CONFIG_PATA_OPTI is not set
+CONFIG_PATA_OPTIDMA=m
+# CONFIG_PATA_PCMCIA is not set
+# CONFIG_PATA_PDC_OLD is not set
+# CONFIG_PATA_QDI is not set
+# CONFIG_PATA_RADISYS is not set
+# CONFIG_PATA_RZ1000 is not set
+# CONFIG_PATA_SC1200 is not set
+# CONFIG_PATA_SERVERWORKS is not set
+# CONFIG_PATA_PDC2027X is not set
+# CONFIG_PATA_SIL680 is not set
+# CONFIG_PATA_SIS is not set
+CONFIG_PATA_VIA=m
+# CONFIG_PATA_WINBOND is not set
+# CONFIG_PATA_WINBOND_VLB is not set
+CONFIG_PATA_PLATFORM=m
+CONFIG_PATA_OF_PLATFORM=m
+CONFIG_PATA_SCH=m
+CONFIG_MD=y
+CONFIG_BLK_DEV_MD=y
+CONFIG_MD_LINEAR=m
+CONFIG_MD_RAID0=m
+CONFIG_MD_RAID1=m
+CONFIG_MD_RAID10=m
+CONFIG_MD_RAID456=m
+CONFIG_MD_RAID5_RESHAPE=y
+CONFIG_MD_MULTIPATH=m
+CONFIG_MD_FAULTY=m
+CONFIG_BLK_DEV_DM=m
+CONFIG_DM_DEBUG=y
+CONFIG_DM_CRYPT=m
+CONFIG_DM_SNAPSHOT=m
+CONFIG_DM_MIRROR=m
+CONFIG_DM_ZERO=m
+CONFIG_DM_MULTIPATH=m
+# CONFIG_DM_DELAY is not set
+CONFIG_DM_UEVENT=y
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# Enable only one of the two stacks, unless you know what you are doing
+#
+CONFIG_FIREWIRE=m
+CONFIG_FIREWIRE_OHCI=m
+CONFIG_FIREWIRE_OHCI_DEBUG=y
+CONFIG_FIREWIRE_SBP2=m
+# CONFIG_IEEE1394 is not set
+# CONFIG_I2O is not set
+CONFIG_MACINTOSH_DRIVERS=y
+CONFIG_ADB=y
+CONFIG_ADB_CUDA=y
+CONFIG_ADB_PMU=y
+CONFIG_ADB_PMU_LED=y
+CONFIG_ADB_PMU_LED_IDE=y
+CONFIG_PMAC_APM_EMU=y
+CONFIG_PMAC_MEDIABAY=y
+CONFIG_PMAC_BACKLIGHT=y
+# CONFIG_PMAC_BACKLIGHT_LEGACY is not set
+CONFIG_ADB_MACIO=y
+CONFIG_INPUT_ADBHID=y
+CONFIG_MAC_EMUMOUSEBTN=y
+CONFIG_THERM_WINDTUNNEL=m
+CONFIG_THERM_ADT746X=m
+CONFIG_WINDFARM=y
+# CONFIG_ANSLCD is not set
+CONFIG_PMAC_RACKMETER=m
+CONFIG_NETDEVICES=y
+CONFIG_NETDEVICES_MULTIQUEUE=y
+CONFIG_IFB=m
+CONFIG_DUMMY=m
+CONFIG_BONDING=m
+CONFIG_MACVLAN=m
+CONFIG_EQUALIZER=m
+CONFIG_TUN=m
+CONFIG_VETH=m
+CONFIG_NET_SB1000=m
+# CONFIG_ARCNET is not set
+CONFIG_PHYLIB=m
+
+#
+# MII PHY device drivers
+#
+CONFIG_MARVELL_PHY=m
+CONFIG_DAVICOM_PHY=m
+CONFIG_QSEMI_PHY=m
+CONFIG_LXT_PHY=m
+CONFIG_CICADA_PHY=m
+CONFIG_VITESSE_PHY=m
+CONFIG_SMSC_PHY=m
+CONFIG_BROADCOM_PHY=m
+CONFIG_ICPLUS_PHY=m
+CONFIG_REALTEK_PHY=m
+CONFIG_MDIO_BITBANG=y
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=m
+CONFIG_MACE=m
+# CONFIG_MACE_AAUI_PORT is not set
+CONFIG_BMAC=m
+CONFIG_HAPPYMEAL=m
+CONFIG_SUNGEM=m
+CONFIG_CASSINI=m
+CONFIG_NET_VENDOR_3COM=y
+# CONFIG_EL1 is not set
+# CONFIG_EL2 is not set
+# CONFIG_ELPLUS is not set
+# CONFIG_EL16 is not set
+CONFIG_EL3=m
+# CONFIG_3C515 is not set
+CONFIG_VORTEX=m
+CONFIG_TYPHOON=m
+# CONFIG_LANCE is not set
+CONFIG_NET_VENDOR_SMC=y
+# CONFIG_WD80x3 is not set
+CONFIG_ULTRA=m
+# CONFIG_SMC9194 is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+CONFIG_NET_TULIP=y
+CONFIG_DE2104X=m
+CONFIG_TULIP=m
+# CONFIG_TULIP_MWI is not set
+CONFIG_TULIP_MMIO=y
+# CONFIG_TULIP_NAPI is not set
+CONFIG_DE4X5=m
+CONFIG_WINBOND_840=m
+CONFIG_DM9102=m
+CONFIG_ULI526X=m
+CONFIG_PCMCIA_XIRCOM=m
+# CONFIG_AT1700 is not set
+# CONFIG_DEPCA is not set
+# CONFIG_HP100 is not set
+CONFIG_NET_ISA=y
+# CONFIG_E2100 is not set
+CONFIG_EWRK3=m
+# CONFIG_EEXPRESS is not set
+# CONFIG_EEXPRESS_PRO is not set
+# CONFIG_HPLAN_PLUS is not set
+# CONFIG_HPLAN is not set
+# CONFIG_LP486E is not set
+# CONFIG_ETH16I is not set
+CONFIG_NE2000=m
+# CONFIG_ZNET is not set
+# CONFIG_SEEQ8005 is not set
+# CONFIG_IBM_NEW_EMAC_ZMII is not set
+# CONFIG_IBM_NEW_EMAC_RGMII is not set
+# CONFIG_IBM_NEW_EMAC_TAH is not set
+# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
+CONFIG_NET_PCI=y
+CONFIG_PCNET32=m
+CONFIG_AMD8111_ETH=m
+CONFIG_AMD8111E_NAPI=y
+CONFIG_ADAPTEC_STARFIRE=m
+CONFIG_ADAPTEC_STARFIRE_NAPI=y
+# CONFIG_AC3200 is not set
+# CONFIG_APRICOT is not set
+CONFIG_B44=m
+CONFIG_B44_PCI_AUTOSELECT=y
+CONFIG_B44_PCICORE_AUTOSELECT=y
+CONFIG_B44_PCI=y
+CONFIG_FORCEDETH=m
+CONFIG_FORCEDETH_NAPI=y
+# CONFIG_CS89x0 is not set
+# CONFIG_EEPRO100 is not set
+CONFIG_E100=m
+CONFIG_FEALNX=m
+CONFIG_NATSEMI=m
+CONFIG_NE2K_PCI=m
+CONFIG_8139CP=m
+CONFIG_8139TOO=m
+# CONFIG_8139TOO_PIO is not set
+# CONFIG_8139TOO_TUNE_TWISTER is not set
+CONFIG_8139TOO_8129=y
+# CONFIG_8139_OLD_RX_RESET is not set
+CONFIG_R6040=m
+CONFIG_SIS900=m
+CONFIG_EPIC100=m
+CONFIG_SUNDANCE=m
+# CONFIG_SUNDANCE_MMIO is not set
+CONFIG_TLAN=m
+CONFIG_VIA_RHINE=m
+CONFIG_VIA_RHINE_MMIO=y
+CONFIG_VIA_RHINE_NAPI=y
+CONFIG_SC92031=m
+CONFIG_NET_POCKET=y
+CONFIG_DE600=m
+CONFIG_DE620=m
+CONFIG_FEC_MPC52xx=m
+CONFIG_FEC_MPC52xx_MDIO=y
+# CONFIG_FS_ENET is not set
+CONFIG_NETDEV_1000=y
+CONFIG_ACENIC=m
+# CONFIG_ACENIC_OMIT_TIGON_I is not set
+CONFIG_DL2K=m
+CONFIG_E1000=m
+CONFIG_E1000_NAPI=y
+# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
+CONFIG_E1000E=m
+CONFIG_E1000E_ENABLED=y
+CONFIG_IP1000=m
+CONFIG_IGB=m
+CONFIG_NS83820=m
+CONFIG_HAMACHI=m
+CONFIG_YELLOWFIN=m
+CONFIG_R8169=m
+CONFIG_R8169_NAPI=y
+CONFIG_R8169_VLAN=y
+CONFIG_SIS190=m
+CONFIG_SKGE=m
+# CONFIG_SKGE_DEBUG is not set
+CONFIG_SKY2=m
+# CONFIG_SKY2_DEBUG is not set
+CONFIG_VIA_VELOCITY=m
+CONFIG_TIGON3=m
+CONFIG_BNX2=m
+CONFIG_GIANFAR=m
+CONFIG_GFAR_NAPI=y
+# CONFIG_UCC_GETH is not set
+CONFIG_MV643XX_ETH=m
+CONFIG_QLA3XXX=m
+CONFIG_ATL1=m
+CONFIG_NETDEV_10000=y
+CONFIG_CHELSIO_T1=m
+CONFIG_CHELSIO_T1_1G=y
+CONFIG_CHELSIO_T1_NAPI=y
+CONFIG_CHELSIO_T3=m
+CONFIG_IXGBE=m
+CONFIG_IXGB=m
+CONFIG_IXGB_NAPI=y
+CONFIG_S2IO=m
+CONFIG_S2IO_NAPI=y
+CONFIG_MYRI10GE=m
+CONFIG_NETXEN_NIC=m
+CONFIG_NIU=m
+# CONFIG_MLX4_CORE is not set
+CONFIG_TEHUTI=m
+CONFIG_BNX2X=m
+CONFIG_SFC=m
+# CONFIG_TR is not set
+
+#
+# Wireless LAN
+#
+# CONFIG_WLAN_PRE80211 is not set
+# CONFIG_WLAN_80211 is not set
+# CONFIG_IWLWIFI_LEDS is not set
+
+#
+# USB Network Adapters
+#
+CONFIG_USB_CATC=m
+CONFIG_USB_KAWETH=m
+CONFIG_USB_PEGASUS=m
+CONFIG_USB_RTL8150=m
+CONFIG_USB_USBNET=m
+CONFIG_USB_NET_AX8817X=m
+CONFIG_USB_NET_CDCETHER=m
+CONFIG_USB_NET_DM9601=m
+CONFIG_USB_NET_GL620A=m
+CONFIG_USB_NET_NET1080=m
+CONFIG_USB_NET_PLUSB=m
+CONFIG_USB_NET_MCS7830=m
+CONFIG_USB_NET_RNDIS_HOST=m
+CONFIG_USB_NET_CDC_SUBSET=m
+CONFIG_USB_ALI_M5632=y
+CONFIG_USB_AN2720=y
+CONFIG_USB_BELKIN=y
+CONFIG_USB_ARMLINUX=y
+CONFIG_USB_EPSON2888=y
+CONFIG_USB_KC2190=y
+CONFIG_USB_NET_ZAURUS=m
+CONFIG_NET_PCMCIA=y
+CONFIG_PCMCIA_3C589=m
+CONFIG_PCMCIA_3C574=m
+CONFIG_PCMCIA_FMVJ18X=m
+CONFIG_PCMCIA_PCNET=m
+CONFIG_PCMCIA_NMCLAN=m
+CONFIG_PCMCIA_SMC91C92=m
+CONFIG_PCMCIA_XIRC2PS=m
+CONFIG_PCMCIA_AXNET=m
+# CONFIG_WAN is not set
+CONFIG_ATM_DRIVERS=y
+# CONFIG_ATM_DUMMY is not set
+CONFIG_ATM_TCP=m
+CONFIG_ATM_LANAI=m
+CONFIG_ATM_ENI=m
+# CONFIG_ATM_ENI_DEBUG is not set
+# CONFIG_ATM_ENI_TUNE_BURST is not set
+# CONFIG_ATM_FIRESTREAM is not set
+# CONFIG_ATM_ZATM is not set
+CONFIG_ATM_NICSTAR=m
+# CONFIG_ATM_NICSTAR_USE_SUNI is not set
+# CONFIG_ATM_NICSTAR_USE_IDT77105 is not set
+CONFIG_ATM_IDT77252=m
+# CONFIG_ATM_IDT77252_DEBUG is not set
+# CONFIG_ATM_IDT77252_RCV_ALL is not set
+CONFIG_ATM_IDT77252_USE_SUNI=y
+# CONFIG_ATM_AMBASSADOR is not set
+# CONFIG_ATM_HORIZON is not set
+# CONFIG_ATM_IA is not set
+CONFIG_ATM_FORE200E_MAYBE=m
+# CONFIG_ATM_FORE200E_PCA is not set
+CONFIG_ATM_HE=m
+# CONFIG_ATM_HE_USE_SUNI is not set
+CONFIG_FDDI=y
+# CONFIG_DEFXX is not set
+CONFIG_SKFP=m
+# CONFIG_HIPPI is not set
+CONFIG_PLIP=m
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+CONFIG_PPP_FILTER=y
+CONFIG_PPP_ASYNC=m
+CONFIG_PPP_SYNC_TTY=m
+CONFIG_PPP_DEFLATE=m
+# CONFIG_PPP_BSDCOMP is not set
+CONFIG_PPP_MPPE=m
+CONFIG_PPPOE=m
+CONFIG_PPPOATM=m
+CONFIG_PPPOL2TP=m
+CONFIG_SLIP=m
+CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLHC=m
+CONFIG_SLIP_SMART=y
+# CONFIG_SLIP_MODE_SLIP6 is not set
+CONFIG_NET_FC=y
+CONFIG_NETCONSOLE=m
+CONFIG_NETCONSOLE_DYNAMIC=y
+CONFIG_NETPOLL=y
+CONFIG_NETPOLL_TRAP=y
+CONFIG_NET_POLL_CONTROLLER=y
+CONFIG_VIRTIO_NET=m
+# CONFIG_ISDN is not set
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+CONFIG_INPUT_FF_MEMLESS=y
+CONFIG_INPUT_POLLDEV=m
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+CONFIG_INPUT_JOYDEV=m
+CONFIG_INPUT_EVDEV=y
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+CONFIG_INPUT_KEYBOARD=y
+CONFIG_KEYBOARD_ATKBD=y
+# CONFIG_KEYBOARD_SUNKBD is not set
+# CONFIG_KEYBOARD_LKKBD is not set
+# CONFIG_KEYBOARD_XTKBD is not set
+# CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_STOWAWAY is not set
+# CONFIG_KEYBOARD_GPIO is not set
+CONFIG_INPUT_MOUSE=y
+CONFIG_MOUSE_PS2=y
+CONFIG_MOUSE_PS2_ALPS=y
+CONFIG_MOUSE_PS2_LOGIPS2PP=y
+CONFIG_MOUSE_PS2_SYNAPTICS=y
+CONFIG_MOUSE_PS2_LIFEBOOK=y
+CONFIG_MOUSE_PS2_TRACKPOINT=y
+# CONFIG_MOUSE_PS2_TOUCHKIT is not set
+CONFIG_MOUSE_SERIAL=m
+CONFIG_MOUSE_APPLETOUCH=m
+# CONFIG_MOUSE_INPORT is not set
+# CONFIG_MOUSE_LOGIBM is not set
+# CONFIG_MOUSE_PC110PAD is not set
+CONFIG_MOUSE_VSXXXAA=m
+# CONFIG_MOUSE_GPIO is not set
+CONFIG_INPUT_JOYSTICK=y
+CONFIG_JOYSTICK_ANALOG=m
+CONFIG_JOYSTICK_A3D=m
+CONFIG_JOYSTICK_ADI=m
+CONFIG_JOYSTICK_COBRA=m
+CONFIG_JOYSTICK_GF2K=m
+CONFIG_JOYSTICK_GRIP=m
+CONFIG_JOYSTICK_GRIP_MP=m
+CONFIG_JOYSTICK_GUILLEMOT=m
+CONFIG_JOYSTICK_INTERACT=m
+CONFIG_JOYSTICK_SIDEWINDER=m
+CONFIG_JOYSTICK_TMDC=m
+CONFIG_JOYSTICK_IFORCE=m
+CONFIG_JOYSTICK_IFORCE_USB=y
+CONFIG_JOYSTICK_IFORCE_232=y
+CONFIG_JOYSTICK_WARRIOR=m
+CONFIG_JOYSTICK_MAGELLAN=m
+CONFIG_JOYSTICK_SPACEORB=m
+CONFIG_JOYSTICK_SPACEBALL=m
+CONFIG_JOYSTICK_STINGER=m
+CONFIG_JOYSTICK_TWIDJOY=m
+CONFIG_JOYSTICK_ZHENHUA=m
+CONFIG_JOYSTICK_DB9=m
+CONFIG_JOYSTICK_GAMECON=m
+CONFIG_JOYSTICK_TURBOGRAFX=m
+CONFIG_JOYSTICK_JOYDUMP=m
+CONFIG_JOYSTICK_XPAD=m
+CONFIG_JOYSTICK_XPAD_FF=y
+CONFIG_JOYSTICK_XPAD_LEDS=y
+CONFIG_INPUT_TABLET=y
+CONFIG_TABLET_USB_ACECAD=m
+CONFIG_TABLET_USB_AIPTEK=m
+CONFIG_TABLET_USB_GTCO=m
+CONFIG_TABLET_USB_KBTAB=m
+CONFIG_TABLET_USB_WACOM=m
+# CONFIG_INPUT_TOUCHSCREEN is not set
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_PCSPKR=m
+CONFIG_INPUT_ATI_REMOTE=m
+CONFIG_INPUT_ATI_REMOTE2=m
+CONFIG_INPUT_KEYSPAN_REMOTE=m
+CONFIG_INPUT_POWERMATE=m
+CONFIG_INPUT_YEALINK=m
+CONFIG_INPUT_UINPUT=m
+
+#
+# Hardware I/O ports
+#
+CONFIG_SERIO=y
+CONFIG_SERIO_I8042=y
+CONFIG_SERIO_SERPORT=y
+# CONFIG_SERIO_PARKBD is not set
+# CONFIG_SERIO_PCIPS2 is not set
+CONFIG_SERIO_LIBPS2=y
+CONFIG_SERIO_RAW=m
+CONFIG_GAMEPORT=m
+CONFIG_GAMEPORT_NS558=m
+CONFIG_GAMEPORT_L4=m
+CONFIG_GAMEPORT_EMU10K1=m
+CONFIG_GAMEPORT_FM801=m
+CONFIG_INPUT_LIRC=y
+CONFIG_LIRC_DEV=m
+CONFIG_LIRC_ATIUSB=m
+CONFIG_LIRC_BT829=m
+CONFIG_LIRC_CMDIR=m
+CONFIG_LIRC_I2C=m
+CONFIG_LIRC_IGORPLUGUSB=m
+CONFIG_LIRC_IMON=m
+CONFIG_LIRC_IT87=m
+CONFIG_LIRC_MCEUSB=m
+CONFIG_LIRC_MCEUSB2=m
+CONFIG_LIRC_PVR150=m
+CONFIG_LIRC_PARALLEL=m
+CONFIG_LIRC_SERIAL=m
+CONFIG_LIRC_SIR=m
+CONFIG_LIRC_STREAMZAP=m
+CONFIG_LIRC_TTUSBIR=m
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+CONFIG_VT_HW_CONSOLE_BINDING=y
+# CONFIG_DEVKMEM is not set
+CONFIG_SERIAL_NONSTANDARD=y
+# CONFIG_COMPUTONE is not set
+CONFIG_ROCKETPORT=m
+CONFIG_CYCLADES=m
+# CONFIG_CYZ_INTR is not set
+# CONFIG_DIGIEPCA is not set
+# CONFIG_ESPSERIAL is not set
+# CONFIG_MOXA_INTELLIO is not set
+# CONFIG_MOXA_SMARTIO is not set
+# CONFIG_ISI is not set
+CONFIG_SYNCLINK=m
+CONFIG_SYNCLINKMP=m
+CONFIG_SYNCLINK_GT=m
+CONFIG_N_HDLC=m
+# CONFIG_RISCOM8 is not set
+# CONFIG_SPECIALIX is not set
+# CONFIG_SX is not set
+# CONFIG_RIO is not set
+# CONFIG_STALDRV is not set
+CONFIG_NOZOMI=m
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_PCI=y
+CONFIG_SERIAL_8250_PNP=y
+CONFIG_SERIAL_8250_CS=m
+CONFIG_SERIAL_8250_NR_UARTS=32
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_MANY_PORTS=y
+# CONFIG_SERIAL_8250_FOURPORT is not set
+# CONFIG_SERIAL_8250_ACCENT is not set
+# CONFIG_SERIAL_8250_BOCA is not set
+# CONFIG_SERIAL_8250_EXAR_ST16C554 is not set
+# CONFIG_SERIAL_8250_HUB6 is not set
+CONFIG_SERIAL_8250_SHARE_IRQ=y
+CONFIG_SERIAL_8250_DETECT_IRQ=y
+CONFIG_SERIAL_8250_RSA=y
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_UARTLITE=m
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_SERIAL_PMACZILOG=m
+# CONFIG_SERIAL_PMACZILOG_TTYS is not set
+# CONFIG_SERIAL_CPM is not set
+CONFIG_SERIAL_MPC52xx=y
+CONFIG_SERIAL_MPC52xx_CONSOLE=y
+CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD=115200
+CONFIG_SERIAL_JSM=m
+CONFIG_SERIAL_OF_PLATFORM=y
+# CONFIG_SERIAL_QE is not set
+CONFIG_UNIX98_PTYS=y
+# CONFIG_LEGACY_PTYS is not set
+# CONFIG_CRASH is not set
+CONFIG_BRIQ_PANEL=m
+CONFIG_PRINTER=m
+CONFIG_LP_CONSOLE=y
+CONFIG_PPDEV=m
+# CONFIG_HVC_RTAS is not set
+# CONFIG_IPMI_HANDLER is not set
+CONFIG_HW_RANDOM=y
+CONFIG_HW_RANDOM_VIRTIO=m
+CONFIG_NVRAM=y
+CONFIG_DTLK=m
+CONFIG_R3964=m
+# CONFIG_APPLICOM is not set
+
+#
+# PCMCIA character devices
+#
+# CONFIG_SYNCLINK_CS is not set
+CONFIG_CARDMAN_4000=m
+CONFIG_CARDMAN_4040=m
+CONFIG_IPWIRELESS=m
+# CONFIG_RAW_DRIVER is not set
+# CONFIG_TCG_TPM is not set
+CONFIG_DEVPORT=y
+CONFIG_I2C=y
+CONFIG_I2C_BOARDINFO=y
+CONFIG_I2C_CHARDEV=m
+CONFIG_I2C_ALGOBIT=y
+CONFIG_I2C_ALGOPCA=m
+
+#
+# I2C Hardware Bus support
+#
+
+#
+# PC SMBus host controller drivers
+#
+# CONFIG_I2C_ALI1535 is not set
+# CONFIG_I2C_ALI1563 is not set
+# CONFIG_I2C_ALI15X3 is not set
+# CONFIG_I2C_AMD756 is not set
+# CONFIG_I2C_AMD8111 is not set
+# CONFIG_I2C_I801 is not set
+# CONFIG_I2C_ISCH is not set
+# CONFIG_I2C_PIIX4 is not set
+# CONFIG_I2C_NFORCE2 is not set
+# CONFIG_I2C_SIS5595 is not set
+# CONFIG_I2C_SIS630 is not set
+# CONFIG_I2C_SIS96X is not set
+# CONFIG_I2C_VIA is not set
+# CONFIG_I2C_VIAPRO is not set
+
+#
+# Mac SMBus host controller drivers
+#
+CONFIG_I2C_HYDRA=m
+CONFIG_I2C_POWERMAC=y
+
+#
+# I2C system bus drivers (mostly embedded / system-on-chip)
+#
+# CONFIG_I2C_CPM is not set
+# CONFIG_I2C_GPIO is not set
+CONFIG_I2C_MPC=m
+# CONFIG_I2C_OCORES is not set
+CONFIG_I2C_SIMTEC=m
+
+#
+# External I2C/SMBus adapter drivers
+#
+CONFIG_I2C_PARPORT=m
+CONFIG_I2C_PARPORT_LIGHT=m
+# CONFIG_I2C_TAOS_EVM is not set
+CONFIG_I2C_TINY_USB=m
+
+#
+# Graphics adapter I2C/DDC channel drivers
+#
+CONFIG_I2C_VOODOO3=m
+
+#
+# Other I2C/SMBus bus drivers
+#
+# CONFIG_I2C_ELEKTOR is not set
+CONFIG_I2C_PCA_ISA=m
+CONFIG_I2C_PCA_PLATFORM=m
+CONFIG_I2C_STUB=m
+
+#
+# Miscellaneous I2C Chip support
+#
+# CONFIG_DS1682 is not set
+CONFIG_AT24=m
+CONFIG_SENSORS_EEPROM=m
+CONFIG_SENSORS_PCF8574=m
+CONFIG_PCF8575=m
+CONFIG_SENSORS_PCA9539=m
+CONFIG_SENSORS_PCF8591=m
+# CONFIG_TPS65010 is not set
+CONFIG_SENSORS_MAX6875=m
+CONFIG_SENSORS_TSL2550=m
+# CONFIG_I2C_DEBUG_CORE is not set
+# CONFIG_I2C_DEBUG_ALGO is not set
+# CONFIG_I2C_DEBUG_BUS is not set
+# CONFIG_I2C_DEBUG_CHIP is not set
+# CONFIG_SPI is not set
+CONFIG_HAVE_GPIO_LIB=y
+
+#
+# GPIO Support
+#
+# CONFIG_DEBUG_GPIO is not set
+
+#
+# I2C GPIO expanders:
+#
+# CONFIG_GPIO_PCA953X is not set
+# CONFIG_GPIO_PCF857X is not set
+
+#
+# SPI GPIO expanders:
+#
+CONFIG_W1=m
+CONFIG_W1_CON=y
+
+#
+# 1-wire Bus Masters
+#
+# CONFIG_W1_MASTER_MATROX is not set
+CONFIG_W1_MASTER_DS2490=m
+CONFIG_W1_MASTER_DS2482=m
+# CONFIG_W1_MASTER_GPIO is not set
+
+#
+# 1-wire Slaves
+#
+CONFIG_W1_SLAVE_THERM=m
+CONFIG_W1_SLAVE_SMEM=m
+CONFIG_W1_SLAVE_DS2433=m
+CONFIG_W1_SLAVE_DS2433_CRC=y
+CONFIG_W1_SLAVE_DS2760=m
+CONFIG_POWER_SUPPLY=m
+# CONFIG_POWER_SUPPLY_DEBUG is not set
+# CONFIG_PDA_POWER is not set
+CONFIG_APM_POWER=m
+# CONFIG_BATTERY_DS2760 is not set
+CONFIG_BATTERY_PMU=m
+CONFIG_HWMON=m
+CONFIG_HWMON_VID=m
+CONFIG_SENSORS_AD7418=m
+CONFIG_SENSORS_ADM1021=m
+CONFIG_SENSORS_ADM1025=m
+CONFIG_SENSORS_ADM1026=m
+CONFIG_SENSORS_ADM1029=m
+CONFIG_SENSORS_ADM1031=m
+CONFIG_SENSORS_ADM9240=m
+CONFIG_SENSORS_ADT7470=m
+CONFIG_SENSORS_ADT7473=m
+CONFIG_SENSORS_AMS=m
+CONFIG_SENSORS_AMS_PMU=y
+CONFIG_SENSORS_AMS_I2C=y
+CONFIG_SENSORS_ATXP1=m
+CONFIG_SENSORS_DS1621=m
+# CONFIG_SENSORS_I5K_AMB is not set
+CONFIG_SENSORS_F71805F=m
+CONFIG_SENSORS_F71882FG=m
+CONFIG_SENSORS_F75375S=m
+CONFIG_SENSORS_GL518SM=m
+CONFIG_SENSORS_GL520SM=m
+CONFIG_SENSORS_IT87=m
+CONFIG_SENSORS_LM63=m
+CONFIG_SENSORS_LM75=m
+CONFIG_SENSORS_LM77=m
+CONFIG_SENSORS_LM78=m
+CONFIG_SENSORS_LM80=m
+CONFIG_SENSORS_LM83=m
+CONFIG_SENSORS_LM85=m
+CONFIG_SENSORS_LM87=m
+CONFIG_SENSORS_LM90=m
+CONFIG_SENSORS_LM92=m
+CONFIG_SENSORS_LM93=m
+CONFIG_SENSORS_MAX1619=m
+CONFIG_SENSORS_MAX6650=m
+CONFIG_SENSORS_PC87360=m
+CONFIG_SENSORS_PC87427=m
+CONFIG_SENSORS_SIS5595=m
+CONFIG_SENSORS_DME1737=m
+CONFIG_SENSORS_SMSC47M1=m
+CONFIG_SENSORS_SMSC47M192=m
+CONFIG_SENSORS_SMSC47B397=m
+CONFIG_SENSORS_ADS7828=m
+CONFIG_SENSORS_THMC50=m
+CONFIG_SENSORS_VIA686A=m
+CONFIG_SENSORS_VT1211=m
+CONFIG_SENSORS_VT8231=m
+CONFIG_SENSORS_W83781D=m
+CONFIG_SENSORS_W83791D=m
+CONFIG_SENSORS_W83792D=m
+CONFIG_SENSORS_W83793=m
+CONFIG_SENSORS_W83L785TS=m
+CONFIG_SENSORS_W83L786NG=m
+CONFIG_SENSORS_W83627HF=m
+CONFIG_SENSORS_W83627EHF=m
+# CONFIG_HWMON_DEBUG_CHIP is not set
+CONFIG_THERMAL=y
+CONFIG_WATCHDOG=y
+# CONFIG_WATCHDOG_NOWAYOUT is not set
+
+#
+# Watchdog Device Drivers
+#
+CONFIG_SOFT_WATCHDOG=m
+# CONFIG_MPC5200_WDT is not set
+CONFIG_83xx_WDT=m
+CONFIG_WATCHDOG_RTAS=m
+
+#
+# ISA-based Watchdog Cards
+#
+# CONFIG_PCWATCHDOG is not set
+# CONFIG_MIXCOMWD is not set
+# CONFIG_WDT is not set
+
+#
+# PCI-based Watchdog Cards
+#
+# CONFIG_PCIPCWATCHDOG is not set
+# CONFIG_WDTPCI is not set
+
+#
+# USB-based Watchdog Cards
+#
+CONFIG_USBPCWATCHDOG=m
+
+#
+# Sonics Silicon Backplane
+#
+CONFIG_SSB_POSSIBLE=y
+CONFIG_SSB=m
+CONFIG_SSB_SPROM=y
+CONFIG_SSB_PCIHOST_POSSIBLE=y
+CONFIG_SSB_PCIHOST=y
+# CONFIG_SSB_B43_PCI_BRIDGE is not set
+CONFIG_SSB_PCMCIAHOST_POSSIBLE=y
+CONFIG_SSB_PCMCIAHOST=y
+# CONFIG_SSB_DEBUG is not set
+CONFIG_SSB_DRIVER_PCICORE_POSSIBLE=y
+CONFIG_SSB_DRIVER_PCICORE=y
+
+#
+# Multifunction device drivers
+#
+CONFIG_MFD_SM501=m
+# CONFIG_HTC_PASIC3 is not set
+
+#
+# Multimedia devices
+#
+
+#
+# Multimedia core support
+#
+CONFIG_VIDEO_DEV=m
+CONFIG_VIDEO_V4L2_COMMON=m
+CONFIG_VIDEO_ALLOW_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_DVB_CORE=m
+CONFIG_VIDEO_MEDIA=m
+
+#
+# Multimedia drivers
+#
+CONFIG_VIDEO_SAA7146=m
+CONFIG_VIDEO_SAA7146_VV=m
+CONFIG_MEDIA_ATTACH=y
+CONFIG_MEDIA_TUNER=m
+# CONFIG_MEDIA_TUNER_CUSTOMIZE is not set
+CONFIG_MEDIA_TUNER_SIMPLE=m
+CONFIG_MEDIA_TUNER_TDA8290=m
+CONFIG_MEDIA_TUNER_TDA827X=m
+CONFIG_MEDIA_TUNER_TDA18271=m
+CONFIG_MEDIA_TUNER_TDA9887=m
+CONFIG_MEDIA_TUNER_TEA5761=m
+CONFIG_MEDIA_TUNER_TEA5767=m
+CONFIG_MEDIA_TUNER_MT20XX=m
+CONFIG_MEDIA_TUNER_MT2060=m
+CONFIG_MEDIA_TUNER_MT2266=m
+CONFIG_MEDIA_TUNER_MT2131=m
+CONFIG_MEDIA_TUNER_QT1010=m
+CONFIG_MEDIA_TUNER_XC2028=m
+CONFIG_MEDIA_TUNER_XC5000=m
+CONFIG_MEDIA_TUNER_MXL5005S=m
+CONFIG_VIDEO_V4L2=m
+CONFIG_VIDEO_V4L1=m
+CONFIG_VIDEOBUF_GEN=m
+CONFIG_VIDEOBUF_DMA_SG=m
+CONFIG_VIDEOBUF_VMALLOC=m
+CONFIG_VIDEOBUF_DVB=m
+CONFIG_VIDEO_BTCX=m
+CONFIG_VIDEO_IR_I2C=m
+CONFIG_VIDEO_IR=m
+CONFIG_VIDEO_TVEEPROM=m
+CONFIG_VIDEO_TUNER=m
+CONFIG_VIDEO_CAPTURE_DRIVERS=y
+# CONFIG_VIDEO_ADV_DEBUG is not set
+# CONFIG_VIDEO_HELPER_CHIPS_AUTO is not set
+
+#
+# Encoders/decoders and other helper chips
+#
+
+#
+# Audio decoders
+#
+CONFIG_VIDEO_TVAUDIO=m
+CONFIG_VIDEO_TDA7432=m
+CONFIG_VIDEO_TDA9840=m
+CONFIG_VIDEO_TDA9875=m
+CONFIG_VIDEO_TEA6415C=m
+CONFIG_VIDEO_TEA6420=m
+CONFIG_VIDEO_MSP3400=m
+CONFIG_VIDEO_CS5345=m
+CONFIG_VIDEO_CS53L32A=m
+CONFIG_VIDEO_M52790=m
+CONFIG_VIDEO_TLV320AIC23B=m
+CONFIG_VIDEO_WM8775=m
+CONFIG_VIDEO_WM8739=m
+CONFIG_VIDEO_VP27SMPX=m
+
+#
+# Video decoders
+#
+CONFIG_VIDEO_BT819=m
+CONFIG_VIDEO_BT856=m
+CONFIG_VIDEO_BT866=m
+CONFIG_VIDEO_KS0127=m
+CONFIG_VIDEO_OV7670=m
+CONFIG_VIDEO_TCM825X=m
+CONFIG_VIDEO_SAA7110=m
+CONFIG_VIDEO_SAA7111=m
+CONFIG_VIDEO_SAA7114=m
+CONFIG_VIDEO_SAA711X=m
+CONFIG_VIDEO_SAA717X=m
+CONFIG_VIDEO_SAA7191=m
+CONFIG_VIDEO_TVP5150=m
+CONFIG_VIDEO_VPX3220=m
+
+#
+# Video and audio decoders
+#
+CONFIG_VIDEO_CX25840=m
+
+#
+# MPEG video encoders
+#
+CONFIG_VIDEO_CX2341X=m
+
+#
+# Video encoders
+#
+CONFIG_VIDEO_SAA7127=m
+CONFIG_VIDEO_SAA7185=m
+CONFIG_VIDEO_ADV7170=m
+CONFIG_VIDEO_ADV7175=m
+
+#
+# Video improvement chips
+#
+CONFIG_VIDEO_UPD64031A=m
+CONFIG_VIDEO_UPD64083=m
+# CONFIG_VIDEO_VIVI is not set
+CONFIG_VIDEO_BT848=m
+CONFIG_VIDEO_BT848_DVB=y
+CONFIG_VIDEO_SAA6588=m
+# CONFIG_VIDEO_PMS is not set
+CONFIG_VIDEO_BWQCAM=m
+CONFIG_VIDEO_CQCAM=m
+CONFIG_VIDEO_W9966=m
+CONFIG_VIDEO_CPIA=m
+CONFIG_VIDEO_CPIA_PP=m
+CONFIG_VIDEO_CPIA_USB=m
+CONFIG_VIDEO_CPIA2=m
+CONFIG_VIDEO_SAA5246A=m
+CONFIG_VIDEO_SAA5249=m
+CONFIG_TUNER_3036=m
+# CONFIG_VIDEO_STRADIS is not set
+# CONFIG_VIDEO_ZORAN is not set
+CONFIG_VIDEO_SAA7134=m
+CONFIG_VIDEO_SAA7134_ALSA=m
+CONFIG_VIDEO_SAA7134_DVB=m
+CONFIG_VIDEO_MXB=m
+CONFIG_VIDEO_DPC=m
+CONFIG_VIDEO_HEXIUM_ORION=m
+CONFIG_VIDEO_HEXIUM_GEMINI=m
+CONFIG_VIDEO_CX88=m
+CONFIG_VIDEO_CX88_ALSA=m
+CONFIG_VIDEO_CX88_BLACKBIRD=m
+CONFIG_VIDEO_CX88_DVB=m
+CONFIG_VIDEO_CX88_VP3054=m
+CONFIG_VIDEO_CX23885=m
+CONFIG_VIDEO_AU0828=m
+CONFIG_VIDEO_IVTV=m
+CONFIG_VIDEO_FB_IVTV=m
+CONFIG_VIDEO_CX18=m
+# CONFIG_VIDEO_CAFE_CCIC is not set
+CONFIG_V4L_USB_DRIVERS=y
+CONFIG_USB_VIDEO_CLASS=m
+CONFIG_VIDEO_PVRUSB2=m
+CONFIG_VIDEO_PVRUSB2_SYSFS=y
+CONFIG_VIDEO_PVRUSB2_DVB=y
+# CONFIG_VIDEO_PVRUSB2_DEBUGIFC is not set
+CONFIG_VIDEO_EM28XX=m
+CONFIG_VIDEO_EM28XX_ALSA=m
+CONFIG_VIDEO_EM28XX_DVB=m
+CONFIG_VIDEO_USBVISION=m
+CONFIG_VIDEO_USBVIDEO=m
+CONFIG_USB_VICAM=m
+CONFIG_USB_IBMCAM=m
+CONFIG_USB_KONICAWC=m
+CONFIG_USB_QUICKCAM_MESSENGER=m
+CONFIG_USB_ET61X251=m
+CONFIG_VIDEO_OVCAMCHIP=m
+CONFIG_USB_W9968CF=m
+CONFIG_USB_OV511=m
+CONFIG_USB_SE401=m
+CONFIG_USB_SN9C102=m
+CONFIG_USB_STV680=m
+CONFIG_USB_ZC0301=m
+CONFIG_USB_PWC=m
+# CONFIG_USB_PWC_DEBUG is not set
+CONFIG_USB_ZR364XX=m
+CONFIG_USB_STKWEBCAM=m
+CONFIG_SOC_CAMERA=m
+CONFIG_SOC_CAMERA_MT9M001=m
+# CONFIG_MT9M001_PCA9536_SWITCH is not set
+CONFIG_SOC_CAMERA_MT9V022=m
+# CONFIG_MT9V022_PCA9536_SWITCH is not set
+CONFIG_RADIO_ADAPTERS=y
+# CONFIG_RADIO_CADET is not set
+# CONFIG_RADIO_RTRACK is not set
+# CONFIG_RADIO_RTRACK2 is not set
+# CONFIG_RADIO_AZTECH is not set
+# CONFIG_RADIO_GEMTEK is not set
+CONFIG_RADIO_GEMTEK_PCI=m
+CONFIG_RADIO_MAXIRADIO=m
+CONFIG_RADIO_MAESTRO=m
+# CONFIG_RADIO_SF16FMI is not set
+# CONFIG_RADIO_SF16FMR2 is not set
+# CONFIG_RADIO_TERRATEC is not set
+# CONFIG_RADIO_TRUST is not set
+# CONFIG_RADIO_TYPHOON is not set
+# CONFIG_RADIO_ZOLTRIX is not set
+CONFIG_USB_DSBR=m
+CONFIG_USB_SI470X=m
+CONFIG_DVB_CAPTURE_DRIVERS=y
+
+#
+# Supported SAA7146 based PCI Adapters
+#
+CONFIG_TTPCI_EEPROM=m
+CONFIG_DVB_AV7110=m
+CONFIG_DVB_AV7110_OSD=y
+CONFIG_DVB_BUDGET_CORE=m
+CONFIG_DVB_BUDGET=m
+CONFIG_DVB_BUDGET_CI=m
+CONFIG_DVB_BUDGET_AV=m
+CONFIG_DVB_BUDGET_PATCH=m
+
+#
+# Supported USB Adapters
+#
+CONFIG_DVB_USB=m
+# CONFIG_DVB_USB_DEBUG is not set
+CONFIG_DVB_USB_A800=m
+CONFIG_DVB_USB_DIBUSB_MB=m
+# CONFIG_DVB_USB_DIBUSB_MB_FAULTY is not set
+CONFIG_DVB_USB_DIBUSB_MC=m
+CONFIG_DVB_USB_DIB0700=m
+CONFIG_DVB_USB_UMT_010=m
+CONFIG_DVB_USB_CXUSB=m
+CONFIG_DVB_USB_M920X=m
+CONFIG_DVB_USB_GL861=m
+CONFIG_DVB_USB_AU6610=m
+CONFIG_DVB_USB_DIGITV=m
+CONFIG_DVB_USB_VP7045=m
+CONFIG_DVB_USB_VP702X=m
+CONFIG_DVB_USB_GP8PSK=m
+CONFIG_DVB_USB_NOVA_T_USB2=m
+CONFIG_DVB_USB_TTUSB2=m
+CONFIG_DVB_USB_DTT200U=m
+CONFIG_DVB_USB_OPERA1=m
+CONFIG_DVB_USB_AF9005=m
+CONFIG_DVB_USB_AF9005_REMOTE=m
+CONFIG_DVB_TTUSB_BUDGET=m
+CONFIG_DVB_TTUSB_DEC=m
+CONFIG_DVB_CINERGYT2=m
+CONFIG_DVB_CINERGYT2_TUNING=y
+CONFIG_DVB_CINERGYT2_STREAM_URB_COUNT=32
+CONFIG_DVB_CINERGYT2_STREAM_BUF_SIZE=512
+CONFIG_DVB_CINERGYT2_QUERY_INTERVAL=250
+CONFIG_DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE=y
+CONFIG_DVB_CINERGYT2_RC_QUERY_INTERVAL=100
+
+#
+# Supported FlexCopII (B2C2) Adapters
+#
+CONFIG_DVB_B2C2_FLEXCOP=m
+CONFIG_DVB_B2C2_FLEXCOP_PCI=m
+CONFIG_DVB_B2C2_FLEXCOP_USB=m
+# CONFIG_DVB_B2C2_FLEXCOP_DEBUG is not set
+
+#
+# Supported BT878 Adapters
+#
+CONFIG_DVB_BT8XX=m
+
+#
+# Supported Pluto2 Adapters
+#
+CONFIG_DVB_PLUTO2=m
+
+#
+# Supported DVB Frontends
+#
+
+#
+# Customise DVB Frontends
+#
+# CONFIG_DVB_FE_CUSTOMISE is not set
+
+#
+# DVB-S (satellite) frontends
+#
+CONFIG_DVB_CX24110=m
+CONFIG_DVB_CX24123=m
+CONFIG_DVB_MT312=m
+CONFIG_DVB_S5H1420=m
+CONFIG_DVB_STV0299=m
+CONFIG_DVB_TDA8083=m
+CONFIG_DVB_TDA10086=m
+CONFIG_DVB_VES1X93=m
+CONFIG_DVB_TUNER_ITD1000=m
+CONFIG_DVB_TDA826X=m
+CONFIG_DVB_TUA6100=m
+
+#
+# DVB-T (terrestrial) frontends
+#
+CONFIG_DVB_SP8870=m
+CONFIG_DVB_SP887X=m
+CONFIG_DVB_CX22700=m
+CONFIG_DVB_CX22702=m
+CONFIG_DVB_L64781=m
+CONFIG_DVB_TDA1004X=m
+CONFIG_DVB_NXT6000=m
+CONFIG_DVB_MT352=m
+CONFIG_DVB_ZL10353=m
+CONFIG_DVB_DIB3000MB=m
+CONFIG_DVB_DIB3000MC=m
+CONFIG_DVB_DIB7000M=m
+CONFIG_DVB_DIB7000P=m
+CONFIG_DVB_TDA10048=m
+
+#
+# DVB-C (cable) frontends
+#
+CONFIG_DVB_VES1820=m
+CONFIG_DVB_TDA10021=m
+CONFIG_DVB_TDA10023=m
+CONFIG_DVB_STV0297=m
+
+#
+# ATSC (North American/Korean Terrestrial/Cable DTV) frontends
+#
+CONFIG_DVB_NXT200X=m
+CONFIG_DVB_OR51211=m
+CONFIG_DVB_OR51132=m
+CONFIG_DVB_BCM3510=m
+CONFIG_DVB_LGDT330X=m
+CONFIG_DVB_S5H1409=m
+CONFIG_DVB_AU8522=m
+CONFIG_DVB_S5H1411=m
+
+#
+# Digital terrestrial only tuners/PLL
+#
+CONFIG_DVB_PLL=m
+CONFIG_DVB_TUNER_DIB0070=m
+
+#
+# SEC control devices for DVB-S
+#
+CONFIG_DVB_LNBP21=m
+CONFIG_DVB_ISL6405=m
+CONFIG_DVB_ISL6421=m
+CONFIG_DAB=y
+CONFIG_USB_DABUSB=m
+
+#
+# Graphics support
+#
+CONFIG_AGP=y
+CONFIG_AGP_UNINORTH=y
+CONFIG_DRM=m
+CONFIG_DRM_TDFX=m
+CONFIG_DRM_R128=m
+CONFIG_DRM_RADEON=m
+CONFIG_DRM_MGA=m
+CONFIG_DRM_SIS=m
+CONFIG_DRM_VIA=m
+CONFIG_DRM_SAVAGE=m
+CONFIG_VGASTATE=y
+CONFIG_VIDEO_OUTPUT_CONTROL=m
+CONFIG_FB=y
+# CONFIG_FIRMWARE_EDID is not set
+CONFIG_FB_DDC=y
+CONFIG_FB_CFB_FILLRECT=y
+CONFIG_FB_CFB_COPYAREA=y
+CONFIG_FB_CFB_IMAGEBLIT=y
+# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
+# CONFIG_FB_SYS_FILLRECT is not set
+# CONFIG_FB_SYS_COPYAREA is not set
+# CONFIG_FB_SYS_IMAGEBLIT is not set
+# CONFIG_FB_FOREIGN_ENDIAN is not set
+# CONFIG_FB_SYS_FOPS is not set
+CONFIG_FB_SVGALIB=m
+CONFIG_FB_MACMODES=y
+CONFIG_FB_BACKLIGHT=y
+CONFIG_FB_MODE_HELPERS=y
+CONFIG_FB_TILEBLITTING=y
+
+#
+# Frame buffer hardware drivers
+#
+CONFIG_FB_CIRRUS=m
+# CONFIG_FB_PM2 is not set
+# CONFIG_FB_CYBER2000 is not set
+CONFIG_FB_OF=y
+# CONFIG_FB_CONTROL is not set
+CONFIG_FB_PLATINUM=y
+CONFIG_FB_VALKYRIE=y
+CONFIG_FB_CT65550=y
+# CONFIG_FB_ASILIANT is not set
+# CONFIG_FB_IMSTT is not set
+# CONFIG_FB_VGA16 is not set
+# CONFIG_FB_UVESA is not set
+# CONFIG_FB_S1D13XXX is not set
+CONFIG_FB_NVIDIA=y
+CONFIG_FB_NVIDIA_I2C=y
+# CONFIG_FB_NVIDIA_DEBUG is not set
+CONFIG_FB_NVIDIA_BACKLIGHT=y
+CONFIG_FB_RIVA=m
+# CONFIG_FB_RIVA_I2C is not set
+# CONFIG_FB_RIVA_DEBUG is not set
+CONFIG_FB_RIVA_BACKLIGHT=y
+CONFIG_FB_MATROX=y
+CONFIG_FB_MATROX_MILLENIUM=y
+CONFIG_FB_MATROX_MYSTIQUE=y
+CONFIG_FB_MATROX_G=y
+CONFIG_FB_MATROX_I2C=m
+CONFIG_FB_MATROX_MAVEN=m
+CONFIG_FB_MATROX_MULTIHEAD=y
+CONFIG_FB_RADEON=y
+CONFIG_FB_RADEON_I2C=y
+CONFIG_FB_RADEON_BACKLIGHT=y
+# CONFIG_FB_RADEON_DEBUG is not set
+CONFIG_FB_ATY128=y
+CONFIG_FB_ATY128_BACKLIGHT=y
+CONFIG_FB_ATY=y
+CONFIG_FB_ATY_CT=y
+CONFIG_FB_ATY_GENERIC_LCD=y
+CONFIG_FB_ATY_GX=y
+CONFIG_FB_ATY_BACKLIGHT=y
+CONFIG_FB_S3=m
+CONFIG_FB_SAVAGE=m
+CONFIG_FB_SAVAGE_I2C=y
+CONFIG_FB_SAVAGE_ACCEL=y
+# CONFIG_FB_SIS is not set
+CONFIG_FB_NEOMAGIC=m
+CONFIG_FB_KYRO=m
+CONFIG_FB_3DFX=m
+CONFIG_FB_3DFX_ACCEL=y
+CONFIG_FB_VOODOO1=m
+# CONFIG_FB_VT8623 is not set
+CONFIG_FB_TRIDENT=m
+CONFIG_FB_TRIDENT_ACCEL=y
+# CONFIG_FB_ARK is not set
+# CONFIG_FB_PM3 is not set
+# CONFIG_FB_FSL_DIU is not set
+CONFIG_FB_SM501=m
+CONFIG_FB_IBM_GXT4500=y
+# CONFIG_FB_VIRTUAL is not set
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_LCD_CLASS_DEVICE=m
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+# CONFIG_BACKLIGHT_CORGI is not set
+
+#
+# Display device support
+#
+CONFIG_DISPLAY_SUPPORT=m
+
+#
+# Display hardware drivers
+#
+
+#
+# Console display driver support
+#
+CONFIG_VGA_CONSOLE=y
+CONFIG_VGACON_SOFT_SCROLLBACK=y
+CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=64
+# CONFIG_MDA_CONSOLE is not set
+CONFIG_DUMMY_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE=y
+CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
+CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
+# CONFIG_FONTS is not set
+CONFIG_FONT_8x8=y
+CONFIG_FONT_8x16=y
+CONFIG_LOGO=y
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+CONFIG_LOGO_LINUX_CLUT224=y
+CONFIG_SOUND=m
+CONFIG_SND=m
+CONFIG_SND_TIMER=m
+CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
+CONFIG_SND_SEQUENCER=m
+CONFIG_SND_SEQ_DUMMY=m
+CONFIG_SND_OSSEMUL=y
+CONFIG_SND_MIXER_OSS=m
+CONFIG_SND_PCM_OSS=m
+CONFIG_SND_PCM_OSS_PLUGINS=y
+CONFIG_SND_SEQUENCER_OSS=y
+CONFIG_SND_DYNAMIC_MINORS=y
+# CONFIG_SND_SUPPORT_OLD_API is not set
+CONFIG_SND_VERBOSE_PROCFS=y
+CONFIG_SND_VERBOSE_PRINTK=y
+CONFIG_SND_DEBUG=y
+CONFIG_SND_DEBUG_VERBOSE=y
+CONFIG_SND_PCM_XRUN_DEBUG=y
+CONFIG_SND_VMASTER=y
+CONFIG_SND_MPU401_UART=m
+CONFIG_SND_OPL3_LIB=m
+CONFIG_SND_VX_LIB=m
+CONFIG_SND_AC97_CODEC=m
+CONFIG_SND_DRIVERS=y
+CONFIG_SND_DUMMY=m
+CONFIG_SND_VIRMIDI=m
+CONFIG_SND_MTPAV=m
+CONFIG_SND_MTS64=m
+CONFIG_SND_SERIAL_U16550=m
+CONFIG_SND_MPU401=m
+CONFIG_SND_PORTMAN2X4=m
+CONFIG_SND_AC97_POWER_SAVE=y
+CONFIG_SND_AC97_POWER_SAVE_DEFAULT=5
+CONFIG_SND_SB_COMMON=m
+CONFIG_SND_SB16_DSP=m
+CONFIG_SND_ISA=y
+# CONFIG_SND_ADLIB is not set
+# CONFIG_SND_AD1816A is not set
+# CONFIG_SND_AD1848 is not set
+# CONFIG_SND_ALS100 is not set
+# CONFIG_SND_AZT2320 is not set
+# CONFIG_SND_CMI8330 is not set
+# CONFIG_SND_CS4231 is not set
+# CONFIG_SND_CS4232 is not set
+# CONFIG_SND_CS4236 is not set
+# CONFIG_SND_DT019X is not set
+# CONFIG_SND_ES968 is not set
+# CONFIG_SND_ES1688 is not set
+# CONFIG_SND_ES18XX is not set
+# CONFIG_SND_SC6000 is not set
+# CONFIG_SND_GUSCLASSIC is not set
+# CONFIG_SND_GUSEXTREME is not set
+# CONFIG_SND_GUSMAX is not set
+# CONFIG_SND_INTERWAVE is not set
+# CONFIG_SND_INTERWAVE_STB is not set
+# CONFIG_SND_OPL3SA2 is not set
+# CONFIG_SND_OPTI92X_AD1848 is not set
+# CONFIG_SND_OPTI92X_CS4231 is not set
+# CONFIG_SND_OPTI93X is not set
+# CONFIG_SND_MIRO is not set
+# CONFIG_SND_SB8 is not set
+# CONFIG_SND_SB16 is not set
+# CONFIG_SND_SBAWE is not set
+# CONFIG_SND_SGALAXY is not set
+# CONFIG_SND_SSCAPE is not set
+# CONFIG_SND_WAVEFRONT is not set
+CONFIG_SND_PCI=y
+CONFIG_SND_AD1889=m
+CONFIG_SND_ALS300=m
+CONFIG_SND_ALS4000=m
+CONFIG_SND_ALI5451=m
+CONFIG_SND_ATIIXP=m
+CONFIG_SND_ATIIXP_MODEM=m
+CONFIG_SND_AU8810=m
+CONFIG_SND_AU8820=m
+CONFIG_SND_AU8830=m
+CONFIG_SND_AW2=m
+CONFIG_SND_AZT3328=m
+CONFIG_SND_BT87X=m
+# CONFIG_SND_BT87X_OVERCLOCK is not set
+CONFIG_SND_CA0106=m
+CONFIG_SND_CMIPCI=m
+CONFIG_SND_OXYGEN_LIB=m
+CONFIG_SND_OXYGEN=m
+CONFIG_SND_CS4281=m
+CONFIG_SND_CS46XX=m
+CONFIG_SND_CS46XX_NEW_DSP=y
+CONFIG_SND_CS5530=m
+CONFIG_SND_DARLA20=m
+CONFIG_SND_GINA20=m
+CONFIG_SND_LAYLA20=m
+CONFIG_SND_DARLA24=m
+CONFIG_SND_GINA24=m
+CONFIG_SND_LAYLA24=m
+CONFIG_SND_MONA=m
+CONFIG_SND_MIA=m
+CONFIG_SND_ECHO3G=m
+CONFIG_SND_INDIGO=m
+CONFIG_SND_INDIGOIO=m
+CONFIG_SND_INDIGODJ=m
+CONFIG_SND_EMU10K1=m
+CONFIG_SND_EMU10K1X=m
+CONFIG_SND_ENS1370=m
+CONFIG_SND_ENS1371=m
+CONFIG_SND_ES1938=m
+CONFIG_SND_ES1968=m
+CONFIG_SND_FM801=m
+CONFIG_SND_FM801_TEA575X_BOOL=y
+CONFIG_SND_FM801_TEA575X=m
+# CONFIG_SND_HDA_INTEL is not set
+CONFIG_SND_HDSP=m
+CONFIG_SND_HDSPM=m
+CONFIG_SND_HIFIER=m
+CONFIG_SND_ICE1712=m
+CONFIG_SND_ICE1724=m
+# CONFIG_SND_INTEL8X0 is not set
+# CONFIG_SND_INTEL8X0M is not set
+CONFIG_SND_KORG1212=m
+CONFIG_SND_MAESTRO3=m
+CONFIG_SND_MIXART=m
+CONFIG_SND_NM256=m
+CONFIG_SND_PCXHR=m
+CONFIG_SND_RIPTIDE=m
+CONFIG_SND_RME32=m
+CONFIG_SND_RME96=m
+CONFIG_SND_RME9652=m
+CONFIG_SND_SONICVIBES=m
+CONFIG_SND_TRIDENT=m
+CONFIG_SND_VIA82XX=m
+CONFIG_SND_VIA82XX_MODEM=m
+CONFIG_SND_VIRTUOSO=m
+CONFIG_SND_VX222=m
+# CONFIG_SND_YMFPCI is not set
+CONFIG_SND_PPC=y
+CONFIG_SND_POWERMAC=m
+CONFIG_SND_POWERMAC_AUTO_DRC=y
+CONFIG_SND_AOA=m
+CONFIG_SND_AOA_FABRIC_LAYOUT=m
+CONFIG_SND_AOA_ONYX=m
+CONFIG_SND_AOA_TAS=m
+CONFIG_SND_AOA_TOONIE=m
+CONFIG_SND_AOA_SOUNDBUS=m
+CONFIG_SND_AOA_SOUNDBUS_I2S=m
+CONFIG_SND_USB=y
+CONFIG_SND_USB_AUDIO=m
+CONFIG_SND_USB_USX2Y=m
+CONFIG_SND_USB_CAIAQ=m
+CONFIG_SND_USB_CAIAQ_INPUT=y
+# CONFIG_SND_PCMCIA is not set
+# CONFIG_SND_SOC is not set
+# CONFIG_SOUND_PRIME is not set
+CONFIG_AC97_BUS=m
+CONFIG_HID_SUPPORT=y
+CONFIG_HID=y
+CONFIG_HID_DEBUG=y
+CONFIG_HIDRAW=y
+
+#
+# USB Input Devices
+#
+CONFIG_USB_HID=y
+CONFIG_USB_HIDINPUT_POWERBOOK=y
+CONFIG_HID_FF=y
+CONFIG_HID_PID=y
+CONFIG_LOGITECH_FF=y
+CONFIG_LOGIRUMBLEPAD2_FF=y
+CONFIG_PANTHERLORD_FF=y
+CONFIG_THRUSTMASTER_FF=y
+CONFIG_ZEROPLUS_FF=y
+CONFIG_USB_HIDDEV=y
+CONFIG_USB_SUPPORT=y
+CONFIG_USB_ARCH_HAS_HCD=y
+CONFIG_USB_ARCH_HAS_OHCI=y
+CONFIG_USB_ARCH_HAS_EHCI=y
+CONFIG_USB=y
+CONFIG_USB_DEBUG=y
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_DEVICE_CLASS is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+CONFIG_USB_SUSPEND=y
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_C67X00_HCD is not set
+CONFIG_USB_EHCI_HCD=m
+CONFIG_USB_EHCI_ROOT_HUB_TT=y
+CONFIG_USB_EHCI_TT_NEWSCHED=y
+CONFIG_USB_EHCI_FSL=y
+CONFIG_USB_EHCI_HCD_PPC_OF=y
+# CONFIG_USB_ISP116X_HCD is not set
+# CONFIG_USB_ISP1760_HCD is not set
+CONFIG_USB_OHCI_HCD=m
+CONFIG_USB_OHCI_HCD_PPC_SOC=y
+CONFIG_USB_OHCI_HCD_PPC_OF=y
+CONFIG_USB_OHCI_HCD_PPC_OF_BE=y
+CONFIG_USB_OHCI_HCD_PPC_OF_LE=y
+CONFIG_USB_OHCI_HCD_PCI=y
+# CONFIG_USB_OHCI_HCD_SSB is not set
+CONFIG_USB_OHCI_BIG_ENDIAN_DESC=y
+CONFIG_USB_OHCI_BIG_ENDIAN_MMIO=y
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+CONFIG_USB_UHCI_HCD=m
+CONFIG_USB_U132_HCD=m
+CONFIG_USB_SL811_HCD=m
+# CONFIG_USB_SL811_CS is not set
+# CONFIG_USB_R8A66597_HCD is not set
+
+#
+# USB Device Class drivers
+#
+CONFIG_USB_ACM=m
+CONFIG_USB_PRINTER=m
+CONFIG_USB_WDM=m
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=m
+# CONFIG_USB_STORAGE_DEBUG is not set
+CONFIG_USB_STORAGE_DATAFAB=y
+CONFIG_USB_STORAGE_FREECOM=y
+# CONFIG_USB_STORAGE_ISD200 is not set
+CONFIG_USB_STORAGE_DPCM=y
+CONFIG_USB_STORAGE_USBAT=y
+CONFIG_USB_STORAGE_SDDR09=y
+CONFIG_USB_STORAGE_SDDR55=y
+CONFIG_USB_STORAGE_JUMPSHOT=y
+CONFIG_USB_STORAGE_ALAUDA=y
+CONFIG_USB_STORAGE_ONETOUCH=y
+CONFIG_USB_STORAGE_KARMA=y
+CONFIG_USB_STORAGE_CYPRESS_ATACB=y
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Imaging devices
+#
+CONFIG_USB_MDC800=m
+CONFIG_USB_MICROTEK=m
+CONFIG_USB_MON=y
+
+#
+# USB port drivers
+#
+CONFIG_USB_USS720=m
+CONFIG_USB_SERIAL=m
+CONFIG_USB_EZUSB=y
+CONFIG_USB_SERIAL_GENERIC=y
+CONFIG_USB_SERIAL_AIRCABLE=m
+CONFIG_USB_SERIAL_AIRPRIME=m
+CONFIG_USB_SERIAL_ARK3116=m
+CONFIG_USB_SERIAL_BELKIN=m
+CONFIG_USB_SERIAL_CH341=m
+CONFIG_USB_SERIAL_WHITEHEAT=m
+CONFIG_USB_SERIAL_DIGI_ACCELEPORT=m
+CONFIG_USB_SERIAL_CP2101=m
+CONFIG_USB_SERIAL_CYPRESS_M8=m
+CONFIG_USB_SERIAL_EMPEG=m
+CONFIG_USB_SERIAL_FTDI_SIO=m
+CONFIG_USB_SERIAL_FUNSOFT=m
+CONFIG_USB_SERIAL_VISOR=m
+CONFIG_USB_SERIAL_IPAQ=m
+CONFIG_USB_SERIAL_IR=m
+CONFIG_USB_SERIAL_EDGEPORT=m
+CONFIG_USB_SERIAL_EDGEPORT_TI=m
+# CONFIG_USB_SERIAL_GARMIN is not set
+CONFIG_USB_SERIAL_IPW=m
+CONFIG_USB_SERIAL_IUU=m
+CONFIG_USB_SERIAL_KEYSPAN_PDA=m
+CONFIG_USB_SERIAL_KEYSPAN=m
+CONFIG_USB_SERIAL_KLSI=m
+CONFIG_USB_SERIAL_KOBIL_SCT=m
+CONFIG_USB_SERIAL_MCT_U232=m
+CONFIG_USB_SERIAL_MOS7720=m
+CONFIG_USB_SERIAL_MOS7840=m
+CONFIG_USB_SERIAL_MOTOROLA=m
+CONFIG_USB_SERIAL_NAVMAN=m
+CONFIG_USB_SERIAL_PL2303=m
+CONFIG_USB_SERIAL_OTI6858=m
+CONFIG_USB_SERIAL_SPCP8X5=m
+CONFIG_USB_SERIAL_HP4X=m
+CONFIG_USB_SERIAL_SAFE=m
+CONFIG_USB_SERIAL_SAFE_PADDED=y
+CONFIG_USB_SERIAL_SIERRAWIRELESS=m
+CONFIG_USB_SERIAL_TI=m
+CONFIG_USB_SERIAL_CYBERJACK=m
+CONFIG_USB_SERIAL_XIRCOM=m
+CONFIG_USB_SERIAL_OPTION=m
+CONFIG_USB_SERIAL_OMNINET=m
+CONFIG_USB_SERIAL_DEBUG=m
+
+#
+# USB Miscellaneous drivers
+#
+CONFIG_USB_EMI62=m
+CONFIG_USB_EMI26=m
+CONFIG_USB_ADUTUX=m
+CONFIG_USB_AUERSWALD=m
+# CONFIG_USB_RIO500 is not set
+CONFIG_USB_LEGOTOWER=m
+CONFIG_USB_LCD=m
+CONFIG_USB_BERRY_CHARGE=m
+CONFIG_USB_LED=m
+# CONFIG_USB_CYPRESS_CY7C63 is not set
+# CONFIG_USB_CYTHERM is not set
+CONFIG_USB_PHIDGET=m
+CONFIG_USB_PHIDGETKIT=m
+CONFIG_USB_PHIDGETMOTORCONTROL=m
+CONFIG_USB_PHIDGETSERVO=m
+CONFIG_USB_IDMOUSE=m
+CONFIG_USB_FTDI_ELAN=m
+CONFIG_USB_APPLEDISPLAY=m
+CONFIG_USB_SISUSBVGA=m
+CONFIG_USB_SISUSBVGA_CON=y
+CONFIG_USB_LD=m
+CONFIG_USB_TRANCEVIBRATOR=m
+CONFIG_USB_IOWARRIOR=m
+# CONFIG_USB_TEST is not set
+CONFIG_USB_ISIGHTFW=m
+CONFIG_USB_ATM=m
+CONFIG_USB_SPEEDTOUCH=m
+CONFIG_USB_CXACRU=m
+CONFIG_USB_UEAGLEATM=m
+CONFIG_USB_XUSBATM=m
+# CONFIG_USB_GADGET is not set
+# CONFIG_MMC is not set
+# CONFIG_MEMSTICK is not set
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+
+#
+# LED drivers
+#
+# CONFIG_LEDS_GPIO is not set
+
+#
+# LED Triggers
+#
+CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_TRIGGER_TIMER=m
+CONFIG_LEDS_TRIGGER_IDE_DISK=y
+CONFIG_LEDS_TRIGGER_HEARTBEAT=m
+CONFIG_LEDS_TRIGGER_DEFAULT_ON=m
+CONFIG_ACCESSIBILITY=y
+CONFIG_A11Y_BRAILLE_CONSOLE=y
+# CONFIG_INFINIBAND is not set
+CONFIG_EDAC=y
+
+#
+# Reporting subsystems
+#
+# CONFIG_EDAC_DEBUG is not set
+CONFIG_EDAC_MM_EDAC=m
+CONFIG_RTC_LIB=y
+CONFIG_RTC_CLASS=y
+# CONFIG_RTC_HCTOSYS is not set
+# CONFIG_RTC_DEBUG is not set
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# I2C RTC drivers
+#
+CONFIG_RTC_DRV_DS1307=m
+CONFIG_RTC_DRV_DS1374=m
+CONFIG_RTC_DRV_DS1672=m
+CONFIG_RTC_DRV_MAX6900=m
+CONFIG_RTC_DRV_RS5C372=m
+CONFIG_RTC_DRV_ISL1208=m
+CONFIG_RTC_DRV_X1205=m
+CONFIG_RTC_DRV_PCF8563=m
+CONFIG_RTC_DRV_PCF8583=m
+CONFIG_RTC_DRV_M41T80=m
+CONFIG_RTC_DRV_M41T80_WDT=y
+# CONFIG_RTC_DRV_S35390A is not set
+CONFIG_RTC_DRV_FM3130=m
+
+#
+# SPI RTC drivers
+#
+
+#
+# Platform RTC drivers
+#
+CONFIG_RTC_DRV_CMOS=y
+CONFIG_RTC_DRV_DS1511=m
+CONFIG_RTC_DRV_DS1553=m
+CONFIG_RTC_DRV_DS1742=m
+CONFIG_RTC_DRV_STK17TA8=m
+# CONFIG_RTC_DRV_M48T86 is not set
+CONFIG_RTC_DRV_M48T59=m
+CONFIG_RTC_DRV_V3020=m
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_RTC_DRV_PPC=y
+CONFIG_DMADEVICES=y
+
+#
+# DMA Devices
+#
+# CONFIG_FSL_DMA is not set
+CONFIG_AUXDISPLAY=y
+CONFIG_KS0108=m
+CONFIG_KS0108_PORT=0x378
+CONFIG_KS0108_DELAY=2
+CONFIG_UIO=m
+CONFIG_UIO_CIF=m
+CONFIG_UIO_SMX=m
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=m
+CONFIG_EXT2_FS_XATTR=y
+CONFIG_EXT2_FS_POSIX_ACL=y
+CONFIG_EXT2_FS_SECURITY=y
+CONFIG_EXT2_FS_XIP=y
+CONFIG_FS_XIP=y
+CONFIG_EXT3_FS=m
+CONFIG_EXT3_FS_XATTR=y
+CONFIG_EXT3_FS_POSIX_ACL=y
+CONFIG_EXT3_FS_SECURITY=y
+CONFIG_EXT4DEV_FS=m
+CONFIG_EXT4DEV_FS_XATTR=y
+CONFIG_EXT4DEV_FS_POSIX_ACL=y
+CONFIG_EXT4DEV_FS_SECURITY=y
+CONFIG_JBD=m
+# CONFIG_JBD_DEBUG is not set
+CONFIG_JBD2=m
+CONFIG_JBD2_DEBUG=y
+CONFIG_FS_MBCACHE=m
+CONFIG_REISERFS_FS=m
+# CONFIG_REISERFS_CHECK is not set
+CONFIG_REISERFS_PROC_INFO=y
+CONFIG_REISERFS_FS_XATTR=y
+CONFIG_REISERFS_FS_POSIX_ACL=y
+CONFIG_REISERFS_FS_SECURITY=y
+CONFIG_JFS_FS=m
+CONFIG_JFS_POSIX_ACL=y
+CONFIG_JFS_SECURITY=y
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+CONFIG_FS_POSIX_ACL=y
+CONFIG_XFS_FS=m
+CONFIG_XFS_QUOTA=y
+CONFIG_XFS_POSIX_ACL=y
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_DEBUG is not set
+CONFIG_GFS2_FS=m
+CONFIG_GFS2_FS_LOCKING_DLM=m
+CONFIG_OCFS2_FS=m
+CONFIG_OCFS2_FS_O2CB=m
+CONFIG_OCFS2_FS_USERSPACE_CLUSTER=m
+# CONFIG_OCFS2_DEBUG_MASKLOG is not set
+# CONFIG_OCFS2_DEBUG_FS is not set
+CONFIG_DNOTIFY=y
+CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
+CONFIG_QUOTA=y
+CONFIG_QUOTA_NETLINK_INTERFACE=y
+# CONFIG_PRINT_QUOTA_WARNING is not set
+# CONFIG_QFMT_V1 is not set
+CONFIG_QFMT_V2=y
+CONFIG_QUOTACTL=y
+CONFIG_AUTOFS_FS=m
+CONFIG_AUTOFS4_FS=m
+CONFIG_FUSE_FS=m
+CONFIG_GENERIC_ACL=y
+
+#
+# CD-ROM/DVD Filesystems
+#
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_UDF_FS=m
+CONFIG_UDF_NLS=y
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=m
+CONFIG_MSDOS_FS=m
+CONFIG_VFAT_FS=m
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="ascii"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_PROC_SYSCTL=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_CONFIGFS_FS=m
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+CONFIG_AFFS_FS=m
+CONFIG_ECRYPT_FS=m
+CONFIG_HFS_FS=m
+CONFIG_HFSPLUS_FS=m
+CONFIG_BEFS_FS=m
+# CONFIG_BEFS_DEBUG is not set
+CONFIG_BFS_FS=m
+CONFIG_EFS_FS=m
+CONFIG_CRAMFS=m
+CONFIG_SQUASHFS=m
+# CONFIG_SQUASHFS_EMBEDDED is not set
+CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
+CONFIG_VXFS_FS=m
+CONFIG_MINIX_FS=m
+# CONFIG_HPFS_FS is not set
+CONFIG_QNX4FS_FS=m
+CONFIG_ROMFS_FS=m
+CONFIG_SYSV_FS=m
+CONFIG_UFS_FS=m
+# CONFIG_UFS_FS_WRITE is not set
+# CONFIG_UFS_DEBUG is not set
+CONFIG_NETWORK_FILESYSTEMS=y
+CONFIG_NFS_FS=m
+CONFIG_NFS_V3=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFSD=m
+CONFIG_NFSD_V2_ACL=y
+CONFIG_NFSD_V3=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_LOCKD=m
+CONFIG_LOCKD_V4=y
+CONFIG_EXPORTFS=m
+CONFIG_NFS_ACL_SUPPORT=m
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=m
+CONFIG_SUNRPC_GSS=m
+CONFIG_SUNRPC_BIND34=y
+CONFIG_RPCSEC_GSS_KRB5=m
+CONFIG_RPCSEC_GSS_SPKM3=m
+# CONFIG_SMB_FS is not set
+CONFIG_CIFS=m
+# CONFIG_CIFS_STATS is not set
+CONFIG_CIFS_WEAK_PW_HASH=y
+CONFIG_CIFS_XATTR=y
+CONFIG_CIFS_POSIX=y
+# CONFIG_CIFS_DEBUG2 is not set
+CONFIG_CIFS_EXPERIMENTAL=y
+CONFIG_CIFS_UPCALL=y
+CONFIG_CIFS_DFS_UPCALL=y
+CONFIG_NCP_FS=m
+CONFIG_NCPFS_PACKET_SIGNING=y
+CONFIG_NCPFS_IOCTL_LOCKING=y
+CONFIG_NCPFS_STRONG=y
+CONFIG_NCPFS_NFS_NS=y
+CONFIG_NCPFS_OS2_NS=y
+CONFIG_NCPFS_SMALLDOS=y
+CONFIG_NCPFS_NLS=y
+CONFIG_NCPFS_EXTRAS=y
+CONFIG_CODA_FS=m
+# CONFIG_CODA_FS_OLD_API is not set
+# CONFIG_AFS_FS is not set
+CONFIG_9P_FS=m
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+CONFIG_OSF_PARTITION=y
+CONFIG_AMIGA_PARTITION=y
+# CONFIG_ATARI_PARTITION is not set
+CONFIG_MAC_PARTITION=y
+CONFIG_MSDOS_PARTITION=y
+CONFIG_BSD_DISKLABEL=y
+CONFIG_MINIX_SUBPARTITION=y
+CONFIG_SOLARIS_X86_PARTITION=y
+CONFIG_UNIXWARE_DISKLABEL=y
+# CONFIG_LDM_PARTITION is not set
+CONFIG_SGI_PARTITION=y
+# CONFIG_ULTRIX_PARTITION is not set
+CONFIG_SUN_PARTITION=y
+CONFIG_KARMA_PARTITION=y
+CONFIG_EFI_PARTITION=y
+# CONFIG_SYSV68_PARTITION is not set
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="utf8"
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_737=m
+CONFIG_NLS_CODEPAGE_775=m
+CONFIG_NLS_CODEPAGE_850=m
+CONFIG_NLS_CODEPAGE_852=m
+CONFIG_NLS_CODEPAGE_855=m
+CONFIG_NLS_CODEPAGE_857=m
+CONFIG_NLS_CODEPAGE_860=m
+CONFIG_NLS_CODEPAGE_861=m
+CONFIG_NLS_CODEPAGE_862=m
+CONFIG_NLS_CODEPAGE_863=m
+CONFIG_NLS_CODEPAGE_864=m
+CONFIG_NLS_CODEPAGE_865=m
+CONFIG_NLS_CODEPAGE_866=m
+CONFIG_NLS_CODEPAGE_869=m
+CONFIG_NLS_CODEPAGE_936=m
+CONFIG_NLS_CODEPAGE_950=m
+CONFIG_NLS_CODEPAGE_932=m
+CONFIG_NLS_CODEPAGE_949=m
+CONFIG_NLS_CODEPAGE_874=m
+CONFIG_NLS_ISO8859_8=m
+CONFIG_NLS_CODEPAGE_1250=m
+CONFIG_NLS_CODEPAGE_1251=m
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=m
+CONFIG_NLS_ISO8859_2=m
+CONFIG_NLS_ISO8859_3=m
+CONFIG_NLS_ISO8859_4=m
+CONFIG_NLS_ISO8859_5=m
+CONFIG_NLS_ISO8859_6=m
+CONFIG_NLS_ISO8859_7=m
+CONFIG_NLS_ISO8859_9=m
+CONFIG_NLS_ISO8859_13=m
+CONFIG_NLS_ISO8859_14=m
+CONFIG_NLS_ISO8859_15=m
+CONFIG_NLS_KOI8_R=m
+CONFIG_NLS_KOI8_U=m
+CONFIG_NLS_UTF8=m
+CONFIG_DLM=m
+CONFIG_DLM_DEBUG=y
+CONFIG_QE_GPIO=y
+
+#
+# Library routines
+#
+CONFIG_BITREVERSE=y
+# CONFIG_GENERIC_FIND_FIRST_BIT is not set
+CONFIG_CRC_CCITT=m
+CONFIG_CRC16=m
+CONFIG_CRC_T10DIF=m
+CONFIG_CRC_ITU_T=m
+CONFIG_CRC32=y
+# CONFIG_CRC7 is not set
+CONFIG_LIBCRC32C=m
+CONFIG_ZLIB_INFLATE=y
+CONFIG_ZLIB_DEFLATE=m
+CONFIG_LZO_COMPRESS=m
+CONFIG_LZO_DECOMPRESS=m
+CONFIG_TEXTSEARCH=y
+CONFIG_TEXTSEARCH_KMP=m
+CONFIG_TEXTSEARCH_BM=m
+CONFIG_TEXTSEARCH_FSM=m
+CONFIG_PLIST=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
+CONFIG_HAS_DMA=y
+CONFIG_HAVE_LMB=y
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+# CONFIG_ENABLE_WARN_DEPRECATED is not set
+CONFIG_ENABLE_MUST_CHECK=y
+CONFIG_FRAME_WARN=1024
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_UNUSED_SYMBOLS=y
+CONFIG_DEBUG_FS=y
+CONFIG_HEADERS_CHECK=y
+CONFIG_DEBUG_KERNEL=y
+CONFIG_DEBUG_SHIRQ=y
+CONFIG_DETECT_SOFTLOCKUP=y
+CONFIG_SCHED_DEBUG=y
+CONFIG_SCHEDSTATS=y
+CONFIG_TIMER_STATS=y
+CONFIG_DEBUG_OBJECTS=y
+# CONFIG_DEBUG_OBJECTS_SELFTEST is not set
+CONFIG_DEBUG_OBJECTS_FREE=y
+CONFIG_DEBUG_OBJECTS_TIMERS=y
+CONFIG_SLUB_DEBUG_ON=y
+# CONFIG_SLUB_STATS is not set
+CONFIG_DEBUG_RT_MUTEXES=y
+CONFIG_DEBUG_PI_LIST=y
+# CONFIG_RT_MUTEX_TESTER is not set
+CONFIG_DEBUG_SPINLOCK=y
+CONFIG_DEBUG_MUTEXES=y
+CONFIG_DEBUG_SPINLOCK_SLEEP=y
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_HIGHMEM=y
+CONFIG_DEBUG_BUGVERBOSE=y
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_VM=y
+CONFIG_DEBUG_WRITECOUNT=y
+CONFIG_DEBUG_LIST=y
+CONFIG_DEBUG_SG=y
+CONFIG_FRAME_POINTER=y
+CONFIG_BOOT_PRINTK_DELAY=y
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_KPROBES_SANITY_TEST is not set
+# CONFIG_BACKTRACE_SELF_TEST is not set
+# CONFIG_LKDTM is not set
+CONFIG_FAULT_INJECTION=y
+CONFIG_FAILSLAB=y
+CONFIG_FAIL_PAGE_ALLOC=y
+CONFIG_FAIL_MAKE_REQUEST=y
+CONFIG_FAULT_INJECTION_DEBUG_FS=y
+CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y
+CONFIG_LATENCYTOP=y
+CONFIG_HAVE_FTRACE=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+CONFIG_TRACER_MAX_TRACE=y
+CONFIG_TRACING=y
+CONFIG_FTRACE=y
+CONFIG_SCHED_TRACER=y
+CONFIG_CONTEXT_SWITCH_TRACER=y
+CONFIG_DYNAMIC_FTRACE=y
+# CONFIG_FTRACE_STARTUP_TEST is not set
+# CONFIG_FIREWIRE_OHCI_REMOTE_DMA is not set
+# CONFIG_SAMPLES is not set
+CONFIG_DEBUG_STACKOVERFLOW=y
+CONFIG_DEBUG_STACK_USAGE=y
+CONFIG_DEBUGGER=y
+# CONFIG_CODE_PATCHING_SELFTEST is not set
+# CONFIG_FTR_FIXUP_SELFTEST is not set
+# CONFIG_KGDB_CONSOLE is not set
+CONFIG_XMON=y
+# CONFIG_XMON_DEFAULT is not set
+CONFIG_XMON_DISASSEMBLY=y
+CONFIG_IRQSTACKS=y
+# CONFIG_VIRQ_DEBUG is not set
+# CONFIG_BDI_SWITCH is not set
+CONFIG_BOOTX_TEXT=y
+# CONFIG_PPC_EARLY_DEBUG is not set
+
+#
+# Security options
+#
+CONFIG_KEYS=y
+CONFIG_KEYS_DEBUG_PROC_KEYS=y
+CONFIG_SECURITY=y
+CONFIG_SECURITY_NETWORK=y
+CONFIG_SECURITY_NETWORK_XFRM=y
+CONFIG_SECURITY_FILE_CAPABILITIES=y
+# CONFIG_SECURITY_ROOTPLUG is not set
+CONFIG_SECURITY_DEFAULT_MMAP_MIN_ADDR=65536
+CONFIG_SECURITY_SELINUX=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM=y
+CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=1
+CONFIG_SECURITY_SELINUX_DISABLE=y
+CONFIG_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SECURITY_SELINUX_AVC_STATS=y
+CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
+CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT=y
+# CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
+# CONFIG_SECURITY_SMACK is not set
+CONFIG_XOR_BLOCKS=m
+CONFIG_ASYNC_CORE=m
+CONFIG_ASYNC_MEMCPY=m
+CONFIG_ASYNC_XOR=m
+CONFIG_CRYPTO=y
+
+#
+# Crypto core or helper
+#
+CONFIG_CRYPTO_ALGAPI=y
+CONFIG_CRYPTO_AEAD=m
+CONFIG_CRYPTO_BLKCIPHER=m
+CONFIG_CRYPTO_HASH=y
+CONFIG_CRYPTO_MANAGER=y
+CONFIG_CRYPTO_GF128MUL=m
+CONFIG_CRYPTO_NULL=m
+# CONFIG_CRYPTO_CRYPTD is not set
+CONFIG_CRYPTO_AUTHENC=m
+CONFIG_CRYPTO_TEST=m
+
+#
+# Authenticated Encryption with Associated Data
+#
+CONFIG_CRYPTO_CCM=m
+CONFIG_CRYPTO_GCM=m
+CONFIG_CRYPTO_SEQIV=m
+
+#
+# Block modes
+#
+CONFIG_CRYPTO_CBC=m
+CONFIG_CRYPTO_CTR=m
+CONFIG_CRYPTO_CTS=m
+CONFIG_CRYPTO_ECB=m
+CONFIG_CRYPTO_LRW=m
+CONFIG_CRYPTO_PCBC=m
+CONFIG_CRYPTO_XTS=m
+
+#
+# Hash modes
+#
+CONFIG_CRYPTO_HMAC=y
+CONFIG_CRYPTO_XCBC=m
+
+#
+# Digest
+#
+CONFIG_CRYPTO_CRC32C=m
+CONFIG_CRYPTO_MD4=m
+CONFIG_CRYPTO_MD5=y
+CONFIG_CRYPTO_MICHAEL_MIC=m
+CONFIG_CRYPTO_RMD128=m
+CONFIG_CRYPTO_RMD160=m
+CONFIG_CRYPTO_RMD256=m
+CONFIG_CRYPTO_RMD320=m
+CONFIG_CRYPTO_SHA1=y
+CONFIG_CRYPTO_SHA256=m
+CONFIG_CRYPTO_SHA512=m
+CONFIG_CRYPTO_TGR192=m
+CONFIG_CRYPTO_WP512=m
+
+#
+# Ciphers
+#
+CONFIG_CRYPTO_AES=m
+CONFIG_CRYPTO_ANUBIS=m
+CONFIG_CRYPTO_ARC4=m
+CONFIG_CRYPTO_BLOWFISH=m
+CONFIG_CRYPTO_CAMELLIA=m
+CONFIG_CRYPTO_CAST5=m
+CONFIG_CRYPTO_CAST6=m
+CONFIG_CRYPTO_DES=m
+CONFIG_CRYPTO_FCRYPT=m
+CONFIG_CRYPTO_KHAZAD=m
+CONFIG_CRYPTO_SALSA20=m
+CONFIG_CRYPTO_SEED=m
+CONFIG_CRYPTO_SERPENT=m
+CONFIG_CRYPTO_TEA=m
+CONFIG_CRYPTO_TWOFISH=m
+CONFIG_CRYPTO_TWOFISH_COMMON=m
+
+#
+# Compression
+#
+CONFIG_CRYPTO_DEFLATE=m
+CONFIG_CRYPTO_LZO=m
+CONFIG_CRYPTO_HW=y
+CONFIG_CRYPTO_DEV_HIFN_795X=m
+CONFIG_CRYPTO_DEV_HIFN_795X_RNG=y
+CONFIG_CRYPTO_DEV_TALITOS=m
+CONFIG_PPC_CLOCK=y
+CONFIG_PPC_LIB_RHEAP=y
+CONFIG_VIRTUALIZATION=y
+CONFIG_VIRTIO=m
+CONFIG_VIRTIO_RING=m
+CONFIG_VIRTIO_PCI=m
+CONFIG_VIRTIO_BALLOON=m
index 71d79e4..f9a3d3b 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.25
-# Mon Apr 28 12:39:10 2008
+# Linux kernel version: 2.6.26
+# Wed Jul 16 13:59:24 2008
 #
 CONFIG_PPC64=y
 
@@ -14,8 +14,9 @@ CONFIG_POWER4=y
 CONFIG_TUNE_CELL=y
 CONFIG_PPC_FPU=y
 CONFIG_ALTIVEC=y
+# CONFIG_VSX is not set
 CONFIG_PPC_STD_MMU=y
-# CONFIG_PPC_MM_SLICES is not set
+CONFIG_PPC_MM_SLICES=y
 CONFIG_VIRT_CPU_ACCOUNTING=y
 CONFIG_SMP=y
 CONFIG_NR_CPUS=2
@@ -31,6 +32,7 @@ CONFIG_GENERIC_HARDIRQS=y
 CONFIG_HAVE_SETUP_PER_CPU_AREA=y
 CONFIG_IRQ_PER_CPU=y
 CONFIG_STACKTRACE_SUPPORT=y
+CONFIG_HAVE_LATENCYTOP_SUPPORT=y
 CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 CONFIG_LOCKDEP_SUPPORT=y
 CONFIG_RWSEM_XCHGADD_ALGORITHM=y
@@ -90,6 +92,7 @@ CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
 # CONFIG_EMBEDDED is not set
 CONFIG_SYSCTL_SYSCALL=y
+CONFIG_SYSCTL_SYSCALL_CHECK=y
 CONFIG_KALLSYMS=y
 CONFIG_KALLSYMS_ALL=y
 CONFIG_KALLSYMS_EXTRA_PASS=y
@@ -117,12 +120,15 @@ CONFIG_HAVE_OPROFILE=y
 # CONFIG_KPROBES is not set
 CONFIG_HAVE_KPROBES=y
 CONFIG_HAVE_KRETPROBES=y
+CONFIG_HAVE_DMA_ATTRS=y
+CONFIG_USE_GENERIC_SMP_HELPERS=y
 CONFIG_PROC_PAGE_MONITOR=y
 CONFIG_SLABINFO=y
 CONFIG_RT_MUTEXES=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
+# CONFIG_MODULE_FORCE_LOAD is not set
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
 # CONFIG_MODVERSIONS is not set
@@ -132,6 +138,7 @@ CONFIG_STOP_MACHINE=y
 CONFIG_BLOCK=y
 # CONFIG_BLK_DEV_IO_TRACE is not set
 CONFIG_BLK_DEV_BSG=y
+# CONFIG_BLK_DEV_INTEGRITY is not set
 CONFIG_BLOCK_COMPAT=y
 
 #
@@ -152,13 +159,8 @@ CONFIG_CLASSIC_RCU=y
 # Platform support
 #
 CONFIG_PPC_MULTIPLATFORM=y
-# CONFIG_PPC_82xx is not set
-# CONFIG_PPC_83xx is not set
-# CONFIG_PPC_86xx is not set
 # CONFIG_PPC_PSERIES is not set
 # CONFIG_PPC_ISERIES is not set
-# CONFIG_PPC_MPC512x is not set
-# CONFIG_PPC_MPC5121 is not set
 # CONFIG_PPC_PMAC is not set
 # CONFIG_PPC_MAPLE is not set
 # CONFIG_PPC_PASEMI is not set
@@ -187,6 +189,7 @@ CONFIG_PPC_CELL=y
 # Cell Broadband Engine options
 #
 CONFIG_SPU_FS=y
+CONFIG_SPU_FS_64K_LS=y
 CONFIG_SPU_BASE=y
 # CONFIG_PQ2ADS is not set
 # CONFIG_IPIC is not set
@@ -222,6 +225,7 @@ CONFIG_PREEMPT_NONE=y
 CONFIG_BINFMT_ELF=y
 CONFIG_COMPAT_BINFMT_ELF=y
 CONFIG_BINFMT_MISC=y
+CONFIG_HUGETLB_PAGE_SIZE_VARIABLE=y
 # CONFIG_IOMMU_VMERGE is not set
 CONFIG_IOMMU_HELPER=y
 CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
@@ -248,18 +252,22 @@ CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
 # CONFIG_SPARSEMEM_VMEMMAP is not set
 CONFIG_MEMORY_HOTPLUG=y
 CONFIG_MEMORY_HOTPLUG_SPARSE=y
+CONFIG_PAGEFLAGS_EXTENDED=y
 CONFIG_SPLIT_PTLOCK_CPUS=4
 CONFIG_RESOURCES_64BIT=y
 CONFIG_ZONE_DMA_FLAG=1
 CONFIG_BOUNCE=y
 CONFIG_ARCH_MEMORY_PROBE=y
-# CONFIG_PPC_HAS_HASH_64K is not set
+CONFIG_PPC_HAS_HASH_64K=y
 # CONFIG_PPC_64K_PAGES is not set
 CONFIG_FORCE_MAX_ZONEORDER=13
-# CONFIG_SCHED_SMT is not set
+CONFIG_SCHED_SMT=y
 CONFIG_PROC_DEVICETREE=y
 # CONFIG_CMDLINE_BOOL is not set
-# CONFIG_PM is not set
+CONFIG_EXTRA_TARGETS=""
+CONFIG_PM=y
+CONFIG_PM_DEBUG=y
+# CONFIG_PM_VERBOSE is not set
 # CONFIG_SECCOMP is not set
 CONFIG_ISA_DMA_API=y
 
@@ -273,6 +281,7 @@ CONFIG_GENERIC_ISA_DMA=y
 # CONFIG_PCI_SYSCALL is not set
 # CONFIG_ARCH_SUPPORTS_MSI is not set
 # CONFIG_PCCARD is not set
+# CONFIG_HAS_RAPIDIO is not set
 CONFIG_PAGE_OFFSET=0xc000000000000000
 CONFIG_KERNEL_START=0xc000000000000000
 CONFIG_PHYSICAL_START=0x00000000
@@ -412,6 +421,8 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 CONFIG_FW_LOADER=m
+# CONFIG_FIRMWARE_IN_KERNEL is not set
+CONFIG_EXTRA_FIRMWARE=""
 # CONFIG_DEBUG_DRIVER is not set
 # CONFIG_DEBUG_DEVRES is not set
 # CONFIG_SYS_HYPERVISOR is not set
@@ -478,6 +489,7 @@ CONFIG_SCSI_WAIT_SCAN=m
 # CONFIG_SCSI_SAS_LIBSAS is not set
 # CONFIG_SCSI_SRP_ATTRS is not set
 # CONFIG_SCSI_LOWLEVEL is not set
+# CONFIG_SCSI_DH is not set
 # CONFIG_ATA is not set
 # CONFIG_MD is not set
 # CONFIG_MACINTOSH_DRIVERS is not set
@@ -533,8 +545,18 @@ CONFIG_USB_NET_MCS7830=m
 # CONFIG_USB_NET_CDC_SUBSET is not set
 # CONFIG_USB_NET_ZAURUS is not set
 # CONFIG_WAN is not set
-# CONFIG_PPP is not set
+CONFIG_PPP=m
+CONFIG_PPP_MULTILINK=y
+# CONFIG_PPP_FILTER is not set
+CONFIG_PPP_ASYNC=m
+# CONFIG_PPP_SYNC_TTY is not set
+CONFIG_PPP_DEFLATE=m
+# CONFIG_PPP_BSDCOMP is not set
+# CONFIG_PPP_MPPE is not set
+CONFIG_PPPOE=m
+# CONFIG_PPPOL2TP is not set
 # CONFIG_SLIP is not set
+CONFIG_SLHC=m
 # CONFIG_NETCONSOLE is not set
 # CONFIG_NETPOLL is not set
 # CONFIG_NET_POLL_CONTROLLER is not set
@@ -603,6 +625,7 @@ CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
 CONFIG_HW_CONSOLE=y
 CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_DEVKMEM=y
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -618,23 +641,17 @@ CONFIG_LEGACY_PTYS=y
 CONFIG_LEGACY_PTY_COUNT=16
 # CONFIG_IPMI_HANDLER is not set
 # CONFIG_HW_RANDOM is not set
-CONFIG_GEN_RTC=y
-# CONFIG_GEN_RTC_X is not set
 # CONFIG_R3964 is not set
 # CONFIG_RAW_DRIVER is not set
 # CONFIG_HANGCHECK_TIMER is not set
 # CONFIG_TCG_TPM is not set
 # CONFIG_I2C is not set
-
-#
-# SPI support
-#
 # CONFIG_SPI is not set
-# CONFIG_SPI_MASTER is not set
 # CONFIG_W1 is not set
 # CONFIG_POWER_SUPPLY is not set
 # CONFIG_HWMON is not set
 # CONFIG_THERMAL is not set
+# CONFIG_THERMAL_HWMON is not set
 # CONFIG_WATCHDOG is not set
 
 #
@@ -652,8 +669,17 @@ CONFIG_SSB_POSSIBLE=y
 #
 # Multimedia devices
 #
+
+#
+# Multimedia core support
+#
 # CONFIG_VIDEO_DEV is not set
 # CONFIG_DVB_CORE is not set
+# CONFIG_VIDEO_MEDIA is not set
+
+#
+# Multimedia drivers
+#
 # CONFIG_DAB is not set
 
 #
@@ -671,8 +697,8 @@ CONFIG_FB=y
 CONFIG_FB_SYS_FILLRECT=y
 CONFIG_FB_SYS_COPYAREA=y
 CONFIG_FB_SYS_IMAGEBLIT=y
+# CONFIG_FB_FOREIGN_ENDIAN is not set
 CONFIG_FB_SYS_FOPS=y
-CONFIG_FB_DEFERRED_IO=y
 # CONFIG_FB_SVGALIB is not set
 # CONFIG_FB_MACMODES is not set
 # CONFIG_FB_BACKLIGHT is not set
@@ -712,18 +738,12 @@ CONFIG_FB_LOGO_EXTRA=y
 # CONFIG_LOGO_LINUX_MONO is not set
 # CONFIG_LOGO_LINUX_VGA16 is not set
 CONFIG_LOGO_LINUX_CLUT224=y
-
-#
-# Sound
-#
 CONFIG_SOUND=m
-
-#
-# Advanced Linux Sound Architecture
-#
 CONFIG_SND=m
 CONFIG_SND_TIMER=m
 CONFIG_SND_PCM=m
+CONFIG_SND_HWDEP=m
+CONFIG_SND_RAWMIDI=m
 # CONFIG_SND_SEQUENCER is not set
 # CONFIG_SND_MIXER_OSS is not set
 # CONFIG_SND_PCM_OSS is not set
@@ -732,53 +752,20 @@ CONFIG_SND_SUPPORT_OLD_API=y
 CONFIG_SND_VERBOSE_PROCFS=y
 # CONFIG_SND_VERBOSE_PRINTK is not set
 # CONFIG_SND_DEBUG is not set
-
-#
-# Generic devices
-#
-# CONFIG_SND_DUMMY is not set
-# CONFIG_SND_MTPAV is not set
-# CONFIG_SND_SERIAL_U16550 is not set
-# CONFIG_SND_MPU401 is not set
-
-#
-# ALSA PowerMac devices
-#
-
-#
-# ALSA PowerMac requires I2C
-#
-
-#
-# ALSA PowerPC devices
-#
+# CONFIG_SND_DRIVERS is not set
+CONFIG_SND_PPC=y
 CONFIG_SND_PS3=m
 CONFIG_SND_PS3_DEFAULT_START_DELAY=2000
-
-#
-# USB devices
-#
-# CONFIG_SND_USB_AUDIO is not set
+CONFIG_SND_USB=y
+CONFIG_SND_USB_AUDIO=m
 # CONFIG_SND_USB_USX2Y is not set
 # CONFIG_SND_USB_CAIAQ is not set
-
-#
-# System on Chip audio support
-#
 # CONFIG_SND_SOC is not set
-
-#
-# ALSA SoC audio for Freescale SOCs
-#
-
-#
-# Open Sound System
-#
 # CONFIG_SOUND_PRIME is not set
 CONFIG_HID_SUPPORT=y
 CONFIG_HID=y
 # CONFIG_HID_DEBUG is not set
-# CONFIG_HIDRAW is not set
+CONFIG_HIDRAW=y
 
 #
 # USB Input Devices
@@ -807,17 +794,20 @@ CONFIG_USB=m
 CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
+CONFIG_USB_SUSPEND=y
 # CONFIG_USB_OTG is not set
 
 #
 # USB Host Controller Drivers
 #
+# CONFIG_USB_C67X00_HCD is not set
 CONFIG_USB_EHCI_HCD=m
 # CONFIG_USB_EHCI_ROOT_HUB_TT is not set
 # CONFIG_USB_EHCI_TT_NEWSCHED is not set
 CONFIG_USB_EHCI_BIG_ENDIAN_MMIO=y
 # CONFIG_USB_EHCI_HCD_PPC_OF is not set
 # CONFIG_USB_ISP116X_HCD is not set
+# CONFIG_USB_ISP1760_HCD is not set
 CONFIG_USB_OHCI_HCD=m
 # CONFIG_USB_OHCI_HCD_PPC_OF is not set
 # CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
@@ -831,6 +821,7 @@ CONFIG_USB_OHCI_LITTLE_ENDIAN=y
 #
 # CONFIG_USB_ACM is not set
 # CONFIG_USB_PRINTER is not set
+# CONFIG_USB_WDM is not set
 
 #
 # NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
@@ -890,12 +881,45 @@ CONFIG_USB_MON=y
 # CONFIG_USB_TRANCEVIBRATOR is not set
 # CONFIG_USB_IOWARRIOR is not set
 # CONFIG_USB_TEST is not set
+# CONFIG_USB_ISIGHTFW is not set
 # CONFIG_USB_GADGET is not set
 # CONFIG_MMC is not set
 # CONFIG_MEMSTICK is not set
 # CONFIG_NEW_LEDS is not set
+# CONFIG_ACCESSIBILITY is not set
 # CONFIG_EDAC is not set
-# CONFIG_RTC_CLASS is not set
+CONFIG_RTC_LIB=m
+CONFIG_RTC_CLASS=m
+
+#
+# RTC interfaces
+#
+CONFIG_RTC_INTF_SYSFS=y
+CONFIG_RTC_INTF_PROC=y
+CONFIG_RTC_INTF_DEV=y
+# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
+# CONFIG_RTC_DRV_TEST is not set
+
+#
+# SPI RTC drivers
+#
+
+#
+# Platform RTC drivers
+#
+# CONFIG_RTC_DRV_CMOS is not set
+# CONFIG_RTC_DRV_DS1511 is not set
+# CONFIG_RTC_DRV_DS1553 is not set
+# CONFIG_RTC_DRV_DS1742 is not set
+# CONFIG_RTC_DRV_STK17TA8 is not set
+# CONFIG_RTC_DRV_M48T86 is not set
+# CONFIG_RTC_DRV_M48T59 is not set
+# CONFIG_RTC_DRV_V3020 is not set
+
+#
+# on-CPU RTC drivers
+#
+CONFIG_RTC_DRV_PPC=m
 # CONFIG_DMADEVICES is not set
 # CONFIG_UIO is not set
 
@@ -911,6 +935,7 @@ CONFIG_EXT3_FS_XATTR=y
 # CONFIG_EXT3_FS_SECURITY is not set
 # CONFIG_EXT4DEV_FS is not set
 CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
@@ -959,8 +984,8 @@ CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
 CONFIG_TMPFS=y
 # CONFIG_TMPFS_POSIX_ACL is not set
-# CONFIG_HUGETLBFS is not set
-# CONFIG_HUGETLB_PAGE is not set
+CONFIG_HUGETLBFS=y
+CONFIG_HUGETLB_PAGE=y
 # CONFIG_CONFIGFS_FS is not set
 
 #
@@ -1059,12 +1084,15 @@ CONFIG_NLS_ISO8859_1=y
 #
 CONFIG_BITREVERSE=y
 # CONFIG_GENERIC_FIND_FIRST_BIT is not set
-# CONFIG_CRC_CCITT is not set
+CONFIG_CRC_CCITT=m
 # CONFIG_CRC16 is not set
+# CONFIG_CRC_T10DIF is not set
 CONFIG_CRC_ITU_T=m
 CONFIG_CRC32=y
 # CONFIG_CRC7 is not set
 # CONFIG_LIBCRC32C is not set
+CONFIG_ZLIB_INFLATE=m
+CONFIG_ZLIB_DEFLATE=m
 CONFIG_LZO_COMPRESS=m
 CONFIG_LZO_DECOMPRESS=m
 CONFIG_PLIST=y
@@ -1082,7 +1110,7 @@ CONFIG_ENABLE_MUST_CHECK=y
 CONFIG_FRAME_WARN=2048
 CONFIG_MAGIC_SYSRQ=y
 # CONFIG_UNUSED_SYMBOLS is not set
-# CONFIG_DEBUG_FS is not set
+CONFIG_DEBUG_FS=y
 # CONFIG_HEADERS_CHECK is not set
 CONFIG_DEBUG_KERNEL=y
 # CONFIG_DEBUG_SHIRQ is not set
@@ -1090,33 +1118,49 @@ CONFIG_DETECT_SOFTLOCKUP=y
 CONFIG_SCHED_DEBUG=y
 # CONFIG_SCHEDSTATS is not set
 # CONFIG_TIMER_STATS is not set
+# CONFIG_DEBUG_OBJECTS is not set
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_RT_MUTEXES is not set
 # CONFIG_RT_MUTEX_TESTER is not set
 CONFIG_DEBUG_SPINLOCK=y
 CONFIG_DEBUG_MUTEXES=y
-# CONFIG_DEBUG_LOCK_ALLOC is not set
-# CONFIG_PROVE_LOCKING is not set
+CONFIG_DEBUG_LOCK_ALLOC=y
+CONFIG_PROVE_LOCKING=y
+CONFIG_LOCKDEP=y
 # CONFIG_LOCK_STAT is not set
+CONFIG_DEBUG_LOCKDEP=y
+CONFIG_TRACE_IRQFLAGS=y
 CONFIG_DEBUG_SPINLOCK_SLEEP=y
 # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
+CONFIG_STACKTRACE=y
 # CONFIG_DEBUG_KOBJECT is not set
 CONFIG_DEBUG_BUGVERBOSE=y
 CONFIG_DEBUG_INFO=y
 # CONFIG_DEBUG_VM is not set
-# CONFIG_DEBUG_WRITECOUNT is not set
+CONFIG_DEBUG_WRITECOUNT=y
 CONFIG_DEBUG_LIST=y
 # CONFIG_DEBUG_SG is not set
+CONFIG_FRAME_POINTER=y
 # CONFIG_BOOT_PRINTK_DELAY is not set
 # CONFIG_RCU_TORTURE_TEST is not set
 # CONFIG_BACKTRACE_SELF_TEST is not set
 # CONFIG_FAULT_INJECTION is not set
+# CONFIG_LATENCYTOP is not set
+CONFIG_HAVE_FTRACE=y
+CONFIG_HAVE_DYNAMIC_FTRACE=y
+# CONFIG_FTRACE is not set
+# CONFIG_IRQSOFF_TRACER is not set
+# CONFIG_SCHED_TRACER is not set
+# CONFIG_CONTEXT_SWITCH_TRACER is not set
 # CONFIG_SAMPLES is not set
 CONFIG_DEBUG_STACKOVERFLOW=y
 # CONFIG_DEBUG_STACK_USAGE is not set
 # CONFIG_DEBUG_PAGEALLOC is not set
 # CONFIG_DEBUGGER is not set
+# CONFIG_CODE_PATCHING_SELFTEST is not set
+# CONFIG_FTR_FIXUP_SELFTEST is not set
 CONFIG_IRQSTACKS=y
+# CONFIG_VIRQ_DEBUG is not set
 # CONFIG_BOOTX_TEXT is not set
 # CONFIG_PPC_EARLY_DEBUG is not set
 
@@ -1172,6 +1216,10 @@ CONFIG_CRYPTO_PCBC=m
 # CONFIG_CRYPTO_MD4 is not set
 CONFIG_CRYPTO_MD5=y
 CONFIG_CRYPTO_MICHAEL_MIC=m
+# CONFIG_CRYPTO_RMD128 is not set
+# CONFIG_CRYPTO_RMD160 is not set
+# CONFIG_CRYPTO_RMD256 is not set
+# CONFIG_CRYPTO_RMD320 is not set
 # CONFIG_CRYPTO_SHA1 is not set
 # CONFIG_CRYPTO_SHA256 is not set
 # CONFIG_CRYPTO_SHA512 is not set
index f7f3c21..b936a1d 100644 (file)
@@ -355,6 +355,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
                .machine_check          = machine_check_generic,
+               .oprofile_cpu_type      = "ppc64/compat-power5+",
                .platform               = "power5+",
        },
        {       /* Power6 */
@@ -386,6 +387,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
                .machine_check          = machine_check_generic,
+               .oprofile_cpu_type      = "ppc64/compat-power6",
                .platform               = "power6",
        },
        {       /* 2.06-compliant processor, i.e. Power7 "architected" mode */
@@ -397,6 +399,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
                .icache_bsize           = 128,
                .dcache_bsize           = 128,
                .machine_check          = machine_check_generic,
+               .oprofile_cpu_type      = "ppc64/compat-power7",
                .platform               = "power7",
        },
        {       /* Power7 */
@@ -1629,6 +1632,23 @@ struct cpu_spec * __init identify_cpu(unsigned long offset, unsigned int pvr)
                                t->cpu_setup = s->cpu_setup;
                                t->cpu_restore = s->cpu_restore;
                                t->platform = s->platform;
+                               /*
+                                * If we have passed through this logic once
+                                * before and have pulled the default case
+                                * because the real PVR was not found inside
+                                * cpu_specs[], then we are possibly running in
+                                * compatibility mode. In that case, let the
+                                * oprofiler know which set of compatibility
+                                * counters to pull from by making sure the
+                                * oprofile_cpu_type string is set to that of
+                                * compatibility mode. If the oprofile_cpu_type
+                                * already has a value, then we are possibly
+                                * overriding a real PVR with a logical one, and,
+                                * in that case, keep the current value for
+                                * oprofile_cpu_type.
+                                */
+                               if (t->oprofile_cpu_type == NULL)
+                                       t->oprofile_cpu_type = s->oprofile_cpu_type;
                        } else
                                *t = *s;
                        *PTRRELOC(&cur_cpu_spec) = &the_cpu_spec;
index c426850..3cb52fa 100644 (file)
@@ -151,16 +151,11 @@ skpinv:   addi    r6,r6,1                         /* Increment */
        /* Invalidate TLB0 */
        li      r6,0x04
        tlbivax 0,r6
-#ifdef CONFIG_SMP
-       tlbsync
-#endif
+       TLBSYNC
        /* Invalidate TLB1 */
        li      r6,0x0c
        tlbivax 0,r6
-#ifdef CONFIG_SMP
-       tlbsync
-#endif
-       msync
+       TLBSYNC
 
 /* 3. Setup a temp mapping and jump to it */
        andi.   r5, r3, 0x1     /* Find an entry not used and is non-zero */
@@ -238,10 +233,7 @@ skpinv:    addi    r6,r6,1                         /* Increment */
        /* Invalidate TLB1 */
        li      r9,0x0c
        tlbivax 0,r9
-#ifdef CONFIG_SMP
-       tlbsync
-#endif
-       msync
+       TLBSYNC
 
 /* 6. Setup KERNELBASE mapping in TLB1[0] */
        lis     r6,0x1000               /* Set MAS0(TLBSEL) = TLB1(1), ESEL = 0 */
@@ -283,10 +275,7 @@ skpinv:    addi    r6,r6,1                         /* Increment */
        /* Invalidate TLB1 */
        li      r9,0x0c
        tlbivax 0,r9
-#ifdef CONFIG_SMP
-       tlbsync
-#endif
-       msync
+       TLBSYNC
 
        /* Establish the interrupt vector offsets */
        SET_IVOR(0,  CriticalInput);
@@ -483,90 +472,16 @@ interrupt_base:
 
        /* Data Storage Interrupt */
        START_EXCEPTION(DataStorage)
-       mtspr   SPRN_SPRG0, r10         /* Save some working registers */
-       mtspr   SPRN_SPRG1, r11
-       mtspr   SPRN_SPRG4W, r12
-       mtspr   SPRN_SPRG5W, r13
-       mfcr    r11
-       mtspr   SPRN_SPRG7W, r11
-
-       /*
-        * Check if it was a store fault, if not then bail
-        * because a user tried to access a kernel or
-        * read-protected page.  Otherwise, get the
-        * offending address and handle it.
-        */
-       mfspr   r10, SPRN_ESR
-       andis.  r10, r10, ESR_ST@h
-       beq     2f
-
-       mfspr   r10, SPRN_DEAR          /* Get faulting address */
-
-       /* If we are faulting a kernel address, we have to use the
-        * kernel page tables.
-        */
-       lis     r11, PAGE_OFFSET@h
-       cmplw   0, r10, r11
-       bge     2f
-
-       /* Get the PGD for the current thread */
-3:
-       mfspr   r11,SPRN_SPRG3
-       lwz     r11,PGDIR(r11)
-4:
-       FIND_PTE
-
-       /* Are _PAGE_USER & _PAGE_RW set & _PAGE_HWWRITE not? */
-       andi.   r13, r11, _PAGE_RW|_PAGE_USER|_PAGE_HWWRITE
-       cmpwi   0, r13, _PAGE_RW|_PAGE_USER
-       bne     2f                      /* Bail if not */
-
-       /* Update 'changed'. */
-       ori     r11, r11, _PAGE_DIRTY|_PAGE_ACCESSED|_PAGE_HWWRITE
-       stw     r11, PTE_FLAGS_OFFSET(r12) /* Update Linux page table */
-
-       /* MAS2 not updated as the entry does exist in the tlb, this
-          fault taken to detect state transition (eg: COW -> DIRTY)
-        */
-       andi.   r11, r11, _PAGE_HWEXEC
-       rlwimi  r11, r11, 31, 27, 27    /* SX <- _PAGE_HWEXEC */
-       ori     r11, r11, (MAS3_UW|MAS3_SW|MAS3_UR|MAS3_SR)@l /* set static perms */
-
-       /* update search PID in MAS6, AS = 0 */
-       mfspr   r12, SPRN_PID0
-       slwi    r12, r12, 16
-       mtspr   SPRN_MAS6, r12
-
-       /* find the TLB index that caused the fault.  It has to be here. */
-       tlbsx   0, r10
-
-       /* only update the perm bits, assume the RPN is fine */
-       mfspr   r12, SPRN_MAS3
-       rlwimi  r12, r11, 0, 20, 31
-       mtspr   SPRN_MAS3,r12
-       tlbwe
-
-       /* Done...restore registers and get out of here.  */
-       mfspr   r11, SPRN_SPRG7R
-       mtcr    r11
-       mfspr   r13, SPRN_SPRG5R
-       mfspr   r12, SPRN_SPRG4R
-       mfspr   r11, SPRN_SPRG1
-       mfspr   r10, SPRN_SPRG0
-       rfi                     /* Force context change */
-
-2:
-       /*
-        * The bailout.  Restore registers to pre-exception conditions
-        * and call the heavyweights to help us out.
-        */
-       mfspr   r11, SPRN_SPRG7R
-       mtcr    r11
-       mfspr   r13, SPRN_SPRG5R
-       mfspr   r12, SPRN_SPRG4R
-       mfspr   r11, SPRN_SPRG1
-       mfspr   r10, SPRN_SPRG0
-       b       data_access
+       NORMAL_EXCEPTION_PROLOG
+       mfspr   r5,SPRN_ESR             /* Grab the ESR, save it, pass arg3 */
+       stw     r5,_ESR(r11)
+       mfspr   r4,SPRN_DEAR            /* Grab the DEAR, save it, pass arg2 */
+       andis.  r10,r5,(ESR_ILK|ESR_DLK)@h
+       bne     1f
+       EXC_XFER_EE_LITE(0x0300, handle_page_fault)
+1:
+       addi    r3,r1,STACK_FRAME_OVERHEAD
+       EXC_XFER_EE_LITE(0x0300, CacheLockingException)
 
        /* Instruction Storage Interrupt */
        INSTRUCTION_STORAGE_EXCEPTION
@@ -645,15 +560,30 @@ interrupt_base:
        lwz     r11,PGDIR(r11)
 
 4:
+       /* Mask of required permission bits. Note that while we
+        * do copy ESR:ST to _PAGE_RW position as trying to write
+        * to an RO page is pretty common, we don't do it with
+        * _PAGE_DIRTY. We could do it, but it's a fairly rare
+        * event so I'd rather take the overhead when it happens
+        * rather than adding an instruction here. We should measure
+        * whether the whole thing is worth it in the first place
+        * as we could avoid loading SPRN_ESR completely in the first
+        * place...
+        *
+        * TODO: Is it worth doing that mfspr & rlwimi in the first
+        *       place or can we save a couple of instructions here ?
+        */
+       mfspr   r12,SPRN_ESR
+       li      r13,_PAGE_PRESENT|_PAGE_ACCESSED
+       rlwimi  r13,r12,11,29,29
+
        FIND_PTE
-       andi.   r13, r11, _PAGE_PRESENT /* Is the page present? */
-       beq     2f                      /* Bail if not present */
+       andc.   r13,r13,r11             /* Check permission */
+       bne     2f                      /* Bail if permission mismach */
 
 #ifdef CONFIG_PTE_64BIT
        lwz     r13, 0(r12)
 #endif
-       ori     r11, r11, _PAGE_ACCESSED
-       stw     r11, PTE_FLAGS_OFFSET(r12)
 
         /* Jump to common tlb load */
        b       finish_tlb_load
@@ -667,7 +597,7 @@ interrupt_base:
        mfspr   r12, SPRN_SPRG4R
        mfspr   r11, SPRN_SPRG1
        mfspr   r10, SPRN_SPRG0
-       b       data_access
+       b       DataStorage
 
        /* Instruction TLB Error Interrupt */
        /*
@@ -705,15 +635,16 @@ interrupt_base:
        lwz     r11,PGDIR(r11)
 
 4:
+       /* Make up the required permissions */
+       li      r13,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_HWEXEC
+
        FIND_PTE
-       andi.   r13, r11, _PAGE_PRESENT /* Is the page present? */
-       beq     2f                      /* Bail if not present */
+       andc.   r13,r13,r11             /* Check permission */
+       bne     2f                      /* Bail if permission mismach */
 
 #ifdef CONFIG_PTE_64BIT
        lwz     r13, 0(r12)
 #endif
-       ori     r11, r11, _PAGE_ACCESSED
-       stw     r11, PTE_FLAGS_OFFSET(r12)
 
        /* Jump to common TLB load point */
        b       finish_tlb_load
@@ -768,29 +699,13 @@ interrupt_base:
  * Local functions
  */
 
-       /*
-        * Data TLB exceptions will bail out to this point
-        * if they can't resolve the lightweight TLB fault.
-        */
-data_access:
-       NORMAL_EXCEPTION_PROLOG
-       mfspr   r5,SPRN_ESR             /* Grab the ESR, save it, pass arg3 */
-       stw     r5,_ESR(r11)
-       mfspr   r4,SPRN_DEAR            /* Grab the DEAR, save it, pass arg2 */
-       andis.  r10,r5,(ESR_ILK|ESR_DLK)@h
-       bne     1f
-       EXC_XFER_EE_LITE(0x0300, handle_page_fault)
-1:
-       addi    r3,r1,STACK_FRAME_OVERHEAD
-       EXC_XFER_EE_LITE(0x0300, CacheLockingException)
-
 /*
-
  * Both the instruction and data TLB miss get to this
  * point to load the TLB.
  *     r10 - EA of fault
  *     r11 - TLB (info from Linux PTE)
- *     r12, r13 - available to use
+ *     r12 - available to use
+ *     r13 - upper bits of PTE (if PTE_64BIT) or available to use
  *     CR5 - results of addr >= PAGE_OFFSET
  *     MAS0, MAS1 - loaded with proper value when we get here
  *     MAS2, MAS3 - will need additional info from Linux PTE
@@ -812,20 +727,14 @@ finish_tlb_load:
 #endif
        mtspr   SPRN_MAS2, r12
 
-       bge     5, 1f
-
-       /* is user addr */
-       andi.   r12, r11, (_PAGE_USER | _PAGE_HWWRITE | _PAGE_HWEXEC)
+       li      r10, (_PAGE_HWEXEC | _PAGE_PRESENT)
+       rlwimi  r10, r11, 31, 29, 29    /* extract _PAGE_DIRTY into SW */
+       and     r12, r11, r10
        andi.   r10, r11, _PAGE_USER    /* Test for _PAGE_USER */
-       srwi    r10, r12, 1
-       or      r12, r12, r10   /* Copy user perms into supervisor */
-       iseleq  r12, 0, r12
-       b       2f
-
-       /* is kernel addr */
-1:     rlwinm  r12, r11, 31, 29, 29    /* Extract _PAGE_HWWRITE into SW */
-       ori     r12, r12, (MAS3_SX | MAS3_SR)
-
+       slwi    r10, r12, 1
+       or      r10, r10, r12
+       iseleq  r12, r12, r10
+       
 #ifdef CONFIG_PTE_64BIT
 2:     rlwimi  r12, r13, 24, 0, 7      /* grab RPN[32:39] */
        rlwimi  r12, r11, 24, 8, 19     /* grab RPN[40:51] */
index 8c68ee9..2385f68 100644 (file)
@@ -186,7 +186,8 @@ static unsigned long iommu_range_alloc(struct device *dev,
 static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
                              void *page, unsigned int npages,
                              enum dma_data_direction direction,
-                             unsigned long mask, unsigned int align_order)
+                             unsigned long mask, unsigned int align_order,
+                             struct dma_attrs *attrs)
 {
        unsigned long entry, flags;
        dma_addr_t ret = DMA_ERROR_CODE;
@@ -205,7 +206,7 @@ static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
 
        /* Put the TCEs in the HW table */
        ppc_md.tce_build(tbl, entry, npages, (unsigned long)page & IOMMU_PAGE_MASK,
-                        direction);
+                        direction, attrs);
 
 
        /* Flush/invalidate TLB caches if necessary */
@@ -336,7 +337,8 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
                            npages, entry, dma_addr);
 
                /* Insert into HW table */
-               ppc_md.tce_build(tbl, entry, npages, vaddr & IOMMU_PAGE_MASK, direction);
+               ppc_md.tce_build(tbl, entry, npages, vaddr & IOMMU_PAGE_MASK,
+                                direction, attrs);
 
                /* If we are in an open segment, try merging */
                if (segstart != s) {
@@ -573,7 +575,8 @@ dma_addr_t iommu_map_single(struct device *dev, struct iommu_table *tbl,
                        align = PAGE_SHIFT - IOMMU_PAGE_SHIFT;
 
                dma_handle = iommu_alloc(dev, tbl, vaddr, npages, direction,
-                                        mask >> IOMMU_PAGE_SHIFT, align);
+                                        mask >> IOMMU_PAGE_SHIFT, align,
+                                        attrs);
                if (dma_handle == DMA_ERROR_CODE) {
                        if (printk_ratelimit())  {
                                printk(KERN_INFO "iommu_alloc failed, "
@@ -642,7 +645,7 @@ void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl,
        nio_pages = size >> IOMMU_PAGE_SHIFT;
        io_order = get_iommu_order(size);
        mapping = iommu_alloc(dev, tbl, ret, nio_pages, DMA_BIDIRECTIONAL,
-                             mask >> IOMMU_PAGE_SHIFT, io_order);
+                             mask >> IOMMU_PAGE_SHIFT, io_order, NULL);
        if (mapping == DMA_ERROR_CODE) {
                free_pages((unsigned long)ret, order);
                return NULL;
index 063cdd4..224e9a1 100644 (file)
@@ -598,6 +598,7 @@ void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose,
                        res->start = pci_addr;
                        break;
                case 2:         /* PCI Memory space */
+               case 3:         /* PCI 64 bits Memory space */
                        printk(KERN_INFO
                               " MEM 0x%016llx..0x%016llx -> 0x%016llx %s\n",
                               cpu_addr, cpu_addr + size - 1, pci_addr,
index 90eb3a3..bc1fb27 100644 (file)
@@ -128,12 +128,35 @@ static void of_bus_pci_count_cells(struct device_node *np,
                *sizec = 2;
 }
 
+static unsigned int of_bus_pci_get_flags(const u32 *addr)
+{
+       unsigned int flags = 0;
+       u32 w = addr[0];
+
+       switch((w >> 24) & 0x03) {
+       case 0x01:
+               flags |= IORESOURCE_IO;
+               break;
+       case 0x02: /* 32 bits */
+       case 0x03: /* 64 bits */
+               flags |= IORESOURCE_MEM;
+               break;
+       }
+       if (w & 0x40000000)
+               flags |= IORESOURCE_PREFETCH;
+       return flags;
+}
+
 static u64 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna)
 {
        u64 cp, s, da;
+       unsigned int af, rf;
+
+       af = of_bus_pci_get_flags(addr);
+       rf = of_bus_pci_get_flags(range);
 
        /* Check address type match */
-       if ((addr[0] ^ range[0]) & 0x03000000)
+       if ((af ^ rf) & (IORESOURCE_MEM | IORESOURCE_IO))
                return OF_BAD_ADDR;
 
        /* Read address values, skipping high cell */
@@ -153,25 +176,6 @@ static int of_bus_pci_translate(u32 *addr, u64 offset, int na)
        return of_bus_default_translate(addr + 1, offset, na - 1);
 }
 
-static unsigned int of_bus_pci_get_flags(const u32 *addr)
-{
-       unsigned int flags = 0;
-       u32 w = addr[0];
-
-       switch((w >> 24) & 0x03) {
-       case 0x01:
-               flags |= IORESOURCE_IO;
-               break;
-       case 0x02: /* 32 bits */
-       case 0x03: /* 64 bits */
-               flags |= IORESOURCE_MEM;
-               break;
-       }
-       if (w & 0x40000000)
-               flags |= IORESOURCE_PREFETCH;
-       return flags;
-}
-
 const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
                        unsigned int *flags)
 {
index 071bee3..f258964 100644 (file)
@@ -59,6 +59,6 @@ EXPORT_SYMBOL_GPL(save_stack_trace);
 
 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 {
-       save_context_stack(trace, tsk->thread.regs->gpr[1], tsk, 0);
+       save_context_stack(trace, tsk->thread.ksp, tsk, 0);
 }
 EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
index c8127f8..aba0ba9 100644 (file)
@@ -28,7 +28,9 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices);
 /* Time in microseconds we delay before sleeping in the idle loop */
 DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 };
 
-static ssize_t store_smt_snooze_delay(struct sys_device *dev, const char *buf,
+static ssize_t store_smt_snooze_delay(struct sys_device *dev,
+                                     struct sysdev_attribute *attr,
+                                     const char *buf,
                                      size_t count)
 {
        struct cpu *cpu = container_of(dev, struct cpu, sysdev);
@@ -44,7 +46,9 @@ static ssize_t store_smt_snooze_delay(struct sys_device *dev, const char *buf,
        return count;
 }
 
-static ssize_t show_smt_snooze_delay(struct sys_device *dev, char *buf)
+static ssize_t show_smt_snooze_delay(struct sys_device *dev,
+                                    struct sysdev_attribute *attr,
+                                    char *buf)
 {
        struct cpu *cpu = container_of(dev, struct cpu, sysdev);
 
@@ -152,14 +156,17 @@ static unsigned long write_##NAME(unsigned long val) \
        mtspr(ADDRESS, val); \
        return 0; \
 } \
-static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
+static ssize_t show_##NAME(struct sys_device *dev, \
+                       struct sysdev_attribute *attr, \
+                       char *buf) \
 { \
        struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
        unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \
        return sprintf(buf, "%lx\n", val); \
 } \
 static ssize_t __used \
-       store_##NAME(struct sys_device *dev, const char *buf, size_t count) \
+       store_##NAME(struct sys_device *dev, struct sysdev_attribute *attr, \
+                       const char *buf, size_t count) \
 { \
        struct cpu *cpu = container_of(dev, struct cpu, sysdev); \
        unsigned long val; \
index 87a72c6..a914411 100644 (file)
@@ -9,6 +9,25 @@
 
 ENTRY(_stext)
 
+PHDRS {
+       kernel PT_LOAD FLAGS(7); /* RWX */
+       notes PT_NOTE FLAGS(0);
+       dummy PT_NOTE FLAGS(0);
+
+       /* binutils < 2.18 has a bug that makes it misbehave when taking an
+          ELF file with all segments at load address 0 as input.  This
+          happens when running "strip" on vmlinux, because of the AT() magic
+          in this linker script.  People using GCC >= 4.2 won't run into
+          this problem, because the "build-id" support will put some data
+          into the "notes" segment (at a non-zero load address).
+
+          To work around this, we force some data into both the "dummy"
+          segment and the kernel segment, so the dummy segment will get a
+          non-zero load address.  It's not enough to always create the
+          "notes" segment, since if nothing gets assigned to it, its load
+          address will be zero.  */
+}
+
 #ifdef CONFIG_PPC64
 OUTPUT_ARCH(powerpc:common64)
 jiffies = jiffies_64;
@@ -50,7 +69,7 @@ SECTIONS
                . = ALIGN(PAGE_SIZE);
                _etext = .;
                PROVIDE32 (etext = .);
-       }
+       } :kernel
 
        /* Read-only data */
        RODATA
@@ -62,7 +81,13 @@ SECTIONS
                __stop___ex_table = .;
        }
 
-       NOTES
+       NOTES :kernel :notes
+
+       /* The dummy segment contents for the bug workaround mentioned above
+          near PHDRS.  */
+       .dummy : {
+               LONG(0xf177)
+       } :kernel :dummy
 
 /*
  * Init sections discarded at runtime
@@ -74,7 +99,7 @@ SECTIONS
                _sinittext = .;
                INIT_TEXT
                _einittext = .;
-       }
+       } :kernel
 
        /* .exit.text is discarded at runtime, not link time,
         * to deal with references from __bug_table
index 4e43702..8c5a03b 100644 (file)
@@ -99,7 +99,7 @@ void do_feature_fixups(unsigned long value, void *fixup_start, void *fixup_end)
 
        for (; fcur < fend; fcur++) {
                if (patch_feature_section(value, fcur)) {
-                       __WARN();
+                       WARN_ON(1);
                        printk("Unable to patch feature section at %p - %p" \
                                " with %p - %p\n",
                                calc_addr(fcur, fcur->start_off),
index 49eb1f1..64e2e49 100644 (file)
 #include <asm/ppc_asm.h>
 
        .section __ex_table,"a"
-#ifdef CONFIG_PPC64
-       .align  3
-#define EXTBL  .llong
-#else
-       .align  2
-#define EXTBL  .long
-#endif
+       PPC_LONG_ALIGN
        .text
        
 _GLOBAL(strcpy)
@@ -160,9 +154,9 @@ _GLOBAL(__clear_user)
        blr
 
        .section __ex_table,"a"
-       EXTBL   11b,90b
-       EXTBL   1b,91b
-       EXTBL   8b,92b
+       PPC_LONG        11b,90b
+       PPC_LONG        1b,91b
+       PPC_LONG        8b,92b
        .text
 
 _GLOBAL(__strncpy_from_user)
@@ -183,7 +177,7 @@ _GLOBAL(__strncpy_from_user)
        blr
 
        .section __ex_table,"a"
-       EXTBL   1b,99b
+       PPC_LONG        1b,99b
        .text
 
 /* r3 = str, r4 = len (> 0), r5 = top (highest addr) */
@@ -208,4 +202,4 @@ _GLOBAL(__strnlen_user)
        blr
 
        .section __ex_table,"a"
-       EXTBL   1b,99b
+       PPC_LONG        1b,99b
index acd2fc8..d664b1b 100644 (file)
@@ -3,6 +3,7 @@ config PPC_MPC52xx
        depends on PPC_MULTIPLATFORM && PPC32
        select FSL_SOC
        select PPC_CLOCK
+       select PPC_PCI_CHOICE
 
 config PPC_MPC5200_SIMPLE
        bool "Generic support for simple MPC5200 based boards"
index 1c8034b..75eb1ed 100644 (file)
@@ -30,6 +30,7 @@ config EP8248E
        select 8272
        select 8260
        select FSL_SOC
+       select PHYLIB
        select MDIO_BITBANG
        help
          This enables support for the Embedded Planet EP8248E board.
index 373e993..d5770fd 100644 (file)
@@ -59,7 +59,6 @@ static void __init ep8248e_pic_init(void)
        of_node_put(np);
 }
 
-#ifdef CONFIG_FS_ENET_MDIO_FCC
 static void ep8248e_set_mdc(struct mdiobb_ctrl *ctrl, int level)
 {
        if (level)
@@ -165,7 +164,6 @@ static struct of_platform_driver ep8248e_mdio_driver = {
        .probe = ep8248e_mdio_probe,
        .remove = ep8248e_mdio_remove,
 };
-#endif
 
 struct cpm_pin {
        int port, pin, flags;
@@ -298,9 +296,7 @@ static  __initdata struct of_device_id of_bus_ids[] = {
 static int __init declare_of_platform_devices(void)
 {
        of_platform_bus_probe(NULL, of_bus_ids, NULL);
-#ifdef CONFIG_FS_ENET_MDIO_FCC
        of_register_platform_driver(&ep8248e_mdio_driver);
-#endif
 
        return 0;
 }
index 27d9bf8..6159c5d 100644 (file)
@@ -2,7 +2,8 @@ menuconfig PPC_83xx
        bool "83xx-based boards"
        depends on 6xx && PPC_MULTIPLATFORM
        select PPC_UDBG_16550
-       select PPC_INDIRECT_PCI
+       select PPC_PCI_CHOICE
+       select FSL_PCI if PCI
        select FSL_SOC
        select IPIC
 
index f331fd7..ba5028e 100644 (file)
@@ -2,7 +2,7 @@
 # Makefile for the PowerPC 83xx linux kernel.
 #
 obj-y                          := misc.o usb.o
-obj-$(CONFIG_PCI)              += pci.o
+obj-$(CONFIG_SUSPEND)          += suspend.o suspend-asm.o
 obj-$(CONFIG_MPC831x_RDB)      += mpc831x_rdb.o
 obj-$(CONFIG_MPC832x_RDB)      += mpc832x_rdb.o
 obj-$(CONFIG_MPC834x_MDS)      += mpc834x_mds.o
index c4db517..a428f8d 100644 (file)
@@ -19,6 +19,7 @@
 #include <asm/time.h>
 #include <asm/ipic.h>
 #include <asm/udbg.h>
+#include <sysdev/fsl_pci.h>
 
 #include "mpc83xx.h"
 
index 6dbc6ea..dd4be4a 100644 (file)
@@ -36,6 +36,7 @@
 #include <asm/prom.h>
 #include <asm/udbg.h>
 #include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
 #include <asm/qe.h>
 #include <asm/qe_ic.h>
 
index e7f706b..f049d69 100644 (file)
@@ -27,6 +27,7 @@
 #include <asm/qe.h>
 #include <asm/qe_ic.h>
 #include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
 
 #include "mpc83xx.h"
 
index 50e8f63..7301d77 100644 (file)
@@ -35,6 +35,7 @@
 #include <asm/prom.h>
 #include <asm/udbg.h>
 #include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
 
 #include "mpc83xx.h"
 
index 2b8a0a3..30d509a 100644 (file)
@@ -35,6 +35,7 @@
 #include <asm/prom.h>
 #include <asm/udbg.h>
 #include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
 
 #include "mpc83xx.h"
 
index c2e5de6..75b80e8 100644 (file)
@@ -42,6 +42,7 @@
 #include <asm/prom.h>
 #include <asm/udbg.h>
 #include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
 #include <asm/qe.h>
 #include <asm/qe_ic.h>
 
index c10dec4..a5273bb 100644 (file)
@@ -23,6 +23,7 @@
 #include <asm/qe.h>
 #include <asm/qe_ic.h>
 #include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
 
 #include "mpc83xx.h"
 
index 64d17b0..be62de2 100644 (file)
@@ -19,6 +19,7 @@
 #include <asm/ipic.h>
 #include <asm/udbg.h>
 #include <asm/prom.h>
+#include <sysdev/fsl_pci.h>
 
 #include "mpc83xx.h"
 
index c00356b..da030af 100644 (file)
@@ -17,6 +17,7 @@
 #include <asm/time.h>
 #include <asm/ipic.h>
 #include <asm/udbg.h>
+#include <sysdev/fsl_pci.h>
 
 #include "mpc83xx.h"
 
index 88a3b5c..2a7cbab 100644 (file)
@@ -26,6 +26,8 @@
 #define MPC834X_SICRL_USB1         0x20000000
 #define MPC831X_SICRL_USB_MASK     0x00000c00
 #define MPC831X_SICRL_USB_ULPI     0x00000800
+#define MPC8315_SICRL_USB_MASK     0x000000fc
+#define MPC8315_SICRL_USB_ULPI     0x00000054
 #define MPC837X_SICRL_USB_MASK     0xf0000000
 #define MPC837X_SICRL_USB_ULPI     0x50000000
 
@@ -34,6 +36,8 @@
 #define MPC834X_SICRH_USB_UTMI     0x00020000
 #define MPC831X_SICRH_USB_MASK     0x000000e0
 #define MPC831X_SICRH_USB_ULPI     0x000000a0
+#define MPC8315_SICRH_USB_MASK     0x0000ff00
+#define MPC8315_SICRH_USB_ULPI     0x00000000
 
 /* USB Control Register */
 #define FSL_USB2_CONTROL_OFFS      0x500
@@ -55,7 +59,6 @@
  * mpc83xx_* files. Mostly for use by mpc83xx_setup
  */
 
-extern int mpc83xx_add_bridge(struct device_node *dev);
 extern void mpc83xx_restart(char *cmd);
 extern long mpc83xx_time_init(void);
 extern int mpc834x_usb_cfg(void);
diff --git a/arch/powerpc/platforms/83xx/pci.c b/arch/powerpc/platforms/83xx/pci.c
deleted file mode 100644 (file)
index 14f1080..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * FSL SoC setup code
- *
- * Maintained by Kumar Gala (see MAINTAINERS for contact information)
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/pci.h>
-#include <linux/delay.h>
-#include <linux/irq.h>
-#include <linux/module.h>
-
-#include <asm/system.h>
-#include <asm/atomic.h>
-#include <asm/io.h>
-#include <asm/pci-bridge.h>
-#include <asm/prom.h>
-#include <sysdev/fsl_soc.h>
-
-#undef DEBUG
-
-#ifdef DEBUG
-#define DBG(x...) printk(x)
-#else
-#define DBG(x...)
-#endif
-
-int __init mpc83xx_add_bridge(struct device_node *dev)
-{
-       int len;
-       struct pci_controller *hose;
-       struct resource rsrc;
-       const int *bus_range;
-       int primary = 1, has_address = 0;
-       phys_addr_t immr = get_immrbase();
-
-       DBG("Adding PCI host bridge %s\n", dev->full_name);
-
-       /* Fetch host bridge registers address */
-       has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
-
-       /* Get bus range if any */
-       bus_range = of_get_property(dev, "bus-range", &len);
-       if (bus_range == NULL || len < 2 * sizeof(int)) {
-               printk(KERN_WARNING "Can't get bus-range for %s, assume"
-                      " bus 0\n", dev->full_name);
-       }
-
-       ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;
-       hose = pcibios_alloc_controller(dev);
-       if (!hose)
-               return -ENOMEM;
-
-       hose->first_busno = bus_range ? bus_range[0] : 0;
-       hose->last_busno = bus_range ? bus_range[1] : 0xff;
-
-       /* MPC83xx supports up to two host controllers one at 0x8500 from immrbar
-        * the other at 0x8600, we consider the 0x8500 the primary controller
-        */
-       /* PCI 1 */
-       if ((rsrc.start & 0xfffff) == 0x8500) {
-               setup_indirect_pci(hose, immr + 0x8300, immr + 0x8304, 0);
-       }
-       /* PCI 2 */
-       if ((rsrc.start & 0xfffff) == 0x8600) {
-               setup_indirect_pci(hose, immr + 0x8380, immr + 0x8384, 0);
-               primary = 0;
-       }
-
-       printk(KERN_INFO "Found MPC83xx PCI host bridge at 0x%016llx. "
-              "Firmware bus number: %d->%d\n",
-              (unsigned long long)rsrc.start, hose->first_busno,
-              hose->last_busno);
-
-       DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
-           hose, hose->cfg_addr, hose->cfg_data);
-
-       /* Interpret the "ranges" property */
-       /* This also maps the I/O region and sets isa_io/mem_base */
-       pci_process_bridge_OF_ranges(hose, dev, primary);
-
-       return 0;
-}
index cf38247..fc21f5c 100644 (file)
@@ -37,6 +37,7 @@
 #include <asm/prom.h>
 #include <asm/udbg.h>
 #include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
 
 #include "mpc83xx.h"
 
diff --git a/arch/powerpc/platforms/83xx/suspend-asm.S b/arch/powerpc/platforms/83xx/suspend-asm.S
new file mode 100644 (file)
index 0000000..1930543
--- /dev/null
@@ -0,0 +1,533 @@
+/*
+ * Enter and leave deep sleep state on MPC83xx
+ *
+ * Copyright (c) 2006-2008 Freescale Semiconductor, Inc.
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <asm/page.h>
+#include <asm/ppc_asm.h>
+#include <asm/reg.h>
+#include <asm/asm-offsets.h>
+
+#define SS_MEMSAVE     0x00 /* First 8 bytes of RAM */
+#define SS_HID         0x08 /* 3 HIDs */
+#define SS_IABR                0x14 /* 2 IABRs */
+#define SS_IBCR                0x1c
+#define SS_DABR                0x20 /* 2 DABRs */
+#define SS_DBCR                0x28
+#define SS_SP          0x2c
+#define SS_SR          0x30 /* 16 segment registers */
+#define SS_R2          0x70
+#define SS_MSR         0x74
+#define SS_SDR1                0x78
+#define SS_LR          0x7c
+#define SS_SPRG                0x80 /* 4 SPRGs */
+#define SS_DBAT                0x90 /* 8 DBATs */
+#define SS_IBAT                0xd0 /* 8 IBATs */
+#define SS_TB          0x110
+#define SS_CR          0x118
+#define SS_GPREG       0x11c /* r12-r31 */
+#define STATE_SAVE_SIZE 0x16c
+
+       .section .data
+       .align  5
+
+mpc83xx_sleep_save_area:
+       .space  STATE_SAVE_SIZE
+immrbase:
+       .long   0
+
+       .section .text
+       .align  5
+
+       /* r3 = physical address of IMMR */
+_GLOBAL(mpc83xx_enter_deep_sleep)
+       lis     r4, immrbase@ha
+       stw     r3, immrbase@l(r4)
+
+       /* The first 2 words of memory are used to communicate with the
+        * bootloader, to tell it how to resume.
+        *
+        * The first word is the magic number 0xf5153ae5, and the second
+        * is the pointer to mpc83xx_deep_resume.
+        *
+        * The original content of these two words is saved in SS_MEMSAVE.
+        */
+
+       lis     r3, mpc83xx_sleep_save_area@h
+       ori     r3, r3, mpc83xx_sleep_save_area@l
+
+       lis     r4, KERNELBASE@h
+       lwz     r5, 0(r4)
+       lwz     r6, 4(r4)
+
+       stw     r5, SS_MEMSAVE+0(r3)
+       stw     r6, SS_MEMSAVE+4(r3)
+
+       mfspr   r5, SPRN_HID0
+       mfspr   r6, SPRN_HID1
+       mfspr   r7, SPRN_HID2
+
+       stw     r5, SS_HID+0(r3)
+       stw     r6, SS_HID+4(r3)
+       stw     r7, SS_HID+8(r3)
+
+       mfspr   r4, SPRN_IABR
+       mfspr   r5, SPRN_IABR2
+       mfspr   r6, SPRN_IBCR
+       mfspr   r7, SPRN_DABR
+       mfspr   r8, SPRN_DABR2
+       mfspr   r9, SPRN_DBCR
+
+       stw     r4, SS_IABR+0(r3)
+       stw     r5, SS_IABR+4(r3)
+       stw     r6, SS_IBCR(r3)
+       stw     r7, SS_DABR+0(r3)
+       stw     r8, SS_DABR+4(r3)
+       stw     r9, SS_DBCR(r3)
+
+       mfspr   r4, SPRN_SPRG0
+       mfspr   r5, SPRN_SPRG1
+       mfspr   r6, SPRN_SPRG2
+       mfspr   r7, SPRN_SPRG3
+       mfsdr1  r8
+
+       stw     r4, SS_SPRG+0(r3)
+       stw     r5, SS_SPRG+4(r3)
+       stw     r6, SS_SPRG+8(r3)
+       stw     r7, SS_SPRG+12(r3)
+       stw     r8, SS_SDR1(r3)
+
+       mfspr   r4, SPRN_DBAT0U
+       mfspr   r5, SPRN_DBAT0L
+       mfspr   r6, SPRN_DBAT1U
+       mfspr   r7, SPRN_DBAT1L
+
+       stw     r4, SS_DBAT+0x00(r3)
+       stw     r5, SS_DBAT+0x04(r3)
+       stw     r6, SS_DBAT+0x08(r3)
+       stw     r7, SS_DBAT+0x0c(r3)
+
+       mfspr   r4, SPRN_DBAT2U
+       mfspr   r5, SPRN_DBAT2L
+       mfspr   r6, SPRN_DBAT3U
+       mfspr   r7, SPRN_DBAT3L
+
+       stw     r4, SS_DBAT+0x10(r3)
+       stw     r5, SS_DBAT+0x14(r3)
+       stw     r6, SS_DBAT+0x18(r3)
+       stw     r7, SS_DBAT+0x1c(r3)
+
+       mfspr   r4, SPRN_DBAT4U
+       mfspr   r5, SPRN_DBAT4L
+       mfspr   r6, SPRN_DBAT5U
+       mfspr   r7, SPRN_DBAT5L
+
+       stw     r4, SS_DBAT+0x20(r3)
+       stw     r5, SS_DBAT+0x24(r3)
+       stw     r6, SS_DBAT+0x28(r3)
+       stw     r7, SS_DBAT+0x2c(r3)
+
+       mfspr   r4, SPRN_DBAT6U
+       mfspr   r5, SPRN_DBAT6L
+       mfspr   r6, SPRN_DBAT7U
+       mfspr   r7, SPRN_DBAT7L
+
+       stw     r4, SS_DBAT+0x30(r3)
+       stw     r5, SS_DBAT+0x34(r3)
+       stw     r6, SS_DBAT+0x38(r3)
+       stw     r7, SS_DBAT+0x3c(r3)
+
+       mfspr   r4, SPRN_IBAT0U
+       mfspr   r5, SPRN_IBAT0L
+       mfspr   r6, SPRN_IBAT1U
+       mfspr   r7, SPRN_IBAT1L
+
+       stw     r4, SS_IBAT+0x00(r3)
+       stw     r5, SS_IBAT+0x04(r3)
+       stw     r6, SS_IBAT+0x08(r3)
+       stw     r7, SS_IBAT+0x0c(r3)
+
+       mfspr   r4, SPRN_IBAT2U
+       mfspr   r5, SPRN_IBAT2L
+       mfspr   r6, SPRN_IBAT3U
+       mfspr   r7, SPRN_IBAT3L
+
+       stw     r4, SS_IBAT+0x10(r3)
+       stw     r5, SS_IBAT+0x14(r3)
+       stw     r6, SS_IBAT+0x18(r3)
+       stw     r7, SS_IBAT+0x1c(r3)
+
+       mfspr   r4, SPRN_IBAT4U
+       mfspr   r5, SPRN_IBAT4L
+       mfspr   r6, SPRN_IBAT5U
+       mfspr   r7, SPRN_IBAT5L
+
+       stw     r4, SS_IBAT+0x20(r3)
+       stw     r5, SS_IBAT+0x24(r3)
+       stw     r6, SS_IBAT+0x28(r3)
+       stw     r7, SS_IBAT+0x2c(r3)
+
+       mfspr   r4, SPRN_IBAT6U
+       mfspr   r5, SPRN_IBAT6L
+       mfspr   r6, SPRN_IBAT7U
+       mfspr   r7, SPRN_IBAT7L
+
+       stw     r4, SS_IBAT+0x30(r3)
+       stw     r5, SS_IBAT+0x34(r3)
+       stw     r6, SS_IBAT+0x38(r3)
+       stw     r7, SS_IBAT+0x3c(r3)
+
+       mfmsr   r4
+       mflr    r5
+       mfcr    r6
+
+       stw     r4, SS_MSR(r3)
+       stw     r5, SS_LR(r3)
+       stw     r6, SS_CR(r3)
+       stw     r1, SS_SP(r3)
+       stw     r2, SS_R2(r3)
+
+1:     mftbu   r4
+       mftb    r5
+       mftbu   r6
+       cmpw    r4, r6
+       bne     1b
+
+       stw     r4, SS_TB+0(r3)
+       stw     r5, SS_TB+4(r3)
+
+       stmw    r12, SS_GPREG(r3)
+
+       li      r4, 0
+       addi    r6, r3, SS_SR-4
+1:     mfsrin  r5, r4
+       stwu    r5, 4(r6)
+       addis   r4, r4, 0x1000
+       cmpwi   r4, 0
+       bne     1b
+
+       /* Disable machine checks and critical exceptions */
+       mfmsr   r4
+       rlwinm  r4, r4, 0, ~MSR_CE
+       rlwinm  r4, r4, 0, ~MSR_ME
+       mtmsr   r4
+       isync
+
+#define TMP_VIRT_IMMR          0xf0000000
+#define DEFAULT_IMMR_VALUE     0xff400000
+#define IMMRBAR_BASE           0x0000
+
+       lis     r4, immrbase@ha
+       lwz     r4, immrbase@l(r4)
+
+       /* Use DBAT0 to address the current IMMR space */
+
+       ori     r4, r4, 0x002a
+       mtspr   SPRN_DBAT0L, r4
+       lis     r8, TMP_VIRT_IMMR@h
+       ori     r4, r8, 0x001e  /* 1 MByte accessable from Kernel Space only */
+       mtspr   SPRN_DBAT0U, r4
+       isync
+
+       /* Use DBAT1 to address the original IMMR space */
+
+       lis     r4, DEFAULT_IMMR_VALUE@h
+       ori     r4, r4, 0x002a
+       mtspr   SPRN_DBAT1L, r4
+       lis     r9, (TMP_VIRT_IMMR + 0x01000000)@h
+       ori     r4, r9, 0x001e  /* 1 MByte accessable from Kernel Space only */
+       mtspr   SPRN_DBAT1U, r4
+       isync
+
+       /* Use DBAT2 to address the beginning of RAM.  This isn't done
+        * using the normal virtual mapping, because with page debugging
+        * enabled it will be read-only.
+        */
+
+       li      r4, 0x0002
+       mtspr   SPRN_DBAT2L, r4
+       lis     r4, KERNELBASE@h
+       ori     r4, r4, 0x001e  /* 1 MByte accessable from Kernel Space only */
+       mtspr   SPRN_DBAT2U, r4
+       isync
+
+       /* Flush the cache with our BAT, as there will be TLB misses
+        * otherwise if page debugging is enabled, and these misses
+        * will disturb the PLRU algorithm.
+        */
+
+       bl      __flush_disable_L1
+
+       /* Keep the i-cache enabled, so the hack below for low-boot
+        * flash will work.
+        */
+       mfspr   r3, SPRN_HID0
+       ori     r3, r3, HID0_ICE
+       mtspr   SPRN_HID0, r3
+       isync
+
+       lis     r6, 0xf515
+       ori     r6, r6, 0x3ae5
+
+       lis     r7, mpc83xx_deep_resume@h
+       ori     r7, r7, mpc83xx_deep_resume@l
+       tophys(r7, r7)
+
+       lis     r5, KERNELBASE@h
+       stw     r6, 0(r5)
+       stw     r7, 4(r5)
+
+       /* Reset BARs */
+
+       li      r4, 0
+       stw     r4, 0x0024(r8)
+       stw     r4, 0x002c(r8)
+       stw     r4, 0x0034(r8)
+       stw     r4, 0x003c(r8)
+       stw     r4, 0x0064(r8)
+       stw     r4, 0x006c(r8)
+
+       /* Rev 1 of the 8313 has problems with wakeup events that are
+        * pending during the transition to deep sleep state (such as if
+        * the PCI host sets the state to D3 and then D0 in rapid
+        * succession).  This check shrinks the race window somewhat.
+        *
+        * See erratum PCI23, though the problem is not limited
+        * to PCI.
+        */
+
+       lwz     r3, 0x0b04(r8)
+       andi.   r3, r3, 1
+       bne-    mpc83xx_deep_resume
+
+       /* Move IMMR back to the default location, following the
+        * procedure specified in the MPC8313 manual.
+        */
+       lwz     r4, IMMRBAR_BASE(r8)
+       isync
+       lis     r4, DEFAULT_IMMR_VALUE@h
+       stw     r4, IMMRBAR_BASE(r8)
+       lis     r4, KERNELBASE@h
+       lwz     r4, 0(r4)
+       isync
+       lwz     r4, IMMRBAR_BASE(r9)
+       mr      r8, r9
+       isync
+
+       /* Check the Reset Configuration Word to see whether flash needs
+        * to be mapped at a low address or a high address.
+        */
+
+       lwz     r4, 0x0904(r8)
+       andis.  r4, r4, 0x0400
+       li      r4, 0
+       beq     boot_low
+       lis     r4, 0xff80
+boot_low:
+       stw     r4, 0x0020(r8)
+       lis     r7, 0x8000
+       ori     r7, r7, 0x0016
+
+       mfspr   r5, SPRN_HID0
+       rlwinm  r5, r5, 0, ~(HID0_DOZE | HID0_NAP)
+       oris    r5, r5, HID0_SLEEP@h
+       mtspr   SPRN_HID0, r5
+       isync
+
+       mfmsr   r5
+       oris    r5, r5, MSR_POW@h
+
+       /* Enable the flash mapping at the appropriate address.  This
+        * mapping will override the RAM mapping if booting low, so there's
+        * no need to disable the latter.  This must be done inside the same
+        * cache line as setting MSR_POW, so that no instruction fetches
+        * from RAM happen after the flash mapping is turned on.
+        */
+
+       .align  5
+       stw     r7, 0x0024(r8)
+       sync
+       isync
+       mtmsr   r5
+       isync
+1:     b       1b
+
+mpc83xx_deep_resume:
+       lis     r4, 1f@h
+       ori     r4, r4, 1f@l
+       tophys(r4, r4)
+       mtsrr0  r4
+
+       mfmsr   r4
+       rlwinm  r4, r4, 0, ~(MSR_IR | MSR_DR)
+       mtsrr1  r4
+
+       rfi
+
+1:     tlbia
+       bl      __inval_enable_L1
+
+       lis     r3, mpc83xx_sleep_save_area@h
+       ori     r3, r3, mpc83xx_sleep_save_area@l
+       tophys(r3, r3)
+
+       lwz     r5, SS_MEMSAVE+0(r3)
+       lwz     r6, SS_MEMSAVE+4(r3)
+
+       stw     r5, 0(0)
+       stw     r6, 4(0)
+
+       lwz     r5, SS_HID+0(r3)
+       lwz     r6, SS_HID+4(r3)
+       lwz     r7, SS_HID+8(r3)
+
+       mtspr   SPRN_HID0, r5
+       mtspr   SPRN_HID1, r6
+       mtspr   SPRN_HID2, r7
+
+       lwz     r4, SS_IABR+0(r3)
+       lwz     r5, SS_IABR+4(r3)
+       lwz     r6, SS_IBCR(r3)
+       lwz     r7, SS_DABR+0(r3)
+       lwz     r8, SS_DABR+4(r3)
+       lwz     r9, SS_DBCR(r3)
+
+       mtspr   SPRN_IABR, r4
+       mtspr   SPRN_IABR2, r5
+       mtspr   SPRN_IBCR, r6
+       mtspr   SPRN_DABR, r7
+       mtspr   SPRN_DABR2, r8
+       mtspr   SPRN_DBCR, r9
+
+       li      r4, 0
+       addi    r6, r3, SS_SR-4
+1:     lwzu    r5, 4(r6)
+       mtsrin  r5, r4
+       addis   r4, r4, 0x1000
+       cmpwi   r4, 0
+       bne     1b
+
+       lwz     r4, SS_DBAT+0x00(r3)
+       lwz     r5, SS_DBAT+0x04(r3)
+       lwz     r6, SS_DBAT+0x08(r3)
+       lwz     r7, SS_DBAT+0x0c(r3)
+
+       mtspr   SPRN_DBAT0U, r4
+       mtspr   SPRN_DBAT0L, r5
+       mtspr   SPRN_DBAT1U, r6
+       mtspr   SPRN_DBAT1L, r7
+
+       lwz     r4, SS_DBAT+0x10(r3)
+       lwz     r5, SS_DBAT+0x14(r3)
+       lwz     r6, SS_DBAT+0x18(r3)
+       lwz     r7, SS_DBAT+0x1c(r3)
+
+       mtspr   SPRN_DBAT2U, r4
+       mtspr   SPRN_DBAT2L, r5
+       mtspr   SPRN_DBAT3U, r6
+       mtspr   SPRN_DBAT3L, r7
+
+       lwz     r4, SS_DBAT+0x20(r3)
+       lwz     r5, SS_DBAT+0x24(r3)
+       lwz     r6, SS_DBAT+0x28(r3)
+       lwz     r7, SS_DBAT+0x2c(r3)
+
+       mtspr   SPRN_DBAT4U, r4
+       mtspr   SPRN_DBAT4L, r5
+       mtspr   SPRN_DBAT5U, r6
+       mtspr   SPRN_DBAT5L, r7
+
+       lwz     r4, SS_DBAT+0x30(r3)
+       lwz     r5, SS_DBAT+0x34(r3)
+       lwz     r6, SS_DBAT+0x38(r3)
+       lwz     r7, SS_DBAT+0x3c(r3)
+
+       mtspr   SPRN_DBAT6U, r4
+       mtspr   SPRN_DBAT6L, r5
+       mtspr   SPRN_DBAT7U, r6
+       mtspr   SPRN_DBAT7L, r7
+
+       lwz     r4, SS_IBAT+0x00(r3)
+       lwz     r5, SS_IBAT+0x04(r3)
+       lwz     r6, SS_IBAT+0x08(r3)
+       lwz     r7, SS_IBAT+0x0c(r3)
+
+       mtspr   SPRN_IBAT0U, r4
+       mtspr   SPRN_IBAT0L, r5
+       mtspr   SPRN_IBAT1U, r6
+       mtspr   SPRN_IBAT1L, r7
+
+       lwz     r4, SS_IBAT+0x10(r3)
+       lwz     r5, SS_IBAT+0x14(r3)
+       lwz     r6, SS_IBAT+0x18(r3)
+       lwz     r7, SS_IBAT+0x1c(r3)
+
+       mtspr   SPRN_IBAT2U, r4
+       mtspr   SPRN_IBAT2L, r5
+       mtspr   SPRN_IBAT3U, r6
+       mtspr   SPRN_IBAT3L, r7
+
+       lwz     r4, SS_IBAT+0x20(r3)
+       lwz     r5, SS_IBAT+0x24(r3)
+       lwz     r6, SS_IBAT+0x28(r3)
+       lwz     r7, SS_IBAT+0x2c(r3)
+
+       mtspr   SPRN_IBAT4U, r4
+       mtspr   SPRN_IBAT4L, r5
+       mtspr   SPRN_IBAT5U, r6
+       mtspr   SPRN_IBAT5L, r7
+
+       lwz     r4, SS_IBAT+0x30(r3)
+       lwz     r5, SS_IBAT+0x34(r3)
+       lwz     r6, SS_IBAT+0x38(r3)
+       lwz     r7, SS_IBAT+0x3c(r3)
+
+       mtspr   SPRN_IBAT6U, r4
+       mtspr   SPRN_IBAT6L, r5
+       mtspr   SPRN_IBAT7U, r6
+       mtspr   SPRN_IBAT7L, r7
+
+       lwz     r4, SS_SPRG+0(r3)
+       lwz     r5, SS_SPRG+4(r3)
+       lwz     r6, SS_SPRG+8(r3)
+       lwz     r7, SS_SPRG+12(r3)
+       lwz     r8, SS_SDR1(r3)
+
+       mtspr   SPRN_SPRG0, r4
+       mtspr   SPRN_SPRG1, r5
+       mtspr   SPRN_SPRG2, r6
+       mtspr   SPRN_SPRG3, r7
+       mtsdr1  r8
+
+       lwz     r4, SS_MSR(r3)
+       lwz     r5, SS_LR(r3)
+       lwz     r6, SS_CR(r3)
+       lwz     r1, SS_SP(r3)
+       lwz     r2, SS_R2(r3)
+
+       mtsrr1  r4
+       mtsrr0  r5
+       mtcr    r6
+
+       li      r4, 0
+       mtspr   SPRN_TBWL, r4
+
+       lwz     r4, SS_TB+0(r3)
+       lwz     r5, SS_TB+4(r3)
+
+       mtspr   SPRN_TBWU, r4
+       mtspr   SPRN_TBWL, r5
+
+       lmw     r12, SS_GPREG(r3)
+
+       /* Kick decrementer */
+       li      r0, 1
+       mtdec   r0
+
+       rfi
diff --git a/arch/powerpc/platforms/83xx/suspend.c b/arch/powerpc/platforms/83xx/suspend.c
new file mode 100644 (file)
index 0000000..08e65fc
--- /dev/null
@@ -0,0 +1,388 @@
+/*
+ * MPC83xx suspend support
+ *
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * Copyright (c) 2006-2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include <linux/init.h>
+#include <linux/pm.h>
+#include <linux/types.h>
+#include <linux/ioport.h>
+#include <linux/interrupt.h>
+#include <linux/wait.h>
+#include <linux/kthread.h>
+#include <linux/freezer.h>
+#include <linux/suspend.h>
+#include <linux/fsl_devices.h>
+#include <linux/of_platform.h>
+
+#include <asm/reg.h>
+#include <asm/io.h>
+#include <asm/time.h>
+#include <asm/mpc6xx.h>
+
+#include <sysdev/fsl_soc.h>
+
+#define PMCCR1_NEXT_STATE       0x0C /* Next state for power management */
+#define PMCCR1_NEXT_STATE_SHIFT 2
+#define PMCCR1_CURR_STATE       0x03 /* Current state for power management*/
+#define IMMR_RCW_OFFSET         0x900
+#define RCW_PCI_HOST            0x80000000
+
+void mpc83xx_enter_deep_sleep(phys_addr_t immrbase);
+
+struct mpc83xx_pmc {
+       u32 config;
+#define PMCCR_DLPEN 2 /* DDR SDRAM low power enable */
+#define PMCCR_SLPEN 1 /* System low power enable */
+
+       u32 event;
+       u32 mask;
+/* All but PMCI are deep-sleep only */
+#define PMCER_GPIO   0x100
+#define PMCER_PCI    0x080
+#define PMCER_USB    0x040
+#define PMCER_ETSEC1 0x020
+#define PMCER_ETSEC2 0x010
+#define PMCER_TIMER  0x008
+#define PMCER_INT1   0x004
+#define PMCER_INT2   0x002
+#define PMCER_PMCI   0x001
+#define PMCER_ALL    0x1FF
+
+       /* deep-sleep only */
+       u32 config1;
+#define PMCCR1_USE_STATE  0x80000000
+#define PMCCR1_PME_EN     0x00000080
+#define PMCCR1_ASSERT_PME 0x00000040
+#define PMCCR1_POWER_OFF  0x00000020
+
+       /* deep-sleep only */
+       u32 config2;
+};
+
+struct mpc83xx_rcw {
+       u32 rcwlr;
+       u32 rcwhr;
+};
+
+struct mpc83xx_clock {
+       u32 spmr;
+       u32 occr;
+       u32 sccr;
+};
+
+struct pmc_type {
+       int has_deep_sleep;
+};
+
+static struct of_device *pmc_dev;
+static int has_deep_sleep, deep_sleeping;
+static int pmc_irq;
+static struct mpc83xx_pmc __iomem *pmc_regs;
+static struct mpc83xx_clock __iomem *clock_regs;
+static int is_pci_agent, wake_from_pci;
+static phys_addr_t immrbase;
+static int pci_pm_state;
+static DECLARE_WAIT_QUEUE_HEAD(agent_wq);
+
+int fsl_deep_sleep(void)
+{
+       return deep_sleeping;
+}
+
+static int mpc83xx_change_state(void)
+{
+       u32 curr_state;
+       u32 reg_cfg1 = in_be32(&pmc_regs->config1);
+
+       if (is_pci_agent) {
+               pci_pm_state = (reg_cfg1 & PMCCR1_NEXT_STATE) >>
+                              PMCCR1_NEXT_STATE_SHIFT;
+               curr_state = reg_cfg1 & PMCCR1_CURR_STATE;
+
+               if (curr_state != pci_pm_state) {
+                       reg_cfg1 &= ~PMCCR1_CURR_STATE;
+                       reg_cfg1 |= pci_pm_state;
+                       out_be32(&pmc_regs->config1, reg_cfg1);
+
+                       wake_up(&agent_wq);
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
+static irqreturn_t pmc_irq_handler(int irq, void *dev_id)
+{
+       u32 event = in_be32(&pmc_regs->event);
+       int ret = IRQ_NONE;
+
+       if (mpc83xx_change_state())
+               ret = IRQ_HANDLED;
+
+       if (event) {
+               out_be32(&pmc_regs->event, event);
+               ret = IRQ_HANDLED;
+       }
+
+       return ret;
+}
+
+static int mpc83xx_suspend_enter(suspend_state_t state)
+{
+       int ret = -EAGAIN;
+
+       /* Don't go to sleep if there's a race where pci_pm_state changes
+        * between the agent thread checking it and the PM code disabling
+        * interrupts.
+        */
+       if (wake_from_pci) {
+               if (pci_pm_state != (deep_sleeping ? 3 : 2))
+                       goto out;
+
+               out_be32(&pmc_regs->config1,
+                        in_be32(&pmc_regs->config1) | PMCCR1_PME_EN);
+       }
+
+       /* Put the system into low-power mode and the RAM
+        * into self-refresh mode once the core goes to
+        * sleep.
+        */
+
+       out_be32(&pmc_regs->config, PMCCR_SLPEN | PMCCR_DLPEN);
+
+       /* If it has deep sleep (i.e. it's an 831x or compatible),
+        * disable power to the core upon entering sleep mode.  This will
+        * require going through the boot firmware upon a wakeup event.
+        */
+
+       if (deep_sleeping) {
+               out_be32(&pmc_regs->mask, PMCER_ALL);
+
+               out_be32(&pmc_regs->config1,
+                        in_be32(&pmc_regs->config1) | PMCCR1_POWER_OFF);
+
+               enable_kernel_fp();
+
+               mpc83xx_enter_deep_sleep(immrbase);
+
+               out_be32(&pmc_regs->config1,
+                        in_be32(&pmc_regs->config1) & ~PMCCR1_POWER_OFF);
+
+               out_be32(&pmc_regs->mask, PMCER_PMCI);
+       } else {
+               out_be32(&pmc_regs->mask, PMCER_PMCI);
+
+               mpc6xx_enter_standby();
+       }
+
+       ret = 0;
+
+out:
+       out_be32(&pmc_regs->config1,
+                in_be32(&pmc_regs->config1) & ~PMCCR1_PME_EN);
+
+       return ret;
+}
+
+static void mpc83xx_suspend_finish(void)
+{
+       deep_sleeping = 0;
+}
+
+static int mpc83xx_suspend_valid(suspend_state_t state)
+{
+       return state == PM_SUSPEND_STANDBY || state == PM_SUSPEND_MEM;
+}
+
+static int mpc83xx_suspend_begin(suspend_state_t state)
+{
+       switch (state) {
+               case PM_SUSPEND_STANDBY:
+                       deep_sleeping = 0;
+                       return 0;
+
+               case PM_SUSPEND_MEM:
+                       if (has_deep_sleep)
+                               deep_sleeping = 1;
+
+                       return 0;
+
+               default:
+                       return -EINVAL;
+       }
+}
+
+static int agent_thread_fn(void *data)
+{
+       while (1) {
+               wait_event_interruptible(agent_wq, pci_pm_state >= 2);
+               try_to_freeze();
+
+               if (signal_pending(current) || pci_pm_state < 2)
+                       continue;
+
+               /* With a preemptible kernel (or SMP), this could race with
+                * a userspace-driven suspend request.  It's probably best
+                * to avoid mixing the two with such a configuration (or
+                * else fix it by adding a mutex to state_store that we can
+                * synchronize with).
+                */
+
+               wake_from_pci = 1;
+
+               pm_suspend(pci_pm_state == 3 ? PM_SUSPEND_MEM :
+                                              PM_SUSPEND_STANDBY);
+
+               wake_from_pci = 0;
+       }
+
+       return 0;
+}
+
+static void mpc83xx_set_agent(void)
+{
+       out_be32(&pmc_regs->config1, PMCCR1_USE_STATE);
+       out_be32(&pmc_regs->mask, PMCER_PMCI);
+
+       kthread_run(agent_thread_fn, NULL, "PCI power mgt");
+}
+
+static int mpc83xx_is_pci_agent(void)
+{
+       struct mpc83xx_rcw __iomem *rcw_regs;
+       int ret;
+
+       rcw_regs = ioremap(get_immrbase() + IMMR_RCW_OFFSET,
+                          sizeof(struct mpc83xx_rcw));
+
+       if (!rcw_regs)
+               return -ENOMEM;
+
+       ret = !(in_be32(&rcw_regs->rcwhr) & RCW_PCI_HOST);
+
+       iounmap(rcw_regs);
+       return ret;
+}
+
+static struct platform_suspend_ops mpc83xx_suspend_ops = {
+       .valid = mpc83xx_suspend_valid,
+       .begin = mpc83xx_suspend_begin,
+       .enter = mpc83xx_suspend_enter,
+       .finish = mpc83xx_suspend_finish,
+};
+
+static int pmc_probe(struct of_device *ofdev,
+                     const struct of_device_id *match)
+{
+       struct device_node *np = ofdev->node;
+       struct resource res;
+       struct pmc_type *type = match->data;
+       int ret = 0;
+
+       if (!of_device_is_available(np))
+               return -ENODEV;
+
+       has_deep_sleep = type->has_deep_sleep;
+       immrbase = get_immrbase();
+       pmc_dev = ofdev;
+
+       is_pci_agent = mpc83xx_is_pci_agent();
+       if (is_pci_agent < 0)
+               return is_pci_agent;
+
+       ret = of_address_to_resource(np, 0, &res);
+       if (ret)
+               return -ENODEV;
+
+       pmc_irq = irq_of_parse_and_map(np, 0);
+       if (pmc_irq != NO_IRQ) {
+               ret = request_irq(pmc_irq, pmc_irq_handler, IRQF_SHARED,
+                                 "pmc", ofdev);
+
+               if (ret)
+                       return -EBUSY;
+       }
+
+       pmc_regs = ioremap(res.start, sizeof(struct mpc83xx_pmc));
+
+       if (!pmc_regs) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       ret = of_address_to_resource(np, 1, &res);
+       if (ret) {
+               ret = -ENODEV;
+               goto out_pmc;
+       }
+
+       clock_regs = ioremap(res.start, sizeof(struct mpc83xx_pmc));
+
+       if (!clock_regs) {
+               ret = -ENOMEM;
+               goto out_pmc;
+       }
+
+       if (is_pci_agent)
+               mpc83xx_set_agent();
+
+       suspend_set_ops(&mpc83xx_suspend_ops);
+       return 0;
+
+out_pmc:
+       iounmap(pmc_regs);
+out:
+       if (pmc_irq != NO_IRQ)
+               free_irq(pmc_irq, ofdev);
+
+       return ret;
+}
+
+static int pmc_remove(struct of_device *ofdev)
+{
+       return -EPERM;
+};
+
+static struct pmc_type pmc_types[] = {
+       {
+               .has_deep_sleep = 1,
+       },
+       {
+               .has_deep_sleep = 0,
+       }
+};
+
+static struct of_device_id pmc_match[] = {
+       {
+               .compatible = "fsl,mpc8313-pmc",
+               .data = &pmc_types[0],
+       },
+       {
+               .compatible = "fsl,mpc8349-pmc",
+               .data = &pmc_types[1],
+       },
+       {}
+};
+
+static struct of_platform_driver pmc_driver = {
+       .name = "mpc83xx-pmc",
+       .match_table = pmc_match,
+       .probe = pmc_probe,
+       .remove = pmc_remove
+};
+
+static int pmc_init(void)
+{
+       return of_register_platform_driver(&pmc_driver);
+}
+
+module_init(pmc_init);
index 64bcf0a..cc99c28 100644 (file)
@@ -137,15 +137,21 @@ int mpc831x_usb_cfg(void)
 
        /* Configure pin mux for ULPI.  There is no pin mux for UTMI */
        if (prop && !strcmp(prop, "ulpi")) {
-               temp = in_be32(immap + MPC83XX_SICRL_OFFS);
-               temp &= ~MPC831X_SICRL_USB_MASK;
-               temp |= MPC831X_SICRL_USB_ULPI;
-               out_be32(immap + MPC83XX_SICRL_OFFS, temp);
-
-               temp = in_be32(immap + MPC83XX_SICRH_OFFS);
-               temp &= ~MPC831X_SICRH_USB_MASK;
-               temp |= MPC831X_SICRH_USB_ULPI;
-               out_be32(immap + MPC83XX_SICRH_OFFS, temp);
+               if (of_device_is_compatible(immr_node, "fsl,mpc8315-immr")) {
+                       clrsetbits_be32(immap + MPC83XX_SICRL_OFFS,
+                                       MPC8315_SICRL_USB_MASK,
+                                       MPC8315_SICRL_USB_ULPI);
+                       clrsetbits_be32(immap + MPC83XX_SICRH_OFFS,
+                                       MPC8315_SICRH_USB_MASK,
+                                       MPC8315_SICRH_USB_ULPI);
+               } else {
+                       clrsetbits_be32(immap + MPC83XX_SICRL_OFFS,
+                                       MPC831X_SICRL_USB_MASK,
+                                       MPC831X_SICRL_USB_ULPI);
+                       clrsetbits_be32(immap + MPC83XX_SICRH_OFFS,
+                                       MPC831X_SICRH_USB_MASK,
+                                       MPC831X_SICRH_USB_ULPI);
+               }
        }
 
        iounmap(immap);
index cebea5c..291675b 100644 (file)
@@ -2,8 +2,8 @@ menuconfig MPC85xx
        bool "Machine Type"
        depends on PPC_85xx
        select PPC_UDBG_16550
-       select PPC_INDIRECT_PCI if PCI
        select MPIC
+       select PPC_PCI_CHOICE
        select FSL_PCI if PCI
        select SERIAL_8250_SHARE_IRQ if SERIAL_8250
        default y
@@ -86,7 +86,6 @@ config TQM8548
        help
          This option enables support for the TQ Components TQM8548 board.
        select DEFAULT_UIMAGE
-       select PPC_CPM_NEW_BINDING
        select TQM85xx
 
 config TQM8555
index 25f41cd..00c5358 100644 (file)
@@ -115,7 +115,6 @@ void __init mpc85xx_ds_pic_init(void)
 
 #ifdef CONFIG_PCI
 static int primary_phb_addr;
-extern int uses_fsl_uli_m1575;
 extern int uli_exclude_device(struct pci_controller *hose,
                                u_char bus, u_char devfn);
 
@@ -161,7 +160,6 @@ static void __init mpc85xx_ds_setup_arch(void)
                }
        }
 
-       uses_fsl_uli_m1575 = 1;
        ppc_md.pci_exclude_device = mpc85xx_exclude_device;
 #endif
 
index 80a81e0..9355a52 100644 (file)
@@ -27,6 +27,7 @@ config SBC8641D
 config MPC8610_HPCD
        bool "Freescale MPC8610 HPCD"
        select DEFAULT_UIMAGE
+       select FSL_ULI1575
        help
          This option enables support for the MPC8610 HPCD board.
 
@@ -34,6 +35,7 @@ endif
 
 config MPC8641
        bool
+       select PPC_PCI_CHOICE
        select FSL_PCI if PCI
        select PPC_UDBG_16550
        select MPIC
@@ -41,6 +43,7 @@ config MPC8641
 
 config MPC8610
        bool
+       select PPC_PCI_CHOICE
        select FSL_PCI if PCI
        select PPC_UDBG_16550
        select MPIC
index 3072530..5eedb71 100644 (file)
@@ -58,93 +58,6 @@ static int __init mpc8610_declare_of_platform_devices(void)
 }
 machine_device_initcall(mpc86xx_hpcd, mpc8610_declare_of_platform_devices);
 
-#ifdef CONFIG_PCI
-static void __devinit quirk_uli1575(struct pci_dev *dev)
-{
-       u32 temp32;
-
-       /* Disable INTx */
-       pci_read_config_dword(dev, 0x48, &temp32);
-       pci_write_config_dword(dev, 0x48, (temp32 | 1<<26));
-
-       /* Enable sideband interrupt */
-       pci_read_config_dword(dev, 0x90, &temp32);
-       pci_write_config_dword(dev, 0x90, (temp32 | 1<<22));
-}
-
-static void __devinit quirk_uli5288(struct pci_dev *dev)
-{
-       unsigned char c;
-       unsigned short temp;
-
-       /* Interrupt Disable, Needed when SATA disabled */
-       pci_read_config_word(dev, PCI_COMMAND, &temp);
-       temp |= 1<<10;
-       pci_write_config_word(dev, PCI_COMMAND, temp);
-
-       pci_read_config_byte(dev, 0x83, &c);
-       c |= 0x80;
-       pci_write_config_byte(dev, 0x83, c);
-
-       pci_write_config_byte(dev, PCI_CLASS_PROG, 0x01);
-       pci_write_config_byte(dev, PCI_CLASS_DEVICE, 0x06);
-
-       pci_read_config_byte(dev, 0x83, &c);
-       c &= 0x7f;
-       pci_write_config_byte(dev, 0x83, c);
-}
-
-/*
- * Since 8259PIC was disabled on the board, the IDE device can not
- * use the legacy IRQ, we need to let the IDE device work under
- * native mode and use the interrupt line like other PCI devices.
- * IRQ14 is a sideband interrupt from IDE device to CPU and we use this
- * as the interrupt for IDE device.
- */
-static void __devinit quirk_uli5229(struct pci_dev *dev)
-{
-       unsigned char c;
-
-       pci_read_config_byte(dev, 0x4b, &c);
-       c |= 0x10;
-       pci_write_config_byte(dev, 0x4b, c);
-}
-
-/*
- * SATA interrupt pin bug fix
- * There's a chip bug for 5288, The interrupt pin should be 2,
- * not the read only value 1, So it use INTB#, not INTA# which
- * actually used by the IDE device 5229.
- * As of this bug, during the PCI initialization, 5288 read the
- * irq of IDE device from the device tree, this function fix this
- * bug by re-assigning a correct irq to 5288.
- *
- */
-static void __devinit final_uli5288(struct pci_dev *dev)
-{
-       struct pci_controller *hose = pci_bus_to_host(dev->bus);
-       struct device_node *hosenode = hose ? hose->dn : NULL;
-       struct of_irq oirq;
-       int virq, pin = 2;
-       u32 laddr[3];
-
-       if (!hosenode)
-               return;
-
-       laddr[0] = (hose->first_busno << 16) | (PCI_DEVFN(31, 0) << 8);
-       laddr[1] = laddr[2] = 0;
-       of_irq_map_raw(hosenode, &pin, 1, laddr, &oirq);
-       virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
-                                    oirq.size);
-       dev->irq = virq;
-}
-
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, quirk_uli1575);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5288, quirk_uli5288);
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5229, quirk_uli5229);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, 0x5288, final_uli5288);
-#endif /* CONFIG_PCI */
-
 #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
 
 static u32 get_busfreq(void)
index 7916599..f712d9c 100644 (file)
@@ -45,7 +45,6 @@
 #endif
 
 #ifdef CONFIG_PCI
-extern int uses_fsl_uli_m1575;
 extern int uli_exclude_device(struct pci_controller *hose,
                                u_char bus, u_char devfn);
 
@@ -87,7 +86,6 @@ mpc86xx_hpcn_setup_arch(void)
                        fsl_add_bridge(np, 0);
        }
 
-       uses_fsl_uli_m1575 = 1;
        ppc_md.pci_exclude_device = mpc86xx_exclude_device;
 
 #endif
index 690c1f4..1d09687 100644 (file)
@@ -253,17 +253,13 @@ config CPM2
        depends on MPC85xx || 8260
        select CPM
        select PPC_LIB_RHEAP
+       select PPC_PCI_CHOICE
        help
          The CPM2 (Communications Processor Module) is a coprocessor on
          embedded CPUs made by Freescale.  Selecting this option means that
          you wish to build a kernel for a machine with a CPM2 coprocessor
          on it (826x, 827x, 8560).
 
-config PPC_CPM_NEW_BINDING
-       bool
-       depends on CPM1 || CPM2
-       default y
-
 config AXON_RAM
        tristate "Axon DDR2 memory device driver"
        depends on PPC_IBM_CELL_BLADE
index 5bc4b61..7f65127 100644 (file)
@@ -42,12 +42,14 @@ config 40x
        select PPC_DCR_NATIVE
        select PPC_UDBG_16550
        select 4xx_SOC
+       select PPC_PCI_CHOICE
 
 config 44x
        bool "AMCC 44x"
        select PPC_DCR_NATIVE
        select PPC_UDBG_16550
        select 4xx_SOC
+       select PPC_PCI_CHOICE
 
 config E200
        bool "Freescale e200"
@@ -84,9 +86,6 @@ config TUNE_CELL
          machines. When building a kernel that is supposed to run only
          on Cell, you should also select the POWER4_ONLY option.
 
-config 6xx
-       bool
-
 # this is temp to handle compat with arch=ppc
 config 8xx
        bool
index 3959fcf..c14d7d8 100644 (file)
@@ -83,6 +83,22 @@ config CBE_RAS
        depends on PPC_CELL_NATIVE
        default y
 
+config PPC_IBM_CELL_RESETBUTTON
+       bool "IBM Cell Blade Pinhole reset button"
+       depends on CBE_RAS && PPC_IBM_CELL_BLADE
+       default y
+       help
+         Support Pinhole Resetbutton on IBM Cell blades.
+         This adds a method to trigger system reset via front panel pinhole button.
+
+config PPC_IBM_CELL_POWERBUTTON
+       tristate "IBM Cell Blade power button"
+       depends on PPC_IBM_CELL_BLADE && PPC_PMI && INPUT_EVDEV
+       default y
+       help
+         Support Powerbutton on IBM Cell blades.
+         This will enable the powerbutton as an input device.
+
 config CBE_THERM
        tristate "CBE thermal support"
        default m
@@ -107,6 +123,15 @@ config CBE_CPUFREQ_PMI
          processor will not only be able to run at lower speed,
          but also at lower core voltage.
 
+config CBE_CPUFREQ_SPU_GOVERNOR
+       tristate "CBE frequency scaling based on SPU usage"
+       depends on SPU_FS && CPU_FREQ
+       default m
+       help
+         This governor checks for spu usage to adjust the cpu frequency.
+         If no spu is running on a given cpu, that cpu will be throttled to
+         the minimal possible frequency.
+
 endmenu
 
 config OPROFILE_CELL
index c2a7e4e..7fd8308 100644 (file)
@@ -8,6 +8,9 @@ obj-$(CONFIG_CBE_THERM)                 += cbe_thermal.o
 obj-$(CONFIG_CBE_CPUFREQ_PMI)          += cbe_cpufreq_pmi.o
 obj-$(CONFIG_CBE_CPUFREQ)              += cbe-cpufreq.o
 cbe-cpufreq-y                          += cbe_cpufreq_pervasive.o cbe_cpufreq.o
+obj-$(CONFIG_CBE_CPUFREQ_SPU_GOVERNOR) += cpufreq_spudemand.o
+
+obj-$(CONFIG_PPC_IBM_CELL_POWERBUTTON) += cbe_powerbutton.o
 
 ifeq ($(CONFIG_SMP),y)
 obj-$(CONFIG_PPC_CELL_NATIVE)          += smp.o
diff --git a/arch/powerpc/platforms/cell/cbe_powerbutton.c b/arch/powerpc/platforms/cell/cbe_powerbutton.c
new file mode 100644 (file)
index 0000000..dcddaa5
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * driver for powerbutton on IBM cell blades
+ *
+ * (C) Copyright IBM Corp. 2005-2008
+ *
+ * Author: Christian Krafft <krafft@de.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/input.h>
+#include <linux/platform_device.h>
+#include <asm/pmi.h>
+#include <asm/prom.h>
+
+static struct input_dev *button_dev;
+static struct platform_device *button_pdev;
+
+static void cbe_powerbutton_handle_pmi(pmi_message_t pmi_msg)
+{
+       BUG_ON(pmi_msg.type != PMI_TYPE_POWER_BUTTON);
+
+       input_report_key(button_dev, KEY_POWER, 1);
+       input_sync(button_dev);
+       input_report_key(button_dev, KEY_POWER, 0);
+       input_sync(button_dev);
+}
+
+static struct pmi_handler cbe_pmi_handler = {
+       .type                   = PMI_TYPE_POWER_BUTTON,
+       .handle_pmi_message     = cbe_powerbutton_handle_pmi,
+};
+
+static int __init cbe_powerbutton_init(void)
+{
+       int ret = 0;
+       struct input_dev *dev;
+
+       if (!machine_is_compatible("IBM,CBPLUS-1.0")) {
+               printk(KERN_ERR "%s: Not a cell blade.\n", __func__);
+               ret = -ENODEV;
+               goto out;
+       }
+
+       dev = input_allocate_device();
+       if (!dev) {
+               ret = -ENOMEM;
+               printk(KERN_ERR "%s: Not enough memory.\n", __func__);
+               goto out;
+       }
+
+       set_bit(EV_KEY, dev->evbit);
+       set_bit(KEY_POWER, dev->keybit);
+
+       dev->name = "Power Button";
+       dev->id.bustype = BUS_HOST;
+
+       /* this makes the button look like an acpi power button
+        * no clue whether anyone relies on that though */
+       dev->id.product = 0x02;
+       dev->phys = "LNXPWRBN/button/input0";
+
+       button_pdev = platform_device_register_simple("power_button", 0, NULL, 0);
+       if (IS_ERR(button_pdev)) {
+               ret = PTR_ERR(button_pdev);
+               goto out_free_input;
+       }
+
+       dev->dev.parent = &button_pdev->dev;
+       ret = input_register_device(dev);
+       if (ret) {
+               printk(KERN_ERR "%s: Failed to register device\n", __func__);
+               goto out_free_pdev;
+       }
+
+       button_dev = dev;
+
+       ret = pmi_register_handler(&cbe_pmi_handler);
+       if (ret) {
+               printk(KERN_ERR "%s: Failed to register with pmi.\n", __func__);
+               goto out_free_pdev;
+       }
+
+       goto out;
+
+out_free_pdev:
+       platform_device_unregister(button_pdev);
+out_free_input:
+       input_free_device(dev);
+out:
+       return ret;
+}
+
+static void __exit cbe_powerbutton_exit(void)
+{
+       pmi_unregister_handler(&cbe_pmi_handler);
+       platform_device_unregister(button_pdev);
+       input_free_device(button_dev);
+}
+
+module_init(cbe_powerbutton_init);
+module_exit(cbe_powerbutton_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Christian Krafft <krafft@de.ibm.com>");
index 4852bf3..4d4c8c1 100644 (file)
@@ -97,7 +97,8 @@ static u8 spu_read_register_value(struct sys_device *sysdev, union spe_reg __iom
        return value.spe[spu->spe_id];
 }
 
-static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf)
+static ssize_t spu_show_temp(struct sys_device *sysdev, struct sysdev_attribute *attr,
+                       char *buf)
 {
        u8 value;
        struct cbe_pmd_regs __iomem *pmd_regs;
@@ -146,32 +147,38 @@ static ssize_t store_throttle(struct cbe_pmd_regs __iomem *pmd_regs, const char
        return size;
 }
 
-static ssize_t spu_show_throttle_end(struct sys_device *sysdev, char *buf)
+static ssize_t spu_show_throttle_end(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        return show_throttle(get_pmd_regs(sysdev), buf, 0);
 }
 
-static ssize_t spu_show_throttle_begin(struct sys_device *sysdev, char *buf)
+static ssize_t spu_show_throttle_begin(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        return show_throttle(get_pmd_regs(sysdev), buf, 8);
 }
 
-static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev, char *buf)
+static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        return show_throttle(get_pmd_regs(sysdev), buf, 16);
 }
 
-static ssize_t spu_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size)
+static ssize_t spu_store_throttle_end(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, const char *buf, size_t size)
 {
        return store_throttle(get_pmd_regs(sysdev), buf, size, 0);
 }
 
-static ssize_t spu_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size)
+static ssize_t spu_store_throttle_begin(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, const char *buf, size_t size)
 {
        return store_throttle(get_pmd_regs(sysdev), buf, size, 8);
 }
 
-static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size)
+static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, const char *buf, size_t size)
 {
        return store_throttle(get_pmd_regs(sysdev), buf, size, 16);
 }
@@ -192,43 +199,51 @@ static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos)
 
 /* shows the temperature of the DTS on the PPE,
  * located near the linear thermal sensor */
-static ssize_t ppe_show_temp0(struct sys_device *sysdev, char *buf)
+static ssize_t ppe_show_temp0(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        return ppe_show_temp(sysdev, buf, 32);
 }
 
 /* shows the temperature of the second DTS on the PPE */
-static ssize_t ppe_show_temp1(struct sys_device *sysdev, char *buf)
+static ssize_t ppe_show_temp1(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        return ppe_show_temp(sysdev, buf, 0);
 }
 
-static ssize_t ppe_show_throttle_end(struct sys_device *sysdev, char *buf)
+static ssize_t ppe_show_throttle_end(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 32);
 }
 
-static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev, char *buf)
+static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 40);
 }
 
-static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev, char *buf)
+static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 48);
 }
 
-static ssize_t ppe_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size)
+static ssize_t ppe_store_throttle_end(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, const char *buf, size_t size)
 {
        return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 32);
 }
 
-static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size)
+static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, const char *buf, size_t size)
 {
        return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 40);
 }
 
-static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size)
+static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev,
+                       struct sysdev_attribute *attr, const char *buf, size_t size)
 {
        return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 48);
 }
diff --git a/arch/powerpc/platforms/cell/cpufreq_spudemand.c b/arch/powerpc/platforms/cell/cpufreq_spudemand.c
new file mode 100644 (file)
index 0000000..a3c6c01
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * spu aware cpufreq governor for the cell processor
+ *
+ * Â© Copyright IBM Corporation 2006-2008
+ *
+ * Author: Christian Krafft <krafft@de.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/cpufreq.h>
+#include <linux/sched.h>
+#include <linux/timer.h>
+#include <linux/workqueue.h>
+#include <asm/atomic.h>
+#include <asm/machdep.h>
+#include <asm/spu.h>
+
+#define POLL_TIME      100000          /* in Âµs */
+#define EXP            753             /* exp(-1) in fixed-point */
+
+struct spu_gov_info_struct {
+       unsigned long busy_spus;        /* fixed-point */
+       struct cpufreq_policy *policy;
+       struct delayed_work work;
+       unsigned int poll_int;          /* Âµs */
+};
+static DEFINE_PER_CPU(struct spu_gov_info_struct, spu_gov_info);
+
+static struct workqueue_struct *kspugov_wq;
+
+static int calc_freq(struct spu_gov_info_struct *info)
+{
+       int cpu;
+       int busy_spus;
+
+       cpu = info->policy->cpu;
+       busy_spus = atomic_read(&cbe_spu_info[cpu_to_node(cpu)].busy_spus);
+
+       CALC_LOAD(info->busy_spus, EXP, busy_spus * FIXED_1);
+       pr_debug("cpu %d: busy_spus=%d, info->busy_spus=%ld\n",
+                       cpu, busy_spus, info->busy_spus);
+
+       return info->policy->max * info->busy_spus / FIXED_1;
+}
+
+static void spu_gov_work(struct work_struct *work)
+{
+       struct spu_gov_info_struct *info;
+       int delay;
+       unsigned long target_freq;
+
+       info = container_of(work, struct spu_gov_info_struct, work.work);
+
+       /* after cancel_delayed_work_sync we unset info->policy */
+       BUG_ON(info->policy == NULL);
+
+       target_freq = calc_freq(info);
+       __cpufreq_driver_target(info->policy, target_freq, CPUFREQ_RELATION_H);
+
+       delay = usecs_to_jiffies(info->poll_int);
+       queue_delayed_work_on(info->policy->cpu, kspugov_wq, &info->work, delay);
+}
+
+static void spu_gov_init_work(struct spu_gov_info_struct *info)
+{
+       int delay = usecs_to_jiffies(info->poll_int);
+       INIT_DELAYED_WORK_DEFERRABLE(&info->work, spu_gov_work);
+       queue_delayed_work_on(info->policy->cpu, kspugov_wq, &info->work, delay);
+}
+
+static void spu_gov_cancel_work(struct spu_gov_info_struct *info)
+{
+       cancel_delayed_work_sync(&info->work);
+}
+
+static int spu_gov_govern(struct cpufreq_policy *policy, unsigned int event)
+{
+       unsigned int cpu = policy->cpu;
+       struct spu_gov_info_struct *info, *affected_info;
+       int i;
+       int ret = 0;
+
+       info = &per_cpu(spu_gov_info, cpu);
+
+       switch (event) {
+       case CPUFREQ_GOV_START:
+               if (!cpu_online(cpu)) {
+                       printk(KERN_ERR "cpu %d is not online\n", cpu);
+                       ret = -EINVAL;
+                       break;
+               }
+
+               if (!policy->cur) {
+                       printk(KERN_ERR "no cpu specified in policy\n");
+                       ret = -EINVAL;
+                       break;
+               }
+
+               /* initialize spu_gov_info for all affected cpus */
+               for_each_cpu_mask(i, policy->cpus) {
+                       affected_info = &per_cpu(spu_gov_info, i);
+                       affected_info->policy = policy;
+               }
+
+               info->poll_int = POLL_TIME;
+
+               /* setup timer */
+               spu_gov_init_work(info);
+
+               break;
+
+       case CPUFREQ_GOV_STOP:
+               /* cancel timer */
+               spu_gov_cancel_work(info);
+
+               /* clean spu_gov_info for all affected cpus */
+               for_each_cpu_mask (i, policy->cpus) {
+                       info = &per_cpu(spu_gov_info, i);
+                       info->policy = NULL;
+               }
+
+               break;
+       }
+
+       return ret;
+}
+
+static struct cpufreq_governor spu_governor = {
+       .name = "spudemand",
+       .governor = spu_gov_govern,
+       .owner = THIS_MODULE,
+};
+
+/*
+ * module init and destoy
+ */
+
+static int __init spu_gov_init(void)
+{
+       int ret;
+
+       kspugov_wq = create_workqueue("kspugov");
+       if (!kspugov_wq) {
+               printk(KERN_ERR "creation of kspugov failed\n");
+               ret = -EFAULT;
+               goto out;
+       }
+
+       ret = cpufreq_register_governor(&spu_governor);
+       if (ret) {
+               printk(KERN_ERR "registration of governor failed\n");
+               destroy_workqueue(kspugov_wq);
+               goto out;
+       }
+out:
+       return ret;
+}
+
+static void __exit spu_gov_exit(void)
+{
+       cpufreq_unregister_governor(&spu_governor);
+       destroy_workqueue(kspugov_wq);
+}
+
+
+module_init(spu_gov_init);
+module_exit(spu_gov_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Christian Krafft <krafft@de.ibm.com>");
+
index eeacb3a..208005c 100644 (file)
@@ -173,7 +173,8 @@ static void invalidate_tce_cache(struct cbe_iommu *iommu, unsigned long *pte,
 }
 
 static void tce_build_cell(struct iommu_table *tbl, long index, long npages,
-               unsigned long uaddr, enum dma_data_direction direction)
+               unsigned long uaddr, enum dma_data_direction direction,
+               struct dma_attrs *attrs)
 {
        int i;
        unsigned long *io_pte, base_pte;
@@ -198,6 +199,8 @@ static void tce_build_cell(struct iommu_table *tbl, long index, long npages,
        base_pte = IOPTE_PP_W | IOPTE_PP_R | IOPTE_M | IOPTE_SO_RW |
                (window->ioid & IOPTE_IOID_Mask);
 #endif
+       if (unlikely(dma_get_attr(DMA_ATTR_WEAK_ORDERING, attrs)))
+               base_pte &= ~IOPTE_SO_RW;
 
        io_pte = (unsigned long *)tbl->it_base + (index - tbl->it_offset);
 
@@ -519,7 +522,7 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
 
        __set_bit(0, window->table.it_map);
        tce_build_cell(&window->table, window->table.it_offset, 1,
-                      (unsigned long)iommu->pad_page, DMA_TO_DEVICE);
+                      (unsigned long)iommu->pad_page, DMA_TO_DEVICE, NULL);
        window->table.it_hint = window->table.it_blocksize;
 
        return window;
@@ -538,7 +541,9 @@ static struct cbe_iommu *cell_iommu_for_node(int nid)
 static unsigned long cell_dma_direct_offset;
 
 static unsigned long dma_iommu_fixed_base;
-struct dma_mapping_ops dma_iommu_fixed_ops;
+
+/* iommu_fixed_is_weak is set if booted with iommu_fixed=weak */
+static int iommu_fixed_is_weak;
 
 static struct iommu_table *cell_get_iommu_table(struct device *dev)
 {
@@ -562,6 +567,98 @@ static struct iommu_table *cell_get_iommu_table(struct device *dev)
        return &window->table;
 }
 
+/* A coherent allocation implies strong ordering */
+
+static void *dma_fixed_alloc_coherent(struct device *dev, size_t size,
+                                     dma_addr_t *dma_handle, gfp_t flag)
+{
+       if (iommu_fixed_is_weak)
+               return iommu_alloc_coherent(dev, cell_get_iommu_table(dev),
+                                           size, dma_handle,
+                                           device_to_mask(dev), flag,
+                                           dev->archdata.numa_node);
+       else
+               return dma_direct_ops.alloc_coherent(dev, size, dma_handle,
+                                                    flag);
+}
+
+static void dma_fixed_free_coherent(struct device *dev, size_t size,
+                                   void *vaddr, dma_addr_t dma_handle)
+{
+       if (iommu_fixed_is_weak)
+               iommu_free_coherent(cell_get_iommu_table(dev), size, vaddr,
+                                   dma_handle);
+       else
+               dma_direct_ops.free_coherent(dev, size, vaddr, dma_handle);
+}
+
+static dma_addr_t dma_fixed_map_single(struct device *dev, void *ptr,
+                                      size_t size,
+                                      enum dma_data_direction direction,
+                                      struct dma_attrs *attrs)
+{
+       if (iommu_fixed_is_weak == dma_get_attr(DMA_ATTR_WEAK_ORDERING, attrs))
+               return dma_direct_ops.map_single(dev, ptr, size, direction,
+                                                attrs);
+       else
+               return iommu_map_single(dev, cell_get_iommu_table(dev), ptr,
+                                       size, device_to_mask(dev), direction,
+                                       attrs);
+}
+
+static void dma_fixed_unmap_single(struct device *dev, dma_addr_t dma_addr,
+                                  size_t size,
+                                  enum dma_data_direction direction,
+                                  struct dma_attrs *attrs)
+{
+       if (iommu_fixed_is_weak == dma_get_attr(DMA_ATTR_WEAK_ORDERING, attrs))
+               dma_direct_ops.unmap_single(dev, dma_addr, size, direction,
+                                           attrs);
+       else
+               iommu_unmap_single(cell_get_iommu_table(dev), dma_addr, size,
+                                  direction, attrs);
+}
+
+static int dma_fixed_map_sg(struct device *dev, struct scatterlist *sg,
+                          int nents, enum dma_data_direction direction,
+                          struct dma_attrs *attrs)
+{
+       if (iommu_fixed_is_weak == dma_get_attr(DMA_ATTR_WEAK_ORDERING, attrs))
+               return dma_direct_ops.map_sg(dev, sg, nents, direction, attrs);
+       else
+               return iommu_map_sg(dev, cell_get_iommu_table(dev), sg, nents,
+                                   device_to_mask(dev), direction, attrs);
+}
+
+static void dma_fixed_unmap_sg(struct device *dev, struct scatterlist *sg,
+                              int nents, enum dma_data_direction direction,
+                              struct dma_attrs *attrs)
+{
+       if (iommu_fixed_is_weak == dma_get_attr(DMA_ATTR_WEAK_ORDERING, attrs))
+               dma_direct_ops.unmap_sg(dev, sg, nents, direction, attrs);
+       else
+               iommu_unmap_sg(cell_get_iommu_table(dev), sg, nents, direction,
+                              attrs);
+}
+
+static int dma_fixed_dma_supported(struct device *dev, u64 mask)
+{
+       return mask == DMA_64BIT_MASK;
+}
+
+static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask);
+
+struct dma_mapping_ops dma_iommu_fixed_ops = {
+       .alloc_coherent = dma_fixed_alloc_coherent,
+       .free_coherent  = dma_fixed_free_coherent,
+       .map_single     = dma_fixed_map_single,
+       .unmap_single   = dma_fixed_unmap_single,
+       .map_sg         = dma_fixed_map_sg,
+       .unmap_sg       = dma_fixed_unmap_sg,
+       .dma_supported  = dma_fixed_dma_supported,
+       .set_dma_mask   = dma_set_mask_and_switch,
+};
+
 static void cell_dma_dev_setup_fixed(struct device *dev);
 
 static void cell_dma_dev_setup(struct device *dev)
@@ -918,9 +1015,16 @@ static void cell_iommu_setup_fixed_ptab(struct cbe_iommu *iommu,
 
        pr_debug("iommu: mapping 0x%lx pages from 0x%lx\n", fsize, fbase);
 
-       base_pte = IOPTE_PP_W | IOPTE_PP_R | IOPTE_M | IOPTE_SO_RW
+       base_pte = IOPTE_PP_W | IOPTE_PP_R | IOPTE_M
                    | (cell_iommu_get_ioid(np) & IOPTE_IOID_Mask);
 
+       if (iommu_fixed_is_weak)
+               pr_info("IOMMU: Using weak ordering for fixed mapping\n");
+       else {
+               pr_info("IOMMU: Using strong ordering for fixed mapping\n");
+               base_pte |= IOPTE_SO_RW;
+       }
+
        for (uaddr = 0; uaddr < fsize; uaddr += (1 << 24)) {
                /* Don't touch the dynamic region */
                ioaddr = uaddr + fbase;
@@ -1036,9 +1140,6 @@ static int __init cell_iommu_fixed_mapping_init(void)
                cell_iommu_setup_window(iommu, np, dbase, dsize, 0);
        }
 
-       dma_iommu_fixed_ops = dma_direct_ops;
-       dma_iommu_fixed_ops.set_dma_mask = dma_set_mask_and_switch;
-
        dma_iommu_ops.set_dma_mask = dma_set_mask_and_switch;
        set_pci_dma_ops(&dma_iommu_ops);
 
@@ -1052,6 +1153,9 @@ static int __init setup_iommu_fixed(char *str)
        if (strcmp(str, "off") == 0)
                iommu_fixed_disabled = 1;
 
+       else if (strcmp(str, "weak") == 0)
+               iommu_fixed_is_weak = 1;
+
        return 1;
 }
 __setup("iommu_fixed=", setup_iommu_fixed);
index 8a3631c..efdacc8 100644 (file)
@@ -38,8 +38,6 @@
 
 #include "pervasive.h"
 
-static int sysreset_hack;
-
 static void cbe_power_save(void)
 {
        unsigned long ctrl, thread_switch_control;
@@ -87,9 +85,6 @@ static void cbe_power_save(void)
 
 static int cbe_system_reset_exception(struct pt_regs *regs)
 {
-       int cpu;
-       struct cbe_pmd_regs __iomem *pmd;
-
        switch (regs->msr & SRR1_WAKEMASK) {
        case SRR1_WAKEEE:
                do_IRQ(regs);
@@ -98,19 +93,7 @@ static int cbe_system_reset_exception(struct pt_regs *regs)
                timer_interrupt(regs);
                break;
        case SRR1_WAKEMT:
-               /*
-                * The BMC can inject user triggered system reset exceptions,
-                * but cannot set the system reset reason in srr1,
-                * so check an extra register here.
-                */
-               if (sysreset_hack && (cpu = smp_processor_id()) == 0) {
-                       pmd = cbe_get_cpu_pmd_regs(cpu);
-                       if (in_be64(&pmd->ras_esc_0) & 0xffff) {
-                               out_be64(&pmd->ras_esc_0, 0);
-                               return 0;
-                       }
-               }
-               break;
+               return cbe_sysreset_hack();
 #ifdef CONFIG_CBE_RAS
        case SRR1_WAKESYSERR:
                cbe_system_error_exception(regs);
@@ -134,8 +117,6 @@ void __init cbe_pervasive_init(void)
        if (!cpu_has_feature(CPU_FTR_PAUSE_ZERO))
                return;
 
-       sysreset_hack = machine_is_compatible("IBM,CBPLUS-1.0");
-
        for_each_possible_cpu(cpu) {
                struct cbe_pmd_regs __iomem *regs = cbe_get_cpu_pmd_regs(cpu);
                if (!regs)
@@ -144,12 +125,6 @@ void __init cbe_pervasive_init(void)
                 /* Enable Pause(0) control bit */
                out_be64(&regs->pmcr, in_be64(&regs->pmcr) |
                                            CBE_PMD_PAUSE_ZERO_CONTROL);
-
-               /* Enable JTAG system-reset hack */
-               if (sysreset_hack)
-                       out_be32(&regs->fir_mode_reg,
-                               in_be32(&regs->fir_mode_reg) |
-                               CBE_PMD_FIR_MODE_M8);
        }
 
        ppc_md.power_save = cbe_power_save;
index 7b50947..fd4d7b7 100644 (file)
@@ -30,4 +30,13 @@ extern void cbe_system_error_exception(struct pt_regs *regs);
 extern void cbe_maintenance_exception(struct pt_regs *regs);
 extern void cbe_thermal_exception(struct pt_regs *regs);
 
+#ifdef CONFIG_PPC_IBM_CELL_RESETBUTTON
+extern int cbe_sysreset_hack(void);
+#else
+static inline int cbe_sysreset_hack(void)
+{
+       return 1;
+}
+#endif /* CONFIG_PPC_IBM_CELL_RESETBUTTON */
+
 #endif
index 505f9b9..2a14b05 100644 (file)
@@ -236,6 +236,52 @@ static struct notifier_block cbe_ptcal_reboot_notifier = {
        .notifier_call = cbe_ptcal_notify_reboot
 };
 
+#ifdef CONFIG_PPC_IBM_CELL_RESETBUTTON
+static int sysreset_hack;
+
+static int __init cbe_sysreset_init(void)
+{
+       struct cbe_pmd_regs __iomem *regs;
+
+       sysreset_hack = machine_is_compatible("IBM,CBPLUS-1.0");
+       if (!sysreset_hack)
+               return 0;
+
+       regs = cbe_get_cpu_pmd_regs(0);
+       if (!regs)
+               return 0;
+
+       /* Enable JTAG system-reset hack */
+       out_be32(&regs->fir_mode_reg,
+               in_be32(&regs->fir_mode_reg) |
+               CBE_PMD_FIR_MODE_M8);
+
+       return 0;
+}
+device_initcall(cbe_sysreset_init);
+
+int cbe_sysreset_hack(void)
+{
+       struct cbe_pmd_regs __iomem *regs;
+
+       /*
+        * The BMC can inject user triggered system reset exceptions,
+        * but cannot set the system reset reason in srr1,
+        * so check an extra register here.
+        */
+       if (sysreset_hack && (smp_processor_id() == 0)) {
+               regs = cbe_get_cpu_pmd_regs(0);
+               if (!regs)
+                       return 0;
+               if (in_be64(&regs->ras_esc_0) & 0x0000ffff) {
+                       out_be64(&regs->ras_esc_0, 0);
+                       return 0;
+               }
+       }
+       return 1;
+}
+#endif /* CONFIG_PPC_IBM_CELL_RESETBUTTON */
+
 int __init cbe_ptcal_init(void)
 {
        int ret;
index 78f905b..a5bdb89 100644 (file)
@@ -703,7 +703,8 @@ static unsigned long long spu_acct_time(struct spu *spu,
 }
 
 
-static ssize_t spu_stat_show(struct sys_device *sysdev, char *buf)
+static ssize_t spu_stat_show(struct sys_device *sysdev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        struct spu *spu = container_of(sysdev, struct spu, sysdev);
 
index 609c46d..768c262 100644 (file)
@@ -367,7 +367,7 @@ static void chrp_pci_fixup_vt8231_ata(struct pci_dev *viaide)
        viaisa = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, NULL);
        if (!viaisa)
                return;
-       printk("Fixing VIA IDE, force legacy mode on '%s'\n", viaide->dev.bus_id);
+       dev_info(&viaide->dev, "Fixing VIA IDE, force legacy mode on\n");
 
        pci_read_config_byte(viaide, PCI_CLASS_PROG, &progif);
        pci_write_config_byte(viaide, PCI_CLASS_PROG, progif & ~0x5);
index afc9141..ef74a07 100644 (file)
@@ -51,15 +51,13 @@ u8 uli_pirq_to_irq[8] = {
        ULI_8259_NONE,          /* PIRQH */
 };
 
-/* set in board code if you want this quirks to do something */
-int uses_fsl_uli_m1575;
-
 /* Bridge */
 static void __devinit early_uli5249(struct pci_dev *dev)
 {
        unsigned char temp;
 
-       if (!uses_fsl_uli_m1575)
+       if (!machine_is(mpc86xx_hpcn) && !machine_is(mpc8544_ds) &&
+                       !machine_is(mpc8572_ds))
                return;
 
        pci_write_config_word(dev, PCI_COMMAND, PCI_COMMAND_IO |
@@ -82,7 +80,8 @@ static void __devinit quirk_uli1575(struct pci_dev *dev)
 {
        int i;
 
-       if (!uses_fsl_uli_m1575)
+       if (!machine_is(mpc86xx_hpcn) && !machine_is(mpc8544_ds) &&
+                       !machine_is(mpc8572_ds))
                return;
 
        /*
@@ -150,7 +149,8 @@ static void __devinit quirk_final_uli1575(struct pci_dev *dev)
         * IRQ 14: Edge
         * IRQ 15: Edge
         */
-       if (!uses_fsl_uli_m1575)
+       if (!machine_is(mpc86xx_hpcn) && !machine_is(mpc8544_ds) &&
+                       !machine_is(mpc8572_ds))
                return;
 
        outb(0xfa, 0x4d0);
@@ -176,7 +176,8 @@ static void __devinit quirk_uli5288(struct pci_dev *dev)
        unsigned char c;
        unsigned int d;
 
-       if (!uses_fsl_uli_m1575)
+       if (!machine_is(mpc86xx_hpcn) && !machine_is(mpc8544_ds) &&
+                       !machine_is(mpc8572_ds))
                return;
 
        /* read/write lock */
@@ -200,7 +201,8 @@ static void __devinit quirk_uli5229(struct pci_dev *dev)
 {
        unsigned short temp;
 
-       if (!uses_fsl_uli_m1575)
+       if (!machine_is(mpc86xx_hpcn) && !machine_is(mpc8544_ds) &&
+                       !machine_is(mpc8572_ds))
                return;
 
        pci_write_config_word(dev, PCI_COMMAND, PCI_COMMAND_INTX_DISABLE |
@@ -221,7 +223,7 @@ static void __devinit quirk_final_uli5249(struct pci_dev *dev)
        for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
                if ((bus->resource[i]) &&
                        (bus->resource[i]->flags & IORESOURCE_MEM)) {
-                       dummy = ioremap(bus->resource[i]->start, 0x4);
+                       dummy = ioremap(bus->resource[i]->end - 3, 0x4);
                        if (dummy) {
                                in_8(dummy);
                                iounmap(dummy);
@@ -238,6 +240,103 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5229, quirk_uli5229);
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, 0x5249, quirk_final_uli5249);
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, 0x1575, quirk_final_uli1575);
 
+static void __devinit hpcd_quirk_uli1575(struct pci_dev *dev)
+{
+       u32 temp32;
+
+       if (!machine_is(mpc86xx_hpcd))
+               return;
+
+       /* Disable INTx */
+       pci_read_config_dword(dev, 0x48, &temp32);
+       pci_write_config_dword(dev, 0x48, (temp32 | 1<<26));
+
+       /* Enable sideband interrupt */
+       pci_read_config_dword(dev, 0x90, &temp32);
+       pci_write_config_dword(dev, 0x90, (temp32 | 1<<22));
+}
+
+static void __devinit hpcd_quirk_uli5288(struct pci_dev *dev)
+{
+       unsigned char c;
+       unsigned short temp;
+
+       if (!machine_is(mpc86xx_hpcd))
+               return;
+
+       /* Interrupt Disable, Needed when SATA disabled */
+       pci_read_config_word(dev, PCI_COMMAND, &temp);
+       temp |= 1<<10;
+       pci_write_config_word(dev, PCI_COMMAND, temp);
+
+       pci_read_config_byte(dev, 0x83, &c);
+       c |= 0x80;
+       pci_write_config_byte(dev, 0x83, c);
+
+       pci_write_config_byte(dev, PCI_CLASS_PROG, 0x01);
+       pci_write_config_byte(dev, PCI_CLASS_DEVICE, 0x06);
+
+       pci_read_config_byte(dev, 0x83, &c);
+       c &= 0x7f;
+       pci_write_config_byte(dev, 0x83, c);
+}
+
+/*
+ * Since 8259PIC was disabled on the board, the IDE device can not
+ * use the legacy IRQ, we need to let the IDE device work under
+ * native mode and use the interrupt line like other PCI devices.
+ * IRQ14 is a sideband interrupt from IDE device to CPU and we use this
+ * as the interrupt for IDE device.
+ */
+static void __devinit hpcd_quirk_uli5229(struct pci_dev *dev)
+{
+       unsigned char c;
+
+       if (!machine_is(mpc86xx_hpcd))
+               return;
+
+       pci_read_config_byte(dev, 0x4b, &c);
+       c |= 0x10;
+       pci_write_config_byte(dev, 0x4b, c);
+}
+
+/*
+ * SATA interrupt pin bug fix
+ * There's a chip bug for 5288, The interrupt pin should be 2,
+ * not the read only value 1, So it use INTB#, not INTA# which
+ * actually used by the IDE device 5229.
+ * As of this bug, during the PCI initialization, 5288 read the
+ * irq of IDE device from the device tree, this function fix this
+ * bug by re-assigning a correct irq to 5288.
+ *
+ */
+static void __devinit hpcd_final_uli5288(struct pci_dev *dev)
+{
+       struct pci_controller *hose = pci_bus_to_host(dev->bus);
+       struct device_node *hosenode = hose ? hose->dn : NULL;
+       struct of_irq oirq;
+       int virq, pin = 2;
+       u32 laddr[3];
+
+       if (!machine_is(mpc86xx_hpcd))
+               return;
+
+       if (!hosenode)
+               return;
+
+       laddr[0] = (hose->first_busno << 16) | (PCI_DEVFN(31, 0) << 8);
+       laddr[1] = laddr[2] = 0;
+       of_irq_map_raw(hosenode, &pin, 1, laddr, &oirq);
+       virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
+                                    oirq.size);
+       dev->irq = virq;
+}
+
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, hpcd_quirk_uli1575);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5288, hpcd_quirk_uli5288);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5229, hpcd_quirk_uli5229);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, 0x5288, hpcd_final_uli5288);
+
 int uli_exclude_device(struct pci_controller *hose,
                        u_char bus, u_char devfn)
 {
index 761d9e9..ea3e541 100644 (file)
@@ -2,6 +2,7 @@ config PPC_ISERIES
        bool "IBM Legacy iSeries"
        depends on PPC_MULTIPLATFORM && PPC64
        select PPC_INDIRECT_IO
+       select PPC_PCI_CHOICE if EMBEDDED
 
 menu "iSeries device drivers"
        depends on PPC_ISERIES
index ab5d868..bc818e4 100644 (file)
@@ -42,7 +42,8 @@
 #include <asm/iseries/iommu.h>
 
 static void tce_build_iSeries(struct iommu_table *tbl, long index, long npages,
-               unsigned long uaddr, enum dma_data_direction direction)
+               unsigned long uaddr, enum dma_data_direction direction,
+               struct dma_attrs *attrs)
 {
        u64 rc;
        u64 tce, rpn;
index 86967bd..70541b7 100644 (file)
@@ -85,7 +85,8 @@ static int iommu_table_iobmap_inited;
 
 static void iobmap_build(struct iommu_table *tbl, long index,
                         long npages, unsigned long uaddr,
-                        enum dma_data_direction direction)
+                        enum dma_data_direction direction,
+                        struct dma_attrs *attrs)
 {
        u32 *ip;
        u32 rpn;
index a5f4e95..920cf7a 100644 (file)
@@ -8,6 +8,7 @@ config PPC_PS3
        select USB_ARCH_HAS_EHCI
        select USB_EHCI_BIG_ENDIAN_MMIO
        select MEMORY_HOTPLUG
+       select PPC_PCI_CHOICE
        help
          This option enables support for the Sony PS3 game console
          and other platforms using the PS3 hypervisor.  Enabling this
index 3866deb..ffdd8e9 100644 (file)
@@ -486,6 +486,7 @@ static int __init ps3_register_graphics_devices(void)
                return -ENOMEM;
 
        p->dev.match_id = PS3_MATCH_ID_GRAPHICS;
+       p->dev.match_sub_id = PS3_MATCH_SUB_ID_FB;
        p->dev.dev_type = PS3_DEVICE_TYPE_IOC0;
 
        result = ps3_system_bus_device_register(&p->dev);
index d66c362..280ee88 100644 (file)
@@ -347,16 +347,23 @@ static int ps3_system_bus_match(struct device *_dev,
        struct ps3_system_bus_driver *drv = ps3_drv_to_system_bus_drv(_drv);
        struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
 
-       result = dev->match_id == drv->match_id;
+       if (!dev->match_sub_id)
+               result = dev->match_id == drv->match_id;
+       else
+               result = dev->match_sub_id == drv->match_sub_id &&
+                       dev->match_id == drv->match_id;
 
        if (result)
-               pr_info("%s:%d: dev=%u(%s), drv=%u(%s): match\n", __func__,
-                       __LINE__, dev->match_id, dev->core.bus_id,
-                       drv->match_id, drv->core.name);
+               pr_info("%s:%d: dev=%u.%u(%s), drv=%u.%u(%s): match\n",
+                       __func__, __LINE__,
+                       dev->match_id, dev->match_sub_id, dev->core.bus_id,
+                       drv->match_id, drv->match_sub_id, drv->core.name);
        else
-               pr_debug("%s:%d: dev=%u(%s), drv=%u(%s): miss\n", __func__,
-                       __LINE__, dev->match_id, dev->core.bus_id,
-                       drv->match_id, drv->core.name);
+               pr_debug("%s:%d: dev=%u.%u(%s), drv=%u.%u(%s): miss\n",
+                       __func__, __LINE__,
+                       dev->match_id, dev->match_sub_id, dev->core.bus_id,
+                       drv->match_id, drv->match_sub_id, drv->core.name);
+
        return result;
 }
 
index 07fe5b6..757c029 100644 (file)
@@ -7,6 +7,7 @@ config PPC_PSERIES
        select RTAS_ERROR_LOGGING
        select PPC_UDBG_16550
        select PPC_NATIVE
+       select PPC_PCI_CHOICE if EMBEDDED
        default y
 
 config PPC_SPLPAR
index c027f0a..54816d7 100644 (file)
@@ -75,9 +75,9 @@
  */
 
 /* If a device driver keeps reading an MMIO register in an interrupt
- * handler after a slot isolation event has occurred, we assume it
- * is broken and panic.  This sets the threshold for how many read
- * attempts we allow before panicking.
+ * handler after a slot isolation event, it might be broken.
+ * This sets the threshold for how many read attempts we allow
+ * before printing an error message.
  */
 #define EEH_MAX_FAILS  2100000
 
@@ -470,6 +470,7 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
        unsigned long flags;
        struct pci_dn *pdn;
        int rc = 0;
+       const char *location;
 
        total_mmio_ffs++;
 
@@ -509,18 +510,15 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
        rc = 1;
        if (pdn->eeh_mode & EEH_MODE_ISOLATED) {
                pdn->eeh_check_count ++;
-               if (pdn->eeh_check_count >= EEH_MAX_FAILS) {
-                       printk (KERN_ERR "EEH: Device driver ignored %d bad reads, panicing\n",
-                               pdn->eeh_check_count);
+               if (pdn->eeh_check_count % EEH_MAX_FAILS == 0) {
+                       location = of_get_property(dn, "ibm,loc-code", NULL);
+                       printk (KERN_ERR "EEH: %d reads ignored for recovering device at "
+                               "location=%s driver=%s pci addr=%s\n",
+                               pdn->eeh_check_count, location,
+                               dev->driver->name, pci_name(dev));
+                       printk (KERN_ERR "EEH: Might be infinite loop in %s driver\n",
+                               dev->driver->name);
                        dump_stack();
-                       msleep(5000);
-                       
-                       /* re-read the slot reset state */
-                       if (read_slot_reset_state(pdn, rets) != 0)
-                               rets[0] = -1;   /* reset state unknown */
-
-                       /* If we are here, then we hit an infinite loop. Stop. */
-                       panic("EEH: MMIO halt (%d) on device:%s\n", rets[0], pci_name(dev));
                }
                goto dn_unlock;
        }
index 9a12908..5377dd4 100644 (file)
@@ -50,7 +50,8 @@
 
 static void tce_build_pSeries(struct iommu_table *tbl, long index,
                              long npages, unsigned long uaddr,
-                             enum dma_data_direction direction)
+                             enum dma_data_direction direction,
+                             struct dma_attrs *attrs)
 {
        u64 proto_tce;
        u64 *tcep;
@@ -95,7 +96,8 @@ static unsigned long tce_get_pseries(struct iommu_table *tbl, long index)
 
 static void tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum,
                                long npages, unsigned long uaddr,
-                               enum dma_data_direction direction)
+                               enum dma_data_direction direction,
+                               struct dma_attrs *attrs)
 {
        u64 rc;
        u64 proto_tce, tce;
@@ -127,7 +129,8 @@ static DEFINE_PER_CPU(u64 *, tce_page) = NULL;
 
 static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
                                     long npages, unsigned long uaddr,
-                                    enum dma_data_direction direction)
+                                    enum dma_data_direction direction,
+                                    struct dma_attrs *attrs)
 {
        u64 rc;
        u64 proto_tce;
@@ -136,7 +139,8 @@ static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
        long l, limit;
 
        if (npages == 1) {
-               tce_build_pSeriesLP(tbl, tcenum, npages, uaddr, direction);
+               tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
+                                   direction, attrs);
                return;
        }
 
@@ -150,7 +154,7 @@ static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
                /* If allocation fails, fall back to the loop implementation */
                if (!tcep) {
                        tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
-                                           direction);
+                                           direction, attrs);
                        return;
                }
                __get_cpu_var(tce_page) = tcep;
index 7f59188..9e105cb 100644 (file)
@@ -57,6 +57,8 @@
 #define AXON_RAM_SECTOR_SIZE           1 << AXON_RAM_SECTOR_SHIFT
 #define AXON_RAM_IRQ_FLAGS             IRQF_SHARED | IRQF_TRIGGER_RISING
 
+static int azfs_major, azfs_minor;
+
 struct axon_ram_bank {
        struct of_device        *device;
        struct gendisk          *disk;
@@ -148,7 +150,10 @@ axon_ram_direct_access(struct block_device *device, sector_t sector,
        struct axon_ram_bank *bank = device->bd_disk->private_data;
        loff_t offset;
 
-       offset = sector << AXON_RAM_SECTOR_SHIFT;
+       offset = sector;
+       if (device->bd_part != NULL)
+               offset += device->bd_part->start_sect;
+       offset <<= AXON_RAM_SECTOR_SHIFT;
        if (offset >= bank->size) {
                dev_err(&bank->device->dev, "Access outside of address space\n");
                return -ERANGE;
@@ -227,19 +232,14 @@ axon_ram_probe(struct of_device *device, const struct of_device_id *device_id)
                goto failed;
        }
 
-       bank->disk->first_minor = 0;
+       bank->disk->major = azfs_major;
+       bank->disk->first_minor = azfs_minor;
        bank->disk->fops = &axon_ram_devops;
        bank->disk->private_data = bank;
        bank->disk->driverfs_dev = &device->dev;
 
        sprintf(bank->disk->disk_name, "%s%d",
                        AXON_RAM_DEVICE_NAME, axon_ram_bank_id);
-       bank->disk->major = register_blkdev(0, bank->disk->disk_name);
-       if (bank->disk->major < 0) {
-               dev_err(&device->dev, "Cannot register block device\n");
-               rc = -EFAULT;
-               goto failed;
-       }
 
        bank->disk->queue = blk_alloc_queue(GFP_KERNEL);
        if (bank->disk->queue == NULL) {
@@ -276,6 +276,8 @@ axon_ram_probe(struct of_device *device, const struct of_device_id *device_id)
                goto failed;
        }
 
+       azfs_minor += bank->disk->minors;
+
        return 0;
 
 failed:
@@ -310,7 +312,6 @@ axon_ram_remove(struct of_device *device)
 
        device_remove_file(&device->dev, &dev_attr_ecc);
        free_irq(bank->irq_id, device);
-       unregister_blkdev(bank->disk->major, bank->disk->disk_name);
        del_gendisk(bank->disk);
        iounmap((void __iomem *) bank->io_addr);
        kfree(bank);
@@ -341,6 +342,14 @@ static struct of_platform_driver axon_ram_driver = {
 static int __init
 axon_ram_init(void)
 {
+       azfs_major = register_blkdev(azfs_major, AXON_RAM_DEVICE_NAME);
+       if (azfs_major < 0) {
+               printk(KERN_ERR "%s cannot become block device major number\n",
+                               AXON_RAM_MODULE_NAME);
+               return -EFAULT;
+       }
+       azfs_minor = 0;
+
        return of_register_platform_driver(&axon_ram_driver);
 }
 
@@ -351,6 +360,7 @@ static void __exit
 axon_ram_exit(void)
 {
        of_unregister_platform_driver(&axon_ram_driver);
+       unregister_blkdev(azfs_major, AXON_RAM_DEVICE_NAME);
 }
 
 module_init(axon_ram_init);
index 005c2ec..de8c8b5 100644 (file)
@@ -149,7 +149,8 @@ static void dart_flush(struct iommu_table *tbl)
 
 static void dart_build(struct iommu_table *tbl, long index,
                       long npages, unsigned long uaddr,
-                      enum dma_data_direction direction)
+                      enum dma_data_direction direction,
+                      struct dma_attrs *attrs)
 {
        unsigned int *dp;
        unsigned int rpn;
index 87b0aa1..61e6d77 100644 (file)
@@ -27,6 +27,7 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#if defined(CONFIG_PPC_85xx) || defined(CONFIG_PPC_86xx)
 /* atmu setup for fsl pci/pcie controller */
 void __init setup_pci_atmu(struct pci_controller *hose, struct resource *rsrc)
 {
@@ -248,3 +249,63 @@ DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8536, quirk_fsl_pcie_header);
 DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8641, quirk_fsl_pcie_header);
 DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8641D, quirk_fsl_pcie_header);
 DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8610, quirk_fsl_pcie_header);
+#endif /* CONFIG_PPC_85xx || CONFIG_PPC_86xx */
+
+#if defined(CONFIG_PPC_83xx)
+int __init mpc83xx_add_bridge(struct device_node *dev)
+{
+       int len;
+       struct pci_controller *hose;
+       struct resource rsrc;
+       const int *bus_range;
+       int primary = 1, has_address = 0;
+       phys_addr_t immr = get_immrbase();
+
+       pr_debug("Adding PCI host bridge %s\n", dev->full_name);
+
+       /* Fetch host bridge registers address */
+       has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
+
+       /* Get bus range if any */
+       bus_range = of_get_property(dev, "bus-range", &len);
+       if (bus_range == NULL || len < 2 * sizeof(int)) {
+               printk(KERN_WARNING "Can't get bus-range for %s, assume"
+                      " bus 0\n", dev->full_name);
+       }
+
+       ppc_pci_flags |= PPC_PCI_REASSIGN_ALL_BUS;
+       hose = pcibios_alloc_controller(dev);
+       if (!hose)
+               return -ENOMEM;
+
+       hose->first_busno = bus_range ? bus_range[0] : 0;
+       hose->last_busno = bus_range ? bus_range[1] : 0xff;
+
+       /* MPC83xx supports up to two host controllers one at 0x8500 from immrbar
+        * the other at 0x8600, we consider the 0x8500 the primary controller
+        */
+       /* PCI 1 */
+       if ((rsrc.start & 0xfffff) == 0x8500) {
+               setup_indirect_pci(hose, immr + 0x8300, immr + 0x8304, 0);
+       }
+       /* PCI 2 */
+       if ((rsrc.start & 0xfffff) == 0x8600) {
+               setup_indirect_pci(hose, immr + 0x8380, immr + 0x8384, 0);
+               primary = 0;
+       }
+
+       printk(KERN_INFO "Found MPC83xx PCI host bridge at 0x%016llx. "
+              "Firmware bus number: %d->%d\n",
+              (unsigned long long)rsrc.start, hose->first_busno,
+              hose->last_busno);
+
+       pr_debug(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
+           hose, hose->cfg_addr, hose->cfg_data);
+
+       /* Interpret the "ranges" property */
+       /* This also maps the I/O region and sets isa_io/mem_base */
+       pci_process_bridge_OF_ranges(hose, dev, primary);
+
+       return 0;
+}
+#endif /* CONFIG_PPC_83xx */
index 37b04ad..13f30c2 100644 (file)
@@ -83,6 +83,7 @@ struct ccsr_pci {
 
 extern int fsl_add_bridge(struct device_node *dev, int is_primary);
 extern void fsl_pcibios_fixup_bus(struct pci_bus *bus);
+extern int mpc83xx_add_bridge(struct device_node *dev);
 
 #endif /* __POWERPC_FSL_PCI_H */
 #endif /* __KERNEL__ */
index ebcec73..214388e 100644 (file)
@@ -207,66 +207,58 @@ static int __init of_add_fixed_phys(void)
 arch_initcall(of_add_fixed_phys);
 #endif /* CONFIG_FIXED_PHY */
 
-static int __init gfar_mdio_of_init(void)
+static int gfar_mdio_of_init_one(struct device_node *np)
 {
-       struct device_node *np = NULL;
+       int k;
+       struct device_node *child = NULL;
+       struct gianfar_mdio_data mdio_data;
        struct platform_device *mdio_dev;
        struct resource res;
        int ret;
 
-       np = of_find_compatible_node(np, NULL, "fsl,gianfar-mdio");
+       memset(&res, 0, sizeof(res));
+       memset(&mdio_data, 0, sizeof(mdio_data));
 
-       /* try the deprecated version */
-       if (!np)
-               np = of_find_compatible_node(np, "mdio", "gianfar");
+       ret = of_address_to_resource(np, 0, &res);
+       if (ret)
+               return ret;
 
-       if (np) {
-               int k;
-               struct device_node *child = NULL;
-               struct gianfar_mdio_data mdio_data;
+       mdio_dev = platform_device_register_simple("fsl-gianfar_mdio",
+                       res.start&0xfffff, &res, 1);
+       if (IS_ERR(mdio_dev))
+               return PTR_ERR(mdio_dev);
 
-               memset(&res, 0, sizeof(res));
-               memset(&mdio_data, 0, sizeof(mdio_data));
+       for (k = 0; k < 32; k++)
+               mdio_data.irq[k] = PHY_POLL;
 
-               ret = of_address_to_resource(np, 0, &res);
-               if (ret)
-                       goto err;
-
-               mdio_dev =
-                   platform_device_register_simple("fsl-gianfar_mdio",
-                                                   res.start, &res, 1);
-               if (IS_ERR(mdio_dev)) {
-                       ret = PTR_ERR(mdio_dev);
-                       goto err;
+       while ((child = of_get_next_child(np, child)) != NULL) {
+               int irq = irq_of_parse_and_map(child, 0);
+               if (irq != NO_IRQ) {
+                       const u32 *id = of_get_property(child, "reg", NULL);
+                       mdio_data.irq[*id] = irq;
                }
+       }
 
-               for (k = 0; k < 32; k++)
-                       mdio_data.irq[k] = PHY_POLL;
+       ret = platform_device_add_data(mdio_dev, &mdio_data,
+                               sizeof(struct gianfar_mdio_data));
+       if (ret)
+               platform_device_unregister(mdio_dev);
 
-               while ((child = of_get_next_child(np, child)) != NULL) {
-                       int irq = irq_of_parse_and_map(child, 0);
-                       if (irq != NO_IRQ) {
-                               const u32 *id = of_get_property(child,
-                                                       "reg", NULL);
-                               mdio_data.irq[*id] = irq;
-                       }
-               }
+       return ret;
+}
 
-               ret =
-                   platform_device_add_data(mdio_dev, &mdio_data,
-                                            sizeof(struct gianfar_mdio_data));
-               if (ret)
-                       goto unreg;
-       }
+static int __init gfar_mdio_of_init(void)
+{
+       struct device_node *np = NULL;
 
-       of_node_put(np);
-       return 0;
+       for_each_compatible_node(np, NULL, "fsl,gianfar-mdio")
+               gfar_mdio_of_init_one(np);
 
-unreg:
-       platform_device_unregister(mdio_dev);
-err:
-       of_node_put(np);
-       return ret;
+       /* try the deprecated version */
+       for_each_compatible_node(np, "mdio", "gianfar");
+               gfar_mdio_of_init_one(np);
+
+       return 0;
 }
 
 arch_initcall(gfar_mdio_of_init);
@@ -296,6 +288,9 @@ static int __init gfar_of_init(void)
                const phandle *ph;
                int n_res = 2;
 
+               if (!of_device_is_available(np))
+                       continue;
+
                memset(r, 0, sizeof(r));
                memset(&gfar_data, 0, sizeof(gfar_data));
 
@@ -357,6 +352,9 @@ static int __init gfar_of_init(void)
                else
                        gfar_data.interface = PHY_INTERFACE_MODE_MII;
 
+               if (of_get_property(np, "fsl,magic-packet", NULL))
+                       gfar_data.device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;
+
                ph = of_get_property(np, "phy-handle", NULL);
                if (ph == NULL) {
                        u32 *fixed_link;
@@ -390,7 +388,7 @@ static int __init gfar_of_init(void)
 
                        gfar_data.phy_id = *id;
                        snprintf(gfar_data.bus_id, MII_BUS_ID_SIZE, "%llx",
-                                (unsigned long long)res.start);
+                                (unsigned long long)res.start&0xfffff);
 
                        of_node_put(phy);
                        of_node_put(mdio);
index 52c831f..0242998 100644 (file)
@@ -10,6 +10,7 @@ extern u32 get_baudrate(void);
 extern u32 fsl_get_sys_freq(void);
 
 struct spi_board_info;
+struct device_node;
 
 extern int fsl_spi_init(struct spi_board_info *board_infos,
                        unsigned int num_board_infos,
index caba1c0..88a983e 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/device.h>
 #include <linux/bootmem.h>
 #include <linux/spinlock.h>
+#include <linux/fsl_devices.h>
 #include <asm/irq.h>
 #include <asm/io.h>
 #include <asm/prom.h>
@@ -889,8 +890,78 @@ unsigned int ipic_get_irq(void)
        return irq_linear_revmap(primary_ipic->irqhost, irq);
 }
 
+#ifdef CONFIG_PM
+static struct {
+       u32 sicfr;
+       u32 siprr[2];
+       u32 simsr[2];
+       u32 sicnr;
+       u32 smprr[2];
+       u32 semsr;
+       u32 secnr;
+       u32 sermr;
+       u32 sercr;
+} ipic_saved_state;
+
+static int ipic_suspend(struct sys_device *sdev, pm_message_t state)
+{
+       struct ipic *ipic = primary_ipic;
+
+       ipic_saved_state.sicfr = ipic_read(ipic->regs, IPIC_SICFR);
+       ipic_saved_state.siprr[0] = ipic_read(ipic->regs, IPIC_SIPRR_A);
+       ipic_saved_state.siprr[1] = ipic_read(ipic->regs, IPIC_SIPRR_D);
+       ipic_saved_state.simsr[0] = ipic_read(ipic->regs, IPIC_SIMSR_H);
+       ipic_saved_state.simsr[1] = ipic_read(ipic->regs, IPIC_SIMSR_L);
+       ipic_saved_state.sicnr = ipic_read(ipic->regs, IPIC_SICNR);
+       ipic_saved_state.smprr[0] = ipic_read(ipic->regs, IPIC_SMPRR_A);
+       ipic_saved_state.smprr[1] = ipic_read(ipic->regs, IPIC_SMPRR_B);
+       ipic_saved_state.semsr = ipic_read(ipic->regs, IPIC_SEMSR);
+       ipic_saved_state.secnr = ipic_read(ipic->regs, IPIC_SECNR);
+       ipic_saved_state.sermr = ipic_read(ipic->regs, IPIC_SERMR);
+       ipic_saved_state.sercr = ipic_read(ipic->regs, IPIC_SERCR);
+
+       if (fsl_deep_sleep()) {
+               /* In deep sleep, make sure there can be no
+                * pending interrupts, as this can cause
+                * problems on 831x.
+                */
+               ipic_write(ipic->regs, IPIC_SIMSR_H, 0);
+               ipic_write(ipic->regs, IPIC_SIMSR_L, 0);
+               ipic_write(ipic->regs, IPIC_SEMSR, 0);
+               ipic_write(ipic->regs, IPIC_SERMR, 0);
+       }
+
+       return 0;
+}
+
+static int ipic_resume(struct sys_device *sdev)
+{
+       struct ipic *ipic = primary_ipic;
+
+       ipic_write(ipic->regs, IPIC_SICFR, ipic_saved_state.sicfr);
+       ipic_write(ipic->regs, IPIC_SIPRR_A, ipic_saved_state.siprr[0]);
+       ipic_write(ipic->regs, IPIC_SIPRR_D, ipic_saved_state.siprr[1]);
+       ipic_write(ipic->regs, IPIC_SIMSR_H, ipic_saved_state.simsr[0]);
+       ipic_write(ipic->regs, IPIC_SIMSR_L, ipic_saved_state.simsr[1]);
+       ipic_write(ipic->regs, IPIC_SICNR, ipic_saved_state.sicnr);
+       ipic_write(ipic->regs, IPIC_SMPRR_A, ipic_saved_state.smprr[0]);
+       ipic_write(ipic->regs, IPIC_SMPRR_B, ipic_saved_state.smprr[1]);
+       ipic_write(ipic->regs, IPIC_SEMSR, ipic_saved_state.semsr);
+       ipic_write(ipic->regs, IPIC_SECNR, ipic_saved_state.secnr);
+       ipic_write(ipic->regs, IPIC_SERMR, ipic_saved_state.sermr);
+       ipic_write(ipic->regs, IPIC_SERCR, ipic_saved_state.sercr);
+
+       return 0;
+}
+#else
+#define ipic_suspend NULL
+#define ipic_resume NULL
+#endif
+
 static struct sysdev_class ipic_sysclass = {
        .name = "ipic",
+       .suspend = ipic_suspend,
+       .resume = ipic_resume,
 };
 
 static struct sys_device device_ipic = {
index 9e82d7e..b3b73ae 100644 (file)
@@ -64,7 +64,7 @@ static phys_addr_t qebase = -1;
 phys_addr_t get_qe_base(void)
 {
        struct device_node *qe;
-       unsigned int size;
+       int size;
        const u32 *prop;
 
        if (qebase != -1)
@@ -158,7 +158,7 @@ static unsigned int brg_clk = 0;
 unsigned int qe_get_brg_clk(void)
 {
        struct device_node *qe;
-       unsigned int size;
+       int size;
        const u32 *prop;
 
        if (brg_clk)
@@ -305,7 +305,7 @@ EXPORT_SYMBOL(qe_put_snum);
 
 static int qe_sdma_init(void)
 {
-       struct sdma *sdma = &qe_immr->sdma;
+       struct sdma __iomem *sdma = &qe_immr->sdma;
        unsigned long sdma_buf_offset;
 
        if (!sdma)
index d3c7f5a..1d78071 100644 (file)
@@ -88,7 +88,7 @@ int ucc_set_type(unsigned int ucc_num, enum ucc_speed_type speed)
        return 0;
 }
 
-static void get_cmxucr_reg(unsigned int ucc_num, __be32 **cmxucr,
+static void get_cmxucr_reg(unsigned int ucc_num, __be32 __iomem **cmxucr,
        unsigned int *reg_num, unsigned int *shift)
 {
        unsigned int cmx = ((ucc_num & 1) << 1) + (ucc_num > 3);
@@ -100,7 +100,7 @@ static void get_cmxucr_reg(unsigned int ucc_num, __be32 **cmxucr,
 
 int ucc_mux_set_grant_tsa_bkpt(unsigned int ucc_num, int set, u32 mask)
 {
-       __be32 *cmxucr;
+       __be32 __iomem *cmxucr;
        unsigned int reg_num;
        unsigned int shift;
 
@@ -121,7 +121,7 @@ int ucc_mux_set_grant_tsa_bkpt(unsigned int ucc_num, int set, u32 mask)
 int ucc_set_qe_mux_rxtx(unsigned int ucc_num, enum qe_clock clock,
        enum comm_dir mode)
 {
-       __be32 *cmxucr;
+       __be32 __iomem *cmxucr;
        unsigned int reg_num;
        unsigned int shift;
        u32 clock_bits = 0;
index bcf88e6..1aecb07 100644 (file)
@@ -46,7 +46,7 @@ void ucc_fast_dump_regs(struct ucc_fast_private * uccf)
        printk(KERN_INFO "uccm  : addr=0x%p, val=0x%08x\n",
                  &uccf->uf_regs->uccm, in_be32(&uccf->uf_regs->uccm));
        printk(KERN_INFO "uccs  : addr=0x%p, val=0x%02x\n",
-                 &uccf->uf_regs->uccs, uccf->uf_regs->uccs);
+                 &uccf->uf_regs->uccs, in_8(&uccf->uf_regs->uccs));
        printk(KERN_INFO "urfb  : addr=0x%p, val=0x%08x\n",
                  &uccf->uf_regs->urfb, in_be32(&uccf->uf_regs->urfb));
        printk(KERN_INFO "urfs  : addr=0x%p, val=0x%04x\n",
@@ -68,7 +68,7 @@ void ucc_fast_dump_regs(struct ucc_fast_private * uccf)
        printk(KERN_INFO "urtry : addr=0x%p, val=0x%08x\n",
                  &uccf->uf_regs->urtry, in_be32(&uccf->uf_regs->urtry));
        printk(KERN_INFO "guemr : addr=0x%p, val=0x%02x\n",
-                 &uccf->uf_regs->guemr, uccf->uf_regs->guemr);
+                 &uccf->uf_regs->guemr, in_8(&uccf->uf_regs->guemr));
 }
 EXPORT_SYMBOL(ucc_fast_dump_regs);
 
@@ -96,7 +96,7 @@ EXPORT_SYMBOL(ucc_fast_transmit_on_demand);
 
 void ucc_fast_enable(struct ucc_fast_private * uccf, enum comm_dir mode)
 {
-       struct ucc_fast *uf_regs;
+       struct ucc_fast __iomem *uf_regs;
        u32 gumr;
 
        uf_regs = uccf->uf_regs;
@@ -117,7 +117,7 @@ EXPORT_SYMBOL(ucc_fast_enable);
 
 void ucc_fast_disable(struct ucc_fast_private * uccf, enum comm_dir mode)
 {
-       struct ucc_fast *uf_regs;
+       struct ucc_fast __iomem *uf_regs;
        u32 gumr;
 
        uf_regs = uccf->uf_regs;
@@ -139,7 +139,7 @@ EXPORT_SYMBOL(ucc_fast_disable);
 int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** uccf_ret)
 {
        struct ucc_fast_private *uccf;
-       struct ucc_fast *uf_regs;
+       struct ucc_fast __iomem *uf_regs;
        u32 gumr;
        int ret;
 
@@ -216,10 +216,10 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
        uccf->stopped_tx = 0;
        uccf->stopped_rx = 0;
        uf_regs = uccf->uf_regs;
-       uccf->p_ucce = (u32 *) & (uf_regs->ucce);
-       uccf->p_uccm = (u32 *) & (uf_regs->uccm);
+       uccf->p_ucce = &uf_regs->ucce;
+       uccf->p_uccm = &uf_regs->uccm;
 #ifdef CONFIG_UGETH_TX_ON_DEMAND
-       uccf->p_utodr = (u16 *) & (uf_regs->utodr);
+       uccf->p_utodr = &uf_regs->utodr;
 #endif
 #ifdef STATISTICS
        uccf->tx_frames = 0;
index b678103..b795b3e 100644 (file)
@@ -864,7 +864,8 @@ int setup_profiling_timer(unsigned int multiplier)
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
-static ssize_t cpu_configure_show(struct sys_device *dev, char *buf)
+static ssize_t cpu_configure_show(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        ssize_t count;
 
@@ -874,8 +875,9 @@ static ssize_t cpu_configure_show(struct sys_device *dev, char *buf)
        return count;
 }
 
-static ssize_t cpu_configure_store(struct sys_device *dev, const char *buf,
-                                  size_t count)
+static ssize_t cpu_configure_store(struct sys_device *dev,
+                                 struct sysdev_attribute *attr,
+                                 const char *buf, size_t count)
 {
        int cpu = dev->id;
        int val, rc;
@@ -922,7 +924,8 @@ out:
 static SYSDEV_ATTR(configure, 0644, cpu_configure_show, cpu_configure_store);
 #endif /* CONFIG_HOTPLUG_CPU */
 
-static ssize_t cpu_polarization_show(struct sys_device *dev, char *buf)
+static ssize_t cpu_polarization_show(struct sys_device *dev,
+                                    struct sysdev_attribute *attr, char *buf)
 {
        int cpu = dev->id;
        ssize_t count;
@@ -950,7 +953,8 @@ static ssize_t cpu_polarization_show(struct sys_device *dev, char *buf)
 }
 static SYSDEV_ATTR(polarization, 0444, cpu_polarization_show, NULL);
 
-static ssize_t show_cpu_address(struct sys_device *dev, char *buf)
+static ssize_t show_cpu_address(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        return sprintf(buf, "%d\n", __cpu_logical_map[dev->id]);
 }
@@ -970,7 +974,8 @@ static struct attribute_group cpu_common_attr_group = {
        .attrs = cpu_common_attrs,
 };
 
-static ssize_t show_capability(struct sys_device *dev, char *buf)
+static ssize_t show_capability(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        unsigned int capability;
        int rc;
@@ -982,7 +987,8 @@ static ssize_t show_capability(struct sys_device *dev, char *buf)
 }
 static SYSDEV_ATTR(capability, 0444, show_capability, NULL);
 
-static ssize_t show_idle_count(struct sys_device *dev, char *buf)
+static ssize_t show_idle_count(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        struct s390_idle_data *idle;
        unsigned long long idle_count;
@@ -995,7 +1001,8 @@ static ssize_t show_idle_count(struct sys_device *dev, char *buf)
 }
 static SYSDEV_ATTR(idle_count, 0444, show_idle_count, NULL);
 
-static ssize_t show_idle_time(struct sys_device *dev, char *buf)
+static ssize_t show_idle_time(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        struct s390_idle_data *idle;
        unsigned long long new_time;
@@ -1112,7 +1119,9 @@ out:
        return rc;
 }
 
-static ssize_t __ref rescan_store(struct sys_device *dev, const char *buf,
+static ssize_t __ref rescan_store(struct sys_device *dev,
+                                 struct sysdev_attribute *attr,
+                                 const char *buf,
                                  size_t count)
 {
        int rc;
@@ -1123,7 +1132,9 @@ static ssize_t __ref rescan_store(struct sys_device *dev, const char *buf,
 static SYSDEV_ATTR(rescan, 0200, NULL, rescan_store);
 #endif /* CONFIG_HOTPLUG_CPU */
 
-static ssize_t dispatching_show(struct sys_device *dev, char *buf)
+static ssize_t dispatching_show(struct sys_device *dev,
+                               struct sysdev_attribute *attr,
+                               char *buf)
 {
        ssize_t count;
 
@@ -1133,8 +1144,9 @@ static ssize_t dispatching_show(struct sys_device *dev, char *buf)
        return count;
 }
 
-static ssize_t dispatching_store(struct sys_device *dev, const char *buf,
-                                size_t count)
+static ssize_t dispatching_store(struct sys_device *dev,
+                                struct sysdev_attribute *attr,
+                                const char *buf, size_t count)
 {
        int val, rc;
        char delim;
index f2cede3..ab70d9b 100644 (file)
@@ -1100,7 +1100,9 @@ static inline struct etr_aib *etr_aib_from_dev(struct sys_device *dev)
                return etr_port1_online ? &etr_port1 : NULL;
 }
 
-static ssize_t etr_online_show(struct sys_device *dev, char *buf)
+static ssize_t etr_online_show(struct sys_device *dev,
+                               struct sysdev_attribute *attr,
+                               char *buf)
 {
        unsigned int online;
 
@@ -1109,7 +1111,8 @@ static ssize_t etr_online_show(struct sys_device *dev, char *buf)
 }
 
 static ssize_t etr_online_store(struct sys_device *dev,
-                             const char *buf, size_t count)
+                               struct sysdev_attribute *attr,
+                               const char *buf, size_t count)
 {
        unsigned int value;
 
@@ -1136,7 +1139,9 @@ static ssize_t etr_online_store(struct sys_device *dev,
 
 static SYSDEV_ATTR(online, 0600, etr_online_show, etr_online_store);
 
-static ssize_t etr_stepping_control_show(struct sys_device *dev, char *buf)
+static ssize_t etr_stepping_control_show(struct sys_device *dev,
+                                       struct sysdev_attribute *attr,
+                                       char *buf)
 {
        return sprintf(buf, "%i\n", (dev == &etr_port0_dev) ?
                       etr_eacr.e0 : etr_eacr.e1);
@@ -1144,7 +1149,8 @@ static ssize_t etr_stepping_control_show(struct sys_device *dev, char *buf)
 
 static SYSDEV_ATTR(stepping_control, 0400, etr_stepping_control_show, NULL);
 
-static ssize_t etr_mode_code_show(struct sys_device *dev, char *buf)
+static ssize_t etr_mode_code_show(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        if (!etr_port0_online && !etr_port1_online)
                /* Status word is not uptodate if both ports are offline. */
@@ -1155,7 +1161,8 @@ static ssize_t etr_mode_code_show(struct sys_device *dev, char *buf)
 
 static SYSDEV_ATTR(state_code, 0400, etr_mode_code_show, NULL);
 
-static ssize_t etr_untuned_show(struct sys_device *dev, char *buf)
+static ssize_t etr_untuned_show(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        struct etr_aib *aib = etr_aib_from_dev(dev);
 
@@ -1166,7 +1173,8 @@ static ssize_t etr_untuned_show(struct sys_device *dev, char *buf)
 
 static SYSDEV_ATTR(untuned, 0400, etr_untuned_show, NULL);
 
-static ssize_t etr_network_id_show(struct sys_device *dev, char *buf)
+static ssize_t etr_network_id_show(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        struct etr_aib *aib = etr_aib_from_dev(dev);
 
@@ -1177,7 +1185,8 @@ static ssize_t etr_network_id_show(struct sys_device *dev, char *buf)
 
 static SYSDEV_ATTR(network, 0400, etr_network_id_show, NULL);
 
-static ssize_t etr_id_show(struct sys_device *dev, char *buf)
+static ssize_t etr_id_show(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        struct etr_aib *aib = etr_aib_from_dev(dev);
 
@@ -1188,7 +1197,8 @@ static ssize_t etr_id_show(struct sys_device *dev, char *buf)
 
 static SYSDEV_ATTR(id, 0400, etr_id_show, NULL);
 
-static ssize_t etr_port_number_show(struct sys_device *dev, char *buf)
+static ssize_t etr_port_number_show(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        struct etr_aib *aib = etr_aib_from_dev(dev);
 
@@ -1199,7 +1209,8 @@ static ssize_t etr_port_number_show(struct sys_device *dev, char *buf)
 
 static SYSDEV_ATTR(port, 0400, etr_port_number_show, NULL);
 
-static ssize_t etr_coupled_show(struct sys_device *dev, char *buf)
+static ssize_t etr_coupled_show(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        struct etr_aib *aib = etr_aib_from_dev(dev);
 
@@ -1210,7 +1221,8 @@ static ssize_t etr_coupled_show(struct sys_device *dev, char *buf)
 
 static SYSDEV_ATTR(coupled, 0400, etr_coupled_show, NULL);
 
-static ssize_t etr_local_time_show(struct sys_device *dev, char *buf)
+static ssize_t etr_local_time_show(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        struct etr_aib *aib = etr_aib_from_dev(dev);
 
@@ -1221,7 +1233,8 @@ static ssize_t etr_local_time_show(struct sys_device *dev, char *buf)
 
 static SYSDEV_ATTR(local_time, 0400, etr_local_time_show, NULL);
 
-static ssize_t etr_utc_offset_show(struct sys_device *dev, char *buf)
+static ssize_t etr_utc_offset_show(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        struct etr_aib *aib = etr_aib_from_dev(dev);
 
index 51b57c0..347ee11 100644 (file)
@@ -23,7 +23,8 @@ static struct sysdev_class dma_sysclass = {
 };
 EXPORT_SYMBOL(dma_sysclass);
 
-static ssize_t dma_show_devices(struct sys_device *dev, char *buf)
+static ssize_t dma_show_devices(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        ssize_t len = 0;
        int i;
@@ -57,13 +58,15 @@ static int __init dma_sysclass_init(void)
 }
 postcore_initcall(dma_sysclass_init);
 
-static ssize_t dma_show_dev_id(struct sys_device *dev, char *buf)
+static ssize_t dma_show_dev_id(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        struct dma_channel *channel = to_dma_channel(dev);
        return sprintf(buf, "%s\n", channel->dev_id);
 }
 
 static ssize_t dma_store_dev_id(struct sys_device *dev,
+                               struct sysdev_attribute *attr,
                                const char *buf, size_t count)
 {
        struct dma_channel *channel = to_dma_channel(dev);
@@ -74,6 +77,7 @@ static ssize_t dma_store_dev_id(struct sys_device *dev,
 static SYSDEV_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id);
 
 static ssize_t dma_store_config(struct sys_device *dev,
+                               struct sysdev_attribute *attr,
                                const char *buf, size_t count)
 {
        struct dma_channel *channel = to_dma_channel(dev);
@@ -87,13 +91,15 @@ static ssize_t dma_store_config(struct sys_device *dev,
 
 static SYSDEV_ATTR(config, S_IWUSR, NULL, dma_store_config);
 
-static ssize_t dma_show_mode(struct sys_device *dev, char *buf)
+static ssize_t dma_show_mode(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        struct dma_channel *channel = to_dma_channel(dev);
        return sprintf(buf, "0x%08x\n", channel->mode);
 }
 
 static ssize_t dma_store_mode(struct sys_device *dev,
+                             struct sysdev_attribute *attr,
                              const char *buf, size_t count)
 {
        struct dma_channel *channel = to_dma_channel(dev);
@@ -104,7 +110,8 @@ static ssize_t dma_store_mode(struct sys_device *dev,
 static SYSDEV_ATTR(mode, S_IRUGO | S_IWUSR, dma_show_mode, dma_store_mode);
 
 #define dma_ro_attr(field, fmt)                                                \
-static ssize_t dma_show_##field(struct sys_device *dev, char *buf)     \
+static ssize_t dma_show_##field(struct sys_device *dev,                \
+                               struct sysdev_attribute *attr, char *buf)\
 {                                                                      \
        struct dma_channel *channel = to_dma_channel(dev);              \
        return sprintf(buf, fmt, channel->field);                       \
index c49d038..4d58d7c 100644 (file)
@@ -401,7 +401,7 @@ static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_de
        dev->ofdev.node = dp;
        dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
        dev->ofdev.dev.bus = &ebus_bus_type;
-       sprintf(dev->ofdev.dev.bus_id, "ebus[%08x]", dp->node);
+       dev_set_name(&dev->ofdev.dev, "ebus[%08x]", dp->node);
 
        /* Register with core */
        if (of_device_register(&dev->ofdev) != 0)
@@ -501,7 +501,7 @@ void __init ebus_init(void)
                ebus->ofdev.node = dp;
                ebus->ofdev.dev.parent = &pdev->dev;
                ebus->ofdev.dev.bus = &ebus_bus_type;
-               sprintf(ebus->ofdev.dev.bus_id, "ebus%d", num_ebus);
+               dev_set_name(&ebus->ofdev.dev, "ebus%d", num_ebus);
 
                /* Register with core */
                if (of_device_register(&ebus->ofdev) != 0)
index d569f60..4fd48ab 100644 (file)
@@ -797,9 +797,9 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
        op->dev.parent = parent;
        op->dev.bus = &of_platform_bus_type;
        if (!parent)
-               strcpy(op->dev.bus_id, "root");
+               dev_set_name(&op->dev, "root");
        else
-               sprintf(op->dev.bus_id, "%08x", dp->node);
+               dev_set_name(&op->dev, "%08x", dp->node);
 
        if (of_device_register(op)) {
                printk("%s: Could not register of device.\n",
index d00a365..5509619 100644 (file)
@@ -408,7 +408,7 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
        dev->class = class >> 8;
        dev->revision = class & 0xff;
 
-       sprintf(dev->dev.bus_id, "%04x:%02x:%02x.%d", pci_domain_nr(bus),
+       dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", pci_domain_nr(bus),
                dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
 
        if (ofpci_verbose)
index e885034..84e5ce1 100644 (file)
@@ -14,7 +14,8 @@
 static DEFINE_PER_CPU(struct hv_mmu_statistics, mmu_stats) __attribute__((aligned(64)));
 
 #define SHOW_MMUSTAT_ULONG(NAME) \
-static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
+static ssize_t show_##NAME(struct sys_device *dev, \
+                       struct sysdev_attribute *attr, char *buf) \
 { \
        struct hv_mmu_statistics *p = &per_cpu(mmu_stats, dev->id); \
        return sprintf(buf, "%lu\n", p->NAME); \
@@ -135,13 +136,16 @@ static unsigned long write_mmustat_enable(unsigned long val)
        return sun4v_mmustat_conf(ra, &orig_ra);
 }
 
-static ssize_t show_mmustat_enable(struct sys_device *s, char *buf)
+static ssize_t show_mmustat_enable(struct sys_device *s,
+                               struct sysdev_attribute *attr, char *buf)
 {
        unsigned long val = run_on_cpu(s->id, read_mmustat_enable, 0);
        return sprintf(buf, "%lx\n", val);
 }
 
-static ssize_t store_mmustat_enable(struct sys_device *s, const char *buf, size_t count)
+static ssize_t store_mmustat_enable(struct sys_device *s,
+                       struct sysdev_attribute *attr, const char *buf,
+                       size_t count)
 {
        unsigned long val, err;
        int ret = sscanf(buf, "%ld", &val);
@@ -179,14 +183,16 @@ static void unregister_mmu_stats(struct sys_device *s)
 #endif
 
 #define SHOW_CPUDATA_ULONG_NAME(NAME, MEMBER) \
-static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
+static ssize_t show_##NAME(struct sys_device *dev, \
+               struct sysdev_attribute *attr, char *buf) \
 { \
        cpuinfo_sparc *c = &cpu_data(dev->id); \
        return sprintf(buf, "%lu\n", c->MEMBER); \
 }
 
 #define SHOW_CPUDATA_UINT_NAME(NAME, MEMBER) \
-static ssize_t show_##NAME(struct sys_device *dev, char *buf) \
+static ssize_t show_##NAME(struct sys_device *dev, \
+               struct sysdev_attribute *attr, char *buf) \
 { \
        cpuinfo_sparc *c = &cpu_data(dev->id); \
        return sprintf(buf, "%u\n", c->MEMBER); \
index e78b351..a490077 100644 (file)
@@ -224,7 +224,7 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
        if (!strcmp(type, "domain-services-port"))
                bus_id_name = "ds";
 
-       if (strlen(bus_id_name) >= KOBJ_NAME_LEN - 4) {
+       if (strlen(bus_id_name) >= BUS_ID_SIZE - 4) {
                printk(KERN_ERR "VIO: bus_id_name [%s] is too long.\n",
                       bus_id_name);
                return NULL;
@@ -260,16 +260,14 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
        vio_fill_channel_info(hp, mp, vdev);
 
        if (!id) {
-               snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s",
-                        bus_id_name);
+               dev_set_name(&vdev->dev, "%s", bus_id_name);
                vdev->dev_no = ~(u64)0;
        } else if (!cfg_handle) {
-               snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s-%lu",
-                        bus_id_name, *id);
+               dev_set_name(&vdev->dev, "%s-%lu", bus_id_name, *id);
                vdev->dev_no = *id;
        } else {
-               snprintf(vdev->dev.bus_id, BUS_ID_SIZE, "%s-%lu-%lu",
-                        bus_id_name, *cfg_handle, *id);
+               dev_set_name(&vdev->dev, "%s-%lu-%lu", bus_id_name,
+                            *cfg_handle, *id);
                vdev->dev_no = *cfg_handle;
        }
 
@@ -292,12 +290,12 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
        }
        vdev->dp = dp;
 
-       printk(KERN_INFO "VIO: Adding device %s\n", vdev->dev.bus_id);
+       printk(KERN_INFO "VIO: Adding device %s\n", dev_name(&vdev->dev));
 
        err = device_register(&vdev->dev);
        if (err) {
                printk(KERN_ERR "VIO: Could not register device %s, err=%d\n",
-                      vdev->dev.bus_id, err);
+                      dev_name(&vdev->dev), err);
                kfree(vdev);
                return NULL;
        }
@@ -330,7 +328,7 @@ static void vio_remove(struct mdesc_handle *hp, u64 node)
        dev = device_find_child(&root_vdev->dev, (void *) node,
                                vio_md_node_match);
        if (dev) {
-               printk(KERN_INFO "VIO: Removing device %s\n", dev->bus_id);
+               printk(KERN_INFO "VIO: Removing device %s\n", dev_name(dev));
 
                device_unregister(dev);
        }
index c4a7ec3..9ab65be 100644 (file)
@@ -762,10 +762,14 @@ DEFINE_PER_CPU(struct sys_device, device_mce);
 
 /* Why are there no generic functions for this? */
 #define ACCESSOR(name, var, start) \
-       static ssize_t show_ ## name(struct sys_device *s, char *buf) { \
+       static ssize_t show_ ## name(struct sys_device *s,              \
+                                    struct sysdev_attribute *attr,     \
+                                    char *buf) {                       \
                return sprintf(buf, "%lx\n", (unsigned long)var);       \
        }                                                               \
-       static ssize_t set_ ## name(struct sys_device *s,const char *buf,size_t siz) { \
+       static ssize_t set_ ## name(struct sys_device *s,               \
+                                   struct sysdev_attribute *attr,      \
+                                   const char *buf, size_t siz) {      \
                char *end;                                              \
                unsigned long new = simple_strtoul(buf, &end, 0);       \
                if (end == buf) return -EINVAL;                         \
@@ -786,14 +790,16 @@ ACCESSOR(bank3ctl,bank[3],mce_restart())
 ACCESSOR(bank4ctl,bank[4],mce_restart())
 ACCESSOR(bank5ctl,bank[5],mce_restart())
 
-static ssize_t show_trigger(struct sys_device *s, char *buf)
+static ssize_t show_trigger(struct sys_device *s, struct sysdev_attribute *attr,
+                               char *buf)
 {
        strcpy(buf, trigger);
        strcat(buf, "\n");
        return strlen(trigger) + 1;
 }
 
-static ssize_t set_trigger(struct sys_device *s,const char *buf,size_t siz)
+static ssize_t set_trigger(struct sys_device *s, struct sysdev_attribute *attr,
+                               const char *buf,size_t siz)
 {
        char *p;
        int len;
@@ -806,12 +812,12 @@ static ssize_t set_trigger(struct sys_device *s,const char *buf,size_t siz)
 }
 
 static SYSDEV_ATTR(trigger, 0644, show_trigger, set_trigger);
-ACCESSOR(tolerant,tolerant,)
+static SYSDEV_INT_ATTR(tolerant, 0644, tolerant);
 ACCESSOR(check_interval,check_interval,mce_restart())
 static struct sysdev_attribute *mce_attributes[] = {
        &attr_bank0ctl, &attr_bank1ctl, &attr_bank2ctl,
        &attr_bank3ctl, &attr_bank4ctl, &attr_bank5ctl,
-       &attr_tolerant, &attr_check_interval, &attr_trigger,
+       &attr_tolerant.attr, &attr_check_interval, &attr_trigger,
        NULL
 };
 
index 1f4cc48..d5ae224 100644 (file)
@@ -35,6 +35,7 @@ atomic_t therm_throt_en = ATOMIC_INIT(0);
 
 #define define_therm_throt_sysdev_show_func(name)                            \
 static ssize_t therm_throt_sysdev_show_##name(struct sys_device *dev,        \
+                                       struct sysdev_attribute *attr,       \
                                               char *buf)                     \
 {                                                                            \
        unsigned int cpu = dev->id;                                          \
index 2de5fa2..14b11b3 100644 (file)
@@ -141,8 +141,8 @@ static __cpuinit int cpuid_device_create(int cpu)
 {
        struct device *dev;
 
-       dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu),
-                           "cpu%d", cpu);
+       dev = device_create_drvdata(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu),
+                                   NULL, "cpu%d", cpu);
        return IS_ERR(dev) ? PTR_ERR(dev) : 0;
 }
 
index 56b9331..fc47906 100644 (file)
@@ -644,7 +644,9 @@ static void microcode_fini_cpu(int cpu)
        mutex_unlock(&microcode_mutex);
 }
 
-static ssize_t reload_store(struct sys_device *dev, const char *buf, size_t sz)
+static ssize_t reload_store(struct sys_device *dev,
+                           struct sysdev_attribute *attr,
+                           const char *buf, size_t sz)
 {
        struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
        char *end;
@@ -674,14 +676,16 @@ static ssize_t reload_store(struct sys_device *dev, const char *buf, size_t sz)
        return sz;
 }
 
-static ssize_t version_show(struct sys_device *dev, char *buf)
+static ssize_t version_show(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
 
        return sprintf(buf, "0x%x\n", uci->rev);
 }
 
-static ssize_t pf_show(struct sys_device *dev, char *buf)
+static ssize_t pf_show(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
 
index a153b39..9fd8095 100644 (file)
@@ -149,8 +149,8 @@ static int __cpuinit msr_device_create(int cpu)
 {
        struct device *dev;
 
-       dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, cpu),
-                           "msr%d", cpu);
+       dev = device_create_drvdata(msr_class, NULL, MKDEV(MSR_MAJOR, cpu),
+                                   NULL, "msr%d", cpu);
        return IS_ERR(dev) ? PTR_ERR(dev) : 0;
 }
 
index a4213c0..cbecb05 100644 (file)
@@ -314,8 +314,7 @@ int dma_supported(struct device *dev, u64 mask)
 {
 #ifdef CONFIG_PCI
        if (mask > 0xffffffff && forbid_dac > 0) {
-               printk(KERN_INFO "PCI: Disallowing DAC for device %s\n",
-                                dev->bus_id);
+               dev_info(dev, "PCI: Disallowing DAC for device\n");
                return 0;
        }
 #endif
@@ -342,8 +341,7 @@ int dma_supported(struct device *dev, u64 mask)
           type. Normally this doesn't make any difference, but gives
           more gentle handling of IOMMU overflow. */
        if (iommu_sac_force && (mask >= DMA_40BIT_MASK)) {
-               printk(KERN_INFO "%s: Force SAC with mask %Lx\n",
-                                dev->bus_id, mask);
+               dev_info(dev, "Force SAC with mask %Lx\n", mask);
                return 0;
        }
 
index be60961..df5f142 100644 (file)
@@ -198,9 +198,7 @@ static void iommu_full(struct device *dev, size_t size, int dir)
         * out. Hopefully no network devices use single mappings that big.
         */
 
-       printk(KERN_ERR
-               "PCI-DMA: Out of IOMMU space for %lu bytes at device %s\n",
-               size, dev->bus_id);
+       dev_err(dev, "PCI-DMA: Out of IOMMU space for %lu bytes\n", size);
 
        if (size > PAGE_SIZE*EMERGENCY_PAGES) {
                if (dir == PCI_DMA_FROMDEVICE || dir == PCI_DMA_BIDIRECTIONAL)
index 5fb9b0b..5a68b09 100644 (file)
@@ -1044,7 +1044,8 @@ int bsg_register_queue(struct request_queue *q, struct device *parent,
        bcd->release = release;
        kref_init(&bcd->ref);
        dev = MKDEV(bsg_major, bcd->minor);
-       class_dev = device_create(bsg_class, parent, dev, "%s", devname);
+       class_dev = device_create_drvdata(bsg_class, parent, dev, NULL,
+                                         "%s", devname);
        if (IS_ERR(class_dev)) {
                ret = PTR_ERR(class_dev);
                goto put_dev;
index 9074f38..c13cc77 100644 (file)
@@ -183,6 +183,7 @@ static int exact_lock(dev_t devt, void *data)
 void add_disk(struct gendisk *disk)
 {
        struct backing_dev_info *bdi;
+       int retval;
 
        disk->flags |= GENHD_FL_UP;
        blk_register_region(MKDEV(disk->major, disk->first_minor),
@@ -193,7 +194,8 @@ void add_disk(struct gendisk *disk)
 
        bdi = &disk->queue->backing_dev_info;
        bdi_register_dev(bdi, MKDEV(disk->major, disk->first_minor));
-       sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi");
+       retval = sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi");
+       WARN_ON(retval);
 }
 
 EXPORT_SYMBOL(add_disk);
@@ -225,89 +227,111 @@ struct gendisk *get_gendisk(dev_t devt, int *part)
 }
 
 /*
- * print a full list of all partitions - intended for places where the root
- * filesystem can't be mounted and thus to give the victim some idea of what
- * went wrong
+ * print a partitions - intended for places where the root filesystem can't be
+ * mounted and thus to give the victim some idea of what went wrong
  */
-void __init printk_all_partitions(void)
+static int printk_partition(struct device *dev, void *data)
 {
-       struct device *dev;
        struct gendisk *sgp;
        char buf[BDEVNAME_SIZE];
        int n;
 
-       mutex_lock(&block_class_lock);
-       /* For each block device... */
-       list_for_each_entry(dev, &block_class.devices, node) {
-               if (dev->type != &disk_type)
-                       continue;
-               sgp = dev_to_disk(dev);
-               /*
-                * Don't show empty devices or things that have been surpressed
-                */
-               if (get_capacity(sgp) == 0 ||
-                   (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
-                       continue;
+       if (dev->type != &disk_type)
+               goto exit;
 
-               /*
-                * Note, unlike /proc/partitions, I am showing the numbers in
-                * hex - the same format as the root= option takes.
-                */
-               printk("%02x%02x %10llu %s",
-                       sgp->major, sgp->first_minor,
-                       (unsigned long long)get_capacity(sgp) >> 1,
-                       disk_name(sgp, 0, buf));
-               if (sgp->driverfs_dev != NULL &&
-                   sgp->driverfs_dev->driver != NULL)
-                       printk(" driver: %s\n",
-                               sgp->driverfs_dev->driver->name);
-               else
-                       printk(" (driver?)\n");
-
-               /* now show the partitions */
-               for (n = 0; n < sgp->minors - 1; ++n) {
-                       if (sgp->part[n] == NULL)
-                               continue;
-                       if (sgp->part[n]->nr_sects == 0)
-                               continue;
-                       printk("  %02x%02x %10llu %s\n",
-                               sgp->major, n + 1 + sgp->first_minor,
-                               (unsigned long long)sgp->part[n]->nr_sects >> 1,
-                               disk_name(sgp, n + 1, buf));
-               }
+       sgp = dev_to_disk(dev);
+       /*
+        * Don't show empty devices or things that have been surpressed
+        */
+       if (get_capacity(sgp) == 0 ||
+           (sgp->flags & GENHD_FL_SUPPRESS_PARTITION_INFO))
+               goto exit;
+
+       /*
+        * Note, unlike /proc/partitions, I am showing the numbers in
+        * hex - the same format as the root= option takes.
+        */
+       printk("%02x%02x %10llu %s",
+               sgp->major, sgp->first_minor,
+               (unsigned long long)get_capacity(sgp) >> 1,
+               disk_name(sgp, 0, buf));
+       if (sgp->driverfs_dev != NULL &&
+           sgp->driverfs_dev->driver != NULL)
+               printk(" driver: %s\n",
+                       sgp->driverfs_dev->driver->name);
+       else
+               printk(" (driver?)\n");
+
+       /* now show the partitions */
+       for (n = 0; n < sgp->minors - 1; ++n) {
+               if (sgp->part[n] == NULL)
+                       goto exit;
+               if (sgp->part[n]->nr_sects == 0)
+                       goto exit;
+               printk("  %02x%02x %10llu %s\n",
+                       sgp->major, n + 1 + sgp->first_minor,
+                       (unsigned long long)sgp->part[n]->nr_sects >> 1,
+                       disk_name(sgp, n + 1, buf));
        }
+exit:
+       return 0;
+}
 
+/*
+ * print a full list of all partitions - intended for places where the root
+ * filesystem can't be mounted and thus to give the victim some idea of what
+ * went wrong
+ */
+void __init printk_all_partitions(void)
+{
+       mutex_lock(&block_class_lock);
+       class_for_each_device(&block_class, NULL, NULL, printk_partition);
        mutex_unlock(&block_class_lock);
 }
 
 #ifdef CONFIG_PROC_FS
 /* iterator */
+static int find_start(struct device *dev, void *data)
+{
+       loff_t k = *(loff_t *)data;
+
+       if (dev->type != &disk_type)
+               return 0;
+       if (!k--)
+               return 1;
+       return 0;
+}
+
 static void *part_start(struct seq_file *part, loff_t *pos)
 {
-       loff_t k = *pos;
        struct device *dev;
+       loff_t n = *pos;
+
+       if (!n)
+               seq_puts(part, "major minor  #blocks  name\n\n");
 
        mutex_lock(&block_class_lock);
-       list_for_each_entry(dev, &block_class.devices, node) {
-               if (dev->type != &disk_type)
-                       continue;
-               if (!k--)
-                       return dev_to_disk(dev);
-       }
+       dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
+       if (dev)
+               return dev_to_disk(dev);
        return NULL;
 }
 
+static int find_next(struct device *dev, void *data)
+{
+       if (dev->type == &disk_type)
+               return 1;
+       return 0;
+}
+
 static void *part_next(struct seq_file *part, void *v, loff_t *pos)
 {
        struct gendisk *gp = v;
        struct device *dev;
        ++*pos;
-       list_for_each_entry(dev, &gp->dev.node, node) {
-               if (&dev->node == &block_class.devices)
-                       return NULL;
-               if (dev->type == &disk_type)
-                       return dev_to_disk(dev);
-       }
+       dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
+       if (dev)
+               return dev_to_disk(dev);
        return NULL;
 }
 
@@ -322,9 +346,6 @@ static int show_partition(struct seq_file *part, void *v)
        int n;
        char buf[BDEVNAME_SIZE];
 
-       if (&sgp->dev.node == block_class.devices.next)
-               seq_puts(part, "major minor  #blocks  name\n\n");
-
        /* Don't show non-partitionable removeable devices or empty devices */
        if (!get_capacity(sgp) ||
                        (sgp->minors == 1 && (sgp->flags & GENHD_FL_REMOVABLE)))
@@ -370,7 +391,10 @@ static struct kobject *base_probe(dev_t devt, int *part, void *data)
 
 static int __init genhd_device_init(void)
 {
-       int error = class_register(&block_class);
+       int error;
+
+       block_class.dev_kobj = sysfs_dev_block_kobj;
+       error = class_register(&block_class);
        if (unlikely(error))
                return error;
        bdev_map = kobj_map_init(base_probe, &block_class_lock);
@@ -532,6 +556,7 @@ static struct device_type disk_type = {
        .release        = disk_release,
 };
 
+#ifdef CONFIG_PROC_FS
 /*
  * aggregate disk stat collector.  Uses the same stats that the sysfs
  * entries do, above, but makes them available through one seq_file.
@@ -542,16 +567,12 @@ static struct device_type disk_type = {
 
 static void *diskstats_start(struct seq_file *part, loff_t *pos)
 {
-       loff_t k = *pos;
        struct device *dev;
 
        mutex_lock(&block_class_lock);
-       list_for_each_entry(dev, &block_class.devices, node) {
-               if (dev->type != &disk_type)
-                       continue;
-               if (!k--)
-                       return dev_to_disk(dev);
-       }
+       dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
+       if (dev)
+               return dev_to_disk(dev);
        return NULL;
 }
 
@@ -561,12 +582,9 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
        struct device *dev;
 
        ++*pos;
-       list_for_each_entry(dev, &gp->dev.node, node) {
-               if (&dev->node == &block_class.devices)
-                       return NULL;
-               if (dev->type == &disk_type)
-                       return dev_to_disk(dev);
-       }
+       dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
+       if (dev)
+               return dev_to_disk(dev);
        return NULL;
 }
 
@@ -641,6 +659,7 @@ const struct seq_operations diskstats_op = {
        .stop   = diskstats_stop,
        .show   = diskstats_show
 };
+#endif /* CONFIG_PROC_FS */
 
 static void media_change_notify_thread(struct work_struct *work)
 {
@@ -665,24 +684,38 @@ void genhd_media_change_notify(struct gendisk *disk)
 EXPORT_SYMBOL_GPL(genhd_media_change_notify);
 #endif  /*  0  */
 
+struct find_block {
+       const char *name;
+       int part;
+};
+
+static int match_id(struct device *dev, void *data)
+{
+       struct find_block *find = data;
+
+       if (dev->type != &disk_type)
+               return 0;
+       if (strcmp(dev->bus_id, find->name) == 0) {
+               struct gendisk *disk = dev_to_disk(dev);
+               if (find->part < disk->minors)
+                       return 1;
+       }
+       return 0;
+}
+
 dev_t blk_lookup_devt(const char *name, int part)
 {
        struct device *dev;
        dev_t devt = MKDEV(0, 0);
+       struct find_block find;
 
        mutex_lock(&block_class_lock);
-       list_for_each_entry(dev, &block_class.devices, node) {
-               if (dev->type != &disk_type)
-                       continue;
-               if (strcmp(dev->bus_id, name) == 0) {
-                       struct gendisk *disk = dev_to_disk(dev);
-
-                       if (part < disk->minors)
-                               devt = MKDEV(MAJOR(dev->devt),
-                                            MINOR(dev->devt) + part);
-                       break;
-               }
-       }
+       find.name = name;
+       find.part = part;
+       dev = class_find_device(&block_class, NULL, (void *)&find, match_id);
+       if (dev)
+               devt = MKDEV(MAJOR(dev->devt),
+                            MINOR(dev->devt) + part);
        mutex_unlock(&block_class_lock);
 
        return devt;
index 55c17af..2655bc1 100644 (file)
@@ -263,22 +263,22 @@ static int acpi_fan_add(struct acpi_device *device)
                goto end;
        }
 
-       printk(KERN_INFO PREFIX
-               "%s is registered as cooling_device%d\n",
-               device->dev.bus_id, cdev->id);
+       dev_info(&device->dev, "registered as cooling_device%d\n", cdev->id);
 
        acpi_driver_data(device) = cdev;
        result = sysfs_create_link(&device->dev.kobj,
                                   &cdev->device.kobj,
                                   "thermal_cooling");
        if (result)
-               printk(KERN_ERR PREFIX "Create sysfs link\n");
+               dev_err(&device->dev, "Failed to create sysfs link "
+                       "'thermal_cooling'\n");
 
        result = sysfs_create_link(&cdev->device.kobj,
                                   &device->dev.kobj,
                                   "device");
        if (result)
-               printk(KERN_ERR PREFIX "Create sysfs link\n");
+               dev_err(&device->dev, "Failed to create sysfs link "
+                       "'device'\n");
 
        result = acpi_fan_add_fs(device);
        if (result)
index 2f173e8..0841095 100644 (file)
@@ -146,8 +146,7 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
        acpi_status status;
 
        if (dev->archdata.acpi_handle) {
-               printk(KERN_WARNING PREFIX
-                      "Drivers changed 'acpi_handle' for %s\n", dev->bus_id);
+               dev_warn(dev, "Drivers changed 'acpi_handle'\n");
                return -EINVAL;
        }
        get_device(dev);
@@ -195,8 +194,7 @@ static int acpi_unbind_one(struct device *dev)
                /* acpi_bind_one increase refcnt by one */
                put_device(dev);
        } else {
-               printk(KERN_ERR PREFIX
-                      "Oops, 'acpi_handle' corrupt for %s\n", dev->bus_id);
+               dev_err(dev, "Oops, 'acpi_handle' corrupt\n");
        }
        return 0;
 }
index ec0f2d5..e36422a 100644 (file)
@@ -714,9 +714,8 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
                goto end;
        }
 
-       printk(KERN_INFO PREFIX
-               "%s is registered as cooling_device%d\n",
-               device->dev.bus_id, pr->cdev->id);
+       dev_info(&device->dev, "registered as cooling_device%d\n",
+                pr->cdev->id);
 
        result = sysfs_create_link(&device->dev.kobj,
                                   &pr->cdev->device.kobj,
index f3132aa..f6f52c1 100644 (file)
@@ -471,7 +471,7 @@ static int acpi_device_register(struct acpi_device *device,
        device->dev.release = &acpi_device_release;
        result = device_add(&device->dev);
        if(result) {
-               printk(KERN_ERR PREFIX "Error adding device %s", device->dev.bus_id);
+               dev_err(&device->dev, "Error adding device\n");
                goto end;
        }
 
index 84c795f..30a3413 100644 (file)
@@ -1179,8 +1179,8 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
 
        tz->tz_enabled = 1;
 
-       printk(KERN_INFO PREFIX "%s is registered as thermal_zone%d\n",
-                       tz->device->dev.bus_id, tz->thermal_zone->id);
+       dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
+                tz->thermal_zone->id);
        return 0;
 }
 
index 64c8893..37b9e16 100644 (file)
@@ -762,9 +762,8 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
                if (IS_ERR(device->cdev))
                        return;
 
-               printk(KERN_INFO PREFIX
-                       "%s is registered as cooling_device%d\n",
-                       device->dev->dev.bus_id, device->cdev->id);
+               dev_info(&device->dev->dev, "registered as cooling_device%d\n",
+                        device->cdev->id);
                result = sysfs_create_link(&device->dev->dev.kobj,
                                &device->cdev->device.kobj,
                                "thermal_cooling");
index d47482f..6318f6b 100644 (file)
@@ -27,8 +27,9 @@ config PREVENT_FIRMWARE_BUILD
          If unsure say Y here.
 
 config FW_LOADER
-       tristate "Userspace firmware loading support"
+       tristate "Userspace firmware loading support" if EMBEDDED
        depends on HOTPLUG
+       default y
        ---help---
          This option is provided for the case where no in-kernel-tree modules
          require userspace firmware loading support, but a module built outside
index 2c9ae43..31dc0cd 100644 (file)
@@ -36,6 +36,33 @@ struct driver_private {
 };
 #define to_driver(obj) container_of(obj, struct driver_private, kobj)
 
+
+/**
+ * struct class_private - structure to hold the private to the driver core portions of the class structure.
+ *
+ * @class_subsys - the struct kset that defines this class.  This is the main kobject
+ * @class_devices - list of devices associated with this class
+ * @class_interfaces - list of class_interfaces associated with this class
+ * @class_dirs - "glue" directory for virtual devices associated with this class
+ * @class_mutex - mutex to protect the children, devices, and interfaces lists.
+ * @class - pointer back to the struct class that this structure is associated
+ * with.
+ *
+ * This structure is the one that is the actual kobject allowing struct
+ * class to be statically allocated safely.  Nothing outside of the driver
+ * core should ever touch these fields.
+ */
+struct class_private {
+       struct kset class_subsys;
+       struct list_head class_devices;
+       struct list_head class_interfaces;
+       struct kset class_dirs;
+       struct mutex class_mutex;
+       struct class *class;
+};
+#define to_class(obj)  \
+       container_of(obj, struct class_private, class_subsys.kobj)
+
 /* initialisation functions */
 extern int devices_init(void);
 extern int buses_init(void);
index e085af0..839d27c 100644 (file)
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/genhd.h>
+#include <linux/mutex.h>
 #include "base.h"
 
 #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
-#define to_class(obj) container_of(obj, struct class, subsys.kobj)
 
 static ssize_t class_attr_show(struct kobject *kobj, struct attribute *attr,
                               char *buf)
 {
        struct class_attribute *class_attr = to_class_attr(attr);
-       struct class *dc = to_class(kobj);
+       struct class_private *cp = to_class(kobj);
        ssize_t ret = -EIO;
 
        if (class_attr->show)
-               ret = class_attr->show(dc, buf);
+               ret = class_attr->show(cp->class, buf);
        return ret;
 }
 
@@ -39,17 +39,18 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
                                const char *buf, size_t count)
 {
        struct class_attribute *class_attr = to_class_attr(attr);
-       struct class *dc = to_class(kobj);
+       struct class_private *cp = to_class(kobj);
        ssize_t ret = -EIO;
 
        if (class_attr->store)
-               ret = class_attr->store(dc, buf, count);
+               ret = class_attr->store(cp->class, buf, count);
        return ret;
 }
 
 static void class_release(struct kobject *kobj)
 {
-       struct class *class = to_class(kobj);
+       struct class_private *cp = to_class(kobj);
+       struct class *class = cp->class;
 
        pr_debug("class '%s': release.\n", class->name);
 
@@ -70,7 +71,7 @@ static struct kobj_type class_ktype = {
        .release        = class_release,
 };
 
-/* Hotplug events for classes go to the class_obj subsys */
+/* Hotplug events for classes go to the class class_subsys */
 static struct kset *class_kset;
 
 
@@ -78,7 +79,8 @@ int class_create_file(struct class *cls, const struct class_attribute *attr)
 {
        int error;
        if (cls)
-               error = sysfs_create_file(&cls->subsys.kobj, &attr->attr);
+               error = sysfs_create_file(&cls->p->class_subsys.kobj,
+                                         &attr->attr);
        else
                error = -EINVAL;
        return error;
@@ -87,21 +89,20 @@ int class_create_file(struct class *cls, const struct class_attribute *attr)
 void class_remove_file(struct class *cls, const struct class_attribute *attr)
 {
        if (cls)
-               sysfs_remove_file(&cls->subsys.kobj, &attr->attr);
+               sysfs_remove_file(&cls->p->class_subsys.kobj, &attr->attr);
 }
 
 static struct class *class_get(struct class *cls)
 {
        if (cls)
-               return container_of(kset_get(&cls->subsys),
-                                   struct class, subsys);
-       return NULL;
+               kset_get(&cls->p->class_subsys);
+       return cls;
 }
 
 static void class_put(struct class *cls)
 {
        if (cls)
-               kset_put(&cls->subsys);
+               kset_put(&cls->p->class_subsys);
 }
 
 static int add_class_attrs(struct class *cls)
@@ -134,42 +135,57 @@ static void remove_class_attrs(struct class *cls)
        }
 }
 
-int class_register(struct class *cls)
+int __class_register(struct class *cls, struct lock_class_key *key)
 {
+       struct class_private *cp;
        int error;
 
        pr_debug("device class '%s': registering\n", cls->name);
 
-       INIT_LIST_HEAD(&cls->devices);
-       INIT_LIST_HEAD(&cls->interfaces);
-       kset_init(&cls->class_dirs);
-       init_MUTEX(&cls->sem);
-       error = kobject_set_name(&cls->subsys.kobj, "%s", cls->name);
-       if (error)
+       cp = kzalloc(sizeof(*cp), GFP_KERNEL);
+       if (!cp)
+               return -ENOMEM;
+       INIT_LIST_HEAD(&cp->class_devices);
+       INIT_LIST_HEAD(&cp->class_interfaces);
+       kset_init(&cp->class_dirs);
+       __mutex_init(&cp->class_mutex, "struct class mutex", key);
+       error = kobject_set_name(&cp->class_subsys.kobj, "%s", cls->name);
+       if (error) {
+               kfree(cp);
                return error;
+       }
+
+       /* set the default /sys/dev directory for devices of this class */
+       if (!cls->dev_kobj)
+               cls->dev_kobj = sysfs_dev_char_kobj;
 
 #if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK)
        /* let the block class directory show up in the root of sysfs */
        if (cls != &block_class)
-               cls->subsys.kobj.kset = class_kset;
+               cp->class_subsys.kobj.kset = class_kset;
 #else
-       cls->subsys.kobj.kset = class_kset;
+       cp->class_subsys.kobj.kset = class_kset;
 #endif
-       cls->subsys.kobj.ktype = &class_ktype;
+       cp->class_subsys.kobj.ktype = &class_ktype;
+       cp->class = cls;
+       cls->p = cp;
 
-       error = kset_register(&cls->subsys);
-       if (!error) {
-               error = add_class_attrs(class_get(cls));
-               class_put(cls);
+       error = kset_register(&cp->class_subsys);
+       if (error) {
+               kfree(cp);
+               return error;
        }
+       error = add_class_attrs(class_get(cls));
+       class_put(cls);
        return error;
 }
+EXPORT_SYMBOL_GPL(__class_register);
 
 void class_unregister(struct class *cls)
 {
        pr_debug("device class '%s': unregistering\n", cls->name);
        remove_class_attrs(cls);
-       kset_unregister(&cls->subsys);
+       kset_unregister(&cls->p->class_subsys);
 }
 
 static void class_create_release(struct class *cls)
@@ -189,7 +205,8 @@ static void class_create_release(struct class *cls)
  * Note, the pointer created here is to be destroyed when finished by
  * making a call to class_destroy().
  */
-struct class *class_create(struct module *owner, const char *name)
+struct class *__class_create(struct module *owner, const char *name,
+                            struct lock_class_key *key)
 {
        struct class *cls;
        int retval;
@@ -204,7 +221,7 @@ struct class *class_create(struct module *owner, const char *name)
        cls->owner = owner;
        cls->class_release = class_create_release;
 
-       retval = class_register(cls);
+       retval = __class_register(cls, key);
        if (retval)
                goto error;
 
@@ -214,6 +231,7 @@ error:
        kfree(cls);
        return ERR_PTR(retval);
 }
+EXPORT_SYMBOL_GPL(__class_create);
 
 /**
  * class_destroy - destroys a struct class structure
@@ -252,39 +270,44 @@ char *make_class_name(const char *name, struct kobject *kobj)
 /**
  * class_for_each_device - device iterator
  * @class: the class we're iterating
+ * @start: the device to start with in the list, if any.
  * @data: data for the callback
  * @fn: function to be called for each device
  *
  * Iterate over @class's list of devices, and call @fn for each,
- * passing it @data.
+ * passing it @data.  If @start is set, the list iteration will start
+ * there, otherwise if it is NULL, the iteration starts at the
+ * beginning of the list.
  *
  * We check the return of @fn each time. If it returns anything
  * other than 0, we break out and return that value.
  *
- * Note, we hold class->sem in this function, so it can not be
+ * Note, we hold class->class_mutex in this function, so it can not be
  * re-acquired in @fn, otherwise it will self-deadlocking. For
  * example, calls to add or remove class members would be verboten.
  */
-int class_for_each_device(struct class *class, void *data,
-                          int (*fn)(struct device *, void *))
+int class_for_each_device(struct class *class, struct device *start,
+                         void *data, int (*fn)(struct device *, void *))
 {
        struct device *dev;
        int error = 0;
 
        if (!class)
                return -EINVAL;
-       down(&class->sem);
-       list_for_each_entry(dev, &class->devices, node) {
+       mutex_lock(&class->p->class_mutex);
+       list_for_each_entry(dev, &class->p->class_devices, node) {
+               if (start) {
+                       if (start == dev)
+                               start = NULL;
+                       continue;
+               }
                dev = get_device(dev);
-               if (dev) {
-                       error = fn(dev, data);
-                       put_device(dev);
-               } else
-                       error = -ENODEV;
+               error = fn(dev, data);
+               put_device(dev);
                if (error)
                        break;
        }
-       up(&class->sem);
+       mutex_unlock(&class->p->class_mutex);
 
        return error;
 }
@@ -293,6 +316,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
 /**
  * class_find_device - device iterator for locating a particular device
  * @class: the class we're iterating
+ * @start: Device to begin with
  * @data: data for the match function
  * @match: function to check device
  *
@@ -306,12 +330,13 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
  *
  * Note, you will need to drop the reference with put_device() after use.
  *
- * We hold class->sem in this function, so it can not be
+ * We hold class->class_mutex in this function, so it can not be
  * re-acquired in @match, otherwise it will self-deadlocking. For
  * example, calls to add or remove class members would be verboten.
  */
-struct device *class_find_device(struct class *class, void *data,
-                                  int (*match)(struct device *, void *))
+struct device *class_find_device(struct class *class, struct device *start,
+                                void *data,
+                                int (*match)(struct device *, void *))
 {
        struct device *dev;
        int found = 0;
@@ -319,19 +344,21 @@ struct device *class_find_device(struct class *class, void *data,
        if (!class)
                return NULL;
 
-       down(&class->sem);
-       list_for_each_entry(dev, &class->devices, node) {
+       mutex_lock(&class->p->class_mutex);
+       list_for_each_entry(dev, &class->p->class_devices, node) {
+               if (start) {
+                       if (start == dev)
+                               start = NULL;
+                       continue;
+               }
                dev = get_device(dev);
-               if (dev) {
-                       if (match(dev, data)) {
-                               found = 1;
-                               break;
-                       } else
-                               put_device(dev);
-               } else
+               if (match(dev, data)) {
+                       found = 1;
                        break;
+               } else
+                       put_device(dev);
        }
-       up(&class->sem);
+       mutex_unlock(&class->p->class_mutex);
 
        return found ? dev : NULL;
 }
@@ -349,13 +376,13 @@ int class_interface_register(struct class_interface *class_intf)
        if (!parent)
                return -EINVAL;
 
-       down(&parent->sem);
-       list_add_tail(&class_intf->node, &parent->interfaces);
+       mutex_lock(&parent->p->class_mutex);
+       list_add_tail(&class_intf->node, &parent->p->class_interfaces);
        if (class_intf->add_dev) {
-               list_for_each_entry(dev, &parent->devices, node)
+               list_for_each_entry(dev, &parent->p->class_devices, node)
                        class_intf->add_dev(dev, class_intf);
        }
-       up(&parent->sem);
+       mutex_unlock(&parent->p->class_mutex);
 
        return 0;
 }
@@ -368,13 +395,13 @@ void class_interface_unregister(struct class_interface *class_intf)
        if (!parent)
                return;
 
-       down(&parent->sem);
+       mutex_lock(&parent->p->class_mutex);
        list_del_init(&class_intf->node);
        if (class_intf->remove_dev) {
-               list_for_each_entry(dev, &parent->devices, node)
+               list_for_each_entry(dev, &parent->p->class_devices, node)
                        class_intf->remove_dev(dev, class_intf);
        }
-       up(&parent->sem);
+       mutex_unlock(&parent->p->class_mutex);
 
        class_put(parent);
 }
@@ -389,9 +416,7 @@ int __init classes_init(void)
 
 EXPORT_SYMBOL_GPL(class_create_file);
 EXPORT_SYMBOL_GPL(class_remove_file);
-EXPORT_SYMBOL_GPL(class_register);
 EXPORT_SYMBOL_GPL(class_unregister);
-EXPORT_SYMBOL_GPL(class_create);
 EXPORT_SYMBOL_GPL(class_destroy);
 
 EXPORT_SYMBOL_GPL(class_interface_register);
index ee0a51a..7d5c63c 100644 (file)
 #include <linux/genhd.h>
 #include <linux/kallsyms.h>
 #include <linux/semaphore.h>
+#include <linux/mutex.h>
 
 #include "base.h"
 #include "power/power.h"
 
 int (*platform_notify)(struct device *dev) = NULL;
 int (*platform_notify_remove)(struct device *dev) = NULL;
+static struct kobject *dev_kobj;
+struct kobject *sysfs_dev_char_kobj;
+struct kobject *sysfs_dev_block_kobj;
 
 #ifdef CONFIG_BLOCK
 static inline int device_is_not_partition(struct device *dev)
@@ -548,7 +552,7 @@ static struct kobject *get_device_parent(struct device *dev,
 {
        /* class devices without a parent live in /sys/class/<classname>/ */
        if (dev->class && (!parent || parent->class != dev->class))
-               return &dev->class->subsys.kobj;
+               return &dev->class->p->class_subsys.kobj;
        /* all other devices keep their parent */
        else if (parent)
                return &parent->kobj;
@@ -594,13 +598,13 @@ static struct kobject *get_device_parent(struct device *dev,
                        parent_kobj = &parent->kobj;
 
                /* find our class-directory at the parent and reference it */
-               spin_lock(&dev->class->class_dirs.list_lock);
-               list_for_each_entry(k, &dev->class->class_dirs.list, entry)
+               spin_lock(&dev->class->p->class_dirs.list_lock);
+               list_for_each_entry(k, &dev->class->p->class_dirs.list, entry)
                        if (k->parent == parent_kobj) {
                                kobj = kobject_get(k);
                                break;
                        }
-               spin_unlock(&dev->class->class_dirs.list_lock);
+               spin_unlock(&dev->class->p->class_dirs.list_lock);
                if (kobj)
                        return kobj;
 
@@ -608,7 +612,7 @@ static struct kobject *get_device_parent(struct device *dev,
                k = kobject_create();
                if (!k)
                        return NULL;
-               k->kset = &dev->class->class_dirs;
+               k->kset = &dev->class->p->class_dirs;
                retval = kobject_add(k, parent_kobj, "%s", dev->class->name);
                if (retval < 0) {
                        kobject_put(k);
@@ -627,7 +631,7 @@ static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
 {
        /* see if we live in a "glue" directory */
        if (!glue_dir || !dev->class ||
-           glue_dir->kset != &dev->class->class_dirs)
+           glue_dir->kset != &dev->class->p->class_dirs)
                return;
 
        kobject_put(glue_dir);
@@ -654,17 +658,18 @@ static int device_add_class_symlinks(struct device *dev)
        if (!dev->class)
                return 0;
 
-       error = sysfs_create_link(&dev->kobj, &dev->class->subsys.kobj,
+       error = sysfs_create_link(&dev->kobj,
+                                 &dev->class->p->class_subsys.kobj,
                                  "subsystem");
        if (error)
                goto out;
 
 #ifdef CONFIG_SYSFS_DEPRECATED
        /* stacked class devices need a symlink in the class directory */
-       if (dev->kobj.parent != &dev->class->subsys.kobj &&
+       if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
            device_is_not_partition(dev)) {
-               error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
-                                         dev->bus_id);
+               error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
+                                         &dev->kobj, dev->bus_id);
                if (error)
                        goto out_subsys;
        }
@@ -701,13 +706,14 @@ out_device:
        if (dev->parent && device_is_not_partition(dev))
                sysfs_remove_link(&dev->kobj, "device");
 out_busid:
-       if (dev->kobj.parent != &dev->class->subsys.kobj &&
+       if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
            device_is_not_partition(dev))
-               sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
+               sysfs_remove_link(&dev->class->p->class_subsys.kobj,
+                                 dev->bus_id);
 #else
        /* link in the class directory pointing to the device */
-       error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
-                                 dev->bus_id);
+       error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
+                                 &dev->kobj, dev->bus_id);
        if (error)
                goto out_subsys;
 
@@ -720,7 +726,7 @@ out_busid:
        return 0;
 
 out_busid:
-       sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
+       sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id);
 #endif
 
 out_subsys:
@@ -746,14 +752,15 @@ static void device_remove_class_symlinks(struct device *dev)
                sysfs_remove_link(&dev->kobj, "device");
        }
 
-       if (dev->kobj.parent != &dev->class->subsys.kobj &&
+       if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
            device_is_not_partition(dev))
-               sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
+               sysfs_remove_link(&dev->class->p->class_subsys.kobj,
+                                 dev->bus_id);
 #else
        if (dev->parent && device_is_not_partition(dev))
                sysfs_remove_link(&dev->kobj, "device");
 
-       sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
+       sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id);
 #endif
 
        sysfs_remove_link(&dev->kobj, "subsystem");
@@ -775,6 +782,54 @@ int dev_set_name(struct device *dev, const char *fmt, ...)
 }
 EXPORT_SYMBOL_GPL(dev_set_name);
 
+/**
+ * device_to_dev_kobj - select a /sys/dev/ directory for the device
+ * @dev: device
+ *
+ * By default we select char/ for new entries.  Setting class->dev_obj
+ * to NULL prevents an entry from being created.  class->dev_kobj must
+ * be set (or cleared) before any devices are registered to the class
+ * otherwise device_create_sys_dev_entry() and
+ * device_remove_sys_dev_entry() will disagree about the the presence
+ * of the link.
+ */
+static struct kobject *device_to_dev_kobj(struct device *dev)
+{
+       struct kobject *kobj;
+
+       if (dev->class)
+               kobj = dev->class->dev_kobj;
+       else
+               kobj = sysfs_dev_char_kobj;
+
+       return kobj;
+}
+
+static int device_create_sys_dev_entry(struct device *dev)
+{
+       struct kobject *kobj = device_to_dev_kobj(dev);
+       int error = 0;
+       char devt_str[15];
+
+       if (kobj) {
+               format_dev_t(devt_str, dev->devt);
+               error = sysfs_create_link(kobj, &dev->kobj, devt_str);
+       }
+
+       return error;
+}
+
+static void device_remove_sys_dev_entry(struct device *dev)
+{
+       struct kobject *kobj = device_to_dev_kobj(dev);
+       char devt_str[15];
+
+       if (kobj) {
+               format_dev_t(devt_str, dev->devt);
+               sysfs_remove_link(kobj, devt_str);
+       }
+}
+
 /**
  * device_add - add device to device hierarchy.
  * @dev: device.
@@ -829,6 +884,10 @@ int device_add(struct device *dev)
                error = device_create_file(dev, &devt_attr);
                if (error)
                        goto ueventattrError;
+
+               error = device_create_sys_dev_entry(dev);
+               if (error)
+                       goto devtattrError;
        }
 
        error = device_add_class_symlinks(dev);
@@ -849,15 +908,16 @@ int device_add(struct device *dev)
                klist_add_tail(&dev->knode_parent, &parent->klist_children);
 
        if (dev->class) {
-               down(&dev->class->sem);
+               mutex_lock(&dev->class->p->class_mutex);
                /* tie the class to the device */
-               list_add_tail(&dev->node, &dev->class->devices);
+               list_add_tail(&dev->node, &dev->class->p->class_devices);
 
                /* notify any interfaces that the device is here */
-               list_for_each_entry(class_intf, &dev->class->interfaces, node)
+               list_for_each_entry(class_intf,
+                                   &dev->class->p->class_interfaces, node)
                        if (class_intf->add_dev)
                                class_intf->add_dev(dev, class_intf);
-               up(&dev->class->sem);
+               mutex_unlock(&dev->class->p->class_mutex);
        }
  Done:
        put_device(dev);
@@ -872,6 +932,9 @@ int device_add(struct device *dev)
  AttrsError:
        device_remove_class_symlinks(dev);
  SymlinkError:
+       if (MAJOR(dev->devt))
+               device_remove_sys_dev_entry(dev);
+ devtattrError:
        if (MAJOR(dev->devt))
                device_remove_file(dev, &devt_attr);
  ueventattrError:
@@ -948,19 +1011,22 @@ void device_del(struct device *dev)
        device_pm_remove(dev);
        if (parent)
                klist_del(&dev->knode_parent);
-       if (MAJOR(dev->devt))
+       if (MAJOR(dev->devt)) {
+               device_remove_sys_dev_entry(dev);
                device_remove_file(dev, &devt_attr);
+       }
        if (dev->class) {
                device_remove_class_symlinks(dev);
 
-               down(&dev->class->sem);
+               mutex_lock(&dev->class->p->class_mutex);
                /* notify any interfaces that the device is now gone */
-               list_for_each_entry(class_intf, &dev->class->interfaces, node)
+               list_for_each_entry(class_intf,
+                                   &dev->class->p->class_interfaces, node)
                        if (class_intf->remove_dev)
                                class_intf->remove_dev(dev, class_intf);
                /* remove the device from the class list */
                list_del_init(&dev->node);
-               up(&dev->class->sem);
+               mutex_unlock(&dev->class->p->class_mutex);
        }
        device_remove_file(dev, &uevent_attr);
        device_remove_attrs(dev);
@@ -1074,7 +1140,25 @@ int __init devices_init(void)
        devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL);
        if (!devices_kset)
                return -ENOMEM;
+       dev_kobj = kobject_create_and_add("dev", NULL);
+       if (!dev_kobj)
+               goto dev_kobj_err;
+       sysfs_dev_block_kobj = kobject_create_and_add("block", dev_kobj);
+       if (!sysfs_dev_block_kobj)
+               goto block_kobj_err;
+       sysfs_dev_char_kobj = kobject_create_and_add("char", dev_kobj);
+       if (!sysfs_dev_char_kobj)
+               goto char_kobj_err;
+
        return 0;
+
+ char_kobj_err:
+       kobject_put(sysfs_dev_block_kobj);
+ block_kobj_err:
+       kobject_put(dev_kobj);
+ dev_kobj_err:
+       kset_unregister(devices_kset);
+       return -ENOMEM;
 }
 
 EXPORT_SYMBOL_GPL(device_for_each_child);
@@ -1157,49 +1241,12 @@ error:
 }
 EXPORT_SYMBOL_GPL(device_create_vargs);
 
-/**
- * device_create_drvdata - creates a device and registers it with sysfs
- * @class: pointer to the struct class that this device should be registered to
- * @parent: pointer to the parent struct device of this new device, if any
- * @devt: the dev_t for the char device to be added
- * @drvdata: the data to be added to the device for callbacks
- * @fmt: string for the device's name
- *
- * This function can be used by char device classes.  A struct device
- * will be created in sysfs, registered to the specified class.
- *
- * A "dev" file will be created, showing the dev_t for the device, if
- * the dev_t is not 0,0.
- * If a pointer to a parent struct device is passed in, the newly created
- * struct device will be a child of that device in sysfs.
- * The pointer to the struct device will be returned from the call.
- * Any further sysfs files that might be required can be created using this
- * pointer.
- *
- * Note: the struct class passed to this function must have previously
- * been created with a call to class_create().
- */
-struct device *device_create_drvdata(struct class *class,
-                                    struct device *parent,
-                                    dev_t devt,
-                                    void *drvdata,
-                                    const char *fmt, ...)
-{
-       va_list vargs;
-       struct device *dev;
-
-       va_start(vargs, fmt);
-       dev = device_create_vargs(class, parent, devt, drvdata, fmt, vargs);
-       va_end(vargs);
-       return dev;
-}
-EXPORT_SYMBOL_GPL(device_create_drvdata);
-
 /**
  * device_create - creates a device and registers it with sysfs
  * @class: pointer to the struct class that this device should be registered to
  * @parent: pointer to the parent struct device of this new device, if any
  * @devt: the dev_t for the char device to be added
+ * @drvdata: the data to be added to the device for callbacks
  * @fmt: string for the device's name
  *
  * This function can be used by char device classes.  A struct device
@@ -1217,13 +1264,13 @@ EXPORT_SYMBOL_GPL(device_create_drvdata);
  * been created with a call to class_create().
  */
 struct device *device_create(struct class *class, struct device *parent,
-                            dev_t devt, const char *fmt, ...)
+                            dev_t devt, void *drvdata, const char *fmt, ...)
 {
        va_list vargs;
        struct device *dev;
 
        va_start(vargs, fmt);
-       dev = device_create_vargs(class, parent, devt, NULL, fmt, vargs);
+       dev = device_create_vargs(class, parent, devt, drvdata, fmt, vargs);
        va_end(vargs);
        return dev;
 }
@@ -1248,7 +1295,7 @@ void device_destroy(struct class *class, dev_t devt)
 {
        struct device *dev;
 
-       dev = class_find_device(class, &devt, __match_devt);
+       dev = class_find_device(class, NULL, &devt, __match_devt);
        if (dev) {
                put_device(dev);
                device_unregister(dev);
@@ -1298,8 +1345,9 @@ int device_rename(struct device *dev, char *new_name)
        if (old_class_name) {
                new_class_name = make_class_name(dev->class->name, &dev->kobj);
                if (new_class_name) {
-                       error = sysfs_create_link(&dev->parent->kobj,
-                                                 &dev->kobj, new_class_name);
+                       error = sysfs_create_link_nowarn(&dev->parent->kobj,
+                                                        &dev->kobj,
+                                                        new_class_name);
                        if (error)
                                goto out;
                        sysfs_remove_link(&dev->parent->kobj, old_class_name);
@@ -1307,11 +1355,12 @@ int device_rename(struct device *dev, char *new_name)
        }
 #else
        if (dev->class) {
-               error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
-                                         dev->bus_id);
+               error = sysfs_create_link_nowarn(&dev->class->p->class_subsys.kobj,
+                                                &dev->kobj, dev->bus_id);
                if (error)
                        goto out;
-               sysfs_remove_link(&dev->class->subsys.kobj, old_device_name);
+               sysfs_remove_link(&dev->class->p->class_subsys.kobj,
+                                 old_device_name);
        }
 #endif
 
@@ -1447,4 +1496,7 @@ void device_shutdown(void)
                        dev->driver->shutdown(dev);
                }
        }
+       kobject_put(sysfs_dev_char_kobj);
+       kobject_put(sysfs_dev_block_kobj);
+       kobject_put(dev_kobj);
 }
index e38dfed..20537d5 100644 (file)
@@ -21,15 +21,16 @@ EXPORT_SYMBOL(cpu_sysdev_class);
 static DEFINE_PER_CPU(struct sys_device *, cpu_sys_devices);
 
 #ifdef CONFIG_HOTPLUG_CPU
-static ssize_t show_online(struct sys_device *dev, char *buf)
+static ssize_t show_online(struct sys_device *dev, struct sysdev_attribute *attr,
+                          char *buf)
 {
        struct cpu *cpu = container_of(dev, struct cpu, sysdev);
 
        return sprintf(buf, "%u\n", !!cpu_online(cpu->sysdev.id));
 }
 
-static ssize_t __ref store_online(struct sys_device *dev, const char *buf,
-                           size_t count)
+static ssize_t __ref store_online(struct sys_device *dev, struct sysdev_attribute *attr,
+                                const char *buf, size_t count)
 {
        struct cpu *cpu = container_of(dev, struct cpu, sysdev);
        ssize_t ret;
@@ -80,7 +81,8 @@ static inline void register_cpu_control(struct cpu *cpu)
 #ifdef CONFIG_KEXEC
 #include <linux/kexec.h>
 
-static ssize_t show_crash_notes(struct sys_device *dev, char *buf)
+static ssize_t show_crash_notes(struct sys_device *dev, struct sysdev_attribute *attr,
+                               char *buf)
 {
        struct cpu *cpu = container_of(dev, struct cpu, sysdev);
        ssize_t rc;
index 937e825..4d4e0e7 100644 (file)
@@ -92,7 +92,8 @@ unregister_memory(struct memory_block *memory, struct mem_section *section)
  * uses.
  */
 
-static ssize_t show_mem_phys_index(struct sys_device *dev, char *buf)
+static ssize_t show_mem_phys_index(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        struct memory_block *mem =
                container_of(dev, struct memory_block, sysdev);
@@ -102,7 +103,8 @@ static ssize_t show_mem_phys_index(struct sys_device *dev, char *buf)
 /*
  * online, offline, going offline, etc.
  */
-static ssize_t show_mem_state(struct sys_device *dev, char *buf)
+static ssize_t show_mem_state(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        struct memory_block *mem =
                container_of(dev, struct memory_block, sysdev);
@@ -217,7 +219,8 @@ out:
 }
 
 static ssize_t
-store_mem_state(struct sys_device *dev, const char *buf, size_t count)
+store_mem_state(struct sys_device *dev,
+               struct sysdev_attribute *attr, const char *buf, size_t count)
 {
        struct memory_block *mem;
        unsigned int phys_section_nr;
@@ -248,7 +251,8 @@ out:
  * s.t. if I offline all of these sections I can then
  * remove the physical device?
  */
-static ssize_t show_phys_device(struct sys_device *dev, char *buf)
+static ssize_t show_phys_device(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        struct memory_block *mem =
                container_of(dev, struct memory_block, sysdev);
index 0f867a0..5116b78 100644 (file)
@@ -36,11 +36,13 @@ static ssize_t node_read_cpumap(struct sys_device *dev, int type, char *buf)
        return len;
 }
 
-static inline ssize_t node_read_cpumask(struct sys_device *dev, char *buf)
+static inline ssize_t node_read_cpumask(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        return node_read_cpumap(dev, 0, buf);
 }
-static inline ssize_t node_read_cpulist(struct sys_device *dev, char *buf)
+static inline ssize_t node_read_cpulist(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        return node_read_cpumap(dev, 1, buf);
 }
@@ -49,7 +51,8 @@ static SYSDEV_ATTR(cpumap,  S_IRUGO, node_read_cpumask, NULL);
 static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL);
 
 #define K(x) ((x) << (PAGE_SHIFT - 10))
-static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
+static ssize_t node_read_meminfo(struct sys_device * dev,
+                       struct sysdev_attribute *attr, char * buf)
 {
        int n;
        int nid = dev->id;
@@ -112,7 +115,8 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
 #undef K
 static SYSDEV_ATTR(meminfo, S_IRUGO, node_read_meminfo, NULL);
 
-static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
+static ssize_t node_read_numastat(struct sys_device * dev,
+                               struct sysdev_attribute *attr, char * buf)
 {
        return sprintf(buf,
                       "numa_hit %lu\n"
@@ -130,7 +134,8 @@ static ssize_t node_read_numastat(struct sys_device * dev, char * buf)
 }
 static SYSDEV_ATTR(numastat, S_IRUGO, node_read_numastat, NULL);
 
-static ssize_t node_read_distance(struct sys_device * dev, char * buf)
+static ssize_t node_read_distance(struct sys_device * dev,
+                       struct sysdev_attribute *attr, char * buf)
 {
        int nid = dev->id;
        int len = 0;
index 9b1b20b..2aa6e8f 100644 (file)
@@ -194,7 +194,7 @@ static int show_dev_hash(unsigned int value)
                struct device * dev = to_device(entry);
                unsigned int hash = hash_string(DEVSEED, dev->bus_id, DEVHASH);
                if (hash == value) {
-                       printk("  hash matches device %s\n", dev->bus_id);
+                       dev_info(dev, "hash matches\n");
                        match++;
                }
                entry = entry->prev;
index 358bb0b..40fc14f 100644 (file)
@@ -36,7 +36,7 @@ sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer)
        struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr);
 
        if (sysdev_attr->show)
-               return sysdev_attr->show(sysdev, buffer);
+               return sysdev_attr->show(sysdev, sysdev_attr, buffer);
        return -EIO;
 }
 
@@ -49,7 +49,7 @@ sysdev_store(struct kobject * kobj, struct attribute * attr,
        struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr);
 
        if (sysdev_attr->store)
-               return sysdev_attr->store(sysdev, buffer, count);
+               return sysdev_attr->store(sysdev, sysdev_attr, buffer, count);
        return -EIO;
 }
 
@@ -130,8 +130,8 @@ static struct kset *system_kset;
 
 int sysdev_class_register(struct sysdev_class * cls)
 {
-       pr_debug("Registering sysdev class '%s'\n",
-                kobject_name(&cls->kset.kobj));
+       pr_debug("Registering sysdev class '%s'\n", cls->name);
+
        INIT_LIST_HEAD(&cls->drivers);
        memset(&cls->kset.kobj, 0x00, sizeof(struct kobject));
        cls->kset.kobj.parent = &system_kset->kobj;
@@ -241,7 +241,8 @@ int sysdev_register(struct sys_device * sysdev)
        if (!cls)
                return -EINVAL;
 
-       pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj));
+       pr_debug("Registering sys device of class '%s'\n",
+                kobject_name(&cls->kset.kobj));
 
        /* initialize the kobject to 0, in case it had previously been used */
        memset(&sysdev->kobj, 0x00, sizeof(struct kobject));
@@ -257,6 +258,9 @@ int sysdev_register(struct sys_device * sysdev)
        if (!error) {
                struct sysdev_driver * drv;
 
+               pr_debug("Registering sys device '%s'\n",
+                        kobject_name(&sysdev->kobj));
+
                mutex_lock(&sysdev_drivers_lock);
                /* Generic notification is implicit, because it's that
                 * code that should have called us.
@@ -269,6 +273,7 @@ int sysdev_register(struct sys_device * sysdev)
                }
                mutex_unlock(&sysdev_drivers_lock);
        }
+
        kobject_uevent(&sysdev->kobj, KOBJ_ADD);
        return error;
 }
@@ -474,3 +479,52 @@ int __init system_bus_init(void)
 
 EXPORT_SYMBOL_GPL(sysdev_register);
 EXPORT_SYMBOL_GPL(sysdev_unregister);
+
+#define to_ext_attr(x) container_of(x, struct sysdev_ext_attribute, attr)
+
+ssize_t sysdev_store_ulong(struct sys_device *sysdev,
+                          struct sysdev_attribute *attr,
+                          const char *buf, size_t size)
+{
+       struct sysdev_ext_attribute *ea = to_ext_attr(attr);
+       char *end;
+       unsigned long new = simple_strtoul(buf, &end, 0);
+       if (end == buf)
+               return -EINVAL;
+       *(unsigned long *)(ea->var) = new;
+       return end - buf;
+}
+EXPORT_SYMBOL_GPL(sysdev_store_ulong);
+
+ssize_t sysdev_show_ulong(struct sys_device *sysdev,
+                         struct sysdev_attribute *attr,
+                         char *buf)
+{
+       struct sysdev_ext_attribute *ea = to_ext_attr(attr);
+       return snprintf(buf, PAGE_SIZE, "%lx\n", *(unsigned long *)(ea->var));
+}
+EXPORT_SYMBOL_GPL(sysdev_show_ulong);
+
+ssize_t sysdev_store_int(struct sys_device *sysdev,
+                          struct sysdev_attribute *attr,
+                          const char *buf, size_t size)
+{
+       struct sysdev_ext_attribute *ea = to_ext_attr(attr);
+       char *end;
+       long new = simple_strtol(buf, &end, 0);
+       if (end == buf || new > INT_MAX || new < INT_MIN)
+               return -EINVAL;
+       *(int *)(ea->var) = new;
+       return end - buf;
+}
+EXPORT_SYMBOL_GPL(sysdev_store_int);
+
+ssize_t sysdev_show_int(struct sys_device *sysdev,
+                         struct sysdev_attribute *attr,
+                         char *buf)
+{
+       struct sysdev_ext_attribute *ea = to_ext_attr(attr);
+       return snprintf(buf, PAGE_SIZE, "%d\n", *(int *)(ea->var));
+}
+EXPORT_SYMBOL_GPL(sysdev_show_int);
+
index 3f6d9b0..199cd97 100644 (file)
@@ -34,7 +34,8 @@
 static SYSDEV_ATTR(_name, 0444, show_##_name, NULL)
 
 #define define_id_show_func(name)                              \
-static ssize_t show_##name(struct sys_device *dev, char *buf)  \
+static ssize_t show_##name(struct sys_device *dev,             \
+               struct sysdev_attribute *attr, char *buf)       \
 {                                                              \
        unsigned int cpu = dev->id;                             \
        return sprintf(buf, "%d\n", topology_##name(cpu));      \
@@ -59,14 +60,17 @@ static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf)
 
 #ifdef arch_provides_topology_pointers
 #define define_siblings_show_map(name)                                 \
-static ssize_t show_##name(struct sys_device *dev, char *buf)  \
+static ssize_t show_##name(struct sys_device *dev,                     \
+                          struct sysdev_attribute *attr, char *buf)    \
 {                                                                      \
        unsigned int cpu = dev->id;                                     \
        return show_cpumap(0, &(topology_##name(cpu)), buf);            \
 }
 
 #define define_siblings_show_list(name)                                        \
-static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
+static ssize_t show_##name##_list(struct sys_device *dev,              \
+                                 struct sysdev_attribute *attr,        \
+                                 char *buf)                            \
 {                                                                      \
        unsigned int cpu = dev->id;                                     \
        return show_cpumap(1, &(topology_##name(cpu)), buf);            \
@@ -74,7 +78,8 @@ static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
 
 #else
 #define define_siblings_show_map(name)                                 \
-static ssize_t show_##name(struct sys_device *dev, char *buf)  \
+static ssize_t show_##name(struct sys_device *dev,                     \
+                          struct sysdev_attribute *attr, char *buf)    \
 {                                                                      \
        unsigned int cpu = dev->id;                                     \
        cpumask_t mask = topology_##name(cpu);                          \
@@ -82,7 +87,9 @@ static ssize_t show_##name(struct sys_device *dev, char *buf) \
 }
 
 #define define_siblings_show_list(name)                                        \
-static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
+static ssize_t show_##name##_list(struct sys_device *dev,              \
+                                 struct sysdev_attribute *attr,        \
+                                 char *buf)                            \
 {                                                                      \
        unsigned int cpu = dev->id;                                     \
        cpumask_t mask = topology_##name(cpu);                          \
index d1de68a..c04440c 100644 (file)
@@ -277,8 +277,9 @@ aoechr_init(void)
                return PTR_ERR(aoe_class);
        }
        for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
-               device_create(aoe_class, NULL,
-                             MKDEV(AOE_MAJOR, chardevs[i].minor), chardevs[i].name);
+               device_create_drvdata(aoe_class, NULL,
+                                     MKDEV(AOE_MAJOR, chardevs[i].minor),
+                                     NULL, chardevs[i].name);
 
        return 0;
 }
index 9d92636..d731ca4 100644 (file)
@@ -686,8 +686,9 @@ static int __init pg_init(void)
        for (unit = 0; unit < PG_UNITS; unit++) {
                struct pg *dev = &devices[unit];
                if (dev->present)
-                       device_create(pg_class, NULL, MKDEV(major, unit),
-                                     "pg%u", unit);
+                       device_create_drvdata(pg_class, NULL,
+                                             MKDEV(major, unit), NULL,
+                                             "pg%u", unit);
        }
        err = 0;
        goto out;
index 5c74c35..673b8b2 100644 (file)
@@ -979,10 +979,12 @@ static int __init pt_init(void)
 
        for (unit = 0; unit < PT_UNITS; unit++)
                if (pt[unit].present) {
-                       device_create(pt_class, NULL, MKDEV(major, unit),
-                                     "pt%d", unit);
-                       device_create(pt_class, NULL, MKDEV(major, unit + 128),
-                                     "pt%dn", unit);
+                       device_create_drvdata(pt_class, NULL,
+                                             MKDEV(major, unit), NULL,
+                                             "pt%d", unit);
+                       device_create_drvdata(pt_class, NULL,
+                                             MKDEV(major, unit + 128), NULL,
+                                             "pt%dn", unit);
                }
        goto out;
 
index 45bee91..158eed4 100644 (file)
@@ -303,7 +303,9 @@ static struct kobj_type kobj_pkt_type_wqueue = {
 static void pkt_sysfs_dev_new(struct pktcdvd_device *pd)
 {
        if (class_pktcdvd) {
-               pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, "%s", pd->name);
+               pd->dev = device_create_drvdata(class_pktcdvd, NULL,
+                                               pd->pkt_dev, NULL,
+                                               "%s", pd->name);
                if (IS_ERR(pd->dev))
                        pd->dev = NULL;
        }
index 650e6b4..e0bbbfb 100644 (file)
@@ -300,16 +300,6 @@ config SPECIALIX
          and compile this driver as kernel loadable module which will be
          called specialix.
 
-config SPECIALIX_RTSCTS
-       bool "Specialix DTR/RTS pin is RTS"
-       depends on SPECIALIX
-       help
-         The Specialix IO8+ card can only support either RTS or DTR. If you
-         say N here, the driver will use the pin as "DTR" when the tty is in
-         software handshake mode.  If you say Y here or hardware handshake is
-         on, it will always be RTS.  Read the file
-         <file:Documentation/specialix.txt> for more information.
-
 config SX
        tristate "Specialix SX (and SI) card support"
        depends on SERIAL_NONSTANDARD && (PCI || EISA || ISA)
index 0e0d12a..dc5a327 100644 (file)
@@ -7,7 +7,7 @@
 #
 FONTMAPFILE = cp437.uni
 
-obj-y   += mem.o random.o tty_io.o n_tty.o tty_ioctl.o
+obj-y   += mem.o random.o tty_io.o n_tty.o tty_ioctl.o tty_ldisc.o 
 
 obj-$(CONFIG_LEGACY_PTYS)      += pty.o
 obj-$(CONFIG_UNIX98_PTYS)      += pty.o
index 37457e5..3530ff4 100644 (file)
@@ -1248,7 +1248,7 @@ static int rs_tiocmset(struct tty_struct *tty, struct file *file,
 /*
  * rs_break() --- routine which turns the break handling on or off
  */
-static void rs_break(struct tty_struct *tty, int break_state)
+static int rs_break(struct tty_struct *tty, int break_state)
 {
        struct async_struct * info = (struct async_struct *)tty->driver_data;
        unsigned long flags;
@@ -1263,6 +1263,7 @@ static void rs_break(struct tty_struct *tty, int break_state)
          custom.adkcon = AC_UARTBRK;
        mb();
        local_irq_restore(flags);
+       return 0;
 }
 
 
index e991dc8..fe6d774 100644 (file)
@@ -3700,14 +3700,15 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
 /*
  * cy_break() --- routine which turns the break handling on or off
  */
-static void cy_break(struct tty_struct *tty, int break_state)
+static int cy_break(struct tty_struct *tty, int break_state)
 {
        struct cyclades_port *info = tty->driver_data;
        struct cyclades_card *card;
        unsigned long flags;
+       int retval = 0;
 
        if (serial_paranoia_check(info, tty->name, "cy_break"))
-               return;
+               return -EINVAL;
 
        card = info->card;
 
@@ -3736,8 +3737,6 @@ static void cy_break(struct tty_struct *tty, int break_state)
                        }
                }
        } else {
-               int retval;
-
                if (break_state == -1) {
                        retval = cyz_issue_cmd(card,
                                info->line - card->first_line,
@@ -3758,6 +3757,7 @@ static void cy_break(struct tty_struct *tty, int break_state)
                }
        }
        spin_unlock_irqrestore(&card->card_lock, flags);
+       return retval;
 }                              /* cy_break */
 
 static int get_mon_info(struct cyclades_port *info,
index b9a30c3..33c466a 100644 (file)
@@ -500,7 +500,8 @@ static int __init dsp56k_init_driver(void)
                err = PTR_ERR(dsp56k_class);
                goto out_chrdev;
        }
-       device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), "dsp56k");
+       device_create_drvdata(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0),
+                             NULL, "dsp56k");
 
        printk(banner);
        goto out;
index ac9995f..456e4ed 100644 (file)
@@ -184,9 +184,8 @@ static void pc_stop(struct tty_struct *);
 static void pc_start(struct tty_struct *);
 static void pc_throttle(struct tty_struct *tty);
 static void pc_unthrottle(struct tty_struct *tty);
-static void digi_send_break(struct channel *ch, int msec);
+static int pc_send_break(struct tty_struct *tty, int msec);
 static void setup_empty_event(struct tty_struct *tty, struct channel *ch);
-static void epca_setup(char *, int *);
 
 static int pc_write(struct tty_struct *, const unsigned char *, int);
 static int pc_init(void);
@@ -1040,6 +1039,7 @@ static const struct tty_operations pc_ops = {
        .throttle = pc_throttle,
        .unthrottle = pc_unthrottle,
        .hangup = pc_hangup,
+       .break_ctl = pc_send_break
 };
 
 static int info_open(struct tty_struct *tty, struct file *filp)
@@ -1132,7 +1132,7 @@ static int __init pc_init(void)
        pc_driver->init_termios.c_lflag = 0;
        pc_driver->init_termios.c_ispeed = 9600;
        pc_driver->init_termios.c_ospeed = 9600;
-       pc_driver->flags = TTY_DRIVER_REAL_RAW;
+       pc_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_HARDWARE_BREAK;
        tty_set_operations(pc_driver, &pc_ops);
 
        pc_info->owner = THIS_MODULE;
@@ -2177,7 +2177,6 @@ static int pc_ioctl(struct tty_struct *tty, struct file *file,
                                        unsigned int cmd, unsigned long arg)
 {
        digiflow_t dflow;
-       int retval;
        unsigned long flags;
        unsigned int mflag, mstat;
        unsigned char startc, stopc;
@@ -2189,37 +2188,7 @@ static int pc_ioctl(struct tty_struct *tty, struct file *file,
                bc = ch->brdchan;
        else
                return -EINVAL;
-       /*
-        * For POSIX compliance we need to add more ioctls. See tty_ioctl.c in
-        * /usr/src/linux/drivers/char for a good example. In particular think
-        * about adding TCSETAF, TCSETAW, TCSETA, TCSETSF, TCSETSW, TCSETS.
-        */
        switch (cmd) {
-       case TCSBRK:    /* SVID version: non-zero arg --> no break */
-               retval = tty_check_change(tty);
-               if (retval)
-                       return retval;
-               /* Setup an event to indicate when the transmit
-                  buffer empties */
-               spin_lock_irqsave(&epca_lock, flags);
-               setup_empty_event(tty, ch);
-               spin_unlock_irqrestore(&epca_lock, flags);
-               tty_wait_until_sent(tty, 0);
-               if (!arg)
-                       digi_send_break(ch, HZ / 4);    /* 1/4 second */
-               return 0;
-       case TCSBRKP:   /* support for POSIX tcsendbreak() */
-               retval = tty_check_change(tty);
-               if (retval)
-                       return retval;
-               /* Setup an event to indicate when the transmit buffer
-                  empties */
-               spin_lock_irqsave(&epca_lock, flags);
-               setup_empty_event(tty, ch);
-               spin_unlock_irqrestore(&epca_lock, flags);
-               tty_wait_until_sent(tty, 0);
-               digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4);
-               return 0;
        case TIOCMODG:
                mflag = pc_tiocmget(tty, file);
                if (put_user(mflag, (unsigned long __user *)argp))
@@ -2505,10 +2474,14 @@ static void pc_unthrottle(struct tty_struct *tty)
        }
 }
 
-static void digi_send_break(struct channel *ch, int msec)
+static int pc_send_break(struct tty_struct *tty, int msec)
 {
+       struct channel *ch = (struct channel *) tty->driver_data;
        unsigned long flags;
 
+       if (msec == -1)
+               return -EOPNOTSUPP;
+
        spin_lock_irqsave(&epca_lock, flags);
        globalwinon(ch);
        /*
@@ -2521,6 +2494,7 @@ static void digi_send_break(struct channel *ch, int msec)
        fepcmd(ch, SENDBREAK, msec, 0, 10, 0);
        memoff(ch);
        spin_unlock_irqrestore(&epca_lock, flags);
+       return 0;
 }
 
 /* Caller MUST hold the lock */
@@ -2538,7 +2512,8 @@ static void setup_empty_event(struct tty_struct *tty, struct channel *ch)
        memoff(ch);
 }
 
-static void epca_setup(char *str, int *ints)
+#ifndef MODULE
+static void __init epca_setup(char *str, int *ints)
 {
        struct board_info board;
        int               index, loop, last;
@@ -2792,6 +2767,17 @@ static void epca_setup(char *str, int *ints)
        num_cards++;
 }
 
+static int __init epca_real_setup(char *str)
+{
+       int ints[11];
+
+       epca_setup(get_options(str, 11, ints), ints);
+       return 1;
+}
+
+__setup("digiepca", epca_real_setup);
+#endif
+
 enum epic_board_types {
        brd_xr = 0,
        brd_xem,
index 2eaf09f..7f077c0 100644 (file)
@@ -1725,13 +1725,13 @@ static int esp_tiocmset(struct tty_struct *tty, struct file *file,
 /*
  * rs_break() --- routine which turns the break handling on or off
  */
-static void esp_break(struct tty_struct *tty, int break_state)
+static int esp_break(struct tty_struct *tty, int break_state)
 {
        struct esp_struct *info = tty->driver_data;
        unsigned long flags;
 
        if (serial_paranoia_check(info, tty->name, "esp_break"))
-               return;
+               return -EINVAL;
 
        if (break_state == -1) {
                spin_lock_irqsave(&info->lock, flags);
@@ -1747,6 +1747,7 @@ static void esp_break(struct tty_struct *tty, int break_state)
                serial_out(info, UART_ESI_CMD2, 0x00);
                spin_unlock_irqrestore(&info->lock, flags);
        }
+       return 0;
 }
 
 static int rs_ioctl(struct tty_struct *tty, struct file *file,
index 5dc7440..9cb48fc 100644 (file)
@@ -718,12 +718,12 @@ ip2_loadmain(int *iop, int *irqp)
                        }
 
                        if ( NULL != ( pB = i2BoardPtrTable[i] ) ) {
-                               device_create(ip2_class, NULL,
-                                               MKDEV(IP2_IPL_MAJOR, 4 * i),
-                                               "ipl%d", i);
-                               device_create(ip2_class, NULL,
-                                               MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
-                                               "stat%d", i);
+                               device_create_drvdata(ip2_class, NULL,
+                                                     MKDEV(IP2_IPL_MAJOR, 4 * i),
+                                                     NULL, "ipl%d", i);
+                               device_create_drvdata(ip2_class, NULL,
+                                                     MKDEV(IP2_IPL_MAJOR, 4 * i + 1),
+                                                     NULL, "stat%d", i);
 
                            for ( box = 0; box < ABS_MAX_BOXES; ++box )
                            {
index c11a404..64e1c16 100644 (file)
@@ -871,7 +871,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
        entry->dev = dev;
 
        mutex_lock(&reg_list_mutex);
-       device_create(ipmi_class, device, dev, "ipmi%d", if_num);
+       device_create_drvdata(ipmi_class, device, dev, NULL, "ipmi%d", if_num);
        list_add(&entry->link, &reg_list);
        mutex_unlock(&reg_list_mutex);
 }
index d4281df..8f7cc19 100644 (file)
@@ -1181,14 +1181,17 @@ static int isicom_chars_in_buffer(struct tty_struct *tty)
 }
 
 /* ioctl et all */
-static inline void isicom_send_break(struct isi_port *port,
-       unsigned long length)
+static int isicom_send_break(struct tty_struct *tty, int length)
 {
+       struct isi_port *port = tty->driver_data;
        struct isi_board *card = port->card;
        unsigned long base = card->base;
 
+       if (length == -1)
+               return -EOPNOTSUPP;
+
        if (!lock_card(card))
-               return;
+               return -EINVAL;
 
        outw(0x8000 | ((port->channel) << (card->shift_count)) | 0x3, base);
        outw((length & 0xff) << 8 | 0x00, base);
@@ -1196,6 +1199,7 @@ static inline void isicom_send_break(struct isi_port *port,
        InterruptTheCard(base);
 
        unlock_card(card);
+       return 0;
 }
 
 static int isicom_tiocmget(struct tty_struct *tty, struct file *file)
@@ -1305,28 +1309,11 @@ static int isicom_ioctl(struct tty_struct *tty, struct file *filp,
 {
        struct isi_port *port = tty->driver_data;
        void __user *argp = (void __user *)arg;
-       int retval;
 
        if (isicom_paranoia_check(port, tty->name, "isicom_ioctl"))
                return -ENODEV;
 
        switch (cmd) {
-       case TCSBRK:
-               retval = tty_check_change(tty);
-               if (retval)
-                       return retval;
-               tty_wait_until_sent(tty, 0);
-               if (!arg)
-                       isicom_send_break(port, HZ/4);
-               return 0;
-
-       case TCSBRKP:
-               retval = tty_check_change(tty);
-               if (retval)
-                       return retval;
-               tty_wait_until_sent(tty, 0);
-               isicom_send_break(port, arg ? arg * (HZ/10) : HZ/4);
-               return 0;
        case TIOCGSERIAL:
                return isicom_get_serial_info(port, argp);
 
@@ -1459,6 +1446,7 @@ static const struct tty_operations isicom_ops = {
        .flush_buffer           = isicom_flush_buffer,
        .tiocmget               = isicom_tiocmget,
        .tiocmset               = isicom_tiocmset,
+       .break_ctl              = isicom_send_break,
 };
 
 static int __devinit reset_card(struct pci_dev *pdev,
@@ -1832,7 +1820,7 @@ static int __init isicom_init(void)
        isicom_normal->init_termios.c_cflag     = B9600 | CS8 | CREAD | HUPCL |
                CLOCAL;
        isicom_normal->flags                    = TTY_DRIVER_REAL_RAW |
-               TTY_DRIVER_DYNAMIC_DEV;
+               TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK;
        tty_set_operations(isicom_normal, &isicom_ops);
 
        retval = tty_register_driver(isicom_normal);
index 7930fba..843a2af 100644 (file)
@@ -609,7 +609,7 @@ static void stli_unthrottle(struct tty_struct *tty);
 static void    stli_stop(struct tty_struct *tty);
 static void    stli_start(struct tty_struct *tty);
 static void    stli_flushbuffer(struct tty_struct *tty);
-static void    stli_breakctl(struct tty_struct *tty, int state);
+static int     stli_breakctl(struct tty_struct *tty, int state);
 static void    stli_waituntilsent(struct tty_struct *tty, int timeout);
 static void    stli_sendxchar(struct tty_struct *tty, char ch);
 static void    stli_hangup(struct tty_struct *tty);
@@ -925,8 +925,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
        clear_bit(ST_TXBUSY, &portp->state);
        clear_bit(ST_RXSTOP, &portp->state);
        set_bit(TTY_IO_ERROR, &tty->flags);
-       if (tty->ldisc.ops->flush_buffer)
-               (tty->ldisc.ops->flush_buffer)(tty);
+       tty_ldisc_flush(tty);
        set_bit(ST_DOFLUSHRX, &portp->state);
        stli_flushbuffer(tty);
 
@@ -1909,7 +1908,7 @@ static void stli_flushbuffer(struct tty_struct *tty)
 
 /*****************************************************************************/
 
-static void stli_breakctl(struct tty_struct *tty, int state)
+static int stli_breakctl(struct tty_struct *tty, int state)
 {
        struct stlibrd  *brdp;
        struct stliport *portp;
@@ -1917,15 +1916,16 @@ static void stli_breakctl(struct tty_struct *tty, int state)
 
        portp = tty->driver_data;
        if (portp == NULL)
-               return;
+               return -EINVAL;
        if (portp->brdnr >= stli_nrbrds)
-               return;
+               return -EINVAL;
        brdp = stli_brds[portp->brdnr];
        if (brdp == NULL)
-               return;
+               return -EINVAL;
 
        arg = (state == -1) ? BREAKON : BREAKOFF;
        stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0);
+       return 0;
 }
 
 /*****************************************************************************/
@@ -4599,8 +4599,9 @@ static int __init istallion_module_init(void)
 
        istallion_class = class_create(THIS_MODULE, "staliomem");
        for (i = 0; i < 4; i++)
-               device_create(istallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
-                             "staliomem%d", i);
+               device_create_drvdata(istallion_class, NULL,
+                                     MKDEV(STL_SIOMEMMAJOR, i),
+                                     NULL, "staliomem%d", i);
 
        return 0;
 err_deinit:
index 71abb4c..3f2719b 100644 (file)
@@ -813,7 +813,8 @@ static int lp_register(int nr, struct parport *port)
        if (reset)
                lp_reset(nr);
 
-       device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), "lp%d", nr);
+       device_create_drvdata(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL,
+                             "lp%d", nr);
 
        printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, 
               (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
index b6772d6..c2dba82 100644 (file)
@@ -989,9 +989,9 @@ static int __init chr_dev_init(void)
 
        mem_class = class_create(THIS_MODULE, "mem");
        for (i = 0; i < ARRAY_SIZE(devlist); i++)
-               device_create(mem_class, NULL,
-                             MKDEV(MEM_MAJOR, devlist[i].minor),
-                             devlist[i].name);
+               device_create_drvdata(mem_class, NULL,
+                                     MKDEV(MEM_MAJOR, devlist[i].minor),
+                                     NULL, devlist[i].name);
 
        return 0;
 }
index 6e1563c..999aa77 100644 (file)
@@ -217,8 +217,8 @@ int misc_register(struct miscdevice * misc)
                misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7);
        dev = MKDEV(MISC_MAJOR, misc->minor);
 
-       misc->this_device = device_create(misc_class, misc->parent, dev,
-                                         "%s", misc->name);
+       misc->this_device = device_create_drvdata(misc_class, misc->parent,
+                                                 dev, NULL, "%s", misc->name);
        if (IS_ERR(misc->this_device)) {
                err = PTR_ERR(misc->this_device);
                goto out;
index 2bba250..d3d7864 100644 (file)
@@ -374,12 +374,13 @@ copy:
        return ret;
 }
 
-static void moxa_break_ctl(struct tty_struct *tty, int state)
+static int moxa_break_ctl(struct tty_struct *tty, int state)
 {
        struct moxa_port *port = tty->driver_data;
 
        moxafunc(port->tableAddr, state ? FC_SendBreak : FC_StopBreak,
                        Magic_code);
+       return 0;
 }
 
 static const struct tty_operations moxa_ops = {
index 6307e30..4c756bb 100644 (file)
@@ -47,7 +47,7 @@
 
 #include "mxser.h"
 
-#define        MXSER_VERSION   "2.0.3"         /* 1.11 */
+#define        MXSER_VERSION   "2.0.4"         /* 1.12 */
 #define        MXSERMAJOR       174
 #define        MXSERCUMAJOR     175
 
 #define UART_MCR_AFE           0x20
 #define UART_LSR_SPECIAL       0x1E
 
+#define PCI_DEVICE_ID_POS104UL 0x1044
 #define PCI_DEVICE_ID_CB108    0x1080
+#define PCI_DEVICE_ID_CP102UF  0x1023
 #define PCI_DEVICE_ID_CB114    0x1142
 #define PCI_DEVICE_ID_CP114UL  0x1143
 #define PCI_DEVICE_ID_CB134I   0x1341
 #define PCI_DEVICE_ID_CP138U   0x1380
-#define PCI_DEVICE_ID_POS104UL 0x1044
 
 
 #define C168_ASIC_ID    1
@@ -142,7 +143,8 @@ static const struct mxser_cardinfo mxser_cards[] = {
        { "CB-134I series",     4, },
        { "CP-138U series",     8, },
        { "POS-104UL series",   4, },
-       { "CP-114UL series",    4, }
+       { "CP-114UL series",    4, },
+/*30*/ { "CP-102UF series",    2, }
 };
 
 /* driver_data correspond to the lines in the structure above
@@ -172,6 +174,7 @@ static struct pci_device_id mxser_pcibrds[] = {
        { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP138U),      .driver_data = 27 },
        { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_POS104UL),    .driver_data = 28 },
        { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP114UL),     .driver_data = 29 },
+       { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_CP102UF),     .driver_data = 30 },
        { }
 };
 MODULE_DEVICE_TABLE(pci, mxser_pcibrds);
@@ -1414,7 +1417,6 @@ static int mxser_set_serial_info(struct mxser_port *info,
                info->port.closing_wait = new_serial.closing_wait * HZ / 100;
                info->port.tty->low_latency =
                                (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
-               info->port.tty->low_latency = 0;
                if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
                                (new_serial.baud_base != info->baud_base ||
                                new_serial.custom_divisor !=
@@ -1464,27 +1466,6 @@ static int mxser_get_lsr_info(struct mxser_port *info,
        return put_user(result, value);
 }
 
-/*
- * This routine sends a break character out the serial port.
- */
-static void mxser_send_break(struct mxser_port *info, int duration)
-{
-       unsigned long flags;
-
-       if (!info->ioaddr)
-               return;
-       set_current_state(TASK_INTERRUPTIBLE);
-       spin_lock_irqsave(&info->slock, flags);
-       outb(inb(info->ioaddr + UART_LCR) | UART_LCR_SBC,
-               info->ioaddr + UART_LCR);
-       spin_unlock_irqrestore(&info->slock, flags);
-       schedule_timeout(duration);
-       spin_lock_irqsave(&info->slock, flags);
-       outb(inb(info->ioaddr + UART_LCR) & ~UART_LCR_SBC,
-               info->ioaddr + UART_LCR);
-       spin_unlock_irqrestore(&info->slock, flags);
-}
-
 static int mxser_tiocmget(struct tty_struct *tty, struct file *file)
 {
        struct mxser_port *info = tty->driver_data;
@@ -1872,21 +1853,6 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
                return -EIO;
 
        switch (cmd) {
-       case TCSBRK:            /* SVID version: non-zero arg --> no break */
-               retval = tty_check_change(tty);
-               if (retval)
-                       return retval;
-               tty_wait_until_sent(tty, 0);
-               if (!arg)
-                       mxser_send_break(info, HZ / 4); /* 1/4 second */
-               return 0;
-       case TCSBRKP:           /* support for POSIX tcsendbreak() */
-               retval = tty_check_change(tty);
-               if (retval)
-                       return retval;
-               tty_wait_until_sent(tty, 0);
-               mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4);
-               return 0;
        case TIOCGSERIAL:
                lock_kernel();
                retval = mxser_get_serial_info(info, argp);
@@ -2219,7 +2185,7 @@ static void mxser_hangup(struct tty_struct *tty)
 /*
  * mxser_rs_break() --- routine which turns the break handling on or off
  */
-static void mxser_rs_break(struct tty_struct *tty, int break_state)
+static int mxser_rs_break(struct tty_struct *tty, int break_state)
 {
        struct mxser_port *info = tty->driver_data;
        unsigned long flags;
@@ -2232,6 +2198,7 @@ static void mxser_rs_break(struct tty_struct *tty, int break_state)
                outb(inb(info->ioaddr + UART_LCR) & ~UART_LCR_SBC,
                        info->ioaddr + UART_LCR);
        spin_unlock_irqrestore(&info->slock, flags);
+       return 0;
 }
 
 static void mxser_receive_chars(struct mxser_port *port, int *status)
index ed4e033..69ec639 100644 (file)
@@ -677,6 +677,10 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
        /* Allocate transmit buffer */
        /* sleep until transmit buffer available */             
        while (!(tbuf = n_hdlc_buf_get(&n_hdlc->tx_free_buf_list))) {
+               if (file->f_flags & O_NONBLOCK) {
+                       error = -EAGAIN;
+                       break;
+               }
                schedule();
                        
                n_hdlc = tty2n_hdlc (tty);
index e4a4fbd..f070ae7 100644 (file)
@@ -1896,7 +1896,7 @@ static int cm4000_probe(struct pcmcia_device *link)
                return ret;
        }
 
-       device_create(cmm_class, NULL, MKDEV(major, i), "cmm%d", i);
+       device_create_drvdata(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i);
 
        return 0;
 }
index 6181f8a..0b5934b 100644 (file)
@@ -653,7 +653,8 @@ static int reader_probe(struct pcmcia_device *link)
                return ret;
        }
 
-       device_create(cmx_class, NULL, MKDEV(major, i), "cmx%d", i);
+       device_create_drvdata(cmx_class, NULL, MKDEV(major, i), NULL,
+                             "cmx%d", i);
 
        return 0;
 }
index b694d43..d1fceab 100644 (file)
@@ -2230,7 +2230,7 @@ static int tiocmset(struct tty_struct *tty, struct file *file,
  * Arguments:          tty             pointer to tty instance data
  *                     break_state     -1=set break condition, 0=clear
  */
-static void mgslpc_break(struct tty_struct *tty, int break_state)
+static int mgslpc_break(struct tty_struct *tty, int break_state)
 {
        MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data;
        unsigned long flags;
@@ -2240,7 +2240,7 @@ static void mgslpc_break(struct tty_struct *tty, int break_state)
                         __FILE__,__LINE__, info->device_name, break_state);
 
        if (mgslpc_paranoia_check(info, tty->name, "mgslpc_break"))
-               return;
+               return -EINVAL;
 
        spin_lock_irqsave(&info->lock,flags);
        if (break_state == -1)
@@ -2248,6 +2248,7 @@ static void mgslpc_break(struct tty_struct *tty, int break_state)
        else
                clear_reg_bits(info, CHA+DAFO, BIT6);
        spin_unlock_irqrestore(&info->lock,flags);
+       return 0;
 }
 
 /* Service an IOCTL request
index f6e6aca..7af7a7e 100644 (file)
@@ -752,8 +752,9 @@ static const struct file_operations pp_fops = {
 
 static void pp_attach(struct parport *port)
 {
-       device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number),
-                       "parport%d", port->number);
+       device_create_drvdata(ppdev_class, port->dev,
+                             MKDEV(PP_MAJOR, port->number),
+                             NULL, "parport%d", port->number);
 }
 
 static void pp_detach(struct parport *port)
index 505fcbe..47b8cf2 100644 (file)
@@ -131,8 +131,8 @@ raw_ioctl(struct inode *inode, struct file *filp,
 static void bind_device(struct raw_config_request *rq)
 {
        device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor));
-       device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
-                     "raw%d", rq->raw_minor);
+       device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor),
+                             NULL, "raw%d", rq->raw_minor);
 }
 
 /*
@@ -283,7 +283,8 @@ static int __init raw_init(void)
                ret = PTR_ERR(raw_class);
                goto error_region;
        }
-       device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), "rawctl");
+       device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL,
+                             "rawctl");
 
        return 0;
 
index 724b2b2..2c6c8f3 100644 (file)
@@ -1250,11 +1250,15 @@ static int rc_tiocmset(struct tty_struct *tty, struct file *file,
        return 0;
 }
 
-static void rc_send_break(struct riscom_port *port, unsigned long length)
+static int rc_send_break(struct tty_struct *tty, int length)
 {
+       struct riscom_port *port = (struct riscom_port *)tty->driver_data;
        struct riscom_board *bp = port_Board(port);
        unsigned long flags;
 
+       if (length == 0 || length == -1)
+               return -EOPNOTSUPP;
+
        spin_lock_irqsave(&riscom_lock, flags);
 
        port->break_length = RISCOM_TPS / HZ * length;
@@ -1268,6 +1272,7 @@ static void rc_send_break(struct riscom_port *port, unsigned long length)
        rc_wait_CCR(bp);
 
        spin_unlock_irqrestore(&riscom_lock, flags);
+       return 0;
 }
 
 static int rc_set_serial_info(struct riscom_port *port,
@@ -1342,27 +1347,12 @@ static int rc_ioctl(struct tty_struct *tty, struct file *filp,
 {
        struct riscom_port *port = (struct riscom_port *)tty->driver_data;
        void __user *argp = (void __user *)arg;
-       int retval = 0;
+       int retval;
 
        if (rc_paranoia_check(port, tty->name, "rc_ioctl"))
                return -ENODEV;
 
        switch (cmd) {
-       case TCSBRK:    /* SVID version: non-zero arg --> no break */
-               retval = tty_check_change(tty);
-               if (retval)
-                       return retval;
-               tty_wait_until_sent(tty, 0);
-               if (!arg)
-                       rc_send_break(port, HZ/4);      /* 1/4 second */
-               break;
-       case TCSBRKP:   /* support for POSIX tcsendbreak() */
-               retval = tty_check_change(tty);
-               if (retval)
-                       return retval;
-               tty_wait_until_sent(tty, 0);
-               rc_send_break(port, arg ? arg*(HZ/10) : HZ/4);
-               break;
        case TIOCGSERIAL:
                lock_kernel();
                retval = rc_get_serial_info(port, argp);
@@ -1517,6 +1507,7 @@ static const struct tty_operations riscom_ops = {
        .hangup = rc_hangup,
        .tiocmget = rc_tiocmget,
        .tiocmset = rc_tiocmset,
+       .break_ctl = rc_send_break,
 };
 
 static int __init rc_init_drivers(void)
@@ -1538,7 +1529,7 @@ static int __init rc_init_drivers(void)
                B9600 | CS8 | CREAD | HUPCL | CLOCAL;
        riscom_driver->init_termios.c_ispeed = 9600;
        riscom_driver->init_termios.c_ospeed = 9600;
-       riscom_driver->flags = TTY_DRIVER_REAL_RAW;
+       riscom_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_HARDWARE_BREAK;
        tty_set_operations(riscom_driver, &riscom_ops);
        error = tty_register_driver(riscom_driver);
        if (error != 0) {
index e670eae..584d791 100644 (file)
@@ -1236,13 +1236,13 @@ static void rp_set_termios(struct tty_struct *tty,
        }
 }
 
-static void rp_break(struct tty_struct *tty, int break_state)
+static int rp_break(struct tty_struct *tty, int break_state)
 {
        struct r_port *info = (struct r_port *) tty->driver_data;
        unsigned long flags;
 
        if (rocket_paranoia_check(info, "rp_break"))
-               return;
+               return -EINVAL;
 
        spin_lock_irqsave(&info->slock, flags);
        if (break_state == -1)
@@ -1250,6 +1250,7 @@ static void rp_break(struct tty_struct *tty, int break_state)
        else
                sClrBreak(&info->channel);
        spin_unlock_irqrestore(&info->slock, flags);
+       return 0;
 }
 
 /*
index 0b799ac..3ce60df 100644 (file)
@@ -444,7 +444,8 @@ scdrv_init(void)
                                continue;
                        }
 
-                       device_create(snsc_class, NULL, dev, "%s", devname);
+                       device_create_drvdata(snsc_class, NULL, dev, NULL,
+                                             "%s", devname);
 
                        ia64_sn_irtr_intr_enable(scd->scd_nasid,
                                                 0 /*ignored */ ,
index 037dc47..242fd46 100644 (file)
@@ -77,7 +77,7 @@
 
 #include <linux/module.h>
 
-#include <asm/io.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/ioport.h>
@@ -92,7 +92,7 @@
 #include <linux/delay.h>
 #include <linux/pci.h>
 #include <linux/init.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #include "specialix_io8.h"
 #include "cd1865.h"
 
 static int sx_debug;
 static int sx_rxfifo = SPECIALIX_RXFIFO;
+static int sx_rtscts;
 
 #ifdef DEBUG
-#define dprintk(f, str...) if (sx_debug & f) printk (str)
+#define dprintk(f, str...) if (sx_debug & f) printk(str)
 #else
 #define dprintk(f, str...) /* nothing */
 #endif
@@ -131,10 +132,8 @@ static int sx_rxfifo = SPECIALIX_RXFIFO;
 #define SX_DEBUG_FIFO    0x0800
 
 
-#define func_enter() dprintk (SX_DEBUG_FLOW, "io8: enter %s\n",__func__)
-#define func_exit()  dprintk (SX_DEBUG_FLOW, "io8: exit  %s\n", __func__)
-
-#define jiffies_from_ms(a) ((((a) * HZ)/1000)+1)
+#define func_enter() dprintk(SX_DEBUG_FLOW, "io8: enter %s\n", __func__)
+#define func_exit()  dprintk(SX_DEBUG_FLOW, "io8: exit  %s\n", __func__)
 
 
 /* Configurable options: */
@@ -142,17 +141,6 @@ static int sx_rxfifo = SPECIALIX_RXFIFO;
 /* Am I paranoid or not ? ;-) */
 #define SPECIALIX_PARANOIA_CHECK
 
-/* Do I trust the IRQ from the card? (enabeling it doesn't seem to help)
-   When the IRQ routine leaves the chip in a state that is keeps on
-   requiring attention, the timer doesn't help either. */
-#undef SPECIALIX_TIMER
-
-#ifdef SPECIALIX_TIMER
-static int sx_poll = HZ;
-#endif
-
-
-
 /*
  * The following defines are mostly for testing purposes. But if you need
  * some nice reporting in your syslog, you can define them also.
@@ -162,16 +150,6 @@ static int sx_poll = HZ;
 
 
 
-#ifdef CONFIG_SPECIALIX_RTSCTS
-#define SX_CRTSCTS(bla) 1
-#else
-#define SX_CRTSCTS(tty) C_CRTSCTS(tty)
-#endif
-
-
-/* Used to be outb (0xff, 0x80); */
-#define short_pause() udelay (1)
-
 
 #define SPECIALIX_LEGAL_FLAGS \
        (ASYNC_HUP_NOTIFY   | ASYNC_SAK          | ASYNC_SPLIT_TERMIOS   | \
@@ -190,21 +168,14 @@ static struct specialix_board sx_board[SX_NBOARD] =  {
 static struct specialix_port sx_port[SX_NBOARD * SX_NPORT];
 
 
-#ifdef SPECIALIX_TIMER
-static struct timer_list missed_irq_timer;
-static irqreturn_t sx_interrupt(int irq, void * dev_id);
-#endif
-
-
-
-static inline int sx_paranoia_check(struct specialix_port const * port,
+static int sx_paranoia_check(struct specialix_port const *port,
                                    char *name, const char *routine)
 {
 #ifdef SPECIALIX_PARANOIA_CHECK
-       static const char *badmagic =
-               KERN_ERR "sx: Warning: bad specialix port magic number for device %s in %s\n";
-       static const char *badinfo =
-               KERN_ERR "sx: Warning: null specialix port for device %s in %s\n";
+       static const char *badmagic = KERN_ERR
+         "sx: Warning: bad specialix port magic number for device %s in %s\n";
+       static const char *badinfo = KERN_ERR
+         "sx: Warning: null specialix port for device %s in %s\n";
 
        if (!port) {
                printk(badinfo, name, routine);
@@ -226,66 +197,69 @@ static inline int sx_paranoia_check(struct specialix_port const * port,
  */
 
 /* Get board number from pointer */
-static inline int board_No (struct specialix_board * bp)
+static inline int board_No(struct specialix_board *bp)
 {
        return bp - sx_board;
 }
 
 
 /* Get port number from pointer */
-static inline int port_No (struct specialix_port const * port)
+static inline int port_No(struct specialix_port const *port)
 {
        return SX_PORT(port - sx_port);
 }
 
 
 /* Get pointer to board from pointer to port */
-static inline struct specialix_board * port_Board(struct specialix_port const * port)
+static inline struct specialix_board *port_Board(
+                                       struct specialix_port const *port)
 {
        return &sx_board[SX_BOARD(port - sx_port)];
 }
 
 
 /* Input Byte from CL CD186x register */
-static inline unsigned char sx_in(struct specialix_board  * bp, unsigned short reg)
+static inline unsigned char sx_in(struct specialix_board *bp,
+                                                       unsigned short reg)
 {
        bp->reg = reg | 0x80;
-       outb (reg | 0x80, bp->base + SX_ADDR_REG);
-       return inb  (bp->base + SX_DATA_REG);
+       outb(reg | 0x80, bp->base + SX_ADDR_REG);
+       return inb(bp->base + SX_DATA_REG);
 }
 
 
 /* Output Byte to CL CD186x register */
-static inline void sx_out(struct specialix_board  * bp, unsigned short reg,
+static inline void sx_out(struct specialix_board *bp, unsigned short reg,
                          unsigned char val)
 {
        bp->reg = reg | 0x80;
-       outb (reg | 0x80, bp->base + SX_ADDR_REG);
-       outb (val, bp->base + SX_DATA_REG);
+       outb(reg | 0x80, bp->base + SX_ADDR_REG);
+       outb(val, bp->base + SX_DATA_REG);
 }
 
 
 /* Input Byte from CL CD186x register */
-static inline unsigned char sx_in_off(struct specialix_board  * bp, unsigned short reg)
+static inline unsigned char sx_in_off(struct specialix_board *bp,
+                               unsigned short reg)
 {
        bp->reg = reg;
-       outb (reg, bp->base + SX_ADDR_REG);
-       return inb  (bp->base + SX_DATA_REG);
+       outb(reg, bp->base + SX_ADDR_REG);
+       return inb(bp->base + SX_DATA_REG);
 }
 
 
 /* Output Byte to CL CD186x register */
-static inline void sx_out_off(struct specialix_board  * bp, unsigned short reg,
-                         unsigned char val)
+static inline void sx_out_off(struct specialix_board  *bp,
+                               unsigned short reg, unsigned char val)
 {
        bp->reg = reg;
-       outb (reg, bp->base + SX_ADDR_REG);
-       outb (val, bp->base + SX_DATA_REG);
+       outb(reg, bp->base + SX_ADDR_REG);
+       outb(val, bp->base + SX_DATA_REG);
 }
 
 
 /* Wait for Channel Command Register ready */
-static inline void sx_wait_CCR(struct specialix_board  * bp)
+static void sx_wait_CCR(struct specialix_board  *bp)
 {
        unsigned long delay, flags;
        unsigned char ccr;
@@ -296,7 +270,7 @@ static inline void sx_wait_CCR(struct specialix_board  * bp)
                spin_unlock_irqrestore(&bp->lock, flags);
                if (!ccr)
                        return;
-               udelay (1);
+               udelay(1);
        }
 
        printk(KERN_ERR "sx%d: Timeout waiting for CCR.\n", board_No(bp));
@@ -304,7 +278,7 @@ static inline void sx_wait_CCR(struct specialix_board  * bp)
 
 
 /* Wait for Channel Command Register ready */
-static inline void sx_wait_CCR_off(struct specialix_board  * bp)
+static void sx_wait_CCR_off(struct specialix_board  *bp)
 {
        unsigned long delay;
        unsigned char crr;
@@ -316,7 +290,7 @@ static inline void sx_wait_CCR_off(struct specialix_board  * bp)
                spin_unlock_irqrestore(&bp->lock, flags);
                if (!crr)
                        return;
-               udelay (1);
+               udelay(1);
        }
 
        printk(KERN_ERR "sx%d: Timeout waiting for CCR.\n", board_No(bp));
@@ -327,7 +301,7 @@ static inline void sx_wait_CCR_off(struct specialix_board  * bp)
  *  specialix IO8+ IO range functions.
  */
 
-static inline int sx_request_io_range(struct specialix_board * bp)
+static int sx_request_io_range(struct specialix_board *bp)
 {
        return request_region(bp->base,
                bp->flags & SX_BOARD_IS_PCI ? SX_PCI_IO_SPACE : SX_IO_SPACE,
@@ -335,15 +309,15 @@ static inline int sx_request_io_range(struct specialix_board * bp)
 }
 
 
-static inline void sx_release_io_range(struct specialix_board * bp)
+static void sx_release_io_range(struct specialix_board *bp)
 {
-       release_region(bp->base,
-                      bp->flags&SX_BOARD_IS_PCI?SX_PCI_IO_SPACE:SX_IO_SPACE);
+       release_region(bp->base, bp->flags & SX_BOARD_IS_PCI ?
+                                       SX_PCI_IO_SPACE : SX_IO_SPACE);
 }
 
 
 /* Set the IRQ using the RTS lines that run to the PAL on the board.... */
-static int sx_set_irq ( struct specialix_board *bp)
+static int sx_set_irq(struct specialix_board *bp)
 {
        int virq;
        int i;
@@ -353,15 +327,24 @@ static int sx_set_irq ( struct specialix_board *bp)
                return 1;
        switch (bp->irq) {
        /* In the same order as in the docs... */
-       case 15: virq = 0;break;
-       case 12: virq = 1;break;
-       case 11: virq = 2;break;
-       case 9:  virq = 3;break;
-       default: printk (KERN_ERR "Speclialix: cannot set irq to %d.\n", bp->irq);
-                return 0;
+       case 15:
+               virq = 0;
+               break;
+       case 12:
+               virq = 1;
+               break;
+       case 11:
+               virq = 2;
+               break;
+       case 9:
+               virq = 3;
+               break;
+       default:printk(KERN_ERR
+                           "Speclialix: cannot set irq to %d.\n", bp->irq);
+               return 0;
        }
        spin_lock_irqsave(&bp->lock, flags);
-       for (i=0;i<2;i++) {
+       for (i = 0; i < 2; i++) {
                sx_out(bp, CD186x_CAR, i);
                sx_out(bp, CD186x_MSVRTS, ((virq >> i) & 0x1)? MSVR_RTS:0);
        }
@@ -371,7 +354,7 @@ static int sx_set_irq ( struct specialix_board *bp)
 
 
 /* Reset and setup CD186x chip */
-static int sx_init_CD186x(struct specialix_board  * bp)
+static int sx_init_CD186x(struct specialix_board  *bp)
 {
        unsigned long flags;
        int scaler;
@@ -390,7 +373,7 @@ static int sx_init_CD186x(struct specialix_board  * bp)
        sx_out_off(bp, CD186x_PILR2, SX_ACK_TINT);      /* Prio for transmitter intr */
        sx_out_off(bp, CD186x_PILR3, SX_ACK_RINT);      /* Prio for receiver intr    */
        /* Set RegAckEn */
-       sx_out_off(bp, CD186x_SRCR, sx_in (bp, CD186x_SRCR) | SRCR_REGACKEN);
+       sx_out_off(bp, CD186x_SRCR, sx_in(bp, CD186x_SRCR) | SRCR_REGACKEN);
 
        /* Setting up prescaler. We need 4 ticks per 1 ms */
        scaler =  SX_OSCFREQ/SPECIALIX_TPS;
@@ -399,9 +382,9 @@ static int sx_init_CD186x(struct specialix_board  * bp)
        sx_out_off(bp, CD186x_PPRL, scaler & 0xff);
        spin_unlock_irqrestore(&bp->lock, flags);
 
-       if (!sx_set_irq (bp)) {
+       if (!sx_set_irq(bp)) {
                /* Figure out how to pass this along... */
-               printk (KERN_ERR "Cannot set irq to %d.\n", bp->irq);
+               printk(KERN_ERR "Cannot set irq to %d.\n", bp->irq);
                rv = 0;
        }
 
@@ -410,16 +393,16 @@ static int sx_init_CD186x(struct specialix_board  * bp)
 }
 
 
-static int read_cross_byte (struct specialix_board *bp, int reg, int bit)
+static int read_cross_byte(struct specialix_board *bp, int reg, int bit)
 {
        int i;
        int t;
        unsigned long flags;
 
        spin_lock_irqsave(&bp->lock, flags);
-       for (i=0, t=0;i<8;i++) {
-               sx_out_off (bp, CD186x_CAR, i);
-               if (sx_in_off (bp, reg) & bit)
+       for (i = 0, t = 0; i < 8; i++) {
+               sx_out_off(bp, CD186x_CAR, i);
+               if (sx_in_off(bp, reg) & bit)
                        t |= 1 << i;
        }
        spin_unlock_irqrestore(&bp->lock, flags);
@@ -428,37 +411,10 @@ static int read_cross_byte (struct specialix_board *bp, int reg, int bit)
 }
 
 
-#ifdef SPECIALIX_TIMER
-void missed_irq (unsigned long data)
-{
-       unsigned char irq;
-       unsigned long flags;
-       struct specialix_board  *bp = (struct specialix_board *)data;
-
-       spin_lock_irqsave(&bp->lock, flags);
-       irq = sx_in ((struct specialix_board *)data, CD186x_SRSR) &
-                                                   (SRSR_RREQint |
-                                                    SRSR_TREQint |
-                                                    SRSR_MREQint);
-       spin_unlock_irqrestore(&bp->lock, flags);
-       if (irq) {
-               printk (KERN_INFO "Missed interrupt... Calling int from timer. \n");
-               sx_interrupt (-1, bp);
-       }
-       mod_timer(&missed_irq_timer, jiffies + sx_poll);
-}
-#endif
-
-
-
 /* Main probing routine, also sets irq. */
 static int sx_probe(struct specialix_board *bp)
 {
        unsigned char val1, val2;
-#if 0
-       int irqs = 0;
-       int retries;
-#endif
        int rev;
        int chip;
 
@@ -471,17 +427,18 @@ static int sx_probe(struct specialix_board *bp)
 
        /* Are the I/O ports here ? */
        sx_out_off(bp, CD186x_PPRL, 0x5a);
-       short_pause ();
+       udelay(1);
        val1 = sx_in_off(bp, CD186x_PPRL);
 
        sx_out_off(bp, CD186x_PPRL, 0xa5);
-       short_pause ();
+       udelay(1);
        val2 = sx_in_off(bp, CD186x_PPRL);
 
 
-       if ((val1 != 0x5a) || (val2 != 0xa5)) {
-               printk(KERN_INFO "sx%d: specialix IO8+ Board at 0x%03x not found.\n",
-                      board_No(bp), bp->base);
+       if (val1 != 0x5a || val2 != 0xa5) {
+               printk(KERN_INFO
+                       "sx%d: specialix IO8+ Board at 0x%03x not found.\n",
+                                               board_No(bp), bp->base);
                sx_release_io_range(bp);
                func_exit();
                return 1;
@@ -489,10 +446,11 @@ static int sx_probe(struct specialix_board *bp)
 
        /* Check the DSR lines that Specialix uses as board
           identification */
-       val1 = read_cross_byte (bp, CD186x_MSVR, MSVR_DSR);
-       val2 = read_cross_byte (bp, CD186x_MSVR, MSVR_RTS);
-       dprintk (SX_DEBUG_INIT, "sx%d: DSR lines are: %02x, rts lines are: %02x\n",
-               board_No(bp),  val1, val2);
+       val1 = read_cross_byte(bp, CD186x_MSVR, MSVR_DSR);
+       val2 = read_cross_byte(bp, CD186x_MSVR, MSVR_RTS);
+       dprintk(SX_DEBUG_INIT,
+                       "sx%d: DSR lines are: %02x, rts lines are: %02x\n",
+                                       board_No(bp), val1, val2);
 
        /* They managed to switch the bit order between the docs and
           the IO8+ card. The new PCI card now conforms to old docs.
@@ -500,7 +458,8 @@ static int sx_probe(struct specialix_board *bp)
           old card. */
        val2 = (bp->flags & SX_BOARD_IS_PCI)?0x4d : 0xb2;
        if (val1 != val2) {
-               printk(KERN_INFO "sx%d: specialix IO8+ ID %02x at 0x%03x not found (%02x).\n",
+               printk(KERN_INFO
+                 "sx%d: specialix IO8+ ID %02x at 0x%03x not found (%02x).\n",
                       board_No(bp), val2, bp->base, val1);
                sx_release_io_range(bp);
                func_exit();
@@ -508,47 +467,6 @@ static int sx_probe(struct specialix_board *bp)
        }
 
 
-#if 0
-       /* It's time to find IRQ for this board */
-       for (retries = 0; retries < 5 && irqs <= 0; retries++) {
-               irqs = probe_irq_on();
-               sx_init_CD186x(bp);                     /* Reset CD186x chip       */
-               sx_out(bp, CD186x_CAR, 2);               /* Select port 2          */
-               sx_wait_CCR(bp);
-               sx_out(bp, CD186x_CCR, CCR_TXEN);        /* Enable transmitter     */
-               sx_out(bp, CD186x_IER, IER_TXRDY);       /* Enable tx empty intr   */
-               msleep(50);
-               irqs = probe_irq_off(irqs);
-
-               dprintk (SX_DEBUG_INIT, "SRSR = %02x, ", sx_in(bp, CD186x_SRSR));
-               dprintk (SX_DEBUG_INIT, "TRAR = %02x, ", sx_in(bp, CD186x_TRAR));
-               dprintk (SX_DEBUG_INIT, "GIVR = %02x, ", sx_in(bp, CD186x_GIVR));
-               dprintk (SX_DEBUG_INIT, "GICR = %02x, ", sx_in(bp, CD186x_GICR));
-               dprintk (SX_DEBUG_INIT, "\n");
-
-               /* Reset CD186x again      */
-               if (!sx_init_CD186x(bp)) {
-                       /* Hmmm. This is dead code anyway. */
-               }
-
-               dprintk (SX_DEBUG_INIT "val1 = %02x, val2 = %02x, val3 = %02x.\n",
-                       val1, val2, val3);
-
-       }
-
-#if 0
-       if (irqs <= 0) {
-               printk(KERN_ERR "sx%d: Can't find IRQ for specialix IO8+ board at 0x%03x.\n",
-                      board_No(bp), bp->base);
-               sx_release_io_range(bp);
-               func_exit();
-               return 1;
-       }
-#endif
-       printk (KERN_INFO "Started with irq=%d, but now have irq=%d.\n", bp->irq, irqs);
-       if (irqs > 0)
-               bp->irq = irqs;
-#endif
        /* Reset CD186x again  */
        if (!sx_init_CD186x(bp)) {
                sx_release_io_range(bp);
@@ -560,7 +478,7 @@ static int sx_probe(struct specialix_board *bp)
        bp->flags |= SX_BOARD_PRESENT;
 
        /* Chip           revcode   pkgtype
-                         GFRCR     SRCR bit 7
+                         GFRCR     SRCR bit 7
           CD180 rev B    0x81      0
           CD180 rev C    0x82      0
           CD1864 rev A   0x82      1
@@ -570,24 +488,32 @@ static int sx_probe(struct specialix_board *bp)
         */
 
        switch (sx_in_off(bp, CD186x_GFRCR)) {
-       case 0x82:chip = 1864;rev='A';break;
-       case 0x83:chip = 1865;rev='A';break;
-       case 0x84:chip = 1865;rev='B';break;
-       case 0x85:chip = 1865;rev='C';break; /* Does not exist at this time */
-       default:chip=-1;rev='x';
+       case 0x82:
+               chip = 1864;
+               rev = 'A';
+               break;
+       case 0x83:
+               chip = 1865;
+               rev = 'A';
+               break;
+       case 0x84:
+               chip = 1865;
+               rev = 'B';
+               break;
+       case 0x85:
+               chip = 1865;
+               rev = 'C';
+               break; /* Does not exist at this time */
+       default:
+               chip = -1;
+               rev = 'x';
        }
 
-       dprintk (SX_DEBUG_INIT, " GFCR = 0x%02x\n", sx_in_off(bp, CD186x_GFRCR) );
-
-#ifdef SPECIALIX_TIMER
-       setup_timer(&missed_irq_timer, missed_irq, (unsigned long)bp);
-       mod_timer(&missed_irq_timer, jiffies + sx_poll);
-#endif
+       dprintk(SX_DEBUG_INIT, " GFCR = 0x%02x\n", sx_in_off(bp, CD186x_GFRCR));
 
-       printk(KERN_INFO"sx%d: specialix IO8+ board detected at 0x%03x, IRQ %d, CD%d Rev. %c.\n",
-              board_No(bp),
-              bp->base, bp->irq,
-              chip, rev);
+       printk(KERN_INFO
+    "sx%d: specialix IO8+ board detected at 0x%03x, IRQ %d, CD%d Rev. %c.\n",
+                               board_No(bp), bp->base, bp->irq, chip, rev);
 
        func_exit();
        return 0;
@@ -598,20 +524,22 @@ static int sx_probe(struct specialix_board *bp)
  *  Interrupt processing routines.
  * */
 
-static inline struct specialix_port * sx_get_port(struct specialix_board * bp,
-                                              unsigned char const * what)
+static struct specialix_port *sx_get_port(struct specialix_board *bp,
+                                              unsigned char const *what)
 {
        unsigned char channel;
-       struct specialix_port * port = NULL;
+       struct specialix_port *port = NULL;
 
        channel = sx_in(bp, CD186x_GICR) >> GICR_CHAN_OFF;
-       dprintk (SX_DEBUG_CHAN, "channel: %d\n", channel);
+       dprintk(SX_DEBUG_CHAN, "channel: %d\n", channel);
        if (channel < CD186x_NCH) {
                port = &sx_port[board_No(bp) * SX_NPORT + channel];
-               dprintk (SX_DEBUG_CHAN, "port: %d %p flags: 0x%lx\n",board_No(bp) * SX_NPORT + channel,  port, port->port.flags & ASYNC_INITIALIZED);
+               dprintk(SX_DEBUG_CHAN, "port: %d %p flags: 0x%lx\n",
+                       board_No(bp) * SX_NPORT + channel,  port,
+                       port->port.flags & ASYNC_INITIALIZED);
 
                if (port->port.flags & ASYNC_INITIALIZED) {
-                       dprintk (SX_DEBUG_CHAN, "port: %d %p\n", channel, port);
+                       dprintk(SX_DEBUG_CHAN, "port: %d %p\n", channel, port);
                        func_exit();
                        return port;
                }
@@ -622,7 +550,7 @@ static inline struct specialix_port * sx_get_port(struct specialix_board * bp,
 }
 
 
-static inline void sx_receive_exc(struct specialix_board * bp)
+static void sx_receive_exc(struct specialix_board *bp)
 {
        struct specialix_port *port;
        struct tty_struct *tty;
@@ -633,7 +561,7 @@ static inline void sx_receive_exc(struct specialix_board * bp)
 
        port = sx_get_port(bp, "Receive");
        if (!port) {
-               dprintk (SX_DEBUG_RX, "Hmm, couldn't find port.\n");
+               dprintk(SX_DEBUG_RX, "Hmm, couldn't find port.\n");
                func_exit();
                return;
        }
@@ -641,19 +569,21 @@ static inline void sx_receive_exc(struct specialix_board * bp)
 
        status = sx_in(bp, CD186x_RCSR);
 
-       dprintk (SX_DEBUG_RX, "status: 0x%x\n", status);
+       dprintk(SX_DEBUG_RX, "status: 0x%x\n", status);
        if (status & RCSR_OE) {
                port->overrun++;
-               dprintk(SX_DEBUG_FIFO, "sx%d: port %d: Overrun. Total %ld overruns.\n",
-                      board_No(bp), port_No(port), port->overrun);
+               dprintk(SX_DEBUG_FIFO,
+                       "sx%d: port %d: Overrun. Total %ld overruns.\n",
+                               board_No(bp), port_No(port), port->overrun);
        }
        status &= port->mark_mask;
 
        /* This flip buffer check needs to be below the reading of the
           status register to reset the chip's IRQ.... */
        if (tty_buffer_request_room(tty, 1) == 0) {
-               dprintk(SX_DEBUG_FIFO, "sx%d: port %d: Working around flip buffer overflow.\n",
-                      board_No(bp), port_No(port));
+               dprintk(SX_DEBUG_FIFO,
+                   "sx%d: port %d: Working around flip buffer overflow.\n",
+                                       board_No(bp), port_No(port));
                func_exit();
                return;
        }
@@ -664,8 +594,9 @@ static inline void sx_receive_exc(struct specialix_board * bp)
                return;
        }
        if (status & RCSR_TOUT) {
-               printk(KERN_INFO "sx%d: port %d: Receiver timeout. Hardware problems ?\n",
-                      board_No(bp), port_No(port));
+               printk(KERN_INFO
+                   "sx%d: port %d: Receiver timeout. Hardware problems ?\n",
+                                       board_No(bp), port_No(port));
                func_exit();
                return;
 
@@ -688,13 +619,13 @@ static inline void sx_receive_exc(struct specialix_board * bp)
        else
                flag = TTY_NORMAL;
 
-       if(tty_insert_flip_char(tty, ch, flag))
+       if (tty_insert_flip_char(tty, ch, flag))
                tty_flip_buffer_push(tty);
        func_exit();
 }
 
 
-static inline void sx_receive(struct specialix_board * bp)
+static void sx_receive(struct specialix_board *bp)
 {
        struct specialix_port *port;
        struct tty_struct *tty;
@@ -702,15 +633,16 @@ static inline void sx_receive(struct specialix_board * bp)
 
        func_enter();
 
-       if (!(port = sx_get_port(bp, "Receive"))) {
-               dprintk (SX_DEBUG_RX, "Hmm, couldn't find port.\n");
+       port = sx_get_port(bp, "Receive");
+       if (port == NULL) {
+               dprintk(SX_DEBUG_RX, "Hmm, couldn't find port.\n");
                func_exit();
                return;
        }
        tty = port->port.tty;
 
        count = sx_in(bp, CD186x_RDCR);
-       dprintk (SX_DEBUG_RX, "port: %p: count: %d\n", port, count);
+       dprintk(SX_DEBUG_RX, "port: %p: count: %d\n", port, count);
        port->hits[count > 8 ? 9 : count]++;
 
        tty_buffer_request_room(tty, count);
@@ -722,18 +654,19 @@ static inline void sx_receive(struct specialix_board * bp)
 }
 
 
-static inline void sx_transmit(struct specialix_board * bp)
+static void sx_transmit(struct specialix_board *bp)
 {
        struct specialix_port *port;
        struct tty_struct *tty;
        unsigned char count;
 
        func_enter();
-       if (!(port = sx_get_port(bp, "Transmit"))) {
+       port = sx_get_port(bp, "Transmit");
+       if (port == NULL) {
                func_exit();
                return;
        }
-       dprintk (SX_DEBUG_TX, "port: %p\n", port);
+       dprintk(SX_DEBUG_TX, "port: %p\n", port);
        tty = port->port.tty;
 
        if (port->IER & IER_TXEMPTY) {
@@ -765,7 +698,8 @@ static inline void sx_transmit(struct specialix_board * bp)
                        sx_out(bp, CD186x_TDR, CD186x_C_ESC);
                        sx_out(bp, CD186x_TDR, CD186x_C_DELAY);
                        sx_out(bp, CD186x_TDR, count);
-                       if (!(port->break_length -= count))
+                       port->break_length -= count;
+                       if (port->break_length == 0)
                                port->break_length--;
                } else {
                        sx_out(bp, CD186x_TDR, CD186x_C_ESC);
@@ -794,36 +728,36 @@ static inline void sx_transmit(struct specialix_board * bp)
                sx_out(bp, CD186x_IER, port->IER);
        }
        if (port->xmit_cnt <= port->wakeup_chars)
-               tty_wakeup(tty);
+               tty_wakeup(tty);
 
        func_exit();
 }
 
 
-static inline void sx_check_modem(struct specialix_board * bp)
+static void sx_check_modem(struct specialix_board *bp)
 {
        struct specialix_port *port;
        struct tty_struct *tty;
        unsigned char mcr;
        int msvr_cd;
 
-       dprintk (SX_DEBUG_SIGNALS, "Modem intr. ");
-       if (!(port = sx_get_port(bp, "Modem")))
+       dprintk(SX_DEBUG_SIGNALS, "Modem intr. ");
+       port = sx_get_port(bp, "Modem");
+       if (port == NULL)
                return;
 
        tty = port->port.tty;
 
        mcr = sx_in(bp, CD186x_MCR);
-       printk ("mcr = %02x.\n", mcr);
 
        if ((mcr & MCR_CDCHG)) {
-               dprintk (SX_DEBUG_SIGNALS, "CD just changed... ");
+               dprintk(SX_DEBUG_SIGNALS, "CD just changed... ");
                msvr_cd = sx_in(bp, CD186x_MSVR) & MSVR_CD;
                if (msvr_cd) {
-                       dprintk (SX_DEBUG_SIGNALS, "Waking up guys in open.\n");
+                       dprintk(SX_DEBUG_SIGNALS, "Waking up guys in open.\n");
                        wake_up_interruptible(&port->port.open_wait);
                } else {
-                       dprintk (SX_DEBUG_SIGNALS, "Sending HUP.\n");
+                       dprintk(SX_DEBUG_SIGNALS, "Sending HUP.\n");
                        tty_hangup(tty);
                }
        }
@@ -874,9 +808,12 @@ static irqreturn_t sx_interrupt(int dummy, void *dev_id)
 
        spin_lock_irqsave(&bp->lock, flags);
 
-       dprintk (SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __func__, port_No(sx_get_port(bp, "INT")), SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1);
+       dprintk(SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __func__,
+               port_No(sx_get_port(bp, "INT")),
+               SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1);
        if (!(bp->flags & SX_BOARD_ACTIVE)) {
-               dprintk (SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n", bp->irq);
+               dprintk(SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n",
+                                                               bp->irq);
                spin_unlock_irqrestore(&bp->lock, flags);
                func_exit();
                return IRQ_NONE;
@@ -884,10 +821,11 @@ static irqreturn_t sx_interrupt(int dummy, void *dev_id)
 
        saved_reg = bp->reg;
 
-       while ((++loop < 16) && (status = (sx_in(bp, CD186x_SRSR) &
-                                          (SRSR_RREQint |
-                                           SRSR_TREQint |
-                                           SRSR_MREQint)))) {
+       while (++loop < 16) {
+               status = sx_in(bp, CD186x_SRSR) &
+                               (SRSR_RREQint | SRSR_TREQint | SRSR_MREQint);
+               if (status == 0)
+                       break;
                if (status & SRSR_RREQint) {
                        ack = sx_in(bp, CD186x_RRAR);
 
@@ -896,8 +834,9 @@ static irqreturn_t sx_interrupt(int dummy, void *dev_id)
                        else if (ack == (SX_ID | GIVR_IT_REXC))
                                sx_receive_exc(bp);
                        else
-                               printk(KERN_ERR "sx%d: status: 0x%x Bad receive ack 0x%02x.\n",
-                                      board_No(bp), status, ack);
+                               printk(KERN_ERR
+                               "sx%d: status: 0x%x Bad receive ack 0x%02x.\n",
+                                               board_No(bp), status, ack);
 
                } else if (status & SRSR_TREQint) {
                        ack = sx_in(bp, CD186x_TRAR);
@@ -906,14 +845,16 @@ static irqreturn_t sx_interrupt(int dummy, void *dev_id)
                                sx_transmit(bp);
                        else
                                printk(KERN_ERR "sx%d: status: 0x%x Bad transmit ack 0x%02x. port: %d\n",
-                                      board_No(bp), status, ack, port_No (sx_get_port (bp, "Int")));
+                                       board_No(bp), status, ack,
+                                       port_No(sx_get_port(bp, "Int")));
                } else if (status & SRSR_MREQint) {
                        ack = sx_in(bp, CD186x_MRAR);
 
                        if (ack == (SX_ID | GIVR_IT_MODEM))
                                sx_check_modem(bp);
                        else
-                               printk(KERN_ERR "sx%d: status: 0x%x Bad modem ack 0x%02x.\n",
+                               printk(KERN_ERR
+                                 "sx%d: status: 0x%x Bad modem ack 0x%02x.\n",
                                       board_No(bp), status, ack);
 
                }
@@ -921,7 +862,7 @@ static irqreturn_t sx_interrupt(int dummy, void *dev_id)
                sx_out(bp, CD186x_EOIR, 0);   /* Mark end of interrupt */
        }
        bp->reg = saved_reg;
-       outb (bp->reg, bp->base + SX_ADDR_REG);
+       outb(bp->reg, bp->base + SX_ADDR_REG);
        spin_unlock_irqrestore(&bp->lock, flags);
        func_exit();
        return IRQ_HANDLED;
@@ -932,36 +873,26 @@ static irqreturn_t sx_interrupt(int dummy, void *dev_id)
  *  Routines for open & close processing.
  */
 
-static void turn_ints_off (struct specialix_board *bp)
+static void turn_ints_off(struct specialix_board *bp)
 {
        unsigned long flags;
 
        func_enter();
-       if (bp->flags & SX_BOARD_IS_PCI) {
-               /* This was intended for enabeling the interrupt on the
-                * PCI card. However it seems that it's already enabled
-                * and as PCI interrupts can be shared, there is no real
-                * reason to have to turn it off. */
-       }
-
        spin_lock_irqsave(&bp->lock, flags);
-       (void) sx_in_off (bp, 0); /* Turn off interrupts. */
+       (void) sx_in_off(bp, 0); /* Turn off interrupts. */
        spin_unlock_irqrestore(&bp->lock, flags);
 
        func_exit();
 }
 
-static void turn_ints_on (struct specialix_board *bp)
+static void turn_ints_on(struct specialix_board *bp)
 {
        unsigned long flags;
 
        func_enter();
 
-       if (bp->flags & SX_BOARD_IS_PCI) {
-               /* play with the PCI chip. See comment above. */
-       }
        spin_lock_irqsave(&bp->lock, flags);
-       (void) sx_in (bp, 0); /* Turn ON interrupts. */
+       (void) sx_in(bp, 0); /* Turn ON interrupts. */
        spin_unlock_irqrestore(&bp->lock, flags);
 
        func_exit();
@@ -969,7 +900,7 @@ static void turn_ints_on (struct specialix_board *bp)
 
 
 /* Called with disabled interrupts */
-static inline int sx_setup_board(struct specialix_board * bp)
+static int sx_setup_board(struct specialix_board *bp)
 {
        int error;
 
@@ -977,14 +908,16 @@ static inline int sx_setup_board(struct specialix_board * bp)
                return 0;
 
        if (bp->flags & SX_BOARD_IS_PCI)
-               error = request_irq(bp->irq, sx_interrupt, IRQF_DISABLED | IRQF_SHARED, "specialix IO8+", bp);
+               error = request_irq(bp->irq, sx_interrupt,
+                       IRQF_DISABLED | IRQF_SHARED, "specialix IO8+", bp);
        else
-               error = request_irq(bp->irq, sx_interrupt, IRQF_DISABLED, "specialix IO8+", bp);
+               error = request_irq(bp->irq, sx_interrupt,
+                       IRQF_DISABLED, "specialix IO8+", bp);
 
        if (error)
                return error;
 
-       turn_ints_on (bp);
+       turn_ints_on(bp);
        bp->flags |= SX_BOARD_ACTIVE;
 
        return 0;
@@ -992,7 +925,7 @@ static inline int sx_setup_board(struct specialix_board * bp)
 
 
 /* Called with disabled interrupts */
-static inline void sx_shutdown_board(struct specialix_board *bp)
+static void sx_shutdown_board(struct specialix_board *bp)
 {
        func_enter();
 
@@ -1003,22 +936,26 @@ static inline void sx_shutdown_board(struct specialix_board *bp)
 
        bp->flags &= ~SX_BOARD_ACTIVE;
 
-       dprintk (SX_DEBUG_IRQ, "Freeing IRQ%d for board %d.\n",
-                bp->irq, board_No (bp));
+       dprintk(SX_DEBUG_IRQ, "Freeing IRQ%d for board %d.\n",
+                bp->irq, board_No(bp));
        free_irq(bp->irq, bp);
-
-       turn_ints_off (bp);
-
-
+       turn_ints_off(bp);
        func_exit();
 }
 
+static unsigned int sx_crtscts(struct tty_struct *tty)
+{
+       if (sx_rtscts)
+               return C_CRTSCTS(tty);
+       return 1;
+}
 
 /*
  * Setting up port characteristics.
  * Must be called with disabled interrupts
  */
-static void sx_change_speed(struct specialix_board *bp, struct specialix_port *port)
+static void sx_change_speed(struct specialix_board *bp,
+                                               struct specialix_port *port)
 {
        struct tty_struct *tty;
        unsigned long baud;
@@ -1030,7 +967,8 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
 
        func_enter();
 
-       if (!(tty = port->port.tty) || !tty->termios) {
+       tty = port->port.tty;
+       if (!tty || !tty->termios) {
                func_exit();
                return;
        }
@@ -1043,12 +981,12 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
 
        /* The Specialix board doens't implement the RTS lines.
           They are used to set the IRQ level. Don't touch them. */
-       if (SX_CRTSCTS(tty))
+       if (sx_crtscts(tty))
                port->MSVR = MSVR_DTR | (sx_in(bp, CD186x_MSVR) & MSVR_RTS);
        else
                port->MSVR =  (sx_in(bp, CD186x_MSVR) & MSVR_RTS);
        spin_unlock_irqrestore(&bp->lock, flags);
-       dprintk (SX_DEBUG_TERMIOS, "sx: got MSVR=%02x.\n", port->MSVR);
+       dprintk(SX_DEBUG_TERMIOS, "sx: got MSVR=%02x.\n", port->MSVR);
        baud = tty_get_baud_rate(tty);
 
        if (baud == 38400) {
@@ -1060,21 +998,19 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
 
        if (!baud) {
                /* Drop DTR & exit */
-               dprintk (SX_DEBUG_TERMIOS, "Dropping DTR...  Hmm....\n");
-               if (!SX_CRTSCTS (tty)) {
-                       port -> MSVR &= ~ MSVR_DTR;
+               dprintk(SX_DEBUG_TERMIOS, "Dropping DTR...  Hmm....\n");
+               if (!sx_crtscts(tty)) {
+                       port->MSVR &= ~MSVR_DTR;
                        spin_lock_irqsave(&bp->lock, flags);
-                       sx_out(bp, CD186x_MSVR, port->MSVR );
+                       sx_out(bp, CD186x_MSVR, port->MSVR);
                        spin_unlock_irqrestore(&bp->lock, flags);
-               }
-               else
-                       dprintk (SX_DEBUG_TERMIOS, "Can't drop DTR: no DTR.\n");
+               } else
+                       dprintk(SX_DEBUG_TERMIOS, "Can't drop DTR: no DTR.\n");
                return;
        } else {
                /* Set DTR on */
-               if (!SX_CRTSCTS (tty)) {
-                       port ->MSVR |= MSVR_DTR;
-               }
+               if (!sx_crtscts(tty))
+                       port->MSVR |= MSVR_DTR;
        }
 
        /*
@@ -1083,28 +1019,27 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
 
        /* Set baud rate for port */
        tmp = port->custom_divisor ;
-       if ( tmp )
-               printk (KERN_INFO "sx%d: Using custom baud rate divisor %ld. \n"
-                                 "This is an untested option, please be carefull.\n",
-                                 port_No (port), tmp);
+       if (tmp)
+               printk(KERN_INFO
+                       "sx%d: Using custom baud rate divisor %ld. \n"
+                       "This is an untested option, please be careful.\n",
+                                                       port_No(port), tmp);
        else
-               tmp = (((SX_OSCFREQ + baud/2) / baud +
-                        CD186x_TPC/2) / CD186x_TPC);
+               tmp = (((SX_OSCFREQ + baud/2) / baud + CD186x_TPC/2) /
+                                                               CD186x_TPC);
 
-       if ((tmp < 0x10) && time_before(again, jiffies)) {
+       if (tmp < 0x10 && time_before(again, jiffies)) {
                again = jiffies + HZ * 60;
                /* Page 48 of version 2.0 of the CL-CD1865 databook */
                if (tmp >= 12) {
-                       printk (KERN_INFO "sx%d: Baud rate divisor is %ld. \n"
-                               "Performance degradation is possible.\n"
-                               "Read specialix.txt for more info.\n",
-                               port_No (port), tmp);
+                       printk(KERN_INFO "sx%d: Baud rate divisor is %ld. \n"
+                               "Performance degradation is possible.\n"
+                               "Read specialix.txt for more info.\n",
+                                               port_No(port), tmp);
                } else {
-                       printk (KERN_INFO "sx%d: Baud rate divisor is %ld. \n"
-                               "Warning: overstressing Cirrus chip. "
-                               "This might not work.\n"
-                               "Read specialix.txt for more info.\n",
-                               port_No (port), tmp);
+                       printk(KERN_INFO "sx%d: Baud rate divisor is %ld. \n"
+               "Warning: overstressing Cirrus chip. This might not work.\n"
+               "Read specialix.txt for more info.\n", port_No(port), tmp);
                }
        }
        spin_lock_irqsave(&bp->lock, flags);
@@ -1114,7 +1049,8 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
        sx_out(bp, CD186x_TBPRL, tmp & 0xff);
        spin_unlock_irqrestore(&bp->lock, flags);
        if (port->custom_divisor)
-               baud = (SX_OSCFREQ + port->custom_divisor/2) / port->custom_divisor;
+               baud = (SX_OSCFREQ + port->custom_divisor/2) /
+                                                       port->custom_divisor;
        baud = (baud + 5) / 10;         /* Estimated CPS */
 
        /* Two timer ticks seems enough to wakeup something like SLIP driver */
@@ -1129,16 +1065,16 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
        sx_out(bp, CD186x_RTPR, tmp);
        spin_unlock_irqrestore(&bp->lock, flags);
        switch (C_CSIZE(tty)) {
-        case CS5:
+       case CS5:
                cor1 |= COR1_5BITS;
                break;
-        case CS6:
+       case CS6:
                cor1 |= COR1_6BITS;
                break;
-        case CS7:
+       case CS7:
                cor1 |= COR1_7BITS;
                break;
-        case CS8:
+       case CS8:
                cor1 |= COR1_8BITS;
                break;
        }
@@ -1175,7 +1111,8 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
                mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
                mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
                spin_lock_irqsave(&bp->lock, flags);
-               tty->hw_stopped = !(sx_in(bp, CD186x_MSVR) & (MSVR_CTS|MSVR_DSR));
+               tty->hw_stopped = !(sx_in(bp, CD186x_MSVR) &
+                                                       (MSVR_CTS|MSVR_DSR));
                spin_unlock_irqrestore(&bp->lock, flags);
 #else
                port->COR2 |= COR2_CTSAE;
@@ -1219,7 +1156,8 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
        spin_lock_irqsave(&bp->lock, flags);
        sx_out(bp, CD186x_CCR, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
        /* Setting up modem option registers */
-       dprintk (SX_DEBUG_TERMIOS, "Mcor1 = %02x, mcor2 = %02x.\n", mcor1, mcor2);
+       dprintk(SX_DEBUG_TERMIOS, "Mcor1 = %02x, mcor2 = %02x.\n",
+                                                               mcor1, mcor2);
        sx_out(bp, CD186x_MCOR1, mcor1);
        sx_out(bp, CD186x_MCOR2, mcor2);
        spin_unlock_irqrestore(&bp->lock, flags);
@@ -1238,7 +1176,8 @@ static void sx_change_speed(struct specialix_board *bp, struct specialix_port *p
 
 
 /* Must be called with interrupts enabled */
-static int sx_setup_port(struct specialix_board *bp, struct specialix_port *port)
+static int sx_setup_port(struct specialix_board *bp,
+                                               struct specialix_port *port)
 {
        unsigned long flags;
 
@@ -1253,7 +1192,8 @@ static int sx_setup_port(struct specialix_board *bp, struct specialix_port *port
                /* We may sleep in get_zeroed_page() */
                unsigned long tmp;
 
-               if (!(tmp = get_zeroed_page(GFP_KERNEL))) {
+               tmp = get_zeroed_page(GFP_KERNEL);
+               if (tmp == 0L) {
                        func_exit();
                        return -ENOMEM;
                }
@@ -1284,7 +1224,8 @@ static int sx_setup_port(struct specialix_board *bp, struct specialix_port *port
 
 
 /* Must be called with interrupts disabled */
-static void sx_shutdown_port(struct specialix_board *bp, struct specialix_port *port)
+static void sx_shutdown_port(struct specialix_board *bp,
+                                               struct specialix_port *port)
 {
        struct tty_struct *tty;
        int i;
@@ -1298,11 +1239,11 @@ static void sx_shutdown_port(struct specialix_board *bp, struct specialix_port *
        }
 
        if (sx_debug & SX_DEBUG_FIFO) {
-               dprintk(SX_DEBUG_FIFO, "sx%d: port %d: %ld overruns, FIFO hits [ ",
-                       board_No(bp), port_No(port), port->overrun);
-               for (i = 0; i < 10; i++) {
+               dprintk(SX_DEBUG_FIFO,
+                       "sx%d: port %d: %ld overruns, FIFO hits [ ",
+                               board_No(bp), port_No(port), port->overrun);
+               for (i = 0; i < 10; i++)
                        dprintk(SX_DEBUG_FIFO, "%ld ", port->hits[i]);
-               }
                dprintk(SX_DEBUG_FIFO, "].\n");
        }
 
@@ -1315,7 +1256,8 @@ static void sx_shutdown_port(struct specialix_board *bp, struct specialix_port *
        spin_lock_irqsave(&bp->lock, flags);
        sx_out(bp, CD186x_CAR, port_No(port));
 
-       if (!(tty = port->port.tty) || C_HUPCL(tty)) {
+       tty = port->port.tty;
+       if (tty == NULL || C_HUPCL(tty)) {
                /* Drop DTR */
                sx_out(bp, CD186x_MSVDTR, 0);
        }
@@ -1338,8 +1280,8 @@ static void sx_shutdown_port(struct specialix_board *bp, struct specialix_port *
 }
 
 
-static int block_til_ready(struct tty_struct *tty, struct file * filp,
-                           struct specialix_port *port)
+static int block_til_ready(struct tty_struct *tty, struct file *filp,
+                                               struct specialix_port *port)
 {
        DECLARE_WAITQUEUE(wait,  current);
        struct specialix_board *bp = port_Board(port);
@@ -1389,23 +1331,22 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
        retval = 0;
        add_wait_queue(&port->port.open_wait, &wait);
        spin_lock_irqsave(&port->lock, flags);
-       if (!tty_hung_up_p(filp)) {
+       if (!tty_hung_up_p(filp))
                port->port.count--;
-       }
        spin_unlock_irqrestore(&port->lock, flags);
        port->port.blocked_open++;
        while (1) {
                spin_lock_irqsave(&bp->lock, flags);
                sx_out(bp, CD186x_CAR, port_No(port));
                CD = sx_in(bp, CD186x_MSVR) & MSVR_CD;
-               if (SX_CRTSCTS (tty)) {
+               if (sx_crtscts(tty)) {
                        /* Activate RTS */
                        port->MSVR |= MSVR_DTR;         /* WTF? */
-                       sx_out (bp, CD186x_MSVR, port->MSVR);
+                       sx_out(bp, CD186x_MSVR, port->MSVR);
                } else {
                        /* Activate DTR */
                        port->MSVR |= MSVR_DTR;
-                       sx_out (bp, CD186x_MSVR, port->MSVR);
+                       sx_out(bp, CD186x_MSVR, port->MSVR);
                }
                spin_unlock_irqrestore(&bp->lock, flags);
                set_current_state(TASK_INTERRUPTIBLE);
@@ -1430,9 +1371,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
        set_current_state(TASK_RUNNING);
        remove_wait_queue(&port->port.open_wait, &wait);
        spin_lock_irqsave(&port->lock, flags);
-       if (!tty_hung_up_p(filp)) {
+       if (!tty_hung_up_p(filp))
                port->port.count++;
-       }
        port->port.blocked_open--;
        spin_unlock_irqrestore(&port->lock, flags);
        if (retval) {
@@ -1446,12 +1386,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
 }
 
 
-static int sx_open(struct tty_struct * tty, struct file * filp)
+static int sx_open(struct tty_struct *tty, struct file *filp)
 {
        int board;
        int error;
-       struct specialix_port * port;
-       struct specialix_board * bp;
+       struct specialix_port *port;
+       struct specialix_board *bp;
        int i;
        unsigned long flags;
 
@@ -1468,17 +1408,19 @@ static int sx_open(struct tty_struct * tty, struct file * filp)
        port = sx_port + board * SX_NPORT + SX_PORT(tty->index);
        port->overrun = 0;
        for (i = 0; i < 10; i++)
-               port->hits[i]=0;
+               port->hits[i] = 0;
 
-       dprintk (SX_DEBUG_OPEN, "Board = %d, bp = %p, port = %p, portno = %d.\n",
-               board, bp, port, SX_PORT(tty->index));
+       dprintk(SX_DEBUG_OPEN,
+                       "Board = %d, bp = %p, port = %p, portno = %d.\n",
+                                board, bp, port, SX_PORT(tty->index));
 
        if (sx_paranoia_check(port, tty->name, "sx_open")) {
                func_enter();
                return -ENODEV;
        }
 
-       if ((error = sx_setup_board(bp))) {
+       error = sx_setup_board(bp);
+       if (error) {
                func_exit();
                return error;
        }
@@ -1490,12 +1432,14 @@ static int sx_open(struct tty_struct * tty, struct file * filp)
        port->port.tty = tty;
        spin_unlock_irqrestore(&bp->lock, flags);
 
-       if ((error = sx_setup_port(bp, port))) {
+       error = sx_setup_port(bp, port);
+       if (error) {
                func_enter();
                return error;
        }
 
-       if ((error = block_til_ready(tty, filp, port))) {
+       error = block_til_ready(tty, filp, port);
+       if (error) {
                func_enter();
                return error;
        }
@@ -1508,7 +1452,7 @@ static void sx_flush_buffer(struct tty_struct *tty)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        unsigned long flags;
-       struct specialix_board  * bp;
+       struct specialix_board  *bp;
 
        func_enter();
 
@@ -1526,9 +1470,9 @@ static void sx_flush_buffer(struct tty_struct *tty)
        func_exit();
 }
 
-static void sx_close(struct tty_struct * tty, struct file * filp)
+static void sx_close(struct tty_struct *tty, struct file *filp)
 {
-       struct specialix_port *port = (struct specialix_port *) tty->driver_data;
+       struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        struct specialix_board *bp;
        unsigned long flags;
        unsigned long timeout;
@@ -1547,7 +1491,7 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
        }
 
        bp = port_Board(port);
-       if ((tty->count == 1) && (port->port.count != 1)) {
+       if (tty->count == 1 && port->port.count != 1) {
                printk(KERN_ERR "sx%d: sx_close: bad port count;"
                       " tty->count is 1, port count is %d\n",
                       board_No(bp), port->port.count);
@@ -1570,17 +1514,16 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
         */
        tty->closing = 1;
        spin_unlock_irqrestore(&port->lock, flags);
-       dprintk (SX_DEBUG_OPEN, "Closing\n");
-       if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
+       dprintk(SX_DEBUG_OPEN, "Closing\n");
+       if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
                tty_wait_until_sent(tty, port->port.closing_wait);
-       }
        /*
         * At this point we stop accepting input.  To do this, we
         * disable the receive line status interrupts, and tell the
         * interrupt driver to stop checking the data ready bit in the
         * line status register.
         */
-       dprintk (SX_DEBUG_OPEN, "Closed\n");
+       dprintk(SX_DEBUG_OPEN, "Closed\n");
        port->IER &= ~IER_RXD;
        if (port->port.flags & ASYNC_INITIALIZED) {
                port->IER &= ~IER_TXRDY;
@@ -1595,11 +1538,11 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
                 * important if there is a transmit FIFO!
                 */
                timeout = jiffies+HZ;
-               while(port->IER & IER_TXEMPTY) {
-                       set_current_state (TASK_INTERRUPTIBLE);
+               while (port->IER & IER_TXEMPTY) {
+                       set_current_state(TASK_INTERRUPTIBLE);
                        msleep_interruptible(jiffies_to_msecs(port->timeout));
                        if (time_after(jiffies, timeout)) {
-                               printk (KERN_INFO "Timeout waiting for close\n");
+                               printk(KERN_INFO "Timeout waiting for close\n");
                                break;
                        }
                }
@@ -1607,13 +1550,15 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
        }
 
        if (--bp->count < 0) {
-               printk(KERN_ERR "sx%d: sx_shutdown_port: bad board count: %d port: %d\n",
-                      board_No(bp), bp->count, tty->index);
+               printk(KERN_ERR
+                   "sx%d: sx_shutdown_port: bad board count: %d port: %d\n",
+                               board_No(bp), bp->count, tty->index);
                bp->count = 0;
        }
        if (--port->port.count < 0) {
-               printk(KERN_ERR "sx%d: sx_close: bad port count for tty%d: %d\n",
-                      board_No(bp), port_No(port), port->port.count);
+               printk(KERN_ERR
+                       "sx%d: sx_close: bad port count for tty%d: %d\n",
+                               board_No(bp), port_No(port), port->port.count);
                port->port.count = 0;
        }
 
@@ -1625,9 +1570,9 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
        port->port.tty = NULL;
        spin_unlock_irqrestore(&port->lock, flags);
        if (port->port.blocked_open) {
-               if (port->port.close_delay) {
-                       msleep_interruptible(jiffies_to_msecs(port->port.close_delay));
-               }
+               if (port->port.close_delay)
+                       msleep_interruptible(
+                               jiffies_to_msecs(port->port.close_delay));
                wake_up_interruptible(&port->port.open_wait);
        }
        port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
@@ -1637,8 +1582,8 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
 }
 
 
-static int sx_write(struct tty_struct * tty,
-                    const unsigned char *buf, int count)
+static int sx_write(struct tty_struct *tty,
+                                       const unsigned char *buf, int count)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        struct specialix_board *bp;
@@ -1690,11 +1635,11 @@ static int sx_write(struct tty_struct * tty,
 }
 
 
-static int sx_put_char(struct tty_struct * tty, unsigned char ch)
+static int sx_put_char(struct tty_struct *tty, unsigned char ch)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        unsigned long flags;
-       struct specialix_board  * bp;
+       struct specialix_board  *bp;
 
        func_enter();
 
@@ -1702,7 +1647,7 @@ static int sx_put_char(struct tty_struct * tty, unsigned char ch)
                func_exit();
                return 0;
        }
-       dprintk (SX_DEBUG_TX, "check tty: %p %p\n", tty, port->xmit_buf);
+       dprintk(SX_DEBUG_TX, "check tty: %p %p\n", tty, port->xmit_buf);
        if (!port->xmit_buf) {
                func_exit();
                return 0;
@@ -1710,14 +1655,15 @@ static int sx_put_char(struct tty_struct * tty, unsigned char ch)
        bp = port_Board(port);
        spin_lock_irqsave(&port->lock, flags);
 
-       dprintk (SX_DEBUG_TX, "xmit_cnt: %d xmit_buf: %p\n", port->xmit_cnt, port->xmit_buf);
-       if ((port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) || (!port->xmit_buf)) {
+       dprintk(SX_DEBUG_TX, "xmit_cnt: %d xmit_buf: %p\n",
+                                       port->xmit_cnt, port->xmit_buf);
+       if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1 || !port->xmit_buf) {
                spin_unlock_irqrestore(&port->lock, flags);
-               dprintk (SX_DEBUG_TX, "Exit size\n");
+               dprintk(SX_DEBUG_TX, "Exit size\n");
                func_exit();
                return 0;
        }
-       dprintk (SX_DEBUG_TX, "Handle xmit: %p %p\n", port, port->xmit_buf);
+       dprintk(SX_DEBUG_TX, "Handle xmit: %p %p\n", port, port->xmit_buf);
        port->xmit_buf[port->xmit_head++] = ch;
        port->xmit_head &= SERIAL_XMIT_SIZE - 1;
        port->xmit_cnt++;
@@ -1728,11 +1674,11 @@ static int sx_put_char(struct tty_struct * tty, unsigned char ch)
 }
 
 
-static void sx_flush_chars(struct tty_struct * tty)
+static void sx_flush_chars(struct tty_struct *tty)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        unsigned long flags;
-       struct specialix_board  * bp = port_Board(port);
+       struct specialix_board  *bp = port_Board(port);
 
        func_enter();
 
@@ -1755,7 +1701,7 @@ static void sx_flush_chars(struct tty_struct * tty)
 }
 
 
-static int sx_write_room(struct tty_struct * tty)
+static int sx_write_room(struct tty_struct *tty)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        int     ret;
@@ -1790,12 +1736,10 @@ static int sx_chars_in_buffer(struct tty_struct *tty)
        return port->xmit_cnt;
 }
 
-
-
 static int sx_tiocmget(struct tty_struct *tty, struct file *file)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
-       struct specialix_board * bp;
+       struct specialix_board *bp;
        unsigned char status;
        unsigned int result;
        unsigned long flags;
@@ -1808,25 +1752,23 @@ static int sx_tiocmget(struct tty_struct *tty, struct file *file)
        }
 
        bp = port_Board(port);
-       spin_lock_irqsave (&bp->lock, flags);
+       spin_lock_irqsave(&bp->lock, flags);
        sx_out(bp, CD186x_CAR, port_No(port));
        status = sx_in(bp, CD186x_MSVR);
        spin_unlock_irqrestore(&bp->lock, flags);
-       dprintk (SX_DEBUG_INIT, "Got msvr[%d] = %02x, car = %d.\n",
-               port_No(port), status, sx_in (bp, CD186x_CAR));
-       dprintk (SX_DEBUG_INIT, "sx_port = %p, port = %p\n", sx_port, port);
-       if (SX_CRTSCTS(port->port.tty)) {
-               result  = /*   (status & MSVR_RTS) ? */ TIOCM_DTR /* : 0) */
-                         |   ((status & MSVR_DTR) ? TIOCM_RTS : 0)
-                         |   ((status & MSVR_CD)  ? TIOCM_CAR : 0)
-                         |/* ((status & MSVR_DSR) ? */ TIOCM_DSR /* : 0) */
-                         |   ((status & MSVR_CTS) ? TIOCM_CTS : 0);
+       dprintk(SX_DEBUG_INIT, "Got msvr[%d] = %02x, car = %d.\n",
+                       port_No(port), status, sx_in(bp, CD186x_CAR));
+       dprintk(SX_DEBUG_INIT, "sx_port = %p, port = %p\n", sx_port, port);
+       if (sx_crtscts(port->port.tty)) {
+               result  = TIOCM_DTR | TIOCM_DSR
+                         |   ((status & MSVR_DTR) ? TIOCM_RTS : 0)
+                         |   ((status & MSVR_CD)  ? TIOCM_CAR : 0)
+                         |   ((status & MSVR_CTS) ? TIOCM_CTS : 0);
        } else {
-               result  = /*   (status & MSVR_RTS) ? */ TIOCM_RTS /* : 0) */
-                         |   ((status & MSVR_DTR) ? TIOCM_DTR : 0)
-                         |   ((status & MSVR_CD)  ? TIOCM_CAR : 0)
-                         |/* ((status & MSVR_DSR) ? */ TIOCM_DSR /* : 0) */
-                         |   ((status & MSVR_CTS) ? TIOCM_CTS : 0);
+               result  = TIOCM_RTS | TIOCM_DSR
+                         |   ((status & MSVR_DTR) ? TIOCM_DTR : 0)
+                         |   ((status & MSVR_CD)  ? TIOCM_CAR : 0)
+                         |   ((status & MSVR_CTS) ? TIOCM_CTS : 0);
        }
 
        func_exit();
@@ -1852,24 +1794,14 @@ static int sx_tiocmset(struct tty_struct *tty, struct file *file,
        bp = port_Board(port);
 
        spin_lock_irqsave(&port->lock, flags);
-   /*  if (set & TIOCM_RTS)
-               port->MSVR |= MSVR_RTS; */
-   /*   if (set & TIOCM_DTR)
-               port->MSVR |= MSVR_DTR; */
-
-       if (SX_CRTSCTS(port->port.tty)) {
+       if (sx_crtscts(port->port.tty)) {
                if (set & TIOCM_RTS)
                        port->MSVR |= MSVR_DTR;
        } else {
                if (set & TIOCM_DTR)
                        port->MSVR |= MSVR_DTR;
        }
-
-  /*   if (clear & TIOCM_RTS)
-               port->MSVR &= ~MSVR_RTS; */
-  /*    if (clear & TIOCM_DTR)
-               port->MSVR &= ~MSVR_DTR; */
-       if (SX_CRTSCTS(port->port.tty)) {
+       if (sx_crtscts(port->port.tty)) {
                if (clear & TIOCM_RTS)
                        port->MSVR &= ~MSVR_DTR;
        } else {
@@ -1886,14 +1818,17 @@ static int sx_tiocmset(struct tty_struct *tty, struct file *file,
 }
 
 
-static inline void sx_send_break(struct specialix_port * port, unsigned long length)
+static int sx_send_break(struct tty_struct *tty, int length)
 {
+       struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        struct specialix_board *bp = port_Board(port);
        unsigned long flags;
 
        func_enter();
+       if (length == 0 || length == -1)
+               return -EOPNOTSUPP;
 
-       spin_lock_irqsave (&port->lock, flags);
+       spin_lock_irqsave(&port->lock, flags);
        port->break_length = SPECIALIX_TPS / HZ * length;
        port->COR2 |= COR2_ETC;
        port->IER  |= IER_TXRDY;
@@ -1902,7 +1837,7 @@ static inline void sx_send_break(struct specialix_port * port, unsigned long len
        sx_out(bp, CD186x_COR2, port->COR2);
        sx_out(bp, CD186x_IER, port->IER);
        spin_unlock_irqrestore(&bp->lock, flags);
-       spin_unlock_irqrestore (&port->lock, flags);
+       spin_unlock_irqrestore(&port->lock, flags);
        sx_wait_CCR(bp);
        spin_lock_irqsave(&bp->lock, flags);
        sx_out(bp, CD186x_CCR, CCR_CORCHG2);
@@ -1910,11 +1845,12 @@ static inline void sx_send_break(struct specialix_port * port, unsigned long len
        sx_wait_CCR(bp);
 
        func_exit();
+       return 0;
 }
 
 
-static inline int sx_set_serial_info(struct specialix_port * port,
-                                     struct serial_struct __user * newinfo)
+static int sx_set_serial_info(struct specialix_port *port,
+                                       struct serial_struct __user *newinfo)
 {
        struct serial_struct tmp;
        struct specialix_board *bp = port_Board(port);
@@ -1943,25 +1879,25 @@ static inline int sx_set_serial_info(struct specialix_port * port,
                        return -EPERM;
                }
                port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
-                                 (tmp.flags & ASYNC_USR_MASK));
+                                               (tmp.flags & ASYNC_USR_MASK));
                port->custom_divisor = tmp.custom_divisor;
        } else {
                port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
-                                 (tmp.flags & ASYNC_FLAGS));
+                                               (tmp.flags & ASYNC_FLAGS));
                port->port.close_delay = tmp.close_delay;
                port->port.closing_wait = tmp.closing_wait;
                port->custom_divisor = tmp.custom_divisor;
        }
-       if (change_speed) {
+       if (change_speed)
                sx_change_speed(bp, port);
-       }
+
        func_exit();
        unlock_kernel();
        return 0;
 }
 
 
-static inline int sx_get_serial_info(struct specialix_port * port,
+static int sx_get_serial_info(struct specialix_port *port,
                                     struct serial_struct __user *retinfo)
 {
        struct serial_struct tmp;
@@ -1992,11 +1928,10 @@ static inline int sx_get_serial_info(struct specialix_port * port,
 }
 
 
-static int sx_ioctl(struct tty_struct * tty, struct file * filp,
-                    unsigned int cmd, unsigned long arg)
+static int sx_ioctl(struct tty_struct *tty, struct file *filp,
+                               unsigned int cmd, unsigned long arg)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
-       int retval;
        void __user *argp = (void __user *)arg;
 
        func_enter();
@@ -2007,34 +1942,14 @@ static int sx_ioctl(struct tty_struct * tty, struct file * filp,
        }
 
        switch (cmd) {
-        case TCSBRK:   /* SVID version: non-zero arg --> no break */
-               retval = tty_check_change(tty);
-               if (retval) {
-                       func_exit();
-                       return retval;
-               }
-               tty_wait_until_sent(tty, 0);
-               if (!arg)
-                       sx_send_break(port, HZ/4);      /* 1/4 second */
-               return 0;
-        case TCSBRKP:  /* support for POSIX tcsendbreak() */
-               retval = tty_check_change(tty);
-               if (retval) {
-                       func_exit();
-                       return retval;
-               }
-               tty_wait_until_sent(tty, 0);
-               sx_send_break(port, arg ? arg*(HZ/10) : HZ/4);
+       case TIOCGSERIAL:
                func_exit();
-               return 0;
-        case TIOCGSERIAL:
-                func_exit();
                return sx_get_serial_info(port, argp);
-        case TIOCSSERIAL:
-                func_exit();
+       case TIOCSSERIAL:
+               func_exit();
                return sx_set_serial_info(port, argp);
-        default:
-                func_exit();
+       default:
+               func_exit();
                return -ENOIOCTLCMD;
        }
        func_exit();
@@ -2042,7 +1957,7 @@ static int sx_ioctl(struct tty_struct * tty, struct file * filp,
 }
 
 
-static void sx_throttle(struct tty_struct * tty)
+static void sx_throttle(struct tty_struct *tty)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        struct specialix_board *bp;
@@ -2058,15 +1973,16 @@ static void sx_throttle(struct tty_struct * tty)
        bp = port_Board(port);
 
        /* Use DTR instead of RTS ! */
-       if (SX_CRTSCTS (tty))
+       if (sx_crtscts(tty))
                port->MSVR &= ~MSVR_DTR;
        else {
                /* Auch!!! I think the system shouldn't call this then. */
                /* Or maybe we're supposed (allowed?) to do our side of hw
                   handshake anyway, even when hardware handshake is off.
                   When you see this in your logs, please report.... */
-               printk (KERN_ERR "sx%d: Need to throttle, but can't (hardware hs is off)\n",
-                        port_No (port));
+               printk(KERN_ERR
+                  "sx%d: Need to throttle, but can't (hardware hs is off)\n",
+                                                       port_No(port));
        }
        spin_lock_irqsave(&bp->lock, flags);
        sx_out(bp, CD186x_CAR, port_No(port));
@@ -2086,7 +2002,7 @@ static void sx_throttle(struct tty_struct * tty)
 }
 
 
-static void sx_unthrottle(struct tty_struct * tty)
+static void sx_unthrottle(struct tty_struct *tty)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        struct specialix_board *bp;
@@ -2103,9 +2019,9 @@ static void sx_unthrottle(struct tty_struct * tty)
 
        spin_lock_irqsave(&port->lock, flags);
        /* XXXX Use DTR INSTEAD???? */
-       if (SX_CRTSCTS(tty)) {
+       if (sx_crtscts(tty))
                port->MSVR |= MSVR_DTR;
-       /* Else clause: see remark in "sx_throttle"... */
+       /* Else clause: see remark in "sx_throttle"... */
        spin_lock_irqsave(&bp->lock, flags);
        sx_out(bp, CD186x_CAR, port_No(port));
        spin_unlock_irqrestore(&bp->lock, flags);
@@ -2127,7 +2043,7 @@ static void sx_unthrottle(struct tty_struct * tty)
 }
 
 
-static void sx_stop(struct tty_struct * tty)
+static void sx_stop(struct tty_struct *tty)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        struct specialix_board *bp;
@@ -2154,7 +2070,7 @@ static void sx_stop(struct tty_struct * tty)
 }
 
 
-static void sx_start(struct tty_struct * tty)
+static void sx_start(struct tty_struct *tty)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        struct specialix_board *bp;
@@ -2182,7 +2098,7 @@ static void sx_start(struct tty_struct * tty)
        func_exit();
 }
 
-static void sx_hangup(struct tty_struct * tty)
+static void sx_hangup(struct tty_struct *tty)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        struct specialix_board *bp;
@@ -2201,8 +2117,9 @@ static void sx_hangup(struct tty_struct * tty)
        spin_lock_irqsave(&port->lock, flags);
        bp->count -= port->port.count;
        if (bp->count < 0) {
-               printk(KERN_ERR "sx%d: sx_hangup: bad board count: %d port: %d\n",
-                       board_No(bp), bp->count, tty->index);
+               printk(KERN_ERR
+                       "sx%d: sx_hangup: bad board count: %d port: %d\n",
+                                       board_No(bp), bp->count, tty->index);
                bp->count = 0;
        }
        port->port.count = 0;
@@ -2215,11 +2132,12 @@ static void sx_hangup(struct tty_struct * tty)
 }
 
 
-static void sx_set_termios(struct tty_struct * tty, struct ktermios * old_termios)
+static void sx_set_termios(struct tty_struct *tty,
+                                       struct ktermios *old_termios)
 {
        struct specialix_port *port = (struct specialix_port *)tty->driver_data;
        unsigned long flags;
-       struct specialix_board  * bp;
+       struct specialix_board  *bp;
 
        if (sx_paranoia_check(port, tty->name, "sx_set_termios"))
                return;
@@ -2254,6 +2172,7 @@ static const struct tty_operations sx_ops = {
        .hangup = sx_hangup,
        .tiocmget = sx_tiocmget,
        .tiocmset = sx_tiocmset,
+       .break_ctl = sx_send_break,
 };
 
 static int sx_init_drivers(void)
@@ -2280,13 +2199,16 @@ static int sx_init_drivers(void)
                B9600 | CS8 | CREAD | HUPCL | CLOCAL;
        specialix_driver->init_termios.c_ispeed = 9600;
        specialix_driver->init_termios.c_ospeed = 9600;
-       specialix_driver->flags = TTY_DRIVER_REAL_RAW;
+       specialix_driver->flags = TTY_DRIVER_REAL_RAW |
+                                               TTY_DRIVER_HARDWARE_BREAK;
        tty_set_operations(specialix_driver, &sx_ops);
 
-       if ((error = tty_register_driver(specialix_driver))) {
+       error = tty_register_driver(specialix_driver);
+       if (error) {
                put_tty_driver(specialix_driver);
-               printk(KERN_ERR "sx: Couldn't register specialix IO8+ driver, error = %d\n",
-                      error);
+               printk(KERN_ERR
+                 "sx: Couldn't register specialix IO8+ driver, error = %d\n",
+                                                               error);
                func_exit();
                return 1;
        }
@@ -2322,11 +2244,11 @@ static int __init specialix_init(void)
 
        printk(KERN_INFO "sx: Specialix IO8+ driver v" VERSION ", (c) R.E.Wolff 1997/1998.\n");
        printk(KERN_INFO "sx: derived from work (c) D.Gorodchanin 1994-1996.\n");
-#ifdef CONFIG_SPECIALIX_RTSCTS
-       printk (KERN_INFO "sx: DTR/RTS pin is always RTS.\n");
-#else
-       printk (KERN_INFO "sx: DTR/RTS pin is RTS when CRTSCTS is on.\n");
-#endif
+       if (sx_rtscts)
+               printk(KERN_INFO
+                       "sx: DTR/RTS pin is RTS when CRTSCTS is on.\n");
+       else
+               printk(KERN_INFO "sx: DTR/RTS pin is always RTS.\n");
 
        for (i = 0; i < SX_NBOARD; i++)
                spin_lock_init(&sx_board[i].lock);
@@ -2344,27 +2266,27 @@ static int __init specialix_init(void)
        {
                struct pci_dev *pdev = NULL;
 
-               i=0;
+               i = 0;
                while (i < SX_NBOARD) {
                        if (sx_board[i].flags & SX_BOARD_PRESENT) {
                                i++;
                                continue;
                        }
-                       pdev = pci_get_device (PCI_VENDOR_ID_SPECIALIX,
-                                               PCI_DEVICE_ID_SPECIALIX_IO8,
-                                               pdev);
-                       if (!pdev) break;
+                       pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX,
+                                       PCI_DEVICE_ID_SPECIALIX_IO8, pdev);
+                       if (!pdev)
+                               break;
 
                        if (pci_enable_device(pdev))
                                continue;
 
                        sx_board[i].irq = pdev->irq;
 
-                       sx_board[i].base = pci_resource_start (pdev, 2);
+                       sx_board[i].base = pci_resource_start(pdev, 2);
 
                        sx_board[i].flags |= SX_BOARD_IS_PCI;
                        if (!sx_probe(&sx_board[i]))
-                               found ++;
+                               found++;
                }
                /* May exit pci_get sequence early with lots of boards */
                if (pdev != NULL)
@@ -2384,16 +2306,13 @@ static int __init specialix_init(void)
 }
 
 static int iobase[SX_NBOARD]  = {0,};
-
-static int irq [SX_NBOARD] = {0,};
+static int irq[SX_NBOARD] = {0,};
 
 module_param_array(iobase, int, NULL, 0);
 module_param_array(irq, int, NULL, 0);
 module_param(sx_debug, int, 0);
+module_param(sx_rtscts, int, 0);
 module_param(sx_rxfifo, int, 0);
-#ifdef SPECIALIX_TIMER
-module_param(sx_poll, int, 0);
-#endif
 
 /*
  * You can setup up to 4 boards.
@@ -2411,10 +2330,10 @@ static int __init specialix_init_module(void)
        func_enter();
 
        if (iobase[0] || iobase[1] || iobase[2] || iobase[3]) {
-               for(i = 0; i < SX_NBOARD; i++) {
+               for (i = 0; i < SX_NBOARD; i++) {
                        sx_board[i].base = iobase[i];
                        sx_board[i].irq = irq[i];
-                       sx_board[i].count= 0;
+                       sx_board[i].count = 0;
                }
        }
 
@@ -2433,10 +2352,6 @@ static void __exit specialix_exit_module(void)
        for (i = 0; i < SX_NBOARD; i++)
                if (sx_board[i].flags & SX_BOARD_PRESENT)
                        sx_release_io_range(&sx_board[i]);
-#ifdef SPECIALIX_TIMER
-       del_timer_sync(&missed_irq_timer);
-#endif
-
        func_exit();
 }
 
index 0243efb..b976248 100644 (file)
@@ -1025,7 +1025,7 @@ static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count
 
 /*****************************************************************************/
 
-static void stl_putchar(struct tty_struct *tty, unsigned char ch)
+static int stl_putchar(struct tty_struct *tty, unsigned char ch)
 {
        struct stlport  *portp;
        unsigned int    len;
@@ -1034,12 +1034,12 @@ static void stl_putchar(struct tty_struct *tty, unsigned char ch)
        pr_debug("stl_putchar(tty=%p,ch=%x)\n", tty, ch);
 
        if (tty == NULL)
-               return;
+               return -EINVAL;
        portp = tty->driver_data;
        if (portp == NULL)
-               return;
+               return -EINVAL;
        if (portp->tx.buf == NULL)
-               return;
+               return -EINVAL;
 
        head = portp->tx.head;
        tail = portp->tx.tail;
@@ -1053,6 +1053,7 @@ static void stl_putchar(struct tty_struct *tty, unsigned char ch)
                        head = portp->tx.buf;
        }       
        portp->tx.head = head;
+       return 0;
 }
 
 /*****************************************************************************/
@@ -1460,19 +1461,20 @@ static void stl_hangup(struct tty_struct *tty)
 
 /*****************************************************************************/
 
-static void stl_breakctl(struct tty_struct *tty, int state)
+static int stl_breakctl(struct tty_struct *tty, int state)
 {
        struct stlport  *portp;
 
        pr_debug("stl_breakctl(tty=%p,state=%d)\n", tty, state);
 
        if (tty == NULL)
-               return;
+               return -EINVAL;
        portp = tty->driver_data;
        if (portp == NULL)
-               return;
+               return -EINVAL;
 
        stl_sendbreak(portp, ((state == -1) ? 1 : 2));
+       return 0;
 }
 
 /*****************************************************************************/
@@ -4753,8 +4755,8 @@ static int __init stallion_module_init(void)
        if (IS_ERR(stallion_class))
                printk("STALLION: failed to create class\n");
        for (i = 0; i < 4; i++)
-               device_create(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
-                             "staliomem%d", i);
+               device_create_drvdata(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i),
+                                     NULL, "staliomem%d", i);
 
        return 0;
 err_unrtty:
index d5cffcd..2162439 100644 (file)
@@ -1840,7 +1840,7 @@ static int sx_fw_ioctl(struct inode *inode, struct file *filp,
        return rc;
 }
 
-static void sx_break(struct tty_struct *tty, int flag)
+static int sx_break(struct tty_struct *tty, int flag)
 {
        struct sx_port *port = tty->driver_data;
        int rv;
@@ -1857,6 +1857,7 @@ static void sx_break(struct tty_struct *tty, int flag)
                        read_sx_byte(port->board, CHAN_OFFSET(port, hi_hstat)));
        unlock_kernel();
        func_exit();
+       return 0;
 }
 
 static int sx_tiocmget(struct tty_struct *tty, struct file *file)
index 527d220..ef6706f 100644 (file)
@@ -2897,9 +2897,9 @@ static int tiocmset(struct tty_struct *tty, struct file *file,
  *
  * Arguments:          tty             pointer to tty instance data
  *                     break_state     -1=set break condition, 0=clear
- * Return Value:       None
+ * Return Value:       error code
  */
-static void mgsl_break(struct tty_struct *tty, int break_state)
+static int mgsl_break(struct tty_struct *tty, int break_state)
 {
        struct mgsl_struct * info = (struct mgsl_struct *)tty->driver_data;
        unsigned long flags;
@@ -2909,7 +2909,7 @@ static void mgsl_break(struct tty_struct *tty, int break_state)
                         __FILE__,__LINE__, info->device_name, break_state);
                         
        if (mgsl_paranoia_check(info, tty->name, "mgsl_break"))
-               return;
+               return -EINVAL;
 
        spin_lock_irqsave(&info->irq_spinlock,flags);
        if (break_state == -1)
@@ -2917,6 +2917,7 @@ static void mgsl_break(struct tty_struct *tty, int break_state)
        else 
                usc_OutReg(info,IOCR,(u16)(usc_InReg(info,IOCR) & ~BIT7));
        spin_unlock_irqrestore(&info->irq_spinlock,flags);
+       return 0;
        
 }      /* end of mgsl_break() */
 
index 2c3e43b..3e90589 100644 (file)
@@ -165,7 +165,7 @@ static int  read_proc(char *page, char **start, off_t off, int count,int *eof, v
 static int  chars_in_buffer(struct tty_struct *tty);
 static void throttle(struct tty_struct * tty);
 static void unthrottle(struct tty_struct * tty);
-static void set_break(struct tty_struct *tty, int break_state);
+static int set_break(struct tty_struct *tty, int break_state);
 
 /*
  * generic HDLC support and callbacks
@@ -214,6 +214,7 @@ struct slgt_desc
        char *buf;          /* virtual  address of data buffer */
        unsigned int pdesc; /* physical address of this descriptor */
        dma_addr_t buf_dma_addr;
+       unsigned short buf_count;
 };
 
 #define set_desc_buffer(a,b) (a).pbuf = cpu_to_le32((unsigned int)(b))
@@ -302,7 +303,7 @@ struct slgt_info {
        u32 idle_mode;
        u32 max_frame_size;       /* as set by device config */
 
-       unsigned int raw_rx_size;
+       unsigned int rbuf_fill_level;
        unsigned int if_mode;
 
        /* device status */
@@ -466,6 +467,7 @@ static void tx_start(struct slgt_info *info);
 static void tx_stop(struct slgt_info *info);
 static void tx_set_idle(struct slgt_info *info);
 static unsigned int free_tbuf_count(struct slgt_info *info);
+static unsigned int tbuf_bytes(struct slgt_info *info);
 static void reset_tbufs(struct slgt_info *info);
 static void tdma_reset(struct slgt_info *info);
 static void tdma_start(struct slgt_info *info);
@@ -513,7 +515,7 @@ static int  wait_mgsl_event(struct slgt_info *info, int __user *mask_ptr);
 static int  tiocmget(struct tty_struct *tty, struct file *file);
 static int  tiocmset(struct tty_struct *tty, struct file *file,
                     unsigned int set, unsigned int clear);
-static void set_break(struct tty_struct *tty, int break_state);
+static int set_break(struct tty_struct *tty, int break_state);
 static int  get_interface(struct slgt_info *info, int __user *if_mode);
 static int  set_interface(struct slgt_info *info, int if_mode);
 static int  set_gpio(struct slgt_info *info, struct gpio_desc __user *gpio);
@@ -849,6 +851,7 @@ static int write(struct tty_struct *tty,
        int ret = 0;
        struct slgt_info *info = tty->driver_data;
        unsigned long flags;
+       unsigned int bufs_needed;
 
        if (sanity_check(info, tty->name, "write"))
                goto cleanup;
@@ -865,25 +868,16 @@ static int write(struct tty_struct *tty,
        if (!count)
                goto cleanup;
 
-       if (info->params.mode == MGSL_MODE_RAW ||
-           info->params.mode == MGSL_MODE_MONOSYNC ||
-           info->params.mode == MGSL_MODE_BISYNC) {
-               unsigned int bufs_needed = (count/DMABUFSIZE);
-               unsigned int bufs_free = free_tbuf_count(info);
-               if (count % DMABUFSIZE)
-                       ++bufs_needed;
-               if (bufs_needed > bufs_free)
-                       goto cleanup;
-       } else {
-               if (info->tx_active)
-                       goto cleanup;
-               if (info->tx_count) {
-                       /* send accumulated data from send_char() calls */
-                       /* as frame and wait before accepting more data. */
-                       tx_load(info, info->tx_buf, info->tx_count);
-                       goto start;
-               }
+       if (!info->tx_active && info->tx_count) {
+               /* send accumulated data from send_char() */
+               tx_load(info, info->tx_buf, info->tx_count);
+               goto start;
        }
+       bufs_needed = (count/DMABUFSIZE);
+       if (count % DMABUFSIZE)
+               ++bufs_needed;
+       if (bufs_needed > free_tbuf_count(info))
+               goto cleanup;
 
        ret = info->tx_count = count;
        tx_load(info, buf, count);
@@ -1396,10 +1390,12 @@ done:
 static int chars_in_buffer(struct tty_struct *tty)
 {
        struct slgt_info *info = tty->driver_data;
+       int count;
        if (sanity_check(info, tty->name, "chars_in_buffer"))
                return 0;
-       DBGINFO(("%s chars_in_buffer()=%d\n", info->device_name, info->tx_count));
-       return info->tx_count;
+       count = tbuf_bytes(info);
+       DBGINFO(("%s chars_in_buffer()=%d\n", info->device_name, count));
+       return count;
 }
 
 /*
@@ -1452,14 +1448,14 @@ static void unthrottle(struct tty_struct * tty)
  * set or clear transmit break condition
  * break_state -1=set break condition, 0=clear
  */
-static void set_break(struct tty_struct *tty, int break_state)
+static int set_break(struct tty_struct *tty, int break_state)
 {
        struct slgt_info *info = tty->driver_data;
        unsigned short value;
        unsigned long flags;
 
        if (sanity_check(info, tty->name, "set_break"))
-               return;
+               return -EINVAL;
        DBGINFO(("%s set_break(%d)\n", info->device_name, break_state));
 
        spin_lock_irqsave(&info->lock,flags);
@@ -1470,6 +1466,7 @@ static void set_break(struct tty_struct *tty, int break_state)
                value &= ~BIT6;
        wr_reg16(info, TCR, value);
        spin_unlock_irqrestore(&info->lock,flags);
+       return 0;
 }
 
 #if SYNCLINK_GENERIC_HDLC
@@ -2679,8 +2676,31 @@ static int tx_abort(struct slgt_info *info)
 static int rx_enable(struct slgt_info *info, int enable)
 {
        unsigned long flags;
-       DBGINFO(("%s rx_enable(%d)\n", info->device_name, enable));
+       unsigned int rbuf_fill_level;
+       DBGINFO(("%s rx_enable(%08x)\n", info->device_name, enable));
        spin_lock_irqsave(&info->lock,flags);
+       /*
+        * enable[31..16] = receive DMA buffer fill level
+        * 0 = noop (leave fill level unchanged)
+        * fill level must be multiple of 4 and <= buffer size
+        */
+       rbuf_fill_level = ((unsigned int)enable) >> 16;
+       if (rbuf_fill_level) {
+               if ((rbuf_fill_level > DMABUFSIZE) || (rbuf_fill_level % 4)) {
+                       spin_unlock_irqrestore(&info->lock, flags);
+                       return -EINVAL;
+               }
+               info->rbuf_fill_level = rbuf_fill_level;
+               rx_stop(info); /* restart receiver to use new fill level */
+       }
+
+       /*
+        * enable[1..0] = receiver enable command
+        * 0 = disable
+        * 1 = enable
+        * 2 = enable or force hunt mode if already enabled
+        */
+       enable &= 3;
        if (enable) {
                if (!info->rx_enabled)
                        rx_start(info);
@@ -3447,7 +3467,7 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
                info->magic = MGSL_MAGIC;
                INIT_WORK(&info->task, bh_handler);
                info->max_frame_size = 4096;
-               info->raw_rx_size = DMABUFSIZE;
+               info->rbuf_fill_level = DMABUFSIZE;
                info->port.close_delay = 5*HZ/10;
                info->port.closing_wait = 30*HZ;
                init_waitqueue_head(&info->status_event_wait_q);
@@ -3934,15 +3954,7 @@ static void tdma_start(struct slgt_info *info)
 
        /* set 1st descriptor address */
        wr_reg32(info, TDDAR, info->tbufs[info->tbuf_start].pdesc);
-       switch(info->params.mode) {
-       case MGSL_MODE_RAW:
-       case MGSL_MODE_MONOSYNC:
-       case MGSL_MODE_BISYNC:
-               wr_reg32(info, TDCSR, BIT2 + BIT0); /* IRQ + DMA enable */
-               break;
-       default:
-               wr_reg32(info, TDCSR, BIT0); /* DMA enable */
-       }
+       wr_reg32(info, TDCSR, BIT2 + BIT0); /* IRQ + DMA enable */
 }
 
 static void tx_stop(struct slgt_info *info)
@@ -4145,7 +4157,7 @@ static void sync_mode(struct slgt_info *info)
         * 01      enable
         * 00      auto-CTS enable
         */
-       val = 0;
+       val = BIT2;
 
        switch(info->params.mode) {
        case MGSL_MODE_MONOSYNC: val |= BIT14 + BIT13; break;
@@ -4418,6 +4430,8 @@ static void msc_set_vcr(struct slgt_info *info)
                break;
        }
 
+       if (info->if_mode & MGSL_INTERFACE_MSB_FIRST)
+               val |= BIT4;
        if (info->signals & SerialSignal_DTR)
                val |= BIT3;
        if (info->signals & SerialSignal_RTS)
@@ -4456,16 +4470,7 @@ static void free_rbufs(struct slgt_info *info, unsigned int i, unsigned int last
        while(!done) {
                /* reset current buffer for reuse */
                info->rbufs[i].status = 0;
-               switch(info->params.mode) {
-               case MGSL_MODE_RAW:
-               case MGSL_MODE_MONOSYNC:
-               case MGSL_MODE_BISYNC:
-                       set_desc_count(info->rbufs[i], info->raw_rx_size);
-                       break;
-               default:
-                       set_desc_count(info->rbufs[i], DMABUFSIZE);
-               }
-
+               set_desc_count(info->rbufs[i], info->rbuf_fill_level);
                if (i == last)
                        done = 1;
                if (++i == info->rbuf_count)
@@ -4572,7 +4577,7 @@ check_again:
 
        DBGBH(("%s rx frame status=%04X size=%d\n",
                info->device_name, status, framesize));
-       DBGDATA(info, info->rbufs[start].buf, min_t(int, framesize, DMABUFSIZE), "rx");
+       DBGDATA(info, info->rbufs[start].buf, min_t(int, framesize, info->rbuf_fill_level), "rx");
 
        if (framesize) {
                if (!(info->params.crc_type & HDLC_CRC_RETURN_EX)) {
@@ -4592,7 +4597,7 @@ check_again:
                        info->icount.rxok++;
 
                        while(copy_count) {
-                               int partial_count = min(copy_count, DMABUFSIZE);
+                               int partial_count = min_t(int, copy_count, info->rbuf_fill_level);
                                memcpy(p, info->rbufs[i].buf, partial_count);
                                p += partial_count;
                                copy_count -= partial_count;
@@ -4683,6 +4688,56 @@ static unsigned int free_tbuf_count(struct slgt_info *info)
        return count;
 }
 
+/*
+ * return number of bytes in unsent transmit DMA buffers
+ * and the serial controller tx FIFO
+ */
+static unsigned int tbuf_bytes(struct slgt_info *info)
+{
+       unsigned int total_count = 0;
+       unsigned int i = info->tbuf_current;
+       unsigned int reg_value;
+       unsigned int count;
+       unsigned int active_buf_count = 0;
+
+       /*
+        * Add descriptor counts for all tx DMA buffers.
+        * If count is zero (cleared by DMA controller after read),
+        * the buffer is complete or is actively being read from.
+        *
+        * Record buf_count of last buffer with zero count starting
+        * from current ring position. buf_count is mirror
+        * copy of count and is not cleared by serial controller.
+        * If DMA controller is active, that buffer is actively
+        * being read so add to total.
+        */
+       do {
+               count = desc_count(info->tbufs[i]);
+               if (count)
+                       total_count += count;
+               else if (!total_count)
+                       active_buf_count = info->tbufs[i].buf_count;
+               if (++i == info->tbuf_count)
+                       i = 0;
+       } while (i != info->tbuf_current);
+
+       /* read tx DMA status register */
+       reg_value = rd_reg32(info, TDCSR);
+
+       /* if tx DMA active, last zero count buffer is in use */
+       if (reg_value & BIT0)
+               total_count += active_buf_count;
+
+       /* add tx FIFO count = reg_value[15..8] */
+       total_count += (reg_value >> 8) & 0xff;
+
+       /* if transmitter active add one byte for shift register */
+       if (info->tx_active)
+               total_count++;
+
+       return total_count;
+}
+
 /*
  * load transmit DMA buffer(s) with data
  */
@@ -4721,6 +4776,7 @@ static void tx_load(struct slgt_info *info, const char *buf, unsigned int size)
                        set_desc_eof(*d, 0);
 
                set_desc_count(*d, count);
+               d->buf_count = count;
        }
 
        info->tbuf_current = i;
index 5768c41..c0490cb 100644 (file)
@@ -527,7 +527,7 @@ static int  read_proc(char *page, char **start, off_t off, int count,int *eof, v
 static int  chars_in_buffer(struct tty_struct *tty);
 static void throttle(struct tty_struct * tty);
 static void unthrottle(struct tty_struct * tty);
-static void set_break(struct tty_struct *tty, int break_state);
+static int set_break(struct tty_struct *tty, int break_state);
 
 #if SYNCLINK_GENERIC_HDLC
 #define dev_to_port(D) (dev_to_hdlc(D)->priv)
@@ -552,7 +552,7 @@ static int  wait_mgsl_event(SLMP_INFO *info, int __user *mask_ptr);
 static int  tiocmget(struct tty_struct *tty, struct file *file);
 static int  tiocmset(struct tty_struct *tty, struct file *file,
                     unsigned int set, unsigned int clear);
-static void set_break(struct tty_struct *tty, int break_state);
+static int  set_break(struct tty_struct *tty, int break_state);
 
 static void add_device(SLMP_INFO *info);
 static void device_init(int adapter_num, struct pci_dev *pdev);
@@ -1587,7 +1587,7 @@ static void unthrottle(struct tty_struct * tty)
 /* set or clear transmit break condition
  * break_state -1=set break condition, 0=clear
  */
-static void set_break(struct tty_struct *tty, int break_state)
+static int set_break(struct tty_struct *tty, int break_state)
 {
        unsigned char RegValue;
        SLMP_INFO * info = (SLMP_INFO *)tty->driver_data;
@@ -1598,7 +1598,7 @@ static void set_break(struct tty_struct *tty, int break_state)
                         __FILE__,__LINE__, info->device_name, break_state);
 
        if (sanity_check(info, tty->name, "set_break"))
-               return;
+               return -EINVAL;
 
        spin_lock_irqsave(&info->lock,flags);
        RegValue = read_reg(info, CTL);
@@ -1608,6 +1608,7 @@ static void set_break(struct tty_struct *tty, int break_state)
                RegValue &= ~BIT3;
        write_reg(info, CTL, RegValue);
        spin_unlock_irqrestore(&info->lock,flags);
+       return 0;
 }
 
 #if SYNCLINK_GENERIC_HDLC
index 82f6a8c..15e597d 100644 (file)
@@ -655,558 +655,6 @@ EXPORT_SYMBOL_GPL(tty_prepare_flip_string_flags);
 
 
 
-/**
- *     tty_set_termios_ldisc           -       set ldisc field
- *     @tty: tty structure
- *     @num: line discipline number
- *
- *     This is probably overkill for real world processors but
- *     they are not on hot paths so a little discipline won't do
- *     any harm.
- *
- *     Locking: takes termios_mutex
- */
-
-static void tty_set_termios_ldisc(struct tty_struct *tty, int num)
-{
-       mutex_lock(&tty->termios_mutex);
-       tty->termios->c_line = num;
-       mutex_unlock(&tty->termios_mutex);
-}
-
-/*
- *     This guards the refcounted line discipline lists. The lock
- *     must be taken with irqs off because there are hangup path
- *     callers who will do ldisc lookups and cannot sleep.
- */
-
-static DEFINE_SPINLOCK(tty_ldisc_lock);
-static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait);
-/* Line disc dispatch table */
-static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS];
-
-/**
- *     tty_register_ldisc      -       install a line discipline
- *     @disc: ldisc number
- *     @new_ldisc: pointer to the ldisc object
- *
- *     Installs a new line discipline into the kernel. The discipline
- *     is set up as unreferenced and then made available to the kernel
- *     from this point onwards.
- *
- *     Locking:
- *             takes tty_ldisc_lock to guard against ldisc races
- */
-
-int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
-{
-       unsigned long flags;
-       int ret = 0;
-
-       if (disc < N_TTY || disc >= NR_LDISCS)
-               return -EINVAL;
-
-       spin_lock_irqsave(&tty_ldisc_lock, flags);
-       tty_ldiscs[disc] = new_ldisc;
-       new_ldisc->num = disc;
-       new_ldisc->refcount = 0;
-       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-
-       return ret;
-}
-EXPORT_SYMBOL(tty_register_ldisc);
-
-/**
- *     tty_unregister_ldisc    -       unload a line discipline
- *     @disc: ldisc number
- *     @new_ldisc: pointer to the ldisc object
- *
- *     Remove a line discipline from the kernel providing it is not
- *     currently in use.
- *
- *     Locking:
- *             takes tty_ldisc_lock to guard against ldisc races
- */
-
-int tty_unregister_ldisc(int disc)
-{
-       unsigned long flags;
-       int ret = 0;
-
-       if (disc < N_TTY || disc >= NR_LDISCS)
-               return -EINVAL;
-
-       spin_lock_irqsave(&tty_ldisc_lock, flags);
-       if (tty_ldiscs[disc]->refcount)
-               ret = -EBUSY;
-       else
-               tty_ldiscs[disc] = NULL;
-       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-
-       return ret;
-}
-EXPORT_SYMBOL(tty_unregister_ldisc);
-
-
-/**
- *     tty_ldisc_try_get       -       try and reference an ldisc
- *     @disc: ldisc number
- *     @ld: tty ldisc structure to complete
- *
- *     Attempt to open and lock a line discipline into place. Return
- *     the line discipline refcounted and assigned in ld. On an error
- *     report the error code back
- */
-
-static int tty_ldisc_try_get(int disc, struct tty_ldisc *ld)
-{
-       unsigned long flags;
-       struct tty_ldisc_ops *ldops;
-       int err = -EINVAL;
-       
-       spin_lock_irqsave(&tty_ldisc_lock, flags);
-       ld->ops = NULL;
-       ldops = tty_ldiscs[disc];
-       /* Check the entry is defined */
-       if (ldops) {
-               /* If the module is being unloaded we can't use it */
-               if (!try_module_get(ldops->owner))
-                       err = -EAGAIN;
-               else {
-                       /* lock it */
-                       ldops->refcount++;
-                       ld->ops = ldops;
-                       err = 0;
-               }
-       }
-       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-       return err;
-}
-
-/**
- *     tty_ldisc_get           -       take a reference to an ldisc
- *     @disc: ldisc number
- *     @ld: tty line discipline structure to use
- *
- *     Takes a reference to a line discipline. Deals with refcounts and
- *     module locking counts. Returns NULL if the discipline is not available.
- *     Returns a pointer to the discipline and bumps the ref count if it is
- *     available
- *
- *     Locking:
- *             takes tty_ldisc_lock to guard against ldisc races
- */
-
-static int tty_ldisc_get(int disc, struct tty_ldisc *ld)
-{
-       int err;
-
-       if (disc < N_TTY || disc >= NR_LDISCS)
-               return -EINVAL;
-       err = tty_ldisc_try_get(disc, ld);
-       if (err == -EAGAIN) {
-               request_module("tty-ldisc-%d", disc);
-               err = tty_ldisc_try_get(disc, ld);
-       }
-       return err;
-}
-
-/**
- *     tty_ldisc_put           -       drop ldisc reference
- *     @disc: ldisc number
- *
- *     Drop a reference to a line discipline. Manage refcounts and
- *     module usage counts
- *
- *     Locking:
- *             takes tty_ldisc_lock to guard against ldisc races
- */
-
-static void tty_ldisc_put(struct tty_ldisc_ops *ld)
-{
-       unsigned long flags;
-       int disc = ld->num;
-
-       BUG_ON(disc < N_TTY || disc >= NR_LDISCS);
-
-       spin_lock_irqsave(&tty_ldisc_lock, flags);
-       ld = tty_ldiscs[disc];
-       BUG_ON(ld->refcount == 0);
-       ld->refcount--;
-       module_put(ld->owner);
-       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-}
-
-static void * tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos)
-{
-       return (*pos < NR_LDISCS) ? pos : NULL;
-}
-
-static void * tty_ldiscs_seq_next(struct seq_file *m, void *v, loff_t *pos)
-{
-       (*pos)++;
-       return (*pos < NR_LDISCS) ? pos : NULL;
-}
-
-static void tty_ldiscs_seq_stop(struct seq_file *m, void *v)
-{
-}
-
-static int tty_ldiscs_seq_show(struct seq_file *m, void *v)
-{
-       int i = *(loff_t *)v;
-       struct tty_ldisc ld;
-       
-       if (tty_ldisc_get(i, &ld) < 0)
-               return 0;
-       seq_printf(m, "%-10s %2d\n", ld.ops->name ? ld.ops->name : "???", i);
-       tty_ldisc_put(ld.ops);
-       return 0;
-}
-
-static const struct seq_operations tty_ldiscs_seq_ops = {
-       .start  = tty_ldiscs_seq_start,
-       .next   = tty_ldiscs_seq_next,
-       .stop   = tty_ldiscs_seq_stop,
-       .show   = tty_ldiscs_seq_show,
-};
-
-static int proc_tty_ldiscs_open(struct inode *inode, struct file *file)
-{
-       return seq_open(file, &tty_ldiscs_seq_ops);
-}
-
-const struct file_operations tty_ldiscs_proc_fops = {
-       .owner          = THIS_MODULE,
-       .open           = proc_tty_ldiscs_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = seq_release,
-};
-
-/**
- *     tty_ldisc_assign        -       set ldisc on a tty
- *     @tty: tty to assign
- *     @ld: line discipline
- *
- *     Install an instance of a line discipline into a tty structure. The
- *     ldisc must have a reference count above zero to ensure it remains/
- *     The tty instance refcount starts at zero.
- *
- *     Locking:
- *             Caller must hold references
- */
-
-static void tty_ldisc_assign(struct tty_struct *tty, struct tty_ldisc *ld)
-{
-       ld->refcount = 0;
-       tty->ldisc = *ld;
-}
-
-/**
- *     tty_ldisc_try           -       internal helper
- *     @tty: the tty
- *
- *     Make a single attempt to grab and bump the refcount on
- *     the tty ldisc. Return 0 on failure or 1 on success. This is
- *     used to implement both the waiting and non waiting versions
- *     of tty_ldisc_ref
- *
- *     Locking: takes tty_ldisc_lock
- */
-
-static int tty_ldisc_try(struct tty_struct *tty)
-{
-       unsigned long flags;
-       struct tty_ldisc *ld;
-       int ret = 0;
-
-       spin_lock_irqsave(&tty_ldisc_lock, flags);
-       ld = &tty->ldisc;
-       if (test_bit(TTY_LDISC, &tty->flags)) {
-               ld->refcount++;
-               ret = 1;
-       }
-       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-       return ret;
-}
-
-/**
- *     tty_ldisc_ref_wait      -       wait for the tty ldisc
- *     @tty: tty device
- *
- *     Dereference the line discipline for the terminal and take a
- *     reference to it. If the line discipline is in flux then
- *     wait patiently until it changes.
- *
- *     Note: Must not be called from an IRQ/timer context. The caller
- *     must also be careful not to hold other locks that will deadlock
- *     against a discipline change, such as an existing ldisc reference
- *     (which we check for)
- *
- *     Locking: call functions take tty_ldisc_lock
- */
-
-struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *tty)
-{
-       /* wait_event is a macro */
-       wait_event(tty_ldisc_wait, tty_ldisc_try(tty));
-       if (tty->ldisc.refcount == 0)
-               printk(KERN_ERR "tty_ldisc_ref_wait\n");
-       return &tty->ldisc;
-}
-
-EXPORT_SYMBOL_GPL(tty_ldisc_ref_wait);
-
-/**
- *     tty_ldisc_ref           -       get the tty ldisc
- *     @tty: tty device
- *
- *     Dereference the line discipline for the terminal and take a
- *     reference to it. If the line discipline is in flux then
- *     return NULL. Can be called from IRQ and timer functions.
- *
- *     Locking: called functions take tty_ldisc_lock
- */
-
-struct tty_ldisc *tty_ldisc_ref(struct tty_struct *tty)
-{
-       if (tty_ldisc_try(tty))
-               return &tty->ldisc;
-       return NULL;
-}
-
-EXPORT_SYMBOL_GPL(tty_ldisc_ref);
-
-/**
- *     tty_ldisc_deref         -       free a tty ldisc reference
- *     @ld: reference to free up
- *
- *     Undoes the effect of tty_ldisc_ref or tty_ldisc_ref_wait. May
- *     be called in IRQ context.
- *
- *     Locking: takes tty_ldisc_lock
- */
-
-void tty_ldisc_deref(struct tty_ldisc *ld)
-{
-       unsigned long flags;
-
-       BUG_ON(ld == NULL);
-
-       spin_lock_irqsave(&tty_ldisc_lock, flags);
-       if (ld->refcount == 0)
-               printk(KERN_ERR "tty_ldisc_deref: no references.\n");
-       else
-               ld->refcount--;
-       if (ld->refcount == 0)
-               wake_up(&tty_ldisc_wait);
-       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-}
-
-EXPORT_SYMBOL_GPL(tty_ldisc_deref);
-
-/**
- *     tty_ldisc_enable        -       allow ldisc use
- *     @tty: terminal to activate ldisc on
- *
- *     Set the TTY_LDISC flag when the line discipline can be called
- *     again. Do necessary wakeups for existing sleepers.
- *
- *     Note: nobody should set this bit except via this function. Clearing
- *     directly is allowed.
- */
-
-static void tty_ldisc_enable(struct tty_struct *tty)
-{
-       set_bit(TTY_LDISC, &tty->flags);
-       wake_up(&tty_ldisc_wait);
-}
-
-/**
- *     tty_ldisc_restore       -       helper for tty ldisc change
- *     @tty: tty to recover
- *     @old: previous ldisc
- *
- *     Restore the previous line discipline or N_TTY when a line discipline
- *     change fails due to an open error
- */
-
-static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old)
-{
-       char buf[64];
-       struct tty_ldisc new_ldisc;
-
-       /* There is an outstanding reference here so this is safe */
-       tty_ldisc_get(old->ops->num, old);
-       tty_ldisc_assign(tty, old);
-       tty_set_termios_ldisc(tty, old->ops->num);
-       if (old->ops->open && (old->ops->open(tty) < 0)) {
-               tty_ldisc_put(old->ops);
-               /* This driver is always present */
-               if (tty_ldisc_get(N_TTY, &new_ldisc) < 0)
-                       panic("n_tty: get");
-               tty_ldisc_assign(tty, &new_ldisc);
-               tty_set_termios_ldisc(tty, N_TTY);
-               if (new_ldisc.ops->open) {
-                       int r = new_ldisc.ops->open(tty);
-                               if (r < 0)
-                               panic("Couldn't open N_TTY ldisc for "
-                                     "%s --- error %d.",
-                                     tty_name(tty, buf), r);
-               }
-       }
-}
-
-/**
- *     tty_set_ldisc           -       set line discipline
- *     @tty: the terminal to set
- *     @ldisc: the line discipline
- *
- *     Set the discipline of a tty line. Must be called from a process
- *     context.
- *
- *     Locking: takes tty_ldisc_lock.
- *              called functions take termios_mutex
- */
-
-static int tty_set_ldisc(struct tty_struct *tty, int ldisc)
-{
-       int retval;
-       struct tty_ldisc o_ldisc, new_ldisc;
-       int work;
-       unsigned long flags;
-       struct tty_struct *o_tty;
-
-restart:
-       /* This is a bit ugly for now but means we can break the 'ldisc
-          is part of the tty struct' assumption later */
-       retval = tty_ldisc_get(ldisc, &new_ldisc);
-       if (retval)
-               return retval;
-
-       /*
-        *      Problem: What do we do if this blocks ?
-        */
-
-       tty_wait_until_sent(tty, 0);
-
-       if (tty->ldisc.ops->num == ldisc) {
-               tty_ldisc_put(new_ldisc.ops);
-               return 0;
-       }
-
-       /*
-        *      No more input please, we are switching. The new ldisc
-        *      will update this value in the ldisc open function
-        */
-
-       tty->receive_room = 0;
-
-       o_ldisc = tty->ldisc;
-       o_tty = tty->link;
-
-       /*
-        *      Make sure we don't change while someone holds a
-        *      reference to the line discipline. The TTY_LDISC bit
-        *      prevents anyone taking a reference once it is clear.
-        *      We need the lock to avoid racing reference takers.
-        */
-
-       spin_lock_irqsave(&tty_ldisc_lock, flags);
-       if (tty->ldisc.refcount || (o_tty && o_tty->ldisc.refcount)) {
-               if (tty->ldisc.refcount) {
-                       /* Free the new ldisc we grabbed. Must drop the lock
-                          first. */
-                       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-                       tty_ldisc_put(o_ldisc.ops);
-                       /*
-                        * There are several reasons we may be busy, including
-                        * random momentary I/O traffic. We must therefore
-                        * retry. We could distinguish between blocking ops
-                        * and retries if we made tty_ldisc_wait() smarter.
-                        * That is up for discussion.
-                        */
-                       if (wait_event_interruptible(tty_ldisc_wait, tty->ldisc.refcount == 0) < 0)
-                               return -ERESTARTSYS;
-                       goto restart;
-               }
-               if (o_tty && o_tty->ldisc.refcount) {
-                       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-                       tty_ldisc_put(o_tty->ldisc.ops);
-                       if (wait_event_interruptible(tty_ldisc_wait, o_tty->ldisc.refcount == 0) < 0)
-                               return -ERESTARTSYS;
-                       goto restart;
-               }
-       }
-       /*
-        *      If the TTY_LDISC bit is set, then we are racing against
-        *      another ldisc change
-        */
-       if (!test_bit(TTY_LDISC, &tty->flags)) {
-               struct tty_ldisc *ld;
-               spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-               tty_ldisc_put(new_ldisc.ops);
-               ld = tty_ldisc_ref_wait(tty);
-               tty_ldisc_deref(ld);
-               goto restart;
-       }
-
-       clear_bit(TTY_LDISC, &tty->flags);
-       if (o_tty)
-               clear_bit(TTY_LDISC, &o_tty->flags);
-       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-       
-       /*
-        *      From this point on we know nobody has an ldisc
-        *      usage reference, nor can they obtain one until
-        *      we say so later on.
-        */
-
-       work = cancel_delayed_work(&tty->buf.work);
-       /*
-        * Wait for ->hangup_work and ->buf.work handlers to terminate
-        * MUST NOT hold locks here.
-        */
-       flush_scheduled_work();
-       /* Shutdown the current discipline. */
-       if (o_ldisc.ops->close)
-               (o_ldisc.ops->close)(tty);
-
-       /* Now set up the new line discipline. */
-       tty_ldisc_assign(tty, &new_ldisc);
-       tty_set_termios_ldisc(tty, ldisc);
-       if (new_ldisc.ops->open)
-               retval = (new_ldisc.ops->open)(tty);
-       if (retval < 0) {
-               tty_ldisc_put(new_ldisc.ops);
-               tty_ldisc_restore(tty, &o_ldisc);
-       }
-       /* At this point we hold a reference to the new ldisc and a
-          a reference to the old ldisc. If we ended up flipping back
-          to the existing ldisc we have two references to it */
-
-       if (tty->ldisc.ops->num != o_ldisc.ops->num && tty->ops->set_ldisc)
-               tty->ops->set_ldisc(tty);
-
-       tty_ldisc_put(o_ldisc.ops);
-
-       /*
-        *      Allow ldisc referencing to occur as soon as the driver
-        *      ldisc callback completes.
-        */
-
-       tty_ldisc_enable(tty);
-       if (o_tty)
-               tty_ldisc_enable(o_tty);
-
-       /* Restart it in case no characters kick it off. Safe if
-          already running */
-       if (work)
-               schedule_delayed_work(&tty->buf.work, 1);
-       return retval;
-}
-
 /**
  *     get_tty_driver          -       find device of a tty
  *     @dev_t: device identifier
@@ -2193,7 +1641,6 @@ static int init_dev(struct tty_driver *driver, int idx,
        struct ktermios *tp, **tp_loc, *o_tp, **o_tp_loc;
        struct ktermios *ltp, **ltp_loc, *o_ltp, **o_ltp_loc;
        int retval = 0;
-       struct tty_ldisc *ld;
 
        /* check whether we're reopening an existing tty */
        if (driver->flags & TTY_DRIVER_DEVPTS_MEM) {
@@ -2342,25 +1789,12 @@ static int init_dev(struct tty_driver *driver, int idx,
         * If we fail here just call release_tty to clean up.  No need
         * to decrement the use counts, as release_tty doesn't care.
         */
-        
-       ld = &tty->ldisc;
 
-       if (ld->ops->open) {
-               retval = (ld->ops->open)(tty);
-               if (retval)
-                       goto release_mem_out;
-       }
-       if (o_tty && o_tty->ldisc.ops->open) {
-               retval = (o_tty->ldisc.ops->open)(o_tty);
-               if (retval) {
-                       if (ld->ops->close)
-                               (ld->ops->close)(tty);
-                       goto release_mem_out;
-               }
-               tty_ldisc_enable(o_tty);
-       }
-       tty_ldisc_enable(tty);
-       goto success;
+       retval = tty_ldisc_setup(tty, o_tty);
+
+       if (retval)
+               goto release_mem_out;
+        goto success;
 
        /*
         * This fast open can be used if the tty is already open.
@@ -2498,12 +1932,10 @@ static void release_tty(struct tty_struct *tty, int idx)
 static void release_dev(struct file *filp)
 {
        struct tty_struct *tty, *o_tty;
-       struct tty_ldisc ld;
        int     pty_master, tty_closing, o_tty_closing, do_sleep;
        int     devpts;
        int     idx;
        char    buf[64];
-       unsigned long flags;
 
        tty = (struct tty_struct *)filp->private_data;
        if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode,
@@ -2705,56 +2137,9 @@ static void release_dev(struct file *filp)
        printk(KERN_DEBUG "freeing tty structure...");
 #endif
        /*
-        * Prevent flush_to_ldisc() from rescheduling the work for later.  Then
-        * kill any delayed work. As this is the final close it does not
-        * race with the set_ldisc code path.
+        * Ask the line discipline code to release its structures
         */
-       clear_bit(TTY_LDISC, &tty->flags);
-       cancel_delayed_work(&tty->buf.work);
-
-       /*
-        * Wait for ->hangup_work and ->buf.work handlers to terminate
-        */
-
-       flush_scheduled_work();
-
-       /*
-        * Wait for any short term users (we know they are just driver
-        * side waiters as the file is closing so user count on the file
-        * side is zero.
-        */
-       spin_lock_irqsave(&tty_ldisc_lock, flags);
-       while (tty->ldisc.refcount) {
-               spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-               wait_event(tty_ldisc_wait, tty->ldisc.refcount == 0);
-               spin_lock_irqsave(&tty_ldisc_lock, flags);
-       }
-       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
-       /*
-        * Shutdown the current line discipline, and reset it to N_TTY.
-        *
-        * FIXME: this MUST get fixed for the new reflocking
-        */
-       if (tty->ldisc.ops->close)
-               (tty->ldisc.ops->close)(tty);
-       tty_ldisc_put(tty->ldisc.ops);
-
-       /*
-        *      Switch the line discipline back
-        */
-       WARN_ON(tty_ldisc_get(N_TTY, &ld));
-       tty_ldisc_assign(tty, &ld);
-       tty_set_termios_ldisc(tty, N_TTY);
-       if (o_tty) {
-               /* FIXME: could o_tty be in setldisc here ? */
-               clear_bit(TTY_LDISC, &o_tty->flags);
-               if (o_tty->ldisc.ops->close)
-                       (o_tty->ldisc.ops->close)(o_tty);
-               tty_ldisc_put(o_tty->ldisc.ops);
-               WARN_ON(tty_ldisc_get(N_TTY, &ld));
-               tty_ldisc_assign(o_tty, &ld);
-               tty_set_termios_ldisc(o_tty, N_TTY);
-       }
+       tty_ldisc_release(tty, o_tty);
        /*
         * The release_tty function takes care of the details of clearing
         * the slots and preserving the termios structure.
@@ -3464,16 +2849,29 @@ static int tiocsetd(struct tty_struct *tty, int __user *p)
 
 static int send_break(struct tty_struct *tty, unsigned int duration)
 {
-       if (tty_write_lock(tty, 0) < 0)
-               return -EINTR;
-       tty->ops->break_ctl(tty, -1);
-       if (!signal_pending(current))
-               msleep_interruptible(duration);
-       tty->ops->break_ctl(tty, 0);
-       tty_write_unlock(tty);
-       if (signal_pending(current))
-               return -EINTR;
-       return 0;
+       int retval;
+
+       if (tty->ops->break_ctl == NULL)
+               return 0;
+
+       if (tty->driver->flags & TTY_DRIVER_HARDWARE_BREAK)
+               retval = tty->ops->break_ctl(tty, duration);
+       else {
+               /* Do the work ourselves */
+               if (tty_write_lock(tty, 0) < 0)
+                       return -EINTR;
+               retval = tty->ops->break_ctl(tty, -1);
+               if (retval)
+                       goto out;
+               if (!signal_pending(current))
+                       msleep_interruptible(duration);
+               retval = tty->ops->break_ctl(tty, 0);
+out:
+               tty_write_unlock(tty);
+               if (signal_pending(current))
+                       retval = -EINTR;
+       }
+       return retval;
 }
 
 /**
@@ -3564,36 +2962,6 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
            tty->driver->subtype == PTY_TYPE_MASTER)
                real_tty = tty->link;
 
-       /*
-        * Break handling by driver
-        */
-
-       retval = -EINVAL;
-
-       if (!tty->ops->break_ctl) {
-               switch (cmd) {
-               case TIOCSBRK:
-               case TIOCCBRK:
-                       if (tty->ops->ioctl)
-                               retval = tty->ops->ioctl(tty, file, cmd, arg);
-                       if (retval != -EINVAL && retval != -ENOIOCTLCMD)
-                               printk(KERN_WARNING "tty: driver %s needs updating to use break_ctl\n", tty->driver->name);
-                       return retval;
-
-               /* These two ioctl's always return success; even if */
-               /* the driver doesn't support them. */
-               case TCSBRK:
-               case TCSBRKP:
-                       if (!tty->ops->ioctl)
-                               return 0;
-                       retval = tty->ops->ioctl(tty, file, cmd, arg);
-                       if (retval != -EINVAL && retval != -ENOIOCTLCMD)
-                               printk(KERN_WARNING "tty: driver %s needs updating to use break_ctl\n", tty->driver->name);
-                       if (retval == -ENOIOCTLCMD)
-                               retval = 0;
-                       return retval;
-               }
-       }
 
        /*
         * Factor out some common prep work
@@ -3615,6 +2983,9 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                break;
        }
 
+       /*
+        *      Now do the stuff.
+        */
        switch (cmd) {
        case TIOCSTI:
                return tiocsti(tty, p);
@@ -3658,12 +3029,11 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
         */
        case TIOCSBRK:  /* Turn break on, unconditionally */
                if (tty->ops->break_ctl)
-                       tty->ops->break_ctl(tty, -1);
+                       return tty->ops->break_ctl(tty, -1);
                return 0;
-
        case TIOCCBRK:  /* Turn break off, unconditionally */
                if (tty->ops->break_ctl)
-                       tty->ops->break_ctl(tty, 0);
+                       return tty->ops->break_ctl(tty, 0);
                return 0;
        case TCSBRK:   /* SVID version: non-zero arg --> no break */
                /* non-zero arg means wait for all output data
@@ -3962,12 +3332,9 @@ EXPORT_SYMBOL(tty_flip_buffer_push);
 
 static void initialize_tty_struct(struct tty_struct *tty)
 {
-       struct tty_ldisc ld;
        memset(tty, 0, sizeof(struct tty_struct));
        tty->magic = TTY_MAGIC;
-       if (tty_ldisc_get(N_TTY, &ld) < 0)
-               panic("n_tty: init_tty");
-       tty_ldisc_assign(tty, &ld);
+       tty_ldisc_init(tty);
        tty->session = NULL;
        tty->pgrp = NULL;
        tty->overrun_time = jiffies;
@@ -4045,7 +3412,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index,
        else
                tty_line_name(driver, index, name);
 
-       return device_create(tty_class, device, dev, name);
+       return device_create_drvdata(tty_class, device, dev, NULL, name);
 }
 
 /**
@@ -4280,7 +3647,7 @@ void __init console_init(void)
        initcall_t *call;
 
        /* Setup the default TTY line discipline. */
-       (void) tty_register_ldisc(N_TTY, &tty_ldisc_N_TTY);
+       tty_ldisc_begin();
 
        /*
         * set up the console device so that later boot sequences can
@@ -4323,20 +3690,22 @@ static int __init tty_init(void)
        if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
            register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
                panic("Couldn't register /dev/tty driver\n");
-       device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), "tty");
+       device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL,
+                             "tty");
 
        cdev_init(&console_cdev, &console_fops);
        if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
            register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
                panic("Couldn't register /dev/console driver\n");
-       device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), "console");
+       device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL,
+                             "console");
 
 #ifdef CONFIG_UNIX98_PTYS
        cdev_init(&ptmx_cdev, &ptmx_fops);
        if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
            register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0)
                panic("Couldn't register /dev/ptmx driver\n");
-       device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), "ptmx");
+       device_create_drvdata(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 2), NULL, "ptmx");
 #endif
 
 #ifdef CONFIG_VT
@@ -4344,7 +3713,7 @@ static int __init tty_init(void)
        if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
            register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
                panic("Couldn't register /dev/tty0 driver\n");
-       device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), "tty0");
+       device_create_drvdata(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
 
        vty_init();
 #endif
diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c
new file mode 100644 (file)
index 0000000..241cbde
--- /dev/null
@@ -0,0 +1,714 @@
+#include <linux/types.h>
+#include <linux/major.h>
+#include <linux/errno.h>
+#include <linux/signal.h>
+#include <linux/fcntl.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/tty.h>
+#include <linux/tty_driver.h>
+#include <linux/tty_flip.h>
+#include <linux/devpts_fs.h>
+#include <linux/file.h>
+#include <linux/fdtable.h>
+#include <linux/console.h>
+#include <linux/timer.h>
+#include <linux/ctype.h>
+#include <linux/kd.h>
+#include <linux/mm.h>
+#include <linux/string.h>
+#include <linux/slab.h>
+#include <linux/poll.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/smp_lock.h>
+#include <linux/device.h>
+#include <linux/wait.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <linux/seq_file.h>
+
+#include <linux/uaccess.h>
+#include <asm/system.h>
+
+#include <linux/kbd_kern.h>
+#include <linux/vt_kern.h>
+#include <linux/selection.h>
+
+#include <linux/kmod.h>
+#include <linux/nsproxy.h>
+
+/*
+ *     This guards the refcounted line discipline lists. The lock
+ *     must be taken with irqs off because there are hangup path
+ *     callers who will do ldisc lookups and cannot sleep.
+ */
+
+static DEFINE_SPINLOCK(tty_ldisc_lock);
+static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait);
+/* Line disc dispatch table */
+static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS];
+
+/**
+ *     tty_register_ldisc      -       install a line discipline
+ *     @disc: ldisc number
+ *     @new_ldisc: pointer to the ldisc object
+ *
+ *     Installs a new line discipline into the kernel. The discipline
+ *     is set up as unreferenced and then made available to the kernel
+ *     from this point onwards.
+ *
+ *     Locking:
+ *             takes tty_ldisc_lock to guard against ldisc races
+ */
+
+int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
+{
+       unsigned long flags;
+       int ret = 0;
+
+       if (disc < N_TTY || disc >= NR_LDISCS)
+               return -EINVAL;
+
+       spin_lock_irqsave(&tty_ldisc_lock, flags);
+       tty_ldiscs[disc] = new_ldisc;
+       new_ldisc->num = disc;
+       new_ldisc->refcount = 0;
+       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+
+       return ret;
+}
+EXPORT_SYMBOL(tty_register_ldisc);
+
+/**
+ *     tty_unregister_ldisc    -       unload a line discipline
+ *     @disc: ldisc number
+ *     @new_ldisc: pointer to the ldisc object
+ *
+ *     Remove a line discipline from the kernel providing it is not
+ *     currently in use.
+ *
+ *     Locking:
+ *             takes tty_ldisc_lock to guard against ldisc races
+ */
+
+int tty_unregister_ldisc(int disc)
+{
+       unsigned long flags;
+       int ret = 0;
+
+       if (disc < N_TTY || disc >= NR_LDISCS)
+               return -EINVAL;
+
+       spin_lock_irqsave(&tty_ldisc_lock, flags);
+       if (tty_ldiscs[disc]->refcount)
+               ret = -EBUSY;
+       else
+               tty_ldiscs[disc] = NULL;
+       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+
+       return ret;
+}
+EXPORT_SYMBOL(tty_unregister_ldisc);
+
+
+/**
+ *     tty_ldisc_try_get       -       try and reference an ldisc
+ *     @disc: ldisc number
+ *     @ld: tty ldisc structure to complete
+ *
+ *     Attempt to open and lock a line discipline into place. Return
+ *     the line discipline refcounted and assigned in ld. On an error
+ *     report the error code back
+ */
+
+static int tty_ldisc_try_get(int disc, struct tty_ldisc *ld)
+{
+       unsigned long flags;
+       struct tty_ldisc_ops *ldops;
+       int err = -EINVAL;
+       
+       spin_lock_irqsave(&tty_ldisc_lock, flags);
+       ld->ops = NULL;
+       ldops = tty_ldiscs[disc];
+       /* Check the entry is defined */
+       if (ldops) {
+               /* If the module is being unloaded we can't use it */
+               if (!try_module_get(ldops->owner))
+                       err = -EAGAIN;
+               else {
+                       /* lock it */
+                       ldops->refcount++;
+                       ld->ops = ldops;
+                       err = 0;
+               }
+       }
+       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+       return err;
+}
+
+/**
+ *     tty_ldisc_get           -       take a reference to an ldisc
+ *     @disc: ldisc number
+ *     @ld: tty line discipline structure to use
+ *
+ *     Takes a reference to a line discipline. Deals with refcounts and
+ *     module locking counts. Returns NULL if the discipline is not available.
+ *     Returns a pointer to the discipline and bumps the ref count if it is
+ *     available
+ *
+ *     Locking:
+ *             takes tty_ldisc_lock to guard against ldisc races
+ */
+
+static int tty_ldisc_get(int disc, struct tty_ldisc *ld)
+{
+       int err;
+
+       if (disc < N_TTY || disc >= NR_LDISCS)
+               return -EINVAL;
+       err = tty_ldisc_try_get(disc, ld);
+       if (err == -EAGAIN) {
+               request_module("tty-ldisc-%d", disc);
+               err = tty_ldisc_try_get(disc, ld);
+       }
+       return err;
+}
+
+/**
+ *     tty_ldisc_put           -       drop ldisc reference
+ *     @disc: ldisc number
+ *
+ *     Drop a reference to a line discipline. Manage refcounts and
+ *     module usage counts
+ *
+ *     Locking:
+ *             takes tty_ldisc_lock to guard against ldisc races
+ */
+
+static void tty_ldisc_put(struct tty_ldisc_ops *ld)
+{
+       unsigned long flags;
+       int disc = ld->num;
+
+       BUG_ON(disc < N_TTY || disc >= NR_LDISCS);
+
+       spin_lock_irqsave(&tty_ldisc_lock, flags);
+       ld = tty_ldiscs[disc];
+       BUG_ON(ld->refcount == 0);
+       ld->refcount--;
+       module_put(ld->owner);
+       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+}
+
+static void * tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos)
+{
+       return (*pos < NR_LDISCS) ? pos : NULL;
+}
+
+static void * tty_ldiscs_seq_next(struct seq_file *m, void *v, loff_t *pos)
+{
+       (*pos)++;
+       return (*pos < NR_LDISCS) ? pos : NULL;
+}
+
+static void tty_ldiscs_seq_stop(struct seq_file *m, void *v)
+{
+}
+
+static int tty_ldiscs_seq_show(struct seq_file *m, void *v)
+{
+       int i = *(loff_t *)v;
+       struct tty_ldisc ld;
+       
+       if (tty_ldisc_get(i, &ld) < 0)
+               return 0;
+       seq_printf(m, "%-10s %2d\n", ld.ops->name ? ld.ops->name : "???", i);
+       tty_ldisc_put(ld.ops);
+       return 0;
+}
+
+static const struct seq_operations tty_ldiscs_seq_ops = {
+       .start  = tty_ldiscs_seq_start,
+       .next   = tty_ldiscs_seq_next,
+       .stop   = tty_ldiscs_seq_stop,
+       .show   = tty_ldiscs_seq_show,
+};
+
+static int proc_tty_ldiscs_open(struct inode *inode, struct file *file)
+{
+       return seq_open(file, &tty_ldiscs_seq_ops);
+}
+
+const struct file_operations tty_ldiscs_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = proc_tty_ldiscs_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = seq_release,
+};
+
+/**
+ *     tty_ldisc_assign        -       set ldisc on a tty
+ *     @tty: tty to assign
+ *     @ld: line discipline
+ *
+ *     Install an instance of a line discipline into a tty structure. The
+ *     ldisc must have a reference count above zero to ensure it remains/
+ *     The tty instance refcount starts at zero.
+ *
+ *     Locking:
+ *             Caller must hold references
+ */
+
+static void tty_ldisc_assign(struct tty_struct *tty, struct tty_ldisc *ld)
+{
+       ld->refcount = 0;
+       tty->ldisc = *ld;
+}
+
+/**
+ *     tty_ldisc_try           -       internal helper
+ *     @tty: the tty
+ *
+ *     Make a single attempt to grab and bump the refcount on
+ *     the tty ldisc. Return 0 on failure or 1 on success. This is
+ *     used to implement both the waiting and non waiting versions
+ *     of tty_ldisc_ref
+ *
+ *     Locking: takes tty_ldisc_lock
+ */
+
+static int tty_ldisc_try(struct tty_struct *tty)
+{
+       unsigned long flags;
+       struct tty_ldisc *ld;
+       int ret = 0;
+
+       spin_lock_irqsave(&tty_ldisc_lock, flags);
+       ld = &tty->ldisc;
+       if (test_bit(TTY_LDISC, &tty->flags)) {
+               ld->refcount++;
+               ret = 1;
+       }
+       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+       return ret;
+}
+
+/**
+ *     tty_ldisc_ref_wait      -       wait for the tty ldisc
+ *     @tty: tty device
+ *
+ *     Dereference the line discipline for the terminal and take a
+ *     reference to it. If the line discipline is in flux then
+ *     wait patiently until it changes.
+ *
+ *     Note: Must not be called from an IRQ/timer context. The caller
+ *     must also be careful not to hold other locks that will deadlock
+ *     against a discipline change, such as an existing ldisc reference
+ *     (which we check for)
+ *
+ *     Locking: call functions take tty_ldisc_lock
+ */
+
+struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *tty)
+{
+       /* wait_event is a macro */
+       wait_event(tty_ldisc_wait, tty_ldisc_try(tty));
+       if (tty->ldisc.refcount == 0)
+               printk(KERN_ERR "tty_ldisc_ref_wait\n");
+       return &tty->ldisc;
+}
+
+EXPORT_SYMBOL_GPL(tty_ldisc_ref_wait);
+
+/**
+ *     tty_ldisc_ref           -       get the tty ldisc
+ *     @tty: tty device
+ *
+ *     Dereference the line discipline for the terminal and take a
+ *     reference to it. If the line discipline is in flux then
+ *     return NULL. Can be called from IRQ and timer functions.
+ *
+ *     Locking: called functions take tty_ldisc_lock
+ */
+
+struct tty_ldisc *tty_ldisc_ref(struct tty_struct *tty)
+{
+       if (tty_ldisc_try(tty))
+               return &tty->ldisc;
+       return NULL;
+}
+
+EXPORT_SYMBOL_GPL(tty_ldisc_ref);
+
+/**
+ *     tty_ldisc_deref         -       free a tty ldisc reference
+ *     @ld: reference to free up
+ *
+ *     Undoes the effect of tty_ldisc_ref or tty_ldisc_ref_wait. May
+ *     be called in IRQ context.
+ *
+ *     Locking: takes tty_ldisc_lock
+ */
+
+void tty_ldisc_deref(struct tty_ldisc *ld)
+{
+       unsigned long flags;
+
+       BUG_ON(ld == NULL);
+
+       spin_lock_irqsave(&tty_ldisc_lock, flags);
+       if (ld->refcount == 0)
+               printk(KERN_ERR "tty_ldisc_deref: no references.\n");
+       else
+               ld->refcount--;
+       if (ld->refcount == 0)
+               wake_up(&tty_ldisc_wait);
+       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+}
+
+EXPORT_SYMBOL_GPL(tty_ldisc_deref);
+
+/**
+ *     tty_ldisc_enable        -       allow ldisc use
+ *     @tty: terminal to activate ldisc on
+ *
+ *     Set the TTY_LDISC flag when the line discipline can be called
+ *     again. Do necessary wakeups for existing sleepers.
+ *
+ *     Note: nobody should set this bit except via this function. Clearing
+ *     directly is allowed.
+ */
+
+void tty_ldisc_enable(struct tty_struct *tty)
+{
+       set_bit(TTY_LDISC, &tty->flags);
+       wake_up(&tty_ldisc_wait);
+}
+
+/**
+ *     tty_set_termios_ldisc           -       set ldisc field
+ *     @tty: tty structure
+ *     @num: line discipline number
+ *
+ *     This is probably overkill for real world processors but
+ *     they are not on hot paths so a little discipline won't do
+ *     any harm.
+ *
+ *     Locking: takes termios_mutex
+ */
+
+static void tty_set_termios_ldisc(struct tty_struct *tty, int num)
+{
+       mutex_lock(&tty->termios_mutex);
+       tty->termios->c_line = num;
+       mutex_unlock(&tty->termios_mutex);
+}
+
+
+/**
+ *     tty_ldisc_restore       -       helper for tty ldisc change
+ *     @tty: tty to recover
+ *     @old: previous ldisc
+ *
+ *     Restore the previous line discipline or N_TTY when a line discipline
+ *     change fails due to an open error
+ */
+
+static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old)
+{
+       char buf[64];
+       struct tty_ldisc new_ldisc;
+
+       /* There is an outstanding reference here so this is safe */
+       tty_ldisc_get(old->ops->num, old);
+       tty_ldisc_assign(tty, old);
+       tty_set_termios_ldisc(tty, old->ops->num);
+       if (old->ops->open && (old->ops->open(tty) < 0)) {
+               tty_ldisc_put(old->ops);
+               /* This driver is always present */
+               if (tty_ldisc_get(N_TTY, &new_ldisc) < 0)
+                       panic("n_tty: get");
+               tty_ldisc_assign(tty, &new_ldisc);
+               tty_set_termios_ldisc(tty, N_TTY);
+               if (new_ldisc.ops->open) {
+                       int r = new_ldisc.ops->open(tty);
+                               if (r < 0)
+                               panic("Couldn't open N_TTY ldisc for "
+                                     "%s --- error %d.",
+                                     tty_name(tty, buf), r);
+               }
+       }
+}
+
+/**
+ *     tty_set_ldisc           -       set line discipline
+ *     @tty: the terminal to set
+ *     @ldisc: the line discipline
+ *
+ *     Set the discipline of a tty line. Must be called from a process
+ *     context.
+ *
+ *     Locking: takes tty_ldisc_lock.
+ *              called functions take termios_mutex
+ */
+
+int tty_set_ldisc(struct tty_struct *tty, int ldisc)
+{
+       int retval;
+       struct tty_ldisc o_ldisc, new_ldisc;
+       int work;
+       unsigned long flags;
+       struct tty_struct *o_tty;
+
+restart:
+       /* This is a bit ugly for now but means we can break the 'ldisc
+          is part of the tty struct' assumption later */
+       retval = tty_ldisc_get(ldisc, &new_ldisc);
+       if (retval)
+               return retval;
+
+       /*
+        *      Problem: What do we do if this blocks ?
+        */
+
+       tty_wait_until_sent(tty, 0);
+
+       if (tty->ldisc.ops->num == ldisc) {
+               tty_ldisc_put(new_ldisc.ops);
+               return 0;
+       }
+
+       /*
+        *      No more input please, we are switching. The new ldisc
+        *      will update this value in the ldisc open function
+        */
+
+       tty->receive_room = 0;
+
+       o_ldisc = tty->ldisc;
+       o_tty = tty->link;
+
+       /*
+        *      Make sure we don't change while someone holds a
+        *      reference to the line discipline. The TTY_LDISC bit
+        *      prevents anyone taking a reference once it is clear.
+        *      We need the lock to avoid racing reference takers.
+        */
+
+       spin_lock_irqsave(&tty_ldisc_lock, flags);
+       if (tty->ldisc.refcount || (o_tty && o_tty->ldisc.refcount)) {
+               if (tty->ldisc.refcount) {
+                       /* Free the new ldisc we grabbed. Must drop the lock
+                          first. */
+                       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+                       tty_ldisc_put(o_ldisc.ops);
+                       /*
+                        * There are several reasons we may be busy, including
+                        * random momentary I/O traffic. We must therefore
+                        * retry. We could distinguish between blocking ops
+                        * and retries if we made tty_ldisc_wait() smarter.
+                        * That is up for discussion.
+                        */
+                       if (wait_event_interruptible(tty_ldisc_wait, tty->ldisc.refcount == 0) < 0)
+                               return -ERESTARTSYS;
+                       goto restart;
+               }
+               if (o_tty && o_tty->ldisc.refcount) {
+                       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+                       tty_ldisc_put(o_tty->ldisc.ops);
+                       if (wait_event_interruptible(tty_ldisc_wait, o_tty->ldisc.refcount == 0) < 0)
+                               return -ERESTARTSYS;
+                       goto restart;
+               }
+       }
+       /*
+        *      If the TTY_LDISC bit is set, then we are racing against
+        *      another ldisc change
+        */
+       if (!test_bit(TTY_LDISC, &tty->flags)) {
+               struct tty_ldisc *ld;
+               spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+               tty_ldisc_put(new_ldisc.ops);
+               ld = tty_ldisc_ref_wait(tty);
+               tty_ldisc_deref(ld);
+               goto restart;
+       }
+
+       clear_bit(TTY_LDISC, &tty->flags);
+       if (o_tty)
+               clear_bit(TTY_LDISC, &o_tty->flags);
+       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+       
+       /*
+        *      From this point on we know nobody has an ldisc
+        *      usage reference, nor can they obtain one until
+        *      we say so later on.
+        */
+
+       work = cancel_delayed_work(&tty->buf.work);
+       /*
+        * Wait for ->hangup_work and ->buf.work handlers to terminate
+        * MUST NOT hold locks here.
+        */
+       flush_scheduled_work();
+       /* Shutdown the current discipline. */
+       if (o_ldisc.ops->close)
+               (o_ldisc.ops->close)(tty);
+
+       /* Now set up the new line discipline. */
+       tty_ldisc_assign(tty, &new_ldisc);
+       tty_set_termios_ldisc(tty, ldisc);
+       if (new_ldisc.ops->open)
+               retval = (new_ldisc.ops->open)(tty);
+       if (retval < 0) {
+               tty_ldisc_put(new_ldisc.ops);
+               tty_ldisc_restore(tty, &o_ldisc);
+       }
+       /* At this point we hold a reference to the new ldisc and a
+          a reference to the old ldisc. If we ended up flipping back
+          to the existing ldisc we have two references to it */
+
+       if (tty->ldisc.ops->num != o_ldisc.ops->num && tty->ops->set_ldisc)
+               tty->ops->set_ldisc(tty);
+
+       tty_ldisc_put(o_ldisc.ops);
+
+       /*
+        *      Allow ldisc referencing to occur as soon as the driver
+        *      ldisc callback completes.
+        */
+
+       tty_ldisc_enable(tty);
+       if (o_tty)
+               tty_ldisc_enable(o_tty);
+
+       /* Restart it in case no characters kick it off. Safe if
+          already running */
+       if (work)
+               schedule_delayed_work(&tty->buf.work, 1);
+       return retval;
+}
+
+
+/**
+ *     tty_ldisc_setup                 -       open line discipline
+ *     @tty: tty being shut down
+ *     @o_tty: pair tty for pty/tty pairs
+ *
+ *     Called during the initial open of a tty/pty pair in order to set up the
+ *     line discplines and bind them to the tty.
+ */
+
+int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty)
+{
+       struct tty_ldisc *ld = &tty->ldisc;
+       int retval;
+
+       if (ld->ops->open) {
+               retval = (ld->ops->open)(tty);
+               if (retval)
+                       return retval;
+       }
+       if (o_tty && o_tty->ldisc.ops->open) {
+               retval = (o_tty->ldisc.ops->open)(o_tty);
+               if (retval) {
+                       if (ld->ops->close)
+                               (ld->ops->close)(tty);
+                       return retval;
+               }
+               tty_ldisc_enable(o_tty);
+       }
+       tty_ldisc_enable(tty);
+       return 0;
+}
+
+/**
+ *     tty_ldisc_release               -       release line discipline
+ *     @tty: tty being shut down
+ *     @o_tty: pair tty for pty/tty pairs
+ *
+ *     Called during the final close of a tty/pty pair in order to shut down the
+ *     line discpline layer.
+ */
+
+void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
+{
+       unsigned long flags;
+       struct tty_ldisc ld;
+       /*
+        * Prevent flush_to_ldisc() from rescheduling the work for later.  Then
+        * kill any delayed work. As this is the final close it does not
+        * race with the set_ldisc code path.
+        */
+       clear_bit(TTY_LDISC, &tty->flags);
+       cancel_delayed_work(&tty->buf.work);
+
+       /*
+        * Wait for ->hangup_work and ->buf.work handlers to terminate
+        */
+
+       flush_scheduled_work();
+
+       /*
+        * Wait for any short term users (we know they are just driver
+        * side waiters as the file is closing so user count on the file
+        * side is zero.
+        */
+       spin_lock_irqsave(&tty_ldisc_lock, flags);
+       while (tty->ldisc.refcount) {
+               spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+               wait_event(tty_ldisc_wait, tty->ldisc.refcount == 0);
+               spin_lock_irqsave(&tty_ldisc_lock, flags);
+       }
+       spin_unlock_irqrestore(&tty_ldisc_lock, flags);
+       /*
+        * Shutdown the current line discipline, and reset it to N_TTY.
+        *
+        * FIXME: this MUST get fixed for the new reflocking
+        */
+       if (tty->ldisc.ops->close)
+               (tty->ldisc.ops->close)(tty);
+       tty_ldisc_put(tty->ldisc.ops);
+
+       /*
+        *      Switch the line discipline back
+        */
+       WARN_ON(tty_ldisc_get(N_TTY, &ld));
+       tty_ldisc_assign(tty, &ld);
+       tty_set_termios_ldisc(tty, N_TTY);
+       if (o_tty) {
+               /* FIXME: could o_tty be in setldisc here ? */
+               clear_bit(TTY_LDISC, &o_tty->flags);
+               if (o_tty->ldisc.ops->close)
+                       (o_tty->ldisc.ops->close)(o_tty);
+               tty_ldisc_put(o_tty->ldisc.ops);
+               WARN_ON(tty_ldisc_get(N_TTY, &ld));
+               tty_ldisc_assign(o_tty, &ld);
+               tty_set_termios_ldisc(o_tty, N_TTY);
+       }
+}
+
+/**
+ *     tty_ldisc_init          -       ldisc setup for new tty
+ *     @tty: tty being allocated
+ *
+ *     Set up the line discipline objects for a newly allocated tty. Note that
+ *     the tty structure is not completely set up when this call is made.
+ */
+
+void tty_ldisc_init(struct tty_struct *tty)
+{
+       struct tty_ldisc ld;
+       if (tty_ldisc_get(N_TTY, &ld) < 0)
+               panic("n_tty: init_tty");
+       tty_ldisc_assign(tty, &ld);
+}
+
+void tty_ldisc_begin(void)
+{
+       /* Setup the default TTY line discipline. */
+       (void) tty_register_ldisc(N_TTY, &tty_ldisc_N_TTY);
+}
index eebfad2..c2ae52d 100644 (file)
@@ -481,10 +481,10 @@ static struct class *vc_class;
 
 void vcs_make_sysfs(struct tty_struct *tty)
 {
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
-                       "vcs%u", tty->index + 1);
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
-                       "vcsa%u", tty->index + 1);
+       device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1),
+                             NULL, "vcs%u", tty->index + 1);
+       device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129),
+                             NULL, "vcsa%u", tty->index + 1);
 }
 
 void vcs_remove_sysfs(struct tty_struct *tty)
@@ -499,7 +499,7 @@ int __init vcs_init(void)
                panic("unable to get major %d for vcs device", VCS_MAJOR);
        vc_class = class_create(THIS_MODULE, "vc");
 
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), "vcs");
-       device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), "vcsa");
+       device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
+       device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
        return 0;
 }
index e5da98d..7a70a40 100644 (file)
@@ -886,10 +886,10 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
        state[i].cur_part = 0;
        for (j = 0; j < MAX_PARTITIONS; ++j)
                state[i].part_stat_rwi[j] = VIOT_IDLE;
-       device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i),
-                       "iseries!vt%d", i);
-       device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
-                       "iseries!nvt%d", i);
+       device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i),
+                             NULL, "iseries!vt%d", i);
+       device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
+                             NULL, "iseries!nvt%d", i);
        printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries "
                        "resource %10.10s type %4.4s, model %3.3s\n",
                        i, viotape_unitinfo[i].rsrcname,
index f17ac04..69c5afe 100644 (file)
@@ -85,7 +85,7 @@ static irqreturn_t scc_rx_int(int irq, void *data);
 static irqreturn_t scc_stat_int(int irq, void *data);
 static irqreturn_t scc_spcond_int(int irq, void *data);
 static void scc_setsignals(struct scc_port *port, int dtr, int rts);
-static void scc_break_ctl(struct tty_struct *tty, int break_state);
+static int scc_break_ctl(struct tty_struct *tty, int break_state);
 
 static struct tty_driver *scc_driver;
 
@@ -942,7 +942,7 @@ static int scc_ioctl(struct tty_struct *tty, struct file *file,
 }
 
 
-static void scc_break_ctl(struct tty_struct *tty, int break_state)
+static int scc_break_ctl(struct tty_struct *tty, int break_state)
 {
        struct scc_port *port = (struct scc_port *)tty->driver_data;
        unsigned long   flags;
@@ -952,6 +952,7 @@ static void scc_break_ctl(struct tty_struct *tty, int break_state)
        SCCmod(TX_CTRL_REG, ~TCR_SEND_BREAK, 
                        break_state ? TCR_SEND_BREAK : 0);
        local_irq_restore(flags);
+       return 0;
 }
 
 
index 935f1c2..e32a076 100644 (file)
@@ -3425,9 +3425,10 @@ int register_con_driver(const struct consw *csw, int first, int last)
        if (retval)
                goto err;
 
-       con_driver->dev = device_create(vtconsole_class, NULL,
-                                       MKDEV(0, con_driver->node),
-                                       "vtcon%i", con_driver->node);
+       con_driver->dev = device_create_drvdata(vtconsole_class, NULL,
+                                               MKDEV(0, con_driver->node),
+                                               NULL, "vtcon%i",
+                                               con_driver->node);
 
        if (IS_ERR(con_driver->dev)) {
                printk(KERN_WARNING "Unable to create device for %s; "
@@ -3535,9 +3536,10 @@ static int __init vtconsole_class_init(void)
                struct con_driver *con = &registered_con_driver[i];
 
                if (con->con && !con->dev) {
-                       con->dev = device_create(vtconsole_class, NULL,
-                                                MKDEV(0, con->node),
-                                                "vtcon%i", con->node);
+                       con->dev = device_create_drvdata(vtconsole_class, NULL,
+                                                        MKDEV(0, con->node),
+                                                        NULL, "vtcon%i",
+                                                        con->node);
 
                        if (IS_ERR(con->dev)) {
                                printk(KERN_WARNING "Unable to create "
index 1e1b81e..51966cc 100644 (file)
@@ -658,8 +658,9 @@ static int __devinit hwicap_setup(struct device *dev, int id,
                dev_err(dev, "cdev_add() failed\n");
                goto failed3;
        }
-       /*  devfs_mk_cdev(devt, S_IFCHR|S_IRUGO|S_IWUGO, DRIVER_NAME); */
-       device_create(icap_class, dev, devt, "%s%d", DRIVER_NAME, id);
+
+       device_create_drvdata(icap_class, dev, devt, NULL,
+                             "%s%d", DRIVER_NAME, id);
        return 0;               /* success */
 
  failed3:
index e949618..31a0e0b 100644 (file)
@@ -21,7 +21,8 @@ static int __init cpuidle_sysfs_setup(char *unused)
 }
 __setup("cpuidle_sysfs_switch", cpuidle_sysfs_setup);
 
-static ssize_t show_available_governors(struct sys_device *dev, char *buf)
+static ssize_t show_available_governors(struct sys_device *dev,
+               struct sysdev_attribute *attr, char *buf)
 {
        ssize_t i = 0;
        struct cpuidle_governor *tmp;
@@ -39,7 +40,8 @@ out:
        return i;
 }
 
-static ssize_t show_current_driver(struct sys_device *dev, char *buf)
+static ssize_t show_current_driver(struct sys_device *dev,
+               struct sysdev_attribute *attr, char *buf)
 {
        ssize_t ret;
 
@@ -53,7 +55,8 @@ static ssize_t show_current_driver(struct sys_device *dev, char *buf)
        return ret;
 }
 
-static ssize_t show_current_governor(struct sys_device *dev, char *buf)
+static ssize_t show_current_governor(struct sys_device *dev,
+                       struct sysdev_attribute *attr, char *buf)
 {
        ssize_t ret;
 
@@ -68,6 +71,7 @@ static ssize_t show_current_governor(struct sys_device *dev, char *buf)
 }
 
 static ssize_t store_current_governor(struct sys_device *dev,
+       struct sysdev_attribute *attr,
        const char *buf, size_t count)
 {
        char gov_name[CPUIDLE_NAME_LEN];
index 011328f..9a70377 100644 (file)
@@ -14,8 +14,9 @@ int dca_sysfs_add_req(struct dca_provider *dca, struct device *dev, int slot)
 {
        struct device *cd;
 
-       cd = device_create(dca_class, dca->cd, MKDEV(0, slot + 1),
-                          "requester%d", slot);
+       cd = device_create_drvdata(dca_class, dca->cd,
+                                  MKDEV(0, slot + 1), NULL,
+                                  "requester%d", slot);
        if (IS_ERR(cd))
                return PTR_ERR(cd);
        return 0;
@@ -46,7 +47,8 @@ idr_try_again:
                return err;
        }
 
-       cd = device_create(dca_class, dev, MKDEV(0, 0), "dca%d", dca->id);
+       cd = device_create_drvdata(dca_class, dev, MKDEV(0, 0), NULL,
+                                  "dca%d", dca->id);
        if (IS_ERR(cd)) {
                spin_lock(&dca_idr_lock);
                idr_remove(&dca_idr, dca->id);
index b54112f..0e024fe 100644 (file)
@@ -33,7 +33,7 @@ static void cell_edac_count_ce(struct mem_ctl_info *mci, int chan, u64 ar)
 {
        struct cell_edac_priv           *priv = mci->pvt_info;
        struct csrow_info               *csrow = &mci->csrows[0];
-       unsigned long                   address, pfn, offset;
+       unsigned long                   address, pfn, offset, syndrome;
 
        dev_dbg(mci->dev, "ECC CE err on node %d, channel %d, ar = 0x%016lx\n",
                priv->node, chan, ar);
@@ -44,10 +44,11 @@ static void cell_edac_count_ce(struct mem_ctl_info *mci, int chan, u64 ar)
                address = (address << 1) | chan;
        pfn = address >> PAGE_SHIFT;
        offset = address & ~PAGE_MASK;
+       syndrome = (ar & 0x000000001fe00000ul) >> 21;
 
        /* TODO: Decoding of the error addresss */
        edac_mc_handle_ce(mci, csrow->first_page + pfn, offset,
-                         0, 0, chan, "");
+                         syndrome, 0, chan, "");
 }
 
 static void cell_edac_count_ue(struct mem_ctl_info *mci, int chan, u64 ar)
index 70abf93..5369ce9 100644 (file)
@@ -9,7 +9,7 @@ obj-${CONFIG_EISA_VIRTUAL_ROOT} += virtual_root.o
 
 
 # Ugly hack to get DEVICE_NAME_SIZE value...
-DEVICE_NAME_SIZE =$(shell awk '$$1=="\#define" && $$2=="DEVICE_NAME_SIZE" {print $$3-1}' $(srctree)/include/linux/device.h)
+DEVICE_NAME_SIZE = 50
 
 $(obj)/eisa-bus.o: $(obj)/devlist.h
 
index 65dcf04..c950bf8 100644 (file)
@@ -22,7 +22,7 @@
 
 struct eisa_device_info {
        struct eisa_device_id id;
-       char name[DEVICE_NAME_SIZE];
+       char name[50];
 };
 
 #ifdef CONFIG_EISA_NAMES
@@ -63,7 +63,7 @@ static void __init eisa_name_device (struct eisa_device *edev)
                if (!strcmp (edev->id.sig, eisa_table[i].id.sig)) {
                        strlcpy (edev->pretty_name,
                                 eisa_table[i].name,
-                                DEVICE_NAME_SIZE);
+                                sizeof(edev->pretty_name));
                        return;
                }
        }
index 008c38b..fced190 100644 (file)
@@ -45,7 +45,7 @@ config GPIO_PCA953X
          will be called pca953x.
 
 config GPIO_PCF857X
-       tristate "PCF857x, PCA857x, and PCA967x I2C GPIO expanders"
+       tristate "PCF857x, PCA{85,96}7x, and MAX732[89] I2C GPIO expanders"
        depends on I2C
        help
          Say yes here to provide access to most "quasi-bidirectional" I2C
@@ -54,7 +54,8 @@ config GPIO_PCF857X
          some of them.  Compatible models include:
 
          8 bits:   pcf8574, pcf8574a, pca8574, pca8574a,
-                   pca9670, pca9672, pca9674, pca9674a
+                   pca9670, pca9672, pca9674, pca9674a,
+                   max7328, max7329
 
          16 bits:  pcf8575, pcf8575c, pca8575,
                    pca9671, pca9673, pca9675
@@ -69,6 +70,12 @@ config GPIO_PCF857X
 
 comment "SPI GPIO expanders:"
 
+config GPIO_MAX7301
+       tristate "Maxim MAX7301 GPIO expander"
+       depends on SPI_MASTER
+       help
+         gpio driver for Maxim MAX7301 SPI GPIO expander.
+
 config GPIO_MCP23S08
        tristate "Microchip MCP23S08 I/O expander"
        depends on SPI_MASTER
index fdde992..16e796d 100644 (file)
@@ -4,6 +4,7 @@ ccflags-$(CONFIG_DEBUG_GPIO)    += -DDEBUG
 
 obj-$(CONFIG_HAVE_GPIO_LIB)    += gpiolib.o
 
+obj-$(CONFIG_GPIO_MAX7301)     += max7301.o
 obj-$(CONFIG_GPIO_MCP23S08)    += mcp23s08.o
 obj-$(CONFIG_GPIO_PCA953X)     += pca953x.o
 obj-$(CONFIG_GPIO_PCF857X)     += pcf857x.o
diff --git a/drivers/gpio/max7301.c b/drivers/gpio/max7301.c
new file mode 100644 (file)
index 0000000..39c795a
--- /dev/null
@@ -0,0 +1,339 @@
+/**
+ * drivers/gpio/max7301.c
+ *
+ * Copyright (C) 2006 Juergen Beisert, Pengutronix
+ * Copyright (C) 2008 Guennadi Liakhovetski, Pengutronix
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * The Maxim's MAX7301 device is an SPI driven GPIO expander. There are
+ * 28 GPIOs. 8 of them can trigger an interrupt. See datasheet for more
+ * details
+ * Note:
+ * - DIN must be stable at the rising edge of clock.
+ * - when writing:
+ *   - always clock in 16 clocks at once
+ *   - at DIN: D15 first, D0 last
+ *   - D0..D7 = databyte, D8..D14 = commandbyte
+ *   - D15 = low -> write command
+ * - when reading
+ *   - always clock in 16 clocks at once
+ *   - at DIN: D15 first, D0 last
+ *   - D0..D7 = dummy, D8..D14 = register address
+ *   - D15 = high -> read command
+ *   - raise CS and assert it again
+ *   - always clock in 16 clocks at once
+ *   - at DOUT: D15 first, D0 last
+ *   - D0..D7 contains the data from the first cycle
+ *
+ * The driver exports a standard gpiochip interface
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/mutex.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/max7301.h>
+#include <linux/gpio.h>
+
+#define DRIVER_NAME "max7301"
+
+/*
+ * Pin configurations, see MAX7301 datasheet page 6
+ */
+#define PIN_CONFIG_MASK 0x03
+#define PIN_CONFIG_IN_PULLUP 0x03
+#define PIN_CONFIG_IN_WO_PULLUP 0x02
+#define PIN_CONFIG_OUT 0x01
+
+#define PIN_NUMBER 28
+
+
+/*
+ * Some registers must be read back to modify.
+ * To save time we cache them here in memory
+ */
+struct max7301 {
+       struct mutex    lock;
+       u8              port_config[8]; /* field 0 is unused */
+       u32             out_level;      /* cached output levels */
+       struct gpio_chip chip;
+       struct spi_device *spi;
+};
+
+/**
+ * max7301_write - Write a new register content
+ * @spi: The SPI device
+ * @reg: Register offset
+ * @val: Value to write
+ *
+ * A write to the MAX7301 means one message with one transfer
+ *
+ * Returns 0 if successful or a negative value on error
+ */
+static int max7301_write(struct spi_device *spi, unsigned int reg, unsigned int val)
+{
+       u16 word = ((reg & 0x7F) << 8) | (val & 0xFF);
+       return spi_write(spi, (const u8 *)&word, sizeof(word));
+}
+
+/**
+ * max7301_read - Read back register content
+ * @spi: The SPI device
+ * @reg: Register offset
+ *
+ * A read from the MAX7301 means two transfers; here, one message each
+ *
+ * Returns positive 8 bit value from device if successful or a
+ * negative value on error
+ */
+static int max7301_read(struct spi_device *spi, unsigned int reg)
+{
+       int ret;
+       u16 word;
+
+       word = 0x8000 | (reg << 8);
+       ret = spi_write(spi, (const u8 *)&word, sizeof(word));
+       if (ret)
+               return ret;
+       /*
+        * This relies on the fact, that a transfer with NULL tx_buf shifts out
+        * zero bytes (=NOOP for MAX7301)
+        */
+       ret = spi_read(spi, (u8 *)&word, sizeof(word));
+       if (ret)
+               return ret;
+       return word & 0xff;
+}
+
+static int max7301_direction_input(struct gpio_chip *chip, unsigned offset)
+{
+       struct max7301 *ts = container_of(chip, struct max7301, chip);
+       u8 *config;
+       int ret;
+
+       /* First 4 pins are unused in the controller */
+       offset += 4;
+
+       config = &ts->port_config[offset >> 2];
+
+       mutex_lock(&ts->lock);
+
+       /* Standard GPIO API doesn't support pull-ups, has to be extended.
+        * Hard-coding no pollup for now. */
+       *config = (*config & ~(3 << (offset & 3))) | (1 << (offset & 3));
+
+       ret = max7301_write(ts->spi, 0x08 + (offset >> 2), *config);
+
+       mutex_unlock(&ts->lock);
+
+       return ret;
+}
+
+static int __max7301_set(struct max7301 *ts, unsigned offset, int value)
+{
+       if (value) {
+               ts->out_level |= 1 << offset;
+               return max7301_write(ts->spi, 0x20 + offset, 0x01);
+       } else {
+               ts->out_level &= ~(1 << offset);
+               return max7301_write(ts->spi, 0x20 + offset, 0x00);
+       }
+}
+
+static int max7301_direction_output(struct gpio_chip *chip, unsigned offset,
+                                   int value)
+{
+       struct max7301 *ts = container_of(chip, struct max7301, chip);
+       u8 *config;
+       int ret;
+
+       /* First 4 pins are unused in the controller */
+       offset += 4;
+
+       config = &ts->port_config[offset >> 2];
+
+       mutex_lock(&ts->lock);
+
+       *config = (*config & ~(3 << (offset & 3))) | (1 << (offset & 3));
+
+       ret = __max7301_set(ts, offset, value);
+
+       if (!ret)
+               ret = max7301_write(ts->spi, 0x08 + (offset >> 2), *config);
+
+       mutex_unlock(&ts->lock);
+
+       return ret;
+}
+
+static int max7301_get(struct gpio_chip *chip, unsigned offset)
+{
+       struct max7301 *ts = container_of(chip, struct max7301, chip);
+       int config, level = -EINVAL;
+
+       /* First 4 pins are unused in the controller */
+       offset += 4;
+
+       mutex_lock(&ts->lock);
+
+       config = (ts->port_config[offset >> 2] >> ((offset & 3) * 2)) & 3;
+
+       switch (config) {
+       case 1:
+               /* Output: return cached level */
+               level =  !!(ts->out_level & (1 << offset));
+               break;
+       case 2:
+       case 3:
+               /* Input: read out */
+               level = max7301_read(ts->spi, 0x20 + offset) & 0x01;
+       }
+       mutex_unlock(&ts->lock);
+
+       return level;
+}
+
+static void max7301_set(struct gpio_chip *chip, unsigned offset, int value)
+{
+       struct max7301 *ts = container_of(chip, struct max7301, chip);
+
+       /* First 4 pins are unused in the controller */
+       offset += 4;
+
+       mutex_lock(&ts->lock);
+
+       __max7301_set(ts, offset, value);
+
+       mutex_unlock(&ts->lock);
+}
+
+static int __devinit max7301_probe(struct spi_device *spi)
+{
+       struct max7301 *ts;
+       struct max7301_platform_data *pdata;
+       int i, ret;
+
+       pdata = spi->dev.platform_data;
+       if (!pdata || !pdata->base)
+               return -ENODEV;
+
+       /*
+        * bits_per_word cannot be configured in platform data
+        */
+       spi->bits_per_word = 16;
+
+       ret = spi_setup(spi);
+       if (ret < 0)
+               return ret;
+
+       ts = kzalloc(sizeof(struct max7301), GFP_KERNEL);
+       if (!ts)
+               return -ENOMEM;
+
+       mutex_init(&ts->lock);
+
+       dev_set_drvdata(&spi->dev, ts);
+
+       /* Power up the chip and disable IRQ output */
+       max7301_write(spi, 0x04, 0x01);
+
+       ts->spi = spi;
+
+       ts->chip.label = DRIVER_NAME,
+
+       ts->chip.direction_input = max7301_direction_input;
+       ts->chip.get = max7301_get;
+       ts->chip.direction_output = max7301_direction_output;
+       ts->chip.set = max7301_set;
+
+       ts->chip.base = pdata->base;
+       ts->chip.ngpio = PIN_NUMBER;
+       ts->chip.can_sleep = 1;
+       ts->chip.dev = &spi->dev;
+       ts->chip.owner = THIS_MODULE;
+
+       ret = gpiochip_add(&ts->chip);
+       if (ret)
+               goto exit_destroy;
+
+       /*
+        * tristate all pins in hardware and cache the
+        * register values for later use.
+        */
+       for (i = 1; i < 8; i++) {
+               int j;
+               /* 0xAA means input with internal pullup disabled */
+               max7301_write(spi, 0x08 + i, 0xAA);
+               ts->port_config[i] = 0xAA;
+               for (j = 0; j < 4; j++) {
+                       int idx = ts->chip.base + (i - 1) * 4 + j;
+                       ret = gpio_direction_input(idx);
+                       if (ret)
+                               goto exit_remove;
+                       gpio_free(idx);
+               }
+       }
+       return ret;
+
+exit_remove:
+       gpiochip_remove(&ts->chip);
+exit_destroy:
+       dev_set_drvdata(&spi->dev, NULL);
+       mutex_destroy(&ts->lock);
+       kfree(ts);
+       return ret;
+}
+
+static int max7301_remove(struct spi_device *spi)
+{
+       struct max7301 *ts;
+       int ret;
+
+       ts = dev_get_drvdata(&spi->dev);
+       if (ts == NULL)
+               return -ENODEV;
+
+       dev_set_drvdata(&spi->dev, NULL);
+
+       /* Power down the chip and disable IRQ output */
+       max7301_write(spi, 0x04, 0x00);
+
+       ret = gpiochip_remove(&ts->chip);
+       if (!ret) {
+               mutex_destroy(&ts->lock);
+               kfree(ts);
+       } else
+               dev_err(&spi->dev, "Failed to remove the GPIO controller: %d\n",
+                       ret);
+
+       return ret;
+}
+
+static struct spi_driver max7301_driver = {
+       .driver = {
+               .name           = DRIVER_NAME,
+               .owner          = THIS_MODULE,
+       },
+       .probe          = max7301_probe,
+       .remove         = __devexit_p(max7301_remove),
+};
+
+static int __init max7301_init(void)
+{
+       return spi_register_driver(&max7301_driver);
+}
+
+static void __exit max7301_exit(void)
+{
+       spi_unregister_driver(&max7301_driver);
+}
+
+module_init(max7301_init);
+module_exit(max7301_exit);
+
+MODULE_AUTHOR("Juergen Beisert");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("MAX7301 SPI based GPIO-Expander");
index aa6cc8b..d25d356 100644 (file)
@@ -37,6 +37,8 @@ static const struct i2c_device_id pcf857x_id[] = {
        { "pca9671", 16 },
        { "pca9673", 16 },
        { "pca9675", 16 },
+       { "max7328", 8 },
+       { "max7329", 8 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, pcf857x_id);
@@ -56,6 +58,7 @@ MODULE_DEVICE_TABLE(i2c, pcf857x_id);
 struct pcf857x {
        struct gpio_chip        chip;
        struct i2c_client       *client;
+       struct mutex            lock;           /* protect 'out' */
        unsigned                out;            /* software latch */
 };
 
@@ -66,9 +69,14 @@ struct pcf857x {
 static int pcf857x_input8(struct gpio_chip *chip, unsigned offset)
 {
        struct pcf857x  *gpio = container_of(chip, struct pcf857x, chip);
+       int             status;
 
+       mutex_lock(&gpio->lock);
        gpio->out |= (1 << offset);
-       return i2c_smbus_write_byte(gpio->client, gpio->out);
+       status = i2c_smbus_write_byte(gpio->client, gpio->out);
+       mutex_unlock(&gpio->lock);
+
+       return status;
 }
 
 static int pcf857x_get8(struct gpio_chip *chip, unsigned offset)
@@ -84,12 +92,17 @@ static int pcf857x_output8(struct gpio_chip *chip, unsigned offset, int value)
 {
        struct pcf857x  *gpio = container_of(chip, struct pcf857x, chip);
        unsigned        bit = 1 << offset;
+       int             status;
 
+       mutex_lock(&gpio->lock);
        if (value)
                gpio->out |= bit;
        else
                gpio->out &= ~bit;
-       return i2c_smbus_write_byte(gpio->client, gpio->out);
+       status = i2c_smbus_write_byte(gpio->client, gpio->out);
+       mutex_unlock(&gpio->lock);
+
+       return status;
 }
 
 static void pcf857x_set8(struct gpio_chip *chip, unsigned offset, int value)
@@ -124,9 +137,14 @@ static int i2c_read_le16(struct i2c_client *client)
 static int pcf857x_input16(struct gpio_chip *chip, unsigned offset)
 {
        struct pcf857x  *gpio = container_of(chip, struct pcf857x, chip);
+       int             status;
 
+       mutex_lock(&gpio->lock);
        gpio->out |= (1 << offset);
-       return i2c_write_le16(gpio->client, gpio->out);
+       status = i2c_write_le16(gpio->client, gpio->out);
+       mutex_unlock(&gpio->lock);
+
+       return status;
 }
 
 static int pcf857x_get16(struct gpio_chip *chip, unsigned offset)
@@ -142,12 +160,17 @@ static int pcf857x_output16(struct gpio_chip *chip, unsigned offset, int value)
 {
        struct pcf857x  *gpio = container_of(chip, struct pcf857x, chip);
        unsigned        bit = 1 << offset;
+       int             status;
 
+       mutex_lock(&gpio->lock);
        if (value)
                gpio->out |= bit;
        else
                gpio->out &= ~bit;
-       return i2c_write_le16(gpio->client, gpio->out);
+       status = i2c_write_le16(gpio->client, gpio->out);
+       mutex_unlock(&gpio->lock);
+
+       return status;
 }
 
 static void pcf857x_set16(struct gpio_chip *chip, unsigned offset, int value)
@@ -173,6 +196,8 @@ static int pcf857x_probe(struct i2c_client *client,
        if (!gpio)
                return -ENOMEM;
 
+       mutex_init(&gpio->lock);
+
        gpio->chip.base = pdata->gpio_base;
        gpio->chip.can_sleep = 1;
        gpio->chip.owner = THIS_MODULE;
index 2fde6c6..0c6b4d4 100644 (file)
@@ -322,8 +322,9 @@ int hidraw_connect(struct hid_device *hid)
                goto out;
        }
 
-       dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor),
-                               "%s%d", "hidraw", minor);
+       dev->dev = device_create_drvdata(hidraw_class, NULL,
+                                        MKDEV(hidraw_major, minor), NULL,
+                                        "%s%d", "hidraw", minor);
 
        if (IS_ERR(dev->dev)) {
                spin_lock(&minors_lock);
index 3db2845..7321a88 100644 (file)
@@ -55,7 +55,8 @@ again:
                return ERR_PTR(err);
 
        id = id & MAX_ID_MASK;
-       hwdev = device_create(hwmon_class, dev, MKDEV(0,0), HWMON_ID_FORMAT, id);
+       hwdev = device_create_drvdata(hwmon_class, dev, MKDEV(0, 0), NULL,
+                                     HWMON_ID_FORMAT, id);
 
        if (IS_ERR(hwdev)) {
                spin_lock(&idr_lock);
index 7608df8..7bf38c4 100644 (file)
@@ -722,7 +722,8 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
 
        INIT_LIST_HEAD(&driver->clients);
        /* Walk the adapters that are already present */
-       class_for_each_device(&i2c_adapter_class, driver, __attach_adapter);
+       class_for_each_device(&i2c_adapter_class, NULL, driver,
+                             __attach_adapter);
 
        mutex_unlock(&core_lock);
        return 0;
@@ -782,7 +783,8 @@ void i2c_del_driver(struct i2c_driver *driver)
 {
        mutex_lock(&core_lock);
 
-       class_for_each_device(&i2c_adapter_class, driver, __detach_adapter);
+       class_for_each_device(&i2c_adapter_class, NULL, driver,
+                             __detach_adapter);
 
        driver_unregister(&driver->driver);
        pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
index 86727fa..9d55c63 100644 (file)
@@ -521,9 +521,9 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
                return PTR_ERR(i2c_dev);
 
        /* register this i2c device with the driver core */
-       i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
-                                    MKDEV(I2C_MAJOR, adap->nr),
-                                    "i2c-%d", adap->nr);
+       i2c_dev->dev = device_create_drvdata(i2c_dev_class, &adap->dev,
+                                            MKDEV(I2C_MAJOR, adap->nr),
+                                            NULL, "i2c-%d", adap->nr);
        if (IS_ERR(i2c_dev->dev)) {
                res = PTR_ERR(i2c_dev->dev);
                goto error;
index b711ab9..353dd11 100644 (file)
@@ -2697,10 +2697,12 @@ static int ide_tape_probe(ide_drive_t *drive)
 
        idetape_setup(drive, tape, minor);
 
-       device_create(idetape_sysfs_class, &drive->gendev,
-                     MKDEV(IDETAPE_MAJOR, minor), "%s", tape->name);
-       device_create(idetape_sysfs_class, &drive->gendev,
-                       MKDEV(IDETAPE_MAJOR, minor + 128), "n%s", tape->name);
+       device_create_drvdata(idetape_sysfs_class, &drive->gendev,
+                             MKDEV(IDETAPE_MAJOR, minor), NULL,
+                             "%s", tape->name);
+       device_create_drvdata(idetape_sysfs_class, &drive->gendev,
+                             MKDEV(IDETAPE_MAJOR, minor + 128), NULL,
+                             "n%s", tape->name);
 
        g->fops = &idetape_block_ops;
        ide_register_region(g);
index 9d19aec..b6eb2cf 100644 (file)
@@ -2296,9 +2296,10 @@ static void dv1394_add_host(struct hpsb_host *host)
 
        ohci = (struct ti_ohci *)host->hostdata;
 
-       device_create(hpsb_protocol_class, NULL, MKDEV(
-               IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)),
-               "dv1394-%d", id);
+       device_create_drvdata(hpsb_protocol_class, NULL,
+                             MKDEV(IEEE1394_MAJOR,
+                                   IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), NULL,
+                             "dv1394-%d", id);
 
        dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE);
        dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
index 05710c7..994a21e 100644 (file)
@@ -754,7 +754,8 @@ static void nodemgr_remove_uds(struct node_entry *ne)
         */
        mutex_lock(&nodemgr_serialize_remove_uds);
        for (;;) {
-               dev = class_find_device(&nodemgr_ud_class, ne, __match_ne);
+               dev = class_find_device(&nodemgr_ud_class, NULL, ne,
+                                       __match_ne);
                if (!dev)
                        break;
                ud = container_of(dev, struct unit_directory, unit_dev);
@@ -901,7 +902,8 @@ static struct node_entry *find_entry_by_guid(u64 guid)
        struct device *dev;
        struct node_entry *ne;
 
-       dev = class_find_device(&nodemgr_ne_class, &guid, __match_ne_guid);
+       dev = class_find_device(&nodemgr_ne_class, NULL, &guid,
+                               __match_ne_guid);
        if (!dev)
                return NULL;
        ne = container_of(dev, struct node_entry, node_dev);
@@ -940,7 +942,8 @@ static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host,
        param.host = host;
        param.nodeid = nodeid;
 
-       dev = class_find_device(&nodemgr_ne_class, &param, __match_ne_nodeid);
+       dev = class_find_device(&nodemgr_ne_class, NULL, &param,
+                               __match_ne_nodeid);
        if (!dev)
                return NULL;
        ne = container_of(dev, struct node_entry, node_dev);
@@ -1453,7 +1456,8 @@ static void nodemgr_suspend_ne(struct node_entry *ne)
        ne->in_limbo = 1;
        WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo));
 
-       class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_driver_suspend);
+       class_for_each_device(&nodemgr_ud_class, NULL, ne,
+                             __nodemgr_driver_suspend);
 }
 
 
@@ -1462,7 +1466,8 @@ static void nodemgr_resume_ne(struct node_entry *ne)
        ne->in_limbo = 0;
        device_remove_file(&ne->device, &dev_attr_ne_in_limbo);
 
-       class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_driver_resume);
+       class_for_each_device(&nodemgr_ud_class, NULL, ne,
+                             __nodemgr_driver_resume);
        HPSB_DEBUG("Node resumed: ID:BUS[" NODE_BUS_FMT "]  GUID[%016Lx]",
                   NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid);
 }
@@ -1498,7 +1503,8 @@ static int __nodemgr_update_pdrv(struct device *dev, void *data)
 
 static void nodemgr_update_pdrv(struct node_entry *ne)
 {
-       class_for_each_device(&nodemgr_ud_class, ne, __nodemgr_update_pdrv);
+       class_for_each_device(&nodemgr_ud_class, NULL, ne,
+                             __nodemgr_update_pdrv);
 }
 
 
@@ -1591,7 +1597,8 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
         * while probes are time-consuming. (Well, those probes need some
         * improvement...) */
 
-       class_for_each_device(&nodemgr_ne_class, &param, __nodemgr_node_probe);
+       class_for_each_device(&nodemgr_ne_class, NULL, &param,
+                             __nodemgr_node_probe);
 
        /* If we had a bus reset while we were scanning the bus, it is
         * possible that we did not probe all nodes.  In that case, we
@@ -1826,7 +1833,7 @@ int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *))
 
        hip.cb = cb;
        hip.data = data;
-       error = class_for_each_device(&hpsb_host_class, &hip,
+       error = class_for_each_device(&hpsb_host_class, NULL, &hip,
                                      __nodemgr_for_each_host);
 
        return error;
index 96f2847..6fa9e4a 100644 (file)
@@ -3010,10 +3010,10 @@ static int __init init_raw1394(void)
        hpsb_register_highlevel(&raw1394_highlevel);
 
        if (IS_ERR
-           (device_create(
+           (device_create_drvdata(
              hpsb_protocol_class, NULL,
              MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
-             RAW1394_DEVICE_NAME))) {
+             NULL, RAW1394_DEVICE_NAME))) {
                ret = -EFAULT;
                goto out_unreg;
        }
index 069b9f6..25db6e6 100644 (file)
@@ -1341,9 +1341,9 @@ static void video1394_add_host (struct hpsb_host *host)
        hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id);
 
        minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id;
-       device_create(hpsb_protocol_class, NULL,
-                     MKDEV(IEEE1394_MAJOR, minor),
-                     "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
+       device_create_drvdata(hpsb_protocol_class, NULL,
+                             MKDEV(IEEE1394_MAJOR, minor), NULL,
+                             "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id);
 }
 
 
index 55738ee..922d35f 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/spinlock.h>
 #include <linux/sysfs.h>
 #include <linux/workqueue.h>
+#include <linux/kdev_t.h>
 
 #include <rdma/ib_cache.h>
 #include <rdma/ib_cm.h>
@@ -162,8 +163,8 @@ struct cm_port {
 
 struct cm_device {
        struct list_head list;
-       struct ib_device *device;
-       struct kobject dev_obj;
+       struct ib_device *ib_device;
+       struct device *device;
        u8 ack_delay;
        struct cm_port *port[0];
 };
@@ -339,7 +340,7 @@ static void cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc,
 {
        av->port = port;
        av->pkey_index = wc->pkey_index;
-       ib_init_ah_from_wc(port->cm_dev->device, port->port_num, wc,
+       ib_init_ah_from_wc(port->cm_dev->ib_device, port->port_num, wc,
                           grh, &av->ah_attr);
 }
 
@@ -353,7 +354,7 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
 
        read_lock_irqsave(&cm.device_lock, flags);
        list_for_each_entry(cm_dev, &cm.device_list, list) {
-               if (!ib_find_cached_gid(cm_dev->device, &path->sgid,
+               if (!ib_find_cached_gid(cm_dev->ib_device, &path->sgid,
                                        &p, NULL)) {
                        port = cm_dev->port[p-1];
                        break;
@@ -364,13 +365,13 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
        if (!port)
                return -EINVAL;
 
-       ret = ib_find_cached_pkey(cm_dev->device, port->port_num,
+       ret = ib_find_cached_pkey(cm_dev->ib_device, port->port_num,
                                  be16_to_cpu(path->pkey), &av->pkey_index);
        if (ret)
                return ret;
 
        av->port = port;
-       ib_init_ah_from_path(cm_dev->device, port->port_num, path,
+       ib_init_ah_from_path(cm_dev->ib_device, port->port_num, path,
                             &av->ah_attr);
        av->timeout = path->packet_life_time + 1;
        return 0;
@@ -1515,7 +1516,7 @@ static int cm_req_handler(struct cm_work *work)
 
        req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
 
-       cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL);
+       cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
        if (IS_ERR(cm_id))
                return PTR_ERR(cm_id);
 
@@ -1550,7 +1551,7 @@ static int cm_req_handler(struct cm_work *work)
        cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]);
        ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av);
        if (ret) {
-               ib_get_cached_gid(work->port->cm_dev->device,
+               ib_get_cached_gid(work->port->cm_dev->ib_device,
                                  work->port->port_num, 0, &work->path[0].sgid);
                ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID,
                               &work->path[0].sgid, sizeof work->path[0].sgid,
@@ -2950,7 +2951,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
        struct cm_sidr_req_msg *sidr_req_msg;
        struct ib_wc *wc;
 
-       cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL);
+       cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
        if (IS_ERR(cm_id))
                return PTR_ERR(cm_id);
        cm_id_priv = container_of(cm_id, struct cm_id_private, id);
@@ -3578,7 +3579,7 @@ static void cm_get_ack_delay(struct cm_device *cm_dev)
 {
        struct ib_device_attr attr;
 
-       if (ib_query_device(cm_dev->device, &attr))
+       if (ib_query_device(cm_dev->ib_device, &attr))
                cm_dev->ack_delay = 0; /* acks will rely on packet life time */
        else
                cm_dev->ack_delay = attr.local_ca_ack_delay;
@@ -3618,18 +3619,6 @@ static struct kobj_type cm_port_obj_type = {
        .release = cm_release_port_obj
 };
 
-static void cm_release_dev_obj(struct kobject *obj)
-{
-       struct cm_device *cm_dev;
-
-       cm_dev = container_of(obj, struct cm_device, dev_obj);
-       kfree(cm_dev);
-}
-
-static struct kobj_type cm_dev_obj_type = {
-       .release = cm_release_dev_obj
-};
-
 struct class cm_class = {
        .name    = "infiniband_cm",
 };
@@ -3640,7 +3629,7 @@ static int cm_create_port_fs(struct cm_port *port)
        int i, ret;
 
        ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type,
-                                  &port->cm_dev->dev_obj,
+                                  &port->cm_dev->device->kobj,
                                   "%d", port->port_num);
        if (ret) {
                kfree(port);
@@ -3676,7 +3665,7 @@ static void cm_remove_port_fs(struct cm_port *port)
        kobject_put(&port->port_obj);
 }
 
-static void cm_add_one(struct ib_device *device)
+static void cm_add_one(struct ib_device *ib_device)
 {
        struct cm_device *cm_dev;
        struct cm_port *port;
@@ -3691,26 +3680,27 @@ static void cm_add_one(struct ib_device *device)
        int ret;
        u8 i;
 
-       if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+       if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB)
                return;
 
        cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) *
-                        device->phys_port_cnt, GFP_KERNEL);
+                        ib_device->phys_port_cnt, GFP_KERNEL);
        if (!cm_dev)
                return;
 
-       cm_dev->device = device;
+       cm_dev->ib_device = ib_device;
        cm_get_ack_delay(cm_dev);
 
-       ret = kobject_init_and_add(&cm_dev->dev_obj, &cm_dev_obj_type,
-                                  &cm_class.subsys.kobj, "%s", device->name);
-       if (ret) {
+       cm_dev->device = device_create_drvdata(&cm_class, &ib_device->dev,
+                                              MKDEV(0, 0), NULL,
+                                              "%s", ib_device->name);
+       if (!cm_dev->device) {
                kfree(cm_dev);
                return;
        }
 
        set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
-       for (i = 1; i <= device->phys_port_cnt; i++) {
+       for (i = 1; i <= ib_device->phys_port_cnt; i++) {
                port = kzalloc(sizeof *port, GFP_KERNEL);
                if (!port)
                        goto error1;
@@ -3723,7 +3713,7 @@ static void cm_add_one(struct ib_device *device)
                if (ret)
                        goto error1;
 
-               port->mad_agent = ib_register_mad_agent(device, i,
+               port->mad_agent = ib_register_mad_agent(ib_device, i,
                                                        IB_QPT_GSI,
                                                        &reg_req,
                                                        0,
@@ -3733,11 +3723,11 @@ static void cm_add_one(struct ib_device *device)
                if (IS_ERR(port->mad_agent))
                        goto error2;
 
-               ret = ib_modify_port(device, i, 0, &port_modify);
+               ret = ib_modify_port(ib_device, i, 0, &port_modify);
                if (ret)
                        goto error3;
        }
-       ib_set_client_data(device, &cm_client, cm_dev);
+       ib_set_client_data(ib_device, &cm_client, cm_dev);
 
        write_lock_irqsave(&cm.device_lock, flags);
        list_add_tail(&cm_dev->list, &cm.device_list);
@@ -3753,14 +3743,14 @@ error1:
        port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
        while (--i) {
                port = cm_dev->port[i-1];
-               ib_modify_port(device, port->port_num, 0, &port_modify);
+               ib_modify_port(ib_device, port->port_num, 0, &port_modify);
                ib_unregister_mad_agent(port->mad_agent);
                cm_remove_port_fs(port);
        }
-       kobject_put(&cm_dev->dev_obj);
+       device_unregister(cm_dev->device);
 }
 
-static void cm_remove_one(struct ib_device *device)
+static void cm_remove_one(struct ib_device *ib_device)
 {
        struct cm_device *cm_dev;
        struct cm_port *port;
@@ -3770,7 +3760,7 @@ static void cm_remove_one(struct ib_device *device)
        unsigned long flags;
        int i;
 
-       cm_dev = ib_get_client_data(device, &cm_client);
+       cm_dev = ib_get_client_data(ib_device, &cm_client);
        if (!cm_dev)
                return;
 
@@ -3778,14 +3768,14 @@ static void cm_remove_one(struct ib_device *device)
        list_del(&cm_dev->list);
        write_unlock_irqrestore(&cm.device_lock, flags);
 
-       for (i = 1; i <= device->phys_port_cnt; i++) {
+       for (i = 1; i <= ib_device->phys_port_cnt; i++) {
                port = cm_dev->port[i-1];
-               ib_modify_port(device, port->port_num, 0, &port_modify);
+               ib_modify_port(ib_device, port->port_num, 0, &port_modify);
                ib_unregister_mad_agent(port->mad_agent);
                flush_workqueue(cm.wq);
                cm_remove_port_fs(port);
        }
-       kobject_put(&cm_dev->dev_obj);
+       device_unregister(cm_dev->device);
 }
 
 static int __init ib_cm_init(void)
index 35f301c..56c0eda 100644 (file)
@@ -2455,7 +2455,7 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops,
                goto err_cdev;
        }
 
-       device = device_create(ipath_class, NULL, dev, name);
+       device = device_create_drvdata(ipath_class, NULL, dev, NULL, name);
 
        if (IS_ERR(device)) {
                ret = PTR_ERR(device);
index 8a35029..871b0cb 100644 (file)
@@ -1302,11 +1302,12 @@ static void capinc_tty_hangup(struct tty_struct *tty)
 #endif
 }
 
-static void capinc_tty_break_ctl(struct tty_struct *tty, int state)
+static int capinc_tty_break_ctl(struct tty_struct *tty, int state)
 {
 #ifdef _DEBUG_TTYFUNCS
        printk(KERN_DEBUG "capinc_tty_break_ctl(%d)\n", state);
 #endif
+       return 0;
 }
 
 static void capinc_tty_flush_buffer(struct tty_struct *tty)
@@ -1552,7 +1553,8 @@ static int __init capi_init(void)
                return PTR_ERR(capi_class);
        }
 
-       device_create(capi_class, NULL, MKDEV(capi_major, 0), "capi");
+       device_create_drvdata(capi_class, NULL, MKDEV(capi_major, 0), NULL,
+                             "capi");
 
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
        if (capinc_tty_init() < 0) {
index e5d4468..cae5248 100644 (file)
@@ -862,7 +862,8 @@ adbdev_init(void)
        adb_dev_class = class_create(THIS_MODULE, "adb");
        if (IS_ERR(adb_dev_class))
                return;
-       device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), "adb");
+       device_create_drvdata(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL,
+                             "adb");
 
        platform_device_register(&adb_pfdev);
        platform_driver_probe(&adb_pfdrv, adb_dummy_probe);
index 67b8e94..ef2dbfe 100644 (file)
@@ -40,7 +40,7 @@ static struct mca_bus *mca_root_busses[MAX_MCA_BUSSES];
 
 struct mca_device_info {
        short pos_id;           /* the 2 byte pos id for this card */
-       char name[DEVICE_NAME_SIZE];
+       char name[50];
 };
 
 static int mca_bus_match (struct device *dev, struct device_driver *drv)
index e208a60..e713277 100644 (file)
@@ -233,9 +233,9 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
 
        mutex_unlock(&dvbdev_register_lock);
 
-       clsdev = device_create(dvb_class, adap->device,
+       clsdev = device_create_drvdata(dvb_class, adap->device,
                               MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
-                              "dvb%d.%s%d", adap->num, dnames[type], id);
+                              NULL, "dvb%d.%s%d", adap->num, dnames[type], id);
        if (IS_ERR(clsdev)) {
                printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n",
                       __func__, adap->num, dnames[type], id, PTR_ERR(clsdev));
index a054668..4e3bfbc 100644 (file)
@@ -51,7 +51,7 @@ struct jmb38x_ms_host {
        void __iomem            *addr;
        spinlock_t              lock;
        int                     id;
-       char                    host_id[DEVICE_ID_SIZE];
+       char                    host_id[32];
        int                     irq;
        unsigned int            block_pos;
        unsigned long           timeout_jiffies;
@@ -781,7 +781,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
 
        spin_lock_init(&host->lock);
        host->id = cnt;
-       snprintf(host->host_id, DEVICE_ID_SIZE, DRIVER_NAME ":slot%d",
+       snprintf(host->host_id, sizeof(host->host_id), DRIVER_NAME ":slot%d",
                 host->id);
        host->irq = jm->pdev->irq;
        host->timeout_jiffies = msecs_to_jiffies(1000);
index 75e599b..34402c4 100644 (file)
@@ -1670,7 +1670,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
        INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work);
        spin_lock_init(&ioc->fault_reset_work_lock);
 
-       snprintf(ioc->reset_work_q_name, KOBJ_NAME_LEN, "mpt_poll_%d", ioc->id);
+       snprintf(ioc->reset_work_q_name, sizeof(ioc->reset_work_q_name),
+                "mpt_poll_%d", ioc->id);
        ioc->reset_work_q =
                create_singlethread_workqueue(ioc->reset_work_q_name);
        if (!ioc->reset_work_q) {
index 6adab64..dff048c 100644 (file)
@@ -707,12 +707,12 @@ typedef struct _MPT_ADAPTER
        u8                       fc_link_speed[2];
        spinlock_t               fc_rescan_work_lock;
        struct work_struct       fc_rescan_work;
-       char                     fc_rescan_work_q_name[KOBJ_NAME_LEN];
+       char                     fc_rescan_work_q_name[20];
        struct workqueue_struct *fc_rescan_work_q;
        struct scsi_cmnd        **ScsiLookup;
        spinlock_t                scsi_lookup_lock;
 
-       char                     reset_work_q_name[KOBJ_NAME_LEN];
+       char                     reset_work_q_name[20];
        struct workqueue_struct *reset_work_q;
        struct delayed_work      fault_reset_work;
        spinlock_t               fault_reset_work_lock;
index fc31ca6..b36cae9 100644 (file)
@@ -1326,8 +1326,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
        /* initialize workqueue */
 
-       snprintf(ioc->fc_rescan_work_q_name, KOBJ_NAME_LEN, "mptfc_wq_%d",
-               sh->host_no);
+       snprintf(ioc->fc_rescan_work_q_name, sizeof(ioc->fc_rescan_work_q_name),
+                "mptfc_wq_%d", sh->host_no);
        ioc->fc_rescan_work_q =
                create_singlethread_workqueue(ioc->fc_rescan_work_q_name);
        if (!ioc->fc_rescan_work_q)
index 1921b8d..ce67d97 100644 (file)
@@ -420,4 +420,17 @@ config SGI_XP
          this feature will allow for direct communication between SSIs
          based on a network adapter and DMA messaging.
 
+config HP_ILO
+       tristate "Channel interface driver for HP iLO/iLO2 processor"
+       default n
+       help
+         The channel interface driver allows applications to communicate
+         with iLO/iLO2 management processors present on HP ProLiant
+         servers.  Upon loading, the driver creates /dev/hpilo/dXccbN files,
+         which can be used to gather data from the management processor,
+         via read and write system calls.
+
+         To compile this driver as a module, choose M here: the
+         module will be called hpilo.
+
 endif # MISC_DEVICES
index a6dac6a..688fe76 100644 (file)
@@ -27,3 +27,4 @@ obj-$(CONFIG_INTEL_MENLOW)    += intel_menlow.o
 obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o
 obj-$(CONFIG_KGDB_TESTS)       += kgdbts.o
 obj-$(CONFIG_SGI_XP)           += sgi-xp/
+obj-$(CONFIG_HP_ILO)           += hpilo.o
diff --git a/drivers/misc/hpilo.c b/drivers/misc/hpilo.c
new file mode 100644 (file)
index 0000000..05e2982
--- /dev/null
@@ -0,0 +1,768 @@
+/*
+ * Driver for HP iLO/iLO2 management processor.
+ *
+ * Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
+ *     David Altobelli <david.altobelli@hp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/pci.h>
+#include <linux/ioport.h>
+#include <linux/device.h>
+#include <linux/file.h>
+#include <linux/cdev.h>
+#include <linux/spinlock.h>
+#include <linux/delay.h>
+#include <linux/uaccess.h>
+#include <linux/io.h>
+#include "hpilo.h"
+
+static struct class *ilo_class;
+static unsigned int ilo_major;
+static char ilo_hwdev[MAX_ILO_DEV];
+
+static inline int get_entry_id(int entry)
+{
+       return (entry & ENTRY_MASK_DESCRIPTOR) >> ENTRY_BITPOS_DESCRIPTOR;
+}
+
+static inline int get_entry_len(int entry)
+{
+       return ((entry & ENTRY_MASK_QWORDS) >> ENTRY_BITPOS_QWORDS) << 3;
+}
+
+static inline int mk_entry(int id, int len)
+{
+       int qlen = len & 7 ? (len >> 3) + 1 : len >> 3;
+       return id << ENTRY_BITPOS_DESCRIPTOR | qlen << ENTRY_BITPOS_QWORDS;
+}
+
+static inline int desc_mem_sz(int nr_entry)
+{
+       return nr_entry << L2_QENTRY_SZ;
+}
+
+/*
+ * FIFO queues, shared with hardware.
+ *
+ * If a queue has empty slots, an entry is added to the queue tail,
+ * and that entry is marked as occupied.
+ * Entries can be dequeued from the head of the list, when the device
+ * has marked the entry as consumed.
+ *
+ * Returns true on successful queue/dequeue, false on failure.
+ */
+static int fifo_enqueue(struct ilo_hwinfo *hw, char *fifobar, int entry)
+{
+       struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar);
+       int ret = 0;
+
+       spin_lock(&hw->fifo_lock);
+       if (!(fifo_q->fifobar[(fifo_q->tail + 1) & fifo_q->imask]
+             & ENTRY_MASK_O)) {
+               fifo_q->fifobar[fifo_q->tail & fifo_q->imask] |=
+                               (entry & ENTRY_MASK_NOSTATE) | fifo_q->merge;
+               fifo_q->tail += 1;
+               ret = 1;
+       }
+       spin_unlock(&hw->fifo_lock);
+
+       return ret;
+}
+
+static int fifo_dequeue(struct ilo_hwinfo *hw, char *fifobar, int *entry)
+{
+       struct fifo *fifo_q = FIFOBARTOHANDLE(fifobar);
+       int ret = 0;
+       u64 c;
+
+       spin_lock(&hw->fifo_lock);
+       c = fifo_q->fifobar[fifo_q->head & fifo_q->imask];
+       if (c & ENTRY_MASK_C) {
+               if (entry)
+                       *entry = c & ENTRY_MASK_NOSTATE;
+
+               fifo_q->fifobar[fifo_q->head & fifo_q->imask] =
+                                                       (c | ENTRY_MASK) + 1;
+               fifo_q->head += 1;
+               ret = 1;
+       }
+       spin_unlock(&hw->fifo_lock);
+
+       return ret;
+}
+
+static int ilo_pkt_enqueue(struct ilo_hwinfo *hw, struct ccb *ccb,
+                          int dir, int id, int len)
+{
+       char *fifobar;
+       int entry;
+
+       if (dir == SENDQ)
+               fifobar = ccb->ccb_u1.send_fifobar;
+       else
+               fifobar = ccb->ccb_u3.recv_fifobar;
+
+       entry = mk_entry(id, len);
+       return fifo_enqueue(hw, fifobar, entry);
+}
+
+static int ilo_pkt_dequeue(struct ilo_hwinfo *hw, struct ccb *ccb,
+                          int dir, int *id, int *len, void **pkt)
+{
+       char *fifobar, *desc;
+       int entry = 0, pkt_id = 0;
+       int ret;
+
+       if (dir == SENDQ) {
+               fifobar = ccb->ccb_u1.send_fifobar;
+               desc = ccb->ccb_u2.send_desc;
+       } else {
+               fifobar = ccb->ccb_u3.recv_fifobar;
+               desc = ccb->ccb_u4.recv_desc;
+       }
+
+       ret = fifo_dequeue(hw, fifobar, &entry);
+       if (ret) {
+               pkt_id = get_entry_id(entry);
+               if (id)
+                       *id = pkt_id;
+               if (len)
+                       *len = get_entry_len(entry);
+               if (pkt)
+                       *pkt = (void *)(desc + desc_mem_sz(pkt_id));
+       }
+
+       return ret;
+}
+
+static inline void doorbell_set(struct ccb *ccb)
+{
+       iowrite8(1, ccb->ccb_u5.db_base);
+}
+
+static inline void doorbell_clr(struct ccb *ccb)
+{
+       iowrite8(2, ccb->ccb_u5.db_base);
+}
+static inline int ctrl_set(int l2sz, int idxmask, int desclim)
+{
+       int active = 0, go = 1;
+       return l2sz << CTRL_BITPOS_L2SZ |
+              idxmask << CTRL_BITPOS_FIFOINDEXMASK |
+              desclim << CTRL_BITPOS_DESCLIMIT |
+              active << CTRL_BITPOS_A |
+              go << CTRL_BITPOS_G;
+}
+static void ctrl_setup(struct ccb *ccb, int nr_desc, int l2desc_sz)
+{
+       /* for simplicity, use the same parameters for send and recv ctrls */
+       ccb->send_ctrl = ctrl_set(l2desc_sz, nr_desc-1, nr_desc-1);
+       ccb->recv_ctrl = ctrl_set(l2desc_sz, nr_desc-1, nr_desc-1);
+}
+
+static inline int fifo_sz(int nr_entry)
+{
+       /* size of a fifo is determined by the number of entries it contains */
+       return (nr_entry * sizeof(u64)) + FIFOHANDLESIZE;
+}
+
+static void fifo_setup(void *base_addr, int nr_entry)
+{
+       struct fifo *fifo_q = base_addr;
+       int i;
+
+       /* set up an empty fifo */
+       fifo_q->head = 0;
+       fifo_q->tail = 0;
+       fifo_q->reset = 0;
+       fifo_q->nrents = nr_entry;
+       fifo_q->imask = nr_entry - 1;
+       fifo_q->merge = ENTRY_MASK_O;
+
+       for (i = 0; i < nr_entry; i++)
+               fifo_q->fifobar[i] = 0;
+}
+
+static void ilo_ccb_close(struct pci_dev *pdev, struct ccb_data *data)
+{
+       struct ccb *driver_ccb;
+       struct ccb __iomem *device_ccb;
+       int retries;
+
+       driver_ccb = &data->driver_ccb;
+       device_ccb = data->mapped_ccb;
+
+       /* complicated dance to tell the hw we are stopping */
+       doorbell_clr(driver_ccb);
+       iowrite32(ioread32(&device_ccb->send_ctrl) & ~(1 << CTRL_BITPOS_G),
+                 &device_ccb->send_ctrl);
+       iowrite32(ioread32(&device_ccb->recv_ctrl) & ~(1 << CTRL_BITPOS_G),
+                 &device_ccb->recv_ctrl);
+
+       /* give iLO some time to process stop request */
+       for (retries = 1000; retries > 0; retries--) {
+               doorbell_set(driver_ccb);
+               udelay(1);
+               if (!(ioread32(&device_ccb->send_ctrl) & (1 << CTRL_BITPOS_A))
+                   &&
+                   !(ioread32(&device_ccb->recv_ctrl) & (1 << CTRL_BITPOS_A)))
+                       break;
+       }
+       if (retries == 0)
+               dev_err(&pdev->dev, "Closing, but controller still active\n");
+
+       /* clear the hw ccb */
+       memset_io(device_ccb, 0, sizeof(struct ccb));
+
+       /* free resources used to back send/recv queues */
+       pci_free_consistent(pdev, data->dma_size, data->dma_va, data->dma_pa);
+}
+
+static int ilo_ccb_open(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
+{
+       char *dma_va, *dma_pa;
+       int pkt_id, pkt_sz, i, error;
+       struct ccb *driver_ccb, *ilo_ccb;
+       struct pci_dev *pdev;
+
+       driver_ccb = &data->driver_ccb;
+       ilo_ccb = &data->ilo_ccb;
+       pdev = hw->ilo_dev;
+
+       data->dma_size = 2 * fifo_sz(NR_QENTRY) +
+                        2 * desc_mem_sz(NR_QENTRY) +
+                        ILO_START_ALIGN + ILO_CACHE_SZ;
+
+       error = -ENOMEM;
+       data->dma_va = pci_alloc_consistent(pdev, data->dma_size,
+                                           &data->dma_pa);
+       if (!data->dma_va)
+               goto out;
+
+       dma_va = (char *)data->dma_va;
+       dma_pa = (char *)data->dma_pa;
+
+       memset(dma_va, 0, data->dma_size);
+
+       dma_va = (char *)roundup((unsigned long)dma_va, ILO_START_ALIGN);
+       dma_pa = (char *)roundup((unsigned long)dma_pa, ILO_START_ALIGN);
+
+       /*
+        * Create two ccb's, one with virt addrs, one with phys addrs.
+        * Copy the phys addr ccb to device shared mem.
+        */
+       ctrl_setup(driver_ccb, NR_QENTRY, L2_QENTRY_SZ);
+       ctrl_setup(ilo_ccb, NR_QENTRY, L2_QENTRY_SZ);
+
+       fifo_setup(dma_va, NR_QENTRY);
+       driver_ccb->ccb_u1.send_fifobar = dma_va + FIFOHANDLESIZE;
+       ilo_ccb->ccb_u1.send_fifobar = dma_pa + FIFOHANDLESIZE;
+       dma_va += fifo_sz(NR_QENTRY);
+       dma_pa += fifo_sz(NR_QENTRY);
+
+       dma_va = (char *)roundup((unsigned long)dma_va, ILO_CACHE_SZ);
+       dma_pa = (char *)roundup((unsigned long)dma_pa, ILO_CACHE_SZ);
+
+       fifo_setup(dma_va, NR_QENTRY);
+       driver_ccb->ccb_u3.recv_fifobar = dma_va + FIFOHANDLESIZE;
+       ilo_ccb->ccb_u3.recv_fifobar = dma_pa + FIFOHANDLESIZE;
+       dma_va += fifo_sz(NR_QENTRY);
+       dma_pa += fifo_sz(NR_QENTRY);
+
+       driver_ccb->ccb_u2.send_desc = dma_va;
+       ilo_ccb->ccb_u2.send_desc = dma_pa;
+       dma_pa += desc_mem_sz(NR_QENTRY);
+       dma_va += desc_mem_sz(NR_QENTRY);
+
+       driver_ccb->ccb_u4.recv_desc = dma_va;
+       ilo_ccb->ccb_u4.recv_desc = dma_pa;
+
+       driver_ccb->channel = slot;
+       ilo_ccb->channel = slot;
+
+       driver_ccb->ccb_u5.db_base = hw->db_vaddr + (slot << L2_DB_SIZE);
+       ilo_ccb->ccb_u5.db_base = NULL; /* hw ccb's doorbell is not used */
+
+       /* copy the ccb with physical addrs to device memory */
+       data->mapped_ccb = (struct ccb __iomem *)
+                               (hw->ram_vaddr + (slot * ILOHW_CCB_SZ));
+       memcpy_toio(data->mapped_ccb, ilo_ccb, sizeof(struct ccb));
+
+       /* put packets on the send and receive queues */
+       pkt_sz = 0;
+       for (pkt_id = 0; pkt_id < NR_QENTRY; pkt_id++) {
+               ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, pkt_sz);
+               doorbell_set(driver_ccb);
+       }
+
+       pkt_sz = desc_mem_sz(1);
+       for (pkt_id = 0; pkt_id < NR_QENTRY; pkt_id++)
+               ilo_pkt_enqueue(hw, driver_ccb, RECVQ, pkt_id, pkt_sz);
+
+       doorbell_clr(driver_ccb);
+
+       /* make sure iLO is really handling requests */
+       for (i = 1000; i > 0; i--) {
+               if (ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, NULL, NULL))
+                       break;
+               udelay(1);
+       }
+
+       if (i) {
+               ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, 0);
+               doorbell_set(driver_ccb);
+       } else {
+               dev_err(&pdev->dev, "Open could not dequeue a packet\n");
+               error = -EBUSY;
+               goto free;
+       }
+
+       return 0;
+free:
+       pci_free_consistent(pdev, data->dma_size, data->dma_va, data->dma_pa);
+out:
+       return error;
+}
+
+static inline int is_channel_reset(struct ccb *ccb)
+{
+       /* check for this particular channel needing a reset */
+       return FIFOBARTOHANDLE(ccb->ccb_u1.send_fifobar)->reset;
+}
+
+static inline void set_channel_reset(struct ccb *ccb)
+{
+       /* set a flag indicating this channel needs a reset */
+       FIFOBARTOHANDLE(ccb->ccb_u1.send_fifobar)->reset = 1;
+}
+
+static inline int is_device_reset(struct ilo_hwinfo *hw)
+{
+       /* check for global reset condition */
+       return ioread32(&hw->mmio_vaddr[DB_OUT]) & (1 << DB_RESET);
+}
+
+static inline void clear_device(struct ilo_hwinfo *hw)
+{
+       /* clear the device (reset bits, pending channel entries) */
+       iowrite32(-1, &hw->mmio_vaddr[DB_OUT]);
+}
+
+static void ilo_locked_reset(struct ilo_hwinfo *hw)
+{
+       int slot;
+
+       /*
+        * Mapped memory is zeroed on ilo reset, so set a per ccb flag
+        * to indicate that this ccb needs to be closed and reopened.
+        */
+       for (slot = 0; slot < MAX_CCB; slot++) {
+               if (!hw->ccb_alloc[slot])
+                       continue;
+               set_channel_reset(&hw->ccb_alloc[slot]->driver_ccb);
+       }
+
+       clear_device(hw);
+}
+
+static void ilo_reset(struct ilo_hwinfo *hw)
+{
+       spin_lock(&hw->alloc_lock);
+
+       /* reset might have been handled after lock was taken */
+       if (is_device_reset(hw))
+               ilo_locked_reset(hw);
+
+       spin_unlock(&hw->alloc_lock);
+}
+
+static ssize_t ilo_read(struct file *fp, char __user *buf,
+                       size_t len, loff_t *off)
+{
+       int err, found, cnt, pkt_id, pkt_len;
+       struct ccb_data *data;
+       struct ccb *driver_ccb;
+       struct ilo_hwinfo *hw;
+       void *pkt;
+
+       data = fp->private_data;
+       driver_ccb = &data->driver_ccb;
+       hw = data->ilo_hw;
+
+       if (is_device_reset(hw) || is_channel_reset(driver_ccb)) {
+               /*
+                * If the device has been reset, applications
+                * need to close and reopen all ccbs.
+                */
+               ilo_reset(hw);
+               return -ENODEV;
+       }
+
+       /*
+        * This function is to be called when data is expected
+        * in the channel, and will return an error if no packet is found
+        * during the loop below.  The sleep/retry logic is to allow
+        * applications to call read() immediately post write(),
+        * and give iLO some time to process the sent packet.
+        */
+       cnt = 20;
+       do {
+               /* look for a received packet */
+               found = ilo_pkt_dequeue(hw, driver_ccb, RECVQ, &pkt_id,
+                                       &pkt_len, &pkt);
+               if (found)
+                       break;
+               cnt--;
+               msleep(100);
+       } while (!found && cnt);
+
+       if (!found)
+               return -EAGAIN;
+
+       /* only copy the length of the received packet */
+       if (pkt_len < len)
+               len = pkt_len;
+
+       err = copy_to_user(buf, pkt, len);
+
+       /* return the received packet to the queue */
+       ilo_pkt_enqueue(hw, driver_ccb, RECVQ, pkt_id, desc_mem_sz(1));
+
+       return err ? -EFAULT : len;
+}
+
+static ssize_t ilo_write(struct file *fp, const char __user *buf,
+                        size_t len, loff_t *off)
+{
+       int err, pkt_id, pkt_len;
+       struct ccb_data *data;
+       struct ccb *driver_ccb;
+       struct ilo_hwinfo *hw;
+       void *pkt;
+
+       data = fp->private_data;
+       driver_ccb = &data->driver_ccb;
+       hw = data->ilo_hw;
+
+       if (is_device_reset(hw) || is_channel_reset(driver_ccb)) {
+               /*
+                * If the device has been reset, applications
+                * need to close and reopen all ccbs.
+                */
+               ilo_reset(hw);
+               return -ENODEV;
+       }
+
+       /* get a packet to send the user command */
+       if (!ilo_pkt_dequeue(hw, driver_ccb, SENDQ, &pkt_id, &pkt_len, &pkt))
+               return -EBUSY;
+
+       /* limit the length to the length of the packet */
+       if (pkt_len < len)
+               len = pkt_len;
+
+       /* on failure, set the len to 0 to return empty packet to the device */
+       err = copy_from_user(pkt, buf, len);
+       if (err)
+               len = 0;
+
+       /* send the packet */
+       ilo_pkt_enqueue(hw, driver_ccb, SENDQ, pkt_id, len);
+       doorbell_set(driver_ccb);
+
+       return err ? -EFAULT : len;
+}
+
+static int ilo_close(struct inode *ip, struct file *fp)
+{
+       int slot;
+       struct ccb_data *data;
+       struct ilo_hwinfo *hw;
+
+       slot = iminor(ip) % MAX_CCB;
+       hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev);
+
+       spin_lock(&hw->alloc_lock);
+
+       if (is_device_reset(hw))
+               ilo_locked_reset(hw);
+
+       if (hw->ccb_alloc[slot]->ccb_cnt == 1) {
+
+               data = fp->private_data;
+
+               ilo_ccb_close(hw->ilo_dev, data);
+
+               kfree(data);
+               hw->ccb_alloc[slot] = NULL;
+       } else
+               hw->ccb_alloc[slot]->ccb_cnt--;
+
+       spin_unlock(&hw->alloc_lock);
+
+       return 0;
+}
+
+static int ilo_open(struct inode *ip, struct file *fp)
+{
+       int slot, error;
+       struct ccb_data *data;
+       struct ilo_hwinfo *hw;
+
+       slot = iminor(ip) % MAX_CCB;
+       hw = container_of(ip->i_cdev, struct ilo_hwinfo, cdev);
+
+       /* new ccb allocation */
+       data = kzalloc(sizeof(*data), GFP_KERNEL);
+       if (!data)
+               return -ENOMEM;
+
+       spin_lock(&hw->alloc_lock);
+
+       if (is_device_reset(hw))
+               ilo_locked_reset(hw);
+
+       /* each fd private_data holds sw/hw view of ccb */
+       if (hw->ccb_alloc[slot] == NULL) {
+               /* create a channel control block for this minor */
+               error = ilo_ccb_open(hw, data, slot);
+               if (!error) {
+                       hw->ccb_alloc[slot] = data;
+                       hw->ccb_alloc[slot]->ccb_cnt = 1;
+                       hw->ccb_alloc[slot]->ccb_excl = fp->f_flags & O_EXCL;
+                       hw->ccb_alloc[slot]->ilo_hw = hw;
+               } else
+                       kfree(data);
+       } else {
+               kfree(data);
+               if (fp->f_flags & O_EXCL || hw->ccb_alloc[slot]->ccb_excl) {
+                       /*
+                        * The channel exists, and either this open
+                        * or a previous open of this channel wants
+                        * exclusive access.
+                        */
+                       error = -EBUSY;
+               } else {
+                       hw->ccb_alloc[slot]->ccb_cnt++;
+                       error = 0;
+               }
+       }
+       spin_unlock(&hw->alloc_lock);
+
+       if (!error)
+               fp->private_data = hw->ccb_alloc[slot];
+
+       return error;
+}
+
+static const struct file_operations ilo_fops = {
+       .owner          = THIS_MODULE,
+       .read           = ilo_read,
+       .write          = ilo_write,
+       .open           = ilo_open,
+       .release        = ilo_close,
+};
+
+static void ilo_unmap_device(struct pci_dev *pdev, struct ilo_hwinfo *hw)
+{
+       pci_iounmap(pdev, hw->db_vaddr);
+       pci_iounmap(pdev, hw->ram_vaddr);
+       pci_iounmap(pdev, hw->mmio_vaddr);
+}
+
+static int __devinit ilo_map_device(struct pci_dev *pdev, struct ilo_hwinfo *hw)
+{
+       int error = -ENOMEM;
+
+       /* map the memory mapped i/o registers */
+       hw->mmio_vaddr = pci_iomap(pdev, 1, 0);
+       if (hw->mmio_vaddr == NULL) {
+               dev_err(&pdev->dev, "Error mapping mmio\n");
+               goto out;
+       }
+
+       /* map the adapter shared memory region */
+       hw->ram_vaddr = pci_iomap(pdev, 2, MAX_CCB * ILOHW_CCB_SZ);
+       if (hw->ram_vaddr == NULL) {
+               dev_err(&pdev->dev, "Error mapping shared mem\n");
+               goto mmio_free;
+       }
+
+       /* map the doorbell aperture */
+       hw->db_vaddr = pci_iomap(pdev, 3, MAX_CCB * ONE_DB_SIZE);
+       if (hw->db_vaddr == NULL) {
+               dev_err(&pdev->dev, "Error mapping doorbell\n");
+               goto ram_free;
+       }
+
+       return 0;
+ram_free:
+       pci_iounmap(pdev, hw->ram_vaddr);
+mmio_free:
+       pci_iounmap(pdev, hw->mmio_vaddr);
+out:
+       return error;
+}
+
+static void ilo_remove(struct pci_dev *pdev)
+{
+       int i, minor;
+       struct ilo_hwinfo *ilo_hw = pci_get_drvdata(pdev);
+
+       clear_device(ilo_hw);
+
+       minor = MINOR(ilo_hw->cdev.dev);
+       for (i = minor; i < minor + MAX_CCB; i++)
+               device_destroy(ilo_class, MKDEV(ilo_major, i));
+
+       cdev_del(&ilo_hw->cdev);
+       ilo_unmap_device(pdev, ilo_hw);
+       pci_release_regions(pdev);
+       pci_disable_device(pdev);
+       kfree(ilo_hw);
+       ilo_hwdev[(minor / MAX_CCB)] = 0;
+}
+
+static int __devinit ilo_probe(struct pci_dev *pdev,
+                              const struct pci_device_id *ent)
+{
+       int devnum, minor, start, error;
+       struct ilo_hwinfo *ilo_hw;
+
+       /* find a free range for device files */
+       for (devnum = 0; devnum < MAX_ILO_DEV; devnum++) {
+               if (ilo_hwdev[devnum] == 0) {
+                       ilo_hwdev[devnum] = 1;
+                       break;
+               }
+       }
+
+       if (devnum == MAX_ILO_DEV) {
+               dev_err(&pdev->dev, "Error finding free device\n");
+               return -ENODEV;
+       }
+
+       /* track global allocations for this device */
+       error = -ENOMEM;
+       ilo_hw = kzalloc(sizeof(*ilo_hw), GFP_KERNEL);
+       if (!ilo_hw)
+               goto out;
+
+       ilo_hw->ilo_dev = pdev;
+       spin_lock_init(&ilo_hw->alloc_lock);
+       spin_lock_init(&ilo_hw->fifo_lock);
+
+       error = pci_enable_device(pdev);
+       if (error)
+               goto free;
+
+       pci_set_master(pdev);
+
+       error = pci_request_regions(pdev, ILO_NAME);
+       if (error)
+               goto disable;
+
+       error = ilo_map_device(pdev, ilo_hw);
+       if (error)
+               goto free_regions;
+
+       pci_set_drvdata(pdev, ilo_hw);
+       clear_device(ilo_hw);
+
+       cdev_init(&ilo_hw->cdev, &ilo_fops);
+       ilo_hw->cdev.owner = THIS_MODULE;
+       start = devnum * MAX_CCB;
+       error = cdev_add(&ilo_hw->cdev, MKDEV(ilo_major, start), MAX_CCB);
+       if (error) {
+               dev_err(&pdev->dev, "Could not add cdev\n");
+               goto unmap;
+       }
+
+       for (minor = 0 ; minor < MAX_CCB; minor++) {
+               struct device *dev;
+               dev = device_create(ilo_class, &pdev->dev,
+                                   MKDEV(ilo_major, minor), NULL,
+                                   "hpilo!d%dccb%d", devnum, minor);
+               if (IS_ERR(dev))
+                       dev_err(&pdev->dev, "Could not create files\n");
+       }
+
+       return 0;
+unmap:
+       ilo_unmap_device(pdev, ilo_hw);
+free_regions:
+       pci_release_regions(pdev);
+disable:
+       pci_disable_device(pdev);
+free:
+       kfree(ilo_hw);
+out:
+       ilo_hwdev[devnum] = 0;
+       return error;
+}
+
+static struct pci_device_id ilo_devices[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB204) },
+       { }
+};
+MODULE_DEVICE_TABLE(pci, ilo_devices);
+
+static struct pci_driver ilo_driver = {
+       .name     = ILO_NAME,
+       .id_table = ilo_devices,
+       .probe    = ilo_probe,
+       .remove   = __devexit_p(ilo_remove),
+};
+
+static int __init ilo_init(void)
+{
+       int error;
+       dev_t dev;
+
+       ilo_class = class_create(THIS_MODULE, "iLO");
+       if (IS_ERR(ilo_class)) {
+               error = PTR_ERR(ilo_class);
+               goto out;
+       }
+
+       error = alloc_chrdev_region(&dev, 0, MAX_OPEN, ILO_NAME);
+       if (error)
+               goto class_destroy;
+
+       ilo_major = MAJOR(dev);
+
+       error = pci_register_driver(&ilo_driver);
+       if (error)
+               goto chr_remove;
+
+       return 0;
+chr_remove:
+       unregister_chrdev_region(dev, MAX_OPEN);
+class_destroy:
+       class_destroy(ilo_class);
+out:
+       return error;
+}
+
+static void __exit ilo_exit(void)
+{
+       pci_unregister_driver(&ilo_driver);
+       unregister_chrdev_region(MKDEV(ilo_major, 0), MAX_OPEN);
+       class_destroy(ilo_class);
+}
+
+MODULE_VERSION("0.05");
+MODULE_ALIAS(ILO_NAME);
+MODULE_DESCRIPTION(ILO_NAME);
+MODULE_AUTHOR("David Altobelli <david.altobelli@hp.com>");
+MODULE_LICENSE("GPL v2");
+
+module_init(ilo_init);
+module_exit(ilo_exit);
diff --git a/drivers/misc/hpilo.h b/drivers/misc/hpilo.h
new file mode 100644 (file)
index 0000000..a281207
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * linux/drivers/char/hpilo.h
+ *
+ * Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
+ *     David Altobelli <david.altobelli@hp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __HPILO_H
+#define __HPILO_H
+
+#define ILO_NAME "hpilo"
+
+/* max number of open channel control blocks per device, hw limited to 32 */
+#define MAX_CCB                8
+/* max number of supported devices */
+#define MAX_ILO_DEV    1
+/* max number of files */
+#define MAX_OPEN       (MAX_CCB * MAX_ILO_DEV)
+
+/*
+ * Per device, used to track global memory allocations.
+ */
+struct ilo_hwinfo {
+       /* mmio registers on device */
+       char __iomem *mmio_vaddr;
+
+       /* doorbell registers on device */
+       char __iomem *db_vaddr;
+
+       /* shared memory on device used for channel control blocks */
+       char __iomem *ram_vaddr;
+
+       /* files corresponding to this device */
+       struct ccb_data *ccb_alloc[MAX_CCB];
+
+       struct pci_dev *ilo_dev;
+
+       spinlock_t alloc_lock;
+       spinlock_t fifo_lock;
+
+       struct cdev cdev;
+};
+
+/* offset from mmio_vaddr */
+#define DB_OUT         0xD4
+/* DB_OUT reset bit */
+#define DB_RESET       26
+
+/*
+ * Channel control block. Used to manage hardware queues.
+ * The format must match hw's version.  The hw ccb is 128 bytes,
+ * but the context area shouldn't be touched by the driver.
+ */
+#define ILOSW_CCB_SZ   64
+#define ILOHW_CCB_SZ   128
+struct ccb {
+       union {
+               char *send_fifobar;
+               u64 padding1;
+       } ccb_u1;
+       union {
+               char *send_desc;
+               u64 padding2;
+       } ccb_u2;
+       u64 send_ctrl;
+
+       union {
+               char *recv_fifobar;
+               u64 padding3;
+       } ccb_u3;
+       union {
+               char *recv_desc;
+               u64 padding4;
+       } ccb_u4;
+       u64 recv_ctrl;
+
+       union {
+               char __iomem *db_base;
+               u64 padding5;
+       } ccb_u5;
+
+       u64 channel;
+
+       /* unused context area (64 bytes) */
+};
+
+/* ccb queue parameters */
+#define SENDQ          1
+#define RECVQ          2
+#define NR_QENTRY      4
+#define L2_QENTRY_SZ   12
+
+/* ccb ctrl bitfields */
+#define CTRL_BITPOS_L2SZ             0
+#define CTRL_BITPOS_FIFOINDEXMASK    4
+#define CTRL_BITPOS_DESCLIMIT        18
+#define CTRL_BITPOS_A                30
+#define CTRL_BITPOS_G                31
+
+/* ccb doorbell macros */
+#define L2_DB_SIZE             14
+#define ONE_DB_SIZE            (1 << L2_DB_SIZE)
+
+/*
+ * Per fd structure used to track the ccb allocated to that dev file.
+ */
+struct ccb_data {
+       /* software version of ccb, using virtual addrs */
+       struct ccb  driver_ccb;
+
+       /* hardware version of ccb, using physical addrs */
+       struct ccb  ilo_ccb;
+
+       /* hardware ccb is written to this shared mapped device memory */
+       struct ccb __iomem *mapped_ccb;
+
+       /* dma'able memory used for send/recv queues */
+       void       *dma_va;
+       dma_addr_t  dma_pa;
+       size_t      dma_size;
+
+       /* pointer to hardware device info */
+       struct ilo_hwinfo *ilo_hw;
+
+       /* usage count, to allow for shared ccb's */
+       int         ccb_cnt;
+
+       /* open wanted exclusive access to this ccb */
+       int         ccb_excl;
+};
+
+/*
+ * FIFO queue structure, shared with hw.
+ */
+#define ILO_START_ALIGN        4096
+#define ILO_CACHE_SZ    128
+struct fifo {
+    u64 nrents;        /* user requested number of fifo entries */
+    u64 imask;  /* mask to extract valid fifo index */
+    u64 merge; /*  O/C bits to merge in during enqueue operation */
+    u64 reset; /* set to non-zero when the target device resets */
+    u8  pad_0[ILO_CACHE_SZ - (sizeof(u64) * 4)];
+
+    u64 head;
+    u8  pad_1[ILO_CACHE_SZ - (sizeof(u64))];
+
+    u64 tail;
+    u8  pad_2[ILO_CACHE_SZ - (sizeof(u64))];
+
+    u64 fifobar[1];
+};
+
+/* convert between struct fifo, and the fifobar, which is saved in the ccb */
+#define FIFOHANDLESIZE (sizeof(struct fifo) - sizeof(u64))
+#define FIFOBARTOHANDLE(_fifo) \
+       ((struct fifo *)(((char *)(_fifo)) - FIFOHANDLESIZE))
+
+/* the number of qwords to consume from the entry descriptor */
+#define ENTRY_BITPOS_QWORDS      0
+/* descriptor index number (within a specified queue) */
+#define ENTRY_BITPOS_DESCRIPTOR  10
+/* state bit, fifo entry consumed by consumer */
+#define ENTRY_BITPOS_C           22
+/* state bit, fifo entry is occupied */
+#define ENTRY_BITPOS_O           23
+
+#define ENTRY_BITS_QWORDS        10
+#define ENTRY_BITS_DESCRIPTOR    12
+#define ENTRY_BITS_C             1
+#define ENTRY_BITS_O             1
+#define ENTRY_BITS_TOTAL       \
+       (ENTRY_BITS_C + ENTRY_BITS_O + \
+        ENTRY_BITS_QWORDS + ENTRY_BITS_DESCRIPTOR)
+
+/* extract various entry fields */
+#define ENTRY_MASK ((1 << ENTRY_BITS_TOTAL) - 1)
+#define ENTRY_MASK_C (((1 << ENTRY_BITS_C) - 1) << ENTRY_BITPOS_C)
+#define ENTRY_MASK_O (((1 << ENTRY_BITS_O) - 1) << ENTRY_BITPOS_O)
+#define ENTRY_MASK_QWORDS \
+       (((1 << ENTRY_BITS_QWORDS) - 1) << ENTRY_BITPOS_QWORDS)
+#define ENTRY_MASK_DESCRIPTOR \
+       (((1 << ENTRY_BITS_DESCRIPTOR) - 1) << ENTRY_BITPOS_DESCRIPTOR)
+
+#define ENTRY_MASK_NOSTATE (ENTRY_MASK >> (ENTRY_BITS_C + ENTRY_BITS_O))
+
+#endif /* __HPILO_H */
index 1861624..4ce3bdc 100644 (file)
@@ -399,8 +399,9 @@ static int __devinit phantom_probe(struct pci_dev *pdev,
                goto err_irq;
        }
 
-       if (IS_ERR(device_create(phantom_class, &pdev->dev, MKDEV(phantom_major,
-                       minor), "phantom%u", minor)))
+       if (IS_ERR(device_create_drvdata(phantom_class, &pdev->dev,
+                                        MKDEV(phantom_major, minor),
+                                        NULL, "phantom%u", minor)))
                dev_err(&pdev->dev, "can't create device\n");
 
        pci_set_drvdata(pdev, pht);
index 519d942..7b72a1b 100644 (file)
@@ -241,6 +241,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
 {
        struct block_device *bdev;
        struct block2mtd_dev *dev;
+       char *name;
 
        if (!devname)
                return NULL;
@@ -279,12 +280,13 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
 
        /* Setup the MTD structure */
        /* make the name contain the block device in */
-       dev->mtd.name = kmalloc(sizeof("block2mtd: ") + strlen(devname),
+       name = kmalloc(sizeof("block2mtd: ") + strlen(devname) + 1,
                        GFP_KERNEL);
-       if (!dev->mtd.name)
+       if (!name)
                goto devinit_err;
 
-       sprintf(dev->mtd.name, "block2mtd: %s", devname);
+       sprintf(name, "block2mtd: %s", devname);
+       dev->mtd.name = name;
 
        dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
        dev->mtd.erasesize = erase_size;
index 129d429..aef9f4b 100644 (file)
@@ -28,10 +28,13 @@ static void mtd_notify_add(struct mtd_info* mtd)
        if (!mtd)
                return;
 
-       device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), "mtd%d", mtd->index);
+       device_create_drvdata(mtd_class, NULL,
+                             MKDEV(MTD_CHAR_MAJOR, mtd->index*2),
+                             NULL, "mtd%d", mtd->index);
 
-       device_create(mtd_class, NULL,
-                     MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), "mtd%dro", mtd->index);
+       device_create_drvdata(mtd_class, NULL,
+                             MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1),
+                             NULL, "mtd%dro", mtd->index);
 }
 
 static void mtd_notify_remove(struct mtd_info* mtd)
index aabad8c..8db4e6b 100644 (file)
@@ -1010,7 +1010,7 @@ static int __devinit vortex_probe1(struct device *gendev,
        static int printed_version;
        int retval, print_info;
        struct vortex_chip_info * const vci = &vortex_info_tbl[chip_idx];
-       char *print_name = "3c59x";
+       const char *print_name = "3c59x";
        struct pci_dev *pdev = NULL;
        struct eisa_device *edev = NULL;
        DECLARE_MAC_BUF(mac);
index 1e39e78..71f7cec 100644 (file)
@@ -677,7 +677,7 @@ static void at91ether_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo
 {
        strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
        strlcpy(info->version, DRV_VERSION, sizeof(info->version));
-       strlcpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info));
+       strlcpy(info->bus_info, dev_name(dev->dev.parent), sizeof(info->bus_info));
 }
 
 static const struct ethtool_ops at91ether_ethtool_ops = {
index ecd8fc6..7a14980 100644 (file)
@@ -848,7 +848,7 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
 
        ep->res = request_mem_region(pdev->resource[0].start,
                        pdev->resource[0].end - pdev->resource[0].start + 1,
-                       pdev->dev.bus_id);
+                       dev_name(&pdev->dev));
        if (ep->res == NULL) {
                dev_err(&pdev->dev, "Could not reserve memory region\n");
                err = -ENOMEM;
index e9d15ec..5c5f1e4 100644 (file)
@@ -535,7 +535,7 @@ static int __init etherh_addr(char *addr, struct expansion_card *ec)
        
        if (!ecard_readchunk(&cd, ec, 0xf5, 0)) {
                printk(KERN_ERR "%s: unable to read podule description string\n",
-                      ec->dev.bus_id);
+                      dev_name(&ec->dev));
                goto no_addr;
        }
 
@@ -554,7 +554,7 @@ static int __init etherh_addr(char *addr, struct expansion_card *ec)
        }
 
        printk(KERN_ERR "%s: unable to parse MAC address: %s\n",
-              ec->dev.bus_id, cd.d.string);
+              dev_name(&ec->dev), cd.d.string);
 
  no_addr:
        return -ENODEV;
@@ -585,7 +585,7 @@ static void etherh_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i
 {
        strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
        strlcpy(info->version, DRV_VERSION, sizeof(info->version));
-       strlcpy(info->bus_info, dev->dev.parent->bus_id,
+       strlcpy(info->bus_info, dev_name(dev->dev.parent),
                sizeof(info->bus_info));
 }
 
index 1ffbe07..d4a305e 100644 (file)
@@ -8,12 +8,7 @@ fs_enet-$(CONFIG_FS_ENET_HAS_SCC) += mac-scc.o
 fs_enet-$(CONFIG_FS_ENET_HAS_FEC) += mac-fec.o
 fs_enet-$(CONFIG_FS_ENET_HAS_FCC) += mac-fcc.o
 
-ifeq ($(CONFIG_PPC_CPM_NEW_BINDING),y)
 obj-$(CONFIG_FS_ENET_MDIO_FEC) += mii-fec.o
 obj-$(CONFIG_FS_ENET_MDIO_FCC) += mii-bitbang.o
-else
-fs_enet-$(CONFIG_FS_ENET_MDIO_FEC) += mii-fec.o
-fs_enet-$(CONFIG_FS_ENET_MDIO_FCC) += mii-bitbang.o
-endif
 
 fs_enet-objs := fs_enet-main.o $(fs_enet-m)
index 445763e..9259138 100644 (file)
 #include <linux/fs.h>
 #include <linux/platform_device.h>
 #include <linux/phy.h>
+#include <linux/of_platform.h>
+#include <linux/of_gpio.h>
 
 #include <linux/vmalloc.h>
 #include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
-#include <linux/of_gpio.h>
-#include <linux/of_platform.h>
-#endif
-
 #include "fs_enet.h"
 
 /*************************************************/
 
-#ifndef CONFIG_PPC_CPM_NEW_BINDING
-static char version[] __devinitdata =
-    DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")" "\n";
-#endif
-
 MODULE_AUTHOR("Pantelis Antoniou <panto@intracom.gr>");
 MODULE_DESCRIPTION("Freescale Ethernet Driver");
 MODULE_LICENSE("GPL");
@@ -958,190 +950,6 @@ static int fs_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 extern int fs_mii_connect(struct net_device *dev);
 extern void fs_mii_disconnect(struct net_device *dev);
 
-#ifndef CONFIG_PPC_CPM_NEW_BINDING
-static struct net_device *fs_init_instance(struct device *dev,
-               struct fs_platform_info *fpi)
-{
-       struct net_device *ndev = NULL;
-       struct fs_enet_private *fep = NULL;
-       int privsize, i, r, err = 0, registered = 0;
-
-       fpi->fs_no = fs_get_id(fpi);
-       /* guard */
-       if ((unsigned int)fpi->fs_no >= FS_MAX_INDEX)
-               return ERR_PTR(-EINVAL);
-
-       privsize = sizeof(*fep) + (sizeof(struct sk_buff **) *
-                           (fpi->rx_ring + fpi->tx_ring));
-
-       ndev = alloc_etherdev(privsize);
-       if (!ndev) {
-               err = -ENOMEM;
-               goto err;
-       }
-
-       fep = netdev_priv(ndev);
-
-       fep->dev = dev;
-       dev_set_drvdata(dev, ndev);
-       fep->fpi = fpi;
-       if (fpi->init_ioports)
-               fpi->init_ioports((struct fs_platform_info *)fpi);
-
-#ifdef CONFIG_FS_ENET_HAS_FEC
-       if (fs_get_fec_index(fpi->fs_no) >= 0)
-               fep->ops = &fs_fec_ops;
-#endif
-
-#ifdef CONFIG_FS_ENET_HAS_SCC
-       if (fs_get_scc_index(fpi->fs_no) >=0)
-               fep->ops = &fs_scc_ops;
-#endif
-
-#ifdef CONFIG_FS_ENET_HAS_FCC
-       if (fs_get_fcc_index(fpi->fs_no) >= 0)
-               fep->ops = &fs_fcc_ops;
-#endif
-
-       if (fep->ops == NULL) {
-               printk(KERN_ERR DRV_MODULE_NAME
-                      ": %s No matching ops found (%d).\n",
-                      ndev->name, fpi->fs_no);
-               err = -EINVAL;
-               goto err;
-       }
-
-       r = (*fep->ops->setup_data)(ndev);
-       if (r != 0) {
-               printk(KERN_ERR DRV_MODULE_NAME
-                      ": %s setup_data failed\n",
-                       ndev->name);
-               err = r;
-               goto err;
-       }
-
-       /* point rx_skbuff, tx_skbuff */
-       fep->rx_skbuff = (struct sk_buff **)&fep[1];
-       fep->tx_skbuff = fep->rx_skbuff + fpi->rx_ring;
-
-       /* init locks */
-       spin_lock_init(&fep->lock);
-       spin_lock_init(&fep->tx_lock);
-
-       /*
-        * Set the Ethernet address.
-        */
-       for (i = 0; i < 6; i++)
-               ndev->dev_addr[i] = fpi->macaddr[i];
-
-       r = (*fep->ops->allocate_bd)(ndev);
-
-       if (fep->ring_base == NULL) {
-               printk(KERN_ERR DRV_MODULE_NAME
-                      ": %s buffer descriptor alloc failed (%d).\n", ndev->name, r);
-               err = r;
-               goto err;
-       }
-
-       /*
-        * Set receive and transmit descriptor base.
-        */
-       fep->rx_bd_base = fep->ring_base;
-       fep->tx_bd_base = fep->rx_bd_base + fpi->rx_ring;
-
-       /* initialize ring size variables */
-       fep->tx_ring = fpi->tx_ring;
-       fep->rx_ring = fpi->rx_ring;
-
-       /*
-        * The FEC Ethernet specific entries in the device structure.
-        */
-       ndev->open = fs_enet_open;
-       ndev->hard_start_xmit = fs_enet_start_xmit;
-       ndev->tx_timeout = fs_timeout;
-       ndev->watchdog_timeo = 2 * HZ;
-       ndev->stop = fs_enet_close;
-       ndev->get_stats = fs_enet_get_stats;
-       ndev->set_multicast_list = fs_set_multicast_list;
-
-#ifdef CONFIG_NET_POLL_CONTROLLER
-       ndev->poll_controller = fs_enet_netpoll;
-#endif
-
-       netif_napi_add(ndev, &fep->napi,
-                      fs_enet_rx_napi, fpi->napi_weight);
-
-       ndev->ethtool_ops = &fs_ethtool_ops;
-       ndev->do_ioctl = fs_ioctl;
-
-       init_timer(&fep->phy_timer_list);
-
-       netif_carrier_off(ndev);
-
-       err = register_netdev(ndev);
-       if (err != 0) {
-               printk(KERN_ERR DRV_MODULE_NAME
-                      ": %s register_netdev failed.\n", ndev->name);
-               goto err;
-       }
-       registered = 1;
-
-
-       return ndev;
-
-err:
-       if (ndev != NULL) {
-               if (registered)
-                       unregister_netdev(ndev);
-
-               if (fep && fep->ops) {
-                       (*fep->ops->free_bd)(ndev);
-                       (*fep->ops->cleanup_data)(ndev);
-               }
-
-               free_netdev(ndev);
-       }
-
-       dev_set_drvdata(dev, NULL);
-
-       return ERR_PTR(err);
-}
-
-static int fs_cleanup_instance(struct net_device *ndev)
-{
-       struct fs_enet_private *fep;
-       const struct fs_platform_info *fpi;
-       struct device *dev;
-
-       if (ndev == NULL)
-               return -EINVAL;
-
-       fep = netdev_priv(ndev);
-       if (fep == NULL)
-               return -EINVAL;
-
-       fpi = fep->fpi;
-
-       unregister_netdev(ndev);
-
-       dma_free_coherent(fep->dev, (fpi->tx_ring + fpi->rx_ring) * sizeof(cbd_t),
-                         (void __force *)fep->ring_base, fep->ring_mem_addr);
-
-       /* reset it */
-       (*fep->ops->cleanup_data)(ndev);
-
-       dev = fep->dev;
-       if (dev != NULL) {
-               dev_set_drvdata(dev, NULL);
-               fep->dev = NULL;
-       }
-
-       free_netdev(ndev);
-
-       return 0;
-}
-#endif
-
 /**************************************************************************************/
 
 /* handy pointer to the immap */
@@ -1168,7 +976,6 @@ static void cleanup_immap(void)
 
 /**************************************************************************************/
 
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
 static int __devinit find_phy(struct device_node *np,
                               struct fs_platform_info *fpi)
 {
@@ -1408,121 +1215,6 @@ static void __exit fs_cleanup(void)
        of_unregister_platform_driver(&fs_enet_driver);
        cleanup_immap();
 }
-#else
-static int __devinit fs_enet_probe(struct device *dev)
-{
-       struct net_device *ndev;
-
-       /* no fixup - no device */
-       if (dev->platform_data == NULL) {
-               printk(KERN_INFO "fs_enet: "
-                               "probe called with no platform data; "
-                               "remove unused devices\n");
-               return -ENODEV;
-       }
-
-       ndev = fs_init_instance(dev, dev->platform_data);
-       if (IS_ERR(ndev))
-               return PTR_ERR(ndev);
-       return 0;
-}
-
-static int fs_enet_remove(struct device *dev)
-{
-       return fs_cleanup_instance(dev_get_drvdata(dev));
-}
-
-static struct device_driver fs_enet_fec_driver = {
-       .name           = "fsl-cpm-fec",
-       .bus            = &platform_bus_type,
-       .probe          = fs_enet_probe,
-       .remove         = fs_enet_remove,
-#ifdef CONFIG_PM
-/*     .suspend        = fs_enet_suspend,      TODO */
-/*     .resume         = fs_enet_resume,       TODO */
-#endif
-};
-
-static struct device_driver fs_enet_scc_driver = {
-       .name           = "fsl-cpm-scc",
-       .bus            = &platform_bus_type,
-       .probe          = fs_enet_probe,
-       .remove         = fs_enet_remove,
-#ifdef CONFIG_PM
-/*     .suspend        = fs_enet_suspend,      TODO */
-/*     .resume         = fs_enet_resume,       TODO */
-#endif
-};
-
-static struct device_driver fs_enet_fcc_driver = {
-       .name           = "fsl-cpm-fcc",
-       .bus            = &platform_bus_type,
-       .probe          = fs_enet_probe,
-       .remove         = fs_enet_remove,
-#ifdef CONFIG_PM
-/*     .suspend        = fs_enet_suspend,      TODO */
-/*     .resume         = fs_enet_resume,       TODO */
-#endif
-};
-
-static int __init fs_init(void)
-{
-       int r;
-
-       printk(KERN_INFO
-                       "%s", version);
-
-       r = setup_immap();
-       if (r != 0)
-               return r;
-
-#ifdef CONFIG_FS_ENET_HAS_FCC
-       /* let's insert mii stuff */
-       r = fs_enet_mdio_bb_init();
-
-       if (r != 0) {
-               printk(KERN_ERR DRV_MODULE_NAME
-                       "BB PHY init failed.\n");
-               return r;
-       }
-       r = driver_register(&fs_enet_fcc_driver);
-       if (r != 0)
-               goto err;
-#endif
-
-#ifdef CONFIG_FS_ENET_HAS_FEC
-       r =  fs_enet_mdio_fec_init();
-       if (r != 0) {
-               printk(KERN_ERR DRV_MODULE_NAME
-                       "FEC PHY init failed.\n");
-               return r;
-       }
-
-       r = driver_register(&fs_enet_fec_driver);
-       if (r != 0)
-               goto err;
-#endif
-
-#ifdef CONFIG_FS_ENET_HAS_SCC
-       r = driver_register(&fs_enet_scc_driver);
-       if (r != 0)
-               goto err;
-#endif
-
-       return 0;
-err:
-       cleanup_immap();
-       return r;
-}
-
-static void __exit fs_cleanup(void)
-{
-       driver_unregister(&fs_enet_fec_driver);
-       driver_unregister(&fs_enet_fcc_driver);
-       driver_unregister(&fs_enet_scc_driver);
-       cleanup_immap();
-}
-#endif
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
 static void fs_enet_netpoll(struct net_device *dev)
index e05389c..db46d2e 100644 (file)
@@ -138,10 +138,6 @@ struct fs_enet_private {
 };
 
 /***************************************************************************/
-#ifndef CONFIG_PPC_CPM_NEW_BINDING
-int fs_enet_mdio_bb_init(void);
-int fs_enet_mdio_fec_init(void);
-#endif
 
 void fs_init_bds(struct net_device *dev);
 void fs_cleanup_bds(struct net_device *dev);
index 8268b35..0a97fc2 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/fs.h>
 #include <linux/platform_device.h>
 #include <linux/phy.h>
+#include <linux/of_device.h>
 
 #include <asm/immap_cpm2.h>
 #include <asm/mpc8260.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
-#include <asm/of_device.h>
-#endif
-
 #include "fs_enet.h"
 
 /*************************************************/
@@ -87,7 +84,6 @@ static inline int fcc_cr_cmd(struct fs_enet_private *fep, u32 op)
 
 static int do_pd_setup(struct fs_enet_private *fep)
 {
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
        struct of_device *ofdev = to_of_device(fep->dev);
        struct fs_platform_info *fpi = fep->fpi;
        int ret = -EINVAL;
@@ -125,44 +121,6 @@ out_fccp:
        iounmap(fep->fcc.fccp);
 out:
        return ret;
-#else
-       struct platform_device *pdev = to_platform_device(fep->dev);
-       struct resource *r;
-
-       /* Fill out IRQ field */
-       fep->interrupt = platform_get_irq(pdev, 0);
-       if (fep->interrupt < 0)
-               return -EINVAL;
-
-       /* Attach the memory for the FCC Parameter RAM */
-       r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fcc_pram");
-       fep->fcc.ep = ioremap(r->start, r->end - r->start + 1);
-       if (fep->fcc.ep == NULL)
-               return -EINVAL;
-
-       r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fcc_regs");
-       fep->fcc.fccp = ioremap(r->start, r->end - r->start + 1);
-       if (fep->fcc.fccp == NULL)
-               return -EINVAL;
-
-       if (fep->fpi->fcc_regs_c) {
-               fep->fcc.fcccp = (void __iomem *)fep->fpi->fcc_regs_c;
-       } else {
-               r = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-                               "fcc_regs_c");
-               fep->fcc.fcccp = ioremap(r->start,
-                               r->end - r->start + 1);
-       }
-
-       if (fep->fcc.fcccp == NULL)
-               return -EINVAL;
-
-       fep->fcc.mem = (void __iomem *)fep->fpi->mem_offset;
-       if (fep->fcc.mem == NULL)
-               return -EINVAL;
-
-       return 0;
-#endif
 }
 
 #define FCC_NAPI_RX_EVENT_MSK  (FCC_ENET_RXF | FCC_ENET_RXB)
@@ -173,17 +131,6 @@ out:
 static int setup_data(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-#ifndef CONFIG_PPC_CPM_NEW_BINDING
-       struct fs_platform_info *fpi = fep->fpi;
-
-       fpi->cp_command = (fpi->cp_page << 26) |
-                         (fpi->cp_block << 21) |
-                         (12 << 6);
-
-       fep->fcc.idx = fs_get_fcc_index(fpi->fs_no);
-       if ((unsigned int)fep->fcc.idx >= 3)    /* max 3 FCCs */
-               return -EINVAL;
-#endif
 
        if (do_pd_setup(fep) != 0)
                return -EINVAL;
@@ -304,9 +251,6 @@ static void restart(struct net_device *dev)
        fcc_enet_t __iomem *ep = fep->fcc.ep;
        dma_addr_t rx_bd_base_phys, tx_bd_base_phys;
        u16 paddrh, paddrm, paddrl;
-#ifndef CONFIG_PPC_CPM_NEW_BINDING
-       u16 mem_addr;
-#endif
        const unsigned char *mac;
        int i;
 
@@ -338,19 +282,10 @@ static void restart(struct net_device *dev)
         * this area.
         */
 
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
        W16(ep, fen_genfcc.fcc_riptr, fpi->dpram_offset);
        W16(ep, fen_genfcc.fcc_tiptr, fpi->dpram_offset + 32);
 
        W16(ep, fen_padptr, fpi->dpram_offset + 64);
-#else
-       mem_addr = (u32) fep->fcc.mem;  /* de-fixup dpram offset */
-
-       W16(ep, fen_genfcc.fcc_riptr, (mem_addr & 0xffff));
-       W16(ep, fen_genfcc.fcc_tiptr, ((mem_addr + 32) & 0xffff));
-
-       W16(ep, fen_padptr, mem_addr + 64);
-#endif
 
        /* fill with special symbol...  */
        memset_io(fep->fcc.mem + fpi->dpram_offset + 64, 0x88, 32);
index 8a311d1..0a7d1c5 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/bitops.h>
 #include <linux/fs.h>
 #include <linux/platform_device.h>
+#include <linux/of_device.h>
 
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 #include <asm/cpm1.h>
 #endif
 
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
-#include <asm/of_device.h>
-#endif
-
 #include "fs_enet.h"
 #include "fec.h"
 
@@ -99,7 +96,6 @@ static int whack_reset(fec_t __iomem *fecp)
 
 static int do_pd_setup(struct fs_enet_private *fep)
 {
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
        struct of_device *ofdev = to_of_device(fep->dev);
 
        fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL);
@@ -111,23 +107,6 @@ static int do_pd_setup(struct fs_enet_private *fep)
                return -EINVAL;
 
        return 0;
-#else
-       struct platform_device *pdev = to_platform_device(fep->dev);
-       struct resource *r;
-
-       /* Fill out IRQ field */
-       fep->interrupt = platform_get_irq_byname(pdev,"interrupt");
-       if (fep->interrupt < 0)
-               return -EINVAL;
-
-       r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
-       fep->fec.fecp = ioremap(r->start, r->end - r->start + 1);
-
-       if(fep->fec.fecp == NULL)
-               return -EINVAL;
-
-       return 0;
-#endif
 }
 
 #define FEC_NAPI_RX_EVENT_MSK  (FEC_ENET_RXF | FEC_ENET_RXB)
index e3557ec..029b3c7 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/bitops.h>
 #include <linux/fs.h>
 #include <linux/platform_device.h>
+#include <linux/of_platform.h>
 
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 #include <asm/cpm1.h>
 #endif
 
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
-#include <linux/of_platform.h>
-#endif
-
 #include "fs_enet.h"
 
 /*************************************************/
@@ -99,7 +96,6 @@ static inline int scc_cr_cmd(struct fs_enet_private *fep, u32 op)
 
 static int do_pd_setup(struct fs_enet_private *fep)
 {
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
        struct of_device *ofdev = to_of_device(fep->dev);
 
        fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL);
@@ -115,27 +111,6 @@ static int do_pd_setup(struct fs_enet_private *fep)
                iounmap(fep->scc.sccp);
                return -EINVAL;
        }
-#else
-       struct platform_device *pdev = to_platform_device(fep->dev);
-       struct resource *r;
-
-       /* Fill out IRQ field */
-       fep->interrupt = platform_get_irq_byname(pdev, "interrupt");
-       if (fep->interrupt < 0)
-               return -EINVAL;
-
-       r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
-       fep->scc.sccp = ioremap(r->start, r->end - r->start + 1);
-
-       if (fep->scc.sccp == NULL)
-               return -EINVAL;
-
-       r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pram");
-       fep->scc.ep = ioremap(r->start, r->end - r->start + 1);
-
-       if (fep->scc.ep == NULL)
-               return -EINVAL;
-#endif
 
        return 0;
 }
@@ -149,16 +124,6 @@ static int setup_data(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
 
-#ifndef CONFIG_PPC_CPM_NEW_BINDING
-       struct fs_platform_info *fpi = fep->fpi;
-
-       fep->scc.idx = fs_get_scc_index(fpi->fs_no);
-       if ((unsigned int)fep->fcc.idx >= 4) /* max 4 SCCs */
-               return -EINVAL;
-
-       fpi->cp_command = fep->fcc.idx << 6;
-#endif
-
        do_pd_setup(fep);
 
        fep->scc.hthi = 0;
index 1620030..be4b72f 100644 (file)
 #include <linux/mii.h>
 #include <linux/platform_device.h>
 #include <linux/mdio-bitbang.h>
-
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
 #include <linux/of_platform.h>
-#endif
 
 #include "fs_enet.h"
 
@@ -110,7 +107,6 @@ static struct mdiobb_ops bb_ops = {
        .get_mdio_data = mdio_read,
 };
 
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
 static int __devinit fs_mii_bitbang_init(struct mii_bus *bus,
                                          struct device_node *np)
 {
@@ -271,106 +267,3 @@ static void fs_enet_mdio_bb_exit(void)
 
 module_init(fs_enet_mdio_bb_init);
 module_exit(fs_enet_mdio_bb_exit);
-#else
-static int __devinit fs_mii_bitbang_init(struct bb_info *bitbang,
-                                         struct fs_mii_bb_platform_info *fmpi)
-{
-       bitbang->dir = (u32 __iomem *)fmpi->mdio_dir.offset;
-       bitbang->dat = (u32 __iomem *)fmpi->mdio_dat.offset;
-       bitbang->mdio_msk = 1U << (31 - fmpi->mdio_dat.bit);
-       bitbang->mdc_msk = 1U << (31 - fmpi->mdc_dat.bit);
-
-       return 0;
-}
-
-static int __devinit fs_enet_mdio_probe(struct device *dev)
-{
-       struct platform_device *pdev = to_platform_device(dev);
-       struct fs_mii_bb_platform_info *pdata;
-       struct mii_bus *new_bus;
-       struct bb_info *bitbang;
-       int err = 0;
-
-       if (NULL == dev)
-               return -EINVAL;
-
-       bitbang = kzalloc(sizeof(struct bb_info), GFP_KERNEL);
-
-       if (NULL == bitbang)
-               return -ENOMEM;
-
-       bitbang->ctrl.ops = &bb_ops;
-
-       new_bus = alloc_mdio_bitbang(&bitbang->ctrl);
-
-       if (NULL == new_bus)
-               return -ENOMEM;
-
-       new_bus->name = "BB MII Bus",
-       snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id);
-
-       new_bus->phy_mask = ~0x9;
-       pdata = (struct fs_mii_bb_platform_info *)pdev->dev.platform_data;
-
-       if (NULL == pdata) {
-               printk(KERN_ERR "gfar mdio %d: Missing platform data!\n", pdev->id);
-               return -ENODEV;
-       }
-
-       /*set up workspace*/
-       fs_mii_bitbang_init(bitbang, pdata);
-
-       new_bus->priv = bitbang;
-
-       new_bus->irq = pdata->irq;
-
-       new_bus->dev = dev;
-       dev_set_drvdata(dev, new_bus);
-
-       err = mdiobus_register(new_bus);
-
-       if (0 != err) {
-               printk (KERN_ERR "%s: Cannot register as MDIO bus\n",
-                               new_bus->name);
-               goto bus_register_fail;
-       }
-
-       return 0;
-
-bus_register_fail:
-       free_mdio_bitbang(new_bus);
-       kfree(bitbang);
-
-       return err;
-}
-
-static int fs_enet_mdio_remove(struct device *dev)
-{
-       struct mii_bus *bus = dev_get_drvdata(dev);
-
-       mdiobus_unregister(bus);
-
-       dev_set_drvdata(dev, NULL);
-
-       free_mdio_bitbang(bus);
-
-       return 0;
-}
-
-static struct device_driver fs_enet_bb_mdio_driver = {
-       .name = "fsl-bb-mdio",
-       .bus = &platform_bus_type,
-       .probe = fs_enet_mdio_probe,
-       .remove = fs_enet_mdio_remove,
-};
-
-int fs_enet_mdio_bb_init(void)
-{
-       return driver_register(&fs_enet_bb_mdio_driver);
-}
-
-void fs_enet_mdio_bb_exit(void)
-{
-       driver_unregister(&fs_enet_bb_mdio_driver);
-}
-#endif
index 8f6a43b..695f74c 100644 (file)
 #include <linux/ethtool.h>
 #include <linux/bitops.h>
 #include <linux/platform_device.h>
+#include <linux/of_platform.h>
 
 #include <asm/pgtable.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
-#include <linux/of_platform.h>
-#endif
-
 #include "fs_enet.h"
 #include "fec.h"
 
 
 #define FEC_MII_LOOPS  10000
 
-#ifndef CONFIG_PPC_CPM_NEW_BINDING
-static int match_has_phy (struct device *dev, void* data)
-{
-       struct platform_device* pdev = container_of(dev, struct platform_device, dev);
-       struct fs_platform_info* fpi;
-       if(strcmp(pdev->name, (char*)data))
-       {
-           return 0;
-       }
-
-       fpi = pdev->dev.platform_data;
-       if((fpi)&&(fpi->has_phy))
-               return 1;
-       return 0;
-}
-
-static int fs_mii_fec_init(struct fec_info* fec, struct fs_mii_fec_platform_info *fmpi)
-{
-       struct resource *r;
-       fec_t __iomem *fecp;
-       char* name = "fsl-cpm-fec";
-
-       /* we need fec in order to be useful */
-       struct platform_device *fec_pdev =
-               container_of(bus_find_device(&platform_bus_type, NULL, name, match_has_phy),
-                               struct platform_device, dev);
-
-       if(fec_pdev == NULL) {
-               printk(KERN_ERR"Unable to find PHY for %s", name);
-               return -ENODEV;
-       }
-
-       r = platform_get_resource_byname(fec_pdev, IORESOURCE_MEM, "regs");
-
-       fec->fecp = fecp = ioremap(r->start,sizeof(fec_t));
-       fec->mii_speed = fmpi->mii_speed;
-
-       setbits32(&fecp->fec_r_cntrl, FEC_RCNTRL_MII_MODE);     /* MII enable */
-       setbits32(&fecp->fec_ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN);
-       out_be32(&fecp->fec_ievent, FEC_ENET_MII);
-       out_be32(&fecp->fec_mii_speed, fec->mii_speed);
-
-       return 0;
-}
-#endif
-
 static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location)
 {
        struct fec_info* fec = bus->priv;
@@ -151,7 +102,6 @@ static int fs_enet_fec_mii_reset(struct mii_bus *bus)
        return 0;
 }
 
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
 static void __devinit add_phy(struct mii_bus *bus, struct device_node *np)
 {
        const u32 *data;
@@ -286,95 +236,3 @@ static void fs_enet_mdio_fec_exit(void)
 
 module_init(fs_enet_mdio_fec_init);
 module_exit(fs_enet_mdio_fec_exit);
-#else
-static int __devinit fs_enet_fec_mdio_probe(struct device *dev)
-{
-       struct platform_device *pdev = to_platform_device(dev);
-       struct fs_mii_fec_platform_info *pdata;
-       struct mii_bus *new_bus;
-       struct fec_info *fec;
-       int err = 0;
-       if (NULL == dev)
-               return -EINVAL;
-       new_bus = kzalloc(sizeof(struct mii_bus), GFP_KERNEL);
-
-       if (NULL == new_bus)
-               return -ENOMEM;
-
-       fec = kzalloc(sizeof(struct fec_info), GFP_KERNEL);
-
-       if (NULL == fec)
-               return -ENOMEM;
-
-       new_bus->name = "FEC MII Bus",
-       new_bus->read = &fs_enet_fec_mii_read,
-       new_bus->write = &fs_enet_fec_mii_write,
-       new_bus->reset = &fs_enet_fec_mii_reset,
-       snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id);
-
-       pdata = (struct fs_mii_fec_platform_info *)pdev->dev.platform_data;
-
-       if (NULL == pdata) {
-               printk(KERN_ERR "fs_enet FEC mdio %d: Missing platform data!\n", pdev->id);
-               return -ENODEV;
-       }
-
-       /*set up workspace*/
-
-       fs_mii_fec_init(fec, pdata);
-       new_bus->priv = fec;
-
-       new_bus->irq = pdata->irq;
-
-       new_bus->dev = dev;
-       dev_set_drvdata(dev, new_bus);
-
-       err = mdiobus_register(new_bus);
-
-       if (0 != err) {
-               printk (KERN_ERR "%s: Cannot register as MDIO bus\n",
-                               new_bus->name);
-               goto bus_register_fail;
-       }
-
-       return 0;
-
-bus_register_fail:
-       kfree(new_bus);
-
-       return err;
-}
-
-
-static int fs_enet_fec_mdio_remove(struct device *dev)
-{
-       struct mii_bus *bus = dev_get_drvdata(dev);
-
-       mdiobus_unregister(bus);
-
-       dev_set_drvdata(dev, NULL);
-       kfree(bus->priv);
-
-       bus->priv = NULL;
-       kfree(bus);
-
-       return 0;
-}
-
-static struct device_driver fs_enet_fec_mdio_driver = {
-       .name = "fsl-cpm-fec-mdio",
-       .bus = &platform_bus_type,
-       .probe = fs_enet_fec_mdio_probe,
-       .remove = fs_enet_fec_mdio_remove,
-};
-
-int fs_enet_mdio_fec_init(void)
-{
-       return driver_register(&fs_enet_fec_mdio_driver);
-}
-
-void fs_enet_mdio_fec_exit(void)
-{
-       driver_unregister(&fs_enet_fec_mdio_driver);
-}
-#endif
index 39b45e9..b8394cf 100644 (file)
@@ -134,6 +134,9 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int l
 static void gfar_vlan_rx_register(struct net_device *netdev,
                                struct vlan_group *grp);
 void gfar_halt(struct net_device *dev);
+#ifdef CONFIG_PM
+static void gfar_halt_nodisable(struct net_device *dev);
+#endif
 void gfar_start(struct net_device *dev);
 static void gfar_clear_exact_match(struct net_device *dev);
 static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr);
@@ -207,6 +210,7 @@ static int gfar_probe(struct platform_device *pdev)
 
        spin_lock_init(&priv->txlock);
        spin_lock_init(&priv->rxlock);
+       spin_lock_init(&priv->bflock);
 
        platform_set_drvdata(pdev, dev);
 
@@ -378,6 +382,103 @@ static int gfar_remove(struct platform_device *pdev)
        return 0;
 }
 
+#ifdef CONFIG_PM
+static int gfar_suspend(struct platform_device *pdev, pm_message_t state)
+{
+       struct net_device *dev = platform_get_drvdata(pdev);
+       struct gfar_private *priv = netdev_priv(dev);
+       unsigned long flags;
+       u32 tempval;
+
+       int magic_packet = priv->wol_en &&
+               (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
+
+       netif_device_detach(dev);
+
+       if (netif_running(dev)) {
+               spin_lock_irqsave(&priv->txlock, flags);
+               spin_lock(&priv->rxlock);
+
+               gfar_halt_nodisable(dev);
+
+               /* Disable Tx, and Rx if wake-on-LAN is disabled. */
+               tempval = gfar_read(&priv->regs->maccfg1);
+
+               tempval &= ~MACCFG1_TX_EN;
+
+               if (!magic_packet)
+                       tempval &= ~MACCFG1_RX_EN;
+
+               gfar_write(&priv->regs->maccfg1, tempval);
+
+               spin_unlock(&priv->rxlock);
+               spin_unlock_irqrestore(&priv->txlock, flags);
+
+#ifdef CONFIG_GFAR_NAPI
+               napi_disable(&priv->napi);
+#endif
+
+               if (magic_packet) {
+                       /* Enable interrupt on Magic Packet */
+                       gfar_write(&priv->regs->imask, IMASK_MAG);
+
+                       /* Enable Magic Packet mode */
+                       tempval = gfar_read(&priv->regs->maccfg2);
+                       tempval |= MACCFG2_MPEN;
+                       gfar_write(&priv->regs->maccfg2, tempval);
+               } else {
+                       phy_stop(priv->phydev);
+               }
+       }
+
+       return 0;
+}
+
+static int gfar_resume(struct platform_device *pdev)
+{
+       struct net_device *dev = platform_get_drvdata(pdev);
+       struct gfar_private *priv = netdev_priv(dev);
+       unsigned long flags;
+       u32 tempval;
+       int magic_packet = priv->wol_en &&
+               (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET);
+
+       if (!netif_running(dev)) {
+               netif_device_attach(dev);
+               return 0;
+       }
+
+       if (!magic_packet && priv->phydev)
+               phy_start(priv->phydev);
+
+       /* Disable Magic Packet mode, in case something
+        * else woke us up.
+        */
+
+       spin_lock_irqsave(&priv->txlock, flags);
+       spin_lock(&priv->rxlock);
+
+       tempval = gfar_read(&priv->regs->maccfg2);
+       tempval &= ~MACCFG2_MPEN;
+       gfar_write(&priv->regs->maccfg2, tempval);
+
+       gfar_start(dev);
+
+       spin_unlock(&priv->rxlock);
+       spin_unlock_irqrestore(&priv->txlock, flags);
+
+       netif_device_attach(dev);
+
+#ifdef CONFIG_GFAR_NAPI
+       napi_enable(&priv->napi);
+#endif
+
+       return 0;
+}
+#else
+#define gfar_suspend NULL
+#define gfar_resume NULL
+#endif
 
 /* Reads the controller's registers to determine what interface
  * connects it to the PHY.
@@ -534,8 +635,9 @@ static void init_registers(struct net_device *dev)
 }
 
 
+#ifdef CONFIG_PM
 /* Halt the receive and transmit queues */
-void gfar_halt(struct net_device *dev)
+static void gfar_halt_nodisable(struct net_device *dev)
 {
        struct gfar_private *priv = netdev_priv(dev);
        struct gfar __iomem *regs = priv->regs;
@@ -558,6 +660,15 @@ void gfar_halt(struct net_device *dev)
                         (IEVENT_GRSC | IEVENT_GTSC)))
                        cpu_relax();
        }
+}
+#endif
+
+/* Halt the receive and transmit queues */
+void gfar_halt(struct net_device *dev)
+{
+       struct gfar_private *priv = netdev_priv(dev);
+       struct gfar __iomem *regs = priv->regs;
+       u32 tempval;
 
        /* Disable Rx and Tx */
        tempval = gfar_read(&regs->maccfg1);
@@ -1909,7 +2020,12 @@ static irqreturn_t gfar_error(int irq, void *dev_id)
        u32 events = gfar_read(&priv->regs->ievent);
 
        /* Clear IEVENT */
-       gfar_write(&priv->regs->ievent, IEVENT_ERR_MASK);
+       gfar_write(&priv->regs->ievent, events & IEVENT_ERR_MASK);
+
+       /* Magic Packet is not an error. */
+       if ((priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) &&
+           (events & IEVENT_MAG))
+               events &= ~IEVENT_MAG;
 
        /* Hmm... */
        if (netif_msg_rx_err(priv) || netif_msg_tx_err(priv))
@@ -1977,6 +2093,8 @@ MODULE_ALIAS("platform:fsl-gianfar");
 static struct platform_driver gfar_driver = {
        .probe = gfar_probe,
        .remove = gfar_remove,
+       .suspend = gfar_suspend,
+       .resume = gfar_resume,
        .driver = {
                .name = "fsl-gianfar",
                .owner = THIS_MODULE,
index bead71c..d59df98 100644 (file)
@@ -157,6 +157,7 @@ extern const char gfar_driver_version[];
 #define MACCFG2_GMII            0x00000200
 #define MACCFG2_HUGEFRAME      0x00000020
 #define MACCFG2_LENGTHCHECK    0x00000010
+#define MACCFG2_MPEN           0x00000008
 
 #define ECNTRL_INIT_SETTINGS   0x00001000
 #define ECNTRL_TBI_MODE         0x00000020
@@ -229,6 +230,7 @@ extern const char gfar_driver_version[];
 #define IEVENT_CRL             0x00020000
 #define IEVENT_XFUN            0x00010000
 #define IEVENT_RXB0            0x00008000
+#define IEVENT_MAG             0x00000800
 #define IEVENT_GRSC            0x00000100
 #define IEVENT_RXF0            0x00000080
 #define IEVENT_FIR             0x00000008
@@ -241,7 +243,8 @@ extern const char gfar_driver_version[];
 #define IEVENT_ERR_MASK         \
 (IEVENT_RXC | IEVENT_BSY | IEVENT_EBERR | IEVENT_MSRO | \
  IEVENT_BABT | IEVENT_TXC | IEVENT_TXE | IEVENT_LC \
- | IEVENT_CRL | IEVENT_XFUN | IEVENT_DPE | IEVENT_PERR)
+ | IEVENT_CRL | IEVENT_XFUN | IEVENT_DPE | IEVENT_PERR \
+ | IEVENT_MAG)
 
 #define IMASK_INIT_CLEAR       0x00000000
 #define IMASK_BABR              0x80000000
@@ -259,6 +262,7 @@ extern const char gfar_driver_version[];
 #define IMASK_CRL              0x00020000
 #define IMASK_XFUN             0x00010000
 #define IMASK_RXB0              0x00008000
+#define IMASK_MAG              0x00000800
 #define IMASK_GTSC              0x00000100
 #define IMASK_RXFEN0           0x00000080
 #define IMASK_FIR              0x00000008
@@ -726,10 +730,14 @@ struct gfar_private {
        unsigned int fifo_starve;
        unsigned int fifo_starve_off;
 
+       /* Bitfield update lock */
+       spinlock_t bflock;
+
        unsigned char vlan_enable:1,
                rx_csum_enable:1,
                extended_hash:1,
-               bd_stash_en:1;
+               bd_stash_en:1,
+               wol_en:1; /* Wake-on-LAN enabled */
        unsigned short padding;
 
        unsigned int interruptTransmit;
index 6007147..fb7d3cc 100644 (file)
@@ -479,14 +479,13 @@ static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rva
 static int gfar_set_rx_csum(struct net_device *dev, uint32_t data)
 {
        struct gfar_private *priv = netdev_priv(dev);
+       unsigned long flags;
        int err = 0;
 
        if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM))
                return -EOPNOTSUPP;
 
        if (dev->flags & IFF_UP) {
-               unsigned long flags;
-
                /* Halt TX and RX, and process the frames which
                 * have already been received */
                spin_lock_irqsave(&priv->txlock, flags);
@@ -502,7 +501,9 @@ static int gfar_set_rx_csum(struct net_device *dev, uint32_t data)
                stop_gfar(dev);
        }
 
+       spin_lock_irqsave(&priv->bflock, flags);
        priv->rx_csum_enable = data;
+       spin_unlock_irqrestore(&priv->bflock, flags);
 
        if (dev->flags & IFF_UP)
                err = startup_gfar(dev);
@@ -564,6 +565,38 @@ static void gfar_set_msglevel(struct net_device *dev, uint32_t data)
        priv->msg_enable = data;
 }
 
+#ifdef CONFIG_PM
+static void gfar_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+       struct gfar_private *priv = netdev_priv(dev);
+
+       if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) {
+               wol->supported = WAKE_MAGIC;
+               wol->wolopts = priv->wol_en ? WAKE_MAGIC : 0;
+       } else {
+               wol->supported = wol->wolopts = 0;
+       }
+}
+
+static int gfar_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
+{
+       struct gfar_private *priv = netdev_priv(dev);
+       unsigned long flags;
+
+       if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MAGIC_PACKET) &&
+           wol->wolopts != 0)
+               return -EINVAL;
+
+       if (wol->wolopts & ~WAKE_MAGIC)
+               return -EINVAL;
+
+       spin_lock_irqsave(&priv->bflock, flags);
+       priv->wol_en = wol->wolopts & WAKE_MAGIC ? 1 : 0;
+       spin_unlock_irqrestore(&priv->bflock, flags);
+
+       return 0;
+}
+#endif
 
 const struct ethtool_ops gfar_ethtool_ops = {
        .get_settings = gfar_gsettings,
@@ -585,4 +618,8 @@ const struct ethtool_ops gfar_ethtool_ops = {
        .set_tx_csum = gfar_set_tx_csum,
        .get_msglevel = gfar_get_msglevel,
        .set_msglevel = gfar_set_msglevel,
+#ifdef CONFIG_PM
+       .get_wol = gfar_get_wol,
+       .set_wol = gfar_set_wol,
+#endif
 };
index 6b1d7a8..739b3ab 100644 (file)
@@ -866,7 +866,8 @@ static int __init ppp_init(void)
                        err = PTR_ERR(ppp_class);
                        goto out_chrdev;
                }
-               device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), "ppp");
+               device_create_drvdata(ppp_class, NULL, MKDEV(PPP_MAJOR, 0),
+                                     NULL, "ppp");
        }
 
 out:
index 5827324..f7d3349 100644 (file)
@@ -397,9 +397,9 @@ static int __init cosa_init(void)
                err = PTR_ERR(cosa_class);
                goto out_chrdev;
        }
-       for (i=0; i<nr_cards; i++) {
-               device_create(cosa_class, NULL, MKDEV(cosa_major, i), "cosa%d", i);
-       }
+       for (i = 0; i < nr_cards; i++)
+               device_create_drvdata(cosa_class, NULL, MKDEV(cosa_major, i),
+                                     NULL, "cosa%d", i);
        err = 0;
        goto out;
        
index eecf7cb..5a58b07 100644 (file)
@@ -36,7 +36,7 @@
 #define _ACPIPHP_H
 
 #include <linux/acpi.h>
-#include <linux/kobject.h>     /* for KOBJ_NAME_LEN */
+#include <linux/kobject.h>
 #include <linux/mutex.h>
 #include <linux/pci_hotplug.h>
 
@@ -51,7 +51,7 @@
 #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
 
 /* name size which is used for entries in pcihpfs */
-#define SLOT_NAME_SIZE KOBJ_NAME_LEN           /* {_SUN} */
+#define SLOT_NAME_SIZE 20              /* {_SUN} */
 
 struct acpiphp_bridge;
 struct acpiphp_slot;
index a489227..936bae5 100644 (file)
@@ -78,7 +78,7 @@ static void find_main_battery(void)
        main_battery = NULL;
        bp.main = main_battery;
 
-       error = class_for_each_device(power_supply_class, &bp,
+       error = class_for_each_device(power_supply_class, NULL, &bp,
                                      __find_main_battery);
        if (error) {
                main_battery = bp.main;
index af1633e..cb1ccb4 100644 (file)
@@ -41,7 +41,7 @@ static void power_supply_changed_work(struct work_struct *work)
 
        dev_dbg(psy->dev, "%s\n", __func__);
 
-       class_for_each_device(power_supply_class, psy,
+       class_for_each_device(power_supply_class, NULL, psy,
                              __power_supply_changed_work);
 
        power_supply_update_leds(psy);
@@ -79,7 +79,7 @@ int power_supply_am_i_supplied(struct power_supply *psy)
 {
        int error;
 
-       error = class_for_each_device(power_supply_class, psy,
+       error = class_for_each_device(power_supply_class, NULL, psy,
                                      __power_supply_am_i_supplied);
 
        dev_dbg(psy->dev, "%s %d\n", __func__, error);
index 58b7336..d397fa5 100644 (file)
@@ -345,7 +345,7 @@ struct rtc_device *rtc_class_open(char *name)
        struct device *dev;
        struct rtc_device *rtc = NULL;
 
-       dev = class_find_device(rtc_class, name, __rtc_match);
+       dev = class_find_device(rtc_class, NULL, name, __rtc_match);
        if (dev)
                rtc = to_rtc_device(dev);
 
index 81a96e0..c3dee90 100644 (file)
@@ -1168,17 +1168,19 @@ static int raw3270_create_attributes(struct raw3270 *rp)
        if (rc)
                goto out;
 
-       rp->clttydev = device_create(class3270, &rp->cdev->dev,
-                                    MKDEV(IBM_TTY3270_MAJOR, rp->minor),
-                                    "tty%s", rp->cdev->dev.bus_id);
+       rp->clttydev = device_create_drvdata(class3270, &rp->cdev->dev,
+                                            MKDEV(IBM_TTY3270_MAJOR, rp->minor),
+                                            NULL,
+                                            "tty%s", rp->cdev->dev.bus_id);
        if (IS_ERR(rp->clttydev)) {
                rc = PTR_ERR(rp->clttydev);
                goto out_ttydev;
        }
 
-       rp->cltubdev = device_create(class3270, &rp->cdev->dev,
-                                    MKDEV(IBM_FS3270_MAJOR, rp->minor),
-                                    "tub%s", rp->cdev->dev.bus_id);
+       rp->cltubdev = device_create_drvdata(class3270, &rp->cdev->dev,
+                                            MKDEV(IBM_FS3270_MAJOR, rp->minor),
+                                            NULL,
+                                            "tub%s", rp->cdev->dev.bus_id);
        if (!IS_ERR(rp->cltubdev))
                goto out;
 
index 6dfdb7c..12c2a5a 100644 (file)
@@ -69,10 +69,9 @@ struct tape_class_device *register_tape_dev(
        if (rc)
                goto fail_with_cdev;
 
-       tcd->class_device = device_create(tape_class, device,
-                                         tcd->char_device->dev,
-                                         "%s", tcd->device_name
-                       );
+       tcd->class_device = device_create_drvdata(tape_class, device,
+                                                 tcd->char_device->dev,
+                                                 NULL, "%s", tcd->device_name);
        rc = IS_ERR(tcd->class_device) ? PTR_ERR(tcd->class_device) : 0;
        if (rc)
                goto fail_with_cdev;
index b0ac44b..c1f352b 100644 (file)
@@ -896,8 +896,9 @@ static int ur_set_online(struct ccw_device *cdev)
                goto fail_free_cdev;
        }
 
-       urd->device = device_create(vmur_class, NULL, urd->char_device->dev,
-                                       "%s", node_id);
+       urd->device = device_create_drvdata(vmur_class, NULL,
+                                           urd->char_device->dev, NULL,
+                                           "%s", node_id);
        if (IS_ERR(urd->device)) {
                rc = PTR_ERR(urd->device);
                TRACE("ur_set_online: device_create rc=%d\n", rc);
index c37d7c2..73a86d0 100644 (file)
@@ -78,7 +78,7 @@ static void __init fill_sbus_device(struct device_node *dp, struct sbus_dev *sde
        else
                sdev->ofdev.dev.parent = &sdev->bus->ofdev.dev;
        sdev->ofdev.dev.bus = &sbus_bus_type;
-       sprintf(sdev->ofdev.dev.bus_id, "sbus[%08x]", dp->node);
+       dev_set_name(&sdev->ofdev.dev, "sbus[%08x]", dp->node);
 
        if (of_device_register(&sdev->ofdev) != 0)
                printk(KERN_DEBUG "sbus: device registration error for %s!\n",
@@ -257,11 +257,11 @@ static void __init build_one_sbus(struct device_node *dp, int num_sbus)
        sbus->ofdev.node = dp;
        sbus->ofdev.dev.parent = NULL;
        sbus->ofdev.dev.bus = &sbus_bus_type;
-       sprintf(sbus->ofdev.dev.bus_id, "sbus%d", num_sbus);
+       dev_set_name(&sbus->ofdev.dev, "sbus%d", num_sbus);
 
        if (of_device_register(&sbus->ofdev) != 0)
                printk(KERN_DEBUG "sbus: device registration error for %s!\n",
-                      sbus->ofdev.dev.bus_id);
+                      dev_name(&sbus->ofdev.dev));
 
        dev_dp = dp->child;
        while (dev_dp) {
index 2bc30e3..1fe0901 100644 (file)
@@ -271,8 +271,8 @@ rebuild_sys_tab:
                pHba->initialized = TRUE;
                pHba->state &= ~DPTI_STATE_RESET;
                if (adpt_sysfs_class) {
-                       struct device *dev = device_create(adpt_sysfs_class,
-                               NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit),
+                       struct device *dev = device_create_drvdata(adpt_sysfs_class,
+                               NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL,
                                "dpti%d", pHba->unit);
                        if (IS_ERR(dev)) {
                                printk(KERN_WARNING"dpti%d: unable to "
index 35cd892..fed0b02 100644 (file)
@@ -232,8 +232,8 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
        }
 
        if (shost->transportt->create_work_queue) {
-               snprintf(shost->work_q_name, KOBJ_NAME_LEN, "scsi_wq_%d",
-                       shost->host_no);
+               snprintf(shost->work_q_name, sizeof(shost->work_q_name),
+                        "scsi_wq_%d", shost->host_no);
                shost->work_q = create_singlethread_workqueue(
                                        shost->work_q_name);
                if (!shost->work_q) {
@@ -466,7 +466,8 @@ struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
        struct device *cdev;
        struct Scsi_Host *shost = ERR_PTR(-ENXIO);
 
-       cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match);
+       cdev = class_find_device(&shost_class, NULL, &hostnum,
+                                __scsi_host_match);
        if (cdev) {
                shost = scsi_host_get(class_to_shost(cdev));
                put_device(cdev);
index 5fd64e7..a272b9a 100644 (file)
@@ -417,15 +417,16 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev,
        fc_host->next_vport_number = 0;
        fc_host->npiv_vports_inuse = 0;
 
-       snprintf(fc_host->work_q_name, KOBJ_NAME_LEN, "fc_wq_%d",
-               shost->host_no);
+       snprintf(fc_host->work_q_name, sizeof(fc_host->work_q_name),
+                "fc_wq_%d", shost->host_no);
        fc_host->work_q = create_singlethread_workqueue(
                                        fc_host->work_q_name);
        if (!fc_host->work_q)
                return -ENOMEM;
 
-       snprintf(fc_host->devloss_work_q_name, KOBJ_NAME_LEN, "fc_dl_%d",
-               shost->host_no);
+       snprintf(fc_host->devloss_work_q_name,
+                sizeof(fc_host->devloss_work_q_name),
+                "fc_dl_%d", shost->host_no);
        fc_host->devloss_work_q = create_singlethread_workqueue(
                                        fc_host->devloss_work_q_name);
        if (!fc_host->devloss_work_q) {
index 3af7cbc..043c392 100644 (file)
@@ -170,7 +170,7 @@ iscsi_create_endpoint(int dd_size)
        int err;
 
        for (id = 1; id < ISCSI_MAX_EPID; id++) {
-               dev = class_find_device(&iscsi_endpoint_class, &id,
+               dev = class_find_device(&iscsi_endpoint_class, NULL, &id,
                                        iscsi_match_epid);
                if (!dev)
                        break;
@@ -222,7 +222,7 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle)
        struct iscsi_endpoint *ep;
        struct device *dev;
 
-       dev = class_find_device(&iscsi_endpoint_class, &handle,
+       dev = class_find_device(&iscsi_endpoint_class, NULL, &handle,
                                iscsi_match_epid);
        if (!dev)
                return NULL;
@@ -247,8 +247,8 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev,
        atomic_set(&ihost->nr_scans, 0);
        mutex_init(&ihost->mutex);
 
-       snprintf(ihost->scan_workq_name, KOBJ_NAME_LEN, "iscsi_scan_%d",
-               shost->host_no);
+       snprintf(ihost->scan_workq_name, sizeof(ihost->scan_workq_name),
+                "iscsi_scan_%d", shost->host_no);
        ihost->scan_workq = create_singlethread_workqueue(
                                                ihost->scan_workq_name);
        if (!ihost->scan_workq)
index ce948b6..27f34a9 100644 (file)
@@ -1874,7 +1874,9 @@ static int serial8250_startup(struct uart_port *port)
                 * the interrupt is enabled.  Delays are necessary to
                 * allow register changes to become visible.
                 */
-               spin_lock_irqsave(&up->port.lock, flags);
+               spin_lock(&up->port.lock);
+               if (up->port.flags & UPF_SHARE_IRQ)
+                       disable_irq_nosync(up->port.irq);
 
                wait_for_xmitr(up, UART_LSR_THRE);
                serial_out_sync(up, UART_IER, UART_IER_THRI);
@@ -1886,7 +1888,9 @@ static int serial8250_startup(struct uart_port *port)
                iir = serial_in(up, UART_IIR);
                serial_out(up, UART_IER, 0);
 
-               spin_unlock_irqrestore(&up->port.lock, flags);
+               if (up->port.flags & UPF_SHARE_IRQ)
+                       enable_irq(up->port.irq);
+               spin_unlock(&up->port.lock);
 
                /*
                 * If the interrupt is not reasserted, setup a timer to
index abe129c..93e407e 100644 (file)
@@ -209,7 +209,7 @@ static void cpm_uart_int_rx(struct uart_port *port)
        int i;
        unsigned char ch;
        u8 *cp;
-       struct tty_struct *tty = port->info->tty;
+       struct tty_struct *tty = port->info->port.tty;
        struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port;
        cbd_t __iomem *bdp;
        u16 status;
index 9c2df5c..2b7531d 100644 (file)
@@ -730,7 +730,7 @@ static void xmit_interrupt(u16 port_int_reg, struct icom_port *icom_port)
 static void recv_interrupt(u16 port_int_reg, struct icom_port *icom_port)
 {
        short int count, rcv_buff;
-       struct tty_struct *tty = icom_port->uart_port.info->tty;
+       struct tty_struct *tty = icom_port->uart_port.info->port.tty;
        unsigned short int status;
        struct uart_icount *icount;
        unsigned long offset;
index 4a3ecaa..d852f83 100644 (file)
@@ -202,7 +202,7 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id)
 {
        struct s3c24xx_uart_port *ourport = dev_id;
        struct uart_port *port = &ourport->port;
-       struct tty_struct *tty = port->info->tty;
+       struct tty_struct *tty = port->info->port.tty;
        unsigned int ufcon, ch, flag, ufstat, uerstat;
        int max_count = 64;
 
index 0bce1fe..f977c98 100644 (file)
@@ -934,7 +934,7 @@ uart_tiocmset(struct tty_struct *tty, struct file *file,
        return ret;
 }
 
-static void uart_break_ctl(struct tty_struct *tty, int break_state)
+static int uart_break_ctl(struct tty_struct *tty, int break_state)
 {
        struct uart_state *state = tty->driver_data;
        struct uart_port *port = state->port;
@@ -945,6 +945,7 @@ static void uart_break_ctl(struct tty_struct *tty, int break_state)
                port->ops->break_ctl(port, break_state);
 
        mutex_unlock(&state->mutex);
+       return 0;
 }
 
 static int uart_do_autoconfig(struct uart_state *state)
index 7ad2192..8fcb4c5 100644 (file)
@@ -272,7 +272,7 @@ static void serial_txx9_initialize(struct uart_port *port)
 static inline void
 receive_chars(struct uart_txx9_port *up, unsigned int *status)
 {
-       struct tty_struct *tty = up->port.info->tty;
+       struct tty_struct *tty = up->port.info->port.tty;
        unsigned char ch;
        unsigned int disr = *status;
        int max_count = 256;
index 1ad12af..1771b24 100644 (file)
@@ -502,7 +502,7 @@ struct spi_master *spi_busnum_to_master(u16 bus_num)
        struct device           *dev;
        struct spi_master       *master = NULL;
 
-       dev = class_find_device(&spi_master_class, &bus_num,
+       dev = class_find_device(&spi_master_class, NULL, &bus_num,
                                __spi_master_match);
        if (dev)
                master = container_of(dev, struct spi_master, dev);
index ddbe1a5..2833fd7 100644 (file)
@@ -576,7 +576,8 @@ static int spidev_probe(struct spi_device *spi)
                struct device *dev;
 
                spidev->devt = MKDEV(SPIDEV_MAJOR, minor);
-               dev = device_create(spidev_class, &spi->dev, spidev->devt,
+               dev = device_create_drvdata(spidev_class, &spi->dev,
+                               spidev->devt, spidev,
                                "spidev%d.%d",
                                spi->master->bus_num, spi->chip_select);
                status = IS_ERR(dev) ? PTR_ERR(dev) : 0;
@@ -586,7 +587,6 @@ static int spidev_probe(struct spi_device *spi)
        }
        if (status == 0) {
                set_bit(minor, minors);
-               spi_set_drvdata(spi, spidev);
                list_add(&spidev->device_entry, &device_list);
        }
        mutex_unlock(&device_list_lock);
index a4aaab9..2e9079d 100644 (file)
@@ -15,7 +15,7 @@ if UIO
 
 config UIO_CIF
        tristate "generic Hilscher CIF Card driver"
-       depends on UIO && PCI
+       depends on PCI
        default n
        help
          Driver for Hilscher CIF DeviceNet and Profibus cards.  This
@@ -26,9 +26,15 @@ config UIO_CIF
          To compile this driver as a module, choose M here: the module
          will be called uio_cif.
 
+config UIO_PDRV
+       tristate "Userspace I/O platform driver"
+       help
+         Generic platform driver for Userspace I/O devices.
+
+         If you don't know what to do here, say N.
+
 config UIO_SMX
        tristate "SMX cryptengine UIO interface"
-       depends on UIO
        default n
        help
          Userspace IO interface to the Cryptography engine found on the
index 18c4566..e00ce0d 100644 (file)
@@ -1,3 +1,4 @@
 obj-$(CONFIG_UIO)      += uio.o
 obj-$(CONFIG_UIO_CIF)  += uio_cif.o
+obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o
 obj-$(CONFIG_UIO_SMX)  += uio_smx.o
index 5a7ca2e..3a6934b 100644 (file)
@@ -427,6 +427,31 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
        return retval;
 }
 
+static ssize_t uio_write(struct file *filep, const char __user *buf,
+                       size_t count, loff_t *ppos)
+{
+       struct uio_listener *listener = filep->private_data;
+       struct uio_device *idev = listener->dev;
+       ssize_t retval;
+       s32 irq_on;
+
+       if (idev->info->irq == UIO_IRQ_NONE)
+               return -EIO;
+
+       if (count != sizeof(s32))
+               return -EINVAL;
+
+       if (!idev->info->irqcontrol)
+               return -ENOSYS;
+
+       if (copy_from_user(&irq_on, buf, count))
+               return -EFAULT;
+
+       retval = idev->info->irqcontrol(idev->info, irq_on);
+
+       return retval ? retval : sizeof(s32);
+}
+
 static int uio_find_mem_index(struct vm_area_struct *vma)
 {
        int mi;
@@ -546,6 +571,7 @@ static const struct file_operations uio_fops = {
        .open           = uio_open,
        .release        = uio_release,
        .read           = uio_read,
+       .write          = uio_write,
        .mmap           = uio_mmap,
        .poll           = uio_poll,
        .fasync         = uio_fasync,
diff --git a/drivers/uio/uio_pdrv.c b/drivers/uio/uio_pdrv.c
new file mode 100644 (file)
index 0000000..5d0d2e8
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * drivers/uio/uio_pdrv.c
+ *
+ * Copyright (C) 2008 by Digi International Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+#include <linux/platform_device.h>
+#include <linux/uio_driver.h>
+#include <linux/stringify.h>
+
+#define DRIVER_NAME "uio"
+
+struct uio_platdata {
+       struct uio_info *uioinfo;
+};
+
+static int uio_pdrv_probe(struct platform_device *pdev)
+{
+       struct uio_info *uioinfo = pdev->dev.platform_data;
+       struct uio_platdata *pdata;
+       struct uio_mem *uiomem;
+       int ret = -ENODEV;
+       int i;
+
+       if (!uioinfo || !uioinfo->name || !uioinfo->version) {
+               dev_dbg(&pdev->dev, "%s: err_uioinfo\n", __func__);
+               goto err_uioinfo;
+       }
+
+       pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+       if (!pdata) {
+               ret = -ENOMEM;
+               dev_dbg(&pdev->dev, "%s: err_alloc_pdata\n", __func__);
+               goto err_alloc_pdata;
+       }
+
+       pdata->uioinfo = uioinfo;
+
+       uiomem = &uioinfo->mem[0];
+
+       for (i = 0; i < pdev->num_resources; ++i) {
+               struct resource *r = &pdev->resource[i];
+
+               if (r->flags != IORESOURCE_MEM)
+                       continue;
+
+               if (uiomem >= &uioinfo->mem[MAX_UIO_MAPS]) {
+                       dev_warn(&pdev->dev, "device has more than "
+                                       __stringify(MAX_UIO_MAPS)
+                                       " I/O memory resources.\n");
+                       break;
+               }
+
+               uiomem->memtype = UIO_MEM_PHYS;
+               uiomem->addr = r->start;
+               uiomem->size = r->end - r->start + 1;
+               ++uiomem;
+       }
+
+       while (uiomem < &uioinfo->mem[MAX_UIO_MAPS]) {
+               uiomem->size = 0;
+               ++uiomem;
+       }
+
+       pdata->uioinfo->priv = pdata;
+
+       ret = uio_register_device(&pdev->dev, pdata->uioinfo);
+
+       if (ret) {
+               kfree(pdata);
+err_alloc_pdata:
+err_uioinfo:
+               return ret;
+       }
+
+       platform_set_drvdata(pdev, pdata);
+
+       return 0;
+}
+
+static int uio_pdrv_remove(struct platform_device *pdev)
+{
+       struct uio_platdata *pdata = platform_get_drvdata(pdev);
+
+       uio_unregister_device(pdata->uioinfo);
+
+       return 0;
+}
+
+static struct platform_driver uio_pdrv = {
+       .probe = uio_pdrv_probe,
+       .remove = uio_pdrv_remove,
+       .driver = {
+               .name = DRIVER_NAME,
+               .owner = THIS_MODULE,
+       },
+};
+
+static int __init uio_pdrv_init(void)
+{
+       return platform_driver_register(&uio_pdrv);
+}
+
+static void __exit uio_pdrv_exit(void)
+{
+       platform_driver_unregister(&uio_pdrv);
+}
+module_init(uio_pdrv_init);
+module_exit(uio_pdrv_exit);
+
+MODULE_AUTHOR("Uwe Kleine-Koenig");
+MODULE_DESCRIPTION("Userspace I/O platform driver");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:" DRIVER_NAME);
index 95ae637..0725b18 100644 (file)
@@ -732,13 +732,16 @@ static void acm_tty_unthrottle(struct tty_struct *tty)
        tasklet_schedule(&acm->urb_task);
 }
 
-static void acm_tty_break_ctl(struct tty_struct *tty, int state)
+static int acm_tty_break_ctl(struct tty_struct *tty, int state)
 {
        struct acm *acm = tty->driver_data;
+       int retval;
        if (!ACM_READY(acm))
-               return;
-       if (acm_send_break(acm, state ? 0xffff : 0))
+               return -EINVAL;
+       retval = acm_send_break(acm, state ? 0xffff : 0);
+       if (retval < 0)
                dbg("send break failed");
+       return retval;
 }
 
 static int acm_tty_tiocmget(struct tty_struct *tty, struct file *file)
index 54a350c..20290c5 100644 (file)
@@ -1729,9 +1729,9 @@ static int usb_classdev_add(struct usb_device *dev)
 {
        struct device *cldev;
 
-       cldev = device_create(usb_classdev_class, &dev->dev, dev->dev.devt,
-                             "usbdev%d.%d", dev->bus->busnum,
-                             dev->devnum);
+       cldev = device_create_drvdata(usb_classdev_class, &dev->dev,
+                                     dev->dev.devt, NULL, "usbdev%d.%d",
+                                     dev->bus->busnum, dev->devnum);
        if (IS_ERR(cldev))
                return PTR_ERR(cldev);
        dev->usb_classdev = cldev;
@@ -1792,6 +1792,11 @@ int __init usb_devio_init(void)
                usb_classdev_class = NULL;
                goto out;
        }
+       /* devices of this class shadow the major:minor of their parent
+        * device, so clear ->dev_kobj to prevent adding duplicate entries
+        * to /sys/dev
+        */
+       usb_classdev_class->dev_kobj = NULL;
 
        usb_register_notify(&usbdev_nb);
 #endif
index 913fb86..6b1b229 100644 (file)
@@ -196,8 +196,9 @@ int usb_register_dev(struct usb_interface *intf,
                ++temp;
        else
                temp = name;
-       intf->usb_dev = device_create(usb_class->class, &intf->dev,
-                                     MKDEV(USB_MAJOR, minor), "%s", temp);
+       intf->usb_dev = device_create_drvdata(usb_class->class, &intf->dev,
+                                             MKDEV(USB_MAJOR, minor), NULL,
+                                             "%s", temp);
        if (IS_ERR(intf->usb_dev)) {
                down_write(&minor_rwsem);
                usb_minors[intf->minor] = NULL;
index 9caaec3..49cd9e1 100644 (file)
@@ -1360,8 +1360,8 @@ printer_bind(struct usb_gadget *gadget)
 
 
        /* Setup the sysfs files for the printer gadget. */
-       dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno,
-                       "g_printer");
+       dev->pdev = device_create_drvdata(usb_gadget_class, NULL,
+                                         g_printer_devno, NULL, "g_printer");
        if (IS_ERR(dev->pdev)) {
                ERROR(dev, "Failed to create device: g_printer\n");
                goto fail;
index 293a462..6566fc0 100644 (file)
@@ -1162,8 +1162,9 @@ int mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus)
        if (minor >= MON_BIN_MAX_MINOR)
                return 0;
 
-       dev = device_create(mon_bin_class, ubus? ubus->controller: NULL,
-                       MKDEV(MAJOR(mon_bin_dev0), minor), "usbmon%d", minor);
+       dev = device_create_drvdata(mon_bin_class, ubus? ubus->controller: NULL,
+                                   MKDEV(MAJOR(mon_bin_dev0), minor), NULL,
+                                   "usbmon%d", minor);
        if (IS_ERR(dev))
                return 0;
 
index db6f97a..79ea98c 100644 (file)
@@ -272,7 +272,7 @@ static void aircable_read(struct work_struct *work)
         * 64 bytes, to ensure I do not get throttled.
         * Ask USB mailing list for better aproach.
         */
-       tty = port->tty;
+       tty = port->port.tty;
 
        if (!tty) {
                schedule_work(&priv->rx_work);
@@ -378,13 +378,14 @@ static void aircable_shutdown(struct usb_serial *serial)
        }
 }
 
-static int aircable_write_room(struct usb_serial_port *port)
+static int aircable_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct aircable_private *priv = usb_get_serial_port_data(port);
        return serial_buf_data_avail(priv->tx_buf);
 }
 
-static int aircable_write(struct usb_serial_port *port,
+static int aircable_write(struct tty_struct *tty, struct usb_serial_port *port,
                          const unsigned char *source, int count)
 {
        struct aircable_private *priv = usb_get_serial_port_data(port);
@@ -466,7 +467,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
 
        if (status) {
                dbg("%s - urb status = %d", __func__, status);
-               if (!port->open_count) {
+               if (!port->port.count) {
                        dbg("%s - port is closed, exiting.", __func__);
                        return;
                }
@@ -494,7 +495,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
        usb_serial_debug_data(debug, &port->dev, __func__,
                                urb->actual_length, urb->transfer_buffer);
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (tty && urb->actual_length) {
                if (urb->actual_length <= 2) {
                        /* This is an incomplete package */
@@ -528,7 +529,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
        }
 
        /* Schedule the next read _if_ we are still open */
-       if (port->open_count) {
+       if (port->port.count) {
                usb_fill_bulk_urb(port->read_urb, port->serial->dev,
                                  usb_rcvbulkpipe(port->serial->dev,
                                          port->bulk_in_endpointAddress),
@@ -547,8 +548,9 @@ static void aircable_read_bulk_callback(struct urb *urb)
 }
 
 /* Based on ftdi_sio.c throttle */
-static void aircable_throttle(struct usb_serial_port *port)
+static void aircable_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct aircable_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
 
@@ -560,8 +562,9 @@ static void aircable_throttle(struct usb_serial_port *port)
 }
 
 /* Based on ftdi_sio.c unthrottle */
-static void aircable_unthrottle(struct usb_serial_port *port)
+static void aircable_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct aircable_private *priv = usb_get_serial_port_data(port);
        int actually_throttled;
        unsigned long flags;
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
new file mode 100644 (file)
index 0000000..b3f1d1e
--- /dev/null
@@ -0,0 +1,355 @@
+/*
+ * AirPrime CDMA Wireless Serial USB driver
+ *
+ * Copyright (C) 2005-2006 Greg Kroah-Hartman <gregkh@suse.de>
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License version
+ *     2 as published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/module.h>
+#include <linux/usb.h>
+#include <linux/usb/serial.h>
+
+static struct usb_device_id id_table [] = {
+       { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
+       { },
+};
+MODULE_DEVICE_TABLE(usb, id_table);
+
+#define URB_TRANSFER_BUFFER_SIZE       4096
+#define NUM_READ_URBS                  4
+#define NUM_WRITE_URBS                 4
+#define NUM_BULK_EPS                   3
+#define MAX_BULK_EPS                   6
+
+/* if overridden by the user, then use their value for the size of the
+ * read and write urbs, and the number of endpoints */
+static int buffer_size = URB_TRANSFER_BUFFER_SIZE;
+static int endpoints = NUM_BULK_EPS;
+static int debug;
+struct airprime_private {
+       spinlock_t lock;
+       int outstanding_urbs;
+       int throttled;
+       struct urb *read_urbp[NUM_READ_URBS];
+
+       /* Settings for the port */
+       int rts_state;  /* Handshaking pins (outputs) */
+       int dtr_state;
+       int cts_state;  /* Handshaking pins (inputs) */
+       int dsr_state;
+       int dcd_state;
+       int ri_state;
+};
+
+static int airprime_send_setup(struct usb_serial_port *port)
+{
+       struct usb_serial *serial = port->serial;
+       struct airprime_private *priv;
+
+       dbg("%s", __func__);
+
+       if (port->number != 0)
+               return 0;
+
+       priv = usb_get_serial_port_data(port);
+
+       if (port->port.tty) {
+               int val = 0;
+               if (priv->dtr_state)
+                       val |= 0x01;
+               if (priv->rts_state)
+                       val |= 0x02;
+
+               return usb_control_msg(serial->dev,
+                                       usb_rcvctrlpipe(serial->dev, 0),
+                                       0x22, 0x21, val, 0, NULL, 0,
+                                       USB_CTRL_SET_TIMEOUT);
+       }
+
+       return 0;
+}
+
+static void airprime_read_bulk_callback(struct urb *urb)
+{
+       struct usb_serial_port *port = urb->context;
+       unsigned char *data = urb->transfer_buffer;
+       struct tty_struct *tty;
+       int result;
+       int status = urb->status;
+
+       dbg("%s - port %d", __func__, port->number);
+
+       if (status) {
+               dbg("%s - nonzero read bulk status received: %d",
+                   __func__, status);
+               return;
+       }
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                               urb->actual_length, data);
+
+       tty = port->port.tty;
+       if (tty && urb->actual_length) {
+               tty_insert_flip_string(tty, data, urb->actual_length);
+               tty_flip_buffer_push(tty);
+       }
+
+       result = usb_submit_urb(urb, GFP_ATOMIC);
+       if (result)
+               dev_err(&port->dev,
+                       "%s - failed resubmitting read urb, error %d\n",
+                       __func__, result);
+       return;
+}
+
+static void airprime_write_bulk_callback(struct urb *urb)
+{
+       struct usb_serial_port *port = urb->context;
+       struct airprime_private *priv = usb_get_serial_port_data(port);
+       int status = urb->status;
+       unsigned long flags;
+
+       dbg("%s - port %d", __func__, port->number);
+
+       /* free up the transfer buffer, as usb_free_urb() does not do this */
+       kfree(urb->transfer_buffer);
+
+       if (status)
+               dbg("%s - nonzero write bulk status received: %d",
+                   __func__, status);
+       spin_lock_irqsave(&priv->lock, flags);
+       --priv->outstanding_urbs;
+       spin_unlock_irqrestore(&priv->lock, flags);
+
+       usb_serial_port_softint(port);
+}
+
+static int airprime_open(struct tty_struct *tty, struct usb_serial_port *port,
+                                                       struct file *filp)
+{
+       struct airprime_private *priv = usb_get_serial_port_data(port);
+       struct usb_serial *serial = port->serial;
+       struct urb *urb;
+       char *buffer = NULL;
+       int i;
+       int result = 0;
+
+       dbg("%s - port %d", __func__, port->number);
+
+       /* initialize our private data structure if it isn't already created */
+       if (!priv) {
+               priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+               if (!priv) {
+                       result = -ENOMEM;
+                       goto out;
+               }
+               spin_lock_init(&priv->lock);
+               usb_set_serial_port_data(port, priv);
+       }
+
+       /* Set some sane defaults */
+       priv->rts_state = 1;
+       priv->dtr_state = 1;
+
+       for (i = 0; i < NUM_READ_URBS; ++i) {
+               buffer = kmalloc(buffer_size, GFP_KERNEL);
+               if (!buffer) {
+                       dev_err(&port->dev, "%s - out of memory.\n",
+                               __func__);
+                       result = -ENOMEM;
+                       goto errout;
+               }
+               urb = usb_alloc_urb(0, GFP_KERNEL);
+               if (!urb) {
+                       kfree(buffer);
+                       dev_err(&port->dev, "%s - no more urbs?\n",
+                               __func__);
+                       result = -ENOMEM;
+                       goto errout;
+               }
+               usb_fill_bulk_urb(urb, serial->dev,
+                                 usb_rcvbulkpipe(serial->dev,
+                                         port->bulk_out_endpointAddress),
+                                 buffer, buffer_size,
+                                 airprime_read_bulk_callback, port);
+               result = usb_submit_urb(urb, GFP_KERNEL);
+               if (result) {
+                       usb_free_urb(urb);
+                       kfree(buffer);
+                       dev_err(&port->dev,
+                               "%s - failed submitting read urb %d for port %d, error %d\n",
+                               __func__, i, port->number, result);
+                       goto errout;
+               }
+               /* remember this urb so we can kill it when the
+                  port is closed */
+               priv->read_urbp[i] = urb;
+       }
+
+       airprime_send_setup(port);
+
+       goto out;
+
+ errout:
+       /* some error happened, cancel any submitted urbs and clean up
+          anything that got allocated successfully */
+
+       while (i-- != 0) {
+               urb = priv->read_urbp[i];
+               buffer = urb->transfer_buffer;
+               usb_kill_urb(urb);
+               usb_free_urb(urb);
+               kfree(buffer);
+       }
+
+ out:
+       return result;
+}
+
+static void airprime_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
+{
+       struct airprime_private *priv = usb_get_serial_port_data(port);
+       int i;
+
+       dbg("%s - port %d", __func__, port->number);
+
+       priv->rts_state = 0;
+       priv->dtr_state = 0;
+
+       mutex_lock(&port->serial->disc_mutex);
+       if (!port->serial->disconnected)
+               airprime_send_setup(port);
+       mutex_unlock(&port->serial->disc_mutex);
+
+       for (i = 0; i < NUM_READ_URBS; ++i) {
+               usb_kill_urb(priv->read_urbp[i]);
+               kfree(priv->read_urbp[i]->transfer_buffer);
+               usb_free_urb(priv->read_urbp[i]);
+       }
+
+       /* free up private structure */
+       kfree(priv);
+       usb_set_serial_port_data(port, NULL);
+}
+
+static int airprime_write(struct tty_struct *tty, struct usb_serial_port *port,
+                         const unsigned char *buf, int count)
+{
+       struct airprime_private *priv = usb_get_serial_port_data(port);
+       struct usb_serial *serial = port->serial;
+       struct urb *urb;
+       unsigned char *buffer;
+       unsigned long flags;
+       int status;
+       dbg("%s - port %d", __func__, port->number);
+
+       spin_lock_irqsave(&priv->lock, flags);
+       if (priv->outstanding_urbs > NUM_WRITE_URBS) {
+               spin_unlock_irqrestore(&priv->lock, flags);
+               dbg("%s - write limit hit\n", __func__);
+               return 0;
+       }
+       spin_unlock_irqrestore(&priv->lock, flags);
+       buffer = kmalloc(count, GFP_ATOMIC);
+       if (!buffer) {
+               dev_err(&port->dev, "out of memory\n");
+               return -ENOMEM;
+       }
+       urb = usb_alloc_urb(0, GFP_ATOMIC);
+       if (!urb) {
+               dev_err(&port->dev, "no more free urbs\n");
+               kfree(buffer);
+               return -ENOMEM;
+       }
+       memcpy(buffer, buf, count);
+
+       usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
+
+       usb_fill_bulk_urb(urb, serial->dev,
+                         usb_sndbulkpipe(serial->dev,
+                                         port->bulk_out_endpointAddress),
+                         buffer, count,
+                         airprime_write_bulk_callback, port);
+
+       /* send it down the pipe */
+       status = usb_submit_urb(urb, GFP_ATOMIC);
+       if (status) {
+               dev_err(&port->dev,
+                       "%s - usb_submit_urb(write bulk) failed with status = %d\n",
+                       __func__, status);
+               count = status;
+               kfree(buffer);
+       } else {
+               spin_lock_irqsave(&priv->lock, flags);
+               ++priv->outstanding_urbs;
+               spin_unlock_irqrestore(&priv->lock, flags);
+       }
+       /* we are done with this urb, so let the host driver
+        * really free it when it is finished with it */
+       usb_free_urb(urb);
+       return count;
+}
+
+static struct usb_driver airprime_driver = {
+       .name =         "airprime",
+       .probe =        usb_serial_probe,
+       .disconnect =   usb_serial_disconnect,
+       .id_table =     id_table,
+       .no_dynamic_id =        1,
+};
+
+static struct usb_serial_driver airprime_device = {
+       .driver = {
+               .owner =        THIS_MODULE,
+               .name =         "airprime",
+       },
+       .usb_driver =           &airprime_driver,
+       .id_table =             id_table,
+       .open =                 airprime_open,
+       .close =                airprime_close,
+       .write =                airprime_write,
+};
+
+static int __init airprime_init(void)
+{
+       int retval;
+
+       airprime_device.num_ports = endpoints;
+       if (endpoints < 0 || endpoints >= MAX_BULK_EPS)
+               airprime_device.num_ports = NUM_BULK_EPS;
+
+       retval = usb_serial_register(&airprime_device);
+       if (retval)
+               return retval;
+       retval = usb_register(&airprime_driver);
+       if (retval)
+               usb_serial_deregister(&airprime_device);
+       return retval;
+}
+
+static void __exit airprime_exit(void)
+{
+       dbg("%s", __func__);
+
+       usb_deregister(&airprime_driver);
+       usb_serial_deregister(&airprime_device);
+}
+
+module_init(airprime_init);
+module_exit(airprime_exit);
+MODULE_LICENSE("GPL");
+
+module_param(debug, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(debug, "Debug enabled");
+module_param(buffer_size, int, 0);
+MODULE_PARM_DESC(buffer_size,
+               "Size of the transfer buffers in bytes (default 4096)");
+module_param(endpoints, int, 0);
+MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)");
index 77895c8..aec6188 100644 (file)
@@ -158,12 +158,13 @@ cleanup:
        return -ENOMEM;
 }
 
-static void ark3116_set_termios(struct usb_serial_port *port,
+static void ark3116_set_termios(struct tty_struct *tty,
+                               struct usb_serial_port *port,
                                struct ktermios *old_termios)
 {
        struct usb_serial *serial = port->serial;
        struct ark3116_private *priv = usb_get_serial_port_data(port);
-       struct ktermios *termios = port->tty->termios;
+       struct ktermios *termios = tty->termios;
        unsigned int cflag = termios->c_cflag;
        unsigned long flags;
        int baud;
@@ -177,8 +178,8 @@ static void ark3116_set_termios(struct usb_serial_port *port,
 
        spin_lock_irqsave(&priv->lock, flags);
        if (!priv->termios_initialized) {
-               *(port->tty->termios) = tty_std_termios;
-               port->tty->termios->c_cflag = B9600 | CS8
+               *termios = tty_std_termios;
+               termios->c_cflag = B9600 | CS8
                                              | CREAD | HUPCL | CLOCAL;
                termios->c_ispeed = 9600;
                termios->c_ospeed = 9600;
@@ -192,7 +193,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
        buf = kmalloc(1, GFP_KERNEL);
        if (!buf) {
                dbg("error kmalloc");
-               *port->tty->termios = *old_termios;
+               *termios = *old_termios;
                return;
        }
 
@@ -243,7 +244,7 @@ static void ark3116_set_termios(struct usb_serial_port *port,
        }
 
        /* set baudrate */
-       baud = tty_get_baud_rate(port->tty);
+       baud = tty_get_baud_rate(tty);
 
        switch (baud) {
        case 75:
@@ -262,11 +263,11 @@ static void ark3116_set_termios(struct usb_serial_port *port,
        case 230400:
        case 460800:
                /* Report the resulting rate back to the caller */
-               tty_encode_baud_rate(port->tty, baud, baud);
+               tty_encode_baud_rate(tty, baud, baud);
                break;
        /* set 9600 as default (if given baudrate is invalid for example) */
        default:
-               tty_encode_baud_rate(port->tty, 9600, 9600);
+               tty_encode_baud_rate(tty, 9600, 9600);
        case 0:
                baud = 9600;
        }
@@ -317,7 +318,8 @@ static void ark3116_set_termios(struct usb_serial_port *port,
        return;
 }
 
-static int ark3116_open(struct usb_serial_port *port, struct file *filp)
+static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port,
+                                       struct file *filp)
 {
        struct ktermios tmp_termios;
        struct usb_serial *serial = port->serial;
@@ -332,7 +334,7 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp)
                return -ENOMEM;
        }
 
-       result = usb_serial_generic_open(port, filp);
+       result = usb_serial_generic_open(tty, port, filp);
        if (result)
                goto err_out;
 
@@ -362,8 +364,8 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp)
        ARK3116_RCV(serial, 124, 0xFE, 0xC0, 0x0000, 0x0006, 0xFF, buf);
 
        /* initialise termios */
-       if (port->tty)
-               ark3116_set_termios(port, &tmp_termios);
+       if (tty)
+               ark3116_set_termios(tty, port, &tmp_termios);
 
 err_out:
        kfree(buf);
@@ -371,9 +373,10 @@ err_out:
        return result;
 }
 
-static int ark3116_ioctl(struct usb_serial_port *port, struct file *file,
+static int ark3116_ioctl(struct tty_struct *tty, struct file *file,
                         unsigned int cmd, unsigned long arg)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct serial_struct serstruct;
        void __user *user_arg = (void __user *)arg;
 
@@ -403,8 +406,9 @@ static int ark3116_ioctl(struct usb_serial_port *port, struct file *file,
        return -ENOIOCTLCMD;
 }
 
-static int ark3116_tiocmget(struct usb_serial_port *port, struct file *file)
+static int ark3116_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
        char *buf;
        char temp;
index 0a322fc..2ebe06c 100644 (file)
@@ -7,13 +7,14 @@
  *  This program is largely derived from work by the linux-usb group
  *  and associated source files.  Please see the usb/serial files for
  *  individual credits and copyrights.
- *  
+ *
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
  *     the Free Software Foundation; either version 2 of the License, or
  *     (at your option) any later version.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  *
  * TODO:
  * -- Add true modem contol line query capability.  Currently we track the
@@ -28,7 +29,8 @@
  *     compressed all the differnent device entries into 1.
  *
  * 30-May-2001 gkh
- *     switched from using spinlock to a semaphore, which fixes lots of problems.
+ *     switched from using spinlock to a semaphore, which fixes lots of
+ *     problems.
  *
  * 08-Apr-2001 gb
  *     - Identify version on module load.
@@ -41,7 +43,7 @@
  *     - Added support for the old Belkin and Peracom devices.
  *     - Made the port able to be opened multiple times.
  *     - Added some defaults incase the line settings are things these devices
- *       can't support. 
+ *       can't support.
  *
  * 18-Oct-2000 William Greathouse
  *    Released into the wild (linux-usb-devel)
@@ -72,7 +74,7 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include "belkin_sa.h"
@@ -87,16 +89,19 @@ static int debug;
 #define DRIVER_DESC "USB Belkin Serial converter driver"
 
 /* function prototypes for a Belkin USB Serial Adapter F5U103 */
-static int  belkin_sa_startup          (struct usb_serial *serial);
-static void belkin_sa_shutdown         (struct usb_serial *serial);
-static int  belkin_sa_open             (struct usb_serial_port *port, struct file *filp);
-static void belkin_sa_close            (struct usb_serial_port *port, struct file *filp);
-static void belkin_sa_read_int_callback (struct urb *urb);
-static void belkin_sa_set_termios      (struct usb_serial_port *port, struct ktermios * old);
-static int  belkin_sa_ioctl            (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
-static void belkin_sa_break_ctl                (struct usb_serial_port *port, int break_state );
-static int  belkin_sa_tiocmget         (struct usb_serial_port *port, struct file *file);
-static int  belkin_sa_tiocmset         (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
+static int  belkin_sa_startup(struct usb_serial *serial);
+static void belkin_sa_shutdown(struct usb_serial *serial);
+static int  belkin_sa_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void belkin_sa_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void belkin_sa_read_int_callback(struct urb *urb);
+static void belkin_sa_set_termios(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct ktermios * old);
+static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state);
+static int  belkin_sa_tiocmget(struct tty_struct *tty, struct file *file);
+static int  belkin_sa_tiocmset(struct tty_struct *tty, struct file *file,
+                                       unsigned int set, unsigned int clear);
 
 
 static struct usb_device_id id_table_combined [] = {
@@ -106,10 +111,10 @@ static struct usb_device_id id_table_combined [] = {
        { USB_DEVICE(GOHUBS_VID, GOHUBS_PID) },
        { USB_DEVICE(GOHUBS_VID, HANDYLINK_PID) },
        { USB_DEVICE(BELKIN_DOCKSTATION_VID, BELKIN_DOCKSTATION_PID) },
-       { }                                                     /* Terminating entry */
+       { }     /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table_combined);
+MODULE_DEVICE_TABLE(usb, id_table_combined);
 
 static struct usb_driver belkin_driver = {
        .name =         "belkin",
@@ -131,8 +136,8 @@ static struct usb_serial_driver belkin_device = {
        .num_ports =            1,
        .open =                 belkin_sa_open,
        .close =                belkin_sa_close,
-       .read_int_callback =    belkin_sa_read_int_callback,    /* How we get the status info */
-       .ioctl =                belkin_sa_ioctl,
+       .read_int_callback =    belkin_sa_read_int_callback,
+                                       /* How we get the status info */
        .set_termios =          belkin_sa_set_termios,
        .break_ctl =            belkin_sa_break_ctl,
        .tiocmget =             belkin_sa_tiocmget,
@@ -160,12 +165,12 @@ struct belkin_sa_private {
 #define WDR_TIMEOUT 5000 /* default urb timeout */
 
 /* assumes that struct usb_serial *serial is available */
-#define BSA_USB_CMD(c,v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \
+#define BSA_USB_CMD(c, v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \
                                            (c), BELKIN_SA_SET_REQUEST_TYPE, \
                                            (v), 0, NULL, 0, WDR_TIMEOUT)
 
 /* do some startup allocations not currently performed by usb_serial_probe() */
-static int belkin_sa_startup (struct usb_serial *serial)
+static int belkin_sa_startup(struct usb_serial *serial)
 {
        struct usb_device *dev = serial->dev;
        struct belkin_sa_private *priv;
@@ -173,32 +178,35 @@ static int belkin_sa_startup (struct usb_serial *serial)
        /* allocate the private data structure */
        priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);
        if (!priv)
-               return (-1); /* error */
+               return -1; /* error */
        /* set initial values for control structures */
        spin_lock_init(&priv->lock);
        priv->control_state = 0;
        priv->last_lsr = 0;
        priv->last_msr = 0;
        /* see comments at top of file */
-       priv->bad_flow_control = (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0;
-       info("bcdDevice: %04x, bfc: %d", le16_to_cpu(dev->descriptor.bcdDevice), priv->bad_flow_control);
+       priv->bad_flow_control =
+               (le16_to_cpu(dev->descriptor.bcdDevice) <= 0x0206) ? 1 : 0;
+       info("bcdDevice: %04x, bfc: %d",
+                                       le16_to_cpu(dev->descriptor.bcdDevice),
+                                       priv->bad_flow_control);
 
        init_waitqueue_head(&serial->port[0]->write_wait);
        usb_set_serial_port_data(serial->port[0], priv);
-       
-       return (0);
+
+       return 0;
 }
 
 
-static void belkin_sa_shutdown (struct usb_serial *serial)
+static void belkin_sa_shutdown(struct usb_serial *serial)
 {
        struct belkin_sa_private *priv;
        int i;
-       
-       dbg ("%s", __func__);
+
+       dbg("%s", __func__);
 
        /* stop reads and writes on all ports */
-       for (i=0; i < serial->num_ports; ++i) {
+       for (i = 0; i < serial->num_ports; ++i) {
                /* My special items, the standard routines free my urbs */
                priv = usb_get_serial_port_data(serial->port[i]);
                kfree(priv);
@@ -206,7 +214,8 @@ static void belkin_sa_shutdown (struct usb_serial *serial)
 }
 
 
-static int  belkin_sa_open (struct usb_serial_port *port, struct file *filp)
+static int  belkin_sa_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        int retval = 0;
 
@@ -235,7 +244,8 @@ exit:
 } /* belkin_sa_open */
 
 
-static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
+static void belkin_sa_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        dbg("%s port %d", __func__, port->number);
 
@@ -246,7 +256,7 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp)
 } /* belkin_sa_close */
 
 
-static void belkin_sa_read_int_callback (struct urb *urb)
+static void belkin_sa_read_int_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        struct belkin_sa_private *priv;
@@ -272,7 +282,8 @@ static void belkin_sa_read_int_callback (struct urb *urb)
                goto exit;
        }
 
-       usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                       urb->actual_length, data);
 
        /* Handle known interrupt data */
        /* ignore data[0] and data[1] */
@@ -280,7 +291,7 @@ static void belkin_sa_read_int_callback (struct urb *urb)
        priv = usb_get_serial_port_data(port);
        spin_lock_irqsave(&priv->lock, flags);
        priv->last_msr = data[BELKIN_SA_MSR_INDEX];
-       
+
        /* Record Control Line states */
        if (priv->last_msr & BELKIN_SA_MSR_DSR)
                priv->control_state |= TIOCM_DSR;
@@ -311,7 +322,7 @@ static void belkin_sa_read_int_callback (struct urb *urb)
         * to look in to this before committing any code.
         */
        if (priv->last_lsr & BELKIN_SA_LSR_ERR) {
-               tty = port->tty;
+               tty = port->port.tty;
                /* Overrun Error */
                if (priv->last_lsr & BELKIN_SA_LSR_OE) {
                }
@@ -328,13 +339,14 @@ static void belkin_sa_read_int_callback (struct urb *urb)
 #endif
        spin_unlock_irqrestore(&priv->lock, flags);
 exit:
-       retval = usb_submit_urb (urb, GFP_ATOMIC);
+       retval = usb_submit_urb(urb, GFP_ATOMIC);
        if (retval)
-               err ("%s - usb_submit_urb failed with result %d",
+               err("%s - usb_submit_urb failed with result %d",
                     __func__, retval);
 }
 
-static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
+static void belkin_sa_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct usb_serial *serial = port->serial;
        struct belkin_sa_private *priv = usb_get_serial_port_data(port);
@@ -347,8 +359,8 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
        unsigned long control_state;
        int bad_flow_control;
        speed_t baud;
-       struct ktermios *termios = port->tty->termios;
-       
+       struct ktermios *termios = tty->termios;
+
        iflag = termios->c_iflag;
        cflag = termios->c_cflag;
 
@@ -359,25 +371,26 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
        control_state = priv->control_state;
        bad_flow_control = priv->bad_flow_control;
        spin_unlock_irqrestore(&priv->lock, flags);
-       
+
        old_iflag = old_termios->c_iflag;
        old_cflag = old_termios->c_cflag;
 
        /* Set the baud rate */
        if ((cflag & CBAUD) != (old_cflag & CBAUD)) {
                /* reassert DTR and (maybe) RTS on transition from B0 */
-               if( (old_cflag&CBAUD) == B0 ) {
+               if ((old_cflag & CBAUD) == B0) {
                        control_state |= (TIOCM_DTR|TIOCM_RTS);
                        if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0)
                                err("Set DTR error");
                        /* don't set RTS if using hardware flow control */
                        if (!(old_cflag & CRTSCTS))
-                               if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0)
+                               if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST
+                                                               , 1) < 0)
                                        err("Set RTS error");
                }
        }
 
-       baud = tty_get_baud_rate(port->tty);
+       baud = tty_get_baud_rate(tty);
        if (baud) {
                urb_value = BELKIN_SA_BAUD(baud);
                /* Clip to maximum speed */
@@ -387,12 +400,13 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
                baud = BELKIN_SA_BAUD(urb_value);
 
                /* Report the actual baud rate back to the caller */
-               tty_encode_baud_rate(port->tty, baud, baud);
+               tty_encode_baud_rate(tty, baud, baud);
                if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0)
                        err("Set baudrate error");
        } else {
                /* Disable flow control */
-               if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, BELKIN_SA_FLOW_NONE) < 0)
+               if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST,
+                                               BELKIN_SA_FLOW_NONE) < 0)
                        err("Disable flowcontrol error");
                /* Drop RTS and DTR */
                control_state &= ~(TIOCM_DTR | TIOCM_RTS);
@@ -403,9 +417,10 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
        }
 
        /* set the parity */
-       if( (cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD)) ) {
+       if ((cflag ^ old_cflag) & (PARENB | PARODD)) {
                if (cflag & PARENB)
-                       urb_value = (cflag & PARODD) ?  BELKIN_SA_PARITY_ODD : BELKIN_SA_PARITY_EVEN;
+                       urb_value = (cflag & PARODD) ?  BELKIN_SA_PARITY_ODD
+                                               : BELKIN_SA_PARITY_EVEN;
                else
                        urb_value = BELKIN_SA_PARITY_NONE;
                if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0)
@@ -413,31 +428,40 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
        }
 
        /* set the number of data bits */
-       if( (cflag&CSIZE) != (old_cflag&CSIZE) ) {
+       if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
                switch (cflag & CSIZE) {
-                       case CS5: urb_value = BELKIN_SA_DATA_BITS(5); break;
-                       case CS6: urb_value = BELKIN_SA_DATA_BITS(6); break;
-                       case CS7: urb_value = BELKIN_SA_DATA_BITS(7); break;
-                       case CS8: urb_value = BELKIN_SA_DATA_BITS(8); break;
-                       default: dbg("CSIZE was not CS5-CS8, using default of 8");
-                               urb_value = BELKIN_SA_DATA_BITS(8);
-                               break;
+               case CS5:
+                       urb_value = BELKIN_SA_DATA_BITS(5);
+                       break;
+               case CS6:
+                       urb_value = BELKIN_SA_DATA_BITS(6);
+                       break;
+               case CS7:
+                       urb_value = BELKIN_SA_DATA_BITS(7);
+                       break;
+               case CS8:
+                       urb_value = BELKIN_SA_DATA_BITS(8);
+                       break;
+               default: dbg("CSIZE was not CS5-CS8, using default of 8");
+                       urb_value = BELKIN_SA_DATA_BITS(8);
+                       break;
                }
                if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0)
                        err("Set data bits error");
        }
 
        /* set the number of stop bits */
-       if( (cflag&CSTOPB) != (old_cflag&CSTOPB) ) {
-               urb_value = (cflag & CSTOPB) ? BELKIN_SA_STOP_BITS(2) : BELKIN_SA_STOP_BITS(1);
-               if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, urb_value) < 0)
+       if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) {
+               urb_value = (cflag & CSTOPB) ? BELKIN_SA_STOP_BITS(2)
+                                               : BELKIN_SA_STOP_BITS(1);
+               if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST,
+                                                       urb_value) < 0)
                        err("Set stop bits error");
        }
 
        /* Set flow control */
-       if( (iflag&IXOFF)   != (old_iflag&IXOFF)
-       ||      (iflag&IXON)    != (old_iflag&IXON)
-       ||  (cflag&CRTSCTS) != (old_cflag&CRTSCTS) ) {
+       if (((iflag ^ old_iflag) & (IXOFF | IXON)) ||
+               ((cflag ^ old_cflag) & CRTSCTS)) {
                urb_value = 0;
                if ((iflag & IXOFF) || (iflag & IXON))
                        urb_value |= (BELKIN_SA_FLOW_OXON | BELKIN_SA_FLOW_IXON);
@@ -463,8 +487,9 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios
 } /* belkin_sa_set_termios */
 
 
-static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state )
+static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
 
        if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0)
@@ -472,12 +497,13 @@ static void belkin_sa_break_ctl( struct usb_serial_port *port, int break_state )
 }
 
 
-static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file)
+static int belkin_sa_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct belkin_sa_private *priv = usb_get_serial_port_data(port);
        unsigned long control_state;
        unsigned long flags;
-       
+
        dbg("%s", __func__);
 
        spin_lock_irqsave(&priv->lock, flags);
@@ -488,9 +514,10 @@ static int belkin_sa_tiocmget (struct usb_serial_port *port, struct file *file)
 }
 
 
-static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file,
+static int belkin_sa_tiocmset(struct tty_struct *tty, struct file *file,
                               unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
        struct belkin_sa_private *priv = usb_get_serial_port_data(port);
        unsigned long control_state;
@@ -498,7 +525,7 @@ static int belkin_sa_tiocmset (struct usb_serial_port *port, struct file *file,
        int retval;
        int rts = 0;
        int dtr = 0;
-       
+
        dbg("%s", __func__);
 
        spin_lock_irqsave(&priv->lock, flags);
@@ -540,29 +567,7 @@ exit:
 }
 
 
-static int belkin_sa_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
-{
-       switch (cmd) {
-       case TIOCMIWAIT:
-               /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
-               /* TODO */
-               return( 0 );
-
-       case TIOCGICOUNT:
-               /* return count of modemline transitions */
-               /* TODO */
-               return 0;
-
-       default:
-               dbg("belkin_sa_ioctl arg not supported - 0x%04x",cmd);
-               return(-ENOIOCTLCMD);
-               break;
-       }
-       return 0;
-} /* belkin_sa_ioctl */
-
-
-static int __init belkin_sa_init (void)
+static int __init belkin_sa_init(void)
 {
        int retval;
        retval = usb_serial_register(&belkin_device);
@@ -582,17 +587,17 @@ failed_usb_serial_register:
 
 static void __exit belkin_sa_exit (void)
 {
-       usb_deregister (&belkin_driver);
-       usb_serial_deregister (&belkin_device);
+       usb_deregister(&belkin_driver);
+       usb_serial_deregister(&belkin_device);
 }
 
 
-module_init (belkin_sa_init);
-module_exit (belkin_sa_exit);
+module_init(belkin_sa_init);
+module_exit(belkin_sa_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
-MODULE_VERSION( DRIVER_VERSION );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_VERSION(DRIVER_VERSION);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index 9116b92..c66a673 100644 (file)
@@ -7,13 +7,14 @@
  *  This program is largely derived from work by the linux-usb group
  *  and associated source files.  Please see the usb/serial files for
  *  individual credits and copyrights.
- *  
+ *
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
  *     the Free Software Foundation; either version 2 of the License, or
  *     (at your option) any later version.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  *
  * 12-Mar-2001 gkh
  *     Added GoHubs GO-COM232 device id.
@@ -27,7 +28,7 @@
  *    adapter, so pardon any stupid mistakes.  All of the information
  *    I am using to write this driver was acquired by using a modified
  *    UsbSnoop on Windows2000.
- *    
+ *
  */
 
 #ifndef __LINUX_USB_SERIAL_BSA_H
 
 /*
  * It seems that the interrupt pipe is closely modelled after the
- * 16550 register layout.  This is probably because the adapter can 
+ * 16550 register layout.  This is probably because the adapter can
  * be used in a "DOS" environment to simulate a standard hardware port.
  */
-#define BELKIN_SA_LSR_INDEX            2               /* Line Status Register */
+#define BELKIN_SA_LSR_INDEX            2       /*     Line Status Register */
 #define BELKIN_SA_LSR_RDR              0x01    /* receive data ready */
 #define BELKIN_SA_LSR_OE               0x02    /* overrun error */
 #define BELKIN_SA_LSR_PE               0x04    /* parity error */
 #define BELKIN_SA_LSR_FE               0x08    /* framing error */
 #define BELKIN_SA_LSR_BI               0x10    /* break indicator */
-#define BELKIN_SA_LSR_THE              0x20    /* transmit holding register empty */
+#define BELKIN_SA_LSR_THE              0x20    /* tx holding register empty */
 #define BELKIN_SA_LSR_TE               0x40    /* transmit register empty */
 #define BELKIN_SA_LSR_ERR              0x80    /* OE | PE | FE | BI */
 
-#define BELKIN_SA_MSR_INDEX            3               /* Modem Status Register */
+#define BELKIN_SA_MSR_INDEX            3       /*     Modem Status Register */
 #define BELKIN_SA_MSR_DCTS             0x01    /* Delta CTS */
 #define BELKIN_SA_MSR_DDSR             0x02    /* Delta DSR */
 #define BELKIN_SA_MSR_DRI              0x04    /* Delta RI */
index 0b14aea..83bbb5b 100644 (file)
@@ -15,7 +15,8 @@
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 
-static int usb_serial_device_match (struct device *dev, struct device_driver *drv)
+static int usb_serial_device_match(struct device *dev,
+                                               struct device_driver *drv)
 {
        struct usb_serial_driver *driver;
        const struct usb_serial_port *port;
@@ -46,7 +47,7 @@ static ssize_t show_port_number(struct device *dev,
 
 static DEVICE_ATTR(port_number, S_IRUGO, show_port_number, NULL);
 
-static int usb_serial_device_probe (struct device *dev)
+static int usb_serial_device_probe(struct device *dev)
 {
        struct usb_serial_driver *driver;
        struct usb_serial_port *port;
@@ -66,7 +67,7 @@ static int usb_serial_device_probe (struct device *dev)
                        retval = -EIO;
                        goto exit;
                }
-               retval = driver->port_probe (port);
+               retval = driver->port_probe(port);
                module_put(driver->driver.owner);
                if (retval)
                        goto exit;
@@ -77,8 +78,8 @@ static int usb_serial_device_probe (struct device *dev)
                goto exit;
 
        minor = port->number;
-       tty_register_device (usb_serial_tty_driver, minor, dev);
-       dev_info(&port->serial->dev->dev, 
+       tty_register_device(usb_serial_tty_driver, minor, dev);
+       dev_info(&port->serial->dev->dev,
                 "%s converter now attached to ttyUSB%d\n",
                 driver->description, minor);
 
@@ -86,7 +87,7 @@ exit:
        return retval;
 }
 
-static int usb_serial_device_remove (struct device *dev)
+static int usb_serial_device_remove(struct device *dev)
 {
        struct usb_serial_driver *driver;
        struct usb_serial_port *port;
@@ -94,9 +95,8 @@ static int usb_serial_device_remove (struct device *dev)
        int minor;
 
        port = to_usb_serial_port(dev);
-       if (!port) {
+       if (!port)
                return -ENODEV;
-       }
 
        device_remove_file(&port->dev, &dev_attr_port_number);
 
@@ -107,12 +107,12 @@ static int usb_serial_device_remove (struct device *dev)
                        retval = -EIO;
                        goto exit;
                }
-               retval = driver->port_remove (port);
+               retval = driver->port_remove(port);
                module_put(driver->driver.owner);
        }
 exit:
        minor = port->number;
-       tty_unregister_device (usb_serial_tty_driver, minor);
+       tty_unregister_device(usb_serial_tty_driver, minor);
        dev_info(dev, "%s converter now disconnected from ttyUSB%d\n",
                 driver->description, minor);
 
index 1f7c86b..f61e3ca 100644 (file)
@@ -232,7 +232,8 @@ error:      kfree(priv);
 }
 
 /* open this device, set default parameters */
-static int ch341_open(struct usb_serial_port *port, struct file *filp)
+static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port,
+                               struct file *filp)
 {
        struct usb_serial *serial = port->serial;
        struct ch341_private *priv = usb_get_serial_port_data(serial->port[0]);
@@ -256,7 +257,7 @@ static int ch341_open(struct usb_serial_port *port, struct file *filp)
        if (r)
                goto out;
 
-       r = usb_serial_generic_open(port, filp);
+       r = usb_serial_generic_open(tty, port, filp);
 
 out:   return r;
 }
@@ -264,11 +265,10 @@ out:      return r;
 /* Old_termios contains the original termios settings and
  * tty->termios contains the new setting to be used.
  */
-static void ch341_set_termios(struct usb_serial_port *port,
-                             struct ktermios *old_termios)
+static void ch341_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct ch341_private *priv = usb_get_serial_port_data(port);
-       struct tty_struct *tty = port->tty;
        unsigned baud_rate;
 
        dbg("ch341_set_termios()");
index 201184c..7b74238 100644 (file)
@@ -6,7 +6,7 @@
  *     This program is free software; you can redistribute it and/or
  *     modify it under the terms of the GNU General Public License version
  *     2 as published by the Free Software Foundation.
- * 
+ *
  * Thanks to Randy Dunlap for the original version of this code.
  *
  */
@@ -67,7 +67,7 @@ static int usb_console_setup(struct console *co, char *options)
        struct tty_struct *tty = NULL;
        struct ktermios *termios = NULL, dummy;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        if (options) {
                baud = simple_strtoul(options, NULL, 10);
@@ -81,55 +81,27 @@ static int usb_console_setup(struct console *co, char *options)
                if (*s)
                        doflow = (*s++ == 'r');
        }
+       
+       /* Sane default */
+       if (baud == 0)
+               baud = 9600;
 
-       /* build a cflag setting */
-       switch (baud) {
-               case 1200:
-                       cflag |= B1200;
-                       break;
-               case 2400:
-                       cflag |= B2400;
-                       break;
-               case 4800:
-                       cflag |= B4800;
-                       break;
-               case 19200:
-                       cflag |= B19200;
-                       break;
-               case 38400:
-                       cflag |= B38400;
-                       break;
-               case 57600:
-                       cflag |= B57600;
-                       break;
-               case 115200:
-                       cflag |= B115200;
-                       break;
-               case 9600:
-               default:
-                       cflag |= B9600;
-                       /*
-                        * Set this to a sane value to prevent a divide error
-                        */
-                       baud  = 9600;
-                       break;
-       }
        switch (bits) {
-               case 7:
-                       cflag |= CS7;
-                       break;
-               default:
-               case 8:
-                       cflag |= CS8;
-                       break;
+       case 7:
+               cflag |= CS7;
+               break;
+       default:
+       case 8:
+               cflag |= CS8;
+               break;
        }
        switch (parity) {
-               case 'o': case 'O':
-                       cflag |= PARODD;
-                       break;
-               case 'e': case 'E':
-                       cflag |= PARENB;
-                       break;
+       case 'o': case 'O':
+               cflag |= PARODD;
+               break;
+       case 'e': case 'E':
+               cflag |= PARENB;
+               break;
        }
        co->cflag = cflag;
 
@@ -140,17 +112,17 @@ static int usb_console_setup(struct console *co, char *options)
        serial = usb_serial_get_by_index(co->index);
        if (serial == NULL) {
                /* no device is connected yet, sorry :( */
-               err ("No USB device connected to ttyUSB%i", co->index);
+               err("No USB device connected to ttyUSB%i", co->index);
                return -ENODEV;
        }
 
        port = serial->port[0];
-       port->tty = NULL;
+       port->port.tty = NULL;
 
        info->port = port;
-        
-       ++port->open_count;
-       if (port->open_count == 1) {
+
+       ++port->port.count;
+       if (port->port.count == 1) {
                if (serial->type->set_termios) {
                        /*
                         * allocate a fake tty so the driver can initialize
@@ -171,15 +143,15 @@ static int usb_console_setup(struct console *co, char *options)
                        }
                        memset(&dummy, 0, sizeof(struct ktermios));
                        tty->termios = termios;
-                       port->tty = tty;
+                       port->port.tty = tty;
                }
 
-               /* only call the device specific open if this 
+               /* only call the device specific open if this
                 * is the first time the port is opened */
                if (serial->type->open)
-                       retval = serial->type->open(port, NULL);
+                       retval = serial->type->open(NULL, port, NULL);
                else
-                       retval = usb_serial_generic_open(port, NULL);
+                       retval = usb_serial_generic_open(NULL, port, NULL);
 
                if (retval) {
                        err("could not open USB console port");
@@ -188,9 +160,10 @@ static int usb_console_setup(struct console *co, char *options)
 
                if (serial->type->set_termios) {
                        termios->c_cflag = cflag;
-                       serial->type->set_termios(port, &dummy);
+                       tty_termios_encode_baud_rate(termios, baud, baud);
+                       serial->type->set_termios(NULL, port, &dummy);
 
-                       port->tty = NULL;
+                       port->port.tty = NULL;
                        kfree(termios);
                        kfree(tty);
                }
@@ -203,15 +176,16 @@ out:
        return retval;
 free_termios:
        kfree(termios);
-       port->tty = NULL;
+       port->port.tty = NULL;
 free_tty:
        kfree(tty);
 reset_open_count:
-       port->open_count = 0;
+       port->port.count = 0;
 goto out;
 }
 
-static void usb_console_write(struct console *co, const char *buf, unsigned count)
+static void usb_console_write(struct console *co,
+                                       const char *buf, unsigned count)
 {
        static struct usbcons_info *info = &usbcons_info;
        struct usb_serial_port *port = info->port;
@@ -227,8 +201,8 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
 
        dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
 
-       if (!port->open_count) {
-               dbg ("%s - port not opened", __func__);
+       if (!port->port.count) {
+               dbg("%s - port not opened", __func__);
                return;
        }
 
@@ -236,26 +210,29 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
                unsigned int i;
                unsigned int lf;
                /* search for LF so we can insert CR if necessary */
-               for (i=0, lf=0 ; i < count ; i++) {
+               for (i = 0, lf = 0 ; i < count ; i++) {
                        if (*(buf + i) == 10) {
                                lf = 1;
                                i++;
                                break;
                        }
                }
-               /* pass on to the driver specific version of this function if it is available */
+               /* pass on to the driver specific version of this function if
+                  it is available */
                if (serial->type->write)
-                       retval = serial->type->write(port, buf, i);
+                       retval = serial->type->write(NULL, port, buf, i);
                else
-                       retval = usb_serial_generic_write(port, buf, i);
+                       retval = usb_serial_generic_write(NULL, port, buf, i);
                dbg("%s - return value : %d", __func__, retval);
                if (lf) {
                        /* append CR after LF */
                        unsigned char cr = 13;
                        if (serial->type->write)
-                               retval = serial->type->write(port, &cr, 1);
+                               retval = serial->type->write(NULL,
+                                                               port, &cr, 1);
                        else
-                               retval = usb_serial_generic_write(port, &cr, 1);
+                               retval = usb_serial_generic_write(NULL,
+                                                               port, &cr, 1);
                        dbg("%s - return value : %d", __func__, retval);
                }
                buf += i;
@@ -273,18 +250,19 @@ static struct console usbcons = {
 
 void usb_serial_console_disconnect(struct usb_serial *serial)
 {
-       if (serial && serial->port && serial->port[0] && serial->port[0] == usbcons_info.port) {
+       if (serial && serial->port && serial->port[0]
+                               && serial->port[0] == usbcons_info.port) {
                usb_serial_console_exit();
                usb_serial_put(serial);
        }
 }
 
-void usb_serial_console_init (int serial_debug, int minor)
+void usb_serial_console_init(int serial_debug, int minor)
 {
        debug = serial_debug;
 
        if (minor == 0) {
-               /* 
+               /*
                 * Call register_console() if this is the first device plugged
                 * in.  If we call it earlier, then the callback to
                 * console_setup() will fail, as there is not a device seen by
@@ -293,21 +271,21 @@ void usb_serial_console_init (int serial_debug, int minor)
                /*
                 * Register console.
                 * NOTES:
-                * console_setup() is called (back) immediately (from register_console).
-                * console_write() is called immediately from register_console iff
-                * CON_PRINTBUFFER is set in flags.
+                * console_setup() is called (back) immediately (from
+                * register_console). console_write() is called immediately
+                * from register_console iff CON_PRINTBUFFER is set in flags.
                 */
-               dbg ("registering the USB serial console.");
+               dbg("registering the USB serial console.");
                register_console(&usbcons);
        }
 }
 
-void usb_serial_console_exit (void)
+void usb_serial_console_exit(void)
 {
        if (usbcons_info.port) {
                unregister_console(&usbcons);
-               if (usbcons_info.port->open_count)
-                       usbcons_info.port->open_count--;
+               if (usbcons_info.port->port.count)
+                       usbcons_info.port->port.count--;
                usbcons_info.port = NULL;
        }
 }
index 2bc5576..442cba6 100644 (file)
@@ -25,7 +25,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/usb.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb/serial.h>
 
 /*
 /*
  * Function Prototypes
  */
-static int cp2101_open(struct usb_serial_port*, struct file*);
-static void cp2101_cleanup(struct usb_serial_port*);
-static void cp2101_close(struct usb_serial_port*, struct file*);
-static void cp2101_get_termios(struct usb_serial_port*);
-static void cp2101_set_termios(struct usb_serial_port*, struct ktermios*);
-static int cp2101_tiocmget (struct usb_serial_port *, struct file *);
-static int cp2101_tiocmset (struct usb_serial_port *, struct file *,
+static int cp2101_open(struct tty_struct *, struct usb_serial_port *,
+                                                       struct file *);
+static void cp2101_cleanup(struct usb_serial_port *);
+static void cp2101_close(struct tty_struct *, struct usb_serial_port *,
+                                                       struct file*);
+static void cp2101_get_termios(struct tty_struct *);
+static void cp2101_set_termios(struct tty_struct *, struct usb_serial_port *,
+                                                       struct ktermios*);
+static int cp2101_tiocmget(struct tty_struct *, struct file *);
+static int cp2101_tiocmset(struct tty_struct *, struct file *,
                unsigned int, unsigned int);
-static void cp2101_break_ctl(struct usb_serial_port*, int);
-static int cp2101_startup (struct usb_serial *);
-static void cp2101_shutdown(struct usb_serial*);
+static void cp2101_break_ctl(struct tty_struct *, int);
+static int cp2101_startup(struct usb_serial *);
+static void cp2101_shutdown(struct usb_serial *);
 
 
 static int debug;
@@ -93,7 +96,7 @@ static struct usb_device_id id_table [] = {
        { } /* Terminating Entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table);
+MODULE_DEVICE_TABLE(usb, id_table);
 
 static struct usb_driver cp2101_driver = {
        .name           = "cp2101",
@@ -182,7 +185,7 @@ static struct usb_serial_driver cp2101_device = {
  * 'data' is a pointer to a pre-allocated array of integers large
  * enough to hold 'size' bytes (with 4 bytes to each integer)
  */
-static int cp2101_get_config(struct usb_serial_portport, u8 request,
+static int cp2101_get_config(struct usb_serial_port *port, u8 request,
                unsigned int *data, int size)
 {
        struct usb_serial *serial = port->serial;
@@ -202,12 +205,12 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request,
        request++;
 
        /* Issue the request, attempting to read 'size' bytes */
-       result = usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev, 0),
+       result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
                                request, REQTYPE_DEVICE_TO_HOST, 0x0000,
                                0, buf, size, 300);
 
        /* Convert data into an array of integers */
-       for (i=0; i<length; i++)
+       for (i = 0; i < length; i++)
                data[i] = le32_to_cpu(buf[i]);
 
        kfree(buf);
@@ -228,7 +231,7 @@ static int cp2101_get_config(struct usb_serial_port* port, u8 request,
  * Values less than 16 bits wide are sent directly
  * 'size' is specified in bytes.
  */
-static int cp2101_set_config(struct usb_serial_portport, u8 request,
+static int cp2101_set_config(struct usb_serial_port *port, u8 request,
                unsigned int *data, int size)
 {
        struct usb_serial *serial = port->serial;
@@ -250,12 +253,12 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request,
                buf[i] = cpu_to_le32(data[i]);
 
        if (size > 2) {
-               result = usb_control_msg (serial->dev,
+               result = usb_control_msg(serial->dev,
                                usb_sndctrlpipe(serial->dev, 0),
                                request, REQTYPE_HOST_TO_DEVICE, 0x0000,
                                0, buf, size, 300);
        } else {
-               result = usb_control_msg (serial->dev,
+               result = usb_control_msg(serial->dev,
                                usb_sndctrlpipe(serial->dev, 0),
                                request, REQTYPE_HOST_TO_DEVICE, data[0],
                                0, NULL, 0, 300);
@@ -271,7 +274,7 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request,
        }
 
        /* Single data value */
-       result = usb_control_msg (serial->dev,
+       result = usb_control_msg(serial->dev,
                        usb_sndctrlpipe(serial->dev, 0),
                        request, REQTYPE_HOST_TO_DEVICE, data[0],
                        0, NULL, 0, 300);
@@ -283,13 +286,14 @@ static int cp2101_set_config(struct usb_serial_port* port, u8 request,
  * Convenience function for calling cp2101_set_config on single data values
  * without requiring an integer pointer
  */
-static inline int cp2101_set_config_single(struct usb_serial_portport,
+static inline int cp2101_set_config_single(struct usb_serial_port *port,
                u8 request, unsigned int data)
 {
        return cp2101_set_config(port, request, &data, 2);
 }
 
-static int cp2101_open (struct usb_serial_port *port, struct file *filp)
+static int cp2101_open(struct tty_struct *tty, struct usb_serial_port *port,
+                               struct file *filp)
 {
        struct usb_serial *serial = port->serial;
        int result;
@@ -303,7 +307,7 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp)
        }
 
        /* Start reading from the device */
-       usb_fill_bulk_urb (port->read_urb, serial->dev,
+       usb_fill_bulk_urb(port->read_urb, serial->dev,
                        usb_rcvbulkpipe(serial->dev,
                        port->bulk_in_endpointAddress),
                        port->read_urb->transfer_buffer,
@@ -318,15 +322,15 @@ static int cp2101_open (struct usb_serial_port *port, struct file *filp)
        }
 
        /* Configure the termios structure */
-       cp2101_get_termios(port);
+       cp2101_get_termios(tty);
 
        /* Set the DTR and RTS pins low */
-       cp2101_tiocmset(port, NULL, TIOCM_DTR | TIOCM_RTS, 0);
+       cp2101_tiocmset(tty, NULL, TIOCM_DTR | TIOCM_RTS, 0);
 
        return 0;
 }
 
-static void cp2101_cleanup (struct usb_serial_port *port)
+static void cp2101_cleanup(struct usb_serial_port *port)
 {
        struct usb_serial *serial = port->serial;
 
@@ -341,7 +345,8 @@ static void cp2101_cleanup (struct usb_serial_port *port)
        }
 }
 
-static void cp2101_close (struct usb_serial_port *port, struct file * filp)
+static void cp2101_close(struct tty_struct *tty, struct usb_serial_port *port,
+                                       struct file *filp)
 {
        dbg("%s - port %d", __func__, port->number);
 
@@ -362,19 +367,15 @@ static void cp2101_close (struct usb_serial_port *port, struct file * filp)
  * from the device, corrects any unsupported values, and configures the
  * termios structure to reflect the state of the device
  */
-static void cp2101_get_termios (struct usb_serial_port *port)
+static void cp2101_get_termios (struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        unsigned int cflag, modem_ctl[4];
        unsigned int baud;
        unsigned int bits;
 
        dbg("%s - port %d", __func__, port->number);
 
-       if (!port->tty || !port->tty->termios) {
-               dbg("%s - no tty structures", __func__);
-               return;
-       }
-
        cp2101_get_config(port, CP2101_BAUDRATE, &baud, 2);
        /* Convert to baudrate */
        if (baud)
@@ -382,104 +383,102 @@ static void cp2101_get_termios (struct usb_serial_port *port)
 
        dbg("%s - baud rate = %d", __func__, baud);
 
-       tty_encode_baud_rate(port->tty, baud, baud);
-       cflag = port->tty->termios->c_cflag;
+       tty_encode_baud_rate(tty, baud, baud);
+       cflag = tty->termios->c_cflag;
 
        cp2101_get_config(port, CP2101_BITS, &bits, 2);
        cflag &= ~CSIZE;
-       switch(bits & BITS_DATA_MASK) {
-               case BITS_DATA_5:
-                       dbg("%s - data bits = 5", __func__);
-                       cflag |= CS5;
-                       break;
-               case BITS_DATA_6:
-                       dbg("%s - data bits = 6", __func__);
-                       cflag |= CS6;
-                       break;
-               case BITS_DATA_7:
-                       dbg("%s - data bits = 7", __func__);
-                       cflag |= CS7;
-                       break;
-               case BITS_DATA_8:
-                       dbg("%s - data bits = 8", __func__);
-                       cflag |= CS8;
-                       break;
-               case BITS_DATA_9:
-                       dbg("%s - data bits = 9 (not supported, "
-                                       "using 8 data bits)", __func__);
-                       cflag |= CS8;
-                       bits &= ~BITS_DATA_MASK;
-                       bits |= BITS_DATA_8;
-                       cp2101_set_config(port, CP2101_BITS, &bits, 2);
-                       break;
-               default:
-                       dbg("%s - Unknown number of data bits, "
-                                       "using 8", __func__);
-                       cflag |= CS8;
-                       bits &= ~BITS_DATA_MASK;
-                       bits |= BITS_DATA_8;
-                       cp2101_set_config(port, CP2101_BITS, &bits, 2);
-                       break;
+       switch (bits & BITS_DATA_MASK) {
+       case BITS_DATA_5:
+               dbg("%s - data bits = 5", __func__);
+               cflag |= CS5;
+               break;
+       case BITS_DATA_6:
+               dbg("%s - data bits = 6", __func__);
+               cflag |= CS6;
+               break;
+       case BITS_DATA_7:
+               dbg("%s - data bits = 7", __func__);
+               cflag |= CS7;
+               break;
+       case BITS_DATA_8:
+               dbg("%s - data bits = 8", __func__);
+               cflag |= CS8;
+               break;
+       case BITS_DATA_9:
+               dbg("%s - data bits = 9 (not supported, using 8 data bits)",
+                                                               __func__);
+               cflag |= CS8;
+               bits &= ~BITS_DATA_MASK;
+               bits |= BITS_DATA_8;
+               cp2101_set_config(port, CP2101_BITS, &bits, 2);
+               break;
+       default:
+               dbg("%s - Unknown number of data bits, using 8", __func__);
+               cflag |= CS8;
+               bits &= ~BITS_DATA_MASK;
+               bits |= BITS_DATA_8;
+               cp2101_set_config(port, CP2101_BITS, &bits, 2);
+               break;
        }
 
-       switch(bits & BITS_PARITY_MASK) {
-               case BITS_PARITY_NONE:
-                       dbg("%s - parity = NONE", __func__);
-                       cflag &= ~PARENB;
-                       break;
-               case BITS_PARITY_ODD:
-                       dbg("%s - parity = ODD", __func__);
-                       cflag |= (PARENB|PARODD);
-                       break;
-               case BITS_PARITY_EVEN:
-                       dbg("%s - parity = EVEN", __func__);
-                       cflag &= ~PARODD;
-                       cflag |= PARENB;
-                       break;
-               case BITS_PARITY_MARK:
-                       dbg("%s - parity = MARK (not supported, "
-                                       "disabling parity)", __func__);
-                       cflag &= ~PARENB;
-                       bits &= ~BITS_PARITY_MASK;
-                       cp2101_set_config(port, CP2101_BITS, &bits, 2);
-                       break;
-               case BITS_PARITY_SPACE:
-                       dbg("%s - parity = SPACE (not supported, "
-                                       "disabling parity)", __func__);
-                       cflag &= ~PARENB;
-                       bits &= ~BITS_PARITY_MASK;
-                       cp2101_set_config(port, CP2101_BITS, &bits, 2);
-                       break;
-               default:
-                       dbg("%s - Unknown parity mode, "
-                                       "disabling parity", __func__);
-                       cflag &= ~PARENB;
-                       bits &= ~BITS_PARITY_MASK;
-                       cp2101_set_config(port, CP2101_BITS, &bits, 2);
-                       break;
+       switch (bits & BITS_PARITY_MASK) {
+       case BITS_PARITY_NONE:
+               dbg("%s - parity = NONE", __func__);
+               cflag &= ~PARENB;
+               break;
+       case BITS_PARITY_ODD:
+               dbg("%s - parity = ODD", __func__);
+               cflag |= (PARENB|PARODD);
+               break;
+       case BITS_PARITY_EVEN:
+               dbg("%s - parity = EVEN", __func__);
+               cflag &= ~PARODD;
+               cflag |= PARENB;
+               break;
+       case BITS_PARITY_MARK:
+               dbg("%s - parity = MARK (not supported, disabling parity)",
+                               __func__);
+               cflag &= ~PARENB;
+               bits &= ~BITS_PARITY_MASK;
+               cp2101_set_config(port, CP2101_BITS, &bits, 2);
+               break;
+       case BITS_PARITY_SPACE:
+               dbg("%s - parity = SPACE (not supported, disabling parity)",
+                               __func__);
+               cflag &= ~PARENB;
+               bits &= ~BITS_PARITY_MASK;
+               cp2101_set_config(port, CP2101_BITS, &bits, 2);
+               break;
+       default:
+               dbg("%s - Unknown parity mode, disabling parity", __func__);
+               cflag &= ~PARENB;
+               bits &= ~BITS_PARITY_MASK;
+               cp2101_set_config(port, CP2101_BITS, &bits, 2);
+               break;
        }
 
        cflag &= ~CSTOPB;
-       switch(bits & BITS_STOP_MASK) {
-               case BITS_STOP_1:
-                       dbg("%s - stop bits = 1", __func__);
-                       break;
-               case BITS_STOP_1_5:
-                       dbg("%s - stop bits = 1.5 (not supported, "
-                                       "using 1 stop bit)", __func__);
-                       bits &= ~BITS_STOP_MASK;
-                       cp2101_set_config(port, CP2101_BITS, &bits, 2);
-                       break;
-               case BITS_STOP_2:
-                       dbg("%s - stop bits = 2", __func__);
-                       cflag |= CSTOPB;
-                       break;
-               default:
-                       dbg("%s - Unknown number of stop bits, "
-                                       "using 1 stop bit", __func__);
-                       bits &= ~BITS_STOP_MASK;
-                       cp2101_set_config(port, CP2101_BITS, &bits, 2);
-                       break;
+       switch (bits & BITS_STOP_MASK) {
+       case BITS_STOP_1:
+               dbg("%s - stop bits = 1", __func__);
+               break;
+       case BITS_STOP_1_5:
+               dbg("%s - stop bits = 1.5 (not supported, using 1 stop bit)",
+                                                               __func__);
+               bits &= ~BITS_STOP_MASK;
+               cp2101_set_config(port, CP2101_BITS, &bits, 2);
+               break;
+       case BITS_STOP_2:
+               dbg("%s - stop bits = 2", __func__);
+               cflag |= CSTOPB;
+               break;
+       default:
+               dbg("%s - Unknown number of stop bits, using 1 stop bit",
+                                                               __func__);
+               bits &= ~BITS_STOP_MASK;
+               cp2101_set_config(port, CP2101_BITS, &bits, 2);
+               break;
        }
 
        cp2101_get_config(port, CP2101_MODEMCTL, modem_ctl, 16);
@@ -491,11 +490,11 @@ static void cp2101_get_termios (struct usb_serial_port *port)
                cflag &= ~CRTSCTS;
        }
 
-       port->tty->termios->c_cflag = cflag;
+       tty->termios->c_cflag = cflag;
 }
 
-static void cp2101_set_termios (struct usb_serial_port *port,
-               struct ktermios *old_termios)
+static void cp2101_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        unsigned int cflag, old_cflag;
        unsigned int baud = 0, bits;
@@ -503,43 +502,41 @@ static void cp2101_set_termios (struct usb_serial_port *port,
 
        dbg("%s - port %d", __func__, port->number);
 
-       if (!port->tty || !port->tty->termios) {
-               dbg("%s - no tty structures", __func__);
+       if (!tty)
                return;
-       }
-       port->tty->termios->c_cflag &= ~CMSPAR;
 
-       cflag = port->tty->termios->c_cflag;
+       tty->termios->c_cflag &= ~CMSPAR;
+       cflag = tty->termios->c_cflag;
        old_cflag = old_termios->c_cflag;
-       baud = tty_get_baud_rate(port->tty);
+       baud = tty_get_baud_rate(tty);
 
        /* If the baud rate is to be updated*/
        if (baud != tty_termios_baud_rate(old_termios)) {
                switch (baud) {
-                       case 0:
-                       case 600:
-                       case 1200:
-                       case 1800:
-                       case 2400:
-                       case 4800:
-                       case 7200:
-                       case 9600:
-                       case 14400:
-                       case 19200:
-                       case 28800:
-                       case 38400:
-                       case 55854:
-                       case 57600:
-                       case 115200:
-                       case 127117:
-                       case 230400:
-                       case 460800:
-                       case 921600:
-                       case 3686400:
-                               break;
-                       default:
-                               baud = 9600;
-                               break;
+               case 0:
+               case 600:
+               case 1200:
+               case 1800:
+               case 2400:
+               case 4800:
+               case 7200:
+               case 9600:
+               case 14400:
+               case 19200:
+               case 28800:
+               case 38400:
+               case 55854:
+               case 57600:
+               case 115200:
+               case 127117:
+               case 230400:
+               case 460800:
+               case 921600:
+               case 3686400:
+                       break;
+               default:
+                       baud = 9600;
+                       break;
                }
 
                if (baud) {
@@ -554,35 +551,35 @@ static void cp2101_set_termios (struct usb_serial_port *port,
                }
        }
        /* Report back the resulting baud rate */
-       tty_encode_baud_rate(port->tty, baud, baud);
+       tty_encode_baud_rate(tty, baud, baud);
 
        /* If the number of data bits is to be updated */
        if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
                cp2101_get_config(port, CP2101_BITS, &bits, 2);
                bits &= ~BITS_DATA_MASK;
                switch (cflag & CSIZE) {
-                       case CS5:
-                               bits |= BITS_DATA_5;
-                               dbg("%s - data bits = 5", __func__);
-                               break;
-                       case CS6:
-                               bits |= BITS_DATA_6;
-                               dbg("%s - data bits = 6", __func__);
-                               break;
-                       case CS7:
-                               bits |= BITS_DATA_7;
-                               dbg("%s - data bits = 7", __func__);
-                               break;
-                       case CS8:
-                               bits |= BITS_DATA_8;
-                               dbg("%s - data bits = 8", __func__);
-                               break;
-                       /*case CS9:
-                               bits |= BITS_DATA_9;
-                               dbg("%s - data bits = 9", __func__);
-                               break;*/
-                       default:
-                               dev_err(&port->dev, "cp2101 driver does not "
+               case CS5:
+                       bits |= BITS_DATA_5;
+                       dbg("%s - data bits = 5", __func__);
+                       break;
+               case CS6:
+                       bits |= BITS_DATA_6;
+                       dbg("%s - data bits = 6", __func__);
+                       break;
+               case CS7:
+                       bits |= BITS_DATA_7;
+                       dbg("%s - data bits = 7", __func__);
+                       break;
+               case CS8:
+                       bits |= BITS_DATA_8;
+                       dbg("%s - data bits = 8", __func__);
+                       break;
+               /*case CS9:
+                       bits |= BITS_DATA_9;
+                       dbg("%s - data bits = 9", __func__);
+                       break;*/
+               default:
+                       dev_err(&port->dev, "cp2101 driver does not "
                                        "support the number of bits requested,"
                                        " using 8 bit mode\n");
                                bits |= BITS_DATA_8;
@@ -651,9 +648,10 @@ static void cp2101_set_termios (struct usb_serial_port *port,
 
 }
 
-static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file,
+static int cp2101_tiocmset (struct tty_struct *tty, struct file *file,
                unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        unsigned int control = 0;
 
        dbg("%s - port %d", __func__, port->number);
@@ -681,8 +679,9 @@ static int cp2101_tiocmset (struct usb_serial_port *port, struct file *file,
 
 }
 
-static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file)
+static int cp2101_tiocmget (struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        unsigned int control;
        int result;
 
@@ -702,8 +701,9 @@ static int cp2101_tiocmget (struct usb_serial_port *port, struct file *file)
        return result;
 }
 
-static void cp2101_break_ctl (struct usb_serial_port *port, int break_state)
+static void cp2101_break_ctl (struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        unsigned int state;
 
        dbg("%s - port %d", __func__, port->number);
@@ -712,30 +712,29 @@ static void cp2101_break_ctl (struct usb_serial_port *port, int break_state)
        else
                state = BREAK_ON;
        dbg("%s - turning break %s", __func__,
-                       state==BREAK_OFF ? "off" : "on");
+                       state == BREAK_OFF ? "off" : "on");
        cp2101_set_config(port, CP2101_BREAK, &state, 2);
 }
 
-static int cp2101_startup (struct usb_serial *serial)
+static int cp2101_startup(struct usb_serial *serial)
 {
        /* CP2101 buffers behave strangely unless device is reset */
        usb_reset_device(serial->dev);
        return 0;
 }
 
-static void cp2101_shutdown (struct usb_serial *serial)
+static void cp2101_shutdown(struct usb_serial *serial)
 {
        int i;
 
        dbg("%s", __func__);
 
        /* Stop reads and writes on all ports */
-       for (i=0; i < serial->num_ports; ++i) {
+       for (i = 0; i < serial->num_ports; ++i)
                cp2101_cleanup(serial->port[i]);
-       }
 }
 
-static int __init cp2101_init (void)
+static int __init cp2101_init(void)
 {
        int retval;
 
@@ -755,10 +754,10 @@ static int __init cp2101_init (void)
        return 0;
 }
 
-static void __exit cp2101_exit (void)
+static void __exit cp2101_exit(void)
 {
-       usb_deregister (&cp2101_driver);
-       usb_serial_deregister (&cp2101_device);
+       usb_deregister(&cp2101_driver);
+       usb_serial_deregister(&cp2101_device);
 }
 
 module_init(cp2101_init);
index c164e2c..b4d7235 100644 (file)
@@ -37,7 +37,7 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 
@@ -57,22 +57,25 @@ static int debug;
 #define CYBERJACK_PRODUCT_ID   0x0100
 
 /* Function prototypes */
-static int cyberjack_startup (struct usb_serial *serial);
-static void cyberjack_shutdown (struct usb_serial *serial);
-static int  cyberjack_open (struct usb_serial_port *port, struct file *filp);
-static void cyberjack_close (struct usb_serial_port *port, struct file *filp);
-static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count);
-static int cyberjack_write_room( struct usb_serial_port *port );
-static void cyberjack_read_int_callback (struct urb *urb);
-static void cyberjack_read_bulk_callback (struct urb *urb);
-static void cyberjack_write_bulk_callback (struct urb *urb);
+static int cyberjack_startup(struct usb_serial *serial);
+static void cyberjack_shutdown(struct usb_serial *serial);
+static int  cyberjack_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void cyberjack_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static int cyberjack_write(struct tty_struct *tty,
+       struct usb_serial_port *port, const unsigned char *buf, int count);
+static int cyberjack_write_room(struct tty_struct *tty);
+static void cyberjack_read_int_callback(struct urb *urb);
+static void cyberjack_read_bulk_callback(struct urb *urb);
+static void cyberjack_write_bulk_callback(struct urb *urb);
 
 static struct usb_device_id id_table [] = {
        { USB_DEVICE(CYBERJACK_VENDOR_ID, CYBERJACK_PRODUCT_ID) },
        { }                     /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table);
+MODULE_DEVICE_TABLE(usb, id_table);
 
 static struct usb_driver cyberjack_driver = {
        .name =         "cyberjack",
@@ -111,7 +114,7 @@ struct cyberjack_private {
 };
 
 /* do some startup allocations not currently performed by usb_serial_probe() */
-static int cyberjack_startup (struct usb_serial *serial)
+static int cyberjack_startup(struct usb_serial *serial)
 {
        struct cyberjack_private *priv;
        int i;
@@ -135,20 +138,20 @@ static int cyberjack_startup (struct usb_serial *serial)
        for (i = 0; i < serial->num_ports; ++i) {
                int result;
                serial->port[i]->interrupt_in_urb->dev = serial->dev;
-               result = usb_submit_urb(serial->port[i]->interrupt_in_urb, 
+               result = usb_submit_urb(serial->port[i]->interrupt_in_urb,
                                        GFP_KERNEL);
                if (result)
                        err(" usb_submit_urb(read int) failed");
                dbg("%s - usb_submit_urb(int urb)", __func__);
        }
 
-       return( 0 );
+       return 0;
 }
 
-static void cyberjack_shutdown (struct usb_serial *serial)
+static void cyberjack_shutdown(struct usb_serial *serial)
 {
        int i;
-       
+
        dbg("%s", __func__);
 
        for (i = 0; i < serial->num_ports; ++i) {
@@ -158,8 +161,9 @@ static void cyberjack_shutdown (struct usb_serial *serial)
                usb_set_serial_port_data(serial->port[i], NULL);
        }
 }
-       
-static int  cyberjack_open (struct usb_serial_port *port, struct file *filp)
+
+static int  cyberjack_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct cyberjack_private *priv;
        unsigned long flags;
@@ -167,14 +171,15 @@ static int  cyberjack_open (struct usb_serial_port *port, struct file *filp)
 
        dbg("%s - port %d", __func__, port->number);
 
-       dbg("%s - usb_clear_halt", __func__ );
+       dbg("%s - usb_clear_halt", __func__);
        usb_clear_halt(port->serial->dev, port->write_urb->pipe);
 
        /* force low_latency on so that our tty_push actually forces
         * the data through, otherwise it is scheduled, and with high
         * data rates (like with OHCI) data can get lost.
         */
-       port->tty->low_latency = 1;
+       if (tty)
+               tty->low_latency = 1;
 
        priv = usb_get_serial_port_data(port);
        spin_lock_irqsave(&priv->lock, flags);
@@ -186,7 +191,8 @@ static int  cyberjack_open (struct usb_serial_port *port, struct file *filp)
        return result;
 }
 
-static void cyberjack_close (struct usb_serial_port *port, struct file *filp)
+static void cyberjack_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        dbg("%s - port %d", __func__, port->number);
 
@@ -197,7 +203,8 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp)
        }
 }
 
-static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count)
+static int cyberjack_write(struct tty_struct *tty,
+       struct usb_serial_port *port, const unsigned char *buf, int count)
 {
        struct usb_serial *serial = port->serial;
        struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -223,7 +230,7 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
 
        spin_lock_irqsave(&priv->lock, flags);
 
-       if( (count+priv->wrfilled) > sizeof(priv->wrbuf) ) {
+       if (count+priv->wrfilled > sizeof(priv->wrbuf)) {
                /* To much data for buffer. Reset buffer. */
                priv->wrfilled = 0;
                port->write_urb_busy = 0;
@@ -232,42 +239,43 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
        }
 
        /* Copy data */
-       memcpy (priv->wrbuf+priv->wrfilled, buf, count);
+       memcpy(priv->wrbuf + priv->wrfilled, buf, count);
 
        usb_serial_debug_data(debug, &port->dev, __func__, count,
-               priv->wrbuf+priv->wrfilled);
+               priv->wrbuf + priv->wrfilled);
        priv->wrfilled += count;
 
-       if( priv->wrfilled >= 3 ) {
+       if (priv->wrfilled >= 3) {
                wrexpected = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3;
                dbg("%s - expected data: %d", __func__, wrexpected);
-       } else {
+       } else
                wrexpected = sizeof(priv->wrbuf);
-       }
 
-       if( priv->wrfilled >= wrexpected ) {
+       if (priv->wrfilled >= wrexpected) {
                /* We have enough data to begin transmission */
                int length;
 
                dbg("%s - transmitting data (frame 1)", __func__);
-               length = (wrexpected > port->bulk_out_size) ? port->bulk_out_size : wrexpected;
+               length = (wrexpected > port->bulk_out_size) ?
+                                       port->bulk_out_size : wrexpected;
 
-               memcpy (port->write_urb->transfer_buffer, priv->wrbuf, length );
-               priv->wrsent=length;
+               memcpy(port->write_urb->transfer_buffer, priv->wrbuf, length);
+               priv->wrsent = length;
 
                /* set up our urb */
-               usb_fill_bulk_urb(port->write_urb, serial->dev, 
+               usb_fill_bulk_urb(port->write_urb, serial->dev,
                              usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress),
                              port->write_urb->transfer_buffer, length,
-                             ((serial->type->write_bulk_callback) ? 
-                              serial->type->write_bulk_callback : 
-                              cyberjack_write_bulk_callback), 
+                             ((serial->type->write_bulk_callback) ?
+                              serial->type->write_bulk_callback :
+                              cyberjack_write_bulk_callback),
                              port);
 
                /* send the data out the bulk port */
                result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
                if (result) {
-                       err("%s - failed submitting write urb, error %d", __func__, result);
+                       err("%s - failed submitting write urb, error %d",
+                                                       __func__, result);
                        /* Throw away data. No better idea what to do with it. */
                        priv->wrfilled = 0;
                        priv->wrsent = 0;
@@ -276,12 +284,12 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
                        return 0;
                }
 
-               dbg("%s - priv->wrsent=%d", __func__,priv->wrsent);
-               dbg("%s - priv->wrfilled=%d", __func__,priv->wrfilled);
+               dbg("%s - priv->wrsent=%d", __func__, priv->wrsent);
+               dbg("%s - priv->wrfilled=%d", __func__, priv->wrfilled);
 
-               if( priv->wrsent>=priv->wrfilled ) {
+               if (priv->wrsent >= priv->wrfilled) {
                        dbg("%s - buffer cleaned", __func__);
-                       memset( priv->wrbuf, 0, sizeof(priv->wrbuf) );
+                       memset(priv->wrbuf, 0, sizeof(priv->wrbuf));
                        priv->wrfilled = 0;
                        priv->wrsent = 0;
                }
@@ -289,16 +297,16 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
 
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       return (count);
-} 
+       return count;
+}
 
-static int cyberjack_write_room( struct usb_serial_port *port )
+static int cyberjack_write_room(struct tty_struct *tty)
 {
        /* FIXME: .... */
        return CYBERJACK_LOCAL_BUF_SIZE;
 }
 
-static void cyberjack_read_int_callback( struct urb *urb )
+static void cyberjack_read_int_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -312,10 +320,11 @@ static void cyberjack_read_int_callback( struct urb *urb )
        if (status)
                return;
 
-       usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                               urb->actual_length, data);
 
        /* React only to interrupts signaling a bulk_in transfer */
-       if( (urb->actual_length == 4) && (data[0] == 0x01) ) {
+       if (urb->actual_length == 4 && data[0] == 0x01) {
                short old_rdtodo;
 
                /* This is a announcement of coming bulk_ins. */
@@ -325,8 +334,8 @@ static void cyberjack_read_int_callback( struct urb *urb )
 
                old_rdtodo = priv->rdtodo;
 
-               if( (old_rdtodo+size)<(old_rdtodo) ) {
-                       dbg( "To many bulk_in urbs to do." );
+               if (old_rdtodo + size < old_rdtodo) {
+                       dbg("To many bulk_in urbs to do.");
                        spin_unlock(&priv->lock);
                        goto resubmit;
                }
@@ -338,10 +347,10 @@ static void cyberjack_read_int_callback( struct urb *urb )
 
                spin_unlock(&priv->lock);
 
-               if( !old_rdtodo ) {
+               if (!old_rdtodo) {
                        port->read_urb->dev = port->serial->dev;
                        result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
-                       if( result )
+                       if (result)
                                err("%s - failed resubmitting read urb, error %d", __func__, result);
                        dbg("%s - usb_submit_urb(read urb)", __func__);
                }
@@ -355,7 +364,7 @@ resubmit:
        dbg("%s - usb_submit_urb(int urb)", __func__);
 }
 
-static void cyberjack_read_bulk_callback (struct urb *urb)
+static void cyberjack_read_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -367,14 +376,15 @@ static void cyberjack_read_bulk_callback (struct urb *urb)
 
        dbg("%s - port %d", __func__, port->number);
 
-       usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                               urb->actual_length, data);
        if (status) {
                dbg("%s - nonzero read bulk status received: %d",
                    __func__, status);
                return;
        }
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (!tty) {
                dbg("%s - ignoring since device not open\n", __func__);
                return;
@@ -382,15 +392,16 @@ static void cyberjack_read_bulk_callback (struct urb *urb)
        if (urb->actual_length) {
                tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
-               tty_flip_buffer_push(tty);
+               tty_flip_buffer_push(tty);
        }
 
        spin_lock(&priv->lock);
 
        /* Reduce urbs to do by one. */
-       priv->rdtodo-=urb->actual_length;
+       priv->rdtodo -= urb->actual_length;
        /* Just to be sure */
-       if ( priv->rdtodo<0 ) priv->rdtodo = 0;
+       if (priv->rdtodo < 0)
+               priv->rdtodo = 0;
        todo = priv->rdtodo;
 
        spin_unlock(&priv->lock);
@@ -398,16 +409,17 @@ static void cyberjack_read_bulk_callback (struct urb *urb)
        dbg("%s - rdtodo: %d", __func__, todo);
 
        /* Continue to read if we have still urbs to do. */
-       if( todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/ ) {
+       if (todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/) {
                port->read_urb->dev = port->serial->dev;
                result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
                if (result)
-                       err("%s - failed resubmitting read urb, error %d", __func__, result);
+                       err("%s - failed resubmitting read urb, error %d",
+                               __func__, result);
                dbg("%s - usb_submit_urb(read urb)", __func__);
        }
 }
 
-static void cyberjack_write_bulk_callback (struct urb *urb)
+static void cyberjack_write_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -425,7 +437,7 @@ static void cyberjack_write_bulk_callback (struct urb *urb)
        spin_lock(&priv->lock);
 
        /* only do something if we have more data to send */
-       if( priv->wrfilled ) {
+       if (priv->wrfilled) {
                int length, blksize, result;
 
                dbg("%s - transmitting data (frame n)", __func__);
@@ -433,37 +445,39 @@ static void cyberjack_write_bulk_callback (struct urb *urb)
                length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ?
                        port->bulk_out_size : (priv->wrfilled - priv->wrsent);
 
-               memcpy (port->write_urb->transfer_buffer, priv->wrbuf + priv->wrsent,
-                       length );
-               priv->wrsent+=length;
+               memcpy(port->write_urb->transfer_buffer,
+                                       priv->wrbuf + priv->wrsent, length);
+               priv->wrsent += length;
 
                /* set up our urb */
-               usb_fill_bulk_urb(port->write_urb, port->serial->dev, 
+               usb_fill_bulk_urb(port->write_urb, port->serial->dev,
                              usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress),
                              port->write_urb->transfer_buffer, length,
-                             ((port->serial->type->write_bulk_callback) ? 
-                              port->serial->type->write_bulk_callback : 
-                              cyberjack_write_bulk_callback), 
+                             ((port->serial->type->write_bulk_callback) ?
+                              port->serial->type->write_bulk_callback :
+                              cyberjack_write_bulk_callback),
                              port);
 
                /* send the data out the bulk port */
                result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
                if (result) {
-                       err("%s - failed submitting write urb, error %d", __func__, result);
+                       err("%s - failed submitting write urb, error %d",
+                                                               __func__, result);
                        /* Throw away data. No better idea what to do with it. */
                        priv->wrfilled = 0;
                        priv->wrsent = 0;
                        goto exit;
                }
 
-               dbg("%s - priv->wrsent=%d", __func__,priv->wrsent);
-               dbg("%s - priv->wrfilled=%d", __func__,priv->wrfilled);
+               dbg("%s - priv->wrsent=%d", __func__, priv->wrsent);
+               dbg("%s - priv->wrfilled=%d", __func__, priv->wrfilled);
 
                blksize = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3;
 
-               if( (priv->wrsent>=priv->wrfilled) || (priv->wrsent>=blksize) ) {
+               if (priv->wrsent >= priv->wrfilled ||
+                                       priv->wrsent >= blksize) {
                        dbg("%s - buffer cleaned", __func__);
-                       memset( priv->wrbuf, 0, sizeof(priv->wrbuf) );
+                       memset(priv->wrbuf, 0, sizeof(priv->wrbuf));
                        priv->wrfilled = 0;
                        priv->wrsent = 0;
                }
@@ -474,14 +488,14 @@ exit:
        usb_serial_port_softint(port);
 }
 
-static int __init cyberjack_init (void)
+static int __init cyberjack_init(void)
 {
        int retval;
        retval  = usb_serial_register(&cyberjack_device);
        if (retval)
                goto failed_usb_serial_register;
        retval = usb_register(&cyberjack_driver);
-       if (retval) 
+       if (retval)
                goto failed_usb_register;
 
        info(DRIVER_VERSION " " DRIVER_AUTHOR);
@@ -494,18 +508,18 @@ failed_usb_serial_register:
        return retval;
 }
 
-static void __exit cyberjack_exit (void)
+static void __exit cyberjack_exit(void)
 {
-       usb_deregister (&cyberjack_driver);
-       usb_serial_deregister (&cyberjack_device);
+       usb_deregister(&cyberjack_driver);
+       usb_serial_deregister(&cyberjack_device);
 }
 
 module_init(cyberjack_init);
 module_exit(cyberjack_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
-MODULE_VERSION( DRIVER_VERSION );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_VERSION(DRIVER_VERSION);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index 0230d3c..22837a3 100644 (file)
@@ -2,7 +2,7 @@
  * USB Cypress M8 driver
  *
  *     Copyright (C) 2004
- *         Lonnie Mendez (dignome@gmail.com) 
+ *         Lonnie Mendez (dignome@gmail.com)
  *     Copyright (C) 2003,2004
  *         Neil Whelchel (koyama@firstlight.net)
  *
  *     the Free Software Foundation; either version 2 of the License, or
  *     (at your option) any later version.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  *
  * See http://geocities.com/i0xox0i for information on this driver and the
  * earthmate usb device.
  *
  *  Lonnie Mendez <dignome@gmail.com>
  *  4-29-2005
- *     Fixed problem where setting or retreiving the serial config would fail with
- *     EPIPE.  Removed CRTS toggling so the driver behaves more like other usbserial
- *     adapters.  Issued new interval of 1ms instead of the default 10ms.  As a
- *     result, transfer speed has been substantially increased.  From avg. 850bps to
- *     avg. 3300bps.  initial termios has also been modified.  Cleaned up code and
- *     formatting issues so it is more readable.  Replaced the C++ style comments.
+ *     Fixed problem where setting or retreiving the serial config would fail
+ *     with EPIPE.  Removed CRTS toggling so the driver behaves more like
+ *     other usbserial adapters.  Issued new interval of 1ms instead of the
+ *     default 10ms.  As a result, transfer speed has been substantially
+ *     increased from avg. 850bps to avg. 3300bps.  initial termios has also
+ *     been modified.  Cleaned up code and formatting issues so it is more
+ *     readable.  Replaced the C++ style comments.
  *
  *  Lonnie Mendez <dignome@gmail.com>
  *  12-15-2004
  *
  */
 
-/* Thanks to Neil Whelchel for writing the first cypress m8 implementation for linux. */
+/* Thanks to Neil Whelchel for writing the first cypress m8 implementation
+   for linux. */
 /* Thanks to cypress for providing references for the hid reports. */
 /* Thanks to Jiang Zhang for providing links and for general help. */
-/* Code originates and was built up from ftdi_sio, belkin, pl2303 and others. */
+/* Code originates and was built up from ftdi_sio, belkin, pl2303 and others.*/
 
 
 #include <linux/kernel.h>
@@ -62,7 +65,7 @@
 #include <linux/usb/serial.h>
 #include <linux/serial.h>
 #include <linux/delay.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 #include "cypress_m8.h"
 
@@ -112,7 +115,7 @@ static struct usb_device_id id_table_combined [] = {
        { }                                             /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table_combined);
+MODULE_DEVICE_TABLE(usb, id_table_combined);
 
 static struct usb_driver cypress_driver = {
        .name =         "cypress",
@@ -146,11 +149,13 @@ struct cypress_private {
        __u8 rx_flags;                     /* throttling - used from whiteheat/ftdi_sio */
        enum packet_format pkt_fmt;        /* format to use for packet send / receive */
        int get_cfg_unsafe;                /* If true, the CYPRESS_GET_CONFIG is unsafe */
-       int baud_rate;                     /* stores current baud rate in integer form */
+       int baud_rate;                     /* stores current baud rate in
+                                             integer form */
        int isthrottled;                   /* if throttled, discard reads */
        wait_queue_head_t delta_msr_wait;  /* used for TIOCMIWAIT */
        char prev_status, diff_status;     /* used for TIOCMIWAIT */
-       /* we pass a pointer to this as the arguement sent to cypress_set_termios old_termios */
+       /* we pass a pointer to this as the arguement sent to
+          cypress_set_termios old_termios */
        struct ktermios tmp_termios;       /* stores the old termios settings */
 };
 
@@ -163,33 +168,41 @@ struct cypress_buf {
 };
 
 /* function prototypes for the Cypress USB to serial device */
-static int  cypress_earthmate_startup  (struct usb_serial *serial);
-static int  cypress_hidcom_startup     (struct usb_serial *serial);
-static int  cypress_ca42v2_startup     (struct usb_serial *serial);
-static void cypress_shutdown           (struct usb_serial *serial);
-static int  cypress_open               (struct usb_serial_port *port, struct file *filp);
-static void cypress_close              (struct usb_serial_port *port, struct file *filp);
-static int  cypress_write              (struct usb_serial_port *port, const unsigned char *buf, int count);
-static void cypress_send               (struct usb_serial_port *port);
-static int  cypress_write_room         (struct usb_serial_port *port);
-static int  cypress_ioctl              (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
-static void cypress_set_termios                (struct usb_serial_port *port, struct ktermios * old);
-static int  cypress_tiocmget           (struct usb_serial_port *port, struct file *file);
-static int  cypress_tiocmset           (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
-static int  cypress_chars_in_buffer    (struct usb_serial_port *port);
-static void cypress_throttle           (struct usb_serial_port *port);
-static void cypress_unthrottle         (struct usb_serial_port *port);
-static void cypress_set_dead           (struct usb_serial_port *port);
-static void cypress_read_int_callback  (struct urb *urb);
-static void cypress_write_int_callback (struct urb *urb);
+static int  cypress_earthmate_startup(struct usb_serial *serial);
+static int  cypress_hidcom_startup(struct usb_serial *serial);
+static int  cypress_ca42v2_startup(struct usb_serial *serial);
+static void cypress_shutdown(struct usb_serial *serial);
+static int  cypress_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void cypress_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static int  cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
+                       const unsigned char *buf, int count);
+static void cypress_send(struct usb_serial_port *port);
+static int  cypress_write_room(struct tty_struct *tty);
+static int  cypress_ioctl(struct tty_struct *tty, struct file *file,
+                       unsigned int cmd, unsigned long arg);
+static void cypress_set_termios(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct ktermios *old);
+static int  cypress_tiocmget(struct tty_struct *tty, struct file *file);
+static int  cypress_tiocmset(struct tty_struct *tty, struct file *file,
+                       unsigned int set, unsigned int clear);
+static int  cypress_chars_in_buffer(struct tty_struct *tty);
+static void cypress_throttle(struct tty_struct *tty);
+static void cypress_unthrottle(struct tty_struct *tty);
+static void cypress_set_dead(struct usb_serial_port *port);
+static void cypress_read_int_callback(struct urb *urb);
+static void cypress_write_int_callback(struct urb *urb);
 /* write buffer functions */
 static struct cypress_buf *cypress_buf_alloc(unsigned int size);
-static void              cypress_buf_free(struct cypress_buf *cb);
-static void              cypress_buf_clear(struct cypress_buf *cb);
-static unsigned int      cypress_buf_data_avail(struct cypress_buf *cb);
-static unsigned int      cypress_buf_space_avail(struct cypress_buf *cb);
-static unsigned int      cypress_buf_put(struct cypress_buf *cb, const char *buf, unsigned int count);
-static unsigned int      cypress_buf_get(struct cypress_buf *cb, char *buf, unsigned int count);
+static void cypress_buf_free(struct cypress_buf *cb);
+static void cypress_buf_clear(struct cypress_buf *cb);
+static unsigned int cypress_buf_data_avail(struct cypress_buf *cb);
+static unsigned int cypress_buf_space_avail(struct cypress_buf *cb);
+static unsigned int cypress_buf_put(struct cypress_buf *cb,
+                                       const char *buf, unsigned int count);
+static unsigned int cypress_buf_get(struct cypress_buf *cb,
+                                       char *buf, unsigned int count);
 
 
 static struct usb_serial_driver cypress_earthmate_device = {
@@ -247,7 +260,7 @@ static struct usb_serial_driver cypress_hidcom_device = {
 static struct usb_serial_driver cypress_ca42v2_device = {
        .driver = {
                .owner =                THIS_MODULE,
-                .name =                        "nokiaca42v2",
+               .name =                 "nokiaca42v2",
        },
        .description =                  "Nokia CA-42 V2 Adapter",
        .usb_driver =                   &cypress_driver,
@@ -322,8 +335,10 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate)
 
 
 /* This function can either set or retrieve the current serial line settings */
-static int cypress_serial_control (struct usb_serial_port *port, speed_t baud_rate, int data_bits, int stop_bits,
-                                  int parity_enable, int parity_type, int reset, int cypress_request_type)
+static int cypress_serial_control(struct tty_struct *tty,
+       struct usb_serial_port *port, speed_t baud_rate, int data_bits,
+       int stop_bits, int parity_enable, int parity_type, int reset,
+       int cypress_request_type)
 {
        int new_baudrate = 0, retval = 0, tries = 0;
        struct cypress_private *priv;
@@ -331,111 +346,114 @@ static int cypress_serial_control (struct usb_serial_port *port, speed_t baud_ra
        unsigned long flags;
 
        dbg("%s", __func__);
-       
+
        priv = usb_get_serial_port_data(port);
 
        if (!priv->comm_is_ok)
                return -ENODEV;
 
-       switch(cypress_request_type) {
-               case CYPRESS_SET_CONFIG:
+       switch (cypress_request_type) {
+       case CYPRESS_SET_CONFIG:
+               new_baudrate = priv->baud_rate;
+               /* 0 means 'Hang up' so doesn't change the true bit rate */
+               if (baud_rate == 0)
                        new_baudrate = priv->baud_rate;
-                       /* 0 means 'Hang up' so doesn't change the true bit rate */
-                       if (baud_rate == 0)
-                               new_baudrate = priv->baud_rate;
-                       /* Change of speed ? */
-                       else if (baud_rate != priv->baud_rate) {
-                               dbg("%s - baud rate is changing", __func__);
-                               retval = analyze_baud_rate(port, baud_rate);
-                               if (retval >=  0) {
-                                       new_baudrate = retval;
-                                       dbg("%s - New baud rate set to %d",
-                                           __func__, new_baudrate);
-                               }
-                       }
-                       dbg("%s - baud rate is being sent as %d", __func__, new_baudrate);
-                       
-                       memset(feature_buffer, 0, sizeof(feature_buffer));
-                       /* fill the feature_buffer with new configuration */
-                       *((u_int32_t *)feature_buffer) = new_baudrate;
-
-                       feature_buffer[4] |= data_bits;   /* assign data bits in 2 bit space ( max 3 ) */
-                       /* 1 bit gap */
-                       feature_buffer[4] |= (stop_bits << 3);   /* assign stop bits in 1 bit space */
-                       feature_buffer[4] |= (parity_enable << 4);   /* assign parity flag in 1 bit space */
-                       feature_buffer[4] |= (parity_type << 5);   /* assign parity type in 1 bit space */
-                       /* 1 bit gap */
-                       feature_buffer[4] |= (reset << 7);   /* assign reset at end of byte, 1 bit space */
-                               
-                       dbg("%s - device is being sent this feature report:", __func__);
-                       dbg("%s - %02X - %02X - %02X - %02X - %02X", __func__, feature_buffer[0], feature_buffer[1],
-                           feature_buffer[2], feature_buffer[3], feature_buffer[4]);
-                       
-                       do {
-                               retval = usb_control_msg(port->serial->dev,
-                                               usb_sndctrlpipe(port->serial->dev, 0),
-                                               HID_REQ_SET_REPORT,
-                                               USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
-                                               0x0300, 0, feature_buffer,
-                                               sizeof(feature_buffer), 500);
-
-                               if (tries++ >= 3)
-                                       break;
-
-                       } while (retval != sizeof(feature_buffer) &&
-                                retval != -ENODEV);
-
-                       if (retval != sizeof(feature_buffer)) {
-                               err("%s - failed sending serial line settings - %d", __func__, retval);
-                               cypress_set_dead(port);
-                       } else {
-                               spin_lock_irqsave(&priv->lock, flags);
-                               priv->baud_rate = new_baudrate;
-                               priv->current_config = feature_buffer[4];
-                               spin_unlock_irqrestore(&priv->lock, flags);
-                               /* If we asked for a speed change encode it */
-                               if (baud_rate)
-                                       tty_encode_baud_rate(port->tty,
-                                                       new_baudrate, new_baudrate);
-                       }
-               break;
-               case CYPRESS_GET_CONFIG:
-                       if (priv->get_cfg_unsafe) {
-                               /* Not implemented for this device,
-                                  and if we try to do it we're likely
-                                  to crash the hardware. */
-                               return -ENOTTY;
-                       }
-                       dbg("%s - retreiving serial line settings", __func__);
-                       /* set initial values in feature buffer */
-                       memset(feature_buffer, 0, sizeof(feature_buffer));
-
-                       do {
-                               retval = usb_control_msg(port->serial->dev,
-                                               usb_rcvctrlpipe(port->serial->dev, 0),
-                                               HID_REQ_GET_REPORT,
-                                               USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
-                                               0x0300, 0, feature_buffer,
-                                               sizeof(feature_buffer), 500);
-
-                               if (tries++ >= 3)
-                                       break;
-
-                       } while (retval != sizeof(feature_buffer) &&
-                                retval != -ENODEV);
-
-                       if (retval != sizeof(feature_buffer)) {
-                               err("%s - failed to retrieve serial line settings - %d", __func__, retval);
-                               cypress_set_dead(port);
-                               return retval;
-                       } else {
-                               spin_lock_irqsave(&priv->lock, flags);
-
-                               /* store the config in one byte, and later use bit masks to check values */
-                               priv->current_config = feature_buffer[4];
-                               priv->baud_rate = *((u_int32_t *)feature_buffer);
-                               spin_unlock_irqrestore(&priv->lock, flags);
+               /* Change of speed ? */
+               else if (baud_rate != priv->baud_rate) {
+                       dbg("%s - baud rate is changing", __func__);
+                       retval = analyze_baud_rate(port, baud_rate);
+                       if (retval >=  0) {
+                               new_baudrate = retval;
+                               dbg("%s - New baud rate set to %d",
+                                   __func__, new_baudrate);
                        }
+               }
+               dbg("%s - baud rate is being sent as %d",
+                                       __func__, new_baudrate);
+
+               memset(feature_buffer, 0, sizeof(feature_buffer));
+               /* fill the feature_buffer with new configuration */
+               *((u_int32_t *)feature_buffer) = new_baudrate;
+               feature_buffer[4] |= data_bits;   /* assign data bits in 2 bit space ( max 3 ) */
+               /* 1 bit gap */
+               feature_buffer[4] |= (stop_bits << 3);   /* assign stop bits in 1 bit space */
+               feature_buffer[4] |= (parity_enable << 4);   /* assign parity flag in 1 bit space */
+               feature_buffer[4] |= (parity_type << 5);   /* assign parity type in 1 bit space */
+               /* 1 bit gap */
+               feature_buffer[4] |= (reset << 7);   /* assign reset at end of byte, 1 bit space */
+
+               dbg("%s - device is being sent this feature report:",
+                                                               __func__);
+               dbg("%s - %02X - %02X - %02X - %02X - %02X", __func__,
+                       feature_buffer[0], feature_buffer[1],
+                       feature_buffer[2], feature_buffer[3],
+                       feature_buffer[4]);
+
+               do {
+                       retval = usb_control_msg(port->serial->dev,
+                                       usb_sndctrlpipe(port->serial->dev, 0),
+                                       HID_REQ_SET_REPORT,
+                                       USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
+                                       0x0300, 0, feature_buffer,
+                                       sizeof(feature_buffer), 500);
+
+                       if (tries++ >= 3)
+                               break;
+
+               } while (retval != sizeof(feature_buffer) &&
+                        retval != -ENODEV);
+
+               if (retval != sizeof(feature_buffer)) {
+                       err("%s - failed sending serial line settings - %d",
+                                                       __func__, retval);
+                       cypress_set_dead(port);
+               } else {
+                       spin_lock_irqsave(&priv->lock, flags);
+                       priv->baud_rate = new_baudrate;
+                       priv->current_config = feature_buffer[4];
+                       spin_unlock_irqrestore(&priv->lock, flags);
+                       /* If we asked for a speed change encode it */
+                       if (baud_rate)
+                               tty_encode_baud_rate(tty,
+                                       new_baudrate, new_baudrate);
+               }
+       break;
+       case CYPRESS_GET_CONFIG:
+               if (priv->get_cfg_unsafe) {
+                       /* Not implemented for this device,
+                          and if we try to do it we're likely
+                          to crash the hardware. */
+                       return -ENOTTY;
+               }
+               dbg("%s - retreiving serial line settings", __func__);
+               /* set initial values in feature buffer */
+               memset(feature_buffer, 0, sizeof(feature_buffer));
+
+               do {
+                       retval = usb_control_msg(port->serial->dev,
+                                       usb_rcvctrlpipe(port->serial->dev, 0),
+                                       HID_REQ_GET_REPORT,
+                                       USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS,
+                                       0x0300, 0, feature_buffer,
+                                       sizeof(feature_buffer), 500);
+
+                       if (tries++ >= 3)
+                               break;
+               } while (retval != sizeof(feature_buffer)
+                                               && retval != -ENODEV);
+
+               if (retval != sizeof(feature_buffer)) {
+                       err("%s - failed to retrieve serial line settings - %d", __func__, retval);
+                       cypress_set_dead(port);
+                       return retval;
+               } else {
+                       spin_lock_irqsave(&priv->lock, flags);
+                       /* store the config in one byte, and later
+                          use bit masks to check values */
+                       priv->current_config = feature_buffer[4];
+                       priv->baud_rate = *((u_int32_t *)feature_buffer);
+                       spin_unlock_irqrestore(&priv->lock, flags);
+               }
        }
        spin_lock_irqsave(&priv->lock, flags);
        ++priv->cmd_count;
@@ -468,14 +486,14 @@ static void cypress_set_dead(struct usb_serial_port *port)
  *****************************************************************************/
 
 
-static int generic_startup (struct usb_serial *serial)
+static int generic_startup(struct usb_serial *serial)
 {
        struct cypress_private *priv;
        struct usb_serial_port *port = serial->port[0];
 
        dbg("%s - port %d", __func__, port->number);
 
-       priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL);
+       priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;
 
@@ -487,9 +505,9 @@ static int generic_startup (struct usb_serial *serial)
                return -ENOMEM;
        }
        init_waitqueue_head(&priv->delta_msr_wait);
-       
-       usb_reset_configuration (serial->dev);
-       
+
+       usb_reset_configuration(serial->dev);
+
        priv->cmd_ctrl = 0;
        priv->line_control = 0;
        priv->termios_initialized = 0;
@@ -500,30 +518,30 @@ static int generic_startup (struct usb_serial *serial)
           small.  Otherwise we can use the slightly more compact
           format.  This is in accordance with the cypress_m8 serial
           converter app note. */
-       if (port->interrupt_out_size > 9) {
+       if (port->interrupt_out_size > 9)
                priv->pkt_fmt = packet_format_1;
-       } else {
+       else
                priv->pkt_fmt = packet_format_2;
-       }
+
        if (interval > 0) {
                priv->write_urb_interval = interval;
                priv->read_urb_interval = interval;
                dbg("%s - port %d read & write intervals forced to %d",
-                   __func__,port->number,interval);
+                   __func__, port->number, interval);
        } else {
                priv->write_urb_interval = port->interrupt_out_urb->interval;
                priv->read_urb_interval = port->interrupt_in_urb->interval;
                dbg("%s - port %d intervals: read=%d write=%d",
-                   __func__,port->number,
-                   priv->read_urb_interval,priv->write_urb_interval);
+                   __func__, port->number,
+                   priv->read_urb_interval, priv->write_urb_interval);
        }
        usb_set_serial_port_data(port, priv);
-       
+
        return 0;
 }
 
 
-static int cypress_earthmate_startup (struct usb_serial *serial)
+static int cypress_earthmate_startup(struct usb_serial *serial)
 {
        struct cypress_private *priv;
        struct usb_serial_port *port = serial->port[0];
@@ -541,7 +559,8 @@ static int cypress_earthmate_startup (struct usb_serial *serial)
        /* All Earthmate devices use the separated-count packet
           format!  Idiotic. */
        priv->pkt_fmt = packet_format_1;
-       if (serial->dev->descriptor.idProduct != cpu_to_le16(PRODUCT_ID_EARTHMATEUSB)) {
+       if (serial->dev->descriptor.idProduct !=
+                               cpu_to_le16(PRODUCT_ID_EARTHMATEUSB)) {
                /* The old original USB Earthmate seemed able to
                   handle GET_CONFIG requests; everything they've
                   produced since that time crashes if this command is
@@ -555,7 +574,7 @@ static int cypress_earthmate_startup (struct usb_serial *serial)
 } /* cypress_earthmate_startup */
 
 
-static int cypress_hidcom_startup (struct usb_serial *serial)
+static int cypress_hidcom_startup(struct usb_serial *serial)
 {
        struct cypress_private *priv;
 
@@ -569,12 +588,12 @@ static int cypress_hidcom_startup (struct usb_serial *serial)
 
        priv = usb_get_serial_port_data(serial->port[0]);
        priv->chiptype = CT_CYPHIDCOM;
-       
+
        return 0;
 } /* cypress_hidcom_startup */
 
 
-static int cypress_ca42v2_startup (struct usb_serial *serial)
+static int cypress_ca42v2_startup(struct usb_serial *serial)
 {
        struct cypress_private *priv;
 
@@ -593,11 +612,11 @@ static int cypress_ca42v2_startup (struct usb_serial *serial)
 } /* cypress_ca42v2_startup */
 
 
-static void cypress_shutdown (struct usb_serial *serial)
+static void cypress_shutdown(struct usb_serial *serial)
 {
        struct cypress_private *priv;
 
-       dbg ("%s - port %d", __func__, serial->port[0]->number);
+       dbg("%s - port %d", __func__, serial->port[0]->number);
 
        /* all open ports are closed at this point */
 
@@ -611,7 +630,8 @@ static void cypress_shutdown (struct usb_serial *serial)
 }
 
 
-static int cypress_open (struct usb_serial_port *port, struct file *filp)
+static int cypress_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct cypress_private *priv = usb_get_serial_port_data(port);
        struct usb_serial *serial = port->serial;
@@ -636,37 +656,44 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
        spin_unlock_irqrestore(&priv->lock, flags);
 
        /* setting to zero could cause data loss */
-       port->tty->low_latency = 1;
+       if (tty)
+               tty->low_latency = 1;
 
        /* raise both lines and set termios */
        spin_lock_irqsave(&priv->lock, flags);
        priv->line_control = CONTROL_DTR | CONTROL_RTS;
        priv->cmd_ctrl = 1;
        spin_unlock_irqrestore(&priv->lock, flags);
-       result = cypress_write(port, NULL, 0);
+       result = cypress_write(tty, port, NULL, 0);
 
        if (result) {
-               dev_err(&port->dev, "%s - failed setting the control lines - error %d\n", __func__, result);
+               dev_err(&port->dev,
+                       "%s - failed setting the control lines - error %d\n",
+                                                       __func__, result);
                return result;
        } else
                dbg("%s - success setting the control lines", __func__);
 
-       cypress_set_termios(port, &priv->tmp_termios);
+       if (tty)
+               cypress_set_termios(tty, port, &priv->tmp_termios);
 
        /* setup the port and start reading from the device */
-       if(!port->interrupt_in_urb){
+       if (!port->interrupt_in_urb) {
                err("%s - interrupt_in_urb is empty!", __func__);
-               return(-1);
+               return -1;
        }
 
        usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
                usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress),
-               port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length,
+               port->interrupt_in_urb->transfer_buffer,
+               port->interrupt_in_urb->transfer_buffer_length,
                cypress_read_int_callback, port, priv->read_urb_interval);
        result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
 
-       if (result){
-               dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
+       if (result) {
+               dev_err(&port->dev,
+                       "%s - failed submitting read urb, error %d\n",
+                                                       __func__, result);
                cypress_set_dead(port);
        }
 
@@ -674,7 +701,8 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
 } /* cypress_open */
 
 
-static void cypress_close(struct usb_serial_port *port, struct file * filp)
+static void cypress_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct cypress_private *priv = usb_get_serial_port_data(port);
        unsigned int c_cflag;
@@ -688,7 +716,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
        spin_lock_irq(&priv->lock);
        timeout = CYPRESS_CLOSING_WAIT;
        init_waitqueue_entry(&wait, current);
-       add_wait_queue(&port->tty->write_wait, &wait);
+       add_wait_queue(&tty->write_wait, &wait);
        for (;;) {
                set_current_state(TASK_INTERRUPTIBLE);
                if (cypress_buf_data_avail(priv->buf) == 0
@@ -701,7 +729,7 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
                spin_lock_irq(&priv->lock);
        }
        set_current_state(TASK_RUNNING);
-       remove_wait_queue(&port->tty->write_wait, &wait);
+       remove_wait_queue(&tty->write_wait, &wait);
        /* clear out any remaining data in the buffer */
        cypress_buf_clear(priv->buf);
        spin_unlock_irq(&priv->lock);
@@ -713,19 +741,21 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
                return;
        }
        /* wait for characters to drain from device */
-       bps = tty_get_baud_rate(port->tty);
-       if (bps > 1200)
-               timeout = max((HZ*2560)/bps,HZ/10);
-       else
-               timeout = 2*HZ;
-       schedule_timeout_interruptible(timeout);
+       if (tty) {
+               bps = tty_get_baud_rate(tty);
+               if (bps > 1200)
+                       timeout = max((HZ * 2560) / bps, HZ / 10);
+               else
+                       timeout = 2 * HZ;
+               schedule_timeout_interruptible(timeout);
+       }
 
        dbg("%s - stopping urbs", __func__);
-       usb_kill_urb (port->interrupt_in_urb);
-       usb_kill_urb (port->interrupt_out_urb);
+       usb_kill_urb(port->interrupt_in_urb);
+       usb_kill_urb(port->interrupt_out_urb);
 
-       if (port->tty) {
-               c_cflag = port->tty->termios->c_cflag;
+       if (tty) {
+               c_cflag = tty->termios->c_cflag;
                if (c_cflag & HUPCL) {
                        /* drop dtr and rts */
                        priv = usb_get_serial_port_data(port);
@@ -733,22 +763,23 @@ static void cypress_close(struct usb_serial_port *port, struct file * filp)
                        priv->line_control = 0;
                        priv->cmd_ctrl = 1;
                        spin_unlock_irq(&priv->lock);
-                       cypress_write(port, NULL, 0);
+                       cypress_write(tty, port, NULL, 0);
                }
        }
 
        if (stats)
-               dev_info (&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n",
-                         priv->bytes_in, priv->bytes_out, priv->cmd_count);
+               dev_info(&port->dev, "Statistics: %d Bytes In | %d Bytes Out | %d Commands Issued\n",
+                       priv->bytes_in, priv->bytes_out, priv->cmd_count);
        mutex_unlock(&port->serial->disc_mutex);
 } /* cypress_close */
 
 
-static int cypress_write(struct usb_serial_port *port, const unsigned char *buf, int count)
+static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count)
 {
        struct cypress_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
-       
+
        dbg("%s - port %d, %d bytes", __func__, port->number, count);
 
        /* line control commands, which need to be executed immediately,
@@ -758,10 +789,10 @@ static int cypress_write(struct usb_serial_port *port, const unsigned char *buf,
                count = 0;
                goto finish;
        }
-       
+
        if (!count)
                return count;
-       
+
        spin_lock_irqsave(&priv->lock, flags);
        count = cypress_buf_put(priv->buf, buf, count);
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -778,13 +809,14 @@ static void cypress_send(struct usb_serial_port *port)
        int count = 0, result, offset, actual_size;
        struct cypress_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
-       
+
        if (!priv->comm_is_ok)
                return;
 
        dbg("%s - port %d", __func__, port->number);
-       dbg("%s - interrupt out size is %d", __func__, port->interrupt_out_size);
-       
+       dbg("%s - interrupt out size is %d", __func__,
+                                               port->interrupt_out_size);
+
        spin_lock_irqsave(&priv->lock, flags);
        if (priv->write_urb_in_use) {
                dbg("%s - can't write, urb in use", __func__);
@@ -794,7 +826,8 @@ static void cypress_send(struct usb_serial_port *port)
        spin_unlock_irqrestore(&priv->lock, flags);
 
        /* clear buffer */
-       memset(port->interrupt_out_urb->transfer_buffer, 0, port->interrupt_out_size);
+       memset(port->interrupt_out_urb->transfer_buffer, 0,
+                                               port->interrupt_out_size);
 
        spin_lock_irqsave(&priv->lock, flags);
        switch (priv->pkt_fmt) {
@@ -825,9 +858,8 @@ static void cypress_send(struct usb_serial_port *port)
        count = cypress_buf_get(priv->buf, &port->interrupt_out_buffer[offset],
                                port->interrupt_out_size-offset);
 
-       if (count == 0) {
+       if (count == 0)
                return;
-       }
 
        switch (priv->pkt_fmt) {
        default:
@@ -851,26 +883,29 @@ send:
                actual_size = count +
                              (priv->pkt_fmt == packet_format_1 ? 2 : 1);
 
-       usb_serial_debug_data(debug, &port->dev, __func__, port->interrupt_out_size,
-                             port->interrupt_out_urb->transfer_buffer);
+       usb_serial_debug_data(debug, &port->dev, __func__,
+               port->interrupt_out_size,
+               port->interrupt_out_urb->transfer_buffer);
 
        usb_fill_int_urb(port->interrupt_out_urb, port->serial->dev,
                usb_sndintpipe(port->serial->dev, port->interrupt_out_endpointAddress),
                port->interrupt_out_buffer, port->interrupt_out_size,
                cypress_write_int_callback, port, priv->write_urb_interval);
-       result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC);
+       result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC);
        if (result) {
-               dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__,
-                       result);
+               dev_err(&port->dev,
+                               "%s - failed submitting write urb, error %d\n",
+                                                       __func__, result);
                priv->write_urb_in_use = 0;
                cypress_set_dead(port);
        }
 
        spin_lock_irqsave(&priv->lock, flags);
-       if (priv->cmd_ctrl) {
+       if (priv->cmd_ctrl)
                priv->cmd_ctrl = 0;
-       }
-       priv->bytes_out += count; /* do not count the line control and size bytes */
+
+       /* do not count the line control and size bytes */
+       priv->bytes_out += count;
        spin_unlock_irqrestore(&priv->lock, flags);
 
        usb_serial_port_softint(port);
@@ -878,8 +913,9 @@ send:
 
 
 /* returns how much space is available in the soft buffer */
-static int cypress_write_room(struct usb_serial_port *port)
+static int cypress_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct cypress_private *priv = usb_get_serial_port_data(port);
        int room = 0;
        unsigned long flags;
@@ -895,13 +931,14 @@ static int cypress_write_room(struct usb_serial_port *port)
 }
 
 
-static int cypress_tiocmget (struct usb_serial_port *port, struct file *file)
+static int cypress_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct cypress_private *priv = usb_get_serial_port_data(port);
        __u8 status, control;
        unsigned int result = 0;
        unsigned long flags;
-       
+
        dbg("%s - port %d", __func__, port->number);
 
        spin_lock_irqsave(&priv->lock, flags);
@@ -922,12 +959,13 @@ static int cypress_tiocmget (struct usb_serial_port *port, struct file *file)
 }
 
 
-static int cypress_tiocmset (struct usb_serial_port *port, struct file *file,
+static int cypress_tiocmset(struct tty_struct *tty, struct file *file,
                               unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct cypress_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
-       
+
        dbg("%s - port %d", __func__, port->number);
 
        spin_lock_irqsave(&priv->lock, flags);
@@ -942,63 +980,60 @@ static int cypress_tiocmset (struct usb_serial_port *port, struct file *file,
        priv->cmd_ctrl = 1;
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       return cypress_write(port, NULL, 0);
+       return cypress_write(tty, port, NULL, 0);
 }
 
 
-static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+static int cypress_ioctl(struct tty_struct *tty, struct file *file,
+                                       unsigned int cmd, unsigned long arg)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct cypress_private *priv = usb_get_serial_port_data(port);
 
        dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
 
        switch (cmd) {
-               /* This code comes from drivers/char/serial.c and ftdi_sio.c */
-               case TIOCMIWAIT:
-                       while (priv != NULL) {
-                               interruptible_sleep_on(&priv->delta_msr_wait);
-                               /* see if a signal did it */
-                               if (signal_pending(current))
-                                       return -ERESTARTSYS;
-                               else {
-                                       char diff = priv->diff_status;
-
-                                       if (diff == 0) {
-                                               return -EIO; /* no change => error */
-                                       }
-                                       
-                                       /* consume all events */
-                                       priv->diff_status = 0;
-
-                                       /* return 0 if caller wanted to know about these bits */
-                                       if ( ((arg & TIOCM_RNG) && (diff & UART_RI)) ||
-                                            ((arg & TIOCM_DSR) && (diff & UART_DSR)) ||
-                                            ((arg & TIOCM_CD) && (diff & UART_CD)) ||
-                                            ((arg & TIOCM_CTS) && (diff & UART_CTS)) ) {
-                                               return 0;
-                                       }
-                                       /* otherwise caller can't care less about what happened,
-                                        * and so we continue to wait for more events.
-                                        */
-                               }
+       /* This code comes from drivers/char/serial.c and ftdi_sio.c */
+       case TIOCMIWAIT:
+               while (priv != NULL) {
+                       interruptible_sleep_on(&priv->delta_msr_wait);
+                       /* see if a signal did it */
+                       if (signal_pending(current))
+                               return -ERESTARTSYS;
+                       else {
+                               char diff = priv->diff_status;
+                               if (diff == 0)
+                                       return -EIO; /* no change => error */
+
+                               /* consume all events */
+                               priv->diff_status = 0;
+
+                               /* return 0 if caller wanted to know about
+                                  these bits */
+                               if (((arg & TIOCM_RNG) && (diff & UART_RI)) ||
+                                   ((arg & TIOCM_DSR) && (diff & UART_DSR)) ||
+                                   ((arg & TIOCM_CD) && (diff & UART_CD)) ||
+                                   ((arg & TIOCM_CTS) && (diff & UART_CTS)))
+                                       return 0;
+                               /* otherwise caller can't care less about what
+                                * happened, and so we continue to wait for
+                                * more events.
+                                */
                        }
-                       return 0;
-                       break;
-               default:
-                       break;
+               }
+               return 0;
+       default:
+               break;
        }
-
        dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __func__, cmd);
-
        return -ENOIOCTLCMD;
 } /* cypress_ioctl */
 
 
-static void cypress_set_termios (struct usb_serial_port *port,
-               struct ktermios *old_termios)
+static void cypress_set_termios(struct tty_struct *tty,
+       struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct cypress_private *priv = usb_get_serial_port_data(port);
-       struct tty_struct *tty;
        int data_bits, stop_bits, parity_type, parity_enable;
        unsigned cflag, iflag;
        unsigned long flags;
@@ -1007,8 +1042,6 @@ static void cypress_set_termios (struct usb_serial_port *port,
 
        dbg("%s - port %d", __func__, port->number);
 
-       tty = port->tty;
-
        spin_lock_irqsave(&priv->lock, flags);
        if (!priv->termios_initialized) {
                if (priv->chiptype == CT_EARTHMATE) {
@@ -1060,28 +1093,24 @@ static void cypress_set_termios (struct usb_serial_port *port,
        } else
                parity_enable = parity_type = 0;
 
-       if (cflag & CSIZE) {
-               switch (cflag & CSIZE) {
-                       case CS5:
-                               data_bits = 0;
-                               break;
-                       case CS6:
-                               data_bits = 1;
-                               break;
-                       case CS7:
-                               data_bits = 2;
-                               break;
-                       case CS8:
-                               data_bits = 3;
-                               break;
-                       default:
-                               err("%s - CSIZE was set, but not CS5-CS8",
-                                               __func__);
-                               data_bits = 3;
-               }
-       } else
+       switch (cflag & CSIZE) {
+       case CS5:
+               data_bits = 0;
+               break;
+       case CS6:
+               data_bits = 1;
+               break;
+       case CS7:
+               data_bits = 2;
+               break;
+       case CS8:
                data_bits = 3;
-
+               break;
+       default:
+               err("%s - CSIZE was set, but not CS5-CS8",
+                               __func__);
+               data_bits = 3;
+       }
        spin_lock_irqsave(&priv->lock, flags);
        oldlines = priv->line_control;
        if ((cflag & CBAUD) == B0) {
@@ -1096,19 +1125,21 @@ static void cypress_set_termios (struct usb_serial_port *port,
                        "%d data_bits (+5)", __func__, stop_bits,
                        parity_enable, parity_type, data_bits);
 
-       cypress_serial_control(port, tty_get_baud_rate(tty), data_bits, stop_bits,
-                       parity_enable, parity_type, 0, CYPRESS_SET_CONFIG);
+       cypress_serial_control(tty, port, tty_get_baud_rate(tty),
+                       data_bits, stop_bits,
+                       parity_enable, parity_type,
+                       0, CYPRESS_SET_CONFIG);
 
        /* we perform a CYPRESS_GET_CONFIG so that the current settings are
         * filled into the private structure this should confirm that all is
         * working if it returns what we just set */
-       cypress_serial_control(port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG);
+       cypress_serial_control(tty, port, 0, 0, 0, 0, 0, 0, CYPRESS_GET_CONFIG);
 
        /* Here we can define custom tty settings for devices; the main tty
         * termios flag base comes from empeg.c */
 
        spin_lock_irqsave(&priv->lock, flags);
-       if ( (priv->chiptype == CT_EARTHMATE) && (priv->baud_rate == 4800) ) {
+       if (priv->chiptype == CT_EARTHMATE && priv->baud_rate == 4800) {
                dbg("Using custom termios settings for a baud rate of "
                                "4800bps.");
                /* define custom termios settings for NMEA protocol */
@@ -1142,20 +1173,21 @@ static void cypress_set_termios (struct usb_serial_port *port,
        /* if necessary, set lines */
        if (linechange) {
                priv->cmd_ctrl = 1;
-               cypress_write(port, NULL, 0);
+               cypress_write(tty, port, NULL, 0);
        }
 } /* cypress_set_termios */
 
 
 /* returns amount of data still left in soft buffer */
-static int cypress_chars_in_buffer(struct usb_serial_port *port)
+static int cypress_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct cypress_private *priv = usb_get_serial_port_data(port);
        int chars = 0;
        unsigned long flags;
 
        dbg("%s - port %d", __func__, port->number);
-       
+
        spin_lock_irqsave(&priv->lock, flags);
        chars = cypress_buf_data_avail(priv->buf);
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -1165,8 +1197,9 @@ static int cypress_chars_in_buffer(struct usb_serial_port *port)
 }
 
 
-static void cypress_throttle (struct usb_serial_port *port)
+static void cypress_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct cypress_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
 
@@ -1178,8 +1211,9 @@ static void cypress_throttle (struct usb_serial_port *port)
 }
 
 
-static void cypress_unthrottle (struct usb_serial_port *port)
+static void cypress_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct cypress_private *priv = usb_get_serial_port_data(port);
        int actually_throttled, result;
        unsigned long flags;
@@ -1232,12 +1266,13 @@ static void cypress_read_int_callback(struct urb *urb)
                /* precursor to disconnect so just go away */
                return;
        case -EPIPE:
-               usb_clear_halt(port->serial->dev,0x81);
+               usb_clear_halt(port->serial->dev, 0x81);
                break;
        default:
                /* something ugly is going on... */
-               dev_err(&urb->dev->dev,"%s - unexpected nonzero read status received: %d\n",
-                       __func__, status);
+               dev_err(&urb->dev->dev,
+                       "%s - unexpected nonzero read status received: %d\n",
+                                                       __func__, status);
                cypress_set_dead(port);
                return;
        }
@@ -1251,7 +1286,7 @@ static void cypress_read_int_callback(struct urb *urb)
        }
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (!tty) {
                dbg("%s - bad tty pointer - exiting", __func__);
                return;
@@ -1285,8 +1320,8 @@ static void cypress_read_int_callback(struct urb *urb)
                goto continue_read;
        }
 
-       usb_serial_debug_data (debug, &port->dev, __func__,
-                       urb->actual_length, data);
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                               urb->actual_length, data);
 
        spin_lock_irqsave(&priv->lock, flags);
        /* check to see if status has changed */
@@ -1327,7 +1362,7 @@ static void cypress_read_int_callback(struct urb *urb)
                                        data[i]);
                        tty_insert_flip_char(tty, data[i], tty_flag);
                }
-               tty_flip_buffer_push(port->tty);
+               tty_flip_buffer_push(port->port.tty);
        }
 
        spin_lock_irqsave(&priv->lock, flags);
@@ -1339,13 +1374,14 @@ continue_read:
 
        /* Continue trying to always read... unless the port has closed. */
 
-       if (port->open_count > 0 && priv->comm_is_ok) {
+       if (port->port.count > 0 && priv->comm_is_ok) {
                usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev,
                                usb_rcvintpipe(port->serial->dev,
                                        port->interrupt_in_endpointAddress),
                                port->interrupt_in_urb->transfer_buffer,
                                port->interrupt_in_urb->transfer_buffer_length,
-                               cypress_read_int_callback, port, priv->read_urb_interval);
+                               cypress_read_int_callback, port,
+                               priv->read_urb_interval);
                result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
                if (result) {
                        dev_err(&urb->dev->dev, "%s - failed resubmitting "
@@ -1369,42 +1405,43 @@ static void cypress_write_int_callback(struct urb *urb)
        dbg("%s - port %d", __func__, port->number);
 
        switch (status) {
-               case 0:
-                       /* success */
+       case 0:
+               /* success */
+               break;
+       case -ECONNRESET:
+       case -ENOENT:
+       case -ESHUTDOWN:
+               /* this urb is terminated, clean up */
+               dbg("%s - urb shutting down with status: %d",
+                                               __func__, status);
+               priv->write_urb_in_use = 0;
+               return;
+       case -EPIPE: /* no break needed; clear halt and resubmit */
+               if (!priv->comm_is_ok)
                        break;
-               case -ECONNRESET:
-               case -ENOENT:
-               case -ESHUTDOWN:
-                       /* this urb is terminated, clean up */
-                       dbg("%s - urb shutting down with status: %d",
-                           __func__, status);
-                       priv->write_urb_in_use = 0;
+               usb_clear_halt(port->serial->dev, 0x02);
+               /* error in the urb, so we have to resubmit it */
+               dbg("%s - nonzero write bulk status received: %d",
+                       __func__, status);
+               port->interrupt_out_urb->transfer_buffer_length = 1;
+               port->interrupt_out_urb->dev = port->serial->dev;
+               result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC);
+               if (!result)
                        return;
-               case -EPIPE: /* no break needed; clear halt and resubmit */
-                       if (!priv->comm_is_ok)
-                               break;
-                       usb_clear_halt(port->serial->dev, 0x02);
-                       /* error in the urb, so we have to resubmit it */
-                       dbg("%s - nonzero write bulk status received: %d",
-                           __func__, status);
-                       port->interrupt_out_urb->transfer_buffer_length = 1;
-                       port->interrupt_out_urb->dev = port->serial->dev;
-                       result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC);
-                       if (!result)
-                               return;
-                       dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n",
-                               __func__, result);
-                       cypress_set_dead(port);
-                       break;
-               default:
-                       dev_err(&urb->dev->dev,"%s - unexpected nonzero write status received: %d\n",
-                               __func__, status);
-                       cypress_set_dead(port);
-                       break;
+               dev_err(&urb->dev->dev,
+                       "%s - failed resubmitting write urb, error %d\n",
+                                                       __func__, result);
+               cypress_set_dead(port);
+               break;
+       default:
+               dev_err(&urb->dev->dev,
+                        "%s - unexpected nonzero write status received: %d\n",
+                                                       __func__, status);
+               cypress_set_dead(port);
+               break;
        }
-       
        priv->write_urb_in_use = 0;
-       
+
        /* send any buffered data */
        cypress_send(port);
 }
@@ -1486,7 +1523,8 @@ static void cypress_buf_clear(struct cypress_buf *cb)
 static unsigned int cypress_buf_data_avail(struct cypress_buf *cb)
 {
        if (cb != NULL)
-               return ((cb->buf_size + cb->buf_put - cb->buf_get) % cb->buf_size);
+               return (cb->buf_size + cb->buf_put - cb->buf_get)
+                                                       % cb->buf_size;
        else
                return 0;
 }
@@ -1502,7 +1540,8 @@ static unsigned int cypress_buf_data_avail(struct cypress_buf *cb)
 static unsigned int cypress_buf_space_avail(struct cypress_buf *cb)
 {
        if (cb != NULL)
-               return ((cb->buf_size + cb->buf_get - cb->buf_put - 1) % cb->buf_size);
+               return (cb->buf_size + cb->buf_get - cb->buf_put - 1)
+                                                       % cb->buf_size;
        else
                return 0;
 }
@@ -1602,9 +1641,9 @@ static unsigned int cypress_buf_get(struct cypress_buf *cb, char *buf,
 static int __init cypress_init(void)
 {
        int retval;
-       
+
        dbg("%s", __func__);
-       
+
        retval = usb_serial_register(&cypress_earthmate_device);
        if (retval)
                goto failed_em_register;
@@ -1632,23 +1671,23 @@ failed_em_register:
 }
 
 
-static void __exit cypress_exit (void)
+static void __exit cypress_exit(void)
 {
        dbg("%s", __func__);
 
-       usb_deregister (&cypress_driver);
-       usb_serial_deregister (&cypress_earthmate_device);
-       usb_serial_deregister (&cypress_hidcom_device);
-       usb_serial_deregister (&cypress_ca42v2_device);
+       usb_deregister(&cypress_driver);
+       usb_serial_deregister(&cypress_earthmate_device);
+       usb_serial_deregister(&cypress_hidcom_device);
+       usb_serial_deregister(&cypress_ca42v2_device);
 }
 
 
 module_init(cypress_init);
 module_exit(cypress_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
-MODULE_VERSION( DRIVER_VERSION );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_VERSION(DRIVER_VERSION);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index 0388065..e772b01 100644 (file)
@@ -54,7 +54,7 @@
 #define UART_DSR       0x20    /* data set ready - flow control - device to host */
 #define CONTROL_RTS    0x10    /* request to send - flow control - host to device */
 #define UART_CTS       0x10    /* clear to send - flow control - device to host */
-#define        UART_RI         0x10    /* ring indicator - modem - device to host */ 
+#define        UART_RI         0x10    /* ring indicator - modem - device to host */
 #define UART_CD                0x40    /* carrier detect - modem - device to host */
 #define CYP_ERROR      0x08    /* received from input report - device to host */
 /* Note - the below has nothing to to with the "feature report" reset */
index 28bc6fc..240aad1 100644 (file)
@@ -15,7 +15,7 @@
 *  Al Borchers (borchers@steinerpoint.com)
 * 
 * (12/03/2001) gkh
-*      switched to using port->open_count instead of private version.
+*      switched to using port->port.count instead of private version.
 *      Removed port->active
 *
 * (04/08/2001) gb
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/wait.h>
 #include <linux/usb/serial.h>
@@ -441,22 +441,23 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
        unsigned int modem_signals, int interruptible);
 static int digi_transmit_idle(struct usb_serial_port *port,
        unsigned long timeout);
-static void digi_rx_throttle (struct usb_serial_port *port);
-static void digi_rx_unthrottle (struct usb_serial_port *port);
-static void digi_set_termios(struct usb_serial_port *port,
-       struct ktermios *old_termios);
-static void digi_break_ctl(struct usb_serial_port *port, int break_state);
-static int digi_ioctl(struct usb_serial_port *port, struct file *file,
-       unsigned int cmd, unsigned long arg);
-static int digi_tiocmget(struct usb_serial_port *port, struct file *file);
-static int digi_tiocmset(struct usb_serial_port *port, struct file *file,
+static void digi_rx_throttle(struct tty_struct *tty);
+static void digi_rx_unthrottle(struct tty_struct *tty);
+static void digi_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios);
+static void digi_break_ctl(struct tty_struct *tty, int break_state);
+static int digi_tiocmget(struct tty_struct *tty, struct file *file);
+static int digi_tiocmset(struct tty_struct *tty, struct file *file,
        unsigned int set, unsigned int clear);
-static int digi_write(struct usb_serial_port *port, const unsigned char *buf, int count);
+static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
+       const unsigned char *buf, int count);
 static void digi_write_bulk_callback(struct urb *urb);
-static int digi_write_room(struct usb_serial_port *port);
-static int digi_chars_in_buffer(struct usb_serial_port *port);
-static int digi_open(struct usb_serial_port *port, struct file *filp);
-static void digi_close(struct usb_serial_port *port, struct file *filp);
+static int digi_write_room(struct tty_struct *tty);
+static int digi_chars_in_buffer(struct tty_struct *tty);
+static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
+       struct file *filp);
+static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,
+       struct file *filp);
 static int digi_startup_device(struct usb_serial *serial);
 static int digi_startup(struct usb_serial *serial);
 static void digi_shutdown(struct usb_serial *serial);
@@ -485,7 +486,7 @@ static struct usb_device_id id_table_4 [] = {
        { }                                             /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table_combined);
+MODULE_DEVICE_TABLE(usb, id_table_combined);
 
 static struct usb_driver digi_driver = {
        .name =         "digi_acceleport",
@@ -516,7 +517,6 @@ static struct usb_serial_driver digi_acceleport_2_device = {
        .chars_in_buffer =              digi_chars_in_buffer,
        .throttle =                     digi_rx_throttle,
        .unthrottle =                   digi_rx_unthrottle,
-       .ioctl =                        digi_ioctl,
        .set_termios =                  digi_set_termios,
        .break_ctl =                    digi_break_ctl,
        .tiocmget =                     digi_tiocmget,
@@ -543,7 +543,6 @@ static struct usb_serial_driver digi_acceleport_4_device = {
        .chars_in_buffer =              digi_chars_in_buffer,
        .throttle =                     digi_rx_throttle,
        .unthrottle =                   digi_rx_unthrottle,
-       .ioctl =                        digi_ioctl,
        .set_termios =                  digi_set_termios,
        .break_ctl =                    digi_break_ctl,
        .tiocmget =                     digi_tiocmget,
@@ -556,17 +555,17 @@ static struct usb_serial_driver digi_acceleport_4_device = {
 /* Functions */
 
 /*
-*  Cond Wait Interruptible Timeout Irqrestore
-*
-*  Do spin_unlock_irqrestore and interruptible_sleep_on_timeout
-*  so that wake ups are not lost if they occur between the unlock
-*  and the sleep.  In other words, spin_unlock_irqrestore and
-*  interruptible_sleep_on_timeout are "atomic" with respect to
-*  wake ups.  This is used to implement condition variables.
-*
-*  interruptible_sleep_on_timeout is deprecated and has been replaced
-*  with the equivalent code.
-*/
+ *  Cond Wait Interruptible Timeout Irqrestore
+ *
+ *  Do spin_unlock_irqrestore and interruptible_sleep_on_timeout
+ *  so that wake ups are not lost if they occur between the unlock
+ *  and the sleep.  In other words, spin_unlock_irqrestore and
+ *  interruptible_sleep_on_timeout are "atomic" with respect to
+ *  wake ups.  This is used to implement condition variables.
+ *
+ *  interruptible_sleep_on_timeout is deprecated and has been replaced
+ *  with the equivalent code.
+ */
 
 static long cond_wait_interruptible_timeout_irqrestore(
        wait_queue_head_t *q, long timeout,
@@ -585,15 +584,16 @@ __releases(lock)
 
 
 /*
-*  Digi Wakeup Write
-*
-*  Wake up port, line discipline, and tty processes sleeping
-*  on writes.
-*/
+ *  Digi Wakeup Write
+ *
+ *  Wake up port, line discipline, and tty processes sleeping
+ *  on writes.
+ */
 
 static void digi_wakeup_write_lock(struct work_struct *work)
 {
-       struct digi_port *priv = container_of(work, struct digi_port, dp_wakeup_work);
+       struct digi_port *priv =
+                       container_of(work, struct digi_port, dp_wakeup_work);
        struct usb_serial_port *port = priv->dp_port;
        unsigned long flags;
 
@@ -604,20 +604,20 @@ static void digi_wakeup_write_lock(struct work_struct *work)
 
 static void digi_wakeup_write(struct usb_serial_port *port)
 {
-       tty_wakeup(port->tty);
+       tty_wakeup(port->port.tty);
 }
 
 
 /*
-*  Digi Write OOB Command
-*
-*  Write commands on the out of band port.  Commands are 4
-*  bytes each, multiple commands can be sent at once, and
-*  no command will be split across USB packets.  Returns 0
-*  if successful, -EINTR if interrupted while sleeping and
-*  the interruptible flag is true, or a negative error
-*  returned by usb_submit_urb.
-*/
+ *  Digi Write OOB Command
+ *
+ *  Write commands on the out of band port.  Commands are 4
+ *  bytes each, multiple commands can be sent at once, and
+ *  no command will be split across USB packets.  Returns 0
+ *  if successful, -EINTR if interrupted while sleeping and
+ *  the interruptible flag is true, or a negative error
+ *  returned by usb_submit_urb.
+ */
 
 static int digi_write_oob_command(struct usb_serial_port *port,
        unsigned char *buf, int count, int interruptible)
@@ -632,8 +632,8 @@ static int digi_write_oob_command(struct usb_serial_port *port,
        dbg("digi_write_oob_command: TOP: port=%d, count=%d", oob_priv->dp_port_num, count);
 
        spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
-       while(count > 0) {
-               while(oob_port->write_urb->status == -EINPROGRESS
+       while (count > 0) {
+               while (oob_port->write_urb->status == -EINPROGRESS
                        || oob_priv->dp_write_urb_in_use) {
                        cond_wait_interruptible_timeout_irqrestore(
                                &oob_port->write_wait, DIGI_RETRY_TIMEOUT,
@@ -650,7 +650,8 @@ static int digi_write_oob_command(struct usb_serial_port *port,
                memcpy(oob_port->write_urb->transfer_buffer, buf, len);
                oob_port->write_urb->transfer_buffer_length = len;
                oob_port->write_urb->dev = port->serial->dev;
-               if ((ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0) {
+               ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC);
+               if (ret == 0) {
                        oob_priv->dp_write_urb_in_use = 1;
                        count -= len;
                        buf += len;
@@ -665,16 +666,16 @@ static int digi_write_oob_command(struct usb_serial_port *port,
 
 
 /*
-*  Digi Write In Band Command
-*
-*  Write commands on the given port.  Commands are 4
-*  bytes each, multiple commands can be sent at once, and
-*  no command will be split across USB packets.  If timeout
-*  is non-zero, write in band command will return after
-*  waiting unsuccessfully for the URB status to clear for
-*  timeout ticks.  Returns 0 if successful, or a negative
-*  error returned by digi_write.
-*/
+ *  Digi Write In Band Command
+ *
+ *  Write commands on the given port.  Commands are 4
+ *  bytes each, multiple commands can be sent at once, and
+ *  no command will be split across USB packets.  If timeout
+ *  is non-zero, write in band command will return after
+ *  waiting unsuccessfully for the URB status to clear for
+ *  timeout ticks.  Returns 0 if successful, or a negative
+ *  error returned by digi_write.
+ */
 
 static int digi_write_inb_command(struct usb_serial_port *port,
        unsigned char *buf, int count, unsigned long timeout)
@@ -694,9 +695,10 @@ static int digi_write_inb_command(struct usb_serial_port *port,
                timeout = ULONG_MAX;
 
        spin_lock_irqsave(&priv->dp_port_lock, flags);
-       while(count > 0 && ret == 0) {
-               while((port->write_urb->status == -EINPROGRESS
-                       || priv->dp_write_urb_in_use) && time_before(jiffies, timeout)) {
+       while (count > 0 && ret == 0) {
+               while ((port->write_urb->status == -EINPROGRESS
+                               || priv->dp_write_urb_in_use)
+                                       && time_before(jiffies, timeout)) {
                        cond_wait_interruptible_timeout_irqrestore(
                                &port->write_wait, DIGI_RETRY_TIMEOUT,
                                &priv->dp_port_lock, flags);
@@ -727,7 +729,8 @@ static int digi_write_inb_command(struct usb_serial_port *port,
                }
                port->write_urb->dev = port->serial->dev;
 
-               if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) {
+               ret = usb_submit_urb(port->write_urb, GFP_ATOMIC);
+               if (ret == 0) {
                        priv->dp_write_urb_in_use = 1;
                        priv->dp_out_buf_len = 0;
                        count -= len;
@@ -745,14 +748,14 @@ static int digi_write_inb_command(struct usb_serial_port *port,
 
 
 /*
-*  Digi Set Modem Signals
-*
-*  Sets or clears DTR and RTS on the port, according to the
-*  modem_signals argument.  Use TIOCM_DTR and TIOCM_RTS flags
-*  for the modem_signals argument.  Returns 0 if successful,
-*  -EINTR if interrupted while sleeping, or a non-zero error
-*  returned by usb_submit_urb.
-*/
+ *  Digi Set Modem Signals
+ *
+ *  Sets or clears DTR and RTS on the port, according to the
+ *  modem_signals argument.  Use TIOCM_DTR and TIOCM_RTS flags
+ *  for the modem_signals argument.  Returns 0 if successful,
+ *  -EINTR if interrupted while sleeping, or a non-zero error
+ *  returned by usb_submit_urb.
+ */
 
 static int digi_set_modem_signals(struct usb_serial_port *port,
        unsigned int modem_signals, int interruptible)
@@ -760,7 +763,7 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
 
        int ret;
        struct digi_port *port_priv = usb_get_serial_port_data(port);
-       struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port;
+       struct usb_serial_port *oob_port = (struct usb_serial_port *) ((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port;
        struct digi_port *oob_priv = usb_get_serial_port_data(oob_port);
        unsigned char *data = oob_port->write_urb->transfer_buffer;
        unsigned long flags = 0;
@@ -772,7 +775,8 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
        spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
        spin_lock(&port_priv->dp_port_lock);
 
-       while(oob_port->write_urb->status == -EINPROGRESS || oob_priv->dp_write_urb_in_use) {
+       while (oob_port->write_urb->status == -EINPROGRESS ||
+                                       oob_priv->dp_write_urb_in_use) {
                spin_unlock(&port_priv->dp_port_lock);
                cond_wait_interruptible_timeout_irqrestore(
                        &oob_port->write_wait, DIGI_RETRY_TIMEOUT,
@@ -784,17 +788,20 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
        }
        data[0] = DIGI_CMD_SET_DTR_SIGNAL;
        data[1] = port_priv->dp_port_num;
-       data[2] = (modem_signals&TIOCM_DTR) ? DIGI_DTR_ACTIVE : DIGI_DTR_INACTIVE;
+       data[2] = (modem_signals & TIOCM_DTR) ?
+                                       DIGI_DTR_ACTIVE : DIGI_DTR_INACTIVE;
        data[3] = 0;
        data[4] = DIGI_CMD_SET_RTS_SIGNAL;
        data[5] = port_priv->dp_port_num;
-       data[6] = (modem_signals&TIOCM_RTS) ? DIGI_RTS_ACTIVE : DIGI_RTS_INACTIVE;
+       data[6] = (modem_signals & TIOCM_RTS) ?
+                                       DIGI_RTS_ACTIVE : DIGI_RTS_INACTIVE;
        data[7] = 0;
 
        oob_port->write_urb->transfer_buffer_length = 8;
        oob_port->write_urb->dev = port->serial->dev;
 
-       if ((ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0) {
+       ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC);
+       if (ret == 0) {
                oob_priv->dp_write_urb_in_use = 1;
                port_priv->dp_modem_signals =
                        (port_priv->dp_modem_signals&~(TIOCM_DTR|TIOCM_RTS))
@@ -808,16 +815,16 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
 }
 
 /*
-*  Digi Transmit Idle
-*
-*  Digi transmit idle waits, up to timeout ticks, for the transmitter
-*  to go idle.  It returns 0 if successful or a negative error.
-*
-*  There are race conditions here if more than one process is calling
-*  digi_transmit_idle on the same port at the same time.  However, this
-*  is only called from close, and only one process can be in close on a
-*  port at a time, so its ok.
-*/
+ *  Digi Transmit Idle
+ *
+ *  Digi transmit idle waits, up to timeout ticks, for the transmitter
+ *  to go idle.  It returns 0 if successful or a negative error.
+ *
+ *  There are race conditions here if more than one process is calling
+ *  digi_transmit_idle on the same port at the same time.  However, this
+ *  is only called from close, and only one process can be in close on a
+ *  port at a time, so its ok.
+ */
 
 static int digi_transmit_idle(struct usb_serial_port *port,
        unsigned long timeout)
@@ -836,12 +843,13 @@ static int digi_transmit_idle(struct usb_serial_port *port,
 
        timeout += jiffies;
 
-       if ((ret = digi_write_inb_command(port, buf, 2, timeout - jiffies)) != 0)
+       ret = digi_write_inb_command(port, buf, 2, timeout - jiffies);
+       if (ret != 0)
                return ret;
 
        spin_lock_irqsave(&priv->dp_port_lock, flags);
 
-       while(time_before(jiffies, timeout) && !priv->dp_transmit_idle) {
+       while (time_before(jiffies, timeout) && !priv->dp_transmit_idle) {
                cond_wait_interruptible_timeout_irqrestore(
                        &priv->dp_transmit_idle_wait, DIGI_RETRY_TIMEOUT,
                        &priv->dp_port_lock, flags);
@@ -856,9 +864,10 @@ static int digi_transmit_idle(struct usb_serial_port *port,
 }
 
 
-static void digi_rx_throttle(struct usb_serial_port *port)
+static void digi_rx_throttle(struct tty_struct *tty)
 {
        unsigned long flags;
+       struct usb_serial_port *port = tty->driver_data;
        struct digi_port *priv = usb_get_serial_port_data(port);
 
 
@@ -872,10 +881,11 @@ static void digi_rx_throttle(struct usb_serial_port *port)
 }
 
 
-static void digi_rx_unthrottle(struct usb_serial_port *port)
+static void digi_rx_unthrottle(struct tty_struct *tty)
 {
        int ret = 0;
        unsigned long flags;
+       struct usb_serial_port *port = tty->driver_data;
        struct digi_port *priv = usb_get_serial_port_data(port);
 
        dbg("digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num);
@@ -900,26 +910,25 @@ static void digi_rx_unthrottle(struct usb_serial_port *port)
 }
 
 
-static void digi_set_termios(struct usb_serial_port *port,
-                                       struct ktermios *old_termios)
+static void digi_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
-
        struct digi_port *priv = usb_get_serial_port_data(port);
-       struct tty_struct *tty = port->tty;
        unsigned int iflag = tty->termios->c_iflag;
        unsigned int cflag = tty->termios->c_cflag;
        unsigned int old_iflag = old_termios->c_iflag;
        unsigned int old_cflag = old_termios->c_cflag;
        unsigned char buf[32];
        unsigned int modem_signals;
-       int arg,ret;
+       int arg, ret;
        int i = 0;
        speed_t baud;
 
        dbg("digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, old_cflag=0x%x", priv->dp_port_num, iflag, old_iflag, cflag, old_cflag);
 
        /* set baud rate */
-       if ((baud = tty_get_baud_rate(tty)) != tty_termios_baud_rate(old_termios)) {
+       baud = tty_get_baud_rate(tty);
+       if (baud != tty_termios_baud_rate(old_termios)) {
                arg = -1;
 
                /* reassert DTR and (maybe) RTS on transition from B0 */
@@ -933,30 +942,30 @@ static void digi_set_termios(struct usb_serial_port *port,
                        digi_set_modem_signals(port, modem_signals, 1);
                }
                switch (baud) {
-                       /* drop DTR and RTS on transition to B0 */
-                       case 0: digi_set_modem_signals(port, 0, 1); break;
-                       case 50: arg = DIGI_BAUD_50; break;
-                       case 75: arg = DIGI_BAUD_75; break;
-                       case 110: arg = DIGI_BAUD_110; break;
-                       case 150: arg = DIGI_BAUD_150; break;
-                       case 200: arg = DIGI_BAUD_200; break;
-                       case 300: arg = DIGI_BAUD_300; break;
-                       case 600: arg = DIGI_BAUD_600; break;
-                       case 1200: arg = DIGI_BAUD_1200; break;
-                       case 1800: arg = DIGI_BAUD_1800; break;
-                       case 2400: arg = DIGI_BAUD_2400; break;
-                       case 4800: arg = DIGI_BAUD_4800; break;
-                       case 9600: arg = DIGI_BAUD_9600; break;
-                       case 19200: arg = DIGI_BAUD_19200; break;
-                       case 38400: arg = DIGI_BAUD_38400; break;
-                       case 57600: arg = DIGI_BAUD_57600; break;
-                       case 115200: arg = DIGI_BAUD_115200; break;
-                       case 230400: arg = DIGI_BAUD_230400; break;
-                       case 460800: arg = DIGI_BAUD_460800; break;
-                       default:
-                               arg = DIGI_BAUD_9600;
-                               baud = 9600;
-                               break;
+               /* drop DTR and RTS on transition to B0 */
+               case 0: digi_set_modem_signals(port, 0, 1); break;
+               case 50: arg = DIGI_BAUD_50; break;
+               case 75: arg = DIGI_BAUD_75; break;
+               case 110: arg = DIGI_BAUD_110; break;
+               case 150: arg = DIGI_BAUD_150; break;
+               case 200: arg = DIGI_BAUD_200; break;
+               case 300: arg = DIGI_BAUD_300; break;
+               case 600: arg = DIGI_BAUD_600; break;
+               case 1200: arg = DIGI_BAUD_1200; break;
+               case 1800: arg = DIGI_BAUD_1800; break;
+               case 2400: arg = DIGI_BAUD_2400; break;
+               case 4800: arg = DIGI_BAUD_4800; break;
+               case 9600: arg = DIGI_BAUD_9600; break;
+               case 19200: arg = DIGI_BAUD_19200; break;
+               case 38400: arg = DIGI_BAUD_38400; break;
+               case 57600: arg = DIGI_BAUD_57600; break;
+               case 115200: arg = DIGI_BAUD_115200; break;
+               case 230400: arg = DIGI_BAUD_230400; break;
+               case 460800: arg = DIGI_BAUD_460800; break;
+               default:
+                       arg = DIGI_BAUD_9600;
+                       baud = 9600;
+                       break;
                }
                if (arg != -1) {
                        buf[i++] = DIGI_CMD_SET_BAUD_RATE;
@@ -1082,14 +1091,16 @@ static void digi_set_termios(struct usb_serial_port *port,
                buf[i++] = arg;
                buf[i++] = 0;
        }
-       if ((ret = digi_write_oob_command(port, buf, i, 1)) != 0)
+       ret = digi_write_oob_command(port, buf, i, 1);
+       if (ret != 0)
                dbg("digi_set_termios: write oob failed, ret=%d", ret);
        tty_encode_baud_rate(tty, baud, baud);
 }
 
 
-static void digi_break_ctl(struct usb_serial_port *port, int break_state)
+static void digi_break_ctl(struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        unsigned char buf[4];
 
        buf[0] = DIGI_CMD_BREAK_CONTROL;
@@ -1100,8 +1111,9 @@ static void digi_break_ctl(struct usb_serial_port *port, int break_state)
 }
 
 
-static int digi_tiocmget(struct usb_serial_port *port, struct file *file)
+static int digi_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct digi_port *priv = usb_get_serial_port_data(port);
        unsigned int val;
        unsigned long flags;
@@ -1115,9 +1127,10 @@ static int digi_tiocmget(struct usb_serial_port *port, struct file *file)
 }
 
 
-static int digi_tiocmset(struct usb_serial_port *port, struct file *file,
+static int digi_tiocmset(struct tty_struct *tty, struct file *file,
        unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct digi_port *priv = usb_get_serial_port_data(port);
        unsigned int val;
        unsigned long flags;
@@ -1131,30 +1144,11 @@ static int digi_tiocmset(struct usb_serial_port *port, struct file *file,
 }
 
 
-static int digi_ioctl(struct usb_serial_port *port, struct file *file,
-       unsigned int cmd, unsigned long arg)
-{
-       struct digi_port *priv = usb_get_serial_port_data(port);
-       dbg("digi_ioctl: TOP: port=%d, cmd=0x%x", priv->dp_port_num, cmd);
-
-       switch (cmd) {
-       case TIOCMIWAIT:
-               /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
-               /* TODO */
-               return 0;
-       case TIOCGICOUNT:
-               /* return count of modemline transitions */
-               /* TODO */
-               return 0;
-       }
-       return -ENOIOCTLCMD;
-
-}
-
-static int digi_write(struct usb_serial_port *port, const unsigned char *buf, int count)
+static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count)
 {
 
-       int ret,data_len,new_len;
+       int ret, data_len, new_len;
        struct digi_port *priv = usb_get_serial_port_data(port);
        unsigned char *data = port->write_urb->transfer_buffer;
        unsigned long flags = 0;
@@ -1172,7 +1166,8 @@ static int digi_write(struct usb_serial_port *port, const unsigned char *buf, in
        spin_lock_irqsave(&priv->dp_port_lock, flags);
 
        /* wait for urb status clear to submit another urb */
-       if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use) {
+       if (port->write_urb->status == -EINPROGRESS ||
+                                       priv->dp_write_urb_in_use) {
                /* buffer data if count is 1 (probably put_char) if possible */
                if (count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE) {
                        priv->dp_out_buf[priv->dp_out_buf_len++] = *buf;
@@ -1207,7 +1202,8 @@ static int digi_write(struct usb_serial_port *port, const unsigned char *buf, in
        /* copy in new data */
        memcpy(data, buf, new_len);
 
-       if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) {
+       ret = usb_submit_urb(port->write_urb, GFP_ATOMIC);
+       if (ret == 0) {
                priv->dp_write_urb_in_use = 1;
                ret = new_len;
                priv->dp_out_buf_len = 0;
@@ -1221,7 +1217,7 @@ static int digi_write(struct usb_serial_port *port, const unsigned char *buf, in
        dbg("digi_write: returning %d", ret);
        return ret;
 
-} 
+}
 
 static void digi_write_bulk_callback(struct urb *urb)
 {
@@ -1236,13 +1232,13 @@ static void digi_write_bulk_callback(struct urb *urb)
        dbg("digi_write_bulk_callback: TOP, urb->status=%d", status);
 
        /* port and serial sanity check */
-       if (port == NULL || (priv=usb_get_serial_port_data(port)) == NULL) {
+       if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) {
                err("%s: port or port->private is NULL, status=%d",
                    __func__, status);
                return;
        }
        serial = port->serial;
-       if (serial == NULL || (serial_priv=usb_get_serial_data(serial)) == NULL) {
+       if (serial == NULL || (serial_priv = usb_get_serial_data(serial)) == NULL) {
                err("%s: serial or serial->private is NULL, status=%d",
                    __func__, status);
                return;
@@ -1261,17 +1257,19 @@ static void digi_write_bulk_callback(struct urb *urb)
        /* try to send any buffered data on this port, if it is open */
        spin_lock(&priv->dp_port_lock);
        priv->dp_write_urb_in_use = 0;
-       if (port->open_count && port->write_urb->status != -EINPROGRESS
+       if (port->port.count && port->write_urb->status != -EINPROGRESS
            && priv->dp_out_buf_len > 0) {
                *((unsigned char *)(port->write_urb->transfer_buffer))
                        = (unsigned char)DIGI_CMD_SEND_DATA;
-               *((unsigned char *)(port->write_urb->transfer_buffer)+1)
+               *((unsigned char *)(port->write_urb->transfer_buffer) + 1)
                        = (unsigned char)priv->dp_out_buf_len;
-               port->write_urb->transfer_buffer_length = priv->dp_out_buf_len+2;
+               port->write_urb->transfer_buffer_length =
+                                               priv->dp_out_buf_len + 2;
                port->write_urb->dev = serial->dev;
-               memcpy(port->write_urb->transfer_buffer+2, priv->dp_out_buf,
+               memcpy(port->write_urb->transfer_buffer + 2, priv->dp_out_buf,
                        priv->dp_out_buf_len);
-               if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) {
+               ret = usb_submit_urb(port->write_urb, GFP_ATOMIC);
+               if (ret == 0) {
                        priv->dp_write_urb_in_use = 1;
                        priv->dp_out_buf_len = 0;
                }
@@ -1288,16 +1286,17 @@ static void digi_write_bulk_callback(struct urb *urb)
                        __func__, ret, priv->dp_port_num);
 }
 
-static int digi_write_room(struct usb_serial_port *port)
+static int digi_write_room(struct tty_struct *tty)
 {
-
-       int room;
+       struct usb_serial_port *port = tty->driver_data;
        struct digi_port *priv = usb_get_serial_port_data(port);
+       int room;
        unsigned long flags = 0;
 
        spin_lock_irqsave(&priv->dp_port_lock, flags);
 
-       if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use)
+       if (port->write_urb->status == -EINPROGRESS ||
+                                       priv->dp_write_urb_in_use)
                room = 0;
        else
                room = port->bulk_out_size - 2 - priv->dp_out_buf_len;
@@ -1308,12 +1307,11 @@ static int digi_write_room(struct usb_serial_port *port)
 
 }
 
-static int digi_chars_in_buffer(struct usb_serial_port *port)
+static int digi_chars_in_buffer(struct tty_struct *tty)
 {
-
+       struct usb_serial_port *port = tty->driver_data;
        struct digi_port *priv = usb_get_serial_port_data(port);
 
-
        if (port->write_urb->status == -EINPROGRESS
            || priv->dp_write_urb_in_use) {
                dbg("digi_chars_in_buffer: port=%d, chars=%d",
@@ -1329,7 +1327,8 @@ static int digi_chars_in_buffer(struct usb_serial_port *port)
 }
 
 
-static int digi_open(struct usb_serial_port *port, struct file *filp)
+static int digi_open(struct tty_struct *tty, struct usb_serial_port *port,
+                               struct file *filp)
 {
        int ret;
        unsigned char buf[32];
@@ -1338,7 +1337,7 @@ static int digi_open(struct usb_serial_port *port, struct file *filp)
        unsigned long flags = 0;
 
        dbg("digi_open: TOP: port=%d, open_count=%d",
-               priv->dp_port_num, port->open_count);
+               priv->dp_port_num, port->port.count);
 
        /* be sure the device is started up */
        if (digi_startup_device(port->serial) != 0)
@@ -1353,7 +1352,7 @@ static int digi_open(struct usb_serial_port *port, struct file *filp)
        }
 
        /* wait for a close in progress to finish */
-       while(priv->dp_in_close) {
+       while (priv->dp_in_close) {
                cond_wait_interruptible_timeout_irqrestore(
                        &priv->dp_close_wait, DIGI_RETRY_TIMEOUT,
                        &priv->dp_port_lock, flags);
@@ -1363,7 +1362,7 @@ static int digi_open(struct usb_serial_port *port, struct file *filp)
        }
 
        spin_unlock_irqrestore(&priv->dp_port_lock, flags);
+
        /* read modem signals automatically whenever they change */
        buf[0] = DIGI_CMD_READ_INPUT_SIGNALS;
        buf[1] = priv->dp_port_num;
@@ -1376,13 +1375,16 @@ static int digi_open(struct usb_serial_port *port, struct file *filp)
        buf[6] = DIGI_FLUSH_TX | DIGI_FLUSH_RX;
        buf[7] = 0;
 
-       if ((ret = digi_write_oob_command(port, buf, 8, 1)) != 0)
+       ret = digi_write_oob_command(port, buf, 8, 1);
+       if (ret != 0)
                dbg("digi_open: write oob failed, ret=%d", ret);
 
        /* set termios settings */
-       not_termios.c_cflag = ~port->tty->termios->c_cflag;
-       not_termios.c_iflag = ~port->tty->termios->c_iflag;
-       digi_set_termios(port, &not_termios);
+       if (tty) {
+               not_termios.c_cflag = ~tty->termios->c_cflag;
+               not_termios.c_iflag = ~tty->termios->c_iflag;
+               digi_set_termios(tty, port, &not_termios);
+       }
 
        /* set DTR and RTS */
        digi_set_modem_signals(port, TIOCM_DTR|TIOCM_RTS, 1);
@@ -1391,16 +1393,16 @@ static int digi_open(struct usb_serial_port *port, struct file *filp)
 }
 
 
-static void digi_close(struct usb_serial_port *port, struct file *filp)
+static void digi_close(struct tty_struct *tty, struct usb_serial_port *port,
+                               struct file *filp)
 {
        DEFINE_WAIT(wait);
        int ret;
        unsigned char buf[32];
-       struct tty_struct *tty = port->tty;
        struct digi_port *priv = usb_get_serial_port_data(port);
 
        dbg("digi_close: TOP: port=%d, open_count=%d",
-               priv->dp_port_num, port->open_count);
+               priv->dp_port_num, port->port.count);
 
        mutex_lock(&port->serial->disc_mutex);
        /* if disconnected, just clear flags */
@@ -1425,9 +1427,8 @@ static void digi_close(struct usb_serial_port *port, struct file *filp)
 
        if (port->serial->dev) {
                /* wait for transmit idle */
-               if ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0) {
+               if ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0)
                        digi_transmit_idle(port, DIGI_CLOSE_TIMEOUT);
-               }
                /* drop DTR and RTS */
                digi_set_modem_signals(port, 0, 0);
 
@@ -1461,11 +1462,13 @@ static void digi_close(struct usb_serial_port *port, struct file *filp)
                buf[18] = DIGI_FLUSH_TX | DIGI_FLUSH_RX;
                buf[19] = 0;
 
-               if ((ret = digi_write_oob_command(port, buf, 20, 0)) != 0)
+               ret = digi_write_oob_command(port, buf, 20, 0);
+               if (ret != 0)
                        dbg("digi_close: write oob failed, ret=%d", ret);
 
                /* wait for final commands on oob port to complete */
-               prepare_to_wait(&priv->dp_flush_wait, &wait, TASK_INTERRUPTIBLE);
+               prepare_to_wait(&priv->dp_flush_wait, &wait,
+                                                       TASK_INTERRUPTIBLE);
                schedule_timeout(DIGI_CLOSE_TIMEOUT);
                finish_wait(&priv->dp_flush_wait, &wait);
 
@@ -1485,15 +1488,15 @@ exit:
 
 
 /*
-*  Digi Startup Device
-*
-*  Starts reads on all ports.  Must be called AFTER startup, with
-*  urbs initialized.  Returns 0 if successful, non-zero error otherwise.
-*/
+ *  Digi Startup Device
+ *
+ *  Starts reads on all ports.  Must be called AFTER startup, with
+ *  urbs initialized.  Returns 0 if successful, non-zero error otherwise.
+ */
 
 static int digi_startup_device(struct usb_serial *serial)
 {
-       int i,ret = 0;
+       int i, ret = 0;
        struct digi_serial *serial_priv = usb_get_serial_data(serial);
        struct usb_serial_port *port;
 
@@ -1511,7 +1514,8 @@ static int digi_startup_device(struct usb_serial *serial)
        for (i = 0; i < serial->type->num_ports + 1; i++) {
                port = serial->port[i];
                port->write_urb->dev = port->serial->dev;
-               if ((ret = usb_submit_urb(port->read_urb, GFP_KERNEL)) != 0) {
+               ret = usb_submit_urb(port->read_urb, GFP_KERNEL);
+               if (ret != 0) {
                        err("%s: usb_submit_urb failed, ret=%d, port=%d",
                                        __func__, ret, i);
                        break;
@@ -1532,7 +1536,7 @@ static int digi_startup(struct usb_serial *serial)
 
        /* allocate the private data structures for all ports */
        /* number of regular ports + 1 for the out-of-band port */
-       for(i = 0; i < serial->type->num_ports + 1; i++) {
+       for (i = 0; i < serial->type->num_ports + 1; i++) {
                /* allocate port private structure */
                priv = kmalloc(sizeof(struct digi_port), GFP_KERNEL);
                if (priv == NULL) {
@@ -1595,7 +1599,7 @@ static void digi_shutdown(struct usb_serial *serial)
 
        /* free the private data structures for all ports */
        /* number of regular ports + 1 for the out-of-band port */
-       for(i = 0; i < serial->type->num_ports + 1; i++)
+       for (i = 0; i < serial->type->num_ports + 1; i++)
                kfree(usb_get_serial_port_data(serial->port[i]));
        kfree(usb_get_serial_data(serial));
 }
@@ -1618,7 +1622,7 @@ static void digi_read_bulk_callback(struct urb *urb)
                return;
        }
        if (port->serial == NULL ||
-               (serial_priv=usb_get_serial_data(port->serial)) == NULL) {
+               (serial_priv = usb_get_serial_data(port->serial)) == NULL) {
                err("%s: serial is bad or serial->private is NULL, status=%d",
                        __func__, status);
                return;
@@ -1642,45 +1646,46 @@ static void digi_read_bulk_callback(struct urb *urb)
 
        /* continue read */
        urb->dev = port->serial->dev;
-       if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
+       ret = usb_submit_urb(urb, GFP_ATOMIC);
+       if (ret != 0) {
                err("%s: failed resubmitting urb, ret=%d, port=%d",
                    __func__, ret, priv->dp_port_num);
        }
 
 }
 
-/* 
-*  Digi Read INB Callback
-*
-*  Digi Read INB Callback handles reads on the in band ports, sending
-*  the data on to the tty subsystem.  When called we know port and
-*  port->private are not NULL and port->serial has been validated.
-*  It returns 0 if successful, 1 if successful but the port is
-*  throttled, and -1 if the sanity checks failed.
-*/
+/*
+ *  Digi Read INB Callback
+ *
+ *  Digi Read INB Callback handles reads on the in band ports, sending
+ *  the data on to the tty subsystem.  When called we know port and
+ *  port->private are not NULL and port->serial has been validated.
+ *  It returns 0 if successful, 1 if successful but the port is
+ *  throttled, and -1 if the sanity checks failed.
+ */
 
 static int digi_read_inb_callback(struct urb *urb)
 {
 
        struct usb_serial_port *port = urb->context;
-       struct tty_struct *tty = port->tty;
+       struct tty_struct *tty = port->port.tty;
        struct digi_port *priv = usb_get_serial_port_data(port);
        int opcode = ((unsigned char *)urb->transfer_buffer)[0];
        int len = ((unsigned char *)urb->transfer_buffer)[1];
        int port_status = ((unsigned char *)urb->transfer_buffer)[2];
-       unsigned char *data = ((unsigned char *)urb->transfer_buffer)+3;
-       int flag,throttled;
+       unsigned char *data = ((unsigned char *)urb->transfer_buffer) + 3;
+       int flag, throttled;
        int i;
        int status = urb->status;
 
        /* do not process callbacks on closed ports */
        /* but do continue the read chain */
-       if (port->open_count == 0)
+       if (port->port.count == 0)
                return 0;
 
        /* short/multiple packet check */
        if (urb->actual_length != len + 2) {
-               err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, "
+               err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, "
                    "port=%d, opcode=%d, len=%d, actual_length=%d, "
                    "status=%d", __func__, status, priv->dp_port_num,
                    opcode, len, urb->actual_length, port_status);
@@ -1722,8 +1727,9 @@ static int digi_read_inb_callback(struct urb *urb)
                        if (flag == TTY_NORMAL)
                                tty_insert_flip_string(tty, data, len);
                        else {
-                               for(i = 0; i < len; i++)
-                                       tty_insert_flip_char(tty, data[i], flag);
+                               for (i = 0; i < len; i++)
+                                       tty_insert_flip_char(tty,
+                                                               data[i], flag);
                        }
                        tty_flip_buffer_push(tty);
                }
@@ -1735,19 +1741,19 @@ static int digi_read_inb_callback(struct urb *urb)
        else if (opcode != DIGI_CMD_RECEIVE_DATA)
                dbg("%s: unknown opcode: %d", __func__, opcode);
 
-       return(throttled ? 1 : 0);
+       return throttled ? 1 : 0;
 
 }
 
 
-/* 
-*  Digi Read OOB Callback
-*
-*  Digi Read OOB Callback handles reads on the out of band port.
-*  When called we know port and port->private are not NULL and
-*  the port->serial is valid.  It returns 0 if successful, and
-*  -1 if the sanity checks failed.
-*/
+/*
+ *  Digi Read OOB Callback
+ *
+ *  Digi Read OOB Callback handles reads on the out of band port.
+ *  When called we know port and port->private are not NULL and
+ *  the port->serial is valid.  It returns 0 if successful, and
+ *  -1 if the sanity checks failed.
+ */
 
 static int digi_read_oob_callback(struct urb *urb)
 {
@@ -1757,12 +1763,13 @@ static int digi_read_oob_callback(struct urb *urb)
        struct digi_port *priv = usb_get_serial_port_data(port);
        int opcode, line, status, val;
        int i;
+       unsigned int rts;
 
        dbg("digi_read_oob_callback: port=%d, len=%d",
                        priv->dp_port_num, urb->actual_length);
 
        /* handle each oob command */
-       for(i = 0; i < urb->actual_length - 3;) {
+       for (i = 0; i < urb->actual_length - 3;) {
                opcode = ((unsigned char *)urb->transfer_buffer)[i++];
                line = ((unsigned char *)urb->transfer_buffer)[i++];
                status = ((unsigned char *)urb->transfer_buffer)[i++];
@@ -1776,27 +1783,29 @@ static int digi_read_oob_callback(struct urb *urb)
 
                port = serial->port[line];
 
-               if ((priv=usb_get_serial_port_data(port)) == NULL)
+               priv = usb_get_serial_port_data(port);
+               if (priv == NULL)
                        return -1;
 
+               rts = 0;
+               if (port->port.count)
+                       rts = port->port.tty->termios->c_cflag & CRTSCTS;
+
                if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) {
                        spin_lock(&priv->dp_port_lock);
                        /* convert from digi flags to termiox flags */
                        if (val & DIGI_READ_INPUT_SIGNALS_CTS) {
                                priv->dp_modem_signals |= TIOCM_CTS;
                                /* port must be open to use tty struct */
-                               if (port->open_count
-                                       && port->tty->termios->c_cflag & CRTSCTS) {
-                                       port->tty->hw_stopped = 0;
+                               if (rts) {
+                                       port->port.tty->hw_stopped = 0;
                                        digi_wakeup_write(port);
                                }
                        } else {
                                priv->dp_modem_signals &= ~TIOCM_CTS;
                                /* port must be open to use tty struct */
-                               if (port->open_count
-                                       && port->tty->termios->c_cflag & CRTSCTS) {
-                                       port->tty->hw_stopped = 1;
-                               }
+                               if (rts)
+                                       port->port.tty->hw_stopped = 1;
                        }
                        if (val & DIGI_READ_INPUT_SIGNALS_DSR)
                                priv->dp_modem_signals |= TIOCM_DSR;
@@ -1833,7 +1842,7 @@ static int __init digi_init(void)
        if (retval)
                goto failed_acceleport_2_device;
        retval = usb_serial_register(&digi_acceleport_4_device);
-       if (retval) 
+       if (retval)
                goto failed_acceleport_4_device;
        retval = usb_register(&digi_driver);
        if (retval)
index c5ec309..a6ab5b5 100644 (file)
  *     it under the terms of the GNU General Public License, as published by
  *     the Free Software Foundation, version 2.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
- * 
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
+ *
  * (07/16/2001) gb
- *     remove unused code in empeg_close() (thanks to Oliver Neukum for pointing this
- *     out) and rewrote empeg_set_termios().
- * 
+ *     remove unused code in empeg_close() (thanks to Oliver Neukum for
+ *     pointing this out) and rewrote empeg_set_termios().
+ *
  * (05/30/2001) gkh
- *     switched from using spinlock to a semaphore, which fixes lots of problems.
+ *     switched from using spinlock to a semaphore, which fixes lots of
+ * problems.
  *
  * (04/08/2001) gb
  *      Identify version on module load.
- * 
+ *
  * (01/22/2001) gb
- *     Added write_room() and chars_in_buffer() support. 
- * 
+ *     Added write_room() and chars_in_buffer() support.
+ *
  * (12/21/2000) gb
  *     Moved termio stuff inside the port->active check.
  *     Moved MOD_DEC_USE_COUNT to end of empeg_close().
- * 
+ *
  * (12/03/2000) gb
- *     Added port->tty->ldisc.set_termios(port->tty, NULL) to empeg_open()
- *     This notifies the tty driver that the termios have changed.
- * 
+ *     Added port->port.tty->ldisc.set_termios(port->port.tty, NULL) to
+ *     empeg_open(). This notifies the tty driver that the termios have
+ *     changed.
+ *
  * (11/13/2000) gb
- *     Moved tty->low_latency = 1 from empeg_read_bulk_callback() to empeg_open()
- *     (It only needs to be set once - Doh!)
- * 
+ *     Moved tty->low_latency = 1 from empeg_read_bulk_callback() to
+ *     empeg_open() (It only needs to be set once - Doh!)
+ *
  * (11/11/2000) gb
  *     Updated to work with id_table structure.
- * 
+ *
  * (11/04/2000) gb
  *     Forked this from visor.c, and hacked it up to work with an
  *     Empeg ltd. empeg-car player.  Constructive criticism welcomed.
@@ -48,7 +51,7 @@
  *     use of his code, and for his guidance, advice and patience. :)
  *     A 'Thank You' is in order for John Ripley of Empeg ltd for his
  *     advice, and patience too.
- * 
+ *
  */
 
 #include <linux/kernel.h>
@@ -60,7 +63,7 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 
@@ -77,31 +80,30 @@ static int debug;
 #define EMPEG_PRODUCT_ID               0x0001
 
 /* function prototypes for an empeg-car player */
-static int  empeg_open                 (struct usb_serial_port *port, struct file *filp);
-static void empeg_close                        (struct usb_serial_port *port, struct file *filp);
-static int  empeg_write                        (struct usb_serial_port *port,
-                                       const unsigned char *buf,
-                                       int count);
-static int  empeg_write_room           (struct usb_serial_port *port);
-static int  empeg_chars_in_buffer      (struct usb_serial_port *port);
-static void empeg_throttle             (struct usb_serial_port *port);
-static void empeg_unthrottle           (struct usb_serial_port *port);
-static int  empeg_startup              (struct usb_serial *serial);
-static void empeg_shutdown             (struct usb_serial *serial);
-static int  empeg_ioctl                        (struct usb_serial_port *port,
-                                       struct file * file,
-                                       unsigned int cmd,
-                                       unsigned long arg);
-static void empeg_set_termios          (struct usb_serial_port *port, struct ktermios *old_termios);
-static void empeg_write_bulk_callback  (struct urb *urb);
-static void empeg_read_bulk_callback   (struct urb *urb);
+static int  empeg_open(struct tty_struct *tty, struct usb_serial_port *port,
+                                               struct file *filp);
+static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port,
+                                               struct file *filp);
+static int  empeg_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                               const unsigned char *buf,
+                                               int count);
+static int  empeg_write_room(struct tty_struct *tty);
+static int  empeg_chars_in_buffer(struct tty_struct *tty);
+static void empeg_throttle(struct tty_struct *tty);
+static void empeg_unthrottle(struct tty_struct *tty);
+static int  empeg_startup(struct usb_serial *serial);
+static void empeg_shutdown(struct usb_serial *serial);
+static void empeg_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios);
+static void empeg_write_bulk_callback(struct urb *urb);
+static void empeg_read_bulk_callback(struct urb *urb);
 
 static struct usb_device_id id_table [] = {
        { USB_DEVICE(EMPEG_VENDOR_ID, EMPEG_PRODUCT_ID) },
        { }                                     /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table);
+MODULE_DEVICE_TABLE(usb, id_table);
 
 static struct usb_driver empeg_driver = {
        .name =         "empeg",
@@ -125,7 +127,6 @@ static struct usb_serial_driver empeg_device = {
        .unthrottle =           empeg_unthrottle,
        .attach =               empeg_startup,
        .shutdown =             empeg_shutdown,
-       .ioctl =                empeg_ioctl,
        .set_termios =          empeg_set_termios,
        .write =                empeg_write,
        .write_room =           empeg_write_room,
@@ -145,7 +146,8 @@ static int          bytes_out;
 /******************************************************************************
  * Empeg specific driver functions
  ******************************************************************************/
-static int empeg_open (struct usb_serial_port *port, struct file *filp)
+static int empeg_open(struct tty_struct *tty, struct usb_serial_port *port,
+                               struct file *filp)
 {
        struct usb_serial *serial = port->serial;
        int result = 0;
@@ -153,7 +155,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
        dbg("%s - port %d", __func__, port->number);
 
        /* Force default termio settings */
-       empeg_set_termios (port, NULL) ;
+       empeg_set_termios(tty, port, NULL) ;
 
        bytes_in = 0;
        bytes_out = 0;
@@ -161,7 +163,7 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
        /* Start reading from the device */
        usb_fill_bulk_urb(
                port->read_urb,
-               serial->dev, 
+               serial->dev,
                usb_rcvbulkpipe(serial->dev,
                        port->bulk_in_endpointAddress),
                port->read_urb->transfer_buffer,
@@ -172,13 +174,16 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
        result = usb_submit_urb(port->read_urb, GFP_KERNEL);
 
        if (result)
-               dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
+               dev_err(&port->dev,
+                       "%s - failed submitting read urb, error %d\n",
+                                                       __func__, result);
 
        return result;
 }
 
 
-static void empeg_close (struct usb_serial_port *port, struct file * filp)
+static void empeg_close(struct tty_struct *tty, struct usb_serial_port *port,
+                               struct file *filp)
 {
        dbg("%s - port %d", __func__, port->number);
 
@@ -189,7 +194,8 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp)
 }
 
 
-static int empeg_write (struct usb_serial_port *port, const unsigned char *buf, int count)
+static int empeg_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count)
 {
        struct usb_serial *serial = port->serial;
        struct urb *urb;
@@ -203,11 +209,10 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf,
        dbg("%s - port %d", __func__, port->number);
 
        while (count > 0) {
-
                /* try to find a free urb in our list of them */
                urb = NULL;
 
-               spin_lock_irqsave (&write_urb_pool_lock, flags);
+               spin_lock_irqsave(&write_urb_pool_lock, flags);
 
                for (i = 0; i < NUM_URBS; ++i) {
                        if (write_urb_pool[i]->status != -EINPROGRESS) {
@@ -216,7 +221,7 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf,
                        }
                }
 
-               spin_unlock_irqrestore (&write_urb_pool_lock, flags);
+               spin_unlock_irqrestore(&write_urb_pool_lock, flags);
 
                if (urb == NULL) {
                        dbg("%s - no more free urbs", __func__);
@@ -224,25 +229,27 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf,
                }
 
                if (urb->transfer_buffer == NULL) {
-                       urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC);
+                       urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC);
                        if (urb->transfer_buffer == NULL) {
-                               dev_err(&port->dev, "%s no more kernel memory...\n", __func__);
+                               dev_err(&port->dev,
+                                       "%s no more kernel memory...\n",
+                                                               __func__);
                                goto exit;
                        }
                }
 
-               transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE);
+               transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);
 
-               memcpy (urb->transfer_buffer, current_position, transfer_size);
+               memcpy(urb->transfer_buffer, current_position, transfer_size);
 
                usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, urb->transfer_buffer);
 
                /* build up our urb */
-               usb_fill_bulk_urb (
+               usb_fill_bulk_urb(
                        urb,
                        serial->dev,
                        usb_sndbulkpipe(serial->dev,
-                               port->bulk_out_endpointAddress), 
+                                       port->bulk_out_endpointAddress),
                        urb->transfer_buffer,
                        transfer_size,
                        empeg_write_bulk_callback,
@@ -262,66 +269,57 @@ static int empeg_write (struct usb_serial_port *port, const unsigned char *buf,
                bytes_out += transfer_size;
 
        }
-
 exit:
        return bytes_sent;
-
-} 
+}
 
 
-static int empeg_write_room (struct usb_serial_port *port)
+static int empeg_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        unsigned long flags;
        int i;
        int room = 0;
 
        dbg("%s - port %d", __func__, port->number);
 
-       spin_lock_irqsave (&write_urb_pool_lock, flags);
-
+       spin_lock_irqsave(&write_urb_pool_lock, flags);
        /* tally up the number of bytes available */
        for (i = 0; i < NUM_URBS; ++i) {
-               if (write_urb_pool[i]->status != -EINPROGRESS) {
+               if (write_urb_pool[i]->status != -EINPROGRESS)
                        room += URB_TRANSFER_BUFFER_SIZE;
-               }
-       } 
-
-       spin_unlock_irqrestore (&write_urb_pool_lock, flags);
-
+       }
+       spin_unlock_irqrestore(&write_urb_pool_lock, flags);
        dbg("%s - returns %d", __func__, room);
-
-       return (room);
+       return room;
 
 }
 
 
-static int empeg_chars_in_buffer (struct usb_serial_port *port)
+static int empeg_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        unsigned long flags;
        int i;
        int chars = 0;
 
        dbg("%s - port %d", __func__, port->number);
 
-       spin_lock_irqsave (&write_urb_pool_lock, flags);
+       spin_lock_irqsave(&write_urb_pool_lock, flags);
 
        /* tally up the number of bytes waiting */
        for (i = 0; i < NUM_URBS; ++i) {
-               if (write_urb_pool[i]->status == -EINPROGRESS) {
+               if (write_urb_pool[i]->status == -EINPROGRESS)
                        chars += URB_TRANSFER_BUFFER_SIZE;
-               }
        }
 
-       spin_unlock_irqrestore (&write_urb_pool_lock, flags);
-
+       spin_unlock_irqrestore(&write_urb_pool_lock, flags);
        dbg("%s - returns %d", __func__, chars);
-
-       return (chars);
-
+       return chars;
 }
 
 
-static void empeg_write_bulk_callback (struct urb *urb)
+static void empeg_write_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        int status = urb->status;
@@ -338,7 +336,7 @@ static void empeg_write_bulk_callback (struct urb *urb)
 }
 
 
-static void empeg_read_bulk_callback (struct urb *urb)
+static void empeg_read_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        struct tty_struct *tty;
@@ -354,9 +352,9 @@ static void empeg_read_bulk_callback (struct urb *urb)
                return;
        }
 
-       usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
-
-       tty = port->tty;
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                               urb->actual_length, data);
+       tty = port->port.tty;
 
        if (urb->actual_length) {
                tty_buffer_request_room(tty, urb->actual_length);
@@ -368,7 +366,7 @@ static void empeg_read_bulk_callback (struct urb *urb)
        /* Continue trying to always read  */
        usb_fill_bulk_urb(
                port->read_urb,
-               port->serial->dev, 
+               port->serial->dev,
                usb_rcvbulkpipe(port->serial->dev,
                        port->bulk_in_endpointAddress),
                port->read_urb->transfer_buffer,
@@ -379,38 +377,39 @@ static void empeg_read_bulk_callback (struct urb *urb)
        result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
 
        if (result)
-               dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
+               dev_err(&urb->dev->dev,
+                       "%s - failed resubmitting read urb, error %d\n",
+                                                       __func__, result);
 
        return;
 
 }
 
 
-static void empeg_throttle (struct usb_serial_port *port)
+static void empeg_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        dbg("%s - port %d", __func__, port->number);
        usb_kill_urb(port->read_urb);
 }
 
 
-static void empeg_unthrottle (struct usb_serial_port *port)
+static void empeg_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        int result;
-
        dbg("%s - port %d", __func__, port->number);
 
        port->read_urb->dev = port->serial->dev;
-
        result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
-
        if (result)
-               dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
-
-       return;
+               dev_err(&port->dev,
+                       "%s - failed submitting read urb, error %d\n",
+                                                       __func__, result);
 }
 
 
-static int  empeg_startup (struct usb_serial *serial)
+static int  empeg_startup(struct usb_serial *serial)
 {
        int r;
 
@@ -422,7 +421,7 @@ static int  empeg_startup (struct usb_serial *serial)
                return -ENODEV;
        }
        dbg("%s - reset config", __func__);
-       r = usb_reset_configuration (serial->dev);
+       r = usb_reset_configuration(serial->dev);
 
        /* continue on with initialization */
        return r;
@@ -430,34 +429,27 @@ static int  empeg_startup (struct usb_serial *serial)
 }
 
 
-static void empeg_shutdown (struct usb_serial *serial)
+static void empeg_shutdown(struct usb_serial *serial)
 {
-       dbg ("%s", __func__);
-}
-
-
-static int empeg_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
-{
-       dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
-
-       return -ENOIOCTLCMD;
+       dbg("%s", __func__);
 }
 
 
-static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
+static void empeg_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
-       struct ktermios *termios = port->tty->termios;
+       struct ktermios *termios = tty->termios;
        dbg("%s - port %d", __func__, port->number);
 
        /*
-         * The empeg-car player wants these particular tty settings.
-         * You could, for example, change the baud rate, however the
-         * player only supports 115200 (currently), so there is really
-         * no point in support for changes to the tty settings.
-         * (at least for now)
-         *
-         * The default requirements for this device are:
-         */
+        * The empeg-car player wants these particular tty settings.
+        * You could, for example, change the baud rate, however the
+        * player only supports 115200 (currently), so there is really
+        * no point in support for changes to the tty settings.
+        * (at least for now)
+        *
+        * The default requirements for this device are:
+        */
        termios->c_iflag
                &= ~(IGNBRK     /* disable ignore break */
                | BRKINT        /* disable break causes interrupt */
@@ -491,18 +483,18 @@ static void empeg_set_termios (struct usb_serial_port *port, struct ktermios *ol
         * this is bad as it opens up the possibility of dropping bytes
         * on the floor.  We don't want to drop bytes on the floor. :)
         */
-       port->tty->low_latency = 1;
-       tty_encode_baud_rate(port->tty, 115200, 115200);
+       tty->low_latency = 1;
+       tty_encode_baud_rate(tty, 115200, 115200);
 }
 
 
-static int __init empeg_init (void)
+static int __init empeg_init(void)
 {
        struct urb *urb;
        int i, retval;
 
-       /* create our write urb pool and transfer buffers */ 
-       spin_lock_init (&write_urb_pool_lock);
+       /* create our write urb pool and transfer buffers */
+       spin_lock_init(&write_urb_pool_lock);
        for (i = 0; i < NUM_URBS; ++i) {
                urb = usb_alloc_urb(0, GFP_KERNEL);
                write_urb_pool[i] = urb;
@@ -511,9 +503,10 @@ static int __init empeg_init (void)
                        continue;
                }
 
-               urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
+               urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
+                                                               GFP_KERNEL);
                if (!urb->transfer_buffer) {
-                       err("%s - out of memory for urb buffers.", 
+                       err("%s - out of memory for urb buffers.",
                            __func__);
                        continue;
                }
@@ -542,36 +535,36 @@ failed_usb_serial_register:
 }
 
 
-static void __exit empeg_exit (void)
+static void __exit empeg_exit(void)
 {
        int i;
        unsigned long flags;
 
        usb_deregister(&empeg_driver);
-       usb_serial_deregister (&empeg_device);
+       usb_serial_deregister(&empeg_device);
 
-       spin_lock_irqsave (&write_urb_pool_lock, flags);
+       spin_lock_irqsave(&write_urb_pool_lock, flags);
 
        for (i = 0; i < NUM_URBS; ++i) {
                if (write_urb_pool[i]) {
-                       /* FIXME - uncomment the following usb_kill_urb call when
-                        * the host controllers get fixed to set urb->dev = NULL after
-                        * the urb is finished.  Otherwise this call oopses. */
+                       /* FIXME - uncomment the following usb_kill_urb call
+                        * when the host controllers get fixed to set urb->dev
+                        * = NULL after the urb is finished.  Otherwise this
+                        * call oopses. */
                        /* usb_kill_urb(write_urb_pool[i]); */
                        kfree(write_urb_pool[i]->transfer_buffer);
-                       usb_free_urb (write_urb_pool[i]);
+                       usb_free_urb(write_urb_pool[i]);
                }
        }
-
-       spin_unlock_irqrestore (&write_urb_pool_lock, flags);
+       spin_unlock_irqrestore(&write_urb_pool_lock, flags);
 }
 
 
 module_init(empeg_init);
 module_exit(empeg_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index cc4fbd9..711e84f 100644 (file)
@@ -20,7 +20,8 @@
 /* EZ-USB Control and Status Register.  Bit 0 controls 8051 reset */
 #define CPUCS_REG    0x7F92
 
-int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest)
+int ezusb_writememory(struct usb_serial *serial, int address,
+                               unsigned char *data, int length, __u8 request)
 {
        int result;
        unsigned char *transfer_buffer;
@@ -33,26 +34,27 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da
 
        transfer_buffer = kmemdup(data, length, GFP_KERNEL);
        if (!transfer_buffer) {
-               dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, length);
+               dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n",
+                                                       __func__, length);
                return -ENOMEM;
        }
-       result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000);
-       kfree (transfer_buffer);
+       result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
+                    request, 0x40, address, 0, transfer_buffer, length, 3000);
+       kfree(transfer_buffer);
        return result;
 }
+EXPORT_SYMBOL_GPL(ezusb_writememory);
 
-int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit)
+int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit)
 {
        int response;
 
        /* dbg("%s - %d", __func__, reset_bit); */
-       response = ezusb_writememory (serial, CPUCS_REG, &reset_bit, 1, 0xa0);
+       response = ezusb_writememory(serial, CPUCS_REG, &reset_bit, 1, 0xa0);
        if (response < 0)
-               dev_err(&serial->dev->dev, "%s- %d failed\n", __func__, reset_bit);
+               dev_err(&serial->dev->dev, "%s- %d failed\n",
+                                               __func__, reset_bit);
        return response;
 }
-
-
-EXPORT_SYMBOL_GPL(ezusb_writememory);
 EXPORT_SYMBOL_GPL(ezusb_set_reset);
 
index 0ff4a39..8387172 100644 (file)
@@ -12,7 +12,8 @@
  *     the Free Software Foundation; either version 2 of the License, or
  *     (at your option) any later version.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  *
  * See http://ftdi-usb-sio.sourceforge.net for upto date testing info
  *     and extra documentation
@@ -25,7 +26,8 @@
 /* Bill Ryder - bryder@sgi.com - wrote the FTDI_SIO implementation */
 /* Thanx to FTDI for so kindly providing details of the protocol required */
 /*   to talk to the device */
-/* Thanx to gkh and the rest of the usb dev group for all code I have assimilated :-) */
+/* Thanx to gkh and the rest of the usb dev group for all code I have
+   assimilated :-) */
 
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -36,7 +38,7 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/serial.h>
 #include <linux/usb/serial.h>
@@ -55,17 +57,22 @@ static __u16 product;
 
 struct ftdi_private {
        ftdi_chip_type_t chip_type;
-                               /* type of the device, either SIO or FT8U232AM */
+                               /* type of device, either SIO or FT8U232AM */
        int baud_base;          /* baud base clock for divisor setting */
-       int custom_divisor;     /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */
+       int custom_divisor;     /* custom_divisor kludge, this is for
+                                  baud_base (different from what goes to the
+                                  chip!) */
        __u16 last_set_data_urb_value ;
-                               /* the last data state set - needed for doing a break */
-        int write_offset;       /* This is the offset in the usb data block to write the serial data -
-                                * it is different between devices
+                               /* the last data state set - needed for doing
+                                * a break
+                                */
+       int write_offset;       /* This is the offset in the usb data block to
+                                * write the serial data - it varies between
+                                * devices
                                 */
        int flags;              /* some ASYNC_xxxx flags are supported */
        unsigned long last_dtr_rts;     /* saved modem control outputs */
-        wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
+       wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
        char prev_status, diff_status;        /* Used for TIOCMIWAIT */
        __u8 rx_flags;          /* receive state flags (throttling) */
        spinlock_t rx_lock;     /* spinlock for receive state */
@@ -76,8 +83,10 @@ struct ftdi_private {
 
        __u16 interface;        /* FT2232C port interface (0 for FT232/245) */
 
-       speed_t force_baud;     /* if non-zero, force the baud rate to this value */
-       int force_rtscts;       /* if non-zero, force RTS-CTS to always be enabled */
+       speed_t force_baud;     /* if non-zero, force the baud rate to
+                                  this value */
+       int force_rtscts;       /* if non-zero, force RTS-CTS to always
+                                  be enabled */
 
        spinlock_t tx_lock;     /* spinlock for transmit state */
        unsigned long tx_bytes;
@@ -88,13 +97,14 @@ struct ftdi_private {
 /* struct ftdi_sio_quirk is used by devices requiring special attention. */
 struct ftdi_sio_quirk {
        int (*probe)(struct usb_serial *);
-       void (*port_probe)(struct ftdi_private *); /* Special settings for probed ports. */
+       /* Special settings for probed ports. */
+       void (*port_probe)(struct ftdi_private *);
 };
 
-static int   ftdi_jtag_probe           (struct usb_serial *serial);
-static int   ftdi_mtxorb_hack_setup    (struct usb_serial *serial);
-static void  ftdi_USB_UIRT_setup       (struct ftdi_private *priv);
-static void  ftdi_HE_TIRA1_setup       (struct ftdi_private *priv);
+static int   ftdi_jtag_probe(struct usb_serial *serial);
+static int   ftdi_mtxorb_hack_setup(struct usb_serial *serial);
+static void  ftdi_USB_UIRT_setup(struct ftdi_private *priv);
+static void  ftdi_HE_TIRA1_setup(struct ftdi_private *priv);
 
 static struct ftdi_sio_quirk ftdi_jtag_quirk = {
        .probe  = ftdi_jtag_probe,
@@ -174,270 +184,270 @@ static struct usb_device_id id_table_combined [] = {
        { USB_DEVICE(FTDI_VID, FTDI_MTXORB_4_PID) },
        { USB_DEVICE(FTDI_VID, FTDI_MTXORB_5_PID) },
        { USB_DEVICE(FTDI_VID, FTDI_MTXORB_6_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0100_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0101_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0102_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0103_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0104_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0105_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0106_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0107_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0108_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0109_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010A_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010B_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010C_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010D_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010E_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_010F_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0110_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0111_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0112_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0113_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0114_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0115_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0116_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0117_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0118_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0119_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011A_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011B_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011C_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011D_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011E_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_011F_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0120_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0121_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0122_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0123_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0124_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0125_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0126_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0127_PID),
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0100_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0101_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0102_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0103_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0104_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0105_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0106_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0107_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0108_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0109_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010A_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010B_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010C_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010D_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010E_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_010F_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0110_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0111_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0112_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0113_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0114_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0115_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0116_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0117_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0118_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0119_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011A_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011B_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011C_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011D_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011E_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_011F_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0120_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0121_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0122_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0123_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0124_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0125_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0126_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0127_PID),
                .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0128_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0129_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012A_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012B_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012C_PID),
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0128_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0129_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012A_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012B_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012C_PID),
                .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012D_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012E_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_012F_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0130_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0131_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0132_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0133_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0134_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0135_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0136_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0137_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0138_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0139_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013A_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013B_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013C_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013D_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013E_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_013F_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0140_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0141_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0142_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0143_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0144_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0145_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0146_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0147_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0148_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0149_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014A_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014B_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014C_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014D_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014E_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_014F_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0150_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0151_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0152_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0153_PID),
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012D_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012E_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_012F_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0130_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0131_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0132_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0133_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0134_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0135_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0136_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0137_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0138_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0139_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013A_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013B_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013C_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013D_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013E_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_013F_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0140_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0141_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0142_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0143_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0144_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0145_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0146_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0147_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0148_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0149_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014A_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014B_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014C_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014D_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014E_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_014F_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0150_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0151_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0152_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0153_PID),
                .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0154_PID),
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0154_PID),
                .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0155_PID),
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0155_PID),
                .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0156_PID),
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0156_PID),
                .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0157_PID),
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0157_PID),
                .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0158_PID),
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0158_PID),
                .driver_info = (kernel_ulong_t)&ftdi_mtxorb_hack_quirk },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0159_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015A_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015B_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015C_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015D_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015E_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_015F_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0160_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0161_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0162_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0163_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0164_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0165_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0166_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0167_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0168_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0169_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016A_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016B_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016C_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016D_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016E_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_016F_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0170_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0171_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0172_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0173_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0174_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0175_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0176_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0177_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0178_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0179_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017A_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017B_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017C_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017D_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017E_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_017F_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0180_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0181_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0182_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0183_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0184_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0185_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0186_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0187_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0188_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0189_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018A_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018B_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018C_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018D_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018E_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_018F_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0190_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0191_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0192_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0193_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0194_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0195_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0196_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0197_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0198_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_0199_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019A_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019B_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019C_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019D_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019E_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_019F_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A0_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A1_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A2_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A3_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A4_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A5_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A6_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A7_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A8_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01A9_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AA_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AB_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AC_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AD_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AE_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01AF_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B0_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B1_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B2_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B3_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B4_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B5_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B6_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B7_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B8_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01B9_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BA_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BB_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BC_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BD_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BE_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01BF_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C0_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C1_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C2_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C3_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C4_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C5_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C6_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C7_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C8_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01C9_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CA_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CB_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CC_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CD_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CE_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01CF_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D0_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D1_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D2_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D3_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D4_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D5_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D6_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D7_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D8_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01D9_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DA_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DB_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DC_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DD_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DE_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01DF_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E0_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E1_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E2_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E3_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E4_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E5_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E6_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E7_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E8_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01E9_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EA_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EB_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EC_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01ED_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EE_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01EF_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F0_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F1_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F2_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F3_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F4_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F5_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F6_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F7_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F8_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01F9_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FA_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FB_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FC_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FD_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FE_PID) },
-       { USB_DEVICE(MTXORB_VID,MTXORB_FTDI_RANGE_01FF_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0159_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015A_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015B_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015C_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015D_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015E_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_015F_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0160_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0161_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0162_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0163_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0164_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0165_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0166_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0167_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0168_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0169_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016A_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016B_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016C_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016D_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016E_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_016F_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0170_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0171_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0172_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0173_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0174_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0175_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0176_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0177_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0178_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0179_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017A_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017B_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017C_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017D_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017E_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_017F_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0180_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0181_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0182_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0183_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0184_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0185_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0186_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0187_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0188_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0189_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018A_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018B_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018C_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018D_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018E_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_018F_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0190_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0191_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0192_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0193_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0194_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0195_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0196_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0197_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0198_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_0199_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019A_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019B_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019C_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019D_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019E_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_019F_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A0_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A1_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A2_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A3_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A4_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A5_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A6_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A7_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A8_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01A9_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AA_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AB_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AC_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AD_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AE_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01AF_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B0_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B1_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B2_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B3_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B4_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B5_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B6_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B7_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B8_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01B9_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BA_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BB_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BC_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BD_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BE_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01BF_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C0_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C1_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C2_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C3_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C4_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C5_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C6_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C7_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C8_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01C9_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CA_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CB_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CC_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CD_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CE_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01CF_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D0_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D1_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D2_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D3_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D4_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D5_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D6_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D7_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D8_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01D9_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DA_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DB_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DC_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DD_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DE_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01DF_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E0_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E1_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E2_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E3_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E4_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E5_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E6_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E7_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E8_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01E9_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EA_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EB_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EC_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01ED_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EE_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01EF_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F0_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F1_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F2_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F3_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F4_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F5_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F6_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F7_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F8_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01F9_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FA_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FB_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FC_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FD_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FE_PID) },
+       { USB_DEVICE(MTXORB_VID, MTXORB_FTDI_RANGE_01FF_PID) },
        { USB_DEVICE(FTDI_VID, FTDI_PERLE_ULTRAPORT_PID) },
        { USB_DEVICE(FTDI_VID, FTDI_PIEGROUP_PID) },
        { USB_DEVICE(FTDI_VID, FTDI_TNC_X_PID) },
@@ -642,7 +652,7 @@ static struct usb_device_id id_table_combined [] = {
        { }                                     /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table_combined);
+MODULE_DEVICE_TABLE(usb, id_table_combined);
 
 static struct usb_driver ftdi_driver = {
        .name =         "ftdi_sio",
@@ -678,30 +688,37 @@ static const char *ftdi_chip_name[] = {
  | ASYNC_SPD_CUST | ASYNC_SPD_SHI | ASYNC_SPD_WARP)
 
 /* function prototypes for a FTDI serial converter */
-static int  ftdi_sio_probe     (struct usb_serial *serial, const struct usb_device_id *id);
-static void ftdi_shutdown              (struct usb_serial *serial);
-static int  ftdi_sio_port_probe        (struct usb_serial_port *port);
-static int  ftdi_sio_port_remove       (struct usb_serial_port *port);
-static int  ftdi_open                  (struct usb_serial_port *port, struct file *filp);
-static void ftdi_close                 (struct usb_serial_port *port, struct file *filp);
-static int  ftdi_write                 (struct usb_serial_port *port, const unsigned char *buf, int count);
-static int  ftdi_write_room            (struct usb_serial_port *port);
-static int  ftdi_chars_in_buffer       (struct usb_serial_port *port);
-static void ftdi_write_bulk_callback   (struct urb *urb);
-static void ftdi_read_bulk_callback    (struct urb *urb);
-static void ftdi_process_read          (struct work_struct *work);
-static void ftdi_set_termios           (struct usb_serial_port *port, struct ktermios * old);
-static int  ftdi_tiocmget               (struct usb_serial_port *port, struct file *file);
-static int  ftdi_tiocmset              (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear);
-static int  ftdi_ioctl                 (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
-static void ftdi_break_ctl             (struct usb_serial_port *port, int break_state );
-static void ftdi_throttle              (struct usb_serial_port *port);
-static void ftdi_unthrottle            (struct usb_serial_port *port);
-
-static unsigned short int ftdi_232am_baud_base_to_divisor (int baud, int base);
-static unsigned short int ftdi_232am_baud_to_divisor (int baud);
-static __u32 ftdi_232bm_baud_base_to_divisor (int baud, int base);
-static __u32 ftdi_232bm_baud_to_divisor (int baud);
+static int  ftdi_sio_probe(struct usb_serial *serial,
+                                       const struct usb_device_id *id);
+static void ftdi_shutdown(struct usb_serial *serial);
+static int  ftdi_sio_port_probe(struct usb_serial_port *port);
+static int  ftdi_sio_port_remove(struct usb_serial_port *port);
+static int  ftdi_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void ftdi_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static int  ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
+                       const unsigned char *buf, int count);
+static int  ftdi_write_room(struct tty_struct *tty);
+static int  ftdi_chars_in_buffer(struct tty_struct *tty);
+static void ftdi_write_bulk_callback(struct urb *urb);
+static void ftdi_read_bulk_callback(struct urb *urb);
+static void ftdi_process_read(struct work_struct *work);
+static void ftdi_set_termios(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct ktermios *old);
+static int  ftdi_tiocmget(struct tty_struct *tty, struct file *file);
+static int  ftdi_tiocmset(struct tty_struct *tty, struct file *file,
+                       unsigned int set, unsigned int clear);
+static int  ftdi_ioctl(struct tty_struct *tty, struct file *file,
+                       unsigned int cmd, unsigned long arg);
+static void ftdi_break_ctl(struct tty_struct *tty, int break_state);
+static void ftdi_throttle(struct tty_struct *tty);
+static void ftdi_unthrottle(struct tty_struct *tty);
+
+static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base);
+static unsigned short int ftdi_232am_baud_to_divisor(int baud);
+static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base);
+static __u32 ftdi_232bm_baud_to_divisor(int baud);
 
 static struct usb_serial_driver ftdi_sio_device = {
        .driver = {
@@ -752,44 +769,54 @@ static struct usb_serial_driver ftdi_sio_device = {
 static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base)
 {
        unsigned short int divisor;
-       int divisor3 = base / 2 / baud; // divisor shifted 3 bits to the left
-       if ((divisor3 & 0x7) == 7) divisor3 ++; // round x.7/8 up to x+1
+       /* divisor shifted 3 bits to the left */
+       int divisor3 = base / 2 / baud;
+       if ((divisor3 & 0x7) == 7)
+               divisor3++; /* round x.7/8 up to x+1 */
        divisor = divisor3 >> 3;
        divisor3 &= 0x7;
-       if (divisor3 == 1) divisor |= 0xc000; else // 0.125
-       if (divisor3 >= 4) divisor |= 0x4000; else // 0.5
-       if (divisor3 != 0) divisor |= 0x8000;      // 0.25
-       if (divisor == 1) divisor = 0;  /* special case for maximum baud rate */
+       if (divisor3 == 1)
+               divisor |= 0xc000;
+       else if (divisor3 >= 4)
+               divisor |= 0x4000;
+       else if (divisor3 != 0)
+               divisor |= 0x8000;
+       else if (divisor == 1)
+               divisor = 0;    /* special case for maximum baud rate */
        return divisor;
 }
 
 static unsigned short int ftdi_232am_baud_to_divisor(int baud)
 {
-        return(ftdi_232am_baud_base_to_divisor(baud, 48000000));
+        return ftdi_232am_baud_base_to_divisor(baud, 48000000);
 }
 
 static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base)
 {
        static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 };
        __u32 divisor;
-       int divisor3 = base / 2 / baud; // divisor shifted 3 bits to the left
+       /* divisor shifted 3 bits to the left */
+       int divisor3 = base / 2 / baud;
        divisor = divisor3 >> 3;
        divisor |= (__u32)divfrac[divisor3 & 0x7] << 14;
        /* Deal with special cases for highest baud rates. */
-       if (divisor == 1) divisor = 0; else     // 1.0
-       if (divisor == 0x4001) divisor = 1;     // 1.5
+       if (divisor == 1)
+               divisor = 0;
+       else if (divisor == 0x4001)
+               divisor = 1;
        return divisor;
 }
 
 static __u32 ftdi_232bm_baud_to_divisor(int baud)
 {
-        return(ftdi_232bm_baud_base_to_divisor(baud, 48000000));
+        return ftdi_232bm_baud_base_to_divisor(baud, 48000000);
 }
 
 #define set_mctrl(port, set)           update_mctrl((port), (set), 0)
 #define clear_mctrl(port, clear)       update_mctrl((port), 0, (clear))
 
-static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned int clear)
+static int update_mctrl(struct usb_serial_port *port, unsigned int set,
+                                                       unsigned int clear)
 {
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        char *buf;
@@ -843,42 +870,8 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned
 }
 
 
-static __u32 get_ftdi_divisor(struct usb_serial_port * port);
-
-
-static int change_speed(struct usb_serial_port *port)
-{
-       struct ftdi_private *priv = usb_get_serial_port_data(port);
-       char *buf;
-        __u16 urb_value;
-       __u16 urb_index;
-       __u32 urb_index_value;
-       int rv;
-
-       buf = kmalloc(1, GFP_NOIO);
-       if (!buf)
-               return -ENOMEM;
-
-       urb_index_value = get_ftdi_divisor(port);
-       urb_value = (__u16)urb_index_value;
-       urb_index = (__u16)(urb_index_value >> 16);
-       if (priv->interface) {  /* FT2232C */
-               urb_index = (__u16)((urb_index << 8) | priv->interface);
-       }
-
-       rv = usb_control_msg(port->serial->dev,
-                           usb_sndctrlpipe(port->serial->dev, 0),
-                           FTDI_SIO_SET_BAUDRATE_REQUEST,
-                           FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
-                           urb_value, urb_index,
-                           buf, 0, WDR_SHORT_TIMEOUT);
-
-       kfree(buf);
-       return rv;
-}
-
-
-static __u32 get_ftdi_divisor(struct usb_serial_port * port)
+static __u32 get_ftdi_divisor(struct tty_struct *tty,
+                                               struct usb_serial_port *port)
 { /* get_ftdi_divisor */
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        __u32 div_value = 0;
@@ -886,48 +879,56 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
        int baud;
 
        /*
-        * The logic involved in setting the baudrate can be cleanly split in 3 steps.
-        * Obtaining the actual baud rate is a little tricky since unix traditionally
-        * somehow ignored the possibility to set non-standard baud rates.
+        * The logic involved in setting the baudrate can be cleanly split into
+        * 3 steps.
         * 1. Standard baud rates are set in tty->termios->c_cflag
-        * 2. If these are not enough, you can set any speed using alt_speed as follows:
+        * 2. If these are not enough, you can set any speed using alt_speed as
+        * follows:
         *    - set tty->termios->c_cflag speed to B38400
         *    - set your real speed in tty->alt_speed; it gets ignored when
         *      alt_speed==0, (or)
-        *    - call TIOCSSERIAL ioctl with (struct serial_struct) set as follows:
-        *      flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP], this just
-        *      sets alt_speed to (HI: 57600, VHI: 115200, SHI: 230400, WARP: 460800)
+        *    - call TIOCSSERIAL ioctl with (struct serial_struct) set as
+        *      follows:
+        *      flags & ASYNC_SPD_MASK == ASYNC_SPD_[HI, VHI, SHI, WARP],
+        *      this just sets alt_speed to (HI: 57600, VHI: 115200,
+        *      SHI: 230400, WARP: 460800)
         * ** Steps 1, 2 are done courtesy of tty_get_baud_rate
         * 3. You can also set baud rate by setting custom divisor as follows
         *    - set tty->termios->c_cflag speed to B38400
-        *    - call TIOCSSERIAL ioctl with (struct serial_struct) set as follows:
+        *    - call TIOCSSERIAL ioctl with (struct serial_struct) set as
+        *      follows:
         *      o flags & ASYNC_SPD_MASK == ASYNC_SPD_CUST
         *      o custom_divisor set to baud_base / your_new_baudrate
-        * ** Step 3 is done courtesy of code borrowed from serial.c - I should really
-        *    spend some time and separate+move this common code to serial.c, it is
-        *    replicated in nearly every serial driver you see.
+        * ** Step 3 is done courtesy of code borrowed from serial.c
+        *    I should really spend some time and separate + move this common
+        *    code to serial.c, it is replicated in nearly every serial driver
+        *    you see.
         */
 
-       /* 1. Get the baud rate from the tty settings, this observes alt_speed hack */
+       /* 1. Get the baud rate from the tty settings, this observes
+             alt_speed hack */
 
-       baud = tty_get_baud_rate(port->tty);
+       baud = tty_get_baud_rate(tty);
        dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud);
 
-       /* 2. Observe async-compatible custom_divisor hack, update baudrate if needed */
+       /* 2. Observe async-compatible custom_divisor hack, update baudrate
+          if needed */
 
        if (baud == 38400 &&
            ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
             (priv->custom_divisor)) {
                baud = priv->baud_base / priv->custom_divisor;
-               dbg("%s - custom divisor %d sets baud rate to %d", __func__, priv->custom_divisor, baud);
+               dbg("%s - custom divisor %d sets baud rate to %d",
+                               __func__, priv->custom_divisor, baud);
        }
 
        /* 3. Convert baudrate to device-specific divisor */
 
-       if (!baud) baud = 9600;
-       switch(priv->chip_type) {
+       if (!baud)
+               baud = 9600;
+       switch (priv->chip_type) {
        case SIO: /* SIO chip */
-               switch(baud) {
+               switch (baud) {
                case 300: div_value = ftdi_sio_b300; break;
                case 600: div_value = ftdi_sio_b600; break;
                case 1200: div_value = ftdi_sio_b1200; break;
@@ -940,7 +941,8 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
                case 115200: div_value = ftdi_sio_b115200; break;
                } /* baud */
                if (div_value == 0) {
-                       dbg("%s - Baudrate (%d) requested is not supported", __func__,  baud);
+                       dbg("%s - Baudrate (%d) requested is not supported",
+                                                       __func__,  baud);
                        div_value = ftdi_sio_b9600;
                        baud = 9600;
                        div_okay = 0;
@@ -950,7 +952,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
                if (baud <= 3000000) {
                        div_value = ftdi_232am_baud_to_divisor(baud);
                } else {
-                       dbg("%s - Baud rate too high!", __func__);
+                       dbg("%s - Baud rate too high!", __func__);
                        baud = 9600;
                        div_value = ftdi_232am_baud_to_divisor(9600);
                        div_okay = 0;
@@ -962,7 +964,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
                if (baud <= 3000000) {
                        div_value = ftdi_232bm_baud_to_divisor(baud);
                } else {
-                       dbg("%s - Baud rate too high!", __func__);
+                       dbg("%s - Baud rate too high!", __func__);
                        div_value = ftdi_232bm_baud_to_divisor(9600);
                        div_okay = 0;
                        baud = 9600;
@@ -976,12 +978,45 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
                        ftdi_chip_name[priv->chip_type]);
        }
 
-       tty_encode_baud_rate(port->tty, baud, baud);
-       return(div_value);
+       tty_encode_baud_rate(tty, baud, baud);
+       return div_value;
+}
+
+static int change_speed(struct tty_struct *tty, struct usb_serial_port *port)
+{
+       struct ftdi_private *priv = usb_get_serial_port_data(port);
+       char *buf;
+       __u16 urb_value;
+       __u16 urb_index;
+       __u32 urb_index_value;
+       int rv;
+
+       buf = kmalloc(1, GFP_NOIO);
+       if (!buf)
+               return -ENOMEM;
+
+       urb_index_value = get_ftdi_divisor(tty, port);
+       urb_value = (__u16)urb_index_value;
+       urb_index = (__u16)(urb_index_value >> 16);
+       if (priv->interface) {  /* FT2232C */
+               urb_index = (__u16)((urb_index << 8) | priv->interface);
+       }
+
+       rv = usb_control_msg(port->serial->dev,
+                           usb_sndctrlpipe(port->serial->dev, 0),
+                           FTDI_SIO_SET_BAUDRATE_REQUEST,
+                           FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE,
+                           urb_value, urb_index,
+                           buf, 0, WDR_SHORT_TIMEOUT);
+
+       kfree(buf);
+       return rv;
 }
 
 
-static int get_serial_info(struct usb_serial_port * port, struct serial_struct __user * retinfo)
+
+static int get_serial_info(struct usb_serial_port *port,
+                               struct serial_struct __user *retinfo)
 {
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        struct serial_struct tmp;
@@ -998,7 +1033,8 @@ static int get_serial_info(struct usb_serial_port * port, struct serial_struct _
 } /* get_serial_info */
 
 
-static int set_serial_info(struct usb_serial_port * port, struct serial_struct __user * newinfo)
+static int set_serial_info(struct tty_struct *tty,
+       struct usb_serial_port *port, struct serial_struct __user *newinfo)
 { /* set_serial_info */
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        struct serial_struct new_serial;
@@ -1006,7 +1042,7 @@ static int set_serial_info(struct usb_serial_port * port, struct serial_struct _
 
        if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
                return -EFAULT;
-       old_priv = * priv;
+       old_priv = *priv;
 
        /* Do error checking and permission checking */
 
@@ -1027,33 +1063,32 @@ static int set_serial_info(struct usb_serial_port * port, struct serial_struct _
        /* Make the changes - these are privileged changes! */
 
        priv->flags = ((priv->flags & ~ASYNC_FLAGS) |
-                      (new_serial.flags & ASYNC_FLAGS));
+                                       (new_serial.flags & ASYNC_FLAGS));
        priv->custom_divisor = new_serial.custom_divisor;
 
-       port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+       tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
 
 check_and_exit:
        if ((old_priv.flags & ASYNC_SPD_MASK) !=
             (priv->flags & ASYNC_SPD_MASK)) {
                if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
-                       port->tty->alt_speed = 57600;
+                       tty->alt_speed = 57600;
                else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
-                       port->tty->alt_speed = 115200;
+                       tty->alt_speed = 115200;
                else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
-                       port->tty->alt_speed = 230400;
+                       tty->alt_speed = 230400;
                else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
-                       port->tty->alt_speed = 460800;
+                       tty->alt_speed = 460800;
                else
-                       port->tty->alt_speed = 0;
+                       tty->alt_speed = 0;
        }
        if (((old_priv.flags & ASYNC_SPD_MASK) !=
             (priv->flags & ASYNC_SPD_MASK)) ||
            (((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
             (old_priv.custom_divisor != priv->custom_divisor))) {
-               change_speed(port);
+               change_speed(tty, port);
        }
-
-       return (0);
+       return 0;
 
 } /* set_serial_info */
 
@@ -1082,11 +1117,10 @@ static void ftdi_determine_type(struct usb_serial_port *port)
                priv->chip_type = FT2232C;
                /* Determine interface code. */
                inter = serial->interface->altsetting->desc.bInterfaceNumber;
-               if (inter == 0) {
+               if (inter == 0)
                        priv->interface = PIT_SIOA;
-               } else {
+               else
                        priv->interface = PIT_SIOB;
-               }
                /* BM-type devices have a bug where bcdDevice gets set
                 * to 0x200 when iSerialNumber is 0.  */
                if (version < 0x500) {
@@ -1120,7 +1154,8 @@ static void ftdi_determine_type(struct usb_serial_port *port)
  * ***************************************************************************
  */
 
-static ssize_t show_latency_timer(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t show_latency_timer(struct device *dev,
+                               struct device_attribute *attr, char *buf)
 {
        struct usb_serial_port *port = to_usb_serial_port(dev);
        struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1129,14 +1164,14 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a
        int rv = 0;
 
 
-       dbg("%s",__func__);
+       dbg("%s", __func__);
 
        rv = usb_control_msg(udev,
                             usb_rcvctrlpipe(udev, 0),
                             FTDI_SIO_GET_LATENCY_TIMER_REQUEST,
                             FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
                             0, priv->interface,
-                            (char*) &latency, 1, WDR_TIMEOUT);
+                            (char *) &latency, 1, WDR_TIMEOUT);
 
        if (rv < 0) {
                dev_err(dev, "Unable to read latency timer: %i\n", rv);
@@ -1146,8 +1181,9 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a
 }
 
 /* Write a new value of the latency timer, in units of milliseconds. */
-static ssize_t store_latency_timer(struct device *dev, struct device_attribute *attr, const char *valbuf,
-                                  size_t count)
+static ssize_t store_latency_timer(struct device *dev,
+                       struct device_attribute *attr, const char *valbuf,
+                       size_t count)
 {
        struct usb_serial_port *port = to_usb_serial_port(dev);
        struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1175,8 +1211,8 @@ static ssize_t store_latency_timer(struct device *dev, struct device_attribute *
 
 /* Write an event character directly to the FTDI register.  The ASCII
    value is in the low 8 bits, with the enable bit in the 9th bit. */
-static ssize_t store_event_char(struct device *dev, struct device_attribute *attr, const char *valbuf,
-                               size_t count)
+static ssize_t store_event_char(struct device *dev,
+       struct device_attribute *attr, const char *valbuf, size_t count)
 {
        struct usb_serial_port *port = to_usb_serial_port(dev);
        struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1202,7 +1238,8 @@ static ssize_t store_event_char(struct device *dev, struct device_attribute *att
        return count;
 }
 
-static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer, store_latency_timer);
+static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer,
+                                                       store_latency_timer);
 static DEVICE_ATTR(event_char, S_IWUSR, NULL, store_event_char);
 
 static int create_sysfs_attrs(struct usb_serial_port *port)
@@ -1210,7 +1247,7 @@ static int create_sysfs_attrs(struct usb_serial_port *port)
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        int retval = 0;
 
-       dbg("%s",__func__);
+       dbg("%s", __func__);
 
        /* XXX I've no idea if the original SIO supports the event_char
         * sysfs parameter, so I'm playing it safe.  */
@@ -1232,7 +1269,7 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)
 {
        struct ftdi_private *priv = usb_get_serial_port_data(port);
 
-       dbg("%s",__func__);
+       dbg("%s", __func__);
 
        /* XXX see create_sysfs_attrs */
        if (priv->chip_type != SIO) {
@@ -1253,9 +1290,11 @@ static void remove_sysfs_attrs(struct usb_serial_port *port)
  */
 
 /* Probe function to check for special devices */
-static int ftdi_sio_probe (struct usb_serial *serial, const struct usb_device_id *id)
+static int ftdi_sio_probe(struct usb_serial *serial,
+                                       const struct usb_device_id *id)
 {
-       struct ftdi_sio_quirk *quirk = (struct ftdi_sio_quirk *)id->driver_info;
+       struct ftdi_sio_quirk *quirk =
+                               (struct ftdi_sio_quirk *)id->driver_info;
 
        if (quirk && quirk->probe) {
                int ret = quirk->probe(serial);
@@ -1274,17 +1313,18 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
        struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial);
 
 
-       dbg("%s",__func__);
+       dbg("%s", __func__);
 
        priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL);
-       if (!priv){
-               err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct ftdi_private));
+       if (!priv) {
+               err("%s- kmalloc(%Zd) failed.", __func__,
+                                       sizeof(struct ftdi_private));
                return -ENOMEM;
        }
 
        spin_lock_init(&priv->rx_lock);
        spin_lock_init(&priv->tx_lock);
-        init_waitqueue_head(&priv->delta_msr_wait);
+       init_waitqueue_head(&priv->delta_msr_wait);
        /* This will push the characters through immediately rather
           than queue a task to deliver them */
        priv->flags = ASYNC_LOW_LATENCY;
@@ -1294,9 +1334,9 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
 
        /* Increase the size of read buffers */
        kfree(port->bulk_in_buffer);
-       port->bulk_in_buffer = kmalloc (BUFSZ, GFP_KERNEL);
+       port->bulk_in_buffer = kmalloc(BUFSZ, GFP_KERNEL);
        if (!port->bulk_in_buffer) {
-               kfree (priv);
+               kfree(priv);
                return -ENOMEM;
        }
        if (port->read_urb) {
@@ -1309,7 +1349,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
 
        /* Free port's existing write urb and transfer buffer. */
        if (port->write_urb) {
-               usb_free_urb (port->write_urb);
+               usb_free_urb(port->write_urb);
                port->write_urb = NULL;
        }
        kfree(port->bulk_out_buffer);
@@ -1317,7 +1357,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
 
        usb_set_serial_port_data(port, priv);
 
-       ftdi_determine_type (port);
+       ftdi_determine_type(port);
        create_sysfs_attrs(port);
        return 0;
 }
@@ -1325,9 +1365,9 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
 /* Setup for the USB-UIRT device, which requires hardwired
  * baudrate (38400 gets mapped to 312500) */
 /* Called from usbserial:serial_probe */
-static void ftdi_USB_UIRT_setup (struct ftdi_private *priv)
+static void ftdi_USB_UIRT_setup(struct ftdi_private *priv)
 {
-       dbg("%s",__func__);
+       dbg("%s", __func__);
 
        priv->flags |= ASYNC_SPD_CUST;
        priv->custom_divisor = 77;
@@ -1336,9 +1376,10 @@ static void ftdi_USB_UIRT_setup (struct ftdi_private *priv)
 
 /* Setup for the HE-TIRA1 device, which requires hardwired
  * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled.  */
-static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv)
+
+static void ftdi_HE_TIRA1_setup(struct ftdi_private *priv)
 {
-       dbg("%s",__func__);
+       dbg("%s", __func__);
 
        priv->flags |= ASYNC_SPD_CUST;
        priv->custom_divisor = 240;
@@ -1356,7 +1397,7 @@ static int ftdi_jtag_probe(struct usb_serial *serial)
        struct usb_device *udev = serial->dev;
        struct usb_interface *interface = serial->interface;
 
-       dbg("%s",__func__);
+       dbg("%s", __func__);
 
        if (interface == udev->actconfig->interface[0]) {
                info("Ignoring serial port reserved for JTAG");
@@ -1390,7 +1431,7 @@ static int ftdi_mtxorb_hack_setup(struct usb_serial *serial)
  *      calls __serial_close for each open of the port
  *      shutdown is called then (ie ftdi_shutdown)
  */
-static void ftdi_shutdown (struct usb_serial *serial)
+static void ftdi_shutdown(struct usb_serial *serial)
 {
        dbg("%s", __func__);
 }
@@ -1404,7 +1445,7 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
        remove_sysfs_attrs(port);
 
        /* all open ports are closed at this point
-         *    (by usbserial.c:__serial_close, which calls ftdi_close)
+        *    (by usbserial.c:__serial_close, which calls ftdi_close)
         */
 
        if (priv) {
@@ -1415,7 +1456,8 @@ static int ftdi_sio_port_remove(struct usb_serial_port *port)
        return 0;
 }
 
-static int  ftdi_open (struct usb_serial_port *port, struct file *filp)
+static int ftdi_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 { /* ftdi_open */
        struct usb_device *dev = port->serial->dev;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1433,8 +1475,8 @@ static int  ftdi_open (struct usb_serial_port *port, struct file *filp)
        priv->rx_bytes = 0;
        spin_unlock_irqrestore(&priv->rx_lock, flags);
 
-       if (port->tty)
-               port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+       if (tty)
+               tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
 
        /* No error checking for this (will get errors later anyway) */
        /* See ftdi_sio.h for description of what is reset */
@@ -1448,8 +1490,8 @@ static int  ftdi_open (struct usb_serial_port *port, struct file *filp)
           This is same behaviour as serial.c/rs_open() - Kuba */
 
        /* ftdi_set_termios  will send usb control messages */
-       if (port->tty)
-               ftdi_set_termios(port, port->tty->termios);
+       if (tty)
+               ftdi_set_termios(tty, port, tty->termios);
 
        /* FIXME: Flow control might be enabled, so it should be checked -
           we have no control of defaults! */
@@ -1464,12 +1506,14 @@ static int  ftdi_open (struct usb_serial_port *port, struct file *filp)
        /* Start reading from the device */
        priv->rx_processed = 0;
        usb_fill_bulk_urb(port->read_urb, dev,
-                     usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress),
-                     port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
-                     ftdi_read_bulk_callback, port);
+                       usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress),
+                       port->read_urb->transfer_buffer,
+                               port->read_urb->transfer_buffer_length,
+                       ftdi_read_bulk_callback, port);
        result = usb_submit_urb(port->read_urb, GFP_KERNEL);
        if (result)
-               err("%s - failed submitting read urb, error %d", __func__, result);
+               err("%s - failed submitting read urb, error %d",
+                                                       __func__, result);
 
 
        return result;
@@ -1485,16 +1529,17 @@ static int  ftdi_open (struct usb_serial_port *port, struct file *filp)
  *
  */
 
-static void ftdi_close (struct usb_serial_port *port, struct file *filp)
+static void ftdi_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 { /* ftdi_close */
-       unsigned int c_cflag = port->tty->termios->c_cflag;
+       unsigned int c_cflag = tty->termios->c_cflag;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        char buf[1];
 
        dbg("%s", __func__);
 
        mutex_lock(&port->serial->disc_mutex);
-       if (c_cflag & HUPCL && !port->serial->disconnected){
+       if (c_cflag & HUPCL && !port->serial->disconnected) {
                /* Disable flow control */
                if (usb_control_msg(port->serial->dev,
                                    usb_sndctrlpipe(port->serial->dev, 0),
@@ -1527,7 +1572,7 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
  *
  * The new devices do not require this byte
  */
-static int ftdi_write (struct usb_serial_port *port,
+static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
                           const unsigned char *buf, int count)
 { /* ftdi_write */
        struct ftdi_private *priv = usb_get_serial_port_data(port);
@@ -1554,7 +1599,7 @@ static int ftdi_write (struct usb_serial_port *port,
        spin_unlock_irqrestore(&priv->tx_lock, flags);
 
        data_offset = priv->write_offset;
-        dbg("data_offset set to %d",data_offset);
+       dbg("data_offset set to %d", data_offset);
 
        /* Determine total transfer size */
        transfer_size = count;
@@ -1565,7 +1610,7 @@ static int ftdi_write (struct usb_serial_port *port,
                                 (PKTSZ - data_offset)));
        }
 
-       buffer = kmalloc (transfer_size, GFP_ATOMIC);
+       buffer = kmalloc(transfer_size, GFP_ATOMIC);
        if (!buffer) {
                err("%s ran out of kernel memory for urb ...", __func__);
                count = -ENOMEM;
@@ -1581,20 +1626,20 @@ static int ftdi_write (struct usb_serial_port *port,
 
        /* Copy data */
        if (data_offset > 0) {
-               /* Original sio requires control byte at start of each packet. */
+               /* Original sio requires control byte at start of
+                  each packet. */
                int user_pktsz = PKTSZ - data_offset;
                int todo = count;
                unsigned char *first_byte = buffer;
                const unsigned char *current_position = buf;
 
                while (todo > 0) {
-                       if (user_pktsz > todo) {
+                       if (user_pktsz > todo)
                                user_pktsz = todo;
-                       }
                        /* Write the control byte at the front of the packet*/
                        *first_byte = 1 | ((user_pktsz) << 2);
                        /* Copy data for packet */
-                       memcpy (first_byte + data_offset,
+                       memcpy(first_byte + data_offset,
                                current_position, user_pktsz);
                        first_byte += user_pktsz + data_offset;
                        current_position += user_pktsz;
@@ -1603,20 +1648,23 @@ static int ftdi_write (struct usb_serial_port *port,
        } else {
                /* No control byte required. */
                /* Copy in the data to send */
-               memcpy (buffer, buf, count);
+               memcpy(buffer, buf, count);
        }
 
-       usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, buffer);
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                               transfer_size, buffer);
 
        /* fill the buffer and send it */
        usb_fill_bulk_urb(urb, port->serial->dev,
-                     usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress),
-                     buffer, transfer_size,
-                     ftdi_write_bulk_callback, port);
+                       usb_sndbulkpipe(port->serial->dev,
+                                       port->bulk_out_endpointAddress),
+                       buffer, transfer_size,
+                       ftdi_write_bulk_callback, port);
 
        status = usb_submit_urb(urb, GFP_ATOMIC);
        if (status) {
-               err("%s - failed submitting write urb, error %d", __func__, status);
+               err("%s - failed submitting write urb, error %d",
+                                                       __func__, status);
                count = status;
                goto error;
        } else {
@@ -1635,7 +1683,7 @@ static int ftdi_write (struct usb_serial_port *port,
 error:
        usb_free_urb(urb);
 error_no_urb:
-       kfree (buffer);
+       kfree(buffer);
 error_no_buffer:
        spin_lock_irqsave(&priv->tx_lock, flags);
        priv->tx_outstanding_urbs--;
@@ -1646,7 +1694,7 @@ error_no_buffer:
 
 /* This function may get called when the device is closed */
 
-static void ftdi_write_bulk_callback (struct urb *urb)
+static void ftdi_write_bulk_callback(struct urb *urb)
 {
        unsigned long flags;
        struct usb_serial_port *port = urb->context;
@@ -1656,7 +1704,7 @@ static void ftdi_write_bulk_callback (struct urb *urb)
        int status = urb->status;
 
        /* free up the transfer buffer, as usb_free_urb() does not do this */
-       kfree (urb->transfer_buffer);
+       kfree(urb->transfer_buffer);
 
        dbg("%s - port %d", __func__, port->number);
 
@@ -1686,8 +1734,9 @@ static void ftdi_write_bulk_callback (struct urb *urb)
 } /* ftdi_write_bulk_callback */
 
 
-static int ftdi_write_room( struct usb_serial_port *port )
+static int ftdi_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        int room;
        unsigned long flags;
@@ -1707,11 +1756,11 @@ static int ftdi_write_room( struct usb_serial_port *port )
        }
        spin_unlock_irqrestore(&priv->tx_lock, flags);
        return room;
-} /* ftdi_write_room */
-
+}
 
-static int ftdi_chars_in_buffer (struct usb_serial_port *port)
-{ /* ftdi_chars_in_buffer */
+static int ftdi_chars_in_buffer(struct tty_struct *tty)
+{
+       struct usb_serial_port *port = tty->driver_data;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        int buffered;
        unsigned long flags;
@@ -1726,12 +1775,10 @@ static int ftdi_chars_in_buffer (struct usb_serial_port *port)
                buffered = 0;
        }
        return buffered;
-} /* ftdi_chars_in_buffer */
-
-
+}
 
-static void ftdi_read_bulk_callback (struct urb *urb)
-{ /* ftdi_read_bulk_callback */
+static void ftdi_read_bulk_callback(struct urb *urb)
+{
        struct usb_serial_port *port = urb->context;
        struct tty_struct *tty;
        struct ftdi_private *priv;
@@ -1740,19 +1787,21 @@ static void ftdi_read_bulk_callback (struct urb *urb)
        int status = urb->status;
 
        if (urb->number_of_packets > 0) {
-               err("%s transfer_buffer_length %d actual_length %d number of packets %d",__func__,
-                   urb->transfer_buffer_length, urb->actual_length, urb->number_of_packets );
-               err("%s transfer_flags %x ", __func__,urb->transfer_flags );
+               err("%s transfer_buffer_length %d actual_length %d number of packets %d",
+                               __func__,
+                               urb->transfer_buffer_length,
+                               urb->actual_length, urb->number_of_packets);
+               err("%s transfer_flags %x ", __func__, urb->transfer_flags);
        }
 
        dbg("%s - port %d", __func__, port->number);
 
-       if (port->open_count <= 0)
+       if (port->port.count <= 0)
                return;
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (!tty) {
-               dbg("%s - bad tty pointer - exiting",__func__);
+               dbg("%s - bad tty pointer - exiting", __func__);
                return;
        }
 
@@ -1762,14 +1811,13 @@ static void ftdi_read_bulk_callback (struct urb *urb)
                return;
        }
 
-       if (urb != port->read_urb) {
+       if (urb != port->read_urb)
                err("%s - Not my urb!", __func__);
-       }
 
        if (status) {
-               /* This will happen at close every time so it is a dbg not an err */
-               dbg("(this is ok on close) nonzero read bulk status received: "
-                   "%d", status);
+               /* This will happen at close every time so it is a dbg not an
+                  err */
+               dbg("(this is ok on close) nonzero read bulk status received: %d", status);
                return;
        }
 
@@ -1785,7 +1833,7 @@ static void ftdi_read_bulk_callback (struct urb *urb)
 } /* ftdi_read_bulk_callback */
 
 
-static void ftdi_process_read (struct work_struct *work)
+static void ftdi_process_read(struct work_struct *work)
 { /* ftdi_process_read */
        struct ftdi_private *priv =
                container_of(work, struct ftdi_private, rx_work.work);
@@ -1803,12 +1851,12 @@ static void ftdi_process_read (struct work_struct *work)
 
        dbg("%s - port %d", __func__, port->number);
 
-       if (port->open_count <= 0)
+       if (port->port.count <= 0)
                return;
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (!tty) {
-               dbg("%s - bad tty pointer - exiting",__func__);
+               dbg("%s - bad tty pointer - exiting", __func__);
                return;
        }
 
@@ -1832,11 +1880,11 @@ static void ftdi_process_read (struct work_struct *work)
                                urb->actual_length - priv->rx_processed);
        } else {
                /* The first two bytes of every read packet are status */
-               if (urb->actual_length > 2) {
-                       usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
-               } else {
-                       dbg("Status only: %03oo %03oo",data[0],data[1]);
-               }
+               if (urb->actual_length > 2)
+                       usb_serial_debug_data(debug, &port->dev, __func__,
+                                               urb->actual_length, data);
+               else
+                       dbg("Status only: %03oo %03oo", data[0], data[1]);
        }
 
 
@@ -1846,16 +1894,19 @@ static void ftdi_process_read (struct work_struct *work)
        /* if CD is dropped and the line is not CLOCAL then we should hangup */
 
        need_flip = 0;
-       for (packet_offset = priv->rx_processed; packet_offset < urb->actual_length; packet_offset += PKTSZ) {
+       for (packet_offset = priv->rx_processed;
+               packet_offset < urb->actual_length; packet_offset += PKTSZ) {
                int length;
 
-               /* Compare new line status to the old one, signal if different */
-               /* N.B. packet may be processed more than once, but differences
-                * are only processed once.  */
+               /* Compare new line status to the old one, signal if different/
+                  N.B. packet may be processed more than once, but differences
+                  are only processed once.  */
                if (priv != NULL) {
-                       char new_status = data[packet_offset+0] & FTDI_STATUS_B0_MASK;
+                       char new_status = data[packet_offset + 0] &
+                                                       FTDI_STATUS_B0_MASK;
                        if (new_status != priv->prev_status) {
-                               priv->diff_status |= new_status ^ priv->prev_status;
+                               priv->diff_status |=
+                                       new_status ^ priv->prev_status;
                                wake_up_interruptible(&priv->delta_msr_wait);
                                priv->prev_status = new_status;
                        }
@@ -1872,30 +1923,31 @@ static void ftdi_process_read (struct work_struct *work)
                        break;
                }
                if (tty_buffer_request_room(tty, length) < length) {
-                       /* break out & wait for throttling/unthrottling to happen */
+                       /* break out & wait for throttling/unthrottling to
+                          happen */
                        dbg("%s - receive room low", __func__);
                        break;
                }
 
                /* Handle errors and break */
                error_flag = TTY_NORMAL;
-               /* Although the device uses a bitmask and hence can have multiple */
-               /* errors on a packet - the order here sets the priority the */
-               /* error is returned to the tty layer  */
+               /* Although the device uses a bitmask and hence can have
+                  multiple errors on a packet - the order here sets the
+                  priority the error is returned to the tty layer  */
 
-               if ( data[packet_offset+1] & FTDI_RS_OE ) {
+               if (data[packet_offset+1] & FTDI_RS_OE) {
                        error_flag = TTY_OVERRUN;
                        dbg("OVERRRUN error");
                }
-               if ( data[packet_offset+1] & FTDI_RS_BI ) {
+               if (data[packet_offset+1] & FTDI_RS_BI) {
                        error_flag = TTY_BREAK;
                        dbg("BREAK received");
                }
-               if ( data[packet_offset+1] & FTDI_RS_PE ) {
+               if (data[packet_offset+1] & FTDI_RS_PE) {
                        error_flag = TTY_PARITY;
                        dbg("PARITY error");
                }
-               if ( data[packet_offset+1] & FTDI_RS_FE ) {
+               if (data[packet_offset+1] & FTDI_RS_FE) {
                        error_flag = TTY_FRAME;
                        dbg("FRAMING error");
                }
@@ -1904,7 +1956,8 @@ static void ftdi_process_read (struct work_struct *work)
                                /* Note that the error flag is duplicated for
                                   every character received since we don't know
                                   which character it applied to */
-                               tty_insert_flip_char(tty, data[packet_offset+i], error_flag);
+                               tty_insert_flip_char(tty,
+                                       data[packet_offset + i], error_flag);
                        }
                        need_flip = 1;
                }
@@ -1912,19 +1965,19 @@ static void ftdi_process_read (struct work_struct *work)
 #ifdef NOT_CORRECT_BUT_KEEPING_IT_FOR_NOW
                /* if a parity error is detected you get status packets forever
                   until a character is sent without a parity error.
-                  This doesn't work well since the application receives a never
-                  ending stream of bad data - even though new data hasn't been sent.
-                  Therefore I (bill) have taken this out.
+                  This doesn't work well since the application receives a
+                  never ending stream of bad data - even though new data
+                  hasn't been sent. Therefore I (bill) have taken this out.
                   However - this might make sense for framing errors and so on
                   so I am leaving the code in for now.
                */
                else {
-                       if (error_flag != TTY_NORMAL){
+                       if (error_flag != TTY_NORMAL) {
                                dbg("error_flag is not normal");
-                               /* In this case it is just status - if that is an error send a bad character */
-                               if(tty->flip.count >= TTY_FLIPBUF_SIZE) {
+                               /* In this case it is just status - if that is
+                                  an error send a bad character */
+                               if (tty->flip.count >= TTY_FLIPBUF_SIZE)
                                        tty_flip_buffer_push(tty);
-                               }
                                tty_insert_flip_char(tty, 0xff, error_flag);
                                need_flip = 1;
                        }
@@ -1933,9 +1986,8 @@ static void ftdi_process_read (struct work_struct *work)
        } /* "for(packet_offset=0..." */
 
        /* Low latency */
-       if (need_flip) {
+       if (need_flip)
                tty_flip_buffer_push(tty);
-       }
 
        if (packet_offset < urb->actual_length) {
                /* not completely processed - record progress */
@@ -1954,12 +2006,11 @@ static void ftdi_process_read (struct work_struct *work)
                }
                spin_unlock_irqrestore(&priv->rx_lock, flags);
                /* if the port is closed stop trying to read */
-               if (port->open_count > 0){
+               if (port->port.count > 0)
                        /* delay processing of remainder */
                        schedule_delayed_work(&priv->rx_work, 1);
-               } else {
+               else
                        dbg("%s - port is closed", __func__);
-               }
                return;
        }
 
@@ -1967,24 +2018,26 @@ static void ftdi_process_read (struct work_struct *work)
        priv->rx_processed = 0;
 
        /* if the port is closed stop trying to read */
-       if (port->open_count > 0){
+       if (port->port.count > 0) {
                /* Continue trying to always read  */
                usb_fill_bulk_urb(port->read_urb, port->serial->dev,
-                             usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
-                             port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
-                             ftdi_read_bulk_callback, port);
+                       usb_rcvbulkpipe(port->serial->dev,
+                                       port->bulk_in_endpointAddress),
+                       port->read_urb->transfer_buffer,
+                       port->read_urb->transfer_buffer_length,
+                       ftdi_read_bulk_callback, port);
 
                result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
                if (result)
-                       err("%s - failed resubmitting read urb, error %d", __func__, result);
+                       err("%s - failed resubmitting read urb, error %d",
+                                                       __func__, result);
        }
-
-       return;
 } /* ftdi_process_read */
 
 
-static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
+static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        __u16 urb_value = 0;
        char buf[1];
@@ -1993,22 +2046,23 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
        /* see drivers/char/tty_io.c to see it used */
        /* last_set_data_urb_value NEVER has the break bit set in it */
 
-       if (break_state) {
+       if (break_state)
                urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK;
-       } else {
+       else
                urb_value = priv->last_set_data_urb_value;
-       }
 
-
-       if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
-                           FTDI_SIO_SET_DATA_REQUEST,
-                           FTDI_SIO_SET_DATA_REQUEST_TYPE,
-                           urb_value , priv->interface,
-                           buf, 0, WDR_TIMEOUT) < 0) {
-               err("%s FAILED to enable/disable break state (state was %d)", __func__,break_state);
+       if (usb_control_msg(port->serial->dev,
+                       usb_sndctrlpipe(port->serial->dev, 0),
+                       FTDI_SIO_SET_DATA_REQUEST,
+                       FTDI_SIO_SET_DATA_REQUEST_TYPE,
+                       urb_value , priv->interface,
+                       buf, 0, WDR_TIMEOUT) < 0) {
+               err("%s FAILED to enable/disable break state (state was %d)",
+                                                       __func__, break_state);
        }
 
-       dbg("%s break state is %d - urb is %d", __func__,break_state, urb_value);
+       dbg("%s break state is %d - urb is %d", __func__,
+                                               break_state, urb_value);
 
 }
 
@@ -2018,26 +2072,28 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
  * WARNING: set_termios calls this with old_termios in kernel space
  */
 
-static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
+static void ftdi_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 { /* ftdi_termios */
        struct usb_device *dev = port->serial->dev;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
-       struct ktermios *termios = port->tty->termios;
+       struct ktermios *termios = tty->termios;
        unsigned int cflag = termios->c_cflag;
        __u16 urb_value; /* will hold the new flags */
        char buf[1]; /* Perhaps I should dynamically alloc this? */
 
-       // Added for xon/xoff support
+       /* Added for xon/xoff support */
        unsigned int iflag = termios->c_iflag;
        unsigned char vstop;
        unsigned char vstart;
 
        dbg("%s", __func__);
 
-       /* Force baud rate if this device requires it, unless it is set to B0. */
+       /* Force baud rate if this device requires it, unless it is set to
+          B0. */
        if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) {
                dbg("%s: forcing baud rate for this device", __func__);
-               tty_encode_baud_rate(port->tty, priv->force_baud,
+               tty_encode_baud_rate(tty, priv->force_baud,
                                        priv->force_baud);
        }
 
@@ -2053,8 +2109,8 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
           not  - so just do the change regardless  - should be able to
           compare old_termios and tty->termios */
        /* NOTE These routines can get interrupted by
-          ftdi_sio_read_bulk_callback  - need to examine what this
-           means - don't see any problems yet */
+          ftdi_sio_read_bulk_callback  - need to examine what this means -
+          don't see any problems yet */
 
        /* Set number of data bits, parity, stop bits */
 
@@ -2078,8 +2134,8 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
                }
        }
 
-       /* This is needed by the break command since it uses the same command - but is
-         or'ed with this value  */
+       /* This is needed by the break command since it uses the same command
+          - but is or'ed with this value  */
        priv->last_set_data_urb_value = urb_value;
 
        if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
@@ -2091,7 +2147,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
        }
 
        /* Now do the baudrate */
-       if ((cflag & CBAUD) == B0 ) {
+       if ((cflag & CBAUD) == B0) {
                /* Disable flow control */
                if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
                                    FTDI_SIO_SET_FLOW_CTRL_REQUEST,
@@ -2104,13 +2160,11 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
                clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
        } else {
                /* set the baudrate determined before */
-               if (change_speed(port)) {
+               if (change_speed(tty, port))
                        err("%s urb failed to set baudrate", __func__);
-               }
                /* Ensure RTS and DTR are raised when baudrate changed from 0 */
-               if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) {
+               if (!old_termios || (old_termios->c_cflag & CBAUD) == B0)
                        set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
-               }
        }
 
        /* Set flow control */
@@ -2130,18 +2184,22 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
                /*
                 * Xon/Xoff code
                 *
-                * Check the IXOFF status in the iflag component of the termios structure
-                * if IXOFF is not set, the pre-xon/xoff code is executed.
-               */
+                * Check the IXOFF status in the iflag component of the
+                * termios structure. If IXOFF is not set, the pre-xon/xoff
+                * code is executed.
+                */
                if (iflag & IXOFF) {
-                       dbg("%s  request to enable xonxoff iflag=%04x",__func__,iflag);
-                       // Try to enable the XON/XOFF on the ftdi_sio
-                       // Set the vstart and vstop -- could have been done up above where
-                       // a lot of other dereferencing is done but that would be very
-                       // inefficient as vstart and vstop are not always needed
+                       dbg("%s  request to enable xonxoff iflag=%04x",
+                                                       __func__, iflag);
+                       /* Try to enable the XON/XOFF on the ftdi_sio
+                        * Set the vstart and vstop -- could have been done up
+                        * above where a lot of other dereferencing is done but
+                        * that would be very inefficient as vstart and vstop
+                        * are not always needed.
+                        */
                        vstart = termios->c_cc[VSTART];
                        vstop = termios->c_cc[VSTOP];
-                       urb_value=(vstop << 8) | (vstart);
+                       urb_value = (vstop << 8) | (vstart);
 
                        if (usb_control_msg(dev,
                                            usb_sndctrlpipe(dev, 0),
@@ -2153,8 +2211,9 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
                                err("urb failed to set to xon/xoff flow control");
                        }
                } else {
-                       /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */
-                       /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */
+                       /* else clause to only run if cflag ! CRTSCTS and iflag
+                        * ! XOFF. CHECKME Assuming XON/XOFF handled by tty
+                        * stack - not by device */
                        dbg("%s Turning off hardware flow control", __func__);
                        if (usb_control_msg(dev,
                                            usb_sndctrlpipe(dev, 0),
@@ -2168,11 +2227,11 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old
 
        }
        return;
-} /* ftdi_termios */
-
+}
 
-static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
+static int ftdi_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        unsigned char buf[2];
        int ret;
@@ -2181,32 +2240,35 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
        switch (priv->chip_type) {
        case SIO:
                /* Request the status from the device */
-               if ((ret = usb_control_msg(port->serial->dev,
-                                          usb_rcvctrlpipe(port->serial->dev, 0),
-                                          FTDI_SIO_GET_MODEM_STATUS_REQUEST,
-                                          FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
-                                          0, 0,
-                                          buf, 1, WDR_TIMEOUT)) < 0 ) {
+               ret = usb_control_msg(port->serial->dev,
+                          usb_rcvctrlpipe(port->serial->dev, 0),
+                          FTDI_SIO_GET_MODEM_STATUS_REQUEST,
+                          FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
+                          0, 0,
+                          buf, 1, WDR_TIMEOUT);
+               if (ret < 0) {
                        err("%s Could not get modem status of device - err: %d", __func__,
                            ret);
-                       return(ret);
+                       return ret;
                }
                break;
        case FT8U232AM:
        case FT232BM:
        case FT2232C:
        case FT232RL:
-               /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same
-                  format as the data returned from the in point */
-               if ((ret = usb_control_msg(port->serial->dev,
-                                          usb_rcvctrlpipe(port->serial->dev, 0),
-                                          FTDI_SIO_GET_MODEM_STATUS_REQUEST,
-                                          FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
-                                          0, priv->interface,
-                                          buf, 2, WDR_TIMEOUT)) < 0 ) {
+               /* the 8U232AM returns a two byte value (the sio is a 1 byte
+                  value) - in the same format as the data returned from the in
+                  point */
+               ret = usb_control_msg(port->serial->dev,
+                                  usb_rcvctrlpipe(port->serial->dev, 0),
+                                  FTDI_SIO_GET_MODEM_STATUS_REQUEST,
+                                  FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
+                                  0, priv->interface,
+                                  buf, 2, WDR_TIMEOUT);
+               if (ret < 0) {
                        err("%s Could not get modem status of device - err: %d", __func__,
                            ret);
-                       return(ret);
+                       return ret;
                }
                break;
        default:
@@ -2221,15 +2283,19 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
                priv->last_dtr_rts;
 }
 
-static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear)
+static int ftdi_tiocmset(struct tty_struct *tty, struct file *file,
+                       unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        dbg("%s TIOCMSET", __func__);
        return update_mctrl(port, set, clear);
 }
 
 
-static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+static int ftdi_ioctl(struct tty_struct *tty, struct file *file,
+                                       unsigned int cmd, unsigned long arg)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
 
        dbg("%s cmd 0x%04x", __func__, cmd);
@@ -2238,10 +2304,12 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
        switch (cmd) {
 
        case TIOCGSERIAL: /* gets serial port data */
-               return get_serial_info(port, (struct serial_struct __user *) arg);
+               return get_serial_info(port,
+                                       (struct serial_struct __user *) arg);
 
        case TIOCSSERIAL: /* sets serial port data */
-               return set_serial_info(port, (struct serial_struct __user *) arg);
+               return set_serial_info(tty, port,
+                                       (struct serial_struct __user *) arg);
 
        /*
         * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
@@ -2260,45 +2328,41 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
                        else {
                                char diff = priv->diff_status;
 
-                               if (diff == 0) {
+                               if (diff == 0)
                                        return -EIO; /* no change => error */
-                               }
 
                                /* Consume all events */
                                priv->diff_status = 0;
 
-                               /* Return 0 if caller wanted to know about these bits */
-                               if ( ((arg & TIOCM_RNG) && (diff & FTDI_RS0_RI)) ||
-                                    ((arg & TIOCM_DSR) && (diff & FTDI_RS0_DSR)) ||
-                                    ((arg & TIOCM_CD)  && (diff & FTDI_RS0_RLSD)) ||
-                                    ((arg & TIOCM_CTS) && (diff & FTDI_RS0_CTS)) ) {
+                               /* Return 0 if caller wanted to know about
+                                  these bits */
+                               if (((arg & TIOCM_RNG) && (diff & FTDI_RS0_RI)) ||
+                                   ((arg & TIOCM_DSR) && (diff & FTDI_RS0_DSR)) ||
+                                   ((arg & TIOCM_CD)  && (diff & FTDI_RS0_RLSD)) ||
+                                   ((arg & TIOCM_CTS) && (diff & FTDI_RS0_CTS))) {
                                        return 0;
                                }
                                /*
-                                * Otherwise caller can't care less about what happened,
-                                * and so we continue to wait for more events.
+                                * Otherwise caller can't care less about what
+                                * happened,and so we continue to wait for more
+                                * events.
                                 */
                        }
                }
-               return(0);
-               break;
+               return 0;
        default:
                break;
-
        }
-
-
-       /* This is not necessarily an error - turns out the higher layers will do
-        *  some ioctls itself (see comment above)
+       /* This is not necessarily an error - turns out the higher layers
+        * will do some ioctls themselves (see comment above)
         */
        dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd);
+       return -ENOIOCTLCMD;
+}
 
-       return(-ENOIOCTLCMD);
-} /* ftdi_ioctl */
-
-
-static void ftdi_throttle (struct usb_serial_port *port)
+static void ftdi_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
 
@@ -2310,8 +2374,9 @@ static void ftdi_throttle (struct usb_serial_port *port)
 }
 
 
-static void ftdi_unthrottle (struct usb_serial_port *port)
+static void ftdi_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ftdi_private *priv = usb_get_serial_port_data(port);
        int actually_throttled;
        unsigned long flags;
@@ -2327,7 +2392,7 @@ static void ftdi_unthrottle (struct usb_serial_port *port)
                schedule_delayed_work(&priv->rx_work, 0);
 }
 
-static int __init ftdi_init (void)
+static int __init ftdi_init(void)
 {
        int retval;
 
@@ -2357,13 +2422,13 @@ failed_sio_register:
 }
 
 
-static void __exit ftdi_exit (void)
+static void __exit ftdi_exit(void)
 {
 
        dbg("%s", __func__);
 
-       usb_deregister (&ftdi_driver);
-       usb_serial_deregister (&ftdi_sio_device);
+       usb_deregister(&ftdi_driver);
+       usb_serial_deregister(&ftdi_sio_device);
 
 }
 
@@ -2371,8 +2436,8 @@ static void __exit ftdi_exit (void)
 module_init(ftdi_init);
 module_exit(ftdi_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index 8302eca..a577ea4 100644 (file)
@@ -1,20 +1,20 @@
 /*
- * Definitions for the FTDI USB Single Port Serial Converter - 
- * known as FTDI_SIO (Serial Input/Output application of the chipset) 
+ * Definitions for the FTDI USB Single Port Serial Converter -
+ * known as FTDI_SIO (Serial Input/Output application of the chipset)
  *
  * The example I have is known as the USC-1000 which is available from
  * http://www.dse.co.nz - cat no XH4214 It looks similar to this:
  * http://www.dansdata.com/usbser.htm but I can't be sure There are other
  * USC-1000s which don't look like my device though so beware!
  *
- * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side, 
+ * The device is based on the FTDI FT8U100AX chip. It has a DB25 on one side,
  * USB on the other.
  *
  * Thanx to FTDI (http://www.ftdi.co.uk) for so kindly providing details
  * of the protocol required to talk to the device and ongoing assistence
  * during development.
  *
- * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the 
+ * Bill Ryder - bryder@sgi.com formerly of Silicon Graphics, Inc.- wrote the
  * FTDI_SIO implementation.
  *
  * Philipp Gühring - pg@futureware.at - added the Device ID of the USB relais
 /*
  * DSS-20 Sync Station for Sony Ericsson P800
  */
-#define FTDI_DSS20_PID          0xFC82  
+#define FTDI_DSS20_PID          0xFC82
 
 /*
  * Home Electronics (www.home-electro.com) USB gadgets
 /*
  * BmRequestType:  0100 0000B
  * bRequest:       FTDI_SIO_RESET
- * wValue:         Control Value 
+ * wValue:         Control Value
  *                   0 = Reset SIO
  *                   1 = Purge RX buffer
  *                   2 = Purge TX buffer
  *   101 - add .625 to divisor
  *   110 - add .750 to divisor
  *   111 - add .875 to divisor
- * Bits 15 to 0 of the 17-bit divisor are placed in the urb value.  Bit 16 is 
+ * Bits 15 to 0 of the 17-bit divisor are placed in the urb value.  Bit 16 is
  * placed in bit 0 of the urb index.
  *
  * Note that there are a couple of special cases to support the highest baud
@@ -971,8 +971,8 @@ typedef enum {
 } ftdi_chip_type_t;
 
 typedef enum {
- ftdi_sio_b300 = 0, 
- ftdi_sio_b600 = 1, 
+ ftdi_sio_b300 = 0,
+ ftdi_sio_b600 = 1,
  ftdi_sio_b1200 = 2,
  ftdi_sio_b2400 = 3,
  ftdi_sio_b4800 = 4,
@@ -981,7 +981,7 @@ typedef enum {
  ftdi_sio_b38400 = 7,
  ftdi_sio_b57600 = 8,
  ftdi_sio_b115200 = 9
-} FTDI_SIO_baudrate_t ;
+} FTDI_SIO_baudrate_t;
 
 /*
  * The ftdi_8U232AM_xxMHz_byyy constants have been removed. The encoded divisor values
@@ -990,19 +990,19 @@ typedef enum {
 
 #define FTDI_SIO_SET_DATA_REQUEST FTDI_SIO_SET_DATA
 #define FTDI_SIO_SET_DATA_REQUEST_TYPE 0x40
-#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8 )
-#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8 )
-#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8 )
-#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8 )
-#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8 )
-#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11 )
-#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11 )
-#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11 )
+#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8)
+#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8)
+#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8)
+#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8)
+#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8)
+#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11)
+#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11)
+#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
 #define FTDI_SIO_SET_BREAK (0x1 << 14)
 /* FTDI_SIO_SET_DATA */
 
 /*
- * BmRequestType:  0100 0000B 
+ * BmRequestType:  0100 0000B
  * bRequest:       FTDI_SIO_SET_DATA
  * wValue:         Data characteristics (see below)
  * wIndex:         Port
@@ -1035,7 +1035,7 @@ typedef enum {
 #define FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE 0x40
 #define FTDI_SIO_SET_MODEM_CTRL_REQUEST FTDI_SIO_MODEM_CTRL
 
-/* 
+/*
  * BmRequestType:   0100 0000B
  * bRequest:        FTDI_SIO_MODEM_CTRL
  * wValue:          ControlValue (see below)
@@ -1049,11 +1049,11 @@ typedef enum {
  */
 
 #define FTDI_SIO_SET_DTR_MASK 0x1
-#define FTDI_SIO_SET_DTR_HIGH ( 1 | ( FTDI_SIO_SET_DTR_MASK  << 8))
-#define FTDI_SIO_SET_DTR_LOW  ( 0 | ( FTDI_SIO_SET_DTR_MASK  << 8))
+#define FTDI_SIO_SET_DTR_HIGH (1 | (FTDI_SIO_SET_DTR_MASK  << 8))
+#define FTDI_SIO_SET_DTR_LOW  (0 | (FTDI_SIO_SET_DTR_MASK  << 8))
 #define FTDI_SIO_SET_RTS_MASK 0x2
-#define FTDI_SIO_SET_RTS_HIGH ( 2 | ( FTDI_SIO_SET_RTS_MASK << 8 ))
-#define FTDI_SIO_SET_RTS_LOW ( 0 | ( FTDI_SIO_SET_RTS_MASK << 8 ))
+#define FTDI_SIO_SET_RTS_HIGH (2 | (FTDI_SIO_SET_RTS_MASK << 8))
+#define FTDI_SIO_SET_RTS_LOW (0 | (FTDI_SIO_SET_RTS_MASK << 8))
 
 /*
  * ControlValue
@@ -1076,7 +1076,7 @@ typedef enum {
 /* FTDI_SIO_SET_FLOW_CTRL */
 #define FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE 0x40
 #define FTDI_SIO_SET_FLOW_CTRL_REQUEST FTDI_SIO_SET_FLOW_CTRL
-#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0 
+#define FTDI_SIO_DISABLE_FLOW_CTRL 0x0
 #define FTDI_SIO_RTS_CTS_HS (0x1 << 8)
 #define FTDI_SIO_DTR_DSR_HS (0x2 << 8)
 #define FTDI_SIO_XON_XOFF_HS (0x4 << 8)
@@ -1085,7 +1085,7 @@ typedef enum {
  *   bRequest:       FTDI_SIO_SET_FLOW_CTRL
  *   wValue:         Xoff/Xon
  *   wIndex:         Protocol/Port - hIndex is protocl / lIndex is port
- *   wLength:        0 
+ *   wLength:        0
  *   Data:           None
  *
  * hIndex protocol is:
@@ -1101,10 +1101,10 @@ typedef enum {
  *
  * A value of zero in the hIndex field disables handshaking
  *
- * If Xon/Xoff handshaking is specified, the hValue field should contain the XOFF character 
+ * If Xon/Xoff handshaking is specified, the hValue field should contain the XOFF character
  * and the lValue field contains the XON character.
- */  
+ */
+
 /*
  * FTDI_SIO_GET_LATENCY_TIMER
  *
@@ -1118,7 +1118,7 @@ typedef enum {
 #define  FTDI_SIO_GET_LATENCY_TIMER_REQUEST FTDI_SIO_GET_LATENCY_TIMER
 #define  FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE 0xC0
 
-/* 
+/*
  *  BmRequestType:   1100 0000b
  *  bRequest:        FTDI_SIO_GET_LATENCY_TIMER
  *  wValue:          0
@@ -1127,7 +1127,7 @@ typedef enum {
  *  Data:            latency (on return)
  */
 
-/* 
+/*
  * FTDI_SIO_SET_LATENCY_TIMER
  *
  * Set the timeout interval. The FTDI collects data from the slave
@@ -1140,7 +1140,7 @@ typedef enum {
 #define  FTDI_SIO_SET_LATENCY_TIMER_REQUEST FTDI_SIO_SET_LATENCY_TIMER
 #define  FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE 0x40
 
-/* 
+/*
  *  BmRequestType:   0100 0000b
  *  bRequest:        FTDI_SIO_SET_LATENCY_TIMER
  *  wValue:          Latency (milliseconds)
@@ -1155,7 +1155,7 @@ typedef enum {
  */
 
 /*
- * FTDI_SIO_SET_EVENT_CHAR 
+ * FTDI_SIO_SET_EVENT_CHAR
  *
  * Set the special event character for the specified communications port.
  * If the device sees this character it will immediately return the
@@ -1168,7 +1168,7 @@ typedef enum {
 #define  FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE 0x40
 
 
-/* 
+/*
  *  BmRequestType:   0100 0000b
  *  bRequest:        FTDI_SIO_SET_EVENT_CHAR
  *  wValue:          EventChar
@@ -1184,12 +1184,12 @@ typedef enum {
  *   B9..15  Reserved
  *
  */
-          
+
 /* FTDI_SIO_SET_ERROR_CHAR */
 
 /* Set the parity error replacement character for the specified communications port */
 
-/* 
+/*
  *  BmRequestType:  0100 0000b
  *  bRequest:       FTDI_SIO_SET_EVENT_CHAR
  *  wValue:         Error Char
@@ -1215,15 +1215,15 @@ typedef enum {
 #define FTDI_SIO_DSR_MASK 0x20
 #define FTDI_SIO_RI_MASK  0x40
 #define FTDI_SIO_RLSD_MASK 0x80
-/* 
+/*
  *   BmRequestType:   1100 0000b
  *   bRequest:        FTDI_SIO_GET_MODEM_STATUS
  *   wValue:          zero
  *   wIndex:          Port
  *   wLength:         1
  *   Data:            Status
- * 
- * One byte of data is returned 
+ *
+ * One byte of data is returned
  * B0..3 0
  * B4    CTS
  *         0 = inactive
@@ -1236,15 +1236,15 @@ typedef enum {
  *         1 = active
  * B7    Receive Line Signal Detect (RLSD)
  *         0 = inactive
- *         1 = active 
+ *         1 = active
  */
 
 
 
-/* Descriptors returned by the device 
- * 
+/* Descriptors returned by the device
+ *
  *  Device Descriptor
- * 
+ *
  * Offset      Field           Size    Value   Description
  * 0   bLength         1       0x12    Size of descriptor in bytes
  * 1   bDescriptorType 1       0x01    DEVICE Descriptor Type
@@ -1260,9 +1260,9 @@ typedef enum {
  * 15  iProduct        1       0x02    Index of prod string desc
  * 16  iSerialNumber   1       0x02    Index of serial nmr string desc
  * 17  bNumConfigurations 1    0x01    Number of possible configurations
- * 
+ *
  * Configuration Descriptor
- * 
+ *
  * Offset      Field                   Size    Value
  * 0   bLength                 1       0x09    Size of descriptor in bytes
  * 1   bDescriptorType         1       0x02    CONFIGURATION Descriptor Type
@@ -1272,9 +1272,9 @@ typedef enum {
  * 6   iConfiguration          1       0x02    Index of config string descriptor
  * 7   bmAttributes            1       0x20    Config characteristics Remote Wakeup
  * 8   MaxPower                1       0x1E    Max power consumption
- * 
+ *
  * Interface Descriptor
- * 
+ *
  * Offset      Field                   Size    Value
  * 0   bLength                 1       0x09    Size of descriptor in bytes
  * 1   bDescriptorType         1       0x04    INTERFACE Descriptor Type
@@ -1285,9 +1285,9 @@ typedef enum {
  * 6   bInterfaceSubClass      1       0xFF    Subclass Code
  * 7   bInterfaceProtocol      1       0xFF    Protocol Code
  * 8   iInterface              1       0x02    Index of interface string description
- * 
+ *
  * IN Endpoint Descriptor
- * 
+ *
  * Offset      Field                   Size    Value
  * 0   bLength                 1       0x07    Size of descriptor in bytes
  * 1   bDescriptorType         1       0x05    ENDPOINT descriptor type
@@ -1295,9 +1295,9 @@ typedef enum {
  * 3   bmAttributes            1       0x02    Endpoint attributes - Bulk
  * 4   bNumEndpoints           2       0x0040  maximum packet size
  * 5   bInterval               1       0x00    Interval for polling endpoint
- * 
+ *
  * OUT Endpoint Descriptor
- * 
+ *
  * Offset      Field                   Size    Value
  * 0   bLength                 1       0x07    Size of descriptor in bytes
  * 1   bDescriptorType         1       0x05    ENDPOINT descriptor type
@@ -1305,17 +1305,17 @@ typedef enum {
  * 3   bmAttributes            1       0x02    Endpoint attributes - Bulk
  * 4   bNumEndpoints           2       0x0040  maximum packet size
  * 5   bInterval               1       0x00    Interval for polling endpoint
- *     
+ *
  * DATA FORMAT
- * 
+ *
  * IN Endpoint
- * 
+ *
  * The device reserves the first two bytes of data on this endpoint to contain the current
  * values of the modem and line status registers. In the absence of data, the device 
  * generates a message consisting of these two status bytes every 40 ms
- * 
+ *
  * Byte 0: Modem Status
- * 
+ *
  * Offset      Description
  * B0  Reserved - must be 1
  * B1  Reserved - must be 0
@@ -1325,9 +1325,9 @@ typedef enum {
  * B5  Data Set Ready (DSR)
  * B6  Ring Indicator (RI)
  * B7  Receive Line Signal Detect (RLSD)
- * 
+ *
  * Byte 1: Line Status
- * 
+ *
  * Offset      Description
  * B0  Data Ready (DR)
  * B1  Overrun Error (OE)
@@ -1337,7 +1337,7 @@ typedef enum {
  * B5  Transmitter Holding Register (THRE)
  * B6  Transmitter Empty (TEMT)
  * B7  Error in RCVR FIFO
- * 
+ *
  */
 #define FTDI_RS0_CTS   (1 << 4)
 #define FTDI_RS0_DSR   (1 << 5)
@@ -1355,17 +1355,17 @@ typedef enum {
 
 /*
  * OUT Endpoint
- * 
+ *
  * This device reserves the first bytes of data on this endpoint contain the length
  * and port identifier of the message. For the FTDI USB Serial converter the port 
  * identifier is always 1.
- * 
+ *
  * Byte 0: Line Status
- * 
+ *
  * Offset      Description
  * B0  Reserved - must be 1
  * B1  Reserved - must be 0
  * B2..7       Length of message - (not including Byte 0)
- * 
+ *
  */
 
index e8ba2cb..d30f736 100644 (file)
@@ -14,7 +14,7 @@
 #include <linux/module.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 static int debug;
 
index 8ce5a56..2e663f1 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <asm/atomic.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
@@ -44,7 +44,7 @@
 static int initial_mode = 1;
 
 /* debug flag */
-static int debug = 0;
+static int debug;
 
 #define GARMIN_VENDOR_ID             0x091E
 
@@ -56,7 +56,7 @@ static int debug = 0;
 #define VERSION_MINOR  31
 
 #define _STR(s) #s
-#define _DRIVER_VERSION(a,b) "v" _STR(a) "." _STR(b)
+#define _DRIVER_VERSION(a, b) "v" _STR(a) "." _STR(b)
 #define DRIVER_VERSION _DRIVER_VERSION(VERSION_MAJOR, VERSION_MINOR)
 #define DRIVER_AUTHOR "hermann kneissel"
 #define DRIVER_DESC "garmin gps driver"
@@ -65,37 +65,37 @@ static int debug = 0;
 #define EINVPKT        1000    /* invalid packet structure */
 
 
-// size of the header of a packet using the usb protocol
+/* size of the header of a packet using the usb protocol */
 #define GARMIN_PKTHDR_LENGTH   12
 
-// max. possible size of a packet using the serial protocol 
-#define MAX_SERIAL_PKT_SIZ (3+255+3)
+/* max. possible size of a packet using the serial protocol */
+#define MAX_SERIAL_PKT_SIZ (3 + 255 + 3)
 
-// max. possible size of a packet with worst case stuffing
-#define MAX_SERIAL_PKT_SIZ_STUFFED MAX_SERIAL_PKT_SIZ+256
+/*  max. possible size of a packet with worst case stuffing */
+#define MAX_SERIAL_PKT_SIZ_STUFFED (MAX_SERIAL_PKT_SIZ + 256)
 
-// size of a buffer able to hold a complete (no stuffing) packet
-// (the document protocol does not contain packets with a larger
-//  size, but in theory a packet may be 64k+12 bytes - if in
-//  later protocol versions larger packet sizes occur, this value
-//  should be increased accordingly, so the input buffer is always 
-//  large enough the store a complete packet inclusive header)
-#define GPS_IN_BUFSIZ  (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ) 
+/* size of a buffer able to hold a complete (no stuffing) packet
+ * (the document protocol does not contain packets with a larger
+ *  size, but in theory a packet may be 64k+12 bytes - if in
+ *  later protocol versions larger packet sizes occur, this value
+ *  should be increased accordingly, so the input buffer is always
+ *  large enough the store a complete packet inclusive header) */
+#define GPS_IN_BUFSIZ  (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ)
 
-// size of a buffer able to hold a complete (incl. stuffing) packet
-#define GPS_OUT_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ_STUFFED) 
+/* size of a buffer able to hold a complete (incl. stuffing) packet */
+#define GPS_OUT_BUFSIZ (GARMIN_PKTHDR_LENGTH+MAX_SERIAL_PKT_SIZ_STUFFED)
 
-// where to place the packet id of a serial packet, so we can
-// prepend the usb-packet header without the need to move the
-// packets data
+/* where to place the packet id of a serial packet, so we can
+ * prepend the usb-packet header without the need to move the
+ * packets data */
 #define GSP_INITIAL_OFFSET (GARMIN_PKTHDR_LENGTH-2)
 
-// max. size of incoming private packets (header+1 param)
+/* max. size of incoming private packets (header+1 param) */
 #define PRIVPKTSIZ (GARMIN_PKTHDR_LENGTH+4)
 
 #define GARMIN_LAYERID_TRANSPORT  0
 #define GARMIN_LAYERID_APPL      20
-// our own layer-id to use for some control mechanisms
+/* our own layer-id to use for some control mechanisms */
 #define GARMIN_LAYERID_PRIVATE 0x01106E4B
 
 #define GARMIN_PKTID_PVT_DATA  51
@@ -103,7 +103,7 @@ static int debug = 0;
 
 #define CMND_ABORT_TRANSFER 0
 
-// packet ids used in private layer
+/* packet ids used in private layer */
 #define PRIV_PKTID_SET_DEBUG   1
 #define PRIV_PKTID_SET_MODE    2
 #define PRIV_PKTID_INFO_REQ    3
@@ -121,7 +121,8 @@ static int debug = 0;
 struct garmin_packet {
        struct list_head  list;
        int               seq;
-       int               size; // the real size of the data array, always > 0
+       /* the real size of the data array, always > 0 */
+       int               size;
        __u8              data[1];
 };
 
@@ -164,7 +165,7 @@ struct garmin_data {
 #define MODE_NATIVE          0
 #define MODE_GARMIN_SERIAL   1
 
-// Flags used in garmin_data.flags:
+/* Flags used in garmin_data.flags: */
 #define FLAGS_SESSION_REPLY_MASK  0x00C0
 #define FLAGS_SESSION_REPLY1_SEEN 0x0080
 #define FLAGS_SESSION_REPLY2_SEEN 0x0040
@@ -185,7 +186,7 @@ struct garmin_data {
 
 
 /* function prototypes */
-static void gsp_next_packet(struct garmin_data * garmin_data_p);
+static void gsp_next_packet(struct garmin_data *garmin_data_p);
 static int  garmin_write_bulk(struct usb_serial_port *port,
                             const unsigned char *buf, int count,
                             int dismiss_ack);
@@ -217,12 +218,13 @@ static unsigned char const PRIVATE_REQ[]
 
 
 static struct usb_device_id id_table [] = {
-       /* the same device id seems to be used by all usb enabled gps devices */
-       { USB_DEVICE(GARMIN_VENDOR_ID, 3 ) },
+       /* the same device id seems to be used by all
+          usb enabled GPS devices */
+       { USB_DEVICE(GARMIN_VENDOR_ID, 3) },
        { }                                     /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table);
+MODULE_DEVICE_TABLE(usb, id_table);
 
 static struct usb_driver garmin_driver = {
        .name =         "garmin_gps",
@@ -233,9 +235,10 @@ static struct usb_driver garmin_driver = {
 };
 
 
-static inline int noResponseFromAppLayer(struct garmin_data * garmin_data_p)
+static inline int noResponseFromAppLayer(struct garmin_data *garmin_data_p)
 {
-       return atomic_read(&garmin_data_p->req_count) == atomic_read(&garmin_data_p->resp_count);
+       return atomic_read(&garmin_data_p->req_count) ==
+                               atomic_read(&garmin_data_p->resp_count);
 }
 
 
@@ -261,10 +264,10 @@ static inline int getDataLength(const __u8 *usbPacket)
  */
 static inline int isAbortTrfCmnd(const unsigned char *buf)
 {
-       if (0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ, 
-                       sizeof(GARMIN_STOP_TRANSFER_REQ)) ||
-           0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2, 
-                       sizeof(GARMIN_STOP_TRANSFER_REQ_V2)))
+       if (0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ,
+                                       sizeof(GARMIN_STOP_TRANSFER_REQ)) ||
+           0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2,
+                                       sizeof(GARMIN_STOP_TRANSFER_REQ_V2)))
                return 1;
        else
                return 0;
@@ -275,11 +278,11 @@ static inline int isAbortTrfCmnd(const unsigned char *buf)
 static void send_to_tty(struct usb_serial_port *port,
                        char *data, unsigned int actual_length)
 {
-       struct tty_struct *tty = port->tty;
+       struct tty_struct *tty = port->port.tty;
 
        if (tty && actual_length) {
 
-               usb_serial_debug_data(debug, &port->dev, 
+               usb_serial_debug_data(debug, &port->dev,
                                        __func__, actual_length, data);
 
                tty_buffer_request_room(tty, actual_length);
@@ -296,7 +299,7 @@ static void send_to_tty(struct usb_serial_port *port,
 /*
  * queue a received (usb-)packet for later processing
  */
-static int pkt_add(struct garmin_data * garmin_data_p,
+static int pkt_add(struct garmin_data *garmin_data_p,
                   unsigned char *data, unsigned int data_length)
 {
        int state = 0;
@@ -307,7 +310,7 @@ static int pkt_add(struct garmin_data * garmin_data_p,
        /* process only packets containg data ... */
        if (data_length) {
                pkt = kmalloc(sizeof(struct garmin_packet)+data_length,
-                             GFP_ATOMIC);
+                                                               GFP_ATOMIC);
                if (pkt == NULL) {
                        dev_err(&garmin_data_p->port->dev, "out of memory\n");
                        return 0;
@@ -325,16 +328,15 @@ static int pkt_add(struct garmin_data * garmin_data_p,
 
                /* in serial mode, if someone is waiting for data from
                   the device, iconvert and send the next packet to tty. */
-               if (result && (state == STATE_GSP_WAIT_DATA)) {
+               if (result && (state == STATE_GSP_WAIT_DATA))
                        gsp_next_packet(garmin_data_p);
-               }
        }
        return result;
 }
 
 
 /* get the next pending packet */
-static struct garmin_packet *pkt_pop(struct garmin_data * garmin_data_p)
+static struct garmin_packet *pkt_pop(struct garmin_data *garmin_data_p)
 {
        unsigned long flags;
        struct garmin_packet *result = NULL;
@@ -350,7 +352,7 @@ static struct garmin_packet *pkt_pop(struct garmin_data * garmin_data_p)
 
 
 /* free up all queued data */
-static void pkt_clear(struct garmin_data * garmin_data_p)
+static void pkt_clear(struct garmin_data *garmin_data_p)
 {
        unsigned long flags;
        struct garmin_packet *result = NULL;
@@ -372,7 +374,7 @@ static void pkt_clear(struct garmin_data * garmin_data_p)
  ******************************************************************************/
 
 /* send an ack packet back to the tty */
-static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id)
+static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id)
 {
        __u8 pkt[10];
        __u8 cksum = 0;
@@ -391,9 +393,8 @@ static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id)
        *ptr++ = pkt_id;
        cksum += pkt_id;
 
-       if (pkt_id == DLE) {
+       if (pkt_id == DLE)
                *ptr++ = DLE;
-       }
 
        *ptr++ = 0;
        *ptr++ = 0xFF & (-cksum);
@@ -415,12 +416,12 @@ static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id)
  * at GSP_INITIAL_OFFSET.
  *
  * count - number of bytes in the input buffer including space reserved for
- *         the usb header: GSP_INITIAL_OFFSET + number of bytes in packet 
+ *         the usb header: GSP_INITIAL_OFFSET + number of bytes in packet
  *         (including pkt-id, data-length a. cksum)
  */
-static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
+static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count)
 {
-       const __u8recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET;
+       const __u8 *recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET;
        __le32 *usbdata = (__le32 *) garmin_data_p->inbuffer;
 
        int cksum = 0;
@@ -440,8 +441,8 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
        cksum += *recpkt++;
        cksum += *recpkt++;
 
-       // sanity check, remove after test ...
-       if ((__u8*)&(usbdata[3]) != recpkt) {
+       /* sanity check, remove after test ... */
+       if ((__u8 *)&(usbdata[3]) != recpkt) {
                dbg("%s - ptr mismatch %p - %p",
                        __func__, &(usbdata[4]), recpkt);
                return -EINVPKT;
@@ -462,7 +463,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
        usbdata[1] = __cpu_to_le32(pktid);
        usbdata[2] = __cpu_to_le32(size);
 
-       garmin_write_bulk (garmin_data_p->port, garmin_data_p->inbuffer,
+       garmin_write_bulk(garmin_data_p->port, garmin_data_p->inbuffer,
                           GARMIN_PKTHDR_LENGTH+size, 0);
 
        /* if this was an abort-transfer command, flush all
@@ -495,7 +496,7 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
  * if the input is an abort command, drop all queued data.
  */
 
-static int gsp_receive(struct garmin_data * garmin_data_p,
+static int gsp_receive(struct garmin_data *garmin_data_p,
                       const unsigned char *buf, int count)
 {
        unsigned long flags;
@@ -504,10 +505,11 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
        int i = 0;
        __u8 *dest;
        int size;
-       // dleSeen: set if last byte read was a DLE
+       /* dleSeen: set if last byte read was a DLE */
        int dleSeen;
-       // skip: if set, skip incoming data until possible start of
-       //       new packet
+       /* skip: if set, skip incoming data until possible start of
+        *       new packet
+        */
        int skip;
        __u8 data;
 
@@ -521,14 +523,13 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
        dbg("%s - dle=%d skip=%d size=%d count=%d",
                __func__, dleSeen, skip, size, count);
 
-       if (size == 0) {
+       if (size == 0)
                size = GSP_INITIAL_OFFSET;
-       }
 
        while (offs < count) {
 
                data = *(buf+offs);
-               offs ++;
+               offs++;
 
                if (data == DLE) {
                        if (skip) { /* start of a new pkt */
@@ -554,9 +555,8 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
                                        ack_or_nak_seen = NAK;
                                        dbg("NAK packet complete.");
                                } else {
-                                       dbg("packet complete "
-                                                       "- id=0x%X.",
-                                                       0xFF & data);
+                                       dbg("packet complete - id=0x%X.",
+                                               0xFF & data);
                                        gsp_rec_packet(garmin_data_p, size);
                                }
 
@@ -589,7 +589,7 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
 
        garmin_data_p->insize = size;
 
-       // copy flags back to structure
+       /* copy flags back to structure */
        if (skip)
                garmin_data_p->flags |= FLAGS_GSP_SKIP;
        else
@@ -600,16 +600,13 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
        else
                garmin_data_p->flags &= ~FLAGS_GSP_DLESEEN;
 
-       if (ack_or_nak_seen) {
+       if (ack_or_nak_seen)
                garmin_data_p->state = STATE_GSP_WAIT_DATA;
-       }
 
        spin_unlock_irqrestore(&garmin_data_p->lock, flags);
 
-       if (ack_or_nak_seen) {
+       if (ack_or_nak_seen)
                gsp_next_packet(garmin_data_p);
-       }
-
        return count;
 }
 
@@ -623,7 +620,7 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
  *
  * return <0 on error, 0 if packet is incomplete or > 0 if packet was sent
  */
-static int gsp_send(struct garmin_data * garmin_data_p,
+static int gsp_send(struct garmin_data *garmin_data_p,
                    const unsigned char *buf, int count)
 {
        const unsigned char *src;
@@ -631,11 +628,11 @@ static int gsp_send(struct garmin_data * garmin_data_p,
        int pktid = 0;
        int datalen = 0;
        int cksum = 0;
-       int i=0;
+       int i = 0;
        int k;
 
        dbg("%s - state %d - %d bytes.", __func__,
-                garmin_data_p->state, count);
+                                       garmin_data_p->state, count);
 
        k = garmin_data_p->outsize;
        if ((k+count) > GPS_OUT_BUFSIZ) {
@@ -650,7 +647,7 @@ static int gsp_send(struct garmin_data * garmin_data_p,
 
        if (k >= GARMIN_PKTHDR_LENGTH) {
                pktid  = getPacketId(garmin_data_p->outbuffer);
-               datalen= getDataLength(garmin_data_p->outbuffer);
+               datalen = getDataLength(garmin_data_p->outbuffer);
                i = GARMIN_PKTHDR_LENGTH + datalen;
                if (k < i)
                        return 0;
@@ -658,19 +655,18 @@ static int gsp_send(struct garmin_data * garmin_data_p,
                return 0;
        }
 
-       dbg("%s - %d bytes in buffer, %d bytes in pkt.", __func__,
-                k, i);
+       dbg("%s - %d bytes in buffer, %d bytes in pkt.", __func__, k, i);
 
        /* garmin_data_p->outbuffer now contains a complete packet */
 
        usb_serial_debug_data(debug, &garmin_data_p->port->dev,
-                                  __func__, k, garmin_data_p->outbuffer);
+                               __func__, k, garmin_data_p->outbuffer);
 
        garmin_data_p->outsize = 0;
 
        if (GARMIN_LAYERID_APPL != getLayerId(garmin_data_p->outbuffer)) {
-               dbg("not an application packet (%d)", 
-                       getLayerId(garmin_data_p->outbuffer));
+               dbg("not an application packet (%d)",
+                               getLayerId(garmin_data_p->outbuffer));
                return -1;
        }
 
@@ -688,14 +684,14 @@ static int gsp_send(struct garmin_data * garmin_data_p,
 
        k = 0;
        src = garmin_data_p->outbuffer+GARMIN_PKTHDR_LENGTH;
-       for (i=0; i<datalen; i++) {
+       for (i = 0; i < datalen; i++) {
                if (*src++ == DLE)
                        k++;
        }
 
        src = garmin_data_p->outbuffer+GARMIN_PKTHDR_LENGTH;
        if (k > (GARMIN_PKTHDR_LENGTH-2)) {
-               /* can't add stuffing DLEs in place, move data to end 
+               /* can't add stuffing DLEs in place, move data to end
                   of buffer ... */
                dst = garmin_data_p->outbuffer+GPS_OUT_BUFSIZ-datalen;
                memcpy(dst, src, datalen);
@@ -712,14 +708,14 @@ static int gsp_send(struct garmin_data * garmin_data_p,
        if (datalen == DLE)
                *dst++ = DLE;
 
-       for (i=0; i<datalen; i++) {
+       for (i = 0; i < datalen; i++) {
                __u8 c = *src++;
                *dst++ = c;
                cksum += c;
                if (c == DLE)
                        *dst++ = DLE;
        }
-               
+
        cksum = 0xFF & -cksum;
        *dst++ = cksum;
        if (cksum == DLE)
@@ -744,7 +740,7 @@ static int gsp_send(struct garmin_data * garmin_data_p,
 /*
  * Process the next pending data packet - if there is one
  */
-static void gsp_next_packet(struct garmin_data * garmin_data_p)
+static void gsp_next_packet(struct garmin_data *garmin_data_p)
 {
        struct garmin_packet *pkt = NULL;
 
@@ -774,17 +770,17 @@ static void gsp_next_packet(struct garmin_data * garmin_data_p)
  * buf contains the data read, it may span more than one packet
  * or even incomplete packets
  */
-static int nat_receive(struct garmin_data * garmin_data_p,
+static int nat_receive(struct garmin_data *garmin_data_p,
                       const unsigned char *buf, int count)
 {
        unsigned long flags;
-       __u8 * dest;
+       __u8 *dest;
        int offs = 0;
        int result = count;
        int len;
 
        while (offs < count) {
-               // if buffer contains header, copy rest of data
+               /* if buffer contains header, copy rest of data */
                if (garmin_data_p->insize >= GARMIN_PKTHDR_LENGTH)
                        len = GARMIN_PKTHDR_LENGTH
                              +getDataLength(garmin_data_p->inbuffer);
@@ -792,9 +788,9 @@ static int nat_receive(struct garmin_data * garmin_data_p,
                        len = GARMIN_PKTHDR_LENGTH;
 
                if (len >= GPS_IN_BUFSIZ) {
-                       /* seem to be an invalid packet, ignore rest of input */
-                       dbg("%s - packet size too large: %d",
-                               __func__, len);
+                       /* seems to be an invalid packet, ignore rest
+                          of input */
+                       dbg("%s - packet size too large: %d", __func__, len);
                        garmin_data_p->insize = 0;
                        count = 0;
                        result = -EINVPKT;
@@ -804,7 +800,7 @@ static int nat_receive(struct garmin_data * garmin_data_p,
                                len = (count-offs);
                        if (len > 0) {
                                dest = garmin_data_p->inbuffer
-                                       +garmin_data_p->insize;
+                                               + garmin_data_p->insize;
                                memcpy(dest, buf+offs, len);
                                garmin_data_p->insize += len;
                                offs += len;
@@ -816,17 +812,19 @@ static int nat_receive(struct garmin_data * garmin_data_p,
                        len = GARMIN_PKTHDR_LENGTH+
                           getDataLength(garmin_data_p->inbuffer);
                        if (garmin_data_p->insize >= len) {
-                               garmin_write_bulk (garmin_data_p->port,
-                                                  garmin_data_p->inbuffer,
-                                                  len, 0);
+                               garmin_write_bulk(garmin_data_p->port,
+                                                  garmin_data_p->inbuffer,
+                                                  len, 0);
                                garmin_data_p->insize = 0;
 
                                /* if this was an abort-transfer command,
                                   flush all queued data. */
                                if (isAbortTrfCmnd(garmin_data_p->inbuffer)) {
-                                       spin_lock_irqsave(&garmin_data_p->lock, flags);
+                                       spin_lock_irqsave(&garmin_data_p->lock,
+                                                                       flags);
                                        garmin_data_p->flags |= FLAGS_DROP_DATA;
-                                       spin_unlock_irqrestore(&garmin_data_p->lock, flags);
+                                       spin_unlock_irqrestore(
+                                               &garmin_data_p->lock, flags);
                                        pkt_clear(garmin_data_p);
                                }
                        }
@@ -842,7 +840,7 @@ static int nat_receive(struct garmin_data * garmin_data_p,
 
 static void priv_status_resp(struct usb_serial_port *port)
 {
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
        __le32 *pkt = (__le32 *)garmin_data_p->privpkt;
 
        pkt[0] = __cpu_to_le32(GARMIN_LAYERID_PRIVATE);
@@ -852,7 +850,7 @@ static void priv_status_resp(struct usb_serial_port *port)
        pkt[4] = __cpu_to_le32(garmin_data_p->mode);
        pkt[5] = __cpu_to_le32(garmin_data_p->serial_num);
 
-       send_to_tty(port, (__u8*)pkt, 6*4);
+       send_to_tty(port, (__u8 *)pkt, 6 * 4);
 }
 
 
@@ -864,7 +862,7 @@ static int process_resetdev_request(struct usb_serial_port *port)
 {
        unsigned long flags;
        int status;
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
 
        spin_lock_irqsave(&garmin_data_p->lock, flags);
        garmin_data_p->flags &= ~(CLEAR_HALT_REQUIRED);
@@ -872,8 +870,8 @@ static int process_resetdev_request(struct usb_serial_port *port)
        garmin_data_p->serial_num = 0;
        spin_unlock_irqrestore(&garmin_data_p->lock, flags);
 
-       usb_kill_urb (port->interrupt_in_urb);
-       dbg("%s - usb_reset_device", __func__ );
+       usb_kill_urb(port->interrupt_in_urb);
+       dbg("%s - usb_reset_device", __func__);
        status = usb_reset_device(port->serial->dev);
        if (status)
                dbg("%s - usb_reset_device failed: %d",
@@ -886,7 +884,7 @@ static int process_resetdev_request(struct usb_serial_port *port)
 /*
  * clear all cached data
  */
-static int garmin_clear(struct garmin_data * garmin_data_p)
+static int garmin_clear(struct garmin_data *garmin_data_p)
 {
        unsigned long flags;
        int status = 0;
@@ -896,8 +894,7 @@ static int garmin_clear(struct garmin_data * garmin_data_p)
        if (port != NULL && atomic_read(&garmin_data_p->resp_count)) {
                /* send a terminate command */
                status = garmin_write_bulk(port, GARMIN_STOP_TRANSFER_REQ,
-                                          sizeof(GARMIN_STOP_TRANSFER_REQ),
-                                          1);
+                                       sizeof(GARMIN_STOP_TRANSFER_REQ), 1);
        }
 
        /* flush all queued data */
@@ -920,28 +917,26 @@ static int garmin_init_session(struct usb_serial_port *port)
 {
        unsigned long flags;
        struct usb_serial *serial = port->serial;
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
        int status = 0;
 
        if (status == 0) {
-               usb_kill_urb (port->interrupt_in_urb);
+               usb_kill_urb(port->interrupt_in_urb);
 
                dbg("%s - adding interrupt input", __func__);
                port->interrupt_in_urb->dev = serial->dev;
                status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
                if (status)
                        dev_err(&serial->dev->dev,
-                               "%s - failed submitting interrupt urb,"
-                               " error %d\n",
-                               __func__, status);
+                         "%s - failed submitting interrupt urb, error %d\n",
+                                                       __func__, status);
        }
 
        if (status == 0) {
                dbg("%s - starting session ...", __func__);
                garmin_data_p->state = STATE_ACTIVE;
                status = garmin_write_bulk(port, GARMIN_START_SESSION_REQ,
-                                          sizeof(GARMIN_START_SESSION_REQ),
-                                          0);
+                                       sizeof(GARMIN_START_SESSION_REQ), 0);
 
                if (status >= 0) {
 
@@ -951,14 +946,14 @@ static int garmin_init_session(struct usb_serial_port *port)
 
                        /* not needed, but the win32 driver does it too ... */
                        status = garmin_write_bulk(port,
-                                                  GARMIN_START_SESSION_REQ2,
-                                                  sizeof(GARMIN_START_SESSION_REQ2),
-                                                  0);
+                                       GARMIN_START_SESSION_REQ2,
+                                       sizeof(GARMIN_START_SESSION_REQ2), 0);
                        if (status >= 0) {
                                status = 0;
                                spin_lock_irqsave(&garmin_data_p->lock, flags);
                                garmin_data_p->ignorePkts++;
-                               spin_unlock_irqrestore(&garmin_data_p->lock, flags);
+                               spin_unlock_irqrestore(&garmin_data_p->lock,
+                                                                       flags);
                        }
                }
        }
@@ -970,11 +965,12 @@ static int garmin_init_session(struct usb_serial_port *port)
 
 
 
-static int garmin_open (struct usb_serial_port *port, struct file *filp)
+static int garmin_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        unsigned long flags;
        int status = 0;
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
 
        dbg("%s - port %d", __func__, port->number);
 
@@ -983,8 +979,8 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp)
         * through, otherwise it is scheduled, and with high data rates (like
         * with OHCI) data can get lost.
         */
-       if (port->tty)
-               port->tty->low_latency = 1;
+       if (tty)
+               tty->low_latency = 1;
 
        spin_lock_irqsave(&garmin_data_p->lock, flags);
        garmin_data_p->mode  = initial_mode;
@@ -995,23 +991,22 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp)
        spin_unlock_irqrestore(&garmin_data_p->lock, flags);
 
        /* shutdown any bulk reads that might be going on */
-       usb_kill_urb (port->write_urb);
-       usb_kill_urb (port->read_urb);
+       usb_kill_urb(port->write_urb);
+       usb_kill_urb(port->read_urb);
 
-       if (garmin_data_p->state == STATE_RESET) {
+       if (garmin_data_p->state == STATE_RESET)
                status = garmin_init_session(port);
-       }
 
        garmin_data_p->state = STATE_ACTIVE;
-
        return status;
 }
 
 
-static void garmin_close (struct usb_serial_port *port, struct file * filp)
+static void garmin_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial *serial = port->serial;
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
 
        dbg("%s - port %d - mode=%d state=%d flags=0x%X", __func__,
                port->number, garmin_data_p->mode,
@@ -1025,8 +1020,8 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp)
                garmin_clear(garmin_data_p);
 
        /* shutdown our urbs */
-       usb_kill_urb (port->read_urb);
-       usb_kill_urb (port->write_urb);
+       usb_kill_urb(port->read_urb);
+       usb_kill_urb(port->write_urb);
 
        if (!port->serial->disconnected) {
                if (noResponseFromAppLayer(garmin_data_p) ||
@@ -1042,21 +1037,22 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp)
        mutex_unlock(&port->serial->disc_mutex);
 }
 
-
-static void garmin_write_bulk_callback (struct urb *urb)
+static void garmin_write_bulk_callback(struct urb *urb)
 {
        unsigned long flags;
        struct usb_serial_port *port = urb->context;
        int status = urb->status;
 
        if (port) {
-               struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
+               struct garmin_data *garmin_data_p =
+                                       usb_get_serial_port_data(port);
 
                dbg("%s - port %d", __func__, port->number);
 
                if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer)
                    && (garmin_data_p->mode == MODE_GARMIN_SERIAL))  {
-                       gsp_send_ack(garmin_data_p, ((__u8 *)urb->transfer_buffer)[4]);
+                       gsp_send_ack(garmin_data_p,
+                                       ((__u8 *)urb->transfer_buffer)[4]);
                }
 
                if (status) {
@@ -1070,20 +1066,21 @@ static void garmin_write_bulk_callback (struct urb *urb)
                usb_serial_port_softint(port);
        }
 
-       /* Ignore errors that resulted from garmin_write_bulk with dismiss_ack=1 */
+       /* Ignore errors that resulted from garmin_write_bulk with
+          dismiss_ack = 1 */
 
        /* free up the transfer buffer, as usb_free_urb() does not do this */
-       kfree (urb->transfer_buffer);
+       kfree(urb->transfer_buffer);
 }
 
 
-static int garmin_write_bulk (struct usb_serial_port *port,
+static int garmin_write_bulk(struct usb_serial_port *port,
                              const unsigned char *buf, int count,
                              int dismiss_ack)
 {
        unsigned long flags;
        struct usb_serial *serial = port->serial;
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
        struct urb *urb;
        unsigned char *buffer;
        int status;
@@ -1095,7 +1092,7 @@ static int garmin_write_bulk (struct usb_serial_port *port,
        garmin_data_p->flags &= ~FLAGS_DROP_DATA;
        spin_unlock_irqrestore(&garmin_data_p->lock, flags);
 
-       buffer = kmalloc (count, GFP_ATOMIC);
+       buffer = kmalloc(count, GFP_ATOMIC);
        if (!buffer) {
                dev_err(&port->dev, "out of memory\n");
                return -ENOMEM;
@@ -1104,17 +1101,17 @@ static int garmin_write_bulk (struct usb_serial_port *port,
        urb = usb_alloc_urb(0, GFP_ATOMIC);
        if (!urb) {
                dev_err(&port->dev, "no more free urbs\n");
-               kfree (buffer);
+               kfree(buffer);
                return -ENOMEM;
        }
 
-       memcpy (buffer, buf, count);
+       memcpy(buffer, buf, count);
 
        usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
 
-       usb_fill_bulk_urb (urb, serial->dev,
-                               usb_sndbulkpipe (serial->dev,
-                               port->bulk_out_endpointAddress),
+       usb_fill_bulk_urb(urb, serial->dev,
+                               usb_sndbulkpipe(serial->dev,
+                                       port->bulk_out_endpointAddress),
                                buffer, count,
                                garmin_write_bulk_callback,
                                dismiss_ack ? NULL : port);
@@ -1132,33 +1129,29 @@ static int garmin_write_bulk (struct usb_serial_port *port,
        status = usb_submit_urb(urb, GFP_ATOMIC);
        if (status) {
                dev_err(&port->dev,
-                       "%s - usb_submit_urb(write bulk) "
-                       "failed with status = %d\n",
+                  "%s - usb_submit_urb(write bulk) failed with status = %d\n",
                                __func__, status);
                count = status;
        }
 
        /* we are done with this urb, so let the host driver
         * really free it when it is finished with it */
-       usb_free_urb (urb);
+       usb_free_urb(urb);
 
        return count;
 }
 
-
-
-static int garmin_write (struct usb_serial_port *port,
-                        const unsigned char *buf, int count)
+static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                        const unsigned char *buf, int count)
 {
        int pktid, pktsiz, len;
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
        __le32 *privpkt = (__le32 *)garmin_data_p->privpkt;
 
        usb_serial_debug_data(debug, &port->dev, __func__, count, buf);
 
        /* check for our private packets */
        if (count >= GARMIN_PKTHDR_LENGTH) {
-
                len = PRIVPKTSIZ;
                if (count < len)
                        len = count;
@@ -1169,15 +1162,16 @@ static int garmin_write (struct usb_serial_port *port,
                pktid  = getPacketId(garmin_data_p->privpkt);
 
                if (count == (GARMIN_PKTHDR_LENGTH+pktsiz)
-                   && GARMIN_LAYERID_PRIVATE == getLayerId(garmin_data_p->privpkt)) {
+                   && GARMIN_LAYERID_PRIVATE ==
+                               getLayerId(garmin_data_p->privpkt)) {
 
                        dbg("%s - processing private request %d",
                                __func__, pktid);
 
-                       // drop all unfinished transfers
+                       /* drop all unfinished transfers */
                        garmin_clear(garmin_data_p);
 
-                       switch(pktid) {
+                       switch (pktid) {
 
                        case PRIV_PKTID_SET_DEBUG:
                                if (pktsiz != 4)
@@ -1226,44 +1220,31 @@ static int garmin_write (struct usb_serial_port *port,
 }
 
 
-static int garmin_write_room (struct usb_serial_port *port)
+static int garmin_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        /*
         * Report back the bytes currently available in the output buffer.
         */
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
        return GPS_OUT_BUFSIZ-garmin_data_p->outsize;
 }
 
 
-static int garmin_chars_in_buffer (struct usb_serial_port *port)
-{
-       /*
-        * Report back the number of bytes currently in our input buffer.
-        * Will this lock up the driver - the buffer contains an incomplete
-        * package which will not be written to the device until it
-        * has been completed ?
-        */
-       //struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
-       //return garmin_data_p->insize;
-       return 0;
-}
-
-
-static void garmin_read_process(struct garmin_data * garmin_data_p,
+static void garmin_read_process(struct garmin_data *garmin_data_p,
                                 unsigned char *data, unsigned data_length)
 {
        if (garmin_data_p->flags & FLAGS_DROP_DATA) {
                /* abort-transfer cmd is actice */
                dbg("%s - pkt dropped", __func__);
        } else if (garmin_data_p->state != STATE_DISCONNECTED &&
-                  garmin_data_p->state != STATE_RESET ) {
+               garmin_data_p->state != STATE_RESET) {
 
                /* remember any appl.layer packets, so we know
                   if a reset is required or not when closing
                   the device */
                if (0 == memcmp(data, GARMIN_APP_LAYER_REPLY,
-                               sizeof(GARMIN_APP_LAYER_REPLY))) {
+                               sizeof(GARMIN_APP_LAYER_REPLY))) {
                        atomic_inc(&garmin_data_p->resp_count);
                }
 
@@ -1273,9 +1254,8 @@ static void garmin_read_process(struct garmin_data * garmin_data_p,
                if (garmin_data_p->flags & FLAGS_QUEUING) {
                        pkt_add(garmin_data_p, data, data_length);
                } else if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
-                       if (getLayerId(data) == GARMIN_LAYERID_APPL) {
+                       if (getLayerId(data) == GARMIN_LAYERID_APPL)
                                pkt_add(garmin_data_p, data, data_length);
-                       }
                } else {
                        send_to_tty(garmin_data_p->port, data, data_length);
                }
@@ -1283,12 +1263,12 @@ static void garmin_read_process(struct garmin_data * garmin_data_p,
 }
 
 
-static void garmin_read_bulk_callback (struct urb *urb)
+static void garmin_read_bulk_callback(struct urb *urb)
 {
        unsigned long flags;
        struct usb_serial_port *port = urb->context;
        struct usb_serial *serial =  port->serial;
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
        unsigned char *data = urb->transfer_buffer;
        int status = urb->status;
        int retval;
@@ -1306,7 +1286,7 @@ static void garmin_read_bulk_callback (struct urb *urb)
                return;
        }
 
-       usb_serial_debug_data(debug, &port->dev, 
+       usb_serial_debug_data(debug, &port->dev,
                                __func__, urb->actual_length, data);
 
        garmin_read_process(garmin_data_p, data, urb->actual_length);
@@ -1340,13 +1320,13 @@ static void garmin_read_bulk_callback (struct urb *urb)
 }
 
 
-static void garmin_read_int_callback (struct urb *urb)
+static void garmin_read_int_callback(struct urb *urb)
 {
        unsigned long flags;
        int retval;
        struct usb_serial_port *port = urb->context;
        struct usb_serial *serial = port->serial;
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
        unsigned char *data = urb->transfer_buffer;
        int status = urb->status;
 
@@ -1372,30 +1352,31 @@ static void garmin_read_int_callback (struct urb *urb)
 
        if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) &&
            0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY,
-                       sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) {
+                               sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) {
 
                dbg("%s - bulk data available.", __func__);
 
                if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) {
 
                        /* bulk data available */
-                       usb_fill_bulk_urb (port->read_urb, serial->dev,
-                                       usb_rcvbulkpipe (serial->dev,
-                                       port->bulk_in_endpointAddress),
+                       usb_fill_bulk_urb(port->read_urb, serial->dev,
+                                       usb_rcvbulkpipe(serial->dev,
+                                               port->bulk_in_endpointAddress),
                                        port->read_urb->transfer_buffer,
                                        port->read_urb->transfer_buffer_length,
                                        garmin_read_bulk_callback, port);
                        retval = usb_submit_urb(port->read_urb, GFP_ATOMIC);
                        if (retval) {
                                dev_err(&port->dev,
-                                       "%s - failed submitting read urb, error %d\n",
-                               __func__, retval);
+                                "%s - failed submitting read urb, error %d\n",
+                                                       __func__, retval);
                        } else {
                                spin_lock_irqsave(&garmin_data_p->lock, flags);
                                garmin_data_p->flags |= FLAGS_BULK_IN_ACTIVE;
                                /* do not send this packet to the user */
                                garmin_data_p->ignorePkts = 1;
-                               spin_unlock_irqrestore(&garmin_data_p->lock, flags);
+                               spin_unlock_irqrestore(&garmin_data_p->lock,
+                                                                       flags);
                        }
                } else {
                        /* bulk-in transfer still active */
@@ -1406,15 +1387,15 @@ static void garmin_read_int_callback (struct urb *urb)
 
        } else if (urb->actual_length == (4+sizeof(GARMIN_START_SESSION_REPLY))
                         && 0 == memcmp(data, GARMIN_START_SESSION_REPLY,
-                                       sizeof(GARMIN_START_SESSION_REPLY))) {
+                                       sizeof(GARMIN_START_SESSION_REPLY))) {
 
                spin_lock_irqsave(&garmin_data_p->lock, flags);
                garmin_data_p->flags |= FLAGS_SESSION_REPLY1_SEEN;
                spin_unlock_irqrestore(&garmin_data_p->lock, flags);
 
                /* save the serial number */
-               garmin_data_p->serial_num 
-                       = __le32_to_cpup((__le32*)(data+GARMIN_PKTHDR_LENGTH));
+               garmin_data_p->serial_num = __le32_to_cpup(
+                                       (__le32 *)(data+GARMIN_PKTHDR_LENGTH));
 
                dbg("%s - start-of-session reply seen - serial %u.",
                        __func__, garmin_data_p->serial_num);
@@ -1433,7 +1414,7 @@ static void garmin_read_int_callback (struct urb *urb)
        }
 
        port->interrupt_in_urb->dev = port->serial->dev;
-       retval = usb_submit_urb (urb, GFP_ATOMIC);
+       retval = usb_submit_urb(urb, GFP_ATOMIC);
        if (retval)
                dev_err(&urb->dev->dev,
                        "%s - Error %d submitting interrupt urb\n",
@@ -1446,7 +1427,7 @@ static void garmin_read_int_callback (struct urb *urb)
  * and then sets a timer to call itself again until all queued data
  * is sent.
  */
-static int garmin_flush_queue(struct garmin_data * garmin_data_p)
+static int garmin_flush_queue(struct garmin_data *garmin_data_p)
 {
        unsigned long flags;
        struct garmin_packet *pkt;
@@ -1468,10 +1449,11 @@ static int garmin_flush_queue(struct garmin_data * garmin_data_p)
 }
 
 
-static void garmin_throttle (struct usb_serial_port *port)
+static void garmin_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
        unsigned long flags;
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
 
        dbg("%s - port %d", __func__, port->number);
        /* set flag, data received will be put into a queue
@@ -1482,10 +1464,11 @@ static void garmin_throttle (struct usb_serial_port *port)
 }
 
 
-static void garmin_unthrottle (struct usb_serial_port *port)
+static void garmin_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
        unsigned long flags;
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
        int status;
 
        dbg("%s - port %d", __func__, port->number);
@@ -1507,8 +1490,6 @@ static void garmin_unthrottle (struct usb_serial_port *port)
        }
 }
 
-
-
 /*
  * The timer is currently only used to send queued packets to
  * the tty in cases where the protocol provides no own handshaking
@@ -1526,11 +1507,11 @@ static void timeout_handler(unsigned long data)
 
 
 
-static int garmin_attach (struct usb_serial *serial)
+static int garmin_attach(struct usb_serial *serial)
 {
        int status = 0;
        struct usb_serial_port *port = serial->port[0];
-       struct garmin_data * garmin_data_p = NULL;
+       struct garmin_data *garmin_data_p = NULL;
 
        dbg("%s", __func__);
 
@@ -1542,7 +1523,7 @@ static int garmin_attach (struct usb_serial *serial)
        init_timer(&garmin_data_p->timer);
        spin_lock_init(&garmin_data_p->lock);
        INIT_LIST_HEAD(&garmin_data_p->pktlist);
-       //garmin_data_p->timer.expires = jiffies + session_timeout;
+       /* garmin_data_p->timer.expires = jiffies + session_timeout; */
        garmin_data_p->timer.data = (unsigned long)garmin_data_p;
        garmin_data_p->timer.function = timeout_handler;
        garmin_data_p->port = port;
@@ -1556,16 +1537,16 @@ static int garmin_attach (struct usb_serial *serial)
 }
 
 
-static void garmin_shutdown (struct usb_serial *serial)
+static void garmin_shutdown(struct usb_serial *serial)
 {
        struct usb_serial_port *port = serial->port[0];
-       struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
+       struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
 
        dbg("%s", __func__);
 
-       usb_kill_urb (port->interrupt_in_urb);
+       usb_kill_urb(port->interrupt_in_urb);
        del_timer_sync(&garmin_data_p->timer);
-       kfree (garmin_data_p);
+       kfree(garmin_data_p);
        usb_set_serial_port_data(port, NULL);
 }
 
@@ -1588,7 +1569,6 @@ static struct usb_serial_driver garmin_device = {
        .shutdown            = garmin_shutdown,
        .write               = garmin_write,
        .write_room          = garmin_write_room,
-       .chars_in_buffer     = garmin_chars_in_buffer,
        .write_bulk_callback = garmin_write_bulk_callback,
        .read_bulk_callback  = garmin_read_bulk_callback,
        .read_int_callback   = garmin_read_int_callback,
@@ -1596,7 +1576,7 @@ static struct usb_serial_driver garmin_device = {
 
 
 
-static int __init garmin_init (void)
+static int __init garmin_init(void)
 {
        int retval;
 
@@ -1616,10 +1596,10 @@ failed_garmin_register:
 }
 
 
-static void __exit garmin_exit (void)
+static void __exit garmin_exit(void)
 {
-       usb_deregister (&garmin_driver);
-       usb_serial_deregister (&garmin_device);
+       usb_deregister(&garmin_driver);
+       usb_serial_deregister(&garmin_device);
 }
 
 
@@ -1628,8 +1608,8 @@ static void __exit garmin_exit (void)
 module_init(garmin_init);
 module_exit(garmin_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IWUSR | S_IRUGO);
index 537f12a..fe84c88 100644 (file)
@@ -18,7 +18,7 @@
 #include <linux/moduleparam.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 
 static int debug;
@@ -81,7 +81,7 @@ static int generic_probe(struct usb_interface *interface,
 }
 #endif
 
-int usb_serial_generic_register (int _debug)
+int usb_serial_generic_register(int _debug)
 {
        int retval = 0;
 
@@ -89,10 +89,11 @@ int usb_serial_generic_register (int _debug)
 #ifdef CONFIG_USB_SERIAL_GENERIC
        generic_device_ids[0].idVendor = vendor;
        generic_device_ids[0].idProduct = product;
-       generic_device_ids[0].match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT;
+       generic_device_ids[0].match_flags =
+               USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT;
 
        /* register our generic driver with ourselves */
-       retval = usb_serial_register (&usb_serial_generic_device);
+       retval = usb_serial_register(&usb_serial_generic_device);
        if (retval)
                goto exit;
        retval = usb_register(&generic_driver);
@@ -103,16 +104,17 @@ exit:
        return retval;
 }
 
-void usb_serial_generic_deregister (void)
+void usb_serial_generic_deregister(void)
 {
 #ifdef CONFIG_USB_SERIAL_GENERIC
        /* remove our generic driver */
        usb_deregister(&generic_driver);
-       usb_serial_deregister (&usb_serial_generic_device);
+       usb_serial_deregister(&usb_serial_generic_device);
 #endif
 }
 
-int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
+int usb_serial_generic_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial *serial = port->serial;
        int result = 0;
@@ -120,11 +122,11 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
 
        dbg("%s - port %d", __func__, port->number);
 
-       /* force low_latency on so that our tty_push actually forces the data through, 
-          otherwise it is scheduled, and with high data rates (like with OHCI) data
-          can get lost. */
-       if (port->tty)
-               port->tty->low_latency = 1;
+       /* force low_latency on so that our tty_push actually forces the data
+          through, otherwise it is scheduled, and with high data rates (like
+          with OHCI) data can get lost. */
+       if (tty)
+               tty->low_latency = 1;
 
        /* clear the throttle flags */
        spin_lock_irqsave(&port->lock, flags);
@@ -135,8 +137,9 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
        /* if we have a bulk endpoint, start reading from it */
        if (serial->num_bulk_in) {
                /* Start reading from the device */
-               usb_fill_bulk_urb (port->read_urb, serial->dev,
-                                  usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
+               usb_fill_bulk_urb(port->read_urb, serial->dev,
+                                  usb_rcvbulkpipe(serial->dev,
+                                               port->bulk_in_endpointAddress),
                                   port->read_urb->transfer_buffer,
                                   port->read_urb->transfer_buffer_length,
                                   ((serial->type->read_bulk_callback) ?
@@ -145,14 +148,16 @@ int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp)
                                   port);
                result = usb_submit_urb(port->read_urb, GFP_KERNEL);
                if (result)
-                       dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
+                       dev_err(&port->dev,
+                           "%s - failed resubmitting read urb, error %d\n",
+                                                       __func__, result);
        }
 
        return result;
 }
 EXPORT_SYMBOL_GPL(usb_serial_generic_open);
 
-static void generic_cleanup (struct usb_serial_port *port)
+static void generic_cleanup(struct usb_serial_port *port)
 {
        struct usb_serial *serial = port->serial;
 
@@ -182,7 +187,7 @@ int usb_serial_generic_resume(struct usb_serial *serial)
 #endif
        for (i = 0; i < serial->num_ports; i++) {
                port = serial->port[i];
-               if (port->open_count && port->read_urb) {
+               if (port->port.count && port->read_urb) {
                        r = usb_submit_urb(port->read_urb, GFP_NOIO);
                        if (r < 0)
                                c++;
@@ -192,13 +197,15 @@ int usb_serial_generic_resume(struct usb_serial *serial)
        return c ? -EIO : 0;
 }
 
-void usb_serial_generic_close (struct usb_serial_port *port, struct file * filp)
+void usb_serial_generic_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        dbg("%s - port %d", __func__, port->number);
-       generic_cleanup (port);
+       generic_cleanup(port);
 }
 
-int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *buf, int count)
+int usb_serial_generic_write(struct tty_struct *tty,
+       struct usb_serial_port *port, const unsigned char *buf, int count)
 {
        struct usb_serial *serial = port->serial;
        int result;
@@ -208,7 +215,7 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *
 
        if (count == 0) {
                dbg("%s - write request of 0 bytes", __func__);
-               return (0);
+               return 0;
        }
 
        /* only do something if we have a bulk out endpoint */
@@ -223,27 +230,32 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *
                port->write_urb_busy = 1;
                spin_unlock_irqrestore(&port->lock, flags);
 
-               count = (count > port->bulk_out_size) ? port->bulk_out_size : count;
+               count = (count > port->bulk_out_size) ?
+                                       port->bulk_out_size : count;
 
-               memcpy (port->write_urb->transfer_buffer, buf, count);
+               memcpy(port->write_urb->transfer_buffer, buf, count);
                data = port->write_urb->transfer_buffer;
                usb_serial_debug_data(debug, &port->dev, __func__, count, data);
 
                /* set up our urb */
-               usb_fill_bulk_urb (port->write_urb, serial->dev,
-                                  usb_sndbulkpipe (serial->dev,
-                                                   port->bulk_out_endpointAddress),
+               usb_fill_bulk_urb(port->write_urb, serial->dev,
+                                  usb_sndbulkpipe(serial->dev,
+                                       port->bulk_out_endpointAddress),
                                   port->write_urb->transfer_buffer, count,
-                                  ((serial->type->write_bulk_callback) ? 
+                                  ((serial->type->write_bulk_callback) ?
                                     serial->type->write_bulk_callback :
-                                    usb_serial_generic_write_bulk_callback), port);
+                                    usb_serial_generic_write_bulk_callback),
+                                  port);
 
                /* send the data out the bulk port */
                port->write_urb_busy = 1;
                result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
                if (result) {
-                       dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __func__, result);
-                       /* don't have to grab the lock here, as we will retry if != 0 */
+                       dev_err(&port->dev,
+                               "%s - failed submitting write urb, error %d\n",
+                                                       __func__, result);
+                       /* don't have to grab the lock here, as we will
+                          retry if != 0 */
                        port->write_urb_busy = 0;
                } else
                        result = count;
@@ -255,8 +267,9 @@ int usb_serial_generic_write(struct usb_serial_port *port, const unsigned char *
        return 0;
 }
 
-int usb_serial_generic_write_room (struct usb_serial_port *port)
+int usb_serial_generic_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
        int room = 0;
 
@@ -272,8 +285,9 @@ int usb_serial_generic_write_room (struct usb_serial_port *port)
        return room;
 }
 
-int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port)
+int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
        int chars = 0;
 
@@ -286,7 +300,7 @@ int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port)
        }
 
        dbg("%s - returns %d", __func__, chars);
-       return (chars);
+       return chars;
 }
 
 
@@ -297,24 +311,26 @@ static void resubmit_read_urb(struct usb_serial_port *port, gfp_t mem_flags)
        int result;
 
        /* Continue reading from device */
-       usb_fill_bulk_urb (urb, serial->dev,
-                          usb_rcvbulkpipe (serial->dev,
-                                           port->bulk_in_endpointAddress),
+       usb_fill_bulk_urb(urb, serial->dev,
+                          usb_rcvbulkpipe(serial->dev,
+                                       port->bulk_in_endpointAddress),
                           urb->transfer_buffer,
                           urb->transfer_buffer_length,
-                          ((serial->type->read_bulk_callback) ? 
-                            serial->type->read_bulk_callback : 
+                          ((serial->type->read_bulk_callback) ?
+                            serial->type->read_bulk_callback :
                             usb_serial_generic_read_bulk_callback), port);
        result = usb_submit_urb(urb, mem_flags);
        if (result)
-               dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
+               dev_err(&port->dev,
+                       "%s - failed resubmitting read urb, error %d\n",
+                                                       __func__, result);
 }
 
 /* Push data to tty layer and resubmit the bulk read URB */
-static void flush_and_resubmit_read_urb (struct usb_serial_port *port)
+static void flush_and_resubmit_read_urb(struct usb_serial_port *port)
 {
        struct urb *urb = port->read_urb;
-       struct tty_struct *tty = port->tty;
+       struct tty_struct *tty = port->port.tty;
        int room;
 
        /* Push data to tty */
@@ -329,7 +345,7 @@ static void flush_and_resubmit_read_urb (struct usb_serial_port *port)
        resubmit_read_urb(port, GFP_ATOMIC);
 }
 
-void usb_serial_generic_read_bulk_callback (struct urb *urb)
+void usb_serial_generic_read_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        unsigned char *data = urb->transfer_buffer;
@@ -344,20 +360,21 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb)
                return;
        }
 
-       usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                               urb->actual_length, data);
 
        /* Throttle the device if requested by tty */
        spin_lock_irqsave(&port->lock, flags);
-       if (!(port->throttled = port->throttle_req)) {
+       port->throttled = port->throttle_req;
+       if (!port->throttled) {
                spin_unlock_irqrestore(&port->lock, flags);
                flush_and_resubmit_read_urb(port);
-       } else {
+       } else
                spin_unlock_irqrestore(&port->lock, flags);
-       }
 }
 EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
 
-void usb_serial_generic_write_bulk_callback (struct urb *urb)
+void usb_serial_generic_write_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        int status = urb->status;
@@ -374,8 +391,9 @@ void usb_serial_generic_write_bulk_callback (struct urb *urb)
 }
 EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback);
 
-void usb_serial_generic_throttle (struct usb_serial_port *port)
+void usb_serial_generic_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        unsigned long flags;
 
        dbg("%s - port %d", __func__, port->number);
@@ -387,8 +405,9 @@ void usb_serial_generic_throttle (struct usb_serial_port *port)
        spin_unlock_irqrestore(&port->lock, flags);
 }
 
-void usb_serial_generic_unthrottle (struct usb_serial_port *port)
+void usb_serial_generic_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        int was_throttled;
        unsigned long flags;
 
@@ -406,15 +425,14 @@ void usb_serial_generic_unthrottle (struct usb_serial_port *port)
        }
 }
 
-void usb_serial_generic_shutdown (struct usb_serial *serial)
+void usb_serial_generic_shutdown(struct usb_serial *serial)
 {
        int i;
 
        dbg("%s", __func__);
 
        /* stop reads and writes on all ports */
-       for (i=0; i < serial->num_ports; ++i) {
+       for (i = 0; i < serial->num_ports; ++i)
                generic_cleanup(serial->port[i]);
-       }
 }
 
index 75b88b3..ab90586 100644 (file)
@@ -9,7 +9,8 @@
  *     the Free Software Foundation; either version 2 of the License, or
  *     (at your option) any later version.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  */
 
 #include <linux/kernel.h>
index 2fd449b..bfa508d 100644 (file)
@@ -44,7 +44,7 @@
 #include <linux/wait.h>
 #include <linux/firmware.h>
 #include <linux/ihex.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include "io_edgeport.h"
 
 /* receive port state */
 enum RXSTATE {
-       EXPECT_HDR1 = 0,        /* Expect header byte 1 */
-       EXPECT_HDR2 = 1,        /* Expect header byte 2 */
-       EXPECT_DATA = 2,        /* Expect 'RxBytesRemaining' data */
-       EXPECT_HDR3 = 3,        /* Expect header byte 3 (for status hdrs only) */
+       EXPECT_HDR1 = 0,    /* Expect header byte 1 */
+       EXPECT_HDR2 = 1,    /* Expect header byte 2 */
+       EXPECT_DATA = 2,    /* Expect 'RxBytesRemaining' data */
+       EXPECT_HDR3 = 3,    /* Expect header byte 3 (for status hdrs only) */
 };
 
 
-/* Transmit Fifo 
- * This Transmit queue is an extension of the edgeport Rx buffer. 
- * The maximum amount of data buffered in both the edgeport 
+/* Transmit Fifo
+ * This Transmit queue is an extension of the edgeport Rx buffer.
+ * The maximum amount of data buffered in both the edgeport
  * Rx buffer (maxTxCredits) and this buffer will never exceed maxTxCredits.
  */
 struct TxFifo {
@@ -132,12 +132,12 @@ struct edgeport_serial {
        int                     is_epic;                        /* flag if EPiC device or not */
 
        __u8                    interrupt_in_endpoint;          /* the interrupt endpoint handle */
-       unsigned char *         interrupt_in_buffer;            /* the buffer we use for the interrupt endpoint */
-       struct urb *            interrupt_read_urb;             /* our interrupt urb */
+       unsigned char           *interrupt_in_buffer;           /* the buffer we use for the interrupt endpoint */
+       struct urb              *interrupt_read_urb;            /* our interrupt urb */
 
        __u8                    bulk_in_endpoint;               /* the bulk in endpoint handle */
-       unsigned char *         bulk_in_buffer;                 /* the buffer we use for the bulk in endpoint */
-       struct urb *            read_urb;                       /* our bulk read urb */
+       unsigned char           *bulk_in_buffer;                /* the buffer we use for the bulk in endpoint */
+       struct urb              *read_urb;                      /* our bulk read urb */
        bool                    read_in_progress;
        spinlock_t              es_lock;
 
@@ -162,16 +162,17 @@ struct divisor_table_entry {
        __u16  Divisor;
 };
 
-//
-// Define table of divisors for Rev A EdgePort/4 hardware
-// These assume a 3.6864MHz crystal, the standard /16, and
-// MCR.7 = 0.
-//
+/*
+ * Define table of divisors for Rev A EdgePort/4 hardware
+ * These assume a 3.6864MHz crystal, the standard /16, and
+ * MCR.7 = 0.
+ */
+
 static const struct divisor_table_entry divisor_table[] = {
-       {   50,         4608},  
-       {   75,         3072},  
-       {   110,        2095},          /* 2094.545455 => 230450   => .0217 % over */
-       {   134,        1713},          /* 1713.011152 => 230398.5 => .00065% under */
+       {   50,         4608},
+       {   75,         3072},
+       {   110,        2095},  /* 2094.545455 => 230450   => .0217 % over */
+       {   134,        1713},  /* 1713.011152 => 230398.5 => .00065% under */
        {   150,        1536},
        {   300,        768},
        {   600,        384},
@@ -194,64 +195,86 @@ static int debug;
 
 static int low_latency = 1;    /* tty low latency flag, on by default */
 
-static atomic_t CmdUrbs;               /* Number of outstanding Command Write Urbs */
+static atomic_t CmdUrbs;       /* Number of outstanding Command Write Urbs */
 
 
 /* local function prototypes */
 
 /* function prototypes for all URB callbacks */
-static void edge_interrupt_callback    (struct urb *urb);
-static void edge_bulk_in_callback      (struct urb *urb);
-static void edge_bulk_out_data_callback        (struct urb *urb);
-static void edge_bulk_out_cmd_callback (struct urb *urb);
+static void edge_interrupt_callback(struct urb *urb);
+static void edge_bulk_in_callback(struct urb *urb);
+static void edge_bulk_out_data_callback(struct urb *urb);
+static void edge_bulk_out_cmd_callback(struct urb *urb);
 
 /* function prototypes for the usbserial callbacks */
-static int  edge_open                  (struct usb_serial_port *port, struct file *filp);
-static void edge_close                 (struct usb_serial_port *port, struct file *filp);
-static int  edge_write                 (struct usb_serial_port *port, const unsigned char *buf, int count);
-static int  edge_write_room            (struct usb_serial_port *port);
-static int  edge_chars_in_buffer       (struct usb_serial_port *port);
-static void edge_throttle              (struct usb_serial_port *port);
-static void edge_unthrottle            (struct usb_serial_port *port);
-static void edge_set_termios           (struct usb_serial_port *port, struct ktermios *old_termios);
-static int  edge_ioctl                 (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg);
-static void edge_break                 (struct usb_serial_port *port, int break_state);
-static int  edge_tiocmget              (struct usb_serial_port *port, struct file *file);
-static int  edge_tiocmset              (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
-static int  edge_startup               (struct usb_serial *serial);
-static void edge_shutdown              (struct usb_serial *serial);
-
+static int edge_open(struct tty_struct *tty, struct usb_serial_port *port,
+                                       struct file *filp);
+static void edge_close(struct tty_struct *tty, struct usb_serial_port *port,
+                                       struct file *filp);
+static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count);
+static int edge_write_room(struct tty_struct *tty);
+static int edge_chars_in_buffer(struct tty_struct *tty);
+static void edge_throttle(struct tty_struct *tty);
+static void edge_unthrottle(struct tty_struct *tty);
+static void edge_set_termios(struct tty_struct *tty,
+                                       struct usb_serial_port *port,
+                                       struct ktermios *old_termios);
+static int  edge_ioctl(struct tty_struct *tty, struct file *file,
+                                       unsigned int cmd, unsigned long arg);
+static void edge_break(struct tty_struct *tty, int break_state);
+static int  edge_tiocmget(struct tty_struct *tty, struct file *file);
+static int  edge_tiocmset(struct tty_struct *tty, struct file *file,
+                                       unsigned int set, unsigned int clear);
+static int  edge_startup(struct usb_serial *serial);
+static void edge_shutdown(struct usb_serial *serial);
 
 #include "io_tables.h" /* all of the devices that this driver supports */
 
 /* function prototypes for all of our local functions */
-static void  process_rcvd_data         (struct edgeport_serial *edge_serial, unsigned char *buffer, __u16 bufferLength);
-static void process_rcvd_status                (struct edgeport_serial *edge_serial, __u8 byte2, __u8 byte3);
-static void edge_tty_recv                      (struct device *dev, struct tty_struct *tty, unsigned char *data, int length);
-static void handle_new_msr             (struct edgeport_port *edge_port, __u8 newMsr);
-static void handle_new_lsr             (struct edgeport_port *edge_port, __u8 lsrData, __u8 lsr, __u8 data);
-static int  send_iosp_ext_cmd          (struct edgeport_port *edge_port, __u8 command, __u8 param);
-static int  calc_baud_rate_divisor     (int baud_rate, int *divisor);
-static int  send_cmd_write_baud_rate   (struct edgeport_port *edge_port, int baudRate);
-static void change_port_settings       (struct edgeport_port *edge_port, struct ktermios *old_termios);
-static int  send_cmd_write_uart_register       (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue);
-static int  write_cmd_usb              (struct edgeport_port *edge_port, unsigned char *buffer, int writeLength);
-static void send_more_port_data                (struct edgeport_serial *edge_serial, struct edgeport_port *edge_port);
-
-static int  sram_write                 (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, const __u8 *data);
-static int  rom_read                   (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, __u8 *data);
-static int  rom_write                  (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, const __u8 *data);
-static void get_manufacturing_desc     (struct edgeport_serial *edge_serial);
-static void get_boot_desc              (struct edgeport_serial *edge_serial);
-static void load_application_firmware  (struct edgeport_serial *edge_serial);
-
-static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unicode_size);
-
-
-// ************************************************************************
-// ************************************************************************
-// ************************************************************************
-// ************************************************************************
+
+static void  process_rcvd_data(struct edgeport_serial *edge_serial,
+                               unsigned char *buffer, __u16 bufferLength);
+static void process_rcvd_status(struct edgeport_serial *edge_serial,
+                               __u8 byte2, __u8 byte3);
+static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
+                               unsigned char *data, int length);
+static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr);
+static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData,
+                               __u8 lsr, __u8 data);
+static int  send_iosp_ext_cmd(struct edgeport_port *edge_port, __u8 command,
+                               __u8 param);
+static int  calc_baud_rate_divisor(int baud_rate, int *divisor);
+static int  send_cmd_write_baud_rate(struct edgeport_port *edge_port,
+                               int baudRate);
+static void change_port_settings(struct tty_struct *tty,
+                               struct edgeport_port *edge_port,
+                               struct ktermios *old_termios);
+static int  send_cmd_write_uart_register(struct edgeport_port *edge_port,
+                               __u8 regNum, __u8 regValue);
+static int  write_cmd_usb(struct edgeport_port *edge_port,
+                               unsigned char *buffer, int writeLength);
+static void send_more_port_data(struct edgeport_serial *edge_serial,
+                               struct edgeport_port *edge_port);
+
+static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr,
+                                       __u16 length, const __u8 *data);
+static int rom_read(struct usb_serial *serial, __u16 extAddr, __u16 addr,
+                                               __u16 length, __u8 *data);
+static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr,
+                                       __u16 length, const __u8 *data);
+static void get_manufacturing_desc(struct edgeport_serial *edge_serial);
+static void get_boot_desc(struct edgeport_serial *edge_serial);
+static void load_application_firmware(struct edgeport_serial *edge_serial);
+
+static void unicode_to_ascii(char *string, int buflen,
+                               __le16 *unicode, int unicode_size);
+
+
+/* ************************************************************************ */
+/* ************************************************************************ */
+/* ************************************************************************ */
+/* ************************************************************************ */
 
 /************************************************************************
  *                                                                     *
@@ -261,7 +284,7 @@ static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unic
  *                             embedded in this driver                 *
  *                                                                     *
  ************************************************************************/
-static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)
+static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial)
 {
        __u32 BootCurVer;
        __u32 BootNewVer;
@@ -275,16 +298,14 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)
        int response;
 
        switch (edge_serial->product_info.iDownloadFile) {
-               case EDGE_DOWNLOAD_FILE_I930:
-                       fw_name = "edgeport/boot.fw";
-                       break;
-
-               case EDGE_DOWNLOAD_FILE_80251:
-                       fw_name = "edgeport/boot2.fw";
-                       break;
-
-               default:
-                       return;
+       case EDGE_DOWNLOAD_FILE_I930:
+               fw_name = "edgeport/boot.fw";
+               break;
+       case EDGE_DOWNLOAD_FILE_80251:
+               fw_name = "edgeport/boot2.fw";
+               break;
+       default:
+               return;
        }
 
        response = request_ihex_firmware(&fw, fw_name,
@@ -300,7 +321,7 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)
        BootMinorVersion = rec->data[1];
        BootBuildNumber = (rec->data[2] << 8) | rec->data[3];
 
-       // Check Boot Image Version
+       /* Check Boot Image Version */
        BootCurVer = (edge_serial->boot_descriptor.MajorVersion << 24) +
                     (edge_serial->boot_descriptor.MinorVersion << 16) +
                      le16_to_cpu(edge_serial->boot_descriptor.BuildNumber);
@@ -352,29 +373,29 @@ static void update_edgeport_E2PROM (struct edgeport_serial *edge_serial)
  *  Get string descriptor from device                                  *
  *                                                                     *
  ************************************************************************/
-static int get_string (struct usb_device *dev, int Id, char *string, int buflen)
+static int get_string(struct usb_device *dev, int Id, char *string, int buflen)
 {
        struct usb_string_descriptor StringDesc;
        struct usb_string_descriptor *pStringDesc;
 
-       dbg("%s - USB String ID = %d", __func__, Id );
+       dbg("%s - USB String ID = %d", __func__, Id);
 
-       if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, sizeof(StringDesc))) {
+       if (!usb_get_descriptor(dev, USB_DT_STRING, Id,
+                                       &StringDesc, sizeof(StringDesc)))
                return 0;
-       }
 
-       pStringDesc = kmalloc (StringDesc.bLength, GFP_KERNEL);
-
-       if (!pStringDesc) {
+       pStringDesc = kmalloc(StringDesc.bLength, GFP_KERNEL);
+       if (!pStringDesc)
                return 0;
-       }
 
-       if (!usb_get_descriptor(dev, USB_DT_STRING, Id, pStringDesc, StringDesc.bLength )) {
+       if (!usb_get_descriptor(dev, USB_DT_STRING, Id,
+                                       pStringDesc, StringDesc.bLength)) {
                kfree(pStringDesc);
                return 0;
        }
 
-       unicode_to_ascii(string, buflen, pStringDesc->wData, pStringDesc->bLength/2);
+       unicode_to_ascii(string, buflen,
+                               pStringDesc->wData, pStringDesc->bLength/2);
 
        kfree(pStringDesc);
        dbg("%s - USB String %s", __func__, string);
@@ -388,24 +409,24 @@ static int get_string (struct usb_device *dev, int Id, char *string, int buflen)
  *  Get string descriptor from device
  *
  ************************************************************************/
-static int get_string_desc (struct usb_device *dev, int Id, struct usb_string_descriptor **pRetDesc)
+static int get_string_desc(struct usb_device *dev, int Id,
+                               struct usb_string_descriptor **pRetDesc)
 {
        struct usb_string_descriptor StringDesc;
        struct usb_string_descriptor *pStringDesc;
 
-       dbg("%s - USB String ID = %d", __func__, Id );
+       dbg("%s - USB String ID = %d", __func__, Id);
 
-       if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, sizeof(StringDesc))) {
+       if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc,
+                                               sizeof(StringDesc)))
                return 0;
-       }
 
-       pStringDesc = kmalloc (StringDesc.bLength, GFP_KERNEL);
-
-       if (!pStringDesc) {
+       pStringDesc = kmalloc(StringDesc.bLength, GFP_KERNEL);
+       if (!pStringDesc)
                return -1;
-       }
 
-       if (!usb_get_descriptor(dev, USB_DT_STRING, Id, pStringDesc, StringDesc.bLength )) {
+       if (!usb_get_descriptor(dev, USB_DT_STRING, Id, pStringDesc,
+                                                       StringDesc.bLength)) {
                kfree(pStringDesc);
                return -1;
        }
@@ -417,25 +438,30 @@ static int get_string_desc (struct usb_device *dev, int Id, struct usb_string_de
 
 static void dump_product_info(struct edgeport_product_info *product_info)
 {
-       // Dump Product Info structure
+       /* Dump Product Info structure */
        dbg("**Product Information:");
-       dbg("  ProductId             %x", product_info->ProductId );
-       dbg("  NumPorts              %d", product_info->NumPorts );
-       dbg("  ProdInfoVer           %d", product_info->ProdInfoVer );
+       dbg("  ProductId             %x", product_info->ProductId);
+       dbg("  NumPorts              %d", product_info->NumPorts);
+       dbg("  ProdInfoVer           %d", product_info->ProdInfoVer);
        dbg("  IsServer              %d", product_info->IsServer);
-       dbg("  IsRS232               %d", product_info->IsRS232 );
-       dbg("  IsRS422               %d", product_info->IsRS422 );
-       dbg("  IsRS485               %d", product_info->IsRS485 );
-       dbg("  RomSize               %d", product_info->RomSize );
-       dbg("  RamSize               %d", product_info->RamSize );
-       dbg("  CpuRev                %x", product_info->CpuRev  );
+       dbg("  IsRS232               %d", product_info->IsRS232);
+       dbg("  IsRS422               %d", product_info->IsRS422);
+       dbg("  IsRS485               %d", product_info->IsRS485);
+       dbg("  RomSize               %d", product_info->RomSize);
+       dbg("  RamSize               %d", product_info->RamSize);
+       dbg("  CpuRev                %x", product_info->CpuRev);
        dbg("  BoardRev              %x", product_info->BoardRev);
        dbg("  BootMajorVersion      %d.%d.%d", product_info->BootMajorVersion,
            product_info->BootMinorVersion,
            le16_to_cpu(product_info->BootBuildNumber));
-       dbg("  ManufactureDescDate   %d/%d/%d", product_info->ManufactureDescDate[0],
-           product_info->ManufactureDescDate[1],
-           product_info->ManufactureDescDate[2]+1900);
+       dbg("  FirmwareMajorVersion  %d.%d.%d",
+                       product_info->FirmwareMajorVersion,
+                       product_info->FirmwareMinorVersion,
+                       le16_to_cpu(product_info->FirmwareBuildNumber));
+       dbg("  ManufactureDescDate   %d/%d/%d",
+                       product_info->ManufactureDescDate[0],
+                       product_info->ManufactureDescDate[1],
+                       product_info->ManufactureDescDate[2]+1900);
        dbg("  iDownloadFile         0x%x", product_info->iDownloadFile);
        dbg("  EpicVer               %d", product_info->EpicVer);
 }
@@ -444,55 +470,60 @@ static void get_product_info(struct edgeport_serial *edge_serial)
 {
        struct edgeport_product_info *product_info = &edge_serial->product_info;
 
-       memset (product_info, 0, sizeof(struct edgeport_product_info));
-
-       product_info->ProductId         = (__u16)(le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) & ~ION_DEVICE_ID_80251_NETCHIP);
-       product_info->NumPorts          = edge_serial->manuf_descriptor.NumPorts;
-       product_info->ProdInfoVer       = 0;
-
-       product_info->RomSize           = edge_serial->manuf_descriptor.RomSize;
-       product_info->RamSize           = edge_serial->manuf_descriptor.RamSize;
-       product_info->CpuRev            = edge_serial->manuf_descriptor.CpuRev;
-       product_info->BoardRev          = edge_serial->manuf_descriptor.BoardRev;
-
-       product_info->BootMajorVersion  = edge_serial->boot_descriptor.MajorVersion;
-       product_info->BootMinorVersion  = edge_serial->boot_descriptor.MinorVersion;
-       product_info->BootBuildNumber   = edge_serial->boot_descriptor.BuildNumber;
-
-       memcpy(product_info->ManufactureDescDate, edge_serial->manuf_descriptor.DescDate, sizeof(edge_serial->manuf_descriptor.DescDate));
-
-       // check if this is 2nd generation hardware
-       if (le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) & ION_DEVICE_ID_80251_NETCHIP) {
-               product_info->iDownloadFile             = EDGE_DOWNLOAD_FILE_80251;
-       } else {
-               product_info->iDownloadFile             = EDGE_DOWNLOAD_FILE_I930;
-       }
-
-       // Determine Product type and set appropriate flags
+       memset(product_info, 0, sizeof(struct edgeport_product_info));
+
+       product_info->ProductId = (__u16)(le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct) & ~ION_DEVICE_ID_80251_NETCHIP);
+       product_info->NumPorts = edge_serial->manuf_descriptor.NumPorts;
+       product_info->ProdInfoVer = 0;
+
+       product_info->RomSize = edge_serial->manuf_descriptor.RomSize;
+       product_info->RamSize = edge_serial->manuf_descriptor.RamSize;
+       product_info->CpuRev = edge_serial->manuf_descriptor.CpuRev;
+       product_info->BoardRev = edge_serial->manuf_descriptor.BoardRev;
+
+       product_info->BootMajorVersion =
+                               edge_serial->boot_descriptor.MajorVersion;
+       product_info->BootMinorVersion =
+                               edge_serial->boot_descriptor.MinorVersion;
+       product_info->BootBuildNumber =
+                               edge_serial->boot_descriptor.BuildNumber;
+
+       memcpy(product_info->ManufactureDescDate,
+                       edge_serial->manuf_descriptor.DescDate,
+                       sizeof(edge_serial->manuf_descriptor.DescDate));
+
+       /* check if this is 2nd generation hardware */
+       if (le16_to_cpu(edge_serial->serial->dev->descriptor.idProduct)
+                                           & ION_DEVICE_ID_80251_NETCHIP)
+               product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251;
+       else
+               product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930;
+       /* Determine Product type and set appropriate flags */
        switch (DEVICE_ID_FROM_USB_PRODUCT_ID(product_info->ProductId)) {
-               case ION_DEVICE_ID_EDGEPORT_COMPATIBLE:
-               case ION_DEVICE_ID_EDGEPORT_4T:
-               case ION_DEVICE_ID_EDGEPORT_4:
-               case ION_DEVICE_ID_EDGEPORT_2:
-               case ION_DEVICE_ID_EDGEPORT_8_DUAL_CPU:
-               case ION_DEVICE_ID_EDGEPORT_8:
-               case ION_DEVICE_ID_EDGEPORT_421:
-               case ION_DEVICE_ID_EDGEPORT_21:
-               case ION_DEVICE_ID_EDGEPORT_2_DIN:
-               case ION_DEVICE_ID_EDGEPORT_4_DIN:
-               case ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU:
-                       product_info->IsRS232 = 1;
-                       break;
+       case ION_DEVICE_ID_EDGEPORT_COMPATIBLE:
+       case ION_DEVICE_ID_EDGEPORT_4T:
+       case ION_DEVICE_ID_EDGEPORT_4:
+       case ION_DEVICE_ID_EDGEPORT_2:
+       case ION_DEVICE_ID_EDGEPORT_8_DUAL_CPU:
+       case ION_DEVICE_ID_EDGEPORT_8:
+       case ION_DEVICE_ID_EDGEPORT_421:
+       case ION_DEVICE_ID_EDGEPORT_21:
+       case ION_DEVICE_ID_EDGEPORT_2_DIN:
+       case ION_DEVICE_ID_EDGEPORT_4_DIN:
+       case ION_DEVICE_ID_EDGEPORT_16_DUAL_CPU:
+               product_info->IsRS232 = 1;
+               break;
 
-               case ION_DEVICE_ID_EDGEPORT_2I:                            // Edgeport/2 RS422/RS485
-                       product_info->IsRS422 = 1;
-                       product_info->IsRS485 = 1;
-                       break;
+       case ION_DEVICE_ID_EDGEPORT_2I: /* Edgeport/2 RS422/RS485 */
+               product_info->IsRS422 = 1;
+               product_info->IsRS485 = 1;
+               break;
 
-               case ION_DEVICE_ID_EDGEPORT_8I:                            // Edgeport/4 RS422
-               case ION_DEVICE_ID_EDGEPORT_4I:                            // Edgeport/4 RS422
-                       product_info->IsRS422 = 1;
-                       break;
+       case ION_DEVICE_ID_EDGEPORT_8I: /* Edgeport/4 RS422 */
+       case ION_DEVICE_ID_EDGEPORT_4I: /* Edgeport/4 RS422 */
+               product_info->IsRS422 = 1;
+               break;
        }
 
        dump_product_info(product_info);
@@ -520,32 +551,32 @@ static int get_epic_descriptor(struct edgeport_serial *ep)
                ep->is_epic = 1;
                memset(product_info, 0, sizeof(struct edgeport_product_info));
 
-               product_info->NumPorts                  = epic->NumPorts;
-               product_info->ProdInfoVer               = 0;
-               product_info->FirmwareMajorVersion      = epic->MajorVersion;
-               product_info->FirmwareMinorVersion      = epic->MinorVersion;
-               product_info->FirmwareBuildNumber       = epic->BuildNumber;
-               product_info->iDownloadFile             = epic->iDownloadFile;
-               product_info->EpicVer                   = epic->EpicVer;
-               product_info->Epic                      = epic->Supports;
-               product_info->ProductId                 = ION_DEVICE_ID_EDGEPORT_COMPATIBLE;
+               product_info->NumPorts = epic->NumPorts;
+               product_info->ProdInfoVer = 0;
+               product_info->FirmwareMajorVersion = epic->MajorVersion;
+               product_info->FirmwareMinorVersion = epic->MinorVersion;
+               product_info->FirmwareBuildNumber = epic->BuildNumber;
+               product_info->iDownloadFile = epic->iDownloadFile;
+               product_info->EpicVer = epic->EpicVer;
+               product_info->Epic = epic->Supports;
+               product_info->ProductId = ION_DEVICE_ID_EDGEPORT_COMPATIBLE;
                dump_product_info(product_info);
 
                bits = &ep->epic_descriptor.Supports;
                dbg("**EPIC descriptor:");
                dbg("  VendEnableSuspend: %s", bits->VendEnableSuspend  ? "TRUE": "FALSE");
-               dbg("  IOSPOpen         : %s", bits->IOSPOpen           ? "TRUE": "FALSE" );
-               dbg("  IOSPClose        : %s", bits->IOSPClose          ? "TRUE": "FALSE" );
-               dbg("  IOSPChase        : %s", bits->IOSPChase          ? "TRUE": "FALSE" );
-               dbg("  IOSPSetRxFlow    : %s", bits->IOSPSetRxFlow      ? "TRUE": "FALSE" );
-               dbg("  IOSPSetTxFlow    : %s", bits->IOSPSetTxFlow      ? "TRUE": "FALSE" );
-               dbg("  IOSPSetXChar     : %s", bits->IOSPSetXChar       ? "TRUE": "FALSE" );
-               dbg("  IOSPRxCheck      : %s", bits->IOSPRxCheck        ? "TRUE": "FALSE" );
-               dbg("  IOSPSetClrBreak  : %s", bits->IOSPSetClrBreak    ? "TRUE": "FALSE" );
-               dbg("  IOSPWriteMCR     : %s", bits->IOSPWriteMCR       ? "TRUE": "FALSE" );
-               dbg("  IOSPWriteLCR     : %s", bits->IOSPWriteLCR       ? "TRUE": "FALSE" );
-               dbg("  IOSPSetBaudRate  : %s", bits->IOSPSetBaudRate    ? "TRUE": "FALSE" );
-               dbg("  TrueEdgeport     : %s", bits->TrueEdgeport       ? "TRUE": "FALSE" );
+               dbg("  IOSPOpen         : %s", bits->IOSPOpen           ? "TRUE": "FALSE");
+               dbg("  IOSPClose        : %s", bits->IOSPClose          ? "TRUE": "FALSE");
+               dbg("  IOSPChase        : %s", bits->IOSPChase          ? "TRUE": "FALSE");
+               dbg("  IOSPSetRxFlow    : %s", bits->IOSPSetRxFlow      ? "TRUE": "FALSE");
+               dbg("  IOSPSetTxFlow    : %s", bits->IOSPSetTxFlow      ? "TRUE": "FALSE");
+               dbg("  IOSPSetXChar     : %s", bits->IOSPSetXChar       ? "TRUE": "FALSE");
+               dbg("  IOSPRxCheck      : %s", bits->IOSPRxCheck        ? "TRUE": "FALSE");
+               dbg("  IOSPSetClrBreak  : %s", bits->IOSPSetClrBreak    ? "TRUE": "FALSE");
+               dbg("  IOSPWriteMCR     : %s", bits->IOSPWriteMCR       ? "TRUE": "FALSE");
+               dbg("  IOSPWriteLCR     : %s", bits->IOSPWriteLCR       ? "TRUE": "FALSE");
+               dbg("  IOSPSetBaudRate  : %s", bits->IOSPSetBaudRate    ? "TRUE": "FALSE");
+               dbg("  TrueEdgeport     : %s", bits->TrueEdgeport       ? "TRUE": "FALSE");
        }
 
        return result;
@@ -561,10 +592,10 @@ static int get_epic_descriptor(struct edgeport_serial *ep)
 
 /*****************************************************************************
  * edge_interrupt_callback
- *     this is the callback function for when we have received data on the 
+ *     this is the callback function for when we have received data on the
  *     interrupt endpoint.
  *****************************************************************************/
-static void edge_interrupt_callback (struct urb *urb)
+static void edge_interrupt_callback(struct urb *urb)
 {
        struct edgeport_serial  *edge_serial = urb->context;
        struct edgeport_port *edge_port;
@@ -589,17 +620,17 @@ static void edge_interrupt_callback (struct urb *urb)
        case -ESHUTDOWN:
                /* this urb is terminated, clean up */
                dbg("%s - urb shutting down with status: %d",
-                   __func__, status);
+                                               __func__, status);
                return;
        default:
-               dbg("%s - nonzero urb status received: %d",
-                   __func__, status);
+               dbg("%s - nonzero urb status received: %d", __func__, status);
                goto exit;
        }
 
-       // process this interrupt-read even if there are no ports open
+       /* process this interrupt-read even if there are no ports open */
        if (length) {
-               usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, length, data);
+               usb_serial_debug_data(debug, &edge_serial->serial->dev->dev,
+                                               __func__, length, data);
 
                if (length > 1) {
                        bytes_avail = data[0] | (data[1] << 8);
@@ -613,7 +644,8 @@ static void edge_interrupt_callback (struct urb *urb)
                                        dbg("%s - posting a read", __func__);
                                        edge_serial->read_in_progress = true;
 
-                                       /* we have pending bytes on the bulk in pipe, send a request */
+                                       /* we have pending bytes on the
+                                          bulk in pipe, send a request */
                                        edge_serial->read_urb->dev = edge_serial->serial->dev;
                                        result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC);
                                        if (result) {
@@ -627,7 +659,8 @@ static void edge_interrupt_callback (struct urb *urb)
                /* grab the txcredits for the ports if available */
                position = 2;
                portNumber = 0;
-               while ((position < length) && (portNumber < edge_serial->serial->num_ports)) {
+               while ((position < length) &&
+                               (portNumber < edge_serial->serial->num_ports)) {
                        txCredits = data[position] | (data[position+1] << 8);
                        if (txCredits) {
                                port = edge_serial->serial->port[portNumber];
@@ -636,14 +669,19 @@ static void edge_interrupt_callback (struct urb *urb)
                                        spin_lock(&edge_port->ep_lock);
                                        edge_port->txCredits += txCredits;
                                        spin_unlock(&edge_port->ep_lock);
-                                       dbg("%s - txcredits for port%d = %d", __func__, portNumber, edge_port->txCredits);
-
-                                       /* tell the tty driver that something has changed */
-                                       if (edge_port->port->tty)
-                                               tty_wakeup(edge_port->port->tty);
-
-                                       // Since we have more credit, check if more data can be sent
-                                       send_more_port_data(edge_serial, edge_port);
+                                       dbg("%s - txcredits for port%d = %d",
+                                                       __func__, portNumber,
+                                                       edge_port->txCredits);
+
+                                       /* tell the tty driver that something
+                                          has changed */
+                                       if (edge_port->port->port.tty)
+                                               tty_wakeup(edge_port->port->port.tty);
+
+                                       /* Since we have more credit, check
+                                          if more data can be sent */
+                                       send_more_port_data(edge_serial,
+                                                               edge_port);
                                }
                        }
                        position += 2;
@@ -652,19 +690,20 @@ static void edge_interrupt_callback (struct urb *urb)
        }
 
 exit:
-       result = usb_submit_urb (urb, GFP_ATOMIC);
-       if (result) {
-               dev_err(&urb->dev->dev, "%s - Error %d submitting control urb\n", __func__, result);
-       }
+       result = usb_submit_urb(urb, GFP_ATOMIC);
+       if (result)
+               dev_err(&urb->dev->dev,
+                       "%s - Error %d submitting control urb\n",
+                                               __func__, result);
 }
 
 
 /*****************************************************************************
  * edge_bulk_in_callback
- *     this is the callback function for when we have received data on the 
+ *     this is the callback function for when we have received data on the
  *     bulk in endpoint.
  *****************************************************************************/
-static void edge_bulk_in_callback (struct urb *urb)
+static void edge_bulk_in_callback(struct urb *urb)
 {
        struct edgeport_serial  *edge_serial = urb->context;
        unsigned char           *data = urb->transfer_buffer;
@@ -689,16 +728,18 @@ static void edge_bulk_in_callback (struct urb *urb)
 
        raw_data_length = urb->actual_length;
 
-       usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, __func__, raw_data_length, data);
+       usb_serial_debug_data(debug, &edge_serial->serial->dev->dev,
+                                       __func__, raw_data_length, data);
 
        spin_lock(&edge_serial->es_lock);
 
        /* decrement our rxBytes available by the number that we just got */
        edge_serial->rxBytesAvail -= raw_data_length;
 
-       dbg("%s - Received = %d, rxBytesAvail %d", __func__, raw_data_length, edge_serial->rxBytesAvail);
+       dbg("%s - Received = %d, rxBytesAvail %d", __func__,
+                               raw_data_length, edge_serial->rxBytesAvail);
 
-       process_rcvd_data (edge_serial, data, urb->actual_length);
+       process_rcvd_data(edge_serial, data, urb->actual_length);
 
        /* check to see if there's any more data for us to read */
        if (edge_serial->rxBytesAvail > 0) {
@@ -721,10 +762,10 @@ static void edge_bulk_in_callback (struct urb *urb)
 
 /*****************************************************************************
  * edge_bulk_out_data_callback
- *     this is the callback function for when we have finished sending serial data
- *     on the bulk out endpoint.
+ *     this is the callback function for when we have finished sending
+ *     serial data on the bulk out endpoint.
  *****************************************************************************/
-static void edge_bulk_out_data_callback (struct urb *urb)
+static void edge_bulk_out_data_callback(struct urb *urb)
 {
        struct edgeport_port *edge_port = urb->context;
        struct tty_struct *tty;
@@ -737,27 +778,29 @@ static void edge_bulk_out_data_callback (struct urb *urb)
                    __func__, status);
        }
 
-       tty = edge_port->port->tty;
+       tty = edge_port->port->port.tty;
 
        if (tty && edge_port->open) {
-               /* let the tty driver wakeup if it has a special write_wakeup function */
+               /* let the tty driver wakeup if it has a special
+                  write_wakeup function */
                tty_wakeup(tty);
        }
 
-       // Release the Write URB
+       /* Release the Write URB */
        edge_port->write_in_progress = false;
 
-       // Check if more data needs to be sent
-       send_more_port_data((struct edgeport_serial *)(usb_get_serial_data(edge_port->port->serial)), edge_port);
+       /* Check if more data needs to be sent */
+       send_more_port_data((struct edgeport_serial *)
+               (usb_get_serial_data(edge_port->port->serial)), edge_port);
 }
 
 
 /*****************************************************************************
  * BulkOutCmdCallback
- *     this is the callback function for when we have finished sending a command
- *     on the bulk out endpoint.
+ *     this is the callback function for when we have finished sending a
+ *     command on the bulk out endpoint.
  *****************************************************************************/
-static void edge_bulk_out_cmd_callback (struct urb *urb)
+static void edge_bulk_out_cmd_callback(struct urb *urb)
 {
        struct edgeport_port *edge_port = urb->context;
        struct tty_struct *tty;
@@ -766,22 +809,24 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
        dbg("%s", __func__);
 
        atomic_dec(&CmdUrbs);
-       dbg("%s - FREE URB %p (outstanding %d)", __func__, urb, atomic_read(&CmdUrbs));
+       dbg("%s - FREE URB %p (outstanding %d)", __func__,
+                                       urb, atomic_read(&CmdUrbs));
 
 
        /* clean up the transfer buffer */
        kfree(urb->transfer_buffer);
 
        /* Free the command urb */
-       usb_free_urb (urb);
+       usb_free_urb(urb);
 
        if (status) {
-               dbg("%s - nonzero write bulk status received: %d", __func__, status);
+               dbg("%s - nonzero write bulk status received: %d",
+                                                       __func__, status);
                return;
        }
 
        /* Get pointer to tty */
-       tty = edge_port->port->tty;
+       tty = edge_port->port->port.tty;
 
        /* tell the tty driver that something has changed */
        if (tty && edge_port->open)
@@ -803,7 +848,8 @@ static void edge_bulk_out_cmd_callback (struct urb *urb)
  *     If successful, we return 0
  *     Otherwise we return a negative error number.
  *****************************************************************************/
-static int edge_open (struct usb_serial_port *port, struct file * filp)
+static int edge_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        struct usb_serial *serial;
@@ -815,55 +861,62 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
        if (edge_port == NULL)
                return -ENODEV;
 
-       if (port->tty)
-               port->tty->low_latency = low_latency;
+       if (tty)
+               tty->low_latency = low_latency;
 
-       /* see if we've set up our endpoint info yet (can't set it up in edge_startup
-          as the structures were not set up at that time.) */
+       /* see if we've set up our endpoint info yet (can't set it up
+          in edge_startup as the structures were not set up at that time.) */
        serial = port->serial;
        edge_serial = usb_get_serial_data(serial);
-       if (edge_serial == NULL) {
+       if (edge_serial == NULL)
                return -ENODEV;
-       }
        if (edge_serial->interrupt_in_buffer == NULL) {
                struct usb_serial_port *port0 = serial->port[0];
-               
+
                /* not set up yet, so do it now */
-               edge_serial->interrupt_in_buffer = port0->interrupt_in_buffer;
-               edge_serial->interrupt_in_endpoint = port0->interrupt_in_endpointAddress;
+               edge_serial->interrupt_in_buffer =
+                                       port0->interrupt_in_buffer;
+               edge_serial->interrupt_in_endpoint =
+                                       port0->interrupt_in_endpointAddress;
                edge_serial->interrupt_read_urb = port0->interrupt_in_urb;
                edge_serial->bulk_in_buffer = port0->bulk_in_buffer;
-               edge_serial->bulk_in_endpoint = port0->bulk_in_endpointAddress;
+               edge_serial->bulk_in_endpoint =
+                                       port0->bulk_in_endpointAddress;
                edge_serial->read_urb = port0->read_urb;
-               edge_serial->bulk_out_endpoint = port0->bulk_out_endpointAddress;
-       
+               edge_serial->bulk_out_endpoint =
+                                       port0->bulk_out_endpointAddress;
+
                /* set up our interrupt urb */
                usb_fill_int_urb(edge_serial->interrupt_read_urb,
-                                serial->dev,
-                                usb_rcvintpipe(serial->dev,
-                                               port0->interrupt_in_endpointAddress),
-                                port0->interrupt_in_buffer,
-                                edge_serial->interrupt_read_urb->transfer_buffer_length,
-                                edge_interrupt_callback, edge_serial,
-                                edge_serial->interrupt_read_urb->interval);
-               
+                     serial->dev,
+                     usb_rcvintpipe(serial->dev,
+                               port0->interrupt_in_endpointAddress),
+                     port0->interrupt_in_buffer,
+                     edge_serial->interrupt_read_urb->transfer_buffer_length,
+                     edge_interrupt_callback, edge_serial,
+                     edge_serial->interrupt_read_urb->interval);
+
                /* set up our bulk in urb */
                usb_fill_bulk_urb(edge_serial->read_urb, serial->dev,
-                                 usb_rcvbulkpipe(serial->dev,
-                                                 port0->bulk_in_endpointAddress),
-                                 port0->bulk_in_buffer,
-                                 edge_serial->read_urb->transfer_buffer_length,
-                                 edge_bulk_in_callback, edge_serial);
+                       usb_rcvbulkpipe(serial->dev,
+                               port0->bulk_in_endpointAddress),
+                       port0->bulk_in_buffer,
+                       edge_serial->read_urb->transfer_buffer_length,
+                       edge_bulk_in_callback, edge_serial);
                edge_serial->read_in_progress = false;
 
                /* start interrupt read for this edgeport
-                * this interrupt will continue as long as the edgeport is connected */
-               response = usb_submit_urb (edge_serial->interrupt_read_urb, GFP_KERNEL);
+                * this interrupt will continue as long
+                * as the edgeport is connected */
+               response = usb_submit_urb(edge_serial->interrupt_read_urb,
+                                                               GFP_KERNEL);
                if (response) {
-                       dev_err(&port->dev, "%s - Error %d submitting control urb\n", __func__, response);
+                       dev_err(&port->dev,
+                               "%s - Error %d submitting control urb\n",
+                                                       __func__, response);
                }
        }
-       
+
        /* initialize our wait queues */
        init_waitqueue_head(&edge_port->wait_open);
        init_waitqueue_head(&edge_port->wait_chase);
@@ -871,26 +924,29 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
        init_waitqueue_head(&edge_port->wait_command);
 
        /* initialize our icount structure */
-       memset (&(edge_port->icount), 0x00, sizeof(edge_port->icount));
+       memset(&(edge_port->icount), 0x00, sizeof(edge_port->icount));
 
        /* initialize our port settings */
-       edge_port->txCredits            = 0;                    /* Can't send any data yet */
-       edge_port->shadowMCR            = MCR_MASTER_IE;        /* Must always set this bit to enable ints! */
+       edge_port->txCredits = 0;       /* Can't send any data yet */
+       /* Must always set this bit to enable ints! */
+       edge_port->shadowMCR = MCR_MASTER_IE;
        edge_port->chaseResponsePending = false;
 
        /* send a open port command */
        edge_port->openPending = true;
        edge_port->open        = false;
-       response = send_iosp_ext_cmd (edge_port, IOSP_CMD_OPEN_PORT, 0);
+       response = send_iosp_ext_cmd(edge_port, IOSP_CMD_OPEN_PORT, 0);
 
        if (response < 0) {
-               dev_err(&port->dev, "%s - error sending open port command\n", __func__);
+               dev_err(&port->dev, "%s - error sending open port command\n",
+                                                               __func__);
                edge_port->openPending = false;
                return -ENODEV;
        }
 
        /* now wait for the port to be completely opened */
-       wait_event_timeout(edge_port->wait_open, !edge_port->openPending, OPEN_TIMEOUT);
+       wait_event_timeout(edge_port->wait_open, !edge_port->openPending,
+                                                               OPEN_TIMEOUT);
 
        if (!edge_port->open) {
                /* open timed out */
@@ -904,25 +960,26 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
        edge_port->txfifo.tail  = 0;
        edge_port->txfifo.count = 0;
        edge_port->txfifo.size  = edge_port->maxTxCredits;
-       edge_port->txfifo.fifo  = kmalloc (edge_port->maxTxCredits, GFP_KERNEL);
+       edge_port->txfifo.fifo  = kmalloc(edge_port->maxTxCredits, GFP_KERNEL);
 
        if (!edge_port->txfifo.fifo) {
                dbg("%s - no memory", __func__);
-               edge_close (port, filp);
+               edge_close(tty, port, filp);
                return -ENOMEM;
        }
 
        /* Allocate a URB for the write */
-       edge_port->write_urb = usb_alloc_urb (0, GFP_KERNEL);
+       edge_port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
        edge_port->write_in_progress = false;
 
        if (!edge_port->write_urb) {
                dbg("%s - no memory", __func__);
-               edge_close (port, filp);
+               edge_close(tty, port, filp);
                return -ENOMEM;
        }
 
-       dbg("%s(%d) - Initialize TX fifo to %d bytes", __func__, port->number, edge_port->maxTxCredits);
+       dbg("%s(%d) - Initialize TX fifo to %d bytes",
+                       __func__, port->number, edge_port->maxTxCredits);
 
        dbg("%s exited", __func__);
 
@@ -948,27 +1005,28 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
        int loop = 10;
 
        while (1) {
-               // Save Last credits
+               /* Save Last credits */
                lastCredits = edge_port->txCredits;
 
-               // Did we get our Chase response
+               /* Did we get our Chase response */
                if (!edge_port->chaseResponsePending) {
                        dbg("%s - Got Chase Response", __func__);
 
-                       // did we get all of our credit back?
-                       if (edge_port->txCredits == edge_port->maxTxCredits ) {
+                       /* did we get all of our credit back? */
+                       if (edge_port->txCredits == edge_port->maxTxCredits) {
                                dbg("%s - Got all credits", __func__);
                                return;
                        }
                }
 
-               // Block the thread for a while
-               prepare_to_wait(&edge_port->wait_chase, &wait, TASK_UNINTERRUPTIBLE);
+               /* Block the thread for a while */
+               prepare_to_wait(&edge_port->wait_chase, &wait,
+                                               TASK_UNINTERRUPTIBLE);
                schedule_timeout(timeout);
                finish_wait(&edge_port->wait_chase, &wait);
 
                if (lastCredits == edge_port->txCredits) {
-                       // No activity.. count down.
+                       /* No activity.. count down. */
                        loop--;
                        if (loop == 0) {
                                edge_port->chaseResponsePending = false;
@@ -976,8 +1034,9 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
                                return;
                        }
                } else {
-                       // Reset timeout value back to 10 seconds
-                       dbg("%s - Last %d, Current %d", __func__, lastCredits, edge_port->txCredits);
+                       /* Reset timeout value back to 10 seconds */
+                       dbg("%s - Last %d, Current %d", __func__,
+                                       lastCredits, edge_port->txCredits);
                        loop = 10;
                }
        }
@@ -994,7 +1053,7 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
  *             3. A timeout of 3 seconds without activity has expired
  *
  ************************************************************************/
-static void block_until_tx_empty (struct edgeport_port *edge_port)
+static void block_until_tx_empty(struct edgeport_port *edge_port)
 {
        DEFINE_WAIT(wait);
        struct TxFifo *fifo = &edge_port->txfifo;
@@ -1003,31 +1062,32 @@ static void block_until_tx_empty (struct edgeport_port *edge_port)
        int loop = 30;
 
        while (1) {
-               // Save Last count
+               /* Save Last count */
                lastCount = fifo->count;
 
-               // Is the Edgeport Buffer empty?
+               /* Is the Edgeport Buffer empty? */
                if (lastCount == 0) {
                        dbg("%s - TX Buffer Empty", __func__);
                        return;
                }
 
-               // Block the thread for a while
-               prepare_to_wait (&edge_port->wait_chase, &wait, TASK_UNINTERRUPTIBLE);
+               /* Block the thread for a while */
+               prepare_to_wait(&edge_port->wait_chase, &wait,
+                                               TASK_UNINTERRUPTIBLE);
                schedule_timeout(timeout);
                finish_wait(&edge_port->wait_chase, &wait);
 
                dbg("%s wait", __func__);
 
                if (lastCount == fifo->count) {
-                       // No activity.. count down.
+                       /* No activity.. count down. */
                        loop--;
                        if (loop == 0) {
                                dbg("%s - TIMEOUT", __func__);
                                return;
                        }
                } else {
-                       // Reset timeout value back to seconds
+                       /* Reset timeout value back to seconds */
                        loop = 30;
                }
        }
@@ -1038,20 +1098,21 @@ static void block_until_tx_empty (struct edgeport_port *edge_port)
  * edge_close
  *     this function is called by the tty driver when a port is closed
  *****************************************************************************/
-static void edge_close (struct usb_serial_port *port, struct file * filp)
+static void edge_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct edgeport_serial *edge_serial;
        struct edgeport_port *edge_port;
        int status;
 
        dbg("%s - port %d", __func__, port->number);
-                        
+
        edge_serial = usb_get_serial_data(port->serial);
        edge_port = usb_get_serial_port_data(port);
-       if ((edge_serial == NULL) || (edge_port == NULL))
+       if (edge_serial == NULL || edge_port == NULL)
                return;
-       
-       // block until tx is empty
+
+       /* block until tx is empty */
        block_until_tx_empty(edge_port);
 
        edge_port->closePending = true;
@@ -1063,13 +1124,12 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
                edge_port->chaseResponsePending = true;
 
                dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__);
-               status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0);
-               if (status == 0) {
-                       // block until chase finished
+               status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0);
+               if (status == 0)
+                       /* block until chase finished */
                        block_until_chase_response(edge_port);
-               } else {
+               else
                        edge_port->chaseResponsePending = false;
-               }
        }
 
        if ((!edge_serial->is_epic) ||
@@ -1077,10 +1137,10 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
             (edge_serial->epic_descriptor.Supports.IOSPClose))) {
               /* close the port */
                dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __func__);
-               send_iosp_ext_cmd (edge_port, IOSP_CMD_CLOSE_PORT, 0);
+               send_iosp_ext_cmd(edge_port, IOSP_CMD_CLOSE_PORT, 0);
        }
 
-       //port->close = true;
+       /* port->close = true; */
        edge_port->closePending = false;
        edge_port->open = false;
        edge_port->openPending = false;
@@ -1088,7 +1148,8 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
        usb_kill_urb(edge_port->write_urb);
 
        if (edge_port->write_urb) {
-               /* if this urb had a transfer buffer already (old transfer) free it */
+               /* if this urb had a transfer buffer already
+                               (old transfer) free it */
                kfree(edge_port->write_urb->transfer_buffer);
                usb_free_urb(edge_port->write_urb);
                edge_port->write_urb = NULL;
@@ -1097,16 +1158,17 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
        edge_port->txfifo.fifo = NULL;
 
        dbg("%s exited", __func__);
-}   
+}
 
 /*****************************************************************************
  * SerialWrite
- *     this function is called by the tty driver when data should be written to
- *     the port.
- *     If successful, we return the number of bytes written, otherwise we return
- *     a negative error number.
+ *     this function is called by the tty driver when data should be written
+ *     to the port.
+ *     If successful, we return the number of bytes written, otherwise we
+ *     return a negative error number.
  *****************************************************************************/
-static int edge_write (struct usb_serial_port *port, const unsigned char *data, int count)
+static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *data, int count)
 {
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        struct TxFifo *fifo;
@@ -1121,66 +1183,76 @@ static int edge_write (struct usb_serial_port *port, const unsigned char *data,
        if (edge_port == NULL)
                return -ENODEV;
 
-       // get a pointer to the Tx fifo
+       /* get a pointer to the Tx fifo */
        fifo = &edge_port->txfifo;
 
        spin_lock_irqsave(&edge_port->ep_lock, flags);
 
-       // calculate number of bytes to put in fifo
-       copySize = min ((unsigned int)count, (edge_port->txCredits - fifo->count));
+       /* calculate number of bytes to put in fifo */
+       copySize = min((unsigned int)count,
+                               (edge_port->txCredits - fifo->count));
 
-       dbg("%s(%d) of %d byte(s) Fifo room  %d -- will copy %d bytes", __func__,
-           port->number, count, edge_port->txCredits - fifo->count, copySize);
+       dbg("%s(%d) of %d byte(s) Fifo room  %d -- will copy %d bytes",
+                       __func__, port->number, count,
+                       edge_port->txCredits - fifo->count, copySize);
 
-       /* catch writes of 0 bytes which the tty driver likes to give us, and when txCredits is empty */
+       /* catch writes of 0 bytes which the tty driver likes to give us,
+          and when txCredits is empty */
        if (copySize == 0) {
                dbg("%s - copySize = Zero", __func__);
                goto finish_write;
        }
 
-       // queue the data       
-       // since we can never overflow the buffer we do not have to check for full condition
-
-       // the copy is done is two parts -- first fill to the end of the buffer
-       // then copy the reset from the start of the buffer 
-
+       /* queue the data
+        * since we can never overflow the buffer we do not have to check for a
+        * full condition
+        *
+        * the copy is done is two parts -- first fill to the end of the buffer
+        * then copy the reset from the start of the buffer
+        */
        bytesleft = fifo->size - fifo->head;
-       firsthalf = min (bytesleft, copySize);
-       dbg("%s - copy %d bytes of %d into fifo ", __func__, firsthalf, bytesleft);
+       firsthalf = min(bytesleft, copySize);
+       dbg("%s - copy %d bytes of %d into fifo ", __func__,
+                                       firsthalf, bytesleft);
 
        /* now copy our data */
        memcpy(&fifo->fifo[fifo->head], data, firsthalf);
-       usb_serial_debug_data(debug, &port->dev, __func__, firsthalf, &fifo->fifo[fifo->head]);
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                       firsthalf, &fifo->fifo[fifo->head]);
 
-       // update the index and size
+       /* update the index and size */
        fifo->head  += firsthalf;
        fifo->count += firsthalf;
 
-       // wrap the index
-       if (fifo->head == fifo->size) {
+       /* wrap the index */
+       if (fifo->head == fifo->size)
                fifo->head = 0;
-       }
 
        secondhalf = copySize-firsthalf;
 
        if (secondhalf) {
                dbg("%s - copy rest of data %d", __func__, secondhalf);
                memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf);
-               usb_serial_debug_data(debug, &port->dev, __func__, secondhalf, &fifo->fifo[fifo->head]);
-               // update the index and size
+               usb_serial_debug_data(debug, &port->dev, __func__,
+                                       secondhalf, &fifo->fifo[fifo->head]);
+               /* update the index and size */
                fifo->count += secondhalf;
                fifo->head  += secondhalf;
-               // No need to check for wrap since we can not get to end of fifo in this part
+               /* No need to check for wrap since we can not get to end of
+                * the fifo in this part
+                */
        }
 
 finish_write:
        spin_unlock_irqrestore(&edge_port->ep_lock, flags);
 
-       send_more_port_data((struct edgeport_serial *)usb_get_serial_data(port->serial), edge_port);
+       send_more_port_data((struct edgeport_serial *)
+                       usb_get_serial_data(port->serial), edge_port);
 
-       dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __func__, copySize, edge_port->txCredits, fifo->count);
+       dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __func__,
+                               copySize, edge_port->txCredits, fifo->count);
 
-       return copySize;   
+       return copySize;
 }
 
 
@@ -1197,7 +1269,8 @@ finish_write:
  *     can transmit more.
  *
  ************************************************************************/
-static void send_more_port_data(struct edgeport_serial *edge_serial, struct edgeport_port *edge_port)
+static void send_more_port_data(struct edgeport_serial *edge_serial,
+                                       struct edgeport_port *edge_port)
 {
        struct TxFifo   *fifo = &edge_port->txfifo;
        struct urb      *urb;
@@ -1216,67 +1289,78 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
        if (edge_port->write_in_progress ||
            !edge_port->open             ||
            (fifo->count == 0)) {
-               dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d", __func__, edge_port->port->number, fifo->count, edge_port->write_in_progress);
+               dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d",
+                               __func__, edge_port->port->number,
+                               fifo->count, edge_port->write_in_progress);
                goto exit_send;
        }
 
-       // since the amount of data in the fifo will always fit into the
-       // edgeport buffer we do not need to check the write length
-
-       //      Do we have enough credits for this port to make it worthwhile
-       //      to bother queueing a write. If it's too small, say a few bytes,
-       //      it's better to wait for more credits so we can do a larger
-       //      write.
-       if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits,EDGE_FW_BULK_MAX_PACKET_SIZE)) {
-               dbg("%s(%d) Not enough credit - fifo %d TxCredit %d", __func__, edge_port->port->number, fifo->count, edge_port->txCredits );
+       /* since the amount of data in the fifo will always fit into the
+        * edgeport buffer we do not need to check the write length
+        *
+        * Do we have enough credits for this port to make it worthwhile
+        * to bother queueing a write. If it's too small, say a few bytes,
+        * it's better to wait for more credits so we can do a larger write.
+        */
+       if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits, EDGE_FW_BULK_MAX_PACKET_SIZE)) {
+               dbg("%s(%d) Not enough credit - fifo %d TxCredit %d",
+                       __func__, edge_port->port->number, fifo->count,
+                       edge_port->txCredits);
                goto exit_send;
        }
 
-       // lock this write
+       /* lock this write */
        edge_port->write_in_progress = true;
 
-       // get a pointer to the write_urb
+       /* get a pointer to the write_urb */
        urb = edge_port->write_urb;
 
        /* make sure transfer buffer is freed */
        kfree(urb->transfer_buffer);
        urb->transfer_buffer = NULL;
 
-       /* build the data header for the buffer and port that we are about to send out */
+       /* build the data header for the buffer and port that we are about
+          to send out */
        count = fifo->count;
-       buffer = kmalloc (count+2, GFP_ATOMIC);
+       buffer = kmalloc(count+2, GFP_ATOMIC);
        if (buffer == NULL) {
-               dev_err(&edge_port->port->dev, "%s - no more kernel memory...\n", __func__);
+               dev_err(&edge_port->port->dev,
+                               "%s - no more kernel memory...\n", __func__);
                edge_port->write_in_progress = false;
                goto exit_send;
        }
-       buffer[0] = IOSP_BUILD_DATA_HDR1 (edge_port->port->number - edge_port->port->serial->minor, count);
-       buffer[1] = IOSP_BUILD_DATA_HDR2 (edge_port->port->number - edge_port->port->serial->minor, count);
+       buffer[0] = IOSP_BUILD_DATA_HDR1(edge_port->port->number
+                               - edge_port->port->serial->minor, count);
+       buffer[1] = IOSP_BUILD_DATA_HDR2(edge_port->port->number
+                               - edge_port->port->serial->minor, count);
 
        /* now copy our data */
        bytesleft =  fifo->size - fifo->tail;
-       firsthalf = min (bytesleft, count);
+       firsthalf = min(bytesleft, count);
        memcpy(&buffer[2], &fifo->fifo[fifo->tail], firsthalf);
        fifo->tail  += firsthalf;
        fifo->count -= firsthalf;
-       if (fifo->tail == fifo->size) {
+       if (fifo->tail == fifo->size)
                fifo->tail = 0;
-       }
 
        secondhalf = count-firsthalf;
        if (secondhalf) {
-               memcpy(&buffer[2+firsthalf], &fifo->fifo[fifo->tail], secondhalf);
+               memcpy(&buffer[2+firsthalf], &fifo->fifo[fifo->tail],
+                                                               secondhalf);
                fifo->tail  += secondhalf;
                fifo->count -= secondhalf;
        }
 
        if (count)
-               usb_serial_debug_data(debug, &edge_port->port->dev, __func__, count, &buffer[2]);
+               usb_serial_debug_data(debug, &edge_port->port->dev,
+                                               __func__, count, &buffer[2]);
 
        /* fill up the urb with all of our data and submit it */
-       usb_fill_bulk_urb (urb, edge_serial->serial->dev, 
-                      usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint),
-                      buffer, count+2, edge_bulk_out_data_callback, edge_port);
+       usb_fill_bulk_urb(urb, edge_serial->serial->dev,
+                       usb_sndbulkpipe(edge_serial->serial->dev,
+                                       edge_serial->bulk_out_endpoint),
+                       buffer, count+2,
+                       edge_bulk_out_data_callback, edge_port);
 
        /* decrement the number of credits we have by the number we just sent */
        edge_port->txCredits -= count;
@@ -1286,14 +1370,17 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, struct edge
        status = usb_submit_urb(urb, GFP_ATOMIC);
        if (status) {
                /* something went wrong */
-               dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", __func__, status);
+               dev_err(&edge_port->port->dev,
+                       "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n",
+                               __func__, status);
                edge_port->write_in_progress = false;
 
                /* revert the credits as something bad happened. */
                edge_port->txCredits += count;
                edge_port->icount.tx -= count;
        }
-       dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d", __func__, count, edge_port->txCredits, fifo->count);
+       dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d",
+                       __func__, count, edge_port->txCredits, fifo->count);
 
 exit_send:
        spin_unlock_irqrestore(&edge_port->ep_lock, flags);
@@ -1302,14 +1389,14 @@ exit_send:
 
 /*****************************************************************************
  * edge_write_room
- *     this function is called by the tty driver when it wants to know how many
- *     bytes of data we can accept for a specific port.
- *     If successful, we return the amount of room that we have for this port
- *     (the txCredits), 
- *     Otherwise we return a negative error number.
+ *     this function is called by the tty driver when it wants to know how
+ *     many bytes of data we can accept for a specific port. If successful,
+ *     we return the amount of room that we have for this port (the txCredits)
+ *     otherwise we return a negative error number.
  *****************************************************************************/
-static int edge_write_room (struct usb_serial_port *port)
+static int edge_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        int room;
        unsigned long flags;
@@ -1317,18 +1404,18 @@ static int edge_write_room (struct usb_serial_port *port)
        dbg("%s", __func__);
 
        if (edge_port == NULL)
-               return -ENODEV;
+               return 0;
        if (edge_port->closePending)
-               return -ENODEV;
+               return 0;
 
        dbg("%s - port %d", __func__, port->number);
 
        if (!edge_port->open) {
                dbg("%s - port not opened", __func__);
-               return -EINVAL;
+               return 0;
        }
 
-       // total of both buffers is still txCredit
+       /* total of both buffers is still txCredit */
        spin_lock_irqsave(&edge_port->ep_lock, flags);
        room = edge_port->txCredits - edge_port->txfifo.count;
        spin_unlock_irqrestore(&edge_port->ep_lock, flags);
@@ -1340,15 +1427,16 @@ static int edge_write_room (struct usb_serial_port *port)
 
 /*****************************************************************************
  * edge_chars_in_buffer
- *     this function is called by the tty driver when it wants to know how many
- *     bytes of data we currently have outstanding in the port (data that has
- *     been written, but hasn't made it out the port yet)
- *     If successful, we return the number of bytes left to be written in the 
- *     system, 
+ *     this function is called by the tty driver when it wants to know how
+ *     many bytes of data we currently have outstanding in the port (data that
+ *     has been written, but hasn't made it out the port yet)
+ *     If successful, we return the number of bytes left to be written in the
+ *     system,
  *     Otherwise we return a negative error number.
  *****************************************************************************/
-static int edge_chars_in_buffer (struct usb_serial_port *port)
+static int edge_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        int num_chars;
        unsigned long flags;
@@ -1356,20 +1444,22 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
        dbg("%s", __func__);
 
        if (edge_port == NULL)
-               return -ENODEV;
+               return 0;
        if (edge_port->closePending)
-               return -ENODEV;
+               return 0;
 
        if (!edge_port->open) {
                dbg("%s - port not opened", __func__);
-               return -EINVAL;
+               return 0;
        }
 
        spin_lock_irqsave(&edge_port->ep_lock, flags);
-       num_chars = edge_port->maxTxCredits - edge_port->txCredits + edge_port->txfifo.count;
+       num_chars = edge_port->maxTxCredits - edge_port->txCredits +
+                                               edge_port->txfifo.count;
        spin_unlock_irqrestore(&edge_port->ep_lock, flags);
        if (num_chars) {
-               dbg("%s(port %d) - returns %d", __func__, port->number, num_chars);
+               dbg("%s(port %d) - returns %d", __func__,
+                                               port->number, num_chars);
        }
 
        return num_chars;
@@ -1381,10 +1471,10 @@ static int edge_chars_in_buffer (struct usb_serial_port *port)
  *     this function is called by the tty driver when it wants to stop the data
  *     being read from the port.
  *****************************************************************************/
-static void edge_throttle (struct usb_serial_port *port)
+static void edge_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
-       struct tty_struct *tty;
        int status;
 
        dbg("%s - port %d", __func__, port->number);
@@ -1397,28 +1487,21 @@ static void edge_throttle (struct usb_serial_port *port)
                return;
        }
 
-       tty = port->tty;
-       if (!tty) {
-               dbg ("%s - no tty available", __func__);
-               return;
-       }
-
        /* if we are implementing XON/XOFF, send the stop character */
        if (I_IXOFF(tty)) {
                unsigned char stop_char = STOP_CHAR(tty);
-               status = edge_write (port, &stop_char, 1);
-               if (status <= 0) {
+               status = edge_write(tty, port, &stop_char, 1);
+               if (status <= 0)
                        return;
-               }
        }
 
        /* if we are implementing RTS/CTS, toggle that line */
        if (tty->termios->c_cflag & CRTSCTS) {
                edge_port->shadowMCR &= ~MCR_RTS;
-               status = send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR);
-               if (status != 0) {
+               status = send_cmd_write_uart_register(edge_port, MCR,
+                                                       edge_port->shadowMCR);
+               if (status != 0)
                        return;
-               }
        }
 
        return;
@@ -1427,13 +1510,13 @@ static void edge_throttle (struct usb_serial_port *port)
 
 /*****************************************************************************
  * edge_unthrottle
- *     this function is called by the tty driver when it wants to resume the data
- *     being read from the port (called after SerialThrottle is called)
+ *     this function is called by the tty driver when it wants to resume the
+ *     data being read from the port (called after SerialThrottle is called)
  *****************************************************************************/
-static void edge_unthrottle (struct usb_serial_port *port)
+static void edge_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
-       struct tty_struct *tty;
        int status;
 
        dbg("%s - port %d", __func__, port->number);
@@ -1446,43 +1529,31 @@ static void edge_unthrottle (struct usb_serial_port *port)
                return;
        }
 
-       tty = port->tty;
-       if (!tty) {
-               dbg ("%s - no tty available", __func__);
-               return;
-       }
-
        /* if we are implementing XON/XOFF, send the start character */
        if (I_IXOFF(tty)) {
                unsigned char start_char = START_CHAR(tty);
-               status = edge_write (port, &start_char, 1);
-               if (status <= 0) {
+               status = edge_write(tty, port, &start_char, 1);
+               if (status <= 0)
                        return;
-               }
        }
-
        /* if we are implementing RTS/CTS, toggle that line */
        if (tty->termios->c_cflag & CRTSCTS) {
                edge_port->shadowMCR |= MCR_RTS;
-               status = send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR);
-               if (status != 0) {
-                       return;
-               }
+               send_cmd_write_uart_register(edge_port, MCR,
+                                               edge_port->shadowMCR);
        }
-
-       return;
 }
 
 
 /*****************************************************************************
  * SerialSetTermios
- *     this function is called by the tty driver when it wants to change the termios structure
+ *     this function is called by the tty driver when it wants to change
+ * the termios structure
  *****************************************************************************/
-static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old_termios)
+static void edge_set_termios(struct tty_struct *tty,
+       struct usb_serial_port *port, struct ktermios *old_termios)
 {
-       /* FIXME: This function appears unused ?? */
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
-       struct tty_struct *tty = port->tty;
        unsigned int cflag;
 
        cflag = tty->termios->c_cflag;
@@ -1502,9 +1573,7 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old
        }
 
        /* change the port settings to the new ones specified */
-       change_port_settings (edge_port, old_termios);
-
-       return;
+       change_port_settings(tty, edge_port, old_termios);
 }
 
 
@@ -1516,9 +1585,10 @@ static void edge_set_termios (struct usb_serial_port *port, struct ktermios *old
  *         release the bus after transmitting. This must be done when
  *         the transmit shift register is empty, not be done when the
  *         transmit holding register is empty.  This functionality
- *         allows an RS485 driver to be written in user space. 
+ *         allows an RS485 driver to be written in user space.
  *****************************************************************************/
-static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *value)
+static int get_lsr_info(struct edgeport_port *edge_port,
+                                               unsigned int __user *value)
 {
        unsigned int result = 0;
        unsigned long flags;
@@ -1536,25 +1606,10 @@ static int get_lsr_info(struct edgeport_port *edge_port, unsigned int __user *va
        return 0;
 }
 
-static int get_number_bytes_avail(struct edgeport_port *edge_port, unsigned int __user *value)
-{
-       unsigned int result = 0;
-       struct tty_struct *tty = edge_port->port->tty;
-
-       if (!tty)
-               return -ENOIOCTLCMD;
-
-       result = tty->read_cnt;
-
-       dbg("%s(%d) = %d", __func__,  edge_port->port->number, result);
-       if (copy_to_user(value, &result, sizeof(int)))
-               return -EFAULT;
-       //return 0;
-       return -ENOIOCTLCMD;
-}
-
-static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear)
+static int edge_tiocmset(struct tty_struct *tty, struct file *file,
+                                       unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        unsigned int mcr;
 
@@ -1582,8 +1637,9 @@ static int edge_tiocmset (struct usb_serial_port *port, struct file *file, unsig
        return 0;
 }
 
-static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
+static int edge_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        unsigned int result = 0;
        unsigned int msr;
@@ -1606,7 +1662,8 @@ static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
        return result;
 }
 
-static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct __user *retinfo)
+static int get_serial_info(struct edgeport_port *edge_port,
+                               struct serial_struct __user *retinfo)
 {
        struct serial_struct tmp;
 
@@ -1624,9 +1681,6 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct
        tmp.baud_base           = 9600;
        tmp.close_delay         = 5*HZ;
        tmp.closing_wait        = 30*HZ;
-//     tmp.custom_divisor      = state->custom_divisor;
-//     tmp.hub6                = state->hub6;
-//     tmp.io_type             = state->io_type;
 
        if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
                return -EFAULT;
@@ -1639,8 +1693,10 @@ static int get_serial_info(struct edgeport_port *edge_port, struct serial_struct
  * SerialIoctl
  *     this function handles any ioctl calls to the driver
  *****************************************************************************/
-static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg)
+static int edge_ioctl(struct tty_struct *tty, struct file *file,
+                                       unsigned int cmd, unsigned long arg)
 {
+       struct usb_serial_port *port = tty->driver_data;
        DEFINE_WAIT(wait);
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        struct async_icount cnow;
@@ -1650,71 +1706,61 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
        dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
 
        switch (cmd) {
-               // return number of bytes available
-               case TIOCINQ:
-                       dbg("%s (%d) TIOCINQ", __func__,  port->number);
-                       return get_number_bytes_avail(edge_port, (unsigned int __user *) arg);
-                       break;
-
-               case TIOCSERGETLSR:
-                       dbg("%s (%d) TIOCSERGETLSR", __func__,  port->number);
-                       return get_lsr_info(edge_port, (unsigned int __user *) arg);
-                       return 0;
-
-               case TIOCGSERIAL:
-                       dbg("%s (%d) TIOCGSERIAL", __func__,  port->number);
-                       return get_serial_info(edge_port, (struct serial_struct __user *) arg);
-
-               case TIOCSSERIAL:
-                       dbg("%s (%d) TIOCSSERIAL", __func__,  port->number);
-                       break;
-
-               case TIOCMIWAIT:
-                       dbg("%s (%d) TIOCMIWAIT", __func__,  port->number);
-                       cprev = edge_port->icount;
-                       while (1) {
-                               prepare_to_wait(&edge_port->delta_msr_wait, &wait, TASK_INTERRUPTIBLE);
-                               schedule();
-                               finish_wait(&edge_port->delta_msr_wait, &wait);
-                               /* see if a signal did it */
-                               if (signal_pending(current))
-                                       return -ERESTARTSYS;
-                               cnow = edge_port->icount;
-                               if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
-                                   cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
-                                       return -EIO; /* no change => error */
-                               if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
-                                   ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
-                                   ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
-                                   ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
-                                       return 0;
-                               }
-                               cprev = cnow;
+       case TIOCSERGETLSR:
+               dbg("%s (%d) TIOCSERGETLSR", __func__,  port->number);
+               return get_lsr_info(edge_port, (unsigned int __user *) arg);
+
+       case TIOCGSERIAL:
+               dbg("%s (%d) TIOCGSERIAL", __func__,  port->number);
+               return get_serial_info(edge_port, (struct serial_struct __user *) arg);
+
+       case TIOCMIWAIT:
+               dbg("%s (%d) TIOCMIWAIT", __func__,  port->number);
+               cprev = edge_port->icount;
+               while (1) {
+                       prepare_to_wait(&edge_port->delta_msr_wait,
+                                               &wait, TASK_INTERRUPTIBLE);
+                       schedule();
+                       finish_wait(&edge_port->delta_msr_wait, &wait);
+                       /* see if a signal did it */
+                       if (signal_pending(current))
+                               return -ERESTARTSYS;
+                       cnow = edge_port->icount;
+                       if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
+                           cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
+                               return -EIO; /* no change => error */
+                       if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
+                           ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
+                           ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
+                           ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
+                               return 0;
                        }
-                       /* NOTREACHED */
-                       break;
+                       cprev = cnow;
+               }
+               /* NOTREACHED */
+               break;
 
-               case TIOCGICOUNT:
-                       cnow = edge_port->icount;
-                       memset(&icount, 0, sizeof(icount));
-                       icount.cts = cnow.cts;
-                       icount.dsr = cnow.dsr;
-                       icount.rng = cnow.rng;
-                       icount.dcd = cnow.dcd;
-                       icount.rx = cnow.rx;
-                       icount.tx = cnow.tx;
-                       icount.frame = cnow.frame;
-                       icount.overrun = cnow.overrun;
-                       icount.parity = cnow.parity;
-                       icount.brk = cnow.brk;
-                       icount.buf_overrun = cnow.buf_overrun;
-
-                       dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__,  port->number, icount.rx, icount.tx );
-                       if (copy_to_user((void __user *)arg, &icount, sizeof(icount)))
-                               return -EFAULT;
-                       return 0;
+       case TIOCGICOUNT:
+               cnow = edge_port->icount;
+               memset(&icount, 0, sizeof(icount));
+               icount.cts = cnow.cts;
+               icount.dsr = cnow.dsr;
+               icount.rng = cnow.rng;
+               icount.dcd = cnow.dcd;
+               icount.rx = cnow.rx;
+               icount.tx = cnow.tx;
+               icount.frame = cnow.frame;
+               icount.overrun = cnow.overrun;
+               icount.parity = cnow.parity;
+               icount.brk = cnow.brk;
+               icount.buf_overrun = cnow.buf_overrun;
+
+               dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d",
+                               __func__,  port->number, icount.rx, icount.tx);
+               if (copy_to_user((void __user *)arg, &icount, sizeof(icount)))
+                       return -EFAULT;
+               return 0;
        }
-
        return -ENOIOCTLCMD;
 }
 
@@ -1723,8 +1769,9 @@ static int edge_ioctl (struct usb_serial_port *port, struct file *file, unsigned
  * SerialBreak
  *     this function sends a break to the port
  *****************************************************************************/
-static void edge_break (struct usb_serial_port *port, int break_state)
+static void edge_break(struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        struct edgeport_serial *edge_serial = usb_get_serial_data(port->serial);
        int status;
@@ -1736,9 +1783,9 @@ static void edge_break (struct usb_serial_port *port, int break_state)
                edge_port->chaseResponsePending = true;
 
                dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__);
-               status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0);
+               status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0);
                if (status == 0) {
-                       // block until chase finished
+                       /* block until chase finished */
                        block_until_chase_response(edge_port);
                } else {
                        edge_port->chaseResponsePending = false;
@@ -1750,14 +1797,16 @@ static void edge_break (struct usb_serial_port *port, int break_state)
             (edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) {
                if (break_state == -1) {
                        dbg("%s - Sending IOSP_CMD_SET_BREAK", __func__);
-                       status = send_iosp_ext_cmd (edge_port, IOSP_CMD_SET_BREAK, 0);
+                       status = send_iosp_ext_cmd(edge_port,
+                                               IOSP_CMD_SET_BREAK, 0);
                } else {
                        dbg("%s - Sending IOSP_CMD_CLEAR_BREAK", __func__);
-                       status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CLEAR_BREAK, 0);
-               }
-               if (status) {
-                       dbg("%s - error sending break set/clear command.", __func__);
+                       status = send_iosp_ext_cmd(edge_port,
+                                               IOSP_CMD_CLEAR_BREAK, 0);
                }
+               if (status)
+                       dbg("%s - error sending break set/clear command.",
+                               __func__);
        }
 
        return;
@@ -1768,7 +1817,8 @@ static void edge_break (struct usb_serial_port *port, int break_state)
  * process_rcvd_data
  *     this function handles the data received on the bulk in pipe.
  *****************************************************************************/
-static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned char * buffer, __u16 bufferLength)
+static void process_rcvd_data(struct edgeport_serial *edge_serial,
+                               unsigned char *buffer, __u16 bufferLength)
 {
        struct usb_serial_port *port;
        struct edgeport_port *edge_port;
@@ -1789,105 +1839,123 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha
                lastBufferLength = bufferLength;
 
                switch (edge_serial->rxState) {
-                       case EXPECT_HDR1:
-                               edge_serial->rxHeader1 = *buffer;
-                               ++buffer;
-                               --bufferLength;
+               case EXPECT_HDR1:
+                       edge_serial->rxHeader1 = *buffer;
+                       ++buffer;
+                       --bufferLength;
 
-                               if (bufferLength == 0) {
-                                       edge_serial->rxState = EXPECT_HDR2;
+                       if (bufferLength == 0) {
+                               edge_serial->rxState = EXPECT_HDR2;
+                               break;
+                       }
+                       /* otherwise, drop on through */
+               case EXPECT_HDR2:
+                       edge_serial->rxHeader2 = *buffer;
+                       ++buffer;
+                       --bufferLength;
+
+                       dbg("%s - Hdr1=%02X Hdr2=%02X", __func__,
+                           edge_serial->rxHeader1, edge_serial->rxHeader2);
+                       /* Process depending on whether this header is
+                        * data or status */
+
+                       if (IS_CMD_STAT_HDR(edge_serial->rxHeader1)) {
+                               /* Decode this status header and go to
+                                * EXPECT_HDR1 (if we can process the status
+                                * with only 2 bytes), or go to EXPECT_HDR3 to
+                                * get the third byte. */
+                               edge_serial->rxPort =
+                                   IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
+                               edge_serial->rxStatusCode =
+                                   IOSP_GET_STATUS_CODE(
+                                               edge_serial->rxHeader1);
+
+                               if (!IOSP_STATUS_IS_2BYTE(
+                                               edge_serial->rxStatusCode)) {
+                                       /* This status needs additional bytes.
+                                        * Save what we have and then wait for
+                                        * more data.
+                                        */
+                                       edge_serial->rxStatusParam
+                                               = edge_serial->rxHeader2;
+                                       edge_serial->rxState = EXPECT_HDR3;
                                        break;
                                }
-                               /* otherwise, drop on through */
-
-                       case EXPECT_HDR2:
-                               edge_serial->rxHeader2 = *buffer;
-                               ++buffer;
-                               --bufferLength;
-
-                               dbg("%s - Hdr1=%02X Hdr2=%02X", __func__, edge_serial->rxHeader1, edge_serial->rxHeader2);
-
-                               // Process depending on whether this header is
-                               // data or status
-
-                               if (IS_CMD_STAT_HDR(edge_serial->rxHeader1)) {
-                                       // Decode this status header and goto EXPECT_HDR1 (if we
-                                       // can process the status with only 2 bytes), or goto
-                                       // EXPECT_HDR3 to get the third byte.
-
-                                       edge_serial->rxPort       = IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
-                                       edge_serial->rxStatusCode = IOSP_GET_STATUS_CODE(edge_serial->rxHeader1);
-
-                                       if (!IOSP_STATUS_IS_2BYTE(edge_serial->rxStatusCode)) {
-                                               // This status needs additional bytes. Save what we have
-                                               // and then wait for more data.
-                                               edge_serial->rxStatusParam = edge_serial->rxHeader2;
-
-                                               edge_serial->rxState = EXPECT_HDR3;
-                                               break;
-                                       }
+                               /* We have all the header bytes, process the
+                                  status now */
+                               process_rcvd_status(edge_serial,
+                                               edge_serial->rxHeader2, 0);
+                               edge_serial->rxState = EXPECT_HDR1;
+                               break;
+                       } else {
+                               edge_serial->rxPort =
+                                   IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
+                               edge_serial->rxBytesRemaining =
+                                   IOSP_GET_HDR_DATA_LEN(
+                                               edge_serial->rxHeader1,
+                                               edge_serial->rxHeader2);
+                               dbg("%s - Data for Port %u Len %u",
+                                               __func__,
+                                               edge_serial->rxPort,
+                                               edge_serial->rxBytesRemaining);
+
+                               /* ASSERT(DevExt->RxPort < DevExt->NumPorts);
+                                * ASSERT(DevExt->RxBytesRemaining <
+                                *              IOSP_MAX_DATA_LENGTH);
+                                */
 
-                                       // We have all the header bytes, process the status now
-                                       process_rcvd_status (edge_serial, edge_serial->rxHeader2, 0);
-                                       edge_serial->rxState = EXPECT_HDR1;
+                               if (bufferLength == 0) {
+                                       edge_serial->rxState = EXPECT_DATA;
                                        break;
-                               } else {
-                                       edge_serial->rxPort = IOSP_GET_HDR_PORT(edge_serial->rxHeader1);
-                                       edge_serial->rxBytesRemaining = IOSP_GET_HDR_DATA_LEN(edge_serial->rxHeader1, edge_serial->rxHeader2);
-
-                                       dbg("%s - Data for Port %u Len %u", __func__, edge_serial->rxPort, edge_serial->rxBytesRemaining);
-
-                                       //ASSERT( DevExt->RxPort < DevExt->NumPorts );
-                                       //ASSERT( DevExt->RxBytesRemaining < IOSP_MAX_DATA_LENGTH );
-
-                                       if (bufferLength == 0 ) {
-                                               edge_serial->rxState = EXPECT_DATA;
-                                               break;
-                                       }
-                                       // Else, drop through
                                }
+                               /* Else, drop through */
+                       }
+               case EXPECT_DATA: /* Expect data */
+                       if (bufferLength < edge_serial->rxBytesRemaining) {
+                               rxLen = bufferLength;
+                               /* Expect data to start next buffer */
+                               edge_serial->rxState = EXPECT_DATA;
+                       } else {
+                               /* BufLen >= RxBytesRemaining */
+                               rxLen = edge_serial->rxBytesRemaining;
+                               /* Start another header next time */
+                               edge_serial->rxState = EXPECT_HDR1;
+                       }
 
-                       case EXPECT_DATA:       // Expect data
-
-                               if (bufferLength < edge_serial->rxBytesRemaining) {
-                                       rxLen = bufferLength;
-                                       edge_serial->rxState = EXPECT_DATA;     // Expect data to start next buffer
-                               } else {
-                                       // BufLen >= RxBytesRemaining
-                                       rxLen = edge_serial->rxBytesRemaining;
-                                       edge_serial->rxState = EXPECT_HDR1;     // Start another header next time
-                               }
+                       bufferLength -= rxLen;
+                       edge_serial->rxBytesRemaining -= rxLen;
 
-                               bufferLength -= rxLen;
-                               edge_serial->rxBytesRemaining -= rxLen;
-
-                               /* spit this data back into the tty driver if this port is open */
-                               if (rxLen) {
-                                       port = edge_serial->serial->port[edge_serial->rxPort];
-                                       edge_port = usb_get_serial_port_data(port);
-                                       if (edge_port->open) {
-                                               tty = edge_port->port->tty;
-                                               if (tty) {
-                                                       dbg("%s - Sending %d bytes to TTY for port %d", __func__, rxLen, edge_serial->rxPort);
-                                                       edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
-                                               }
-                                               edge_port->icount.rx += rxLen;
+                       /* spit this data back into the tty driver if this
+                          port is open */
+                       if (rxLen) {
+                               port = edge_serial->serial->port[
+                                                       edge_serial->rxPort];
+                               edge_port = usb_get_serial_port_data(port);
+                               if (edge_port->open) {
+                                       tty = edge_port->port->port.tty;
+                                       if (tty) {
+                                               dbg("%s - Sending %d bytes to TTY for port %d",
+                                                       __func__, rxLen, edge_serial->rxPort);
+                                               edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
                                        }
-                                       buffer += rxLen;
+                                       edge_port->icount.rx += rxLen;
                                }
+                               buffer += rxLen;
+                       }
+                       break;
 
-                               break;
-
-                       case EXPECT_HDR3:                       // Expect 3rd byte of status header
-                               edge_serial->rxHeader3 = *buffer;
-                               ++buffer;
-                               --bufferLength;
-
-                               // We have all the header bytes, process the status now
-                               process_rcvd_status (edge_serial, edge_serial->rxStatusParam, edge_serial->rxHeader3);
-                               edge_serial->rxState = EXPECT_HDR1;
-                               break;
-
+               case EXPECT_HDR3:       /* Expect 3rd byte of status header */
+                       edge_serial->rxHeader3 = *buffer;
+                       ++buffer;
+                       --bufferLength;
+
+                       /* We have all the header bytes, process the
+                          status now */
+                       process_rcvd_status(edge_serial,
+                               edge_serial->rxStatusParam,
+                               edge_serial->rxHeader3);
+                       edge_serial->rxState = EXPECT_HDR1;
+                       break;
                }
        }
 }
@@ -1895,9 +1963,11 @@ static void process_rcvd_data (struct edgeport_serial *edge_serial, unsigned cha
 
 /*****************************************************************************
  * process_rcvd_status
- *     this function handles the any status messages received on the bulk in pipe.
+ *     this function handles the any status messages received on the
+ *     bulk in pipe.
  *****************************************************************************/
-static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2, __u8 byte3)
+static void process_rcvd_status(struct edgeport_serial *edge_serial,
+                                               __u8 byte2, __u8 byte3)
 {
        struct usb_serial_port *port;
        struct edgeport_port *edge_port;
@@ -1907,7 +1977,9 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
        port = edge_serial->serial->port[edge_serial->rxPort];
        edge_port = usb_get_serial_port_data(port);
        if (edge_port == NULL) {
-               dev_err(&edge_serial->serial->dev->dev, "%s - edge_port == NULL for port %d\n", __func__, edge_serial->rxPort);
+               dev_err(&edge_serial->serial->dev->dev,
+                       "%s - edge_port == NULL for port %d\n",
+                                       __func__, edge_serial->rxPort);
                return;
        }
 
@@ -1915,22 +1987,28 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
 
        if (code == IOSP_EXT_STATUS) {
                switch (byte2) {
-                       case IOSP_EXT_STATUS_CHASE_RSP:
-                               // we want to do EXT status regardless of port open/closed 
-                               dbg("%s - Port %u EXT CHASE_RSP Data = %02x", __func__, edge_serial->rxPort, byte3 );
-                               // Currently, the only EXT_STATUS is Chase, so process here instead of one more call
-                               // to one more subroutine. If/when more EXT_STATUS, there'll be more work to do.
-                               // Also, we currently clear flag and close the port regardless of content of above's Byte3.
-                               // We could choose to do something else when Byte3 says Timeout on Chase from Edgeport,
-                               // like wait longer in block_until_chase_response, but for now we don't. 
-                               edge_port->chaseResponsePending = false;
-                               wake_up (&edge_port->wait_chase);
-                               return;
+               case IOSP_EXT_STATUS_CHASE_RSP:
+                       /* we want to do EXT status regardless of port
+                        * open/closed */
+                       dbg("%s - Port %u EXT CHASE_RSP Data = %02x",
+                                       __func__, edge_serial->rxPort, byte3);
+                       /* Currently, the only EXT_STATUS is Chase, so process
+                        * here instead of one more call to one more subroutine
+                        * If/when more EXT_STATUS, there'll be more work to do
+                        * Also, we currently clear flag and close the port
+                        * regardless of content of above's Byte3.
+                        * We could choose to do something else when Byte3 says
+                        * Timeout on Chase from Edgeport, like wait longer in
+                        * block_until_chase_response, but for now we don't.
+                        */
+                       edge_port->chaseResponsePending = false;
+                       wake_up(&edge_port->wait_chase);
+                       return;
 
-                       case IOSP_EXT_STATUS_RX_CHECK_RSP:
-                               dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __func__, edge_serial->rxPort, byte3 );
-                               //Port->RxCheckRsp = true;
-                               return;
+               case IOSP_EXT_STATUS_RX_CHECK_RSP:
+                       dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============\n", __func__, edge_serial->rxPort, byte3);
+                       /* Port->RxCheckRsp = true; */
+                       return;
                }
        }
 
@@ -1938,11 +2016,14 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
                edge_port->txCredits = GET_TX_BUFFER_SIZE(byte3);
                edge_port->maxTxCredits = edge_port->txCredits;
                dbg("%s - Port %u Open Response Inital MSR = %02x TxBufferSize = %d", __func__, edge_serial->rxPort, byte2, edge_port->txCredits);
-               handle_new_msr (edge_port, byte2);
+               handle_new_msr(edge_port, byte2);
 
-               /* send the current line settings to the port so we are in sync with any further termios calls */
-               if (edge_port->port->tty)
-                       change_port_settings (edge_port, edge_port->port->tty->termios);
+               /* send the current line settings to the port so we are
+                  in sync with any further termios calls */
+               /* FIXME: locking on tty */
+               if (edge_port->port->port.tty)
+                       change_port_settings(edge_port->port->port.tty,
+                               edge_port, edge_port->port->port.tty->termios);
 
                /* we have completed the open */
                edge_port->openPending = false;
@@ -1951,45 +2032,49 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
                return;
        }
 
-       // If port is closed, silently discard all rcvd status. We can
-       // have cases where buffered status is received AFTER the close
-       // port command is sent to the Edgeport.
-       if (!edge_port->open || edge_port->closePending) {
+       /* If port is closed, silently discard all rcvd status. We can
+        * have cases where buffered status is received AFTER the close
+        * port command is sent to the Edgeport.
+        */
+       if (!edge_port->open || edge_port->closePending)
                return;
-       }
 
        switch (code) {
-               // Not currently sent by Edgeport
-               case IOSP_STATUS_LSR:
-                       dbg("%s - Port %u LSR Status = %02x", __func__, edge_serial->rxPort, byte2);
-                       handle_new_lsr(edge_port, false, byte2, 0);
-                       break;
+       /* Not currently sent by Edgeport */
+       case IOSP_STATUS_LSR:
+               dbg("%s - Port %u LSR Status = %02x",
+                                       __func__, edge_serial->rxPort, byte2);
+               handle_new_lsr(edge_port, false, byte2, 0);
+               break;
 
-               case IOSP_STATUS_LSR_DATA:
-                       dbg("%s - Port %u LSR Status = %02x, Data = %02x", __func__, edge_serial->rxPort, byte2, byte3);
-                       // byte2 is LSR Register
-                       // byte3 is broken data byte
-                       handle_new_lsr(edge_port, true, byte2, byte3);
-                       break;
-                       //
-                       //      case IOSP_EXT_4_STATUS:
-                       //              dbg("%s - Port %u LSR Status = %02x Data = %02x", __func__, edge_serial->rxPort, byte2, byte3);
-                       //              break;
-                       //
-               case IOSP_STATUS_MSR:
-                       dbg("%s - Port %u MSR Status = %02x", __func__, edge_serial->rxPort, byte2);
-
-                       // Process this new modem status and generate appropriate
-                       // events, etc, based on the new status. This routine
-                       // also saves the MSR in Port->ShadowMsr.
-                       handle_new_msr(edge_port, byte2);
-                       break;
+       case IOSP_STATUS_LSR_DATA:
+               dbg("%s - Port %u LSR Status = %02x, Data = %02x",
+                               __func__, edge_serial->rxPort, byte2, byte3);
+               /* byte2 is LSR Register */
+               /* byte3 is broken data byte */
+               handle_new_lsr(edge_port, true, byte2, byte3);
+               break;
+       /*
+        *      case IOSP_EXT_4_STATUS:
+        *              dbg("%s - Port %u LSR Status = %02x Data = %02x",
+        *                      __func__, edge_serial->rxPort, byte2, byte3);
+        *              break;
+        */
+       case IOSP_STATUS_MSR:
+               dbg("%s - Port %u MSR Status = %02x",
+                                       __func__, edge_serial->rxPort, byte2);
+               /*
+                * Process this new modem status and generate appropriate
+                * events, etc, based on the new status. This routine
+                * also saves the MSR in Port->ShadowMsr.
+                */
+               handle_new_msr(edge_port, byte2);
+               break;
 
-               default:
-                       dbg("%s - Unrecognized IOSP status code %u\n", __func__, code);
-                       break;
+       default:
+               dbg("%s - Unrecognized IOSP status code %u\n", __func__, code);
+               break;
        }
-
        return;
 }
 
@@ -1998,7 +2083,8 @@ static void process_rcvd_status (struct edgeport_serial *edge_serial, __u8 byte2
  * edge_tty_recv
  *     this function passes data on to the tty flip buffer
  *****************************************************************************/
-static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned char *data, int length)
+static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
+                                       unsigned char *data, int length)
 {
        int cnt;
 
@@ -2007,7 +2093,7 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty, unsigned c
                if (cnt < length) {
                        dev_err(dev, "%s - dropping data, %d bytes lost\n",
                                        __func__, length - cnt);
-                       if(cnt == 0)
+                       if (cnt == 0)
                                break;
                }
                tty_insert_flip_string(tty, data, cnt);
@@ -2029,22 +2115,19 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr)
 
        dbg("%s %02x", __func__, newMsr);
 
-       if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
+       if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR |
+                       EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
                icount = &edge_port->icount;
 
                /* update input line counters */
-               if (newMsr & EDGEPORT_MSR_DELTA_CTS) {
+               if (newMsr & EDGEPORT_MSR_DELTA_CTS)
                        icount->cts++;
-               }
-               if (newMsr & EDGEPORT_MSR_DELTA_DSR) {
+               if (newMsr & EDGEPORT_MSR_DELTA_DSR)
                        icount->dsr++;
-               }
-               if (newMsr & EDGEPORT_MSR_DELTA_CD) {
+               if (newMsr & EDGEPORT_MSR_DELTA_CD)
                        icount->dcd++;
-               }
-               if (newMsr & EDGEPORT_MSR_DELTA_RI) {
+               if (newMsr & EDGEPORT_MSR_DELTA_RI)
                        icount->rng++;
-               }
                wake_up_interruptible(&edge_port->delta_msr_wait);
        }
 
@@ -2059,42 +2142,41 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr)
  * handle_new_lsr
  *     this function handles any change to the lsr register for a port.
  *****************************************************************************/
-static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 lsr, __u8 data)
+static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData,
+                                                       __u8 lsr, __u8 data)
 {
-       __u8    newLsr = (__u8)(lsr & (__u8)(LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK));
-       struct  async_icount *icount;
+       __u8 newLsr = (__u8) (lsr & (__u8)
+               (LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK));
+       struct async_icount *icount;
 
        dbg("%s - %02x", __func__, newLsr);
 
        edge_port->shadowLSR = lsr;
 
        if (newLsr & LSR_BREAK) {
-               //
-               // Parity and Framing errors only count if they
-               // occur exclusive of a break being
-               // received.
-               //
+               /*
+                * Parity and Framing errors only count if they
+                * occur exclusive of a break being
+                * received.
+                */
                newLsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK);
        }
 
        /* Place LSR data byte into Rx buffer */
-       if (lsrData && edge_port->port->tty)
-               edge_tty_recv(&edge_port->port->dev, edge_port->port->tty, &data, 1);
+       if (lsrData && edge_port->port->port.tty)
+               edge_tty_recv(&edge_port->port->dev,
+                                       edge_port->port->port.tty, &data, 1);
 
        /* update input line counters */
        icount = &edge_port->icount;
-       if (newLsr & LSR_BREAK) {
+       if (newLsr & LSR_BREAK)
                icount->brk++;
-       }
-       if (newLsr & LSR_OVER_ERR) {
+       if (newLsr & LSR_OVER_ERR)
                icount->overrun++;
-       }
-       if (newLsr & LSR_PAR_ERR) {
+       if (newLsr & LSR_PAR_ERR)
                icount->parity++;
-       }
-       if (newLsr & LSR_FRM_ERR) {
+       if (newLsr & LSR_FRM_ERR)
                icount->frame++;
-       }
 
        return;
 }
@@ -2102,12 +2184,13 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData, __u8 l
 
 /****************************************************************************
  * sram_write
- *     writes a number of bytes to the Edgeport device's sram starting at the 
+ *     writes a number of bytes to the Edgeport device's sram starting at the
  *     given address.
  *     If successful returns the number of bytes written, otherwise it returns
  *     a negative error number of the problem.
  ****************************************************************************/
-static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, const __u8 *data)
+static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr,
+                                       __u16 length, const __u8 *data)
 {
        int result;
        __u16 current_length;
@@ -2115,32 +2198,37 @@ static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, __u1
 
        dbg("%s - %x, %x, %d", __func__, extAddr, addr, length);
 
-       transfer_buffer =  kmalloc (64, GFP_KERNEL);
+       transfer_buffer =  kmalloc(64, GFP_KERNEL);
        if (!transfer_buffer) {
-               dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64);
+               dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n",
+                                                       __func__, 64);
                return -ENOMEM;
        }
 
        /* need to split these writes up into 64 byte chunks */
        result = 0;
        while (length > 0) {
-               if (length > 64) {
+               if (length > 64)
                        current_length = 64;
-               } else {
+               else
                        current_length = length;
-               }
-//             dbg("%s - writing %x, %x, %d", __func__, extAddr, addr, current_length);
-               memcpy (transfer_buffer, data, current_length);
-               result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), USB_REQUEST_ION_WRITE_RAM, 
-                                         0x40, addr, extAddr, transfer_buffer, current_length, 300);
+
+/*             dbg("%s - writing %x, %x, %d", __func__,
+                                       extAddr, addr, current_length); */
+               memcpy(transfer_buffer, data, current_length);
+               result = usb_control_msg(serial->dev,
+                                       usb_sndctrlpipe(serial->dev, 0),
+                                       USB_REQUEST_ION_WRITE_RAM,
+                                       0x40, addr, extAddr, transfer_buffer,
+                                       current_length, 300);
                if (result < 0)
                        break;
                length -= current_length;
                addr += current_length;
                data += current_length;
-       }       
+       }
 
-       kfree (transfer_buffer);
+       kfree(transfer_buffer);
        return result;
 }
 
@@ -2152,40 +2240,45 @@ static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, __u1
  *     If successful returns the number of bytes written, otherwise it returns
  *     a negative error number of the problem.
  ****************************************************************************/
-static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, const __u8 *data)
+static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr,
+                                       __u16 length, const __u8 *data)
 {
        int result;
        __u16 current_length;
        unsigned char *transfer_buffer;
 
-//     dbg("%s - %x, %x, %d", __func__, extAddr, addr, length);
+/*     dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); */
 
-       transfer_buffer =  kmalloc (64, GFP_KERNEL);
+       transfer_buffer =  kmalloc(64, GFP_KERNEL);
        if (!transfer_buffer) {
-               dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64);
+               dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n",
+                                                               __func__, 64);
                return -ENOMEM;
        }
 
        /* need to split these writes up into 64 byte chunks */
        result = 0;
        while (length > 0) {
-               if (length > 64) {
+               if (length > 64)
                        current_length = 64;
-               } else {
+               else
                        current_length = length;
-               }
-//             dbg("%s - writing %x, %x, %d", __func__, extAddr, addr, current_length);
-               memcpy (transfer_buffer, data, current_length);
-               result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), USB_REQUEST_ION_WRITE_ROM, 
-                                         0x40, addr, extAddr, transfer_buffer, current_length, 300);
+/*             dbg("%s - writing %x, %x, %d", __func__,
+                                       extAddr, addr, current_length); */
+               memcpy(transfer_buffer, data, current_length);
+               result = usb_control_msg(serial->dev,
+                                       usb_sndctrlpipe(serial->dev, 0),
+                                       USB_REQUEST_ION_WRITE_ROM, 0x40,
+                                       addr, extAddr,
+                                       transfer_buffer, current_length, 300);
                if (result < 0)
                        break;
                length -= current_length;
                addr += current_length;
                data += current_length;
-       }       
+       }
 
-       kfree (transfer_buffer);
+       kfree(transfer_buffer);
        return result;
 }
 
@@ -2197,7 +2290,8 @@ static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16
  *     If successful returns the number of bytes read, otherwise it returns
  *     a negative error number of the problem.
  ****************************************************************************/
-static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16 length, __u8 *data)
+static int rom_read(struct usb_serial *serial, __u16 extAddr,
+                                       __u16 addr, __u16 length, __u8 *data)
 {
        int result;
        __u16 current_length;
@@ -2205,32 +2299,36 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16
 
        dbg("%s - %x, %x, %d", __func__, extAddr, addr, length);
 
-       transfer_buffer =  kmalloc (64, GFP_KERNEL);
+       transfer_buffer =  kmalloc(64, GFP_KERNEL);
        if (!transfer_buffer) {
-               dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, 64);
+               dev_err(&serial->dev->dev,
+                       "%s - kmalloc(%d) failed.\n", __func__, 64);
                return -ENOMEM;
        }
 
        /* need to split these reads up into 64 byte chunks */
        result = 0;
        while (length > 0) {
-               if (length > 64) {
+               if (length > 64)
                        current_length = 64;
-               } else {
+               else
                        current_length = length;
-               }
-//             dbg("%s - %x, %x, %d", __func__, extAddr, addr, current_length);
-               result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), USB_REQUEST_ION_READ_ROM, 
-                                         0xC0, addr, extAddr, transfer_buffer, current_length, 300);
+/*             dbg("%s - %x, %x, %d", __func__,
+                               extAddr, addr, current_length); */
+               result = usb_control_msg(serial->dev,
+                                       usb_rcvctrlpipe(serial->dev, 0),
+                                       USB_REQUEST_ION_READ_ROM,
+                                       0xC0, addr, extAddr, transfer_buffer,
+                                       current_length, 300);
                if (result < 0)
                        break;
-               memcpy (data, transfer_buffer, current_length);
+               memcpy(data, transfer_buffer, current_length);
                length -= current_length;
                addr += current_length;
                data += current_length;
-       }       
+       }
 
-       kfree (transfer_buffer);
+       kfree(transfer_buffer);
        return result;
 }
 
@@ -2239,7 +2337,8 @@ static int rom_read (struct usb_serial *serial, __u16 extAddr, __u16 addr, __u16
  * send_iosp_ext_cmd
  *     Is used to send a IOSP message to the Edgeport device
  ****************************************************************************/
-static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u8 param)
+static int send_iosp_ext_cmd(struct edgeport_port *edge_port,
+                                               __u8 command, __u8 param)
 {
        unsigned char   *buffer;
        unsigned char   *currentCommand;
@@ -2248,19 +2347,20 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u
 
        dbg("%s - %d, %d", __func__, command, param);
 
-       buffer =  kmalloc (10, GFP_ATOMIC);
+       buffer = kmalloc(10, GFP_ATOMIC);
        if (!buffer) {
-               dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __func__, 10);
+               dev_err(&edge_port->port->dev,
+                               "%s - kmalloc(%d) failed.\n", __func__, 10);
                return -ENOMEM;
        }
 
        currentCommand = buffer;
 
-       MAKE_CMD_EXT_CMD (&currentCommand, &length,
-                         edge_port->port->number - edge_port->port->serial->minor,
-                         command, param);
+       MAKE_CMD_EXT_CMD(&currentCommand, &length,
+               edge_port->port->number - edge_port->port->serial->minor,
+               command, param);
 
-       status = write_cmd_usb (edge_port, buffer, length);
+       status = write_cmd_usb(edge_port, buffer, length);
        if (status) {
                /* something bad happened, let's free up the memory */
                kfree(buffer);
@@ -2274,43 +2374,50 @@ static int send_iosp_ext_cmd (struct edgeport_port *edge_port, __u8 command, __u
  * write_cmd_usb
  *     this function writes the given buffer out to the bulk write endpoint.
  *****************************************************************************/
-static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer, int length)
+static int write_cmd_usb(struct edgeport_port *edge_port,
+                                       unsigned char *buffer, int length)
 {
-       struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial);
+       struct edgeport_serial *edge_serial =
+                               usb_get_serial_data(edge_port->port->serial);
        int status = 0;
        struct urb *urb;
        int timeout;
 
-       usb_serial_debug_data(debug, &edge_port->port->dev, __func__, length, buffer);
+       usb_serial_debug_data(debug, &edge_port->port->dev,
+                                               __func__, length, buffer);
 
        /* Allocate our next urb */
-       urb = usb_alloc_urb (0, GFP_ATOMIC);
+       urb = usb_alloc_urb(0, GFP_ATOMIC);
        if (!urb)
                return -ENOMEM;
 
        atomic_inc(&CmdUrbs);
-       dbg("%s - ALLOCATE URB %p (outstanding %d)", __func__, urb, atomic_read(&CmdUrbs));
+       dbg("%s - ALLOCATE URB %p (outstanding %d)",
+                               __func__, urb, atomic_read(&CmdUrbs));
 
-       usb_fill_bulk_urb (urb, edge_serial->serial->dev, 
-                      usb_sndbulkpipe(edge_serial->serial->dev, edge_serial->bulk_out_endpoint),
-                      buffer, length, edge_bulk_out_cmd_callback, edge_port);
+       usb_fill_bulk_urb(urb, edge_serial->serial->dev,
+                       usb_sndbulkpipe(edge_serial->serial->dev,
+                                       edge_serial->bulk_out_endpoint),
+                       buffer, length, edge_bulk_out_cmd_callback, edge_port);
 
        edge_port->commandPending = true;
        status = usb_submit_urb(urb, GFP_ATOMIC);
 
        if (status) {
                /* something went wrong */
-               dev_err(&edge_port->port->dev, "%s - usb_submit_urb(write command) failed, status = %d\n", __func__, status);
+               dev_err(&edge_port->port->dev,
+                   "%s - usb_submit_urb(write command) failed, status = %d\n",
+                                                       __func__, status);
                usb_kill_urb(urb);
                usb_free_urb(urb);
                atomic_dec(&CmdUrbs);
                return status;
        }
 
-       // wait for command to finish
+       /* wait for command to finish */
        timeout = COMMAND_TIMEOUT;
 #if 0
-       wait_event (&edge_port->wait_command, !edge_port->commandPending);
+       wait_event(&edge_port->wait_command, !edge_port->commandPending);
 
        if (edge_port->commandPending) {
                /* command timed out */
@@ -2327,15 +2434,18 @@ static int write_cmd_usb (struct edgeport_port *edge_port, unsigned char *buffer
  *     this function sends the proper command to change the baud rate of the
  *     specified port.
  *****************************************************************************/
-static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRate)
+static int send_cmd_write_baud_rate(struct edgeport_port *edge_port,
+                                                               int baudRate)
 {
-       struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial);
+       struct edgeport_serial *edge_serial =
+                               usb_get_serial_data(edge_port->port->serial);
        unsigned char *cmdBuffer;
        unsigned char *currCmd;
        int cmdLen = 0;
        int divisor;
        int status;
-       unsigned char number = edge_port->port->number - edge_port->port->serial->minor;
+       unsigned char number =
+               edge_port->port->number - edge_port->port->serial->minor;
 
        if (edge_serial->is_epic &&
            !edge_serial->epic_descriptor.Supports.IOSPSetBaudRate) {
@@ -2344,36 +2454,40 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRa
                return 0;
        }
 
-       dbg("%s - port = %d, baud = %d", __func__, edge_port->port->number, baudRate);
+       dbg("%s - port = %d, baud = %d", __func__,
+                                       edge_port->port->number, baudRate);
 
-       status = calc_baud_rate_divisor (baudRate, &divisor);
+       status = calc_baud_rate_divisor(baudRate, &divisor);
        if (status) {
-               dev_err(&edge_port->port->dev, "%s - bad baud rate\n", __func__);
+               dev_err(&edge_port->port->dev, "%s - bad baud rate\n",
+                                                               __func__);
                return status;
        }
 
-       // Alloc memory for the string of commands.
-       cmdBuffer =  kmalloc (0x100, GFP_ATOMIC);
+       /* Alloc memory for the string of commands. */
+       cmdBuffer =  kmalloc(0x100, GFP_ATOMIC);
        if (!cmdBuffer) {
-               dev_err(&edge_port->port->dev, "%s - kmalloc(%d) failed.\n", __func__, 0x100);
+               dev_err(&edge_port->port->dev,
+                       "%s - kmalloc(%d) failed.\n", __func__, 0x100);
                return -ENOMEM;
        }
        currCmd = cmdBuffer;
 
-       // Enable access to divisor latch
-       MAKE_CMD_WRITE_REG( &currCmd, &cmdLen, number, LCR, LCR_DL_ENABLE );
+       /* Enable access to divisor latch */
+       MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, number, LCR, LCR_DL_ENABLE);
 
-       // Write the divisor itself
-       MAKE_CMD_WRITE_REG( &currCmd, &cmdLen, number, DLL, LOW8 (divisor) );
-       MAKE_CMD_WRITE_REG( &currCmd, &cmdLen, number, DLM, HIGH8(divisor) );
+       /* Write the divisor itself */
+       MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, number, DLL, LOW8(divisor));
+       MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, number, DLM, HIGH8(divisor));
 
-       // Restore original value to disable access to divisor latch
-       MAKE_CMD_WRITE_REG( &currCmd, &cmdLen, number, LCR, edge_port->shadowLCR);
+       /* Restore original value to disable access to divisor latch */
+       MAKE_CMD_WRITE_REG(&currCmd, &cmdLen, number, LCR,
+                                               edge_port->shadowLCR);
 
-       status = write_cmd_usb(edge_port, cmdBuffer, cmdLen );
+       status = write_cmd_usb(edge_port, cmdBuffer, cmdLen);
        if (status) {
                /* something bad happened, let's free up the memory */
-               kfree (cmdBuffer);
+               kfree(cmdBuffer);
        }
 
        return status;
@@ -2385,7 +2499,7 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRa
  *     this function calculates the proper baud rate divisor for the specified
  *     baud rate.
  *****************************************************************************/
-static int calc_baud_rate_divisor (int baudrate, int *divisor)
+static int calc_baud_rate_divisor(int baudrate, int *divisor)
 {
        int i;
        __u16 custom;
@@ -2394,17 +2508,17 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor)
        dbg("%s - %d", __func__, baudrate);
 
        for (i = 0; i < ARRAY_SIZE(divisor_table); i++) {
-               if ( divisor_table[i].BaudRate == baudrate ) {
+               if (divisor_table[i].BaudRate == baudrate) {
                        *divisor = divisor_table[i].Divisor;
                        return 0;
                }
        }
 
-       // We have tried all of the standard baud rates
-       // lets try to calculate the divisor for this baud rate
-       // Make sure the baud rate is reasonable
+       /* We have tried all of the standard baud rates
+        * lets try to calculate the divisor for this baud rate
+        * Make sure the baud rate is reasonable */
        if (baudrate > 50 && baudrate < 230400) {
-               // get divisor
+               /* get divisor */
                custom = (__u16)((230400L + baudrate/2) / baudrate);
 
                *divisor = custom;
@@ -2419,17 +2533,20 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor)
 
 /*****************************************************************************
  * send_cmd_write_uart_register
- *     this function builds up a uart register message and sends to to the device.
+ *  this function builds up a uart register message and sends to to the device.
  *****************************************************************************/
-static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 regNum, __u8 regValue)
+static int send_cmd_write_uart_register(struct edgeport_port *edge_port,
+                                               __u8 regNum, __u8 regValue)
 {
-       struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial);
+       struct edgeport_serial *edge_serial =
+                               usb_get_serial_data(edge_port->port->serial);
        unsigned char *cmdBuffer;
        unsigned char *currCmd;
        unsigned long cmdLen = 0;
        int status;
 
-       dbg("%s - write to %s register 0x%02x", (regNum == MCR) ? "MCR" : "LCR", __func__, regValue);
+       dbg("%s - write to %s register 0x%02x",
+                       (regNum == MCR) ? "MCR" : "LCR", __func__, regValue);
 
        if (edge_serial->is_epic &&
            !edge_serial->epic_descriptor.Supports.IOSPWriteMCR &&
@@ -2441,27 +2558,26 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r
        if (edge_serial->is_epic &&
            !edge_serial->epic_descriptor.Supports.IOSPWriteLCR &&
            regNum == LCR) {
-               dbg ("SendCmdWriteUartReg - Not writing to LCR Register");
+               dbg("SendCmdWriteUartReg - Not writing to LCR Register");
                return 0;
        }
 
-       // Alloc memory for the string of commands.
-       cmdBuffer = kmalloc (0x10, GFP_ATOMIC);
-       if (cmdBuffer == NULL ) {
+       /* Alloc memory for the string of commands. */
+       cmdBuffer = kmalloc(0x10, GFP_ATOMIC);
+       if (cmdBuffer == NULL)
                return -ENOMEM;
-       }
 
        currCmd = cmdBuffer;
 
-       // Build a cmd in the buffer to write the given register
-       MAKE_CMD_WRITE_REG (&currCmd, &cmdLen,
-                           edge_port->port->number - edge_port->port->serial->minor,
-                           regNum, regValue);
+       /* Build a cmd in the buffer to write the given register */
+       MAKE_CMD_WRITE_REG(&currCmd, &cmdLen,
+               edge_port->port->number - edge_port->port->serial->minor,
+               regNum, regValue);
 
        status = write_cmd_usb(edge_port, cmdBuffer, cmdLen);
        if (status) {
                /* something bad happened, let's free up the memory */
-               kfree (cmdBuffer);
+               kfree(cmdBuffer);
        }
 
        return status;
@@ -2470,16 +2586,15 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r
 
 /*****************************************************************************
  * change_port_settings
- *     This routine is called to set the UART on the device to match the specified
- *     new settings.
+ *     This routine is called to set the UART on the device to match the
+ *     specified new settings.
  *****************************************************************************/
-#ifndef CMSPAR
-#define CMSPAR 0
-#endif
-static void change_port_settings (struct edgeport_port *edge_port, struct ktermios *old_termios)
+
+static void change_port_settings(struct tty_struct *tty,
+       struct edgeport_port *edge_port, struct ktermios *old_termios)
 {
-       struct edgeport_serial *edge_serial = usb_get_serial_data(edge_port->port->serial);
-       struct tty_struct *tty;
+       struct edgeport_serial *edge_serial =
+                       usb_get_serial_data(edge_port->port->serial);
        int baud;
        unsigned cflag;
        __u8 mask = 0xff;
@@ -2498,21 +2613,26 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
                return;
        }
 
-       tty = edge_port->port->tty;
-       if ((!tty) ||
-           (!tty->termios)) {
-               dbg("%s - no tty structures", __func__);
-               return;
-       }
-
        cflag = tty->termios->c_cflag;
 
        switch (cflag & CSIZE) {
-               case CS5:   lData = LCR_BITS_5; mask = 0x1f;    dbg("%s - data bits = 5", __func__);   break;
-               case CS6:   lData = LCR_BITS_6; mask = 0x3f;    dbg("%s - data bits = 6", __func__);   break;
-               case CS7:   lData = LCR_BITS_7; mask = 0x7f;    dbg("%s - data bits = 7", __func__);   break;
-               default:
-               case CS8:   lData = LCR_BITS_8;                 dbg("%s - data bits = 8", __func__);   break;
+       case CS5:
+               lData = LCR_BITS_5; mask = 0x1f;
+               dbg("%s - data bits = 5", __func__);
+               break;
+       case CS6:
+               lData = LCR_BITS_6; mask = 0x3f;
+               dbg("%s - data bits = 6", __func__);
+               break;
+       case CS7:
+               lData = LCR_BITS_7; mask = 0x7f;
+               dbg("%s - data bits = 7", __func__);
+               break;
+       default:
+       case CS8:
+               lData = LCR_BITS_8;
+               dbg("%s - data bits = 8", __func__);
+               break;
        }
 
        lParity = LCR_PAR_NONE;
@@ -2554,7 +2674,8 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
                dbg("%s - RTS/CTS is disabled", __func__);
        }
 
-       /* if we are implementing XON/XOFF, set the start and stop character in the device */
+       /* if we are implementing XON/XOFF, set the start and stop character
+          in the device */
        if (I_IXOFF(tty) || I_IXON(tty)) {
                unsigned char stop_char  = STOP_CHAR(tty);
                unsigned char start_char = START_CHAR(tty);
@@ -2562,14 +2683,17 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
                if ((!edge_serial->is_epic) ||
                    ((edge_serial->is_epic) &&
                     (edge_serial->epic_descriptor.Supports.IOSPSetXChar))) {
-                       send_iosp_ext_cmd(edge_port, IOSP_CMD_SET_XON_CHAR, start_char);
-                       send_iosp_ext_cmd(edge_port, IOSP_CMD_SET_XOFF_CHAR, stop_char);
+                       send_iosp_ext_cmd(edge_port,
+                                       IOSP_CMD_SET_XON_CHAR, start_char);
+                       send_iosp_ext_cmd(edge_port,
+                                       IOSP_CMD_SET_XOFF_CHAR, stop_char);
                }
 
                /* if we are implementing INBOUND XON/XOFF */
                if (I_IXOFF(tty)) {
                        rxFlow |= IOSP_RX_FLOW_XON_XOFF;
-                       dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __func__, start_char, stop_char);
+                       dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x",
+                                       __func__, start_char, stop_char);
                } else {
                        dbg("%s - INBOUND XON/XOFF is disabled", __func__);
                }
@@ -2577,7 +2701,8 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
                /* if we are implementing OUTBOUND XON/XOFF */
                if (I_IXON(tty)) {
                        txFlow |= IOSP_TX_FLOW_XON_XOFF;
-                       dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", __func__, start_char, stop_char);
+                       dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x",
+                                       __func__, start_char, stop_char);
                } else {
                        dbg("%s - OUTBOUND XON/XOFF is disabled", __func__);
                }
@@ -2600,20 +2725,20 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
        edge_port->validDataMask = mask;
 
        /* Send the updated LCR value to the EdgePort */
-       status = send_cmd_write_uart_register(edge_port, LCR, edge_port->shadowLCR);
-       if (status != 0) {
+       status = send_cmd_write_uart_register(edge_port, LCR,
+                                                       edge_port->shadowLCR);
+       if (status != 0)
                return;
-       }
 
        /* set up the MCR register and send it to the EdgePort */
        edge_port->shadowMCR = MCR_MASTER_IE;
-       if (cflag & CBAUD) {
+       if (cflag & CBAUD)
                edge_port->shadowMCR |= (MCR_DTR | MCR_RTS);
-       }
-       status = send_cmd_write_uart_register(edge_port, MCR, edge_port->shadowMCR);
-       if (status != 0) {
+
+       status = send_cmd_write_uart_register(edge_port, MCR,
+                                               edge_port->shadowMCR);
+       if (status != 0)
                return;
-       }
 
        /* Determine divisor based on baud rate */
        baud = tty_get_baud_rate(tty);
@@ -2623,7 +2748,7 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
        }
 
        dbg("%s - baud rate = %d", __func__, baud);
-       status = send_cmd_write_baud_rate (edge_port, baud);
+       status = send_cmd_write_baud_rate(edge_port, baud);
        if (status == -1) {
                /* Speed change was not possible - put back the old speed */
                baud = tty_termios_baud_rate(old_termios);
@@ -2640,7 +2765,8 @@ static void change_port_settings (struct edgeport_port *edge_port, struct ktermi
  *     ASCII range, but it's only for debugging...
  *     NOTE: expects the unicode in LE format
  ****************************************************************************/
-static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unicode_size)
+static void unicode_to_ascii(char *string, int buflen,
+                                       __le16 *unicode, int unicode_size)
 {
        int i;
 
@@ -2659,75 +2785,99 @@ static void unicode_to_ascii(char *string, int buflen, __le16 *unicode, int unic
 
 /****************************************************************************
  * get_manufacturing_desc
- *     reads in the manufacturing descriptor and stores it into the serial 
+ *     reads in the manufacturing descriptor and stores it into the serial
  *     structure.
  ****************************************************************************/
-static void get_manufacturing_desc (struct edgeport_serial *edge_serial)
+static void get_manufacturing_desc(struct edgeport_serial *edge_serial)
 {
        int response;
 
        dbg("getting manufacturer descriptor");
 
-       response = rom_read (edge_serial->serial, (EDGE_MANUF_DESC_ADDR & 0xffff0000) >> 16, 
-                           (__u16)(EDGE_MANUF_DESC_ADDR & 0x0000ffff), EDGE_MANUF_DESC_LEN,
-                           (__u8 *)(&edge_serial->manuf_descriptor));
+       response = rom_read(edge_serial->serial,
+                               (EDGE_MANUF_DESC_ADDR & 0xffff0000) >> 16,
+                               (__u16)(EDGE_MANUF_DESC_ADDR & 0x0000ffff),
+                               EDGE_MANUF_DESC_LEN,
+                               (__u8 *)(&edge_serial->manuf_descriptor));
 
-       if (response < 1) {
-               dev_err(&edge_serial->serial->dev->dev, "error in getting manufacturer descriptor\n");
-       } else {
+       if (response < 1)
+               dev_err(&edge_serial->serial->dev->dev,
+                       "error in getting manufacturer descriptor\n");
+       else {
                char string[30];
                dbg("**Manufacturer Descriptor");
-               dbg("  RomSize:        %dK", edge_serial->manuf_descriptor.RomSize);
-               dbg("  RamSize:        %dK", edge_serial->manuf_descriptor.RamSize);
-               dbg("  CpuRev:         %d", edge_serial->manuf_descriptor.CpuRev);
-               dbg("  BoardRev:       %d", edge_serial->manuf_descriptor.BoardRev);
-               dbg("  NumPorts:       %d", edge_serial->manuf_descriptor.NumPorts);
-               dbg("  DescDate:       %d/%d/%d", edge_serial->manuf_descriptor.DescDate[0], edge_serial->manuf_descriptor.DescDate[1], edge_serial->manuf_descriptor.DescDate[2]+1900);
+               dbg("  RomSize:        %dK",
+                       edge_serial->manuf_descriptor.RomSize);
+               dbg("  RamSize:        %dK",
+                       edge_serial->manuf_descriptor.RamSize);
+               dbg("  CpuRev:         %d",
+                       edge_serial->manuf_descriptor.CpuRev);
+               dbg("  BoardRev:       %d",
+                       edge_serial->manuf_descriptor.BoardRev);
+               dbg("  NumPorts:       %d",
+                       edge_serial->manuf_descriptor.NumPorts);
+               dbg("  DescDate:       %d/%d/%d",
+                       edge_serial->manuf_descriptor.DescDate[0],
+                       edge_serial->manuf_descriptor.DescDate[1],
+                       edge_serial->manuf_descriptor.DescDate[2]+1900);
                unicode_to_ascii(string, sizeof(string),
-                   edge_serial->manuf_descriptor.SerialNumber,
-                   edge_serial->manuf_descriptor.SerNumLength/2);
+                       edge_serial->manuf_descriptor.SerialNumber,
+                       edge_serial->manuf_descriptor.SerNumLength/2);
                dbg("  SerialNumber: %s", string);
                unicode_to_ascii(string, sizeof(string),
-                   edge_serial->manuf_descriptor.AssemblyNumber,
-                   edge_serial->manuf_descriptor.AssemblyNumLength/2);
+                       edge_serial->manuf_descriptor.AssemblyNumber,
+                       edge_serial->manuf_descriptor.AssemblyNumLength/2);
                dbg("  AssemblyNumber: %s", string);
                unicode_to_ascii(string, sizeof(string),
                    edge_serial->manuf_descriptor.OemAssyNumber,
                    edge_serial->manuf_descriptor.OemAssyNumLength/2);
                dbg("  OemAssyNumber:  %s", string);
-               dbg("  UartType:       %d", edge_serial->manuf_descriptor.UartType);
-               dbg("  IonPid:         %d", edge_serial->manuf_descriptor.IonPid);
-               dbg("  IonConfig:      %d", edge_serial->manuf_descriptor.IonConfig);
+               dbg("  UartType:       %d",
+                       edge_serial->manuf_descriptor.UartType);
+               dbg("  IonPid:         %d",
+                       edge_serial->manuf_descriptor.IonPid);
+               dbg("  IonConfig:      %d",
+                       edge_serial->manuf_descriptor.IonConfig);
        }
 }
 
 
 /****************************************************************************
  * get_boot_desc
- *     reads in the bootloader descriptor and stores it into the serial 
+ *     reads in the bootloader descriptor and stores it into the serial
  *     structure.
  ****************************************************************************/
-static void get_boot_desc (struct edgeport_serial *edge_serial)
+static void get_boot_desc(struct edgeport_serial *edge_serial)
 {
        int response;
 
        dbg("getting boot descriptor");
 
-       response = rom_read (edge_serial->serial, (EDGE_BOOT_DESC_ADDR & 0xffff0000) >> 16, 
-                           (__u16)(EDGE_BOOT_DESC_ADDR & 0x0000ffff), EDGE_BOOT_DESC_LEN,
-                           (__u8 *)(&edge_serial->boot_descriptor));
+       response = rom_read(edge_serial->serial,
+                               (EDGE_BOOT_DESC_ADDR & 0xffff0000) >> 16,
+                               (__u16)(EDGE_BOOT_DESC_ADDR & 0x0000ffff),
+                               EDGE_BOOT_DESC_LEN,
+                               (__u8 *)(&edge_serial->boot_descriptor));
 
-       if (response < 1) {
-               dev_err(&edge_serial->serial->dev->dev, "error in getting boot descriptor\n");
-       } else {
+       if (response < 1)
+               dev_err(&edge_serial->serial->dev->dev,
+                               "error in getting boot descriptor\n");
+       else {
                dbg("**Boot Descriptor:");
-               dbg("  BootCodeLength: %d", le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength));
-               dbg("  MajorVersion:   %d", edge_serial->boot_descriptor.MajorVersion);
-               dbg("  MinorVersion:   %d", edge_serial->boot_descriptor.MinorVersion);
-               dbg("  BuildNumber:    %d", le16_to_cpu(edge_serial->boot_descriptor.BuildNumber));
-               dbg("  Capabilities:   0x%x", le16_to_cpu(edge_serial->boot_descriptor.Capabilities));
-               dbg("  UConfig0:       %d", edge_serial->boot_descriptor.UConfig0);
-               dbg("  UConfig1:       %d", edge_serial->boot_descriptor.UConfig1);
+               dbg("  BootCodeLength: %d",
+                   le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength));
+               dbg("  MajorVersion:   %d",
+                       edge_serial->boot_descriptor.MajorVersion);
+               dbg("  MinorVersion:   %d",
+                       edge_serial->boot_descriptor.MinorVersion);
+               dbg("  BuildNumber:    %d",
+                       le16_to_cpu(edge_serial->boot_descriptor.BuildNumber));
+               dbg("  Capabilities:   0x%x",
+                     le16_to_cpu(edge_serial->boot_descriptor.Capabilities));
+               dbg("  UConfig0:       %d",
+                       edge_serial->boot_descriptor.UConfig0);
+               dbg("  UConfig1:       %d",
+                       edge_serial->boot_descriptor.UConfig1);
        }
 }
 
@@ -2736,7 +2886,7 @@ static void get_boot_desc (struct edgeport_serial *edge_serial)
  * load_application_firmware
  *     This is called to load the application firmware to the device
  ****************************************************************************/
-static void load_application_firmware (struct edgeport_serial *edge_serial)
+static void load_application_firmware(struct edgeport_serial *edge_serial)
 {
        const struct ihex_binrec *rec;
        const struct firmware *fw;
@@ -2813,7 +2963,7 @@ static void load_application_firmware (struct edgeport_serial *edge_serial)
 /****************************************************************************
  * edge_startup
  ****************************************************************************/
-static int edge_startup (struct usb_serial *serial)
+static int edge_startup(struct usb_serial *serial)
 {
        struct edgeport_serial *edge_serial;
        struct edgeport_port *edge_port;
@@ -2855,10 +3005,10 @@ static int edge_startup (struct usb_serial *serial)
                       sizeof(struct edge_compatibility_bits));
 
                /* get the manufacturing descriptor for this device */
-               get_manufacturing_desc (edge_serial);
+               get_manufacturing_desc(edge_serial);
 
                /* get the boot descriptor */
-               get_boot_desc (edge_serial);
+               get_boot_desc(edge_serial);
 
                get_product_info(edge_serial);
        }
@@ -2879,41 +3029,43 @@ static int edge_startup (struct usb_serial *serial)
        /* If not an EPiC device */
        if (!edge_serial->is_epic) {
                /* now load the application firmware into this device */
-               load_application_firmware (edge_serial);
+               load_application_firmware(edge_serial);
 
                dbg("%s - time 2 %ld", __func__, jiffies);
 
                /* Check current Edgeport EEPROM and update if necessary */
-               update_edgeport_E2PROM (edge_serial);
+               update_edgeport_E2PROM(edge_serial);
 
                dbg("%s - time 3 %ld", __func__, jiffies);
 
                /* set the configuration to use #1 */
-//             dbg("set_configuration 1");
-//             usb_set_configuration (dev, 1);
+/*             dbg("set_configuration 1"); */
+/*             usb_set_configuration (dev, 1); */
        }
        dbg("  FirmwareMajorVersion  %d.%d.%d",
            edge_serial->product_info.FirmwareMajorVersion,
            edge_serial->product_info.FirmwareMinorVersion,
            le16_to_cpu(edge_serial->product_info.FirmwareBuildNumber));
 
-       /* we set up the pointers to the endpoints in the edge_open function, 
+       /* we set up the pointers to the endpoints in the edge_open function,
         * as the structures aren't created yet. */
 
        /* set up our port private structures */
        for (i = 0; i < serial->num_ports; ++i) {
-               edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
+               edge_port = kmalloc(sizeof(struct edgeport_port), GFP_KERNEL);
                if (edge_port == NULL) {
-                       dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__);
+                       dev_err(&serial->dev->dev, "%s - Out of memory\n",
+                                                                  __func__);
                        for (j = 0; j < i; ++j) {
-                               kfree (usb_get_serial_port_data(serial->port[j]));
-                               usb_set_serial_port_data(serial->port[j],  NULL);
+                               kfree(usb_get_serial_port_data(serial->port[j]));
+                               usb_set_serial_port_data(serial->port[j],
+                                                                       NULL);
                        }
                        usb_set_serial_data(serial, NULL);
                        kfree(edge_serial);
                        return -ENOMEM;
                }
-               memset (edge_port, 0, sizeof(struct edgeport_port));
+               memset(edge_port, 0, sizeof(struct edgeport_port));
                spin_lock_init(&edge_port->ep_lock);
                edge_port->port = serial->port[i];
                usb_set_serial_port_data(serial->port[i], edge_port);
@@ -2922,14 +3074,16 @@ static int edge_startup (struct usb_serial *serial)
        response = 0;
 
        if (edge_serial->is_epic) {
-               /* EPIC thing, set up our interrupt polling now and our read urb, so
-                * that the device knows it really is connected. */
+               /* EPIC thing, set up our interrupt polling now and our read
+                * urb, so that the device knows it really is connected. */
                interrupt_in_found = bulk_in_found = bulk_out_found = false;
-               for (i = 0; i < serial->interface->altsetting[0].desc.bNumEndpoints; ++i) {
+               for (i = 0; i < serial->interface->altsetting[0]
+                                               .desc.bNumEndpoints; ++i) {
                        struct usb_endpoint_descriptor *endpoint;
                        int buffer_size;
 
-                       endpoint = &serial->interface->altsetting[0].endpoint[i].desc;
+                       endpoint = &serial->interface->altsetting[0].
+                                                       endpoint[i].desc;
                        buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
                        if (!interrupt_in_found &&
                            (usb_endpoint_is_int_in(endpoint))) {
@@ -2937,58 +3091,67 @@ static int edge_startup (struct usb_serial *serial)
                                dbg("found interrupt in");
 
                                /* not set up yet, so do it now */
-                               edge_serial->interrupt_read_urb = usb_alloc_urb(0, GFP_KERNEL);
+                               edge_serial->interrupt_read_urb =
+                                               usb_alloc_urb(0, GFP_KERNEL);
                                if (!edge_serial->interrupt_read_urb) {
                                        err("out of memory");
                                        return -ENOMEM;
                                }
-                               edge_serial->interrupt_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
+                               edge_serial->interrupt_in_buffer =
+                                       kmalloc(buffer_size, GFP_KERNEL);
                                if (!edge_serial->interrupt_in_buffer) {
                                        err("out of memory");
                                        usb_free_urb(edge_serial->interrupt_read_urb);
                                        return -ENOMEM;
                                }
-                               edge_serial->interrupt_in_endpoint = endpoint->bEndpointAddress;
+                               edge_serial->interrupt_in_endpoint =
+                                               endpoint->bEndpointAddress;
 
                                /* set up our interrupt urb */
-                               usb_fill_int_urb(edge_serial->interrupt_read_urb,
-                                                dev,
-                                                usb_rcvintpipe(dev, endpoint->bEndpointAddress),
-                                                edge_serial->interrupt_in_buffer,
-                                                buffer_size,
-                                                edge_interrupt_callback,
-                                                edge_serial,
-                                                endpoint->bInterval);
+                               usb_fill_int_urb(
+                                       edge_serial->interrupt_read_urb,
+                                       dev,
+                                       usb_rcvintpipe(dev,
+                                               endpoint->bEndpointAddress),
+                                       edge_serial->interrupt_in_buffer,
+                                       buffer_size,
+                                       edge_interrupt_callback,
+                                       edge_serial,
+                                       endpoint->bInterval);
 
                                interrupt_in_found = true;
                        }
 
                        if (!bulk_in_found &&
-                           (usb_endpoint_is_bulk_in(endpoint))) {
+                               (usb_endpoint_is_bulk_in(endpoint))) {
                                /* we found a bulk in endpoint */
                                dbg("found bulk in");
 
                                /* not set up yet, so do it now */
-                               edge_serial->read_urb = usb_alloc_urb(0, GFP_KERNEL);
+                               edge_serial->read_urb =
+                                               usb_alloc_urb(0, GFP_KERNEL);
                                if (!edge_serial->read_urb) {
                                        err("out of memory");
                                        return -ENOMEM;
                                }
-                               edge_serial->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
+                               edge_serial->bulk_in_buffer =
+                                       kmalloc(buffer_size, GFP_KERNEL);
                                if (!edge_serial->bulk_in_buffer) {
-                                       err ("out of memory");
+                                       err("out of memory");
                                        usb_free_urb(edge_serial->read_urb);
                                        return -ENOMEM;
                                }
-                               edge_serial->bulk_in_endpoint = endpoint->bEndpointAddress;
+                               edge_serial->bulk_in_endpoint =
+                                               endpoint->bEndpointAddress;
 
                                /* set up our bulk in urb */
                                usb_fill_bulk_urb(edge_serial->read_urb, dev,
-                                                 usb_rcvbulkpipe(dev, endpoint->bEndpointAddress),
-                                                 edge_serial->bulk_in_buffer,
-                                                 le16_to_cpu(endpoint->wMaxPacketSize),
-                                                 edge_bulk_in_callback,
-                                                 edge_serial);
+                                       usb_rcvbulkpipe(dev,
+                                               endpoint->bEndpointAddress),
+                                       edge_serial->bulk_in_buffer,
+                                       le16_to_cpu(endpoint->wMaxPacketSize),
+                                       edge_bulk_in_callback,
+                                       edge_serial);
                                bulk_in_found = true;
                        }
 
@@ -2996,21 +3159,24 @@ static int edge_startup (struct usb_serial *serial)
                            (usb_endpoint_is_bulk_out(endpoint))) {
                                /* we found a bulk out endpoint */
                                dbg("found bulk out");
-                               edge_serial->bulk_out_endpoint = endpoint->bEndpointAddress;
+                               edge_serial->bulk_out_endpoint =
+                                               endpoint->bEndpointAddress;
                                bulk_out_found = true;
                        }
                }
 
                if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) {
-                       err ("Error - the proper endpoints were not found!");
+                       err("Error - the proper endpoints were not found!");
                        return -ENODEV;
                }
 
                /* start interrupt read for this edgeport this interrupt will
                 * continue as long as the edgeport is connected */
-               response = usb_submit_urb(edge_serial->interrupt_read_urb, GFP_KERNEL);
+               response = usb_submit_urb(edge_serial->interrupt_read_urb,
+                                                               GFP_KERNEL);
                if (response)
-                       err("%s - Error %d submitting control urb", __func__, response);
+                       err("%s - Error %d submitting control urb",
+                                                       __func__, response);
        }
        return response;
 }
@@ -3020,7 +3186,7 @@ static int edge_startup (struct usb_serial *serial)
  * edge_shutdown
  *     This function is called whenever the device is removed from the usb bus.
  ****************************************************************************/
-static void edge_shutdown (struct usb_serial *serial)
+static void edge_shutdown(struct usb_serial *serial)
 {
        struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
        int i;
@@ -3028,8 +3194,8 @@ static void edge_shutdown (struct usb_serial *serial)
        dbg("%s", __func__);
 
        /* stop reads and writes on all ports */
-       for (i=0; i < serial->num_ports; ++i) {
-               kfree (usb_get_serial_port_data(serial->port[i]));
+       for (i = 0; i < serial->num_ports; ++i) {
+               kfree(usb_get_serial_port_data(serial->port[i]));
                usb_set_serial_port_data(serial->port[i],  NULL);
        }
        /* free up our endpoint stuff */
@@ -3069,7 +3235,7 @@ static int __init edgeport_init(void)
        if (retval)
                goto failed_epic_device_register;
        retval = usb_register(&io_driver);
-       if (retval) 
+       if (retval)
                goto failed_usb_register;
        atomic_set(&CmdUrbs, 0);
        info(DRIVER_DESC " " DRIVER_VERSION);
@@ -3094,19 +3260,19 @@ failed_2port_device_register:
  ****************************************************************************/
 static void __exit edgeport_exit (void)
 {
-       usb_deregister (&io_driver);
-       usb_serial_deregister (&edgeport_2port_device);
-       usb_serial_deregister (&edgeport_4port_device);
-       usb_serial_deregister (&edgeport_8port_device);
-       usb_serial_deregister (&epic_device);
+       usb_deregister(&io_driver);
+       usb_serial_deregister(&edgeport_2port_device);
+       usb_serial_deregister(&edgeport_4port_device);
+       usb_serial_deregister(&edgeport_8port_device);
+       usb_serial_deregister(&epic_device);
 }
 
 module_init(edgeport_init);
 module_exit(edgeport_exit);
 
 /* Module information */
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 MODULE_FIRMWARE("edgeport/boot.fw");
 MODULE_FIRMWARE("edgeport/boot2.fw");
index 2ec8589..7eb9d67 100644 (file)
@@ -8,7 +8,7 @@
  *     it under the terms of the GNU General Public License as published by
  *     the Free Software Foundation; either version 2 of the License, or
  *     (at your option) any later version.
- * 
+ *
  */
 
 #ifndef IO_TABLES_H
@@ -90,10 +90,10 @@ static struct usb_device_id id_table_combined [] = {
        { USB_DEVICE(USB_VENDOR_ID_AXIOHM, AXIOHM_DEVICE_ID_EPIC_A758) },
        { USB_DEVICE(USB_VENDOR_ID_AXIOHM, AXIOHM_DEVICE_ID_EPIC_A794) },
        { USB_DEVICE(USB_VENDOR_ID_AXIOHM, AXIOHM_DEVICE_ID_EPIC_A225) },
-       { }                                                     /* Terminating entry */
+       { } /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table_combined);
+MODULE_DEVICE_TABLE(usb, id_table_combined);
 
 static struct usb_driver io_driver = {
        .name =         "io_edgeport",
index a58822a..cb4c543 100644 (file)
@@ -243,9 +243,9 @@ static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
 static void stop_read(struct edgeport_port *edge_port);
 static int restart_read(struct edgeport_port *edge_port);
 
-static void edge_set_termios(struct usb_serial_port *port,
-                            struct ktermios *old_termios);
-static void edge_send(struct usb_serial_port *port);
+static void edge_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios);
+static void edge_send(struct tty_struct *tty);
 
 /* sysfs attributes */
 static int edge_create_sysfs_attrs(struct usb_serial_port *port);
@@ -572,7 +572,7 @@ static void chase_port(struct edgeport_port *port, unsigned long timeout,
                                                                int flush)
 {
        int baud_rate;
-       struct tty_struct *tty = port->port->tty;
+       struct tty_struct *tty = port->port->port.tty;
        wait_queue_t wait;
        unsigned long flags;
 
@@ -1554,7 +1554,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr)
        /* Save the new modem status */
        edge_port->shadow_msr = msr & 0xf0;
 
-       tty = edge_port->port->tty;
+       tty = edge_port->port->port.tty;
        /* handle CTS flow control */
        if (tty && C_CRTSCTS(tty)) {
                if (msr & EDGEPORT_MSR_CTS) {
@@ -1587,9 +1587,8 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
                new_lsr &= (__u8)(LSR_OVER_ERR | LSR_BREAK);
 
        /* Place LSR data byte into Rx buffer */
-       if (lsr_data && edge_port->port->tty)
-               edge_tty_recv(&edge_port->port->dev, edge_port->port->tty,
-                                                               &data, 1);
+       if (lsr_data && edge_port->port->port.tty)
+               edge_tty_recv(&edge_port->port->dev, edge_port->port->port.tty, &data, 1);
 
        /* update input line counters */
        icount = &edge_port->icount;
@@ -1750,7 +1749,7 @@ static void edge_bulk_in_callback(struct urb *urb)
                ++data;
        }
 
-       tty = edge_port->port->tty;
+       tty = edge_port->port->port.tty;
        if (tty && urb->actual_length) {
                usb_serial_debug_data(debug, &edge_port->port->dev,
                                        __func__, urb->actual_length, data);
@@ -1819,10 +1818,11 @@ static void edge_bulk_out_callback(struct urb *urb)
        }
 
        /* send any buffered data */
-       edge_send(port);
+       edge_send(port->port.tty);
 }
 
-static int edge_open(struct usb_serial_port *port, struct file *filp)
+static int edge_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        struct edgeport_serial *edge_serial;
@@ -1838,7 +1838,8 @@ static int edge_open(struct usb_serial_port *port, struct file *filp)
        if (edge_port == NULL)
                return -ENODEV;
 
-       port->tty->low_latency = low_latency;
+       if (tty)
+               tty->low_latency = low_latency;
 
        port_number = port->number - port->serial->minor;
        switch (port_number) {
@@ -1874,7 +1875,8 @@ static int edge_open(struct usb_serial_port *port, struct file *filp)
        }
 
        /* set up the port settings */
-       edge_set_termios(port, port->tty->termios);
+       if (tty)
+               edge_set_termios(tty, port, port->port.tty->termios);
 
        /* open up the port */
 
@@ -2000,7 +2002,8 @@ release_es_lock:
        return status;
 }
 
-static void edge_close(struct usb_serial_port *port, struct file *filp)
+static void edge_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct edgeport_serial *edge_serial;
        struct edgeport_port *edge_port;
@@ -2048,8 +2051,8 @@ static void edge_close(struct usb_serial_port *port, struct file *filp)
        dbg("%s - exited", __func__);
 }
 
-static int edge_write(struct usb_serial_port *port, const unsigned char *data,
-                                                               int count)
+static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
+                               const unsigned char *data, int count)
 {
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        unsigned long flags;
@@ -2070,16 +2073,16 @@ static int edge_write(struct usb_serial_port *port, const unsigned char *data,
        count = edge_buf_put(edge_port->ep_out_buf, data, count);
        spin_unlock_irqrestore(&edge_port->ep_lock, flags);
 
-       edge_send(port);
+       edge_send(tty);
 
        return count;
 }
 
-static void edge_send(struct usb_serial_port *port)
+static void edge_send(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        int count, result;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
-       struct tty_struct *tty = port->tty;
        unsigned long flags;
 
 
@@ -2133,8 +2136,9 @@ static void edge_send(struct usb_serial_port *port)
                tty_wakeup(tty);
 }
 
-static int edge_write_room(struct usb_serial_port *port)
+static int edge_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        int room = 0;
        unsigned long flags;
@@ -2154,8 +2158,9 @@ static int edge_write_room(struct usb_serial_port *port)
        return room;
 }
 
-static int edge_chars_in_buffer(struct usb_serial_port *port)
+static int edge_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        int chars = 0;
        unsigned long flags;
@@ -2175,10 +2180,10 @@ static int edge_chars_in_buffer(struct usb_serial_port *port)
        return chars;
 }
 
-static void edge_throttle(struct usb_serial_port *port)
+static void edge_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
-       struct tty_struct *tty = port->tty;
        int status;
 
        dbg("%s - port %d", __func__, port->number);
@@ -2189,11 +2194,10 @@ static void edge_throttle(struct usb_serial_port *port)
        /* if we are implementing XON/XOFF, send the stop character */
        if (I_IXOFF(tty)) {
                unsigned char stop_char = STOP_CHAR(tty);
-               status = edge_write(port, &stop_char, 1);
-               if (status <= 0)
-                       dev_err(&port->dev,
-                               "%s - failed to write stop character, %d\n",
-                                                       __func__, status);
+               status = edge_write(tty, port, &stop_char, 1);
+               if (status <= 0) {
+                       dev_err(&port->dev, "%s - failed to write stop character, %d\n", __func__, status);
+               }
        }
 
        /* if we are implementing RTS/CTS, stop reads */
@@ -2203,10 +2207,10 @@ static void edge_throttle(struct usb_serial_port *port)
 
 }
 
-static void edge_unthrottle(struct usb_serial_port *port)
+static void edge_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
-       struct tty_struct *tty = port->tty;
        int status;
 
        dbg("%s - port %d", __func__, port->number);
@@ -2217,11 +2221,10 @@ static void edge_unthrottle(struct usb_serial_port *port)
        /* if we are implementing XON/XOFF, send the start character */
        if (I_IXOFF(tty)) {
                unsigned char start_char = START_CHAR(tty);
-               status = edge_write(port, &start_char, 1);
-               if (status <= 0)
-                       dev_err(&port->dev,
-                               "%s - failed to write start character, %d\n",
-                                                       __func__, status);
+               status = edge_write(tty, port, &start_char, 1);
+               if (status <= 0) {
+                       dev_err(&port->dev, "%s - failed to write start character, %d\n", __func__, status);
+               }
        }
        /* if we are implementing RTS/CTS, restart reads */
        /* are the Edgeport will assert the RTS line */
@@ -2271,11 +2274,10 @@ static int restart_read(struct edgeport_port *edge_port)
        return status;
 }
 
-static void change_port_settings(struct edgeport_port *edge_port,
-                                               struct ktermios *old_termios)
+static void change_port_settings(struct tty_struct *tty,
+               struct edgeport_port *edge_port, struct ktermios *old_termios)
 {
        struct ump_uart_config *config;
-       struct tty_struct *tty;
        int baud;
        unsigned cflag;
        int status;
@@ -2284,9 +2286,7 @@ static void change_port_settings(struct edgeport_port *edge_port,
 
        dbg("%s - port %d", __func__, edge_port->port->number);
 
-       tty = edge_port->port->tty;
-
-       config = kmalloc(sizeof(*config), GFP_KERNEL);
+       config = kmalloc (sizeof (*config), GFP_KERNEL);
        if (!config) {
                *tty->termios = *old_termios;
                dev_err(&edge_port->port->dev, "%s - out of memory\n",
@@ -2419,11 +2419,13 @@ static void change_port_settings(struct edgeport_port *edge_port,
        return;
 }
 
-static void edge_set_termios(struct usb_serial_port *port,
-                                       struct ktermios *old_termios)
+static void edge_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
-       struct tty_struct *tty = port->tty;
+       unsigned int cflag;
+
+       cflag = tty->termios->c_cflag;
 
        dbg("%s - clfag %08x iflag %08x", __func__,
            tty->termios->c_cflag, tty->termios->c_iflag);
@@ -2434,12 +2436,14 @@ static void edge_set_termios(struct usb_serial_port *port,
        if (edge_port == NULL)
                return;
        /* change the port settings to the new ones specified */
-       change_port_settings(edge_port, old_termios);
+       change_port_settings(tty, edge_port, old_termios);
+       return;
 }
 
-static int edge_tiocmset(struct usb_serial_port *port, struct file *file,
+static int edge_tiocmset(struct tty_struct *tty, struct file *file,
                                        unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        unsigned int mcr;
        unsigned long flags;
@@ -2469,8 +2473,9 @@ static int edge_tiocmset(struct usb_serial_port *port, struct file *file,
        return 0;
 }
 
-static int edge_tiocmget(struct usb_serial_port *port, struct file *file)
+static int edge_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        unsigned int result = 0;
        unsigned int msr;
@@ -2522,9 +2527,10 @@ static int get_serial_info(struct edgeport_port *edge_port,
        return 0;
 }
 
-static int edge_ioctl(struct usb_serial_port *port, struct file *file,
+static int edge_ioctl(struct tty_struct *tty, struct file *file,
                                        unsigned int cmd, unsigned long arg)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        struct async_icount cnow;
        struct async_icount cprev;
@@ -2569,18 +2575,19 @@ static int edge_ioctl(struct usb_serial_port *port, struct file *file,
        return -ENOIOCTLCMD;
 }
 
-static void edge_break(struct usb_serial_port *port, int on)
+static void edge_break(struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct edgeport_port *edge_port = usb_get_serial_port_data(port);
        int status;
        int bv = 0;     /* Off */
 
-       dbg("%s - state = %d", __func__, on);
+       dbg("%s - state = %d", __func__, break_state);
 
        /* chase the port close */
        chase_port(edge_port, 0, 0);
 
-       if (on == -1)
+       if (break_state == -1)
                bv = 1; /* On */
        status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv);
        if (status)
index 80d9ec5..832a5a4 100644 (file)
@@ -53,7 +53,7 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include "ipaq.h"
@@ -74,19 +74,21 @@ static int connect_retries = KP_RETRIES;
 static int initial_wait;
 
 /* Function prototypes for an ipaq */
-static int  ipaq_open (struct usb_serial_port *port, struct file *filp);
-static void ipaq_close (struct usb_serial_port *port, struct file *filp);
-static int  ipaq_startup (struct usb_serial *serial);
-static void ipaq_shutdown (struct usb_serial *serial);
-static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf,
-                      int count);
-static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf,
-                          int count);
+static int  ipaq_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void ipaq_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static int  ipaq_startup(struct usb_serial *serial);
+static void ipaq_shutdown(struct usb_serial *serial);
+static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,
+                       const unsigned char *buf, int count);
+static int ipaq_write_bulk(struct usb_serial_port *port,
+                               const unsigned char *buf, int count);
 static void ipaq_write_gather(struct usb_serial_port *port);
-static void ipaq_read_bulk_callback (struct urb *urb);
+static void ipaq_read_bulk_callback(struct urb *urb);
 static void ipaq_write_bulk_callback(struct urb *urb);
-static int ipaq_write_room(struct usb_serial_port *port);
-static int ipaq_chars_in_buffer(struct usb_serial_port *port);
+static int ipaq_write_room(struct tty_struct *tty);
+static int ipaq_chars_in_buffer(struct tty_struct *tty);
 static void ipaq_destroy_lists(struct usb_serial_port *port);
 
 
@@ -550,7 +552,7 @@ static struct usb_device_id ipaq_id_table [] = {
        { }                             /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, ipaq_id_table);
+MODULE_DEVICE_TABLE(usb, ipaq_id_table);
 
 static struct usb_driver ipaq_driver = {
        .name =         "ipaq",
@@ -591,7 +593,8 @@ static spinlock_t   write_list_lock;
 static int             bytes_in;
 static int             bytes_out;
 
-static int ipaq_open(struct usb_serial_port *port, struct file *filp)
+static int ipaq_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial       *serial = port->serial;
        struct ipaq_private     *priv;
@@ -617,9 +620,9 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
 
        for (i = 0; i < URBDATA_QUEUE_MAX / PACKET_SIZE; i++) {
                pkt = kmalloc(sizeof(struct ipaq_packet), GFP_KERNEL);
-               if (pkt == NULL) {
+               if (pkt == NULL)
                        goto enomem;
-               }
+
                pkt->data = kmalloc(PACKET_SIZE, GFP_KERNEL);
                if (pkt->data == NULL) {
                        kfree(pkt);
@@ -637,10 +640,12 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
         * discipline instead of queueing.
         */
 
-       port->tty->low_latency = 1;
-       port->tty->raw = 1;
-       port->tty->real_raw = 1;
-
+       if (tty) {
+               tty->low_latency = 1;
+               /* FIXME: These two are bogus */
+               tty->raw = 1;
+               tty->real_raw = 1;
+       }
        /*
         * Lose the small buffers usbserial provides. Make larger ones.
         */
@@ -662,8 +667,9 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
        port->read_urb->transfer_buffer = port->bulk_in_buffer;
        port->write_urb->transfer_buffer = port->bulk_out_buffer;
        port->read_urb->transfer_buffer_length = URBDATA_SIZE;
-       port->bulk_out_size = port->write_urb->transfer_buffer_length = URBDATA_SIZE;
-       
+       port->bulk_out_size = port->write_urb->transfer_buffer_length
+                                                       = URBDATA_SIZE;
+
        msleep(1000*initial_wait);
 
        /*
@@ -692,13 +698,15 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
 
        /* Start reading from the device */
        usb_fill_bulk_urb(port->read_urb, serial->dev,
-                     usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
-                     port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
-                     ipaq_read_bulk_callback, port);
+               usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
+               port->read_urb->transfer_buffer,
+               port->read_urb->transfer_buffer_length,
+               ipaq_read_bulk_callback, port);
 
        result = usb_submit_urb(port->read_urb, GFP_KERNEL);
        if (result) {
-               err("%s - failed submitting read urb, error %d", __func__, result);
+               err("%s - failed submitting read urb, error %d",
+                                               __func__, result);
                goto error;
        }
 
@@ -714,12 +722,13 @@ error:
 }
 
 
-static void ipaq_close(struct usb_serial_port *port, struct file *filp)
+static void ipaq_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct ipaq_private     *priv = usb_get_serial_port_data(port);
 
        dbg("%s - port %d", __func__, port->number);
-                        
+
        /*
         * shut down bulk read and write
         */
@@ -729,7 +738,8 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp)
        kfree(priv);
        usb_set_serial_port_data(port, NULL);
 
-       /* Uncomment the following line if you want to see some statistics in your syslog */
+       /* Uncomment the following line if you want to see some statistics
+        * in your syslog */
        /* info ("Bytes In = %d  Bytes Out = %d", bytes_in, bytes_out); */
 }
 
@@ -749,9 +759,10 @@ static void ipaq_read_bulk_callback(struct urb *urb)
                return;
        }
 
-       usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                               urb->actual_length, data);
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (tty && urb->actual_length) {
                tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
@@ -760,18 +771,20 @@ static void ipaq_read_bulk_callback(struct urb *urb)
        }
 
        /* Continue trying to always read  */
-       usb_fill_bulk_urb(port->read_urb, port->serial->dev, 
-                     usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
-                     port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
-                     ipaq_read_bulk_callback, port);
+       usb_fill_bulk_urb(port->read_urb, port->serial->dev,
+           usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
+           port->read_urb->transfer_buffer,
+           port->read_urb->transfer_buffer_length,
+           ipaq_read_bulk_callback, port);
        result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
        if (result)
-               err("%s - failed resubmitting read urb, error %d", __func__, result);
+               err("%s - failed resubmitting read urb, error %d",
+                                                       __func__, result);
        return;
 }
 
-static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf,
-                      int count)
+static int ipaq_write(struct tty_struct *tty, struct usb_serial_port *port,
+                       const unsigned char *buf, int count)
 {
        const unsigned char     *current_position = buf;
        int                     bytes_sent = 0;
@@ -781,9 +794,8 @@ static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf,
 
        while (count > 0) {
                transfer_size = min(count, PACKET_SIZE);
-               if (ipaq_write_bulk(port, current_position, transfer_size)) {
+               if (ipaq_write_bulk(port, current_position, transfer_size))
                        break;
-               }
                current_position += transfer_size;
                bytes_sent += transfer_size;
                count -= transfer_size;
@@ -791,10 +803,10 @@ static int ipaq_write(struct usb_serial_port *port, const unsigned char *buf,
        }
 
        return bytes_sent;
-} 
+}
 
-static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *buf,
-                          int count)
+static int ipaq_write_bulk(struct usb_serial_port *port,
+                                       const unsigned char *buf, int count)
 {
        struct ipaq_private     *priv = usb_get_serial_port_data(port);
        struct ipaq_packet      *pkt = NULL;
@@ -831,9 +843,9 @@ static int ipaq_write_bulk(struct usb_serial_port *port, const unsigned char *bu
                ipaq_write_gather(port);
                spin_unlock_irqrestore(&write_list_lock, flags);
                result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
-               if (result) {
-                       err("%s - failed submitting write urb, error %d", __func__, result);
-               }
+               if (result)
+                       err("%s - failed submitting write urb, error %d",
+                               __func__, result);
        } else {
                spin_unlock_irqrestore(&write_list_lock, flags);
        }
@@ -860,16 +872,15 @@ static void ipaq_write_gather(struct usb_serial_port *port)
                        list_move(&pkt->list, &priv->freelist);
                        priv->free_len += PACKET_SIZE;
                }
-               if (room == 0) {
+               if (room == 0)
                        break;
-               }
        }
 
        count = URBDATA_SIZE - room;
-       usb_fill_bulk_urb(port->write_urb, serial->dev, 
-                     usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress),
-                     port->write_urb->transfer_buffer, count, ipaq_write_bulk_callback,
-                     port);
+       usb_fill_bulk_urb(port->write_urb, serial->dev,
+               usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress),
+               port->write_urb->transfer_buffer, count,
+               ipaq_write_bulk_callback, port);
        return;
 }
 
@@ -894,9 +905,9 @@ static void ipaq_write_bulk_callback(struct urb *urb)
                ipaq_write_gather(port);
                spin_unlock_irqrestore(&write_list_lock, flags);
                result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
-               if (result) {
-                       err("%s - failed submitting write urb, error %d", __func__, result);
-               }
+               if (result)
+                       err("%s - failed submitting write urb, error %d",
+                                       __func__, result);
        } else {
                priv->active = 0;
                spin_unlock_irqrestore(&write_list_lock, flags);
@@ -905,16 +916,18 @@ static void ipaq_write_bulk_callback(struct urb *urb)
        usb_serial_port_softint(port);
 }
 
-static int ipaq_write_room(struct usb_serial_port *port)
+static int ipaq_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ipaq_private     *priv = usb_get_serial_port_data(port);
 
        dbg("%s - freelen %d", __func__, priv->free_len);
        return priv->free_len;
 }
 
-static int ipaq_chars_in_buffer(struct usb_serial_port *port)
+static int ipaq_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ipaq_private     *priv = usb_get_serial_port_data(port);
 
        dbg("%s - queuelen %d", __func__, priv->queue_len);
@@ -945,7 +958,7 @@ static int ipaq_startup(struct usb_serial *serial)
                        serial->dev->actconfig->desc.bConfigurationValue);
                return -ENODEV;
        }
-       return usb_reset_configuration (serial->dev);
+       return usb_reset_configuration(serial->dev);
 }
 
 static void ipaq_shutdown(struct usb_serial *serial)
@@ -958,7 +971,7 @@ static int __init ipaq_init(void)
        int retval;
        spin_lock_init(&write_list_lock);
        retval = usb_serial_register(&ipaq_device);
-       if (retval) 
+       if (retval)
                goto failed_usb_serial_register;
        info(DRIVER_DESC " " DRIVER_VERSION);
        if (vendor) {
@@ -968,7 +981,7 @@ static int __init ipaq_init(void)
        retval = usb_register(&ipaq_driver);
        if (retval)
                goto failed_usb_register;
-                 
+
        return 0;
 failed_usb_register:
        usb_serial_deregister(&ipaq_device);
@@ -987,8 +1000,8 @@ static void __exit ipaq_exit(void)
 module_init(ipaq_init);
 module_exit(ipaq_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
@@ -1001,7 +1014,9 @@ module_param(product, ushort, 0);
 MODULE_PARM_DESC(product, "User specified USB idProduct");
 
 module_param(connect_retries, int, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(connect_retries, "Maximum number of connect retries (one second each)");
+MODULE_PARM_DESC(connect_retries,
+               "Maximum number of connect retries (one second each)");
 
 module_param(initial_wait, int, S_IRUGO|S_IWUSR);
-MODULE_PARM_DESC(initial_wait, "Time to wait before attempting a connection (in seconds)");
+MODULE_PARM_DESC(initial_wait,
+               "Time to wait before attempting a connection (in seconds)");
index bc85ca5..a842025 100644 (file)
  *   (at your option) any later version.
  *
  * All information about the device was acquired using SnoopyPro
- * on MSFT's O/S, and examing the MSFT drivers' debug output 
+ * on MSFT's O/S, and examing the MSFT drivers' debug output
  * (insanely left _on_ in the enduser version)
  *
  * It was written out of frustration with the IPWireless USB modem
  * supplied by Axity3G/Sentech South Africa not supporting
  * Linux whatsoever.
  *
- * Nobody provided any proprietary information that was not already 
+ * Nobody provided any proprietary information that was not already
  * available for this device.
- * 
- * The modem adheres to the "3GPP TS  27.007 AT command set for 3G 
- * User Equipment (UE)" standard, available from 
+ *
+ * The modem adheres to the "3GPP TS  27.007 AT command set for 3G
+ * User Equipment (UE)" standard, available from
  * http://www.3gpp.org/ftp/Specs/html-info/27007.htm
  *
  * The code was only tested the IPWireless handheld modem distributed
  * in South Africa by Sentech.
- * 
+ *
  * It may work for Woosh Inc in .nz too, as it appears they use the
  * same kit.
  *
- * There is still some work to be done in terms of handling 
+ * There is still some work to be done in terms of handling
  * DCD, DTR, RTS, CTS which are currently faked.
  * It's good enough for PPP at this point. It's based off all kinds of
  * code found in usb/serial and usb/class
@@ -47,7 +47,7 @@
 #include <linux/spinlock.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 /*
  * Version Information
@@ -64,7 +64,7 @@
 
 /* Message sizes */
 #define EVENT_BUFFER_SIZE      0xFF
-#define CHAR2INT16(c1,c0)      (((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff))
+#define CHAR2INT16(c1, c0)     (((u32)((c1) & 0xff) << 8) + (u32)((c0) & 0xff))
 #define NUM_BULK_URBS          24
 #define NUM_CONTROL_URBS       16
 
@@ -94,33 +94,34 @@ enum {
 
 /* data bits */
 #define ipw_dtb_7              0x700
-#define ipw_dtb_8              0x810   // ok so the define is misleading, I know, but forces 8,n,1
-                                       // I mean, is there a point to any other setting these days? :) 
+#define ipw_dtb_8              0x810   /* ok so the define is misleading, I know, but forces 8,n,1 */
+                                       /* I mean, is there a point to any other setting these days? :) */
 
 /* usb control request types : */
-#define IPW_SIO_RXCTL          0x00    // control bulk rx channel transmissions, value=1/0 (on/off)
-#define IPW_SIO_SET_BAUD       0x01    // set baud, value=requested ipw_sio_bxxxx
-#define IPW_SIO_SET_LINE       0x03    // set databits, parity. value=ipw_dtb_x
-#define IPW_SIO_SET_PIN                0x03    // set/clear dtr/rts value=ipw_pin_xxx
-#define IPW_SIO_POLL           0x08    // get serial port status byte, call with value=0
-#define IPW_SIO_INIT           0x11    // initializes ? value=0 (appears as first thing todo on open)
-#define IPW_SIO_PURGE          0x12    // purge all transmissions?, call with value=numchar_to_purge
-#define IPW_SIO_HANDFLOW       0x13    // set xon/xoff limits value=0, and a buffer of 0x10 bytes
-#define IPW_SIO_SETCHARS       0x13    // set the flowcontrol special chars, value=0, buf=6 bytes, 
-                                       // last 2 bytes contain flowcontrol chars e.g. 00 00 00 00 11 13
+#define IPW_SIO_RXCTL          0x00    /* control bulk rx channel transmissions, value=1/0 (on/off) */
+#define IPW_SIO_SET_BAUD       0x01    /* set baud, value=requested ipw_sio_bxxxx */
+#define IPW_SIO_SET_LINE       0x03    /* set databits, parity. value=ipw_dtb_x */
+#define IPW_SIO_SET_PIN                0x03    /* set/clear dtr/rts value=ipw_pin_xxx */
+#define IPW_SIO_POLL           0x08    /* get serial port status byte, call with value=0 */
+#define IPW_SIO_INIT           0x11    /* initializes ? value=0 (appears as first thing todo on open) */
+#define IPW_SIO_PURGE          0x12    /* purge all transmissions?, call with value=numchar_to_purge */
+#define IPW_SIO_HANDFLOW       0x13    /* set xon/xoff limits value=0, and a buffer of 0x10 bytes */
+#define IPW_SIO_SETCHARS       0x13    /* set the flowcontrol special chars, value=0, buf=6 bytes, */
+                                       /* last 2 bytes contain flowcontrol chars e.g. 00 00 00 00 11 13 */
 
 /* values used for request IPW_SIO_SET_PIN */
 #define IPW_PIN_SETDTR         0x101
 #define IPW_PIN_SETRTS         0x202
 #define IPW_PIN_CLRDTR         0x100
-#define IPW_PIN_CLRRTS         0x200 // unconfirmed
+#define IPW_PIN_CLRRTS         0x200 /* unconfirmed */
 
 /* values used for request IPW_SIO_RXCTL */
 #define IPW_RXBULK_ON          1
 #define IPW_RXBULK_OFF         0
 
 /* various 16 byte hardcoded transferbuffers used by flow control */
-#define IPW_BYTES_FLOWINIT     { 0x01, 0, 0, 0, 0x40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
+#define IPW_BYTES_FLOWINIT     { 0x01, 0, 0, 0, 0x40, 0, 0, 0, \
+                                       0, 0, 0, 0, 0, 0, 0, 0 }
 
 /* Interpretation of modem status lines */
 /* These need sorting out by individually connecting pins and checking
@@ -132,17 +133,6 @@ enum {
 #define IPW_CTS                        ((1<<5) | (1<<4))
 
 #define IPW_WANTS_TO_SEND      0x30
-//#define IPW_DTR                      /* Data Terminal Ready */
-//#define IPW_CTS                      /* Clear To Send */
-//#define IPW_CD                       /* Carrier Detect */
-//#define IPW_DSR                      /* Data Set Ready */
-//#define IPW_RxD                      /* Receive pin */
-
-//#define IPW_LE
-//#define IPW_RTS              
-//#define IPW_ST               
-//#define IPW_SR               
-//#define IPW_RI                       /* Ring Indicator */
 
 static struct usb_device_id usb_ipw_ids[] = {
        { USB_DEVICE(IPW_VID, IPW_PID) },
@@ -177,9 +167,10 @@ static void ipw_read_bulk_callback(struct urb *urb)
                return;
        }
 
-       usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                       urb->actual_length, data);
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (tty && urb->actual_length) {
                tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
@@ -187,19 +178,22 @@ static void ipw_read_bulk_callback(struct urb *urb)
        }
 
        /* Continue trying to always read  */
-       usb_fill_bulk_urb (port->read_urb, port->serial->dev,
-                          usb_rcvbulkpipe(port->serial->dev,
+       usb_fill_bulk_urb(port->read_urb, port->serial->dev,
+                         usb_rcvbulkpipe(port->serial->dev,
                                           port->bulk_in_endpointAddress),
-                          port->read_urb->transfer_buffer,
-                          port->read_urb->transfer_buffer_length,
-                          ipw_read_bulk_callback, port);
+                         port->read_urb->transfer_buffer,
+                         port->read_urb->transfer_buffer_length,
+                         ipw_read_bulk_callback, port);
        result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
        if (result)
-               dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
+               dev_err(&port->dev,
+                       "%s - failed resubmitting read urb, error %d\n",
+                                                       __func__, result);
        return;
 }
 
-static int ipw_open(struct usb_serial_port *port, struct file *filp)
+static int ipw_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_device *dev = port->serial->dev;
        u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT;
@@ -212,29 +206,33 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
        if (!buf_flow_init)
                return -ENOMEM;
 
-       if (port->tty)
-               port->tty->low_latency = 1;
-
-       /* --1: Tell the modem to initialize (we think) From sniffs this is always the
-        * first thing that gets sent to the modem during opening of the device */
-       dbg("%s: Sending SIO_INIT (we guess)",__func__);
-       result = usb_control_msg(dev, usb_sndctrlpipe(dev,0),
-                                IPW_SIO_INIT,
-                                USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
-                                0,
-                                0, /* index */
-                                NULL,
-                                0,
-                                100000);
+       if (tty)
+               tty->low_latency = 1;
+
+       /* --1: Tell the modem to initialize (we think) From sniffs this is
+        *      always the first thing that gets sent to the modem during
+        *      opening of the device */
+       dbg("%s: Sending SIO_INIT (we guess)", __func__);
+       result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
+                        IPW_SIO_INIT,
+                        USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+                        0,
+                        0, /* index */
+                        NULL,
+                        0,
+                        100000);
        if (result < 0)
-               dev_err(&port->dev, "Init of modem failed (error = %d)\n", result);
+               dev_err(&port->dev,
+                       "Init of modem failed (error = %d)\n", result);
 
        /* reset the bulk pipes */
-       usb_clear_halt(dev, usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress));
-       usb_clear_halt(dev, usb_sndbulkpipe(dev, port->bulk_out_endpointAddress));
+       usb_clear_halt(dev,
+                       usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress));
+       usb_clear_halt(dev,
+                       usb_sndbulkpipe(dev, port->bulk_out_endpointAddress));
 
-       /*--2: Start reading from the device */ 
-       dbg("%s: setting up bulk read callback",__func__);
+       /*--2: Start reading from the device */
+       dbg("%s: setting up bulk read callback", __func__);
        usb_fill_bulk_urb(port->read_urb, dev,
                          usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress),
                          port->bulk_in_buffer,
@@ -242,66 +240,72 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
                          ipw_read_bulk_callback, port);
        result = usb_submit_urb(port->read_urb, GFP_KERNEL);
        if (result < 0)
-               dbg("%s - usb_submit_urb(read bulk) failed with status %d", __func__, result);
+               dbg("%s - usb_submit_urb(read bulk) failed with status %d",
+                                                       __func__, result);
 
        /*--3: Tell the modem to open the floodgates on the rx bulk channel */
-       dbg("%s:asking modem for RxRead (RXBULK_ON)",__func__);
+       dbg("%s:asking modem for RxRead (RXBULK_ON)", __func__);
        result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-                                IPW_SIO_RXCTL,
-                                USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
-                                IPW_RXBULK_ON,
-                                0, /* index */
-                                NULL,
-                                0,
-                                100000);
-       if (result < 0) 
-               dev_err(&port->dev, "Enabling bulk RxRead failed (error = %d)\n", result);
+                        IPW_SIO_RXCTL,
+                        USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+                        IPW_RXBULK_ON,
+                        0, /* index */
+                        NULL,
+                        0,
+                        100000);
+       if (result < 0)
+               dev_err(&port->dev,
+                       "Enabling bulk RxRead failed (error = %d)\n", result);
 
        /*--4: setup the initial flowcontrol */
-       dbg("%s:setting init flowcontrol (%s)",__func__,buf_flow_init);
+       dbg("%s:setting init flowcontrol (%s)", __func__, buf_flow_init);
        result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-                                IPW_SIO_HANDFLOW,
-                                USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
-                                0,
-                                0,
-                                buf_flow_init,
-                                0x10,
-                                200000);
+                        IPW_SIO_HANDFLOW,
+                        USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+                        0,
+                        0,
+                        buf_flow_init,
+                        0x10,
+                        200000);
        if (result < 0)
-               dev_err(&port->dev, "initial flowcontrol failed (error = %d)\n", result);
+               dev_err(&port->dev,
+                       "initial flowcontrol failed (error = %d)\n", result);
 
 
        /*--5: raise the dtr */
-       dbg("%s:raising dtr",__func__);
+       dbg("%s:raising dtr", __func__);
        result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-                                IPW_SIO_SET_PIN,
-                                USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
-                                IPW_PIN_SETDTR,
-                                0,
-                                NULL,
-                                0,
-                                200000);
+                        IPW_SIO_SET_PIN,
+                        USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+                        IPW_PIN_SETDTR,
+                        0,
+                        NULL,
+                        0,
+                        200000);
        if (result < 0)
-               dev_err(&port->dev, "setting dtr failed (error = %d)\n", result);
+               dev_err(&port->dev,
+                               "setting dtr failed (error = %d)\n", result);
 
        /*--6: raise the rts */
-       dbg("%s:raising rts",__func__);
+       dbg("%s:raising rts", __func__);
        result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-                                IPW_SIO_SET_PIN,
-                                USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
-                                IPW_PIN_SETRTS,
-                                0,
-                                NULL,
-                                0,
-                                200000);
+                        IPW_SIO_SET_PIN,
+                        USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+                        IPW_PIN_SETRTS,
+                        0,
+                        NULL,
+                        0,
+                        200000);
        if (result < 0)
-               dev_err(&port->dev, "setting dtr failed (error = %d)\n", result);
-       
+               dev_err(&port->dev,
+                               "setting dtr failed (error = %d)\n", result);
+
        kfree(buf_flow_init);
        return 0;
 }
 
-static void ipw_close(struct usb_serial_port *port, struct file * filp)
+static void ipw_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_device *dev = port->serial->dev;
        int result;
@@ -312,56 +316,62 @@ static void ipw_close(struct usb_serial_port *port, struct file * filp)
        }
 
        /*--1: drop the dtr */
-       dbg("%s:dropping dtr",__func__);
+       dbg("%s:dropping dtr", __func__);
        result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-                                IPW_SIO_SET_PIN,
-                                USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
-                                IPW_PIN_CLRDTR,
-                                0,
-                                NULL,
-                                0,
-                                200000);
+                        IPW_SIO_SET_PIN,
+                        USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+                        IPW_PIN_CLRDTR,
+                        0,
+                        NULL,
+                        0,
+                        200000);
        if (result < 0)
-               dev_err(&port->dev, "dropping dtr failed (error = %d)\n", result);
+               dev_err(&port->dev, "dropping dtr failed (error = %d)\n",
+                                                               result);
 
        /*--2: drop the rts */
-       dbg("%s:dropping rts",__func__);
+       dbg("%s:dropping rts", __func__);
        result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-                                IPW_SIO_SET_PIN, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
-                                IPW_PIN_CLRRTS,
-                                0,
-                                NULL,
-                                0,
-                                200000);
+                        IPW_SIO_SET_PIN, USB_TYPE_VENDOR |
+                                       USB_RECIP_INTERFACE | USB_DIR_OUT,
+                        IPW_PIN_CLRRTS,
+                        0,
+                        NULL,
+                        0,
+                        200000);
        if (result < 0)
-               dev_err(&port->dev, "dropping rts failed (error = %d)\n", result);
+               dev_err(&port->dev,
+                               "dropping rts failed (error = %d)\n", result);
 
 
        /*--3: purge */
-       dbg("%s:sending purge",__func__);
+       dbg("%s:sending purge", __func__);
        result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-                                IPW_SIO_PURGE, USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
-                                0x03,
-                                0,
-                                NULL,
-                                0,
-                                200000);
+                        IPW_SIO_PURGE, USB_TYPE_VENDOR |
+                                       USB_RECIP_INTERFACE | USB_DIR_OUT,
+                        0x03,
+                        0,
+                        NULL,
+                        0,
+                        200000);
        if (result < 0)
                dev_err(&port->dev, "purge failed (error = %d)\n", result);
 
 
-       /* send RXBULK_off (tell modem to stop transmitting bulk data on rx chan) */
+       /* send RXBULK_off (tell modem to stop transmitting bulk data on
+          rx chan) */
        result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
-                                IPW_SIO_RXCTL,
-                                USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
-                                IPW_RXBULK_OFF,
-                                0, /* index */
-                                NULL,
-                                0,
-                                100000);
+                        IPW_SIO_RXCTL,
+                        USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+                        IPW_RXBULK_OFF,
+                        0, /* index */
+                        NULL,
+                        0,
+                        100000);
 
        if (result < 0)
-               dev_err(&port->dev, "Disabling bulk RxRead failed (error = %d)\n", result);
+               dev_err(&port->dev,
+                       "Disabling bulk RxRead failed (error = %d)\n", result);
 
        /* shutdown any in-flight urbs that we know about */
        usb_kill_urb(port->read_urb);
@@ -384,13 +394,14 @@ static void ipw_write_bulk_callback(struct urb *urb)
        usb_serial_port_softint(port);
 }
 
-static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int count)
+static int ipw_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count)
 {
        struct usb_device *dev = port->serial->dev;
        int ret;
 
        dbg("%s: TOP: count=%d, in_interrupt=%ld", __func__,
-               count, in_interrupt() );
+               count, in_interrupt());
 
        if (count == 0) {
                dbg("%s - write request of 0 bytes", __func__);
@@ -421,13 +432,14 @@ static int ipw_write(struct usb_serial_port *port, const unsigned char *buf, int
        ret = usb_submit_urb(port->write_urb, GFP_ATOMIC);
        if (ret != 0) {
                port->write_urb_busy = 0;
-               dbg("%s - usb_submit_urb(write bulk) failed with error = %d", __func__, ret);
+               dbg("%s - usb_submit_urb(write bulk) failed with error = %d",
+                                                               __func__, ret);
                return ret;
        }
 
        dbg("%s returning %d", __func__, count);
        return count;
-} 
+}
 
 static int ipw_probe(struct usb_serial_port *port)
 {
@@ -486,8 +498,8 @@ module_init(usb_ipw_init);
 module_exit(usb_ipw_exit);
 
 /* Module information */
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index 0063c11..e59155c 100644 (file)
@@ -85,15 +85,17 @@ static int buffer_size;
 /* if overridden by the user, then use the specified number of XBOFs */
 static int xbof = -1;
 
-static int ir_startup(struct usb_serial *serial);
-static int ir_open(struct usb_serial_port *port, struct file *filep);
-static void ir_close(struct usb_serial_port *port, struct file *filep);
-static int ir_write(struct usb_serial_port *port,
-               const unsigned char *buf, int count);
-static void ir_write_bulk_callback(struct urb *urb);
-static void ir_read_bulk_callback(struct urb *urb);
-static void ir_set_termios(struct usb_serial_port *port,
-               struct ktermios *old_termios);
+static int  ir_startup (struct usb_serial *serial);
+static int  ir_open(struct tty_struct *tty, struct usb_serial_port *port,
+                                       struct file *filep);
+static void ir_close(struct tty_struct *tty, struct usb_serial_port *port,
+                                       struct file *filep);
+static int  ir_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count);
+static void ir_write_bulk_callback (struct urb *urb);
+static void ir_read_bulk_callback (struct urb *urb);
+static void ir_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios);
 
 /* Not that this lot means you can only have one per system */
 static u8 ir_baud;
@@ -295,7 +297,8 @@ static int ir_startup(struct usb_serial *serial)
        return 0;
 }
 
-static int ir_open(struct usb_serial_port *port, struct file *filp)
+static int ir_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        char *buffer;
        int result = 0;
@@ -343,7 +346,8 @@ static int ir_open(struct usb_serial_port *port, struct file *filp)
        return result;
 }
 
-static void ir_close(struct usb_serial_port *port, struct file *filp)
+static void ir_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file * filp)
 {
        dbg("%s - port %d", __func__, port->number);
 
@@ -351,8 +355,8 @@ static void ir_close(struct usb_serial_port *port, struct file *filp)
        usb_kill_urb(port->read_urb);
 }
 
-static int ir_write(struct usb_serial_port *port,
-               const unsigned char *buf, int count)
+static int ir_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count)
 {
        unsigned char *transfer_buffer;
        int result;
@@ -360,11 +364,6 @@ static int ir_write(struct usb_serial_port *port,
 
        dbg("%s - port = %d, count = %d", __func__, port->number, count);
 
-       if (!port->tty) {
-               dev_err(&port->dev, "%s - no tty???\n", __func__);
-               return 0;
-       }
-
        if (count == 0)
                return 0;
 
@@ -450,14 +449,13 @@ static void ir_read_bulk_callback(struct urb *urb)
 
        dbg("%s - port %d", __func__, port->number);
 
-       if (!port->open_count) {
+       if (!port->port.count) {
                dbg("%s - port closed.", __func__);
                return;
        }
 
        switch (status) {
        case 0: /* Successful */
-
                /*
                 * The first byte of the packet we get from the device
                 * contains a busy indicator and baud rate change.
@@ -465,19 +463,11 @@ static void ir_read_bulk_callback(struct urb *urb)
                 */
                if ((*data & 0x0f) > 0)
                        ir_baud = *data & 0x0f;
-
-               usb_serial_debug_data(
-                       debug,
-                       &port->dev,
-                       __func__,
-                       urb->actual_length,
-                       data);
-
-               tty = port->tty;
-
+               usb_serial_debug_data(debug, &port->dev, __func__,
+                                               urb->actual_length, data);
+               tty = port->port.tty;
                if (tty_buffer_request_room(tty, urb->actual_length - 1)) {
-                       tty_insert_flip_string(tty, data + 1,
-                                       urb->actual_length - 1);
+                       tty_insert_flip_string(tty, data+1, urb->actual_length - 1);
                        tty_flip_buffer_push(tty);
                }
 
@@ -488,11 +478,10 @@ static void ir_read_bulk_callback(struct urb *urb)
                 */
 
        case -EPROTO: /* taking inspiration from pl2303.c */
-
-               /* Continue trying to always read */
+                       /* Continue trying to always read */
                usb_fill_bulk_urb(
                        port->read_urb,
-                       port->serial->dev,
+                       port->serial->dev, 
                        usb_rcvbulkpipe(port->serial->dev,
                                port->bulk_in_endpointAddress),
                        port->read_urb->transfer_buffer,
@@ -502,23 +491,19 @@ static void ir_read_bulk_callback(struct urb *urb)
 
                result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
                if (result)
-                       dev_err(&port->dev,
-                               "%s - failed resubmitting read urb, error %d\n",
+                       dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n",
                                __func__, result);
-               break;
-
+                       break ;
        default:
                dbg("%s - nonzero read bulk status received: %d",
-                       __func__,
-                       status);
-               break;
+                       __func__, status);
+               break ;
        }
-
        return;
 }
 
-static void ir_set_termios(struct usb_serial_port *port,
-               struct ktermios *old_termios)
+static void ir_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        unsigned char *transfer_buffer;
        int result;
@@ -527,7 +512,7 @@ static void ir_set_termios(struct usb_serial_port *port,
 
        dbg("%s - port %d", __func__, port->number);
 
-       baud = tty_get_baud_rate(port->tty);
+       baud = tty_get_baud_rate(tty);
 
        /*
         * FIXME, we should compare the baud request against the
@@ -600,8 +585,8 @@ static void ir_set_termios(struct usb_serial_port *port,
                                __func__, result);
 
        /* Only speed changes are supported */
-       tty_termios_copy_hw(port->tty->termios, old_termios);
-       tty_encode_baud_rate(port->tty, baud, baud);
+       tty_termios_copy_hw(tty->termios, old_termios);
+       tty_encode_baud_rate(tty, baud, baud);
 }
 
 static int __init ir_init(void)
index a01e987..ddff37f 100644 (file)
@@ -144,9 +144,10 @@ static void iuu_shutdown(struct usb_serial *serial)
        }
 }
 
-static int iuu_tiocmset(struct usb_serial_port *port, struct file *file,
+static int iuu_tiocmset(struct tty_struct *tty, struct file *file,
                        unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct iuu_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
 
@@ -171,8 +172,9 @@ static int iuu_tiocmset(struct usb_serial_port *port, struct file *file,
  * When no card , the reader respond with TIOCM_CD
  * This is known as CD autodetect mechanism
  */
-static int iuu_tiocmget(struct usb_serial_port *port, struct file *file)
+static int iuu_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct iuu_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
        int rc;
@@ -316,11 +318,10 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
                                         port->bulk_out_endpointAddress), buf,
                         count, &actual, HZ * 1);
 
-       if (status != IUU_OPERATION_OK) {
+       if (status != IUU_OPERATION_OK)
                dbg("%s - error = %2x", __func__, status);
-       } else {
+       else
                dbg("%s - write OK !", __func__);
-       }
        return status;
 }
 
@@ -340,12 +341,10 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
                                         port->bulk_in_endpointAddress), buf,
                         count, &actual, HZ * 1);
 
-       if (status != IUU_OPERATION_OK) {
+       if (status != IUU_OPERATION_OK)
                dbg("%s - error = %2x", __func__, status);
-       } else {
+       else
                dbg("%s - read OK !", __func__);
-       }
-
        return status;
 }
 
@@ -630,7 +629,7 @@ static void read_buf_callback(struct urb *urb)
        }
 
        dbg("%s - %i chars to write", __func__, urb->actual_length);
-       tty = port->tty;
+       tty = port->port.tty;
        if (data == NULL)
                dbg("%s - data is NULL !!!", __func__);
        if (tty && urb->actual_length && data) {
@@ -752,11 +751,10 @@ static void iuu_uart_read_callback(struct urb *urb)
        /* if nothing to write call again rxcmd */
        dbg("%s - rxcmd recall", __func__);
        iuu_led_activity_off(urb);
-       return;
 }
 
-static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf,
-                         int count)
+static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port,
+                         const u8 *buf, int count)
 {
        struct iuu_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
@@ -769,14 +767,14 @@ static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf,
        if (priv->writelen > 0) {
                /* buffer already filled but not commited */
                spin_unlock_irqrestore(&priv->lock, flags);
-               return (0);
+               return 0;
        }
        /* fill the buffer */
        memcpy(priv->writebuf, buf, count);
        priv->writelen = count;
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       return (count);
+       return count;
 }
 
 static void read_rxcmd_callback(struct urb *urb)
@@ -948,7 +946,8 @@ static int set_control_lines(struct usb_device *dev, u8 value)
        return 0;
 }
 
-static void iuu_close(struct usb_serial_port *port, struct file *filp)
+static void iuu_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        /* iuu_led (port,255,0,0,0); */
        struct usb_serial *serial;
@@ -964,8 +963,8 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp)
 
        iuu_uart_off(port);
        if (serial->dev) {
-               if (port->tty) {
-                       c_cflag = port->tty->termios->c_cflag;
+               if (tty) {
+                       c_cflag = tty->termios->c_cflag;
                        if (c_cflag & HUPCL) {
                                /* drop DTR and RTS */
                                priv = usb_get_serial_port_data(port);
@@ -989,7 +988,8 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp)
        }
 }
 
-static int iuu_open(struct usb_serial_port *port, struct file *filp)
+static int iuu_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial *serial = port->serial;
        u8 *buf;
@@ -1036,15 +1036,17 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
 
        /* set the termios structure */
        spin_lock_irqsave(&priv->lock, flags);
-       if (!priv->termios_initialized) {
-               *(port->tty->termios) = tty_std_termios;
-               port->tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600
-                                               | TIOCM_CTS | CSTOPB | PARENB;
-               port->tty->termios->c_lflag = 0;
-               port->tty->termios->c_oflag = 0;
-               port->tty->termios->c_iflag = 0;
+       if (tty && !priv->termios_initialized) {
+               *(tty->termios) = tty_std_termios;
+               tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600
+                                       | TIOCM_CTS | CSTOPB | PARENB;
+               tty->termios->c_ispeed = 9600;
+               tty->termios->c_ospeed = 9600;
+               tty->termios->c_lflag = 0;
+               tty->termios->c_oflag = 0;
+               tty->termios->c_iflag = 0;
                priv->termios_initialized = 1;
-               port->tty->low_latency = 1;
+               tty->low_latency = 1;
                priv->poll = 0;
         }
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -1148,7 +1150,7 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
        if (result) {
                dev_err(&port->dev, "%s - failed submitting read urb,"
                        " error %d\n", __func__, result);
-               iuu_close(port, NULL);
+               iuu_close(tty, port, NULL);
                return -EPROTO;
        } else {
                dbg("%s - rxcmd OK", __func__);
index 11e439b..704716f 100644 (file)
@@ -1,29 +1,29 @@
 /*
   Keyspan USB to Serial Converter driver
+
   (C) Copyright (C) 2000-2001  Hugh Blemings <hugh@blemings.org>
   (C) Copyright (C) 2002       Greg Kroah-Hartman <greg@kroah.com>
-   
+
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
 
   See http://misc.nu/hugh/keyspan.html for more information.
-  
+
   Code in this driver inspired by and in a number of places taken
   from Brian Warner's original Keyspan-PDA driver.
 
   This driver has been put together with the support of Innosys, Inc.
   and Keyspan, Inc the manufacturers of the Keyspan USB-serial products.
   Thanks Guys :)
-  
+
   Thanks to Paulus for miscellaneous tidy ups, some largish chunks
   of much nicer and/or completely new code and (perhaps most uniquely)
   having the patience to sit down and explain why and where he'd changed
-  stuff. 
-  
-  Tip 'o the hat to IBM (and previously Linuxcare :) for supporting 
+  stuff.
+
+  Tip 'o the hat to IBM (and previously Linuxcare :) for supporting
   staff in their work on open source projects.
 
   Change History
 
     Thu May 31 11:56:42 PDT 2001 gkh
       switched from using spinlock to a semaphore
-   
+
     (04/08/2001) gb
        Identify version on module load.
-   
+
     (11/01/2000) Adam J. Richter
        usb_device_id table support.
-   
+
     Tue Oct 10 23:15:33 EST 2000 Hugh
       Merged Paul's changes with my USA-49W mods.  Work in progress
       still...
-  
+
     Wed Jul 19 14:00:42 EST 2000 gkh
       Added module_init and module_exit functions to handle the fact that
       this driver is a loadable module now.
+
     Tue Jul 18 16:14:52 EST 2000 Hugh
       Basic character input/output for USA-19 now mostly works,
       fixed at 9600 baud for the moment.
 #include <linux/spinlock.h>
 #include <linux/firmware.h>
 #include <linux/ihex.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include "keyspan.h"
@@ -132,15 +132,15 @@ struct keyspan_serial_private {
        struct urb      *instat_urb;
        char            instat_buf[INSTAT_BUFLEN];
 
-       /* added to support 49wg, where data from all 4 ports comes in on 1 EP */
-       /* and high-speed supported */
+       /* added to support 49wg, where data from all 4 ports comes in
+          on 1 EP and high-speed supported */
        struct urb      *indat_urb;
        char            indat_buf[INDAT49W_BUFLEN];
 
        /* XXX this one probably will need a lock */
        struct urb      *glocont_urb;
        char            glocont_buf[GLOCONT_BUFLEN];
-       char            ctrl_buf[8];                    // for EP0 control message
+       char            ctrl_buf[8];    /* for EP0 control message */
 };
 
 struct keyspan_port_private {
@@ -186,19 +186,19 @@ struct keyspan_port_private {
        int             resend_cont;    /* need to resend control packet */
 };
 
-       
 /* Include Keyspan message headers.  All current Keyspan Adapters
    make use of one of five message formats which are referred
-   to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and within this driver. */
+   to as USA-26, USA-28, USA-49, USA-90, USA-67 by Keyspan and
+   within this driver. */
 #include "keyspan_usa26msg.h"
 #include "keyspan_usa28msg.h"
 #include "keyspan_usa49msg.h"
 #include "keyspan_usa90msg.h"
 #include "keyspan_usa67msg.h"
-       
+
 
 /* Functions used by new usb-serial code. */
-static int __init keyspan_init (void)
+static int __init keyspan_init(void)
 {
        int retval;
        retval = usb_serial_register(&keyspan_pre_device);
@@ -214,7 +214,7 @@ static int __init keyspan_init (void)
        if (retval)
                goto failed_4port_device_register;
        retval = usb_register(&keyspan_driver);
-       if (retval) 
+       if (retval)
                goto failed_usb_register;
 
        info(DRIVER_VERSION ":" DRIVER_DESC);
@@ -232,35 +232,24 @@ failed_pre_device_register:
        return retval;
 }
 
-static void __exit keyspan_exit (void)
+static void __exit keyspan_exit(void)
 {
-       usb_deregister (&keyspan_driver);
-       usb_serial_deregister (&keyspan_pre_device);
-       usb_serial_deregister (&keyspan_1port_device);
-       usb_serial_deregister (&keyspan_2port_device);
-       usb_serial_deregister (&keyspan_4port_device);
+       usb_deregister(&keyspan_driver);
+       usb_serial_deregister(&keyspan_pre_device);
+       usb_serial_deregister(&keyspan_1port_device);
+       usb_serial_deregister(&keyspan_2port_device);
+       usb_serial_deregister(&keyspan_4port_device);
 }
 
 module_init(keyspan_init);
 module_exit(keyspan_exit);
 
-static void keyspan_rx_throttle (struct usb_serial_port *port)
-{
-       dbg("%s - port %d", __func__, port->number);
-}
-
-
-static void keyspan_rx_unthrottle (struct usb_serial_port *port)
-{
-       dbg("%s - port %d", __func__, port->number);
-}
-
-
-static void keyspan_break_ctl (struct usb_serial_port *port, int break_state)
+static void keyspan_break_ctl(struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct keyspan_port_private     *p_priv;
 
-       dbg("%s", __func__);
+       dbg("%s", __func__);
 
        p_priv = usb_get_serial_port_data(port);
 
@@ -273,14 +262,13 @@ static void keyspan_break_ctl (struct usb_serial_port *port, int break_state)
 }
 
 
-static void keyspan_set_termios (struct usb_serial_port *port, 
-                                    struct ktermios *old_termios)
+static void keyspan_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        int                             baud_rate, device_port;
        struct keyspan_port_private     *p_priv;
        const struct keyspan_device_details     *d_details;
        unsigned int                    cflag;
-       struct tty_struct               *tty = port->tty;
 
        dbg("%s", __func__);
 
@@ -292,7 +280,7 @@ static void keyspan_set_termios (struct usb_serial_port *port,
        /* Baud rate calculation takes baud rate as an integer
           so other rates can be generated if desired. */
        baud_rate = tty_get_baud_rate(tty);
-       /* If no match or invalid, don't change */              
+       /* If no match or invalid, don't change */
        if (d_details->calculate_baud_rate(baud_rate, d_details->baudclk,
                                NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
                /* FIXME - more to do here to ensure rate changes cleanly */
@@ -312,35 +300,32 @@ static void keyspan_set_termios (struct usb_serial_port *port,
        keyspan_send_setup(port, 0);
 }
 
-static int keyspan_tiocmget(struct usb_serial_port *port, struct file *file)
+static int keyspan_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
+       struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
        unsigned int                    value;
-       struct keyspan_port_private     *p_priv;
 
-       p_priv = usb_get_serial_port_data(port);
-       
        value = ((p_priv->rts_state) ? TIOCM_RTS : 0) |
                ((p_priv->dtr_state) ? TIOCM_DTR : 0) |
                ((p_priv->cts_state) ? TIOCM_CTS : 0) |
                ((p_priv->dsr_state) ? TIOCM_DSR : 0) |
                ((p_priv->dcd_state) ? TIOCM_CAR : 0) |
-               ((p_priv->ri_state) ? TIOCM_RNG : 0); 
+               ((p_priv->ri_state) ? TIOCM_RNG : 0);
 
        return value;
 }
 
-static int keyspan_tiocmset(struct usb_serial_port *port, struct file *file,
+static int keyspan_tiocmset(struct tty_struct *tty, struct file *file,
                            unsigned int set, unsigned int clear)
 {
-       struct keyspan_port_private     *p_priv;
+       struct usb_serial_port *port = tty->driver_data;
+       struct keyspan_port_private *p_priv = usb_get_serial_port_data(port);
 
-       p_priv = usb_get_serial_port_data(port);
-       
        if (set & TIOCM_RTS)
                p_priv->rts_state = 1;
        if (set & TIOCM_DTR)
                p_priv->dtr_state = 1;
-
        if (clear & TIOCM_RTS)
                p_priv->rts_state = 0;
        if (clear & TIOCM_DTR)
@@ -349,35 +334,29 @@ static int keyspan_tiocmset(struct usb_serial_port *port, struct file *file,
        return 0;
 }
 
-static int keyspan_ioctl(struct usb_serial_port *port, struct file *file,
-                            unsigned int cmd, unsigned long arg)
-{
-       return -ENOIOCTLCMD;
-}
-
-       /* Write function is similar for the four protocols used
-          with only a minor change for usa90 (usa19hs) required */
-static int keyspan_write(struct usb_serial_port *port, 
-                        const unsigned char *buf, int count)
+/* Write function is similar for the four protocols used
+   with only a minor change for usa90 (usa19hs) required */
+static int keyspan_write(struct tty_struct *tty,
+       struct usb_serial_port *port, const unsigned char *buf, int count)
 {
        struct keyspan_port_private     *p_priv;
        const struct keyspan_device_details     *d_details;
        int                             flip;
        int                             left, todo;
        struct urb                      *this_urb;
-       int                             err, maxDataLen, dataOffset;
+       int                             err, maxDataLen, dataOffset;
 
        p_priv = usb_get_serial_port_data(port);
        d_details = p_priv->device_details;
 
        if (d_details->msg_format == msg_usa90) {
-               maxDataLen = 64;
+               maxDataLen = 64;
                dataOffset = 0;
        } else {
                maxDataLen = 63;
                dataOffset = 1;
        }
-       
+
        dbg("%s - for port %d (%d chars), flip=%d",
            __func__, port->number, count, p_priv->out_flip);
 
@@ -387,37 +366,40 @@ static int keyspan_write(struct usb_serial_port *port,
                        todo = maxDataLen;
 
                flip = p_priv->out_flip;
-       
+
                /* Check we have a valid urb/endpoint before we use it... */
-               if ((this_urb = p_priv->out_urbs[flip]) == NULL) {
+               this_urb = p_priv->out_urbs[flip];
+               if (this_urb == NULL) {
                        /* no bulk out, so return 0 bytes written */
                        dbg("%s - no output urb :(", __func__);
                        return count;
                }
 
-               dbg("%s - endpoint %d flip %d", __func__, usb_pipeendpoint(this_urb->pipe), flip);
+               dbg("%s - endpoint %d flip %d",
+                       __func__, usb_pipeendpoint(this_urb->pipe), flip);
 
                if (this_urb->status == -EINPROGRESS) {
-                       if (time_before(jiffies, p_priv->tx_start_time[flip] + 10 * HZ))
+                       if (time_before(jiffies,
+                                       p_priv->tx_start_time[flip] + 10 * HZ))
                                break;
                        usb_unlink_urb(this_urb);
                        break;
                }
 
-               /* First byte in buffer is "last flag" (except for usa19hx) - unused so
-                  for now so set to zero */
+               /* First byte in buffer is "last flag" (except for usa19hx)
+                  - unused so for now so set to zero */
                ((char *)this_urb->transfer_buffer)[0] = 0;
 
-               memcpy (this_urb->transfer_buffer + dataOffset, buf, todo);
+               memcpy(this_urb->transfer_buffer + dataOffset, buf, todo);
                buf += todo;
 
                /* send the data out the bulk port */
                this_urb->transfer_buffer_length = todo + dataOffset;
 
                this_urb->dev = port->serial->dev;
-               if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
+               err = usb_submit_urb(this_urb, GFP_ATOMIC);
+               if (err != 0)
                        dbg("usb_submit_urb(write bulk) failed (%d)", err);
-               }
                p_priv->tx_start_time[flip] = jiffies;
 
                /* Flip for next time if usa26 or usa28 interface
@@ -437,7 +419,7 @@ static void usa26_indat_callback(struct urb *urb)
        unsigned char           *data = urb->transfer_buffer;
        int status = urb->status;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        endpoint = usb_pipeendpoint(urb->pipe);
 
@@ -448,17 +430,18 @@ static void       usa26_indat_callback(struct urb *urb)
        }
 
        port =  urb->context;
-       tty = port->tty;
+       tty = port->port.tty;
        if (tty && urb->actual_length) {
                /* 0x80 bit is error flag */
                if ((data[0] & 0x80) == 0) {
-                       /* no errors on individual bytes, only possible overrun err*/
+                       /* no errors on individual bytes, only
+                          possible overrun err */
                        if (data[0] & RXERROR_OVERRUN)
-                                       err = TTY_OVERRUN;
-                       else err = 0;
-                       for (i = 1; i < urb->actual_length ; ++i) {
+                               err = TTY_OVERRUN;
+                       else
+                               err = 0;
+                       for (i = 1; i < urb->actual_length ; ++i)
                                tty_insert_flip_char(tty, data[i], err);
-                       }
                } else {
                        /* some bytes had errors, every byte has status */
                        dbg("%s - RX error!!!!", __func__);
@@ -476,17 +459,19 @@ static void       usa26_indat_callback(struct urb *urb)
                }
                tty_flip_buffer_push(tty);
        }
-                               
-               /* Resubmit urb so we continue receiving */
+
+       /* Resubmit urb so we continue receiving */
        urb->dev = port->serial->dev;
-       if (port->open_count)
-               if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
-                       dbg("%s - resubmit read urb failed. (%d)", __func__, err);
-               }
+       if (port->port.count) {
+               err = usb_submit_urb(urb, GFP_ATOMIC);
+               if (err != 0)
+                       dbg("%s - resubmit read urb failed. (%d)",
+                                       __func__, err);
+       }
        return;
 }
 
-       /* Outdat handling is common for all devices */
+/* Outdat handling is common for all devices */
 static void    usa2x_outdat_callback(struct urb *urb)
 {
        struct usb_serial_port *port;
@@ -494,16 +479,16 @@ static void       usa2x_outdat_callback(struct urb *urb)
 
        port =  urb->context;
        p_priv = usb_get_serial_port_data(port);
-       dbg ("%s - urb %d", __func__, urb == p_priv->out_urbs[1]);
+       dbg("%s - urb %d", __func__, urb == p_priv->out_urbs[1]);
 
-       if (port->open_count)
+       if (port->port.count)
                usb_serial_port_softint(port);
 }
 
 static void    usa26_inack_callback(struct urb *urb)
 {
-       dbg ("%s", __func__);
-       
+       dbg("%s", __func__);
+
 }
 
 static void    usa26_outcont_callback(struct urb *urb)
@@ -515,8 +500,9 @@ static void usa26_outcont_callback(struct urb *urb)
        p_priv = usb_get_serial_port_data(port);
 
        if (p_priv->resend_cont) {
-               dbg ("%s - sending setup", __func__);
-               keyspan_usa26_send_setup(port->serial, port, p_priv->resend_cont - 1);
+               dbg("%s - sending setup", __func__);
+               keyspan_usa26_send_setup(port->serial, port,
+                                               p_priv->resend_cont - 1);
        }
 }
 
@@ -552,14 +538,14 @@ static void       usa26_instat_callback(struct urb *urb)
        /* Now do something useful with the data */
 
 
-       /* Check port number from message and retrieve private data */  
+       /* Check port number from message and retrieve private data */
        if (msg->port >= serial->num_ports) {
-               dbg ("%s - Unexpected port number %d", __func__, msg->port);
+               dbg("%s - Unexpected port number %d", __func__, msg->port);
                goto exit;
        }
        port = serial->port[msg->port];
        p_priv = usb_get_serial_port_data(port);
-       
+
        /* Update handshaking pin state information */
        old_dcd_state = p_priv->dcd_state;
        p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
@@ -567,39 +553,38 @@ static void       usa26_instat_callback(struct urb *urb)
        p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
        p_priv->ri_state = ((msg->ri) ? 1 : 0);
 
-       if (port->tty && !C_CLOCAL(port->tty)
+       if (port->port.tty && !C_CLOCAL(port->port.tty)
            && old_dcd_state != p_priv->dcd_state) {
                if (old_dcd_state)
-                       tty_hangup(port->tty);
+                       tty_hangup(port->port.tty);
                /*  else */
                /*      wake_up_interruptible(&p_priv->open_wait); */
        }
-       
+
        /* Resubmit urb so we continue receiving */
        urb->dev = serial->dev;
-       if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
+       err = usb_submit_urb(urb, GFP_ATOMIC);
+       if (err != 0)
                dbg("%s - resubmit read urb failed. (%d)", __func__, err);
-       }
 exit: ;
 }
 
 static void    usa26_glocont_callback(struct urb *urb)
 {
-       dbg ("%s", __func__);
-       
+       dbg("%s", __func__);
 }
 
 
 static void usa28_indat_callback(struct urb *urb)
 {
-       int                     i, err;
+       int                     err;
        struct usb_serial_port  *port;
        struct tty_struct       *tty;
        unsigned char           *data;
        struct keyspan_port_private             *p_priv;
        int status = urb->status;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        port =  urb->context;
        p_priv = usb_get_serial_port_data(port);
@@ -619,20 +604,20 @@ static void usa28_indat_callback(struct urb *urb)
                p_priv = usb_get_serial_port_data(port);
                data = urb->transfer_buffer;
 
-               tty = port->tty;
+               tty = port->port.tty;
                if (urb->actual_length) {
-                       for (i = 0; i < urb->actual_length ; ++i) {
-                               tty_insert_flip_char(tty, data[i], 0);
-                       }
+                       tty_insert_flip_string(tty, data, urb->actual_length);
                        tty_flip_buffer_push(tty);
                }
 
                /* Resubmit urb so we continue receiving */
                urb->dev = port->serial->dev;
-               if (port->open_count)
-                       if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
-                               dbg("%s - resubmit read urb failed. (%d)", __func__, err);
-                       }
+               if (port->port.count) {
+                       err = usb_submit_urb(urb, GFP_ATOMIC);
+                       if (err != 0)
+                               dbg("%s - resubmit read urb failed. (%d)",
+                                                               __func__, err);
+               }
                p_priv->in_flip ^= 1;
 
                urb = p_priv->in_urbs[p_priv->in_flip];
@@ -641,7 +626,7 @@ static void usa28_indat_callback(struct urb *urb)
 
 static void    usa28_inack_callback(struct urb *urb)
 {
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 }
 
 static void    usa28_outcont_callback(struct urb *urb)
@@ -653,8 +638,9 @@ static void usa28_outcont_callback(struct urb *urb)
        p_priv = usb_get_serial_port_data(port);
 
        if (p_priv->resend_cont) {
-               dbg ("%s - sending setup", __func__);
-               keyspan_usa28_send_setup(port->serial, port, p_priv->resend_cont - 1);
+               dbg("%s - sending setup", __func__);
+               keyspan_usa28_send_setup(port->serial, port,
+                                               p_priv->resend_cont - 1);
        }
 }
 
@@ -684,19 +670,18 @@ static void       usa28_instat_callback(struct urb *urb)
        /*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__
            data[0], data[1], data[2], data[3], data[4], data[5],
            data[6], data[7], data[8], data[9], data[10], data[11]);*/
-       
-               /* Now do something useful with the data */
-       msg = (struct keyspan_usa28_portStatusMessage *)data;
 
+       /* Now do something useful with the data */
+       msg = (struct keyspan_usa28_portStatusMessage *)data;
 
-               /* Check port number from message and retrieve private data */  
+       /* Check port number from message and retrieve private data */
        if (msg->port >= serial->num_ports) {
-               dbg ("%s - Unexpected port number %d", __func__, msg->port);
+               dbg("%s - Unexpected port number %d", __func__, msg->port);
                goto exit;
        }
        port = serial->port[msg->port];
        p_priv = usb_get_serial_port_data(port);
-       
+
        /* Update handshaking pin state information */
        old_dcd_state = p_priv->dcd_state;
        p_priv->cts_state = ((msg->cts) ? 1 : 0);
@@ -704,25 +689,25 @@ static void       usa28_instat_callback(struct urb *urb)
        p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
        p_priv->ri_state = ((msg->ri) ? 1 : 0);
 
-       if (port->tty && !C_CLOCAL(port->tty)
+       if (port->port.tty && !C_CLOCAL(port->port.tty)
            && old_dcd_state != p_priv->dcd_state) {
                if (old_dcd_state)
-                       tty_hangup(port->tty);
+                       tty_hangup(port->port.tty);
                /*  else */
                /*      wake_up_interruptible(&p_priv->open_wait); */
        }
 
                /* Resubmit urb so we continue receiving */
        urb->dev = serial->dev;
-       if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
+       err = usb_submit_urb(urb, GFP_ATOMIC);
+       if (err != 0)
                dbg("%s - resubmit read urb failed. (%d)", __func__, err);
-       }
 exit: ;
 }
 
 static void    usa28_glocont_callback(struct urb *urb)
 {
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 }
 
 
@@ -733,7 +718,7 @@ static void usa49_glocont_callback(struct urb *urb)
        struct keyspan_port_private *p_priv;
        int i;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        serial =  urb->context;
        for (i = 0; i < serial->num_ports; ++i) {
@@ -741,8 +726,9 @@ static void usa49_glocont_callback(struct urb *urb)
                p_priv = usb_get_serial_port_data(port);
 
                if (p_priv->resend_cont) {
-                       dbg ("%s - sending setup", __func__);
-                       keyspan_usa49_send_setup(serial, port, p_priv->resend_cont - 1);
+                       dbg("%s - sending setup", __func__);
+                       keyspan_usa49_send_setup(serial, port,
+                                               p_priv->resend_cont - 1);
                        break;
                }
        }
@@ -761,7 +747,7 @@ static void usa49_instat_callback(struct urb *urb)
        int old_dcd_state;
        int status = urb->status;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        serial =  urb->context;
 
@@ -770,7 +756,8 @@ static void usa49_instat_callback(struct urb *urb)
                return;
        }
 
-       if (urb->actual_length != sizeof(struct keyspan_usa49_portStatusMessage)) {
+       if (urb->actual_length !=
+                       sizeof(struct keyspan_usa49_portStatusMessage)) {
                dbg("%s - bad length %d", __func__, urb->actual_length);
                goto exit;
        }
@@ -778,18 +765,19 @@ static void       usa49_instat_callback(struct urb *urb)
        /*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __func__,
            data[0], data[1], data[2], data[3], data[4], data[5],
            data[6], data[7], data[8], data[9], data[10]);*/
-       
-               /* Now do something useful with the data */
+
+       /* Now do something useful with the data */
        msg = (struct keyspan_usa49_portStatusMessage *)data;
 
-               /* Check port number from message and retrieve private data */  
+       /* Check port number from message and retrieve private data */
        if (msg->portNumber >= serial->num_ports) {
-               dbg ("%s - Unexpected port number %d", __func__, msg->portNumber);
+               dbg("%s - Unexpected port number %d",
+                                       __func__, msg->portNumber);
                goto exit;
        }
        port = serial->port[msg->portNumber];
        p_priv = usb_get_serial_port_data(port);
-       
+
        /* Update handshaking pin state information */
        old_dcd_state = p_priv->dcd_state;
        p_priv->cts_state = ((msg->cts) ? 1 : 0);
@@ -797,26 +785,26 @@ static void       usa49_instat_callback(struct urb *urb)
        p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
        p_priv->ri_state = ((msg->ri) ? 1 : 0);
 
-       if (port->tty && !C_CLOCAL(port->tty)
+       if (port->port.tty && !C_CLOCAL(port->port.tty)
            && old_dcd_state != p_priv->dcd_state) {
                if (old_dcd_state)
-                       tty_hangup(port->tty);
+                       tty_hangup(port->port.tty);
                /*  else */
                /*      wake_up_interruptible(&p_priv->open_wait); */
        }
 
-               /* Resubmit urb so we continue receiving */
+       /* Resubmit urb so we continue receiving */
        urb->dev = serial->dev;
 
-       if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
+       err = usb_submit_urb(urb, GFP_ATOMIC);
+       if (err != 0)
                dbg("%s - resubmit read urb failed. (%d)", __func__, err);
-       }
 exit:  ;
 }
 
 static void    usa49_inack_callback(struct urb *urb)
 {
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 }
 
 static void    usa49_indat_callback(struct urb *urb)
@@ -828,7 +816,7 @@ static void usa49_indat_callback(struct urb *urb)
        unsigned char           *data = urb->transfer_buffer;
        int status = urb->status;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        endpoint = usb_pipeendpoint(urb->pipe);
 
@@ -839,14 +827,13 @@ static void       usa49_indat_callback(struct urb *urb)
        }
 
        port =  urb->context;
-       tty = port->tty;
+       tty = port->port.tty;
        if (tty && urb->actual_length) {
                /* 0x80 bit is error flag */
                if ((data[0] & 0x80) == 0) {
                        /* no error on any byte */
-                       for (i = 1; i < urb->actual_length ; ++i) {
-                               tty_insert_flip_char(tty, data[i], 0);
-                       }
+                       tty_insert_flip_string(tty, data + 1,
+                                               urb->actual_length - 1);
                } else {
                        /* some bytes had errors, every byte has status */
                        for (i = 0; i + 1 < urb->actual_length; i += 2) {
@@ -863,13 +850,15 @@ static void       usa49_indat_callback(struct urb *urb)
                }
                tty_flip_buffer_push(tty);
        }
-                               
-               /* Resubmit urb so we continue receiving */
+
+       /* Resubmit urb so we continue receiving */
        urb->dev = port->serial->dev;
-       if (port->open_count)
-               if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
-                       dbg("%s - resubmit read urb failed. (%d)", __func__, err);
-               }
+       if (port->port.count) {
+               err = usb_submit_urb(urb, GFP_ATOMIC);
+               if (err != 0)
+                       dbg("%s - resubmit read urb failed. (%d)",
+                                                       __func__, err);
+       }
 }
 
 static void usa49wg_indat_callback(struct urb *urb)
@@ -881,7 +870,7 @@ static void usa49wg_indat_callback(struct urb *urb)
        unsigned char           *data = urb->transfer_buffer;
        int status = urb->status;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        serial = urb->context;
 
@@ -899,12 +888,12 @@ static void usa49wg_indat_callback(struct urb *urb)
 
                        /* Check port number from message*/
                        if (data[i] >= serial->num_ports) {
-                               dbg ("%s - Unexpected port number %d",
+                               dbg("%s - Unexpected port number %d",
                                        __func__, data[i]);
                                return;
                        }
                        port = serial->port[data[i++]];
-                       tty = port->tty;
+                       tty = port->port.tty;
                        len = data[i++];
 
                        /* 0x80 bit is error flag */
@@ -912,7 +901,7 @@ static void usa49wg_indat_callback(struct urb *urb)
                                /* no error on any byte */
                                i++;
                                for (x = 1; x < len ; ++x)
-                                       if (port->open_count)
+                                       if (port->port.count)
                                                tty_insert_flip_char(tty,
                                                                data[i++], 0);
                                        else
@@ -930,13 +919,13 @@ static void usa49wg_indat_callback(struct urb *urb)
                                        if (stat & RXERROR_PARITY)
                                                flag |= TTY_PARITY;
                                        /* XXX should handle break (0x10) */
-                                       if (port->open_count)
+                                       if (port->port.count)
                                                tty_insert_flip_char(tty,
                                                        data[i+1], flag);
                                        i += 2;
                                }
                        }
-                       if (port->open_count)
+                       if (port->port.count)
                                tty_flip_buffer_push(tty);
                }
        }
@@ -952,7 +941,7 @@ static void usa49wg_indat_callback(struct urb *urb)
 /* not used, usa-49 doesn't have per-port control endpoints */
 static void usa49_outcont_callback(struct urb *urb)
 {
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 }
 
 static void usa90_indat_callback(struct urb *urb)
@@ -965,7 +954,7 @@ static void usa90_indat_callback(struct urb *urb)
        unsigned char           *data = urb->transfer_buffer;
        int status = urb->status;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        endpoint = usb_pipeendpoint(urb->pipe);
 
@@ -978,29 +967,26 @@ static void usa90_indat_callback(struct urb *urb)
        port =  urb->context;
        p_priv = usb_get_serial_port_data(port);
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (urb->actual_length) {
-       
                /* if current mode is DMA, looks like usa28 format
-                       otherwise looks like usa26 data format */
+                  otherwise looks like usa26 data format */
 
-               if (p_priv->baud > 57600) {
-                       for (i = 0; i < urb->actual_length ; ++i) 
-                               tty_insert_flip_char(tty, data[i], 0);
-               }
+               if (p_priv->baud > 57600)
+                       tty_insert_flip_string(tty, data, urb->actual_length);
                else {
-                       
                        /* 0x80 bit is error flag */
                        if ((data[0] & 0x80) == 0) {
-                               /* no errors on individual bytes, only possible overrun err*/
+                               /* no errors on individual bytes, only
+                                  possible overrun err*/
                                if (data[0] & RXERROR_OVERRUN)
-                                               err = TTY_OVERRUN;
-                               else err = 0;
-                               for (i = 1; i < urb->actual_length ; ++i) 
-                                       tty_insert_flip_char(tty, data[i], err);
-                       
-                       } 
-                       else {
+                                       err = TTY_OVERRUN;
+                               else
+                                       err = 0;
+                               for (i = 1; i < urb->actual_length ; ++i)
+                                       tty_insert_flip_char(tty, data[i],
+                                                                       err);
+                       }  else {
                        /* some bytes had errors, every byte has status */
                                dbg("%s - RX error!!!!", __func__);
                                for (i = 0; i + 1 < urb->actual_length; i += 2) {
@@ -1012,19 +998,22 @@ static void usa90_indat_callback(struct urb *urb)
                                        if (stat & RXERROR_PARITY)
                                                flag |= TTY_PARITY;
                                        /* XXX should handle break (0x10) */
-                                       tty_insert_flip_char(tty, data[i+1], flag);
+                                       tty_insert_flip_char(tty, data[i+1],
+                                                                       flag);
                                }
                        }
                }
                tty_flip_buffer_push(tty);
        }
-                               
+
        /* Resubmit urb so we continue receiving */
        urb->dev = port->serial->dev;
-       if (port->open_count)
-               if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
-                       dbg("%s - resubmit read urb failed. (%d)", __func__, err);
-               }
+       if (port->port.count) {
+               err = usb_submit_urb(urb, GFP_ATOMIC);
+               if (err != 0)
+                       dbg("%s - resubmit read urb failed. (%d)",
+                                                       __func__, err);
+       }
        return;
 }
 
@@ -1056,7 +1045,7 @@ static void       usa90_instat_callback(struct urb *urb)
 
        port = serial->port[0];
        p_priv = usb_get_serial_port_data(port);
-       
+
        /* Update handshaking pin state information */
        old_dcd_state = p_priv->dcd_state;
        p_priv->cts_state = ((msg->cts) ? 1 : 0);
@@ -1064,19 +1053,19 @@ static void     usa90_instat_callback(struct urb *urb)
        p_priv->dcd_state = ((msg->dcd) ? 1 : 0);
        p_priv->ri_state = ((msg->ri) ? 1 : 0);
 
-       if (port->tty && !C_CLOCAL(port->tty)
+       if (port->port.tty && !C_CLOCAL(port->port.tty)
            && old_dcd_state != p_priv->dcd_state) {
                if (old_dcd_state)
-                       tty_hangup(port->tty);
+                       tty_hangup(port->port.tty);
                /*  else */
                /*      wake_up_interruptible(&p_priv->open_wait); */
        }
-       
+
        /* Resubmit urb so we continue receiving */
        urb->dev = serial->dev;
-       if ((err = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
+       err = usb_submit_urb(urb, GFP_ATOMIC);
+       if (err != 0)
                dbg("%s - resubmit read urb failed. (%d)", __func__, err);
-       }
 exit:
        ;
 }
@@ -1090,8 +1079,9 @@ static void       usa90_outcont_callback(struct urb *urb)
        p_priv = usb_get_serial_port_data(port);
 
        if (p_priv->resend_cont) {
-               dbg ("%s - sending setup", __func__);
-               keyspan_usa90_send_setup(port->serial, port, p_priv->resend_cont - 1);
+               dbg("%s - sending setup", __func__);
+               keyspan_usa90_send_setup(port->serial, port,
+                                               p_priv->resend_cont - 1);
        }
 }
 
@@ -1107,7 +1097,7 @@ static void       usa67_instat_callback(struct urb *urb)
        int old_dcd_state;
        int status = urb->status;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        serial = urb->context;
 
@@ -1116,7 +1106,8 @@ static void       usa67_instat_callback(struct urb *urb)
                return;
        }
 
-       if (urb->actual_length != sizeof(struct keyspan_usa67_portStatusMessage)) {
+       if (urb->actual_length !=
+                       sizeof(struct keyspan_usa67_portStatusMessage)) {
                dbg("%s - bad length %d", __func__, urb->actual_length);
                return;
        }
@@ -1127,7 +1118,7 @@ static void       usa67_instat_callback(struct urb *urb)
 
        /* Check port number from message and retrieve private data */
        if (msg->port >= serial->num_ports) {
-               dbg ("%s - Unexpected port number %d", __func__, msg->port);
+               dbg("%s - Unexpected port number %d", __func__, msg->port);
                return;
        }
 
@@ -1139,10 +1130,10 @@ static void     usa67_instat_callback(struct urb *urb)
        p_priv->cts_state = ((msg->hskia_cts) ? 1 : 0);
        p_priv->dcd_state = ((msg->gpia_dcd) ? 1 : 0);
 
-       if (port->tty && !C_CLOCAL(port->tty)
+       if (port->port.tty && !C_CLOCAL(port->port.tty)
            && old_dcd_state != p_priv->dcd_state) {
                if (old_dcd_state)
-                       tty_hangup(port->tty);
+                       tty_hangup(port->port.tty);
                /*  else */
                /*      wake_up_interruptible(&p_priv->open_wait); */
        }
@@ -1161,7 +1152,7 @@ static void usa67_glocont_callback(struct urb *urb)
        struct keyspan_port_private *p_priv;
        int i;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        serial = urb->context;
        for (i = 0; i < serial->num_ports; ++i) {
@@ -1169,7 +1160,7 @@ static void usa67_glocont_callback(struct urb *urb)
                p_priv = usb_get_serial_port_data(port);
 
                if (p_priv->resend_cont) {
-                       dbg ("%s - sending setup", __func__);
+                       dbg("%s - sending setup", __func__);
                        keyspan_usa67_send_setup(serial, port,
                                                p_priv->resend_cont - 1);
                        break;
@@ -1177,8 +1168,9 @@ static void usa67_glocont_callback(struct urb *urb)
        }
 }
 
-static int keyspan_write_room (struct usb_serial_port *port)
+static int keyspan_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct keyspan_port_private     *p_priv;
        const struct keyspan_device_details     *d_details;
        int                             flip;
@@ -1191,32 +1183,30 @@ static int keyspan_write_room (struct usb_serial_port *port)
 
        /* FIXME: locking */
        if (d_details->msg_format == msg_usa90)
-               data_len = 64;
+               data_len = 64;
        else
                data_len = 63;
 
        flip = p_priv->out_flip;
 
        /* Check both endpoints to see if any are available. */
-       if ((this_urb = p_priv->out_urbs[flip]) != NULL) {
+       this_urb = p_priv->out_urbs[flip];
+       if (this_urb != NULL) {
                if (this_urb->status != -EINPROGRESS)
-                       return (data_len);
-               flip = (flip + 1) & d_details->outdat_endp_flip;        
-               if ((this_urb = p_priv->out_urbs[flip]) != NULL) 
+                       return data_len;
+               flip = (flip + 1) & d_details->outdat_endp_flip;
+               this_urb = p_priv->out_urbs[flip];
+               if (this_urb != NULL) {
                        if (this_urb->status != -EINPROGRESS)
-                               return (data_len);
+                               return data_len;
+               }
        }
        return 0;
 }
 
 
-static int keyspan_chars_in_buffer (struct usb_serial_port *port)
-{
-       return 0;
-}
-
-
-static int keyspan_open (struct usb_serial_port *port, struct file *filp)
+static int keyspan_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct keyspan_port_private     *p_priv;
        struct keyspan_serial_private   *s_priv;
@@ -1225,7 +1215,7 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
        int                             i, err;
        int                             baud_rate, device_port;
        struct urb                      *urb;
-       unsigned int                    cflag;
+       unsigned int                    cflag = 0;
 
        s_priv = usb_get_serial_data(serial);
        p_priv = usb_get_serial_port_data(port);
@@ -1247,50 +1237,53 @@ static int keyspan_open (struct usb_serial_port *port, struct file *filp)
 
        /* Reset low level data toggle and start reading from endpoints */
        for (i = 0; i < 2; i++) {
-               if ((urb = p_priv->in_urbs[i]) == NULL)
+               urb = p_priv->in_urbs[i];
+               if (urb == NULL)
                        continue;
                urb->dev = serial->dev;
 
-               /* make sure endpoint data toggle is synchronized with the device */
-
+               /* make sure endpoint data toggle is synchronized
+                  with the device */
                usb_clear_halt(urb->dev, urb->pipe);
-
-               if ((err = usb_submit_urb(urb, GFP_KERNEL)) != 0) {
-                       dbg("%s - submit urb %d failed (%d)", __func__, i, err);
-               }
+               err = usb_submit_urb(urb, GFP_KERNEL);
+               if (err != 0)
+                       dbg("%s - submit urb %d failed (%d)",
+                                                       __func__, i, err);
        }
 
        /* Reset low level data toggle on out endpoints */
        for (i = 0; i < 2; i++) {
-               if ((urb = p_priv->out_urbs[i]) == NULL)
+               urb = p_priv->out_urbs[i];
+               if (urb == NULL)
                        continue;
                urb->dev = serial->dev;
-               /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe), 0); */
+               /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
+                                               usb_pipeout(urb->pipe), 0); */
        }
 
        /* get the terminal config for the setup message now so we don't
         * need to send 2 of them */
 
-       cflag = port->tty->termios->c_cflag;
        device_port = port->number - port->serial->minor;
-
-       /* Baud rate calculation takes baud rate as an integer
-          so other rates can be generated if desired. */
-       baud_rate = tty_get_baud_rate(port->tty);
-       /* If no match or invalid, leave as default */
-       if (baud_rate >= 0
-           && d_details->calculate_baud_rate(baud_rate, d_details->baudclk,
-                               NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
-               p_priv->baud = baud_rate;
+       if (tty) {
+               cflag = tty->termios->c_cflag;
+               /* Baud rate calculation takes baud rate as an integer
+                  so other rates can be generated if desired. */
+               baud_rate = tty_get_baud_rate(tty);
+               /* If no match or invalid, leave as default */
+               if (baud_rate >= 0
+                   && d_details->calculate_baud_rate(baud_rate, d_details->baudclk,
+                                       NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
+                       p_priv->baud = baud_rate;
+               }
        }
-
        /* set CTS/RTS handshake etc. */
        p_priv->cflag = cflag;
        p_priv->flow_control = (cflag & CRTSCTS)? flow_cts: flow_none;
 
        keyspan_send_setup(port, 1);
-       //mdelay(100);
-       //keyspan_set_termios(port, NULL);
+       /* mdelay(100); */
+       /* keyspan_set_termios(port, NULL); */
 
        return 0;
 }
@@ -1301,7 +1294,8 @@ static inline void stop_urb(struct urb *urb)
                usb_kill_urb(urb);
 }
 
-static void keyspan_close(struct usb_serial_port *port, struct file *filp)
+static void keyspan_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        int                     i;
        struct usb_serial       *serial = port->serial;
@@ -1311,15 +1305,15 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
        dbg("%s", __func__);
        s_priv = usb_get_serial_data(serial);
        p_priv = usb_get_serial_port_data(port);
-       
+
        p_priv->rts_state = 0;
        p_priv->dtr_state = 0;
-       
+
        if (serial->dev) {
                keyspan_send_setup(port, 2);
                /* pilot-xfer seems to work best with this delay */
                mdelay(100);
-               // keyspan_set_termios(port, NULL);
+               /* keyspan_set_termios(port, NULL); */
        }
 
        /*while (p_priv->outcont_urb->status == -EINPROGRESS) {
@@ -1338,11 +1332,11 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp)
                        stop_urb(p_priv->out_urbs[i]);
                }
        }
-       port->tty = NULL;
+       port->port.tty = NULL;
 }
 
-       /* download the firmware to a pre-renumeration device */
-static int keyspan_fake_startup (struct usb_serial *serial)
+/* download the firmware to a pre-renumeration device */
+static int keyspan_fake_startup(struct usb_serial *serial)
 {
        int                             response;
        const struct ihex_binrec        *record;
@@ -1352,10 +1346,11 @@ static int keyspan_fake_startup (struct usb_serial *serial)
        dbg("Keyspan startup version %04x product %04x",
            le16_to_cpu(serial->dev->descriptor.bcdDevice),
            le16_to_cpu(serial->dev->descriptor.idProduct));
-       
-       if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000) != 0x8000) {
+
+       if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000)
+                                                               != 0x8000) {
                dbg("Firmware already loaded.  Quitting.");
-               return(1);
+               return 1;
        }
 
                /* Select firmware image on the basis of idProduct */
@@ -1379,11 +1374,11 @@ static int keyspan_fake_startup (struct usb_serial *serial)
        case keyspan_usa19_pre_product_id:
                fw_name = "keyspan/usa19.fw";
                break;
-                            
+
        case keyspan_usa19qi_pre_product_id:
                fw_name = "keyspan/usa19qi.fw";
                break;
-                            
+
        case keyspan_mpr_pre_product_id:
                fw_name = "keyspan/mpr.fw";
                break;
@@ -1391,15 +1386,15 @@ static int keyspan_fake_startup (struct usb_serial *serial)
        case keyspan_usa19qw_pre_product_id:
                fw_name = "keyspan/usa19qw.fw";
                break;
-                            
+
        case keyspan_usa18x_pre_product_id:
                fw_name = "keyspan/usa18x.fw";
                break;
-                            
+
        case keyspan_usa19w_pre_product_id:
                fw_name = "keyspan/usa19w.fw";
                break;
-               
+
        case keyspan_usa49w_pre_product_id:
                fw_name = "keyspan/usa49w.fw";
                break;
@@ -1431,8 +1426,7 @@ static int keyspan_fake_startup (struct usb_serial *serial)
                                             (unsigned char *)record->data,
                                             be16_to_cpu(record->len), 0xa0);
                if (response < 0) {
-                       dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan"
-                               "firmware (%d %04X %p %d)\n",
+                       dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan firmware (%d %04X %p %d)\n",
                                response, be32_to_cpu(record->addr),
                                record->data, be16_to_cpu(record->len));
                        break;
@@ -1445,7 +1439,7 @@ static int keyspan_fake_startup (struct usb_serial *serial)
        response = ezusb_set_reset(serial, 0);
 
        /* we don't want this device to have a driver assigned to it. */
-       return (1);
+       return 1;
 }
 
 /* Helper functions used by keyspan_setup_urbs */
@@ -1467,7 +1461,7 @@ static struct usb_endpoint_descriptor const *find_ep(struct usb_serial const *se
        return NULL;
 }
 
-static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint,
+static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
                                      int dir, void *ctx, char *buf, int len,
                                      void (*callback)(struct urb *))
 {
@@ -1478,10 +1472,10 @@ static struct urb *keyspan_setup_urb (struct usb_serial *serial, int endpoint,
        if (endpoint == -1)
                return NULL;            /* endpoint not needed */
 
-       dbg ("%s - alloc for endpoint %d.", __func__, endpoint);
+       dbg("%s - alloc for endpoint %d.", __func__, endpoint);
        urb = usb_alloc_urb(0, GFP_KERNEL);             /* No ISO */
        if (urb == NULL) {
-               dbg ("%s - alloc for endpoint %d failed.", __func__, endpoint);
+               dbg("%s - alloc for endpoint %d failed.", __func__, endpoint);
                return NULL;
        }
 
@@ -1554,7 +1548,7 @@ static struct callbacks {
        }, {
                /* msg_usa90 callbacks */
                .instat_callback =      usa90_instat_callback,
-               .glocont_callback =     usa28_glocont_callback,         
+               .glocont_callback =     usa28_glocont_callback,
                .indat_callback =       usa90_indat_callback,
                .outdat_callback =      usa2x_outdat_callback,
                .inack_callback =       usa28_inack_callback,
@@ -1582,16 +1576,16 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
        struct callbacks                *cback;
        int                             endp;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        s_priv = usb_get_serial_data(serial);
        d_details = s_priv->device_details;
 
-               /* Setup values for the various callback routines */
+       /* Setup values for the various callback routines */
        cback = &keyspan_callbacks[d_details->msg_format];
 
-               /* Allocate and set up urbs for each one that is in use, 
-                  starting with instat endpoints */
+       /* Allocate and set up urbs for each one that is in use,
+          starting with instat endpoints */
        s_priv->instat_urb = keyspan_setup_urb
                (serial, d_details->instat_endpoint, USB_DIR_IN,
                 serial, s_priv->instat_buf, INSTAT_BUFLEN,
@@ -1607,8 +1601,8 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
                 serial, s_priv->glocont_buf, GLOCONT_BUFLEN,
                 cback->glocont_callback);
 
-               /* Setup endpoints for each port specific thing */
-       for (i = 0; i < d_details->num_ports; i ++) {
+       /* Setup endpoints for each port specific thing */
+       for (i = 0; i < d_details->num_ports; i++) {
                port = serial->port[i];
                p_priv = usb_get_serial_port_data(port);
 
@@ -1644,8 +1638,7 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
                        (serial, d_details->outcont_endpoints[i], USB_DIR_OUT,
                         port, p_priv->outcont_buffer, 64,
                         cback->outcont_callback);
-       }       
-
+       }
 }
 
 /* usa19 function doesn't require prescaler */
@@ -1653,46 +1646,39 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
                                   u8 *rate_low, u8 *prescaler, int portnum)
 {
        u32     b16,    /* baud rate times 16 (actual rate used internally) */
-               div,    /* divisor */   
+               div,    /* divisor */
                cnt;    /* inverse of divisor (programmed into 8051) */
-               
-       dbg ("%s - %d.", __func__, baud_rate);
-
-               /* prevent divide by zero...  */
-       if( (b16 = (baud_rate * 16L)) == 0) {
-               return (KEYSPAN_INVALID_BAUD_RATE);
-       }
 
-               /* Any "standard" rate over 57k6 is marginal on the USA-19
-                  as we run out of divisor resolution. */
-       if (baud_rate > 57600) {
-               return (KEYSPAN_INVALID_BAUD_RATE);
-       }
-
-               /* calculate the divisor and the counter (its inverse) */
-       if( (div = (baudclk / b16)) == 0) {
-               return (KEYSPAN_INVALID_BAUD_RATE);
-       }
-       else {
+       dbg("%s - %d.", __func__, baud_rate);
+
+       /* prevent divide by zero...  */
+       b16 = baud_rate * 16L;
+       if (b16 == 0)
+               return KEYSPAN_INVALID_BAUD_RATE;
+       /* Any "standard" rate over 57k6 is marginal on the USA-19
+          as we run out of divisor resolution. */
+       if (baud_rate > 57600)
+               return KEYSPAN_INVALID_BAUD_RATE;
+
+       /* calculate the divisor and the counter (its inverse) */
+       div = baudclk / b16;
+       if (div == 0)
+               return KEYSPAN_INVALID_BAUD_RATE;
+       else
                cnt = 0 - div;
-       }
 
-       if(div > 0xffff) {
-               return (KEYSPAN_INVALID_BAUD_RATE);
-       }
+       if (div > 0xffff)
+               return KEYSPAN_INVALID_BAUD_RATE;
 
-               /* return the counter values if non-null */
-       if (rate_low) {
+       /* return the counter values if non-null */
+       if (rate_low)
                *rate_low = (u8) (cnt & 0xff);
-       }
-       if (rate_hi) {
+       if (rate_hi)
                *rate_hi = (u8) ((cnt >> 8) & 0xff);
-       }
-       if (rate_low && rate_hi) {
-               dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low);
-       }
-       
-       return (KEYSPAN_BAUD_RATE_OK);
+       if (rate_low && rate_hi)
+               dbg("%s - %d %02x %02x.",
+                               __func__, baud_rate, *rate_hi, *rate_low);
+       return KEYSPAN_BAUD_RATE_OK;
 }
 
 /* usa19hs function doesn't require prescaler */
@@ -1700,34 +1686,35 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
                                   u8 *rate_low, u8 *prescaler, int portnum)
 {
        u32     b16,    /* baud rate times 16 (actual rate used internally) */
-                       div;    /* divisor */   
-               
-       dbg ("%s - %d.", __func__, baud_rate);
+                       div;    /* divisor */
 
-               /* prevent divide by zero...  */
-       if( (b16 = (baud_rate * 16L)) == 0) 
-               return (KEYSPAN_INVALID_BAUD_RATE);
-       
+       dbg("%s - %d.", __func__, baud_rate);
 
+       /* prevent divide by zero...  */
+       b16 = baud_rate * 16L;
+       if (b16 == 0)
+               return KEYSPAN_INVALID_BAUD_RATE;
 
-               /* calculate the divisor */
-       if( (div = (baudclk / b16)) == 0) 
-               return (KEYSPAN_INVALID_BAUD_RATE);
+       /* calculate the divisor */
+       div = baudclk / b16;
+       if (div == 0)
+               return KEYSPAN_INVALID_BAUD_RATE;
 
-       if(div > 0xffff) 
-               return (KEYSPAN_INVALID_BAUD_RATE);
+       if (div > 0xffff)
+               return KEYSPAN_INVALID_BAUD_RATE;
 
-               /* return the counter values if non-null */
-       if (rate_low) 
+       /* return the counter values if non-null */
+       if (rate_low)
                *rate_low = (u8) (div & 0xff);
-       
-       if (rate_hi) 
+
+       if (rate_hi)
                *rate_hi = (u8) ((div >> 8) & 0xff);
-       
-       if (rate_low && rate_hi) 
-               dbg ("%s - %d %02x %02x.", __func__, baud_rate, *rate_hi, *rate_low);
-       
-       return (KEYSPAN_BAUD_RATE_OK);
+
+       if (rate_low && rate_hi)
+               dbg("%s - %d %02x %02x.",
+                       __func__, baud_rate, *rate_hi, *rate_low);
+
+       return KEYSPAN_BAUD_RATE_OK;
 }
 
 static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
@@ -1735,64 +1722,61 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
 {
        u32     b16,    /* baud rate times 16 (actual rate used internally) */
                clk,    /* clock with 13/8 prescaler */
-               div,    /* divisor using 13/8 prescaler */      
+               div,    /* divisor using 13/8 prescaler */
                res,    /* resulting baud rate using 13/8 prescaler */
                diff,   /* error using 13/8 prescaler */
                smallest_diff;
        u8      best_prescaler;
        int     i;
 
-       dbg ("%s - %d.", __func__, baud_rate);
+       dbg("%s - %d.", __func__, baud_rate);
 
-               /* prevent divide by zero */
-       if( (b16 = baud_rate * 16L) == 0) {
-               return (KEYSPAN_INVALID_BAUD_RATE);
-       }
+       /* prevent divide by zero */
+       b16 = baud_rate * 16L;
+       if (b16 == 0)
+               return KEYSPAN_INVALID_BAUD_RATE;
 
-               /* Calculate prescaler by trying them all and looking
-                  for best fit */
-               
-               /* start with largest possible difference */
+       /* Calculate prescaler by trying them all and looking
+          for best fit */
+
+       /* start with largest possible difference */
        smallest_diff = 0xffffffff;
 
                /* 0 is an invalid prescaler, used as a flag */
        best_prescaler = 0;
 
-       for(i = 8; i <= 0xff; ++i) {
+       for (i = 8; i <= 0xff; ++i) {
                clk = (baudclk * 8) / (u32) i;
-               
-               if( (div = clk / b16) == 0) {
+
+               div = clk / b16;
+               if (div == 0)
                        continue;
-               }
 
                res = clk / div;
-               diff= (res > b16) ? (res-b16) : (b16-res);
+               diff = (res > b16) ? (res-b16) : (b16-res);
 
-               if(diff < smallest_diff) {
+               if (diff < smallest_diff) {
                        best_prescaler = i;
                        smallest_diff = diff;
                }
        }
 
-       if(best_prescaler == 0) {
-               return (KEYSPAN_INVALID_BAUD_RATE);
-       }
+       if (best_prescaler == 0)
+               return KEYSPAN_INVALID_BAUD_RATE;
 
        clk = (baudclk * 8) / (u32) best_prescaler;
        div = clk / b16;
 
-               /* return the divisor and prescaler if non-null */
-       if (rate_low) {
+       /* return the divisor and prescaler if non-null */
+       if (rate_low)
                *rate_low = (u8) (div & 0xff);
-       }
-       if (rate_hi) {
+       if (rate_hi)
                *rate_hi = (u8) ((div >> 8) & 0xff);
-       }
        if (prescaler) {
                *prescaler = best_prescaler;
                /*  dbg("%s - %d %d", __func__, *prescaler, div); */
        }
-       return (KEYSPAN_BAUD_RATE_OK);
+       return KEYSPAN_BAUD_RATE_OK;
 }
 
        /* USA-28 supports different maximum baud rates on each port */
@@ -1800,57 +1784,51 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
                                    u8 *rate_low, u8 *prescaler, int portnum)
 {
        u32     b16,    /* baud rate times 16 (actual rate used internally) */
-               div,    /* divisor */   
+               div,    /* divisor */
                cnt;    /* inverse of divisor (programmed into 8051) */
 
-       dbg ("%s - %d.", __func__, baud_rate);
+       dbg("%s - %d.", __func__, baud_rate);
 
                /* prevent divide by zero */
-       if ((b16 = baud_rate * 16L) == 0)
-               return (KEYSPAN_INVALID_BAUD_RATE);
-
-               /* calculate the divisor and the counter (its inverse) */
-       if ((div = (KEYSPAN_USA28_BAUDCLK / b16)) == 0) {
-               return (KEYSPAN_INVALID_BAUD_RATE);
-       }
-       else {
+       b16 = baud_rate * 16L;
+       if (b16 == 0)
+               return KEYSPAN_INVALID_BAUD_RATE;
+
+       /* calculate the divisor and the counter (its inverse) */
+       div = KEYSPAN_USA28_BAUDCLK / b16;
+       if (div == 0)
+               return KEYSPAN_INVALID_BAUD_RATE;
+       else
                cnt = 0 - div;
-       }
 
-               /* check for out of range, based on portnum, 
-                  and return result */
-       if(portnum == 0) {
-               if(div > 0xffff)
-                       return (KEYSPAN_INVALID_BAUD_RATE);
-       }
-       else {
-               if(portnum == 1) {
-                       if(div > 0xff) {
-                               return (KEYSPAN_INVALID_BAUD_RATE);
-                       }
-               }
-               else {
-                       return (KEYSPAN_INVALID_BAUD_RATE);
-               }
+       /* check for out of range, based on portnum,
+          and return result */
+       if (portnum == 0) {
+               if (div > 0xffff)
+                       return KEYSPAN_INVALID_BAUD_RATE;
+       } else {
+               if (portnum == 1) {
+                       if (div > 0xff)
+                               return KEYSPAN_INVALID_BAUD_RATE;
+               } else
+                       return KEYSPAN_INVALID_BAUD_RATE;
        }
 
                /* return the counter values if not NULL
                   (port 1 will ignore retHi) */
-       if (rate_low) {
+       if (rate_low)
                *rate_low = (u8) (cnt & 0xff);
-       }
-       if (rate_hi) {
+       if (rate_hi)
                *rate_hi = (u8) ((cnt >> 8) & 0xff);
-       }
-       dbg ("%s - %d OK.", __func__, baud_rate);
-       return (KEYSPAN_BAUD_RATE_OK);
+       dbg("%s - %d OK.", __func__, baud_rate);
+       return KEYSPAN_BAUD_RATE_OK;
 }
 
 static int keyspan_usa26_send_setup(struct usb_serial *serial,
                                    struct usb_serial_port *port,
                                    int reset_port)
 {
-       struct keyspan_usa26_portControlMessage msg;            
+       struct keyspan_usa26_portControlMessage msg;
        struct keyspan_serial_private           *s_priv;
        struct keyspan_port_private             *p_priv;
        const struct keyspan_device_details     *d_details;
@@ -1858,7 +1836,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
        struct urb                              *this_urb;
        int                                     device_port, err;
 
-       dbg ("%s reset=%d", __func__, reset_port);
+       dbg("%s reset=%d", __func__, reset_port);
 
        s_priv = usb_get_serial_data(serial);
        p_priv = usb_get_serial_port_data(port);
@@ -1881,22 +1859,22 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
        if ((reset_port + 1) > p_priv->resend_cont)
                p_priv->resend_cont = reset_port + 1;
        if (this_urb->status == -EINPROGRESS) {
-               /*  dbg ("%s - already writing", __func__); */
+               /*  dbg("%s - already writing", __func__); */
                mdelay(5);
-               return(-1);
+               return -1;
        }
 
-       memset(&msg, 0, sizeof (struct keyspan_usa26_portControlMessage));
-       
-               /* Only set baud rate if it's changed */        
+       memset(&msg, 0, sizeof(struct keyspan_usa26_portControlMessage));
+
+       /* Only set baud rate if it's changed */
        if (p_priv->old_baud != p_priv->baud) {
                p_priv->old_baud = p_priv->baud;
                msg.setClocking = 0xff;
                if (d_details->calculate_baud_rate
                    (p_priv->baud, d_details->baudclk, &msg.baudHi,
-                    &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
-                       dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
-                           p_priv->baud);
+                    &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
+                       dbg("%s - Invalid baud rate %d requested, using 9600.",
+                                               __func__, p_priv->baud);
                        msg.baudLo = 0;
                        msg.baudHi = 125;       /* Values for 9600 baud */
                        msg.prescaler = 10;
@@ -1922,7 +1900,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
        if (p_priv->cflag & PARENB) {
                /* note USA_PARITY_NONE == 0 */
                msg.lcr |= (p_priv->cflag & PARODD)?
-                       USA_PARITY_ODD: USA_PARITY_EVEN;
+                       USA_PARITY_ODD : USA_PARITY_EVEN;
        }
        msg.setLcr = 0xff;
 
@@ -1963,7 +1941,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
 
        /* Sending intermediate configs */
        else {
-               msg._txOn = (! p_priv->break_on);
+               msg._txOn = (!p_priv->break_on);
                msg._txOff = 0;
                msg.txFlush = 0;
                msg.txBreak = (p_priv->break_on);
@@ -1975,23 +1953,23 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
                msg.resetDataToggle = 0x0;
        }
 
-               /* Do handshaking outputs */    
+       /* Do handshaking outputs */
        msg.setTxTriState_setRts = 0xff;
        msg.txTriState_rts = p_priv->rts_state;
 
        msg.setHskoa_setDtr = 0xff;
        msg.hskoa_dtr = p_priv->dtr_state;
-               
+
        p_priv->resend_cont = 0;
-       memcpy (this_urb->transfer_buffer, &msg, sizeof(msg));
-       
+       memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
+
        /* send the data out the device on control endpoint */
        this_urb->transfer_buffer_length = sizeof(msg);
 
        this_urb->dev = serial->dev;
-       if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
+       err = usb_submit_urb(this_urb, GFP_ATOMIC);
+       if (err != 0)
                dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err);
-       }
 #if 0
        else {
                dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__
@@ -2007,14 +1985,14 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
                                    struct usb_serial_port *port,
                                    int reset_port)
 {
-       struct keyspan_usa28_portControlMessage msg;            
+       struct keyspan_usa28_portControlMessage msg;
        struct keyspan_serial_private           *s_priv;
        struct keyspan_port_private             *p_priv;
        const struct keyspan_device_details     *d_details;
        struct urb                              *this_urb;
        int                                     device_port, err;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        s_priv = usb_get_serial_data(serial);
        p_priv = usb_get_serial_port_data(port);
@@ -2022,7 +2000,8 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
        device_port = port->number - port->serial->minor;
 
        /* only do something if we have a bulk out endpoint */
-       if ((this_urb = p_priv->outcont_urb) == NULL) {
+       this_urb = p_priv->outcont_urb;
+       if (this_urb == NULL) {
                dbg("%s - oops no urb.", __func__);
                return -1;
        }
@@ -2032,17 +2011,18 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
        if ((reset_port + 1) > p_priv->resend_cont)
                p_priv->resend_cont = reset_port + 1;
        if (this_urb->status == -EINPROGRESS) {
-               dbg ("%s already writing", __func__);
+               dbg("%s already writing", __func__);
                mdelay(5);
-               return(-1);
+               return -1;
        }
 
-       memset(&msg, 0, sizeof (struct keyspan_usa28_portControlMessage));
+       memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage));
 
        msg.setBaudRate = 1;
        if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk,
-               &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
-               dbg("%s - Invalid baud rate requested %d.", __func__, p_priv->baud);
+               &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
+               dbg("%s - Invalid baud rate requested %d.",
+                                               __func__, p_priv->baud);
                msg.baudLo = 0xff;
                msg.baudHi = 0xb2;      /* Values for 9600 baud */
        }
@@ -2053,7 +2033,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
        msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
        msg.xonFlowControl = 0;
 
-       /* Do handshaking outputs, DTR is inverted relative to RTS */   
+       /* Do handshaking outputs, DTR is inverted relative to RTS */
        msg.rts = p_priv->rts_state;
        msg.dtr = p_priv->dtr_state;
 
@@ -2095,7 +2075,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
        }
        /* Sending intermediate configs */
        else {
-               msg._txOn = (! p_priv->break_on);
+               msg._txOn = (!p_priv->break_on);
                msg._txOff = 0;
                msg.txFlush = 0;
                msg.txForceXoff = 0;
@@ -2109,15 +2089,15 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
        }
 
        p_priv->resend_cont = 0;
-       memcpy (this_urb->transfer_buffer, &msg, sizeof(msg));
+       memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
 
        /* send the data out the device on control endpoint */
        this_urb->transfer_buffer_length = sizeof(msg);
 
        this_urb->dev = serial->dev;
-       if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
+       err = usb_submit_urb(this_urb, GFP_ATOMIC);
+       if (err != 0)
                dbg("%s - usb_submit_urb(setup) failed", __func__);
-       }
 #if 0
        else {
                dbg("%s - usb_submit_urb(setup) OK %d bytes", __func__,
@@ -2140,7 +2120,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
        struct urb                              *this_urb;
        int                                     err, device_port;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        s_priv = usb_get_serial_data(serial);
        p_priv = usb_get_serial_port_data(port);
@@ -2151,7 +2131,9 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
        /* Work out which port within the device is being setup */
        device_port = port->number - port->serial->minor;
 
-       dbg("%s - endpoint %d port %d (%d)",__func__, usb_pipeendpoint(this_urb->pipe), port->number, device_port);
+       dbg("%s - endpoint %d port %d (%d)",
+                       __func__, usb_pipeendpoint(this_urb->pipe),
+                       port->number, device_port);
 
                /* Make sure we have an urb then send the message */
        if (this_urb == NULL) {
@@ -2165,30 +2147,30 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
                p_priv->resend_cont = reset_port + 1;
 
        if (this_urb->status == -EINPROGRESS) {
-               /*  dbg ("%s - already writing", __func__); */
+               /*  dbg("%s - already writing", __func__); */
                mdelay(5);
-               return(-1);
+               return -1;
        }
 
-       memset(&msg, 0, sizeof (struct keyspan_usa49_portControlMessage));
+       memset(&msg, 0, sizeof(struct keyspan_usa49_portControlMessage));
 
        /*msg.portNumber = port->number;*/
        msg.portNumber = device_port;
-       
-               /* Only set baud rate if it's changed */        
+
+       /* Only set baud rate if it's changed */
        if (p_priv->old_baud != p_priv->baud) {
                p_priv->old_baud = p_priv->baud;
                msg.setClocking = 0xff;
                if (d_details->calculate_baud_rate
                    (p_priv->baud, d_details->baudclk, &msg.baudHi,
-                    &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
-                       dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
-                           p_priv->baud);
+                    &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
+                       dbg("%s - Invalid baud rate %d requested, using 9600.",
+                                               __func__, p_priv->baud);
                        msg.baudLo = 0;
                        msg.baudHi = 125;       /* Values for 9600 baud */
                        msg.prescaler = 10;
                }
-               //msg.setPrescaler = 0xff;
+               /* msg.setPrescaler = 0xff; */
        }
 
        msg.lcr = (p_priv->cflag & CSTOPB)? STOPBITS_678_2: STOPBITS_5678_1;
@@ -2209,19 +2191,19 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
        if (p_priv->cflag & PARENB) {
                /* note USA_PARITY_NONE == 0 */
                msg.lcr |= (p_priv->cflag & PARODD)?
-                       USA_PARITY_ODD: USA_PARITY_EVEN;
+                       USA_PARITY_ODD : USA_PARITY_EVEN;
        }
        msg.setLcr = 0xff;
 
        msg.ctsFlowControl = (p_priv->flow_control == flow_cts);
        msg.xonFlowControl = 0;
        msg.setFlowControl = 0xff;
-       
+
        msg.forwardingLength = 16;
        msg.xonChar = 17;
        msg.xoffChar = 19;
 
-       /* Opening port */ 
+       /* Opening port */
        if (reset_port == 1) {
                msg._txOn = 1;
                msg._txOff = 0;
@@ -2253,7 +2235,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
        }
        /* Sending intermediate configs */
        else {
-               msg._txOn = (! p_priv->break_on);
+               msg._txOn = (!p_priv->break_on);
                msg._txOff = 0;
                msg.txFlush = 0;
                msg.txBreak = (p_priv->break_on);
@@ -2267,16 +2249,17 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
                msg.disablePort = 0;
        }
 
-               /* Do handshaking outputs */    
+       /* Do handshaking outputs */
        msg.setRts = 0xff;
        msg.rts = p_priv->rts_state;
 
        msg.setDtr = 0xff;
        msg.dtr = p_priv->dtr_state;
-               
+
        p_priv->resend_cont = 0;
 
-       /* if the device is a 49wg, we send control message on usb control EP 0 */
+       /* if the device is a 49wg, we send control message on usb
+          control EP 0 */
 
        if (d_details->product_id == keyspan_usa49wg_product_id) {
                dr = (void *)(s_priv->ctrl_buf);
@@ -2286,23 +2269,24 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
                dr->wIndex = 0;
                dr->wLength = cpu_to_le16(sizeof(msg));
 
-               memcpy (s_priv->glocont_buf, &msg, sizeof(msg));
+               memcpy(s_priv->glocont_buf, &msg, sizeof(msg));
 
-               usb_fill_control_urb(this_urb, serial->dev, usb_sndctrlpipe(serial->dev, 0),
-                            (unsigned char *)dr, s_priv->glocont_buf, sizeof(msg),
-                            usa49_glocont_callback, serial);
+               usb_fill_control_urb(this_urb, serial->dev,
+                               usb_sndctrlpipe(serial->dev, 0),
+                               (unsigned char *)dr, s_priv->glocont_buf,
+                               sizeof(msg), usa49_glocont_callback, serial);
 
        } else {
                memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
-       
+
                /* send the data out the device on control endpoint */
                this_urb->transfer_buffer_length = sizeof(msg);
 
                this_urb->dev = serial->dev;
        }
-       if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
+       err = usb_submit_urb(this_urb, GFP_ATOMIC);
+       if (err != 0)
                dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err);
-       }
 #if 0
        else {
                dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__,
@@ -2318,7 +2302,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
                                    struct usb_serial_port *port,
                                    int reset_port)
 {
-       struct keyspan_usa90_portControlMessage msg;            
+       struct keyspan_usa90_portControlMessage msg;
        struct keyspan_serial_private           *s_priv;
        struct keyspan_port_private             *p_priv;
        const struct keyspan_device_details     *d_details;
@@ -2326,14 +2310,15 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
        int                                     err;
        u8                                              prescaler;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        s_priv = usb_get_serial_data(serial);
        p_priv = usb_get_serial_port_data(port);
        d_details = s_priv->device_details;
 
        /* only do something if we have a bulk out endpoint */
-       if ((this_urb = p_priv->outcont_urb) == NULL) {
+       this_urb = p_priv->outcont_urb;
+       if (this_urb == NULL) {
                dbg("%s - oops no urb.", __func__);
                return -1;
        }
@@ -2343,24 +2328,24 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
        if ((reset_port + 1) > p_priv->resend_cont)
                p_priv->resend_cont = reset_port + 1;
        if (this_urb->status == -EINPROGRESS) {
-               dbg ("%s already writing", __func__);
+               dbg("%s already writing", __func__);
                mdelay(5);
-               return(-1);
+               return -1;
        }
 
-       memset(&msg, 0, sizeof (struct keyspan_usa90_portControlMessage));
+       memset(&msg, 0, sizeof(struct keyspan_usa90_portControlMessage));
 
-       /* Only set baud rate if it's changed */        
+       /* Only set baud rate if it's changed */
        if (p_priv->old_baud != p_priv->baud) {
                p_priv->old_baud = p_priv->baud;
                msg.setClocking = 0x01;
                if (d_details->calculate_baud_rate
                    (p_priv->baud, d_details->baudclk, &msg.baudHi,
-                    &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE ) {
-                       dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
-                           p_priv->baud);
+                    &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) {
+                       dbg("%s - Invalid baud rate %d requested, using 9600.",
+                                               __func__, p_priv->baud);
                        p_priv->baud = 9600;
-                       d_details->calculate_baud_rate (p_priv->baud, d_details->baudclk, 
+                       d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk,
                                &msg.baudHi, &msg.baudLo, &prescaler, 0);
                }
                msg.setRxMode = 1;
@@ -2368,13 +2353,10 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
        }
 
        /* modes must always be correctly specified */
-       if (p_priv->baud > 57600)
-       {
+       if (p_priv->baud > 57600) {
                msg.rxMode = RXMODE_DMA;
                msg.txMode = TXMODE_DMA;
-       }
-       else
-       {
+       } else {
                msg.rxMode = RXMODE_BYHAND;
                msg.txMode = TXMODE_BYHAND;
        }
@@ -2397,7 +2379,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
        if (p_priv->cflag & PARENB) {
                /* note USA_PARITY_NONE == 0 */
                msg.lcr |= (p_priv->cflag & PARODD)?
-                       USA_PARITY_ODD: USA_PARITY_EVEN;
+                       USA_PARITY_ODD : USA_PARITY_EVEN;
        }
        if (p_priv->old_cflag != p_priv->cflag) {
                p_priv->old_cflag = p_priv->cflag;
@@ -2408,47 +2390,46 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
                msg.txFlowControl = TXFLOW_CTS;
        msg.setTxFlowControl = 0x01;
        msg.setRxFlowControl = 0x01;
-       
+
        msg.rxForwardingLength = 16;
-       msg.rxForwardingTimeout = 16;   
+       msg.rxForwardingTimeout = 16;
        msg.txAckSetting = 0;
        msg.xonChar = 17;
        msg.xoffChar = 19;
 
-       /* Opening port */ 
+       /* Opening port */
        if (reset_port == 1) {
                msg.portEnabled = 1;
                msg.rxFlush = 1;
                msg.txBreak = (p_priv->break_on);
        }
        /* Closing port */
-       else if (reset_port == 2) {
+       else if (reset_port == 2)
                msg.portEnabled = 0;
-       }
        /* Sending intermediate configs */
        else {
-               if (port->open_count)
+               if (port->port.count)
                        msg.portEnabled = 1;
                msg.txBreak = (p_priv->break_on);
        }
 
-       /* Do handshaking outputs */    
+       /* Do handshaking outputs */
        msg.setRts = 0x01;
        msg.rts = p_priv->rts_state;
 
        msg.setDtr = 0x01;
        msg.dtr = p_priv->dtr_state;
-               
+
        p_priv->resend_cont = 0;
-       memcpy (this_urb->transfer_buffer, &msg, sizeof(msg));
-       
+       memcpy(this_urb->transfer_buffer, &msg, sizeof(msg));
+
        /* send the data out the device on control endpoint */
        this_urb->transfer_buffer_length = sizeof(msg);
 
        this_urb->dev = serial->dev;
-       if ((err = usb_submit_urb(this_urb, GFP_ATOMIC)) != 0) {
+       err = usb_submit_urb(this_urb, GFP_ATOMIC);
+       if (err != 0)
                dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err);
-       }
        return 0;
 }
 
@@ -2463,7 +2444,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
        struct urb                              *this_urb;
        int                                     err, device_port;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        s_priv = usb_get_serial_data(serial);
        p_priv = usb_get_serial_port_data(port);
@@ -2486,9 +2467,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
        if ((reset_port + 1) > p_priv->resend_cont)
                p_priv->resend_cont = reset_port + 1;
        if (this_urb->status == -EINPROGRESS) {
-               /*  dbg ("%s - already writing", __func__); */
+               /*  dbg("%s - already writing", __func__); */
                mdelay(5);
-               return(-1);
+               return -1;
        }
 
        memset(&msg, 0, sizeof(struct keyspan_usa67_portControlMessage));
@@ -2501,9 +2482,9 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
                msg.setClocking = 0xff;
                if (d_details->calculate_baud_rate
                    (p_priv->baud, d_details->baudclk, &msg.baudHi,
-                    &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE ) {
-                       dbg("%s - Invalid baud rate %d requested, using 9600.", __func__,
-                           p_priv->baud);
+                    &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) {
+                       dbg("%s - Invalid baud rate %d requested, using 9600.",
+                                               __func__, p_priv->baud);
                        msg.baudLo = 0;
                        msg.baudHi = 125;       /* Values for 9600 baud */
                        msg.prescaler = 10;
@@ -2529,7 +2510,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
        if (p_priv->cflag & PARENB) {
                /* note USA_PARITY_NONE == 0 */
                msg.lcr |= (p_priv->cflag & PARODD)?
-                       USA_PARITY_ODD: USA_PARITY_EVEN;
+                                       USA_PARITY_ODD : USA_PARITY_EVEN;
        }
        msg.setLcr = 0xff;
 
@@ -2566,7 +2547,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
                msg.resetDataToggle = 0;
        } else {
                /* Sending intermediate configs */
-               msg._txOn = (! p_priv->break_on);
+               msg._txOn = (!p_priv->break_on);
                msg._txOff = 0;
                msg.txFlush = 0;
                msg.txBreak = (p_priv->break_on);
@@ -2606,7 +2587,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
        struct keyspan_serial_private *s_priv;
        const struct keyspan_device_details *d_details;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        s_priv = usb_get_serial_data(serial);
        d_details = s_priv->device_details;
@@ -2633,7 +2614,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
 
 /* Gets called by the "real" driver (ie once firmware is loaded
    and renumeration has taken place. */
-static int keyspan_startup (struct usb_serial *serial)
+static int keyspan_startup(struct usb_serial *serial)
 {
        int                             i, err;
        struct usb_serial_port          *port;
@@ -2644,17 +2625,20 @@ static int keyspan_startup (struct usb_serial *serial)
        dbg("%s", __func__);
 
        for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i)
-               if (d_details->product_id == le16_to_cpu(serial->dev->descriptor.idProduct))
+               if (d_details->product_id ==
+                               le16_to_cpu(serial->dev->descriptor.idProduct))
                        break;
        if (d_details == NULL) {
-               dev_err(&serial->dev->dev, "%s - unknown product id %x\n", __func__, le16_to_cpu(serial->dev->descriptor.idProduct));
+               dev_err(&serial->dev->dev, "%s - unknown product id %x\n",
+                   __func__, le16_to_cpu(serial->dev->descriptor.idProduct));
                return 1;
        }
 
        /* Setup private data for serial driver */
        s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
        if (!s_priv) {
-               dbg("%s - kmalloc for keyspan_serial_private failed.", __func__);
+               dbg("%s - kmalloc for keyspan_serial_private failed.",
+                                                               __func__);
                return -ENOMEM;
        }
 
@@ -2664,10 +2648,11 @@ static int keyspan_startup (struct usb_serial *serial)
        /* Now setup per port private data */
        for (i = 0; i < serial->num_ports; i++) {
                port = serial->port[i];
-               p_priv = kzalloc(sizeof(struct keyspan_port_private), GFP_KERNEL);
+               p_priv = kzalloc(sizeof(struct keyspan_port_private),
+                                                               GFP_KERNEL);
                if (!p_priv) {
                        dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __func__, i);
-                       return (1);
+                       return 1;
                }
                p_priv->device_details = d_details;
                usb_set_serial_port_data(port, p_priv);
@@ -2689,11 +2674,11 @@ static int keyspan_startup (struct usb_serial *serial)
                        dbg("%s - submit indat urb failed %d", __func__,
                                err);
        }
-                       
+
        return 0;
 }
 
-static void keyspan_shutdown (struct usb_serial *serial)
+static void keyspan_shutdown(struct usb_serial *serial)
 {
        int                             i, j;
        struct usb_serial_port          *port;
@@ -2745,8 +2730,8 @@ static void keyspan_shutdown (struct usb_serial *serial)
        }
 }
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 MODULE_FIRMWARE("keyspan/usa28.fw");
index 8bf7263..38b4582 100644 (file)
 
 
 /* Function prototypes for Keyspan serial converter */
-static int  keyspan_open               (struct usb_serial_port *port,
+static int  keyspan_open               (struct tty_struct *tty,
+                                        struct usb_serial_port *port,
                                         struct file *filp);
-static void keyspan_close              (struct usb_serial_port *port,
+static void keyspan_close              (struct tty_struct *tty,
+                                        struct usb_serial_port *port,
                                         struct file *filp);
 static int  keyspan_startup            (struct usb_serial *serial);
 static void keyspan_shutdown           (struct usb_serial *serial);
-static void keyspan_rx_throttle                (struct usb_serial_port *port);
-static void keyspan_rx_unthrottle      (struct usb_serial_port *port);
-static int  keyspan_write_room         (struct usb_serial_port *port);
+static int  keyspan_write_room         (struct tty_struct *tty);
 
-static int  keyspan_write              (struct usb_serial_port *port,
+static int  keyspan_write              (struct tty_struct *tty,
+                                        struct usb_serial_port *port,
                                         const unsigned char *buf,
                                         int count);
 
@@ -53,18 +54,14 @@ static void keyspan_send_setup              (struct usb_serial_port *port,
                                         int reset_port);
 
 
-static int  keyspan_chars_in_buffer    (struct usb_serial_port *port);
-static int  keyspan_ioctl              (struct usb_serial_port *port,
-                                        struct file *file,
-                                        unsigned int cmd,
-                                        unsigned long arg);
-static void keyspan_set_termios                (struct usb_serial_port *port,
+static void keyspan_set_termios                (struct tty_struct *tty,
+                                        struct usb_serial_port *port,
                                         struct ktermios *old);
-static void keyspan_break_ctl          (struct usb_serial_port *port,
+static void keyspan_break_ctl          (struct tty_struct *tty,
                                         int break_state);
-static int  keyspan_tiocmget           (struct usb_serial_port *port,
+static int  keyspan_tiocmget           (struct tty_struct *tty,
                                         struct file *file);
-static int  keyspan_tiocmset           (struct usb_serial_port *port,
+static int  keyspan_tiocmset           (struct tty_struct *tty,
                                         struct file *file, unsigned int set,
                                         unsigned int clear);
 static int  keyspan_fake_startup       (struct usb_serial *serial);
@@ -567,10 +564,6 @@ static struct usb_serial_driver keyspan_1port_device = {
        .close                  = keyspan_close,
        .write                  = keyspan_write,
        .write_room             = keyspan_write_room,
-       .chars_in_buffer        = keyspan_chars_in_buffer,
-       .throttle               = keyspan_rx_throttle,
-       .unthrottle             = keyspan_rx_unthrottle,
-       .ioctl                  = keyspan_ioctl,
        .set_termios            = keyspan_set_termios,
        .break_ctl              = keyspan_break_ctl,
        .tiocmget               = keyspan_tiocmget,
@@ -591,10 +584,6 @@ static struct usb_serial_driver keyspan_2port_device = {
        .close                  = keyspan_close,
        .write                  = keyspan_write,
        .write_room             = keyspan_write_room,
-       .chars_in_buffer        = keyspan_chars_in_buffer,
-       .throttle               = keyspan_rx_throttle,
-       .unthrottle             = keyspan_rx_unthrottle,
-       .ioctl                  = keyspan_ioctl,
        .set_termios            = keyspan_set_termios,
        .break_ctl              = keyspan_break_ctl,
        .tiocmget               = keyspan_tiocmget,
@@ -615,10 +604,6 @@ static struct usb_serial_driver keyspan_4port_device = {
        .close                  = keyspan_close,
        .write                  = keyspan_write,
        .write_room             = keyspan_write_room,
-       .chars_in_buffer        = keyspan_chars_in_buffer,
-       .throttle               = keyspan_rx_throttle,
-       .unthrottle             = keyspan_rx_unthrottle,
-       .ioctl                  = keyspan_ioctl,
        .set_termios            = keyspan_set_termios,
        .break_ctl              = keyspan_break_ctl,
        .tiocmget               = keyspan_tiocmget,
index 60b3e22..040040a 100644 (file)
@@ -10,8 +10,9 @@
  *     the Free Software Foundation; either version 2 of the License, or
  *     (at your option) any later version.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
- * 
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
+ *
  * (09/07/2001) gkh
  *     cleaned up the Xircom support.  Added ids for Entregra device which is
  *     the same as the Xircom device.  Enabled the code to be compiled for
  *     support for Xircom PGSDB9
  *
  * (05/31/2001) gkh
- *     switched from using spinlock to a semaphore, which fixes lots of problems.
+ *     switched from using spinlock to a semaphore, which fixes lots of
+ *     problems.
  *
  * (04/08/2001) gb
  *     Identify version on module load.
- * 
+ *
  * (11/01/2000) Adam J. Richter
  *     usb_device_id table support
- * 
+ *
  * (10/05/2000) gkh
  *     Fixed bug with urb->dev not being set properly, now that the usb
  *     core needs it.
- * 
+ *
  * (08/28/2000) gkh
  *     Added locks for SMP safeness.
- *     Fixed MOD_INC and MOD_DEC logic and the ability to open a port more 
+ *     Fixed MOD_INC and MOD_DEC logic and the ability to open a port more
  *     than once.
- * 
+ *
  * (07/20/2000) borchers
  *     - keyspan_pda_write no longer sleeps if it is called on interrupt time;
  *       PPP and the line discipline with stty echo on can call write on
  *       than done directly from the callback to avoid the race in write_chan
  *     - keyspan_pda_chars_in_buffer also indicates its buffer is full if the
  *       urb status is -EINPROGRESS, meaning it cannot write at the moment
- *      
+ *
  * (07/19/2000) gkh
  *     Added module_init and module_exit functions to handle the fact that this
  *     driver is a loadable module now.
  *
  * (03/26/2000) gkh
  *     Split driver up into device specific pieces.
- * 
+ *
  */
 
 
@@ -78,7 +80,7 @@
 #include <linux/workqueue.h>
 #include <linux/firmware.h>
 #include <linux/ihex.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 
@@ -135,7 +137,7 @@ static struct usb_device_id id_table_combined [] = {
        { }                                             /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table_combined);
+MODULE_DEVICE_TABLE(usb, id_table_combined);
 
 static struct usb_driver keyspan_pda_driver = {
        .name =         "keyspan_pda",
@@ -159,9 +161,9 @@ static struct usb_device_id id_table_fake [] = {
 
 #ifdef XIRCOM
 static struct usb_device_id id_table_fake_xircom [] = {
-        { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) },
-        { USB_DEVICE(ENTREGRA_VENDOR_ID, ENTREGRA_FAKE_ID) },
-        { }                                             
+       { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) },
+       { USB_DEVICE(ENTREGRA_VENDOR_ID, ENTREGRA_FAKE_ID) },
+       { }
 };
 #endif
 
@@ -171,7 +173,7 @@ static void keyspan_pda_wakeup_write(struct work_struct *work)
                container_of(work, struct keyspan_pda_private, wakeup_work);
        struct usb_serial_port *port = priv->port;
 
-       tty_wakeup(port->tty);
+       tty_wakeup(port->port.tty);
 }
 
 static void keyspan_pda_request_unthrottle(struct work_struct *work)
@@ -184,7 +186,7 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work)
        dbg(" request_unthrottle");
        /* ask the device to tell us when the tx buffer becomes
           sufficiently empty */
-       result = usb_control_msg(serial->dev, 
+       result = usb_control_msg(serial->dev,
                                 usb_sndctrlpipe(serial->dev, 0),
                                 7, /* request_unthrottle */
                                 USB_TYPE_VENDOR | USB_RECIP_INTERFACE
@@ -195,17 +197,16 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work)
                                 0,
                                 2000);
        if (result < 0)
-               dbg("%s - error %d from usb_control_msg", 
+               dbg("%s - error %d from usb_control_msg",
                    __func__, result);
 }
 
 
-static void keyspan_pda_rx_interrupt (struct urb *urb)
+static void keyspan_pda_rx_interrupt(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
-               struct tty_struct *tty = port->tty;
+       struct tty_struct *tty = port->port.tty;
        unsigned char *data = urb->transfer_buffer;
-       int i;
        int retval;
        int status = urb->status;
        struct keyspan_pda_private *priv;
@@ -228,14 +229,13 @@ static void keyspan_pda_rx_interrupt (struct urb *urb)
                goto exit;
        }
 
-       /* see if the message is data or a status interrupt */
+       /* see if the message is data or a status interrupt */
        switch (data[0]) {
        case 0:
                /* rest of message is rx data */
                if (urb->actual_length) {
-                       for (i = 1; i < urb->actual_length ; ++i) {
-                               tty_insert_flip_char(tty, data[i], 0);
-                       }
+                       tty_insert_flip_string(tty, data + 1,
+                                               urb->actual_length - 1);
                        tty_flip_buffer_push(tty);
                }
                break;
@@ -259,14 +259,14 @@ static void keyspan_pda_rx_interrupt (struct urb *urb)
        }
 
 exit:
-       retval = usb_submit_urb (urb, GFP_ATOMIC);
+       retval = usb_submit_urb(urb, GFP_ATOMIC);
        if (retval)
-               err ("%s - usb_submit_urb failed with result %d",
+               err("%s - usb_submit_urb failed with result %d",
                     __func__, retval);
 }
 
 
-static void keyspan_pda_rx_throttle (struct usb_serial_port *port)
+static void keyspan_pda_rx_throttle(struct tty_struct *tty)
 {
        /* stop receiving characters. We just turn off the URB request, and
           let chars pile up in the device. If we're doing hardware
@@ -274,14 +274,15 @@ static void keyspan_pda_rx_throttle (struct usb_serial_port *port)
           fills up. If we're doing XON/XOFF, this would be a good time to
           send an XOFF, although it might make sense to foist that off
           upon the device too. */
-
+       struct usb_serial_port *port = tty->driver_data;
        dbg("keyspan_pda_rx_throttle port %d", port->number);
        usb_kill_urb(port->interrupt_in_urb);
 }
 
 
-static void keyspan_pda_rx_unthrottle (struct usb_serial_port *port)
+static void keyspan_pda_rx_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        /* just restart the receive interrupt URB */
        dbg("keyspan_pda_rx_unthrottle port %d", port->number);
        port->interrupt_in_urb->dev = port->serial->dev;
@@ -291,32 +292,52 @@ static void keyspan_pda_rx_unthrottle (struct usb_serial_port *port)
 }
 
 
-static speed_t keyspan_pda_setbaud (struct usb_serial *serial, speed_t baud)
+static speed_t keyspan_pda_setbaud(struct usb_serial *serial, speed_t baud)
 {
        int rc;
        int bindex;
 
-       switch(baud) {
-               case 110: bindex = 0; break;
-               case 300: bindex = 1; break;
-               case 1200: bindex = 2; break;
-               case 2400: bindex = 3; break;
-               case 4800: bindex = 4; break;
-               case 9600: bindex = 5; break;
-               case 19200: bindex = 6; break;
-               case 38400: bindex = 7; break;
-               case 57600: bindex = 8; break;
-               case 115200: bindex = 9; break;
-               default:
-                       bindex = 5;     /* Default to 9600 */
-                       baud = 9600;
+       switch (baud) {
+       case 110:
+               bindex = 0;
+               break;
+       case 300:
+               bindex = 1;
+               break;
+       case 1200:
+               bindex = 2;
+               break;
+       case 2400:
+               bindex = 3;
+               break;
+       case 4800:
+               bindex = 4;
+               break;
+       case 9600:
+               bindex = 5;
+               break;
+       case 19200:
+               bindex = 6;
+               break;
+       case 38400:
+               bindex = 7;
+               break;
+       case 57600:
+               bindex = 8;
+               break;
+       case 115200:
+               bindex = 9;
+               break;
+       default:
+               bindex = 5;     /* Default to 9600 */
+               baud = 9600;
        }
 
        /* rather than figure out how to sleep while waiting for this
           to complete, I just use the "legacy" API. */
        rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
                             0, /* set baud */
-                            USB_TYPE_VENDOR 
+                            USB_TYPE_VENDOR
                             | USB_RECIP_INTERFACE
                             | USB_DIR_OUT, /* type */
                             bindex, /* value */
@@ -330,8 +351,9 @@ static speed_t keyspan_pda_setbaud (struct usb_serial *serial, speed_t baud)
 }
 
 
-static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state)
+static void keyspan_pda_break_ctl(struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
        int value;
        int result;
@@ -341,11 +363,11 @@ static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state
        else
                value = 0; /* clear break */
        result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
-                               4, /* set break */
-                               USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
-                               value, 0, NULL, 0, 2000);
+                       4, /* set break */
+                       USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
+                       value, 0, NULL, 0, 2000);
        if (result < 0)
-               dbg("%s - error %d from usb_control_msg", 
+               dbg("%s - error %d from usb_control_msg",
                    __func__, result);
        /* there is something funky about this.. the TCSBRK that 'cu' performs
           ought to translate into a break_ctl(-1),break_ctl(0) pair HZ/4
@@ -354,8 +376,8 @@ static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state
 }
 
 
-static void keyspan_pda_set_termios (struct usb_serial_port *port, 
-                                    struct ktermios *old_termios)
+static void keyspan_pda_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct usb_serial *serial = port->serial;
        speed_t speed;
@@ -380,7 +402,7 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port,
 
           For now, just do baud. */
 
-       speed = tty_get_baud_rate(port->tty);
+       speed = tty_get_baud_rate(tty);
        speed = keyspan_pda_setbaud(serial, speed);
 
        if (speed == 0) {
@@ -390,8 +412,8 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port,
        }
        /* Only speed can change so copy the old h/w parameters
           then encode the new speed */
-       tty_termios_copy_hw(port->tty->termios, old_termios);
-       tty_encode_baud_rate(port->tty, speed, speed);
+       tty_termios_copy_hw(tty->termios, old_termios);
+       tty_encode_baud_rate(tty, speed, speed);
 }
 
 
@@ -425,8 +447,9 @@ static int keyspan_pda_set_modem_info(struct usb_serial *serial,
        return rc;
 }
 
-static int keyspan_pda_tiocmget(struct usb_serial_port *port, struct file *file)
+static int keyspan_pda_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
        int rc;
        unsigned char status;
@@ -445,9 +468,10 @@ static int keyspan_pda_tiocmget(struct usb_serial_port *port, struct file *file)
        return value;
 }
 
-static int keyspan_pda_tiocmset(struct usb_serial_port *port, struct file *file,
+static int keyspan_pda_tiocmset(struct tty_struct *tty, struct file *file,
                                unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
        int rc;
        unsigned char status;
@@ -469,23 +493,8 @@ static int keyspan_pda_tiocmset(struct usb_serial_port *port, struct file *file,
        return rc;
 }
 
-static int keyspan_pda_ioctl(struct usb_serial_port *port, struct file *file,
-                            unsigned int cmd, unsigned long arg)
-{
-       switch (cmd) {
-       case TIOCMIWAIT:
-               /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
-               /* TODO */
-       case TIOCGICOUNT:
-               /* return count of modemline transitions */
-               return 0; /* TODO */
-       }
-       
-       return -ENOIOCTLCMD;
-}
-
-static int keyspan_pda_write(struct usb_serial_port *port, 
-                            const unsigned char *buf, int count)
+static int keyspan_pda_write(struct tty_struct *tty,
+       struct usb_serial_port *port, const unsigned char *buf, int count)
 {
        struct usb_serial *serial = port->serial;
        int request_unthrottle = 0;
@@ -501,10 +510,10 @@ static int keyspan_pda_write(struct usb_serial_port *port,
           select() or poll() too) until we receive that unthrottle interrupt.
           Block if we can't write anything at all, otherwise write as much as
           we can. */
-       dbg("keyspan_pda_write(%d)",count);
+       dbg("keyspan_pda_write(%d)", count);
        if (count == 0) {
                dbg(" write request of 0 bytes");
-               return (0);
+               return 0;
        }
 
        /* we might block because of:
@@ -531,7 +540,7 @@ static int keyspan_pda_write(struct usb_serial_port *port,
           scheduler time, since usb_control_msg() sleeps. */
        if (count > priv->tx_room && !in_interrupt()) {
                unsigned char room;
-               rc = usb_control_msg(serial->dev, 
+               rc = usb_control_msg(serial->dev,
                                     usb_rcvctrlpipe(serial->dev, 0),
                                     6, /* write_room */
                                     USB_TYPE_VENDOR | USB_RECIP_INTERFACE
@@ -562,7 +571,7 @@ static int keyspan_pda_write(struct usb_serial_port *port,
 
        if (count) {
                /* now transfer data */
-               memcpy (port->write_urb->transfer_buffer, buf, count);
+               memcpy(port->write_urb->transfer_buffer, buf, count);
                /* send the data out the bulk port */
                port->write_urb->transfer_buffer_length = count;
 
@@ -574,8 +583,7 @@ static int keyspan_pda_write(struct usb_serial_port *port,
                        dbg(" usb_submit_urb(write bulk) failed");
                        goto exit;
                }
-       }
-       else {
+       } else {
                /* There wasn't any room left, so we are throttled until
                   the buffer empties a bit */
                request_unthrottle = 1;
@@ -594,7 +602,7 @@ exit:
 }
 
 
-static void keyspan_pda_write_bulk_callback (struct urb *urb)
+static void keyspan_pda_write_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        struct keyspan_pda_private *priv;
@@ -607,22 +615,21 @@ static void keyspan_pda_write_bulk_callback (struct urb *urb)
 }
 
 
-static int keyspan_pda_write_room (struct usb_serial_port *port)
+static int keyspan_pda_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct keyspan_pda_private *priv;
-
        priv = usb_get_serial_port_data(port);
-
        /* used by n_tty.c for processing of tabs and such. Giving it our
           conservative guess is probably good enough, but needs testing by
           running a console through the device. */
-
-       return (priv->tx_room);
+       return priv->tx_room;
 }
 
 
-static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port)
+static int keyspan_pda_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct keyspan_pda_private *priv;
        unsigned long flags;
        int ret = 0;
@@ -640,7 +647,8 @@ static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port)
 }
 
 
-static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
+static int keyspan_pda_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial *serial = port->serial;
        unsigned char room;
@@ -672,8 +680,8 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp)
 
        /* the normal serial device seems to always turn on DTR and RTS here,
           so do the same */
-       if (port->tty->termios->c_cflag & CBAUD)
-               keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2) );
+       if (tty && (tty->termios->c_cflag & CBAUD))
+               keyspan_pda_set_modem_info(serial, (1<<7) | (1<<2));
        else
                keyspan_pda_set_modem_info(serial, 0);
 
@@ -690,13 +698,15 @@ error:
 }
 
 
-static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp)
+static void keyspan_pda_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial *serial = port->serial;
 
        if (serial->dev) {
-               /* the normal serial device seems to always shut off DTR and RTS now */
-               if (port->tty->termios->c_cflag & HUPCL)
+               /* the normal serial device seems to always shut
+                  off DTR and RTS now */
+               if (tty->termios->c_cflag & HUPCL)
                        keyspan_pda_set_modem_info(serial, 0);
 
                /* shutdown our bulk reads and writes */
@@ -707,7 +717,7 @@ static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp)
 
 
 /* download the firmware to a "fake" device (pre-renumeration) */
-static int keyspan_pda_fake_startup (struct usb_serial *serial)
+static int keyspan_pda_fake_startup(struct usb_serial *serial)
 {
        int response;
        const char *fw_name;
@@ -756,10 +766,10 @@ static int keyspan_pda_fake_startup (struct usb_serial *serial)
        response = ezusb_set_reset(serial, 0);
 
        /* we want this device to fail to have a driver assigned to it. */
-       return (1);
+       return 1;
 }
 
-static int keyspan_pda_startup (struct usb_serial *serial)
+static int keyspan_pda_startup(struct usb_serial *serial)
 {
 
        struct keyspan_pda_private *priv;
@@ -769,20 +779,20 @@ static int keyspan_pda_startup (struct usb_serial *serial)
 
        priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
        if (!priv)
-               return (1); /* error */
+               return 1; /* error */
        usb_set_serial_port_data(serial->port[0], priv);
        init_waitqueue_head(&serial->port[0]->write_wait);
        INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write);
        INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
        priv->serial = serial;
        priv->port = serial->port[0];
-       return (0);
+       return 0;
 }
 
-static void keyspan_pda_shutdown (struct usb_serial *serial)
+static void keyspan_pda_shutdown(struct usb_serial *serial)
 {
        dbg("%s", __func__);
-       
+
        kfree(usb_get_serial_port_data(serial->port[0]));
 }
 
@@ -832,7 +842,6 @@ static struct usb_serial_driver keyspan_pda_device = {
        .chars_in_buffer =      keyspan_pda_chars_in_buffer,
        .throttle =             keyspan_pda_rx_throttle,
        .unthrottle =           keyspan_pda_rx_unthrottle,
-       .ioctl =                keyspan_pda_ioctl,
        .set_termios =          keyspan_pda_set_termios,
        .break_ctl =            keyspan_pda_break_ctl,
        .tiocmget =             keyspan_pda_tiocmget,
@@ -842,7 +851,7 @@ static struct usb_serial_driver keyspan_pda_device = {
 };
 
 
-static int __init keyspan_pda_init (void)
+static int __init keyspan_pda_init(void)
 {
        int retval;
        retval = usb_serial_register(&keyspan_pda_device);
@@ -863,7 +872,7 @@ static int __init keyspan_pda_init (void)
                goto failed_usb_register;
        info(DRIVER_DESC " " DRIVER_VERSION);
        return 0;
-failed_usb_register:   
+failed_usb_register:
 #ifdef XIRCOM
        usb_serial_deregister(&xircom_pgs_fake_device);
 failed_xircom_register:
@@ -880,15 +889,15 @@ failed_pda_register:
 }
 
 
-static void __exit keyspan_pda_exit (void)
+static void __exit keyspan_pda_exit(void)
 {
-       usb_deregister (&keyspan_pda_driver);
-       usb_serial_deregister (&keyspan_pda_device);
+       usb_deregister(&keyspan_pda_driver);
+       usb_serial_deregister(&keyspan_pda_device);
 #ifdef KEYSPAN
-       usb_serial_deregister (&keyspan_pda_fake_device);
+       usb_serial_deregister(&keyspan_pda_fake_device);
 #endif
 #ifdef XIRCOM
-       usb_serial_deregister (&xircom_pgs_fake_device);
+       usb_serial_deregister(&xircom_pgs_fake_device);
 #endif
 }
 
@@ -896,8 +905,8 @@ static void __exit keyspan_pda_exit (void)
 module_init(keyspan_pda_init);
 module_exit(keyspan_pda_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index 79787ed..b84dddc 100644 (file)
  * Neither Palm, nor their contractor (MCCI) or their supplier (KLSI) provided
  * information that was not already available.
  *
- * It seems that KLSI bought some silicon-design information from ScanLogic, 
+ * It seems that KLSI bought some silicon-design information from ScanLogic,
  * whose SL11R processor is at the core of the KL5KUSB chipset from KLSI.
  * KLSI has firmware available for their devices; it is probable that the
  * firmware differs from that used by KLSI in their products. If you have an
- * original KLSI device and can provide some information on it, I would be 
- * most interested in adding support for it here. If you have any information 
+ * original KLSI device and can provide some information on it, I would be
+ * most interested in adding support for it here. If you have any information
  * on the protocol used (or find errors in my reverse-engineered stuff), please
  * let me know.
  *
@@ -40,7 +40,7 @@
  *   0.2  - TIOCMGET works, so autopilot(1) can be used!
  *   0.1  - can be used to to pilot-xfer -p /dev/ttyUSB0 -l
  *
- *   The driver skeleton is mainly based on mct_u232.c and various other 
+ *   The driver skeleton is mainly based on mct_u232.c and various other
  *   pieces of code shamelessly copied from the drivers/usb/serial/ directory.
  */
 
@@ -53,7 +53,7 @@
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
 #include <linux/module.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <asm/unaligned.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
@@ -72,33 +72,25 @@ static int debug;
 /*
  * Function prototypes
  */
-static int  klsi_105_startup            (struct usb_serial *serial);
-static void klsi_105_shutdown           (struct usb_serial *serial);
-static int  klsi_105_open               (struct usb_serial_port *port,
-                                         struct file *filp);
-static void klsi_105_close              (struct usb_serial_port *port,
-                                         struct file *filp);
-static int  klsi_105_write              (struct usb_serial_port *port,
-                                         const unsigned char *buf,
-                                         int count);
-static void klsi_105_write_bulk_callback (struct urb *urb);
-static int  klsi_105_chars_in_buffer     (struct usb_serial_port *port);
-static int  klsi_105_write_room          (struct usb_serial_port *port);
-
-static void klsi_105_read_bulk_callback  (struct urb *urb);
-static void klsi_105_set_termios         (struct usb_serial_port *port,
-                                         struct ktermios *old);
-static void klsi_105_throttle           (struct usb_serial_port *port);
-static void klsi_105_unthrottle                 (struct usb_serial_port *port);
-/*
-static void klsi_105_break_ctl          (struct usb_serial_port *port,
-                                         int break_state );
- */
-static int  klsi_105_tiocmget           (struct usb_serial_port *port,
-                                         struct file *file);
-static int  klsi_105_tiocmset           (struct usb_serial_port *port,
-                                         struct file *file, unsigned int set,
-                                         unsigned int clear);
+static int  klsi_105_startup(struct usb_serial *serial);
+static void klsi_105_shutdown(struct usb_serial *serial);
+static int  klsi_105_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void klsi_105_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static int  klsi_105_write(struct tty_struct *tty,
+       struct usb_serial_port *port, const unsigned char *buf, int count);
+static void klsi_105_write_bulk_callback(struct urb *urb);
+static int  klsi_105_chars_in_buffer(struct tty_struct *tty);
+static int  klsi_105_write_room(struct tty_struct *tty);
+static void klsi_105_read_bulk_callback(struct urb *urb);
+static void klsi_105_set_termios(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct ktermios *old);
+static void klsi_105_throttle(struct tty_struct *tty);
+static void klsi_105_unthrottle(struct tty_struct *tty);
+static int  klsi_105_tiocmget(struct tty_struct *tty, struct file *file);
+static int  klsi_105_tiocmset(struct tty_struct *tty, struct file *file,
+                       unsigned int set, unsigned int clear);
 
 /*
  * All of the device info needed for the KLSI converters.
@@ -109,7 +101,7 @@ static struct usb_device_id id_table [] = {
        { }             /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table);
+MODULE_DEVICE_TABLE(usb, id_table);
 
 static struct usb_driver kl5kusb105d_driver = {
        .name =         "kl5kusb105d",
@@ -134,7 +126,7 @@ static struct usb_serial_driver kl5kusb105d_device = {
        .write_bulk_callback = klsi_105_write_bulk_callback,
        .chars_in_buffer =   klsi_105_chars_in_buffer,
        .write_room =        klsi_105_write_room,
-       .read_bulk_callback =klsi_105_read_bulk_callback,
+       .read_bulk_callback = klsi_105_read_bulk_callback,
        .set_termios =       klsi_105_set_termios,
        /*.break_ctl =       klsi_105_break_ctl,*/
        .tiocmget =          klsi_105_tiocmget,
@@ -161,7 +153,7 @@ struct klsi_105_private {
        struct ktermios                 termios;
        unsigned long                   line_state; /* modem line settings */
        /* write pool */
-       struct urb *                    write_urb_pool[NUM_URBS];
+       struct urb                      *write_urb_pool[NUM_URBS];
        spinlock_t                      lock;
        unsigned long                   bytes_in;
        unsigned long                   bytes_out;
@@ -180,15 +172,15 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port,
 {
        int rc;
 
-        rc = usb_control_msg(port->serial->dev,
-                            usb_sndctrlpipe(port->serial->dev, 0),
-                            KL5KUSB105A_SIO_SET_DATA,
-                             USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE,
-                            0, /* value */
-                            0, /* index */
-                            settings,
-                            sizeof(struct klsi_105_port_settings),
-                            KLSI_TIMEOUT);
+       rc = usb_control_msg(port->serial->dev,
+                       usb_sndctrlpipe(port->serial->dev, 0),
+                       KL5KUSB105A_SIO_SET_DATA,
+                       USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE,
+                       0, /* value */
+                       0, /* index */
+                       settings,
+                       sizeof(struct klsi_105_port_settings),
+                       KLSI_TIMEOUT);
        if (rc < 0)
                err("Change port settings failed (error = %d)", rc);
        info("%s - %d byte block, baudrate %x, databits %d, u1 %d, u2 %d",
@@ -196,7 +188,7 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port,
            settings->pktlen,
            settings->baudrate, settings->databits,
            settings->unknown1, settings->unknown2);
-        return rc;
+       return rc;
 } /* klsi_105_chg_port_settings */
 
 /* translate a 16-bit status value from the device to linux's TIO bits */
@@ -210,9 +202,9 @@ static unsigned long klsi_105_status2linestate(const __u16 status)
 
        return res;
 }
-/* 
+/*
  * Read line control via vendor command and return result through
- * *line_state_p 
+ * *line_state_p
  */
 /* It seems that the status buffer has always only 2 bytes length */
 #define KLSI_STATUSBUF_LEN     2
@@ -220,14 +212,14 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
                                   unsigned long *line_state_p)
 {
        int rc;
-       __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1,-1};
+       __u8 status_buf[KLSI_STATUSBUF_LEN] = { -1, -1};
        __u16 status;
 
        info("%s - sending SIO Poll request", __func__);
-        rc = usb_control_msg(port->serial->dev,
+       rc = usb_control_msg(port->serial->dev,
                             usb_rcvctrlpipe(port->serial->dev, 0),
                             KL5KUSB105A_SIO_POLL,
-                             USB_TYPE_VENDOR | USB_DIR_IN,
+                            USB_TYPE_VENDOR | USB_DIR_IN,
                             0, /* value */
                             0, /* index */
                             status_buf, KLSI_STATUSBUF_LEN,
@@ -243,8 +235,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
 
                *line_state_p = klsi_105_status2linestate(status);
        }
-
-        return rc;
+       return rc;
 }
 
 
@@ -252,7 +243,7 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
  * Driver's tty interface functions
  */
 
-static int klsi_105_startup (struct usb_serial *serial)
+static int klsi_105_startup(struct usb_serial *serial)
 {
        struct klsi_105_private *priv;
        int i, j;
@@ -262,7 +253,7 @@ static int klsi_105_startup (struct usb_serial *serial)
         */
 
        /* allocate the private data structure */
-       for (i=0; i<serial->num_ports; i++) {
+       for (i = 0; i < serial->num_ports; i++) {
                priv = kmalloc(sizeof(struct klsi_105_private),
                                                   GFP_KERNEL);
                if (!priv) {
@@ -283,9 +274,9 @@ static int klsi_105_startup (struct usb_serial *serial)
                priv->bytes_out     = 0;
                usb_set_serial_port_data(serial->port[i], priv);
 
-               spin_lock_init (&priv->lock);
-               for (j=0; j<NUM_URBS; j++) {
-                       struct urburb = usb_alloc_urb(0, GFP_KERNEL);
+               spin_lock_init(&priv->lock);
+               for (j = 0; j < NUM_URBS; j++) {
+                       struct urb *urb = usb_alloc_urb(0, GFP_KERNEL);
 
                        priv->write_urb_pool[j] = urb;
                        if (urb == NULL) {
@@ -293,10 +284,11 @@ static int klsi_105_startup (struct usb_serial *serial)
                                goto err_cleanup;
                        }
 
-                       urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE,
-                                                       GFP_KERNEL);
+                       urb->transfer_buffer =
+                               kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
                        if (!urb->transfer_buffer) {
-                               err("%s - out of memory for urb buffers.", __func__);
+                               err("%s - out of memory for urb buffers.",
+                                                               __func__);
                                goto err_cleanup;
                        }
                }
@@ -304,13 +296,13 @@ static int klsi_105_startup (struct usb_serial *serial)
                /* priv->termios is left uninitalized until port opening */
                init_waitqueue_head(&serial->port[i]->write_wait);
        }
-       
+
        return 0;
 
 err_cleanup:
        for (; i >= 0; i--) {
                priv = usb_get_serial_port_data(serial->port[i]);
-               for (j=0; j < NUM_URBS; j++) {
+               for (j = 0; j < NUM_URBS; j++) {
                        if (priv->write_urb_pool[j]) {
                                kfree(priv->write_urb_pool[j]->transfer_buffer);
                                usb_free_urb(priv->write_urb_pool[j]);
@@ -322,22 +314,23 @@ err_cleanup:
 } /* klsi_105_startup */
 
 
-static void klsi_105_shutdown (struct usb_serial *serial)
+static void klsi_105_shutdown(struct usb_serial *serial)
 {
        int i;
-       
+
        dbg("%s", __func__);
 
        /* stop reads and writes on all ports */
-       for (i=0; i < serial->num_ports; ++i) {
-               struct klsi_105_private *priv = usb_get_serial_port_data(serial->port[i]);
+       for (i = 0; i < serial->num_ports; ++i) {
+               struct klsi_105_private *priv =
+                               usb_get_serial_port_data(serial->port[i]);
                unsigned long flags;
 
                if (priv) {
                        /* kill our write urb pool */
                        int j;
                        struct urb **write_urbs = priv->write_urb_pool;
-                       spin_lock_irqsave(&priv->lock,flags);
+                       spin_lock_irqsave(&priv->lock, flags);
 
                        for (j = 0; j < NUM_URBS; j++) {
                                if (write_urbs[j]) {
@@ -349,19 +342,18 @@ static void klsi_105_shutdown (struct usb_serial *serial)
                                         * oopses. */
                                        /* usb_kill_urb(write_urbs[j]); */
                                        kfree(write_urbs[j]->transfer_buffer);
-                                       usb_free_urb (write_urbs[j]);
+                                       usb_free_urb(write_urbs[j]);
                                }
                        }
-
-                       spin_unlock_irqrestore (&priv->lock, flags);
-
+                       spin_unlock_irqrestore(&priv->lock, flags);
                        kfree(priv);
                        usb_set_serial_port_data(serial->port[i], NULL);
                }
        }
 } /* klsi_105_shutdown */
 
-static int  klsi_105_open (struct usb_serial_port *port, struct file *filp)
+static int  klsi_105_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct klsi_105_private *priv = usb_get_serial_port_data(port);
        int retval = 0;
@@ -375,11 +367,11 @@ static int  klsi_105_open (struct usb_serial_port *port, struct file *filp)
 
        /* force low_latency on so that our tty_push actually forces
         * the data through
-        * port->tty->low_latency = 1; */
+        * tty->low_latency = 1; */
 
        /* Do a defined restart:
         * Set up sane default baud rate and send the 'READ_ON'
-        * vendor command. 
+        * vendor command.
         * FIXME: set modem line control (how?)
         * Then read the modem line control and store values in
         * priv->line_state.
@@ -390,24 +382,24 @@ static int  klsi_105_open (struct usb_serial_port *port, struct file *filp)
        cfg.unknown1 = 0;
        cfg.unknown2 = 1;
        klsi_105_chg_port_settings(port, &cfg);
-       
+
        /* set up termios structure */
-       spin_lock_irqsave (&priv->lock, flags);
-       priv->termios.c_iflag = port->tty->termios->c_iflag;
-       priv->termios.c_oflag = port->tty->termios->c_oflag;
-       priv->termios.c_cflag = port->tty->termios->c_cflag;
-       priv->termios.c_lflag = port->tty->termios->c_lflag;
-       for (i=0; i<NCCS; i++)
-               priv->termios.c_cc[i] = port->tty->termios->c_cc[i];
+       spin_lock_irqsave(&priv->lock, flags);
+       priv->termios.c_iflag = tty->termios->c_iflag;
+       priv->termios.c_oflag = tty->termios->c_oflag;
+       priv->termios.c_cflag = tty->termios->c_cflag;
+       priv->termios.c_lflag = tty->termios->c_lflag;
+       for (i = 0; i < NCCS; i++)
+               priv->termios.c_cc[i] = tty->termios->c_cc[i];
        priv->cfg.pktlen   = cfg.pktlen;
        priv->cfg.baudrate = cfg.baudrate;
        priv->cfg.databits = cfg.databits;
        priv->cfg.unknown1 = cfg.unknown1;
        priv->cfg.unknown2 = cfg.unknown2;
-       spin_unlock_irqrestore (&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->lock, flags);
 
        /* READ_ON and urb submission */
-       usb_fill_bulk_urb(port->read_urb, port->serial->dev, 
+       usb_fill_bulk_urb(port->read_urb, port->serial->dev,
                      usb_rcvbulkpipe(port->serial->dev,
                                      port->bulk_in_endpointAddress),
                      port->read_urb->transfer_buffer,
@@ -423,7 +415,7 @@ static int  klsi_105_open (struct usb_serial_port *port, struct file *filp)
        }
 
        rc = usb_control_msg(port->serial->dev,
-                            usb_sndctrlpipe(port->serial->dev,0),
+                            usb_sndctrlpipe(port->serial->dev, 0),
                             KL5KUSB105A_SIO_CONFIGURE,
                             USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE,
                             KL5KUSB105A_SIO_CONFIGURE_READ_ON,
@@ -434,14 +426,14 @@ static int  klsi_105_open (struct usb_serial_port *port, struct file *filp)
        if (rc < 0) {
                err("Enabling read failed (error = %d)", rc);
                retval = rc;
-       } else 
+       } else
                dbg("%s - enabled reading", __func__);
 
        rc = klsi_105_get_line_state(port, &line_state);
        if (rc >= 0) {
-               spin_lock_irqsave (&priv->lock, flags);
+               spin_lock_irqsave(&priv->lock, flags);
                priv->line_state = line_state;
-               spin_unlock_irqrestore (&priv->lock, flags);
+               spin_unlock_irqrestore(&priv->lock, flags);
                dbg("%s - read line state 0x%lx", __func__, line_state);
                retval = 0;
        } else
@@ -452,7 +444,8 @@ exit:
 } /* klsi_105_open */
 
 
-static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
+static void klsi_105_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct klsi_105_private *priv = usb_get_serial_port_data(port);
        int rc;
@@ -462,14 +455,14 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
        mutex_lock(&port->serial->disc_mutex);
        if (!port->serial->disconnected) {
                /* send READ_OFF */
-               rc = usb_control_msg (port->serial->dev,
-                                     usb_sndctrlpipe(port->serial->dev, 0),
-                                     KL5KUSB105A_SIO_CONFIGURE,
-                                     USB_TYPE_VENDOR | USB_DIR_OUT,
-                                     KL5KUSB105A_SIO_CONFIGURE_READ_OFF,
-                                     0, /* index */
-                                     NULL, 0,
-                                     KLSI_TIMEOUT);
+               rc = usb_control_msg(port->serial->dev,
+                                    usb_sndctrlpipe(port->serial->dev, 0),
+                                    KL5KUSB105A_SIO_CONFIGURE,
+                                    USB_TYPE_VENDOR | USB_DIR_OUT,
+                                    KL5KUSB105A_SIO_CONFIGURE_READ_OFF,
+                                    0, /* index */
+                                    NULL, 0,
+                                    KLSI_TIMEOUT);
                if (rc < 0)
                        err("Disabling read failed (error = %d)", rc);
        }
@@ -482,23 +475,24 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
        /* FIXME */
        /* wgg - do I need this? I think so. */
        usb_kill_urb(port->interrupt_in_urb);
-       info("kl5kusb105 port stats: %ld bytes in, %ld bytes out", priv->bytes_in, priv->bytes_out);
+       info("kl5kusb105 port stats: %ld bytes in, %ld bytes out",
+                                       priv->bytes_in, priv->bytes_out);
 } /* klsi_105_close */
 
 
 /* We need to write a complete 64-byte data block and encode the
- * number actually sent in the first double-byte, LSB-order. That 
+ * number actually sent in the first double-byte, LSB-order. That
  * leaves at most 62 bytes of payload.
  */
 #define KLSI_105_DATA_OFFSET   2   /* in the bulk urb data block */
 
 
-static int klsi_105_write (struct usb_serial_port *port,
-                          const unsigned char *buf, int count)
+static int klsi_105_write(struct tty_struct *tty,
+       struct usb_serial_port *port, const unsigned char *buf, int count)
 {
        struct klsi_105_private *priv = usb_get_serial_port_data(port);
        int result, size;
-       int bytes_sent=0;
+       int bytes_sent = 0;
 
        dbg("%s - port %d", __func__, port->number);
 
@@ -507,34 +501,37 @@ static int klsi_105_write (struct usb_serial_port *port,
                struct urb *urb = NULL;
                unsigned long flags;
                int i;
-               /* since the pool is per-port we might not need the spin lock !? */
-               spin_lock_irqsave (&priv->lock, flags);
-               for (i=0; i<NUM_URBS; i++) {
+               /* since the pool is per-port we might not need
+                  the spin lock !? */
+               spin_lock_irqsave(&priv->lock, flags);
+               for (i = 0; i < NUM_URBS; i++) {
                        if (priv->write_urb_pool[i]->status != -EINPROGRESS) {
                                urb = priv->write_urb_pool[i];
                                dbg("%s - using pool URB %d", __func__, i);
                                break;
                        }
                }
-               spin_unlock_irqrestore (&priv->lock, flags);
+               spin_unlock_irqrestore(&priv->lock, flags);
 
-               if (urb==NULL) {
+               if (urb == NULL) {
                        dbg("%s - no more free urbs", __func__);
                        goto exit;
                }
 
                if (urb->transfer_buffer == NULL) {
-                       urb->transfer_buffer = kmalloc (URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC);
+                       urb->transfer_buffer =
+                               kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_ATOMIC);
                        if (urb->transfer_buffer == NULL) {
                                err("%s - no more kernel memory...", __func__);
                                goto exit;
                        }
                }
 
-               size = min (count, port->bulk_out_size - KLSI_105_DATA_OFFSET);
-               size = min (size, URB_TRANSFER_BUFFER_SIZE - KLSI_105_DATA_OFFSET);
+               size = min(count, port->bulk_out_size - KLSI_105_DATA_OFFSET);
+               size = min(size, URB_TRANSFER_BUFFER_SIZE -
+                                                       KLSI_105_DATA_OFFSET);
 
-               memcpy (urb->transfer_buffer + KLSI_105_DATA_OFFSET, buf, size);
+               memcpy(urb->transfer_buffer + KLSI_105_DATA_OFFSET, buf, size);
 
                /* write payload size into transfer buffer */
                ((__u8 *)urb->transfer_buffer)[0] = (__u8) (size & 0xFF);
@@ -552,7 +549,8 @@ static int klsi_105_write (struct usb_serial_port *port,
                /* send the data out the bulk port */
                result = usb_submit_urb(urb, GFP_ATOMIC);
                if (result) {
-                       err("%s - failed submitting write urb, error %d", __func__, result);
+                       err("%s - failed submitting write urb, error %d",
+                                                       __func__, result);
                        goto exit;
                }
                buf += size;
@@ -561,12 +559,12 @@ static int klsi_105_write (struct usb_serial_port *port,
        }
 exit:
        /* lockless, but it's for debug info only... */
-       priv->bytes_out+=bytes_sent;
+       priv->bytes_out += bytes_sent;
 
        return bytes_sent;      /* that's how much we wrote */
 } /* klsi_105_write */
 
-static void klsi_105_write_bulk_callback ( struct urb *urb)
+static void klsi_105_write_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        int status = urb->status;
@@ -584,50 +582,50 @@ static void klsi_105_write_bulk_callback ( struct urb *urb)
 
 
 /* return number of characters currently in the writing process */
-static int klsi_105_chars_in_buffer (struct usb_serial_port *port)
+static int klsi_105_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        int chars = 0;
        int i;
        unsigned long flags;
        struct klsi_105_private *priv = usb_get_serial_port_data(port);
 
-       spin_lock_irqsave (&priv->lock, flags);
+       spin_lock_irqsave(&priv->lock, flags);
 
        for (i = 0; i < NUM_URBS; ++i) {
-               if (priv->write_urb_pool[i]->status == -EINPROGRESS) {
+               if (priv->write_urb_pool[i]->status == -EINPROGRESS)
                        chars += URB_TRANSFER_BUFFER_SIZE;
-               }
        }
 
-       spin_unlock_irqrestore (&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->lock, flags);
 
        dbg("%s - returns %d", __func__, chars);
-       return (chars);
+       return chars;
 }
 
-static int klsi_105_write_room (struct usb_serial_port *port)
+static int klsi_105_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        unsigned long flags;
        int i;
        int room = 0;
        struct klsi_105_private *priv = usb_get_serial_port_data(port);
 
-       spin_lock_irqsave (&priv->lock, flags);
+       spin_lock_irqsave(&priv->lock, flags);
        for (i = 0; i < NUM_URBS; ++i) {
-               if (priv->write_urb_pool[i]->status != -EINPROGRESS) {
+               if (priv->write_urb_pool[i]->status != -EINPROGRESS)
                        room += URB_TRANSFER_BUFFER_SIZE;
-               }
        }
 
-       spin_unlock_irqrestore (&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->lock, flags);
 
        dbg("%s - returns %d", __func__, room);
-       return (room);
+       return room;
 }
 
 
 
-static void klsi_105_read_bulk_callback (struct urb *urb)
+static void klsi_105_read_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        struct klsi_105_private *priv = usb_get_serial_port_data(port);
@@ -660,13 +658,13 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
        } else {
                int bytes_sent = ((__u8 *) data)[0] +
                                 ((unsigned int) ((__u8 *) data)[1] << 8);
-               tty = port->tty;
+               tty = port->port.tty;
                /* we should immediately resubmit the URB, before attempting
                 * to pass the data on to the tty layer. But that needs locking
                 * against re-entry an then mixed-up data because of
                 * intermixed tty_flip_buffer_push()s
                 * FIXME
-                */ 
+                */
                usb_serial_debug_data(debug, &port->dev, __func__,
                                      urb->actual_length, data);
 
@@ -686,7 +684,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
                priv->bytes_in += bytes_sent;
        }
        /* Continue trying to always read  */
-       usb_fill_bulk_urb(port->read_urb, port->serial->dev, 
+       usb_fill_bulk_urb(port->read_urb, port->serial->dev,
                      usb_rcvbulkpipe(port->serial->dev,
                                      port->bulk_in_endpointAddress),
                      port->read_urb->transfer_buffer,
@@ -695,15 +693,16 @@ static void klsi_105_read_bulk_callback (struct urb *urb)
                      port);
        rc = usb_submit_urb(port->read_urb, GFP_ATOMIC);
        if (rc)
-               err("%s - failed resubmitting read urb, error %d", __func__, rc);
+               err("%s - failed resubmitting read urb, error %d",
+                                                       __func__, rc);
 } /* klsi_105_read_bulk_callback */
 
 
-static void klsi_105_set_termios (struct usb_serial_port *port,
-                                 struct ktermios *old_termios)
+static void klsi_105_set_termios(struct tty_struct *tty,
+                                struct usb_serial_port *port,
+                                struct ktermios *old_termios)
 {
        struct klsi_105_private *priv = usb_get_serial_port_data(port);
-       struct tty_struct *tty = port->tty;
        unsigned int iflag = tty->termios->c_iflag;
        unsigned int old_iflag = old_termios->c_iflag;
        unsigned int cflag = tty->termios->c_cflag;
@@ -711,65 +710,63 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
        struct klsi_105_port_settings cfg;
        unsigned long flags;
        speed_t baud;
-       
+
        /* lock while we are modifying the settings */
-       spin_lock_irqsave (&priv->lock, flags);
-       
+       spin_lock_irqsave(&priv->lock, flags);
+
        /*
         * Update baud rate
         */
        baud = tty_get_baud_rate(tty);
 
-       if( (cflag & CBAUD) != (old_cflag & CBAUD) ) {
-               /* reassert DTR and (maybe) RTS on transition from B0 */
-               if( (old_cflag & CBAUD) == B0 ) {
+       if ((cflag & CBAUD) != (old_cflag & CBAUD)) {
+               /* reassert DTR and (maybe) RTS on transition from B0 */
+               if ((old_cflag & CBAUD) == B0) {
                        dbg("%s: baud was B0", __func__);
 #if 0
                        priv->control_state |= TIOCM_DTR;
                        /* don't set RTS if using hardware flow control */
-                       if (!(old_cflag & CRTSCTS)) {
+                       if (!(old_cflag & CRTSCTS))
                                priv->control_state |= TIOCM_RTS;
-                       }
                        mct_u232_set_modem_ctrl(serial, priv->control_state);
 #endif
                }
        }
-       switch(baud) {
-               case 0: /* handled below */
-                       break;
-               case 1200:
-                       priv->cfg.baudrate = kl5kusb105a_sio_b1200;
-                       break;
-               case 2400:
-                       priv->cfg.baudrate = kl5kusb105a_sio_b2400;
-                       break;
-               case 4800:
-                       priv->cfg.baudrate = kl5kusb105a_sio_b4800;
-                       break;
-               case 9600:
-                       priv->cfg.baudrate = kl5kusb105a_sio_b9600;
-                       break;
-               case 19200:
-                       priv->cfg.baudrate = kl5kusb105a_sio_b19200;
-                       break;
-               case 38400:
-                       priv->cfg.baudrate = kl5kusb105a_sio_b38400;
-                       break;
-               case 57600:
-                       priv->cfg.baudrate = kl5kusb105a_sio_b57600;
-                       break;
-               case 115200:
-                       priv->cfg.baudrate = kl5kusb105a_sio_b115200;
-                       break;
-               default:
-                       dbg("KLSI USB->Serial converter:"
-                           " unsupported baudrate request, using default"
-                           " of 9600");
+       switch (baud) {
+       case 0: /* handled below */
+               break;
+       case 1200:
+               priv->cfg.baudrate = kl5kusb105a_sio_b1200;
+               break;
+       case 2400:
+               priv->cfg.baudrate = kl5kusb105a_sio_b2400;
+               break;
+       case 4800:
+               priv->cfg.baudrate = kl5kusb105a_sio_b4800;
+               break;
+       case 9600:
+               priv->cfg.baudrate = kl5kusb105a_sio_b9600;
+               break;
+       case 19200:
+               priv->cfg.baudrate = kl5kusb105a_sio_b19200;
+               break;
+       case 38400:
+               priv->cfg.baudrate = kl5kusb105a_sio_b38400;
+               break;
+       case 57600:
+               priv->cfg.baudrate = kl5kusb105a_sio_b57600;
+               break;
+       case 115200:
+               priv->cfg.baudrate = kl5kusb105a_sio_b115200;
+               break;
+       default:
+               dbg("KLSI USB->Serial converter:"
+                   " unsupported baudrate request, using default of 9600");
                        priv->cfg.baudrate = kl5kusb105a_sio_b9600;
-                       baud = 9600;
-                       break;
+               baud = 9600;
+               break;
        }
-       if ((cflag & CBAUD) == B0 ) {
+       if ((cflag & CBAUD) == B0) {
                dbg("%s: baud is B0", __func__);
                /* Drop RTS and DTR */
                /* maybe this should be simulated by sending read
@@ -778,7 +775,7 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
                ;
 #if 0
                priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
-                       mct_u232_set_modem_ctrl(serial, priv->control_state);
+               mct_u232_set_modem_ctrl(serial, priv->control_state);
 #endif
        }
        tty_encode_baud_rate(tty, baud, baud);
@@ -788,11 +785,11 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
                switch (cflag & CSIZE) {
                case CS5:
                        dbg("%s - 5 bits/byte not supported", __func__);
-                       spin_unlock_irqrestore (&priv->lock, flags);
+                       spin_unlock_irqrestore(&priv->lock, flags);
                        return ;
                case CS6:
                        dbg("%s - 6 bits/byte not supported", __func__);
-                       spin_unlock_irqrestore (&priv->lock, flags);
+                       spin_unlock_irqrestore(&priv->lock, flags);
                        return ;
                case CS7:
                        priv->cfg.databits = kl5kusb105a_dtb_7;
@@ -811,8 +808,7 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
         * Update line control register (LCR)
         */
        if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))
-           || (cflag & CSTOPB) != (old_cflag & CSTOPB) ) {
-               
+           || (cflag & CSTOPB) != (old_cflag & CSTOPB)) {
                /* Not currently supported */
                tty->termios->c_cflag &= ~(PARENB|PARODD|CSTOPB);
 #if 0
@@ -833,20 +829,18 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
 #endif
                ;
        }
-       
        /*
         * Set flow control: well, I do not really now how to handle DTR/RTS.
         * Just do what we have seen with SniffUSB on Win98.
         */
-       if(iflag & IXOFF) != (old_iflag & IXOFF)
+       if ((iflag & IXOFF) != (old_iflag & IXOFF)
            || (iflag & IXON) != (old_iflag & IXON)
-           ||  (cflag & CRTSCTS) != (old_cflag & CRTSCTS) ) {
-               
+           ||  (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) {
                /* Not currently supported */
                tty->termios->c_cflag &= ~CRTSCTS;
                /* Drop DTR/RTS if no flow control otherwise assert */
 #if 0
-               if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS) )
+               if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS))
                        priv->control_state |= TIOCM_DTR | TIOCM_RTS;
                else
                        priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
@@ -854,19 +848,21 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
 #endif
                ;
        }
-       memcpy (&cfg, &priv->cfg, sizeof(cfg));
-       spin_unlock_irqrestore (&priv->lock, flags);
-       
+       memcpy(&cfg, &priv->cfg, sizeof(cfg));
+       spin_unlock_irqrestore(&priv->lock, flags);
+
        /* now commit changes to device */
        klsi_105_chg_port_settings(port, &cfg);
 } /* klsi_105_set_termios */
 
 
 #if 0
-static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
+static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
-       struct mct_u232_private *priv = (struct mct_u232_private *)port->private;
+       struct mct_u232_private *priv =
+                               (struct mct_u232_private *)port->private;
        unsigned char lcr = priv->last_lcr;
 
        dbg("%sstate=%d", __func__, break_state);
@@ -878,8 +874,9 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
 } /* mct_u232_break_ctl */
 #endif
 
-static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file)
+static int klsi_105_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct klsi_105_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
        int rc;
@@ -893,18 +890,18 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file)
                return rc;
        }
 
-       spin_lock_irqsave (&priv->lock, flags);
+       spin_lock_irqsave(&priv->lock, flags);
        priv->line_state = line_state;
-       spin_unlock_irqrestore (&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->lock, flags);
        dbg("%s - read line state 0x%lx", __func__, line_state);
        return (int)line_state;
 }
 
-static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file,
-                             unsigned int set, unsigned int clear)
+static int klsi_105_tiocmset(struct tty_struct *tty, struct file *file,
+                            unsigned int set, unsigned int clear)
 {
        int retval = -EINVAL;
-       
+
        dbg("%s", __func__);
 
 /* if this ever gets implemented, it should be done something like this:
@@ -929,14 +926,16 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file,
        return retval;
 }
 
-static void klsi_105_throttle (struct usb_serial_port *port)
+static void klsi_105_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        dbg("%s - port %d", __func__, port->number);
        usb_kill_urb(port->read_urb);
 }
 
-static void klsi_105_unthrottle (struct usb_serial_port *port)
+static void klsi_105_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        int result;
 
        dbg("%s - port %d", __func__, port->number);
@@ -950,7 +949,7 @@ static void klsi_105_unthrottle (struct usb_serial_port *port)
 
 
 
-static int __init klsi_105_init (void)
+static int __init klsi_105_init(void)
 {
        int retval;
        retval = usb_serial_register(&kl5kusb105d_device);
@@ -969,19 +968,19 @@ failed_usb_serial_register:
 }
 
 
-static void __exit klsi_105_exit (void)
+static void __exit klsi_105_exit(void)
 {
-       usb_deregister (&kl5kusb105d_driver);
-       usb_serial_deregister (&kl5kusb105d_device);
+       usb_deregister(&kl5kusb105d_driver);
+       usb_serial_deregister(&kl5kusb105d_device);
 }
 
 
-module_init (klsi_105_init);
-module_exit (klsi_105_exit);
+module_init(klsi_105_init);
+module_exit(klsi_105_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
-MODULE_LICENSE("GPL"); 
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
 
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index 693f00d..deba28e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  KOBIL USB Smart Card Terminal Driver
  *
- *  Copyright (C) 2002  KOBIL Systems GmbH 
+ *  Copyright (C) 2002  KOBIL Systems GmbH
  *  Author: Thomas Wahrenbruch
  *
  *  Contact: linuxusb@kobil.de
@@ -20,7 +20,7 @@
  *
  * Supported readers: USB TWIN, KAAN Standard Plus and SecOVID Reader Plus
  * (Adapter K), B1 Professional and KAAN Professional (Adapter B)
- * 
+ *
  * (21/05/2004) tw
  *      Fix bug with P'n'P readers
  *
@@ -44,7 +44,7 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include <linux/ioctl.h>
@@ -68,21 +68,24 @@ static int debug;
 
 
 /* Function prototypes */
-static int  kobil_startup (struct usb_serial *serial);
-static void kobil_shutdown (struct usb_serial *serial);
-static int  kobil_open (struct usb_serial_port *port, struct file *filp);
-static void kobil_close (struct usb_serial_port *port, struct file *filp);
-static int  kobil_write (struct usb_serial_port *port, 
+static int  kobil_startup(struct usb_serial *serial);
+static void kobil_shutdown(struct usb_serial *serial);
+static int  kobil_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void kobil_close(struct tty_struct *tty, struct usb_serial_port *port,
+                       struct file *filp);
+static int  kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
                         const unsigned char *buf, int count);
-static int  kobil_write_room(struct usb_serial_port *port);
-static int  kobil_ioctl(struct usb_serial_port *port, struct file *file,
+static int  kobil_write_room(struct tty_struct *tty);
+static int  kobil_ioctl(struct tty_struct *tty, struct file *file,
                        unsigned int cmd, unsigned long arg);
-static int  kobil_tiocmget(struct usb_serial_port *port, struct file *file);
-static int  kobil_tiocmset(struct usb_serial_port *port, struct file *file,
+static int  kobil_tiocmget(struct tty_struct *tty, struct file *file);
+static int  kobil_tiocmset(struct tty_struct *tty, struct file *file,
                           unsigned int set, unsigned int clear);
-static void kobil_read_int_callback( struct urb *urb );
-static void kobil_write_callback( struct urb *purb );
-static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old);
+static void kobil_read_int_callback(struct urb *urb);
+static void kobil_write_callback(struct urb *purb);
+static void kobil_set_termios(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct ktermios *old);
 
 
 static struct usb_device_id id_table [] = {
@@ -94,7 +97,7 @@ static struct usb_device_id id_table [] = {
 };
 
 
-MODULE_DEVICE_TABLE (usb, id_table);
+MODULE_DEVICE_TABLE(usb, id_table);
 
 static struct usb_driver kobil_driver = {
        .name =         "kobil",
@@ -131,14 +134,14 @@ static struct usb_serial_driver kobil_device = {
 struct kobil_private {
        int write_int_endpoint_address;
        int read_int_endpoint_address;
-       unsigned char buf[KOBIL_BUF_LENGTH]; // buffer for the APDU to send
-       int filled;  // index of the last char in buf
-       int cur_pos; // index of the next char to send in buf
+       unsigned char buf[KOBIL_BUF_LENGTH]; /* buffer for the APDU to send */
+       int filled;  /* index of the last char in buf */
+       int cur_pos; /* index of the next char to send in buf */
        __u16 device_type;
 };
 
 
-static int kobil_startup (struct usb_serial *serial)
+static int kobil_startup(struct usb_serial *serial)
 {
        int i;
        struct kobil_private *priv;
@@ -149,20 +152,20 @@ static int kobil_startup (struct usb_serial *serial)
        struct usb_host_endpoint *endpoint;
 
        priv = kmalloc(sizeof(struct kobil_private), GFP_KERNEL);
-       if (!priv){
+       if (!priv)
                return -ENOMEM;
-       }
 
        priv->filled = 0;
        priv->cur_pos = 0;
        priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct);
 
-       switch (priv->device_type){
+       switch (priv->device_type) {
        case KOBIL_ADAPTER_B_PRODUCT_ID:
                printk(KERN_DEBUG "KOBIL B1 PRO / KAAN PRO detected\n");
                break;
        case KOBIL_ADAPTER_K_PRODUCT_ID:
-               printk(KERN_DEBUG "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected\n");
+               printk(KERN_DEBUG
+                 "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected\n");
                break;
        case KOBIL_USBTWIN_PRODUCT_ID:
                printk(KERN_DEBUG "KOBIL USBTWIN detected\n");
@@ -173,44 +176,48 @@ static int kobil_startup (struct usb_serial *serial)
        }
        usb_set_serial_port_data(serial->port[0], priv);
 
-       // search for the necessary endpoints
+       /* search for the necessary endpoints */
        pdev = serial->dev;
-       actconfig = pdev->actconfig;
-       interface = actconfig->interface[0];
+       actconfig = pdev->actconfig;
+       interface = actconfig->interface[0];
        altsetting = interface->cur_altsetting;
-       endpoint = altsetting->endpoint;
-  
-       for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
+       endpoint = altsetting->endpoint;
+
+       for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
                endpoint = &altsetting->endpoint[i];
                if (usb_endpoint_is_int_out(&endpoint->desc)) {
-                       dbg("%s Found interrupt out endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress);
-                       priv->write_int_endpoint_address = endpoint->desc.bEndpointAddress;
-               }
+                       dbg("%s Found interrupt out endpoint. Address: %d",
+                               __func__, endpoint->desc.bEndpointAddress);
+                       priv->write_int_endpoint_address =
+                               endpoint->desc.bEndpointAddress;
+               }
                if (usb_endpoint_is_int_in(&endpoint->desc)) {
-                       dbg("%s Found interrupt in  endpoint. Address: %d", __func__, endpoint->desc.bEndpointAddress);
-                       priv->read_int_endpoint_address = endpoint->desc.bEndpointAddress;
-               }
+                       dbg("%s Found interrupt in  endpoint. Address: %d",
+                               __func__, endpoint->desc.bEndpointAddress);
+                       priv->read_int_endpoint_address =
+                               endpoint->desc.bEndpointAddress;
+               }
        }
        return 0;
 }
 
 
-static void kobil_shutdown (struct usb_serial *serial)
+static void kobil_shutdown(struct usb_serial *serial)
 {
        int i;
        dbg("%s - port %d", __func__, serial->port[0]->number);
 
-       for (i=0; i < serial->num_ports; ++i) {
-               while (serial->port[i]->open_count > 0) {
-                       kobil_close (serial->port[i], NULL);
-               }
+       for (i = 0; i < serial->num_ports; ++i) {
+               while (serial->port[i]->port.count > 0)
+                       kobil_close(NULL, serial->port[i], NULL);
                kfree(usb_get_serial_port_data(serial->port[i]));
                usb_set_serial_port_data(serial->port[i], NULL);
        }
 }
 
 
-static int kobil_open (struct usb_serial_port *port, struct file *filp)
+static int kobil_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        int result = 0;
        struct kobil_private *priv;
@@ -221,7 +228,7 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
        dbg("%s - port %d", __func__, port->number);
        priv = usb_get_serial_port_data(port);
 
-       // someone sets the dev to 0 if the close method has been called
+       /* someone sets the dev to 0 if the close method has been called */
        port->interrupt_in_urb->dev = port->serial->dev;
 
 
@@ -229,100 +236,115 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
         * the data through, otherwise it is scheduled, and with high
         * data rates (like with OHCI) data can get lost.
         */
-       port->tty->low_latency = 1;
-
-       // without this, every push_tty_char is echoed :-(  
-       port->tty->termios->c_lflag = 0;
-       port->tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN | XCASE);
-       port->tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF;
-       port->tty->termios->c_oflag &= ~ONLCR; // do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D)
-       
-       // allocate memory for transfer buffer
+       if (tty) {
+               tty->low_latency = 1;
+
+               /* Default to echo off and other sane device settings */
+               tty->termios->c_lflag = 0;
+               tty->termios->c_lflag &= ~(ISIG | ICANON | ECHO | IEXTEN |
+                                                                XCASE);
+               tty->termios->c_iflag = IGNBRK | IGNPAR | IXOFF;
+               /* do NOT translate CR to CR-NL (0x0A -> 0x0A 0x0D) */
+               tty->termios->c_oflag &= ~ONLCR;
+       }
+       /* allocate memory for transfer buffer */
        transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
-       if (! transfer_buffer) {
+       if (!transfer_buffer)
                return -ENOMEM;
-       }
-       
-       // allocate write_urb
-       if (!port->write_urb) { 
-               dbg("%s - port %d  Allocating port->write_urb", __func__, port->number);
-               port->write_urb = usb_alloc_urb(0, GFP_KERNEL);  
+
+       /* allocate write_urb */
+       if (!port->write_urb) {
+               dbg("%s - port %d  Allocating port->write_urb",
+                                               __func__, port->number);
+               port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
                if (!port->write_urb) {
-                       dbg("%s - port %d usb_alloc_urb failed", __func__, port->number);
+                       dbg("%s - port %d usb_alloc_urb failed",
+                                               __func__, port->number);
                        kfree(transfer_buffer);
                        return -ENOMEM;
                }
        }
 
-       // allocate memory for write_urb transfer buffer
-       port->write_urb->transfer_buffer = kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL);
-       if (! port->write_urb->transfer_buffer) {
+       /* allocate memory for write_urb transfer buffer */
+       port->write_urb->transfer_buffer =
+                       kmalloc(write_urb_transfer_buffer_length, GFP_KERNEL);
+       if (!port->write_urb->transfer_buffer) {
                kfree(transfer_buffer);
                usb_free_urb(port->write_urb);
                port->write_urb = NULL;
                return -ENOMEM;
-       } 
-
-       // get hardware version
-       result = usb_control_msg( port->serial->dev, 
-                                 usb_rcvctrlpipe(port->serial->dev, 0 ), 
-                                 SUSBCRequest_GetMisc,
-                                 USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
-                                 SUSBCR_MSC_GetHWVersion,
-                                 0,
-                                 transfer_buffer,
-                                 transfer_buffer_length,
-                                 KOBIL_TIMEOUT
+       }
+
+       /* get hardware version */
+       result = usb_control_msg(port->serial->dev,
+                         usb_rcvctrlpipe(port->serial->dev, 0),
+                         SUSBCRequest_GetMisc,
+                         USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
+                         SUSBCR_MSC_GetHWVersion,
+                         0,
+                         transfer_buffer,
+                         transfer_buffer_length,
+                         KOBIL_TIMEOUT
+       );
+       dbg("%s - port %d Send get_HW_version URB returns: %i",
+               __func__, port->number, result);
+       dbg("Harware version: %i.%i.%i",
+               transfer_buffer[0], transfer_buffer[1], transfer_buffer[2]);
+
+       /* get firmware version */
+       result = usb_control_msg(port->serial->dev,
+                         usb_rcvctrlpipe(port->serial->dev, 0),
+                         SUSBCRequest_GetMisc,
+                         USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
+                         SUSBCR_MSC_GetFWVersion,
+                         0,
+                         transfer_buffer,
+                         transfer_buffer_length,
+                         KOBIL_TIMEOUT
+       );
+       dbg("%s - port %d Send get_FW_version URB returns: %i",
+                                       __func__, port->number, result);
+       dbg("Firmware version: %i.%i.%i",
+               transfer_buffer[0], transfer_buffer[1], transfer_buffer[2]);
+
+       if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
+                       priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) {
+               /* Setting Baudrate, Parity and Stopbits */
+               result = usb_control_msg(port->serial->dev,
+                         usb_rcvctrlpipe(port->serial->dev, 0),
+                         SUSBCRequest_SetBaudRateParityAndStopBits,
+                         USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
+                         SUSBCR_SBR_9600 | SUSBCR_SPASB_EvenParity |
+                                                       SUSBCR_SPASB_1StopBit,
+                         0,
+                         transfer_buffer,
+                         0,
+                         KOBIL_TIMEOUT
                );
-       dbg("%s - port %d Send get_HW_version URB returns: %i", __func__, port->number, result);
-       dbg("Harware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] );
-       
-       // get firmware version
-       result = usb_control_msg( port->serial->dev, 
-                                 usb_rcvctrlpipe(port->serial->dev, 0 ), 
-                                 SUSBCRequest_GetMisc,
-                                 USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
-                                 SUSBCR_MSC_GetFWVersion,
-                                 0,
-                                 transfer_buffer,
-                                 transfer_buffer_length,
-                                 KOBIL_TIMEOUT
+               dbg("%s - port %d Send set_baudrate URB returns: %i",
+                                       __func__, port->number, result);
+
+               /* reset all queues */
+               result = usb_control_msg(port->serial->dev,
+                         usb_rcvctrlpipe(port->serial->dev, 0),
+                         SUSBCRequest_Misc,
+                         USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
+                         SUSBCR_MSC_ResetAllQueues,
+                         0,
+                         transfer_buffer,
+                         0,
+                         KOBIL_TIMEOUT
                );
-       dbg("%s - port %d Send get_FW_version URB returns: %i", __func__, port->number, result);
-       dbg("Firmware version: %i.%i.%i", transfer_buffer[0], transfer_buffer[1], transfer_buffer[2] );
-
-       if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) {
-               // Setting Baudrate, Parity and Stopbits
-               result = usb_control_msg( port->serial->dev, 
-                                         usb_rcvctrlpipe(port->serial->dev, 0 ), 
-                                         SUSBCRequest_SetBaudRateParityAndStopBits,
-                                         USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
-                                         SUSBCR_SBR_9600 | SUSBCR_SPASB_EvenParity | SUSBCR_SPASB_1StopBit,
-                                         0,
-                                         transfer_buffer,
-                                         0,
-                                         KOBIL_TIMEOUT
-                       );
-               dbg("%s - port %d Send set_baudrate URB returns: %i", __func__, port->number, result);
-               
-               // reset all queues
-               result = usb_control_msg( port->serial->dev, 
-                                         usb_rcvctrlpipe(port->serial->dev, 0 ), 
-                                         SUSBCRequest_Misc,
-                                         USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
-                                         SUSBCR_MSC_ResetAllQueues,
-                                         0,
-                                         transfer_buffer,
-                                         0,
-                                         KOBIL_TIMEOUT
-                       );
-               dbg("%s - port %d Send reset_all_queues URB returns: %i", __func__, port->number, result);
+               dbg("%s - port %d Send reset_all_queues URB returns: %i",
+                                       __func__, port->number, result);
        }
-       if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
+       if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID ||
+           priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
            priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) {
-               // start reading (Adapter B 'cause PNP string)
-               result = usb_submit_urb( port->interrupt_in_urb, GFP_ATOMIC  ); 
-               dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result);
+               /* start reading (Adapter B 'cause PNP string) */
+               result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
+               dbg("%s - port %d Send read URB returns: %i",
+                                       __func__, port->number, result);
        }
 
        kfree(transfer_buffer);
@@ -330,13 +352,14 @@ static int kobil_open (struct usb_serial_port *port, struct file *filp)
 }
 
 
-static void kobil_close (struct usb_serial_port *port, struct file *filp)
+static void kobil_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        dbg("%s - port %d", __func__, port->number);
 
        if (port->write_urb) {
                usb_kill_urb(port->write_urb);
-               usb_free_urb( port->write_urb );
+               usb_free_urb(port->write_urb);
                port->write_urb = NULL;
        }
        usb_kill_urb(port->interrupt_in_urb);
@@ -350,7 +373,7 @@ static void kobil_read_int_callback(struct urb *urb)
        struct tty_struct *tty;
        unsigned char *data = urb->transfer_buffer;
        int status = urb->status;
-//     char *dbg_data;
+/*     char *dbg_data; */
 
        dbg("%s - port %d", __func__, port->number);
 
@@ -360,51 +383,53 @@ static void kobil_read_int_callback(struct urb *urb)
                return;
        }
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (urb->actual_length) {
 
-               // BEGIN DEBUG
+               /* BEGIN DEBUG */
                /*
-                 dbg_data = kzalloc((3 *  purb->actual_length + 10) * sizeof(char), GFP_KERNEL);
+                 dbg_data = kzalloc((3 *  purb->actual_length + 10)
+                                               * sizeof(char), GFP_KERNEL);
                  if (! dbg_data) {
-                 return;
+                         return;
                  }
-                 for (i = 0; i < purb->actual_length; i++) { 
-                 sprintf(dbg_data +3*i, "%02X ", data[i]); 
+                 for (i = 0; i < purb->actual_length; i++) {
+                         sprintf(dbg_data +3*i, "%02X ", data[i]);
                  }
-                 dbg(" <-- %s", dbg_data );
+                 dbg(" <-- %s", dbg_data);
                  kfree(dbg_data);
                */
-               // END DEBUG
+               /* END DEBUG */
 
                tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
-
-       // someone sets the dev to 0 if the close method has been called
+       /* someone sets the dev to 0 if the close method has been called */
        port->interrupt_in_urb->dev = port->serial->dev;
 
        result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
-       dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result);
+       dbg("%s - port %d Send read URB returns: %i",
+                       __func__, port->number, result);
 }
 
 
-static void kobil_write_callback( struct urb *purb )
+static void kobil_write_callback(struct urb *purb)
 {
 }
 
 
-static int kobil_write (struct usb_serial_port *port, 
+static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
                        const unsigned char *buf, int count)
 {
        int length = 0;
        int result = 0;
        int todo = 0;
-       struct kobil_private * priv;
+       struct kobil_private *priv;
 
        if (count == 0) {
-               dbg("%s - port %d write request of 0 bytes", __func__, port->number);
+               dbg("%s - port %d write request of 0 bytes",
+                                               __func__, port->number);
                return 0;
        }
 
@@ -415,106 +440,113 @@ static int kobil_write (struct usb_serial_port *port,
                return -ENOMEM;
        }
 
-       // Copy data to buffer
-       memcpy (priv->buf + priv->filled, buf, count);
-
-       usb_serial_debug_data(debug, &port->dev, __func__, count, priv->buf + priv->filled);
-
+       /* Copy data to buffer */
+       memcpy(priv->buf + priv->filled, buf, count);
+       usb_serial_debug_data(debug, &port->dev, __func__, count,
+                                               priv->buf + priv->filled);
        priv->filled = priv->filled + count;
 
-
-       // only send complete block. TWIN, KAAN SIM and adapter K use the same protocol.
-       if ( ((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) || 
-            ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4))) ) {
-               
-               // stop reading (except TWIN and KAAN SIM)
-               if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) )
+       /* only send complete block. TWIN, KAAN SIM and adapter K
+          use the same protocol. */
+       if (((priv->device_type != KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 2) && (priv->filled >= (priv->buf[1] + 3))) ||
+            ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) && (priv->filled > 3) && (priv->filled >= (priv->buf[2] + 4)))) {
+               /* stop reading (except TWIN and KAAN SIM) */
+               if ((priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID)
+                       || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID))
                        usb_kill_urb(port->interrupt_in_urb);
 
                todo = priv->filled - priv->cur_pos;
 
-               while(todo > 0) {
-                       // max 8 byte in one urb (endpoint size)
+               while (todo > 0) {
+                       /* max 8 byte in one urb (endpoint size) */
                        length = (todo < 8) ? todo : 8;
-                       // copy data to transfer buffer
-                       memcpy(port->write_urb->transfer_buffer, priv->buf + priv->cur_pos, length );
-                       usb_fill_int_urb( port->write_urb,
-                                         port->serial->dev,
-                                         usb_sndintpipe(port->serial->dev, priv->write_int_endpoint_address),
-                                         port->write_urb->transfer_buffer,
-                                         length,
-                                         kobil_write_callback,
-                                         port,
-                                         8
-                               );
+                       /* copy data to transfer buffer */
+                       memcpy(port->write_urb->transfer_buffer,
+                                       priv->buf + priv->cur_pos, length);
+                       usb_fill_int_urb(port->write_urb,
+                                 port->serial->dev,
+                                 usb_sndintpipe(port->serial->dev,
+                                       priv->write_int_endpoint_address),
+                                 port->write_urb->transfer_buffer,
+                                 length,
+                                 kobil_write_callback,
+                                 port,
+                                 8
+                       );
 
                        priv->cur_pos = priv->cur_pos + length;
-                       result = usb_submit_urb( port->write_urb, GFP_NOIO );
-                       dbg("%s - port %d Send write URB returns: %i", __func__, port->number, result);
+                       result = usb_submit_urb(port->write_urb, GFP_NOIO);
+                       dbg("%s - port %d Send write URB returns: %i",
+                                       __func__, port->number, result);
                        todo = priv->filled - priv->cur_pos;
 
-                       if (todo > 0) {
+                       if (todo > 0)
                                msleep(24);
-                       }
+               }
 
-               } // end while
-               
                priv->filled = 0;
                priv->cur_pos = 0;
 
-               // someone sets the dev to 0 if the close method has been called
+               /* someone sets the dev to 0 if the close method
+                  has been called */
                port->interrupt_in_urb->dev = port->serial->dev;
-               
-               // start reading (except TWIN and KAAN SIM)
-               if ( (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) || (priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) ) {
-                       // someone sets the dev to 0 if the close method has been called
+
+               /* start reading (except TWIN and KAAN SIM) */
+               if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
+                       priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) {
+                       /* someone sets the dev to 0 if the close method has
+                          been called */
                        port->interrupt_in_urb->dev = port->serial->dev;
-                       
-                       result = usb_submit_urb( port->interrupt_in_urb, GFP_NOIO ); 
-                       dbg("%s - port %d Send read URB returns: %i", __func__, port->number, result);
+
+                       result = usb_submit_urb(port->interrupt_in_urb,
+                                                               GFP_NOIO);
+                       dbg("%s - port %d Send read URB returns: %i",
+                                       __func__, port->number, result);
                }
        }
        return count;
 }
 
 
-static int kobil_write_room (struct usb_serial_port *port)
+static int kobil_write_room(struct tty_struct *tty)
 {
-       //dbg("%s - port %d", __func__, port->number);
+       /* dbg("%s - port %d", __func__, port->number); */
+       /* FIXME */
        return 8;
 }
 
 
-static int kobil_tiocmget(struct usb_serial_port *port, struct file *file)
+static int kobil_tiocmget(struct tty_struct *tty, struct file *file)
 {
-       struct kobil_private * priv;
+       struct usb_serial_port *port = tty->driver_data;
+       struct kobil_private *priv;
        int result;
        unsigned char *transfer_buffer;
        int transfer_buffer_length = 8;
 
        priv = usb_get_serial_port_data(port);
-       if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) {
-               // This device doesn't support ioctl calls
+       if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID
+                       || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) {
+               /* This device doesn't support ioctl calls */
                return -EINVAL;
        }
 
-       // allocate memory for transfer buffer
+       /* allocate memory for transfer buffer */
        transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
-       if (!transfer_buffer) {
+       if (!transfer_buffer)
                return -ENOMEM;
-       }
 
-       result = usb_control_msg( port->serial->dev, 
-                                 usb_rcvctrlpipe(port->serial->dev, 0 ), 
-                                 SUSBCRequest_GetStatusLineState,
-                                 USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
-                                 0,
-                                 0,
-                                 transfer_buffer,
-                                 transfer_buffer_length,
-                                 KOBIL_TIMEOUT);
-
-       dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", 
+       result = usb_control_msg(port->serial->dev,
+                         usb_rcvctrlpipe(port->serial->dev, 0),
+                         SUSBCRequest_GetStatusLineState,
+                         USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_IN,
+                         0,
+                         0,
+                         transfer_buffer,
+                         transfer_buffer_length,
+                         KOBIL_TIMEOUT);
+
+       dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x",
            __func__, port->number, result, transfer_buffer[0]);
 
        result = 0;
@@ -524,10 +556,11 @@ static int kobil_tiocmget(struct usb_serial_port *port, struct file *file)
        return result;
 }
 
-static int  kobil_tiocmset(struct usb_serial_port *port, struct file *file,
+static int kobil_tiocmset(struct tty_struct *tty, struct file *file,
                           unsigned int set, unsigned int clear)
 {
-       struct kobil_private * priv;
+       struct usb_serial_port *port = tty->driver_data;
+       struct kobil_private *priv;
        int result;
        int dtr = 0;
        int rts = 0;
@@ -536,16 +569,16 @@ static int  kobil_tiocmset(struct usb_serial_port *port, struct file *file,
 
        /* FIXME: locking ? */
        priv = usb_get_serial_port_data(port);
-       if ((priv->device_type == KOBIL_USBTWIN_PRODUCT_ID) || (priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)) {
-               // This device doesn't support ioctl calls
+       if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID
+               || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) {
+               /* This device doesn't support ioctl calls */
                return -EINVAL;
        }
 
-       // allocate memory for transfer buffer
+       /* allocate memory for transfer buffer */
        transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
-       if (! transfer_buffer) {
+       if (!transfer_buffer)
                return -ENOMEM;
-       }
 
        if (set & TIOCM_RTS)
                rts = 1;
@@ -558,66 +591,77 @@ static int  kobil_tiocmset(struct usb_serial_port *port, struct file *file,
 
        if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) {
                if (dtr != 0)
-                       dbg("%s - port %d Setting DTR", __func__, port->number);
+                       dbg("%s - port %d Setting DTR",
+                                               __func__, port->number);
                else
-                       dbg("%s - port %d Clearing DTR", __func__, port->number);
-               result = usb_control_msg( port->serial->dev, 
-                                         usb_rcvctrlpipe(port->serial->dev, 0 ), 
-                                         SUSBCRequest_SetStatusLinesOrQueues,
-                                         USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
-                                         ((dtr != 0) ? SUSBCR_SSL_SETDTR : SUSBCR_SSL_CLRDTR),
-                                         0,
-                                         transfer_buffer,
-                                         0,
-                                         KOBIL_TIMEOUT);
+                       dbg("%s - port %d Clearing DTR",
+                                               __func__, port->number);
+               result = usb_control_msg(port->serial->dev,
+                         usb_rcvctrlpipe(port->serial->dev, 0),
+                         SUSBCRequest_SetStatusLinesOrQueues,
+                         USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
+                         ((dtr != 0) ? SUSBCR_SSL_SETDTR : SUSBCR_SSL_CLRDTR),
+                         0,
+                         transfer_buffer,
+                         0,
+                         KOBIL_TIMEOUT);
        } else {
                if (rts != 0)
-                       dbg("%s - port %d Setting RTS", __func__, port->number);
+                       dbg("%s - port %d Setting RTS",
+                                               __func__, port->number);
                else
-                       dbg("%s - port %d Clearing RTS", __func__, port->number);
-               result = usb_control_msg( port->serial->dev, 
-                                         usb_rcvctrlpipe(port->serial->dev, 0 ), 
-                                         SUSBCRequest_SetStatusLinesOrQueues,
-                                         USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
-                                         ((rts != 0) ? SUSBCR_SSL_SETRTS : SUSBCR_SSL_CLRRTS),
-                                         0,
-                                         transfer_buffer,
-                                         0,
-                                         KOBIL_TIMEOUT);
+                       dbg("%s - port %d Clearing RTS",
+                                               __func__, port->number);
+               result = usb_control_msg(port->serial->dev,
+                       usb_rcvctrlpipe(port->serial->dev, 0),
+                       SUSBCRequest_SetStatusLinesOrQueues,
+                       USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
+                       ((rts != 0) ? SUSBCR_SSL_SETRTS : SUSBCR_SSL_CLRRTS),
+                       0,
+                       transfer_buffer,
+                       0,
+                       KOBIL_TIMEOUT);
        }
-       dbg("%s - port %d Send set_status_line URB returns: %i", __func__, port->number, result);
+       dbg("%s - port %d Send set_status_line URB returns: %i",
+                                       __func__, port->number, result);
        kfree(transfer_buffer);
        return (result < 0) ? result : 0;
 }
 
-static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old)
+static void kobil_set_termios(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct ktermios *old)
 {
-       struct kobil_private * priv;
+       struct kobil_private *priv;
        int result;
        unsigned short urb_val = 0;
-       int c_cflag = port->tty->termios->c_cflag;
+       int c_cflag = tty->termios->c_cflag;
        speed_t speed;
-       void * settings;
+       void *settings;
 
        priv = usb_get_serial_port_data(port);
-       if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)
-               // This device doesn't support ioctl calls
+       if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID ||
+                       priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) {
+               /* This device doesn't support ioctl calls */
+               *tty->termios = *old;
                return;
+       }
 
-       switch (speed = tty_get_baud_rate(port->tty)) {
-               case 1200:
-                       urb_val = SUSBCR_SBR_1200;
-                       break;
-               default:
-                       speed = 9600;
-               case 9600:
-                       urb_val = SUSBCR_SBR_9600;
-                       break;
+       speed = tty_get_baud_rate(tty);
+       switch (speed) {
+       case 1200:
+               urb_val = SUSBCR_SBR_1200;
+               break;
+       default:
+               speed = 9600;
+       case 9600:
+               urb_val = SUSBCR_SBR_9600;
+               break;
        }
-       urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits : SUSBCR_SPASB_1StopBit;
+       urb_val |= (c_cflag & CSTOPB) ? SUSBCR_SPASB_2StopBits :
+                                                       SUSBCR_SPASB_1StopBit;
 
        settings = kzalloc(50, GFP_KERNEL);
-       if (! settings)
+       if (!settings)
                return;
 
        sprintf(settings, "%d ", speed);
@@ -634,66 +678,69 @@ static void kobil_set_termios(struct usb_serial_port *port, struct ktermios *old
                urb_val |= SUSBCR_SPASB_NoParity;
                strcat(settings, "No Parity");
        }
-       port->tty->termios->c_cflag &= ~CMSPAR;
-       tty_encode_baud_rate(port->tty, speed, speed);
-
-       result = usb_control_msg( port->serial->dev,
-                                 usb_rcvctrlpipe(port->serial->dev, 0 ),
-                                 SUSBCRequest_SetBaudRateParityAndStopBits,
-                                 USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
-                                 urb_val,
-                                 0,
-                                 settings,
-                                 0,
-                                 KOBIL_TIMEOUT
+       tty->termios->c_cflag &= ~CMSPAR;
+       tty_encode_baud_rate(tty, speed, speed);
+
+       result = usb_control_msg(port->serial->dev,
+                 usb_rcvctrlpipe(port->serial->dev, 0),
+                 SUSBCRequest_SetBaudRateParityAndStopBits,
+                 USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
+                 urb_val,
+                 0,
+                 settings,
+                 0,
+                 KOBIL_TIMEOUT
                );
        kfree(settings);
 }
 
-static int kobil_ioctl(struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+static int kobil_ioctl(struct tty_struct *tty, struct file *file,
+                                       unsigned int cmd, unsigned long arg)
 {
-       struct kobil_private * priv = usb_get_serial_port_data(port);
+       struct usb_serial_port *port = tty->driver_data;
+       struct kobil_private *priv = usb_get_serial_port_data(port);
        unsigned char *transfer_buffer;
        int transfer_buffer_length = 8;
        int result;
 
-       if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)
-               // This device doesn't support ioctl calls
-               return 0;
+       if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID ||
+                       priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID)
+               /* This device doesn't support ioctl calls */
+               return -ENOIOCTLCMD;
 
        switch (cmd) {
-       case TCFLSH:   // 0x540B
+       case TCFLSH:
                transfer_buffer = kmalloc(transfer_buffer_length, GFP_KERNEL);
-               if (! transfer_buffer)
-                       return -ENOBUFS;
-
-               result = usb_control_msg( port->serial->dev, 
-                                         usb_rcvctrlpipe(port->serial->dev, 0 ), 
-                                         SUSBCRequest_Misc,
-                                         USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
-                                         SUSBCR_MSC_ResetAllQueues,
-                                         0,
-                                         NULL,//transfer_buffer,
-                                         0,
-                                         KOBIL_TIMEOUT
+               if (!transfer_buffer)
+                       return -ENOBUFS;
+
+               result = usb_control_msg(port->serial->dev,
+                         usb_rcvctrlpipe(port->serial->dev, 0),
+                         SUSBCRequest_Misc,
+                         USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT,
+                         SUSBCR_MSC_ResetAllQueues,
+                         0,
+                         NULL, /* transfer_buffer, */
+                         0,
+                         KOBIL_TIMEOUT
                        );
-               
+
                dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result);
                kfree(transfer_buffer);
-               return (result < 0) ? -EFAULT : 0;
+               return (result < 0) ? -EIO: 0;
        default:
                return -ENOIOCTLCMD;
        }
 }
 
-static int __init kobil_init (void)
+static int __init kobil_init(void)
 {
        int retval;
        retval = usb_serial_register(&kobil_device);
        if (retval)
                goto failed_usb_serial_register;
        retval = usb_register(&kobil_driver);
-       if (retval) 
+       if (retval)
                goto failed_usb_register;
 
        info(DRIVER_VERSION " " DRIVER_AUTHOR);
@@ -707,18 +754,18 @@ failed_usb_serial_register:
 }
 
 
-static void __exit kobil_exit (void)
+static void __exit kobil_exit(void)
 {
-       usb_deregister (&kobil_driver);
-       usb_serial_deregister (&kobil_device);
+       usb_deregister(&kobil_driver);
+       usb_serial_deregister(&kobil_device);
 }
 
 module_init(kobil_init);
 module_exit(kobil_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
-MODULE_LICENSE( "GPL" );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Debug enabled or not");
index 5fc2cef..0ded8bd 100644 (file)
  *   - Fixed an endianess problem with the baudrate selection for PowerPC.
  *
  * 06-Dec-2001 Martin Hamilton <martinh@gnu.org>
- *     Added support for the Belkin F5U109 DB9 adaptor
+ *   - Added support for the Belkin F5U109 DB9 adaptor
  *
  * 30-May-2001 Greg Kroah-Hartman
- *     switched from using spinlock to a semaphore, which fixes lots of problems.
+ *   - switched from using spinlock to a semaphore, which fixes lots of
+ *     problems.
  *
  * 04-May-2001 Stelian Pop
  *   - Set the maximum bulk output size for Sitecom U232-P25 model to 16 bytes
@@ -49,7 +50,7 @@
  * 08-Apr-2001 gb
  *   - Identify version on module load.
  *
- * 06-Jan-2001 Cornel Ciocirlan 
+ * 06-Jan-2001 Cornel Ciocirlan
  *   - Added support for Sitecom U232-P25 model (Product Id 0x0230)
  *   - Added support for D-Link DU-H3SP USB BAY (Product Id 0x0200)
  *
@@ -59,8 +60,8 @@
  *     (lots of things will change if/when the usb-serial core changes to
  *     handle these issues.
  *
- * 27-Nov-2000 Wolfgang Grandegger
- *   A version for kernel 2.4.0-test10 released to the Linux community 
+ * 27-Nov-2000 Wolfgang Grandegge
+ *   A version for kernel 2.4.0-test10 released to the Linux community
  *   (via linux-usb-devel).
  */
 
@@ -73,7 +74,7 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include "mct_u232.h"
@@ -90,28 +91,21 @@ static int debug;
 /*
  * Function prototypes
  */
-static int  mct_u232_startup            (struct usb_serial *serial);
-static void mct_u232_shutdown           (struct usb_serial *serial);
-static int  mct_u232_open               (struct usb_serial_port *port,
-                                         struct file *filp);
-static void mct_u232_close              (struct usb_serial_port *port,
-                                         struct file *filp);
-static void mct_u232_read_int_callback   (struct urb *urb);
-static void mct_u232_set_termios         (struct usb_serial_port *port,
-                                         struct ktermios * old);
-static int  mct_u232_ioctl              (struct usb_serial_port *port,
-                                         struct file * file,
-                                         unsigned int cmd,
-                                         unsigned long arg);
-static void mct_u232_break_ctl          (struct usb_serial_port *port,
-                                         int break_state );
-static int  mct_u232_tiocmget           (struct usb_serial_port *port,
-                                         struct file *file);
-static int  mct_u232_tiocmset           (struct usb_serial_port *port,
-                                         struct file *file, unsigned int set,
-                                         unsigned int clear);
-static void mct_u232_throttle           (struct usb_serial_port *port);
-static void mct_u232_unthrottle                 (struct usb_serial_port *port);
+static int  mct_u232_startup(struct usb_serial *serial);
+static void mct_u232_shutdown(struct usb_serial *serial);
+static int  mct_u232_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void mct_u232_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void mct_u232_read_int_callback(struct urb *urb);
+static void mct_u232_set_termios(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct ktermios *old);
+static void mct_u232_break_ctl(struct tty_struct *tty, int break_state);
+static int  mct_u232_tiocmget(struct tty_struct *tty, struct file *file);
+static int  mct_u232_tiocmset(struct tty_struct *tty, struct file *file,
+                       unsigned int set, unsigned int clear);
+static void mct_u232_throttle(struct tty_struct *tty);
+static void mct_u232_unthrottle(struct tty_struct *tty);
 
 
 /*
@@ -125,7 +119,7 @@ static struct usb_device_id id_table_combined [] = {
        { }             /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table_combined);
+MODULE_DEVICE_TABLE(usb, id_table_combined);
 
 static struct usb_driver mct_u232_driver = {
        .name =         "mct_u232",
@@ -149,7 +143,6 @@ static struct usb_serial_driver mct_u232_device = {
        .throttle =          mct_u232_throttle,
        .unthrottle =        mct_u232_unthrottle,
        .read_int_callback = mct_u232_read_int_callback,
-       .ioctl =             mct_u232_ioctl,
        .set_termios =       mct_u232_set_termios,
        .break_ctl =         mct_u232_break_ctl,
        .tiocmget =          mct_u232_tiocmget,
@@ -180,23 +173,34 @@ struct mct_u232_private {
  * Later day 2.6.0-test kernels have new baud rates like B230400 which
  * we do not know how to support. We ignore them for the moment.
  */
-static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value, speed_t *result)
+static int mct_u232_calculate_baud_rate(struct usb_serial *serial,
+                                       speed_t value, speed_t *result)
 {
        *result = value;
 
        if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID
-         || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) {
+               || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) {
                switch (value) {
-               case    300: return 0x01;
-               case    600: return 0x02; /* this one not tested */
-               case   1200: return 0x03;
-               case   2400: return 0x04;
-               case   4800: return 0x06;
-               case   9600: return 0x08;
-               case  19200: return 0x09;
-               case  38400: return 0x0a;
-               case  57600: return 0x0b;
-               case 115200: return 0x0c;
+               case 300:
+                       return 0x01;
+               case 600:
+                       return 0x02; /* this one not tested */
+               case 1200:
+                       return 0x03;
+               case 2400:
+                       return 0x04;
+               case 4800:
+                       return 0x06;
+               case 9600:
+                       return 0x08;
+               case 19200:
+                       return 0x09;
+               case 38400:
+                       return 0x0a;
+               case 57600:
+                       return 0x0b;
+               case 115200:
+                       return 0x0c;
                default:
                        *result = 9600;
                        return 0x08;
@@ -224,26 +228,27 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value
        }
 }
 
-static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_port *port,
-                                 speed_t value)
+static int mct_u232_set_baud_rate(struct tty_struct *tty,
+       struct usb_serial *serial, struct usb_serial_port *port, speed_t value)
 {
        __le32 divisor;
-        int rc;
-        unsigned char zero_byte = 0;
-        unsigned char cts_enable_byte = 0;
-        speed_t speed;
-
-       divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value, &speed));
-
-        rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
-                             MCT_U232_SET_BAUD_RATE_REQUEST,
-                            MCT_U232_SET_REQUEST_TYPE,
-                             0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE,
-                            WDR_TIMEOUT);
+       int rc;
+       unsigned char zero_byte = 0;
+       unsigned char cts_enable_byte = 0;
+       speed_t speed;
+
+       divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value,
+                                                               &speed));
+
+       rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
+                               MCT_U232_SET_BAUD_RATE_REQUEST,
+                               MCT_U232_SET_REQUEST_TYPE,
+                               0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE,
+                               WDR_TIMEOUT);
        if (rc < 0)     /*FIXME: What value speed results */
                err("Set BAUD RATE %d failed (error = %d)", value, rc);
        else
-               tty_encode_baud_rate(port->tty, speed, speed);
+               tty_encode_baud_rate(tty, speed, speed);
        dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor);
 
        /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which
@@ -258,55 +263,55 @@ static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_p
           whether data will be transmitted to a device which is not asserting
           the 'CTS' signal.  If the second message's data byte is zero, data
           will be transmitted even if 'CTS' is not asserted (i.e. no hardware
-          flow control).  if the second message's data byte is nonzero (a value
-          of 1 is used by this driver), data will not be transmitted to a device
-          which is not asserting 'CTS'.
+          flow control).  if the second message's data byte is nonzero (a
+          value of 1 is used by this driver), data will not be transmitted to
+          a device which is not asserting 'CTS'.
        */
 
        rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
-                            MCT_U232_SET_UNKNOWN1_REQUEST, 
-                            MCT_U232_SET_REQUEST_TYPE,
-                            0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE, 
-                            WDR_TIMEOUT);
+                               MCT_U232_SET_UNKNOWN1_REQUEST,
+                               MCT_U232_SET_REQUEST_TYPE,
+                               0, 0, &zero_byte, MCT_U232_SET_UNKNOWN1_SIZE,
+                               WDR_TIMEOUT);
        if (rc < 0)
-               err("Sending USB device request code %d failed (error = %d)", 
+               err("Sending USB device request code %d failed (error = %d)",
                    MCT_U232_SET_UNKNOWN1_REQUEST, rc);
 
-       if (port && C_CRTSCTS(port->tty)) {
+       if (port && C_CRTSCTS(tty))
           cts_enable_byte = 1;
-       }
 
-        dbg("set_baud_rate: send second control message, data = %02X", cts_enable_byte);
+       dbg("set_baud_rate: send second control message, data = %02X",
+                                                       cts_enable_byte);
        rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
-                            MCT_U232_SET_CTS_REQUEST,
-                            MCT_U232_SET_REQUEST_TYPE,
-                            0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE,
-                            WDR_TIMEOUT);
+                       MCT_U232_SET_CTS_REQUEST,
+                       MCT_U232_SET_REQUEST_TYPE,
+                       0, 0, &cts_enable_byte, MCT_U232_SET_CTS_SIZE,
+                       WDR_TIMEOUT);
        if (rc < 0)
-         err("Sending USB device request code %d failed (error = %d)",
-             MCT_U232_SET_CTS_REQUEST, rc);
+               err("Sending USB device request code %d failed (error = %d)",
+                                       MCT_U232_SET_CTS_REQUEST, rc);
 
-        return rc;
+       return rc;
 } /* mct_u232_set_baud_rate */
 
 static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr)
 {
-        int rc;
-        rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
-                             MCT_U232_SET_LINE_CTRL_REQUEST,
-                            MCT_U232_SET_REQUEST_TYPE,
-                             0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE,
-                            WDR_TIMEOUT);
+       int rc;
+       rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
+                       MCT_U232_SET_LINE_CTRL_REQUEST,
+                       MCT_U232_SET_REQUEST_TYPE,
+                       0, 0, &lcr, MCT_U232_SET_LINE_CTRL_SIZE,
+                       WDR_TIMEOUT);
        if (rc < 0)
                err("Set LINE CTRL 0x%x failed (error = %d)", lcr, rc);
        dbg("set_line_ctrl: 0x%x", lcr);
-        return rc;
+       return rc;
 } /* mct_u232_set_line_ctrl */
 
 static int mct_u232_set_modem_ctrl(struct usb_serial *serial,
                                   unsigned int control_state)
 {
-        int rc;
+       int rc;
        unsigned char mcr = MCT_U232_MCR_NONE;
 
        if (control_state & TIOCM_DTR)
@@ -314,37 +319,39 @@ static int mct_u232_set_modem_ctrl(struct usb_serial *serial,
        if (control_state & TIOCM_RTS)
                mcr |= MCT_U232_MCR_RTS;
 
-        rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
-                             MCT_U232_SET_MODEM_CTRL_REQUEST,
-                            MCT_U232_SET_REQUEST_TYPE,
-                             0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE,
-                            WDR_TIMEOUT);
+       rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
+                       MCT_U232_SET_MODEM_CTRL_REQUEST,
+                       MCT_U232_SET_REQUEST_TYPE,
+                       0, 0, &mcr, MCT_U232_SET_MODEM_CTRL_SIZE,
+                       WDR_TIMEOUT);
        if (rc < 0)
                err("Set MODEM CTRL 0x%x failed (error = %d)", mcr, rc);
        dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr);
 
-        return rc;
+       return rc;
 } /* mct_u232_set_modem_ctrl */
 
-static int mct_u232_get_modem_stat(struct usb_serial *serial, unsigned char *msr)
+static int mct_u232_get_modem_stat(struct usb_serial *serial,
+                                               unsigned char *msr)
 {
-        int rc;
-        rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
-                             MCT_U232_GET_MODEM_STAT_REQUEST,
-                            MCT_U232_GET_REQUEST_TYPE,
-                             0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE,
-                            WDR_TIMEOUT);
+       int rc;
+       rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
+                       MCT_U232_GET_MODEM_STAT_REQUEST,
+                       MCT_U232_GET_REQUEST_TYPE,
+                       0, 0, msr, MCT_U232_GET_MODEM_STAT_SIZE,
+                       WDR_TIMEOUT);
        if (rc < 0) {
                err("Get MODEM STATus failed (error = %d)", rc);
                *msr = 0;
        }
        dbg("get_modem_stat: 0x%x", *msr);
-        return rc;
+       return rc;
 } /* mct_u232_get_modem_stat */
 
-static void mct_u232_msr_to_state(unsigned int *control_state, unsigned char msr)
+static void mct_u232_msr_to_state(unsigned int *control_state,
+                                               unsigned char msr)
 {
-       /* Translate Control Line states */
+       /* Translate Control Line states */
        if (msr & MCT_U232_MSR_DSR)
                *control_state |=  TIOCM_DSR;
        else
@@ -361,14 +368,14 @@ static void mct_u232_msr_to_state(unsigned int *control_state, unsigned char msr
                *control_state |=  TIOCM_CD;
        else
                *control_state &= ~TIOCM_CD;
-       dbg("msr_to_state: msr=0x%x ==> state=0x%x", msr, *control_state);
+       dbg("msr_to_state: msr=0x%x ==> state=0x%x", msr, *control_state);
 } /* mct_u232_msr_to_state */
 
 /*
  * Driver's tty interface functions
  */
 
-static int mct_u232_startup (struct usb_serial *serial)
+static int mct_u232_startup(struct usb_serial *serial)
 {
        struct mct_u232_private *priv;
        struct usb_serial_port *port, *rport;
@@ -390,18 +397,18 @@ static int mct_u232_startup (struct usb_serial *serial)
        rport->interrupt_in_urb = NULL;
        port->read_urb->context = port;
 
-       return (0);
+       return 0;
 } /* mct_u232_startup */
 
 
-static void mct_u232_shutdown (struct usb_serial *serial)
+static void mct_u232_shutdown(struct usb_serial *serial)
 {
        struct mct_u232_private *priv;
        int i;
-       
+
        dbg("%s", __func__);
 
-       for (i=0; i < serial->num_ports; ++i) {
+       for (i = 0; i < serial->num_ports; ++i) {
                /* My special items, the standard routines free my urbs */
                priv = usb_get_serial_port_data(serial->port[i]);
                if (priv) {
@@ -411,7 +418,8 @@ static void mct_u232_shutdown (struct usb_serial *serial)
        }
 } /* mct_u232_shutdown */
 
-static int  mct_u232_open (struct usb_serial_port *port, struct file *filp)
+static int  mct_u232_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial *serial = port->serial;
        struct mct_u232_private *priv = usb_get_serial_port_data(port);
@@ -428,21 +436,22 @@ static int  mct_u232_open (struct usb_serial_port *port, struct file *filp)
         * it seems to be able to accept only 16 bytes (and that's what
         * SniffUSB says too...)
         */
-       if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID)
+       if (le16_to_cpu(serial->dev->descriptor.idProduct)
+                                               == MCT_U232_SITECOM_PID)
                port->bulk_out_size = 16;
 
-       /* Do a defined restart: the normal serial device seems to 
+       /* Do a defined restart: the normal serial device seems to
         * always turn on DTR and RTS here, so do the same. I'm not
         * sure if this is really necessary. But it should not harm
         * either.
         */
        spin_lock_irqsave(&priv->lock, flags);
-       if (port->tty->termios->c_cflag & CBAUD)
+       if (tty && (tty->termios->c_cflag & CBAUD))
                priv->control_state = TIOCM_DTR | TIOCM_RTS;
        else
                priv->control_state = 0;
-       
-       priv->last_lcr = (MCT_U232_DATA_BITS_8 | 
+
+       priv->last_lcr = (MCT_U232_DATA_BITS_8 |
                          MCT_U232_PARITY_NONE |
                          MCT_U232_STOP_BITS_1);
        control_state = priv->control_state;
@@ -481,15 +490,16 @@ error:
 } /* mct_u232_open */
 
 
-static void mct_u232_close (struct usb_serial_port *port, struct file *filp)
+static void mct_u232_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        unsigned int c_cflag;
        unsigned int control_state;
        struct mct_u232_private *priv = usb_get_serial_port_data(port);
        dbg("%s port %d", __func__, port->number);
 
-       if (port->tty) {
-               c_cflag = port->tty->termios->c_cflag;
+       if (tty) {
+               c_cflag = tty->termios->c_cflag;
                mutex_lock(&port->serial->disc_mutex);
                if (c_cflag & HUPCL && !port->serial->disconnected) {
                        /* drop DTR and RTS */
@@ -512,7 +522,7 @@ static void mct_u232_close (struct usb_serial_port *port, struct file *filp)
 } /* mct_u232_close */
 
 
-static void mct_u232_read_int_callback (struct urb *urb)
+static void mct_u232_read_int_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        struct mct_u232_private *priv = usb_get_serial_port_data(port);
@@ -545,36 +555,34 @@ static void mct_u232_read_int_callback (struct urb *urb)
                return;
        }
 
-        dbg("%s - port %d", __func__, port->number);
-       usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
+       dbg("%s - port %d", __func__, port->number);
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                       urb->actual_length, data);
 
        /*
         * Work-a-round: handle the 'usual' bulk-in pipe here
         */
        if (urb->transfer_buffer_length > 2) {
-               int i;
-               tty = port->tty;
+               tty = port->port.tty;
                if (urb->actual_length) {
-                       for (i = 0; i < urb->actual_length ; ++i) {
-                               tty_insert_flip_char(tty, data[i], 0);
-                       }
+                       tty_insert_flip_string(tty, data, urb->actual_length);
                        tty_flip_buffer_push(tty);
                }
                goto exit;
        }
-       
+
        /*
         * The interrupt-in pipe signals exceptional conditions (modem line
         * signal changes and errors). data[0] holds MSR, data[1] holds LSR.
         */
        spin_lock_irqsave(&priv->lock, flags);
        priv->last_msr = data[MCT_U232_MSR_INDEX];
-       
+
        /* Record Control Line states */
        mct_u232_msr_to_state(&priv->control_state, priv->last_msr);
 
 #if 0
-       /* Not yet handled. See belin_sa.c for further information */
+       /* Not yet handled. See belkin_sa.c for further information */
        /* Now to report any errors */
        priv->last_lsr = data[MCT_U232_LSR_INDEX];
        /*
@@ -583,7 +591,7 @@ static void mct_u232_read_int_callback (struct urb *urb)
         * to look in to this before committing any code.
         */
        if (priv->last_lsr & MCT_U232_LSR_ERR) {
-               tty = port->tty;
+               tty = port->port.tty;
                /* Overrun Error */
                if (priv->last_lsr & MCT_U232_LSR_OE) {
                }
@@ -600,18 +608,19 @@ static void mct_u232_read_int_callback (struct urb *urb)
 #endif
        spin_unlock_irqrestore(&priv->lock, flags);
 exit:
-       retval = usb_submit_urb (urb, GFP_ATOMIC);
+       retval = usb_submit_urb(urb, GFP_ATOMIC);
        if (retval)
-               err ("%s - usb_submit_urb failed with result %d",
+               err("%s - usb_submit_urb failed with result %d",
                     __func__, retval);
 } /* mct_u232_read_int_callback */
 
-static void mct_u232_set_termios (struct usb_serial_port *port,
-                                 struct ktermios *old_termios)
+static void mct_u232_set_termios(struct tty_struct *tty,
+                                struct usb_serial_port *port,
+                                struct ktermios *old_termios)
 {
        struct usb_serial *serial = port->serial;
        struct mct_u232_private *priv = usb_get_serial_port_data(port);
-       struct ktermios *termios = port->tty->termios;
+       struct ktermios *termios = tty->termios;
        unsigned int cflag = termios->c_cflag;
        unsigned int old_cflag = old_termios->c_cflag;
        unsigned long flags;
@@ -631,20 +640,20 @@ static void mct_u232_set_termios (struct usb_serial_port *port,
         * Premature optimization is the root of all evil.
         */
 
-        /* reassert DTR and RTS on transition from B0 */
+       /* reassert DTR and RTS on transition from B0 */
        if ((old_cflag & CBAUD) == B0) {
                dbg("%s: baud was B0", __func__);
                control_state |= TIOCM_DTR | TIOCM_RTS;
                mct_u232_set_modem_ctrl(serial, control_state);
        }
 
-       mct_u232_set_baud_rate(serial, port, tty_get_baud_rate(port->tty));
+       mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty));
 
-       if ((cflag & CBAUD) == B0 ) {
+       if ((cflag & CBAUD) == B0) {
                dbg("%s: baud is B0", __func__);
                /* Drop RTS and DTR */
                control_state &= ~(TIOCM_DTR | TIOCM_RTS);
-                       mct_u232_set_modem_ctrl(serial, control_state);
+               mct_u232_set_modem_ctrl(serial, control_state);
        }
 
        /*
@@ -689,8 +698,9 @@ static void mct_u232_set_termios (struct usb_serial_port *port,
        spin_unlock_irqrestore(&priv->lock, flags);
 } /* mct_u232_set_termios */
 
-static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
+static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
        struct mct_u232_private *priv = usb_get_serial_port_data(port);
        unsigned char lcr;
@@ -709,12 +719,13 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
 } /* mct_u232_break_ctl */
 
 
-static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file)
+static int mct_u232_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct mct_u232_private *priv = usb_get_serial_port_data(port);
        unsigned int control_state;
        unsigned long flags;
-       
+
        dbg("%s", __func__);
 
        spin_lock_irqsave(&priv->lock, flags);
@@ -724,14 +735,15 @@ static int mct_u232_tiocmget (struct usb_serial_port *port, struct file *file)
        return control_state;
 }
 
-static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file,
+static int mct_u232_tiocmset(struct tty_struct *tty, struct file *file,
                              unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
        struct mct_u232_private *priv = usb_get_serial_port_data(port);
        unsigned int control_state;
        unsigned long flags;
-       
+
        dbg("%s", __func__);
 
        spin_lock_irqsave(&priv->lock, flags);
@@ -751,77 +763,50 @@ static int mct_u232_tiocmset (struct usb_serial_port *port, struct file *file,
        return mct_u232_set_modem_ctrl(serial, control_state);
 }
 
-static int mct_u232_ioctl (struct usb_serial_port *port, struct file * file,
-                          unsigned int cmd, unsigned long arg)
-{
-       dbg("%scmd=0x%x", __func__, cmd);
-
-       /* Based on code from acm.c and others */
-       switch (cmd) {
-       case TIOCMIWAIT:
-               /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
-               /* TODO */
-               return( 0 );
-
-       case TIOCGICOUNT:
-               /* return count of modemline transitions */
-               /* TODO */
-               return 0;
-
-       default:
-               dbg("%s: arg not supported - 0x%04x", __func__,cmd);
-               return(-ENOIOCTLCMD);
-               break;
-       }
-       return 0;
-} /* mct_u232_ioctl */
-
-static void mct_u232_throttle (struct usb_serial_port *port)
+static void mct_u232_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct mct_u232_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
        unsigned int control_state;
-       struct tty_struct *tty;
 
-       tty = port->tty;
        dbg("%s - port %d", __func__, port->number);
 
        spin_lock_irqsave(&priv->lock, flags);
        priv->rx_flags |= THROTTLED;
        if (C_CRTSCTS(tty)) {
-         priv->control_state &= ~TIOCM_RTS;
-         control_state = priv->control_state;
-         spin_unlock_irqrestore(&priv->lock, flags);
-         (void) mct_u232_set_modem_ctrl(port->serial, control_state);
+               priv->control_state &= ~TIOCM_RTS;
+               control_state = priv->control_state;
+               spin_unlock_irqrestore(&priv->lock, flags);
+               (void) mct_u232_set_modem_ctrl(port->serial, control_state);
        } else {
-         spin_unlock_irqrestore(&priv->lock, flags);
+               spin_unlock_irqrestore(&priv->lock, flags);
        }
 }
 
 
-static void mct_u232_unthrottle (struct usb_serial_port *port)
+static void mct_u232_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct mct_u232_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
        unsigned int control_state;
-       struct tty_struct *tty;
 
        dbg("%s - port %d", __func__, port->number);
 
-       tty = port->tty;
        spin_lock_irqsave(&priv->lock, flags);
        if ((priv->rx_flags & THROTTLED) && C_CRTSCTS(tty)) {
-         priv->rx_flags &= ~THROTTLED;
-         priv->control_state |= TIOCM_RTS;
-         control_state = priv->control_state;
-         spin_unlock_irqrestore(&priv->lock, flags);
-         (void) mct_u232_set_modem_ctrl(port->serial, control_state);
+               priv->rx_flags &= ~THROTTLED;
+               priv->control_state |= TIOCM_RTS;
+               control_state = priv->control_state;
+               spin_unlock_irqrestore(&priv->lock, flags);
+               (void) mct_u232_set_modem_ctrl(port->serial, control_state);
        } else {
-         spin_unlock_irqrestore(&priv->lock, flags);
+               spin_unlock_irqrestore(&priv->lock, flags);
        }
 }
 
-static int __init mct_u232_init (void)
+static int __init mct_u232_init(void)
 {
        int retval;
        retval = usb_serial_register(&mct_u232_device);
@@ -839,18 +824,17 @@ failed_usb_serial_register:
 }
 
 
-static void __exit mct_u232_exit (void)
+static void __exit mct_u232_exit(void)
 {
-       usb_deregister (&mct_u232_driver);
-       usb_serial_deregister (&mct_u232_device);
+       usb_deregister(&mct_u232_driver);
+       usb_serial_deregister(&mct_u232_device);
 }
 
-
-module_init (mct_u232_init);
+module_init(mct_u232_init);
 module_exit(mct_u232_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index 50f1fe2..7c4917d 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/serial_reg.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 
 /*
@@ -64,8 +64,7 @@
 #define URB_TRANSFER_BUFFER_SIZE       32      /* URB Size */
 
 /* This structure holds all of the local port information */
-struct moschip_port
-{
+struct moschip_port {
        __u8    shadowLCR;              /* last LCR value received */
        __u8    shadowMCR;              /* last MCR value received */
        __u8    shadowMSR;              /* last MSR value received */
@@ -76,8 +75,7 @@ struct moschip_port
 };
 
 /* This structure holds all of the individual serial device information */
-struct moschip_serial
-{
+struct moschip_serial {
        int interrupt_started;
 };
 
@@ -88,7 +86,7 @@ static int debug;
 #define MOSCHIP_DEVICE_ID_7715         0x7715
 
 static struct usb_device_id moschip_port_id_table [] = {
-       { USB_DEVICE(USB_VENDOR_ID_MOSCHIP,MOSCHIP_DEVICE_ID_7720) },
+       { USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7720) },
        { } /* terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, moschip_port_id_table);
@@ -108,7 +106,7 @@ static void mos7720_interrupt_callback(struct urb *urb)
        __u8 sp1;
        __u8 sp2;
 
-       dbg("%s"," : Entering\n");
+       dbg("%s", " : Entering\n");
 
        switch (status) {
        case 0:
@@ -208,7 +206,7 @@ static void mos7720_bulk_in_callback(struct urb *urb)
 
        mos7720_port = urb->context;
        if (!mos7720_port) {
-               dbg("%s","NULL mos7720_port pointer \n");
+               dbg("%s", "NULL mos7720_port pointer \n");
                return ;
        }
 
@@ -218,7 +216,7 @@ static void mos7720_bulk_in_callback(struct urb *urb)
 
        data = urb->transfer_buffer;
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (tty && urb->actual_length) {
                tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
@@ -264,7 +262,7 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
 
        dbg("Entering .........");
 
-       tty = mos7720_port->port->tty;
+       tty = mos7720_port->port->port.tty;
 
        if (tty && mos7720_port->open)
                tty_wakeup(tty);
@@ -284,17 +282,16 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
        __u16 size = 0x0000;
 
        if (value < MOS_MAX_PORT) {
-               if (product == MOSCHIP_DEVICE_ID_7715) {
+               if (product == MOSCHIP_DEVICE_ID_7715)
                        value = value*0x100+0x100;
-               } else {
+               else
                        value = value*0x100+0x200;
-               }
        } else {
                value = 0x0000;
                if ((product == MOSCHIP_DEVICE_ID_7715) &&
                    (index != 0x08)) {
                        dbg("serial->product== MOSCHIP_DEVICE_ID_7715");
-                       //index = 0x01 ;
+                       /* index = 0x01 ; */
                }
        }
 
@@ -308,19 +305,20 @@ static int send_mos_cmd(struct usb_serial *serial, __u8 request, __u16 value,
                request = (__u8)MOS_READ;
                requesttype = (__u8)0xC0;
                size = 0x01;
-               pipe = usb_rcvctrlpipe(serial->dev,0);
+               pipe = usb_rcvctrlpipe(serial->dev, 0);
        }
 
        status = usb_control_msg(serial->dev, pipe, request, requesttype,
                                 value, index, data, size, MOS_WDR_TIMEOUT);
 
        if (status < 0)
-               dbg("Command Write failed Value %x index %x\n",value,index);
+               dbg("Command Write failed Value %x index %x\n", value, index);
 
        return status;
 }
 
-static int mos7720_open(struct usb_serial_port *port, struct file * filp)
+static int mos7720_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial *serial;
        struct usb_serial_port *port0;
@@ -351,7 +349,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
 
        /* Initialising the write urb pool */
        for (j = 0; j < NUM_URBS; ++j) {
-               urb = usb_alloc_urb(0,GFP_KERNEL);
+               urb = usb_alloc_urb(0, GFP_KERNEL);
                mos7720_port->write_urb_pool[j] = urb;
 
                if (urb == NULL) {
@@ -385,7 +383,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
          */
        port_number = port->number - port->serial->minor;
        send_mos_cmd(port->serial, MOS_READ, port_number, UART_LSR, &data);
-       dbg("SS::%p LSR:%x\n",mos7720_port, data);
+       dbg("SS::%p LSR:%x\n", mos7720_port, data);
 
        dbg("Check:Sending Command ..........");
 
@@ -402,10 +400,10 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
        data = 0xCF;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x02, &data);
        data = 0x03;
-        mos7720_port->shadowLCR  = data;
+       mos7720_port->shadowLCR  = data;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
        data = 0x0b;
-        mos7720_port->shadowMCR  = data;
+       mos7720_port->shadowMCR  = data;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
        data = 0x0b;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
@@ -420,7 +418,8 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
        data = 0x03;
        send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);
        data = 0x00;
-       send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);
+       send_mos_cmd(port->serial, MOS_WRITE, MOS_MAX_PORT,
+                                               port_number + 1, &data);
 */
        data = 0x00;
        send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
@@ -429,28 +428,26 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
        send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
 
        data = 0x83;
-        mos7720_port->shadowLCR  = data;
+       mos7720_port->shadowLCR  = data;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
        data = 0x0c;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data);
        data = 0x00;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
        data = 0x03;
-        mos7720_port->shadowLCR  = data;
+       mos7720_port->shadowLCR  = data;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
        data = 0x0c;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
        data = 0x0c;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
 
-//Matrix
-
        /* force low_latency on so that our tty_push actually forces *
         * the data through,otherwise it is scheduled, and with      *
         * high data rates (like with OHCI) data can get lost.       */
 
-       if (port->tty)
-               port->tty->low_latency = 1;
+       if (tty)
+               tty->low_latency = 1;
 
        /* see if we've set up our endpoint info yet   *
         * (can't set it up in mos7720_startup as the  *
@@ -465,15 +462,15 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
 
                /* set up our interrupt urb */
                usb_fill_int_urb(port0->interrupt_in_urb, serial->dev,
-                                usb_rcvintpipe(serial->dev,
-                                               port->interrupt_in_endpointAddress),
-                                port0->interrupt_in_buffer,
-                                port0->interrupt_in_urb->transfer_buffer_length,
-                                mos7720_interrupt_callback, mos7720_port,
-                                port0->interrupt_in_urb->interval);
+                        usb_rcvintpipe(serial->dev,
+                               port->interrupt_in_endpointAddress),
+                        port0->interrupt_in_buffer,
+                        port0->interrupt_in_urb->transfer_buffer_length,
+                        mos7720_interrupt_callback, mos7720_port,
+                        port0->interrupt_in_urb->interval);
 
                /* start interrupt read for this mos7720 this interrupt *
-                * will continue as long as the mos7720 is connected    */
+                * will continue as long as the mos7720 is connected    */
                dbg("Submit URB over !!!");
                response = usb_submit_urb(port0->interrupt_in_urb, GFP_KERNEL);
                if (response)
@@ -485,14 +482,14 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
        /* set up our bulk in urb */
        usb_fill_bulk_urb(port->read_urb, serial->dev,
                          usb_rcvbulkpipe(serial->dev,
-                                         port->bulk_in_endpointAddress),
+                               port->bulk_in_endpointAddress),
                          port->bulk_in_buffer,
                          port->read_urb->transfer_buffer_length,
                          mos7720_bulk_in_callback, mos7720_port);
        response = usb_submit_urb(port->read_urb, GFP_KERNEL);
        if (response)
-               dev_err(&port->dev,
-                       "%s - Error %d submitting read urb\n", __func__, response);
+               dev_err(&port->dev, "%s - Error %d submitting read urb\n",
+                                                       __func__, response);
 
        /* initialize our icount structure */
        memset(&(mos7720_port->icount), 0x00, sizeof(mos7720_port->icount));
@@ -515,8 +512,9 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
  *     system,
  *     Otherwise we return a negative error number.
  */
-static int mos7720_chars_in_buffer(struct usb_serial_port *port)
+static int mos7720_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        int i;
        int chars = 0;
        struct moschip_port *mos7720_port;
@@ -530,14 +528,16 @@ static int mos7720_chars_in_buffer(struct usb_serial_port *port)
        }
 
        for (i = 0; i < NUM_URBS; ++i) {
-               if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
+               if (mos7720_port->write_urb_pool[i] &&
+                   mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
                        chars += URB_TRANSFER_BUFFER_SIZE;
        }
        dbg("%s - returns %d", __func__, chars);
        return chars;
 }
 
-static void mos7720_close(struct usb_serial_port *port, struct file *filp)
+static void mos7720_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial *serial;
        struct moschip_port *mos7720_port;
@@ -575,12 +575,12 @@ static void mos7720_close(struct usb_serial_port *port, struct file *filp)
         * been disconnected */
        if (!serial->disconnected) {
                data = 0x00;
-               send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
-                            0x04, &data);
+               send_mos_cmd(serial, MOS_WRITE,
+                       port->number - port->serial->minor, 0x04, &data);
 
                data = 0x00;
-               send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
-                            0x01, &data);
+               send_mos_cmd(serial, MOS_WRITE,
+                       port->number - port->serial->minor, 0x01, &data);
        }
        mutex_unlock(&serial->disc_mutex);
        mos7720_port->open = 0;
@@ -588,9 +588,10 @@ static void mos7720_close(struct usb_serial_port *port, struct file *filp)
        dbg("Leaving %s", __func__);
 }
 
-static void mos7720_break(struct usb_serial_port *port, int break_state)
+static void mos7720_break(struct tty_struct *tty, int break_state)
 {
-        unsigned char data;
+       struct usb_serial_port *port = tty->driver_data;
+       unsigned char data;
        struct usb_serial *serial;
        struct moschip_port *mos7720_port;
 
@@ -621,8 +622,9 @@ static void mos7720_break(struct usb_serial_port *port, int break_state)
  *     If successful, we return the amount of room that we have for this port
  *     Otherwise we return a negative error number.
  */
-static int mos7720_write_room(struct usb_serial_port *port)
+static int mos7720_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct moschip_port *mos7720_port;
        int room = 0;
        int i;
@@ -637,7 +639,8 @@ static int mos7720_write_room(struct usb_serial_port *port)
 
        /* FIXME: Locking */
        for (i = 0; i < NUM_URBS; ++i) {
-               if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
+               if (mos7720_port->write_urb_pool[i] &&
+                   mos7720_port->write_urb_pool[i]->status != -EINPROGRESS)
                        room += URB_TRANSFER_BUFFER_SIZE;
        }
 
@@ -645,8 +648,8 @@ static int mos7720_write_room(struct usb_serial_port *port)
        return room;
 }
 
-static int mos7720_write(struct usb_serial_port *port,
-                        const unsigned char *data, int count)
+static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                const unsigned char *data, int count)
 {
        int status;
        int i;
@@ -672,9 +675,10 @@ static int mos7720_write(struct usb_serial_port *port,
        urb = NULL;
 
        for (i = 0; i < NUM_URBS; ++i) {
-               if (mos7720_port->write_urb_pool[i] && mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
+               if (mos7720_port->write_urb_pool[i] &&
+                   mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
                        urb = mos7720_port->write_urb_pool[i];
-                       dbg("URB:%d",i);
+                       dbg("URB:%d", i);
                        break;
                }
        }
@@ -692,7 +696,7 @@ static int mos7720_write(struct usb_serial_port *port,
                        goto exit;
                }
        }
-       transfer_size = min (count, URB_TRANSFER_BUFFER_SIZE);
+       transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);
 
        memcpy(urb->transfer_buffer, current_position, transfer_size);
        usb_serial_debug_data(debug, &port->dev, __func__, transfer_size,
@@ -701,12 +705,12 @@ static int mos7720_write(struct usb_serial_port *port,
        /* fill urb with data and submit  */
        usb_fill_bulk_urb(urb, serial->dev,
                          usb_sndbulkpipe(serial->dev,
-                                         port->bulk_out_endpointAddress),
+                                       port->bulk_out_endpointAddress),
                          urb->transfer_buffer, transfer_size,
                          mos7720_bulk_out_data_callback, mos7720_port);
 
        /* send it down the pipe */
-       status = usb_submit_urb(urb,GFP_ATOMIC);
+       status = usb_submit_urb(urb, GFP_ATOMIC);
        if (status) {
                err("%s - usb_submit_urb(write bulk) failed with status = %d",
                    __func__, status);
@@ -719,10 +723,10 @@ exit:
        return bytes_sent;
 }
 
-static void mos7720_throttle(struct usb_serial_port *port)
+static void mos7720_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct moschip_port *mos7720_port;
-       struct tty_struct *tty;
        int status;
 
        dbg("%s- port %d\n", __func__, port->number);
@@ -739,16 +743,10 @@ static void mos7720_throttle(struct usb_serial_port *port)
 
        dbg("%s: Entering ..........", __func__);
 
-       tty = port->tty;
-       if (!tty) {
-               dbg("%s - no tty available", __func__);
-               return;
-       }
-
        /* if we are implementing XON/XOFF, send the stop character */
        if (I_IXOFF(tty)) {
                unsigned char stop_char = STOP_CHAR(tty);
-               status = mos7720_write(port, &stop_char, 1);
+               status = mos7720_write(tty, port, &stop_char, 1);
                if (status <= 0)
                        return;
        }
@@ -764,11 +762,11 @@ static void mos7720_throttle(struct usb_serial_port *port)
        }
 }
 
-static void mos7720_unthrottle(struct usb_serial_port *port)
+static void mos7720_unthrottle(struct tty_struct *tty)
 {
-       struct tty_struct *tty;
-       int status;
+       struct usb_serial_port *port = tty->driver_data;
        struct moschip_port *mos7720_port = usb_get_serial_port_data(port);
+       int status;
 
        if (mos7720_port == NULL)
                return;
@@ -780,16 +778,10 @@ static void mos7720_unthrottle(struct usb_serial_port *port)
 
        dbg("%s: Entering ..........", __func__);
 
-       tty = port->tty;
-       if (!tty) {
-               dbg("%s - no tty available", __func__);
-               return;
-       }
-
        /* if we are implementing XON/XOFF, send the start character */
        if (I_IXOFF(tty)) {
                unsigned char start_char = START_CHAR(tty);
-               status = mos7720_write(port, &start_char, 1);
+               status = mos7720_write(tty, port, &start_char, 1);
                if (status <= 0)
                        return;
        }
@@ -819,9 +811,9 @@ static int set_higher_rates(struct moschip_port *mos7720_port,
        port = mos7720_port->port;
        serial = port->serial;
 
-        /***********************************************
-         *      Init Sequence for higher rates
-         ***********************************************/
+        /***********************************************
+        *      Init Sequence for higher rates
+        ***********************************************/
        dbg("Sending Setting Commands ..........");
        port_number = port->number - port->serial->minor;
 
@@ -832,7 +824,7 @@ static int set_higher_rates(struct moschip_port *mos7720_port,
        data = 0x0CF;
        send_mos_cmd(serial, MOS_WRITE, port->number, 0x02, &data);
        data = 0x00b;
-        mos7720_port->shadowMCR  = data;
+       mos7720_port->shadowMCR  = data;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
        data = 0x00b;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
@@ -843,12 +835,12 @@ static int set_higher_rates(struct moschip_port *mos7720_port,
        send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
 
 
-        /***********************************************
-         *              Set for higher rates           *
-         ***********************************************/
+       /***********************************************
+        *              Set for higher rates           *
+        ***********************************************/
 
        data = baud * 0x10;
-       send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1,&data);
+       send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, port_number + 1, &data);
 
        data = 0x003;
        send_mos_cmd(serial, MOS_READ, MOS_MAX_PORT, 0x08, &data);
@@ -856,34 +848,33 @@ static int set_higher_rates(struct moschip_port *mos7720_port,
        send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT, 0x08, &data);
 
        data = 0x02b;
-        mos7720_port->shadowMCR  = data;
+       mos7720_port->shadowMCR  = data;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
        data = 0x02b;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
 
-        /***********************************************
-         *              Set DLL/DLM
-         ***********************************************/
+       /***********************************************
+        *              Set DLL/DLM
+        ***********************************************/
 
        data = mos7720_port->shadowLCR | UART_LCR_DLAB;
-        mos7720_port->shadowLCR  = data;
+       mos7720_port->shadowLCR  = data;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
 
        data =  0x001; /* DLL */
-        send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data);
+       send_mos_cmd(serial, MOS_WRITE, port_number, 0x00, &data);
        data =  0x000; /* DLM */
-        send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
+       send_mos_cmd(serial, MOS_WRITE, port_number, 0x01, &data);
 
        data = mos7720_port->shadowLCR & ~UART_LCR_DLAB;
-        mos7720_port->shadowLCR  = data;
+       mos7720_port->shadowLCR  = data;
        send_mos_cmd(serial, MOS_WRITE, port_number, 0x03, &data);
 
        return 0;
 }
 
 /* baud rate information */
-struct divisor_table_entry
-{
+struct divisor_table_entry {
        __u32  baudrate;
        __u16  divisor;
 };
@@ -932,8 +923,8 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor)
                }
        }
 
-        /* After trying for all the standard baud rates    *
-         * Try calculating the divisor for this baud rate  */
+       /* After trying for all the standard baud rates    *
+        * Try calculating the divisor for this baud rate  */
        if (baudrate > 75 &&  baudrate < 230400) {
                /* get the divisor */
                custom = (__u16)(230400L  / baudrate);
@@ -945,7 +936,7 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor)
                        custom++;
                *divisor = custom;
 
-               dbg("Baud %d = %d",baudrate, custom);
+               dbg("Baud %d = %d", baudrate, custom);
                return 0;
        }
 
@@ -979,29 +970,29 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port,
        number = port->number - port->serial->minor;
        dbg("%s - port = %d, baud = %d", __func__, port->number, baudrate);
 
-        /* Calculate the Divisor */
+       /* Calculate the Divisor */
        status = calc_baud_rate_divisor(baudrate, &divisor);
        if (status) {
                err("%s - bad baud rate", __func__);
                return status;
        }
 
-        /* Enable access to divisor latch */
-        data = mos7720_port->shadowLCR | UART_LCR_DLAB;
-        mos7720_port->shadowLCR  = data;
-        send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data);
+       /* Enable access to divisor latch */
+       data = mos7720_port->shadowLCR | UART_LCR_DLAB;
+       mos7720_port->shadowLCR  = data;
+       send_mos_cmd(serial, MOS_WRITE, number, UART_LCR, &data);
 
        /* Write the divisor */
        data = ((unsigned char)(divisor & 0xff));
-        send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data);
+       send_mos_cmd(serial, MOS_WRITE, number, 0x00, &data);
 
        data = ((unsigned char)((divisor & 0xff00) >> 8));
-        send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data);
+       send_mos_cmd(serial, MOS_WRITE, number, 0x01, &data);
 
-        /* Disable access to divisor latch */
-        data = mos7720_port->shadowLCR & ~UART_LCR_DLAB;
-        mos7720_port->shadowLCR = data;
-        send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data);
+       /* Disable access to divisor latch */
+       data = mos7720_port->shadowLCR & ~UART_LCR_DLAB;
+       mos7720_port->shadowLCR = data;
+       send_mos_cmd(serial, MOS_WRITE, number, 0x03, &data);
 
        return status;
 }
@@ -1011,12 +1002,12 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port,
  *     This routine is called to set the UART on the device to match
  *      the specified new settings.
  */
-static void change_port_settings(struct moschip_port *mos7720_port,
+static void change_port_settings(struct tty_struct *tty,
+                                struct moschip_port *mos7720_port,
                                 struct ktermios *old_termios)
 {
        struct usb_serial_port *port;
        struct usb_serial *serial;
-       struct tty_struct *tty;
        int baud;
        unsigned cflag;
        unsigned iflag;
@@ -1042,8 +1033,6 @@ static void change_port_settings(struct moschip_port *mos7720_port,
                return;
        }
 
-       tty = mos7720_port->port->tty;
-
        dbg("%s: Entering ..........", __func__);
 
        lData = UART_LCR_WLEN8;
@@ -1106,29 +1095,31 @@ static void change_port_settings(struct moschip_port *mos7720_port,
 #define LCR_PAR_MASK           0x38    /* Mask for parity field */
 
        /* Update the LCR with the correct value */
-       mos7720_port->shadowLCR &= ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK);
+       mos7720_port->shadowLCR &=
+                       ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK);
        mos7720_port->shadowLCR |= (lData | lParity | lStop);
 
 
        /* Disable Interrupts */
        data = 0x00;
-        send_mos_cmd(serial,MOS_WRITE,port->number - port->serial->minor, UART_IER, &data);
+       send_mos_cmd(serial, MOS_WRITE, port->number - port->serial->minor,
+                                                       UART_IER, &data);
 
        data = 0x00;
-        send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
+       send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
 
        data = 0xcf;
-        send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
+       send_mos_cmd(serial, MOS_WRITE, port_number, UART_FCR, &data);
 
        /* Send the updated LCR value to the mos7720 */
        data = mos7720_port->shadowLCR;
-        send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data);
+       send_mos_cmd(serial, MOS_WRITE, port_number, UART_LCR, &data);
 
-        data = 0x00b;
-        mos7720_port->shadowMCR = data;
-        send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
-        data = 0x00b;
-        send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
+       data = 0x00b;
+       mos7720_port->shadowMCR = data;
+       send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
+       data = 0x00b;
+       send_mos_cmd(serial, MOS_WRITE, port_number, 0x04, &data);
 
        /* set up the MCR register and send it to the mos7720 */
        mos7720_port->shadowMCR = UART_MCR_OUT2;
@@ -1137,9 +1128,8 @@ static void change_port_settings(struct moschip_port *mos7720_port,
 
        if (cflag & CRTSCTS) {
                mos7720_port->shadowMCR |= (UART_MCR_XONANY);
-
-                /* To set hardware flow control to the specified *
-                 * serial port, in SP1/2_CONTROL_REG             */
+               /* To set hardware flow control to the specified *
+                * serial port, in SP1/2_CONTROL_REG             */
                if (port->number) {
                        data = 0x001;
                        send_mos_cmd(serial, MOS_WRITE, MOS_MAX_PORT,
@@ -1198,14 +1188,13 @@ static void change_port_settings(struct moschip_port *mos7720_port,
  *     this function is called by the tty driver when it wants to change the
  *     termios structure.
  */
-static void mos7720_set_termios(struct usb_serial_port *port,
-                               struct ktermios *old_termios)
+static void mos7720_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        int status;
        unsigned int cflag;
        struct usb_serial *serial;
        struct moschip_port *mos7720_port;
-       struct tty_struct *tty;
 
        serial = port->serial;
 
@@ -1214,15 +1203,12 @@ static void mos7720_set_termios(struct usb_serial_port *port,
        if (mos7720_port == NULL)
                return;
 
-       tty = port->tty;
-
-
        if (!mos7720_port->open) {
                dbg("%s - port not opened", __func__);
                return;
        }
 
-       dbg("%s\n","setting termios - ASPIRE");
+       dbg("%s\n", "setting termios - ASPIRE");
 
        cflag = tty->termios->c_cflag;
 
@@ -1237,14 +1223,14 @@ static void mos7720_set_termios(struct usb_serial_port *port,
        dbg("%s - port %d", __func__, port->number);
 
        /* change the port settings to the new ones specified */
-       change_port_settings(mos7720_port, old_termios);
+       change_port_settings(tty, mos7720_port, old_termios);
 
-       if(!port->read_urb) {
-               dbg("%s","URB KILLED !!!!!\n");
+       if (!port->read_urb) {
+               dbg("%s", "URB KILLED !!!!!\n");
                return;
        }
 
-       if(port->read_urb->status != -EINPROGRESS) {
+       if (port->read_urb->status != -EINPROGRESS) {
                port->read_urb->dev = serial->dev;
                status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
                if (status)
@@ -1264,13 +1250,13 @@ static void mos7720_set_termios(struct usb_serial_port *port,
  *         transmit holding register is empty.  This functionality
  *         allows an RS485 driver to be written in user space.
  */
-static int get_lsr_info(struct moschip_port *mos7720_port,
-                       unsigned int __user *value)
+static int get_lsr_info(struct tty_struct *tty,
+               struct moschip_port *mos7720_port, unsigned int __user *value)
 {
        int count;
        unsigned int result = 0;
 
-       count = mos7720_chars_in_buffer(mos7720_port->port);
+       count = mos7720_chars_in_buffer(tty);
        if (count == 0) {
                dbg("%s -- Empty", __func__);
                result = TIOCSER_TEMT;
@@ -1290,7 +1276,7 @@ static int get_number_bytes_avail(struct moschip_port *mos7720_port,
                                  unsigned int __user *value)
 {
        unsigned int result = 0;
-       struct tty_struct *tty = mos7720_port->port->tty;
+       struct tty_struct *tty = mos7720_port->port->port.tty;
 
        if (!tty)
                return -ENOIOCTLCMD;
@@ -1316,7 +1302,7 @@ static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd,
        if (mos7720_port == NULL)
                return -1;
 
-       port = (struct usb_serial_port*)mos7720_port->port;
+       port = (struct usb_serial_port *)mos7720_port->port;
        mcr = mos7720_port->shadowMCR;
 
        if (copy_from_user(&arg, value, sizeof(int)))
@@ -1397,7 +1383,7 @@ static int get_serial_info(struct moschip_port *mos7720_port,
        tmp.port                = mos7720_port->port->number;
        tmp.irq                 = 0;
        tmp.flags               = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
-        tmp.xmit_fifo_size     = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
+       tmp.xmit_fifo_size      = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
        tmp.baud_base           = 9600;
        tmp.close_delay         = 5*HZ;
        tmp.closing_wait        = 30*HZ;
@@ -1407,9 +1393,10 @@ static int get_serial_info(struct moschip_port *mos7720_port,
        return 0;
 }
 
-static int mos7720_ioctl(struct usb_serial_port *port, struct file *file,
+static int mos7720_ioctl(struct tty_struct *tty, struct file *file,
                         unsigned int cmd, unsigned long arg)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct moschip_port *mos7720_port;
        struct async_icount cnow;
        struct async_icount cprev;
@@ -1431,14 +1418,16 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file,
 
        case TIOCSERGETLSR:
                dbg("%s (%d) TIOCSERGETLSR", __func__,  port->number);
-               return get_lsr_info(mos7720_port, (unsigned int __user *)arg);
+               return get_lsr_info(tty, mos7720_port,
+                                       (unsigned int __user *)arg);
                return 0;
 
+       /* FIXME: These should be using the mode methods */
        case TIOCMBIS:
        case TIOCMBIC:
        case TIOCMSET:
-               dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __func__,
-                   port->number);
+               dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET",
+                                       __func__, port->number);
                return set_modem_info(mos7720_port, cmd,
                                      (unsigned int __user *)arg);
 
@@ -1452,10 +1441,6 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file,
                return get_serial_info(mos7720_port,
                                       (struct serial_struct __user *)arg);
 
-       case TIOCSSERIAL:
-               dbg("%s (%d) TIOCSSERIAL", __func__,  port->number);
-               break;
-
        case TIOCMIWAIT:
                dbg("%s (%d) TIOCMIWAIT", __func__,  port->number);
                cprev = mos7720_port->icount;
@@ -1469,7 +1454,7 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file,
                        if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
                            ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
                            ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
-                           ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
+                           ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
                                return 0;
                        }
                        cprev = cnow;
@@ -1492,7 +1477,7 @@ static int mos7720_ioctl(struct usb_serial_port *port, struct file *file,
                icount.buf_overrun = cnow.buf_overrun;
 
                dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__,
-                   port->number, icount.rx, icount.tx );
+                   port->number, icount.rx, icount.tx);
                if (copy_to_user((void __user *)arg, &icount, sizeof(icount)))
                        return -EFAULT;
                return 0;
@@ -1543,7 +1528,8 @@ static int mos7720_startup(struct usb_serial *serial)
                /* Initialize all port interrupt end point to port 0 int
                 * endpoint.  Our device has only one interrupt endpoint
                 * comman to all ports */
-               serial->port[i]->interrupt_in_endpointAddress = serial->port[0]->interrupt_in_endpointAddress;
+               serial->port[i]->interrupt_in_endpointAddress =
+                               serial->port[0]->interrupt_in_endpointAddress;
 
                mos7720_port->port = serial->port[i];
                usb_set_serial_port_data(serial->port[i], mos7720_port);
@@ -1555,13 +1541,15 @@ static int mos7720_startup(struct usb_serial *serial)
 
        /* setting configuration feature to one */
        usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
-                       (__u8)0x03, 0x00,0x01,0x00, NULL, 0x00, 5*HZ);
+                       (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5*HZ);
 
-       send_mos_cmd(serial,MOS_READ,0x00, UART_LSR, &data);  // LSR For Port 1
-       dbg("LSR:%x",data);
+       /* LSR For Port 1 */
+       send_mos_cmd(serial, MOS_READ, 0x00, UART_LSR, &data);
+       dbg("LSR:%x", data);
 
-       send_mos_cmd(serial,MOS_READ,0x01, UART_LSR, &data);  // LSR For Port 2
-       dbg("LSR:%x",data);
+       /* LSR For Port 2 */
+       send_mos_cmd(serial, MOS_READ, 0x01, UART_LSR, &data);
+       dbg("LSR:%x", data);
 
        return 0;
 }
@@ -1571,7 +1559,7 @@ static void mos7720_shutdown(struct usb_serial *serial)
        int i;
 
        /* free private structure allocated for serial port */
-       for (i=0; i < serial->num_ports; ++i) {
+       for (i = 0; i < serial->num_ports; ++i) {
                kfree(usb_get_serial_port_data(serial->port[i]));
                usb_set_serial_port_data(serial->port[i], NULL);
        }
@@ -1651,8 +1639,8 @@ module_init(moschip7720_init);
 module_exit(moschip7720_exit);
 
 /* Module information */
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index 78f2f6d..09d8206 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/serial.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 
 /*
  * Version Information
@@ -82,8 +82,8 @@
  * Defines used for sending commands to port
  */
 
-#define WAIT_FOR_EVER   (HZ * 0 )      /* timeout urb is wait for ever */
-#define MOS_WDR_TIMEOUT (HZ * 5 )      /* default urb timeout */
+#define WAIT_FOR_EVER   (HZ * 0      /* timeout urb is wait for ever */
+#define MOS_WDR_TIMEOUT (HZ * 5      /* default urb timeout */
 
 #define MOS_PORT1       0x0200
 #define MOS_PORT2       0x0300
 
 #define MAX_NAME_LEN    64
 
-#define ZLP_REG1  0x3A         //Zero_Flag_Reg1    58
-#define ZLP_REG5  0x3E         //Zero_Flag_Reg5    62
+#define ZLP_REG1  0x3A         /* Zero_Flag_Reg1    58 */
+#define ZLP_REG5  0x3E         /* Zero_Flag_Reg5    62 */
 
 /* For higher baud Rates use TIOCEXBAUD */
 #define TIOCEXBAUD     0x5462
 #define MOS_MSR_DELTA_RI    0x40
 #define MOS_MSR_DELTA_CD    0x80
 
-// Serial Port register Address
+/* Serial Port register Address */
 #define INTERRUPT_ENABLE_REGISTER  ((__u16)(0x01))
 #define FIFO_CONTROL_REGISTER      ((__u16)(0x02))
 #define LINE_CONTROL_REGISTER      ((__u16)(0x03))
@@ -201,11 +201,11 @@ struct moschip_port {
        struct async_icount icount;
        struct usb_serial_port *port;   /* loop back to the owner of this object */
 
-       /*Offsets */
+       /* Offsets */
        __u8 SpRegOffset;
        __u8 ControlRegOffset;
        __u8 DcrRegOffset;
-       //for processing control URBS in interrupt context
+       /* for processing control URBS in interrupt context */
        struct urb *control_urb;
        struct usb_ctrlrequest *dr;
        char *ctrl_buf;
@@ -244,7 +244,7 @@ static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg,
  */
 
 static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg,
-                               __u16 * val)
+                               __u16 *val)
 {
        struct usb_device *dev = port->serial->dev;
        int ret = 0;
@@ -269,16 +269,15 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg,
 
        struct usb_device *dev = port->serial->dev;
        val = val & 0x00ff;
-       // For the UART control registers, the application number need to be Or'ed
+       /* For the UART control registers, the application number need
+          to be Or'ed */
        if (port->serial->num_ports == 4) {
-               val |=
-                   (((__u16) port->number - (__u16) (port->serial->minor)) +
-                    1) << 8;
+               val |= (((__u16) port->number -
+                               (__u16) (port->serial->minor)) + 1) << 8;
                dbg("mos7840_set_uart_reg application number is %x\n", val);
        } else {
                if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
-                       val |=
-                           (((__u16) port->number -
+                       val |= (((__u16) port->number -
                              (__u16) (port->serial->minor)) + 1) << 8;
                        dbg("mos7840_set_uart_reg application number is %x\n",
                            val);
@@ -302,14 +301,15 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg,
  *     by passing usb_rcvctrlpipe function as parameter.
  */
 static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
-                               __u16 * val)
+                               __u16 *val)
 {
        struct usb_device *dev = port->serial->dev;
        int ret = 0;
        __u16 Wval;
 
-       //dbg("application number is %4x \n",(((__u16)port->number - (__u16)(port->serial->minor))+1)<<8);
-       /*Wval  is same as application number */
+       /* dbg("application number is %4x \n",
+           (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */
+       /* Wval  is same as application number */
        if (port->serial->num_ports == 4) {
                Wval =
                    (((__u16) port->number - (__u16) (port->serial->minor)) +
@@ -317,14 +317,12 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
                dbg("mos7840_get_uart_reg application number is %x\n", Wval);
        } else {
                if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
-                       Wval =
-                           (((__u16) port->number -
+                       Wval = (((__u16) port->number -
                              (__u16) (port->serial->minor)) + 1) << 8;
                        dbg("mos7840_get_uart_reg application number is %x\n",
                            Wval);
                } else {
-                       Wval =
-                           (((__u16) port->number -
+                       Wval = (((__u16) port->number -
                              (__u16) (port->serial->minor)) + 2) << 8;
                        dbg("mos7840_get_uart_reg application number is %x\n",
                            Wval);
@@ -406,11 +404,11 @@ static void mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr)
        dbg("%s - %02x", __func__, new_lsr);
 
        if (new_lsr & SERIAL_LSR_BI) {
-               //
-               // Parity and Framing errors only count if they
-               // occur exclusive of a break being
-               // received.
-               //
+               /*
+                * Parity and Framing errors only count if they
+                * occur exclusive of a break being
+                * received.
+                */
                new_lsr &= (__u8) (SERIAL_LSR_OE | SERIAL_LSR_BI);
        }
 
@@ -492,7 +490,7 @@ exit:
 }
 
 static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
-                          __u16 * val)
+                          __u16 *val)
 {
        struct usb_device *dev = mcs->port->serial->dev;
        struct usb_ctrlrequest *dr = mcs->dr;
@@ -501,7 +499,7 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
 
        dr->bRequestType = MCS_RD_RTYPE;
        dr->bRequest = MCS_RDREQ;
-       dr->wValue = cpu_to_le16(Wval); //0;
+       dr->wValue = cpu_to_le16(Wval); /* 0 */
        dr->wIndex = cpu_to_le16(reg);
        dr->wLength = cpu_to_le16(2);
 
@@ -607,7 +605,8 @@ static void mos7840_interrupt_callback(struct urb *urb)
                        }
                }
        }
-       if (!(rv < 0)) /* the completion handler for the control urb will resubmit */
+       if (!(rv < 0))
+               /* the completion handler for the control urb will resubmit */
                return;
 exit:
        result = usb_submit_urb(urb, GFP_ATOMIC);
@@ -656,8 +655,8 @@ static struct usb_serial *mos7840_get_usb_serial(struct usb_serial_port *port,
        if (!port ||
            mos7840_port_paranoia_check(port, function) ||
            mos7840_serial_paranoia_check(port->serial, function)) {
-               /* then say that we don't have a valid usb_serial thing, which will
-                * end up genrating -ENODEV return values */
+               /* then say that we don't have a valid usb_serial thing,
+                * which will end up genrating -ENODEV return values */
                return NULL;
        }
 
@@ -710,7 +709,7 @@ static void mos7840_bulk_in_callback(struct urb *urb)
        dbg("%s", "Entering ........... \n");
 
        if (urb->actual_length) {
-               tty = mos7840_port->port->tty;
+               tty = mos7840_port->port->port.tty;
                if (tty) {
                        tty_buffer_request_room(tty, urb->actual_length);
                        tty_insert_flip_string(tty, data, urb->actual_length);
@@ -741,8 +740,8 @@ static void mos7840_bulk_in_callback(struct urb *urb)
 
 /*****************************************************************************
  * mos7840_bulk_out_data_callback
- *     this is the callback function for when we have finished sending serial data
- *     on the bulk out endpoint.
+ *     this is the callback function for when we have finished sending
+ *     serial data on the bulk out endpoint.
  *****************************************************************************/
 
 static void mos7840_bulk_out_data_callback(struct urb *urb)
@@ -774,7 +773,7 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
 
        dbg("%s \n", "Entering .........");
 
-       tty = mos7840_port->port->tty;
+       tty = mos7840_port->port->port.tty;
 
        if (tty && mos7840_port->open)
                tty_wakeup(tty);
@@ -804,7 +803,8 @@ static int mos7840_serial_probe(struct usb_serial *serial,
  *     Otherwise we return a negative error number.
  *****************************************************************************/
 
-static int mos7840_open(struct usb_serial_port *port, struct file *filp)
+static int mos7840_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        int response;
        int j;
@@ -847,7 +847,8 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
                        continue;
                }
 
-               urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
+               urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
+                                                               GFP_KERNEL);
                if (!urb->transfer_buffer) {
                        usb_free_urb(urb);
                        mos7840_port->write_urb_pool[j] = NULL;
@@ -868,9 +869,8 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
  * 0x08 : SP1/2 Control Reg
  *****************************************************************************/
 
-//NEED to check the following Block
+       /* NEED to check the following Block */
 
-       status = 0;
        Data = 0x0;
        status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
        if (status < 0) {
@@ -890,36 +890,35 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
                dbg("writing Spreg failed\n");
                return -1;
        }
-//End of block to be checked
+       /* End of block to be checked */
 
-       status = 0;
        Data = 0x0;
-       status =
-           mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data);
+       status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset,
+                                                                       &Data);
        if (status < 0) {
                dbg("Reading Controlreg failed\n");
                return -1;
        }
-       Data |= 0x08;           //Driver done bit
-       Data |= 0x20;           //rx_disable
-       status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data);
+       Data |= 0x08;           /* Driver done bit */
+       Data |= 0x20;           /* rx_disable */
+       status = mos7840_set_reg_sync(port,
+                               mos7840_port->ControlRegOffset, Data);
        if (status < 0) {
                dbg("writing Controlreg failed\n");
                return -1;
        }
-       //do register settings here
-       // Set all regs to the device default values.
-       ////////////////////////////////////
-       // First Disable all interrupts.
-       ////////////////////////////////////
-
+       /* do register settings here */
+       /* Set all regs to the device default values. */
+       /***********************************
+        * First Disable all interrupts.
+        ***********************************/
        Data = 0x00;
        status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
        if (status < 0) {
                dbg("disableing interrupts failed\n");
                return -1;
        }
-       // Set FIFO_CONTROL_REGISTER to the default value
+       /* Set FIFO_CONTROL_REGISTER to the default value */
        Data = 0x00;
        status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
        if (status < 0) {
@@ -946,90 +945,73 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
        status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
        mos7840_port->shadowLCR = Data;
 
-       Data |= SERIAL_LCR_DLAB;        //data latch enable in LCR 0x80
+       Data |= SERIAL_LCR_DLAB;        /* data latch enable in LCR 0x80 */
        status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
 
        Data = 0x0c;
-       status = 0;
        status = mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data);
 
        Data = 0x0;
-       status = 0;
        status = mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data);
 
        Data = 0x00;
-       status = 0;
        status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
 
        Data = Data & ~SERIAL_LCR_DLAB;
-       status = 0;
        status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
        mos7840_port->shadowLCR = Data;
 
-       //clearing Bulkin and Bulkout Fifo
+       /* clearing Bulkin and Bulkout Fifo */
        Data = 0x0;
-       status = 0;
        status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
 
        Data = Data | 0x0c;
-       status = 0;
        status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
 
        Data = Data & ~0x0c;
-       status = 0;
        status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
-       //Finally enable all interrupts
-       Data = 0x0;
+       /* Finally enable all interrupts */
        Data = 0x0c;
-       status = 0;
        status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
 
-       //clearing rx_disable
+       /* clearing rx_disable */
        Data = 0x0;
-       status = 0;
-       status =
-           mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data);
+       status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset,
+                                                                       &Data);
        Data = Data & ~0x20;
-       status = 0;
-       status =
-           mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data);
+       status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset,
+                                                                       Data);
 
-       // rx_negate
+       /* rx_negate */
        Data = 0x0;
-       status = 0;
-       status =
-           mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data);
+       status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset,
+                                                                       &Data);
        Data = Data | 0x10;
-       status = 0;
-       status =
-           mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data);
+       status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset,
+                                                                       Data);
 
        /* force low_latency on so that our tty_push actually forces *
         * the data through,otherwise it is scheduled, and with      *
         * high data rates (like with OHCI) data can get lost.       */
+       if (tty)
+               tty->low_latency = 1;
 
-       if (port->tty)
-               port->tty->low_latency = 1;
-/* Check to see if we've set up our endpoint info yet    *
-     * (can't set it up in mos7840_startup as the structures *
-     * were not set up at that time.)                        */
+       /* Check to see if we've set up our endpoint info yet    *
+        * (can't set it up in mos7840_startup as the structures *
+        * were not set up at that time.)                        */
        if (port0->open_ports == 1) {
                if (serial->port[0]->interrupt_in_buffer == NULL) {
-
                        /* set up interrupt urb */
-
                        usb_fill_int_urb(serial->port[0]->interrupt_in_urb,
-                                        serial->dev,
-                                        usb_rcvintpipe(serial->dev,
-                                                       serial->port[0]->
-                                                       interrupt_in_endpointAddress),
-                                        serial->port[0]->interrupt_in_buffer,
-                                        serial->port[0]->interrupt_in_urb->
-                                        transfer_buffer_length,
-                                        mos7840_interrupt_callback,
-                                        serial,
-                                        serial->port[0]->interrupt_in_urb->
-                                        interval);
+                               serial->dev,
+                               usb_rcvintpipe(serial->dev,
+                               serial->port[0]->interrupt_in_endpointAddress),
+                               serial->port[0]->interrupt_in_buffer,
+                               serial->port[0]->interrupt_in_urb->
+                               transfer_buffer_length,
+                               mos7840_interrupt_callback,
+                               serial,
+                               serial->port[0]->interrupt_in_urb->interval);
 
                        /* start interrupt read for mos7840               *
                         * will continue as long as mos7840 is connected  */
@@ -1084,14 +1066,16 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
        memset(&(mos7840_port->icount), 0x00, sizeof(mos7840_port->icount));
 
        /* initialize our port settings */
-       mos7840_port->shadowMCR = MCR_MASTER_IE;        /* Must set to enable ints! */
+       /* Must set to enable ints! */
+       mos7840_port->shadowMCR = MCR_MASTER_IE;
        /* send a open port command */
        mos7840_port->open = 1;
-       //mos7840_change_port_settings(mos7840_port,old_termios);
+       /* mos7840_change_port_settings(mos7840_port,old_termios); */
        mos7840_port->icount.tx = 0;
        mos7840_port->icount.rx = 0;
 
-       dbg("\n\nusb_serial serial:%p       mos7840_port:%p\n      usb_serial_port port:%p\n\n", serial, mos7840_port, port);
+       dbg("\n\nusb_serial serial:%p       mos7840_port:%p\n      usb_serial_port port:%p\n\n",
+                               serial, mos7840_port, port);
 
        return 0;
 
@@ -1104,11 +1088,12 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
  *     been written, but hasn't made it out the port yet)
  *     If successful, we return the number of bytes left to be written in the
  *     system,
- *     Otherwise we return a negative error number.
+ *     Otherwise we return zero.
  *****************************************************************************/
 
-static int mos7840_chars_in_buffer(struct usb_serial_port *port)
+static int mos7840_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        int i;
        int chars = 0;
        unsigned long flags;
@@ -1118,22 +1103,20 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port)
 
        if (mos7840_port_paranoia_check(port, __func__)) {
                dbg("%s", "Invalid port \n");
-               return -1;
+               return 0;
        }
 
        mos7840_port = mos7840_get_port_private(port);
        if (mos7840_port == NULL) {
                dbg("%s \n", "mos7840_break:leaving ...........");
-               return -1;
+               return 0;
        }
 
-       spin_lock_irqsave(&mos7840_port->pool_lock,flags);
-       for (i = 0; i < NUM_URBS; ++i) {
-               if (mos7840_port->busy[i]) {
+       spin_lock_irqsave(&mos7840_port->pool_lock, flags);
+       for (i = 0; i < NUM_URBS; ++i)
+               if (mos7840_port->busy[i])
                        chars += URB_TRANSFER_BUFFER_SIZE;
-               }
-       }
-       spin_unlock_irqrestore(&mos7840_port->pool_lock,flags);
+       spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
        dbg("%s - returns %d", __func__, chars);
        return chars;
 
@@ -1149,7 +1132,8 @@ static int mos7840_chars_in_buffer(struct usb_serial_port *port)
  *             3. A timeout of 3 seconds without activity has expired
  *
  ************************************************************************/
-static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port)
+static void mos7840_block_until_tx_empty(struct tty_struct *tty,
+                               struct moschip_port *mos7840_port)
 {
        int timeout = HZ / 10;
        int wait = 30;
@@ -1157,12 +1141,11 @@ static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port)
 
        while (1) {
 
-               count = mos7840_chars_in_buffer(mos7840_port->port);
+               count = mos7840_chars_in_buffer(tty);
 
                /* Check for Buffer status */
-               if (count <= 0) {
+               if (count <= 0)
                        return;
-               }
 
                /* Block the thread for a while */
                interruptible_sleep_on_timeout(&mos7840_port->wait_chase,
@@ -1185,7 +1168,8 @@ static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port)
  *     this function is called by the tty driver when a port is closed
  *****************************************************************************/
 
-static void mos7840_close(struct usb_serial_port *port, struct file *filp)
+static void mos7840_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial *serial;
        struct moschip_port *mos7840_port;
@@ -1226,32 +1210,28 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
                }
        }
 
-       if (serial->dev) {
+       if (serial->dev)
                /* flush and block until tx is empty */
-               mos7840_block_until_tx_empty(mos7840_port);
-       }
+               mos7840_block_until_tx_empty(tty, mos7840_port);
 
        /* While closing port, shutdown all bulk read, write  *
         * and interrupt read if they exists                  */
        if (serial->dev) {
-
                if (mos7840_port->write_urb) {
                        dbg("%s", "Shutdown bulk write\n");
                        usb_kill_urb(mos7840_port->write_urb);
                }
-
                if (mos7840_port->read_urb) {
                        dbg("%s", "Shutdown bulk read\n");
                        usb_kill_urb(mos7840_port->read_urb);
                }
                if ((&mos7840_port->control_urb)) {
                        dbg("%s", "Shutdown control read\n");
-                       //      usb_kill_urb (mos7840_port->control_urb);
-
+                       /*/      usb_kill_urb (mos7840_port->control_urb); */
                }
        }
-//              if(mos7840_port->ctrl_buf != NULL)
-//                      kfree(mos7840_port->ctrl_buf);
+/*      if(mos7840_port->ctrl_buf != NULL) */
+/*              kfree(mos7840_port->ctrl_buf); */
        port0->open_ports--;
        dbg("mos7840_num_open_ports in close%d:in port%d\n",
            port0->open_ports, port->number);
@@ -1264,10 +1244,8 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
 
        if (mos7840_port->write_urb) {
                /* if this urb had a transfer buffer already (old tx) free it */
-
-               if (mos7840_port->write_urb->transfer_buffer != NULL) {
+               if (mos7840_port->write_urb->transfer_buffer != NULL)
                        kfree(mos7840_port->write_urb->transfer_buffer);
-               }
                usb_free_urb(mos7840_port->write_urb);
        }
 
@@ -1293,20 +1271,19 @@ static void mos7840_close(struct usb_serial_port *port, struct file *filp)
  *
  ************************************************************************/
 
-static void mos7840_block_until_chase_response(struct moschip_port
-                                              *mos7840_port)
+static void mos7840_block_until_chase_response(struct tty_struct *tty,
+                                       struct moschip_port *mos7840_port)
 {
        int timeout = 1 * HZ;
        int wait = 10;
        int count;
 
        while (1) {
-               count = mos7840_chars_in_buffer(mos7840_port->port);
+               count = mos7840_chars_in_buffer(tty);
 
                /* Check for Buffer status */
-               if (count <= 0) {
+               if (count <= 0)
                        return;
-               }
 
                /* Block the thread for a while */
                interruptible_sleep_on_timeout(&mos7840_port->wait_chase,
@@ -1328,8 +1305,9 @@ static void mos7840_block_until_chase_response(struct moschip_port
  * mos7840_break
  *     this function sends a break to the port
  *****************************************************************************/
-static void mos7840_break(struct usb_serial_port *port, int break_state)
+static void mos7840_break(struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        unsigned char data;
        struct usb_serial *serial;
        struct moschip_port *mos7840_port;
@@ -1350,21 +1328,17 @@ static void mos7840_break(struct usb_serial_port *port, int break_state)
 
        mos7840_port = mos7840_get_port_private(port);
 
-       if (mos7840_port == NULL) {
+       if (mos7840_port == NULL)
                return;
-       }
-
-       if (serial->dev) {
 
+       if (serial->dev)
                /* flush and block until tx is empty */
-               mos7840_block_until_chase_response(mos7840_port);
-       }
+               mos7840_block_until_chase_response(tty, mos7840_port);
 
-       if (break_state == -1) {
+       if (break_state == -1)
                data = mos7840_port->shadowLCR | LCR_SET_BREAK;
-       } else {
+       else
                data = mos7840_port->shadowLCR & ~LCR_SET_BREAK;
-       }
 
        mos7840_port->shadowLCR = data;
        dbg("mcs7840_break mos7840_port->shadowLCR is %x\n",
@@ -1383,8 +1357,9 @@ static void mos7840_break(struct usb_serial_port *port, int break_state)
  *     Otherwise we return a negative error number.
  *****************************************************************************/
 
-static int mos7840_write_room(struct usb_serial_port *port)
+static int mos7840_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        int i;
        int room = 0;
        unsigned long flags;
@@ -1406,9 +1381,8 @@ static int mos7840_write_room(struct usb_serial_port *port)
 
        spin_lock_irqsave(&mos7840_port->pool_lock, flags);
        for (i = 0; i < NUM_URBS; ++i) {
-               if (!mos7840_port->busy[i]) {
+               if (!mos7840_port->busy[i])
                        room += URB_TRANSFER_BUFFER_SIZE;
-               }
        }
        spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
 
@@ -1426,7 +1400,7 @@ static int mos7840_write_room(struct usb_serial_port *port)
  *      return a negative error number.
  *****************************************************************************/
 
-static int mos7840_write(struct usb_serial_port *port,
+static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
                         const unsigned char *data, int count)
 {
        int status;
@@ -1438,45 +1412,41 @@ static int mos7840_write(struct usb_serial_port *port,
        struct moschip_port *mos7840_port;
        struct usb_serial *serial;
        struct urb *urb;
-       //__u16 Data;
+       /* __u16 Data; */
        const unsigned char *current_position = data;
        unsigned char *data1;
        dbg("%s \n", "entering ...........");
-       //dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",mos7840_port->shadowLCR);
+       /* dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
+                                       mos7840_port->shadowLCR); */
 
 #ifdef NOTMOS7840
        Data = 0x00;
-       status = 0;
        status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
        mos7840_port->shadowLCR = Data;
        dbg("mos7840_write: LINE_CONTROL_REGISTER is %x\n", Data);
        dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
            mos7840_port->shadowLCR);
 
-       //Data = 0x03;
-       //status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data);
-       //mos7840_port->shadowLCR=Data;//Need to add later
+       /* Data = 0x03; */
+       /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */
+       /* mos7840_port->shadowLCR=Data;//Need to add later */
 
-       Data |= SERIAL_LCR_DLAB;        //data latch enable in LCR 0x80
-       status = 0;
+       Data |= SERIAL_LCR_DLAB;        /* data latch enable in LCR 0x80 */
        status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
 
-       //Data = 0x0c;
-       //status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data);
+       /* Data = 0x0c; */
+       /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */
        Data = 0x00;
-       status = 0;
        status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data);
        dbg("mos7840_write:DLL value is %x\n", Data);
 
        Data = 0x0;
-       status = 0;
        status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data);
        dbg("mos7840_write:DLM value is %x\n", Data);
 
        Data = Data & ~SERIAL_LCR_DLAB;
        dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
            mos7840_port->shadowLCR);
-       status = 0;
        status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
 #endif
 
@@ -1555,8 +1525,7 @@ static int mos7840_write(struct usb_serial_port *port,
        mos7840_port->icount.tx += transfer_size;
        smp_wmb();
        dbg("mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx);
-      exit:
-
+exit:
        return bytes_sent;
 
 }
@@ -1567,10 +1536,10 @@ static int mos7840_write(struct usb_serial_port *port,
  *     being read from the port.
  *****************************************************************************/
 
-static void mos7840_throttle(struct usb_serial_port *port)
+static void mos7840_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct moschip_port *mos7840_port;
-       struct tty_struct *tty;
        int status;
 
        if (mos7840_port_paranoia_check(port, __func__)) {
@@ -1592,32 +1561,20 @@ static void mos7840_throttle(struct usb_serial_port *port)
 
        dbg("%s", "Entering .......... \n");
 
-       tty = port->tty;
-       if (!tty) {
-               dbg("%s - no tty available", __func__);
-               return;
-       }
-
        /* if we are implementing XON/XOFF, send the stop character */
        if (I_IXOFF(tty)) {
                unsigned char stop_char = STOP_CHAR(tty);
-               status = mos7840_write(port, &stop_char, 1);
-               if (status <= 0) {
+               status = mos7840_write(tty, port, &stop_char, 1);
+               if (status <= 0)
                        return;
-               }
        }
-
        /* if we are implementing RTS/CTS, toggle that line */
        if (tty->termios->c_cflag & CRTSCTS) {
                mos7840_port->shadowMCR &= ~MCR_RTS;
-               status = 0;
-               status =
-                   mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
+               status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
                                         mos7840_port->shadowMCR);
-
-               if (status < 0) {
+               if (status < 0)
                        return;
-               }
        }
 
        return;
@@ -1625,12 +1582,13 @@ static void mos7840_throttle(struct usb_serial_port *port)
 
 /*****************************************************************************
  * mos7840_unthrottle
- *     this function is called by the tty driver when it wants to resume the data
- *     being read from the port (called after SerialThrottle is called)
+ *     this function is called by the tty driver when it wants to resume
+ *     the data being read from the port (called after mos7840_throttle is
+ *     called)
  *****************************************************************************/
-static void mos7840_unthrottle(struct usb_serial_port *port)
+static void mos7840_unthrottle(struct tty_struct *tty)
 {
-       struct tty_struct *tty;
+       struct usb_serial_port *port = tty->driver_data;
        int status;
        struct moschip_port *mos7840_port = mos7840_get_port_private(port);
 
@@ -1649,43 +1607,32 @@ static void mos7840_unthrottle(struct usb_serial_port *port)
 
        dbg("%s", "Entering .......... \n");
 
-       tty = port->tty;
-       if (!tty) {
-               dbg("%s - no tty available", __func__);
-               return;
-       }
-
        /* if we are implementing XON/XOFF, send the start character */
        if (I_IXOFF(tty)) {
                unsigned char start_char = START_CHAR(tty);
-               status = mos7840_write(port, &start_char, 1);
-               if (status <= 0) {
+               status = mos7840_write(tty, port, &start_char, 1);
+               if (status <= 0)
                        return;
-               }
        }
 
        /* if we are implementing RTS/CTS, toggle that line */
        if (tty->termios->c_cflag & CRTSCTS) {
                mos7840_port->shadowMCR |= MCR_RTS;
-               status = 0;
-               status =
-                   mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
+               status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
                                         mos7840_port->shadowMCR);
-               if (status < 0) {
+               if (status < 0)
                        return;
-               }
        }
-
-       return;
 }
 
-static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file)
+static int mos7840_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct moschip_port *mos7840_port;
        unsigned int result;
        __u16 msr;
        __u16 mcr;
-       int status = 0;
+       int status;
        mos7840_port = mos7840_get_port_private(port);
 
        dbg("%s - port %d", __func__, port->number);
@@ -1708,9 +1655,10 @@ static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file)
        return result;
 }
 
-static int mos7840_tiocmset(struct usb_serial_port *port, struct file *file,
+static int mos7840_tiocmset(struct tty_struct *tty, struct file *file,
                            unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct moschip_port *mos7840_port;
        unsigned int mcr;
        int status;
@@ -1755,7 +1703,7 @@ static int mos7840_tiocmset(struct usb_serial_port *port, struct file *file,
  *     baud rate.
  *****************************************************************************/
 static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor,
-                                         __u16 * clk_sel_val)
+                                         __u16 *clk_sel_val)
 {
 
        dbg("%s - %d", __func__, baudRate);
@@ -1807,9 +1755,8 @@ static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor,
                /* Check for round off */
                round1 = (__u16) (2304000L / baudrate);
                round = (__u16) (round1 - (custom * 10));
-               if (round > 4) {
+               if (round > 4)
                        custom++;
-               }
                *divisor = custom;
 
                dbg(" Baud %d = %d\n", baudrate, custom);
@@ -1857,16 +1804,15 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
 
        dbg("%s - port = %d, baud = %d", __func__,
            mos7840_port->port->number, baudRate);
-       //reset clk_uart_sel in spregOffset
+       /* reset clk_uart_sel in spregOffset */
        if (baudRate > 115200) {
 #ifdef HW_flow_control
-               //NOTE: need to see the pther register to modify
-               //setting h/w flow control bit to 1;
-               status = 0;
+               /* NOTE: need to see the pther register to modify */
+               /* setting h/w flow control bit to 1 */
                Data = 0x2b;
                mos7840_port->shadowMCR = Data;
-               status =
-                   mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
+               status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
+                                                                       Data);
                if (status < 0) {
                        dbg("Writing spreg failed in set_serial_baud\n");
                        return -1;
@@ -1875,12 +1821,11 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
 
        } else {
 #ifdef HW_flow_control
-               //setting h/w flow control bit to 0;
-               status = 0;
+               / *setting h/w flow control bit to 0 */
                Data = 0xb;
                mos7840_port->shadowMCR = Data;
-               status =
-                   mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
+               status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
+                                                                       Data);
                if (status < 0) {
                        dbg("Writing spreg failed in set_serial_baud\n");
                        return -1;
@@ -1889,25 +1834,20 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
 
        }
 
-       if (1)                  //baudRate <= 115200)
-       {
+       if (1) {                /* baudRate <= 115200) */
                clk_sel_val = 0x0;
                Data = 0x0;
-               status = 0;
-               status =
-                   mos7840_calc_baud_rate_divisor(baudRate, &divisor,
+               status = mos7840_calc_baud_rate_divisor(baudRate, &divisor,
                                                   &clk_sel_val);
-               status =
-                   mos7840_get_reg_sync(port, mos7840_port->SpRegOffset,
-                                        &Data);
+               status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset,
+                                                                &Data);
                if (status < 0) {
                        dbg("reading spreg failed in set_serial_baud\n");
                        return -1;
                }
                Data = (Data & 0x8f) | clk_sel_val;
-               status = 0;
-               status =
-                   mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
+               status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset,
+                                                               Data);
                if (status < 0) {
                        dbg("Writing spreg failed in set_serial_baud\n");
                        return -1;
@@ -1939,7 +1879,6 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
                mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
 
        }
-
        return status;
 }
 
@@ -1949,10 +1888,9 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
  *      the specified new settings.
  *****************************************************************************/
 
-static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
-                                        struct ktermios *old_termios)
+static void mos7840_change_port_settings(struct tty_struct *tty,
+       struct moschip_port *mos7840_port, struct ktermios *old_termios)
 {
-       struct tty_struct *tty;
        int baud;
        unsigned cflag;
        unsigned iflag;
@@ -1988,8 +1926,6 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
                return;
        }
 
-       tty = mos7840_port->port->tty;
-
        dbg("%s", "Entering .......... \n");
 
        lData = LCR_BITS_8;
@@ -2033,9 +1969,8 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
                dbg("%s - parity = none", __func__);
        }
 
-       if (cflag & CMSPAR) {
+       if (cflag & CMSPAR)
                lParity = lParity | 0x20;
-       }
 
        /* Change the Stop bit */
        if (cflag & CSTOPB) {
@@ -2077,16 +2012,13 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
        /* set up the MCR register and send it to the mos7840 */
 
        mos7840_port->shadowMCR = MCR_MASTER_IE;
-       if (cflag & CBAUD) {
+       if (cflag & CBAUD)
                mos7840_port->shadowMCR |= (MCR_DTR | MCR_RTS);
-       }
 
-       if (cflag & CRTSCTS) {
+       if (cflag & CRTSCTS)
                mos7840_port->shadowMCR |= (MCR_XON_ANY);
-
-       } else {
+       else
                mos7840_port->shadowMCR &= ~(MCR_XON_ANY);
-       }
 
        Data = mos7840_port->shadowMCR;
        mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
@@ -2131,14 +2063,14 @@ static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
  *     the termios structure
  *****************************************************************************/
 
-static void mos7840_set_termios(struct usb_serial_port *port,
+static void mos7840_set_termios(struct tty_struct *tty,
+                               struct usb_serial_port *port,
                                struct ktermios *old_termios)
 {
        int status;
        unsigned int cflag;
        struct usb_serial *serial;
        struct moschip_port *mos7840_port;
-       struct tty_struct *tty;
        dbg("mos7840_set_termios: START\n");
        if (mos7840_port_paranoia_check(port, __func__)) {
                dbg("%s", "Invalid port \n");
@@ -2157,8 +2089,6 @@ static void mos7840_set_termios(struct usb_serial_port *port,
        if (mos7840_port == NULL)
                return;
 
-       tty = port->tty;
-
        if (!mos7840_port->open) {
                dbg("%s - port not opened", __func__);
                return;
@@ -2176,7 +2106,7 @@ static void mos7840_set_termios(struct usb_serial_port *port,
 
        /* change the port settings to the new ones specified */
 
-       mos7840_change_port_settings(mos7840_port, old_termios);
+       mos7840_change_port_settings(tty, mos7840_port, old_termios);
 
        if (!mos7840_port->read_urb) {
                dbg("%s", "URB KILLED !!!!!\n");
@@ -2205,13 +2135,13 @@ static void mos7840_set_termios(struct usb_serial_port *port,
  *         allows an RS485 driver to be written in user space.
  *****************************************************************************/
 
-static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
+static int mos7840_get_lsr_info(struct tty_struct *tty,
                                unsigned int __user *value)
 {
        int count;
        unsigned int result = 0;
 
-       count = mos7840_chars_in_buffer(mos7840_port->port);
+       count = mos7840_chars_in_buffer(tty);
        if (count == 0) {
                dbg("%s -- Empty", __func__);
                result = TIOCSER_TEMT;
@@ -2227,6 +2157,8 @@ static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
  *      function to set modem info
  *****************************************************************************/
 
+/* FIXME: Should be using the model control hooks */
+
 static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
                                  unsigned int cmd, unsigned int __user *value)
 {
@@ -2282,7 +2214,6 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
        mos7840_port->shadowMCR = mcr;
 
        Data = mos7840_port->shadowMCR;
-       status = 0;
        status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
        if (status < 0) {
                dbg("setting MODEM_CONTROL_REGISTER Failed\n");
@@ -2303,10 +2234,8 @@ static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
        unsigned int result = 0;
        __u16 msr;
        unsigned int mcr = mos7840_port->shadowMCR;
-       int status = 0;
-       status =
-           mos7840_get_uart_reg(mos7840_port->port, MODEM_STATUS_REGISTER,
-                                &msr);
+        mos7840_get_uart_reg(mos7840_port->port,
+                                               MODEM_STATUS_REGISTER, &msr);
        result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0)      /* 0x002 */
            |((mcr & MCR_RTS) ? TIOCM_RTS : 0)  /* 0x004 */
            |((msr & MOS7840_MSR_CTS) ? TIOCM_CTS : 0)  /* 0x020 */
@@ -2359,12 +2288,12 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
  *     this function handles any ioctl calls to the driver
  *****************************************************************************/
 
-static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
+static int mos7840_ioctl(struct tty_struct *tty, struct file *file,
                         unsigned int cmd, unsigned long arg)
 {
+       struct usb_serial_port *port = tty->driver_data;
        void __user *argp = (void __user *)arg;
        struct moschip_port *mos7840_port;
-       struct tty_struct *tty;
 
        struct async_icount cnow;
        struct async_icount cprev;
@@ -2381,8 +2310,6 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
        if (mos7840_port == NULL)
                return -1;
 
-       tty = mos7840_port->port->tty;
-
        dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd);
 
        switch (cmd) {
@@ -2390,9 +2317,10 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
 
        case TIOCSERGETLSR:
                dbg("%s (%d) TIOCSERGETLSR", __func__, port->number);
-               return mos7840_get_lsr_info(mos7840_port, argp);
+               return mos7840_get_lsr_info(tty, argp);
                return 0;
 
+       /* FIXME: use the modem hooks and remove this */
        case TIOCMBIS:
        case TIOCMBIC:
        case TIOCMSET:
@@ -2418,7 +2346,7 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
                dbg("%s (%d) TIOCMIWAIT", __func__, port->number);
                cprev = mos7840_port->icount;
                while (1) {
-                       //interruptible_sleep_on(&mos7840_port->delta_msr_wait);
+                       /* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */
                        mos7840_port->delta_msr_cond = 0;
                        wait_event_interruptible(mos7840_port->delta_msr_wait,
                                                 (mos7840_port->
@@ -2463,13 +2391,9 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
                if (copy_to_user(argp, &icount, sizeof(icount)))
                        return -EFAULT;
                return 0;
-
-       case TIOCEXBAUD:
-               return 0;
        default:
                break;
        }
-
        return -ENOIOCTLCMD;
 }
 
@@ -2527,8 +2451,9 @@ static int mos7840_startup(struct usb_serial *serial)
                        goto error;
                }
 
-               /* Initialize all port interrupt end point to port 0 int endpoint *
-                * Our device has only one interrupt end point comman to all port */
+               /* Initialize all port interrupt end point to port 0 int
+                * endpoint. Our device has only one interrupt end point
+                * common to all port */
 
                mos7840_port->port = serial->port[i];
                mos7840_set_port_private(serial->port[i], mos7840_port);
@@ -2564,27 +2489,23 @@ static int mos7840_startup(struct usb_serial *serial)
                        mos7840_port->DcrRegOffset = 0x1c;
                }
                mos7840_dump_serial_port(mos7840_port);
-
                mos7840_set_port_private(serial->port[i], mos7840_port);
 
-               //enable rx_disable bit in control register
-
-               status =
-                   mos7840_get_reg_sync(serial->port[i],
-                                        mos7840_port->ControlRegOffset, &Data);
+               /* enable rx_disable bit in control register */
+               status = mos7840_get_reg_sync(serial->port[i],
+                                mos7840_port->ControlRegOffset, &Data);
                if (status < 0) {
                        dbg("Reading ControlReg failed status-0x%x\n", status);
                        break;
                } else
                        dbg("ControlReg Reading success val is %x, status%d\n",
                            Data, status);
-               Data |= 0x08;   //setting driver done bit
-               Data |= 0x04;   //sp1_bit to have cts change reflect in modem status reg
+               Data |= 0x08;   /* setting driver done bit */
+               Data |= 0x04;   /* sp1_bit to have cts change reflect in
+                                  modem status reg */
 
-               //Data |= 0x20; //rx_disable bit
-               status = 0;
-               status =
-                   mos7840_set_reg_sync(serial->port[i],
+               /* Data |= 0x20; //rx_disable bit */
+               status = mos7840_set_reg_sync(serial->port[i],
                                         mos7840_port->ControlRegOffset, Data);
                if (status < 0) {
                        dbg("Writing ControlReg failed(rx_disable) status-0x%x\n", status);
@@ -2593,13 +2514,11 @@ static int mos7840_startup(struct usb_serial *serial)
                        dbg("ControlReg Writing success(rx_disable) status%d\n",
                            status);
 
-               //Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 and 0x24 in DCR3
+               /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2
+                  and 0x24 in DCR3 */
                Data = 0x01;
-               status = 0;
-               status =
-                   mos7840_set_reg_sync(serial->port[i],
-                                        (__u16) (mos7840_port->DcrRegOffset +
-                                                 0), Data);
+               status = mos7840_set_reg_sync(serial->port[i],
+                        (__u16) (mos7840_port->DcrRegOffset + 0), Data);
                if (status < 0) {
                        dbg("Writing DCR0 failed status-0x%x\n", status);
                        break;
@@ -2607,11 +2526,8 @@ static int mos7840_startup(struct usb_serial *serial)
                        dbg("DCR0 Writing success status%d\n", status);
 
                Data = 0x05;
-               status = 0;
-               status =
-                   mos7840_set_reg_sync(serial->port[i],
-                                        (__u16) (mos7840_port->DcrRegOffset +
-                                                 1), Data);
+               status = mos7840_set_reg_sync(serial->port[i],
+                        (__u16) (mos7840_port->DcrRegOffset + 1), Data);
                if (status < 0) {
                        dbg("Writing DCR1 failed status-0x%x\n", status);
                        break;
@@ -2619,22 +2535,17 @@ static int mos7840_startup(struct usb_serial *serial)
                        dbg("DCR1 Writing success status%d\n", status);
 
                Data = 0x24;
-               status = 0;
-               status =
-                   mos7840_set_reg_sync(serial->port[i],
-                                        (__u16) (mos7840_port->DcrRegOffset +
-                                                 2), Data);
+               status = mos7840_set_reg_sync(serial->port[i],
+                        (__u16) (mos7840_port->DcrRegOffset + 2), Data);
                if (status < 0) {
                        dbg("Writing DCR2 failed status-0x%x\n", status);
                        break;
                } else
                        dbg("DCR2 Writing success status%d\n", status);
 
-               // write values in clkstart0x0 and clkmulti 0x20
+               /* write values in clkstart0x0 and clkmulti 0x20 */
                Data = 0x0;
-               status = 0;
-               status =
-                   mos7840_set_reg_sync(serial->port[i],
+               status = mos7840_set_reg_sync(serial->port[i],
                                         CLK_START_VALUE_REGISTER, Data);
                if (status < 0) {
                        dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status);
@@ -2643,9 +2554,8 @@ static int mos7840_startup(struct usb_serial *serial)
                        dbg("CLK_START_VALUE_REGISTER Writing success status%d\n", status);
 
                Data = 0x20;
-               status =
-                   mos7840_set_reg_sync(serial->port[i], CLK_MULTI_REGISTER,
-                                        Data);
+               status = mos7840_set_reg_sync(serial->port[i],
+                                       CLK_MULTI_REGISTER, Data);
                if (status < 0) {
                        dbg("Writing CLK_MULTI_REGISTER failed status-0x%x\n",
                            status);
@@ -2654,11 +2564,10 @@ static int mos7840_startup(struct usb_serial *serial)
                        dbg("CLK_MULTI_REGISTER Writing success status%d\n",
                            status);
 
-               //write value 0x0 to scratchpad register
+               /* write value 0x0 to scratchpad register */
                Data = 0x00;
-               status =
-                   mos7840_set_uart_reg(serial->port[i], SCRATCH_PAD_REGISTER,
-                                        Data);
+               status = mos7840_set_uart_reg(serial->port[i],
+                                               SCRATCH_PAD_REGISTER, Data);
                if (status < 0) {
                        dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x\n",
                            status);
@@ -2667,21 +2576,17 @@ static int mos7840_startup(struct usb_serial *serial)
                        dbg("SCRATCH_PAD_REGISTER Writing success status%d\n",
                            status);
 
-               //Zero Length flag register
+               /* Zero Length flag register */
                if ((mos7840_port->port_num != 1)
                    && (serial->num_ports == 2)) {
 
                        Data = 0xff;
-                       status = 0;
                        status = mos7840_set_reg_sync(serial->port[i],
-                                                     (__u16) (ZLP_REG1 +
-                                                              ((__u16)
-                                                               mos7840_port->
-                                                               port_num)),
-                                                     Data);
+                                     (__u16) (ZLP_REG1 +
+                                     ((__u16)mos7840_port->port_num)), Data);
                        dbg("ZLIP offset%x\n",
                            (__u16) (ZLP_REG1 +
-                                    ((__u16) mos7840_port->port_num)));
+                                       ((__u16) mos7840_port->port_num)));
                        if (status < 0) {
                                dbg("Writing ZLP_REG%d failed status-0x%x\n",
                                    i + 2, status);
@@ -2691,13 +2596,9 @@ static int mos7840_startup(struct usb_serial *serial)
                                    i + 2, status);
                } else {
                        Data = 0xff;
-                       status = 0;
                        status = mos7840_set_reg_sync(serial->port[i],
-                                                     (__u16) (ZLP_REG1 +
-                                                              ((__u16)
-                                                               mos7840_port->
-                                                               port_num) -
-                                                              0x1), Data);
+                             (__u16) (ZLP_REG1 +
+                             ((__u16)mos7840_port->port_num) - 0x1), Data);
                        dbg("ZLIP offset%x\n",
                            (__u16) (ZLP_REG1 +
                                     ((__u16) mos7840_port->port_num) - 0x1));
@@ -2712,14 +2613,16 @@ static int mos7840_startup(struct usb_serial *serial)
                }
                mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL);
                mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL);
-               mos7840_port->dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
-               if (!mos7840_port->control_urb || !mos7840_port->ctrl_buf || !mos7840_port->dr) {
+               mos7840_port->dr = kmalloc(sizeof(struct usb_ctrlrequest),
+                                                               GFP_KERNEL);
+               if (!mos7840_port->control_urb || !mos7840_port->ctrl_buf ||
+                                                       !mos7840_port->dr) {
                        status = -ENOMEM;
                        goto error;
                }
        }
 
-       //Zero Length flag enable
+       /* Zero Length flag enable */
        Data = 0x0f;
        status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data);
        if (status < 0) {
@@ -2762,7 +2665,7 @@ static void mos7840_shutdown(struct usb_serial *serial)
                return;
        }
 
-       /*      check for the ports to be closed,close the ports and disconnect         */
+       /* check for the ports to be closed,close the ports and disconnect */
 
        /* free private structure allocated for serial port  *
         * stop reads and writes on all ports                */
@@ -2843,20 +2746,12 @@ static int __init moschip7840_init(void)
 
        /* Register with the usb */
        retval = usb_register(&io_driver);
-
-       if (retval)
-               goto failed_usb_register;
-
        if (retval == 0) {
                dbg("%s\n", "Leaving...");
                return 0;
        }
-
-      failed_usb_register:
        usb_serial_deregister(&moschip7840_4port_device);
-
-      failed_port_device_register:
-
+failed_port_device_register:
        return retval;
 }
 
index 43c8894..d673653 100644 (file)
@@ -64,7 +64,7 @@ static void navman_read_int_callback(struct urb *urb)
        usb_serial_debug_data(debug, &port->dev, __func__,
                              urb->actual_length, data);
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (tty && urb->actual_length) {
                tty_buffer_request_room(tty, urb->actual_length);
                tty_insert_flip_string(tty, data, urb->actual_length);
@@ -79,7 +79,8 @@ exit:
                        __func__, result);
 }
 
-static int navman_open(struct usb_serial_port *port, struct file *filp)
+static int navman_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        int result = 0;
 
@@ -96,14 +97,15 @@ static int navman_open(struct usb_serial_port *port, struct file *filp)
        return result;
 }
 
-static void navman_close(struct usb_serial_port *port, struct file *filp)
+static void navman_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        dbg("%s - port %d", __func__, port->number);
 
        usb_kill_urb(port->interrupt_in_urb);
 }
 
-static int navman_write(struct usb_serial_port *port,
+static int navman_write(struct tty_struct *tty, struct usb_serial_port *port,
                        const unsigned char *buf, int count)
 {
        dbg("%s - port %d", __func__, port->number);
index 7b7422f..ae8e227 100644 (file)
@@ -5,26 +5,28 @@
  *     modify it under the terms of the GNU General Public License version
  *     2 as published by the Free Software Foundation.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  *
  * Please report both successes and troubles to the author at omninet@kroah.com
- * 
+ *
  * (05/30/2001) gkh
- *     switched from using spinlock to a semaphore, which fixes lots of problems.
+ *     switched from using spinlock to a semaphore, which fixes lots of
+ *     problems.
  *
  * (04/08/2001) gb
  *     Identify version on module load.
  *
  * (11/01/2000) Adam J. Richter
  *     usb_device_id table support
- * 
+ *
  * (10/05/2000) gkh
  *     Fixed bug with urb->dev not being set properly, now that the usb
  *     core needs it.
- * 
+ *
  * (08/28/2000) gkh
  *     Added locks for SMP safeness.
- *     Fixed MOD_INC and MOD_DEC logic and the ability to open a port more 
+ *     Fixed MOD_INC and MOD_DEC logic and the ability to open a port more
  *     than once.
  *     Fixed potential race in omninet_write_bulk_callback
  *
@@ -43,7 +45,7 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 
@@ -58,25 +60,29 @@ static int debug;
 
 #define ZYXEL_VENDOR_ID                0x0586
 #define ZYXEL_OMNINET_ID       0x1000
-#define BT_IGNITIONPRO_ID      0x2000  /* This one seems to be a re-branded ZyXEL device */
+/* This one seems to be a re-branded ZyXEL device */
+#define BT_IGNITIONPRO_ID      0x2000
 
 /* function prototypes */
-static int  omninet_open               (struct usb_serial_port *port, struct file *filp);
-static void omninet_close              (struct usb_serial_port *port, struct file *filp);
-static void omninet_read_bulk_callback (struct urb *urb);
-static void omninet_write_bulk_callback        (struct urb *urb);
-static int  omninet_write              (struct usb_serial_port *port, const unsigned char *buf, int count);
-static int  omninet_write_room         (struct usb_serial_port *port);
-static void omninet_shutdown           (struct usb_serial *serial);
-static int omninet_attach              (struct usb_serial *serial);
-
-static struct usb_device_id id_table [] = {
+static int  omninet_open(struct tty_struct *tty, struct usb_serial_port *port,
+                                                       struct file *filp);
+static void omninet_close(struct tty_struct *tty, struct usb_serial_port *port,
+                                                       struct file *filp);
+static void omninet_read_bulk_callback(struct urb *urb);
+static void omninet_write_bulk_callback(struct urb *urb);
+static int  omninet_write(struct tty_struct *tty, struct usb_serial_port *port,
+                               const unsigned char *buf, int count);
+static int  omninet_write_room(struct tty_struct *tty);
+static void omninet_shutdown(struct usb_serial *serial);
+static int omninet_attach(struct usb_serial *serial);
+
+static struct usb_device_id id_table[] = {
        { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) },
        { USB_DEVICE(ZYXEL_VENDOR_ID, BT_IGNITIONPRO_ID) },
        { }                                             /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table);
+MODULE_DEVICE_TABLE(usb, id_table);
 
 static struct usb_driver omninet_driver = {
        .name =         "omninet",
@@ -130,34 +136,34 @@ static struct usb_serial_driver zyxel_omninet_device = {
  *
  */
 
-struct omninet_header
-{
+struct omninet_header {
        __u8    oh_seq;
        __u8    oh_len;
        __u8    oh_xxx;
        __u8    oh_pad;
 };
 
-struct omninet_data
-{
-       __u8    od_outseq;      // Sequence number for bulk_out URBs
+struct omninet_data {
+       __u8    od_outseq;      /* Sequence number for bulk_out URBs */
 };
 
-static int omninet_attach (struct usb_serial *serial)
+static int omninet_attach(struct usb_serial *serial)
 {
        struct omninet_data *od;
        struct usb_serial_port *port = serial->port[0];
 
-       od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL );
-       if( !od ) {
-               err("%s- kmalloc(%Zd) failed.", __func__, sizeof(struct omninet_data));
+       od = kmalloc(sizeof(struct omninet_data), GFP_KERNEL);
+       if (!od) {
+               err("%s- kmalloc(%Zd) failed.",
+                               __func__, sizeof(struct omninet_data));
                return -ENOMEM;
        }
        usb_set_serial_port_data(port, od);
        return 0;
 }
 
-static int omninet_open (struct usb_serial_port *port, struct file *filp)
+static int omninet_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial       *serial = port->serial;
        struct usb_serial_port  *wport;
@@ -166,22 +172,24 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
        dbg("%s - port %d", __func__, port->number);
 
        wport = serial->port[1];
-       wport->tty = port->tty;
+       wport->port.tty = tty;          /* FIXME */
 
        /* Start reading from the device */
-       usb_fill_bulk_urb(port->read_urb, serial->dev, 
-                     usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
-                     port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
-                     omninet_read_bulk_callback, port);
+       usb_fill_bulk_urb(port->read_urb, serial->dev,
+                       usb_rcvbulkpipe(serial->dev,
+                               port->bulk_in_endpointAddress),
+                       port->read_urb->transfer_buffer,
+                       port->read_urb->transfer_buffer_length,
+                       omninet_read_bulk_callback, port);
        result = usb_submit_urb(port->read_urb, GFP_KERNEL);
-       if (result) {
-               err("%s - failed submitting read urb, error %d", __func__, result);
-       }
-
+       if (result)
+               err("%s - failed submitting read urb, error %d",
+                                                       __func__, result);
        return result;
 }
 
-static void omninet_close (struct usb_serial_port *port, struct file * filp)
+static void omninet_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        dbg("%s - port %d", __func__, port->number);
        usb_kill_urb(port->read_urb);
@@ -192,14 +200,14 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
 #define OMNINET_HEADERLEN      sizeof(struct omninet_header)
 #define OMNINET_BULKOUTSIZE    (64 - OMNINET_HEADERLEN)
 
-static void omninet_read_bulk_callback (struct urb *urb)
+static void omninet_read_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port  *port   = urb->context;
        unsigned char           *data   = urb->transfer_buffer;
        struct omninet_header   *header = (struct omninet_header *) &data[0];
        int status = urb->status;
-       int i;
        int result;
+       int i;
 
        dbg("%s - port %d", __func__, port->number);
 
@@ -209,42 +217,46 @@ static void omninet_read_bulk_callback (struct urb *urb)
                return;
        }
 
-       if ((debug) && (header->oh_xxx != 0x30)) {
+       if (debug && header->oh_xxx != 0x30) {
                if (urb->actual_length) {
-                       printk (KERN_DEBUG __FILE__ ": omninet_read %d: ", header->oh_len);
-                       for (i = 0; i < (header->oh_len + OMNINET_HEADERLEN); i++) {
-                               printk ("%.2x ", data[i]);
-                       }
-                       printk ("\n");
+                       printk(KERN_DEBUG __FILE__
+                                       ": omninet_read %d: ", header->oh_len);
+                       for (i = 0; i < (header->oh_len +
+                                               OMNINET_HEADERLEN); i++)
+                               printk("%.2x ", data[i]);
+                       printk("\n");
                }
        }
 
        if (urb->actual_length && header->oh_len) {
-               for (i = 0; i < header->oh_len; i++) {
-                        tty_insert_flip_char(port->tty, data[OMNINET_DATAOFFSET + i], 0);
-               }
-               tty_flip_buffer_push(port->tty);
+               tty_insert_flip_string(port->port.tty,
+                       data + OMNINET_DATAOFFSET, header->oh_len);
+               tty_flip_buffer_push(port->port.tty);
        }
 
        /* Continue trying to always read  */
-       usb_fill_bulk_urb(urb, port->serial->dev, 
-                     usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
-                     urb->transfer_buffer, urb->transfer_buffer_length,
-                     omninet_read_bulk_callback, port);
+       usb_fill_bulk_urb(urb, port->serial->dev,
+                       usb_rcvbulkpipe(port->serial->dev,
+                                       port->bulk_in_endpointAddress),
+                       urb->transfer_buffer, urb->transfer_buffer_length,
+                       omninet_read_bulk_callback, port);
        result = usb_submit_urb(urb, GFP_ATOMIC);
        if (result)
-               err("%s - failed resubmitting read urb, error %d", __func__, result);
+               err("%s - failed resubmitting read urb, error %d",
+                                               __func__, result);
 
        return;
 }
 
-static int omninet_write (struct usb_serial_port *port, const unsigned char *buf, int count)
+static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count)
 {
-       struct usb_serial       *serial = port->serial;
-       struct usb_serial_port  *wport  = serial->port[1];
+       struct usb_serial *serial = port->serial;
+       struct usb_serial_port *wport = serial->port[1];
 
-       struct omninet_data     *od     = usb_get_serial_port_data(port);
-       struct omninet_header   *header = (struct omninet_header *) wport->write_urb->transfer_buffer;
+       struct omninet_data *od = usb_get_serial_port_data(port);
+       struct omninet_header *header = (struct omninet_header *)
+                                       wport->write_urb->transfer_buffer;
 
        int                     result;
 
@@ -252,7 +264,7 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
 
        if (count == 0) {
                dbg("%s - write request of 0 bytes", __func__);
-               return (0);
+               return 0;
        }
 
        spin_lock_bh(&wport->lock);
@@ -266,9 +278,11 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
 
        count = (count > OMNINET_BULKOUTSIZE) ? OMNINET_BULKOUTSIZE : count;
 
-       memcpy (wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, buf, count);
+       memcpy(wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET,
+                                                               buf, count);
 
-       usb_serial_debug_data(debug, &port->dev, __func__, count, wport->write_urb->transfer_buffer);
+       usb_serial_debug_data(debug, &port->dev, __func__, count,
+                                       wport->write_urb->transfer_buffer);
 
        header->oh_seq  = od->od_outseq++;
        header->oh_len  = count;
@@ -282,7 +296,8 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
        result = usb_submit_urb(wport->write_urb, GFP_ATOMIC);
        if (result) {
                wport->write_urb_busy = 0;
-               err("%s - failed submitting write urb, error %d", __func__, result);
+               err("%s - failed submitting write urb, error %d",
+                                                       __func__, result);
        } else
                result = count;
 
@@ -290,8 +305,9 @@ static int omninet_write (struct usb_serial_port *port, const unsigned char *buf
 }
 
 
-static int omninet_write_room (struct usb_serial_port *port)
+static int omninet_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial       *serial = port->serial;
        struct usb_serial_port  *wport  = serial->port[1];
 
@@ -303,12 +319,13 @@ static int omninet_write_room (struct usb_serial_port *port)
 
        dbg("%s - returns %d", __func__, room);
 
-       return (room);
+       return room;
 }
 
-static void omninet_write_bulk_callback (struct urb *urb)
+static void omninet_write_bulk_callback(struct urb *urb)
 {
-/*     struct omninet_header   *header = (struct omninet_header  *) urb->transfer_buffer; */
+/*     struct omninet_header   *header = (struct omninet_header  *)
+                                               urb->transfer_buffer; */
        struct usb_serial_port  *port   =  urb->context;
        int status = urb->status;
 
@@ -325,18 +342,18 @@ static void omninet_write_bulk_callback (struct urb *urb)
 }
 
 
-static void omninet_shutdown (struct usb_serial *serial)
+static void omninet_shutdown(struct usb_serial *serial)
 {
        struct usb_serial_port *wport = serial->port[1];
        struct usb_serial_port *port = serial->port[0];
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        usb_kill_urb(wport->write_urb);
        kfree(usb_get_serial_port_data(port));
 }
 
 
-static int __init omninet_init (void)
+static int __init omninet_init(void)
 {
        int retval;
        retval = usb_serial_register(&zyxel_omninet_device);
@@ -354,18 +371,18 @@ failed_usb_serial_register:
 }
 
 
-static void __exit omninet_exit (void)
+static void __exit omninet_exit(void)
 {
-       usb_deregister (&omninet_driver);
-       usb_serial_deregister (&zyxel_omninet_device);
+       usb_deregister(&omninet_driver);
+       usb_serial_deregister(&zyxel_omninet_device);
 }
 
 
 module_init(omninet_init);
 module_exit(omninet_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index 1e936a1..e4eca95 100644 (file)
 #include <linux/usb/serial.h>
 
 /* Function prototypes */
-static int  option_open(struct usb_serial_port *port, struct file *filp);
-static void option_close(struct usb_serial_port *port, struct file *filp);
+static int  option_open(struct tty_struct *tty, struct usb_serial_port *port,
+                                                       struct file *filp);
+static void option_close(struct tty_struct *tty, struct usb_serial_port *port,
+                                                       struct file *filp);
 static int  option_startup(struct usb_serial *serial);
 static void option_shutdown(struct usb_serial *serial);
-static void option_rx_throttle(struct usb_serial_port *port);
-static void option_rx_unthrottle(struct usb_serial_port *port);
-static int  option_write_room(struct usb_serial_port *port);
+static int  option_write_room(struct tty_struct *tty);
 
 static void option_instat_callback(struct urb *urb);
 
-static int option_write(struct usb_serial_port *port,
+static int option_write(struct tty_struct *tty, struct usb_serial_port *port,
                        const unsigned char *buf, int count);
-
-static int  option_chars_in_buffer(struct usb_serial_port *port);
-static int  option_ioctl(struct usb_serial_port *port, struct file *file,
-                       unsigned int cmd, unsigned long arg);
-static void option_set_termios(struct usb_serial_port *port,
-                               struct ktermios *old);
-static void option_break_ctl(struct usb_serial_port *port, int break_state);
-static int  option_tiocmget(struct usb_serial_port *port, struct file *file);
-static int  option_tiocmset(struct usb_serial_port *port, struct file *file,
+static int  option_chars_in_buffer(struct tty_struct *tty);
+static void option_set_termios(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct ktermios *old);
+static int  option_tiocmget(struct tty_struct *tty, struct file *file);
+static int  option_tiocmset(struct tty_struct *tty, struct file *file,
                                unsigned int set, unsigned int clear);
-static int  option_send_setup(struct usb_serial_port *port);
+static int  option_send_setup(struct tty_struct *tty, struct usb_serial_port *port);
 
 /* Vendor and product IDs */
 #define OPTION_VENDOR_ID                       0x0AF0
@@ -342,11 +338,7 @@ static struct usb_serial_driver option_1port_device = {
        .write             = option_write,
        .write_room        = option_write_room,
        .chars_in_buffer   = option_chars_in_buffer,
-       .throttle          = option_rx_throttle,
-       .unthrottle        = option_rx_unthrottle,
-       .ioctl             = option_ioctl,
        .set_termios       = option_set_termios,
-       .break_ctl         = option_break_ctl,
        .tiocmget          = option_tiocmget,
        .tiocmset          = option_tiocmset,
        .attach            = option_startup,
@@ -403,47 +395,32 @@ static int __init option_init(void)
        return 0;
 
 failed_driver_register:
-       usb_serial_deregister (&option_1port_device);
+       usb_serial_deregister(&option_1port_device);
 failed_1port_device_register:
        return retval;
 }
 
 static void __exit option_exit(void)
 {
-       usb_deregister (&option_driver);
-       usb_serial_deregister (&option_1port_device);
+       usb_deregister(&option_driver);
+       usb_serial_deregister(&option_1port_device);
 }
 
 module_init(option_init);
 module_exit(option_exit);
 
-static void option_rx_throttle(struct usb_serial_port *port)
-{
-       dbg("%s", __func__);
-}
-
-static void option_rx_unthrottle(struct usb_serial_port *port)
-{
-       dbg("%s", __func__);
-}
-
-static void option_break_ctl(struct usb_serial_port *port, int break_state)
-{
-       /* Unfortunately, I don't know how to send a break */
-       dbg("%s", __func__);
-}
-
-static void option_set_termios(struct usb_serial_port *port,
-                       struct ktermios *old_termios)
+static void option_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        dbg("%s", __func__);
        /* Doesn't support option setting */
-       tty_termios_copy_hw(port->tty->termios, old_termios);
-       option_send_setup(port);
+       tty_termios_copy_hw(tty->termios, old_termios);
+       option_send_setup(tty, port);
 }
 
-static int option_tiocmget(struct usb_serial_port *port, struct file *file)
+static int option_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        unsigned int value;
        struct option_port_private *portdata;
 
@@ -459,9 +436,10 @@ static int option_tiocmget(struct usb_serial_port *port, struct file *file)
        return value;
 }
 
-static int option_tiocmset(struct usb_serial_port *port, struct file *file,
+static int option_tiocmset(struct tty_struct *tty, struct file *file,
                        unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct option_port_private *portdata;
 
        portdata = usb_get_serial_port_data(port);
@@ -476,17 +454,11 @@ static int option_tiocmset(struct usb_serial_port *port, struct file *file,
                portdata->rts_state = 0;
        if (clear & TIOCM_DTR)
                portdata->dtr_state = 0;
-       return option_send_setup(port);
-}
-
-static int option_ioctl(struct usb_serial_port *port, struct file *file,
-                       unsigned int cmd, unsigned long arg)
-{
-       return -ENOIOCTLCMD;
+       return option_send_setup(tty, port);
 }
 
 /* Write */
-static int option_write(struct usb_serial_port *port,
+static int option_write(struct tty_struct *tty, struct usb_serial_port *port,
                        const unsigned char *buf, int count)
 {
        struct option_port_private *portdata;
@@ -501,7 +473,7 @@ static int option_write(struct usb_serial_port *port,
 
        i = 0;
        left = count;
-       for (i=0; left > 0 && i < N_OUT_URB; i++) {
+       for (i = 0; left > 0 && i < N_OUT_URB; i++) {
                todo = left;
                if (todo > OUT_BUFLEN)
                        todo = OUT_BUFLEN;
@@ -522,7 +494,7 @@ static int option_write(struct usb_serial_port *port,
                        usb_pipeendpoint(this_urb->pipe), i);
 
                /* send the data */
-               memcpy (this_urb->transfer_buffer, buf, todo);
+               memcpy(this_urb->transfer_buffer, buf, todo);
                this_urb->transfer_buffer_length = todo;
 
                this_urb->dev = port->serial->dev;
@@ -562,7 +534,7 @@ static void option_indat_callback(struct urb *urb)
                dbg("%s: nonzero status: %d on endpoint %02x.",
                    __func__, status, endpoint);
        } else {
-               tty = port->tty;
+               tty = port->port.tty;
                if (urb->actual_length) {
                        tty_buffer_request_room(tty, urb->actual_length);
                        tty_insert_flip_string(tty, data, urb->actual_length);
@@ -572,7 +544,7 @@ static void option_indat_callback(struct urb *urb)
                }
 
                /* Resubmit urb so we continue receiving */
-               if (port->open_count && status != -ESHUTDOWN) {
+               if (port->port.count && status != -ESHUTDOWN) {
                        err = usb_submit_urb(urb, GFP_ATOMIC);
                        if (err)
                                printk(KERN_ERR "%s: resubmit read urb failed. "
@@ -613,7 +585,7 @@ static void option_instat_callback(struct urb *urb)
        struct usb_serial *serial = port->serial;
 
        dbg("%s", __func__);
-       dbg("%s: urb %p port %p has data %p", __func__,urb,port,portdata);
+       dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata);
 
        if (status == 0) {
                struct usb_ctrlrequest *req_pkt =
@@ -638,12 +610,12 @@ static void option_instat_callback(struct urb *urb)
                        portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
                        portdata->ri_state = ((signals & 0x08) ? 1 : 0);
 
-                       if (port->tty && !C_CLOCAL(port->tty) &&
+                       if (port->port.tty && !C_CLOCAL(port->port.tty) &&
                                        old_dcd_state && !portdata->dcd_state)
-                               tty_hangup(port->tty);
+                               tty_hangup(port->port.tty);
                } else {
                        dbg("%s: type %x req %x", __func__,
-                               req_pkt->bRequestType,req_pkt->bRequest);
+                               req_pkt->bRequestType, req_pkt->bRequest);
                }
        } else
                dbg("%s: error %d", __func__, status);
@@ -658,8 +630,9 @@ static void option_instat_callback(struct urb *urb)
        }
 }
 
-static int option_write_room(struct usb_serial_port *port)
+static int option_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct option_port_private *portdata;
        int i;
        int data_len = 0;
@@ -668,7 +641,7 @@ static int option_write_room(struct usb_serial_port *port)
        portdata = usb_get_serial_port_data(port);
 
 
-       for (i=0; i < N_OUT_URB; i++) {
+       for (i = 0; i < N_OUT_URB; i++) {
                this_urb = portdata->out_urbs[i];
                if (this_urb && !test_bit(i, &portdata->out_busy))
                        data_len += OUT_BUFLEN;
@@ -678,8 +651,9 @@ static int option_write_room(struct usb_serial_port *port)
        return data_len;
 }
 
-static int option_chars_in_buffer(struct usb_serial_port *port)
+static int option_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct option_port_private *portdata;
        int i;
        int data_len = 0;
@@ -687,7 +661,7 @@ static int option_chars_in_buffer(struct usb_serial_port *port)
 
        portdata = usb_get_serial_port_data(port);
 
-       for (i=0; i < N_OUT_URB; i++) {
+       for (i = 0; i < N_OUT_URB; i++) {
                this_urb = portdata->out_urbs[i];
                /* FIXME: This locking is insufficient as this_urb may
                   go unused during the test */
@@ -698,7 +672,8 @@ static int option_chars_in_buffer(struct usb_serial_port *port)
        return data_len;
 }
 
-static int option_open(struct usb_serial_port *port, struct file *filp)
+static int option_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct option_port_private *portdata;
        struct usb_serial *serial = port->serial;
@@ -716,7 +691,7 @@ static int option_open(struct usb_serial_port *port, struct file *filp)
        /* Reset low level data toggle and start reading from endpoints */
        for (i = 0; i < N_IN_URB; i++) {
                urb = portdata->in_urbs[i];
-               if (! urb)
+               if (!urb)
                        continue;
                if (urb->dev != serial->dev) {
                        dbg("%s: dev %p != %p", __func__,
@@ -741,21 +716,23 @@ static int option_open(struct usb_serial_port *port, struct file *filp)
        /* Reset low level data toggle on out endpoints */
        for (i = 0; i < N_OUT_URB; i++) {
                urb = portdata->out_urbs[i];
-               if (! urb)
+               if (!urb)
                        continue;
                urb->dev = serial->dev;
                /* usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe),
                                usb_pipeout(urb->pipe), 0); */
        }
 
-       port->tty->low_latency = 1;
+       if (tty)
+               tty->low_latency = 1;
 
-       option_send_setup(port);
+       option_send_setup(tty, port);
 
-       return (0);
+       return 0;
 }
 
-static void option_close(struct usb_serial_port *port, struct file *filp)
+static void option_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        int i;
        struct usb_serial *serial = port->serial;
@@ -770,7 +747,7 @@ static void option_close(struct usb_serial_port *port, struct file *filp)
        if (serial->dev) {
                mutex_lock(&serial->disc_mutex);
                if (!serial->disconnected)
-                       option_send_setup(port);
+                       option_send_setup(tty, port);
                mutex_unlock(&serial->disc_mutex);
 
                /* Stop reading/writing urbs */
@@ -779,7 +756,7 @@ static void option_close(struct usb_serial_port *port, struct file *filp)
                for (i = 0; i < N_OUT_URB; i++)
                        usb_kill_urb(portdata->out_urbs[i]);
        }
-       port->tty = NULL;
+       port->port.tty = NULL;  /* FIXME */
 }
 
 /* Helper functions used by option_setup_urbs */
@@ -809,7 +786,7 @@ static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint,
 /* Setup urbs */
 static void option_setup_urbs(struct usb_serial *serial)
 {
-       int i,j;
+       int i, j;
        struct usb_serial_port *port;
        struct option_port_private *portdata;
 
@@ -819,18 +796,22 @@ static void option_setup_urbs(struct usb_serial *serial)
                port = serial->port[i];
                portdata = usb_get_serial_port_data(port);
 
-       /* Do indat endpoints first */
+               /* Do indat endpoints first */
                for (j = 0; j < N_IN_URB; ++j) {
-                       portdata->in_urbs[j] = option_setup_urb (serial,
-                       port->bulk_in_endpointAddress, USB_DIR_IN, port,
-                       portdata->in_buffer[j], IN_BUFLEN, option_indat_callback);
+                       portdata->in_urbs[j] = option_setup_urb(serial,
+                                       port->bulk_in_endpointAddress,
+                                       USB_DIR_IN, port,
+                                       portdata->in_buffer[j],
+                                       IN_BUFLEN, option_indat_callback);
                }
 
                /* outdat endpoints */
                for (j = 0; j < N_OUT_URB; ++j) {
-                       portdata->out_urbs[j] = option_setup_urb (serial,
-                       port->bulk_out_endpointAddress, USB_DIR_OUT, port,
-                       portdata->out_buffer[j], OUT_BUFLEN, option_outdat_callback);
+                       portdata->out_urbs[j] = option_setup_urb(serial,
+                                       port->bulk_out_endpointAddress,
+                                       USB_DIR_OUT, port,
+                                       portdata->out_buffer[j],
+                                       OUT_BUFLEN, option_outdat_callback);
                }
        }
 }
@@ -841,7 +822,8 @@ static void option_setup_urbs(struct usb_serial *serial)
  * This is exactly the same as SET_CONTROL_LINE_STATE from the PSTN
  * CDC.
 */
-static int option_send_setup(struct usb_serial_port *port)
+static int option_send_setup(struct tty_struct *tty,
+                                               struct usb_serial_port *port)
 {
        struct usb_serial *serial = port->serial;
        struct option_port_private *portdata;
@@ -850,7 +832,7 @@ static int option_send_setup(struct usb_serial_port *port)
 
        portdata = usb_get_serial_port_data(port);
 
-       if (port->tty) {
+       if (tty) {
                int val = 0;
                if (portdata->dtr_state)
                        val |= 0x01;
@@ -858,10 +840,9 @@ static int option_send_setup(struct usb_serial_port *port)
                        val |= 0x02;
 
                return usb_control_msg(serial->dev,
-                               usb_rcvctrlpipe(serial->dev, 0),
-                               0x22,0x21,val,ifNum,NULL,0,USB_CTRL_SET_TIMEOUT);
+                       usb_rcvctrlpipe(serial->dev, 0),
+                       0x22, 0x21, val, ifNum, NULL, 0, USB_CTRL_SET_TIMEOUT);
        }
-
        return 0;
 }
 
@@ -881,7 +862,7 @@ static int option_startup(struct usb_serial *serial)
                if (!portdata) {
                        dbg("%s: kmalloc for option_port_private (%d) failed!.",
                                        __func__, i);
-                       return (1);
+                       return 1;
                }
 
                for (j = 0; j < N_IN_URB; j++) {
@@ -900,17 +881,15 @@ static int option_startup(struct usb_serial *serial)
 
                usb_set_serial_port_data(port, portdata);
 
-               if (! port->interrupt_in_urb)
+               if (!port->interrupt_in_urb)
                        continue;
                err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
                if (err)
                        dbg("%s: submit irq_in urb failed %d",
                                __func__, err);
        }
-
        option_setup_urbs(serial);
-
-       return (0);
+       return 0;
 
 bail_out_error2:
        for (j = 0; j < N_OUT_URB; j++)
@@ -949,7 +928,8 @@ static void option_shutdown(struct usb_serial *serial)
                for (j = 0; j < N_IN_URB; j++) {
                        if (portdata->in_urbs[j]) {
                                usb_free_urb(portdata->in_urbs[j]);
-                               free_page((unsigned long)portdata->in_buffer[j]);
+                               free_page((unsigned long)
+                                       portdata->in_buffer[j]);
                                portdata->in_urbs[j] = NULL;
                        }
                }
index a9625c1..81db571 100644 (file)
@@ -25,7 +25,8 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  *
  * TODO:
  *  - implement correct flushing for ioctls and oti6858_close()
@@ -49,7 +50,7 @@
 #include <linux/spinlock.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include "oti6858.h"
 
 #define OTI6858_DESCRIPTION \
@@ -135,27 +136,28 @@ struct oti6858_control_pkt {
 
 #define OTI6858_CTRL_PKT_SIZE  sizeof(struct oti6858_control_pkt)
 #define OTI6858_CTRL_EQUALS_PENDING(a, priv) \
-       (    ((a)->divisor == (priv)->pending_setup.divisor) \
+       (((a)->divisor == (priv)->pending_setup.divisor) \
          && ((a)->control == (priv)->pending_setup.control) \
-         && ((a)->frame_fmt == (priv)->pending_setup.frame_fmt) )
+         && ((a)->frame_fmt == (priv)->pending_setup.frame_fmt))
 
 /* function prototypes */
-static int oti6858_open(struct usb_serial_port *port, struct file *filp);
-static void oti6858_close(struct usb_serial_port *port, struct file *filp);
-static void oti6858_set_termios(struct usb_serial_port *port,
-                               struct ktermios *old);
-static int oti6858_ioctl(struct usb_serial_port *port, struct file *file,
+static int oti6858_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void oti6858_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void oti6858_set_termios(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct ktermios *old);
+static int oti6858_ioctl(struct tty_struct *tty, struct file *file,
                        unsigned int cmd, unsigned long arg);
 static void oti6858_read_int_callback(struct urb *urb);
 static void oti6858_read_bulk_callback(struct urb *urb);
 static void oti6858_write_bulk_callback(struct urb *urb);
-static int oti6858_write(struct usb_serial_port *port,
+static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port,
                        const unsigned char *buf, int count);
-static int oti6858_write_room(struct usb_serial_port *port);
-static void oti6858_break_ctl(struct usb_serial_port *port, int break_state);
-static int oti6858_chars_in_buffer(struct usb_serial_port *port);
-static int oti6858_tiocmget(struct usb_serial_port *port, struct file *file);
-static int oti6858_tiocmset(struct usb_serial_port *port, struct file *file,
+static int oti6858_write_room(struct tty_struct *tty);
+static int oti6858_chars_in_buffer(struct tty_struct *tty);
+static int oti6858_tiocmget(struct tty_struct *tty, struct file *file);
+static int oti6858_tiocmset(struct tty_struct *tty, struct file *file,
                                unsigned int set, unsigned int clear);
 static int oti6858_startup(struct usb_serial *serial);
 static void oti6858_shutdown(struct usb_serial *serial);
@@ -184,7 +186,6 @@ static struct usb_serial_driver oti6858_device = {
        .close =                oti6858_close,
        .write =                oti6858_write,
        .ioctl =                oti6858_ioctl,
-       .break_ctl =            oti6858_break_ctl,
        .set_termios =          oti6858_set_termios,
        .tiocmget =             oti6858_tiocmget,
        .tiocmset =             oti6858_tiocmset,
@@ -220,7 +221,7 @@ struct oti6858_private {
        struct delayed_work delayed_setup_work;
 
        wait_queue_head_t intr_wait;
-        struct usb_serial_port *port;   /* USB port with which associated */
+       struct usb_serial_port *port;   /* USB port with which associated */
 };
 
 #undef dbg
@@ -229,7 +230,8 @@ struct oti6858_private {
 
 static void setup_line(struct work_struct *work)
 {
-       struct oti6858_private *priv = container_of(work, struct oti6858_private, delayed_setup_work.work);
+       struct oti6858_private *priv = container_of(work,
+                       struct oti6858_private, delayed_setup_work.work);
        struct usb_serial_port *port = priv->port;
        struct oti6858_control_pkt *new_setup;
        unsigned long flags;
@@ -237,10 +239,12 @@ static void setup_line(struct work_struct *work)
 
        dbg("%s(port = %d)", __func__, port->number);
 
-       if ((new_setup = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) {
+       new_setup = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL);
+       if (new_setup == NULL) {
                dev_err(&port->dev, "%s(): out of memory!\n", __func__);
                /* we will try again */
-               schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2));
+               schedule_delayed_work(&priv->delayed_setup_work,
+                                               msecs_to_jiffies(2));
                return;
        }
 
@@ -256,7 +260,8 @@ static void setup_line(struct work_struct *work)
                dev_err(&port->dev, "%s(): error reading status\n", __func__);
                kfree(new_setup);
                /* we will try again */
-               schedule_delayed_work(&priv->delayed_setup_work, msecs_to_jiffies(2));
+               schedule_delayed_work(&priv->delayed_setup_work,
+                                                       msecs_to_jiffies(2));
                return;
        }
 
@@ -297,7 +302,8 @@ static void setup_line(struct work_struct *work)
 
 void send_data(struct work_struct *work)
 {
-       struct oti6858_private *priv = container_of(work, struct oti6858_private, delayed_write_work.work);
+       struct oti6858_private *priv = container_of(work,
+                       struct oti6858_private, delayed_write_work.work);
        struct usb_serial_port *port = priv->port;
        int count = 0, result;
        unsigned long flags;
@@ -308,7 +314,8 @@ void send_data(struct work_struct *work)
        spin_lock_irqsave(&priv->lock, flags);
        if (priv->flags.write_urb_in_use) {
                spin_unlock_irqrestore(&priv->lock, flags);
-               schedule_delayed_work(&priv->delayed_write_work, msecs_to_jiffies(2));
+               schedule_delayed_work(&priv->delayed_write_work,
+                                               msecs_to_jiffies(2));
                return;
        }
        priv->flags.write_urb_in_use = 1;
@@ -359,8 +366,8 @@ void send_data(struct work_struct *work)
 
 static int oti6858_startup(struct usb_serial *serial)
 {
-        struct usb_serial_port *port = serial->port[0];
-        struct oti6858_private *priv;
+       struct usb_serial_port *port = serial->port[0];
+       struct oti6858_private *priv;
        int i;
 
        for (i = 0; i < serial->num_ports; ++i) {
@@ -375,8 +382,8 @@ static int oti6858_startup(struct usb_serial *serial)
 
                spin_lock_init(&priv->lock);
                init_waitqueue_head(&priv->intr_wait);
-//             INIT_WORK(&priv->setup_work, setup_line, serial->port[i]);
-//             INIT_WORK(&priv->write_work, send_data, serial->port[i]);
+/*             INIT_WORK(&priv->setup_work, setup_line, serial->port[i]); */
+/*             INIT_WORK(&priv->write_work, send_data, serial->port[i]); */
                priv->port = port;
                INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line);
                INIT_DELAYED_WORK(&priv->delayed_write_work, send_data);
@@ -395,7 +402,7 @@ static int oti6858_startup(struct usb_serial *serial)
        return -ENOMEM;
 }
 
-static int oti6858_write(struct usb_serial_port *port,
+static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port,
                        const unsigned char *buf, int count)
 {
        struct oti6858_private *priv = usb_get_serial_port_data(port);
@@ -413,8 +420,9 @@ static int oti6858_write(struct usb_serial_port *port,
        return count;
 }
 
-static int oti6858_write_room(struct usb_serial_port *port)
+static int oti6858_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct oti6858_private *priv = usb_get_serial_port_data(port);
        int room = 0;
        unsigned long flags;
@@ -428,8 +436,9 @@ static int oti6858_write_room(struct usb_serial_port *port)
        return room;
 }
 
-static int oti6858_chars_in_buffer(struct usb_serial_port *port)
+static int oti6858_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct oti6858_private *priv = usb_get_serial_port_data(port);
        int chars = 0;
        unsigned long flags;
@@ -443,8 +452,8 @@ static int oti6858_chars_in_buffer(struct usb_serial_port *port)
        return chars;
 }
 
-static void oti6858_set_termios(struct usb_serial_port *port,
-                               struct ktermios *old_termios)
+static void oti6858_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct oti6858_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
@@ -455,22 +464,22 @@ static void oti6858_set_termios(struct usb_serial_port *port,
 
        dbg("%s(port = %d)", __func__, port->number);
 
-       if (!port->tty || !port->tty->termios) {
+       if (!tty) {
                dbg("%s(): no tty structures", __func__);
                return;
        }
 
        spin_lock_irqsave(&priv->lock, flags);
        if (!priv->flags.termios_initialized) {
-               *(port->tty->termios) = tty_std_termios;
-               port->tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL;
+               *(tty->termios) = tty_std_termios;
+               tty->termios->c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL;
+               tty->termios->c_ispeed = 38400;
+               tty->termios->c_ospeed = 38400;
                priv->flags.termios_initialized = 1;
-               port->tty->termios->c_ispeed = 38400;
-               port->tty->termios->c_ospeed = 38400;
        }
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       cflag = port->tty->termios->c_cflag;
+       cflag = tty->termios->c_cflag;
 
        spin_lock_irqsave(&priv->lock, flags);
        divisor = priv->pending_setup.divisor;
@@ -480,19 +489,19 @@ static void oti6858_set_termios(struct usb_serial_port *port,
 
        frame_fmt &= ~FMT_DATA_BITS_MASK;
        switch (cflag & CSIZE) {
-               case CS5:
-                       frame_fmt |= FMT_DATA_BITS_5;
-                       break;
-               case CS6:
-                       frame_fmt |= FMT_DATA_BITS_6;
-                       break;
-               case CS7:
-                       frame_fmt |= FMT_DATA_BITS_7;
-                       break;
-               default:
-               case CS8:
-                       frame_fmt |= FMT_DATA_BITS_8;
-                       break;
+       case CS5:
+               frame_fmt |= FMT_DATA_BITS_5;
+               break;
+       case CS6:
+               frame_fmt |= FMT_DATA_BITS_6;
+               break;
+       case CS7:
+               frame_fmt |= FMT_DATA_BITS_7;
+               break;
+       default:
+       case CS8:
+               frame_fmt |= FMT_DATA_BITS_8;
+               break;
        }
 
        /* manufacturer claims that this device can work with baud rates
@@ -500,7 +509,7 @@ static void oti6858_set_termios(struct usb_serial_port *port,
         * guarantee that any other baud rate will work (especially
         * the higher ones)
         */
-       br = tty_get_baud_rate(port->tty);
+       br = tty_get_baud_rate(tty);
        if (br == 0) {
                divisor = 0;
        } else {
@@ -511,23 +520,21 @@ static void oti6858_set_termios(struct usb_serial_port *port,
                new_divisor = (96000000 + 8 * br) / (16 * br);
                real_br = 96000000 / (16 * new_divisor);
                divisor = cpu_to_le16(new_divisor);
-               tty_encode_baud_rate(port->tty, real_br, real_br);
+               tty_encode_baud_rate(tty, real_br, real_br);
        }
 
        frame_fmt &= ~FMT_STOP_BITS_MASK;
-       if ((cflag & CSTOPB) != 0) {
+       if ((cflag & CSTOPB) != 0)
                frame_fmt |= FMT_STOP_BITS_2;
-       } else {
+       else
                frame_fmt |= FMT_STOP_BITS_1;
-       }
 
        frame_fmt &= ~FMT_PARITY_MASK;
        if ((cflag & PARENB) != 0) {
-               if ((cflag & PARODD) != 0) {
+               if ((cflag & PARODD) != 0)
                        frame_fmt |= FMT_PARITY_ODD;
-               } else {
+               else
                        frame_fmt |= FMT_PARITY_EVEN;
-               }
        } else {
                frame_fmt |= FMT_PARITY_NONE;
        }
@@ -564,7 +571,8 @@ static void oti6858_set_termios(struct usb_serial_port *port,
        spin_unlock_irqrestore(&priv->lock, flags);
 }
 
-static int oti6858_open(struct usb_serial_port *port, struct file *filp)
+static int oti6858_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct oti6858_private *priv = usb_get_serial_port_data(port);
        struct ktermios tmp_termios;
@@ -578,10 +586,11 @@ static int oti6858_open(struct usb_serial_port *port, struct file *filp)
        usb_clear_halt(serial->dev, port->write_urb->pipe);
        usb_clear_halt(serial->dev, port->read_urb->pipe);
 
-       if (port->open_count != 1)
+       if (port->port.count != 1)
                return 0;
 
-       if ((buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL)) == NULL) {
+       buf = kmalloc(OTI6858_CTRL_PKT_SIZE, GFP_KERNEL);
+       if (buf == NULL) {
                dev_err(&port->dev, "%s(): out of memory!\n", __func__);
                return -ENOMEM;
        }
@@ -617,18 +626,19 @@ static int oti6858_open(struct usb_serial_port *port, struct file *filp)
        if (result != 0) {
                dev_err(&port->dev, "%s(): usb_submit_urb() failed"
                               " with error %d\n", __func__, result);
-               oti6858_close(port, NULL);
+               oti6858_close(tty, port, NULL);
                return -EPROTO;
        }
 
        /* setup termios */
-       if (port->tty)
-               oti6858_set_termios(port, &tmp_termios);
+       if (tty)
+               oti6858_set_termios(tty, port, &tmp_termios);
 
        return 0;
 }
 
-static void oti6858_close(struct usb_serial_port *port, struct file *filp)
+static void oti6858_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct oti6858_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
@@ -641,7 +651,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
        spin_lock_irqsave(&priv->lock, flags);
        timeout = 30 * HZ;      /* PL2303_CLOSING_WAIT */
        init_waitqueue_entry(&wait, current);
-       add_wait_queue(&port->tty->write_wait, &wait);
+       add_wait_queue(&tty->write_wait, &wait);
        dbg("%s(): entering wait loop", __func__);
        for (;;) {
                set_current_state(TASK_INTERRUPTIBLE);
@@ -654,7 +664,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
                spin_lock_irqsave(&priv->lock, flags);
        }
        set_current_state(TASK_RUNNING);
-       remove_wait_queue(&port->tty->write_wait, &wait);
+       remove_wait_queue(&tty->write_wait, &wait);
        dbg("%s(): after wait loop", __func__);
 
        /* clear out any remaining data in the buffer */
@@ -669,7 +679,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
        /* data is in the buffer to compute a delay */
        /* that is not unnecessarily long) */
        /* FIXME
-       bps = tty_get_baud_rate(port->tty);
+       bps = tty_get_baud_rate(tty);
        if (bps > 1200)
                timeout = max((HZ*2560)/bps,HZ/10);
        else
@@ -690,7 +700,7 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
        usb_kill_urb(port->interrupt_in_urb);
 
        /*
-       if (port->tty && (port->tty->termios->c_cflag) & HUPCL) {
+       if (tty && (tty->termios->c_cflag) & HUPCL) {
                // drop DTR and RTS
                spin_lock_irqsave(&priv->lock, flags);
                priv->pending_setup.control &= ~CONTROL_MASK;
@@ -699,9 +709,10 @@ static void oti6858_close(struct usb_serial_port *port, struct file *filp)
        */
 }
 
-static int oti6858_tiocmset(struct usb_serial_port *port, struct file *file,
+static int oti6858_tiocmset(struct tty_struct *tty, struct file *file,
                                unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct oti6858_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
        u8 control;
@@ -724,16 +735,16 @@ static int oti6858_tiocmset(struct usb_serial_port *port, struct file *file,
        if ((clear & TIOCM_DTR) != 0)
                control &= ~CONTROL_DTR_HIGH;
 
-       if (control != priv->pending_setup.control) {
+       if (control != priv->pending_setup.control)
                priv->pending_setup.control = control;
-       }
-       spin_unlock_irqrestore(&priv->lock, flags);
 
+       spin_unlock_irqrestore(&priv->lock, flags);
        return 0;
 }
 
-static int oti6858_tiocmget(struct usb_serial_port *port, struct file *file)
+static int oti6858_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct oti6858_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
        unsigned pin_state;
@@ -779,7 +790,8 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
        spin_unlock_irqrestore(&priv->lock, flags);
 
        while (1) {
-               wait_event_interruptible(priv->intr_wait, priv->status.pin_state != prev);
+               wait_event_interruptible(priv->intr_wait,
+                                       priv->status.pin_state != prev);
                if (signal_pending(current))
                        return -ERESTARTSYS;
 
@@ -789,12 +801,11 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
 
                changed = prev ^ status;
                /* FIXME: check if this is correct (active high/low) */
-               if (    ((arg & TIOCM_RNG) && (changed & PIN_RI)) ||
-                       ((arg & TIOCM_DSR) && (changed & PIN_DSR)) ||
-                       ((arg & TIOCM_CD)  && (changed & PIN_DCD)) ||
-                       ((arg & TIOCM_CTS) && (changed & PIN_CTS))) {
-                               return 0;
-               }
+               if (((arg & TIOCM_RNG) && (changed & PIN_RI)) ||
+                   ((arg & TIOCM_DSR) && (changed & PIN_DSR)) ||
+                   ((arg & TIOCM_CD)  && (changed & PIN_DCD)) ||
+                   ((arg & TIOCM_CTS) && (changed & PIN_CTS)))
+                       return 0;
                prev = status;
        }
 
@@ -802,56 +813,25 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
        return 0;
 }
 
-static int oti6858_ioctl(struct usb_serial_port *port, struct file *file,
+static int oti6858_ioctl(struct tty_struct *tty, struct file *file,
                        unsigned int cmd, unsigned long arg)
 {
-       void __user *user_arg = (void __user *) arg;
-       unsigned int x;
+       struct usb_serial_port *port = tty->driver_data;
 
        dbg("%s(port = %d, cmd = 0x%04x, arg = 0x%08lx)",
                                __func__, port->number, cmd, arg);
 
        switch (cmd) {
-               case TIOCMBIS:
-                       if (copy_from_user(&x, user_arg, sizeof(x)))
-                               return -EFAULT;
-                       return oti6858_tiocmset(port, NULL, x, 0);
-
-               case TIOCMBIC:
-                       if (copy_from_user(&x, user_arg, sizeof(x)))
-                               return -EFAULT;
-                       return oti6858_tiocmset(port, NULL, 0, x);
-
-               case TIOCMIWAIT:
-                       dbg("%s(): TIOCMIWAIT", __func__);
-                       return wait_modem_info(port, arg);
-
-               default:
-                       dbg("%s(): 0x%04x not supported", __func__, cmd);
-                       break;
+       case TIOCMIWAIT:
+               dbg("%s(): TIOCMIWAIT", __func__);
+               return wait_modem_info(port, arg);
+       default:
+               dbg("%s(): 0x%04x not supported", __func__, cmd);
+               break;
        }
-
        return -ENOIOCTLCMD;
 }
 
-static void oti6858_break_ctl(struct usb_serial_port *port, int break_state)
-{
-       int state;
-
-       dbg("%s(port = %d)", __func__, port->number);
-
-       state = (break_state == 0) ? 0 : 1;
-       dbg("%s(): turning break %s", __func__, state ? "on" : "off");
-
-       /* FIXME */
-/*
-       result = usb_control_msg (serial->dev, usb_sndctrlpipe (serial->dev, 0),
-                                 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
-                                 0, NULL, 0, 100);
-       if (result != 0)
-               dbg("%s(): error sending break", __func__);
- */
-}
 
 static void oti6858_shutdown(struct usb_serial *serial)
 {
@@ -964,7 +944,7 @@ static void oti6858_read_int_callback(struct urb *urb)
                spin_lock_irqsave(&priv->lock, flags);
                if (priv->flags.write_urb_in_use == 0
                                && oti6858_buf_data_avail(priv->buf) != 0) {
-                       schedule_delayed_work(&priv->delayed_write_work,0);
+                       schedule_delayed_work(&priv->delayed_write_work, 0);
                        resubmit = 0;
                }
                spin_unlock_irqrestore(&priv->lock, flags);
@@ -973,7 +953,7 @@ static void oti6858_read_int_callback(struct urb *urb)
        if (resubmit) {
                int result;
 
-//             dbg("%s(): submitting interrupt urb", __func__);
+/*             dbg("%s(): submitting interrupt urb", __func__); */
                urb->dev = port->serial->dev;
                result = usb_submit_urb(urb, GFP_ATOMIC);
                if (result != 0) {
@@ -1002,14 +982,16 @@ static void oti6858_read_bulk_callback(struct urb *urb)
        spin_unlock_irqrestore(&priv->lock, flags);
 
        if (status != 0) {
-               if (!port->open_count) {
+               if (!port->port.count) {
                        dbg("%s(): port is closed, exiting", __func__);
                        return;
                }
                /*
                if (status == -EPROTO) {
-                       // PL2303 mysteriously fails with -EPROTO reschedule the read
-                       dbg("%s - caught -EPROTO, resubmitting the urb", __func__);
+                       * PL2303 mysteriously fails with -EPROTO reschedule
+                          the read *
+                       dbg("%s - caught -EPROTO, resubmitting the urb",
+                                                               __func__);
                        result = usb_submit_urb(urb, GFP_ATOMIC);
                        if (result)
                                dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
@@ -1020,14 +1002,14 @@ static void oti6858_read_bulk_callback(struct urb *urb)
                return;
        }
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (tty != NULL && urb->actual_length > 0) {
                tty_insert_flip_string(tty, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
 
-       // schedule the interrupt urb if we are still open */
-       if (port->open_count != 0) {
+       /* schedule the interrupt urb if we are still open */
+       if (port->port.count != 0) {
                port->interrupt_in_urb->dev = port->serial->dev;
                result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
                if (result != 0) {
@@ -1078,7 +1060,7 @@ static void oti6858_write_bulk_callback(struct urb *urb)
 
        priv->flags.write_urb_in_use = 0;
 
-       // schedule the interrupt urb if we are still open */
+       /* schedule the interrupt urb if we are still open */
        port->interrupt_in_urb->dev = port->serial->dev;
        dbg("%s(): submitting interrupt urb", __func__);
        result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
@@ -1153,7 +1135,7 @@ static unsigned int oti6858_buf_data_avail(struct oti6858_buf *pb)
 {
        if (pb == NULL)
                return 0;
-       return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size);
+       return (pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size;
 }
 
 /*
@@ -1166,7 +1148,7 @@ static unsigned int oti6858_buf_space_avail(struct oti6858_buf *pb)
 {
        if (pb == NULL)
                return 0;
-       return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size);
+       return (pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size;
 }
 
 /*
@@ -1253,13 +1235,12 @@ static int __init oti6858_init(void)
 {
        int retval;
 
-       if ((retval = usb_serial_register(&oti6858_device)) == 0) {
-               if ((retval = usb_register(&oti6858_driver)) != 0)
+       retval = usb_serial_register(&oti6858_device);
+       if (retval == 0) {
+               retval = usb_register(&oti6858_driver);
+               if (retval)
                        usb_serial_deregister(&oti6858_device);
-               else
-                       return 0;
        }
-
        return retval;
 }
 
index 2a0dd1b..2c9c446 100644 (file)
@@ -10,7 +10,8 @@
  *     modify it under the terms of the GNU General Public License version
  *     2 as published by the Free Software Foundation.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  *
  */
 
@@ -25,7 +26,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include "pl2303.h"
@@ -116,7 +117,7 @@ static struct usb_driver pl2303_driver = {
 #define CONTROL_RTS                    0x02
 
 #define BREAK_REQUEST_TYPE             0x21
-#define BREAK_REQUEST                  0x23    
+#define BREAK_REQUEST                  0x23
 #define BREAK_ON                       0xffff
 #define BREAK_OFF                      0x0000
 
@@ -222,7 +223,7 @@ static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb)
        if (pb == NULL)
                return 0;
 
-       return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size);
+       return (pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size;
 }
 
 /*
@@ -236,7 +237,7 @@ static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb)
        if (pb == NULL)
                return 0;
 
-       return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size);
+       return (pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size;
 }
 
 /*
@@ -395,7 +396,7 @@ static int pl2303_startup(struct usb_serial *serial)
 
 cleanup:
        kfree(buf);
-       for (--i; i>=0; --i) {
+       for (--i; i >= 0; --i) {
                priv = usb_get_serial_port_data(serial->port[i]);
                pl2303_buf_free(priv->buf);
                kfree(priv);
@@ -407,7 +408,7 @@ cleanup:
 static int set_control_lines(struct usb_device *dev, u8 value)
 {
        int retval;
-       
+
        retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
                                 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE,
                                 value, 0, NULL, 0, 100);
@@ -452,14 +453,14 @@ static void pl2303_send(struct usb_serial_port *port)
                dev_err(&port->dev, "%s - failed submitting write urb,"
                        " error %d\n", __func__, result);
                priv->write_urb_in_use = 0;
-               // TODO: reschedule pl2303_send
+               /* TODO: reschedule pl2303_send */
        }
 
        usb_serial_port_softint(port);
 }
 
-static int pl2303_write(struct usb_serial_port *port, const unsigned char *buf,
-                       int count)
+static int pl2303_write(struct tty_struct *tty, struct usb_serial_port *port,
+                               const unsigned char *buf, int count)
 {
        struct pl2303_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
@@ -478,8 +479,9 @@ static int pl2303_write(struct usb_serial_port *port, const unsigned char *buf,
        return count;
 }
 
-static int pl2303_write_room(struct usb_serial_port *port)
+static int pl2303_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct pl2303_private *priv = usb_get_serial_port_data(port);
        int room = 0;
        unsigned long flags;
@@ -494,8 +496,9 @@ static int pl2303_write_room(struct usb_serial_port *port)
        return room;
 }
 
-static int pl2303_chars_in_buffer(struct usb_serial_port *port)
+static int pl2303_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct pl2303_private *priv = usb_get_serial_port_data(port);
        int chars = 0;
        unsigned long flags;
@@ -510,8 +513,8 @@ static int pl2303_chars_in_buffer(struct usb_serial_port *port)
        return chars;
 }
 
-static void pl2303_set_termios(struct usb_serial_port *port,
-                              struct ktermios *old_termios)
+static void pl2303_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct usb_serial *serial = port->serial;
        struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -526,11 +529,10 @@ static void pl2303_set_termios(struct usb_serial_port *port,
 
        spin_lock_irqsave(&priv->lock, flags);
        if (!priv->termios_initialized) {
-               *(port->tty->termios) = tty_std_termios;
-               port->tty->termios->c_cflag = B9600 | CS8 | CREAD |
-                                             HUPCL | CLOCAL;
-               port->tty->termios->c_ispeed = 9600;
-               port->tty->termios->c_ospeed = 9600;
+               *(tty->termios) = tty_std_termios;
+               tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+               tty->termios->c_ispeed = 9600;
+               tty->termios->c_ospeed = 9600;
                priv->termios_initialized = 1;
        }
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -539,16 +541,16 @@ static void pl2303_set_termios(struct usb_serial_port *port,
           serial settings even to the same values as before. Thus
           we actually need to filter in this specific case */
 
-       if (!tty_termios_hw_change(port->tty->termios, old_termios))
+       if (!tty_termios_hw_change(tty->termios, old_termios))
                return;
 
-       cflag = port->tty->termios->c_cflag;
+       cflag = tty->termios->c_cflag;
 
        buf = kzalloc(7, GFP_KERNEL);
        if (!buf) {
                dev_err(&port->dev, "%s - out of memory.\n", __func__);
                /* Report back no change occurred */
-               *port->tty->termios = *old_termios;
+               *tty->termios = *old_termios;
                return;
        }
 
@@ -560,16 +562,24 @@ static void pl2303_set_termios(struct usb_serial_port *port,
 
        if (cflag & CSIZE) {
                switch (cflag & CSIZE) {
-                       case CS5:       buf[6] = 5;     break;
-                       case CS6:       buf[6] = 6;     break;
-                       case CS7:       buf[6] = 7;     break;
-                       default:
-                       case CS8:       buf[6] = 8;     break;
+               case CS5:
+                       buf[6] = 5;
+                       break;
+               case CS6:
+                       buf[6] = 6;
+                       break;
+               case CS7:
+                       buf[6] = 7;
+                       break;
+               default:
+               case CS8:
+                       buf[6] = 8;
+                       break;
                }
                dbg("%s - data bits = %d", __func__, buf[6]);
        }
 
-       baud = tty_get_baud_rate(port->tty);;
+       baud = tty_get_baud_rate(tty);
        dbg("%s - baud = %d", __func__, baud);
        if (baud) {
                buf[0] = baud & 0xff;
@@ -646,12 +656,13 @@ static void pl2303_set_termios(struct usb_serial_port *port,
 
        /* FIXME: Need to read back resulting baud rate */
        if (baud)
-               tty_encode_baud_rate(port->tty, baud, baud);
+               tty_encode_baud_rate(tty, baud, baud);
 
        kfree(buf);
 }
 
-static void pl2303_close(struct usb_serial_port *port, struct file *filp)
+static void pl2303_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct pl2303_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
@@ -666,7 +677,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
        spin_lock_irqsave(&priv->lock, flags);
        timeout = PL2303_CLOSING_WAIT;
        init_waitqueue_entry(&wait, current);
-       add_wait_queue(&port->tty->write_wait, &wait);
+       add_wait_queue(&tty->write_wait, &wait);
        for (;;) {
                set_current_state(TASK_INTERRUPTIBLE);
                if (pl2303_buf_data_avail(priv->buf) == 0 ||
@@ -678,7 +689,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
                spin_lock_irqsave(&priv->lock, flags);
        }
        set_current_state(TASK_RUNNING);
-       remove_wait_queue(&port->tty->write_wait, &wait);
+       remove_wait_queue(&tty->write_wait, &wait);
        /* clear out any remaining data in the buffer */
        pl2303_buf_clear(priv->buf);
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -690,9 +701,9 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
        /* for lower rates we should really know how much */
        /* data is in the buffer to compute a delay */
        /* that is not unnecessarily long) */
-       bps = tty_get_baud_rate(port->tty);
+       bps = tty_get_baud_rate(tty);
        if (bps > 1200)
-               timeout = max((HZ*2560)/bps,HZ/10);
+               timeout = max((HZ*2560)/bps, HZ/10);
        else
                timeout = 2*HZ;
        schedule_timeout_interruptible(timeout);
@@ -703,8 +714,8 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
        usb_kill_urb(port->read_urb);
        usb_kill_urb(port->interrupt_in_urb);
 
-       if (port->tty) {
-               c_cflag = port->tty->termios->c_cflag;
+       if (tty) {
+               c_cflag = tty->termios->c_cflag;
                if (c_cflag & HUPCL) {
                        /* drop DTR and RTS */
                        spin_lock_irqsave(&priv->lock, flags);
@@ -715,7 +726,8 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
        }
 }
 
-static int pl2303_open(struct usb_serial_port *port, struct file *filp)
+static int pl2303_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct ktermios tmp_termios;
        struct usb_serial *serial = port->serial;
@@ -734,11 +746,10 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp)
        }
 
        /* Setup termios */
-       if (port->tty) {
-               pl2303_set_termios(port, &tmp_termios);
-       }
+       if (tty)
+               pl2303_set_termios(tty, port, &tmp_termios);
 
-       //FIXME: need to assert RTS and DTR if CRTSCTS off
+       /* FIXME: need to assert RTS and DTR if CRTSCTS off */
 
        dbg("%s - submitting read urb", __func__);
        port->read_urb->dev = serial->dev;
@@ -746,7 +757,7 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp)
        if (result) {
                dev_err(&port->dev, "%s - failed submitting read urb,"
                        " error %d\n", __func__, result);
-               pl2303_close(port, NULL);
+               pl2303_close(tty, port, NULL);
                return -EPROTO;
        }
 
@@ -756,15 +767,16 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp)
        if (result) {
                dev_err(&port->dev, "%s - failed submitting interrupt urb,"
                        " error %d\n", __func__, result);
-               pl2303_close(port, NULL);
+               pl2303_close(tty, port, NULL);
                return -EPROTO;
        }
        return 0;
 }
 
-static int pl2303_tiocmset(struct usb_serial_port *port, struct file *file,
+static int pl2303_tiocmset(struct tty_struct *tty, struct file *file,
                           unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct pl2303_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
        u8 control;
@@ -787,8 +799,9 @@ static int pl2303_tiocmset(struct usb_serial_port *port, struct file *file,
        return set_control_lines(port->serial->dev, control);
 }
 
-static int pl2303_tiocmget(struct usb_serial_port *port, struct file *file)
+static int pl2303_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct pl2303_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
        unsigned int mcr;
@@ -839,12 +852,12 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
                status = priv->line_status;
                spin_unlock_irqrestore(&priv->lock, flags);
 
-               changed=prevstatus^status;
+               changed = prevstatus ^ status;
 
                if (((arg & TIOCM_RNG) && (changed & UART_RING)) ||
                    ((arg & TIOCM_DSR) && (changed & UART_DSR)) ||
                    ((arg & TIOCM_CD)  && (changed & UART_DCD)) ||
-                   ((arg & TIOCM_CTS) && (changed & UART_CTS)) ) {
+                   ((arg & TIOCM_CTS) && (changed & UART_CTS))) {
                        return 0;
                }
                prevstatus = status;
@@ -853,26 +866,26 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
        return 0;
 }
 
-static int pl2303_ioctl(struct usb_serial_port *port, struct file *file,
+static int pl2303_ioctl(struct tty_struct *tty, struct file *file,
                        unsigned int cmd, unsigned long arg)
 {
+       struct usb_serial_port *port = tty->driver_data;
        dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);
 
        switch (cmd) {
-               case TIOCMIWAIT:
-                       dbg("%s (%d) TIOCMIWAIT", __func__,  port->number);
-                       return wait_modem_info(port, arg);
-
-               default:
-                       dbg("%s not supported = 0x%04x", __func__, cmd);
-                       break;
+       case TIOCMIWAIT:
+               dbg("%s (%d) TIOCMIWAIT", __func__,  port->number);
+               return wait_modem_info(port, arg);
+       default:
+               dbg("%s not supported = 0x%04x", __func__, cmd);
+               break;
        }
-
        return -ENOIOCTLCMD;
 }
 
-static void pl2303_break_ctl(struct usb_serial_port *port, int break_state)
+static void pl2303_break_ctl(struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct usb_serial *serial = port->serial;
        u16 state;
        int result;
@@ -883,7 +896,8 @@ static void pl2303_break_ctl(struct usb_serial_port *port, int break_state)
                state = BREAK_OFF;
        else
                state = BREAK_ON;
-       dbg("%s - turning break %s", __func__, state==BREAK_OFF ? "off" : "on");
+       dbg("%s - turning break %s", __func__,
+                       state == BREAK_OFF ? "off" : "on");
 
        result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
                                 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
@@ -937,7 +951,7 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
        if (actual_length < length)
                return;
 
-        /* Save off the uart status for others to look at */
+       /* Save off the uart status for others to look at */
        spin_lock_irqsave(&priv->lock, flags);
        priv->line_status = data[status_idx];
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -1001,7 +1015,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
 
        if (status) {
                dbg("%s - urb status = %d", __func__, status);
-               if (!port->open_count) {
+               if (!port->port.count) {
                        dbg("%s - port is closed, exiting.", __func__);
                        return;
                }
@@ -1036,7 +1050,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
 
        /* break takes precedence over parity, */
        /* which takes precedence over framing errors */
-       if (line_status & UART_BREAK_ERROR )
+       if (line_status & UART_BREAK_ERROR)
                tty_flag = TTY_BREAK;
        else if (line_status & UART_PARITY_ERROR)
                tty_flag = TTY_PARITY;
@@ -1044,7 +1058,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
                tty_flag = TTY_FRAME;
        dbg("%s - tty_flag = %d", __func__, tty_flag);
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (tty && urb->actual_length) {
                tty_buffer_request_room(tty, urb->actual_length + 1);
                /* overrun is special, not associated with a char */
@@ -1056,7 +1070,7 @@ static void pl2303_read_bulk_callback(struct urb *urb)
        }
 
        /* Schedule the next read _if_ we are still open */
-       if (port->open_count) {
+       if (port->port.count) {
                urb->dev = port->serial->dev;
                result = usb_submit_urb(urb, GFP_ATOMIC);
                if (result)
index 94bddf0..def52d0 100644 (file)
  *      Stuart Lynne <sl@lineo.com>, Tom Rushworth <tbr@lineo.com>
  */
 
-/* 
- * The encapsultaion is designed to overcome difficulties with some USB hardware.
+/*
+ * The encapsultaion is designed to overcome difficulties with some USB
+ * hardware.
  *
  * While the USB protocol has a CRC over the data while in transit, i.e. while
- * being carried over the bus, there is no end to end protection. If the hardware
- * has any problems getting the data into or out of the USB transmit and receive
- * FIFO's then data can be lost. 
+ * being carried over the bus, there is no end to end protection. If the
+ * hardware has any problems getting the data into or out of the USB transmit
+ * and receive FIFO's then data can be lost.
  *
- * This protocol adds a two byte trailer to each USB packet to specify the number
- * of bytes of valid data and a 10 bit CRC that will allow the receiver to verify
- * that the entire USB packet was received without error.
+ * This protocol adds a two byte trailer to each USB packet to specify the
+ * number of bytes of valid data and a 10 bit CRC that will allow the receiver
+ * to verify that the entire USB packet was received without error.
  *
- * Because in this case the sender and receiver are the class and function drivers
- * there is now end to end protection.
+ * Because in this case the sender and receiver are the class and function
+ * drivers there is now end to end protection.
  *
- * There is an additional option that can be used to force all transmitted packets
- * to be padded to the maximum packet size. This provides a work around for some
- * devices which have problems with small USB packets.
+ * There is an additional option that can be used to force all transmitted
+ * packets to be padded to the maximum packet size. This provides a work
+ * around for some devices which have problems with small USB packets.
  *
  * Assuming a packetsize of N:
  *
  *      | Data Length       | 10 bit CRC                                |
  *      + 7 . 6 . 5 . 4 . 3 . 2 . 1 . 0 | 7 . 6 . 5 . 4 . 3 . 2 . 1 . 0 +
  *
- * The 10 bit CRC is computed across the sent data, followed by the trailer with
- * the length set and the CRC set to zero. The CRC is then OR'd into the trailer.
+ * The 10 bit CRC is computed across the sent data, followed by the trailer
+ * with the length set and the CRC set to zero. The CRC is then OR'd into
+ * the trailer.
  *
- * When received a 10 bit CRC is computed over the entire frame including the trailer
- * and should be equal to zero.
+ * When received a 10 bit CRC is computed over the entire frame including
+ * the trailer and should be equal to zero.
  *
  * Two module parameters are used to control the encapsulation, if both are
  * turned of the module works as a simple serial device with NO
@@ -69,7 +71,7 @@
 #include <linux/tty_flip.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 
@@ -86,12 +88,12 @@ static int padded = CONFIG_USB_SERIAL_SAFE_PADDED;
 #define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com"
 #define DRIVER_DESC "USB Safe Encapsulated Serial"
 
-MODULE_AUTHOR (DRIVER_AUTHOR);
-MODULE_DESCRIPTION (DRIVER_DESC);
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
-static __u16 vendor;           // no default
-static __u16 product;          // no default
+static __u16 vendor;           /* no default */
+static __u16 product;          /* no default */
 module_param(vendor, ushort, 0);
 MODULE_PARM_DESC(vendor, "User specified USB idVendor (required)");
 module_param(product, ushort, 0);
@@ -122,30 +124,31 @@ MODULE_PARM_DESC(padded, "Pad to full wMaxPacketSize On/Off");
 #define LINEO_SAFESERIAL_CRC_PADDED             0x02
 
 
-#define MY_USB_DEVICE(vend,prod,dc,ic,isc) \
-        .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_CLASS | \
-                USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS, \
-        .idVendor = (vend), \
-        .idProduct = (prod),\
-        .bDeviceClass = (dc),\
-        .bInterfaceClass = (ic), \
-        .bInterfaceSubClass = (isc),
+#define MY_USB_DEVICE(vend, prod, dc, ic, isc) \
+       .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
+                      USB_DEVICE_ID_MATCH_DEV_CLASS | \
+                      USB_DEVICE_ID_MATCH_INT_CLASS | \
+                      USB_DEVICE_ID_MATCH_INT_SUBCLASS, \
+       .idVendor = (vend), \
+       .idProduct = (prod),\
+       .bDeviceClass = (dc),\
+       .bInterfaceClass = (ic), \
+       .bInterfaceSubClass = (isc),
 
 static struct usb_device_id id_table[] = {
-       {MY_USB_DEVICE (0x49f, 0xffff, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},  // Itsy
-       {MY_USB_DEVICE (0x3f0, 0x2101, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},  // Calypso
-       {MY_USB_DEVICE (0x4dd, 0x8001, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},  // Iris 
-       {MY_USB_DEVICE (0x4dd, 0x8002, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},  // Collie 
-       {MY_USB_DEVICE (0x4dd, 0x8003, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},  // Collie 
-       {MY_USB_DEVICE (0x4dd, 0x8004, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},  // Collie 
-       {MY_USB_DEVICE (0x5f9, 0xffff, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},  // Sharp tmp
-       // extra null entry for module 
-       // vendor/produc parameters
-       {MY_USB_DEVICE (0, 0, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},
-       {}                      // terminating entry 
+       {MY_USB_DEVICE(0x49f, 0xffff, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},   /* Itsy */
+       {MY_USB_DEVICE(0x3f0, 0x2101, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},   /* Calypso */
+       {MY_USB_DEVICE(0x4dd, 0x8001, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},   /* Iris */
+       {MY_USB_DEVICE(0x4dd, 0x8002, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},   /* Collie */
+       {MY_USB_DEVICE(0x4dd, 0x8003, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},   /* Collie */
+       {MY_USB_DEVICE(0x4dd, 0x8004, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},   /* Collie */
+       {MY_USB_DEVICE(0x5f9, 0xffff, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},   /* Sharp tmp */
+       /* extra null entry for module vendor/produc parameters */
+       {MY_USB_DEVICE(0, 0, CDC_DEVICE_CLASS, LINEO_INTERFACE_CLASS, LINEO_INTERFACE_SUBCLASS_SAFESERIAL)},
+       {}                      /* terminating entry  */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table);
+MODULE_DEVICE_TABLE(usb, id_table);
 
 static struct usb_driver safe_driver = {
        .name =         "safe_serial",
@@ -156,29 +159,45 @@ static struct usb_driver safe_driver = {
 };
 
 static const __u16 crc10_table[256] = {
-       0x000, 0x233, 0x255, 0x066, 0x299, 0x0aa, 0x0cc, 0x2ff, 0x301, 0x132, 0x154, 0x367, 0x198, 0x3ab, 0x3cd, 0x1fe,
-       0x031, 0x202, 0x264, 0x057, 0x2a8, 0x09b, 0x0fd, 0x2ce, 0x330, 0x103, 0x165, 0x356, 0x1a9, 0x39a, 0x3fc, 0x1cf,
-       0x062, 0x251, 0x237, 0x004, 0x2fb, 0x0c8, 0x0ae, 0x29d, 0x363, 0x150, 0x136, 0x305, 0x1fa, 0x3c9, 0x3af, 0x19c,
-       0x053, 0x260, 0x206, 0x035, 0x2ca, 0x0f9, 0x09f, 0x2ac, 0x352, 0x161, 0x107, 0x334, 0x1cb, 0x3f8, 0x39e, 0x1ad,
-       0x0c4, 0x2f7, 0x291, 0x0a2, 0x25d, 0x06e, 0x008, 0x23b, 0x3c5, 0x1f6, 0x190, 0x3a3, 0x15c, 0x36f, 0x309, 0x13a,
-       0x0f5, 0x2c6, 0x2a0, 0x093, 0x26c, 0x05f, 0x039, 0x20a, 0x3f4, 0x1c7, 0x1a1, 0x392, 0x16d, 0x35e, 0x338, 0x10b,
-       0x0a6, 0x295, 0x2f3, 0x0c0, 0x23f, 0x00c, 0x06a, 0x259, 0x3a7, 0x194, 0x1f2, 0x3c1, 0x13e, 0x30d, 0x36b, 0x158,
-       0x097, 0x2a4, 0x2c2, 0x0f1, 0x20e, 0x03d, 0x05b, 0x268, 0x396, 0x1a5, 0x1c3, 0x3f0, 0x10f, 0x33c, 0x35a, 0x169,
-       0x188, 0x3bb, 0x3dd, 0x1ee, 0x311, 0x122, 0x144, 0x377, 0x289, 0x0ba, 0x0dc, 0x2ef, 0x010, 0x223, 0x245, 0x076,
-       0x1b9, 0x38a, 0x3ec, 0x1df, 0x320, 0x113, 0x175, 0x346, 0x2b8, 0x08b, 0x0ed, 0x2de, 0x021, 0x212, 0x274, 0x047,
-       0x1ea, 0x3d9, 0x3bf, 0x18c, 0x373, 0x140, 0x126, 0x315, 0x2eb, 0x0d8, 0x0be, 0x28d, 0x072, 0x241, 0x227, 0x014,
-       0x1db, 0x3e8, 0x38e, 0x1bd, 0x342, 0x171, 0x117, 0x324, 0x2da, 0x0e9, 0x08f, 0x2bc, 0x043, 0x270, 0x216, 0x025,
-       0x14c, 0x37f, 0x319, 0x12a, 0x3d5, 0x1e6, 0x180, 0x3b3, 0x24d, 0x07e, 0x018, 0x22b, 0x0d4, 0x2e7, 0x281, 0x0b2,
-       0x17d, 0x34e, 0x328, 0x11b, 0x3e4, 0x1d7, 0x1b1, 0x382, 0x27c, 0x04f, 0x029, 0x21a, 0x0e5, 0x2d6, 0x2b0, 0x083,
-       0x12e, 0x31d, 0x37b, 0x148, 0x3b7, 0x184, 0x1e2, 0x3d1, 0x22f, 0x01c, 0x07a, 0x249, 0x0b6, 0x285, 0x2e3, 0x0d0,
-       0x11f, 0x32c, 0x34a, 0x179, 0x386, 0x1b5, 0x1d3, 0x3e0, 0x21e, 0x02d, 0x04b, 0x278, 0x087, 0x2b4, 0x2d2, 0x0e1,
+       0x000, 0x233, 0x255, 0x066, 0x299, 0x0aa, 0x0cc, 0x2ff,
+       0x301, 0x132, 0x154, 0x367, 0x198, 0x3ab, 0x3cd, 0x1fe,
+       0x031, 0x202, 0x264, 0x057, 0x2a8, 0x09b, 0x0fd, 0x2ce,
+       0x330, 0x103, 0x165, 0x356, 0x1a9, 0x39a, 0x3fc, 0x1cf,
+       0x062, 0x251, 0x237, 0x004, 0x2fb, 0x0c8, 0x0ae, 0x29d,
+       0x363, 0x150, 0x136, 0x305, 0x1fa, 0x3c9, 0x3af, 0x19c,
+       0x053, 0x260, 0x206, 0x035, 0x2ca, 0x0f9, 0x09f, 0x2ac,
+       0x352, 0x161, 0x107, 0x334, 0x1cb, 0x3f8, 0x39e, 0x1ad,
+       0x0c4, 0x2f7, 0x291, 0x0a2, 0x25d, 0x06e, 0x008, 0x23b,
+       0x3c5, 0x1f6, 0x190, 0x3a3, 0x15c, 0x36f, 0x309, 0x13a,
+       0x0f5, 0x2c6, 0x2a0, 0x093, 0x26c, 0x05f, 0x039, 0x20a,
+       0x3f4, 0x1c7, 0x1a1, 0x392, 0x16d, 0x35e, 0x338, 0x10b,
+       0x0a6, 0x295, 0x2f3, 0x0c0, 0x23f, 0x00c, 0x06a, 0x259,
+       0x3a7, 0x194, 0x1f2, 0x3c1, 0x13e, 0x30d, 0x36b, 0x158,
+       0x097, 0x2a4, 0x2c2, 0x0f1, 0x20e, 0x03d, 0x05b, 0x268,
+       0x396, 0x1a5, 0x1c3, 0x3f0, 0x10f, 0x33c, 0x35a, 0x169,
+       0x188, 0x3bb, 0x3dd, 0x1ee, 0x311, 0x122, 0x144, 0x377,
+       0x289, 0x0ba, 0x0dc, 0x2ef, 0x010, 0x223, 0x245, 0x076,
+       0x1b9, 0x38a, 0x3ec, 0x1df, 0x320, 0x113, 0x175, 0x346,
+       0x2b8, 0x08b, 0x0ed, 0x2de, 0x021, 0x212, 0x274, 0x047,
+       0x1ea, 0x3d9, 0x3bf, 0x18c, 0x373, 0x140, 0x126, 0x315,
+       0x2eb, 0x0d8, 0x0be, 0x28d, 0x072, 0x241, 0x227, 0x014,
+       0x1db, 0x3e8, 0x38e, 0x1bd, 0x342, 0x171, 0x117, 0x324,
+       0x2da, 0x0e9, 0x08f, 0x2bc, 0x043, 0x270, 0x216, 0x025,
+       0x14c, 0x37f, 0x319, 0x12a, 0x3d5, 0x1e6, 0x180, 0x3b3,
+       0x24d, 0x07e, 0x018, 0x22b, 0x0d4, 0x2e7, 0x281, 0x0b2,
+       0x17d, 0x34e, 0x328, 0x11b, 0x3e4, 0x1d7, 0x1b1, 0x382,
+       0x27c, 0x04f, 0x029, 0x21a, 0x0e5, 0x2d6, 0x2b0, 0x083,
+       0x12e, 0x31d, 0x37b, 0x148, 0x3b7, 0x184, 0x1e2, 0x3d1,
+       0x22f, 0x01c, 0x07a, 0x249, 0x0b6, 0x285, 0x2e3, 0x0d0,
+       0x11f, 0x32c, 0x34a, 0x179, 0x386, 0x1b5, 0x1d3, 0x3e0,
+       0x21e, 0x02d, 0x04b, 0x278, 0x087, 0x2b4, 0x2d2, 0x0e1,
 };
 
-#define CRC10_INITFCS     0x000        // Initial FCS value
-#define CRC10_GOODFCS     0x000        // Good final FCS value
-#define CRC10_FCS(fcs, c) ( (((fcs) << 8) & 0x3ff) ^ crc10_table[((fcs) >> 2) & 0xff] ^ (c))
+#define CRC10_INITFCS     0x000        /* Initial FCS value */
+#define CRC10_GOODFCS     0x000        /* Good final FCS value */
+#define CRC10_FCS(fcs, c) ((((fcs) << 8) & 0x3ff) ^ crc10_table[((fcs) >> 2) & 0xff] ^ (c))
 
-/**     
+/**
  * fcs_compute10 - memcpy and calculate 10 bit CRC across buffer
  * @sp: pointer to buffer
  * @len: number of bytes
@@ -187,13 +206,13 @@ static const __u16 crc10_table[256] = {
  * Perform a memcpy and calculate fcs using ppp 10bit CRC algorithm. Return
  * new 10 bit FCS.
  */
-static __u16 __inline__ fcs_compute10 (unsigned char *sp, int len, __u16 fcs)
+static __u16 __inline__ fcs_compute10(unsigned char *sp, int len, __u16 fcs)
 {
-       for (; len-- > 0; fcs = CRC10_FCS (fcs, *sp++));
+       for (; len-- > 0; fcs = CRC10_FCS(fcs, *sp++));
        return fcs;
 }
 
-static void safe_read_bulk_callback (struct urb *urb)
+static void safe_read_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port *port =  urb->context;
        unsigned char *data = urb->transfer_buffer;
@@ -201,7 +220,7 @@ static void safe_read_bulk_callback (struct urb *urb)
        int result;
        int status = urb->status;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        if (status) {
                dbg("%s - nonzero read bulk status received: %d",
@@ -209,76 +228,82 @@ static void safe_read_bulk_callback (struct urb *urb)
                return;
        }
 
-       dbg ("safe_read_bulk_callback length: %d", port->read_urb->actual_length);
+       dbg("safe_read_bulk_callback length: %d",
+                                       port->read_urb->actual_length);
 #ifdef ECHO_RCV
        {
                int i;
                unsigned char *cp = port->read_urb->transfer_buffer;
                for (i = 0; i < port->read_urb->actual_length; i++) {
-                       if ((i % 32) == 0) {
-                               printk ("\nru[%02x] ", i);
-                       }
-                       printk ("%02x ", *cp++);
+                       if ((i % 32) == 0)
+                               printk("\nru[%02x] ", i);
+                       printk("%02x ", *cp++);
                }
-               printk ("\n");
+               printk("\n");
        }
 #endif
        if (safe) {
                __u16 fcs;
-               if (!(fcs = fcs_compute10 (data, length, CRC10_INITFCS))) {
+               fcs = fcs_compute10(data, length, CRC10_INITFCS);
+               if (!fcs) {
                        int actual_length = data[length - 2] >> 2;
                        if (actual_length <= (length - 2)) {
-                               info ("%s - actual: %d", __func__, actual_length);
-                               tty_insert_flip_string(port->tty, data, actual_length);
-                               tty_flip_buffer_push (port->tty);
+                               info("%s - actual: %d", __func__,
+                                                       actual_length);
+                               tty_insert_flip_string(port->port.tty,
+                                                       data, actual_length);
+                               tty_flip_buffer_push(port->port.tty);
                        } else {
-                               err ("%s - inconsistent lengths %d:%d", __func__,
-                                    actual_length, length);
+                               err("%s - inconsistent lengths %d:%d",
+                                       __func__, actual_length, length);
                        }
                } else {
-                       err ("%s - bad CRC %x", __func__, fcs);
+                       err("%s - bad CRC %x", __func__, fcs);
                }
        } else {
-               tty_insert_flip_string(port->tty, data, length);
-               tty_flip_buffer_push (port->tty);
+               tty_insert_flip_string(port->port.tty, data, length);
+               tty_flip_buffer_push(port->port.tty);
        }
 
        /* Continue trying to always read  */
-       usb_fill_bulk_urb (urb, port->serial->dev,
-                      usb_rcvbulkpipe (port->serial->dev, port->bulk_in_endpointAddress),
-                      urb->transfer_buffer, urb->transfer_buffer_length,
-                      safe_read_bulk_callback, port);
-
-       if ((result = usb_submit_urb (urb, GFP_ATOMIC))) {
-               err ("%s - failed resubmitting read urb, error %d", __func__, result);
+       usb_fill_bulk_urb(urb, port->serial->dev,
+                       usb_rcvbulkpipe(port->serial->dev,
+                                       port->bulk_in_endpointAddress),
+                       urb->transfer_buffer, urb->transfer_buffer_length,
+                       safe_read_bulk_callback, port);
+
+       result = usb_submit_urb(urb, GFP_ATOMIC);
+       if (result)
+               err("%s - failed resubmitting read urb, error %d",
+                                                       __func__, result);
                /* FIXME: Need a mechanism to retry later if this happens */
-       }
 }
 
-static int safe_write (struct usb_serial_port *port, const unsigned char *buf, int count)
+static int safe_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count)
 {
        unsigned char *data;
        int result;
        int i;
        int packet_length;
 
-       dbg ("safe_write port: %p %d urb: %p count: %d", port, port->number, port->write_urb,
-            count);
+       dbg("safe_write port: %p %d urb: %p count: %d",
+                               port, port->number, port->write_urb, count);
 
        if (!port->write_urb) {
-               dbg ("%s - write urb NULL", __func__);
+               dbg("%s - write urb NULL", __func__);
                return 0;
        }
 
-       dbg ("safe_write write_urb: %d transfer_buffer_length",
+       dbg("safe_write write_urb: %d transfer_buffer_length",
             port->write_urb->transfer_buffer_length);
 
        if (!port->write_urb->transfer_buffer_length) {
-               dbg ("%s - write urb transfer_buffer_length zero", __func__);
+               dbg("%s - write urb transfer_buffer_length zero", __func__);
                return 0;
        }
        if (count == 0) {
-               dbg ("%s - write request of 0 bytes", __func__);
+               dbg("%s - write request of 0 bytes", __func__);
                return 0;
        }
        spin_lock_bh(&port->lock);
@@ -290,85 +315,85 @@ static int safe_write (struct usb_serial_port *port, const unsigned char *buf, i
        port->write_urb_busy = 1;
        spin_unlock_bh(&port->lock);
 
-       packet_length = port->bulk_out_size;    // get max packetsize
+       packet_length = port->bulk_out_size;    /* get max packetsize */
 
-       i = packet_length - (safe ? 2 : 0);     // get bytes to send
+       i = packet_length - (safe ? 2 : 0);     /* get bytes to send */
        count = (count > i) ? i : count;
 
 
-       // get the data into the transfer buffer
+       /* get the data into the transfer buffer */
        data = port->write_urb->transfer_buffer;
-       memset (data, '0', packet_length);
+       memset(data, '0', packet_length);
 
-       memcpy (data, buf, count);
+       memcpy(data, buf, count);
 
        if (safe) {
                __u16 fcs;
 
-               // pad if necessary
-               if (!padded) {
+               /* pad if necessary */
+               if (!padded)
                        packet_length = count + 2;
-               }
-               // set count
+               /* set count */
                data[packet_length - 2] = count << 2;
                data[packet_length - 1] = 0;
 
-               // compute fcs and insert into trailer
-               fcs = fcs_compute10 (data, packet_length, CRC10_INITFCS);
+               /* compute fcs and insert into trailer */
+               fcs = fcs_compute10(data, packet_length, CRC10_INITFCS);
                data[packet_length - 2] |= fcs >> 8;
                data[packet_length - 1] |= fcs & 0xff;
 
-               // set length to send
+               /* set length to send */
                port->write_urb->transfer_buffer_length = packet_length;
        } else {
                port->write_urb->transfer_buffer_length = count;
        }
 
-       usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer);
+       usb_serial_debug_data(debug, &port->dev, __func__, count,
+                                       port->write_urb->transfer_buffer);
 #ifdef ECHO_TX
        {
                int i;
                unsigned char *cp = port->write_urb->transfer_buffer;
                for (i = 0; i < port->write_urb->transfer_buffer_length; i++) {
-                       if ((i % 32) == 0) {
-                               printk ("\nsu[%02x] ", i);
-                       }
-                       printk ("%02x ", *cp++);
+                       if ((i % 32) == 0)
+                               printk("\nsu[%02x] ", i);
+                       printk("%02x ", *cp++);
                }
-               printk ("\n");
+               printk("\n");
        }
 #endif
        port->write_urb->dev = port->serial->dev;
-       if ((result = usb_submit_urb (port->write_urb, GFP_KERNEL))) {
+       result = usb_submit_urb(port->write_urb, GFP_KERNEL);
+       if (result) {
                port->write_urb_busy = 0;
-               err ("%s - failed submitting write urb, error %d", __func__, result);
+               err("%s - failed submitting write urb, error %d",
+                                                       __func__, result);
                return 0;
        }
-       dbg ("%s urb: %p submitted", __func__, port->write_urb);
+       dbg("%s urb: %p submitted", __func__, port->write_urb);
 
-       return (count);
+       return count;
 }
 
-static int safe_write_room (struct usb_serial_port *port)
+static int safe_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        int room = 0;           /* Default: no room */
        unsigned long flags;
 
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        spin_lock_irqsave(&port->lock, flags);
        if (port->write_urb_busy)
                room = port->bulk_out_size - (safe ? 2 : 0);
        spin_unlock_irqrestore(&port->lock, flags);
 
-       if (room) {
-               dbg ("safe_write_room returns %d", room);
-       }
-
+       if (room)
+               dbg("safe_write_room returns %d", room);
        return room;
 }
 
-static int safe_startup (struct usb_serial *serial)
+static int safe_startup(struct usb_serial *serial)
 {
        switch (serial->interface->cur_altsetting->desc.bInterfaceProtocol) {
        case LINEO_SAFESERIAL_CRC:
@@ -396,17 +421,18 @@ static struct usb_serial_driver safe_device = {
        .attach =               safe_startup,
 };
 
-static int __init safe_init (void)
+static int __init safe_init(void)
 {
        int i, retval;
 
-       info (DRIVER_VERSION " " DRIVER_AUTHOR);
-       info (DRIVER_DESC);
-       info ("vendor: %x product: %x safe: %d padded: %d\n", vendor, product, safe, padded);
+       info(DRIVER_VERSION " " DRIVER_AUTHOR);
+       info(DRIVER_DESC);
+       info("vendor: %x product: %x safe: %d padded: %d\n",
+                                       vendor, product, safe, padded);
 
-       // if we have vendor / product parameters patch them into id list
+       /* if we have vendor / product parameters patch them into id list */
        if (vendor || product) {
-               info ("vendor: %x product: %x\n", vendor, product);
+               info("vendor: %x product: %x\n", vendor, product);
 
                for (i = 0; i < ARRAY_SIZE(id_table); i++) {
                        if (!id_table[i].idVendor && !id_table[i].idProduct) {
@@ -431,11 +457,11 @@ failed_usb_serial_register:
        return retval;
 }
 
-static void __exit safe_exit (void)
+static void __exit safe_exit(void)
 {
-       usb_deregister (&safe_driver);
-       usb_serial_deregister (&safe_device);
+       usb_deregister(&safe_driver);
+       usb_serial_deregister(&safe_device);
 }
 
-module_init (safe_init);
-module_exit (safe_exit);
+module_init(safe_init);
+module_exit(safe_exit);
index 29074c1..2f6f152 100644 (file)
@@ -250,7 +250,8 @@ struct sierra_port_private {
        int ri_state;
 };
 
-static int sierra_send_setup(struct usb_serial_port *port)
+static int sierra_send_setup(struct tty_struct *tty,
+                                               struct usb_serial_port *port)
 {
        struct usb_serial *serial = port->serial;
        struct sierra_port_private *portdata;
@@ -260,7 +261,7 @@ static int sierra_send_setup(struct usb_serial_port *port)
 
        portdata = usb_get_serial_port_data(port);
 
-       if (port->tty) {
+       if (tty) {
                int val = 0;
                if (portdata->dtr_state)
                        val |= 0x01;
@@ -284,32 +285,17 @@ static int sierra_send_setup(struct usb_serial_port *port)
        return 0;
 }
 
-static void sierra_rx_throttle(struct usb_serial_port *port)
+static void sierra_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        dbg("%s", __func__);
+       tty_termios_copy_hw(tty->termios, old_termios);
+       sierra_send_setup(tty, port);
 }
 
-static void sierra_rx_unthrottle(struct usb_serial_port *port)
-{
-       dbg("%s", __func__);
-}
-
-static void sierra_break_ctl(struct usb_serial_port *port, int break_state)
-{
-       /* Unfortunately, I don't know how to send a break */
-       dbg("%s", __func__);
-}
-
-static void sierra_set_termios(struct usb_serial_port *port,
-                       struct ktermios *old_termios)
-{
-       dbg("%s", __func__);
-       tty_termios_copy_hw(port->tty->termios, old_termios);
-       sierra_send_setup(port);
-}
-
-static int sierra_tiocmget(struct usb_serial_port *port, struct file *file)
+static int sierra_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        unsigned int value;
        struct sierra_port_private *portdata;
 
@@ -325,9 +311,10 @@ static int sierra_tiocmget(struct usb_serial_port *port, struct file *file)
        return value;
 }
 
-static int sierra_tiocmset(struct usb_serial_port *port, struct file *file,
+static int sierra_tiocmset(struct tty_struct *tty, struct file *file,
                        unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct sierra_port_private *portdata;
 
        portdata = usb_get_serial_port_data(port);
@@ -341,13 +328,7 @@ static int sierra_tiocmset(struct usb_serial_port *port, struct file *file,
                portdata->rts_state = 0;
        if (clear & TIOCM_DTR)
                portdata->dtr_state = 0;
-       return sierra_send_setup(port);
-}
-
-static int sierra_ioctl(struct usb_serial_port *port, struct file *file,
-                       unsigned int cmd, unsigned long arg)
-{
-       return -ENOIOCTLCMD;
+       return sierra_send_setup(tty, port);
 }
 
 static void sierra_outdat_callback(struct urb *urb)
@@ -374,8 +355,8 @@ static void sierra_outdat_callback(struct urb *urb)
 }
 
 /* Write */
-static int sierra_write(struct usb_serial_port *port,
-                       const unsigned char *buf, int count)
+static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count)
 {
        struct sierra_port_private *portdata = usb_get_serial_port_data(port);
        struct usb_serial *serial = port->serial;
@@ -463,7 +444,7 @@ static void sierra_indat_callback(struct urb *urb)
                dbg("%s: nonzero status: %d on endpoint %02x.",
                    __func__, status, endpoint);
        } else {
-               tty = port->tty;
+               tty = port->port.tty;
                if (urb->actual_length) {
                        tty_buffer_request_room(tty, urb->actual_length);
                        tty_insert_flip_string(tty, data, urb->actual_length);
@@ -473,7 +454,7 @@ static void sierra_indat_callback(struct urb *urb)
                }
 
                /* Resubmit urb so we continue receiving */
-               if (port->open_count && status != -ESHUTDOWN) {
+               if (port->port.count && status != -ESHUTDOWN) {
                        err = usb_submit_urb(urb, GFP_ATOMIC);
                        if (err)
                                dev_err(&port->dev, "resubmit read urb failed."
@@ -517,9 +498,9 @@ static void sierra_instat_callback(struct urb *urb)
                        portdata->dsr_state = ((signals & 0x02) ? 1 : 0);
                        portdata->ri_state = ((signals & 0x08) ? 1 : 0);
 
-                       if (port->tty && !C_CLOCAL(port->tty) &&
+                       if (port->port.tty && !C_CLOCAL(port->port.tty) &&
                                        old_dcd_state && !portdata->dcd_state)
-                               tty_hangup(port->tty);
+                               tty_hangup(port->port.tty);
                } else {
                        dbg("%s: type %x req %x", __func__,
                                req_pkt->bRequestType, req_pkt->bRequest);
@@ -537,8 +518,9 @@ static void sierra_instat_callback(struct urb *urb)
        }
 }
 
-static int sierra_write_room(struct usb_serial_port *port)
+static int sierra_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct sierra_port_private *portdata = usb_get_serial_port_data(port);
        unsigned long flags;
 
@@ -557,22 +539,8 @@ static int sierra_write_room(struct usb_serial_port *port)
        return 2048;
 }
 
-static int sierra_chars_in_buffer(struct usb_serial_port *port)
-{
-       dbg("%s - port %d", __func__, port->number);
-
-       /*
-        * We can't really account for how much data we
-        * have sent out, but hasn't made it through to the
-        * device as we can't see the backend here, so just
-        * tell the tty layer that everything is flushed.
-        *
-        * FIXME: should walk the outstanding urbs info
-        */
-       return 0;
-}
-
-static int sierra_open(struct usb_serial_port *port, struct file *filp)
+static int sierra_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct sierra_port_private *portdata;
        struct usb_serial *serial = port->serial;
@@ -612,9 +580,10 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp)
                }
        }
 
-       port->tty->low_latency = 1;
+       if (tty)
+               tty->low_latency = 1;
 
-       sierra_send_setup(port);
+       sierra_send_setup(tty, port);
 
        /* start up the interrupt endpoint if we have one */
        if (port->interrupt_in_urb) {
@@ -626,7 +595,8 @@ static int sierra_open(struct usb_serial_port *port, struct file *filp)
        return 0;
 }
 
-static void sierra_close(struct usb_serial_port *port, struct file *filp)
+static void sierra_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        int i;
        struct usb_serial *serial = port->serial;
@@ -641,7 +611,7 @@ static void sierra_close(struct usb_serial_port *port, struct file *filp)
        if (serial->dev) {
                mutex_lock(&serial->disc_mutex);
                if (!serial->disconnected)
-                       sierra_send_setup(port);
+                       sierra_send_setup(tty, port);
                mutex_unlock(&serial->disc_mutex);
 
                /* Stop reading/writing urbs */
@@ -651,7 +621,7 @@ static void sierra_close(struct usb_serial_port *port, struct file *filp)
 
        usb_kill_urb(port->interrupt_in_urb);
 
-       port->tty = NULL;
+       port->port.tty = NULL;  /* FIXME */
 }
 
 static int sierra_startup(struct usb_serial *serial)
@@ -754,12 +724,7 @@ static struct usb_serial_driver sierra_device = {
        .close             = sierra_close,
        .write             = sierra_write,
        .write_room        = sierra_write_room,
-       .chars_in_buffer   = sierra_chars_in_buffer,
-       .throttle          = sierra_rx_throttle,
-       .unthrottle        = sierra_rx_unthrottle,
-       .ioctl             = sierra_ioctl,
        .set_termios       = sierra_set_termios,
-       .break_ctl         = sierra_break_ctl,
        .tiocmget          = sierra_tiocmget,
        .tiocmset          = sierra_tiocmset,
        .attach            = sierra_startup,
@@ -792,7 +757,7 @@ failed_device_register:
 
 static void __exit sierra_exit(void)
 {
-       usb_deregister (&sierra_driver);
+       usb_deregister(&sierra_driver);
        usb_serial_deregister(&sierra_device);
 }
 
index 55b2570..283cf6b 100644 (file)
@@ -208,7 +208,7 @@ static inline unsigned int ringbuf_avail_data(struct ringbuf *pb)
 {
        if (pb == NULL)
                return 0;
-       return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size);
+       return (pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size;
 }
 
 /* get the number of space in the pipo */
@@ -216,7 +216,7 @@ static inline unsigned int ringbuf_avail_space(struct ringbuf *pb)
 {
        if (pb == NULL)
                return 0;
-       return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size);
+       return (pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size;
 }
 
 /* put count data into pipo */
@@ -448,7 +448,8 @@ static void spcp8x5_set_workMode(struct usb_device *dev, u16 value,
 
 /* close the serial port. We should wait for data sending to device 1st and
  * then kill all urb. */
-static void spcp8x5_close(struct usb_serial_port *port, struct file *filp)
+static void spcp8x5_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct spcp8x5_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
@@ -464,7 +465,7 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp)
        spin_lock_irqsave(&priv->lock, flags);
        timeout = SPCP8x5_CLOSING_WAIT;
        init_waitqueue_entry(&wait, current);
-       add_wait_queue(&port->tty->write_wait, &wait);
+       add_wait_queue(&tty->write_wait, &wait);
        for (;;) {
                set_current_state(TASK_INTERRUPTIBLE);
                if (ringbuf_avail_data(priv->buf) == 0 ||
@@ -475,7 +476,7 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp)
                spin_lock_irqsave(&priv->lock, flags);
        }
        set_current_state(TASK_RUNNING);
-       remove_wait_queue(&port->tty->write_wait, &wait);
+       remove_wait_queue(&tty->write_wait, &wait);
 
        /* clear out any remaining data in the buffer */
        clear_ringbuf(priv->buf);
@@ -486,7 +487,7 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp)
         * flow control for data rates of 1200 bps or more, for lower rates we
         * should really know how much data is in the buffer to compute a delay
         * that is not unnecessarily long) */
-       bps = tty_get_baud_rate(port->tty);
+       bps = tty_get_baud_rate(tty);
        if (bps > 1200)
                timeout = max((HZ*2560) / bps, HZ/10);
        else
@@ -495,8 +496,8 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp)
        schedule_timeout(timeout);
 
        /* clear control lines */
-       if (port->tty) {
-               c_cflag = port->tty->termios->c_cflag;
+       if (tty) {
+               c_cflag = tty->termios->c_cflag;
                if (c_cflag & HUPCL) {
                        spin_lock_irqsave(&priv->lock, flags);
                        priv->line_control = 0;
@@ -518,14 +519,14 @@ static void spcp8x5_close(struct usb_serial_port *port, struct file *filp)
 }
 
 /* set the serial param for transfer. we should check if we really need to
- * transfer. then if be set flow contorl we should do this too. */
-static void spcp8x5_set_termios(struct usb_serial_port *port,
-                               struct ktermios *old_termios)
+ * transfer. if we set flow control we should do this too. */
+static void spcp8x5_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct usb_serial *serial = port->serial;
        struct spcp8x5_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
-       unsigned int cflag = port->tty->termios->c_cflag;
+       unsigned int cflag = tty->termios->c_cflag;
        unsigned int old_cflag = old_termios->c_cflag;
        unsigned short uartdata;
        unsigned char buf[2] = {0, 0};
@@ -533,21 +534,19 @@ static void spcp8x5_set_termios(struct usb_serial_port *port,
        int i;
        u8 control;
 
-       if ((!port->tty) || (!port->tty->termios))
-               return;
-
        /* for the 1st time call this function */
        spin_lock_irqsave(&priv->lock, flags);
        if (!priv->termios_initialized) {
-               *(port->tty->termios) = tty_std_termios;
-               port->tty->termios->c_cflag = B115200 | CS8 | CREAD |
-                                             HUPCL | CLOCAL;
+               *(tty->termios) = tty_std_termios;
+               tty->termios->c_cflag = B115200 | CS8 | CREAD | HUPCL | CLOCAL;
+               tty->termios->c_ispeed = 115200;
+               tty->termios->c_ospeed = 115200;
                priv->termios_initialized = 1;
        }
        spin_unlock_irqrestore(&priv->lock, flags);
 
        /* check that they really want us to change something */
-       if (!tty_termios_hw_change(port->tty->termios, old_termios))
+       if (!tty_termios_hw_change(tty->termios, old_termios))
                return;
 
        /* set DTR/RTS active */
@@ -567,7 +566,7 @@ static void spcp8x5_set_termios(struct usb_serial_port *port,
        }
 
        /* Set Baud Rate */
-       baud = tty_get_baud_rate(port->tty);;
+       baud = tty_get_baud_rate(tty);;
        switch (baud) {
        case 300:       buf[0] = 0x00;  break;
        case 600:       buf[0] = 0x01;  break;
@@ -643,7 +642,8 @@ static void spcp8x5_set_termios(struct usb_serial_port *port,
 
 /* open the serial port. do some usb system call. set termios and get the line
  * status of the device. then submit the read urb */
-static int spcp8x5_open(struct usb_serial_port *port, struct file *filp)
+static int spcp8x5_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct ktermios tmp_termios;
        struct usb_serial *serial = port->serial;
@@ -665,7 +665,7 @@ static int spcp8x5_open(struct usb_serial_port *port, struct file *filp)
                return ret;
 
        spin_lock_irqsave(&priv->lock, flags);
-       if (port->tty->termios->c_cflag & CBAUD)
+       if (tty && (tty->termios->c_cflag & CBAUD))
                priv->line_control = MCR_DTR | MCR_RTS;
        else
                priv->line_control = 0;
@@ -674,8 +674,8 @@ static int spcp8x5_open(struct usb_serial_port *port, struct file *filp)
        spcp8x5_set_ctrlLine(serial->dev, priv->line_control , priv->type);
 
        /* Setup termios */
-       if (port->tty)
-               spcp8x5_set_termios(port, &tmp_termios);
+       if (tty)
+               spcp8x5_set_termios(tty, port, &tmp_termios);
 
        spcp8x5_get_msr(serial->dev, &status, priv->type);
 
@@ -690,7 +690,7 @@ static int spcp8x5_open(struct usb_serial_port *port, struct file *filp)
        port->read_urb->dev = serial->dev;
        ret = usb_submit_urb(port->read_urb, GFP_KERNEL);
        if (ret) {
-               spcp8x5_close(port, NULL);
+               spcp8x5_close(tty, port, NULL);
                return -EPROTO;
        }
        return 0;
@@ -717,7 +717,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
 
        /* check the urb status */
        if (urb->status) {
-               if (!port->open_count)
+               if (!port->port.count)
                        return;
                if (urb->status == -EPROTO) {
                        /* spcp8x5 mysteriously fails with -EPROTO */
@@ -755,7 +755,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
                tty_flag = TTY_FRAME;
        dev_dbg(&port->dev, "tty_flag = %d\n", tty_flag);
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (tty && urb->actual_length) {
                tty_buffer_request_room(tty, urb->actual_length + 1);
                /* overrun is special, not associated with a char */
@@ -767,7 +767,7 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
        }
 
        /* Schedule the next read _if_ we are still open */
-       if (port->open_count) {
+       if (port->port.count) {
                urb->dev = port->serial->dev;
                result = usb_submit_urb(urb , GFP_ATOMIC);
                if (result)
@@ -866,7 +866,7 @@ static void spcp8x5_write_bulk_callback(struct urb *urb)
 }
 
 /* write data to ring buffer. and then start the write transfer */
-static int spcp8x5_write(struct usb_serial_port *port,
+static int spcp8x5_write(struct tty_struct *tty, struct usb_serial_port *port,
                         const unsigned char *buf, int count)
 {
        struct spcp8x5_private *priv = usb_get_serial_port_data(port);
@@ -925,9 +925,10 @@ static int spcp8x5_wait_modem_info(struct usb_serial_port *port,
        return 0;
 }
 
-static int spcp8x5_ioctl(struct usb_serial_port *port, struct file *file,
+static int spcp8x5_ioctl(struct tty_struct *tty, struct file *file,
                         unsigned int cmd, unsigned long arg)
 {
+       struct usb_serial_port *port = tty->driver_data;
        dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);
 
        switch (cmd) {
@@ -943,9 +944,10 @@ static int spcp8x5_ioctl(struct usb_serial_port *port, struct file *file,
        return -ENOIOCTLCMD;
 }
 
-static int spcp8x5_tiocmset(struct usb_serial_port *port, struct file *file,
+static int spcp8x5_tiocmset(struct tty_struct *tty, struct file *file,
                            unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct spcp8x5_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
        u8 control;
@@ -965,8 +967,9 @@ static int spcp8x5_tiocmset(struct usb_serial_port *port, struct file *file,
        return spcp8x5_set_ctrlLine(port->serial->dev, control , priv->type);
 }
 
-static int spcp8x5_tiocmget(struct usb_serial_port *port, struct file *file)
+static int spcp8x5_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct spcp8x5_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
        unsigned int mcr;
@@ -989,8 +992,9 @@ static int spcp8x5_tiocmget(struct usb_serial_port *port, struct file *file)
 }
 
 /* get the avail space room in ring buffer */
-static int spcp8x5_write_room(struct usb_serial_port *port)
+static int spcp8x5_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct spcp8x5_private *priv = usb_get_serial_port_data(port);
        int room = 0;
        unsigned long flags;
@@ -1003,8 +1007,9 @@ static int spcp8x5_write_room(struct usb_serial_port *port)
 }
 
 /* get the number of avail data in write ring buffer */
-static int spcp8x5_chars_in_buffer(struct usb_serial_port *port)
+static int spcp8x5_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct spcp8x5_private *priv = usb_get_serial_port_data(port);
        int chars = 0;
        unsigned long flags;
index a26a629..e39c779 100644 (file)
@@ -16,7 +16,7 @@
  * For questions or problems with this driver, contact Texas Instruments
  * technical support, or Al Borchers <alborchers@steinerpoint.com>, or
  * Peter Berger <pberger@brimson.com>.
- * 
+ *
  * This driver needs this hotplug script in /etc/hotplug/usb/ti_usb_3410_5052
  * or in /etc/hotplug.d/usb/ti_usb_3410_5052.hotplug to set the device
  * configuration.
@@ -70,6 +70,7 @@
 
 #include <linux/kernel.h>
 #include <linux/errno.h>
+#include <linux/firmware.h>
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/tty.h>
@@ -81,7 +82,7 @@
 #include <linux/serial.h>
 #include <linux/circ_buf.h>
 #include <linux/mutex.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include <linux/firmware.h>
@@ -149,21 +150,24 @@ struct ti_device {
 
 static int ti_startup(struct usb_serial *serial);
 static void ti_shutdown(struct usb_serial *serial);
-static int ti_open(struct usb_serial_port *port, struct file *file);
-static void ti_close(struct usb_serial_port *port, struct file *file);
-static int ti_write(struct usb_serial_port *port, const unsigned char *data,
-       int count);
-static int ti_write_room(struct usb_serial_port *port);
-static int ti_chars_in_buffer(struct usb_serial_port *port);
-static void ti_throttle(struct usb_serial_port *port);
-static void ti_unthrottle(struct usb_serial_port *port);
-static int ti_ioctl(struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg);
-static void ti_set_termios(struct usb_serial_port *port,
-       struct ktermios *old_termios);
-static int ti_tiocmget(struct usb_serial_port *port, struct file *file);
-static int ti_tiocmset(struct usb_serial_port *port, struct file *file,
-       unsigned int set, unsigned int clear);
-static void ti_break(struct usb_serial_port *port, int break_state);
+static int ti_open(struct tty_struct *tty, struct usb_serial_port *port,
+               struct file *file);
+static void ti_close(struct tty_struct *tty, struct usb_serial_port *port,
+               struct file *file);
+static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
+               const unsigned char *data, int count);
+static int ti_write_room(struct tty_struct *tty);
+static int ti_chars_in_buffer(struct tty_struct *tty);
+static void ti_throttle(struct tty_struct *tty);
+static void ti_unthrottle(struct tty_struct *tty);
+static int ti_ioctl(struct tty_struct *tty, struct file *file,
+               unsigned int cmd, unsigned long arg);
+static void ti_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios);
+static int ti_tiocmget(struct tty_struct *tty, struct file *file);
+static int ti_tiocmset(struct tty_struct *tty, struct file *file,
+               unsigned int set, unsigned int clear);
+static void ti_break(struct tty_struct *tty, int break_state);
 static void ti_interrupt_callback(struct urb *urb);
 static void ti_bulk_in_callback(struct urb *urb);
 static void ti_bulk_out_callback(struct urb *urb);
@@ -192,8 +196,7 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command,
 static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
        __u8 mask, __u8 byte);
 
-static int ti_download_firmware(struct ti_device *tdev, char *fw_name);
-
+static int ti_download_firmware(struct ti_device *tdev, int type);
 
 /* circular buffer */
 static struct circ_buf *ti_buf_alloc(void);
@@ -325,19 +328,25 @@ module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes");
 
 module_param(low_latency, bool, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(low_latency, "TTY low_latency flag, 0=off, 1=on, default is off");
+MODULE_PARM_DESC(low_latency,
+               "TTY low_latency flag, 0=off, 1=on, default is off");
 
 module_param(closing_wait, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain in close, in .01 secs, default is 4000");
+MODULE_PARM_DESC(closing_wait,
+    "Maximum wait for data to drain in close, in .01 secs, default is 4000");
 
 module_param_array(vendor_3410, ushort, &vendor_3410_count, S_IRUGO);
-MODULE_PARM_DESC(vendor_3410, "Vendor ids for 3410 based devices, 1-5 short integers");
+MODULE_PARM_DESC(vendor_3410,
+               "Vendor ids for 3410 based devices, 1-5 short integers");
 module_param_array(product_3410, ushort, &product_3410_count, S_IRUGO);
-MODULE_PARM_DESC(product_3410, "Product ids for 3410 based devices, 1-5 short integers");
+MODULE_PARM_DESC(product_3410,
+               "Product ids for 3410 based devices, 1-5 short integers");
 module_param_array(vendor_5052, ushort, &vendor_5052_count, S_IRUGO);
-MODULE_PARM_DESC(vendor_5052, "Vendor ids for 5052 based devices, 1-5 short integers");
+MODULE_PARM_DESC(vendor_5052,
+               "Vendor ids for 5052 based devices, 1-5 short integers");
 module_param_array(product_5052, ushort, &product_5052_count, S_IRUGO);
-MODULE_PARM_DESC(product_5052, "Product ids for 5052 based devices, 1-5 short integers");
+MODULE_PARM_DESC(product_5052,
+               "Product ids for 5052 based devices, 1-5 short integers");
 
 MODULE_DEVICE_TABLE(usb, ti_id_table_combined);
 
@@ -346,18 +355,18 @@ MODULE_DEVICE_TABLE(usb, ti_id_table_combined);
 
 static int __init ti_init(void)
 {
-       int i,j;
+       int i, j;
        int ret;
 
        /* insert extra vendor and product ids */
        j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1;
-       for (i=0; i<min(vendor_3410_count,product_3410_count); i++,j++) {
+       for (i = 0; i < min(vendor_3410_count, product_3410_count); i++, j++) {
                ti_id_table_3410[j].idVendor = vendor_3410[i];
                ti_id_table_3410[j].idProduct = product_3410[i];
                ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
        }
        j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1;
-       for (i=0; i<min(vendor_5052_count,product_5052_count); i++,j++) {
+       for (i = 0; i < min(vendor_5052_count, product_5052_count); i++, j++) {
                ti_id_table_5052[j].idVendor = vendor_5052[i];
                ti_id_table_5052[j].idProduct = product_5052[i];
                ti_id_table_5052[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
@@ -426,15 +435,15 @@ static int ti_startup(struct usb_serial *serial)
        /* determine device type */
        if (usb_match_id(serial->interface, ti_id_table_3410))
                tdev->td_is_3410 = 1;
-       dbg("%s - device type is %s", __func__, tdev->td_is_3410 ? "3410" : "5052");
+       dbg("%s - device type is %s", __func__,
+                               tdev->td_is_3410 ? "3410" : "5052");
 
        /* if we have only 1 configuration, download firmware */
        if (dev->descriptor.bNumConfigurations == 1) {
-
                if (tdev->td_is_3410)
-                       status = ti_download_firmware(tdev, "ti_3410.fw");
+                       status = ti_download_firmware(tdev, 3410);
                else
-                       status = ti_download_firmware(tdev, "ti_5052.fw");
+                       status = ti_download_firmware(tdev, 5052);
                if (status)
                        goto free_tdev;
 
@@ -446,7 +455,7 @@ static int ti_startup(struct usb_serial *serial)
 
                status = -ENODEV;
                goto free_tdev;
-       } 
+       }
 
        /* the second configuration must be set (in sysfs by hotplug script) */
        if (dev->actconfig->desc.bConfigurationValue == TI_BOOT_CONFIG) {
@@ -463,7 +472,8 @@ static int ti_startup(struct usb_serial *serial)
                        goto free_tports;
                }
                spin_lock_init(&tport->tp_lock);
-               tport->tp_uart_base_addr = (i == 0 ? TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR);
+               tport->tp_uart_base_addr = (i == 0 ?
+                               TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR);
                tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0;
                tport->tp_closing_wait = closing_wait;
                init_waitqueue_head(&tport->tp_msr_wait);
@@ -480,11 +490,11 @@ static int ti_startup(struct usb_serial *serial)
                usb_set_serial_port_data(serial->port[i], tport);
                tport->tp_uart_mode = 0;        /* default is RS232 */
        }
-       
+
        return 0;
 
 free_tports:
-       for (--i; i>=0; --i) {
+       for (--i; i >= 0; --i) {
                tport = usb_get_serial_port_data(serial->port[i]);
                ti_buf_free(tport->tp_write_buf);
                kfree(tport);
@@ -505,7 +515,7 @@ static void ti_shutdown(struct usb_serial *serial)
 
        dbg("%s", __func__);
 
-       for (i=0; i < serial->num_ports; ++i) {
+       for (i = 0; i < serial->num_ports; ++i) {
                tport = usb_get_serial_port_data(serial->port[i]);
                if (tport) {
                        ti_buf_free(tport->tp_write_buf);
@@ -519,7 +529,8 @@ static void ti_shutdown(struct usb_serial *serial)
 }
 
 
-static int ti_open(struct usb_serial_port *port, struct file *file)
+static int ti_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *file)
 {
        struct ti_port *tport = usb_get_serial_port_data(port);
        struct ti_device *tdev;
@@ -527,8 +538,8 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
        struct urb *urb;
        int port_number;
        int status;
-       __u16 open_settings = (__u8)(TI_PIPE_MODE_CONTINOUS | 
-                            TI_PIPE_TIMEOUT_ENABLE | 
+       __u16 open_settings = (__u8)(TI_PIPE_MODE_CONTINOUS |
+                            TI_PIPE_TIMEOUT_ENABLE |
                             (TI_TRANSFER_TIMEOUT << 2));
 
        dbg("%s - port %d", __func__, port->number);
@@ -543,9 +554,9 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
        if (mutex_lock_interruptible(&tdev->td_open_close_lock))
                return -ERESTARTSYS;
 
-       if (port->tty)
-               port->tty->low_latency = 
-                       (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+       if (tty)
+               tty->low_latency =
+                               (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0;
 
        port_number = port->number - port->serial->minor;
 
@@ -559,7 +570,8 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
                dbg("%s - start interrupt in urb", __func__);
                urb = tdev->td_serial->port[0]->interrupt_in_urb;
                if (!urb) {
-                       dev_err(&port->dev, "%s - no interrupt urb\n", __func__);
+                       dev_err(&port->dev, "%s - no interrupt urb\n",
+                                                               __func__);
                        status = -EINVAL;
                        goto release_lock;
                }
@@ -568,18 +580,22 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
                urb->dev = dev;
                status = usb_submit_urb(urb, GFP_KERNEL);
                if (status) {
-                       dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __func__, status);
+                       dev_err(&port->dev,
+                               "%s - submit interrupt urb failed, %d\n",
+                                       __func__, status);
                        goto release_lock;
                }
        }
 
-       ti_set_termios(port, port->tty->termios);
+       if (tty)
+               ti_set_termios(tty, port, tty->termios);
 
        dbg("%s - sending TI_OPEN_PORT", __func__);
        status = ti_command_out_sync(tdev, TI_OPEN_PORT,
                (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0);
        if (status) {
-               dev_err(&port->dev, "%s - cannot send open command, %d\n", __func__, status);
+               dev_err(&port->dev, "%s - cannot send open command, %d\n",
+                                                       __func__, status);
                goto unlink_int_urb;
        }
 
@@ -587,7 +603,8 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
        status = ti_command_out_sync(tdev, TI_START_PORT,
                (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0);
        if (status) {
-               dev_err(&port->dev, "%s - cannot send start command, %d\n", __func__, status);
+               dev_err(&port->dev, "%s - cannot send start command, %d\n",
+                                                       __func__, status);
                goto unlink_int_urb;
        }
 
@@ -595,13 +612,15 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
        status = ti_command_out_sync(tdev, TI_PURGE_PORT,
                (__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0);
        if (status) {
-               dev_err(&port->dev, "%s - cannot clear input buffers, %d\n", __func__, status);
+               dev_err(&port->dev, "%s - cannot clear input buffers, %d\n",
+                                                       __func__, status);
                goto unlink_int_urb;
        }
        status = ti_command_out_sync(tdev, TI_PURGE_PORT,
                (__u8)(TI_UART1_PORT + port_number), TI_PURGE_OUTPUT, NULL, 0);
        if (status) {
-               dev_err(&port->dev, "%s - cannot clear output buffers, %d\n", __func__, status);
+               dev_err(&port->dev, "%s - cannot clear output buffers, %d\n",
+                                                       __func__, status);
                goto unlink_int_urb;
        }
 
@@ -610,13 +629,15 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
        usb_clear_halt(dev, port->write_urb->pipe);
        usb_clear_halt(dev, port->read_urb->pipe);
 
-       ti_set_termios(port, port->tty->termios);
+       if (tty)
+               ti_set_termios(tty, port, tty->termios);
 
        dbg("%s - sending TI_OPEN_PORT (2)", __func__);
        status = ti_command_out_sync(tdev, TI_OPEN_PORT,
                (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0);
        if (status) {
-               dev_err(&port->dev, "%s - cannot send open command (2), %d\n", __func__, status);
+               dev_err(&port->dev, "%s - cannot send open command (2), %d\n",
+                                                       __func__, status);
                goto unlink_int_urb;
        }
 
@@ -624,7 +645,8 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
        status = ti_command_out_sync(tdev, TI_START_PORT,
                (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0);
        if (status) {
-               dev_err(&port->dev, "%s - cannot send start command (2), %d\n", __func__, status);
+               dev_err(&port->dev, "%s - cannot send start command (2), %d\n",
+                                                       __func__, status);
                goto unlink_int_urb;
        }
 
@@ -642,7 +664,8 @@ static int ti_open(struct usb_serial_port *port, struct file *file)
        urb->dev = dev;
        status = usb_submit_urb(urb, GFP_KERNEL);
        if (status) {
-               dev_err(&port->dev, "%s - submit read urb failed, %d\n", __func__, status);
+               dev_err(&port->dev, "%s - submit read urb failed, %d\n",
+                                                       __func__, status);
                goto unlink_int_urb;
        }
 
@@ -661,7 +684,8 @@ release_lock:
 }
 
 
-static void ti_close(struct usb_serial_port *port, struct file *file)
+static void ti_close(struct tty_struct *tty, struct usb_serial_port *port,
+                                                       struct file *file)
 {
        struct ti_device *tdev;
        struct ti_port *tport;
@@ -670,7 +694,7 @@ static void ti_close(struct usb_serial_port *port, struct file *file)
        int do_unlock;
 
        dbg("%s - port %d", __func__, port->number);
-                        
+
        tdev = usb_get_serial_data(port->serial);
        tport = usb_get_serial_port_data(port);
        if (tdev == NULL || tport == NULL)
@@ -690,7 +714,9 @@ static void ti_close(struct usb_serial_port *port, struct file *file)
        status = ti_command_out_sync(tdev, TI_CLOSE_PORT,
                     (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0);
        if (status)
-               dev_err(&port->dev, "%s - cannot send close port command, %d\n" , __func__, status);
+               dev_err(&port->dev,
+                       "%s - cannot send close port command, %d\n"
+                                                       , __func__, status);
 
        /* if mutex_lock is interrupted, continue anyway */
        do_unlock = !mutex_lock_interruptible(&tdev->td_open_close_lock);
@@ -707,8 +733,8 @@ static void ti_close(struct usb_serial_port *port, struct file *file)
 }
 
 
-static int ti_write(struct usb_serial_port *port, const unsigned char *data,
-       int count)
+static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
+                       const unsigned char *data, int count)
 {
        struct ti_port *tport = usb_get_serial_port_data(port);
        unsigned long flags;
@@ -733,8 +759,9 @@ static int ti_write(struct usb_serial_port *port, const unsigned char *data,
 }
 
 
-static int ti_write_room(struct usb_serial_port *port)
+static int ti_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ti_port *tport = usb_get_serial_port_data(port);
        int room = 0;
        unsigned long flags;
@@ -743,7 +770,7 @@ static int ti_write_room(struct usb_serial_port *port)
 
        if (tport == NULL)
                return -ENODEV;
-       
+
        spin_lock_irqsave(&tport->tp_lock, flags);
        room = ti_buf_space_avail(tport->tp_write_buf);
        spin_unlock_irqrestore(&tport->tp_lock, flags);
@@ -753,8 +780,9 @@ static int ti_write_room(struct usb_serial_port *port)
 }
 
 
-static int ti_chars_in_buffer(struct usb_serial_port *port)
+static int ti_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ti_port *tport = usb_get_serial_port_data(port);
        int chars = 0;
        unsigned long flags;
@@ -773,32 +801,26 @@ static int ti_chars_in_buffer(struct usb_serial_port *port)
 }
 
 
-static void ti_throttle(struct usb_serial_port *port)
+static void ti_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ti_port *tport = usb_get_serial_port_data(port);
-       struct tty_struct *tty;
 
        dbg("%s - port %d", __func__, port->number);
 
        if (tport == NULL)
                return;
 
-       tty = port->tty;
-       if (!tty) {
-               dbg("%s - no tty", __func__);
-               return;
-       }
-
        if (I_IXOFF(tty) || C_CRTSCTS(tty))
                ti_stop_read(tport, tty);
 
 }
 
 
-static void ti_unthrottle(struct usb_serial_port *port)
+static void ti_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ti_port *tport = usb_get_serial_port_data(port);
-       struct tty_struct *tty;
        int status;
 
        dbg("%s - port %d", __func__, port->number);
@@ -806,23 +828,19 @@ static void ti_unthrottle(struct usb_serial_port *port)
        if (tport == NULL)
                return;
 
-       tty = port->tty;
-       if (!tty) {
-               dbg("%s - no tty", __func__);
-               return;
-       }
-
        if (I_IXOFF(tty) || C_CRTSCTS(tty)) {
                status = ti_restart_read(tport, tty);
                if (status)
-                       dev_err(&port->dev, "%s - cannot restart read, %d\n", __func__, status);
+                       dev_err(&port->dev, "%s - cannot restart read, %d\n",
+                                                       __func__, status);
        }
 }
 
 
-static int ti_ioctl(struct usb_serial_port *port, struct file *file,
+static int ti_ioctl(struct tty_struct *tty, struct file *file,
        unsigned int cmd, unsigned long arg)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ti_port *tport = usb_get_serial_port_data(port);
        struct async_icount cnow;
        struct async_icount cprev;
@@ -833,55 +851,52 @@ static int ti_ioctl(struct usb_serial_port *port, struct file *file,
                return -ENODEV;
 
        switch (cmd) {
-               case TIOCGSERIAL:
-                       dbg("%s - (%d) TIOCGSERIAL", __func__, port->number);
-                       return ti_get_serial_info(tport, (struct serial_struct __user *)arg);
-                       break;
-
-               case TIOCSSERIAL:
-                       dbg("%s - (%d) TIOCSSERIAL", __func__, port->number);
-                       return ti_set_serial_info(tport, (struct serial_struct __user *)arg);
-                       break;
-
-               case TIOCMIWAIT:
-                       dbg("%s - (%d) TIOCMIWAIT", __func__, port->number);
-                       cprev = tport->tp_icount;
-                       while (1) {
-                               interruptible_sleep_on(&tport->tp_msr_wait);
-                               if (signal_pending(current))
-                                       return -ERESTARTSYS;
-                               cnow = tport->tp_icount;
-                               if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
-                                   cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
-                                       return -EIO; /* no change => error */
-                               if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
-                                   ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
-                                   ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
-                                   ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
-                                       return 0;
-                               }
-                               cprev = cnow;
-                       }
-                       break;
-
-               case TIOCGICOUNT:
-                       dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, port->number, tport->tp_icount.rx, tport->tp_icount.tx);
-                       if (copy_to_user((void __user *)arg, &tport->tp_icount, sizeof(tport->tp_icount)))
-                               return -EFAULT;
-                       return 0;
+       case TIOCGSERIAL:
+               dbg("%s - (%d) TIOCGSERIAL", __func__, port->number);
+               return ti_get_serial_info(tport,
+                               (struct serial_struct __user *)arg);
+       case TIOCSSERIAL:
+               dbg("%s - (%d) TIOCSSERIAL", __func__, port->number);
+               return ti_set_serial_info(tport,
+                                       (struct serial_struct __user *)arg);
+       case TIOCMIWAIT:
+               dbg("%s - (%d) TIOCMIWAIT", __func__, port->number);
+               cprev = tport->tp_icount;
+               while (1) {
+                       interruptible_sleep_on(&tport->tp_msr_wait);
+                       if (signal_pending(current))
+                               return -ERESTARTSYS;
+                       cnow = tport->tp_icount;
+                       if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
+                           cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
+                               return -EIO; /* no change => error */
+                       if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
+                           ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
+                           ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
+                           ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)))
+                               return 0;
+                       cprev = cnow;
+               }
+               break;
+       case TIOCGICOUNT:
+               dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d",
+                               __func__, port->number,
+                               tport->tp_icount.rx, tport->tp_icount.tx);
+               if (copy_to_user((void __user *)arg, &tport->tp_icount,
+                                       sizeof(tport->tp_icount)))
+                       return -EFAULT;
+               return 0;
        }
-
        return -ENOIOCTLCMD;
 }
 
 
-static void ti_set_termios(struct usb_serial_port *port,
-       struct ktermios *old_termios)
+static void ti_set_termios(struct tty_struct *tty,
+               struct usb_serial_port *port, struct ktermios *old_termios)
 {
        struct ti_port *tport = usb_get_serial_port_data(port);
-       struct tty_struct *tty = port->tty;
        struct ti_uart_config *config;
-       tcflag_t cflag,iflag;
+       tcflag_t cflag, iflag;
        int baud;
        int status;
        int port_number = port->number - port->serial->minor;
@@ -893,7 +908,8 @@ static void ti_set_termios(struct usb_serial_port *port,
        iflag = tty->termios->c_iflag;
 
        dbg("%s - cflag %08x, iflag %08x", __func__, cflag, iflag);
-       dbg("%s - old clfag %08x, old iflag %08x", __func__, old_termios->c_cflag, old_termios->c_iflag);
+       dbg("%s - old clfag %08x, old iflag %08x", __func__,
+                               old_termios->c_cflag, old_termios->c_iflag);
 
        if (tport == NULL)
                return;
@@ -912,19 +928,19 @@ static void ti_set_termios(struct usb_serial_port *port,
        config->bUartMode = (__u8)(tport->tp_uart_mode);
 
        switch (cflag & CSIZE) {
-               case CS5:
-                           config->bDataBits = TI_UART_5_DATA_BITS;
-                           break;
-               case CS6:
-                           config->bDataBits = TI_UART_6_DATA_BITS;
-                           break;
-               case CS7:
-                           config->bDataBits = TI_UART_7_DATA_BITS;
-                           break;
-               default:
-               case CS8:
-                           config->bDataBits = TI_UART_8_DATA_BITS;
-                           break;
+       case CS5:
+                   config->bDataBits = TI_UART_5_DATA_BITS;
+                   break;
+       case CS6:
+                   config->bDataBits = TI_UART_6_DATA_BITS;
+                   break;
+       case CS7:
+                   config->bDataBits = TI_UART_7_DATA_BITS;
+                   break;
+       default:
+       case CS8:
+                   config->bDataBits = TI_UART_8_DATA_BITS;
+                   break;
        }
 
        /* CMSPAR isn't supported by this driver */
@@ -940,7 +956,7 @@ static void ti_set_termios(struct usb_serial_port *port,
                }
        } else {
                config->wFlags &= ~TI_UART_ENABLE_PARITY_CHECKING;
-               config->bParity = TI_UART_NO_PARITY;    
+               config->bParity = TI_UART_NO_PARITY;
        }
 
        if (cflag & CSTOPB)
@@ -993,7 +1009,8 @@ static void ti_set_termios(struct usb_serial_port *port,
                (__u8)(TI_UART1_PORT + port_number), 0, (__u8 *)config,
                sizeof(*config));
        if (status)
-               dev_err(&port->dev, "%s - cannot set config on port %d, %d\n", __func__, port_number, status);
+               dev_err(&port->dev, "%s - cannot set config on port %d, %d\n",
+                                       __func__, port_number, status);
 
        /* SET_CONFIG asserts RTS and DTR, reset them correctly */
        mcr = tport->tp_shadow_mcr;
@@ -1002,14 +1019,17 @@ static void ti_set_termios(struct usb_serial_port *port,
                mcr &= ~(TI_MCR_DTR | TI_MCR_RTS);
        status = ti_set_mcr(tport, mcr);
        if (status)
-               dev_err(&port->dev, "%s - cannot set modem control on port %d, %d\n", __func__, port_number, status);
+               dev_err(&port->dev,
+                       "%s - cannot set modem control on port %d, %d\n",
+                                               __func__, port_number, status);
 
        kfree(config);
 }
 
 
-static int ti_tiocmget(struct usb_serial_port *port, struct file *file)
+static int ti_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ti_port *tport = usb_get_serial_port_data(port);
        unsigned int result;
        unsigned int msr;
@@ -1040,9 +1060,10 @@ static int ti_tiocmget(struct usb_serial_port *port, struct file *file)
 }
 
 
-static int ti_tiocmset(struct usb_serial_port *port, struct file *file,
+static int ti_tiocmset(struct tty_struct *tty, struct file *file,
        unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ti_port *tport = usb_get_serial_port_data(port);
        unsigned int mcr;
        unsigned long flags;
@@ -1074,8 +1095,9 @@ static int ti_tiocmset(struct usb_serial_port *port, struct file *file,
 }
 
 
-static void ti_break(struct usb_serial_port *port, int break_state)
+static void ti_break(struct tty_struct *tty, int break_state)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct ti_port *tport = usb_get_serial_port_data(port);
        int status;
 
@@ -1141,10 +1163,12 @@ static void ti_interrupt_callback(struct urb *urb)
        port_number = TI_GET_PORT_FROM_CODE(data[0]);
        function = TI_GET_FUNC_FROM_CODE(data[0]);
 
-       dbg("%s - port_number %d, function %d, data 0x%02X", __func__, port_number, function, data[1]);
+       dbg("%s - port_number %d, function %d, data 0x%02X",
+                               __func__, port_number, function, data[1]);
 
        if (port_number >= serial->num_ports) {
-               dev_err(dev, "%s - bad port number, %d\n", __func__, port_number);
+               dev_err(dev, "%s - bad port number, %d\n",
+                                               __func__, port_number);
                goto exit;
        }
 
@@ -1156,7 +1180,8 @@ static void ti_interrupt_callback(struct urb *urb)
 
        switch (function) {
        case TI_CODE_DATA_ERROR:
-               dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", __func__, port_number, data[1]);
+               dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n",
+                                       __func__, port_number, data[1]);
                break;
 
        case TI_CODE_MODEM_STATUS:
@@ -1166,7 +1191,8 @@ static void ti_interrupt_callback(struct urb *urb)
                break;
 
        default:
-               dev_err(dev, "%s - unknown interrupt code, 0x%02X\n", __func__, data[1]);
+               dev_err(dev, "%s - unknown interrupt code, 0x%02X\n",
+                                                       __func__, data[1]);
                break;
        }
 
@@ -1200,7 +1226,7 @@ static void ti_bulk_in_callback(struct urb *urb)
                return;
        default:
                dev_err(dev, "%s - nonzero urb status, %d\n",
-                       __func__, status );
+                       __func__, status);
                tport->tp_tdev->td_urb_error = 1;
                wake_up_interruptible(&tport->tp_write_wait);
        }
@@ -1213,15 +1239,16 @@ static void ti_bulk_in_callback(struct urb *urb)
                return;
        }
 
-       if (port->tty && urb->actual_length) {
+       if (port->port.tty && urb->actual_length) {
                usb_serial_debug_data(debug, dev, __func__,
                        urb->actual_length, urb->transfer_buffer);
 
                if (!tport->tp_is_open)
                        dbg("%s - port closed, dropping data", __func__);
                else
-                       ti_recv(&urb->dev->dev, port->tty, urb->transfer_buffer,
-                               urb->actual_length);
+                       ti_recv(&urb->dev->dev, port->port.tty,
+                                               urb->transfer_buffer,
+                                               urb->actual_length);
 
                spin_lock(&tport->tp_lock);
                tport->tp_icount.rx += urb->actual_length;
@@ -1285,8 +1312,9 @@ static void ti_recv(struct device *dev, struct tty_struct *tty,
        do {
                cnt = tty_buffer_request_room(tty, length);
                if (cnt < length) {
-                       dev_err(dev, "%s - dropping data, %d bytes lost\n", __func__, length - cnt);
-                       if(cnt == 0)
+                       dev_err(dev, "%s - dropping data, %d bytes lost\n",
+                                               __func__, length - cnt);
+                       if (cnt == 0)
                                break;
                }
                tty_insert_flip_string(tty, data, cnt);
@@ -1302,7 +1330,7 @@ static void ti_send(struct ti_port *tport)
 {
        int count, result;
        struct usb_serial_port *port = tport->tp_port;
-       struct tty_struct *tty = port->tty;
+       struct tty_struct *tty = port->port.tty;        /* FIXME */
        unsigned long flags;
 
 
@@ -1328,7 +1356,8 @@ static void ti_send(struct ti_port *tport)
 
        spin_unlock_irqrestore(&tport->tp_lock, flags);
 
-       usb_serial_debug_data(debug, &port->dev, __func__, count, port->write_urb->transfer_buffer);
+       usb_serial_debug_data(debug, &port->dev, __func__, count,
+                                       port->write_urb->transfer_buffer);
 
        usb_fill_bulk_urb(port->write_urb, port->serial->dev,
                           usb_sndbulkpipe(port->serial->dev,
@@ -1338,8 +1367,9 @@ static void ti_send(struct ti_port *tport)
 
        result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
        if (result) {
-               dev_err(&port->dev, "%s - submit write urb failed, %d\n", __func__, result);
-               tport->tp_write_urb_in_use = 0; 
+               dev_err(&port->dev, "%s - submit write urb failed, %d\n",
+                                                       __func__, result);
+               tport->tp_write_urb_in_use = 0;
                /* TODO: reschedule ti_send */
        } else {
                spin_lock_irqsave(&tport->tp_lock, flags);
@@ -1374,7 +1404,7 @@ static int ti_set_mcr(struct ti_port *tport, unsigned int mcr)
 
 static int ti_get_lsr(struct ti_port *tport)
 {
-       int size,status;
+       int size, status;
        struct ti_device *tdev = tport->tp_tdev;
        struct usb_serial_port *port = tport->tp_port;
        int port_number = port->number - port->serial->minor;
@@ -1392,7 +1422,9 @@ static int ti_get_lsr(struct ti_port *tport)
        status = ti_command_in_sync(tdev, TI_GET_PORT_STATUS,
                (__u8)(TI_UART1_PORT+port_number), 0, (__u8 *)data, size);
        if (status) {
-               dev_err(&port->dev, "%s - get port status command failed, %d\n", __func__, status);
+               dev_err(&port->dev,
+                       "%s - get port status command failed, %d\n",
+                                                       __func__, status);
                goto free_data;
        }
 
@@ -1442,8 +1474,9 @@ static int ti_set_serial_info(struct ti_port *tport,
                return -EFAULT;
 
        tport->tp_flags = new_serial.flags & TI_SET_SERIAL_FLAGS;
-       if (port->tty)
-               port->tty->low_latency =
+       /* FIXME */
+       if (port->port.tty)
+               port->port.tty->low_latency =
                        (tport->tp_flags & ASYNC_LOW_LATENCY) ? 1 : 0;
        tport->tp_closing_wait = new_serial.closing_wait;
 
@@ -1477,7 +1510,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr)
        tport->tp_msr = msr & TI_MSR_MASK;
 
        /* handle CTS flow control */
-       tty = tport->tp_port->tty;
+       tty = tport->tp_port->port.tty;
        if (tty && C_CRTSCTS(tty)) {
                if (msr & TI_MSR_CTS) {
                        tty->hw_stopped = 0;
@@ -1627,7 +1660,8 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
        struct ti_write_data_bytes *data;
        struct device *dev = &tdev->td_serial->dev->dev;
 
-       dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X", __func__, addr, mask, byte);
+       dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X",
+                                       __func__, addr, mask, byte);
 
        size = sizeof(struct ti_write_data_bytes) + 2;
        data = kmalloc(size, GFP_KERNEL);
@@ -1655,67 +1689,68 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
        return status;
 }
 
-
-static int ti_download_firmware(struct ti_device *tdev,
-                               char *fw_name)
+static int ti_do_download(struct usb_device *dev, int pipe,
+                                               u8 *buffer, int size)
 {
-       const struct firmware *fw;
-       int status = 0;
-       int buffer_size;
        int pos;
-       int len;
+       u8 cs = 0;
        int done;
-       __u8 cs = 0;
-       __u8 *buffer;
-       struct usb_device *dev = tdev->td_serial->dev;
        struct ti_firmware_header *header;
-       unsigned int pipe = usb_sndbulkpipe(dev,
-               tdev->td_serial->port[0]->bulk_out_endpointAddress);
-
-       buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header);
-
-       if (request_firmware(&fw, fw_name, &dev->dev)) {
-               dev_err(&dev->dev, "%s - failed to load firmware \"%s\"\n",
-                       __func__, fw_name);
-               return -ENOENT;
-       }
-       if (fw->size > buffer_size) {
-               dev_err(&dev->dev, "%s - firmware \"%s\" is too large\n",
-                       __func__, fw_name);
-               release_firmware(fw);
-               return -EINVAL;
-       }
-
-       buffer = kmalloc(buffer_size, GFP_KERNEL);
-       if (!buffer) {
-               dev_err(&dev->dev, "%s - out of memory\n", __func__);
-               release_firmware(fw);
-               return -ENOMEM;
-       }
-
-       memcpy(buffer, fw->data, fw->size);
-       memset(buffer+fw->size, 0xff, buffer_size-fw->size);
+       int status;
+       int len;
 
-       for(pos = sizeof(struct ti_firmware_header); pos < buffer_size; pos++)
+       for (pos = sizeof(struct ti_firmware_header); pos < size; pos++)
                cs = (__u8)(cs + buffer[pos]);
 
        header = (struct ti_firmware_header *)buffer;
-       header->wLength = cpu_to_le16((__u16)(buffer_size - sizeof(struct ti_firmware_header)));
+       header->wLength = cpu_to_le16((__u16)(size
+                                       - sizeof(struct ti_firmware_header)));
        header->bCheckSum = cs;
 
        dbg("%s - downloading firmware", __func__);
-       for (pos = 0; pos < buffer_size; pos += done) {
-               len = min(buffer_size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE);
-               status = usb_bulk_msg(dev, pipe, buffer+pos, len, &done, 1000);
+       for (pos = 0; pos < size; pos += done) {
+               len = min(size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE);
+               status = usb_bulk_msg(dev, pipe, buffer + pos, len,
+                                                               &done, 1000);
                if (status)
                        break;
        }
+       return status;
+}
 
-       kfree(buffer);
-       release_firmware(fw);
+static int ti_download_firmware(struct ti_device *tdev, int type)
+{
+       int status = -ENOMEM;
+       int buffer_size;
+       __u8 *buffer;
+       struct usb_device *dev = tdev->td_serial->dev;
+       unsigned int pipe = usb_sndbulkpipe(dev,
+               tdev->td_serial->port[0]->bulk_out_endpointAddress);
+       const struct firmware *fw_p;
+       char buf[32];
+       sprintf(buf, "ti_usb-%d.bin", type);
 
+       if (request_firmware(&fw_p, buf, &dev->dev)) {
+               dev_err(&dev->dev, "%s - firmware not found\n", __func__);
+               return -ENOENT;
+       }
+       if (fw_p->size > TI_FIRMWARE_BUF_SIZE) {
+               dev_err(&dev->dev, "%s - firmware too large\n", __func__);
+               return -ENOENT;
+       }
+
+       buffer_size = TI_FIRMWARE_BUF_SIZE + sizeof(struct ti_firmware_header);
+       buffer = kmalloc(buffer_size, GFP_KERNEL);
+       if (buffer) {
+               memcpy(buffer, fw_p->data, fw_p->size);
+               memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size);
+               ti_do_download(dev, pipe, buffer, fw_p->size);
+               kfree(buffer);
+       }
+       release_firmware(fw_p);
        if (status) {
-               dev_err(&dev->dev, "%s - error downloading firmware, %d\n", __func__, status);
+               dev_err(&dev->dev, "%s - error downloading firmware, %d\n",
+                                                       __func__, status);
                return status;
        }
 
@@ -1787,7 +1822,7 @@ static void ti_buf_clear(struct circ_buf *cb)
 
 static int ti_buf_data_avail(struct circ_buf *cb)
 {
-       return CIRC_CNT(cb->head,cb->tail,TI_WRITE_BUF_SIZE);
+       return CIRC_CNT(cb->head, cb->tail, TI_WRITE_BUF_SIZE);
 }
 
 
@@ -1800,7 +1835,7 @@ static int ti_buf_data_avail(struct circ_buf *cb)
 
 static int ti_buf_space_avail(struct circ_buf *cb)
 {
-       return CIRC_SPACE(cb->head,cb->tail,TI_WRITE_BUF_SIZE);
+       return CIRC_SPACE(cb->head, cb->tail, TI_WRITE_BUF_SIZE);
 }
 
 
index 3537986..8c2d531 100644 (file)
@@ -12,7 +12,8 @@
  * This driver was originally based on the ACM driver by Armin Fuerst (which was
  * based on a driver by Brad Keryan)
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  *
  */
 
@@ -28,7 +29,7 @@
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
 #include <linux/list.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include "pl2303.h"
@@ -59,7 +60,8 @@ static struct usb_driver usb_serial_driver = {
 */
 
 static int debug;
-static struct usb_serial *serial_table[SERIAL_TTY_MINORS];     /* initially all NULL */
+/* initially all NULL */
+static struct usb_serial *serial_table[SERIAL_TTY_MINORS];
 static DEFINE_MUTEX(table_lock);
 static LIST_HEAD(usb_serial_driver_list);
 
@@ -76,7 +78,8 @@ struct usb_serial *usb_serial_get_by_index(unsigned index)
        return serial;
 }
 
-static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_ports, unsigned int *minor)
+static struct usb_serial *get_free_serial(struct usb_serial *serial,
+                                       int num_ports, unsigned int *minor)
 {
        unsigned int i, j;
        int good_spot;
@@ -122,9 +125,8 @@ static void return_serial(struct usb_serial *serial)
        if (serial == NULL)
                return;
 
-       for (i = 0; i < serial->num_ports; ++i) {
+       for (i = 0; i < serial->num_ports; ++i)
                serial_table[serial->minor + i] = NULL;
-       }
 }
 
 static void destroy_serial(struct kref *kref)
@@ -143,7 +145,7 @@ static void destroy_serial(struct kref *kref)
        return_serial(serial);
 
        for (i = 0; i < serial->num_ports; ++i)
-               serial->port[i]->open_count = 0;
+               serial->port[i]->port.count = 0;
 
        /* the ports are cleaned up and released in port_release() */
        for (i = 0; i < serial->num_ports; ++i)
@@ -156,7 +158,8 @@ static void destroy_serial(struct kref *kref)
         * not get cleaned up in port_release() as it was never registered with
         * the driver core */
        if (serial->num_ports < serial->num_port_pointers) {
-               for (i = serial->num_ports; i < serial->num_port_pointers; ++i) {
+               for (i = serial->num_ports;
+                                       i < serial->num_port_pointers; ++i) {
                        port = serial->port[i];
                        if (!port)
                                continue;
@@ -167,7 +170,7 @@ static void destroy_serial(struct kref *kref)
        usb_put_dev(serial->dev);
 
        /* free up any memory that we allocated */
-       kfree (serial);
+       kfree(serial);
 }
 
 void usb_serial_put(struct usb_serial *serial)
@@ -180,13 +183,13 @@ void usb_serial_put(struct usb_serial *serial)
 /*****************************************************************************
  * Driver tty interface functions
  *****************************************************************************/
-static int serial_open (struct tty_struct *tty, struct file * filp)
+static int serial_open (struct tty_struct *tty, struct file *filp)
 {
        struct usb_serial *serial;
        struct usb_serial_port *port;
        unsigned int portNumber;
        int retval;
-       
+
        dbg("%s", __func__);
 
        /* get the serial object associated with this tty pointer */
@@ -207,15 +210,15 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
                retval = -ERESTARTSYS;
                goto bailout_kref_put;
        }
-        
-       ++port->open_count;
+
+       ++port->port.count;
 
        /* set up our port structure making the tty driver
         * remember our port object, and us it */
        tty->driver_data = port;
-       port->tty = tty;
+       port->port.tty = tty;
 
-       if (port->open_count == 1) {
+       if (port->port.count == 1) {
 
                /* lock this module before we call it
                 * this may fail, which means we must bail out,
@@ -228,9 +231,9 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
                retval = usb_autopm_get_interface(serial->interface);
                if (retval)
                        goto bailout_module_put;
-               /* only call the device specific open if this 
+               /* only call the device specific open if this
                 * is the first time the port is opened */
-               retval = serial->type->open(port, filp);
+               retval = serial->type->open(tty, port, filp);
                if (retval)
                        goto bailout_interface_put;
        }
@@ -243,16 +246,16 @@ bailout_interface_put:
 bailout_module_put:
        module_put(serial->type->driver.owner);
 bailout_mutex_unlock:
-       port->open_count = 0;
+       port->port.count = 0;
        tty->driver_data = NULL;
-       port->tty = NULL;
+       port->port.tty = NULL;
        mutex_unlock(&port->mutex);
 bailout_kref_put:
        usb_serial_put(serial);
        return retval;
 }
 
-static void serial_close(struct tty_struct *tty, struct file * filp)
+static void serial_close(struct tty_struct *tty, struct file *filp)
 {
        struct usb_serial_port *port = tty->driver_data;
 
@@ -263,26 +266,26 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
 
        mutex_lock(&port->mutex);
 
-       if (port->open_count == 0) {
+       if (port->port.count == 0) {
                mutex_unlock(&port->mutex);
                return;
        }
 
-       --port->open_count;
-       if (port->open_count == 0)
-               /* only call the device specific close if this 
+       --port->port.count;
+       if (port->port.count == 0)
+               /* only call the device specific close if this
                 * port is being closed by the last owner */
-               port->serial->type->close(port, filp);
+               port->serial->type->close(tty, port, filp);
 
-       if (port->open_count == (port->console? 1 : 0)) {
-               if (port->tty) {
-                       if (port->tty->driver_data)
-                               port->tty->driver_data = NULL;
-                       port->tty = NULL;
+       if (port->port.count == (port->console? 1 : 0)) {
+               if (port->port.tty) {
+                       if (port->port.tty->driver_data)
+                               port->port.tty->driver_data = NULL;
+                       port->port.tty = NULL;
                }
        }
 
-       if (port->open_count == 0) {
+       if (port->port.count == 0) {
                mutex_lock(&port->serial->disc_mutex);
                if (!port->serial->disconnected)
                        usb_autopm_put_interface(port->serial->interface);
@@ -294,7 +297,8 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
        usb_serial_put(port->serial);
 }
 
-static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count)
+static int serial_write(struct tty_struct *tty, const unsigned char *buf,
+                                                               int count)
 {
        struct usb_serial_port *port = tty->driver_data;
        int retval = -ENODEV;
@@ -304,107 +308,112 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int
 
        dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
 
-       /* open_count is managed under the mutex lock for the tty so cannot
-           drop to zero until after the last close completes */
-       WARN_ON(!port->open_count);
+       /* count is managed under the mutex lock for the tty so cannot
+          drop to zero until after the last close completes */
+       WARN_ON(!port->port.count);
 
        /* pass on to the driver specific version of this function */
-       retval = port->serial->type->write(port, buf, count);
+       retval = port->serial->type->write(tty, port, buf, count);
 
 exit:
        return retval;
 }
 
-static int serial_write_room (struct tty_struct *tty) 
+static int serial_write_room(struct tty_struct *tty)
 {
        struct usb_serial_port *port = tty->driver_data;
        dbg("%s - port %d", __func__, port->number);
-       WARN_ON(!port->open_count);
+       WARN_ON(!port->port.count);
        /* pass on to the driver specific version of this function */
-       return port->serial->type->write_room(port);
+       return port->serial->type->write_room(tty);
 }
 
-static int serial_chars_in_buffer (struct tty_struct *tty) 
+static int serial_chars_in_buffer(struct tty_struct *tty)
 {
        struct usb_serial_port *port = tty->driver_data;
        dbg("%s = port %d", __func__, port->number);
 
-       WARN_ON(!port->open_count);
+       WARN_ON(!port->port.count);
        /* pass on to the driver specific version of this function */
-       return port->serial->type->chars_in_buffer(port);
+       return port->serial->type->chars_in_buffer(tty);
 }
 
-static void serial_throttle (struct tty_struct * tty)
+static void serial_throttle(struct tty_struct *tty)
 {
        struct usb_serial_port *port = tty->driver_data;
        dbg("%s - port %d", __func__, port->number);
 
-       WARN_ON(!port->open_count);
+       WARN_ON(!port->port.count);
        /* pass on to the driver specific version of this function */
        if (port->serial->type->throttle)
-               port->serial->type->throttle(port);
+               port->serial->type->throttle(tty);
 }
 
-static void serial_unthrottle (struct tty_struct * tty)
+static void serial_unthrottle(struct tty_struct *tty)
 {
        struct usb_serial_port *port = tty->driver_data;
        dbg("%s - port %d", __func__, port->number);
 
-       WARN_ON(!port->open_count);
+       WARN_ON(!port->port.count);
        /* pass on to the driver specific version of this function */
        if (port->serial->type->unthrottle)
-               port->serial->type->unthrottle(port);
+               port->serial->type->unthrottle(tty);
 }
 
-static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg)
+static int serial_ioctl(struct tty_struct *tty, struct file *file,
+                                       unsigned int cmd, unsigned long arg)
 {
        struct usb_serial_port *port = tty->driver_data;
        int retval = -ENODEV;
 
        dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
 
-       WARN_ON(!port->open_count);
+       WARN_ON(!port->port.count);
 
-       /* pass on to the driver specific version of this function if it is available */
+       /* pass on to the driver specific version of this function
+          if it is available */
        if (port->serial->type->ioctl) {
                lock_kernel();
-               retval = port->serial->type->ioctl(port, file, cmd, arg);
+               retval = port->serial->type->ioctl(tty, file, cmd, arg);
                unlock_kernel();
-       }
-       else
+       } else
                retval = -ENOIOCTLCMD;
        return retval;
 }
 
-static void serial_set_termios (struct tty_struct *tty, struct ktermios * old)
+static void serial_set_termios(struct tty_struct *tty, struct ktermios *old)
 {
        struct usb_serial_port *port = tty->driver_data;
        dbg("%s - port %d", __func__, port->number);
 
-       WARN_ON(!port->open_count);
-       /* pass on to the driver specific version of this function if it is available */
+       WARN_ON(!port->port.count);
+       /* pass on to the driver specific version of this function
+          if it is available */
        if (port->serial->type->set_termios)
-               port->serial->type->set_termios(port, old);
+               port->serial->type->set_termios(tty, port, old);
        else
                tty_termios_copy_hw(tty->termios, old);
 }
 
-static void serial_break (struct tty_struct *tty, int break_state)
+static int serial_break(struct tty_struct *tty, int break_state)
 {
        struct usb_serial_port *port = tty->driver_data;
 
        dbg("%s - port %d", __func__, port->number);
 
-       WARN_ON(!port->open_count);
-       /* pass on to the driver specific version of this function if it is available */
+       WARN_ON(!port->port.count);
+       /* pass on to the driver specific version of this function
+          if it is available */
        if (port->serial->type->break_ctl) {
                lock_kernel();
-               port->serial->type->break_ctl(port, break_state);
+               port->serial->type->break_ctl(tty, break_state);
                unlock_kernel();
        }
+       return 0;
 }
 
-static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data)
+static int serial_read_proc(char *page, char **start, off_t off, int count,
+                                                       int *eof, void *data)
 {
        struct usb_serial *serial;
        int length = 0;
@@ -413,26 +422,29 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, int
        char tmp[40];
 
        dbg("%s", __func__);
-       length += sprintf (page, "usbserinfo:1.0 driver:2.0\n");
+       length += sprintf(page, "usbserinfo:1.0 driver:2.0\n");
        for (i = 0; i < SERIAL_TTY_MINORS && length < PAGE_SIZE; ++i) {
                serial = usb_serial_get_by_index(i);
                if (serial == NULL)
                        continue;
 
-               length += sprintf (page+length, "%d:", i);
+               length += sprintf(page+length, "%d:", i);
                if (serial->type->driver.owner)
-                       length += sprintf (page+length, " module:%s", module_name(serial->type->driver.owner));
-               length += sprintf (page+length, " name:\"%s\"", serial->type->description);
-               length += sprintf (page+length, " vendor:%04x product:%04x", 
-                                  le16_to_cpu(serial->dev->descriptor.idVendor), 
-                                  le16_to_cpu(serial->dev->descriptor.idProduct));
-               length += sprintf (page+length, " num_ports:%d", serial->num_ports);
-               length += sprintf (page+length, " port:%d", i - serial->minor + 1);
-
+                       length += sprintf(page+length, " module:%s",
+                               module_name(serial->type->driver.owner));
+               length += sprintf(page+length, " name:\"%s\"",
+                               serial->type->description);
+               length += sprintf(page+length, " vendor:%04x product:%04x",
+                       le16_to_cpu(serial->dev->descriptor.idVendor),
+                       le16_to_cpu(serial->dev->descriptor.idProduct));
+               length += sprintf(page+length, " num_ports:%d",
+                                                       serial->num_ports);
+               length += sprintf(page+length, " port:%d",
+                                                       i - serial->minor + 1);
                usb_make_path(serial->dev, tmp, sizeof(tmp));
-               length += sprintf (page+length, " path:%s", tmp);
-                       
-               length += sprintf (page+length, "\n");
+               length += sprintf(page+length, " path:%s", tmp);
+
+               length += sprintf(page+length, "\n");
                if ((length + begin) > (off + count)) {
                        usb_serial_put(serial);
                        goto done;
@@ -448,31 +460,31 @@ done:
        if (off >= (length + begin))
                return 0;
        *start = page + (off-begin);
-       return ((count < begin+length-off) ? count : begin+length-off);
+       return (count < begin+length-off) ? count : begin+length-off;
 }
 
-static int serial_tiocmget (struct tty_struct *tty, struct file *file)
+static int serial_tiocmget(struct tty_struct *tty, struct file *file)
 {
        struct usb_serial_port *port = tty->driver_data;
 
        dbg("%s - port %d", __func__, port->number);
 
-       WARN_ON(!port->open_count);
+       WARN_ON(!port->port.count);
        if (port->serial->type->tiocmget)
-               return port->serial->type->tiocmget(port, file);
+               return port->serial->type->tiocmget(tty, file);
        return -EINVAL;
 }
 
-static int serial_tiocmset (struct tty_struct *tty, struct file *file,
+static int serial_tiocmset(struct tty_struct *tty, struct file *file,
                            unsigned int set, unsigned int clear)
 {
        struct usb_serial_port *port = tty->driver_data;
 
        dbg("%s - port %d", __func__, port->number);
 
-       WARN_ON(!port->open_count);
+       WARN_ON(!port->port.count);
        if (port->serial->type->tiocmset)
-               return port->serial->type->tiocmset(port, file, set, clear);
+               return port->serial->type->tiocmset(tty, file, set, clear);
        return -EINVAL;
 }
 
@@ -485,6 +497,7 @@ void usb_serial_port_softint(struct usb_serial_port *port)
 {
        schedule_work(&port->work);
 }
+EXPORT_SYMBOL_GPL(usb_serial_port_softint);
 
 static void usb_serial_port_work(struct work_struct *work)
 {
@@ -493,11 +506,11 @@ static void usb_serial_port_work(struct work_struct *work)
        struct tty_struct *tty;
 
        dbg("%s - port %d", __func__, port->number);
-       
+
        if (!port)
                return;
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (!tty)
                return;
 
@@ -546,9 +559,9 @@ static void port_free(struct usb_serial_port *port)
        kfree(port);
 }
 
-static struct usb_serial * create_serial (struct usb_device *dev, 
-                                         struct usb_interface *interface,
-                                         struct usb_serial_driver *driver)
+static struct usb_serial *create_serial(struct usb_device *dev,
+                                       struct usb_interface *interface,
+                                       struct usb_serial_driver *driver)
 {
        struct usb_serial *serial;
 
@@ -567,7 +580,7 @@ static struct usb_serial * create_serial (struct usb_device *dev,
 }
 
 static const struct usb_device_id *match_dynamic_id(struct usb_interface *intf,
-                                                   struct usb_serial_driver *drv)
+                                           struct usb_serial_driver *drv)
 {
        struct usb_dynid *dynid;
 
@@ -599,7 +612,8 @@ exit:
        return id;
 }
 
-static struct usb_serial_driver *search_serial_device(struct usb_interface *iface)
+static struct usb_serial_driver *search_serial_device(
+                                       struct usb_interface *iface)
 {
        const struct usb_device_id *id;
        struct usb_serial_driver *drv;
@@ -617,7 +631,7 @@ static struct usb_serial_driver *search_serial_device(struct usb_interface *ifac
 int usb_serial_probe(struct usb_interface *interface,
                               const struct usb_device_id *id)
 {
-       struct usb_device *dev = interface_to_usbdev (interface);
+       struct usb_device *dev = interface_to_usbdev(interface);
        struct usb_serial *serial = NULL;
        struct usb_serial_port *port;
        struct usb_host_interface *iface_desc;
@@ -646,7 +660,7 @@ int usb_serial_probe(struct usb_interface *interface,
                return -ENODEV;
        }
 
-       serial = create_serial (dev, interface, type);
+       serial = create_serial(dev, interface, type);
        if (!serial) {
                unlock_kernel();
                dev_err(&interface->dev, "%s - out of memory\n", __func__);
@@ -659,8 +673,9 @@ int usb_serial_probe(struct usb_interface *interface,
 
                if (!try_module_get(type->driver.owner)) {
                        unlock_kernel();
-                       dev_err(&interface->dev, "module get failed, exiting\n");
-                       kfree (serial);
+                       dev_err(&interface->dev,
+                               "module get failed, exiting\n");
+                       kfree(serial);
                        return -EIO;
                }
 
@@ -670,8 +685,8 @@ int usb_serial_probe(struct usb_interface *interface,
 
                if (retval) {
                        unlock_kernel();
-                       dbg ("sub driver rejected device");
-                       kfree (serial);
+                       dbg("sub driver rejected device");
+                       kfree(serial);
                        return retval;
                }
        }
@@ -712,7 +727,7 @@ int usb_serial_probe(struct usb_interface *interface,
        }
 
 #if defined(CONFIG_USB_SERIAL_PL2303) || defined(CONFIG_USB_SERIAL_PL2303_MODULE)
-       /* BEGIN HORRIBLE HACK FOR PL2303 */ 
+       /* BEGIN HORRIBLE HACK FOR PL2303 */
        /* this is needed due to the looney way its endpoints are set up */
        if (((le16_to_cpu(dev->descriptor.idVendor) == PL2303_VENDOR_ID) &&
             (le16_to_cpu(dev->descriptor.idProduct) == PL2303_PRODUCT_ID)) ||
@@ -741,7 +756,7 @@ int usb_serial_probe(struct usb_interface *interface,
                if (num_bulk_in == 0 || num_bulk_out == 0) {
                        unlock_kernel();
                        dev_info(&interface->dev, "PL-2303 hack: descriptors matched but endpoints did not\n");
-                       kfree (serial);
+                       kfree(serial);
                        return -ENODEV;
                }
        }
@@ -753,8 +768,9 @@ int usb_serial_probe(struct usb_interface *interface,
                num_ports = num_bulk_out;
                if (num_ports == 0) {
                        unlock_kernel();
-                       dev_err(&interface->dev, "Generic device with no bulk out, not allowed.\n");
-                       kfree (serial);
+                       dev_err(&interface->dev,
+                           "Generic device with no bulk out, not allowed.\n");
+                       kfree(serial);
                        return -EIO;
                }
        }
@@ -764,11 +780,12 @@ int usb_serial_probe(struct usb_interface *interface,
                if (type->calc_num_ports) {
                        if (!try_module_get(type->driver.owner)) {
                                unlock_kernel();
-                               dev_err(&interface->dev, "module get failed, exiting\n");
-                               kfree (serial);
+                               dev_err(&interface->dev,
+                                       "module get failed, exiting\n");
+                               kfree(serial);
                                return -EIO;
                        }
-                       num_ports = type->calc_num_ports (serial);
+                       num_ports = type->calc_num_ports(serial);
                        module_put(type->driver.owner);
                }
                if (!num_ports)
@@ -786,7 +803,8 @@ int usb_serial_probe(struct usb_interface *interface,
                        type->description);
 
        /* create our ports, we need as many as the max endpoints */
-       /* we don't use num_ports here cauz some devices have more endpoint pairs than ports */
+       /* we don't use num_ports here because some devices have more
+          endpoint pairs than ports */
        max_endpoints = max(num_bulk_in, num_bulk_out);
        max_endpoints = max(max_endpoints, num_interrupt_in);
        max_endpoints = max(max_endpoints, num_interrupt_out);
@@ -794,7 +812,8 @@ int usb_serial_probe(struct usb_interface *interface,
        serial->num_port_pointers = max_endpoints;
        unlock_kernel();
 
-       dbg("%s - setting up %d port structures for this device", __func__, max_endpoints);
+       dbg("%s - setting up %d port structures for this device",
+                                               __func__, max_endpoints);
        for (i = 0; i < max_endpoints; ++i) {
                port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
                if (!port)
@@ -810,7 +829,7 @@ int usb_serial_probe(struct usb_interface *interface,
        for (i = 0; i < num_bulk_in; ++i) {
                endpoint = bulk_in_endpoint[i];
                port = serial->port[i];
-               port->read_urb = usb_alloc_urb (0, GFP_KERNEL);
+               port->read_urb = usb_alloc_urb(0, GFP_KERNEL);
                if (!port->read_urb) {
                        dev_err(&interface->dev, "No free urbs available\n");
                        goto probe_error;
@@ -818,17 +837,17 @@ int usb_serial_probe(struct usb_interface *interface,
                buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
                port->bulk_in_size = buffer_size;
                port->bulk_in_endpointAddress = endpoint->bEndpointAddress;
-               port->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
+               port->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
                if (!port->bulk_in_buffer) {
-                       dev_err(&interface->dev, "Couldn't allocate bulk_in_buffer\n");
+                       dev_err(&interface->dev,
+                                       "Couldn't allocate bulk_in_buffer\n");
                        goto probe_error;
                }
-               usb_fill_bulk_urb (port->read_urb, dev,
-                                  usb_rcvbulkpipe (dev,
-                                                   endpoint->bEndpointAddress),
-                                  port->bulk_in_buffer, buffer_size,
-                                  serial->type->read_bulk_callback,
-                                  port);
+               usb_fill_bulk_urb(port->read_urb, dev,
+                               usb_rcvbulkpipe(dev,
+                                               endpoint->bEndpointAddress),
+                               port->bulk_in_buffer, buffer_size,
+                               serial->type->read_bulk_callback, port);
        }
 
        for (i = 0; i < num_bulk_out; ++i) {
@@ -842,17 +861,17 @@ int usb_serial_probe(struct usb_interface *interface,
                buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
                port->bulk_out_size = buffer_size;
                port->bulk_out_endpointAddress = endpoint->bEndpointAddress;
-               port->bulk_out_buffer = kmalloc (buffer_size, GFP_KERNEL);
+               port->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
                if (!port->bulk_out_buffer) {
-                       dev_err(&interface->dev, "Couldn't allocate bulk_out_buffer\n");
+                       dev_err(&interface->dev,
+                                       "Couldn't allocate bulk_out_buffer\n");
                        goto probe_error;
                }
-               usb_fill_bulk_urb (port->write_urb, dev,
-                                  usb_sndbulkpipe (dev,
-                                                   endpoint->bEndpointAddress),
-                                  port->bulk_out_buffer, buffer_size, 
-                                  serial->type->write_bulk_callback,
-                                  port);
+               usb_fill_bulk_urb(port->write_urb, dev,
+                               usb_sndbulkpipe(dev,
+                                       endpoint->bEndpointAddress),
+                               port->bulk_out_buffer, buffer_size,
+                               serial->type->write_bulk_callback, port);
        }
 
        if (serial->type->read_int_callback) {
@@ -861,73 +880,82 @@ int usb_serial_probe(struct usb_interface *interface,
                        port = serial->port[i];
                        port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
                        if (!port->interrupt_in_urb) {
-                               dev_err(&interface->dev, "No free urbs available\n");
+                               dev_err(&interface->dev,
+                                               "No free urbs available\n");
                                goto probe_error;
                        }
                        buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
-                       port->interrupt_in_endpointAddress = endpoint->bEndpointAddress;
-                       port->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
+                       port->interrupt_in_endpointAddress =
+                                               endpoint->bEndpointAddress;
+                       port->interrupt_in_buffer = kmalloc(buffer_size,
+                                                               GFP_KERNEL);
                        if (!port->interrupt_in_buffer) {
-                               dev_err(&interface->dev, "Couldn't allocate interrupt_in_buffer\n");
+                               dev_err(&interface->dev,
+                                   "Couldn't allocate interrupt_in_buffer\n");
                                goto probe_error;
                        }
-                       usb_fill_int_urb (port->interrupt_in_urb, dev, 
-                                         usb_rcvintpipe (dev,
-                                                         endpoint->bEndpointAddress),
-                                         port->interrupt_in_buffer, buffer_size, 
-                                         serial->type->read_int_callback, port, 
-                                         endpoint->bInterval);
+                       usb_fill_int_urb(port->interrupt_in_urb, dev,
+                               usb_rcvintpipe(dev,
+                                               endpoint->bEndpointAddress),
+                               port->interrupt_in_buffer, buffer_size,
+                               serial->type->read_int_callback, port,
+                               endpoint->bInterval);
                }
        } else if (num_interrupt_in) {
                dbg("the device claims to support interrupt in transfers, but read_int_callback is not defined");
        }
-       
+
        if (serial->type->write_int_callback) {
                for (i = 0; i < num_interrupt_out; ++i) {
                        endpoint = interrupt_out_endpoint[i];
                        port = serial->port[i];
                        port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
                        if (!port->interrupt_out_urb) {
-                               dev_err(&interface->dev, "No free urbs available\n");
+                               dev_err(&interface->dev,
+                                               "No free urbs available\n");
                                goto probe_error;
                        }
                        buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
                        port->interrupt_out_size = buffer_size;
-                       port->interrupt_out_endpointAddress = endpoint->bEndpointAddress;
-                       port->interrupt_out_buffer = kmalloc (buffer_size, GFP_KERNEL);
+                       port->interrupt_out_endpointAddress =
+                                               endpoint->bEndpointAddress;
+                       port->interrupt_out_buffer = kmalloc(buffer_size,
+                                                               GFP_KERNEL);
                        if (!port->interrupt_out_buffer) {
-                               dev_err(&interface->dev, "Couldn't allocate interrupt_out_buffer\n");
+                               dev_err(&interface->dev,
+                                 "Couldn't allocate interrupt_out_buffer\n");
                                goto probe_error;
                        }
-                       usb_fill_int_urb (port->interrupt_out_urb, dev,
-                                         usb_sndintpipe (dev,
-                                                         endpoint->bEndpointAddress),
-                                         port->interrupt_out_buffer, buffer_size,
-                                         serial->type->write_int_callback, port,
-                                         endpoint->bInterval);
+                       usb_fill_int_urb(port->interrupt_out_urb, dev,
+                               usb_sndintpipe(dev,
+                                                 endpoint->bEndpointAddress),
+                               port->interrupt_out_buffer, buffer_size,
+                               serial->type->write_int_callback, port,
+                               endpoint->bInterval);
                }
        } else if (num_interrupt_out) {
                dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined");
        }
-       
+
        /* if this device type has an attach function, call it */
        if (type->attach) {
                if (!try_module_get(type->driver.owner)) {
-                       dev_err(&interface->dev, "module get failed, exiting\n");
+                       dev_err(&interface->dev,
+                                       "module get failed, exiting\n");
                        goto probe_error;
                }
-               retval = type->attach (serial);
+               retval = type->attach(serial);
                module_put(type->driver.owner);
                if (retval < 0)
                        goto probe_error;
                if (retval > 0) {
-                       /* quietly accept this device, but don't bind to a serial port
-                        * as it's about to disappear */
+                       /* quietly accept this device, but don't bind to a
+                          serial port as it's about to disappear */
                        goto exit;
                }
        }
 
-       if (get_free_serial (serial, num_ports, &minor) == NULL) {
+       if (get_free_serial(serial, num_ports, &minor) == NULL) {
                dev_err(&interface->dev, "No more free serial devices\n");
                goto probe_error;
        }
@@ -949,11 +977,11 @@ int usb_serial_probe(struct usb_interface *interface,
                                "continuing\n");
        }
 
-       usb_serial_console_init (debug, minor);
+       usb_serial_console_init(debug, minor);
 
 exit:
        /* success */
-       usb_set_intfdata (interface, serial);
+       usb_set_intfdata(interface, serial);
        return 0;
 
 probe_error:
@@ -989,29 +1017,30 @@ probe_error:
        /* free up any memory that we allocated */
        for (i = 0; i < serial->num_port_pointers; ++i)
                kfree(serial->port[i]);
-       kfree (serial);
+       kfree(serial);
        return -EIO;
 }
+EXPORT_SYMBOL_GPL(usb_serial_probe);
 
 void usb_serial_disconnect(struct usb_interface *interface)
 {
        int i;
-       struct usb_serial *serial = usb_get_intfdata (interface);
+       struct usb_serial *serial = usb_get_intfdata(interface);
        struct device *dev = &interface->dev;
        struct usb_serial_port *port;
 
        usb_serial_console_disconnect(serial);
-       dbg ("%s", __func__);
+       dbg("%s", __func__);
 
        mutex_lock(&serial->disc_mutex);
-       usb_set_intfdata (interface, NULL);
+       usb_set_intfdata(interface, NULL);
        /* must set a flag, to signal subdrivers */
        serial->disconnected = 1;
        for (i = 0; i < serial->num_ports; ++i) {
                port = serial->port[i];
                if (port) {
-                       if (port->tty)
-                               tty_hangup(port->tty);
+                       if (port->port.tty)
+                               tty_hangup(port->port.tty);
                        kill_traffic(port);
                }
        }
@@ -1021,6 +1050,7 @@ void usb_serial_disconnect(struct usb_interface *interface)
        usb_serial_put(serial);
        dev_info(dev, "device disconnected\n");
 }
+EXPORT_SYMBOL_GPL(usb_serial_disconnect);
 
 int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
 {
@@ -1079,9 +1109,8 @@ static int __init usb_serial_init(void)
                return -ENOMEM;
 
        /* Initialize our global data */
-       for (i = 0; i < SERIAL_TTY_MINORS; ++i) {
+       for (i = 0; i < SERIAL_TTY_MINORS; ++i)
                serial_table[i] = NULL;
-       }
 
        result = bus_register(&usb_serial_bus_type);
        if (result) {
@@ -1096,9 +1125,11 @@ static int __init usb_serial_init(void)
        usb_serial_tty_driver->minor_start = 0;
        usb_serial_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
        usb_serial_tty_driver->subtype = SERIAL_TYPE_NORMAL;
-       usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
+       usb_serial_tty_driver->flags = TTY_DRIVER_REAL_RAW |
+                                               TTY_DRIVER_DYNAMIC_DEV;
        usb_serial_tty_driver->init_termios = tty_std_termios;
-       usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+       usb_serial_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD
+                                                       | HUPCL | CLOCAL;
        usb_serial_tty_driver->init_termios.c_ispeed = 9600;
        usb_serial_tty_driver->init_termios.c_ospeed = 9600;
        tty_set_operations(usb_serial_tty_driver, &serial_ops);
@@ -1136,7 +1167,7 @@ exit_reg_driver:
        bus_unregister(&usb_serial_bus_type);
 
 exit_bus:
-       err ("%s - returning with error %d", __func__, result);
+       err("%s - returning with error %d", __func__, result);
        put_tty_driver(usb_serial_tty_driver);
        return result;
 }
@@ -1163,7 +1194,7 @@ module_exit(usb_serial_exit);
                if (!type->function) {                                  \
                        type->function = usb_serial_generic_##function; \
                        dbg("Had to override the " #function            \
-                                " usb serial operation with the generic one.");\
+                               " usb serial operation with the generic one.");\
                        }                                               \
        } while (0)
 
@@ -1180,8 +1211,9 @@ static void fixup_generic(struct usb_serial_driver *device)
        set_to_generic_if_null(device, resume);
 }
 
-int usb_serial_register(struct usb_serial_driver *driver) /* must be called with BKL held */
+int usb_serial_register(struct usb_serial_driver *driver)
 {
+       /* must be called with BKL held */
        int retval;
 
        fixup_generic(driver);
@@ -1194,37 +1226,30 @@ int usb_serial_register(struct usb_serial_driver *driver) /* must be called with
 
        retval = usb_serial_bus_register(driver);
        if (retval) {
-               err("problem %d when registering driver %s", retval, driver->description);
+               err("problem %d when registering driver %s",
+                                               retval, driver->description);
                list_del(&driver->driver_list);
-       }
-       else
-               info("USB Serial support registered for %s", driver->description);
+       } else
+               info("USB Serial support registered for %s",
+                                               driver->description);
 
        return retval;
 }
+EXPORT_SYMBOL_GPL(usb_serial_register);
 
 
-void usb_serial_deregister(struct usb_serial_driver *device) /* must be called with BKL held */
+void usb_serial_deregister(struct usb_serial_driver *device)
 {
+       /* must be called with BKL held */
        info("USB Serial deregistering driver %s", device->description);
        list_del(&device->driver_list);
        usb_serial_bus_deregister(device);
 }
-
-
-
-/* If the usb-serial core is built into the core, the usb-serial drivers
-   need these symbols to load properly as modules. */
-EXPORT_SYMBOL_GPL(usb_serial_register);
 EXPORT_SYMBOL_GPL(usb_serial_deregister);
-EXPORT_SYMBOL_GPL(usb_serial_probe);
-EXPORT_SYMBOL_GPL(usb_serial_disconnect);
-EXPORT_SYMBOL_GPL(usb_serial_port_softint);
-
 
 /* Module information */
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index 9ca4d4d..fc5d995 100644 (file)
@@ -31,10 +31,11 @@ static struct usb_driver debug_driver = {
        .no_dynamic_id =        1,
 };
 
-int usb_debug_open(struct usb_serial_port *port, struct file *filp)
+int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port,
+                                                       struct file *filp)
 {
        port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE;
-       return usb_serial_generic_open(port, filp);
+       return usb_serial_generic_open(tty, port, filp);
 }
 
 static struct usb_serial_driver debug_device = {
index 5fc2012..cf8924f 100644 (file)
@@ -9,7 +9,8 @@
  *     modify it under the terms of the GNU General Public License version
  *     2 as published by the Free Software Foundation.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  *
  */
 
@@ -23,7 +24,7 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/spinlock.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 #include "visor.h"
 #define DRIVER_DESC "USB HandSpring Visor / Palm OS driver"
 
 /* function prototypes for a handspring visor */
-static int  visor_open         (struct usb_serial_port *port, struct file *filp);
-static void visor_close                (struct usb_serial_port *port, struct file *filp);
-static int  visor_write                (struct usb_serial_port *port, const unsigned char *buf, int count);
-static int  visor_write_room           (struct usb_serial_port *port);
-static int  visor_chars_in_buffer      (struct usb_serial_port *port);
-static void visor_throttle     (struct usb_serial_port *port);
-static void visor_unthrottle   (struct usb_serial_port *port);
-static int  visor_probe                (struct usb_serial *serial, const struct usb_device_id *id);
+static int  visor_open(struct tty_struct *tty, struct usb_serial_port *port,
+                                       struct file *filp);
+static void visor_close(struct tty_struct *tty, struct usb_serial_port *port,
+                                       struct file *filp);
+static int  visor_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count);
+static int  visor_write_room(struct tty_struct *tty);
+static void visor_throttle(struct tty_struct *tty);
+static void visor_unthrottle(struct tty_struct *tty);
+static int  visor_probe(struct usb_serial *serial,
+                                       const struct usb_device_id *id);
 static int  visor_calc_num_ports(struct usb_serial *serial);
-static void visor_shutdown     (struct usb_serial *serial);
-static int  visor_ioctl                (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
-static void visor_write_bulk_callback  (struct urb *urb);
-static void visor_read_bulk_callback   (struct urb *urb);
-static void visor_read_int_callback    (struct urb *urb);
-static int  clie_3_5_startup   (struct usb_serial *serial);
-static int  treo_attach                (struct usb_serial *serial);
-static int clie_5_attach (struct usb_serial *serial);
-static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id);
-static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id);
+static void visor_shutdown(struct usb_serial *serial);
+static void visor_write_bulk_callback(struct urb *urb);
+static void visor_read_bulk_callback(struct urb *urb);
+static void visor_read_int_callback(struct urb *urb);
+static int  clie_3_5_startup(struct usb_serial *serial);
+static int  treo_attach(struct usb_serial *serial);
+static int clie_5_attach(struct usb_serial *serial);
+static int palm_os_3_probe(struct usb_serial *serial,
+                                       const struct usb_device_id *id);
+static int palm_os_4_probe(struct usb_serial *serial,
+                                       const struct usb_device_id *id);
 
 /* Parameters that may be passed into the module. */
 static int debug;
@@ -105,13 +110,13 @@ static struct usb_device_id id_table [] = {
                .driver_info = (kernel_ulong_t)&palm_os_4_probe },
        { USB_DEVICE(ACER_VENDOR_ID, ACER_S10_ID),
                .driver_info = (kernel_ulong_t)&palm_os_4_probe },
-       { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), 
+       { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID),
                .driver_info = (kernel_ulong_t)&palm_os_4_probe },
-       { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), 
+       { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID),
                .driver_info = (kernel_ulong_t)&palm_os_4_probe },
        { USB_DEVICE(TAPWAVE_VENDOR_ID, TAPWAVE_ZODIAC_ID),
                .driver_info = (kernel_ulong_t)&palm_os_4_probe },
-       { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID), 
+       { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID),
                .driver_info = (kernel_ulong_t)&palm_os_4_probe },
        { USB_DEVICE(ACEECA_VENDOR_ID, ACEECA_MEZ1000_ID),
                .driver_info = (kernel_ulong_t)&palm_os_4_probe },
@@ -170,7 +175,7 @@ static struct usb_device_id id_table_combined [] = {
        { }                                     /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table_combined);
+MODULE_DEVICE_TABLE(usb, id_table_combined);
 
 static struct usb_driver visor_driver = {
        .name =         "visor",
@@ -180,7 +185,8 @@ static struct usb_driver visor_driver = {
        .no_dynamic_id =        1,
 };
 
-/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */
+/* All of the device info needed for the Handspring Visor,
+   and Palm 4.0 devices */
 static struct usb_serial_driver handspring_device = {
        .driver = {
                .owner =        THIS_MODULE,
@@ -198,10 +204,8 @@ static struct usb_serial_driver handspring_device = {
        .probe =                visor_probe,
        .calc_num_ports =       visor_calc_num_ports,
        .shutdown =             visor_shutdown,
-       .ioctl =                visor_ioctl,
        .write =                visor_write,
        .write_room =           visor_write_room,
-       .chars_in_buffer =      visor_chars_in_buffer,
        .write_bulk_callback =  visor_write_bulk_callback,
        .read_bulk_callback =   visor_read_bulk_callback,
        .read_int_callback =    visor_read_int_callback,
@@ -225,10 +229,8 @@ static struct usb_serial_driver clie_5_device = {
        .probe =                visor_probe,
        .calc_num_ports =       visor_calc_num_ports,
        .shutdown =             visor_shutdown,
-       .ioctl =                visor_ioctl,
        .write =                visor_write,
        .write_room =           visor_write_room,
-       .chars_in_buffer =      visor_chars_in_buffer,
        .write_bulk_callback =  visor_write_bulk_callback,
        .read_bulk_callback =   visor_read_bulk_callback,
        .read_int_callback =    visor_read_int_callback,
@@ -249,10 +251,8 @@ static struct usb_serial_driver clie_3_5_device = {
        .throttle =             visor_throttle,
        .unthrottle =           visor_unthrottle,
        .attach =               clie_3_5_startup,
-       .ioctl =                visor_ioctl,
        .write =                visor_write,
        .write_room =           visor_write_room,
-       .chars_in_buffer =      visor_chars_in_buffer,
        .write_bulk_callback =  visor_write_bulk_callback,
        .read_bulk_callback =   visor_read_bulk_callback,
 };
@@ -274,7 +274,8 @@ static int stats;
 /******************************************************************************
  * Handspring Visor specific driver functions
  ******************************************************************************/
-static int visor_open (struct usb_serial_port *port, struct file *filp)
+static int visor_open(struct tty_struct *tty, struct usb_serial_port *port,
+                                                       struct file *filp)
 {
        struct usb_serial *serial = port->serial;
        struct visor_private *priv = usb_get_serial_port_data(port);
@@ -300,42 +301,45 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
         * through, otherwise it is scheduled, and with high data rates (like
         * with OHCI) data can get lost.
         */
-       if (port->tty)
-               port->tty->low_latency = 1;
+       if (tty)
+               tty->low_latency = 1;
 
        /* Start reading from the device */
-       usb_fill_bulk_urb (port->read_urb, serial->dev,
-                          usb_rcvbulkpipe (serial->dev, 
+       usb_fill_bulk_urb(port->read_urb, serial->dev,
+                          usb_rcvbulkpipe(serial->dev,
                                            port->bulk_in_endpointAddress),
                           port->read_urb->transfer_buffer,
                           port->read_urb->transfer_buffer_length,
                           visor_read_bulk_callback, port);
        result = usb_submit_urb(port->read_urb, GFP_KERNEL);
        if (result) {
-               dev_err(&port->dev, "%s - failed submitting read urb, error %d\n",
-                       __func__, result);
+               dev_err(&port->dev,
+                       "%s - failed submitting read urb, error %d\n",
+                                                       __func__, result);
                goto exit;
        }
-       
+
        if (port->interrupt_in_urb) {
                dbg("%s - adding interrupt input for treo", __func__);
                result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
                if (result)
-                       dev_err(&port->dev, "%s - failed submitting interrupt urb, error %d\n",
-                               __func__, result);
+                       dev_err(&port->dev,
+                           "%s - failed submitting interrupt urb, error %d\n",
+                                                       __func__, result);
        }
-exit:  
+exit:
        return result;
 }
 
 
-static void visor_close (struct usb_serial_port *port, struct file * filp)
+static void visor_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct visor_private *priv = usb_get_serial_port_data(port);
        unsigned char *transfer_buffer;
 
        dbg("%s - port %d", __func__, port->number);
-                        
+
        /* shutdown our urbs */
        usb_kill_urb(port->read_urb);
        usb_kill_urb(port->interrupt_in_urb);
@@ -343,14 +347,14 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
        mutex_lock(&port->serial->disc_mutex);
        if (!port->serial->disconnected) {
                /* Try to send shutdown message, unless the device is gone */
-               transfer_buffer =  kmalloc (0x12, GFP_KERNEL);
+               transfer_buffer =  kmalloc(0x12, GFP_KERNEL);
                if (transfer_buffer) {
-                       usb_control_msg (port->serial->dev,
+                       usb_control_msg(port->serial->dev,
                                         usb_rcvctrlpipe(port->serial->dev, 0),
                                         VISOR_CLOSE_NOTIFICATION, 0xc2,
                                         0x0000, 0x0000,
                                         transfer_buffer, 0x12, 300);
-                       kfree (transfer_buffer);
+                       kfree(transfer_buffer);
                }
        }
        mutex_unlock(&port->serial->disc_mutex);
@@ -361,7 +365,8 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
 }
 
 
-static int visor_write (struct usb_serial_port *port, const unsigned char *buf, int count)
+static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
+                                       const unsigned char *buf, int count)
 {
        struct visor_private *priv = usb_get_serial_port_data(port);
        struct usb_serial *serial = port->serial;
@@ -381,7 +386,7 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf,
        priv->outstanding_urbs++;
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       buffer = kmalloc (count, GFP_ATOMIC);
+       buffer = kmalloc(count, GFP_ATOMIC);
        if (!buffer) {
                dev_err(&port->dev, "out of memory\n");
                count = -ENOMEM;
@@ -395,21 +400,22 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf,
                goto error_no_urb;
        }
 
-       memcpy (buffer, buf, count);
+       memcpy(buffer, buf, count);
 
        usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
 
-       usb_fill_bulk_urb (urb, serial->dev,
-                          usb_sndbulkpipe (serial->dev,
+       usb_fill_bulk_urb(urb, serial->dev,
+                          usb_sndbulkpipe(serial->dev,
                                            port->bulk_out_endpointAddress),
-                          buffer, count, 
+                          buffer, count,
                           visor_write_bulk_callback, port);
 
        /* send it down the pipe */
        status = usb_submit_urb(urb, GFP_ATOMIC);
        if (status) {
-               dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n",
-                       __func__, status);
+               dev_err(&port->dev,
+                  "%s - usb_submit_urb(write bulk) failed with status = %d\n",
+                                                       __func__, status);
                count = status;
                goto error;
        } else {
@@ -435,8 +441,9 @@ error_no_buffer:
 }
 
 
-static int visor_write_room (struct usb_serial_port *port)
+static int visor_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct visor_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
 
@@ -460,23 +467,7 @@ static int visor_write_room (struct usb_serial_port *port)
 }
 
 
-static int visor_chars_in_buffer (struct usb_serial_port *port)
-{
-       dbg("%s - port %d", __func__, port->number);
-
-       /* 
-        * We can't really account for how much data we
-        * have sent out, but hasn't made it through to the
-        * device, so just tell the tty layer that everything
-        * is flushed.
-        *
-        * FIXME: Should walk outstanding_urbs
-        */
-       return 0;
-}
-
-
-static void visor_write_bulk_callback (struct urb *urb)
+static void visor_write_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        struct visor_private *priv = usb_get_serial_port_data(port);
@@ -484,7 +475,7 @@ static void visor_write_bulk_callback (struct urb *urb)
        unsigned long flags;
 
        /* free up the transfer buffer, as usb_free_urb() does not do this */
-       kfree (urb->transfer_buffer);
+       kfree(urb->transfer_buffer);
 
        dbg("%s - port %d", __func__, port->number);
 
@@ -500,7 +491,7 @@ static void visor_write_bulk_callback (struct urb *urb)
 }
 
 
-static void visor_read_bulk_callback (struct urb *urb)
+static void visor_read_bulk_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        struct visor_private *priv = usb_get_serial_port_data(port);
@@ -518,11 +509,13 @@ static void visor_read_bulk_callback (struct urb *urb)
                return;
        }
 
-       usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
+       usb_serial_debug_data(debug, &port->dev, __func__,
+                                               urb->actual_length, data);
 
-       tty = port->tty;
+       tty = port->port.tty;
        if (tty && urb->actual_length) {
-               available_room = tty_buffer_request_room(tty, urb->actual_length);
+               available_room = tty_buffer_request_room(tty,
+                                                       urb->actual_length);
                if (available_room) {
                        tty_insert_flip_string(tty, data, available_room);
                        tty_flip_buffer_push(tty);
@@ -536,22 +529,23 @@ static void visor_read_bulk_callback (struct urb *urb)
 
        /* Continue trying to always read if we should */
        if (!priv->throttled) {
-               usb_fill_bulk_urb (port->read_urb, port->serial->dev,
+               usb_fill_bulk_urb(port->read_urb, port->serial->dev,
                                   usb_rcvbulkpipe(port->serial->dev,
-                                                  port->bulk_in_endpointAddress),
+                                          port->bulk_in_endpointAddress),
                                   port->read_urb->transfer_buffer,
                                   port->read_urb->transfer_buffer_length,
                                   visor_read_bulk_callback, port);
                result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
                if (result)
-                       dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result);
-       } else {
+                       dev_err(&port->dev,
+                           "%s - failed resubmitting read urb, error %d\n",
+                                                       __func__, result);
+       } else
                priv->actually_throttled = 1;
-       }
        spin_unlock(&priv->lock);
 }
 
-static void visor_read_int_callback (struct urb *urb)
+static void visor_read_int_callback(struct urb *urb)
 {
        struct usb_serial_port *port = urb->context;
        int status = urb->status;
@@ -585,14 +579,16 @@ static void visor_read_int_callback (struct urb *urb)
                              urb->actual_length, urb->transfer_buffer);
 
 exit:
-       result = usb_submit_urb (urb, GFP_ATOMIC);
+       result = usb_submit_urb(urb, GFP_ATOMIC);
        if (result)
-               dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n",
-                       __func__, result);
+               dev_err(&urb->dev->dev,
+                               "%s - Error %d submitting interrupt urb\n",
+                                                       __func__, result);
 }
 
-static void visor_throttle (struct usb_serial_port *port)
+static void visor_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct visor_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
 
@@ -603,8 +599,9 @@ static void visor_throttle (struct usb_serial_port *port)
 }
 
 
-static void visor_unthrottle (struct usb_serial_port *port)
+static void visor_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct visor_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
        int result;
@@ -618,10 +615,13 @@ static void visor_unthrottle (struct usb_serial_port *port)
        port->read_urb->dev = port->serial->dev;
        result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
        if (result)
-               dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result);
+               dev_err(&port->dev,
+                       "%s - failed submitting read urb, error %d\n",
+                                                       __func__, result);
 }
 
-static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id)
+static int palm_os_3_probe(struct usb_serial *serial,
+                                               const struct usb_device_id *id)
 {
        struct device *dev = &serial->dev->dev;
        struct visor_connection_info *connection_info;
@@ -633,7 +633,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
 
        dbg("%s", __func__);
 
-       transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL);
+       transfer_buffer = kmalloc(sizeof(*connection_info), GFP_KERNEL);
        if (!transfer_buffer) {
                dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__,
                        sizeof(*connection_info));
@@ -641,7 +641,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
        }
 
        /* send a get connection info request */
-       retval = usb_control_msg (serial->dev,
+       retval = usb_control_msg(serial->dev,
                                  usb_rcvctrlpipe(serial->dev, 0),
                                  VISOR_GET_CONNECTION_INFORMATION,
                                  0xc2, 0x0000, 0x0000, transfer_buffer,
@@ -653,29 +653,31 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
        }
 
        if (retval == sizeof(*connection_info)) {
-               connection_info = (struct visor_connection_info *)transfer_buffer;
+                       connection_info = (struct visor_connection_info *)
+                                                       transfer_buffer;
 
                num_ports = le16_to_cpu(connection_info->num_ports);
                for (i = 0; i < num_ports; ++i) {
-                       switch (connection_info->connections[i].port_function_id) {
-                               case VISOR_FUNCTION_GENERIC:
-                                       string = "Generic";
-                                       break;
-                               case VISOR_FUNCTION_DEBUGGER:
-                                       string = "Debugger";
-                                       break;
-                               case VISOR_FUNCTION_HOTSYNC:
-                                       string = "HotSync";
-                                       break;
-                               case VISOR_FUNCTION_CONSOLE:
-                                       string = "Console";
-                                       break;
-                               case VISOR_FUNCTION_REMOTE_FILE_SYS:
-                                       string = "Remote File System";
-                                       break;
-                               default:
-                                       string = "unknown";
-                                       break;
+                       switch (
+                          connection_info->connections[i].port_function_id) {
+                       case VISOR_FUNCTION_GENERIC:
+                               string = "Generic";
+                               break;
+                       case VISOR_FUNCTION_DEBUGGER:
+                               string = "Debugger";
+                               break;
+                       case VISOR_FUNCTION_HOTSYNC:
+                               string = "HotSync";
+                               break;
+                       case VISOR_FUNCTION_CONSOLE:
+                               string = "Console";
+                               break;
+                       case VISOR_FUNCTION_REMOTE_FILE_SYS:
+                               string = "Remote File System";
+                               break;
+                       default:
+                               string = "unknown";
+                               break;
                        }
                        dev_info(dev, "%s: port %d, is for %s use\n",
                                serial->type->description,
@@ -686,11 +688,11 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
        * Handle devices that report invalid stuff here.
        */
        if (num_ports == 0 || num_ports > 2) {
-               dev_warn (dev, "%s: No valid connect info available\n",
+               dev_warn(dev, "%s: No valid connect info available\n",
                        serial->type->description);
                num_ports = 2;
        }
-  
+
        dev_info(dev, "%s: Number of ports: %d\n", serial->type->description,
                num_ports);
 
@@ -700,8 +702,9 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
         */
        usb_set_serial_data(serial, (void *)(long)num_ports);
 
-       /* ask for the number of bytes available, but ignore the response as it is broken */
-       retval = usb_control_msg (serial->dev,
+       /* ask for the number of bytes available, but ignore the
+          response as it is broken */
+       retval = usb_control_msg(serial->dev,
                                  usb_rcvctrlpipe(serial->dev, 0),
                                  VISOR_REQUEST_BYTES_AVAILABLE,
                                  0xc2, 0x0000, 0x0005, transfer_buffer,
@@ -712,12 +715,13 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
        retval = 0;
 
 exit:
-       kfree (transfer_buffer);
+       kfree(transfer_buffer);
 
        return retval;
 }
 
-static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id)
+static int palm_os_4_probe(struct usb_serial *serial,
+                                               const struct usb_device_id *id)
 {
        struct device *dev = &serial->dev->dev;
        struct palm_ext_connection_info *connection_info;
@@ -726,18 +730,18 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i
 
        dbg("%s", __func__);
 
-       transfer_buffer =  kmalloc (sizeof (*connection_info), GFP_KERNEL);
+       transfer_buffer =  kmalloc(sizeof(*connection_info), GFP_KERNEL);
        if (!transfer_buffer) {
                dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__,
                        sizeof(*connection_info));
                return -ENOMEM;
        }
 
-       retval = usb_control_msg (serial->dev,
-                                 usb_rcvctrlpipe(serial->dev, 0), 
+       retval = usb_control_msg(serial->dev,
+                                 usb_rcvctrlpipe(serial->dev, 0),
                                  PALM_GET_EXT_CONNECTION_INFORMATION,
                                  0xc2, 0x0000, 0x0000, transfer_buffer,
-                                 sizeof (*connection_info), 300);
+                                 sizeof(*connection_info), 300);
        if (retval < 0)
                dev_err(dev, "%s - error %d getting connection info\n",
                        __func__, retval);
@@ -745,15 +749,17 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i
                usb_serial_debug_data(debug, &serial->dev->dev, __func__,
                                      retval, transfer_buffer);
 
-       kfree (transfer_buffer);
+       kfree(transfer_buffer);
        return 0;
 }
 
 
-static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id)
+static int visor_probe(struct usb_serial *serial,
+                                       const struct usb_device_id *id)
 {
        int retval = 0;
-       int (*startup) (struct usb_serial *serial, const struct usb_device_id *id);
+       int (*startup)(struct usb_serial *serial,
+                                       const struct usb_device_id *id);
 
        dbg("%s", __func__);
 
@@ -771,7 +777,7 @@ static int visor_probe (struct usb_serial *serial, const struct usb_device_id *i
        return retval;
 }
 
-static int visor_calc_num_ports (struct usb_serial *serial)
+static int visor_calc_num_ports(struct usb_serial *serial)
 {
        int num_ports = (int)(long)(usb_get_serial_data(serial));
 
@@ -788,7 +794,7 @@ static int generic_startup(struct usb_serial *serial)
        int i;
 
        for (i = 0; i < serial->num_ports; ++i) {
-               priv = kzalloc (sizeof(*priv), GFP_KERNEL);
+               priv = kzalloc(sizeof(*priv), GFP_KERNEL);
                if (!priv) {
                        while (i-- != 0) {
                                priv = usb_get_serial_port_data(ports[i]);
@@ -803,7 +809,7 @@ static int generic_startup(struct usb_serial *serial)
        return 0;
 }
 
-static int clie_3_5_startup (struct usb_serial *serial)
+static int clie_3_5_startup(struct usb_serial *serial)
 {
        struct device *dev = &serial->dev->dev;
        int result;
@@ -816,62 +822,72 @@ static int clie_3_5_startup (struct usb_serial *serial)
         */
 
        /* get the config number */
-       result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0),
+       result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
                                  USB_REQ_GET_CONFIGURATION, USB_DIR_IN,
                                  0, 0, &data, 1, 3000);
        if (result < 0) {
-               dev_err(dev, "%s: get config number failed: %d\n", __func__, result);
+               dev_err(dev, "%s: get config number failed: %d\n",
+                                                       __func__, result);
                return result;
        }
        if (result != 1) {
-               dev_err(dev, "%s: get config number bad return length: %d\n", __func__, result);
+               dev_err(dev, "%s: get config number bad return length: %d\n",
+                                                       __func__, result);
                return -EIO;
        }
 
        /* get the interface number */
-       result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0),
-                                 USB_REQ_GET_INTERFACE, 
+       result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
+                                 USB_REQ_GET_INTERFACE,
                                  USB_DIR_IN | USB_RECIP_INTERFACE,
                                  0, 0, &data, 1, 3000);
        if (result < 0) {
-               dev_err(dev, "%s: get interface number failed: %d\n", __func__, result);
+               dev_err(dev, "%s: get interface number failed: %d\n",
+                                                       __func__, result);
                return result;
        }
        if (result != 1) {
-               dev_err(dev, "%s: get interface number bad return length: %d\n", __func__, result);
+               dev_err(dev,
+                       "%s: get interface number bad return length: %d\n",
+                                                       __func__, result);
                return -EIO;
        }
 
        return generic_startup(serial);
 }
-static int treo_attach (struct usb_serial *serial)
+
+static int treo_attach(struct usb_serial *serial)
 {
        struct usb_serial_port *swap_port;
 
        /* Only do this endpoint hack for the Handspring devices with
         * interrupt in endpoints, which for now are the Treo devices. */
-       if (!((le16_to_cpu(serial->dev->descriptor.idVendor) == HANDSPRING_VENDOR_ID) ||
-             (le16_to_cpu(serial->dev->descriptor.idVendor) == KYOCERA_VENDOR_ID)) ||
-           (serial->num_interrupt_in == 0))
+       if (!((le16_to_cpu(serial->dev->descriptor.idVendor)
+                                               == HANDSPRING_VENDOR_ID) ||
+               (le16_to_cpu(serial->dev->descriptor.idVendor)
+                                               == KYOCERA_VENDOR_ID)) ||
+               (serial->num_interrupt_in == 0))
                goto generic_startup;
 
        dbg("%s", __func__);
 
        /*
-       * It appears that Treos and Kyoceras want to use the 
-       * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint, 
-       * so let's swap the 1st and 2nd bulk in and interrupt endpoints.  
-       * Note that swapping the bulk out endpoints would break lots of 
+       * It appears that Treos and Kyoceras want to use the
+       * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint,
+       * so let's swap the 1st and 2nd bulk in and interrupt endpoints.
+       * Note that swapping the bulk out endpoints would break lots of
        * apps that want to communicate on the second port.
        */
 #define COPY_PORT(dest, src)                                           \
-       dest->read_urb = src->read_urb;                                 \
-       dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress;   \
-       dest->bulk_in_buffer = src->bulk_in_buffer;                     \
-       dest->interrupt_in_urb = src->interrupt_in_urb;                 \
-       dest->interrupt_in_endpointAddress = src->interrupt_in_endpointAddress; \
-       dest->interrupt_in_buffer = src->interrupt_in_buffer;
+       do { \
+               dest->read_urb = src->read_urb;                         \
+               dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress;\
+               dest->bulk_in_buffer = src->bulk_in_buffer;             \
+               dest->interrupt_in_urb = src->interrupt_in_urb;         \
+               dest->interrupt_in_endpointAddress = \
+                                       src->interrupt_in_endpointAddress;\
+               dest->interrupt_in_buffer = src->interrupt_in_buffer;   \
+       } while (0);
 
        swap_port = kmalloc(sizeof(*swap_port), GFP_KERNEL);
        if (!swap_port)
@@ -885,28 +901,30 @@ generic_startup:
        return generic_startup(serial);
 }
 
-static int clie_5_attach (struct usb_serial *serial)
+static int clie_5_attach(struct usb_serial *serial)
 {
        dbg("%s", __func__);
 
-       /* TH55 registers 2 ports. 
-          Communication in from the UX50/TH55 uses bulk_in_endpointAddress from port 0 
-          Communication out to the UX50/TH55 uses bulk_out_endpointAddress from port 1 
-          
+       /* TH55 registers 2 ports.
+          Communication in from the UX50/TH55 uses bulk_in_endpointAddress
+          from port 0. Communication out to the UX50/TH55 uses
+          bulk_out_endpointAddress from port 1
+
           Lets do a quick and dirty mapping
         */
-       
+
        /* some sanity check */
        if (serial->num_ports < 2)
                return -1;
-               
+
        /* port 0 now uses the modified endpoint Address */
-       serial->port[0]->bulk_out_endpointAddress = serial->port[1]->bulk_out_endpointAddress;
+       serial->port[0]->bulk_out_endpointAddress =
+                               serial->port[1]->bulk_out_endpointAddress;
 
        return generic_startup(serial);
 }
 
-static void visor_shutdown (struct usb_serial *serial)
+static void visor_shutdown(struct usb_serial *serial)
 {
        struct visor_private *priv;
        int i;
@@ -922,37 +940,35 @@ static void visor_shutdown (struct usb_serial *serial)
        }
 }
 
-static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
-{
-       dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
-
-       return -ENOIOCTLCMD;
-}
-
-static int __init visor_init (void)
+static int __init visor_init(void)
 {
        int i, retval;
        /* Only if parameters were passed to us */
-       if ((vendor>0) && (product>0)) {
-               struct usb_device_id usb_dev_temp[]=
-                       {{USB_DEVICE(vendor, product),
-                       .driver_info = (kernel_ulong_t)&palm_os_4_probe }};
+       if (vendor > 0 && product > 0) {
+               struct usb_device_id usb_dev_temp[] = {
+                       {
+                               USB_DEVICE(vendor, product),
+                               .driver_info =
+                                       (kernel_ulong_t) &palm_os_4_probe
+                       }
+               };
 
                /* Find the last entry in id_table */
-               for (i=0; ; i++) {
-                       if (id_table[i].idVendor==0) {
+               for (i = 0;; i++) {
+                       if (id_table[i].idVendor == 0) {
                                id_table[i] = usb_dev_temp[0];
                                break;
                        }
                }
                /* Find the last entry in id_table_combined */
-               for (i=0; ; i++) {
-                       if (id_table_combined[i].idVendor==0) {
+               for (i = 0;; i++) {
+                       if (id_table_combined[i].idVendor == 0) {
                                id_table_combined[i] = usb_dev_temp[0];
                                break;
                        }
                }
-               info("Untested USB device specified at time of module insertion");
+               info(
+                 "Untested USB device specified at time of module insertion");
                info("Warning: This is not guaranteed to work");
                info("Using a newer kernel is preferred to this method");
                info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x",
@@ -968,7 +984,7 @@ static int __init visor_init (void)
        if (retval)
                goto failed_clie_5_register;
        retval = usb_register(&visor_driver);
-       if (retval) 
+       if (retval)
                goto failed_usb_register;
        info(DRIVER_DESC);
 
@@ -986,18 +1002,18 @@ failed_handspring_register:
 
 static void __exit visor_exit (void)
 {
-       usb_deregister (&visor_driver);
-       usb_serial_deregister (&handspring_device);
-       usb_serial_deregister (&clie_3_5_device);
-       usb_serial_deregister (&clie_5_device);
+       usb_deregister(&visor_driver);
+       usb_serial_deregister(&handspring_device);
+       usb_serial_deregister(&clie_3_5_device);
+       usb_serial_deregister(&clie_5_device);
 }
 
 
 module_init(visor_init);
 module_exit(visor_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
index 665aa77..3a9d143 100644 (file)
  *     the Free Software Foundation; either version 2 of the License, or
  *     (at your option) any later version.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  *
  * (10/09/2002) Stuart MacDonald (stuartm@connecttech.com)
  *     Upgrade to full working driver
  *
  * (05/30/2001) gkh
- *     switched from using spinlock to a semaphore, which fixes lots of problems.
+ *     switched from using spinlock to a semaphore, which fixes lots of
+ *     problems.
  *
  * (04/08/2001) gb
  *     Identify version on module load.
- * 
+ *
  * 2001_Mar_19 gkh
- *     Fixed MOD_INC and MOD_DEC logic, the ability to open a port more 
+ *     Fixed MOD_INC and MOD_DEC logic, the ability to open a port more
  *     than once, and the got the proper usb_device_id table entries so
  *     the driver works again.
  *
  * (11/01/2000) Adam J. Richter
  *     usb_device_id table support
- * 
+ *
  * (10/05/2000) gkh
  *     Fixed bug with urb->dev not being set properly, now that the usb
  *     core needs it.
- * 
+ *
  * (10/03/2000) smd
  *     firmware is improved to guard against crap sent to device
  *     firmware now replies CMD_FAILURE on bad things
@@ -52,9 +54,9 @@
  *     Fixed bug with port->minor that was found by Al Borchers
  *
  * (07/04/2000) gkh
- *     Added support for port settings. Baud rate can now be changed. Line signals
- *     are not transferred to and from the tty layer yet, but things seem to be 
- *     working well now.
+ *     Added support for port settings. Baud rate can now be changed. Line
+ *     signals are not transferred to and from the tty layer yet, but things
+ *     seem to be working well now.
  *
  * (05/04/2000) gkh
  *     First cut at open and close commands. Data can flow through the ports at
@@ -62,7 +64,7 @@
  *
  * (03/26/2000) gkh
  *     Split driver up into device specific pieces.
- * 
+ *
  */
 
 #include <linux/kernel.h>
@@ -75,7 +77,7 @@
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <asm/termbits.h>
 #include <linux/usb.h>
 #include <linux/serial_reg.h>
@@ -125,7 +127,7 @@ static struct usb_device_id id_table_combined [] = {
        { }                                             /* Terminating entry */
 };
 
-MODULE_DEVICE_TABLE (usb, id_table_combined);
+MODULE_DEVICE_TABLE(usb, id_table_combined);
 
 static struct usb_driver whiteheat_driver = {
        .name =         "whiteheat",
@@ -136,26 +138,34 @@ static struct usb_driver whiteheat_driver = {
 };
 
 /* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */
-static int  whiteheat_firmware_download        (struct usb_serial *serial, const struct usb_device_id *id);
-static int  whiteheat_firmware_attach  (struct usb_serial *serial);
+static int  whiteheat_firmware_download(struct usb_serial *serial,
+                                       const struct usb_device_id *id);
+static int  whiteheat_firmware_attach(struct usb_serial *serial);
 
 /* function prototypes for the Connect Tech WhiteHEAT serial converter */
-static int  whiteheat_attach           (struct usb_serial *serial);
-static void whiteheat_shutdown         (struct usb_serial *serial);
-static int  whiteheat_open             (struct usb_serial_port *port, struct file *filp);
-static void whiteheat_close            (struct usb_serial_port *port, struct file *filp);
-static int  whiteheat_write            (struct usb_serial_port *port, const unsigned char *buf, int count);
-static int  whiteheat_write_room       (struct usb_serial_port *port);
-static int  whiteheat_ioctl            (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
-static void whiteheat_set_termios      (struct usb_serial_port *port, struct ktermios * old);
-static int  whiteheat_tiocmget         (struct usb_serial_port *port, struct file *file);
-static int  whiteheat_tiocmset         (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
-static void whiteheat_break_ctl                (struct usb_serial_port *port, int break_state);
-static int  whiteheat_chars_in_buffer  (struct usb_serial_port *port);
-static void whiteheat_throttle         (struct usb_serial_port *port);
-static void whiteheat_unthrottle       (struct usb_serial_port *port);
-static void whiteheat_read_callback    (struct urb *urb);
-static void whiteheat_write_callback   (struct urb *urb);
+static int  whiteheat_attach(struct usb_serial *serial);
+static void whiteheat_shutdown(struct usb_serial *serial);
+static int  whiteheat_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static void whiteheat_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+static int  whiteheat_write(struct tty_struct *tty,
+                       struct usb_serial_port *port,
+                       const unsigned char *buf, int count);
+static int  whiteheat_write_room(struct tty_struct *tty);
+static int  whiteheat_ioctl(struct tty_struct *tty, struct file *file,
+                       unsigned int cmd, unsigned long arg);
+static void whiteheat_set_termios(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct ktermios *old);
+static int  whiteheat_tiocmget(struct tty_struct *tty, struct file *file);
+static int  whiteheat_tiocmset(struct tty_struct *tty, struct file *file,
+                       unsigned int set, unsigned int clear);
+static void whiteheat_break_ctl(struct tty_struct *tty, int break_state);
+static int  whiteheat_chars_in_buffer(struct tty_struct *tty);
+static void whiteheat_throttle(struct tty_struct *tty);
+static void whiteheat_unthrottle(struct tty_struct *tty);
+static void whiteheat_read_callback(struct urb *urb);
+static void whiteheat_write_callback(struct urb *urb);
 
 static struct usb_serial_driver whiteheat_fake_device = {
        .driver = {
@@ -202,7 +212,9 @@ struct whiteheat_command_private {
        struct mutex            mutex;
        __u8                    port_running;
        __u8                    command_finished;
-       wait_queue_head_t       wait_command;   /* for handling sleeping while waiting for a command to finish */
+       wait_queue_head_t       wait_command; /* for handling sleeping whilst
+                                                waiting for a command to
+                                                finish */
        __u8                    result_buffer[64];
 };
 
@@ -239,14 +251,16 @@ static void command_port_write_callback(struct urb *urb);
 static void command_port_read_callback(struct urb *urb);
 
 static int start_port_read(struct usb_serial_port *port);
-static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head);
+static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb,
+                                               struct list_head *head);
 static struct list_head *list_first(struct list_head *head);
 static void rx_data_softint(struct work_struct *work);
 
-static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize);
+static int firm_send_command(struct usb_serial_port *port, __u8 command,
+                                               __u8 *data, __u8 datasize);
 static int firm_open(struct usb_serial_port *port);
 static int firm_close(struct usb_serial_port *port);
-static int firm_setup_port(struct usb_serial_port *port);
+static int firm_setup_port(struct tty_struct *tty);
 static int firm_set_rts(struct usb_serial_port *port, __u8 onoff);
 static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff);
 static int firm_set_break(struct usb_serial_port *port, __u8 onoff);
@@ -278,7 +292,8 @@ static int firm_report_tx_done(struct usb_serial_port *port);
  - device renumerated itself and comes up as new device id with all
    firmware download completed.
 */
-static int whiteheat_firmware_download (struct usb_serial *serial, const struct usb_device_id *id)
+static int whiteheat_firmware_download(struct usb_serial *serial,
+                                       const struct usb_device_id *id)
 {
        int response, ret = -ENOENT;
        const struct firmware *loader_fw = NULL, *firmware_fw = NULL;
@@ -313,7 +328,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct
                record = ihex_next_binrec(record);
        }
 
-       response = ezusb_set_reset (serial, 0);
+       response = ezusb_set_reset(serial, 0);
 
        record = (const struct ihex_binrec *)firmware_fw->data;
        while (record && be32_to_cpu(record->addr) < 0x1b40)
@@ -330,8 +345,8 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct
                }
                ++record;
        }
-       
-       response = ezusb_set_reset (serial, 1);
+
+       response = ezusb_set_reset(serial, 1);
 
        record = (const struct ihex_binrec *)firmware_fw->data;
        while (record && be32_to_cpu(record->addr) < 0x1b40) {
@@ -355,7 +370,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct
 }
 
 
-static int whiteheat_firmware_attach (struct usb_serial *serial)
+static int whiteheat_firmware_attach(struct usb_serial *serial)
 {
        /* We want this device to fail to have a driver assigned to it */
        return 1;
@@ -365,7 +380,7 @@ static int whiteheat_firmware_attach (struct usb_serial *serial)
 /*****************************************************************************
  * Connect Tech's White Heat serial driver functions
  *****************************************************************************/
-static int whiteheat_attach (struct usb_serial *serial)
+static int whiteheat_attach(struct usb_serial *serial)
 {
        struct usb_serial_port *command_port;
        struct whiteheat_command_private *command_info;
@@ -386,43 +401,52 @@ static int whiteheat_attach (struct usb_serial *serial)
 
        command_port = serial->port[COMMAND_PORT];
 
-       pipe = usb_sndbulkpipe (serial->dev, command_port->bulk_out_endpointAddress);
+       pipe = usb_sndbulkpipe(serial->dev,
+                       command_port->bulk_out_endpointAddress);
        command = kmalloc(2, GFP_KERNEL);
        if (!command)
                goto no_command_buffer;
        command[0] = WHITEHEAT_GET_HW_INFO;
        command[1] = 0;
-       
+
        result = kmalloc(sizeof(*hw_info) + 1, GFP_KERNEL);
        if (!result)
                goto no_result_buffer;
        /*
         * When the module is reloaded the firmware is still there and
         * the endpoints are still in the usb core unchanged. This is the
-         * unlinking bug in disguise. Same for the call below.
-         */
+        * unlinking bug in disguise. Same for the call below.
+        */
        usb_clear_halt(serial->dev, pipe);
-       ret = usb_bulk_msg (serial->dev, pipe, command, 2, &alen, COMMAND_TIMEOUT_MS);
+       ret = usb_bulk_msg(serial->dev, pipe, command, 2,
+                                               &alen, COMMAND_TIMEOUT_MS);
        if (ret) {
-               err("%s: Couldn't send command [%d]", serial->type->description, ret);
+               err("%s: Couldn't send command [%d]",
+                               serial->type->description, ret);
                goto no_firmware;
        } else if (alen != 2) {
-               err("%s: Send command incomplete [%d]", serial->type->description, alen);
+               err("%s: Send command incomplete [%d]",
+                               serial->type->description, alen);
                goto no_firmware;
        }
 
-       pipe = usb_rcvbulkpipe (serial->dev, command_port->bulk_in_endpointAddress);
+       pipe = usb_rcvbulkpipe(serial->dev,
+                               command_port->bulk_in_endpointAddress);
        /* See the comment on the usb_clear_halt() above */
        usb_clear_halt(serial->dev, pipe);
-       ret = usb_bulk_msg (serial->dev, pipe, result, sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS);
+       ret = usb_bulk_msg(serial->dev, pipe, result,
+                       sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS);
        if (ret) {
-               err("%s: Couldn't get results [%d]", serial->type->description, ret);
+               err("%s: Couldn't get results [%d]",
+                               serial->type->description, ret);
                goto no_firmware;
        } else if (alen != sizeof(*hw_info) + 1) {
-               err("%s: Get results incomplete [%d]", serial->type->description, alen);
+               err("%s: Get results incomplete [%d]",
+                               serial->type->description, alen);
                goto no_firmware;
        } else if (result[0] != command[0]) {
-               err("%s: Command failed [%d]", serial->type->description, result[0]);
+               err("%s: Command failed [%d]",
+                               serial->type->description, result[0]);
                goto no_firmware;
        }
 
@@ -436,7 +460,8 @@ static int whiteheat_attach (struct usb_serial *serial)
 
                info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL);
                if (info == NULL) {
-                       err("%s: Out of memory for port structures\n", serial->type->description);
+                       err("%s: Out of memory for port structures\n",
+                                       serial->type->description);
                        goto no_private;
                }
 
@@ -506,9 +531,11 @@ static int whiteheat_attach (struct usb_serial *serial)
                usb_set_serial_port_data(port, info);
        }
 
-       command_info = kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL);
+       command_info = kmalloc(sizeof(struct whiteheat_command_private),
+                                                               GFP_KERNEL);
        if (command_info == NULL) {
-               err("%s: Out of memory for port structures\n", serial->type->description);
+               err("%s: Out of memory for port structures\n",
+                                       serial->type->description);
                goto no_command_private;
        }
 
@@ -525,9 +552,12 @@ static int whiteheat_attach (struct usb_serial *serial)
 
 no_firmware:
        /* Firmware likely not running */
-       err("%s: Unable to retrieve firmware version, try replugging\n", serial->type->description);
-       err("%s: If the firmware is not running (status led not blinking)\n", serial->type->description);
-       err("%s: please contact support@connecttech.com\n", serial->type->description);
+       err("%s: Unable to retrieve firmware version, try replugging\n",
+                                       serial->type->description);
+       err("%s: If the firmware is not running (status led not blinking)\n",
+                                       serial->type->description);
+       err("%s: please contact support@connecttech.com\n",
+                                       serial->type->description);
        kfree(result);
        return -ENODEV;
 
@@ -570,7 +600,7 @@ no_command_buffer:
 }
 
 
-static void whiteheat_shutdown (struct usb_serial *serial)
+static void whiteheat_shutdown(struct usb_serial *serial)
 {
        struct usb_serial_port *command_port;
        struct usb_serial_port *port;
@@ -585,7 +615,7 @@ static void whiteheat_shutdown (struct usb_serial *serial)
 
        /* free up our private data for our command port */
        command_port = serial->port[COMMAND_PORT];
-       kfree (usb_get_serial_port_data(command_port));
+       kfree(usb_get_serial_port_data(command_port));
 
        for (i = 0; i < serial->num_ports; i++) {
                port = serial->port[i];
@@ -612,11 +642,10 @@ static void whiteheat_shutdown (struct usb_serial *serial)
        return;
 }
 
-
-static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
+static int whiteheat_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        int             retval = 0;
-       struct ktermios old_term;
 
        dbg("%s - port %d", __func__, port->number);
 
@@ -624,7 +653,8 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
        if (retval)
                goto exit;
 
-       port->tty->low_latency = 1;
+       if (tty)
+               tty->low_latency = 1;
 
        /* send an open port command */
        retval = firm_open(port);
@@ -640,9 +670,8 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
                goto exit;
        }
 
-       old_term.c_cflag = ~port->tty->termios->c_cflag;
-       old_term.c_iflag = ~port->tty->termios->c_iflag;
-       whiteheat_set_termios(port, &old_term);
+       if (tty)
+               firm_setup_port(tty);
 
        /* Work around HCD bugs */
        usb_clear_halt(port->serial->dev, port->read_urb->pipe);
@@ -651,7 +680,8 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
        /* Start reading from the device */
        retval = start_port_read(port);
        if (retval) {
-               err("%s - failed submitting read urb, error %d", __func__, retval);
+               err("%s - failed submitting read urb, error %d",
+                               __func__, retval);
                firm_close(port);
                stop_command_port(port->serial);
                goto exit;
@@ -663,7 +693,8 @@ exit:
 }
 
 
-static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
+static void whiteheat_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct whiteheat_private *info = usb_get_serial_port_data(port);
        struct whiteheat_urb_wrap *wrap;
@@ -681,7 +712,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
        }
        mutex_unlock(&port->serial->disc_mutex);
 
-       port->tty->closing = 1;
+       tty->closing = 1;
 
 /*
  * Not currently in use; tty_wait_until_sent() calls
@@ -689,12 +720,12 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
  * acquisition. This should be fixed at some point. Greg's been
  * notified.
        if ((filp->f_flags & (O_NDELAY | O_NONBLOCK)) == 0) {
-               tty_wait_until_sent(port->tty, CLOSING_DELAY);
+               tty_wait_until_sent(tty, CLOSING_DELAY);
        }
 */
 
-       tty_driver_flush_buffer(port->tty);
-       tty_ldisc_flush(port->tty);
+       tty_driver_flush_buffer(tty);
+       tty_ldisc_flush(tty);
 
        firm_report_tx_done(port);
 
@@ -728,11 +759,12 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
 
        stop_command_port(port->serial);
 
-       port->tty->closing = 0;
+       tty->closing = 0;
 }
 
 
-static int whiteheat_write(struct usb_serial_port *port, const unsigned char *buf, int count)
+static int whiteheat_write(struct tty_struct *tty,
+       struct usb_serial_port *port, const unsigned char *buf, int count)
 {
        struct usb_serial *serial = port->serial;
        struct whiteheat_private *info = usb_get_serial_port_data(port);
@@ -763,16 +795,19 @@ static int whiteheat_write(struct usb_serial_port *port, const unsigned char *bu
 
                wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
                urb = wrap->urb;
-               bytes = (count > port->bulk_out_size) ? port->bulk_out_size : count;
-               memcpy (urb->transfer_buffer, buf + sent, bytes);
+               bytes = (count > port->bulk_out_size) ?
+                                       port->bulk_out_size : count;
+               memcpy(urb->transfer_buffer, buf + sent, bytes);
 
-               usb_serial_debug_data(debug, &port->dev, __func__, bytes, urb->transfer_buffer);
+               usb_serial_debug_data(debug, &port->dev,
+                               __func__, bytes, urb->transfer_buffer);
 
                urb->dev = serial->dev;
                urb->transfer_buffer_length = bytes;
                result = usb_submit_urb(urb, GFP_ATOMIC);
                if (result) {
-                       err("%s - failed submitting write urb, error %d", __func__, result);
+                       err("%s - failed submitting write urb, error %d",
+                                                       __func__, result);
                        sent = result;
                        spin_lock_irqsave(&info->lock, flags);
                        list_add(tmp, &info->tx_urbs_free);
@@ -790,16 +825,16 @@ static int whiteheat_write(struct usb_serial_port *port, const unsigned char *bu
        return sent;
 }
 
-
-static int whiteheat_write_room(struct usb_serial_port *port)
+static int whiteheat_write_room(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct whiteheat_private *info = usb_get_serial_port_data(port);
        struct list_head *tmp;
        int room = 0;
        unsigned long flags;
 
        dbg("%s - port %d", __func__, port->number);
-       
+
        spin_lock_irqsave(&info->lock, flags);
        list_for_each(tmp, &info->tx_urbs_free)
                room++;
@@ -810,9 +845,9 @@ static int whiteheat_write_room(struct usb_serial_port *port)
        return (room);
 }
 
-
-static int whiteheat_tiocmget (struct usb_serial_port *port, struct file *file)
+static int whiteheat_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct whiteheat_private *info = usb_get_serial_port_data(port);
        unsigned int modem_signals = 0;
 
@@ -827,10 +862,10 @@ static int whiteheat_tiocmget (struct usb_serial_port *port, struct file *file)
        return modem_signals;
 }
 
-
-static int whiteheat_tiocmset (struct usb_serial_port *port, struct file *file,
+static int whiteheat_tiocmset(struct tty_struct *tty, struct file *file,
                               unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct whiteheat_private *info = usb_get_serial_port_data(port);
 
        dbg("%s - port %d", __func__, port->number);
@@ -851,65 +886,55 @@ static int whiteheat_tiocmset (struct usb_serial_port *port, struct file *file,
 }
 
 
-static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+static int whiteheat_ioctl(struct tty_struct *tty, struct file *file,
+                                       unsigned int cmd, unsigned long arg)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct serial_struct serstruct;
        void __user *user_arg = (void __user *)arg;
 
        dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
 
        switch (cmd) {
-               case TIOCGSERIAL:
-                       memset(&serstruct, 0, sizeof(serstruct));
-                       serstruct.type = PORT_16654;
-                       serstruct.line = port->serial->minor;
-                       serstruct.port = port->number;
-                       serstruct.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
-                       serstruct.xmit_fifo_size = port->bulk_out_size;
-                       serstruct.custom_divisor = 0;
-                       serstruct.baud_base = 460800;
-                       serstruct.close_delay = CLOSING_DELAY;
-                       serstruct.closing_wait = CLOSING_DELAY;
-
-                       if (copy_to_user(user_arg, &serstruct, sizeof(serstruct)))
-                               return -EFAULT;
-
-                       break;
-
-               case TIOCSSERIAL:
-                       if (copy_from_user(&serstruct, user_arg, sizeof(serstruct)))
-                               return -EFAULT;
-
-                       /*
-                        * For now this is ignored. dip sets the ASYNC_[V]HI flags
-                        * but this isn't used by us at all. Maybe someone somewhere
-                        * will need the custom_divisor setting.
-                        */
-
-                       break;
-
-               default:
-                       break;
+       case TIOCGSERIAL:
+               memset(&serstruct, 0, sizeof(serstruct));
+               serstruct.type = PORT_16654;
+               serstruct.line = port->serial->minor;
+               serstruct.port = port->number;
+               serstruct.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
+               serstruct.xmit_fifo_size = port->bulk_out_size;
+               serstruct.custom_divisor = 0;
+               serstruct.baud_base = 460800;
+               serstruct.close_delay = CLOSING_DELAY;
+               serstruct.closing_wait = CLOSING_DELAY;
+
+               if (copy_to_user(user_arg, &serstruct, sizeof(serstruct)))
+                       return -EFAULT;
+               break;
+       default:
+               break;
        }
 
        return -ENOIOCTLCMD;
 }
 
 
-static void whiteheat_set_termios(struct usb_serial_port *port, struct ktermios *old_termios)
+static void whiteheat_set_termios(struct tty_struct *tty,
+       struct usb_serial_port *port, struct ktermios *old_termios)
 {
-       dbg("%s -port %d", __func__, port->number);
-       firm_setup_port(port);
+       firm_setup_port(tty);
 }
 
-
-static void whiteheat_break_ctl(struct usb_serial_port *port, int break_state) {
+static void whiteheat_break_ctl(struct tty_struct *tty, int break_state)
+{
+       struct usb_serial_port *port = tty->driver_data;
        firm_set_break(port, break_state);
 }
 
 
-static int whiteheat_chars_in_buffer(struct usb_serial_port *port)
+static int whiteheat_chars_in_buffer(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct whiteheat_private *info = usb_get_serial_port_data(port);
        struct list_head *tmp;
        struct whiteheat_urb_wrap *wrap;
@@ -925,13 +950,14 @@ static int whiteheat_chars_in_buffer(struct usb_serial_port *port)
        }
        spin_unlock_irqrestore(&info->lock, flags);
 
-       dbg ("%s - returns %d", __func__, chars);
+       dbg("%s - returns %d", __func__, chars);
        return chars;
 }
 
 
-static void whiteheat_throttle (struct usb_serial_port *port)
+static void whiteheat_throttle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct whiteheat_private *info = usb_get_serial_port_data(port);
        unsigned long flags;
 
@@ -945,8 +971,9 @@ static void whiteheat_throttle (struct usb_serial_port *port)
 }
 
 
-static void whiteheat_unthrottle (struct usb_serial_port *port)
+static void whiteheat_unthrottle(struct tty_struct *tty)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct whiteheat_private *info = usb_get_serial_port_data(port);
        int actually_throttled;
        unsigned long flags;
@@ -993,7 +1020,7 @@ static void command_port_read_callback(struct urb *urb)
 
        command_info = usb_get_serial_port_data(command_port);
        if (!command_info) {
-               dbg ("%s - command_info is NULL, exiting.", __func__);
+               dbg("%s - command_info is NULL, exiting.", __func__);
                return;
        }
        if (status) {
@@ -1004,7 +1031,8 @@ static void command_port_read_callback(struct urb *urb)
                return;
        }
 
-       usb_serial_debug_data(debug, &command_port->dev, __func__, urb->actual_length, data);
+       usb_serial_debug_data(debug, &command_port->dev,
+                               __func__, urb->actual_length, data);
 
        if (data[0] == WHITEHEAT_CMD_COMPLETE) {
                command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
@@ -1013,21 +1041,23 @@ static void command_port_read_callback(struct urb *urb)
                command_info->command_finished = WHITEHEAT_CMD_FAILURE;
                wake_up(&command_info->wait_command);
        } else if (data[0] == WHITEHEAT_EVENT) {
-               /* These are unsolicited reports from the firmware, hence no waiting command to wakeup */
+               /* These are unsolicited reports from the firmware, hence no
+                  waiting command to wakeup */
                dbg("%s - event received", __func__);
        } else if (data[0] == WHITEHEAT_GET_DTR_RTS) {
-               memcpy(command_info->result_buffer, &data[1], urb->actual_length - 1);
+               memcpy(command_info->result_buffer, &data[1],
+                                               urb->actual_length - 1);
                command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
                wake_up(&command_info->wait_command);
-       } else {
+       } else
                dbg("%s - bad reply from firmware", __func__);
-       }
-       
+
        /* Continue trying to always read */
        command_port->read_urb->dev = command_port->serial->dev;
        result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC);
        if (result)
-               dbg("%s - failed resubmitting read urb, error %d", __func__, result);
+               dbg("%s - failed resubmitting read urb, error %d",
+                       __func__, result);
 }
 
 
@@ -1060,7 +1090,8 @@ static void whiteheat_read_callback(struct urb *urb)
                return;
        }
 
-       usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data);
+       usb_serial_debug_data(debug, &port->dev,
+                               __func__, urb->actual_length, data);
 
        spin_lock(&info->lock);
        list_add_tail(&wrap->list, &info->rx_urb_q);
@@ -1107,7 +1138,8 @@ static void whiteheat_write_callback(struct urb *urb)
 /*****************************************************************************
  * Connect Tech's White Heat firmware interface
  *****************************************************************************/
-static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize)
+static int firm_send_command(struct usb_serial_port *port, __u8 command,
+                                               __u8 *data, __u8 datasize)
 {
        struct usb_serial_port *command_port;
        struct whiteheat_command_private *command_info;
@@ -1122,13 +1154,13 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *d
        command_info = usb_get_serial_port_data(command_port);
        mutex_lock(&command_info->mutex);
        command_info->command_finished = false;
-       
+
        transfer_buffer = (__u8 *)command_port->write_urb->transfer_buffer;
        transfer_buffer[0] = command;
-       memcpy (&transfer_buffer[1], data, datasize);
+       memcpy(&transfer_buffer[1], data, datasize);
        command_port->write_urb->transfer_buffer_length = datasize + 1;
        command_port->write_urb->dev = port->serial->dev;
-       retval = usb_submit_urb (command_port->write_urb, GFP_NOIO);
+       retval = usb_submit_urb(command_port->write_urb, GFP_NOIO);
        if (retval) {
                dbg("%s - submit urb failed", __func__);
                goto exit;
@@ -1155,51 +1187,57 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *d
        if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) {
                dbg("%s - command completed.", __func__);
                switch (command) {
-                       case WHITEHEAT_GET_DTR_RTS:
-                               info = usb_get_serial_port_data(port);
-                               memcpy(&info->mcr, command_info->result_buffer, sizeof(struct whiteheat_dr_info));
+               case WHITEHEAT_GET_DTR_RTS:
+                       info = usb_get_serial_port_data(port);
+                       memcpy(&info->mcr, command_info->result_buffer,
+                                       sizeof(struct whiteheat_dr_info));
                                break;
                }
        }
-
 exit:
        mutex_unlock(&command_info->mutex);
        return retval;
 }
 
 
-static int firm_open(struct usb_serial_port *port) {
+static int firm_open(struct usb_serial_port *port)
+{
        struct whiteheat_simple open_command;
 
        open_command.port = port->number - port->serial->minor + 1;
-       return firm_send_command(port, WHITEHEAT_OPEN, (__u8 *)&open_command, sizeof(open_command));
+       return firm_send_command(port, WHITEHEAT_OPEN,
+               (__u8 *)&open_command, sizeof(open_command));
 }
 
 
-static int firm_close(struct usb_serial_port *port) {
+static int firm_close(struct usb_serial_port *port)
+{
        struct whiteheat_simple close_command;
 
        close_command.port = port->number - port->serial->minor + 1;
-       return firm_send_command(port, WHITEHEAT_CLOSE, (__u8 *)&close_command, sizeof(close_command));
+       return firm_send_command(port, WHITEHEAT_CLOSE,
+                       (__u8 *)&close_command, sizeof(close_command));
 }
 
 
-static int firm_setup_port(struct usb_serial_port *port) {
+static int firm_setup_port(struct tty_struct *tty)
+{
+       struct usb_serial_port *port = tty->driver_data;
        struct whiteheat_port_settings port_settings;
-       unsigned int cflag = port->tty->termios->c_cflag;
+       unsigned int cflag = tty->termios->c_cflag;
 
        port_settings.port = port->number + 1;
 
        /* get the byte size */
        switch (cflag & CSIZE) {
-               case CS5:       port_settings.bits = 5;   break;
-               case CS6:       port_settings.bits = 6;   break;
-               case CS7:       port_settings.bits = 7;   break;
-               default:
-               case CS8:       port_settings.bits = 8;   break;
+       case CS5:       port_settings.bits = 5;   break;
+       case CS6:       port_settings.bits = 6;   break;
+       case CS7:       port_settings.bits = 7;   break;
+       default:
+       case CS8:       port_settings.bits = 8;   break;
        }
        dbg("%s - data bits = %d", __func__, port_settings.bits);
-       
+
        /* determine the parity */
        if (cflag & PARENB)
                if (cflag & CMSPAR)
@@ -1225,7 +1263,8 @@ static int firm_setup_port(struct usb_serial_port *port) {
 
        /* figure out the flow control settings */
        if (cflag & CRTSCTS)
-               port_settings.hflow = (WHITEHEAT_HFLOW_CTS | WHITEHEAT_HFLOW_RTS);
+               port_settings.hflow = (WHITEHEAT_HFLOW_CTS |
+                                               WHITEHEAT_HFLOW_RTS);
        else
                port_settings.hflow = WHITEHEAT_HFLOW_NONE;
        dbg("%s - hardware flow control = %s %s %s %s", __func__,
@@ -1233,81 +1272,95 @@ static int firm_setup_port(struct usb_serial_port *port) {
            (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "",
            (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "",
            (port_settings.hflow & WHITEHEAT_HFLOW_DTR) ? "DTR" : "");
-       
+
        /* determine software flow control */
-       if (I_IXOFF(port->tty))
+       if (I_IXOFF(tty))
                port_settings.sflow = WHITEHEAT_SFLOW_RXTX;
        else
                port_settings.sflow = WHITEHEAT_SFLOW_NONE;
        dbg("%s - software flow control = %c", __func__, port_settings.sflow);
-       
-       port_settings.xon = START_CHAR(port->tty);
-       port_settings.xoff = STOP_CHAR(port->tty);
-       dbg("%s - XON = %2x, XOFF = %2x", __func__, port_settings.xon, port_settings.xoff);
+
+       port_settings.xon = START_CHAR(tty);
+       port_settings.xoff = STOP_CHAR(tty);
+       dbg("%s - XON = %2x, XOFF = %2x",
+                       __func__, port_settings.xon, port_settings.xoff);
 
        /* get the baud rate wanted */
-       port_settings.baud = tty_get_baud_rate(port->tty);
+       port_settings.baud = tty_get_baud_rate(tty);
        dbg("%s - baud rate = %d", __func__, port_settings.baud);
 
        /* fixme: should set validated settings */
-       tty_encode_baud_rate(port->tty, port_settings.baud, port_settings.baud);
+       tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud);
        /* handle any settings that aren't specified in the tty structure */
        port_settings.lloop = 0;
-       
+
        /* now send the message to the device */
-       return firm_send_command(port, WHITEHEAT_SETUP_PORT, (__u8 *)&port_settings, sizeof(port_settings));
+       return firm_send_command(port, WHITEHEAT_SETUP_PORT,
+                       (__u8 *)&port_settings, sizeof(port_settings));
 }
 
 
-static int firm_set_rts(struct usb_serial_port *port, __u8 onoff) {
+static int firm_set_rts(struct usb_serial_port *port, __u8 onoff)
+{
        struct whiteheat_set_rdb rts_command;
 
        rts_command.port = port->number - port->serial->minor + 1;
        rts_command.state = onoff;
-       return firm_send_command(port, WHITEHEAT_SET_RTS, (__u8 *)&rts_command, sizeof(rts_command));
+       return firm_send_command(port, WHITEHEAT_SET_RTS,
+                       (__u8 *)&rts_command, sizeof(rts_command));
 }
 
 
-static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff) {
+static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff)
+{
        struct whiteheat_set_rdb dtr_command;
 
        dtr_command.port = port->number - port->serial->minor + 1;
        dtr_command.state = onoff;
-       return firm_send_command(port, WHITEHEAT_SET_RTS, (__u8 *)&dtr_command, sizeof(dtr_command));
+       return firm_send_command(port, WHITEHEAT_SET_DTR,
+                       (__u8 *)&dtr_command, sizeof(dtr_command));
 }
 
 
-static int firm_set_break(struct usb_serial_port *port, __u8 onoff) {
+static int firm_set_break(struct usb_serial_port *port, __u8 onoff)
+{
        struct whiteheat_set_rdb break_command;
 
        break_command.port = port->number - port->serial->minor + 1;
        break_command.state = onoff;
-       return firm_send_command(port, WHITEHEAT_SET_RTS, (__u8 *)&break_command, sizeof(break_command));
+       return firm_send_command(port, WHITEHEAT_SET_BREAK,
+                       (__u8 *)&break_command, sizeof(break_command));
 }
 
 
-static int firm_purge(struct usb_serial_port *port, __u8 rxtx) {
+static int firm_purge(struct usb_serial_port *port, __u8 rxtx)
+{
        struct whiteheat_purge purge_command;
 
        purge_command.port = port->number - port->serial->minor + 1;
        purge_command.what = rxtx;
-       return firm_send_command(port, WHITEHEAT_PURGE, (__u8 *)&purge_command, sizeof(purge_command));
+       return firm_send_command(port, WHITEHEAT_PURGE,
+                       (__u8 *)&purge_command, sizeof(purge_command));
 }
 
 
-static int firm_get_dtr_rts(struct usb_serial_port *port) {
+static int firm_get_dtr_rts(struct usb_serial_port *port)
+{
        struct whiteheat_simple get_dr_command;
 
        get_dr_command.port = port->number - port->serial->minor + 1;
-       return firm_send_command(port, WHITEHEAT_GET_DTR_RTS, (__u8 *)&get_dr_command, sizeof(get_dr_command));
+       return firm_send_command(port, WHITEHEAT_GET_DTR_RTS,
+                       (__u8 *)&get_dr_command, sizeof(get_dr_command));
 }
 
 
-static int firm_report_tx_done(struct usb_serial_port *port) {
+static int firm_report_tx_done(struct usb_serial_port *port)
+{
        struct whiteheat_simple close_command;
 
        close_command.port = port->number - port->serial->minor + 1;
-       return firm_send_command(port, WHITEHEAT_REPORT_TX_DONE, (__u8 *)&close_command, sizeof(close_command));
+       return firm_send_command(port, WHITEHEAT_REPORT_TX_DONE,
+                       (__u8 *)&close_command, sizeof(close_command));
 }
 
 
@@ -1319,7 +1372,7 @@ static int start_command_port(struct usb_serial *serial)
        struct usb_serial_port *command_port;
        struct whiteheat_command_private *command_info;
        int retval = 0;
-       
+
        command_port = serial->port[COMMAND_PORT];
        command_info = usb_get_serial_port_data(command_port);
        mutex_lock(&command_info->mutex);
@@ -1330,7 +1383,8 @@ static int start_command_port(struct usb_serial *serial)
                command_port->read_urb->dev = serial->dev;
                retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL);
                if (retval) {
-                       err("%s - failed submitting read urb, error %d", __func__, retval);
+                       err("%s - failed submitting read urb, error %d",
+                                                       __func__, retval);
                        goto exit;
                }
        }
@@ -1400,7 +1454,8 @@ static int start_port_read(struct usb_serial_port *port)
 }
 
 
-static struct whiteheat_urb_wrap *urb_to_wrap(struct urb* urb, struct list_head *head)
+static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb,
+                                               struct list_head *head)
 {
        struct whiteheat_urb_wrap *wrap;
        struct list_head *tmp;
@@ -1426,7 +1481,7 @@ static void rx_data_softint(struct work_struct *work)
        struct whiteheat_private *info =
                container_of(work, struct whiteheat_private, rx_work);
        struct usb_serial_port *port = info->port;
-       struct tty_struct *tty = port->tty;
+       struct tty_struct *tty = port->port.tty;
        struct whiteheat_urb_wrap *wrap;
        struct urb *urb;
        unsigned long flags;
@@ -1449,7 +1504,8 @@ static void rx_data_softint(struct work_struct *work)
                urb = wrap->urb;
 
                if (tty && urb->actual_length) {
-                       int len = tty_buffer_request_room(tty, urb->actual_length);
+                       int len = tty_buffer_request_room(tty,
+                                                       urb->actual_length);
                        /* This stuff can go away now I suspect */
                        if (unlikely(len < urb->actual_length)) {
                                spin_lock_irqsave(&info->lock, flags);
@@ -1466,7 +1522,8 @@ static void rx_data_softint(struct work_struct *work)
                urb->dev = port->serial->dev;
                result = usb_submit_urb(urb, GFP_ATOMIC);
                if (result) {
-                       err("%s - failed resubmitting read urb, error %d", __func__, result);
+                       err("%s - failed resubmitting read urb, error %d",
+                               __func__, result);
                        spin_lock_irqsave(&info->lock, flags);
                        list_add(tmp, &info->rx_urbs_free);
                        continue;
@@ -1485,7 +1542,7 @@ static void rx_data_softint(struct work_struct *work)
 /*****************************************************************************
  * Connect Tech's White Heat module functions
  *****************************************************************************/
-static int __init whiteheat_init (void)
+static int __init whiteheat_init(void)
 {
        int retval;
        retval = usb_serial_register(&whiteheat_fake_device);
@@ -1508,19 +1565,19 @@ failed_fake_register:
 }
 
 
-static void __exit whiteheat_exit (void)
+static void __exit whiteheat_exit(void)
 {
-       usb_deregister (&whiteheat_driver);
-       usb_serial_deregister (&whiteheat_fake_device);
-       usb_serial_deregister (&whiteheat_device);
+       usb_deregister(&whiteheat_driver);
+       usb_serial_deregister(&whiteheat_fake_device);
+       usb_serial_deregister(&whiteheat_device);
 }
 
 
 module_init(whiteheat_init);
 module_exit(whiteheat_exit);
 
-MODULE_AUTHOR( DRIVER_AUTHOR );
-MODULE_DESCRIPTION( DRIVER_DESC );
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 
 MODULE_FIRMWARE("whiteheat.fw");
index f160797..38065df 100644 (file)
@@ -2,7 +2,7 @@
  * USB ConnectTech WhiteHEAT driver
  *
  *      Copyright (C) 2002
- *          Connect Tech Inc.  
+ *          Connect Tech Inc.
  *
  *      Copyright (C) 1999, 2000
  *          Greg Kroah-Hartman (greg@kroah.com)
@@ -12,7 +12,8 @@
  *      the Free Software Foundation; either version 2 of the License, or
  *      (at your option) any later version.
  *
- * See Documentation/usb/usb-serial.txt for more information on using this driver
+ * See Documentation/usb/usb-serial.txt for more information on using this
+ * driver
  *
  */
 
 #define WHITEHEAT_DUMP                 7       /* dump memory */
 #define WHITEHEAT_STATUS               8       /* get status */
 #define WHITEHEAT_PURGE                        9       /* clear the UART fifos */
-#define WHITEHEAT_GET_DTR_RTS          10      /* get the state of DTR and RTS for a port */
-#define WHITEHEAT_GET_HW_INFO          11      /* get EEPROM info and hardware ID */
+#define WHITEHEAT_GET_DTR_RTS          10      /* get the state of DTR and RTS
+                                                       for a port */
+#define WHITEHEAT_GET_HW_INFO          11      /* get EEPROM info and
+                                                       hardware ID */
 #define WHITEHEAT_REPORT_TX_DONE       12      /* get the next TX done */
 #define WHITEHEAT_EVENT                        13      /* unsolicited status events */
-#define WHITEHEAT_ECHO                 14      /* send data to the indicated IN endpoint */
-#define WHITEHEAT_DO_TEST              15      /* perform the specified test */
-#define WHITEHEAT_CMD_COMPLETE         16      /* reply for certain commands */
+#define WHITEHEAT_ECHO                 14      /* send data to the indicated
+                                                  IN endpoint */
+#define WHITEHEAT_DO_TEST              15      /* perform specified test */
+#define WHITEHEAT_CMD_COMPLETE         16      /* reply for some commands */
 #define WHITEHEAT_CMD_FAILURE          17      /* reply for failed commands */
 
 
@@ -67,20 +71,28 @@ struct whiteheat_simple {
 #define WHITEHEAT_PAR_MARK     '1'     /* mark (force 1) parity */
 
 #define WHITEHEAT_SFLOW_NONE   'n'     /* no software flow control */
-#define WHITEHEAT_SFLOW_RX     'r'     /* XOFF/ON is sent when RX fills/empties */
-#define WHITEHEAT_SFLOW_TX     't'     /* when received XOFF/ON will stop/start TX */
+#define WHITEHEAT_SFLOW_RX     'r'     /* XOFF/ON is sent when RX
+                                          fills/empties */
+#define WHITEHEAT_SFLOW_TX     't'     /* when received XOFF/ON will
+                                          stop/start TX */
 #define WHITEHEAT_SFLOW_RXTX   'b'     /* both SFLOW_RX and SFLOW_TX */
 
 #define WHITEHEAT_HFLOW_NONE           0x00    /* no hardware flow control */
-#define WHITEHEAT_HFLOW_RTS_TOGGLE     0x01    /* RTS is on during transmit, off otherwise */
-#define WHITEHEAT_HFLOW_DTR            0x02    /* DTR is off/on when RX fills/empties */
-#define WHITEHEAT_HFLOW_CTS            0x08    /* when received CTS off/on will stop/start TX */
-#define WHITEHEAT_HFLOW_DSR            0x10    /* when received DSR off/on will stop/start TX */
-#define WHITEHEAT_HFLOW_RTS            0x80    /* RTS is off/on when RX fills/empties */
+#define WHITEHEAT_HFLOW_RTS_TOGGLE     0x01    /* RTS is on during transmit,
+                                                  off otherwise */
+#define WHITEHEAT_HFLOW_DTR            0x02    /* DTR is off/on when RX
+                                                  fills/empties */
+#define WHITEHEAT_HFLOW_CTS            0x08    /* when received CTS off/on
+                                                  will stop/start TX */
+#define WHITEHEAT_HFLOW_DSR            0x10    /* when received DSR off/on
+                                                  will stop/start TX */
+#define WHITEHEAT_HFLOW_RTS            0x80    /* RTS is off/on when RX
+                                                  fills/empties */
 
 struct whiteheat_port_settings {
        __u8    port;           /* port number (1 to N) */
-       __u32   baud;           /* any value 7 - 460800, firmware calculates best fit; arrives little endian */
+       __u32   baud;           /* any value 7 - 460800, firmware calculates
+                                  best fit; arrives little endian */
        __u8    bits;           /* 5, 6, 7, or 8 */
        __u8    stop;           /* 1 or 2, default 1 (2 = 1.5 if bits = 5) */
        __u8    parity;         /* see WHITEHEAT_PAR_* above */
@@ -167,12 +179,14 @@ struct whiteheat_echo {
  */
 #define WHITEHEAT_TEST_UART_RW         0x01  /* read/write uart registers */
 #define WHITEHEAT_TEST_UART_INTR       0x02  /* uart interrupt */
-#define WHITEHEAT_TEST_SETUP_CONT      0x03  /* setup for PORT_CONT/PORT_DISCONT */
+#define WHITEHEAT_TEST_SETUP_CONT      0x03  /* setup for
+                                               PORT_CONT/PORT_DISCONT */
 #define WHITEHEAT_TEST_PORT_CONT       0x04  /* port connect */
 #define WHITEHEAT_TEST_PORT_DISCONT    0x05  /* port disconnect */
 #define WHITEHEAT_TEST_UART_CLK_START  0x06  /* uart clock test start */
 #define WHITEHEAT_TEST_UART_CLK_STOP   0x07  /* uart clock test stop */
-#define WHITEHEAT_TEST_MODEM_FT                0x08  /* modem signals, requires a loopback cable/connector */
+#define WHITEHEAT_TEST_MODEM_FT                0x08  /* modem signals, requires a
+                                               loopback cable/connector */
 #define WHITEHEAT_TEST_ERASE_EEPROM    0x09  /* erase eeprom */
 #define WHITEHEAT_TEST_READ_EEPROM     0x0a  /* read eeprom */
 #define WHITEHEAT_TEST_PROGRAM_EEPROM  0x0b  /* program eeprom */
@@ -198,19 +212,27 @@ struct whiteheat_test {
 #define WHITEHEAT_EVENT_CONNECT                0x08    /* connect field is valid */
 
 #define WHITEHEAT_FLOW_NONE            0x00    /* no flow control active */
-#define WHITEHEAT_FLOW_HARD_OUT                0x01    /* TX is stopped by CTS (waiting for CTS to go on) */
-#define WHITEHEAT_FLOW_HARD_IN         0x02    /* remote TX is stopped by RTS */
-#define WHITEHEAT_FLOW_SOFT_OUT                0x04    /* TX is stopped by XOFF received (waiting for XON) */
-#define WHITEHEAT_FLOW_SOFT_IN         0x08    /* remote TX is stopped by XOFF transmitted */
+#define WHITEHEAT_FLOW_HARD_OUT                0x01    /* TX is stopped by CTS
+                                                 (waiting for CTS to go on) */
+#define WHITEHEAT_FLOW_HARD_IN         0x02    /* remote TX is stopped
+                                                 by RTS */
+#define WHITEHEAT_FLOW_SOFT_OUT                0x04    /* TX is stopped by XOFF
+                                                 received (waiting for XON) */
+#define WHITEHEAT_FLOW_SOFT_IN         0x08    /* remote TX is stopped by XOFF
+                                                 transmitted */
 #define WHITEHEAT_FLOW_TX_DONE         0x80    /* TX has completed */
 
 struct whiteheat_status_info {
        __u8    port;           /* port number (1 to N) */
-       __u8    event;          /* indicates what the current event is, see WHITEHEAT_EVENT_* above */
-       __u8    modem;          /* modem signal status (copy of uart's MSR register) */
+       __u8    event;          /* indicates what the current event is,
+                                       see WHITEHEAT_EVENT_* above */
+       __u8    modem;          /* modem signal status (copy of uart's
+                                       MSR register) */
        __u8    error;          /* line status (copy of uart's LSR register) */
-       __u8    flow;           /* flow control state, see WHITEHEAT_FLOW_* above */
-       __u8    connect;        /* 0 means not connected, non-zero means connected */
+       __u8    flow;           /* flow control state, see WHITEHEAT_FLOW_*
+                                       above */
+       __u8    connect;        /* 0 means not connected, non-zero means
+                                       connected */
 };
 
 
@@ -256,7 +278,8 @@ struct whiteheat_hw_info {
 struct whiteheat_event_info {
        __u8    port;           /* port number (1 to N) */
        __u8    event;          /* see whiteheat_status_info.event */
-       __u8    info;           /* see whiteheat_status_info.modem, .error, .flow, .connect */
+       __u8    info;           /* see whiteheat_status_info.modem, .error,
+                                       .flow, .connect */
 };
 
 
@@ -269,7 +292,8 @@ struct whiteheat_event_info {
 
 struct whiteheat_test_info {
        __u8    port;           /* port number (1 to N) */
-       __u8    test;           /* indicates which test this is a response for, see WHITEHEAT_DO_TEST above */
+       __u8    test;           /* indicates which test this is a response for,
+                                  see WHITEHEAT_DO_TEST above */
        __u8    status;         /* see WHITEHEAT_TEST_* above */
        __u8    results[32];    /* test-dependent results */
 };
index 24ee96c..07b6add 100644 (file)
@@ -1872,7 +1872,7 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
        struct fb_info *info = pci_get_drvdata(pdev);
        struct aty128fb_par *par = info->par;
        struct fb_var_screeninfo var;
-       char video_card[DEVICE_NAME_SIZE];
+       char video_card[50];
        u8 chip_rev;
        u32 dac;
 
index c347e38..ccbfffd 100644 (file)
@@ -289,7 +289,7 @@ struct radeonfb_info {
        struct radeon_regs      state;
        struct radeon_regs      init_state;
 
-       char                    name[DEVICE_NAME_SIZE];
+       char                    name[50];
 
        unsigned long           mmio_base_phys;
        unsigned long           fb_base_phys;
index 97aff8d..4be3b46 100644 (file)
@@ -3586,7 +3586,8 @@ static int __init fb_console_init(void)
 
        acquire_console_sem();
        fb_register_client(&fbcon_event_notifier);
-       fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), "fbcon");
+       fbcon_device = device_create_drvdata(fb_class, NULL, MKDEV(0, 0),
+                                            NULL, "fbcon");
 
        if (IS_ERR(fbcon_device)) {
                printk(KERN_WARNING "Unable to create device "
index 33ebdb1..1cd5071 100644 (file)
@@ -1439,8 +1439,9 @@ register_framebuffer(struct fb_info *fb_info)
                        break;
        fb_info->node = i;
 
-       fb_info->dev = device_create(fb_class, fb_info->device,
-                                    MKDEV(FB_MAJOR, i), "fb%d", i);
+       fb_info->dev = device_create_drvdata(fb_class, fb_info->device,
+                                            MKDEV(FB_MAJOR, i), NULL,
+                                            "fb%d", i);
        if (IS_ERR(fb_info->dev)) {
                /* Not fatal */
                printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
index d7b3dcc..e1d9eeb 100644 (file)
@@ -47,6 +47,7 @@ enum {
        cmap_M3B,               /* ATI Rage Mobility M3 Head B */
        cmap_radeon,            /* ATI Radeon */
        cmap_gxt2000,           /* IBM GXT2000 */
+       cmap_avivo,             /* ATI R5xx */
 };
 
 struct offb_par {
@@ -58,26 +59,36 @@ struct offb_par {
 
 struct offb_par default_par;
 
-    /*
-     *  Interface used by the world
-     */
-
-static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
-                         u_int transp, struct fb_info *info);
-static int offb_blank(int blank, struct fb_info *info);
-
 #ifdef CONFIG_PPC32
 extern boot_infos_t *boot_infos;
 #endif
 
-static struct fb_ops offb_ops = {
-       .owner          = THIS_MODULE,
-       .fb_setcolreg   = offb_setcolreg,
-       .fb_blank       = offb_blank,
-       .fb_fillrect    = cfb_fillrect,
-       .fb_copyarea    = cfb_copyarea,
-       .fb_imageblit   = cfb_imageblit,
-};
+/* Definitions used by the Avivo palette hack */
+#define AVIVO_DC_LUT_RW_SELECT                  0x6480
+#define AVIVO_DC_LUT_RW_MODE                    0x6484
+#define AVIVO_DC_LUT_RW_INDEX                   0x6488
+#define AVIVO_DC_LUT_SEQ_COLOR                  0x648c
+#define AVIVO_DC_LUT_PWL_DATA                   0x6490
+#define AVIVO_DC_LUT_30_COLOR                   0x6494
+#define AVIVO_DC_LUT_READ_PIPE_SELECT           0x6498
+#define AVIVO_DC_LUT_WRITE_EN_MASK              0x649c
+#define AVIVO_DC_LUT_AUTOFILL                   0x64a0
+
+#define AVIVO_DC_LUTA_CONTROL                   0x64c0
+#define AVIVO_DC_LUTA_BLACK_OFFSET_BLUE         0x64c4
+#define AVIVO_DC_LUTA_BLACK_OFFSET_GREEN        0x64c8
+#define AVIVO_DC_LUTA_BLACK_OFFSET_RED          0x64cc
+#define AVIVO_DC_LUTA_WHITE_OFFSET_BLUE         0x64d0
+#define AVIVO_DC_LUTA_WHITE_OFFSET_GREEN        0x64d4
+#define AVIVO_DC_LUTA_WHITE_OFFSET_RED          0x64d8
+
+#define AVIVO_DC_LUTB_CONTROL                   0x6cc0
+#define AVIVO_DC_LUTB_BLACK_OFFSET_BLUE         0x6cc4
+#define AVIVO_DC_LUTB_BLACK_OFFSET_GREEN        0x6cc8
+#define AVIVO_DC_LUTB_BLACK_OFFSET_RED          0x6ccc
+#define AVIVO_DC_LUTB_WHITE_OFFSET_BLUE         0x6cd0
+#define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN        0x6cd4
+#define AVIVO_DC_LUTB_WHITE_OFFSET_RED          0x6cd8
 
     /*
      *  Set a single color register. The values supplied are already
@@ -160,6 +171,17 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
                out_le32(((unsigned __iomem *) par->cmap_adr) + regno,
                         (red << 16 | green << 8 | blue));
                break;
+       case cmap_avivo:
+               /* Write to both LUTs for now */
+               writel(1, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT);
+               writeb(regno, par->cmap_adr + AVIVO_DC_LUT_RW_INDEX);
+               writel(((red) << 22) | ((green) << 12) | ((blue) << 2),
+                      par->cmap_adr + AVIVO_DC_LUT_30_COLOR);
+               writel(0, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT);
+               writeb(regno, par->cmap_adr + AVIVO_DC_LUT_RW_INDEX);
+               writel(((red) << 22) | ((green) << 12) | ((blue) << 2),
+                      par->cmap_adr + AVIVO_DC_LUT_30_COLOR);
+               break;
        }
 
        return 0;
@@ -216,12 +238,59 @@ static int offb_blank(int blank, struct fb_info *info)
                                out_le32(((unsigned __iomem *) par->cmap_adr) + i,
                                         0);
                                break;
+                       case cmap_avivo:
+                               writel(1, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT);
+                               writeb(i, par->cmap_adr + AVIVO_DC_LUT_RW_INDEX);
+                               writel(0, par->cmap_adr + AVIVO_DC_LUT_30_COLOR);
+                               writel(0, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT);
+                               writeb(i, par->cmap_adr + AVIVO_DC_LUT_RW_INDEX);
+                               writel(0, par->cmap_adr + AVIVO_DC_LUT_30_COLOR);
+                               break;
                        }
        } else
                fb_set_cmap(&info->cmap, info);
        return 0;
 }
 
+static int offb_set_par(struct fb_info *info)
+{
+       struct offb_par *par = (struct offb_par *) info->par;
+
+       /* On avivo, initialize palette control */
+       if (par->cmap_type == cmap_avivo) {
+               writel(0, par->cmap_adr + AVIVO_DC_LUTA_CONTROL);
+               writel(0, par->cmap_adr + AVIVO_DC_LUTA_BLACK_OFFSET_BLUE);
+               writel(0, par->cmap_adr + AVIVO_DC_LUTA_BLACK_OFFSET_GREEN);
+               writel(0, par->cmap_adr + AVIVO_DC_LUTA_BLACK_OFFSET_RED);
+               writel(0x0000ffff, par->cmap_adr + AVIVO_DC_LUTA_WHITE_OFFSET_BLUE);
+               writel(0x0000ffff, par->cmap_adr + AVIVO_DC_LUTA_WHITE_OFFSET_GREEN);
+               writel(0x0000ffff, par->cmap_adr + AVIVO_DC_LUTA_WHITE_OFFSET_RED);
+               writel(0, par->cmap_adr + AVIVO_DC_LUTB_CONTROL);
+               writel(0, par->cmap_adr + AVIVO_DC_LUTB_BLACK_OFFSET_BLUE);
+               writel(0, par->cmap_adr + AVIVO_DC_LUTB_BLACK_OFFSET_GREEN);
+               writel(0, par->cmap_adr + AVIVO_DC_LUTB_BLACK_OFFSET_RED);
+               writel(0x0000ffff, par->cmap_adr + AVIVO_DC_LUTB_WHITE_OFFSET_BLUE);
+               writel(0x0000ffff, par->cmap_adr + AVIVO_DC_LUTB_WHITE_OFFSET_GREEN);
+               writel(0x0000ffff, par->cmap_adr + AVIVO_DC_LUTB_WHITE_OFFSET_RED);
+               writel(1, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT);
+               writel(0, par->cmap_adr + AVIVO_DC_LUT_RW_MODE);
+               writel(0x0000003f, par->cmap_adr + AVIVO_DC_LUT_WRITE_EN_MASK);
+               writel(0, par->cmap_adr + AVIVO_DC_LUT_RW_SELECT);
+               writel(0, par->cmap_adr + AVIVO_DC_LUT_RW_MODE);
+               writel(0x0000003f, par->cmap_adr + AVIVO_DC_LUT_WRITE_EN_MASK);
+       }
+       return 0;
+}
+
+static struct fb_ops offb_ops = {
+       .owner          = THIS_MODULE,
+       .fb_setcolreg   = offb_setcolreg,
+       .fb_set_par     = offb_set_par,
+       .fb_blank       = offb_blank,
+       .fb_fillrect    = cfb_fillrect,
+       .fb_copyarea    = cfb_copyarea,
+       .fb_imageblit   = cfb_imageblit,
+};
 
 static void __iomem *offb_map_reg(struct device_node *np, int index,
                                  unsigned long offset, unsigned long size)
@@ -245,6 +314,59 @@ static void __iomem *offb_map_reg(struct device_node *np, int index,
        return ioremap(taddr + offset, size);
 }
 
+static void offb_init_palette_hacks(struct fb_info *info, struct device_node *dp,
+                                   const char *name, unsigned long address)
+{
+       struct offb_par *par = (struct offb_par *) info->par;
+
+       if (dp && !strncmp(name, "ATY,Rage128", 11)) {
+               par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff);
+               if (par->cmap_adr)
+                       par->cmap_type = cmap_r128;
+       } else if (dp && (!strncmp(name, "ATY,RageM3pA", 12)
+                         || !strncmp(name, "ATY,RageM3p12A", 14))) {
+               par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff);
+               if (par->cmap_adr)
+                       par->cmap_type = cmap_M3A;
+       } else if (dp && !strncmp(name, "ATY,RageM3pB", 12)) {
+               par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff);
+               if (par->cmap_adr)
+                       par->cmap_type = cmap_M3B;
+       } else if (dp && !strncmp(name, "ATY,Rage6", 9)) {
+               par->cmap_adr = offb_map_reg(dp, 1, 0, 0x1fff);
+               if (par->cmap_adr)
+                       par->cmap_type = cmap_radeon;
+       } else if (!strncmp(name, "ATY,", 4)) {
+               unsigned long base = address & 0xff000000UL;
+               par->cmap_adr =
+                       ioremap(base + 0x7ff000, 0x1000) + 0xcc0;
+               par->cmap_data = par->cmap_adr + 1;
+               par->cmap_type = cmap_m64;
+       } else if (dp && (of_device_is_compatible(dp, "pci1014,b7") ||
+                         of_device_is_compatible(dp, "pci1014,21c"))) {
+               par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000);
+               if (par->cmap_adr)
+                       par->cmap_type = cmap_gxt2000;
+       } else if (dp && !strncmp(name, "vga,Display-", 12)) {
+               /* Look for AVIVO initialized by SLOF */
+               struct device_node *pciparent = of_get_parent(dp);
+               const u32 *vid, *did;
+               vid = of_get_property(pciparent, "vendor-id", NULL);
+               did = of_get_property(pciparent, "device-id", NULL);
+               /* This will match most R5xx */
+               if (vid && did && *vid == 0x1002 &&
+                   ((*did >= 0x7100 && *did < 0x7800) ||
+                    (*did >= 0x9400))) {
+                       par->cmap_adr = offb_map_reg(pciparent, 2, 0, 0x10000);
+                       if (par->cmap_adr)
+                               par->cmap_type = cmap_avivo;
+               }
+               of_node_put(pciparent);
+       }
+       info->fix.visual = (par->cmap_type != cmap_unknown) ?
+               FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_STATIC_PSEUDOCOLOR;
+}
+
 static void __init offb_init_fb(const char *name, const char *full_name,
                                int width, int height, int depth,
                                int pitch, unsigned long address,
@@ -283,6 +405,7 @@ static void __init offb_init_fb(const char *name, const char *full_name,
 
        fix = &info->fix;
        var = &info->var;
+       info->par = par;
 
        strcpy(fix->id, "OFfb ");
        strncat(fix->id, name, sizeof(fix->id) - sizeof("OFfb "));
@@ -298,39 +421,9 @@ static void __init offb_init_fb(const char *name, const char *full_name,
        fix->type_aux = 0;
 
        par->cmap_type = cmap_unknown;
-       if (depth == 8) {
-               if (dp && !strncmp(name, "ATY,Rage128", 11)) {
-                       par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff);
-                       if (par->cmap_adr)
-                               par->cmap_type = cmap_r128;
-               } else if (dp && (!strncmp(name, "ATY,RageM3pA", 12)
-                                 || !strncmp(name, "ATY,RageM3p12A", 14))) {
-                       par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff);
-                       if (par->cmap_adr)
-                               par->cmap_type = cmap_M3A;
-               } else if (dp && !strncmp(name, "ATY,RageM3pB", 12)) {
-                       par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff);
-                       if (par->cmap_adr)
-                               par->cmap_type = cmap_M3B;
-               } else if (dp && !strncmp(name, "ATY,Rage6", 9)) {
-                       par->cmap_adr = offb_map_reg(dp, 1, 0, 0x1fff);
-                       if (par->cmap_adr)
-                               par->cmap_type = cmap_radeon;
-               } else if (!strncmp(name, "ATY,", 4)) {
-                       unsigned long base = address & 0xff000000UL;
-                       par->cmap_adr =
-                           ioremap(base + 0x7ff000, 0x1000) + 0xcc0;
-                       par->cmap_data = par->cmap_adr + 1;
-                       par->cmap_type = cmap_m64;
-               } else if (dp && (of_device_is_compatible(dp, "pci1014,b7") ||
-                                 of_device_is_compatible(dp, "pci1014,21c"))) {
-                       par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000);
-                       if (par->cmap_adr)
-                               par->cmap_type = cmap_gxt2000;
-               }
-               fix->visual = (par->cmap_type != cmap_unknown) ?
-                       FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_STATIC_PSEUDOCOLOR;
-       } else
+       if (depth == 8)
+               offb_init_palette_hacks(info, dp, name, address);
+       else
                fix->visual = FB_VISUAL_TRUECOLOR;
 
        var->xoffset = var->yoffset = 0;
@@ -395,7 +488,6 @@ static void __init offb_init_fb(const char *name, const char *full_name,
 
        info->fbops = &offb_ops;
        info->screen_base = ioremap(address, fix->smem_len);
-       info->par = par;
        info->pseudo_palette = (void *) (info + 1);
        info->flags = FBINFO_DEFAULT | foreign_endian;
 
index dc3af1c..4b5d807 100644 (file)
@@ -1297,6 +1297,7 @@ static int ps3fb_shutdown(struct ps3_system_bus_device *dev)
 
 static struct ps3_system_bus_driver ps3fb_driver = {
        .match_id       = PS3_MATCH_ID_GRAPHICS,
+       .match_sub_id   = PS3_MATCH_SUB_ID_FB,
        .core.name      = DEVICE_NAME,
        .core.owner     = THIS_MODULE,
        .probe          = ps3fb_probe,
index 591bc29..d4427cb 100644 (file)
@@ -610,6 +610,7 @@ static ssize_t show_target_kb(struct sys_device *dev, char *buf)
 }
 
 static ssize_t store_target_kb(struct sys_device *dev,
+                              struct sysdev_attribute *attr,
                               const char *buf,
                               size_t count)
 {
index d48ff5f..639d2d8 100644 (file)
@@ -204,6 +204,7 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
        NEW_AUX_ENT(AT_GID, tsk->gid);
        NEW_AUX_ENT(AT_EGID, tsk->egid);
        NEW_AUX_ENT(AT_SECURE, security_bprm_secureexec(bprm));
+       NEW_AUX_ENT(AT_EXECFN, bprm->exec);
        if (k_platform) {
                NEW_AUX_ENT(AT_PLATFORM,
                            (elf_addr_t)(unsigned long)u_platform);
index e3eb355..40c36f7 100644 (file)
@@ -362,8 +362,9 @@ static int init_coda_psdev(void)
                goto out_chrdev;
        }               
        for (i = 0; i < MAX_CODADEVS; i++)
-               device_create(coda_psdev_class, NULL,
-                             MKDEV(CODA_PSDEV_MAJOR,i), "cfs%d", i);
+               device_create_drvdata(coda_psdev_class, NULL,
+                                     MKDEV(CODA_PSDEV_MAJOR, i),
+                                     NULL, "cfs%d", i);
        coda_sysctl_init();
        goto out;
 
index e9602d8..08e28c9 100644 (file)
@@ -309,6 +309,31 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
 }
 EXPORT_SYMBOL_GPL(debugfs_create_symlink);
 
+static void __debugfs_remove(struct dentry *dentry, struct dentry *parent)
+{
+       int ret = 0;
+
+       if (debugfs_positive(dentry)) {
+               if (dentry->d_inode) {
+                       dget(dentry);
+                       switch (dentry->d_inode->i_mode & S_IFMT) {
+                       case S_IFDIR:
+                               ret = simple_rmdir(parent->d_inode, dentry);
+                               break;
+                       case S_IFLNK:
+                               kfree(dentry->d_inode->i_private);
+                               /* fall through */
+                       default:
+                               simple_unlink(parent->d_inode, dentry);
+                               break;
+                       }
+                       if (!ret)
+                               d_delete(dentry);
+                       dput(dentry);
+               }
+       }
+}
+
 /**
  * debugfs_remove - removes a file or directory from the debugfs filesystem
  * @dentry: a pointer to a the dentry of the file or directory to be
@@ -325,7 +350,6 @@ EXPORT_SYMBOL_GPL(debugfs_create_symlink);
 void debugfs_remove(struct dentry *dentry)
 {
        struct dentry *parent;
-       int ret = 0;
        
        if (!dentry)
                return;
@@ -335,29 +359,83 @@ void debugfs_remove(struct dentry *dentry)
                return;
 
        mutex_lock(&parent->d_inode->i_mutex);
-       if (debugfs_positive(dentry)) {
-               if (dentry->d_inode) {
-                       dget(dentry);
-                       switch (dentry->d_inode->i_mode & S_IFMT) {
-                       case S_IFDIR:
-                               ret = simple_rmdir(parent->d_inode, dentry);
-                               break;
-                       case S_IFLNK:
-                               kfree(dentry->d_inode->i_private);
-                               /* fall through */
-                       default:
-                               simple_unlink(parent->d_inode, dentry);
+       __debugfs_remove(dentry, parent);
+       mutex_unlock(&parent->d_inode->i_mutex);
+       simple_release_fs(&debugfs_mount, &debugfs_mount_count);
+}
+EXPORT_SYMBOL_GPL(debugfs_remove);
+
+/**
+ * debugfs_remove_recursive - recursively removes a directory
+ * @dentry: a pointer to a the dentry of the directory to be removed.
+ *
+ * This function recursively removes a directory tree in debugfs that
+ * was previously created with a call to another debugfs function
+ * (like debugfs_create_file() or variants thereof.)
+ *
+ * This function is required to be called in order for the file to be
+ * removed, no automatic cleanup of files will happen when a module is
+ * removed, you are responsible here.
+ */
+void debugfs_remove_recursive(struct dentry *dentry)
+{
+       struct dentry *child;
+       struct dentry *parent;
+
+       if (!dentry)
+               return;
+
+       parent = dentry->d_parent;
+       if (!parent || !parent->d_inode)
+               return;
+
+       parent = dentry;
+       mutex_lock(&parent->d_inode->i_mutex);
+
+       while (1) {
+               /*
+                * When all dentries under "parent" has been removed,
+                * walk up the tree until we reach our starting point.
+                */
+               if (list_empty(&parent->d_subdirs)) {
+                       mutex_unlock(&parent->d_inode->i_mutex);
+                       if (parent == dentry)
                                break;
-                       }
-                       if (!ret)
-                               d_delete(dentry);
-                       dput(dentry);
+                       parent = parent->d_parent;
+                       mutex_lock(&parent->d_inode->i_mutex);
+               }
+               child = list_entry(parent->d_subdirs.next, struct dentry,
+                               d_u.d_child);
+
+               /*
+                * If "child" isn't empty, walk down the tree and
+                * remove all its descendants first.
+                */
+               if (!list_empty(&child->d_subdirs)) {
+                       mutex_unlock(&parent->d_inode->i_mutex);
+                       parent = child;
+                       mutex_lock(&parent->d_inode->i_mutex);
+                       continue;
                }
+               __debugfs_remove(child, parent);
+               if (parent->d_subdirs.next == &child->d_u.d_child) {
+                       /*
+                        * Avoid infinite loop if we fail to remove
+                        * one dentry.
+                        */
+                       mutex_unlock(&parent->d_inode->i_mutex);
+                       break;
+               }
+               simple_release_fs(&debugfs_mount, &debugfs_mount_count);
        }
+
+       parent = dentry->d_parent;
+       mutex_lock(&parent->d_inode->i_mutex);
+       __debugfs_remove(dentry, parent);
        mutex_unlock(&parent->d_inode->i_mutex);
        simple_release_fs(&debugfs_mount, &debugfs_mount_count);
 }
-EXPORT_SYMBOL_GPL(debugfs_remove);
+EXPORT_SYMBOL_GPL(debugfs_remove_recursive);
 
 /**
  * debugfs_rename - rename a file/directory in the debugfs filesystem
index 6149e4b..efef715 100644 (file)
@@ -401,7 +401,7 @@ void register_disk(struct gendisk *disk)
        disk->dev.parent = disk->driverfs_dev;
        disk->dev.devt = MKDEV(disk->major, disk->first_minor);
 
-       strlcpy(disk->dev.bus_id, disk->disk_name, KOBJ_NAME_LEN);
+       strlcpy(disk->dev.bus_id, disk->disk_name, BUS_ID_SIZE);
        /* ewww... some of these buggers have / in the name... */
        s = strchr(disk->dev.bus_id, '/');
        if (s)
index 164bd9f..7546a91 100644 (file)
@@ -636,7 +636,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
        struct pagemapread pm;
        int pagecount;
        int ret = -ESRCH;
-       struct mm_walk pagemap_walk;
+       struct mm_walk pagemap_walk = {};
        unsigned long src;
        unsigned long svpfn;
        unsigned long start_vaddr;
index 8c0e4b9..c1a7efb 100644 (file)
@@ -398,7 +398,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
 }
 
 /**
- *     sysfs_add_one - add sysfs_dirent to parent
+ *     __sysfs_add_one - add sysfs_dirent to parent without warning
  *     @acxt: addrm context to use
  *     @sd: sysfs_dirent to be added
  *
@@ -417,7 +417,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
  *     0 on success, -EEXIST if entry with the given name already
  *     exists.
  */
-int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
+int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
 {
        if (sysfs_find_dirent(acxt->parent_sd, sd->s_name))
                return -EEXIST;
@@ -434,6 +434,39 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
        return 0;
 }
 
+/**
+ *     sysfs_add_one - add sysfs_dirent to parent
+ *     @acxt: addrm context to use
+ *     @sd: sysfs_dirent to be added
+ *
+ *     Get @acxt->parent_sd and set sd->s_parent to it and increment
+ *     nlink of parent inode if @sd is a directory and link into the
+ *     children list of the parent.
+ *
+ *     This function should be called between calls to
+ *     sysfs_addrm_start() and sysfs_addrm_finish() and should be
+ *     passed the same @acxt as passed to sysfs_addrm_start().
+ *
+ *     LOCKING:
+ *     Determined by sysfs_addrm_start().
+ *
+ *     RETURNS:
+ *     0 on success, -EEXIST if entry with the given name already
+ *     exists.
+ */
+int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
+{
+       int ret;
+
+       ret = __sysfs_add_one(acxt, sd);
+       if (ret == -EEXIST) {
+               printk(KERN_WARNING "sysfs: duplicate filename '%s' "
+                      "can not be created\n", sd->s_name);
+               WARN_ON(1);
+       }
+       return ret;
+}
+
 /**
  *     sysfs_remove_one - remove sysfs_dirent from parent
  *     @acxt: addrm context to use
index e7735f6..3f07893 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/kobject.h>
 #include <linux/kallsyms.h>
 #include <linux/slab.h>
+#include <linux/fsnotify.h>
 #include <linux/namei.h>
 #include <linux/poll.h>
 #include <linux/list.h>
@@ -585,9 +586,11 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
 
        newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
        newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
-       rc = notify_change(victim, &newattrs);
+       newattrs.ia_ctime = current_fs_time(inode->i_sb);
+       rc = sysfs_setattr(victim, &newattrs);
 
        if (rc == 0) {
+               fsnotify_change(victim, newattrs.ia_valid);
                mutex_lock(&sysfs_mutex);
                victim_sd->s_mode = newattrs.ia_mode;
                mutex_unlock(&sysfs_mutex);
index 817f596..a3ba217 100644 (file)
 
 #include "sysfs.h"
 
-/**
- *     sysfs_create_link - create symlink between two objects.
- *     @kobj:  object whose directory we're creating the link in.
- *     @target:        object we're pointing to.
- *     @name:          name of the symlink.
- */
-int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name)
+static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target,
+                               const char *name, int warn)
 {
        struct sysfs_dirent *parent_sd = NULL;
        struct sysfs_dirent *target_sd = NULL;
@@ -65,7 +60,10 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
        target_sd = NULL;       /* reference is now owned by the symlink */
 
        sysfs_addrm_start(&acxt, parent_sd);
-       error = sysfs_add_one(&acxt, sd);
+       if (warn)
+               error = sysfs_add_one(&acxt, sd);
+       else
+               error = __sysfs_add_one(&acxt, sd);
        sysfs_addrm_finish(&acxt);
 
        if (error)
@@ -79,6 +77,33 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
        return error;
 }
 
+/**
+ *     sysfs_create_link - create symlink between two objects.
+ *     @kobj:  object whose directory we're creating the link in.
+ *     @target:        object we're pointing to.
+ *     @name:          name of the symlink.
+ */
+int sysfs_create_link(struct kobject *kobj, struct kobject *target,
+                     const char *name)
+{
+       return sysfs_do_create_link(kobj, target, name, 1);
+}
+
+/**
+ *     sysfs_create_link_nowarn - create symlink between two objects.
+ *     @kobj:  object whose directory we're creating the link in.
+ *     @target:        object we're pointing to.
+ *     @name:          name of the symlink.
+ *
+ *     This function does the same as sysf_create_link(), but it
+ *     doesn't warn if the link already exists.
+ */
+int sysfs_create_link_nowarn(struct kobject *kobj, struct kobject *target,
+                            const char *name)
+{
+       return sysfs_do_create_link(kobj, target, name, 0);
+}
+
 /**
  *     sysfs_remove_link - remove symlink in object's directory.
  *     @kobj:  object we're acting for.
index ce4e15f..a5db496 100644 (file)
@@ -107,6 +107,7 @@ struct sysfs_dirent *sysfs_get_active_two(struct sysfs_dirent *sd);
 void sysfs_put_active_two(struct sysfs_dirent *sd);
 void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
                       struct sysfs_dirent *parent_sd);
+int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd);
 int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd);
 void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd);
 void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
index 8ec2e1d..8f0fe79 100644 (file)
@@ -22,6 +22,7 @@
 #define PPC_STL                stringify_in_c(std)
 #define PPC_LCMPI      stringify_in_c(cmpdi)
 #define PPC_LONG       stringify_in_c(.llong)
+#define PPC_LONG_ALIGN stringify_in_c(.balign 8)
 #define PPC_TLNEI      stringify_in_c(tdnei)
 #define PPC_LLARX      stringify_in_c(ldarx)
 #define PPC_STLCX      stringify_in_c(stdcx.)
@@ -43,6 +44,7 @@
 #define PPC_STL                stringify_in_c(stw)
 #define PPC_LCMPI      stringify_in_c(cmpwi)
 #define PPC_LONG       stringify_in_c(.long)
+#define PPC_LONG_ALIGN stringify_in_c(.balign 4)
 #define PPC_TLNEI      stringify_in_c(twnei)
 #define PPC_LLARX      stringify_in_c(lwarx)
 #define PPC_STLCX      stringify_in_c(stwcx.)
index 9899226..1233d73 100644 (file)
@@ -80,7 +80,8 @@ struct machdep_calls {
                                     long index,
                                     long npages,
                                     unsigned long uaddr,
-                                    enum dma_data_direction direction);
+                                    enum dma_data_direction direction,
+                                    struct dma_attrs *attrs);
        void            (*tce_free)(struct iommu_table *tbl,
                                    long index,
                                    long npages);
index 73015f0..3a96d00 100644 (file)
@@ -295,10 +295,10 @@ extern int icache_44x_need_flush;
 #define _PAGE_PRESENT  0x00001 /* S: PTE contains a translation */
 #define _PAGE_USER     0x00002 /* S: User page (maps to UR) */
 #define _PAGE_FILE     0x00002 /* S: when !present: nonlinear file mapping */
-#define _PAGE_ACCESSED 0x00004 /* S: Page referenced */
-#define _PAGE_HWWRITE  0x00008 /* H: Dirty & RW, set in exception */
-#define _PAGE_RW       0x00010 /* S: Write permission */
-#define _PAGE_HWEXEC   0x00020 /* H: UX permission */
+#define _PAGE_RW       0x00004 /* S: Write permission (SW) */
+#define _PAGE_DIRTY    0x00008 /* S: Page dirty */
+#define _PAGE_HWEXEC   0x00010 /* H: SX permission */
+#define _PAGE_ACCESSED 0x00020 /* S: Page referenced */
 
 #define _PAGE_ENDIAN   0x00040 /* H: E bit */
 #define _PAGE_GUARDED  0x00080 /* H: G bit */
@@ -307,21 +307,14 @@ extern int icache_44x_need_flush;
 #define _PAGE_WRITETHRU        0x00400 /* H: W bit */
 
 #ifdef CONFIG_PTE_64BIT
-#define _PAGE_DIRTY    0x08000 /* S: Page dirty */
-
 /* ERPN in a PTE never gets cleared, ignore it */
 #define _PTE_NONE_MASK 0xffffffffffff0000ULL
-#else
-#define _PAGE_DIRTY    0x00800 /* S: Page dirty */
 #endif
 
 #define _PMD_PRESENT   0
 #define _PMD_PRESENT_MASK (PAGE_MASK)
 #define _PMD_BAD       (~PAGE_MASK)
 
-/* Until my rework is finished, FSL BookE still needs atomic PTE updates */
-#define PTE_ATOMIC_UPDATES     1
-
 #elif defined(CONFIG_8xx)
 /* Definitions for 8xx embedded chips. */
 #define _PAGE_PRESENT  0x0001  /* Page is valid */
index e1dc090..b4e91fb 100644 (file)
@@ -30,6 +30,7 @@
 #ifdef __KERNEL__
 
 #define PMI_TYPE_FREQ_CHANGE   0x01
+#define PMI_TYPE_POWER_BUTTON  0x02
 #define PMI_READ_TYPE          0
 #define PMI_READ_DATA0         1
 #define PMI_READ_DATA1         2
index 81ffe3b..f9e34c4 100644 (file)
@@ -337,12 +337,18 @@ enum ps3_system_bus_device_type {
        PS3_DEVICE_TYPE_LPM,
 };
 
+enum ps3_match_sub_id {
+       /* for PS3_MATCH_ID_GRAPHICS */
+       PS3_MATCH_SUB_ID_FB             = 1,
+};
+
 /**
  * struct ps3_system_bus_device - a device on the system bus
  */
 
 struct ps3_system_bus_device {
        enum ps3_match_id match_id;
+       enum ps3_match_sub_id match_sub_id;
        enum ps3_system_bus_device_type dev_type;
 
        u64 bus_id;                       /* SB */
@@ -371,6 +377,7 @@ int ps3_close_hv_device(struct ps3_system_bus_device *dev);
 
 struct ps3_system_bus_driver {
        enum ps3_match_id match_id;
+       enum ps3_match_sub_id match_sub_id;
        struct device_driver core;
        int (*probe)(struct ps3_system_bus_device *);
        int (*remove)(struct ps3_system_bus_device *);
index bbccadf..c6d1ab6 100644 (file)
 #define   CTRL_RUNLATCH        0x1
 #define SPRN_DABR      0x3F5   /* Data Address Breakpoint Register */
 #define   DABR_TRANSLATION     (1UL << 2)
+#define SPRN_DABR2     0x13D   /* e300 */
 #define SPRN_DABRX     0x3F7   /* Data Address Breakpoint Register Extension */
 #define   DABRX_USER   (1UL << 0)
 #define   DABRX_KERNEL (1UL << 1)
 #define SPRN_DAR       0x013   /* Data Address Register */
+#define SPRN_DBCR      0x136   /* e300 Data Breakpoint Control Reg */
 #define SPRN_DSISR     0x012   /* Data Storage Interrupt Status Register */
 #define   DSISR_NOHPTE         0x40000000      /* no translation found */
 #define   DSISR_PROTFAULT      0x08000000      /* protection fault */
 #define HID1_PS                (1<<16)         /* 750FX PLL selection */
 #define SPRN_HID2      0x3F8           /* Hardware Implementation Register 2 */
 #define SPRN_IABR      0x3F2   /* Instruction Address Breakpoint Register */
+#define SPRN_IABR2     0x3FA           /* 83xx */
+#define SPRN_IBCR      0x135           /* 83xx Insn Breakpoint Control Reg */
 #define SPRN_HID4      0x3F4           /* 970 HID4 */
 #define SPRN_HID5      0x3F6           /* 970 HID5 */
 #define SPRN_HID6      0x3F9   /* BE HID 6 */
index 1a0736f..bd0fb84 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <linux/sched.h>
 #include <linux/errno.h>
+#include <asm/asm-compat.h>
 #include <asm/processor.h>
 #include <asm/page.h>
 
@@ -141,12 +142,11 @@ extern long __put_user_bad(void);
                "       b 2b\n"                                 \
                ".previous\n"                                   \
                ".section __ex_table,\"a\"\n"                   \
-               "       .balign %5\n"                           \
+                       PPC_LONG_ALIGN "\n"                     \
                        PPC_LONG "1b,3b\n"                      \
                ".previous"                                     \
                : "=r" (err)                                    \
-               : "r" (x), "b" (addr), "i" (-EFAULT), "0" (err),\
-                 "i"(sizeof(unsigned long)))
+               : "r" (x), "b" (addr), "i" (-EFAULT), "0" (err))
 
 #ifdef __powerpc64__
 #define __put_user_asm2(x, ptr, retval)                                \
@@ -162,13 +162,12 @@ extern long __put_user_bad(void);
                "       b 3b\n"                                 \
                ".previous\n"                                   \
                ".section __ex_table,\"a\"\n"                   \
-               "       .balign %5\n"                           \
+                       PPC_LONG_ALIGN "\n"                     \
                        PPC_LONG "1b,4b\n"                      \
                        PPC_LONG "2b,4b\n"                      \
                ".previous"                                     \
                : "=r" (err)                                    \
-               : "r" (x), "b" (addr), "i" (-EFAULT), "0" (err),\
-                 "i"(sizeof(unsigned long)))
+               : "r" (x), "b" (addr), "i" (-EFAULT), "0" (err))
 #endif /* __powerpc64__ */
 
 #define __put_user_size(x, ptr, size, retval)                  \
@@ -226,12 +225,11 @@ extern long __get_user_bad(void);
                "       b 2b\n"                         \
                ".previous\n"                           \
                ".section __ex_table,\"a\"\n"           \
-               "       .balign %5\n"                   \
+                       PPC_LONG_ALIGN "\n"             \
                        PPC_LONG "1b,3b\n"              \
                ".previous"                             \
                : "=r" (err), "=r" (x)                  \
-               : "b" (addr), "i" (-EFAULT), "0" (err), \
-                 "i"(sizeof(unsigned long)))
+               : "b" (addr), "i" (-EFAULT), "0" (err))
 
 #ifdef __powerpc64__
 #define __get_user_asm2(x, addr, err)                  \
@@ -249,13 +247,12 @@ extern long __get_user_bad(void);
                "       b 3b\n"                         \
                ".previous\n"                           \
                ".section __ex_table,\"a\"\n"           \
-               "       .balign %5\n"                   \
+                       PPC_LONG_ALIGN "\n"             \
                        PPC_LONG "1b,4b\n"              \
                        PPC_LONG "2b,4b\n"              \
                ".previous"                             \
                : "=r" (err), "=&r" (x)                 \
-               : "b" (addr), "i" (-EFAULT), "0" (err), \
-                 "i"(sizeof(unsigned long)))
+               : "b" (addr), "i" (-EFAULT), "0" (err))
 #endif /* __powerpc64__ */
 
 #define __get_user_size(x, ptr, size, retval)                  \
index f529f70..fce16ab 100644 (file)
@@ -156,11 +156,11 @@ struct ucc_fast_info {
 
 struct ucc_fast_private {
        struct ucc_fast_info *uf_info;
-       struct ucc_fast *uf_regs;       /* a pointer to memory map of UCC regs. */
-       u32 *p_ucce;            /* a pointer to the event register in memory. */
-       u32 *p_uccm;            /* a pointer to the mask register in memory. */
+       struct ucc_fast __iomem *uf_regs; /* a pointer to the UCC regs. */
+       u32 __iomem *p_ucce;    /* a pointer to the event register in memory. */
+       u32 __iomem *p_uccm;    /* a pointer to the mask register in memory. */
 #ifdef CONFIG_UGETH_TX_ON_DEMAND
-       u16 *p_utodr;           /* pointer to the transmit on demand register */
+       u16 __iomem *p_utodr;   /* pointer to the transmit on demand register */
 #endif
        int enabled_tx;         /* Whether channel is enabled for Tx (ENT) */
        int enabled_rx;         /* Whether channel is enabled for Rx (ENR) */
index ad89545..0da17d1 100644 (file)
 
 #define AT_SECURE 23   /* secure mode boolean */
 
+#define AT_EXECFN  31  /* filename of program */
 #ifdef __KERNEL__
-#define AT_VECTOR_SIZE_BASE (14 + 2) /* NEW_AUX_ENT entries in auxiliary table */
+#define AT_VECTOR_SIZE_BASE 17 /* NEW_AUX_ENT entries in auxiliary table */
+  /* number of "#define AT_.*" above, minus {AT_NULL, AT_IGNORE, AT_NOTELF} */
 #endif
 
 #endif /* _LINUX_AUXVEC_H */
index 32755cd..e1a6c04 100644 (file)
@@ -44,6 +44,7 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
                                      const char *dest);
 
 void debugfs_remove(struct dentry *dentry);
+void debugfs_remove_recursive(struct dentry *dentry);
 
 struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
                 struct dentry *new_dir, const char *new_name);
@@ -101,6 +102,9 @@ static inline struct dentry *debugfs_create_symlink(const char *name,
 static inline void debugfs_remove(struct dentry *dentry)
 { }
 
+static inline void debugfs_remove_recursive(struct dentry *dentry)
+{ }
+
 static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
                 struct dentry *new_dir, char *new_name)
 {
index f71a78d..d24a47f 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/kobject.h>
 #include <linux/klist.h>
 #include <linux/list.h>
+#include <linux/lockdep.h>
 #include <linux/compiler.h>
 #include <linux/types.h>
 #include <linux/module.h>
 #include <asm/atomic.h>
 #include <asm/device.h>
 
-#define DEVICE_NAME_SIZE       50
-/* DEVICE_NAME_HALF is really less than half to accommodate slop */
-#define DEVICE_NAME_HALF       __stringify(20)
-#define DEVICE_ID_SIZE         32
-#define BUS_ID_SIZE            KOBJ_NAME_LEN
-
+#define BUS_ID_SIZE            20
 
 struct device;
 struct device_driver;
 struct driver_private;
 struct class;
+struct class_private;
 struct bus_type;
 struct bus_type_private;
 
@@ -186,13 +183,9 @@ struct class {
        const char              *name;
        struct module           *owner;
 
-       struct kset             subsys;
-       struct list_head        devices;
-       struct list_head        interfaces;
-       struct kset             class_dirs;
-       struct semaphore        sem; /* locks children, devices, interfaces */
        struct class_attribute          *class_attrs;
        struct device_attribute         *dev_attrs;
+       struct kobject                  *dev_kobj;
 
        int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
 
@@ -203,13 +196,28 @@ struct class {
        int (*resume)(struct device *dev);
 
        struct pm_ops *pm;
+       struct class_private *p;
 };
 
-extern int __must_check class_register(struct class *class);
+extern struct kobject *sysfs_dev_block_kobj;
+extern struct kobject *sysfs_dev_char_kobj;
+extern int __must_check __class_register(struct class *class,
+                                        struct lock_class_key *key);
 extern void class_unregister(struct class *class);
-extern int class_for_each_device(struct class *class, void *data,
+
+/* This is a #define to keep the compiler from merging different
+ * instances of the __key variable */
+#define class_register(class)                  \
+({                                             \
+       static struct lock_class_key __key;     \
+       __class_register(class, &__key);        \
+})
+
+extern int class_for_each_device(struct class *class, struct device *start,
+                                void *data,
                                 int (*fn)(struct device *dev, void *data));
-extern struct device *class_find_device(struct class *class, void *data,
+extern struct device *class_find_device(struct class *class,
+                                       struct device *start, void *data,
                                        int (*match)(struct device *, void *));
 
 struct class_attribute {
@@ -237,9 +245,19 @@ struct class_interface {
 extern int __must_check class_interface_register(struct class_interface *);
 extern void class_interface_unregister(struct class_interface *);
 
-extern struct class *class_create(struct module *owner, const char *name);
+extern struct class * __must_check __class_create(struct module *owner,
+                                                 const char *name,
+                                                 struct lock_class_key *key);
 extern void class_destroy(struct class *cls);
 
+/* This is a #define to keep the compiler from merging different
+ * instances of the __key variable */
+#define class_create(owner, name)              \
+({                                             \
+       static struct lock_class_key __key;     \
+       __class_create(owner, name, &__key);    \
+})
+
 /*
  * The type of device, "struct device" is embedded in. A class
  * or bus can contain devices of different types
@@ -468,14 +486,10 @@ extern struct device *device_create_vargs(struct class *cls,
                                          const char *fmt,
                                          va_list vargs);
 extern struct device *device_create(struct class *cls, struct device *parent,
-                                   dev_t devt, const char *fmt, ...)
-                                   __attribute__((format(printf, 4, 5)));
-extern struct device *device_create_drvdata(struct class *cls,
-                                           struct device *parent,
-                                           dev_t devt,
-                                           void *drvdata,
-                                           const char *fmt, ...)
+                                   dev_t devt, void *drvdata,
+                                   const char *fmt, ...)
                                    __attribute__((format(printf, 5, 6)));
+#define device_create_drvdata  device_create
 extern void device_destroy(struct class *cls, dev_t devt);
 
 /*
index 1677e2b..71ad34e 100644 (file)
@@ -12,6 +12,7 @@
  */
 enum dma_attr {
        DMA_ATTR_WRITE_BARRIER,
+       DMA_ATTR_WEAK_ORDERING,
        DMA_ATTR_MAX,
 };
 
index fe806b6..e61c0be 100644 (file)
@@ -40,7 +40,7 @@ struct eisa_device {
        u64                   dma_mask;
        struct device         dev; /* generic device */
 #ifdef CONFIG_EISA_NAMES
-       char                  pretty_name[DEVICE_NAME_SIZE];
+       char                  pretty_name[50];
 #endif
 };
 
index 9bc045b..0ba21ee 100644 (file)
@@ -135,11 +135,7 @@ struct fs_platform_info {
        u32 device_flags;
 
        int phy_addr;           /* the phy address (-1 no phy) */
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
        char bus_id[16];
-#else
-       const char*     bus_id;
-#endif
        int phy_irq;            /* the phy irq (if it exists)  */
 
        const struct fs_mii_bus_info *bus_info;
index c415a49..4e625e0 100644 (file)
@@ -69,6 +69,7 @@ struct gianfar_mdio_data {
 #define FSL_GIANFAR_DEV_HAS_VLAN               0x00000020
 #define FSL_GIANFAR_DEV_HAS_EXTENDED_HASH      0x00000040
 #define FSL_GIANFAR_DEV_HAS_PADDING            0x00000080
+#define FSL_GIANFAR_DEV_HAS_MAGIC_PACKET       0x00000100
 
 /* Flags in gianfar_platform_data */
 #define FSL_GIANFAR_BRD_HAS_PHY_INTR   0x00000001 /* set or use a timer */
@@ -125,4 +126,10 @@ struct mpc8xx_pcmcia_ops {
        int(*voltage_set)(int slot, int vcc, int vpp);
 };
 
+/* Returns non-zero if the current suspend operation would
+ * lead to a deep sleep (i.e. power removed from the core,
+ * instead of just the clock).
+ */
+int fsl_deep_sleep(void);
+
 #endif /* _FSL_DEVICE_H_ */
index 39e709f..60f0d41 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/wait.h>
 #include <asm/atomic.h>
 
-#define KOBJ_NAME_LEN                  20
 #define UEVENT_HELPER_PATH_LEN         256
 #define UEVENT_NUM_ENVP                        32      /* number of env pointers */
 #define UEVENT_BUFFER_SIZE             2048    /* buffer for the variables */
@@ -59,12 +58,12 @@ enum kobject_action {
 
 struct kobject {
        const char              *name;
-       struct kref             kref;
        struct list_head        entry;
        struct kobject          *parent;
        struct kset             *kset;
        struct kobj_type        *ktype;
        struct sysfs_dirent     *sd;
+       struct kref             kref;
        unsigned int state_initialized:1;
        unsigned int state_in_sysfs:1;
        unsigned int state_add_uevent_sent:1;
index a9fae03..9c1d954 100644 (file)
@@ -189,7 +189,7 @@ typedef union {
 */
 
 struct map_info {
-       char *name;
+       const char *name;
        unsigned long size;
        resource_size_t phys;
 #define NO_XIP (-1UL)
index 245f909..8b5d491 100644 (file)
@@ -121,7 +121,7 @@ struct mtd_info {
        u_int32_t oobavail;  // Available OOB bytes per block
 
        // Kernel-only stuff starts here.
-       char *name;
+       const char *name;
        int index;
 
        /* ecc layout structure pointer - read only ! */
index 2ee97e9..67db101 100644 (file)
@@ -15,7 +15,7 @@
 #define __LINUX_OF_GPIO_H
 
 #include <linux/errno.h>
-#include <asm/gpio.h>
+#include <linux/gpio.h>
 
 #ifdef CONFIG_OF_GPIO
 
diff --git a/include/linux/spi/max7301.h b/include/linux/spi/max7301.h
new file mode 100644 (file)
index 0000000..6dfd83f
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef LINUX_SPI_MAX7301_H
+#define LINUX_SPI_MAX7301_H
+
+struct max7301_platform_data {
+       /* number assigned to the first GPIO */
+       unsigned        base;
+};
+
+#endif
index 387e428..b9a76c9 100644 (file)
@@ -733,7 +733,7 @@ struct spi_board_info {
         * controller_data goes to spi_device.controller_data,
         * irq is copied too
         */
-       char            modalias[KOBJ_NAME_LEN];
+       char            modalias[32];
        const void      *platform_data;
        void            *controller_data;
        int             irq;
index 45f6bc8..c844a22 100644 (file)
 #define MGSL_INTERFACE_RTS_EN   0x10
 #define MGSL_INTERFACE_LL       0x20
 #define MGSL_INTERFACE_RL       0x40
+#define MGSL_INTERFACE_MSB_FIRST 0x80
 
 typedef struct _MGSL_PARAMS
 {
index f2767bc..f395bb3 100644 (file)
@@ -99,8 +99,9 @@ extern void sysdev_unregister(struct sys_device *);
 
 struct sysdev_attribute { 
        struct attribute        attr;
-       ssize_t (*show)(struct sys_device *, char *);
-       ssize_t (*store)(struct sys_device *, const char *, size_t);
+       ssize_t (*show)(struct sys_device *, struct sysdev_attribute *, char *);
+       ssize_t (*store)(struct sys_device *, struct sysdev_attribute *,
+                        const char *, size_t);
 };
 
 
@@ -118,4 +119,38 @@ struct sysdev_attribute {
 extern int sysdev_create_file(struct sys_device *, struct sysdev_attribute *);
 extern void sysdev_remove_file(struct sys_device *, struct sysdev_attribute *);
 
+struct sysdev_ext_attribute {
+       struct sysdev_attribute attr;
+       void *var;
+};
+
+/*
+ * Support for simple variable sysdev attributes.
+ * The pointer to the variable is stored in a sysdev_ext_attribute
+ */
+
+/* Add more types as needed */
+
+extern ssize_t sysdev_show_ulong(struct sys_device *, struct sysdev_attribute *,
+                               char *);
+extern ssize_t sysdev_store_ulong(struct sys_device *,
+                       struct sysdev_attribute *, const char *, size_t);
+extern ssize_t sysdev_show_int(struct sys_device *, struct sysdev_attribute *,
+                               char *);
+extern ssize_t sysdev_store_int(struct sys_device *,
+                       struct sysdev_attribute *, const char *, size_t);
+
+#define _SYSDEV_ULONG_ATTR(_name, _mode, _var)                         \
+       { _SYSDEV_ATTR(_name, _mode, sysdev_show_ulong, sysdev_store_ulong), \
+         &(_var) }
+#define SYSDEV_ULONG_ATTR(_name, _mode, _var)                  \
+       struct sysdev_ext_attribute attr_##_name =              \
+               _SYSDEV_ULONG_ATTR(_name, _mode, _var);
+#define _SYSDEV_INT_ATTR(_name, _mode, _var)                           \
+       { _SYSDEV_ATTR(_name, _mode, sysdev_show_int, sysdev_store_int), \
+         &(_var) }
+#define SYSDEV_INT_ATTR(_name, _mode, _var)                    \
+       struct sysdev_ext_attribute attr_##_name =              \
+               _SYSDEV_INT_ATTR(_name, _mode, _var);
+
 #endif /* _SYSDEV_H_ */
index 7858eac..37fa241 100644 (file)
@@ -101,6 +101,9 @@ void sysfs_remove_bin_file(struct kobject *kobj, struct bin_attribute *attr);
 
 int __must_check sysfs_create_link(struct kobject *kobj, struct kobject *target,
                                   const char *name);
+int __must_check sysfs_create_link_nowarn(struct kobject *kobj,
+                                         struct kobject *target,
+                                         const char *name);
 void sysfs_remove_link(struct kobject *kobj, const char *name);
 
 int __must_check sysfs_create_group(struct kobject *kobj,
@@ -180,6 +183,13 @@ static inline int sysfs_create_link(struct kobject *kobj,
        return 0;
 }
 
+static inline int sysfs_create_link_nowarn(struct kobject *kobj,
+                                          struct kobject *target,
+                                          const char *name)
+{
+       return 0;
+}
+
 static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
 {
 }
index 4e58330..e3579cb 100644 (file)
@@ -317,8 +317,6 @@ extern void tty_wait_until_sent(struct tty_struct *tty, long timeout);
 extern int tty_check_change(struct tty_struct *tty);
 extern void stop_tty(struct tty_struct *tty);
 extern void start_tty(struct tty_struct *tty);
-extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
-extern int tty_unregister_ldisc(int disc);
 extern int tty_register_driver(struct tty_driver *driver);
 extern int tty_unregister_driver(struct tty_driver *driver);
 extern struct device *tty_register_device(struct tty_driver *driver,
@@ -383,6 +381,15 @@ extern void tty_port_init(struct tty_port *port);
 extern int tty_port_alloc_xmit_buf(struct tty_port *port);
 extern void tty_port_free_xmit_buf(struct tty_port *port);
 
+extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
+extern int tty_unregister_ldisc(int disc);
+extern int tty_set_ldisc(struct tty_struct *tty, int ldisc);
+extern int tty_ldisc_setup(struct tty_struct *tty, struct tty_struct *o_tty);
+extern void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty);
+extern void tty_ldisc_init(struct tty_struct *tty);
+extern void tty_ldisc_begin(void);
+/* This last one is just for the tty layer internals and shouldn't be used elsewhere */
+extern void tty_ldisc_enable(struct tty_struct *tty);
 
 
 /* n_tty.c */
index d2a0035..e1065ac 100644 (file)
  *
  *     Optional:
  *
- * void (*break_ctl)(struct tty_stuct *tty, int state);
+ * int (*break_ctl)(struct tty_stuct *tty, int state);
  *
  *     This optional routine requests the tty driver to turn on or
  *     off BREAK status on the RS-232 port.  If state is -1,
  *     handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK,
  *     TIOCCBRK.
  *
+ *     If the driver sets TTY_DRIVER_HARDWARE_BREAK then the interface
+ *     will also be called with actual times and the hardware is expected
+ *     to do the delay work itself. 0 and -1 are still used for on/off.
+ *
  *     Optional: Required for TCSBRK/BRKP/etc handling.
  *
  * void (*wait_until_sent)(struct tty_struct *tty, int timeout);
@@ -192,7 +196,7 @@ struct tty_operations {
        void (*stop)(struct tty_struct *tty);
        void (*start)(struct tty_struct *tty);
        void (*hangup)(struct tty_struct *tty);
-       void (*break_ctl)(struct tty_struct *tty, int state);
+       int (*break_ctl)(struct tty_struct *tty, int state);
        void (*flush_buffer)(struct tty_struct *tty);
        void (*set_ldisc)(struct tty_struct *tty);
        void (*wait_until_sent)(struct tty_struct *tty, int timeout);
@@ -285,12 +289,18 @@ extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
  * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead
  *     use dynamic memory keyed through the devpts filesystem.  This
  *     is only applicable to the pty driver.
+ *
+ * TTY_DRIVER_HARDWARE_BREAK -- hardware handles break signals. Pass
+ *     the requested timeout to the caller instead of using a simple
+ *     on/off interface.
+ *
  */
 #define TTY_DRIVER_INSTALLED           0x0001
 #define TTY_DRIVER_RESET_TERMIOS       0x0002
 #define TTY_DRIVER_REAL_RAW            0x0004
 #define TTY_DRIVER_DYNAMIC_DEV         0x0008
 #define TTY_DRIVER_DEVPTS_MEM          0x0010
+#define TTY_DRIVER_HARDWARE_BREAK      0x0020
 
 /* tty driver types */
 #define TTY_DRIVER_TYPE_SYSTEM         0x0001
index 973386d..cdf338d 100644 (file)
@@ -36,7 +36,7 @@ struct uio_mem {
        struct uio_map          *map;
 };
 
-#define MAX_UIO_MAPS   5
+#define MAX_UIO_MAPS   5
 
 struct uio_device;
 
@@ -53,6 +53,7 @@ struct uio_device;
  * @mmap:              mmap operation for this uio device
  * @open:              open operation for this uio device
  * @release:           release operation for this uio device
+ * @irqcontrol:                disable/enable irqs when 0/1 is written to /dev/uioX
  */
 struct uio_info {
        struct uio_device       *uio_dev;
@@ -66,6 +67,7 @@ struct uio_info {
        int (*mmap)(struct uio_info *info, struct vm_area_struct *vma);
        int (*open)(struct uio_info *info, struct inode *inode);
        int (*release)(struct uio_info *info, struct inode *inode);
+       int (*irqcontrol)(struct uio_info *info, s32 irq_on);
 };
 
 extern int __must_check
@@ -80,11 +82,11 @@ static inline int __must_check
 extern void uio_unregister_device(struct uio_info *info);
 extern void uio_event_notify(struct uio_info *info);
 
-/* defines for uio_device->irq */
+/* defines for uio_info->irq */
 #define UIO_IRQ_CUSTOM -1
 #define UIO_IRQ_NONE   -2
 
-/* defines for uio_device->memtype */
+/* defines for uio_mem->memtype */
 #define UIO_MEM_NONE   0
 #define UIO_MEM_PHYS   1
 #define UIO_MEM_LOGICAL        2
index 8f891cb..09a3e6a 100644 (file)
@@ -62,7 +62,7 @@
  */
 struct usb_serial_port {
        struct usb_serial       *serial;
-       struct tty_struct       *tty;
+       struct tty_port         port;
        spinlock_t              lock;
        struct mutex            mutex;
        unsigned char           number;
@@ -89,7 +89,6 @@ struct usb_serial_port {
 
        wait_queue_head_t       write_wait;
        struct work_struct      work;
-       int                     open_count;
        char                    throttled;
        char                    throttle_req;
        char                    console;
@@ -217,22 +216,27 @@ struct usb_serial_driver {
        int (*resume)(struct usb_serial *serial);
 
        /* serial function calls */
-       int  (*open)(struct usb_serial_port *port, struct file *filp);
-       void (*close)(struct usb_serial_port *port, struct file *filp);
-       int  (*write)(struct usb_serial_port *port, const unsigned char *buf,
-                     int count);
-       int  (*write_room)(struct usb_serial_port *port);
-       int  (*ioctl)(struct usb_serial_port *port, struct file *file,
+       /* Called by console with tty = NULL and by tty */
+       int  (*open)(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+       void (*close)(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
+       int  (*write)(struct tty_struct *tty, struct usb_serial_port *port,
+                       const unsigned char *buf, int count);
+       /* Called only by the tty layer */
+       int  (*write_room)(struct tty_struct *tty);
+       int  (*ioctl)(struct tty_struct *tty, struct file *file,
                      unsigned int cmd, unsigned long arg);
-       void (*set_termios)(struct usb_serial_port *port, struct ktermios *old);
-       void (*break_ctl)(struct usb_serial_port *port, int break_state);
-       int  (*chars_in_buffer)(struct usb_serial_port *port);
-       void (*throttle)(struct usb_serial_port *port);
-       void (*unthrottle)(struct usb_serial_port *port);
-       int  (*tiocmget)(struct usb_serial_port *port, struct file *file);
-       int  (*tiocmset)(struct usb_serial_port *port, struct file *file,
+       void (*set_termios)(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct ktermios *old);
+       void (*break_ctl)(struct tty_struct *tty, int break_state);
+       int  (*chars_in_buffer)(struct tty_struct *tty);
+       void (*throttle)(struct tty_struct *tty);
+       void (*unthrottle)(struct tty_struct *tty);
+       int  (*tiocmget)(struct tty_struct *tty, struct file *file);
+       int  (*tiocmset)(struct tty_struct *tty, struct file *file,
                         unsigned int set, unsigned int clear);
-
+       /* USB events */
        void (*read_int_callback)(struct urb *urb);
        void (*write_int_callback)(struct urb *urb);
        void (*read_bulk_callback)(struct urb *urb);
@@ -270,19 +274,19 @@ static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
 /* Functions needed by other parts of the usbserial core */
 extern struct usb_serial *usb_serial_get_by_index(unsigned int minor);
 extern void usb_serial_put(struct usb_serial *serial);
-extern int usb_serial_generic_open(struct usb_serial_port *port,
-                                  struct file *filp);
-extern int usb_serial_generic_write(struct usb_serial_port *port,
-                                   const unsigned char *buf, int count);
-extern void usb_serial_generic_close(struct usb_serial_port *port,
-                                    struct file *filp);
+extern int usb_serial_generic_open(struct tty_struct *tty,
+               struct usb_serial_port *port, struct file *filp);
+extern int usb_serial_generic_write(struct tty_struct *tty,
+       struct usb_serial_port *port, const unsigned char *buf, int count);
+extern void usb_serial_generic_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp);
 extern int usb_serial_generic_resume(struct usb_serial *serial);
-extern int usb_serial_generic_write_room(struct usb_serial_port *port);
-extern int usb_serial_generic_chars_in_buffer(struct usb_serial_port *port);
+extern int usb_serial_generic_write_room(struct tty_struct *tty);
+extern int usb_serial_generic_chars_in_buffer(struct tty_struct *tty);
 extern void usb_serial_generic_read_bulk_callback(struct urb *urb);
 extern void usb_serial_generic_write_bulk_callback(struct urb *urb);
-extern void usb_serial_generic_throttle(struct usb_serial_port *port);
-extern void usb_serial_generic_unthrottle(struct usb_serial_port *port);
+extern void usb_serial_generic_throttle(struct tty_struct *tty);
+extern void usb_serial_generic_unthrottle(struct tty_struct *tty);
 extern void usb_serial_generic_shutdown(struct usb_serial *serial);
 extern int usb_serial_generic_register(int debug);
 extern void usb_serial_generic_deregister(void);
index 1834fdf..a594bac 100644 (file)
@@ -623,7 +623,7 @@ struct Scsi_Host {
        /*
         * Optional work queue to be utilized by the transport
         */
-       char work_q_name[KOBJ_NAME_LEN];
+       char work_q_name[20];
        struct workqueue_struct *work_q;
 
        /*
index 06f72ba..878373c 100644 (file)
@@ -489,9 +489,9 @@ struct fc_host_attrs {
        u16 npiv_vports_inuse;
 
        /* work queues for rport state manipulation */
-       char work_q_name[KOBJ_NAME_LEN];
+       char work_q_name[20];
        struct workqueue_struct *work_q;
-       char devloss_work_q_name[KOBJ_NAME_LEN];
+       char devloss_work_q_name[20];
        struct workqueue_struct *devloss_work_q;
 };
 
index f5444e0..8b6c91d 100644 (file)
@@ -198,7 +198,7 @@ struct iscsi_cls_host {
        atomic_t nr_scans;
        struct mutex mutex;
        struct workqueue_struct *scan_workq;
-       char scan_workq_name[KOBJ_NAME_LEN];
+       char scan_workq_name[20];
 };
 
 extern void iscsi_host_for_each_session(struct Scsi_Host *shost,
index 459d601..d2cc67d 100644 (file)
@@ -679,7 +679,9 @@ restart:
                                if (apn == b->pn) {
                                        cpus_or(*dp, *dp, b->cpus_allowed);
                                        b->pn = -1;
-                                       update_domain_attr(dattr, b);
+                                       if (dattr)
+                                               update_domain_attr(dattr
+                                                                  + nslot, b);
                                }
                        }
                        nslot++;
index 092e4c6..a56f629 100644 (file)
@@ -297,8 +297,8 @@ static int test_func(void *data)
  *
  * opcode:data
  */
-static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf,
-                                 size_t count)
+static ssize_t sysfs_test_command(struct sys_device *dev, struct sysdev_attribute *attr,
+                                 const char *buf, size_t count)
 {
        struct sched_param schedpar;
        struct test_thread_data *td;
@@ -360,7 +360,8 @@ static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf,
  * @dev:       thread to query
  * @buf:       char buffer to be filled with thread status info
  */
-static ssize_t sysfs_test_status(struct sys_device *dev, char *buf)
+static ssize_t sysfs_test_status(struct sys_device *dev, struct sysdev_attribute *attr,
+                                char *buf)
 {
        struct test_thread_data *td;
        struct task_struct *tsk;
index 99e6d85..b1104ea 100644 (file)
@@ -7737,11 +7737,13 @@ static ssize_t sched_power_savings_store(const char *buf, size_t count, int smt)
 }
 
 #ifdef CONFIG_SCHED_MC
-static ssize_t sched_mc_power_savings_show(struct sys_device *dev, char *page)
+static ssize_t sched_mc_power_savings_show(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *page)
 {
        return sprintf(page, "%u\n", sched_mc_power_savings);
 }
 static ssize_t sched_mc_power_savings_store(struct sys_device *dev,
+                                           struct sysdev_attribute *attr,
                                            const char *buf, size_t count)
 {
        return sched_power_savings_store(buf, count, 0);
@@ -7751,11 +7753,13 @@ static SYSDEV_ATTR(sched_mc_power_savings, 0644, sched_mc_power_savings_show,
 #endif
 
 #ifdef CONFIG_SCHED_SMT
-static ssize_t sched_smt_power_savings_show(struct sys_device *dev, char *page)
+static ssize_t sched_smt_power_savings_show(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *page)
 {
        return sprintf(page, "%u\n", sched_smt_power_savings);
 }
 static ssize_t sched_smt_power_savings_store(struct sys_device *dev,
+                                            struct sysdev_attribute *attr,
                                             const char *buf, size_t count)
 {
        return sched_power_savings_store(buf, count, 1);
index 5b9b467..0fea0ee 100644 (file)
@@ -59,6 +59,7 @@ cond_syscall(sys_epoll_create);
 cond_syscall(sys_epoll_ctl);
 cond_syscall(sys_epoll_wait);
 cond_syscall(sys_epoll_pwait);
+cond_syscall(compat_sys_epoll_pwait);
 cond_syscall(sys_semget);
 cond_syscall(sys_semop);
 cond_syscall(sys_semtimedop);
index dadde53..b1c2da8 100644 (file)
@@ -376,7 +376,8 @@ void clocksource_unregister(struct clocksource *cs)
  * Provides sysfs interface for listing current clocksource.
  */
 static ssize_t
-sysfs_show_current_clocksources(struct sys_device *dev, char *buf)
+sysfs_show_current_clocksources(struct sys_device *dev,
+                               struct sysdev_attribute *attr, char *buf)
 {
        ssize_t count = 0;
 
@@ -397,6 +398,7 @@ sysfs_show_current_clocksources(struct sys_device *dev, char *buf)
  * clocksource selction.
  */
 static ssize_t sysfs_override_clocksource(struct sys_device *dev,
+                                         struct sysdev_attribute *attr,
                                          const char *buf, size_t count)
 {
        struct clocksource *ovr = NULL;
@@ -449,7 +451,9 @@ static ssize_t sysfs_override_clocksource(struct sys_device *dev,
  * Provides sysfs interface for listing registered clocksources
  */
 static ssize_t
-sysfs_show_available_clocksources(struct sys_device *dev, char *buf)
+sysfs_show_available_clocksources(struct sys_device *dev,
+                                 struct sysdev_attribute *attr,
+                                 char *buf)
 {
        struct clocksource *src;
        ssize_t count = 0;
index df27132..ba106db 100644 (file)
@@ -74,6 +74,9 @@ config DEBUG_FS
          debugging files into.  Enable this option to be able to read and
          write to these files.
 
+         For detailed documentation on the debugfs API, see
+         Documentation/DocBook/filesystems.
+
          If unsure, say N.
 
 config HEADERS_CHECK
index dcade05..7444015 100644 (file)
@@ -216,13 +216,19 @@ static int kobject_add_internal(struct kobject *kobj)
 static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
                                  va_list vargs)
 {
-       /* Free the old name, if necessary. */
-       kfree(kobj->name);
+       const char *old_name = kobj->name;
+       char *s;
 
        kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
        if (!kobj->name)
                return -ENOMEM;
 
+       /* ewww... some of these buggers have '/' in the name ... */
+       s = strchr(kobj->name, '/');
+       if (s)
+               s[0] = '!';
+
+       kfree(old_name);
        return 0;
 }
 
index 2fa545a..9f8d599 100644 (file)
@@ -245,7 +245,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
                if (retval)
                        goto exit;
 
-               call_usermodehelper(argv[0], argv, env->envp, UMH_WAIT_EXEC);
+               retval = call_usermodehelper(argv[0], argv,
+                                            env->envp, UMH_WAIT_EXEC);
        }
 
 exit:
index 844ca5f..c85bf8f 100644 (file)
@@ -398,10 +398,6 @@ int hci_register_sysfs(struct hci_dev *hdev)
                if (device_create_file(dev, bt_attrs[i]) < 0)
                        BT_ERR("Failed to create device attribute");
 
-       if (sysfs_create_link(&bt_class->subsys.kobj,
-                               &dev->kobj, kobject_name(&dev->kobj)) < 0)
-               BT_ERR("Failed to create class symlink");
-
        return 0;
 }
 
@@ -409,9 +405,6 @@ void hci_unregister_sysfs(struct hci_dev *hdev)
 {
        BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type);
 
-       sysfs_remove_link(&bt_class->subsys.kobj,
-                                       kobject_name(&hdev->dev.kobj));
-
        device_del(&hdev->dev);
 }
 
index 9392116..e6cf7a4 100644 (file)
@@ -124,7 +124,7 @@ static int fw_setup_class_device(struct class_device *class_dev,
        class_dev->class_id[BUS_ID_SIZE-1] = '\0';
        class_dev->dev = device;
 
-       class_dev->class = &firmware_class,
+       class_dev->class = &firmware_class;
        class_set_devdata(class_dev, fw_priv);
        retval = class_device_register(class_dev);
        if (retval) {
index b0a1b4f..7395c0b 100644 (file)
@@ -211,7 +211,7 @@ static struct foo_obj *create_foo_obj(const char *name)
         */
        retval = kobject_init_and_add(&foo->kobj, &foo_ktype, NULL, "%s", name);
        if (retval) {
-               kfree(foo);
+               kobject_put(&foo->kobj);
                return NULL;
        }
 
index 17092d6..9ee9783 100644 (file)
@@ -101,6 +101,7 @@ quiet_cmd_kernel-mod = MODPOST $@
       cmd_kernel-mod = $(modpost) $@
 
 vmlinux.o: FORCE
+       @rm -fr $(kernelmarkersfile)
        $(call cmd,kernel-mod)
 
 # Declare generated files as targets for modpost
index 37d5c36..1fcaf32 100644 (file)
@@ -340,11 +340,18 @@ static int do_acpi_entry(const char *filename,
 }
 
 /* looks like: "pnp:dD" */
-static int do_pnp_entry(const char *filename,
-                       struct pnp_device_id *id, char *alias)
+static void do_pnp_device_entry(void *symval, unsigned long size,
+                               struct module *mod)
 {
-       sprintf(alias, "pnp:d%s*", id->id);
-       return 1;
+       const unsigned long id_size = sizeof(struct pnp_device_id);
+       const struct pnp_device_id *id = symval;
+
+       device_id_check(mod->name, "pnp", size, id_size, symval);
+
+       buf_printf(&mod->dev_table_buf,
+                  "MODULE_ALIAS(\"pnp:d%s*\");\n", id->id);
+       buf_printf(&mod->dev_table_buf,
+                  "MODULE_ALIAS(\"acpi*:%s:*\");\n", id->id);
 }
 
 /* looks like: "pnp:dD" for every device of the card */
@@ -388,9 +395,12 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
                        }
 
                        /* add an individual alias for every device entry */
-                       if (!dup)
+                       if (!dup) {
                                buf_printf(&mod->dev_table_buf,
                                           "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
+                               buf_printf(&mod->dev_table_buf,
+                                          "MODULE_ALIAS(\"acpi*:%s:*\");\n", id);
+                       }
                }
        }
 }
@@ -701,9 +711,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
                         sizeof(struct acpi_device_id), "acpi",
                         do_acpi_entry, mod);
        else if (sym_is(symname, "__mod_pnp_device_table"))
-               do_table(symval, sym->st_size,
-                        sizeof(struct pnp_device_id), "pnp",
-                        do_pnp_entry, mod);
+               do_pnp_device_entry(symval, sym->st_size, mod);
        else if (sym_is(symname, "__mod_pnp_card_device_table"))
                do_pnp_card_entries(symval, sym->st_size, mod);
        else if (sym_is(symname, "__mod_pcmcia_device_table"))
index a07f91a..8f038e6 100644 (file)
@@ -1992,7 +1992,8 @@ static void read_markers(const char *fname)
                        mod->skip = 1;
                }
 
-               add_marker(mod, marker, fmt);
+               if (!mod->skip)
+                       add_marker(mod, marker, fmt);
        }
        return;
 fail:
index 5c254d4..df46bbc 100644 (file)
@@ -548,8 +548,9 @@ int snd_card_register(struct snd_card *card)
        snd_assert(card != NULL, return -EINVAL);
 #ifndef CONFIG_SYSFS_DEPRECATED
        if (!card->card_dev) {
-               card->card_dev = device_create(sound_class, card->dev, 0,
-                                              "card%i", card->number);
+               card->card_dev = device_create_drvdata(sound_class, card->dev,
+                                                      MKDEV(0, 0), NULL,
+                                                      "card%i", card->number);
                if (IS_ERR(card->card_dev))
                        card->card_dev = NULL;
        }
index a9c23b2..7d89c08 100644 (file)
@@ -560,17 +560,19 @@ static int __init oss_init(void)
        sound_dmap_flag = (dmabuf > 0 ? 1 : 0);
 
        for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
-               device_create(sound_class, NULL,
-                             MKDEV(SOUND_MAJOR, dev_list[i].minor),
-                             "%s", dev_list[i].name);
+               device_create_drvdata(sound_class, NULL,
+                                     MKDEV(SOUND_MAJOR, dev_list[i].minor),
+                                     NULL, "%s", dev_list[i].name);
 
                if (!dev_list[i].num)
                        continue;
 
                for (j = 1; j < *dev_list[i].num; j++)
-                       device_create(sound_class, NULL,
-                                     MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
-                                     "%s%d", dev_list[i].name, j);
+                       device_create_drvdata(sound_class, NULL,
+                                             MKDEV(SOUND_MAJOR,
+                                                   dev_list[i].minor + (j*0x10)),
+                                             NULL,
+                                             "%s%d", dev_list[i].name, j);
        }
 
        if (sound_nblocks >= 1024)
index dcfc1d5..1b04259 100644 (file)
@@ -171,8 +171,9 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati
        else
                sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);
 
-       device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
-                     s->name+6);
+       device_create_drvdata(sound_class, dev,
+                             MKDEV(SOUND_MAJOR, s->unit_minor),
+                             NULL, s->name+6);
        return r;
 
  fail: