Merge tag 'iio-for-3.17d' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Fourth round of IIO new drivers, functionality and cleanups for the 3.17 cycle

New functionality
* A new modifier to indicate that a rotation is relative to either
  true or magnetic north.  This is to be used by some magnetometers
  that provide data in this way.
* hid magnetometer now supports output rotations from various variants on
  North
* HMC5843 driver converted to regmap and reworked to allow easy support
  of other similar devices.  Support for HMC5983 added via both i2c and SPI.
* Rework of Exynos driver to simplify extension to support more devices.
* Addition of support for the Exynos3250 ADC (which requires an additional
  clock)  Support for quite a few more devices on its way.

Cleanups
* ad7997 - a number of cleanups and tweaks to how the events are controlled
  to make it more intuitive.
* kxcjk - cleanups and minor fixes for this new driver.
diff --git a/Documentation/Changes b/Documentation/Changes
index 2254db0..227bec8 100644
--- a/Documentation/Changes
+++ b/Documentation/Changes
@@ -280,12 +280,9 @@
 mcelog
 ------
 
-In Linux 2.6.31+ the i386 kernel needs to run the mcelog utility
-as a regular cronjob similar to the x86-64 kernel to process and log
-machine check events when CONFIG_X86_NEW_MCE is enabled. Machine check
-events are errors reported by the CPU. Processing them is strongly encouraged.
-All x86-64 kernels since 2.6.4 require the mcelog utility to
-process machine checks.
+On x86 kernels the mcelog utility is needed to process and log machine check
+events when CONFIG_X86_MCE is enabled. Machine check events are errors reported
+by the CPU. Processing them is strongly encouraged.
 
 Getting updated software
 ========================
diff --git a/Documentation/DocBook/gadget.tmpl b/Documentation/DocBook/gadget.tmpl
index 4017f14..2c425d7 100644
--- a/Documentation/DocBook/gadget.tmpl
+++ b/Documentation/DocBook/gadget.tmpl
@@ -708,7 +708,7 @@
 
 <para>Systems need specialized hardware support to implement OTG,
 notably including a special <emphasis>Mini-AB</emphasis> jack
-and associated transciever to support <emphasis>Dual-Role</emphasis>
+and associated transceiver to support <emphasis>Dual-Role</emphasis>
 operation:
 they can act either as a host, using the standard
 Linux-USB host side driver stack,
diff --git a/Documentation/DocBook/genericirq.tmpl b/Documentation/DocBook/genericirq.tmpl
index 46347f6..59fb5c0 100644
--- a/Documentation/DocBook/genericirq.tmpl
+++ b/Documentation/DocBook/genericirq.tmpl
@@ -182,7 +182,7 @@
 	<para>
 	Each interrupt is described by an interrupt descriptor structure
 	irq_desc. The interrupt is referenced by an 'unsigned int' numeric
-	value which selects the corresponding interrupt decription structure
+	value which selects the corresponding interrupt description structure
 	in the descriptor structures array.
 	The descriptor structure contains status information and pointers
 	to the interrupt flow method and the interrupt chip structure
@@ -470,7 +470,7 @@
      <para>
        To avoid copies of identical implementations of IRQ chips the
        core provides a configurable generic interrupt chip
-       implementation. Developers should check carefuly whether the
+       implementation. Developers should check carefully whether the
        generic chip fits their needs before implementing the same
        functionality slightly differently themselves.
      </para>
diff --git a/Documentation/DocBook/kernel-locking.tmpl b/Documentation/DocBook/kernel-locking.tmpl
index 19f2a5a..e584ee1 100644
--- a/Documentation/DocBook/kernel-locking.tmpl
+++ b/Documentation/DocBook/kernel-locking.tmpl
@@ -1760,7 +1760,7 @@
 </para>
 
 <para>
-There is a furthur optimization possible here: remember our original
+There is a further optimization possible here: remember our original
 cache code, where there were no reference counts and the caller simply
 held the lock whenever using the object?  This is still possible: if
 you hold the lock, no one can delete the object, so you don't need to
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl
index deb71ba..d7fcdc5 100644
--- a/Documentation/DocBook/libata.tmpl
+++ b/Documentation/DocBook/libata.tmpl
@@ -677,7 +677,7 @@
 
 	<listitem>
 	<para>
-	ATA_QCFLAG_ACTIVE is clared from qc->flags.
+	ATA_QCFLAG_ACTIVE is cleared from qc->flags.
 	</para>
 	</listitem>
 
@@ -708,7 +708,7 @@
 
 	   <listitem>
 	   <para>
-	   qc->waiting is claread &amp; completed (in that order).
+	   qc->waiting is cleared &amp; completed (in that order).
 	   </para>
 	   </listitem>
 
@@ -1163,7 +1163,7 @@
 
 	<para>
 	Once sense data is acquired, this type of errors can be
-	handled similary to other SCSI errors.  Note that sense data
+	handled similarly to other SCSI errors.  Note that sense data
 	may indicate ATA bus error (e.g. Sense Key 04h HARDWARE ERROR
 	&amp;&amp; ASC/ASCQ 47h/00h SCSI PARITY ERROR).  In such
 	cases, the error should be considered as an ATA bus error and
diff --git a/Documentation/DocBook/media_api.tmpl b/Documentation/DocBook/media_api.tmpl
index 4decb46..03f9a1f 100644
--- a/Documentation/DocBook/media_api.tmpl
+++ b/Documentation/DocBook/media_api.tmpl
@@ -68,7 +68,7 @@
 		several digital tv standards. While it is called as DVB API,
 		in fact it covers several different video standards including
 		DVB-T, DVB-S, DVB-C and ATSC. The API is currently being updated
-		to documment support also for DVB-S2, ISDB-T and ISDB-S.</para>
+		to document support also for DVB-S2, ISDB-T and ISDB-S.</para>
 	<para>The third part covers the Remote Controller API.</para>
 	<para>The fourth part covers the Media Controller API.</para>
 	<para>For additional information and for the latest development code,
diff --git a/Documentation/DocBook/mtdnand.tmpl b/Documentation/DocBook/mtdnand.tmpl
index cd11926..7da8f04 100644
--- a/Documentation/DocBook/mtdnand.tmpl
+++ b/Documentation/DocBook/mtdnand.tmpl
@@ -91,7 +91,7 @@
 		<listitem><para>
 	  	[MTD Interface]</para><para>
 		These functions provide the interface to the MTD kernel API. 
-		They are not replacable and provide functionality
+		They are not replaceable and provide functionality
 		which is complete hardware independent.
 		</para></listitem>
 		<listitem><para>
@@ -100,14 +100,14 @@
 		</para></listitem>
 		<listitem><para>
 	  	[GENERIC]</para><para>
-		Generic functions are not replacable and provide functionality
+		Generic functions are not replaceable and provide functionality
 		which is complete hardware independent.
 		</para></listitem>
 		<listitem><para>
 	  	[DEFAULT]</para><para>
 		Default functions provide hardware related functionality which is suitable
 		for most of the implementations. These functions can be replaced by the
-		board driver if neccecary. Those functions are called via pointers in the
+		board driver if necessary. Those functions are called via pointers in the
 		NAND chip description structure. The board driver can set the functions which
 		should be replaced by board dependent functions before calling nand_scan().
 		If the function pointer is NULL on entry to nand_scan() then the pointer
@@ -264,7 +264,7 @@
 			is set up nand_scan() is called. This function tries to
 			detect and identify then chip. If a chip is found all the
 			internal data fields are initialized accordingly.
-			The structure(s) have to be zeroed out first and then filled with the neccecary 
+			The structure(s) have to be zeroed out first and then filled with the necessary
 			information about the device.
 		</para>
 		<programlisting>
@@ -327,7 +327,7 @@
 	<sect1 id="Exit_function">
 		<title>Exit function</title>
 		<para>
-			The exit function is only neccecary if the driver is
+			The exit function is only necessary if the driver is
 			compiled as a module. It releases all resources which
 			are held by the chip driver and unregisters the partitions
 			in the MTD layer.
@@ -494,7 +494,7 @@
 				in this case. See rts_from4.c and diskonchip.c for 
 				implementation reference. In those cases we must also
 				use bad block tables on FLASH, because the ECC layout is
-				interferring with the bad block marker positions.
+				interfering with the bad block marker positions.
 				See bad block table support for details.
 			</para>
 		</sect2>
@@ -542,7 +542,7 @@
 		<para>	
 			nand_scan() calls the function nand_default_bbt(). 
 			nand_default_bbt() selects appropriate default
-			bad block table desriptors depending on the chip information
+			bad block table descriptors depending on the chip information
 			which was retrieved by nand_scan().
 		</para>
 		<para>
@@ -554,7 +554,7 @@
 		<sect2 id="Flash_based_tables">
 			<title>Flash based tables</title>
 			<para>
-				It may be desired or neccecary to keep a bad block table in FLASH. 
+				It may be desired or necessary to keep a bad block table in FLASH.
 				For AG-AND chips this is mandatory, as they have no factory marked
 				bad blocks. They have factory marked good blocks. The marker pattern
 				is erased when the block is erased to be reused. So in case of
@@ -565,10 +565,10 @@
 				of the blocks.
 			</para>
 			<para>
-				The blocks in which the tables are stored are procteted against
+				The blocks in which the tables are stored are protected against
 				accidental access by marking them bad in the memory bad block
 				table. The bad block table management functions are allowed
-				to circumvernt this protection.
+				to circumvent this protection.
 			</para>
 			<para>
 				The simplest way to activate the FLASH based bad block table support 
@@ -592,7 +592,7 @@
 				User defined tables are created by filling out a 
 				nand_bbt_descr structure and storing the pointer in the
 				nand_chip structure member bbt_td before calling nand_scan(). 
-				If a mirror table is neccecary a second structure must be
+				If a mirror table is necessary a second structure must be
 				created and a pointer to this structure must be stored
 				in bbt_md inside the nand_chip structure. If the bbt_md 
 				member is set to NULL then only the main table is used
@@ -666,7 +666,7 @@
 				<para>
 				For automatic placement some blocks must be reserved for
 				bad block table storage. The number of reserved blocks is defined 
-				in the maxblocks member of the babd block table description structure.
+				in the maxblocks member of the bad block table description structure.
 				Reserving 4 blocks for mirrored tables should be a reasonable number. 
 				This also limits the number of blocks which are scanned for the bad
 				block table ident pattern.
@@ -1068,11 +1068,11 @@
   <chapter id="filesystems">
      	<title>Filesystem support</title>
 	<para>
-		The NAND driver provides all neccecary functions for a
+		The NAND driver provides all necessary functions for a
 		filesystem via the MTD interface.
 	</para>
 	<para>
-		Filesystems must be aware of the NAND pecularities and
+		Filesystems must be aware of the NAND peculiarities and
 		restrictions. One major restrictions of NAND Flash is, that you cannot 
 		write as often as you want to a page. The consecutive writes to a page, 
 		before erasing it again, are restricted to 1-3 writes, depending on the 
@@ -1222,7 +1222,7 @@
 #define NAND_BBT_VERSION	0x00000100
 /* Create a bbt if none axists */
 #define NAND_BBT_CREATE		0x00000200
-/* Write bbt if neccecary */
+/* Write bbt if necessary */
 #define NAND_BBT_WRITE		0x00001000
 /* Read and write back block contents when writing bbt */
 #define NAND_BBT_SAVECONTENT	0x00002000
diff --git a/Documentation/DocBook/regulator.tmpl b/Documentation/DocBook/regulator.tmpl
index 346e552..3b08a08 100644
--- a/Documentation/DocBook/regulator.tmpl
+++ b/Documentation/DocBook/regulator.tmpl
@@ -155,7 +155,7 @@
        release regulators.  Functions are
        provided to <link linkend='API-regulator-enable'>enable</link>
        and <link linkend='API-regulator-disable'>disable</link> the
-       reguator and to get and set the runtime parameters of the
+       regulator and to get and set the runtime parameters of the
        regulator.
      </para>
      <para>
diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
index 9561815..bbe9c1f 100644
--- a/Documentation/DocBook/uio-howto.tmpl
+++ b/Documentation/DocBook/uio-howto.tmpl
@@ -766,10 +766,10 @@
 	<para>
 	The dynamic memory regions will be allocated when the UIO device file,
 	<varname>/dev/uioX</varname> is opened.
-	Simiar to static memory resources, the memory region information for
+	Similar to static memory resources, the memory region information for
 	dynamic regions is then visible via sysfs at
 	<varname>/sys/class/uio/uioX/maps/mapY/*</varname>.
-	The dynmaic memory regions will be freed when the UIO device file is
+	The dynamic memory regions will be freed when the UIO device file is
 	closed. When no processes are holding the device file open, the address
 	returned to userspace is ~0.
 	</para>
diff --git a/Documentation/DocBook/usb.tmpl b/Documentation/DocBook/usb.tmpl
index 8d57c18..85fc0e2 100644
--- a/Documentation/DocBook/usb.tmpl
+++ b/Documentation/DocBook/usb.tmpl
@@ -153,7 +153,7 @@
 
 	<listitem><para>The Linux USB API supports synchronous calls for
 	control and bulk messages.
-	It also supports asynchnous calls for all kinds of data transfer,
+	It also supports asynchronous calls for all kinds of data transfer,
 	using request structures called "URBs" (USB Request Blocks).
 	</para></listitem>
 
diff --git a/Documentation/DocBook/writing-an-alsa-driver.tmpl b/Documentation/DocBook/writing-an-alsa-driver.tmpl
index d0056a4..6f639d9 100644
--- a/Documentation/DocBook/writing-an-alsa-driver.tmpl
+++ b/Documentation/DocBook/writing-an-alsa-driver.tmpl
@@ -5696,7 +5696,7 @@
 	suspending the PCM operations via
 	<function>snd_pcm_suspend_all()</function> or
 	<function>snd_pcm_suspend()</function>.  It means that the PCM
-	streams are already stoppped when the register snapshot is
+	streams are already stopped when the register snapshot is
 	taken.  But, remember that you don't have to restart the PCM
 	stream in the resume callback. It'll be restarted via 
 	trigger call with <constant>SNDRV_PCM_TRIGGER_RESUME</constant>
diff --git a/Documentation/cpu-freq/intel-pstate.txt b/Documentation/cpu-freq/intel-pstate.txt
index e742d21..a69ffe1 100644
--- a/Documentation/cpu-freq/intel-pstate.txt
+++ b/Documentation/cpu-freq/intel-pstate.txt
@@ -15,10 +15,13 @@
 /sys/devices/system/cpu/intel_pstate/
 
       max_perf_pct: limits the maximum P state that will be requested by
-      the driver stated as a percentage of the available performance.
+      the driver stated as a percentage of the available performance. The
+      available (P states) performance may be reduced by the no_turbo
+      setting described below.
 
       min_perf_pct: limits the minimum P state that will be  requested by
-      the driver stated as a percentage of the available performance.
+      the driver stated as a percentage of the max (non-turbo)
+      performance level.
 
       no_turbo: limits the driver to selecting P states below the turbo
       frequency range.
diff --git a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
index 5216b41..8b4f7b7f 100644
--- a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
+++ b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt
@@ -9,6 +9,18 @@
 - reg: physical base address of the controller and length of memory mapped
     region.
 
+Optional Properties:
+- clocks: List of clock handles. The parent clocks of the input clocks to the
+	devices in this power domain are set to oscclk before power gating
+	and restored back after powering on a domain. This is required for
+	all domains which are powered on and off and not required for unused
+	domains.
+- clock-names: The following clocks can be specified:
+	- oscclk: Oscillator clock.
+	- pclkN, clkN: Pairs of parent of input clock and input clock to the
+		devices in this power domain. Maximum of 4 pairs (N = 0 to 3)
+		are supported currently.
+
 Node of a device using power domains must have a samsung,power-domain property
 defined with a phandle to respective power domain.
 
@@ -19,6 +31,14 @@
 		reg = <0x10023C00 0x10>;
 	};
 
+	mfc_pd: power-domain@10044060 {
+		compatible = "samsung,exynos4210-pd";
+		reg = <0x10044060 0x20>;
+		clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_SW_ACLK333>,
+			<&clock CLK_MOUT_USER_ACLK333>;
+		clock-names = "oscclk", "pclk0", "clk0";
+	};
+
 Example of the node using power domain:
 
 	node {
diff --git a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
index 64fd7de..b355660 100644
--- a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
+++ b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
@@ -4,6 +4,13 @@
 
   - compatible: Must contain one of the following:
 
+    - "renesas,scifa-sh73a0" for SH73A0 (SH-Mobile AG5) SCIFA compatible UART.
+    - "renesas,scifb-sh73a0" for SH73A0 (SH-Mobile AG5) SCIFB compatible UART.
+    - "renesas,scifa-r8a73a4" for R8A73A4 (R-Mobile APE6) SCIFA compatible UART.
+    - "renesas,scifb-r8a73a4" for R8A73A4 (R-Mobile APE6) SCIFB compatible UART.
+    - "renesas,scifa-r8a7740" for R8A7740 (R-Mobile A1) SCIFA compatible UART.
+    - "renesas,scifb-r8a7740" for R8A7740 (R-Mobile A1) SCIFB compatible UART.
+    - "renesas,scif-r8a7778" for R8A7778 (R-Car M1) SCIF compatible UART.
     - "renesas,scif-r8a7779" for R8A7779 (R-Car H1) SCIF compatible UART.
     - "renesas,scif-r8a7790" for R8A7790 (R-Car H2) SCIF compatible UART.
     - "renesas,scifa-r8a7790" for R8A7790 (R-Car H2) SCIFA compatible UART.
diff --git a/Documentation/laptops/00-INDEX b/Documentation/laptops/00-INDEX
index d13b9a9..d399ae1 100644
--- a/Documentation/laptops/00-INDEX
+++ b/Documentation/laptops/00-INDEX
@@ -8,8 +8,8 @@
 	- information on hard disk shock protection.
 dslm.c
 	- Simple Disk Sleep Monitor program
-hpfall.c
-	- (HP) laptop accelerometer program for disk protection.
+freefall.c
+	- (HP/DELL) laptop accelerometer program for disk protection.
 laptop-mode.txt
 	- how to conserve battery power using laptop-mode.
 sony-laptop.txt
diff --git a/Documentation/laptops/hpfall.c b/Documentation/laptops/freefall.c
similarity index 65%
rename from Documentation/laptops/hpfall.c
rename to Documentation/laptops/freefall.c
index b85dbba..aab2ff0 100644
--- a/Documentation/laptops/hpfall.c
+++ b/Documentation/laptops/freefall.c
@@ -1,7 +1,9 @@
-/* Disk protection for HP machines.
+/* Disk protection for HP/DELL machines.
  *
  * Copyright 2008 Eric Piel
  * Copyright 2009 Pavel Machek <pavel@ucw.cz>
+ * Copyright 2012 Sonal Santan
+ * Copyright 2014 Pali Rohár <pali.rohar@gmail.com>
  *
  * GPLv2.
  */
@@ -18,24 +20,31 @@
 #include <signal.h>
 #include <sys/mman.h>
 #include <sched.h>
+#include <syslog.h>
 
-char unload_heads_path[64];
+static int noled;
+static char unload_heads_path[64];
+static char device_path[32];
+static const char app_name[] = "FREE FALL";
 
-int set_unload_heads_path(char *device)
+static int set_unload_heads_path(char *device)
 {
 	char devname[64];
 
 	if (strlen(device) <= 5 || strncmp(device, "/dev/", 5) != 0)
 		return -EINVAL;
-	strncpy(devname, device + 5, sizeof(devname));
+	strncpy(devname, device + 5, sizeof(devname) - 1);
+	strncpy(device_path, device, sizeof(device_path) - 1);
 
 	snprintf(unload_heads_path, sizeof(unload_heads_path) - 1,
 				"/sys/block/%s/device/unload_heads", devname);
 	return 0;
 }
-int valid_disk(void)
+
+static int valid_disk(void)
 {
 	int fd = open(unload_heads_path, O_RDONLY);
+
 	if (fd < 0) {
 		perror(unload_heads_path);
 		return 0;
@@ -45,43 +54,54 @@
 	return 1;
 }
 
-void write_int(char *path, int i)
+static void write_int(char *path, int i)
 {
 	char buf[1024];
 	int fd = open(path, O_RDWR);
+
 	if (fd < 0) {
 		perror("open");
 		exit(1);
 	}
+
 	sprintf(buf, "%d", i);
+
 	if (write(fd, buf, strlen(buf)) != strlen(buf)) {
 		perror("write");
 		exit(1);
 	}
+
 	close(fd);
 }
 
-void set_led(int on)
+static void set_led(int on)
 {
+	if (noled)
+		return;
 	write_int("/sys/class/leds/hp::hddprotect/brightness", on);
 }
 
-void protect(int seconds)
+static void protect(int seconds)
 {
+	const char *str = (seconds == 0) ? "Unparked" : "Parked";
+
 	write_int(unload_heads_path, seconds*1000);
+	syslog(LOG_INFO, "%s %s disk head\n", str, device_path);
 }
 
-int on_ac(void)
+static int on_ac(void)
 {
-//	/sys/class/power_supply/AC0/online
+	/* /sys/class/power_supply/AC0/online */
+	return 1;
 }
 
-int lid_open(void)
+static int lid_open(void)
 {
-//	/proc/acpi/button/lid/LID/state
+	/* /proc/acpi/button/lid/LID/state */
+	return 1;
 }
 
-void ignore_me(void)
+static void ignore_me(int signum)
 {
 	protect(0);
 	set_led(0);
@@ -90,6 +110,7 @@
 int main(int argc, char **argv)
 {
 	int fd, ret;
+	struct stat st;
 	struct sched_param param;
 
 	if (argc == 1)
@@ -111,7 +132,16 @@
 		return EXIT_FAILURE;
 	}
 
-	daemon(0, 0);
+	if (stat("/sys/class/leds/hp::hddprotect/brightness", &st))
+		noled = 1;
+
+	if (daemon(0, 0) != 0) {
+		perror("daemon");
+		return EXIT_FAILURE;
+	}
+
+	openlog(app_name, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
+
 	param.sched_priority = sched_get_priority_max(SCHED_FIFO);
 	sched_setscheduler(0, SCHED_FIFO, &param);
 	mlockall(MCL_CURRENT|MCL_FUTURE);
@@ -141,6 +171,7 @@
 			alarm(20);
 	}
 
+	closelog();
 	close(fd);
 	return EXIT_SUCCESS;
 }
diff --git a/MAINTAINERS b/MAINTAINERS
index e2d311c..6d2c52e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1314,6 +1314,20 @@
 Q:	http://patchwork.kernel.org/project/linux-sh/list/
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git next
 S:	Supported
+F:	arch/arm/boot/dts/emev2*
+F:	arch/arm/boot/dts/r7s*
+F:	arch/arm/boot/dts/r8a*
+F:	arch/arm/boot/dts/sh*
+F:	arch/arm/configs/ape6evm_defconfig
+F:	arch/arm/configs/armadillo800eva_defconfig
+F:	arch/arm/configs/bockw_defconfig
+F:	arch/arm/configs/genmai_defconfig
+F:	arch/arm/configs/koelsch_defconfig
+F:	arch/arm/configs/kzm9g_defconfig
+F:	arch/arm/configs/lager_defconfig
+F:	arch/arm/configs/mackerel_defconfig
+F:	arch/arm/configs/marzen_defconfig
+F:	arch/arm/configs/shmobile_defconfig
 F:	arch/arm/mach-shmobile/
 F:	drivers/sh/
 
@@ -6788,7 +6802,7 @@
 
 PCI DRIVER FOR IMX6
 M:	Richard Zhu <r65037@freescale.com>
-M:	Shawn Guo <shawn.guo@linaro.org>
+M:	Shawn Guo <shawn.guo@freescale.com>
 L:	linux-pci@vger.kernel.org
 L:	linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:	Maintained
@@ -8528,11 +8542,6 @@
 S:	Odd Fixes
 F:	drivers/staging/ft1000/
 
-STAGING - FRONTIER TRANZPORT AND ALPHATRACK
-M:	David Täht <d@teklibre.com>
-S:	Odd Fixes
-F:	drivers/staging/frontier/
-
 STAGING - GO7007 MPEG CODEC
 M:	Hans Verkuil <hans.verkuil@cisco.com>
 S:	Maintained
@@ -8605,21 +8614,11 @@
 M:	Chris Brannon <chris@the-brannons.com>
 M:	Kirk Reiser <kirk@reisers.ca>
 M:	Samuel Thibault <samuel.thibault@ens-lyon.org>
-L:	speakup@braille.uwo.ca
+L:	speakup@linux-speakup.org
 W:	http://www.linux-speakup.org/
 S:	Odd Fixes
 F:	drivers/staging/speakup/
 
-STAGING - TI DSP BRIDGE DRIVERS
-M:	Omar Ramirez Luna <omar.ramirez@copitl.com>
-S:	Odd Fixes
-F:	drivers/staging/tidspbridge/
-
-STAGING - USB ENE SM/MS CARD READER DRIVER
-M:	Al Cho <acho@novell.com>
-S:	Odd Fixes
-F:	drivers/staging/keucr/
-
 STAGING - VIA VT665X DRIVERS
 M:	Forest Bond <forest@alittletooquiet.net>
 S:	Odd Fixes
@@ -8950,7 +8949,7 @@
 
 THERMAL
 M:	Zhang Rui <rui.zhang@intel.com>
-M:	Eduardo Valentin <eduardo.valentin@ti.com>
+M:	Eduardo Valentin <edubezval@gmail.com>
 L:	linux-pm@vger.kernel.org
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git
@@ -8977,7 +8976,7 @@
 F:	drivers/platform/x86/thinkpad_acpi.c
 
 TI BANDGAP AND THERMAL DRIVER
-M:	Eduardo Valentin <eduardo.valentin@ti.com>
+M:	Eduardo Valentin <edubezval@gmail.com>
 L:	linux-pm@vger.kernel.org
 S:	Supported
 F:	drivers/thermal/ti-soc-thermal/
diff --git a/Makefile b/Makefile
index 4d75b4b..f3c543d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 3
 PATCHLEVEL = 16
 SUBLEVEL = 0
-EXTRAVERSION = -rc4
+EXTRAVERSION = -rc5
 NAME = Shuffling Zombie Juror
 
 # *DOCUMENTATION*
@@ -41,6 +41,29 @@
 # descending is started. They are now explicitly listed as the
 # prepare rule.
 
+# Beautify output
+# ---------------------------------------------------------------------------
+#
+# Normally, we echo the whole command before executing it. By making
+# that echo $($(quiet)$(cmd)), we now have the possibility to set
+# $(quiet) to choose other forms of output instead, e.g.
+#
+#         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
+#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
+#
+# If $(quiet) is empty, the whole command will be printed.
+# If it is set to "quiet_", only the short version will be printed.
+# If it is set to "silent_", nothing will be printed at all, since
+# the variable $(silent_cmd_cc_o_c) doesn't exist.
+#
+# A simple variant is to prefix commands with $(Q) - that's useful
+# for commands that shall be hidden in non-verbose mode.
+#
+#	$(Q)ln $@ :<
+#
+# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
+# If KBUILD_VERBOSE equals 1 then the above command is displayed.
+#
 # To put more focus on warnings, be less verbose as default
 # Use 'make V=1' to see the full commands
 
@@ -51,6 +74,29 @@
   KBUILD_VERBOSE = 0
 endif
 
+ifeq ($(KBUILD_VERBOSE),1)
+  quiet =
+  Q =
+else
+  quiet=quiet_
+  Q = @
+endif
+
+# If the user is running make -s (silent mode), suppress echoing of
+# commands
+
+ifneq ($(filter 4.%,$(MAKE_VERSION)),)	# make-4
+ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
+  quiet=silent_
+endif
+else					# make-3.8x
+ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
+  quiet=silent_
+endif
+endif
+
+export quiet Q KBUILD_VERBOSE
+
 # Call a source code checker (by default, "sparse") as part of the
 # C compilation.
 #
@@ -128,8 +174,11 @@
 
 # Fake the "Entering directory" message once, so that IDEs/editors are
 # able to understand relative filenames.
+       echodir := @echo
+ quiet_echodir := @echo
+silent_echodir := @:
 sub-make: FORCE
-	@echo "make[1]: Entering directory \`$(KBUILD_OUTPUT)'"
+	$($(quiet)echodir) "make[1]: Entering directory \`$(KBUILD_OUTPUT)'"
 	$(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
 	KBUILD_SRC=$(CURDIR) \
 	KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \
@@ -292,52 +341,6 @@
 export KBUILD_MODULES KBUILD_BUILTIN
 export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD
 
-# Beautify output
-# ---------------------------------------------------------------------------
-#
-# Normally, we echo the whole command before executing it. By making
-# that echo $($(quiet)$(cmd)), we now have the possibility to set
-# $(quiet) to choose other forms of output instead, e.g.
-#
-#         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
-#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
-#
-# If $(quiet) is empty, the whole command will be printed.
-# If it is set to "quiet_", only the short version will be printed.
-# If it is set to "silent_", nothing will be printed at all, since
-# the variable $(silent_cmd_cc_o_c) doesn't exist.
-#
-# A simple variant is to prefix commands with $(Q) - that's useful
-# for commands that shall be hidden in non-verbose mode.
-#
-#	$(Q)ln $@ :<
-#
-# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
-# If KBUILD_VERBOSE equals 1 then the above command is displayed.
-
-ifeq ($(KBUILD_VERBOSE),1)
-  quiet =
-  Q =
-else
-  quiet=quiet_
-  Q = @
-endif
-
-# If the user is running make -s (silent mode), suppress echoing of
-# commands
-
-ifneq ($(filter 4.%,$(MAKE_VERSION)),)	# make-4
-ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),)
-  quiet=silent_
-endif
-else					# make-3.8x
-ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
-  quiet=silent_
-endif
-endif
-
-export quiet Q KBUILD_VERBOSE
-
 ifneq ($(CC),)
 ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
 COMPILER := clang
@@ -1173,7 +1176,7 @@
 # Packaging of the kernel to various formats
 # ---------------------------------------------------------------------------
 # rpm target kept for backward compatibility
-package-dir	:= $(srctree)/scripts/package
+package-dir	:= scripts/package
 
 %src-pkg: FORCE
 	$(Q)$(MAKE) $(build)=$(package-dir) $@
diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts
index ecb2677..e2156a5 100644
--- a/arch/arm/boot/dts/am335x-evm.dts
+++ b/arch/arm/boot/dts/am335x-evm.dts
@@ -529,8 +529,8 @@
 		serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
 			0 0 1 2
 		>;
-		tx-num-evt = <1>;
-		rx-num-evt = <1>;
+		tx-num-evt = <32>;
+		rx-num-evt = <32>;
 };
 
 &tps {
diff --git a/arch/arm/boot/dts/am335x-evmsk.dts b/arch/arm/boot/dts/am335x-evmsk.dts
index ab9a34c..80a3b21 100644
--- a/arch/arm/boot/dts/am335x-evmsk.dts
+++ b/arch/arm/boot/dts/am335x-evmsk.dts
@@ -560,8 +560,8 @@
 		serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
 			0 0 1 2
 		>;
-		tx-num-evt = <1>;
-		rx-num-evt = <1>;
+		tx-num-evt = <32>;
+		rx-num-evt = <32>;
 };
 
 &tscadc {
diff --git a/arch/arm/boot/dts/am335x-igep0033.dtsi b/arch/arm/boot/dts/am335x-igep0033.dtsi
index 8a0a72d..a1a0cc5 100644
--- a/arch/arm/boot/dts/am335x-igep0033.dtsi
+++ b/arch/arm/boot/dts/am335x-igep0033.dtsi
@@ -105,10 +105,16 @@
 
 &cpsw_emac0 {
 	phy_id = <&davinci_mdio>, <0>;
+	phy-mode = "rmii";
 };
 
 &cpsw_emac1 {
 	phy_id = <&davinci_mdio>, <1>;
+	phy-mode = "rmii";
+};
+
+&phy_sel {
+	rmii-clock-ext;
 };
 
 &elm {
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index d6133f4..2ebc421 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -1045,6 +1045,8 @@
 				reg = <0x00500000 0x80000
 				       0xf803c000 0x400>;
 				interrupts = <23 IRQ_TYPE_LEVEL_HIGH 0>;
+				clocks = <&usb>, <&udphs_clk>;
+				clock-names = "hclk", "pclk";
 				status = "disabled";
 
 				ep0 {
diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts
index 4adc280..8308954 100644
--- a/arch/arm/boot/dts/dra7-evm.dts
+++ b/arch/arm/boot/dts/dra7-evm.dts
@@ -240,6 +240,7 @@
 					regulator-name = "ldo3";
 					regulator-min-microvolt = <1800000>;
 					regulator-max-microvolt = <1800000>;
+					regulator-always-on;
 					regulator-boot-on;
 				};
 
diff --git a/arch/arm/boot/dts/dra7xx-clocks.dtsi b/arch/arm/boot/dts/dra7xx-clocks.dtsi
index c90c76d..dc7a292 100644
--- a/arch/arm/boot/dts/dra7xx-clocks.dtsi
+++ b/arch/arm/boot/dts/dra7xx-clocks.dtsi
@@ -673,10 +673,12 @@
 
 	l3_iclk_div: l3_iclk_div {
 		#clock-cells = <0>;
-		compatible = "fixed-factor-clock";
+		compatible = "ti,divider-clock";
+		ti,max-div = <2>;
+		ti,bit-shift = <4>;
+		reg = <0x0100>;
 		clocks = <&dpll_core_h12x2_ck>;
-		clock-mult = <1>;
-		clock-div = <1>;
+		ti,index-power-of-two;
 	};
 
 	l4_root_clk_div: l4_root_clk_div {
@@ -684,7 +686,7 @@
 		compatible = "fixed-factor-clock";
 		clocks = <&l3_iclk_div>;
 		clock-mult = <1>;
-		clock-div = <1>;
+		clock-div = <2>;
 	};
 
 	video1_clk2_div: video1_clk2_div {
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index fbaf426..17b22e9 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -554,7 +554,7 @@
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
 		clocks = <&clock CLK_PWM>;
 		clock-names = "timers";
-		#pwm-cells = <2>;
+		#pwm-cells = <3>;
 		status = "disabled";
 	};
 
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi
index e385322..1595722 100644
--- a/arch/arm/boot/dts/exynos5420.dtsi
+++ b/arch/arm/boot/dts/exynos5420.dtsi
@@ -167,7 +167,7 @@
 		compatible = "samsung,exynos5420-audss-clock";
 		reg = <0x03810000 0x0C>;
 		#clock-cells = <1>;
-		clocks = <&clock CLK_FIN_PLL>, <&clock CLK_FOUT_EPLL>,
+		clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MAU_EPLL>,
 			 <&clock CLK_SCLK_MAUDIO0>, <&clock CLK_SCLK_MAUPCM0>;
 		clock-names = "pll_ref", "pll_in", "sclk_audio", "sclk_pcm_in";
 	};
@@ -260,6 +260,9 @@
 	mfc_pd: power-domain@10044060 {
 		compatible = "samsung,exynos4210-pd";
 		reg = <0x10044060 0x20>;
+		clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_SW_ACLK333>,
+			<&clock CLK_MOUT_USER_ACLK333>;
+		clock-names = "oscclk", "pclk0", "clk0";
 	};
 
 	disp_pd: power-domain@100440C0 {
diff --git a/arch/arm/kernel/kprobes-test-arm.c b/arch/arm/kernel/kprobes-test-arm.c
index 9db4b65..cb14242 100644
--- a/arch/arm/kernel/kprobes-test-arm.c
+++ b/arch/arm/kernel/kprobes-test-arm.c
@@ -74,8 +74,6 @@
 	TEST_RRR( op "lt" s "	r11, r",11,VAL1,", r",14,N(val),", asr r",7, 6,"")\
 	TEST_RR(  op "gt" s "	r12, r13"       ", r",14,val, ", ror r",14,7,"")\
 	TEST_RR(  op "le" s "	r14, r",0, val, ", r13"       ", lsl r",14,8,"")\
-	TEST_RR(  op s "	r12, pc"        ", r",14,val, ", ror r",14,7,"")\
-	TEST_RR(  op s "	r14, r",0, val, ", pc"        ", lsl r",14,8,"")\
 	TEST_R(   op "eq" s "	r0,  r",11,VAL1,", #0xf5")			\
 	TEST_R(   op "ne" s "	r11, r",0, VAL1,", #0xf5000000")		\
 	TEST_R(   op s "	r7,  r",8, VAL2,", #0x000af000")		\
@@ -103,8 +101,6 @@
 	TEST_RRR( op "ge	r",11,VAL1,", r",14,N(val),", asr r",7, 6,"")	\
 	TEST_RR(  op "le	r13"       ", r",14,val, ", ror r",14,7,"")	\
 	TEST_RR(  op "gt	r",0, val, ", r13"       ", lsl r",14,8,"")	\
-	TEST_RR(  op "	pc"        ", r",14,val, ", ror r",14,7,"")		\
-	TEST_RR(  op "	r",0, val, ", pc"        ", lsl r",14,8,"")		\
 	TEST_R(   op "eq	r",11,VAL1,", #0xf5")				\
 	TEST_R(   op "ne	r",0, VAL1,", #0xf5000000")			\
 	TEST_R(   op "	r",8, VAL2,", #0x000af000")
@@ -125,7 +121,6 @@
 	TEST_RR(  op "ge" s "	r11, r",11,N(val),", asr r",7, 6,"")	\
 	TEST_RR(  op "lt" s "	r12, r",11,val, ", ror r",14,7,"")	\
 	TEST_R(   op "gt" s "	r14, r13"       ", lsl r",14,8,"")	\
-	TEST_R(   op "le" s "	r14, pc"        ", lsl r",14,8,"")	\
 	TEST(     op "eq" s "	r0,  #0xf5")				\
 	TEST(     op "ne" s "	r11, #0xf5000000")			\
 	TEST(     op s "	r7,  #0x000af000")			\
@@ -159,12 +154,19 @@
 	TEST_SUPPORTED("cmp	pc, #0x1000");
 	TEST_SUPPORTED("cmp	sp, #0x1000");
 
-	/* Data-processing with PC as shift*/
+	/* Data-processing with PC and a shift count in a register */
 	TEST_UNSUPPORTED(__inst_arm(0xe15c0f1e) "	@ cmp	r12, r14, asl pc")
 	TEST_UNSUPPORTED(__inst_arm(0xe1a0cf1e) "	@ mov	r12, r14, asl pc")
 	TEST_UNSUPPORTED(__inst_arm(0xe08caf1e) "	@ add	r10, r12, r14, asl pc")
+	TEST_UNSUPPORTED(__inst_arm(0xe151021f) "	@ cmp	r1, pc, lsl r2")
+	TEST_UNSUPPORTED(__inst_arm(0xe17f0211) "	@ cmn	pc, r1, lsl r2")
+	TEST_UNSUPPORTED(__inst_arm(0xe1a0121f) "	@ mov	r1, pc, lsl r2")
+	TEST_UNSUPPORTED(__inst_arm(0xe1a0f211) "	@ mov	pc, r1, lsl r2")
+	TEST_UNSUPPORTED(__inst_arm(0xe042131f) "	@ sub	r1, r2, pc, lsl r3")
+	TEST_UNSUPPORTED(__inst_arm(0xe1cf1312) "	@ bic	r1, pc, r2, lsl r3")
+	TEST_UNSUPPORTED(__inst_arm(0xe081f312) "	@ add	pc, r1, r2, lsl r3")
 
-	/* Data-processing with PC as shift*/
+	/* Data-processing with PC as a target and status registers updated */
 	TEST_UNSUPPORTED("movs	pc, r1")
 	TEST_UNSUPPORTED("movs	pc, r1, lsl r2")
 	TEST_UNSUPPORTED("movs	pc, #0x10000")
@@ -187,14 +189,14 @@
 	TEST_BF_R ("add	pc, pc, r",14,2f-1f-8,"")
 	TEST_BF_R ("add	pc, r",14,2f-1f-8,", pc")
 	TEST_BF_R ("mov	pc, r",0,2f,"")
-	TEST_BF_RR("mov	pc, r",0,2f,", asl r",1,0,"")
+	TEST_BF_R ("add	pc, pc, r",14,(2f-1f-8)*2,", asr #1")
 	TEST_BB(   "sub	pc, pc, #1b-2b+8")
 #if __LINUX_ARM_ARCH__ == 6 && !defined(CONFIG_CPU_V7)
 	TEST_BB(   "sub	pc, pc, #1b-2b+8-2") /* UNPREDICTABLE before and after ARMv6 */
 #endif
 	TEST_BB_R( "sub	pc, pc, r",14, 1f-2f+8,"")
 	TEST_BB_R( "rsb	pc, r",14,1f-2f+8,", pc")
-	TEST_RR(   "add	pc, pc, r",10,-2,", asl r",11,1,"")
+	TEST_R(    "add	pc, pc, r",10,-2,", asl #1")
 #ifdef CONFIG_THUMB2_KERNEL
 	TEST_ARM_TO_THUMB_INTERWORK_R("add	pc, pc, r",0,3f-1f-8+1,"")
 	TEST_ARM_TO_THUMB_INTERWORK_R("sub	pc, r",0,3f+8+1,", #8")
@@ -216,6 +218,7 @@
 	TEST_BB_R("bx	r",7,2f,"")
 	TEST_BF_R("bxeq	r",14,2f,"")
 
+#if __LINUX_ARM_ARCH__ >= 5
 	TEST_R("clz	r0, r",0, 0x0,"")
 	TEST_R("clzeq	r7, r",14,0x1,"")
 	TEST_R("clz	lr, r",7, 0xffffffff,"")
@@ -337,6 +340,7 @@
 	TEST_UNSUPPORTED(__inst_arm(0xe16f02e1) " @ smultt pc, r1, r2")
 	TEST_UNSUPPORTED(__inst_arm(0xe16002ef) " @ smultt r0, pc, r2")
 	TEST_UNSUPPORTED(__inst_arm(0xe1600fe1) " @ smultt r0, r1, pc")
+#endif
 
 	TEST_GROUP("Multiply and multiply-accumulate")
 
@@ -559,6 +563,7 @@
 	TEST_UNSUPPORTED("ldrsht	r1, [r2], #48")
 #endif
 
+#if __LINUX_ARM_ARCH__ >= 5
 	TEST_RPR(  "strd	r",0, VAL1,", [r",1, 48,", -r",2,24,"]")
 	TEST_RPR(  "strccd	r",8, VAL2,", [r",13,0, ", r",12,48,"]")
 	TEST_RPR(  "strd	r",4, VAL1,", [r",2, 24,", r",3, 48,"]!")
@@ -595,6 +600,7 @@
 	TEST_UNSUPPORTED(__inst_arm(0xe1efc3d0) "	@ ldrd r12, [pc, #48]!")
 	TEST_UNSUPPORTED(__inst_arm(0xe0c9f3d0) "	@ ldrd pc, [r9], #48")
 	TEST_UNSUPPORTED(__inst_arm(0xe0c9e3d0) "	@ ldrd lr, [r9], #48")
+#endif
 
 	TEST_GROUP("Miscellaneous")
 
@@ -1227,7 +1233,9 @@
 	TEST_COPROCESSOR( "mrc"two"	0, 0, r0, cr0, cr0, 0")
 
 	COPROCESSOR_INSTRUCTIONS_ST_LD("",e)
+#if __LINUX_ARM_ARCH__ >= 5
 	COPROCESSOR_INSTRUCTIONS_MC_MR("",e)
+#endif
 	TEST_UNSUPPORTED("svc	0")
 	TEST_UNSUPPORTED("svc	0xffffff")
 
@@ -1287,7 +1295,9 @@
 	TEST(	"blx	__dummy_thumb_subroutine_odd")
 #endif /* __LINUX_ARM_ARCH__ >= 6 */
 
+#if __LINUX_ARM_ARCH__ >= 5
 	COPROCESSOR_INSTRUCTIONS_ST_LD("2",f)
+#endif
 #if __LINUX_ARM_ARCH__ >= 6
 	COPROCESSOR_INSTRUCTIONS_MC_MR("2",f)
 #endif
diff --git a/arch/arm/kernel/kprobes-test.c b/arch/arm/kernel/kprobes-test.c
index 3796399..08d7312 100644
--- a/arch/arm/kernel/kprobes-test.c
+++ b/arch/arm/kernel/kprobes-test.c
@@ -225,6 +225,7 @@
 static int post_handler_called;
 static int jprobe_func_called;
 static int kretprobe_handler_called;
+static int tests_failed;
 
 #define FUNC_ARG1 0x12345678
 #define FUNC_ARG2 0xabcdef
@@ -461,6 +462,13 @@
 
 	pr_info("    jprobe\n");
 	ret = test_jprobe(func);
+#if defined(CONFIG_THUMB2_KERNEL) && !defined(MODULE)
+	if (ret == -EINVAL) {
+		pr_err("FAIL: Known longtime bug with jprobe on Thumb kernels\n");
+		tests_failed = ret;
+		ret = 0;
+	}
+#endif
 	if (ret < 0)
 		return ret;
 
@@ -1672,6 +1680,8 @@
 
 out:
 	if (ret == 0)
+		ret = tests_failed;
+	if (ret == 0)
 		pr_info("Finished kprobe tests OK\n");
 	else
 		pr_err("kprobe tests failed\n");
diff --git a/arch/arm/kernel/probes-arm.c b/arch/arm/kernel/probes-arm.c
index 51a13a0..8eaef81 100644
--- a/arch/arm/kernel/probes-arm.c
+++ b/arch/arm/kernel/probes-arm.c
@@ -341,12 +341,12 @@
 	/* CMP (reg-shift reg)	cccc 0001 0101 xxxx xxxx xxxx 0xx1 xxxx */
 	/* CMN (reg-shift reg)	cccc 0001 0111 xxxx xxxx xxxx 0xx1 xxxx */
 	DECODE_EMULATEX	(0x0f900090, 0x01100010, PROBES_DATA_PROCESSING_REG,
-						 REGS(ANY, 0, NOPC, 0, ANY)),
+						 REGS(NOPC, 0, NOPC, 0, NOPC)),
 
 	/* MOV (reg-shift reg)	cccc 0001 101x xxxx xxxx xxxx 0xx1 xxxx */
 	/* MVN (reg-shift reg)	cccc 0001 111x xxxx xxxx xxxx 0xx1 xxxx */
 	DECODE_EMULATEX	(0x0fa00090, 0x01a00010, PROBES_DATA_PROCESSING_REG,
-						 REGS(0, ANY, NOPC, 0, ANY)),
+						 REGS(0, NOPC, NOPC, 0, NOPC)),
 
 	/* AND (reg-shift reg)	cccc 0000 000x xxxx xxxx xxxx 0xx1 xxxx */
 	/* EOR (reg-shift reg)	cccc 0000 001x xxxx xxxx xxxx 0xx1 xxxx */
@@ -359,7 +359,7 @@
 	/* ORR (reg-shift reg)	cccc 0001 100x xxxx xxxx xxxx 0xx1 xxxx */
 	/* BIC (reg-shift reg)	cccc 0001 110x xxxx xxxx xxxx 0xx1 xxxx */
 	DECODE_EMULATEX	(0x0e000090, 0x00000010, PROBES_DATA_PROCESSING_REG,
-						 REGS(ANY, ANY, NOPC, 0, ANY)),
+						 REGS(NOPC, NOPC, NOPC, 0, NOPC)),
 
 	DECODE_END
 };
diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
index f38cf7c1..46d893f 100644
--- a/arch/arm/mach-exynos/exynos.c
+++ b/arch/arm/mach-exynos/exynos.c
@@ -173,10 +173,8 @@
 
 void __init exynos_cpuidle_init(void)
 {
-	if (soc_is_exynos5440())
-		return;
-
-	platform_device_register(&exynos_cpuidle);
+	if (soc_is_exynos4210() || soc_is_exynos5250())
+		platform_device_register(&exynos_cpuidle);
 }
 
 void __init exynos_cpufreq_init(void)
@@ -297,7 +295,7 @@
 	 * This is called from smp_prepare_cpus if we've built for SMP, but
 	 * we still need to set it up for PM and firmware ops if not.
 	 */
-	if (!IS_ENABLED(SMP))
+	if (!IS_ENABLED(CONFIG_SMP))
 		exynos_sysram_init();
 
 	exynos_cpuidle_init();
diff --git a/arch/arm/mach-exynos/firmware.c b/arch/arm/mach-exynos/firmware.c
index eb91d23..e8797bb 100644
--- a/arch/arm/mach-exynos/firmware.c
+++ b/arch/arm/mach-exynos/firmware.c
@@ -57,8 +57,13 @@
 
 	boot_reg = sysram_ns_base_addr + 0x1c;
 
-	if (!soc_is_exynos4212() && !soc_is_exynos3250())
-		boot_reg += 4*cpu;
+	/*
+	 * Almost all Exynos-series of SoCs that run in secure mode don't need
+	 * additional offset for every CPU, with Exynos4412 being the only
+	 * exception.
+	 */
+	if (soc_is_exynos4412())
+		boot_reg += 4 * cpu;
 
 	__raw_writel(boot_addr, boot_reg);
 	return 0;
diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c
index fe6570e..797cb13 100644
--- a/arch/arm/mach-exynos/pm_domains.c
+++ b/arch/arm/mach-exynos/pm_domains.c
@@ -17,6 +17,7 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/pm_domain.h>
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
@@ -24,6 +25,8 @@
 
 #include "regs-pmu.h"
 
+#define MAX_CLK_PER_DOMAIN	4
+
 /*
  * Exynos specific wrapper around the generic power domain
  */
@@ -32,6 +35,9 @@
 	char const *name;
 	bool is_off;
 	struct generic_pm_domain pd;
+	struct clk *oscclk;
+	struct clk *clk[MAX_CLK_PER_DOMAIN];
+	struct clk *pclk[MAX_CLK_PER_DOMAIN];
 };
 
 static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
@@ -44,6 +50,19 @@
 	pd = container_of(domain, struct exynos_pm_domain, pd);
 	base = pd->base;
 
+	/* Set oscclk before powering off a domain*/
+	if (!power_on) {
+		int i;
+
+		for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
+			if (IS_ERR(pd->clk[i]))
+				break;
+			if (clk_set_parent(pd->clk[i], pd->oscclk))
+				pr_err("%s: error setting oscclk as parent to clock %d\n",
+						pd->name, i);
+		}
+	}
+
 	pwr = power_on ? S5P_INT_LOCAL_PWR_EN : 0;
 	__raw_writel(pwr, base);
 
@@ -60,6 +79,20 @@
 		cpu_relax();
 		usleep_range(80, 100);
 	}
+
+	/* Restore clocks after powering on a domain*/
+	if (power_on) {
+		int i;
+
+		for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
+			if (IS_ERR(pd->clk[i]))
+				break;
+			if (clk_set_parent(pd->clk[i], pd->pclk[i]))
+				pr_err("%s: error setting parent to clock%d\n",
+						pd->name, i);
+		}
+	}
+
 	return 0;
 }
 
@@ -152,9 +185,11 @@
 
 	for_each_compatible_node(np, NULL, "samsung,exynos4210-pd") {
 		struct exynos_pm_domain *pd;
-		int on;
+		int on, i;
+		struct device *dev;
 
 		pdev = of_find_device_by_node(np);
+		dev = &pdev->dev;
 
 		pd = kzalloc(sizeof(*pd), GFP_KERNEL);
 		if (!pd) {
@@ -170,6 +205,30 @@
 		pd->pd.power_on = exynos_pd_power_on;
 		pd->pd.of_node = np;
 
+		pd->oscclk = clk_get(dev, "oscclk");
+		if (IS_ERR(pd->oscclk))
+			goto no_clk;
+
+		for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
+			char clk_name[8];
+
+			snprintf(clk_name, sizeof(clk_name), "clk%d", i);
+			pd->clk[i] = clk_get(dev, clk_name);
+			if (IS_ERR(pd->clk[i]))
+				break;
+			snprintf(clk_name, sizeof(clk_name), "pclk%d", i);
+			pd->pclk[i] = clk_get(dev, clk_name);
+			if (IS_ERR(pd->pclk[i])) {
+				clk_put(pd->clk[i]);
+				pd->clk[i] = ERR_PTR(-EINVAL);
+				break;
+			}
+		}
+
+		if (IS_ERR(pd->clk[0]))
+			clk_put(pd->oscclk);
+
+no_clk:
 		platform_set_drvdata(pdev, pd);
 
 		on = __raw_readl(pd->base + 0x4) & S5P_INT_LOCAL_PWR_EN;
diff --git a/arch/arm/mach-imx/clk-gate2.c b/arch/arm/mach-imx/clk-gate2.c
index 4ba587d..84acdfd 100644
--- a/arch/arm/mach-imx/clk-gate2.c
+++ b/arch/arm/mach-imx/clk-gate2.c
@@ -67,8 +67,12 @@
 
 	spin_lock_irqsave(gate->lock, flags);
 
-	if (gate->share_count && --(*gate->share_count) > 0)
-		goto out;
+	if (gate->share_count) {
+		if (WARN_ON(*gate->share_count == 0))
+			goto out;
+		else if (--(*gate->share_count) > 0)
+			goto out;
+	}
 
 	reg = readl(gate->reg);
 	reg &= ~(3 << gate->bit_idx);
@@ -78,19 +82,26 @@
 	spin_unlock_irqrestore(gate->lock, flags);
 }
 
-static int clk_gate2_is_enabled(struct clk_hw *hw)
+static int clk_gate2_reg_is_enabled(void __iomem *reg, u8 bit_idx)
 {
-	u32 reg;
-	struct clk_gate2 *gate = to_clk_gate2(hw);
+	u32 val = readl(reg);
 
-	reg = readl(gate->reg);
-
-	if (((reg >> gate->bit_idx) & 1) == 1)
+	if (((val >> bit_idx) & 1) == 1)
 		return 1;
 
 	return 0;
 }
 
+static int clk_gate2_is_enabled(struct clk_hw *hw)
+{
+	struct clk_gate2 *gate = to_clk_gate2(hw);
+
+	if (gate->share_count)
+		return !!(*gate->share_count);
+	else
+		return clk_gate2_reg_is_enabled(gate->reg, gate->bit_idx);
+}
+
 static struct clk_ops clk_gate2_ops = {
 	.enable = clk_gate2_enable,
 	.disable = clk_gate2_disable,
@@ -116,6 +127,10 @@
 	gate->bit_idx = bit_idx;
 	gate->flags = clk_gate2_flags;
 	gate->lock = lock;
+
+	/* Initialize share_count per hardware state */
+	if (share_count)
+		*share_count = clk_gate2_reg_is_enabled(reg, bit_idx) ? 1 : 0;
 	gate->share_count = share_count;
 
 	init.name = name;
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 8ca99e9..fa78000 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -232,10 +232,6 @@
 iommu-$(CONFIG_OMAP_IOMMU)		:= omap-iommu.o
 obj-y					+= $(iommu-m) $(iommu-y)
 
-ifneq ($(CONFIG_TIDSPBRIDGE),)
-obj-y					+= dsp.o
-endif
-
 # OMAP2420 MSDI controller integration support ("MMC")
 obj-$(CONFIG_SOC_OMAP2420)		+= msdi.o
 
diff --git a/arch/arm/mach-omap2/clkt_dpll.c b/arch/arm/mach-omap2/clkt_dpll.c
index 332af92..67fd26a 100644
--- a/arch/arm/mach-omap2/clkt_dpll.c
+++ b/arch/arm/mach-omap2/clkt_dpll.c
@@ -76,7 +76,7 @@
  * (assuming that it is counting N upwards), or -2 if the enclosing loop
  * should skip to the next iteration (again assuming N is increasing).
  */
-static int _dpll_test_fint(struct clk_hw_omap *clk, u8 n)
+static int _dpll_test_fint(struct clk_hw_omap *clk, unsigned int n)
 {
 	struct dpll_data *dd;
 	long fint, fint_min, fint_max;
diff --git a/arch/arm/mach-omap2/cm-regbits-34xx.h b/arch/arm/mach-omap2/cm-regbits-34xx.h
index 04dab2f..ee6c784 100644
--- a/arch/arm/mach-omap2/cm-regbits-34xx.h
+++ b/arch/arm/mach-omap2/cm-regbits-34xx.h
@@ -26,11 +26,14 @@
 #define OMAP3430_EN_WDT3_SHIFT				12
 #define OMAP3430_CM_FCLKEN_IVA2_EN_IVA2_MASK		(1 << 0)
 #define OMAP3430_CM_FCLKEN_IVA2_EN_IVA2_SHIFT		0
+#define OMAP3430_IVA2_DPLL_FREQSEL_SHIFT		4
 #define OMAP3430_IVA2_DPLL_FREQSEL_MASK			(0xf << 4)
 #define OMAP3430_EN_IVA2_DPLL_DRIFTGUARD_SHIFT		3
+#define OMAP3430_EN_IVA2_DPLL_SHIFT			0
 #define OMAP3430_EN_IVA2_DPLL_MASK			(0x7 << 0)
 #define OMAP3430_ST_IVA2_SHIFT				0
 #define OMAP3430_ST_IVA2_CLK_MASK			(1 << 0)
+#define OMAP3430_AUTO_IVA2_DPLL_SHIFT			0
 #define OMAP3430_AUTO_IVA2_DPLL_MASK			(0x7 << 0)
 #define OMAP3430_IVA2_CLK_SRC_SHIFT			19
 #define OMAP3430_IVA2_CLK_SRC_WIDTH			3
diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c
index 2dabb9e..484cdad 100644
--- a/arch/arm/mach-omap2/common.c
+++ b/arch/arm/mach-omap2/common.c
@@ -14,7 +14,6 @@
  */
 #include <linux/kernel.h>
 #include <linux/init.h>
-#include <linux/platform_data/dsp-omap.h>
 
 #include "common.h"
 #include "omap-secure.h"
@@ -30,7 +29,6 @@
 
 void __init omap_reserve(void)
 {
-	omap_dsp_reserve_sdram_memblock();
 	omap_secure_ram_reserve_memblock();
 	omap_barrier_reserve_memblock();
 }
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index b2d252b..dc571f1 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -162,7 +162,8 @@
 }
 #endif
 
-#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
+#if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
+	defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM43XX)
 void omap44xx_restart(enum reboot_mode mode, const char *cmd);
 #else
 static inline void omap44xx_restart(enum reboot_mode mode, const char *cmd)
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 592ba0a..b6f8f34 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -297,33 +297,6 @@
 static inline void omap_init_audio(void) {}
 #endif
 
-#if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \
-		defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE)
-
-static struct platform_device omap_hdmi_audio = {
-	.name	= "omap-hdmi-audio",
-	.id	= -1,
-};
-
-static void __init omap_init_hdmi_audio(void)
-{
-	struct omap_hwmod *oh;
-	struct platform_device *pdev;
-
-	oh = omap_hwmod_lookup("dss_hdmi");
-	if (!oh)
-		return;
-
-	pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0);
-	WARN(IS_ERR(pdev),
-	     "Can't build omap_device for omap-hdmi-audio-dai.\n");
-
-	platform_device_register(&omap_hdmi_audio);
-}
-#else
-static inline void omap_init_hdmi_audio(void) {}
-#endif
-
 #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE)
 
 #include <linux/platform_data/spi-omap2-mcspi.h>
@@ -459,7 +432,6 @@
 	 */
 	omap_init_audio();
 	omap_init_camera();
-	omap_init_hdmi_audio();
 	omap_init_mbox();
 	/* If dtb is there, the devices will be created dynamically */
 	if (!of_have_populated_dt()) {
diff --git a/arch/arm/mach-omap2/dsp.c b/arch/arm/mach-omap2/dsp.c
deleted file mode 100644
index b8208b4..0000000
--- a/arch/arm/mach-omap2/dsp.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * TI's OMAP DSP platform device registration
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- * Copyright (C) 2009 Nokia Corporation
- *
- * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.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.
- */
-
-/*
- * XXX The function pointers to the PRM/CM functions are incorrect and
- * should be removed.  No device driver should be changing PRM/CM bits
- * directly; that's a layering violation -- those bits are the responsibility
- * of the OMAP PM core code.
- */
-
-#include <linux/module.h>
-#include <linux/platform_device.h>
-
-#include <asm/memblock.h>
-
-#include "control.h"
-#include "cm2xxx_3xxx.h"
-#include "prm2xxx_3xxx.h"
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-#include "omap-pm.h"
-#endif
-
-#include <linux/platform_data/dsp-omap.h>
-
-static struct platform_device *omap_dsp_pdev;
-
-static struct omap_dsp_platform_data omap_dsp_pdata __initdata = {
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-	.dsp_set_min_opp = omap_pm_dsp_set_min_opp,
-	.dsp_get_opp = omap_pm_dsp_get_opp,
-	.cpu_set_freq = omap_pm_cpu_set_freq,
-	.cpu_get_freq = omap_pm_cpu_get_freq,
-#endif
-	.dsp_prm_read = omap2_prm_read_mod_reg,
-	.dsp_prm_write = omap2_prm_write_mod_reg,
-	.dsp_prm_rmw_bits = omap2_prm_rmw_mod_reg_bits,
-	.dsp_cm_read = omap2_cm_read_mod_reg,
-	.dsp_cm_write = omap2_cm_write_mod_reg,
-	.dsp_cm_rmw_bits = omap2_cm_rmw_mod_reg_bits,
-
-	.set_bootaddr = omap_ctrl_write_dsp_boot_addr,
-	.set_bootmode = omap_ctrl_write_dsp_boot_mode,
-};
-
-static phys_addr_t omap_dsp_phys_mempool_base;
-
-void __init omap_dsp_reserve_sdram_memblock(void)
-{
-	phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
-	phys_addr_t paddr;
-
-	if (!size)
-		return;
-
-	paddr = arm_memblock_steal(size, SZ_1M);
-	if (!paddr) {
-		pr_err("%s: failed to reserve %llx bytes\n",
-				__func__, (unsigned long long)size);
-		return;
-	}
-
-	omap_dsp_phys_mempool_base = paddr;
-}
-
-static phys_addr_t omap_dsp_get_mempool_base(void)
-{
-	return omap_dsp_phys_mempool_base;
-}
-
-static int __init omap_dsp_init(void)
-{
-	struct platform_device *pdev;
-	int err = -ENOMEM;
-	struct omap_dsp_platform_data *pdata = &omap_dsp_pdata;
-
-	pdata->phys_mempool_base = omap_dsp_get_mempool_base();
-
-	if (pdata->phys_mempool_base) {
-		pdata->phys_mempool_size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE;
-		pr_info("%s: %llx bytes @ %llx\n", __func__,
-			(unsigned long long)pdata->phys_mempool_size,
-			(unsigned long long)pdata->phys_mempool_base);
-	}
-
-	pdev = platform_device_alloc("omap-dsp", -1);
-	if (!pdev)
-		goto err_out;
-
-	err = platform_device_add_data(pdev, pdata, sizeof(*pdata));
-	if (err)
-		goto err_out;
-
-	err = platform_device_add(pdev);
-	if (err)
-		goto err_out;
-
-	omap_dsp_pdev = pdev;
-	return 0;
-
-err_out:
-	platform_device_put(pdev);
-	return err;
-}
-module_init(omap_dsp_init);
-
-static void __exit omap_dsp_exit(void)
-{
-	platform_device_unregister(omap_dsp_pdev);
-}
-module_exit(omap_dsp_exit);
-
-MODULE_AUTHOR("Hiroshi DOYU");
-MODULE_DESCRIPTION("TI's OMAP DSP platform device registration");
-MODULE_LICENSE("GPL");
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 2c0c281..8bc1338 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -1615,7 +1615,7 @@
 		return ret;
 	}
 
-	for_each_child_of_node(pdev->dev.of_node, child) {
+	for_each_available_child_of_node(pdev->dev.of_node, child) {
 
 		if (!child->name)
 			continue;
diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
index 20b4398..284324f 100644
--- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
@@ -1268,9 +1268,6 @@
 };
 
 /* sata */
-static struct omap_hwmod_opt_clk sata_opt_clks[] = {
-	{ .role = "ref_clk", .clk = "sata_ref_clk" },
-};
 
 static struct omap_hwmod dra7xx_sata_hwmod = {
 	.name		= "sata",
@@ -1278,6 +1275,7 @@
 	.clkdm_name	= "l3init_clkdm",
 	.flags		= HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY,
 	.main_clk	= "func_48m_fclk",
+	.mpu_rt_idx	= 1,
 	.prcm = {
 		.omap4 = {
 			.clkctrl_offs = DRA7XX_CM_L3INIT_SATA_CLKCTRL_OFFSET,
@@ -1285,8 +1283,6 @@
 			.modulemode   = MODULEMODE_SWCTRL,
 		},
 	},
-	.opt_clks	= sata_opt_clks,
-	.opt_clks_cnt	= ARRAY_SIZE(sata_opt_clks),
 };
 
 /*
@@ -1731,8 +1727,20 @@
  *
  */
 
+static struct omap_hwmod_class_sysconfig dra7xx_usb_otg_ss_sysc = {
+	.rev_offs	= 0x0000,
+	.sysc_offs	= 0x0010,
+	.sysc_flags	= (SYSC_HAS_DMADISABLE | SYSC_HAS_MIDLEMODE |
+			   SYSC_HAS_SIDLEMODE),
+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+			   SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO |
+			   MSTANDBY_SMART | MSTANDBY_SMART_WKUP),
+	.sysc_fields	= &omap_hwmod_sysc_type2,
+};
+
 static struct omap_hwmod_class dra7xx_usb_otg_ss_hwmod_class = {
 	.name	= "usb_otg_ss",
+	.sysc	= &dra7xx_usb_otg_ss_sysc,
 };
 
 /* usb_otg_ss1 */
diff --git a/arch/arm/mach-omap2/prm-regbits-34xx.h b/arch/arm/mach-omap2/prm-regbits-34xx.h
index 106132d..cbefbd7 100644
--- a/arch/arm/mach-omap2/prm-regbits-34xx.h
+++ b/arch/arm/mach-omap2/prm-regbits-34xx.h
@@ -35,6 +35,8 @@
 #define OMAP3430_LOGICSTATEST_MASK			(1 << 2)
 #define OMAP3430_LASTLOGICSTATEENTERED_MASK		(1 << 2)
 #define OMAP3430_LASTPOWERSTATEENTERED_MASK		(0x3 << 0)
+#define OMAP3430_GRPSEL_MCBSP5_MASK			(1 << 10)
+#define OMAP3430_GRPSEL_MCBSP1_MASK			(1 << 9)
 #define OMAP3630_GRPSEL_UART4_MASK			(1 << 18)
 #define OMAP3430_GRPSEL_GPIO6_MASK			(1 << 17)
 #define OMAP3430_GRPSEL_GPIO5_MASK			(1 << 16)
@@ -42,6 +44,10 @@
 #define OMAP3430_GRPSEL_GPIO3_MASK			(1 << 14)
 #define OMAP3430_GRPSEL_GPIO2_MASK			(1 << 13)
 #define OMAP3430_GRPSEL_UART3_MASK			(1 << 11)
+#define OMAP3430_GRPSEL_GPT8_MASK			(1 << 9)
+#define OMAP3430_GRPSEL_GPT7_MASK			(1 << 8)
+#define OMAP3430_GRPSEL_GPT6_MASK			(1 << 7)
+#define OMAP3430_GRPSEL_GPT5_MASK			(1 << 6)
 #define OMAP3430_GRPSEL_MCBSP4_MASK			(1 << 2)
 #define OMAP3430_GRPSEL_MCBSP3_MASK			(1 << 1)
 #define OMAP3430_GRPSEL_MCBSP2_MASK			(1 << 0)
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index 076172b..7c3fb41 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -664,7 +664,7 @@
 
 static void __init l2c310_enable(void __iomem *base, u32 aux, unsigned num_lock)
 {
-	unsigned rev = readl_relaxed(base + L2X0_CACHE_ID) & L2X0_CACHE_ID_PART_MASK;
+	unsigned rev = readl_relaxed(base + L2X0_CACHE_ID) & L2X0_CACHE_ID_RTL_MASK;
 	bool cortex_a9 = read_cpuid_part_number() == ARM_CPU_PART_CORTEX_A9;
 
 	if (rev >= L310_CACHE_ID_RTL_R2P0) {
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 993bce5..902eb70 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -56,6 +56,8 @@
 #define TASK_SIZE_32		UL(0x100000000)
 #define TASK_SIZE		(test_thread_flag(TIF_32BIT) ? \
 				TASK_SIZE_32 : TASK_SIZE_64)
+#define TASK_SIZE_OF(tsk)	(test_tsk_thread_flag(tsk, TIF_32BIT) ? \
+				TASK_SIZE_32 : TASK_SIZE_64)
 #else
 #define TASK_SIZE		TASK_SIZE_64
 #endif /* CONFIG_COMPAT */
diff --git a/arch/arm64/mm/copypage.c b/arch/arm64/mm/copypage.c
index 9aecbac..13bbc3be 100644
--- a/arch/arm64/mm/copypage.c
+++ b/arch/arm64/mm/copypage.c
@@ -27,8 +27,10 @@
 	copy_page(kto, kfrom);
 	__flush_dcache_area(kto, PAGE_SIZE);
 }
+EXPORT_SYMBOL_GPL(__cpu_copy_user_page);
 
 void __cpu_clear_user_page(void *kaddr, unsigned long vaddr)
 {
 	clear_page(kaddr);
 }
+EXPORT_SYMBOL_GPL(__cpu_clear_user_page);
diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S
index dbb118e..a5478845 100644
--- a/arch/m68k/kernel/head.S
+++ b/arch/m68k/kernel/head.S
@@ -921,7 +921,8 @@
 	jls	1f
 	lsrl	#1,%d1
 1:
-	movel	%d1,m68k_init_mapped_size
+	lea	%pc@(m68k_init_mapped_size),%a0
+	movel	%d1,%a0@
 	mmu_map	#PAGE_OFFSET,%pc@(L(phys_kernel_start)),%d1,\
 		%pc@(m68k_supervisor_cachemode)
 
diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index 958f1ad..3857737 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -11,6 +11,7 @@
  */
 
 #include <linux/errno.h>
+#include <linux/export.h>
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/kernel.h>
@@ -30,6 +31,7 @@
 
 
 unsigned long (*mach_random_get_entropy)(void);
+EXPORT_SYMBOL_GPL(mach_random_get_entropy);
 
 
 /*
diff --git a/arch/parisc/kernel/hardware.c b/arch/parisc/kernel/hardware.c
index 608716f..af3bc35 100644
--- a/arch/parisc/kernel/hardware.c
+++ b/arch/parisc/kernel/hardware.c
@@ -1210,7 +1210,8 @@
 	{HPHW_FIO, 0x004, 0x00320, 0x0, "Metheus Frame Buffer"}, 
 	{HPHW_FIO, 0x004, 0x00340, 0x0, "BARCO CX4500 VME Grphx Cnsl"}, 
 	{HPHW_FIO, 0x004, 0x00360, 0x0, "Hughes TOG VME FDDI"}, 
-	{HPHW_FIO, 0x076, 0x000AD, 0x00, "Crestone Peak RS-232"},
+	{HPHW_FIO, 0x076, 0x000AD, 0x0, "Crestone Peak Core RS-232"},
+	{HPHW_FIO, 0x077, 0x000AD, 0x0, "Crestone Peak Fast? Core RS-232"},
 	{HPHW_IOA, 0x185, 0x0000B, 0x00, "Java BC Summit Port"}, 
 	{HPHW_IOA, 0x1FF, 0x0000B, 0x00, "Hitachi Ghostview Summit Port"}, 
 	{HPHW_IOA, 0x580, 0x0000B, 0x10, "U2-IOA BC Runway Port"}, 
diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c
index bb9f3b6..93c1963 100644
--- a/arch/parisc/kernel/sys_parisc32.c
+++ b/arch/parisc/kernel/sys_parisc32.c
@@ -4,6 +4,7 @@
  * Copyright (C) 2000-2001 Hewlett Packard Company
  * Copyright (C) 2000 John Marvin
  * Copyright (C) 2001 Matthew Wilcox
+ * Copyright (C) 2014 Helge Deller <deller@gmx.de>
  *
  * These routines maintain argument size conversion between 32bit and 64bit
  * environment. Based heavily on sys_ia32.c and sys_sparc32.c.
@@ -11,44 +12,8 @@
 
 #include <linux/compat.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/fs.h> 
-#include <linux/mm.h> 
-#include <linux/file.h> 
-#include <linux/signal.h>
-#include <linux/resource.h>
-#include <linux/times.h>
-#include <linux/time.h>
-#include <linux/smp.h>
-#include <linux/sem.h>
-#include <linux/shm.h>
-#include <linux/slab.h>
-#include <linux/uio.h>
-#include <linux/ncp_fs.h>
-#include <linux/poll.h>
-#include <linux/personality.h>
-#include <linux/stat.h>
-#include <linux/highmem.h>
-#include <linux/highuid.h>
-#include <linux/mman.h>
-#include <linux/binfmts.h>
-#include <linux/namei.h>
-#include <linux/vfs.h>
-#include <linux/ptrace.h>
-#include <linux/swap.h>
 #include <linux/syscalls.h>
 
-#include <asm/types.h>
-#include <asm/uaccess.h>
-#include <asm/mmu_context.h>
-
-#undef DEBUG
-
-#ifdef DEBUG
-#define DBG(x)	printk x
-#else
-#define DBG(x)
-#endif
 
 asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23,
 	int r22, int r21, int r20)
@@ -57,3 +22,12 @@
     	current->comm, current->pid, r20);
     return -ENOSYS;
 }
+
+asmlinkage long sys32_fanotify_mark(compat_int_t fanotify_fd, compat_uint_t flags,
+	compat_uint_t mask0, compat_uint_t mask1, compat_int_t dfd,
+	const char  __user * pathname)
+{
+	return sys_fanotify_mark(fanotify_fd, flags,
+			((__u64)mask1 << 32) | mask0,
+			 dfd, pathname);
+}
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index c5fa7a6..84c5d3a 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -418,7 +418,7 @@
 	ENTRY_SAME(accept4)		/* 320 */
 	ENTRY_SAME(prlimit64)
 	ENTRY_SAME(fanotify_init)
-	ENTRY_COMP(fanotify_mark)
+	ENTRY_DIFF(fanotify_mark)
 	ENTRY_COMP(clock_adjtime)
 	ENTRY_SAME(name_to_handle_at)	/* 325 */
 	ENTRY_COMP(open_by_handle_at)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index bd6dd6e..fefe7c8 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -414,7 +414,7 @@
 config CRASH_DUMP
 	bool "Build a kdump crash kernel"
 	depends on PPC64 || 6xx || FSL_BOOKE || (44x && !SMP)
-	select RELOCATABLE if PPC64 || 44x || FSL_BOOKE
+	select RELOCATABLE if (PPC64 && !COMPILE_TEST) || 44x || FSL_BOOKE
 	help
 	  Build a kernel suitable for use as a kdump capture kernel.
 	  The same kernel binary can be used as production kernel and dump
@@ -1017,6 +1017,7 @@
 if PPC64
 config RELOCATABLE
 	bool "Build a relocatable kernel"
+	depends on !COMPILE_TEST
 	select NONSTATIC_KERNEL
 	help
 	  This builds a kernel image that is capable of running anywhere
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index f8d1d6d..e61f24e 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -19,8 +19,7 @@
 #define MMU_FTR_TYPE_40x		ASM_CONST(0x00000004)
 #define MMU_FTR_TYPE_44x		ASM_CONST(0x00000008)
 #define MMU_FTR_TYPE_FSL_E		ASM_CONST(0x00000010)
-#define MMU_FTR_TYPE_3E			ASM_CONST(0x00000020)
-#define MMU_FTR_TYPE_47x		ASM_CONST(0x00000040)
+#define MMU_FTR_TYPE_47x		ASM_CONST(0x00000020)
 
 /*
  * This is individual features
@@ -106,13 +105,6 @@
 				MMU_FTR_CI_LARGE_PAGE
 #define MMU_FTRS_PA6T		MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
 				MMU_FTR_CI_LARGE_PAGE | MMU_FTR_NO_SLBIE_B
-#define MMU_FTRS_A2		MMU_FTR_TYPE_3E | MMU_FTR_USE_TLBILX | \
-				MMU_FTR_USE_TLBIVAX_BCAST | \
-				MMU_FTR_LOCK_BCAST_INVAL | \
-				MMU_FTR_USE_TLBRSRV | \
-				MMU_FTR_USE_PAIRED_MAS | \
-				MMU_FTR_TLBIEL | \
-				MMU_FTR_16M_PAGE
 #ifndef __ASSEMBLY__
 #include <asm/cputable.h>
 
diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h
index 9ed73714..b3e9360 100644
--- a/arch/powerpc/include/asm/perf_event_server.h
+++ b/arch/powerpc/include/asm/perf_event_server.h
@@ -61,8 +61,7 @@
 #define PPMU_SIAR_VALID		0x00000010 /* Processor has SIAR Valid bit */
 #define PPMU_HAS_SSLOT		0x00000020 /* Has sampled slot in MMCRA */
 #define PPMU_HAS_SIER		0x00000040 /* Has SIER */
-#define PPMU_BHRB		0x00000080 /* has BHRB feature enabled */
-#define PPMU_EBB		0x00000100 /* supports event based branch */
+#define PPMU_ARCH_207S		0x00000080 /* PMC is architecture v2.07S */
 
 /*
  * Values for flags to get_alternatives()
diff --git a/arch/powerpc/kernel/idle_power7.S b/arch/powerpc/kernel/idle_power7.S
index 2480256..5cf3d36 100644
--- a/arch/powerpc/kernel/idle_power7.S
+++ b/arch/powerpc/kernel/idle_power7.S
@@ -131,7 +131,7 @@
 
 _GLOBAL(power7_sleep)
 	li	r3,1
-	li	r4,0
+	li	r4,1
 	b	power7_powersave_common
 	/* No return */
 
diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S
index 8c86422..731be74 100644
--- a/arch/powerpc/kvm/book3s_hv_interrupts.S
+++ b/arch/powerpc/kvm/book3s_hv_interrupts.S
@@ -127,11 +127,6 @@
 	stw	r10, HSTATE_PMC + 24(r13)
 	stw	r11, HSTATE_PMC + 28(r13)
 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
-BEGIN_FTR_SECTION
-	mfspr	r9, SPRN_SIER
-	std	r8, HSTATE_MMCR + 40(r13)
-	std	r9, HSTATE_MMCR + 48(r13)
-END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
 31:
 
 	/*
diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
index af3d78e..928ebe7 100644
--- a/arch/powerpc/mm/mmu_context_nohash.c
+++ b/arch/powerpc/mm/mmu_context_nohash.c
@@ -410,17 +410,7 @@
 	} else if (mmu_has_feature(MMU_FTR_TYPE_47x)) {
 		first_context = 1;
 		last_context = 65535;
-	} else
-#ifdef CONFIG_PPC_BOOK3E_MMU
-	if (mmu_has_feature(MMU_FTR_TYPE_3E)) {
-		u32 mmucfg = mfspr(SPRN_MMUCFG);
-		u32 pid_bits = (mmucfg & MMUCFG_PIDSIZE_MASK)
-				>> MMUCFG_PIDSIZE_SHIFT;
-		first_context = 1;
-		last_context = (1UL << (pid_bits + 1)) - 1;
-	} else
-#endif
-	{
+	} else {
 		first_context = 1;
 		last_context = 255;
 	}
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 4520c93..6b0641c 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -485,7 +485,7 @@
 	 * check that the PMU supports EBB, meaning those that don't can still
 	 * use bit 63 of the event code for something else if they wish.
 	 */
-	return (ppmu->flags & PPMU_EBB) &&
+	return (ppmu->flags & PPMU_ARCH_207S) &&
 	       ((event->attr.config >> PERF_EVENT_CONFIG_EBB_SHIFT) & 1);
 }
 
@@ -777,7 +777,7 @@
 	if (ppmu->flags & PPMU_HAS_SIER)
 		sier = mfspr(SPRN_SIER);
 
-	if (ppmu->flags & PPMU_EBB) {
+	if (ppmu->flags & PPMU_ARCH_207S) {
 		pr_info("MMCR2: %016lx EBBHR: %016lx\n",
 			mfspr(SPRN_MMCR2), mfspr(SPRN_EBBHR));
 		pr_info("EBBRR: %016lx BESCR: %016lx\n",
@@ -996,7 +996,22 @@
 	} while (local64_cmpxchg(&event->hw.prev_count, prev, val) != prev);
 
 	local64_add(delta, &event->count);
-	local64_sub(delta, &event->hw.period_left);
+
+	/*
+	 * A number of places program the PMC with (0x80000000 - period_left).
+	 * We never want period_left to be less than 1 because we will program
+	 * the PMC with a value >= 0x800000000 and an edge detected PMC will
+	 * roll around to 0 before taking an exception. We have seen this
+	 * on POWER8.
+	 *
+	 * To fix this, clamp the minimum value of period_left to 1.
+	 */
+	do {
+		prev = local64_read(&event->hw.period_left);
+		val = prev - delta;
+		if (val < 1)
+			val = 1;
+	} while (local64_cmpxchg(&event->hw.period_left, prev, val) != prev);
 }
 
 /*
@@ -1300,6 +1315,9 @@
 
 	write_mmcr0(cpuhw, mmcr0);
 
+	if (ppmu->flags & PPMU_ARCH_207S)
+		mtspr(SPRN_MMCR2, 0);
+
 	/*
 	 * Enable instruction sampling if necessary
 	 */
@@ -1696,7 +1714,7 @@
 
 	if (has_branch_stack(event)) {
 	        /* PMU has BHRB enabled */
-		if (!(ppmu->flags & PPMU_BHRB))
+		if (!(ppmu->flags & PPMU_ARCH_207S))
 			return -EOPNOTSUPP;
 	}
 
diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
index fe2763b..639cd91 100644
--- a/arch/powerpc/perf/power8-pmu.c
+++ b/arch/powerpc/perf/power8-pmu.c
@@ -792,7 +792,7 @@
 	.get_constraint		= power8_get_constraint,
 	.get_alternatives	= power8_get_alternatives,
 	.disable_pmc		= power8_disable_pmc,
-	.flags			= PPMU_HAS_SSLOT | PPMU_HAS_SIER | PPMU_BHRB | PPMU_EBB,
+	.flags			= PPMU_HAS_SSLOT | PPMU_HAS_SIER | PPMU_ARCH_207S,
 	.n_generic		= ARRAY_SIZE(power8_generic_events),
 	.generic_events		= power8_generic_events,
 	.cache_events		= &power8_cache_events,
diff --git a/arch/powerpc/platforms/cell/spu_syscalls.c b/arch/powerpc/platforms/cell/spu_syscalls.c
index 38e0a1a..5e6e0ba 100644
--- a/arch/powerpc/platforms/cell/spu_syscalls.c
+++ b/arch/powerpc/platforms/cell/spu_syscalls.c
@@ -111,6 +111,7 @@
 	return ret;
 }
 
+#ifdef CONFIG_COREDUMP
 int elf_coredump_extra_notes_size(void)
 {
 	struct spufs_calls *calls;
@@ -142,6 +143,7 @@
 
 	return ret;
 }
+#endif
 
 void notify_spus_active(void)
 {
diff --git a/arch/powerpc/platforms/cell/spufs/Makefile b/arch/powerpc/platforms/cell/spufs/Makefile
index b9d5d67..52a7d25 100644
--- a/arch/powerpc/platforms/cell/spufs/Makefile
+++ b/arch/powerpc/platforms/cell/spufs/Makefile
@@ -1,8 +1,9 @@
 
 obj-$(CONFIG_SPU_FS) += spufs.o
-spufs-y += inode.o file.o context.o syscalls.o coredump.o
+spufs-y += inode.o file.o context.o syscalls.o
 spufs-y += sched.o backing_ops.o hw_ops.o run.o gang.o
 spufs-y += switch.o fault.o lscsa_alloc.o
+spufs-$(CONFIG_COREDUMP) += coredump.o
 
 # magic for the trace events
 CFLAGS_sched.o := -I$(src)
diff --git a/arch/powerpc/platforms/cell/spufs/syscalls.c b/arch/powerpc/platforms/cell/spufs/syscalls.c
index b045fdd..a87200a 100644
--- a/arch/powerpc/platforms/cell/spufs/syscalls.c
+++ b/arch/powerpc/platforms/cell/spufs/syscalls.c
@@ -79,8 +79,10 @@
 struct spufs_calls spufs_calls = {
 	.create_thread = do_spu_create,
 	.spu_run = do_spu_run,
-	.coredump_extra_notes_size = spufs_coredump_extra_notes_size,
-	.coredump_extra_notes_write = spufs_coredump_extra_notes_write,
 	.notify_spus_active = do_notify_spus_active,
 	.owner = THIS_MODULE,
+#ifdef CONFIG_COREDUMP
+	.coredump_extra_notes_size = spufs_coredump_extra_notes_size,
+	.coredump_extra_notes_write = spufs_coredump_extra_notes_write,
+#endif
 };
diff --git a/arch/x86/crypto/sha512_ssse3_glue.c b/arch/x86/crypto/sha512_ssse3_glue.c
index f30cd10..8626b03 100644
--- a/arch/x86/crypto/sha512_ssse3_glue.c
+++ b/arch/x86/crypto/sha512_ssse3_glue.c
@@ -141,7 +141,7 @@
 
 	/* save number of bits */
 	bits[1] = cpu_to_be64(sctx->count[0] << 3);
-	bits[0] = cpu_to_be64(sctx->count[1] << 3) | sctx->count[0] >> 61;
+	bits[0] = cpu_to_be64(sctx->count[1] << 3 | sctx->count[0] >> 61);
 
 	/* Pad out to 112 mod 128 and append length */
 	index = sctx->count[0] & 0x7f;
diff --git a/arch/x86/vdso/vdso2c.h b/arch/x86/vdso/vdso2c.h
index df95a2f..11b65d4 100644
--- a/arch/x86/vdso/vdso2c.h
+++ b/arch/x86/vdso/vdso2c.h
@@ -93,6 +93,9 @@
 	uint64_t flags = GET_LE(&in->sh_flags);
 
 	bool copy = flags & SHF_ALLOC &&
+		(GET_LE(&in->sh_size) ||
+		 (GET_LE(&in->sh_type) != SHT_RELA &&
+		  GET_LE(&in->sh_type) != SHT_REL)) &&
 		strcmp(name, ".altinstructions") &&
 		strcmp(name, ".altinstr_replacement");
 
diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
index e1513c4..5a5176d 100644
--- a/arch/x86/vdso/vma.c
+++ b/arch/x86/vdso/vma.c
@@ -62,6 +62,9 @@
    Only used for the 64-bit and x32 vdsos. */
 static unsigned long vdso_addr(unsigned long start, unsigned len)
 {
+#ifdef CONFIG_X86_32
+	return 0;
+#else
 	unsigned long addr, end;
 	unsigned offset;
 	end = (start + PMD_SIZE - 1) & PMD_MASK;
@@ -83,6 +86,7 @@
 	addr = align_vdso_addr(addr);
 
 	return addr;
+#endif
 }
 
 static int map_vdso(const struct vdso_image *image, bool calculate_addr)
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index c67f6f5..36b0e61 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -30,6 +30,10 @@
 #include <linux/types.h>
 #include <linux/dmi.h>
 #include <linux/delay.h>
+#ifdef CONFIG_ACPI_PROCFS_POWER
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#endif
 #include <linux/platform_device.h>
 #include <linux/power_supply.h>
 #include <linux/acpi.h>
@@ -52,6 +56,7 @@
 MODULE_DESCRIPTION("ACPI AC Adapter Driver");
 MODULE_LICENSE("GPL");
 
+
 static int acpi_ac_add(struct acpi_device *device);
 static int acpi_ac_remove(struct acpi_device *device);
 static void acpi_ac_notify(struct acpi_device *device, u32 event);
@@ -67,6 +72,13 @@
 #endif
 static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume);
 
+#ifdef CONFIG_ACPI_PROCFS_POWER
+extern struct proc_dir_entry *acpi_lock_ac_dir(void);
+extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir);
+static int acpi_ac_open_fs(struct inode *inode, struct file *file);
+#endif
+
+
 static int ac_sleep_before_get_state_ms;
 
 static struct acpi_driver acpi_ac_driver = {
@@ -91,6 +103,16 @@
 
 #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger)
 
+#ifdef CONFIG_ACPI_PROCFS_POWER
+static const struct file_operations acpi_ac_fops = {
+	.owner = THIS_MODULE,
+	.open = acpi_ac_open_fs,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+#endif
+
 /* --------------------------------------------------------------------------
                                AC Adapter Management
    -------------------------------------------------------------------------- */
@@ -143,6 +165,83 @@
 	POWER_SUPPLY_PROP_ONLINE,
 };
 
+#ifdef CONFIG_ACPI_PROCFS_POWER
+/* --------------------------------------------------------------------------
+                              FS Interface (/proc)
+   -------------------------------------------------------------------------- */
+
+static struct proc_dir_entry *acpi_ac_dir;
+
+static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
+{
+	struct acpi_ac *ac = seq->private;
+
+
+	if (!ac)
+		return 0;
+
+	if (acpi_ac_get_state(ac)) {
+		seq_puts(seq, "ERROR: Unable to read AC Adapter state\n");
+		return 0;
+	}
+
+	seq_puts(seq, "state:                   ");
+	switch (ac->state) {
+	case ACPI_AC_STATUS_OFFLINE:
+		seq_puts(seq, "off-line\n");
+		break;
+	case ACPI_AC_STATUS_ONLINE:
+		seq_puts(seq, "on-line\n");
+		break;
+	default:
+		seq_puts(seq, "unknown\n");
+		break;
+	}
+
+	return 0;
+}
+
+static int acpi_ac_open_fs(struct inode *inode, struct file *file)
+{
+	return single_open(file, acpi_ac_seq_show, PDE_DATA(inode));
+}
+
+static int acpi_ac_add_fs(struct acpi_ac *ac)
+{
+	struct proc_dir_entry *entry = NULL;
+
+	printk(KERN_WARNING PREFIX "Deprecated procfs I/F for AC is loaded,"
+			" please retry with CONFIG_ACPI_PROCFS_POWER cleared\n");
+	if (!acpi_device_dir(ac->device)) {
+		acpi_device_dir(ac->device) =
+			proc_mkdir(acpi_device_bid(ac->device), acpi_ac_dir);
+		if (!acpi_device_dir(ac->device))
+			return -ENODEV;
+	}
+
+	/* 'state' [R] */
+	entry = proc_create_data(ACPI_AC_FILE_STATE,
+				 S_IRUGO, acpi_device_dir(ac->device),
+				 &acpi_ac_fops, ac);
+	if (!entry)
+		return -ENODEV;
+	return 0;
+}
+
+static int acpi_ac_remove_fs(struct acpi_ac *ac)
+{
+
+	if (acpi_device_dir(ac->device)) {
+		remove_proc_entry(ACPI_AC_FILE_STATE,
+				  acpi_device_dir(ac->device));
+		remove_proc_entry(acpi_device_bid(ac->device), acpi_ac_dir);
+		acpi_device_dir(ac->device) = NULL;
+	}
+
+	return 0;
+}
+#endif
+
 /* --------------------------------------------------------------------------
                                    Driver Model
    -------------------------------------------------------------------------- */
@@ -243,6 +342,11 @@
 		goto end;
 
 	ac->charger.name = acpi_device_bid(device);
+#ifdef CONFIG_ACPI_PROCFS_POWER
+	result = acpi_ac_add_fs(ac);
+	if (result)
+		goto end;
+#endif
 	ac->charger.type = POWER_SUPPLY_TYPE_MAINS;
 	ac->charger.properties = ac_props;
 	ac->charger.num_properties = ARRAY_SIZE(ac_props);
@@ -258,8 +362,12 @@
 	ac->battery_nb.notifier_call = acpi_ac_battery_notify;
 	register_acpi_notifier(&ac->battery_nb);
 end:
-	if (result)
+	if (result) {
+#ifdef CONFIG_ACPI_PROCFS_POWER
+		acpi_ac_remove_fs(ac);
+#endif
 		kfree(ac);
+	}
 
 	dmi_check_system(ac_dmi_table);
 	return result;
@@ -303,6 +411,10 @@
 		power_supply_unregister(&ac->charger);
 	unregister_acpi_notifier(&ac->battery_nb);
 
+#ifdef CONFIG_ACPI_PROCFS_POWER
+	acpi_ac_remove_fs(ac);
+#endif
+
 	kfree(ac);
 
 	return 0;
@@ -315,9 +427,20 @@
 	if (acpi_disabled)
 		return -ENODEV;
 
-	result = acpi_bus_register_driver(&acpi_ac_driver);
-	if (result < 0)
+#ifdef CONFIG_ACPI_PROCFS_POWER
+	acpi_ac_dir = acpi_lock_ac_dir();
+	if (!acpi_ac_dir)
 		return -ENODEV;
+#endif
+
+
+	result = acpi_bus_register_driver(&acpi_ac_driver);
+	if (result < 0) {
+#ifdef CONFIG_ACPI_PROCFS_POWER
+		acpi_unlock_ac_dir(acpi_ac_dir);
+#endif
+		return -ENODEV;
+	}
 
 	return 0;
 }
@@ -325,6 +448,9 @@
 static void __exit acpi_ac_exit(void)
 {
 	acpi_bus_unregister_driver(&acpi_ac_driver);
+#ifdef CONFIG_ACPI_PROCFS_POWER
+	acpi_unlock_ac_dir(acpi_ac_dir);
+#endif
 }
 module_init(acpi_ac_init);
 module_exit(acpi_ac_exit);
diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c
index 6703c1f..4ddb0dc 100644
--- a/drivers/acpi/acpi_pnp.c
+++ b/drivers/acpi/acpi_pnp.c
@@ -14,6 +14,8 @@
 #include <linux/module.h>
 
 static const struct acpi_device_id acpi_pnp_device_ids[] = {
+	/* soc_button_array */
+	{"PNP0C40"},
 	/* pata_isapnp */
 	{"PNP0600"},		/* Generic ESDI/IDE/ATA compatible hard disk controller */
 	/* floppy */
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 0d7116f..130f513 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -35,6 +35,7 @@
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/suspend.h>
+#include <linux/delay.h>
 #include <asm/unaligned.h>
 
 #ifdef CONFIG_ACPI_PROCFS_POWER
@@ -534,6 +535,20 @@
 			" invalid.\n");
 	}
 
+	/*
+	 * When fully charged, some batteries wrongly report
+	 * capacity_now = design_capacity instead of = full_charge_capacity
+	 */
+	if (battery->capacity_now > battery->full_charge_capacity
+	    && battery->full_charge_capacity != ACPI_BATTERY_VALUE_UNKNOWN) {
+		battery->capacity_now = battery->full_charge_capacity;
+		if (battery->capacity_now != battery->design_capacity)
+			printk_once(KERN_WARNING FW_BUG
+				"battery: reported current charge level (%d) "
+				"is higher than reported maximum charge level (%d).\n",
+				battery->capacity_now, battery->full_charge_capacity);
+	}
+
 	if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags)
 	    && battery->capacity_now >= 0 && battery->capacity_now <= 100)
 		battery->capacity_now = (battery->capacity_now *
@@ -1151,6 +1166,28 @@
 	{},
 };
 
+/*
+ * Some machines'(E,G Lenovo Z480) ECs are not stable
+ * during boot up and this causes battery driver fails to be
+ * probed due to failure of getting battery information
+ * from EC sometimes. After several retries, the operation
+ * may work. So add retry code here and 20ms sleep between
+ * every retries.
+ */
+static int acpi_battery_update_retry(struct acpi_battery *battery)
+{
+	int retry, ret;
+
+	for (retry = 5; retry; retry--) {
+		ret = acpi_battery_update(battery, false);
+		if (!ret)
+			break;
+
+		msleep(20);
+	}
+	return ret;
+}
+
 static int acpi_battery_add(struct acpi_device *device)
 {
 	int result = 0;
@@ -1169,9 +1206,11 @@
 	mutex_init(&battery->sysfs_lock);
 	if (acpi_has_method(battery->device->handle, "_BIX"))
 		set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags);
-	result = acpi_battery_update(battery, false);
+
+	result = acpi_battery_update_retry(battery);
 	if (result)
 		goto fail;
+
 #ifdef CONFIG_ACPI_PROCFS_POWER
 	result = acpi_battery_add_fs(device);
 #endif
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index ad11ba4..a66ab65 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -1,11 +1,14 @@
 /*
- *  ec.c - ACPI Embedded Controller Driver (v2.1)
+ *  ec.c - ACPI Embedded Controller Driver (v2.2)
  *
- *  Copyright (C) 2006-2008 Alexey Starikovskiy <astarikovskiy@suse.de>
- *  Copyright (C) 2006 Denis Sadykov <denis.m.sadykov@intel.com>
- *  Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
- *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
- *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
+ *  Copyright (C) 2001-2014 Intel Corporation
+ *    Author: 2014       Lv Zheng <lv.zheng@intel.com>
+ *            2006, 2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
+ *            2006       Denis Sadykov <denis.m.sadykov@intel.com>
+ *            2004       Luming Yu <luming.yu@intel.com>
+ *            2001, 2002 Andy Grover <andrew.grover@intel.com>
+ *            2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
+ *  Copyright (C) 2008      Alexey Starikovskiy <astarikovskiy@suse.de>
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
@@ -52,6 +55,7 @@
 /* EC status register */
 #define ACPI_EC_FLAG_OBF	0x01	/* Output buffer full */
 #define ACPI_EC_FLAG_IBF	0x02	/* Input buffer full */
+#define ACPI_EC_FLAG_CMD	0x08	/* Input buffer contains a command */
 #define ACPI_EC_FLAG_BURST	0x10	/* burst mode */
 #define ACPI_EC_FLAG_SCI	0x20	/* EC-SCI occurred */
 
@@ -78,6 +82,9 @@
 	EC_FLAGS_BLOCKED,		/* Transactions are blocked */
 };
 
+#define ACPI_EC_COMMAND_POLL		0x01 /* Available for command byte */
+#define ACPI_EC_COMMAND_COMPLETE	0x02 /* Completed last byte */
+
 /* ec.c is compiled in acpi namespace so this shows up as acpi.ec_delay param */
 static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY;
 module_param(ec_delay, uint, 0644);
@@ -109,7 +116,7 @@
 	u8 ri;
 	u8 wlen;
 	u8 rlen;
-	bool done;
+	u8 flags;
 };
 
 struct acpi_ec *boot_ec, *first_ec;
@@ -127,83 +134,104 @@
 static inline u8 acpi_ec_read_status(struct acpi_ec *ec)
 {
 	u8 x = inb(ec->command_addr);
-	pr_debug("---> status = 0x%2.2x\n", x);
+	pr_debug("EC_SC(R) = 0x%2.2x "
+		 "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d\n",
+		 x,
+		 !!(x & ACPI_EC_FLAG_SCI),
+		 !!(x & ACPI_EC_FLAG_BURST),
+		 !!(x & ACPI_EC_FLAG_CMD),
+		 !!(x & ACPI_EC_FLAG_IBF),
+		 !!(x & ACPI_EC_FLAG_OBF));
 	return x;
 }
 
 static inline u8 acpi_ec_read_data(struct acpi_ec *ec)
 {
 	u8 x = inb(ec->data_addr);
-	pr_debug("---> data = 0x%2.2x\n", x);
+	pr_debug("EC_DATA(R) = 0x%2.2x\n", x);
 	return x;
 }
 
 static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command)
 {
-	pr_debug("<--- command = 0x%2.2x\n", command);
+	pr_debug("EC_SC(W) = 0x%2.2x\n", command);
 	outb(command, ec->command_addr);
 }
 
 static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data)
 {
-	pr_debug("<--- data = 0x%2.2x\n", data);
+	pr_debug("EC_DATA(W) = 0x%2.2x\n", data);
 	outb(data, ec->data_addr);
 }
 
-static int ec_transaction_done(struct acpi_ec *ec)
+static int ec_transaction_completed(struct acpi_ec *ec)
 {
 	unsigned long flags;
 	int ret = 0;
 	spin_lock_irqsave(&ec->lock, flags);
-	if (!ec->curr || ec->curr->done)
+	if (ec->curr && (ec->curr->flags & ACPI_EC_COMMAND_COMPLETE))
 		ret = 1;
 	spin_unlock_irqrestore(&ec->lock, flags);
 	return ret;
 }
 
-static void start_transaction(struct acpi_ec *ec)
+static bool advance_transaction(struct acpi_ec *ec)
 {
-	ec->curr->irq_count = ec->curr->wi = ec->curr->ri = 0;
-	ec->curr->done = false;
-	acpi_ec_write_cmd(ec, ec->curr->command);
-}
-
-static void advance_transaction(struct acpi_ec *ec, u8 status)
-{
-	unsigned long flags;
 	struct transaction *t;
+	u8 status;
+	bool wakeup = false;
 
-	spin_lock_irqsave(&ec->lock, flags);
+	pr_debug("===== %s =====\n", in_interrupt() ? "IRQ" : "TASK");
+	status = acpi_ec_read_status(ec);
 	t = ec->curr;
 	if (!t)
-		goto unlock;
-	if (t->wlen > t->wi) {
-		if ((status & ACPI_EC_FLAG_IBF) == 0)
-			acpi_ec_write_data(ec,
-				t->wdata[t->wi++]);
-		else
-			goto err;
-	} else if (t->rlen > t->ri) {
-		if ((status & ACPI_EC_FLAG_OBF) == 1) {
-			t->rdata[t->ri++] = acpi_ec_read_data(ec);
-			if (t->rlen == t->ri)
-				t->done = true;
+		goto err;
+	if (t->flags & ACPI_EC_COMMAND_POLL) {
+		if (t->wlen > t->wi) {
+			if ((status & ACPI_EC_FLAG_IBF) == 0)
+				acpi_ec_write_data(ec, t->wdata[t->wi++]);
+			else
+				goto err;
+		} else if (t->rlen > t->ri) {
+			if ((status & ACPI_EC_FLAG_OBF) == 1) {
+				t->rdata[t->ri++] = acpi_ec_read_data(ec);
+				if (t->rlen == t->ri) {
+					t->flags |= ACPI_EC_COMMAND_COMPLETE;
+					wakeup = true;
+				}
+			} else
+				goto err;
+		} else if (t->wlen == t->wi &&
+			   (status & ACPI_EC_FLAG_IBF) == 0) {
+			t->flags |= ACPI_EC_COMMAND_COMPLETE;
+			wakeup = true;
+		}
+		return wakeup;
+	} else {
+		if ((status & ACPI_EC_FLAG_IBF) == 0) {
+			acpi_ec_write_cmd(ec, t->command);
+			t->flags |= ACPI_EC_COMMAND_POLL;
 		} else
 			goto err;
-	} else if (t->wlen == t->wi &&
-		   (status & ACPI_EC_FLAG_IBF) == 0)
-		t->done = true;
-	goto unlock;
+		return wakeup;
+	}
 err:
 	/*
 	 * If SCI bit is set, then don't think it's a false IRQ
 	 * otherwise will take a not handled IRQ as a false one.
 	 */
-	if (in_interrupt() && !(status & ACPI_EC_FLAG_SCI))
-		++t->irq_count;
+	if (!(status & ACPI_EC_FLAG_SCI)) {
+		if (in_interrupt() && t)
+			++t->irq_count;
+	}
+	return wakeup;
+}
 
-unlock:
-	spin_unlock_irqrestore(&ec->lock, flags);
+static void start_transaction(struct acpi_ec *ec)
+{
+	ec->curr->irq_count = ec->curr->wi = ec->curr->ri = 0;
+	ec->curr->flags = 0;
+	(void)advance_transaction(ec);
 }
 
 static int acpi_ec_sync_query(struct acpi_ec *ec, u8 *data);
@@ -228,15 +256,17 @@
 			/* don't sleep with disabled interrupts */
 			if (EC_FLAGS_MSI || irqs_disabled()) {
 				udelay(ACPI_EC_MSI_UDELAY);
-				if (ec_transaction_done(ec))
+				if (ec_transaction_completed(ec))
 					return 0;
 			} else {
 				if (wait_event_timeout(ec->wait,
-						ec_transaction_done(ec),
+						ec_transaction_completed(ec),
 						msecs_to_jiffies(1)))
 					return 0;
 			}
-			advance_transaction(ec, acpi_ec_read_status(ec));
+			spin_lock_irqsave(&ec->lock, flags);
+			(void)advance_transaction(ec);
+			spin_unlock_irqrestore(&ec->lock, flags);
 		} while (time_before(jiffies, delay));
 		pr_debug("controller reset, restart transaction\n");
 		spin_lock_irqsave(&ec->lock, flags);
@@ -268,23 +298,6 @@
 	return ret;
 }
 
-static int ec_check_ibf0(struct acpi_ec *ec)
-{
-	u8 status = acpi_ec_read_status(ec);
-	return (status & ACPI_EC_FLAG_IBF) == 0;
-}
-
-static int ec_wait_ibf0(struct acpi_ec *ec)
-{
-	unsigned long delay = jiffies + msecs_to_jiffies(ec_delay);
-	/* interrupt wait manually if GPE mode is not active */
-	while (time_before(jiffies, delay))
-		if (wait_event_timeout(ec->wait, ec_check_ibf0(ec),
-					msecs_to_jiffies(1)))
-			return 0;
-	return -ETIME;
-}
-
 static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t)
 {
 	int status;
@@ -305,12 +318,6 @@
 			goto unlock;
 		}
 	}
-	if (ec_wait_ibf0(ec)) {
-		pr_err("input buffer is not empty, "
-				"aborting transaction\n");
-		status = -ETIME;
-		goto end;
-	}
 	pr_debug("transaction start (cmd=0x%02x, addr=0x%02x)\n",
 			t->command, t->wdata ? t->wdata[0] : 0);
 	/* disable GPE during transaction if storm is detected */
@@ -334,7 +341,6 @@
 		set_bit(EC_FLAGS_GPE_STORM, &ec->flags);
 	}
 	pr_debug("transaction end\n");
-end:
 	if (ec->global_lock)
 		acpi_release_global_lock(glk);
 unlock:
@@ -634,17 +640,14 @@
 static u32 acpi_ec_gpe_handler(acpi_handle gpe_device,
 	u32 gpe_number, void *data)
 {
+	unsigned long flags;
 	struct acpi_ec *ec = data;
-	u8 status = acpi_ec_read_status(ec);
 
-	pr_debug("~~~> interrupt, status:0x%02x\n", status);
-
-	advance_transaction(ec, status);
-	if (ec_transaction_done(ec) &&
-	    (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) {
+	spin_lock_irqsave(&ec->lock, flags);
+	if (advance_transaction(ec))
 		wake_up(&ec->wait);
-		ec_check_sci(ec, acpi_ec_read_status(ec));
-	}
+	spin_unlock_irqrestore(&ec->lock, flags);
+	ec_check_sci(ec, acpi_ec_read_status(ec));
 	return ACPI_INTERRUPT_HANDLED | ACPI_REENABLE_GPE;
 }
 
@@ -1066,8 +1069,10 @@
 	/* fall through */
 	}
 
-	if (EC_FLAGS_SKIP_DSDT_SCAN)
+	if (EC_FLAGS_SKIP_DSDT_SCAN) {
+		kfree(saved_ec);
 		return -ENODEV;
+	}
 
 	/* This workaround is needed only on some broken machines,
 	 * which require early EC, but fail to provide ECDT */
@@ -1105,6 +1110,7 @@
 	}
 error:
 	kfree(boot_ec);
+	kfree(saved_ec);
 	boot_ec = NULL;
 	return -ENODEV;
 }
diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index 0bdacc5..2ba8f02 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -77,7 +77,7 @@
 	switch (ares->type) {
 	case ACPI_RESOURCE_TYPE_MEMORY24:
 		memory24 = &ares->data.memory24;
-		if (!memory24->address_length)
+		if (!memory24->minimum && !memory24->address_length)
 			return false;
 		acpi_dev_get_memresource(res, memory24->minimum,
 					 memory24->address_length,
@@ -85,7 +85,7 @@
 		break;
 	case ACPI_RESOURCE_TYPE_MEMORY32:
 		memory32 = &ares->data.memory32;
-		if (!memory32->address_length)
+		if (!memory32->minimum && !memory32->address_length)
 			return false;
 		acpi_dev_get_memresource(res, memory32->minimum,
 					 memory32->address_length,
@@ -93,7 +93,7 @@
 		break;
 	case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
 		fixed_memory32 = &ares->data.fixed_memory32;
-		if (!fixed_memory32->address_length)
+		if (!fixed_memory32->address && !fixed_memory32->address_length)
 			return false;
 		acpi_dev_get_memresource(res, fixed_memory32->address,
 					 fixed_memory32->address_length,
@@ -150,7 +150,7 @@
 	switch (ares->type) {
 	case ACPI_RESOURCE_TYPE_IO:
 		io = &ares->data.io;
-		if (!io->address_length)
+		if (!io->minimum && !io->address_length)
 			return false;
 		acpi_dev_get_ioresource(res, io->minimum,
 					io->address_length,
@@ -158,7 +158,7 @@
 		break;
 	case ACPI_RESOURCE_TYPE_FIXED_IO:
 		fixed_io = &ares->data.fixed_io;
-		if (!fixed_io->address_length)
+		if (!fixed_io->address && !fixed_io->address_length)
 			return false;
 		acpi_dev_get_ioresource(res, fixed_io->address,
 					fixed_io->address_length,
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index fb9ffe9..071c1df 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -241,13 +241,14 @@
 		return use_native_backlight_dmi;
 }
 
-static bool acpi_video_verify_backlight_support(void)
+bool acpi_video_verify_backlight_support(void)
 {
 	if (acpi_osi_is_win8() && acpi_video_use_native_backlight() &&
 	    backlight_device_registered(BACKLIGHT_RAW))
 		return false;
 	return acpi_video_backlight_support();
 }
+EXPORT_SYMBOL_GPL(acpi_video_verify_backlight_support);
 
 /* backlight device sysfs support */
 static int acpi_video_get_brightness(struct backlight_device *bd)
@@ -563,6 +564,14 @@
 		},
 	},
 	{
+	 .callback = video_set_use_native_backlight,
+	 .ident = "Acer TravelMate B113",
+	 .matches = {
+		DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+		DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate B113"),
+		},
+	},
+	{
 	.callback = video_set_use_native_backlight,
 	.ident = "HP ProBook 4340s",
 	.matches = {
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index 33e3db5..c42feb2 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -166,6 +166,14 @@
 		DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"),
 		},
 	},
+	{
+	.callback = video_detect_force_vendor,
+	.ident = "Dell Inspiron 5737",
+	.matches = {
+		DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+		DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"),
+		},
+	},
 	{ },
 };
 
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 05882e4..5513296 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -371,7 +371,9 @@
 		      int pmp, unsigned long deadline,
 		      int (*check_ready)(struct ata_link *link));
 
+unsigned int ahci_qc_issue(struct ata_queued_cmd *qc);
 int ahci_stop_engine(struct ata_port *ap);
+void ahci_start_fis_rx(struct ata_port *ap);
 void ahci_start_engine(struct ata_port *ap);
 int ahci_check_ready(struct ata_link *link);
 int ahci_kick_engine(struct ata_port *ap);
diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c
index 3a90152..cac4360 100644
--- a/drivers/ata/ahci_imx.c
+++ b/drivers/ata/ahci_imx.c
@@ -58,6 +58,8 @@
 struct imx_ahci_priv {
 	struct platform_device *ahci_pdev;
 	enum ahci_imx_type type;
+	struct clk *sata_clk;
+	struct clk *sata_ref_clk;
 	struct clk *ahb_clk;
 	struct regmap *gpr;
 	bool no_device;
@@ -224,7 +226,7 @@
 			return ret;
 	}
 
-	ret = ahci_platform_enable_clks(hpriv);
+	ret = clk_prepare_enable(imxpriv->sata_ref_clk);
 	if (ret < 0)
 		goto disable_regulator;
 
@@ -291,7 +293,7 @@
 				   !IMX6Q_GPR13_SATA_MPLL_CLK_EN);
 	}
 
-	ahci_platform_disable_clks(hpriv);
+	clk_disable_unprepare(imxpriv->sata_ref_clk);
 
 	if (hpriv->target_pwr)
 		regulator_disable(hpriv->target_pwr);
@@ -324,6 +326,9 @@
 	writel(reg_val | IMX_P0PHYCR_TEST_PDDQ, mmio + IMX_P0PHYCR);
 	imx_sata_disable(hpriv);
 	imxpriv->no_device = true;
+
+	dev_info(ap->dev, "no device found, disabling link.\n");
+	dev_info(ap->dev, "pass " MODULE_PARAM_PREFIX ".hotplug=1 to enable hotplug\n");
 }
 
 static int ahci_imx_softreset(struct ata_link *link, unsigned int *class,
@@ -385,6 +390,19 @@
 	imxpriv->no_device = false;
 	imxpriv->first_time = true;
 	imxpriv->type = (enum ahci_imx_type)of_id->data;
+
+	imxpriv->sata_clk = devm_clk_get(dev, "sata");
+	if (IS_ERR(imxpriv->sata_clk)) {
+		dev_err(dev, "can't get sata clock.\n");
+		return PTR_ERR(imxpriv->sata_clk);
+	}
+
+	imxpriv->sata_ref_clk = devm_clk_get(dev, "sata_ref");
+	if (IS_ERR(imxpriv->sata_ref_clk)) {
+		dev_err(dev, "can't get sata_ref clock.\n");
+		return PTR_ERR(imxpriv->sata_ref_clk);
+	}
+
 	imxpriv->ahb_clk = devm_clk_get(dev, "ahb");
 	if (IS_ERR(imxpriv->ahb_clk)) {
 		dev_err(dev, "can't get ahb clock.\n");
@@ -407,10 +425,14 @@
 
 	hpriv->plat_data = imxpriv;
 
-	ret = imx_sata_enable(hpriv);
+	ret = clk_prepare_enable(imxpriv->sata_clk);
 	if (ret)
 		return ret;
 
+	ret = imx_sata_enable(hpriv);
+	if (ret)
+		goto disable_clk;
+
 	/*
 	 * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL,
 	 * and IP vendor specific register IMX_TIMER1MS.
@@ -435,16 +457,24 @@
 	ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info,
 				      0, 0, 0);
 	if (ret)
-		imx_sata_disable(hpriv);
+		goto disable_sata;
 
+	return 0;
+
+disable_sata:
+	imx_sata_disable(hpriv);
+disable_clk:
+	clk_disable_unprepare(imxpriv->sata_clk);
 	return ret;
 }
 
 static void ahci_imx_host_stop(struct ata_host *host)
 {
 	struct ahci_host_priv *hpriv = host->private_data;
+	struct imx_ahci_priv *imxpriv = hpriv->plat_data;
 
 	imx_sata_disable(hpriv);
+	clk_disable_unprepare(imxpriv->sata_clk);
 }
 
 #ifdef CONFIG_PM_SLEEP
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index ebe505c..b10d81d 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -58,7 +58,7 @@
 	}
 
 	if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci"))
-		hflags |= AHCI_HFLAG_NO_FBS;
+		hflags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ;
 
 	rc = ahci_platform_init_host(pdev, hpriv, &ahci_port_info,
 				     hflags, 0, 0);
diff --git a/drivers/ata/ahci_xgene.c b/drivers/ata/ahci_xgene.c
index 042a9bb..ee3a365 100644
--- a/drivers/ata/ahci_xgene.c
+++ b/drivers/ata/ahci_xgene.c
@@ -78,6 +78,7 @@
 struct xgene_ahci_context {
 	struct ahci_host_priv *hpriv;
 	struct device *dev;
+	u8 last_cmd[MAX_AHCI_CHN_PERCTR]; /* tracking the last command issued*/
 	void __iomem *csr_core;		/* Core CSR address of IP */
 	void __iomem *csr_diag;		/* Diag CSR address of IP */
 	void __iomem *csr_axi;		/* AXI CSR address of IP */
@@ -98,20 +99,62 @@
 }
 
 /**
+ * xgene_ahci_restart_engine - Restart the dma engine.
+ * @ap : ATA port of interest
+ *
+ * Restarts the dma engine inside the controller.
+ */
+static int xgene_ahci_restart_engine(struct ata_port *ap)
+{
+	struct ahci_host_priv *hpriv = ap->host->private_data;
+
+	ahci_stop_engine(ap);
+	ahci_start_fis_rx(ap);
+	hpriv->start_engine(ap);
+
+	return 0;
+}
+
+/**
+ * xgene_ahci_qc_issue - Issue commands to the device
+ * @qc: Command to issue
+ *
+ * Due to Hardware errata for IDENTIFY DEVICE command, the controller cannot
+ * clear the BSY bit after receiving the PIO setup FIS. This results in the dma
+ * state machine goes into the CMFatalErrorUpdate state and locks up. By
+ * restarting the dma engine, it removes the controller out of lock up state.
+ */
+static unsigned int xgene_ahci_qc_issue(struct ata_queued_cmd *qc)
+{
+	struct ata_port *ap = qc->ap;
+	struct ahci_host_priv *hpriv = ap->host->private_data;
+	struct xgene_ahci_context *ctx = hpriv->plat_data;
+	int rc = 0;
+
+	if (unlikely(ctx->last_cmd[ap->port_no] == ATA_CMD_ID_ATA))
+		xgene_ahci_restart_engine(ap);
+
+	rc = ahci_qc_issue(qc);
+
+	/* Save the last command issued */
+	ctx->last_cmd[ap->port_no] = qc->tf.command;
+
+	return rc;
+}
+
+/**
  * xgene_ahci_read_id - Read ID data from the specified device
  * @dev: device
  * @tf: proposed taskfile
  * @id: data buffer
  *
  * This custom read ID function is required due to the fact that the HW
- * does not support DEVSLP and the controller state machine may get stuck
- * after processing the ID query command.
+ * does not support DEVSLP.
  */
 static unsigned int xgene_ahci_read_id(struct ata_device *dev,
 				       struct ata_taskfile *tf, u16 *id)
 {
 	u32 err_mask;
-	void __iomem *port_mmio = ahci_port_base(dev->link->ap);
 
 	err_mask = ata_do_dev_read_id(dev, tf, id);
 	if (err_mask)
@@ -133,16 +176,6 @@
 	 */
 	id[ATA_ID_FEATURE_SUPP] &= ~(1 << 8);
 
-	/*
-	 * Due to HW errata, restart the port if no other command active.
-	 * Otherwise the controller may get stuck.
-	 */
-	if (!readl(port_mmio + PORT_CMD_ISSUE)) {
-		writel(PORT_CMD_FIS_RX, port_mmio + PORT_CMD);
-		readl(port_mmio + PORT_CMD);	/* Force a barrier */
-		writel(PORT_CMD_FIS_RX | PORT_CMD_START, port_mmio + PORT_CMD);
-		readl(port_mmio + PORT_CMD);	/* Force a barrier */
-	}
 	return 0;
 }
 
@@ -300,6 +333,7 @@
 	.host_stop = xgene_ahci_host_stop,
 	.hardreset = xgene_ahci_hardreset,
 	.read_id = xgene_ahci_read_id,
+	.qc_issue = xgene_ahci_qc_issue,
 };
 
 static const struct ata_port_info xgene_ahci_port_info = {
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 40ea583..d72ce04 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -68,7 +68,6 @@
 
 static int ahci_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val);
 static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val);
-static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc);
 static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc);
 static int ahci_port_start(struct ata_port *ap);
 static void ahci_port_stop(struct ata_port *ap);
@@ -620,7 +619,7 @@
 }
 EXPORT_SYMBOL_GPL(ahci_stop_engine);
 
-static void ahci_start_fis_rx(struct ata_port *ap)
+void ahci_start_fis_rx(struct ata_port *ap)
 {
 	void __iomem *port_mmio = ahci_port_base(ap);
 	struct ahci_host_priv *hpriv = ap->host->private_data;
@@ -646,6 +645,7 @@
 	/* flush */
 	readl(port_mmio + PORT_CMD);
 }
+EXPORT_SYMBOL_GPL(ahci_start_fis_rx);
 
 static int ahci_stop_fis_rx(struct ata_port *ap)
 {
@@ -1945,7 +1945,7 @@
 }
 EXPORT_SYMBOL_GPL(ahci_interrupt);
 
-static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
+unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
 {
 	struct ata_port *ap = qc->ap;
 	void __iomem *port_mmio = ahci_port_base(ap);
@@ -1974,6 +1974,7 @@
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(ahci_qc_issue);
 
 static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc)
 {
diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
index 3a5b4ed..b0077589 100644
--- a/drivers/ata/libahci_platform.c
+++ b/drivers/ata/libahci_platform.c
@@ -250,8 +250,13 @@
 	if (IS_ERR(hpriv->phy)) {
 		rc = PTR_ERR(hpriv->phy);
 		switch (rc) {
-		case -ENODEV:
 		case -ENOSYS:
+			/* No PHY support. Check if PHY is required. */
+			if (of_find_property(dev->of_node, "phys", NULL)) {
+				dev_err(dev, "couldn't get sata-phy: ENOSYS\n");
+				goto err_out;
+			}
+		case -ENODEV:
 			/* continue normally */
 			hpriv->phy = NULL;
 			break;
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 5230294..69d9b0c 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -817,6 +817,61 @@
 EXPORT_SYMBOL_GPL(devm_kstrdup);
 
 /**
+ * devm_kvasprintf - Allocate resource managed space
+ *			for the formatted string.
+ * @dev: Device to allocate memory for
+ * @gfp: the GFP mask used in the devm_kmalloc() call when
+ *       allocating memory
+ * @fmt: the formatted string to duplicate
+ * @ap: the list of tokens to be placed in the formatted string
+ * RETURNS:
+ * Pointer to allocated string on success, NULL on failure.
+ */
+char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
+		      va_list ap)
+{
+	unsigned int len;
+	char *p;
+	va_list aq;
+
+	va_copy(aq, ap);
+	len = vsnprintf(NULL, 0, fmt, aq);
+	va_end(aq);
+
+	p = devm_kmalloc(dev, len+1, gfp);
+	if (!p)
+		return NULL;
+
+	vsnprintf(p, len+1, fmt, ap);
+
+	return p;
+}
+EXPORT_SYMBOL(devm_kvasprintf);
+
+/**
+ * devm_kasprintf - Allocate resource managed space
+ *		and copy an existing formatted string into that
+ * @dev: Device to allocate memory for
+ * @gfp: the GFP mask used in the devm_kmalloc() call when
+ *       allocating memory
+ * @fmt: the string to duplicate
+ * RETURNS:
+ * Pointer to allocated string on success, NULL on failure.
+ */
+char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...)
+{
+	va_list ap;
+	char *p;
+
+	va_start(ap, fmt);
+	p = devm_kvasprintf(dev, gfp, fmt, ap);
+	va_end(ap);
+
+	return p;
+}
+EXPORT_SYMBOL_GPL(devm_kasprintf);
+
+/**
  * devm_kfree - Resource-managed kfree
  * @dev: Device this memory belongs to
  * @p: Memory to free
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index d915707..93dcad0 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -138,7 +138,9 @@
 	if (!alloc_cpumask_var(&old_mask, GFP_KERNEL))
 		return -ENOMEM;
 	cpumask_copy(old_mask, &current->cpus_allowed);
-	set_cpus_allowed_ptr(current, cpumask_of(0));
+	rc = set_cpus_allowed_ptr(current, cpumask_of(0));
+	if (rc)
+		goto out;
 	if (smp_processor_id() != 0) {
 		rc = -EBUSY;
 		goto out;
diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c
index 9b7b585..3757e9e 100644
--- a/drivers/clk/clk-s2mps11.c
+++ b/drivers/clk/clk-s2mps11.c
@@ -230,16 +230,13 @@
 			goto err_reg;
 		}
 
-		s2mps11_clk->lookup = devm_kzalloc(&pdev->dev,
-					sizeof(struct clk_lookup), GFP_KERNEL);
+		s2mps11_clk->lookup = clkdev_alloc(s2mps11_clk->clk,
+					s2mps11_name(s2mps11_clk), NULL);
 		if (!s2mps11_clk->lookup) {
 			ret = -ENOMEM;
 			goto err_lup;
 		}
 
-		s2mps11_clk->lookup->con_id = s2mps11_name(s2mps11_clk);
-		s2mps11_clk->lookup->clk = s2mps11_clk->clk;
-
 		clkdev_add(s2mps11_clk->lookup);
 	}
 
diff --git a/drivers/clk/qcom/mmcc-msm8960.c b/drivers/clk/qcom/mmcc-msm8960.c
index 12f3c0b..4c449b3 100644
--- a/drivers/clk/qcom/mmcc-msm8960.c
+++ b/drivers/clk/qcom/mmcc-msm8960.c
@@ -1209,7 +1209,7 @@
 
 static u8 mmcc_pxo_hdmi_map[] = {
 	[P_PXO]		= 0,
-	[P_HDMI_PLL]	= 2,
+	[P_HDMI_PLL]	= 3,
 };
 
 static const char *mmcc_pxo_hdmi[] = {
diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c
index 4f150c9..7f4a473 100644
--- a/drivers/clk/samsung/clk-exynos4.c
+++ b/drivers/clk/samsung/clk-exynos4.c
@@ -925,21 +925,13 @@
 	GATE(CLK_RTC, "rtc", "aclk100", E4X12_GATE_IP_PERIR, 15,
 			0, 0),
 	GATE(CLK_KEYIF, "keyif", "aclk100", E4X12_GATE_IP_PERIR, 16, 0, 0),
-	GATE(CLK_SCLK_PWM_ISP, "sclk_pwm_isp", "div_pwm_isp",
-			E4X12_SRC_MASK_ISP, 0, CLK_SET_RATE_PARENT, 0),
-	GATE(CLK_SCLK_SPI0_ISP, "sclk_spi0_isp", "div_spi0_isp_pre",
-			E4X12_SRC_MASK_ISP, 4, CLK_SET_RATE_PARENT, 0),
-	GATE(CLK_SCLK_SPI1_ISP, "sclk_spi1_isp", "div_spi1_isp_pre",
-			E4X12_SRC_MASK_ISP, 8, CLK_SET_RATE_PARENT, 0),
-	GATE(CLK_SCLK_UART_ISP, "sclk_uart_isp", "div_uart_isp",
-			E4X12_SRC_MASK_ISP, 12, CLK_SET_RATE_PARENT, 0),
-	GATE(CLK_PWM_ISP_SCLK, "pwm_isp_sclk", "sclk_pwm_isp",
+	GATE(CLK_PWM_ISP_SCLK, "pwm_isp_sclk", "div_pwm_isp",
 			E4X12_GATE_IP_ISP, 0, 0, 0),
-	GATE(CLK_SPI0_ISP_SCLK, "spi0_isp_sclk", "sclk_spi0_isp",
+	GATE(CLK_SPI0_ISP_SCLK, "spi0_isp_sclk", "div_spi0_isp_pre",
 			E4X12_GATE_IP_ISP, 1, 0, 0),
-	GATE(CLK_SPI1_ISP_SCLK, "spi1_isp_sclk", "sclk_spi1_isp",
+	GATE(CLK_SPI1_ISP_SCLK, "spi1_isp_sclk", "div_spi1_isp_pre",
 			E4X12_GATE_IP_ISP, 2, 0, 0),
-	GATE(CLK_UART_ISP_SCLK, "uart_isp_sclk", "sclk_uart_isp",
+	GATE(CLK_UART_ISP_SCLK, "uart_isp_sclk", "div_uart_isp",
 			E4X12_GATE_IP_ISP, 3, 0, 0),
 	GATE(CLK_WDT, "watchdog", "aclk100", E4X12_GATE_IP_PERIR, 14, 0, 0),
 	GATE(CLK_PCM0, "pcm0", "aclk100", E4X12_GATE_IP_MAUDIO, 2,
diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c
index 1fad4c5..184f642 100644
--- a/drivers/clk/samsung/clk-exynos5250.c
+++ b/drivers/clk/samsung/clk-exynos5250.c
@@ -661,7 +661,7 @@
 	GATE(CLK_RTC, "rtc", "div_aclk66", GATE_IP_PERIS, 20, 0, 0),
 	GATE(CLK_TMU, "tmu", "div_aclk66", GATE_IP_PERIS, 21, 0, 0),
 	GATE(CLK_SMMU_TV, "smmu_tv", "mout_aclk200_disp1_sub",
-			GATE_IP_DISP1, 2, 0, 0),
+			GATE_IP_DISP1, 9, 0, 0),
 	GATE(CLK_SMMU_FIMD1, "smmu_fimd1", "mout_aclk200_disp1_sub",
 			GATE_IP_DISP1, 8, 0, 0),
 	GATE(CLK_SMMU_2D, "smmu_2d", "div_aclk200", GATE_IP_ACP, 7, 0, 0),
diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c
index 9d7d7ee..a4e6cc7 100644
--- a/drivers/clk/samsung/clk-exynos5420.c
+++ b/drivers/clk/samsung/clk-exynos5420.c
@@ -631,7 +631,8 @@
 			SRC_TOP4, 16, 1),
 	MUX(0, "mout_user_aclk266", mout_user_aclk266_p, SRC_TOP4, 20, 1),
 	MUX(0, "mout_user_aclk166", mout_user_aclk166_p, SRC_TOP4, 24, 1),
-	MUX(0, "mout_user_aclk333", mout_user_aclk333_p, SRC_TOP4, 28, 1),
+	MUX(CLK_MOUT_USER_ACLK333, "mout_user_aclk333", mout_user_aclk333_p,
+			SRC_TOP4, 28, 1),
 
 	MUX(0, "mout_user_aclk400_disp1", mout_user_aclk400_disp1_p,
 			SRC_TOP5, 0, 1),
@@ -684,7 +685,8 @@
 			SRC_TOP11, 12, 1),
 	MUX(0, "mout_sw_aclk266", mout_sw_aclk266_p, SRC_TOP11, 20, 1),
 	MUX(0, "mout_sw_aclk166", mout_sw_aclk166_p, SRC_TOP11, 24, 1),
-	MUX(0, "mout_sw_aclk333", mout_sw_aclk333_p, SRC_TOP11, 28, 1),
+	MUX(CLK_MOUT_SW_ACLK333, "mout_sw_aclk333", mout_sw_aclk333_p,
+			SRC_TOP11, 28, 1),
 
 	MUX(0, "mout_sw_aclk400_disp1", mout_sw_aclk400_disp1_p,
 			SRC_TOP12, 4, 1),
@@ -890,8 +892,6 @@
 			GATE_BUS_TOP, 9, CLK_IGNORE_UNUSED, 0),
 	GATE(0, "aclk66_psgen", "mout_user_aclk66_psgen",
 			GATE_BUS_TOP, 10, CLK_IGNORE_UNUSED, 0),
-	GATE(CLK_ACLK66_PERIC, "aclk66_peric", "mout_user_aclk66_peric",
-			GATE_BUS_TOP, 11, CLK_IGNORE_UNUSED, 0),
 	GATE(0, "aclk266_isp", "mout_user_aclk266_isp",
 			GATE_BUS_TOP, 13, 0, 0),
 	GATE(0, "aclk166", "mout_user_aclk166",
@@ -994,34 +994,61 @@
 			SRC_MASK_FSYS, 24, CLK_SET_RATE_PARENT, 0),
 
 	/* PERIC Block */
-	GATE(CLK_UART0, "uart0", "aclk66_peric", GATE_IP_PERIC, 0, 0, 0),
-	GATE(CLK_UART1, "uart1", "aclk66_peric", GATE_IP_PERIC, 1, 0, 0),
-	GATE(CLK_UART2, "uart2", "aclk66_peric", GATE_IP_PERIC, 2, 0, 0),
-	GATE(CLK_UART3, "uart3", "aclk66_peric", GATE_IP_PERIC, 3, 0, 0),
-	GATE(CLK_I2C0, "i2c0", "aclk66_peric", GATE_IP_PERIC, 6, 0, 0),
-	GATE(CLK_I2C1, "i2c1", "aclk66_peric", GATE_IP_PERIC, 7, 0, 0),
-	GATE(CLK_I2C2, "i2c2", "aclk66_peric", GATE_IP_PERIC, 8, 0, 0),
-	GATE(CLK_I2C3, "i2c3", "aclk66_peric", GATE_IP_PERIC, 9, 0, 0),
-	GATE(CLK_USI0, "usi0", "aclk66_peric", GATE_IP_PERIC, 10, 0, 0),
-	GATE(CLK_USI1, "usi1", "aclk66_peric", GATE_IP_PERIC, 11, 0, 0),
-	GATE(CLK_USI2, "usi2", "aclk66_peric", GATE_IP_PERIC, 12, 0, 0),
-	GATE(CLK_USI3, "usi3", "aclk66_peric", GATE_IP_PERIC, 13, 0, 0),
-	GATE(CLK_I2C_HDMI, "i2c_hdmi", "aclk66_peric", GATE_IP_PERIC, 14, 0, 0),
-	GATE(CLK_TSADC, "tsadc", "aclk66_peric", GATE_IP_PERIC, 15, 0, 0),
-	GATE(CLK_SPI0, "spi0", "aclk66_peric", GATE_IP_PERIC, 16, 0, 0),
-	GATE(CLK_SPI1, "spi1", "aclk66_peric", GATE_IP_PERIC, 17, 0, 0),
-	GATE(CLK_SPI2, "spi2", "aclk66_peric", GATE_IP_PERIC, 18, 0, 0),
-	GATE(CLK_I2S1, "i2s1", "aclk66_peric", GATE_IP_PERIC, 20, 0, 0),
-	GATE(CLK_I2S2, "i2s2", "aclk66_peric", GATE_IP_PERIC, 21, 0, 0),
-	GATE(CLK_PCM1, "pcm1", "aclk66_peric", GATE_IP_PERIC, 22, 0, 0),
-	GATE(CLK_PCM2, "pcm2", "aclk66_peric", GATE_IP_PERIC, 23, 0, 0),
-	GATE(CLK_PWM, "pwm", "aclk66_peric", GATE_IP_PERIC, 24, 0, 0),
-	GATE(CLK_SPDIF, "spdif", "aclk66_peric", GATE_IP_PERIC, 26, 0, 0),
-	GATE(CLK_USI4, "usi4", "aclk66_peric", GATE_IP_PERIC, 28, 0, 0),
-	GATE(CLK_USI5, "usi5", "aclk66_peric", GATE_IP_PERIC, 30, 0, 0),
-	GATE(CLK_USI6, "usi6", "aclk66_peric", GATE_IP_PERIC, 31, 0, 0),
+	GATE(CLK_UART0, "uart0", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 0, 0, 0),
+	GATE(CLK_UART1, "uart1", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 1, 0, 0),
+	GATE(CLK_UART2, "uart2", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 2, 0, 0),
+	GATE(CLK_UART3, "uart3", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 3, 0, 0),
+	GATE(CLK_I2C0, "i2c0", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 6, 0, 0),
+	GATE(CLK_I2C1, "i2c1", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 7, 0, 0),
+	GATE(CLK_I2C2, "i2c2", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 8, 0, 0),
+	GATE(CLK_I2C3, "i2c3", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 9, 0, 0),
+	GATE(CLK_USI0, "usi0", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 10, 0, 0),
+	GATE(CLK_USI1, "usi1", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 11, 0, 0),
+	GATE(CLK_USI2, "usi2", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 12, 0, 0),
+	GATE(CLK_USI3, "usi3", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 13, 0, 0),
+	GATE(CLK_I2C_HDMI, "i2c_hdmi", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 14, 0, 0),
+	GATE(CLK_TSADC, "tsadc", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 15, 0, 0),
+	GATE(CLK_SPI0, "spi0", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 16, 0, 0),
+	GATE(CLK_SPI1, "spi1", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 17, 0, 0),
+	GATE(CLK_SPI2, "spi2", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 18, 0, 0),
+	GATE(CLK_I2S1, "i2s1", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 20, 0, 0),
+	GATE(CLK_I2S2, "i2s2", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 21, 0, 0),
+	GATE(CLK_PCM1, "pcm1", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 22, 0, 0),
+	GATE(CLK_PCM2, "pcm2", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 23, 0, 0),
+	GATE(CLK_PWM, "pwm", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 24, 0, 0),
+	GATE(CLK_SPDIF, "spdif", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 26, 0, 0),
+	GATE(CLK_USI4, "usi4", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 28, 0, 0),
+	GATE(CLK_USI5, "usi5", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 30, 0, 0),
+	GATE(CLK_USI6, "usi6", "mout_user_aclk66_peric",
+			GATE_IP_PERIC, 31, 0, 0),
 
-	GATE(CLK_KEYIF, "keyif", "aclk66_peric", GATE_BUS_PERIC, 22, 0, 0),
+	GATE(CLK_KEYIF, "keyif", "mout_user_aclk66_peric",
+			GATE_BUS_PERIC, 22, 0, 0),
 
 	/* PERIS Block */
 	GATE(CLK_CHIPID, "chipid", "aclk66_psgen",
diff --git a/drivers/clk/samsung/clk-s3c2410.c b/drivers/clk/samsung/clk-s3c2410.c
index ba07168..140f473 100644
--- a/drivers/clk/samsung/clk-s3c2410.c
+++ b/drivers/clk/samsung/clk-s3c2410.c
@@ -152,6 +152,11 @@
 	ALIAS(HCLK, NULL, "hclk"),
 	ALIAS(MPLL, NULL, "mpll"),
 	ALIAS(FCLK, NULL, "fclk"),
+	ALIAS(PCLK, NULL, "watchdog"),
+	ALIAS(PCLK_SDI, NULL, "sdi"),
+	ALIAS(HCLK_NAND, NULL, "nand"),
+	ALIAS(PCLK_I2S, NULL, "iis"),
+	ALIAS(PCLK_I2C, NULL, "i2c"),
 };
 
 /* S3C2410 specific clocks */
@@ -378,7 +383,7 @@
 	if (!np)
 		s3c2410_common_clk_register_fixed_ext(ctx, xti_f);
 
-	if (current_soc == 2410) {
+	if (current_soc == S3C2410) {
 		if (_get_rate("xti") == 12 * MHZ) {
 			s3c2410_plls[mpll].rate_table = pll_s3c2410_12mhz_tbl;
 			s3c2410_plls[upll].rate_table = pll_s3c2410_12mhz_tbl;
@@ -432,7 +437,7 @@
 		samsung_clk_register_fixed_factor(ctx, s3c2410_ffactor,
 				ARRAY_SIZE(s3c2410_ffactor));
 		samsung_clk_register_alias(ctx, s3c2410_aliases,
-			ARRAY_SIZE(s3c2410_common_aliases));
+			ARRAY_SIZE(s3c2410_aliases));
 		break;
 	case S3C2440:
 		samsung_clk_register_mux(ctx, s3c2440_muxes,
diff --git a/drivers/clk/samsung/clk-s3c64xx.c b/drivers/clk/samsung/clk-s3c64xx.c
index efa16ee..8889ff1c 100644
--- a/drivers/clk/samsung/clk-s3c64xx.c
+++ b/drivers/clk/samsung/clk-s3c64xx.c
@@ -418,8 +418,10 @@
 	ALIAS(SCLK_MMC2, "s3c-sdhci.2", "mmc_busclk.2"),
 	ALIAS(SCLK_MMC1, "s3c-sdhci.1", "mmc_busclk.2"),
 	ALIAS(SCLK_MMC0, "s3c-sdhci.0", "mmc_busclk.2"),
-	ALIAS(SCLK_SPI1, "s3c6410-spi.1", "spi-bus"),
-	ALIAS(SCLK_SPI0, "s3c6410-spi.0", "spi-bus"),
+	ALIAS(PCLK_SPI1, "s3c6410-spi.1", "spi_busclk0"),
+	ALIAS(SCLK_SPI1, "s3c6410-spi.1", "spi_busclk2"),
+	ALIAS(PCLK_SPI0, "s3c6410-spi.0", "spi_busclk0"),
+	ALIAS(SCLK_SPI0, "s3c6410-spi.0", "spi_busclk2"),
 	ALIAS(SCLK_AUDIO1, "samsung-pcm.1", "audio-bus"),
 	ALIAS(SCLK_AUDIO1, "samsung-i2s.1", "audio-bus"),
 	ALIAS(SCLK_AUDIO0, "samsung-pcm.0", "audio-bus"),
diff --git a/drivers/clk/spear/spear3xx_clock.c b/drivers/clk/spear/spear3xx_clock.c
index c2d2043..bb5f387 100644
--- a/drivers/clk/spear/spear3xx_clock.c
+++ b/drivers/clk/spear/spear3xx_clock.c
@@ -211,7 +211,7 @@
 /* array of all spear 320 clock lookups */
 #ifdef CONFIG_MACH_SPEAR320
 
-#define SPEAR320_CONTROL_REG		(soc_config_base + 0x0000)
+#define SPEAR320_CONTROL_REG		(soc_config_base + 0x0010)
 #define SPEAR320_EXT_CTRL_REG		(soc_config_base + 0x0018)
 
 	#define SPEAR320_UARTX_PCLK_MASK		0x1
@@ -245,7 +245,8 @@
 	"ras_syn0_gclk", };
 static const char *uartx_parents[] = { "ras_syn1_gclk", "ras_apb_clk", };
 
-static void __init spear320_clk_init(void __iomem *soc_config_base)
+static void __init spear320_clk_init(void __iomem *soc_config_base,
+				     struct clk *ras_apb_clk)
 {
 	struct clk *clk;
 
@@ -342,6 +343,8 @@
 			SPEAR320_CONTROL_REG, UART1_PCLK_SHIFT, UART1_PCLK_MASK,
 			0, &_lock);
 	clk_register_clkdev(clk, NULL, "a3000000.serial");
+	/* Enforce ras_apb_clk */
+	clk_set_parent(clk, ras_apb_clk);
 
 	clk = clk_register_mux(NULL, "uart2_clk", uartx_parents,
 			ARRAY_SIZE(uartx_parents),
@@ -349,6 +352,8 @@
 			SPEAR320_EXT_CTRL_REG, SPEAR320_UART2_PCLK_SHIFT,
 			SPEAR320_UARTX_PCLK_MASK, 0, &_lock);
 	clk_register_clkdev(clk, NULL, "a4000000.serial");
+	/* Enforce ras_apb_clk */
+	clk_set_parent(clk, ras_apb_clk);
 
 	clk = clk_register_mux(NULL, "uart3_clk", uartx_parents,
 			ARRAY_SIZE(uartx_parents),
@@ -379,12 +384,12 @@
 	clk_register_clkdev(clk, NULL, "60100000.serial");
 }
 #else
-static inline void spear320_clk_init(void __iomem *soc_config_base) { }
+static inline void spear320_clk_init(void __iomem *sb, struct clk *rc) { }
 #endif
 
 void __init spear3xx_clk_init(void __iomem *misc_base, void __iomem *soc_config_base)
 {
-	struct clk *clk, *clk1;
+	struct clk *clk, *clk1, *ras_apb_clk;
 
 	clk = clk_register_fixed_rate(NULL, "osc_32k_clk", NULL, CLK_IS_ROOT,
 			32000);
@@ -613,6 +618,7 @@
 	clk = clk_register_gate(NULL, "ras_apb_clk", "apb_clk", 0, RAS_CLK_ENB,
 			RAS_APB_CLK_ENB, 0, &_lock);
 	clk_register_clkdev(clk, "ras_apb_clk", NULL);
+	ras_apb_clk = clk;
 
 	clk = clk_register_gate(NULL, "ras_32k_clk", "osc_32k_clk", 0,
 			RAS_CLK_ENB, RAS_32K_CLK_ENB, 0, &_lock);
@@ -659,5 +665,5 @@
 	else if (of_machine_is_compatible("st,spear310"))
 		spear310_clk_init();
 	else if (of_machine_is_compatible("st,spear320"))
-		spear320_clk_init(soc_config_base);
+		spear320_clk_init(soc_config_base, ras_apb_clk);
 }
diff --git a/drivers/clk/sunxi/clk-sun6i-apb0-gates.c b/drivers/clk/sunxi/clk-sun6i-apb0-gates.c
index 44cd27c..670f90d 100644
--- a/drivers/clk/sunxi/clk-sun6i-apb0-gates.c
+++ b/drivers/clk/sunxi/clk-sun6i-apb0-gates.c
@@ -29,7 +29,7 @@
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	reg = devm_ioremap_resource(&pdev->dev, r);
-	if (!reg)
+	if (IS_ERR(reg))
 		return PTR_ERR(reg);
 
 	clk_parent = of_clk_get_parent_name(np, 0);
diff --git a/drivers/clk/ti/apll.c b/drivers/clk/ti/apll.c
index 5428c9c..72d9727 100644
--- a/drivers/clk/ti/apll.c
+++ b/drivers/clk/ti/apll.c
@@ -77,13 +77,11 @@
 	if (i == MAX_APLL_WAIT_TRIES) {
 		pr_warn("clock: %s failed transition to '%s'\n",
 			clk_name, (state) ? "locked" : "bypassed");
-	} else {
+		r = -EBUSY;
+	} else
 		pr_debug("clock: %s transition to '%s' in %d loops\n",
 			 clk_name, (state) ? "locked" : "bypassed", i);
 
-		r = 0;
-	}
-
 	return r;
 }
 
@@ -338,7 +336,7 @@
 	const char *parent_name;
 	u32 val;
 
-	ad = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
+	ad = kzalloc(sizeof(*ad), GFP_KERNEL);
 	clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
 	init = kzalloc(sizeof(*init), GFP_KERNEL);
 
diff --git a/drivers/clk/ti/dpll.c b/drivers/clk/ti/dpll.c
index abd956d..79791e1 100644
--- a/drivers/clk/ti/dpll.c
+++ b/drivers/clk/ti/dpll.c
@@ -161,7 +161,8 @@
 }
 
 #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
-	defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM33XX)
+	defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM33XX) || \
+	defined(CONFIG_SOC_AM43XX)
 /**
  * ti_clk_register_dpll_x2 - Registers a DPLLx2 clock
  * @node: device node for this clock
@@ -322,7 +323,7 @@
 	       of_ti_omap4_dpll_x2_setup);
 #endif
 
-#ifdef CONFIG_SOC_AM33XX
+#if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
 static void __init of_ti_am3_dpll_x2_setup(struct device_node *node)
 {
 	ti_clk_register_dpll_x2(node, &dpll_x2_ck_ops, NULL);
diff --git a/drivers/clk/ti/mux.c b/drivers/clk/ti/mux.c
index 0197a47..e9d650e 100644
--- a/drivers/clk/ti/mux.c
+++ b/drivers/clk/ti/mux.c
@@ -160,7 +160,7 @@
 	u8 clk_mux_flags = 0;
 	u32 mask = 0;
 	u32 shift = 0;
-	u32 flags = 0;
+	u32 flags = CLK_SET_RATE_NO_REPARENT;
 
 	num_parents = of_clk_get_parent_count(node);
 	if (num_parents < 2) {
diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c
index f71d55f..ab51bf20a 100644
--- a/drivers/clocksource/exynos_mct.c
+++ b/drivers/clocksource/exynos_mct.c
@@ -162,7 +162,7 @@
 	exynos4_mct_write(reg, EXYNOS4_MCT_G_TCON);
 }
 
-static cycle_t exynos4_frc_read(struct clocksource *cs)
+static cycle_t notrace _exynos4_frc_read(void)
 {
 	unsigned int lo, hi;
 	u32 hi2 = __raw_readl(reg_base + EXYNOS4_MCT_G_CNT_U);
@@ -176,6 +176,11 @@
 	return ((cycle_t)hi << 32) | lo;
 }
 
+static cycle_t exynos4_frc_read(struct clocksource *cs)
+{
+	return _exynos4_frc_read();
+}
+
 static void exynos4_frc_resume(struct clocksource *cs)
 {
 	exynos4_mct_frc_start();
@@ -192,13 +197,24 @@
 
 static u64 notrace exynos4_read_sched_clock(void)
 {
-	return exynos4_frc_read(&mct_frc);
+	return _exynos4_frc_read();
+}
+
+static struct delay_timer exynos4_delay_timer;
+
+static cycles_t exynos4_read_current_timer(void)
+{
+	return _exynos4_frc_read();
 }
 
 static void __init exynos4_clocksource_init(void)
 {
 	exynos4_mct_frc_start();
 
+	exynos4_delay_timer.read_current_timer = &exynos4_read_current_timer;
+	exynos4_delay_timer.freq = clk_rate;
+	register_current_timer_delay(&exynos4_delay_timer);
+
 	if (clocksource_register_hz(&mct_frc, clk_rate))
 		panic("%s: can't register clocksource\n", mct_frc.name);
 
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 738c8b7..db6d9a2 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -49,7 +49,7 @@
 # LITTLE drivers, so that it is probed last.
 obj-$(CONFIG_ARM_DT_BL_CPUFREQ)		+= arm_big_little_dt.o
 
-obj-$(CONFIG_ARCH_DAVINCI_DA850)	+= davinci-cpufreq.o
+obj-$(CONFIG_ARCH_DAVINCI)		+= davinci-cpufreq.o
 obj-$(CONFIG_UX500_SOC_DB8500)		+= dbx500-cpufreq.o
 obj-$(CONFIG_ARM_EXYNOS_CPUFREQ)	+= exynos-cpufreq.o
 obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ)	+= exynos4210-cpufreq.o
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 924bb2d..86631cb 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -128,6 +128,7 @@
 
 struct perf_limits {
 	int no_turbo;
+	int turbo_disabled;
 	int max_perf_pct;
 	int min_perf_pct;
 	int32_t max_perf;
@@ -287,7 +288,10 @@
 	if (ret != 1)
 		return -EINVAL;
 	limits.no_turbo = clamp_t(int, input, 0 , 1);
-
+	if (limits.turbo_disabled) {
+		pr_warn("Turbo disabled by BIOS or unavailable on processor\n");
+		limits.no_turbo = limits.turbo_disabled;
+	}
 	return count;
 }
 
@@ -357,21 +361,21 @@
 {
 	u64 value;
 	rdmsrl(BYT_RATIOS, value);
-	return (value >> 8) & 0x3F;
+	return (value >> 8) & 0x7F;
 }
 
 static int byt_get_max_pstate(void)
 {
 	u64 value;
 	rdmsrl(BYT_RATIOS, value);
-	return (value >> 16) & 0x3F;
+	return (value >> 16) & 0x7F;
 }
 
 static int byt_get_turbo_pstate(void)
 {
 	u64 value;
 	rdmsrl(BYT_TURBO_RATIOS, value);
-	return value & 0x3F;
+	return value & 0x7F;
 }
 
 static void byt_set_pstate(struct cpudata *cpudata, int pstate)
@@ -381,7 +385,7 @@
 	u32 vid;
 
 	val = pstate << 8;
-	if (limits.no_turbo)
+	if (limits.no_turbo && !limits.turbo_disabled)
 		val |= (u64)1 << 32;
 
 	vid_fp = cpudata->vid.min + mul_fp(
@@ -405,8 +409,8 @@
 
 
 	rdmsrl(BYT_VIDS, value);
-	cpudata->vid.min = int_tofp((value >> 8) & 0x3f);
-	cpudata->vid.max = int_tofp((value >> 16) & 0x3f);
+	cpudata->vid.min = int_tofp((value >> 8) & 0x7f);
+	cpudata->vid.max = int_tofp((value >> 16) & 0x7f);
 	cpudata->vid.ratio = div_fp(
 		cpudata->vid.max - cpudata->vid.min,
 		int_tofp(cpudata->pstate.max_pstate -
@@ -448,7 +452,7 @@
 	u64 val;
 
 	val = pstate << 8;
-	if (limits.no_turbo)
+	if (limits.no_turbo && !limits.turbo_disabled)
 		val |= (u64)1 << 32;
 
 	wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val);
@@ -696,9 +700,8 @@
 
 	cpu = all_cpu_data[cpunum];
 
-	intel_pstate_get_cpu_pstates(cpu);
-
 	cpu->cpu = cpunum;
+	intel_pstate_get_cpu_pstates(cpu);
 
 	init_timer_deferrable(&cpu->timer);
 	cpu->timer.function = intel_pstate_timer_func;
@@ -741,7 +744,7 @@
 		limits.min_perf = int_tofp(1);
 		limits.max_perf_pct = 100;
 		limits.max_perf = int_tofp(1);
-		limits.no_turbo = 0;
+		limits.no_turbo = limits.turbo_disabled;
 		return 0;
 	}
 	limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq;
@@ -784,6 +787,7 @@
 {
 	struct cpudata *cpu;
 	int rc;
+	u64 misc_en;
 
 	rc = intel_pstate_init_cpu(policy->cpu);
 	if (rc)
@@ -791,8 +795,13 @@
 
 	cpu = all_cpu_data[policy->cpu];
 
-	if (!limits.no_turbo &&
-		limits.min_perf_pct == 100 && limits.max_perf_pct == 100)
+	rdmsrl(MSR_IA32_MISC_ENABLE, misc_en);
+	if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE ||
+		cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) {
+		limits.turbo_disabled = 1;
+		limits.no_turbo = 1;
+	}
+	if (limits.min_perf_pct == 100 && limits.max_perf_pct == 100)
 		policy->policy = CPUFREQ_POLICY_PERFORMANCE;
 	else
 		policy->policy = CPUFREQ_POLICY_POWERSAVE;
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c
index 1d80bd3..b512a4b 100644
--- a/drivers/crypto/caam/jr.c
+++ b/drivers/crypto/caam/jr.c
@@ -453,8 +453,8 @@
 	int error;
 
 	jrdev = &pdev->dev;
-	jrpriv = kmalloc(sizeof(struct caam_drv_private_jr),
-			 GFP_KERNEL);
+	jrpriv = devm_kmalloc(jrdev, sizeof(struct caam_drv_private_jr),
+			      GFP_KERNEL);
 	if (!jrpriv)
 		return -ENOMEM;
 
@@ -487,10 +487,8 @@
 
 	/* Now do the platform independent part */
 	error = caam_jr_init(jrdev); /* now turn on hardware */
-	if (error) {
-		kfree(jrpriv);
+	if (error)
 		return error;
-	}
 
 	jrpriv->dev = jrdev;
 	spin_lock(&driver_data.jr_alloc_lock);
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index d028f36..8f8b0b6 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -86,6 +86,9 @@
 
 #define USBSS_IRQ_PD_COMP	(1 <<  2)
 
+/* Packet Descriptor */
+#define PD2_ZERO_LENGTH		(1 << 19)
+
 struct cppi41_channel {
 	struct dma_chan chan;
 	struct dma_async_tx_descriptor txd;
@@ -307,7 +310,7 @@
 			__iormb();
 
 		while (val) {
-			u32 desc;
+			u32 desc, len;
 
 			q_num = __fls(val);
 			val &= ~(1 << q_num);
@@ -319,9 +322,13 @@
 						q_num, desc);
 				continue;
 			}
-			c->residue = pd_trans_len(c->desc->pd6) -
-				pd_trans_len(c->desc->pd0);
 
+			if (c->desc->pd2 & PD2_ZERO_LENGTH)
+				len = 0;
+			else
+				len = pd_trans_len(c->desc->pd0);
+
+			c->residue = pd_trans_len(c->desc->pd6) - len;
 			dma_cookie_complete(&c->txd);
 			c->txd.callback(c->txd.callback_param);
 		}
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 1287146..14867e3 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -255,6 +255,7 @@
 	enum dma_slave_buswidth		word_size;
 	unsigned int			buf_tail;
 	unsigned int			num_bd;
+	unsigned int			period_len;
 	struct sdma_buffer_descriptor	*bd;
 	dma_addr_t			bd_phys;
 	unsigned int			pc_from_device, pc_to_device;
@@ -593,6 +594,12 @@
 
 static void sdma_handle_channel_loop(struct sdma_channel *sdmac)
 {
+	if (sdmac->desc.callback)
+		sdmac->desc.callback(sdmac->desc.callback_param);
+}
+
+static void sdma_update_channel_loop(struct sdma_channel *sdmac)
+{
 	struct sdma_buffer_descriptor *bd;
 
 	/*
@@ -611,9 +618,6 @@
 		bd->mode.status |= BD_DONE;
 		sdmac->buf_tail++;
 		sdmac->buf_tail %= sdmac->num_bd;
-
-		if (sdmac->desc.callback)
-			sdmac->desc.callback(sdmac->desc.callback_param);
 	}
 }
 
@@ -669,6 +673,9 @@
 		int channel = fls(stat) - 1;
 		struct sdma_channel *sdmac = &sdma->channel[channel];
 
+		if (sdmac->flags & IMX_DMA_SG_LOOP)
+			sdma_update_channel_loop(sdmac);
+
 		tasklet_schedule(&sdmac->tasklet);
 
 		__clear_bit(channel, &stat);
@@ -1129,6 +1136,7 @@
 	sdmac->status = DMA_IN_PROGRESS;
 
 	sdmac->buf_tail = 0;
+	sdmac->period_len = period_len;
 
 	sdmac->flags |= IMX_DMA_SG_LOOP;
 	sdmac->direction = direction;
@@ -1225,9 +1233,15 @@
 				      struct dma_tx_state *txstate)
 {
 	struct sdma_channel *sdmac = to_sdma_chan(chan);
+	u32 residue;
+
+	if (sdmac->flags & IMX_DMA_SG_LOOP)
+		residue = (sdmac->num_bd - sdmac->buf_tail) * sdmac->period_len;
+	else
+		residue = sdmac->chn_count - sdmac->chn_real_count;
 
 	dma_set_tx_state(txstate, chan->completed_cookie, chan->cookie,
-			sdmac->chn_count - sdmac->chn_real_count);
+			 residue);
 
 	return sdmac->status;
 }
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 6c65639..d443441 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1464,12 +1464,13 @@
 #else
 static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv)
 {
-	int ret;
+	int ret = 0;
 
 	DRM_INFO("Replacing VGA console driver\n");
 
 	console_lock();
-	ret = do_take_over_console(&dummy_con, 0, MAX_NR_CONSOLES - 1, 1);
+	if (con_is_bound(&vga_con))
+		ret = do_take_over_console(&dummy_con, 0, MAX_NR_CONSOLES - 1, 1);
 	if (ret == 0) {
 		ret = do_unregister_con_driver(&vga_con);
 
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a47fbf6..374f964 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -656,6 +656,7 @@
 #define QUIRK_PIPEA_FORCE (1<<0)
 #define QUIRK_LVDS_SSC_DISABLE (1<<1)
 #define QUIRK_INVERT_BRIGHTNESS (1<<2)
+#define QUIRK_BACKLIGHT_PRESENT (1<<3)
 
 struct intel_fbdev;
 struct intel_fbc_work;
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index 62ef55b..7465ab0 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -74,6 +74,50 @@
 	if (base == 0)
 		return 0;
 
+	/* make sure we don't clobber the GTT if it's within stolen memory */
+	if (INTEL_INFO(dev)->gen <= 4 && !IS_G33(dev) && !IS_G4X(dev)) {
+		struct {
+			u32 start, end;
+		} stolen[2] = {
+			{ .start = base, .end = base + dev_priv->gtt.stolen_size, },
+			{ .start = base, .end = base + dev_priv->gtt.stolen_size, },
+		};
+		u64 gtt_start, gtt_end;
+
+		gtt_start = I915_READ(PGTBL_CTL);
+		if (IS_GEN4(dev))
+			gtt_start = (gtt_start & PGTBL_ADDRESS_LO_MASK) |
+				(gtt_start & PGTBL_ADDRESS_HI_MASK) << 28;
+		else
+			gtt_start &= PGTBL_ADDRESS_LO_MASK;
+		gtt_end = gtt_start + gtt_total_entries(dev_priv->gtt) * 4;
+
+		if (gtt_start >= stolen[0].start && gtt_start < stolen[0].end)
+			stolen[0].end = gtt_start;
+		if (gtt_end > stolen[1].start && gtt_end <= stolen[1].end)
+			stolen[1].start = gtt_end;
+
+		/* pick the larger of the two chunks */
+		if (stolen[0].end - stolen[0].start >
+		    stolen[1].end - stolen[1].start) {
+			base = stolen[0].start;
+			dev_priv->gtt.stolen_size = stolen[0].end - stolen[0].start;
+		} else {
+			base = stolen[1].start;
+			dev_priv->gtt.stolen_size = stolen[1].end - stolen[1].start;
+		}
+
+		if (stolen[0].start != stolen[1].start ||
+		    stolen[0].end != stolen[1].end) {
+			DRM_DEBUG_KMS("GTT within stolen memory at 0x%llx-0x%llx\n",
+				      (unsigned long long) gtt_start,
+				      (unsigned long long) gtt_end - 1);
+			DRM_DEBUG_KMS("Stolen memory adjusted to 0x%x-0x%x\n",
+				      base, base + (u32) dev_priv->gtt.stolen_size - 1);
+		}
+	}
+
+
 	/* Verify that nothing else uses this physical address. Stolen
 	 * memory should be reserved by the BIOS and hidden from the
 	 * kernel. So if the region is already marked as busy, something
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index e691b30..a5bab61b 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -942,6 +942,9 @@
 /*
  * Instruction and interrupt control regs
  */
+#define PGTBL_CTL	0x02020
+#define   PGTBL_ADDRESS_LO_MASK	0xfffff000 /* bits [31:12] */
+#define   PGTBL_ADDRESS_HI_MASK	0x000000f0 /* bits [35:32] (gen4) */
 #define PGTBL_ER	0x02024
 #define RENDER_RING_BASE	0x02000
 #define BSD_RING_BASE		0x04000
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 556c916..e27e780 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11591,6 +11591,14 @@
 	DRM_INFO("applying inverted panel brightness quirk\n");
 }
 
+/* Some VBT's incorrectly indicate no backlight is present */
+static void quirk_backlight_present(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	dev_priv->quirks |= QUIRK_BACKLIGHT_PRESENT;
+	DRM_INFO("applying backlight present quirk\n");
+}
+
 struct intel_quirk {
 	int device;
 	int subsystem_vendor;
@@ -11659,6 +11667,12 @@
 
 	/* Acer Aspire 5336 */
 	{ 0x2a42, 0x1025, 0x048a, quirk_invert_brightness },
+
+	/* Acer C720 and C720P Chromebooks (Celeron 2955U) have backlights */
+	{ 0x0a06, 0x1025, 0x0a11, quirk_backlight_present },
+
+	/* Toshiba CB35 Chromebook (Celeron 2955U) */
+	{ 0x0a06, 0x1179, 0x0a88, quirk_backlight_present },
 };
 
 static void intel_init_quirks(struct drm_device *dev)
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 52fda95..075170d 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -28,6 +28,8 @@
 #include <linux/i2c.h>
 #include <linux/slab.h>
 #include <linux/export.h>
+#include <linux/notifier.h>
+#include <linux/reboot.h>
 #include <drm/drmP.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_crtc_helper.h>
@@ -336,6 +338,37 @@
 		return VLV_PIPE_PP_STATUS(vlv_power_sequencer_pipe(intel_dp));
 }
 
+/* Reboot notifier handler to shutdown panel power to guarantee T12 timing
+   This function only applicable when panel PM state is not to be tracked */
+static int edp_notify_handler(struct notifier_block *this, unsigned long code,
+			      void *unused)
+{
+	struct intel_dp *intel_dp = container_of(this, typeof(* intel_dp),
+						 edp_notifier);
+	struct drm_device *dev = intel_dp_to_dev(intel_dp);
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	u32 pp_div;
+	u32 pp_ctrl_reg, pp_div_reg;
+	enum pipe pipe = vlv_power_sequencer_pipe(intel_dp);
+
+	if (!is_edp(intel_dp) || code != SYS_RESTART)
+		return 0;
+
+	if (IS_VALLEYVIEW(dev)) {
+		pp_ctrl_reg = VLV_PIPE_PP_CONTROL(pipe);
+		pp_div_reg  = VLV_PIPE_PP_DIVISOR(pipe);
+		pp_div = I915_READ(pp_div_reg);
+		pp_div &= PP_REFERENCE_DIVIDER_MASK;
+
+		/* 0x1F write to PP_DIV_REG sets max cycle delay */
+		I915_WRITE(pp_div_reg, pp_div | 0x1F);
+		I915_WRITE(pp_ctrl_reg, PANEL_UNLOCK_REGS | PANEL_POWER_OFF);
+		msleep(intel_dp->panel_power_cycle_delay);
+	}
+
+	return 0;
+}
+
 static bool edp_have_panel_power(struct intel_dp *intel_dp)
 {
 	struct drm_device *dev = intel_dp_to_dev(intel_dp);
@@ -3707,6 +3740,10 @@
 		drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
 		edp_panel_vdd_off_sync(intel_dp);
 		drm_modeset_unlock(&dev->mode_config.connection_mutex);
+		if (intel_dp->edp_notifier.notifier_call) {
+			unregister_reboot_notifier(&intel_dp->edp_notifier);
+			intel_dp->edp_notifier.notifier_call = NULL;
+		}
 	}
 	kfree(intel_dig_port);
 }
@@ -4184,6 +4221,11 @@
 	}
 	mutex_unlock(&dev->mode_config.mutex);
 
+	if (IS_VALLEYVIEW(dev)) {
+		intel_dp->edp_notifier.notifier_call = edp_notify_handler;
+		register_reboot_notifier(&intel_dp->edp_notifier);
+	}
+
 	intel_panel_init(&intel_connector->panel, fixed_mode, downclock_mode);
 	intel_panel_setup_backlight(connector);
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index eaa27ee..f67340e 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -538,6 +538,8 @@
 	unsigned long last_power_on;
 	unsigned long last_backlight_off;
 	bool psr_setup_done;
+	struct notifier_block edp_notifier;
+
 	bool use_tps3;
 	struct intel_connector *attached_connector;
 
diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index 02f99d7..3fd0829 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -117,17 +117,18 @@
 	/* bandgap reset is needed after everytime we do power gate */
 	band_gap_reset(dev_priv);
 
+	I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_ENTER);
+	usleep_range(2500, 3000);
+
 	val = I915_READ(MIPI_PORT_CTRL(pipe));
 	I915_WRITE(MIPI_PORT_CTRL(pipe), val | LP_OUTPUT_HOLD);
 	usleep_range(1000, 1500);
-	I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY | ULPS_STATE_EXIT);
-	usleep_range(2000, 2500);
+
+	I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_EXIT);
+	usleep_range(2500, 3000);
+
 	I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY);
-	usleep_range(2000, 2500);
-	I915_WRITE(MIPI_DEVICE_READY(pipe), 0x00);
-	usleep_range(2000, 2500);
-	I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY);
-	usleep_range(2000, 2500);
+	usleep_range(2500, 3000);
 }
 
 static void intel_dsi_enable(struct intel_encoder *encoder)
@@ -271,23 +272,23 @@
 
 	DRM_DEBUG_KMS("\n");
 
-	I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_ENTER);
+	I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY | ULPS_STATE_ENTER);
 	usleep_range(2000, 2500);
 
-	I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_EXIT);
+	I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY | ULPS_STATE_EXIT);
 	usleep_range(2000, 2500);
 
-	I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_ENTER);
+	I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY | ULPS_STATE_ENTER);
 	usleep_range(2000, 2500);
 
-	val = I915_READ(MIPI_PORT_CTRL(pipe));
-	I915_WRITE(MIPI_PORT_CTRL(pipe), val & ~LP_OUTPUT_HOLD);
-	usleep_range(1000, 1500);
-
 	if (wait_for(((I915_READ(MIPI_PORT_CTRL(pipe)) & AFE_LATCHOUT)
 					== 0x00000), 30))
 		DRM_ERROR("DSI LP not going Low\n");
 
+	val = I915_READ(MIPI_PORT_CTRL(pipe));
+	I915_WRITE(MIPI_PORT_CTRL(pipe), val & ~LP_OUTPUT_HOLD);
+	usleep_range(1000, 1500);
+
 	I915_WRITE(MIPI_DEVICE_READY(pipe), 0x00);
 	usleep_range(2000, 2500);
 
diff --git a/drivers/gpu/drm/i915/intel_dsi_cmd.c b/drivers/gpu/drm/i915/intel_dsi_cmd.c
index 3eeb21b..933c863 100644
--- a/drivers/gpu/drm/i915/intel_dsi_cmd.c
+++ b/drivers/gpu/drm/i915/intel_dsi_cmd.c
@@ -404,12 +404,6 @@
 	else
 		cmd |= DPI_LP_MODE;
 
-	/* DPI virtual channel?! */
-
-	mask = DPI_FIFO_EMPTY;
-	if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(pipe)) & mask) == mask, 50))
-		DRM_ERROR("Timeout waiting for DPI FIFO empty.\n");
-
 	/* clear bit */
 	I915_WRITE(MIPI_INTR_STAT(pipe), SPL_PKT_SENT_INTERRUPT);
 
diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c
index 2e2c71f..4f6b539 100644
--- a/drivers/gpu/drm/i915/intel_opregion.c
+++ b/drivers/gpu/drm/i915/intel_opregion.c
@@ -403,6 +403,15 @@
 
 	DRM_DEBUG_DRIVER("bclp = 0x%08x\n", bclp);
 
+	/*
+	 * If the acpi_video interface is not supposed to be used, don't
+	 * bother processing backlight level change requests from firmware.
+	 */
+	if (!acpi_video_verify_backlight_support()) {
+		DRM_DEBUG_KMS("opregion backlight request ignored\n");
+		return 0;
+	}
+
 	if (!(bclp & ASLE_BCLP_VALID))
 		return ASLC_BACKLIGHT_FAILED;
 
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index 38a9857..628cd89 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -1118,8 +1118,12 @@
 	int ret;
 
 	if (!dev_priv->vbt.backlight.present) {
-		DRM_DEBUG_KMS("native backlight control not available per VBT\n");
-		return 0;
+		if (dev_priv->quirks & QUIRK_BACKLIGHT_PRESENT) {
+			DRM_DEBUG_KMS("no backlight present per VBT, but present per quirk\n");
+		} else {
+			DRM_DEBUG_KMS("no backlight present per VBT\n");
+			return 0;
+		}
 	}
 
 	/* set level and max in panel struct */
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
index 26e962b..2283c44 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
@@ -1516,11 +1516,11 @@
 		}
 
 		switch ((ctrl & 0x000f0000) >> 16) {
-		case 6: datarate = pclk * 30 / 8; break;
-		case 5: datarate = pclk * 24 / 8; break;
+		case 6: datarate = pclk * 30; break;
+		case 5: datarate = pclk * 24; break;
 		case 2:
 		default:
-			datarate = pclk * 18 / 8;
+			datarate = pclk * 18;
 			break;
 		}
 
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c b/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c
index 48aa38a..fa30d81 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c
@@ -1159,11 +1159,11 @@
 	if (outp->info.type == DCB_OUTPUT_DP) {
 		u32 sync = nv_rd32(priv, 0x660404 + (head * 0x300));
 		switch ((sync & 0x000003c0) >> 6) {
-		case 6: pclk = pclk * 30 / 8; break;
-		case 5: pclk = pclk * 24 / 8; break;
+		case 6: pclk = pclk * 30; break;
+		case 5: pclk = pclk * 24; break;
 		case 2:
 		default:
-			pclk = pclk * 18 / 8;
+			pclk = pclk * 18;
 			break;
 		}
 
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/outpdp.c b/drivers/gpu/drm/nouveau/core/engine/disp/outpdp.c
index 52c299c..eb2d778 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/outpdp.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/outpdp.c
@@ -34,7 +34,7 @@
 	struct nvkm_output_dp *outp = (void *)base;
 	bool retrain = true;
 	u8 link[2], stat[3];
-	u32 rate;
+	u32 linkrate;
 	int ret, i;
 
 	/* check that the link is trained at a high enough rate */
@@ -44,8 +44,10 @@
 		goto done;
 	}
 
-	rate = link[0] * 27000 * (link[1] & DPCD_LC01_LANE_COUNT_SET);
-	if (rate < ((datarate / 8) * 10)) {
+	linkrate = link[0] * 27000 * (link[1] & DPCD_LC01_LANE_COUNT_SET);
+	linkrate = (linkrate * 8) / 10; /* 8B/10B coding overhead */
+	datarate = (datarate + 9) / 10; /* -> decakilobits */
+	if (linkrate < datarate) {
 		DBG("link not trained at sufficient rate\n");
 		goto done;
 	}
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c
index e183277..7a1ebdf 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c
@@ -87,6 +87,7 @@
 			struct nvkm_output_dp *outpdp = (void *)outp;
 			switch (data) {
 			case NV94_DISP_SOR_DP_PWR_STATE_OFF:
+				nouveau_event_put(outpdp->irq);
 				((struct nvkm_output_dp_impl *)nv_oclass(outp))
 					->lnk_pwr(outpdp, 0);
 				atomic_set(&outpdp->lt.done, 0);
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/ramfuc.h b/drivers/gpu/drm/nouveau/core/subdev/fb/ramfuc.h
index 0f57fcf..2af9cfd 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/ramfuc.h
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/ramfuc.h
@@ -26,7 +26,7 @@
 	};
 }
 
-static inline struct ramfuc_reg
+static noinline struct ramfuc_reg
 ramfuc_reg(u32 addr)
 {
 	return ramfuc_reg2(addr, addr);
@@ -107,7 +107,7 @@
 
 #define ram_init(s,p)       ramfuc_init(&(s)->base, (p))
 #define ram_exec(s,e)       ramfuc_exec(&(s)->base, (e))
-#define ram_have(s,r)       ((s)->r_##r.addr != 0x000000)
+#define ram_have(s,r)       ((s)->r_##r.addr[0] != 0x000000)
 #define ram_rd32(s,r)       ramfuc_rd32(&(s)->base, &(s)->r_##r)
 #define ram_wr32(s,r,d)     ramfuc_wr32(&(s)->base, &(s)->r_##r, (d))
 #define ram_nuke(s,r)       ramfuc_nuke(&(s)->base, &(s)->r_##r)
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c
index 1ad3ea5..c5b46e3 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c
@@ -200,6 +200,7 @@
 	/* (re)program mempll, if required */
 	if (ram->mode == 2) {
 		ram_mask(fuc, 0x1373f4, 0x00010000, 0x00000000);
+		ram_mask(fuc, 0x132000, 0x80000000, 0x80000000);
 		ram_mask(fuc, 0x132000, 0x00000001, 0x00000000);
 		ram_mask(fuc, 0x132004, 0x103fffff, mcoef);
 		ram_mask(fuc, 0x132000, 0x00000001, 0x00000001);
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index ddd8375..5425ffe 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -652,12 +652,12 @@
 	ret = nouveau_do_resume(drm_dev);
 	if (ret)
 		return ret;
-	if (drm_dev->mode_config.num_crtc)
-		nouveau_fbcon_set_suspend(drm_dev, 0);
 
-	nouveau_fbcon_zfill_all(drm_dev);
-	if (drm_dev->mode_config.num_crtc)
+	if (drm_dev->mode_config.num_crtc) {
 		nouveau_display_resume(drm_dev);
+		nouveau_fbcon_set_suspend(drm_dev, 0);
+	}
+
 	return 0;
 }
 
@@ -683,11 +683,12 @@
 	ret = nouveau_do_resume(drm_dev);
 	if (ret)
 		return ret;
-	if (drm_dev->mode_config.num_crtc)
-		nouveau_fbcon_set_suspend(drm_dev, 0);
-	nouveau_fbcon_zfill_all(drm_dev);
-	if (drm_dev->mode_config.num_crtc)
+
+	if (drm_dev->mode_config.num_crtc) {
 		nouveau_display_resume(drm_dev);
+		nouveau_fbcon_set_suspend(drm_dev, 0);
+	}
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
index 64a42cf..191665e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
@@ -531,17 +531,10 @@
 		if (state == 1)
 			nouveau_fbcon_save_disable_accel(dev);
 		fb_set_suspend(drm->fbcon->helper.fbdev, state);
-		if (state == 0)
+		if (state == 0) {
 			nouveau_fbcon_restore_accel(dev);
+			nouveau_fbcon_zfill(dev, drm->fbcon);
+		}
 		console_unlock();
 	}
 }
-
-void
-nouveau_fbcon_zfill_all(struct drm_device *dev)
-{
-	struct nouveau_drm *drm = nouveau_drm(dev);
-	if (drm->fbcon) {
-		nouveau_fbcon_zfill(dev, drm->fbcon);
-	}
-}
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.h b/drivers/gpu/drm/nouveau/nouveau_fbcon.h
index fdfc0c9..fcff797 100644
--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.h
+++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.h
@@ -61,7 +61,6 @@
 int nouveau_fbcon_init(struct drm_device *dev);
 void nouveau_fbcon_fini(struct drm_device *dev);
 void nouveau_fbcon_set_suspend(struct drm_device *dev, int state);
-void nouveau_fbcon_zfill_all(struct drm_device *dev);
 void nouveau_fbcon_save_disable_accel(struct drm_device *dev);
 void nouveau_fbcon_restore_accel(struct drm_device *dev);
 
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index afdf607..4c534b7 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -1741,7 +1741,8 @@
 		}
 	}
 
-	mthd  = (ffs(nv_encoder->dcb->sorconf.link) - 1) << 2;
+	mthd  = (ffs(nv_encoder->dcb->heads) - 1) << 3;
+	mthd |= (ffs(nv_encoder->dcb->sorconf.link) - 1) << 2;
 	mthd |= nv_encoder->or;
 
 	if (nv_encoder->dcb->type == DCB_OUTPUT_DP) {
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 35f4182..b1e11f8 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -127,7 +127,7 @@
 	/* flags not zero */
 	if (args.v1.ucReplyStatus == 2) {
 		DRM_DEBUG_KMS("dp_aux_ch flags not zero\n");
-		r = -EBUSY;
+		r = -EIO;
 		goto done;
 	}
 
diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c
index 10dae41..584090a 100644
--- a/drivers/gpu/drm/radeon/ci_dpm.c
+++ b/drivers/gpu/drm/radeon/ci_dpm.c
@@ -1179,7 +1179,7 @@
 	tmp &= ~GLOBAL_PWRMGT_EN;
 	WREG32_SMC(GENERAL_PWRMGT, tmp);
 
-	tmp = RREG32(SCLK_PWRMGT_CNTL);
+	tmp = RREG32_SMC(SCLK_PWRMGT_CNTL);
 	tmp &= ~DYNAMIC_PM_EN;
 	WREG32_SMC(SCLK_PWRMGT_CNTL, tmp);
 
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index dcd4518..0b24711 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -7676,14 +7676,16 @@
 			addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR);
 			status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS);
 			mc_client = RREG32(VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT);
+			/* reset addr and status */
+			WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1);
+			if (addr == 0x0 && status == 0x0)
+				break;
 			dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data);
 			dev_err(rdev->dev, "  VM_CONTEXT1_PROTECTION_FAULT_ADDR   0x%08X\n",
 				addr);
 			dev_err(rdev->dev, "  VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n",
 				status);
 			cik_vm_decode_fault(rdev, status, addr, mc_client);
-			/* reset addr and status */
-			WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1);
 			break;
 		case 167: /* VCE */
 			DRM_DEBUG("IH: VCE int: 0x%08x\n", src_data);
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index e2f6052..f7ece0f 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -189,7 +189,7 @@
 	0x8c1c, 0xffffffff, 0x00001010,
 	0x28350, 0xffffffff, 0x00000000,
 	0xa008, 0xffffffff, 0x00010000,
-	0x5cc, 0xffffffff, 0x00000001,
+	0x5c4, 0xffffffff, 0x00000001,
 	0x9508, 0xffffffff, 0x00000002,
 	0x913c, 0x0000000f, 0x0000000a
 };
@@ -476,7 +476,7 @@
 	0x8c1c, 0xffffffff, 0x00001010,
 	0x28350, 0xffffffff, 0x00000000,
 	0xa008, 0xffffffff, 0x00010000,
-	0x5cc, 0xffffffff, 0x00000001,
+	0x5c4, 0xffffffff, 0x00000001,
 	0x9508, 0xffffffff, 0x00000002
 };
 
@@ -635,7 +635,7 @@
 static const u32 supersumo_golden_registers[] =
 {
 	0x5eb4, 0xffffffff, 0x00000002,
-	0x5cc, 0xffffffff, 0x00000001,
+	0x5c4, 0xffffffff, 0x00000001,
 	0x7030, 0xffffffff, 0x00000011,
 	0x7c30, 0xffffffff, 0x00000011,
 	0x6104, 0x01000300, 0x00000000,
@@ -719,7 +719,7 @@
 static const u32 wrestler_golden_registers[] =
 {
 	0x5eb4, 0xffffffff, 0x00000002,
-	0x5cc, 0xffffffff, 0x00000001,
+	0x5c4, 0xffffffff, 0x00000001,
 	0x7030, 0xffffffff, 0x00000011,
 	0x7c30, 0xffffffff, 0x00000011,
 	0x6104, 0x01000300, 0x00000000,
@@ -5066,14 +5066,16 @@
 		case 147:
 			addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR);
 			status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS);
+			/* reset addr and status */
+			WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1);
+			if (addr == 0x0 && status == 0x0)
+				break;
 			dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data);
 			dev_err(rdev->dev, "  VM_CONTEXT1_PROTECTION_FAULT_ADDR   0x%08X\n",
 				addr);
 			dev_err(rdev->dev, "  VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n",
 				status);
 			cayman_vm_decode_fault(rdev, status, addr);
-			/* reset addr and status */
-			WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1);
 			break;
 		case 176: /* CP_INT in ring buffer */
 		case 177: /* CP_INT in IB1 */
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c
index da041a43..3c76e1d 100644
--- a/drivers/gpu/drm/radeon/rv770_dpm.c
+++ b/drivers/gpu/drm/radeon/rv770_dpm.c
@@ -2329,12 +2329,6 @@
 	pi->mclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss,
 						       ASIC_INTERNAL_MEMORY_SS, 0);
 
-	/* disable ss, causes hangs on some cayman boards */
-	if (rdev->family == CHIP_CAYMAN) {
-		pi->sclk_ss = false;
-		pi->mclk_ss = false;
-	}
-
 	if (pi->sclk_ss || pi->mclk_ss)
 		pi->dynamic_ss = true;
 	else
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 730cee2..eba0225 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -6376,14 +6376,16 @@
 		case 147:
 			addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR);
 			status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS);
+			/* reset addr and status */
+			WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1);
+			if (addr == 0x0 && status == 0x0)
+				break;
 			dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data);
 			dev_err(rdev->dev, "  VM_CONTEXT1_PROTECTION_FAULT_ADDR   0x%08X\n",
 				addr);
 			dev_err(rdev->dev, "  VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n",
 				status);
 			si_vm_decode_fault(rdev, status, addr);
-			/* reset addr and status */
-			WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1);
 			break;
 		case 176: /* RINGID0 CP_INT */
 			radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX);
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 800c8b6..5e79c6a 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -810,7 +810,7 @@
 
 config HID_SENSOR_HUB
 	tristate "HID Sensors framework support"
-	depends on HID
+	depends on HID && HAS_IOMEM
 	select MFD_CORE
 	default n
 	---help---
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 6d00bb9..48b66bb 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -323,6 +323,7 @@
 
 #define USB_VENDOR_ID_ETURBOTOUCH	0x22b9
 #define USB_DEVICE_ID_ETURBOTOUCH	0x0006
+#define USB_DEVICE_ID_ETURBOTOUCH_2968	0x2968
 
 #define USB_VENDOR_ID_EZKEY		0x0518
 #define USB_DEVICE_ID_BTC_8193		0x0002
@@ -715,6 +716,8 @@
 
 #define USB_VENDOR_ID_PENMOUNT		0x14e1
 #define USB_DEVICE_ID_PENMOUNT_PCI	0x3500
+#define USB_DEVICE_ID_PENMOUNT_1610	0x1610
+#define USB_DEVICE_ID_PENMOUNT_1640	0x1640
 
 #define USB_VENDOR_ID_PETALYNX		0x18b1
 #define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE	0x0037
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 2451c7e..578bbe6 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -428,6 +428,7 @@
 	return 0;
 }
 
+#ifdef CONFIG_PM
 static int rmi_post_reset(struct hid_device *hdev)
 {
 	return rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS);
@@ -437,6 +438,7 @@
 {
 	return rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS);
 }
+#endif /* CONFIG_PM */
 
 #define RMI4_MAX_PAGE 0xff
 #define RMI4_PAGE_SIZE 0x0100
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index a8d5c8f..e244e44 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -159,17 +159,18 @@
 {
 	struct hid_sensor_hub_callbacks_list *callback;
 	struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev);
+	unsigned long flags;
 
-	spin_lock(&pdata->dyn_callback_lock);
+	spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
 	list_for_each_entry(callback, &pdata->dyn_callback_list, list)
 		if (callback->usage_id == usage_id &&
 						callback->hsdev == hsdev) {
-			spin_unlock(&pdata->dyn_callback_lock);
+			spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
 			return -EINVAL;
 		}
 	callback = kzalloc(sizeof(*callback), GFP_ATOMIC);
 	if (!callback) {
-		spin_unlock(&pdata->dyn_callback_lock);
+		spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
 		return -ENOMEM;
 	}
 	callback->hsdev = hsdev;
@@ -177,7 +178,7 @@
 	callback->usage_id = usage_id;
 	callback->priv = NULL;
 	list_add_tail(&callback->list, &pdata->dyn_callback_list);
-	spin_unlock(&pdata->dyn_callback_lock);
+	spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
 
 	return 0;
 }
@@ -188,8 +189,9 @@
 {
 	struct hid_sensor_hub_callbacks_list *callback;
 	struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev);
+	unsigned long flags;
 
-	spin_lock(&pdata->dyn_callback_lock);
+	spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
 	list_for_each_entry(callback, &pdata->dyn_callback_list, list)
 		if (callback->usage_id == usage_id &&
 						callback->hsdev == hsdev) {
@@ -197,7 +199,7 @@
 			kfree(callback);
 			break;
 		}
-	spin_unlock(&pdata->dyn_callback_lock);
+	spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
 
 	return 0;
 }
@@ -378,15 +380,16 @@
 {
 	struct sensor_hub_data *pdata = hid_get_drvdata(hdev);
 	struct hid_sensor_hub_callbacks_list *callback;
+	unsigned long flags;
 
 	hid_dbg(hdev, " sensor_hub_suspend\n");
-	spin_lock(&pdata->dyn_callback_lock);
+	spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
 	list_for_each_entry(callback, &pdata->dyn_callback_list, list) {
 		if (callback->usage_callback->suspend)
 			callback->usage_callback->suspend(
 					callback->hsdev, callback->priv);
 	}
-	spin_unlock(&pdata->dyn_callback_lock);
+	spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
 
 	return 0;
 }
@@ -395,15 +398,16 @@
 {
 	struct sensor_hub_data *pdata = hid_get_drvdata(hdev);
 	struct hid_sensor_hub_callbacks_list *callback;
+	unsigned long flags;
 
 	hid_dbg(hdev, " sensor_hub_resume\n");
-	spin_lock(&pdata->dyn_callback_lock);
+	spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
 	list_for_each_entry(callback, &pdata->dyn_callback_list, list) {
 		if (callback->usage_callback->resume)
 			callback->usage_callback->resume(
 					callback->hsdev, callback->priv);
 	}
-	spin_unlock(&pdata->dyn_callback_lock);
+	spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
 
 	return 0;
 }
@@ -632,6 +636,7 @@
 			if (name == NULL) {
 				hid_err(hdev, "Failed MFD device name\n");
 					ret = -ENOMEM;
+					kfree(hsdev);
 					goto err_no_mem;
 			}
 			sd->hid_sensor_hub_client_devs[
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index 59badc1..31e6727 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -49,6 +49,7 @@
 
 	{ USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II, HID_QUIRK_MULTI_INPUT },
 	{ USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH, HID_QUIRK_MULTI_INPUT },
+	{ USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH_2968, HID_QUIRK_MULTI_INPUT },
 	{ USB_VENDOR_ID_GREENASIA, USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD, HID_QUIRK_MULTI_INPUT },
 	{ USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
 	{ USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT },
@@ -76,6 +77,8 @@
 	{ USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GX680R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS },
 	{ USB_VENDOR_ID_NEXIO, USB_DEVICE_ID_NEXIO_MULTITOUCH_PTI0750, HID_QUIRK_NO_INIT_REPORTS },
 	{ USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS },
+	{ USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_1610, HID_QUIRK_NOGET },
+	{ USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_1640, HID_QUIRK_NOGET },
 	{ USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS },
 	{ USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS },
 	{ USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2, HID_QUIRK_NO_INIT_REPORTS },
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index e84f452..ae22e3c 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -339,9 +339,13 @@
 		 */
 
 		do {
-			hv_begin_read(&channel->inbound);
+			if (read_state)
+				hv_begin_read(&channel->inbound);
 			channel->onchannel_callback(arg);
-			bytes_to_read = hv_end_read(&channel->inbound);
+			if (read_state)
+				bytes_to_read = hv_end_read(&channel->inbound);
+			else
+				bytes_to_read = 0;
 		} while (read_state && (bytes_to_read != 0));
 	} else {
 		pr_err("no channel callback for relid - %u\n", relid);
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index ea85253..521c146 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -127,6 +127,17 @@
 	kvp_respond_to_host(NULL, HV_E_FAIL);
 }
 
+static void poll_channel(struct vmbus_channel *channel)
+{
+	if (channel->target_cpu != smp_processor_id())
+		smp_call_function_single(channel->target_cpu,
+					 hv_kvp_onchannelcallback,
+					 channel, true);
+	else
+		hv_kvp_onchannelcallback(channel);
+}
+
+
 static int kvp_handle_handshake(struct hv_kvp_msg *msg)
 {
 	int ret = 1;
@@ -155,7 +166,7 @@
 		kvp_register(dm_reg_value);
 		kvp_transaction.active = false;
 		if (kvp_transaction.kvp_context)
-			hv_kvp_onchannelcallback(kvp_transaction.kvp_context);
+			poll_channel(kvp_transaction.kvp_context);
 	}
 	return ret;
 }
@@ -568,7 +579,7 @@
 
 	vmbus_sendpacket(channel, recv_buffer, buf_len, req_id,
 				VM_PKT_DATA_INBAND, 0);
-
+	poll_channel(channel);
 }
 
 /*
@@ -603,7 +614,7 @@
 		return;
 	}
 
-	vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 2, &recvlen,
+	vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 4, &recvlen,
 			 &requestid);
 
 	if (recvlen > 0) {
diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c
index dd76180..3b9c9ef 100644
--- a/drivers/hv/hv_util.c
+++ b/drivers/hv/hv_util.c
@@ -319,7 +319,7 @@
 		(struct hv_util_service *)dev_id->driver_data;
 	int ret;
 
-	srv->recv_buffer = kmalloc(PAGE_SIZE * 2, GFP_KERNEL);
+	srv->recv_buffer = kmalloc(PAGE_SIZE * 4, GFP_KERNEL);
 	if (!srv->recv_buffer)
 		return -ENOMEM;
 	if (srv->util_init) {
diff --git a/drivers/hwmon/adc128d818.c b/drivers/hwmon/adc128d818.c
index 5ffd81f..0625e50 100644
--- a/drivers/hwmon/adc128d818.c
+++ b/drivers/hwmon/adc128d818.c
@@ -239,50 +239,50 @@
 	return sprintf(buf, "%u\n", !!(alarms & mask));
 }
 
-static SENSOR_DEVICE_ATTR_2(in0_input, S_IWUSR | S_IRUGO,
-			    adc128_show_in, adc128_set_in, 0, 0);
+static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO,
+			    adc128_show_in, NULL, 0, 0);
 static SENSOR_DEVICE_ATTR_2(in0_min, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 0, 1);
 static SENSOR_DEVICE_ATTR_2(in0_max, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 0, 2);
 
-static SENSOR_DEVICE_ATTR_2(in1_input, S_IWUSR | S_IRUGO,
-			    adc128_show_in, adc128_set_in, 1, 0);
+static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO,
+			    adc128_show_in, NULL, 1, 0);
 static SENSOR_DEVICE_ATTR_2(in1_min, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 1, 1);
 static SENSOR_DEVICE_ATTR_2(in1_max, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 1, 2);
 
-static SENSOR_DEVICE_ATTR_2(in2_input, S_IWUSR | S_IRUGO,
-			    adc128_show_in, adc128_set_in, 2, 0);
+static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO,
+			    adc128_show_in, NULL, 2, 0);
 static SENSOR_DEVICE_ATTR_2(in2_min, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 2, 1);
 static SENSOR_DEVICE_ATTR_2(in2_max, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 2, 2);
 
-static SENSOR_DEVICE_ATTR_2(in3_input, S_IWUSR | S_IRUGO,
-			    adc128_show_in, adc128_set_in, 3, 0);
+static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO,
+			    adc128_show_in, NULL, 3, 0);
 static SENSOR_DEVICE_ATTR_2(in3_min, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 3, 1);
 static SENSOR_DEVICE_ATTR_2(in3_max, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 3, 2);
 
-static SENSOR_DEVICE_ATTR_2(in4_input, S_IWUSR | S_IRUGO,
-			    adc128_show_in, adc128_set_in, 4, 0);
+static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO,
+			    adc128_show_in, NULL, 4, 0);
 static SENSOR_DEVICE_ATTR_2(in4_min, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 4, 1);
 static SENSOR_DEVICE_ATTR_2(in4_max, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 4, 2);
 
-static SENSOR_DEVICE_ATTR_2(in5_input, S_IWUSR | S_IRUGO,
-			    adc128_show_in, adc128_set_in, 5, 0);
+static SENSOR_DEVICE_ATTR_2(in5_input, S_IRUGO,
+			    adc128_show_in, NULL, 5, 0);
 static SENSOR_DEVICE_ATTR_2(in5_min, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 5, 1);
 static SENSOR_DEVICE_ATTR_2(in5_max, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 5, 2);
 
-static SENSOR_DEVICE_ATTR_2(in6_input, S_IWUSR | S_IRUGO,
-			    adc128_show_in, adc128_set_in, 6, 0);
+static SENSOR_DEVICE_ATTR_2(in6_input, S_IRUGO,
+			    adc128_show_in, NULL, 6, 0);
 static SENSOR_DEVICE_ATTR_2(in6_min, S_IWUSR | S_IRUGO,
 			    adc128_show_in, adc128_set_in, 6, 1);
 static SENSOR_DEVICE_ATTR_2(in6_max, S_IWUSR | S_IRUGO,
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index 3eb4281..d74241b 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -185,7 +185,7 @@
 	struct adm1021_data *data = dev_get_drvdata(dev);
 	struct i2c_client *client = data->client;
 	long temp;
-	int err;
+	int reg_val, err;
 
 	err = kstrtol(buf, 10, &temp);
 	if (err)
@@ -193,10 +193,11 @@
 	temp /= 1000;
 
 	mutex_lock(&data->update_lock);
-	data->temp_max[index] = clamp_val(temp, -128, 127);
+	reg_val = clamp_val(temp, -128, 127);
+	data->temp_max[index] = reg_val * 1000;
 	if (!read_only)
 		i2c_smbus_write_byte_data(client, ADM1021_REG_TOS_W(index),
-					  data->temp_max[index]);
+					  reg_val);
 	mutex_unlock(&data->update_lock);
 
 	return count;
@@ -210,7 +211,7 @@
 	struct adm1021_data *data = dev_get_drvdata(dev);
 	struct i2c_client *client = data->client;
 	long temp;
-	int err;
+	int reg_val, err;
 
 	err = kstrtol(buf, 10, &temp);
 	if (err)
@@ -218,10 +219,11 @@
 	temp /= 1000;
 
 	mutex_lock(&data->update_lock);
-	data->temp_min[index] = clamp_val(temp, -128, 127);
+	reg_val = clamp_val(temp, -128, 127);
+	data->temp_min[index] = reg_val * 1000;
 	if (!read_only)
 		i2c_smbus_write_byte_data(client, ADM1021_REG_THYST_W(index),
-					  data->temp_min[index]);
+					  reg_val);
 	mutex_unlock(&data->update_lock);
 
 	return count;
diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c
index 78339e8..2804571 100644
--- a/drivers/hwmon/adm1029.c
+++ b/drivers/hwmon/adm1029.c
@@ -232,6 +232,9 @@
 	/* Update the value */
 	reg = (reg & 0x3F) | (val << 6);
 
+	/* Update the cache */
+	data->fan_div[attr->index] = reg;
+
 	/* Write value */
 	i2c_smbus_write_byte_data(client,
 				  ADM1029_REG_FAN_DIV[attr->index], reg);
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c
index a8a540c..51c1a5a 100644
--- a/drivers/hwmon/adm1031.c
+++ b/drivers/hwmon/adm1031.c
@@ -365,6 +365,7 @@
 	if (ret)
 		return ret;
 
+	val = clamp_val(val, 0, 127000);
 	mutex_lock(&data->update_lock);
 	data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]);
 	adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr),
@@ -394,6 +395,7 @@
 	if (ret)
 		return ret;
 
+	val = clamp_val(val, 0, 127000);
 	mutex_lock(&data->update_lock);
 	data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr],
 						  data->pwm[nr]);
@@ -696,7 +698,7 @@
 	if (ret)
 		return ret;
 
-	val = clamp_val(val, -55000, nr == 0 ? 127750 : 127875);
+	val = clamp_val(val, -55000, 127000);
 	mutex_lock(&data->update_lock);
 	data->temp_min[nr] = TEMP_TO_REG(val);
 	adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr),
@@ -717,7 +719,7 @@
 	if (ret)
 		return ret;
 
-	val = clamp_val(val, -55000, nr == 0 ? 127750 : 127875);
+	val = clamp_val(val, -55000, 127000);
 	mutex_lock(&data->update_lock);
 	data->temp_max[nr] = TEMP_TO_REG(val);
 	adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr),
@@ -738,7 +740,7 @@
 	if (ret)
 		return ret;
 
-	val = clamp_val(val, -55000, nr == 0 ? 127750 : 127875);
+	val = clamp_val(val, -55000, 127000);
 	mutex_lock(&data->update_lock);
 	data->temp_crit[nr] = TEMP_TO_REG(val);
 	adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr),
diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c
index eea8172..9f2be3d 100644
--- a/drivers/hwmon/amc6821.c
+++ b/drivers/hwmon/amc6821.c
@@ -704,7 +704,7 @@
 	get_temp_alarm, NULL, IDX_TEMP1_MAX);
 static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO,
 	get_temp_alarm, NULL, IDX_TEMP1_CRIT);
-static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO | S_IWUSR,
+static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO,
 	get_temp, NULL, IDX_TEMP2_INPUT);
 static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR, get_temp,
 	set_temp, IDX_TEMP2_MIN);
diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
index fd892dd..78002de 100644
--- a/drivers/hwmon/emc2103.c
+++ b/drivers/hwmon/emc2103.c
@@ -250,9 +250,7 @@
 	if (result < 0)
 		return result;
 
-	val = DIV_ROUND_CLOSEST(val, 1000);
-	if ((val < -63) || (val > 127))
-		return -EINVAL;
+	val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -63, 127);
 
 	mutex_lock(&data->update_lock);
 	data->temp_min[nr] = val;
@@ -274,9 +272,7 @@
 	if (result < 0)
 		return result;
 
-	val = DIV_ROUND_CLOSEST(val, 1000);
-	if ((val < -63) || (val > 127))
-		return -EINVAL;
+	val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -63, 127);
 
 	mutex_lock(&data->update_lock);
 	data->temp_max[nr] = val;
@@ -390,15 +386,14 @@
 {
 	struct emc2103_data *data = emc2103_update_device(dev);
 	struct i2c_client *client = to_i2c_client(dev);
-	long rpm_target;
+	unsigned long rpm_target;
 
-	int result = kstrtol(buf, 10, &rpm_target);
+	int result = kstrtoul(buf, 10, &rpm_target);
 	if (result < 0)
 		return result;
 
 	/* Datasheet states 16384 as maximum RPM target (table 3.2) */
-	if ((rpm_target < 0) || (rpm_target > 16384))
-		return -EINVAL;
+	rpm_target = clamp_val(rpm_target, 0, 16384);
 
 	mutex_lock(&data->update_lock);
 
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
index bdfbe91..ae66f42 100644
--- a/drivers/hwmon/ntc_thermistor.c
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -512,7 +512,7 @@
 	}
 
 	dev_info(&pdev->dev, "Thermistor type: %s successfully probed.\n",
-								pdev->name);
+								pdev_id->name);
 
 	return 0;
 err_after_sysfs:
diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c
index 09de4fd..4d75d47 100644
--- a/drivers/i2c/busses/i2c-sun6i-p2wi.c
+++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c
@@ -22,7 +22,6 @@
  *
  */
 #include <linux/clk.h>
-#include <linux/module.h>
 #include <linux/i2c.h>
 #include <linux/io.h>
 #include <linux/interrupt.h>
diff --git a/drivers/i2c/muxes/Kconfig b/drivers/i2c/muxes/Kconfig
index f7f9865..f6d313e 100644
--- a/drivers/i2c/muxes/Kconfig
+++ b/drivers/i2c/muxes/Kconfig
@@ -40,6 +40,7 @@
 
 config I2C_MUX_PCA954x
 	tristate "Philips PCA954x I2C Mux/switches"
+	depends on GPIOLIB
 	help
 	  If you say yes here you get support for the Philips PCA954x
 	  I2C mux/switch devices.
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 69abf91..54e464e 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -110,7 +110,6 @@
 	struct accel_3d_state *accel_state = iio_priv(indio_dev);
 	int report_id = -1;
 	u32 address;
-	int ret;
 	int ret_type;
 	s32 poll_value;
 
@@ -151,14 +150,12 @@
 		ret_type = IIO_VAL_INT;
 		break;
 	case IIO_CHAN_INFO_SAMP_FREQ:
-		ret = hid_sensor_read_samp_freq_value(
+		ret_type = hid_sensor_read_samp_freq_value(
 			&accel_state->common_attributes, val, val2);
-		ret_type = IIO_VAL_INT_PLUS_MICRO;
 		break;
 	case IIO_CHAN_INFO_HYSTERESIS:
-		ret = hid_sensor_read_raw_hyst_value(
+		ret_type = hid_sensor_read_raw_hyst_value(
 			&accel_state->common_attributes, val, val2);
-		ret_type = IIO_VAL_INT_PLUS_MICRO;
 		break;
 	default:
 		ret_type = -EINVAL;
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index a4db302..d5dc4c6 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -374,7 +374,7 @@
 			return -EAGAIN;
 		}
 	}
-	map_val = chan->channel + TOTAL_CHANNELS;
+	map_val = adc_dev->channel_step[chan->scan_index];
 
 	/*
 	 * We check the complete FIFO. We programmed just one entry but in case
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index 40f4e49..fa034a3 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -110,7 +110,6 @@
 	struct gyro_3d_state *gyro_state = iio_priv(indio_dev);
 	int report_id = -1;
 	u32 address;
-	int ret;
 	int ret_type;
 	s32 poll_value;
 
@@ -151,14 +150,12 @@
 		ret_type = IIO_VAL_INT;
 		break;
 	case IIO_CHAN_INFO_SAMP_FREQ:
-		ret = hid_sensor_read_samp_freq_value(
+		ret_type = hid_sensor_read_samp_freq_value(
 			&gyro_state->common_attributes, val, val2);
-			ret_type = IIO_VAL_INT_PLUS_MICRO;
 		break;
 	case IIO_CHAN_INFO_HYSTERESIS:
-		ret = hid_sensor_read_raw_hyst_value(
+		ret_type = hid_sensor_read_raw_hyst_value(
 			&gyro_state->common_attributes, val, val2);
-		ret_type = IIO_VAL_INT_PLUS_MICRO;
 		break;
 	default:
 		ret_type = -EINVAL;
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index f34c943..96e71e1 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -79,7 +79,6 @@
 	struct als_state *als_state = iio_priv(indio_dev);
 	int report_id = -1;
 	u32 address;
-	int ret;
 	int ret_type;
 	s32 poll_value;
 
@@ -129,14 +128,12 @@
 		ret_type = IIO_VAL_INT;
 		break;
 	case IIO_CHAN_INFO_SAMP_FREQ:
-		ret = hid_sensor_read_samp_freq_value(
+		ret_type = hid_sensor_read_samp_freq_value(
 				&als_state->common_attributes, val, val2);
-		ret_type = IIO_VAL_INT_PLUS_MICRO;
 		break;
 	case IIO_CHAN_INFO_HYSTERESIS:
-		ret = hid_sensor_read_raw_hyst_value(
+		ret_type = hid_sensor_read_raw_hyst_value(
 				&als_state->common_attributes, val, val2);
-		ret_type = IIO_VAL_INT_PLUS_MICRO;
 		break;
 	default:
 		ret_type = -EINVAL;
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index d203ef4..412bae8 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -74,7 +74,6 @@
 	struct prox_state *prox_state = iio_priv(indio_dev);
 	int report_id = -1;
 	u32 address;
-	int ret;
 	int ret_type;
 	s32 poll_value;
 
@@ -125,14 +124,12 @@
 		ret_type = IIO_VAL_INT;
 		break;
 	case IIO_CHAN_INFO_SAMP_FREQ:
-		ret = hid_sensor_read_samp_freq_value(
+		ret_type = hid_sensor_read_samp_freq_value(
 				&prox_state->common_attributes, val, val2);
-		ret_type = IIO_VAL_INT_PLUS_MICRO;
 		break;
 	case IIO_CHAN_INFO_HYSTERESIS:
-		ret = hid_sensor_read_raw_hyst_value(
+		ret_type = hid_sensor_read_raw_hyst_value(
 				&prox_state->common_attributes, val, val2);
-		ret_type = IIO_VAL_INT_PLUS_MICRO;
 		break;
 	default:
 		ret_type = -EINVAL;
diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c
index fe063a0..7525699 100644
--- a/drivers/iio/light/tcs3472.c
+++ b/drivers/iio/light/tcs3472.c
@@ -52,6 +52,7 @@
 
 struct tcs3472_data {
 	struct i2c_client *client;
+	struct mutex lock;
 	u8 enable;
 	u8 control;
 	u8 atime;
@@ -116,10 +117,17 @@
 
 	switch (mask) {
 	case IIO_CHAN_INFO_RAW:
+		if (iio_buffer_enabled(indio_dev))
+			return -EBUSY;
+
+		mutex_lock(&data->lock);
 		ret = tcs3472_req_data(data);
-		if (ret < 0)
+		if (ret < 0) {
+			mutex_unlock(&data->lock);
 			return ret;
+		}
 		ret = i2c_smbus_read_word_data(data->client, chan->address);
+		mutex_unlock(&data->lock);
 		if (ret < 0)
 			return ret;
 		*val = ret;
@@ -255,6 +263,7 @@
 	data = iio_priv(indio_dev);
 	i2c_set_clientdata(client, indio_dev);
 	data->client = client;
+	mutex_init(&data->lock);
 
 	indio_dev->dev.parent = &client->dev;
 	indio_dev->info = &tcs3472_info;
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index ad83cf2..3ec777a 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -156,7 +156,6 @@
 	struct magn_3d_state *magn_state = iio_priv(indio_dev);
 	int report_id = -1;
 	u32 address;
-	int ret;
 	int ret_type;
 	s32 poll_value;
 
@@ -199,14 +198,12 @@
 		ret_type = IIO_VAL_INT;
 		break;
 	case IIO_CHAN_INFO_SAMP_FREQ:
-		ret = hid_sensor_read_samp_freq_value(
+		ret_type = hid_sensor_read_samp_freq_value(
 			&magn_state->common_attributes, val, val2);
-		ret_type = IIO_VAL_INT_PLUS_MICRO;
 		break;
 	case IIO_CHAN_INFO_HYSTERESIS:
-		ret = hid_sensor_read_raw_hyst_value(
+		ret_type = hid_sensor_read_raw_hyst_value(
 			&magn_state->common_attributes, val, val2);
-		ret_type = IIO_VAL_INT_PLUS_MICRO;
 		break;
 	default:
 		ret_type = -EINVAL;
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index 1cd190c..2c0d2a4 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -78,7 +78,6 @@
 	struct press_state *press_state = iio_priv(indio_dev);
 	int report_id = -1;
 	u32 address;
-	int ret;
 	int ret_type;
 	s32 poll_value;
 
@@ -128,14 +127,12 @@
 		ret_type = IIO_VAL_INT;
 		break;
 	case IIO_CHAN_INFO_SAMP_FREQ:
-		ret = hid_sensor_read_samp_freq_value(
+		ret_type = hid_sensor_read_samp_freq_value(
 				&press_state->common_attributes, val, val2);
-		ret_type = IIO_VAL_INT_PLUS_MICRO;
 		break;
 	case IIO_CHAN_INFO_HYSTERESIS:
-		ret = hid_sensor_read_raw_hyst_value(
+		ret_type = hid_sensor_read_raw_hyst_value(
 				&press_state->common_attributes, val, val2);
-		ret_type = IIO_VAL_INT_PLUS_MICRO;
 		break;
 	default:
 		ret_type = -EINVAL;
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 53b2132..4cba2d8 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 Christophe Saout <christophe@saout.de>
+ * Copyright (C) 2003 Jana Saout <jana@saout.de>
  * Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org>
  * Copyright (C) 2006-2009 Red Hat, Inc. All rights reserved.
  * Copyright (C) 2013 Milan Broz <gmazyland@gmail.com>
@@ -1996,6 +1996,6 @@
 module_init(dm_crypt_init);
 module_exit(dm_crypt_exit);
 
-MODULE_AUTHOR("Christophe Saout <christophe@saout.de>");
+MODULE_AUTHOR("Jana Saout <jana@saout.de>");
 MODULE_DESCRIPTION(DM_NAME " target for transparent encryption / decryption");
 MODULE_LICENSE("GPL");
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index 3842ac7..db404a0 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -10,6 +10,7 @@
 #include <linux/device-mapper.h>
 
 #include <linux/bio.h>
+#include <linux/completion.h>
 #include <linux/mempool.h>
 #include <linux/module.h>
 #include <linux/sched.h>
@@ -32,7 +33,7 @@
 struct io {
 	unsigned long error_bits;
 	atomic_t count;
-	struct task_struct *sleeper;
+	struct completion *wait;
 	struct dm_io_client *client;
 	io_notify_fn callback;
 	void *context;
@@ -121,8 +122,8 @@
 			invalidate_kernel_vmap_range(io->vma_invalidate_address,
 						     io->vma_invalidate_size);
 
-		if (io->sleeper)
-			wake_up_process(io->sleeper);
+		if (io->wait)
+			complete(io->wait);
 
 		else {
 			unsigned long r = io->error_bits;
@@ -387,6 +388,7 @@
 	 */
 	volatile char io_[sizeof(struct io) + __alignof__(struct io) - 1];
 	struct io *io = (struct io *)PTR_ALIGN(&io_, __alignof__(struct io));
+	DECLARE_COMPLETION_ONSTACK(wait);
 
 	if (num_regions > 1 && (rw & RW_MASK) != WRITE) {
 		WARN_ON(1);
@@ -395,7 +397,7 @@
 
 	io->error_bits = 0;
 	atomic_set(&io->count, 1); /* see dispatch_io() */
-	io->sleeper = current;
+	io->wait = &wait;
 	io->client = client;
 
 	io->vma_invalidate_address = dp->vma_invalidate_address;
@@ -403,15 +405,7 @@
 
 	dispatch_io(rw, num_regions, where, dp, io, 1);
 
-	while (1) {
-		set_current_state(TASK_UNINTERRUPTIBLE);
-
-		if (!atomic_read(&io->count))
-			break;
-
-		io_schedule();
-	}
-	set_current_state(TASK_RUNNING);
+	wait_for_completion_io(&wait);
 
 	if (error_bits)
 		*error_bits = io->error_bits;
@@ -434,7 +428,7 @@
 	io = mempool_alloc(client->pool, GFP_NOIO);
 	io->error_bits = 0;
 	atomic_set(&io->count, 1); /* see dispatch_io() */
-	io->sleeper = NULL;
+	io->wait = NULL;
 	io->client = client;
 	io->callback = fn;
 	io->context = context;
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 3f6fd9d..f4167b0 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1611,8 +1611,9 @@
 
 	spin_lock_irqsave(&m->lock, flags);
 
-	/* pg_init in progress, requeue until done */
-	if (!pg_ready(m)) {
+	/* pg_init in progress or no paths available */
+	if (m->pg_init_in_progress ||
+	    (!m->nr_valid_paths && m->queue_if_no_path)) {
 		busy = 1;
 		goto out;
 	}
diff --git a/drivers/md/dm-zero.c b/drivers/md/dm-zero.c
index c99003e..b9a64bb 100644
--- a/drivers/md/dm-zero.c
+++ b/drivers/md/dm-zero.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 Christophe Saout <christophe@saout.de>
+ * Copyright (C) 2003 Jana Saout <jana@saout.de>
  *
  * This file is released under the GPL.
  */
@@ -79,6 +79,6 @@
 module_init(dm_zero_init)
 module_exit(dm_zero_exit)
 
-MODULE_AUTHOR("Christophe Saout <christophe@saout.de>");
+MODULE_AUTHOR("Jana Saout <jana@saout.de>");
 MODULE_DESCRIPTION(DM_NAME " dummy target returning zeros");
 MODULE_LICENSE("GPL");
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 437d990..32b958d 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -54,6 +54,8 @@
 
 static DECLARE_WORK(deferred_remove_work, do_deferred_remove);
 
+static struct workqueue_struct *deferred_remove_workqueue;
+
 /*
  * For bio-based dm.
  * One of these is allocated per bio.
@@ -276,16 +278,24 @@
 	if (r)
 		goto out_free_rq_tio_cache;
 
+	deferred_remove_workqueue = alloc_workqueue("kdmremove", WQ_UNBOUND, 1);
+	if (!deferred_remove_workqueue) {
+		r = -ENOMEM;
+		goto out_uevent_exit;
+	}
+
 	_major = major;
 	r = register_blkdev(_major, _name);
 	if (r < 0)
-		goto out_uevent_exit;
+		goto out_free_workqueue;
 
 	if (!_major)
 		_major = r;
 
 	return 0;
 
+out_free_workqueue:
+	destroy_workqueue(deferred_remove_workqueue);
 out_uevent_exit:
 	dm_uevent_exit();
 out_free_rq_tio_cache:
@@ -299,6 +309,7 @@
 static void local_exit(void)
 {
 	flush_scheduled_work();
+	destroy_workqueue(deferred_remove_workqueue);
 
 	kmem_cache_destroy(_rq_tio_cache);
 	kmem_cache_destroy(_io_cache);
@@ -407,7 +418,7 @@
 
 	if (atomic_dec_and_test(&md->open_count) &&
 	    (test_bit(DMF_DEFERRED_REMOVE, &md->flags)))
-		schedule_work(&deferred_remove_work);
+		queue_work(deferred_remove_workqueue, &deferred_remove_work);
 
 	dm_put(md);
 
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 63a54a3..1c8592b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3135,8 +3135,13 @@
 	if (probe)
 		return 0;
 
-	/* Wait for Transaction Pending bit clean */
-	if (pci_wait_for_pending(dev, pos + PCI_AF_STATUS, PCI_AF_STATUS_TP))
+	/*
+	 * Wait for Transaction Pending bit to clear.  A word-aligned test
+	 * is used, so we use the conrol offset rather than status and shift
+	 * the test bit to match.
+	 */
+	if (pci_wait_for_pending(dev, pos + PCI_AF_CTRL,
+				 PCI_AF_STATUS_TP << 8))
 		goto clear;
 
 	dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n");
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 16a2f06..64b98d2 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -112,6 +112,7 @@
 config PHY_SUN4I_USB
 	tristate "Allwinner sunxi SoC USB PHY driver"
 	depends on ARCH_SUNXI && HAS_IOMEM && OF
+	depends on RESET_CONTROLLER
 	select GENERIC_PHY
 	help
 	  Enable this to support the transceiver that is part of Allwinner
@@ -122,6 +123,7 @@
 
 config PHY_SAMSUNG_USB2
 	tristate "Samsung USB 2.0 PHY driver"
+	depends on HAS_IOMEM
 	select GENERIC_PHY
 	select MFD_SYSCON
 	help
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index c64a2f3..49c4465 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -614,8 +614,9 @@
 	return phy;
 
 put_dev:
-	put_device(&phy->dev);
-	ida_remove(&phy_ida, phy->id);
+	put_device(&phy->dev);  /* calls phy_release() which frees resources */
+	return ERR_PTR(ret);
+
 free_phy:
 	kfree(phy);
 	return ERR_PTR(ret);
@@ -799,7 +800,7 @@
 
 	phy = to_phy(dev);
 	dev_vdbg(dev, "releasing '%s'\n", dev_name(dev));
-	ida_remove(&phy_ida, phy->id);
+	ida_simple_remove(&phy_ida, phy->id);
 	kfree(phy);
 }
 
diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index 7007c11..34b3961 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -233,8 +233,8 @@
 	if (phy_data->flags & OMAP_USB2_CALIBRATE_FALSE_DISCONNECT) {
 		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 		phy->phy_base = devm_ioremap_resource(&pdev->dev, res);
-		if (!phy->phy_base)
-			return -ENOMEM;
+		if (IS_ERR(phy->phy_base))
+			return PTR_ERR(phy->phy_base);
 		phy->flags |= OMAP_USB2_CALIBRATE_FALSE_DISCONNECT;
 	}
 
@@ -262,7 +262,6 @@
 	otg->phy		= &phy->phy;
 
 	platform_set_drvdata(pdev, phy);
-	pm_runtime_enable(phy->dev);
 
 	generic_phy = devm_phy_create(phy->dev, &ops, NULL);
 	if (IS_ERR(generic_phy))
@@ -270,10 +269,13 @@
 
 	phy_set_drvdata(generic_phy, phy);
 
+	pm_runtime_enable(phy->dev);
 	phy_provider = devm_of_phy_provider_register(phy->dev,
 			of_phy_simple_xlate);
-	if (IS_ERR(phy_provider))
+	if (IS_ERR(phy_provider)) {
+		pm_runtime_disable(phy->dev);
 		return PTR_ERR(phy_provider);
+	}
 
 	phy->wkupclk = devm_clk_get(phy->dev, "wkupclk");
 	if (IS_ERR(phy->wkupclk)) {
@@ -317,6 +319,7 @@
 	if (!IS_ERR(phy->optclk))
 		clk_unprepare(phy->optclk);
 	usb_remove_phy(&phy->phy);
+	pm_runtime_disable(phy->dev);
 
 	return 0;
 }
diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy-samsung-usb2.c
index 8a8c6bc..1e69a32 100644
--- a/drivers/phy/phy-samsung-usb2.c
+++ b/drivers/phy/phy-samsung-usb2.c
@@ -107,6 +107,7 @@
 #endif
 	{ },
 };
+MODULE_DEVICE_TABLE(of, samsung_usb2_phy_of_match);
 
 static int samsung_usb2_phy_probe(struct platform_device *pdev)
 {
diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c
index edf5d2f..86db223 100644
--- a/drivers/pinctrl/berlin/berlin.c
+++ b/drivers/pinctrl/berlin/berlin.c
@@ -320,7 +320,7 @@
 
 	regmap = dev_get_regmap(&pdev->dev, NULL);
 	if (!regmap)
-		return PTR_ERR(regmap);
+		return -ENODEV;
 
 	pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL);
 	if (!pctrl)
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
index f1ca75e..5f38c7f 100644
--- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
+++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
@@ -211,6 +211,10 @@
 			configlen++;
 
 		pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL);
+		if (!pinconfig) {
+			kfree(*map);
+			return -ENOMEM;
+		}
 
 		if (!of_property_read_u32(node, "allwinner,drive", &val)) {
 			u16 strength = (val + 1) * 10;
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 0fd8744..5b14f0d 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -54,8 +54,6 @@
 
 source "drivers/staging/rts5208/Kconfig"
 
-source "drivers/staging/frontier/Kconfig"
-
 source "drivers/staging/phison/Kconfig"
 
 source "drivers/staging/line6/Kconfig"
@@ -74,14 +72,10 @@
 
 source "drivers/staging/xgifb/Kconfig"
 
-source "drivers/staging/tidspbridge/Kconfig"
-
 source "drivers/staging/quickstart/Kconfig"
 
 source "drivers/staging/emxx_udc/Kconfig"
 
-source "drivers/staging/keucr/Kconfig"
-
 source "drivers/staging/bcm/Kconfig"
 
 source "drivers/staging/ft1000/Kconfig"
@@ -108,8 +102,6 @@
 
 source "drivers/staging/silicom/Kconfig"
 
-source "drivers/staging/ced1401/Kconfig"
-
 source "drivers/staging/imx-drm/Kconfig"
 
 source "drivers/staging/fwserial/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 9aeecc9..d4536df 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -19,7 +19,6 @@
 obj-$(CONFIG_R8723AU)		+= rtl8723au/
 obj-$(CONFIG_R8821AE)		+= rtl8821ae/
 obj-$(CONFIG_RTS5208)		+= rts5208/
-obj-$(CONFIG_TRANZPORT)		+= frontier/
 obj-$(CONFIG_IDE_PHISON)	+= phison/
 obj-$(CONFIG_LINE6_USB)		+= line6/
 obj-$(CONFIG_NETLOGIC_XLR_NET)	+= netlogic/
@@ -31,10 +30,8 @@
 obj-$(CONFIG_DX_SEP)            += sep/
 obj-$(CONFIG_IIO)		+= iio/
 obj-$(CONFIG_FB_XGI)		+= xgifb/
-obj-$(CONFIG_TIDSPBRIDGE)	+= tidspbridge/
 obj-$(CONFIG_ACPI_QUICKSTART)	+= quickstart/
 obj-$(CONFIG_USB_EMXX)		+= emxx_udc/
-obj-$(CONFIG_USB_ENESTORAGE)	+= keucr/
 obj-$(CONFIG_BCM_WIMAX)		+= bcm/
 obj-$(CONFIG_FT1000)		+= ft1000/
 obj-$(CONFIG_SPEAKUP)		+= speakup/
@@ -47,7 +44,6 @@
 obj-$(CONFIG_WIMAX_GDM72XX)	+= gdm72xx/
 obj-$(CONFIG_LTE_GDM724X)	+= gdm724x/
 obj-$(CONFIG_NET_VENDOR_SILICOM)	+= silicom/
-obj-$(CONFIG_CED1401)		+= ced1401/
 obj-$(CONFIG_DRM_IMX)		+= imx-drm/
 obj-$(CONFIG_FIREWIRE_SERIAL)	+= fwserial/
 obj-$(CONFIG_GOLDFISH)		+= goldfish/
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index e446f62..02b0379 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -1185,6 +1185,7 @@
 				     uint32_t error_code)
 {
 	struct binder_thread *target_thread;
+	struct binder_transaction *next;
 
 	BUG_ON(t->flags & TF_ONE_WAY);
 	while (1) {
@@ -1212,24 +1213,23 @@
 					target_thread->return_error);
 			}
 			return;
-		} else {
-			struct binder_transaction *next = t->from_parent;
-
-			binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
-				     "send failed reply for transaction %d, target dead\n",
-				     t->debug_id);
-
-			binder_pop_transaction(target_thread, t);
-			if (next == NULL) {
-				binder_debug(BINDER_DEBUG_DEAD_BINDER,
-					     "reply failed, no target thread at root\n");
-				return;
-			}
-			t = next;
-			binder_debug(BINDER_DEBUG_DEAD_BINDER,
-				     "reply failed, no target thread -- retry %d\n",
-				      t->debug_id);
 		}
+		next = t->from_parent;
+
+		binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
+			     "send failed reply for transaction %d, target dead\n",
+			     t->debug_id);
+
+		binder_pop_transaction(target_thread, t);
+		if (next == NULL) {
+			binder_debug(BINDER_DEBUG_DEAD_BINDER,
+				     "reply failed, no target thread at root\n");
+			return;
+		}
+		t = next;
+		binder_debug(BINDER_DEBUG_DEAD_BINDER,
+			     "reply failed, no target thread -- retry %d\n",
+			      t->debug_id);
 	}
 }
 
diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h
index dcd2a0c..d305bb7 100644
--- a/drivers/staging/android/ion/ion.h
+++ b/drivers/staging/android/ion/ion.h
@@ -84,7 +84,6 @@
 /**
  * ion_client_create() -  allocate a client and returns it
  * @dev:		the global ion device
- * @heap_type_mask:	mask of heaps this client can allocate from
  * @name:		used for debugging
  */
 struct ion_client *ion_client_create(struct ion_device *dev,
diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c
index ce68ecf..f8cabcb 100644
--- a/drivers/staging/android/ion/ion_cma_heap.c
+++ b/drivers/staging/android/ion/ion_cma_heap.c
@@ -76,10 +76,8 @@
 		return -EINVAL;
 
 	info = kzalloc(sizeof(struct ion_cma_buffer_info), GFP_KERNEL);
-	if (!info) {
-		dev_err(dev, "Can't allocate buffer info\n");
+	if (!info)
 		return ION_CMA_ALLOCATE_FAILED;
-	}
 
 	info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle),
 						GFP_HIGHUSER | __GFP_ZERO);
@@ -90,10 +88,8 @@
 	}
 
 	info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
-	if (!info->table) {
-		dev_err(dev, "Fail to allocate sg table\n");
+	if (!info->table)
 		goto free_mem;
-	}
 
 	if (ion_cma_get_sgtable
 	    (dev, info->table, info->cpu_addr, info->handle, len))
@@ -155,7 +151,6 @@
 static void ion_cma_heap_unmap_dma(struct ion_heap *heap,
 				   struct ion_buffer *buffer)
 {
-	return;
 }
 
 static int ion_cma_mmap(struct ion_heap *mapper, struct ion_buffer *buffer,
diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c
index 18174f7..cd7b8f5 100644
--- a/drivers/staging/android/sync.c
+++ b/drivers/staging/android/sync.c
@@ -687,8 +687,7 @@
 		return POLLIN;
 	else if (fence->status < 0)
 		return POLLERR;
-	else
-		return 0;
+	return 0;
 }
 
 static long sync_fence_ioctl_wait(struct sync_fence *fence, unsigned long arg)
diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c
index a1c833c..883f739 100644
--- a/drivers/staging/bcm/Misc.c
+++ b/drivers/staging/bcm/Misc.c
@@ -1154,7 +1154,7 @@
 	reporting_mode = ntohl(psAdapter->pstargetparams->m_u32PowerSavingModeOptions) & 0x02;
 	psAdapter->bIsAutoCorrectEnabled = !((char)(psAdapter->ulPowerSaveMode >> 3) & 0x1);
 
-	if (reporting_mode == TRUE) {
+	if (reporting_mode) {
 		BCM_DEBUG_PRINT(psAdapter, DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "can't do suspen/resume as reporting mode is enable");
 		psAdapter->bDoSuspend = false;
 	}
diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c
index 4b6de76..5f4e503 100644
--- a/drivers/staging/bcm/PHSModule.c
+++ b/drivers/staging/bcm/PHSModule.c
@@ -1,46 +1,80 @@
 #include "headers.h"
 
-static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid, B_UINT16 uiClsId, struct bcm_phs_table *psServiceFlowTable, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI);
+static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid,
+					    B_UINT16 uiClsId,
+					    struct bcm_phs_table *psServiceFlowTable,
+					    struct bcm_phs_rule *psPhsRule,
+					    B_UINT8 u8AssociatedPHSI);
 
-static UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid, B_UINT16  uiClsId, struct bcm_phs_entry *pstServiceFlowEntry, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI);
+static UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid,
+					    B_UINT16  uiClsId,
+					    struct bcm_phs_entry *pstServiceFlowEntry,
+					    struct bcm_phs_rule *psPhsRule,
+					    B_UINT8 u8AssociatedPHSI);
 
-static UINT CreateClassifierPHSRule(B_UINT16  uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *psPhsRule, enum bcm_phs_classifier_context eClsContext, B_UINT8 u8AssociatedPHSI);
+static UINT CreateClassifierPHSRule(B_UINT16  uiClsId,
+				    struct bcm_phs_classifier_table *psaClassifiertable,
+				    struct bcm_phs_rule *psPhsRule,
+				    enum bcm_phs_classifier_context eClsContext,
+				    B_UINT8 u8AssociatedPHSI);
 
-static UINT UpdateClassifierPHSRule(B_UINT16 uiClsId, struct bcm_phs_classifier_entry *pstClassifierEntry, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI);
+static UINT UpdateClassifierPHSRule(B_UINT16 uiClsId,
+				    struct bcm_phs_classifier_entry *pstClassifierEntry,
+				    struct bcm_phs_classifier_table *psaClassifiertable,
+				    struct bcm_phs_rule *psPhsRule,
+				    B_UINT8 u8AssociatedPHSI);
 
-static bool ValidatePHSRuleComplete(struct bcm_phs_rule *psPhsRule);
+static bool ValidatePHSRuleComplete(const struct bcm_phs_rule *psPhsRule);
 
-static bool DerefPhsRule(B_UINT16 uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *pstPhsRule);
+static bool DerefPhsRule(B_UINT16 uiClsId,
+			 struct bcm_phs_classifier_table *psaClassifiertable,
+			 struct bcm_phs_rule *pstPhsRule);
 
-static UINT GetClassifierEntry(struct bcm_phs_classifier_table *pstClassifierTable, B_UINT32 uiClsid, enum bcm_phs_classifier_context eClsContext, struct bcm_phs_classifier_entry **ppstClassifierEntry);
+static UINT GetClassifierEntry(struct bcm_phs_classifier_table *pstClassifierTable,
+			       B_UINT32 uiClsid,
+			       enum bcm_phs_classifier_context eClsContext,
+			       struct bcm_phs_classifier_entry **ppstClassifierEntry);
 
-static UINT GetPhsRuleEntry(struct bcm_phs_classifier_table *pstClassifierTable, B_UINT32 uiPHSI, enum bcm_phs_classifier_context eClsContext, struct bcm_phs_rule **ppstPhsRule);
+static UINT GetPhsRuleEntry(struct bcm_phs_classifier_table *pstClassifierTable,
+			    B_UINT32 uiPHSI,
+			    enum bcm_phs_classifier_context eClsContext,
+			    struct bcm_phs_rule **ppstPhsRule);
 
 static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable);
 
-static int phs_compress(struct bcm_phs_rule *phs_members, unsigned char *in_buf,
-			unsigned char *out_buf, unsigned int *header_size, UINT *new_header_size);
+static int phs_compress(struct bcm_phs_rule *phs_members,
+			unsigned char *in_buf,
+			unsigned char *out_buf,
+			unsigned int *header_size,
+			UINT *new_header_size);
 
-static int verify_suppress_phsf(unsigned char *in_buffer, unsigned char *out_buffer,
-				unsigned char *phsf, unsigned char *phsm, unsigned int phss, unsigned int phsv, UINT *new_header_size);
+static int verify_suppress_phsf(unsigned char *in_buffer,
+				unsigned char *out_buffer,
+				unsigned char *phsf,
+				unsigned char *phsm,
+				unsigned int phss,
+				unsigned int phsv,
+				UINT *new_header_size);
 
-static int phs_decompress(unsigned char *in_buf, unsigned char *out_buf,
-			struct bcm_phs_rule *phs_rules, UINT *header_size);
+static int phs_decompress(unsigned char *in_buf,
+			  unsigned char *out_buf,
+			  struct bcm_phs_rule *phs_rules,
+			  UINT *header_size);
 
 static ULONG PhsCompress(void *pvContext,
-			B_UINT16 uiVcid,
-			B_UINT16 uiClsId,
-			void *pvInputBuffer,
-			void *pvOutputBuffer,
-			UINT *pOldHeaderSize,
-			UINT *pNewHeaderSize);
+			 B_UINT16 uiVcid,
+			 B_UINT16 uiClsId,
+			 void *pvInputBuffer,
+			 void *pvOutputBuffer,
+			 UINT *pOldHeaderSize,
+			 UINT *pNewHeaderSize);
 
 static ULONG PhsDeCompress(void *pvContext,
-			B_UINT16 uiVcid,
-			void *pvInputBuffer,
-			void *pvOutputBuffer,
-			UINT *pInHeaderSize,
-			UINT *pOutHeaderSize);
+			   B_UINT16 uiVcid,
+			   void *pvInputBuffer,
+			   void *pvOutputBuffer,
+			   UINT *pInHeaderSize,
+			   UINT *pOutHeaderSize);
 
 #define IN
 #define OUT
@@ -76,9 +110,11 @@
 	UINT unPhsOldHdrSize = 0;
 	UINT unPHSNewPktHeaderLen = 0;
 	/* Pointer to PHS IN Hdr Buffer */
-	PUCHAR pucPHSPktHdrInBuf = Adapter->stPhsTxContextInfo.ucaHdrSuppressionInBuf;
+	PUCHAR pucPHSPktHdrInBuf =
+		Adapter->stPhsTxContextInfo.ucaHdrSuppressionInBuf;
 	/* Pointer to PHS OUT Hdr Buffer */
-	PUCHAR pucPHSPktHdrOutBuf = Adapter->stPhsTxContextInfo.ucaHdrSuppressionOutBuf;
+	PUCHAR pucPHSPktHdrOutBuf =
+		Adapter->stPhsTxContextInfo.ucaHdrSuppressionOutBuf;
 	UINT usPacketType;
 	UINT BytesToRemove = 0;
 	bool bPHSI = 0;
@@ -87,7 +123,8 @@
 	struct sk_buff *newPacket = NULL;
 	struct sk_buff *Packet = *pPacket;
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "In PHSTransmit");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
+			"In PHSTransmit");
 
 	if (!bEthCSSupport)
 		BytesToRemove = ETH_HLEN;
@@ -109,23 +146,31 @@
 		(unPHSPktHdrBytesCopied <= MAX_PHS_LENGTHS)) {
 
 		/*
-		 * Step 2 Suppress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf.
-		 * Suppress only if IP Header and PHS Enabled For the Service Flow
+		 * Step 2 Suppress Header using PHS and fill into intermediate
+		 * ucaPHSPktHdrOutBuf.
+		 * Suppress only if IP Header and PHS Enabled For the
+		 * Service Flow
 		 */
 		if (((usPacketType == ETHERNET_FRAMETYPE_IPV4) ||
 				(usPacketType == ETHERNET_FRAMETYPE_IPV6)) &&
 			(bHeaderSuppressionEnabled)) {
 
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nTrying to PHS Compress Using Classifier rule 0x%X", uiClassifierRuleID);
+			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND,
+					DBG_LVL_ALL,
+					"\nTrying to PHS Compress Using Classifier rule 0x%X",
+					uiClassifierRuleID);
 			unPHSNewPktHeaderLen = unPHSPktHdrBytesCopied;
 			ulPhsStatus = PhsCompress(&Adapter->stBCMPhsContext,
-						Vcid,
-						uiClassifierRuleID,
-						pucPHSPktHdrInBuf,
-						pucPHSPktHdrOutBuf,
-						&unPhsOldHdrSize,
-						&unPHSNewPktHeaderLen);
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nPHS Old header Size : %d New Header Size  %d\n", unPhsOldHdrSize, unPHSNewPktHeaderLen);
+						  Vcid,
+						  uiClassifierRuleID,
+						  pucPHSPktHdrInBuf,
+						  pucPHSPktHdrOutBuf,
+						  &unPhsOldHdrSize,
+						  &unPHSNewPktHeaderLen);
+			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND,
+					DBG_LVL_ALL,
+					"\nPHS Old header Size : %d New Header Size  %d\n",
+					unPhsOldHdrSize, unPHSNewPktHeaderLen);
 
 			if (unPHSNewPktHeaderLen == unPhsOldHdrSize) {
 
@@ -137,32 +182,45 @@
 
 			if (ulPhsStatus == STATUS_PHS_COMPRESSED) {
 
-				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "PHS Sending packet Compressed");
+				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
+						PHS_SEND, DBG_LVL_ALL,
+						"PHS Sending packet Compressed");
 
 				if (skb_cloned(Packet)) {
-					newPacket = skb_copy(Packet, GFP_ATOMIC);
+					newPacket =
+						skb_copy(Packet, GFP_ATOMIC);
 
 					if (newPacket == NULL)
 						return STATUS_FAILURE;
 
 					dev_kfree_skb(Packet);
 					*pPacket = Packet = newPacket;
-					pucPHSPktHdrInBuf = Packet->data  + BytesToRemove;
+					pucPHSPktHdrInBuf =
+						Packet->data + BytesToRemove;
 				}
 
-				numBytesCompressed = unPhsOldHdrSize - (unPHSNewPktHeaderLen + PHSI_LEN);
+				numBytesCompressed = unPhsOldHdrSize -
+					(unPHSNewPktHeaderLen + PHSI_LEN);
 
-				memcpy(pucPHSPktHdrInBuf + numBytesCompressed, pucPHSPktHdrOutBuf, unPHSNewPktHeaderLen + PHSI_LEN);
-				memcpy(Packet->data + numBytesCompressed, Packet->data, BytesToRemove);
+				memcpy(pucPHSPktHdrInBuf + numBytesCompressed,
+				       pucPHSPktHdrOutBuf,
+				       unPHSNewPktHeaderLen + PHSI_LEN);
+				memcpy(Packet->data + numBytesCompressed,
+				       Packet->data, BytesToRemove);
 				skb_pull(Packet, numBytesCompressed);
 
 				return STATUS_SUCCESS;
 			} else {
-				/* if one byte headroom is not available, increase it through skb_cow */
+				/* if one byte headroom is not available,
+				 * increase it through skb_cow
+				 */
 				if (!(skb_headroom(Packet) > 0)) {
 
 					if (skb_cow(Packet, 1)) {
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "SKB Cow Failed\n");
+						BCM_DEBUG_PRINT(Adapter,
+								DBG_TYPE_PRINTK,
+								0, 0,
+								"SKB Cow Failed\n");
 						return STATUS_FAILURE;
 					}
 				}
@@ -179,22 +237,25 @@
 		} else {
 
 			if (!bHeaderSuppressionEnabled)
-				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nHeader Suppression Disabled For SF: No PHS\n");
+				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
+						PHS_SEND, DBG_LVL_ALL,
+						"\nHeader Suppression Disabled For SF: No PHS\n");
 
 			return STATUS_SUCCESS;
 		}
 	}
 
-	/* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"PHSTransmit : Dumping data packet After PHS"); */
+	/* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
+	 * "PHSTransmit : Dumping data packet After PHS"); */
 	return STATUS_SUCCESS;
 }
 
 int PHSReceive(struct bcm_mini_adapter *Adapter,
-	USHORT usVcid,
-	struct sk_buff *packet,
-	UINT *punPacketLen,
-	UCHAR *pucEthernetHdr,
-	UINT bHeaderSuppressionEnabled)
+	       USHORT usVcid,
+	       struct sk_buff *packet,
+	       UINT *punPacketLen,
+	       UCHAR *pucEthernetHdr,
+	       UINT bHeaderSuppressionEnabled)
 {
 	u32 nStandardPktHdrLen = 0;
 	u32 nTotalsuppressedPktHdrBytes = 0;
@@ -203,7 +264,9 @@
 	UINT TotalBytesAdded = 0;
 
 	if (!bHeaderSuppressionEnabled) {
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "\nPhs Disabled for incoming packet");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
+				DBG_LVL_ALL,
+				"\nPhs Disabled for incoming packet");
 		return ulPhsStatus;
 	}
 
@@ -212,27 +275,31 @@
 	/* Restore PHS suppressed header */
 	nStandardPktHdrLen = packet->len;
 	ulPhsStatus = PhsDeCompress(&Adapter->stBCMPhsContext,
-				usVcid,
-				pucInBuff,
-				Adapter->ucaPHSPktRestoreBuf,
-				&nTotalsuppressedPktHdrBytes,
-				&nStandardPktHdrLen);
+				    usVcid,
+				    pucInBuff,
+				    Adapter->ucaPHSPktRestoreBuf,
+				    &nTotalsuppressedPktHdrBytes,
+				    &nStandardPktHdrLen);
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "\nSuppressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x",
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL,
+			"\nSuppressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x",
 			nTotalsuppressedPktHdrBytes, nStandardPktHdrLen);
 
 	if (ulPhsStatus != STATUS_PHS_COMPRESSED) {
 		skb_pull(packet, 1);
 		return STATUS_SUCCESS;
 	} else {
-		TotalBytesAdded = nStandardPktHdrLen - nTotalsuppressedPktHdrBytes - PHSI_LEN;
+		TotalBytesAdded = nStandardPktHdrLen -
+			nTotalsuppressedPktHdrBytes - PHSI_LEN;
 
 		if (TotalBytesAdded) {
 			if (skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded))
 				skb_push(packet, TotalBytesAdded);
 			else {
 				if (skb_cow(packet, skb_headroom(packet) + TotalBytesAdded)) {
-					BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "cow failed in receive\n");
+					BCM_DEBUG_PRINT(Adapter,
+							DBG_TYPE_PRINTK, 0, 0,
+							"cow failed in receive\n");
 					return STATUS_FAILURE;
 				}
 
@@ -240,7 +307,8 @@
 			}
 		}
 
-		memcpy(packet->data, Adapter->ucaPHSPktRestoreBuf, nStandardPktHdrLen);
+		memcpy(packet->data, Adapter->ucaPHSPktRestoreBuf,
+		       nStandardPktHdrLen);
 	}
 
 	return STATUS_SUCCESS;
@@ -250,47 +318,58 @@
 {
 	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dumping Data Packet");
-	BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, pBuf, nPktLen);
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,
+			"Dumping Data Packet");
+	BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,
+			       pBuf, nPktLen);
 }
 
 /*
  * Procedure:   phs_init
  *
- * Description: This routine is responsible for allocating memory for classifier and
- * PHS rules.
+ * Description: This routine is responsible for allocating memory for classifier
+ * and PHS rules.
  *
  * Arguments:
- * pPhsdeviceExtension - ptr to Device extension containing PHS Classifier rules and PHS Rules , RX, TX buffer etc
+ * pPhsdeviceExtension - ptr to Device extension containing PHS Classifier rules
+ * and PHS Rules , RX, TX buffer etc
  *
  * Returns:
  * TRUE(1)	-If allocation of memory was successful.
  * FALSE	-If allocation of memory fails.
  */
-int phs_init(struct bcm_phs_extension *pPhsdeviceExtension, struct bcm_mini_adapter *Adapter)
+int phs_init(struct bcm_phs_extension *pPhsdeviceExtension,
+	     struct bcm_mini_adapter *Adapter)
 {
 	int i;
 	struct bcm_phs_table *pstServiceFlowTable;
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nPHS:phs_init function");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
+			"\nPHS:phs_init function");
 
 	if (pPhsdeviceExtension->pstServiceFlowPhsRulesTable)
 		return -EINVAL;
 
-	pPhsdeviceExtension->pstServiceFlowPhsRulesTable = kzalloc(sizeof(struct bcm_phs_table), GFP_KERNEL);
+	pPhsdeviceExtension->pstServiceFlowPhsRulesTable =
+		kzalloc(sizeof(struct bcm_phs_table), GFP_KERNEL);
 
 	if (!pPhsdeviceExtension->pstServiceFlowPhsRulesTable) {
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation ServiceFlowPhsRulesTable failed");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
+				DBG_LVL_ALL,
+				"\nAllocation ServiceFlowPhsRulesTable failed");
 		return -ENOMEM;
 	}
 
 	pstServiceFlowTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable;
 	for (i = 0; i < MAX_SERVICEFLOWS; i++) {
-		struct bcm_phs_entry sServiceFlow = pstServiceFlowTable->stSFList[i];
-
-		sServiceFlow.pstClassifierTable = kzalloc(sizeof(struct bcm_phs_classifier_table), GFP_KERNEL);
+		struct bcm_phs_entry sServiceFlow =
+			pstServiceFlowTable->stSFList[i];
+		sServiceFlow.pstClassifierTable =
+			kzalloc(sizeof(struct bcm_phs_classifier_table),
+				GFP_KERNEL);
 		if (!sServiceFlow.pstClassifierTable) {
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed");
+			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
+					DBG_LVL_ALL, "\nAllocation failed");
 			free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
 			pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
 			return -ENOMEM;
@@ -299,22 +378,26 @@
 
 	pPhsdeviceExtension->CompressedTxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL);
 	if (pPhsdeviceExtension->CompressedTxBuffer == NULL) {
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
+				DBG_LVL_ALL, "\nAllocation failed");
 		free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
 		pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
 		return -ENOMEM;
 	}
 
-	pPhsdeviceExtension->UnCompressedRxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL);
+	pPhsdeviceExtension->UnCompressedRxBuffer =
+		kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL);
 	if (pPhsdeviceExtension->UnCompressedRxBuffer == NULL) {
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
+				DBG_LVL_ALL, "\nAllocation failed");
 		kfree(pPhsdeviceExtension->CompressedTxBuffer);
 		free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
 		pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
 		return -ENOMEM;
 	}
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n phs_init Successful");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
+			"\n phs_init Successful");
 	return STATUS_SUCCESS;
 }
 
@@ -353,21 +436,24 @@
  * >0 Error.
  */
 ULONG PhsUpdateClassifierRule(IN void *pvContext,
-			IN B_UINT16 uiVcid ,
-			IN B_UINT16 uiClsId   ,
-			IN struct bcm_phs_rule *psPhsRule,
-			IN B_UINT8 u8AssociatedPHSI)
+			      IN B_UINT16 uiVcid ,
+			      IN B_UINT16 uiClsId   ,
+			      IN struct bcm_phs_rule *psPhsRule,
+			      IN B_UINT8 u8AssociatedPHSI)
 {
 	ULONG lStatus = 0;
 	UINT nSFIndex = 0;
 	struct bcm_phs_entry *pstServiceFlowEntry = NULL;
 	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-	struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext;
+	struct bcm_phs_extension *pDeviceExtension =
+		(struct bcm_phs_extension *)pvContext;
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "PHS With Corr2 Changes\n");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
+			"PHS With Corr2 Changes\n");
 
 	if (pDeviceExtension == NULL) {
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "Invalid Device Extension\n");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
+				DBG_LVL_ALL, "Invalid Device Extension\n");
 		return ERR_PHS_INVALID_DEVICE_EXETENSION;
 	}
 
@@ -376,18 +462,22 @@
 
 	/* Retrieve the SFID Entry Index for requested Service Flow */
 	nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
-				uiVcid, &pstServiceFlowEntry);
+				       uiVcid, &pstServiceFlowEntry);
 
 	if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
 		/* This is a new SF. Create a mapping entry for this */
 		lStatus = CreateSFToClassifierRuleMapping(uiVcid, uiClsId,
-							pDeviceExtension->pstServiceFlowPhsRulesTable, psPhsRule, u8AssociatedPHSI);
+							  pDeviceExtension->pstServiceFlowPhsRulesTable,
+							  psPhsRule,
+							  u8AssociatedPHSI);
 		return lStatus;
 	}
 
 	/* SF already Exists Add PHS Rule to existing SF */
 	lStatus = CreateClassiferToPHSRuleMapping(uiVcid, uiClsId,
-						pstServiceFlowEntry, psPhsRule, u8AssociatedPHSI);
+						  pstServiceFlowEntry,
+						  psPhsRule,
+						  u8AssociatedPHSI);
 
 	return lStatus;
 }
@@ -408,40 +498,48 @@
  * 0 if successful,
  * >0 Error.
  */
-ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI)
+ULONG PhsDeletePHSRule(IN void *pvContext,
+		       IN B_UINT16 uiVcid,
+		       IN B_UINT8 u8PHSI)
 {
 	UINT nSFIndex = 0, nClsidIndex = 0;
 	struct bcm_phs_entry *pstServiceFlowEntry = NULL;
 	struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL;
 	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
 	struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext;
+	struct bcm_phs_classifier_entry *curr_entry;
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "======>\n");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
+			"======>\n");
 
 	if (pDeviceExtension) {
 		/* Retrieve the SFID Entry Index for requested Service Flow */
-		nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, uiVcid, &pstServiceFlowEntry);
+		nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
+					       uiVcid, &pstServiceFlowEntry);
 
 		if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n");
+			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
+					DBG_LVL_ALL, "SFID Match Failed\n");
 			return ERR_SF_MATCH_FAIL;
 		}
 
 		pstClassifierRulesTable = pstServiceFlowEntry->pstClassifierTable;
 		if (pstClassifierRulesTable) {
 			for (nClsidIndex = 0; nClsidIndex < MAX_PHSRULE_PER_SF; nClsidIndex++) {
-				if (pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].bUsed && pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule) {
-					if (pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8PHSI == u8PHSI) {
+				curr_entry = &pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex];
+				if (curr_entry->bUsed &&
+				    curr_entry->pstPhsRule &&
+				    (curr_entry->pstPhsRule->u8PHSI == u8PHSI)) {
 
-						if (pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
-							pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt--;
+					if (curr_entry->pstPhsRule->u8RefCnt)
+						curr_entry->pstPhsRule->u8RefCnt--;
 
-						if (0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
-							kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule);
+					if (0 == curr_entry->pstPhsRule->u8RefCnt)
+						kfree(curr_entry->pstPhsRule);
 
-						memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0,
-							sizeof(struct bcm_phs_classifier_entry));
-					}
+					memset(curr_entry,
+					       0,
+					       sizeof(struct bcm_phs_classifier_entry));
 				}
 			}
 		}
@@ -465,44 +563,62 @@
  * 0 if successful,
  * >0 Error.
  */
-ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT16 uiClsId)
+ULONG PhsDeleteClassifierRule(IN void *pvContext,
+			      IN B_UINT16 uiVcid,
+			      IN B_UINT16 uiClsId)
 {
 	UINT nSFIndex = 0, nClsidIndex = 0;
 	struct bcm_phs_entry *pstServiceFlowEntry = NULL;
 	struct bcm_phs_classifier_entry *pstClassifierEntry = NULL;
 	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-	struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext;
+	struct bcm_phs_extension *pDeviceExtension =
+		(struct bcm_phs_extension *)pvContext;
 
-	if (pDeviceExtension) {
-		/* Retrieve the SFID Entry Index for requested Service Flow */
-		nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, uiVcid, &pstServiceFlowEntry);
-		if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n");
-			return ERR_SF_MATCH_FAIL;
-		}
+	if (!pDeviceExtension)
+		goto out;
 
-		nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
-						uiClsId, eActiveClassifierRuleContext, &pstClassifierEntry);
-
-		if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) {
-			if (pstClassifierEntry->pstPhsRule) {
-				if (pstClassifierEntry->pstPhsRule->u8RefCnt)
-					pstClassifierEntry->pstPhsRule->u8RefCnt--;
-
-				if (0 == pstClassifierEntry->pstPhsRule->u8RefCnt)
-					kfree(pstClassifierEntry->pstPhsRule);
-			}
-			memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry));
-		}
-
-		nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
-						uiClsId, eOldClassifierRuleContext, &pstClassifierEntry);
-
-		if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) {
-			kfree(pstClassifierEntry->pstPhsRule);
-			memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry));
-		}
+	/* Retrieve the SFID Entry Index for requested Service Flow */
+	nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
+				       uiVcid, &pstServiceFlowEntry);
+	if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
+				DBG_LVL_ALL, "SFID Match Failed\n");
+		return ERR_SF_MATCH_FAIL;
 	}
+
+	nClsidIndex =
+		GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
+				   uiClsId,
+				   eActiveClassifierRuleContext,
+				   &pstClassifierEntry);
+
+	if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) &&
+			(!pstClassifierEntry->bUnclassifiedPHSRule)) {
+		if (pstClassifierEntry->pstPhsRule) {
+			if (pstClassifierEntry->pstPhsRule->u8RefCnt)
+				pstClassifierEntry->pstPhsRule->u8RefCnt--;
+
+			if (0 == pstClassifierEntry->pstPhsRule->u8RefCnt)
+				kfree(pstClassifierEntry->pstPhsRule);
+		}
+		memset(pstClassifierEntry, 0,
+		       sizeof(struct bcm_phs_classifier_entry));
+	}
+
+	nClsidIndex =
+		GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
+				   uiClsId,
+				   eOldClassifierRuleContext,
+				   &pstClassifierEntry);
+
+	if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) &&
+			(!pstClassifierEntry->bUnclassifiedPHSRule)) {
+		kfree(pstClassifierEntry->pstPhsRule);
+		memset(pstClassifierEntry, 0,
+		       sizeof(struct bcm_phs_classifier_entry));
+	}
+
+out:
 	return 0;
 }
 
@@ -527,50 +643,65 @@
 	struct bcm_phs_entry *pstServiceFlowEntry = NULL;
 	struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL;
 	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-	struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext;
+	struct bcm_phs_extension *pDeviceExtension =
+		(struct bcm_phs_extension *)pvContext;
+	struct bcm_phs_classifier_entry *curr_clsf_entry;
+	struct bcm_phs_classifier_entry *curr_rules_list;
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "====>\n");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
+			"====>\n");
 
-	if (pDeviceExtension) {
-		/* Retrieve the SFID Entry Index for requested Service Flow */
-		nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
-					uiVcid, &pstServiceFlowEntry);
-		if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n");
-			return ERR_SF_MATCH_FAIL;
-		}
+	if (!pDeviceExtension)
+		goto out;
 
-		pstClassifierRulesTable = pstServiceFlowEntry->pstClassifierTable;
-		if (pstClassifierRulesTable) {
-			for (nClsidIndex = 0; nClsidIndex < MAX_PHSRULE_PER_SF; nClsidIndex++) {
-				if (pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule) {
-
-					if (pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
-						pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt--;
-
-					if (0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
-						kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule);
-
-					pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule = NULL;
-				}
-				memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, sizeof(struct bcm_phs_classifier_entry));
-				if (pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule) {
-
-					if (pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
-						pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt--;
-
-					if (0 == pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
-						kfree(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule);
-
-					pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule = NULL;
-				}
-				memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex], 0, sizeof(struct bcm_phs_classifier_entry));
-			}
-		}
-		pstServiceFlowEntry->bUsed = false;
-		pstServiceFlowEntry->uiVcid = 0;
+	/* Retrieve the SFID Entry Index for requested Service Flow */
+	nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
+				       uiVcid, &pstServiceFlowEntry);
+	if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
+				DBG_LVL_ALL, "SFID Match Failed\n");
+		return ERR_SF_MATCH_FAIL;
 	}
 
+	pstClassifierRulesTable = pstServiceFlowEntry->pstClassifierTable;
+	if (pstClassifierRulesTable) {
+		for (nClsidIndex = 0; nClsidIndex < MAX_PHSRULE_PER_SF; nClsidIndex++) {
+			curr_clsf_entry =
+				&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex];
+
+			curr_rules_list =
+				&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex];
+
+			if (curr_clsf_entry->pstPhsRule) {
+
+				if (curr_clsf_entry->pstPhsRule->u8RefCnt)
+					curr_clsf_entry->pstPhsRule->u8RefCnt--;
+
+				if (0 == curr_clsf_entry->pstPhsRule->u8RefCnt)
+					kfree(curr_clsf_entry->pstPhsRule);
+
+				curr_clsf_entry->pstPhsRule = NULL;
+			}
+			memset(curr_clsf_entry, 0,
+			       sizeof(struct bcm_phs_classifier_entry));
+			if (curr_rules_list->pstPhsRule) {
+
+				if (curr_rules_list->pstPhsRule->u8RefCnt)
+					curr_rules_list->pstPhsRule->u8RefCnt--;
+
+				if (0 == curr_rules_list->pstPhsRule->u8RefCnt)
+					kfree(curr_rules_list->pstPhsRule);
+
+				curr_rules_list->pstPhsRule = NULL;
+			}
+			memset(curr_rules_list, 0,
+			       sizeof(struct bcm_phs_classifier_entry));
+		}
+	}
+	pstServiceFlowEntry->bUsed = false;
+	pstServiceFlowEntry->uiVcid = 0;
+
+out:
 	return 0;
 }
 
@@ -581,13 +712,18 @@
  *    Exported function to compress the data using PHS.
  *
  * Arguments:
- *	IN void* pvContext - PHS Driver Specific Context.
- *	IN B_UINT16 uiVcid    - The Service Flow ID to which current packet header compression applies.
- *	IN UINT  uiClsId   - The Classifier ID to which current packet header compression applies.
- *	IN void *pvInputBuffer - The Input buffer containg packet header data
- *	IN void *pvOutputBuffer - The output buffer returned by this function after PHS
- *	IN UINT *pOldHeaderSize  - The actual size of the header before PHS
- *	IN UINT *pNewHeaderSize - The new size of the header after applying PHS
+ *	IN void* pvContext	    - PHS Driver Specific Context.
+ *	IN B_UINT16 uiVcid	    - The Service Flow ID to which current
+ *				      packet header compression applies.
+ *	IN UINT  uiClsId	    - The Classifier ID to which current packet
+ *				      header compression applies.
+ *	IN void *pvInputBuffer	    - The Input buffer containg packet header
+ *				      data
+ *	IN void *pvOutputBuffer     - The output buffer returned by this
+ *				      function after PHS
+ *	IN UINT *pOldHeaderSize	    - The actual size of the header before PHS
+ *	IN UINT *pNewHeaderSize	    - The new size of the header after applying
+ *				      PHS
  *
  * Return Value:
  *
@@ -595,12 +731,12 @@
  * >0 Error.
  */
 static ULONG PhsCompress(IN void *pvContext,
-		IN B_UINT16 uiVcid,
-		IN B_UINT16 uiClsId,
-		IN void *pvInputBuffer,
-		OUT void *pvOutputBuffer,
-		OUT UINT *pOldHeaderSize,
-		OUT UINT *pNewHeaderSize)
+			 IN B_UINT16 uiVcid,
+			 IN B_UINT16 uiClsId,
+			 IN void *pvInputBuffer,
+			 OUT void *pvOutputBuffer,
+			 OUT UINT *pOldHeaderSize,
+			 OUT UINT *pNewHeaderSize)
 {
 	UINT nSFIndex = 0, nClsidIndex = 0;
 	struct bcm_phs_entry *pstServiceFlowEntry = NULL;
@@ -608,30 +744,36 @@
 	struct bcm_phs_rule *pstPhsRule = NULL;
 	ULONG lStatus = 0;
 	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-	struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext;
+	struct bcm_phs_extension *pDeviceExtension =
+		(struct bcm_phs_extension *)pvContext;
 
 	if (pDeviceExtension == NULL) {
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "Invalid Device Extension\n");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
+				"Invalid Device Extension\n");
 		lStatus = STATUS_PHS_NOCOMPRESSION;
 		return lStatus;
 	}
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "Suppressing header\n");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
+			"Suppressing header\n");
 
 	/* Retrieve the SFID Entry Index for requested Service Flow */
 	nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
-				uiVcid, &pstServiceFlowEntry);
+				       uiVcid, &pstServiceFlowEntry);
 	if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "SFID Match Failed\n");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
+				"SFID Match Failed\n");
 		lStatus = STATUS_PHS_NOCOMPRESSION;
 		return lStatus;
 	}
 
 	nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
-					uiClsId, eActiveClassifierRuleContext, &pstClassifierEntry);
+					 uiClsId, eActiveClassifierRuleContext,
+					 &pstClassifierEntry);
 
 	if (nClsidIndex == PHS_INVALID_TABLE_INDEX) {
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "No PHS Rule Defined For Classifier\n");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
+				"No PHS Rule Defined For Classifier\n");
 		lStatus =  STATUS_PHS_NOCOMPRESSION;
 		return lStatus;
 	}
@@ -639,20 +781,26 @@
 	/* get rule from SF id,Cls ID pair and proceed */
 	pstPhsRule = pstClassifierEntry->pstPhsRule;
 	if (!ValidatePHSRuleComplete(pstPhsRule)) {
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "PHS Rule Defined For Classifier But Not Complete\n");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
+				"PHS Rule Defined For Classifier But Not Complete\n");
 		lStatus = STATUS_PHS_NOCOMPRESSION;
 		return lStatus;
 	}
 
 	/* Compress Packet */
-	lStatus = phs_compress(pstPhsRule, (PUCHAR)pvInputBuffer,
-			(PUCHAR)pvOutputBuffer, pOldHeaderSize, pNewHeaderSize);
+	lStatus = phs_compress(pstPhsRule,
+			       (PUCHAR)pvInputBuffer,
+			       (PUCHAR)pvOutputBuffer,
+			       pOldHeaderSize,
+			       pNewHeaderSize);
 
 	if (lStatus == STATUS_PHS_COMPRESSED) {
-		pstPhsRule->PHSModifiedBytes += *pOldHeaderSize - *pNewHeaderSize - 1;
+		pstPhsRule->PHSModifiedBytes +=
+			*pOldHeaderSize - *pNewHeaderSize - 1;
 		pstPhsRule->PHSModifiedNumPackets++;
-	} else
+	} else {
 		pstPhsRule->PHSErrorNumPackets++;
+	}
 
 	return lStatus;
 }
@@ -664,11 +812,15 @@
  *    Exported function to restore the packet header in Rx path.
  *
  * Arguments:
- *	IN void* pvContext - PHS Driver Specific Context.
- *	IN B_UINT16 uiVcid    - The Service Flow ID to which current packet header restoration applies.
- *	IN  void *pvInputBuffer - The Input buffer containg suppressed packet header data
- *	OUT void *pvOutputBuffer - The output buffer returned by this function after restoration
- *	OUT UINT *pHeaderSize   - The packet header size after restoration is returned in this parameter.
+ *	IN void* pvContext	    - PHS Driver Specific Context.
+ *	IN B_UINT16 uiVcid	    - The Service Flow ID to which current
+ *				      packet header restoration applies.
+ *	IN  void *pvInputBuffer	    - The Input buffer containg suppressed
+ *				      packet header data
+ *	OUT void *pvOutputBuffer    - The output buffer returned by this
+ *				      function after restoration
+ *	OUT UINT *pHeaderSize	    - The packet header size after restoration
+ *				      is returned in this parameter.
  *
  * Return Value:
  *
@@ -676,52 +828,65 @@
  * >0 Error.
  */
 static ULONG PhsDeCompress(IN void *pvContext,
-		IN B_UINT16 uiVcid,
-		IN void *pvInputBuffer,
-		OUT void *pvOutputBuffer,
-		OUT UINT *pInHeaderSize,
-		OUT UINT *pOutHeaderSize)
+			   IN B_UINT16 uiVcid,
+			   IN void *pvInputBuffer,
+			   OUT void *pvOutputBuffer,
+			   OUT UINT *pInHeaderSize,
+			   OUT UINT *pOutHeaderSize)
 {
 	UINT nSFIndex = 0, nPhsRuleIndex = 0;
 	struct bcm_phs_entry *pstServiceFlowEntry = NULL;
 	struct bcm_phs_rule *pstPhsRule = NULL;
 	UINT phsi;
 	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
-	struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext;
+	struct bcm_phs_extension *pDeviceExtension =
+		(struct bcm_phs_extension *)pvContext;
 
 	*pInHeaderSize = 0;
 	if (pDeviceExtension == NULL) {
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "Invalid Device Extension\n");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
+				DBG_LVL_ALL, "Invalid Device Extension\n");
 		return ERR_PHS_INVALID_DEVICE_EXETENSION;
 	}
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "Restoring header\n");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL,
+			"Restoring header\n");
 
 	phsi = *((unsigned char *)(pvInputBuffer));
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "PHSI To Be Used For restore : %x\n", phsi);
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL,
+			"PHSI To Be Used For restore : %x\n", phsi);
 	if (phsi == UNCOMPRESSED_PACKET)
 		return STATUS_PHS_NOCOMPRESSION;
 
 	/* Retrieve the SFID Entry Index for requested Service Flow */
 	nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
-				uiVcid, &pstServiceFlowEntry);
+				       uiVcid, &pstServiceFlowEntry);
 	if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "SFID Match Failed During Lookup\n");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
+				DBG_LVL_ALL,
+				"SFID Match Failed During Lookup\n");
 		return ERR_SF_MATCH_FAIL;
 	}
 
-	nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable, phsi,
-					eActiveClassifierRuleContext, &pstPhsRule);
+	nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable,
+					phsi,
+					eActiveClassifierRuleContext,
+					&pstPhsRule);
 	if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) {
-		/* Phs Rule does not exist in  active rules table. Lets try in the old rules table. */
+		/* Phs Rule does not exist in  active rules table. Lets try
+		 * in the old rules table. */
 		nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable,
-						phsi, eOldClassifierRuleContext, &pstPhsRule);
+						phsi,
+						eOldClassifierRuleContext,
+						&pstPhsRule);
 		if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX)
 			return ERR_PHSRULE_MATCH_FAIL;
 	}
 
 	*pInHeaderSize = phs_decompress((PUCHAR)pvInputBuffer,
-					(PUCHAR)pvOutputBuffer, pstPhsRule, pOutHeaderSize);
+					(PUCHAR)pvOutputBuffer,
+					pstPhsRule,
+					pOutHeaderSize);
 
 	pstPhsRule->PHSModifiedBytes += *pOutHeaderSize - *pInHeaderSize - 1;
 
@@ -732,7 +897,8 @@
 /*
  * Procedure:   free_phs_serviceflow_rules
  *
- * Description: This routine is responsible for freeing memory allocated for PHS rules.
+ * Description: This routine is responsible for freeing memory allocated for
+ * PHS rules.
  *
  * Arguments:
  * rules	- ptr to S_SERVICEFLOW_TABLE structure.
@@ -744,82 +910,83 @@
 {
 	int i, j;
 	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
+	struct bcm_phs_classifier_entry *curr_act_rules_list;
+	struct bcm_phs_classifier_entry *curr_old_rules_list;
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "=======>\n");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
+			"=======>\n");
 
-	if (psServiceFlowRulesTable) {
-		for (i = 0; i < MAX_SERVICEFLOWS; i++) {
-			struct bcm_phs_entry stServiceFlowEntry = psServiceFlowRulesTable->stSFList[i];
-			struct bcm_phs_classifier_table *pstClassifierRulesTable = stServiceFlowEntry.pstClassifierTable;
+	if (!psServiceFlowRulesTable)
+		goto out;
 
-			if (pstClassifierRulesTable) {
-				for (j = 0; j < MAX_PHSRULE_PER_SF; j++) {
-					if (pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule) {
+	for (i = 0; i < MAX_SERVICEFLOWS; i++) {
+		struct bcm_phs_entry stServiceFlowEntry =
+			psServiceFlowRulesTable->stSFList[i];
+		struct bcm_phs_classifier_table *pstClassifierRulesTable =
+			stServiceFlowEntry.pstClassifierTable;
 
-						if (pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule->u8RefCnt)
-							pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule->u8RefCnt--;
+		if (pstClassifierRulesTable) {
+			for (j = 0; j < MAX_PHSRULE_PER_SF; j++) {
+				curr_act_rules_list =
+					&pstClassifierRulesTable->stActivePhsRulesList[j];
 
-						if (0 == pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule->u8RefCnt)
-							kfree(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule);
+				curr_old_rules_list =
+					&pstClassifierRulesTable->stOldPhsRulesList[j];
 
-						pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule = NULL;
-					}
+				if (curr_act_rules_list->pstPhsRule) {
 
-					if (pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule) {
+					if (curr_act_rules_list->pstPhsRule->u8RefCnt)
+						curr_act_rules_list->pstPhsRule->u8RefCnt--;
 
-						if (pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule->u8RefCnt)
-							pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule->u8RefCnt--;
+					if (0 == curr_act_rules_list->pstPhsRule->u8RefCnt)
+						kfree(curr_act_rules_list->pstPhsRule);
 
-						if (0 == pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule->u8RefCnt)
-							kfree(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule);
-
-						pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule = NULL;
-					}
+					curr_act_rules_list->pstPhsRule = NULL;
 				}
-				kfree(pstClassifierRulesTable);
-				stServiceFlowEntry.pstClassifierTable = pstClassifierRulesTable = NULL;
+
+				if (curr_old_rules_list->pstPhsRule) {
+
+					if (curr_old_rules_list->pstPhsRule->u8RefCnt)
+						curr_old_rules_list->pstPhsRule->u8RefCnt--;
+
+					if (0 == curr_old_rules_list->pstPhsRule->u8RefCnt)
+						kfree(curr_old_rules_list->pstPhsRule);
+
+					curr_old_rules_list->pstPhsRule = NULL;
+				}
 			}
+			kfree(pstClassifierRulesTable);
+			stServiceFlowEntry.pstClassifierTable =
+				pstClassifierRulesTable = NULL;
 		}
 	}
 
+out:
+
 	kfree(psServiceFlowRulesTable);
 	psServiceFlowRulesTable = NULL;
 }
 
-static bool ValidatePHSRuleComplete(IN struct bcm_phs_rule *psPhsRule)
+static bool ValidatePHSRuleComplete(IN const struct bcm_phs_rule *psPhsRule)
 {
-	if (psPhsRule) {
-		if (!psPhsRule->u8PHSI) {
-			/* PHSI is not valid */
-			return false;
-		}
-
-		if (!psPhsRule->u8PHSS) {
-			/* PHSS Is Undefined */
-			return false;
-		}
-
-		/* Check if PHSF is defines for the PHS Rule */
-		if (!psPhsRule->u8PHSFLength) /* If any part of PHSF is valid then Rule contains valid PHSF */
-			return false;
-
-		return TRUE;
-	} else
-		return false;
+	return (psPhsRule &&
+		psPhsRule->u8PHSI &&
+		psPhsRule->u8PHSS &&
+		psPhsRule->u8PHSFLength);
 }
 
 UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable,
-			IN B_UINT16 uiVcid,
-			struct bcm_phs_entry **ppstServiceFlowEntry)
+			 IN B_UINT16 uiVcid,
+			 struct bcm_phs_entry **ppstServiceFlowEntry)
 {
 	int i;
+	struct bcm_phs_entry *curr_sf_list;
 
 	for (i = 0; i < MAX_SERVICEFLOWS; i++) {
-		if (psServiceFlowTable->stSFList[i].bUsed) {
-			if (psServiceFlowTable->stSFList[i].uiVcid == uiVcid) {
-				*ppstServiceFlowEntry = &psServiceFlowTable->stSFList[i];
-				return i;
-			}
+		curr_sf_list = &psServiceFlowTable->stSFList[i];
+		if (curr_sf_list->bUsed && (curr_sf_list->uiVcid == uiVcid)) {
+			*ppstServiceFlowEntry = curr_sf_list;
+			return i;
 		}
 	}
 
@@ -828,8 +995,9 @@
 }
 
 static UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifierTable,
-			IN B_UINT32 uiClsid, enum bcm_phs_classifier_context eClsContext,
-			OUT struct bcm_phs_classifier_entry **ppstClassifierEntry)
+			       IN B_UINT32 uiClsid,
+			       enum bcm_phs_classifier_context eClsContext,
+			       OUT struct bcm_phs_classifier_entry **ppstClassifierEntry)
 {
 	int  i;
 	struct bcm_phs_classifier_entry *psClassifierRules = NULL;
@@ -837,15 +1005,16 @@
 	for (i = 0; i < MAX_PHSRULE_PER_SF; i++) {
 
 		if (eClsContext == eActiveClassifierRuleContext)
-			psClassifierRules = &pstClassifierTable->stActivePhsRulesList[i];
+			psClassifierRules =
+				&pstClassifierTable->stActivePhsRulesList[i];
 		else
-			psClassifierRules = &pstClassifierTable->stOldPhsRulesList[i];
+			psClassifierRules =
+				&pstClassifierTable->stOldPhsRulesList[i];
 
-		if (psClassifierRules->bUsed) {
-			if (psClassifierRules->uiClassifierRuleId == uiClsid) {
-				*ppstClassifierEntry = psClassifierRules;
-				return i;
-			}
+		if (psClassifierRules->bUsed &&
+		   (psClassifierRules->uiClassifierRuleId == uiClsid)) {
+			*ppstClassifierEntry = psClassifierRules;
+			return i;
 		}
 	}
 
@@ -854,23 +1023,25 @@
 }
 
 static UINT GetPhsRuleEntry(IN struct bcm_phs_classifier_table *pstClassifierTable,
-			IN B_UINT32 uiPHSI, enum bcm_phs_classifier_context eClsContext,
-			OUT struct bcm_phs_rule **ppstPhsRule)
+			    IN B_UINT32 uiPHSI,
+			    enum bcm_phs_classifier_context eClsContext,
+			    OUT struct bcm_phs_rule **ppstPhsRule)
 {
 	int  i;
 	struct bcm_phs_classifier_entry *pstClassifierRule = NULL;
 
 	for (i = 0; i < MAX_PHSRULE_PER_SF; i++) {
 		if (eClsContext == eActiveClassifierRuleContext)
-			pstClassifierRule = &pstClassifierTable->stActivePhsRulesList[i];
+			pstClassifierRule =
+				&pstClassifierTable->stActivePhsRulesList[i];
 		else
-			pstClassifierRule = &pstClassifierTable->stOldPhsRulesList[i];
+			pstClassifierRule =
+				&pstClassifierTable->stOldPhsRulesList[i];
 
-		if (pstClassifierRule->bUsed) {
-			if (pstClassifierRule->u8PHSI == uiPHSI) {
-				*ppstPhsRule = pstClassifierRule->pstPhsRule;
-				return i;
-			}
+		if (pstClassifierRule->bUsed &&
+		   (pstClassifierRule->u8PHSI == uiPHSI)) {
+			*ppstPhsRule = pstClassifierRule->pstPhsRule;
+			return i;
 		}
 	}
 
@@ -878,19 +1049,22 @@
 	return PHS_INVALID_TABLE_INDEX;
 }
 
-static UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid, IN B_UINT16  uiClsId,
-				IN struct bcm_phs_table *psServiceFlowTable,
-				struct bcm_phs_rule *psPhsRule,
-				B_UINT8 u8AssociatedPHSI)
+static UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid,
+					    IN B_UINT16  uiClsId,
+					    IN struct bcm_phs_table *psServiceFlowTable,
+					    struct bcm_phs_rule *psPhsRule,
+					    B_UINT8 u8AssociatedPHSI)
 {
 	struct bcm_phs_classifier_table *psaClassifiertable = NULL;
 	UINT uiStatus = 0;
 	int iSfIndex;
 	bool bFreeEntryFound = false;
+	struct bcm_phs_entry *curr_list;
 
 	/* Check for a free entry in SFID table */
 	for (iSfIndex = 0; iSfIndex < MAX_SERVICEFLOWS; iSfIndex++) {
-		if (!psServiceFlowTable->stSFList[iSfIndex].bUsed) {
+		curr_list = &psServiceFlowTable->stSFList[iSfIndex];
+		if (!curr_list->bUsed) {
 			bFreeEntryFound = TRUE;
 			break;
 		}
@@ -899,23 +1073,26 @@
 	if (!bFreeEntryFound)
 		return ERR_SFTABLE_FULL;
 
-	psaClassifiertable = psServiceFlowTable->stSFList[iSfIndex].pstClassifierTable;
-	uiStatus = CreateClassifierPHSRule(uiClsId, psaClassifiertable, psPhsRule,
-					eActiveClassifierRuleContext, u8AssociatedPHSI);
+	psaClassifiertable = curr_list->pstClassifierTable;
+	uiStatus = CreateClassifierPHSRule(uiClsId,
+					   psaClassifiertable,
+					   psPhsRule,
+					   eActiveClassifierRuleContext,
+					   u8AssociatedPHSI);
 	if (uiStatus == PHS_SUCCESS) {
 		/* Add entry at free index to the SF */
-		psServiceFlowTable->stSFList[iSfIndex].bUsed = TRUE;
-		psServiceFlowTable->stSFList[iSfIndex].uiVcid = uiVcid;
+		curr_list->bUsed = TRUE;
+		curr_list->uiVcid = uiVcid;
 	}
 
 	return uiStatus;
 }
 
 static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
-				IN B_UINT16 uiClsId,
-				IN struct bcm_phs_entry *pstServiceFlowEntry,
-				struct bcm_phs_rule *psPhsRule,
-				B_UINT8 u8AssociatedPHSI)
+					    IN B_UINT16 uiClsId,
+					    IN struct bcm_phs_entry *pstServiceFlowEntry,
+					    struct bcm_phs_rule *psPhsRule,
+					    B_UINT8 u8AssociatedPHSI)
 {
 	struct bcm_phs_classifier_entry *pstClassifierEntry = NULL;
 	UINT uiStatus = PHS_SUCCESS;
@@ -925,7 +1102,8 @@
 
 	psaClassifiertable = pstServiceFlowEntry->pstClassifierTable;
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "==>");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
+			"==>");
 
 	/* Check if the supplied Classifier already exists */
 	nClassifierIndex = GetClassifierEntry(
@@ -936,14 +1114,15 @@
 
 	if (nClassifierIndex == PHS_INVALID_TABLE_INDEX) {
 		/*
-		 * The Classifier doesn't exist. So its a new classifier being added.
+		 * The Classifier doesn't exist. So its a new classifier being
+		 * added.
 		 * Add new entry to associate PHS Rule to the Classifier
 		 */
 
 		uiStatus = CreateClassifierPHSRule(uiClsId, psaClassifiertable,
-						psPhsRule,
-						eActiveClassifierRuleContext,
-						u8AssociatedPHSI);
+						   psPhsRule,
+						   eActiveClassifierRuleContext,
+						   u8AssociatedPHSI);
 		return uiStatus;
 	}
 
@@ -957,25 +1136,28 @@
 			return ERR_PHS_INVALID_PHS_RULE;
 
 		/*
-		 * This rule already exists if any fields are changed for this PHS
-		 * rule update them.
+		 * This rule already exists if any fields are changed for this
+		 * PHS rule update them.
 		 */
 		/* If any part of PHSF is valid then we update PHSF */
 		if (psPhsRule->u8PHSFLength) {
 			/* update PHSF */
 			memcpy(pstClassifierEntry->pstPhsRule->u8PHSF,
-				psPhsRule->u8PHSF, MAX_PHS_LENGTHS);
+			       psPhsRule->u8PHSF,
+			       MAX_PHS_LENGTHS);
 		}
 
 		if (psPhsRule->u8PHSFLength) {
 			/* update PHSFLen */
-			pstClassifierEntry->pstPhsRule->u8PHSFLength = psPhsRule->u8PHSFLength;
+			pstClassifierEntry->pstPhsRule->u8PHSFLength =
+				psPhsRule->u8PHSFLength;
 		}
 
 		if (psPhsRule->u8PHSMLength) {
 			/* update PHSM */
 			memcpy(pstClassifierEntry->pstPhsRule->u8PHSM,
-				psPhsRule->u8PHSM, MAX_PHS_LENGTHS);
+			       psPhsRule->u8PHSM,
+			       MAX_PHS_LENGTHS);
 		}
 
 		if (psPhsRule->u8PHSMLength) {
@@ -986,25 +1168,29 @@
 
 		if (psPhsRule->u8PHSS) {
 			/* update PHSS */
-			pstClassifierEntry->pstPhsRule->u8PHSS = psPhsRule->u8PHSS;
+			pstClassifierEntry->pstPhsRule->u8PHSS =
+				psPhsRule->u8PHSS;
 		}
 
 		/* update PHSV */
 		pstClassifierEntry->pstPhsRule->u8PHSV = psPhsRule->u8PHSV;
 	} else {
 		/* A new rule is being set for this classifier. */
-		uiStatus = UpdateClassifierPHSRule(uiClsId, pstClassifierEntry,
-						psaClassifiertable, psPhsRule, u8AssociatedPHSI);
+		uiStatus = UpdateClassifierPHSRule(uiClsId,
+						   pstClassifierEntry,
+						   psaClassifiertable,
+						   psPhsRule,
+						   u8AssociatedPHSI);
 	}
 
 	return uiStatus;
 }
 
 static UINT CreateClassifierPHSRule(IN B_UINT16  uiClsId,
-				struct bcm_phs_classifier_table *psaClassifiertable,
-				struct bcm_phs_rule *psPhsRule,
-				enum bcm_phs_classifier_context eClsContext,
-				B_UINT8 u8AssociatedPHSI)
+				    struct bcm_phs_classifier_table *psaClassifiertable,
+				    struct bcm_phs_rule *psPhsRule,
+				    enum bcm_phs_classifier_context eClsContext,
+				    B_UINT8 u8AssociatedPHSI)
 {
 	UINT iClassifierIndex = 0;
 	bool bFreeEntryFound = false;
@@ -1012,7 +1198,8 @@
 	UINT nStatus = PHS_SUCCESS;
 	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "Inside CreateClassifierPHSRule");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
+			"Inside CreateClassifierPHSRule");
 
 	if (psaClassifiertable == NULL)
 		return ERR_INVALID_CLASSIFIERTABLE_FOR_SF;
@@ -1023,9 +1210,10 @@
 		 * old rules table replace it.
 		 */
 
-		iClassifierIndex =
-			GetClassifierEntry(psaClassifiertable, uiClsId,
-					eClsContext, &psClassifierRules);
+		iClassifierIndex = GetClassifierEntry(psaClassifiertable,
+						      uiClsId,
+						      eClsContext,
+						      &psClassifierRules);
 
 		if (iClassifierIndex != PHS_INVALID_TABLE_INDEX) {
 			/*
@@ -1057,12 +1245,15 @@
 		if (eClsContext == eActiveClassifierRuleContext)
 			return ERR_CLSASSIFIER_TABLE_FULL;
 		else {
-			/* Lets replace the oldest rule if we are looking in old Rule table */
+			/* Lets replace the oldest rule if we are looking in
+			 * old Rule table */
 			if (psaClassifiertable->uiOldestPhsRuleIndex >= MAX_PHSRULE_PER_SF)
 				psaClassifiertable->uiOldestPhsRuleIndex = 0;
 
-			iClassifierIndex = psaClassifiertable->uiOldestPhsRuleIndex;
-			psClassifierRules = &psaClassifiertable->stOldPhsRulesList[iClassifierIndex];
+			iClassifierIndex =
+				psaClassifiertable->uiOldestPhsRuleIndex;
+			psClassifierRules =
+				&psaClassifiertable->stOldPhsRulesList[iClassifierIndex];
 
 			(psaClassifiertable->uiOldestPhsRuleIndex)++;
 		}
@@ -1072,7 +1263,9 @@
 
 		if (psClassifierRules->pstPhsRule == NULL) {
 
-			psClassifierRules->pstPhsRule = kmalloc(sizeof(struct bcm_phs_rule), GFP_KERNEL);
+			psClassifierRules->pstPhsRule =
+				kmalloc(sizeof(struct bcm_phs_rule),
+					GFP_KERNEL);
 
 			if (NULL == psClassifierRules->pstPhsRule)
 				return ERR_PHSRULE_MEMALLOC_FAIL;
@@ -1081,22 +1274,27 @@
 		psClassifierRules->bUsed = TRUE;
 		psClassifierRules->uiClassifierRuleId = uiClsId;
 		psClassifierRules->u8PHSI = psPhsRule->u8PHSI;
-		psClassifierRules->bUnclassifiedPHSRule = psPhsRule->bUnclassifiedPHSRule;
+		psClassifierRules->bUnclassifiedPHSRule =
+			psPhsRule->bUnclassifiedPHSRule;
 
 		/* Update The PHS rule */
-		memcpy(psClassifierRules->pstPhsRule, psPhsRule, sizeof(struct bcm_phs_rule));
+		memcpy(psClassifierRules->pstPhsRule, psPhsRule,
+		       sizeof(struct bcm_phs_rule));
 	} else
-		nStatus = UpdateClassifierPHSRule(uiClsId, psClassifierRules,
-						psaClassifiertable, psPhsRule, u8AssociatedPHSI);
+		nStatus = UpdateClassifierPHSRule(uiClsId,
+						  psClassifierRules,
+						  psaClassifiertable,
+						  psPhsRule,
+						  u8AssociatedPHSI);
 
 	return nStatus;
 }
 
 static UINT UpdateClassifierPHSRule(IN B_UINT16  uiClsId,
-				IN struct bcm_phs_classifier_entry *pstClassifierEntry,
-				struct bcm_phs_classifier_table *psaClassifiertable,
-				struct bcm_phs_rule *psPhsRule,
-				B_UINT8 u8AssociatedPHSI)
+				    IN struct bcm_phs_classifier_entry *pstClassifierEntry,
+				    struct bcm_phs_classifier_table *psaClassifiertable,
+				    struct bcm_phs_rule *psPhsRule,
+				    B_UINT8 u8AssociatedPHSI)
 {
 	struct bcm_phs_rule *pstAddPhsRule = NULL;
 	UINT nPhsRuleIndex = 0;
@@ -1109,29 +1307,41 @@
 	bPHSRuleOrphaned = DerefPhsRule(uiClsId, psaClassifiertable,
 					pstClassifierEntry->pstPhsRule);
 
-	/* Step 2 Search if there is a PHS Rule with u8AssociatedPHSI in Classifier table for this SF */
+	/* Step 2 Search if there is a PHS Rule with u8AssociatedPHSI in
+	 * Classifier table for this SF */
 	nPhsRuleIndex = GetPhsRuleEntry(psaClassifiertable, u8AssociatedPHSI,
-					eActiveClassifierRuleContext, &pstAddPhsRule);
+					eActiveClassifierRuleContext,
+					&pstAddPhsRule);
 	if (PHS_INVALID_TABLE_INDEX == nPhsRuleIndex) {
 
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAdding New PHSRuleEntry For Classifier");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
+				DBG_LVL_ALL,
+				"\nAdding New PHSRuleEntry For Classifier");
 
 		if (psPhsRule->u8PHSI == 0) {
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nError PHSI is Zero\n");
+			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
+					DBG_LVL_ALL, "\nError PHSI is Zero\n");
 			return ERR_PHS_INVALID_PHS_RULE;
 		}
 
-		/* Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId */
+		/* Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for
+		 * uiClsId */
 		if (false == bPHSRuleOrphaned) {
 
-			pstClassifierEntry->pstPhsRule = kmalloc(sizeof(struct bcm_phs_rule), GFP_KERNEL);
+			pstClassifierEntry->pstPhsRule =
+				kmalloc(sizeof(struct bcm_phs_rule),
+					GFP_KERNEL);
 			if (NULL == pstClassifierEntry->pstPhsRule)
 				return ERR_PHSRULE_MEMALLOC_FAIL;
 		}
-		memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(struct bcm_phs_rule));
+		memcpy(pstClassifierEntry->pstPhsRule, psPhsRule,
+		       sizeof(struct bcm_phs_rule));
 	} else {
-		/* Step 2.b PHS Rule  Exists Tie uiClsId with the existing PHS Rule */
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nTying Classifier to Existing PHS Rule");
+		/* Step 2.b PHS Rule  Exists Tie uiClsId with the existing
+		 * PHS Rule */
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
+				DBG_LVL_ALL,
+				"\nTying Classifier to Existing PHS Rule");
 		if (bPHSRuleOrphaned) {
 			kfree(pstClassifierEntry->pstPhsRule);
 			pstClassifierEntry->pstPhsRule = NULL;
@@ -1143,12 +1353,15 @@
 	pstClassifierEntry->u8PHSI = pstClassifierEntry->pstPhsRule->u8PHSI;
 	pstClassifierEntry->uiClassifierRuleId = uiClsId;
 	pstClassifierEntry->pstPhsRule->u8RefCnt++;
-	pstClassifierEntry->bUnclassifiedPHSRule = pstClassifierEntry->pstPhsRule->bUnclassifiedPHSRule;
+	pstClassifierEntry->bUnclassifiedPHSRule =
+		pstClassifierEntry->pstPhsRule->bUnclassifiedPHSRule;
 
 	return PHS_SUCCESS;
 }
 
-static bool DerefPhsRule(IN B_UINT16  uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *pstPhsRule)
+static bool DerefPhsRule(IN B_UINT16  uiClsId,
+			 struct bcm_phs_classifier_table *psaClassifiertable,
+			 struct bcm_phs_rule *pstPhsRule)
 {
 	if (pstPhsRule == NULL)
 		return false;
@@ -1156,68 +1369,89 @@
 	if (pstPhsRule->u8RefCnt)
 		pstPhsRule->u8RefCnt--;
 
-	if (0 == pstPhsRule->u8RefCnt) {
-		/*
-		 * if(pstPhsRule->u8PHSI)
-		 * Store the currently active rule into the old rules list
-		 * CreateClassifierPHSRule(uiClsId,psaClassifiertable,pstPhsRule,eOldClassifierRuleContext,pstPhsRule->u8PHSI);
-		 */
-		return TRUE;
-	} else
-		return false;
+	return (0 == pstPhsRule->u8RefCnt);
+}
+
+static void dbg_print_st_cls_entry(struct bcm_mini_adapter *ad,
+				   struct bcm_phs_entry *st_serv_flow_entry,
+				   struct bcm_phs_classifier_entry *st_cls_entry)
+{
+	int k;
+
+	BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n VCID  : %#X", st_serv_flow_entry->uiVcid);
+	BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n ClassifierID  : %#X", st_cls_entry->uiClassifierRuleId);
+	BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSRuleID  : %#X", st_cls_entry->u8PHSI);
+	BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n****************PHS Rule********************\n");
+	BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSI  : %#X", st_cls_entry->pstPhsRule->u8PHSI);
+	BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSFLength : %#X ", st_cls_entry->pstPhsRule->u8PHSFLength);
+	BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSF : ");
+
+	for (k = 0 ; k < st_cls_entry->pstPhsRule->u8PHSFLength; k++)
+		BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X  ", st_cls_entry->pstPhsRule->u8PHSF[k]);
+	BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSMLength  : %#X", st_cls_entry->pstPhsRule->u8PHSMLength);
+	BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSM :");
+
+	for (k = 0; k < st_cls_entry->pstPhsRule->u8PHSMLength; k++)
+		BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X  ", st_cls_entry->pstPhsRule->u8PHSM[k]);
+	BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSS : %#X ", st_cls_entry->pstPhsRule->u8PHSS);
+	BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSV  : %#X", st_cls_entry->pstPhsRule->u8PHSV);
+	BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n********************************************\n");
+}
+
+static void phsrules_per_sf_dbg_print(struct bcm_mini_adapter *ad,
+				      struct bcm_phs_entry *st_serv_flow_entry)
+{
+	int j, l;
+	struct bcm_phs_classifier_entry st_cls_entry;
+
+	for (j = 0; j < MAX_PHSRULE_PER_SF; j++) {
+
+		for (l = 0; l < 2; l++) {
+
+			if (l == 0) {
+				st_cls_entry = st_serv_flow_entry->pstClassifierTable->stActivePhsRulesList[j];
+				if (st_cls_entry.bUsed)
+					BCM_DEBUG_PRINT(ad,
+							DBG_TYPE_OTHERS,
+							DUMP_INFO,
+							(DBG_LVL_ALL | DBG_NO_FUNC_PRINT),
+							"\n Active PHS Rule :\n");
+			} else {
+				st_cls_entry = st_serv_flow_entry->pstClassifierTable->stOldPhsRulesList[j];
+				if (st_cls_entry.bUsed)
+					BCM_DEBUG_PRINT(ad,
+							DBG_TYPE_OTHERS,
+							DUMP_INFO,
+							(DBG_LVL_ALL | DBG_NO_FUNC_PRINT),
+							"\n Old PHS Rule :\n");
+			}
+
+			if (st_cls_entry.bUsed) {
+				dbg_print_st_cls_entry(ad,
+						       st_serv_flow_entry,
+						       &st_cls_entry);
+			}
+		}
+	}
 }
 
 void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension)
 {
-	int i, j, k, l;
+	int i;
 	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n Dumping PHS Rules :\n");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,
+			"\n Dumping PHS Rules :\n");
 
 	for (i = 0; i < MAX_SERVICEFLOWS; i++) {
 
 		struct bcm_phs_entry stServFlowEntry =
 			pDeviceExtension->pstServiceFlowPhsRulesTable->stSFList[i];
-		if (stServFlowEntry.bUsed) {
 
-			for (j = 0; j < MAX_PHSRULE_PER_SF; j++) {
+		if (!stServFlowEntry.bUsed)
+			continue;
 
-				for (l = 0; l < 2; l++) {
-					struct bcm_phs_classifier_entry stClsEntry;
-
-					if (l == 0) {
-						stClsEntry = stServFlowEntry.pstClassifierTable->stActivePhsRulesList[j];
-						if (stClsEntry.bUsed)
-							BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n Active PHS Rule :\n");
-					} else {
-						stClsEntry = stServFlowEntry.pstClassifierTable->stOldPhsRulesList[j];
-						if (stClsEntry.bUsed)
-							BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n Old PHS Rule :\n");
-					}
-
-					if (stClsEntry.bUsed) {
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n VCID  : %#X", stServFlowEntry.uiVcid);
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n ClassifierID  : %#X", stClsEntry.uiClassifierRuleId);
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSRuleID  : %#X", stClsEntry.u8PHSI);
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n****************PHS Rule********************\n");
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSI  : %#X", stClsEntry.pstPhsRule->u8PHSI);
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSFLength : %#X ", stClsEntry.pstPhsRule->u8PHSFLength);
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSF : ");
-
-						for (k = 0 ; k < stClsEntry.pstPhsRule->u8PHSFLength; k++)
-							BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X  ", stClsEntry.pstPhsRule->u8PHSF[k]);
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSMLength  : %#X", stClsEntry.pstPhsRule->u8PHSMLength);
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSM :");
-
-						for (k = 0; k < stClsEntry.pstPhsRule->u8PHSMLength; k++)
-							BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X  ", stClsEntry.pstPhsRule->u8PHSM[k]);
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSS : %#X ", stClsEntry.pstPhsRule->u8PHSS);
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSV  : %#X", stClsEntry.pstPhsRule->u8PHSV);
-						BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n********************************************\n");
-					}
-				}
-			}
-		}
+		phsrules_per_sf_dbg_print(Adapter, &stServFlowEntry);
 	}
 }
 
@@ -1228,19 +1462,22 @@
  *
  * Arguments:
  *	in_buf			- ptr to incoming packet buffer.
- *	out_buf			- ptr to output buffer where the suppressed header is copied.
- *	decomp_phs_rules - ptr to PHS rule.
- *	header_size		- ptr to field which holds the phss or phsf_length.
+ *	out_buf			- ptr to output buffer where the suppressed
+ *				  header is copied.
+ *	decomp_phs_rules	- ptr to PHS rule.
+ *	header_size		- ptr to field which holds the phss or
+ *				  phsf_length.
  *
  * Returns:
- *	size -The number of bytes of dynamic fields present with in the incoming packet
- *			header.
- *	0	-If PHS rule is NULL.If PHSI is 0 indicateing packet as uncompressed.
+ *	size	- The number of bytes of dynamic fields present with in the
+ *		  incoming packet header.
+ *	0	- If PHS rule is NULL.If PHSI is 0 indicateing packet as
+ *		  uncompressed.
  */
 static int phs_decompress(unsigned char *in_buf,
-		unsigned char *out_buf,
-		struct bcm_phs_rule *decomp_phs_rules,
-		UINT *header_size)
+			  unsigned char *out_buf,
+			  struct bcm_phs_rule *decomp_phs_rules,
+			  UINT *header_size)
 {
 	int phss, size = 0;
 	struct bcm_phs_rule *tmp_memb;
@@ -1251,7 +1488,8 @@
 
 	in_buf++;
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "====>\n");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL,
+			"====>\n");
 	*header_size = 0;
 
 	if (decomp_phs_rules == NULL)
@@ -1259,7 +1497,8 @@
 
 	tmp_memb = decomp_phs_rules;
 	/*
-	 * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nDECOMP:In phs_decompress PHSI 1  %d",phsi));
+	 * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,
+	 * "\nDECOMP:In phs_decompress PHSI 1  %d",phsi));
 	 * header_size = tmp_memb->u8PHSFLength;
 	 */
 	phss = tmp_memb->u8PHSS;
@@ -1270,7 +1509,8 @@
 		phss = MAX_PHS_LENGTHS;
 
 	/*
-	 * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,"\nDECOMP:
+	 * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL,
+	 * "\nDECOMP:
 	 * In phs_decompress PHSI  %d phss %d index %d",phsi,phss,index));
 	 */
 	while ((phss > 0) && (size < in_buf_len)) {
@@ -1278,11 +1518,15 @@
 
 		if (bit == SUPPRESS) {
 			*out_buf = *phsf;
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "\nDECOMP:In phss  %d phsf %d output %d",
+			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
+					DBG_LVL_ALL,
+					"\nDECOMP:In phss  %d phsf %d output %d",
 					phss, *phsf, *out_buf);
 		} else {
 			*out_buf = *in_buf;
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "\nDECOMP:In phss  %d input %d output %d",
+			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
+					DBG_LVL_ALL,
+					"\nDECOMP:In phss  %d input %d output %d",
 					phss, *in_buf, *out_buf);
 			in_buf++;
 			size++;
@@ -1305,22 +1549,25 @@
 /*
  * Procedure:   phs_compress
  *
- * Description: This routine suppresses the static fields within the packet.Before
- * that it will verify the fields to be suppressed with the corresponding fields in the
- * phsf. For verification it checks the phsv field of PHS rule. If set and verification
- * succeeds it suppresses the field.If any one static field is found different none of
- * the static fields are suppressed then the packet is sent as uncompressed packet with
- * phsi=0.
+ * Description: This routine suppresses the static fields within the packet.
+ * Before that it will verify the fields to be suppressed with the corresponding
+ * fields in the phsf. For verification it checks the phsv field of PHS rule.
+ * If set and verification succeeds it suppresses the field.If any one static
+ * field is found different none of the static fields are suppressed then the
+ * packet is sent as uncompressed packet with phsi=0.
  *
  * Arguments:
  *	phs_rule - ptr to PHS rule.
  *	in_buf		- ptr to incoming packet buffer.
- *	out_buf		- ptr to output buffer where the suppressed header is copied.
+ *	out_buf		- ptr to output buffer where the suppressed header is
+ *			  copied.
  *	header_size	- ptr to field which holds the phss.
  *
  * Returns:
- *	size-The number of bytes copied into the output buffer i.e dynamic fields
- *	0	-If PHS rule is NULL.If PHSV field is not set.If the verification fails.
+ *	size	- The number of bytes copied into the output buffer i.e
+ *		  dynamic fields
+ *	0	- If PHS rule is NULL.If PHSV field is not set. If the
+ *		  verification fails.
  */
 static int phs_compress(struct bcm_phs_rule *phs_rule,
 			unsigned char *in_buf,
@@ -1333,7 +1580,8 @@
 	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
 
 	if (phs_rule == NULL) {
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nphs_compress(): phs_rule null!");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
+				"\nphs_compress(): phs_rule null!");
 		*out_buf = ZERO_PHSI;
 		return STATUS_PHS_NOCOMPRESSION;
 	}
@@ -1351,10 +1599,13 @@
 
 	if (suppress == STATUS_PHS_COMPRESSED) {
 		*old_addr = (unsigned char)phs_rule->u8PHSI;
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nCOMP:In phs_compress phsi %d", phs_rule->u8PHSI);
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
+				"\nCOMP:In phs_compress phsi %d",
+				phs_rule->u8PHSI);
 	} else {
 		*old_addr = ZERO_PHSI;
-		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nCOMP:In phs_compress PHSV Verification failed");
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
+				"\nCOMP:In phs_compress PHSV Verification failed");
 	}
 
 	return suppress;
@@ -1371,13 +1622,14 @@
  * rules_set	- ptr to classifier_rules.
  * in_buffer	- ptr to incoming packet buffer.
  * out_buffer	- ptr to output buffer where the suppressed header is copied.
- * phsf			- ptr to phsf.
- * phsm			- ptr to phsm.
- * phss			- variable holding phss.
+ * phsf		- ptr to phsf.
+ * phsm		- ptr to phsm.
+ * phss		- variable holding phss.
  *
  * Returns:
- *	size-The number of bytes copied into the output buffer i.e dynamic fields.
- *	0	-Packet has failed the verification.
+ *	size    - The number of bytes copied into the output buffer i.e dynamic
+ *		  fields.
+ *	0	- Packet has failed the verification.
  */
 static int verify_suppress_phsf(unsigned char *in_buffer,
 				unsigned char *out_buffer,
@@ -1391,7 +1643,8 @@
 	int bit, i = 0;
 	struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
 
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nCOMP:In verify_phsf PHSM - 0x%X", *phsm);
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
+			"\nCOMP:In verify_phsf PHSM - 0x%X", *phsm);
 
 	if (phss > (*new_header_size))
 		phss = *new_header_size;
@@ -1443,7 +1696,8 @@
 			phsm++;
 		}
 	}
-	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nCOMP:In verify_phsf success");
+	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
+			"\nCOMP:In verify_phsf success");
 	*new_header_size = size;
 	return STATUS_PHS_COMPRESSED;
 }
diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c
index c5213b3..0eb78a8 100644
--- a/drivers/staging/bcm/Qos.c
+++ b/drivers/staging/bcm/Qos.c
@@ -322,8 +322,8 @@
 	spin_lock_bh(&Adapter->PackInfo[iIndex].SFQueueLock);
 
 	while (1) {
-//	while((UINT)Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost >
-//		SF_MAX_ALLOWED_PACKETS_TO_BACKUP) {
+	/* while((UINT)Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost > */
+	/* 	SF_MAX_ALLOWED_PACKETS_TO_BACKUP) { */
 
 		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "uiCurrentBytesOnHost:%x uiMaxBucketSize :%x",
 		Adapter->PackInfo[iIndex].uiCurrentBytesOnHost,
@@ -379,7 +379,7 @@
 
 	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>");
 
-//	down(&Adapter->data_packet_queue_lock);
+	/* down(&Adapter->data_packet_queue_lock); */
 	for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++) {
 		struct net_device_stats *netstats = &Adapter->dev->stats;
 
@@ -413,7 +413,7 @@
 		}
 		spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
 	}
-//	up(&Adapter->data_packet_queue_lock);
+	/* up(&Adapter->data_packet_queue_lock); */
 	BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "<=====");
 }
 
@@ -438,26 +438,26 @@
 	EThCSGetPktInfo(Adapter, pvEThPayload, &stEthCsPktInfo);
 
 	switch (stEthCsPktInfo.eNwpktEthFrameType) {
-		case eEth802LLCFrame:
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLCFrame\n");
-			pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_frame);
-			break;
-		case eEth802LLCSNAPFrame:
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLC SNAP Frame\n");
-			pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_snap_frame);
-			break;
-		case eEth802QVLANFrame:
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802.1Q VLANFrame\n");
-			pIpHeader = pvEThPayload + sizeof(struct bcm_eth_q_frame);
-			break;
-		case eEthOtherFrame:
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : ETH Other Frame\n");
-			pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame);
-			break;
-		default:
-			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Unrecognized ETH Frame\n");
-			pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame);
-			break;
+	case eEth802LLCFrame:
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLCFrame\n");
+		pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_frame);
+		break;
+	case eEth802LLCSNAPFrame:
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLC SNAP Frame\n");
+		pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_snap_frame);
+		break;
+	case eEth802QVLANFrame:
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802.1Q VLANFrame\n");
+		pIpHeader = pvEThPayload + sizeof(struct bcm_eth_q_frame);
+		break;
+	case eEthOtherFrame:
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : ETH Other Frame\n");
+		pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame);
+		break;
+	default:
+		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Unrecognized ETH Frame\n");
+		pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame);
+		break;
 	}
 
 	if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) {
@@ -765,7 +765,7 @@
 			/* 802.1Q VLAN Header */
 			pstEthCsPktInfo->eNwpktEthFrameType = eEth802QVLANFrame;
 			u16Etype = ((struct bcm_eth_q_frame *)pvEthPayload)->EthType;
-			//((ETH_CS_802_Q_FRAME*)pvEthPayload)->UserPriority
+			/* ((ETH_CS_802_Q_FRAME*)pvEthPayload)->UserPriority */
 		} else {
 			pstEthCsPktInfo->eNwpktEthFrameType = eEthOtherFrame;
 			u16Etype = ntohs(u16Etype);
diff --git a/drivers/staging/bcm/Transmit.c b/drivers/staging/bcm/Transmit.c
index 05fae92..622a482 100644
--- a/drivers/staging/bcm/Transmit.c
+++ b/drivers/staging/bcm/Transmit.c
@@ -89,7 +89,8 @@
  * to the target via the host h/w interface.
  * @return  zero(success) or -ve value(failure)
  */
-int SetupNextSend(struct bcm_mini_adapter *Adapter,  struct sk_buff *Packet, USHORT Vcid)
+int SetupNextSend(struct bcm_mini_adapter *Adapter,
+		struct sk_buff *Packet, USHORT Vcid)
 {
 	int	status = 0;
 	bool	bHeaderSupressionEnabled = false;
@@ -205,7 +206,9 @@
 	int status = 0;
 
 	while (!kthread_should_stop()) {
-		/* FIXME - the timeout looks like workaround for racey usage of TxPktAvail */
+		/* FIXME - the timeout looks like workaround
+		 *  for racey usage of TxPktAvail
+		*/
 		if (Adapter->LinkUpStatus)
 			wait_event_timeout(Adapter->tx_packet_wait_queue,
 					   tx_pending(Adapter),
@@ -229,7 +232,8 @@
 		if (Adapter->bEndPointHalted == TRUE) {
 			Bcm_clear_halt_of_endpoints(Adapter);
 			Adapter->bEndPointHalted = false;
-			StartInterruptUrb((struct bcm_interface_adapter *)(Adapter->pvInterfaceAdapter));
+			StartInterruptUrb((struct bcm_interface_adapter *)
+					(Adapter->pvInterfaceAdapter));
 		}
 
 		if (Adapter->LinkUpStatus && !Adapter->IdleMode) {
diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c
index 8ce4d41..ce09473 100644
--- a/drivers/staging/bcm/nvm.c
+++ b/drivers/staging/bcm/nvm.c
@@ -2,35 +2,52 @@
 
 #define DWORD unsigned int
 
-static int BcmDoChipSelect(struct bcm_mini_adapter *Adapter, unsigned int offset);
+static int BcmDoChipSelect(struct bcm_mini_adapter *Adapter,
+			   unsigned int offset);
 static int BcmGetActiveDSD(struct bcm_mini_adapter *Adapter);
 static int BcmGetActiveISO(struct bcm_mini_adapter *Adapter);
 static unsigned int BcmGetEEPROMSize(struct bcm_mini_adapter *Adapter);
 static int BcmGetFlashCSInfo(struct bcm_mini_adapter *Adapter);
-static unsigned int BcmGetFlashSectorSize(struct bcm_mini_adapter *Adapter, unsigned int FlashSectorSizeSig, unsigned int FlashSectorSize);
+static unsigned int BcmGetFlashSectorSize(struct bcm_mini_adapter *Adapter,
+					  unsigned int FlashSectorSizeSig,
+					  unsigned int FlashSectorSize);
 
 static VOID BcmValidateNvmType(struct bcm_mini_adapter *Adapter);
 static int BcmGetNvmSize(struct bcm_mini_adapter *Adapter);
 static unsigned int BcmGetFlashSize(struct bcm_mini_adapter *Adapter);
 static enum bcm_nvm_type BcmGetNvmType(struct bcm_mini_adapter *Adapter);
 
-static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal);
+static int BcmGetSectionValEndOffset(struct bcm_mini_adapter *Adapter,
+				     enum bcm_flash2x_section_val eFlash2xSectionVal);
 
-static B_UINT8 IsOffsetWritable(struct bcm_mini_adapter *Adapter, unsigned int uiOffset);
-static int IsSectionWritable(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val Section);
-static int IsSectionExistInVendorInfo(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val section);
+static B_UINT8 IsOffsetWritable(struct bcm_mini_adapter *Adapter,
+				unsigned int uiOffset);
+static int IsSectionWritable(struct bcm_mini_adapter *Adapter,
+			     enum bcm_flash2x_section_val Section);
+static int IsSectionExistInVendorInfo(struct bcm_mini_adapter *Adapter,
+				      enum bcm_flash2x_section_val section);
 
-static int ReadDSDPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd);
-static int ReadDSDSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val dsd);
-static int ReadISOPriority(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso);
-static int ReadISOSignature(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val iso);
+static int ReadDSDPriority(struct bcm_mini_adapter *Adapter,
+			   enum bcm_flash2x_section_val dsd);
+static int ReadDSDSignature(struct bcm_mini_adapter *Adapter,
+			    enum bcm_flash2x_section_val dsd);
+static int ReadISOPriority(struct bcm_mini_adapter *Adapter,
+			   enum bcm_flash2x_section_val iso);
+static int ReadISOSignature(struct bcm_mini_adapter *Adapter,
+			    enum bcm_flash2x_section_val iso);
 
-static int CorruptDSDSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal);
-static int CorruptISOSig(struct bcm_mini_adapter *Adapter, enum bcm_flash2x_section_val eFlash2xSectionVal);
-static int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter, PUCHAR pBuff, unsigned int uiSectAlignAddr);
-static int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter, PUINT pBuff,
-					enum bcm_flash2x_section_val eFlash2xSectionVal,
-					unsigned int uiOffset, unsigned int uiNumBytes);
+static int CorruptDSDSig(struct bcm_mini_adapter *Adapter,
+			 enum bcm_flash2x_section_val eFlash2xSectionVal);
+static int CorruptISOSig(struct bcm_mini_adapter *Adapter,
+			 enum bcm_flash2x_section_val eFlash2xSectionVal);
+static int SaveHeaderIfPresent(struct bcm_mini_adapter *Adapter,
+			       PUCHAR pBuff,
+			       unsigned int uiSectAlignAddr);
+static int WriteToFlashWithoutSectorErase(struct bcm_mini_adapter *Adapter,
+					  PUINT pBuff,
+					  enum bcm_flash2x_section_val eFlash2xSectionVal,
+					  unsigned int uiOffset,
+					  unsigned int uiNumBytes);
 static enum bcm_flash2x_section_val getHighestPriDSD(struct bcm_mini_adapter *Adapter);
 static enum bcm_flash2x_section_val getHighestPriISO(struct bcm_mini_adapter *Adapter);
 
@@ -1016,6 +1033,45 @@
 	return ulStatus;
 }
 
+static int bulk_read_complete_sector(struct bcm_mini_adapter *ad,
+				     UCHAR read_bk[],
+				     PCHAR tmpbuff,
+				     unsigned int offset,
+				     unsigned int partoff)
+{
+	unsigned int i;
+	int j;
+	int bulk_read_stat;
+	FP_FLASH_WRITE_STATUS writef =
+		ad->fpFlashWriteWithStatusCheck;
+
+	for (i = 0; i < ad->uiSectorSize; i += MAX_RW_SIZE) {
+		bulk_read_stat = BeceemFlashBulkRead(ad,
+						     (PUINT)read_bk,
+						     offset + i,
+						     MAX_RW_SIZE);
+
+		if (bulk_read_stat != STATUS_SUCCESS)
+			continue;
+
+		if (ad->ulFlashWriteSize == 1) {
+			for (j = 0; j < 16; j++) {
+				if ((read_bk[j] != tmpbuff[i + j]) &&
+				    (STATUS_SUCCESS != (*writef)(ad, partoff + i + j, &tmpbuff[i + j]))) {
+					return STATUS_FAILURE;
+				}
+			}
+		} else {
+			if ((memcmp(read_bk, &tmpbuff[i], MAX_RW_SIZE)) &&
+			    (STATUS_SUCCESS != (*writef)(ad, partoff + i, &tmpbuff[i]))) {
+				return STATUS_FAILURE;
+			}
+		}
+	}
+
+	return STATUS_SUCCESS;
+}
+
 /*
  * Procedure:	BeceemFlashBulkWrite
  *
@@ -1152,29 +1208,16 @@
 		/* do_gettimeofday(&tw);
 		 * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken in Write  to Flash :%ld ms\n", (tw.tv_sec *1000 + tw.tv_usec/1000) - (te.tv_sec *1000 + te.tv_usec/1000));
 		 */
-		for (uiIndex = 0; uiIndex < Adapter->uiSectorSize; uiIndex += MAX_RW_SIZE) {
-			if (STATUS_SUCCESS == BeceemFlashBulkRead(Adapter, (PUINT)ucReadBk, uiOffsetFromSectStart + uiIndex, MAX_RW_SIZE)) {
-				if (Adapter->ulFlashWriteSize == 1) {
-					unsigned int uiReadIndex = 0;
 
-					for (uiReadIndex = 0; uiReadIndex < 16; uiReadIndex++) {
-						if (ucReadBk[uiReadIndex] != pTempBuff[uiIndex + uiReadIndex]) {
-							if (STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter, uiPartOffset + uiIndex + uiReadIndex, &pTempBuff[uiIndex+uiReadIndex])) {
-								Status = STATUS_FAILURE;
-								goto BeceemFlashBulkWrite_EXIT;
-							}
-						}
-					}
-				} else {
-					if (memcmp(ucReadBk, &pTempBuff[uiIndex], MAX_RW_SIZE)) {
-						if (STATUS_SUCCESS != (*Adapter->fpFlashWriteWithStatusCheck)(Adapter, uiPartOffset + uiIndex, &pTempBuff[uiIndex])) {
-							Status = STATUS_FAILURE;
-							goto BeceemFlashBulkWrite_EXIT;
-						}
-					}
-				}
-			}
+		if (STATUS_FAILURE == bulk_read_complete_sector(Adapter,
+								ucReadBk,
+								pTempBuff,
+								uiOffsetFromSectStart,
+								uiPartOffset)) {
+			Status = STATUS_FAILURE;
+			goto BeceemFlashBulkWrite_EXIT;
 		}
+
 		/* do_gettimeofday(&twv);
 		 * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Total time taken in Write  to Flash verification :%ld ms\n", (twv.tv_sec *1000 + twv.tv_usec/1000) - (tw.tv_sec *1000 + tw.tv_usec/1000));
 		 */
@@ -3492,11 +3535,10 @@
 		return STATUS_FAILURE;
 	}
 
-	Status = BcmFlash2xBulkRead(Adapter,
-				&ISOLength,
-				sCopySectStrut.SrcSection,
-				0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageSize),
-				4);
+	Status = BcmFlash2xBulkRead(Adapter, &ISOLength,
+				    sCopySectStrut.SrcSection,
+				    0 + FIELD_OFFSET_IN_HEADER(struct bcm_iso_header *, ISOImageSize),
+				    4);
 	if (Status) {
 		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "Read failed while copying ISO\n");
 		return Status;
diff --git a/drivers/staging/ced1401/Kconfig b/drivers/staging/ced1401/Kconfig
deleted file mode 100644
index ae36d1b..0000000
--- a/drivers/staging/ced1401/Kconfig
+++ /dev/null
@@ -1,6 +0,0 @@
-config CED1401
-	tristate "Cambridge Electronic Design 1401 USB support"
-	depends on USB
-	help
-	  This driver supports the Cambridge Electronic Design 1401 USB device
-	  (whatever that is.)
diff --git a/drivers/staging/ced1401/Makefile b/drivers/staging/ced1401/Makefile
deleted file mode 100644
index f0c114b..0000000
--- a/drivers/staging/ced1401/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-
-obj-$(CONFIG_CED1401)	:= cedusb.o
-cedusb-objs	:= usb1401.o ced_ioc.o
diff --git a/drivers/staging/ced1401/TODO b/drivers/staging/ced1401/TODO
deleted file mode 100644
index 9fd5630..0000000
--- a/drivers/staging/ced1401/TODO
+++ /dev/null
@@ -1,10 +0,0 @@
-TODO:
-	- coding syle fixes
-	- build warning fixups
-	- ioctl auditing
-	- usb api auditing
-	- proper USB minor number (it's stomping on an existing one right now.)
-
-Please send patches to Greg Kroah-Hartman <gregkh@linuxfoundation.org> and Cc:
-Alois Schlögl <alois.schloegl@ist.ac.at>
-
diff --git a/drivers/staging/ced1401/ced_ioc.c b/drivers/staging/ced1401/ced_ioc.c
deleted file mode 100644
index 8cb6ea9..0000000
--- a/drivers/staging/ced1401/ced_ioc.c
+++ /dev/null
@@ -1,1613 +0,0 @@
-/* ced_ioc.c
- ioctl part of the 1401 usb device driver for linux.
- Copyright (C) 2010 Cambridge Electronic Design Ltd
- Author Greg P Smith (greg@ced.co.uk)
-
- 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.
-
- 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*/
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/kref.h>
-#include <linux/uaccess.h>
-#include <linux/usb.h>
-#include <linux/mutex.h>
-#include <linux/page-flags.h>
-#include <linux/pagemap.h>
-#include <linux/jiffies.h>
-
-#include "usb1401.h"
-
-/****************************************************************************
-** ced_flush_out_buff
-**
-** Empties the Output buffer and sets int lines. Used from user level only
-****************************************************************************/
-static void ced_flush_out_buff(struct ced_data *ced)
-{
-	dev_dbg(&ced->interface->dev, "%s: current_state=%d\n",
-		__func__, ced->current_state);
-
-	/* Do nothing if hardware in trouble */
-	if (ced->current_state == U14ERR_TIME)
-		return;
-	/* Kill off any pending I/O */
-	/* CharSend_Cancel(ced);  */
-	spin_lock_irq(&ced->char_out_lock);
-	ced->num_output = 0;
-	ced->out_buff_get = 0;
-	ced->out_buff_put = 0;
-	spin_unlock_irq(&ced->char_out_lock);
-}
-
-/****************************************************************************
-**
-** ced_flush_in_buff
-**
-** Empties the input buffer and sets int lines
-****************************************************************************/
-static void ced_flush_in_buff(struct ced_data *ced)
-{
-	dev_dbg(&ced->interface->dev, "%s: current_state=%d\n",
-		__func__, ced->current_state);
-
-	if (ced->current_state == U14ERR_TIME)
-		return;	/* Do nothing if hardware in trouble */
-
-	/* Kill off any pending I/O */
-	/*     CharRead_Cancel(pDevObject);  */
-	spin_lock_irq(&ced->char_in_lock);
-	ced->num_input = 0;
-	ced->in_buff_get = 0;
-	ced->in_buff_put = 0;
-	spin_unlock_irq(&ced->char_in_lock);
-}
-
-/****************************************************************************
-** ced_put_chars
-**
-** Utility routine to copy chars into the output buffer and fire them off.
-** called from user mode, holds char_out_lock.
-****************************************************************************/
-static int ced_put_chars(struct ced_data *ced, const char *ch,
-		    unsigned int count)
-{
-	int ret;
-
-	spin_lock_irq(&ced->char_out_lock);	/*  get the output spin lock */
-	if ((OUTBUF_SZ - ced->num_output) >= count) {
-		unsigned int u;
-
-		for (u = 0; u < count; u++) {
-			ced->output_buffer[ced->out_buff_put++] = ch[u];
-			if (ced->out_buff_put >= OUTBUF_SZ)
-				ced->out_buff_put = 0;
-		}
-		ced->num_output += count;
-		spin_unlock_irq(&ced->char_out_lock);
-
-		/* ...give a chance to transmit data */
-		ret = ced_send_chars(ced);
-	} else {
-		ret = U14ERR_NOOUT;	/*  no room at the out (ha-ha) */
-		spin_unlock_irq(&ced->char_out_lock);
-	}
-	return ret;
-}
-
-/*****************************************************************************
-** Add the data in "data" local pointer of length n to the output buffer, and
-** trigger an output transfer if this is appropriate. User mode.
-** Holds the io_mutex
-*****************************************************************************/
-int ced_send_string(struct ced_data *ced, const char __user *data,
-	       unsigned int n)
-{
-	int ret = U14ERR_NOERROR;	/* assume all will be well */
-	char buffer[OUTBUF_SZ + 1];	/* space in our address space */
-					/* for characters             */
-	if (n > OUTBUF_SZ)	/*  check space in local buffer... */
-		return U14ERR_NOOUT;	/*  ...too many characters */
-	if (copy_from_user(buffer, data, n))
-		return -EFAULT;
-	buffer[n] = 0;		/*  terminate for debug purposes */
-
-	mutex_lock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-	if (n > 0) {		/*  do nothing if nowt to do! */
-		dev_dbg(&ced->interface->dev, "%s: n=%d>%s<\n",
-			__func__, n, buffer);
-		ret = ced_put_chars(ced, buffer, n);
-	}
-
-	ced_allowi(ced);		/*  make sure we have input int */
-	mutex_unlock(&ced->io_mutex);
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_send_char
-**
-** Sends a single character to the 1401. User mode, holds io_mutex.
-****************************************************************************/
-int ced_send_char(struct ced_data *ced, char c)
-{
-	int ret;
-
-	mutex_lock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-	ret = ced_put_chars(ced, &c, 1);
-	dev_dbg(&ced->interface->dev, "ced_send_char >%c< (0x%02x)\n", c, c);
-	ced_allowi(ced);	/*  Make sure char reads are running */
-	mutex_unlock(&ced->io_mutex);
-	return ret;
-}
-
-/***************************************************************************
-**
-** ced_get_state
-**
-**  Retrieves state information from the 1401, adjusts the 1401 state held
-**  in the device extension to indicate the current 1401 type.
-**
-**  *state is updated with information about the 1401 state as returned by the
-**         1401. The low byte is a code for what 1401 is doing:
-**
-**  0       normal 1401 operation
-**  1       sending chars to host
-**  2       sending block data to host
-**  3       reading block data from host
-**  4       sending an escape sequence to the host
-**  0x80    1401 is executing self-test, in which case the upper word
-**          is the last error code seen (or zero for no new error).
-**
-** *error is updated with error information if a self-test error code
-**          is returned in the upper word of state.
-**
-**  both state and error are set to -1 if there are comms problems, and
-**  to zero if there is a simple failure.
-**
-** return error code (U14ERR_NOERROR for OK)
-*/
-int ced_get_state(struct ced_data *ced, __u32 *state, __u32 *error)
-{
-	int got;
-
-	dev_dbg(&ced->interface->dev, "%s: entry\n", __func__);
-
-	*state = 0xFFFFFFFF;	/*  Start off with invalid state */
-	got = usb_control_msg(ced->udev, usb_rcvctrlpipe(ced->udev, 0),
-			       GET_STATUS, (D_TO_H | VENDOR | DEVREQ), 0, 0,
-			       ced->stat_buf, sizeof(ced->stat_buf), HZ);
-	if (got != sizeof(ced->stat_buf)) {
-		dev_err(&ced->interface->dev,
-			"%s: FAILED, return code %d\n", __func__, got);
-		/* Indicate that things are very wrong indeed */
-		ced->current_state = U14ERR_TIME;
-		*state = 0;	/*  Force status values to a known state */
-		*error = 0;
-	} else {
-		int device;
-
-		dev_dbg(&ced->interface->dev,
-			"%s: Success, state: 0x%x, 0x%x\n",
-			__func__, ced->stat_buf[0], ced->stat_buf[1]);
-
-		/* Return the state values to the calling code */
-		*state = ced->stat_buf[0];
-
-		*error = ced->stat_buf[1];
-
-		/* 1401 type code value */
-		device = ced->udev->descriptor.bcdDevice >> 8;
-		switch (device) {	/*  so we can clean up current state */
-		case 0:
-			ced->current_state = U14ERR_U1401;
-			break;
-
-		default: /* allow lots of device codes for future 1401s */
-			if ((device >= 1) && (device <= 23))
-				ced->current_state = (short)(device + 6);
-			else
-				ced->current_state = U14ERR_ILL;
-			break;
-		}
-	}
-
-	return ced->current_state >= 0 ? U14ERR_NOERROR : ced->current_state;
-}
-
-/****************************************************************************
-** ced_read_write_cancel
-**
-** Kills off staged read\write request from the USB if one is pending.
-****************************************************************************/
-int ced_read_write_cancel(struct ced_data *ced)
-{
-	dev_dbg(&ced->interface->dev, "%s: entry %d\n",
-		__func__, ced->staged_urb_pending);
-#ifdef NOT_WRITTEN_YET
-	int ntStatus = STATUS_SUCCESS;
-	bool bResult = false;
-	unsigned int i;
-
-	/* We can fill this in when we know how we will implement the staged */
-	/* transfer stuff						     */
-	spin_lock_irq(&ced->staged_lock);
-
-	if (ced->staged_urb_pending) {/* anything to be cancelled? */
-				      /* May need more... */
-		dev_info(&ced->interface - dev,
-			 "ced_read_write_cancel about to cancel Urb\n");
-		/* Clear the staging done flag */
-		/* KeClearEvent(&ced->StagingDoneEvent); */
-		USB_ASSERT(ced->pStagedIrp != NULL);
-
-		/* Release the spinlock first otherwise the completion  */
-		/* routine may hang on the spinlock while this function */
-		/* hands waiting for the event.				*/
-		spin_unlock_irq(&ced->staged_lock);
-
-		/* Actually do the cancel */
-		bResult = IoCancelIrp(ced->pStagedIrp);
-		if (bResult) {
-			LARGE_INTEGER timeout;
-
-			/* Use a timeout of 1 second */
-			timeout.QuadPart = -10000000;
-			dev_info(&ced->interface - dev,
-				 "%s: about to wait till done\n", __func__);
-			ntStatus =
-			    KeWaitForSingleObject(&ced->StagingDoneEvent,
-						  Executive, KernelMode, FALSE,
-						  &timeout);
-		} else {
-			dev_info(&ced->interface - dev,
-				 "%s: cancellation failed\n", __func__);
-			ntStatus = U14ERR_FAIL;
-		}
-		USB_KdPrint(DBGLVL_DEFAULT,
-			("ced_read_write_cancel ntStatus = 0x%x decimal %d\n",
-			ntStatus, ntStatus));
-	} else
-		spin_unlock_irq(&ced->staged_lock);
-
-	dev_info(&ced->interface - dev, "%s: done\n", __func__);
-	return ntStatus;
-#else
-	return U14ERR_NOERROR;
-#endif
-
-}
-
-/***************************************************************************
-** ced_in_self_test - utility to check in self test. Return 1 for ST, 0 for not
-** or a -ve error code if we failed for some reason.
-***************************************************************************/
-static int ced_in_self_test(struct ced_data *ced, unsigned int *stat)
-{
-	unsigned int state, error;
-	int ret = ced_get_state(ced, &state, &error); /* see if in self-test */
-
-	if (ret == U14ERR_NOERROR)	/*  if all still OK */
-		ret = (state == (unsigned int)-1) ||	/*  TX problem or... */
-		    ((state & 0xff) == 0x80);	/*  ...self test */
-	*stat = state;	/*  return actual state */
-	return ret;
-}
-
-/***************************************************************************
-** ced_is_1401 - ALWAYS CALLED HOLDING THE io_mutex
-**
-** Tests for the current state of the 1401. Sets current_state:
-**
-**  U14ERR_NOIF  1401  i/f card not installed (not done here)
-**  U14ERR_OFF   1401  apparently not switched on
-**  U14ERR_NC    1401  appears to be not connected
-**  U14ERR_ILL   1401  if it is there its not very well at all
-**  U14ERR_TIME  1401  appears OK, but doesn't communicate - very bad
-**  U14ERR_STD   1401  OK and ready for use
-**  U14ERR_PLUS  1401+ OK and ready for use
-**  U14ERR_U1401 Micro1401 OK and ready for use
-**  U14ERR_POWER Power1401 OK and ready for use
-**  U14ERR_U14012 Micro1401 mkII OK and ready for use
-**
-**  Returns TRUE if a 1401 detected and OK, else FALSE
-****************************************************************************/
-static bool ced_is_1401(struct ced_data *ced)
-{
-	int ret;
-
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-
-	ced_draw_down(ced);	/*  wait for, then kill outstanding Urbs */
-	ced_flush_in_buff(ced);	/*  Clear out input buffer & pipe */
-	ced_flush_out_buff(ced);	/*  Clear output buffer & pipe */
-
-	/* The next call returns 0 if OK, but has returned 1 in the past, */
-	/* meaning that usb_unlock_device() is needed... now it always is */
-	ret = usb_lock_device_for_reset(ced->udev, ced->interface);
-
-	/*  release the io_mutex because if we don't, we will deadlock due to */
-	/* system calls back into the driver.				      */
-	mutex_unlock(&ced->io_mutex); /* locked, so we will not get */
-				      /* system calls		    */
-	if (ret >= 0) {	/*  if we failed */
-		ret = usb_reset_device(ced->udev); /* try to do the reset */
-		usb_unlock_device(ced->udev);	/* undo the lock */
-	}
-
-	mutex_lock(&ced->io_mutex);	/*  hold stuff off while we wait */
-	ced->dma_flag = MODE_CHAR;	/*  Clear DMA mode flag regardless! */
-	if (ret == 0) {	/*  if all is OK still */
-		unsigned int state;
-
-		ret = ced_in_self_test(ced, &state); /* see if likely in */
-						     /* self test	 */
-		if (ret > 0) {	/*  do we need to wait for self-test? */
-			/* when to give up */
-			unsigned long timeout = jiffies + 30 * HZ;
-
-			while ((ret > 0) && time_before(jiffies, timeout)) {
-				schedule();	/*  let other stuff run */
-
-				/* see if done yet */
-				ret = ced_in_self_test(ced, &state);
-			}
-		}
-
-		if (ret == 0)	/*  if all is OK... */
-			/* then success is that the state is 0 */
-			ret = state == 0;
-	} else
-		ret = 0;	/*  we failed */
-	ced->force_reset = false;	/*  Clear forced reset flag now */
-
-	return ret > 0;
-}
-
-/****************************************************************************
-** ced_quick_check  - ALWAYS CALLED HOLDING THE io_mutex
-** This is used to test for a 1401. It will try to do a quick check if all is
-**  OK, that is the 1401 was OK the last time it was asked, and there is no DMA
-**  in progress, and if the bTestBuff flag is set, the character buffers must be
-**  empty too. If the quick check shows that the state is still the same, then
-**  all is OK.
-**
-** If any of the above conditions are not met, or if the state or type of the
-**  1401 has changed since the previous test, the full ced_is_1401 test is done,
-** but only if can_reset is also TRUE.
-**
-** The return value is TRUE if a useable 1401 is found, FALSE if not
-*/
-static bool ced_quick_check(struct ced_data *ced, bool test_buff,
-			    bool can_reset)
-{
-	bool ret = false;	/*  assume it will fail and we will reset */
-	bool short_test;
-
-	short_test = ((ced->dma_flag == MODE_CHAR) &&	/*  no DMA running */
-		      (!ced->force_reset) && /* Not had a real reset forced */
-		       /* No 1401 errors stored */
-		      (ced->current_state >= U14ERR_STD));
-
-	dev_dbg(&ced->interface->dev,
-		"%s: DMAFlag:%d, state:%d, force:%d, testBuff:%d, short:%d\n",
-		__func__, ced->dma_flag, ced->current_state, ced->force_reset,
-		test_buff, short_test);
-
-	if ((test_buff) &&	/*  Buffer check requested, and... */
-	    (ced->num_input || ced->num_output)) {/* ...characters were in */
-						  /* the buffer?	   */
-		short_test = false;	/*  Then do the full test */
-		dev_dbg(&ced->interface->dev,
-			"%s: will reset as buffers not empty\n", __func__);
-	}
-
-	if (short_test || !can_reset) {	/* Still OK to try the short test? */
-					/* Always test if no reset - we    */
-					/* want state update		   */
-		unsigned int state, error;
-
-		dev_dbg(&ced->interface->dev, "%s: ced_get_state\n", __func__);
-
-		/* Check on the 1401 state */
-		if (ced_get_state(ced, &state, &error) == U14ERR_NOERROR) {
-			/* If call worked, check the status value */
-			if ((state & 0xFF) == 0)
-				ret = true; /* If that was zero, all is OK, */
-					    /* no reset needed		    */
-		}
-	}
-
-	if (!ret && can_reset)	{ /*  If all not OK, then */
-		dev_info(&ced->interface->dev, "%s: ced_is_1401 %d %d %d %d\n",
-			 __func__, short_test, ced->current_state, test_buff,
-			 ced->force_reset);
-		ret = ced_is_1401(ced);	/*   do full test */
-	}
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_reset
-**
-** Resets the 1401 and empties the i/o buffers
-*****************************************************************************/
-int ced_reset(struct ced_data *ced)
-{
-	mutex_lock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-	dev_dbg(&ced->interface->dev, "%s: About to call ced_quick_check\n",
-		__func__);
-	ced_quick_check(ced, true, true); /* Check 1401, reset if not OK */
-	mutex_unlock(&ced->io_mutex);
-	return U14ERR_NOERROR;
-}
-
-/****************************************************************************
-** ced_get_char
-**
-** Gets a single character from the 1401
-****************************************************************************/
-int ced_get_char(struct ced_data *ced)
-{
-	int ret = U14ERR_NOIN;	/*  assume we will get  nothing */
-
-	mutex_lock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-
-	ced_allowi(ced);	/*  Make sure char reads are running */
-	ced_send_chars(ced);	/*  and send any buffered chars */
-
-	spin_lock_irq(&ced->char_in_lock);
-	if (ced->num_input > 0) {	/*  worth looking */
-		ret = ced->input_buffer[ced->in_buff_get++];
-		if (ced->in_buff_get >= INBUF_SZ)
-			ced->in_buff_get = 0;
-		ced->num_input--;
-	} else
-		ret = U14ERR_NOIN;	/*  no input data to read */
-	spin_unlock_irq(&ced->char_in_lock);
-
-	ced_allowi(ced);	/*  Make sure char reads are running */
-
-	mutex_unlock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-	return ret;
-}
-
-/****************************************************************************
-** ced_get_string
-**
-** Gets a string from the 1401. Returns chars up to the next CR or when
-** there are no more to read or nowhere to put them. CR is translated to
-** 0 and counted as a character. If the string does not end in a 0, we will
-** add one, if there is room, but it is not counted as a character.
-**
-** returns the count of characters (including the terminator, or 0 if none
-** or a negative error code.
-****************************************************************************/
-int ced_get_string(struct ced_data *ced, char __user *user, int n)
-{
-	int available;		/*  character in the buffer */
-	int ret = U14ERR_NOIN;
-
-	if (n <= 0)
-		return -ENOMEM;
-
-	mutex_lock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-	ced_allowi(ced);	/*  Make sure char reads are running */
-	ced_send_chars(ced);		/*  and send any buffered chars */
-
-	spin_lock_irq(&ced->char_in_lock);
-	available = ced->num_input;	/*  characters available now */
-	if (available > n)	/*  read max of space in user... */
-		available = n;	/*  ...or input characters */
-
-	if (available > 0) {	/*  worth looking? */
-		char buffer[INBUF_SZ + 1]; /* space for a linear copy of data */
-		int got = 0;
-		int n_copy_to_user;	/*  number to copy to user */
-		char data;
-
-		do {
-			data = ced->input_buffer[ced->in_buff_get++];
-			if (data == CR_CHAR)	/*  replace CR with zero */
-				data = (char)0;
-
-			if (ced->in_buff_get >= INBUF_SZ)
-				ced->in_buff_get = 0; /* wrap buffer pointer */
-
-			buffer[got++] = data;	/*  save the output */
-		} while ((got < available) && data);
-
-		n_copy_to_user = got;	/*  what to copy... */
-		if (data) {	/*  do we need null */
-			buffer[got] = (char)0;	/*  make it tidy */
-			if (got < n)	/*  if space in user buffer... */
-				++n_copy_to_user; /* ...copy the 0 as well. */
-		}
-
-		ced->num_input -= got;
-		spin_unlock_irq(&ced->char_in_lock);
-
-		dev_dbg(&ced->interface->dev, "%s: read %d characters >%s<\n",
-			__func__, got, buffer);
-		if (copy_to_user(user, buffer, n_copy_to_user))
-			ret = -EFAULT;
-		else
-			ret = got;		/*  report characters read */
-	} else
-		spin_unlock_irq(&ced->char_in_lock);
-
-	ced_allowi(ced);	/*  Make sure char reads are running */
-	mutex_unlock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-
-	return ret;
-}
-
-/*******************************************************************************
-** Get count of characters in the inout buffer.
-*******************************************************************************/
-int ced_stat_1401(struct ced_data *ced)
-{
-	int ret;
-
-	mutex_lock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-	ced_allowi(ced);		/*  make sure we allow pending chars */
-	ced_send_chars(ced);		/*  in both directions */
-	ret = ced->num_input;		/*  no lock as single read */
-	mutex_unlock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-	return ret;
-}
-
-/****************************************************************************
-** ced_line_count
-**
-** Returns the number of newline chars in the buffer. There is no need for
-** any fancy interlocks as we only read the interrupt routine data, and the
-** system is arranged so nothing can be destroyed.
-****************************************************************************/
-int ced_line_count(struct ced_data *ced)
-{
-	int ret = 0;	/*  will be count of line ends */
-
-	mutex_lock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-	ced_allowi(ced);		/*  Make sure char reads are running */
-	ced_send_chars(ced);		/*  and send any buffered chars */
-	spin_lock_irq(&ced->char_in_lock);	/*  Get protection */
-
-	if (ced->num_input > 0) {	/*  worth looking? */
-		/* start at first available */
-		unsigned int index = ced->in_buff_get;
-		/* Position for search end */
-		unsigned int end = ced->in_buff_put;
-
-		do {
-			if (ced->input_buffer[index++] == CR_CHAR)
-				++ret;	/*  inc count if CR */
-
-			if (index >= INBUF_SZ) /*  see if we fall off buff */
-				index = 0;
-		} while (index != end);	/*  go to last available */
-	}
-
-	spin_unlock_irq(&ced->char_in_lock);
-	dev_dbg(&ced->interface->dev, "%s: returned %d\n", __func__, ret);
-	mutex_unlock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-	return ret;
-}
-
-/****************************************************************************
-** ced_get_out_buf_space
-**
-** Gets the space in the output buffer. Called from user code.
-*****************************************************************************/
-int ced_get_out_buf_space(struct ced_data *ced)
-{
-	int ret;
-
-	mutex_lock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-
-	ced_send_chars(ced);		/*  send any buffered chars */
-
-	 /* no lock needed for single read */
-	ret = (int)(OUTBUF_SZ - ced->num_output);
-
-	dev_dbg(&ced->interface->dev, "%s: %d\n", __func__, ret);
-
-	mutex_unlock(&ced->io_mutex);	/*  Protect disconnect from new i/o */
-	return ret;
-}
-
-/****************************************************************************
-**
-** ced_clear_area
-**
-** Clears up a transfer area. This is always called in the context of a user
-** request, never from a call-back.
-****************************************************************************/
-int ced_clear_area(struct ced_data *ced, int area)
-{
-	int ret = U14ERR_NOERROR;
-
-	if ((area < 0) || (area >= MAX_TRANSAREAS)) {
-		ret = U14ERR_BADAREA;
-		dev_err(&ced->interface->dev, "%s: Attempt to clear area %d\n",
-			__func__, area);
-	} else {
-		/* to save typing */
-		struct transarea *ta = &ced->trans_def[area];
-
-		if (!ta->used)	/*  if not used... */
-			ret = U14ERR_NOTSET;	/*  ...nothing to be done */
-		else {
-			/*  We must save the memory we return as we shouldn't */
-			/* mess with memory while holding a spin lock. */
-			struct page **pages = NULL; /*save page address list*/
-			int n_pages = 0;	/*  and number of pages */
-			int np;
-
-			dev_dbg(&ced->interface->dev, "%s: area %d\n",
-				__func__, area);
-			spin_lock_irq(&ced->staged_lock);
-			if ((ced->staged_id == area)
-			    && (ced->dma_flag > MODE_CHAR)) {
-				/* cannot delete as in use */
-				ret = U14ERR_UNLOCKFAIL;
-				dev_err(&ced->interface->dev,
-					"%s: call on area %d while active\n",
-					__func__, area);
-			} else {
-				pages = ta->pages; /* save page address list */
-				n_pages = ta->n_pages;	/* and page count */
-				if (ta->event_sz)/* if events flagging in use */
-					/* release anything that was waiting */
-					wake_up_interruptible(&ta->event);
-
-				if (ced->xfer_waiting
-				    && (ced->dma_info.ident == area))
-					/* Cannot have pending xfer if */
-					/* area cleared		       */
-					ced->xfer_waiting = false;
-
-				/* Clean out the struct transarea except for */
-				/* the wait queue, which is at the end. This */
-				/* sets used to false and event_sz to 0 to   */
-				/* say area not used and no events.          */
-				memset(ta, 0,
-				       sizeof(struct transarea) -
-				       sizeof(wait_queue_head_t));
-			}
-			spin_unlock_irq(&ced->staged_lock);
-
-			if (pages) { /*  if we decided to release the memory */
-				/* Now we must undo the pinning down of the  */
-				/* pages. We will assume the worst and mark  */
-				/* all the pages as dirty. Don't be tempted  */
-				/* to move this up above as you must not be  */
-				/* holding a spin lock to do this stuff as   */
-				/* it is not atomic.                         */
-				dev_dbg(&ced->interface->dev,
-					"%s: n_pages=%d\n",
-					__func__, n_pages);
-
-				for (np = 0; np < n_pages; ++np) {
-					if (pages[np]) {
-						SetPageDirty(pages[np]);
-						page_cache_release(pages[np]);
-					}
-				}
-
-				kfree(pages);
-				dev_dbg(&ced->interface->dev,
-					"%s: kfree(pages) done\n", __func__);
-			}
-		}
-	}
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_set_area
-**
-** Sets up a transfer area - the functional part. Called by both
-** ced_set_transfer and ced_set_circular.
-****************************************************************************/
-static int ced_set_area(struct ced_data *ced, int area, char __user *buf,
-		   unsigned int length, bool circular, bool circ_to_host)
-{
-	/* Start by working out the page aligned start of the area and the  */
-	/* size of the area in pages, allowing for the start not being      */
-	/* aligned and the end needing to be rounded up to a page boundary. */
-	unsigned long start = ((unsigned long)buf) & PAGE_MASK;
-	unsigned int offset = ((unsigned long)buf) & (PAGE_SIZE - 1);
-	int len = (length + offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
-
-	struct transarea *ta = &ced->trans_def[area];	/*  to save typing */
-	struct page **pages = NULL;	/*  space for page tables */
-	int n_pages = 0;		/*  and number of pages */
-
-	int ret = ced_clear_area(ced, area); /*  see if OK to use this area */
-
-	if ((ret != U14ERR_NOTSET) &&	/*  if not area unused and... */
-	    (ret != U14ERR_NOERROR))	/*  ...not all OK, then... */
-		return ret;	/*  ...we cannot use this area */
-
-	/* if we cannot access the memory... */
-	if (!access_ok(VERIFY_WRITE, buf, length))
-		return -EFAULT;	/*  ...then we are done */
-
-	/*  Now allocate space to hold the page pointer and */
-	/* virtual address pointer tables		    */
-	pages = kmalloc(len * sizeof(struct page *), GFP_KERNEL);
-	if (!pages) {
-		ret = U14ERR_NOMEMORY;
-		goto error;
-	}
-	dev_dbg(&ced->interface->dev, "%s: %p, length=%06x, circular %d\n",
-		__func__, buf, length, circular);
-
-	/* To pin down user pages we must first */
-	/* acquire the mapping semaphore.	*/
-	n_pages = get_user_pages_fast(start, len, 1, pages);
-	dev_dbg(&ced->interface->dev, "%s: n_pages = %d\n", __func__, n_pages);
-
-	if (n_pages > 0) { /* if we succeeded */
-		/* If you are tempted to use page_address (form LDD3), forget */
-		/* it. You MUST use kmap() or kmap_atomic() to get a virtual  */
-		/* address. page_address will give you (null) or at least it  */
-		/* does in this context with an x86 machine.                  */
-		spin_lock_irq(&ced->staged_lock);
-		ta->buff = buf;	/*  keep start of region (user address) */
-		ta->base_offset = offset; /* save offset in first page */
-					  /* to start of xfer          */
-		ta->length = length;	/*  Size if the region in bytes */
-		ta->pages = pages; /* list of pages that are used by buffer */
-		ta->n_pages = n_pages;	/*  number of pages */
-
-		ta->circular = circular;
-		ta->circ_to_host = circ_to_host;
-
-		ta->blocks[0].offset = 0;
-		ta->blocks[0].size = 0;
-		ta->blocks[1].offset = 0;
-		ta->blocks[1].size = 0;
-		ta->used = true;	/*  This is now a used block */
-
-		spin_unlock_irq(&ced->staged_lock);
-		ret = U14ERR_NOERROR;	/*  say all was well */
-	} else {
-		ret = U14ERR_LOCKFAIL;
-		goto error;
-	}
-
-	return ret;
-
-error:
-	kfree(pages);
-	return ret;
-}
-
-/****************************************************************************
-** ced_set_transfer
-**
-** Sets up a transfer area record. If the area is already set, we attempt to
-** unset it. Unsetting will fail if the area is booked, and a transfer to that
-** area is in progress. Otherwise, we will release the area and re-assign it.
-****************************************************************************/
-int ced_set_transfer(struct ced_data *ced,
-		     struct transfer_area_desc __user *utd)
-{
-	int ret;
-	struct transfer_area_desc td;
-
-	if (copy_from_user(&td, utd, sizeof(td)))
-		return -EFAULT;
-
-	mutex_lock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s: area:%d, size:%08x\n",
-		__func__, td.wAreaNum, td.dwLength);
-	/* The strange cast is done so that we don't get warnings in 32-bit  */
-	/* linux about the size of the pointer. The pointer is always passed */
-	/* as a 64-bit object so that we don't have problems using a 32-bit  */
-	/* program on a 64-bit system. unsigned long is 64-bits on a 64-bit  */
-	/* system.							     */
-	ret =
-	    ced_set_area(ced, td.wAreaNum,
-		    (char __user *)((unsigned long)td.lpvBuff), td.dwLength,
-		    false, false);
-	mutex_unlock(&ced->io_mutex);
-	return ret;
-}
-
-/****************************************************************************
-** ced_unset_transfer
-** Erases a transfer area record
-****************************************************************************/
-int ced_unset_transfer(struct ced_data *ced, int area)
-{
-	int ret;
-
-	mutex_lock(&ced->io_mutex);
-	ret = ced_clear_area(ced, area);
-	mutex_unlock(&ced->io_mutex);
-	return ret;
-}
-
-/****************************************************************************
-** ced_set_event
-** Creates an event that we can test for based on a transfer to/from an area.
-** The area must be setup for a transfer. We attempt to simulate the Windows
-** driver behavior for events (as we don't actually use them), which is to
-** pretend that whatever the user asked for was achieved, so we return 1 if
-** try to create one, and 0 if they ask to remove (assuming all else was OK).
-****************************************************************************/
-int ced_set_event(struct ced_data *ced, struct transfer_event __user *ute)
-{
-	int ret = U14ERR_NOERROR;
-	struct transfer_event te;
-	struct transarea *ta;
-
-	/*  get a local copy of the data */
-	if (copy_from_user(&te, ute, sizeof(te)))
-		return -EFAULT;
-
-	if (te.wAreaNum >= MAX_TRANSAREAS)	/*  the area must exist */
-		return U14ERR_BADAREA;
-
-	ta = &ced->trans_def[te.wAreaNum];
-
-	/* make sure we have no competitor */
-	mutex_lock(&ced->io_mutex);
-	spin_lock_irq(&ced->staged_lock);
-
-	if (ta->used) {	/* area must be in use */
-		ta->event_st = te.dwStart; /*  set area regions */
-
-		 /* set size (0 cancels it) */
-		ta->event_sz = te.dwLength;
-
-		 /*  set the direction */
-		ta->event_to_host = te.wFlags & 1;
-		ta->wake_up = 0;	/*  zero the wake up count */
-	} else
-		ret = U14ERR_NOTSET;
-
-	spin_unlock_irq(&ced->staged_lock);
-	mutex_unlock(&ced->io_mutex);
-
-	return ret ==
-	    U14ERR_NOERROR ? (te.iSetEvent ? 1 : U14ERR_NOERROR) : ret;
-}
-
-/****************************************************************************
-** ced_wait_event
-** Sleep the process with a timeout waiting for an event. Returns the number
-** of times that a block met the event condition since we last cleared it or
-** 0 if timed out, or -ve error (bad area or not set, or signal).
-****************************************************************************/
-int ced_wait_event(struct ced_data *ced, int area, int time_out)
-{
-	int ret;
-	int wait;
-	struct transarea *ta;
-
-	if ((unsigned)area >= MAX_TRANSAREAS)
-		return U14ERR_BADAREA;
-
-	ta = &ced->trans_def[area];
-
-	 /* convert timeout to jiffies */
-	time_out = (time_out * HZ + 999) / 1000;
-
-	/* We cannot wait holding the mutex, but we check the flags  */
-	/* while holding it. This may well be pointless as another   */
-	/* thread could get in between releasing it and the wait     */
-	/* call. However, this would have to clear the wake_up flag. */
-	/* However, the !ta->used may help us in this case.	     */
-
-	/* make sure we have no competitor */
-	mutex_lock(&ced->io_mutex);
-	if (!ta->used || !ta->event_sz) /* check something to */
-					  /* wait for...        */
-		return U14ERR_NOTSET;	/*  ...else we do nothing */
-	mutex_unlock(&ced->io_mutex);
-
-	if (time_out)
-		wait = wait_event_interruptible_timeout(ta->event,
-							ta->wake_up ||
-							!ta->used,
-							time_out);
-	else
-		wait = wait_event_interruptible(ta->event,
-						ta->wake_up ||
-						!ta->used);
-
-	if (wait)
-		ret = -ERESTARTSYS; /* oops - we have had a SIGNAL */
-	else
-		ret = ta->wake_up; /* else the wakeup count */
-
-	spin_lock_irq(&ced->staged_lock);
-	ta->wake_up = 0;	/*  clear the flag */
-	spin_unlock_irq(&ced->staged_lock);
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_test_event
-** Test the event to see if a ced_wait_event would return immediately. Returns
-** the number of times a block completed since the last call, or 0 if none or a
-** negative error.
-****************************************************************************/
-int ced_test_event(struct ced_data *ced, int area)
-{
-	int ret;
-
-	if ((unsigned)area >= MAX_TRANSAREAS)
-		ret = U14ERR_BADAREA;
-	else {
-		struct transarea *ta = &ced->trans_def[area];
-
-		 /* make sure we have no competitor */
-		mutex_lock(&ced->io_mutex);
-		spin_lock_irq(&ced->staged_lock);
-		ret = ta->wake_up;	/*  get wakeup count since last call */
-		ta->wake_up = 0;	/*  clear the count */
-		spin_unlock_irq(&ced->staged_lock);
-		mutex_unlock(&ced->io_mutex);
-	}
-	return ret;
-}
-
-/****************************************************************************
-** ced_get_transferInfo
-** Puts the current state of the 1401 in a TGET_TX_BLOCK.
-*****************************************************************************/
-int ced_get_transfer(struct ced_data *ced, TGET_TX_BLOCK __user *utx)
-{
-	int ret = U14ERR_NOERROR;
-	unsigned int dwIdent;
-
-	mutex_lock(&ced->io_mutex);
-	dwIdent = ced->staged_id;	/*  area ident for last xfer */
-	if (dwIdent >= MAX_TRANSAREAS)
-		ret = U14ERR_BADAREA;
-	else {
-		/* Return the best information we have - we */
-		/* don't have physical addresses	    */
-		TGET_TX_BLOCK *tx;
-
-		tx = kzalloc(sizeof(*tx), GFP_KERNEL);
-		if (!tx) {
-			mutex_unlock(&ced->io_mutex);
-			return -ENOMEM;
-		}
-		tx->size = ced->trans_def[dwIdent].length;
-		tx->linear = (long long)((long)ced->trans_def[dwIdent].buff);
-		/* how many blocks we could return */
-		tx->avail = GET_TX_MAXENTRIES;
-		tx->used = 1;	/*  number we actually return */
-		tx->entries[0].physical =
-		    (long long)(tx->linear + ced->staged_offset);
-		tx->entries[0].size = tx->size;
-
-		if (copy_to_user(utx, tx, sizeof(*tx)))
-			ret = -EFAULT;
-		kfree(tx);
-	}
-	mutex_unlock(&ced->io_mutex);
-	return ret;
-}
-
-/****************************************************************************
-** ced_kill_io
-**
-** Empties the host i/o buffers
-****************************************************************************/
-int ced_kill_io(struct ced_data *ced)
-{
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-	mutex_lock(&ced->io_mutex);
-	ced_flush_out_buff(ced);
-	ced_flush_in_buff(ced);
-	mutex_unlock(&ced->io_mutex);
-	return U14ERR_NOERROR;
-}
-
-/****************************************************************************
-** ced_state_of_1401
-**
-** Puts the current state of the 1401 in the Irp return buffer.
-*****************************************************************************/
-int ced_state_of_1401(struct ced_data *ced)
-{
-	int ret;
-
-	mutex_lock(&ced->io_mutex);
-
-	ced_quick_check(ced, false, false); /* get state up to date, no reset */
-	ret = ced->current_state;
-
-	mutex_unlock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s: %d\n", __func__, ret);
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_start_self_test
-**
-** Initiates a self-test cycle. The assumption is that we have no interrupts
-** active, so we should make sure that this is the case.
-*****************************************************************************/
-int ced_start_self_test(struct ced_data *ced)
-{
-	int got;
-
-	mutex_lock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-
-	ced_draw_down(ced);	/*  wait for, then kill outstanding Urbs */
-	ced_flush_in_buff(ced);	/*  Clear out input buffer & pipe */
-	ced_flush_out_buff(ced);	/*  Clear output buffer & pipe */
-	/* so things stay tidy */
-	/* ced_read_write_cancel(pDeviceObject); */
-	ced->dma_flag = MODE_CHAR;	/* Clear DMA mode flags here */
-
-	got = usb_control_msg(ced->udev, usb_rcvctrlpipe(ced->udev, 0),
-			       DB_SELFTEST, (H_TO_D | VENDOR | DEVREQ),
-			       0, 0, NULL, 0, HZ); /* allow 1 second timeout */
-	ced->self_test_time = jiffies + HZ * 30;   /* 30 seconds into the    */
-						   /* future                 */
-
-	mutex_unlock(&ced->io_mutex);
-	if (got < 0)
-		dev_err(&ced->interface->dev, "%s: err=%d\n", __func__, got);
-	return got < 0 ? U14ERR_FAIL : U14ERR_NOERROR;
-}
-
-/****************************************************************************
-** ced_check_self_test
-**
-** Check progress of a self-test cycle
-****************************************************************************/
-int ced_check_self_test(struct ced_data *ced, TGET_SELFTEST __user *ugst)
-{
-	unsigned int state, error;
-	int ret;
-	TGET_SELFTEST gst;	/*  local work space */
-
-	memset(&gst, 0, sizeof(gst));	/*  clear out the space (sets code 0) */
-
-	mutex_lock(&ced->io_mutex);
-
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-	ret = ced_get_state(ced, &state, &error);
-	if (ret == U14ERR_NOERROR) /* Only accept zero if it happens twice */
-		ret = ced_get_state(ced, &state, &error);
-
-	if (ret != U14ERR_NOERROR) {	/*  Self-test can cause comms errors */
-				/*  so we assume still testing */
-		dev_err(&ced->interface->dev,
-			"%s: ced_get_state=%d, assuming still testing\n",
-			__func__, ret);
-		state = 0x80;	/*  Force still-testing, no error */
-		error = 0;
-		ret = U14ERR_NOERROR;
-	}
-
-	if ((state == -1) && (error == -1)) {/* If ced_get_state had problems */
-		dev_err(&ced->interface->dev,
-			"%s: ced_get_state failed, assuming still testing\n",
-			__func__);
-		state = 0x80;	/*  Force still-testing, no error */
-		error = 0;
-	}
-
-	if ((state & 0xFF) == 0x80) {	/*  If we are still in self-test */
-		if (state & 0x00FF0000)	{ /*  Have we got an error? */
-			/* read the error code */
-			gst.code = (state & 0x00FF0000) >> 16;
-			gst.x = error & 0x0000FFFF;	    /* Error data X */
-			gst.y = (error & 0xFFFF0000) >> 16; /* and data Y   */
-			dev_dbg(&ced->interface->dev,
-				"Self-test error code %d\n", gst.code);
-		} else {		/*  No error, check for timeout */
-			unsigned long now = jiffies;	/*  get current time */
-
-			if (time_after(now, ced->self_test_time)) {
-				gst.code = -2;	/*  Flag the timeout */
-				dev_dbg(&ced->interface->dev,
-					"Self-test timed-out\n");
-			} else
-				dev_dbg(&ced->interface->dev,
-					"Self-test on-going\n");
-		}
-	} else {
-		gst.code = -1;	/*  Flag the test is done */
-		dev_dbg(&ced->interface->dev, "Self-test done\n");
-	}
-
-	if (gst.code < 0) { /* If we have a problem or finished */
-			    /* If using the 2890 we should reset properly */
-		if ((ced->n_pipes == 4) && (ced->type <= TYPEPOWER))
-			ced_is_1401(ced);	/*  Get 1401 reset and OK */
-		else
-			/* Otherwise check without reset unless problems */
-			ced_quick_check(ced, true, true);
-	}
-	mutex_unlock(&ced->io_mutex);
-
-	if (copy_to_user(ugst, &gst, sizeof(gst)))
-		return -EFAULT;
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_type_of_1401
-**
-** Returns code for standard, plus, micro1401, power1401 or none
-****************************************************************************/
-int ced_type_of_1401(struct ced_data *ced)
-{
-	int ret = TYPEUNKNOWN;
-
-	mutex_lock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-
-	switch (ced->type) {
-	case TYPE1401:
-		ret = U14ERR_STD;
-		break;		/*  Handle these types directly */
-	case TYPEPLUS:
-		ret = U14ERR_PLUS;
-		break;
-	case TYPEU1401:
-		ret = U14ERR_U1401;
-		break;
-	default:
-		if ((ced->type >= TYPEPOWER) && (ced->type <= 25))
-			ret = ced->type + 4;	/*  We can calculate types */
-		else		/*   for up-coming 1401 designs */
-			ret = TYPEUNKNOWN;	/*  Don't know or not there */
-	}
-	dev_dbg(&ced->interface->dev, "%s %d\n", __func__, ret);
-	mutex_unlock(&ced->io_mutex);
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_transfer_flags
-**
-** Returns flags on block transfer abilities
-****************************************************************************/
-int ced_transfer_flags(struct ced_data *ced)
-{
-	 /* we always have multiple DMA area diagnostics, notify and circular */
-	int ret = U14TF_MULTIA | U14TF_DIAG |
-	    U14TF_NOTIFY | U14TF_CIRCTH;
-
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-	mutex_lock(&ced->io_mutex);
-	if (ced->is_usb2)	/*  Set flag for USB2 if appropriate */
-		ret |= U14TF_USB2;
-	mutex_unlock(&ced->io_mutex);
-
-	return ret;
-}
-
-/***************************************************************************
-** ced_dbg_cmd
-** Issues a debug\diagnostic command to the 1401 along with a 32-bit datum
-** This is a utility command used for dbg operations.
-*/
-static int ced_dbg_cmd(struct ced_data *ced, unsigned char cmd,
-		      unsigned int data)
-{
-	int ret;
-
-	dev_dbg(&ced->interface->dev, "%s: entry\n", __func__);
-	ret = usb_control_msg(ced->udev, usb_sndctrlpipe(ced->udev, 0), cmd,
-				  (H_TO_D | VENDOR | DEVREQ),
-				  (unsigned short)data,
-				  (unsigned short)(data >> 16), NULL, 0, HZ);
-						/* allow 1 second timeout */
-	if (ret < 0)
-		dev_err(&ced->interface->dev, "%s: fail code=%d\n",
-			__func__, ret);
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_dbg_peek
-**
-** Execute the diagnostic peek operation. Uses address, width and repeats.
-****************************************************************************/
-int ced_dbg_peek(struct ced_data *ced, TDBGBLOCK __user *udb)
-{
-	int ret;
-	TDBGBLOCK db;
-
-	if (copy_from_user(&db, udb, sizeof(db)))
-		return -EFAULT;
-
-	mutex_lock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s: @ %08x\n", __func__, db.iAddr);
-
-	ret = ced_dbg_cmd(ced, DB_SETADD, db.iAddr);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_WIDTH, db.iWidth);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_REPEATS, db.iRepeats);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_PEEK, 0);
-	mutex_unlock(&ced->io_mutex);
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_dbg_poke
-**
-** Execute the diagnostic poke operation. Parameters are in the CSBLOCK struct
-** in order address, size, repeats and value to poke.
-****************************************************************************/
-int ced_dbg_poke(struct ced_data *ced, TDBGBLOCK __user *udb)
-{
-	int ret;
-	TDBGBLOCK db;
-
-	if (copy_from_user(&db, udb, sizeof(db)))
-		return -EFAULT;
-
-	mutex_lock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s: @ %08x\n", __func__, db.iAddr);
-
-	ret = ced_dbg_cmd(ced, DB_SETADD, db.iAddr);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_WIDTH, db.iWidth);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_REPEATS, db.iRepeats);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_POKE, db.iData);
-	mutex_unlock(&ced->io_mutex);
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_dbg_ramp_data
-**
-** Execute the diagnostic ramp data operation. Parameters are in the CSBLOCK
-** struct in order address, default, enable mask, size and repeats.
-****************************************************************************/
-int ced_dbg_ramp_data(struct ced_data *ced, TDBGBLOCK __user *udb)
-{
-	int ret;
-	TDBGBLOCK db;
-
-	if (copy_from_user(&db, udb, sizeof(db)))
-		return -EFAULT;
-
-	mutex_lock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s: @ %08x\n", __func__, db.iAddr);
-
-	ret = ced_dbg_cmd(ced, DB_SETADD, db.iAddr);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_SETDEF, db.iDefault);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_SETMASK, db.iMask);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_WIDTH, db.iWidth);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_REPEATS, db.iRepeats);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_RAMPD, 0);
-	mutex_unlock(&ced->io_mutex);
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_dbg_ramp_addr
-**
-** Execute the diagnostic ramp address operation
-****************************************************************************/
-int ced_dbg_ramp_addr(struct ced_data *ced, TDBGBLOCK __user *udb)
-{
-	int ret;
-	TDBGBLOCK db;
-
-	if (copy_from_user(&db, udb, sizeof(db)))
-		return -EFAULT;
-
-	mutex_lock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-
-	ret = ced_dbg_cmd(ced, DB_SETDEF, db.iDefault);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_SETMASK, db.iMask);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_WIDTH, db.iWidth);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_REPEATS, db.iRepeats);
-	if (ret == U14ERR_NOERROR)
-		ret = ced_dbg_cmd(ced, DB_RAMPA, 0);
-	mutex_unlock(&ced->io_mutex);
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_dbg_get_data
-**
-** Retrieve the data resulting from the last debug Peek operation
-****************************************************************************/
-int ced_dbg_get_data(struct ced_data *ced, TDBGBLOCK __user *udb)
-{
-	int ret;
-	TDBGBLOCK db;
-
-	memset(&db, 0, sizeof(db));	/*  fill returned block with 0s */
-
-	mutex_lock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-
-	/*  Read back the last peeked value from the 1401. */
-	ret = usb_control_msg(ced->udev, usb_rcvctrlpipe(ced->udev, 0),
-				  DB_DATA, (D_TO_H | VENDOR | DEVREQ), 0, 0,
-				  &db.iData, sizeof(db.iData), HZ);
-	if (ret == sizeof(db.iData)) {
-		if (copy_to_user(udb, &db, sizeof(db)))
-			ret = -EFAULT;
-		else
-			ret = U14ERR_NOERROR;
-	} else
-		dev_err(&ced->interface->dev, "%s: failed, code %d\n",
-			__func__, ret);
-
-	mutex_unlock(&ced->io_mutex);
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_dbg_stop_loop
-**
-** Stop any never-ending debug loop, we just call ced_get_state for USB
-**
-****************************************************************************/
-int ced_dbg_stop_loop(struct ced_data *ced)
-{
-	int ret;
-	unsigned int uState, uErr;
-
-	mutex_lock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-	ret = ced_get_state(ced, &uState, &uErr);
-	mutex_unlock(&ced->io_mutex);
-
-	return ret;
-}
-
-/****************************************************************************
-** ced_set_circular
-**
-** Sets up a transfer area record for circular transfers. If the area is
-** already set, we attempt to unset it. Unsetting will fail if the area is
-** booked and a transfer to that area is in progress. Otherwise, we will
-** release the area and re-assign it.
-****************************************************************************/
-int ced_set_circular(struct ced_data *ced,
-		     struct transfer_area_desc __user *utd)
-{
-	int ret;
-	bool to_host;
-	struct transfer_area_desc td;
-
-	if (copy_from_user(&td, utd, sizeof(td)))
-		return -EFAULT;
-
-	mutex_lock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s: area:%d, size:%08x\n",
-		__func__, td.wAreaNum, td.dwLength);
-	to_host = td.eSize != 0;	/*  this is used as the tohost flag */
-
-	/* The strange cast is done so that we don't get warnings in 32-bit  */
-	/* linux about the size of the pointer. The pointer is always passed */
-	/* as a 64-bit object so that we don't have problems using a 32-bit  */
-	/* program on a 64-bit system. unsigned long is 64-bits on a 64-bit  */
-	/* system.							     */
-	ret =
-	    ced_set_area(ced, td.wAreaNum,
-		    (char __user *)((unsigned long)td.lpvBuff), td.dwLength,
-		    true, to_host);
-	mutex_unlock(&ced->io_mutex);
-	return ret;
-}
-
-/****************************************************************************
-** ced_get_circ_block
-**
-** Return the next available block of circularly-transferred data.
-****************************************************************************/
-int ced_get_circ_block(struct ced_data *ced, TCIRCBLOCK __user *ucb)
-{
-	int ret = U14ERR_NOERROR;
-	unsigned int area;
-	TCIRCBLOCK cb;
-
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-
-	if (copy_from_user(&cb, ucb, sizeof(cb)))
-		return -EFAULT;
-
-	mutex_lock(&ced->io_mutex);
-
-	area = cb.nArea;	/*  Retrieve parameters first */
-	cb.dwOffset = 0;	/*  set default result (nothing) */
-	cb.dwSize = 0;
-
-	if (area < MAX_TRANSAREAS) {	/*  The area number must be OK */
-		/* Pointer to relevant info */
-		struct transarea *ta = &ced->trans_def[area];
-
-		spin_lock_irq(&ced->staged_lock);	/*  Lock others out */
-
-		if ((ta->used) && (ta->circular) && /* Must be circular area */
-		    (ta->circ_to_host)) { /* For now at least must be to host */
-			if (ta->blocks[0].size > 0) {	/*  Got anything? */
-				cb.dwOffset = ta->blocks[0].offset;
-				cb.dwSize = ta->blocks[0].size;
-				dev_dbg(&ced->interface->dev,
-					"%s: return block 0: %d bytes at %d\n",
-					__func__, cb.dwSize, cb.dwOffset);
-			}
-		} else
-			ret = U14ERR_NOTSET;
-
-		spin_unlock_irq(&ced->staged_lock);
-	} else
-		ret = U14ERR_BADAREA;
-
-	if (copy_to_user(ucb, &cb, sizeof(cb)))
-		ret = -EFAULT;
-
-	mutex_unlock(&ced->io_mutex);
-	return ret;
-}
-
-/****************************************************************************
-** ced_free_circ_block
-**
-** Frees a block of circularly-transferred data and returns the next one.
-****************************************************************************/
-int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *ucb)
-{
-	int ret = U14ERR_NOERROR;
-	unsigned int area, start, size;
-	TCIRCBLOCK cb;
-
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-
-	if (copy_from_user(&cb, ucb, sizeof(cb)))
-		return -EFAULT;
-
-	mutex_lock(&ced->io_mutex);
-
-	area = cb.nArea;	/*  Retrieve parameters first */
-	start = cb.dwOffset;
-	size = cb.dwSize;
-	cb.dwOffset = 0;	/*  then set default result (nothing) */
-	cb.dwSize = 0;
-
-	if (area < MAX_TRANSAREAS) {	/*  The area number must be OK */
-		/* Pointer to relevant info */
-		struct transarea *ta = &ced->trans_def[area];
-
-		spin_lock_irq(&ced->staged_lock);	/*  Lock others out */
-
-		if ((ta->used) && (ta->circular) && /*  Must be circular area */
-		    (ta->circ_to_host)) { /* For now at least must be to host */
-			bool waiting = false;
-
-			if ((ta->blocks[0].size >= size) && /* Got anything? */
-			    /* Must be legal data */
-			    (ta->blocks[0].offset == start)) {
-				ta->blocks[0].size -= size;
-				ta->blocks[0].offset += size;
-
-				 /* Have we emptied this block? */
-				if (ta->blocks[0].size == 0) {
-					/* Is there a second block? */
-					if (ta->blocks[1].size) {
-						/* Copy down block 2 data */
-						ta->blocks[0] = ta->blocks[1];
-						/* and mark the second */
-						/* block as unused     */
-						ta->blocks[1].size = 0;
-						ta->blocks[1].offset = 0;
-					} else
-						ta->blocks[0].offset = 0;
-				}
-
-				dev_dbg(&ced->interface->dev,
-					"%s: free %d bytes at %d, "
-					"return %d bytes at %d, wait=%d\n",
-					__func__, size, start,
-					ta->blocks[0].size,
-					ta->blocks[0].offset,
-					ced->xfer_waiting);
-
-				/* Return the next available block of */
-				/* memory as well		      */
-				if (ta->blocks[0].size > 0) {/* Got anything? */
-					cb.dwOffset =
-					    ta->blocks[0].offset;
-					cb.dwSize = ta->blocks[0].size;
-				}
-
-				waiting = ced->xfer_waiting;
-				if (waiting && ced->staged_urb_pending) {
-					dev_err(&ced->interface->dev,
-						"%s: ERROR: waiting xfer and "
-						"staged Urb pending!\n",
-						__func__);
-					waiting = false;
-				}
-			} else {
-				dev_err(&ced->interface->dev,
-					"%s: ERROR: freeing %d bytes at %d, "
-					"block 0 is %d bytes at %d\n",
-					__func__, size, start,
-					ta->blocks[0].size,
-					ta->blocks[0].offset);
-				ret = U14ERR_NOMEMORY;
-			}
-
-			/*  If we have one, kick off pending transfer */
-			if (waiting) {	/*  Got a block xfer waiting? */
-				int RWMStat =
-				    ced_read_write_mem(ced,
-						       !ced->dma_info.outward,
-						       ced->dma_info.ident,
-						       ced->dma_info.offset,
-						       ced->dma_info.size);
-				if (RWMStat != U14ERR_NOERROR)
-					dev_err(&ced->interface->dev,
-						"%s: rw setup failed %d\n",
-						__func__, RWMStat);
-			}
-		} else
-			ret = U14ERR_NOTSET;
-
-		spin_unlock_irq(&ced->staged_lock);
-	} else
-		ret = U14ERR_BADAREA;
-
-	if (copy_to_user(ucb, &cb, sizeof(cb)))
-		ret = -EFAULT;
-
-	mutex_unlock(&ced->io_mutex);
-	return ret;
-}
diff --git a/drivers/staging/ced1401/ced_ioctl.h b/drivers/staging/ced1401/ced_ioctl.h
deleted file mode 100644
index 4b6c9de..0000000
--- a/drivers/staging/ced1401/ced_ioctl.h
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * IOCTL calls for the CED1401 driver
- * Copyright (C) 2010 Cambridge Electronic Design Ltd
- * Author Greg P Smith (greg@ced.co.uk)
- *
- * 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.
- *
- * 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.
- */
-#ifndef __CED_IOCTL_H__
-#define __CED_IOCTL_H__
-
-#include <linux/ioctl.h>
-
-/* dma modes, only MODE_CHAR and MODE_LINEAR are used in this driver */
-#define MODE_CHAR		0
-#define MODE_LINEAR		1
-
-/****************************************************************************
-** TypeDefs
-*****************************************************************************/
-
-struct transfer_area_desc {
-	long long lpvBuff;	/* address of transfer area (for 64 or 32 bit) */
-	unsigned int dwLength;	/* length of the area */
-	unsigned short wAreaNum;	/* number of transfer area to set up */
-	short eSize;		/* element size - is tohost flag for circular */
-};
-
-
-struct transfer_event {
-	unsigned int dwStart;		/* offset into the area */
-	unsigned int dwLength;		/* length of the region */
-	unsigned short wAreaNum;	/* the area number */
-	unsigned short wFlags;		/* bit 0 set for toHost */
-	int iSetEvent;			/* could be dummy in LINUX */
-};
-
-#define MAX_TRANSFER_SIZE	0x4000		/* Maximum data bytes per IRP */
-#define MAX_AREA_LENGTH		0x100000	/* Maximum size of transfer area */
-#define MAX_TRANSAREAS		8		/* definitions for dma set up  */
-
-typedef struct TGetSelfTest {
-	int code;			/* self-test error code */
-	int x, y;			/* additional information */
-} TGET_SELFTEST;
-
-/* Debug block used for several commands. Not all fields are used for all commands. */
-typedef struct TDbgBlock {
-	int iAddr;			/* the address in the 1401 */
-	int iRepeats;			/* number of repeats */
-	int iWidth;			/* width in bytes 1, 2, 4 */
-	int iDefault;			/* default value */
-	int iMask;			/* mask to apply */
-	int iData;			/* data for poke, result for peek */
-} TDBGBLOCK;
-
-/* Used to collect information about a circular block from the device driver */
-typedef struct TCircBlock {
-	unsigned int nArea;		/* the area to collect information from */
-	unsigned int dwOffset;		/* offset into the area to the available block */
-	unsigned int dwSize;		/* size of the area */
-} TCIRCBLOCK;
-
-/* Used to clollect the 1401 status */
-typedef struct TCSBlock {
-	unsigned int uiState;
-	unsigned int uiError;
-} TCSBLOCK;
-
-/*
- * As seen by the user, an ioctl call looks like: int ioctl(int fd, unsigned
- * long cmd, char* argp); We will then have all sorts of variants on this that
- * can be used to pass stuff to our driver. We will generate macros for each
- * type of call so as to provide some sort of type safety in the calling:
- */
-#define CED_MAGIC_IOC 0xce
-
-#define IOCTL_CED_SENDSTRING(n)		_IOC(_IOC_WRITE, CED_MAGIC_IOC, 2, n)
-
-#define IOCTL_CED_RESET1401		_IO(CED_MAGIC_IOC, 3)
-#define IOCTL_CED_GETCHAR		_IO(CED_MAGIC_IOC, 4)
-#define IOCTL_CED_SENDCHAR		_IO(CED_MAGIC_IOC, 5)
-#define IOCTL_CED_STAT1401		_IO(CED_MAGIC_IOC, 6)
-#define IOCTL_CED_LINECOUNT		_IO(CED_MAGIC_IOC, 7)
-#define IOCTL_CED_GETSTRING(nMax)	_IOC(_IOC_READ, CED_MAGIC_IOC, 8, nMax)
-
-#define IOCTL_CED_SETTRANSFER		_IOW(CED_MAGIC_IOC, 11, struct transfer_area_desc)
-#define IOCTL_CED_UNSETTRANSFER		_IO(CED_MAGIC_IOC, 12)
-#define IOCTL_CED_SETEVENT		_IOW(CED_MAGIC_IOC, 13, struct transfer_event)
-#define IOCTL_CED_GETOUTBUFSPACE	_IO(CED_MAGIC_IOC, 14)
-#define IOCTL_CED_GETBASEADDRESS	_IO(CED_MAGIC_IOC, 15)
-#define IOCTL_CED_GETDRIVERREVISION	_IO(CED_MAGIC_IOC, 16)
-
-#define IOCTL_CED_GETTRANSFER		_IOR(CED_MAGIC_IOC, 17, TGET_TX_BLOCK)
-#define IOCTL_CED_KILLIO1401		_IO(CED_MAGIC_IOC, 18)
-#define IOCTL_CED_BLKTRANSSTATE		_IO(CED_MAGIC_IOC, 19)
-
-#define IOCTL_CED_STATEOF1401		_IO(CED_MAGIC_IOC, 23)
-#define IOCTL_CED_GRAB1401		_IO(CED_MAGIC_IOC, 25)
-#define IOCTL_CED_FREE1401		_IO(CED_MAGIC_IOC, 26)
-#define IOCTL_CED_STARTSELFTEST		_IO(CED_MAGIC_IOC, 31)
-#define IOCTL_CED_CHECKSELFTEST		_IOR(CED_MAGIC_IOC, 32, TGET_SELFTEST)
-#define IOCTL_CED_TYPEOF1401		_IO(CED_MAGIC_IOC, 33)
-#define IOCTL_CED_TRANSFERFLAGS		_IO(CED_MAGIC_IOC, 34)
-
-#define IOCTL_CED_DBGPEEK		_IOW(CED_MAGIC_IOC, 35, TDBGBLOCK)
-#define IOCTL_CED_DBGPOKE		_IOW(CED_MAGIC_IOC, 36, TDBGBLOCK)
-#define IOCTL_CED_DBGRAMPDATA		_IOW(CED_MAGIC_IOC, 37, TDBGBLOCK)
-#define IOCTL_CED_DBGRAMPADDR		_IOW(CED_MAGIC_IOC, 38, TDBGBLOCK)
-#define IOCTL_CED_DBGGETDATA		_IOR(CED_MAGIC_IOC, 39, TDBGBLOCK)
-#define IOCTL_CED_DBGSTOPLOOP		_IO(CED_MAGIC_IOC, 40)
-#define IOCTL_CED_FULLRESET		_IO(CED_MAGIC_IOC, 41)
-#define IOCTL_CED_SETCIRCULAR		_IOW(CED_MAGIC_IOC, 42, struct transfer_area_desc)
-#define IOCTL_CED_GETCIRCBLOCK		_IOWR(CED_MAGIC_IOC, 43, TCIRCBLOCK)
-#define IOCTL_CED_FREECIRCBLOCK		_IOWR(CED_MAGIC_IOC, 44, TCIRCBLOCK)
-#define IOCTL_CED_WAITEVENT		_IO(CED_MAGIC_IOC, 45)
-#define IOCTL_CED_TESTEVENT		_IO(CED_MAGIC_IOC, 46)
-
-#ifndef __KERNEL__
-/*
- * If nothing said about return value, it is a U14ERR_... error code
- * (U14ERR_NOERROR for none)
- */
-inline int CED_SendString(int fh, const char *szText, int n)
-{
-	return ioctl(fh, IOCTL_CED_SENDSTRING(n), szText);
-}
-
-inline int CED_Reset1401(int fh)
-{
-	return ioctl(fh, IOCTL_CED_RESET1401);
-}
-
-/* Return the singe character or a -ve error code. */
-inline int CED_GetChar(int fh)
-{
-	return ioctl(fh, IOCTL_CED_GETCHAR);
-}
-
-/* Return character count in input buffer */
-inline int CED_Stat1401(int fh)
-{
-	return ioctl(fh, IOCTL_CED_STAT1401);
-}
-
-inline int CED_SendChar(int fh, char c)
-{
-	return ioctl(fh, IOCTL_CED_SENDCHAR, c);
-}
-
-inline int CED_LineCount(int fh)
-{
-	return ioctl(fh, IOCTL_CED_LINECOUNT);
-}
-
-/*
- * return the count of characters returned. If the string was terminated by CR
- * or 0, then the 0 is part of the count. Otherwise, we will add a zero if
- * there is room, but it is not included in the count.  The return value is 0
- * if there was nothing to read.
- */
-inline int CED_GetString(int fh, char *szText, int nMax)
-{
-	return ioctl(fh, IOCTL_CED_GETSTRING(nMax), szText);
-}
-
-/* returns space in the output buffer. */
-inline int CED_GetOutBufSpace(int fh)
-{
-	return ioctl(fh, IOCTL_CED_GETOUTBUFSPACE);
-}
-
-/* This always returns -1 as not implemented. */
-inline int CED_GetBaseAddress(int fh)
-{
-	return ioctl(fh, IOCTL_CED_GETBASEADDRESS);
-}
-
-/* returns the major revision <<16 | minor revision. */
-inline int CED_GetDriverRevision(int fh)
-{
-	return ioctl(fh, IOCTL_CED_GETDRIVERREVISION);
-}
-
-inline int CED_SetTransfer(int fh, struct transfer_area_desc *pTD)
-{
-	return ioctl(fh, IOCTL_CED_SETTRANSFER, pTD);
-}
-
-inline int CED_UnsetTransfer(int fh, int nArea)
-{
-	return ioctl(fh, IOCTL_CED_UNSETTRANSFER, nArea);
-}
-
-inline int CED_SetEvent(int fh, struct transfer_event *pTE)
-{
-	return ioctl(fh, IOCTL_CED_SETEVENT, pTE);
-}
-
-inline int CED_GetTransfer(int fh, TGET_TX_BLOCK *pTX)
-{
-	return ioctl(fh, IOCTL_CED_GETTRANSFER, pTX);
-}
-
-inline int CED_KillIO1401(int fh)
-{
-	return ioctl(fh, IOCTL_CED_KILLIO1401);
-}
-
-/* returns 0 if no active DMA, 1 if active */
-inline int CED_BlkTransState(int fh)
-{
-	return ioctl(fh, IOCTL_CED_BLKTRANSSTATE);
-}
-
-inline int CED_StateOf1401(int fh)
-{
-	return ioctl(fh, IOCTL_CED_STATEOF1401);
-}
-
-inline int CED_Grab1401(int fh)
-{
-	return ioctl(fh, IOCTL_CED_GRAB1401);
-}
-
-inline int CED_Free1401(int fh)
-{
-	return ioctl(fh, IOCTL_CED_FREE1401);
-}
-
-inline int CED_StartSelfTest(int fh)
-{
-	return ioctl(fh, IOCTL_CED_STARTSELFTEST);
-}
-
-inline int CED_CheckSelfTest(int fh, TGET_SELFTEST *pGST)
-{
-	return ioctl(fh, IOCTL_CED_CHECKSELFTEST, pGST);
-}
-
-inline int CED_TypeOf1401(int fh)
-{
-	return ioctl(fh, IOCTL_CED_TYPEOF1401);
-}
-
-inline int CED_TransferFlags(int fh)
-{
-	return ioctl(fh, IOCTL_CED_TRANSFERFLAGS);
-}
-
-inline int CED_DbgPeek(int fh, TDBGBLOCK *pDB)
-{
-	return ioctl(fh, IOCTL_CED_DBGPEEK, pDB);
-}
-
-inline int CED_DbgPoke(int fh, TDBGBLOCK *pDB)
-{
-	return ioctl(fh, IOCTL_CED_DBGPOKE, pDB);
-}
-
-inline int CED_DbgRampData(int fh, TDBGBLOCK *pDB)
-{
-	return ioctl(fh, IOCTL_CED_DBGRAMPDATA, pDB);
-}
-
-inline int CED_DbgRampAddr(int fh, TDBGBLOCK *pDB)
-{
-	return ioctl(fh, IOCTL_CED_DBGRAMPADDR, pDB);
-}
-
-inline int CED_DbgGetData(int fh, TDBGBLOCK *pDB)
-{
-	return ioctl(fh, IOCTL_CED_DBGGETDATA, pDB);
-}
-
-inline int CED_DbgStopLoop(int fh)
-{
-	return ioctl(fh, IOCTL_CED_DBGSTOPLOOP);
-}
-
-inline int CED_FullReset(int fh)
-{
-	return ioctl(fh, IOCTL_CED_FULLRESET);
-}
-
-inline int CED_SetCircular(int fh, struct transfer_area_desc *pTD)
-{
-	return ioctl(fh, IOCTL_CED_SETCIRCULAR, pTD);
-}
-
-inline int CED_GetCircBlock(int fh, TCIRCBLOCK *pCB)
-{
-	return ioctl(fh, IOCTL_CED_GETCIRCBLOCK, pCB);
-}
-
-inline int CED_FreeCircBlock(int fh, TCIRCBLOCK *pCB)
-{
-	return ioctl(fh, IOCTL_CED_FREECIRCBLOCK, pCB);
-}
-
-inline int CED_WaitEvent(int fh, int nArea, int msTimeOut)
-{
-	return ioctl(fh, IOCTL_CED_WAITEVENT, (nArea & 0xff)|(msTimeOut << 8));
-}
-
-inline int CED_TestEvent(int fh, int nArea)
-{
-	return ioctl(fh, IOCTL_CED_TESTEVENT, nArea);
-}
-#endif
-
-#ifdef NOTWANTEDYET
-#define IOCTL_CED_REGCALLBACK		_IO(CED_MAGIC_IOC, 9)	/* Not used */
-#define IOCTL_CED_GETMONITORBUF		_IO(CED_MAGIC_IOC, 10)	/* Not used */
-
-#define IOCTL_CED_BYTECOUNT		_IO(CED_MAGIC_IOC, 20)	/* Not used */
-#define IOCTL_CED_ZEROBLOCKCOUNT	_IO(CED_MAGIC_IOC, 21)	/* Not used */
-#define IOCTL_CED_STOPCIRCULAR		_IO(CED_MAGIC_IOC, 22)	/* Not used */
-
-#define IOCTL_CED_REGISTERS1401		_IO(CED_MAGIC_IOC, 24)	/* Not used */
-#define IOCTL_CED_STEP1401		_IO(CED_MAGIC_IOC, 27)	/* Not used */
-#define IOCTL_CED_SET1401REGISTERS	_IO(CED_MAGIC_IOC, 28)	/* Not used */
-#define IOCTL_CED_STEPTILL1401		_IO(CED_MAGIC_IOC, 29)	/* Not used */
-#define IOCTL_CED_SETORIN		_IO(CED_MAGIC_IOC, 30)	/* Not used */
-
-#endif
-
-/* __CED_IOCTL_H__ */
-#endif
diff --git a/drivers/staging/ced1401/machine.h b/drivers/staging/ced1401/machine.h
deleted file mode 100644
index dbd4036d..0000000
--- a/drivers/staging/ced1401/machine.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*****************************************************************************
-**
-** machine.h
-**
-** Copyright (c) Cambridge Electronic Design Limited 1991,1992,2010
-**
-** 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.
-**
-** 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-**
-** Contact CED: Cambridge Electronic Design Limited, Science Park, Milton Road
-**              Cambridge, CB6 0FE.
-**              www.ced.co.uk
-**              greg@ced.co.uk
-**
-** This file is included at the start of 'C' or 'C++' source file to define
-** things for cross-platform/compiler interoperability. This used to deal with
-** MSDOS/16-bit stuff, but this was all removed in Decemeber 2010. There are
-** three things to consider: Windows, LINUX, mac OSX (BSD Unix) and 32 vs 64
-** bit. At the time of writing (DEC 2010) there is a consensus on the following
-** and their unsigned equivalents:
-**
-** type       bits
-** char         8
-** short       16
-** int         32
-** long long   64
-**
-** long is a problem as it is always 64 bits on linux/unix and is always 32 bits
-** on windows.
-** On windows, we define _IS_WINDOWS_ and one of WIN32 or WIN64.
-** On linux we define LINUX
-** On Max OSX we define MACOSX
-**
-*/
-
-#ifndef __MACHINE_H__
-#define __MACHINE_H__
-#ifndef __KERNEL__
-#include <float.h>
-#include <limits.h>
-#endif
-
-/*
-** The initial section is to identify the operating system
-*/
-#if (defined(__linux__) || defined(_linux) || defined(__linux)) && !defined(LINUX)
-#define LINUX 1
-#endif
-
-#if (defined(__WIN32__) || defined(_WIN32)) && !defined(WIN32)
-#define WIN32 1
-#endif
-
-#if defined(__APPLE__)
-#define MACOSX
-#endif
-
-#if defined(_WIN64)
-#undef WIN32
-#undef WIN64
-#define WIN64 1
-#endif
-
-#if defined(WIN32) || defined(WIN64)
-#define _IS_WINDOWS_ 1
-#endif
-
-#if defined(LINUX) || defined(MAXOSX)
-	#define FAR
-
-	typedef int BOOL;       /*  To match Windows */
-	typedef unsigned char  BYTE;
-	#define __packed __attribute__((packed))
-	#define HIWORD(x) (unsigned short)(((x)>>16) & 0xffff)
-	#define LOWORD(x) (unsigned short)((x) & 0xffff)
-#endif
-
-#ifdef _IS_WINDOWS_
-#include <windows.h>
-#define __packed
-#endif
-
-/*
-** Sort out the DllExport and DllImport macros. The GCC compiler has its own
-** syntax for this, though it also supports the MS specific __declspec() as
-** a synonym.
-*/
-#ifdef GNUC
-	#define DllExport __attribute__((dllexport))
-	#define DllImport __attribute__((dllimport))
-#endif
-
-#ifndef DllExport
-#ifdef _IS_WINDOWS_
-	#define DllExport __declspec(dllexport)
-	#define DllImport __declspec(dllimport)
-#else
-	#define DllExport
-	#define DllImport
-#endif
-#endif /* _IS_WINDOWS_ */
-
-#ifndef TRUE
-   #define TRUE 1
-   #define FALSE 0
-#endif
-
-#endif
diff --git a/drivers/staging/ced1401/usb1401.c b/drivers/staging/ced1401/usb1401.c
deleted file mode 100644
index 9988677..0000000
--- a/drivers/staging/ced1401/usb1401.c
+++ /dev/null
@@ -1,1767 +0,0 @@
-/*******************************************************************************
- CED1401 usb driver. This basic loading is based on the usb-skeleton.c code that
- is:
- Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
- Copyright (C) 2012 Alois Schloegl <alois.schloegl@ist.ac.at>
- There is not a great deal of the skeleton left.
-
- All the remainder dealing specifically with the CED1401 is based on drivers
- written by CED for other systems (mainly Windows) and is:
- Copyright (C) 2010 Cambridge Electronic Design Ltd
- Author Greg P Smith (greg@ced.co.uk)
-
- 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.
-
- 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-
-Endpoints
-*********
-There are 4 endpoints plus the control endpoint in the standard interface
-provided by most 1401s. The control endpoint is used for standard USB requests,
-plus various CED-specific transactions such as start self test, debug and get
-the 1401 status. The other endpoints are:
-
- 1 Characters to the 1401
- 2 Characters from the 1401
- 3 Block data to the 1401
- 4 Block data to the host.
-
-inside the driver these are indexed as an array from 0 to 3, transactions
-over the control endpoint are carried out using a separate mechanism. The
-use of the endpoints is mostly straightforward, with the driver issuing
-IO request packets (IRPs) as required to transfer data to and from the 1401.
-The handling of endpoint 2 is different because it is used for characters
-from the 1401, which can appear spontaneously and without any other driver
-activity - for example to repeatedly request DMA transfers in Spike2. The
-desired effect is achieved by using an interrupt endpoint which can be
-polled to see if it has data available, and writing the driver so that it
-always maintains a pending read IRP from that endpoint which will read the
-character data and terminate as soon as the 1401 makes data available. This
-works very well, some care is taken with when you kick off this character
-read IRP to avoid it being active when it is not wanted but generally it
-is running all the time.
-
-In the 2270, there are only three endpoints plus the control endpoint. In
-addition to the transactions mentioned above, the control endpoint is used
-to transfer character data to the 1401. The other endpoints are used as:
-
- 1 Characters from the 1401
- 2 Block data to the 1401
- 3 Block data to the host.
-
-The type of interface available is specified by the interface subclass field
-in the interface descriptor provided by the 1401. See the USB_INT_ constants
-for the values that this field can hold.
-
-****************************************************************************
-Linux implementation
-
-Although Linux Device Drivers (3rd Edition) was a major source of information,
-it is very out of date. A lot of information was gleaned from the latest
-usb_skeleton.c code (you need to download the kernel sources to get this).
-
-To match the Windows version, everything is done using ioctl calls. All the
-device state is held in the struct ced_data.
-Block transfers are done by using get_user_pages() to pin down a list of
-pages that we hold a pointer to in the device driver. We also allocate a
-coherent transfer buffer of size STAGED_SZ (this must be a multiple of the
-bulk endpoint size so that the 1401 does not realise that we break large
-transfers down into smaller pieces). We use kmap_atomic() to get a kernel
-va for each page, as it is required, for copying; see ced_copy_user_space().
-
-All character and data transfers are done using asynchronous IO. All Urbs are
-tracked by anchoring them. Status and debug ioctls are implemented with the
-synchronous non-Urb based transfers.
-*/
-
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/usb.h>
-#include <linux/mutex.h>
-#include <linux/mm.h>
-#include <linux/highmem.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/kref.h>
-#include <linux/uaccess.h>
-
-#include "usb1401.h"
-
-/* Define these values to match your devices */
-#define USB_CED_VENDOR_ID	0x0525
-#define USB_CED_PRODUCT_ID	0xa0f0
-
-/* table of devices that work with this driver */
-static const struct usb_device_id ced_table[] = {
-	{USB_DEVICE(USB_CED_VENDOR_ID, USB_CED_PRODUCT_ID)},
-	{}			/* Terminating entry */
-};
-
-MODULE_DEVICE_TABLE(usb, ced_table);
-
-/* Get a minor range for your devices from the usb maintainer */
-#define USB_CED_MINOR_BASE	192
-
-/* our private defines. if this grows any larger, use your own .h file */
-#define MAX_TRANSFER		(PAGE_SIZE - 512)
-/* MAX_TRANSFER is chosen so that the VM is not stressed by
-   allocations > PAGE_SIZE and the number of packets in a page
-   is an integer 512 is the largest possible packet on EHCI */
-#define WRITES_IN_FLIGHT	8
-/* arbitrarily chosen */
-
-static struct usb_driver ced_driver;
-
-static void ced_delete(struct kref *kref)
-{
-	struct ced_data *ced = to_ced_data(kref);
-
-	/* Free up the output buffer, then free the output urb. Note that the */
-	/* interface member of ced will probably be NULL, so cannot be used   */
-	/* to get to dev. */
-	usb_free_coherent(ced->udev, OUTBUF_SZ, ced->coher_char_out,
-			  ced->urb_char_out->transfer_dma);
-	usb_free_urb(ced->urb_char_out);
-
-	/*  Do the same for chan input */
-	usb_free_coherent(ced->udev, INBUF_SZ, ced->coher_char_in,
-			  ced->urb_char_in->transfer_dma);
-	usb_free_urb(ced->urb_char_in);
-
-	/*  Do the same for the block transfers */
-	usb_free_coherent(ced->udev, STAGED_SZ, ced->coher_staged_io,
-			  ced->staged_urb->transfer_dma);
-	usb_free_urb(ced->staged_urb);
-
-	usb_put_dev(ced->udev);
-	kfree(ced);
-}
-
-/*  This is the driver end of the open() call from user space. */
-static int ced_open(struct inode *inode, struct file *file)
-{
-	struct ced_data *ced;
-	int retval = 0;
-	int subminor = iminor(inode);
-	struct usb_interface *interface =
-	    usb_find_interface(&ced_driver, subminor);
-	if (!interface) {
-		pr_err("%s - error, can't find device for minor %d", __func__,
-		       subminor);
-		retval = -ENODEV;
-		goto exit;
-	}
-
-	ced = usb_get_intfdata(interface);
-	if (!ced) {
-		retval = -ENODEV;
-		goto exit;
-	}
-
-	dev_dbg(&interface->dev, "%s: got ced\n", __func__);
-
-	/* increment our usage count for the device */
-	kref_get(&ced->kref);
-
-	/* lock the device to allow correctly handling errors
-	 * in resumption */
-	mutex_lock(&ced->io_mutex);
-
-	if (!ced->open_count++) {
-		retval = usb_autopm_get_interface(interface);
-		if (retval) {
-			ced->open_count--;
-			mutex_unlock(&ced->io_mutex);
-			kref_put(&ced->kref, ced_delete);
-			goto exit;
-		}
-	} else { /* uncomment this block if you want exclusive open */
-		dev_err(&interface->dev, "%s: fail: already open\n", __func__);
-		retval = -EBUSY;
-		ced->open_count--;
-		mutex_unlock(&ced->io_mutex);
-		kref_put(&ced->kref, ced_delete);
-		goto exit;
-	}
-	/* prevent the device from being autosuspended */
-
-	/* save our object in the file's private structure */
-	file->private_data = ced;
-	mutex_unlock(&ced->io_mutex);
-
-exit:
-	return retval;
-}
-
-static int ced_release(struct inode *inode, struct file *file)
-{
-	struct ced_data *ced = file->private_data;
-
-	if (ced == NULL)
-		return -ENODEV;
-
-	dev_dbg(&ced->interface->dev, "%s: called\n", __func__);
-	mutex_lock(&ced->io_mutex);
-	if (!--ced->open_count && ced->interface)	/*  Allow autosuspend */
-		usb_autopm_put_interface(ced->interface);
-	mutex_unlock(&ced->io_mutex);
-
-	/* decrement the count on our device */
-	kref_put(&ced->kref, ced_delete);
-	return 0;
-}
-
-static int ced_flush(struct file *file, fl_owner_t id)
-{
-	int res;
-	struct ced_data *ced = file->private_data;
-
-	if (ced == NULL)
-		return -ENODEV;
-
-	dev_dbg(&ced->interface->dev, "%s: char in pend=%d\n",
-		__func__, ced->read_chars_pending);
-
-	/* wait for io to stop */
-	mutex_lock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s: got io_mutex\n", __func__);
-	ced_draw_down(ced);
-
-	/* read out errors, leave subsequent opens a clean slate */
-	spin_lock_irq(&ced->err_lock);
-	res = ced->errors ? (ced->errors == -EPIPE ? -EPIPE : -EIO) : 0;
-	ced->errors = 0;
-	spin_unlock_irq(&ced->err_lock);
-
-	mutex_unlock(&ced->io_mutex);
-	dev_dbg(&ced->interface->dev, "%s: exit reached\n", __func__);
-
-	return res;
-}
-
-/***************************************************************************
-** can_accept_io_requests
-** If the device is removed, interface is set NULL. We also clear our pointer
-** from the interface, so we should make sure that ced is not NULL. This will
-** not help with a device extension held by a file.
-** return true if can accept new io requests, else false
-*/
-static bool can_accept_io_requests(struct ced_data *ced)
-{
-	return ced && ced->interface;	/*  Can we accept IO requests */
-}
-
-/****************************************************************************
-** Callback routine to complete writes. This may need to fire off another
-** urb to complete the transfer.
-****************************************************************************/
-static void ced_writechar_callback(struct urb *urb)
-{
-	struct ced_data *ced = urb->context;
-	int got = urb->actual_length;	/*  what we transferred */
-
-	if (urb->status) {	/*  sync/async unlink faults aren't errors */
-		if (!
-		    (urb->status == -ENOENT || urb->status == -ECONNRESET
-		     || urb->status == -ESHUTDOWN)) {
-			dev_err(&ced->interface->dev,
-				"%s: nonzero write bulk status received: %d\n",
-				__func__, urb->status);
-		}
-
-		spin_lock(&ced->err_lock);
-		ced->errors = urb->status;
-		spin_unlock(&ced->err_lock);
-		got = 0;	/*   and tidy up again if so */
-
-		spin_lock(&ced->char_out_lock);	/* already at irq level */
-		ced->out_buff_get = 0;	/*  Reset the output buffer */
-		ced->out_buff_put = 0;
-		ced->num_output = 0;	/*  Clear the char count */
-		ced->pipe_error[0] = 1;	/*  Flag an error for later */
-		ced->send_chars_pending = false; /* Allow other threads again */
-		spin_unlock(&ced->char_out_lock); /* already at irq level */
-		dev_dbg(&ced->interface->dev,
-			"%s: char out done, 0 chars sent\n", __func__);
-	} else {
-		dev_dbg(&ced->interface->dev,
-			"%s: char out done, %d chars sent\n", __func__, got);
-		spin_lock(&ced->char_out_lock);	/*  already at irq level */
-		ced->num_output -= got;	/*  Now adjust the char send buffer */
-		ced->out_buff_get += got;	/*  to match what we did */
-
-		/* Can't do this any earlier as data could be overwritten */
-		if (ced->out_buff_get >= OUTBUF_SZ)
-			ced->out_buff_get = 0;
-
-		if (ced->num_output > 0) {	/*  if more to be done... */
-			int pipe = 0;	/*  The pipe number to use */
-			int ret;
-			char *pDat = &ced->output_buffer[ced->out_buff_get];
-			/* maximum to send */
-			unsigned int count = ced->num_output;
-
-			/* does it cross buffer end? */
-			if ((ced->out_buff_get + count) > OUTBUF_SZ)
-				count = OUTBUF_SZ - ced->out_buff_get;
-
-			/* we are done with stuff that changes */
-			spin_unlock(&ced->char_out_lock);
-
-			/* copy output data to the buffer */
-			memcpy(ced->coher_char_out, pDat, count);
-			usb_fill_bulk_urb(ced->urb_char_out, ced->udev,
-					  usb_sndbulkpipe(ced->udev,
-							  ced->ep_addr[0]),
-					  ced->coher_char_out, count,
-					  ced_writechar_callback, ced);
-			ced->urb_char_out->transfer_flags |=
-			    URB_NO_TRANSFER_DMA_MAP;
-
-			/*  in case we need to kill it */
-			usb_anchor_urb(ced->urb_char_out, &ced->submitted);
-			ret = usb_submit_urb(ced->urb_char_out, GFP_ATOMIC);
-			dev_dbg(&ced->interface->dev, "%s: n=%d>%s<\n",
-				__func__, count, pDat);
-
-			/* grab lock for errors */
-			spin_lock(&ced->char_out_lock);
-
-			if (ret) {
-				/* Flag an error to be handled later */
-				ced->pipe_error[pipe] = 1;
-				/* Allow other threads again */
-				ced->send_chars_pending = false;
-				usb_unanchor_urb(ced->urb_char_out);
-				dev_err(&ced->interface->dev,
-					"%s: usb_submit_urb() returned %d\n",
-					__func__, ret);
-			}
-		} else
-			/* Allow other threads again */
-			ced->send_chars_pending = false;
-
-		spin_unlock(&ced->char_out_lock); /* already at irq level */
-	}
-}
-
-/****************************************************************************
-** ced_send_chars
-** Transmit the characters in the output buffer to the 1401. This may need
-** breaking down into multiple transfers.
-****************************************************************************/
-int ced_send_chars(struct ced_data *ced)
-{
-	int retval = U14ERR_NOERROR;
-
-	spin_lock_irq(&ced->char_out_lock);	/*  Protect ourselves */
-
-	if ((!ced->send_chars_pending) && /* Not currently sending */
-	    (ced->num_output > 0) &&	  /* has characters to output */
-	    (can_accept_io_requests(ced))) { /* and current activity is OK */
-		unsigned int count = ced->num_output;	/* Get a copy of the */
-							/* character count   */
-
-		/* Set flag to lock out other threads */
-		ced->send_chars_pending = true;
-
-		dev_dbg(&ced->interface->dev,
-			"Send %d chars to 1401, EP0 flag %d\n",
-			count, ced->n_pipes == 3);
-		/* If we have only 3 end points we must send the characters */
-		/* to the 1401 using EP0.				    */
-		if (ced->n_pipes == 3) {
-			/* For EP0 character transmissions to the 1401, we */
-			/* have to hang about until they are gone, as	   */
-			/* otherwise without more character IO activity    */
-			/* they will never go.				   */
-			unsigned int i = count;	/* Local char counter */
-			unsigned int index = 0;	/* The index into the */
-						/* char buffer        */
-
-			/* Free spinlock as we call USBD */
-			spin_unlock_irq(&ced->char_out_lock);
-
-			while ((i > 0) && (retval == U14ERR_NOERROR)) {
-				/* We have to break the transfer up into 64-byte chunks because of a 2270 problem */
-				int n = i > 64 ? 64 : i;	/*  Chars for this xfer, max of 64 */
-				int sent = usb_control_msg(ced->udev,
-							    usb_sndctrlpipe(ced->udev, 0),	/*  use end point 0 */
-							    DB_CHARS,	/*  bRequest */
-							    (H_TO_D | VENDOR | DEVREQ),	/*  to the device, vendor request to the device */
-							    0, 0,	/*  value and index are both 0 */
-							    &ced->output_buffer[index],	/*  where to send from */
-							    n,	/*  how much to send */
-							    1000);	/*  timeout in jiffies */
-				if (sent <= 0) {
-					/* if 0 chars says we timed out */
-					retval = sent ? sent : -ETIMEDOUT;
-					dev_err(&ced->interface->dev,
-						"Send %d chars by EP0 failed: %d\n",
-						n, retval);
-				} else {
-					dev_dbg(&ced->interface->dev,
-						"Sent %d chars by EP0\n", n);
-					i -= sent;
-					index += sent;
-				}
-			}
-
-			/* Protect ced changes, released by general code */
-			spin_lock_irq(&ced->char_out_lock);
-			ced->out_buff_get = 0; /* so reset the output buffer */
-			ced->out_buff_put = 0;
-			ced->num_output = 0;   /* and clear the buffer count */
-			/* Allow other threads again */
-			ced->send_chars_pending = false;
-		} else { /* Here for sending chars normally - we hold the */
-			 /* spin lock */
-			int pipe = 0;	/*  The pipe number to use */
-			char *pDat = &ced->output_buffer[ced->out_buff_get];
-
-			/* does it cross buffer end? */
-			if ((ced->out_buff_get + count) > OUTBUF_SZ)
-				count = OUTBUF_SZ - ced->out_buff_get;
-			/* we are done with stuff that changes */
-			spin_unlock_irq(&ced->char_out_lock);
-			/* copy output data to the buffer */
-			memcpy(ced->coher_char_out, pDat, count);
-			usb_fill_bulk_urb(ced->urb_char_out, ced->udev,
-					  usb_sndbulkpipe(ced->udev,
-							  ced->ep_addr[0]),
-					  ced->coher_char_out, count,
-					  ced_writechar_callback, ced);
-			ced->urb_char_out->transfer_flags |=
-			    URB_NO_TRANSFER_DMA_MAP;
-			usb_anchor_urb(ced->urb_char_out, &ced->submitted);
-			retval = usb_submit_urb(ced->urb_char_out, GFP_KERNEL);
-
-			 /* grab lock for errors */
-			spin_lock_irq(&ced->char_out_lock);
-
-			if (retval) {
-				/* Flag an error to be handled later */
-				ced->pipe_error[pipe] = 1;
-				/* Allow other threads again */
-				ced->send_chars_pending = false;
-				/* remove from list of active urbs */
-				usb_unanchor_urb(ced->urb_char_out);
-			}
-		}
-	} else if (ced->send_chars_pending && (ced->num_output > 0))
-		dev_dbg(&ced->interface->dev,
-			"%s: send_chars_pending:true\n", __func__);
-
-	dev_dbg(&ced->interface->dev, "%s: exit code: %d\n", __func__, retval);
-	spin_unlock_irq(&ced->char_out_lock); /* Now let go of the spinlock */
-	return retval;
-}
-
-/***************************************************************************
-** ced_copy_user_space
-** This moves memory between pinned down user space and the coher_staged_io
-** memory buffer we use for transfers. Copy n bytes in the directions that
-** is defined by ced->staged_read. The user space is determined by the area
-** in ced->staged_id and the offset in ced->staged_done. The user
-** area may well not start on a page boundary, so allow for that.
-**
-** We have a table of physical pages that describe the area, so we can use
-** this to get a virtual address that the kernel can use.
-**
-** ced  Is our device extension which holds all we know about the transfer.
-** n    The number of bytes to move one way or the other.
-***************************************************************************/
-static void ced_copy_user_space(struct ced_data *ced, int n)
-{
-	unsigned int area = ced->staged_id;
-
-	if (area < MAX_TRANSAREAS) {
-		/*  area to be used */
-		struct transarea *ta = &ced->trans_def[area];
-		unsigned int offset =
-		    ced->staged_done + ced->staged_offset + ta->base_offset;
-		char *coher_buf = ced->coher_staged_io;	/*  coherent buffer */
-
-		if (!ta->used) {
-			dev_err(&ced->interface->dev, "%s: area %d unused\n",
-				__func__, area);
-			return;
-		}
-
-		while (n) {
-			/*  page number in table */
-			int page = offset >> PAGE_SHIFT;
-
-			if (page < ta->n_pages) {
-				char *address =
-				    (char *)kmap_atomic(ta->pages[page]);
-				if (address) {
-					/* offset into the page */
-					unsigned int page_off =
-						offset & (PAGE_SIZE - 1);
-					/* max to transfer on this page */
-					size_t xfer = PAGE_SIZE - page_off;
-
-					/* limit byte count if too much */
-					/* for the page                 */
-					if (xfer > n)
-						xfer = n;
-					if (ced->staged_read)
-						memcpy(address + page_off,
-						       coher_buf, xfer);
-					else
-						memcpy(coher_buf,
-						       address + page_off,
-						       xfer);
-					kunmap_atomic(address);
-					offset += xfer;
-					coher_buf += xfer;
-					n -= xfer;
-				} else {
-					dev_err(&ced->interface->dev,
-						"%s: did not map page %d\n",
-						__func__, page);
-					return;
-				}
-
-			} else {
-				dev_err(&ced->interface->dev,
-					"%s: exceeded pages %d\n",
-					__func__, page);
-				return;
-			}
-		}
-	} else
-		dev_err(&ced->interface->dev, "%s: bad area %d\n",
-			__func__, area);
-}
-
-/*  Forward declarations for stuff used circularly */
-static int ced_stage_chunk(struct ced_data *ced);
-
-/***************************************************************************
-** ReadWrite_Complete
-**
-**  Completion routine for our staged read/write Irps
-*/
-static void staged_callback(struct urb *urb)
-{
-	struct ced_data *ced = urb->context;
-	unsigned int got = urb->actual_length;	/*  what we transferred */
-	bool cancel = false;
-	bool restart_char_input;	/*  used at the end */
-
-	spin_lock(&ced->staged_lock); /* stop ced_read_write_mem() action */
-				      /* while this routine is running    */
-
-	 /* clear the flag for staged IRP pending */
-	ced->staged_urb_pending = false;
-
-	if (urb->status) {	/*  sync/async unlink faults aren't errors */
-		if (!
-		    (urb->status == -ENOENT || urb->status == -ECONNRESET
-		     || urb->status == -ESHUTDOWN)) {
-			dev_err(&ced->interface->dev,
-				"%s: nonzero write bulk status received: %d\n",
-				__func__, urb->status);
-		} else
-			dev_info(&ced->interface->dev,
-				 "%s: staged xfer cancelled\n", __func__);
-
-		spin_lock(&ced->err_lock);
-		ced->errors = urb->status;
-		spin_unlock(&ced->err_lock);
-		got = 0;	/*   and tidy up again if so */
-		cancel = true;
-	} else {
-		dev_dbg(&ced->interface->dev, "%s: %d chars xferred\n",
-			__func__, got);
-		if (ced->staged_read)	/* if reading, save to user space */
-			/* copy from buffer to user */
-			ced_copy_user_space(ced, got);
-		if (got == 0)
-			dev_dbg(&ced->interface->dev, "%s: ZLP\n", __func__);
-	}
-
-	/* Update the transfer length based on the TransferBufferLength value */
-	/* in the URB                                                         */
-	ced->staged_done += got;
-
-	dev_dbg(&ced->interface->dev, "%s: done %d bytes of %d\n",
-		__func__, ced->staged_done, ced->staged_length);
-
-	if ((ced->staged_done == ced->staged_length) ||	/* If no more to do */
-	    (cancel)) {		/*  or this IRP was cancelled */
-		/*  Transfer area info */
-		struct transarea *ta = &ced->trans_def[ced->staged_id];
-
-		dev_dbg(&ced->interface->dev,
-			"%s: transfer done, bytes %d, cancel %d\n",
-			__func__, ced->staged_done, cancel);
-
-		/* Here is where we sort out what to do with this transfer if */
-		/* using a circular buffer. We have a completed transfer that */
-		/* can be assumed to fit into the transfer area. We should be */
-		/* able to add this to the end of a growing block or to use   */
-		/* it to start a new block unless the code that calculates    */
-		/* the offset to use (in ced_read_write_mem) is totally duff. */
-		if ((ta->circular) &&
-		    (ta->circ_to_host) &&
-		    (!cancel) && /* Time to sort out circular buffer info? */
-		    (ced->staged_read)) {/* Only for tohost transfers for now */
-			/* If block 1 is in use we must append to it */
-			if (ta->blocks[1].size > 0) {
-				if (ced->staged_offset ==
-				    (ta->blocks[1].offset +
-				     ta->blocks[1].size)) {
-					ta->blocks[1].size +=
-					    ced->staged_length;
-					dev_dbg(&ced->interface->dev,
-						"RWM_Complete, circ block 1 now %d bytes at %d\n",
-						ta->blocks[1].size,
-						ta->blocks[1].offset);
-				} else {
-					/* Here things have gone very, very */
-					/* wrong, but I cannot see how this */
-					/* can actually be achieved         */
-					ta->blocks[1].offset =
-					    ced->staged_offset;
-					ta->blocks[1].size =
-					    ced->staged_length;
-					dev_err(&ced->interface->dev,
-						"%s: ERROR, circ block 1 re-started %d bytes at %d\n",
-						__func__,
-						ta->blocks[1].size,
-						ta->blocks[1].offset);
-				}
-			} else { /* If block 1 is not used, we try to add */
-				 /*to block 0                             */
-
-				/* Got stored block 0 information? */
-				if (ta->blocks[0].size > 0) {
-					/*  Must append onto the */
-					/*existing block 0       */
-					if (ced->staged_offset ==
-					    (ta->blocks[0].offset +
-					     ta->blocks[0].size)) {
-						/* Just add this transfer in */
-						ta->blocks[0].size +=
-							ced->staged_length;
-						dev_dbg(&ced->interface->dev,
-							"RWM_Complete, circ block 0 now %d bytes at %d\n",
-							ta->blocks[0].size,
-							ta->blocks[0].offset);
-
-					} else { /* If it doesn't append, put */
-						 /* into new block 1          */
-						ta->blocks[1].offset =
-						    ced->staged_offset;
-						ta->blocks[1].size =
-						    ced->staged_length;
-						dev_dbg(&ced->interface->dev,
-							"RWM_Complete, circ block 1 started %d bytes at %d\n",
-							ta->blocks[1].size,
-							ta->blocks[1].offset);
-					}
-				} else	{ /* No info stored yet, just save */
-					  /* in block 0                    */
-					ta->blocks[0].offset =
-					    ced->staged_offset;
-					ta->blocks[0].size =
-					    ced->staged_length;
-					dev_dbg(&ced->interface->dev,
-						"RWM_Complete, circ block 0 started %d bytes at %d\n",
-						ta->blocks[0].size,
-						ta->blocks[0].offset);
-				}
-			}
-		}
-
-		if (!cancel) { /*  Don't generate an event if cancelled */
-			dev_dbg(&ced->interface->dev,
-				"RWM_Complete,  bCircular %d, bToHost %d, eStart %d, eSize %d\n",
-				ta->circular, ta->event_to_host,
-				ta->event_st, ta->event_sz);
-			/* Set a user-mode event...           */
-			/* ...on transfers in this direction? */
-			if ((ta->event_sz) &&
-			    (ced->staged_read == ta->event_to_host)) {
-				int wakeup = 0; /* assume */
-
-				/* If we have completed the right sort of DMA */
-				/* transfer then set the event to notify the  */
-				/* user code to wake up anyone that is        */
-				/* waiting. */
-				if ((ta->circular) && /* Circular areas use a
-							 simpler test */
-				    (ta->circ_to_host)) { /* only in supported
-							     direction */
-					/* Is total data waiting up */
-					/* to size limit? */
-					unsigned int dwTotal =
-					    ta->blocks[0].size +
-					    ta->blocks[1].size;
-					wakeup = (dwTotal >= ta->event_sz);
-				} else {
-					unsigned int transEnd =
-					    ced->staged_offset +
-					    ced->staged_length;
-					unsigned int eventEnd =
-					    ta->event_st + ta->event_sz;
-					wakeup = (ced->staged_offset < eventEnd)
-					    && (transEnd > ta->event_st);
-				}
-
-				if (wakeup) {
-					dev_dbg(&ced->interface->dev,
-					  "About to set event to notify app\n");
-
-					/*  wake up waiting processes */
-					wake_up_interruptible(&ta->event);
-					/* increment wakeup count */
-					++ta->wake_up;
-				}
-			}
-		}
-
-		/* Switch back to char mode before ced_read_write_mem call */
-		ced->dma_flag = MODE_CHAR;
-
-		 /* Don't look for waiting transfer if cancelled */
-		if (!cancel) {
-			/*  If we have a transfer waiting, kick it off */
-			if (ced->xfer_waiting) {/*  Got a block xfer waiting? */
-				int retval;
-
-				dev_info(&ced->interface->dev,
-					 "*** RWM_Complete *** pending transfer will now be set up!!!\n");
-				retval =
-				    ced_read_write_mem(ced,
-						       !ced->dma_info.outward,
-						       ced->dma_info.ident,
-						       ced->dma_info.offset,
-						       ced->dma_info.size);
-
-				if (retval)
-					dev_err(&ced->interface->dev,
-						"RWM_Complete rw setup failed %d\n",
-						retval);
-			}
-		}
-
-	} else			/*  Here for more to do */
-		ced_stage_chunk(ced);	/*  fire off the next bit */
-
-	/* While we hold the staged_lock, see if we should reallow character */
-	/* input ints                                                        */
-	/* Don't allow if cancelled, or if a new block has started or if     */
-	/* there is a waiting block.                                         */
-	/* This feels wrong as we should ask which spin lock protects        */
-	/* dma_flag. */
-	restart_char_input = !cancel && (ced->dma_flag == MODE_CHAR) &&
-			     !ced->xfer_waiting;
-
-	spin_unlock(&ced->staged_lock);	/*  Finally release the lock again */
-
-	/* This is not correct as dma_flag is protected by the staged lock, */
-	/* but it is treated in ced_allowi as if it were protected by the   */
-	/* char lock. In any case, most systems will not be upset by char   */
-	/* input during DMA... sigh. Needs sorting out.                     */
-	if (restart_char_input)	/*  may be out of date, but... */
-		ced_allowi(ced);	/*  ...ced_allowi tests a lock too. */
-	dev_dbg(&ced->interface->dev, "%s: done\n", __func__);
-}
-
-/****************************************************************************
-** ced_stage_chunk
-**
-** Generates the next chunk of data making up a staged transfer.
-**
-** The calling code must have acquired the staging spinlock before calling
-** this function, and is responsible for releasing it. We are at callback level.
-****************************************************************************/
-static int ced_stage_chunk(struct ced_data *ced)
-{
-	int retval = U14ERR_NOERROR;
-	unsigned int chunk_size;
-	int pipe = ced->staged_read ? 3 : 2; /* The pipe number to use for */
-					     /* reads or writes            */
-
-	if (ced->n_pipes == 3)
-		pipe--;	/* Adjust for the 3-pipe case */
-
-	if (pipe < 0)   /* and trap case that should never happen */
-		return U14ERR_FAIL;
-
-	if (!can_accept_io_requests(ced)) {	/*  got sudden remove? */
-		dev_info(&ced->interface->dev, "%s: sudden remove, giving up\n",
-			 __func__);
-		return U14ERR_FAIL;	/*  could do with a better error */
-	}
-
-	/* transfer length remaining */
-	chunk_size = (ced->staged_length - ced->staged_done);
-	if (chunk_size > STAGED_SZ)	/*  make sure to keep legal */
-		chunk_size = STAGED_SZ;	/*   limit to max allowed */
-
-	if (!ced->staged_read)	/*  if writing... */
-		/* ...copy data into the buffer */
-		ced_copy_user_space(ced, chunk_size);
-
-	usb_fill_bulk_urb(ced->staged_urb, ced->udev,
-			  ced->staged_read ? usb_rcvbulkpipe(ced->udev,
-							    ced->
-							    ep_addr[pipe]) :
-			  usb_sndbulkpipe(ced->udev, ced->ep_addr[pipe]),
-					  ced->coher_staged_io, chunk_size,
-					  staged_callback, ced);
-	ced->staged_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-	/* in case we need to kill it */
-	usb_anchor_urb(ced->staged_urb, &ced->submitted);
-	retval = usb_submit_urb(ced->staged_urb, GFP_ATOMIC);
-	if (retval) {
-		usb_unanchor_urb(ced->staged_urb);	/*  kill it */
-		ced->pipe_error[pipe] = 1; /* Flag an error to be */
-					   /* handled later       */
-		dev_err(&ced->interface->dev,
-			"%s: submit urb failed, code %d\n",
-			__func__, retval);
-	} else
-		/* Set the flag for staged URB pending */
-		ced->staged_urb_pending = true;
-	dev_dbg(&ced->interface->dev, "%s: done so far:%d, this size:%d\n",
-		__func__, ced->staged_done, chunk_size);
-
-	return retval;
-}
-
-/***************************************************************************
-** ced_read_write_mem
-**
-** This routine is used generally for block read and write operations.
-** Breaks up a read or write in to specified sized chunks, as specified by pipe
-** information on maximum transfer size.
-**
-** Any code that calls this must be holding the staged_lock
-**
-** Arguments:
-**    DeviceObject - pointer to our FDO (Functional Device Object)
-**    read - TRUE for read, FALSE for write. This is from POV of the driver
-**    ident - the transfer area number - defines memory area and more.
-**    offs - the start offset within the transfer area of the start of this
-**             transfer.
-**    len - the number of bytes to transfer.
-*/
-int ced_read_write_mem(struct ced_data *ced, bool read, unsigned short ident,
-		 unsigned int offs, unsigned int len)
-{
-	/* Transfer area info */
-	struct transarea *ta = &ced->trans_def[ident];
-
-	/*  Are we in a state to accept new requests? */
-	if (!can_accept_io_requests(ced)) {
-		dev_err(&ced->interface->dev, "%s: can't accept requests\n",
-			__func__);
-		return U14ERR_FAIL;
-	}
-
-	dev_dbg(&ced->interface->dev,
-		"%s: xfer %d bytes to %s, offset %d, area %d\n",
-		__func__, len, read ? "host" : "1401", offs, ident);
-
-	/* Amazingly, we can get an escape sequence back before the current   */
-	/* staged Urb is done, so we have to check for this situation and, if */
-	/* so, wait until all is OK. */
-	if (ced->staged_urb_pending) {
-		ced->xfer_waiting = true;	/*  Flag we are waiting */
-		dev_info(&ced->interface->dev,
-			 "%s: xfer is waiting, as previous staged pending\n",
-			 __func__);
-		return U14ERR_NOERROR;
-	}
-
-	if (len == 0) {	/* allow 0-len read or write; just return success */
-		dev_dbg(&ced->interface->dev,
-			"%s: OK; zero-len read/write request\n", __func__);
-		return U14ERR_NOERROR;
-	}
-
-	if ((ta->circular) &&	/*  Circular transfer? */
-	    (ta->circ_to_host) && (read)) {	/*  In a supported direction */
-				/*  If so, we sort out offset ourself */
-		bool bWait = false;	/*  Flag for transfer having to wait */
-
-		dev_dbg(&ced->interface->dev,
-			"Circular buffers are %d at %d and %d at %d\n",
-			ta->blocks[0].size, ta->blocks[0].offset,
-			ta->blocks[1].size, ta->blocks[1].offset);
-
-		/* Using the second block already? */
-		if (ta->blocks[1].size > 0) {
-			/* take offset from that */
-			offs = ta->blocks[1].offset + ta->blocks[1].size;
-			/* Wait if will overwrite block 0? */
-			bWait = (offs + len) > ta->blocks[0].offset;
-			/* or if it overflows the buffer */
-			bWait |= (offs + len) > ta->length;
-		} else {	/*  Area 1 not in use, try to use area 0 */
-			/* Reset block 0 if not in use */
-			if (ta->blocks[0].size == 0)
-				ta->blocks[0].offset = 0;
-			offs =
-			    ta->blocks[0].offset +
-			    ta->blocks[0].size;
-			 /* Off the end of the buffer? */
-			if ((offs + len) > ta->length) {
-				/* Set up to use second block */
-				ta->blocks[1].offset = 0;
-				offs = 0;
-				/* Wait if will overwrite block 0? */
-				bWait = (offs + len) > ta->blocks[0].offset;
-				/* or if it overflows the buffer */
-				bWait |= (offs + len) > ta->length;
-			}
-		}
-
-		if (bWait) {	/*  This transfer will have to wait? */
-			ced->xfer_waiting = true;      /* Flag we are waiting */
-			dev_dbg(&ced->interface->dev,
-				"%s: xfer waiting for circular buffer space\n",
-				__func__);
-			return U14ERR_NOERROR;
-		}
-
-		dev_dbg(&ced->interface->dev,
-			"%s: circular xfer, %d bytes starting at %d\n",
-			__func__, len, offs);
-	}
-	/*  Save the parameters for the read\write transfer */
-	ced->staged_read = read;	/*  Save the parameters for this read */
-	ced->staged_id = ident;	/*  ID allows us to get transfer area info */
-	ced->staged_offset = offs;	/*  The area within the transfer area */
-	ced->staged_length = len;
-	ced->staged_done = 0;	/*  Initialise the byte count */
-	ced->dma_flag = MODE_LINEAR;	/*  Set DMA mode flag at this point */
-	ced->xfer_waiting = false;      /* Clearly not a transfer waiting now */
-
-/*     KeClearEvent(&ced->StagingDoneEvent); // Clear the transfer done event */
-	ced_stage_chunk(ced);	/*  fire off the first chunk */
-
-	return U14ERR_NOERROR;
-}
-
-/****************************************************************************
-**
-** ced_read_char
-**
-** Reads a character a buffer. If there is no more
-**  data we return FALSE. Used as part of decoding a DMA request.
-**
-****************************************************************************/
-static bool ced_read_char(unsigned char *character, char *buf,
-			  unsigned int *n_done, unsigned int got)
-{
-	bool read = false;
-	unsigned int done = *n_done;
-
-	if (done < got) {	/* If there is more data */
-		/* Extract the next char */
-		*character = (unsigned char)buf[done];
-		done++;	/* Increment the done count */
-		*n_done = done;
-		read = true;	/* and flag success */
-	}
-
-	return read;
-}
-
-#ifdef NOTUSED
-/****************************************************************************
-**
-** ced_read_word
-**
-** Reads a word from the 1401, just uses ced_read_char twice;
-** passes on any error
-**
-*****************************************************************************/
-static bool ced_read_word(unsigned short *word, char *buf, unsigned int *n_done,
-		     unsigned int got)
-{
-	if (ced_read_char((unsigned char *)word, buf, n_done, got))
-		return ced_read_char(((unsigned char *)word) + 1, buf, n_done,
-				got);
-	else
-		return false;
-}
-#endif
-
-/****************************************************************************
-** ced_read_huff
-**
-** Reads a coded number in and returns it, Code is:
-** If data is in range 0..127 we receive 1 byte. If data in range 128-16383
-** we receive two bytes, top bit of first indicates another on its way. If
-** data in range 16384-4194303 we get three bytes, top two bits of first set
-** to indicate three byte total.
-**
-*****************************************************************************/
-static bool ced_read_huff(volatile unsigned int *word, char *buf,
-		     unsigned int *n_done, unsigned int got)
-{
-	unsigned char c;	/* for each read to ced_read_char */
-	bool retval = true;	/* assume we will succeed */
-	unsigned int data = 0;	/* Accumulator for the data */
-
-	if (ced_read_char(&c, buf, n_done, got)) {
-		data = c;	/* copy the data */
-		if ((data & 0x00000080) != 0) {	/* Bit set for more data ? */
-			data &= 0x0000007F;	/* Clear the relevant bit */
-			if (ced_read_char(&c, buf, n_done, got)) {
-				data = (data << 8) | c;
-
-				/* three byte sequence ? */
-				if ((data & 0x00004000) != 0) {
-					/* Clear the relevant bit */
-					data &= 0x00003FFF;
-					if (ced_read_char
-					    (&c, buf, n_done, got))
-						data = (data << 8) | c;
-					else
-						retval = false;
-				}
-			} else
-				retval = false;	/* couldn't read data */
-		}
-	} else
-		retval = false;
-
-	*word = data;	/* return the data */
-	return retval;
-}
-
-/***************************************************************************
-**
-** ced_read_dma_info
-**
-** Tries to read info about the dma request from the 1401 and decode it into
-** the dma descriptor block. We have at this point had the escape character
-** from the 1401 and now we must read in the rest of the information about
-** the transfer request. Returns FALSE if 1401 fails to respond or obselete
-** code from 1401 or bad parameters.
-**
-** The buf char pointer does not include the initial escape character, so
-**  we start handling the data at offset zero.
-**
-*****************************************************************************/
-static bool ced_read_dma_info(volatile struct dmadesc *dma_desc,
-			      struct ced_data *ced,
-			      char *buf, unsigned int count)
-{
-	bool retval = false;	/*  assume we won't succeed */
-	unsigned char c;
-	unsigned int n_done = 0;	/*  We haven't parsed anything so far */
-
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-
-	if (ced_read_char(&c, buf, &n_done, count)) {
-		/* get code for transfer type */
-		unsigned char trans_code = (c & 0x0F);
-		/* and area identifier */
-		unsigned short ident = ((c >> 4) & 0x07);
-
-		/*  fill in the structure we were given */
-		dma_desc->trans_type = trans_code;	/*  type of transfer */
-		dma_desc->ident = ident;	/*  area to use */
-		dma_desc->size = 0;	/*  initialise other bits */
-		dma_desc->offset = 0;
-
-		dev_dbg(&ced->interface->dev, "%s: type: %d ident: %d\n",
-			__func__, dma_desc->trans_type, dma_desc->ident);
-
-		/* set transfer direction */
-		dma_desc->outward = (trans_code != TM_EXTTOHOST);
-
-		switch (trans_code) {
-
-		/* Extended linear transfer modes (the only ones!) */
-		case TM_EXTTOHOST:
-		case TM_EXTTO1401:
-			{
-				retval =
-				    ced_read_huff(&(dma_desc->offset), buf,
-					     &n_done, count)
-				    && ced_read_huff(&(dma_desc->size), buf,
-						&n_done, count);
-				if (retval) {
-					dev_dbg(&ced->interface->dev,
-						"%s: xfer offset & size %d %d\n",
-						__func__, dma_desc->offset,
-						dma_desc->size);
-
-					if ((ident >= MAX_TRANSAREAS) ||	/*  Illegal area number, or... */
-					    (!ced->trans_def[ident].used) ||	/*  area not set up, or... */
-					    (dma_desc->offset > ced->trans_def[ident].length) ||	/*  range/size */
-					    ((dma_desc->offset +
-					      dma_desc->size) >
-					     (ced->trans_def[ident].length))) {
-						/* bad parameter(s) */
-						retval = false;
-						dev_dbg(&ced->interface->dev,
-							"%s: bad param - id %d, bUsed %d, offset %d, size %d, area length %d\n",
-							__func__, ident,
-							ced->trans_def[ident].
-							used,
-							dma_desc->offset,
-							dma_desc->size,
-							ced->trans_def[ident].
-							length);
-					}
-				}
-				break;
-			}
-		default:
-			break;
-		}
-	} else
-		retval = false;
-
-	if (!retval)		/*  now check parameters for validity */
-		dev_err(&ced->interface->dev,
-			"%s: error reading Esc sequence\n",
-			__func__);
-
-	return retval;
-}
-
-/****************************************************************************
-**
-** ced_handle_esc
-**
-** Deals with an escape sequence coming from the 1401. This can either be
-**  a DMA transfer request of various types or a response to an escape sequence
-**  sent to the 1401. This is called from a callback.
-**
-** Parameters are
-**
-** count - the number of characters in the device extension char in buffer,
-**           this is known to be at least 2 or we will not be called.
-**
-****************************************************************************/
-static int ced_handle_esc(struct ced_data *ced, char *ch,
-			 unsigned int count)
-{
-	int retval = U14ERR_FAIL;
-
-	/* I have no idea what this next test is about. '?' is 0x3f, which is */
-	/* area 3, code 15. At the moment, this is not used, so it does no    */
-	/* harm, but unless someone can tell me what this is for, it should   */
-	/* be removed from this and the Windows driver. */
-	if (ch[0] == '?') {	/*  Is this an information response */
-				/*  Parse and save the information */
-	} else {
-		spin_lock(&ced->staged_lock);	/*  Lock others out */
-
-		/* Get DMA parameters */
-		if (ced_read_dma_info(&ced->dma_info, ced, ch, count)) {
-			/* check transfer type */
-			unsigned short trans_type = ced->dma_info.trans_type;
-
-			dev_dbg(&ced->interface->dev,
-				"%s: xfer to %s, offset %d, length %d\n",
-				__func__,
-				ced->dma_info.outward ? "1401" : "host",
-				ced->dma_info.offset, ced->dma_info.size);
-
-			/* Check here for badly out of kilter... */
-			if (ced->xfer_waiting) {
-				/*  This can never happen, really */
-				dev_err(&ced->interface->dev,
-					"ERROR: DMA setup while transfer still waiting\n");
-			} else {
-				if ((trans_type == TM_EXTTOHOST)
-				    || (trans_type == TM_EXTTO1401)) {
-					retval =
-					    ced_read_write_mem(ced,
-							 !ced->dma_info.outward,
-							 ced->dma_info.ident,
-							 ced->dma_info.offset,
-							 ced->dma_info.size);
-					if (retval != U14ERR_NOERROR)
-						dev_err(&ced->interface->dev,
-							"%s: ced_read_write_mem() failed %d\n",
-							__func__, retval);
-				} else	/* This covers non-linear
-					   transfer setup */
-					dev_err(&ced->interface->dev,
-						"%s: Unknown block xfer type %d\n",
-						__func__, trans_type);
-			}
-		} else		/*  Failed to read parameters */
-			dev_err(&ced->interface->dev, "%s: ced_read_dma_info() fail\n",
-				__func__);
-
-		spin_unlock(&ced->staged_lock);	/*  OK here */
-	}
-
-	dev_dbg(&ced->interface->dev, "%s: returns %d\n", __func__, retval);
-
-	return retval;
-}
-
-/****************************************************************************
-** Callback for the character read complete or error
-****************************************************************************/
-static void ced_readchar_callback(struct urb *urb)
-{
-	struct ced_data *ced = urb->context;
-	int got = urb->actual_length;	/*  what we transferred */
-
-	if (urb->status) {	/*  Do we have a problem to handle? */
-		/* The pipe number to use for error */
-		int pipe = ced->n_pipes == 4 ? 1 : 0;
-		/* sync/async unlink faults aren't errors... */
-		/* just saying device removed or stopped     */
-		if (!
-		    (urb->status == -ENOENT || urb->status == -ECONNRESET
-		     || urb->status == -ESHUTDOWN)) {
-			dev_err(&ced->interface->dev,
-				"%s: nonzero write bulk status received: %d\n",
-				__func__, urb->status);
-		} else
-			dev_dbg(&ced->interface->dev,
-				"%s: 0 chars urb->status=%d (shutdown?)\n",
-				__func__, urb->status);
-
-		spin_lock(&ced->err_lock);
-		ced->errors = urb->status;
-		spin_unlock(&ced->err_lock);
-		got = 0;	/*   and tidy up again if so */
-
-		spin_lock(&ced->char_in_lock);	/*  already at irq level */
-		ced->pipe_error[pipe] = 1;	/*  Flag an error for later */
-	} else {
-		/* Esc sequence? */
-		if ((got > 1) && ((ced->coher_char_in[0] & 0x7f) == 0x1b)) {
-			/* handle it */
-			ced_handle_esc(ced, &ced->coher_char_in[1], got - 1);
-
-			/* already at irq level */
-			spin_lock(&ced->char_in_lock);
-		} else {
-			/* already at irq level */
-			spin_lock(&ced->char_in_lock);
-
-			if (got > 0) {
-				unsigned int i;
-
-				if (got < INBUF_SZ) {
-					/* tidy the string */
-					ced->coher_char_in[got] = 0;
-					dev_dbg(&ced->interface->dev,
-						"%s: got %d chars >%s<\n",
-						__func__, got,
-						ced->coher_char_in);
-				}
-				/* We know that whatever we read must fit */
-				/* in the input buffer                    */
-				for (i = 0; i < got; i++) {
-					ced->input_buffer[ced->in_buff_put++] =
-					    ced->coher_char_in[i] & 0x7F;
-					if (ced->in_buff_put >= INBUF_SZ)
-						ced->in_buff_put = 0;
-				}
-
-				if ((ced->num_input + got) <= INBUF_SZ)
-					/* Adjust the buffer count */
-					/* accordingly		   */
-					ced->num_input += got;
-			} else
-				dev_dbg(&ced->interface->dev, "%s: read ZLP\n",
-					__func__);
-		}
-	}
-
-	ced->read_chars_pending = false;  /* No longer have a pending read */
-	spin_unlock(&ced->char_in_lock);  /*  already at irq level */
-
-	ced_allowi(ced);	/*  see if we can do the next one */
-}
-
-/****************************************************************************
-** ced_allowi
-**
-** This is used to make sure that there is always a pending input transfer so
-** we can pick up any inward transfers. This can be called in multiple contexts
-** so we use the irqsave version of the spinlock.
-****************************************************************************/
-int ced_allowi(struct ced_data *ced)
-{
-	int retval = U14ERR_NOERROR;
-	unsigned long flags;
-
-	/* can be called in multiple contexts */
-	spin_lock_irqsave(&ced->char_in_lock, flags);
-
-	/* We don't want char input running while DMA is in progress as we    */
-	/* know that this can cause sequencing problems for the 2270. So      */
-	/* don't. It will also allow the ERR response to get back to the host */
-	/* code too early on some PCs, even if there is no actual driver      */
-	/* failure, so we don't allow this at all. */
-	if (!ced->in_draw_down &&	/* stop input if */
-	    !ced->read_chars_pending &&	/* If no read request outstanding */
-	    (ced->num_input < (INBUF_SZ / 2)) && /*  and there is some space */
-	    (ced->dma_flag == MODE_CHAR) &&	/*   not doing any DMA */
-	    (!ced->xfer_waiting) &&               /* no xfer waiting to start */
-	    (can_accept_io_requests(ced))) { /* and activity is generally OK */
-				/*   then off we go */
-		/* max we could read */
-		unsigned int max = INBUF_SZ - ced->num_input;
-		/* The pipe number to use */
-		int pipe = ced->n_pipes == 4 ? 1 : 0;
-
-		dev_dbg(&ced->interface->dev, "%s: %d chars in input buffer\n",
-			__func__, ced->num_input);
-
-		usb_fill_int_urb(ced->urb_char_in, ced->udev,
-				 usb_rcvintpipe(ced->udev, ced->ep_addr[pipe]),
-				 ced->coher_char_in, max, ced_readchar_callback,
-				 ced, ced->interval);
-
-		/* short xfers are OK by default */
-		ced->urb_char_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-
-		/* in case we need to kill it */
-		usb_anchor_urb(ced->urb_char_in, &ced->submitted);
-
-		retval = usb_submit_urb(ced->urb_char_in, GFP_ATOMIC);
-		if (retval) {
-			/* remove from list of active Urbs */
-			usb_unanchor_urb(ced->urb_char_in);
-			/* Flag an error to be handled later */
-			ced->pipe_error[pipe] = 1;
-			dev_err(&ced->interface->dev,
-				"%s: submit urb failed: %d\n",
-				__func__, retval);
-		} else
-			/* Flag that we are active here */
-			ced->read_chars_pending = true;
-	}
-
-	spin_unlock_irqrestore(&ced->char_in_lock, flags);
-
-	return retval;
-}
-
-/*****************************************************************************
-** The ioctl entry point to the driver that is used by us to talk to it.
-** inode    The device node (no longer in 3.0.0 kernels)
-** file     The file that is open, which holds our ced pointer
-** arg    The argument passed in. Note that long is 64-bits in 64-bit system,
-**        i.e. it is big enough for a 64-bit pointer.
-*****************************************************************************/
-static long ced_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	int err = 0;
-	struct ced_data *ced = file->private_data;
-
-	if (!can_accept_io_requests(ced))	/*  check we still exist */
-		return -ENODEV;
-
-	/* Check that access is allowed, where is is needed. Anything that */
-	/* would have an indeterminate size will be checked by the         */
-	/* specific command.						   */
-	if (_IOC_DIR(cmd) & _IOC_READ) /* read from point of view of user... */
-		/* is kernel write */
-		err = !access_ok(VERIFY_WRITE,
-				 (void __user *)arg, _IOC_SIZE(cmd));
-	else if (_IOC_DIR(cmd) & _IOC_WRITE) /* and write from point of */
-					     /* view of user...         */
-		/* is kernel read */
-		err = !access_ok(VERIFY_READ,
-				 (void __user *)arg, _IOC_SIZE(cmd));
-	if (err)
-		return -EFAULT;
-
-	switch (_IOC_NR(cmd)) {
-	case _IOC_NR(IOCTL_CED_SENDSTRING(0)):
-		return ced_send_string(ced, (const char __user *)arg,
-				  _IOC_SIZE(cmd));
-
-	case _IOC_NR(IOCTL_CED_RESET1401):
-		return ced_reset(ced);
-
-	case _IOC_NR(IOCTL_CED_GETCHAR):
-		return ced_get_char(ced);
-
-	case _IOC_NR(IOCTL_CED_SENDCHAR):
-		return ced_send_char(ced, (char)arg);
-
-	case _IOC_NR(IOCTL_CED_STAT1401):
-		return ced_stat_1401(ced);
-
-	case _IOC_NR(IOCTL_CED_LINECOUNT):
-		return ced_line_count(ced);
-
-	case _IOC_NR(IOCTL_CED_GETSTRING(0)):
-		return ced_get_string(ced, (char __user *)arg, _IOC_SIZE(cmd));
-
-	case _IOC_NR(IOCTL_CED_SETTRANSFER):
-		return ced_set_transfer(ced,
-				(struct transfer_area_desc __user *) arg);
-
-	case _IOC_NR(IOCTL_CED_UNSETTRANSFER):
-		return ced_unset_transfer(ced, (int)arg);
-
-	case _IOC_NR(IOCTL_CED_SETEVENT):
-		return ced_set_event(ced,
-				     (struct transfer_event __user *) arg);
-
-	case _IOC_NR(IOCTL_CED_GETOUTBUFSPACE):
-		return ced_get_out_buf_space(ced);
-
-	case _IOC_NR(IOCTL_CED_GETBASEADDRESS):
-		return -1;
-
-	case _IOC_NR(IOCTL_CED_GETDRIVERREVISION):
-		/* USB | MAJOR | MINOR */
-		return (2 << 24) | (DRIVERMAJREV << 16) | DRIVERMINREV;
-
-	case _IOC_NR(IOCTL_CED_GETTRANSFER):
-		return ced_get_transfer(ced, (TGET_TX_BLOCK __user *) arg);
-
-	case _IOC_NR(IOCTL_CED_KILLIO1401):
-		return ced_kill_io(ced);
-
-	case _IOC_NR(IOCTL_CED_STATEOF1401):
-		return ced_state_of_1401(ced);
-
-	case _IOC_NR(IOCTL_CED_GRAB1401):
-	case _IOC_NR(IOCTL_CED_FREE1401):
-		return U14ERR_NOERROR;
-
-	case _IOC_NR(IOCTL_CED_STARTSELFTEST):
-		return ced_start_self_test(ced);
-
-	case _IOC_NR(IOCTL_CED_CHECKSELFTEST):
-		return ced_check_self_test(ced, (TGET_SELFTEST __user *) arg);
-
-	case _IOC_NR(IOCTL_CED_TYPEOF1401):
-		return ced_type_of_1401(ced);
-
-	case _IOC_NR(IOCTL_CED_TRANSFERFLAGS):
-		return ced_transfer_flags(ced);
-
-	case _IOC_NR(IOCTL_CED_DBGPEEK):
-		return ced_dbg_peek(ced, (TDBGBLOCK __user *) arg);
-
-	case _IOC_NR(IOCTL_CED_DBGPOKE):
-		return ced_dbg_poke(ced, (TDBGBLOCK __user *) arg);
-
-	case _IOC_NR(IOCTL_CED_DBGRAMPDATA):
-		return ced_dbg_ramp_data(ced, (TDBGBLOCK __user *) arg);
-
-	case _IOC_NR(IOCTL_CED_DBGRAMPADDR):
-		return ced_dbg_ramp_addr(ced, (TDBGBLOCK __user *) arg);
-
-	case _IOC_NR(IOCTL_CED_DBGGETDATA):
-		return ced_dbg_get_data(ced, (TDBGBLOCK __user *) arg);
-
-	case _IOC_NR(IOCTL_CED_DBGSTOPLOOP):
-		return ced_dbg_stop_loop(ced);
-
-	case _IOC_NR(IOCTL_CED_FULLRESET):
-		ced->force_reset = true; /* Set a flag for a full reset */
-		break;
-
-	case _IOC_NR(IOCTL_CED_SETCIRCULAR):
-		return ced_set_circular(ced,
-				      (struct transfer_area_desc __user *) arg);
-
-	case _IOC_NR(IOCTL_CED_GETCIRCBLOCK):
-		return ced_get_circ_block(ced, (TCIRCBLOCK __user *) arg);
-
-	case _IOC_NR(IOCTL_CED_FREECIRCBLOCK):
-		return ced_free_circ_block(ced, (TCIRCBLOCK __user *) arg);
-
-	case _IOC_NR(IOCTL_CED_WAITEVENT):
-		return ced_wait_event(ced, (int)(arg & 0xff), (int)(arg >> 8));
-
-	case _IOC_NR(IOCTL_CED_TESTEVENT):
-		return ced_test_event(ced, (int)arg);
-
-	default:
-		return U14ERR_NO_SUCH_FN;
-	}
-	return U14ERR_NOERROR;
-}
-
-static const struct file_operations ced_fops = {
-	.owner = THIS_MODULE,
-	.open = ced_open,
-	.release = ced_release,
-	.flush = ced_flush,
-	.llseek = noop_llseek,
-	.unlocked_ioctl = ced_ioctl,
-};
-
-/*
- * usb class driver info in order to get a minor number from the usb core,
- * and to have the device registered with the driver core
- */
-static struct usb_class_driver ced_class = {
-	.name = "cedusb%d",
-	.fops = &ced_fops,
-	.minor_base = USB_CED_MINOR_BASE,
-};
-
-/* Check that the device that matches a 1401 vendor and product ID is OK to */
-/* use and initialise our struct ced_data.				    */
-static int ced_probe(struct usb_interface *interface,
-		     const struct usb_device_id *id)
-{
-	struct ced_data *ced;
-	struct usb_host_interface *iface_desc;
-	struct usb_endpoint_descriptor *endpoint;
-	int i, bcdDevice;
-	int retval = -ENOMEM;
-
-	/*  allocate memory for our device extension and initialize it */
-	ced = kzalloc(sizeof(*ced), GFP_KERNEL);
-	if (!ced)
-		goto error;
-
-	for (i = 0; i < MAX_TRANSAREAS; ++i) {	/* Initialise the wait queues */
-		init_waitqueue_head(&ced->trans_def[i].event);
-	}
-
-	/* Put initialises for our stuff here. Note that all of *ced is
-	 * zero, so no need to explicitly zero it. */
-	spin_lock_init(&ced->char_out_lock);
-	spin_lock_init(&ced->char_in_lock);
-	spin_lock_init(&ced->staged_lock);
-
-	/*  Initialises from the skeleton stuff */
-	kref_init(&ced->kref);
-	mutex_init(&ced->io_mutex);
-	spin_lock_init(&ced->err_lock);
-	init_usb_anchor(&ced->submitted);
-
-	ced->udev = usb_get_dev(interface_to_usbdev(interface));
-	ced->interface = interface;
-
-	/*  Attempt to identify the device */
-	bcdDevice = ced->udev->descriptor.bcdDevice;
-	i = (bcdDevice >> 8);
-	if (i == 0)
-		ced->type = TYPEU1401;
-	else if ((i >= 1) && (i <= 23))
-		ced->type = i + 2;
-	else {
-		dev_err(&interface->dev, "%s: Unknown device. bcdDevice = %d\n",
-			__func__, bcdDevice);
-		goto error;
-	}
-	/* set up the endpoint information. We only care about the number of */
-	/* EP as we know that we are dealing with a 1401 device.	     */
-	iface_desc = interface->cur_altsetting;
-	ced->n_pipes = iface_desc->desc.bNumEndpoints;
-	dev_info(&interface->dev, "1401Type=%d with %d End Points\n",
-		 ced->type, ced->n_pipes);
-	if ((ced->n_pipes < 3) || (ced->n_pipes > 4))
-		goto error;
-
-	/*  Allocate the URBs we hold for performing transfers */
-	ced->urb_char_out = usb_alloc_urb(0, GFP_KERNEL);/* character output
-							    URB */
-	ced->urb_char_in = usb_alloc_urb(0, GFP_KERNEL); /* character input
-							    URB */
-	ced->staged_urb = usb_alloc_urb(0, GFP_KERNEL);	/* block transfer URB */
-	if (!ced->urb_char_out || !ced->urb_char_in || !ced->staged_urb) {
-		dev_err(&interface->dev, "%s: URB alloc failed\n", __func__);
-		goto error;
-	}
-
-	ced->coher_staged_io =
-	    usb_alloc_coherent(ced->udev, STAGED_SZ, GFP_KERNEL,
-			       &ced->staged_urb->transfer_dma);
-	ced->coher_char_out =
-	    usb_alloc_coherent(ced->udev, OUTBUF_SZ, GFP_KERNEL,
-			       &ced->urb_char_out->transfer_dma);
-	ced->coher_char_in =
-	    usb_alloc_coherent(ced->udev, INBUF_SZ, GFP_KERNEL,
-			       &ced->urb_char_in->transfer_dma);
-	if (!ced->coher_char_out || !ced->coher_char_in ||
-	    !ced->coher_staged_io) {
-		dev_err(&interface->dev, "%s: Coherent buffer alloc failed\n",
-			__func__);
-		goto error;
-	}
-
-	for (i = 0; i < ced->n_pipes; ++i) {
-		endpoint = &iface_desc->endpoint[i].desc;
-		ced->ep_addr[i] = endpoint->bEndpointAddress;
-		dev_info(&interface->dev, "Pipe %d, ep address %02x\n",
-			 i, ced->ep_addr[i]);
-
-		/* if char input end point */
-		if (((ced->n_pipes == 3) && (i == 0)) ||
-		    ((ced->n_pipes == 4) && (i == 1))) {
-			/* save the endpoint interrupt interval */
-			ced->interval = endpoint->bInterval;
-			dev_info(&interface->dev, "Pipe %d, interval = %d\n",
-				 i, ced->interval);
-		}
-		/*  Detect USB2 by checking last ep size (64 if USB1) */
-		if (i == ced->n_pipes - 1) { /* if this is the last ep (bulk) */
-			ced->is_usb2 =
-			    le16_to_cpu(endpoint->wMaxPacketSize) > 64;
-			dev_info(&ced->interface->dev, "USB%d\n",
-				 ced->is_usb2 + 1);
-		}
-	}
-
-	/* save our data pointer in this interface device */
-	usb_set_intfdata(interface, ced);
-
-	/* we can register the device now, as it is ready */
-	retval = usb_register_dev(interface, &ced_class);
-	if (retval) {
-		/* something prevented us from registering this driver */
-		dev_err(&interface->dev,
-			"Not able to get a minor for this device\n");
-		usb_set_intfdata(interface, NULL);
-		goto error;
-	}
-
-	/* let the user know what node this device is now attached to */
-	dev_info(&interface->dev,
-		 "USB CEDUSB device now attached to cedusb #%d\n",
-		 interface->minor);
-	return 0;
-
-error:
-	if (ced)
-		kref_put(&ced->kref, ced_delete); /* frees allocated memory */
-	return retval;
-}
-
-static void ced_disconnect(struct usb_interface *interface)
-{
-	struct ced_data *ced = usb_get_intfdata(interface);
-	int minor = interface->minor;
-	int i;
-
-	/* remove the ced from the interface */
-	usb_set_intfdata(interface, NULL);
-	/* give back our minor device number */
-	usb_deregister_dev(interface, &ced_class);
-
-	mutex_lock(&ced->io_mutex);	/* stop more I/O starting while... */
-	ced_draw_down(ced);	/*  ...wait for then kill any io */
-	for (i = 0; i < MAX_TRANSAREAS; ++i) {
-		/* ...release any used memory */
-		int err = ced_clear_area(ced, i);
-
-		if (err == U14ERR_UNLOCKFAIL)
-			dev_err(&ced->interface->dev,
-				"%s: Area %d was in used\n",
-				__func__, i);
-	}
-	ced->interface = NULL; /* ...we kill off link to interface */
-	mutex_unlock(&ced->io_mutex);
-
-	usb_kill_anchored_urbs(&ced->submitted);
-
-	kref_put(&ced->kref, ced_delete);	/*  decrement our usage count */
-
-	dev_info(&interface->dev, "USB cedusb #%d now disconnected\n", minor);
-}
-
-/*  Wait for all the urbs we know of to be done with, then kill off any that */
-/*  are left. NBNB we will need to have a mechanism to stop circular xfers */
-/*  from trying to fire off more urbs. We will wait up to 3 seconds for Urbs */
-/*  to be done. */
-void ced_draw_down(struct ced_data *ced)
-{
-	int time;
-
-	dev_dbg(&ced->interface->dev, "%s: called\n", __func__);
-
-	ced->in_draw_down = true;
-	time = usb_wait_anchor_empty_timeout(&ced->submitted, 3000);
-	if (!time) {		/*  if we timed out we kill the urbs */
-		usb_kill_anchored_urbs(&ced->submitted);
-		dev_err(&ced->interface->dev, "%s: timed out\n", __func__);
-	}
-	ced->in_draw_down = false;
-}
-
-static int ced_suspend(struct usb_interface *intf, pm_message_t message)
-{
-	struct ced_data *ced = usb_get_intfdata(intf);
-
-	if (!ced)
-		return 0;
-	ced_draw_down(ced);
-
-	dev_dbg(&ced->interface->dev, "%s: called\n", __func__);
-	return 0;
-}
-
-static int ced_resume(struct usb_interface *intf)
-{
-	struct ced_data *ced = usb_get_intfdata(intf);
-
-	if (!ced)
-		return 0;
-	dev_dbg(&ced->interface->dev, "%s: called\n", __func__);
-	return 0;
-}
-
-static int ced_pre_reset(struct usb_interface *intf)
-{
-	struct ced_data *ced = usb_get_intfdata(intf);
-
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-	mutex_lock(&ced->io_mutex);
-	ced_draw_down(ced);
-	return 0;
-}
-
-static int ced_post_reset(struct usb_interface *intf)
-{
-	struct ced_data *ced = usb_get_intfdata(intf);
-
-	dev_dbg(&ced->interface->dev, "%s\n", __func__);
-
-	/* we are sure no URBs are active - no locking needed */
-	ced->errors = -EPIPE;
-	mutex_unlock(&ced->io_mutex);
-
-	return 0;
-}
-
-static struct usb_driver ced_driver = {
-	.name = "cedusb",
-	.probe = ced_probe,
-	.disconnect = ced_disconnect,
-	.suspend = ced_suspend,
-	.resume = ced_resume,
-	.pre_reset = ced_pre_reset,
-	.post_reset = ced_post_reset,
-	.id_table = ced_table,
-	.supports_autosuspend = 1,
-};
-
-module_usb_driver(ced_driver);
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/ced1401/usb1401.h b/drivers/staging/ced1401/usb1401.h
deleted file mode 100644
index da4d90c..0000000
--- a/drivers/staging/ced1401/usb1401.h
+++ /dev/null
@@ -1,260 +0,0 @@
-/* usb1401.h
- Header file for the CED 1401 USB device driver for Linux
- Copyright (C) 2010 Cambridge Electronic Design Ltd
- Author Greg P Smith (greg@ced.co.uk)
-
- 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.
-
- 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*/
-#ifndef __USB1401_H__
-#define __USB1401_H__
-#include "use1401.h"
-#include "ced_ioctl.h"
-
-#ifndef UINT
-#define UINT unsigned int
-#endif
-
-/** Device type codes, but these don't need to be extended - a succession is assumed
-** These are set for usb from the bcdDevice field (suitably mangled). Future devices
-** will be added in order of device creation to the list, so the names here are just
-** to help use remember which device is which. The U14ERR_... values follow the same
-** pattern for modern devices.a
-**/
-#define TYPEUNKNOWN        -1             /*  dont know */
-#define TYPE1401           0              /*  standard 1401 */
-#define TYPEPLUS           1              /*  1401 plus */
-#define TYPEU1401          2              /*  u1401 */
-#define TYPEPOWER          3              /*  Power1401 */
-#define TYPEU14012         4              /*  u1401 mkII */
-#define TYPEPOWER2         5              /*  Power1401 mk II */
-#define TYPEMICRO3         6              /*  Micro1401-3 */
-#define TYPEPOWER3         7              /*  Power1401-3 */
-
-/*  Some useful defines of constants. DONT FORGET to change the version in the */
-/*  resources whenever you change it here!. */
-#define DRIVERMAJREV      2             /*  driver revision level major (match windows) */
-#define DRIVERMINREV      0             /*  driver revision level minor */
-
-/*  Definitions of the various block transfer command codes */
-#define TM_EXTTOHOST    8               /*  extended tohost */
-#define TM_EXTTO1401    9               /*  extended to1401 */
-
-/*  Definitions of values in usbReqtype. Used in sorting out setup actions */
-#define H_TO_D 0x00
-#define D_TO_H 0x80
-#define VENDOR 0x40
-#define DEVREQ 0x00
-#define INTREQ 0x01
-#define ENDREQ 0x02
-
-/*  Definition of values in usbRequest, again used to sort out setup */
-#define GET_STATUS      0x00
-#define CLEAR_FEATURE   0x01
-#define SET_FEATURE     0x03
-#define SET_ADDRESS     0x05
-#define GET_DESC        0x06
-#define SET_DESC        0x07
-#define GET_CONF        0x08
-#define SET_CONF        0x09
-#define GET_INTERFACE   0x0a
-#define SET_INTERFACE   0x0b
-#define SYNCH_FRAME     0x0c
-
-/*  Definitions of the various debug command codes understood by the 1401. These */
-/*  are used in various vendor-specific commands to achieve the desired effect */
-#define DB_GRAB         0x50            /* Grab is a NOP for USB */
-#define DB_FREE         0x51            /* Free is a NOP for the USB */
-#define DB_SETADD       0x52            /* Set debug address (double) */
-#define DB_SELFTEST     0x53            /* Start self test */
-#define DB_SETMASK      0x54            /* Set enable mask (double) */
-#define DB_SETDEF       0x55            /* Set default mask (double) */
-#define DB_PEEK         0x56            /* Peek address, save result */
-#define DB_POKE         0x57            /* Poke address with data (double) */
-#define DB_RAMPD        0x58            /* Ramp data at debug address */
-#define DB_RAMPA        0x59            /* Ramp address bus */
-#define DB_REPEATS      0x5A            /* Set repeats for operations (double) */
-#define DB_WIDTH        0x5B            /* Set width for operations (byte) */
-#define DB_DATA         0x5C            /* Get 4-byte data read by PEEK */
-#define DB_CHARS        0x5D            /* Send chars via EP0 control write */
-
-#define CR_CHAR          0x0D           /* The carriage return character */
-#define CR_CHAR_80       0x8d           /*  and with bit 7 set */
-
-/* A structure holding information about a block */
-/* of memory for use in circular transfers       */
-struct circ_blk {
-	volatile UINT offset;   /* Offset within area of block start */
-	volatile UINT size;     /* Size of the block, in bytes (0 = unused) */
-};
-
-/* A structure holding all of the information about a transfer area - an area */
-/* of memory set up for use either as a source or destination in DMA          */
-/* transfers.                                                                 */
-struct transarea {
-	/* User address of xfer area saved for completeness */
-	void __user *buff;
-
-	/* offset to start of xfer area in first page */
-	UINT        base_offset;
-
-	UINT        length;        /* Length of xfer area, in bytes */
-	struct page **pages;       /* Points at array of locked down pages */
-	int         n_pages;       /* number of pages that are locked down */
-	bool        used;          /* Is this structure in use? */
-	bool        circular;      /* Is this area for circular transfers? */
-	bool        circ_to_host;  /* Flag for direction of circular transfer */
-	bool        event_to_host; /*  Set event on transfer to host? */
-	int         wake_up;       /* Set 1 on event, cleared by TestEvent() */
-	UINT        event_st;      /* Defines section within xfer area for... */
-	UINT        event_sz;   /* notification by the event SZ is 0 if unset */
-	struct circ_blk blocks[2]; /* Info on a pair of circular blocks */
-
-	wait_queue_head_t event; /* The wait queue for events in this */
-				 /* area MUST BE LAST */
-};
-
-/* The dmadesc structure is used to hold information on the transfer in       */
-/* progress. It is set up by ReadDMAInfo, using information sent by the 1401  */
-/* in an escape sequence.                                                     */
-struct dmadesc {
-	unsigned short trans_type;    /* transfer type as TM_xxx above        */
-	unsigned short ident;         /* identifier word                      */
-	unsigned int   size;          /* bytes to transfer                    */
-	unsigned int   offset;        /* offset into transfer area for trans  */
-	bool           outward;       /* true when data is going TO 1401      */
-};
-
-#define INBUF_SZ  256         /* input buffer size */
-#define OUTBUF_SZ 256         /* output buffer size */
-#define STAGED_SZ 0x10000     /* size of coherent buffer for staged transfers */
-
-/* Structure to hold all of our device specific stuff. We are making this as  */
-/* similar as we can to the Windows driver to help in our understanding of    */
-/* what is going on.                                                          */
-struct ced_data {
-	char input_buffer[INBUF_SZ];        /* The two buffers */
-	char output_buffer[OUTBUF_SZ];      /* accessed by the host functions */
-	volatile unsigned int num_input;    /* num of chars in input buffer   */
-	volatile unsigned int in_buff_get;  /* where to get from input buffer */
-	volatile unsigned int in_buff_put;  /* where to put into input buffer */
-	volatile unsigned int num_output;   /* num of chars in output buffer  */
-	volatile unsigned int out_buff_get; /* where to get from output buffer*/
-	volatile unsigned int out_buff_put; /* where to put into output buffer*/
-
-	volatile bool send_chars_pending; /* Flag to indicate sendchar active */
-	volatile bool read_chars_pending; /* Flag to indicate a read is primed*/
-	char *coher_char_out;     /* special aligned buffer for chars to 1401 */
-	struct urb *urb_char_out;           /* urb used for chars to 1401 */
-	char *coher_char_in;      /* special aligned buffer for chars to host */
-	struct urb *urb_char_in;            /* urb used for chars to host */
-
-	spinlock_t char_out_lock; /* protect the output_buffer and outputting */
-	spinlock_t char_in_lock;  /* protect the input_buffer and char reads  */
-	__u8 interval;                     /* Interrupt end point interval */
-
-	volatile unsigned int dma_flag;     /* state of DMA */
-	struct transarea trans_def[MAX_TRANSAREAS];  /* transfer area info */
-	volatile struct dmadesc dma_info;   /*  info on current DMA transfer */
-	volatile bool xfer_waiting;      /*  Flag set if DMA transfer stalled */
-	volatile bool in_draw_down;   /*  Flag that we want to halt transfers */
-
-	/* Parameters relating to a block read\write that is in progress. Some of these values */
-	/* are equivalent to values in dma_info. The values here are those in use, while those */
-	/* in dma_info are those received from the 1401 via an escape sequence. If another */
-	/* escape sequence arrives before the previous xfer ends, dma_info values are updated while these */
-	/* are used to finish off the current transfer. */
-	volatile short staged_id;  /*  The transfer area id for this transfer */
-	volatile bool staged_read; /*  Flag TRUE for read from 1401, FALSE for write */
-	volatile unsigned int staged_length; /* Total length of this transfer */
-	volatile unsigned int staged_offset; /*  Offset within memory area for transfer start */
-	volatile unsigned int staged_done;   /*  Bytes transferred so far */
-	volatile bool staged_urb_pending;    /*  Flag to indicate active */
-	char *coher_staged_io;            /*  buffer used for block transfers */
-	struct urb *staged_urb;             /*  The URB to use */
-	spinlock_t staged_lock;             /* protects ReadWriteMem() and    */
-					    /* circular buffer stuff          */
-
-	short type;                         /*  type of 1401 attached */
-	short current_state;                /*  current error state */
-	bool is_usb2;                 /*  type of the interface we connect to */
-	bool force_reset;           /*  Flag to make sure we get a real reset */
-	__u32 stat_buf[2];                  /*  buffer for 1401 state info */
-
-	unsigned long self_test_time;       /*  used to timeout self test */
-
-	int n_pipes;           /* Should be 3 or 4 depending on 1401 usb chip */
-	int pipe_error[4];     /* set non-zero if an error on one of the pipe */
-	__u8 ep_addr[4];                   /* addresses of the 3/4 end points */
-
-	struct usb_device *udev;            /*  the usb device for this device */
-	struct usb_interface *interface;    /*  the interface for this device, NULL if removed */
-	struct usb_anchor submitted;        /*  in case we need to retract our submissions */
-	struct mutex io_mutex;              /*  synchronize I/O with disconnect, one user-mode caller at a time */
-
-	int    errors;                      /*  the last request tanked */
-	int    open_count;                  /*  count the number of openers */
-	spinlock_t err_lock;                /*  lock for errors */
-	struct kref kref;
-};
-
-#define to_ced_data(d) container_of(d, struct ced_data, kref)
-
-/*  Definitions of routimes used between compilation object files */
-/*  in usb1401.c */
-extern int ced_allowi(struct ced_data *ced);
-extern int ced_send_chars(struct ced_data *ced);
-extern void ced_draw_down(struct ced_data *ced);
-extern int ced_read_write_mem(struct ced_data *ced, bool read,
-			      unsigned short ident, unsigned int offs,
-			      unsigned int len);
-
-/*  in ced_ioc.c */
-extern int ced_clear_area(struct ced_data *ced, int area);
-extern int ced_send_string(struct ced_data *ced, const char __user *data, unsigned int n);
-extern int ced_send_char(struct ced_data *ced, char c);
-extern int ced_get_state(struct ced_data *ced, __u32 *state, __u32 *error);
-extern int ced_read_write_cancel(struct ced_data *ced);
-extern int ced_reset(struct ced_data *ced);
-extern int ced_get_char(struct ced_data *ced);
-extern int ced_get_string(struct ced_data *ced, char __user *user, int n);
-extern int ced_set_transfer(struct ced_data *ced,
-			    struct transfer_area_desc __user *utd);
-extern int ced_unset_transfer(struct ced_data *ced, int area);
-extern int ced_set_event(struct ced_data *ced,
-			 struct transfer_event __user *ute);
-extern int ced_stat_1401(struct ced_data *ced);
-extern int ced_line_count(struct ced_data *ced);
-extern int ced_get_out_buf_space(struct ced_data *ced);
-extern int ced_get_transfer(struct ced_data *ced, TGET_TX_BLOCK __user *utx);
-extern int ced_kill_io(struct ced_data *ced);
-extern int ced_state_of_1401(struct ced_data *ced);
-extern int ced_start_self_test(struct ced_data *ced);
-extern int ced_check_self_test(struct ced_data *ced,
-			       TGET_SELFTEST __user *ugst);
-extern int ced_type_of_1401(struct ced_data *ced);
-extern int ced_transfer_flags(struct ced_data *ced);
-extern int ced_dbg_peek(struct ced_data *ced, TDBGBLOCK __user *udb);
-extern int ced_dbg_poke(struct ced_data *ced, TDBGBLOCK __user *udb);
-extern int ced_dbg_ramp_data(struct ced_data *ced, TDBGBLOCK __user *udb);
-extern int ced_dbg_ramp_addr(struct ced_data *ced, TDBGBLOCK __user *udb);
-extern int ced_dbg_get_data(struct ced_data *ced, TDBGBLOCK __user *udb);
-extern int ced_dbg_stop_loop(struct ced_data *ced);
-extern int ced_set_circular(struct ced_data *ced,
-			    struct transfer_area_desc __user *utd);
-extern int ced_get_circ_block(struct ced_data *ced, TCIRCBLOCK __user *ucb);
-extern int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *ucb);
-extern int ced_wait_event(struct ced_data *ced, int area, int time_out);
-extern int ced_test_event(struct ced_data *ced, int area);
-#endif
diff --git a/drivers/staging/ced1401/use1401.h b/drivers/staging/ced1401/use1401.h
deleted file mode 100644
index b7997c9..0000000
--- a/drivers/staging/ced1401/use1401.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/****************************************************************************
-** use1401.h
-** Copyright (C) Cambridge Electronic Design Ltd, 1992-2010
-** Authors: Paul Cox, Tim Bergel, Greg Smith
-** See CVS for revisions.
-**
-** Because the size of a long is different between 32-bit and 64-bit on some
-** systems, we avoid this in this interface.
-****************************************************************************/
-#ifndef __USE1401_H__
-#define __USE1401_H__
-#include "machine.h"
-
-/*  Some definitions to make things compatible. If you want to use Use1401 directly */
-/*   from a Windows program you should define U14_NOT_DLL, in which case you also */
-/*   MUST make sure that your application startup code calls U14InitLib(). */
-/*  DLL_USE1401 is defined when you are building the Use1401 dll, not otherwise. */
-#ifdef _IS_WINDOWS_
-#ifndef U14_NOT_DLL
-#ifdef DLL_USE1401
-#define U14API(retType) (retType DllExport __stdcall)
-#else
-#define U14API(retType) (retType DllImport __stdcall)
-#endif
-#endif
-
-#define U14ERRBASE -500
-#define U14LONG long
-#endif
-
-#ifdef LINUX
-#define U14ERRBASE -1000
-#define U14LONG int
-#endif
-
-#ifdef _QT
-#ifndef U14_NOT_DLL
-#undef U14API
-#define U14API(retType) (retType __declspec(dllimport) __stdcall)
-#endif
-#undef U14LONG
-#define U14LONG int
-#endif
-
-#ifndef U14API
-#define U14API(retType) retType
-#endif
-
-#ifndef U14LONG
-#define U14LONG long
-#endif
-
-/* Error codes: We need them here as user space can see them. */
-#define U14ERR_NOERROR        0             /*  no problems */
-
-/* Device error codes, but these don't need to be extended - a succession is assumed */
-#define U14ERR_STD            4              /*  standard 1401 connected */
-#define U14ERR_U1401          5              /*  u1401 connected */
-#define U14ERR_PLUS           6              /*  1401 plus connected */
-#define U14ERR_POWER          7              /*  Power1401 connected */
-#define U14ERR_U14012         8              /*  u1401 mkII connected */
-#define U14ERR_POWER2         9
-#define U14ERR_U14013        10
-#define U14ERR_POWER3        11
-
-/* NBNB Error numbers need shifting as some linux error codes start at 512 */
-#define U14ERR(n)             (n+U14ERRBASE)
-#define U14ERR_OFF            U14ERR(0)      /* 1401 there but switched off    */
-#define U14ERR_NC             U14ERR(-1)     /* 1401 not connected             */
-#define U14ERR_ILL            U14ERR(-2)     /* if present it is ill           */
-#define U14ERR_NOIF           U14ERR(-3)     /* I/F card missing               */
-#define U14ERR_TIME           U14ERR(-4)     /* 1401 failed to come ready      */
-#define U14ERR_BADSW          U14ERR(-5)     /* I/F card bad switches          */
-#define U14ERR_PTIME          U14ERR(-6)     /* 1401plus failed to come ready  */
-#define U14ERR_NOINT          U14ERR(-7)     /* couldn't grab the int vector   */
-#define U14ERR_INUSE          U14ERR(-8)     /* 1401 is already in use         */
-#define U14ERR_NODMA          U14ERR(-9)     /* couldn't get DMA channel       */
-#define U14ERR_BADHAND        U14ERR(-10)    /* handle provided was bad        */
-#define U14ERR_BAD1401NUM     U14ERR(-11)    /* 1401 number provided was bad   */
-
-#define U14ERR_NO_SUCH_FN     U14ERR(-20)    /* no such function               */
-#define U14ERR_NO_SUCH_SUBFN  U14ERR(-21)    /* no such sub function           */
-#define U14ERR_NOOUT          U14ERR(-22)    /* no room in output buffer       */
-#define U14ERR_NOIN           U14ERR(-23)    /* no input in buffer             */
-#define U14ERR_STRLEN         U14ERR(-24)    /* string longer than buffer      */
-#define U14ERR_ERR_STRLEN     U14ERR(-24)    /* string longer than buffer      */
-#define U14ERR_LOCKFAIL       U14ERR(-25)    /* failed to lock memory          */
-#define U14ERR_UNLOCKFAIL     U14ERR(-26)    /* failed to unlock memory        */
-#define U14ERR_ALREADYSET     U14ERR(-27)    /* area already set up            */
-#define U14ERR_NOTSET         U14ERR(-28)    /* area not set up                */
-#define U14ERR_BADAREA        U14ERR(-29)    /* illegal area number            */
-#define U14ERR_FAIL           U14ERR(-30)    /* we failed for some other reason*/
-
-#define U14ERR_NOFILE         U14ERR(-40)    /* command file not found         */
-#define U14ERR_READERR        U14ERR(-41)    /* error reading command file     */
-#define U14ERR_UNKNOWN        U14ERR(-42)    /* unknown command                */
-#define U14ERR_HOSTSPACE      U14ERR(-43)    /* not enough host space to load  */
-#define U14ERR_LOCKERR        U14ERR(-44)    /* could not lock resource/command*/
-#define U14ERR_CLOADERR       U14ERR(-45)    /* CLOAD command failed           */
-
-#define U14ERR_TOXXXERR       U14ERR(-60)    /* tohost/1401 failed             */
-#define U14ERR_NO386ENH       U14ERR(-80)    /* not 386 enhanced mode          */
-#define U14ERR_NO1401DRIV     U14ERR(-81)    /* no device driver               */
-#define U14ERR_DRIVTOOOLD     U14ERR(-82)    /* device driver too old          */
-
-#define U14ERR_TIMEOUT        U14ERR(-90)    /* timeout occurred               */
-
-#define U14ERR_BUFF_SMALL     U14ERR(-100)   /* buffer for getstring too small */
-#define U14ERR_CBALREADY      U14ERR(-101)   /* there is already a callback    */
-#define U14ERR_BADDEREG       U14ERR(-102)   /* bad parameter to deregcallback */
-#define U14ERR_NOMEMORY       U14ERR(-103)   /* no memory for allocation       */
-
-#define U14ERR_DRIVCOMMS      U14ERR(-110)   /* failed talking to driver       */
-#define U14ERR_OUTOFMEMORY    U14ERR(-111)   /* needed memory and couldnt get it*/
-
-/* / 1401 type codes. */
-#define U14TYPE1401           0           /* standard 1401                  */
-#define U14TYPEPLUS           1           /* 1401 plus                      */
-#define U14TYPEU1401          2           /* u1401                          */
-#define U14TYPEPOWER          3           /* power1401                      */
-#define U14TYPEU14012         4           /* u1401 mk II                    */
-#define U14TYPEPOWER2         5           /* power1401 mk II                */
-#define U14TYPEU14013         6           /* u1401-3                        */
-#define U14TYPEPOWER3         7           /* power1401-3                    */
-#define U14TYPEUNKNOWN        -1          /* dont know                      */
-
-/* Transfer flags to allow driver capabilities to be interrogated */
-
-/* Constants for transfer flags */
-#define U14TF_USEDMA          1           /* Transfer flag for use DMA      */
-#define U14TF_MULTIA          2           /* Transfer flag for multi areas  */
-#define U14TF_FIFO            4           /* for FIFO interface card        */
-#define U14TF_USB2            8           /* for USB2 interface and 1401    */
-#define U14TF_NOTIFY          16          /* for event notifications        */
-#define U14TF_SHORT           32          /* for PCI can short cycle        */
-#define U14TF_PCI2            64          /* for new PCI card 1401-70       */
-#define U14TF_CIRCTH          128         /* Circular-mode to host          */
-#define U14TF_DIAG            256         /* Diagnostics/debug functions    */
-#define U14TF_CIRC14          512         /* Circular-mode to 1401          */
-
-/* Definitions of element sizes for DMA transfers - to allow byte-swapping */
-#define ESZBYTES              0           /* BYTE element size value        */
-#define ESZWORDS              1           /* unsigned short element size value        */
-#define ESZLONGS              2           /* long element size value        */
-#define ESZUNKNOWN            0           /* unknown element size value     */
-
-/* These define required access types for the debug/diagnostics function */
-#define BYTE_SIZE             1           /* 8-bit access                   */
-#define WORD_SIZE             2           /* 16-bit access                  */
-#define LONG_SIZE             3           /* 32-bit access                  */
-
-/* Stuff used by U14_GetTransfer */
-#define GET_TX_MAXENTRIES  257          /* (max length / page size + 1) */
-
-#ifdef _IS_WINDOWS_
-#pragma pack(1)
-
-typedef struct                          /* used for U14_GetTransfer results */
-{                                          /* Info on a single mapped block */
-	U14LONG physical;
-	U14LONG size;
-} TXENTRY;
-
-typedef struct TGetTxBlock              /* used for U14_GetTransfer results */
-{                                               /* matches structure in VXD */
-	U14LONG size;
-	U14LONG linear;
-	short   seg;
-	short   reserved;
-	short   avail;                      /* number of available entries */
-	short   used;                       /* number of used entries */
-	TXENTRY entries[GET_TX_MAXENTRIES];       /* Array of mapped block info */
-} TGET_TX_BLOCK;
-
-typedef TGET_TX_BLOCK *LPGET_TX_BLOCK;
-
-#pragma pack()
-#endif
-
-#ifdef LINUX
-typedef struct                          /* used for U14_GetTransfer results */
-{                                       /* Info on a single mapped block */
-	long long physical;
-	long     size;
-} TXENTRY;
-
-typedef struct TGetTxBlock              /* used for U14_GetTransfer results */
-{                                       /* matches structure in VXD */
-	long long linear;                    /* linear address */
-	long     size;                       /* total size of the mapped area, holds id when called */
-	short    seg;                        /* segment of the address for Win16 */
-	short    reserved;
-	short    avail;                      /* number of available entries */
-	short    used;                       /* number of used entries */
-	TXENTRY  entries[GET_TX_MAXENTRIES]; /* Array of mapped block info */
-} TGET_TX_BLOCK;
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-U14API(int)   U14WhenToTimeOut(short hand);         /*  when to timeout in ms */
-U14API(short)	U14PassedTime(int iTime);             /*  non-zero if iTime passed */
-
-U14API(short)	U14LastErrCode(short hand);
-
-U14API(short)	U14Open1401(short n1401);
-U14API(short)	U14Close1401(short hand);
-U14API(short)	U14Reset1401(short hand);
-U14API(short)	U14ForceReset(short hand);
-U14API(short)	U14TypeOf1401(short hand);
-U14API(short)	U14NameOf1401(short hand, char *pBuf, unsigned short wMax);
-
-U14API(short)	U14Stat1401(short hand);
-U14API(short)	U14CharCount(short hand);
-U14API(short)	U14LineCount(short hand);
-
-U14API(short)	U14SendString(short hand, const char *pString);
-U14API(short)	U14GetString(short hand, char *pBuffer, unsigned short wMaxLen);
-U14API(short)	U14SendChar(short hand, char cChar);
-U14API(short)	U14GetChar(short hand, char *pcChar);
-
-U14API(short)	U14LdCmd(short hand, const char *command);
-U14API(unsigned int) U14Ld(short hand, const char *vl, const char *str);
-
-U14API(short)	U14SetTransArea(short hand, unsigned short wArea, void *pvBuff,
-					unsigned int dwLength, short eSz);
-U14API(short)	U14UnSetTransfer(short hand, unsigned short wArea);
-U14API(short)	U14SetTransferEvent(short hand, unsigned short wArea, BOOL bEvent,
-					BOOL bToHost, unsigned int dwStart, unsigned int dwLength);
-U14API(int)   U14TestTransferEvent(short hand, unsigned short wArea);
-U14API(int)   U14WaitTransferEvent(short hand, unsigned short wArea, int msTimeOut);
-U14API(short)	U14GetTransfer(short hand, TGET_TX_BLOCK *pTransBlock);
-
-U14API(short)	U14ToHost(short hand, char *pAddrHost, unsigned int dwSize, unsigned int dw1401,
-								short eSz);
-U14API(short)	U14To1401(short hand, const char *pAddrHost, unsigned int dwSize, unsigned int dw1401,
-								short eSz);
-
-U14API(short)	U14SetCircular(short hand, unsigned short wArea, BOOL bToHost, void *pvBuff,
-							unsigned int dwLength);
-
-U14API(int)   U14GetCircBlk(short hand, unsigned short wArea, unsigned int *pdwOffs);
-U14API(int)   U14FreeCircBlk(short hand, unsigned short wArea, unsigned int dwOffs, unsigned int dwSize,
-							unsigned int *pdwOffs);
-
-U14API(short)	U14StrToLongs(const char *pszBuff, U14LONG *palNums, short sMaxLongs);
-U14API(short)	U14LongsFrom1401(short hand, U14LONG *palBuff, short sMaxLongs);
-
-U14API(void)  U14SetTimeout(short hand, int lTimeout);
-U14API(int)   U14GetTimeout(short hand);
-U14API(short)	U14OutBufSpace(short hand);
-U14API(int)   U14BaseAddr1401(short hand);
-U14API(int)   U14DriverVersion(short hand);
-U14API(int)   U14DriverType(short hand);
-U14API(short)	U14DriverName(short hand, char *pBuf, unsigned short wMax);
-U14API(short)	U14GetUserMemorySize(short hand, unsigned int *pMemorySize);
-U14API(short)	U14KillIO1401(short hand);
-
-U14API(short)	U14BlkTransState(short hand);
-U14API(short)	U14StateOf1401(short hand);
-
-U14API(short)	U14Grab1401(short hand);
-U14API(short)	U14Free1401(short hand);
-U14API(short)	U14Peek1401(short hand, unsigned int dwAddr, int nSize, int nRepeats);
-U14API(short)	U14Poke1401(short hand, unsigned int dwAddr, unsigned int dwValue, int nSize, int nRepeats);
-U14API(short)	U14Ramp1401(short hand, unsigned int dwAddr, unsigned int dwDef, unsigned int dwEnable, int nSize, int nRepeats);
-U14API(short)	U14RampAddr(short hand, unsigned int dwDef, unsigned int dwEnable, int nSize, int nRepeats);
-U14API(short)	U14StopDebugLoop(short hand);
-U14API(short)	U14GetDebugData(short hand, U14LONG *plValue);
-
-U14API(short)	U14StartSelfTest(short hand);
-U14API(short)	U14CheckSelfTest(short hand, U14LONG *pData);
-U14API(short)	U14TransferFlags(short hand);
-U14API(void)  U14GetErrorString(short nErr, char *pStr, unsigned short wMax);
-U14API(int)   U14MonitorRev(short hand);
-U14API(void)  U14CloseAll(void);
-
-U14API(short)	U14WorkingSet(unsigned int dwMinKb, unsigned int dwMaxKb);
-U14API(int)   U14InitLib(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* End of ifndef __USE1401_H__ */
-
diff --git a/drivers/staging/ced1401/use14_ioc.h b/drivers/staging/ced1401/use14_ioc.h
deleted file mode 100644
index 42d2e4e..0000000
--- a/drivers/staging/ced1401/use14_ioc.h
+++ /dev/null
@@ -1,299 +0,0 @@
-/* use14_ioc.h
-** definitions of use1401 module stuff that is shared between use1401 and the driver.
-** Copyright (C) Cambridge Electronic Design Limited 2010
-** Author Greg P Smith
-************************************************************************************/
-#ifndef __USE14_IOC_H__
-#define __USE14_IOC_H__
-
-#define  MAX_TRANSAREAS   8   /* The number of transfer areas supported by driver */
-
-#define i386
-#include "winioctl.h"                   /* needed so we can access driver   */
-
-/*
-** Defines for IOCTL functions to ask driver to perform. These must be matched
-** in both use1401 and in the driver. The IOCTL code contains a command
-** identifier, plus other information about the device, the type of access
-** with which the file must have been opened, and the type of buffering.
-** The IOCTL function codes from 0x80 to 0xFF are for developer use.
-*/
-#define  FILE_DEVICE_CED1401    0x8001
-						FNNUMBASE              0x800
-
-#define  U14_OPEN1401            CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE,               \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_CLOSE1401           CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+1,             \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_SENDSTRING          CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+2,             \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_RESET1401           CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+3,             \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_GETCHAR             CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+4,             \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_SENDCHAR            CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+5,             \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_STAT1401            CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+6,             \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_LINECOUNT           CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+7,             \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_GETSTRING           CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+8,             \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_REGCALLBACK         CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+9,             \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_GETMONITORBUF       CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+10,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_SETTRANSFER         CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+11,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_UNSETTRANSFER       CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+12,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_SETTRANSEVENT       CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+13,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_GETOUTBUFSPACE      CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+14,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_GETBASEADDRESS      CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+15,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_GETDRIVERREVISION   CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+16,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_GETTRANSFER         CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+17,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_KILLIO1401          CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+18,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_BLKTRANSSTATE       CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+19,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_BYTECOUNT           CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+20,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_ZEROBLOCKCOUNT      CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+21,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_STOPCIRCULAR        CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+22,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_STATEOF1401         CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+23,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_REGISTERS1401       CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+24,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_GRAB1401            CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+25,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_FREE1401            CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+26,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_STEP1401            CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+27,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_SET1401REGISTERS    CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+28,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_STEPTILL1401        CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+29,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_SETORIN             CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+30,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_STARTSELFTEST       CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+31,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_CHECKSELFTEST       CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+32,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_TYPEOF1401          CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+33,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_TRANSFERFLAGS       CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+34,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_DBGPEEK             CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+35,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_DBGPOKE             CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+36,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_DBGRAMPDATA         CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+37,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_DBGRAMPADDR         CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+38,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_DBGGETDATA          CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+39,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_DBGSTOPLOOP         CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+40,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_FULLRESET           CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+41,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_SETCIRCULAR         CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+42,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_GETCIRCBLK          CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+43,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-#define  U14_FREECIRCBLK         CTL_CODE(FILE_DEVICE_CED1401,     \
-						FNNUMBASE+44,            \
-						METHOD_BUFFERED,         \
-						FILE_ANY_ACCESS)
-
-/*--------------- Structures that are shared with the driver ------------- */
-#pragma pack(1)
-
-typedef struct                  /* used for get/set standard 1401 registers */
-{
-	short   sPC;
-	char    A;
-	char    X;
-	char    Y;
-	char    stat;
-	char    rubbish;
-} T1401REGISTERS;
-
-typedef union     /* to communicate with 1401 driver status & control funcs */
-{
-	char           chrs[22];
-	short          ints[11];
-	long           longs[5];
-	T1401REGISTERS registers;
-} TCSBLOCK;
-
-typedef TCSBLOCK*  LPTCSBLOCK;
-
-typedef struct paramBlk {
-	 short       sState;
-	 TCSBLOCK    csBlock;
-} PARAMBLK;
-
-typedef PARAMBLK*   PPARAMBLK;
-
-struct transfer_area_desc          /* Structure and type for SetTransArea */
-{
-	unsigned short        wArea;            /* number of transfer area to set up       */
-	void FAR *lpvBuff;          /* address of transfer area                */
-	unsigned int       dwLength;         /* length of area to set up                */
-	short       eSize;            /* size to move (for swapping on MAC)      */
-};
-
-
-/* This is the structure used to set up a transfer area */
-typedef struct VXTransferDesc    /* use1401.c and use1432x.x use only       */
-{
-	unsigned short        wArea;            /* number of transfer area to set up       */
-	unsigned short        wAddrSel;         /* 16 bit selector for area                */
-	unsigned int       dwAddrOfs;        /* 32 bit offset for area start            */
-	unsigned int       dwLength;         /* length of area to set up                */
-} VXTRANSFERDESC;
-
-#pragma pack()
-
-#endif
diff --git a/drivers/staging/ced1401/userspace/use1401.c b/drivers/staging/ced1401/userspace/use1401.c
deleted file mode 100644
index d589311..0000000
--- a/drivers/staging/ced1401/userspace/use1401.c
+++ /dev/null
@@ -1,3030 +0,0 @@
-/****************************************************************************
-** use1401.c
-** Copyright (C) Cambridge Electronic Design Ltd, 1992-2010
-**
-** 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.
-**
-** 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-**
-** Contact CED: Cambridge Electronic Design Limited, Science Park, Milton Road
-**              Cambridge, CB6 0FE.
-**              www.ced.co.uk
-**              greg@ced.co.uk
-**
-**  Title:      USE1401.C
-**  Version:    4.00
-**  Author:     Paul Cox, Tim Bergel, Greg Smith
-**
-** The code was vigorously pruned in DEC 2010 to remove the macintosh options
-** and to get rid of the 16-bit support. It has also been aligned with the
-** Linux version. See CVS for revisions. This will work for Win 9x onwards.
-****************************************************************************
-**
-** Notes on Windows interface to driver
-** ************************************
-**
-** Under Windows 9x and NT, Use1401 uses DeviceIoControl to get access to
-** the 1401 driver. This has parameters for the device handle, the function
-** code, an input pointer and byte count, an output pointer and byte count
-** and a pointer to a unsigned int to hold the output byte count. Note that input
-** and output are from the point-of-view of the driver, so the output stuff
-** is used to read values from the 1401, not send to the 1401. The use of
-** these parameters varies with the function in use and the operating
-** system; there are five separate DIOC calls SendString, GetString and
-** SetTransferArea all have their own specialised calls, the rest use the
-** Status1401 or Control1401 functions.
-**
-** There are two basic styles of DIOC call used, one for Win9x VxD drivers
-** and one for NT Kernel-mode and WDM drivers (see below for tables showing
-** the different parameters used. The array bUseNTDIOC[] selects between
-** these two calling styles.
-**
-** Function codes
-** In Win3.x, simple function codes from 0 to 40 were used, shifted left 8
-** bits with a sub-function code in the lower 8 bits. These were also used
-** in the Windows 95 driver, though we had to add 1 to the code value to
-** avoid problems (Open from CreateFile is zero), and the sub-function code
-** is now unused. We found that this gave some problems with Windows 98
-** as the function code values are reserved by microsoft, so we switched to
-** using the NT function codes instead. The NT codes are generated using the
-** CTL_CODE macro, essentially this gives 0x80012000 | (func << 2), where
-** func is the original 0 to 34 value. The driver will handle both types of
-** code and Use1432 only uses the NT codes if it knows the driver is new
-** enough. The array bUseNTCodes[] holds flags on the type of codes required.
-** GPS/TDB Dec 2010: we removed the bUseNTCodes array as this is always true
-** as we no longer support ancient versions.
-**
-** The CreateFile and CloseFile function calls are also handled
-** by DIOC, using the special function codes 0 and -1 respectively.
-**
-** Input pointer and buffer size
-** These are intended for data sent to the device driver. In nearly all cases
-** they are unused in calls to the Win95 driver, the NT driver uses them
-** for all information sent to the driver. The table below shows the pointer
-** and byte count used for the various calls:
-**
-**                      Win 95                  Win NT
-** SendString           NULL, 0                 pStr, nStr
-** GetString            NULL, 0                 NULL, 0
-** SetTransferArea      pBuf, nBuf (unused?)    pDesc, nDesc
-** GetTransfer          NULL, 0                 NULL, 0
-** Status1401           NULL, 0                 NULL, 0
-** Control1401          NULL, 0                 pBlk, nBlk
-**
-** pStr and nStr are pointers to a char buffer and the buffer length for
-** string I/O, note that these are temporary buffers owned by the DLL, not
-** application memory, pBuf and nBuf are the transfer area buffer (I think
-** these are unused), pDesc and nDesc are the TRANSFERDESC structure, pBlk
-** and nBlk are the TCSBLOCK structure.
-**
-**
-** Output pointer and buffer size
-** These are intended for data read from the device driver. These are used
-** for almost all information sent to the Win95 driver, the NT driver uses
-** them for information read from the driver, chiefly the error code. The
-** table below shows the pointer and byte count used for the various calls:
-**
-**                      Win 95                  Win NT
-** SendString           pStr, nStr              pPar, nPar
-** GetString            pStr, nStr+2            pStr, nStr+2
-** SetTransferArea      pDesc, nDesc            pPar, nPar
-** GetTransfer          pGet, nGet              pGet, nGet
-** Status1401           pBlk, nBlk              pPar, nPar
-** Control1401          pBlk, nBlk              pPar, nPar
-**
-** pStr and nStr are pointers to a char buffer and the buffer length for
-** string I/O, the +2 for GetString refers to two spare bytes at the start
-** used to hold the string length and returning an error code for NT. Note
-** again that these are (and must be) DLL-owned temporary buffers. pPar
-** and nPar are a PARAM structure used in NT (it holds an error code and a 
-** TCSBLOCK structure). pDesc and nDesc are the VXTRANSFERDESC structure,
-** pBlk and nBlk are the TCSBLOCK structure. pGet and nGet indicate the
-** TGET_TX_BLOCK structure used for GetTransfer.
-**
-**
-** The output byte count
-** Both drivers return the output buffer size here, regardless of the actual
-** bytes output. This is used to check that we did get through to the driver.
-**
-** Multiple 1401s
-** **************
-**
-** We have code that tries to support the use of multiple 1401s, but there
-** are problems: The lDriverVersion and lDriverType variables are global, not
-** per-1401 (a particular problem as the U14 functions that use them don't
-** have a hand parameter). In addition, the mechansim for finding a free
-** 1401 depends upon the 1401 device driver open operation failing if it's
-** already in use, which doesn't always happen, particularly with the VxDs.
-** The code in TryToOpen tries to fix this by relying on TYPEOF1401 to detect
-** the 1401-in-use state - the VxDs contain special code to help this. This is
-** working OK but multiple 1401 support works better with the Win2000 drivers.
-**
-** USB driver
-** **********
-**
-** The USB driver, which runs on both Win98 and NT2000, uses the NT-style
-** calling convention, both for the DIOC codes and the DIOC parameters. The
-** TryToOpen function has been altered to look for an NT driver first in
-** the appropriate circumstances, and to set the driver DIOC flags up in
-** the correct state.
-**
-** Adding a new 1401 type - now almost nothing to do
-** *************************************************
-**
-** The 1401 types are defined by a set of U14TYPExxxx codes in USE1401.H.
-** You should add a new one of these to keep things tidy for applications.
-**
-** DRIVERET_MAX (below) specifies the maximum allowed type code from the
-** 1401 driver; I have set this high to accommodate as yet undesigned 1401
-** types. Similarly, as long as the command file names follow the ARM,
-** ARN, ARO sequence, these are calculated by the ExtForType function, so
-** you don't need to do anything here either.
-**
-** Version number
-** **************
-** The new U14InitLib() function returns 0 if the OS is incapable of use,
-** otherwise is returns the version of the USE1401 library. This is done
-** in three parts: Major(31-24).Minor(23-16).Revision.(15-0) (brackets are
-** the bits used). The Major number starts at 2 for the first revision with
-** the U14InitLib() function. Changes to the Major version means that we
-** have broken backwards compatibility. Minor number changes mean that we
-** have added new functionality that does not break backwards compatibility.
-** we starts at 0. Revision changes mean we have fixed something. Each index
-** returns to 0 when a higher one changes.
-*/
-#define U14LIB_MAJOR 4
-#define U14LIB_MINOR 0
-#define U14LIB_REVISION 0
-#define U14LIB_VERSION ((U14LIB_MAJOR<<24) | (U14LIB_MINOR<<16) | U14LIB_REVISION)
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "USE1401.H"
-
-#ifdef _IS_WINDOWS_
-#include <io.h>
-#include <windows.h>
-#pragma warning(disable: 4100) /* Disable "Unused formal parameter" warning */
-#include <assert.h>
-#include "process.h"
-
-
-#define sprintf wsprintf
-#define PATHSEP '\\'
-#define PATHSEPSTR "\\"
-#define DEFCMDPATH "\\1401\\"   // default command path if all else fails
-#define MINDRIVERMAJREV 1       // minimum driver revision level we need
-#define __packed                // does nothing in Windows
-
-#include "use14_ioc.h"          // links to device driver stuff
-#endif
-
-#ifdef LINUX
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <sched.h>
-#include <libgen.h>
-#define PATHSEP '/'
-#define PATHSEPSTR "/"
-#define DEFCMDPATH "/var/1401/" // default command path if all else fails
-#define MINDRIVERMAJREV 2       // minimum driver revision level we need
-
-#include "ced_ioctl.h"          // links to device driver stuff
-#endif
-
-#define MAX1401         8       // The number of 1401s that can be supported
-
-/*
-** These are the 1401 type codes returned by the driver, they are a slightly
-** odd sequence & start for reasons of compatibility with the DOS driver.
-** The maximum code value is the upper limit of 1401 device types.
-*/
-#define DRIVRET_STD     4       // Codes for 1401 types matching driver values
-#define DRIVRET_U1401   5       // This table does not need extending, as
-#define DRIVRET_PLUS    6       // we can calculate values now.
-#define DRIVRET_POWER   7       // but we need all of these values still
-#define DRIVRET_MAX     26      // Maximum tolerated code - future designs
-
-/*
-** These variables store data that will be used to generate the last
-** error string. For now, a string will hold the 1401 command file name.
-*/
-static char szLastName[20];     // additional text information
-
-/*
-** Information stored per handle. NBNB, driverType and DriverVersion used to be
-** only stored once for all handles... i.e. nonsensical. This change means that
-** three U14...() calls now include handles that were previously void. We have
-** set a constructor and a destructor call for the library (see the end) to
-** initialise important structures, or call use1401_load().
-*/
-static short asDriverType[MAX1401] = {0};
-static int lLastDriverVersion = U14ERR_NO1401DRIV;
-static int lLastDriverType = U14TYPEUNKNOWN;
-static int alDriverVersion[MAX1401];            // version/type of each driver
-static int alTimeOutPeriod[MAX1401];            // timeout time in milliseconds
-static short asLastRetCode[MAX1401];            // last code from a fn call
-static short asType1401[MAX1401] = {0};         // The type of the 1401
-static BOOL abGrabbed[MAX1401] = {0};           // Flag for grabbed, set true by grab1401
-static int iAttached = 0;                       // counts process attaches so can let go
-
-#ifdef _IS_WINDOWS_
-/****************************************************************************
-** Windows NT Specific Variables and internal types
-****************************************************************************/
-static HANDLE aHand1401[MAX1401] = {0};         // handles for 1401s
-static HANDLE aXferEvent[MAX1401] = {0};        // transfer events for the 1401s
-static LPVOID apAreas[MAX1401][MAX_TRANSAREAS]; // Locked areas
-static unsigned int  auAreas[MAX1401][MAX_TRANSAREAS]; // Size of locked areas
-static BOOL   bWindows9x = FALSE;               // if we are Windows 95 or better
-#ifdef _WIN64
-#define USE_NT_DIOC(ind) TRUE
-#else
-static BOOL   abUseNTDIOC[MAX1401];             // Use NT-style DIOC parameters */
-#define USE_NT_DIOC(ind) abUseNTDIOC[ind]
-#endif
-
-#endif
-
-#ifdef LINUX
-static int aHand1401[MAX1401] = {0};    // handles for 1401s
-#define INVALID_HANDLE_VALUE 0          // to avoid code differences
-#endif
-
-
-/*
-** The CmdHead relates to backwards compatibility with ancient Microsoft (and Sperry!)
-** versions of BASIC, where this header was needed so we could load a command into
-** memory.
-*/
-#pragma pack(1)                 // pack our structure
-typedef struct CmdHead          // defines header block on command
-{                               // for PC commands
-   char   acBasic[5];           // BASIC information - needed to align things
-   unsigned short   wBasicSz;             // size as seen by BASIC
-   unsigned short   wCmdSize;             // size of the following info
-} __packed CMDHEAD;
-#pragma pack()                  // back to normal
-
-/*
-** The rest of the header looks like this...
-**  int    iRelPnt;             relocation pointer... actual start
-**  char   acName[8];           string holding the command name
-**  BYTE   bMonRev;             monitor revision level
-**  BYTE   bCmdRev;             command revision level
-*/
-
-typedef CMDHEAD *LPCMDHEAD;     // pointer to a command header
-
-#define  MAXSTRLEN   255        // maximum string length we use
-#define  TOHOST      FALSE
-#define  TO1401      TRUE
-
-static short CheckHandle(short h)
-{
-    if ((h < 0) || (h >= MAX1401))  // must be legal range...
-        return U14ERR_BADHAND;
-    if (aHand1401[h] <= 0)          // must be open
-        return U14ERR_BADHAND;
-    return U14ERR_NOERROR;
-}
-
-#ifdef _IS_WINDOWS_
-/****************************************************************************
-** U14Status1401    Used for functions which do not pass any data in but
-**                  get data back
-****************************************************************************/
-static short U14Status1401(short sHand, LONG lCode, TCSBLOCK* pBlk)
-{
-    unsigned int dwBytes = 0;
-
-    if ((sHand < 0) || (sHand >= MAX1401))  /* Check parameters */
-        return U14ERR_BADHAND;
-#ifndef _WIN64
-    if (!USE_NT_DIOC(sHand)) 
-    {   /* Windows 9x DIOC methods? */
-        if (DeviceIoControl(aHand1401[sHand], lCode, NULL, 0, pBlk,sizeof(TCSBLOCK),&dwBytes,NULL))
-            return (short)((dwBytes>=sizeof(TCSBLOCK)) ? U14ERR_NOERROR : U14ERR_DRIVCOMMS);
-        else
-            return (short)GetLastError();
-    }
-    else
-#endif
-    {                                       /* Windows NT or USB driver */
-        PARAMBLK rWork;
-        rWork.sState = U14ERR_DRIVCOMMS;
-        if (DeviceIoControl(aHand1401[sHand], lCode, NULL, 0, &rWork,sizeof(PARAMBLK),&dwBytes,NULL) &&
-            (dwBytes >= sizeof(PARAMBLK)))
-        {
-            *pBlk = rWork.csBlock;
-            return rWork.sState;
-        }
-    }
-
-    return U14ERR_DRIVCOMMS;
-}
-
-/****************************************************************************
-** U14Control1401   Used for functions which pass data in and only expect
-**                  an error code back
-****************************************************************************/
-static short U14Control1401(short sHand, LONG lCode, TCSBLOCK* pBlk)
-{
-    unsigned int dwBytes = 0;
-
-    if ((sHand < 0) || (sHand >= MAX1401))              /* Check parameters */
-        return U14ERR_BADHAND;
-
-#ifndef _WIN64
-    if (!USE_NT_DIOC(sHand))                    
-    {                            /* Windows 9x DIOC methods */
-        if (DeviceIoControl(aHand1401[sHand], lCode, NULL, 0, pBlk, sizeof(TCSBLOCK), &dwBytes, NULL))
-            return (short)(dwBytes >= sizeof(TCSBLOCK) ? U14ERR_NOERROR : U14ERR_DRIVCOMMS);
-        else
-            return (short)GetLastError();
-    }
-    else
-#endif
-    {                            /* Windows NT or later */
-        PARAMBLK rWork;
-        rWork.sState = U14ERR_DRIVCOMMS;
-        if (DeviceIoControl(aHand1401[sHand], lCode, pBlk, sizeof(TCSBLOCK), &rWork, sizeof(PARAMBLK), &dwBytes, NULL) &&
-            (dwBytes >= sizeof(PARAMBLK)))
-            return rWork.sState;
-    }
-
-    return U14ERR_DRIVCOMMS;
-}
-#endif
-
-/****************************************************************************
-** SafeTickCount
-** Gets time in approximately units of a millisecond.
-*****************************************************************************/
-static long SafeTickCount(void)
-{
-#ifdef _IS_WINDOWS_
-    return GetTickCount();
-#endif
-#ifdef LINUX
-    struct timeval tv;
-    gettimeofday(&tv, NULL);
-    return (tv.tv_sec*1000 + tv.tv_usec/1000);
-#endif
-}
-
-/****************************************************************************
-** A utility routine to get the command file extension for a given type
-** of 1401. We assume the type code is vaguely legal.
-****************************************************************************/
-static int ExtForType(short sType, char* szExt)
-{
-    szExt[0] = 0;                       /* Default return is a blank string */
-    switch (sType)
-    {
-    case U14TYPE1401: strcpy(szExt, ".CMD");  break;    // Standard 1401
-    case U14TYPEPLUS: strcpy(szExt, ".GXC");  break;    // 1401 plus
-    default:               // All others are in a predictable sequence
-        strcpy(szExt, ".ARM");
-            szExt[3] = (char)('M' + sType - U14TYPEU1401);
-        if (szExt[3] > 'Z')             // Wrap round to ARA after ARZ
-                szExt[3] = (char)(szExt[3] - 26);
-    }
-    return 0;
-}
-
-/****************************************************************************
-**   U14WhenToTimeOut
-**       Returns the time to time out in time units suitable for the machine
-** we are running on  ie millsecs for pc/linux, or Mac/
-****************************************************************************/
-U14API(int) U14WhenToTimeOut(short hand)
-{
-    int iNow = SafeTickCount();
-    if ((hand >= 0) && (hand < MAX1401))
-        iNow += alTimeOutPeriod[hand];
-    return iNow;
-}
-
-/****************************************************************************
-** U14PassedTime
-** Returns non zero if the timed passed in has been passed 0 if not
-****************************************************************************/
-U14API(short) U14PassedTime(int lCheckTime)
-{
-    return (short)((SafeTickCount()-lCheckTime) > 0);
-}
-
-/****************************************************************************
-** TranslateString
-** Tidies up string that U14GetString returns. Converts all the commas in a
-** string to spaces. Removes terminating CR character. May do more in future.
-****************************************************************************/
-static void TranslateString(char* pStr)
-{
-    int i = 0;
-    while (pStr[i])
-    {
-        if (pStr[i] == ',')
-            pStr[i] = ' ';              /* convert comma to space */
-        ++i;
-    }
-
-    if ((i > 0) && (pStr[i-1] == '\n'))  /* kill terminating LF */
-        pStr[i-1] = (char)0;
-}
-
-/****************************************************************************
-** U14StrToLongs
-** Converts a string to an array of longs and returns the number of values
-****************************************************************************/
-U14API(short) U14StrToLongs(const char* pszBuff, U14LONG *palNums, short sMaxLongs)
-{
-    unsigned short wChInd = 0;                // index into source
-    short sLgInd = 0;               // index into result longs
-
-    while (pszBuff[wChInd] &&       // until we get to end of string...
-           (sLgInd < sMaxLongs))    // ...or filled the buffer
-    {
-        // Why not use a C Library converter?
-        switch (pszBuff[wChInd])
-        {
-        case '-':
-        case '0': case '1':   case '2': case '3':   case '4':
-        case '5': case '6':   case '7': case '8':   case '9':
-            {
-                BOOL bDone = FALSE; // true at end of number
-                int iSign = 1;      // sign of number
-                long lValue = 0;
-
-                while ((!bDone) && pszBuff[wChInd])
-                {
-                    switch (pszBuff[wChInd])
-                    {
-                    case '-':
-                        iSign = -1; // swap sign
-                        break;
-
-                    case '0': case '1':   case '2': case '3':   case '4':
-                    case '5': case '6':   case '7': case '8':   case '9':
-                        lValue *= 10;   // move to next digit base 10
-                        lValue += ((int)pszBuff[wChInd]-(int)'0');
-                        break;
-
-                    default:        // end of number
-                        bDone = TRUE;
-                        break;
-                    }
-                    wChInd++;       // move onto next character
-                }
-                palNums[sLgInd] = lValue * iSign;
-                sLgInd++;
-            }
-            break;
-
-        default:
-            wChInd++;               // look at next char
-            break;
-        }
-    }
-    return (sLgInd);
-}
-
-
-/****************************************************************************
-** U14LongsFrom1401
-** Gets the next waiting line from the 1401 and converts it longs
-** Returns the number of numbers read or an error.
-****************************************************************************/
-U14API(short) U14LongsFrom1401(short hand, U14LONG *palBuff, short sMaxLongs)
-{
-    char szWork[MAXSTRLEN];
-    short sResult = U14GetString(hand, szWork, MAXSTRLEN);/* get reply from 1401   */
-    if (sResult == U14ERR_NOERROR)                  /* if no error convert   */
-        sResult = U14StrToLongs(szWork, palBuff, sMaxLongs);
-    return sResult;
-}
-
-/****************************************************************************
-**   U14CheckErr
-**   Sends the ERR command to the 1401 and gets the result. Returns 0, a
-**   negative error code, or the first error value.
-****************************************************************************/
-U14API(short) U14CheckErr(short hand)
-{
-    short sResult = U14SendString(hand, ";ERR;");
-    if (sResult == U14ERR_NOERROR)
-    {
-        U14LONG er[3];
-        sResult = U14LongsFrom1401(hand, er, 3);
-        if (sResult > 0)
-        {
-            sResult = (short)er[0];        /* Either zero or an error value */
-#ifdef _DEBUG
-            if (er[0] != 0)
-            {
-                char szMsg[50];
-                sprintf(szMsg, "U14CheckErr returned %d,%d\n", er[0], er[1]);
-                OutputDebugString(szMsg);
-            }
-#endif
-        }
-        else
-        {
-            if (sResult == 0)
-                sResult = U14ERR_TIMEOUT;      /* No numbers equals timeout */
-        }
-    }
-
-    return sResult;
-}
-
-/****************************************************************************
-** U14LastErrCode
-** Returns the last code from the driver. This is for Windows where all calls
-** go through the Control and Status routines, so we can save any error.
-****************************************************************************/
-U14API(short) U14LastErrCode(short hand)
-{
-    if ((hand < 0) || (hand >= MAX1401))
-        return U14ERR_BADHAND;
-    return asLastRetCode[hand];
-}
-
-/****************************************************************************
-** U14SetTimeout
-** Set the timeout period for 1401 comms in milliseconds
-****************************************************************************/
-U14API(void) U14SetTimeout(short hand, int lTimeOut)
-{
-    if ((hand < 0) || (hand >= MAX1401))
-        return;
-    alTimeOutPeriod[hand] = lTimeOut;
-}
-
-/****************************************************************************
-** U14GetTimeout
-** Get the timeout period for 1401 comms in milliseconds
-****************************************************************************/
-U14API(int) U14GetTimeout(short hand)
-{
-    if ((hand < 0) || (hand >= MAX1401))
-        return U14ERR_BADHAND;
-    return alTimeOutPeriod[hand];
-}
-
-/****************************************************************************
-** U14OutBufSpace
-** Return the space in the output buffer, or an error.
-****************************************************************************/
-U14API(short) U14OutBufSpace(short hand)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    short sErr = U14Status1401(hand, U14_GETOUTBUFSPACE,&csBlock);
-    if (sErr == U14ERR_NOERROR)
-        sErr = csBlock.ints[0];
-    return sErr;
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_GetOutBufSpace(aHand1401[hand]) : sErr;
-#endif
-}
-
-
-/****************************************************************************
-** U14BaseAddr1401
-** Returns the 1401 base address or an error code. Meaningless nowadays
-****************************************************************************/
-U14API(int) U14BaseAddr1401(short hand)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    int iError = U14Status1401(hand, U14_GETBASEADDRESS,&csBlock);
-    if (iError == U14ERR_NOERROR)
-        iError = csBlock.longs[0];
-    return iError;
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_GetBaseAddress(aHand1401[hand]) : sErr;
-#endif
-}
-
-/****************************************************************************
-** U14StateOf1401
-** Return error state, either NOERROR or a negative code.
-****************************************************************************/
-U14API(short) U14StateOf1401(short hand)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    short sErr = U14Status1401(hand, U14_STATEOF1401, &csBlock);
-    if (sErr == U14ERR_NOERROR)
-    {
-        sErr = csBlock.ints[0];      // returned 1401 state
-        if ((sErr >= DRIVRET_STD) && (sErr <= DRIVRET_MAX))
-            sErr = U14ERR_NOERROR;
-    }
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    if (sErr == U14ERR_NOERROR)
-    {
-        sErr = (short)CED_StateOf1401(aHand1401[hand]);
-        if ((sErr >= DRIVRET_STD) && (sErr <= DRIVRET_MAX))
-            sErr = U14ERR_NOERROR;
-    }
-#endif
-    return sErr;
-}
-
-/****************************************************************************
-** U14DriverVersion
-** Returns the driver version. Hi word is major revision, low word is minor.
-** If you pass in a silly handle (like -1), we return the version of the last
-** driver we know of (to cope with PCI and no 1401 attached).
-****************************************************************************/
-U14API(int) U14DriverVersion(short hand)
-{
-    return CheckHandle(hand) != U14ERR_NOERROR ? lLastDriverVersion : alDriverVersion[hand];
-}
-
-/****************************************************************************
-** U14DriverType
-** Returns the driver type. The type, 0=ISA/NU-Bus, 1=PCI, 2=USB, 3=HSS
-** If you pass in a silly handle (like -1), we return the type of the last
-** driver we know of (to cope with PCI and no 1401 attached).
-****************************************************************************/
-U14API(int) U14DriverType(short hand)
-{
-    return CheckHandle(hand) != U14ERR_NOERROR ? lLastDriverType : asDriverType[hand];
-}
-
-/****************************************************************************
-** U14DriverName
-** Returns the driver type as 3 character (ISA, PCI, USB or HSS))
-****************************************************************************/
-U14API(short) U14DriverName(short hand, char* pBuf, unsigned short wMax)
-{
-    char* pName;
-    *pBuf = 0;                             // Start off with a blank string
-    switch (U14DriverType(hand))           // Results according to type
-    {
-    case 0:  pName = "ISA"; break;
-    case 1:  pName = "PCI"; break;
-    case 2:  pName = "USB"; break;
-    case 3:  pName = "HSS"; break;
-    default: pName = "???"; break;
-    }
-    strncpy(pBuf, pName, wMax);            // Copy the correct name to return
-
-    return U14ERR_NOERROR;
-}
-
-/****************************************************************************
-** U14BlkTransState
-** Returns 0 no transfer in progress, 1 transfer in progress or an error code
-****************************************************************************/
-U14API(short) U14BlkTransState(short hand)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    short sErr = U14Status1401(hand, U14_BLKTRANSSTATE, &csBlock);
-    if (sErr == U14ERR_NOERROR)
-        sErr = csBlock.ints[0];
-    return sErr;
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_BlkTransState(aHand1401[hand]) : sErr;
-#endif
-}
-
-/****************************************************************************
-** U14Grab1401
-** Take control of the 1401 for diagnostics purposes. USB does nothing.
-****************************************************************************/
-U14API(short) U14Grab1401(short hand)
-{
-    short sErr = CheckHandle(hand);
-    if (sErr == U14ERR_NOERROR)
-    {
-#ifdef _IS_WINDOWS_
-        if (abGrabbed[hand])            // 1401 should not have been grabbed
-            sErr = U14ERR_ALREADYSET;   // Error code defined for this
-        else
-        {
-            TCSBLOCK csBlock;
-            sErr = U14Control1401(hand, U14_GRAB1401, &csBlock);
-        }
-#endif
-#ifdef LINUX
-        // 1401 should not have been grabbed
-        sErr = abGrabbed[hand] ? U14ERR_ALREADYSET : CED_Grab1401(aHand1401[hand]);
-#endif
-        if (sErr == U14ERR_NOERROR)
-            abGrabbed[hand] = TRUE;
-    }
-    return sErr;
-}
-
-/****************************************************************************
-** U14Free1401
-****************************************************************************/
-U14API(short)  U14Free1401(short hand)
-{
-    short sErr = CheckHandle(hand);
-    if (sErr == U14ERR_NOERROR)
-    {
-#ifdef _IS_WINDOWS_
-        if (abGrabbed[hand])    // 1401 should have been grabbed
-        {
-            TCSBLOCK csBlock;
-            sErr = U14Control1401(hand, U14_FREE1401, &csBlock);
-        }
-        else
-            sErr = U14ERR_NOTSET;
-#endif
-#ifdef LINUX
-        // 1401 should not have been grabbed
-        sErr = abGrabbed[hand] ? CED_Free1401(aHand1401[hand]) : U14ERR_NOTSET;
-#endif
-        if (sErr == U14ERR_NOERROR)
-            abGrabbed[hand] = FALSE;
-    }
-    return sErr;
-}
-
-/****************************************************************************
-** U14Peek1401
-** DESCRIPTION  Cause the 1401 to do one or more peek operations.
-** If lRepeats is zero, the loop will continue until U14StopDebugLoop
-** is called. After the peek is done, use U14GetDebugData to retrieve
-** the results of the peek.
-****************************************************************************/
-U14API(short) U14Peek1401(short hand, unsigned int dwAddr, int nSize, int nRepeats)
-{
-    short sErr = CheckHandle(hand);
-    if (sErr == U14ERR_NOERROR)
-    {
-        if (abGrabbed[hand])    // 1401 should have been grabbed
-        {
-#ifdef _IS_WINDOWS_
-            TCSBLOCK csBlock;
-            csBlock.longs[0] = (long)dwAddr;
-            csBlock.longs[1] = nSize;
-            csBlock.longs[2] = nRepeats;
-            sErr = U14Control1401(hand, U14_DBGPEEK, &csBlock);
-#endif
-#ifdef LINUX
-            TDBGBLOCK dbb;
-            dbb.iAddr = (int)dwAddr;
-            dbb.iWidth = nSize;
-            dbb.iRepeats = nRepeats;
-            sErr = CED_DbgPeek(aHand1401[hand], &dbb);
-#endif
-        }
-        else
-            sErr = U14ERR_NOTSET;
-    }
-    return sErr;
-}
-
-/****************************************************************************
-** U14Poke1401
-** DESCRIPTION  Cause the 1401 to do one or more poke operations.
-** If lRepeats is zero, the loop will continue until U14StopDebugLoop
-** is called.
-****************************************************************************/
-U14API(short) U14Poke1401(short hand, unsigned int dwAddr, unsigned int dwValue,
-                                      int nSize, int nRepeats)
-{
-    short sErr = CheckHandle(hand);
-    if (sErr == U14ERR_NOERROR)
-    {
-        if (abGrabbed[hand])    // 1401 should have been grabbed
-        {
-#ifdef _IS_WINDOWS_
-            TCSBLOCK csBlock;
-            csBlock.longs[0] = (long)dwAddr;
-            csBlock.longs[1] = nSize;
-            csBlock.longs[2] = nRepeats;
-            csBlock.longs[3] = (long)dwValue;
-            sErr = U14Control1401(hand, U14_DBGPOKE, &csBlock);
-#endif
-#ifdef LINUX
-            TDBGBLOCK dbb;
-            dbb.iAddr = (int)dwAddr;
-            dbb.iWidth = nSize;
-            dbb.iRepeats= nRepeats;
-            dbb.iData = (int)dwValue;
-            sErr = CED_DbgPoke(aHand1401[hand], &dbb);
-#endif
-        }
-        else
-            sErr = U14ERR_NOTSET;
-    }
-    return sErr;
-}
-
-/****************************************************************************
-** U14Ramp1401
-** DESCRIPTION  Cause the 1401 to loop, writing a ramp to a location.
-** If lRepeats is zero, the loop will continue until U14StopDebugLoop.
-****************************************************************************/
-U14API(short) U14Ramp1401(short hand, unsigned int dwAddr, unsigned int dwDef, unsigned int dwEnable,
-                                      int nSize, int nRepeats)
-{
-    short sErr = CheckHandle(hand);
-    if (sErr == U14ERR_NOERROR)
-    {
-        if (abGrabbed[hand])    // 1401 should have been grabbed
-        {
-#ifdef _IS_WINDOWS_
-            TCSBLOCK csBlock;
-            csBlock.longs[0] = (long)dwAddr;
-            csBlock.longs[1] = (long)dwDef;
-            csBlock.longs[2] = (long)dwEnable;
-            csBlock.longs[3] = nSize;
-            csBlock.longs[4] = nRepeats;
-            sErr = U14Control1401(hand, U14_DBGRAMPDATA, &csBlock);
-#endif
-#ifdef LINUX
-            TDBGBLOCK dbb;
-            dbb.iAddr = (int)dwAddr;
-            dbb.iDefault = (int)dwDef;
-            dbb.iMask = (int)dwEnable;
-            dbb.iWidth = nSize;
-            dbb.iRepeats = nRepeats;
-            sErr = CED_DbgRampAddr(aHand1401[hand], &dbb);
-#endif
-        }
-        else
-            sErr = U14ERR_NOTSET;
-    }
-    return sErr;
-}
-
-/****************************************************************************
-** U14RampAddr
-** DESCRIPTION  Cause the 1401 to loop, reading from a ramping location.
-** If lRepeats is zero, the loop will continue until U14StopDebugLoop
-****************************************************************************/
-U14API(short) U14RampAddr(short hand, unsigned int dwDef, unsigned int dwEnable,
-                                      int nSize, int nRepeats)
-{
-    short sErr = CheckHandle(hand);
-    if (sErr == U14ERR_NOERROR)
-    {
-        if (abGrabbed[hand])    // 1401 should have been grabbed
-        {
-#ifdef _IS_WINDOWS_
-            TCSBLOCK csBlock;
-            csBlock.longs[0] = (long)dwDef;
-            csBlock.longs[1] = (long)dwEnable;
-            csBlock.longs[2] = nSize;
-            csBlock.longs[3] = nRepeats;
-            sErr = U14Control1401(hand, U14_DBGRAMPADDR, &csBlock);
-#endif
-#ifdef LINUX
-            TDBGBLOCK dbb;
-            dbb.iDefault = (int)dwDef;
-            dbb.iMask = (int)dwEnable;
-            dbb.iWidth = nSize;
-            dbb.iRepeats = nRepeats;
-            sErr = CED_DbgRampAddr(aHand1401[hand], &dbb);
-#endif
-        }
-        else
-            sErr = U14ERR_NOTSET;
-    }
-    return sErr;
-}
-
-/****************************************************************************
-**    U14StopDebugLoop
-**    DESCRIPTION Stops a peek\poke\ramp that, with repeats set to zero,
-**    will otherwise continue forever.
-****************************************************************************/
-U14API(short) U14StopDebugLoop(short hand)
-{
-    short sErr = CheckHandle(hand);
-    if (sErr == U14ERR_NOERROR)
-#ifdef _IS_WINDOWS_
-    {
-        if (abGrabbed[hand])    // 1401 should have been grabbed
-        {
-            TCSBLOCK csBlock;
-            sErr = U14Control1401(hand, U14_DBGSTOPLOOP, &csBlock);
-        }
-        else
-            sErr = U14ERR_NOTSET;
-    }
-#endif
-#ifdef LINUX
-        sErr = abGrabbed[hand] ? CED_DbgStopLoop(aHand1401[hand]) : U14ERR_NOTSET;
-#endif
-    return sErr;
-}
-
-/****************************************************************************
-** U14GetDebugData
-** DESCRIPTION Returns the result from a previous peek operation.
-****************************************************************************/
-U14API(short) U14GetDebugData(short hand, U14LONG* plValue)
-{
-    short sErr = CheckHandle(hand);
-    if (sErr == U14ERR_NOERROR)
-    {
-        if (abGrabbed[hand])    // 1401 should have been grabbed
-        {
-#ifdef _IS_WINDOWS_
-            TCSBLOCK csBlock;
-            sErr = U14Status1401(hand, U14_DBGGETDATA, &csBlock);
-            if (sErr == U14ERR_NOERROR)
-                *plValue = csBlock.longs[0];    // Return the data
-#endif
-#ifdef LINUX
-            TDBGBLOCK dbb;
-            sErr = CED_DbgGetData(aHand1401[hand], &dbb);
-            if (sErr == U14ERR_NOERROR)
-                *plValue = dbb.iData;                     /* Return the data */
-#endif
-        }
-        else
-            sErr = U14ERR_NOTSET;
-    }
-    return sErr;
-}
-
-/****************************************************************************
-** U14StartSelfTest
-****************************************************************************/
-U14API(short) U14StartSelfTest(short hand)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    return U14Control1401(hand, U14_STARTSELFTEST, &csBlock);
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_StartSelfTest(aHand1401[hand]) : sErr;
-#endif
-}
-
-/****************************************************************************
-** U14CheckSelfTest
-****************************************************************************/
-U14API(short) U14CheckSelfTest(short hand, U14LONG *pData)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    short sErr = U14Status1401(hand, U14_CHECKSELFTEST, &csBlock);
-    if (sErr == U14ERR_NOERROR)
-    {
-        pData[0] = csBlock.longs[0];        /* Return the results to user */
-        pData[1] = csBlock.longs[1];
-        pData[2] = csBlock.longs[2];
-    }
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    if (sErr == U14ERR_NOERROR)                /* Check parameters */
-    {
-        TGET_SELFTEST gst;
-        sErr = CED_CheckSelfTest(aHand1401[hand], &gst);
-        if (sErr == U14ERR_NOERROR)
-        {
-            pData[0] = gst.code;        /* Return the results to user */
-            pData[1] = gst.x;
-            pData[2] = gst.y;
-        }
-    }
-#endif
-    return sErr;
-}
-
-/****************************************************************************
-** U14GetUserMemorySize
-****************************************************************************/
-U14API(short) U14GetUserMemorySize(short hand, unsigned int *pMemorySize)
-{
-    // The original 1401 used a different command for getting the size
-    short sErr = U14SendString(hand, (asType1401[hand] == U14TYPE1401) ? "MEMTOP;" : "MEMTOP,?;");
-    *pMemorySize = 0;         /* if we get error then leave size set at 0  */
-    if (sErr == U14ERR_NOERROR)
-    {
-        U14LONG alLimits[4];
-        sErr = U14LongsFrom1401(hand, alLimits, 4);
-        if (sErr > 0)              /* +ve sErr is the number of values read */
-        {
-            sErr = U14ERR_NOERROR;                  /* All OK, flag success */
-            if (asType1401[hand] == U14TYPE1401)    /* result for standard  */
-                *pMemorySize = alLimits[0] - alLimits[1]; /* memtop-membot */
-            else
-                *pMemorySize = alLimits[0];   /* result for plus or u1401  */
-        }
-    }
-    return sErr;
-}
-
-/****************************************************************************
-** U14TypeOf1401
-** Returns the type of the 1401, maybe unknown
-****************************************************************************/
-U14API(short) U14TypeOf1401(short hand)
-{
-    if ((hand < 0) || (hand >= MAX1401))                /* Check parameters */
-        return U14ERR_BADHAND;
-    else
-        return asType1401[hand];
-}
-
-/****************************************************************************
-** U14NameOf1401
-** Returns the type of the 1401 as a string, blank if unknown
-****************************************************************************/
-U14API(short) U14NameOf1401(short hand, char* pBuf, unsigned short wMax)
-{
-    short sErr = CheckHandle(hand);
-    if (sErr == U14ERR_NOERROR)
-    {
-    char* pName;
-    switch (asType1401[hand])               // Results according to type
-    {
-    case U14TYPE1401:  pName = "Std 1401"; break;
-    case U14TYPEPLUS:  pName = "1401plus"; break;
-    case U14TYPEU1401: pName = "micro1401"; break;
-    case U14TYPEPOWER: pName = "Power1401"; break;
-    case U14TYPEU14012:pName = "Micro1401 mk II"; break;
-    case U14TYPEPOWER2:pName = "Power1401 mk II"; break;
-    case U14TYPEU14013:pName = "Micro1401-3"; break;
-    case U14TYPEPOWER3:pName = "Power1401-3"; break;
-    default:           pName = "Unknown";
-    }
-        strncpy(pBuf, pName, wMax);
-    }
-    return sErr;
-}
-
-/****************************************************************************
-** U14TransferFlags
-**  Returns the driver block transfer flags.
-**  Bits can be set - see U14TF_ constants in use1401.h
-*****************************************************************************/
-U14API(short) U14TransferFlags(short hand)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    short sErr = U14Status1401(hand, U14_TRANSFERFLAGS, &csBlock);
-    return (sErr == U14ERR_NOERROR) ? (short)csBlock.ints[0] : sErr;
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_TransferFlags(aHand1401[hand]) : sErr;
-#endif
-}
-
-/****************************************************************************
-** GetDriverVersion
-** Actually reads driver version from the device driver.
-** Hi word is major revision, low word is minor revision.
-** Assumes that hand has been checked. Also codes driver type in bits 24 up.
-*****************************************************************************/
-static int GetDriverVersion(short hand)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    int iErr = U14Status1401(hand, U14_GETDRIVERREVISION, &csBlock);
-    if (iErr == U14ERR_NOERROR)
-        iErr = csBlock.longs[0];
-    return iErr;
-#endif
-#ifdef LINUX
-    return CED_GetDriverRevision(aHand1401[hand]);
-#endif
-}
-
-/****************************************************************************
-** U14MonitorRev
-** Returns the 1401 monitor revision number.
-** The number returned is the minor revision - the part after the
-** decimal point - plus the major revision times 1000.
-*****************************************************************************/
-U14API(int) U14MonitorRev(short hand)
-{
-    int iRev = 0;
-    int iErr = CheckHandle(hand);
-    if (iErr != U14ERR_NOERROR)                 // Check open and in use
-        return iErr;
-
-    if (asType1401[hand] >= U14TYPEPOWER2)      // The Power2 onwards can give us the monitor
-    {                                           //  revision directly for all versions
-        iErr = U14SendString(hand, "INFO,S,28;");
-        if (iErr == U14ERR_NOERROR)
-        {
-            U14LONG lVals[2];                   // Read a single number being the revision
-            iErr = U14LongsFrom1401(hand, lVals, 1);
-            if (iErr > 0)
-            {
-                iErr = U14ERR_NOERROR;
-                iRev = lVals[0];                // This is the minor part of the revision
-                iRev += asType1401[hand] * 10000;
-            }
-        }
-    }
-    else
-    {                                           /* Do it the hard way for older hardware */
-        iErr = U14SendString(hand, ";CLIST;");     /* ask for command levels */
-        if (iErr == U14ERR_NOERROR)
-        {     
-            while (iErr == U14ERR_NOERROR)
-            {
-                char wstr[50];
-                iErr = U14GetString(hand, wstr, 45);
-                if (iErr == U14ERR_NOERROR)
-                {
-                    char *pstr = strstr(wstr,"RESET");  /* Is this the RESET command? */
-                    if ((pstr == wstr) && (wstr[5] == ' '))
-                    {
-                        char *pstr2;
-                        size_t l;
-                        pstr += 6;       /* Move past RESET and followinmg char */
-                        l = strlen(pstr);       /* The length of text remaining */
-                        while (((pstr[l-1] == ' ') || (pstr[l-1] == 13)) && (l > 0))
-                        {
-                            pstr[l-1] = 0;         /* Tidy up string at the end */
-                            l--;                  /* by removing spaces and CRs */
-                        }
-                        pstr2 = strchr(pstr, '.');    /* Find the decimal point */
-                        if (pstr2 != NULL)                /* If we found the DP */
-                        {
-                            *pstr2 = 0;                /* End pstr string at DP */
-                            pstr2++;              /* Now past the decimal point */
-                            iRev = atoi(pstr2);   /* Get the number after point */
-                        }
-                        iRev += (atoi(pstr) * 1000);    /* Add first bit * 1000 */
-                    }
-                    if ((strlen(wstr) < 3) && (wstr[0] == ' '))
-                        break;              /* Spot the last line of results */
-                }
-            }
-        }
-    }
-    if (iErr == U14ERR_NOERROR)            /* Return revision if no error */
-        iErr = iRev;
-
-    return iErr;
-}
-
-/****************************************************************************
-** U14TryToOpen     Tries to open the 1401 number passed
-**  Note : This will succeed with NT driver even if no I/F card or
-**         1401 switched off, so we check state and close the driver
-**         if the state is unsatisfactory in U14Open1401.
-****************************************************************************/
-#ifdef _IS_WINDOWS_
-#define U14NAMEOLD "\\\\.\\CED_140%d"
-#define U14NAMENEW "\\\\.\\CED%d"
-static short U14TryToOpen(int n1401, long* plRetVal, short* psHandle)
-{
-    short sErr = U14ERR_NOERROR;
-    HANDLE hDevice = INVALID_HANDLE_VALUE;
-    unsigned int dwErr = 0;
-    int nFirst, nLast, nDev = 0;        /* Used for the search for a 1401 */
-    BOOL bOldName = FALSE;               /* start by looking for a modern driver */
-
-    if (n1401 == 0)                             /* If we need to look for a 1401 */
-    {
-        nFirst = 1;                             /* Set the search range */
-        nLast = MAX1401;                        /* through all the possible 1401s */
-    }
-    else
-        nFirst = nLast = n1401;                 /* Otherwise just one 1401 */
-
-    while (hDevice == INVALID_HANDLE_VALUE)     /* Loop to try for a 1401 */
-    {
-        for (nDev = nFirst; nDev <= nLast; nDev++)
-        {
-            char szDevName[40];                 /* name of the device to open */
-            sprintf(szDevName, bOldName ? U14NAMEOLD : U14NAMENEW, nDev);
-            hDevice = CreateFile(szDevName, GENERIC_WRITE | GENERIC_READ,
-                                 0, 0,          /* Unshared mode does nothing as this is a device */
-                                 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-
-            if (hDevice != INVALID_HANDLE_VALUE)/* Check 1401 if opened */
-            {
-                TCSBLOCK csBlock;
-                assert(aHand1401[nDev-1] == INVALID_HANDLE_VALUE);  // assert if already open
-                aHand1401[nDev-1] = hDevice;    /* Save handle for now */
-
-#ifndef _WIN64
-                // Use DIOC method if not windows 9x or if using new device name
-                abUseNTDIOC[nDev-1] = (BOOL)(!bWindows9x || !bOldName);
-#endif
-                sErr = U14Status1401((short)(nDev-1), U14_TYPEOF1401, &csBlock);
-                if (sErr == U14ERR_NOERROR)
-                {
-                    *plRetVal = csBlock.ints[0];
-                    if (csBlock.ints[0] == U14ERR_INUSE)/* Prevent multi opens */
-                    {
-                        CloseHandle(hDevice);   /* treat as open failure */
-                        hDevice = INVALID_HANDLE_VALUE;
-                        aHand1401[nDev-1] = INVALID_HANDLE_VALUE;
-                        sErr = U14ERR_INUSE;
-                    }
-                    else
-                        break;                  /* Exit from for loop on success */
-                }
-                else
-                {
-                    CloseHandle(hDevice);       /* Give up if func fails */
-                    hDevice = INVALID_HANDLE_VALUE;
-                    aHand1401[nDev-1] = INVALID_HANDLE_VALUE;
-                }
-            }
-            else
-            {
-                unsigned int dwe = GetLastError();     /* Get error code otherwise */
-                if ((dwe != ERROR_FILE_NOT_FOUND) || (dwErr == 0))
-                    dwErr = dwe;                /* Ignore repeats of 'not found' */
-            }
-        }
-
-        if ((hDevice == INVALID_HANDLE_VALUE) &&/* No device found, and... */
-            (bWindows9x) &&                     /* ...old names are allowed, and... */
-            (bOldName == FALSE))                /* ...not tried old names yet */
-            bOldName = TRUE;                    /* Set flag and go round again */
-        else
-            break;                              /* otherwise that's all folks */
-    }
-
-    if (hDevice != INVALID_HANDLE_VALUE)        /* If we got our device open */
-        *psHandle = (short)(nDev-1);            /* return 1401 number opened */
-    else
-    {
-        if (dwErr == ERROR_FILE_NOT_FOUND)      /* Sort out the error codes */
-            sErr = U14ERR_NO1401DRIV;           /* if file not found */
-        else if (dwErr == ERROR_NOT_SUPPORTED)
-            sErr = U14ERR_DRIVTOOOLD;           /* if DIOC not supported */
-        else if (dwErr == ERROR_ACCESS_DENIED)
-            sErr = U14ERR_INUSE;
-        else
-            sErr = U14ERR_DRIVCOMMS;            /* otherwise assume comms problem */
-    }
-    return sErr;
-}
-#endif
-#ifdef LINUX
-static short U14TryToOpen(int n1401, long* plRetVal, short* psHandle)
-{
-    short sErr = U14ERR_NOERROR;
-    int fh = 0;                             // will be 1401 handle
-    int iErr = 0;
-    int nFirst, nLast, nDev = 0;            // Used for the search for a 1401
-
-    if (n1401 == 0)                         // If we need to look for a 1401
-    {
-        nFirst = 1;                             /* Set the search range */
-        nLast = MAX1401;                        /* through all the possible 1401s */
-    }
-    else
-        nFirst = nLast = n1401;                 /* Otherwise just one 1401 */
-
-    for (nDev = nFirst; nDev <= nLast; nDev++)
-    {
-        char szDevName[40];                 // name of the device to open
-        sprintf(szDevName,"/dev/cedusb/%d", nDev-1);
-        fh = open(szDevName, O_RDWR);       // can only be opened once at a time
-        if (fh > 0)                         // Check 1401 if opened
-        {
-            int iType1401 = CED_TypeOf1401(fh); // get 1401 type
-            aHand1401[nDev-1] = fh;         // Save handle for now
-            if (iType1401 >= 0)
-            {
-                *plRetVal = iType1401;
-                 break;                     // Exit from for loop on success
-            }
-            else
-            {
-                close(fh);                  // Give up if func fails
-                fh = 0;
-                aHand1401[nDev-1] = 0;
-            }
-        }
-        else
-        {
-            if (((errno != ENODEV) && (errno != ENOENT)) || (iErr == 0))
-                iErr = errno;                // Ignore repeats of 'not found'
-        }
-    }
-
-
-    if (fh)                                 // If we got our device open
-        *psHandle = (short)(nDev-1);        // return 1401 number opened
-    else
-    {
-        if ((iErr == ENODEV) || (iErr == ENOENT)) // Sort out the error codes
-            sErr = U14ERR_NO1401DRIV;       // if file not found
-        else if (iErr == EBUSY)
-            sErr = U14ERR_INUSE;
-        else
-            sErr = U14ERR_DRIVCOMMS;        // otherwise assume comms problem
-    }
-
-    return sErr;
-}
-#endif
-/****************************************************************************
-** U14Open1401
-** Tries to get the 1401 for use by this application
-*****************************************************************************/
-U14API(short) U14Open1401(short n1401)
-{
-    long     lRetVal = -1;
-    short    sErr;
-    short    hand = 0;
-    
-    if ((n1401 < 0) || (n1401 > MAX1401))       // must check the 1401 number
-        return U14ERR_BAD1401NUM;
-
-    szLastName[0] = 0;          /* initialise the error info string */
-
-    sErr = U14TryToOpen(n1401, &lRetVal, &hand);
-    if (sErr == U14ERR_NOERROR)
-    {
-        long lDriverVersion = GetDriverVersion(hand);   /* get driver revision */
-        long lDriverRev = -1;
-		if (lDriverVersion >= 0)                    /* can use it if all OK */
-        {
-            lLastDriverType = (lDriverVersion >> 24) & 0x000000FF;
-            asDriverType[hand] = (short)lLastDriverType;    /* Drv type */
-            lLastDriverVersion = lDriverVersion & 0x00FFFFFF;
-            alDriverVersion[hand] = lLastDriverVersion;     /* Actual version */
-            lDriverRev = ((lDriverVersion>>16) & 0x00FF);    /* use hi word */
-        }
-        else
-        {
-            U14Close1401(hand);    /* If there is a problem we should close */
-            return (short)lDriverVersion;      /* and return the error code */
-        }
-    
-        if (lDriverRev < MINDRIVERMAJREV)       /* late enough version?     */
-        {
-            U14Close1401(hand);    /* If there is a problem we should close */
-            return U14ERR_DRIVTOOOLD;           /* too old                  */
-        }
-    
-        asLastRetCode[hand] = U14ERR_NOERROR; /* Initialise this 1401s info */
-        abGrabbed[hand] = FALSE;          /* we are not in single step mode */
-        U14SetTimeout(hand, 3000);      /* set 3 seconds as default timeout */
-
-        switch (lRetVal)
-        {
-        case DRIVRET_STD:  asType1401[hand] = U14TYPE1401; break;      /* Some we do by hand */
-        case DRIVRET_U1401:asType1401[hand] = U14TYPEU1401; break;
-        case DRIVRET_PLUS: asType1401[hand] = U14TYPEPLUS; break;
-        default:  // For the power upwards, we can calculate the codes
-                if ((lRetVal >= DRIVRET_POWER) && (lRetVal <= DRIVRET_MAX))
-                    asType1401[hand] = (short)(lRetVal - (DRIVRET_POWER - U14TYPEPOWER));
-                else
-                    asType1401[hand] = U14TYPEUNKNOWN;
-                break;
-            }
-        U14KillIO1401(hand);                     /* resets the 1401 buffers */
-
-        if (asType1401[hand] != U14TYPEUNKNOWN)   /* If all seems OK so far */
-        {
-            sErr = U14CheckErr(hand);        /* we can check 1401 comms now */
-            if (sErr != 0)                       /* If this failed to go OK */
-                U14Reset1401(hand); /* Reset the 1401 to try to sort it out */
-        }
-
-        sErr = U14StateOf1401(hand);/* Get the state of the 1401 for return */
-        if (sErr == U14ERR_NOERROR)
-            sErr = hand;                 /* return the handle if no problem */
-        else
-            U14Close1401(hand);    /* If there is a problem we should close */
-    }
-
-    return sErr;
-}
-
-
-/****************************************************************************
-** U14Close1401
-** Closes the 1401 so someone else can use it.
-****************************************************************************/
-U14API(short) U14Close1401(short hand)
-{
-    int j;
-    int iAreaMask = 0;                          // Mask for active areas
-    short sErr = CheckHandle(hand);
-    if (sErr != U14ERR_NOERROR)                 // Check open and in use
-        return sErr;
-
-    for (j = 0; j<MAX_TRANSAREAS; ++j)
-    {
-        TGET_TX_BLOCK gtb;
-        int iReturn = U14GetTransfer(hand, &gtb);   // get area information
-        if (iReturn == U14ERR_NOERROR)          // ignore if any problem
-            if (gtb.used)
-                iAreaMask |= (1 << j);          // set a bit for each used area
-    }
-
-    if (iAreaMask)                              // if any areas are in use
-    {
-        U14Reset1401(hand);                     // in case an active transfer running
-        for (j = 0; j < MAX_TRANSAREAS; ++j)    // Locate locked areas
-            if (iAreaMask & (1 << j))           // And kill off any transfers
-                U14UnSetTransfer(hand, (unsigned short)j);
-    }
-
-#ifdef _IS_WINDOWS_
-    if (aXferEvent[hand])                       // if this 1401 has an open event handle
-    {
-        CloseHandle(aXferEvent[hand]);          // close down the handle
-        aXferEvent[hand] = NULL;                // and mark it as gone
-    }
-
-    if (CloseHandle(aHand1401[hand]))
-#endif
-#ifdef LINUX
-    if (close(aHand1401[hand]) == 0)            // make sure that close works
-#endif
-    {
-        aHand1401[hand] = INVALID_HANDLE_VALUE;
-        asType1401[hand] = U14TYPEUNKNOWN;
-        return U14ERR_NOERROR;
-    }
-    else
-        return U14ERR_BADHAND;     /* BUGBUG GetLastError() ? */
-}
-
-/**************************************************************************
-**
-** Look for open 1401s and attempt to close them down. 32-bit windows only.
-**************************************************************************/
-U14API(void) U14CloseAll(void)
-{
-    int i;
-    for (i = 0; i < MAX1401; i++)       // Tidy up and make safe
-        if (aHand1401[i] != INVALID_HANDLE_VALUE)
-            U14Close1401((short)i);     // Last ditch close 1401
-}
-
-/****************************************************************************
-** U14Reset1401
-** Resets the 1401
-****************************************************************************/
-U14API(short) U14Reset1401(short hand)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    return U14Control1401(hand, U14_RESET1401, &csBlock);
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_Reset1401(aHand1401[hand]) : sErr;
-#endif
-}
-
-/****************************************************************************
-** U14ForceReset
-**    Sets the 1401 full reset flag, so that next call to Reset1401 will
-**     always cause a genuine reset.
-*****************************************************************************/
-U14API(short) U14ForceReset(short hand)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    return U14Control1401(hand, U14_FULLRESET, &csBlock);
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_FullReset(aHand1401[hand]) : sErr;
-#endif
-}
-
-/****************************************************************************
-** U14KillIO1401
-**    Removes any pending IO from the buffers.
-*****************************************************************************/
-U14API(short) U14KillIO1401(short hand)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    return U14Control1401(hand, U14_KILLIO1401, &csBlock);
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_KillIO1401(aHand1401[hand]) : sErr;
-#endif
-}
-
-
-/****************************************************************************
-** U14SendString
-** Send characters to the 1401
-*****************************************************************************/
-U14API(short) U14SendString(short hand, const char* pString)
-{
-    int nChars;                     // length we are sending
-    long lTimeOutTicks;             // when to time out
-    BOOL bSpaceToSend;              // space to send yet
-    short sErr = CheckHandle(hand);
-    if (sErr != U14ERR_NOERROR)
-        return sErr;
-
-    nChars = (int)strlen(pString);  // get string length we want to send
-    if (nChars > MAXSTRLEN)
-        return U14ERR_STRLEN;       // String too long
-
-#ifdef _IS_WINDOWS_
-    // To get here we must wait for the buffer to have some space
-    lTimeOutTicks = U14WhenToTimeOut(hand);
-    do
-    {
-        bSpaceToSend = (BOOL)((long)U14OutBufSpace(hand) >= nChars);
-    }
-    while (!bSpaceToSend && !U14PassedTime(lTimeOutTicks));
-
-    if (!bSpaceToSend)             /* Last-ditch attempt to avoid timeout */
-    {           /* This can happen with anti-virus or network activity! */
-        int i;
-        for (i = 0; (i < 4) && (!bSpaceToSend); ++i)
-        {
-            Sleep(25);       /* Give other threads a chance for a while */
-            bSpaceToSend = (BOOL)((long)U14OutBufSpace(hand) >= nChars);
-        }
-    }
-
-    if (asLastRetCode[hand] == U14ERR_NOERROR)      /* no errors? */
-    {
-        if (bSpaceToSend)
-        {
-            PARAMBLK    rData;
-            unsigned int       dwBytes;
-            char        tstr[MAXSTRLEN+5];          /* Buffer for chars */
-
-            if ((hand < 0) || (hand >= MAX1401))
-                sErr = U14ERR_BADHAND;
-            else
-            {
-                strcpy(tstr, pString);              /* Into local buf */
-#ifndef _WIN64
-                if (!USE_NT_DIOC(hand))             /* Using WIN 95 driver access? */
-                {
-                    int iOK = DeviceIoControl(aHand1401[hand], (unsigned int)U14_SENDSTRING,
-                                    NULL, 0, tstr, nChars,
-                                    &dwBytes, NULL);
-                    if (iOK)
-                        sErr = (dwBytes >= (unsigned int)nChars) ? U14ERR_NOERROR : U14ERR_DRIVCOMMS;
-                    else
-                        sErr = (short)GetLastError();
-                }
-                else
-#endif
-                {
-                    int iOK = DeviceIoControl(aHand1401[hand],(unsigned int)U14_SENDSTRING,
-                                    tstr, nChars,
-                                    &rData,sizeof(PARAMBLK),&dwBytes,NULL);
-                    if (iOK && (dwBytes >= sizeof(PARAMBLK)))
-                        sErr = rData.sState;
-                    else
-                        sErr = U14ERR_DRIVCOMMS;
-                }
-
-                if (sErr != U14ERR_NOERROR) // If we have had a comms error
-                    U14ForceReset(hand);    //  make sure we get real reset
-            }
-
-            return sErr;
-
-        }
-        else
-        {
-            U14ForceReset(hand);                //  make sure we get real reset
-            return U14ERR_TIMEOUT;
-        }
-    }
-    else
-        return asLastRetCode[hand];
-#endif
-#ifdef LINUX
-    // Just try to send it and see what happens!
-    sErr = CED_SendString(aHand1401[hand], pString, nChars);
-    if (sErr != U14ERR_NOOUT)       // if any result except "no room in output"...
-    {
-        if (sErr != U14ERR_NOERROR) // if a problem...
-             U14ForceReset(hand);   // ...make sure we get real reset next time
-        return sErr;                // ... we are done as nothing we can do
-    }
-
-    // To get here we must wait for the buffer to have some space
-    lTimeOutTicks = U14WhenToTimeOut(hand);
-    do
-    {
-        bSpaceToSend = (BOOL)((long)U14OutBufSpace(hand) >= nChars);
-        if (!bSpaceToSend)
-            sched_yield();          // let others have fun while we wait
-    }
-    while (!bSpaceToSend && !U14PassedTime(lTimeOutTicks));
-
-    if (asLastRetCode[hand] == U14ERR_NOERROR)                /* no errors? */
-    {
-        if (bSpaceToSend)
-        {
-            sErr = CED_SendString(aHand1401[hand], pString, nChars);
-            if (sErr != U14ERR_NOERROR) // If we have had a comms error
-                U14ForceReset(hand);    //  make sure we get real reset
-            return sErr;
-        }
-        else
-        {
-            U14ForceReset(hand);                //  make sure we get real reset
-            return U14ERR_TIMEOUT;
-        }
-    }
-    else
-        return asLastRetCode[hand];
-#endif
-}
-
-/****************************************************************************
-** U14SendChar
-** Send character to the 1401
-*****************************************************************************/
-U14API(short) U14SendChar(short hand, char cChar)
-{
-#ifdef _IS_WINDOWS_
-    char sz[2]=" ";                         // convert to a string and send
-    sz[0] = cChar;
-    sz[1] = 0;
-    return(U14SendString(hand, sz));        // String routines are better
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_SendChar(aHand1401[hand], cChar) : sErr;
-#endif
-}
-
-/****************************************************************************
-** U14GetString
-** Get a string from the 1401. Returns a null terminated string.
-** The string is all the characters up to the next CR in the buffer
-** or the end of the buffer if that comes first. This only returns text
-** if there is a CR in the buffer. The terminating CR character is removed.
-** wMaxLen  Is the size of the buffer and must be at least 2 or an error.
-** Returns  U14ERR_NOERR if OK with the result in the string or a negative
-**          error code. Any error from the device causes us to set up for
-**          a full reset.
-****************************************************************************/
-U14API(short) U14GetString(short hand, char* pBuffer, unsigned short wMaxLen)
-{
-    short sErr = CheckHandle(hand);
-    if (sErr != U14ERR_NOERROR)             // If an error...
-        return sErr;                        // ...bail out!
-
-#ifdef _IS_WINDOWS_
-    if (wMaxLen>1)                          // we need space for terminating 0
-    {
-        BOOL bLineToGet;                    // true when a line to get
-        long lTimeOutTicks = U14WhenToTimeOut(hand);
-        do
-            bLineToGet = (BOOL)(U14LineCount(hand) != 0);
-        while (!bLineToGet && !U14PassedTime(lTimeOutTicks));
-
-        if (!bLineToGet)             /* Last-ditch attempt to avoid timeout */
-        {           /* This can happen with anti-virus or network activity! */
-            int i;
-            for (i = 0; (i < 4) && (!bLineToGet); ++i)
-            {
-                Sleep(25);       /* Give other threads a chance for a while */
-                bLineToGet = (BOOL)(U14LineCount(hand) != 0);
-            }
-        }
-
-        if (bLineToGet)
-        {
-            if (asLastRetCode[hand] == U14ERR_NOERROR)     /* all ok so far */
-            {
-                unsigned int       dwBytes = 0;
-                *((unsigned short *)pBuffer) = wMaxLen;       /* set up length */
-#ifndef _WIN64
-                if (!USE_NT_DIOC(hand))             /* Win 95 DIOC here ? */
-                {
-                    char tstr[MAXSTRLEN+5];         /* Buffer for Win95 chars */
-                    int iOK;
-
-                    if (wMaxLen > MAXSTRLEN)        /* Truncate length */
-                        wMaxLen = MAXSTRLEN;    
-
-                    *((unsigned short *)tstr) = wMaxLen;      /* set len */
-
-                    iOK = DeviceIoControl(aHand1401[hand],(unsigned int)U14_GETSTRING,
-                                    NULL, 0, tstr, wMaxLen+sizeof(short),
-                                    &dwBytes, NULL);
-                    if (iOK)                        /* Device IO control OK ? */
-                    {
-                        strcpy(pBuffer, tstr);
-                        sErr = U14ERR_NOERROR;
-                    }
-                    else
-                    {
-                        sErr = (short)GetLastError();
-                        if (sErr > 0)               /* Errors are -ve */
-                            sErr = (short)-sErr;
-                    }
-                }
-                else
-#endif
-                {       /* Here for NT, the DLL must own the buffer */
-                    HANDLE hMem = GlobalAlloc(GMEM_MOVEABLE,wMaxLen+sizeof(short));
-                    if (hMem)
-                    {
-                        char* pMem = (char*)GlobalLock(hMem);
-                        if (pMem)
-                        {
-                            int iOK = DeviceIoControl(aHand1401[hand],(unsigned int)U14_GETSTRING,
-                                            NULL, 0, pMem, wMaxLen+sizeof(short),
-                                            &dwBytes, NULL);
-                            if (iOK)                /* Device IO control OK ? */
-                            {
-                                if (dwBytes >= wMaxLen)
-                                {
-                                    strcpy(pBuffer, pMem+sizeof(short));
-                                    sErr = *((SHORT*)pMem);
-                                }
-                                else
-                                    sErr = U14ERR_DRIVCOMMS;
-                            }
-                            else
-                                sErr = U14ERR_DRIVCOMMS;
-
-                            GlobalUnlock(hMem);
-                        }
-                        else
-                            sErr = U14ERR_OUTOFMEMORY;
-
-                        GlobalFree(hMem);
-                    }
-                    else
-                        sErr = U14ERR_OUTOFMEMORY;
-                }
-
-                if (sErr == U14ERR_NOERROR)     // If all OK...
-                    TranslateString(pBuffer);   // ...convert any commas to spaces
-                else                            // If we have had a comms error...
-                    U14ForceReset(hand);        // ...make sure we get real reset
-
-            }
-            else
-                sErr = asLastRetCode[hand];
-        }
-        else
-        {
-            sErr = U14ERR_TIMEOUT;
-            U14ForceReset(hand);            //  make sure we get real reset
-        }
-    }
-    else
-        sErr = U14ERR_BUFF_SMALL;
-    return sErr;
-#endif
-#ifdef LINUX
-    if (wMaxLen>1)                          // we need space for terminating 0
-    {
-        BOOL bLineToGet;                    // true when a line to get
-        long lTimeOutTicks = U14WhenToTimeOut(hand);
-        do
-        {
-            bLineToGet = (BOOL)(U14LineCount(hand) != 0);
-            if (!bLineToGet)
-                sched_yield();
-
-        }
-        while (!bLineToGet && !U14PassedTime(lTimeOutTicks));
-
-        if (bLineToGet)
-        {
-            sErr = CED_GetString(aHand1401[hand], pBuffer, wMaxLen-1);   // space for terminator
-            if (sErr >=0)                    // if we were OK...
-            {
-                if (sErr >= wMaxLen)         // this should NOT happen unless
-                    sErr = U14ERR_DRIVCOMMS; // ...driver Comms are very bad
-                else
-                {
-                    pBuffer[sErr] = 0;      // OK, so terminate the string...
-                    TranslateString(pBuffer);  // ...and convert commas to spaces.
-                }
-            }
-
-            if (sErr < U14ERR_NOERROR)       // If we have had a comms error
-                U14ForceReset(hand);            //  make sure we get real reset
-        }
-        else
-        {
-            sErr = U14ERR_TIMEOUT;
-            U14ForceReset(hand);            //  make sure we get real reset
-        }
-    }
-    else
-        sErr = U14ERR_BUFF_SMALL;
-
-    return sErr >= U14ERR_NOERROR ? U14ERR_NOERROR : sErr;
-#endif
-}
-
-/****************************************************************************
-** U14GetChar
-** Get a character from the 1401. CR returned as CR.
-*****************************************************************************/
-U14API(short) U14GetChar(short hand, char* pcChar)
-{
-#ifdef _IS_WINDOWS_
-    char sz[2];                             // read a very short string
-    short sErr = U14GetString(hand, sz, 2); // read one char and nul terminate it
-    *pcChar = sz[0];    // copy to result, NB char translate done by GetString
-    if (sErr == U14ERR_NOERROR)
-    {                                       // undo translate of CR to zero
-        if (*pcChar == '\0')                // by converting back
-            *pcChar = '\n';                 // What a nasty thing to have to do
-    }
-    return sErr;
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    if (sErr != U14ERR_NOERROR)             // Check parameters
-        return sErr;
-    sErr = CED_GetChar(aHand1401[hand]);    // get one char, if available
-    if (sErr >= 0)
-    {
-        *pcChar = (char)sErr;              // return if it we have one
-        return U14ERR_NOERROR;              // say all OK
-    }
-    else
-        return sErr;
-#endif
-}
-
-/****************************************************************************
-** U14Stat1401
-** Returns 0 for no lines or error or non zero for something waiting
-****************************************************************************/
-U14API(short) U14Stat1401(short hand)
-{
-    return ((short)(U14LineCount(hand) > 0));
-}
-
-/****************************************************************************
-** U14CharCount
-** Returns the number of characters in the input buffer
-*****************************************************************************/
-U14API(short) U14CharCount(short hand)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    short sErr = U14Status1401(hand, U14_STAT1401, &csBlock);
-    if (sErr == U14ERR_NOERROR)
-        sErr = csBlock.ints[0];
-    return sErr;
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_Stat1401(aHand1401[hand]) : sErr;
-#endif
-}
-
-/****************************************************************************
-** U14LineCount
-** Returns the number of CR characters in the input buffer
-*****************************************************************************/
-U14API(short) U14LineCount(short hand)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    short sErr = U14Status1401(hand, U14_LINECOUNT, &csBlock);
-    if (sErr == U14ERR_NOERROR)
-        sErr = csBlock.ints[0];
-    return sErr;
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_LineCount(aHand1401[hand]) : sErr;
-#endif
-}
-
-/****************************************************************************
-** U14GetErrorString
-** Converts error code supplied to a decent descriptive string.
-** NOTE: This function may use some extra information stored
-**       internally in the DLL. This information is stored on a
-**       per-process basis, but it might be altered if you call
-**       other functions after getting an error and before using
-**       this function.
-****************************************************************************/
-U14API(void)  U14GetErrorString(short nErr, char* pStr, unsigned short wMax)
-{
-    char    wstr[150];
-
-    switch (nErr)              /* Basically, we do this with a switch block */
-    {
-    case U14ERR_OFF:
-        sprintf(wstr, "The 1401 is apparently switched off (code %d)", nErr);
-        break;
-
-    case U14ERR_NC:
-        sprintf(wstr, "The 1401 is not connected to the interface card (code %d)", nErr);
-        break;
-
-    case U14ERR_ILL:
-        sprintf(wstr, "The 1401 is not working correctly (code %d)", nErr);
-        break;
-
-    case U14ERR_NOIF:
-        sprintf(wstr, "The 1401 interface card was not detected (code %d)", nErr);
-        break;
-
-    case U14ERR_TIME:
-        sprintf(wstr, "The 1401 fails to become ready for use (code %d)", nErr);
-        break;
-
-    case U14ERR_BADSW:
-        sprintf(wstr, "The 1401 interface card jumpers are incorrect (code %d)", nErr);
-        break;
-
-    case U14ERR_NOINT:
-        sprintf(wstr, "The 1401 interrupt is not available for use (code %d)", nErr);
-        break;
-
-    case U14ERR_INUSE:
-        sprintf(wstr, "The 1401 is already in use by another program (code %d)", nErr);
-        break;
-
-    case U14ERR_NODMA:
-        sprintf(wstr, "The 1401 DMA channel is not available for use (code %d)", nErr);
-        break;
-
-    case U14ERR_BADHAND:
-        sprintf(wstr, "The application supplied an incorrect 1401 handle (code %d)", nErr);
-        break;
-
-    case U14ERR_BAD1401NUM:
-        sprintf(wstr, "The application used an incorrect 1401 number (code %d)", nErr);
-        break;
-
-    case U14ERR_NO_SUCH_FN:
-        sprintf(wstr, "The code passed to the 1401 driver is invalid (code %d)", nErr);
-        break;
-
-    case U14ERR_NO_SUCH_SUBFN:
-        sprintf(wstr, "The sub-code passed to the 1401 driver is invalid (code %d)", nErr);
-        break;
-
-    case U14ERR_NOOUT:
-        sprintf(wstr, "No room in buffer for characters for the 1401 (code %d)", nErr);
-        break;
-
-    case U14ERR_NOIN:
-        sprintf(wstr, "No characters from the 1401 are available (code %d)", nErr);
-        break;
-
-    case U14ERR_STRLEN:
-        sprintf(wstr, "A string sent to or read from the 1401 was too long (code %d)", nErr);
-        break;
-
-    case U14ERR_LOCKFAIL:
-        sprintf(wstr, "Failed to lock host memory for data transfer (code %d)", nErr);
-        break;
-
-    case U14ERR_UNLOCKFAIL:
-        sprintf(wstr, "Failed to unlock host memory after data transfer (code %d)", nErr);
-        break;
-
-    case U14ERR_ALREADYSET:
-        sprintf(wstr, "The transfer area used is already set up (code %d)", nErr);
-        break;
-
-    case U14ERR_NOTSET:
-        sprintf(wstr, "The transfer area used has not been set up (code %d)", nErr);
-        break;
-
-    case U14ERR_BADAREA:
-        sprintf(wstr, "The transfer area number is incorrect (code %d)", nErr);
-        break;
-
-    case U14ERR_NOFILE:
-        sprintf(wstr, "The command file %s could not be opened (code %d)", szLastName, nErr);
-        break;
-
-    case U14ERR_READERR:
-        sprintf(wstr, "The command file %s could not be read (code %d)", szLastName, nErr);
-        break;
-
-    case U14ERR_UNKNOWN:
-        sprintf(wstr, "The %s command resource could not be found (code %d)", szLastName, nErr);
-        break;
-
-    case U14ERR_HOSTSPACE:
-        sprintf(wstr, "Unable to allocate memory for loading command %s (code %d)", szLastName, nErr);
-        break;
-
-    case U14ERR_LOCKERR:
-        sprintf(wstr, "Unable to lock memory for loading command %s (code %d)", szLastName, nErr);
-        break;
-
-    case U14ERR_CLOADERR:
-        sprintf(wstr, "Error in loading command %s, bad command format (code %d)", szLastName, nErr);
-        break;
-
-    case U14ERR_TOXXXERR:
-        sprintf(wstr, "Error detected after data transfer to or from the 1401 (code %d)", nErr);
-        break;
-
-    case U14ERR_NO386ENH:
-        sprintf(wstr, "Windows 3.1 is not running in 386 enhanced mode (code %d)", nErr);
-        break;
-
-    case U14ERR_NO1401DRIV:
-        sprintf(wstr, "The 1401 device driver cannot be found (code %d)\nUSB:   check plugged in and powered\nOther: not installed?", nErr);
-        break;
-
-    case U14ERR_DRIVTOOOLD:
-        sprintf(wstr, "The 1401 device driver is too old for use (code %d)", nErr);
-        break;
-
-    case U14ERR_TIMEOUT:
-        sprintf(wstr, "Character transmissions to the 1401 timed-out (code %d)", nErr);
-        break;
-
-    case U14ERR_BUFF_SMALL:
-        sprintf(wstr, "Buffer for text from the 1401 was too small (code %d)", nErr);
-        break;
-
-    case U14ERR_CBALREADY:
-        sprintf(wstr, "1401 monitor callback already set up (code %d)", nErr);
-        break;
-
-    case U14ERR_BADDEREG:
-        sprintf(wstr, "1401 monitor callback deregister invalid (code %d)", nErr);
-        break;
-
-    case U14ERR_DRIVCOMMS:
-        sprintf(wstr, "1401 device driver communications failed (code %d)", nErr);
-        break;
-
-    case U14ERR_OUTOFMEMORY:
-        sprintf(wstr, "Failed to allocate or lock memory for text from the 1401 (code %d)", nErr);
-        break;
-
-    default:
-        sprintf(wstr, "1401 error code %d returned; this code is unknown", nErr);
-        break;
-
-    }
-    if ((unsigned short)strlen(wstr) >= wMax-1)  /* Check for string being too long */
-        wstr[wMax-1] = 0;                          /* and truncate it if so */
-    strcpy(pStr, wstr);                       /* Return the error string */
-}
-
-/***************************************************************************
-** U14GetTransfer
-** Get a TGET_TX_BLOCK describing a transfer area (held in the block)
-***************************************************************************/
-U14API(short) U14GetTransfer(short hand, TGET_TX_BLOCK *pTransBlock)
-{
-    short sErr = CheckHandle(hand);
-#ifdef _IS_WINDOWS_
-    if (sErr == U14ERR_NOERROR)
-    { 
-        unsigned int dwBytes = 0;
-        BOOL bOK = DeviceIoControl(aHand1401[hand], (unsigned int)U14_GETTRANSFER, NULL, 0, pTransBlock,
-                              sizeof(TGET_TX_BLOCK), &dwBytes, NULL);
-    
-        if (bOK && (dwBytes >= sizeof(TGET_TX_BLOCK)))
-            sErr = U14ERR_NOERROR;
-        else
-            sErr = U14ERR_DRIVCOMMS;
-    }
-    return sErr;
-#endif
-#ifdef LINUX
-    return (sErr == U14ERR_NOERROR) ? CED_GetTransfer(aHand1401[hand], pTransBlock) : sErr;
-#endif
-}
-/////////////////////////////////////////////////////////////////////////////
-// U14WorkingSet
-// For Win32 only, adjusts process working set so that minimum is at least
-//  dwMinKb and maximum is at least dwMaxKb.
-// Return value is zero if all went OK, or a code from 1 to 3 indicating the
-//  cause of the failure:
-//
-//     1 unable to access process (insufficient rights?)
-//     2 unable to read process working set
-//     3 unable to set process working set - bad parameters?
-U14API(short) U14WorkingSet(unsigned int dwMinKb, unsigned int dwMaxKb)
-{
-#ifdef _IS_WINDOWS_
-    short sRetVal = 0;                      // 0 means all is OK
-    HANDLE hProcess;
-    unsigned int dwVer = GetVersion();
-	if (dwVer & 0x80000000)                 // is this not NT?
-        return 0;                           // then give up right now
-
-    // Now attempt to get information on working set size
-    hProcess = OpenProcess(STANDARD_RIGHTS_REQUIRED |
-                                  PROCESS_QUERY_INFORMATION |
-                                  PROCESS_SET_QUOTA,
-                                  FALSE, _getpid());
-    if (hProcess)
-    {
-        SIZE_T dwMinSize,dwMaxSize;
-        if (GetProcessWorkingSetSize(hProcess, &dwMinSize, &dwMaxSize))
-        {
-            unsigned int dwMin = dwMinKb << 10;    // convert from kb to bytes
-            unsigned int dwMax = dwMaxKb << 10;
-
-            // if we get here, we have managed to read the current size
-            if (dwMin > dwMinSize)          // need to change sizes?
-                dwMinSize = dwMin;
-
-            if (dwMax > dwMaxSize)
-                dwMaxSize = dwMax;
-
-            if (!SetProcessWorkingSetSize(hProcess, dwMinSize, dwMaxSize))
-                sRetVal = 3;                // failed to change size
-        }
-        else
-            sRetVal = 2;                    // failed to read original size
-
-        CloseHandle(hProcess);
-    }
-    else
-        sRetVal = 1;            // failed to get handle
-
-    return sRetVal;
-#endif
-#ifdef LINUX
-    if (dwMinKb | dwMaxKb)
-    {
-        // to stop compiler moaning
-    }
-    return U14ERR_NOERROR;
-#endif
-}
-
-/****************************************************************************
-** U14UnSetTransfer  Cancels a transfer area
-** wArea    The index of a block previously used in by SetTransfer
-*****************************************************************************/
-U14API(short) U14UnSetTransfer(short hand, unsigned short wArea)
-{
-    short sErr = CheckHandle(hand);
-#ifdef _IS_WINDOWS_
-    if (sErr == U14ERR_NOERROR)
-    {
-       TCSBLOCK csBlock;
-       csBlock.ints[0] = (short)wArea;       /* Area number into control block */
-       sErr = U14Control1401(hand, U14_UNSETTRANSFER, &csBlock);  /* Free area */
-   
-       VirtualUnlock(apAreas[hand][wArea], auAreas[hand][wArea]);/* Unlock */
-       apAreas[hand][wArea] = NULL;                         /* Clear locations */
-       auAreas[hand][wArea] = 0;
-    }
-    return sErr;
-#endif
-#ifdef LINUX
-    return (sErr == U14ERR_NOERROR) ? CED_UnsetTransfer(aHand1401[hand], wArea) : sErr;
-#endif
-}
-
-/****************************************************************************
-** U14SetTransArea      Sets an area up to be used for transfers
-** unsigned short  wArea     The area number to set up
-** void *pvBuff    The address of the buffer for the data.
-** unsigned int dwLength  The length of the buffer for the data
-** short eSz       The element size (used for byte swapping on the Mac)
-****************************************************************************/
-U14API(short) U14SetTransArea(short hand, unsigned short wArea, void *pvBuff,
-                                          unsigned int dwLength, short eSz)
-{
-    struct transfer_area_desc td;
-    short sErr = CheckHandle(hand);
-    if (sErr != U14ERR_NOERROR)
-        return sErr;
-    if (wArea >= MAX_TRANSAREAS)                    // Is this a valid area number
-        return U14ERR_BADAREA;
-
-#ifdef _IS_WINDOWS_
-    assert(apAreas[hand][wArea] == NULL);
-    assert(auAreas[hand][wArea] == 0);
-
-    apAreas[hand][wArea] = pvBuff;                  /* Save data for later */
-    auAreas[hand][wArea] = dwLength;
-
-    if (!VirtualLock(pvBuff, dwLength))             /* Lock using WIN32 calls */
-    {
-        apAreas[hand][wArea] = NULL;                /* Clear locations */
-        auAreas[hand][wArea] = 0;
-        return U14ERR_LOCKERR;                      /* VirtualLock failed */
-    }
-#ifndef _WIN64
-    if (!USE_NT_DIOC(hand))                         /* Use Win 9x DIOC? */
-    {
-        unsigned int dwBytes;
-        VXTRANSFERDESC vxDesc;                      /* Structure to pass to VXD */
-        vxDesc.wArea = wArea;                       /* Copy across simple params */
-        vxDesc.dwLength = dwLength;
-
-        // Check we are not asking an old driver for more than area 0
-        if ((wArea != 0) && (U14DriverVersion(hand) < 0x00010002L))
-            sErr = U14ERR_DRIVTOOOLD;
-        else
-        {
-            vxDesc.dwAddrOfs = (unsigned int)pvBuff;       /* 32 bit offset */
-            vxDesc.wAddrSel  = 0;
-
-            if (DeviceIoControl(aHand1401[hand], (unsigned int)U14_SETTRANSFER,
-                                pvBuff,dwLength,    /* Will translate pointer */
-                                &vxDesc,sizeof(VXTRANSFERDESC),
-                                &dwBytes,NULL))
-            {
-                if (dwBytes >= sizeof(VXTRANSFERDESC)) /* Driver OK ? */
-                    sErr = U14ERR_NOERROR;
-                else
-                    sErr = U14ERR_DRIVCOMMS;        /* Else never got there */
-            }
-            else
-                sErr = (short)GetLastError();
-        }
-    }
-    else
-#endif
-    {
-        PARAMBLK rWork;
-        unsigned int dwBytes;
-        td.wArea = wArea;     /* Pure NT - put data into struct */
-        td.lpvBuff = pvBuff;
-        td.dwLength = dwLength;
-        td.eSize = 0;                // Dummy element size
-
-        if (DeviceIoControl(aHand1401[hand],(unsigned int)U14_SETTRANSFER,
-                            &td,sizeof(struct transfer_area_desc),
-                            &rWork,sizeof(PARAMBLK),&dwBytes,NULL))
-        {
-            if (dwBytes >= sizeof(PARAMBLK))    // maybe error from driver?
-                sErr = rWork.sState;            // will report any error
-            else
-                sErr = U14ERR_DRIVCOMMS;        // Else never got there
-        }
-        else
-            sErr = U14ERR_DRIVCOMMS;
-    }
-
-    if (sErr != U14ERR_NOERROR)
-    {
-        if (sErr != U14ERR_LOCKERR)             // unless lock failed...
-            VirtualUnlock(pvBuff, dwLength);    // ...release the lock
-        apAreas[hand][wArea] = NULL;            // Clear locations
-        auAreas[hand][wArea] = 0;
-    }
-
-    return sErr;
-#endif
-#ifdef LINUX
-    // The strange cast is so that it works in 64 and 32-bit linux as long is 64-bits
-    // in the 64 bit version.
-    td.lpvBuff = (long long)((unsigned long)pvBuff);
-    td.wAreaNum = wArea;
-    td.dwLength = dwLength;
-    td.eSize = eSz;                // Dummy element size
-    return CED_SetTransfer(aHand1401[hand], &td);
-#endif
-}
-
-/****************************************************************************
-** U14SetTransferEvent  Sets an event for notification of application
-** wArea       The transfer area index, from 0 to MAXAREAS-1
-**    bEvent      True to create an event, false to remove it
-**    bToHost     Set 0 for notification on to1401 tranfers, 1 for
-**                notification of transfers to the host PC
-**    dwStart     The offset of the sub-area of interest
-**    dwLength    The size of the sub-area of interest
-**
-** The device driver will set the event supplied to the signalled state
-** whenever a DMA transfer to/from the specified area is completed. The
-** transfer has to be in the direction specified by bToHost, and overlap
-** that part of the whole transfer area specified by dwStart and dwLength.
-** It is important that this function is called with bEvent false to release
-** the event once 1401 activity is finished.
-**
-** Returns 1 if an event handle exists, 0 if all OK and no event handle or
-** a negative code for an error.
-****************************************************************************/
-U14API(short) U14SetTransferEvent(short hand, unsigned short wArea, BOOL bEvent,
-                                  BOOL bToHost, unsigned int dwStart, unsigned int dwLength)
-{
-#ifdef _IS_WINDOWS_
-    TCSBLOCK csBlock;
-    short sErr = U14TransferFlags(hand);        // see if we can handle events
-    if (sErr >= U14ERR_NOERROR)                 // check handle is OK
-    {
-        bEvent = bEvent && ((sErr & U14TF_NOTIFY) != 0); // remove request if we cannot do events
-        if (wArea >= MAX_TRANSAREAS)            // Check a valid area...
-            return U14ERR_BADAREA;              // ...and bail of not
-
-        // We can hold an event for each area, so see if we need to change the
-        // state of the event.
-        if ((bEvent != 0) != (aXferEvent[hand] != 0))    // change of event state?
-        {
-            if (bEvent)                         // want one and none present
-                aXferEvent[hand] = CreateEvent(NULL, FALSE, FALSE, NULL);
-            else
-            {
-                CloseHandle(aXferEvent[hand]);  // clear the existing event
-                aXferEvent[hand] = NULL;        // and clear handle
-            }
-        }
-
-        // We have to store the parameters differently for 64-bit operations
-        //  because a handle is 64 bits long. The drivers know of this and
-        //  handle the information appropriately.
-#ifdef _WIN64
-        csBlock.longs[0] = wArea;               // Pass paramaters into the driver...
-        if (bToHost != 0)                       // The direction flag is held in the
-            csBlock.longs[0] |= 0x10000;        //  upper word of the transfer area value
-        *((HANDLE*)&csBlock.longs[1]) = aXferEvent[hand];  // The event handle is 64-bits
-        csBlock.longs[3] = dwStart;             // Thankfully these two remain
-        csBlock.longs[4] = dwLength;            //  as unsigned 32-bit values
-#else
-        csBlock.longs[0] = wArea;               // pass paramaters into the driver...
-        csBlock.longs[1] = (long)aXferEvent[hand];    // ...especially the event handle
-        csBlock.longs[2] = bToHost;
-        csBlock.longs[3] = dwStart;
-        csBlock.longs[4] = dwLength;
-#endif
-        sErr = U14Control1401(hand, U14_SETTRANSEVENT, &csBlock);
-        if (sErr == U14ERR_NOERROR)
-            sErr = (short)(aXferEvent[hand] != NULL);    // report if we have a flag
-    }
-
-    return sErr;
-#endif
-#ifdef LINUX
-    TRANSFEREVENT te;
-    short sErr = CheckHandle(hand);
-    if (sErr != U14ERR_NOERROR)
-        return sErr;
-
-    if (wArea >= MAX_TRANSAREAS)            // Is this a valid area number
-        return U14ERR_BADAREA;
-
-    te.wAreaNum = wArea;                    // copy parameters to the control block
-    te.wFlags = bToHost ? 1 : 0;            // bit 0 sets the direction
-    te.dwStart = dwStart;                   // start offset of the event area
-    te.dwLength = dwLength;                 // size of the event area
-    te.iSetEvent = bEvent;                  // in Windows, this creates/destroys the event
-    return CED_SetEvent(aHand1401[hand], &te);
-#endif
-}
-
-/****************************************************************************
-** U14TestTransferEvent
-** Would a U14WaitTransferEvent() call return immediately? return 1 if so,
-** 0 if not or a negative code if a problem.
-****************************************************************************/
-U14API(int) U14TestTransferEvent(short hand, unsigned short wArea)
-{
-#ifdef _IS_WINDOWS_
-    int iErr = CheckHandle(hand);
-    if (iErr == U14ERR_NOERROR)
-    {
-        if (aXferEvent[hand])           // if a handle is set...
-            iErr = WaitForSingleObject(aXferEvent[hand], 0) == WAIT_OBJECT_0;
-    }
-    return iErr;
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_TestEvent(aHand1401[hand], wArea) : sErr;
-#endif
-}
-
-/****************************************************************************
-** U14WaitTransferEvent
-** Wait for a transfer event with a timeout.
-** msTimeOut is 0 for an infinite wait, else it is the maximum time to wait
-**           in milliseconds in range 0-0x00ffffff.
-** Returns   If no event handle then return immediately. Else return 1 if
-**           timed out or 0=event, and a negative code if a problem.
-****************************************************************************/
-U14API(int) U14WaitTransferEvent(short hand, unsigned short wArea, int msTimeOut)
-{
-#ifdef _IS_WINDOWS_
-    int iErr = CheckHandle(hand);
-    if (iErr == U14ERR_NOERROR)
-    {
-        if (aXferEvent[hand])
-        {
-            if (msTimeOut == 0)
-                msTimeOut = INFINITE;
-            iErr = WaitForSingleObject(aXferEvent[hand], msTimeOut) != WAIT_OBJECT_0;
-        }
-        else
-            iErr = TRUE;                // say we timed out if no event
-    }
-    return iErr;
-#endif
-#ifdef LINUX
-    short sErr = CheckHandle(hand);
-    return (sErr == U14ERR_NOERROR) ? CED_WaitEvent(aHand1401[hand], wArea, msTimeOut) : sErr;
-#endif
-}
-
-/****************************************************************************
-** U14SetCircular    Sets an area up for circular DMA transfers
-** unsigned short  wArea          The area number to set up
-** BOOL  bToHost        Sets the direction of data transfer
-** void *pvBuff        The address of the buffer for the data
-** unsigned int dwLength       The length of the buffer for the data
-****************************************************************************/
-U14API(short) U14SetCircular(short hand, unsigned short wArea, BOOL bToHost,
-									void *pvBuff, unsigned int dwLength)
-{
-    short sErr = CheckHandle(hand);
-    if (sErr != U14ERR_NOERROR)
-        return sErr;
-
-    if (wArea >= MAX_TRANSAREAS)         /* Is this a valid area number */
-        return U14ERR_BADAREA;
-
-	if (!bToHost)             /* For now, support tohost transfers only */
-        return U14ERR_BADAREA;            /* best error code I can find */
-#ifdef _IS_WINDOWS_
-    assert(apAreas[hand][wArea] == NULL);
-    assert(auAreas[hand][wArea] == 0);
-
-    apAreas[hand][wArea] = pvBuff;              /* Save data for later */
-    auAreas[hand][wArea] = dwLength;
-
-    if (!VirtualLock(pvBuff, dwLength))      /* Lock using WIN32 calls */
-        sErr = U14ERR_LOCKERR;                    /* VirtualLock failed */
-    else
-    {
-        PARAMBLK rWork;
-        unsigned int dwBytes;
-        struct transfer_area_desc txDesc;
-        txDesc.wArea = wArea;             /* Pure NT - put data into struct */
-        txDesc.lpvBuff = pvBuff;
-        txDesc.dwLength = dwLength;
-        txDesc.eSize = (short)bToHost;       /* Use this for direction flag */
-   
-        if (DeviceIoControl(aHand1401[hand],(unsigned int)U14_SETCIRCULAR,
-                           &txDesc, sizeof(struct transfer_area_desc),
-                           &rWork, sizeof(PARAMBLK),&dwBytes,NULL))
-        {
-           if (dwBytes >= sizeof(PARAMBLK))          /* error from driver? */
-               sErr = rWork.sState;         /* No, just return driver data */
-           else
-               sErr = U14ERR_DRIVCOMMS;            /* Else never got there */
-        }
-        else
-            sErr = U14ERR_DRIVCOMMS;
-    }
-
-    if (sErr != U14ERR_NOERROR)
-    {
-        if (sErr != U14ERR_LOCKERR)
-            VirtualUnlock(pvBuff, dwLength);         /* Release NT lock */
-        apAreas[hand][wArea] = NULL;                 /* Clear locations */
-        auAreas[hand][wArea] = 0;
-    }
-
-    return sErr;
-#endif
-#ifdef LINUX
-    else
-    {
-        struct transfer_area_desc td;
-        td.lpvBuff = (long long)((unsigned long)pvBuff);
-        td.wAreaNum = wArea;
-        td.dwLength = dwLength;
-        td.eSize = (short)bToHost;       /* Use this for direction flag */
-        return CED_SetCircular(aHand1401[hand], &td);
-    }
-#endif
-}
-
-/****************************************************************************
-** Function  GetCircBlk returns the size (& start offset) of the next
-**           available block of circular data.
-****************************************************************************/
-U14API(int) U14GetCircBlk(short hand, unsigned short wArea, unsigned int *pdwOffs)
-{
-    int lErr = CheckHandle(hand);
-    if (lErr != U14ERR_NOERROR)
-        return lErr;
-
-    if (wArea >= MAX_TRANSAREAS)            // Is this a valid area number?
-        return U14ERR_BADAREA;
-    else
-    {
-#ifdef _IS_WINDOWS_
-        PARAMBLK rWork;
-        TCSBLOCK csBlock;
-        unsigned int dwBytes;
-        csBlock.longs[0] = wArea;               // Area number into control block
-        rWork.sState = U14ERR_DRIVCOMMS;
-        if (DeviceIoControl(aHand1401[hand], (unsigned int)U14_GETCIRCBLK, &csBlock, sizeof(TCSBLOCK), &rWork, sizeof(PARAMBLK), &dwBytes, NULL) &&
-           (dwBytes >= sizeof(PARAMBLK)))
-            lErr = rWork.sState;
-        else
-            lErr = U14ERR_DRIVCOMMS;
-   
-        if (lErr == U14ERR_NOERROR)             // Did everything go OK?
-        {                                       // Yes, we can pass the results back
-            lErr = rWork.csBlock.longs[1];      // Return the block information
-            *pdwOffs = rWork.csBlock.longs[0];  // Offset is first in array
-        }
-#endif
-#ifdef LINUX
-        TCIRCBLOCK cb;
-        cb.nArea = wArea;                       // Area number into control block
-        cb.dwOffset = 0;
-        cb.dwSize = 0;
-        lErr = CED_GetCircBlock(aHand1401[hand], &cb);
-        if (lErr == U14ERR_NOERROR)             // Did everything go OK?
-        {                                       // Yes, we can pass the results back
-            lErr = cb.dwSize;                   // return the size
-            *pdwOffs = cb.dwOffset;             // and the offset
-        }
-#endif
-    }
-    return lErr;
-}
-
-/****************************************************************************
-** Function  FreeCircBlk marks the specified area of memory as free for
-**           resuse for circular transfers and returns the size (& start
-**           offset) of the next available block of circular data.
-****************************************************************************/
-U14API(int) U14FreeCircBlk(short hand, unsigned short wArea, unsigned int dwOffs, unsigned int dwSize,
-                                        unsigned int *pdwOffs)
-{
-    int lErr = CheckHandle(hand);
-    if (lErr != U14ERR_NOERROR)
-        return lErr;
-
-    if (wArea < MAX_TRANSAREAS)                 // Is this a valid area number
-    {
-#ifdef _IS_WINDOWS_
-        PARAMBLK rWork;
-        TCSBLOCK csBlock;
-        unsigned int dwBytes;
-        csBlock.longs[0] = wArea;               // Area number into control block
-        csBlock.longs[1] = dwOffs;
-        csBlock.longs[2] = dwSize;
-        rWork.sState = U14ERR_DRIVCOMMS;
-        if (DeviceIoControl(aHand1401[hand], (unsigned int)U14_FREECIRCBLK, &csBlock, sizeof(TCSBLOCK),
-                           &rWork, sizeof(PARAMBLK), &dwBytes, NULL) &&
-           (dwBytes >= sizeof(PARAMBLK)))
-           lErr = rWork.sState;
-        else
-           lErr = U14ERR_DRIVCOMMS;
-       if (lErr == U14ERR_NOERROR)             // Did everything work OK?
-       {                                       // Yes, we can pass the results back
-           lErr = rWork.csBlock.longs[1];      // Return the block information
-           *pdwOffs = rWork.csBlock.longs[0];  // Offset is first in array
-       }
-#endif
-#ifdef LINUX
-        TCIRCBLOCK cb;
-        cb.nArea = wArea;                       // Area number into control block
-        cb.dwOffset = dwOffs;
-        cb.dwSize = dwSize;
-    
-        lErr = CED_FreeCircBlock(aHand1401[hand], &cb);
-        if (lErr == U14ERR_NOERROR)             // Did everything work OK?
-        {                                       // Yes, we can pass the results back
-            lErr = cb.dwSize;                   // Return the block information
-            *pdwOffs = cb.dwOffset;             // Offset is first in array
-        }
-#endif
-    }
-    else
-        lErr = U14ERR_BADAREA;
-
-    return lErr;
-}
-
-/****************************************************************************
-** Transfer
-** Transfer moves data to 1401 or to host
-** Assumes memory is allocated and locked,
-** which it should be to get a pointer
-*****************************************************************************/
-static short Transfer(short hand, BOOL bTo1401, char* pData,
-                       unsigned int dwSize, unsigned int dw1401, short eSz)
-{
-    char strcopy[MAXSTRLEN+1];          // to hold copy of work string
-    short sResult = U14SetTransArea(hand, 0, (void *)pData, dwSize, eSz);
-    if (sResult == U14ERR_NOERROR)      // no error
-    {
-        sprintf(strcopy,                // data offset is always 0
-                "TO%s,$%X,$%X,0;", bTo1401 ? "1401" : "HOST", dw1401, dwSize);
-
-        U14SendString(hand, strcopy);   // send transfer string
-
-        sResult = U14CheckErr(hand);    // Use ERR command to check for done
-        if (sResult > 0)
-            sResult = U14ERR_TOXXXERR;  // If a 1401 error, use this code
-
-        U14UnSetTransfer(hand, 0);
-    }
-    return sResult;
-}
-
-/****************************************************************************
-** Function  ToHost transfers data into the host from the 1401
-****************************************************************************/
-U14API(short) U14ToHost(short hand, char* pAddrHost, unsigned int dwSize,
-                                            unsigned int dw1401, short eSz)
-{
-    short sErr = CheckHandle(hand);
-    if ((sErr == U14ERR_NOERROR) && dwSize) // TOHOST is a constant
-        sErr = Transfer(hand, TOHOST, pAddrHost, dwSize, dw1401, eSz);
-    return sErr;
-}
-
-/****************************************************************************
-** Function  To1401 transfers data into the 1401 from the host
-****************************************************************************/
-U14API(short) U14To1401(short hand, const char* pAddrHost,unsigned int dwSize,
-                                    unsigned int dw1401, short eSz)
-{
-    short sErr = CheckHandle(hand);
-    if ((sErr == U14ERR_NOERROR) && dwSize) // TO1401 is a constant
-        sErr = Transfer(hand, TO1401, (char*)pAddrHost, dwSize, dw1401, eSz);
-    return sErr;
-}
-
-/****************************************************************************
-** Function  LdCmd    Loads a command from a full path or just a file
-*****************************************************************************/
-#ifdef _IS_WINDOWS_
-#define file_exist(name) (_access(name, 0) != -1)
-#define file_open(name) _lopen(name, OF_READ)
-#define file_close(h)   _lclose(h)
-#define file_seek(h, pos) _llseek(h, pos, FILE_BEGIN) 
-#define file_read(h, buffer, size) (_lread(h, buffer, size) == size)
-#endif
-#ifdef LINUX
-#define file_exist(name) (access(name, F_OK) != -1)
-#define file_open(name) open(name, O_RDONLY)
-#define file_close(h)   close(h)
-#define file_seek(h, pos) lseek(h, pos, SEEK_SET) 
-#define file_read(h, buffer, size) (read(h, buffer, size) == (ssize_t)size)
-static unsigned int GetModuleFileName(void* dummy, char* buffer, int max)
-{
-    // The following works for Linux systems with a /proc file system.
-    char szProcPath[32];
-    sprintf(szProcPath, "/proc/%d/exe", getpid());  // attempt to read link
-    if (readlink(szProcPath, buffer, max) != -1)
-    {
-        dirname (buffer);
-        strcat  (buffer, "/");
-        return strlen(buffer);
-    }
-    return 0;
-}
-#endif
-
-U14API(short) U14LdCmd(short hand, const char* command)
-{
-    char strcopy[MAXSTRLEN+1];      // to hold copy of work string
-    BOOL bGotIt = FALSE;            // have we found the command file?
-    int iFHandle;                   // file handle of command
-#define FNSZ 260
-    char filnam[FNSZ];              // space to build name in
-    char szCmd[25];                 // just the command name with extension
-
-    short sErr = CheckHandle(hand);
-    if (sErr != U14ERR_NOERROR)
-        return sErr;
-
-    if (strchr(command, '.') != NULL)       // see if we have full name
-    {
-        if (file_exist(command))            // If the file exists
-        {
-            strcpy(filnam, command);        // use name as is
-            bGotIt = TRUE;                  // Flag no more searching
-        }
-        else                                // not found, get file name for search
-        {
-            char* pStr = strrchr(command, PATHSEP);  // Point to last separator
-            if (pStr != NULL)               // Check we got it
-            {
-                pStr++;                     // move past the backslash
-                strcpy(szCmd, pStr);        // copy file name as is
-            }
-            else
-                strcpy(szCmd, command);     // use as is
-        }
-    }
-    else    // File extension not supplied, so build the command file name
-    {
-        char szExt[8];
-        strcpy(szCmd, command);             // Build command file name
-        ExtForType(asType1401[hand], szExt);// File extension string
-        strcat(szCmd, szExt);               // add it to the end
-    }
-
-    // Next place to look is in the 1401 folder in the same place as the
-    // application was run from.
-    if (!bGotIt)                            // Still not got it?
-    {
-        unsigned int dwLen = GetModuleFileName(NULL, filnam, FNSZ); // Get app path
-        if (dwLen > 0)                      // and use it as path if found
-        {
-            char* pStr = strrchr(filnam, PATHSEP);    // Point to last separator
-            if (pStr != NULL)
-            {
-                *(++pStr) = 0;                  // Terminate string there
-                if (strlen(filnam) < FNSZ-6)    // make sure we have space
-                {
-                    strcat(filnam, "1401" PATHSEPSTR);  // add in 1401 subdir
-                    strcat(filnam,szCmd);
-                    bGotIt = (BOOL)file_exist(filnam);  // See if file exists
-                }
-            }
-        }
-    }
-
-    // Next place to look is in whatever path is set by the 1401DIR environment
-    // variable, if it exists.
-    if (!bGotIt)                            // Need to do more searches?/
-    {
-        char* pStr = getenv("1401DIR");     // Try to find environment var
-        if (pStr != NULL)                   // and use it as path if found
-        {
-            strcpy(filnam, pStr);                   // Use path in environment
-            if (filnam[strlen(filnam)-1] != PATHSEP)// We need separator
-                strcat(filnam, PATHSEPSTR);
-            strcat(filnam, szCmd);
-            bGotIt = (BOOL)file_exist(filnam); // Got this one?
-        }
-    }
-
-    // Last place to look is the default location.
-    if (!bGotIt)                        // Need to do more searches?
-    {
-        strcpy(filnam, DEFCMDPATH);     // Use default path
-        strcat(filnam, szCmd);
-        bGotIt = file_exist(filnam);    // Got this one?
-    }
-
-    iFHandle = file_open(filnam);
-    if (iFHandle == -1)
-        sErr = U14ERR_NOFILE;
-    else
-    {                                   // first read in the header block
-        CMDHEAD rCmdHead;               // to hold the command header
-        if (file_read(iFHandle, &rCmdHead, sizeof(CMDHEAD)))
-        {
-            size_t nComSize = rCmdHead.wCmdSize;
-            char* pMem = malloc(nComSize);
-            if (pMem != NULL)
-            {
-                file_seek(iFHandle, sizeof(CMDHEAD));
-                if (file_read(iFHandle, pMem, (UINT)nComSize))
-                {
-                    sErr = U14SetTransArea(hand, 0, (void *)pMem, (unsigned int)nComSize, ESZBYTES);
-                    if (sErr == U14ERR_NOERROR)
-                    {
-                        sprintf(strcopy, "CLOAD,0,$%X;", (int)nComSize);
-                        sErr = U14SendString(hand, strcopy);
-                        if (sErr == U14ERR_NOERROR)
-                        {
-                            sErr = U14CheckErr(hand);     // Use ERR to check for done
-                            if (sErr > 0)
-                                sErr = U14ERR_CLOADERR;   // If an error, this code
-                        }
-                        U14UnSetTransfer(hand, 0);  // release transfer area
-                    }
-                }
-                else
-                    sErr = U14ERR_READERR;
-                free(pMem);
-            }
-            else
-                sErr = U14ERR_HOSTSPACE;    // memory allocate failed
-        }
-        else
-            sErr = U14ERR_READERR;
-
-        file_close(iFHandle);               // close the file
-    }
-
-    return sErr;
-}
-
-
-/****************************************************************************
-** Ld
-** Loads a command into the 1401
-** Returns NOERROR code or a long with error in lo word and index of
-** command that failed in high word
-****************************************************************************/
-U14API(unsigned int) U14Ld(short hand, const char* vl, const char* str)
-{
-    unsigned int dwIndex = 0;              // index to current command
-    long lErr = U14ERR_NOERROR;     // what the error was that went wrong
-    char strcopy[MAXSTRLEN+1];      // stores unmodified str parameter
-    char szFExt[8];                 // The command file extension
-    short sErr = CheckHandle(hand);
-    if (sErr != U14ERR_NOERROR)
-        return sErr;
-
-    ExtForType(asType1401[hand], szFExt);   // File extension string
-    strcpy(strcopy, str);               // to avoid changing original
-
-    // now break out one command at a time and see if loaded
-    if (*str)                           // if anything there
-    {
-        BOOL bDone = FALSE;             // true when finished all commands
-        int iLoop1 = 0;                 // Point at start of string for command name
-        int iLoop2 = 0;                 // and at start of str parameter
-        do                              // repeat until end of str
-        {
-            char filnam[MAXSTRLEN+1];   // filename to use
-            char szFName[MAXSTRLEN+1];  // filename work string
-
-            if (!strcopy[iLoop1])       // at the end of the string?
-                bDone = TRUE;           // set the finish flag
-
-            if (bDone || (strcopy[iLoop1] == ','))  // end of cmd?
-            {
-                U14LONG er[5];                  // Used to read back error results
-                ++dwIndex;                      // Keep count of command number, first is 1
-                szFName[iLoop2]=(char)0;        // null terminate name of command
-
-                strncpy(szLastName, szFName, sizeof(szLastName));    // Save for error info
-                szLastName[sizeof(szLastName)-1] = 0;
-                strncat(szLastName, szFExt, sizeof(szLastName));     // with extension included
-                szLastName[sizeof(szLastName)-1] = 0;
-
-                U14SendString(hand, szFName);   // ask if loaded
-                U14SendString(hand, ";ERR;");   // add err return
-
-                lErr = U14LongsFrom1401(hand, er, 5);
-                if (lErr > 0)
-                {
-                    lErr = U14ERR_NOERROR;
-                    if (er[0] == 255)           // if command not loaded at all
-                    {
-                        if (vl && *vl)          // if we have a path name
-                        {
-                            strcpy(filnam, vl);
-                            if (strchr("\\/:", filnam[strlen(filnam)-1]) == NULL)
-                                strcat(filnam, PATHSEPSTR); // add separator if none found
-                            strcat(filnam, szFName);    // add the file name
-                            strcat(filnam, szFExt);     // and extension
-                        }
-                        else
-                            strcpy(filnam, szFName);    // simple name
-
-                        lErr = U14LdCmd(hand, filnam);  // load cmd
-                        if (lErr != U14ERR_NOERROR)     // spot any errors
-                            bDone = TRUE;               // give up if an error
-                    }
-                }
-                else
-                    bDone = TRUE;       // give up if an error
-
-                iLoop2 = 0;             // Reset pointer to command name string
-                ++iLoop1;               // and move on through str parameter
-            }
-            else
-                szFName[iLoop2++] = strcopy[iLoop1++];  // no command end, so copy 1 char
-        }
-        while (!bDone);
-    }
-
-    if (lErr == U14ERR_NOERROR)
-    {
-        szLastName[0] = 0;      // No error, so clean out command name here
-        return lErr;
-    }
-    else
-        return ((dwIndex<<16) | ((unsigned int)lErr & 0x0000FFFF));
-}
-
-// Initialise the library (if not initialised) and return the library version
-U14API(int) U14InitLib(void)
-{
-    int iRetVal = U14LIB_VERSION;
-    if (iAttached == 0)         // only do this the first time please
-    {
-        int i;
-#ifdef _IS_WINDOWS_
-        int j;
-        unsigned int   dwVersion = GetVersion();
-        bWindows9x = FALSE;                  // Assume not Win9x
-
-        if (dwVersion & 0x80000000)                 // if not windows NT
-        {
-            if ((LOBYTE(LOWORD(dwVersion)) < 4) &&  // if Win32s or...
-                 (HIBYTE(LOWORD(dwVersion)) < 95))  // ...below Windows 95
-            iRetVal = 0;                            // We do not support this
-        else
-            bWindows9x = TRUE;                      // Flag we have Win9x
-        }
-#endif
-        
-        for (i = 0; i < MAX1401; i++)               // initialise the device area
-        {
-            aHand1401[i] = INVALID_HANDLE_VALUE;    // Clear handle values
-            asType1401[i] = U14TYPEUNKNOWN;         // and 1401 type codes
-            alTimeOutPeriod[i] = 3000;              // 3 second timeouts
-#ifdef _IS_WINDOWS_
-#ifndef _WIN64
-            abUseNTDIOC[i] = (BOOL)!bWindows9x;
-#endif
-            aXferEvent[i] = NULL;                   // there are no Xfer events
-            for (j = 0; j < MAX_TRANSAREAS; j++)    // Clear out locked area info
-            {
-                apAreas[i][j] = NULL;
-                auAreas[i][j] = 0;
-            }
-#endif
-        }
-    }
-    return iRetVal;
-}
-
-///--------------------------------------------------------------------------------
-/// Functions called when the library is loaded and unloaded to give us a chance to
-/// setup the library.
-
-
-#ifdef _IS_WINDOWS_
-#ifndef U14_NOT_DLL
-/****************************************************************************
-** FUNCTION: DllMain(HANDLE, unsigned int, LPVOID)
-** LibMain is called by Windows when the DLL is initialized, Thread Attached,
-** and other times. Refer to SDK documentation, as to the different ways this
-** may be called.
-****************************************************************************/
-INT APIENTRY DllMain(HANDLE hInst, unsigned int ul_reason_being_called, LPVOID lpReserved)
-{
-    int iRetVal = 1;
-
-    switch (ul_reason_being_called)
-    {
-    case DLL_PROCESS_ATTACH:
-        iRetVal = U14InitLib() > 0;         // does nothing if iAttached != 0
-        ++iAttached;                        // count times attached
-        break;
-
-    case DLL_PROCESS_DETACH:
-        if (--iAttached == 0)               // last man out?
-            U14CloseAll();                  // release all open handles
-        break;
-    }
-    return iRetVal;
-
-    UNREFERENCED_PARAMETER(lpReserved);
-}
-#endif
-#endif
-#ifdef LINUX
-void __attribute__((constructor)) use1401_load(void)
-{
-    U14InitLib();
-    ++iAttached;
-}
-
-void __attribute__((destructor)) use1401_unload(void)
-{
-        if (--iAttached == 0)               // last man out?
-            U14CloseAll();                  // release all open handles
-}
-#endif
diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 8d992a8..341fc07 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -1014,8 +1014,6 @@
 
 config COMEDI_NI_65XX
 	tristate "NI 65xx static dio PCI card support"
-	depends on HAS_DMA
-	select COMEDI_MITE
 	---help---
 	  Enable support for National Instruments 65xx static dio boards.
 	  Supported devices: National Instruments PCI-6509 (ni_65xx),
@@ -1039,8 +1037,6 @@
 
 config COMEDI_NI_670X
 	tristate "NI 670x PCI card support"
-	depends on HAS_DMA
-	select COMEDI_MITE
 	---help---
 	  Enable support for National Instruments PCI-6703 and PCI-6704
 
@@ -1049,9 +1045,7 @@
 
 config COMEDI_NI_LABPC_PCI
 	tristate "NI Lab-PC PCI-1200 support"
-	depends on HAS_DMA
 	select COMEDI_NI_LABPC
-	select COMEDI_MITE
 	---help---
 	  Enable support for National Instruments Lab-PC PCI-1200.
 
diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h
index dbaeba7..217baf8 100644
--- a/drivers/staging/comedi/comedi.h
+++ b/drivers/staging/comedi/comedi.h
@@ -551,21 +551,8 @@
 	I8254_BINARY = 0
 };
 
-static inline unsigned NI_USUAL_PFI_SELECT(unsigned pfi_channel)
-{
-	if (pfi_channel < 10)
-		return 0x1 + pfi_channel;
-	else
-		return 0xb + pfi_channel;
-}
-
-static inline unsigned NI_USUAL_RTSI_SELECT(unsigned rtsi_channel)
-{
-	if (rtsi_channel < 7)
-		return 0xb + rtsi_channel;
-	else
-		return 0x1b;
-}
+#define NI_USUAL_PFI_SELECT(x)	(((x) < 10) ? (0x1 + (x)) : (0xb + (x)))
+#define NI_USUAL_RTSI_SELECT(x)	(((x) < 7) ? (0xb + (x)) : 0x1b)
 
 /* mode bits for NI general-purpose counters, set with
  * INSN_CONFIG_SET_COUNTER_MODE */
@@ -659,20 +646,14 @@
 	NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000,
 	NI_GPCT_INVERT_CLOCK_SRC_BIT = 0x80000000
 };
-static inline unsigned NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(unsigned n)
-{
-	/* NI 660x-specific */
-	return 0x10 + n;
-}
-static inline unsigned NI_GPCT_RTSI_CLOCK_SRC_BITS(unsigned n)
-{
-	return 0x18 + n;
-}
-static inline unsigned NI_GPCT_PFI_CLOCK_SRC_BITS(unsigned n)
-{
-	/* no pfi on NI 660x */
-	return 0x20 + n;
-}
+
+/* NI 660x-specific */
+#define NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(x)	(0x10 + (x))
+
+#define NI_GPCT_RTSI_CLOCK_SRC_BITS(x)		(0x18 + (x))
+
+/* no pfi on NI 660x */
+#define NI_GPCT_PFI_CLOCK_SRC_BITS(x)		(0x20 + (x))
 
 /* Possibilities for setting a gate source with
 INSN_CONFIG_SET_GATE_SRC when using NI general-purpose counters.
@@ -698,22 +679,11 @@
 	 * known. */
 	NI_GPCT_DISABLED_GATE_SELECT = 0x8000,
 };
-static inline unsigned NI_GPCT_GATE_PIN_GATE_SELECT(unsigned n)
-{
-	return 0x102 + n;
-}
-static inline unsigned NI_GPCT_RTSI_GATE_SELECT(unsigned n)
-{
-	return NI_USUAL_RTSI_SELECT(n);
-}
-static inline unsigned NI_GPCT_PFI_GATE_SELECT(unsigned n)
-{
-	return NI_USUAL_PFI_SELECT(n);
-}
-static inline unsigned NI_GPCT_UP_DOWN_PIN_GATE_SELECT(unsigned n)
-{
-	return 0x202 + n;
-}
+
+#define NI_GPCT_GATE_PIN_GATE_SELECT(x)		(0x102 + (x))
+#define NI_GPCT_RTSI_GATE_SELECT(x)		NI_USUAL_RTSI_SELECT(x)
+#define NI_GPCT_PFI_GATE_SELECT(x)		NI_USUAL_PFI_SELECT(x)
+#define NI_GPCT_UP_DOWN_PIN_GATE_SELECT(x)	(0x202 + (x))
 
 /* Possibilities for setting a source with
 INSN_CONFIG_SET_OTHER_SRC when using NI general-purpose counters. */
@@ -722,15 +692,14 @@
 	NI_GPCT_SOURCE_ENCODER_B,
 	NI_GPCT_SOURCE_ENCODER_Z
 };
+
 enum ni_gpct_other_select {
 	/* m-series gates */
 	/* Still unknown, probably only need NI_GPCT_PFI_OTHER_SELECT */
 	NI_GPCT_DISABLED_OTHER_SELECT = 0x8000,
 };
-static inline unsigned NI_GPCT_PFI_OTHER_SELECT(unsigned n)
-{
-	return NI_USUAL_PFI_SELECT(n);
-}
+
+#define NI_GPCT_PFI_OTHER_SELECT(x)	NI_USUAL_PFI_SELECT(x)
 
 /* start sources for ni general-purpose counters for use with
 INSN_CONFIG_ARM */
@@ -777,10 +746,8 @@
 	NI_MIO_PLL_PXI10_CLOCK = 3,
 	NI_MIO_PLL_RTSI0_CLOCK = 4
 };
-static inline unsigned NI_MIO_PLL_RTSI_CLOCK(unsigned rtsi_channel)
-{
-	return NI_MIO_PLL_RTSI0_CLOCK + rtsi_channel;
-}
+
+#define NI_MIO_PLL_RTSI_CLOCK(x)	(NI_MIO_PLL_RTSI0_CLOCK + (x))
 
 /* Signals which can be routed to an NI RTSI pin with INSN_CONFIG_SET_ROUTING.
  The numbers assigned are not arbitrary, they correspond to the bits required
@@ -798,10 +765,8 @@
 	NI_RTSI_OUTPUT_RTSI_OSC = 12	/* pre-m-series always have RTSI
 					 * clock on line 7 */
 };
-static inline unsigned NI_RTSI_OUTPUT_RTSI_BRD(unsigned n)
-{
-	return NI_RTSI_OUTPUT_RTSI_BRD_0 + n;
-}
+
+#define NI_RTSI_OUTPUT_RTSI_BRD(x)	(NI_RTSI_OUTPUT_RTSI_BRD_0 + (x))
 
 /* Signals which can be routed to an NI PFI pin on an m-series board with
  * INSN_CONFIG_SET_ROUTING.  These numbers are also returned by
@@ -834,10 +799,8 @@
 	NI_PFI_OUTPUT_CDI_SAMPLE = 29,
 	NI_PFI_OUTPUT_CDO_UPDATE = 30
 };
-static inline unsigned NI_PFI_OUTPUT_RTSI(unsigned rtsi_channel)
-{
-	return NI_PFI_OUTPUT_RTSI0 + rtsi_channel;
-}
+
+#define NI_PFI_OUTPUT_RTSI(x)		(NI_PFI_OUTPUT_RTSI0 + (x))
 
 /* Signals which can be routed to output on a NI PFI pin on a 660x board
  with INSN_CONFIG_SET_ROUTING.  The numbers assigned are
@@ -853,14 +816,8 @@
 /* NI External Trigger lines.  These values are not arbitrary, but are related
  * to the bits required to program the board (offset by 1 for historical
  * reasons). */
-static inline unsigned NI_EXT_PFI(unsigned pfi_channel)
-{
-	return NI_USUAL_PFI_SELECT(pfi_channel) - 1;
-}
-static inline unsigned NI_EXT_RTSI(unsigned rtsi_channel)
-{
-	return NI_USUAL_RTSI_SELECT(rtsi_channel) - 1;
-}
+#define NI_EXT_PFI(x)			(NI_USUAL_PFI_SELECT(x) - 1)
+#define NI_EXT_RTSI(x)			(NI_USUAL_RTSI_SELECT(x) - 1)
 
 /* status bits for INSN_CONFIG_GET_COUNTER_STATUS */
 enum comedi_counter_status_flags {
@@ -884,26 +841,15 @@
 	NI_CDIO_SCAN_BEGIN_SRC_FREQ_OUT = 32,
 	NI_CDIO_SCAN_BEGIN_SRC_DIO_CHANGE_DETECT_IRQ = 33
 };
-static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel)
-{
-	return NI_USUAL_PFI_SELECT(pfi_channel);
-}
-static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_RTSI(unsigned rtsi_channel)
-{
-	return NI_USUAL_RTSI_SELECT(rtsi_channel);
-}
+
+#define NI_CDIO_SCAN_BEGIN_SRC_PFI(x)	NI_USUAL_PFI_SELECT(x)
+#define NI_CDIO_SCAN_BEGIN_SRC_RTSI(x)	NI_USUAL_RTSI_SELECT(x)
 
 /* scan_begin_src for scan_begin_arg==TRIG_EXT with analog output command on NI
  * boards.  These scan begin sources can also be bitwise-or'd with CR_INVERT to
  * change polarity. */
-static inline unsigned NI_AO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel)
-{
-	return NI_USUAL_PFI_SELECT(pfi_channel);
-}
-static inline unsigned NI_AO_SCAN_BEGIN_SRC_RTSI(unsigned rtsi_channel)
-{
-	return NI_USUAL_RTSI_SELECT(rtsi_channel);
-}
+#define NI_AO_SCAN_BEGIN_SRC_PFI(x)	NI_USUAL_PFI_SELECT(x)
+#define NI_AO_SCAN_BEGIN_SRC_RTSI(x)	NI_USUAL_RTSI_SELECT(x)
 
 /* Bits for setting a clock source with
  * INSN_CONFIG_SET_CLOCK_SRC when using NI frequency output subdevice. */
diff --git a/drivers/staging/comedi/comedi_compat32.c b/drivers/staging/comedi/comedi_compat32.c
index 1e9da40..9b6f96f 100644
--- a/drivers/staging/comedi/comedi_compat32.c
+++ b/drivers/staging/comedi/comedi_compat32.c
@@ -107,10 +107,10 @@
 	chaninfo = compat_alloc_user_space(sizeof(*chaninfo));
 
 	/* Copy chaninfo structure.  Ignore unused members. */
-	if (!access_ok(VERIFY_READ, chaninfo32, sizeof(*chaninfo32))
-	    || !access_ok(VERIFY_WRITE, chaninfo, sizeof(*chaninfo))) {
+	if (!access_ok(VERIFY_READ, chaninfo32, sizeof(*chaninfo32)) ||
+	    !access_ok(VERIFY_WRITE, chaninfo, sizeof(*chaninfo)))
 		return -EFAULT;
-	}
+
 	err = 0;
 	err |= __get_user(temp.uint, &chaninfo32->subdev);
 	err |= __put_user(temp.uint, &chaninfo->subdev);
@@ -141,10 +141,10 @@
 	rangeinfo = compat_alloc_user_space(sizeof(*rangeinfo));
 
 	/* Copy rangeinfo structure. */
-	if (!access_ok(VERIFY_READ, rangeinfo32, sizeof(*rangeinfo32))
-	    || !access_ok(VERIFY_WRITE, rangeinfo, sizeof(*rangeinfo))) {
+	if (!access_ok(VERIFY_READ, rangeinfo32, sizeof(*rangeinfo32)) ||
+	    !access_ok(VERIFY_WRITE, rangeinfo, sizeof(*rangeinfo)))
 		return -EFAULT;
-	}
+
 	err = 0;
 	err |= __get_user(temp.uint, &rangeinfo32->range_type);
 	err |= __put_user(temp.uint, &rangeinfo->range_type);
@@ -168,10 +168,10 @@
 	} temp;
 
 	/* Copy cmd structure. */
-	if (!access_ok(VERIFY_READ, cmd32, sizeof(*cmd32))
-	    || !access_ok(VERIFY_WRITE, cmd, sizeof(*cmd))) {
+	if (!access_ok(VERIFY_READ, cmd32, sizeof(*cmd32)) ||
+	    !access_ok(VERIFY_WRITE, cmd, sizeof(*cmd)))
 		return -EFAULT;
-	}
+
 	err = 0;
 	err |= __get_user(temp.uint, &cmd32->subdev);
 	err |= __put_user(temp.uint, &cmd->subdev);
@@ -219,10 +219,10 @@
 	/* Assume the pointer values are already valid. */
 	/* (Could use ptr_to_compat() to set them, but that wasn't implemented
 	 * until kernel version 2.6.11.) */
-	if (!access_ok(VERIFY_READ, cmd, sizeof(*cmd))
-	    || !access_ok(VERIFY_WRITE, cmd32, sizeof(*cmd32))) {
+	if (!access_ok(VERIFY_READ, cmd, sizeof(*cmd)) ||
+	    !access_ok(VERIFY_WRITE, cmd32, sizeof(*cmd32)))
 		return -EFAULT;
-	}
+
 	err = 0;
 	err |= __get_user(temp, &cmd->subdev);
 	err |= __put_user(temp, &cmd32->subdev);
@@ -311,8 +311,8 @@
 
 	/* Copy insn structure.  Ignore the unused members. */
 	err = 0;
-	if (!access_ok(VERIFY_READ, insn32, sizeof(*insn32))
-	    || !access_ok(VERIFY_WRITE, insn, sizeof(*insn)))
+	if (!access_ok(VERIFY_READ, insn32, sizeof(*insn32)) ||
+	    !access_ok(VERIFY_WRITE, insn, sizeof(*insn)))
 		return -EFAULT;
 
 	err |= __get_user(temp.uint, &insn32->insn);
diff --git a/drivers/staging/comedi/comedi_compat32.h b/drivers/staging/comedi/comedi_compat32.h
index 28e3c30..2d0a6fc 100644
--- a/drivers/staging/comedi/comedi_compat32.h
+++ b/drivers/staging/comedi/comedi_compat32.h
@@ -25,8 +25,7 @@
 #ifdef CONFIG_COMPAT
 
 struct file;
-extern long comedi_compat_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg);
+long comedi_compat_ioctl(struct file *, unsigned int cmd, unsigned long arg);
 
 #else /* CONFIG_COMPAT */
 
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 038b69a..2182c74 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -16,6 +16,8 @@
     GNU General Public License for more details.
 */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include "comedi_compat32.h"
 
 #include <linux/module.h>
@@ -206,8 +208,8 @@
 {
 	if (minor < COMEDI_NUM_BOARD_MINORS)
 		return comedi_dev_get_from_board_minor(minor);
-	else
-		return comedi_dev_get_from_subdevice_minor(minor);
+
+	return comedi_dev_get_from_subdevice_minor(minor);
 }
 EXPORT_SYMBOL_GPL(comedi_dev_get_from_minor);
 
@@ -266,7 +268,7 @@
 		return retval;
 
 	if (s->buf_change) {
-		retval = s->buf_change(dev, s, new_size);
+		retval = s->buf_change(dev, s);
 		if (retval < 0)
 			return retval;
 	}
@@ -1073,11 +1075,10 @@
 		/* by default we allow the insn since we don't have checks for
 		 * all possible cases yet */
 	default:
-		pr_warn("comedi: No check for data length of config insn id %i is implemented.\n",
+		pr_warn("No check for data length of config insn id %i is implemented\n",
 			data[0]);
-		pr_warn("comedi: Add a check to %s in %s.\n",
-			__func__, __FILE__);
-		pr_warn("comedi: Assuming n=%i is correct.\n", insn->n);
+		pr_warn("Add a check to %s in %s\n", __func__, __FILE__);
+		pr_warn("Assuming n=%i is correct\n", insn->n);
 		return 0;
 	}
 	return -EINVAL;
@@ -1226,10 +1227,9 @@
 				/* Most drivers ignore the base channel in
 				 * insn->chanspec.  Fix this here if
 				 * the subdevice has <= 32 channels.  */
-				unsigned int shift;
-				unsigned int orig_mask;
+				unsigned int orig_mask = data[0];
+				unsigned int shift = 0;
 
-				orig_mask = data[0];
 				if (s->n_chan <= 32) {
 					shift = CR_CHAN(insn->chanspec);
 					if (shift > 0) {
@@ -1237,8 +1237,7 @@
 						data[0] <<= shift;
 						data[1] <<= shift;
 					}
-				} else
-					shift = 0;
+				}
 				ret = s->insn_bits(dev, s, insn, data);
 				data[0] = orig_mask;
 				if (shift > 0)
@@ -1661,14 +1660,6 @@
 		s->lock = file;
 	spin_unlock_irqrestore(&s->spin_lock, flags);
 
-#if 0
-	if (ret < 0)
-		return ret;
-
-	if (s->lock_f)
-		ret = s->lock_f(dev, s);
-#endif
-
 	return ret;
 }
 
@@ -1703,14 +1694,8 @@
 	if (s->lock && s->lock != file)
 		return -EACCES;
 
-	if (s->lock == file) {
-#if 0
-		if (s->unlock)
-			s->unlock(dev, s);
-#endif
-
+	if (s->lock == file)
 		s->lock = NULL;
-	}
 
 	return 0;
 }
@@ -2177,7 +2162,7 @@
 }
 
 static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
-				loff_t *offset)
+			   loff_t *offset)
 {
 	struct comedi_subdevice *s;
 	struct comedi_async *async;
@@ -2221,10 +2206,8 @@
 		n = nbytes;
 
 		m = comedi_buf_read_n_available(s);
-		/* printk("%d available\n",m); */
 		if (async->buf_read_ptr + m > async->prealloc_bufsz)
 			m = async->prealloc_bufsz - async->buf_read_ptr;
-		/* printk("%d contiguous\n",m); */
 		if (m < n)
 			n = m;
 
@@ -2401,12 +2384,6 @@
 	.llseek = noop_llseek,
 };
 
-void comedi_error(const struct comedi_device *dev, const char *s)
-{
-	dev_err(dev->class_dev, "%s: %s\n", dev->driver->driver_name, s);
-}
-EXPORT_SYMBOL_GPL(comedi_error);
-
 void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
 {
 	struct comedi_async *async = s->async;
@@ -2450,7 +2427,7 @@
 	struct device *csdev;
 	unsigned i;
 
-	dev = kzalloc(sizeof(struct comedi_device), GFP_KERNEL);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (dev == NULL)
 		return ERR_PTR(-ENOMEM);
 	comedi_device_init(dev);
@@ -2469,7 +2446,7 @@
 		mutex_unlock(&dev->mutex);
 		comedi_device_cleanup(dev);
 		comedi_dev_put(dev);
-		pr_err("comedi: error: ran out of minor numbers for board device files.\n");
+		pr_err("ran out of minor numbers for board device files\n");
 		return ERR_PTR(-EBUSY);
 	}
 	dev->minor = i;
@@ -2522,7 +2499,7 @@
 	}
 	mutex_unlock(&comedi_subdevice_minor_table_lock);
 	if (i == COMEDI_NUM_SUBDEVICE_MINORS) {
-		pr_err("comedi: error: ran out of minor numbers for subdevice files.\n");
+		pr_err("ran out of minor numbers for subdevice files\n");
 		return -EBUSY;
 	}
 	i += COMEDI_NUM_BOARD_MINORS;
@@ -2572,11 +2549,11 @@
 	int i;
 	int retval;
 
-	pr_info("comedi: version " COMEDI_RELEASE " - http://www.comedi.org\n");
+	pr_info("version " COMEDI_RELEASE " - http://www.comedi.org\n");
 
 	if (comedi_num_legacy_minors < 0 ||
 	    comedi_num_legacy_minors > COMEDI_NUM_BOARD_MINORS) {
-		pr_err("comedi: error: invalid value for module parameter \"comedi_num_legacy_minors\".  Valid values are 0 through %i.\n",
+		pr_err("invalid value for module parameter \"comedi_num_legacy_minors\".  Valid values are 0 through %i.\n",
 		       COMEDI_NUM_BOARD_MINORS);
 		return -EINVAL;
 	}
@@ -2602,7 +2579,7 @@
 	}
 	comedi_class = class_create(THIS_MODULE, "comedi");
 	if (IS_ERR(comedi_class)) {
-		pr_err("comedi: failed to create class\n");
+		pr_err("failed to create class\n");
 		cdev_del(&comedi_cdev);
 		unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
 					 COMEDI_NUM_MINORS);
@@ -2625,10 +2602,9 @@
 			unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
 						 COMEDI_NUM_MINORS);
 			return PTR_ERR(dev);
-		} else {
-			/* comedi_alloc_board_minor() locked the mutex */
-			mutex_unlock(&dev->mutex);
 		}
+		/* comedi_alloc_board_minor() locked the mutex */
+		mutex_unlock(&dev->mutex);
 	}
 
 	return 0;
diff --git a/drivers/staging/comedi/comedi_internal.h b/drivers/staging/comedi/comedi_internal.h
index e978c22..d57817c 100644
--- a/drivers/staging/comedi/comedi_internal.h
+++ b/drivers/staging/comedi/comedi_internal.h
@@ -48,6 +48,7 @@
 static inline void comedi_proc_init(void)
 {
 }
+
 static inline void comedi_proc_cleanup(void)
 {
 }
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
index 83fd155..f3999f5 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -75,13 +75,9 @@
 			  struct comedi_cmd *);
 	int (*poll)(struct comedi_device *, struct comedi_subdevice *);
 	int (*cancel)(struct comedi_device *, struct comedi_subdevice *);
-	/* int (*do_lock)(struct comedi_device *, struct comedi_subdevice *); */
-	/* int (*do_unlock)(struct comedi_device *, \
-			struct comedi_subdevice *); */
 
 	/* called when the buffer changes */
-	int (*buf_change)(struct comedi_device *dev,
-			  struct comedi_subdevice *s, unsigned long new_size);
+	int (*buf_change)(struct comedi_device *, struct comedi_subdevice *);
 
 	void (*munge)(struct comedi_device *dev, struct comedi_subdevice *s,
 		      void *data, unsigned int num_bytes,
@@ -280,7 +276,6 @@
  */
 
 void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s);
-void comedi_error(const struct comedi_device *dev, const char *s);
 
 /* we can expand the number of bits used to encode devices/subdevices into
  the minor number soon, after more distros support > 8 bit minor numbers
@@ -289,6 +284,7 @@
 	COMEDI_DEVICE_MINOR_MASK = 0xf,
 	COMEDI_SUBDEVICE_MINOR_MASK = 0xf0
 };
+
 static const unsigned COMEDI_SUBDEVICE_MINOR_SHIFT = 4;
 static const unsigned COMEDI_SUBDEVICE_MINOR_OFFSET = 1;
 
@@ -363,6 +359,12 @@
 	return s->range_table->range[range].min >= 0;
 }
 
+static inline bool comedi_range_is_external(struct comedi_subdevice *s,
+					    unsigned int range)
+{
+	return !!(s->range_table->range[range].flags & RF_EXTERNAL);
+}
+
 static inline bool comedi_chan_range_is_bipolar(struct comedi_subdevice *s,
 						unsigned int chan,
 						unsigned int range)
@@ -377,6 +379,13 @@
 	return s->range_table_list[chan]->range[range].min >= 0;
 }
 
+static inline bool comedi_chan_range_is_external(struct comedi_subdevice *s,
+						 unsigned int chan,
+						 unsigned int range)
+{
+	return !!(s->range_table_list[chan]->range[range].flags & RF_EXTERNAL);
+}
+
 /* munge between offset binary and two's complement values */
 static inline unsigned int comedi_offset_munge(struct comedi_subdevice *s,
 					       unsigned int val)
@@ -388,8 +397,8 @@
 {
 	if (subd->subdev_flags & SDF_LSAMPL)
 		return sizeof(unsigned int);
-	else
-		return sizeof(short);
+
+	return sizeof(short);
 }
 
 /*
@@ -556,9 +565,9 @@
 void comedi_pcmcia_auto_unconfig(struct pcmcia_device *);
 
 int comedi_pcmcia_driver_register(struct comedi_driver *,
-					struct pcmcia_driver *);
+				  struct pcmcia_driver *);
 void comedi_pcmcia_driver_unregister(struct comedi_driver *,
-					struct pcmcia_driver *);
+				     struct pcmcia_driver *);
 
 /**
  * module_comedi_pcmcia_driver() - Helper macro for registering a comedi PCMCIA driver
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 299726f..42ddf13 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -38,6 +38,7 @@
 #include "comedi_internal.h"
 
 struct comedi_driver *comedi_drivers;
+/* protects access to comedi_drivers */
 DEFINE_MUTEX(comedi_drivers_list_lock);
 
 int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev)
@@ -319,7 +320,7 @@
 		return -ENOMEM;
 	}
 	if (s->buf_change) {
-		ret = s->buf_change(dev, s, buf_size);
+		ret = s->buf_change(dev, s);
 		if (ret < 0)
 			return ret;
 	}
@@ -566,8 +567,9 @@
 			dev->board_ptr = comedi_recognize(driv, it->board_name);
 			if (dev->board_ptr)
 				break;
-		} else if (strcmp(driv->driver_name, it->board_name) == 0)
+		} else if (strcmp(driv->driver_name, it->board_name) == 0) {
 			break;
+		}
 		module_put(driv->module);
 	}
 	if (driv == NULL) {
@@ -591,8 +593,6 @@
 		ret = -ENOSYS;
 		goto out;
 	}
-	/* initialize dev->driver here so
-	 * comedi_error() can be called from attach */
 	dev->driver = driv;
 	dev->board_name = dev->board_ptr ? *(const char **)dev->board_ptr
 					 : dev->driver->driver_name;
diff --git a/drivers/staging/comedi/drivers/8253.h b/drivers/staging/comedi/drivers/8253.h
index 5829b46..f8e1eba 100644
--- a/drivers/staging/comedi/drivers/8253.h
+++ b/drivers/staging/comedi/drivers/8253.h
@@ -34,7 +34,7 @@
 					     unsigned int *d1,
 					     unsigned int *d2,
 					     unsigned int *nanosec,
-					     int round_mode)
+					     unsigned int flags)
 {
 	unsigned int divider;
 	unsigned int div1, div2;
@@ -90,8 +90,7 @@
 		}
 	}
 
-	round_mode &= TRIG_ROUND_MASK;
-	switch (round_mode) {
+	switch (flags & TRIG_ROUND_MASK) {
 	case TRIG_ROUND_NEAREST:
 	default:
 		ns_high = div1_lub * div2_lub * i8253_osc_base;
@@ -118,7 +117,6 @@
 	/*  masking is done since counter maps zero to 0x10000 */
 	*d1 = div1 & 0xffff;
 	*d2 = div2 & 0xffff;
-	return;
 }
 
 #ifndef CMDTEST
diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c
index 46113a3..a33a196 100644
--- a/drivers/staging/comedi/drivers/8255.c
+++ b/drivers/staging/comedi/drivers/8255.c
@@ -102,9 +102,8 @@
 	if (dir) {
 		outb(data, iobase + port);
 		return 0;
-	} else {
-		return inb(iobase + port);
 	}
+	return inb(iobase + port);
 }
 
 void subdev_8255_interrupt(struct comedi_device *dev,
diff --git a/drivers/staging/comedi/drivers/8255_pci.c b/drivers/staging/comedi/drivers/8255_pci.c
index 46a385c..e4cec93 100644
--- a/drivers/staging/comedi/drivers/8255_pci.c
+++ b/drivers/staging/comedi/drivers/8255_pci.c
@@ -56,7 +56,6 @@
 #include "../comedidev.h"
 
 #include "8255.h"
-#include "mite.h"
 
 enum pci_8255_boardid {
 	BOARD_ADLINK_PCI7224,
@@ -172,6 +171,10 @@
 	void __iomem *mmio_base;
 };
 
+/* ripped from mite.h and mite_setup2() to avoid mite dependancy */
+#define MITE_IODWBSR	0xc0	 /* IO Device Window Base Size Register */
+#define WENAB		(1 << 7) /* window enable */
+
 static int pci_8255_mite_init(struct pci_dev *pcidev)
 {
 	void __iomem *mite_base;
@@ -198,9 +201,8 @@
 	if (dir) {
 		writeb(data, mmio_base + port);
 		return 0;
-	} else {
-		return readb(mmio_base  + port);
 	}
+	return readb(mmio_base  + port);
 }
 
 static int pci_8255_auto_attach(struct comedi_device *dev,
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c
index a633957..1e2fe66 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1500.c
@@ -872,7 +872,8 @@
 					break;
 
 				default:
-					comedi_error(dev, " chan spec wrong");
+					dev_err(dev->class_dev,
+						"chan spec wrong\n");
 					return -EINVAL;	/*  "sorry channel spec wrong " */
 
 				}	/* switch(ui_NoOfChannels) */
@@ -950,8 +951,8 @@
 						break;
 
 					default:
-						comedi_error(dev,
-							" chan spec wrong");
+						dev_err(dev->class_dev,
+							"chan spec wrong\n");
 						return -EINVAL;	/*  "sorry channel spec wrong " */
 
 					}	/* switch(ui_NoOfChannels) */
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
index 7326f3a..a1730e9 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c
@@ -102,8 +102,7 @@
 	unsigned int ul_Command = 0;
 
 	if ((data[0] != 0) && (data[0] != 1)) {
-		comedi_error(dev,
-			"Not a valid Data !!! ,Data should be 1 or 0\n");
+		dev_err(dev->class_dev, "Data should be 1 or 0\n");
 		return -EINVAL;
 	}
 
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
index bfa154d..77cee87 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c
@@ -270,7 +270,7 @@
 
 			if (CR_CHAN(data[4 + i]) >=
 				this_board->i_NbrAiChannel) {
-				printk("bad channel list\n");
+				dev_err(dev->class_dev, "bad channel list\n");
 				return -2;
 			}
 		}
@@ -318,7 +318,8 @@
 	/* correct channel and range number check itself comedi/range.c */
 	if (n_chan < 1) {
 		if (!check)
-			comedi_error(dev, "range/channel list is empty!");
+			dev_err(dev->class_dev,
+				"range/channel list is empty!\n");
 		return 0;
 	}
 	/*  All is ok, so we can setup channel/range list */
@@ -344,11 +345,6 @@
 		us_TmpValue |= ((gain & 0x03) << 4);	/* <<4 for G0 and G1 bit in RAM */
 		us_TmpValue |= i << 8;	/* To select the RAM LOCATION.... */
 		outw(us_TmpValue, dev->iobase + APCI3120_SEQ_RAM_ADDRESS);
-
-		printk("\n Gain = %i",
-			(((unsigned char)CR_RANGE(chanlist[i]) & 0x03) << 2));
-		printk("\n Channel = %i", CR_CHAN(chanlist[i]));
-		printk("\n Polarity = %i", us_TmpValue & APCI3120_UNIPOLAR);
 	}
 	return 1;		/*  we can serve this with scan logic */
 }
@@ -369,10 +365,9 @@
 	unsigned char b_Tmp;
 
 	/*  fix conversion time to 10 us */
-	if (!devpriv->ui_EocEosConversionTime) {
-		printk("No timer0 Value using 10 us\n");
+	if (!devpriv->ui_EocEosConversionTime)
 		us_ConvertTiming = 10;
-	} else
+	else
 		us_ConvertTiming = (unsigned short) (devpriv->ui_EocEosConversionTime / 1000);	/*  nano to useconds */
 
 	/*  this_board->ai_read(dev,us_ConvertTiming,insn->n,&insn->chanspec,data,insn->unused[0]); */
@@ -593,7 +588,7 @@
 			break;
 
 		default:
-			printk("inputs wrong\n");
+			dev_err(dev->class_dev, "inputs wrong\n");
 
 		}
 		devpriv->ui_EocEosConversionTime = 0;	/*  re initializing the variable; */
@@ -1373,10 +1368,10 @@
 
 	if (samplesinbuf <
 		devpriv->ui_DmaBufferUsesize[devpriv->ui_DmaActualBuffer]) {
-		comedi_error(dev, "Interrupted DMA transfer!");
+		dev_err(dev->class_dev, "Interrupted DMA transfer!\n");
 	}
 	if (samplesinbuf & 1) {
-		comedi_error(dev, "Odd count of bytes in DMA ring!");
+		dev_err(dev->class_dev, "Odd count of bytes in DMA ring!\n");
 		apci3120_cancel(dev, s);
 		return;
 	}
@@ -1548,7 +1543,7 @@
 	int_amcc = inl(devpriv->i_IobaseAmcc + AMCC_OP_REG_INTCSR);	/*  get AMCC int register */
 
 	if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) {
-		comedi_error(dev, "IRQ from unknown source");
+		dev_err(dev->class_dev, "IRQ from unknown source\n");
 		return;
 	}
 
@@ -1565,9 +1560,9 @@
 	inb(devpriv->i_IobaseAmcc + APCI3120_TIMER_STATUS_REGISTER);
 
 	if (int_amcc & MASTER_ABORT_INT)
-		comedi_error(dev, "AMCC IRQ - MASTER DMA ABORT!");
+		dev_err(dev->class_dev, "AMCC IRQ - MASTER DMA ABORT!\n");
 	if (int_amcc & TARGET_ABORT_INT)
-		comedi_error(dev, "AMCC IRQ - TARGET DMA ABORT!");
+		dev_err(dev->class_dev, "AMCC IRQ - TARGET DMA ABORT!\n");
 
 	/*  Ckeck if EOC interrupt */
 	if (((int_daq & 0x8) == 0)
@@ -1740,7 +1735,7 @@
 	unsigned char b_Tmp;
 
 	if (!data[1])
-		comedi_error(dev, "config:No timer constant !");
+		dev_err(dev->class_dev, "No timer constant!\n");
 
 	devpriv->b_Timer2Interrupt = (unsigned char) data[2];	/*  save info whether to enable or disable interrupt */
 
@@ -1886,14 +1881,14 @@
 
 	if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG)
 		&& (devpriv->b_Timer2Mode != APCI3120_TIMER)) {
-		comedi_error(dev, "\nwrite:timer2  not configured ");
+		dev_err(dev->class_dev, "timer2 not configured\n");
 		return -EINVAL;
 	}
 
 	if (data[0] == 2) {	/*  write new value */
 		if (devpriv->b_Timer2Mode != APCI3120_TIMER) {
-			comedi_error(dev,
-				"write :timer2  not configured  in TIMER MODE");
+			dev_err(dev->class_dev,
+				"timer2 not configured in TIMER MODE\n");
 			return -EINVAL;
 		}
 
@@ -1991,8 +1986,8 @@
 
 	case 2:		/* write new value to Timer */
 		if (devpriv->b_Timer2Mode != APCI3120_TIMER) {
-			comedi_error(dev,
-				"write :timer2  not configured  in TIMER MODE");
+			dev_err(dev->class_dev,
+				"timer2 not configured in TIMER MODE\n");
 			return -EINVAL;
 		}
 		/*  ui_Timervalue2=data[1]; // passed as argument */
@@ -2056,7 +2051,7 @@
 
 	if ((devpriv->b_Timer2Mode != APCI3120_WATCHDOG)
 		&& (devpriv->b_Timer2Mode != APCI3120_TIMER)) {
-		comedi_error(dev, "\nread:timer2  not configured ");
+		dev_err(dev->class_dev, "timer2 not configured\n");
 	}
 
 	/* this_board->timer_read(dev,data); */
@@ -2161,10 +2156,6 @@
 
 	}
 
-/*
- * out put n values at the given channel. printk("\nwaiting for
- * DA_READY BIT");
- */
 	do {			/* Waiting of DA_READY BIT */
 		us_TmpValue =
 			((unsigned short) inw(devpriv->iobase +
diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
index a3026a2..5e321f9 100644
--- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
+++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3200.c
@@ -47,8 +47,6 @@
   +----------+-----------+------------------------------------------------+
 */
 
-/* #define PRINT_INFO */
-
 /* Card Specific information */
 /* #define APCI3200_ADDRESS_RANGE	264 */
 
@@ -455,12 +453,6 @@
 			BoardInformations->s_Module[w_ModulCounter].
 				w_GainValue[w_GainIndex] = w_GainValue;
 
-#             ifdef PRINT_INFO
-			printk("\n Gain value = %d",
-				BoardInformations->s_Module[w_ModulCounter].
-				w_GainValue[w_GainIndex]);
-#             endif
-
 	  /*************************************/
 	  /** Read gain factor for the module **/
 	  /*************************************/
@@ -472,12 +464,6 @@
 				ul_GainFactor[w_GainIndex] =
 				(w_GainFactorValue[1] << 16) +
 				w_GainFactorValue[0];
-
-#             ifdef PRINT_INFO
-			printk("\n w_GainFactorValue [%d] = %lu", w_GainIndex,
-				BoardInformations->s_Module[w_ModulCounter].
-				ul_GainFactor[w_GainIndex]);
-#             endif
 		}
 
       /***************************************************************/
@@ -499,12 +485,6 @@
 				ul_CurrentSource[w_Input] =
 				(w_CurrentSources[0] +
 				((w_CurrentSources[1] & 0xFFF) << 16));
-
-#             ifdef PRINT_INFO
-			printk("\n Current sources [%d] = %lu", w_Input,
-				BoardInformations->s_Module[w_ModulCounter].
-				ul_CurrentSource[w_Input]);
-#             endif
 		}
 
       /***************************************/
@@ -522,12 +502,6 @@
 			ul_CurrentSourceCJC =
 			(w_CurrentSources[0] +
 			((w_CurrentSources[1] & 0xFFF) << 16));
-
-#          ifdef PRINT_INFO
-		printk("\n Current sources CJC = %lu",
-			BoardInformations->s_Module[w_ModulCounter].
-			ul_CurrentSourceCJC);
-#          endif
 	}
 }
 
@@ -540,10 +514,6 @@
 	int i_DiffChannel = 0;
 	int i_Module = 0;
 
-#ifdef PRINT_INFO
-	printk("\n Channel = %u", ui_Channel_num);
-#endif
-
 	/* Test if single or differential mode */
 	if (s_BoardInfos[dev->minor].i_ConnectionType == 1) {
 		/* if diff */
@@ -580,16 +550,10 @@
 	/* Test if thermocouple or RTD mode */
 	*CJCCurrentSource =
 		s_BoardInfos[dev->minor].s_Module[i_Module].ul_CurrentSourceCJC;
-#ifdef PRINT_INFO
-	printk("\n CJCCurrentSource = %lu", *CJCCurrentSource);
-#endif
 
 	*ChannelCurrentSource =
 		s_BoardInfos[dev->minor].s_Module[i_Module].
 		ul_CurrentSource[i_DiffChannel];
-#ifdef PRINT_INFO
-	printk("\n ChannelCurrentSource = %lu", *ChannelCurrentSource);
-#endif
 	/*       } */
 	/*    } */
 
@@ -597,9 +561,6 @@
 	*ChannelGainFactor =
 		s_BoardInfos[dev->minor].s_Module[i_Module].
 		ul_GainFactor[s_BoardInfos[dev->minor].i_ADDIDATAGain];
-#ifdef PRINT_INFO
-	printk("\n ChannelGainFactor = %lu", *ChannelGainFactor);
-#endif
 	/* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
 
 	return 0;
@@ -1279,10 +1240,6 @@
 		return -EINVAL;
 	}			/* if(i_Initialised==0); */
 
-#ifdef PRINT_INFO
-	printk("\n insn->unused[0] = %i", insn->unused[0]);
-#endif
-
 	switch (insn->unused[0]) {
 	case 0:
 
@@ -1307,15 +1264,6 @@
 			&s_BoardInfos[dev->minor].
 			ui_InterruptChannelValue[s_BoardInfos[dev->minor].
 				i_Count + 8]);
-
-#ifdef PRINT_INFO
-		printk("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+6] = %lu", s_BoardInfos[dev->minor].ui_InterruptChannelValue[s_BoardInfos[dev->minor].i_Count + 6]);
-
-		printk("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+7] = %lu", s_BoardInfos[dev->minor].ui_InterruptChannelValue[s_BoardInfos[dev->minor].i_Count + 7]);
-
-		printk("\n s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count+8] = %lu", s_BoardInfos[dev->minor].ui_InterruptChannelValue[s_BoardInfos[dev->minor].i_Count + 8]);
-#endif
-
 		/* End JK 25.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
 
 		/* BEGIN JK 06.07.04: Management of sevrals boards */
@@ -1471,9 +1419,6 @@
 			   data[4]= ui_InterruptChannelValue[4];
 			   data[5]= ui_InterruptChannelValue[5];
 			 */
-#ifdef PRINT_INFO
-			printk("\n data[0]= s_BoardInfos [dev->minor].ui_InterruptChannelValue[0];");
-#endif
 			data[0] =
 				s_BoardInfos[dev->minor].
 				ui_InterruptChannelValue[0];
@@ -1494,7 +1439,6 @@
 				ui_InterruptChannelValue[5];
 
 			/* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-			/* printk("\n 0 - i_APCI3200_GetChannelCalibrationValue data [6] = %lu, data [7] = %lu, data [8] = %lu", data [6], data [7], data [8]); */
 			i_APCI3200_GetChannelCalibrationValue(dev,
 				s_BoardInfos[dev->minor].ui_Channel_num,
 				&data[6], &data[7], &data[8]);
@@ -1576,13 +1520,6 @@
 	unsigned int ui_Dummy = 0;
 	int i_err = 0;
 
-	/* Begin JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-
-#ifdef PRINT_INFO
-	int i = 0, i2 = 0;
-#endif
-	/* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
-
 	/* BEGIN JK 06.07.04: Management of sevrals boards */
 	/*  Initialize the structure */
 	if (s_BoardInfos[dev->minor].b_StructInitialized != 1) {
@@ -1608,29 +1545,6 @@
 
 		v_GetAPCI3200EepromCalibrationValue(devpriv->i_IobaseAmcc,
 			&s_BoardInfos[dev->minor]);
-
-#ifdef PRINT_INFO
-		for (i = 0; i < MAX_MODULE; i++) {
-			printk("\n s_Module[%i].ul_CurrentSourceCJC = %lu", i,
-				s_BoardInfos[dev->minor].s_Module[i].
-				ul_CurrentSourceCJC);
-
-			for (i2 = 0; i2 < 5; i2++) {
-				printk("\n s_Module[%i].ul_CurrentSource [%i] = %lu", i, i2, s_BoardInfos[dev->minor].s_Module[i].ul_CurrentSource[i2]);
-			}
-
-			for (i2 = 0; i2 < 8; i2++) {
-				printk("\n s_Module[%i].ul_GainFactor [%i] = %lu", i, i2, s_BoardInfos[dev->minor].s_Module[i].ul_GainFactor[i2]);
-			}
-
-			for (i2 = 0; i2 < 8; i2++) {
-				printk("\n s_Module[%i].w_GainValue [%i] = %u",
-					i, i2,
-					s_BoardInfos[dev->minor].s_Module[i].
-					w_GainValue[i2]);
-			}
-		}
-#endif
 		/* End JK 21.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
 	}
 
@@ -1750,34 +1664,34 @@
 	/* END JK 06.07.04: Management of sevrals boards */
 
 	if (data[5] == 0) {
-		if (ui_ChannelNo < 0 || ui_ChannelNo > 15) {
+		if (ui_ChannelNo > 15) {
 			printk("\nThe Selection of the channel is in error\n");
 			i_err++;
-		}		/*  if(ui_ChannelNo<0 || ui_ChannelNo>15) */
+		}		/*  if(ui_ChannelNo>15) */
 	}			/* if(data[5]==0) */
 	else {
 		if (data[14] == 2) {
-			if (ui_ChannelNo < 0 || ui_ChannelNo > 3) {
+			if (ui_ChannelNo > 3) {
 				printk("\nThe Selection of the channel is in error\n");
 				i_err++;
-			}	/*  if(ui_ChannelNo<0 || ui_ChannelNo>3) */
+			}	/*  if(ui_ChannelNo>3) */
 		}		/* if(data[14]==2) */
 		else {
-			if (ui_ChannelNo < 0 || ui_ChannelNo > 7) {
+			if (ui_ChannelNo > 7) {
 				printk("\nThe Selection of the channel is in error\n");
 				i_err++;
-			}	/*  if(ui_ChannelNo<0 || ui_ChannelNo>7) */
+			}	/*  if(ui_ChannelNo>7) */
 		}		/* elseif(data[14]==2) */
 	}			/* elseif(data[5]==0) */
 	if (data[12] == 0 || data[12] == 1) {
 		switch (data[5]) {
 		case 0:
-			if (ui_ChannelNo >= 0 && ui_ChannelNo <= 3) {
+			if (ui_ChannelNo <= 3) {
 				/* BEGIN JK 06.07.04: Management of sevrals boards */
 				/* i_Offset=0; */
 				s_BoardInfos[dev->minor].i_Offset = 0;
 				/* END JK 06.07.04: Management of sevrals boards */
-			}	/* if(ui_ChannelNo >=0 && ui_ChannelNo <=3) */
+			}	/* if(ui_ChannelNo <=3) */
 			if (ui_ChannelNo >= 4 && ui_ChannelNo <= 7) {
 				/* BEGIN JK 06.07.04: Management of sevrals boards */
 				/* i_Offset=64; */
@@ -1831,12 +1745,12 @@
 				ui_ChannelNo = 0;
 				break;
 			}	/* if(data[14]==2) */
-			if (ui_ChannelNo >= 0 && ui_ChannelNo <= 1) {
+			if (ui_ChannelNo <= 1) {
 				/* BEGIN JK 06.07.04: Management of sevrals boards */
 				/* i_Offset=0; */
 				s_BoardInfos[dev->minor].i_Offset = 0;
 				/* END JK 06.07.04: Management of sevrals boards */
-			}	/* if(ui_ChannelNo >=0 && ui_ChannelNo <=1) */
+			}	/* if(ui_ChannelNo <=1) */
 			if (ui_ChannelNo >= 2 && ui_ChannelNo <= 3) {
 				/* BEGIN JK 06.07.04: Management of sevrals boards */
 				/* i_ChannelNo=i_ChannelNo-2; */
@@ -2135,7 +2049,6 @@
 	}
 	/* i_InterruptFlag=i_Temp ; */
 	s_BoardInfos[dev->minor].i_InterruptFlag = i_Temp;
-	/* printk("\ni_InterruptFlag=%d\n",i_InterruptFlag); */
 	return insn->n;
 }
 
@@ -2407,8 +2320,6 @@
 		ui_DelayTimeBase = cmd->scan_begin_arg >> 16;
 		ui_DelayMode = 1;
 	}			/* else if(cmd->scan_begin_src==TRIG_FOLLOW) */
-	/*         printk("\nui_DelayTime=%u\n",ui_DelayTime); */
-	/*         printk("\nui_DelayTimeBase=%u\n",ui_DelayTimeBase); */
 	if (cmd->convert_src == TRIG_TIMER) {
 		ui_ConvertTime = cmd->convert_arg & 0xFFFF;
 		ui_ConvertTimeBase = cmd->convert_arg >> 16;
@@ -2436,13 +2347,6 @@
 		devpriv->iobase + s_BoardInfos[dev->minor].i_Offset + 12);
 	/*  } */
 	ui_Configuration = 0;
-	/*      printk("\nfirstchannel=%u\n",i_FirstChannel); */
-	/*      printk("\nlastchannel=%u\n",i_LastChannel); */
-	/*      printk("\nui_Trigger=%u\n",ui_Trigger); */
-	/*      printk("\nui_TriggerEdge=%u\n",ui_TriggerEdge); */
-	/*      printk("\nui_Triggermode=%u\n",ui_Triggermode); */
-	/*       printk("\nui_DelayMode=%u\n",ui_DelayMode); */
-	/*      printk("\nui_ScanMode=%u\n",ui_ScanMode); */
 
 	/* ui_Configuration = i_FirstChannel |(i_LastChannel << 8)| 0x00100000 | */
 	ui_Configuration =
@@ -2694,8 +2598,6 @@
 	int i_ReturnValue = 0;
 	/* END JK TEST */
 
-	/* printk ("\n i_ScanType = %i i_ADDIDATAType = %i", s_BoardInfos [dev->minor].i_ScanType, s_BoardInfos [dev->minor].i_ADDIDATAType); */
-
 	/* switch(i_ScanType) */
 	switch (s_BoardInfos[dev->minor].i_ScanType) {
 	case 0:
@@ -2746,7 +2648,6 @@
 
 					/* Begin JK 22.10.2004: APCI-3200 / APCI-3300 Reading of EEPROM values */
 					/*
-					   printk("\n 1 - i_APCI3200_GetChannelCalibrationValue (dev, s_BoardInfos %i", ui_ChannelNumber);
 					   i_APCI3200_GetChannelCalibrationValue (dev, s_BoardInfos [dev->minor].ui_Channel_num,
 					   &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 6],
 					   &s_BoardInfos [dev->minor].ui_InterruptChannelValue[s_BoardInfos [dev->minor].i_Count + 7],
diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c
index 1e25342..190b026 100644
--- a/drivers/staging/comedi/drivers/addi_apci_1564.c
+++ b/drivers/staging/comedi/drivers/addi_apci_1564.c
@@ -1,13 +1,13 @@
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/interrupt.h>
+#include <linux/sched.h>
 
 #include "../comedidev.h"
 #include "comedi_fc.h"
 #include "amcc_s5933.h"
 #include "addi_watchdog.h"
 
-#include "addi-data/addi_common.h"
-
 struct apci1564_private {
 	unsigned int amcc_iobase;	/* base of AMCC I/O registers */
 	unsigned int mode1;		/* riding-edge/high level channels */
@@ -373,7 +373,7 @@
 			dev->irq = pcidev->irq;
 	}
 
-	ret = comedi_alloc_subdevices(dev, 4);
+	ret = comedi_alloc_subdevices(dev, 5);
 	if (ret)
 		return ret;
 
@@ -397,20 +397,8 @@
 	s->insn_bits = apci1564_do_insn_bits;
 	s->insn_read = apci1564_do_read;
 
-	/*  Allocate and Initialise Timer Subdevice Structures */
-	s = &dev->subdevices[2];
-	s->type = COMEDI_SUBD_TIMER;
-	s->subdev_flags = SDF_WRITEABLE;
-	s->n_chan = 1;
-	s->maxdata = 0;
-	s->len_chanlist = 1;
-	s->range_table = &range_digital;
-	s->insn_write = apci1564_timer_write;
-	s->insn_read = apci1564_timer_read;
-	s->insn_config = apci1564_timer_config;
-
 	/* Change-Of-State (COS) interrupt subdevice */
-	s = &dev->subdevices[3];
+	s = &dev->subdevices[2];
 	if (dev->irq) {
 		dev->read_subdev = s;
 		s->type = COMEDI_SUBD_DI;
@@ -428,6 +416,24 @@
 		s->type = COMEDI_SUBD_UNUSED;
 	}
 
+	/*  Allocate and Initialise Timer Subdevice Structures */
+	s = &dev->subdevices[3];
+	s->type = COMEDI_SUBD_TIMER;
+	s->subdev_flags = SDF_WRITEABLE;
+	s->n_chan = 1;
+	s->maxdata = 0;
+	s->len_chanlist = 1;
+	s->range_table = &range_digital;
+	s->insn_write = apci1564_timer_write;
+	s->insn_read = apci1564_timer_read;
+	s->insn_config = apci1564_timer_config;
+
+	/* Initialize the watchdog subdevice */
+	s = &dev->subdevices[4];
+	ret = addi_watchdog_init(s, devpriv->amcc_iobase + APCI1564_WDOG_REG);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c
index 49bf1fb..d9594f4 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3501.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3501.c
@@ -274,7 +274,7 @@
 
 	ui_Timer_AOWatchdog = inl(dev->iobase + APCI3501_TIMER_IRQ_REG) & 0x1;
 	if ((!ui_Timer_AOWatchdog)) {
-		comedi_error(dev, "IRQ from unknown source");
+		dev_err(dev->class_dev, "IRQ from unknown source\n");
 		return IRQ_NONE;
 	}
 
diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
index 0532b6c..1b7cbf4 100644
--- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c
+++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c
@@ -389,9 +389,8 @@
 
 	if ((readl(devpriv->mmio + 8) & 0x80000) == 0x80000)
 		return 1;
-	else
-		return 0;
 
+	return 0;
 }
 
 static int apci3xxx_ai_setup(struct comedi_device *dev, unsigned int chanspec)
@@ -478,7 +477,7 @@
 }
 
 static int apci3xxx_ai_ns_to_timer(struct comedi_device *dev,
-				   unsigned int *ns, int round_mode)
+				   unsigned int *ns, unsigned int flags)
 {
 	const struct apci3xxx_boardinfo *board = comedi_board(dev);
 	struct apci3xxx_private *devpriv = dev->private;
@@ -504,7 +503,7 @@
 			break;
 		}
 
-		switch (round_mode) {
+		switch (flags & TRIG_ROUND_MASK) {
 		case TRIG_ROUND_NEAREST:
 		default:
 			timer = (*ns + base / 2) / base;
@@ -574,7 +573,7 @@
 	/* step 4: fix up any arguments */
 
 	arg = cmd->convert_arg;
-	err |= apci3xxx_ai_ns_to_timer(dev, &arg, cmd->flags & TRIG_ROUND_MASK);
+	err |= apci3xxx_ai_ns_to_timer(dev, &arg, cmd->flags);
 	err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
 
 	if (err)
@@ -696,10 +695,9 @@
 		/* ignore all other instructions for ports 0 and 1 */
 		if (chan < 16)
 			return -EINVAL;
-		else
-			/* changing any channel in port 2 */
-			/* changes the entire port        */
-			mask = 0xff0000;
+
+		/* changing any channel in port 2 changes the entire port */
+		mask = 0xff0000;
 	}
 
 	ret = comedi_dio_insn_config(dev, s, insn, data, mask);
diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c
index 59a65cb..f30b84e 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -7,61 +7,62 @@
  *
  * Author: Michal Dobes <dobes@tesnet.cz>
  *
-*/
+ */
+
 /*
-Driver: adl_pci9118
-Description: Adlink PCI-9118DG, PCI-9118HG, PCI-9118HR
-Author: Michal Dobes <dobes@tesnet.cz>
-Devices: [ADLink] PCI-9118DG (pci9118dg), PCI-9118HG (pci9118hg),
-  PCI-9118HR (pci9118hr)
-Status: works
-
-This driver supports AI, AO, DI and DO subdevices.
-AI subdevice supports cmd and insn interface,
-other subdevices support only insn interface.
-For AI:
-- If cmd->scan_begin_src=TRIG_EXT then trigger input is TGIN (pin 46).
-- If cmd->convert_src=TRIG_EXT then trigger input is EXTTRG (pin 44).
-- If cmd->start_src/stop_src=TRIG_EXT then trigger input is TGIN (pin 46).
-- It is not necessary to have cmd.scan_end_arg=cmd.chanlist_len but
-  cmd.scan_end_arg modulo cmd.chanlist_len must by 0.
-- If return value of cmdtest is 5 then you've bad channel list
-  (it isn't possible mixture S.E. and DIFF inputs or bipolar and unipolar
-  ranges).
-
-There are some hardware limitations:
-a) You cann't use mixture of unipolar/bipoar ranges or differencial/single
-   ended inputs.
-b) DMA transfers must have the length aligned to two samples (32 bit),
-   so there is some problems if cmd->chanlist_len is odd. This driver tries
-   bypass this with adding one sample to the end of the every scan and discard
-   it on output but this cann't be used if cmd->scan_begin_src=TRIG_FOLLOW
-   and is used flag TRIG_WAKE_EOS, then driver switch to interrupt driven mode
-   with interrupt after every sample.
-c) If isn't used DMA then you can use only mode where
-   cmd->scan_begin_src=TRIG_FOLLOW.
-
-Configuration options:
-  [0] - PCI bus of device (optional)
-  [1] - PCI slot of device (optional)
-	If bus/slot is not specified, then first available PCI
-	card will be used.
-  [2] - 0= standard 8 DIFF/16 SE channels configuration
-	n = external multiplexer connected, 1 <= n <= 256
-  [3] - 0=autoselect DMA or EOC interrupts operation
-	1 = disable DMA mode
-	3 = disable DMA and INT, only insn interface will work
-  [4] - sample&hold signal - card can generate signal for external S&H board
-	0 = use SSHO(pin 45) signal is generated in onboard hardware S&H logic
-	0 != use ADCHN7(pin 23) signal is generated from driver, number say how
-		long delay is requested in ns and sign polarity of the hold
-		(in this case external multiplexor can serve only 128 channels)
-  [5] - 0=stop measure on all hardware errors
-	2 | = ignore ADOR - A/D Overrun status
-	8|=ignore Bover - A/D Burst Mode Overrun status
-	256|=ignore nFull - A/D FIFO Full status
-
-*/
+ * Driver: adl_pci9118
+ * Description: Adlink PCI-9118DG, PCI-9118HG, PCI-9118HR
+ * Author: Michal Dobes <dobes@tesnet.cz>
+ * Devices: [ADLink] PCI-9118DG (pci9118dg), PCI-9118HG (pci9118hg),
+ * PCI-9118HR (pci9118hr)
+ * Status: works
+ *
+ * This driver supports AI, AO, DI and DO subdevices.
+ * AI subdevice supports cmd and insn interface,
+ * other subdevices support only insn interface.
+ * For AI:
+ * - If cmd->scan_begin_src=TRIG_EXT then trigger input is TGIN (pin 46).
+ * - If cmd->convert_src=TRIG_EXT then trigger input is EXTTRG (pin 44).
+ * - If cmd->start_src/stop_src=TRIG_EXT then trigger input is TGIN (pin 46).
+ * - It is not necessary to have cmd.scan_end_arg=cmd.chanlist_len but
+ * cmd.scan_end_arg modulo cmd.chanlist_len must by 0.
+ * - If return value of cmdtest is 5 then you've bad channel list
+ * (it isn't possible mixture S.E. and DIFF inputs or bipolar and unipolar
+ * ranges).
+ *
+ * There are some hardware limitations:
+ * a) You cann't use mixture of unipolar/bipoar ranges or differencial/single
+ *  ended inputs.
+ * b) DMA transfers must have the length aligned to two samples (32 bit),
+ *  so there is some problems if cmd->chanlist_len is odd. This driver tries
+ *  bypass this with adding one sample to the end of the every scan and discard
+ *  it on output but this cann't be used if cmd->scan_begin_src=TRIG_FOLLOW
+ *  and is used flag TRIG_WAKE_EOS, then driver switch to interrupt driven mode
+ *  with interrupt after every sample.
+ * c) If isn't used DMA then you can use only mode where
+ *  cmd->scan_begin_src=TRIG_FOLLOW.
+ *
+ * Configuration options:
+ * [0] - PCI bus of device (optional)
+ * [1] - PCI slot of device (optional)
+ *	 If bus/slot is not specified, then first available PCI
+ *	 card will be used.
+ * [2] - 0= standard 8 DIFF/16 SE channels configuration
+ *	 n = external multiplexer connected, 1 <= n <= 256
+ * [3] - 0=autoselect DMA or EOC interrupts operation
+ *	 1 = disable DMA mode
+ *	 3 = disable DMA and INT, only insn interface will work
+ * [4] - sample&hold signal - card can generate signal for external S&H board
+ *	 0 = use SSHO(pin 45) signal is generated in onboard hardware S&H logic
+ *	 0 != use ADCHN7(pin 23) signal is generated from driver, number say how
+ *		long delay is requested in ns and sign polarity of the hold
+ *		(in this case external multiplexor can serve only 128 channels)
+ * [5] - 0=stop measure on all hardware errors
+ *	 2 | = ignore ADOR - A/D Overrun status
+ *	 8|=ignore Bover - A/D Burst Mode Overrun status
+ *	 256|=ignore nFull - A/D FIFO Full status
+ *
+ */
 
 /*
  * FIXME
@@ -346,7 +347,7 @@
 						 * on external start
 						 */
 	unsigned short ao_data[2];		/* data output buffer */
-	char dma_doublebuf;			/* we can use double buffering */
+	char dma_doublebuf;			/* use double buffering */
 	unsigned int dma_actbuf;		/* which buffer is used now */
 	unsigned short *dmabuf_virt[2];		/*
 						 * pointers to begin of
@@ -394,12 +395,12 @@
 
 	/* correct channel and range number check itself comedi/range.c */
 	if (n_chan < 1) {
-		comedi_error(dev, "range/channel list is empty!");
+		dev_err(dev->class_dev, "range/channel list is empty!\n");
 		return 0;
 	}
 	if ((frontadd + n_chan + backadd) > s->len_chanlist) {
-		comedi_error(dev,
-			    "range/channel list is too long for actual configuration!\n");
+		dev_err(dev->class_dev,
+			"range/channel list is too long for actual configuration!\n");
 		return 0;
 	}
 
@@ -411,23 +412,20 @@
 		for (i = 1; i < n_chan; i++) {	/* check S.E/diff */
 			if ((CR_AREF(chanlist[i]) == AREF_DIFF) !=
 			    (differencial)) {
-				comedi_error(dev,
-					     "Differencial and single ended "
-						"inputs can't be mixtured!");
+				dev_err(dev->class_dev,
+					"Differential and single ended inputs can't be mixed!\n");
 				return 0;
 			}
 			if ((CR_RANGE(chanlist[i]) < PCI9118_BIPOLAR_RANGES) !=
 			    (bipolar)) {
-				comedi_error(dev,
-					     "Bipolar and unipolar ranges "
-							"can't be mixtured!");
+				dev_err(dev->class_dev,
+					"Bipolar and unipolar ranges can't be mixed!\n");
 				return 0;
 			}
 			if (!devpriv->usemux && differencial &&
 			    (CR_CHAN(chanlist[i]) >= this_board->n_aichand)) {
-				comedi_error(dev,
-					     "If AREF_DIFF is used then is "
-					"available only first 8 channels!");
+				dev_err(dev->class_dev,
+					"AREF_DIFF is only available for the first 8 channels!\n");
 				return 0;
 			}
 		}
@@ -864,20 +862,21 @@
 	struct pci9118_private *devpriv = dev->private;
 
 	if (m & 0x100) {
-		comedi_error(dev, "A/D FIFO Full status (Fatal Error!)");
+		dev_err(dev->class_dev,
+			"A/D FIFO Full status (Fatal Error!)\n");
 		devpriv->ai_maskerr &= ~0x100L;
 	}
 	if (m & 0x008) {
-		comedi_error(dev,
-			     "A/D Burst Mode Overrun Status (Fatal Error!)");
+		dev_err(dev->class_dev,
+			"A/D Burst Mode Overrun Status (Fatal Error!)\n");
 		devpriv->ai_maskerr &= ~0x008L;
 	}
 	if (m & 0x004) {
-		comedi_error(dev, "A/D Over Speed Status (Warning!)");
+		dev_err(dev->class_dev, "A/D Over Speed Status (Warning!)\n");
 		devpriv->ai_maskerr &= ~0x004L;
 	}
 	if (m & 0x002) {
-		comedi_error(dev, "A/D Overrun Status (Fatal Error!)");
+		dev_err(dev->class_dev, "A/D Overrun Status (Fatal Error!)\n");
 		devpriv->ai_maskerr &= ~0x002L;
 	}
 	if (m & devpriv->ai_maskharderr) {
@@ -966,14 +965,14 @@
 	unsigned int next_dma_buf, samplesinbuf, sampls, m;
 
 	if (int_amcc & MASTER_ABORT_INT) {
-		comedi_error(dev, "AMCC IRQ - MASTER DMA ABORT!");
+		dev_err(dev->class_dev, "AMCC IRQ - MASTER DMA ABORT!\n");
 		s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
 		cfc_handle_events(dev, s);
 		return;
 	}
 
 	if (int_amcc & TARGET_ABORT_INT) {
-		comedi_error(dev, "AMCC IRQ - TARGET DMA ABORT!");
+		dev_err(dev->class_dev, "AMCC IRQ - TARGET DMA ABORT!\n");
 		s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
 		cfc_handle_events(dev, s);
 		return;
@@ -1427,17 +1426,16 @@
 		devpriv->AdControlReg |= AdControl_TmrTr;
 		break;
 	case 2:
-		comedi_error(dev, "pci9118_ai_docmd_sampl() mode 2 bug!\n");
+		dev_err(dev->class_dev, "%s mode 2 bug!\n", __func__);
 		return -EIO;
 	case 3:
 		devpriv->AdControlReg |= AdControl_ExtM;
 		break;
 	case 4:
-		comedi_error(dev, "pci9118_ai_docmd_sampl() mode 4 bug!\n");
+		dev_err(dev->class_dev, "%s mode 4 bug!\n", __func__);
 		return -EIO;
 	default:
-		comedi_error(dev,
-			     "pci9118_ai_docmd_sampl() mode number bug!\n");
+		dev_err(dev->class_dev, "%s mode number bug!\n", __func__);
 		return -EIO;
 	}
 
@@ -1509,7 +1507,7 @@
 		devpriv->AdFunctionReg |= AdFunction_Start;
 		break;
 	default:
-		comedi_error(dev, "pci9118_ai_docmd_dma() mode number bug!\n");
+		dev_err(dev->class_dev, "%s mode number bug!\n", __func__);
 		return -EIO;
 	}
 
@@ -1677,9 +1675,8 @@
 		(cmd->convert_src == TRIG_NOW))) {
 						/* double timed action */
 		if (!devpriv->usedma) {
-			comedi_error(dev,
-				     "cmd->scan_begin_src=TRIG_TIMER works "
-						"only with bus mastering!");
+			dev_err(dev->class_dev,
+				"cmd->scan_begin_src=TRIG_TIMER works only with bus mastering!\n");
 			return -EIO;
 		}
 
diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c
index 602b7a1..e19ab95 100644
--- a/drivers/staging/comedi/drivers/adv_pci1710.c
+++ b/drivers/staging/comedi/drivers/adv_pci1710.c
@@ -722,8 +722,8 @@
 	default:
 		devpriv->CntrlReg &= Control_CNT0;
 		devpriv->CntrlReg |= Control_SW;
-
-		outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);	/*  reset any operations */
+		/* reset any operations */
+		outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
 		pci171x_start_pacer(dev, false);
 		outb(0, dev->iobase + PCI171x_CLRFIFO);
 		outb(0, dev->iobase + PCI171x_CLRINT);
@@ -1049,15 +1049,18 @@
 	struct pci1710_private *devpriv = dev->private;
 
 	outw(0x30, dev->iobase + PCI171x_CNTCTRL);
-	devpriv->CntrlReg = Control_SW | Control_CNT0;	/*  Software trigger, CNT0=external */
-	outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);	/*  reset any operations */
+	/* Software trigger, CNT0=external */
+	devpriv->CntrlReg = Control_SW | Control_CNT0;
+	/* reset any operations */
+	outw(devpriv->CntrlReg, dev->iobase + PCI171x_CONTROL);
 	outb(0, dev->iobase + PCI171x_CLRFIFO);	/*  clear FIFO */
 	outb(0, dev->iobase + PCI171x_CLRINT);	/*  clear INT request */
 	pci171x_start_pacer(dev, false);
 	devpriv->da_ranges = 0;
 	if (this_board->n_aochan) {
-		outb(devpriv->da_ranges, dev->iobase + PCI171x_DAREF);	/*  set DACs to 0..5V */
-		outw(0, dev->iobase + PCI171x_DA1);	/*  set DA outputs to 0V */
+		/* set DACs to 0..5V */
+		outb(devpriv->da_ranges, dev->iobase + PCI171x_DAREF);
+		outw(0, dev->iobase + PCI171x_DA1); /* set DA outputs to 0V */
 		devpriv->ao_data[0] = 0x0000;
 		if (this_board->n_aochan > 1) {
 			outw(0, dev->iobase + PCI171x_DA2);
@@ -1077,10 +1080,11 @@
 static int pci1720_reset(struct comedi_device *dev)
 {
 	struct pci1710_private *devpriv = dev->private;
-
-	outb(Syncont_SC0, dev->iobase + PCI1720_SYNCONT);	/*  set synchronous output mode */
+	/* set synchronous output mode */
+	outb(Syncont_SC0, dev->iobase + PCI1720_SYNCONT);
 	devpriv->da_ranges = 0xAA;
-	outb(devpriv->da_ranges, dev->iobase + PCI1720_RANGE);	/*  set all ranges to +/-5V */
+	/* set all ranges to +/-5V */
+	outb(devpriv->da_ranges, dev->iobase + PCI1720_RANGE);
 	outw(0x0800, dev->iobase + PCI1720_DA0);	/*  set outputs to 0V */
 	outw(0x0800, dev->iobase + PCI1720_DA1);
 	outw(0x0800, dev->iobase + PCI1720_DA2);
diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c
index 07b107d..1881df4 100644
--- a/drivers/staging/comedi/drivers/adv_pci1723.c
+++ b/drivers/staging/comedi/drivers/adv_pci1723.c
@@ -161,11 +161,10 @@
 				  struct comedi_insn *insn, unsigned int *data)
 {
 	struct pci1723_private *devpriv = dev->private;
-	int n, chan;
-	chan = CR_CHAN(insn->chanspec);
+	unsigned int chan = CR_CHAN(insn->chanspec);
+	int n;
 
 	for (n = 0; n < insn->n; n++) {
-
 		devpriv->ao_data[chan] = data[n];
 		outw(data[n], dev->iobase + PCI1723_DA(chan));
 	}
diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c
index af670ac..bc3c349 100644
--- a/drivers/staging/comedi/drivers/adv_pci1724.c
+++ b/drivers/staging/comedi/drivers/adv_pci1724.c
@@ -143,7 +143,8 @@
 		udelay(1);
 	}
 	if (i == timeout) {
-		comedi_error(dev, "Timed out waiting for dac to become idle.");
+		dev_err(dev->class_dev,
+			"Timed out waiting for dac to become idle\n");
 		return -EIO;
 	}
 	return 0;
@@ -195,8 +196,8 @@
 	int i;
 
 	if (devpriv->ao_value[channel] < 0) {
-		comedi_error(dev,
-			     "Cannot read back channels which have not yet been written to.");
+		dev_err(dev->class_dev,
+			"Cannot read back channels which have not yet been written to\n");
 		return -EIO;
 	}
 	for (i = 0; i < insn->n; i++)
@@ -236,8 +237,8 @@
 	int i;
 
 	if (devpriv->offset_value[channel] < 0) {
-		comedi_error(dev,
-			     "Cannot read back channels which have not yet been written to.");
+		dev_err(dev->class_dev,
+			"Cannot read back channels which have not yet been written to\n");
 		return -EIO;
 	}
 	for (i = 0; i < insn->n; i++)
@@ -277,8 +278,8 @@
 	int i;
 
 	if (devpriv->gain_value[channel] < 0) {
-		comedi_error(dev,
-			     "Cannot read back channels which have not yet been written to.");
+		dev_err(dev->class_dev,
+			"Cannot read back channels which have not yet been written to\n");
 		return -EIO;
 	}
 	for (i = 0; i < insn->n; i++)
diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c
index 2d966a8..b8c7d914 100644
--- a/drivers/staging/comedi/drivers/adv_pci_dio.c
+++ b/drivers/staging/comedi/drivers/adv_pci_dio.c
@@ -592,7 +592,7 @@
 			return 0;
 	}
 
-	comedi_error(dev, "PCI-1760 mailbox request timeout!");
+	dev_err(dev->class_dev, "PCI-1760 mailbox request timeout!\n");
 	return -ETIME;
 }
 
@@ -610,12 +610,13 @@
 			      unsigned char *omb, unsigned char *imb)
 {
 	if (omb[2] == CMD_ClearIMB2) {
-		comedi_error(dev,
-			     "bug! this function should not be used for CMD_ClearIMB2 command");
+		dev_err(dev->class_dev,
+			"bug! this function should not be used for CMD_ClearIMB2 command\n");
 		return -EINVAL;
 	}
 	if (inb(dev->iobase + IMB2) == omb[2]) {
 		int retval;
+
 		retval = pci1760_clear_imb2(dev);
 		if (retval < 0)
 			return retval;
@@ -826,7 +827,7 @@
 		outb(0, dev->iobase + PCI1730_DO + 1);
 		outb(0, dev->iobase + PCI1730_IDO);
 		outb(0, dev->iobase + PCI1730_IDO + 1);
-		/* NO break there! */
+		/* fallthrough */
 	case TYPE_PCI1733:
 		/* disable interrupts */
 		outb(0, dev->iobase + PCI1730_3_INT_EN);
@@ -886,7 +887,7 @@
 		outb(0x80, dev->iobase + PCI1753E_ICR1);
 		outb(0x80, dev->iobase + PCI1753E_ICR2);
 		outb(0x80, dev->iobase + PCI1753E_ICR3);
-		/* NO break there! */
+		/* fallthrough */
 	case TYPE_PCI1753:
 		outb(0x88, dev->iobase + PCI1753_ICR0); /* disable & clear
 							 * interrupts */
diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c
index 781104a..7b5ed43 100644
--- a/drivers/staging/comedi/drivers/aio_iiro_16.c
+++ b/drivers/staging/comedi/drivers/aio_iiro_16.c
@@ -33,7 +33,6 @@
 #include <linux/module.h>
 #include "../comedidev.h"
 
-#define AIO_IIRO_16_SIZE	0x08
 #define AIO_IIRO_16_RELAY_0_7	0x00
 #define AIO_IIRO_16_INPUT_0_7	0x01
 #define AIO_IIRO_16_IRQ		0x02
@@ -74,7 +73,7 @@
 	struct comedi_subdevice *s;
 	int ret;
 
-	ret = comedi_request_region(dev, it->options[0], AIO_IIRO_16_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x8);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/amcc_s5933.h b/drivers/staging/comedi/drivers/amcc_s5933.h
index 2ba7364..cf6a497 100644
--- a/drivers/staging/comedi/drivers/amcc_s5933.h
+++ b/drivers/staging/comedi/drivers/amcc_s5933.h
@@ -41,7 +41,7 @@
 #define  AMCC_OP_REG_MCSR_NVCMD  (AMCC_OP_REG_MCSR + 3)	/* Command in byte 3 */
 
 #define AMCC_FIFO_DEPTH_DWORD	8
-#define AMCC_FIFO_DEPTH_BYTES	(8 * sizeof (u32))
+#define AMCC_FIFO_DEPTH_BYTES	(8 * sizeof(u32))
 
 /****************************************************************************/
 /* AMCC - PCI Interrupt Control/Status Register                            */
@@ -52,8 +52,10 @@
 #define INTCSR_INBOX_BYTE(x)	(((x) & 0x3) << 8)
 #define INTCSR_INBOX_SELECT(x)	(((x) & 0x3) << 10)
 #define INTCSR_INBOX_FULL_INT	0x1000	/*  enable inbox full interrupt */
-#define INTCSR_INBOX_INTR_STATUS	0x20000	/*  read, or write clear inbox full interrupt */
-#define INTCSR_INTR_ASSERTED	0x800000	/*  read only, interrupt asserted */
+/* read, or write clear inbox full interrupt */
+#define INTCSR_INBOX_INTR_STATUS	0x20000
+/* read only, interrupt asserted */
+#define INTCSR_INTR_ASSERTED	0x800000
 
 /****************************************************************************/
 /* AMCC - PCI non-volatile ram command register (byte 3 of master control/status register) */
diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c
index 3edaa40..78700e8 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200_common.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c
@@ -156,8 +156,8 @@
 	offset <<= thisboard->mainshift;
 	if (devpriv->io.regtype == io_regtype)
 		return inb(devpriv->io.u.iobase + offset);
-	else
-		return readb(devpriv->io.u.membase + offset);
+
+	return readb(devpriv->io.u.membase + offset);
 }
 
 /*
@@ -188,8 +188,8 @@
 	offset <<= thisboard->mainshift;
 	if (devpriv->io.regtype == io_regtype)
 		return inl(devpriv->io.u.iobase + offset);
-	else
-		return readl(devpriv->io.u.membase + offset);
+
+	return readl(devpriv->io.u.membase + offset);
 }
 
 /*
@@ -327,7 +327,7 @@
 		/* Error!  Stop acquisition.  */
 		dio200_stop_intr(dev, s);
 		s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW;
-		comedi_error(dev, "buffer overflow");
+		dev_err(dev->class_dev, "buffer overflow\n");
 	}
 
 	/* Check for end of acquisition. */
diff --git a/drivers/staging/comedi/drivers/amplc_dio200_pci.c b/drivers/staging/comedi/drivers/amplc_dio200_pci.c
index e036738..3cec0e0 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200_pci.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200_pci.c
@@ -228,13 +228,6 @@
 
 #include "amplc_dio200.h"
 
-/* PCI IDs */
-#define PCI_DEVICE_ID_AMPLICON_PCI272 0x000a
-#define PCI_DEVICE_ID_AMPLICON_PCI215 0x000b
-#define PCI_DEVICE_ID_AMPLICON_PCIE236 0x0011
-#define PCI_DEVICE_ID_AMPLICON_PCIE215 0x0012
-#define PCI_DEVICE_ID_AMPLICON_PCIE296 0x0014
-
 /*
  * Board descriptions.
  */
@@ -440,22 +433,11 @@
 };
 
 static const struct pci_device_id dio200_pci_table[] = {
-	{
-		PCI_VDEVICE(AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI215),
-		pci215_model
-	}, {
-		PCI_VDEVICE(AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI272),
-		pci272_model
-	}, {
-		PCI_VDEVICE(AMPLICON, PCI_DEVICE_ID_AMPLICON_PCIE236),
-		pcie236_model
-	}, {
-		PCI_VDEVICE(AMPLICON, PCI_DEVICE_ID_AMPLICON_PCIE215),
-		pcie215_model
-	}, {
-		PCI_VDEVICE(AMPLICON, PCI_DEVICE_ID_AMPLICON_PCIE296),
-		pcie296_model
-	},
+	{ PCI_VDEVICE(AMPLICON, 0x000b), pci215_model },
+	{ PCI_VDEVICE(AMPLICON, 0x000a), pci272_model },
+	{ PCI_VDEVICE(AMPLICON, 0x0011), pcie236_model },
+	{ PCI_VDEVICE(AMPLICON, 0x0012), pcie215_model },
+	{ PCI_VDEVICE(AMPLICON, 0x0014), pcie296_model },
 	{0}
 };
 
diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c
index c9a96ad..243b0f4 100644
--- a/drivers/staging/comedi/drivers/amplc_pc236.c
+++ b/drivers/staging/comedi/drivers/amplc_pc236.c
@@ -57,8 +57,6 @@
 #include "8255.h"
 #include "plx9052.h"
 
-#define PC236_DRIVER_NAME	"amplc_pc236"
-
 #define DO_ISA	IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA)
 #define DO_PCI	IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
 
@@ -68,9 +66,6 @@
 
 /* PC36AT / PCI236 registers */
 
-#define PC236_IO_SIZE		4
-#define PC236_LCR_IO_SIZE	128
-
 /* Disable, and clear, interrupts */
 #define PCI236_INTR_DISABLE	(PLX9052_INTCSR_LI1POL |	\
 				 PLX9052_INTCSR_LI2POL |	\
@@ -114,7 +109,7 @@
 		.model = pci236_model,
 	},
 	{
-		.name = PC236_DRIVER_NAME,
+		.name = "amplc_pc236",
 		.devid = PCI_DEVICE_ID_INVALID,
 		.bustype = pci_bustype,
 		.model = anypci_model,	/* wildcard */
@@ -394,7 +389,7 @@
 	pc236_intr_disable(dev);
 	if (irq) {
 		if (request_irq(irq, pc236_interrupt, req_irq_flags,
-				PC236_DRIVER_NAME, dev) >= 0) {
+				dev->board_name, dev) >= 0) {
 			dev->irq = irq;
 			s->type = COMEDI_SUBD_DI;
 			s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
@@ -448,7 +443,7 @@
 
 	/* Process options according to bus type. */
 	if (is_isa_board(thisboard)) {
-		ret = comedi_request_region(dev, it->options[0], PC236_IO_SIZE);
+		ret = comedi_request_region(dev, it->options[0], 0x4);
 		if (ret)
 			return ret;
 
@@ -460,11 +455,10 @@
 		if (!pci_dev)
 			return -EIO;
 		return pc236_pci_common_attach(dev, pci_dev);
-	} else {
-		dev_err(dev->class_dev, PC236_DRIVER_NAME
-			": BUG! cannot determine board type!\n");
-		return -EINVAL;
 	}
+
+	dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
+	return -EINVAL;
 }
 
 /*
@@ -481,8 +475,7 @@
 	if (!DO_PCI)
 		return -EINVAL;
 
-	dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach pci %s\n",
-		 pci_name(pci_dev));
+	dev_info(dev->class_dev, "attach pci %s\n", pci_name(pci_dev));
 
 	devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
 	if (!devpriv)
@@ -515,6 +508,7 @@
 		comedi_legacy_detach(dev);
 	} else if (is_pci_board(thisboard)) {
 		struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
 		if (dev->irq)
 			free_irq(dev->irq, dev);
 		comedi_pci_disable(dev);
@@ -530,7 +524,7 @@
  * the device code.
  */
 static struct comedi_driver amplc_pc236_driver = {
-	.driver_name = PC236_DRIVER_NAME,
+	.driver_name = "amplc_pc236",
 	.module = THIS_MODULE,
 	.attach = pc236_attach,
 	.auto_attach = pc236_auto_attach,
@@ -556,7 +550,7 @@
 }
 
 static struct pci_driver amplc_pc236_pci_driver = {
-	.name = PC236_DRIVER_NAME,
+	.name = "amplc_pc236",
 	.id_table = pc236_pci_table,
 	.probe = &amplc_pc236_pci_probe,
 	.remove		= comedi_pci_auto_unconfig,
diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c
index 7c10d28..f8e551d 100644
--- a/drivers/staging/comedi/drivers/amplc_pc263.c
+++ b/drivers/staging/comedi/drivers/amplc_pc263.c
@@ -36,10 +36,7 @@
 #include <linux/module.h>
 #include "../comedidev.h"
 
-#define PC263_DRIVER_NAME	"amplc_pc263"
-
 /* PC263 registers */
-#define PC263_IO_SIZE	2
 
 /*
  * Board descriptions for Amplicon PC263.
@@ -75,7 +72,7 @@
 	struct comedi_subdevice *s;
 	int ret;
 
-	ret = comedi_request_region(dev, it->options[0], PC263_IO_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x2);
 	if (ret)
 		return ret;
 
@@ -98,7 +95,7 @@
 }
 
 static struct comedi_driver amplc_pc263_driver = {
-	.driver_name = PC263_DRIVER_NAME,
+	.driver_name = "amplc_pc263",
 	.module = THIS_MODULE,
 	.attach = pc263_attach,
 	.detach = comedi_legacy_detach,
diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c
index 339c47c..45aba1f 100644
--- a/drivers/staging/comedi/drivers/amplc_pci224.c
+++ b/drivers/staging/comedi/drivers/amplc_pci224.c
@@ -108,8 +108,6 @@
 #include "comedi_fc.h"
 #include "8253.h"
 
-#define DRIVER_NAME	"amplc_pci224"
-
 /*
  * PCI IDs.
  */
@@ -120,7 +118,6 @@
 /*
  * PCI224/234 i/o space 1 (PCIBAR2) registers.
  */
-#define PCI224_IO1_SIZE	0x20	/* Size of i/o space 1 (8-bit registers) */
 #define PCI224_Z2_CT0	0x14	/* 82C54 counter/timer 0 */
 #define PCI224_Z2_CT1	0x15	/* 82C54 counter/timer 1 */
 #define PCI224_Z2_CT2	0x16	/* 82C54 counter/timer 2 */
@@ -133,7 +130,6 @@
 /*
  * PCI224/234 i/o space 2 (PCIBAR3) 16-bit registers.
  */
-#define PCI224_IO2_SIZE	0x10	/* Size of i/o space 2 (16-bit registers). */
 #define PCI224_DACDATA	0x00	/* (w-o) DAC FIFO data. */
 #define PCI224_SOFTTRIG	0x00	/* (r-o) DAC software scan trigger. */
 #define PCI224_DACCON	0x02	/* (r/w) DAC status/configuration. */
@@ -354,7 +350,7 @@
 	 .ao_bits = 16,
 	 },
 	{
-	 .name = DRIVER_NAME,
+	 .name = "amplc_pci224",
 	 .devid = PCI_DEVICE_ID_INVALID,
 	 .model = any_model,	/* wildcard */
 	 },
@@ -1206,8 +1202,8 @@
 		if (options) {
 			for (n = 2; n < 3 + s->n_chan; n++) {
 				if (options[n] < 0 || options[n] > 1) {
-					dev_warn(dev->class_dev, DRIVER_NAME
-						 ": warning! bad options[%u]=%d\n",
+					dev_warn(dev->class_dev,
+						 "warning! bad options[%u]=%d\n",
 						 n, options[n]);
 				}
 			}
@@ -1237,8 +1233,8 @@
 			devpriv->hwrange = hwrange_pci224_external;
 		} else {
 			if (options && options[2] != 0) {
-				dev_warn(dev->class_dev, DRIVER_NAME
-					 ": warning! bad options[2]=%d\n",
+				dev_warn(dev->class_dev,
+					 "warning! bad options[2]=%d\n",
 					 options[2]);
 			}
 			s->range_table = &range_pci224_internal;
@@ -1250,14 +1246,13 @@
 
 	if (irq) {
 		ret = request_irq(irq, pci224_interrupt, IRQF_SHARED,
-				  DRIVER_NAME, dev);
+				  dev->board_name, dev);
 		if (ret < 0) {
 			dev_err(dev->class_dev,
 				"error! unable to allocate irq %u\n", irq);
 			return ret;
-		} else {
-			dev->irq = irq;
 		}
+		dev->irq = irq;
 	}
 
 	return 0;
@@ -1268,7 +1263,7 @@
 	struct pci224_private *devpriv;
 	struct pci_dev *pci_dev;
 
-	dev_info(dev->class_dev, DRIVER_NAME ": attach\n");
+	dev_info(dev->class_dev, "attach\n");
 
 	devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
 	if (!devpriv)
@@ -1287,8 +1282,7 @@
 	struct pci_dev *pci_dev = comedi_to_pci_dev(dev);
 	struct pci224_private *devpriv;
 
-	dev_info(dev->class_dev, DRIVER_NAME ": attach pci %s\n",
-		 pci_name(pci_dev));
+	dev_info(dev->class_dev, "attach pci %s\n", pci_name(pci_dev));
 
 	devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
 	if (!devpriv)
@@ -1297,7 +1291,7 @@
 	dev->board_ptr = pci224_find_pci_board(pci_dev);
 	if (dev->board_ptr == NULL) {
 		dev_err(dev->class_dev,
-			DRIVER_NAME ": BUG! cannot determine board type!\n");
+			"BUG! cannot determine board type!\n");
 		return -EINVAL;
 	}
 	/*
diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c
index 3895bc7..a61d990 100644
--- a/drivers/staging/comedi/drivers/amplc_pci230.c
+++ b/drivers/staging/comedi/drivers/amplc_pci230.c
@@ -200,9 +200,6 @@
 #define PCI_DEVICE_ID_PCI260 0x0006
 #define PCI_DEVICE_ID_INVALID 0xffff
 
-#define PCI230_IO1_SIZE 32	/* Size of I/O space 1 */
-#define PCI230_IO2_SIZE 16	/* Size of I/O space 2 */
-
 /* PCI230 i/o space 1 registers. */
 #define PCI230_PPI_X_BASE	0x00	/* User PPI (82C55) base */
 #define PCI230_PPI_X_A		0x00	/* User PPI (82C55) port A */
@@ -712,15 +709,14 @@
 }
 
 static unsigned int divide_ns(uint64_t ns, unsigned int timebase,
-			      unsigned int round_mode)
+			      unsigned int flags)
 {
 	uint64_t div;
 	unsigned int rem;
 
 	div = ns;
 	rem = do_div(div, timebase);
-	round_mode &= TRIG_ROUND_MASK;
-	switch (round_mode) {
+	switch (flags & TRIG_ROUND_MASK) {
 	default:
 	case TRIG_ROUND_NEAREST:
 		div += (rem + (timebase / 2)) / timebase;
@@ -737,12 +733,12 @@
 /* Given desired period in ns, returns the required internal clock source
  * and gets the initial count. */
 static unsigned int pci230_choose_clk_count(uint64_t ns, unsigned int *count,
-					    unsigned int round_mode)
+					    unsigned int flags)
 {
 	unsigned int clk_src, cnt;
 
 	for (clk_src = CLK_10MHZ;; clk_src++) {
-		cnt = divide_ns(ns, pci230_timebase[clk_src], round_mode);
+		cnt = divide_ns(ns, pci230_timebase[clk_src], flags);
 		if ((cnt <= 65536) || (clk_src == CLK_1KHZ))
 			break;
 
@@ -751,19 +747,18 @@
 	return clk_src;
 }
 
-static void pci230_ns_to_single_timer(unsigned int *ns, unsigned int round)
+static void pci230_ns_to_single_timer(unsigned int *ns, unsigned int flags)
 {
 	unsigned int count;
 	unsigned int clk_src;
 
-	clk_src = pci230_choose_clk_count(*ns, &count, round);
+	clk_src = pci230_choose_clk_count(*ns, &count, flags);
 	*ns = count * pci230_timebase[clk_src];
-	return;
 }
 
 static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct,
 				    unsigned int mode, uint64_t ns,
-				    unsigned int round)
+				    unsigned int flags)
 {
 	struct pci230_private *devpriv = dev->private;
 	unsigned int clk_src;
@@ -772,7 +767,7 @@
 	/* Set mode. */
 	i8254_set_mode(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct, mode);
 	/* Determine clock source and count. */
-	clk_src = pci230_choose_clk_count(ns, &count, round);
+	clk_src = pci230_choose_clk_count(ns, &count, flags);
 	/* Program clock source. */
 	outb(CLK_CONFIG(ct, clk_src), devpriv->iobase1 + PCI230_ZCLK_SCE);
 	/* Set initial count. */
@@ -1080,8 +1075,7 @@
 
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		tmp = cmd->scan_begin_arg;
-		pci230_ns_to_single_timer(&cmd->scan_begin_arg,
-					  cmd->flags & TRIG_ROUND_MASK);
+		pci230_ns_to_single_timer(&cmd->scan_begin_arg, cmd->flags);
 		if (tmp != cmd->scan_begin_arg)
 			err++;
 	}
@@ -1168,7 +1162,7 @@
 		if (ret == 0) {
 			s->async->events |= COMEDI_CB_OVERFLOW;
 			pci230_ao_stop(dev, s);
-			comedi_error(dev, "AO buffer underrun");
+			dev_err(dev->class_dev, "AO buffer underrun\n");
 			return;
 		}
 		/* Write value to DAC. */
@@ -1216,7 +1210,7 @@
 	if (events == 0) {
 		/* Check for FIFO underrun. */
 		if ((dacstat & PCI230P2_DAC_FIFO_UNDERRUN_LATCHED) != 0) {
-			comedi_error(dev, "AO FIFO underrun");
+			dev_err(dev->class_dev, "AO FIFO underrun\n");
 			events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
 		}
 		/* Check for buffer underrun if FIFO less than half full
@@ -1224,7 +1218,7 @@
 		 * interrupts). */
 		if ((num_scans == 0)
 		    && ((dacstat & PCI230P2_DAC_FIFO_HALF) == 0)) {
-			comedi_error(dev, "AO buffer underrun");
+			dev_err(dev->class_dev, "AO buffer underrun\n");
 			events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
 		}
 	}
@@ -1271,7 +1265,7 @@
 		/* Check if FIFO underrun occurred while writing to FIFO. */
 		dacstat = inw(dev->iobase + PCI230_DACCON);
 		if ((dacstat & PCI230P2_DAC_FIFO_UNDERRUN_LATCHED) != 0) {
-			comedi_error(dev, "AO FIFO underrun");
+			dev_err(dev->class_dev, "AO FIFO underrun\n");
 			events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
 		}
 	}
@@ -1493,7 +1487,7 @@
 		     devpriv->iobase1 + PCI230_ZGAT_SCE);
 		pci230_ct_setup_ns_mode(dev, 1, I8254_MODE3,
 					cmd->scan_begin_arg,
-					cmd->flags & TRIG_ROUND_MASK);
+					cmd->flags);
 	}
 
 	/* N.B. cmd->start_src == TRIG_INT */
@@ -1800,8 +1794,7 @@
 
 	if (cmd->convert_src == TRIG_TIMER) {
 		tmp = cmd->convert_arg;
-		pci230_ns_to_single_timer(&cmd->convert_arg,
-					  cmd->flags & TRIG_ROUND_MASK);
+		pci230_ns_to_single_timer(&cmd->convert_arg, cmd->flags);
 		if (tmp != cmd->convert_arg)
 			err++;
 	}
@@ -1809,8 +1802,7 @@
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		/* N.B. cmd->convert_arg is also TRIG_TIMER */
 		tmp = cmd->scan_begin_arg;
-		pci230_ns_to_single_timer(&cmd->scan_begin_arg,
-					  cmd->flags & TRIG_ROUND_MASK);
+		pci230_ns_to_single_timer(&cmd->scan_begin_arg, cmd->flags);
 		if (!pci230_ai_check_scan_period(cmd)) {
 			/* Was below minimum required.  Round up. */
 			pci230_ns_to_single_timer(&cmd->scan_begin_arg,
@@ -2182,7 +2174,7 @@
 			if ((status_fifo & PCI230_ADC_FIFO_FULL_LATCHED) != 0) {
 				/* Report error otherwise FIFO overruns will go
 				 * unnoticed by the caller. */
-				comedi_error(dev, "AI FIFO overrun");
+				dev_err(dev->class_dev, "AI FIFO overrun\n");
 				events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
 				break;
 			} else if ((status_fifo & PCI230_ADC_FIFO_EMPTY) != 0) {
@@ -2209,7 +2201,7 @@
 		/* Read sample and store in Comedi's circular buffer. */
 		if (comedi_buf_put(s, pci230_ai_read(dev)) == 0) {
 			events |= COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW;
-			comedi_error(dev, "AI buffer overflow");
+			dev_err(dev->class_dev, "AI buffer overflow\n");
 			break;
 		}
 		fifoamount--;
@@ -2381,7 +2373,7 @@
 		outb(zgat, devpriv->iobase1 + PCI230_ZGAT_SCE);
 		/* Set counter/timer 2 to the specified conversion period. */
 		pci230_ct_setup_ns_mode(dev, 2, I8254_MODE3, cmd->convert_arg,
-					cmd->flags & TRIG_ROUND_MASK);
+					cmd->flags);
 		if (cmd->scan_begin_src != TRIG_FOLLOW) {
 			/*
 			 * Set up monostable on CT0 output for scan timing.  A
@@ -2412,9 +2404,7 @@
 				outb(zgat, devpriv->iobase1 + PCI230_ZGAT_SCE);
 				pci230_ct_setup_ns_mode(dev, 1, I8254_MODE3,
 							cmd->scan_begin_arg,
-							cmd->
-							flags &
-							TRIG_ROUND_MASK);
+							cmd->flags);
 			}
 		}
 	}
diff --git a/drivers/staging/comedi/drivers/amplc_pci263.c b/drivers/staging/comedi/drivers/amplc_pci263.c
index 93ed03e..748a6b1 100644
--- a/drivers/staging/comedi/drivers/amplc_pci263.c
+++ b/drivers/staging/comedi/drivers/amplc_pci263.c
@@ -37,11 +37,6 @@
 
 #include "../comedidev.h"
 
-#define PCI263_DRIVER_NAME	"amplc_pci263"
-
-/* PCI263 PCI configuration register information */
-#define PCI_DEVICE_ID_AMPLICON_PCI263 0x000c
-
 static int pci263_do_insn_bits(struct comedi_device *dev,
 			       struct comedi_subdevice *s,
 			       struct comedi_insn *insn,
@@ -88,14 +83,14 @@
 }
 
 static struct comedi_driver amplc_pci263_driver = {
-	.driver_name	= PCI263_DRIVER_NAME,
+	.driver_name	= "amplc_pci263",
 	.module		= THIS_MODULE,
 	.auto_attach	= pci263_auto_attach,
 	.detach		= comedi_pci_disable,
 };
 
 static const struct pci_device_id pci263_pci_table[] = {
-	{ PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, PCI_DEVICE_ID_AMPLICON_PCI263) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, 0x000c) },
 	{0}
 };
 MODULE_DEVICE_TABLE(pci, pci263_pci_table);
@@ -108,7 +103,7 @@
 }
 
 static struct pci_driver amplc_pci263_pci_driver = {
-	.name		= PCI263_DRIVER_NAME,
+	.name		= "amplc_pci263",
 	.id_table	= pci263_pci_table,
 	.probe		= &amplc_pci263_pci_probe,
 	.remove		= comedi_pci_auto_unconfig,
diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c
index eb1b92d..853733e 100644
--- a/drivers/staging/comedi/drivers/cb_das16_cs.c
+++ b/drivers/staging/comedi/drivers/cb_das16_cs.c
@@ -46,8 +46,6 @@
 #include "comedi_fc.h"
 #include "8253.h"
 
-#define DAS16CS_SIZE			18
-
 #define DAS16CS_ADC_DATA		0
 #define DAS16CS_DIO_MUX			2
 #define DAS16CS_MISC1			4
diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c
index 7377da1..4a7bd4e 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas.c
@@ -461,7 +461,6 @@
 		break;
 	default:
 		return -EINVAL;
-		break;
 	}
 	return insn->n;
 }
@@ -622,7 +621,7 @@
 	static const int caldac_8800_udelay = 1;
 
 	if (address >= num_caldac_channels) {
-		comedi_error(dev, "illegal caldac channel");
+		dev_err(dev->class_dev, "illegal caldac channel\n");
 		return -1;
 	}
 
@@ -774,9 +773,8 @@
 		trimpot_8402_write(dev, channel, value);
 		break;
 	default:
-		comedi_error(dev, "driver bug?");
+		dev_err(dev->class_dev, "driver bug?\n");
 		return -1;
-		break;
 	}
 
 	return 1;
@@ -1251,9 +1249,8 @@
 		break;
 	default:
 		spin_unlock_irqrestore(&dev->spinlock, flags);
-		comedi_error(dev, "error setting dac pacer source");
+		dev_err(dev->class_dev, "error setting dac pacer source\n");
 		return -1;
-		break;
 	}
 	spin_unlock_irqrestore(&dev->spinlock, flags);
 
@@ -1303,7 +1300,7 @@
 			if (cmd->stop_src == TRIG_NONE ||
 			    (cmd->stop_src == TRIG_COUNT
 			     && devpriv->ao_count)) {
-				comedi_error(dev, "dac fifo underflow");
+				dev_err(dev->class_dev, "dac fifo underflow\n");
 				async->events |= COMEDI_CB_ERROR;
 			}
 			async->events |= COMEDI_CB_EOA;
@@ -1414,8 +1411,8 @@
 		     devpriv->control_status + INT_ADCFIFO);
 		spin_unlock_irqrestore(&dev->spinlock, flags);
 	} else if (status & EOAI) {
-		comedi_error(dev,
-			     "bug! encountered end of acquisition interrupt?");
+		dev_err(dev->class_dev,
+			"bug! encountered end of acquisition interrupt?\n");
 		/*  clear EOA interrupt latch */
 		spin_lock_irqsave(&dev->spinlock, flags);
 		outw(devpriv->adc_fifo_bits | EOAI,
@@ -1424,7 +1421,7 @@
 	}
 	/* check for fifo overflow */
 	if (status & LADFUL) {
-		comedi_error(dev, "fifo overflow");
+		dev_err(dev->class_dev, "fifo overflow\n");
 		/*  clear overflow interrupt latch */
 		spin_lock_irqsave(&dev->spinlock, flags);
 		outw(devpriv->adc_fifo_bits | LADFUL,
@@ -1474,11 +1471,12 @@
 	outl(INTCSR_INBOX_INTR_STATUS,
 	     devpriv->s5933_config + AMCC_OP_REG_INTCSR);
 
-	if (request_irq(pcidev->irq, cb_pcidas_interrupt,
-			IRQF_SHARED, dev->driver->driver_name, dev)) {
+	ret = request_irq(pcidev->irq, cb_pcidas_interrupt, IRQF_SHARED,
+			  dev->board_name, dev);
+	if (ret) {
 		dev_dbg(dev->class_dev, "unable to allocate irq %d\n",
 			pcidev->irq);
-		return -EINVAL;
+		return ret;
 	}
 	dev->irq = pcidev->irq;
 
diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index 035c3a1..4b332dd 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -80,8 +80,6 @@
 	make ao fifo size adjustable like ai fifo
 */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
@@ -636,8 +634,8 @@
 {
 	if (board->layout == LAYOUT_4020)
 		return MAX_AI_DMA_RING_COUNT;
-	else
-		return MIN_AI_DMA_RING_COUNT;
+
+	return MIN_AI_DMA_RING_COUNT;
 }
 
 static const int bytes_in_sample = 2;
@@ -1045,9 +1043,9 @@
 	if ((thisboard->layout == LAYOUT_64XX && !use_differential) ||
 	    (thisboard->layout == LAYOUT_60XX && use_differential))
 		return ADC_SE_DIFF_BIT;
-	else
-		return 0;
-};
+
+	return 0;
+}
 
 struct ext_clock_info {
 	/*  master clock divisor to use for scans with external master clock */
@@ -1069,7 +1067,7 @@
 	uint32_t local0_iobase;
 	uint32_t local1_iobase;
 	/*  number of analog input samples remaining */
-	volatile unsigned int ai_count;
+	unsigned int ai_count;
 	/*  dma buffers for analog input */
 	uint16_t *ai_buffer[MAX_AI_DMA_RING_COUNT];
 	/*  physical addresses of ai dma buffers */
@@ -1081,7 +1079,7 @@
 	dma_addr_t ai_dma_desc_bus_addr;
 	/*  index of the ai dma descriptor/buffer
 	 *  that is currently being used */
-	volatile unsigned int ai_dma_index;
+	unsigned int ai_dma_index;
 	/*  dma buffers for analog output */
 	uint16_t *ao_buffer[AO_DMA_RING_COUNT];
 	/*  physical addresses of ao dma buffers */
@@ -1089,35 +1087,35 @@
 	struct plx_dma_desc *ao_dma_desc;
 	dma_addr_t ao_dma_desc_bus_addr;
 	/*  keeps track of buffer where the next ao sample should go */
-	volatile unsigned int ao_dma_index;
+	unsigned int ao_dma_index;
 	/*  number of analog output samples remaining */
-	volatile unsigned long ao_count;
+	unsigned long ao_count;
 	/*  remember what the analog outputs are set to, to allow readback */
-	volatile unsigned int ao_value[2];
+	unsigned int ao_value[2];
 	unsigned int hw_revision;	/*  stc chip hardware revision number */
 	/*  last bits sent to INTR_ENABLE_REG register */
-	volatile unsigned int intr_enable_bits;
+	unsigned int intr_enable_bits;
 	/*  last bits sent to ADC_CONTROL1_REG register */
-	volatile uint16_t adc_control1_bits;
+	uint16_t adc_control1_bits;
 	/*  last bits sent to FIFO_SIZE_REG register */
-	volatile uint16_t fifo_size_bits;
+	uint16_t fifo_size_bits;
 	/*  last bits sent to HW_CONFIG_REG register */
-	volatile uint16_t hw_config_bits;
-	volatile uint16_t dac_control1_bits;
+	uint16_t hw_config_bits;
+	uint16_t dac_control1_bits;
 	/*  last bits written to plx9080 control register */
-	volatile uint32_t plx_control_bits;
+	uint32_t plx_control_bits;
 	/*  last bits written to plx interrupt control and status register */
-	volatile uint32_t plx_intcsr_bits;
+	uint32_t plx_intcsr_bits;
 	/*  index of calibration source readable through ai ch0 */
-	volatile int calibration_source;
+	int calibration_source;
 	/*  bits written to i2c calibration/range register */
-	volatile uint8_t i2c_cal_range_bits;
+	uint8_t i2c_cal_range_bits;
 	/*  configure digital triggers to trigger on falling edge */
-	volatile unsigned int ext_trig_falling;
+	unsigned int ext_trig_falling;
 	/*  states of various devices stored to enable read-back */
 	unsigned int ad8402_state[2];
 	unsigned int caldac_state[8];
-	volatile short ai_cmd_running;
+	short ai_cmd_running;
 	unsigned int ai_fifo_segment_length;
 	struct ext_clock_info ext_clock;
 	unsigned short ao_bounce_buffer[DAC_FIFO_SIZE];
@@ -1160,7 +1158,7 @@
 		bits = 0x700;
 		break;
 	default:
-		comedi_error(dev, "bug! in ai_range_bits_6xxx");
+		dev_err(dev->class_dev, "bug! in %s\n", __func__);
 		break;
 	}
 	if (range->min == 0)
@@ -1180,16 +1178,16 @@
 }
 
 static void set_dac_range_bits(struct comedi_device *dev,
-			       volatile uint16_t *bits, unsigned int channel,
+			       uint16_t *bits, unsigned int channel,
 			       unsigned int range)
 {
 	const struct pcidas64_board *thisboard = comedi_board(dev);
 	unsigned int code = thisboard->ao_range_code[range];
 
 	if (channel > 1)
-		comedi_error(dev, "bug! bad channel?");
+		dev_err(dev->class_dev, "bug! bad channel?\n");
 	if (code & ~0x3)
-		comedi_error(dev, "bug! bad range code?");
+		dev_err(dev->class_dev, "bug! bad range code?\n");
 
 	*bits &= ~(0x3 << (2 * channel));
 	*bits |= code << (2 * channel);
@@ -1531,10 +1529,10 @@
 
 static inline void warn_external_queue(struct comedi_device *dev)
 {
-	comedi_error(dev,
-		     "AO command and AI external channel queue cannot be used simultaneously.");
-	comedi_error(dev,
-		     "Use internal AI channel queue (channels must be consecutive and use same range/aref)");
+	dev_err(dev->class_dev,
+		"AO command and AI external channel queue cannot be used simultaneously\n");
+	dev_err(dev->class_dev,
+		"Use internal AI channel queue (channels must be consecutive and use same range/aref)\n");
 }
 
 /* Their i2c requires a huge delay on setting clock or data high for some reason */
@@ -1648,7 +1646,8 @@
 
 	/*  get acknowledge */
 	if (i2c_read_ack(dev) != 0) {
-		comedi_error(dev, "i2c write failed: no acknowledge");
+		dev_err(dev->class_dev, "%s failed: no acknowledge\n",
+			__func__);
 		i2c_stop(dev);
 		return;
 	}
@@ -1656,7 +1655,8 @@
 	for (i = 0; i < length; i++) {
 		i2c_write_byte(dev, data[i]);
 		if (i2c_read_ack(dev) != 0) {
-			comedi_error(dev, "i2c write failed: no acknowledge");
+			dev_err(dev->class_dev, "%s failed: no acknowledge\n",
+				__func__);
 			i2c_stop(dev);
 			return;
 		}
@@ -1769,6 +1769,7 @@
 		 *  as it is very slow */
 		if (old_cal_range_bits != devpriv->i2c_cal_range_bits) {
 			uint8_t i2c_data = devpriv->i2c_cal_range_bits;
+
 			i2c_write(dev, RANGE_CAL_I2C_ADDR, &i2c_data,
 				  sizeof(i2c_data));
 		}
@@ -1874,7 +1875,6 @@
 		break;
 	default:
 		return -EINVAL;
-		break;
 	}
 
 	data[4] = divisor;
@@ -1890,10 +1890,8 @@
 	switch (thisboard->layout) {
 	case LAYOUT_4020:
 		return ai_config_master_clock_4020(dev, data);
-		break;
 	default:
 		return -EINVAL;
-		break;
 	}
 
 	return -EINVAL;
@@ -1907,16 +1905,12 @@
 	switch (id) {
 	case INSN_CONFIG_ALT_SOURCE:
 		return ai_config_calibration_source(dev, data);
-		break;
 	case INSN_CONFIG_BLOCK_SIZE:
 		return ai_config_block_size(dev, data);
-		break;
 	case INSN_CONFIG_TIMER_1:
 		return ai_config_master_clock(dev, data);
-		break;
 	default:
 		return -EINVAL;
-		break;
 	}
 	return -EINVAL;
 }
@@ -1991,8 +1985,6 @@
 			scan_divisor = min_scan_divisor;
 		cmd->scan_begin_arg = scan_divisor * TIMER_BASE;
 	}
-
-	return;
 }
 
 static int cb_pcidas64_ai_check_chanlist(struct comedi_device *dev,
@@ -2162,8 +2154,8 @@
 
 	if (cmd->stop_src == TRIG_COUNT && cmd->stop_arg <= max_counter_value)
 		return 1;
-	else
-		return 0;
+
+	return 0;
 }
 
 static void setup_sample_counters(struct comedi_device *dev,
@@ -2224,7 +2216,6 @@
 		break;
 	default:
 		return 0;
-		break;
 	}
 	return count - 3;
 }
@@ -2243,7 +2234,7 @@
 		divisor = devpriv->ext_clock.divisor;
 		break;
 	default:		/*  should never happen */
-		comedi_error(dev, "bug! failed to set ai pacing!");
+		dev_err(dev->class_dev, "bug! failed to set ai pacing!\n");
 		divisor = 1000;
 		break;
 	}
@@ -2454,6 +2445,7 @@
 		 *  as it is very slow */
 		if (old_cal_range_bits != devpriv->i2c_cal_range_bits) {
 			uint8_t i2c_data = devpriv->i2c_cal_range_bits;
+
 			i2c_write(dev, RANGE_CAL_I2C_ADDR, &i2c_data,
 				  sizeof(i2c_data));
 		}
@@ -2775,7 +2767,7 @@
 
 	/*  check for fifo overrun */
 	if (status & ADC_OVERRUN_BIT) {
-		comedi_error(dev, "fifo overrun");
+		dev_err(dev->class_dev, "fifo overrun\n");
 		async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 	}
 	/*  spin lock makes sure no one else changes plx dma control reg */
@@ -3138,7 +3130,8 @@
 	first_channel = CR_CHAN(cmd->chanlist[0]);
 	last_channel = CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1]);
 	if (last_channel < first_channel)
-		comedi_error(dev, "bug! last ao channel < first ao channel");
+		dev_err(dev->class_dev,
+			"bug! last ao channel < first ao channel\n");
 
 	bits = (first_channel & 0x7) | (last_channel & 0x7) << 3;
 
@@ -3161,7 +3154,7 @@
 
 	divisor = get_ao_divisor(cmd->scan_begin_arg, cmd->flags);
 	if (divisor > max_counter_value) {
-		comedi_error(dev, "bug! ao divisor too big");
+		dev_err(dev->class_dev, "bug! ao divisor too big\n");
 		divisor = max_counter_value;
 	}
 	writew(divisor & 0xffff,
@@ -3381,23 +3374,23 @@
 static int dio_callback(int dir, int port, int data, unsigned long arg)
 {
 	void __iomem *iobase = (void __iomem *)arg;
+
 	if (dir) {
 		writeb(data, iobase + port);
 		return 0;
-	} else {
-		return readb(iobase + port);
 	}
+	return readb(iobase + port);
 }
 
 static int dio_callback_4020(int dir, int port, int data, unsigned long arg)
 {
 	void __iomem *iobase = (void __iomem *)arg;
+
 	if (dir) {
 		writew(data, iobase + 2 * port);
 		return 0;
-	} else {
-		return readw(iobase + 2 * port);
 	}
+	return readw(iobase + 2 * port);
 }
 
 static int di_rbits(struct comedi_device *dev, struct comedi_subdevice *s,
@@ -3496,7 +3489,7 @@
 	static const int caldac_8800_udelay = 1;
 
 	if (address >= num_caldac_channels) {
-		comedi_error(dev, "illegal caldac channel");
+		dev_err(dev->class_dev, "illegal caldac channel\n");
 		return -1;
 	}
 	for (bit = 1 << (bitstream_length - 1); bit; bit >>= 1) {
@@ -3568,9 +3561,8 @@
 		serial_bytes[0] = GAIN_1_3;
 		break;
 	default:
-		comedi_error(dev, "invalid caldac channel\n");
+		dev_err(dev->class_dev, "invalid caldac channel\n");
 		return -1;
-		break;
 	}
 	serial_bytes[1] = NOT_CLEAR_REGISTERS | ((value >> 8) & 0xf);
 	serial_bytes[2] = value & 0xff;
@@ -3997,12 +3989,13 @@
 		devpriv->hw_revision);
 	init_plx9080(dev);
 	init_stc_registers(dev);
-	/*  get irq */
-	if (request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED,
-			"cb_pcidas64", dev)) {
+
+	retval = request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED,
+			     dev->board_name, dev);
+	if (retval) {
 		dev_dbg(dev->class_dev, "unable to allocate irq %u\n",
 			pcidev->irq);
-		return -EINVAL;
+		return retval;
 	}
 	dev->irq = pcidev->irq;
 	dev_dbg(dev->class_dev, "irq %u\n", dev->irq);
diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c
index 50e522e..ccb9c72 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdas.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdas.c
@@ -47,9 +47,6 @@
 
 /* Registers for the PCIM-DAS1602/16 */
 
-/* sizes of io regions (bytes) */
-#define BADR3_SIZE 16
-
 /* DAC Offsets */
 #define ADC_TRIG 0
 #define DAC0_OFFSET 2
diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c
index 67a09aa..845a679 100644
--- a/drivers/staging/comedi/drivers/comedi_test.c
+++ b/drivers/staging/comedi/drivers/comedi_test.c
@@ -146,10 +146,8 @@
 	switch (channel) {
 	case SAWTOOTH_CHAN:
 		return fake_sawtooth(dev, range, current_time);
-		break;
 	case SQUARE_CHAN:
 		return fake_squarewave(dev, range, current_time);
-		break;
 	default:
 		break;
 	}
@@ -305,8 +303,8 @@
 	struct comedi_cmd *cmd = &s->async->cmd;
 
 	if (cmd->flags & TRIG_RT) {
-		comedi_error(dev,
-			     "commands at RT priority not supported in this driver");
+		dev_err(dev->class_dev,
+			"commands at RT priority not supported in this driver\n");
 		return -1;
 	}
 
diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c
index 0a9c32e..f066fb0 100644
--- a/drivers/staging/comedi/drivers/contec_pci_dio.c
+++ b/drivers/staging/comedi/drivers/contec_pci_dio.c
@@ -30,8 +30,6 @@
 
 #include "../comedidev.h"
 
-#define PCI_DEVICE_ID_PIO1616L 0x8172
-
 /*
  * Register map
  */
@@ -110,7 +108,7 @@
 }
 
 static const struct pci_device_id contec_pci_dio_pci_table[] = {
-	{ PCI_DEVICE(PCI_VENDOR_ID_CONTEC, PCI_DEVICE_ID_PIO1616L) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_CONTEC, 0x8172) },
 	{ 0 }
 };
 MODULE_DEVICE_TABLE(pci, contec_pci_dio_pci_table);
diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c
index a8f6036..ceab88b 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -113,8 +113,8 @@
 
 #define DAQBOARD2000_FIRMWARE		"daqboard2000_firmware.bin"
 
-#define DAQBOARD2000_SUBSYSTEM_IDS2 	0x0002	/* Daqboard/2000 - 2 Dacs */
-#define DAQBOARD2000_SUBSYSTEM_IDS4 	0x0004	/* Daqboard/2000 - 4 Dacs */
+#define DAQBOARD2000_SUBSYSTEM_IDS2	0x0002	/* Daqboard/2000 - 2 Dacs */
+#define DAQBOARD2000_SUBSYSTEM_IDS4	0x0004	/* Daqboard/2000 - 4 Dacs */
 
 /* Initialization bits for the Serial EEPROM Control Register */
 #define DAQBOARD2000_SECRProgPinHi      0x8001767e
@@ -128,8 +128,8 @@
 #define DAQBOARD2000_EEPROM_PRESENT     0x10000000
 
 /* CPLD status bits */
-#define DAQBOARD2000_CPLD_INIT 		0x0002
-#define DAQBOARD2000_CPLD_DONE 		0x0004
+#define DAQBOARD2000_CPLD_INIT		0x0002
+#define DAQBOARD2000_CPLD_DONE		0x0004
 
 static const struct comedi_lrange range_daqboard2000_ai = {
 	13, {
@@ -673,9 +673,8 @@
 	if (dir) {
 		writew(data, mmio_base + port * 2);
 		return 0;
-	} else {
-		return readw(mmio_base + port * 2);
 	}
+	return readw(mmio_base + port * 2);
 }
 
 static const void *daqboard2000_find_boardinfo(struct comedi_device *dev,
diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c
index c5e352f..fcf916a 100644
--- a/drivers/staging/comedi/drivers/das08.c
+++ b/drivers/staging/comedi/drivers/das08.c
@@ -273,7 +273,7 @@
 			else
 				data[n] = (1 << 15) - (lsb | (msb & 0x7f) << 8);
 		} else {
-			comedi_error(dev, "bug! unknown ai encoding");
+			dev_err(dev->class_dev, "bug! unknown ai encoding\n");
 			return -1;
 		}
 	}
@@ -452,7 +452,6 @@
 		break;
 	default:
 		return -EINVAL;
-		break;
 	}
 	return 2;
 }
diff --git a/drivers/staging/comedi/drivers/das08_pci.c b/drivers/staging/comedi/drivers/das08_pci.c
index d94af09..4ce3eb0 100644
--- a/drivers/staging/comedi/drivers/das08_pci.c
+++ b/drivers/staging/comedi/drivers/das08_pci.c
@@ -38,8 +38,6 @@
 
 #include "das08.h"
 
-#define PCI_DEVICE_ID_PCIDAS08		0x0029
-
 static const struct das08_board_struct das08_pci_boards[] = {
 	{
 		.name		= "pci-das08",
@@ -90,7 +88,7 @@
 }
 
 static const struct pci_device_id das08_pci_table[] = {
-	{ PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_PCIDAS08) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0029) },
 	{ 0 }
 };
 MODULE_DEVICE_TABLE(pci, das08_pci_table);
diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c
index 2feecf1..057bc16 100644
--- a/drivers/staging/comedi/drivers/das16.c
+++ b/drivers/staging/comedi/drivers/das16.c
@@ -506,18 +506,18 @@
 static int disable_dma_on_even(struct comedi_device *dev)
 {
 	struct das16_private_struct *devpriv = dev->private;
-	int residue;
-	int i;
 	static const int disable_limit = 100;
 	static const int enable_timeout = 100;
+	int residue;
+	int new_residue;
+	int i;
+	int j;
 
 	disable_dma(devpriv->dma_chan);
 	residue = get_dma_residue(devpriv->dma_chan);
 	for (i = 0; i < disable_limit && (residue % 2); ++i) {
-		int j;
 		enable_dma(devpriv->dma_chan);
 		for (j = 0; j < enable_timeout; ++j) {
-			int new_residue;
 			udelay(2);
 			new_residue = get_dma_residue(devpriv->dma_chan);
 			if (new_residue != residue)
@@ -729,14 +729,14 @@
 }
 
 static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
-				    int rounding_flags)
+				    unsigned int flags)
 {
 	struct das16_private_struct *devpriv = dev->private;
 	unsigned long timer_base = dev->iobase + DAS16_TIMER_BASE_REG;
 
 	i8253_cascade_ns_to_timer(devpriv->clockbase,
 				  &devpriv->divisor1, &devpriv->divisor2,
-				  &ns, rounding_flags);
+				  &ns, flags);
 
 	i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY);
 	i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY);
@@ -782,9 +782,7 @@
 	}
 
 	/* set counter mode and counts */
-	cmd->convert_arg =
-	    das16_set_pacer(dev, cmd->convert_arg,
-			    cmd->flags & TRIG_ROUND_MASK);
+	cmd->convert_arg = das16_set_pacer(dev, cmd->convert_arg, cmd->flags);
 
 	/* enable counters */
 	byte = 0;
diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c
index c252ad2..5b6998b 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/staging/comedi/drivers/das16m1.c
@@ -60,7 +60,6 @@
 #include "8253.h"
 #include "comedi_fc.h"
 
-#define DAS16M1_SIZE 16
 #define DAS16M1_SIZE2 8
 
 #define FIFO_SIZE 1024		/*  1024 sample fifo */
@@ -126,7 +125,7 @@
 
 struct das16m1_private_struct {
 	unsigned int control_state;
-	volatile unsigned int adc_count;	/*  number of samples completed */
+	unsigned int adc_count;	/*  number of samples completed */
 	/* initial value in lower half of hardware conversion counter,
 	 * needed to keep track of whether new count has been loaded into
 	 * counter yet (loaded by first sample conversion) */
@@ -460,7 +459,7 @@
 	 * overrun interrupts, but we might as well try */
 	if (status & OVRUN) {
 		async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
-		comedi_error(dev, "fifo overflow");
+		dev_err(dev->class_dev, "fifo overflow\n");
 	}
 
 	cfc_handle_events(dev, s);
@@ -486,7 +485,7 @@
 	struct comedi_device *dev = d;
 
 	if (!dev->attached) {
-		comedi_error(dev, "premature interrupt");
+		dev_err(dev->class_dev, "premature interrupt\n");
 		return IRQ_HANDLED;
 	}
 	/*  prevent race with comedi_poll() */
@@ -495,7 +494,7 @@
 	status = inb(dev->iobase + DAS16M1_CS);
 
 	if ((status & (IRQDATA | OVRUN)) == 0) {
-		comedi_error(dev, "spurious interrupt");
+		dev_err(dev->class_dev, "spurious interrupt\n");
 		spin_unlock(&dev->spinlock);
 		return IRQ_NONE;
 	}
@@ -549,7 +548,7 @@
 	if (!devpriv)
 		return -ENOMEM;
 
-	ret = comedi_request_region(dev, it->options[0], DAS16M1_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x10);
 	if (ret)
 		return ret;
 	/* Request an additional region for the 8255 */
diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c
index b2f8391d..0cfca339 100644
--- a/drivers/staging/comedi/drivers/das1800.c
+++ b/drivers/staging/comedi/drivers/das1800.c
@@ -421,7 +421,7 @@
 };
 
 struct das1800_private {
-	volatile unsigned int count;	/* number of data points left to be taken */
+	unsigned int count;	/* number of data points left to be taken */
 	unsigned int divisor1;	/* value to load into board's counter 1 for timed conversions */
 	unsigned int divisor2;	/* value to load into board's counter 2 for timed conversions */
 	int irq_dma_bits;	/* bits for control register b */
@@ -430,7 +430,7 @@
 	int dma_bits;
 	unsigned int dma0;	/* dma channels used */
 	unsigned int dma1;
-	volatile unsigned int dma_current;	/* dma channel currently in use */
+	unsigned int dma_current;	/* dma channel currently in use */
 	uint16_t *ai_buf0;	/* pointers to dma buffers */
 	uint16_t *ai_buf1;
 	uint16_t *dma_current_buf;	/* pointer to dma buffer currently being used */
@@ -492,7 +492,6 @@
 				  numPoints * sizeof(devpriv->ai_buf0[0]));
 	if (cmd->stop_src == TRIG_COUNT)
 		devpriv->count -= numPoints;
-	return;
 }
 
 static void das1800_handle_fifo_not_empty(struct comedi_device *dev,
@@ -517,8 +516,6 @@
 		if (cmd->stop_src == TRIG_COUNT)
 			devpriv->count--;
 	}
-
-	return;
 }
 
 /* Utility function used by das1800_flush_dma() and das1800_handle_dma().
@@ -549,8 +546,6 @@
 	cfc_write_array_to_buffer(s, buffer, num_bytes);
 	if (cmd->stop_src == TRIG_COUNT)
 		devpriv->count -= num_samples;
-
-	return;
 }
 
 /* flushes remaining data from board when external trigger has stopped acquisition
@@ -583,8 +578,6 @@
 
 	/*  get any remaining samples in fifo */
 	das1800_handle_fifo_not_empty(dev, s);
-
-	return;
 }
 
 static void das1800_handle_dma(struct comedi_device *dev,
@@ -619,8 +612,6 @@
 			}
 		}
 	}
-
-	return;
 }
 
 static int das1800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
@@ -663,7 +654,7 @@
 	if (status & OVF) {
 		/*  clear OVF interrupt bit */
 		outb(CLEAR_INTR_MASK & ~OVF, dev->iobase + DAS1800_STATUS);
-		comedi_error(dev, "DAS1800 FIFO overflow");
+		dev_err(dev->class_dev, "FIFO overflow\n");
 		async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
 		cfc_handle_events(dev, s);
 		return;
@@ -705,7 +696,7 @@
 	unsigned int status;
 
 	if (!dev->attached) {
-		comedi_error(dev, "premature interrupt");
+		dev_err(dev->class_dev, "premature interrupt\n");
 		return IRQ_HANDLED;
 	}
 
@@ -1060,8 +1051,6 @@
 		enable_dma(devpriv->dma1);
 	}
 	release_dma_lock(lock_flags);
-
-	return;
 }
 
 /* programs channel/gain list into card */
@@ -1088,8 +1077,6 @@
 	}
 	outb(n - 1, dev->iobase + DAS1800_QRAM_ADDRESS);	/*finish write to QRAM */
 	spin_unlock_irqrestore(&dev->spinlock, irq_flags);
-
-	return;
 }
 
 /* analog input do_cmd */
@@ -1192,7 +1179,7 @@
 				break;
 		}
 		if (i == timeout) {
-			comedi_error(dev, "timeout");
+			dev_err(dev->class_dev, "timeout\n");
 			n = -ETIME;
 			goto exit;
 		}
@@ -1301,7 +1288,6 @@
 			dev_err(dev->class_dev,
 				"dma 5,6 / 6,7 / or 7,5\n");
 			return -EINVAL;
-			break;
 		}
 		if (request_dma(dma0, dev->driver->driver_name)) {
 			dev_err(dev->class_dev,
@@ -1343,84 +1329,60 @@
 
 static int das1800_probe(struct comedi_device *dev)
 {
+	const struct das1800_board *board = comedi_board(dev);
+	int index;
 	int id;
-	int board;
 
-	id = (inb(dev->iobase + DAS1800_DIGITAL) >> 4) & 0xf;	/* get id bits */
-	board = ((struct das1800_board *)dev->board_ptr) - das1800_boards;
+	/* calc the offset to the boardinfo that was found by the core */
+	index = board - das1800_boards;
 
+	/* verify that the board id matches the boardinfo */
+	id = (inb(dev->iobase + DAS1800_DIGITAL) >> 4) & 0xf;
 	switch (id) {
 	case 0x3:
-		if (board == das1801st_da || board == das1802st_da ||
-		    board == das1701st_da || board == das1702st_da) {
-			dev_dbg(dev->class_dev, "Board model: %s\n",
-				das1800_boards[board].name);
-			return board;
-		}
-		printk
-		    (" Board model (probed, not recommended): das-1800st-da series\n");
-		return das1801st;
+		if (index == das1801st_da || index == das1802st_da ||
+		    index == das1701st_da || index == das1702st_da)
+			return index;
+		index = das1801st;
 		break;
 	case 0x4:
-		if (board == das1802hr_da || board == das1702hr_da) {
-			dev_dbg(dev->class_dev, "Board model: %s\n",
-				das1800_boards[board].name);
-			return board;
-		}
-		printk
-		    (" Board model (probed, not recommended): das-1802hr-da\n");
-		return das1802hr;
+		if (index == das1802hr_da || index == das1702hr_da)
+			return index;
+		index = das1802hr;
 		break;
 	case 0x5:
-		if (board == das1801ao || board == das1802ao ||
-		    board == das1701ao || board == das1702ao) {
-			dev_dbg(dev->class_dev, "Board model: %s\n",
-				das1800_boards[board].name);
-			return board;
-		}
-		printk
-		    (" Board model (probed, not recommended): das-1800ao series\n");
-		return das1801ao;
+		if (index == das1801ao || index == das1802ao ||
+		    index == das1701ao || index == das1702ao)
+			return index;
+		index = das1801ao;
 		break;
 	case 0x6:
-		if (board == das1802hr || board == das1702hr) {
-			dev_dbg(dev->class_dev, "Board model: %s\n",
-				das1800_boards[board].name);
-			return board;
-		}
-		printk
-		    (" Board model (probed, not recommended): das-1802hr\n");
-		return das1802hr;
+		if (index == das1802hr || index == das1702hr)
+			return index;
+		index = das1802hr;
 		break;
 	case 0x7:
-		if (board == das1801st || board == das1802st ||
-		    board == das1701st || board == das1702st) {
-			dev_dbg(dev->class_dev, "Board model: %s\n",
-				das1800_boards[board].name);
-			return board;
-		}
-		printk
-		    (" Board model (probed, not recommended): das-1800st series\n");
-		return das1801st;
+		if (index == das1801st || index == das1802st ||
+		    index == das1701st || index == das1702st)
+			return index;
+		index = das1801st;
 		break;
 	case 0x8:
-		if (board == das1801hc || board == das1802hc) {
-			dev_dbg(dev->class_dev, "Board model: %s\n",
-				das1800_boards[board].name);
-			return board;
-		}
-		printk
-		    (" Board model (probed, not recommended): das-1800hc series\n");
-		return das1801hc;
+		if (index == das1801hc || index == das1802hc)
+			return index;
+		index = das1801hc;
 		break;
 	default:
-		printk
-		    (" Board model: probe returned 0x%x (unknown, please report)\n",
-		     id);
-		return board;
+		dev_err(dev->class_dev,
+			"Board model: probe returned 0x%x (unknown, please report)\n",
+			id);
 		break;
 	}
-	return -1;
+	dev_err(dev->class_dev,
+		"Board model (probed, not recommended): %s series\n",
+		das1800_boards[index].name);
+
+	return index;
 }
 
 static int das1800_attach(struct comedi_device *dev,
diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c
index 6f7f8d5..cbbb297 100644
--- a/drivers/staging/comedi/drivers/das800.c
+++ b/drivers/staging/comedi/drivers/das800.c
@@ -65,7 +65,6 @@
 #include "8253.h"
 #include "comedi_fc.h"
 
-#define DAS800_SIZE           8
 #define N_CHAN_AI             8	/*  number of analog input channels */
 
 /* Registers for the das800 */
@@ -686,7 +685,7 @@
 	if (!devpriv)
 		return -ENOMEM;
 
-	ret = comedi_request_region(dev, it->options[0], DAS800_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x8);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c
index ad7a5d5..e9cd2517 100644
--- a/drivers/staging/comedi/drivers/dmm32at.c
+++ b/drivers/staging/comedi/drivers/dmm32at.c
@@ -40,9 +40,6 @@
 #include "comedi_fc.h"
 
 /* Board register addresses */
-
-#define DMM32AT_MEMSIZE 0x10
-
 #define DMM32AT_CONV 0x00
 #define DMM32AT_AILSB 0x00
 #define DMM32AT_AUXDOUT 0x01
@@ -237,7 +234,7 @@
 	return n;
 }
 
-static int dmm32at_ns_to_timer(unsigned int *ns, int round)
+static int dmm32at_ns_to_timer(unsigned int *ns, unsigned int flags)
 {
 	/* trivial timer */
 	return *ns;
@@ -352,12 +349,12 @@
 
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		arg = cmd->scan_begin_arg;
-		dmm32at_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK);
+		dmm32at_ns_to_timer(&arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
 	}
 	if (cmd->convert_src == TRIG_TIMER) {
 		arg = cmd->convert_arg;
-		dmm32at_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK);
+		dmm32at_ns_to_timer(&arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
 
 		if (cmd->scan_begin_src == TRIG_TIMER) {
@@ -491,7 +488,7 @@
 	int i;
 
 	if (!dev->attached) {
-		comedi_error(dev, "spurious interrupt");
+		dev_err(dev->class_dev, "spurious interrupt\n");
 		return IRQ_HANDLED;
 	}
 
@@ -684,7 +681,7 @@
 	struct comedi_subdevice *s;
 	unsigned char aihi, ailo, fifostat, aistat, intstat, airback;
 
-	ret = comedi_request_region(dev, it->options[0], DMM32AT_MEMSIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x10);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c
index 4263014..ad8ba0b 100644
--- a/drivers/staging/comedi/drivers/dt2801.c
+++ b/drivers/staging/comedi/drivers/dt2801.c
@@ -40,9 +40,6 @@
 
 #define DT2801_MAX_DMA_SIZE (64 * 1024)
 
-/* Ports */
-#define DT2801_IOSIZE 2
-
 /* define's */
 /* ====================== */
 
@@ -552,7 +549,7 @@
 	int ret = 0;
 	int n_ai_chans;
 
-	ret = comedi_request_region(dev, it->options[0], DT2801_IOSIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x2);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c
index ba7c2ba..a2e9caf 100644
--- a/drivers/staging/comedi/drivers/dt2811.c
+++ b/drivers/staging/comedi/drivers/dt2811.c
@@ -169,8 +169,6 @@
 
 #define TIMEOUT 10000
 
-#define DT2811_SIZE 8
-
 #define DT2811_ADCSR 0
 #define DT2811_ADGCR 1
 #define DT2811_ADDATLO 2
@@ -344,7 +342,7 @@
 	int ret;
 	struct comedi_subdevice *s;
 
-	ret = comedi_request_region(dev, it->options[0], DT2811_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x8);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c
index 904c9f0..9216c35 100644
--- a/drivers/staging/comedi/drivers/dt2814.c
+++ b/drivers/staging/comedi/drivers/dt2814.c
@@ -42,8 +42,6 @@
 
 #include "comedi_fc.h"
 
-#define DT2814_SIZE 2
-
 #define DT2814_CSR 0
 #define DT2814_DATA 1
 
@@ -171,7 +169,7 @@
 	/* step 4: fix up any arguments */
 
 	arg = cmd->scan_begin_arg;
-	dt2814_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK);
+	dt2814_ns_to_timer(&arg, cmd->flags);
 	err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
 
 	if (err)
@@ -187,9 +185,7 @@
 	int chan;
 	int trigvar;
 
-	trigvar =
-	    dt2814_ns_to_timer(&cmd->scan_begin_arg,
-			       cmd->flags & TRIG_ROUND_MASK);
+	trigvar = dt2814_ns_to_timer(&cmd->scan_begin_arg, cmd->flags);
 
 	chan = CR_CHAN(cmd->chanlist[0]);
 
@@ -209,7 +205,7 @@
 	int data;
 
 	if (!dev->attached) {
-		comedi_error(dev, "spurious interrupt");
+		dev_err(dev->class_dev, "spurious interrupt\n");
 		return IRQ_HANDLED;
 	}
 
@@ -245,7 +241,7 @@
 	int ret;
 	int i;
 
-	ret = comedi_request_region(dev, it->options[0], DT2814_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x2);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c
index b9ac4ed..a98fb66 100644
--- a/drivers/staging/comedi/drivers/dt2815.c
+++ b/drivers/staging/comedi/drivers/dt2815.c
@@ -56,8 +56,6 @@
 
 #include <linux/delay.h>
 
-#define DT2815_SIZE 2
-
 #define DT2815_DATA 0
 #define DT2815_STATUS 1
 
@@ -154,7 +152,7 @@
 	const struct comedi_lrange *current_range_type, *voltage_range_type;
 	int ret;
 
-	ret = comedi_request_region(dev, it->options[0], DT2815_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x2);
 	if (ret)
 		return ret;
 
@@ -195,6 +193,7 @@
 		status = inb(dev->iobase + DT2815_STATUS);
 		if (status == 4) {
 			unsigned int program;
+
 			program = (it->options[4] & 0x3) << 3 | 0x7;
 			outb(program, dev->iobase + DT2815_DATA);
 			dev_dbg(dev->class_dev, "program: 0x%x (@t=%d)\n",
diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c
index bf58993..5131dee 100644
--- a/drivers/staging/comedi/drivers/dt2817.c
+++ b/drivers/staging/comedi/drivers/dt2817.c
@@ -36,8 +36,6 @@
 #include <linux/module.h>
 #include "../comedidev.h"
 
-#define DT2817_SIZE 5
-
 #define DT2817_CR 0
 #define DT2817_DATA 1
 
@@ -114,7 +112,7 @@
 	int ret;
 	struct comedi_subdevice *s;
 
-	ret = comedi_request_region(dev, it->options[0], DT2817_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x5);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c
index 27a8bb1..5de2674 100644
--- a/drivers/staging/comedi/drivers/dt282x.c
+++ b/drivers/staging/comedi/drivers/dt282x.c
@@ -438,7 +438,8 @@
 	int i;
 
 	if (nbytes % 2)
-		comedi_error(dev, "bug! odd number of bytes from dma xfer");
+		dev_err(dev->class_dev,
+			"bug! odd number of bytes from dma xfer\n");
 
 	for (i = 0; i < nbytes / 2; i++) {
 		val = buf[i];
@@ -528,7 +529,7 @@
 	int handled = 0;
 
 	if (!dev->attached) {
-		comedi_error(dev, "spurious interrupt");
+		dev_err(dev->class_dev, "spurious interrupt\n");
 		return IRQ_HANDLED;
 	}
 
@@ -544,13 +545,13 @@
 	}
 	if (adcsr & DT2821_ADCSR_ADERR) {
 		if (devpriv->nread != 0) {
-			comedi_error(dev, "A/D error");
+			dev_err(dev->class_dev, "A/D error\n");
 			s->async->events |= COMEDI_CB_ERROR;
 		}
 		handled = 1;
 	}
 	if (dacsr & DT2821_DACSR_DAERR) {
-		comedi_error(dev, "D/A error");
+		dev_err(dev->class_dev, "D/A error\n");
 		s_ao->async->events |= COMEDI_CB_ERROR;
 		handled = 1;
 	}
@@ -1079,11 +1080,11 @@
 		if (x < 0 || x >= 2)
 			x = 0;
 		return ai_range_pgl_table[x];
-	} else {
-		if (x < 0 || x >= 4)
-			x = 0;
-		return ai_range_table[x];
 	}
+
+	if (x < 0 || x >= 4)
+		x = 0;
+	return ai_range_table[x];
 }
 
 static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2)
diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c
index 4ab4de0..bf5a05c 100644
--- a/drivers/staging/comedi/drivers/dt3000.c
+++ b/drivers/staging/comedi/drivers/dt3000.c
@@ -377,7 +377,7 @@
 }
 
 static int dt3k_ns_to_timer(unsigned int timer_base, unsigned int *nanosec,
-			    unsigned int round_mode)
+			    unsigned int flags)
 {
 	int divider, base, prescale;
 
@@ -386,7 +386,7 @@
 
 	for (prescale = 0; prescale < 16; prescale++) {
 		base = timer_base * (prescale + 1);
-		switch (round_mode) {
+		switch (flags & TRIG_ROUND_MASK) {
 		case TRIG_ROUND_NEAREST:
 		default:
 			divider = (*nanosec + base / 2) / base;
@@ -467,13 +467,13 @@
 
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		arg = cmd->scan_begin_arg;
-		dt3k_ns_to_timer(100, &arg, cmd->flags & TRIG_ROUND_MASK);
+		dt3k_ns_to_timer(100, &arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
 	}
 
 	if (cmd->convert_src == TRIG_TIMER) {
 		arg = cmd->convert_arg;
-		dt3k_ns_to_timer(50, &arg, cmd->flags & TRIG_ROUND_MASK);
+		dt3k_ns_to_timer(50, &arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
 
 		if (cmd->scan_begin_src == TRIG_TIMER) {
@@ -511,15 +511,14 @@
 	writew(cmd->scan_end_arg, devpriv->io_addr + DPR_Params(0));
 
 	if (cmd->convert_src == TRIG_TIMER) {
-		divider = dt3k_ns_to_timer(50, &cmd->convert_arg,
-					   cmd->flags & TRIG_ROUND_MASK);
+		divider = dt3k_ns_to_timer(50, &cmd->convert_arg, cmd->flags);
 		writew((divider >> 16), devpriv->io_addr + DPR_Params(1));
 		writew((divider & 0xffff), devpriv->io_addr + DPR_Params(2));
 	}
 
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		tscandiv = dt3k_ns_to_timer(100, &cmd->scan_begin_arg,
-					    cmd->flags & TRIG_ROUND_MASK);
+					    cmd->flags);
 		writew((tscandiv >> 16), devpriv->io_addr + DPR_Params(3));
 		writew((tscandiv & 0xffff), devpriv->io_addr + DPR_Params(4));
 	}
diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c
index b3aeb6f..bd2ca2b 100644
--- a/drivers/staging/comedi/drivers/dt9812.c
+++ b/drivers/staging/comedi/drivers/dt9812.c
@@ -653,6 +653,7 @@
 
 	for (i = 0; i < host->desc.bNumEndpoints; ++i) {
 		int dir = -1;
+
 		ep = &host->endpoint[i].desc;
 		switch (i) {
 		case 0:
diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c
index 0b8b216..e646958 100644
--- a/drivers/staging/comedi/drivers/icp_multi.c
+++ b/drivers/staging/comedi/drivers/icp_multi.c
@@ -49,8 +49,6 @@
 
 #include "../comedidev.h"
 
-#define PCI_DEVICE_ID_ICP_MULTI	0x8000
-
 #define ICP_MULTI_ADC_CSR	0	/* R/W: ADC command/status register */
 #define ICP_MULTI_AI		2	/* R:   Analogue input data */
 #define ICP_MULTI_DAC_CSR	4	/* R/W: DAC command/status register */
@@ -420,7 +418,7 @@
 
 	/*  Check that we at least have one channel to check */
 	if (n_chan < 1) {
-		comedi_error(dev, "range/channel list is empty!");
+		dev_err(dev->class_dev, "range/channel list is empty!\n");
 		return 0;
 	}
 	/*  Check all channels */
@@ -428,14 +426,14 @@
 		/*  Check that channel number is < maximum */
 		if (CR_AREF(chanlist[i]) == AREF_DIFF) {
 			if (CR_CHAN(chanlist[i]) > (s->nchan / 2)) {
-				comedi_error(dev,
-					     "Incorrect differential ai ch-nr");
+				dev_err(dev->class_dev,
+					"Incorrect differential ai ch-nr\n");
 				return 0;
 			}
 		} else {
 			if (CR_CHAN(chanlist[i]) > s->n_chan) {
-				comedi_error(dev,
-					     "Incorrect ai channel number");
+				dev_err(dev->class_dev,
+					"Incorrect ai channel number\n");
 				return 0;
 			}
 		}
@@ -594,7 +592,7 @@
 }
 
 static const struct pci_device_id icp_multi_pci_table[] = {
-	{ PCI_DEVICE(PCI_VENDOR_ID_ICP, PCI_DEVICE_ID_ICP_MULTI) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_ICP, 0x8000) },
 	{ 0 }
 };
 MODULE_DEVICE_TABLE(pci, icp_multi_pci_table);
diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c
index a8db9d8..7b20e19 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -196,6 +196,7 @@
 					     *channel)
 {
 	struct six_axis_t result;
+
 	result.fx = get_s16(&channel->min_full_scale.fx);
 	result.fy = get_s16(&channel->min_full_scale.fy);
 	result.fz = get_s16(&channel->min_full_scale.fz);
@@ -209,6 +210,7 @@
 					     *channel)
 {
 	struct six_axis_t result;
+
 	result.fx = get_s16(&channel->max_full_scale.fx);
 	result.fy = get_s16(&channel->max_full_scale.fy);
 	result.fz = get_s16(&channel->max_full_scale.fz);
@@ -319,6 +321,8 @@
 			 unsigned int *val)
 {
 	int result = 0;
+	int value;
+
 	if (pos && val) {
 		/*  Skip over non hex */
 		for (; *pos < size && !isxdigit(data[*pos]); (*pos)++)
@@ -326,7 +330,6 @@
 		/*  Collect value */
 		*val = 0;
 		for (; *pos < size; (*pos)++) {
-			int value;
 			value = hex_to_bin(data[*pos]);
 			if (value >= 0) {
 				result = 1;
diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c
index 25ce2f7..9a5c535 100644
--- a/drivers/staging/comedi/drivers/me4000.c
+++ b/drivers/staging/comedi/drivers/me4000.c
@@ -170,7 +170,6 @@
 
 #define ME4000_AI_MIN_TICKS			66
 #define ME4000_AI_MIN_SAMPLE_TIME		2000
-#define ME4000_AI_BASE_FREQUENCY		(unsigned int) 33E6
 
 #define ME4000_AI_CHANNEL_LIST_COUNT		1024
 
diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c
index 52d1548..4658dfd 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -90,6 +90,7 @@
 	unsigned fcr_bits = readl(mite->mite_io_addr + MITE_FCR(channel));
 	unsigned empty_count = (fcr_bits >> 16) & 0xff;
 	unsigned full_count = fcr_bits & 0xff;
+
 	return empty_count + full_count;
 }
 
@@ -444,12 +445,14 @@
 static u32 mite_device_bytes_transferred(struct mite_channel *mite_chan)
 {
 	struct mite_struct *mite = mite_chan->mite;
+
 	return readl(mite->mite_io_addr + MITE_DAR(mite_chan->channel));
 }
 
 u32 mite_bytes_in_transit(struct mite_channel *mite_chan)
 {
 	struct mite_struct *mite = mite_chan->mite;
+
 	return readl(mite->mite_io_addr +
 		     MITE_FCR(mite_chan->channel)) & 0x000000FF;
 }
diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h
index a4852cb..ef7172a 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -107,11 +107,6 @@
 int mite_buf_change(struct mite_dma_descriptor_ring *ring,
 		    struct comedi_subdevice *s);
 
-static inline int CHAN_OFFSET(int channel)
-{
-	return 0x500 + 0x100 * channel;
-};
-
 enum mite_registers {
 	/* The bits 0x90180700 in MITE_UNKNOWN_DMA_BURST_REG can be
 	   written and read back.  The bits 0x1f always read as 1.
@@ -123,90 +118,25 @@
 	MITE_PCI_CONFIG_OFFSET = 0x300,
 	MITE_CSIGR = 0x460	/* chip signature */
 };
-static inline int MITE_CHOR(int channel)
-{				/*  channel operation */
-	return CHAN_OFFSET(channel) + 0x0;
-};
 
-static inline int MITE_CHCR(int channel)
-{				/*  channel control */
-	return CHAN_OFFSET(channel) + 0x4;
-};
-
-static inline int MITE_TCR(int channel)
-{				/*  transfer count */
-	return CHAN_OFFSET(channel) + 0x8;
-};
-
-static inline int MITE_MCR(int channel)
-{				/*  memory configuration */
-	return CHAN_OFFSET(channel) + 0xc;
-};
-
-static inline int MITE_MAR(int channel)
-{				/*  memory address */
-	return CHAN_OFFSET(channel) + 0x10;
-};
-
-static inline int MITE_DCR(int channel)
-{				/*  device configuration */
-	return CHAN_OFFSET(channel) + 0x14;
-};
-
-static inline int MITE_DAR(int channel)
-{				/*  device address */
-	return CHAN_OFFSET(channel) + 0x18;
-};
-
-static inline int MITE_LKCR(int channel)
-{				/*  link configuration */
-	return CHAN_OFFSET(channel) + 0x1c;
-};
-
-static inline int MITE_LKAR(int channel)
-{				/*  link address */
-	return CHAN_OFFSET(channel) + 0x20;
-};
-
-static inline int MITE_LLKAR(int channel)
-{				/*  see mite section of tnt5002 manual */
-	return CHAN_OFFSET(channel) + 0x24;
-};
-
-static inline int MITE_BAR(int channel)
-{				/*  base address */
-	return CHAN_OFFSET(channel) + 0x28;
-};
-
-static inline int MITE_BCR(int channel)
-{				/*  base count */
-	return CHAN_OFFSET(channel) + 0x2c;
-};
-
-static inline int MITE_SAR(int channel)
-{				/*  ? address */
-	return CHAN_OFFSET(channel) + 0x30;
-};
-
-static inline int MITE_WSCR(int channel)
-{				/*  ? */
-	return CHAN_OFFSET(channel) + 0x34;
-};
-
-static inline int MITE_WSER(int channel)
-{				/*  ? */
-	return CHAN_OFFSET(channel) + 0x38;
-};
-
-static inline int MITE_CHSR(int channel)
-{				/*  channel status */
-	return CHAN_OFFSET(channel) + 0x3c;
-};
-
-static inline int MITE_FCR(int channel)
-{				/*  fifo count */
-	return CHAN_OFFSET(channel) + 0x40;
-};
+#define MITE_CHAN(x)	(0x500 + 0x100 * (x))
+#define MITE_CHOR(x)	(0x00 + MITE_CHAN(x))	/* channel operation */
+#define MITE_CHCR(x)	(0x04 + MITE_CHAN(x))	/* channel control */
+#define MITE_TCR(x)	(0x08 + MITE_CHAN(x))	/* transfer count */
+#define MITE_MCR(x)	(0x0c + MITE_CHAN(x))	/* memory configuration */
+#define MITE_MAR(x)	(0x10 + MITE_CHAN(x))	/* memory address */
+#define MITE_DCR(x)	(0x14 + MITE_CHAN(x))	/* device configuration */
+#define MITE_DAR(x)	(0x18 + MITE_CHAN(x))	/* device address */
+#define MITE_LKCR(x)	(0x1c + MITE_CHAN(x))	/* link configuration */
+#define MITE_LKAR(x)	(0x20 + MITE_CHAN(x))	/* link address */
+#define MITE_LLKAR(x)	(0x24 + MITE_CHAN(x))	/* see tnt5002 manual */
+#define MITE_BAR(x)	(0x28 + MITE_CHAN(x))	/* base address */
+#define MITE_BCR(x)	(0x2c + MITE_CHAN(x))	/* base count */
+#define MITE_SAR(x)	(0x30 + MITE_CHAN(x))	/* ? address */
+#define MITE_WSCR(x)	(0x34 + MITE_CHAN(x))	/* ? */
+#define MITE_WSER(x)	(0x38 + MITE_CHAN(x))	/* ? */
+#define MITE_CHSR(x)	(0x3c + MITE_CHAN(x))	/* channel status */
+#define MITE_FCR(x)	(0x40 + MITE_CHAN(x))	/* fifo count */
 
 enum MITE_IODWBSR_bits {
 	WENAB = 0x80,		/*  window enable */
@@ -254,11 +184,9 @@
 static inline int mite_csigr_wpdep(u32 csigr_bits)
 {				/*  write post fifo depth */
 	unsigned int wpdep_bits = (csigr_bits >> 20) & 0x7;
-	if (wpdep_bits == 0)
-		return 0;
-	else
-		return 1 << (wpdep_bits - 1);
-};
+
+	return (wpdep_bits) ? (1 << (wpdep_bits - 1)) : 0;
+}
 
 static inline int mite_csigr_wins(u32 csigr_bits)
 {
diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c
index f770400..1241f99 100644
--- a/drivers/staging/comedi/drivers/mpc624.c
+++ b/drivers/staging/comedi/drivers/mpc624.c
@@ -56,9 +56,6 @@
 
 #include <linux/delay.h>
 
-/* Consecutive I/O port addresses */
-#define MPC624_SIZE             16
-
 /* Offsets of different ports */
 #define MPC624_MASTER_CONTROL	0 /* not used */
 #define MPC624_GNMUXCH          1 /* Gain, Mux, Channel of ADC */
@@ -279,7 +276,7 @@
 	struct comedi_subdevice *s;
 	int ret;
 
-	ret = comedi_request_region(dev, it->options[0], MPC624_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x10);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/staging/comedi/drivers/multiq3.c
index b74b9e9..e841a5a 100644
--- a/drivers/staging/comedi/drivers/multiq3.c
+++ b/drivers/staging/comedi/drivers/multiq3.c
@@ -28,8 +28,6 @@
 #include <linux/interrupt.h>
 #include "../comedidev.h"
 
-#define MULTIQ3_SIZE 16
-
 /*
  * MULTIQ-3 port offsets
  */
@@ -189,12 +187,12 @@
 				     struct comedi_insn *insn,
 				     unsigned int *data)
 {
-	int n;
 	int chan = CR_CHAN(insn->chanspec);
 	int control = MULTIQ3_CONTROL_MUST | MULTIQ3_AD_MUX_EN | (chan << 3);
+	int value;
+	int n;
 
 	for (n = 0; n < insn->n; n++) {
-		int value;
 		outw(control, dev->iobase + MULTIQ3_CONTROL);
 		outb(MULTIQ3_BP_RESET, dev->iobase + MULTIQ3_ENC_CONTROL);
 		outb(MULTIQ3_TRSFRCNTR_OL, dev->iobase + MULTIQ3_ENC_CONTROL);
@@ -233,7 +231,7 @@
 	struct comedi_subdevice *s;
 	int ret;
 
-	ret = comedi_request_region(dev, it->options[0], MULTIQ3_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x10);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c
index c8b1fa7..8ea93b5 100644
--- a/drivers/staging/comedi/drivers/ni_6527.c
+++ b/drivers/staging/comedi/drivers/ni_6527.c
@@ -299,21 +299,38 @@
 }
 
 static void ni6527_set_edge_detection(struct comedi_device *dev,
+				      unsigned int mask,
 				      unsigned int rising,
 				      unsigned int falling)
 {
 	struct ni6527_private *devpriv = dev->private;
 	void __iomem *mmio = devpriv->mmio_base;
+	unsigned int i;
 
-	/* enable rising-edge detection channels */
-	writeb(rising & 0xff, mmio + NI6527_RISING_EDGE_REG(0));
-	writeb((rising >> 8) & 0xff, mmio + NI6527_RISING_EDGE_REG(1));
-	writeb((rising >> 16) & 0xff, mmio + NI6527_RISING_EDGE_REG(2));
-
-	/* enable falling-edge detection channels */
-	writeb(falling & 0xff, mmio + NI6527_FALLING_EDGE_REG(0));
-	writeb((falling >> 8) & 0xff, mmio + NI6527_FALLING_EDGE_REG(1));
-	writeb((falling >> 16) & 0xff, mmio + NI6527_FALLING_EDGE_REG(2));
+	rising &= mask;
+	falling &= mask;
+	for (i = 0; i < 2; i++) {
+		if (mask & 0xff) {
+			if (~mask & 0xff) {
+				/* preserve rising-edge detection channels */
+				rising |= readb(mmio +
+						NI6527_RISING_EDGE_REG(i)) &
+					  (~mask & 0xff);
+				/* preserve falling-edge detection channels */
+				falling |= readb(mmio +
+						 NI6527_FALLING_EDGE_REG(i)) &
+					   (~mask & 0xff);
+			}
+			/* update rising-edge detection channels */
+			writeb(rising & 0xff, mmio + NI6527_RISING_EDGE_REG(i));
+			/* update falling-edge detection channels */
+			writeb(falling & 0xff,
+			       mmio + NI6527_FALLING_EDGE_REG(i));
+		}
+		rising >>= 8;
+		falling >>= 8;
+		mask >>= 8;
+	}
 }
 
 static int ni6527_intr_insn_config(struct comedi_device *dev,
@@ -321,12 +338,45 @@
 				   struct comedi_insn *insn,
 				   unsigned int *data)
 {
+	unsigned int mask = 0xffffffff;
+	unsigned int rising, falling, shift;
+
 	switch (data[0]) {
 	case INSN_CONFIG_CHANGE_NOTIFY:
 		/* check_insn_config_length() does not check this instruction */
 		if (insn->n != 3)
 			return -EINVAL;
-		ni6527_set_edge_detection(dev, data[1], data[2]);
+		rising = data[1];
+		falling = data[2];
+		ni6527_set_edge_detection(dev, mask, rising, falling);
+		break;
+	case INSN_CONFIG_DIGITAL_TRIG:
+		/* check trigger number */
+		if (data[1] != 0)
+			return -EINVAL;
+		/* check digital trigger operation */
+		switch (data[2]) {
+		case COMEDI_DIGITAL_TRIG_DISABLE:
+			rising = 0;
+			falling = 0;
+			break;
+		case COMEDI_DIGITAL_TRIG_ENABLE_EDGES:
+			/* check shift amount */
+			shift = data[3];
+			if (shift >= s->n_chan) {
+				mask = 0;
+				rising = 0;
+				falling = 0;
+			} else {
+				mask <<= shift;
+				rising = data[4] << shift;
+				falling = data[5] << shift;
+			}
+			break;
+		default:
+			return -EINVAL;
+		}
+		ni6527_set_edge_detection(dev, mask, rising, falling);
 		break;
 	default:
 		return -EINVAL;
@@ -343,6 +393,9 @@
 	/* disable deglitch filters on all channels */
 	ni6527_set_filter_enable(dev, 0);
 
+	/* disable edge detection */
+	ni6527_set_edge_detection(dev, 0xffffffff, 0, 0);
+
 	writeb(NI6527_CLR_IRQS | NI6527_CLR_RESET_FILT,
 	       mmio + NI6527_CLR_REG);
 	writeb(NI6527_CTRL_DISABLE_IRQS, mmio + NI6527_CTRL_REG);
diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c
index 59f592e..aba6fbb 100644
--- a/drivers/staging/comedi/drivers/ni_65xx.c
+++ b/drivers/staging/comedi/drivers/ni_65xx.c
@@ -1,46 +1,73 @@
 /*
-    comedi/drivers/ni_6514.c
-    driver for National Instruments PCI-6514
-
-    Copyright (C) 2006 Jon Grierson <jd@renko.co.uk>
-    Copyright (C) 2006 Frank Mori Hess <fmhess@users.sourceforge.net>
-
-    COMEDI - Linux Control and Measurement Device Interface
-    Copyright (C) 1999,2002,2003 David A. Schleef <ds@schleef.org>
-
-    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.
-
-    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.
-*/
-/*
-Driver: ni_65xx
-Description: National Instruments 65xx static dio boards
-Author: Jon Grierson <jd@renko.co.uk>,
-	Frank Mori Hess <fmhess@users.sourceforge.net>
-Status: testing
-Devices: [National Instruments] PCI-6509 (ni_65xx), PXI-6509, PCI-6510,
-  PCI-6511, PXI-6511, PCI-6512, PXI-6512, PCI-6513, PXI-6513, PCI-6514,
-  PXI-6514, PCI-6515, PXI-6515, PCI-6516, PCI-6517, PCI-6518, PCI-6519,
-  PCI-6520, PCI-6521, PXI-6521, PCI-6528, PXI-6528
-Updated: Wed Oct 18 08:59:11 EDT 2006
-
-Based on the PCI-6527 driver by ds.
-The interrupt subdevice (subdevice 3) is probably broken for all boards
-except maybe the 6514.
-
-*/
+ * ni_65xx.c
+ * Comedi driver for National Instruments PCI-65xx static dio boards
+ *
+ * Copyright (C) 2006 Jon Grierson <jd@renko.co.uk>
+ * Copyright (C) 2006 Frank Mori Hess <fmhess@users.sourceforge.net>
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1999,2002,2003 David A. Schleef <ds@schleef.org>
+ *
+ * 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.
+ *
+ * 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.
+ */
 
 /*
-   Manuals (available from ftp://ftp.natinst.com/support/manuals)
+ * Driver: ni_65xx
+ * Description: National Instruments 65xx static dio boards
+ * Author: Jon Grierson <jd@renko.co.uk>,
+ *	   Frank Mori Hess <fmhess@users.sourceforge.net>
+ * Status: testing
+ * Devices: (National Instruments) PCI-6509 [ni_65xx]
+ *	    (National Instruments) PXI-6509 [ni_65xx]
+ *	    (National Instruments) PCI-6510 [ni_65xx]
+ *	    (National Instruments) PCI-6511 [ni_65xx]
+ *	    (National Instruments) PXI-6511 [ni_65xx]
+ *	    (National Instruments) PCI-6512 [ni_65xx]
+ *	    (National Instruments) PXI-6512 [ni_65xx]
+ *	    (National Instruments) PCI-6513 [ni_65xx]
+ *	    (National Instruments) PXI-6513 [ni_65xx]
+ *	    (National Instruments) PCI-6514 [ni_65xx]
+ *	    (National Instruments) PXI-6514 [ni_65xx]
+ *	    (National Instruments) PCI-6515 [ni_65xx]
+ *	    (National Instruments) PXI-6515 [ni_65xx]
+ *	    (National Instruments) PCI-6516 [ni_65xx]
+ *	    (National Instruments) PCI-6517 [ni_65xx]
+ *	    (National Instruments) PCI-6518 [ni_65xx]
+ *	    (National Instruments) PCI-6519 [ni_65xx]
+ *	    (National Instruments) PCI-6520 [ni_65xx]
+ *	    (National Instruments) PCI-6521 [ni_65xx]
+ *	    (National Instruments) PXI-6521 [ni_65xx]
+ *	    (National Instruments) PCI-6528 [ni_65xx]
+ *	    (National Instruments) PXI-6528 [ni_65xx]
+ * Updated: Mon, 21 Jul 2014 12:49:58 +0000
+ *
+ * Configuration Options: not applicable, uses PCI auto config
+ *
+ * Based on the PCI-6527 driver by ds.
+ * The interrupt subdevice (subdevice 3) is probably broken for all
+ * boards except maybe the 6514.
+ *
+ * This driver previously inverted the outputs on PCI-6513 through to
+ * PCI-6519 and on PXI-6513 through to PXI-6515.  It no longer inverts
+ * outputs on those cards by default as it didn't make much sense.  If
+ * you require the outputs to be inverted on those cards for legacy
+ * reasons, set the module parameter "legacy_invert_outputs=true" when
+ * loading the module, or set "ni_65xx.legacy_invert_outputs=true" on
+ * the kernel command line if the driver is built in to the kernel.
+ */
 
-	370106b.pdf	6514 Register Level Programmer Manual
-
+/*
+ * Manuals (available from ftp://ftp.natinst.com/support/manuals)
+ *
+ *	370106b.pdf	6514 Register Level Programmer Manual
  */
 
 #include <linux/module.h>
@@ -50,59 +77,69 @@
 #include "../comedidev.h"
 
 #include "comedi_fc.h"
-#include "mite.h"
 
-#define NI6514_DIO_SIZE 4096
-#define NI6514_MITE_SIZE 4096
+/*
+ * PCI BAR1 Register Map
+ */
 
-#define NI_65XX_MAX_NUM_PORTS 12
-static const unsigned ni_65xx_channels_per_port = 8;
-static const unsigned ni_65xx_port_offset = 0x10;
+/* Non-recurring Registers (8-bit except where noted) */
+#define NI_65XX_ID_REG			0x00
+#define NI_65XX_CLR_REG			0x01
+#define NI_65XX_CLR_WDOG_INT		(1 << 6)
+#define NI_65XX_CLR_WDOG_PING		(1 << 5)
+#define NI_65XX_CLR_WDOG_EXP		(1 << 4)
+#define NI_65XX_CLR_EDGE_INT		(1 << 3)
+#define NI_65XX_CLR_OVERFLOW_INT	(1 << 2)
+#define NI_65XX_STATUS_REG		0x02
+#define NI_65XX_STATUS_WDOG_INT		(1 << 5)
+#define NI_65XX_STATUS_FALL_EDGE	(1 << 4)
+#define NI_65XX_STATUS_RISE_EDGE	(1 << 3)
+#define NI_65XX_STATUS_INT		(1 << 2)
+#define NI_65XX_STATUS_OVERFLOW_INT	(1 << 1)
+#define NI_65XX_STATUS_EDGE_INT		(1 << 0)
+#define NI_65XX_CTRL_REG		0x03
+#define NI_65XX_CTRL_WDOG_ENA		(1 << 5)
+#define NI_65XX_CTRL_FALL_EDGE_ENA	(1 << 4)
+#define NI_65XX_CTRL_RISE_EDGE_ENA	(1 << 3)
+#define NI_65XX_CTRL_INT_ENA		(1 << 2)
+#define NI_65XX_CTRL_OVERFLOW_ENA	(1 << 1)
+#define NI_65XX_CTRL_EDGE_ENA		(1 << 0)
+#define NI_65XX_REV_REG			0x04 /* 32-bit */
+#define NI_65XX_FILTER_REG		0x08 /* 32-bit */
+#define NI_65XX_RTSI_ROUTE_REG		0x0c /* 16-bit */
+#define NI_65XX_RTSI_EDGE_REG		0x0e /* 16-bit */
+#define NI_65XX_RTSI_WDOG_REG		0x10 /* 16-bit */
+#define NI_65XX_RTSI_TRIG_REG		0x12 /* 16-bit */
+#define NI_65XX_AUTO_CLK_SEL_REG	0x14 /* PXI-6528 only */
+#define NI_65XX_AUTO_CLK_SEL_STATUS	(1 << 1)
+#define NI_65XX_AUTO_CLK_SEL_DISABLE	(1 << 0)
+#define NI_65XX_WDOG_CTRL_REG		0x15
+#define NI_65XX_WDOG_CTRL_ENA		(1 << 0)
+#define NI_65XX_RTSI_CFG_REG		0x16
+#define NI_65XX_RTSI_CFG_RISE_SENSE	(1 << 2)
+#define NI_65XX_RTSI_CFG_FALL_SENSE	(1 << 1)
+#define NI_65XX_RTSI_CFG_SYNC_DETECT	(1 << 0)
+#define NI_65XX_WDOG_STATUS_REG		0x17
+#define NI_65XX_WDOG_STATUS_EXP		(1 << 0)
+#define NI_65XX_WDOG_INTERVAL_REG	0x18 /* 32-bit */
 
-static inline unsigned Port_Data(unsigned port)
-{
-	return 0x40 + port * ni_65xx_port_offset;
-}
+/* Recurring port registers (8-bit) */
+#define NI_65XX_PORT(x)			((x) * 0x10)
+#define NI_65XX_IO_DATA_REG(x)		(0x40 + NI_65XX_PORT(x))
+#define NI_65XX_IO_SEL_REG(x)		(0x41 + NI_65XX_PORT(x))
+#define NI_65XX_IO_SEL_OUTPUT		(0 << 0)
+#define NI_65XX_IO_SEL_INPUT		(1 << 0)
+#define NI_65XX_RISE_EDGE_ENA_REG(x)	(0x42 + NI_65XX_PORT(x))
+#define NI_65XX_FALL_EDGE_ENA_REG(x)	(0x43 + NI_65XX_PORT(x))
+#define NI_65XX_FILTER_ENA(x)		(0x44 + NI_65XX_PORT(x))
+#define NI_65XX_WDOG_HIZ_REG(x)		(0x46 + NI_65XX_PORT(x))
+#define NI_65XX_WDOG_ENA(x)		(0x47 + NI_65XX_PORT(x))
+#define NI_65XX_WDOG_HI_LO_REG(x)	(0x48 + NI_65XX_PORT(x))
+#define NI_65XX_RTSI_ENA(x)		(0x49 + NI_65XX_PORT(x))
 
-static inline unsigned Port_Select(unsigned port)
-{
-	return 0x41 + port * ni_65xx_port_offset;
-}
-
-static inline unsigned Rising_Edge_Detection_Enable(unsigned port)
-{
-	return 0x42 + port * ni_65xx_port_offset;
-}
-
-static inline unsigned Falling_Edge_Detection_Enable(unsigned port)
-{
-	return 0x43 + port * ni_65xx_port_offset;
-}
-
-static inline unsigned Filter_Enable(unsigned port)
-{
-	return 0x44 + port * ni_65xx_port_offset;
-}
-
-#define ID_Register				0x00
-
-#define Clear_Register				0x01
-#define ClrEdge				0x08
-#define ClrOverflow			0x04
-
-#define Filter_Interval			0x08
-
-#define Change_Status				0x02
-#define MasterInterruptStatus		0x04
-#define Overflow			0x02
-#define EdgeStatus			0x01
-
-#define Master_Interrupt_Control		0x03
-#define FallingEdgeIntEnable		0x10
-#define RisingEdgeIntEnable		0x08
-#define MasterInterruptEnable		0x04
-#define OverflowIntEnable		0x02
-#define EdgeIntEnable			0x01
+#define NI_65XX_PORT_TO_CHAN(x)		((x) * 8)
+#define NI_65XX_CHAN_TO_PORT(x)		((x) / 8)
+#define NI_65XX_CHAN_TO_MASK(x)		(1 << ((x) % 8))
 
 enum ni_65xx_boardid {
 	BOARD_PCI6509,
@@ -134,7 +171,7 @@
 	unsigned num_dio_ports;
 	unsigned num_di_ports;
 	unsigned num_do_ports;
-	unsigned invert_outputs:1;
+	unsigned legacy_invert:1;
 };
 
 static const struct ni_65xx_board ni_65xx_boards[] = {
@@ -169,58 +206,58 @@
 	[BOARD_PCI6513] = {
 		.name		= "pci-6513",
 		.num_do_ports	= 8,
-		.invert_outputs	= 1,
+		.legacy_invert	= 1,
 	},
 	[BOARD_PXI6513] = {
 		.name		= "pxi-6513",
 		.num_do_ports	= 8,
-		.invert_outputs	= 1,
+		.legacy_invert	= 1,
 	},
 	[BOARD_PCI6514] = {
 		.name		= "pci-6514",
 		.num_di_ports	= 4,
 		.num_do_ports	= 4,
-		.invert_outputs	= 1,
+		.legacy_invert	= 1,
 	},
 	[BOARD_PXI6514] = {
 		.name		= "pxi-6514",
 		.num_di_ports	= 4,
 		.num_do_ports	= 4,
-		.invert_outputs	= 1,
+		.legacy_invert	= 1,
 	},
 	[BOARD_PCI6515] = {
 		.name		= "pci-6515",
 		.num_di_ports	= 4,
 		.num_do_ports	= 4,
-		.invert_outputs	= 1,
+		.legacy_invert	= 1,
 	},
 	[BOARD_PXI6515] = {
 		.name		= "pxi-6515",
 		.num_di_ports	= 4,
 		.num_do_ports	= 4,
-		.invert_outputs	= 1,
+		.legacy_invert	= 1,
 	},
 	[BOARD_PCI6516] = {
 		.name		= "pci-6516",
 		.num_do_ports	= 4,
-		.invert_outputs	= 1,
+		.legacy_invert	= 1,
 	},
 	[BOARD_PCI6517] = {
 		.name		= "pci-6517",
 		.num_do_ports	= 4,
-		.invert_outputs	= 1,
+		.legacy_invert	= 1,
 	},
 	[BOARD_PCI6518] = {
 		.name		= "pci-6518",
 		.num_di_ports	= 2,
 		.num_do_ports	= 2,
-		.invert_outputs	= 1,
+		.legacy_invert	= 1,
 	},
 	[BOARD_PCI6519] = {
 		.name		= "pci-6519",
 		.num_di_ports	= 2,
 		.num_do_ports	= 2,
-		.invert_outputs	= 1,
+		.legacy_invert	= 1,
 	},
 	[BOARD_PCI6520] = {
 		.name		= "pci-6520",
@@ -249,135 +286,122 @@
 	},
 };
 
-static inline unsigned ni_65xx_port_by_channel(unsigned channel)
-{
-	return channel / ni_65xx_channels_per_port;
-}
-
-static inline unsigned ni_65xx_total_num_ports(const struct ni_65xx_board
-					       *board)
-{
-	return board->num_dio_ports + board->num_di_ports + board->num_do_ports;
-}
+static bool ni_65xx_legacy_invert_outputs;
+module_param_named(legacy_invert_outputs, ni_65xx_legacy_invert_outputs,
+		   bool, 0444);
+MODULE_PARM_DESC(legacy_invert_outputs,
+		 "invert outputs of PCI/PXI-6513/6514/6515/6516/6517/6518/6519 for compatibility with old user code");
 
 struct ni_65xx_private {
-	struct mite_struct *mite;
-	unsigned int filter_interval;
-	unsigned short filter_enable[NI_65XX_MAX_NUM_PORTS];
-	unsigned short output_bits[NI_65XX_MAX_NUM_PORTS];
-	unsigned short dio_direction[NI_65XX_MAX_NUM_PORTS];
+	void __iomem *mmio;
 };
 
-struct ni_65xx_subdevice_private {
-	unsigned base_port;
-};
-
-static inline struct ni_65xx_subdevice_private *sprivate(struct comedi_subdevice
-							 *subdev)
+static void ni_65xx_disable_input_filters(struct comedi_device *dev)
 {
-	return subdev->private;
-}
-
-static int ni_65xx_config_filter(struct comedi_device *dev,
-				 struct comedi_subdevice *s,
-				 struct comedi_insn *insn, unsigned int *data)
-{
+	const struct ni_65xx_board *board = comedi_board(dev);
 	struct ni_65xx_private *devpriv = dev->private;
-	const unsigned chan = CR_CHAN(insn->chanspec);
-	const unsigned port =
-	    sprivate(s)->base_port + ni_65xx_port_by_channel(chan);
+	unsigned num_ports;
+	int i;
 
-	if (data[0] != INSN_CONFIG_FILTER)
-		return -EINVAL;
-	if (data[1]) {
-		static const unsigned filter_resolution_ns = 200;
-		static const unsigned max_filter_interval = 0xfffff;
-		unsigned interval =
-		    (data[1] +
-		     (filter_resolution_ns / 2)) / filter_resolution_ns;
-		if (interval > max_filter_interval)
-			interval = max_filter_interval;
-		data[1] = interval * filter_resolution_ns;
+	num_ports = board->num_dio_ports +
+		    board->num_di_ports +
+		    board->num_do_ports;
 
-		if (interval != devpriv->filter_interval) {
-			writeb(interval,
-			       devpriv->mite->daq_io_addr +
-			       Filter_Interval);
-			devpriv->filter_interval = interval;
-		}
+	/* disable input filtering on all ports */
+	for (i = 0; i < num_ports; ++i)
+		writeb(0x00, devpriv->mmio + NI_65XX_FILTER_ENA(i));
 
-		devpriv->filter_enable[port] |=
-		    1 << (chan % ni_65xx_channels_per_port);
-	} else {
-		devpriv->filter_enable[port] &=
-		    ~(1 << (chan % ni_65xx_channels_per_port));
-	}
-
-	writeb(devpriv->filter_enable[port],
-	       devpriv->mite->daq_io_addr + Filter_Enable(port));
-
-	return 2;
+	/* set filter interval to 0 (32bit reg) */
+	writel(0x00000000, devpriv->mmio + NI_65XX_FILTER_REG);
 }
 
 static int ni_65xx_dio_insn_config(struct comedi_device *dev,
 				   struct comedi_subdevice *s,
-				   struct comedi_insn *insn, unsigned int *data)
+				   struct comedi_insn *insn,
+				   unsigned int *data)
 {
 	struct ni_65xx_private *devpriv = dev->private;
-	unsigned port;
+	unsigned long base_port = (unsigned long)s->private;
+	unsigned int chan = CR_CHAN(insn->chanspec);
+	unsigned int chan_mask = NI_65XX_CHAN_TO_MASK(chan);
+	unsigned port = base_port + NI_65XX_CHAN_TO_PORT(chan);
+	unsigned int interval;
+	unsigned int val;
 
-	if (insn->n < 1)
-		return -EINVAL;
-	port = sprivate(s)->base_port +
-	    ni_65xx_port_by_channel(CR_CHAN(insn->chanspec));
 	switch (data[0]) {
 	case INSN_CONFIG_FILTER:
-		return ni_65xx_config_filter(dev, s, insn, data);
+		/*
+		 * The deglitch filter interval is specified in nanoseconds.
+		 * The hardware supports intervals in 200ns increments. Round
+		 * the user values up and return the actual interval.
+		 */
+		interval = (data[1] + 100) / 200;
+		if (interval > 0xfffff)
+			interval = 0xfffff;
+		data[1] = interval * 200;
+
+		/*
+		 * Enable/disable the channel for deglitch filtering. Note
+		 * that the filter interval is never set to '0'. This is done
+		 * because other channels might still be enabled for filtering.
+		 */
+		val = readb(devpriv->mmio + NI_65XX_FILTER_ENA(port));
+		if (interval) {
+			writel(interval, devpriv->mmio + NI_65XX_FILTER_REG);
+			val |= chan_mask;
+		} else {
+			val &= ~chan_mask;
+		}
+		writeb(val, devpriv->mmio + NI_65XX_FILTER_ENA(port));
 		break;
+
 	case INSN_CONFIG_DIO_OUTPUT:
 		if (s->type != COMEDI_SUBD_DIO)
 			return -EINVAL;
-		devpriv->dio_direction[port] = COMEDI_OUTPUT;
-		writeb(0, devpriv->mite->daq_io_addr + Port_Select(port));
-		return 1;
+		writeb(NI_65XX_IO_SEL_OUTPUT,
+		       devpriv->mmio + NI_65XX_IO_SEL_REG(port));
 		break;
+
 	case INSN_CONFIG_DIO_INPUT:
 		if (s->type != COMEDI_SUBD_DIO)
 			return -EINVAL;
-		devpriv->dio_direction[port] = COMEDI_INPUT;
-		writeb(1, devpriv->mite->daq_io_addr + Port_Select(port));
-		return 1;
+		writeb(NI_65XX_IO_SEL_INPUT,
+		       devpriv->mmio + NI_65XX_IO_SEL_REG(port));
 		break;
+
 	case INSN_CONFIG_DIO_QUERY:
 		if (s->type != COMEDI_SUBD_DIO)
 			return -EINVAL;
-		data[1] = devpriv->dio_direction[port];
-		return insn->n;
+		val = readb(devpriv->mmio + NI_65XX_IO_SEL_REG(port));
+		data[1] = (val == NI_65XX_IO_SEL_INPUT) ? COMEDI_INPUT
+							: COMEDI_OUTPUT;
 		break;
+
 	default:
-		break;
+		return -EINVAL;
 	}
-	return -EINVAL;
+
+	return insn->n;
 }
 
 static int ni_65xx_dio_insn_bits(struct comedi_device *dev,
 				 struct comedi_subdevice *s,
-				 struct comedi_insn *insn, unsigned int *data)
+				 struct comedi_insn *insn,
+				 unsigned int *data)
 {
-	const struct ni_65xx_board *board = comedi_board(dev);
 	struct ni_65xx_private *devpriv = dev->private;
-	int base_bitfield_channel;
+	unsigned long base_port = (unsigned long)s->private;
+	unsigned int base_chan = CR_CHAN(insn->chanspec);
+	int last_port_offset = NI_65XX_CHAN_TO_PORT(s->n_chan - 1);
 	unsigned read_bits = 0;
-	int last_port_offset = ni_65xx_port_by_channel(s->n_chan - 1);
 	int port_offset;
 
-	base_bitfield_channel = CR_CHAN(insn->chanspec);
-	for (port_offset = ni_65xx_port_by_channel(base_bitfield_channel);
+	for (port_offset = NI_65XX_CHAN_TO_PORT(base_chan);
 	     port_offset <= last_port_offset; port_offset++) {
-		unsigned port = sprivate(s)->base_port + port_offset;
-		int base_port_channel = port_offset * ni_65xx_channels_per_port;
-		unsigned port_mask, port_data, port_read_bits;
-		int bitshift = base_port_channel - base_bitfield_channel;
+		unsigned port = base_port + port_offset;
+		int base_port_channel = NI_65XX_PORT_TO_CHAN(port_offset);
+		unsigned port_mask, port_data, bits;
+		int bitshift = base_port_channel - base_chan;
 
 		if (bitshift >= 32)
 			break;
@@ -392,32 +416,26 @@
 		}
 		port_mask &= 0xff;
 		port_data &= 0xff;
-		if (port_mask) {
-			unsigned bits;
-			devpriv->output_bits[port] &= ~port_mask;
-			devpriv->output_bits[port] |=
-			    port_data & port_mask;
-			bits = devpriv->output_bits[port];
-			if (board->invert_outputs)
-				bits = ~bits;
-			writeb(bits,
-			       devpriv->mite->daq_io_addr +
-			       Port_Data(port));
-		}
-		port_read_bits =
-		    readb(devpriv->mite->daq_io_addr + Port_Data(port));
-		if (s->type == COMEDI_SUBD_DO && board->invert_outputs) {
-			/* Outputs inverted, so invert value read back from
-			 * DO subdevice.  (Does not apply to boards with DIO
-			 * subdevice.) */
-			port_read_bits ^= 0xFF;
-		}
-		if (bitshift > 0)
-			port_read_bits <<= bitshift;
-		else
-			port_read_bits >>= -bitshift;
 
-		read_bits |= port_read_bits;
+		/* update the outputs */
+		if (port_mask) {
+			bits = readb(devpriv->mmio + NI_65XX_IO_DATA_REG(port));
+			bits ^= s->io_bits;	/* invert if necessary */
+			bits &= ~port_mask;
+			bits |= (port_data & port_mask);
+			bits ^= s->io_bits;	/* invert back */
+			writeb(bits, devpriv->mmio + NI_65XX_IO_DATA_REG(port));
+		}
+
+		/* read back the actual state */
+		bits = readb(devpriv->mmio + NI_65XX_IO_DATA_REG(port));
+		bits ^= s->io_bits;	/* invert if necessary */
+		if (bitshift > 0)
+			bits <<= bitshift;
+		else
+			bits >>= -bitshift;
+
+		read_bits |= bits;
 	}
 	data[1] = read_bits;
 	return insn->n;
@@ -430,14 +448,14 @@
 	struct comedi_subdevice *s = dev->read_subdev;
 	unsigned int status;
 
-	status = readb(devpriv->mite->daq_io_addr + Change_Status);
-	if ((status & MasterInterruptStatus) == 0)
+	status = readb(devpriv->mmio + NI_65XX_STATUS_REG);
+	if ((status & NI_65XX_STATUS_INT) == 0)
 		return IRQ_NONE;
-	if ((status & EdgeStatus) == 0)
+	if ((status & NI_65XX_STATUS_EDGE_INT) == 0)
 		return IRQ_NONE;
 
-	writeb(ClrEdge | ClrOverflow,
-	       devpriv->mite->daq_io_addr + Clear_Register);
+	writeb(NI_65XX_CLR_EDGE_INT | NI_65XX_CLR_OVERFLOW_INT,
+	       devpriv->mmio + NI_65XX_CLR_REG);
 
 	comedi_buf_put(s, 0);
 	s->async->events |= COMEDI_CB_EOS;
@@ -492,11 +510,11 @@
 {
 	struct ni_65xx_private *devpriv = dev->private;
 
-	writeb(ClrEdge | ClrOverflow,
-	       devpriv->mite->daq_io_addr + Clear_Register);
-	writeb(FallingEdgeIntEnable | RisingEdgeIntEnable |
-	       MasterInterruptEnable | EdgeIntEnable,
-	       devpriv->mite->daq_io_addr + Master_Interrupt_Control);
+	writeb(NI_65XX_CLR_EDGE_INT | NI_65XX_CLR_OVERFLOW_INT,
+	       devpriv->mmio + NI_65XX_CLR_REG);
+	writeb(NI_65XX_CTRL_FALL_EDGE_ENA | NI_65XX_CTRL_RISE_EDGE_ENA |
+	       NI_65XX_CTRL_INT_ENA | NI_65XX_CTRL_EDGE_ENA,
+	       devpriv->mmio + NI_65XX_CTRL_REG);
 
 	return 0;
 }
@@ -506,14 +524,15 @@
 {
 	struct ni_65xx_private *devpriv = dev->private;
 
-	writeb(0x00, devpriv->mite->daq_io_addr + Master_Interrupt_Control);
+	writeb(0x00, devpriv->mmio + NI_65XX_CTRL_REG);
 
 	return 0;
 }
 
 static int ni_65xx_intr_insn_bits(struct comedi_device *dev,
 				  struct comedi_subdevice *s,
-				  struct comedi_insn *insn, unsigned int *data)
+				  struct comedi_insn *insn,
+				  unsigned int *data)
 {
 	data[1] = 0;
 	return insn->n;
@@ -526,38 +545,64 @@
 {
 	struct ni_65xx_private *devpriv = dev->private;
 
-	if (insn->n < 1)
+	switch (data[0]) {
+	case INSN_CONFIG_CHANGE_NOTIFY:
+		/* add instruction to check_insn_config_length() */
+		if (insn->n != 3)
+			return -EINVAL;
+
+		/*
+		 * This only works for the first 4 ports (32 channels)!
+		 */
+
+		/* set the channels to monitor for rising edges */
+		writeb(data[1] & 0xff,
+		       devpriv->mmio + NI_65XX_RISE_EDGE_ENA_REG(0));
+		writeb((data[1] >> 8) & 0xff,
+		       devpriv->mmio + NI_65XX_RISE_EDGE_ENA_REG(1));
+		writeb((data[1] >> 16) & 0xff,
+		       devpriv->mmio + NI_65XX_RISE_EDGE_ENA_REG(2));
+		writeb((data[1] >> 24) & 0xff,
+		       devpriv->mmio + NI_65XX_RISE_EDGE_ENA_REG(3));
+
+		/* set the channels to monitor for falling edges */
+		writeb(data[2] & 0xff,
+		       devpriv->mmio + NI_65XX_FALL_EDGE_ENA_REG(0));
+		writeb((data[2] >> 8) & 0xff,
+		       devpriv->mmio + NI_65XX_FALL_EDGE_ENA_REG(1));
+		writeb((data[2] >> 16) & 0xff,
+		       devpriv->mmio + NI_65XX_FALL_EDGE_ENA_REG(2));
+		writeb((data[2] >> 24) & 0xff,
+		       devpriv->mmio + NI_65XX_FALL_EDGE_ENA_REG(3));
+		break;
+	default:
 		return -EINVAL;
-	if (data[0] != INSN_CONFIG_CHANGE_NOTIFY)
-		return -EINVAL;
+	}
 
-	writeb(data[1],
-	       devpriv->mite->daq_io_addr +
-	       Rising_Edge_Detection_Enable(0));
-	writeb(data[1] >> 8,
-	       devpriv->mite->daq_io_addr +
-	       Rising_Edge_Detection_Enable(0x10));
-	writeb(data[1] >> 16,
-	       devpriv->mite->daq_io_addr +
-	       Rising_Edge_Detection_Enable(0x20));
-	writeb(data[1] >> 24,
-	       devpriv->mite->daq_io_addr +
-	       Rising_Edge_Detection_Enable(0x30));
+	return insn->n;
+}
 
-	writeb(data[2],
-	       devpriv->mite->daq_io_addr +
-	       Falling_Edge_Detection_Enable(0));
-	writeb(data[2] >> 8,
-	       devpriv->mite->daq_io_addr +
-	       Falling_Edge_Detection_Enable(0x10));
-	writeb(data[2] >> 16,
-	       devpriv->mite->daq_io_addr +
-	       Falling_Edge_Detection_Enable(0x20));
-	writeb(data[2] >> 24,
-	       devpriv->mite->daq_io_addr +
-	       Falling_Edge_Detection_Enable(0x30));
+/* ripped from mite.h and mite_setup2() to avoid mite dependancy */
+#define MITE_IODWBSR	0xc0	 /* IO Device Window Base Size Register */
+#define WENAB		(1 << 7) /* window enable */
 
-	return 2;
+static int ni_65xx_mite_init(struct pci_dev *pcidev)
+{
+	void __iomem *mite_base;
+	u32 main_phys_addr;
+
+	/* ioremap the MITE registers (BAR 0) temporarily */
+	mite_base = pci_ioremap_bar(pcidev, 0);
+	if (!mite_base)
+		return -ENOMEM;
+
+	/* set data window to main registers (BAR 1) */
+	main_phys_addr = pci_resource_start(pcidev, 1);
+	writel(main_phys_addr | WENAB, mite_base + MITE_IODWBSR);
+
+	/* finished with MITE registers */
+	iounmap(mite_base);
+	return 0;
 }
 
 static int ni_65xx_auto_attach(struct comedi_device *dev,
@@ -566,7 +611,6 @@
 	struct pci_dev *pcidev = comedi_to_pci_dev(dev);
 	const struct ni_65xx_board *board = NULL;
 	struct ni_65xx_private *devpriv;
-	struct ni_65xx_subdevice_private *spriv;
 	struct comedi_subdevice *s;
 	unsigned i;
 	int ret;
@@ -586,19 +630,27 @@
 	if (!devpriv)
 		return -ENOMEM;
 
-	devpriv->mite = mite_alloc(pcidev);
-	if (!devpriv->mite)
+	ret = ni_65xx_mite_init(pcidev);
+	if (ret)
+		return ret;
+
+	devpriv->mmio = pci_ioremap_bar(pcidev, 1);
+	if (!devpriv->mmio)
 		return -ENOMEM;
 
-	ret = mite_setup(devpriv->mite);
-	if (ret < 0) {
-		dev_warn(dev->class_dev, "error setting up mite\n");
-		return ret;
+	writeb(NI_65XX_CLR_EDGE_INT | NI_65XX_CLR_OVERFLOW_INT,
+	       devpriv->mmio + NI_65XX_CLR_REG);
+	writeb(0x00, devpriv->mmio + NI_65XX_CTRL_REG);
+
+	if (pcidev->irq) {
+		ret = request_irq(pcidev->irq, ni_65xx_interrupt, IRQF_SHARED,
+				  dev->board_name, dev);
+		if (ret == 0)
+			dev->irq = pcidev->irq;
 	}
 
-	dev->irq = pcidev->irq;
 	dev_info(dev->class_dev, "board: %s, ID=0x%02x", dev->board_name,
-	       readb(devpriv->mite->daq_io_addr + ID_Register));
+	       readb(devpriv->mmio + NI_65XX_ID_REG));
 
 	ret = comedi_alloc_subdevices(dev, 4);
 	if (ret)
@@ -606,101 +658,90 @@
 
 	s = &dev->subdevices[0];
 	if (board->num_di_ports) {
-		s->type = COMEDI_SUBD_DI;
-		s->subdev_flags = SDF_READABLE;
-		s->n_chan =
-		    board->num_di_ports * ni_65xx_channels_per_port;
-		s->range_table = &range_digital;
-		s->maxdata = 1;
-		s->insn_config = ni_65xx_dio_insn_config;
-		s->insn_bits = ni_65xx_dio_insn_bits;
-		spriv = comedi_alloc_spriv(s, sizeof(*spriv));
-		if (!spriv)
-			return -ENOMEM;
-		spriv->base_port = 0;
+		s->type		= COMEDI_SUBD_DI;
+		s->subdev_flags	= SDF_READABLE;
+		s->n_chan	= NI_65XX_PORT_TO_CHAN(board->num_di_ports);
+		s->maxdata	= 1;
+		s->range_table	= &range_digital;
+		s->insn_bits	= ni_65xx_dio_insn_bits;
+		s->insn_config	= ni_65xx_dio_insn_config;
+
+		/* the input ports always start at port 0 */
+		s->private = (void *)0;
 	} else {
-		s->type = COMEDI_SUBD_UNUSED;
+		s->type		= COMEDI_SUBD_UNUSED;
 	}
 
 	s = &dev->subdevices[1];
 	if (board->num_do_ports) {
-		s->type = COMEDI_SUBD_DO;
-		s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
-		s->n_chan =
-		    board->num_do_ports * ni_65xx_channels_per_port;
-		s->range_table = &range_digital;
-		s->maxdata = 1;
-		s->insn_bits = ni_65xx_dio_insn_bits;
-		spriv = comedi_alloc_spriv(s, sizeof(*spriv));
-		if (!spriv)
-			return -ENOMEM;
-		spriv->base_port = board->num_di_ports;
+		s->type		= COMEDI_SUBD_DO;
+		s->subdev_flags	= SDF_WRITABLE;
+		s->n_chan	= NI_65XX_PORT_TO_CHAN(board->num_do_ports);
+		s->maxdata	= 1;
+		s->range_table	= &range_digital;
+		s->insn_bits	= ni_65xx_dio_insn_bits;
+
+		/* the output ports always start after the input ports */
+		s->private = (void *)(unsigned long)board->num_di_ports;
+
+		/*
+		 * Use the io_bits to handle the inverted outputs.  Inverted
+		 * outputs are only supported if the "legacy_invert_outputs"
+		 * module parameter is set to "true".
+		 */
+		if (ni_65xx_legacy_invert_outputs && board->legacy_invert)
+			s->io_bits = 0xff;
+
+		/* reset all output ports to comedi '0' */
+		for (i = 0; i < board->num_do_ports; ++i) {
+			writeb(s->io_bits,	/* inverted if necessary */
+			       devpriv->mmio +
+			       NI_65XX_IO_DATA_REG(board->num_di_ports + i));
+		}
 	} else {
-		s->type = COMEDI_SUBD_UNUSED;
+		s->type		= COMEDI_SUBD_UNUSED;
 	}
 
 	s = &dev->subdevices[2];
 	if (board->num_dio_ports) {
-		s->type = COMEDI_SUBD_DIO;
-		s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
-		s->n_chan =
-		    board->num_dio_ports * ni_65xx_channels_per_port;
-		s->range_table = &range_digital;
-		s->maxdata = 1;
-		s->insn_config = ni_65xx_dio_insn_config;
-		s->insn_bits = ni_65xx_dio_insn_bits;
-		spriv = comedi_alloc_spriv(s, sizeof(*spriv));
-		if (!spriv)
-			return -ENOMEM;
-		spriv->base_port = 0;
+		s->type		= COMEDI_SUBD_DIO;
+		s->subdev_flags	= SDF_READABLE | SDF_WRITABLE;
+		s->n_chan	= NI_65XX_PORT_TO_CHAN(board->num_dio_ports);
+		s->maxdata	= 1;
+		s->range_table	= &range_digital;
+		s->insn_bits	= ni_65xx_dio_insn_bits;
+		s->insn_config	= ni_65xx_dio_insn_config;
+
+		/* the input/output ports always start at port 0 */
+		s->private = (void *)0;
+
+		/* configure all ports for input */
 		for (i = 0; i < board->num_dio_ports; ++i) {
-			/*  configure all ports for input */
-			writeb(0x1,
-			       devpriv->mite->daq_io_addr +
-			       Port_Select(i));
+			writeb(NI_65XX_IO_SEL_INPUT,
+			       devpriv->mmio + NI_65XX_IO_SEL_REG(i));
 		}
 	} else {
-		s->type = COMEDI_SUBD_UNUSED;
+		s->type		= COMEDI_SUBD_UNUSED;
 	}
 
 	s = &dev->subdevices[3];
-	dev->read_subdev = s;
-	s->type = COMEDI_SUBD_DI;
-	s->subdev_flags = SDF_READABLE | SDF_CMD_READ;
-	s->n_chan = 1;
-	s->range_table = &range_unknown;
-	s->maxdata = 1;
-	s->len_chanlist	= 1;
-	s->do_cmdtest = ni_65xx_intr_cmdtest;
-	s->do_cmd = ni_65xx_intr_cmd;
-	s->cancel = ni_65xx_intr_cancel;
-	s->insn_bits = ni_65xx_intr_insn_bits;
-	s->insn_config = ni_65xx_intr_insn_config;
-
-	for (i = 0; i < ni_65xx_total_num_ports(board); ++i) {
-		writeb(0x00,
-		       devpriv->mite->daq_io_addr + Filter_Enable(i));
-		if (board->invert_outputs)
-			writeb(0x01,
-			       devpriv->mite->daq_io_addr + Port_Data(i));
-		else
-			writeb(0x00,
-			       devpriv->mite->daq_io_addr + Port_Data(i));
+	s->type		= COMEDI_SUBD_DI;
+	s->subdev_flags	= SDF_READABLE;
+	s->n_chan	= 1;
+	s->maxdata	= 1;
+	s->range_table	= &range_digital;
+	s->insn_bits	= ni_65xx_intr_insn_bits;
+	if (dev->irq) {
+		dev->read_subdev = s;
+		s->subdev_flags	|= SDF_CMD_READ;
+		s->len_chanlist	= 1;
+		s->insn_config	= ni_65xx_intr_insn_config;
+		s->do_cmdtest	= ni_65xx_intr_cmdtest;
+		s->do_cmd	= ni_65xx_intr_cmd;
+		s->cancel	= ni_65xx_intr_cancel;
 	}
-	writeb(ClrEdge | ClrOverflow,
-	       devpriv->mite->daq_io_addr + Clear_Register);
-	writeb(0x00,
-	       devpriv->mite->daq_io_addr + Master_Interrupt_Control);
 
-	/* Set filter interval to 0  (32bit reg) */
-	writeb(0x00000000, devpriv->mite->daq_io_addr + Filter_Interval);
-
-	ret = request_irq(dev->irq, ni_65xx_interrupt, IRQF_SHARED,
-			  "ni_65xx", dev);
-	if (ret < 0) {
-		dev->irq = 0;
-		dev_warn(dev->class_dev, "irq not available\n");
-	}
+	ni_65xx_disable_input_filters(dev);
 
 	return 0;
 }
@@ -709,23 +750,20 @@
 {
 	struct ni_65xx_private *devpriv = dev->private;
 
-	if (devpriv && devpriv->mite && devpriv->mite->daq_io_addr) {
-		writeb(0x00,
-		       devpriv->mite->daq_io_addr +
-		       Master_Interrupt_Control);
+	if (devpriv && devpriv->mmio) {
+		writeb(0x00, devpriv->mmio + NI_65XX_CTRL_REG);
+		iounmap(devpriv->mmio);
 	}
 	if (dev->irq)
 		free_irq(dev->irq, dev);
-	if (devpriv)
-		mite_detach(devpriv->mite);
 	comedi_pci_disable(dev);
 }
 
 static struct comedi_driver ni_65xx_driver = {
-	.driver_name = "ni_65xx",
-	.module = THIS_MODULE,
-	.auto_attach = ni_65xx_auto_attach,
-	.detach = ni_65xx_detach,
+	.driver_name	= "ni_65xx",
+	.module		= THIS_MODULE,
+	.auto_attach	= ni_65xx_auto_attach,
+	.detach		= ni_65xx_detach,
 };
 
 static int ni_65xx_pci_probe(struct pci_dev *dev,
@@ -770,5 +808,5 @@
 module_comedi_pci_driver(ni_65xx_driver, ni_65xx_pci_driver);
 
 MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("Comedi driver for NI PCI-65xx static dio boards");
 MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c
index 27d435f..20fe692 100644
--- a/drivers/staging/comedi/drivers/ni_660x.c
+++ b/drivers/staging/comedi/drivers/ni_660x.c
@@ -28,7 +28,7 @@
  *
  * Encoders work.  PulseGeneration (both single pulse and pulse train)
  * works.  Buffered commands work for input but not output.
- * 
+ *
  * References:
  * DAQ 660x Register-Level Programmer Manual  (NI 370505A-01)
  * DAQ 6601/6602 User Manual (NI 322137B-01)
@@ -161,6 +161,7 @@
 static inline unsigned IOConfigReg(unsigned pfi_channel)
 {
 	unsigned reg = NI660X_IO_CFG_0_1 + pfi_channel / 2;
+
 	BUG_ON(reg > NI660X_IO_CFG_38_39);
 	return reg;
 }
@@ -310,10 +311,7 @@
 /* ioconfigreg */
 static inline unsigned ioconfig_bitshift(unsigned pfi_channel)
 {
-	if (pfi_channel % 2)
-		return 0;
-	else
-		return 8;
+	return (pfi_channel % 2) ? 0 : 8;
 }
 
 static inline unsigned pfi_output_select_mask(unsigned pfi_channel)
@@ -619,10 +617,8 @@
 	switch (registerData[reg].size) {
 	case DATA_2B:
 		return readw(read_address);
-		break;
 	case DATA_4B:
 		return readl(read_address);
-		break;
 	default:
 		BUG();
 		break;
@@ -714,8 +710,8 @@
 					 mite_ring(devpriv, counter));
 	if (mite_chan == NULL) {
 		spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
-		comedi_error(dev,
-			     "failed to reserve mite dma channel for counter.");
+		dev_err(dev->class_dev,
+			"failed to reserve mite dma channel for counter\n");
 		return -EBUSY;
 	}
 	mite_chan->dir = direction;
@@ -749,8 +745,8 @@
 
 	retval = ni_660x_request_mite_channel(dev, counter, COMEDI_INPUT);
 	if (retval) {
-		comedi_error(dev,
-			     "no dma channel available for use by counter");
+		dev_err(dev->class_dev,
+			"no dma channel available for use by counter\n");
 		return retval;
 	}
 	ni_tio_acknowledge_and_confirm(counter, NULL, NULL, NULL, NULL);
@@ -829,8 +825,7 @@
 }
 
 static int ni_660x_buf_change(struct comedi_device *dev,
-			      struct comedi_subdevice *s,
-			      unsigned long new_size)
+			      struct comedi_subdevice *s)
 {
 	struct ni_660x_private *devpriv = dev->private;
 	struct ni_gpct *counter = s->private;
@@ -1126,9 +1121,8 @@
 		s = &dev->subdevices[NI_660X_GPCT_SUBDEV(i)];
 		if (i < ni_660x_num_counters(dev)) {
 			s->type = COMEDI_SUBD_COUNTER;
-			s->subdev_flags =
-			    SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL |
-			    SDF_CMD_READ /* | SDF_CMD_WRITE */ ;
+			s->subdev_flags = SDF_READABLE | SDF_WRITABLE |
+					  SDF_LSAMPL | SDF_CMD_READ;
 			s->n_chan = 3;
 			s->maxdata = 0xffffffff;
 			s->insn_read = ni_tio_insn_read;
@@ -1170,8 +1164,8 @@
 	for (i = 0; i < board->n_chips; ++i)
 		set_tio_counterswap(dev, i);
 
-	ret = request_irq(pcidev->irq, ni_660x_interrupt,
-			  IRQF_SHARED, "ni_660x", dev);
+	ret = request_irq(pcidev->irq, ni_660x_interrupt, IRQF_SHARED,
+			  dev->board_name, dev);
 	if (ret < 0) {
 		dev_warn(dev->class_dev, " irq not available\n");
 		return ret;
diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c
index b487f8d..a054bd5 100644
--- a/drivers/staging/comedi/drivers/ni_670x.c
+++ b/drivers/staging/comedi/drivers/ni_670x.c
@@ -39,11 +39,10 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 
 #include "../comedidev.h"
 
-#include "mite.h"
-
 #define AO_VALUE_OFFSET			0x00
 #define	AO_CHAN_OFFSET			0x0c
 #define	AO_STATUS_OFFSET		0x10
@@ -82,8 +81,7 @@
 };
 
 struct ni_670x_private {
-
-	struct mite_struct *mite;
+	void __iomem *mmio;
 	int boardtype;
 	int dio;
 	unsigned int ao_readback[32];
@@ -111,9 +109,9 @@
 	for (i = 0; i < insn->n; i++) {
 		/* First write in channel register which channel to use */
 		writel(((chan & 15) << 1) | ((chan & 16) >> 4),
-		       devpriv->mite->daq_io_addr + AO_CHAN_OFFSET);
+		       devpriv->mmio + AO_CHAN_OFFSET);
 		/* write channel value */
-		writel(data[i], devpriv->mite->daq_io_addr + AO_VALUE_OFFSET);
+		writel(data[i], devpriv->mmio + AO_VALUE_OFFSET);
 		devpriv->ao_readback[chan] = data[i];
 	}
 
@@ -140,8 +138,7 @@
 				 unsigned int *data)
 {
 	struct ni_670x_private *devpriv = dev->private;
-	void __iomem *io_addr = devpriv->mite->daq_io_addr +
-					DIO_PORT0_DATA_OFFSET;
+	void __iomem *io_addr = devpriv->mmio + DIO_PORT0_DATA_OFFSET;
 
 	if (comedi_dio_update_state(s, data))
 		writel(s->state, io_addr);
@@ -163,11 +160,34 @@
 	if (ret)
 		return ret;
 
-	writel(s->io_bits, devpriv->mite->daq_io_addr + DIO_PORT0_DIR_OFFSET);
+	writel(s->io_bits, devpriv->mmio + DIO_PORT0_DIR_OFFSET);
 
 	return insn->n;
 }
 
+/* ripped from mite.h and mite_setup2() to avoid mite dependancy */
+#define MITE_IODWBSR	0xc0	 /* IO Device Window Base Size Register */
+#define WENAB		(1 << 7) /* window enable */
+
+static int ni_670x_mite_init(struct pci_dev *pcidev)
+{
+	void __iomem *mite_base;
+	u32 main_phys_addr;
+
+	/* ioremap the MITE registers (BAR 0) temporarily */
+	mite_base = pci_ioremap_bar(pcidev, 0);
+	if (!mite_base)
+		return -ENOMEM;
+
+	/* set data window to main registers (BAR 1) */
+	main_phys_addr = pci_resource_start(pcidev, 1);
+	writel(main_phys_addr | WENAB, mite_base + MITE_IODWBSR);
+
+	/* finished with MITE registers */
+	iounmap(mite_base);
+	return 0;
+}
+
 static int ni_670x_auto_attach(struct comedi_device *dev,
 			       unsigned long context)
 {
@@ -193,15 +213,13 @@
 	if (!devpriv)
 		return -ENOMEM;
 
-	devpriv->mite = mite_alloc(pcidev);
-	if (!devpriv->mite)
-		return -ENOMEM;
-
-	ret = mite_setup(devpriv->mite);
-	if (ret < 0) {
-		dev_warn(dev->class_dev, "error setting up mite\n");
+	ret = ni_670x_mite_init(pcidev);
+	if (ret)
 		return ret;
-	}
+
+	devpriv->mmio = pci_ioremap_bar(pcidev, 1);
+	if (!devpriv->mmio)
+		return -ENOMEM;
 
 	ret = comedi_alloc_subdevices(dev, 2);
 	if (ret)
@@ -242,9 +260,9 @@
 	s->insn_config = ni_670x_dio_insn_config;
 
 	/* Config of misc registers */
-	writel(0x10, devpriv->mite->daq_io_addr + MISC_CONTROL_OFFSET);
+	writel(0x10, devpriv->mmio + MISC_CONTROL_OFFSET);
 	/* Config of ao registers */
-	writel(0x00, devpriv->mite->daq_io_addr + AO_CONTROL_OFFSET);
+	writel(0x00, devpriv->mmio + AO_CONTROL_OFFSET);
 
 	return 0;
 }
@@ -259,8 +277,8 @@
 		if (s)
 			kfree(s->range_table_list);
 	}
-	if (devpriv)
-		mite_detach(devpriv->mite);
+	if (devpriv && devpriv->mmio)
+		iounmap(devpriv->mmio);
 	comedi_pci_disable(dev);
 }
 
diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c
index 5bd19494..de67161 100644
--- a/drivers/staging/comedi/drivers/ni_at_a2150.c
+++ b/drivers/staging/comedi/drivers/ni_at_a2150.c
@@ -71,7 +71,6 @@
 #include "8253.h"
 #include "comedi_fc.h"
 
-#define A2150_SIZE           28
 #define A2150_DMA_BUFFER_SIZE	0xff00	/*  size in bytes of dma buffer */
 
 /* Registers and bits */
@@ -156,13 +155,6 @@
 	int config_bits;	/*  config register bits */
 };
 
-static int a2150_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
-
-static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
-			    int flags);
-static int a2150_set_chanlist(struct comedi_device *dev,
-			      unsigned int start_channel,
-			      unsigned int num_channels);
 /* interrupt service routine */
 static irqreturn_t a2150_interrupt(int irq, void *d)
 {
@@ -179,7 +171,7 @@
 	static const int sample_size = sizeof(devpriv->dma_buffer[0]);
 
 	if (!dev->attached) {
-		comedi_error(dev, "premature interrupt");
+		dev_err(dev->class_dev, "premature interrupt\n");
 		return IRQ_HANDLED;
 	}
 	/*  initialize async here to make sure s is not NULL */
@@ -189,18 +181,19 @@
 	status = inw(dev->iobase + STATUS_REG);
 
 	if ((status & INTR_BIT) == 0) {
-		comedi_error(dev, "spurious interrupt");
+		dev_err(dev->class_dev, "spurious interrupt\n");
 		return IRQ_NONE;
 	}
 
 	if (status & OVFL_BIT) {
-		comedi_error(dev, "fifo overflow");
+		dev_err(dev->class_dev, "fifo overflow\n");
 		async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
 		cfc_handle_events(dev, s);
 	}
 
 	if ((status & DMA_TC_BIT) == 0) {
-		comedi_error(dev, "caught non-dma interrupt?  Aborting.");
+		dev_err(dev->class_dev,
+			"caught non-dma interrupt?  Aborting.\n");
 		async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
 		cfc_handle_events(dev, s);
 		return IRQ_HANDLED;
@@ -287,6 +280,117 @@
 	return 0;
 }
 
+/*
+ * sets bits in devpriv->clock_bits to nearest approximation of requested
+ * period, adjusts requested period to actual timing.
+ */
+static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
+			    unsigned int flags)
+{
+	const struct a2150_board *thisboard = comedi_board(dev);
+	struct a2150_private *devpriv = dev->private;
+	int lub, glb, temp;
+	int lub_divisor_shift, lub_index, glb_divisor_shift, glb_index;
+	int i, j;
+
+	/*  initialize greatest lower and least upper bounds */
+	lub_divisor_shift = 3;
+	lub_index = 0;
+	lub = thisboard->clock[lub_index] * (1 << lub_divisor_shift);
+	glb_divisor_shift = 0;
+	glb_index = thisboard->num_clocks - 1;
+	glb = thisboard->clock[glb_index] * (1 << glb_divisor_shift);
+
+	/*  make sure period is in available range */
+	if (*period < glb)
+		*period = glb;
+	if (*period > lub)
+		*period = lub;
+
+	/*  we can multiply period by 1, 2, 4, or 8, using (1 << i) */
+	for (i = 0; i < 4; i++) {
+		/*  there are a maximum of 4 master clocks */
+		for (j = 0; j < thisboard->num_clocks; j++) {
+			/*  temp is the period in nanosec we are evaluating */
+			temp = thisboard->clock[j] * (1 << i);
+			/*  if it is the best match yet */
+			if (temp < lub && temp >= *period) {
+				lub_divisor_shift = i;
+				lub_index = j;
+				lub = temp;
+			}
+			if (temp > glb && temp <= *period) {
+				glb_divisor_shift = i;
+				glb_index = j;
+				glb = temp;
+			}
+		}
+	}
+	switch (flags & TRIG_ROUND_MASK) {
+	case TRIG_ROUND_NEAREST:
+	default:
+		/*  if least upper bound is better approximation */
+		if (lub - *period < *period - glb)
+			*period = lub;
+		else
+			*period = glb;
+		break;
+	case TRIG_ROUND_UP:
+		*period = lub;
+		break;
+	case TRIG_ROUND_DOWN:
+		*period = glb;
+		break;
+	}
+
+	/*  set clock bits for config register appropriately */
+	devpriv->config_bits &= ~CLOCK_MASK;
+	if (*period == lub) {
+		devpriv->config_bits |=
+		    CLOCK_SELECT_BITS(lub_index) |
+		    CLOCK_DIVISOR_BITS(lub_divisor_shift);
+	} else {
+		devpriv->config_bits |=
+		    CLOCK_SELECT_BITS(glb_index) |
+		    CLOCK_DIVISOR_BITS(glb_divisor_shift);
+	}
+
+	return 0;
+}
+
+static int a2150_set_chanlist(struct comedi_device *dev,
+			      unsigned int start_channel,
+			      unsigned int num_channels)
+{
+	struct a2150_private *devpriv = dev->private;
+
+	if (start_channel + num_channels > 4)
+		return -1;
+
+	devpriv->config_bits &= ~CHANNEL_MASK;
+
+	switch (num_channels) {
+	case 1:
+		devpriv->config_bits |= CHANNEL_BITS(0x4 | start_channel);
+		break;
+	case 2:
+		if (start_channel == 0)
+			devpriv->config_bits |= CHANNEL_BITS(0x2);
+		else if (start_channel == 2)
+			devpriv->config_bits |= CHANNEL_BITS(0x3);
+		else
+			return -1;
+		break;
+	case 4:
+		devpriv->config_bits |= CHANNEL_BITS(0x1);
+		break;
+	default:
+		return -1;
+	}
+
+	return 0;
+}
+
 static int a2150_ai_check_chanlist(struct comedi_device *dev,
 				   struct comedi_subdevice *s,
 				   struct comedi_cmd *cmd)
@@ -408,8 +512,8 @@
 	unsigned int trigger_bits;
 
 	if (cmd->flags & TRIG_RT) {
-		comedi_error(dev,
-			     " dma incompatible with hard real-time interrupt (TRIG_RT), aborting");
+		dev_err(dev->class_dev,
+			"dma incompatible with hard real-time interrupt (TRIG_RT), aborting\n");
 		return -1;
 	}
 	/*  clear fifo and reset triggering circuitry */
@@ -490,7 +594,7 @@
 		trigger_bits |= HW_TRIG_EN;
 	} else if (cmd->start_src == TRIG_OTHER) {
 		/*  XXX add support for level/slope start trigger using TRIG_OTHER */
-		comedi_error(dev, "you shouldn't see this?");
+		dev_err(dev->class_dev, "you shouldn't see this?\n");
 	}
 	/*  send trigger config bits */
 	outw(trigger_bits, dev->iobase + TRIGGER_REG);
@@ -574,123 +678,11 @@
 	return n;
 }
 
-/*
- * sets bits in devpriv->clock_bits to nearest approximation of requested
- * period, adjusts requested period to actual timing.
- */
-static int a2150_get_timing(struct comedi_device *dev, unsigned int *period,
-			    int flags)
-{
-	const struct a2150_board *thisboard = comedi_board(dev);
-	struct a2150_private *devpriv = dev->private;
-	int lub, glb, temp;
-	int lub_divisor_shift, lub_index, glb_divisor_shift, glb_index;
-	int i, j;
-
-	/*  initialize greatest lower and least upper bounds */
-	lub_divisor_shift = 3;
-	lub_index = 0;
-	lub = thisboard->clock[lub_index] * (1 << lub_divisor_shift);
-	glb_divisor_shift = 0;
-	glb_index = thisboard->num_clocks - 1;
-	glb = thisboard->clock[glb_index] * (1 << glb_divisor_shift);
-
-	/*  make sure period is in available range */
-	if (*period < glb)
-		*period = glb;
-	if (*period > lub)
-		*period = lub;
-
-	/*  we can multiply period by 1, 2, 4, or 8, using (1 << i) */
-	for (i = 0; i < 4; i++) {
-		/*  there are a maximum of 4 master clocks */
-		for (j = 0; j < thisboard->num_clocks; j++) {
-			/*  temp is the period in nanosec we are evaluating */
-			temp = thisboard->clock[j] * (1 << i);
-			/*  if it is the best match yet */
-			if (temp < lub && temp >= *period) {
-				lub_divisor_shift = i;
-				lub_index = j;
-				lub = temp;
-			}
-			if (temp > glb && temp <= *period) {
-				glb_divisor_shift = i;
-				glb_index = j;
-				glb = temp;
-			}
-		}
-	}
-	flags &= TRIG_ROUND_MASK;
-	switch (flags) {
-	case TRIG_ROUND_NEAREST:
-	default:
-		/*  if least upper bound is better approximation */
-		if (lub - *period < *period - glb)
-			*period = lub;
-		else
-			*period = glb;
-		break;
-	case TRIG_ROUND_UP:
-		*period = lub;
-		break;
-	case TRIG_ROUND_DOWN:
-		*period = glb;
-		break;
-	}
-
-	/*  set clock bits for config register appropriately */
-	devpriv->config_bits &= ~CLOCK_MASK;
-	if (*period == lub) {
-		devpriv->config_bits |=
-		    CLOCK_SELECT_BITS(lub_index) |
-		    CLOCK_DIVISOR_BITS(lub_divisor_shift);
-	} else {
-		devpriv->config_bits |=
-		    CLOCK_SELECT_BITS(glb_index) |
-		    CLOCK_DIVISOR_BITS(glb_divisor_shift);
-	}
-
-	return 0;
-}
-
-static int a2150_set_chanlist(struct comedi_device *dev,
-			      unsigned int start_channel,
-			      unsigned int num_channels)
-{
-	struct a2150_private *devpriv = dev->private;
-
-	if (start_channel + num_channels > 4)
-		return -1;
-
-	devpriv->config_bits &= ~CHANNEL_MASK;
-
-	switch (num_channels) {
-	case 1:
-		devpriv->config_bits |= CHANNEL_BITS(0x4 | start_channel);
-		break;
-	case 2:
-		if (start_channel == 0)
-			devpriv->config_bits |= CHANNEL_BITS(0x2);
-		else if (start_channel == 2)
-			devpriv->config_bits |= CHANNEL_BITS(0x3);
-		else
-			return -1;
-		break;
-	case 4:
-		devpriv->config_bits |= CHANNEL_BITS(0x1);
-		break;
-	default:
-		return -1;
-		break;
-	}
-
-	return 0;
-}
-
 /* probes board type, returns offset */
 static int a2150_probe(struct comedi_device *dev)
 {
 	int status = inw(dev->iobase + STATUS_REG);
+
 	return ID_BITS(status);
 }
 
@@ -709,7 +701,7 @@
 	if (!devpriv)
 		return -ENOMEM;
 
-	ret = comedi_request_region(dev, it->options[0], A2150_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x1c);
 	if (ret)
 		return ret;
 
@@ -784,8 +776,8 @@
 		udelay(1000);
 	}
 	if (i == timeout) {
-		printk
-		    (" timed out waiting for offset calibration to complete\n");
+		dev_err(dev->class_dev,
+			"timed out waiting for offset calibration to complete\n");
 		return -ETIME;
 	}
 	devpriv->config_bits |= ENABLE0_BIT | ENABLE1_BIT;
diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/staging/comedi/drivers/ni_atmio.c
index d7ee6bd..2bd9f69 100644
--- a/drivers/staging/comedi/drivers/ni_atmio.c
+++ b/drivers/staging/comedi/drivers/ni_atmio.c
@@ -108,66 +108,58 @@
 		.device_id	= 44,
 		.isapnp_id	= 0x0000,	/* XXX unknown */
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 8192,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 800,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { mb88341 },
 	}, {
 		.name		= "at-mio-16e-2",
 		.device_id	= 25,
 		.isapnp_id	= 0x1900,
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 2048,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 2000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { mb88341 },
 	}, {
 		.name		= "at-mio-16e-10",
 		.device_id	= 36,
 		.isapnp_id	= 0x2400,
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 512,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 10000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 10000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },
 	}, {
 		.name		= "at-mio-16de-10",
 		.device_id	= 37,
 		.isapnp_id	= 0x2500,
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 512,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 10000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 10000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },
 		.has_8255	= 1,
 	}, {
@@ -175,63 +167,57 @@
 		.device_id	= 38,
 		.isapnp_id	= 0x2600,
 		.n_adchan	= 64,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 2048,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 2000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },
 	}, {
 		.name		= "at-mio-16xe-50",
 		.device_id	= 39,
 		.isapnp_id	= 0x2700,
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_8,
 		.ai_speed	= 50000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 50000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { dac8800, dac8043 },
 	}, {
 		.name		= "at-mio-16xe-10",
 		.device_id	= 50,
 		.isapnp_id	= 0x0000,	/* XXX unknown */
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_14,
 		.ai_speed	= 10000,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { dac8800, dac8043, ad8522 },
 	}, {
 		.name		= "at-ai-16xe-10",
 		.device_id	= 51,
 		.isapnp_id	= 0x0000,	/* XXX unknown */
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,	/* unknown */
 		.gainlkup	= ai_gain_14,
 		.ai_speed	= 10000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { dac8800, dac8043, ad8522 },
 	},
 };
@@ -267,20 +253,17 @@
 		if (isapnp_dev == NULL || isapnp_dev->card == NULL)
 			continue;
 
-		if (pnp_device_attach(isapnp_dev) < 0) {
-			printk
-			 ("ni_atmio: %s found but already active, skipping.\n",
-			  ni_boards[i].name);
+		if (pnp_device_attach(isapnp_dev) < 0)
 			continue;
-		}
+
 		if (pnp_activate_dev(isapnp_dev) < 0) {
 			pnp_device_detach(isapnp_dev);
 			return -EAGAIN;
 		}
-		if (!pnp_port_valid(isapnp_dev, 0)
-		    || !pnp_irq_valid(isapnp_dev, 0)) {
+
+		if (!pnp_port_valid(isapnp_dev, 0) ||
+		    !pnp_irq_valid(isapnp_dev, 0)) {
 			pnp_device_detach(isapnp_dev);
-			printk("ni_atmio: pnp invalid port or irq, aborting\n");
 			return -ENOMEM;
 		}
 		break;
@@ -302,11 +285,13 @@
 
 	}
 	if (device_id == 255)
-		printk(" can't find board\n");
+		dev_err(dev->class_dev, "can't find board\n");
 	 else if (device_id == 0)
-		printk(" EEPROM read error (?) or device not found\n");
+		dev_err(dev->class_dev,
+			"EEPROM read error (?) or device not found\n");
 	 else
-		printk(" unknown device ID %d -- contact author\n", device_id);
+		dev_err(dev->class_dev,
+			"unknown device ID %d -- contact author\n", device_id);
 
 	return -1;
 }
@@ -352,25 +337,17 @@
 
 	dev->board_ptr = ni_boards + board;
 	boardtype = comedi_board(dev);
-
-	printk(" %s", boardtype->name);
 	dev->board_name = boardtype->name;
 
 	/* irq stuff */
 
 	if (irq != 0) {
-		if (irq > 15 || ni_irqpin[irq] == -1) {
-			printk(" invalid irq %u\n", irq);
+		if (irq > 15 || ni_irqpin[irq] == -1)
 			return -EINVAL;
-		}
-		printk(" ( irq = %u )", irq);
 		ret = request_irq(irq, ni_E_interrupt, 0,
-				  "ni_atmio", dev);
-
-		if (ret < 0) {
-			printk(" irq not available\n");
+				  dev->board_name, dev);
+		if (ret < 0)
 			return -EINVAL;
-		}
 		dev->irq = irq;
 	}
 
diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c
index b1b4744..9c08da9 100644
--- a/drivers/staging/comedi/drivers/ni_atmio16d.c
+++ b/drivers/staging/comedi/drivers/ni_atmio16d.c
@@ -94,8 +94,6 @@
 #define CLOCK_10_KHZ	0x8D25
 #define CLOCK_1_KHZ		0x8E25
 #define CLOCK_100_HZ	0x8F25
-/* Other miscellaneous defines */
-#define ATMIO16D_SIZE	32	/* bus address range */
 
 struct atmio16_board_t {
 
@@ -624,7 +622,7 @@
 	struct comedi_subdevice *s;
 	int ret;
 
-	ret = comedi_request_region(dev, it->options[0], ATMIO16D_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x20);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 3e3f940..51a6d4e 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -72,8 +72,6 @@
 #include "ni_labpc_regs.h"
 #include "ni_labpc_isadma.h"
 
-#define LABPC_SIZE		0x20	/* size of ISA io region */
-
 enum scan_mode {
 	MODE_SINGLE_CHAN,
 	MODE_SINGLE_CHAN_INTERVAL,
@@ -531,24 +529,26 @@
 
 static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd *cmd)
 {
+	unsigned int chan0;
+	unsigned int chan1;
+
 	if (cmd->chanlist_len == 1)
 		return MODE_SINGLE_CHAN;
 
-	/* chanlist may be NULL during cmdtest. */
+	/* chanlist may be NULL during cmdtest */
 	if (cmd->chanlist == NULL)
 		return MODE_MULT_CHAN_UP;
 
-	if (CR_CHAN(cmd->chanlist[0]) == CR_CHAN(cmd->chanlist[1]))
-		return MODE_SINGLE_CHAN_INTERVAL;
+	chan0 = CR_CHAN(cmd->chanlist[0]);
+	chan1 = CR_CHAN(cmd->chanlist[1]);
 
-	if (CR_CHAN(cmd->chanlist[0]) < CR_CHAN(cmd->chanlist[1]))
+	if (chan0 < chan1)
 		return MODE_MULT_CHAN_UP;
 
-	if (CR_CHAN(cmd->chanlist[0]) > CR_CHAN(cmd->chanlist[1]))
+	if (chan0 > chan1)
 		return MODE_MULT_CHAN_DOWN;
 
-	pr_err("ni_labpc: bug! cannot determine AI scan mode\n");
-	return 0;
+	return MODE_SINGLE_CHAN_INTERVAL;
 }
 
 static int labpc_ai_check_chanlist(struct comedi_device *dev,
@@ -895,7 +895,7 @@
 		devpriv->stat1 = devpriv->read_byte(dev->iobase + STAT1_REG);
 	}
 	if (i == timeout) {
-		comedi_error(dev, "ai timeout, fifo never empties");
+		dev_err(dev->class_dev, "ai timeout, fifo never empties\n");
 		async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
 		return -1;
 	}
@@ -926,7 +926,7 @@
 	struct comedi_cmd *cmd;
 
 	if (!dev->attached) {
-		comedi_error(dev, "premature interrupt");
+		dev_err(dev->class_dev, "premature interrupt\n");
 		return IRQ_HANDLED;
 	}
 
@@ -950,7 +950,7 @@
 		devpriv->write_byte(0x1, dev->iobase + ADC_FIFO_CLEAR_REG);
 		async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
 		cfc_handle_events(dev, s);
-		comedi_error(dev, "overrun");
+		dev_err(dev->class_dev, "overrun\n");
 		return IRQ_HANDLED;
 	}
 
@@ -960,7 +960,7 @@
 		labpc_drain_fifo(dev);
 
 	if (devpriv->stat1 & STAT1_CNTINT) {
-		comedi_error(dev, "handled timer interrupt?");
+		dev_err(dev->class_dev, "handled timer interrupt?\n");
 		/*  clear it */
 		devpriv->write_byte(0x1, dev->iobase + TIMER_CLEAR_REG);
 	}
@@ -970,7 +970,7 @@
 		devpriv->write_byte(0x1, dev->iobase + ADC_FIFO_CLEAR_REG);
 		async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
 		cfc_handle_events(dev, s);
-		comedi_error(dev, "overflow");
+		dev_err(dev->class_dev, "overflow\n");
 		return IRQ_HANDLED;
 	}
 	/*  handle external stop trigger */
@@ -1051,9 +1051,9 @@
 	if (dir) {
 		writeb(data, (void __iomem *)(iobase + port));
 		return 0;
-	} else {
-		return readb((void __iomem *)(iobase + port));
 	}
+
+	return readb((void __iomem *)(iobase + port));
 }
 
 /* lowlevel write to eeprom/dac */
@@ -1186,7 +1186,7 @@
 			break;
 	}
 	if (i == timeout) {
-		comedi_error(dev, "eeprom write timed out");
+		dev_err(dev->class_dev, "eeprom write timed out\n");
 		return -ETIME;
 	}
 	/*  update software copy of eeprom */
@@ -1463,7 +1463,7 @@
 	if (!devpriv)
 		return -ENOMEM;
 
-	ret = comedi_request_region(dev, it->options[0], LABPC_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x20);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h
index 486589f..b159b4b 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.h
+++ b/drivers/staging/comedi/drivers/ni_labpc.h
@@ -36,7 +36,6 @@
 };
 
 struct labpc_private {
-	struct mite_struct *mite;	/*  for mite chip on pci-1200 */
 	/*  number of data points left to be taken */
 	unsigned long long count;
 	/*  software copy of analog output values */
@@ -80,8 +79,8 @@
 	 * function pointers so we can use inb/outb or readb/writeb as
 	 * appropriate
 	 */
-	unsigned int (*read_byte) (unsigned long address);
-	void (*write_byte) (unsigned int byte, unsigned long address);
+	unsigned int (*read_byte)(unsigned long address);
+	void (*write_byte)(unsigned int byte, unsigned long address);
 };
 
 int labpc_common_attach(struct comedi_device *dev,
diff --git a/drivers/staging/comedi/drivers/ni_labpc_pci.c b/drivers/staging/comedi/drivers/ni_labpc_pci.c
index 358c4af..5b59be3 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_pci.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_pci.c
@@ -35,7 +35,6 @@
 
 #include "../comedidev.h"
 
-#include "mite.h"
 #include "ni_labpc.h"
 
 enum labpc_pci_boardid {
@@ -53,12 +52,36 @@
 	},
 };
 
+/* ripped from mite.h and mite_setup2() to avoid mite dependancy */
+#define MITE_IODWBSR	0xc0	 /* IO Device Window Base Size Register */
+#define WENAB		(1 << 7) /* window enable */
+
+static int labpc_pci_mite_init(struct pci_dev *pcidev)
+{
+	void __iomem *mite_base;
+	u32 main_phys_addr;
+
+	/* ioremap the MITE registers (BAR 0) temporarily */
+	mite_base = pci_ioremap_bar(pcidev, 0);
+	if (!mite_base)
+		return -ENOMEM;
+
+	/* set data window to main registers (BAR 1) */
+	main_phys_addr = pci_resource_start(pcidev, 1);
+	writel(main_phys_addr | WENAB, mite_base + MITE_IODWBSR);
+
+	/* finished with MITE registers */
+	iounmap(mite_base);
+	return 0;
+}
+
 static int labpc_pci_auto_attach(struct comedi_device *dev,
 				 unsigned long context)
 {
 	struct pci_dev *pcidev = comedi_to_pci_dev(dev);
 	const struct labpc_boardinfo *board = NULL;
 	struct labpc_private *devpriv;
+	void __iomem *mmio;
 	int ret;
 
 	if (context < ARRAY_SIZE(labpc_pci_boards))
@@ -72,27 +95,26 @@
 	if (ret)
 		return ret;
 
+	ret = labpc_pci_mite_init(pcidev);
+	if (ret)
+		return ret;
+
+	mmio = pci_ioremap_bar(pcidev, 1);
+	if (!mmio)
+		return -ENOMEM;
+	dev->iobase = (unsigned long)mmio;
+
 	devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
 	if (!devpriv)
 		return -ENOMEM;
 
-	devpriv->mite = mite_alloc(pcidev);
-	if (!devpriv->mite)
-		return -ENOMEM;
-	ret = mite_setup(devpriv->mite);
-	if (ret < 0)
-		return ret;
-	dev->iobase = (unsigned long)devpriv->mite->daq_io_addr;
-
 	return labpc_common_attach(dev, pcidev->irq, IRQF_SHARED);
 }
 
 static void labpc_pci_detach(struct comedi_device *dev)
 {
-	struct labpc_private *devpriv = dev->private;
-
-	if (devpriv)
-		mite_detach(devpriv->mite);
+	if (dev->iobase)
+		iounmap((void __iomem *)dev->iobase);
 	if (dev->irq)
 		free_irq(dev->irq, dev);
 	comedi_pci_disable(dev);
diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
index ff881a7..4285f07 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -223,10 +223,8 @@
 	switch (counter_index) {
 	case 0:
 		return NI_GPCT0_SUBDEV;
-		break;
 	case 1:
 		return NI_GPCT1_SUBDEV;
-		break;
 	default:
 		break;
 	}
@@ -252,8 +250,8 @@
 
 	if (devpriv->mite)
 		writel(data, devpriv->mite->daq_io_addr + reg);
-	else
-		outl(data, dev->iobase + reg);
+
+	outl(data, dev->iobase + reg);
 }
 
 static void ni_writew(struct comedi_device *dev, uint16_t data, int reg)
@@ -262,8 +260,8 @@
 
 	if (devpriv->mite)
 		writew(data, devpriv->mite->daq_io_addr + reg);
-	else
-		outw(data, dev->iobase + reg);
+
+	outw(data, dev->iobase + reg);
 }
 
 static void ni_writeb(struct comedi_device *dev, uint8_t data, int reg)
@@ -272,8 +270,8 @@
 
 	if (devpriv->mite)
 		writeb(data, devpriv->mite->daq_io_addr + reg);
-	else
-		outb(data, dev->iobase + reg);
+
+	outb(data, dev->iobase + reg);
 }
 
 static uint32_t ni_readl(struct comedi_device *dev, int reg)
@@ -282,8 +280,8 @@
 
 	if (devpriv->mite)
 		return readl(devpriv->mite->daq_io_addr + reg);
-	else
-		return inl(dev->iobase + reg);
+
+	return inl(dev->iobase + reg);
 }
 
 static uint16_t ni_readw(struct comedi_device *dev, int reg)
@@ -292,8 +290,8 @@
 
 	if (devpriv->mite)
 		return readw(devpriv->mite->daq_io_addr + reg);
-	else
-		return inw(dev->iobase + reg);
+
+	return inw(dev->iobase + reg);
 }
 
 static uint8_t ni_readb(struct comedi_device *dev, int reg)
@@ -302,8 +300,8 @@
 
 	if (devpriv->mite)
 		return readb(devpriv->mite->daq_io_addr + reg);
-	else
-		return inb(dev->iobase + reg);
+
+	return inb(dev->iobase + reg);
 }
 
 /*
@@ -684,8 +682,8 @@
 		ni_writeb(dev, devpriv->g0_g1_select_reg, G0_G1_Select);
 		break;
 	default:
-		printk("Warning %s() called with invalid register\n", __func__);
-		printk("reg is %d\n", reg);
+		dev_err(dev->class_dev,
+			"%s called with invalid register %d\n", __func__, reg);
 		break;
 	}
 	mmiowb();
@@ -773,8 +771,8 @@
 	    mite_request_channel(devpriv->mite, devpriv->ai_mite_ring);
 	if (devpriv->ai_mite_chan == NULL) {
 		spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
-		comedi_error(dev,
-			     "failed to reserve mite dma channel for analog input.");
+		dev_err(dev->class_dev,
+			"failed to reserve mite dma channel for analog input\n");
 		return -EBUSY;
 	}
 	devpriv->ai_mite_chan->dir = COMEDI_INPUT;
@@ -794,8 +792,8 @@
 	    mite_request_channel(devpriv->mite, devpriv->ao_mite_ring);
 	if (devpriv->ao_mite_chan == NULL) {
 		spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
-		comedi_error(dev,
-			     "failed to reserve mite dma channel for analog outut.");
+		dev_err(dev->class_dev,
+			"failed to reserve mite dma channel for analog outut\n");
 		return -EBUSY;
 	}
 	devpriv->ao_mite_chan->dir = COMEDI_OUTPUT;
@@ -820,8 +818,8 @@
 				 devpriv->gpct_mite_ring[gpct_index]);
 	if (mite_chan == NULL) {
 		spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
-		comedi_error(dev,
-			     "failed to reserve mite dma channel for counter.");
+		dev_err(dev->class_dev,
+			"failed to reserve mite dma channel for counter\n");
 		return -EBUSY;
 	}
 	mite_chan->dir = direction;
@@ -846,8 +844,8 @@
 	    mite_request_channel(devpriv->mite, devpriv->cdo_mite_ring);
 	if (devpriv->cdo_mite_chan == NULL) {
 		spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
-		comedi_error(dev,
-			     "failed to reserve mite dma channel for correlated digital outut.");
+		dev_err(dev->class_dev,
+			"failed to reserve mite dma channel for correlated digital output\n");
 		return -EBUSY;
 	}
 	devpriv->cdo_mite_chan->dir = COMEDI_OUTPUT;
@@ -958,11 +956,11 @@
 
 static void ni_clear_ai_fifo(struct comedi_device *dev)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
+	struct ni_private *devpriv = dev->private;
 	static const int timeout = 10000;
 	int i;
 
-	if (board->reg_type == ni_reg_6143) {
+	if (devpriv->is_6143) {
 		/*  Flush the 6143 data FIFO */
 		ni_writel(dev, 0x10, AIFIFO_Control_6143);
 		ni_writel(dev, 0x00, AIFIFO_Control_6143);
@@ -972,12 +970,11 @@
 				break;
 			udelay(1);
 		}
-		if (i == timeout) {
-			comedi_error(dev, "FIFO flush timeout.");
-		}
+		if (i == timeout)
+			dev_err(dev->class_dev, "FIFO flush timeout\n");
 	} else {
 		ni_stc_writew(dev, 1, ADC_FIFO_Clear);
-		if (board->reg_type == ni_reg_625x) {
+		if (devpriv->is_625x) {
 			ni_writeb(dev, 0, M_Offset_Static_AI_Control(0));
 			ni_writeb(dev, 1, M_Offset_Static_AI_Control(0));
 #if 0
@@ -994,7 +991,6 @@
 	}
 }
 
-#define ao_win_out(data, addr) ni_ao_win_outw(dev, data, addr)
 static inline void ni_ao_win_outw(struct comedi_device *dev, uint16_t data,
 				  int addr)
 {
@@ -1086,11 +1082,11 @@
 			udelay(5);
 		}
 		if (i == timeout) {
-			printk("ni_mio_common: wait for dma drain timed out\n");
-			printk
-			    ("mite_bytes_in_transit=%i, AI_Status1_Register=0x%x\n",
-			     mite_bytes_in_transit(devpriv->ai_mite_chan),
-			     ni_stc_readw(dev, AI_Status_1_Register));
+			dev_err(dev->class_dev, "%s timed out\n", __func__);
+			dev_err(dev->class_dev,
+				"mite_bytes_in_transit=%i, AI_Status1_Register=0x%x\n",
+				mite_bytes_in_transit(devpriv->ai_mite_chan),
+				ni_stc_readw(dev, AI_Status_1_Register));
 			retval = -1;
 		}
 	}
@@ -1118,6 +1114,7 @@
 {
 	static const int timeout = 10000;
 	int i;
+
 	for (i = 0; i < timeout; i++) {
 		unsigned short b_status;
 
@@ -1129,7 +1126,7 @@
 		udelay(10);
 	}
 	if (i == timeout) {
-		comedi_error(dev, "timed out waiting for dma load");
+		dev_err(dev->class_dev, "timed out waiting for dma load\n");
 		return -EPIPE;
 	}
 	return 0;
@@ -1141,7 +1138,7 @@
 static void ni_ao_fifo_load(struct comedi_device *dev,
 			    struct comedi_subdevice *s, int n)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
+	struct ni_private *devpriv = dev->private;
 	struct comedi_async *async = s->async;
 	struct comedi_cmd *cmd = &async->cmd;
 	int chan;
@@ -1159,10 +1156,10 @@
 
 		range = CR_RANGE(cmd->chanlist[chan]);
 
-		if (board->reg_type & ni_reg_6xxx_mask) {
+		if (devpriv->is_6xxx) {
 			packed_data = d & 0xffff;
 			/* 6711 only has 16 bit wide ao fifo */
-			if (board->reg_type != ni_reg_6711) {
+			if (!devpriv->is_6711) {
 				err &= comedi_buf_get(s, &d);
 				if (err == 0)
 					break;
@@ -1225,11 +1222,12 @@
 			   struct comedi_subdevice *s)
 {
 	const struct ni_board_struct *board = comedi_board(dev);
+	struct ni_private *devpriv = dev->private;
 	int n;
 
 	/* reset fifo */
 	ni_stc_writew(dev, 1, DAC_FIFO_Clear);
-	if (board->reg_type & ni_reg_6xxx_mask)
+	if (devpriv->is_6xxx)
 		ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x);
 
 	/* load some data */
@@ -1249,12 +1247,11 @@
 static void ni_ai_fifo_read(struct comedi_device *dev,
 			    struct comedi_subdevice *s, int n)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
 	struct comedi_async *async = s->async;
 	int i;
 
-	if (board->reg_type == ni_reg_611x) {
+	if (devpriv->is_611x) {
 		unsigned short data[2];
 		u32 dl;
 
@@ -1271,7 +1268,7 @@
 			data[0] = dl & 0xffff;
 			cfc_write_to_buffer(s, data[0]);
 		}
-	} else if (board->reg_type == ni_reg_6143) {
+	} else if (devpriv->is_6143) {
 		unsigned short data[2];
 		u32 dl;
 
@@ -1294,7 +1291,8 @@
 	} else {
 		if (n > sizeof(devpriv->ai_fifo_buffer) /
 		    sizeof(devpriv->ai_fifo_buffer[0])) {
-			comedi_error(dev, "bug! ai_fifo_buffer too small");
+			dev_err(dev->class_dev,
+				"bug! ai_fifo_buffer too small\n");
 			async->events |= COMEDI_CB_ERROR;
 			return;
 		}
@@ -1325,7 +1323,6 @@
 */
 static void ni_handle_fifo_dregs(struct comedi_device *dev)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
 	struct comedi_subdevice *s = dev->read_subdev;
 	unsigned short data[2];
@@ -1333,7 +1330,7 @@
 	unsigned short fifo_empty;
 	int i;
 
-	if (board->reg_type == ni_reg_611x) {
+	if (devpriv->is_611x) {
 		while ((ni_stc_readw(dev, AI_Status_1_Register) &
 			AI_FIFO_Empty_St) == 0) {
 			dl = ni_readl(dev, ADC_FIFO_Data_611x);
@@ -1343,7 +1340,7 @@
 			data[1] = (dl & 0xffff);
 			cfc_write_array_to_buffer(s, data, sizeof(data));
 		}
-	} else if (board->reg_type == ni_reg_6143) {
+	} else if (devpriv->is_6143) {
 		i = 0;
 		while (ni_readl(dev, AIFIFO_Status_6143) & 0x04) {
 			dl = ni_readl(dev, AIFIFO_Data_6143);
@@ -1389,12 +1386,12 @@
 
 static void get_last_sample_611x(struct comedi_device *dev)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
+	struct ni_private *devpriv = dev->private;
 	struct comedi_subdevice *s = dev->read_subdev;
 	unsigned short data;
 	u32 dl;
 
-	if (board->reg_type != ni_reg_611x)
+	if (!devpriv->is_611x)
 		return;
 
 	/* Check if there's a single sample stuck in the FIFO */
@@ -1407,12 +1404,12 @@
 
 static void get_last_sample_6143(struct comedi_device *dev)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
+	struct ni_private *devpriv = dev->private;
 	struct comedi_subdevice *s = dev->read_subdev;
 	unsigned short data;
 	u32 dl;
 
-	if (board->reg_type != ni_reg_6143)
+	if (!devpriv->is_6143)
 		return;
 
 	/* Check if there's a single sample stuck in the FIFO */
@@ -1501,8 +1498,8 @@
 static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
 			       unsigned ai_mite_status)
 {
-	struct ni_private *devpriv = dev->private;
 	struct comedi_subdevice *s = dev->read_subdev;
+	struct comedi_cmd *cmd = &s->async->cmd;
 
 	/* 67xx boards don't have ai subdevice, but their gpct0 might generate an a interrupt */
 	if (s->type == COMEDI_SUBD_UNUSED)
@@ -1515,9 +1512,9 @@
 	if (ai_mite_status & ~(CHSR_INT | CHSR_LINKC | CHSR_DONE | CHSR_MRDY |
 			       CHSR_DRDY | CHSR_DRQ1 | CHSR_DRQ0 | CHSR_ERROR |
 			       CHSR_SABORT | CHSR_XFERR | CHSR_LxERR_mask)) {
-		printk
-		    ("unknown mite interrupt, ack! (ai_mite_status=%08x)\n",
-		     ai_mite_status);
+		dev_err(dev->class_dev,
+			"unknown mite interrupt (ai_mite_status=%08x)\n",
+			ai_mite_status);
 		s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA;
 		/* disable_irq(dev->irq); */
 	}
@@ -1527,8 +1524,7 @@
 	if (status & (AI_Overrun_St | AI_Overflow_St | AI_SC_TC_Error_St |
 		      AI_SC_TC_St | AI_START1_St)) {
 		if (status == 0xffff) {
-			printk
-			    ("ni_mio_common: a_status=0xffff.  Card removed?\n");
+			dev_err(dev->class_dev, "Card removed?\n");
 			/* we probably aren't even running a command now,
 			 * so it's a good idea to be careful. */
 			if (comedi_is_subdevice_running(s)) {
@@ -1540,8 +1536,8 @@
 		}
 		if (status & (AI_Overrun_St | AI_Overflow_St |
 			      AI_SC_TC_Error_St)) {
-			printk("ni_mio_common: ai error a_status=%04x\n",
-			       status);
+			dev_err(dev->class_dev, "ai error a_status=%04x\n",
+				status);
 
 			shutdown_ai_command(dev);
 
@@ -1553,7 +1549,7 @@
 			return;
 		}
 		if (status & AI_SC_TC_St) {
-			if (!devpriv->ai_continuous)
+			if (cmd->stop_src == TRIG_COUNT)
 				shutdown_ai_command(dev);
 		}
 	}
@@ -1617,9 +1613,9 @@
 	if (ao_mite_status & ~(CHSR_INT | CHSR_LINKC | CHSR_DONE | CHSR_MRDY |
 			       CHSR_DRDY | CHSR_DRQ1 | CHSR_DRQ0 | CHSR_ERROR |
 			       CHSR_SABORT | CHSR_XFERR | CHSR_LxERR_mask)) {
-		printk
-		    ("unknown mite interrupt, ack! (ao_mite_status=%08x)\n",
-		     ao_mite_status);
+		dev_err(dev->class_dev,
+			"unknown mite interrupt (ao_mite_status=%08x)\n",
+			ao_mite_status);
 		s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 	}
 #endif
@@ -1627,9 +1623,9 @@
 	if (b_status == 0xffff)
 		return;
 	if (b_status & AO_Overrun_St) {
-		printk
-		    ("ni_mio_common: AO FIFO underrun status=0x%04x status2=0x%04x\n",
-		     b_status, ni_stc_readw(dev, AO_Status_2_Register));
+		dev_err(dev->class_dev,
+			"AO FIFO underrun status=0x%04x status2=0x%04x\n",
+			b_status, ni_stc_readw(dev, AO_Status_2_Register));
 		s->async->events |= COMEDI_CB_OVERFLOW;
 	}
 
@@ -1642,7 +1638,7 @@
 
 		ret = ni_ao_fifo_half_empty(dev, s);
 		if (!ret) {
-			printk("ni_mio_common: AO buffer underrun\n");
+			dev_err(dev->class_dev, "AO buffer underrun\n");
 			ni_set_bits(dev, Interrupt_B_Enable_Register,
 				    AO_FIFO_Interrupt_Enable |
 				    AO_Error_Interrupt_Enable, 0);
@@ -1686,7 +1682,6 @@
 
 static int ni_ai_setup_MITE_dma(struct comedi_device *dev)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
 	struct comedi_subdevice *s = dev->read_subdev;
 	int retval;
@@ -1695,7 +1690,6 @@
 	retval = ni_request_ai_mite_channel(dev);
 	if (retval)
 		return retval;
-/* printk("comedi_debug: using mite channel %i for ai.\n", devpriv->ai_mite_chan->channel); */
 
 	/* write alloc the entire buffer */
 	comedi_buf_write_alloc(s, s->async->prealloc_bufsz);
@@ -1706,18 +1700,13 @@
 		return -EIO;
 	}
 
-	switch (board->reg_type) {
-	case ni_reg_611x:
-	case ni_reg_6143:
+	if (devpriv->is_611x || devpriv->is_6143)
 		mite_prep_dma(devpriv->ai_mite_chan, 32, 16);
-		break;
-	case ni_reg_628x:
+	else if (devpriv->is_628x)
 		mite_prep_dma(devpriv->ai_mite_chan, 32, 32);
-		break;
-	default:
+	else
 		mite_prep_dma(devpriv->ai_mite_chan, 16, 16);
-		break;
-	}
+
 	/*start the MITE */
 	mite_dma_arm(devpriv->ai_mite_chan);
 	spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
@@ -1727,7 +1716,6 @@
 
 static int ni_ao_setup_MITE_dma(struct comedi_device *dev)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
 	struct comedi_subdevice *s = dev->write_subdev;
 	int retval;
@@ -1742,7 +1730,7 @@
 
 	spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
 	if (devpriv->ao_mite_chan) {
-		if (board->reg_type & (ni_reg_611x | ni_reg_6713)) {
+		if (devpriv->is_611x || devpriv->is_6713) {
 			mite_prep_dma(devpriv->ao_mite_chan, 32, 32);
 		} else {
 			/* doing 32 instead of 16 bit wide transfers from memory
@@ -1767,7 +1755,7 @@
 
 static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
+	struct ni_private *devpriv = dev->private;
 
 	ni_release_ai_mite_channel(dev);
 	/* ai configuration */
@@ -1782,7 +1770,7 @@
 
 	ni_clear_ai_fifo(dev);
 
-	if (board->reg_type != ni_reg_6143)
+	if (!devpriv->is_6143)
 		ni_writeb(dev, 0, Misc_Command);
 
 	ni_stc_writew(dev, AI_Disarm, AI_Command_1_Register); /* reset pulses */
@@ -1792,7 +1780,7 @@
 	ni_stc_writew(dev, 0x0000, AI_Mode_2_Register);
 	/* generate FIFO interrupts on non-empty */
 	ni_stc_writew(dev, (0 << 6) | 0x0000, AI_Mode_3_Register);
-	if (board->reg_type == ni_reg_611x) {
+	if (devpriv->is_611x) {
 		ni_stc_writew(dev,
 			      AI_SHIFTIN_Pulse_Width |
 			      AI_SOC_Polarity |
@@ -1806,7 +1794,7 @@
 			      AI_CONVERT_Output_Select
 			      (AI_CONVERT_Output_Enable_High),
 			      AI_Output_Control_Register);
-	} else if (board->reg_type == ni_reg_6143) {
+	} else if (devpriv->is_6143) {
 		ni_stc_writew(dev, AI_SHIFTIN_Pulse_Width |
 				   AI_SOC_Polarity |
 				   AI_LOCALMUX_CLK_Pulse_Width,
@@ -1821,6 +1809,7 @@
 			      AI_Output_Control_Register);
 	} else {
 		unsigned ai_output_control_bits;
+
 		ni_stc_writew(dev,
 			      AI_SHIFTIN_Pulse_Width |
 			      AI_SOC_Polarity |
@@ -1832,7 +1821,7 @@
 		    AI_EXTMUX_CLK_Output_Select(0) |
 		    AI_LOCALMUX_CLK_Output_Select(2) |
 		    AI_SC_TC_Output_Select(3);
-		if (board->reg_type == ni_reg_622x)
+		if (devpriv->is_622x)
 			ai_output_control_bits |=
 			    AI_CONVERT_Output_Select
 			    (AI_CONVERT_Output_Enable_High);
@@ -1897,7 +1886,7 @@
 		}
 		udelay(1);
 	}
-	printk("ni_mio_common: timeout loading channel/gain list\n");
+	dev_err(dev->class_dev, "timeout loading channel/gain list\n");
 }
 
 static void ni_m_series_load_channelgain_list(struct comedi_device *dev,
@@ -1908,15 +1897,14 @@
 	struct ni_private *devpriv = dev->private;
 	unsigned int chan, range, aref;
 	unsigned int i;
-	unsigned offset;
 	unsigned int dither;
 	unsigned range_code;
 
 	ni_stc_writew(dev, 1, Configuration_Memory_Clear);
 
-/* offset = 1 << (board->adbits - 1); */
 	if ((list[0] & CR_ALT_SOURCE)) {
 		unsigned bypass_bits;
+
 		chan = CR_CHAN(list[0]);
 		range = CR_RANGE(list[0]);
 		range_code = ni_gainlkup[board->gainlkup][range];
@@ -1938,16 +1926,16 @@
 	} else {
 		ni_writel(dev, 0, M_Offset_AI_Config_FIFO_Bypass);
 	}
-	offset = 0;
 	for (i = 0; i < n_chan; i++) {
 		unsigned config_bits = 0;
+
 		chan = CR_CHAN(list[i]);
 		aref = CR_AREF(list[i]);
 		range = CR_RANGE(list[i]);
 		dither = ((list[i] & CR_ALT_FILTER) != 0);
 
 		range_code = ni_gainlkup[board->gainlkup][range];
-		devpriv->ai_offset[i] = offset;
+		devpriv->ai_offset[i] = 0;
 		switch (aref) {
 		case AREF_DIFF:
 			config_bits |=
@@ -2009,22 +1997,22 @@
  *       valid channels are 0-3
  */
 static void ni_load_channelgain_list(struct comedi_device *dev,
+				     struct comedi_subdevice *s,
 				     unsigned int n_chan, unsigned int *list)
 {
 	const struct ni_board_struct *board = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
+	unsigned int offset = (s->maxdata + 1) >> 1;
 	unsigned int chan, range, aref;
 	unsigned int i;
 	unsigned int hi, lo;
-	unsigned offset;
 	unsigned int dither;
 
 	if (devpriv->is_m_series) {
 		ni_m_series_load_channelgain_list(dev, n_chan, list);
 		return;
 	}
-	if (n_chan == 1 && (board->reg_type != ni_reg_611x)
-	    && (board->reg_type != ni_reg_6143)) {
+	if (n_chan == 1 && !devpriv->is_611x && !devpriv->is_6143) {
 		if (devpriv->changain_state
 		    && devpriv->changain_spec == list[0]) {
 			/*  ready to go. */
@@ -2039,7 +2027,7 @@
 	ni_stc_writew(dev, 1, Configuration_Memory_Clear);
 
 	/*  Set up Calibration mode if required */
-	if (board->reg_type == ni_reg_6143) {
+	if (devpriv->is_6143) {
 		if ((list[0] & CR_ALT_SOURCE)
 		    && !devpriv->ai_calib_source_enabled) {
 			/*  Strobe Relay enable bit */
@@ -2063,34 +2051,31 @@
 		}
 	}
 
-	offset = 1 << (board->adbits - 1);
 	for (i = 0; i < n_chan; i++) {
-		if ((board->reg_type != ni_reg_6143)
-		    && (list[i] & CR_ALT_SOURCE)) {
+		if (!devpriv->is_6143 && (list[i] & CR_ALT_SOURCE))
 			chan = devpriv->ai_calib_source;
-		} else {
+		else
 			chan = CR_CHAN(list[i]);
-		}
 		aref = CR_AREF(list[i]);
 		range = CR_RANGE(list[i]);
 		dither = ((list[i] & CR_ALT_FILTER) != 0);
 
 		/* fix the external/internal range differences */
 		range = ni_gainlkup[board->gainlkup][range];
-		if (board->reg_type == ni_reg_611x)
+		if (devpriv->is_611x)
 			devpriv->ai_offset[i] = offset;
 		else
 			devpriv->ai_offset[i] = (range & 0x100) ? 0 : offset;
 
 		hi = 0;
 		if ((list[i] & CR_ALT_SOURCE)) {
-			if (board->reg_type == ni_reg_611x)
+			if (devpriv->is_611x)
 				ni_writew(dev, CR_CHAN(list[i]) & 0x0003,
 					  Calibration_Channel_Select_611x);
 		} else {
-			if (board->reg_type == ni_reg_611x)
+			if (devpriv->is_611x)
 				aref = AREF_DIFF;
-			else if (board->reg_type == ni_reg_6143)
+			else if (devpriv->is_6143)
 				aref = AREF_OTHER;
 			switch (aref) {
 			case AREF_DIFF:
@@ -2110,7 +2095,7 @@
 
 		ni_writew(dev, hi, Configuration_Memory_High);
 
-		if (board->reg_type != ni_reg_6143) {
+		if (!devpriv->is_6143) {
 			lo = range;
 			if (i == n_chan - 1)
 				lo |= AI_LAST_CHANNEL;
@@ -2122,10 +2107,8 @@
 	}
 
 	/* prime the channel/gain list */
-	if ((board->reg_type != ni_reg_611x)
-	    && (board->reg_type != ni_reg_6143)) {
+	if (!devpriv->is_611x && !devpriv->is_6143)
 		ni_prime_channelgain_list(dev);
-	}
 }
 
 static int ni_ai_insn_read(struct comedi_device *dev,
@@ -2133,20 +2116,19 @@
 			   struct comedi_insn *insn,
 			   unsigned int *data)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
+	unsigned int mask = (s->maxdata + 1) >> 1;
 	int i, n;
-	const unsigned int mask = (1 << board->adbits) - 1;
 	unsigned signbits;
 	unsigned short d;
 	unsigned long dl;
 
-	ni_load_channelgain_list(dev, 1, &insn->chanspec);
+	ni_load_channelgain_list(dev, s, 1, &insn->chanspec);
 
 	ni_clear_ai_fifo(dev);
 
 	signbits = devpriv->ai_offset[0];
-	if (board->reg_type == ni_reg_611x) {
+	if (devpriv->is_611x) {
 		for (n = 0; n < num_adc_stages_611x; n++) {
 			ni_stc_writew(dev, AI_CONVERT_Pulse,
 				      AI_Command_1_Register);
@@ -2172,14 +2154,14 @@
 				}
 			}
 			if (i == NI_TIMEOUT) {
-				printk
-				    ("ni_mio_common: timeout in 611x ni_ai_insn_read\n");
+				dev_err(dev->class_dev, "%s timeout\n",
+					__func__);
 				return -ETIME;
 			}
 			d += signbits;
 			data[n] = d;
 		}
-	} else if (board->reg_type == ni_reg_6143) {
+	} else if (devpriv->is_6143) {
 		for (n = 0; n < insn->n; n++) {
 			ni_stc_writew(dev, AI_CONVERT_Pulse,
 				      AI_Command_1_Register);
@@ -2196,8 +2178,8 @@
 				}
 			}
 			if (i == NI_TIMEOUT) {
-				printk
-				    ("ni_mio_common: timeout in 6143 ni_ai_insn_read\n");
+				dev_err(dev->class_dev, "%s timeout\n",
+					__func__);
 				return -ETIME;
 			}
 			data[n] = (((dl >> 16) & 0xFFFF) + signbits) & 0xFFFF;
@@ -2212,8 +2194,8 @@
 					break;
 			}
 			if (i == NI_TIMEOUT) {
-				printk
-				    ("ni_mio_common: timeout in ni_ai_insn_read\n");
+				dev_err(dev->class_dev, "%s timeout\n",
+					__func__);
 				return -ETIME;
 			}
 			if (devpriv->is_m_series) {
@@ -2231,12 +2213,12 @@
 }
 
 static int ni_ns_to_timer(const struct comedi_device *dev, unsigned nanosec,
-			  int round_mode)
+			  unsigned int flags)
 {
 	struct ni_private *devpriv = dev->private;
 	int divider;
 
-	switch (round_mode) {
+	switch (flags & TRIG_ROUND_MASK) {
 	case TRIG_ROUND_NEAREST:
 	default:
 		divider = (nanosec + devpriv->clock_ns / 2) / devpriv->clock_ns;
@@ -2262,17 +2244,13 @@
 					 unsigned num_channels)
 {
 	const struct ni_board_struct *board = comedi_board(dev);
+	struct ni_private *devpriv = dev->private;
 
-	switch (board->reg_type) {
-	case ni_reg_611x:
-	case ni_reg_6143:
-		/*  simultaneously-sampled inputs */
+	/* simultaneously-sampled inputs */
+	if (devpriv->is_611x || devpriv->is_6143)
 		return board->ai_speed;
-		break;
-	default:
-		/*  multiplexed inputs */
-		break;
-	}
+
+	/* multiplexed inputs */
 	return board->ai_speed * num_channels;
 }
 
@@ -2296,8 +2274,7 @@
 					TRIG_TIMER | TRIG_EXT);
 
 	sources = TRIG_TIMER | TRIG_EXT;
-	if (board->reg_type == ni_reg_611x ||
-	    board->reg_type == ni_reg_6143)
+	if (devpriv->is_611x || devpriv->is_6143)
 		sources |= TRIG_NOW;
 	err |= cfc_check_trigger_src(&cmd->convert_src, sources);
 
@@ -2354,8 +2331,7 @@
 	}
 
 	if (cmd->convert_src == TRIG_TIMER) {
-		if ((board->reg_type == ni_reg_611x)
-		    || (board->reg_type == ni_reg_6143)) {
+		if (devpriv->is_611x || devpriv->is_6143) {
 			err |= cfc_check_trigger_arg_is(&cmd->convert_arg, 0);
 		} else {
 			err |= cfc_check_trigger_arg_min(&cmd->convert_arg,
@@ -2380,7 +2356,7 @@
 	if (cmd->stop_src == TRIG_COUNT) {
 		unsigned int max_count = 0x01000000;
 
-		if (board->reg_type == ni_reg_611x)
+		if (devpriv->is_611x)
 			max_count -= num_adc_stages_611x;
 		err |= cfc_check_trigger_arg_max(&cmd->stop_arg, max_count);
 		err |= cfc_check_trigger_arg_min(&cmd->stop_arg, 1);
@@ -2399,22 +2375,17 @@
 		cmd->scan_begin_arg =
 		    ni_timer_to_ns(dev, ni_ns_to_timer(dev,
 						       cmd->scan_begin_arg,
-						       cmd->
-						       flags &
-						       TRIG_ROUND_MASK));
+						       cmd->flags));
 		if (tmp != cmd->scan_begin_arg)
 			err++;
 	}
 	if (cmd->convert_src == TRIG_TIMER) {
-		if ((board->reg_type != ni_reg_611x)
-		    && (board->reg_type != ni_reg_6143)) {
+		if (!devpriv->is_611x && !devpriv->is_6143) {
 			tmp = cmd->convert_arg;
 			cmd->convert_arg =
 			    ni_timer_to_ns(dev, ni_ns_to_timer(dev,
 							       cmd->convert_arg,
-							       cmd->
-							       flags &
-							       TRIG_ROUND_MASK));
+							       cmd->flags));
 			if (tmp != cmd->convert_arg)
 				err++;
 			if (cmd->scan_begin_src == TRIG_TIMER &&
@@ -2452,7 +2423,6 @@
 
 static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
 	const struct comedi_cmd *cmd = &s->async->cmd;
 	int timer;
@@ -2463,12 +2433,12 @@
 	int interrupt_a_enable = 0;
 
 	if (dev->irq == 0) {
-		comedi_error(dev, "cannot run command without an irq");
+		dev_err(dev->class_dev, "cannot run command without an irq\n");
 		return -EIO;
 	}
 	ni_clear_ai_fifo(dev);
 
-	ni_load_channelgain_list(dev, cmd->chanlist_len, cmd->chanlist);
+	ni_load_channelgain_list(dev, s, cmd->chanlist_len, cmd->chanlist);
 
 	/* start configuration */
 	ni_stc_writew(dev, AI_Configuration_Start, Joint_Reset_Register);
@@ -2508,8 +2478,7 @@
 	mode2 &= ~AI_SC_Reload_Mode;
 	ni_stc_writew(dev, mode2, AI_Mode_2_Register);
 
-	if (cmd->chanlist_len == 1 || (board->reg_type == ni_reg_611x)
-	    || (board->reg_type == ni_reg_6143)) {
+	if (cmd->chanlist_len == 1 || devpriv->is_611x || devpriv->is_6143) {
 		start_stop_select |= AI_STOP_Polarity;
 		start_stop_select |= AI_STOP_Select(31);	/*  logic low */
 		start_stop_select |= AI_STOP_Sync;
@@ -2523,7 +2492,7 @@
 	case TRIG_COUNT:
 		stop_count = cmd->stop_arg - 1;
 
-		if (board->reg_type == ni_reg_611x) {
+		if (devpriv->is_611x) {
 			/*  have to take 3 stage adc pipeline into account */
 			stop_count += num_adc_stages_611x;
 		}
@@ -2535,7 +2504,6 @@
 		/* load SC (Scan Count) */
 		ni_stc_writew(dev, AI_SC_Load, AI_Command_1_Register);
 
-		devpriv->ai_continuous = 0;
 		if (stop_count == 0) {
 			devpriv->ai_cmd2 |= AI_End_On_End_Of_Scan;
 			interrupt_a_enable |= AI_STOP_Interrupt_Enable;
@@ -2554,9 +2522,6 @@
 
 		/* load SC (Scan Count) */
 		ni_stc_writew(dev, AI_SC_Load, AI_Command_1_Register);
-
-		devpriv->ai_continuous = 1;
-
 		break;
 	}
 
@@ -2735,6 +2700,7 @@
 #ifdef PCIDMA
 	{
 		int retval = ni_ai_setup_MITE_dma(dev);
+
 		if (retval)
 			return retval;
 	}
@@ -2754,119 +2720,16 @@
 	return 0;
 }
 
-static int ni_ai_config_analog_trig(struct comedi_device *dev,
-				    struct comedi_subdevice *s,
-				    struct comedi_insn *insn,
-				    unsigned int *data)
-{
-	const struct ni_board_struct *board = comedi_board(dev);
-	struct ni_private *devpriv = dev->private;
-	unsigned int a, b, modebits;
-	int err = 0;
-
-	/* data[1] is flags
-	 * data[2] is analog line
-	 * data[3] is set level
-	 * data[4] is reset level */
-	if (!board->has_analog_trig)
-		return -EINVAL;
-	if ((data[1] & 0xffff0000) != COMEDI_EV_SCAN_BEGIN) {
-		data[1] &= (COMEDI_EV_SCAN_BEGIN | 0xffff);
-		err++;
-	}
-	if (data[2] >= board->n_adchan) {
-		data[2] = board->n_adchan - 1;
-		err++;
-	}
-	if (data[3] > 255) {	/* a */
-		data[3] = 255;
-		err++;
-	}
-	if (data[4] > 255) {	/* b */
-		data[4] = 255;
-		err++;
-	}
-	/*
-	 * 00 ignore
-	 * 01 set
-	 * 10 reset
-	 *
-	 * modes:
-	 *   1 level:                    +b-   +a-
-	 *     high mode                00 00 01 10
-	 *     low mode                 00 00 10 01
-	 *   2 level: (a<b)
-	 *     hysteresis low mode      10 00 00 01
-	 *     hysteresis high mode     01 00 00 10
-	 *     middle mode              10 01 01 10
-	 */
-
-	a = data[3];
-	b = data[4];
-	modebits = data[1] & 0xff;
-	if (modebits & 0xf0) {
-		/* two level mode */
-		if (b < a) {
-			/* swap order */
-			a = data[4];
-			b = data[3];
-			modebits =
-			    ((data[1] & 0xf) << 4) | ((data[1] & 0xf0) >> 4);
-		}
-		devpriv->atrig_low = a;
-		devpriv->atrig_high = b;
-		switch (modebits) {
-		case 0x81:	/* low hysteresis mode */
-			devpriv->atrig_mode = 6;
-			break;
-		case 0x42:	/* high hysteresis mode */
-			devpriv->atrig_mode = 3;
-			break;
-		case 0x96:	/* middle window mode */
-			devpriv->atrig_mode = 2;
-			break;
-		default:
-			data[1] &= ~0xff;
-			err++;
-		}
-	} else {
-		/* one level mode */
-		if (b != 0) {
-			data[4] = 0;
-			err++;
-		}
-		switch (modebits) {
-		case 0x06:	/* high window mode */
-			devpriv->atrig_high = a;
-			devpriv->atrig_mode = 0;
-			break;
-		case 0x09:	/* low window mode */
-			devpriv->atrig_low = a;
-			devpriv->atrig_mode = 1;
-			break;
-		default:
-			data[1] &= ~0xff;
-			err++;
-		}
-	}
-	if (err)
-		return -EAGAIN;
-	return 5;
-}
-
 static int ni_ai_insn_config(struct comedi_device *dev,
 			     struct comedi_subdevice *s,
 			     struct comedi_insn *insn, unsigned int *data)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
 
 	if (insn->n < 1)
 		return -EINVAL;
 
 	switch (data[0]) {
-	case INSN_CONFIG_ANALOG_TRIG:
-		return ni_ai_config_analog_trig(dev, s, insn, data);
 	case INSN_CONFIG_ALT_SOURCE:
 		if (devpriv->is_m_series) {
 			if (data[1] & ~(MSeries_AI_Bypass_Cal_Sel_Pos_Mask |
@@ -2876,7 +2739,7 @@
 				return -EINVAL;
 			}
 			devpriv->ai_calib_source = data[1];
-		} else if (board->reg_type == ni_reg_6143) {
+		} else if (devpriv->is_6143) {
 			unsigned int calib_source;
 
 			calib_source = data[1] & 0xf;
@@ -2896,7 +2759,7 @@
 			if (calib_source >= 8)
 				return -EINVAL;
 			devpriv->ai_calib_source = calib_source;
-			if (board->reg_type == ni_reg_611x) {
+			if (devpriv->is_611x) {
 				ni_writeb(dev, calib_source_adjust,
 					  Cal_Gain_Select_611x);
 			}
@@ -2909,27 +2772,30 @@
 	return -EINVAL;
 }
 
-/* munge data from unsigned to 2's complement for analog output bipolar modes */
 static void ni_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s,
 			void *data, unsigned int num_bytes,
 			unsigned int chan_index)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
-	struct comedi_async *async = s->async;
-	struct comedi_cmd *cmd = &async->cmd;
-	unsigned int length = num_bytes / sizeof(short);
-	unsigned int offset = 1 << (board->aobits - 1);
+	struct comedi_cmd *cmd = &s->async->cmd;
+	unsigned int length = num_bytes / bytes_per_sample(s);
 	unsigned short *array = data;
-	unsigned int range;
 	unsigned int i;
 
 	for (i = 0; i < length; i++) {
-		range = CR_RANGE(cmd->chanlist[chan_index]);
-		if (board->ao_unipolar == 0 || (range & 1) == 0)
-			array[i] -= offset;
+		unsigned int range = CR_RANGE(cmd->chanlist[chan_index]);
+		unsigned short val = array[i];
+
+		/*
+		 * Munge data from unsigned to two's complement for
+		 * bipolar ranges.
+		 */
+		if (comedi_range_is_bipolar(s, range))
+			val = comedi_offset_munge(s, val);
 #ifdef PCIDMA
-		array[i] = cpu_to_le16(array[i]);
+		val = cpu_to_le16(val);
 #endif
+		array[i] = val;
+
 		chan_index++;
 		chan_index %= cmd->chanlist_len;
 	}
@@ -2940,7 +2806,6 @@
 					  unsigned int chanspec[],
 					  unsigned int n_chans, int timed)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
 	unsigned int range;
 	unsigned int chan;
@@ -2949,7 +2814,7 @@
 	int invert = 0;
 
 	if (timed) {
-		for (i = 0; i < board->n_aochan; ++i) {
+		for (i = 0; i < s->n_chan; ++i) {
 			devpriv->ao_conf[i] &= ~MSeries_AO_Update_Timed_Bit;
 			ni_writeb(dev, devpriv->ao_conf[i],
 				  M_Offset_AO_Config_Bank(i));
@@ -2958,6 +2823,7 @@
 	}
 	for (i = 0; i < n_chans; i++) {
 		const struct comedi_krange *krange;
+
 		chan = CR_CHAN(chanspec[i]);
 		range = CR_RANGE(chanspec[i]);
 		krange = s->range_table->range + range;
@@ -2985,8 +2851,9 @@
 				  M_Offset_AO_Reference_Attenuation(chan));
 			break;
 		default:
-			printk("%s: bug! unhandled ao reference voltage\n",
-			       __func__);
+			dev_err(dev->class_dev,
+				"%s: bug! unhandled ao reference voltage\n",
+				__func__);
 			break;
 		}
 		switch (krange->max + krange->min) {
@@ -2997,8 +2864,9 @@
 			conf |= MSeries_AO_DAC_Offset_5V_Bits;
 			break;
 		default:
-			printk("%s: bug! unhandled ao offset voltage\n",
-			       __func__);
+			dev_err(dev->class_dev,
+				"%s: bug! unhandled ao offset voltage\n",
+				__func__);
 			break;
 		}
 		if (timed)
@@ -3015,7 +2883,6 @@
 				     unsigned int chanspec[],
 				     unsigned int n_chans)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
 	unsigned int range;
 	unsigned int chan;
@@ -3028,19 +2895,14 @@
 		range = CR_RANGE(chanspec[i]);
 		conf = AO_Channel(chan);
 
-		if (board->ao_unipolar) {
-			if ((range & 1) == 0) {
-				conf |= AO_Bipolar;
-				invert = (1 << (board->aobits - 1));
-			} else {
-				invert = 0;
-			}
-			if (range & 2)
-				conf |= AO_Ext_Ref;
-		} else {
+		if (comedi_range_is_bipolar(s, range)) {
 			conf |= AO_Bipolar;
-			invert = (1 << (board->aobits - 1));
+			invert = (s->maxdata + 1) >> 1;
+		} else {
+			invert = 0;
 		}
+		if (comedi_range_is_external(s, range))
+			conf |= AO_Ext_Ref;
 
 		/* not all boards can deglitch, but this shouldn't hurt */
 		if (chanspec[i] & CR_DEGLITCH)
@@ -3072,55 +2934,75 @@
 }
 
 static int ni_ao_insn_read(struct comedi_device *dev,
-			   struct comedi_subdevice *s, struct comedi_insn *insn,
+			   struct comedi_subdevice *s,
+			   struct comedi_insn *insn,
 			   unsigned int *data)
 {
 	struct ni_private *devpriv = dev->private;
+	unsigned int chan = CR_CHAN(insn->chanspec);
+	int i;
 
-	data[0] = devpriv->ao[CR_CHAN(insn->chanspec)];
+	for (i = 0; i < insn->n; i++)
+		data[i] = devpriv->ao[chan];
 
-	return 1;
+	return insn->n;
 }
 
 static int ni_ao_insn_write(struct comedi_device *dev,
 			    struct comedi_subdevice *s,
-			    struct comedi_insn *insn, unsigned int *data)
+			    struct comedi_insn *insn,
+			    unsigned int *data)
 {
 	struct ni_private *devpriv = dev->private;
 	unsigned int chan = CR_CHAN(insn->chanspec);
-	unsigned int invert;
+	unsigned int range = CR_RANGE(insn->chanspec);
+	int reg;
+	int i;
 
-	invert = ni_ao_config_chanlist(dev, s, &insn->chanspec, 1, 0);
+	if (devpriv->is_6xxx) {
+		ni_ao_win_outw(dev, 1 << chan, AO_Immediate_671x);
 
-	devpriv->ao[chan] = data[0];
-
-	if (devpriv->is_m_series) {
-		ni_writew(dev, data[0], M_Offset_DAC_Direct_Data(chan));
-	} else
-		ni_writew(dev, data[0] ^ invert,
-			  (chan) ? DAC1_Direct_Data : DAC0_Direct_Data);
-
-	return 1;
-}
-
-static int ni_ao_insn_write_671x(struct comedi_device *dev,
-				 struct comedi_subdevice *s,
-				 struct comedi_insn *insn, unsigned int *data)
-{
-	const struct ni_board_struct *board = comedi_board(dev);
-	struct ni_private *devpriv = dev->private;
-	unsigned int chan = CR_CHAN(insn->chanspec);
-	unsigned int invert;
-
-	ao_win_out(1 << chan, AO_Immediate_671x);
-	invert = 1 << (board->aobits - 1);
+		reg = DACx_Direct_Data_671x(chan);
+	} else if (devpriv->is_m_series) {
+		reg = M_Offset_DAC_Direct_Data(chan);
+	} else {
+		reg = (chan) ? DAC1_Direct_Data : DAC0_Direct_Data;
+	}
 
 	ni_ao_config_chanlist(dev, s, &insn->chanspec, 1, 0);
 
-	devpriv->ao[chan] = data[0];
-	ao_win_out(data[0] ^ invert, DACx_Direct_Data_671x(chan));
+	for (i = 0; i < insn->n; i++) {
+		unsigned int val = data[i];
 
-	return 1;
+		devpriv->ao[chan] = val;
+
+		if (devpriv->is_6xxx) {
+			/*
+			 * 6xxx boards have bipolar outputs, munge the
+			 * unsigned comedi values to 2's complement
+			 */
+			val = comedi_offset_munge(s, val);
+
+			ni_ao_win_outw(dev, val, reg);
+		} else if (devpriv->is_m_series) {
+			/*
+			 * M-series boards use offset binary values for
+			 * bipolar and uinpolar outputs
+			 */
+			ni_writew(dev, val, reg);
+		} else {
+			/*
+			 * Non-M series boards need two's complement values
+			 * for bipolar ranges.
+			 */
+			if (comedi_range_is_bipolar(s, range))
+				val = comedi_offset_munge(s, val);
+
+			ni_writew(dev, val, reg);
+		}
+	}
+
+	return insn->n;
 }
 
 static int ni_ao_insn_config(struct comedi_device *dev,
@@ -3143,7 +3025,6 @@
 			break;
 		default:
 			return -EINVAL;
-			break;
 		}
 		return 0;
 	default:
@@ -3157,7 +3038,6 @@
 			 struct comedi_subdevice *s,
 			 unsigned int trig_num)
 {
-	const struct ni_board_struct *board __maybe_unused = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
 	struct comedi_cmd *cmd = &s->async->cmd;
 	int ret;
@@ -3178,7 +3058,7 @@
 	interrupt_b_bits = AO_Error_Interrupt_Enable;
 #ifdef PCIDMA
 	ni_stc_writew(dev, 1, DAC_FIFO_Clear);
-	if (board->reg_type & ni_reg_6xxx_mask)
+	if (devpriv->is_6xxx)
 		ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x);
 	ret = ni_ao_setup_MITE_dma(dev);
 	if (ret)
@@ -3205,8 +3085,8 @@
 			break;
 	}
 	if (i == timeout) {
-		comedi_error(dev,
-			     "timed out waiting for AO_TMRDACWRs_In_Progress_St to clear");
+		dev_err(dev->class_dev,
+			"timed out waiting for AO_TMRDACWRs_In_Progress_St to clear\n");
 		return -EIO;
 	}
 	/*
@@ -3238,7 +3118,7 @@
 	unsigned trigvar;
 
 	if (dev->irq == 0) {
-		comedi_error(dev, "cannot run command without an irq");
+		dev_err(dev->class_dev, "cannot run command without an irq\n");
 		return -EIO;
 	}
 
@@ -3246,8 +3126,8 @@
 
 	ni_stc_writew(dev, AO_Disarm, AO_Command_1_Register);
 
-	if (board->reg_type & ni_reg_6xxx_mask) {
-		ao_win_out(CLEAR_WG, AO_Misc_611x);
+	if (devpriv->is_6xxx) {
+		ni_ao_win_outw(dev, CLEAR_WG, AO_Misc_611x);
 
 		bits = 0;
 		for (i = 0; i < cmd->chanlist_len; i++) {
@@ -3255,9 +3135,9 @@
 
 			chan = CR_CHAN(cmd->chanlist[i]);
 			bits |= 1 << chan;
-			ao_win_out(chan, AO_Waveform_Generation_611x);
+			ni_ao_win_outw(dev, chan, AO_Waveform_Generation_611x);
 		}
-		ao_win_out(bits, AO_Timed_611x);
+		ni_ao_win_outw(dev, bits, AO_Timed_611x);
 	}
 
 	ni_ao_config_chanlist(dev, s, cmd->chanlist, cmd->chanlist_len, 1);
@@ -3370,10 +3250,10 @@
 			      AO_Output_Control_Register);
 	} else {
 		unsigned bits;
+
 		devpriv->ao_mode1 &= ~AO_Multiple_Channels;
 		bits = AO_UPDATE_Output_Select(AO_Update_Output_High_Z);
-		if (devpriv->is_m_series ||
-		    board->reg_type & ni_reg_6xxx_mask) {
+		if (devpriv->is_m_series || devpriv->is_6xxx) {
 			bits |= AO_Number_Of_Channels(0);
 		} else {
 			bits |=
@@ -3502,9 +3382,7 @@
 		cmd->scan_begin_arg =
 		    ni_timer_to_ns(dev, ni_ns_to_timer(dev,
 						       cmd->scan_begin_arg,
-						       cmd->
-						       flags &
-						       TRIG_ROUND_MASK));
+						       cmd->flags));
 		if (tmp != cmd->scan_begin_arg)
 			err++;
 	}
@@ -3516,7 +3394,6 @@
 
 static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s)
 {
-	const struct ni_board_struct *board = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
 
 	ni_release_ao_mite_channel(dev);
@@ -3546,13 +3423,14 @@
 	devpriv->ao_trigger_select = 0;
 	ni_stc_writew(dev, devpriv->ao_trigger_select,
 		      AO_Trigger_Select_Register);
-	if (board->reg_type & ni_reg_6xxx_mask) {
+	if (devpriv->is_6xxx) {
 		unsigned immediate_bits = 0;
 		unsigned i;
+
 		for (i = 0; i < s->n_chan; ++i)
 			immediate_bits |= 1 << i;
-		ao_win_out(immediate_bits, AO_Immediate_671x);
-		ao_win_out(CLEAR_WG, AO_Misc_611x);
+		ni_ao_win_outw(dev, immediate_bits, AO_Immediate_671x);
+		ni_ao_win_outw(dev, CLEAR_WG, AO_Misc_611x);
 	}
 	ni_stc_writew(dev, AO_Configuration_End, Joint_Reset_Register);
 
@@ -3728,7 +3606,7 @@
 		mite_prep_dma(devpriv->cdo_mite_chan, 32, 32);
 		mite_dma_arm(devpriv->cdo_mite_chan);
 	} else {
-		comedi_error(dev, "BUG: no cdo mite channel?");
+		dev_err(dev->class_dev, "BUG: no cdo mite channel?\n");
 		retval = -EIO;
 	}
 	spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
@@ -3746,7 +3624,7 @@
 		udelay(10);
 	}
 	if (i == timeout) {
-		comedi_error(dev, "dma failed to fill cdo fifo!");
+		dev_err(dev->class_dev, "dma failed to fill cdo fifo!\n");
 		s->cancel(dev, s);
 		return -EIO;
 	}
@@ -3781,8 +3659,8 @@
 		ni_writel(dev, CDO_SW_Update_Bit, M_Offset_CDIO_Command);
 		ni_writel(dev, s->io_bits, M_Offset_CDO_Mask_Enable);
 	} else {
-		comedi_error(dev,
-			     "attempted to run digital output command with no lines configured as outputs");
+		dev_err(dev->class_dev,
+			"attempted to run digital output command with no lines configured as outputs\n");
 		return -EIO;
 	}
 	retval = ni_request_cdo_mite_channel(dev);
@@ -3837,14 +3715,12 @@
 
 	cdio_status = ni_readl(dev, M_Offset_CDIO_Status);
 	if (cdio_status & (CDO_Overrun_Bit | CDO_Underflow_Bit)) {
-		/* printk("cdio error: statux=0x%x\n", cdio_status); */
 		/* XXX just guessing this is needed and does something useful */
 		ni_writel(dev, CDO_Error_Interrupt_Confirm_Bit,
 			  M_Offset_CDIO_Command);
 		s->async->events |= COMEDI_CB_OVERFLOW;
 	}
 	if (cdio_status & CDO_FIFO_Empty_Bit) {
-		/* printk("cdio fifo empty\n"); */
 		ni_writel(dev, CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit,
 			  M_Offset_CDIO_Command);
 		/* s->async->events |= COMEDI_CB_EOA; */
@@ -3881,8 +3757,9 @@
 		/* Delay one bit per loop */
 		udelay((devpriv->serial_interval_ns + 999) / 1000);
 		if (--count < 0) {
-			printk
-			    ("ni_serial_hw_readwrite8: SPI serial I/O didn't finish in time!\n");
+			dev_err(dev->class_dev,
+				"%s: SPI serial I/O didn't finish in time!\n",
+				__func__);
 			err = -ETIME;
 			goto Error;
 		}
@@ -3934,10 +3811,8 @@
 		udelay((devpriv->serial_interval_ns + 999) / 2000);
 
 		/* Input current bit */
-		if (ni_stc_readw(dev, DIO_Parallel_Input_Register) & DIO_SDIN) {
-			/* printk("DIO_P_I_R: 0x%x\n", ni_stc_readw(dev, DIO_Parallel_Input_Register)); */
+		if (ni_stc_readw(dev, DIO_Parallel_Input_Register) & DIO_SDIN)
 			input |= mask;
-		}
 	}
 
 	if (data_in)
@@ -4022,7 +3897,8 @@
 			err = ni_serial_sw_readwrite8(dev, s, byte_out,
 						      &byte_in);
 		} else {
-			printk("ni_serial_insn_config: serial disabled!\n");
+			dev_err(dev->class_dev, "%s: serial disabled!\n",
+				__func__);
 			return -EINVAL;
 		}
 		if (err < 0)
@@ -4045,12 +3921,13 @@
 		ni_ao_win_outw(dev, AO_Channel(i) | 0x0,
 			       AO_Configuration_2_67xx);
 	}
-	ao_win_out(0x0, AO_Later_Single_Point_Updates);
+	ni_ao_win_outw(dev, 0x0, AO_Later_Single_Point_Updates);
 }
 
 static unsigned ni_gpct_to_stc_register(enum ni_gpct_register reg)
 {
 	unsigned stc_register;
+
 	switch (reg) {
 	case NITIO_G0_AUTO_INC:
 		stc_register = G_Autoincrement_Register(0);
@@ -4135,7 +4012,6 @@
 		       __func__, reg);
 		BUG();
 		return 0;
-		break;
 	}
 	return stc_register;
 }
@@ -4233,7 +4109,6 @@
 	default:
 		stc_register = ni_gpct_to_stc_register(reg);
 		return ni_stc_readw(dev, stc_register);
-		break;
 	}
 	return 0;
 }
@@ -4320,9 +4195,9 @@
 	if (dir) {
 		ni_writeb(dev, data, Port_A + 2 * port);
 		return 0;
-	} else {
-		return ni_readb(dev, Port_A + 2 * port);
 	}
+
+	return ni_readb(dev, Port_A + 2 * port);
 }
 
 static int ni_get_pwm_config(struct comedi_device *dev, unsigned int *data)
@@ -4360,7 +4235,6 @@
 			break;
 		default:
 			return -EINVAL;
-			break;
 		}
 		switch (data[3]) {
 		case TRIG_ROUND_NEAREST:
@@ -4378,7 +4252,6 @@
 			break;
 		default:
 			return -EINVAL;
-			break;
 		}
 		if (up_count * devpriv->clock_ns != data[2] ||
 		    down_count * devpriv->clock_ns != data[4]) {
@@ -4392,13 +4265,10 @@
 		devpriv->pwm_up_count = up_count;
 		devpriv->pwm_down_count = down_count;
 		return 5;
-		break;
 	case INSN_CONFIG_GET_PWM_OUTPUT:
 		return ni_get_pwm_config(dev, data);
-		break;
 	default:
 		return -EINVAL;
-		break;
 	}
 	return 0;
 }
@@ -4429,7 +4299,6 @@
 			break;
 		default:
 			return -EINVAL;
-			break;
 		}
 		switch (data[3]) {
 		case TRIG_ROUND_NEAREST:
@@ -4447,7 +4316,6 @@
 			break;
 		default:
 			return -EINVAL;
-			break;
 		}
 		if (up_count * devpriv->clock_ns != data[2] ||
 		    down_count * devpriv->clock_ns != data[4]) {
@@ -4460,12 +4328,10 @@
 		ni_writel(dev, down_count, Calibration_LowTime_6143);
 		devpriv->pwm_down_count = down_count;
 		return 5;
-		break;
 	case INSN_CONFIG_GET_PWM_OUTPUT:
 		return ni_get_pwm_config(dev, data);
 	default:
 		return -EINVAL;
-		break;
 	}
 	return 0;
 }
@@ -4542,7 +4408,6 @@
 	int i;
 	int type;
 
-	/* printk("ni_write_caldac: chan=%d val=%d\n",addr,val); */
 	if (devpriv->caldacs[addr] == val)
 		return;
 	devpriv->caldacs[addr] = val;
@@ -4554,7 +4419,6 @@
 		if (addr < caldacs[type].n_chans) {
 			bits = caldacs[type].packbits(addr, val, &bitstring);
 			loadbit = SerDacLd(i);
-			/* printk("caldac: using i=%d addr=%d %x\n",i,addr,bitstring); */
 			break;
 		}
 		addr -= caldacs[type].n_chans;
@@ -4625,7 +4489,8 @@
 		unsigned int *maxdata_list;
 
 		if (n_chans > MAX_N_CALDACS)
-			printk("BUG! MAX_N_CALDACS too small\n");
+			dev_err(dev->class_dev,
+				"BUG! MAX_N_CALDACS too small\n");
 		s->maxdata_list = maxdata_list = devpriv->caldac_maxdata_list;
 		chan = 0;
 		for (i = 0; i < n_dacs; i++) {
@@ -4701,36 +4566,27 @@
 	switch (chan) {
 	case 0:
 		return NI_PFI_OUTPUT_AI_START1;
-		break;
 	case 1:
 		return NI_PFI_OUTPUT_AI_START2;
-		break;
 	case 2:
 		return NI_PFI_OUTPUT_AI_CONVERT;
-		break;
 	case 3:
 		return NI_PFI_OUTPUT_G_SRC1;
-		break;
 	case 4:
 		return NI_PFI_OUTPUT_G_GATE1;
-		break;
 	case 5:
 		return NI_PFI_OUTPUT_AO_UPDATE_N;
-		break;
 	case 6:
 		return NI_PFI_OUTPUT_AO_START1;
-		break;
 	case 7:
 		return NI_PFI_OUTPUT_AI_START_PULSE;
-		break;
 	case 8:
 		return NI_PFI_OUTPUT_G_SRC0;
-		break;
 	case 9:
 		return NI_PFI_OUTPUT_G_GATE0;
-		break;
 	default:
-		printk("%s: bug, unhandled case in switch.\n", __func__);
+		dev_err(dev->class_dev,
+			"%s: bug, unhandled case in switch.\n", __func__);
 		break;
 	}
 	return 0;
@@ -4779,10 +4635,9 @@
 {
 	struct ni_private *devpriv = dev->private;
 
-	if (devpriv->is_m_series)
-		return ni_m_series_get_pfi_routing(dev, chan);
-	else
-		return ni_old_get_pfi_routing(dev, chan);
+	return (devpriv->is_m_series)
+			? ni_m_series_get_pfi_routing(dev, chan)
+			: ni_old_get_pfi_routing(dev, chan);
 }
 
 static int ni_set_pfi_routing(struct comedi_device *dev, unsigned chan,
@@ -4790,10 +4645,9 @@
 {
 	struct ni_private *devpriv = dev->private;
 
-	if (devpriv->is_m_series)
-		return ni_m_series_set_pfi_routing(dev, chan, source);
-	else
-		return ni_old_set_pfi_routing(dev, chan, source);
+	return (devpriv->is_m_series)
+			? ni_m_series_set_pfi_routing(dev, chan, source)
+			: ni_old_set_pfi_routing(dev, chan, source);
 }
 
 static int ni_config_filter(struct comedi_device *dev,
@@ -4838,16 +4692,13 @@
 		    (devpriv->io_bidirection_pin_reg & (1 << chan)) ?
 		    COMEDI_OUTPUT : COMEDI_INPUT;
 		return 0;
-		break;
 	case INSN_CONFIG_SET_ROUTING:
 		return ni_set_pfi_routing(dev, chan, data[1]);
-		break;
 	case INSN_CONFIG_GET_ROUTING:
 		data[1] = ni_get_pfi_routing(dev, chan);
 		break;
 	case INSN_CONFIG_FILTER:
 		return ni_config_filter(dev, chan, data[1]);
-		break;
 	default:
 		return -EINVAL;
 	}
@@ -4886,9 +4737,8 @@
 		if (schedule_timeout(1))
 			return -EIO;
 	}
-/* printk("looped %i times waiting for idle\n", i); */
 	if (i == timeout) {
-		printk("%s: %s: timeout\n", __FILE__, __func__);
+		dev_err(dev->class_dev, "%s timeout\n", __func__);
 		return -ETIME;
 	}
 	return 0;
@@ -4909,9 +4759,9 @@
 			break;
 		udelay(1);
 	}
-/* printk("looped %i times writing command to cs5529\n", i); */
 	if (i == timeout)
-		comedi_error(dev, "possible problem - never saw adc go busy?");
+		dev_err(dev->class_dev,
+			"possible problem - never saw adc go busy?\n");
 }
 
 static int cs5529_do_conversion(struct comedi_device *dev,
@@ -4923,19 +4773,19 @@
 	cs5529_command(dev, CSCMD_COMMAND | CSCMD_SINGLE_CONVERSION);
 	retval = cs5529_wait_for_idle(dev);
 	if (retval) {
-		comedi_error(dev,
-			     "timeout or signal in cs5529_do_conversion()");
+		dev_err(dev->class_dev,
+			"timeout or signal in cs5529_do_conversion()\n");
 		return -ETIME;
 	}
 	status = ni_ao_win_inw(dev, CAL_ADC_Status_67xx);
 	if (status & CSS_OSC_DETECT) {
-		printk
-		    ("ni_mio_common: cs5529 conversion error, status CSS_OSC_DETECT\n");
+		dev_err(dev->class_dev,
+			"cs5529 conversion error, status CSS_OSC_DETECT\n");
 		return -EIO;
 	}
 	if (status & CSS_OVERRANGE) {
-		printk
-		    ("ni_mio_common: cs5529 conversion error, overrange (ignoring)\n");
+		dev_err(dev->class_dev,
+			"cs5529 conversion error, overrange (ignoring)\n");
 	}
 	if (data) {
 		*data = ni_ao_win_inw(dev, CAL_ADC_Data_67xx);
@@ -4983,7 +4833,8 @@
 	reg_select_bits &= CSCMD_REGISTER_SELECT_MASK;
 	cs5529_command(dev, CSCMD_COMMAND | reg_select_bits);
 	if (cs5529_wait_for_idle(dev))
-		comedi_error(dev, "time or signal in cs5529_config_write()");
+		dev_err(dev->class_dev,
+			"timeout or signal in %s\n", __func__);
 }
 
 static int init_cs5529(struct comedi_device *dev)
@@ -5003,7 +4854,8 @@
 	cs5529_config_write(dev, config_bits | CSCFG_SELF_CAL_OFFSET,
 			    CSCMD_CONFIG_REGISTER);
 	if (cs5529_wait_for_idle(dev))
-		comedi_error(dev, "timeout or signal in init_cs5529()\n");
+		dev_err(dev->class_dev,
+			"timeout or signal in %s\n", __func__);
 #endif
 	return 0;
 }
@@ -5031,6 +4883,7 @@
 	static const unsigned target_picosec = 12500;
 	static const unsigned fudge_factor_80_to_20Mhz = 4;
 	int best_period_picosec = 0;
+
 	for (div = 1; div <= max_div; ++div) {
 		for (mult = 1; mult <= max_mult; ++mult) {
 			unsigned new_period_ps =
@@ -5043,10 +4896,9 @@
 			}
 		}
 	}
-	if (best_period_picosec == 0) {
-		printk("%s: bug, failed to find pll parameters\n", __func__);
+	if (best_period_picosec == 0)
 		return -EIO;
-	}
+
 	*freq_divider = best_div;
 	*freq_multiplier = best_mult;
 	*actual_period_ns =
@@ -5072,10 +4924,9 @@
 		period_ns = 100;
 	/*  these limits are somewhat arbitrary, but NI advertises 1 to 20MHz range so we'll use that */
 	if (period_ns < min_period_ns || period_ns > max_period_ns) {
-		printk
-		    ("%s: you must specify an input clock frequency between %i and %i nanosec "
-		     "for the phased-lock loop.\n", __func__,
-		     min_period_ns, max_period_ns);
+		dev_err(dev->class_dev,
+			"%s: you must specify an input clock frequency between %i and %i nanosec for the phased-lock loop\n",
+			__func__, min_period_ns, max_period_ns);
 		return -EINVAL;
 	}
 	devpriv->rtsi_trig_direction_reg &= ~Use_RTSI_Clock_Bit;
@@ -5090,26 +4941,17 @@
 	case NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK:
 		devpriv->clock_and_fout2 |=
 		    MSeries_PLL_In_Source_Select_Star_Trigger_Bits;
-		retval = ni_mseries_get_pll_parameters(period_ns, &freq_divider,
-						       &freq_multiplier,
-						       &devpriv->clock_ns);
-		if (retval < 0)
-			return retval;
 		break;
 	case NI_MIO_PLL_PXI10_CLOCK:
 		/* pxi clock is 10MHz */
 		devpriv->clock_and_fout2 |=
 		    MSeries_PLL_In_Source_Select_PXI_Clock10;
-		retval = ni_mseries_get_pll_parameters(period_ns, &freq_divider,
-						       &freq_multiplier,
-						       &devpriv->clock_ns);
-		if (retval < 0)
-			return retval;
 		break;
 	default:
 		{
 			unsigned rtsi_channel;
 			static const unsigned max_rtsi_channel = 7;
+
 			for (rtsi_channel = 0; rtsi_channel <= max_rtsi_channel;
 			     ++rtsi_channel) {
 				if (source ==
@@ -5122,24 +4964,24 @@
 			}
 			if (rtsi_channel > max_rtsi_channel)
 				return -EINVAL;
-			retval = ni_mseries_get_pll_parameters(period_ns,
-							       &freq_divider,
-							       &freq_multiplier,
-							       &devpriv->
-							       clock_ns);
-			if (retval < 0)
-				return retval;
 		}
 		break;
 	}
+	retval = ni_mseries_get_pll_parameters(period_ns,
+					       &freq_divider,
+					       &freq_multiplier,
+					       &devpriv->clock_ns);
+	if (retval < 0) {
+		dev_err(dev->class_dev,
+			"%s: bug, failed to find pll parameters\n", __func__);
+		return retval;
+	}
+
 	ni_writew(dev, devpriv->clock_and_fout2, M_Offset_Clock_and_Fout2);
 	pll_control_bits |=
 	    MSeries_PLL_Divisor_Bits(freq_divider) |
 	    MSeries_PLL_Multiplier_Bits(freq_multiplier);
 
-	/* printk("using divider=%i, multiplier=%i for PLL. pll_control_bits = 0x%x\n",
-	 * freq_divider, freq_multiplier, pll_control_bits); */
-	/* printk("clock_ns=%d\n", devpriv->clock_ns); */
 	ni_writew(dev, pll_control_bits, M_Offset_PLL_Control);
 	devpriv->clock_source = source;
 	/* it seems to typically take a few hundred microseconds for PLL to lock */
@@ -5149,9 +4991,9 @@
 		udelay(1);
 	}
 	if (i == timeout) {
-		printk
-		    ("%s: timed out waiting for PLL to lock to reference clock source %i with period %i ns.\n",
-		     __func__, source, period_ns);
+		dev_err(dev->class_dev,
+			"%s: timed out waiting for PLL to lock to reference clock source %i with period %i ns\n",
+			__func__, source, period_ns);
 		return -ETIMEDOUT;
 	}
 	return 3;
@@ -5188,13 +5030,12 @@
 					      devpriv->rtsi_trig_direction_reg,
 					      RTSI_Trig_Direction_Register);
 				if (period_ns == 0) {
-					printk
-					    ("%s: we don't handle an unspecified clock period correctly yet, returning error.\n",
-					     __func__);
+					dev_err(dev->class_dev,
+						"%s: we don't handle an unspecified clock period correctly yet, returning error\n",
+						__func__);
 					return -EINVAL;
-				} else {
-					devpriv->clock_ns = period_ns;
 				}
+				devpriv->clock_ns = period_ns;
 				devpriv->clock_source = source;
 			} else
 				return -EINVAL;
@@ -5207,10 +5048,7 @@
 {
 	struct ni_private *devpriv = dev->private;
 
-	if (devpriv->is_m_series)
-		return 8;
-	else
-		return 7;
+	return (devpriv->is_m_series) ? 8 : 7;
 }
 
 static int ni_valid_rtsi_output_source(struct comedi_device *dev,
@@ -5222,12 +5060,11 @@
 		if (chan == old_RTSI_clock_channel) {
 			if (source == NI_RTSI_OUTPUT_RTSI_OSC)
 				return 1;
-			else {
-				printk
-				    ("%s: invalid source for channel=%i, channel %i is always the RTSI clock for pre-m-series boards.\n",
-				     __func__, chan, old_RTSI_clock_channel);
-				return 0;
-			}
+
+			dev_err(dev->class_dev,
+				"%s: invalid source for channel=%i, channel %i is always the RTSI clock for pre-m-series boards\n",
+				__func__, chan, old_RTSI_clock_channel);
+			return 0;
 		}
 		return 0;
 	}
@@ -5242,16 +5079,10 @@
 	case NI_RTSI_OUTPUT_RGOUT0:
 	case NI_RTSI_OUTPUT_RTSI_BRD_0:
 		return 1;
-		break;
 	case NI_RTSI_OUTPUT_RTSI_OSC:
-		if (devpriv->is_m_series)
-			return 1;
-		else
-			return 0;
-		break;
+		return (devpriv->is_m_series) ? 1 : 0;
 	default:
 		return 0;
-		break;
 	}
 }
 
@@ -5291,7 +5122,8 @@
 	} else {
 		if (chan == old_RTSI_clock_channel)
 			return NI_RTSI_OUTPUT_RTSI_OSC;
-		printk("%s: bug! should never get here?\n", __func__);
+		dev_err(dev->class_dev, "%s: bug! should never get here?\n",
+			__func__);
 		return 0;
 	}
 }
@@ -5341,25 +5173,19 @@
 			    ? INSN_CONFIG_DIO_OUTPUT : INSN_CONFIG_DIO_INPUT;
 		}
 		return 2;
-		break;
 	case INSN_CONFIG_SET_CLOCK_SRC:
 		return ni_set_master_clock(dev, data[1], data[2]);
-		break;
 	case INSN_CONFIG_GET_CLOCK_SRC:
 		data[1] = devpriv->clock_source;
 		data[2] = devpriv->clock_ns;
 		return 3;
-		break;
 	case INSN_CONFIG_SET_ROUTING:
 		return ni_set_rtsi_routing(dev, chan, data[1]);
-		break;
 	case INSN_CONFIG_GET_ROUTING:
 		data[1] = ni_get_rtsi_routing(dev, chan);
 		return 2;
-		break;
 	default:
 		return -EINVAL;
-		break;
 	}
 	return 1;
 }
@@ -5383,7 +5209,7 @@
 	/*  Set clock mode to internal */
 	devpriv->clock_and_fout2 = MSeries_RTSI_10MHz_Bit;
 	if (ni_set_master_clock(dev, NI_MIO_INTERNAL_CLOCK, 0) < 0)
-		printk("ni_set_master_clock failed, bug?");
+		dev_err(dev->class_dev, "ni_set_master_clock failed, bug?\n");
 	/*  default internal lines routing to RTSI bus lines */
 	devpriv->rtsi_trig_a_output_reg =
 	    RTSI_Trig_Output_Bits(0,
@@ -5422,8 +5248,8 @@
 	retval = ni_request_gpct_mite_channel(dev, counter->counter_index,
 					      COMEDI_INPUT);
 	if (retval) {
-		comedi_error(dev,
-			     "no dma channel available for use by counter");
+		dev_err(dev->class_dev,
+			"no dma channel available for use by counter\n");
 		return retval;
 	}
 	ni_tio_acknowledge_and_confirm(counter, NULL, NULL, NULL, NULL);
@@ -5475,7 +5301,6 @@
 {
 	int temp_ack_reg = 0;
 
-	/* printk("GPCT_Reset..."); */
 	devpriv->gpct_cur_operation[chan] = GPCT_RESET;
 
 	switch (chan) {
@@ -5524,8 +5349,6 @@
 	ni_stc_writew(dev, devpriv->gpct_input_select[chan],
 		      G_Input_Select_Register(chan));
 	ni_stc_writew(dev, 0, G_Autoincrement_Register(chan));
-
-	/* printk("exit GPCT_Reset\n"); */
 }
 #endif
 
@@ -5610,115 +5433,138 @@
 	const struct ni_board_struct *board = comedi_board(dev);
 	struct ni_private *devpriv = dev->private;
 	struct comedi_subdevice *s;
-	unsigned j;
-	enum ni_gpct_variant counter_variant;
 	int ret;
+	int i;
 
 	if (board->n_aochan > MAX_N_AO_CHAN) {
-		printk("bug! n_aochan > MAX_N_AO_CHAN\n");
+		dev_err(dev->class_dev, "bug! n_aochan > MAX_N_AO_CHAN\n");
 		return -EINVAL;
 	}
 
+	/* initialize clock dividers */
+	devpriv->clock_and_fout = Slow_Internal_Time_Divide_By_2 |
+				  Slow_Internal_Timebase |
+				  Clock_To_Board_Divide_By_2 |
+				  Clock_To_Board;
+	if (!devpriv->is_6xxx) {
+		/* BEAM is this needed for PCI-6143 ?? */
+		devpriv->clock_and_fout |= (AI_Output_Divide_By_2 |
+					    AO_Output_Divide_By_2);
+	}
+	ni_stc_writew(dev, devpriv->clock_and_fout, Clock_and_FOUT_Register);
+
 	ret = comedi_alloc_subdevices(dev, NI_NUM_SUBDEVICES);
 	if (ret)
 		return ret;
 
-	/* analog input subdevice */
-
+	/* Analog Input subdevice */
 	s = &dev->subdevices[NI_AI_SUBDEV];
-	dev->read_subdev = s;
 	if (board->n_adchan) {
-		s->type = COMEDI_SUBD_AI;
-		s->subdev_flags =
-		    SDF_READABLE | SDF_DIFF | SDF_DITHER | SDF_CMD_READ;
-		if (board->reg_type != ni_reg_611x)
-			s->subdev_flags |= SDF_GROUND | SDF_COMMON | SDF_OTHER;
-		if (board->adbits > 16)
-			s->subdev_flags |= SDF_LSAMPL;
+		s->type		= COMEDI_SUBD_AI;
+		s->subdev_flags	= SDF_READABLE | SDF_DIFF | SDF_DITHER;
+		if (!devpriv->is_611x)
+			s->subdev_flags	|= SDF_GROUND | SDF_COMMON | SDF_OTHER;
+		if (board->ai_maxdata > 0xffff)
+			s->subdev_flags	|= SDF_LSAMPL;
 		if (devpriv->is_m_series)
-			s->subdev_flags |= SDF_SOFT_CALIBRATED;
-		s->n_chan = board->n_adchan;
-		s->len_chanlist = 512;
-		s->maxdata = (1 << board->adbits) - 1;
-		s->range_table = ni_range_lkup[board->gainlkup];
-		s->insn_read = &ni_ai_insn_read;
-		s->insn_config = &ni_ai_insn_config;
-		s->do_cmdtest = &ni_ai_cmdtest;
-		s->do_cmd = &ni_ai_cmd;
-		s->cancel = &ni_ai_reset;
-		s->poll = &ni_ai_poll;
-		s->munge = &ni_ai_munge;
-#ifdef PCIDMA
-		s->async_dma_dir = DMA_FROM_DEVICE;
-#endif
+			s->subdev_flags	|= SDF_SOFT_CALIBRATED;
+		s->n_chan	= board->n_adchan;
+		s->maxdata	= board->ai_maxdata;
+		s->range_table	= ni_range_lkup[board->gainlkup];
+		s->insn_read	= ni_ai_insn_read;
+		s->insn_config	= ni_ai_insn_config;
+		if (dev->irq) {
+			dev->read_subdev = s;
+			s->subdev_flags	|= SDF_CMD_READ;
+			s->len_chanlist	= 512;
+			s->do_cmdtest	= ni_ai_cmdtest;
+			s->do_cmd	= ni_ai_cmd;
+			s->cancel	= ni_ai_reset;
+			s->poll		= ni_ai_poll;
+			s->munge	= ni_ai_munge;
+
+			if (devpriv->mite)
+				s->async_dma_dir = DMA_FROM_DEVICE;
+		}
+
+		/* reset the analog input configuration */
+		ni_ai_reset(dev, s);
 	} else {
-		s->type = COMEDI_SUBD_UNUSED;
+		s->type		= COMEDI_SUBD_UNUSED;
 	}
 
-	/* analog output subdevice */
-
+	/* Analog Output subdevice */
 	s = &dev->subdevices[NI_AO_SUBDEV];
 	if (board->n_aochan) {
-		s->type = COMEDI_SUBD_AO;
-		s->subdev_flags = SDF_WRITABLE | SDF_DEGLITCH | SDF_GROUND;
+		s->type		= COMEDI_SUBD_AO;
+		s->subdev_flags	= SDF_WRITABLE | SDF_DEGLITCH | SDF_GROUND;
 		if (devpriv->is_m_series)
-			s->subdev_flags |= SDF_SOFT_CALIBRATED;
-		s->n_chan = board->n_aochan;
-		s->maxdata = (1 << board->aobits) - 1;
-		s->range_table = board->ao_range_table;
-		s->insn_read = &ni_ao_insn_read;
-		if (board->reg_type & ni_reg_6xxx_mask)
-			s->insn_write = &ni_ao_insn_write_671x;
-		else
-			s->insn_write = &ni_ao_insn_write;
-		s->insn_config = &ni_ao_insn_config;
-#ifdef PCIDMA
-		if (board->n_aochan) {
-			s->async_dma_dir = DMA_TO_DEVICE;
-#else
-		if (board->ao_fifo_depth) {
-#endif
+			s->subdev_flags	|= SDF_SOFT_CALIBRATED;
+		s->n_chan	= board->n_aochan;
+		s->maxdata	= board->ao_maxdata;
+		s->range_table	= board->ao_range_table;
+		s->insn_read	= ni_ao_insn_read;
+		s->insn_write	= ni_ao_insn_write;
+		s->insn_config	= ni_ao_insn_config;
+
+		/*
+		 * Along with the IRQ we need either a FIFO or DMA for
+		 * async command support.
+		 */
+		if (dev->irq && (board->ao_fifo_depth || devpriv->mite)) {
 			dev->write_subdev = s;
-			s->subdev_flags |= SDF_CMD_WRITE;
-			s->do_cmd = &ni_ao_cmd;
-			s->do_cmdtest = &ni_ao_cmdtest;
-			s->len_chanlist = board->n_aochan;
+			s->subdev_flags	|= SDF_CMD_WRITE;
+			s->len_chanlist	= s->n_chan;
+			s->do_cmdtest	= ni_ao_cmdtest;
+			s->do_cmd	= ni_ao_cmd;
+			s->cancel	= ni_ao_reset;
 			if (!devpriv->is_m_series)
-				s->munge = ni_ao_munge;
+				s->munge	= ni_ao_munge;
+
+			if (devpriv->mite)
+				s->async_dma_dir = DMA_TO_DEVICE;
 		}
-		s->cancel = &ni_ao_reset;
+
+		if (devpriv->is_67xx)
+			init_ao_67xx(dev, s);
+
+		/* reset the analog output configuration */
+		ni_ao_reset(dev, s);
 	} else {
-		s->type = COMEDI_SUBD_UNUSED;
+		s->type		= COMEDI_SUBD_UNUSED;
 	}
-	if ((board->reg_type & ni_reg_67xx_mask))
-		init_ao_67xx(dev, s);
 
-	/* digital i/o subdevice */
-
+	/* Digital I/O subdevice */
 	s = &dev->subdevices[NI_DIO_SUBDEV];
-	s->type = COMEDI_SUBD_DIO;
-	s->subdev_flags = SDF_WRITABLE | SDF_READABLE;
-	s->maxdata = 1;
-	s->io_bits = 0;		/* all bits input */
-	s->range_table = &range_digital;
-	s->n_chan = board->num_p0_dio_channels;
+	s->type		= COMEDI_SUBD_DIO;
+	s->subdev_flags	= SDF_WRITABLE | SDF_READABLE;
+	s->n_chan	= board->has_32dio_chan ? 32 : 8;
+	s->maxdata	= 1;
+	s->range_table	= &range_digital;
 	if (devpriv->is_m_series) {
-		s->subdev_flags |=
-		    SDF_LSAMPL | SDF_CMD_WRITE /* | SDF_CMD_READ */;
-		s->insn_bits = &ni_m_series_dio_insn_bits;
-		s->insn_config = &ni_m_series_dio_insn_config;
-		s->do_cmd = &ni_cdio_cmd;
-		s->do_cmdtest = &ni_cdio_cmdtest;
-		s->cancel = &ni_cdio_cancel;
-		s->async_dma_dir = DMA_BIDIRECTIONAL;
-		s->len_chanlist = s->n_chan;
+		s->subdev_flags	|= SDF_LSAMPL;
+		s->insn_bits	= ni_m_series_dio_insn_bits;
+		s->insn_config	= ni_m_series_dio_insn_config;
+		if (dev->irq) {
+			s->subdev_flags	|= SDF_CMD_WRITE /* | SDF_CMD_READ */;
+			s->len_chanlist	= s->n_chan;
+			s->do_cmdtest	= ni_cdio_cmdtest;
+			s->do_cmd	= ni_cdio_cmd;
+			s->cancel	= ni_cdio_cancel;
 
+			/* M-series boards use DMA */
+			s->async_dma_dir = DMA_BIDIRECTIONAL;
+		}
+
+		/* reset DIO and set all channels to inputs */
 		ni_writel(dev, CDO_Reset_Bit | CDI_Reset_Bit,
 			  M_Offset_CDIO_Command);
 		ni_writel(dev, s->io_bits, M_Offset_DIO_Direction);
 	} else {
-		s->insn_bits = &ni_dio_insn_bits;
-		s->insn_config = &ni_dio_insn_config;
+		s->insn_bits	= ni_dio_insn_bits;
+		s->insn_config	= ni_dio_insn_config;
+
+		/* set all channels to inputs */
 		devpriv->dio_control = DIO_Pins_Dir(s->io_bits);
 		ni_writew(dev, devpriv->dio_control, DIO_Control_Register);
 	}
@@ -5738,66 +5584,66 @@
 	s = &dev->subdevices[NI_UNUSED_SUBDEV];
 	s->type = COMEDI_SUBD_UNUSED;
 
-	/* calibration subdevice -- ai and ao */
+	/* Calibration subdevice */
 	s = &dev->subdevices[NI_CALIBRATION_SUBDEV];
-	s->type = COMEDI_SUBD_CALIB;
+	s->type		= COMEDI_SUBD_CALIB;
+	s->subdev_flags	= SDF_INTERNAL;
+	s->n_chan	= 1;
+	s->maxdata	= 0;
 	if (devpriv->is_m_series) {
-		/*  internal PWM analog output used for AI nonlinearity calibration */
-		s->subdev_flags = SDF_INTERNAL;
-		s->insn_config = &ni_m_series_pwm_config;
-		s->n_chan = 1;
-		s->maxdata = 0;
+		/* internal PWM output used for AI nonlinearity calibration */
+		s->insn_config	= ni_m_series_pwm_config;
+
 		ni_writel(dev, 0x0, M_Offset_Cal_PWM);
-	} else if (board->reg_type == ni_reg_6143) {
-		/*  internal PWM analog output used for AI nonlinearity calibration */
-		s->subdev_flags = SDF_INTERNAL;
-		s->insn_config = &ni_6143_pwm_config;
-		s->n_chan = 1;
-		s->maxdata = 0;
+	} else if (devpriv->is_6143) {
+		/* internal PWM output used for AI nonlinearity calibration */
+		s->insn_config	= ni_6143_pwm_config;
 	} else {
-		s->subdev_flags = SDF_WRITABLE | SDF_INTERNAL;
-		s->insn_read = &ni_calib_insn_read;
-		s->insn_write = &ni_calib_insn_write;
+		s->subdev_flags	|= SDF_WRITABLE;
+		s->insn_read	= ni_calib_insn_read;
+		s->insn_write	= ni_calib_insn_write;
+
+		/* setup the caldacs and find the real n_chan and maxdata */
 		caldac_setup(dev, s);
 	}
 
-	/* EEPROM */
+	/* EEPROM subdevice */
 	s = &dev->subdevices[NI_EEPROM_SUBDEV];
-	s->type = COMEDI_SUBD_MEMORY;
-	s->subdev_flags = SDF_READABLE | SDF_INTERNAL;
-	s->maxdata = 0xff;
+	s->type		= COMEDI_SUBD_MEMORY;
+	s->subdev_flags	= SDF_READABLE | SDF_INTERNAL;
+	s->maxdata	= 0xff;
 	if (devpriv->is_m_series) {
-		s->n_chan = M_SERIES_EEPROM_SIZE;
-		s->insn_read = &ni_m_series_eeprom_insn_read;
+		s->n_chan	= M_SERIES_EEPROM_SIZE;
+		s->insn_read	= ni_m_series_eeprom_insn_read;
 	} else {
-		s->n_chan = 512;
-		s->insn_read = &ni_eeprom_insn_read;
+		s->n_chan	= 512;
+		s->insn_read	= ni_eeprom_insn_read;
 	}
 
-	/* PFI */
+	/* Digital I/O (PFI) subdevice */
 	s = &dev->subdevices[NI_PFI_DIO_SUBDEV];
-	s->type = COMEDI_SUBD_DIO;
-	s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
+	s->type		= COMEDI_SUBD_DIO;
+	s->subdev_flags	= SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
+	s->maxdata	= 1;
 	if (devpriv->is_m_series) {
-		unsigned i;
-		s->n_chan = 16;
+		s->n_chan	= 16;
+		s->insn_bits	= ni_pfi_insn_bits;
+
 		ni_writew(dev, s->state, M_Offset_PFI_DO);
 		for (i = 0; i < NUM_PFI_OUTPUT_SELECT_REGS; ++i) {
 			ni_writew(dev, devpriv->pfi_output_select_reg[i],
 				  M_Offset_PFI_Output_Select(i + 1));
 		}
 	} else {
-		s->n_chan = 10;
+		s->n_chan	= 10;
 	}
-	s->maxdata = 1;
-	if (devpriv->is_m_series)
-		s->insn_bits = &ni_pfi_insn_bits;
-	s->insn_config = &ni_pfi_insn_config;
+	s->insn_config	= ni_pfi_insn_config;
+
 	ni_set_bits(dev, IO_Bidirection_Pin_Register, ~0, 0);
 
 	/* cs5529 calibration adc */
 	s = &dev->subdevices[NI_CS5529_CALIBRATION_SUBDEV];
-	if (board->reg_type & ni_reg_67xx_mask) {
+	if (devpriv->is_67xx) {
 		s->type = COMEDI_SUBD_AI;
 		s->subdev_flags = SDF_READABLE | SDF_DIFF | SDF_INTERNAL;
 		/*  one channel for each analog output channel */
@@ -5831,78 +5677,58 @@
 	s->insn_config = ni_rtsi_insn_config;
 	ni_rtsi_init(dev);
 
-	if (devpriv->is_m_series)
-		counter_variant = ni_gpct_variant_m_series;
-	else
-		counter_variant = ni_gpct_variant_e_series;
+	/* allocate and initialize the gpct counter device */
 	devpriv->counter_dev = ni_gpct_device_construct(dev,
-							&ni_gpct_write_register,
-							&ni_gpct_read_register,
-							counter_variant,
-							NUM_GPCT);
+					ni_gpct_write_register,
+					ni_gpct_read_register,
+					(devpriv->is_m_series)
+						? ni_gpct_variant_m_series
+						: ni_gpct_variant_e_series,
+					NUM_GPCT);
 	if (!devpriv->counter_dev)
 		return -ENOMEM;
 
-	/* General purpose counters */
-	for (j = 0; j < NUM_GPCT; ++j) {
-		s = &dev->subdevices[NI_GPCT_SUBDEV(j)];
-		s->type = COMEDI_SUBD_COUNTER;
-		s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL;
-		s->n_chan = 3;
-		if (devpriv->is_m_series)
-			s->maxdata = 0xffffffff;
-		else
-			s->maxdata = 0xffffff;
-		s->insn_read = ni_tio_insn_read;
-		s->insn_write = ni_tio_insn_read;
-		s->insn_config = ni_tio_insn_config;
+	/* Counter (gpct) subdevices */
+	for (i = 0; i < NUM_GPCT; ++i) {
+		struct ni_gpct *gpct = &devpriv->counter_dev->counters[i];
+
+		/* setup and initialize the counter */
+		gpct->chip_index = 0;
+		gpct->counter_index = i;
+		ni_tio_init_counter(gpct);
+
+		s = &dev->subdevices[NI_GPCT_SUBDEV(i)];
+		s->type		= COMEDI_SUBD_COUNTER;
+		s->subdev_flags	= SDF_READABLE | SDF_WRITABLE | SDF_LSAMPL;
+		s->n_chan	= 3;
+		s->maxdata	= (devpriv->is_m_series) ? 0xffffffff
+							 : 0x00ffffff;
+		s->insn_read	= ni_tio_insn_read;
+		s->insn_write	= ni_tio_insn_read;
+		s->insn_config	= ni_tio_insn_config;
 #ifdef PCIDMA
-		s->subdev_flags |= SDF_CMD_READ /* | SDF_CMD_WRITE */;
-		s->do_cmd = &ni_gpct_cmd;
-		s->len_chanlist = 1;
-		s->do_cmdtest = ni_tio_cmdtest;
-		s->cancel = &ni_gpct_cancel;
-		s->async_dma_dir = DMA_BIDIRECTIONAL;
+		if (dev->irq && devpriv->mite) {
+			s->subdev_flags	|= SDF_CMD_READ /* | SDF_CMD_WRITE */;
+			s->len_chanlist	= 1;
+			s->do_cmdtest	= ni_tio_cmdtest;
+			s->do_cmd	= ni_gpct_cmd;
+			s->cancel	= ni_gpct_cancel;
+
+			s->async_dma_dir = DMA_BIDIRECTIONAL;
+		}
 #endif
-		s->private = &devpriv->counter_dev->counters[j];
-
-		devpriv->counter_dev->counters[j].chip_index = 0;
-		devpriv->counter_dev->counters[j].counter_index = j;
-		ni_tio_init_counter(&devpriv->counter_dev->counters[j]);
+		s->private	= gpct;
 	}
 
-	/* Frequency output */
+	/* Frequency output subdevice */
 	s = &dev->subdevices[NI_FREQ_OUT_SUBDEV];
-	s->type = COMEDI_SUBD_COUNTER;
-	s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
-	s->n_chan = 1;
-	s->maxdata = 0xf;
-	s->insn_read = &ni_freq_out_insn_read;
-	s->insn_write = &ni_freq_out_insn_write;
-	s->insn_config = &ni_freq_out_insn_config;
-
-	/* ai configuration */
-	s = &dev->subdevices[NI_AI_SUBDEV];
-	ni_ai_reset(dev, s);
-	if ((board->reg_type & ni_reg_6xxx_mask) == 0) {
-		/*  BEAM is this needed for PCI-6143 ?? */
-		devpriv->clock_and_fout =
-		    Slow_Internal_Time_Divide_By_2 |
-		    Slow_Internal_Timebase |
-		    Clock_To_Board_Divide_By_2 |
-		    Clock_To_Board |
-		    AI_Output_Divide_By_2 | AO_Output_Divide_By_2;
-	} else {
-		devpriv->clock_and_fout =
-		    Slow_Internal_Time_Divide_By_2 |
-		    Slow_Internal_Timebase |
-		    Clock_To_Board_Divide_By_2 | Clock_To_Board;
-	}
-	ni_stc_writew(dev, devpriv->clock_and_fout, Clock_and_FOUT_Register);
-
-	/* analog output configuration */
-	s = &dev->subdevices[NI_AO_SUBDEV];
-	ni_ao_reset(dev, s);
+	s->type		= COMEDI_SUBD_COUNTER;
+	s->subdev_flags	= SDF_READABLE | SDF_WRITABLE;
+	s->n_chan	= 1;
+	s->maxdata	= 0xf;
+	s->insn_read	= ni_freq_out_insn_read;
+	s->insn_write	= ni_freq_out_insn_write;
+	s->insn_config	= ni_freq_out_insn_config;
 
 	if (dev->irq) {
 		ni_stc_writew(dev,
@@ -5918,10 +5744,11 @@
 	ni_writeb(dev, devpriv->ai_ao_select_reg, AI_AO_Select);
 	ni_writeb(dev, devpriv->g0_g1_select_reg, G0_G1_Select);
 
-	if (board->reg_type & ni_reg_6xxx_mask) {
+	if (devpriv->is_6xxx) {
 		ni_writeb(dev, 0, Magic_611x);
 	} else if (devpriv->is_m_series) {
 		int channel;
+
 		for (channel = 0; channel < board->n_aochan; ++channel) {
 			ni_writeb(dev, 0xf,
 				  M_Offset_AO_Waveform_Order(channel));
diff --git a/drivers/staging/comedi/drivers/ni_mio_cs.c b/drivers/staging/comedi/drivers/ni_mio_cs.c
index 815cb2b..9b201e4 100644
--- a/drivers/staging/comedi/drivers/ni_mio_cs.c
+++ b/drivers/staging/comedi/drivers/ni_mio_cs.c
@@ -56,67 +56,62 @@
 		.name		= "DAQCard-ai-16xe-50",
 		.device_id	= 0x010d,
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 1024,
 		.gainlkup	= ai_gain_8,
 		.ai_speed	= 5000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { dac8800, dac8043 },
 	}, {
 		.name		= "DAQCard-ai-16e-4",
 		.device_id	= 0x010c,
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 1024,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 4000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { mb88341 },		/* verified */
 	}, {
 		.name		= "DAQCard-6062E",
 		.device_id	= 0x02c4,
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 8192,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 2000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 1176,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },	/* verified */
 	 }, {
 		/* specs incorrect! */
 		.name		= "DAQCard-6024E",
 		.device_id	= 0x075e,
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 1024,
 		.gainlkup	= ai_gain_4,
 		.ai_speed	= 5000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 1000000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },
 	}, {
 		/* specs incorrect! */
 		.name		= "DAQCard-6036E",
 		.device_id	= 0x0245,
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 1024,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_4,
 		.ai_speed	= 5000,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 1000000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },
 	 },
 #if 0
@@ -124,9 +119,8 @@
 		.name		= "DAQCard-6715",
 		.device_id	= 0x0000,	/* unknown */
 		.n_aochan	= 8,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_671x	= 8192,
-		.num_p0_dio_channels = 8,
 		.caldac		= { mb88341, mb88341 },
 	},
 #endif
diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c
index 4d6b2ed..352c60f 100644
--- a/drivers/staging/comedi/drivers/ni_pcidio.c
+++ b/drivers/staging/comedi/drivers/ni_pcidio.c
@@ -58,9 +58,6 @@
 #include "comedi_fc.h"
 #include "mite.h"
 
-#define PCI_DIO_SIZE 4096
-#define PCI_MITE_SIZE 4096
-
 /* defines for the PCI-DIO-32HS */
 
 #define Window_Address			4	/* W */
@@ -297,16 +294,6 @@
 	spinlock_t mite_channel_lock;
 };
 
-static int ni_pcidio_cmdtest(struct comedi_device *dev,
-			     struct comedi_subdevice *s,
-			     struct comedi_cmd *cmd);
-static int ni_pcidio_cmd(struct comedi_device *dev, struct comedi_subdevice *s);
-static int ni_pcidio_inttrig(struct comedi_device *dev,
-			     struct comedi_subdevice *s, unsigned int trignum);
-static int ni_pcidio_ns_to_timer(int *nanosec, int round_mode);
-static int setup_mite_dma(struct comedi_device *dev,
-			  struct comedi_subdevice *s);
-
 static int ni_pcidio_request_di_mite_channel(struct comedi_device *dev)
 {
 	struct nidio96_private *devpriv = dev->private;
@@ -319,7 +306,7 @@
 					  devpriv->di_mite_ring, 1, 2);
 	if (devpriv->di_mite_chan == NULL) {
 		spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
-		comedi_error(dev, "failed to reserve mite dma channel.");
+		dev_err(dev->class_dev, "failed to reserve mite dma channel\n");
 		return -EBUSY;
 	}
 	devpriv->di_mite_chan->dir = COMEDI_INPUT;
@@ -350,6 +337,30 @@
 	spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
 }
 
+static int setup_mite_dma(struct comedi_device *dev, struct comedi_subdevice *s)
+{
+	struct nidio96_private *devpriv = dev->private;
+	int retval;
+	unsigned long flags;
+
+	retval = ni_pcidio_request_di_mite_channel(dev);
+	if (retval)
+		return retval;
+
+	/* write alloc the entire buffer */
+	comedi_buf_write_alloc(s, s->async->prealloc_bufsz);
+
+	spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
+	if (devpriv->di_mite_chan) {
+		mite_prep_dma(devpriv->di_mite_chan, 32, 32);
+		mite_dma_arm(devpriv->di_mite_chan);
+	} else
+		retval = -EIO;
+	spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
+
+	return retval;
+}
+
 static int ni_pcidio_poll(struct comedi_device *dev, struct comedi_subdevice *s)
 {
 	struct nidio96_private *devpriv = dev->private;
@@ -532,6 +543,29 @@
 	return insn->n;
 }
 
+static int ni_pcidio_ns_to_timer(int *nanosec, unsigned int flags)
+{
+	int divider, base;
+
+	base = TIMER_BASE;
+
+	switch (flags & TRIG_ROUND_MASK) {
+	case TRIG_ROUND_NEAREST:
+	default:
+		divider = (*nanosec + base / 2) / base;
+		break;
+	case TRIG_ROUND_DOWN:
+		divider = (*nanosec) / base;
+		break;
+	case TRIG_ROUND_UP:
+		divider = (*nanosec + base - 1) / base;
+		break;
+	}
+
+	*nanosec = base * divider;
+	return divider;
+}
+
 static int ni_pcidio_cmdtest(struct comedi_device *dev,
 			     struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
@@ -596,7 +630,7 @@
 
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		arg = cmd->scan_begin_arg;
-		ni_pcidio_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK);
+		ni_pcidio_ns_to_timer(&arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
 	}
 
@@ -606,27 +640,20 @@
 	return 0;
 }
 
-static int ni_pcidio_ns_to_timer(int *nanosec, int round_mode)
+static int ni_pcidio_inttrig(struct comedi_device *dev,
+			     struct comedi_subdevice *s,
+			     unsigned int trig_num)
 {
-	int divider, base;
+	struct nidio96_private *devpriv = dev->private;
+	struct comedi_cmd *cmd = &s->async->cmd;
 
-	base = TIMER_BASE;
+	if (trig_num != cmd->start_arg)
+		return -EINVAL;
 
-	switch (round_mode) {
-	case TRIG_ROUND_NEAREST:
-	default:
-		divider = (*nanosec + base / 2) / base;
-		break;
-	case TRIG_ROUND_DOWN:
-		divider = (*nanosec) / base;
-		break;
-	case TRIG_ROUND_UP:
-		divider = (*nanosec + base - 1) / base;
-		break;
-	}
+	writeb(devpriv->OpModeBits, devpriv->mite->daq_io_addr + OpMode);
+	s->async->inttrig = NULL;
 
-	*nanosec = base * divider;
-	return divider;
+	return 1;
 }
 
 static int ni_pcidio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
@@ -711,6 +738,7 @@
 
 	{
 		int retval = setup_mite_dma(dev, s);
+
 		if (retval)
 			return retval;
 	}
@@ -746,46 +774,6 @@
 	return 0;
 }
 
-static int setup_mite_dma(struct comedi_device *dev, struct comedi_subdevice *s)
-{
-	struct nidio96_private *devpriv = dev->private;
-	int retval;
-	unsigned long flags;
-
-	retval = ni_pcidio_request_di_mite_channel(dev);
-	if (retval)
-		return retval;
-
-	/* write alloc the entire buffer */
-	comedi_buf_write_alloc(s, s->async->prealloc_bufsz);
-
-	spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
-	if (devpriv->di_mite_chan) {
-		mite_prep_dma(devpriv->di_mite_chan, 32, 32);
-		mite_dma_arm(devpriv->di_mite_chan);
-	} else
-		retval = -EIO;
-	spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
-
-	return retval;
-}
-
-static int ni_pcidio_inttrig(struct comedi_device *dev,
-			     struct comedi_subdevice *s,
-			     unsigned int trig_num)
-{
-	struct nidio96_private *devpriv = dev->private;
-	struct comedi_cmd *cmd = &s->async->cmd;
-
-	if (trig_num != cmd->start_arg)
-		return -EINVAL;
-
-	writeb(devpriv->OpModeBits, devpriv->mite->daq_io_addr + OpMode);
-	s->async->inttrig = NULL;
-
-	return 1;
-}
-
 static int ni_pcidio_cancel(struct comedi_device *dev,
 			    struct comedi_subdevice *s)
 {
@@ -799,7 +787,7 @@
 }
 
 static int ni_pcidio_change(struct comedi_device *dev,
-			    struct comedi_subdevice *s, unsigned long new_size)
+			    struct comedi_subdevice *s)
 {
 	struct nidio96_private *devpriv = dev->private;
 	int ret;
@@ -853,6 +841,7 @@
 	}
 	for (j = 0; j + 1 < data_len;) {
 		unsigned int value = data[j++];
+
 		value |= data[j++] << 8;
 		writew(value,
 		       devpriv->mite->daq_io_addr + Firmware_Data_Register);
diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c
index 20c839b..22c0e95d 100644
--- a/drivers/staging/comedi/drivers/ni_pcimio.c
+++ b/drivers/staging/comedi/drivers/ni_pcimio.c
@@ -211,87 +211,79 @@
 	[BOARD_PCIMIO_16XE_50] = {
 		.name		= "pci-mio-16xe-50",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 2048,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_8,
 		.ai_speed	= 50000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 50000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { dac8800, dac8043 },
 	},
 	[BOARD_PCIMIO_16XE_10] = {
 		.name		= "pci-mio-16xe-10",	/*  aka pci-6030E */
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_14,
 		.ai_speed	= 10000,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 10000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { dac8800, dac8043, ad8522 },
 	},
 	[BOARD_PCI6014] = {
 		.name		= "pci-6014",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_4,
 		.ai_speed	= 5000,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 100000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },
 	},
 	[BOARD_PXI6030E] = {
 		.name		= "pxi-6030e",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_14,
 		.ai_speed	= 10000,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 10000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { dac8800, dac8043, ad8522 },
 	},
 	[BOARD_PCIMIO_16E_1] = {
 		.name		= "pci-mio-16e-1",	/* aka pci-6070e */
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 512,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 800,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { mb88341 },
 	},
 	[BOARD_PCIMIO_16E_4] = {
 		.name		= "pci-mio-16e-4",	/* aka pci-6040e */
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 512,
 		.gainlkup	= ai_gain_16,
 		/*
@@ -300,216 +292,195 @@
 		 */
 		.ai_speed	= 2000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 512,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },	/* doc says mb88341 */
 	},
 	[BOARD_PXI6040E] = {
 		.name		= "pxi-6040e",
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 512,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 2000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 512,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { mb88341 },
 	},
 	[BOARD_PCI6031E] = {
 		.name		= "pci-6031e",
 		.n_adchan	= 64,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_14,
 		.ai_speed	= 10000,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 10000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { dac8800, dac8043, ad8522 },
 	},
 	[BOARD_PCI6032E] = {
 		.name		= "pci-6032e",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_14,
 		.ai_speed	= 10000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { dac8800, dac8043, ad8522 },
 	},
 	[BOARD_PCI6033E] = {
 		.name		= "pci-6033e",
 		.n_adchan	= 64,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_14,
 		.ai_speed	= 10000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { dac8800, dac8043, ad8522 },
 	},
 	[BOARD_PCI6071E] = {
 		.name		= "pci-6071e",
 		.n_adchan	= 64,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 800,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },
 	},
 	[BOARD_PCI6023E] = {
 		.name		= "pci-6023e",
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 512,
 		.gainlkup	= ai_gain_4,
 		.ai_speed	= 5000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },	/* manual is wrong */
 	},
 	[BOARD_PCI6024E] = {
 		.name		= "pci-6024e",
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 512,
 		.gainlkup	= ai_gain_4,
 		.ai_speed	= 5000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 100000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },	/* manual is wrong */
 	},
 	[BOARD_PCI6025E] = {
 		.name		= "pci-6025e",
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 512,
 		.gainlkup	= ai_gain_4,
 		.ai_speed	= 5000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 100000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },	/* manual is wrong */
 		.has_8255	= 1,
 	},
 	[BOARD_PXI6025E] = {
 		.name		= "pxi-6025e",
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 512,
 		.gainlkup	= ai_gain_4,
 		.ai_speed	= 5000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 100000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },	/* manual is wrong */
 		.has_8255	= 1,
 	},
 	[BOARD_PCI6034E] = {
 		.name		= "pci-6034e",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_4,
 		.ai_speed	= 5000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },
 	},
 	[BOARD_PCI6035E] = {
 		.name		= "pci-6035e",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_4,
 		.ai_speed	= 5000,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 100000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },
 	},
 	[BOARD_PCI6052E] = {
 		.name		= "pci-6052e",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 3000,
 		.n_aochan	= 2,
-		.aobits		= 16,
-		.ao_unipolar	= 1,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
 		.ao_speed	= 3000,
-		.num_p0_dio_channels = 8,
 		/* manual is wrong */
 		.caldac		= { ad8804_debug, ad8804_debug, ad8522 },
 	},
 	[BOARD_PCI6110] = {
 		.name		= "pci-6110",
 		.n_adchan	= 4,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 8192,
 		.alwaysdither	= 0,
 		.gainlkup	= ai_gain_611x,
 		.ai_speed	= 200,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.reg_type	= ni_reg_611x,
 		.ao_range_table	= &range_bipolar10,
 		.ao_fifo_depth	= 2048,
 		.ao_speed	= 250,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804, ad8804 },
 	},
 	[BOARD_PCI6111] = {
 		.name		= "pci-6111",
 		.n_adchan	= 2,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 8192,
 		.gainlkup	= ai_gain_611x,
 		.ai_speed	= 200,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.reg_type	= ni_reg_611x,
 		.ao_range_table	= &range_bipolar10,
 		.ao_fifo_depth	= 2048,
 		.ao_speed	= 250,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804, ad8804 },
 	},
 #if 0
@@ -517,16 +488,15 @@
 	[BOARD_PCI6115] = {	/* .device_id = 0x2ed0, */
 		.name		= "pci-6115",
 		.n_adchan	= 4,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 8192,
 		.gainlkup	= ai_gain_611x,
 		.ai_speed	= 100,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_671x	= 1,
 		.ao_fifo_depth	= 2048,
 		.ao_speed	= 250,
-		.num_p0_dio_channels = 8,
 		.reg_611x	= 1,
 		/* XXX */
 		.caldac		= { ad8804_debug, ad8804_debug, ad8804_debug },
@@ -536,17 +506,16 @@
 	[BOARD_PXI6115] = {	/* .device_id = ????, */
 		.name		= "pxi-6115",
 		.n_adchan	= 4,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 8192,
 		.gainlkup	= ai_gain_611x,
 		.ai_speed	= 100,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_671x	= 1,
 		.ao_fifo_depth	= 2048,
 		.ao_speed	= 250,
 		.reg_611x	= 1,
-		.num_p0_dio_channels = 8,
 		/* XXX */
 		.caldac		= { ad8804_debug, ad8804_debug, ad8804_debug },
 	},
@@ -554,56 +523,51 @@
 	[BOARD_PCI6711] = {
 		.name = "pci-6711",
 		.n_aochan	= 4,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		/* data sheet says 8192, but fifo really holds 16384 samples */
 		.ao_fifo_depth	= 16384,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.reg_type	= ni_reg_6711,
 		.caldac		= { ad8804_debug },
 	},
 	[BOARD_PXI6711] = {
 		.name		= "pxi-6711",
 		.n_aochan	= 4,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 16384,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.reg_type	= ni_reg_6711,
 		.caldac		= { ad8804_debug },
 	},
 	[BOARD_PCI6713] = {
 		.name		= "pci-6713",
 		.n_aochan	= 8,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 16384,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.reg_type	= ni_reg_6713,
 		.caldac		= { ad8804_debug, ad8804_debug },
 	},
 	[BOARD_PXI6713] = {
 		.name		= "pxi-6713",
 		.n_aochan	= 8,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 16384,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.reg_type	= ni_reg_6713,
 		.caldac		= { ad8804_debug, ad8804_debug },
 	},
 	[BOARD_PCI6731] = {
 		.name		= "pci-6731",
 		.n_aochan	= 4,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8192,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.reg_type	= ni_reg_6711,
 		.caldac		= { ad8804_debug },
 	},
@@ -611,10 +575,9 @@
 	[BOARD_PXI6731] = {	/* .device_id = ????, */
 		.name		= "pxi-6731",
 		.n_aochan	= 4,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8192,
 		.ao_range_table	= &range_bipolar10,
-		.num_p0_dio_channels = 8,
 		.reg_type	= ni_reg_6711,
 		.caldac		= { ad8804_debug },
 	},
@@ -622,417 +585,391 @@
 	[BOARD_PCI6733] = {
 		.name		= "pci-6733",
 		.n_aochan	= 8,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 16384,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.reg_type	= ni_reg_6713,
 		.caldac		= { ad8804_debug, ad8804_debug },
 	},
 	[BOARD_PXI6733] = {
 		.name		= "pxi-6733",
 		.n_aochan	= 8,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 16384,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.reg_type	= ni_reg_6713,
 		.caldac		= { ad8804_debug, ad8804_debug },
 	},
 	[BOARD_PXI6071E] = {
 		.name		= "pxi-6071e",
 		.n_adchan	= 64,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 800,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },
 	},
 	[BOARD_PXI6070E] = {
 		.name		= "pxi-6070e",
 		.n_adchan	= 16,
-		.adbits		= 12,
+		.ai_maxdata	= 0x0fff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 800,
 		.n_aochan	= 2,
-		.aobits		= 12,
+		.ao_maxdata	= 0x0fff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 1000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },
 	},
 	[BOARD_PXI6052E] = {
 		.name		= "pxi-6052e",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_16,
 		.ai_speed	= 3000,
 		.n_aochan	= 2,
-		.aobits		= 16,
-		.ao_unipolar	= 1,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
 		.ao_speed	= 3000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { mb88341, mb88341, ad8522 },
 	},
 	[BOARD_PXI6031E] = {
 		.name		= "pxi-6031e",
 		.n_adchan	= 64,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_14,
 		.ai_speed	= 10000,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 2048,
 		.ao_range_table	= &range_ni_E_ao_ext,
-		.ao_unipolar	= 1,
 		.ao_speed	= 10000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { dac8800, dac8043, ad8522 },
 	},
 	[BOARD_PCI6036E] = {
 		.name = "pci-6036e",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,
 		.alwaysdither	= 1,
 		.gainlkup	= ai_gain_4,
 		.ai_speed	= 5000,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_range_table	= &range_bipolar10,
 		.ao_speed	= 100000,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug },
 	},
 	[BOARD_PCI6220] = {
 		.name		= "pci-6220",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 512,		/* FIXME: guess */
 		.gainlkup	= ai_gain_622x,
 		.ai_speed	= 4000,
-		.num_p0_dio_channels = 8,
 		.reg_type	= ni_reg_622x,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6221] = {
 		.name		= "pci-6221",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_622x,
 		.ai_speed	= 4000,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table	= &range_bipolar10,
 		.reg_type	= ni_reg_622x,
 		.ao_speed	= 1200,
-		.num_p0_dio_channels = 8,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6221_37PIN] = {
 		.name		= "pci-6221_37pin",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_622x,
 		.ai_speed	= 4000,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table	= &range_bipolar10,
 		.reg_type	= ni_reg_622x,
 		.ao_speed	= 1200,
-		.num_p0_dio_channels = 8,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6224] = {
 		.name		= "pci-6224",
 		.n_adchan	= 32,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_622x,
 		.ai_speed	= 4000,
 		.reg_type	= ni_reg_622x,
-		.num_p0_dio_channels = 32,
+		.has_32dio_chan	= 1,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PXI6224] = {
 		.name		= "pxi-6224",
 		.n_adchan	= 32,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_622x,
 		.ai_speed	= 4000,
 		.reg_type	= ni_reg_622x,
-		.num_p0_dio_channels = 32,
+		.has_32dio_chan	= 1,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6225] = {
 		.name		= "pci-6225",
 		.n_adchan	= 80,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_622x,
 		.ai_speed	= 4000,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table	= &range_bipolar10,
 		.reg_type	= ni_reg_622x,
 		.ao_speed	= 1200,
-		.num_p0_dio_channels = 32,
+		.has_32dio_chan	= 1,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PXI6225] = {
 		.name		= "pxi-6225",
 		.n_adchan	= 80,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_622x,
 		.ai_speed	= 4000,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table	= &range_bipolar10,
 		.reg_type	= ni_reg_622x,
 		.ao_speed	= 1200,
-		.num_p0_dio_channels = 32,
+		.has_32dio_chan	= 1,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6229] = {
 		.name		= "pci-6229",
 		.n_adchan	= 32,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_622x,
 		.ai_speed	= 4000,
 		.n_aochan	= 4,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table	= &range_bipolar10,
 		.reg_type	= ni_reg_622x,
 		.ao_speed	= 1200,
-		.num_p0_dio_channels = 32,
+		.has_32dio_chan	= 1,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6250] = {
 		.name		= "pci-6250",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_628x,
 		.ai_speed	= 800,
 		.reg_type	= ni_reg_625x,
-		.num_p0_dio_channels = 8,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6251] = {
 		.name		= "pci-6251",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_628x,
 		.ai_speed	= 800,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table	= &range_ni_M_625x_ao,
 		.reg_type	= ni_reg_625x,
 		.ao_speed	= 350,
-		.num_p0_dio_channels = 8,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCIE6251] = {
 		.name		= "pcie-6251",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_628x,
 		.ai_speed	= 800,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table	= &range_ni_M_625x_ao,
 		.reg_type	= ni_reg_625x,
 		.ao_speed	= 350,
-		.num_p0_dio_channels = 8,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PXIE6251] = {
 		.name		= "pxie-6251",
 		.n_adchan	= 16,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_628x,
 		.ai_speed	= 800,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table	= &range_ni_M_625x_ao,
 		.reg_type	= ni_reg_625x,
 		.ao_speed	= 350,
-		.num_p0_dio_channels = 8,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6254] = {
 		.name		= "pci-6254",
 		.n_adchan	= 32,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_628x,
 		.ai_speed	= 800,
 		.reg_type	= ni_reg_625x,
-		.num_p0_dio_channels = 32,
+		.has_32dio_chan	= 1,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6259] = {
 		.name		= "pci-6259",
 		.n_adchan	= 32,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_628x,
 		.ai_speed	= 800,
 		.n_aochan	= 4,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table	= &range_ni_M_625x_ao,
 		.reg_type	= ni_reg_625x,
 		.ao_speed	= 350,
-		.num_p0_dio_channels = 32,
+		.has_32dio_chan	= 1,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCIE6259] = {
 		.name		= "pcie-6259",
 		.n_adchan	= 32,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 4095,
 		.gainlkup	= ai_gain_628x,
 		.ai_speed	= 800,
 		.n_aochan	= 4,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table	= &range_ni_M_625x_ao,
 		.reg_type	= ni_reg_625x,
 		.ao_speed	= 350,
-		.num_p0_dio_channels = 32,
+		.has_32dio_chan	= 1,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6280] = {
 		.name		= "pci-6280",
 		.n_adchan	= 16,
-		.adbits		= 18,
+		.ai_maxdata	= 0x3ffff,
 		.ai_fifo_depth	= 2047,
 		.gainlkup	= ai_gain_628x,
 		.ai_speed	= 1600,
 		.ao_fifo_depth	= 8191,
 		.reg_type	= ni_reg_628x,
-		.num_p0_dio_channels = 8,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6281] = {
 		.name		= "pci-6281",
 		.n_adchan	= 16,
-		.adbits		= 18,
+		.ai_maxdata	= 0x3ffff,
 		.ai_fifo_depth	= 2047,
 		.gainlkup	= ai_gain_628x,
 		.ai_speed	= 1600,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table = &range_ni_M_628x_ao,
 		.reg_type	= ni_reg_628x,
-		.ao_unipolar	= 1,
 		.ao_speed	= 350,
-		.num_p0_dio_channels = 8,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PXI6281] = {
 		.name		= "pxi-6281",
 		.n_adchan	= 16,
-		.adbits		= 18,
+		.ai_maxdata	= 0x3ffff,
 		.ai_fifo_depth	= 2047,
 		.gainlkup	= ai_gain_628x,
 		.ai_speed	= 1600,
 		.n_aochan	= 2,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table	= &range_ni_M_628x_ao,
 		.reg_type	= ni_reg_628x,
-		.ao_unipolar	= 1,
 		.ao_speed	= 350,
-		.num_p0_dio_channels = 8,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6284] = {
 		.name		= "pci-6284",
 		.n_adchan	= 32,
-		.adbits		= 18,
+		.ai_maxdata	= 0x3ffff,
 		.ai_fifo_depth	= 2047,
 		.gainlkup	= ai_gain_628x,
 		.ai_speed	= 1600,
 		.reg_type	= ni_reg_628x,
-		.num_p0_dio_channels = 32,
+		.has_32dio_chan	= 1,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6289] = {
 		.name		= "pci-6289",
 		.n_adchan	= 32,
-		.adbits		= 18,
+		.ai_maxdata	= 0x3ffff,
 		.ai_fifo_depth	= 2047,
 		.gainlkup	= ai_gain_628x,
 		.ai_speed	= 1600,
 		.n_aochan	= 4,
-		.aobits		= 16,
+		.ao_maxdata	= 0xffff,
 		.ao_fifo_depth	= 8191,
 		.ao_range_table	= &range_ni_M_628x_ao,
 		.reg_type	= ni_reg_628x,
-		.ao_unipolar	= 1,
 		.ao_speed	= 350,
-		.num_p0_dio_channels = 32,
+		.has_32dio_chan	= 1,
 		.caldac		= { caldac_none },
 	},
 	[BOARD_PCI6143] = {
 		.name		= "pci-6143",
 		.n_adchan	= 8,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 1024,
 		.gainlkup	= ai_gain_6143,
 		.ai_speed	= 4000,
 		.reg_type	= ni_reg_6143,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug, ad8804_debug },
 	},
 	[BOARD_PXI6143] = {
 		.name		= "pxi-6143",
 		.n_adchan	= 8,
-		.adbits		= 16,
+		.ai_maxdata	= 0xffff,
 		.ai_fifo_depth	= 1024,
 		.gainlkup	= ai_gain_6143,
 		.ai_speed	= 4000,
 		.reg_type	= ni_reg_6143,
-		.num_p0_dio_channels = 8,
 		.caldac		= { ad8804_debug, ad8804_debug },
 	},
 };
@@ -1040,8 +977,7 @@
 #include "ni_mio_common.c"
 
 static int pcimio_ai_change(struct comedi_device *dev,
-			    struct comedi_subdevice *s,
-			    unsigned long new_size)
+			    struct comedi_subdevice *s)
 {
 	struct ni_private *devpriv = dev->private;
 	int ret;
@@ -1054,8 +990,7 @@
 }
 
 static int pcimio_ao_change(struct comedi_device *dev,
-			    struct comedi_subdevice *s,
-			    unsigned long new_size)
+			    struct comedi_subdevice *s)
 {
 	struct ni_private *devpriv = dev->private;
 	int ret;
@@ -1068,8 +1003,7 @@
 }
 
 static int pcimio_gpct0_change(struct comedi_device *dev,
-			       struct comedi_subdevice *s,
-			       unsigned long new_size)
+			       struct comedi_subdevice *s)
 {
 	struct ni_private *devpriv = dev->private;
 	int ret;
@@ -1082,8 +1016,7 @@
 }
 
 static int pcimio_gpct1_change(struct comedi_device *dev,
-			       struct comedi_subdevice *s,
-			       unsigned long new_size)
+			       struct comedi_subdevice *s)
 {
 	struct ni_private *devpriv = dev->private;
 	int ret;
@@ -1096,8 +1029,7 @@
 }
 
 static int pcimio_dio_change(struct comedi_device *dev,
-			     struct comedi_subdevice *s,
-			     unsigned long new_size)
+			     struct comedi_subdevice *s)
 {
 	struct ni_private *devpriv = dev->private;
 	int ret;
@@ -1225,10 +1157,28 @@
 
 	if (board->reg_type & ni_reg_m_series_mask)
 		devpriv->is_m_series = 1;
+	if (board->reg_type & ni_reg_6xxx_mask)
+		devpriv->is_6xxx = 1;
+	if (board->reg_type == ni_reg_611x)
+		devpriv->is_611x = 1;
+	if (board->reg_type == ni_reg_6143)
+		devpriv->is_6143 = 1;
+	if (board->reg_type == ni_reg_622x)
+		devpriv->is_622x = 1;
+	if (board->reg_type == ni_reg_625x)
+		devpriv->is_625x = 1;
+	if (board->reg_type == ni_reg_628x)
+		devpriv->is_628x = 1;
+	if (board->reg_type & ni_reg_67xx_mask)
+		devpriv->is_67xx = 1;
+	if (board->reg_type == ni_reg_6711)
+		devpriv->is_6711 = 1;
+	if (board->reg_type == ni_reg_6713)
+		devpriv->is_6713 = 1;
 
 	ret = mite_setup(devpriv->mite);
 	if (ret < 0) {
-		pr_warn("error setting up mite\n");
+		dev_warn(dev->class_dev, "error setting up mite\n");
 		return ret;
 	}
 
@@ -1250,7 +1200,7 @@
 
 	if (devpriv->is_m_series)
 		m_series_init_eeprom_buffer(dev);
-	if (board->reg_type == ni_reg_6143)
+	if (devpriv->is_6143)
 		init_6143(dev);
 
 	irq = pcidev->irq;
diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h
index 02a7fa3..caad9d8 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -1393,7 +1393,7 @@
 	int isapnp_id;
 
 	int n_adchan;
-	int adbits;
+	unsigned int ai_maxdata;
 
 	int ai_fifo_depth;
 	unsigned int alwaysdither:1;
@@ -1401,17 +1401,14 @@
 	int ai_speed;
 
 	int n_aochan;
-	int aobits;
+	unsigned int ao_maxdata;
 	int ao_fifo_depth;
 	const struct comedi_lrange *ao_range_table;
 	unsigned ao_speed;
 
-	unsigned num_p0_dio_channels;
-
 	int reg_type;
-	unsigned int ao_unipolar:1;
 	unsigned int has_8255:1;
-	unsigned int has_analog_trig:1;
+	unsigned int has_32dio_chan:1;
 
 	enum caldac_enum caldac[3];
 };
@@ -1424,7 +1421,6 @@
 	unsigned short dio_output;
 	unsigned short dio_control;
 	int aimode;
-	int ai_continuous;
 	unsigned int ai_calib_source;
 	unsigned int ai_calib_source_enabled;
 	spinlock_t window_lock;
@@ -1472,10 +1468,6 @@
 	unsigned clock_ns;
 	unsigned clock_source;
 
-	unsigned short atrig_mode;
-	unsigned short atrig_high;
-	unsigned short atrig_low;
-
 	unsigned short pwm_up_count;
 	unsigned short pwm_down_count;
 
@@ -1492,7 +1484,17 @@
 	struct mite_dma_descriptor_ring *cdo_mite_ring;
 	struct mite_dma_descriptor_ring *gpct_mite_ring[NUM_GPCT];
 
+	/* ni_pcimio board type flags (based on the boardinfo reg_type) */
 	unsigned int is_m_series:1;
+	unsigned int is_6xxx:1;
+	unsigned int is_611x:1;
+	unsigned int is_6143:1;
+	unsigned int is_622x:1;
+	unsigned int is_625x:1;
+	unsigned int is_628x:1;
+	unsigned int is_67xx:1;
+	unsigned int is_6711:1;
+	unsigned int is_6713:1;
 };
 
 #endif /* _COMEDI_NI_STC_H */
diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c
index 92691b4..694bd51 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -60,13 +60,10 @@
 	switch (variant) {
 	case ni_gpct_variant_e_series:
 		return 0;
-		break;
 	case ni_gpct_variant_m_series:
 		return Gi_M_Series_Alternate_Sync_Bit;
-		break;
 	case ni_gpct_variant_660x:
 		return Gi_660x_Alternate_Sync_Bit;
-		break;
 	default:
 		BUG();
 		break;
@@ -81,13 +78,10 @@
 	switch (variant) {
 	case ni_gpct_variant_e_series:
 		return 0;
-		break;
 	case ni_gpct_variant_m_series:
 		return Gi_M_Series_Prescale_X2_Bit;
-		break;
 	case ni_gpct_variant_660x:
 		return Gi_660x_Prescale_X2_Bit;
-		break;
 	default:
 		BUG();
 		break;
@@ -102,13 +96,10 @@
 	switch (variant) {
 	case ni_gpct_variant_e_series:
 		return 0;
-		break;
 	case ni_gpct_variant_m_series:
 		return Gi_M_Series_Prescale_X8_Bit;
-		break;
 	case ni_gpct_variant_660x:
 		return Gi_660x_Prescale_X8_Bit;
-		break;
 	default:
 		BUG();
 		break;
@@ -123,13 +114,10 @@
 	switch (variant) {
 	case ni_gpct_variant_e_series:
 		return 0;
-		break;
 	case ni_gpct_variant_m_series:
 		return Gi_M_Series_HW_Arm_Select_Mask;
-		break;
 	case ni_gpct_variant_660x:
 		return Gi_660x_HW_Arm_Select_Mask;
-		break;
 	default:
 		BUG();
 		break;
@@ -177,20 +165,16 @@
 static inline unsigned NI_M_Series_PFI_Clock(unsigned n)
 {
 	BUG_ON(n > ni_m_series_max_pfi_channel);
-	if (n < 10)
-		return 1 + n;
-	else
-		return 0xb + n;
+
+	return (n < 10) ? (1 + n) : (0xb + n);
 }
 
 static const unsigned ni_m_series_max_rtsi_channel = 7;
 static inline unsigned NI_M_Series_RTSI_Clock(unsigned n)
 {
 	BUG_ON(n > ni_m_series_max_rtsi_channel);
-	if (n == 7)
-		return 0x1b;
-	else
-		return 0xb + n;
+
+	return (n == 7) ? 0x1b : (0xb + n);
 }
 
 enum ni_660x_gate_select {
@@ -331,11 +315,9 @@
 	switch (counter_dev->variant) {
 	case ni_gpct_variant_e_series:
 		return 0;
-		break;
 	case ni_gpct_variant_m_series:
 	case ni_gpct_variant_660x:
 		return 1;
-		break;
 	default:
 		BUG();
 		break;
@@ -481,6 +463,7 @@
 
 	if (ni_tio_counting_mode_registers_present(counter_dev)) {
 		unsigned counting_mode_bits = 0;
+
 		counting_mode_bits |=
 		    (mode >> NI_GPCT_COUNTING_MODE_SHIFT) &
 		    Gi_Counting_Mode_Mask;
@@ -704,7 +687,6 @@
 		/* Gi_Source_Subselect doesn't matter */
 	default:
 		return;
-		break;
 	}
 	write_register(counter, counter_dev->regs[second_gate_reg],
 		       second_gate_reg);
@@ -757,7 +739,6 @@
 			break;
 		default:
 			return -EINVAL;
-			break;
 		}
 		ni_tio_set_bits(counter, NITIO_CNT_MODE_REG(cidx),
 				Gi_Prescale_X2_Bit(counter_dev->variant) |
@@ -915,10 +896,8 @@
 	case ni_gpct_variant_e_series:
 	case ni_gpct_variant_m_series:
 		return ni_m_series_clock_src_select(counter);
-		break;
 	case ni_gpct_variant_660x:
 		return ni_660x_clock_src_select(counter);
-		break;
 	default:
 		BUG();
 		break;
@@ -947,7 +926,6 @@
 	default:
 		/* clock period is specified by user with prescaling already taken into account. */
 		return counter->clock_period_ps;
-		break;
 	}
 
 	switch (generic_clock_source & NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK) {
@@ -1035,7 +1013,6 @@
 		if (i <= ni_660x_max_gate_pin)
 			break;
 		return -EINVAL;
-		break;
 	}
 	ni_tio_set_bits(counter, NITIO_INPUT_SEL_REG(cidx),
 			Gi_Gate_Select_Mask,
@@ -1084,7 +1061,6 @@
 		if (i <= ni_m_series_max_pfi_channel)
 			break;
 		return -EINVAL;
-		break;
 	}
 	ni_tio_set_bits(counter, NITIO_INPUT_SEL_REG(cidx),
 			Gi_Gate_Select_Mask,
@@ -1140,7 +1116,6 @@
 		if (i <= ni_660x_max_up_down_pin)
 			break;
 		return -EINVAL;
-		break;
 	}
 	counter_dev->regs[second_gate_reg] |= Gi_Second_Gate_Mode_Bit;
 	counter_dev->regs[second_gate_reg] &= ~Gi_Second_Gate_Select_Mask;
@@ -1199,10 +1174,8 @@
 		case ni_gpct_variant_e_series:
 		case ni_gpct_variant_m_series:
 			return ni_m_series_set_first_gate(counter, gate_source);
-			break;
 		case ni_gpct_variant_660x:
 			return ni_660x_set_first_gate(counter, gate_source);
-			break;
 		default:
 			BUG();
 			break;
@@ -1230,10 +1203,8 @@
 		case ni_gpct_variant_m_series:
 			return ni_m_series_set_second_gate(counter,
 							   gate_source);
-			break;
 		case ni_gpct_variant_660x:
 			return ni_660x_set_second_gate(counter, gate_source);
-			break;
 		default:
 			BUG();
 			break;
@@ -1241,7 +1212,6 @@
 		break;
 	default:
 		return -EINVAL;
-		break;
 	}
 	return 0;
 }
@@ -1269,7 +1239,6 @@
 			break;
 		default:
 			return -EINVAL;
-			break;
 		}
 		mask = 0x1f << shift;
 		if (source > 0x1f) {
@@ -1292,34 +1261,25 @@
 	switch (ni_660x_gate_select) {
 	case NI_660x_Source_Pin_i_Gate_Select:
 		return NI_GPCT_SOURCE_PIN_i_GATE_SELECT;
-		break;
 	case NI_660x_Gate_Pin_i_Gate_Select:
 		return NI_GPCT_GATE_PIN_i_GATE_SELECT;
-		break;
 	case NI_660x_Next_SRC_Gate_Select:
 		return NI_GPCT_NEXT_SOURCE_GATE_SELECT;
-		break;
 	case NI_660x_Next_Out_Gate_Select:
 		return NI_GPCT_NEXT_OUT_GATE_SELECT;
-		break;
 	case NI_660x_Logic_Low_Gate_Select:
 		return NI_GPCT_LOGIC_LOW_GATE_SELECT;
-		break;
 	default:
 		for (i = 0; i <= ni_660x_max_rtsi_channel; ++i) {
-			if (ni_660x_gate_select == NI_660x_RTSI_Gate_Select(i)) {
+			if (ni_660x_gate_select == NI_660x_RTSI_Gate_Select(i))
 				return NI_GPCT_RTSI_GATE_SELECT(i);
-				break;
-			}
 		}
 		if (i <= ni_660x_max_rtsi_channel)
 			break;
 		for (i = 0; i <= ni_660x_max_gate_pin; ++i) {
 			if (ni_660x_gate_select ==
-			    NI_660x_Gate_Pin_Gate_Select(i)) {
+			    NI_660x_Gate_Pin_Gate_Select(i))
 				return NI_GPCT_GATE_PIN_GATE_SELECT(i);
-				break;
-			}
 		}
 		if (i <= ni_660x_max_gate_pin)
 			break;
@@ -1337,34 +1297,25 @@
 	switch (ni_m_series_gate_select) {
 	case NI_M_Series_Timestamp_Mux_Gate_Select:
 		return NI_GPCT_TIMESTAMP_MUX_GATE_SELECT;
-		break;
 	case NI_M_Series_AI_START2_Gate_Select:
 		return NI_GPCT_AI_START2_GATE_SELECT;
-		break;
 	case NI_M_Series_PXI_Star_Trigger_Gate_Select:
 		return NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT;
-		break;
 	case NI_M_Series_Next_Out_Gate_Select:
 		return NI_GPCT_NEXT_OUT_GATE_SELECT;
-		break;
 	case NI_M_Series_AI_START1_Gate_Select:
 		return NI_GPCT_AI_START1_GATE_SELECT;
-		break;
 	case NI_M_Series_Next_SRC_Gate_Select:
 		return NI_GPCT_NEXT_SOURCE_GATE_SELECT;
-		break;
 	case NI_M_Series_Analog_Trigger_Out_Gate_Select:
 		return NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT;
-		break;
 	case NI_M_Series_Logic_Low_Gate_Select:
 		return NI_GPCT_LOGIC_LOW_GATE_SELECT;
-		break;
 	default:
 		for (i = 0; i <= ni_m_series_max_rtsi_channel; ++i) {
 			if (ni_m_series_gate_select ==
 			    NI_M_Series_RTSI_Gate_Select(i)) {
 				return NI_GPCT_RTSI_GATE_SELECT(i);
-				break;
 			}
 		}
 		if (i <= ni_m_series_max_rtsi_channel)
@@ -1373,7 +1324,6 @@
 			if (ni_m_series_gate_select ==
 			    NI_M_Series_PFI_Gate_Select(i)) {
 				return NI_GPCT_PFI_GATE_SELECT(i);
-				break;
 			}
 		}
 		if (i <= ni_m_series_max_pfi_channel)
@@ -1392,28 +1342,21 @@
 	switch (ni_660x_gate_select) {
 	case NI_660x_Source_Pin_i_Second_Gate_Select:
 		return NI_GPCT_SOURCE_PIN_i_GATE_SELECT;
-		break;
 	case NI_660x_Up_Down_Pin_i_Second_Gate_Select:
 		return NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT;
-		break;
 	case NI_660x_Next_SRC_Second_Gate_Select:
 		return NI_GPCT_NEXT_SOURCE_GATE_SELECT;
-		break;
 	case NI_660x_Next_Out_Second_Gate_Select:
 		return NI_GPCT_NEXT_OUT_GATE_SELECT;
-		break;
 	case NI_660x_Selected_Gate_Second_Gate_Select:
 		return NI_GPCT_SELECTED_GATE_GATE_SELECT;
-		break;
 	case NI_660x_Logic_Low_Second_Gate_Select:
 		return NI_GPCT_LOGIC_LOW_GATE_SELECT;
-		break;
 	default:
 		for (i = 0; i <= ni_660x_max_rtsi_channel; ++i) {
 			if (ni_660x_gate_select ==
 			    NI_660x_RTSI_Second_Gate_Select(i)) {
 				return NI_GPCT_RTSI_GATE_SELECT(i);
-				break;
 			}
 		}
 		if (i <= ni_660x_max_rtsi_channel)
@@ -1422,7 +1365,6 @@
 			if (ni_660x_gate_select ==
 			    NI_660x_Up_Down_Pin_Second_Gate_Select(i)) {
 				return NI_GPCT_UP_DOWN_PIN_GATE_SELECT(i);
-				break;
 			}
 		}
 		if (i <= ni_660x_max_up_down_pin)
@@ -1441,7 +1383,6 @@
 	switch (ni_m_series_gate_select) {
 	default:
 		return ni_m_series_gate_select;
-		break;
 	}
 	return 0;
 };
@@ -1462,12 +1403,12 @@
 		    Gi_Gating_Disabled_Bits) {
 			*gate_source = NI_GPCT_DISABLED_GATE_SELECT;
 			return 0;
-		} else {
-			gate_select_bits =
-			    (ni_tio_get_soft_copy(counter,
-						  NITIO_INPUT_SEL_REG(cidx)) &
-			     Gi_Gate_Select_Mask) >> Gi_Gate_Select_Shift;
 		}
+
+		gate_select_bits =
+		    (ni_tio_get_soft_copy(counter, NITIO_INPUT_SEL_REG(cidx)) &
+			Gi_Gate_Select_Mask) >> Gi_Gate_Select_Shift;
+
 		switch (counter_dev->variant) {
 		case ni_gpct_variant_e_series:
 		case ni_gpct_variant_m_series:
@@ -1496,12 +1437,11 @@
 		    == 0) {
 			*gate_source = NI_GPCT_DISABLED_GATE_SELECT;
 			return 0;
-		} else {
-			gate_select_bits =
-			    (counter_dev->regs[second_gate_reg] &
-			     Gi_Second_Gate_Select_Mask) >>
-			    Gi_Second_Gate_Select_Shift;
 		}
+
+		gate_select_bits = (counter_dev->regs[second_gate_reg] &
+				Gi_Second_Gate_Select_Mask) >>
+				Gi_Second_Gate_Select_Shift;
 		switch (counter_dev->variant) {
 		case ni_gpct_variant_e_series:
 		case ni_gpct_variant_m_series:
@@ -1528,7 +1468,6 @@
 		break;
 	default:
 		return -EINVAL;
-		break;
 	}
 	return 0;
 }
@@ -1543,39 +1482,29 @@
 	switch (data[0]) {
 	case INSN_CONFIG_SET_COUNTER_MODE:
 		return ni_tio_set_counter_mode(counter, data[1]);
-		break;
 	case INSN_CONFIG_ARM:
 		return ni_tio_arm(counter, 1, data[1]);
-		break;
 	case INSN_CONFIG_DISARM:
 		ni_tio_arm(counter, 0, 0);
 		return 0;
-		break;
 	case INSN_CONFIG_GET_COUNTER_STATUS:
 		data[1] = ni_tio_counter_status(counter);
 		data[2] = counter_status_mask;
 		return 0;
-		break;
 	case INSN_CONFIG_SET_CLOCK_SRC:
 		return ni_tio_set_clock_src(counter, data[1], data[2]);
-		break;
 	case INSN_CONFIG_GET_CLOCK_SRC:
 		ni_tio_get_clock_src(counter, &data[1], &data[2]);
 		return 0;
-		break;
 	case INSN_CONFIG_SET_GATE_SRC:
 		return ni_tio_set_gate_src(counter, data[1], data[2]);
-		break;
 	case INSN_CONFIG_GET_GATE_SRC:
 		return ni_tio_get_gate_src(counter, data[1], &data[2]);
-		break;
 	case INSN_CONFIG_SET_OTHER_SRC:
 		return ni_tio_set_other_src(counter, data[1], data[2]);
-		break;
 	case INSN_CONFIG_RESET:
 		ni_tio_reset_count_and_disarm(counter);
 		return 0;
-		break;
 	default:
 		break;
 	}
@@ -1618,7 +1547,6 @@
 			correct_read = first_read;
 		data[0] = correct_read;
 		return 0;
-		break;
 	case 1:
 		data[0] = counter_dev->regs[NITIO_LOADA_REG(cidx)];
 		break;
@@ -1636,10 +1564,9 @@
 	const unsigned bits =
 		read_register(counter, NITIO_SHARED_STATUS_REG(cidx));
 
-	if (bits & Gi_Next_Load_Source_Bit(cidx))
-		return NITIO_LOADB_REG(cidx);
-	else
-		return NITIO_LOADA_REG(cidx);
+	return (bits & Gi_Next_Load_Source_Bit(cidx))
+			? NITIO_LOADB_REG(cidx)
+			: NITIO_LOADA_REG(cidx);
 }
 
 int ni_tio_insn_write(struct comedi_device *dev,
@@ -1676,7 +1603,6 @@
 		break;
 	default:
 		return -EINVAL;
-		break;
 	}
 	return 0;
 }
diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h
index 15b81b8..3c53958 100644
--- a/drivers/staging/comedi/drivers/ni_tio_internal.h
+++ b/drivers/staging/comedi/drivers/ni_tio_internal.h
@@ -334,11 +334,9 @@
 	switch (counter_dev->variant) {
 	case ni_gpct_variant_e_series:
 		return 0;
-		break;
 	case ni_gpct_variant_m_series:
 	case ni_gpct_variant_660x:
 		return 1;
-		break;
 	default:
 		BUG();
 		break;
diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c
index 2557ab4..f66b504 100644
--- a/drivers/staging/comedi/drivers/ni_tiocmd.c
+++ b/drivers/staging/comedi/drivers/ni_tiocmd.c
@@ -342,7 +342,6 @@
 	    in register-level manual) */
 	case ni_gpct_variant_660x:
 		return 1;
-		break;
 	case ni_gpct_variant_e_series:
 		spin_lock_irqsave(&counter->lock, flags);
 		{
diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c
index c38d97a..40f9136 100644
--- a/drivers/staging/comedi/drivers/pcl711.c
+++ b/drivers/staging/comedi/drivers/pcl711.c
@@ -206,7 +206,7 @@
 	unsigned int data;
 
 	if (!dev->attached) {
-		comedi_error(dev, "spurious interrupt");
+		dev_err(dev->class_dev, "spurious interrupt\n");
 		return IRQ_HANDLED;
 	}
 
diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c
index 655bac4..c7f8eb1 100644
--- a/drivers/staging/comedi/drivers/pcl724.c
+++ b/drivers/staging/comedi/drivers/pcl724.c
@@ -88,14 +88,12 @@
 
 	iobase &= 0x0fff;
 
+	outb(port + movport, iobase);
 	if (dir) {
-		outb(port + movport, iobase);
 		outb(data, iobase + 1);
 		return 0;
-	} else {
-		outb(port + movport, iobase);
-		return inb(iobase + 1);
 	}
+	return inb(iobase + 1);
 }
 
 static int pcl724_attach(struct comedi_device *dev,
diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c
index 4eef4b4..bdce24c 100644
--- a/drivers/staging/comedi/drivers/pcl730.c
+++ b/drivers/staging/comedi/drivers/pcl730.c
@@ -310,7 +310,7 @@
 		s->maxdata	= 1;
 		s->range_table	= &range_digital;
 		s->insn_bits	= pcl730_di_insn_bits;
-		s->private	= board->is_ir104 ? (void*)4 :
+		s->private	= board->is_ir104 ? (void *)4 :
 				  board->is_acl7225b ? (void *)2 :
 				  board->is_pcl725 ? (void *)1 : (void *)0;
 	}
diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c
index eda9986..54732c5 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -130,10 +130,6 @@
 	unsigned int ai_cmd_canceled:1;
 };
 
-static int check_channel_list(struct comedi_device *dev,
-			      struct comedi_subdevice *s,
-			      unsigned int *chanlist, unsigned int chanlen);
-
 static void pcl816_start_pacer(struct comedi_device *dev, bool load_counters)
 {
 	struct pcl816_private *devpriv = dev->private;
@@ -363,6 +359,62 @@
 	return IRQ_HANDLED;
 }
 
+static int check_channel_list(struct comedi_device *dev,
+			      struct comedi_subdevice *s,
+			      unsigned int *chanlist,
+			      unsigned int chanlen)
+{
+	unsigned int chansegment[16];
+	unsigned int i, nowmustbechan, seglen, segpos;
+
+	/*  correct channel and range number check itself comedi/range.c */
+	if (chanlen < 1) {
+		dev_err(dev->class_dev, "range/channel list is empty!\n");
+		return 0;
+	}
+
+	if (chanlen > 1) {
+		/*  first channel is every time ok */
+		chansegment[0] = chanlist[0];
+		for (i = 1, seglen = 1; i < chanlen; i++, seglen++) {
+			/*  we detect loop, this must by finish */
+			    if (chanlist[0] == chanlist[i])
+				break;
+			nowmustbechan =
+			    (CR_CHAN(chansegment[i - 1]) + 1) % chanlen;
+			if (nowmustbechan != CR_CHAN(chanlist[i])) {
+				/*  channel list isn't continuous :-( */
+				dev_dbg(dev->class_dev,
+					"channel list must be continuous! chanlist[%i]=%d but must be %d or %d!\n",
+					i, CR_CHAN(chanlist[i]), nowmustbechan,
+					CR_CHAN(chanlist[0]));
+				return 0;
+			}
+			/*  well, this is next correct channel in list */
+			chansegment[i] = chanlist[i];
+		}
+
+		/*  check whole chanlist */
+		for (i = 0, segpos = 0; i < chanlen; i++) {
+			    if (chanlist[i] != chansegment[i % seglen]) {
+				dev_dbg(dev->class_dev,
+					"bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n",
+					i, CR_CHAN(chansegment[i]),
+					CR_RANGE(chansegment[i]),
+					CR_AREF(chansegment[i]),
+					CR_CHAN(chanlist[i % seglen]),
+					CR_RANGE(chanlist[i % seglen]),
+					CR_AREF(chansegment[i % seglen]));
+				return 0;	/*  chan/gain list is strange */
+			}
+		}
+	} else {
+		seglen = 1;
+	}
+
+	return seglen;	/*  we can serve this with MUX logic */
+}
+
 static int pcl816_ai_cmdtest(struct comedi_device *dev,
 			     struct comedi_subdevice *s, struct comedi_cmd *cmd)
 {
@@ -542,62 +594,6 @@
 	return 0;
 }
 
-static int
-check_channel_list(struct comedi_device *dev,
-		   struct comedi_subdevice *s, unsigned int *chanlist,
-		   unsigned int chanlen)
-{
-	unsigned int chansegment[16];
-	unsigned int i, nowmustbechan, seglen, segpos;
-
-	/*  correct channel and range number check itself comedi/range.c */
-	if (chanlen < 1) {
-		comedi_error(dev, "range/channel list is empty!");
-		return 0;
-	}
-
-	if (chanlen > 1) {
-		/*  first channel is every time ok */
-		chansegment[0] = chanlist[0];
-		for (i = 1, seglen = 1; i < chanlen; i++, seglen++) {
-			/*  we detect loop, this must by finish */
-			    if (chanlist[0] == chanlist[i])
-				break;
-			nowmustbechan =
-			    (CR_CHAN(chansegment[i - 1]) + 1) % chanlen;
-			if (nowmustbechan != CR_CHAN(chanlist[i])) {
-				/*  channel list isn't continuous :-( */
-				dev_dbg(dev->class_dev,
-					"channel list must be continuous! chanlist[%i]=%d but must be %d or %d!\n",
-					i, CR_CHAN(chanlist[i]), nowmustbechan,
-					CR_CHAN(chanlist[0]));
-				return 0;
-			}
-			/*  well, this is next correct channel in list */
-			chansegment[i] = chanlist[i];
-		}
-
-		/*  check whole chanlist */
-		for (i = 0, segpos = 0; i < chanlen; i++) {
-			    if (chanlist[i] != chansegment[i % seglen]) {
-				dev_dbg(dev->class_dev,
-					"bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n",
-					i, CR_CHAN(chansegment[i]),
-					CR_RANGE(chansegment[i]),
-					CR_AREF(chansegment[i]),
-					CR_CHAN(chanlist[i % seglen]),
-					CR_RANGE(chanlist[i % seglen]),
-					CR_AREF(chansegment[i % seglen]));
-				return 0;	/*  chan/gain list is strange */
-			}
-		}
-	} else {
-		seglen = 1;
-	}
-
-	return seglen;	/*  we can serve this with MUX logic */
-}
-
 static int pcl816_ai_insn_read(struct comedi_device *dev,
 			       struct comedi_subdevice *s,
 			       struct comedi_insn *insn,
diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c
index 7d00ae6..000dbf8 100644
--- a/drivers/staging/comedi/drivers/pcl818.c
+++ b/drivers/staging/comedi/drivers/pcl818.c
@@ -551,7 +551,7 @@
 	unsigned int val;
 
 	if (pcl818_ai_eoc(dev, s, NULL, 0)) {
-		comedi_error(dev, "A/D mode1/3 IRQ without DRDY!");
+		dev_err(dev->class_dev, "A/D mode1/3 IRQ without DRDY!\n");
 		s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 		return;
 	}
@@ -608,13 +608,14 @@
 	status = inb(dev->iobase + PCL818_FI_STATUS);
 
 	if (status & 4) {
-		comedi_error(dev, "A/D mode1/3 FIFO overflow!");
+		dev_err(dev->class_dev, "A/D mode1/3 FIFO overflow!\n");
 		s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 		return;
 	}
 
 	if (status & 1) {
-		comedi_error(dev, "A/D mode1/3 FIFO interrupt without data!");
+		dev_err(dev->class_dev,
+			"A/D mode1/3 FIFO interrupt without data!\n");
 		s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
 		return;
 	}
@@ -682,7 +683,7 @@
 
 	/* correct channel and range number check itself comedi/range.c */
 	if (n_chan < 1) {
-		comedi_error(dev, "range/channel list is empty!");
+		dev_err(dev->class_dev, "range/channel list is empty!\n");
 		return 0;
 	}
 
diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c
index 53e7373..6e0d78f 100644
--- a/drivers/staging/comedi/drivers/pcm3724.c
+++ b/drivers/staging/comedi/drivers/pcm3724.c
@@ -33,7 +33,6 @@
 
 #include "8255.h"
 
-#define PCM3724_SIZE   16
 #define SIZE_8255	4
 
 #define BUF_C0 0x1
@@ -66,19 +65,6 @@
 	int dio_2;
 };
 
-static int subdev_8255_cb(int dir, int port, int data, unsigned long arg)
-{
-	unsigned long iobase = arg;
-	unsigned char inbres;
-	if (dir) {
-		outb(data, iobase + port);
-		return 0;
-	} else {
-		inbres = inb(iobase + port);
-		return inbres;
-	}
-}
-
 static int compute_buffer(int config, int devno, struct comedi_subdevice *s)
 {
 	/* 1 in io_bits indicates output */
@@ -215,7 +201,7 @@
 	if (!priv)
 		return -ENOMEM;
 
-	ret = comedi_request_region(dev, it->options[0], PCM3724_SIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x10);
 	if (ret)
 		return ret;
 
@@ -225,7 +211,7 @@
 
 	for (i = 0; i < dev->n_subdevices; i++) {
 		s = &dev->subdevices[i];
-		ret = subdev_8255_init(dev, s, subdev_8255_cb,
+		ret = subdev_8255_init(dev, s, NULL,
 				       dev->iobase + SIZE_8255 * i);
 		if (ret)
 			return ret;
diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c
index 62914bb..1bca3fb 100644
--- a/drivers/staging/comedi/drivers/pcmuio.c
+++ b/drivers/staging/comedi/drivers/pcmuio.c
@@ -333,6 +333,7 @@
 
 	for (i = 0; i < cmd->chanlist_len; i++) {
 		unsigned int chan = CR_CHAN(cmd->chanlist[i]);
+
 		if (triggered & (1 << chan))
 			val |= (1 << i);
 	}
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index b3bbec0..b1db61d 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -351,7 +351,7 @@
  * time that the device will use.
  */
 
-static int daqp_ns_to_timer(unsigned int *ns, int round)
+static int daqp_ns_to_timer(unsigned int *ns, unsigned int flags)
 {
 	int timer;
 
@@ -436,13 +436,13 @@
 
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		arg = cmd->scan_begin_arg;
-		daqp_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK);
+		daqp_ns_to_timer(&arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
 	}
 
 	if (cmd->convert_src == TRIG_TIMER) {
 		arg = cmd->convert_arg;
-		daqp_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK);
+		daqp_ns_to_timer(&arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
 	}
 
@@ -488,15 +488,13 @@
 	 */
 
 	if (cmd->convert_src == TRIG_TIMER) {
-		counter = daqp_ns_to_timer(&cmd->convert_arg,
-					       cmd->flags & TRIG_ROUND_MASK);
+		counter = daqp_ns_to_timer(&cmd->convert_arg, cmd->flags);
 		outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
 		outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
 		outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
 		scanlist_start_on_every_entry = 1;
 	} else {
-		counter = daqp_ns_to_timer(&cmd->scan_begin_arg,
-					       cmd->flags & TRIG_ROUND_MASK);
+		counter = daqp_ns_to_timer(&cmd->scan_begin_arg, cmd->flags);
 		outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
 		outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
 		outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c
index d55c589..69dc737 100644
--- a/drivers/staging/comedi/drivers/rtd520.c
+++ b/drivers/staging/comedi/drivers/rtd520.c
@@ -397,11 +397,11 @@
   Note: you have to check if the value is larger than the counter range!
 */
 static int rtd_ns_to_timer_base(unsigned int *nanosec,
-				int round_mode, int base)
+				unsigned int flags, int base)
 {
 	int divider;
 
-	switch (round_mode) {
+	switch (flags & TRIG_ROUND_MASK) {
 	case TRIG_ROUND_NEAREST:
 	default:
 		divider = (*nanosec + base / 2) / base;
@@ -428,9 +428,9 @@
   return the proper counter value (divider-1) for the internal clock.
   Sets the original period to be the true value.
 */
-static int rtd_ns_to_timer(unsigned int *ns, int round_mode)
+static int rtd_ns_to_timer(unsigned int *ns, unsigned int flags)
 {
-	return rtd_ns_to_timer_base(ns, round_mode, RTD_CLOCK_BASE);
+	return rtd_ns_to_timer_base(ns, flags, RTD_CLOCK_BASE);
 }
 
 /*
@@ -895,13 +895,13 @@
 
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		arg = cmd->scan_begin_arg;
-		rtd_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK);
+		rtd_ns_to_timer(&arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
 	}
 
 	if (cmd->convert_src == TRIG_TIMER) {
 		arg = cmd->convert_arg;
-		rtd_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK);
+		rtd_ns_to_timer(&arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
 
 		if (cmd->scan_begin_src == TRIG_TIMER) {
diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c
index bd447b2..2b1db97 100644
--- a/drivers/staging/comedi/drivers/rti800.c
+++ b/drivers/staging/comedi/drivers/rti800.c
@@ -81,8 +81,6 @@
 #define RTI800_9513A_CNTRL	0x0d
 #define RTI800_9513A_STATUS	0x0d
 
-#define RTI800_IOSIZE		0x10
-
 static const struct comedi_lrange range_rti800_ai_10_bipolar = {
 	4, {
 		BIP_RANGE(10),
@@ -281,7 +279,7 @@
 	struct comedi_subdevice *s;
 	int ret;
 
-	ret = comedi_request_region(dev, it->options[0], RTI800_IOSIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x10);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c
index 85d2b7a..83f7433 100644
--- a/drivers/staging/comedi/drivers/s526.c
+++ b/drivers/staging/comedi/drivers/s526.c
@@ -40,13 +40,10 @@
 #include "../comedidev.h"
 #include <asm/byteorder.h>
 
-#define S526_SIZE 64
-
 #define S526_START_AI_CONV	0
 #define S526_AI_READ		0
 
 /* Ports */
-#define S526_IOSIZE 0x40
 #define S526_NUM_PORTS 27
 
 /* registers */
@@ -345,7 +342,6 @@
 
 	default:
 		return -EINVAL;
-		break;
 	}
 
 	return insn->n;
@@ -557,7 +553,7 @@
 	struct comedi_subdevice *s;
 	int ret;
 
-	ret = comedi_request_region(dev, it->options[0], S526_IOSIZE);
+	ret = comedi_request_region(dev, it->options[0], 0x40);
 	if (ret)
 		return ret;
 
diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c
index 9da6822..0b18d24 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -174,8 +174,8 @@
 		udelay(1);
 	}
 	if (i == timeout)
-		comedi_error(dev,
-			"Timeout while uploading to DEBI control register.");
+		dev_err(dev->class_dev,
+			"Timeout while uploading to DEBI control register\n");
 
 	/* Wait until DEBI transfer is done */
 	for (i = 0; i < timeout; i++) {
@@ -184,7 +184,7 @@
 		udelay(1);
 	}
 	if (i == timeout)
-		comedi_error(dev, "DEBI transfer timeout.");
+		dev_err(dev->class_dev, "DEBI transfer timeout\n");
 }
 
 /*
@@ -427,7 +427,7 @@
 	ret = comedi_timeout(dev, NULL, NULL, s626_send_dac_eoc,
 			     s626_send_dac_wait_not_mc1_a2out);
 	if (ret) {
-		comedi_error(dev, "DMA transfer timeout.");
+		dev_err(dev->class_dev, "DMA transfer timeout\n");
 		return ret;
 	}
 
@@ -452,7 +452,8 @@
 	ret = comedi_timeout(dev, NULL, NULL, s626_send_dac_eoc,
 			     s626_send_dac_wait_ssr_af2_out);
 	if (ret) {
-		comedi_error(dev, "TSL timeout waiting for slot 1 to execute.");
+		dev_err(dev->class_dev,
+			"TSL timeout waiting for slot 1 to execute\n");
 		return ret;
 	}
 
@@ -497,8 +498,8 @@
 		ret = comedi_timeout(dev, NULL, NULL, s626_send_dac_eoc,
 				     s626_send_dac_wait_fb_buffer2_msb_00);
 		if (ret) {
-			comedi_error(dev,
-				"TSL timeout waiting for slot 0 to execute.");
+			dev_err(dev->class_dev,
+				"TSL timeout waiting for slot 0 to execute\n");
 			return ret;
 		}
 	}
@@ -522,7 +523,8 @@
 	ret = comedi_timeout(dev, NULL, NULL, s626_send_dac_eoc,
 			     s626_send_dac_wait_fb_buffer2_msb_ff);
 	if (ret) {
-		comedi_error(dev, "TSL timeout waiting for slot 0 to execute.");
+		dev_err(dev->class_dev,
+			"TSL timeout waiting for slot 0 to execute\n");
 		return ret;
 	}
 	return 0;
@@ -836,10 +838,8 @@
 static uint16_t s626_get_mode(struct comedi_device *dev,
 			      unsigned int chan)
 {
-	if (chan < 3)
-		return s626_get_mode_a(dev, chan);
-	else
-		return s626_get_mode_b(dev, chan);
+	return (chan < 3) ? s626_get_mode_a(dev, chan)
+			  : s626_get_mode_b(dev, chan);
 }
 #endif
 
@@ -1047,10 +1047,8 @@
 {
 	uint16_t crb = s626_debi_read(dev, S626_LP_CRB(chan));
 
-	if (chan < 3)
-		return S626_GET_CRB_CLKENAB_A(crb);
-	else
-		return S626_GET_CRB_CLKENAB_B(crb);
+	return (chan < 3) ? S626_GET_CRB_CLKENAB_A(crb)
+			  : S626_GET_CRB_CLKENAB_B(crb);
 }
 #endif
 
@@ -1983,13 +1981,13 @@
  * Also, it should adjust ns so that it cooresponds to the actual time
  * that the device will use.
  */
-static int s626_ns_to_timer(unsigned int *nanosec, int round_mode)
+static int s626_ns_to_timer(unsigned int *nanosec, unsigned int flags)
 {
 	int divider, base;
 
 	base = 500;		/* 2MHz internal clock */
 
-	switch (round_mode) {
+	switch (flags & TRIG_ROUND_MASK) {
 	case TRIG_ROUND_NEAREST:
 	default:
 		divider = (*nanosec + base / 2) / base;
@@ -2089,8 +2087,7 @@
 		 * set a counter to generate adc trigger at scan_begin_arg
 		 * interval
 		 */
-		tick = s626_ns_to_timer(&cmd->scan_begin_arg,
-					cmd->flags & TRIG_ROUND_MASK);
+		tick = s626_ns_to_timer(&cmd->scan_begin_arg, cmd->flags);
 
 		/* load timer value and enable interrupt */
 		s626_timer_load(dev, 5, tick);
@@ -2111,8 +2108,7 @@
 		 * set a counter to generate adc trigger at convert_arg
 		 * interval
 		 */
-		tick = s626_ns_to_timer(&cmd->convert_arg,
-					cmd->flags & TRIG_ROUND_MASK);
+		tick = s626_ns_to_timer(&cmd->convert_arg, cmd->flags);
 
 		/* load timer value and enable interrupt */
 		s626_timer_load(dev, 4, tick);
@@ -2254,13 +2250,13 @@
 
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		arg = cmd->scan_begin_arg;
-		s626_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK);
+		s626_ns_to_timer(&arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
 	}
 
 	if (cmd->convert_src == TRIG_TIMER) {
 		arg = cmd->convert_arg;
-		s626_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK);
+		s626_ns_to_timer(&arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
 
 		if (cmd->scan_begin_src == TRIG_TIMER) {
diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c
index 441813f..167f824 100644
--- a/drivers/staging/comedi/drivers/serial2002.c
+++ b/drivers/staging/comedi/drivers/serial2002.c
@@ -174,6 +174,7 @@
 		} else {
 			/* Device does not support poll, busy wait */
 			int retries = 0;
+
 			while (1) {
 				retries++;
 				if (retries >= timeout)
@@ -311,6 +312,7 @@
 	} else {
 		unsigned char ch[6];
 		int i = 0;
+
 		if (data.value >= (1L << 30)) {
 			ch[i] = 0x80 | ((data.value >> 30) & 0x03);
 			i++;
@@ -359,7 +361,8 @@
 	s->n_chan = chan;
 	s->maxdata = 0;
 	kfree(s->maxdata_list);
-	maxdata_list = kmalloc(sizeof(unsigned int) * s->n_chan, GFP_KERNEL);
+	maxdata_list = kmalloc_array(s->n_chan, sizeof(unsigned int),
+				     GFP_KERNEL);
 	if (!maxdata_list)
 		return -ENOMEM;
 	s->maxdata_list = maxdata_list;
@@ -369,9 +372,8 @@
 	if (kind == 1 || kind == 2) {
 		s->range_table = &range_digital;
 	} else if (range) {
-		range_table_list =
-			kmalloc(sizeof(struct serial2002_range_table_t) *
-				s->n_chan, GFP_KERNEL);
+		range_table_list = kmalloc_array(s->n_chan, sizeof(*range),
+						 GFP_KERNEL);
 		if (!range_table_list)
 			return -ENOMEM;
 		s->range_table_list = range_table_list;
@@ -420,67 +422,65 @@
 	serial2002_tty_setspeed(devpriv->tty, devpriv->speed);
 	serial2002_poll_channel(devpriv->tty, 31);
 	while (1) {
-		struct serial_data data;
+		struct serial_data data = serial2002_read(devpriv->tty, 1000);
+		int kind = S2002_CFG_KIND(data.value);
+		int channel = S2002_CFG_CHAN(data.value);
+		int range = S2002_CFG_BASE(data.value);
+		int cmd = S2002_CFG_CMD(data.value);
 
-		data = serial2002_read(devpriv->tty, 1000);
 		if (data.kind != is_channel || data.index != 31 ||
-		    S2002_CFG_KIND(data.value) == S2002_CFG_KIND_INVALID) {
+		    kind == S2002_CFG_KIND_INVALID)
 			break;
-		} else {
-			int channel = S2002_CFG_CHAN(data.value);
-			int range = S2002_CFG_BASE(data.value);
 
-			switch (S2002_CFG_KIND(data.value)) {
-			case S2002_CFG_KIND_DIGITAL_IN:
-				cfg = di_cfg;
+		switch (kind) {
+		case S2002_CFG_KIND_DIGITAL_IN:
+			cfg = di_cfg;
+			break;
+		case S2002_CFG_KIND_DIGITAL_OUT:
+			cfg = do_cfg;
+			break;
+		case S2002_CFG_KIND_ANALOG_IN:
+			cfg = ai_cfg;
+			break;
+		case S2002_CFG_KIND_ANALOG_OUT:
+			cfg = ao_cfg;
+			break;
+		case S2002_CFG_KIND_ENCODER_IN:
+			cfg = ai_cfg;
+			break;
+		default:
+			cfg = NULL;
+			break;
+		}
+		if (!cfg)
+			continue;	/* unknown kind, skip it */
+
+		cfg[channel].kind = kind;
+
+		switch (cmd) {
+		case S2002_CFG_CMD_BITS:
+			cfg[channel].bits = S2002_CFG_BITS(data.value);
+			break;
+		case S2002_CFG_CMD_MIN:
+		case S2002_CFG_CMD_MAX:
+			switch (S2002_CFG_UNITS(data.value)) {
+			case 0:
+				range *= 1000000;
 				break;
-			case S2002_CFG_KIND_DIGITAL_OUT:
-				cfg = do_cfg;
+			case 1:
+				range *= 1000;
 				break;
-			case S2002_CFG_KIND_ANALOG_IN:
-				cfg = ai_cfg;
-				break;
-			case S2002_CFG_KIND_ANALOG_OUT:
-				cfg = ao_cfg;
-				break;
-			case S2002_CFG_KIND_ENCODER_IN:
-				cfg = ai_cfg;
-				break;
-			default:
-				cfg = NULL;
+			case 2:
+				range *= 1;
 				break;
 			}
-			if (!cfg)
-				continue;	/* unknown kind, skip it */
-
-			cfg[channel].kind = S2002_CFG_KIND(data.value);
-
-			switch (S2002_CFG_CMD(data.value)) {
-			case S2002_CFG_CMD_BITS:
-				cfg[channel].bits = S2002_CFG_BITS(data.value);
-				break;
-			case S2002_CFG_CMD_MIN:
-			case S2002_CFG_CMD_MAX:
-				switch (S2002_CFG_UNITS(data.value)) {
-				case 0:
-					range *= 1000000;
-					break;
-				case 1:
-					range *= 1000;
-					break;
-				case 2:
-					range *= 1;
-					break;
-				}
-				if (S2002_CFG_SIGN(data.value))
-					range = -range;
-				if (S2002_CFG_CMD(data.value) ==
-				    S2002_CFG_CMD_MIN)
-					cfg[channel].min = range;
-				else
-					cfg[channel].max = range;
-				break;
-			}
+			if (S2002_CFG_SIGN(data.value))
+				range = -range;
+			if (cmd == S2002_CFG_CMD_MIN)
+				cfg[channel].min = range;
+			else
+				cfg[channel].max = range;
+			break;
 		}
 	}
 
diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c
index 3bfa221..a118678 100644
--- a/drivers/staging/comedi/drivers/skel.c
+++ b/drivers/staging/comedi/drivers/skel.c
@@ -75,9 +75,6 @@
 #include "comedi_fc.h"
 
 /* Imaginary registers for the imaginary board */
-
-#define SKEL_SIZE 0
-
 #define SKEL_START_AI_CONV	0
 #define SKEL_AI_READ		0
 
@@ -129,7 +126,7 @@
  * convert ns nanoseconds to a counter value suitable for programming
  * the device.  Also, it should adjust ns so that it cooresponds to
  * the actual time that the device will use. */
-static int skel_ns_to_timer(unsigned int *ns, int round)
+static int skel_ns_to_timer(unsigned int *ns, unsigned int flags)
 {
 	/* trivial timer */
 	/* if your timing is done through two cascaded timers, the
@@ -287,12 +284,12 @@
 
 	if (cmd->scan_begin_src == TRIG_TIMER) {
 		arg = cmd->scan_begin_arg;
-		skel_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK);
+		skel_ns_to_timer(&arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
 	}
 	if (cmd->convert_src == TRIG_TIMER) {
 		arg = cmd->convert_arg;
-		skel_ns_to_timer(&arg, cmd->flags & TRIG_ROUND_MASK);
+		skel_ns_to_timer(&arg, cmd->flags);
 		err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
 
 		if (cmd->scan_begin_src == TRIG_TIMER) {
diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c
index adf7cb7..7c2276a 100644
--- a/drivers/staging/comedi/drivers/unioxx5.c
+++ b/drivers/staging/comedi/drivers/unioxx5.c
@@ -43,7 +43,6 @@
 #include <linux/delay.h>
 #include "../comedidev.h"
 
-#define DRIVER_NAME "unioxx5"
 #define UNIOXX5_SIZE 0x10
 #define UNIOXX5_SUBDEV_BASE 0xA000	/* base addr of first subdev */
 #define UNIOXX5_SUBDEV_ODDS 0x400
@@ -496,7 +495,7 @@
 }
 
 static struct comedi_driver unioxx5_driver = {
-	.driver_name	= DRIVER_NAME,
+	.driver_name	= "unioxx5",
 	.module		= THIS_MODULE,
 	.attach		= unioxx5_attach,
 	.detach		= unioxx5_detach,
diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 5f65e42..053bc50 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1327,13 +1327,13 @@
 	struct usbdux_private *devpriv = dev->private;
 	int fx2delay = 255;
 
-	if (period < MIN_PWM_PERIOD) {
+	if (period < MIN_PWM_PERIOD)
 		return -EAGAIN;
-	} else {
-		fx2delay = (period / (6 * 512 * 1000 / 33)) - 6;
-		if (fx2delay > 255)
-			return -EAGAIN;
-	}
+
+	fx2delay = (period / (6 * 512 * 1000 / 33)) - 6;
+	if (fx2delay > 255)
+		return -EAGAIN;
+
 	devpriv->pwm_delay = fx2delay;
 	devpriv->pwm_period = period;
 
diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c
index 85f9dcf..2490e88 100644
--- a/drivers/staging/comedi/drivers/usbduxfast.c
+++ b/drivers/staging/comedi/drivers/usbduxfast.c
@@ -33,8 +33,6 @@
  *       udev coldplug problem
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -275,8 +273,9 @@
 		return;
 
 	default:
-		pr_err("non-zero urb status received in ai intr context: %d\n",
-		       urb->status);
+		dev_err(dev->class_dev,
+			"non-zero urb status received in ai intr context: %d\n",
+			urb->status);
 		async->events |= COMEDI_CB_EOA;
 		async->events |= COMEDI_CB_ERROR;
 		comedi_event(dev, s);
diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c
index e869af4..94a09c1 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -1176,13 +1176,13 @@
 	struct usbduxsigma_private *devpriv = dev->private;
 	int fx2delay = 255;
 
-	if (period < MIN_PWM_PERIOD) {
+	if (period < MIN_PWM_PERIOD)
 		return -EAGAIN;
-	} else {
-		fx2delay = (period / (6 * 512 * 1000 / 33)) - 6;
-		if (fx2delay > 255)
-			return -EAGAIN;
-	}
+
+	fx2delay = (period / (6 * 512 * 1000 / 33)) - 6;
+	if (fx2delay > 255)
+		return -EAGAIN;
+
 	devpriv->pwm_delay = fx2delay;
 	devpriv->pwm_period = period;
 	return 0;
diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 32988a8..06c55cb 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -150,9 +150,8 @@
 /*
  * Function prototypes from dgap_parse.c.
  */
-static int dgap_gettok(char **in, struct cnode *p);
+static int dgap_gettok(char **in);
 static char *dgap_getword(char **in);
-static struct cnode *dgap_newnode(int t);
 static int dgap_checknode(struct cnode *p);
 static void dgap_err(char *s);
 
@@ -2181,10 +2180,7 @@
 
 	spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
 
-	if (retval)
-		return retval;
-
-	return 0;
+	return retval;
 }
 
 /*
@@ -6345,7 +6341,7 @@
 		p = p->next;
 
 	/* file must start with a BEGIN */
-	while ((rc = dgap_gettok(in, p)) != BEGIN) {
+	while ((rc = dgap_gettok(in)) != BEGIN) {
 		if (rc == 0) {
 			dgap_err("unexpected EOF");
 			return -1;
@@ -6353,17 +6349,13 @@
 	}
 
 	for (; ;) {
-		rc = dgap_gettok(in, p);
+		rc = dgap_gettok(in);
 		if (rc == 0) {
 			dgap_err("unexpected EOF");
 			return -1;
 		}
 
 		switch (rc) {
-		case 0:
-			dgap_err("unexpected end of file");
-			return -1;
-
 		case BEGIN:	/* should only be 1 begin */
 			dgap_err("unexpected config_begin\n");
 			return -1;
@@ -6374,13 +6366,15 @@
 		case BOARD:	/* board info */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(BNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
 			p = p->next;
 
+			p->type = BNODE;
 			p->u.board.status = kstrdup("No", GFP_KERNEL);
 			line = conc = NULL;
 			brd = p;
@@ -6665,12 +6659,16 @@
 		case TTYN:	/* tty name prefix */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(TNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = TNODE;
+
 			s = dgap_getword(in);
 			if (!s) {
 				dgap_err("unexpeced end of file");
@@ -6686,12 +6684,16 @@
 		case CU:	/* cu name prefix */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(CUNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = CUNODE;
+
 			s = dgap_getword(in);
 			if (!s) {
 				dgap_err("unexpeced end of file");
@@ -6716,12 +6718,15 @@
 				dgap_err("line not vaild for PC/em");
 				return -1;
 			}
-			p->next = dgap_newnode(LNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = LNODE;
 			conc = NULL;
 			line = p;
 			linecnt++;
@@ -6734,13 +6739,17 @@
 				dgap_err("must specify line info before concentrator");
 				return -1;
 			}
-			p->next = dgap_newnode(CNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = CNODE;
 			conc = p;
+
 			if (linecnt)
 				brd->u.board.conc2++;
 			else
@@ -6783,12 +6792,15 @@
 					return -1;
 				}
 			}
-			p->next = dgap_newnode(MNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
 			p = p->next;
+			p->type = MNODE;
+
 			if (linecnt)
 				brd->u.board.module2++;
 			else
@@ -6869,12 +6881,16 @@
 		case PRINT:	/* transparent print name prefix */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(PNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = PNODE;
+
 			s = dgap_getword(in);
 			if (!s) {
 				dgap_err("unexpeced end of file");
@@ -6890,12 +6906,16 @@
 		case CMAJOR:	/* major number */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(JNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = JNODE;
+
 			s = dgap_getword(in);
 			if (!s) {
 				dgap_err("unexpected end of file");
@@ -6910,12 +6930,16 @@
 		case ALTPIN:	/* altpin setting */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(ANODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = ANODE;
+
 			s = dgap_getword(in);
 			if (!s) {
 				dgap_err("unexpected end of file");
@@ -6930,12 +6954,14 @@
 		case USEINTR:		/* enable interrupt setting */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(INTRNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
 			p = p->next;
+			p->type = INTRNODE;
 			s = dgap_getword(in);
 			if (!s) {
 				dgap_err("unexpected end of file");
@@ -6950,12 +6976,16 @@
 		case TTSIZ:	/* size of tty structure */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(TSNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = TSNODE;
+
 			s = dgap_getword(in);
 			if (!s) {
 				dgap_err("unexpected end of file");
@@ -6970,12 +7000,16 @@
 		case CHSIZ:	/* channel structure size */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(CSNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = CSNODE;
+
 			s = dgap_getword(in);
 			if (!s) {
 				dgap_err("unexpected end of file");
@@ -6990,12 +7024,16 @@
 		case BSSIZ:	/* board structure size */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(BSNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = BSNODE;
+
 			s = dgap_getword(in);
 			if (!s) {
 				dgap_err("unexpected end of file");
@@ -7010,12 +7048,16 @@
 		case UNTSIZ:	/* sched structure size */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(USNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = USNODE;
+
 			s = dgap_getword(in);
 			if (!s) {
 				dgap_err("unexpected end of file");
@@ -7030,12 +7072,16 @@
 		case F2SIZ:	/* f2200 structure size */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(FSNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = FSNODE;
+
 			s = dgap_getword(in);
 			if (!s) {
 				dgap_err("unexpected end of file");
@@ -7050,12 +7096,16 @@
 		case VPSIZ:	/* vpix structure size */
 			if (dgap_checknode(p))
 				return -1;
-			p->next = dgap_newnode(VSNODE);
+
+			p->next = kzalloc(sizeof(struct cnode), GFP_KERNEL);
 			if (!p->next) {
 				dgap_err("out of memory");
 				return -1;
 			}
+
 			p = p->next;
+			p->type = VSNODE;
+
 			s = dgap_getword(in);
 			if (!s) {
 				dgap_err("unexpected end of file");
@@ -7107,12 +7157,12 @@
 /*
  * Get a token from the input file; return 0 if end of file is reached
  */
-static int dgap_gettok(char **in, struct cnode *p)
+static int dgap_gettok(char **in)
 {
 	char *w;
 	struct toklist *t;
 
-	if (strstr(dgap_cword, "boar")) {
+	if (strstr(dgap_cword, "board")) {
 		w = dgap_getword(in);
 		snprintf(dgap_cword, MAXCWORD, "%s", w);
 		for (t = dgap_tlist; t->token != 0; t++) {
@@ -7172,19 +7222,6 @@
 }
 
 /*
- * allocate a new configuration node of type t
- */
-static struct cnode *dgap_newnode(int t)
-{
-	struct cnode *n;
-
-	n = kzalloc(sizeof(struct cnode), GFP_KERNEL);
-	if (n)
-		n->type = t;
-	return n;
-}
-
-/*
  * dgap_checknode: see if all the necessary info has been supplied for a node
  * before creating the next node.
  */
diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h
index 3519b80..fe5ea90 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -98,7 +98,7 @@
 /* Choose one: */
 #  define TRC_ON_OVERFLOW_WRAP_AROUND
 #  undef  TRC_ON_OVERFLOW_SHIFT_BUFFER
-# endif //TRC_TO_KMEM
+# endif /* TRC_TO_KMEM */
 
 # define TRC_MAXMSG		1024
 # define TRC_OVERFLOW		"(OVERFLOW)"
@@ -106,13 +106,13 @@
 
 #if defined TRC_TO_CONSOLE
 #define PRINTF_TO_CONSOLE(args) { printk(DRVSTR": "); printk args; }
-#else //!defined TRACE_TO_CONSOLE
+#else /* !defined TRACE_TO_CONSOLE */
 #define PRINTF_TO_CONSOLE(args)
 #endif
 
 #if defined TRC_TO_KMEM
 #define PRINTF_TO_KMEM(args) dgnc_tracef args
-#else //!defined TRC_TO_KMEM
+#else /* !defined TRC_TO_KMEM */
 #define PRINTF_TO_KMEM(args)
 #endif
 
@@ -140,7 +140,7 @@
 # define P(X)			dgnc_tracef(#X "=%p\n", X)
 # define X(X)			dgnc_tracef(#X "=%x\n", X)
 
-#else//!defined DGNC_TRACER
+#else/* !defined DGNC_TRACER */
 
 #define PRINTF_TO_KMEM(args)
 # define TRC(ARGS)
@@ -164,7 +164,7 @@
 
 # define DPR(args)
 
-#endif//DGNC_TRACER
+#endif/* DGNC_TRACER */
 
 /* Number of boards we support at once. */
 #define	MAXBOARDS	20
diff --git a/drivers/staging/dgnc/digi.h b/drivers/staging/dgnc/digi.h
index 6a9adf6..282908f 100644
--- a/drivers/staging/dgnc/digi.h
+++ b/drivers/staging/dgnc/digi.h
@@ -394,23 +394,23 @@
 #define DIGI_REALPORT_GETCOUNTERS ('e'<<8 ) | 110
 #define DIGI_REALPORT_GETEVENTS ('e'<<8 ) | 111
 
-#define EV_OPU		0x0001		//!<Output paused by client
-#define EV_OPS		0x0002		//!<Output paused by reqular sw flowctrl
-#define EV_OPX		0x0004		//!<Output paused by extra sw flowctrl
-#define EV_OPH		0x0008		//!<Output paused by hw flowctrl
-#define EV_OPT		0x0800		//!<Output paused for RTS Toggle predelay
+#define EV_OPU		0x0001		/* !<Output paused by client */
+#define EV_OPS		0x0002		/* !<Output paused by reqular sw flowctrl */
+#define EV_OPX		0x0004		/* !<Output paused by extra sw flowctrl */
+#define EV_OPH		0x0008		/* !<Output paused by hw flowctrl */
+#define EV_OPT		0x0800		/* !<Output paused for RTS Toggle predelay */
 
-#define EV_IPU		0x0010		//!<Input paused unconditionally by user
-#define EV_IPS		0x0020		//!<Input paused by high/low water marks
-//#define EV_IPH	0x0040		//!<Input paused w/ hardware
-#define EV_IPA		0x0400		//!<Input paused by pattern alarm module
+#define EV_IPU		0x0010		/* !<Input paused unconditionally by user */
+#define EV_IPS		0x0020		/* !<Input paused by high/low water marks */
+/* #define EV_IPH	0x0040		//!<Input paused w/ hardware */
+#define EV_IPA		0x0400		/* !<Input paused by pattern alarm module */
 
-#define EV_TXB		0x0040		//!<Transmit break pending
-#define EV_TXI		0x0080		//!<Transmit immediate pending
-#define EV_TXF		0x0100		//!<Transmit flowctrl char pending
-#define EV_RXB		0x0200		//!<Break received
+#define EV_TXB		0x0040		/* !<Transmit break pending */
+#define EV_TXI		0x0080		/* !<Transmit immediate pending */
+#define EV_TXF		0x0100		/* !<Transmit flowctrl char pending */
+#define EV_RXB		0x0200		/* !<Break received */
 
-#define EV_OPALL	0x080f		//!<Output pause flags
-#define EV_IPALL	0x0430		//!<Input pause flags
+#define EV_OPALL	0x080f		/* !<Output pause flags */
+#define EV_IPALL	0x0430		/* !<Input pause flags */
 
 #endif /* DIGI_H */
diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
index 0003463..b2eaf01 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -562,12 +562,12 @@
 
 /*-------------------------------------------------------------------------*/
 /* Endpoint 0 OUT Transfer (PIO) */
-static int EP0_out_PIO(struct nbu2ss_udc *udc, u8* pBuf, u32 length)
+static int EP0_out_PIO(struct nbu2ss_udc *udc, u8 *pBuf, u32 length)
 {
 	u32		i;
 	int		nret   = 0;
 	u32		iWordLength = 0;
-	USB_REG_ACCESS* pBuf32 = (USB_REG_ACCESS *)pBuf;
+	USB_REG_ACCESS *pBuf32 = (USB_REG_ACCESS *)pBuf;
 
 	/*------------------------------------------------------------*/
 	/* Read Length */
@@ -588,12 +588,12 @@
 
 /*-------------------------------------------------------------------------*/
 /* Endpoint 0 OUT Transfer (PIO, OverBytes) */
-static int EP0_out_OverBytes(struct nbu2ss_udc *udc, u8* pBuf, u32 length)
+static int EP0_out_OverBytes(struct nbu2ss_udc *udc, u8 *pBuf, u32 length)
 {
 	u32		i;
 	u32		iReadSize = 0;
 	USB_REG_ACCESS  Temp32;
-	USB_REG_ACCESS* pBuf32 = (USB_REG_ACCESS *)pBuf;
+	USB_REG_ACCESS *pBuf32 = (USB_REG_ACCESS *)pBuf;
 
 	if ((0 < length) && (length < sizeof(u32))) {
 		Temp32.dw = _nbu2ss_readl(&udc->p_regs->EP0_READ);
@@ -613,7 +613,7 @@
 	u32		iMaxLength   = EP0_PACKETSIZE;
 	u32		iWordLength  = 0;
 	u32		iWriteLength = 0;
-	USB_REG_ACCESS*	pBuf32 = (USB_REG_ACCESS *)pBuf;
+	USB_REG_ACCESS *pBuf32 = (USB_REG_ACCESS *)pBuf;
 
 	/*------------------------------------------------------------*/
 	/* Transfer Length */
@@ -639,7 +639,7 @@
 {
 	u32		i;
 	USB_REG_ACCESS Temp32;
-	USB_REG_ACCESS* pBuf32 = (USB_REG_ACCESS *)pBuf;
+	USB_REG_ACCESS *pBuf32 = (USB_REG_ACCESS *)pBuf;
 
 	if ((0 < iRemainSize) && (iRemainSize < sizeof(u32))) {
 		for (i = 0 ; i < iRemainSize ; i++)
@@ -3339,7 +3339,7 @@
 	udc->gadget.ep0 = &udc->ep[0].ep;
 	udc->gadget.speed = USB_SPEED_UNKNOWN;
 	udc->gadget.name = driver_name;
-	//udc->gadget.is_dualspeed = 1;
+	/* udc->gadget.is_dualspeed = 1; */
 
 	device_initialize(&udc->gadget.dev);
 
diff --git a/drivers/staging/frontier/Kconfig b/drivers/staging/frontier/Kconfig
deleted file mode 100644
index 4da290b..0000000
--- a/drivers/staging/frontier/Kconfig
+++ /dev/null
@@ -1,5 +0,0 @@
-config TRANZPORT
-	tristate "Frontier Tranzport and Alphatrack support"
-	depends on USB
-	---help---
-	  Enable support for the Frontier Tranzport and Alphatrack devices.
diff --git a/drivers/staging/frontier/Makefile b/drivers/staging/frontier/Makefile
deleted file mode 100644
index 2d2ac97..0000000
--- a/drivers/staging/frontier/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-obj-$(CONFIG_TRANZPORT)		+= tranzport.o
-obj-$(CONFIG_TRANZPORT)		+= alphatrack.o
diff --git a/drivers/staging/frontier/README b/drivers/staging/frontier/README
deleted file mode 100644
index cd07af2..0000000
--- a/drivers/staging/frontier/README
+++ /dev/null
@@ -1,47 +0,0 @@
-This directory contains the Linux USB Tranzport and Alphatrack Kernel drivers.
-
-See http://www.frontierdesign.com for details on these devices.
-
-Userspace test code is available from
-
-git://toutatis.isc.org/home/d/src/git/frontier.git
-
-At present the tranzport does reads/writes of 8 byte cmds to
-/dev/tranzport0 to control the lights, screen, and wheel.
-
-At present the alphatrack accepts reads/writes of 12 byte cmds to
-/dev/tranzport0 to control the lights, screen, fader and touchpad.
-
-The tranzport driver provides a rudimentary sysfs interface for the status of
-the device and a writable parameter for turning wheel compression on and off.
-
-The API is nothing more than the USB commands issued to the device. Why?
-
-The control wheel/fader can generate events far too quickly for
-a typical userspace application to keep up with them via libusb. Input
-needs to be 100% accurate and fast in order for the alphatrack or tranzport
-to be useful.
-
-UIO would be useful except that usb disconnect events need
-to be handled correctly.
-
-A sysfs interface is perfect for simple userspace apps to do fun things with
-the lights and screen. But it's fairly lousy for handling input events and
-very lousy for watching the state of the shuttle wheel.
-
-A linux input events interface is great for the input events and shuttle wheel.
-* It's theoretically OK on LEDs.
-* A fader can be mapped to an absolute mouse device.
-* But there is no LCD support at all, or fader feedback support in that API
-
-So, thus, these stubby drivers exist.
-
-In the end this could be driven by a midi layer, which handles all those
-cases via a well defined API, but - among other things - is slow, doesn't do
-flow control, and is a LOT of extra work, none of which is required at
-the kernel level (probably). Frankly, I'd like to keep the
-core driver simple because the only realtime work really required is
-the bottom half interrupt handler and the output overlapping.
-
-Exposing some sort of clean api to userspace would be perfect. What that
-API looks like? Gah. beats me.
diff --git a/drivers/staging/frontier/TODO b/drivers/staging/frontier/TODO
deleted file mode 100644
index 3620ad2..0000000
--- a/drivers/staging/frontier/TODO
+++ /dev/null
@@ -1,9 +0,0 @@
-TODO:
-	- checkpatch.pl clean
-	- sparse clean
-	- fix userspace interface to be sane
-	- possibly just port to userspace with libusb
-	- review by the USB developer community
-
-Please send any patches for this driver to Greg Kroah-Hartman <greg@kroah.com>
-and David Taht <d@teklibre.com>.
diff --git a/drivers/staging/frontier/alphatrack.c b/drivers/staging/frontier/alphatrack.c
deleted file mode 100644
index 226b231..0000000
--- a/drivers/staging/frontier/alphatrack.c
+++ /dev/null
@@ -1,849 +0,0 @@
-/*
- * Frontier Designs Alphatrack driver
- *
- * Copyright (C) 2007 Michael Taht (m@taht.net)
- *
- * Based on the usbled driver and ldusb drivers by
- *
- * Copyright (C) 2004 Greg Kroah-Hartman (greg@kroah.com)
- * Copyright (C) 2005 Michael Hund <mhund@ld-didactic.de>
- *
- * The ldusb driver was, in turn, derived from Lego USB Tower driver
- * Copyright (C) 2003 David Glance <advidgsf@sourceforge.net>
- *		 2001-2004 Juergen Stuber <starblue@users.sourceforge.net>
- *
- *	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, version 2.
- *
- */
-
-/**
- * This driver uses a ring buffer for time critical reading of
- * interrupt in reports and provides read and write methods for
- * raw interrupt reports.
- */
-
-/*
- * Note: this currently uses a dumb ringbuffer for reads and writes.
- * A more optimal driver would cache and kill off outstanding urbs that are
- * now invalid, and ignore ones that already were in the queue but valid
- * as we only have 30 commands for the alphatrack. In particular this is
- * key for getting lights to flash in time as otherwise many commands
- * can be buffered up before the light change makes it to the interface.
- */
-
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/kobject.h>
-#include <linux/mutex.h>
-
-#include <linux/uaccess.h>
-#include <linux/input.h>
-#include <linux/usb.h>
-#include <linux/poll.h>
-
-#include "alphatrack.h"
-
-#define VENDOR_ID	0x165b
-#define PRODUCT_ID	0xfad1
-
-#ifdef CONFIG_USB_DYNAMIC_MINORS
-#define USB_ALPHATRACK_MINOR_BASE	0
-#else
-/* FIXME 176 - is another driver's minor - apply for that */
-#define USB_ALPHATRACK_MINOR_BASE	176
-#endif
-
-/* table of devices that work with this driver */
-static const struct usb_device_id usb_alphatrack_table[] = {
-	{USB_DEVICE(VENDOR_ID, PRODUCT_ID)},
-	{}			/* Terminating entry */
-};
-
-MODULE_DEVICE_TABLE(usb, usb_alphatrack_table);
-MODULE_VERSION("0.41");
-MODULE_AUTHOR("Mike Taht <m@taht.net>");
-MODULE_DESCRIPTION("Alphatrack USB Driver");
-MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("Frontier Designs Alphatrack Control Surface");
-
-/* These aren't done yet */
-
-#define SUPPRESS_EXTRA_ONLINE_EVENTS 0
-#define BUFFERED_WRITES 0
-#define SUPPRESS_EXTRA_OFFLINE_EVENTS 0
-#define COMPRESS_FADER_EVENTS 0
-
-#define BUFFERED_READS 1
-#define RING_BUFFER_SIZE 512
-#define WRITE_BUFFER_SIZE 34
-#define ALPHATRACK_USB_TIMEOUT 10
-#define OUTPUT_CMD_SIZE 8
-#define INPUT_CMD_SIZE 12
-#define ALPHATRACK_DEBUG 0
-
-static int debug = ALPHATRACK_DEBUG;
-
-/* Use our own dbg macro */
-#define dbg_info(dev, format, arg...) do \
-	{ if (debug) dev_info(dev , format , ## arg); } while (0)
-
-#define alphatrack_ocmd_info(dev, cmd, format, arg...)
-
-#define alphatrack_icmd_info(dev, cmd, format, arg...)
-
-/* Module parameters */
-
-module_param(debug, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(debug, "Debug enabled or not");
-
-/*
- * All interrupt in transfers are collected in a ring buffer to
- * avoid racing conditions and get better performance of the driver.
- */
-
-static int ring_buffer_size = RING_BUFFER_SIZE;
-
-module_param(ring_buffer_size, int, S_IRUGO);
-MODULE_PARM_DESC(ring_buffer_size, "Read ring buffer size");
-
-/* The write_buffer can one day contain more than one interrupt out transfer.*/
-
-static int write_buffer_size = WRITE_BUFFER_SIZE;
-module_param(write_buffer_size, int, S_IRUGO);
-MODULE_PARM_DESC(write_buffer_size, "Write buffer size");
-
-/*
- * Increase the interval for debugging purposes.
- * or set to 1 to use the standard interval from the endpoint descriptors.
- */
-
-static int min_interrupt_in_interval = ALPHATRACK_USB_TIMEOUT;
-module_param(min_interrupt_in_interval, int, 0);
-MODULE_PARM_DESC(min_interrupt_in_interval,
-		 "Minimum interrupt in interval in ms");
-
-static int min_interrupt_out_interval = ALPHATRACK_USB_TIMEOUT;
-module_param(min_interrupt_out_interval, int, 0);
-MODULE_PARM_DESC(min_interrupt_out_interval,
-		 "Minimum interrupt out interval in ms");
-
-/* Structure to hold all of our device specific stuff */
-
-struct usb_alphatrack {
-	struct mutex mtx;	/* locks this structure */
-	struct usb_interface *intf;	/* save off the usb interface pointer */
-	int open_count;		/* number of times this port has been opened */
-
-	/* make gcc happy */
-	struct alphatrack_icmd (*ring_buffer)[RING_BUFFER_SIZE];
-	struct alphatrack_ocmd (*write_buffer)[WRITE_BUFFER_SIZE];
-	unsigned int ring_head;
-	unsigned int ring_tail;
-
-	wait_queue_head_t read_wait;
-	wait_queue_head_t write_wait;
-
-	unsigned char *interrupt_in_buffer;
-	unsigned char *oldi_buffer;
-	struct usb_endpoint_descriptor *interrupt_in_endpoint;
-	struct urb *interrupt_in_urb;
-	int interrupt_in_interval;
-	size_t interrupt_in_endpoint_size;
-	int interrupt_in_running;
-	int interrupt_in_done;
-
-	char *interrupt_out_buffer;
-	struct usb_endpoint_descriptor *interrupt_out_endpoint;
-	struct urb *interrupt_out_urb;
-	int interrupt_out_interval;
-	size_t interrupt_out_endpoint_size;
-	int interrupt_out_busy;
-
-	atomic_t writes_pending;
-	int event;		/* alternate interface to events */
-	int fader;		/* 10 bits */
-	int lights;		/* 23 bits */
-	unsigned char dump_state;	/* 0 if disabled 1 if enabled */
-	unsigned char enable;	/* 0 if disabled 1 if enabled */
-	unsigned char offline;	/* if the device is out of range or asleep */
-	unsigned char verbose;	/* be verbose in error reporting */
-	unsigned char last_cmd[OUTPUT_CMD_SIZE];
-	unsigned char screen[32];
-};
-
-/* prevent races between open() and disconnect() */
-static DEFINE_MUTEX(disconnect_mutex);
-
-/* forward declaration */
-
-static struct usb_driver usb_alphatrack_driver;
-
-/**
- *	usb_alphatrack_abort_transfers
- *      aborts transfers and frees associated data structures
- */
-static void usb_alphatrack_abort_transfers(struct usb_alphatrack *dev)
-{
-	/* shutdown transfer */
-	if (dev->interrupt_in_running) {
-		dev->interrupt_in_running = 0;
-		if (dev->intf)
-			usb_kill_urb(dev->interrupt_in_urb);
-	}
-	if (dev->interrupt_out_busy)
-		if (dev->intf)
-			usb_kill_urb(dev->interrupt_out_urb);
-}
-
-/** usb_alphatrack_delete */
-static void usb_alphatrack_delete(struct usb_alphatrack *dev)
-{
-	usb_alphatrack_abort_transfers(dev);
-	usb_free_urb(dev->interrupt_in_urb);
-	usb_free_urb(dev->interrupt_out_urb);
-	kfree(dev->ring_buffer);
-	kfree(dev->interrupt_in_buffer);
-	kfree(dev->interrupt_out_buffer);
-	kfree(dev->oldi_buffer);
-	kfree(dev->write_buffer);
-	kfree(dev);
-}
-
-/** usb_alphatrack_interrupt_in_callback */
-
-static void usb_alphatrack_interrupt_in_callback(struct urb *urb)
-{
-	struct usb_alphatrack *dev = urb->context;
-	unsigned int next_ring_head;
-	int retval = -1;
-
-	if (urb->status) {
-		if (urb->status == -ENOENT ||
-		    urb->status == -ECONNRESET || urb->status == -ESHUTDOWN) {
-			goto exit;
-		} else {
-			dbg_info(&dev->intf->dev,
-				 "%s: nonzero status received: %d\n", __func__,
-				 urb->status);
-			goto resubmit;	/* maybe we can recover */
-		}
-	}
-
-	if (urb->actual_length != INPUT_CMD_SIZE) {
-		dev_warn(&dev->intf->dev,
-			 "Urb length was %d bytes!! Do something intelligent\n",
-			 urb->actual_length);
-	} else {
-		alphatrack_ocmd_info(&dev->intf->dev,
-				     &(*dev->ring_buffer)[dev->ring_tail].cmd,
-				     "%s", "bla");
-		if (memcmp
-		    (dev->interrupt_in_buffer, dev->oldi_buffer,
-		     INPUT_CMD_SIZE) == 0) {
-			goto resubmit;
-		}
-		memcpy(dev->oldi_buffer, dev->interrupt_in_buffer,
-		       INPUT_CMD_SIZE);
-
-#if SUPPRESS_EXTRA_OFFLINE_EVENTS
-		if (dev->offline == 2 && dev->interrupt_in_buffer[1] == 0xff)
-			goto resubmit;
-		if (dev->offline == 1 && dev->interrupt_in_buffer[1] == 0xff) {
-			dev->offline = 2;
-			goto resubmit;
-		}
-/* Always pass one offline event up the stack */
-		if (dev->offline > 0 && dev->interrupt_in_buffer[1] != 0xff)
-			dev->offline = 0;
-		if (dev->offline == 0 && dev->interrupt_in_buffer[1] == 0xff)
-			dev->offline = 1;
-#endif
-		dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n",
-			 __func__, dev->ring_head, dev->ring_tail);
-		next_ring_head = (dev->ring_head + 1) % ring_buffer_size;
-
-		if (next_ring_head != dev->ring_tail) {
-			memcpy(&((*dev->ring_buffer)[dev->ring_head]),
-			       dev->interrupt_in_buffer, urb->actual_length);
-			dev->ring_head = next_ring_head;
-			retval = 0;
-			memset(dev->interrupt_in_buffer, 0, urb->actual_length);
-		} else {
-			dev_warn(&dev->intf->dev,
-				 "Ring buffer overflow, %d bytes dropped\n",
-				 urb->actual_length);
-			memset(dev->interrupt_in_buffer, 0, urb->actual_length);
-		}
-	}
-
-resubmit:
-	/* resubmit if we're still running */
-	if (dev->interrupt_in_running && dev->intf) {
-		retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC);
-		if (retval)
-			dev_err(&dev->intf->dev,
-				"usb_submit_urb failed (%d)\n", retval);
-	}
-
-exit:
-	dev->interrupt_in_done = 1;
-	wake_up_interruptible(&dev->read_wait);
-}
-
-/** usb_alphatrack_interrupt_out_callback */
-static void usb_alphatrack_interrupt_out_callback(struct urb *urb)
-{
-	struct usb_alphatrack *dev = urb->context;
-
-	/* sync/async unlink faults aren't errors */
-	if (urb->status && !(urb->status == -ENOENT ||
-			     urb->status == -ECONNRESET ||
-			     urb->status == -ESHUTDOWN))
-		dbg_info(&dev->intf->dev,
-			 "%s - nonzero write interrupt status received: %d\n",
-			 __func__, urb->status);
-	atomic_dec(&dev->writes_pending);
-	dev->interrupt_out_busy = 0;
-	wake_up_interruptible(&dev->write_wait);
-}
-
-/** usb_alphatrack_open */
-static int usb_alphatrack_open(struct inode *inode, struct file *file)
-{
-	struct usb_alphatrack *dev;
-	int subminor;
-	int retval = 0;
-	struct usb_interface *interface;
-
-	nonseekable_open(inode, file);
-	subminor = iminor(inode);
-
-	mutex_lock(&disconnect_mutex);
-
-	interface = usb_find_interface(&usb_alphatrack_driver, subminor);
-
-	if (!interface) {
-		pr_err("%s - error, can't find device for minor %d\n",
-		       __func__, subminor);
-		retval = -ENODEV;
-		goto unlock_disconnect_exit;
-	}
-
-	dev = usb_get_intfdata(interface);
-
-	if (!dev) {
-		retval = -ENODEV;
-		goto unlock_disconnect_exit;
-	}
-
-	/* lock this device */
-	if (mutex_lock_interruptible(&dev->mtx)) {
-		retval = -ERESTARTSYS;
-		goto unlock_disconnect_exit;
-	}
-
-	/* allow opening only once */
-	if (dev->open_count) {
-		retval = -EBUSY;
-		goto unlock_exit;
-	}
-	dev->open_count = 1;
-
-	/* initialize in direction */
-	dev->ring_head = 0;
-	dev->ring_tail = 0;
-	usb_fill_int_urb(dev->interrupt_in_urb,
-			 interface_to_usbdev(interface),
-			 usb_rcvintpipe(interface_to_usbdev(interface),
-					dev->interrupt_in_endpoint->
-					bEndpointAddress),
-			 dev->interrupt_in_buffer,
-			 dev->interrupt_in_endpoint_size,
-			 usb_alphatrack_interrupt_in_callback, dev,
-			 dev->interrupt_in_interval);
-
-	dev->interrupt_in_running = 1;
-	dev->interrupt_in_done = 0;
-	dev->enable = 1;
-	dev->offline = 0;
-
-	retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
-	if (retval) {
-		dev_err(&interface->dev,
-			"Couldn't submit interrupt_in_urb %d\n", retval);
-		dev->interrupt_in_running = 0;
-		dev->open_count = 0;
-		goto unlock_exit;
-	}
-
-	/* save device in the file's private structure */
-	file->private_data = dev;
-
-unlock_exit:
-	mutex_unlock(&dev->mtx);
-
-unlock_disconnect_exit:
-	mutex_unlock(&disconnect_mutex);
-
-	return retval;
-}
-
-/** usb_alphatrack_release */
-static int usb_alphatrack_release(struct inode *inode, struct file *file)
-{
-	struct usb_alphatrack *dev;
-	int retval = 0;
-
-	dev = file->private_data;
-
-	if (dev == NULL) {
-		retval = -ENODEV;
-		goto exit;
-	}
-
-	if (mutex_lock_interruptible(&dev->mtx)) {
-		retval = -ERESTARTSYS;
-		goto exit;
-	}
-
-	if (dev->open_count != 1) {
-		retval = -ENODEV;
-		goto unlock_exit;
-	}
-
-	if (dev->intf == NULL) {
-		/* the device was unplugged before the file was released */
-		mutex_unlock(&dev->mtx);
-		/* unlock here as usb_alphatrack_delete frees dev */
-		usb_alphatrack_delete(dev);
-		retval = -ENODEV;
-		goto exit;
-	}
-
-	/* wait until write transfer is finished */
-	if (dev->interrupt_out_busy)
-		wait_event_interruptible_timeout(dev->write_wait,
-						 !dev->interrupt_out_busy,
-						 2 * HZ);
-	usb_alphatrack_abort_transfers(dev);
-	dev->open_count = 0;
-
-unlock_exit:
-	mutex_unlock(&dev->mtx);
-
-exit:
-	return retval;
-}
-
-/** usb_alphatrack_poll */
-static unsigned int usb_alphatrack_poll(struct file *file, poll_table *wait)
-{
-	struct usb_alphatrack *dev;
-	unsigned int mask = 0;
-
-	dev = file->private_data;
-
-	poll_wait(file, &dev->read_wait, wait);
-	poll_wait(file, &dev->write_wait, wait);
-
-	if (dev->ring_head != dev->ring_tail)
-		mask |= POLLIN | POLLRDNORM;
-	if (!dev->interrupt_out_busy)
-		mask |= POLLOUT | POLLWRNORM;
-
-	return mask;
-}
-
-/** usb_alphatrack_read */
-static ssize_t usb_alphatrack_read(struct file *file, char __user *buffer,
-				   size_t count, loff_t *ppos)
-{
-	struct usb_alphatrack *dev;
-	int retval = 0;
-
-	int c = 0;
-
-	dev = file->private_data;
-
-	/* verify that we actually have some data to read */
-	if (count == 0)
-		goto exit;
-
-	/* lock this object */
-	if (mutex_lock_interruptible(&dev->mtx)) {
-		retval = -ERESTARTSYS;
-		goto exit;
-	}
-
-	/* verify that the device wasn't unplugged */
-	if (dev->intf == NULL) {
-		retval = -ENODEV;
-		pr_err("%s: No device or device unplugged %d\n",
-		       __func__, retval);
-		goto unlock_exit;
-	}
-
-	while (dev->ring_head == dev->ring_tail) {
-		if (file->f_flags & O_NONBLOCK) {
-			retval = -EAGAIN;
-			goto unlock_exit;
-		}
-		dev->interrupt_in_done = 0;
-		retval =
-		    wait_event_interruptible(dev->read_wait,
-					     dev->interrupt_in_done);
-		if (retval < 0)
-			goto unlock_exit;
-	}
-
-	alphatrack_ocmd_info(&dev->intf->dev,
-			     &(*dev->ring_buffer)[dev->ring_tail].cmd, "%s",
-			     ": copying to userspace");
-
-	c = 0;
-	while ((c < count) && (dev->ring_tail != dev->ring_head)) {
-		if (copy_to_user
-		    (&buffer[c], &(*dev->ring_buffer)[dev->ring_tail],
-		     INPUT_CMD_SIZE)) {
-			retval = -EFAULT;
-			goto unlock_exit;
-		}
-		dev->ring_tail = (dev->ring_tail + 1) % ring_buffer_size;
-		c += INPUT_CMD_SIZE;
-		dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n",
-			 __func__, dev->ring_head, dev->ring_tail);
-	}
-	retval = c;
-
-unlock_exit:
-	/* unlock the device */
-	mutex_unlock(&dev->mtx);
-
-exit:
-	return retval;
-}
-
-/** usb_alphatrack_write */
-static ssize_t usb_alphatrack_write(struct file *file,
-				    const char __user *buffer, size_t count,
-				    loff_t *ppos)
-{
-	struct usb_alphatrack *dev;
-	size_t bytes_to_write;
-	int retval = 0;
-
-	dev = file->private_data;
-
-	/* verify that we actually have some data to write */
-	if (count == 0)
-		goto exit;
-
-	/* lock this object */
-	if (mutex_lock_interruptible(&dev->mtx)) {
-		retval = -ERESTARTSYS;
-		goto exit;
-	}
-
-	/* verify that the device wasn't unplugged */
-	if (dev->intf == NULL) {
-		retval = -ENODEV;
-		pr_err("%s: No device or device unplugged %d\n",
-		       __func__, retval);
-		goto unlock_exit;
-	}
-
-	/* wait until previous transfer is finished */
-	if (dev->interrupt_out_busy) {
-		if (file->f_flags & O_NONBLOCK) {
-			retval = -EAGAIN;
-			goto unlock_exit;
-		}
-		retval =
-		    wait_event_interruptible(dev->write_wait,
-					     !dev->interrupt_out_busy);
-		if (retval < 0)
-			goto unlock_exit;
-	}
-
-	/* write the data into interrupt_out_buffer from userspace */
-	/* FIXME - if you write more than 12 bytes this breaks */
-	bytes_to_write =
-	    min(count, write_buffer_size * dev->interrupt_out_endpoint_size);
-	if (bytes_to_write < count)
-		dev_warn(&dev->intf->dev,
-			 "Write buffer overflow, %zd bytes dropped\n",
-			 count - bytes_to_write);
-
-	dbg_info(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n",
-		 __func__, count, bytes_to_write);
-
-	if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) {
-		retval = -EFAULT;
-		goto unlock_exit;
-	}
-
-	if (dev->interrupt_out_endpoint == NULL) {
-		dev_err(&dev->intf->dev, "Endpoint should not be null!\n");
-		goto unlock_exit;
-	}
-
-	/* send off the urb */
-	usb_fill_int_urb(dev->interrupt_out_urb,
-			 interface_to_usbdev(dev->intf),
-			 usb_sndintpipe(interface_to_usbdev(dev->intf),
-					dev->interrupt_out_endpoint->
-					bEndpointAddress),
-			 dev->interrupt_out_buffer, bytes_to_write,
-			 usb_alphatrack_interrupt_out_callback, dev,
-			 dev->interrupt_out_interval);
-	dev->interrupt_out_busy = 1;
-	atomic_inc(&dev->writes_pending);
-	wmb();
-
-	retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL);
-	if (retval) {
-		dev->interrupt_out_busy = 0;
-		dev_err(&dev->intf->dev,
-			"Couldn't submit interrupt_out_urb %d\n", retval);
-		atomic_dec(&dev->writes_pending);
-		goto unlock_exit;
-	}
-	retval = bytes_to_write;
-
-unlock_exit:
-	/* unlock the device */
-	mutex_unlock(&dev->mtx);
-
-exit:
-	return retval;
-}
-
-/* file operations needed when we register this driver */
-static const struct file_operations usb_alphatrack_fops = {
-	.owner = THIS_MODULE,
-	.read = usb_alphatrack_read,
-	.write = usb_alphatrack_write,
-	.open = usb_alphatrack_open,
-	.release = usb_alphatrack_release,
-	.poll = usb_alphatrack_poll,
-	.llseek = no_llseek,
-};
-
-/*
- * usb class driver info in order to get a minor number from the usb core,
- * and to have the device registered with the driver core
- */
-
-static struct usb_class_driver usb_alphatrack_class = {
-	.name = "alphatrack%d",
-	.fops = &usb_alphatrack_fops,
-	.minor_base = USB_ALPHATRACK_MINOR_BASE,
-};
-
-/**
- *	usb_alphatrack_probe
- *
- *	Called by the usb core when a new device is connected that it thinks
- *	this driver might be interested in.
- */
-static int usb_alphatrack_probe(struct usb_interface *intf,
-				const struct usb_device_id *id)
-{
-	struct usb_device *udev = interface_to_usbdev(intf);
-	struct usb_alphatrack *dev = NULL;
-	struct usb_host_interface *iface_desc;
-	struct usb_endpoint_descriptor *endpoint;
-	int i;
-	int true_size;
-	int retval = -ENOMEM;
-
-	/* allocate memory for our device state and initialize it */
-
-	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (dev == NULL)
-		goto exit;
-
-	mutex_init(&dev->mtx);
-	dev->intf = intf;
-	init_waitqueue_head(&dev->read_wait);
-	init_waitqueue_head(&dev->write_wait);
-
-	iface_desc = intf->cur_altsetting;
-
-	/* set up the endpoint information */
-	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
-		endpoint = &iface_desc->endpoint[i].desc;
-
-		if (usb_endpoint_is_int_in(endpoint))
-			dev->interrupt_in_endpoint = endpoint;
-
-		if (usb_endpoint_is_int_out(endpoint))
-			dev->interrupt_out_endpoint = endpoint;
-	}
-	if (dev->interrupt_in_endpoint == NULL) {
-		dev_err(&intf->dev, "Interrupt in endpoint not found\n");
-		goto error;
-	}
-	if (dev->interrupt_out_endpoint == NULL)
-		dev_warn(&intf->dev,
-			 "Interrupt out endpoint not found (using control endpoint instead)\n");
-
-	dev->interrupt_in_endpoint_size =
-	    le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize);
-
-	if (dev->interrupt_in_endpoint_size != 64)
-		dev_warn(&intf->dev, "Interrupt in endpoint size is not 64!\n");
-
-	if (ring_buffer_size == 0)
-		ring_buffer_size = RING_BUFFER_SIZE;
-
-	true_size = min(ring_buffer_size, RING_BUFFER_SIZE);
-
-	/*
-	 * FIXME - there are more usb_alloc routines for dma correctness.
-	 * Needed?
-	 */
-	dev->ring_buffer = kmalloc_array(true_size,
-					 sizeof(struct alphatrack_icmd),
-					 GFP_KERNEL);
-	if (!dev->ring_buffer)
-		goto error;
-
-	dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size,
-					   GFP_KERNEL);
-	if (!dev->interrupt_in_buffer)
-		goto error;
-
-	dev->oldi_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL);
-	if (!dev->oldi_buffer)
-		goto error;
-
-	dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
-	if (!dev->interrupt_in_urb) {
-		dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n");
-		goto error;
-	}
-
-	dev->interrupt_out_endpoint_size =
-	    dev->interrupt_out_endpoint ? le16_to_cpu(dev->
-						      interrupt_out_endpoint->
-						      wMaxPacketSize) : udev->
-	    descriptor.bMaxPacketSize0;
-
-	if (dev->interrupt_out_endpoint_size != 64)
-		dev_warn(&intf->dev,
-			 "Interrupt out endpoint size is not 64!)\n");
-
-	if (write_buffer_size == 0)
-		write_buffer_size = WRITE_BUFFER_SIZE;
-	true_size = min(write_buffer_size, WRITE_BUFFER_SIZE);
-
-	dev->interrupt_out_buffer =
-		kmalloc_array(true_size,
-			      dev->interrupt_out_endpoint_size,
-			      GFP_KERNEL);
-	if (!dev->interrupt_out_buffer)
-		goto error;
-
-	dev->write_buffer = kmalloc_array(true_size,
-					  sizeof(struct alphatrack_ocmd),
-					  GFP_KERNEL);
-	if (!dev->write_buffer)
-		goto error;
-
-	dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
-	if (!dev->interrupt_out_urb) {
-		dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb\n");
-		goto error;
-	}
-	dev->interrupt_in_interval =
-	    min_interrupt_in_interval >
-	    dev->interrupt_in_endpoint->
-	    bInterval ? min_interrupt_in_interval : dev->interrupt_in_endpoint->
-	    bInterval;
-	if (dev->interrupt_out_endpoint)
-		dev->interrupt_out_interval =
-		    min_interrupt_out_interval >
-		    dev->interrupt_out_endpoint->
-		    bInterval ? min_interrupt_out_interval : dev->
-		    interrupt_out_endpoint->bInterval;
-
-	/* we can register the device now, as it is ready */
-	usb_set_intfdata(intf, dev);
-
-	atomic_set(&dev->writes_pending, 0);
-	retval = usb_register_dev(intf, &usb_alphatrack_class);
-	if (retval) {
-		/* something prevented us from registering this driver */
-		dev_err(&intf->dev,
-			"Not able to get a minor for this device.\n");
-		usb_set_intfdata(intf, NULL);
-		goto error;
-	}
-
-	/* let the user know what node this device is now attached to */
-	dev_info(&intf->dev,
-		 "Alphatrack Device #%d now attached to major %d minor %d\n",
-		 (intf->minor - USB_ALPHATRACK_MINOR_BASE), USB_MAJOR,
-		 intf->minor);
-
-exit:
-	return retval;
-
-error:
-	usb_alphatrack_delete(dev);
-
-	return retval;
-}
-
-/**
- *	usb_alphatrack_disconnect
- *
- *	Called by the usb core when the device is removed from the system.
- */
-static void usb_alphatrack_disconnect(struct usb_interface *intf)
-{
-	struct usb_alphatrack *dev;
-	int minor;
-
-	mutex_lock(&disconnect_mutex);
-
-	dev = usb_get_intfdata(intf);
-	usb_set_intfdata(intf, NULL);
-
-	mutex_lock(&dev->mtx);
-
-	minor = intf->minor;
-
-	/* give back our minor */
-	usb_deregister_dev(intf, &usb_alphatrack_class);
-
-	/* if the device is not opened, then we clean up right now */
-	if (!dev->open_count) {
-		mutex_unlock(&dev->mtx);
-		usb_alphatrack_delete(dev);
-	} else {
-		atomic_set(&dev->writes_pending, 0);
-		dev->intf = NULL;
-		mutex_unlock(&dev->mtx);
-	}
-
-	mutex_unlock(&disconnect_mutex);
-
-	dev_info(&intf->dev, "Alphatrack Surface #%d now disconnected\n",
-		 (minor - USB_ALPHATRACK_MINOR_BASE));
-}
-
-/* usb specific object needed to register this driver with the usb subsystem */
-static struct usb_driver usb_alphatrack_driver = {
-	.name = "alphatrack",
-	.probe = usb_alphatrack_probe,
-	.disconnect = usb_alphatrack_disconnect,
-	.id_table = usb_alphatrack_table,
-};
-
-module_usb_driver(usb_alphatrack_driver);
diff --git a/drivers/staging/frontier/alphatrack.h b/drivers/staging/frontier/alphatrack.h
deleted file mode 100644
index 418c605..0000000
--- a/drivers/staging/frontier/alphatrack.h
+++ /dev/null
@@ -1,78 +0,0 @@
-struct alphatrack_icmd {
-	unsigned char cmd[12];
-};
-
-struct alphatrack_ocmd {
-	unsigned char cmd[8];
-};
-
-/*
- * These are unused by the present driver but provide documentation for the
- * userspace API.
- */
-enum LightID {
-	LIGHT_EQ = 0,
-	LIGHT_OUT,
-	LIGHT_F2,
-	LIGHT_SEND,
-	LIGHT_IN,
-	LIGHT_F1,
-	LIGHT_PAN,
-	LIGHT_UNDEF1,
-	LIGHT_UNDEF2,
-	LIGHT_SHIFT,
-	LIGHT_TRACKMUTE,
-	LIGHT_TRACKSOLO,
-	LIGHT_TRACKREC,
-	LIGHT_READ,
-	LIGHT_WRITE,
-	LIGHT_ANYSOLO,
-	LIGHT_AUTO,
-	LIGHT_F4,
-	LIGHT_RECORD,
-	LIGHT_WINDOW,
-	LIGHT_PLUGIN,
-	LIGHT_F3,
-	LIGHT_LOOP
-};
-
-#define BUTTONMASK_BATTERY     0x00004000
-#define BUTTONMASK_BACKLIGHT   0x00008000
-#define BUTTONMASK_FASTFORWARD 0x04000000
-#define BUTTONMASK_TRACKMUTE   0x00040000
-#define BUTTONMASK_TRACKSOLO   0x00800000
-#define BUTTONMASK_TRACKLEFT   0x80000000
-#define BUTTONMASK_RECORD      0x02000000
-#define BUTTONMASK_SHIFT       0x20000000
-#define BUTTONMASK_PUNCH       0x00800000
-#define BUTTONMASK_TRACKRIGHT  0x00020000
-#define BUTTONMASK_REWIND      0x01000000
-#define BUTTONMASK_STOP        0x10000000
-#define BUTTONMASK_LOOP        0x00010000
-#define BUTTONMASK_TRACKREC    0x00001000
-#define BUTTONMASK_PLAY        0x08000000
-#define BUTTONMASK_TOUCH1      0x00000008
-#define BUTTONMASK_TOUCH2      0x00000010
-#define BUTTONMASK_TOUCH3      0x00000020
-
-#define BUTTONMASK_PRESS1      0x00000009
-#define BUTTONMASK_PRESS2      0x00008010
-#define BUTTONMASK_PRESS3      0x00002020
-
-/*
- * last 3 bytes are the slider position
- * 40 is the actual slider moving, the most sig bits, and 3 lsb
- */
-
-#define BUTTONMASK_FLIP         0x40000000
-#define BUTTONMASK_F1           0x00100000
-#define BUTTONMASK_F2           0x00400000
-#define BUTTONMASK_F3           0x00200000
-#define BUTTONMASK_F4           0x00080000
-#define BUTTONMASK_PAN          0x00000200
-#define BUTTONMASK_SEND         0x00000800
-#define BUTTONMASK_EQ           0x00004000
-#define BUTTONMASK_PLUGIN       0x00000400
-#define BUTTONMASK_AUTO         0x00000100
-
-/* #define BUTTONMASK_FOOTSWITCH FIXME */
diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c
deleted file mode 100644
index 2f86163..0000000
--- a/drivers/staging/frontier/tranzport.c
+++ /dev/null
@@ -1,973 +0,0 @@
-/*
- * Frontier Designs Tranzport driver
- *
- * Copyright (C) 2007 Michael Taht (m@taht.net)
- *
- * Based on the usbled driver and ldusb drivers by
- *
- * Copyright (C) 2004 Greg Kroah-Hartman (greg@kroah.com)
- * Copyright (C) 2005 Michael Hund <mhund@ld-didactic.de>
- *
- * The ldusb driver was, in turn, derived from Lego USB Tower driver
- * Copyright (C) 2003 David Glance <advidgsf@sourceforge.net>
- *		 2001-2004 Juergen Stuber <starblue@users.sourceforge.net>
- *
- *	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, version 2.
- *
- */
-
-/*
- * This driver uses a ring buffer for time critical reading of
- * interrupt in reports and provides read and write methods for
- * raw interrupt reports.
- */
-
-/* Note: this currently uses a dumb ringbuffer for reads and writes.
- * A more optimal driver would cache and kill off outstanding urbs that are
- * now invalid, and ignore ones that already were in the queue but valid
- * as we only have 17 commands for the tranzport. In particular this is
- * key for getting lights to flash in time as otherwise many commands
- * can be buffered up before the light change makes it to the interface.
- */
-
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-
-#include <linux/uaccess.h>
-#include <linux/input.h>
-#include <linux/usb.h>
-#include <linux/poll.h>
-
-/* Define these values to match your devices */
-#define VENDOR_ID   0x165b
-#define PRODUCT_ID  0x8101
-
-#ifdef CONFIG_USB_DYNAMIC_MINORS
-#define USB_TRANZPORT_MINOR_BASE	0
-#else  /* FIXME 177- is the another driver's minor - apply for a minor soon */
-#define USB_TRANZPORT_MINOR_BASE	177
-#endif
-
-/* table of devices that work with this driver */
-static const struct usb_device_id usb_tranzport_table[] = {
-	{USB_DEVICE(VENDOR_ID, PRODUCT_ID)},
-	{}			/* Terminating entry */
-};
-
-MODULE_DEVICE_TABLE(usb, usb_tranzport_table);
-MODULE_VERSION("0.35");
-MODULE_AUTHOR("Mike Taht <m@taht.net>");
-MODULE_DESCRIPTION("Tranzport USB Driver");
-MODULE_LICENSE("GPL");
-MODULE_SUPPORTED_DEVICE("Frontier Designs Tranzport Control Surface");
-
-#define SUPPRESS_EXTRA_OFFLINE_EVENTS 1
-#define COMPRESS_WHEEL_EVENTS 1
-#define BUFFERED_READS 1
-#define RING_BUFFER_SIZE 1000
-#define WRITE_BUFFER_SIZE 34
-#define TRANZPORT_USB_TIMEOUT 10
-#define TRANZPORT_DEBUG 0
-
-static int debug = TRANZPORT_DEBUG;
-
-/* Use our own dbg macro */
-#define dbg_info(dev, format, arg...) do			\
-	{ if (debug) dev_info(dev , format , ## arg); } while (0)
-
-/* Module parameters */
-
-module_param(debug, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(debug, "Debug enabled or not");
-
-/*
- * All interrupt in transfers are collected in a ring buffer to
- * avoid racing conditions and get better performance of the driver.
- */
-
-static int ring_buffer_size = RING_BUFFER_SIZE;
-
-module_param(ring_buffer_size, int, S_IRUGO);
-MODULE_PARM_DESC(ring_buffer_size, "Read ring buffer size in reports");
-
-/*
- * The write_buffer can one day contain more than one interrupt out transfer.
- */
-static int write_buffer_size = WRITE_BUFFER_SIZE;
-module_param(write_buffer_size, int, S_IRUGO);
-MODULE_PARM_DESC(write_buffer_size, "Write buffer size");
-
-/*
- * Increase the interval for debugging purposes.
- * or set to 1 to use the standard interval from the endpoint descriptors.
- */
-
-static int min_interrupt_in_interval = TRANZPORT_USB_TIMEOUT;
-module_param(min_interrupt_in_interval, int, 0);
-MODULE_PARM_DESC(min_interrupt_in_interval,
-		"Minimum interrupt in interval in ms");
-
-static int min_interrupt_out_interval = TRANZPORT_USB_TIMEOUT;
-module_param(min_interrupt_out_interval, int, 0);
-MODULE_PARM_DESC(min_interrupt_out_interval,
-		"Minimum interrupt out interval in ms");
-
-struct tranzport_cmd {
-	unsigned char cmd[8];
-};
-
-/* Structure to hold all of our device specific stuff */
-
-struct usb_tranzport {
-	struct mutex mtx;	/* locks this structure */
-	struct usb_interface *intf;	/* save off the usb interface pointer */
-	int open_count;		/* number of times this port opened */
-	struct tranzport_cmd (*ring_buffer)[RING_BUFFER_SIZE];
-	unsigned int ring_head;
-	unsigned int ring_tail;
-	wait_queue_head_t read_wait;
-	wait_queue_head_t write_wait;
-	unsigned char *interrupt_in_buffer;
-	struct usb_endpoint_descriptor *interrupt_in_endpoint;
-	struct urb *interrupt_in_urb;
-	int interrupt_in_interval;
-	size_t interrupt_in_endpoint_size;
-	int interrupt_in_running;
-	int interrupt_in_done;
-	char *interrupt_out_buffer;
-	struct usb_endpoint_descriptor *interrupt_out_endpoint;
-	struct urb *interrupt_out_urb;
-	int interrupt_out_interval;
-	size_t interrupt_out_endpoint_size;
-	int interrupt_out_busy;
-
-	/* Sysfs support */
-
-	unsigned char enable;	/* 0 if disabled 1 if enabled */
-	unsigned char offline;	/* if the device is out of range or asleep */
-	unsigned char compress_wheel;	/* flag to compress wheel events */
-};
-
-/* prevent races between open() and disconnect() */
-static DEFINE_MUTEX(disconnect_mutex);
-
-static struct usb_driver usb_tranzport_driver;
-
-/**
- *	usb_tranzport_abort_transfers
- *      aborts transfers and frees associated data structures
- */
-static void usb_tranzport_abort_transfers(struct usb_tranzport *dev)
-{
-	/* shutdown transfer */
-	if (dev->interrupt_in_running) {
-		dev->interrupt_in_running = 0;
-		if (dev->intf)
-			usb_kill_urb(dev->interrupt_in_urb);
-	}
-	if (dev->interrupt_out_busy)
-		if (dev->intf)
-			usb_kill_urb(dev->interrupt_out_urb);
-}
-
-#define show_int(value)	\
-	static ssize_t value##_show(struct device *dev,	\
-			      struct device_attribute *attr, char *buf)	\
-	{	\
-		struct usb_interface *intf = to_usb_interface(dev);	\
-		struct usb_tranzport *t = usb_get_intfdata(intf);	\
-		return sprintf(buf, "%d\n", t->value);	\
-	}	\
-	static DEVICE_ATTR_RO(value)
-
-#define show_set_int(value)	\
-	static ssize_t value##_show(struct device *dev,	\
-			      struct device_attribute *attr, char *buf)	\
-	{	\
-		struct usb_interface *intf = to_usb_interface(dev);	\
-		struct usb_tranzport *t = usb_get_intfdata(intf);	\
-		return sprintf(buf, "%d\n", t->value);	\
-	}	\
-	static ssize_t value##_store(struct device *dev,	\
-			     struct device_attribute *attr,		\
-			     const char *buf, size_t count)		\
-	{	\
-		struct usb_interface *intf = to_usb_interface(dev);	\
-		struct usb_tranzport *t = usb_get_intfdata(intf);	\
-		unsigned long temp;	\
-		if (kstrtoul(buf, 10, &temp))	\
-			return -EINVAL;	\
-		t->value = temp;	\
-		return count;	\
-	}	\
-	static DEVICE_ATTR_RW(value)
-
-show_int(enable);
-show_int(offline);
-show_set_int(compress_wheel);
-
-/**
- *	usb_tranzport_delete
- */
-static void usb_tranzport_delete(struct usb_tranzport *dev)
-{
-	usb_tranzport_abort_transfers(dev);
-	if (dev->intf != NULL) {
-		device_remove_file(&dev->intf->dev, &dev_attr_enable);
-		device_remove_file(&dev->intf->dev, &dev_attr_offline);
-		device_remove_file(&dev->intf->dev, &dev_attr_compress_wheel);
-	}
-
-	/* free data structures */
-	usb_free_urb(dev->interrupt_in_urb);
-	usb_free_urb(dev->interrupt_out_urb);
-	kfree(dev->ring_buffer);
-	kfree(dev->interrupt_in_buffer);
-	kfree(dev->interrupt_out_buffer);
-	kfree(dev);
-}
-
-/**
- *	usb_tranzport_interrupt_in_callback
- */
-
-static void usb_tranzport_interrupt_in_callback(struct urb *urb)
-{
-	struct usb_tranzport *dev = urb->context;
-	unsigned int next_ring_head;
-	int retval = -1;
-
-	if (urb->status) {
-		if (urb->status == -ENOENT ||
-			urb->status == -ECONNRESET ||
-			urb->status == -ESHUTDOWN) {
-			goto exit;
-		} else {
-			dbg_info(&dev->intf->dev,
-				 "%s: nonzero status received: %d\n",
-				 __func__, urb->status);
-			goto resubmit;	/* maybe we can recover */
-		}
-	}
-
-	if (urb->actual_length != 8) {
-		dev_warn(&dev->intf->dev,
-			"Urb length was %d bytes!! Do something intelligent\n",
-			 urb->actual_length);
-	} else {
-		dbg_info(&dev->intf->dev,
-			 "%s: received: %02x%02x%02x%02x%02x%02x%02x%02x\n",
-			 __func__, dev->interrupt_in_buffer[0],
-			 dev->interrupt_in_buffer[1],
-			 dev->interrupt_in_buffer[2],
-			 dev->interrupt_in_buffer[3],
-			 dev->interrupt_in_buffer[4],
-			 dev->interrupt_in_buffer[5],
-			 dev->interrupt_in_buffer[6],
-			 dev->interrupt_in_buffer[7]);
-#if SUPPRESS_EXTRA_OFFLINE_EVENTS
-		if (dev->offline == 2 && dev->interrupt_in_buffer[1] == 0xff)
-			goto resubmit;
-		if (dev->offline == 1 && dev->interrupt_in_buffer[1] == 0xff) {
-			dev->offline = 2;
-			goto resubmit;
-		}
-
-		/* Always pass one offline event up the stack */
-		if (dev->offline > 0 && dev->interrupt_in_buffer[1] != 0xff)
-			dev->offline = 0;
-		if (dev->offline == 0 && dev->interrupt_in_buffer[1] == 0xff)
-			dev->offline = 1;
-
-#endif	/* SUPPRESS_EXTRA_OFFLINE_EVENTS */
-		dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n",
-			 __func__, dev->ring_head, dev->ring_tail);
-
-		next_ring_head = (dev->ring_head + 1) % ring_buffer_size;
-
-		if (next_ring_head != dev->ring_tail) {
-			memcpy(&((*dev->ring_buffer)[dev->ring_head]),
-			       dev->interrupt_in_buffer, urb->actual_length);
-			dev->ring_head = next_ring_head;
-			retval = 0;
-			memset(dev->interrupt_in_buffer, 0, urb->actual_length);
-		} else {
-			dev_warn(&dev->intf->dev,
-				 "Ring buffer overflow, %d bytes dropped\n",
-				 urb->actual_length);
-			memset(dev->interrupt_in_buffer, 0, urb->actual_length);
-		}
-	}
-
-resubmit:
-/* resubmit if we're still running */
-	if (dev->interrupt_in_running && dev->intf) {
-		retval = usb_submit_urb(dev->interrupt_in_urb, GFP_ATOMIC);
-		if (retval)
-			dev_err(&dev->intf->dev,
-				"usb_submit_urb failed (%d)\n", retval);
-	}
-
-exit:
-	dev->interrupt_in_done = 1;
-	wake_up_interruptible(&dev->read_wait);
-}
-
-/**
- *	usb_tranzport_interrupt_out_callback
- */
-static void usb_tranzport_interrupt_out_callback(struct urb *urb)
-{
-	struct usb_tranzport *dev = urb->context;
-	/* sync/async unlink faults aren't errors */
-	if (urb->status && !(urb->status == -ENOENT ||
-				urb->status == -ECONNRESET ||
-				urb->status == -ESHUTDOWN))
-		dbg_info(&dev->intf->dev,
-			"%s - nonzero write interrupt status received: %d\n",
-			__func__, urb->status);
-
-	dev->interrupt_out_busy = 0;
-	wake_up_interruptible(&dev->write_wait);
-}
-/**
- *	usb_tranzport_open
- */
-static int usb_tranzport_open(struct inode *inode, struct file *file)
-{
-	struct usb_tranzport *dev;
-	int subminor;
-	int retval = 0;
-	struct usb_interface *interface;
-
-	nonseekable_open(inode, file);
-	subminor = iminor(inode);
-
-	mutex_lock(&disconnect_mutex);
-
-	interface = usb_find_interface(&usb_tranzport_driver, subminor);
-
-	if (!interface) {
-		pr_err("%s - error, can't find device for minor %d\n",
-		       __func__, subminor);
-		retval = -ENODEV;
-		goto unlock_disconnect_exit;
-	}
-
-	dev = usb_get_intfdata(interface);
-
-	if (!dev) {
-		retval = -ENODEV;
-		goto unlock_disconnect_exit;
-	}
-
-	/* lock this device */
-	if (mutex_lock_interruptible(&dev->mtx)) {
-		retval = -ERESTARTSYS;
-		goto unlock_disconnect_exit;
-	}
-
-	/* allow opening only once */
-	if (dev->open_count) {
-		retval = -EBUSY;
-		goto unlock_exit;
-	}
-	dev->open_count = 1;
-
-	/* initialize in direction */
-	dev->ring_head = 0;
-	dev->ring_tail = 0;
-	usb_fill_int_urb(dev->interrupt_in_urb,
-			interface_to_usbdev(interface),
-			usb_rcvintpipe(interface_to_usbdev(interface),
-				dev->interrupt_in_endpoint->
-				bEndpointAddress),
-			dev->interrupt_in_buffer,
-			dev->interrupt_in_endpoint_size,
-			usb_tranzport_interrupt_in_callback, dev,
-			dev->interrupt_in_interval);
-
-	dev->interrupt_in_running = 1;
-	dev->interrupt_in_done = 0;
-	dev->enable = 1;
-	dev->offline = 0;
-	dev->compress_wheel = 1;
-
-	retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
-	if (retval) {
-		dev_err(&interface->dev,
-			"Couldn't submit interrupt_in_urb %d\n", retval);
-		dev->interrupt_in_running = 0;
-		dev->open_count = 0;
-		goto unlock_exit;
-	}
-
-	/* save device in the file's private structure */
-	file->private_data = dev;
-
-unlock_exit:
-	mutex_unlock(&dev->mtx);
-
-unlock_disconnect_exit:
-	mutex_unlock(&disconnect_mutex);
-
-	return retval;
-}
-
-/**
- *	usb_tranzport_release
- */
-static int usb_tranzport_release(struct inode *inode, struct file *file)
-{
-	struct usb_tranzport *dev;
-	int retval = 0;
-
-	dev = file->private_data;
-
-	if (dev == NULL) {
-		retval = -ENODEV;
-		goto exit;
-	}
-
-	if (mutex_lock_interruptible(&dev->mtx)) {
-		retval = -ERESTARTSYS;
-		goto exit;
-	}
-
-	if (dev->open_count != 1) {
-		retval = -ENODEV;
-		goto unlock_exit;
-	}
-
-	if (dev->intf == NULL) {
-		/* the device was unplugged before the file was released */
-		mutex_unlock(&dev->mtx);
-		/* unlock here as usb_tranzport_delete frees dev */
-		usb_tranzport_delete(dev);
-		retval = -ENODEV;
-		goto exit;
-	}
-
-	/* wait until write transfer is finished */
-	if (dev->interrupt_out_busy)
-		wait_event_interruptible_timeout(dev->write_wait,
-						!dev->interrupt_out_busy,
-						2 * HZ);
-	usb_tranzport_abort_transfers(dev);
-	dev->open_count = 0;
-
-unlock_exit:
-	mutex_unlock(&dev->mtx);
-
-exit:
-	return retval;
-}
-
-/**
- *	usb_tranzport_poll
- */
-static unsigned int usb_tranzport_poll(struct file *file, poll_table *wait)
-{
-	struct usb_tranzport *dev;
-	unsigned int mask = 0;
-
-	dev = file->private_data;
-	poll_wait(file, &dev->read_wait, wait);
-	poll_wait(file, &dev->write_wait, wait);
-	if (dev->ring_head != dev->ring_tail)
-		mask |= POLLIN | POLLRDNORM;
-	if (!dev->interrupt_out_busy)
-		mask |= POLLOUT | POLLWRNORM;
-	return mask;
-}
-/**
- *	usb_tranzport_read
- */
-
-static ssize_t usb_tranzport_read(struct file *file, char __user *buffer,
-				size_t count, loff_t *ppos)
-{
-	struct usb_tranzport *dev;
-	int retval = 0;
-#if BUFFERED_READS
-	int c = 0;
-#endif
-#if COMPRESS_WHEEL_EVENTS
-	signed char oldwheel;
-	signed char newwheel;
-	int cancompress = 1;
-	int next_tail;
-#endif
-
-	/* do I have such a thing as a null event? */
-
-	dev = file->private_data;
-
-	/* verify that we actually have some data to read */
-	if (count == 0)
-		goto exit;
-
-	/* lock this object */
-	if (mutex_lock_interruptible(&dev->mtx)) {
-		retval = -ERESTARTSYS;
-		goto exit;
-	}
-
-	/* verify that the device wasn't unplugged */
-	if (dev->intf == NULL) {
-		retval = -ENODEV;
-		pr_err("%s: No device or device unplugged %d\n",
-		       __func__, retval);
-		goto unlock_exit;
-	}
-
-	while (dev->ring_head == dev->ring_tail) {
-
-		if (file->f_flags & O_NONBLOCK) {
-			retval = -EAGAIN;
-			goto unlock_exit;
-		}
-		/* tiny race - FIXME: make atomic? */
-		/* atomic_cmp_exchange(&dev->interrupt_in_done,0,0); */
-		dev->interrupt_in_done = 0;
-		retval = wait_event_interruptible(dev->read_wait,
-						  dev->interrupt_in_done);
-		if (retval < 0)
-			goto unlock_exit;
-	}
-
-	dbg_info(&dev->intf->dev,
-		"%s: copying to userspace: %02x%02x%02x%02x%02x%02x%02x%02x\n",
-		 __func__,
-		 (*dev->ring_buffer)[dev->ring_tail].cmd[0],
-		 (*dev->ring_buffer)[dev->ring_tail].cmd[1],
-		 (*dev->ring_buffer)[dev->ring_tail].cmd[2],
-		 (*dev->ring_buffer)[dev->ring_tail].cmd[3],
-		 (*dev->ring_buffer)[dev->ring_tail].cmd[4],
-		 (*dev->ring_buffer)[dev->ring_tail].cmd[5],
-		 (*dev->ring_buffer)[dev->ring_tail].cmd[6],
-		 (*dev->ring_buffer)[dev->ring_tail].cmd[7]);
-
-#if BUFFERED_READS
-	c = 0;
-	while ((c < count) && (dev->ring_tail != dev->ring_head)) {
-
-#if COMPRESS_WHEEL_EVENTS
-		next_tail = (dev->ring_tail+1) % ring_buffer_size;
-		if (dev->compress_wheel)
-			cancompress = 1;
-		while (dev->ring_head != next_tail && cancompress == 1) {
-			newwheel = (*dev->ring_buffer)[next_tail].cmd[6];
-			oldwheel = (*dev->ring_buffer)[dev->ring_tail].cmd[6];
-			/* if both are wheel events, and
-			 * no buttons have changes (FIXME, do I have to check?),
-			 * and we are the same sign, we can compress +- 7F
-			 */
-			dbg_info(&dev->intf->dev,
-				"%s: trying to compress: %02x%02x%02x%02x%02x%02x%02x%02x\n",
-				__func__,
-				(*dev->ring_buffer)[dev->ring_tail].cmd[0],
-				(*dev->ring_buffer)[dev->ring_tail].cmd[1],
-				(*dev->ring_buffer)[dev->ring_tail].cmd[2],
-				(*dev->ring_buffer)[dev->ring_tail].cmd[3],
-				(*dev->ring_buffer)[dev->ring_tail].cmd[4],
-				(*dev->ring_buffer)[dev->ring_tail].cmd[5],
-				(*dev->ring_buffer)[dev->ring_tail].cmd[6],
-				(*dev->ring_buffer)[dev->ring_tail].cmd[7]);
-
-			if (((*dev->ring_buffer)[dev->ring_tail].cmd[6] != 0 &&
-				(*dev->ring_buffer)[next_tail].cmd[6] != 0) &&
-				((newwheel > 0 && oldwheel > 0) ||
-					(newwheel < 0 && oldwheel < 0)) &&
-				((*dev->ring_buffer)[dev->ring_tail].cmd[2] ==
-				(*dev->ring_buffer)[next_tail].cmd[2]) &&
-				((*dev->ring_buffer)[dev->ring_tail].cmd[3] ==
-				(*dev->ring_buffer)[next_tail].cmd[3]) &&
-				((*dev->ring_buffer)[dev->ring_tail].cmd[4] ==
-				(*dev->ring_buffer)[next_tail].cmd[4]) &&
-				((*dev->ring_buffer)[dev->ring_tail].cmd[5] ==
-				(*dev->ring_buffer)[next_tail].cmd[5])) {
-				dbg_info(&dev->intf->dev,
-					"%s: should compress: "
-					"%02x%02x%02x%02x%02x%02x%02x%02x\n",
-					__func__,
-					(*dev->ring_buffer)[dev->ring_tail].
-					cmd[0],
-					(*dev->ring_buffer)[dev->ring_tail].
-					cmd[1],
-					(*dev->ring_buffer)[dev->ring_tail].
-					cmd[2],
-					(*dev->ring_buffer)[dev->ring_tail].
-					cmd[3],
-					(*dev->ring_buffer)[dev->ring_tail].
-					cmd[4],
-					(*dev->ring_buffer)[dev->ring_tail].
-					cmd[5],
-					(*dev->ring_buffer)[dev->ring_tail].
-					cmd[6],
-					(*dev->ring_buffer)[dev->ring_tail].
-					cmd[7]);
-				newwheel += oldwheel;
-				if (oldwheel > 0 && !(newwheel > 0)) {
-					newwheel = 0x7f;
-					cancompress = 0;
-				}
-				if (oldwheel < 0 && !(newwheel < 0)) {
-					newwheel = 0x80;
-					cancompress = 0;
-				}
-
-				(*dev->ring_buffer)[next_tail].cmd[6] =
-					newwheel;
-				dev->ring_tail = next_tail;
-				next_tail =
-					(dev->ring_tail + 1) % ring_buffer_size;
-			} else {
-				cancompress = 0;
-			}
-		}
-#endif /* COMPRESS_WHEEL_EVENTS */
-		if (copy_to_user(
-				&buffer[c],
-				&(*dev->ring_buffer)[dev->ring_tail], 8)) {
-			retval = -EFAULT;
-			goto unlock_exit;
-		}
-		dev->ring_tail = (dev->ring_tail + 1) % ring_buffer_size;
-		c += 8;
-		dbg_info(&dev->intf->dev,
-			 "%s: head, tail are %x, %x\n",
-			 __func__, dev->ring_head, dev->ring_tail);
-	}
-	retval = c;
-
-#else
-/*  if (copy_to_user(buffer, &(*dev->ring_buffer)[dev->ring_tail], 8)) { */
-	retval = -EFAULT;
-	goto unlock_exit;
-}
-
-dev->ring_tail = (dev->ring_tail + 1) % ring_buffer_size;
-dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n",
-	 __func__, dev->ring_head, dev->ring_tail);
-
-retval = 8;
-#endif /* BUFFERED_READS */
-
-unlock_exit:
-/* unlock the device */
-mutex_unlock(&dev->mtx);
-
-exit:
-return retval;
-}
-
-/**
- *	usb_tranzport_write
- */
-static ssize_t usb_tranzport_write(struct file *file,
-				const char __user *buffer, size_t count,
-				loff_t *ppos)
-{
-	struct usb_tranzport *dev;
-	size_t bytes_to_write;
-	int retval = 0;
-
-	dev = file->private_data;
-
-	/* verify that we actually have some data to write */
-	if (count == 0)
-		goto exit;
-
-	/* lock this object */
-	if (mutex_lock_interruptible(&dev->mtx)) {
-		retval = -ERESTARTSYS;
-		goto exit;
-	}
-	/* verify that the device wasn't unplugged */
-	if (dev->intf == NULL) {
-		retval = -ENODEV;
-		pr_err("%s: No device or device unplugged %d\n",
-		       __func__, retval);
-		goto unlock_exit;
-	}
-
-	/* wait until previous transfer is finished */
-	if (dev->interrupt_out_busy) {
-		if (file->f_flags & O_NONBLOCK) {
-			retval = -EAGAIN;
-			goto unlock_exit;
-		}
-		retval = wait_event_interruptible(dev->write_wait,
-						!dev->interrupt_out_busy);
-		if (retval < 0)
-			goto unlock_exit;
-	}
-
-	/* write the data into interrupt_out_buffer from userspace */
-	bytes_to_write = min(count,
-			write_buffer_size *
-			dev->interrupt_out_endpoint_size);
-	if (bytes_to_write < count)
-		dev_warn(&dev->intf->dev,
-			"Write buffer overflow, %zd bytes dropped\n",
-			count - bytes_to_write);
-
-	dbg_info(&dev->intf->dev,
-		"%s: count = %zd, bytes_to_write = %zd\n", __func__,
-		count, bytes_to_write);
-
-	if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) {
-		retval = -EFAULT;
-		goto unlock_exit;
-	}
-
-	if (dev->interrupt_out_endpoint == NULL) {
-		dev_err(&dev->intf->dev, "Endpoint should not be null!\n");
-		goto unlock_exit;
-	}
-
-	/* send off the urb */
-	usb_fill_int_urb(dev->interrupt_out_urb,
-			interface_to_usbdev(dev->intf),
-			usb_sndintpipe(interface_to_usbdev(dev->intf),
-				dev->interrupt_out_endpoint->
-				bEndpointAddress),
-			dev->interrupt_out_buffer, bytes_to_write,
-			usb_tranzport_interrupt_out_callback, dev,
-			dev->interrupt_out_interval);
-
-	dev->interrupt_out_busy = 1;
-	wmb();
-
-	retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL);
-	if (retval) {
-		dev->interrupt_out_busy = 0;
-		dev_err(&dev->intf->dev,
-			"Couldn't submit interrupt_out_urb %d\n", retval);
-		goto unlock_exit;
-	}
-	retval = bytes_to_write;
-
-unlock_exit:
-	/* unlock the device */
-	mutex_unlock(&dev->mtx);
-
-exit:
-	return retval;
-}
-
-/* file operations needed when we register this driver */
-static const struct file_operations usb_tranzport_fops = {
-	.owner = THIS_MODULE,
-	.read = usb_tranzport_read,
-	.write = usb_tranzport_write,
-	.open = usb_tranzport_open,
-	.release = usb_tranzport_release,
-	.poll = usb_tranzport_poll,
-	.llseek = no_llseek,
-};
-
-/*
- * usb class driver info in order to get a minor number from the usb core,
- * and to have the device registered with the driver core
- */
-static struct usb_class_driver usb_tranzport_class = {
-	.name = "tranzport%d",
-	.fops = &usb_tranzport_fops,
-	.minor_base = USB_TRANZPORT_MINOR_BASE,
-};
-
-/**
- *	usb_tranzport_probe
- *
- *	Called by the usb core when a new device is connected that it thinks
- *	this driver might be interested in.
- */
-static int usb_tranzport_probe(struct usb_interface *intf,
-			       const struct usb_device_id *id) {
-	struct usb_device *udev = interface_to_usbdev(intf);
-	struct usb_tranzport *dev = NULL;
-	struct usb_host_interface *iface_desc;
-	struct usb_endpoint_descriptor *endpoint;
-	int i;
-	int true_size;
-	int retval = -ENOMEM;
-
-	/* allocate memory for our device state and initialize it */
-
-	 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (dev == NULL)
-		goto exit;
-
-	mutex_init(&dev->mtx);
-	dev->intf = intf;
-	init_waitqueue_head(&dev->read_wait);
-	init_waitqueue_head(&dev->write_wait);
-
-	iface_desc = intf->cur_altsetting;
-
-	/* set up the endpoint information */
-	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
-		endpoint = &iface_desc->endpoint[i].desc;
-
-		if (usb_endpoint_is_int_in(endpoint))
-			dev->interrupt_in_endpoint = endpoint;
-
-		if (usb_endpoint_is_int_out(endpoint))
-			dev->interrupt_out_endpoint = endpoint;
-	}
-	if (dev->interrupt_in_endpoint == NULL) {
-		dev_err(&intf->dev, "Interrupt in endpoint not found\n");
-		goto error;
-	}
-	if (dev->interrupt_out_endpoint == NULL)
-		dev_warn(&intf->dev,
-			"Interrupt out endpoint not found (using control endpoint instead)\n");
-
-	dev->interrupt_in_endpoint_size =
-	    le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize);
-
-	if (dev->interrupt_in_endpoint_size != 8)
-		dev_warn(&intf->dev, "Interrupt in endpoint size is not 8!\n");
-
-	if (ring_buffer_size == 0)
-		ring_buffer_size = RING_BUFFER_SIZE;
-	true_size = min(ring_buffer_size, RING_BUFFER_SIZE);
-
-	/*
-	 * FIXME - there are more usb_alloc routines for dma correctness.
-	 * Needed?
-	 */
-
-	dev->ring_buffer =
-	    kmalloc((true_size * sizeof(struct tranzport_cmd)) + 8, GFP_KERNEL);
-	if (!dev->ring_buffer)
-		goto error;
-
-	dev->interrupt_in_buffer =
-	    kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL);
-	if (!dev->interrupt_in_buffer)
-		goto error;
-
-	dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
-	if (!dev->interrupt_in_urb) {
-		dev_err(&intf->dev, "Couldn't allocate interrupt_in_urb\n");
-		goto error;
-	}
-	dev->interrupt_out_endpoint_size =
-	    dev->interrupt_out_endpoint ?
-	    le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize) :
-	    udev->descriptor.bMaxPacketSize0;
-
-	if (dev->interrupt_out_endpoint_size != 8)
-		dev_warn(&intf->dev,
-			 "Interrupt out endpoint size is not 8!)\n");
-
-	dev->interrupt_out_buffer =
-		kmalloc_array(write_buffer_size,
-			      dev->interrupt_out_endpoint_size, GFP_KERNEL);
-	if (!dev->interrupt_out_buffer)
-		goto error;
-
-	dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
-	if (!dev->interrupt_out_urb) {
-		dev_err(&intf->dev, "Couldn't allocate interrupt_out_urb\n");
-		goto error;
-	}
-	dev->interrupt_in_interval =
-	    min_interrupt_in_interval >
-	    dev->interrupt_in_endpoint->bInterval ? min_interrupt_in_interval
-	    : dev->interrupt_in_endpoint->bInterval;
-
-	if (dev->interrupt_out_endpoint) {
-		dev->interrupt_out_interval =
-		    min_interrupt_out_interval >
-		    dev->interrupt_out_endpoint->bInterval ?
-		    min_interrupt_out_interval :
-		    dev->interrupt_out_endpoint->bInterval;
-	}
-
-	/* we can register the device now, as it is ready */
-	usb_set_intfdata(intf, dev);
-
-	retval = usb_register_dev(intf, &usb_tranzport_class);
-	if (retval) {
-		/* something prevented us from registering this driver */
-		dev_err(&intf->dev,
-			"Not able to get a minor for this device.\n");
-		usb_set_intfdata(intf, NULL);
-		goto error;
-	}
-
-	retval = device_create_file(&intf->dev, &dev_attr_compress_wheel);
-	if (retval)
-		goto error;
-	retval = device_create_file(&intf->dev, &dev_attr_enable);
-	if (retval)
-		goto error;
-	retval = device_create_file(&intf->dev, &dev_attr_offline);
-	if (retval)
-		goto error;
-
-	/* let the user know what node this device is now attached to */
-	dev_info(&intf->dev,
-		"Tranzport Device #%d now attached to major %d minor %d\n",
-		(intf->minor - USB_TRANZPORT_MINOR_BASE), USB_MAJOR,
-		intf->minor);
-
-exit:
-	return retval;
-
-error:
-	usb_tranzport_delete(dev);
-	return retval;
-}
-
-/**
- *	usb_tranzport_disconnect
- *
- *	Called by the usb core when the device is removed from the system.
- */
-static void usb_tranzport_disconnect(struct usb_interface *intf)
-{
-	struct usb_tranzport *dev;
-	int minor;
-
-	mutex_lock(&disconnect_mutex);
-	dev = usb_get_intfdata(intf);
-	usb_set_intfdata(intf, NULL);
-	mutex_lock(&dev->mtx);
-	minor = intf->minor;
-	/* give back our minor */
-	usb_deregister_dev(intf, &usb_tranzport_class);
-
-	/* if the device is not opened, then we clean up right now */
-	if (!dev->open_count) {
-		mutex_unlock(&dev->mtx);
-		usb_tranzport_delete(dev);
-	} else {
-		dev->intf = NULL;
-		mutex_unlock(&dev->mtx);
-	}
-
-	mutex_unlock(&disconnect_mutex);
-
-	dev_info(&intf->dev, "Tranzport Surface #%d now disconnected\n",
-		(minor - USB_TRANZPORT_MINOR_BASE));
-}
-
-/* usb specific object needed to register this driver with the usb subsystem */
-static struct usb_driver usb_tranzport_driver = {
-	.name = "tranzport",
-	.probe = usb_tranzport_probe,
-	.disconnect = usb_tranzport_disconnect,
-	.id_table = usb_tranzport_table,
-};
-
-module_usb_driver(usb_tranzport_driver);
diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
index fe47cd3..001348c 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -111,24 +111,28 @@
 static int gdm_tty_open(struct tty_struct *tty, struct file *filp)
 {
 	struct gdm *gdm = tty->driver_data;
+
 	return tty_port_open(&gdm->port, tty, filp);
 }
 
 static void gdm_tty_cleanup(struct tty_struct *tty)
 {
 	struct gdm *gdm = tty->driver_data;
+
 	tty_port_put(&gdm->port);
 }
 
 static void gdm_tty_hangup(struct tty_struct *tty)
 {
 	struct gdm *gdm = tty->driver_data;
+
 	tty_port_hangup(&gdm->port);
 }
 
 static void gdm_tty_close(struct tty_struct *tty, struct file *filp)
 {
 	struct gdm *gdm = tty->driver_data;
+
 	tty_port_close(&gdm->port, tty, filp);
 }
 
@@ -139,6 +143,7 @@
 				 int complete)
 {
 	struct gdm *gdm = tty_dev->gdm[index];
+
 	if (!GDM_TTY_READY(gdm)) {
 		if (complete == RECV_PACKET_PROCESS_COMPLETE)
 			gdm_tty_recv(gdm, gdm_tty_recv_complete);
diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c
index ea89d53..0c1b2de 100644
--- a/drivers/staging/gdm724x/gdm_usb.c
+++ b/drivers/staging/gdm724x/gdm_usb.c
@@ -896,6 +896,7 @@
 	struct lte_udev *udev;
 	u16 idVendor, idProduct;
 	struct usb_device *usbdev;
+
 	usbdev = interface_to_usbdev(intf);
 
 	idVendor = __le16_to_cpu(usbdev->descriptor.idVendor);
diff --git a/drivers/staging/gdm724x/netlink_k.c b/drivers/staging/gdm724x/netlink_k.c
index 5ddd369..59a1830 100644
--- a/drivers/staging/gdm724x/netlink_k.c
+++ b/drivers/staging/gdm724x/netlink_k.c
@@ -54,7 +54,7 @@
 		return;
 	}
 
-	if (skb->len < NLMSG_SPACE(0)) {
+	if (skb->len < NLMSG_HDRLEN) {
 		pr_err("nl cb - invalid skb length\n");
 		return;
 	}
diff --git a/drivers/staging/gdm72xx/gdm_sdio.c b/drivers/staging/gdm72xx/gdm_sdio.c
index 6a23bef..7a0a0f2 100644
--- a/drivers/staging/gdm72xx/gdm_sdio.c
+++ b/drivers/staging/gdm72xx/gdm_sdio.c
@@ -278,9 +278,8 @@
 
 	spin_unlock_irqrestore(&tx->lock, flags);
 
-	print_hex_dump_debug("sdio_send: ", DUMP_PREFIX_NONE, 16, 1,
-			     tx->sdu_buf + TYPE_A_HEADER_SIZE,
-			     aggr_len - TYPE_A_HEADER_SIZE, false);
+	dev_dbg(&func->dev, "sdio_send: %*ph\n", aggr_len - TYPE_A_HEADER_SIZE,
+		tx->sdu_buf + TYPE_A_HEADER_SIZE);
 
 	for (pos = TYPE_A_HEADER_SIZE; pos < aggr_len; pos += TX_CHUNK_SIZE) {
 		len = aggr_len - pos;
@@ -315,9 +314,9 @@
 {
 	unsigned long flags;
 
-	print_hex_dump_debug("sdio_send: ", DUMP_PREFIX_NONE, 16, 1,
-			     t->buf + TYPE_A_HEADER_SIZE,
-			     t->len - TYPE_A_HEADER_SIZE, false);
+	dev_dbg(&func->dev, "sdio_send: %*ph\n", t->len - TYPE_A_HEADER_SIZE,
+		t->buf + TYPE_A_HEADER_SIZE);
+
 	send_sdio_pkt(func, t->buf, t->len);
 
 	spin_lock_irqsave(&tx->lock, flags);
@@ -549,8 +548,8 @@
 	}
 
 end_io:
-	print_hex_dump_debug("sdio_receive: ", DUMP_PREFIX_NONE, 16, 1,
-			     rx->rx_buf, len, false);
+	dev_dbg(&func->dev, "sdio_receive: %*ph\n", len, rx->rx_buf);
+
 	len = control_sdu_tx_flow(sdev, rx->rx_buf, len);
 
 	spin_lock_irqsave(&rx->lock, flags);
diff --git a/drivers/staging/gdm72xx/gdm_usb.c b/drivers/staging/gdm72xx/gdm_usb.c
index 45b3dda..eac2f34 100644
--- a/drivers/staging/gdm72xx/gdm_usb.c
+++ b/drivers/staging/gdm72xx/gdm_usb.c
@@ -341,8 +341,8 @@
 	usb_fill_bulk_urb(t->urb, usbdev, usb_sndbulkpipe(usbdev, 1), t->buf,
 			  len + padding, gdm_usb_send_complete, t);
 
-	print_hex_dump_debug("usb_send: ", DUMP_PREFIX_NONE, 16, 1, t->buf,
-			     len + padding, false);
+	dev_dbg(&usbdev->dev, "usb_send: %*ph\n", len + padding, t->buf);
+
 #ifdef CONFIG_WIMAX_GDM72XX_USB_PM
 	if (usbdev->state & USB_STATE_SUSPENDED) {
 		list_add_tail(&t->p_list, &tx->pending_list);
@@ -420,8 +420,10 @@
 
 	if (!urb->status) {
 		cmd_evt = (r->buf[0] << 8) | (r->buf[1]);
-		print_hex_dump_debug("usb_receive: ", DUMP_PREFIX_NONE, 16, 1,
-				     r->buf, urb->actual_length, false);
+
+		dev_dbg(&dev->dev, "usb_receive: %*ph\n", urb->actual_length,
+			r->buf);
+
 		if (cmd_evt == WIMAX_SDU_TX_FLOW) {
 			if (r->buf[4] == 0) {
 				dev_dbg(&dev->dev, "WIMAX ==> STOP SDU TX\n");
diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
index 726c943..6754463 100644
--- a/drivers/staging/gdm72xx/gdm_wimax.c
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -52,108 +52,6 @@
 
 static u8 gdm_wimax_macaddr[6] = {0x00, 0x0a, 0x3b, 0xf0, 0x01, 0x30};
 
-static const char *get_protocol_name(u16 protocol)
-{
-	static char buf[32];
-	const char *name = "-";
-
-	switch (protocol) {
-	case ETH_P_ARP:
-		name = "ARP";
-		break;
-	case ETH_P_IP:
-		name = "IP";
-		break;
-	case ETH_P_IPV6:
-		name = "IPv6";
-		break;
-	}
-
-	sprintf(buf, "0x%04x(%s)", protocol, name);
-	return buf;
-}
-
-static const char *get_ip_protocol_name(u8 ip_protocol)
-{
-	static char buf[32];
-	const char *name = "-";
-
-	switch (ip_protocol) {
-	case IPPROTO_TCP:
-		name = "TCP";
-		break;
-	case IPPROTO_UDP:
-		name = "UDP";
-		break;
-	case IPPROTO_ICMP:
-		name = "ICMP";
-		break;
-	}
-
-	sprintf(buf, "%u(%s)", ip_protocol, name);
-	return buf;
-}
-
-static const char *get_port_name(u16 port)
-{
-	static char buf[32];
-	const char *name = "-";
-
-	switch (port) {
-	case 67:
-		name = "DHCP-Server";
-		break;
-	case 68:
-		name = "DHCP-Client";
-		break;
-	case 69:
-		name = "TFTP";
-		break;
-	}
-
-	sprintf(buf, "%u(%s)", port, name);
-	return buf;
-}
-
-static void dump_eth_packet(struct net_device *dev, const char *title,
-			    u8 *data, int len)
-{
-	struct iphdr *ih = NULL;
-	struct udphdr *uh = NULL;
-	u16 protocol = 0;
-	u8 ip_protocol = 0;
-	u16 port = 0;
-
-	protocol = (data[12]<<8) | data[13];
-	ih = (struct iphdr *)(data+ETH_HLEN);
-
-	if (protocol == ETH_P_IP) {
-		uh = (struct udphdr *)((char *)ih + sizeof(struct iphdr));
-		ip_protocol = ih->protocol;
-		port = ntohs(uh->dest);
-	} else if (protocol == ETH_P_IPV6) {
-		struct ipv6hdr *i6h = (struct ipv6hdr *)data;
-
-		uh = (struct udphdr *)((char *)i6h + sizeof(struct ipv6hdr));
-		ip_protocol = i6h->nexthdr;
-		port = ntohs(uh->dest);
-	}
-
-	netdev_dbg(dev, "[%s] len=%d, %s, %s, %s\n", title, len,
-		   get_protocol_name(protocol),
-		   get_ip_protocol_name(ip_protocol),
-		   get_port_name(port));
-
-	if (!(data[0] == 0xff && data[1] == 0xff)) {
-		if (protocol == ETH_P_IP)
-			netdev_dbg(dev, "     src=%pI4\n", &ih->saddr);
-		else if (protocol == ETH_P_IPV6)
-			netdev_dbg(dev, "     src=%pI6\n", &ih->saddr);
-	}
-
-	print_hex_dump_debug("", DUMP_PREFIX_NONE, 16, 1, data, len, false);
-}
-
 static inline int gdm_wimax_header(struct sk_buff **pskb)
 {
 	u16 buf[HCI_HEADER_SIZE / sizeof(u16)];
@@ -361,8 +259,6 @@
 {
 	int ret = 0;
 
-	dump_eth_packet(dev, "TX", skb->data, skb->len);
-
 	ret = gdm_wimax_header(&skb);
 	if (ret < 0) {
 		skb_pull(skb, HCI_HEADER_SIZE);
@@ -708,8 +604,6 @@
 	struct sk_buff *skb;
 	int ret;
 
-	dump_eth_packet(dev, "RX", buf, len);
-
 	skb = dev_alloc_skb(len + 2);
 	if (!skb) {
 		netdev_err(dev, "%s: dev_alloc_skb failed!\n", __func__);
diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c
index 9df4ad8..c89d0b8 100644
--- a/drivers/staging/goldfish/goldfish_audio.c
+++ b/drivers/staging/goldfish/goldfish_audio.c
@@ -297,7 +297,7 @@
 	}
 	data->buffer_virt = dmam_alloc_coherent(&pdev->dev,
 				COMBINED_BUFFER_SIZE, &buf_addr, GFP_KERNEL);
-	if (data->buffer_virt == 0) {
+	if (data->buffer_virt == NULL) {
 		dev_err(&pdev->dev, "allocate buffer failed\n");
 		return -ENOMEM;
 	}
diff --git a/drivers/staging/keucr/Kconfig b/drivers/staging/keucr/Kconfig
deleted file mode 100644
index ba756bf..0000000
--- a/drivers/staging/keucr/Kconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-config USB_ENESTORAGE
-	tristate "USB ENE SM card reader support"
-	depends on USB && SCSI && m
-	---help---
-	  Say Y here if you wish to control a ENE SM Card reader.
-	  To use SD/MS card, please build driver/usb/storage/ums-eneub6250.ko
-
-	  This option depends on 'SCSI' support being enabled, but you
-	  probably also need 'SCSI device support: SCSI disk support'
-	  (BLK_DEV_SD) for most USB storage devices.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called keucr.
-
diff --git a/drivers/staging/keucr/Makefile b/drivers/staging/keucr/Makefile
deleted file mode 100644
index c180bf4..0000000
--- a/drivers/staging/keucr/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-ccflags-y := -Idrivers/scsi
-
-obj-$(CONFIG_USB_ENESTORAGE)	+= keucr.o
-
-keucr-y :=			\
-		usb.o		\
-		scsiglue.o	\
-		transport.o	\
-		init.o		\
-		smscsi.o	\
-		smilmain.o	\
-		smilsub.o	\
-		smilecc.o
diff --git a/drivers/staging/keucr/TODO b/drivers/staging/keucr/TODO
deleted file mode 100644
index d6da656..0000000
--- a/drivers/staging/keucr/TODO
+++ /dev/null
@@ -1,12 +0,0 @@
-TODO:
-	- checkpatch.pl clean
-	- sparse clean
-	- determine if the driver should not be using a duplicate
-	  version of the usb-storage scsi interface code, but should
-	  be merged into the drivers/usb/storage/ directory and
-	  infrastructure instead.
-	- review by the USB developer community
-	- smcommon.h & smilsub.c: use kernel hweight8(), hweight16()
-
-Please send any patches for this driver to Al Cho <acho@novell.com> and
-Greg Kroah-Hartman <gregkh@linuxfoundation.org>.
diff --git a/drivers/staging/keucr/common.h b/drivers/staging/keucr/common.h
deleted file mode 100644
index f0b9776..0000000
--- a/drivers/staging/keucr/common.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef COMMON_INCD
-#define COMMON_INCD
-
-#define BYTE_MASK	0xff
-
-#endif
-
diff --git a/drivers/staging/keucr/init.c b/drivers/staging/keucr/init.c
deleted file mode 100644
index 1e7449d..0000000
--- a/drivers/staging/keucr/init.c
+++ /dev/null
@@ -1,333 +0,0 @@
-#include <linux/sched.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-
-#include <scsi/scsi.h>
-#include <scsi/scsi_eh.h>
-#include <scsi/scsi_device.h>
-
-#include "usb.h"
-#include "scsiglue.h"
-#include "transport.h"
-#include "smil.h"
-#include "init.h"
-
-/*
- * ENE_InitMedia():
- */
-int ENE_InitMedia(struct us_data *us)
-{
-	int	result;
-	u8	MiscReg03 = 0;
-
-	dev_info(&us->pusb_dev->dev, "--- Init Media ---\n");
-	result = ene_read_byte(us, REG_CARD_STATUS, &MiscReg03);
-	if (result != USB_STOR_XFER_GOOD) {
-		dev_err(&us->pusb_dev->dev, "Failed to read register\n");
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-	dev_info(&us->pusb_dev->dev, "MiscReg03 = %x\n", MiscReg03);
-
-	if (MiscReg03 & 0x02) {
-		if (!us->SM_Status.Ready && !us->MS_Status.Ready) {
-			result = ENE_SMInit(us);
-			if (result != USB_STOR_XFER_GOOD)
-				return USB_STOR_TRANSPORT_ERROR;
-		}
-
-	}
-	return result;
-}
-
-/*
- * ene_read_byte() :
- */
-int ene_read_byte(struct us_data *us, u16 index, void *buf)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	int result;
-
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength	= 0x01;
-	bcb->Flags			= 0x80;
-	bcb->CDB[0]			= 0xED;
-	bcb->CDB[2]			= (u8)(index>>8);
-	bcb->CDB[3]			= (u8)index;
-
-	result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0);
-	return result;
-}
-
-/*
- *ENE_SMInit()
- */
-int ENE_SMInit(struct us_data *us)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	int	result;
-	u8	buf[0x200];
-
-	dev_dbg(&us->pusb_dev->dev, "transport --- ENE_SMInit\n");
-
-	result = ENE_LoadBinCode(us, SM_INIT_PATTERN);
-	if (result != USB_STOR_XFER_GOOD) {
-		dev_info(&us->pusb_dev->dev,
-			 "Failed to load SmartMedia init code\n: result= %x\n",
-			 result);
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength	= 0x200;
-	bcb->Flags			= 0x80;
-	bcb->CDB[0]			= 0xF1;
-	bcb->CDB[1]			= 0x01;
-
-	result = ENE_SendScsiCmd(us, FDIR_READ, &buf, 0);
-	if (result != USB_STOR_XFER_GOOD) {
-		dev_err(&us->pusb_dev->dev,
-			"Failed to load SmartMedia init code: result = %x\n",
-			result);
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	us->SM_Status = *(struct keucr_sm_status *)&buf[0];
-
-	us->SM_DeviceID = buf[1];
-	us->SM_CardID   = buf[2];
-
-	if (us->SM_Status.Insert && us->SM_Status.Ready) {
-		dev_info(&us->pusb_dev->dev, "Insert     = %x\n",
-					     us->SM_Status.Insert);
-		dev_info(&us->pusb_dev->dev, "Ready      = %x\n",
-					     us->SM_Status.Ready);
-		dev_info(&us->pusb_dev->dev, "WtP        = %x\n",
-					     us->SM_Status.WtP);
-		dev_info(&us->pusb_dev->dev, "DeviceID   = %x\n",
-					     us->SM_DeviceID);
-		dev_info(&us->pusb_dev->dev, "CardID     = %x\n",
-					     us->SM_CardID);
-		MediaChange = 1;
-		Check_D_MediaFmt(us);
-	} else {
-		dev_err(&us->pusb_dev->dev,
-			"SmartMedia Card Not Ready --- %x\n", buf[0]);
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/*
- * ENE_LoadBinCode()
- */
-int ENE_LoadBinCode(struct us_data *us, u8 flag)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	int result;
-	/* void *buf; */
-	u8 *buf;
-
-	/* dev_info(&us->pusb_dev->dev, "transport --- ENE_LoadBinCode\n"); */
-	if (us->BIN_FLAG == flag)
-		return USB_STOR_TRANSPORT_GOOD;
-
-	buf = kmalloc(0x800, GFP_KERNEL);
-	if (buf == NULL)
-		return USB_STOR_TRANSPORT_ERROR;
-	switch (flag) {
-	/* For SS */
-	case SM_INIT_PATTERN:
-		dev_dbg(&us->pusb_dev->dev, "SM_INIT_PATTERN\n");
-		memcpy(buf, SM_Init, 0x800);
-		break;
-	case SM_RW_PATTERN:
-		dev_dbg(&us->pusb_dev->dev, "SM_RW_PATTERN\n");
-		memcpy(buf, SM_Rdwr, 0x800);
-		break;
-	}
-
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength = 0x800;
-	bcb->Flags = 0x00;
-	bcb->CDB[0] = 0xEF;
-
-	result = ENE_SendScsiCmd(us, FDIR_WRITE, buf, 0);
-
-	kfree(buf);
-	us->BIN_FLAG = flag;
-	return result;
-}
-
-/*
- * ENE_SendScsiCmd():
- */
-int ENE_SendScsiCmd(struct us_data *us, u8 fDir, void *buf, int use_sg)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
-
-	int result;
-	unsigned int transfer_length = bcb->DataTransferLength,
-		     cswlen = 0, partial = 0;
-	unsigned int residue;
-
-	/* dev_dbg(&us->pusb_dev->dev, "transport --- ENE_SendScsiCmd\n"); */
-	/* send cmd to out endpoint */
-	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
-					    bcb, US_BULK_CB_WRAP_LEN, NULL);
-	if (result != USB_STOR_XFER_GOOD) {
-		dev_err(&us->pusb_dev->dev,
-				"send cmd to out endpoint fail ---\n");
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	if (buf) {
-		unsigned int pipe = fDir;
-
-		if (fDir == FDIR_READ)
-			pipe = us->recv_bulk_pipe;
-		else
-			pipe = us->send_bulk_pipe;
-
-		/* Bulk */
-		if (use_sg)
-			result = usb_stor_bulk_srb(us, pipe, us->srb);
-		else
-			result = usb_stor_bulk_transfer_sg(us, pipe, buf,
-						transfer_length, 0, &partial);
-		if (result != USB_STOR_XFER_GOOD) {
-			dev_err(&us->pusb_dev->dev, "data transfer fail ---\n");
-			return USB_STOR_TRANSPORT_ERROR;
-		}
-	}
-
-	/* Get CSW for device status */
-	result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
-						US_BULK_CS_WRAP_LEN, &cswlen);
-
-	if (result == USB_STOR_XFER_SHORT && cswlen == 0) {
-		dev_warn(&us->pusb_dev->dev,
-				"Received 0-length CSW; retrying...\n");
-		result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
-					bcs, US_BULK_CS_WRAP_LEN, &cswlen);
-	}
-
-	if (result == USB_STOR_XFER_STALLED) {
-		/* get the status again */
-		dev_warn(&us->pusb_dev->dev,
-				"Attempting to get CSW (2nd try)...\n");
-		result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
-						bcs, US_BULK_CS_WRAP_LEN, NULL);
-	}
-
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	/* check bulk status */
-	residue = le32_to_cpu(bcs->Residue);
-
-	/*
-	 * try to compute the actual residue, based on how much data
-	 * was really transferred and what the device tells us
-	 */
-	if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) {
-		residue = min(residue, transfer_length);
-		if (us->srb)
-			scsi_set_resid(us->srb, max(scsi_get_resid(us->srb),
-					(int) residue));
-	}
-
-	if (bcs->Status != US_BULK_STAT_OK)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/*
- * ENE_Read_Data()
- */
-int ENE_Read_Data(struct us_data *us, void *buf, unsigned int length)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
-	int result;
-
-	/* dev_dbg(&us->pusb_dev->dev, "transport --- ENE_Read_Data\n"); */
-	/* set up the command wrapper */
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength = length;
-	bcb->Flags = 0x80;
-	bcb->CDB[0] = 0xED;
-	bcb->CDB[2] = 0xFF;
-	bcb->CDB[3] = 0x81;
-
-	/* send cmd to out endpoint */
-	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb,
-						US_BULK_CB_WRAP_LEN, NULL);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	/* R/W data */
-	result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
-						buf, length, NULL);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	/* Get CSW for device status */
-	result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
-						US_BULK_CS_WRAP_LEN, NULL);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-	if (bcs->Status != US_BULK_STAT_OK)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/*
- * ENE_Write_Data():
- */
-int ENE_Write_Data(struct us_data *us, void *buf, unsigned int length)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
-	int result;
-
-	/* printk("transport --- ENE_Write_Data\n"); */
-	/* set up the command wrapper */
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength = length;
-	bcb->Flags = 0x00;
-	bcb->CDB[0] = 0xEE;
-	bcb->CDB[2] = 0xFF;
-	bcb->CDB[3] = 0x81;
-
-	/* send cmd to out endpoint */
-	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb,
-						US_BULK_CB_WRAP_LEN, NULL);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	/* R/W data */
-	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
-						buf, length, NULL);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	/* Get CSW for device status */
-	result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
-						US_BULK_CS_WRAP_LEN, NULL);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-	if (bcs->Status != US_BULK_STAT_OK)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
diff --git a/drivers/staging/keucr/init.h b/drivers/staging/keucr/init.h
deleted file mode 100644
index d1367e7..0000000
--- a/drivers/staging/keucr/init.h
+++ /dev/null
@@ -1,518 +0,0 @@
-#include "common.h"
-
-static u8 SM_Init[] = {
-0x7B, 0x09, 0x7C, 0xF0, 0x7D, 0x10, 0x7E, 0xE9,
-0x7F, 0xCC, 0x12, 0x2F, 0x71, 0x90, 0xE9, 0xCC,
-0xE0, 0xB4, 0x07, 0x12, 0x90, 0xFF, 0x09, 0xE0,
-0x30, 0xE1, 0x06, 0x90, 0xFF, 0x23, 0x74, 0x80,
-0xF0, 0x12, 0x2F, 0x5C, 0xD3, 0x22, 0x78, 0x00,
-0x90, 0xFF, 0x83, 0xE0, 0xA2, 0xE1, 0x92, 0x0A,
-0x20, 0x0A, 0x03, 0x02, 0xE0, 0xD0, 0x7F, 0x00,
-0x12, 0x2F, 0xCB, 0x20, 0x01, 0x05, 0xC2, 0x25,
-0x02, 0xE0, 0xEB, 0xC3, 0xE8, 0x94, 0x02, 0x40,
-0x03, 0x02, 0xE0, 0xD0, 0xC0, 0x00, 0x90, 0xFE,
-0x66, 0x74, 0x90, 0xF0, 0x12, 0xE1, 0x40, 0x90,
-0xFF, 0x95, 0xE0, 0xC2, 0xE4, 0xF0, 0x90, 0xFF,
-0x97, 0x74, 0x01, 0xF0, 0x7E, 0x01, 0x7F, 0x90,
-0x12, 0x2F, 0x74, 0x90, 0xFF, 0x97, 0x74, 0x03,
-0xF0, 0x90, 0xFE, 0xC5, 0xE4, 0xF0, 0x74, 0x00,
-0x90, 0xFE, 0x6A, 0xF0, 0xA3, 0xF0, 0xA3, 0xF0,
-0xA3, 0xF0, 0x7E, 0x23, 0x7F, 0xDC, 0x12, 0x2F,
-0x74, 0x12, 0x2F, 0x5C, 0x90, 0xFE, 0x64, 0xE0,
-0x54, 0x01, 0x60, 0x04, 0xD2, 0x02, 0x80, 0x02,
-0xC2, 0x02, 0x90, 0xFF, 0x95, 0xE0, 0xD2, 0xE4,
-0xF0, 0x78, 0x10, 0x79, 0x04, 0x12, 0xE1, 0x71,
-0x50, 0x3A, 0x90, 0xE9, 0xC6, 0xE0, 0x90, 0xE9,
-0xC3, 0xF0, 0x78, 0x9A, 0x79, 0x04, 0x12, 0xE1,
-0x71, 0x50, 0x29, 0x90, 0xE9, 0xC7, 0xE0, 0xB4,
-0xB5, 0x22, 0x90, 0xE9, 0xC4, 0xF0, 0xD0, 0x00,
-0xD2, 0x00, 0xC2, 0x01, 0xC2, 0x25, 0x80, 0x1B,
-0xC2, 0x00, 0xD2, 0x01, 0x74, 0xFF, 0x90, 0xE9,
-0xC3, 0xF0, 0xA3, 0xF0, 0x51, 0x01, 0xC2, 0x0A,
-0xC2, 0x02, 0x80, 0x07, 0xD0, 0x00, 0x05, 0x00,
-0x02, 0xE0, 0x43, 0x90, 0xFF, 0x09, 0xE0, 0x30,
-0xE1, 0x06, 0x90, 0xFF, 0x23, 0x74, 0x80, 0xF0,
-0x90, 0xFF, 0x09, 0xE0, 0x30, 0xE5, 0xFC, 0xE4,
-0xA2, 0x0A, 0x92, 0xE0, 0xA2, 0x00, 0x92, 0xE1,
-0xA2, 0x01, 0x92, 0xE2, 0xA2, 0x02, 0x92, 0xE6,
-0xA2, 0x25, 0x92, 0xE7, 0x90, 0xF4, 0x00, 0xF0,
-0x90, 0xE9, 0xC3, 0xE0, 0x90, 0xF4, 0x01, 0xF0,
-0x90, 0xE9, 0xC4, 0xE0, 0x90, 0xF4, 0x02, 0xF0,
-0x90, 0xFF, 0x2A, 0x74, 0x02, 0xF0, 0xA3, 0x74,
-0x00, 0xF0, 0x75, 0x3C, 0x00, 0x75, 0x3D, 0x00,
-0x75, 0x3E, 0x00, 0x75, 0x3F, 0x00, 0xD3, 0x22,
-0x90, 0xFE, 0x71, 0xE4, 0xF0, 0x90, 0xFE, 0x72,
-0x74, 0x01, 0xF0, 0x90, 0xFE, 0x64, 0x74, 0x0C,
-0xF0, 0x90, 0xFE, 0x64, 0x74, 0x00, 0x45, 0x4E,
-0xF0, 0x90, 0xFE, 0x64, 0xE0, 0x54, 0x10, 0x60,
-0x08, 0x90, 0xFE, 0x72, 0x74, 0x81, 0xF0, 0xD3,
-0x22, 0x90, 0xFE, 0x64, 0x74, 0x08, 0xF0, 0xC3,
-0x22, 0x90, 0xFE, 0x6F, 0xE9, 0x14, 0xF0, 0x90,
-0xFE, 0x70, 0xE0, 0x54, 0xFC, 0xF0, 0x90, 0xFE,
-0x68, 0x74, 0x00, 0xF0, 0xB8, 0x9A, 0x2A, 0x74,
-0x15, 0x90, 0xFE, 0x64, 0xF0, 0x74, 0x9A, 0x90,
-0xFE, 0x60, 0xF0, 0x74, 0x16, 0x90, 0xFE, 0x64,
-0xF0, 0x74, 0x00, 0x90, 0xFE, 0x60, 0xF0, 0x30,
-0x0A, 0x5D, 0x90, 0xFE, 0x64, 0xE0, 0x20, 0xE7,
-0xF6, 0x74, 0x14, 0x90, 0xFE, 0x64, 0xF0, 0x80,
-0x20, 0x90, 0xFE, 0x6E, 0xE8, 0x44, 0x01, 0xF0,
-0xC2, 0x09, 0x12, 0xE3, 0x26, 0x20, 0x08, 0x0E,
-0x12, 0xE3, 0x32, 0x30, 0x3E, 0xF7, 0x90, 0xFE,
-0xD8, 0x74, 0x01, 0xF0, 0xD2, 0x09, 0x20, 0x09,
-0x2E, 0x7A, 0xE9, 0x7B, 0xC5, 0x7C, 0xFE, 0x7D,
-0x60, 0xB8, 0x10, 0x07, 0x90, 0xFE, 0x69, 0xE0,
-0x20, 0xE6, 0xFC, 0x8C, 0x83, 0x8D, 0x82, 0xE0,
-0x8A, 0x83, 0x8B, 0x82, 0xF0, 0xA3, 0xAA, 0x83,
-0xAB, 0x82, 0xD9, 0xE5, 0xB8, 0x9A, 0x06, 0x74,
-0x10, 0x90, 0xFE, 0x64, 0xF0, 0xD3, 0x22, 0xC3,
-0x22, 0x90, 0xFF, 0x83, 0xE0, 0xA2, 0xE1, 0x92,
-0x25, 0x20, 0x25, 0x06, 0xC2, 0x1F, 0xD2, 0x19,
-0xC3, 0x22, 0x7F, 0x02, 0x12, 0x2F, 0xCB, 0x20,
-0x19, 0x05, 0x30, 0x1F, 0x02, 0xD3, 0x22, 0x90,
-0xEA, 0x44, 0x74, 0x80, 0xF0, 0x7F, 0x10, 0x12,
-0x2F, 0xC5, 0x90, 0xFE, 0x47, 0xE0, 0x44, 0x80,
-0xF0, 0x78, 0x00, 0xE8, 0xC3, 0x94, 0x04, 0x50,
-0x0A, 0x7F, 0x88, 0x7E, 0x13, 0x12, 0xE3, 0x4D,
-0x08, 0x80, 0xF0, 0x90, 0xFE, 0x45, 0xE0, 0x54,
-0xFB, 0xF0, 0x90, 0xFE, 0x47, 0xE0, 0x54, 0xBF,
-0xF0, 0x90, 0xFE, 0x45, 0xE0, 0x54, 0xFE, 0xF0,
-0x90, 0xFE, 0x45, 0xE0, 0x54, 0x7F, 0xF0, 0x90,
-0xFE, 0x46, 0xE0, 0x44, 0x40, 0xF0, 0x90, 0xFE,
-0x45, 0xE0, 0x54, 0xC7, 0x44, 0x18, 0xF0, 0x90,
-0xFE, 0x47, 0xE0, 0x44, 0x08, 0xF0, 0x90, 0xFE,
-0x45, 0xE0, 0x44, 0x40, 0xF0, 0x7F, 0x32, 0x7E,
-0x00, 0x12, 0xE3, 0x4D, 0x90, 0xFE, 0x51, 0xE0,
-0x54, 0x33, 0xF0, 0x90, 0xFE, 0x44, 0x74, 0x02,
-0xF0, 0x30, 0x25, 0x04, 0xE0, 0x20, 0xE1, 0xF9,
-0x90, 0xFE, 0x51, 0xE0, 0x54, 0x0F, 0xF0, 0x90,
-0xFE, 0x44, 0x74, 0x02, 0xF0, 0x30, 0x25, 0x04,
-0xE0, 0x20, 0xE1, 0xF9, 0x90, 0xFE, 0x44, 0x74,
-0x04, 0xF0, 0x30, 0x25, 0x04, 0xE0, 0x20, 0xE2,
-0xF9, 0x90, 0xFE, 0x4C, 0xE0, 0xF0, 0x90, 0xFE,
-0x4D, 0xE0, 0xF0, 0x90, 0xFE, 0x48, 0x74, 0x7F,
-0xF0, 0x90, 0xFE, 0x49, 0x74, 0x9F, 0xF0, 0x90,
-0xFE, 0x51, 0xE0, 0x54, 0x3C, 0x44, 0x02, 0xF0,
-0x90, 0xFE, 0x44, 0x74, 0x02, 0xF0, 0x30, 0x25,
-0x04, 0xE0, 0x20, 0xE1, 0xF9, 0x90, 0xFE, 0x46,
-0xE0, 0x44, 0x20, 0xF0, 0x79, 0x02, 0x7A, 0x06,
-0x7B, 0x00, 0x7C, 0x00, 0x7D, 0x06, 0x7E, 0xEB,
-0x7F, 0xC9, 0x12, 0x2F, 0xA7, 0x40, 0x03, 0x02,
-0xE3, 0x04, 0xD3, 0x22, 0xE4, 0x90, 0xFE, 0x48,
-0xF0, 0x90, 0xFE, 0x49, 0xF0, 0x90, 0xFE, 0x4C,
-0xE0, 0xF0, 0x90, 0xFE, 0x4D, 0xE0, 0xF0, 0x90,
-0xFE, 0x47, 0xE0, 0x54, 0x7F, 0xF0, 0xC2, 0x25,
-0xC2, 0x1F, 0xD2, 0x19, 0xC3, 0x22, 0xC2, 0x3E,
-0x75, 0x7C, 0x00, 0x75, 0x7D, 0x00, 0x75, 0x7E,
-0x00, 0x22, 0x05, 0x7C, 0xE5, 0x7C, 0x70, 0x14,
-0x05, 0x7D, 0xE5, 0x7D, 0x70, 0x04, 0x05, 0x7E,
-0x80, 0x0A, 0xB4, 0x17, 0x07, 0xE5, 0x7E, 0xB4,
-0x06, 0x02, 0xD2, 0x3E, 0x22, 0x75, 0x8A, 0x00,
-0x75, 0x8C, 0xCE, 0xC2, 0x8D, 0x90, 0xEA, 0x65,
-0xE4, 0xF0, 0xA3, 0xF0, 0xD2, 0x8C, 0x90, 0xEA,
-0x65, 0xE0, 0xFC, 0xA3, 0xE0, 0xFD, 0xEC, 0xC3,
-0x9E, 0x40, 0xF3, 0x70, 0x05, 0xED, 0xC3, 0x9F,
-0x40, 0xEC, 0xC2, 0x8C, 0x22, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x58, 0x44, 0x2D, 0x49, 0x6E, 0x69, 0x74, 0x20,
-0x20, 0x20, 0x20, 0x31, 0x30, 0x30, 0x30, 0x31 };
-
-static u8 SM_Rdwr[] = {
-0x7B, 0x0C, 0x7C, 0xF0, 0x7D, 0x10, 0x7E, 0xE9,
-0x7F, 0xCC, 0x12, 0x2F, 0x71, 0x90, 0xE9, 0xC3,
-0xE0, 0xB4, 0x73, 0x04, 0x74, 0x40, 0x80, 0x09,
-0xB4, 0x75, 0x04, 0x74, 0x40, 0x80, 0x02, 0x74,
-0xC0, 0x90, 0xFE, 0x70, 0xF0, 0x90, 0xFF, 0x09,
-0xE0, 0x30, 0xE1, 0x06, 0x90, 0xFF, 0x23, 0x74,
-0x80, 0xF0, 0x90, 0xFF, 0x83, 0xE0, 0xA2, 0xE1,
-0x92, 0x0A, 0x40, 0x01, 0x22, 0x90, 0xFE, 0x6A,
-0xE4, 0xF0, 0x90, 0xE9, 0xCC, 0xE0, 0xB4, 0x02,
-0x05, 0xD2, 0x06, 0x02, 0xE0, 0x78, 0xB4, 0x03,
-0x03, 0x02, 0xE3, 0xD0, 0xB4, 0x04, 0x03, 0x02,
-0xE1, 0xC6, 0xB4, 0x05, 0x03, 0x02, 0xE5, 0x20,
-0xB4, 0x06, 0x03, 0x02, 0xE5, 0xE0, 0xB4, 0x07,
-0x05, 0x12, 0x2F, 0x5C, 0xD3, 0x22, 0xB4, 0x08,
-0x05, 0xC2, 0x06, 0x02, 0xE6, 0x3B, 0xC3, 0x22,
-0xE5, 0x3E, 0xC3, 0x13, 0x90, 0xE9, 0xCA, 0xF0,
-0xC0, 0xE0, 0x75, 0xF0, 0x02, 0xC0, 0xF0, 0x12,
-0xE0, 0xD8, 0xEF, 0x70, 0x21, 0x20, 0x37, 0x07,
-0x20, 0x09, 0x04, 0xD0, 0xF0, 0x80, 0x05, 0xD0,
-0xF0, 0xD5, 0xF0, 0xE9, 0xD0, 0xE0, 0x90, 0xFF,
-0x28, 0xE0, 0x30, 0xE7, 0xFC, 0x90, 0xFF, 0x28,
-0xE0, 0x44, 0x01, 0xF0, 0xC3, 0x22, 0xD0, 0xF0,
-0x90, 0xE9, 0xCF, 0xE0, 0x24, 0x01, 0xF0, 0x90,
-0xE9, 0xCE, 0xE0, 0x34, 0x00, 0xF0, 0x90, 0xE9,
-0xCD, 0xE0, 0x34, 0x00, 0xF0, 0xD0, 0xE0, 0x14,
-0x70, 0xB6, 0x75, 0x3C, 0x00, 0x75, 0x3D, 0x00,
-0x75, 0x3E, 0x00, 0x75, 0x3F, 0x00, 0xD3, 0x22,
-0xC2, 0x08, 0xC2, 0x36, 0xC2, 0x37, 0xE4, 0x90,
-0xEB, 0xC2, 0xF0, 0x90, 0xE9, 0xCD, 0xE0, 0xF8,
-0xA3, 0xE0, 0xF9, 0xA3, 0xE0, 0x90, 0xFE, 0x6B,
-0xF0, 0xA3, 0xE9, 0xF0, 0xA3, 0xE8, 0xF0, 0x90,
-0xFE, 0x6F, 0x74, 0x0F, 0xF0, 0x90, 0xFE, 0x70,
-0xE0, 0x54, 0xFC, 0x44, 0x02, 0xF0, 0x90, 0xFE,
-0xC6, 0x74, 0x02, 0xF0, 0xA3, 0x74, 0x0F, 0xF0,
-0x90, 0xFE, 0xC0, 0x74, 0xF4, 0xF0, 0x74, 0x00,
-0xA3, 0xF0, 0x90, 0xFE, 0x68, 0x74, 0x21, 0xF0,
-0x90, 0xFE, 0x64, 0x74, 0x70, 0x45, 0x4E, 0xF0,
-0x90, 0xFE, 0x64, 0x74, 0x30, 0x45, 0x4E, 0xF0,
-0x30, 0x06, 0x07, 0x90, 0xFF, 0x09, 0xE0, 0x30,
-0xE5, 0xFC, 0x90, 0xFE, 0x6E, 0x74, 0x51, 0xF0,
-0x90, 0xFE, 0xC4, 0x74, 0x21, 0xF0, 0xC2, 0x09,
-0x12, 0xE7, 0xB0, 0x20, 0x08, 0x0E, 0x12, 0xE7,
-0xBC, 0x30, 0x3E, 0xF7, 0x90, 0xFE, 0xD8, 0x74,
-0x01, 0xF0, 0xD2, 0x09, 0x30, 0x09, 0x03, 0x7F,
-0x00, 0x22, 0x12, 0xE7, 0xB0, 0x20, 0x36, 0x11,
-0x20, 0x37, 0x0E, 0x12, 0xE7, 0xBC, 0x30, 0x3E,
-0xF4, 0x90, 0xFE, 0xD8, 0x74, 0x01, 0xF0, 0xD2,
-0x37, 0x30, 0x37, 0x03, 0x7F, 0x00, 0x22, 0x90,
-0xFE, 0x64, 0x74, 0x10, 0x45, 0x4E, 0xF0, 0x90,
-0xFE, 0x64, 0x74, 0x00, 0x45, 0x4E, 0xF0, 0x12,
-0x2F, 0x65, 0x12, 0x2F, 0x68, 0xBF, 0x00, 0x09,
-0x74, 0x02, 0x90, 0xEB, 0xC2, 0xF0, 0x7F, 0x00,
-0x22, 0x12, 0x2F, 0x6B, 0xBF, 0x00, 0x0F, 0x12,
-0x2F, 0x6E, 0xBF, 0x00, 0x09, 0x74, 0x01, 0x90,
-0xEB, 0xC2, 0xF0, 0x7F, 0x00, 0x22, 0x30, 0x06,
-0x0A, 0x90, 0xFF, 0x2A, 0x74, 0x02, 0xF0, 0xA3,
-0x74, 0x00, 0xF0, 0x7F, 0x01, 0x22, 0x12, 0xE3,
-0xAA, 0x74, 0x01, 0x90, 0xE9, 0xCB, 0xF0, 0xE5,
-0x3E, 0xC3, 0x13, 0x90, 0xE9, 0xCA, 0xF0, 0xC0,
-0xE0, 0x75, 0xF0, 0x02, 0xC0, 0xF0, 0x12, 0xE2,
-0x2F, 0xEF, 0x70, 0x21, 0x20, 0x37, 0x07, 0x20,
-0x09, 0x04, 0xD0, 0xF0, 0x80, 0x05, 0xD0, 0xF0,
-0xD5, 0xF0, 0xE9, 0xD0, 0xE0, 0x90, 0xFF, 0x28,
-0xE0, 0x30, 0xE7, 0xFC, 0x90, 0xFF, 0x28, 0xE0,
-0x44, 0x01, 0xF0, 0xC3, 0x22, 0xD0, 0xF0, 0x90,
-0xE9, 0xD2, 0xE0, 0x24, 0x01, 0xF0, 0x90, 0xE9,
-0xD1, 0xE0, 0x34, 0x00, 0xF0, 0x90, 0xE9, 0xD0,
-0xE0, 0x34, 0x00, 0xF0, 0xD0, 0xE0, 0x14, 0x70,
-0xB6, 0x75, 0x3C, 0x00, 0x75, 0x3D, 0x00, 0x75,
-0x3E, 0x00, 0x75, 0x3F, 0x00, 0xD3, 0x22, 0xC2,
-0x08, 0xC2, 0x36, 0xC2, 0x37, 0x90, 0xFE, 0x68,
-0x74, 0x31, 0xF0, 0x90, 0xE9, 0xD0, 0xE0, 0xF8,
-0xA3, 0xE0, 0xF9, 0xA3, 0xE0, 0x90, 0xFE, 0x6B,
-0xF0, 0xA3, 0xE9, 0xF0, 0xA3, 0xE8, 0xF0, 0x90,
-0xFE, 0x6F, 0x74, 0x0F, 0xF0, 0x90, 0xFE, 0x70,
-0xE0, 0x54, 0xFC, 0x44, 0x22, 0xF0, 0x90, 0xE9,
-0xCB, 0xE0, 0x70, 0x0C, 0x90, 0xFE, 0xC0, 0x74,
-0xF4, 0xF0, 0xA3, 0x74, 0x00, 0xF0, 0x80, 0x0A,
-0x90, 0xFE, 0xC0, 0x74, 0xF0, 0xF0, 0xA3, 0x74,
-0x00, 0xF0, 0x90, 0xFE, 0x64, 0x74, 0xF0, 0x45,
-0x4E, 0xF0, 0x90, 0xFE, 0x64, 0x74, 0xB0, 0x45,
-0x4E, 0xF0, 0x90, 0xFE, 0x6E, 0x74, 0x81, 0xF0,
-0x90, 0xE9, 0xCB, 0xE0, 0x70, 0x0D, 0x90, 0xFE,
-0xC6, 0x74, 0x02, 0xF0, 0xA3, 0x74, 0x0F, 0xF0,
-0x02, 0xE3, 0x56, 0x20, 0x2D, 0x03, 0x02, 0xE2,
-0xEF, 0x90, 0xFE, 0xC6, 0x74, 0x01, 0xF0, 0xA3,
-0x74, 0xFF, 0xF0, 0x90, 0xFF, 0x09, 0x30, 0x0A,
-0x04, 0xE0, 0x30, 0xE1, 0xF9, 0x90, 0xFE, 0xC4,
-0x74, 0x23, 0xF0, 0x12, 0xE7, 0xB0, 0x20, 0x36,
-0x11, 0x20, 0x37, 0x0E, 0x12, 0xE7, 0xBC, 0x30,
-0x3E, 0xF4, 0x90, 0xFE, 0xD8, 0x74, 0x01, 0xF0,
-0xD2, 0x37, 0x30, 0x37, 0x02, 0x61, 0xA7, 0x90,
-0xFF, 0x09, 0xE0, 0x30, 0xE1, 0x06, 0x90, 0xFF,
-0x23, 0x74, 0x80, 0xF0, 0x02, 0xE3, 0x3F, 0x90,
-0xFE, 0xC6, 0xE4, 0xF0, 0xA3, 0x74, 0x3F, 0xF0,
-0x78, 0x08, 0xC0, 0x00, 0xC2, 0x36, 0xC2, 0x37,
-0x90, 0xFF, 0x09, 0x30, 0x0A, 0x04, 0xE0, 0x30,
-0xE1, 0xF9, 0x90, 0xFE, 0xC4, 0x74, 0x23, 0xF0,
-0x12, 0xE7, 0xB0, 0x20, 0x36, 0x11, 0x20, 0x37,
-0x0E, 0x12, 0xE7, 0xBC, 0x30, 0x3E, 0xF4, 0x90,
-0xFE, 0xD8, 0x74, 0x01, 0xF0, 0xD2, 0x37, 0x90,
-0xFF, 0x09, 0xE0, 0x30, 0xE1, 0x06, 0x90, 0xFF,
-0x23, 0x74, 0x80, 0xF0, 0x30, 0x37, 0x04, 0xD0,
-0x00, 0x80, 0x6C, 0xD0, 0x00, 0xD8, 0xBB, 0xC2,
-0x36, 0xC2, 0x37, 0x90, 0xFE, 0xC6, 0xE4, 0xF0,
-0xA3, 0x74, 0x0F, 0xF0, 0x90, 0xFE, 0xC0, 0x74,
-0xF6, 0xF0, 0xA3, 0x74, 0x00, 0xF0, 0x90, 0xFE,
-0xC4, 0x74, 0x23, 0xF0, 0x12, 0xE7, 0xB0, 0x20,
-0x36, 0x11, 0x20, 0x37, 0x0E, 0x12, 0xE7, 0xBC,
-0x30, 0x3E, 0xF4, 0x90, 0xFE, 0xD8, 0x74, 0x01,
-0xF0, 0xD2, 0x37, 0x30, 0x37, 0x02, 0x80, 0x2F,
-0xC2, 0x09, 0x12, 0xE7, 0xB0, 0x20, 0x08, 0x0E,
-0x12, 0xE7, 0xBC, 0x30, 0x3E, 0xF7, 0x90, 0xFE,
-0xD8, 0x74, 0x01, 0xF0, 0xD2, 0x09, 0x30, 0x09,
-0x02, 0x80, 0x14, 0x90, 0xFE, 0x64, 0x74, 0x90,
-0x45, 0x4E, 0xF0, 0x90, 0xFE, 0x64, 0x74, 0x80,
-0x45, 0x4E, 0xF0, 0x12, 0x2F, 0x59, 0x22, 0x7F,
-0x00, 0x22, 0x90, 0xF6, 0x00, 0x7F, 0x06, 0x74,
-0xFF, 0xF0, 0xA3, 0xDF, 0xFC, 0x7B, 0x02, 0x7C,
-0xE9, 0x7D, 0xD3, 0x7E, 0xF6, 0x7F, 0x06, 0x12,
-0x2F, 0x71, 0x7B, 0x02, 0x7C, 0xE9, 0x7D, 0xD3,
-0x7E, 0xF6, 0x7F, 0x0B, 0x12, 0x2F, 0x71, 0x22,
-0x90, 0xFE, 0xC6, 0xE4, 0xF0, 0xA3, 0x74, 0x0F,
-0xF0, 0x90, 0xFE, 0x6F, 0xF0, 0x90, 0xFE, 0x70,
-0xE0, 0x54, 0xFC, 0xF0, 0x90, 0xFE, 0xC0, 0x74,
-0xF6, 0xF0, 0xA3, 0x74, 0x00, 0xF0, 0x90, 0xFE,
-0x68, 0x74, 0x21, 0xF0, 0x90, 0xFE, 0x66, 0xE0,
-0x54, 0xEF, 0xF0, 0x90, 0xE9, 0xD3, 0xE0, 0xF5,
-0x08, 0xA3, 0xE0, 0xF5, 0x09, 0x90, 0xFF, 0x09,
-0xE0, 0x30, 0xE5, 0xFC, 0xE4, 0xF5, 0x10, 0x7E,
-0xF4, 0x7F, 0x00, 0xC0, 0x06, 0xC0, 0x07, 0xC2,
-0x36, 0xC2, 0x37, 0xC2, 0x09, 0x90, 0xE9, 0xCD,
-0xE0, 0xF8, 0xA3, 0xE0, 0xF9, 0xA3, 0xE0, 0x90,
-0xFE, 0x6B, 0xF0, 0xA3, 0xE9, 0xF0, 0xA3, 0xE8,
-0xF0, 0x90, 0xFE, 0x6E, 0x74, 0x71, 0xF0, 0x90,
-0xFE, 0xC4, 0x74, 0x21, 0xF0, 0x90, 0xFE, 0x65,
-0x12, 0xE7, 0xB0, 0xE0, 0x20, 0xE4, 0x11, 0x12,
-0xE7, 0xBC, 0x30, 0x3E, 0xF6, 0x90, 0xFE, 0xD8,
-0x74, 0x01, 0xF0, 0xD2, 0x09, 0x02, 0xE4, 0x72,
-0x74, 0x10, 0xF0, 0x12, 0xE7, 0xB0, 0x20, 0x36,
-0x11, 0x20, 0x37, 0x0E, 0x12, 0xE7, 0xBC, 0x30,
-0x3E, 0xF4, 0x90, 0xFE, 0xD8, 0x74, 0x01, 0xF0,
-0xD2, 0x37, 0x20, 0x09, 0x05, 0x20, 0x37, 0x02,
-0x80, 0x10, 0x90, 0xFE, 0x66, 0xE0, 0x44, 0x10,
-0xF0, 0x12, 0x2F, 0x5C, 0xD0, 0x07, 0xD0, 0x06,
-0xC3, 0x22, 0xD0, 0x07, 0xD0, 0x06, 0x7B, 0x10,
-0x7C, 0xF6, 0x7D, 0x00, 0x12, 0x2F, 0x71, 0x05,
-0x10, 0xC3, 0xE5, 0x09, 0x94, 0x01, 0xF5, 0x09,
-0xE5, 0x08, 0x94, 0x00, 0xF5, 0x08, 0x45, 0x09,
-0x70, 0x03, 0x02, 0xE4, 0xEF, 0x90, 0xE9, 0xCF,
-0xE0, 0x24, 0x20, 0xF0, 0x90, 0xE9, 0xCE, 0xE0,
-0x34, 0x00, 0xF0, 0x90, 0xE9, 0xCD, 0xE0, 0x34,
-0x00, 0xF0, 0xC3, 0xEF, 0x24, 0x10, 0xFF, 0xEE,
-0x34, 0x00, 0xFE, 0xE5, 0x10, 0x64, 0x20, 0x60,
-0x03, 0x02, 0xE4, 0x13, 0x90, 0xFF, 0x2A, 0x74,
-0x02, 0xF0, 0xA3, 0x74, 0x00, 0xF0, 0x75, 0x10,
-0x00, 0x7E, 0xF4, 0x7F, 0x00, 0x90, 0xFF, 0x09,
-0xE0, 0x30, 0xE5, 0xFC, 0x02, 0xE4, 0x13, 0xE5,
-0x10, 0x60, 0x17, 0x7E, 0x00, 0x7F, 0x00, 0x78,
-0x04, 0xC3, 0x33, 0xFF, 0xEE, 0x33, 0xFE, 0xEF,
-0xD8, 0xF8, 0x90, 0xFF, 0x2A, 0xEE, 0xF0, 0xA3,
-0xEF, 0xF0, 0x90, 0xFE, 0x66, 0xE0, 0x44, 0x10,
-0xF0, 0x12, 0x2F, 0x5C, 0x78, 0x00, 0x88, 0x3C,
-0x88, 0x3D, 0x88, 0x3E, 0x88, 0x3F, 0xD3, 0x22,
-0x12, 0x2F, 0x5F, 0x12, 0x2F, 0x62, 0x90, 0xFE,
-0xC6, 0xE4, 0xF0, 0xA3, 0x74, 0x0F, 0xF0, 0x90,
-0xFE, 0x6F, 0xF0, 0x90, 0xFE, 0x70, 0xE0, 0x54,
-0xFC, 0xF0, 0x90, 0xFE, 0xC0, 0x74, 0xF6, 0xF0,
-0xA3, 0x74, 0x00, 0xF0, 0x90, 0xFE, 0x68, 0x74,
-0x31, 0xF0, 0x90, 0xE9, 0xD3, 0xE0, 0xF8, 0xC0,
-0x00, 0xC2, 0x08, 0xC2, 0x36, 0xC2, 0x37, 0x90,
-0xE9, 0xD0, 0xE0, 0xF8, 0xA3, 0xE0, 0xF9, 0xA3,
-0xE0, 0x90, 0xFE, 0x6B, 0xF0, 0xA3, 0xE9, 0xF0,
-0xA3, 0xE8, 0xF0, 0x90, 0xFE, 0x6E, 0x74, 0x81,
-0xF0, 0x90, 0xFE, 0xC4, 0x74, 0x23, 0xF0, 0x12,
-0xE7, 0xB0, 0x20, 0x36, 0x11, 0x20, 0x37, 0x0E,
-0x12, 0xE7, 0xBC, 0x30, 0x3E, 0xF4, 0x90, 0xFE,
-0xD8, 0x74, 0x01, 0xF0, 0xD2, 0x37, 0x30, 0x37,
-0x07, 0xD0, 0x00, 0x12, 0x2F, 0x5C, 0xC3, 0x22,
-0xC2, 0x09, 0x12, 0xE7, 0xB0, 0x20, 0x08, 0x0E,
-0x12, 0xE7, 0xBC, 0x30, 0x3E, 0xF7, 0x90, 0xFE,
-0xD8, 0x74, 0x01, 0xF0, 0xD2, 0x09, 0x20, 0x09,
-0xE0, 0x90, 0xE9, 0xD2, 0xE0, 0x24, 0x01, 0xF0,
-0x90, 0xE9, 0xD1, 0xE0, 0x34, 0x00, 0xF0, 0x90,
-0xE9, 0xD0, 0xE0, 0x34, 0x00, 0xF0, 0xD0, 0x00,
-0x18, 0xE8, 0x60, 0x03, 0x02, 0xE5, 0x4F, 0x12,
-0x2F, 0x5C, 0x75, 0x3C, 0x00, 0x75, 0x3D, 0x00,
-0x75, 0x3E, 0x00, 0x75, 0x3F, 0x00, 0xD3, 0x22,
-0x90, 0xE9, 0xD0, 0xE0, 0xF8, 0xA3, 0xE0, 0xF9,
-0xA3, 0xE0, 0x90, 0xFE, 0x6B, 0xF0, 0xA3, 0xE9,
-0xF0, 0xA3, 0xE8, 0xF0, 0x90, 0xFE, 0x68, 0x74,
-0x00, 0xF0, 0xC2, 0x08, 0x90, 0xFE, 0x6E, 0x74,
-0xB1, 0xF0, 0xC2, 0x09, 0x12, 0xE7, 0xB0, 0x20,
-0x08, 0x0E, 0x12, 0xE7, 0xBC, 0x30, 0x3E, 0xF7,
-0x90, 0xFE, 0xD8, 0x74, 0x01, 0xF0, 0xD2, 0x09,
-0x20, 0x09, 0x1E, 0x90, 0xFE, 0x70, 0xE0, 0x44,
-0x10, 0xF0, 0x54, 0xEF, 0xF0, 0x12, 0x2F, 0x59,
-0xEF, 0x60, 0x0E, 0x75, 0x3C, 0x00, 0x75, 0x3D,
-0x00, 0x75, 0x3E, 0x00, 0x75, 0x3F, 0x00, 0xD3,
-0x22, 0xC3, 0x22, 0x7B, 0x03, 0x7C, 0xE9, 0x7D,
-0xCD, 0x7E, 0xE9, 0x7F, 0xD7, 0x12, 0x2F, 0x71,
-0x12, 0xE3, 0xAA, 0x90, 0xE9, 0xD5, 0xE0, 0x60,
-0x12, 0xF9, 0x12, 0xE7, 0x17, 0x40, 0x01, 0x22,
-0x90, 0xF6, 0x00, 0x78, 0x06, 0x74, 0xFF, 0xF0,
-0xA3, 0xD8, 0xFC, 0x74, 0x01, 0x90, 0xE9, 0xCB,
-0xF0, 0xE5, 0x3E, 0xC3, 0x13, 0x90, 0xE9, 0xCA,
-0xF0, 0xC0, 0xE0, 0x75, 0xF0, 0x02, 0xC0, 0xF0,
-0x12, 0xE2, 0x2F, 0xEF, 0x70, 0x21, 0x20, 0x37,
-0x07, 0x20, 0x09, 0x04, 0xD0, 0xF0, 0x80, 0x05,
-0xD0, 0xF0, 0xD5, 0xF0, 0xE9, 0xD0, 0xE0, 0x90,
-0xFF, 0x28, 0xE0, 0x30, 0xE7, 0xFC, 0x90, 0xFF,
-0x28, 0xE0, 0x44, 0x01, 0xF0, 0xC3, 0x22, 0xD0,
-0xF0, 0x90, 0xE9, 0xD2, 0xE0, 0x24, 0x01, 0xF0,
-0x90, 0xE9, 0xD1, 0xE0, 0x34, 0x00, 0xF0, 0x90,
-0xE9, 0xD0, 0xE0, 0x34, 0x00, 0xF0, 0xD0, 0xE0,
-0x14, 0x70, 0xB6, 0x90, 0xE9, 0xD5, 0xE0, 0xF8,
-0x90, 0xE9, 0xCA, 0xE0, 0x28, 0xF5, 0xF0, 0xC3,
-0x74, 0x20, 0x95, 0xF0, 0x60, 0x22, 0xF9, 0x90,
-0xE9, 0xCA, 0xE0, 0xF5, 0xF0, 0x90, 0xE9, 0xCF,
-0xE0, 0x25, 0xF0, 0xF0, 0x90, 0xE9, 0xCE, 0xE0,
-0x34, 0x00, 0xF0, 0x90, 0xE9, 0xCD, 0xE0, 0x34,
-0x00, 0xF0, 0x12, 0xE7, 0x17, 0x40, 0x01, 0x22,
-0x90, 0xE9, 0xD6, 0xE0, 0x70, 0x13, 0x7B, 0x03,
-0x7C, 0xE9, 0x7D, 0xD7, 0x7E, 0xE9, 0x7F, 0xD0,
-0x12, 0x2F, 0x71, 0x12, 0xE5, 0xE0, 0x40, 0x01,
-0x22, 0x75, 0x3C, 0x00, 0x75, 0x3D, 0x00, 0x75,
-0x3E, 0x00, 0x75, 0x3F, 0x00, 0xD3, 0x22, 0x90,
-0xE9, 0xD6, 0xE0, 0x60, 0x18, 0x74, 0xFF, 0x90,
-0xF4, 0x00, 0x78, 0xFF, 0xF0, 0xA3, 0x18, 0xB8,
-0x00, 0xFA, 0x78, 0xFF, 0xF0, 0xA3, 0x18, 0xB8,
-0x00, 0xFA, 0xF0, 0xA3, 0xF0, 0xC0, 0x01, 0x12,
-0xE7, 0x70, 0x40, 0x04, 0xD0, 0x01, 0xC3, 0x22,
-0x90, 0xE9, 0xCF, 0xE0, 0x24, 0x01, 0xF0, 0x90,
-0xE9, 0xCE, 0xE0, 0x34, 0x00, 0xF0, 0x90, 0xE9,
-0xCD, 0xE0, 0x34, 0x00, 0xF0, 0x90, 0xE9, 0xD2,
-0xE0, 0x24, 0x01, 0xF0, 0x90, 0xE9, 0xD1, 0xE0,
-0x34, 0x00, 0xF0, 0x90, 0xE9, 0xD0, 0xE0, 0x34,
-0x00, 0xF0, 0xD0, 0x01, 0xD9, 0xC7, 0xD3, 0x22,
-0xC2, 0x06, 0x90, 0xE9, 0xD6, 0xE0, 0x70, 0x28,
-0x12, 0xE0, 0xD8, 0xEF, 0x60, 0x03, 0x02, 0xE7,
-0xA0, 0x90, 0xEB, 0xC2, 0xE0, 0x60, 0x17, 0x64,
-0x02, 0x60, 0x15, 0x90, 0xF6, 0x00, 0x78, 0x06,
-0x74, 0xFF, 0xF0, 0xA3, 0xD8, 0xFC, 0x74, 0xF0,
-0x90, 0xF6, 0x04, 0xF0, 0x80, 0x02, 0xC3, 0x22,
-0xE4, 0x90, 0xE9, 0xCB, 0xF0, 0x12, 0xE2, 0x2F,
-0xEF, 0x70, 0x03, 0x02, 0xE7, 0x81, 0xD3, 0x22,
-0xC2, 0x3E, 0x75, 0x7C, 0x00, 0x75, 0x7D, 0x00,
-0x75, 0x7E, 0x00, 0x22, 0x05, 0x7C, 0xE5, 0x7C,
-0x70, 0x14, 0x05, 0x7D, 0xE5, 0x7D, 0x70, 0x04,
-0x05, 0x7E, 0x80, 0x0A, 0xB4, 0x17, 0x07, 0xE5,
-0x7E, 0xB4, 0x06, 0x02, 0xD2, 0x3E, 0x22, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x58, 0x44, 0x2D, 0x52, 0x57, 0x20, 0x20, 0x20,
-0x20, 0x20, 0x20, 0x31, 0x30, 0x30, 0x30, 0x30 };
-
diff --git a/drivers/staging/keucr/scsiglue.c b/drivers/staging/keucr/scsiglue.c
deleted file mode 100644
index 7d8d444..0000000
--- a/drivers/staging/keucr/scsiglue.c
+++ /dev/null
@@ -1,467 +0,0 @@
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
-#include <scsi/scsi_devinfo.h>
-#include <scsi/scsi_device.h>
-#include <scsi/scsi_eh.h>
-
-#include "usb.h"
-#include "scsiglue.h"
-#include "transport.h"
-
-/* Host functions */
-/*
- * host_info()
- */
-static const char *host_info(struct Scsi_Host *host)
-{
-	/* pr_info("scsiglue --- host_info\n"); */
-	return "SCSI emulation for USB Mass Storage devices";
-}
-
-/*
- * slave_alloc()
- */
-static int slave_alloc(struct scsi_device *sdev)
-{
-	struct us_data *us = host_to_us(sdev->host);
-
-	/* pr_info("scsiglue --- slave_alloc\n"); */
-	sdev->inquiry_len = 36;
-
-	blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
-
-	if (us->subclass == USB_SC_UFI)
-		sdev->sdev_target->pdt_1f_for_no_lun = 1;
-
-	return 0;
-}
-
-/*
- * slave_configure()
- */
-static int slave_configure(struct scsi_device *sdev)
-{
-	struct us_data *us = host_to_us(sdev->host);
-
-	/* pr_info("scsiglue --- slave_configure\n"); */
-	if (us->fflags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) {
-		unsigned int max_sectors = 64;
-
-		if (us->fflags & US_FL_MAX_SECTORS_MIN)
-			max_sectors = PAGE_CACHE_SIZE >> 9;
-		if (queue_max_sectors(sdev->request_queue) > max_sectors)
-			blk_queue_max_hw_sectors(sdev->request_queue,
-					      max_sectors);
-	}
-
-	if (sdev->type == TYPE_DISK) {
-		if (us->subclass != USB_SC_SCSI &&
-			us->subclass != USB_SC_CYP_ATACB)
-			sdev->use_10_for_ms = 1;
-		sdev->use_192_bytes_for_3f = 1;
-		if (us->fflags & US_FL_NO_WP_DETECT)
-			sdev->skip_ms_page_3f = 1;
-		sdev->skip_ms_page_8 = 1;
-		if (us->fflags & US_FL_FIX_CAPACITY)
-			sdev->fix_capacity = 1;
-		if (us->fflags & US_FL_CAPACITY_HEURISTICS)
-			sdev->guess_capacity = 1;
-		if (sdev->scsi_level > SCSI_2)
-			sdev->sdev_target->scsi_level = sdev->scsi_level
-								= SCSI_2;
-		sdev->retry_hwerror = 1;
-		sdev->allow_restart = 1;
-		sdev->last_sector_bug = 1;
-	} else {
-		sdev->use_10_for_ms = 1;
-	}
-
-	if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_CBI) &&
-					sdev->scsi_level == SCSI_UNKNOWN)
-		us->max_lun = 0;
-
-	if (us->fflags & US_FL_NOT_LOCKABLE)
-		sdev->lockable = 0;
-
-	return 0;
-}
-
-/* This is always called with scsi_lock(host) held */
-/*
- * queuecommand()
- */
-static int queuecommand_lck(struct scsi_cmnd *srb,
-				void (*done)(struct scsi_cmnd *))
-{
-	struct us_data *us = host_to_us(srb->device->host);
-
-	/* pr_info("scsiglue --- queuecommand\n"); */
-
-	/* check for state-transition errors */
-	if (us->srb != NULL) {
-		/* pr_info("Error in %s: us->srb = %p\n"
-				 __func__, us->srb); */
-		return SCSI_MLQUEUE_HOST_BUSY;
-	}
-
-	/* fail the command if we are disconnecting */
-	if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
-		pr_info("Fail command during disconnect\n");
-		srb->result = DID_NO_CONNECT << 16;
-		done(srb);
-		return 0;
-	}
-
-	/* enqueue the command and wake up the control thread */
-	srb->scsi_done = done;
-	us->srb = srb;
-	complete(&us->cmnd_ready);
-
-	return 0;
-}
-
-static DEF_SCSI_QCMD(queuecommand)
-
-/***********************************************************************
- * Error handling functions
- ***********************************************************************/
-
-/* Command timeout and abort */
-/*
- * command_abort()
- */
-static int command_abort(struct scsi_cmnd *srb)
-{
-	struct us_data *us = host_to_us(srb->device->host);
-
-	/* pr_info("scsiglue --- command_abort\n"); */
-
-	scsi_lock(us_to_host(us));
-	if (us->srb != srb) {
-		scsi_unlock(us_to_host(us));
-		dev_info(&us->pusb_dev->dev, "-- nothing to abort\n");
-		return FAILED;
-	}
-
-	set_bit(US_FLIDX_TIMED_OUT, &us->dflags);
-	if (!test_bit(US_FLIDX_RESETTING, &us->dflags)) {
-		set_bit(US_FLIDX_ABORTING, &us->dflags);
-		usb_stor_stop_transport(us);
-	}
-	scsi_unlock(us_to_host(us));
-
-	/* Wait for the aborted command to finish */
-	wait_for_completion(&us->notify);
-	return SUCCESS;
-}
-
-/* This invokes the transport reset mechanism to reset the state of the
- * device.
- */
-/*
- * device_reset()
- */
-static int device_reset(struct scsi_cmnd *srb)
-{
-	struct us_data *us = host_to_us(srb->device->host);
-	int result;
-
-	/* pr_info("scsiglue --- device_reset\n"); */
-
-	/* lock the device pointers and do the reset */
-	mutex_lock(&(us->dev_mutex));
-	result = us->transport_reset(us);
-	mutex_unlock(&us->dev_mutex);
-
-	return result < 0 ? FAILED : SUCCESS;
-}
-
-/*
- * bus_reset()
- */
-static int bus_reset(struct scsi_cmnd *srb)
-{
-	struct us_data *us = host_to_us(srb->device->host);
-	int result;
-
-	/* pr_info("scsiglue --- bus_reset\n"); */
-	result = usb_stor_port_reset(us);
-	return result < 0 ? FAILED : SUCCESS;
-}
-
-/*
- * usb_stor_report_device_reset()
- */
-void usb_stor_report_device_reset(struct us_data *us)
-{
-	int i;
-	struct Scsi_Host *host = us_to_host(us);
-
-	/* pr_info("scsiglue --- usb_stor_report_device_reset\n"); */
-	scsi_report_device_reset(host, 0, 0);
-	if (us->fflags & US_FL_SCM_MULT_TARG) {
-		for (i = 1; i < host->max_id; ++i)
-			scsi_report_device_reset(host, 0, i);
-	}
-}
-
-/*
- * usb_stor_report_bus_reset()
- */
-void usb_stor_report_bus_reset(struct us_data *us)
-{
-	struct Scsi_Host *host = us_to_host(us);
-
-	/* pr_info("scsiglue --- usb_stor_report_bus_reset\n"); */
-	scsi_lock(host);
-	scsi_report_bus_reset(host, 0);
-	scsi_unlock(host);
-}
-
-/***********************************************************************
- * /proc/scsi/ functions
- ***********************************************************************/
-
-/* we use this macro to help us write into the buffer */
-#undef SPRINTF
-#define SPRINTF(args...) seq_printf(m, ##args)
-
-static int write_info(struct Scsi_Host *host, char *buffer, int length)
-{
-	return length;
-}
-
-static int show_info(struct seq_file *m, struct Scsi_Host *host)
-{
-	struct us_data *us = host_to_us(host);
-	const char *string;
-
-	/* print the controller name */
-	SPRINTF("   Host scsi%d: usb-storage\n", host->host_no);
-
-	/* print product, vendor, and serial number strings */
-	if (us->pusb_dev->manufacturer)
-		string = us->pusb_dev->manufacturer;
-	else if (us->unusual_dev->vendorName)
-		string = us->unusual_dev->vendorName;
-	else
-		string = "Unknown";
-	SPRINTF("       Vendor: %s\n", string);
-	if (us->pusb_dev->product)
-		string = us->pusb_dev->product;
-	else if (us->unusual_dev->productName)
-		string = us->unusual_dev->productName;
-	else
-		string = "Unknown";
-	SPRINTF("      Product: %s\n", string);
-	if (us->pusb_dev->serial)
-		string = us->pusb_dev->serial;
-	else
-		string = "None";
-	SPRINTF("Serial Number: %s\n", string);
-
-	/* show the protocol and transport */
-	SPRINTF("     Protocol: %s\n", us->protocol_name);
-	SPRINTF("    Transport: %s\n", us->transport_name);
-
-	/* show the device flags */
-	SPRINTF("       Quirks:");
-
-#define US_FLAG(name, value) \
-	do { \
-		if (us->fflags & value) \
-			SPRINTF(" " #name); \
-	} while (0);
-US_DO_ALL_FLAGS
-#undef US_FLAG
-	seq_putc(m, '\n');
-	return 0;
-}
-
-/***********************************************************************
- * Sysfs interface
- ***********************************************************************/
-
-/* Output routine for the sysfs max_sectors file */
-static ssize_t max_sectors_show(struct device *dev,
-				struct device_attribute *attr, char *buf)
-{
-	struct scsi_device *sdev = to_scsi_device(dev);
-
-	/* pr_info("scsiglue --- ssize_t show_max_sectors\n"); */
-	return sprintf(buf, "%u\n", queue_max_sectors(sdev->request_queue));
-}
-
-/* Input routine for the sysfs max_sectors file */
-static ssize_t max_sectors_store(struct device *dev,
-				struct device_attribute *attr,
-				const char *buf, size_t count)
-{
-	struct scsi_device *sdev = to_scsi_device(dev);
-	unsigned short ms;
-
-	/* pr_info("scsiglue --- ssize_t store_max_sectors\n"); */
-	if (sscanf(buf, "%hu", &ms) > 0 && ms <= SCSI_DEFAULT_MAX_SECTORS) {
-		blk_queue_max_hw_sectors(sdev->request_queue, ms);
-		return strlen(buf);
-	}
-	return -EINVAL;
-}
-static DEVICE_ATTR_RW(max_sectors);
-
-static struct device_attribute *sysfs_device_attr_list[] = {
-	&dev_attr_max_sectors, NULL,
-};
-
-/* this defines our host template, with which we'll allocate hosts */
-
-/*
- * usb_stor_host_template()
- */
-struct scsi_host_template usb_stor_host_template = {
-	/* basic userland interface stuff */
-	.name =				"eucr-storage",
-	.proc_name =			"eucr-storage",
-	.write_info =			write_info,
-	.show_info =			show_info,
-	.info =				host_info,
-
-	/* command interface -- queued only */
-	.queuecommand =			queuecommand,
-
-	/* error and abort handlers */
-	.eh_abort_handler =		command_abort,
-	.eh_device_reset_handler =	device_reset,
-	.eh_bus_reset_handler =		bus_reset,
-
-	/* queue commands only, only one command per LUN */
-	.can_queue =			1,
-	.cmd_per_lun =			1,
-
-	/* unknown initiator id */
-	.this_id =			-1,
-
-	.slave_alloc =			slave_alloc,
-	.slave_configure =		slave_configure,
-
-	/* lots of sg segments can be handled */
-	.sg_tablesize =			SG_ALL,
-
-	/* limit the total size of a transfer to 120 KB */
-	.max_sectors =                  240,
-
-	/* merge commands... this seems to help performance, but
-	 * periodically someone should test to see which setting is more
-	 * optimal.
-	 */
-	.use_clustering =		1,
-
-	/* emulated HBA */
-	.emulated =			1,
-
-	/* we do our own delay after a device or bus reset */
-	.skip_settle_delay =		1,
-
-	/* sysfs device attributes */
-	.sdev_attrs =			sysfs_device_attr_list,
-
-	/* module management */
-	.module =			THIS_MODULE
-};
-
-/* To Report "Illegal Request: Invalid Field in CDB */
-unsigned char usb_stor_sense_invalidCDB[18] = {
-	[0]	= 0x70,			    /* current error */
-	[2]	= ILLEGAL_REQUEST,	    /* Illegal Request = 0x05 */
-	[7]	= 0x0a,			    /* additional length */
-	[12]	= 0x24			    /* Invalid Field in CDB */
-};
-
-/***********************************************************************
- * Scatter-gather transfer buffer access routines
- ***********************************************************************/
-
-/*
- * usb_stor_access_xfer_buf()
- */
-unsigned int usb_stor_access_xfer_buf(struct us_data *us,
-	unsigned char *buffer, unsigned int buflen,
-	struct scsi_cmnd *srb, struct scatterlist **sgptr,
-	unsigned int *offset, enum xfer_buf_dir dir)
-{
-	unsigned int cnt;
-
-	/* pr_info("transport --- usb_stor_access_xfer_buf\n"); */
-	struct scatterlist *sg = *sgptr;
-
-	if (!sg)
-		sg = scsi_sglist(srb);
-
-	cnt = 0;
-	while (cnt < buflen && sg) {
-		struct page *page = sg_page(sg) +
-					((sg->offset + *offset) >> PAGE_SHIFT);
-		unsigned int poff = (sg->offset + *offset) & (PAGE_SIZE-1);
-		unsigned int sglen = sg->length - *offset;
-
-		if (sglen > buflen - cnt) {
-			/* Transfer ends within this s-g entry */
-			sglen = buflen - cnt;
-			*offset += sglen;
-		} else {
-			/* Transfer continues to next s-g entry */
-			*offset = 0;
-			sg = sg_next(sg);
-		}
-
-		while (sglen > 0) {
-			unsigned int plen = min(sglen,
-					(unsigned int)PAGE_SIZE - poff);
-			unsigned char *ptr = kmap(page);
-
-			if (dir == TO_XFER_BUF)
-				memcpy(ptr + poff, buffer + cnt, plen);
-			else
-				memcpy(buffer + cnt, ptr + poff, plen);
-			kunmap(page);
-
-			/* Start at the beginning of the next page */
-			poff = 0;
-			++page;
-			cnt += plen;
-			sglen -= plen;
-		}
-	}
-	*sgptr = sg;
-
-	/* Return the amount actually transferred */
-	return cnt;
-}
-
-/*
- * Store the contents of buffer into srb's transfer
- * buffer and set the SCSI residue.
- */
-/*
- * usb_stor_set_xfer_buf()
- */
-void usb_stor_set_xfer_buf(struct us_data *us, unsigned char *buffer,
-		unsigned int buflen, struct scsi_cmnd *srb, unsigned int dir)
-{
-	unsigned int offset = 0;
-	struct scatterlist *sg = NULL;
-
-	/* pr_info("transport --- usb_stor_set_xfer_buf\n"); */
-	/* TO_XFER_BUF = 0, FROM_XFER_BUF = 1 */
-	buflen = min(buflen, scsi_bufflen(srb));
-	buflen = usb_stor_access_xfer_buf(us, buffer, buflen, srb,
-						&sg, &offset, dir);
-	if (buflen < scsi_bufflen(srb))
-		scsi_set_resid(srb, scsi_bufflen(srb) - buflen);
-}
diff --git a/drivers/staging/keucr/scsiglue.h b/drivers/staging/keucr/scsiglue.h
deleted file mode 100644
index c7e59f0..0000000
--- a/drivers/staging/keucr/scsiglue.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef _SCSIGLUE_H_
-#define _SCSIGLUE_H_
-
-extern void usb_stor_report_device_reset(struct us_data *us);
-extern void usb_stor_report_bus_reset(struct us_data *us);
-
-extern unsigned char usb_stor_sense_invalidCDB[18];
-extern struct scsi_host_template usb_stor_host_template;
-
-#endif
diff --git a/drivers/staging/keucr/smcommon.h b/drivers/staging/keucr/smcommon.h
deleted file mode 100644
index 1d2752a..0000000
--- a/drivers/staging/keucr/smcommon.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*----- < SMCommon.h> --------------------------------------------------*/
-#ifndef SMCOMMON_INCD
-#define SMCOMMON_INCD
-
-
-/***************************************************************************
-Define Definition
-***************************************************************************/
-#define SMSUCCESS           0x0000 /* SUCCESS */
-#define ERROR               0xFFFF /* ERROR */
-#define CORRECT             0x0001 /* CORRECTABLE */
-
-/***************************************************************************/
-#define NO_ERROR            0x0000 /* NO ERROR */
-#define ERR_WriteFault      0x0003 /* Peripheral Device Write Fault */
-#define ERR_HwError         0x0004 /* Hardware Error */
-#define ERR_DataStatus      0x0010 /* DataStatus Error */
-#define ERR_EccReadErr      0x0011 /* Unrecovered Read Error */
-#define ERR_CorReadErr      0x0018 /* Recovered Read Data with ECC */
-#define ERR_OutOfLBA        0x0021 /* Illegal Logical Block Address */
-#define ERR_WrtProtect      0x0027 /* Write Protected */
-#define ERR_ChangedMedia    0x0028 /* Medium Changed */
-#define ERR_UnknownMedia    0x0030 /* Incompatible Medium Installed */
-#define ERR_IllegalFmt      0x0031 /* Medium Format Corrupted */
-#define ERR_NoSmartMedia    0x003A /* Medium Not Present */
-
-/***************************************************************************/
-
-#endif
diff --git a/drivers/staging/keucr/smil.h b/drivers/staging/keucr/smil.h
deleted file mode 100644
index f938759..0000000
--- a/drivers/staging/keucr/smil.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/*----- < smil.h> ----------------------------------------------------*/
-#ifndef SMIL_INCD
-#define SMIL_INCD
-
-/***************************************************************************
-Define Definition
-***************************************************************************/
-#define K_BYTE              1024   /* Kilo Byte */
-#define SECTSIZE            512    /* Sector buffer size */
-#define REDTSIZE            16     /* Redundant buffer size */
-
-/***************************************************************************/
-#define DUMMY_DATA          0xFF   /* No Assign Sector Read Data */
-
-/***************************************************************************
-Max Zone/Block/Sectors Data Definition
-***************************************************************************/
-#define MAX_ZONENUM         128    /* Max Zone Numbers in a SmartMedia    */
-#define MAX_BLOCKNUM        0x0400 /* Max Block Numbers in a Zone         */
-#define MAX_SECTNUM         0x20   /* Max Sector Numbers in a Block       */
-#define MAX_LOGBLOCK        1000   /* Max Logical Block Numbers in a Zone */
-
-/***************************************************************************/
-#define CIS_SEARCH_SECT     0x08   /* Max CIS Search Sector Number */
-
-/***************************************************************************
-Logical to Physical Block Table Data Definition
-***************************************************************************/
-#define NO_ASSIGN           0xFFFF /* No Assign Logical Block Address */
-
-/***************************************************************************
-'SectCopyMode' Data
-***************************************************************************/
-#define COMPLETED           0      /* Sector Copy Completed */
-#define REQ_ERASE           1      /* Request Read Block Erase */
-#define REQ_FAIL            2      /* Request Read Block Failed */
-
-/***************************************************************************
-Retry Counter Definition
-***************************************************************************/
-#define RDERR_REASSIGN      1      /* Reassign with Read Error */
-#define L2P_ERR_ERASE       1      /* BlockErase for Contradicted L2P Table */
-
-/***************************************************************************
-Hardware ECC Definition
-***************************************************************************/
-#define HW_ECC_SUPPORTED    1	   /* Hardware ECC Supported */
-/* No definition for Software ECC */
-
-/***************************************************************************
-SmartMedia Command & Status Definition
-***************************************************************************/
-/* SmartMedia Command */
-#define WRDATA        0x80
-/* #define READ          0x00 */
-#define READ_REDT     0x50
-/* #define WRITE         0x10 */
-#define RDSTATUS      0x70
-
-#define READ1         0x00 /* NO */
-#define READ2         0x01 /* NO */
-#define READ3         0x50 /* NO */
-#define RST_CHIP      0xFF
-#define ERASE1        0x60
-#define ERASE2        0xD0
-#define READ_ID_1     0x90
-#define READ_ID_2     0x91
-#define READ_ID_3     0x9A
-
-/* 712 SmartMedia Command */
-#define SM_CMD_RESET                0x00    /* 0xFF */
-#define SM_CMD_READ_ID_1            0x10    /* 0x90 */
-#define SM_CMD_READ_ID_2            0x20    /* 0x91 */
-#define SM_CMD_READ_STAT            0x30    /* 0x70 */
-#define SM_CMD_RDMULTPL_STAT        0x40    /* 0x71 */
-#define SM_CMD_READ_1               0x50    /* 0x00 */
-#define SM_CMD_READ_2               0x60    /* 0x01 */
-#define SM_CMD_READ_3               0x70    /* 0x50 */
-#define SM_CMD_PAGPRGM_TRUE         0x80    /* {0x80, 0x10} */
-#define SM_CMD_PAGPRGM_DUMY         0x90    /* {0x80, 0x11} */
-#define SM_CMD_PAGPRGM_MBLK         0xA0    /* {0x80, 0x15} */
-#define SM_CMD_BLKERASE             0xB0    /* {0x60, 0xD0} */
-#define SM_CMD_BLKERASE_MULTPL      0xC0    /* {0x60-0x60, 0xD0} */
-
-#define SM_CRADDTCT_DEBNCETIMER_EN  0x02
-#define SM_CMD_START_BIT            0x01
-
-#define SM_WaitCmdDone { while (!SM_CmdDone); }
-#define SM_WaitDmaDone { while (!SM_DmaDone); }
-
-/* SmartMedia Status */
-#define WR_FAIL       0x01      /* 0:Pass, 1:Fail */
-#define SUSPENDED     0x20      /* 0:Not Suspended, 1:Suspended */
-#define READY         0x40      /* 0:Busy, 1:Ready */
-#define WR_PRTCT      0x80      /* 0:Protect, 1:Not Protect */
-
-/* SmartMedia Busy Time (1bit:0.1ms) */
-#define BUSY_PROG 200 /* tPROG   : 20ms  ----- Program Time old : 200 */
-#define BUSY_ERASE 4000 /* tBERASE : 400ms ----- Block Erase Time old : 4000 */
-
-/*for 712 Test */
-/* #define BUSY_READ 1 *//* tR : 100us ----- Data transfer Time   old : 1 */
-/* #define BUSY_READ 10 *//* tR : 100us ----- Data transfer Time   old : 1 */
-
-#define BUSY_READ 200 /* tR : 20ms   ----- Data transfer Time   old : 1 */
-
-/* #define BUSY_RESET 60 *//* tRST : 6ms ----- Device Resetting Time old : 60 */
-
-#define BUSY_RESET 600 /* tRST : 60ms   ----- Device Resetting Time old : 60 */
-
-/* Hardware Timer (1bit:0.1ms) */
-#define TIME_PON      3000      /* 300ms ------ Power On Wait Time */
-#define TIME_CDCHK    200       /* 20ms  ------ Card Check Interval Timer */
-#define TIME_WPCHK    50        /* 5ms   ------ WP Check Interval Timer */
-#define TIME_5VCHK    10        /* 1ms   ------ 5V Check Interval Timer */
-
-/***************************************************************************
-Redundant Data
-***************************************************************************/
-#define REDT_DATA     0x04
-#define REDT_BLOCK    0x05
-#define REDT_ADDR1H   0x06
-#define REDT_ADDR1L   0x07
-#define REDT_ADDR2H   0x0B
-#define REDT_ADDR2L   0x0C
-#define REDT_ECC10    0x0D
-#define REDT_ECC11    0x0E
-#define REDT_ECC12    0x0F
-#define REDT_ECC20    0x08
-#define REDT_ECC21    0x09
-#define REDT_ECC22    0x0A
-
-/***************************************************************************
-SmartMedia Model & Attribute
-***************************************************************************/
-/* SmartMedia Attribute */
-#define NOWP          0x00 /* 0... .... No Write Protect */
-#define WP            0x80 /* 1... .... Write Protected */
-#define MASK          0x00 /* .00. .... NAND MASK ROM Model */
-#define FLASH         0x20 /* .01. .... NAND Flash ROM Model */
-#define AD3CYC        0x00 /* ...0 .... Address 3-cycle */
-#define AD4CYC        0x10 /* ...1 .... Address 4-cycle */
-#define BS16          0x00 /* .... 00.. 16page/block */
-#define BS32          0x04 /* .... 01.. 32page/block */
-#define PS256         0x00 /* .... ..00 256byte/page */
-#define PS512         0x01 /* .... ..01 512byte/page */
-#define MWP           0x80 /* WriteProtect mask */
-#define MFLASH        0x60 /* Flash Rom mask */
-#define MADC          0x10 /* Address Cycle */
-#define MBS           0x0C /* BlockSize mask */
-#define MPS           0x03 /* PageSize mask */
-
-/* SmartMedia Model */
-#define NOSSFDC       0x00 /* NO   SmartMedia */
-#define SSFDC1MB      0x01 /* 1MB  SmartMedia */
-#define SSFDC2MB      0x02 /* 2MB  SmartMedia */
-#define SSFDC4MB      0x03 /* 4MB  SmartMedia */
-#define SSFDC8MB      0x04 /* 8MB  SmartMedia */
-#define SSFDC16MB     0x05 /* 16MB SmartMedia */
-#define SSFDC32MB     0x06 /* 32MB SmartMedia */
-#define SSFDC64MB     0x07 /* 64MB SmartMedia */
-#define SSFDC128MB    0x08 /*128MB SmartMedia */
-#define SSFDC256MB    0x09
-#define SSFDC512MB    0x0A
-#define SSFDC1GB      0x0B
-#define SSFDC2GB      0x0C
-
-/***************************************************************************
-Struct Definition
-***************************************************************************/
-struct keucr_media_info {
-	u8 Model;
-	u8 Attribute;
-	u8 MaxZones;
-	u8 MaxSectors;
-	u16 MaxBlocks;
-	u16 MaxLogBlocks;
-};
-
-struct keucr_media_address {
-	u8 Zone;	/* Zone Number */
-	u8 Sector;	/* Sector(512byte) Number on Block */
-	u16 PhyBlock;	/* Physical Block Number on Zone */
-	u16 LogBlock;	/* Logical Block Number of Zone */
-};
-
-struct keucr_media_area {
-	u8 Sector;	/* Sector(512byte) Number on Block */
-	u16 PhyBlock;	/* Physical Block Number on Zone 0 */
-};
-
-extern u16	ReadBlock;
-extern u16	WriteBlock;
-extern u32	MediaChange;
-
-extern struct keucr_media_info    Ssfdc;
-extern struct keucr_media_address Media;
-extern struct keucr_media_area    CisArea;
-
-/*
- * SMILMain.c
- */
-/******************************************/
-int         Init_D_SmartMedia(void);
-int         Pwoff_D_SmartMedia(void);
-int         Check_D_SmartMedia(void);
-int         Check_D_MediaFmt(struct us_data *);
-int         Check_D_Parameter(struct us_data *, u16 *, u8 *, u8 *);
-int         Media_D_ReadSector(struct us_data *, u32, u16, u8 *);
-int         Media_D_WriteSector(struct us_data *, u32, u16, u8 *);
-int         Media_D_CopySector(struct us_data *, u32, u16, u8 *);
-int         Media_D_EraseBlock(struct us_data *, u32, u16);
-int         Media_D_EraseAll(struct us_data *);
-/******************************************/
-int         Media_D_OneSectWriteStart(struct us_data *, u32, u8 *);
-int         Media_D_OneSectWriteNext(struct us_data *, u8 *);
-int         Media_D_OneSectWriteFlush(struct us_data *);
-
-/******************************************/
-extern int	SM_FreeMem(void);	/* ENE SM function */
-void        SM_EnableLED(struct us_data *, bool);
-void        Led_D_TernOn(void);
-void        Led_D_TernOff(void);
-
-int         Media_D_EraseAllRedtData(u32 Index, bool CheckBlock);
-/*DWORD Media_D_GetMediaInfo(struct us_data * fdoExt,
-	PIOCTL_MEDIA_INFO_IN pParamIn, PIOCTL_MEDIA_INFO_OUT pParamOut); */
-
-/*
- * SMILSub.c
- */
-/******************************************/
-int  Check_D_DataBlank(u8 *);
-int  Check_D_FailBlock(u8 *);
-int  Check_D_DataStatus(u8 *);
-int  Load_D_LogBlockAddr(u8 *);
-void Clr_D_RedundantData(u8 *);
-void Set_D_LogBlockAddr(u8 *);
-void Set_D_FailBlock(u8 *);
-void Set_D_DataStaus(u8 *);
-
-/******************************************/
-void Ssfdc_D_Reset(struct us_data *);
-int  Ssfdc_D_ReadCisSect(struct us_data *, u8 *, u8 *);
-void Ssfdc_D_WriteRedtMode(void);
-void Ssfdc_D_ReadID(u8 *, u8);
-int  Ssfdc_D_ReadSect(struct us_data *, u8 *, u8 *);
-int  Ssfdc_D_ReadBlock(struct us_data *, u16, u8 *, u8 *);
-int  Ssfdc_D_WriteSect(struct us_data *, u8 *, u8 *);
-int  Ssfdc_D_WriteBlock(struct us_data *, u16, u8 *, u8 *);
-int  Ssfdc_D_CopyBlock(struct us_data *, u16, u8 *, u8 *);
-int  Ssfdc_D_WriteSectForCopy(struct us_data *, u8 *, u8 *);
-int  Ssfdc_D_EraseBlock(struct us_data *);
-int  Ssfdc_D_ReadRedtData(struct us_data *, u8 *);
-int  Ssfdc_D_WriteRedtData(struct us_data *, u8 *);
-int  Ssfdc_D_CheckStatus(void);
-int  Set_D_SsfdcModel(u8);
-void Cnt_D_Reset(void);
-int  Cnt_D_PowerOn(void);
-void Cnt_D_PowerOff(void);
-void Cnt_D_LedOn(void);
-void Cnt_D_LedOff(void);
-int  Check_D_CntPower(void);
-int  Check_D_CardExist(void);
-int  Check_D_CardStsChg(void);
-int  Check_D_SsfdcWP(void);
-int  SM_ReadBlock(struct us_data *, u8 *, u8 *);
-
-int  Ssfdc_D_ReadSect_DMA(struct us_data *, u8 *, u8 *);
-int  Ssfdc_D_ReadSect_PIO(struct us_data *, u8 *, u8 *);
-int  Ssfdc_D_WriteSect_DMA(struct us_data *, u8 *, u8 *);
-int  Ssfdc_D_WriteSect_PIO(struct us_data *, u8 *, u8 *);
-
-/******************************************/
-int  Check_D_ReadError(u8 *);
-int  Check_D_Correct(u8 *, u8 *);
-int  Check_D_CISdata(u8 *, u8 *);
-void Set_D_RightECC(u8 *);
-
-/*
- * SMILECC.c
- */
-void calculate_ecc(u8 *, u8 *, u8 *, u8 *, u8 *);
-u8 correct_data(u8 *, u8 *, u8,   u8,   u8);
-int  _Correct_D_SwECC(u8 *, u8 *, u8 *);
-void _Calculate_D_SwECC(u8 *, u8 *);
-
-#endif /* already included */
diff --git a/drivers/staging/keucr/smilecc.c b/drivers/staging/keucr/smilecc.c
deleted file mode 100644
index ffe6030..0000000
--- a/drivers/staging/keucr/smilecc.c
+++ /dev/null
@@ -1,211 +0,0 @@
-#include "usb.h"
-#include "scsiglue.h"
-#include "transport.h"
-/* #include "stdlib.h" */
-/* #include "EUCR6SK.h" */
-#include "smcommon.h"
-#include "smil.h"
-
-/* #include <stdio.h> */
-/* #include <stdlib.h> */
-/* #include <string.h> */
-/* #include <dos.h> */
-/* #include "EMCRIOS.h" */
-
-/* CP0-CP5 code table */
-static u8 ecctable[256] = {
-0x00, 0x55, 0x56, 0x03, 0x59, 0x0C, 0x0F, 0x5A, 0x5A, 0x0F, 0x0C, 0x59, 0x03,
-0x56, 0x55, 0x00, 0x65, 0x30, 0x33, 0x66, 0x3C, 0x69, 0x6A, 0x3F, 0x3F, 0x6A,
-0x69, 0x3C, 0x66, 0x33, 0x30, 0x65, 0x66, 0x33, 0x30, 0x65, 0x3F, 0x6A, 0x69,
-0x3C, 0x3C, 0x69, 0x6A, 0x3F, 0x65, 0x30, 0x33, 0x66, 0x03, 0x56, 0x55, 0x00,
-0x5A, 0x0F, 0x0C, 0x59, 0x59, 0x0C, 0x0F, 0x5A, 0x00, 0x55, 0x56, 0x03, 0x69,
-0x3C, 0x3F, 0x6A, 0x30, 0x65, 0x66, 0x33, 0x33, 0x66, 0x65, 0x30, 0x6A, 0x3F,
-0x3C, 0x69, 0x0C, 0x59, 0x5A, 0x0F, 0x55, 0x00, 0x03, 0x56, 0x56, 0x03, 0x00,
-0x55, 0x0F, 0x5A, 0x59, 0x0C, 0x0F, 0x5A, 0x59, 0x0C, 0x56, 0x03, 0x00, 0x55,
-0x55, 0x00, 0x03, 0x56, 0x0C, 0x59, 0x5A, 0x0F, 0x6A, 0x3F, 0x3C, 0x69, 0x33,
-0x66, 0x65, 0x30, 0x30, 0x65, 0x66, 0x33, 0x69, 0x3C, 0x3F, 0x6A, 0x6A, 0x3F,
-0x3C, 0x69, 0x33, 0x66, 0x65, 0x30, 0x30, 0x65, 0x66, 0x33, 0x69, 0x3C, 0x3F,
-0x6A, 0x0F, 0x5A, 0x59, 0x0C, 0x56, 0x03, 0x00, 0x55, 0x55, 0x00, 0x03, 0x56,
-0x0C, 0x59, 0x5A, 0x0F, 0x0C, 0x59, 0x5A, 0x0F, 0x55, 0x00, 0x03, 0x56, 0x56,
-0x03, 0x00, 0x55, 0x0F, 0x5A, 0x59, 0x0C, 0x69, 0x3C, 0x3F, 0x6A, 0x30, 0x65,
-0x66, 0x33, 0x33, 0x66, 0x65, 0x30, 0x6A, 0x3F, 0x3C, 0x69, 0x03, 0x56, 0x55,
-0x00, 0x5A, 0x0F, 0x0C, 0x59, 0x59, 0x0C, 0x0F, 0x5A, 0x00, 0x55, 0x56, 0x03,
-0x66, 0x33, 0x30, 0x65, 0x3F, 0x6A, 0x69, 0x3C, 0x3C, 0x69, 0x6A, 0x3F, 0x65,
-0x30, 0x33, 0x66, 0x65, 0x30, 0x33, 0x66, 0x3C, 0x69, 0x6A, 0x3F, 0x3F, 0x6A,
-0x69, 0x3C, 0x66, 0x33, 0x30, 0x65, 0x00, 0x55, 0x56, 0x03, 0x59, 0x0C, 0x0F,
-0x5A, 0x5A, 0x0F, 0x0C, 0x59, 0x03, 0x56, 0x55, 0x00
-};
-
-static void   trans_result(u8,   u8,   u8 *, u8 *);
-
-#define BIT7        0x80
-#define BIT6        0x40
-#define BIT5        0x20
-#define BIT4        0x10
-#define BIT3        0x08
-#define BIT2        0x04
-#define BIT1        0x02
-#define BIT0        0x01
-#define BIT1BIT0    0x03
-#define BIT23       0x00800000L
-#define MASK_CPS    0x3f
-#define CORRECTABLE 0x00555554L
-
-/*
- * reg2; * LP14,LP12,LP10,...
- * reg3; * LP15,LP13,LP11,...
- * *ecc1; * LP15,LP14,LP13,...
- * *ecc2; * LP07,LP06,LP05,...
- */
-static void trans_result(u8 reg2, u8 reg3, u8 *ecc1, u8 *ecc2)
-{
-	u8 a; /* Working for reg2,reg3 */
-	u8 b; /* Working for ecc1,ecc2 */
-	u8 i; /* For counting */
-
-	a = BIT7; b = BIT7; /* 80h=10000000b */
-	*ecc1 = *ecc2 = 0; /* Clear ecc1,ecc2 */
-	for (i = 0; i < 4; ++i) {
-		if ((reg3&a) != 0)
-			*ecc1 |= b; /* LP15,13,11,9 -> ecc1 */
-		b = b>>1; /* Right shift */
-		if ((reg2&a) != 0)
-			*ecc1 |= b; /* LP14,12,10,8 -> ecc1 */
-		b = b>>1; /* Right shift */
-		a = a>>1; /* Right shift */
-	}
-
-	b = BIT7; /* 80h=10000000b */
-	for (i = 0; i < 4; ++i) {
-		if ((reg3&a) != 0)
-			*ecc2 |= b; /* LP7,5,3,1 -> ecc2 */
-		b = b>>1; /* Right shift */
-		if ((reg2&a) != 0)
-			*ecc2 |= b; /* LP6,4,2,0 -> ecc2 */
-		b = b>>1; /* Right shift */
-		a = a>>1; /* Right shift */
-	}
-}
-
-/*static void calculate_ecc(table,data,ecc1,ecc2,ecc3) */
-/*
- * *table; * CP0-CP5 code table
- * *data; * DATA
- * *ecc1; * LP15,LP14,LP13,...
- * *ecc2; * LP07,LP06,LP05,...
- * *ecc3; * CP5,CP4,CP3,...,"1","1"
- */
-void calculate_ecc(u8 *table, u8 *data, u8 *ecc1, u8 *ecc2, u8 *ecc3)
-{
-	u32  i;    /* For counting */
-	u8 a;    /* Working for table */
-	u8 reg1; /* D-all,CP5,CP4,CP3,... */
-	u8 reg2; /* LP14,LP12,L10,... */
-	u8 reg3; /* LP15,LP13,L11,... */
-
-	reg1 = reg2 = reg3 = 0;   /* Clear parameter */
-	for (i = 0; i < 256; ++i) {
-		a = table[data[i]]; /* Get CP0-CP5 code from table */
-		reg1 ^= (a&MASK_CPS); /* XOR with a */
-		if ((a&BIT6) != 0) { /* If D_all(all bit XOR) = 1 */
-			reg3 ^= (u8)i; /* XOR with counter */
-			reg2 ^= ~((u8)i); /* XOR with inv. of counter */
-		}
-	}
-
-	/* Trans LP14,12,10,... & LP15,13,11,... ->
-						LP15,14,13,... & LP7,6,5,.. */
-	trans_result(reg2, reg3, ecc1, ecc2);
-	*ecc1 = ~(*ecc1); *ecc2 = ~(*ecc2); /* Inv. ecc2 & ecc3 */
-	*ecc3 = ((~reg1)<<2)|BIT1BIT0; /* Make TEL format */
-}
-
-/*
- * *data; * DATA
- * *eccdata; * ECC DATA
- * ecc1; * LP15,LP14,LP13,...
- * ecc2; * LP07,LP06,LP05,...
- * ecc3; * CP5,CP4,CP3,...,"1","1"
- */
-u8 correct_data(u8 *data, u8 *eccdata, u8 ecc1, u8 ecc2, u8 ecc3)
-{
-	u32 l; /* Working to check d */
-	u32 d; /* Result of comparison */
-	u32 i; /* For counting */
-	u8 d1, d2, d3; /* Result of comparison */
-	u8 a; /* Working for add */
-	u8 add; /* Byte address of cor. DATA */
-	u8 b; /* Working for bit */
-	u8 bit; /* Bit address of cor. DATA */
-
-	d1 = ecc1^eccdata[1]; d2 = ecc2^eccdata[0]; /* Compare LP's */
-	d3 = ecc3^eccdata[2]; /* Compare CP's */
-	d = ((u32)d1<<16) /* Result of comparison */
-	+((u32)d2<<8)
-	+(u32)d3;
-
-	if (d == 0)
-		return 0; /* If No error, return */
-
-	if (((d^(d>>1))&CORRECTABLE) == CORRECTABLE) { /* If correctable */
-		l = BIT23;
-		add = 0; /* Clear parameter */
-		a = BIT7;
-
-		for (i = 0; i < 8; ++i) { /* Checking 8 bit */
-			if ((d&l) != 0)
-				add |= a; /* Make byte address from LP's */
-			l >>= 2; a >>= 1; /* Right Shift */
-		}
-
-		bit = 0; /* Clear parameter */
-		b = BIT2;
-		for (i = 0; i < 3; ++i) { /* Checking 3 bit */
-			if ((d&l) != 0)
-				bit |= b; /* Make bit address from CP's */
-			l >>= 2; b >>= 1; /* Right shift */
-		}
-
-		b = BIT0;
-		data[add] ^= (b<<bit); /* Put corrected data */
-		return 1;
-	}
-
-	i = 0; /* Clear count */
-	d &= 0x00ffffffL; /* Masking */
-
-	while (d) { /* If d=0 finish counting */
-		if (d&BIT0)
-			++i; /* Count number of 1 bit */
-		d >>= 1; /* Right shift */
-	}
-
-	if (i == 1) { /* If ECC error */
-		eccdata[1] = ecc1; eccdata[0] = ecc2; /* Put right ECC code */
-		eccdata[2] = ecc3;
-		return 2;
-	}
-	return 3; /* Uncorrectable error */
-}
-
-int _Correct_D_SwECC(u8 *buf, u8 *redundant_ecc, u8 *calculate_ecc)
-{
-	u32 err;
-
-	err = correct_data(buf, redundant_ecc, *(calculate_ecc + 1),
-			   *(calculate_ecc), *(calculate_ecc + 2));
-	if (err == 1)
-		memcpy(calculate_ecc, redundant_ecc, 3);
-
-	if (err == 0 || err == 1 || err == 2)
-		return 0;
-
-	return -1;
-}
-
-void _Calculate_D_SwECC(u8 *buf, u8 *ecc)
-{
-	calculate_ecc(ecctable, buf, ecc+1, ecc+0, ecc+2);
-}
-
-
diff --git a/drivers/staging/keucr/smilmain.c b/drivers/staging/keucr/smilmain.c
deleted file mode 100644
index 42ec8a6..0000000
--- a/drivers/staging/keucr/smilmain.c
+++ /dev/null
@@ -1,760 +0,0 @@
-#include <linux/slab.h>
-#include "usb.h"
-#include "scsiglue.h"
-#include "smcommon.h"
-#include "smil.h"
-
-static int         Conv_D_MediaAddr(struct us_data *, u32);
-static int         Inc_D_MediaAddr(struct us_data *);
-static int         Media_D_ReadOneSect(struct us_data *, u16, u8 *);
-
-static int  Copy_D_BlockAll(struct us_data *, u32);
-
-static int  Assign_D_WriteBlock(void);
-static int  Release_D_ReadBlock(struct us_data *);
-static int  Release_D_WriteBlock(struct us_data *);
-static int  Release_D_CopySector(struct us_data *);
-
-static int  Copy_D_PhyOneSect(struct us_data *);
-static int  Read_D_PhyOneSect(struct us_data *, u16, u8 *);
-static int  Erase_D_PhyOneBlock(struct us_data *);
-
-static int  Set_D_PhyFmtValue(struct us_data *);
-static int  Search_D_CIS(struct us_data *);
-static int  Make_D_LogTable(struct us_data *);
-
-static int  MarkFail_D_PhyOneBlock(struct us_data *);
-
-static u32 ErrCode;
-static u8  WorkBuf[SECTSIZE];
-static u8  Redundant[REDTSIZE];
-static u8  WorkRedund[REDTSIZE];
-/* 128 x 1000, Log2Phy[MAX_ZONENUM][MAX_LOGBLOCK]; */
-static u16  *Log2Phy[MAX_ZONENUM];
-static u8  Assign[MAX_ZONENUM][MAX_BLOCKNUM / 8];
-static u16  AssignStart[MAX_ZONENUM];
-u16  ReadBlock;
-u16  WriteBlock;
-u32 MediaChange;
-static u32 SectCopyMode;
-
-/* BIT Control Macro */
-static u8 BitData[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
-#define Set_D_Bit(a, b)    (a[(u8)((b) / 8)] |= BitData[(b) % 8])
-#define Clr_D_Bit(a, b)    (a[(u8)((b) / 8)] &= ~BitData[(b) % 8])
-#define Chk_D_Bit(a, b)    (a[(u8)((b) / 8)] & BitData[(b) % 8])
-
-/* ----- SM_FreeMem() ------------------------------------------------- */
-int SM_FreeMem(void)
-{
-	int	i;
-
-	pr_info("SM_FreeMem start\n");
-	for (i = 0; i < MAX_ZONENUM; i++) {
-		if (Log2Phy[i] != NULL) {
-			pr_info("Free Zone = %x, Addr = %p\n", i, Log2Phy[i]);
-			kfree(Log2Phy[i]);
-			Log2Phy[i] = NULL;
-		}
-	}
-	return NO_ERROR;
-}
-
-/* SmartMedia Read/Write/Erase Function */
-/* ----- Media_D_ReadSector() ------------------------------------------- */
-int Media_D_ReadSector(struct us_data *us, u32 start, u16 count, u8 *buf)
-{
-	u16 len, bn;
-
-	if (Conv_D_MediaAddr(us, start))
-		return ErrCode;
-
-	while (1) {
-		len = Ssfdc.MaxSectors - Media.Sector;
-		if (count > len)
-			bn = len;
-		else
-			bn = count;
-
-		if (Media_D_ReadOneSect(us, bn, buf)) {
-			ErrCode = ERR_EccReadErr;
-			return ErrCode;
-		}
-
-		Media.Sector += bn;
-		count -= bn;
-
-		if (count <= 0)
-			break;
-
-		buf += bn * SECTSIZE;
-
-		if (Inc_D_MediaAddr(us))
-			return ErrCode;
-	}
-
-	return NO_ERROR;
-}
-/* here */
-/* ----- Media_D_CopySector() ------------------------------------------ */
-int Media_D_CopySector(struct us_data *us, u32 start, u16 count, u8 *buf)
-{
-	u16 len, bn;
-
-	/* pr_info("Media_D_CopySector !!!\n"); */
-	if (Conv_D_MediaAddr(us, start))
-		return ErrCode;
-
-	while (1) {
-		if (Assign_D_WriteBlock())
-			return ERROR;
-
-		len = Ssfdc.MaxSectors - Media.Sector;
-		if (count > len)
-			bn = len;
-		else
-		bn = count;
-
-		if (Ssfdc_D_CopyBlock(us, bn, buf, Redundant)) {
-			ErrCode = ERR_WriteFault;
-			return ErrCode;
-		}
-
-		Media.Sector = 0x1F;
-		if (Release_D_CopySector(us)) {
-			if (ErrCode == ERR_HwError) {
-				ErrCode = ERR_WriteFault;
-				return ErrCode;
-			}
-		}
-		count -= bn;
-
-		if (count <= 0)
-			break;
-
-		buf += bn * SECTSIZE;
-
-		if (Inc_D_MediaAddr(us))
-			return ErrCode;
-
-	}
-	return NO_ERROR;
-}
-
-/* SmartMedia Physical Format Test Subroutine */
-/* ----- Check_D_MediaFmt() --------------------------------------------- */
-int Check_D_MediaFmt(struct us_data *us)
-{
-	pr_info("Check_D_MediaFmt\n");
-
-	if (!MediaChange)
-		return SMSUCCESS;
-
-	MediaChange  = ERROR;
-	SectCopyMode = COMPLETED;
-
-	if (Set_D_PhyFmtValue(us)) {
-		ErrCode = ERR_UnknownMedia;
-		return ERROR;
-	}
-
-	if (Search_D_CIS(us)) {
-		ErrCode = ERR_IllegalFmt;
-		return ERROR;
-	}
-
-	MediaChange = SMSUCCESS;
-	return SMSUCCESS;
-}
-
-/* ----- Release_D_CopySector() ------------------------------------------ */
-static int Release_D_CopySector(struct us_data *us)
-{
-	Log2Phy[Media.Zone][Media.LogBlock] = WriteBlock;
-	Media.PhyBlock = ReadBlock;
-
-	if (Media.PhyBlock == NO_ASSIGN) {
-		Media.PhyBlock = WriteBlock;
-		return SMSUCCESS;
-	}
-
-	Clr_D_Bit(Assign[Media.Zone], Media.PhyBlock);
-	Media.PhyBlock = WriteBlock;
-
-	return SMSUCCESS;
-}
-
-/* SmartMedia Physical Address Control Subroutine */
-/* ----- Conv_D_MediaAddr() --------------------------------------------- */
-static int Conv_D_MediaAddr(struct us_data *us, u32 addr)
-{
-	u32 temp;
-
-	temp           = addr / Ssfdc.MaxSectors;
-	Media.Zone     = (u8) (temp / Ssfdc.MaxLogBlocks);
-
-	if (Log2Phy[Media.Zone] == NULL) {
-		if (Make_D_LogTable(us)) {
-			ErrCode = ERR_IllegalFmt;
-			return ERROR;
-		}
-	}
-
-	Media.Sector   = (u8) (addr % Ssfdc.MaxSectors);
-	Media.LogBlock = (u16) (temp % Ssfdc.MaxLogBlocks);
-
-	if (Media.Zone < Ssfdc.MaxZones) {
-		Clr_D_RedundantData(Redundant);
-		Set_D_LogBlockAddr(Redundant);
-		Media.PhyBlock = Log2Phy[Media.Zone][Media.LogBlock];
-		return SMSUCCESS;
-	}
-
-	ErrCode = ERR_OutOfLBA;
-	return ERROR;
-}
-
-/* ----- Inc_D_MediaAddr() ---------------------------------------------- */
-static int Inc_D_MediaAddr(struct us_data *us)
-{
-	u16        LogBlock = Media.LogBlock;
-
-	if (++Media.Sector < Ssfdc.MaxSectors)
-		return SMSUCCESS;
-
-	if (Log2Phy[Media.Zone] == NULL) {
-		if (Make_D_LogTable(us)) {
-			ErrCode = ERR_IllegalFmt;
-			return ERROR;
-		}
-	}
-
-	Media.Sector = 0;
-	Media.LogBlock = LogBlock;
-
-	if (++Media.LogBlock < Ssfdc.MaxLogBlocks) {
-		Clr_D_RedundantData(Redundant);
-		Set_D_LogBlockAddr(Redundant);
-		Media.PhyBlock = Log2Phy[Media.Zone][Media.LogBlock];
-		return SMSUCCESS;
-	}
-
-	Media.LogBlock = 0;
-
-	if (++Media.Zone < Ssfdc.MaxZones) {
-		if (Log2Phy[Media.Zone] == NULL) {
-			if (Make_D_LogTable(us)) {
-				ErrCode = ERR_IllegalFmt;
-				return ERROR;
-			}
-		}
-
-		Media.LogBlock = 0;
-
-		Clr_D_RedundantData(Redundant);
-		Set_D_LogBlockAddr(Redundant);
-		Media.PhyBlock = Log2Phy[Media.Zone][Media.LogBlock];
-		return SMSUCCESS;
-	}
-
-	Media.Zone = 0;
-	ErrCode = ERR_OutOfLBA;
-
-	return ERROR;
-}
-
-/* SmartMedia Read/Write Subroutine with Retry */
-/* ----- Media_D_ReadOneSect() ------------------------------------------ */
-static int Media_D_ReadOneSect(struct us_data *us, u16 count, u8 *buf)
-{
-	u32 err, retry;
-
-	if (!Read_D_PhyOneSect(us, count, buf))
-		return SMSUCCESS;
-	if (ErrCode == ERR_HwError)
-		return ERROR;
-	if (ErrCode == ERR_DataStatus)
-		return ERROR;
-
-#ifdef RDERR_REASSIGN
-	if (Ssfdc.Attribute & MWP) {
-		if (ErrCode == ERR_CorReadErr)
-			return SMSUCCESS;
-		return ERROR;
-	}
-
-	err = ErrCode;
-	for (retry = 0; retry < 2; retry++) {
-		if (Copy_D_BlockAll(us,
-			(err == ERR_EccReadErr) ? REQ_FAIL : REQ_ERASE)) {
-			if (ErrCode == ERR_HwError)
-				return ERROR;
-			continue;
-		}
-
-		ErrCode = err;
-		if (ErrCode == ERR_CorReadErr)
-			return SMSUCCESS;
-		return ERROR;
-	}
-
-	MediaChange = ERROR;
-#else
-	if (ErrCode == ERR_CorReadErr)
-		return SMSUCCESS;
-#endif
-
-	return ERROR;
-}
-
-/* SmartMedia Physical Sector Data Copy Subroutine */
-/* ----- Copy_D_BlockAll() ---------------------------------------------- */
-static int Copy_D_BlockAll(struct us_data *us, u32 mode)
-{
-	u8 sect;
-
-	sect = Media.Sector;
-
-	if (Assign_D_WriteBlock())
-		return ERROR;
-	if (mode == REQ_FAIL)
-		SectCopyMode = REQ_FAIL;
-
-	for (Media.Sector = 0; Media.Sector < Ssfdc.MaxSectors;
-							Media.Sector++) {
-		if (Copy_D_PhyOneSect(us)) {
-			if (ErrCode == ERR_HwError)
-				return ERROR;
-			if (Release_D_WriteBlock(us))
-				return ERROR;
-
-			ErrCode = ERR_WriteFault;
-			Media.PhyBlock = ReadBlock;
-			Media.Sector = sect;
-
-			return ERROR;
-		}
-	}
-
-	if (Release_D_ReadBlock(us))
-		return ERROR;
-
-	Media.PhyBlock = WriteBlock;
-	Media.Sector = sect;
-	return SMSUCCESS;
-}
-
-/* SmartMedia Physical Block Assign/Release Subroutine */
-/* ----- Assign_D_WriteBlock() ------------------------------------------ */
-static int Assign_D_WriteBlock(void)
-{
-	ReadBlock = Media.PhyBlock;
-
-	for (WriteBlock = AssignStart[Media.Zone];
-			WriteBlock < Ssfdc.MaxBlocks; WriteBlock++) {
-		if (!Chk_D_Bit(Assign[Media.Zone], WriteBlock)) {
-			Set_D_Bit(Assign[Media.Zone], WriteBlock);
-			AssignStart[Media.Zone] = WriteBlock + 1;
-			Media.PhyBlock = WriteBlock;
-			SectCopyMode = REQ_ERASE;
-			return SMSUCCESS;
-		}
-	}
-
-	for (WriteBlock = 0;
-			WriteBlock < AssignStart[Media.Zone]; WriteBlock++) {
-		if (!Chk_D_Bit(Assign[Media.Zone], WriteBlock)) {
-			Set_D_Bit(Assign[Media.Zone], WriteBlock);
-			AssignStart[Media.Zone] = WriteBlock + 1;
-			Media.PhyBlock = WriteBlock;
-			SectCopyMode = REQ_ERASE;
-			return SMSUCCESS;
-		}
-	}
-
-	WriteBlock = NO_ASSIGN;
-	ErrCode = ERR_WriteFault;
-
-	return ERROR;
-}
-
-/* ----- Release_D_ReadBlock() ------------------------------------------ */
-static int Release_D_ReadBlock(struct us_data *us)
-{
-	u32 mode;
-
-	mode = SectCopyMode;
-	SectCopyMode = COMPLETED;
-
-	if (mode == COMPLETED)
-		return SMSUCCESS;
-
-	Log2Phy[Media.Zone][Media.LogBlock] = WriteBlock;
-	Media.PhyBlock = ReadBlock;
-
-	if (Media.PhyBlock == NO_ASSIGN) {
-		Media.PhyBlock = WriteBlock;
-		return SMSUCCESS;
-	}
-
-	if (mode == REQ_ERASE) {
-		if (Erase_D_PhyOneBlock(us)) {
-			if (ErrCode == ERR_HwError)
-				return ERROR;
-			if (MarkFail_D_PhyOneBlock(us))
-				return ERROR;
-		} else
-			Clr_D_Bit(Assign[Media.Zone], Media.PhyBlock);
-	} else if (MarkFail_D_PhyOneBlock(us))
-		return ERROR;
-
-	Media.PhyBlock = WriteBlock;
-	return SMSUCCESS;
-}
-
-/* ----- Release_D_WriteBlock() ----------------------------------------- */
-static int Release_D_WriteBlock(struct us_data *us)
-{
-	SectCopyMode = COMPLETED;
-	Media.PhyBlock = WriteBlock;
-
-	if (MarkFail_D_PhyOneBlock(us))
-		return ERROR;
-
-	Media.PhyBlock = ReadBlock;
-	return SMSUCCESS;
-}
-
-/* SmartMedia Physical Sector Data Copy Subroutine */
-/* ----- Copy_D_PhyOneSect() -------------------------------------------- */
-static int Copy_D_PhyOneSect(struct us_data *us)
-{
-	int           i;
-	u32  err, retry;
-
-	/* pr_info("Copy_D_PhyOneSect --- Sector = %x\n", Media.Sector); */
-	if (ReadBlock != NO_ASSIGN) {
-		Media.PhyBlock = ReadBlock;
-		for (retry = 0; retry < 2; retry++) {
-			if (retry != 0) {
-				Ssfdc_D_Reset(us);
-				if (Ssfdc_D_ReadCisSect(us, WorkBuf,
-								WorkRedund)) {
-					ErrCode = ERR_HwError;
-					MediaChange = ERROR;
-					return ERROR;
-				}
-
-				if (Check_D_CISdata(WorkBuf, WorkRedund)) {
-					ErrCode = ERR_HwError;
-					MediaChange = ERROR;
-					return ERROR;
-				}
-			}
-
-			if (Ssfdc_D_ReadSect(us, WorkBuf, WorkRedund)) {
-				ErrCode = ERR_HwError;
-				MediaChange = ERROR;
-				return ERROR;
-			}
-			if (Check_D_DataStatus(WorkRedund)) {
-				err = ERROR;
-				break;
-			}
-			if (!Check_D_ReadError(WorkRedund)) {
-				err = SMSUCCESS;
-				break;
-			}
-			if (!Check_D_Correct(WorkBuf, WorkRedund)) {
-				err = SMSUCCESS;
-				break;
-			}
-
-			err = ERROR;
-			SectCopyMode = REQ_FAIL;
-		}
-	} else {
-		err = SMSUCCESS;
-		for (i = 0; i < SECTSIZE; i++)
-			WorkBuf[i] = DUMMY_DATA;
-		Clr_D_RedundantData(WorkRedund);
-	}
-
-	Set_D_LogBlockAddr(WorkRedund);
-	if (err == ERROR) {
-		Set_D_RightECC(WorkRedund);
-		Set_D_DataStaus(WorkRedund);
-	}
-
-	Media.PhyBlock = WriteBlock;
-
-	if (Ssfdc_D_WriteSectForCopy(us, WorkBuf, WorkRedund)) {
-		ErrCode = ERR_HwError;
-		MediaChange = ERROR;
-		return ERROR;
-	}
-	if (Ssfdc_D_CheckStatus()) {
-		ErrCode = ERR_WriteFault;
-		return ERROR;
-	}
-
-	Media.PhyBlock = ReadBlock;
-	return SMSUCCESS;
-}
-
-/* SmartMedia Physical Sector Read/Write/Erase Subroutine */
-/* ----- Read_D_PhyOneSect() -------------------------------------------- */
-static int Read_D_PhyOneSect(struct us_data *us, u16 count, u8 *buf)
-{
-	int           i;
-	u32  retry;
-
-	if (Media.PhyBlock == NO_ASSIGN) {
-		for (i = 0; i < SECTSIZE; i++)
-			*buf++ = DUMMY_DATA;
-		return SMSUCCESS;
-	}
-
-	for (retry = 0; retry < 2; retry++) {
-		if (retry != 0) {
-			Ssfdc_D_Reset(us);
-
-			if (Ssfdc_D_ReadCisSect(us, WorkBuf, WorkRedund)) {
-				ErrCode = ERR_HwError;
-				MediaChange = ERROR;
-				return ERROR;
-			}
-			if (Check_D_CISdata(WorkBuf, WorkRedund)) {
-				ErrCode = ERR_HwError;
-				MediaChange = ERROR;
-				return ERROR;
-			}
-		}
-
-		if (Ssfdc_D_ReadBlock(us, count, buf, Redundant)) {
-			ErrCode = ERR_HwError;
-			MediaChange = ERROR;
-			return ERROR;
-		}
-		if (Check_D_DataStatus(Redundant)) {
-			ErrCode = ERR_DataStatus;
-			return ERROR;
-		}
-
-		if (!Check_D_ReadError(Redundant))
-			return SMSUCCESS;
-
-		if (!Check_D_Correct(buf, Redundant)) {
-			ErrCode = ERR_CorReadErr;
-			return ERROR;
-		}
-	}
-
-	ErrCode = ERR_EccReadErr;
-	return ERROR;
-}
-
-/* ----- Erase_D_PhyOneBlock() ------------------------------------------ */
-static int Erase_D_PhyOneBlock(struct us_data *us)
-{
-	if (Ssfdc_D_EraseBlock(us)) {
-		ErrCode = ERR_HwError;
-		MediaChange = ERROR;
-		return ERROR;
-	}
-	if (Ssfdc_D_CheckStatus()) {
-		ErrCode = ERR_WriteFault;
-		return ERROR;
-	}
-
-	return SMSUCCESS;
-}
-
-/* SmartMedia Physical Format Check Local Subroutine */
-/* ----- Set_D_PhyFmtValue() -------------------------------------------- */
-static int Set_D_PhyFmtValue(struct us_data *us)
-{
-	if (Set_D_SsfdcModel(us->SM_DeviceID))
-		return ERROR;
-
-	return SMSUCCESS;
-}
-
-/* ----- Search_D_CIS() ------------------------------------------------- */
-static int Search_D_CIS(struct us_data *us)
-{
-	Media.Zone = 0;
-	Media.Sector = 0;
-
-	for (Media.PhyBlock = 0;
-		Media.PhyBlock < (Ssfdc.MaxBlocks - Ssfdc.MaxLogBlocks - 1);
-		Media.PhyBlock++) {
-		if (Ssfdc_D_ReadRedtData(us, Redundant)) {
-			Ssfdc_D_Reset(us);
-			return ERROR;
-		}
-
-		if (!Check_D_FailBlock(Redundant))
-			break;
-	}
-
-	if (Media.PhyBlock == (Ssfdc.MaxBlocks - Ssfdc.MaxLogBlocks - 1)) {
-		Ssfdc_D_Reset(us);
-		return ERROR;
-	}
-
-	while (Media.Sector < CIS_SEARCH_SECT) {
-		if (Media.Sector) {
-			if (Ssfdc_D_ReadRedtData(us, Redundant)) {
-				Ssfdc_D_Reset(us);
-				return ERROR;
-			}
-		}
-		if (!Check_D_DataStatus(Redundant)) {
-			if (Ssfdc_D_ReadSect(us, WorkBuf, Redundant)) {
-				Ssfdc_D_Reset(us);
-				return ERROR;
-			}
-
-			if (Check_D_CISdata(WorkBuf, Redundant)) {
-				Ssfdc_D_Reset(us);
-				return ERROR;
-			}
-
-			CisArea.PhyBlock = Media.PhyBlock;
-			CisArea.Sector = Media.Sector;
-			Ssfdc_D_Reset(us);
-			return SMSUCCESS;
-		}
-
-		Media.Sector++;
-	}
-
-	Ssfdc_D_Reset(us);
-	return ERROR;
-}
-
-/* ----- Make_D_LogTable() ---------------------------------------------- */
-static int Make_D_LogTable(struct us_data *us)
-{
-	u16  phyblock, logblock;
-
-	if (Log2Phy[Media.Zone] == NULL) {
-		Log2Phy[Media.Zone] = kmalloc(MAX_LOGBLOCK * sizeof(u16),
-								GFP_KERNEL);
-		/* pr_info("ExAllocatePool Zone = %x, Addr = %x\n",
-				Media.Zone, Log2Phy[Media.Zone]); */
-		if (Log2Phy[Media.Zone] == NULL)
-			return ERROR;
-	}
-
-	Media.Sector = 0;
-
-	/* pr_info("Make_D_LogTable --- MediaZone = 0x%x\n",
-						Media.Zone); */
-	for (Media.LogBlock = 0; Media.LogBlock < Ssfdc.MaxLogBlocks;
-						Media.LogBlock++)
-		Log2Phy[Media.Zone][Media.LogBlock] = NO_ASSIGN;
-
-	for (Media.PhyBlock = 0; Media.PhyBlock < (MAX_BLOCKNUM / 8);
-						Media.PhyBlock++)
-		Assign[Media.Zone][Media.PhyBlock] = 0x00;
-
-	for (Media.PhyBlock = 0; Media.PhyBlock < Ssfdc.MaxBlocks;
-						Media.PhyBlock++) {
-		if ((!Media.Zone) && (Media.PhyBlock <= CisArea.PhyBlock)) {
-			Set_D_Bit(Assign[Media.Zone], Media.PhyBlock);
-			continue;
-		}
-
-		if (Ssfdc_D_ReadRedtData(us, Redundant)) {
-			Ssfdc_D_Reset(us);
-			return ERROR;
-		}
-
-		if (!Check_D_DataBlank(Redundant))
-			continue;
-
-		Set_D_Bit(Assign[Media.Zone], Media.PhyBlock);
-
-		if (Check_D_FailBlock(Redundant))
-			continue;
-
-		if (Load_D_LogBlockAddr(Redundant))
-			continue;
-
-		if (Media.LogBlock >= Ssfdc.MaxLogBlocks)
-			continue;
-
-		if (Log2Phy[Media.Zone][Media.LogBlock] == NO_ASSIGN) {
-			Log2Phy[Media.Zone][Media.LogBlock] = Media.PhyBlock;
-			continue;
-		}
-
-		phyblock     = Media.PhyBlock;
-		logblock     = Media.LogBlock;
-		Media.Sector = (u8)(Ssfdc.MaxSectors - 1);
-
-		if (Ssfdc_D_ReadRedtData(us, Redundant)) {
-			Ssfdc_D_Reset(us);
-			return ERROR;
-		}
-
-		if (!Load_D_LogBlockAddr(Redundant) &&
-				(Media.LogBlock == logblock)) {
-			Media.PhyBlock = Log2Phy[Media.Zone][logblock];
-
-			if (Ssfdc_D_ReadRedtData(us, Redundant)) {
-				Ssfdc_D_Reset(us);
-				return ERROR;
-			}
-
-			Media.PhyBlock = phyblock;
-
-			if (!Load_D_LogBlockAddr(Redundant)) {
-				if (Media.LogBlock != logblock) {
-					Media.PhyBlock =
-						Log2Phy[Media.Zone][logblock];
-					Log2Phy[Media.Zone][logblock] =
-								phyblock;
-				}
-			} else {
-				Media.PhyBlock = Log2Phy[Media.Zone][logblock];
-				Log2Phy[Media.Zone][logblock] = phyblock;
-			}
-		}
-
-		Media.Sector = 0;
-		Media.PhyBlock = phyblock;
-
-	AssignStart[Media.Zone] = 0;
-
-	} /* End for (Media.Zone<MAX_ZONENUM) */
-
-	Ssfdc_D_Reset(us);
-	return SMSUCCESS;
-}
-
-/* ----- MarkFail_D_PhyOneBlock() --------------------------------------- */
-static int MarkFail_D_PhyOneBlock(struct us_data *us)
-{
-	u8 sect;
-
-	sect = Media.Sector;
-	Set_D_FailBlock(WorkRedund);
-
-	for (Media.Sector = 0; Media.Sector < Ssfdc.MaxSectors;
-							Media.Sector++) {
-		if (Ssfdc_D_WriteRedtData(us, WorkRedund)) {
-			Ssfdc_D_Reset(us);
-			Media.Sector   = sect;
-			ErrCode        = ERR_HwError;
-			MediaChange = ERROR;
-			return ERROR;
-		} /* NO Status Check */
-	}
-
-	Ssfdc_D_Reset(us);
-	Media.Sector = sect;
-	return SMSUCCESS;
-}
diff --git a/drivers/staging/keucr/smilsub.c b/drivers/staging/keucr/smilsub.c
deleted file mode 100644
index e981f14..0000000
--- a/drivers/staging/keucr/smilsub.c
+++ /dev/null
@@ -1,679 +0,0 @@
-#include <linux/slab.h>
-#include "usb.h"
-#include "scsiglue.h"
-#include "transport.h"
-
-#include "smcommon.h"
-#include "smil.h"
-
-static u8   _Check_D_DevCode(u8);
-static u32	ErrXDCode;
-static u8	IsSSFDCCompliance;
-static u8	IsXDCompliance;
-
-struct keucr_media_info         Ssfdc;
-struct keucr_media_address      Media;
-struct keucr_media_area         CisArea;
-
-static u8                            EccBuf[6];
-
-#define EVEN                    0             /* Even Page for 256byte/page */
-#define ODD                     1             /* Odd Page for 256byte/page */
-
-
-/* SmartMedia Redundant buffer data Control Subroutine
- *----- Check_D_DataBlank() --------------------------------------------
- */
-int Check_D_DataBlank(u8 *redundant)
-{
-	char i;
-
-	for (i = 0; i < REDTSIZE; i++)
-		if (*redundant++ != 0xFF)
-			return  ERROR;
-
-	return SMSUCCESS;
-}
-
-/* ----- Check_D_FailBlock() -------------------------------------------- */
-int Check_D_FailBlock(u8 *redundant)
-{
-	redundant += REDT_BLOCK;
-
-	if (*redundant == 0xFF)
-		return SMSUCCESS;
-	if (!*redundant)
-		return ERROR;
-	if (hweight8(*redundant) < 7)
-		return ERROR;
-
-	return SMSUCCESS;
-}
-
-/* ----- Check_D_DataStatus() ------------------------------------------- */
-int Check_D_DataStatus(u8 *redundant)
-{
-	redundant += REDT_DATA;
-
-	if (*redundant == 0xFF)
-		return SMSUCCESS;
-	if (!*redundant) {
-		ErrXDCode = ERR_DataStatus;
-		return ERROR;
-	} else
-		ErrXDCode = NO_ERROR;
-
-	if (hweight8(*redundant) < 5)
-		return ERROR;
-
-	return SMSUCCESS;
-}
-
-/* ----- Load_D_LogBlockAddr() ------------------------------------------ */
-int Load_D_LogBlockAddr(u8 *redundant)
-{
-	u16 addr1, addr2;
-
-	addr1 = (u16)*(redundant + REDT_ADDR1H)*0x0100 +
-					(u16)*(redundant + REDT_ADDR1L);
-	addr2 = (u16)*(redundant + REDT_ADDR2H)*0x0100 +
-					(u16)*(redundant + REDT_ADDR2L);
-
-	if (addr1 == addr2)
-		if ((addr1 & 0xF000) == 0x1000) {
-			Media.LogBlock = (addr1 & 0x0FFF) / 2;
-			return SMSUCCESS;
-		}
-
-	if (hweight16((u16)(addr1^addr2)) != 0x01)
-		return ERROR;
-
-	if ((addr1 & 0xF000) == 0x1000)
-		if (!(hweight16(addr1) & 0x01)) {
-			Media.LogBlock = (addr1 & 0x0FFF) / 2;
-			return SMSUCCESS;
-		}
-
-	if ((addr2 & 0xF000) == 0x1000)
-		if (!(hweight16(addr2) & 0x01)) {
-			Media.LogBlock = (addr2 & 0x0FFF) / 2;
-			return SMSUCCESS;
-		}
-
-	return ERROR;
-}
-
-/* ----- Clr_D_RedundantData() ------------------------------------------ */
-void Clr_D_RedundantData(u8 *redundant)
-{
-	char i;
-
-	for (i = 0; i < REDTSIZE; i++)
-		*(redundant + i) = 0xFF;
-}
-
-/* ----- Set_D_LogBlockAddr() ------------------------------------------- */
-void Set_D_LogBlockAddr(u8 *redundant)
-{
-	u16 addr;
-
-	*(redundant + REDT_BLOCK) = 0xFF;
-	*(redundant + REDT_DATA) = 0xFF;
-	addr = Media.LogBlock*2 + 0x1000;
-
-	if ((hweight16(addr) % 2))
-		addr++;
-
-	*(redundant + REDT_ADDR1H) = *(redundant + REDT_ADDR2H) =
-							(u8)(addr / 0x0100);
-	*(redundant + REDT_ADDR1L) = *(redundant + REDT_ADDR2L) = (u8)addr;
-}
-
-/*----- Set_D_FailBlock() ---------------------------------------------- */
-void Set_D_FailBlock(u8 *redundant)
-{
-	char i;
-
-	for (i = 0; i < REDTSIZE; i++)
-		*redundant++ = (u8)((i == REDT_BLOCK) ? 0xF0 : 0xFF);
-}
-
-/* ----- Set_D_DataStaus() ---------------------------------------------- */
-void Set_D_DataStaus(u8 *redundant)
-{
-	redundant += REDT_DATA;
-	*redundant = 0x00;
-}
-
-/* SmartMedia Function Command Subroutine
- * 6250 CMD 6
- */
-/* ----- Ssfdc_D_Reset() ------------------------------------------------ */
-void Ssfdc_D_Reset(struct us_data *us)
-{
-	return;
-}
-
-/* ----- Ssfdc_D_ReadCisSect() ------------------------------------------ */
-int Ssfdc_D_ReadCisSect(struct us_data *us, u8 *buf, u8 *redundant)
-{
-	u8 zone, sector;
-	u16 block;
-
-	zone = Media.Zone; block = Media.PhyBlock; sector = Media.Sector;
-	Media.Zone = 0;
-	Media.PhyBlock = CisArea.PhyBlock;
-	Media.Sector = CisArea.Sector;
-
-	if (Ssfdc_D_ReadSect(us, buf, redundant)) {
-		Media.Zone = zone;
-		Media.PhyBlock = block;
-		Media.Sector = sector;
-		return ERROR;
-	}
-
-	Media.Zone = zone; Media.PhyBlock = block; Media.Sector = sector;
-	return SMSUCCESS;
-}
-
-/* 6250 CMD 1 */
-/* ----- Ssfdc_D_ReadSect() --------------------------------------------- */
-int Ssfdc_D_ReadSect(struct us_data *us, u8 *buf, u8 *redundant)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	int	result;
-	u16	addr;
-
-	result = ENE_LoadBinCode(us, SM_RW_PATTERN);
-	if (result != USB_STOR_XFER_GOOD) {
-		dev_err(&us->pusb_dev->dev,
-			"Failed to load SmartMedia read/write code\n");
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	addr = (u16)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
-	addr = addr*(u16)Ssfdc.MaxSectors + Media.Sector;
-
-	/* Read sect data */
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength	= 0x200;
-	bcb->Flags			= 0x80;
-	bcb->CDB[0]			= 0xF1;
-	bcb->CDB[1]			= 0x02;
-	bcb->CDB[4]			= (u8)addr;
-	bcb->CDB[3]			= (u8)(addr / 0x0100);
-	bcb->CDB[2]			= Media.Zone / 2;
-
-	result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	/* Read redundant */
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength	= 0x10;
-	bcb->Flags			= 0x80;
-	bcb->CDB[0]			= 0xF1;
-	bcb->CDB[1]			= 0x03;
-	bcb->CDB[4]			= (u8)addr;
-	bcb->CDB[3]			= (u8)(addr / 0x0100);
-	bcb->CDB[2]			= Media.Zone / 2;
-	bcb->CDB[8]			= 0;
-	bcb->CDB[9]			= 1;
-
-	result = ENE_SendScsiCmd(us, FDIR_READ, redundant, 0);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/* ----- Ssfdc_D_ReadBlock() --------------------------------------------- */
-int Ssfdc_D_ReadBlock(struct us_data *us, u16 count, u8 *buf,
-							u8 *redundant)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	int	result;
-	u16	addr;
-
-	result = ENE_LoadBinCode(us, SM_RW_PATTERN);
-	if (result != USB_STOR_XFER_GOOD) {
-		dev_err(&us->pusb_dev->dev,
-			"Failed to load SmartMedia read/write code\n");
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	addr = (u16)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
-	addr = addr*(u16)Ssfdc.MaxSectors + Media.Sector;
-
-	/* Read sect data */
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength	= 0x200*count;
-	bcb->Flags			= 0x80;
-	bcb->CDB[0]			= 0xF1;
-	bcb->CDB[1]			= 0x02;
-	bcb->CDB[4]			= (u8)addr;
-	bcb->CDB[3]			= (u8)(addr / 0x0100);
-	bcb->CDB[2]			= Media.Zone / 2;
-
-	result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	/* Read redundant */
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength	= 0x10;
-	bcb->Flags			= 0x80;
-	bcb->CDB[0]			= 0xF1;
-	bcb->CDB[1]			= 0x03;
-	bcb->CDB[4]			= (u8)addr;
-	bcb->CDB[3]			= (u8)(addr / 0x0100);
-	bcb->CDB[2]			= Media.Zone / 2;
-	bcb->CDB[8]			= 0;
-	bcb->CDB[9]			= 1;
-
-	result = ENE_SendScsiCmd(us, FDIR_READ, redundant, 0);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-
-/* ----- Ssfdc_D_CopyBlock() -------------------------------------------- */
-int Ssfdc_D_CopyBlock(struct us_data *us, u16 count, u8 *buf,
-							u8 *redundant)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	int	result;
-	u16	ReadAddr, WriteAddr;
-
-	result = ENE_LoadBinCode(us, SM_RW_PATTERN);
-	if (result != USB_STOR_XFER_GOOD) {
-		dev_err(&us->pusb_dev->dev,
-			"Failed to load SmartMedia read/write code\n");
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	ReadAddr = (u16)Media.Zone*Ssfdc.MaxBlocks + ReadBlock;
-	ReadAddr = ReadAddr*(u16)Ssfdc.MaxSectors;
-	WriteAddr = (u16)Media.Zone*Ssfdc.MaxBlocks + WriteBlock;
-	WriteAddr = WriteAddr*(u16)Ssfdc.MaxSectors;
-
-	/* Write sect data */
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength	= 0x200*count;
-	bcb->Flags			= 0x00;
-	bcb->CDB[0]			= 0xF0;
-	bcb->CDB[1]			= 0x08;
-	bcb->CDB[7]			= (u8)WriteAddr;
-	bcb->CDB[6]			= (u8)(WriteAddr / 0x0100);
-	bcb->CDB[5]			= Media.Zone / 2;
-	bcb->CDB[8]			= *(redundant + REDT_ADDR1H);
-	bcb->CDB[9]			= *(redundant + REDT_ADDR1L);
-	bcb->CDB[10]		= Media.Sector;
-
-	if (ReadBlock != NO_ASSIGN) {
-		bcb->CDB[4]		= (u8)ReadAddr;
-		bcb->CDB[3]		= (u8)(ReadAddr / 0x0100);
-		bcb->CDB[2]		= Media.Zone / 2;
-	} else
-		bcb->CDB[11]	= 1;
-
-	result = ENE_SendScsiCmd(us, FDIR_WRITE, buf, 0);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/* ----- Ssfdc_D_WriteSectForCopy() ------------------------------------- */
-int Ssfdc_D_WriteSectForCopy(struct us_data *us, u8 *buf, u8 *redundant)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	int	result;
-	u16	addr;
-
-	result = ENE_LoadBinCode(us, SM_RW_PATTERN);
-	if (result != USB_STOR_XFER_GOOD) {
-		dev_err(&us->pusb_dev->dev,
-			"Failed to load SmartMedia read/write code\n");
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-
-	addr = (u16)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
-	addr = addr*(u16)Ssfdc.MaxSectors + Media.Sector;
-
-	/* Write sect data */
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength	= 0x200;
-	bcb->Flags			= 0x00;
-	bcb->CDB[0]			= 0xF0;
-	bcb->CDB[1]			= 0x04;
-	bcb->CDB[7]			= (u8)addr;
-	bcb->CDB[6]			= (u8)(addr / 0x0100);
-	bcb->CDB[5]			= Media.Zone / 2;
-	bcb->CDB[8]			= *(redundant + REDT_ADDR1H);
-	bcb->CDB[9]			= *(redundant + REDT_ADDR1L);
-
-	result = ENE_SendScsiCmd(us, FDIR_WRITE, buf, 0);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/* 6250 CMD 5 */
-/* ----- Ssfdc_D_EraseBlock() ------------------------------------------- */
-int Ssfdc_D_EraseBlock(struct us_data *us)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	int	result;
-	u16	addr;
-
-	result = ENE_LoadBinCode(us, SM_RW_PATTERN);
-	if (result != USB_STOR_XFER_GOOD) {
-		dev_err(&us->pusb_dev->dev,
-			"Failed to load SmartMedia read/write code\n");
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	addr = (u16)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
-	addr = addr*(u16)Ssfdc.MaxSectors;
-
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength	= 0x200;
-	bcb->Flags			= 0x80;
-	bcb->CDB[0]			= 0xF2;
-	bcb->CDB[1]			= 0x06;
-	bcb->CDB[7]			= (u8)addr;
-	bcb->CDB[6]			= (u8)(addr / 0x0100);
-	bcb->CDB[5]			= Media.Zone / 2;
-
-	result = ENE_SendScsiCmd(us, FDIR_READ, NULL, 0);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/* 6250 CMD 2 */
-/*----- Ssfdc_D_ReadRedtData() ----------------------------------------- */
-int Ssfdc_D_ReadRedtData(struct us_data *us, u8 *redundant)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	int	result;
-	u16	addr;
-	u8	*buf;
-
-	result = ENE_LoadBinCode(us, SM_RW_PATTERN);
-	if (result != USB_STOR_XFER_GOOD) {
-		dev_err(&us->pusb_dev->dev,
-			"Failed to load SmartMedia read/write code\n");
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	addr = (u16)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
-	addr = addr*(u16)Ssfdc.MaxSectors + Media.Sector;
-
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength	= 0x10;
-	bcb->Flags			= 0x80;
-	bcb->CDB[0]			= 0xF1;
-	bcb->CDB[1]			= 0x03;
-	bcb->CDB[4]			= (u8)addr;
-	bcb->CDB[3]			= (u8)(addr / 0x0100);
-	bcb->CDB[2]			= Media.Zone / 2;
-	bcb->CDB[8]			= 0;
-	bcb->CDB[9]			= 1;
-
-	buf = kmalloc(0x10, GFP_KERNEL);
-	result = ENE_SendScsiCmd(us, FDIR_READ, buf, 0);
-	memcpy(redundant, buf, 0x10);
-	kfree(buf);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/* 6250 CMD 4 */
-/* ----- Ssfdc_D_WriteRedtData() ---------------------------------------- */
-int Ssfdc_D_WriteRedtData(struct us_data *us, u8 *redundant)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	int	result;
-	u16                    addr;
-
-	result = ENE_LoadBinCode(us, SM_RW_PATTERN);
-	if (result != USB_STOR_XFER_GOOD) {
-		dev_err(&us->pusb_dev->dev,
-			"Failed to load SmartMedia read/write code\n");
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	addr = (u16)Media.Zone*Ssfdc.MaxBlocks + Media.PhyBlock;
-	addr = addr*(u16)Ssfdc.MaxSectors + Media.Sector;
-
-	memset(bcb, 0, sizeof(struct bulk_cb_wrap));
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength	= 0x10;
-	bcb->Flags			= 0x80;
-	bcb->CDB[0]			= 0xF2;
-	bcb->CDB[1]			= 0x05;
-	bcb->CDB[7]			= (u8)addr;
-	bcb->CDB[6]			= (u8)(addr / 0x0100);
-	bcb->CDB[5]			= Media.Zone / 2;
-	bcb->CDB[8]			= *(redundant + REDT_ADDR1H);
-	bcb->CDB[9]			= *(redundant + REDT_ADDR1L);
-
-	result = ENE_SendScsiCmd(us, FDIR_READ, NULL, 0);
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/* ----- Ssfdc_D_CheckStatus() ------------------------------------------ */
-int Ssfdc_D_CheckStatus(void)
-{
-	return SMSUCCESS;
-}
-
-
-
-/* SmartMedia ID Code Check & Mode Set Subroutine
- * ----- Set_D_SsfdcModel() ---------------------------------------------
- */
-int Set_D_SsfdcModel(u8 dcode)
-{
-	switch (_Check_D_DevCode(dcode)) {
-	case SSFDC1MB:
-		Ssfdc.Model        = SSFDC1MB;
-		Ssfdc.Attribute    = FLASH | AD3CYC | BS16 | PS256;
-		Ssfdc.MaxZones     = 1;
-		Ssfdc.MaxBlocks    = 256;
-		Ssfdc.MaxLogBlocks = 250;
-		Ssfdc.MaxSectors   = 8;
-		break;
-	case SSFDC2MB:
-		Ssfdc.Model        = SSFDC2MB;
-		Ssfdc.Attribute    = FLASH | AD3CYC | BS16 | PS256;
-		Ssfdc.MaxZones     = 1;
-		Ssfdc.MaxBlocks    = 512;
-		Ssfdc.MaxLogBlocks = 500;
-		Ssfdc.MaxSectors   = 8;
-		break;
-	case SSFDC4MB:
-		Ssfdc.Model        = SSFDC4MB;
-		Ssfdc.Attribute    = FLASH | AD3CYC | BS16 | PS512;
-		Ssfdc.MaxZones     = 1;
-		Ssfdc.MaxBlocks    = 512;
-		Ssfdc.MaxLogBlocks = 500;
-		Ssfdc.MaxSectors   = 16;
-		break;
-	case SSFDC8MB:
-		Ssfdc.Model        = SSFDC8MB;
-		Ssfdc.Attribute    = FLASH | AD3CYC | BS16 | PS512;
-		Ssfdc.MaxZones     = 1;
-		Ssfdc.MaxBlocks    = 1024;
-		Ssfdc.MaxLogBlocks = 1000;
-		Ssfdc.MaxSectors   = 16;
-		break;
-	case SSFDC16MB:
-		Ssfdc.Model        = SSFDC16MB;
-		Ssfdc.Attribute    = FLASH | AD3CYC | BS32 | PS512;
-		Ssfdc.MaxZones     = 1;
-		Ssfdc.MaxBlocks    = 1024;
-		Ssfdc.MaxLogBlocks = 1000;
-		Ssfdc.MaxSectors   = 32;
-		break;
-	case SSFDC32MB:
-		Ssfdc.Model        = SSFDC32MB;
-		Ssfdc.Attribute    = FLASH | AD3CYC | BS32 | PS512;
-		Ssfdc.MaxZones     = 2;
-		Ssfdc.MaxBlocks    = 1024;
-		Ssfdc.MaxLogBlocks = 1000;
-		Ssfdc.MaxSectors   = 32;
-		break;
-	case SSFDC64MB:
-		Ssfdc.Model        = SSFDC64MB;
-		Ssfdc.Attribute    = FLASH | AD4CYC | BS32 | PS512;
-		Ssfdc.MaxZones     = 4;
-		Ssfdc.MaxBlocks    = 1024;
-		Ssfdc.MaxLogBlocks = 1000;
-		Ssfdc.MaxSectors   = 32;
-		break;
-	case SSFDC128MB:
-		Ssfdc.Model        = SSFDC128MB;
-		Ssfdc.Attribute    = FLASH | AD4CYC | BS32 | PS512;
-		Ssfdc.MaxZones     = 8;
-		Ssfdc.MaxBlocks    = 1024;
-		Ssfdc.MaxLogBlocks = 1000;
-		Ssfdc.MaxSectors   = 32;
-		break;
-	case SSFDC256MB:
-		Ssfdc.Model        = SSFDC256MB;
-		Ssfdc.Attribute    = FLASH | AD4CYC | BS32 | PS512;
-		Ssfdc.MaxZones     = 16;
-		Ssfdc.MaxBlocks    = 1024;
-		Ssfdc.MaxLogBlocks = 1000;
-		Ssfdc.MaxSectors   = 32;
-		break;
-	case SSFDC512MB:
-		Ssfdc.Model        = SSFDC512MB;
-		Ssfdc.Attribute    = FLASH | AD4CYC | BS32 | PS512;
-		Ssfdc.MaxZones     = 32;
-		Ssfdc.MaxBlocks    = 1024;
-		Ssfdc.MaxLogBlocks = 1000;
-		Ssfdc.MaxSectors   = 32;
-		break;
-	case SSFDC1GB:
-		Ssfdc.Model        = SSFDC1GB;
-		Ssfdc.Attribute    = FLASH | AD4CYC | BS32 | PS512;
-		Ssfdc.MaxZones     = 64;
-		Ssfdc.MaxBlocks    = 1024;
-		Ssfdc.MaxLogBlocks = 1000;
-		Ssfdc.MaxSectors   = 32;
-		break;
-	case SSFDC2GB:
-		Ssfdc.Model        = SSFDC2GB;
-		Ssfdc.Attribute    = FLASH | AD4CYC | BS32 | PS512;
-		Ssfdc.MaxZones     = 128;
-		Ssfdc.MaxBlocks    = 1024;
-		Ssfdc.MaxLogBlocks = 1000;
-		Ssfdc.MaxSectors   = 32;
-		break;
-	default:
-		Ssfdc.Model = NOSSFDC;
-		return ERROR;
-	}
-
-	return SMSUCCESS;
-}
-
-/* ----- _Check_D_DevCode() --------------------------------------------- */
-static u8 _Check_D_DevCode(u8 dcode)
-{
-	switch (dcode) {
-	case 0x6E:
-	case 0xE8:
-	case 0xEC: return SSFDC1MB;   /* 8Mbit (1M) NAND */
-	case 0x64:
-	case 0xEA: return SSFDC2MB;   /* 16Mbit (2M) NAND */
-	case 0x6B:
-	case 0xE3:
-	case 0xE5: return SSFDC4MB;   /* 32Mbit (4M) NAND */
-	case 0xE6: return SSFDC8MB;   /* 64Mbit (8M) NAND */
-	case 0x73: return SSFDC16MB;  /* 128Mbit (16M)NAND */
-	case 0x75: return SSFDC32MB;  /* 256Mbit (32M)NAND */
-	case 0x76: return SSFDC64MB;  /* 512Mbit (64M)NAND */
-	case 0x79: return SSFDC128MB; /* 1Gbit(128M)NAND */
-	case 0x71: return SSFDC256MB;
-	case 0xDC: return SSFDC512MB;
-	case 0xD3: return SSFDC1GB;
-	case 0xD5: return SSFDC2GB;
-	default: return NOSSFDC;
-	}
-}
-
-
-
-
-/* SmartMedia ECC Control Subroutine
- * ----- Check_D_ReadError() ----------------------------------------------
- */
-int Check_D_ReadError(u8 *redundant)
-{
-	return SMSUCCESS;
-}
-
-/* ----- Check_D_Correct() ---------------------------------------------- */
-int Check_D_Correct(u8 *buf, u8 *redundant)
-{
-	return SMSUCCESS;
-}
-
-/* ----- Check_D_CISdata() ---------------------------------------------- */
-int Check_D_CISdata(u8 *buf, u8 *redundant)
-{
-	u8 cis[] = {0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02,
-		      0xDF, 0x01, 0x20};
-
-	int cis_len = sizeof(cis);
-
-	if (!IsSSFDCCompliance && !IsXDCompliance)
-		return SMSUCCESS;
-
-	if (!memcmp(redundant + 0x0D, EccBuf, 3))
-		return memcmp(buf, cis, cis_len);
-
-	if (!_Correct_D_SwECC(buf, redundant + 0x0D, EccBuf))
-		return memcmp(buf, cis, cis_len);
-
-	buf += 0x100;
-	if (!memcmp(redundant + 0x08, EccBuf + 0x03, 3))
-		return memcmp(buf, cis, cis_len);
-
-	if (!_Correct_D_SwECC(buf, redundant + 0x08, EccBuf + 0x03))
-		return memcmp(buf, cis, cis_len);
-
-	return ERROR;
-}
-
-/* ----- Set_D_RightECC() ---------------------------------------------- */
-void Set_D_RightECC(u8 *redundant)
-{
-	/* Driver ECC Check */
-	return;
-}
-
-
diff --git a/drivers/staging/keucr/smscsi.c b/drivers/staging/keucr/smscsi.c
deleted file mode 100644
index 20858f6..0000000
--- a/drivers/staging/keucr/smscsi.c
+++ /dev/null
@@ -1,194 +0,0 @@
-#include <linux/sched.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-
-#include <scsi/scsi.h>
-#include <scsi/scsi_eh.h>
-#include <scsi/scsi_device.h>
-
-#include "usb.h"
-#include "scsiglue.h"
-#include "transport.h"
-#include "smil.h"
-
-static int SM_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb);
-static int SM_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb);
-static int SM_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb);
-static int SM_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb);
-static int SM_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb);
-static int SM_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb);
-
-/* ----- SM_SCSIIrp() -------------------------------------------------- */
-int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb)
-{
-	int    result;
-
-	us->SrbStatus = SS_SUCCESS;
-	switch (srb->cmnd[0]) {
-	case TEST_UNIT_READY:
-		result = SM_SCSI_Test_Unit_Ready(us, srb);
-		break;		/* 0x00 */
-	case INQUIRY:
-		result = SM_SCSI_Inquiry(us, srb);
-		break;		/* 0x12 */
-	case MODE_SENSE:
-		result = SM_SCSI_Mode_Sense(us, srb);
-		break;		/* 0x1A */
-	case READ_CAPACITY:
-		result = SM_SCSI_Read_Capacity(us, srb);
-		break;		/* 0x25 */
-	case READ_10:
-		result = SM_SCSI_Read(us, srb);
-		break;		/* 0x28 */
-	case WRITE_10:
-		result = SM_SCSI_Write(us, srb);
-		break;		/* 0x2A */
-
-	default:
-			us->SrbStatus = SS_ILLEGAL_REQUEST;
-			result = USB_STOR_TRANSPORT_FAILED;
-			break;
-	}
-	return result;
-}
-
-/* ----- SM_SCSI_Test_Unit_Ready() ------------------------------------- */
-static int SM_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb)
-{
-	if (us->SM_Status.Insert && us->SM_Status.Ready)
-		return USB_STOR_TRANSPORT_GOOD;
-	else {
-		ENE_SMInit(us);
-		return USB_STOR_TRANSPORT_GOOD;
-	}
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/* ----- SM_SCSI_Inquiry() --------------------------------------------- */
-static int SM_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb)
-{
-	u8 data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00,
-				 0x55, 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20,
-				 0x20, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65,
-				 0x61, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20,
-				 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
-
-	usb_stor_set_xfer_buf(us, data_ptr, 36, srb, TO_XFER_BUF);
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-
-/* ----- SM_SCSI_Mode_Sense() ------------------------------------------ */
-static int SM_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)
-{
-	u8	mediaNoWP[12] = {0x0b, 0x00, 0x00, 0x08, 0x00, 0x00,
-				0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
-	u8	mediaWP[12]   = {0x0b, 0x00, 0x80, 0x08, 0x00, 0x00,
-				0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
-
-	if (us->SM_Status.WtP)
-		usb_stor_set_xfer_buf(us, mediaWP, 12, srb, TO_XFER_BUF);
-	else
-		usb_stor_set_xfer_buf(us, mediaNoWP, 12, srb, TO_XFER_BUF);
-
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/* ----- SM_SCSI_Read_Capacity() --------------------------------------- */
-static int SM_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)
-{
-	unsigned int offset = 0;
-	struct scatterlist *sg = NULL;
-	u32   bl_num;
-	u16    bl_len;
-	u8    buf[8];
-
-	dev_dbg(&us->pusb_dev->dev, "SM_SCSI_Read_Capacity\n");
-
-	bl_len = 0x200;
-	bl_num = Ssfdc.MaxLogBlocks * Ssfdc.MaxSectors * Ssfdc.MaxZones - 1;
-
-	us->bl_num = bl_num;
-	dev_dbg(&us->pusb_dev->dev, "bl_len = %x\n", bl_len);
-	dev_dbg(&us->pusb_dev->dev, "bl_num = %x\n", bl_num);
-
-	buf[0] = (bl_num >> 24) & 0xff;
-	buf[1] = (bl_num >> 16) & 0xff;
-	buf[2] = (bl_num >> 8) & 0xff;
-	buf[3] = (bl_num >> 0) & 0xff;
-	buf[4] = (bl_len >> 24) & 0xff;
-	buf[5] = (bl_len >> 16) & 0xff;
-	buf[6] = (bl_len >> 8) & 0xff;
-	buf[7] = (bl_len >> 0) & 0xff;
-
-	usb_stor_access_xfer_buf(us, buf, 8, srb, &sg, &offset, TO_XFER_BUF);
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/* ----- SM_SCSI_Read() -------------------------------------------------- */
-static int SM_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
-{
-	int result = 0;
-	u8 *Cdb = srb->cmnd;
-	u32 bn  =  ((Cdb[2] << 24) & 0xff000000) |
-			((Cdb[3] << 16) & 0x00ff0000) |
-			((Cdb[4] << 8) & 0x0000ff00) |
-			((Cdb[5] << 0) & 0x000000ff);
-	u16  blen = ((Cdb[7] << 8) & 0xff00)     | ((Cdb[8] << 0) & 0x00ff);
-	u32	blenByte = blen * 0x200;
-	void	*buf;
-
-
-	if (bn > us->bl_num)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	buf = kmalloc(blenByte, GFP_KERNEL);
-	if (buf == NULL)
-		return USB_STOR_TRANSPORT_ERROR;
-	result = Media_D_ReadSector(us, bn, blen, buf);
-	usb_stor_set_xfer_buf(us, buf, blenByte, srb, TO_XFER_BUF);
-	kfree(buf);
-
-	if (!result)
-		return USB_STOR_TRANSPORT_GOOD;
-	else
-		return USB_STOR_TRANSPORT_ERROR;
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
-/* ----- SM_SCSI_Write() -------------------------------------------------- */
-static int SM_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
-{
-	int result = 0;
-	u8 *Cdb = srb->cmnd;
-	u32 bn  =  ((Cdb[2] << 24) & 0xff000000) |
-			((Cdb[3] << 16) & 0x00ff0000) |
-			((Cdb[4] << 8) & 0x0000ff00) |
-			((Cdb[5] << 0) & 0x000000ff);
-	u16  blen = ((Cdb[7] << 8) & 0xff00)     | ((Cdb[8] << 0) & 0x00ff);
-	u32	blenByte = blen * 0x200;
-	void	*buf;
-
-
-	if (bn > us->bl_num)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	buf = kmalloc(blenByte, GFP_KERNEL);
-	if (buf == NULL)
-		return USB_STOR_TRANSPORT_ERROR;
-	usb_stor_set_xfer_buf(us, buf, blenByte, srb, FROM_XFER_BUF);
-	result = Media_D_CopySector(us, bn, blen, buf);
-	kfree(buf);
-
-	if (!result)
-		return USB_STOR_TRANSPORT_GOOD;
-	else
-		return USB_STOR_TRANSPORT_ERROR;
-
-	return USB_STOR_TRANSPORT_GOOD;
-}
-
diff --git a/drivers/staging/keucr/transport.c b/drivers/staging/keucr/transport.c
deleted file mode 100644
index 5e59525..0000000
--- a/drivers/staging/keucr/transport.c
+++ /dev/null
@@ -1,865 +0,0 @@
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/sched.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-
-#include <scsi/scsi.h>
-#include <scsi/scsi_eh.h>
-#include <scsi/scsi_device.h>
-
-#include "usb.h"
-#include "scsiglue.h"
-#include "transport.h"
-
-/***********************************************************************
- * Data transfer routines
- ***********************************************************************/
-/*
- * usb_stor_blocking_completion()
- */
-static void usb_stor_blocking_completion(struct urb *urb)
-{
-	struct completion *urb_done_ptr = urb->context;
-
-	/* pr_info("transport --- usb_stor_blocking_completion\n"); */
-	complete(urb_done_ptr);
-}
-
-/*
- * usb_stor_msg_common()
- */
-static int usb_stor_msg_common(struct us_data *us, int timeout)
-{
-	struct completion urb_done;
-	long timeleft;
-	int status;
-
-	/* pr_info("transport --- usb_stor_msg_common\n"); */
-	if (test_bit(US_FLIDX_ABORTING, &us->dflags))
-		return -EIO;
-
-	init_completion(&urb_done);
-
-	us->current_urb->context = &urb_done;
-	us->current_urb->actual_length = 0;
-	us->current_urb->error_count = 0;
-	us->current_urb->status = 0;
-
-	us->current_urb->transfer_flags = 0;
-	if (us->current_urb->transfer_buffer == us->iobuf)
-		us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-	us->current_urb->transfer_dma = us->iobuf_dma;
-	us->current_urb->setup_dma = us->cr_dma;
-
-	status = usb_submit_urb(us->current_urb, GFP_NOIO);
-	if (status)
-		return status;
-
-	set_bit(US_FLIDX_URB_ACTIVE, &us->dflags);
-
-	if (test_bit(US_FLIDX_ABORTING, &us->dflags)) {
-		if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {
-			/* pr_info("-- cancelling URB\n"); */
-			usb_unlink_urb(us->current_urb);
-		}
-	}
-
-	timeleft = wait_for_completion_interruptible_timeout(&urb_done,
-					timeout ? : MAX_SCHEDULE_TIMEOUT);
-	clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags);
-
-	if (timeleft <= 0) {
-		/* pr_info("%s -- cancelling URB\n",
-			timeleft == 0 ? "Timeout" : "Signal"); */
-		usb_kill_urb(us->current_urb);
-	}
-
-	return us->current_urb->status;
-}
-
-/*
- * usb_stor_print_cmd():
- */
-static void usb_stor_print_cmd(struct us_data *us, struct scsi_cmnd *srb)
-{
-	u8 *Cdb = srb->cmnd;
-	u32   cmd = Cdb[0];
-
-	switch (cmd) {
-	case TEST_UNIT_READY:
-		break;
-	case INQUIRY:
-		dev_dbg(&us->pusb_dev->dev,
-				"scsi cmd %X --- SCSIOP_INQUIRY\n", cmd);
-		break;
-	case MODE_SENSE:
-		dev_dbg(&us->pusb_dev->dev,
-				"scsi cmd %X --- SCSIOP_MODE_SENSE\n", cmd);
-		break;
-	case START_STOP:
-		dev_dbg(&us->pusb_dev->dev,
-				"scsi cmd %X --- SCSIOP_START_STOP\n", cmd);
-		break;
-	case READ_CAPACITY:
-		dev_dbg(&us->pusb_dev->dev,
-				"scsi cmd %X --- SCSIOP_READ_CAPACITY\n", cmd);
-		break;
-	case READ_10:
-		break;
-	case WRITE_10:
-		break;
-	case ALLOW_MEDIUM_REMOVAL:
-		dev_dbg(&us->pusb_dev->dev,
-			"scsi cmd %X --- SCSIOP_ALLOW_MEDIUM_REMOVAL\n", cmd);
-		break;
-	default:
-		dev_dbg(&us->pusb_dev->dev, "scsi cmd %X --- Other cmd\n", cmd);
-		break;
-	}
-}
-
-/*
- * usb_stor_control_msg()
- */
-int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
-		 u8 request, u8 requesttype, u16 value, u16 index,
-		 void *data, u16 size, int timeout)
-{
-	int status;
-
-	/* pr_info("transport --- usb_stor_control_msg\n"); */
-
-	/* fill in the devrequest structure */
-	us->cr->bRequestType = requesttype;
-	us->cr->bRequest = request;
-	us->cr->wValue = cpu_to_le16(value);
-	us->cr->wIndex = cpu_to_le16(index);
-	us->cr->wLength = cpu_to_le16(size);
-
-	/* fill and submit the URB */
-	usb_fill_control_urb(us->current_urb, us->pusb_dev, pipe,
-			 (unsigned char *) us->cr, data, size,
-			 usb_stor_blocking_completion, NULL);
-	status = usb_stor_msg_common(us, timeout);
-
-	/* return the actual length of the data transferred if no error */
-	if (status == 0)
-		status = us->current_urb->actual_length;
-	return status;
-}
-
-/*
- * usb_stor_clear_halt()
- */
-int usb_stor_clear_halt(struct us_data *us, unsigned int pipe)
-{
-	int result;
-	int endp = usb_pipeendpoint(pipe);
-
-	/* pr_info("transport --- usb_stor_clear_halt\n"); */
-	if (usb_pipein(pipe))
-		endp |= USB_DIR_IN;
-
-	result = usb_stor_control_msg(us, us->send_ctrl_pipe,
-		USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT,
-		USB_ENDPOINT_HALT, endp,
-		NULL, 0, 3*HZ);
-
-	/* reset the endpoint toggle */
-	if (result >= 0)
-		/* usb_settoggle(us->pusb_dev, usb_pipeendpoint(pipe),
-						usb_pipeout(pipe), 0); */
-		usb_reset_endpoint(us->pusb_dev, endp);
-
-	return result;
-}
-
-/*
- * interpret_urb_result()
- */
-static int interpret_urb_result(struct us_data *us, unsigned int pipe,
-		unsigned int length, int result, unsigned int partial)
-{
-	/* pr_info("transport --- interpret_urb_result\n"); */
-	switch (result) {
-	/* no error code; did we send all the data? */
-	case 0:
-		if (partial != length) {
-			/* pr_info("-- short transfer\n"); */
-			return USB_STOR_XFER_SHORT;
-		}
-		/* pr_info("-- transfer complete\n"); */
-		return USB_STOR_XFER_GOOD;
-	case -EPIPE:
-		if (usb_pipecontrol(pipe)) {
-			/* pr_info("-- stall on control pipe\n"); */
-			return USB_STOR_XFER_STALLED;
-		}
-		/* pr_info("clearing endpoint halt for pipe 0x%x\n", pipe); */
-		if (usb_stor_clear_halt(us, pipe) < 0)
-			return USB_STOR_XFER_ERROR;
-		return USB_STOR_XFER_STALLED;
-	case -EOVERFLOW:
-		/* pr_info("-- babble\n"); */
-		return USB_STOR_XFER_LONG;
-	case -ECONNRESET:
-		/* pr_info("-- transfer cancelled\n"); */
-		return USB_STOR_XFER_ERROR;
-	case -EREMOTEIO:
-		/* pr_info("-- short read transfer\n"); */
-		return USB_STOR_XFER_SHORT;
-	case -EIO:
-		/* pr_info("-- abort or disconnect in progress\n"); */
-		return USB_STOR_XFER_ERROR;
-	default:
-		/* pr_info("-- unknown error\n"); */
-		return USB_STOR_XFER_ERROR;
-	}
-}
-
-/*
- * usb_stor_bulk_transfer_buf()
- */
-int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
-	void *buf, unsigned int length, unsigned int *act_len)
-{
-	int result;
-
-	/* pr_info("transport --- usb_stor_bulk_transfer_buf\n"); */
-
-	/* fill and submit the URB */
-	usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf,
-				length, usb_stor_blocking_completion, NULL);
-	result = usb_stor_msg_common(us, 0);
-
-	/* store the actual length of the data transferred */
-	if (act_len)
-		*act_len = us->current_urb->actual_length;
-
-	return interpret_urb_result(us, pipe, length, result,
-					us->current_urb->actual_length);
-}
-
-/*
- * usb_stor_bulk_transfer_sglist()
- */
-static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
-		struct scatterlist *sg, int num_sg, unsigned int length,
-		unsigned int *act_len)
-{
-	int result;
-
-	/* pr_info("transport --- usb_stor_bulk_transfer_sglist\n"); */
-	if (test_bit(US_FLIDX_ABORTING, &us->dflags))
-		return USB_STOR_XFER_ERROR;
-
-	/* initialize the scatter-gather request block */
-	result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
-					sg, num_sg, length, GFP_NOIO);
-	if (result) {
-		/* pr_info("usb_sg_init returned %d\n", result); */
-		return USB_STOR_XFER_ERROR;
-	}
-
-	/* since the block has been initialized successfully,
-					it's now okay to cancel it */
-	set_bit(US_FLIDX_SG_ACTIVE, &us->dflags);
-
-	/* did an abort/disconnect occur during the submission? */
-	if (test_bit(US_FLIDX_ABORTING, &us->dflags)) {
-		/* cancel the request, if it hasn't been cancelled already */
-		if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {
-			/* pr_info("-- cancelling sg request\n"); */
-			usb_sg_cancel(&us->current_sg);
-		}
-	}
-
-	/* wait for the completion of the transfer */
-	usb_sg_wait(&us->current_sg);
-	clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags);
-
-	result = us->current_sg.status;
-	if (act_len)
-		*act_len = us->current_sg.bytes;
-
-	return interpret_urb_result(us, pipe, length,
-					result, us->current_sg.bytes);
-}
-
-/*
- * usb_stor_bulk_srb()
- */
-int usb_stor_bulk_srb(struct us_data *us, unsigned int pipe,
-					struct scsi_cmnd *srb)
-{
-	unsigned int partial;
-	int result = usb_stor_bulk_transfer_sglist(us, pipe, scsi_sglist(srb),
-				      scsi_sg_count(srb), scsi_bufflen(srb),
-				      &partial);
-
-	scsi_set_resid(srb, scsi_bufflen(srb) - partial);
-	return result;
-}
-
-/*
- * usb_stor_bulk_transfer_sg()
- */
-int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
-		void *buf, unsigned int length_left, int use_sg, int *residual)
-{
-	int result;
-	unsigned int partial;
-
-	/* pr_info("transport --- usb_stor_bulk_transfer_sg\n"); */
-	/* are we scatter-gathering? */
-	if (use_sg) {
-		/* use the usb core scatter-gather primitives */
-		result = usb_stor_bulk_transfer_sglist(us, pipe,
-				(struct scatterlist *) buf, use_sg,
-				length_left, &partial);
-		length_left -= partial;
-	} else {
-		/* no scatter-gather, just make the request */
-		result = usb_stor_bulk_transfer_buf(us, pipe, buf,
-							length_left, &partial);
-		length_left -= partial;
-	}
-
-	/* store the residual and return the error code */
-	if (residual)
-		*residual = length_left;
-	return result;
-}
-
-/***********************************************************************
- * Transport routines
- ***********************************************************************/
-/*
- * usb_stor_invoke_transport()
- */
-void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
-{
-	int need_auto_sense;
-	int result;
-
-	/* pr_info("transport --- usb_stor_invoke_transport\n"); */
-	usb_stor_print_cmd(us, srb);
-	/* send the command to the transport layer */
-	scsi_set_resid(srb, 0);
-	result = us->transport(srb, us); /* usb_stor_Bulk_transport; */
-
-	/* if the command gets aborted by the higher layers,
-		we need to short-circuit all other processing */
-	if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
-		/* pr_info("-- command was aborted\n"); */
-		srb->result = DID_ABORT << 16;
-		goto Handle_Errors;
-	}
-
-	/* if there is a transport error, reset and don't auto-sense */
-	if (result == USB_STOR_TRANSPORT_ERROR) {
-		/* pr_info("-- transport indicates error, resetting\n"); */
-		srb->result = DID_ERROR << 16;
-		goto Handle_Errors;
-	}
-
-	/* if the transport provided its own sense data, don't auto-sense */
-	if (result == USB_STOR_TRANSPORT_NO_SENSE) {
-		srb->result = SAM_STAT_CHECK_CONDITION;
-		return;
-	}
-
-	srb->result = SAM_STAT_GOOD;
-
-	/* Determine if we need to auto-sense */
-	need_auto_sense = 0;
-
-	if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_DPCM_USB) &&
-				srb->sc_data_direction != DMA_FROM_DEVICE) {
-		/* pr_info("-- CB transport device requiring auto-sense\n"); */
-		need_auto_sense = 1;
-	}
-
-	if (result == USB_STOR_TRANSPORT_FAILED) {
-		/* pr_info("-- transport indicates command failure\n"); */
-		need_auto_sense = 1;
-	}
-
-	/* Now, if we need to do the auto-sense, let's do it */
-	if (need_auto_sense) {
-		int temp_result;
-		struct scsi_eh_save ses;
-
-		pr_info("Issuing auto-REQUEST_SENSE\n");
-
-		scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE);
-
-		/* we must do the protocol translation here */
-		if (us->subclass == USB_SC_RBC ||
-			us->subclass == USB_SC_SCSI ||
-			us->subclass == USB_SC_CYP_ATACB) {
-			srb->cmd_len = 6;
-		} else {
-			srb->cmd_len = 12;
-		}
-		/* issue the auto-sense command */
-		scsi_set_resid(srb, 0);
-		temp_result = us->transport(us->srb, us);
-
-		/* let's clean up right away */
-		scsi_eh_restore_cmnd(srb, &ses);
-
-		if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
-			/* pr_info("-- auto-sense aborted\n"); */
-			srb->result = DID_ABORT << 16;
-			goto Handle_Errors;
-		}
-		if (temp_result != USB_STOR_TRANSPORT_GOOD) {
-			/* pr_info("-- auto-sense failure\n"); */
-			srb->result = DID_ERROR << 16;
-			if (!(us->fflags & US_FL_SCM_MULT_TARG))
-				goto Handle_Errors;
-			return;
-		}
-
-		/* set the result so the higher layers expect this data */
-		srb->result = SAM_STAT_CHECK_CONDITION;
-
-		if (result == USB_STOR_TRANSPORT_GOOD &&
-			(srb->sense_buffer[2] & 0xaf) == 0 &&
-			srb->sense_buffer[12] == 0 &&
-			srb->sense_buffer[13] == 0) {
-			srb->result = SAM_STAT_GOOD;
-			srb->sense_buffer[0] = 0x0;
-		}
-	}
-
-	/* Did we transfer less than the minimum amount required? */
-	if (srb->result == SAM_STAT_GOOD && scsi_bufflen(srb) -
-				scsi_get_resid(srb) < srb->underflow)
-		srb->result = (DID_ERROR << 16);
-		/* v02 | (SUGGEST_RETRY << 24); */
-
-	return;
-
-Handle_Errors:
-	scsi_lock(us_to_host(us));
-	set_bit(US_FLIDX_RESETTING, &us->dflags);
-	clear_bit(US_FLIDX_ABORTING, &us->dflags);
-	scsi_unlock(us_to_host(us));
-
-	mutex_unlock(&us->dev_mutex);
-	result = usb_stor_port_reset(us);
-	mutex_lock(&us->dev_mutex);
-
-	if (result < 0) {
-		scsi_lock(us_to_host(us));
-		usb_stor_report_device_reset(us);
-		scsi_unlock(us_to_host(us));
-		us->transport_reset(us);
-	}
-	clear_bit(US_FLIDX_RESETTING, &us->dflags);
-}
-
-/*
- * ENE_stor_invoke_transport()
- */
-void ENE_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
-{
-	int result = 0;
-
-	/* pr_info("transport --- ENE_stor_invoke_transport\n"); */
-	usb_stor_print_cmd(us, srb);
-	/* send the command to the transport layer */
-	scsi_set_resid(srb, 0);
-	if (!(us->SM_Status.Ready))
-		result = ENE_InitMedia(us);
-
-	if (us->Power_IsResum == true) {
-		result = ENE_InitMedia(us);
-		us->Power_IsResum = false;
-	}
-
-	if (us->SM_Status.Ready)
-		result = SM_SCSIIrp(us, srb);
-
-	/* if the command gets aborted by the higher layers,
-		we need to short-circuit all other processing */
-	if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
-		/* pr_info("-- command was aborted\n"); */
-		srb->result = DID_ABORT << 16;
-		goto Handle_Errors;
-	}
-
-	/* if there is a transport error, reset and don't auto-sense */
-	if (result == USB_STOR_TRANSPORT_ERROR) {
-		/* pr_info("-- transport indicates error, resetting\n"); */
-		srb->result = DID_ERROR << 16;
-		goto Handle_Errors;
-	}
-
-	/* if the transport provided its own sense data, don't auto-sense */
-	if (result == USB_STOR_TRANSPORT_NO_SENSE) {
-		srb->result = SAM_STAT_CHECK_CONDITION;
-		return;
-	}
-
-	srb->result = SAM_STAT_GOOD;
-	if (result == USB_STOR_TRANSPORT_FAILED) {
-		/* pr_info("-- transport indicates command failure\n"); */
-		/* need_auto_sense = 1; */
-		BuildSenseBuffer(srb, us->SrbStatus);
-		srb->result = SAM_STAT_CHECK_CONDITION;
-	}
-
-	/* Did we transfer less than the minimum amount required? */
-	if (srb->result == SAM_STAT_GOOD && scsi_bufflen(srb) -
-					scsi_get_resid(srb) < srb->underflow)
-		srb->result = (DID_ERROR << 16);
-		/* v02 | (SUGGEST_RETRY << 24); */
-
-	return;
-
-Handle_Errors:
-	scsi_lock(us_to_host(us));
-	set_bit(US_FLIDX_RESETTING, &us->dflags);
-	clear_bit(US_FLIDX_ABORTING, &us->dflags);
-	scsi_unlock(us_to_host(us));
-
-	mutex_unlock(&us->dev_mutex);
-	result = usb_stor_port_reset(us);
-	mutex_lock(&us->dev_mutex);
-
-	if (result < 0) {
-		scsi_lock(us_to_host(us));
-		usb_stor_report_device_reset(us);
-		scsi_unlock(us_to_host(us));
-		us->transport_reset(us);
-	}
-	clear_bit(US_FLIDX_RESETTING, &us->dflags);
-}
-
-/*
- * BuildSenseBuffer()
- */
-void BuildSenseBuffer(struct scsi_cmnd *srb, int SrbStatus)
-{
-	u8    *buf = srb->sense_buffer;
-	u8    asc;
-
-	pr_info("transport --- BuildSenseBuffer\n");
-	switch (SrbStatus) {
-	case SS_NOT_READY:
-		asc = 0x3a;
-		break;  /*  sense key = 0x02 */
-	case SS_MEDIUM_ERR:
-		asc = 0x0c;
-		break;  /*  sense key = 0x03 */
-	case SS_ILLEGAL_REQUEST:
-		asc = 0x20;
-		break;  /*  sense key = 0x05 */
-	default:
-		asc = 0x00;
-		break;  /*  ?? */
-	}
-
-	memset(buf, 0, 18);
-	buf[0x00] = 0xf0;
-	buf[0x02] = SrbStatus;
-	buf[0x07] = 0x0b;
-	buf[0x0c] = asc;
-}
-
-/*
- * usb_stor_stop_transport()
- */
-void usb_stor_stop_transport(struct us_data *us)
-{
-	/* pr_info("transport --- usb_stor_stop_transport\n"); */
-
-	if (test_and_clear_bit(US_FLIDX_URB_ACTIVE, &us->dflags)) {
-		/* pr_info("-- cancelling URB\n"); */
-		usb_unlink_urb(us->current_urb);
-	}
-
-	if (test_and_clear_bit(US_FLIDX_SG_ACTIVE, &us->dflags)) {
-		/* pr_info("-- cancelling sg request\n"); */
-		usb_sg_cancel(&us->current_sg);
-	}
-}
-
-/*
- * usb_stor_Bulk_max_lun()
- */
-int usb_stor_Bulk_max_lun(struct us_data *us)
-{
-	int result;
-
-	/* pr_info("transport --- usb_stor_Bulk_max_lun\n"); */
-	/* issue the command */
-	us->iobuf[0] = 0;
-	result = usb_stor_control_msg(us, us->recv_ctrl_pipe,
-				 US_BULK_GET_MAX_LUN,
-				 USB_DIR_IN | USB_TYPE_CLASS |
-				 USB_RECIP_INTERFACE,
-				 0, us->ifnum, us->iobuf, 1, HZ);
-
-	/* pr_info("GetMaxLUN command result is %d, data is %d\n",
-						result, us->iobuf[0]); */
-
-	/* if we have a successful request, return the result */
-	if (result > 0)
-		return us->iobuf[0];
-
-	return 0;
-}
-
-/*
- * usb_stor_Bulk_transport()
- */
-int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
-{
-	struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
-	struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap *) us->iobuf;
-	unsigned int transfer_length = scsi_bufflen(srb);
-	unsigned int residue;
-	int result;
-	int fake_sense = 0;
-	unsigned int cswlen;
-	unsigned int cbwlen = US_BULK_CB_WRAP_LEN;
-
-	/* pr_info("transport --- usb_stor_Bulk_transport\n"); */
-	/* Take care of BULK32 devices; set extra byte to 0 */
-	if (unlikely(us->fflags & US_FL_BULK32)) {
-		cbwlen = 32;
-		us->iobuf[31] = 0;
-	}
-
-	/* set up the command wrapper */
-	bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
-	bcb->DataTransferLength = cpu_to_le32(transfer_length);
-	bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? 1 << 7 : 0;
-	bcb->Tag = ++us->tag;
-	bcb->Lun = srb->device->lun;
-	if (us->fflags & US_FL_SCM_MULT_TARG)
-		bcb->Lun |= srb->device->id << 4;
-	bcb->Length = srb->cmd_len;
-
-	/* copy the command payload */
-	memset(bcb->CDB, 0, sizeof(bcb->CDB));
-	memcpy(bcb->CDB, srb->cmnd, bcb->Length);
-
-	/*  send command */
-	/* send it to out endpoint */
-	/* pr_info("Bulk Command S 0x%x T 0x%x L %d F %d Trg %d LUN %d CL %d\n",
-			le32_to_cpu(bcb->Signature), bcb->Tag,
-			le32_to_cpu(bcb->DataTransferLength), bcb->Flags,
-			(bcb->Lun >> 4), (bcb->Lun & 0x0F),
-			bcb->Length); */
-	result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
-						bcb, cbwlen, NULL);
-	/* pr_info("Bulk command transfer result=%d\n", result); */
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	if (unlikely(us->fflags & US_FL_GO_SLOW))
-		udelay(125);
-
-	/*  R/W data */
-	if (transfer_length) {
-		unsigned int pipe;
-
-		if (srb->sc_data_direction == DMA_FROM_DEVICE)
-			pipe = us->recv_bulk_pipe;
-		else
-			pipe = us->send_bulk_pipe;
-
-		result = usb_stor_bulk_srb(us, pipe, srb);
-		/* pr_info("Bulk data transfer result 0x%x\n", result); */
-		if (result == USB_STOR_XFER_ERROR)
-			return USB_STOR_TRANSPORT_ERROR;
-
-		if (result == USB_STOR_XFER_LONG)
-			fake_sense = 1;
-	}
-
-	/* get CSW for device status */
-	/* pr_info("Attempting to get CSW...\n"); */
-	result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
-						US_BULK_CS_WRAP_LEN, &cswlen);
-
-	if (result == USB_STOR_XFER_SHORT && cswlen == 0) {
-		/* pr_info("Received 0-length CSW; retrying...\n"); */
-		result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
-						US_BULK_CS_WRAP_LEN, &cswlen);
-	}
-
-	/* did the attempt to read the CSW fail? */
-	if (result == USB_STOR_XFER_STALLED) {
-		/* get the status again */
-		/* pr_info("Attempting to get CSW (2nd try)...\n"); */
-		result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
-						US_BULK_CS_WRAP_LEN, NULL);
-	}
-
-	/* if we still have a failure at this point, we're in trouble */
-	/* pr_info("Bulk status result = %d\n", result); */
-	if (result != USB_STOR_XFER_GOOD)
-		return USB_STOR_TRANSPORT_ERROR;
-
-	/* check bulk status */
-	residue = le32_to_cpu(bcs->Residue);
-	/* pr_info("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n",
-				le32_to_cpu(bcs->Signature),
-				bcs->Tag, residue, bcs->Status); */
-	if (!(bcs->Tag == us->tag ||
-		(us->fflags & US_FL_BULK_IGNORE_TAG)) ||
-		bcs->Status > US_BULK_STAT_PHASE) {
-		/* pr_info("Bulk logical error\n"); */
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	if (!us->bcs_signature) {
-		us->bcs_signature = bcs->Signature;
-		/* if (us->bcs_signature != cpu_to_le32(US_BULK_CS_SIGN)) */
-		/* pr_info("Learnt BCS signature 0x%08X\n",
-				le32_to_cpu(us->bcs_signature)); */
-	} else if (bcs->Signature != us->bcs_signature) {
-		/* pr_info("Signature mismatch: got %08X, expecting %08X\n",
-			  le32_to_cpu(bcs->Signature),
-			  le32_to_cpu(us->bcs_signature)); */
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-
-	/* try to compute the actual residue, based on how much data
-	 * was really transferred and what the device tells us */
-	if (residue && !(us->fflags & US_FL_IGNORE_RESIDUE)) {
-
-		/* Heuristically detect devices that generate bogus residues
-		 * by seeing what happens with INQUIRY and READ CAPACITY
-		 * commands.
-		 */
-		if (bcs->Status == US_BULK_STAT_OK &&
-				scsi_get_resid(srb) == 0 &&
-					((srb->cmnd[0] == INQUIRY &&
-						transfer_length == 36) ||
-					(srb->cmnd[0] == READ_CAPACITY &&
-						transfer_length == 8))) {
-			us->fflags |= US_FL_IGNORE_RESIDUE;
-
-		} else {
-			residue = min(residue, transfer_length);
-			scsi_set_resid(srb, max_t(int, scsi_get_resid(srb),
-							residue));
-		}
-	}
-
-	/* based on the status code, we report good or bad */
-	switch (bcs->Status) {
-	case US_BULK_STAT_OK:
-		if (fake_sense) {
-			memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB,
-					sizeof(usb_stor_sense_invalidCDB));
-			return USB_STOR_TRANSPORT_NO_SENSE;
-		}
-		return USB_STOR_TRANSPORT_GOOD;
-
-	case US_BULK_STAT_FAIL:
-		return USB_STOR_TRANSPORT_FAILED;
-
-	case US_BULK_STAT_PHASE:
-		return USB_STOR_TRANSPORT_ERROR;
-	}
-	return USB_STOR_TRANSPORT_ERROR;
-}
-
-/***********************************************************************
- * Reset routines
- ***********************************************************************/
-/*
- * usb_stor_reset_common()
- */
-static int usb_stor_reset_common(struct us_data *us,
-		u8 request, u8 requesttype,
-		u16 value, u16 index, void *data, u16 size)
-{
-	int result;
-	int result2;
-
-	/* pr_info("transport --- usb_stor_reset_common\n"); */
-	if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
-		/* pr_info("No reset during disconnect\n"); */
-		return -EIO;
-	}
-
-	result = usb_stor_control_msg(us, us->send_ctrl_pipe,
-			request, requesttype, value, index, data, size,	5*HZ);
-
-	if (result < 0) {
-		/* pr_info("Soft reset failed: %d\n", result); */
-		return result;
-	}
-
-	wait_event_interruptible_timeout(us->delay_wait,
-			test_bit(US_FLIDX_DISCONNECTING, &us->dflags),	HZ*6);
-
-	if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
-		/* pr_info("Reset interrupted by disconnect\n"); */
-		return -EIO;
-	}
-
-	/* pr_info("Soft reset: clearing bulk-in endpoint halt\n"); */
-	result = usb_stor_clear_halt(us, us->recv_bulk_pipe);
-
-	/* pr_info("Soft reset: clearing bulk-out endpoint halt\n"); */
-	result2 = usb_stor_clear_halt(us, us->send_bulk_pipe);
-
-	/* return a result code based on the result of the clear-halts */
-	if (result >= 0)
-		result = result2;
-	/* if (result < 0) */
-		/* pr_info("Soft reset failed\n"); */
-	/* else */
-		/* pr_info("Soft reset done\n"); */
-	return result;
-}
-
-/*
- * usb_stor_Bulk_reset()
- */
-int usb_stor_Bulk_reset(struct us_data *us)
-{
-	/* pr_info("transport --- usb_stor_Bulk_reset\n"); */
-	return usb_stor_reset_common(us, US_BULK_RESET_REQUEST,
-				 USB_TYPE_CLASS | USB_RECIP_INTERFACE,
-				 0, us->ifnum, NULL, 0);
-}
-
-/*
- * usb_stor_port_reset()
- */
-int usb_stor_port_reset(struct us_data *us)
-{
-	int result;
-
-	/* pr_info("transport --- usb_stor_port_reset\n"); */
-	result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);
-	if (result < 0)
-		pr_info("unable to lock device for reset: %d\n", result);
-	else {
-		/* Were we disconnected while waiting for the lock? */
-		if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
-			result = -EIO;
-			/* pr_info("No reset during disconnect\n"); */
-		} else {
-			result = usb_reset_device(us->pusb_dev);
-			/* pr_info("usb_reset_composite_device returns %d\n",
-								result); */
-		}
-		usb_unlock_device(us->pusb_dev);
-	}
-	return result;
-}
-
-
diff --git a/drivers/staging/keucr/transport.h b/drivers/staging/keucr/transport.h
deleted file mode 100644
index abd8e5a..0000000
--- a/drivers/staging/keucr/transport.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef _TRANSPORT_H_
-#define _TRANSPORT_H_
-
-#include <linux/blkdev.h>
-
-/* usb_stor_bulk_transfer_xxx() return codes, in order of severity */
-#define USB_STOR_XFER_GOOD	0	/* good transfer                 */
-#define USB_STOR_XFER_SHORT	1	/* transferred less than expected */
-#define USB_STOR_XFER_STALLED	2	/* endpoint stalled              */
-#define USB_STOR_XFER_LONG	3	/* device tried to send too much */
-#define USB_STOR_XFER_ERROR	4	/* transfer died in the middle   */
-
-/* Transport return codes */
-#define USB_STOR_TRANSPORT_GOOD	0	/* Transport good, command good	*/
-#define USB_STOR_TRANSPORT_FAILED 1	/* Transport good, command failed */
-#define USB_STOR_TRANSPORT_NO_SENSE 2	/* Command failed, no auto-sense */
-#define USB_STOR_TRANSPORT_ERROR 3	/* Transport bad (i.e. device dead) */
-
-/*
- * We used to have USB_STOR_XFER_ABORTED and USB_STOR_TRANSPORT_ABORTED
- * return codes.  But now the transport and low-level transfer routines
- * treat an abort as just another error (-ENOENT for a cancelled URB).
- * It is up to the invoke_transport() function to test for aborts and
- * distinguish them from genuine communication errors.
- */
-
-/* CBI accept device specific command */
-#define US_CBI_ADSC		0
-extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*);
-extern int usb_stor_Bulk_max_lun(struct us_data *);
-extern int usb_stor_Bulk_reset(struct us_data *);
-extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
-extern void usb_stor_stop_transport(struct us_data *);
-extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
-		u8 request, u8 requesttype, u16 value, u16 index,
-		void *data, u16 size, int timeout);
-extern int usb_stor_clear_halt(struct us_data *us, unsigned int pipe);
-extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
-		void *buf, unsigned int length, unsigned int *act_len);
-extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
-		void *buf, unsigned int length, int use_sg, int *residual);
-extern int usb_stor_bulk_srb(struct us_data *us, unsigned int pipe,
-		struct scsi_cmnd *srb);
-extern int usb_stor_port_reset(struct us_data *us);
-
-/* Protocol handling routines */
-enum xfer_buf_dir	{TO_XFER_BUF, FROM_XFER_BUF};
-extern unsigned int usb_stor_access_xfer_buf(struct us_data*,
-	unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb,
-	struct scatterlist **, unsigned int *offset, enum xfer_buf_dir dir);
-extern void usb_stor_set_xfer_buf(struct us_data*, unsigned char *buffer,
-	unsigned int buflen, struct scsi_cmnd *srb,
-	unsigned int dir);
-
-/*
- * ENE scsi function
- */
-extern void ENE_stor_invoke_transport(struct scsi_cmnd *, struct us_data *);
-extern int ENE_InitMedia(struct us_data *);
-extern int ENE_SMInit(struct us_data *);
-extern int ENE_SendScsiCmd(struct us_data*, u8, void*, int);
-extern int ENE_LoadBinCode(struct us_data*, u8);
-extern int ene_read_byte(struct us_data*, u16 index, void *buf);
-extern int ENE_Read_Data(struct us_data*, void *buf, unsigned int length);
-extern int ENE_Write_Data(struct us_data*, void *buf, unsigned int length);
-extern void BuildSenseBuffer(struct scsi_cmnd *, int);
-
-/*
- * ENE scsi function
- */
-extern int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
-
-#endif
diff --git a/drivers/staging/keucr/usb.c b/drivers/staging/keucr/usb.c
deleted file mode 100644
index 1e2073b..0000000
--- a/drivers/staging/keucr/usb.c
+++ /dev/null
@@ -1,643 +0,0 @@
-#include <linux/sched.h>
-#include <linux/errno.h>
-#include <linux/freezer.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/kthread.h>
-#include <linux/mutex.h>
-#include <linux/utsname.h>
-
-#include <scsi/scsi.h>
-#include <scsi/scsi_cmnd.h>
-#include <scsi/scsi_device.h>
-
-#include "usb.h"
-#include "scsiglue.h"
-#include "smil.h"
-#include "transport.h"
-
-/* Some informational data */
-MODULE_AUTHOR("Domao");
-MODULE_DESCRIPTION("ENE USB Mass Storage driver for Linux");
-MODULE_LICENSE("GPL");
-
-static unsigned int delay_use = 1;
-
-static struct usb_device_id eucr_usb_ids[] = {
-	{ USB_DEVICE(0x058f, 0x6366) },
-	{ USB_DEVICE(0x0cf2, 0x6230) },
-	{ USB_DEVICE(0x0cf2, 0x6250) },
-	{ }                                            /* Terminating entry */
-};
-MODULE_DEVICE_TABLE(usb, eucr_usb_ids);
-
-
-#ifdef CONFIG_PM
-
-static int eucr_suspend(struct usb_interface *iface, pm_message_t message)
-{
-	struct us_data *us = usb_get_intfdata(iface);
-
-	pr_info("--- eucr_suspend ---\n");
-	/* Wait until no command is running */
-	mutex_lock(&us->dev_mutex);
-
-	if (us->suspend_resume_hook)
-		(us->suspend_resume_hook)(us, US_SUSPEND);
-
-	mutex_unlock(&us->dev_mutex);
-	return 0;
-}
-
-static int eucr_resume(struct usb_interface *iface)
-{
-	u8    tmp = 0;
-	struct us_data *us = usb_get_intfdata(iface);
-
-	pr_info("--- eucr_resume---\n");
-	mutex_lock(&us->dev_mutex);
-
-	if (us->suspend_resume_hook)
-		(us->suspend_resume_hook)(us, US_RESUME);
-
-
-	mutex_unlock(&us->dev_mutex);
-
-	us->Power_IsResum = true;
-
-	us->SM_Status = *(struct keucr_sm_status *)&tmp;
-
-	return 0;
-}
-
-static int eucr_reset_resume(struct usb_interface *iface)
-{
-	u8    tmp = 0;
-	struct us_data *us = usb_get_intfdata(iface);
-
-	pr_info("--- eucr_reset_resume---\n");
-
-	/* Report the reset to the SCSI core */
-	usb_stor_report_bus_reset(us);
-
-	/*
-	 * FIXME: Notify the subdrivers that they need to reinitialize
-	 * the device
-	 */
-
-	us->Power_IsResum = true;
-
-	us->SM_Status = *(struct keucr_sm_status *)&tmp;
-
-	return 0;
-}
-
-#else
-
-#define eucr_suspend		NULL
-#define eucr_resume		NULL
-#define eucr_reset_resume	NULL
-
-#endif
-
-static int eucr_pre_reset(struct usb_interface *iface)
-{
-	struct us_data *us = usb_get_intfdata(iface);
-
-	pr_info("usb --- eucr_pre_reset\n");
-
-	/* Make sure no command runs during the reset */
-	mutex_lock(&us->dev_mutex);
-	return 0;
-}
-
-static int eucr_post_reset(struct usb_interface *iface)
-{
-	struct us_data *us = usb_get_intfdata(iface);
-
-	pr_info("usb --- eucr_post_reset\n");
-
-	/* Report the reset to the SCSI core */
-	usb_stor_report_bus_reset(us);
-
-	mutex_unlock(&us->dev_mutex);
-	return 0;
-}
-
-void fill_inquiry_response(struct us_data *us, unsigned char *data,
-							unsigned int data_len)
-{
-	pr_info("usb --- fill_inquiry_response\n");
-	if (data_len < 36) /* You lose. */
-		return;
-
-	if (data[0]&0x20) {
-		memset(data+8, 0, 28);
-	} else {
-		u16 bcdDevice =
-			le16_to_cpu(us->pusb_dev->descriptor.bcdDevice);
-		memcpy(data+8, us->unusual_dev->vendorName,
-			strlen(us->unusual_dev->vendorName) > 8 ? 8 :
-			strlen(us->unusual_dev->vendorName));
-		memcpy(data+16, us->unusual_dev->productName,
-			strlen(us->unusual_dev->productName) > 16 ? 16 :
-			strlen(us->unusual_dev->productName));
-		data[32] = 0x30 + ((bcdDevice>>12) & 0x0F);
-		data[33] = 0x30 + ((bcdDevice>>8) & 0x0F);
-		data[34] = 0x30 + ((bcdDevice>>4) & 0x0F);
-		data[35] = 0x30 + ((bcdDevice) & 0x0F);
-	}
-	usb_stor_set_xfer_buf(us, data, data_len, us->srb, TO_XFER_BUF);
-}
-
-static int usb_stor_control_thread(void *__us)
-{
-	struct us_data *us = (struct us_data *)__us;
-	struct Scsi_Host *host = us_to_host(us);
-
-	pr_info("usb --- usb_stor_control_thread\n");
-	for (;;) {
-		if (wait_for_completion_interruptible(&us->cmnd_ready))
-			break;
-
-		/* lock the device pointers */
-		mutex_lock(&(us->dev_mutex));
-
-		/* if the device has disconnected, we are free to exit */
-		if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) {
-			mutex_unlock(&us->dev_mutex);
-			break;
-		}
-
-		/* lock access to the state */
-		scsi_lock(host);
-
-		/* When we are called with no command pending, we're done */
-		if (us->srb == NULL) {
-			scsi_unlock(host);
-			mutex_unlock(&us->dev_mutex);
-			break;
-		}
-
-		/* has the command timed out *already* ? */
-		if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
-			us->srb->result = DID_ABORT << 16;
-			goto SkipForAbort;
-		}
-
-		scsi_unlock(host);
-
-		if (us->srb->sc_data_direction == DMA_BIDIRECTIONAL) {
-			us->srb->result = DID_ERROR << 16;
-		} else if (us->srb->device->id
-			   && !(us->fflags & US_FL_SCM_MULT_TARG)) {
-			us->srb->result = DID_BAD_TARGET << 16;
-		} else if (us->srb->device->lun > us->max_lun) {
-			us->srb->result = DID_BAD_TARGET << 16;
-		} else if ((us->srb->cmnd[0] == INQUIRY)
-			   && (us->fflags & US_FL_FIX_INQUIRY)) {
-			unsigned char data_ptr[36] = {0x00, 0x80, 0x02, 0x02,
-						0x1F, 0x00, 0x00, 0x00};
-
-			fill_inquiry_response(us, data_ptr, 36);
-			us->srb->result = SAM_STAT_GOOD;
-		} else {
-			us->proto_handler(us->srb, us);
-		}
-
-		/* lock access to the state */
-		scsi_lock(host);
-
-		/* indicate that the command is done */
-		if (us->srb->result != DID_ABORT << 16) {
-			us->srb->scsi_done(us->srb);
-		} else {
-SkipForAbort:
-			pr_info("scsi command aborted\n");
-		}
-
-		if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
-			complete(&(us->notify));
-
-			/* Allow USB transfers to resume */
-			clear_bit(US_FLIDX_ABORTING, &us->dflags);
-			clear_bit(US_FLIDX_TIMED_OUT, &us->dflags);
-		}
-
-		/* finished working on this command */
-		us->srb = NULL;
-		scsi_unlock(host);
-
-		/* unlock the device pointers */
-		mutex_unlock(&us->dev_mutex);
-	} /* for (;;) */
-
-	/* Wait until we are told to stop */
-	for (;;) {
-		set_current_state(TASK_INTERRUPTIBLE);
-		if (kthread_should_stop())
-			break;
-		schedule();
-	}
-	__set_current_state(TASK_RUNNING);
-	return 0;
-}
-
-static int associate_dev(struct us_data *us, struct usb_interface *intf)
-{
-	pr_info("usb --- associate_dev\n");
-
-	/* Fill in the device-related fields */
-	us->pusb_dev = interface_to_usbdev(intf);
-	us->pusb_intf = intf;
-	us->ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
-
-	/* Store our private data in the interface */
-	usb_set_intfdata(intf, us);
-
-	/* Allocate the device-related DMA-mapped buffers */
-	us->cr = usb_alloc_coherent(us->pusb_dev, sizeof(*us->cr), GFP_KERNEL,
-							&us->cr_dma);
-	if (!us->cr) {
-		pr_info("usb_ctrlrequest allocation failed\n");
-		return -ENOMEM;
-	}
-
-	us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE, GFP_KERNEL,
-							&us->iobuf_dma);
-	if (!us->iobuf) {
-		pr_info("I/O buffer allocation failed\n");
-		return -ENOMEM;
-	}
-
-	us->sensebuf = kmalloc(US_SENSE_SIZE, GFP_KERNEL);
-	if (!us->sensebuf)
-		return -ENOMEM;
-
-	return 0;
-}
-
-static int get_device_info(struct us_data *us, const struct usb_device_id *id)
-{
-	struct usb_device *dev = us->pusb_dev;
-	struct usb_interface_descriptor *idesc =
-					&us->pusb_intf->cur_altsetting->desc;
-
-	pr_info("usb --- get_device_info\n");
-
-	us->subclass = idesc->bInterfaceSubClass;
-	us->protocol = idesc->bInterfaceProtocol;
-	us->fflags = id->driver_info;
-	us->Power_IsResum = false;
-
-	if (us->fflags & US_FL_IGNORE_DEVICE) {
-		pr_info("device ignored\n");
-		return -ENODEV;
-	}
-
-	if (dev->speed != USB_SPEED_HIGH)
-		us->fflags &= ~US_FL_GO_SLOW;
-
-	return 0;
-}
-
-static int get_transport(struct us_data *us)
-{
-	pr_info("usb --- get_transport\n");
-	switch (us->protocol) {
-	case USB_PR_BULK:
-		us->transport_name = "Bulk";
-		us->transport = usb_stor_Bulk_transport;
-		us->transport_reset = usb_stor_Bulk_reset;
-		break;
-
-	default:
-		return -EIO;
-	}
-
-	/* fix for single-lun devices */
-	if (us->fflags & US_FL_SINGLE_LUN)
-		us->max_lun = 0;
-	return 0;
-}
-
-static int get_protocol(struct us_data *us)
-{
-	pr_info("usb --- get_protocol\n");
-	pr_info("us->pusb_dev->descriptor.idVendor = %x\n",
-			us->pusb_dev->descriptor.idVendor);
-	pr_info("us->pusb_dev->descriptor.idProduct = %x\n",
-			us->pusb_dev->descriptor.idProduct);
-	switch (us->subclass) {
-	case USB_SC_SCSI:
-		us->protocol_name = "Transparent SCSI";
-		if ((us->pusb_dev->descriptor.idVendor == 0x0CF2)
-		    && (us->pusb_dev->descriptor.idProduct == 0x6250))
-			us->proto_handler = ENE_stor_invoke_transport;
-		else
-			us->proto_handler = usb_stor_invoke_transport;
-		break;
-
-	default:
-		return -EIO;
-	}
-	return 0;
-}
-
-static int get_pipes(struct us_data *us)
-{
-	struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting;
-	int i;
-	struct usb_endpoint_descriptor *ep;
-	struct usb_endpoint_descriptor *ep_in = NULL;
-	struct usb_endpoint_descriptor *ep_out = NULL;
-	struct usb_endpoint_descriptor *ep_int = NULL;
-
-	pr_info("usb --- get_pipes\n");
-
-	for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
-		ep = &altsetting->endpoint[i].desc;
-
-		if (usb_endpoint_xfer_bulk(ep)) {
-			if (usb_endpoint_dir_in(ep)) {
-				if (!ep_in)
-					ep_in = ep;
-			} else {
-				if (!ep_out)
-					ep_out = ep;
-			}
-		} else if (usb_endpoint_is_int_in(ep)) {
-			if (!ep_int)
-				ep_int = ep;
-		}
-	}
-
-	if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) {
-		pr_info("Endpoint sanity check failed! Rejecting dev.\n");
-		return -EIO;
-	}
-
-	/* Calculate and store the pipe values */
-	us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0);
-	us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0);
-	us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev,
-			ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
-	us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev,
-			ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
-	if (ep_int) {
-		us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev,
-			ep_int->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
-		us->ep_bInterval = ep_int->bInterval;
-	}
-	return 0;
-}
-
-static int usb_stor_acquire_resources(struct us_data *us)
-{
-	struct task_struct *th;
-
-	pr_info("usb --- usb_stor_acquire_resources\n");
-	us->current_urb = usb_alloc_urb(0, GFP_KERNEL);
-	if (!us->current_urb) {
-		pr_info("URB allocation failed\n");
-		return -ENOMEM;
-	}
-
-	/* Start up our control thread */
-	th = kthread_run(usb_stor_control_thread, us, "eucr-storage");
-	if (IS_ERR(th)) {
-		pr_info("Unable to start control thread\n");
-		return PTR_ERR(th);
-	}
-	us->ctl_thread = th;
-
-	return 0;
-}
-
-static void usb_stor_release_resources(struct us_data *us)
-{
-	pr_info("usb --- usb_stor_release_resources\n");
-
-	SM_FreeMem();
-
-	complete(&us->cmnd_ready);
-	if (us->ctl_thread)
-		kthread_stop(us->ctl_thread);
-
-	/* Call the destructor routine, if it exists */
-	if (us->extra_destructor) {
-		pr_info("-- calling extra_destructor()\n");
-		us->extra_destructor(us->extra);
-	}
-
-	/* Free the extra data and the URB */
-	kfree(us->extra);
-	usb_free_urb(us->current_urb);
-}
-
-static void dissociate_dev(struct us_data *us)
-{
-	pr_info("usb --- dissociate_dev\n");
-
-	kfree(us->sensebuf);
-
-	/* Free the device-related DMA-mapped buffers */
-	usb_free_coherent(us->pusb_dev, sizeof(*us->cr), us->cr, us->cr_dma);
-	usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf,
-			  us->iobuf_dma);
-
-	/* Remove our private data from the interface */
-	usb_set_intfdata(us->pusb_intf, NULL);
-}
-
-static void quiesce_and_remove_host(struct us_data *us)
-{
-	struct Scsi_Host *host = us_to_host(us);
-
-	pr_info("usb --- quiesce_and_remove_host\n");
-
-	/* If the device is really gone, cut short reset delays */
-	if (us->pusb_dev->state == USB_STATE_NOTATTACHED)
-		set_bit(US_FLIDX_DISCONNECTING, &us->dflags);
-
-	/*
-	 * Prevent SCSI-scanning (if it hasn't started yet)
-	 * and wait for the SCSI-scanning thread to stop.
-	 */
-	set_bit(US_FLIDX_DONT_SCAN, &us->dflags);
-	wake_up(&us->delay_wait);
-	wait_for_completion(&us->scanning_done);
-
-	/*
-	 * Removing the host will perform an orderly shutdown: caches
-	 * synchronized, disks spun down, etc.
-	 */
-	scsi_remove_host(host);
-
-	/*
-	 * Prevent any new commands from being accepted and cut short
-	 * reset delays.
-	 */
-	scsi_lock(host);
-	set_bit(US_FLIDX_DISCONNECTING, &us->dflags);
-	scsi_unlock(host);
-	wake_up(&us->delay_wait);
-}
-
-static void release_everything(struct us_data *us)
-{
-	pr_info("usb --- release_everything\n");
-
-	usb_stor_release_resources(us);
-	dissociate_dev(us);
-	scsi_host_put(us_to_host(us));
-}
-
-static int usb_stor_scan_thread(void *__us)
-{
-	struct us_data *us = (struct us_data *)__us;
-
-	pr_info("usb --- usb_stor_scan_thread\n");
-	pr_info("EUCR : device found at %d\n", us->pusb_dev->devnum);
-
-	set_freezable();
-	/* Wait for the timeout to expire or for a disconnect */
-	if (delay_use > 0) {
-		wait_event_freezable_timeout(us->delay_wait,
-				test_bit(US_FLIDX_DONT_SCAN, &us->dflags),
-				delay_use * HZ);
-	}
-
-	/* If the device is still connected, perform the scanning */
-	if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags)) {
-		/* For bulk-only devices, determine the max LUN value */
-		if (us->protocol == USB_PR_BULK
-		    && !(us->fflags & US_FL_SINGLE_LUN)) {
-			mutex_lock(&us->dev_mutex);
-			us->max_lun = usb_stor_Bulk_max_lun(us);
-			mutex_unlock(&us->dev_mutex);
-		}
-		scsi_scan_host(us_to_host(us));
-		pr_info("EUCR : device scan complete\n");
-	}
-	complete_and_exit(&us->scanning_done, 0);
-}
-
-static int eucr_probe(struct usb_interface *intf,
-					const struct usb_device_id *id)
-{
-	struct Scsi_Host *host;
-	struct us_data *us;
-	int result;
-	u8	MiscReg03 = 0;
-	struct task_struct *th;
-
-	pr_info("usb --- eucr_probe\n");
-
-	host = scsi_host_alloc(&usb_stor_host_template, sizeof(*us));
-	if (!host) {
-		pr_info("Unable to allocate the scsi host\n");
-		return -ENOMEM;
-	}
-
-	/* Allow 16-byte CDBs and thus > 2TB */
-	host->max_cmd_len = 16;
-	us = host_to_us(host);
-	memset(us, 0, sizeof(struct us_data));
-	mutex_init(&(us->dev_mutex));
-	init_completion(&us->cmnd_ready);
-	init_completion(&(us->notify));
-	init_waitqueue_head(&us->delay_wait);
-	init_completion(&us->scanning_done);
-
-	/* Associate the us_data structure with the USB device */
-	result = associate_dev(us, intf);
-	if (result)
-		goto BadDevice;
-
-	/* Get Device info */
-	result = get_device_info(us, id);
-	if (result)
-		goto BadDevice;
-
-	/* Get the transport, protocol, and pipe settings */
-	result = get_transport(us);
-	if (result)
-		goto BadDevice;
-	result = get_protocol(us);
-	if (result)
-		goto BadDevice;
-	result = get_pipes(us);
-	if (result)
-		goto BadDevice;
-
-	/* Acquire all the other resources and add the host */
-	result = usb_stor_acquire_resources(us);
-	if (result)
-		goto BadDevice;
-
-	result = scsi_add_host(host, &intf->dev);
-	if (result) {
-		pr_info("Unable to add the scsi host\n");
-		goto BadDevice;
-	}
-
-	/* Start up the thread for delayed SCSI-device scanning */
-	th = kthread_create(usb_stor_scan_thread, us, "eucr-stor-scan");
-	if (IS_ERR(th)) {
-		pr_info("Unable to start the device-scanning thread\n");
-		complete(&us->scanning_done);
-		quiesce_and_remove_host(us);
-		result = PTR_ERR(th);
-		goto BadDevice;
-	}
-	wake_up_process(th);
-
-	/* probe card type */
-	result = ene_read_byte(us, REG_CARD_STATUS, &MiscReg03);
-	if (result != USB_STOR_XFER_GOOD) {
-		result = USB_STOR_TRANSPORT_ERROR;
-		quiesce_and_remove_host(us);
-		goto BadDevice;
-	}
-
-	if (!(MiscReg03 & 0x02)) {
-		result = -ENODEV;
-		quiesce_and_remove_host(us);
-		pr_info("keucr: The driver only supports SM/MS card. To use SD card, please build driver/usb/storage/ums-eneub6250.ko\n");
-		goto BadDevice;
-	}
-
-	return 0;
-
-	/* We come here if there are any problems */
-BadDevice:
-	pr_info("usb --- eucr_probe failed\n");
-	release_everything(us);
-	return result;
-}
-
-static void eucr_disconnect(struct usb_interface *intf)
-{
-	struct us_data *us = usb_get_intfdata(intf);
-
-	pr_info("usb --- eucr_disconnect\n");
-	quiesce_and_remove_host(us);
-	release_everything(us);
-}
-
-/* Initialization and registration */
-static struct usb_driver usb_storage_driver = {
-	.name =		"eucr",
-	.probe =		eucr_probe,
-	.suspend =	    eucr_suspend,
-	.resume =	    eucr_resume,
-	.reset_resume =	eucr_reset_resume,
-	.disconnect =	eucr_disconnect,
-	.pre_reset =	eucr_pre_reset,
-	.post_reset =	eucr_post_reset,
-	.id_table =		eucr_usb_ids,
-	.soft_unbind =	1,
-};
-
-module_usb_driver(usb_storage_driver);
diff --git a/drivers/staging/keucr/usb.h b/drivers/staging/keucr/usb.h
deleted file mode 100644
index e894f84..0000000
--- a/drivers/staging/keucr/usb.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/* Driver for USB Mass Storage compliant devices */
-
-#ifndef _USB_H_
-#define _USB_H_
-
-#include <linux/usb.h>
-#include <linux/usb_usual.h>
-#include <linux/blkdev.h>
-#include <linux/completion.h>
-#include <linux/mutex.h>
-#include <scsi/scsi_host.h>
-#include "common.h"
-
-struct us_data;
-struct scsi_cmnd;
-
-/*
- * Unusual device list definitions
- */
-
-struct us_unusual_dev {
-	const char *vendorName;
-	const char *productName;
-	__u8  useProtocol;
-	__u8  useTransport;
-	int (*initFunction)(struct us_data *);
-};
-
-/* EnE HW Register */
-#define REG_CARD_STATUS     0xFF83
-#define REG_HW_TRAP1        0xFF89
-
-/* SRB Status. Refers /usr/include/wine/wine/wnaspi32.h & SCSI sense key */
-#define SS_SUCCESS                  0x00      /* No Sense */
-#define SS_NOT_READY                0x02
-#define SS_MEDIUM_ERR               0x03
-#define SS_HW_ERR                   0x04
-#define SS_ILLEGAL_REQUEST          0x05
-#define SS_UNIT_ATTENTION           0x06
-
-/* ENE Load FW Pattern */
-#define SD_INIT1_PATTERN   1
-#define SD_INIT2_PATTERN   2
-#define SD_RW_PATTERN      3
-#define MS_INIT_PATTERN    4
-#define MSP_RW_PATTERN     5
-#define MS_RW_PATTERN      6
-#define SM_INIT_PATTERN    7
-#define SM_RW_PATTERN      8
-
-#define FDIR_WRITE        0
-#define FDIR_READ         1
-
-struct keucr_sd_status {
-	u8    Insert:1;
-	u8    Ready:1;
-	u8    MediaChange:1;
-	u8    IsMMC:1;
-	u8    HiCapacity:1;
-	u8    HiSpeed:1;
-	u8    WtP:1;
-	u8    Reserved:1;
-};
-
-struct keucr_ms_status {
-	u8    Insert:1;
-	u8    Ready:1;
-	u8    MediaChange:1;
-	u8    IsMSPro:1;
-	u8    IsMSPHG:1;
-	u8    Reserved1:1;
-	u8    WtP:1;
-	u8    Reserved2:1;
-};
-
-struct keucr_sm_status {
-	u8    Insert:1;
-	u8    Ready:1;
-	u8    MediaChange:1;
-	u8    Reserved:3;
-	u8    WtP:1;
-	u8    IsMS:1;
-};
-
-/* SD Block Length */
-#define SD_BLOCK_LEN		9	/* 2^9 = 512 Bytes,
-				The HW maximum read/write data length */
-
-/* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
-#define US_FLIDX_URB_ACTIVE	0	/* current_urb is in use    */
-#define US_FLIDX_SG_ACTIVE	1	/* current_sg is in use     */
-#define US_FLIDX_ABORTING	2	/* abort is in progress     */
-#define US_FLIDX_DISCONNECTING	3	/* disconnect in progress   */
-#define US_FLIDX_RESETTING	4	/* device reset in progress */
-#define US_FLIDX_TIMED_OUT	5	/* SCSI midlayer timed out  */
-#define US_FLIDX_DONT_SCAN	6	/* don't scan (disconnect)  */
-
-
-#define USB_STOR_STRING_LEN 32
-
-/*
- * We provide a DMA-mapped I/O buffer for use with small USB transfers.
- * It turns out that CB[I] needs a 12-byte buffer and Bulk-only needs a
- * 31-byte buffer.  But Freecom needs a 64-byte buffer, so that's the
- * size we'll allocate.
- */
-
-#define US_IOBUF_SIZE		64	/* Size of the DMA-mapped I/O buffer */
-#define US_SENSE_SIZE		18	/* Size of the autosense data buffer */
-
-typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data *);
-typedef int (*trans_reset)(struct us_data *);
-typedef void (*proto_cmnd)(struct scsi_cmnd *, struct us_data *);
-typedef void (*extra_data_destructor)(void *);	/* extra data destructor */
-typedef void (*pm_hook)(struct us_data *, int);	/* power management hook */
-
-#define US_SUSPEND	0
-#define US_RESUME	1
-
-/* we allocate one of these for every device that we remember */
-struct us_data {
-	/* The device we're working with
-	 * It's important to note:
-	 *    (o) you must hold dev_mutex to change pusb_dev
-	 */
-	struct mutex		dev_mutex;	 /* protect pusb_dev */
-	struct usb_device	*pusb_dev;	 /* this usb_device */
-	struct usb_interface	*pusb_intf;	 /* this interface */
-	struct us_unusual_dev   *unusual_dev;	 /* device-filter entry     */
-	unsigned long		fflags;		 /* fixed flags from filter */
-	unsigned long		dflags;		 /* dynamic atomic bitflags */
-	unsigned int		send_bulk_pipe;	 /* cached pipe values */
-	unsigned int		recv_bulk_pipe;
-	unsigned int		send_ctrl_pipe;
-	unsigned int		recv_ctrl_pipe;
-	unsigned int		recv_intr_pipe;
-
-	/* information about the device */
-	char			*transport_name;
-	char			*protocol_name;
-	__le32			bcs_signature;
-	u8			subclass;
-	u8			protocol;
-	u8			max_lun;
-
-	u8			ifnum;		 /* interface number   */
-	u8			ep_bInterval;	 /* interrupt interval */
-
-	/* function pointers for this device */
-	trans_cmnd		transport;	 /* transport function	   */
-	trans_reset		transport_reset; /* transport device reset */
-	proto_cmnd		proto_handler;	 /* protocol handler	   */
-
-	/* SCSI interfaces */
-	struct scsi_cmnd	*srb;		 /* current srb		*/
-	unsigned int		tag;		 /* current dCBWTag	*/
-
-	/* control and bulk communications data */
-	struct urb		*current_urb;	 /* USB requests	 */
-	struct usb_ctrlrequest	*cr;		 /* control requests	 */
-	struct usb_sg_request	current_sg;	 /* scatter-gather req.  */
-	unsigned char		*iobuf;		 /* I/O buffer		 */
-	unsigned char		*sensebuf;	 /* sense data buffer	 */
-	dma_addr_t		cr_dma;		 /* buffer DMA addresses */
-	dma_addr_t		iobuf_dma;
-	struct task_struct	*ctl_thread;	 /* the control thread   */
-
-	/* mutual exclusion and synchronization structures */
-	struct completion	cmnd_ready;	 /* to sleep thread on	    */
-	struct completion	notify;		 /* thread begin/end	    */
-	wait_queue_head_t	delay_wait;	 /* wait during scan, reset */
-	struct completion	scanning_done;	 /* wait for scan thread    */
-
-	/* subdriver information */
-	void			*extra;		 /* Any extra data          */
-	extra_data_destructor	extra_destructor;/* extra data destructor   */
-#ifdef CONFIG_PM
-	pm_hook			suspend_resume_hook;
-#endif
-	/* for 6250 code */
-	struct keucr_sd_status   SD_Status;
-	struct keucr_ms_status   MS_Status;
-	struct keucr_sm_status   SM_Status;
-
-	/* ----- SD Control Data ---------------- */
-	/* SD_REGISTER SD_Regs; */
-	u16        SD_Block_Mult;
-	u8        SD_READ_BL_LEN;
-	u16        SD_C_SIZE;
-	u8        SD_C_SIZE_MULT;
-
-	/* SD/MMC New spec. */
-	u8        SD_SPEC_VER;
-	u8        SD_CSD_VER;
-	u8        SD20_HIGH_CAPACITY;
-	u32       HC_C_SIZE;
-	u8        MMC_SPEC_VER;
-	u8        MMC_BusWidth;
-	u8        MMC_HIGH_CAPACITY;
-
-	/* ----- MS Control Data ---------------- */
-	bool             MS_SWWP;
-	u32               MSP_TotalBlock;
-	/* MS_LibControl       MS_Lib; */
-	bool             MS_IsRWPage;
-	u16                MS_Model;
-
-	/* ----- SM Control Data ---------------- */
-	u8		SM_DeviceID;
-	u8		SM_CardID;
-
-	u8 *testbuf;
-	u8		BIN_FLAG;
-	u32		bl_num;
-	int		SrbStatus;
-
-	/* ------Power Managerment --------------- */
-	bool         Power_IsResum;
-};
-
-/* Convert between us_data and the corresponding Scsi_Host */
-static inline struct Scsi_Host *us_to_host(struct us_data *us)
-{
-	return container_of((void *) us, struct Scsi_Host, hostdata);
-}
-static inline struct us_data *host_to_us(struct Scsi_Host *host)
-{
-	return (struct us_data *) host->hostdata;
-}
-
-/* Function to fill an inquiry response. See usb.c for details */
-extern void fill_inquiry_response(struct us_data *us,
-	unsigned char *data, unsigned int data_len);
-
-/* The scsi_lock() and scsi_unlock() macros protect the sm_state and the
- * single queue element srb for write access */
-#define scsi_unlock(host)	spin_unlock_irq(host->host_lock)
-#define scsi_lock(host)		spin_lock_irq(host->host_lock)
-
-#endif
diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c
index 001c4b7..5dfb887 100644
--- a/drivers/staging/lustre/lnet/lnet/acceptor.c
+++ b/drivers/staging/lustre/lnet/lnet/acceptor.c
@@ -42,7 +42,7 @@
 static int   accept_backlog = 127;
 static int   accept_timeout = 5;
 
-struct {
+static struct {
 	int			pta_shutdown;
 	struct socket		*pta_sock;
 	struct completion	pta_signal;
@@ -75,7 +75,7 @@
 
 static char *accept_type;
 
-int
+static int
 lnet_acceptor_get_tunables(void)
 {
 	/* Userland acceptor uses 'accept_type' instead of 'accept', due to
@@ -207,7 +207,7 @@
 
 /* Below is the code common for both kernel and MT user-space */
 
-int
+static int
 lnet_accept(struct socket *sock, __u32 magic)
 {
 	lnet_acceptor_connreq_t cr;
@@ -329,7 +329,7 @@
 	return rc;
 }
 
-int
+static int
 lnet_acceptor(void *arg)
 {
 	struct socket *newsock;
diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h
index 9a21e88..dc31bf9 100644
--- a/drivers/staging/lustre/lustre/include/lustre_sec.h
+++ b/drivers/staging/lustre/lustre/include/lustre_sec.h
@@ -387,7 +387,7 @@
 	/**
 	 * Force the \a ctx to die.
 	 */
-	void    (*die)	 (struct ptlrpc_cli_ctx *ctx,
+	void    (*force_die)   (struct ptlrpc_cli_ctx *ctx,
 				int grace);
 	int     (*display)     (struct ptlrpc_cli_ctx *ctx,
 				char *buf, int bufsize);
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index e48f323..13586c5 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -910,7 +910,7 @@
 		 sbi->ll_stats_track_id == current->pid)
 		lprocfs_counter_add(sbi->ll_stats, op, count);
 	else if (sbi->ll_stats_track_type == STATS_TRACK_PPID &&
-		 sbi->ll_stats_track_id == current->parent->pid)
+		 sbi->ll_stats_track_id == current->real_parent->pid)
 		lprocfs_counter_add(sbi->ll_stats, op, count);
 	else if (sbi->ll_stats_track_type == STATS_TRACK_GID &&
 		 sbi->ll_stats_track_id ==
diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c
index cd8402e..ecd7a22 100644
--- a/drivers/staging/lustre/lustre/llite/rw.c
+++ b/drivers/staging/lustre/lustre/llite/rw.c
@@ -496,14 +496,9 @@
 	struct cl_object *clob  = ll_i2info(mapping->host)->lli_clob;
 	struct cl_page   *page;
 	enum ra_stat      which = _NR_RA_STAT; /* keep gcc happy */
-	unsigned int      gfp_mask;
 	int	       rc    = 0;
 	const char       *msg   = NULL;
 
-	gfp_mask = GFP_HIGHUSER & ~__GFP_WAIT;
-#ifdef __GFP_NOWARN
-	gfp_mask |= __GFP_NOWARN;
-#endif
 	vmpage = grab_cache_page_nowait(mapping, index);
 	if (vmpage != NULL) {
 		/* Check if vmpage was truncated or reclaimed */
diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c
index ce830e4..e4bb02a 100644
--- a/drivers/staging/lustre/lustre/lov/lov_request.c
+++ b/drivers/staging/lustre/lustre/lov/lov_request.c
@@ -140,16 +140,16 @@
 
 static int lov_check_set(struct lov_obd *lov, int idx)
 {
-	int rc = 0;
+	int rc;
+	struct lov_tgt_desc *tgt;
+
 	mutex_lock(&lov->lov_lock);
-
-	if (lov->lov_tgts[idx] == NULL ||
-	    lov->lov_tgts[idx]->ltd_active ||
-	    (lov->lov_tgts[idx]->ltd_exp != NULL &&
-	     class_exp2cliimp(lov->lov_tgts[idx]->ltd_exp)->imp_connect_tried))
-		rc = 1;
-
+	tgt = lov->lov_tgts[idx];
+	rc = !tgt || tgt->ltd_active ||
+		(tgt->ltd_exp &&
+		 class_exp2cliimp(tgt->ltd_exp)->imp_connect_tried);
 	mutex_unlock(&lov->lov_lock);
+
 	return rc;
 }
 
@@ -478,7 +478,7 @@
 		GOTO(out_set, rc = -ENOMEM);
 	lockh->cookie = set->set_lockh->llh_handle.h_cookie;
 
-	for (i = 0; i < lsm->lsm_stripe_count; i++){
+	for (i = 0; i < lsm->lsm_stripe_count; i++) {
 		struct lov_oinfo *loi;
 		struct lov_request *req;
 		obd_off start, end;
@@ -566,7 +566,7 @@
 	}
 	lockh->cookie = set->set_lockh->llh_handle.h_cookie;
 
-	for (i = 0; i < lsm->lsm_stripe_count; i++){
+	for (i = 0; i < lsm->lsm_stripe_count; i++) {
 		struct lov_request *req;
 		struct lustre_handle *lov_lockhp;
 		struct lov_oinfo *loi = lsm->lsm_oinfo[i];
@@ -734,7 +734,7 @@
 
 	/* alloc and initialize lov request */
 	shift = 0;
-	for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++){
+	for (i = 0; i < oinfo->oi_md->lsm_stripe_count; i++) {
 		struct lov_oinfo *loi = NULL;
 		struct lov_request *req;
 
@@ -836,6 +836,7 @@
 {
 	struct obd_info *oinfo = cookie;
 	struct lov_request *lovreq;
+
 	lovreq = container_of(oinfo, struct lov_request, rq_oi);
 	return lov_update_common_set(lovreq->rq_rqset, lovreq, rc);
 }
@@ -1018,6 +1019,7 @@
 {
 	struct obd_info *oinfo = cookie;
 	struct lov_request *lovreq;
+
 	lovreq = container_of(oinfo, struct lov_request, rq_oi);
 	return lov_update_setattr_set(lovreq->rq_rqset, lovreq, rc);
 }
@@ -1141,6 +1143,7 @@
 {
 	struct obd_info *oinfo = cookie;
 	struct lov_request *lovreq;
+
 	lovreq = container_of(oinfo, struct lov_request, rq_oi);
 	return lov_update_punch_set(lovreq->rq_rqset, lovreq, rc);
 }
diff --git a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c b/drivers/staging/lustre/lustre/obdecho/lproc_echo.c
index 487c4f3..1d3bf6c 100644
--- a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c
+++ b/drivers/staging/lustre/lustre/obdecho/lproc_echo.c
@@ -40,13 +40,13 @@
 LPROC_SEQ_FOPS_RO_TYPE(echo, uuid);
 static struct lprocfs_vars lprocfs_echo_obd_vars[] = {
 	{ "uuid",	 &echo_uuid_fops,	NULL, 0 },
-	{ 0 }
+	{ NULL }
 };
 
 LPROC_SEQ_FOPS_RO_TYPE(echo, numrefs);
 static struct lprocfs_vars lprocfs_echo_module_vars[] = {
 	{ "num_refs",     &echo_numrefs_fops,     NULL, 0 },
-	{ 0 }
+	{ NULL }
 };
 
 void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars)
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 27d497df..5cff7ee 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -305,8 +305,8 @@
  */
 void sptlrpc_cli_ctx_expire(struct ptlrpc_cli_ctx *ctx)
 {
-	LASSERT(ctx->cc_ops->die);
-	ctx->cc_ops->die(ctx, 0);
+	LASSERT(ctx->cc_ops->force_die);
+	ctx->cc_ops->force_die(ctx, 0);
 }
 EXPORT_SYMBOL(sptlrpc_cli_ctx_expire);
 
@@ -591,7 +591,7 @@
 	 * later than the context refresh expire time.
 	 */
 	if (rc == 0)
-		req->rq_cli_ctx->cc_ops->die(req->rq_cli_ctx, 0);
+		req->rq_cli_ctx->cc_ops->force_die(req->rq_cli_ctx, 0);
 	return rc;
 }
 
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index d325048..0a5c84a 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -960,7 +960,7 @@
 }
 #endif
 
-static const SIMPLE_DEV_PM_OPS(nvec_pm_ops, nvec_suspend, nvec_resume);
+static SIMPLE_DEV_PM_OPS(nvec_pm_ops, nvec_suspend, nvec_resume);
 
 /* Match table for of_platform binding */
 static const struct of_device_id nvidia_nvec_of_match[] = {
diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c
index 20b3533..3cc286e 100644
--- a/drivers/staging/octeon/ethernet-xaui.c
+++ b/drivers/staging/octeon/ethernet-xaui.c
@@ -128,6 +128,7 @@
 int cvm_oct_xaui_init(struct net_device *dev)
 {
 	struct octeon_ethernet *priv = netdev_priv(dev);
+
 	cvm_oct_common_init(dev);
 	dev->netdev_ops->ndo_stop(dev);
 	if (!octeon_is_simulation() && priv->phydev == NULL)
diff --git a/drivers/staging/rtl8192ee/base.c b/drivers/staging/rtl8192ee/base.c
index 71ed12e..f7c3c8b 100644
--- a/drivers/staging/rtl8192ee/base.c
+++ b/drivers/staging/rtl8192ee/base.c
@@ -826,8 +826,7 @@
 	u8 hw_rate;
 	u16 map = le16_to_cpu(sta->vht_cap.vht_mcs.tx_mcs_map);
 
-	if ((get_rf_type(rtlphy) == RF_2T2R) &&
-	    (map & 0x000c) != 0x000c) {
+	if (get_rf_type(rtlphy) == RF_2T2R) {
 		if ((map & 0x000c) >> 2 == IEEE80211_VHT_MCS_SUPPORT_0_7)
 			hw_rate =
 			rtlpriv->cfg->maps[RTL_RC_VHT_RATE_2SS_MCS7];
diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c
index ab9a66e..4d2880a 100644
--- a/drivers/staging/rtl8723au/core/rtw_ap.c
+++ b/drivers/staging/rtl8723au/core/rtw_ap.c
@@ -52,7 +52,7 @@
 
 	rtw_sta_flush23a(padapter);
 
-	pmlmeinfo->state = _HW_STATE_NOLINK_;
+	pmlmeinfo->state = MSR_NOLINK;
 
 	/* free_assoc_sta_resources */
 	rtw_free_all_stainfo23a(padapter);
@@ -93,7 +93,7 @@
 	} else {
 		tim_ielen = 0;
 
-		/* calulate head_len */
+		/* calculate head_len */
 		offset = 0;
 
 		/* get ssid_ie len */
@@ -135,7 +135,7 @@
 	*dst_ie++= tim_ielen;
 
 	*dst_ie++= 0;/* DTIM count */
-	*dst_ie++= 1;/* DTIM peroid */
+	*dst_ie++= 1;/* DTIM period */
 
 	if (pstapriv->tim_bitmap & BIT(0))/* for bc/mc frames */
 		*dst_ie++ = BIT(0);/* bitmap ctrl */
@@ -243,7 +243,7 @@
 
 			if (psta->state & WIFI_SLEEP_STATE) {
 				if (!(psta->state & WIFI_STA_ALIVE_CHK_STATE)) {
-					/* to check if alive by another methods if staion is at ps mode. */
+					/* to check if alive by another methods if station is at ps mode. */
 					psta->expire_to = pstapriv->expire_to;
 					psta->state |= WIFI_STA_ALIVE_CHK_STATE;
 
@@ -688,7 +688,7 @@
 	}
 
 	/* set MSR to AP_Mode */
-	Set_MSR23a(padapter, _HW_STATE_AP_);
+	rtl8723a_set_media_status(padapter, MSR_AP);
 
 	/* Set BSSID REG */
 	hw_var_set_bssid(padapter, pnetwork->MacAddress);
@@ -764,7 +764,7 @@
 	/* update cur_wireless_mode */
 	update_wireless_mode23a(padapter);
 
-	/* udpate capability after cur_wireless_mode updated */
+	/* update capability after cur_wireless_mode updated */
 	update_capinfo23a(padapter, pnetwork->capability);
 
 	/* let pnetwork_mlmeext == pnetwork_mlme. */
@@ -844,7 +844,7 @@
 		pbss_network->Ssid.ssid_len = ie_len;
 	}
 
-	/* chnnel */
+	/* channel */
 	channel = 0;
 	p = rtw_get_ie23a(ie, WLAN_EID_DS_PARAMS, &ie_len,
 			  pbss_network->IELength);
@@ -1305,7 +1305,7 @@
 
 /*
 op_mode
-Set to 0 (HT pure) under the followign conditions
+Set to 0 (HT pure) under the following conditions
 	- all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or
 	- all STAs in the BSS are 20 MHz HT in 20 MHz BSS
 Set to 1 (HT non-member protection) if there may be non-HT STAs
@@ -1387,7 +1387,7 @@
 
 void associated_clients_update23a(struct rtw_adapter *padapter, u8 updated)
 {
-	/* update associcated stations cap. */
+	/* update associated stations cap. */
 	if (updated == true)
 	{
 		struct list_head *phead, *plist, *ptmp;
@@ -1572,7 +1572,7 @@
 		update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true);
 	}
 
-	/* update associcated stations cap. */
+	/* update associated stations cap. */
 	associated_clients_update23a(padapter,  beacon_updated);
 
 	DBG_8723A("%s, updated =%d\n", __func__, beacon_updated);
@@ -1641,7 +1641,7 @@
 		update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true);
 	}
 
-	/* update associcated stations cap. */
+	/* update associated stations cap. */
 
 	DBG_8723A("%s, updated =%d\n", __func__, beacon_updated);
 
@@ -1703,7 +1703,7 @@
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 	u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
-	if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE)
+	if ((pmlmeinfo->state&0x03) != MSR_AP)
 		return ret;
 
 	DBG_8723A("%s(%s): with ch:%u, offset:%u\n", __func__,
@@ -1740,7 +1740,7 @@
 
 	DBG_8723A("%s(%s)\n", __func__, padapter->pnetdev->name);
 
-	if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE)
+	if ((pmlmeinfo->state&0x03) != MSR_AP)
 		return ret;
 
 	spin_lock_bh(&pstapriv->asoc_list_lock);
diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c
index df1ffb3..25d65b2 100644
--- a/drivers/staging/rtl8723au/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723au/core/rtw_cmd.c
@@ -322,7 +322,7 @@
 				  pcmd_callback, pcmd->cmdcode));
 			rtw_free_cmd_obj23a(pcmd);
 		} else {
-			/* need conider that free cmd_obj in
+			/* need consider that free cmd_obj in
 			   rtw_cmd_callback */
 			pcmd_callback(pcmd->padapter, pcmd);
 		}
@@ -736,7 +736,7 @@
 		       &psecuritypriv->dot118021XGrpKey[idx].skey, 16);
         }
 
-	/* jeff: set this becasue at least sw key is ready */
+	/* jeff: set this because at least sw key is ready */
 	padapter->securitypriv.busetkipkey = 1;
 
 	res = rtw_enqueue_cmd23a(pcmdpriv, ph2c);
diff --git a/drivers/staging/rtl8723au/core/rtw_efuse.c b/drivers/staging/rtl8723au/core/rtw_efuse.c
index cc063cb..345bff8 100644
--- a/drivers/staging/rtl8723au/core/rtw_efuse.c
+++ b/drivers/staging/rtl8723au/core/rtw_efuse.c
@@ -59,7 +59,7 @@
 		rtl8723au_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON);
 
 		/*  1.2V Power: From VDDON with Power
-		    Cut(0x0000h[15]), defualt valid */
+		    Cut(0x0000h[15]), default valid */
 		tmpV16 = rtl8723au_read16(padapter, REG_SYS_ISO_CTRL);
 		if (!(tmpV16 & PWC_EV12V)) {
 			tmpV16 |= PWC_EV12V;
@@ -144,7 +144,7 @@
 /*  */
 /*	Description: */
 /*		Execute E-Fuse read byte operation. */
-/*		Refered from SD1 Richard. */
+/*		Referred from SD1 Richard. */
 /*  */
 /*	Assumption: */
 /*		1. Boot from E-Fuse and successfully auto-load. */
@@ -521,7 +521,7 @@
 }
 
 /*
- * read/wirte raw efuse data
+ * read/write raw efuse data
  */
 int rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr,
 			u16 cnts, u8 *data)
diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c
index 78a7b27..23e6662 100644
--- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c
@@ -250,7 +250,7 @@
  * rtw_ies_remove_ie23a - Find matching IEs and remove
  * @ies: Address of IEs to search
  * @ies_len: Pointer of length of ies, will update to new length
- * @offset: The offset to start scarch
+ * @offset: The offset to start search
  * @eid: Element ID to match
  * @oui: OUI to match
  * @oui_len: OUI length
diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c
index 4827280..c475b79 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme.c
@@ -134,7 +134,7 @@
 /*
  return the wlan_network with the matching addr
 
- Shall be calle under atomic context... to avoid possible racing condition...
+ Shall be called under atomic context... to avoid possible racing condition...
 */
 struct wlan_network *
 rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr)
@@ -395,7 +395,7 @@
 				    (u32)dst->PhyInfo.SignalQuality * 4) / 5;
 			rssi_final = src->Rssi+dst->Rssi * 4 / 5;
 		} else {
-			/* bss info not receving from the right channel, use
+			/* bss info not receiving from the right channel, use
 			   the original RX signal infos */
 			ss_final = dst->PhyInfo.SignalStrength;
 			sq_final = dst->PhyInfo.SignalQuality;
@@ -490,7 +490,7 @@
 		pnetwork->aid = 0;
 		pnetwork->join_res = 0;
 
-		/* bss info not receving from the right channel */
+		/* bss info not receiving from the right channel */
 		if (pnetwork->network.PhyInfo.SignalQuality == 101)
 			pnetwork->network.PhyInfo.SignalQuality = 0;
 	} else {
@@ -956,7 +956,7 @@
 		/*	Commented by Albert 2012/07/21 */
 		/*	When doing the WPS, the wps_ie_len won't equal to 0 */
 		/*	And the Wi-Fi driver shouldn't allow the data packet
-			to be tramsmitted. */
+			to be transmitted. */
 		if (padapter->securitypriv.wps_ie_len != 0) {
 			psta->ieee8021x_blocked = true;
 			padapter->securitypriv.wps_ie_len = 0;
@@ -964,7 +964,7 @@
 
 		/* for A-MPDU Rx reordering buffer control for bmc_sta &
 		 * sta_info */
-		/* if A-MPDU Rx is enabled, reseting
+		/* if A-MPDU Rx is enabled, resetting
 		   rx_ordering_ctrl wstart_b(indicate_seq) to default
 		   value = 0xffff */
 		/* todo: check if AP can send A-MPDU packets */
@@ -1073,7 +1073,7 @@
 
 /*
  * Notes:
- * the fucntion could be > passive_level (the same context as Rx tasklet)
+ * the function could be > passive_level (the same context as Rx tasklet)
  * pnetwork : returns from rtw23a_joinbss_event_cb
  * ptarget_wlan: found from scanned_queue
  * if join_res > 0, for (fw_state==WIFI_STATION_STATE),
@@ -1419,7 +1419,7 @@
 }
 
 /*
-* rtw23a_join_to_handler - Timeout/faliure handler for CMD JoinBss
+* rtw23a_join_to_handler - Timeout/failure handler for CMD JoinBss
 * @adapter: pointer to _adapter structure
 */
 void rtw23a_join_to_handler (unsigned long data)
@@ -1470,7 +1470,7 @@
 }
 
 /*
-* rtw_scan_timeout_handler23a - Timeout/Faliure handler for CMD SiteSurvey
+* rtw_scan_timeout_handler23a - Timeout/Failure handler for CMD SiteSurvey
 * @data: pointer to _adapter structure
 */
 void rtw_scan_timeout_handler23a(unsigned long data)
@@ -2102,7 +2102,7 @@
 	/* pdev_network->IELength = cpu_to_le32(sz); */
 }
 
-/* the fucntion is at passive_level */
+/* the function is at passive_level */
 void rtw_joinbss_reset23a(struct rtw_adapter *padapter)
 {
 	u8 threshold;
@@ -2131,7 +2131,7 @@
 	rtl8723a_set_rxdma_agg_pg_th(padapter, threshold);
 }
 
-/* the fucntion is >= passive_level */
+/* the function is >= passive_level */
 bool rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie,
 			      u8 *out_ie, uint in_len, uint *pout_len)
 {
@@ -2203,7 +2203,7 @@
 	return phtpriv->ht_option;
 }
 
-/* the fucntion is > passive_level (in critical_section) */
+/* the function is > passive_level (in critical_section) */
 void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len)
 {
 	u8 max_ampdu_sz;
@@ -2271,7 +2271,7 @@
 				pmlmeinfo->ht_cap.mcs.rx_mask[i] &=
 					MCS_rate_2R23A[i];
 		}
-		/* switch to the 40M Hz mode accoring to the AP */
+		/* switch to the 40M Hz mode according to the AP */
 		pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40;
 		switch (pmlmeinfo->HT_info.ht_param &
 			IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
index 3655ee5..c5fdcb8 100644
--- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c
@@ -393,7 +393,7 @@
 	pmlmeext->sitesurvey_res.bss_cnt = 0;
 	pmlmeext->scan_abort = false;
 
-	pmlmeinfo->state = WIFI_FW_NULL_STATE;
+	pmlmeinfo->state = MSR_NOLINK;
 	pmlmeinfo->reauth_count = 0;
 	pmlmeinfo->reassoc_count = 0;
 	pmlmeinfo->link_count = 0;
@@ -849,7 +849,7 @@
 		return _SUCCESS;
 	}
 
-	if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) &&
+	if (((pmlmeinfo->state & 0x03) == MSR_AP) &&
 	    (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) {
 		psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
 		if (psta) {
@@ -869,7 +869,7 @@
 						      pkt_len, psta);
 			}
 		}
-	} else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) {
+	} else if ((pmlmeinfo->state&0x03) == MSR_ADHOC) {
 		psta = rtw_get_stainfo23a(pstapriv, mgmt->sa);
 		if (psta) {
 			/* update WMM, ERP in the beacon */
@@ -925,7 +925,7 @@
 	u16 auth_mode, seq, algorithm;
 	int status, len = skb->len;
 
-	if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
+	if ((pmlmeinfo->state & 0x03) != MSR_AP)
 		return _FAIL;
 
 	DBG_8723A("+OnAuth23a\n");
@@ -1344,7 +1344,7 @@
 	uint pkt_len = skb->len;
 	int r;
 
-	if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE)
+	if ((pmlmeinfo->state & 0x03) != MSR_AP)
 		return _FAIL;
 
 	left = pkt_len - sizeof(struct ieee80211_hdr_3addr);
@@ -1801,7 +1801,7 @@
 	status = le16_to_cpu(pmgmt->u.assoc_resp.status_code);
 	if (status > 0)	{
 		DBG_8723A("assoc reject, status code: %d\n", status);
-		pmlmeinfo->state = WIFI_FW_NULL_STATE;
+		pmlmeinfo->state = MSR_NOLINK;
 		res = -4;
 		goto report_assoc_result;
 	}
@@ -2033,7 +2033,7 @@
 
 	DBG_8723A("%s\n", __func__);
 
-	if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE)
+	if ((pmlmeinfo->state&0x03) != MSR_AP)
 		if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS))
 			return _SUCCESS;
 
@@ -2213,7 +2213,7 @@
 
 /****************************************************************************
 
-Following are some TX fuctions for WiFi MLME
+Following are some TX functions for WiFi MLME
 
 *****************************************************************************/
 
@@ -2416,7 +2416,7 @@
 	pframe = mgmt->u.beacon.variable;
 	pattrib->pktlen = offsetof(struct ieee80211_mgmt, u.beacon.variable);
 
-	if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) {
+	if ((pmlmeinfo->state & 0x03) == MSR_AP) {
 		u8 *iebuf;
 		int buflen;
 		/* DBG_8723A("ie len =%d\n", cur_network->IELength); */
@@ -2461,7 +2461,7 @@
 	pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)
 			       &cur_network->DSConfig, &pattrib->pktlen);
 
-	/* if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) */
+	/* if ((pmlmeinfo->state&0x03) == MSR_ADHOC) */
 	{
 		u8 erpinfo = 0;
 		u32 ATIMWindow;
@@ -2578,7 +2578,7 @@
 	/* below for ad-hoc mode */
 
 #ifdef CONFIG_8723AU_AP_MODE
-	if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) {
+	if ((pmlmeinfo->state & 0x03) == MSR_AP) {
 		pwps_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT,
 						  WLAN_OUI_TYPE_MICROSOFT_WPS,
 						  cur_network->IEs,
@@ -2639,7 +2639,7 @@
 				       (unsigned char *)&cur_network->DSConfig,
 				       &pattrib->pktlen);
 
-		if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) {
+		if ((pmlmeinfo->state & 0x03) == MSR_ADHOC) {
 			u8 erpinfo = 0;
 			u32 ATIMWindow;
 			/*  IBSS Parameter Set... */
@@ -3352,7 +3352,7 @@
 	return;
 }
 
-/* when wait_ack is ture, this function shoule be called at process context */
+/* when wait_ack is true, this function should be called at process context */
 static int _issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
 			      unsigned int power_mode, int wait_ack)
 {
@@ -3391,9 +3391,9 @@
 	pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
 					      IEEE80211_STYPE_NULLFUNC);
 
-	if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)
+	if ((pmlmeinfo->state&0x03) == MSR_AP)
 		pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
-	else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)
+	else if ((pmlmeinfo->state&0x03) == MSR_INFRA)
 		pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_TODS);
 
 	if (power_mode)
@@ -3423,7 +3423,7 @@
 	return ret;
 }
 
-/* when wait_ms >0 , this function shoule be called at process context */
+/* when wait_ms >0 , this function should be called at process context */
 /* da == NULL for station mode */
 int issue_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
 		      unsigned int power_mode, int try_cnt, int wait_ms)
@@ -3434,7 +3434,7 @@
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 
-	/* da == NULL, assum it's null data for sta to ap*/
+	/* da == NULL, assume it's null data for sta to ap*/
 	if (da == NULL)
 		da = get_my_bssid23a(&pmlmeinfo->network);
 
@@ -3476,7 +3476,7 @@
 	return ret;
 }
 
-/* when wait_ack is ture, this function shoule be called at process context */
+/* when wait_ack is true, this function should be called at process context */
 static int _issue_qos_nulldata23a(struct rtw_adapter *padapter,
 				  unsigned char *da, u16 tid, int wait_ack)
 {
@@ -3513,9 +3513,9 @@
 	pwlanhdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
 					      IEEE80211_STYPE_QOS_NULLFUNC);
 
-	if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)
+	if ((pmlmeinfo->state&0x03) == MSR_AP)
 		pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
-	else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)
+	else if ((pmlmeinfo->state&0x03) == MSR_INFRA)
 		pwlanhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_TODS);
 
 	if (pattrib->mdata)
@@ -3551,7 +3551,7 @@
 	return ret;
 }
 
-/* when wait_ms >0 , this function shoule be called at process context */
+/* when wait_ms >0 , this function should be called at process context */
 /* da == NULL for station mode */
 int issue_qos_nulldata23a(struct rtw_adapter *padapter, unsigned char *da,
 			  u16 tid, int try_cnt, int wait_ms)
@@ -3562,7 +3562,7 @@
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 
-	/* da == NULL, assum it's null data for sta to ap*/
+	/* da == NULL, assume it's null data for sta to ap*/
 	if (da == NULL)
 		da = get_my_bssid23a(&pmlmeinfo->network);
 
@@ -3950,7 +3950,7 @@
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 	u16 tid;
 
-	if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE)
+	if ((pmlmeinfo->state&0x03) != MSR_AP)
 		if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS))
 			return _SUCCESS;
 
@@ -4023,7 +4023,7 @@
 
 /****************************************************************************
 
-Following are some utitity fuctions for WiFi MLME
+Following are some utitity functions for WiFi MLME
 
 *****************************************************************************/
 
@@ -4102,7 +4102,7 @@
 		/* val8 = 0; */
 
 		/* config MSR */
-		Set_MSR23a(padapter, (pmlmeinfo->state & 0x3));
+		rtl8723a_set_media_status(padapter, pmlmeinfo->state & 0x3);
 
 		/* restore RX GAIN */
 		rtl8723a_set_initial_gain(padapter, 0xff);
@@ -4303,7 +4303,7 @@
 	}
 
 
-	/*  mark bss info receving from nearby channel as SignalQuality 101 */
+	/*  mark bss info receiving from nearby channel as SignalQuality 101 */
 	if (bssid->DSConfig != rtw_get_oper_ch23a(padapter))
 		bssid->PhyInfo.SignalQuality = 101;
 
@@ -4325,7 +4325,7 @@
 	/* update wireless mode */
 	update_wireless_mode23a(padapter);
 
-	/* udpate capability */
+	/* update capability */
 	caps = pnetwork->capability;
 	update_capinfo23a(padapter, caps);
 	if (caps & WLAN_CAPABILITY_IBSS) {	/* adhoc master */
@@ -4337,20 +4337,17 @@
 
 		rtl8723a_SetBeaconRelatedRegisters(padapter);
 
-		/* set msr to WIFI_FW_ADHOC_STATE */
-		pmlmeinfo->state = WIFI_FW_ADHOC_STATE;
-		Set_MSR23a(padapter, (pmlmeinfo->state & 0x3));
+		/* set msr to MSR_ADHOC */
+		pmlmeinfo->state = MSR_ADHOC;
+		rtl8723a_set_media_status(padapter, pmlmeinfo->state & 0x3);
 
 		/* issue beacon */
-		if (send_beacon23a(padapter) == _FAIL)
-		{
+		if (send_beacon23a(padapter) == _FAIL) {
 			RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("issuing beacon frame fail....\n"));
 
 			report_join_res23a(padapter, -1);
-			pmlmeinfo->state = WIFI_FW_NULL_STATE;
-		}
-		else
-		{
+			pmlmeinfo->state = MSR_NOLINK;
+		} else {
 			hw_var_set_bssid(padapter, padapter->registrypriv.dev_network.MacAddress);
 			hw_var_set_mlme_join(padapter, 0);
 
@@ -4380,14 +4377,14 @@
 	/* update wireless mode */
 	update_wireless_mode23a(padapter);
 
-	/* udpate capability */
+	/* update capability */
 	caps = pnetwork->capability;
 	update_capinfo23a(padapter, caps);
 	if (caps & WLAN_CAPABILITY_ESS) {
 		/* switch channel */
 		set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode);
 
-		Set_MSR23a(padapter, WIFI_FW_STATION_STATE);
+		rtl8723a_set_media_status(padapter, MSR_INFRA);
 
 		val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ?
 			0xcc: 0xcf;
@@ -4403,9 +4400,9 @@
 		set_link_timer(pmlmeext, beacon_timeout);
 		mod_timer(&padapter->mlmepriv.assoc_timer, jiffies +
 			  msecs_to_jiffies((REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) + beacon_timeout));
-		pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE;
+		pmlmeinfo->state = WIFI_FW_AUTH_NULL | MSR_INFRA;
 	} else if (caps & WLAN_CAPABILITY_IBSS) {	/* adhoc client */
-		Set_MSR23a(padapter, WIFI_FW_ADHOC_STATE);
+		rtl8723a_set_media_status(padapter, MSR_ADHOC);
 
 		rtl8723a_set_sec_cfg(padapter, 0xcf);
 
@@ -4414,7 +4411,7 @@
 
 		rtl8723a_SetBeaconRelatedRegisters(padapter);
 
-		pmlmeinfo->state = WIFI_FW_ADHOC_STATE;
+		pmlmeinfo->state = MSR_ADHOC;
 
 		report_join_res23a(padapter, 1);
 	}
@@ -4483,17 +4480,17 @@
 
 	DBG_8723A("%s\n", __func__);
 
-	if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)
+	if ((pmlmeinfo->state&0x03) == MSR_INFRA)
 	{
 		if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)
 		{
-			pmlmeinfo->state = WIFI_FW_NULL_STATE;
+			pmlmeinfo->state = MSR_NOLINK;
 			report_del_sta_event23a(padapter, MacAddr, reason);
 
 		}
 		else if (pmlmeinfo->state & WIFI_FW_LINKING_STATE)
 		{
-			pmlmeinfo->state = WIFI_FW_NULL_STATE;
+			pmlmeinfo->state = MSR_NOLINK;
 			report_join_res23a(padapter, -2);
 		}
 	}
@@ -5053,7 +5050,7 @@
 		goto exit_mlmeext_joinbss_event_callback23a;
 	}
 
-	if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)
+	if ((pmlmeinfo->state&0x03) == MSR_ADHOC)
 	{
 		/* for bc/mc */
 		psta_bmc = rtw_get_bcmc_stainfo23a(padapter);
@@ -5076,7 +5073,7 @@
 	/* BCN interval */
 	rtl8723a_set_beacon_interval(padapter, pmlmeinfo->bcn_interval);
 
-	/* udpate capability */
+	/* update capability */
 	update_capinfo23a(padapter, pmlmeinfo->capability);
 
 	/* WMM, Update EDCA param */
@@ -5103,7 +5100,7 @@
 
 	hw_var_set_mlme_join(padapter, 2);
 
-	if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) {
+	if ((pmlmeinfo->state&0x03) == MSR_INFRA) {
 		/*  correcting TSF */
 		rtw_correct_TSF(padapter);
 
@@ -5124,7 +5121,7 @@
 
 	DBG_8723A("%s\n", __func__);
 
-	if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) {
+	if ((pmlmeinfo->state & 0x03) == MSR_ADHOC) {
 	/* adhoc master or sta_count>1 */
 		if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)
 		{
@@ -5137,7 +5134,7 @@
 			if (send_beacon23a(padapter) != _SUCCESS) {
 				pmlmeinfo->FW_sta_info[psta->mac_id].status = 0;
 
-				pmlmeinfo->state ^= WIFI_FW_ADHOC_STATE;
+				pmlmeinfo->state ^= MSR_ADHOC;
 
 				return;
 			}
@@ -5182,10 +5179,10 @@
 
 		flush_all_cam_entry23a(padapter);
 
-		pmlmeinfo->state = WIFI_FW_NULL_STATE;
+		pmlmeinfo->state = MSR_NOLINK;
 
 		/* set MSR to no link state -> infra. mode */
-		Set_MSR23a(padapter, _HW_STATE_STATION_);
+		rtl8723a_set_media_status(padapter, MSR_INFRA);
 
 		del_timer_sync(&pmlmeext->link_timer);
 	}
@@ -5393,7 +5390,7 @@
 
 	if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
 		DBG_8723A("link_timer_hdl:no beacon while connecting\n");
-		pmlmeinfo->state = WIFI_FW_NULL_STATE;
+		pmlmeinfo->state = MSR_NOLINK;
 		report_join_res23a(padapter, -3);
 	} else if (pmlmeinfo->state & WIFI_FW_AUTH_STATE) {
 		/* re-auth timer */
@@ -5418,7 +5415,7 @@
 	} else if (pmlmeinfo->state & WIFI_FW_ASSOC_STATE) {
 		/* re-assoc timer */
 		if (++pmlmeinfo->reassoc_count > REASSOC_LIMIT) {
-			pmlmeinfo->state = WIFI_FW_NULL_STATE;
+			pmlmeinfo->state = MSR_NOLINK;
 			report_join_res23a(padapter, -2);
 			return;
 		}
@@ -5479,22 +5476,22 @@
 	switch (psetop->mode) {
 	case NL80211_IFTYPE_P2P_GO:
 	case NL80211_IFTYPE_AP:
-		pmlmeinfo->state = WIFI_FW_AP_STATE;
-		type = _HW_STATE_AP_;
+		pmlmeinfo->state = MSR_AP;
+		type = MSR_AP;
 		break;
 	case NL80211_IFTYPE_P2P_CLIENT:
 	case NL80211_IFTYPE_STATION:
 		/*  clear state */
 		pmlmeinfo->state &= ~(BIT(0)|BIT(1));
 		/* set to STATION_STATE */
-		pmlmeinfo->state |= WIFI_FW_STATION_STATE;
-		type = _HW_STATE_STATION_;
+		pmlmeinfo->state |= MSR_INFRA;
+		type = MSR_INFRA;
 		break;
 	case NL80211_IFTYPE_ADHOC:
-		type = _HW_STATE_ADHOC_;
+		type = MSR_ADHOC;
 		break;
 	default:
-		type = _HW_STATE_NOLINK_;
+		type = MSR_NOLINK;
 		break;
 	}
 
@@ -5515,7 +5512,7 @@
 	if (pparm->ifmode == NL80211_IFTYPE_AP ||
 	    pparm->ifmode == NL80211_IFTYPE_P2P_GO) {
 #ifdef CONFIG_8723AU_AP_MODE
-		if (pmlmeinfo->state == WIFI_FW_AP_STATE) {
+		if (pmlmeinfo->state == MSR_AP) {
 			/* todo: */
 			return H2C_SUCCESS;
 		}
@@ -5572,11 +5569,11 @@
 
 	/* check already connecting to AP or not */
 	if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {
-		if (pmlmeinfo->state & WIFI_FW_STATION_STATE)
+		if (pmlmeinfo->state & MSR_INFRA)
 			issue_deauth_ex(padapter, pnetwork->MacAddress,
 					WLAN_REASON_DEAUTH_LEAVING, 5, 100);
 
-		pmlmeinfo->state = WIFI_FW_NULL_STATE;
+		pmlmeinfo->state = MSR_NOLINK;
 
 		/* clear CAM */
 		flush_all_cam_entry23a(padapter);
@@ -5584,8 +5581,7 @@
 		del_timer_sync(&pmlmeext->link_timer);
 
 		/* set MSR to nolink -> infra. mode */
-		/* Set_MSR23a(padapter, _HW_STATE_NOLINK_); */
-		Set_MSR23a(padapter, _HW_STATE_STATION_);
+		rtl8723a_set_media_status(padapter, MSR_INFRA);
 
 		hw_var_set_mlme_disconnect(padapter);
 	}
@@ -5691,7 +5687,7 @@
 
 	/* set_opmode_cmd(padapter, infra_client_with_mlme); */
 
-	/* pmlmeinfo->state = WIFI_FW_NULL_STATE; */
+	/* pmlmeinfo->state = MSR_NOLINK; */
 
 	hw_var_set_mlme_disconnect(padapter);
 	hw_var_set_bssid(padapter, null_addr);
@@ -5699,14 +5695,14 @@
 	/* restore to initial setting. */
 	update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode);
 
-	if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE ||
-	    (pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)
+	if ((pmlmeinfo->state & 0x03) == MSR_ADHOC ||
+	    (pmlmeinfo->state & 0x03) == MSR_AP)
 		rtl8723a_set_bcn_func(padapter, 0);	/* Stop BCN */
 
 	/* set MSR to no link state -> infra. mode */
-	Set_MSR23a(padapter, _HW_STATE_STATION_);
+	rtl8723a_set_media_status(padapter, MSR_INFRA);
 
-	pmlmeinfo->state = WIFI_FW_NULL_STATE;
+	pmlmeinfo->state = MSR_NOLINK;
 
 	/* switch to the 20M Hz mode after disconnect */
 	pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20;
@@ -5855,7 +5851,7 @@
 		rtl8723a_odm_support_ability_clr(padapter,
 						 DYNAMIC_FUNC_DISABLE);
 
-		/* config the initial gain under scaning, need to
+		/* config the initial gain under scanning, need to
 		   write the BB registers */
 		if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled == true)
 			initialgain = 0x30;
@@ -5865,7 +5861,7 @@
 		rtl8723a_set_initial_gain(padapter, initialgain);
 
 		/* set MSR to no link state */
-		Set_MSR23a(padapter, _HW_STATE_NOLINK_);
+		rtl8723a_set_media_status(padapter, MSR_NOLINK);
 
 		rtl8723a_mlme_sitesurvey(padapter, 1);
 
@@ -5941,7 +5937,7 @@
 	DBG_8723A_LEVEL(_drv_always_, "set pairwise key to hw: alg:%d(WEP40-1 "
 			"WEP104-5 TKIP-2 AES-4) camid:%d\n",
 			pparm->algorithm, cam_id);
-	if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) {
+	if ((pmlmeinfo->state & 0x03) == MSR_AP) {
 		struct sta_info *psta;
 		struct sta_priv *pstapriv = &padapter->stapriv;
 
@@ -6015,7 +6011,7 @@
 
 	if (((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) &&
 	     pmlmeinfo->HT_enable) ||
-	    (pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) {
+	    (pmlmeinfo->state & 0x03) == MSR_AP) {
 		issue_action_BA23a(padapter, pparm->addr,
 				   WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid);
 		mod_timer(&psta->addba_retry_timer,
diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c
index ad06335..7fbbdaf 100644
--- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c
@@ -498,7 +498,7 @@
 /*
 * rtw_pwr_wakeup - Wake the NIC up from: 1)IPS. 2)USB autosuspend
 * @adapter: pointer to _adapter structure
-* @ips_deffer_ms: the ms wiil prevent from falling into IPS after wakeup
+* @ips_deffer_ms: the ms will prevent from falling into IPS after wakeup
 * Return _SUCCESS or _FAIL
 */
 
diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c
index 690970e..a9f8183 100644
--- a/drivers/staging/rtl8723au/core/rtw_recv.c
+++ b/drivers/staging/rtl8723au/core/rtw_recv.c
@@ -1185,7 +1185,7 @@
 
 					/* DBG_8723A("after handling ps-poll, tim =%x\n", pstapriv->tim_bitmap); */
 
-					/* upate BCN for TIM IE */
+					/* update BCN for TIM IE */
 					/* update_BCNTIM(padapter); */
 					update_beacon23a(padapter, WLAN_EID_TIM,
 							 NULL, false);
@@ -1217,7 +1217,7 @@
 
 					pstapriv->tim_bitmap &= ~CHKBIT(psta->aid);
 
-					/* upate BCN for TIM IE */
+					/* update BCN for TIM IE */
 					/* update_BCNTIM(padapter); */
 					update_beacon23a(padapter, WLAN_EID_TIM,
 							 NULL, false);
@@ -2363,7 +2363,7 @@
 				recvpriv->signal_strength_data.avg_val;
 			num_signal_strength =
 				recvpriv->signal_strength_data.total_num;
-			/*  after avg_vals are accquired, we can re-stat */
+			/*  after avg_vals are acquired, we can re-stat */
 			/* the signal values */
 			recvpriv->signal_strength_data.update_req = 1;
 		}
@@ -2372,7 +2372,7 @@
 			/*  update_req is clear, means we got rx */
 			avg_signal_qual = recvpriv->signal_qual_data.avg_val;
 			num_signal_qual = recvpriv->signal_qual_data.total_num;
-			/*  after avg_vals are accquired, we can re-stat */
+			/*  after avg_vals are acquired, we can re-stat */
 			/*the signal values */
 			recvpriv->signal_qual_data.update_req = 1;
 		}
diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c
index c152aef..9a79e11 100644
--- a/drivers/staging/rtl8723au/core/rtw_sreset.c
+++ b/drivers/staging/rtl8723au/core/rtw_sreset.c
@@ -103,7 +103,7 @@
 	hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress);
 	hw_var_set_mlme_join(padapter, 0);
 
-	Set_MSR23a(padapter, (pmlmeinfo->state & 0x3));
+	rtl8723a_set_media_status(padapter, pmlmeinfo->state & 0x3);
 
 	mlmeext_joinbss_event_callback23a(padapter, 1);
 	/* restore Sequence No. */
diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c
index 8db844b..d17998d 100644
--- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c
@@ -26,7 +26,7 @@
 
 static void _rtw_init_stainfo(struct sta_info *psta)
 {
-	memset((u8 *)psta, 0, sizeof (struct sta_info));
+	memset((u8 *)psta, 0, sizeof(struct sta_info));
 	spin_lock_init(&psta->lock);
 	INIT_LIST_HEAD(&psta->list);
 	INIT_LIST_HEAD(&psta->hash_list);
@@ -71,8 +71,10 @@
 	pstapriv->auth_list_cnt = 0;
 	pstapriv->auth_to = 3; /*  3*2 = 6 sec */
 	pstapriv->assoc_to = 3;
-	/* pstapriv->expire_to = 900;  900*2 = 1800 sec = 30 min, expire after no any traffic. */
-	/* pstapriv->expire_to = 30;  30*2 = 60 sec = 1 min, expire after no any traffic. */
+	/* pstapriv->expire_to = 900;  900*2 = 1800 sec = 30 min,
+	    expire after no any traffic. */
+	/* pstapriv->expire_to = 30;  30*2 = 60 sec = 1 min,
+	    expire after no any traffic. */
 	pstapriv->expire_to = 3; /*  3*2 = 6 sec */
 	pstapriv->max_num_sta = NUM_STA;
 #endif
@@ -94,6 +96,7 @@
 
 			list_for_each_safe(plist, ptmp, phead) {
 				int i;
+
 				psta = container_of(plist, struct sta_info,
 						    hash_list);
 				for (i = 0; i < 16 ; i++) {
@@ -144,14 +147,17 @@
 
 	list_add_tail(&psta->hash_list, phash_list);
 
-	pstapriv->asoc_sta_count ++ ;
+	pstapriv->asoc_sta_count++;
 
-/*  For the SMC router, the sequence number of first packet of WPS handshake will be 0. */
-/*  In this case, this packet will be dropped by recv_decache function if we use the 0x00 as the default value for tid_rxseq variable. */
+/*  For the SMC router, the sequence number of first packet of WPS
+     handshake will be 0. */
+/*  In this case, this packet will be dropped by recv_decache function
+    if we use the 0x00 as the default value for tid_rxseq variable. */
 /*  So, we initialize the tid_rxseq variable as the 0xffff. */
 
 	for (i = 0; i < 16; i++)
-		memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2);
+		memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i],
+			&wRxSeqInitialValue, 2);
 
 	RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_,
 		 ("alloc number_%d stainfo  with hwaddr = %pM\n",
@@ -242,8 +248,12 @@
 	spin_unlock_bh(&pxmitpriv->lock);
 
 	list_del_init(&psta->hash_list);
-	RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("\n free number_%d stainfo  with hwaddr = 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x \n", pstapriv->asoc_sta_count, psta->hwaddr[0], psta->hwaddr[1], psta->hwaddr[2], psta->hwaddr[3], psta->hwaddr[4], psta->hwaddr[5]));
-	pstapriv->asoc_sta_count --;
+	RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_,
+		("\n free number_%d stainfo  with hwaddr = 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n",
+			pstapriv->asoc_sta_count, psta->hwaddr[0],
+			psta->hwaddr[1], psta->hwaddr[2], psta->hwaddr[3],
+			psta->hwaddr[4], psta->hwaddr[5]));
+	pstapriv->asoc_sta_count--;
 
 	/*  re-init sta_info; 20061114  will be init in alloc_stainfo */
 	/* _rtw_init_sta_xmit_priv23a(&psta->sta_xmitpriv); */
@@ -251,7 +261,8 @@
 
 	del_timer_sync(&psta->addba_retry_timer);
 
-	/* for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer */
+	/* for A-MPDU Rx reordering buffer control,
+	   cancel reordering_ctrl_timer */
 	for (i = 0; i < 16; i++) {
 		struct list_head	*phead, *plist;
 		struct recv_frame *prframe;
@@ -261,7 +272,8 @@
 
 		del_timer_sync(&preorder_ctrl->reordering_ctrl_timer);
 
-		ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;
+		ppending_recvframe_queue =
+			&preorder_ctrl->pending_recvframe_queue;
 
 		spin_lock_bh(&ppending_recvframe_queue->lock);
 		phead =		get_list_head(ppending_recvframe_queue);
@@ -301,7 +313,7 @@
 	pstapriv->sta_dz_bitmap &= ~CHKBIT(psta->aid);
 	pstapriv->tim_bitmap &= ~CHKBIT(psta->aid);
 
-	if ((psta->aid >0) && (pstapriv->sta_aid[psta->aid - 1] == psta)) {
+	if ((psta->aid > 0) && (pstapriv->sta_aid[psta->aid - 1] == psta)) {
 		pstapriv->sta_aid[psta->aid - 1] = NULL;
 		psta->aid = 0;
 	}
@@ -318,7 +330,7 @@
 	struct list_head *plist, *phead, *ptmp;
 	struct sta_info *psta;
 	struct sta_priv *pstapriv = &padapter->stapriv;
-	struct sta_info* pbcmc_stainfo = rtw_get_bcmc_stainfo23a(padapter);
+	struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo23a(padapter);
 	s32 index;
 
 	if (pstapriv->asoc_sta_count == 1)
@@ -332,7 +344,7 @@
 		list_for_each_safe(plist, ptmp, phead) {
 			psta = container_of(plist, struct sta_info, hash_list);
 
-			if (pbcmc_stainfo!= psta)
+			if (pbcmc_stainfo != psta)
 				rtw_free_stainfo23a(padapter, psta);
 		}
 	}
@@ -374,7 +386,7 @@
 	return psta;
 }
 
-int rtw_init_bcmc_stainfo23a(struct rtw_adapter* padapter)
+int rtw_init_bcmc_stainfo23a(struct rtw_adapter *padapter)
 {
 	struct	sta_priv *pstapriv = &padapter->stapriv;
 	struct sta_info		*psta;
diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c
index 25dae51..32f3603 100644
--- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c
@@ -18,6 +18,7 @@
 #include <drv_types.h>
 #include <linux/ieee80211.h>
 #include <wifi.h>
+#include <rtl8723a_spec.h>
 
 static unsigned char ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f};
 static unsigned char ARTHEROS_OUI2[] = {0x00, 0x13, 0x74};
@@ -293,11 +294,6 @@
 	}
 }
 
-void Set_MSR23a(struct rtw_adapter *padapter, u8 type)
-{
-	rtl8723a_set_media_status(padapter, type);
-}
-
 inline u8 rtw_get_oper_ch23a(struct rtw_adapter *adapter)
 {
 	return adapter_to_dvobj(adapter)->oper_channel;
@@ -407,7 +403,7 @@
 	pmlmeinfo = &pmlmeext->mlmext_info;
 
 	if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS &&
-	    (pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE)
+	    (pmlmeinfo->state & 0x03) == MSR_INFRA)
 		return true;
 	else
 		return false;
@@ -419,7 +415,7 @@
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 
 	if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS &&
-	    (pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE)
+	    (pmlmeinfo->state & 0x03) == MSR_ADHOC)
 		return true;
 	else
 		return false;
@@ -449,11 +445,6 @@
 		return bcn_interval << 2;
 }
 
-void invalidate_cam_all23a(struct rtw_adapter *padapter)
-{
-	rtl8723a_cam_invalid_all(padapter);
-}
-
 void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry)
 {
 	unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
@@ -487,7 +478,7 @@
 	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
 
-	rtl8723a_cam_invalid_all(padapter);
+	rtl8723a_cam_invalidate_all(padapter);
 
 	memset(pmlmeinfo->FW_sta_info, 0, sizeof(pmlmeinfo->FW_sta_info));
 }
diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c
index b917526..d83af87 100644
--- a/drivers/staging/rtl8723au/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723au/core/rtw_xmit.c
@@ -1197,7 +1197,7 @@
 			mpdu_len -= pattrib->icv_len;
 
 		if (bmcst)
-			/*  don't do fragment to broadcat/multicast packets */
+			/*  don't do fragment to broadcast/multicast packets */
 			mem_sz = min_t(s32, data_len, pattrib->pktlen);
 		else
 			mem_sz = min_t(s32, data_len, mpdu_len);
@@ -2011,7 +2011,7 @@
 
 			/* DBG_8723A("enqueue, sq_len =%d, tim =%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */
 
-			/* tx bc/mc packets after upate bcn */
+			/* tx bc/mc packets after update bcn */
 			update_beacon23a(padapter, WLAN_EID_TIM, NULL, false);
 
 			/* spin_unlock_bh(&psta->sleep_q.lock); */
@@ -2068,7 +2068,7 @@
 				pstapriv->tim_bitmap |= CHKBIT(psta->aid);
 
 				if (psta->sleepq_len == 1) {
-					/* upate BCN for TIM IE */
+					/* update BCN for TIM IE */
 					update_beacon23a(padapter, WLAN_EID_TIM,
 							 NULL, false);
 				}
@@ -2227,7 +2227,7 @@
 	if (psta->sleepq_len == 0) {
 		pstapriv->tim_bitmap &= ~CHKBIT(psta->aid);
 
-		/* upate BCN for TIM IE */
+		/* update BCN for TIM IE */
 		update_mask = BIT(0);
 
 		if (psta->state&WIFI_SLEEP_STATE)
@@ -2274,7 +2274,7 @@
 			pstapriv->tim_bitmap &= ~BIT(0);
 			pstapriv->sta_dz_bitmap &= ~BIT(0);
 
-			/* upate BCN for TIM IE */
+			/* update BCN for TIM IE */
 			/* update_BCNTIM(padapter); */
 			update_mask |= BIT(1);
 		}
@@ -2348,7 +2348,7 @@
 		    (wmmps_ac)) {
 			pstapriv->tim_bitmap &= ~CHKBIT(psta->aid);
 
-			/* upate BCN for TIM IE */
+			/* update BCN for TIM IE */
 			update_beacon23a(padapter, WLAN_EID_TIM, NULL, false);
 		}
 	}
diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c
index 9fba049..8f299ec 100644
--- a/drivers/staging/rtl8723au/hal/hal_com.c
+++ b/drivers/staging/rtl8723au/hal/hal_com.c
@@ -567,8 +567,8 @@
 		pmlmeinfo = &pmlmeext->mlmext_info;
 
 		if ((is_client_associated_to_ap23a(padapter) == true) ||
-		    ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) ||
-		    ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) {
+		    ((pmlmeinfo->state & 0x03) == MSR_ADHOC) ||
+		    ((pmlmeinfo->state & 0x03) == MSR_AP)) {
 			/*  enable to rx data frame */
 			rtl8723au_write16(padapter, REG_RXFLTMAP2, 0xFFFF);
 
@@ -669,16 +669,16 @@
 		   ("rtl8723a_cam_empty_entry(): WRITE A4: %lx \n",
 		   ulContent));*/
 		/* delay_ms(40); */
-		rtl8723au_write32(padapter, RWCAM, ulCommand);
+		rtl8723au_write32(padapter, REG_CAMCMD, ulCommand);
 		/* RT_TRACE(COMP_SEC, DBG_LOUD,
 		   ("rtl8723a_cam_empty_entry(): WRITE A0: %lx \n",
 		   ulCommand));*/
 	}
 }
 
-void rtl8723a_cam_invalid_all(struct rtw_adapter *padapter)
+void rtl8723a_cam_invalidate_all(struct rtw_adapter *padapter)
 {
-	rtl8723au_write32(padapter, RWCAM, BIT(31) | BIT(30));
+	rtl8723au_write32(padapter, REG_CAMCMD, CAM_POLLINIG | BIT(30));
 }
 
 void rtl8723a_cam_write(struct rtw_adapter *padapter,
@@ -708,7 +708,7 @@
 
 		rtl8723au_write32(padapter, WCAMI, val);
 		cmd = CAM_POLLINIG | CAM_WRITE | (addr + j);
-		rtl8723au_write32(padapter, RWCAM, cmd);
+		rtl8723au_write32(padapter, REG_CAMCMD, cmd);
 
 		/* DBG_8723A("%s => cam write: %x, %x\n", __func__, cmd, val);*/
 	}
@@ -818,24 +818,6 @@
 	rtl8723au_write8(padapter, REG_RXDMA_AGG_PG_TH, val);
 }
 
-void rtl8723a_set_nav_upper(struct rtw_adapter *padapter, u32 usNavUpper)
-{
-	if (usNavUpper > HAL_8723A_NAV_UPPER_UNIT * 0xFF) {
-		RT_TRACE(_module_hal_init_c_, _drv_notice_,
-			 ("The setting value (0x%08X us) of NAV_UPPER "
-			  "is larger than (%d * 0xFF)!!!\n",
-			  usNavUpper, HAL_8723A_NAV_UPPER_UNIT));
-		return;
-	}
-
-	/*  The value of ((usNavUpper + HAL_8723A_NAV_UPPER_UNIT - 1) /
-	    HAL_8723A_NAV_UPPER_UNIT) */
-	/*  is getting the upper integer. */
-	usNavUpper = (usNavUpper + HAL_8723A_NAV_UPPER_UNIT - 1) /
-		HAL_8723A_NAV_UPPER_UNIT;
-	rtl8723au_write8(padapter, REG_NAV_UPPER, (u8) usNavUpper);
-}
-
 void rtl8723a_set_initial_gain(struct rtw_adapter *padapter, u32 rx_gain)
 {
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
@@ -867,12 +849,10 @@
 {
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
 
-	if (val == DYNAMIC_ALL_FUNC_ENABLE) {
-		pHalData->dmpriv.DMFlag = pHalData->dmpriv.InitDMFlag;
+	if (val == DYNAMIC_ALL_FUNC_ENABLE)
 		pHalData->odmpriv.SupportAbility = pHalData->dmpriv.InitODMFlag;
-	} else {
+	else
 		pHalData->odmpriv.SupportAbility |= val;
-	}
 }
 
 void rtl8723a_odm_support_ability_clr(struct rtw_adapter *padapter, u32 val)
diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c
index e15ebfe..1c0f106d 100644
--- a/drivers/staging/rtl8723au/hal/odm.c
+++ b/drivers/staging/rtl8723au/hal/odm.c
@@ -166,12 +166,10 @@
 /* START------------COMMON INFO RELATED--------------- */
 void odm_CommonInfoSelfInit23a(struct dm_odm_t *pDM_Odm);
 
-void odm_CommonInfoSelfUpdate23a(struct dm_odm_t *pDM_Odm);
+static void odm_CommonInfoSelfUpdate(struct hal_data_8723a *pHalData);
 
 void odm_CmnInfoInit_Debug23a(struct dm_odm_t *pDM_Odm);
 
-void odm_CmnInfoHook_Debug23a(struct dm_odm_t *pDM_Odm);
-
 void odm_CmnInfoUpdate_Debug23a(struct dm_odm_t *pDM_Odm);
 
 /* START---------------DIG--------------------------- */
@@ -179,7 +177,7 @@
 
 void odm_DIG23aInit(struct dm_odm_t *pDM_Odm);
 
-void odm_DIG23a(struct dm_odm_t *pDM_Odm);
+void odm_DIG23a(struct rtw_adapter *adapter);
 
 void odm_CCKPacketDetectionThresh23a(struct dm_odm_t *pDM_Odm);
 /* END---------------DIG--------------------------- */
@@ -210,18 +208,6 @@
 void odm_RSSIMonitorCheck23a(struct dm_odm_t *pDM_Odm);
 void odm_DynamicTxPower23a(struct dm_odm_t *pDM_Odm);
 
-void odm_SwAntDivInit(struct dm_odm_t *pDM_Odm);
-
-void odm_SwAntDivInit_NIC(struct dm_odm_t *pDM_Odm);
-
-void odm_SwAntDivChkAntSwitch(struct dm_odm_t *pDM_Odm, u8 Step);
-
-void odm_SwAntDivChkAntSwitchNIC(struct dm_odm_t *pDM_Odm,
-		u8 Step
-	);
-
-void odm_SwAntDivChkAntSwitchCallback23a(unsigned long data);
-
 void odm_RefreshRateAdaptiveMask23a(struct dm_odm_t *pDM_Odm);
 
 void ODM_TXPowerTrackingCheck23a(struct dm_odm_t *pDM_Odm);
@@ -238,16 +224,12 @@
 
 void odm_TXPowerTrackingCheckCE23a(struct dm_odm_t *pDM_Odm);
 
-void odm_EdcaTurboCheck23a(struct dm_odm_t *pDM_Odm);
-void ODM_EdcaTurboInit23a(struct dm_odm_t *pDM_Odm);
-
-void odm_EdcaTurboCheck23aCE23a(struct dm_odm_t *pDM_Odm);
+static void odm_EdcaTurboCheck23a(struct dm_odm_t *pDM_Odm);
+static void ODM_EdcaTurboInit23a(struct dm_odm_t *pDM_Odm);
 
 #define		RxDefaultAnt1		0x65a9
 #define	RxDefaultAnt2		0x569a
 
-void odm_InitHybridAntDiv23a(struct dm_odm_t *pDM_Odm);
-
 bool odm_StaDefAntSel(struct dm_odm_t *pDM_Odm,
  u32 OFDM_Ant1_Cnt,
  u32 OFDM_Ant2_Cnt,
@@ -261,8 +243,6 @@
    bool   bDualPath
 );
 
-void odm_HwAntDiv23a(struct dm_odm_t *pDM_Odm);
-
 /* 3 Export Interface */
 
 /*  2011/09/21 MH Add to describe different team necessary resource allocate?? */
@@ -274,29 +254,24 @@
 	odm_DIG23aInit(pDM_Odm);
 	odm_RateAdaptiveMaskInit23a(pDM_Odm);
 
-	if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) {
-		odm23a_DynBBPSInit(pDM_Odm);
-		odm_DynamicTxPower23aInit(pDM_Odm);
-		odm_TXPowerTrackingInit23a(pDM_Odm);
-		ODM_EdcaTurboInit23a(pDM_Odm);
-		if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV)	||
-		    (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV)	||
-		    (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV))
-			odm_InitHybridAntDiv23a(pDM_Odm);
-		else if (pDM_Odm->AntDivType == CGCS_RX_SW_ANTDIV)
-			odm_SwAntDivInit(pDM_Odm);
-	}
+	odm23a_DynBBPSInit(pDM_Odm);
+	odm_DynamicTxPower23aInit(pDM_Odm);
+	odm_TXPowerTrackingInit23a(pDM_Odm);
+	ODM_EdcaTurboInit23a(pDM_Odm);
 }
 
 /*  2011/09/20 MH This is the entry pointer for all team to execute HW out source DM. */
 /*  You can not add any dummy function here, be care, you can only use DM structure */
 /*  to perform any new ODM_DM. */
-void ODM_DMWatchdog23a(struct dm_odm_t *pDM_Odm)
+void ODM_DMWatchdog23a(struct rtw_adapter *adapter)
 {
+	struct hal_data_8723a *pHalData = GET_HAL_DATA(adapter);
+	struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
+	struct pwrctrl_priv *pwrctrlpriv = &adapter->pwrctrlpriv;
+
 	/* 2012.05.03 Luke: For all IC series */
-	odm_CmnInfoHook_Debug23a(pDM_Odm);
 	odm_CmnInfoUpdate_Debug23a(pDM_Odm);
-	odm_CommonInfoSelfUpdate23a(pDM_Odm);
+	odm_CommonInfoSelfUpdate(pHalData);
 	odm_FalseAlarmCounterStatistics23a(pDM_Odm);
 	odm_RSSIMonitorCheck23a(pDM_Odm);
 
@@ -304,33 +279,25 @@
 	/* NeilChen--2012--08--24-- */
 	/* Fix Leave LPS issue */
 	if ((pDM_Odm->Adapter->pwrctrlpriv.pwr_mode != PS_MODE_ACTIVE) &&/*  in LPS mode */
-	    (pDM_Odm->SupportICType & (ODM_RTL8723A))) {
+	    (pDM_Odm->SupportICType & ODM_RTL8723A)) {
 			ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG23a is in LPS mode\n"));
 			ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n"));
 			odm_DIG23abyRSSI_LPS(pDM_Odm);
 	} else {
-		odm_DIG23a(pDM_Odm);
+		odm_DIG23a(adapter);
 	}
 
 	odm_CCKPacketDetectionThresh23a(pDM_Odm);
 
-	if (*(pDM_Odm->pbPowerSaving))
+	if (pwrctrlpriv->bpower_saving)
 		return;
 
 	odm_RefreshRateAdaptiveMask23a(pDM_Odm);
 
 	odm_DynamicBBPowerSaving23a(pDM_Odm);
-	if ((pDM_Odm->AntDivType ==  CG_TRX_HW_ANTDIV)	||
-	    (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV)	||
-	    (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV))
-		odm_HwAntDiv23a(pDM_Odm);
-	else if (pDM_Odm->AntDivType == CGCS_RX_SW_ANTDIV)
-		odm_SwAntDivChkAntSwitch(pDM_Odm, SWAW_STEP_PEAK);
 
-	if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) {
-		ODM_TXPowerTrackingCheck23a(pDM_Odm);
-	      odm_EdcaTurboCheck23a(pDM_Odm);
-	}
+	ODM_TXPowerTrackingCheck23a(pDM_Odm);
+	odm_EdcaTurboCheck23a(pDM_Odm);
 
 	odm_dtc(pDM_Odm);
 }
@@ -350,9 +317,6 @@
 	/*  */
 	switch	(CmnInfo) {
 	/*  Fixed ODM value. */
-	case	ODM_CMNINFO_ABILITY:
-		pDM_Odm->SupportAbility = (u32)Value;
-		break;
 	case	ODM_CMNINFO_PLATFORM:
 		break;
 	case	ODM_CMNINFO_INTERFACE:
@@ -373,9 +337,6 @@
 	case	ODM_CMNINFO_RF_TYPE:
 		pDM_Odm->RFType = (u8)Value;
 		break;
-	case    ODM_CMNINFO_RF_ANTENNA_TYPE:
-		pDM_Odm->AntDivType = (u8)Value;
-		break;
 	case	ODM_CMNINFO_BOARD_TYPE:
 		pDM_Odm->BoardType = (u8)Value;
 		break;
@@ -416,81 +377,6 @@
 
 }
 
-void ODM23a_CmnInfoHook(struct dm_odm_t *pDM_Odm,
-		enum odm_cmninfo CmnInfo,
-		void *pValue
-	)
-{
-	/*  Hook call by reference pointer. */
-	switch	(CmnInfo) {
-	/*  Dynamic call by reference pointer. */
-	case	ODM_CMNINFO_MAC_PHY_MODE:
-		pDM_Odm->pMacPhyMode = (u8 *)pValue;
-		break;
-	case	ODM_CMNINFO_TX_UNI:
-		pDM_Odm->pNumTxBytesUnicast = (u64 *)pValue;
-		break;
-	case	ODM_CMNINFO_RX_UNI:
-		pDM_Odm->pNumRxBytesUnicast = (u64 *)pValue;
-		break;
-	case	ODM_CMNINFO_WM_MODE:
-		pDM_Odm->pWirelessMode = (u8 *)pValue;
-		break;
-	case	ODM_CMNINFO_BAND:
-		pDM_Odm->pBandType = (u8 *)pValue;
-		break;
-	case	ODM_CMNINFO_SEC_CHNL_OFFSET:
-		pDM_Odm->pSecChOffset = (u8 *)pValue;
-		break;
-	case	ODM_CMNINFO_SEC_MODE:
-		pDM_Odm->pSecurity = (u8 *)pValue;
-		break;
-	case	ODM_CMNINFO_BW:
-		pDM_Odm->pBandWidth = (u8 *)pValue;
-		break;
-	case	ODM_CMNINFO_CHNL:
-		pDM_Odm->pChannel = (u8 *)pValue;
-		break;
-	case	ODM_CMNINFO_DMSP_GET_VALUE:
-		pDM_Odm->pbGetValueFromOtherMac = (bool *)pValue;
-		break;
-	case	ODM_CMNINFO_BUDDY_ADAPTOR:
-		pDM_Odm->pBuddyAdapter = (struct rtw_adapter **)pValue;
-		break;
-	case	ODM_CMNINFO_DMSP_IS_MASTER:
-		pDM_Odm->pbMasterOfDMSP = (bool *)pValue;
-		break;
-	case	ODM_CMNINFO_SCAN:
-		pDM_Odm->pbScanInProcess = (bool *)pValue;
-		break;
-	case	ODM_CMNINFO_POWER_SAVING:
-		pDM_Odm->pbPowerSaving = (bool *)pValue;
-		break;
-	case	ODM_CMNINFO_ONE_PATH_CCA:
-		pDM_Odm->pOnePathCCA = (u8 *)pValue;
-		break;
-	case	ODM_CMNINFO_DRV_STOP:
-		pDM_Odm->pbDriverStopped =  (bool *)pValue;
-		break;
-	case	ODM_CMNINFO_PNP_IN:
-		pDM_Odm->pbDriverIsGoingToPnpSetPowerSleep =  (bool *)pValue;
-		break;
-	case	ODM_CMNINFO_INIT_ON:
-		pDM_Odm->pinit_adpt_in_progress =  (bool *)pValue;
-		break;
-	case	ODM_CMNINFO_ANT_TEST:
-		pDM_Odm->pAntennaTest =  (u8 *)pValue;
-		break;
-	case	ODM_CMNINFO_NET_CLOSED:
-		pDM_Odm->pbNet_closed = (bool *)pValue;
-		break;
-	/* To remove the compiler warning, must add an empty default statement to handle the other values. */
-	default:
-		/* do nothing */
-		break;
-	}
-}
-
 void ODM_CmnInfoPtrArrayHook23a(struct dm_odm_t *pDM_Odm, enum odm_cmninfo CmnInfo,
 				u16 Index, void *pValue)
 {
@@ -512,9 +398,6 @@
 {
 	/*  This init variable may be changed in run time. */
 	switch	(CmnInfo) {
-	case	ODM_CMNINFO_ABILITY:
-		pDM_Odm->SupportAbility = (u32)Value;
-		break;
 	case	ODM_CMNINFO_RF_TYPE:
 		pDM_Odm->RFType = (u8)Value;
 		break;
@@ -549,32 +432,33 @@
 void odm_CommonInfoSelfInit23a(struct dm_odm_t *pDM_Odm
 	)
 {
-	pDM_Odm->bCckHighPower = (bool) ODM_GetBBReg(pDM_Odm, 0x824, BIT(9));
-	pDM_Odm->RFPathRxEnable = (u8) ODM_GetBBReg(pDM_Odm, 0xc04, 0x0F);
-	if (pDM_Odm->SupportICType & (ODM_RTL8723A))
-		pDM_Odm->AntDivType = CGCS_RX_SW_ANTDIV;
+	pDM_Odm->bCckHighPower =
+		(bool) ODM_GetBBReg(pDM_Odm, rFPGA0_XA_HSSIParameter2, BIT(9));
+	pDM_Odm->RFPathRxEnable =
+		(u8) ODM_GetBBReg(pDM_Odm, rOFDM0_TRxPathEnable, 0x0F);
 
 	ODM_InitDebugSetting23a(pDM_Odm);
 }
 
-void odm_CommonInfoSelfUpdate23a(struct dm_odm_t *pDM_Odm)
+static void odm_CommonInfoSelfUpdate(struct hal_data_8723a *pHalData)
 {
+	struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
+	struct sta_info *pEntry;
 	u8 EntryCnt = 0;
 	u8 i;
-	struct sta_info *pEntry;
 
-	if (*(pDM_Odm->pBandWidth) == ODM_BW40M) {
-		if (*(pDM_Odm->pSecChOffset) == 1)
-			pDM_Odm->ControlChannel = *(pDM_Odm->pChannel) - 2;
-		else if (*(pDM_Odm->pSecChOffset) == 2)
-			pDM_Odm->ControlChannel = *(pDM_Odm->pChannel) + 2;
+	if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_40) {
+		if (pHalData->nCur40MhzPrimeSC == 1)
+			pDM_Odm->ControlChannel = pHalData->CurrentChannel - 2;
+		else if (pHalData->nCur40MhzPrimeSC == 2)
+			pDM_Odm->ControlChannel = pHalData->CurrentChannel + 2;
 	} else {
-		pDM_Odm->ControlChannel = *(pDM_Odm->pChannel);
+		pDM_Odm->ControlChannel = pHalData->CurrentChannel;
 	}
 
 	for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
 		pEntry = pDM_Odm->pODM_StaInfo[i];
-		if (IS_STA_VALID(pEntry))
+		if (pEntry)
 			EntryCnt++;
 	}
 	if (EntryCnt == 1)
@@ -603,21 +487,6 @@
 
 }
 
-void odm_CmnInfoHook_Debug23a(struct dm_odm_t *pDM_Odm)
-{
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoHook_Debug23a ==>\n"));
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pNumTxBytesUnicast =%llu\n", *(pDM_Odm->pNumTxBytesUnicast)));
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pNumRxBytesUnicast =%llu\n", *(pDM_Odm->pNumRxBytesUnicast)));
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pWirelessMode = 0x%x\n", *(pDM_Odm->pWirelessMode)));
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pSecChOffset =%d\n", *(pDM_Odm->pSecChOffset)));
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pSecurity =%d\n", *(pDM_Odm->pSecurity)));
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pBandWidth =%d\n", *(pDM_Odm->pBandWidth)));
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pChannel =%d\n", *(pDM_Odm->pChannel)));
-
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbScanInProcess =%d\n", *(pDM_Odm->pbScanInProcess)));
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbPowerSaving =%d\n", *(pDM_Odm->pbPowerSaving)));
-}
-
 void odm_CmnInfoUpdate_Debug23a(struct dm_odm_t *pDM_Odm)
 {
 	ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoUpdate_Debug23a ==>\n"));
@@ -655,7 +524,7 @@
 	u8 bFwCurrentInPSMode = false;
 	u8 CurrentIGI = pDM_Odm->RSSI_Min;
 
-	if (!(pDM_Odm->SupportICType & (ODM_RTL8723A)))
+	if (!(pDM_Odm->SupportICType & ODM_RTL8723A))
 		return;
 
 	CurrentIGI = CurrentIGI+RSSI_OFFSET_DIG;
@@ -723,15 +592,12 @@
 	pDM_DigTable->DIG_Dynamic_MIN_1 = DM_DIG_MIN_NIC;
 	pDM_DigTable->bMediaConnect_0 = false;
 	pDM_DigTable->bMediaConnect_1 = false;
-
-	/* To Initialize pDM_Odm->bDMInitialGainEnable == false to avoid DIG error */
-	pDM_Odm->bDMInitialGainEnable = true;
-
 }
 
-void odm_DIG23a(struct dm_odm_t *pDM_Odm)
+void odm_DIG23a(struct rtw_adapter *adapter)
 {
-
+	struct hal_data_8723a *pHalData = GET_HAL_DATA(adapter);
+	struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 	struct dig_t *pDM_DigTable = &pDM_Odm->DM_DigTable;
 	struct false_alarm_stats *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt;
 	u8 DIG_Dynamic_MIN;
@@ -748,23 +614,17 @@
 		return;
 	}
 
-	if (*(pDM_Odm->pbScanInProcess)) {
+	if (adapter->mlmepriv.bScanInProcess) {
 		ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a() Return: In Scan Progress \n"));
 		return;
 	}
 
-	/* add by Neil Chen to avoid PSD is processing */
-	if (!pDM_Odm->bDMInitialGainEnable) {
-		ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG23a() Return: PSD is Processing \n"));
-		return;
-	}
-
 	DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0;
 	FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0);
 	FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0);
 
 	/* 1 Boundary Decision */
-	if ((pDM_Odm->SupportICType & (ODM_RTL8723A)) &&
+	if ((pDM_Odm->SupportICType & ODM_RTL8723A) &&
 	    ((pDM_Odm->BoardType == ODM_BOARD_HIGHPWR) || pDM_Odm->ExtLNA)) {
 		dm_dig_max = DM_DIG_MAX_NIC_HP;
 		dm_dig_min = DM_DIG_MIN_NIC_HP;
@@ -777,7 +637,7 @@
 
 	if (pDM_Odm->bLinked) {
 	      /* 2 8723A Series, offset need to be 10 */
-		if (pDM_Odm->SupportICType == (ODM_RTL8723A)) {
+		if (pDM_Odm->SupportICType == ODM_RTL8723A) {
 			/* 2 Upper Bound */
 			if ((pDM_Odm->RSSI_Min + 10) > DM_DIG_MAX_NIC)
 				pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC;
@@ -925,32 +785,36 @@
 	if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT))
 		return;
 
-	if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) {
-		/* hold ofdm counter */
-		ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT(31), 1); /* hold page C counter */
-		ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 1); /* hold page D counter */
+	/* hold ofdm counter */
+	 /* hold page C counter */
+	ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT(31), 1);
+	/* hold page D counter */
+	ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 1);
+	ret_value =
+		ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord);
+	FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff);
+	FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value&0xffff0000)>>16);
+	ret_value =
+		ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord);
+	FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0xffff);
+	FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16);
+	ret_value =
+		ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord);
+	FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff);
+	FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16);
+	ret_value =
+		ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord);
+	FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff);
 
-		ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord);
-		FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff);
-		FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value&0xffff0000)>>16);
-		ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord);
-		FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0xffff);
-		FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16);
-		ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord);
-		FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff);
-		FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16);
-		ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord);
-		FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff);
-
-		FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail +
-					     FalseAlmCnt->Cnt_Rate_Illegal +
-					     FalseAlmCnt->Cnt_Crc8_fail +
-					     FalseAlmCnt->Cnt_Mcs_fail +
-					     FalseAlmCnt->Cnt_Fast_Fsync +
-					     FalseAlmCnt->Cnt_SB_Search_fail;
-		/* hold cck counter */
-		ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(12), 1);
-		ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(14), 1);
+	FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail +
+		FalseAlmCnt->Cnt_Rate_Illegal +
+		FalseAlmCnt->Cnt_Crc8_fail +
+		FalseAlmCnt->Cnt_Mcs_fail +
+		FalseAlmCnt->Cnt_Fast_Fsync +
+		FalseAlmCnt->Cnt_SB_Search_fail;
+	/* hold cck counter */
+	ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(12), 1);
+	ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(14), 1);
 
 	ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_LSB_11N, bMaskByte0);
 	FalseAlmCnt->Cnt_Cck_fail = ret_value;
@@ -958,7 +822,8 @@
 	FalseAlmCnt->Cnt_Cck_fail +=  (ret_value & 0xff) << 8;
 
 	ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_CCA_CNT_11N, bMaskDWord);
-	FalseAlmCnt->Cnt_CCK_CCA = ((ret_value&0xFF)<<8) | ((ret_value&0xFF00)>>8);
+	FalseAlmCnt->Cnt_CCK_CCA =
+		((ret_value&0xFF)<<8) | ((ret_value&0xFF00)>>8);
 
 	FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Fast_Fsync +
 				FalseAlmCnt->Cnt_SB_Search_fail +
@@ -968,7 +833,8 @@
 				FalseAlmCnt->Cnt_Mcs_fail +
 				FalseAlmCnt->Cnt_Cck_fail);
 
-	FalseAlmCnt->Cnt_CCA_all = FalseAlmCnt->Cnt_OFDM_CCA + FalseAlmCnt->Cnt_CCK_CCA;
+	FalseAlmCnt->Cnt_CCA_all =
+		FalseAlmCnt->Cnt_OFDM_CCA + FalseAlmCnt->Cnt_CCK_CCA;
 
 	if (pDM_Odm->SupportICType >= ODM_RTL8723A) {
 		/* reset false alarm counter registers */
@@ -977,8 +843,10 @@
 		ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(27), 1);
 		ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(27), 0);
 		/* update ofdm counter */
-		ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT(31), 0); /* update page C counter */
-		ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 0); /* update page D counter */
+		 /* update page C counter */
+		ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT(31), 0);
+		 /* update page D counter */
+		ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 0);
 
 		/* reset CCK CCA counter */
 		ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N,
@@ -992,26 +860,20 @@
 			     BIT(15) | BIT(14), 2);
 	}
 
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Enter odm_FalseAlarmCounterStatistics23a\n"));
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Fast_Fsync =%d, Cnt_SB_Search_fail =%d\n",
-		FalseAlmCnt->Cnt_Fast_Fsync, FalseAlmCnt->Cnt_SB_Search_fail));
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Parity_Fail =%d, Cnt_Rate_Illegal =%d\n",
-		FalseAlmCnt->Cnt_Parity_Fail, FalseAlmCnt->Cnt_Rate_Illegal));
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Crc8_fail =%d, Cnt_Mcs_fail =%d\n",
-		FalseAlmCnt->Cnt_Crc8_fail, FalseAlmCnt->Cnt_Mcs_fail));
-	} else { /* FOR ODM_IC_11AC_SERIES */
-		/* read OFDM FA counter */
-		FalseAlmCnt->Cnt_Ofdm_fail = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_11AC, bMaskLWord);
-		FalseAlmCnt->Cnt_Cck_fail = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_11AC, bMaskLWord);
-		FalseAlmCnt->Cnt_all = FalseAlmCnt->Cnt_Ofdm_fail + FalseAlmCnt->Cnt_Cck_fail;
+	ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD,
+		     ("Enter odm_FalseAlarmCounterStatistics23a\n"));
+	ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD,
+		     ("Cnt_Fast_Fsync =%d, Cnt_SB_Search_fail =%d\n",
+		      FalseAlmCnt->Cnt_Fast_Fsync,
+		      FalseAlmCnt->Cnt_SB_Search_fail));
+	ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD,
+		     ("Cnt_Parity_Fail =%d, Cnt_Rate_Illegal =%d\n",
+		      FalseAlmCnt->Cnt_Parity_Fail,
+		      FalseAlmCnt->Cnt_Rate_Illegal));
+	ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD,
+		     ("Cnt_Crc8_fail =%d, Cnt_Mcs_fail =%d\n",
+		      FalseAlmCnt->Cnt_Crc8_fail, FalseAlmCnt->Cnt_Mcs_fail));
 
-		/*  reset OFDM FA coutner */
-		ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT(17), 1);
-		ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT(17), 0);
-		/*  reset CCK FA counter */
-		ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT(15), 0);
-		ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT(15), 1);
-	}
 	ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Cck_fail =%d\n", FalseAlmCnt->Cnt_Cck_fail));
 	ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Ofdm_fail =%d\n", FalseAlmCnt->Cnt_Ofdm_fail));
 	ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Total False Alarm =%d\n", FalseAlmCnt->Cnt_all));
@@ -1207,18 +1069,16 @@
 	pOdmRA->LowRSSIThresh = 20;
 }
 
-u32 ODM_Get_Rate_Bitmap23a(struct dm_odm_t *pDM_Odm,
-	u32 macid,
-	u32 ra_mask,
-	u8 rssi_level)
+u32 ODM_Get_Rate_Bitmap23a(struct hal_data_8723a *pHalData, u32 macid,
+			   u32 ra_mask, u8 rssi_level)
 {
+	struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 	struct sta_info *pEntry;
 	u32 rate_bitmap = 0x0fffffff;
 	u8 WirelessMode;
-	/* u8 WirelessMode =*(pDM_Odm->pWirelessMode); */
 
 	pEntry = pDM_Odm->pODM_StaInfo[macid];
-	if (!IS_STA_VALID(pEntry))
+	if (!pEntry)
 		return ra_mask;
 
 	WirelessMode = pEntry->wireless_mode;
@@ -1252,7 +1112,8 @@
 			} else if (rssi_level == DM_RATR_STA_MIDDLE) {
 				rate_bitmap = 0x000ff000;
 			} else {
-				if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
+				if (pHalData->CurrentChannelBW ==
+				    HT_CHANNEL_WIDTH_40)
 					rate_bitmap = 0x000ff015;
 				else
 					rate_bitmap = 0x000ff005;
@@ -1263,7 +1124,8 @@
 			} else if (rssi_level == DM_RATR_STA_MIDDLE) {
 				rate_bitmap = 0x0f8ff000;
 			} else {
-				if (*(pDM_Odm->pBandWidth) == ODM_BW40M)
+				if (pHalData->CurrentChannelBW ==
+				    HT_CHANNEL_WIDTH_40)
 					rate_bitmap = 0x0f8ff015;
 				else
 					rate_bitmap = 0x0f8ff005;
@@ -1340,7 +1202,7 @@
 
 	for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
 		struct sta_info *pstat = pDM_Odm->pODM_StaInfo[i];
-		if (IS_STA_VALID(pstat)) {
+		if (pstat) {
 			if (ODM_RAStateCheck23a(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) {
 				ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD,
 					     ("RSSI:%d, RSSI_LEVEL:%d\n",
@@ -1482,7 +1344,7 @@
 
 	for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
 		psta = pDM_Odm->pODM_StaInfo[i];
-		if (IS_STA_VALID(psta)) {
+		if (psta) {
 			if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB)
 				tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB;
 
@@ -1568,52 +1430,8 @@
 {
 }
 
-/* antenna mapping info */
-/*  1: right-side antenna */
-/*  2/0: left-side antenna */
-/* PpDM_SWAT_Table->CCK_Ant1_Cnt /OFDM_Ant1_Cnt:  for right-side antenna:   Ant:1    RxDefaultAnt1 */
-/* PpDM_SWAT_Table->CCK_Ant2_Cnt /OFDM_Ant2_Cnt:  for left-side antenna:     Ant:0    RxDefaultAnt2 */
-/*  We select left antenna as default antenna in initial process, modify it as needed */
-/*  */
-
-/* 3 ============================================================ */
-/* 3 SW Antenna Diversity */
-/* 3 ============================================================ */
-void odm_SwAntDivInit(struct dm_odm_t *pDM_Odm)
-{
-}
-
-void ODM_SwAntDivChkPerPktRssi(struct dm_odm_t *pDM_Odm, u8 StationID,
-			       struct phy_info *pPhyInfo)
-{
-}
-
-void odm_SwAntDivChkAntSwitch(struct dm_odm_t *pDM_Odm, u8 Step)
-{
-}
-
-void ODM_SwAntDivRestAfterLink(struct dm_odm_t *pDM_Odm)
-{
-}
-
-void odm_SwAntDivChkAntSwitchCallback23a(unsigned long data)
-{
-}
-
-/* 3 ============================================================ */
-/* 3 SW Antenna Diversity */
-/* 3 ============================================================ */
-
-void odm_InitHybridAntDiv23a(struct dm_odm_t *pDM_Odm)
-{
-}
-
-void odm_HwAntDiv23a(struct dm_odm_t *pDM_Odm)
-{
-}
-
 /* EDCA Turbo */
-void ODM_EdcaTurboInit23a(struct dm_odm_t *pDM_Odm)
+static void ODM_EdcaTurboInit23a(struct dm_odm_t *pDM_Odm)
 {
 
 	struct rtw_adapter *Adapter = pDM_Odm->Adapter;
@@ -1628,39 +1446,30 @@
 
 }	/*  ODM_InitEdcaTurbo */
 
-void odm_EdcaTurboCheck23a(struct dm_odm_t *pDM_Odm)
-{
-	/*  For AP/ADSL use struct rtl8723a_priv * */
-	/*  For CE/NIC use struct rtw_adapter * */
-
-	/*  2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */
-	/*  at the same time. In the stage2/3, we need to prive universal interface and merge all */
-	/*  HW dynamic mechanism. */
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("odm_EdcaTurboCheck23a ========================>\n"));
-
-	if (!(pDM_Odm->SupportAbility & ODM_MAC_EDCA_TURBO))
-		return;
-
-	odm_EdcaTurboCheck23aCE23a(pDM_Odm);
-	ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("<======================== odm_EdcaTurboCheck23a\n"));
-
-}	/*  odm_CheckEdcaTurbo */
-
-void odm_EdcaTurboCheck23aCE23a(struct dm_odm_t *pDM_Odm)
+static void odm_EdcaTurboCheck23a(struct dm_odm_t *pDM_Odm)
 {
 	struct rtw_adapter *Adapter = pDM_Odm->Adapter;
-
-	u32 trafficIndex;
-	u32 edca_param;
-	u64 cur_tx_bytes = 0;
-	u64 cur_rx_bytes = 0;
-	u8 bbtchange = false;
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
 	struct xmit_priv *pxmitpriv = &Adapter->xmitpriv;
 	struct recv_priv *precvpriv = &Adapter->recvpriv;
 	struct registry_priv *pregpriv = &Adapter->registrypriv;
 	struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv;
 	struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
+	u32 trafficIndex;
+	u32 edca_param;
+	u64 cur_tx_bytes = 0;
+	u64 cur_rx_bytes = 0;
+	u8 bbtchange = false;
+
+	/*  For AP/ADSL use struct rtl8723a_priv * */
+	/*  For CE/NIC use struct rtw_adapter * */
+
+	/*  2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */
+	/*  at the same time. In the stage2/3, we need to prive universal interface and merge all */
+	/*  HW dynamic mechanism. */
+
+	if (!(pDM_Odm->SupportAbility & ODM_MAC_EDCA_TURBO))
+		return;
 
 	if ((pregpriv->wifi_spec == 1))/*  (pmlmeinfo->HT_enable == 0)) */
 		goto dm_CheckEdcaTurbo_EXIT;
@@ -1836,7 +1645,7 @@
 		rSleep, rPMPD_ANAEN,
 		rFPGA0_XCD_SwitchControl, rBlue_Tooth};
 
-	if (!(pDM_Odm->SupportICType & (ODM_RTL8723A)))
+	if (!(pDM_Odm->SupportICType & ODM_RTL8723A))
 		return bResult;
 
 	if (!(pDM_Odm->SupportAbility&ODM_BB_ANT_DIV))
diff --git a/drivers/staging/rtl8723au/hal/odm_HWConfig.c b/drivers/staging/rtl8723au/hal/odm_HWConfig.c
index 26fbf6c..409fde4 100644
--- a/drivers/staging/rtl8723au/hal/odm_HWConfig.c
+++ b/drivers/staging/rtl8723au/hal/odm_HWConfig.c
@@ -291,7 +291,7 @@
 		return;
 
 	pEntry = pDM_Odm->pODM_StaInfo[pPktinfo->StationID];
-	if (!IS_STA_VALID(pEntry))
+	if (!pEntry)
 		return;
 	if ((!pPktinfo->bPacketMatchBSSID))
 		return;
@@ -401,8 +401,6 @@
 					 pPhyStatus, pPktinfo);
 	if (pDM_Odm->RSSI_test) {
 		/*  Select the packets to do RSSI checking for antenna switching. */
-		if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon)
-			ODM_SwAntDivChkPerPktRssi(pDM_Odm, pPktinfo->StationID, pPhyInfo);
 	} else {
 		odm_Process_RSSIForDM(pDM_Odm, pPhyInfo, pPktinfo);
 	}
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
index 66ece49..271c33d 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
@@ -151,7 +151,8 @@
 
 	bitmap &= 0x0fffffff;
 	if (rssi_level != DM_RATR_STA_INIT)
-		bitmap = ODM_Get_Rate_Bitmap23a(&pHalData->odmpriv, macid, bitmap, rssi_level);
+		bitmap = ODM_Get_Rate_Bitmap23a(pHalData, macid, bitmap,
+						rssi_level);
 
 	bitmap |= ((raid<<28)&0xf0000000);
 
@@ -235,7 +236,7 @@
 	pframe = mgmt->u.beacon.variable;
 	pktlen = offsetof(struct ieee80211_mgmt, u.beacon.variable);
 
-	if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) {
+	if ((pmlmeinfo->state&0x03) == MSR_AP) {
 		/* DBG_8723A("ie len =%d\n", cur_network->IELength); */
 		pktlen += cur_network->IELength;
 		memcpy(pframe, cur_network->IEs, pktlen);
@@ -259,7 +260,7 @@
 	pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)
 			       &cur_network->DSConfig, &pktlen);
 
-	if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) {
+	if ((pmlmeinfo->state&0x03) == MSR_ADHOC) {
 		u32 ATIMWindow;
 		/*  IBSS Parameter Set... */
 		/* ATIMWindow = cur->ATIMWindow; */
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c
index ac47a97..fa826b0 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c
@@ -34,10 +34,6 @@
 /*  Global var */
 /*  */
 
-static void dm_CheckStatistics(struct rtw_adapter *Adapter)
-{
-}
-
 static void dm_CheckPbcGPIO(struct rtw_adapter *padapter)
 {
 	u8	tmp1byte;
@@ -86,16 +82,15 @@
 
 /*  Initialize GPIO setting registers */
 /*  functions */
-static void Init_ODM_ComInfo_8723a(struct rtw_adapter *Adapter)
+
+void rtl8723a_init_dm_priv(struct rtw_adapter *Adapter)
 {
-
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
+	struct dm_priv	*pdmpriv = &pHalData->dmpriv;
 	struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
-	u8	cut_ver, fab_ver;
+	u8 cut_ver, fab_ver;
 
-	/*  */
-	/*  Init Value */
-	/*  */
+	memset(pdmpriv, 0, sizeof(struct dm_priv));
 	memset(pDM_Odm, 0, sizeof(*pDM_Odm));
 
 	pDM_Odm->Adapter = Adapter;
@@ -137,9 +132,6 @@
 
 static void Update_ODM_ComInfo_8723a(struct rtw_adapter *Adapter)
 {
-	struct mlme_ext_priv	*pmlmeext = &Adapter->mlmeextpriv;
-	struct mlme_priv		*pmlmepriv = &Adapter->mlmepriv;
-	struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv;
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
 	struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 	struct dm_priv	*pdmpriv = &pHalData->dmpriv;
@@ -155,28 +147,7 @@
 				ODM_RF_TX_PWR_TRACK	|
 				ODM_RF_CALIBRATION;
 	/*  Pointer reference */
-
-	ODM_CmnInfoUpdate23a(pDM_Odm, ODM_CMNINFO_ABILITY, pdmpriv->InitODMFlag);
-
-	ODM23a_CmnInfoHook(pDM_Odm, ODM_CMNINFO_TX_UNI,
-			   &Adapter->xmitpriv.tx_bytes);
-	ODM23a_CmnInfoHook(pDM_Odm, ODM_CMNINFO_RX_UNI,
-			   &Adapter->recvpriv.rx_bytes);
-	ODM23a_CmnInfoHook(pDM_Odm, ODM_CMNINFO_WM_MODE,
-			   &pmlmeext->cur_wireless_mode);
-	ODM23a_CmnInfoHook(pDM_Odm, ODM_CMNINFO_SEC_CHNL_OFFSET,
-			   &pHalData->nCur40MhzPrimeSC);
-	ODM23a_CmnInfoHook(pDM_Odm, ODM_CMNINFO_SEC_MODE,
-			   &Adapter->securitypriv.dot11PrivacyAlgrthm);
-	ODM23a_CmnInfoHook(pDM_Odm, ODM_CMNINFO_BW,
-			   &pHalData->CurrentChannelBW);
-	ODM23a_CmnInfoHook(pDM_Odm, ODM_CMNINFO_CHNL,
-			   &pHalData->CurrentChannel);
-	ODM23a_CmnInfoHook(pDM_Odm, ODM_CMNINFO_NET_CLOSED, &Adapter->net_closed);
-
-	ODM23a_CmnInfoHook(pDM_Odm, ODM_CMNINFO_SCAN, &pmlmepriv->bScanInProcess);
-	ODM23a_CmnInfoHook(pDM_Odm, ODM_CMNINFO_POWER_SAVING,
-			   &pwrctrlpriv->bpower_saving);
+	rtl8723a_odm_support_ability_set(Adapter, DYNAMIC_ALL_FUNC_ENABLE);
 
 	for (i = 0; i < NUM_STA; i++)
 		ODM_CmnInfoPtrArrayHook23a(pDM_Odm, ODM_CMNINFO_STA_STATUS, i, NULL);
@@ -189,14 +160,6 @@
 	struct dm_odm_t *pDM_Odm = &pHalData->odmpriv;
 	u8	i;
 
-	pdmpriv->DM_Type = DM_Type_ByDriver;
-	pdmpriv->DMFlag = DYNAMIC_FUNC_DISABLE;
-
-#ifdef CONFIG_8723AU_BT_COEXIST
-	pdmpriv->DMFlag |= DYNAMIC_FUNC_BT;
-#endif
-	pdmpriv->InitDMFlag = pdmpriv->DMFlag;
-
 	Update_ODM_ComInfo_8723a(Adapter);
 	ODM23a_DMInit(pDM_Odm);
 	/*  Save REG_INIDATA_RATE_SEL value for TXDESC. */
@@ -211,6 +174,7 @@
 {
 	bool		bFwCurrentInPSMode = false;
 	bool		bFwPSAwake = true;
+	u8 bLinked = false;
 	u8 hw_init_completed = false;
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
 	struct dm_priv	*pdmpriv = &pHalData->dmpriv;
@@ -223,10 +187,7 @@
 	bFwCurrentInPSMode = Adapter->pwrctrlpriv.bFwCurrentInPSMode;
 	bFwPSAwake = rtl8723a_get_fwlps_rf_on(Adapter);
 
-	if ((hw_init_completed) && ((!bFwCurrentInPSMode) && bFwPSAwake)) {
-		/*  Calculate Tx/Rx statistics. */
-		dm_CheckStatistics(Adapter);
-
+	if (!bFwCurrentInPSMode && bFwPSAwake) {
 		/*  Read REG_INIDATA_RATE_SEL value for TXDESC. */
 		if (check_fwstate(&Adapter->mlmepriv, WIFI_STATION_STATE)) {
 			pdmpriv->INIDATA_RATE[0] = rtl8723au_read8(Adapter, REG_INIDATA_RATE_SEL) & 0x3f;
@@ -238,16 +199,11 @@
 	}
 
 	/* ODM */
-	if (hw_init_completed == true) {
-		u8	bLinked = false;
+	if (rtw_linked_check(Adapter))
+		bLinked = true;
 
-		if (rtw_linked_check(Adapter))
-			bLinked = true;
-
-		ODM_CmnInfoUpdate23a(&pHalData->odmpriv, ODM_CMNINFO_LINK,
-				     bLinked);
-		ODM_DMWatchdog23a(&pHalData->odmpriv);
-	}
+	ODM_CmnInfoUpdate23a(&pHalData->odmpriv, ODM_CMNINFO_LINK, bLinked);
+	ODM_DMWatchdog23a(Adapter);
 
 skip_dm:
 
@@ -255,16 +211,3 @@
 	/*  Check Hardware Radio ON/OFF or not */
 	dm_CheckPbcGPIO(Adapter);
 }
-
-void rtl8723a_init_dm_priv(struct rtw_adapter *Adapter)
-{
-	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
-	struct dm_priv	*pdmpriv = &pHalData->dmpriv;
-
-	memset(pdmpriv, 0, sizeof(struct dm_priv));
-	Init_ODM_ComInfo_8723a(Adapter);
-}
-
-void rtl8723a_deinit_dm_priv(struct rtw_adapter *Adapter)
-{
-}
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
index 2bc830f..8523908 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
@@ -882,28 +882,18 @@
 /*  */
 void SetBcnCtrlReg23a(struct rtw_adapter *padapter, u8 SetBits, u8 ClearBits)
 {
-	struct hal_data_8723a *pHalData;
-	u32 addr;
-	u8 *pRegBcnCtrlVal;
+	u8 val8;
 
-	pHalData = GET_HAL_DATA(padapter);
-	pRegBcnCtrlVal = (u8 *)&pHalData->RegBcnCtrlVal;
+	val8 = rtl8723au_read8(padapter, REG_BCN_CTRL);
+	val8 |= SetBits;
+	val8 &= ~ClearBits;
 
-	addr = REG_BCN_CTRL;
-
-	*pRegBcnCtrlVal = rtl8723au_read8(padapter, addr);
-	*pRegBcnCtrlVal |= SetBits;
-	*pRegBcnCtrlVal &= ~ClearBits;
-
-	rtl8723au_write8(padapter, addr, *pRegBcnCtrlVal);
+	rtl8723au_write8(padapter, REG_BCN_CTRL, val8);
 }
 
 void rtl8723a_InitBeaconParameters(struct rtw_adapter *padapter)
 {
-	struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
-
 	rtl8723au_write16(padapter, REG_BCN_CTRL, 0x1010);
-	pHalData->RegBcnCtrlVal = 0x1010;
 
 	/*  TODO: Remove these magic number */
 	rtl8723au_write16(padapter, REG_TBTT_PROHIBIT, 0x6404);	/*  ms */
@@ -2300,18 +2290,18 @@
 {
 	u8 val8;
 
-	if ((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) {
+	if (mode == MSR_INFRA || mode == MSR_NOLINK) {
 		StopTxBeacon(padapter);
 
 		/*  disable atim wnd */
 		val8 = DIS_TSF_UDT | EN_BCN_FUNCTION | DIS_ATIM;
 		SetBcnCtrlReg23a(padapter, val8, ~val8);
-	} else if ((mode == _HW_STATE_ADHOC_) /*|| (mode == _HW_STATE_AP_) */) {
+	} else if (mode == MSR_ADHOC) {
 		ResumeTxBeacon(padapter);
 
 		val8 = DIS_TSF_UDT | EN_BCN_FUNCTION | DIS_BCNQ_SUB;
 		SetBcnCtrlReg23a(padapter, val8, ~val8);
-	} else if (mode == _HW_STATE_AP_) {
+	} else if (mode == MSR_AP) {
 		/*  add NULL Data and BT NULL Data Packets to FW RSVD Page */
 		rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(padapter);
 
@@ -2393,8 +2383,8 @@
 		do_div(pmlmeext->TSFValue,
 		       (pmlmeinfo->bcn_interval * 1024)) - 1024;	/* us */
 
-	if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) ||
-	    ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) {
+	if (((pmlmeinfo->state & 0x03) == MSR_ADHOC) ||
+	    ((pmlmeinfo->state & 0x03) == MSR_AP)) {
 		/* pHalData->RegTxPause |= STOP_BCNQ;BIT(6) */
 		/* rtl8723au_write8(padapter, REG_TXPAUSE,
 		   (rtl8723au_read8(Adapter, REG_TXPAUSE)|BIT(6))); */
@@ -2412,8 +2402,8 @@
 	/* enable related TSF function */
 	SetBcnCtrlReg23a(padapter, EN_BCN_FUNCTION, 0);
 
-	if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) ||
-	    ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE))
+	if (((pmlmeinfo->state & 0x03) == MSR_ADHOC) ||
+	    ((pmlmeinfo->state & 0x03) == MSR_AP))
 		ResumeTxBeacon(padapter);
 }
 
diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c
index 8a7e644..681810e 100644
--- a/drivers/staging/rtl8723au/hal/usb_halinit.c
+++ b/drivers/staging/rtl8723au/hal/usb_halinit.c
@@ -338,17 +338,6 @@
 	_InitNormalChipQueuePriority(Adapter);
 }
 
-static void _InitNetworkType(struct rtw_adapter *Adapter)
-{
-	u32 value32;
-
-	value32 = rtl8723au_read32(Adapter, REG_CR);
-
-	/*  TODO: use the other function to set network type */
-	value32 = (value32 & ~MASK_NETTYPE) | _NETTYPE(NT_LINK_AP);
-	rtl8723au_write32(Adapter, REG_CR, value32);
-}
-
 static void _InitTransferPageSize(struct rtw_adapter *Adapter)
 {
 	/*  Tx page size is always 128. */
@@ -484,62 +473,6 @@
 	rtl8723au_write8(Adapter, REG_ACKTO, 0x40);
 }
 
-/*-----------------------------------------------------------------------------
- * Function:	usb_AggSettingTxUpdate()
- *
- * Overview:	Seperate TX/RX parameters update independent for TP
- *		detection and dynamic TX/RX aggreagtion parameters update.
- *
- * Input:			struct rtw_adapter *
- *
- * Output/Return:	NONE
- *
- * Revised History:
- *	When		Who		Remark
- *	12/10/2010	MHC		Seperate to smaller function.
- *
- *---------------------------------------------------------------------------*/
-static void usb_AggSettingTxUpdate(struct rtw_adapter *Adapter)
-{
-}	/*  usb_AggSettingTxUpdate */
-
-/*-----------------------------------------------------------------------------
- * Function:	usb_AggSettingRxUpdate()
- *
- * Overview:	Seperate TX/RX parameters update independent for TP
- *		detection and dynamic TX/RX aggreagtion parameters update.
- *
- * Input:			struct rtw_adapter *
- *
- * Output/Return:	NONE
- *
- * Revised History:
- *	When		Who		Remark
- *	12/10/2010	MHC		Seperate to smaller function.
- *
- *---------------------------------------------------------------------------*/
-static void usb_AggSettingRxUpdate(struct rtw_adapter *Adapter)
-{
-}	/*  usb_AggSettingRxUpdate */
-
-static void InitUsbAggregationSetting(struct rtw_adapter *Adapter)
-{
-	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
-
-	/*  Tx aggregation setting */
-	usb_AggSettingTxUpdate(Adapter);
-
-	/*  Rx aggregation setting */
-	usb_AggSettingRxUpdate(Adapter);
-
-	/*  201/12/10 MH Add for USB agg mode dynamic switch. */
-	pHalData->UsbRxHighSpeedMode = false;
-}
-
-static void _InitOperationMode(struct rtw_adapter *Adapter)
-{
-}
-
 static void _InitRFType(struct rtw_adapter *Adapter)
 {
 	struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter);
@@ -601,7 +534,7 @@
 
 void _ps_open_RF23a(struct rtw_adapter *padapter);
 
-static int rtl8723au_hal_init(struct rtw_adapter *Adapter)
+int rtl8723au_hal_init(struct rtw_adapter *Adapter)
 {
 	u8 val8 = 0;
 	u32 boundary;
@@ -612,6 +545,8 @@
 
 	unsigned long init_start_time = jiffies;
 
+	Adapter->hw_init_completed = false;
+
 	if (Adapter->pwrctrlpriv.bkeepfwalive) {
 		_ps_open_RF23a(Adapter);
 
@@ -756,14 +691,12 @@
 
 	_InitInterrupt(Adapter);
 	hw_var_set_macaddr(Adapter, Adapter->eeprompriv.mac_addr);
-	_InitNetworkType(Adapter);/* set msr */
+	rtl8723a_set_media_status(Adapter, MSR_INFRA);
 	_InitWMACSetting(Adapter);
 	_InitAdaptiveCtrl(Adapter);
 	_InitEDCA(Adapter);
 	_InitRateFallback(Adapter);
 	_InitRetryFunction(Adapter);
-	InitUsbAggregationSetting(Adapter);
-	_InitOperationMode(Adapter);/* todo */
 	rtl8723a_InitBeaconParameters(Adapter);
 
 	_InitHWLed(Adapter);
@@ -771,7 +704,7 @@
 	_BBTurnOnBlock(Adapter);
 	/* NicIFSetMacAddress(padapter, padapter->PermanentAddress); */
 
-	invalidate_cam_all23a(Adapter);
+	rtl8723a_cam_invalidate_all(Adapter);
 
 	/*  2010/12/17 MH We need to set TX power according to EFUSE content at first. */
 	PHY_SetTxPowerLevel8723A(Adapter, pHalData->CurrentChannel);
@@ -849,7 +782,9 @@
 
 	rtl8723a_InitHalDm(Adapter);
 
-	rtl8723a_set_nav_upper(Adapter, WiFiNavUpperUs);
+	val8 = ((WiFiNavUpperUs + HAL_8723A_NAV_UPPER_UNIT - 1) /
+		HAL_8723A_NAV_UPPER_UNIT);
+	rtl8723au_write8(Adapter, REG_NAV_UPPER, val8);
 
 	/*  2011/03/09 MH debug only, UMC-B cut pass 2500 S5 test, but we need to fin root cause. */
 	if (((rtl8723au_read32(Adapter, rFPGA0_RFMOD) & 0xFF000000) !=
@@ -863,6 +798,13 @@
 			  rtl8723au_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12));
 
 exit:
+	if (status == _SUCCESS) {
+		Adapter->hw_init_completed = true;
+
+		if (Adapter->registrypriv.notch_filter == 1)
+			rtl8723a_notch_filter(Adapter, 1);
+	}
+
 	DBG_8723A("%s in %dms\n", __func__,
 		  jiffies_to_msecs(jiffies - init_start_time));
 	return status;
@@ -1172,7 +1114,7 @@
 	rtl8723au_write8(Adapter, REG_RSV_CTRL, 0x0e);
 }
 
-static int rtl8723au_hal_deinit(struct rtw_adapter *padapter)
+int rtl8723au_hal_deinit(struct rtw_adapter *padapter)
 {
 	DBG_8723A("==> %s\n", __func__);
 
@@ -1185,6 +1127,8 @@
 	/*  IC. Accord to johnny's opinion, only RU need the support. */
 	CardDisableRTL8723U(padapter);
 
+	padapter->hw_init_completed = false;
+
 	return _SUCCESS;
 }
 
@@ -1569,8 +1513,8 @@
 
 	/* mask &= 0x0fffffff; */
 	rate_bitmap = 0x0fffffff;
-	rate_bitmap = ODM_Get_Rate_Bitmap23a(&pHalData->odmpriv,
-					  mac_id, mask, rssi_level);
+	rate_bitmap = ODM_Get_Rate_Bitmap23a(pHalData, mac_id, mask,
+					     rssi_level);
 	DBG_8723A("%s => mac_id:%d, networkType:0x%02x, "
 		  "mask:0x%08x\n\t ==> rssi_level:%d, rate_bitmap:0x%08x\n",
 		  __func__, mac_id, networkType, mask, rssi_level, rate_bitmap);
@@ -1610,40 +1554,3 @@
 	/* set correct initial date rate for each mac_id */
 	pdmpriv->INIDATA_RATE[mac_id] = init_rate;
 }
-
-int rtw_hal_init23a(struct rtw_adapter *padapter)
-{
-	int status;
-
-	padapter->hw_init_completed = false;
-
-	status = rtl8723au_hal_init(padapter);
-
-	if (status == _SUCCESS) {
-		padapter->hw_init_completed = true;
-
-		if (padapter->registrypriv.notch_filter == 1)
-			rtl8723a_notch_filter(padapter, 1);
-	} else {
-		padapter->hw_init_completed = false;
-		DBG_8723A("rtw_hal_init23a: hal__init fail\n");
-	}
-
-	RT_TRACE(_module_hal_init_c_, _drv_err_,
-		 ("-rtl871x_hal_init:status = 0x%x\n", status));
-
-	return status;
-}
-
-int rtw_hal_deinit23a(struct rtw_adapter *padapter)
-{
-	int status;
-
-	status = rtl8723au_hal_deinit(padapter);
-
-	if (status == _SUCCESS)
-		padapter->hw_init_completed = false;
-	else
-		DBG_8723A("\n rtw_hal_deinit23a: hal_init fail\n");
-	return status;
-}
diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h
index 4a161e2..7c31865 100644
--- a/drivers/staging/rtl8723au/include/hal_com.h
+++ b/drivers/staging/rtl8723au/include/hal_com.h
@@ -182,7 +182,7 @@
 void rtl8723a_ack_preamble(struct rtw_adapter *padapter, u8 bShortPreamble);
 void rtl8723a_set_sec_cfg(struct rtw_adapter *padapter, u8 sec);
 void rtl8723a_cam_empty_entry(struct rtw_adapter *padapter, u8 ucIndex);
-void rtl8723a_cam_invalid_all(struct rtw_adapter *padapter);
+void rtl8723a_cam_invalidate_all(struct rtw_adapter *padapter);
 void rtl8723a_cam_write(struct rtw_adapter *padapter,
 			u8 entry, u16 ctrl, const u8 *mac, const u8 *key);
 void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter);
@@ -197,7 +197,6 @@
 void rtl8723a_set_ac_param_be(struct rtw_adapter *padapter, u32 be);
 void rtl8723a_set_ac_param_bk(struct rtw_adapter *padapter, u32 bk);
 void rtl8723a_set_rxdma_agg_pg_th(struct rtw_adapter *padapter, u8 val);
-void rtl8723a_set_nav_upper(struct rtw_adapter *padapter, u32 usNavUpper);
 void rtl8723a_set_initial_gain(struct rtw_adapter *padapter, u32 rx_gain);
 
 void rtl8723a_odm_support_ability_write(struct rtw_adapter *padapter, u32 val);
diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h
index 04223b5..404acb5 100644
--- a/drivers/staging/rtl8723au/include/hal_intf.h
+++ b/drivers/staging/rtl8723au/include/hal_intf.h
@@ -101,10 +101,9 @@
 
 void rtw_hal_def_value_init23a(struct rtw_adapter *padapter);
 int pm_netdev_open23a(struct net_device *pnetdev, u8 bnormal);
-int rtw_resume_process23a(struct rtw_adapter *padapter);
 
-int rtw_hal_init23a(struct rtw_adapter *padapter);
-int rtw_hal_deinit23a(struct rtw_adapter *padapter);
+int rtl8723au_hal_init(struct rtw_adapter *padapter);
+int rtl8723au_hal_deinit(struct rtw_adapter *padapter);
 void rtw_hal_stop(struct rtw_adapter *padapter);
 
 void rtw_hal_update_ra_mask23a(struct sta_info *psta, u8 rssi_level);
diff --git a/drivers/staging/rtl8723au/include/odm.h b/drivers/staging/rtl8723au/include/odm.h
index 08c6f72..41dba62 100644
--- a/drivers/staging/rtl8723au/include/odm.h
+++ b/drivers/staging/rtl8723au/include/odm.h
@@ -125,7 +125,6 @@
 	bool		bMediaConnect_0;
 	bool		bMediaConnect_1;
 
-	u32		AntDiv_RSSI_max;
 	u32		RSSI_max;
 };
 
@@ -300,7 +299,6 @@
 	/*  */
 
 	ODM_CMNINFO_PLATFORM = 0,
-	ODM_CMNINFO_ABILITY,					/*  enum odm_ability */
 	ODM_CMNINFO_INTERFACE,				/*  enum odm_interface_def */
 	ODM_CMNINFO_MP_TEST_CHIP,
 	ODM_CMNINFO_IC_TYPE,					/*  enum odm_ic_type_def */
@@ -320,27 +318,6 @@
 	/*  */
 	/*  Dynamic value: */
 	/*  */
-	ODM_CMNINFO_MAC_PHY_MODE,			/*  enum odm_mac_phy_mode */
-	ODM_CMNINFO_TX_UNI,
-	ODM_CMNINFO_RX_UNI,
-	ODM_CMNINFO_WM_MODE,				/*  enum odm_wireless_mode */
-	ODM_CMNINFO_BAND,					/*  enum odm_band_type */
-	ODM_CMNINFO_SEC_CHNL_OFFSET,		/*  enum odm_sec_chnl_offset */
-	ODM_CMNINFO_SEC_MODE,				/*  enum odm_security */
-	ODM_CMNINFO_BW,						/*  enum odm_band_width */
-	ODM_CMNINFO_CHNL,
-
-	ODM_CMNINFO_DMSP_GET_VALUE,
-	ODM_CMNINFO_BUDDY_ADAPTOR,
-	ODM_CMNINFO_DMSP_IS_MASTER,
-	ODM_CMNINFO_SCAN,
-	ODM_CMNINFO_POWER_SAVING,
-	ODM_CMNINFO_ONE_PATH_CCA,			/*  enum odm_cca_path */
-	ODM_CMNINFO_DRV_STOP,
-	ODM_CMNINFO_PNP_IN,
-	ODM_CMNINFO_INIT_ON,
-	ODM_CMNINFO_ANT_TEST,
-	ODM_CMNINFO_NET_CLOSED,
 	ODM_CMNINFO_MP_MODE,
 
 	ODM_CMNINFO_WIFI_DIRECT,
@@ -415,10 +392,6 @@
 	ODM_RTL8821	=	BIT(6),
 };
 
-#define ODM_IC_11N_SERIES			\
-	(ODM_RTL8192S|ODM_RTL8192C|ODM_RTL8192D|ODM_RTL8723A|ODM_RTL8188E)
-#define ODM_IC_11AC_SERIES		(ODM_RTL8812)
-
 /* ODM_CMNINFO_CUT_VER */
 enum odm_cut_version {
 	ODM_CUT_A		=	1,
@@ -516,15 +489,6 @@
 	ODM_ABOVE		= 2
 };
 
-/*  ODM_CMNINFO_BW */
-enum odm_band_width {
-	ODM_BW20M		= 0,
-	ODM_BW40M		= 1,
-	ODM_BW80M		= 2,
-	ODM_BW160M		= 3,
-	ODM_BW10M		= 4,
-};
-
 /*  ODM_CMNINFO_CHNL */
 
 /*  ODM_CMNINFO_BOARD_TYPE */
@@ -705,7 +669,6 @@
 
 	bool			bDualMacSmartConcurrent;
 	u32			BK_SupportAbility;
-	u8			AntDivType;
 /* HOOK BEFORE REG INIT----------- */
 
 	/*  */
@@ -717,37 +680,6 @@
 	bool			bool_temp;
 	struct rtw_adapter	*PADAPTER_temp;
 
-	/*  MAC PHY Mode SMSP/DMSP/DMDP = 0/1/2 */
-	u8			*pMacPhyMode;
-	/* TX Unicast byte count */
-	u64			*pNumTxBytesUnicast;
-	/* RX Unicast byte count */
-	u64			*pNumRxBytesUnicast;
-	/*  Wireless mode B/G/A/N = BIT0/BIT1/BIT2/BIT3 */
-	u8			*pWirelessMode; /* enum odm_wireless_mode */
-	/*  Frequence band 2.4G/5G = 0/1 */
-	u8			*pBandType;
-	/*  Secondary channel offset don't_care/below/above = 0/1/2 */
-	u8			*pSecChOffset;
-	/*  Security mode Open/WEP/AES/TKIP = 0/1/2/3 */
-	u8			*pSecurity;
-	/*  BW info 20M/40M/80M = 0/1/2 */
-	u8			*pBandWidth;
-	/*  Central channel location Ch1/Ch2/.... */
-	u8			*pChannel;	/* central channel number */
-	/*  Common info for 92D DMSP */
-
-	bool			*pbGetValueFromOtherMac;
-	struct rtw_adapter	**pBuddyAdapter;
-	bool			*pbMasterOfDMSP; /* MAC0: master, MAC1: slave */
-	/*  Common info for Status */
-	bool			*pbScanInProcess;
-	bool			*pbPowerSaving;
-	/*  CCA Path 2-path/path-A/path-B = 0/1/2; using enum odm_cca_path. */
-	u8			*pOnePathCCA;
-	/* pMgntInfo->AntennaTest */
-	u8			*pAntennaTest;
-	bool			*pbNet_closed;
 /*  POINTER REFERENCE----------- */
 	/*  */
 /* CALL BY VALUE------------- */
@@ -813,16 +745,10 @@
 	/*  ================================================== */
 	/*  */
 
-	/* common */
-	bool			*pbDriverStopped;
-	bool			*pbDriverIsGoingToPnpSetPowerSleep;
-	bool			*pinit_adpt_in_progress;
-
 	/* PSD */
 	bool			bUserAssignLevel;
 	u8			RSSI_BT;			/* come from BT */
 	bool			bPSDinProcess;
-	bool			bDMInitialGainEnable;
 
 	/* for rate adaptive, in fact,  88c/92c fw will handle this */
 	u8			bUseRAMask;
@@ -1005,10 +931,6 @@
 
 
 
-/*  */
-/*  check Sta pointer valid or not */
-/*  */
-#define IS_STA_VALID(pSta)		(pSta)
 /*  20100514 Joseph: Add definition for antenna switching test after link. */
 /*  This indicates two different the steps. */
 /*  In SWAW_STEP_PEAK, driver needs to switch antenna and listen to the signal on the air. */
@@ -1017,6 +939,8 @@
 #define SWAW_STEP_PEAK		0
 #define SWAW_STEP_DETERMINE	1
 
+struct hal_data_8723a;
+
 void ODM_Write_DIG23a(struct dm_odm_t *pDM_Odm,	u8	CurrentIGI);
 void ODM_Write_CCK_CCA_Thres23a(struct dm_odm_t *pDM_Odm, u8	CurCCK_CCAThres);
 
@@ -1026,9 +950,6 @@
 #define dm_RF_Saving	ODM_RF_Saving23a
 void ODM_RF_Saving23a(struct dm_odm_t *pDM_Odm, u8 bForceInNormal);
 
-#define SwAntDivRestAfterLink	ODM_SwAntDivRestAfterLink
-void ODM_SwAntDivRestAfterLink(struct dm_odm_t *pDM_Odm);
-
 #define dm_CheckTXPowerTracking		ODM_TXPowerTrackingCheck23a
 void ODM_TXPowerTrackingCheck23a(struct dm_odm_t *pDM_Odm);
 
@@ -1036,27 +957,21 @@
 		      u8 *pRATRState);
 
 
-#define dm_SWAW_RSSI_Check	ODM_SwAntDivChkPerPktRssi
-void ODM_SwAntDivChkPerPktRssi(struct dm_odm_t *pDM_Odm, u8 StationID,
-			       struct phy_info *pPhyInfo);
-
 u32 ConvertTo_dB23a(u32 Value);
 
 u32 GetPSDData(struct dm_odm_t *pDM_Odm, unsigned int point, u8 initial_gain_psd);
 
 void odm_DIG23abyRSSI_LPS(struct dm_odm_t *pDM_Odm);
 
-u32 ODM_Get_Rate_Bitmap23a(struct dm_odm_t *pDM_Odm, u32 macid, u32 ra_mask, u8 rssi_level);
+u32 ODM_Get_Rate_Bitmap23a(struct hal_data_8723a *pHalData, u32 macid, u32 ra_mask, u8 rssi_level);
 
 
 void ODM23a_DMInit(struct dm_odm_t *pDM_Odm);
 
-void ODM_DMWatchdog23a(struct dm_odm_t *pDM_Odm); /*  For common use in the future */
+void ODM_DMWatchdog23a(struct rtw_adapter *adapter);
 
 void ODM_CmnInfoInit23a(struct dm_odm_t *pDM_Odm, enum odm_cmninfo	CmnInfo, u32 Value);
 
-void ODM23a_CmnInfoHook(struct dm_odm_t *pDM_Odm, enum odm_cmninfo	CmnInfo, void *pValue);
-
 void ODM_CmnInfoPtrArrayHook23a(struct dm_odm_t *pDM_Odm, enum odm_cmninfo	CmnInfo, u16 Index, void *pValue);
 
 void ODM_CmnInfoUpdate23a(struct dm_odm_t *pDM_Odm, u32 CmnInfo, u64 Value);
diff --git a/drivers/staging/rtl8723au/include/odm_RegDefine11AC.h b/drivers/staging/rtl8723au/include/odm_RegDefine11AC.h
deleted file mode 100644
index 77b7acec..0000000
--- a/drivers/staging/rtl8723au/include/odm_RegDefine11AC.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/******************************************************************************
- *
- * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * 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.
- *
- ******************************************************************************/
-
-#ifndef	__ODM_REGDEFINE11AC_H__
-#define __ODM_REGDEFINE11AC_H__
-
-/* 2 RF REG LIST */
-
-
-
-/* 2 BB REG LIST */
-/* PAGE 8 */
-/* PAGE 9 */
-#define	ODM_REG_OFDM_FA_RST_11AC		0x9A4
-/* PAGE A */
-#define	ODM_REG_CCK_CCA_11AC				0xA0A
-#define	ODM_REG_CCK_FA_RST_11AC			0xA2C
-#define	ODM_REG_CCK_FA_11AC				0xA5C
-/* PAGE C */
-#define	ODM_REG_IGI_A_11AC				0xC50
-/* PAGE E */
-#define	ODM_REG_IGI_B_11AC				0xE50
-/* PAGE F */
-#define	ODM_REG_OFDM_FA_11AC			0xF48
-
-
-/* 2 MAC REG LIST */
-
-
-
-
-/* DIG Related */
-#define	ODM_BIT_IGI_11AC				0xFFFFFFFF
-
-
-
-#endif
diff --git a/drivers/staging/rtl8723au/include/odm_interface.h b/drivers/staging/rtl8723au/include/odm_interface.h
index c260d6b..ea35070 100644
--- a/drivers/staging/rtl8723au/include/odm_interface.h
+++ b/drivers/staging/rtl8723au/include/odm_interface.h
@@ -33,17 +33,16 @@
 #define _bit_11N(_name)			ODM_BIT_##_name##_11N
 #define _bit_11AC(_name)		ODM_BIT_##_name##_11AC
 
-#define _cat(_name, _ic_type, _func)									\
-	(															\
-		((_ic_type) & ODM_IC_11N_SERIES)? _func##_11N(_name):		\
-		_func##_11AC(_name)									\
+#define _cat(_name, _func)					\
+	(							\
+		_func##_11N(_name)				\
 	)
 
 /*  _name: name of register or bit. */
 /*  Example: "ODM_REG(R_A_AGC_CORE1, pDM_Odm)" */
 /*         gets "ODM_R_A_AGC_CORE1" or "ODM_R_A_AGC_CORE1_8192C", depends on SupportICType. */
-#define ODM_REG(_name, _pDM_Odm)	_cat(_name, _pDM_Odm->SupportICType, _reg)
-#define ODM_BIT(_name, _pDM_Odm)	_cat(_name, _pDM_Odm->SupportICType, _bit)
+#define ODM_REG(_name, _pDM_Odm)	_cat(_name, _reg)
+#define ODM_BIT(_name, _pDM_Odm)	_cat(_name, _bit)
 
 /*  */
 /*  2012/02/17 MH For non-MP compile pass only. Linux does not support workitem. */
diff --git a/drivers/staging/rtl8723au/include/odm_precomp.h b/drivers/staging/rtl8723au/include/odm_precomp.h
index 69de888..fb793c8 100644
--- a/drivers/staging/rtl8723au/include/odm_precomp.h
+++ b/drivers/staging/rtl8723au/include/odm_precomp.h
@@ -32,7 +32,6 @@
 #include "odm.h"
 #include "odm_HWConfig.h"
 #include "odm_debug.h"
-#include "odm_RegDefine11AC.h"
 #include "odm_RegDefine11N.h"
 
 #include "HalDMOutSrc8723A.h" /* for IQK,LCK,Power-tracking */
diff --git a/drivers/staging/rtl8723au/include/rtl8723a_dm.h b/drivers/staging/rtl8723au/include/rtl8723a_dm.h
index ccac672..1811222 100644
--- a/drivers/staging/rtl8723au/include/rtl8723a_dm.h
+++ b/drivers/staging/rtl8723au/include/rtl8723a_dm.h
@@ -39,9 +39,6 @@
 /*  duplicate code,will move to ODM ######### */
 struct dm_priv
 {
-	u8	DM_Type;
-	u8	DMFlag;
-	u8	InitDMFlag;
 	u32	InitODMFlag;
 
 	/*  Upper and Lower Signal threshold for Rate Adaptive*/
@@ -134,7 +131,6 @@
 /*  */
 
 void rtl8723a_init_dm_priv(struct rtw_adapter *padapter);
-void rtl8723a_deinit_dm_priv(struct rtw_adapter *padapter);
 
 void rtl8723a_InitHalDm(struct rtw_adapter *padapter);
 void rtl8723a_HalDmWatchDog(struct rtw_adapter *padapter);
diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h
index 344b708..3b0b06d 100644
--- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h
+++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h
@@ -315,7 +315,6 @@
 	u8	framesync;
 	u32	framesyncC34;
 	u8	framesyncMonitor;
-	u8	DefaultInitialGain[4];
 	u8	pwrGroupCnt;
 	u32	MCSTxPowerLevelOriginalOffset[7][16];
 	u32	CCKTxPowerLevelOriginalOffset;
@@ -356,7 +355,6 @@
 	u8	fw_ractrl;
 	u8	RegTxPause;
 	/*  Beacon function related global variable. */
-	u32	RegBcnCtrlVal;
 	u8	RegFwHwTxQCtrl;
 	u8	RegReg542;
 
@@ -384,9 +382,6 @@
 	u8	OutEpQueueSel;
 	u8	OutEpNumber;
 
-	/*  2010/12/10 MH Add for USB aggreation mode dynamic shceme. */
-	bool		UsbRxHighSpeedMode;
-
 	/*  2010/11/22 MH Add for slim combo debug mode selective. */
 	/*  This is used for fix the drawback of CU TSMC-A/UMC-A cut. HW auto suspend ability. Close BT clock. */
 	bool		SlimComboDbg;
diff --git a/drivers/staging/rtl8723au/include/rtl8723a_spec.h b/drivers/staging/rtl8723au/include/rtl8723a_spec.h
index b5d7123..59b545b 100644
--- a/drivers/staging/rtl8723au/include/rtl8723a_spec.h
+++ b/drivers/staging/rtl8723au/include/rtl8723a_spec.h
@@ -454,8 +454,6 @@
 /*  */
 /*  9. Security Control Registers	(Offset: ) */
 /*  */
-	/* IN 8190 Data Sheet is called CAMcmd */
-#define	RWCAM				REG_CAMCMD
 	/*  Software write CAM input content */
 #define	WCAMI				REG_CAMWRITE
 	/*  Software read/write CAM config */
@@ -1323,14 +1321,6 @@
 #define ENSWBCN				BIT(8)
 #define ENSEC				BIT(9)
 
-/*  Network type */
-#define _NETTYPE(x)			(((x) & 0x3) << 16)
-#define MASK_NETTYPE			0x30000
-#define NT_NO_LINK			0x0
-#define NT_LINK_AD_HOC			0x1
-#define NT_LINK_AP			0x2
-#define NT_AS_AP			0x3
-
 #define _LBMODE(x)			(((x) & 0xF) << 24)
 #define MASK_LBMODE			0xF000000
 #define LOOPBACK_NORMAL			0x0
diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h
index 7fd249f..2e32c83 100644
--- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h
@@ -282,16 +282,6 @@
 	struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
 };
 
-/* define AP_MODE				0x0C */
-/* define STATION_MODE	0x08 */
-/* define AD_HOC_MODE		0x04 */
-/* define NO_LINK_MODE	0x00 */
-
-#define		WIFI_FW_NULL_STATE			_HW_STATE_NOLINK_
-#define	WIFI_FW_STATION_STATE		_HW_STATE_STATION_
-#define	WIFI_FW_AP_STATE				_HW_STATE_AP_
-#define	WIFI_FW_ADHOC_STATE			_HW_STATE_ADHOC_
-
 #define	WIFI_FW_AUTH_NULL			0x00000100
 #define	WIFI_FW_AUTH_STATE			0x00000200
 #define	WIFI_FW_AUTH_SUCCESS			0x00000400
@@ -471,8 +461,6 @@
 void UpdateBrateTbl23a(struct rtw_adapter *padapter,u8 *mBratesOS);
 void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen);
 
-void Set_MSR23a(struct rtw_adapter *padapter, u8 type);
-
 u8 rtw_get_oper_ch23a(struct rtw_adapter *adapter);
 void rtw_set_oper_ch23a(struct rtw_adapter *adapter, u8 ch);
 u8 rtw_get_oper_bw23a(struct rtw_adapter *adapter);
diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c
index d72305d..b34eaec 100644
--- a/drivers/staging/rtl8723au/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c
@@ -557,8 +557,6 @@
 		 ("%s:cancel set_scan_deny_timer!\n", __func__));
 
 	del_timer_sync(&padapter->recvpriv.signal_stat_timer);
-	/* cancel dm timer */
-	rtl8723a_deinit_dm_priv(padapter);
 }
 
 int rtw_free_drv_sw23a(struct rtw_adapter *padapter)
@@ -668,7 +666,7 @@
 		padapter->bSurpriseRemoved = false;
 		padapter->bCardDisableWOHSM = false;
 
-		status = rtw_hal_init23a(padapter);
+		status = rtl8723au_hal_init(padapter);
 		if (status == _FAIL) {
 			RT_TRACE(_module_os_intfs_c_, _drv_err_,
 				 ("rtl871x_hal_init(): Can't init h/w!\n"));
@@ -737,7 +735,7 @@
 	padapter->bSurpriseRemoved = false;
 	padapter->bCardDisableWOHSM = false;
 
-	status = rtw_hal_init23a(padapter);
+	status = rtl8723au_hal_init(padapter);
 	if (status == _FAIL) {
 		RT_TRACE(_module_os_intfs_c_, _drv_err_,
 			 ("ips_netdrv_open(): Can't init h/w!\n"));
@@ -802,7 +800,7 @@
 
 	/* s5. */
 	if (!padapter->bSurpriseRemoved)
-		rtw_hal_deinit23a(padapter);
+		rtl8723au_hal_deinit(padapter);
 }
 
 int pm_netdev_open23a(struct net_device *pnetdev, u8 bnormal)
diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c
index ec90216..06c885f 100644
--- a/drivers/staging/rtl8723au/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c
@@ -303,7 +303,7 @@
 
 		/* s5. */
 		if (!padapter->bSurpriseRemoved) {
-			rtw_hal_deinit23a(padapter);
+			rtl8723au_hal_deinit(padapter);
 			padapter->bSurpriseRemoved = true;
 		}
 		padapter->bup = false;
@@ -488,15 +488,6 @@
 {
 	struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
 	struct rtw_adapter *padapter = dvobj->if1;
-	int ret;
-
-	ret = rtw_resume_process23a(padapter);
-
-	return ret;
-}
-
-int rtw_resume_process23a(struct rtw_adapter *padapter)
-{
 	struct net_device *pnetdev;
 	struct pwrctrl_priv *pwrpriv = NULL;
 	int ret = -1;
@@ -514,8 +505,10 @@
 	pwrpriv->bkeepfwalive = false;
 
 	DBG_8723A("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive);
-	if (pm_netdev_open23a(pnetdev, true) != 0)
+	if (pm_netdev_open23a(pnetdev, true) != 0) {
+		up(&pwrpriv->lock);
 		goto exit;
+	}
 
 	netif_device_attach(pnetdev);
 	netif_carrier_on(pnetdev);
diff --git a/drivers/staging/rtl8821ae/cam.c b/drivers/staging/rtl8821ae/cam.c
index 3bc6b3d..6185ea4 100644
--- a/drivers/staging/rtl8821ae/cam.c
+++ b/drivers/staging/rtl8821ae/cam.c
@@ -152,7 +152,6 @@
 	return 1;
 
 }
-//EXPORT_SYMBOL(rtl_cam_add_one_entry);
 
 int rtl_cam_delete_one_entry(struct ieee80211_hw *hw,
 			     u8 *mac_addr, u32 ul_key_id)
@@ -176,7 +175,6 @@
 	return 0;
 
 }
-//EXPORT_SYMBOL(rtl_cam_delete_one_entry);
 
 void rtl_cam_reset_all_entry(struct ieee80211_hw *hw)
 {
@@ -186,7 +184,6 @@
 	ul_command = BIT(31) | BIT(30);
 	rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[RWCAM], ul_command);
 }
-//EXPORT_SYMBOL(rtl_cam_reset_all_entry);
 
 void rtl_cam_mark_invalid(struct ieee80211_hw *hw, u8 uc_index)
 {
@@ -227,7 +224,6 @@
 	RT_TRACE(COMP_SEC, DBG_DMESG,
 		 ("rtl_cam_mark_invalid(): WRITE A0: %x \n", ul_command));
 }
-//EXPORT_SYMBOL(rtl_cam_mark_invalid);
 
 void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index)
 {
@@ -281,7 +277,6 @@
 	}
 
 }
-//EXPORT_SYMBOL(rtl_cam_empty_entry);
 
 u8 rtl_cam_get_free_entry(struct ieee80211_hw *hw, u8 *sta_addr)
 {
@@ -316,7 +311,6 @@
 	}
 	return TOTAL_CAM_ENTRY;
 }
-//EXPORT_SYMBOL(rtl_cam_get_free_entry);
 
 void rtl_cam_del_entry(struct ieee80211_hw *hw, u8 *sta_addr)
 {
@@ -349,4 +343,3 @@
 	}
 	return;
 }
-//EXPORT_SYMBOL(rtl_cam_del_entry);
diff --git a/drivers/staging/sep/sep_main.c b/drivers/staging/sep/sep_main.c
index 75ca15e..85fea5f 100644
--- a/drivers/staging/sep/sep_main.c
+++ b/drivers/staging/sep/sep_main.c
@@ -130,7 +130,6 @@
 
 	dev_dbg(&sep->pdev->dev, "[PID%d] sep_queue_status_remove return\n",
 		current->pid);
-	return;
 }
 
 /**
@@ -493,7 +492,6 @@
 		 * memory is not available to the o/s at all.
 		 */
 		if (!(*dma_ctx)->secure_dma && dma->out_map_array) {
-
 			for (count = 0; count < dma->out_num_pages; count++) {
 				dma_unmap_page(&sep->pdev->dev,
 					dma->out_map_array[count].dma_addr,
@@ -514,7 +512,6 @@
 
 		/* Again, we do this only for non secure dma */
 		if (!(*dma_ctx)->secure_dma && dma->out_page_array) {
-
 			for (count = 0; count < dma->out_num_pages; count++) {
 				if (!PageReserved(dma->out_page_array[count]))
 
@@ -634,7 +631,6 @@
 	return 0;
 }
 
-
 /**
  * sep_release - close a SEP device
  * @inode: inode of SEP device
@@ -767,7 +763,6 @@
 		goto end_function;
 	}
 
-
 	/* Add the event to the polling wait table */
 	dev_dbg(&sep->pdev->dev, "[PID%d] poll: calling wait sep_event\n",
 					current->pid);
@@ -857,7 +852,6 @@
 	struct timeval time;
 	u32 *time_addr;	/* Address of time as seen by the kernel */
 
-
 	do_gettimeofday(&time);
 
 	/* Set value in the SYSTEM MEMORY offset */
@@ -906,7 +900,6 @@
 	msg_pool += 1;
 	if ((*msg_pool < 2) ||
 		(*msg_pool > SEP_DRIVER_MAX_MESSAGE_SIZE_IN_BYTES)) {
-
 		dev_warn(&sep->pdev->dev, "invalid message size\n");
 		error = -EPROTO;
 		goto end_function;
@@ -1024,7 +1017,6 @@
 
 	*dma_maps = sep_dma;
 	return count_mapped;
-
 }
 
 /**
@@ -1054,7 +1046,6 @@
 	u32 data_size,
 	enum dma_data_direction direction)
 {
-
 	int ct1;
 	struct sep_lli_entry *sep_lli;
 	struct sep_dma_map *sep_map;
@@ -1318,7 +1309,6 @@
 			(unsigned long)lli_array[0].bus_address,
 			lli_array[0].block_size);
 
-
 	/* Check the size of the last page */
 	if (num_pages > 1) {
 		lli_array[num_pages - 1].block_size =
@@ -1663,7 +1653,6 @@
 
 	/* Set the output parameter */
 	*num_processed_entries_ptr += array_counter;
-
 }
 
 /**
@@ -1736,7 +1725,7 @@
 		return;
 	}
 
-	while ((unsigned long) lli_table_ptr->bus_address != 0xffffffff) {
+	while ((unsigned long)lli_table_ptr->bus_address != 0xffffffff) {
 		dev_dbg(&sep->pdev->dev,
 			"[PID%d] lli table %08lx, table_data_size is (hex) %lx\n",
 			current->pid, table_count, table_data_size);
@@ -1747,11 +1736,10 @@
 		/* Print entries of the table (without info entry) */
 		for (entries_count = 0; entries_count < num_table_entries;
 			entries_count++, lli_table_ptr++) {
-
 			dev_dbg(&sep->pdev->dev,
 				"[PID%d] lli_table_ptr address is %08lx\n",
 				current->pid,
-				(unsigned long) lli_table_ptr);
+				(unsigned long)lli_table_ptr);
 
 			dev_dbg(&sep->pdev->dev,
 				"[PID%d] phys address is %08lx block size is (hex) %x\n",
@@ -1773,7 +1761,6 @@
 			current->pid,
 			(unsigned long)lli_table_ptr->bus_address);
 
-
 		table_data_size = lli_table_ptr->block_size & 0xffffff;
 		num_table_entries = (lli_table_ptr->block_size >> 24) & 0xff;
 
@@ -1796,7 +1783,6 @@
 #endif
 }
 
-
 /**
  * sep_prepare_empty_lli_table - create a blank LLI table
  * @sep: pointer to struct sep_device
@@ -1972,7 +1958,6 @@
 
 	/* Loop till all the entries in in array are processed */
 	while (current_entry < sep_lli_entries) {
-
 		/* Set the new input and output tables */
 		in_lli_table_ptr =
 			(struct sep_lli_entry *)lli_table_alloc_addr;
@@ -1988,10 +1973,8 @@
 			((void *)sep->shared_addr +
 			SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
 			SYNCHRONIC_DMA_TABLES_AREA_SIZE_BYTES)) {
-
 			error = -ENOMEM;
 			goto end_function_error;
-
 		}
 
 		/* Update the number of created tables */
@@ -2022,7 +2005,6 @@
 			&current_entry, &num_entries_in_table, table_data_size);
 
 		if (info_entry_ptr == NULL) {
-
 			/* Set the output parameters to physical addresses */
 			*lli_table_ptr = sep_shared_area_virt_to_bus(sep,
 				dma_in_lli_table_ptr);
@@ -2071,7 +2053,6 @@
 
 end_function:
 	return error;
-
 }
 
 /**
@@ -2193,7 +2174,6 @@
 			((void *)sep->shared_addr +
 			SYNCHRONIC_DMA_TABLES_AREA_OFFSET_BYTES +
 			SYNCHRONIC_DMA_TABLES_AREA_SIZE_BYTES)) {
-
 			dev_warn(&sep->pdev->dev, "dma table limit overrun\n");
 			return -ENOMEM;
 		}
@@ -2450,10 +2430,7 @@
 
 			goto end_function_free_lli_in;
 		}
-
-	}
-
-	else {
+	} else {
 		dev_dbg(&sep->pdev->dev, "[PID%d] Locking user input pages\n",
 						current->pid);
 		error = sep_lock_user_pages(sep, app_virt_in_addr,
@@ -2554,7 +2531,6 @@
 	dma_ctx->dma_res_arr[dma_ctx->nr_dcb_creat].out_page_array = NULL;
 	kfree(lli_out_array);
 
-
 end_function_free_lli_in:
 	kfree(dma_ctx->dma_res_arr[dma_ctx->nr_dcb_creat].in_map_array);
 	dma_ctx->dma_res_arr[dma_ctx->nr_dcb_creat].in_map_array = NULL;
@@ -2563,9 +2539,7 @@
 	kfree(lli_in_array);
 
 end_function:
-
 	return error;
-
 }
 
 /**
@@ -2703,7 +2677,6 @@
 	dcb_table_ptr->out_vr_tail_pt = 0;
 
 	if (isapplet) {
-
 		/* Check if there is enough data for DMA operation */
 		if (data_in_size < SEP_DRIVER_MIN_DATA_SIZE_PER_TABLE) {
 			if (is_kva) {
@@ -2829,10 +2802,8 @@
 
 end_function:
 	return error;
-
 }
 
-
 /**
  * sep_free_dma_tables_and_dcb - free DMA tables and DCBs
  * @sep: pointer to struct sep_device
@@ -2880,12 +2851,11 @@
 				if (is_kva) {
 					error = -ENODEV;
 					break;
-				} else {
-					error_temp = copy_to_user(
+				}
+				error_temp = copy_to_user(
 						(void __user *)tail_pt,
 						dcb_table_ptr->tail_data,
 						dcb_table_ptr->tail_data_size);
-				}
 				if (error_temp) {
 					/* Release the DMA resource */
 					error = -EFAULT;
@@ -2964,7 +2934,6 @@
 
 end_function:
 	return error;
-
 }
 
 /**
@@ -3168,7 +3137,6 @@
 	dev_dbg(&sep->pdev->dev, "sep int: IRR REG val: %x\n", reg_val);
 
 	if (reg_val & (0x1 << 13)) {
-
 		/* Lock and update the counter of reply messages */
 		spin_lock_irqsave(&sep->snd_rply_lck, lock_irq_flag);
 		sep->reply_ct++;
@@ -3245,8 +3213,9 @@
 		dev_warn(&sep->pdev->dev, "could not reconfig shared area\n");
 		dev_warn(&sep->pdev->dev, "result was %x\n", ret_val);
 		ret_val = -ENOMEM;
-	} else
+	} else {
 		ret_val = 0;
+	}
 
 	dev_dbg(&sep->pdev->dev, "reconfig shared area end\n");
 
@@ -3433,7 +3402,6 @@
 end_function:
 	kfree(dcb_args);
 	return error;
-
 }
 
 /**
@@ -3512,7 +3480,6 @@
 
 end_function:
 	return error;
-
 }
 
 /**
@@ -3591,7 +3558,6 @@
 	return error;
 }
 
-
 /**
  *	sep_read - Returns results of an operation for fastcall interface
  *	@filp: File pointer
@@ -3639,7 +3605,6 @@
 		goto end_function_error;
 	}
 
-
 	/* Wait for SEP to finish */
 	wait_event(sep->event_interrupt,
 		   test_bit(SEP_WORKING_LOCK_BIT,
@@ -3712,7 +3677,6 @@
 		goto end_function;
 	}
 
-
 	if (copy_from_user(args, buf_user, sizeof(struct sep_fastcall_hdr))) {
 		error = -EFAULT;
 		goto end_function;
@@ -3814,7 +3778,6 @@
 		goto end_function_error;
 	}
 
-
 	/*
 	 * Prepare contents of the shared area regions for
 	 * the operation into temporary buffers
@@ -3924,6 +3887,7 @@
 
 	return error;
 }
+
 /**
  *	sep_seek - Handler for seek system call
  *	@filp: File pointer
@@ -3938,8 +3902,6 @@
 	return -ENOSYS;
 }
 
-
-
 /**
  * sep_file_operations - file operation on sep device
  * @sep_ioctl:	ioctl handler from user space call
@@ -3992,7 +3954,6 @@
 	if (queue_num > SEP_DOUBLEBUF_USERS_LIMIT)
 		queue_num = SEP_DOUBLEBUF_USERS_LIMIT;
 
-
 	if (count < sizeof(queue_num)
 			+ (queue_num * sizeof(struct sep_queue_data))) {
 		spin_unlock_irqrestore(&sep->sep_queue_lock, lck_flags);
@@ -4062,7 +4023,6 @@
 	return ret_val;
 }
 
-
 /**
  *sep_probe - probe a matching PCI device
  *@pdev:	pci_device
@@ -4353,7 +4313,6 @@
  */
 static int sep_pm_runtime_resume(struct device *dev)
 {
-
 	u32 retval2;
 	u32 delay_count;
 	struct sep_device *sep = sep_dev;
diff --git a/drivers/staging/speakup/TODO b/drivers/staging/speakup/TODO
index c3612e4..3094799 100644
--- a/drivers/staging/speakup/TODO
+++ b/drivers/staging/speakup/TODO
@@ -1,6 +1,6 @@
 Speakup project home:  http://www.linux-speakup.org
 
-Mailing List:  speakup@braille.uwo.ca
+Mailing List:  speakup@linux-speakup.org
 
 Speakup is a kernel based screen review package for the linux operating
 system.  It allows blind users to interact with applications on the
diff --git a/drivers/staging/tidspbridge/Documentation/CONTRIBUTORS b/drivers/staging/tidspbridge/Documentation/CONTRIBUTORS
deleted file mode 100644
index 86f5787..0000000
--- a/drivers/staging/tidspbridge/Documentation/CONTRIBUTORS
+++ /dev/null
@@ -1,45 +0,0 @@
-TI DSP/Bridge Driver - Contributors File
-
-The DSP/Bridge project wish to thank all of its contributors, current bridge
-driver is the result of the work of all of them. If any name is accidentally
-omitted, let us know by sending a mail to omar.ramirez@ti.com or
-x095840@ti.com.
-
-Please keep the following list in alphabetical order.
-
-	Suman Anna
-	Sripal Bagadia
-	Felipe Balbi
-	Ohad Ben-Cohen
-	Phil Carmody
-	Deepak Chitriki
-	Felipe Contreras
-	Hiroshi Doyu
-	Seth Forshee
-	Ivan Gomez Castellanos
-	Mark Grosen
-	Ramesh Gupta G
-	Fernando Guzman Lugo
-	Axel Haslam
-	Janet Head
-	Shivananda Hebbar
-	Hari Kanigeri
-	Tony Lindgren
-	Antonio Luna
-	Hari Nagalla
-	Nishanth Menon
-	Ameya Palande
-	Vijay Pasam
-	Gilbert Pitney
-	Omar Ramirez Luna
-	Ernesto Ramos
-	Chris Ring
-	Larry Schiefer
-	Rebecca Schultz Zavin
-	Bhavin Shah
-	Andy Shevchenko
-	Jeff Taylor
-	Roman Tereshonkov
-	Armando Uribe de Leon
-	Nischal Varide
-	Wenbiao Wang
diff --git a/drivers/staging/tidspbridge/Documentation/README b/drivers/staging/tidspbridge/Documentation/README
deleted file mode 100644
index df6d371..0000000
--- a/drivers/staging/tidspbridge/Documentation/README
+++ /dev/null
@@ -1,70 +0,0 @@
-                        Linux DSP/BIOS Bridge release
-
-DSP/BIOS Bridge overview
-========================
-
-DSP/BIOS Bridge is designed for platforms that contain a GPP and one or more
-attached DSPs.  The GPP is considered the master or "host" processor, and the
-attached DSPs are processing resources that can be utilized by applications
-and drivers running on the GPP.
-
-The abstraction that DSP/BIOS Bridge supplies, is a direct link between a GPP
-program and a DSP task.  This communication link is partitioned into two
-types of sub-links:  messaging (short, fixed-length packets) and data
-streaming (multiple, large buffers).  Each sub-link operates independently,
-and features in-order delivery of data, meaning that messages are delivered
-in the order they were submitted to the message link, and stream buffers are
-delivered in the order they were submitted to the stream link.
-
-In addition, a GPP client can specify what inputs and outputs a DSP task
-uses. DSP tasks typically use message objects for passing control and status
-information and stream objects for efficient streaming of real-time data.
-
-GPP Software Architecture
-=========================
-
-A GPP application communicates with its associated DSP task running on the
-DSP subsystem using the DSP/BIOS Bridge API. For example, a GPP audio
-application can use the API to pass messages to a DSP task that is managing
-data flowing from analog-to-digital converters (ADCs) to digital-to-analog
-converters (DACs).
-
-From the perspective of the GPP OS, the DSP is treated as just another
-peripheral device.   Most high level GPP OS typically support a device driver
-model, whereby applications can safely access and share a hardware peripheral
-through standard driver interfaces.  Therefore, to allow multiple GPP
-applications to share access to the DSP, the GPP side of DSP/BIOS Bridge
-implements a device driver for the DSP.
-
-Since driver interfaces are not always standard across GPP OS, and to provide
-some level of interoperability of application code using DSP/BIOS Bridge
-between GPP OS, DSP/BIOS Bridge provides a standard library of APIs which
-wrap calls into the device driver.   So, rather than calling GPP OS specific
-driver interfaces, applications (and even other device drivers) can use the
-standard API library directly.
-
-DSP Software Architecture
-=========================
-
-For DSP/BIOS, DSP/BIOS Bridge adds a device-independent streaming I/O (STRM)
-interface, a messaging interface (NODE), and a Resource Manager (RM) Server.
-The RM Server runs as a task of DSP/BIOS and is subservient to commands
-and queries from the GPP.  It executes commands to start and stop DSP signal
-processing nodes in response to GPP programs making requests through the
-(GPP-side) API.
-
-DSP tasks started by the RM Server are similar to any other DSP task with two
-important differences:  they must follow a specific task model consisting of
-three C-callable functions (node create, execute, and delete), with specific
-sets of arguments, and they have a pre-defined task environment established
-by the RM Server.
-
-Tasks started by the RM Server communicate using the STRM and NODE interfaces
-and act as servers for their corresponding GPP clients, performing signal
-processing functions as requested by messages sent by their GPP client.
-Typically, a DSP task moves data from source devices to sink devices using
-device independent I/O streams, performing application-specific processing
-and transformations on the data while it is moved.  For example, an audio
-task might perform audio decompression (ADPCM, MPEG, CELP) on data received
-from a GPP audio driver and then send the decompressed linear samples to a
-digital-to-analog converter.
diff --git a/drivers/staging/tidspbridge/Documentation/error-codes b/drivers/staging/tidspbridge/Documentation/error-codes
deleted file mode 100644
index ad73cba..0000000
--- a/drivers/staging/tidspbridge/Documentation/error-codes
+++ /dev/null
@@ -1,157 +0,0 @@
-			DSP/Bridge Error Code Guide
-
-
-Success code is always taken as 0, except for one case where a success status
-different than 0 can be possible, this is when enumerating a series of dsp
-objects, if the enumeration doesn't have any more objects it is considered as a
-successful case. In this case a positive ENODATA is returned (TODO: Change to
-avoid this case).
-
-Error codes are returned as a negative 1, if an specific code is expected, it
-can be propagated to user space by reading errno symbol defined in errno.h, for
-specific details on the implementation a copy of the standard used should be
-read first.
-
-The error codes used by this driver are:
-
-[EPERM]
-    General driver failure.
-
-    According to the use case the following might apply:
-    - Device is in 'sleep/suspend' mode due to DPM.
-    - User cannot mark end of stream on an input channel.
-    - Requested operation is invalid for the node type.
-    - Invalid alignment for the node messaging buffer.
-    - The specified direction is invalid for the stream.
-    - Invalid stream mode.
-
-[ENOENT]
-    The specified object or file was not found.
-
-[ESRCH]
-    A shared memory buffer contained in a message or stream could not be mapped
-    to the GPP client process's virtual space.
-
-[EIO]
-    Driver interface I/O error.
-
-    or:
-    - Unable to plug channel ISR for configured IRQ.
-    - No free I/O request packets are available.
-
-[ENXIO]
-    Unable to find a named section in DSP executable or a non-existent memory
-    segment identifier was specified.
-
-[EBADF]
-    General error for file handling:
-
-    - Unable to open file.
-    - Unable to read file.
-    - An error occurred while parsing the DSP executable file.
-
-[ENOMEM]
-    A memory allocation failure occurred.
-
-[EACCES]
-    - Unable to read content of DCD data section; this is typically caused by
-    improperly configured nodes.
-    - Unable to decode DCD data section content; this is typically caused by
-    changes to DSP/BIOS Bridge data structures.
-    - Unable to get pointer to DCD data section; this is typically caused by
-    improperly configured UUIDs.
-    - Unable to load file containing DCD data section; this is typically
-    caused by a missing COFF file.
-    - The specified COFF file does not contain a valid node registration
-    section.
-
-[EFAULT]
-    Invalid pointer or handler.
-
-[EEXIST]
-    Attempted to create a channel manager when one already exists.
-
-[EINVAL]
-    Invalid argument.
-
-[ESPIPE]
-    Symbol not found in the COFF file.  DSPNode_Create will return this if
-    the iAlg function table for an xDAIS socket is not found in the COFF file.
-    In this case, force the symbol to be linked into the COFF file.
-    DSPNode_Create, DSPNode_Execute, and DSPNode_Delete will return this if
-    the create, execute, or delete phase function, respectively, could not be
-    found in the COFF file.
-
-    - No symbol table is loaded/found for this board.
-    - Unable to initialize the ZL COFF parsing module.
-
-[EPIPE]
-    I/O is currently pending.
-
-    - End of stream was already requested on this output channel.
-
-[EDOM]
-    A parameter is specified outside its valid range.
-
-[ENOSYS]
-    The indicated operation is not supported.
-
-[EIDRM]
-    During enumeration a change in the number or properties of the objects
-    has occurred.
-
-[ECHRNG]
-    Attempt to created channel manager with too many channels or channel ID out
-    of range.
-
-[EBADR]
-    The state of the specified object is incorrect for the requested operation.
-
-    - Invalid segment ID.
-
-[ENODATA]
-    Unable to retrieve resource information from the registry.
-
-    - No more registry values.
-
-[ETIME]
-    A timeout occurred before the requested operation could complete.
-
-[ENOSR]
-    A stream has been issued the maximum number of buffers allowed in the
-    stream at once; buffers must be reclaimed from the stream before any more
-    can be issued.
-
-    - No free channels are available.
-
-[EILSEQ]
-    Error occurred in a dynamic loader library function.
-
-[EISCONN]
-    The Specified Connection already exists.
-
-[ENOTCONN]
-    Nodes not connected.
-
-[ETIMEDOUT]
-    Timeout occurred waiting for a response from the hardware.
-
-    - Wait for flush operation on an output channel timed out.
-
-[ECONNREFUSED]
-    No more connections can be made for this node.
-
-[EALREADY]
-    Channel is already in use.
-
-[EREMOTEIO]
-    dwTimeOut parameter was CHNL_IOCNOWAIT, yet no I/O completions were
-    queued.
-
-[ECANCELED]
-    I/O has been cancelled on this channel.
-
-[ENOKEY]
-    Invalid subkey parameter.
-
-    - UUID not found in registry.
diff --git a/drivers/staging/tidspbridge/Kconfig b/drivers/staging/tidspbridge/Kconfig
deleted file mode 100644
index b5e74e9..0000000
--- a/drivers/staging/tidspbridge/Kconfig
+++ /dev/null
@@ -1,69 +0,0 @@
-#
-# DSP Bridge Driver Support
-#
-
-menuconfig TIDSPBRIDGE
-	tristate "DSP Bridge driver"
-	depends on ARCH_OMAP3 && !ARCH_MULTIPLATFORM && BROKEN
-	select MAILBOX
-	select OMAP2PLUS_MBOX
-	help
-	  DSP/BIOS Bridge is designed for platforms that contain a GPP and
-	  one or more attached DSPs.  The GPP is considered the master or
-	  "host" processor, and the attached DSPs are processing resources
-	  that can be utilized by applications and drivers running on the GPP.
-
-	  This driver depends on OMAP Mailbox (OMAP_MBOX_FWK).
-
-config TIDSPBRIDGE_DVFS
-	bool "Enable Bridge Dynamic Voltage and Frequency Scaling (DVFS)"
-	depends on TIDSPBRIDGE && CPU_FREQ
-	help
-	  DVFS allows DSP Bridge to initiate the operating point change to
-	  scale the chip voltage and frequency in order to match the
-	  performance and power consumption to the current processing
-	  requirements.
-
-config TIDSPBRIDGE_MEMPOOL_SIZE
-	hex "Physical memory pool size (Byte)"
-	depends on TIDSPBRIDGE
-	default 0x600000
-	help
-	  Allocate specified size of memory at booting time to avoid allocation
-	  failure under heavy memory fragmentation after some use time.
-
-config TIDSPBRIDGE_RECOVERY
-	bool "Recovery Support"
-	depends on TIDSPBRIDGE
-	default y
-	help
-	  In case of DSP fatal error, BRIDGE driver will try to
-	  recover itself.
-
-config TIDSPBRIDGE_CACHE_LINE_CHECK
-	bool "Check buffers to be 128 byte aligned"
-	depends on TIDSPBRIDGE
-	help
-	  When the DSP processes data, the DSP cache controller loads 128-Byte
-	  chunks (lines) from SDRAM and writes the data back in 128-Byte chunks.
-	  If a DMM buffer does not start and end on a 128-Byte boundary, the data
-	  preceding the start address (SA) from the 128-Byte boundary to the SA
-	  and the data at addresses trailing the end address (EA) from the EA to
-	  the next 128-Byte boundary will be loaded and written back as well.
-	  This can lead to heap corruption. Say Y, to enforce the check for 128
-	  byte alignment, buffers failing this check will be rejected.
-
-config TIDSPBRIDGE_NTFY_PWRERR
-	bool "Notify power errors"
-	depends on TIDSPBRIDGE
-	help
-	  Enable notifications to registered clients on the event of power error
-	  trying to suspend bridge driver. Say Y, to signal this event as a fatal
-	  error, this will require a bridge restart to recover.
-
-config TIDSPBRIDGE_BACKTRACE
-	bool "Dump backtraces on fatal errors"
-	depends on TIDSPBRIDGE
-	help
-	  Enable useful information to backtrace fatal errors. Say Y if you
-	  want to dump information for testing purposes.
diff --git a/drivers/staging/tidspbridge/Makefile b/drivers/staging/tidspbridge/Makefile
deleted file mode 100644
index adb21c5..0000000
--- a/drivers/staging/tidspbridge/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-obj-$(CONFIG_TIDSPBRIDGE)	+= tidspbridge.o
-
-libgen = gen/gh.o
-libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
-		core/tiomap3430_pwr.o core/tiomap_io.o \
-		core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
-libpmgr = pmgr/chnl.o pmgr/io.o pmgr/msg.o pmgr/cod.o pmgr/dev.o pmgr/dspapi.o \
-		pmgr/dmm.o pmgr/cmm.o pmgr/dbll.o
-librmgr = rmgr/dbdcd.o rmgr/disp.o rmgr/drv.o rmgr/mgr.o rmgr/node.o \
-		rmgr/proc.o rmgr/pwr.o rmgr/rmm.o rmgr/strm.o rmgr/dspdrv.o \
-		rmgr/nldr.o rmgr/drv_interface.o
-libdload = dynload/cload.o dynload/getsection.o dynload/reloc.o \
-		 dynload/tramp.o
-libhw = hw/hw_mmu.o
-
-tidspbridge-y := $(libgen) $(libservices) $(libcore) $(libpmgr) $(librmgr) \
-			$(libdload) $(libhw)
-
-#Machine dependent
-ccflags-y += -D_TI_ -D_DB_TIOMAP -DTMS32060 \
-		-DTICFG_PROC_VER -DTICFG_EVM_TYPE -DCHNL_SMCLASS \
-		-DCHNL_MESSAGES -DUSE_LEVEL_1_MACROS
-
-ccflags-y += -Idrivers/staging/tidspbridge/include
-ccflags-y += -Idrivers/staging/tidspbridge/services
-ccflags-y += -Idrivers/staging/tidspbridge/core
-ccflags-y += -Idrivers/staging/tidspbridge/pmgr
-ccflags-y += -Idrivers/staging/tidspbridge/rmgr
-ccflags-y += -Idrivers/staging/tidspbridge/dynload
-ccflags-y += -Idrivers/staging/tidspbridge/hw
-ccflags-y += -Iarch/arm
-
diff --git a/drivers/staging/tidspbridge/TODO b/drivers/staging/tidspbridge/TODO
deleted file mode 100644
index 1c51e2d..0000000
--- a/drivers/staging/tidspbridge/TODO
+++ /dev/null
@@ -1,18 +0,0 @@
-* Migrate to (and if necessary, extend) existing upstream code such as 
-  iommu, wdt, mcbsp, gptimers
-* Decouple hardware-specific code (e.g. bridge_brd_start/stop/delete/monitor)
-* DOFF binary loader: consider pushing to user space. at the very least
-  eliminate the direct filesystem access
-* Eliminate general services and libraries - use or extend existing kernel
-  libraries instead (e.g. gcf/lcm in nldr.c, global helpers in gen/)
-* Eliminate direct manipulation of OMAP_SYSC_BASE
-* Eliminate DSP_SUCCEEDED macros and their imposed redundant indentations
-  (adopt the kernel way of checking for return values)
-* Audit interfaces exposed to user space
-* Audit and clean up header files folder
-* Use kernel coding style
-* checkpatch.pl fixes
-* allocate ext_mem_pool from consistent memory instead of using ioremap
-
-Please send any patches to Greg Kroah-Hartman <greg@kroah.com>
-and Omar Ramirez Luna <omar.ramirez@ti.com>.
diff --git a/drivers/staging/tidspbridge/core/_cmm.h b/drivers/staging/tidspbridge/core/_cmm.h
deleted file mode 100644
index 7660bef..0000000
--- a/drivers/staging/tidspbridge/core/_cmm.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * _cmm.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Private header file defining CMM manager objects and defines needed
- * by IO manager to register shared memory regions when DSP base image
- * is loaded(bridge_io_on_loaded).
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _CMM_
-#define _CMM_
-
-/*
- *  These target side symbols define the beginning and ending addresses
- *  of the section of shared memory used for shared memory manager CMM.
- *  They are defined in the *cfg.cmd file by cdb code.
- */
-#define SHM0_SHARED_BASE_SYM             "_SHM0_BEG"
-#define SHM0_SHARED_END_SYM              "_SHM0_END"
-#define SHM0_SHARED_RESERVED_BASE_SYM    "_SHM0_RSVDSTRT"
-
-/*
- *  Shared Memory Region #0(SHMSEG0) is used in the following way:
- *
- *  |(_SHM0_BEG)                  | (_SHM0_RSVDSTRT)           | (_SHM0_END)
- *  V                             V                            V
- *  ------------------------------------------------------------
- *  |     DSP-side allocations    |    GPP-side allocations    |
- *  ------------------------------------------------------------
- *
- *
- */
-
-#endif /* _CMM_ */
diff --git a/drivers/staging/tidspbridge/core/_deh.h b/drivers/staging/tidspbridge/core/_deh.h
deleted file mode 100644
index 025d343..0000000
--- a/drivers/staging/tidspbridge/core/_deh.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * _deh.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Private header for DEH module.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- * Copyright (C) 2010 Felipe Contreras
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _DEH_
-#define _DEH_
-
-#include <dspbridge/ntfy.h>
-#include <dspbridge/dspdefs.h>
-
-/* DEH Manager: only one created per board: */
-struct deh_mgr {
-	struct bridge_dev_context *bridge_context;	/* Bridge context. */
-	struct ntfy_object *ntfy_obj;	/* NTFY object */
-
-	/* MMU Fault DPC */
-	struct tasklet_struct dpc_tasklet;
-};
-
-#endif /* _DEH_ */
diff --git a/drivers/staging/tidspbridge/core/_msg_sm.h b/drivers/staging/tidspbridge/core/_msg_sm.h
deleted file mode 100644
index f6e58e3..0000000
--- a/drivers/staging/tidspbridge/core/_msg_sm.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * _msg_sm.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Private header file defining msg_ctrl manager objects and defines needed
- * by IO manager.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _MSG_SM_
-#define _MSG_SM_
-
-#include <linux/list.h>
-#include <dspbridge/msgdefs.h>
-
-/*
- *  These target side symbols define the beginning and ending addresses
- *  of the section of shared memory used for messages. They are
- *  defined in the *cfg.cmd file by cdb code.
- */
-#define MSG_SHARED_BUFFER_BASE_SYM      "_MSG_BEG"
-#define MSG_SHARED_BUFFER_LIMIT_SYM     "_MSG_END"
-
-#ifndef _CHNL_WORDSIZE
-#define _CHNL_WORDSIZE 4	/* default _CHNL_WORDSIZE is 2 bytes/word */
-#endif
-
-/*
- *  ======== msg_ctrl ========
- *  There is a control structure for messages to the DSP, and a control
- *  structure for messages from the DSP. The shared memory region for
- *  transferring messages is partitioned as follows:
- *
- *  ----------------------------------------------------------
- *  |Control | Messages from DSP | Control | Messages to DSP |
- *  ----------------------------------------------------------
- *
- *  msg_ctrl control structure for messages to the DSP is used in the following
- *  way:
- *
- *  buf_empty -      This flag is set to FALSE by the GPP after it has output
- *                  messages for the DSP. The DSP host driver sets it to
- *                  TRUE after it has copied the messages.
- *  post_swi -       Set to 1 by the GPP after it has written the messages,
- *                  set the size, and set buf_empty to FALSE.
- *                  The DSP Host driver uses SWI_andn of the post_swi field
- *                  when a host interrupt occurs. The host driver clears
- *                  this after posting the SWI.
- *  size -          Number of messages to be read by the DSP.
- *
- *  For messages from the DSP:
- *  buf_empty -      This flag is set to FALSE by the DSP after it has output
- *                  messages for the GPP. The DPC on the GPP sets it to
- *                  TRUE after it has copied the messages.
- *  post_swi -       Set to 1 the DPC on the GPP after copying the messages.
- *  size -          Number of messages to be read by the GPP.
- */
-struct msg_ctrl {
-	u32 buf_empty;		/* to/from DSP buffer is empty */
-	u32 post_swi;		/* Set to "1" to post msg_ctrl SWI */
-	u32 size;		/* Number of messages to/from the DSP */
-	u32 resvd;
-};
-
-/*
- *  ======== msg_mgr ========
- *  The msg_mgr maintains a list of all MSG_QUEUEs. Each NODE object can
- *  have msg_queue to hold all messages that come up from the corresponding
- *  node on the DSP. The msg_mgr also has a shared queue of messages
- *  ready to go to the DSP.
- */
-struct msg_mgr {
-	/* The first field must match that in msgobj.h */
-
-	/* Function interface to Bridge driver */
-	struct bridge_drv_interface *intf_fxns;
-
-	struct io_mgr *iomgr;		/* IO manager */
-	struct list_head queue_list;	/* List of MSG_QUEUEs */
-	spinlock_t msg_mgr_lock;	/* For critical sections */
-	/* Signalled when MsgFrame is available */
-	struct sync_object *sync_event;
-	struct list_head msg_free_list;	/* Free MsgFrames ready to be filled */
-	struct list_head msg_used_list;	/* MsgFrames ready to go to DSP */
-	u32 msgs_pending;	/* # of queued messages to go to DSP */
-	u32 max_msgs;		/* Max # of msgs that fit in buffer */
-	msg_onexit on_exit;	/* called when RMS_EXIT is received */
-};
-
-/*
- *  ======== msg_queue ========
- *  Each NODE has a msg_queue for receiving messages from the
- *  corresponding node on the DSP. The msg_queue object maintains a list
- *  of messages that have been sent to the host, but not yet read (MSG_Get),
- *  and a list of free frames that can be filled when new messages arrive
- *  from the DSP.
- *  The msg_queue's hSynEvent gets posted when a message is ready.
- */
-struct msg_queue {
-	struct list_head list_elem;
-	struct msg_mgr *msg_mgr;
-	u32 max_msgs;		/* Node message depth */
-	u32 msgq_id;		/* Node environment pointer */
-	struct list_head msg_free_list;	/* Free MsgFrames ready to be filled */
-	/* Filled MsgFramess waiting to be read */
-	struct list_head msg_used_list;
-	void *arg;		/* Handle passed to mgr on_exit callback */
-	struct sync_object *sync_event;	/* Signalled when message is ready */
-	struct sync_object *sync_done;	/* For synchronizing cleanup */
-	struct sync_object *sync_done_ack;	/* For synchronizing cleanup */
-	struct ntfy_object *ntfy_obj;	/* For notification of message ready */
-	bool done;		/* TRUE <==> deleting the object */
-	u32 io_msg_pend;	/* Number of pending MSG_get/put calls */
-};
-
-/*
- *  ======== msg_dspmsg ========
- */
-struct msg_dspmsg {
-	struct dsp_msg msg;
-	u32 msgq_id;		/* Identifies the node the message goes to */
-};
-
-/*
- *  ======== msg_frame ========
- */
-struct msg_frame {
-	struct list_head list_elem;
-	struct msg_dspmsg msg_data;
-};
-
-#endif /* _MSG_SM_ */
diff --git a/drivers/staging/tidspbridge/core/_tiomap.h b/drivers/staging/tidspbridge/core/_tiomap.h
deleted file mode 100644
index 65971b7..0000000
--- a/drivers/staging/tidspbridge/core/_tiomap.h
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * _tiomap.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Definitions and types private to this Bridge driver.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _TIOMAP_
-#define _TIOMAP_
-
-/*
- * XXX These powerdomain.h/clockdomain.h includes are wrong and should
- * be removed.  No driver should call pwrdm_* or clkdm_* functions
- * directly; they should rely on OMAP core code to do this.
- */
-#include <mach-omap2/powerdomain.h>
-#include <mach-omap2/clockdomain.h>
-/*
- * XXX These mach-omap2/ includes are wrong and should be removed.  No
- * driver should read or write to PRM/CM registers directly; they
- * should rely on OMAP core code to do this.
- */
-#include <mach-omap2/cm3xxx.h>
-#include <mach-omap2/prm-regbits-34xx.h>
-#include <mach-omap2/cm-regbits-34xx.h>
-#include <dspbridge/devdefs.h>
-#include <hw_defs.h>
-#include <dspbridge/dspioctl.h>	/* for bridge_ioctl_extproc defn */
-#include <dspbridge/sync.h>
-#include <dspbridge/clk.h>
-
-struct map_l4_peripheral {
-	u32 phys_addr;
-	u32 dsp_virt_addr;
-};
-
-#define ARM_MAILBOX_START               0xfffcf000
-#define ARM_MAILBOX_LENGTH              0x800
-
-/* New Registers in OMAP3.1 */
-
-#define TESTBLOCK_ID_START              0xfffed400
-#define TESTBLOCK_ID_LENGTH             0xff
-
-/* ID Returned by OMAP1510 */
-#define TBC_ID_VALUE                    0xB47002F
-
-#define SPACE_LENGTH                    0x2000
-#define API_CLKM_DPLL_DMA               0xfffec000
-#define ARM_INTERRUPT_OFFSET            0xb00
-
-#define BIOS24XX
-
-#define L4_PERIPHERAL_NULL          0x0
-#define DSPVA_PERIPHERAL_NULL       0x0
-
-#define MAX_LOCK_TLB_ENTRIES 15
-
-#define L4_PERIPHERAL_PRM        0x48306000	/*PRM L4 Peripheral */
-#define DSPVA_PERIPHERAL_PRM     0x1181e000
-#define L4_PERIPHERAL_SCM        0x48002000	/*SCM L4 Peripheral */
-#define DSPVA_PERIPHERAL_SCM     0x1181f000
-#define L4_PERIPHERAL_MMU        0x5D000000	/*MMU L4 Peripheral */
-#define DSPVA_PERIPHERAL_MMU     0x11820000
-#define L4_PERIPHERAL_CM        0x48004000	/* Core L4, Clock Management */
-#define DSPVA_PERIPHERAL_CM     0x1181c000
-#define L4_PERIPHERAL_PER        0x48005000	/*  PER */
-#define DSPVA_PERIPHERAL_PER     0x1181d000
-
-#define L4_PERIPHERAL_GPIO1       0x48310000
-#define DSPVA_PERIPHERAL_GPIO1    0x11809000
-#define L4_PERIPHERAL_GPIO2       0x49050000
-#define DSPVA_PERIPHERAL_GPIO2    0x1180a000
-#define L4_PERIPHERAL_GPIO3       0x49052000
-#define DSPVA_PERIPHERAL_GPIO3    0x1180b000
-#define L4_PERIPHERAL_GPIO4       0x49054000
-#define DSPVA_PERIPHERAL_GPIO4    0x1180c000
-#define L4_PERIPHERAL_GPIO5       0x49056000
-#define DSPVA_PERIPHERAL_GPIO5    0x1180d000
-
-#define L4_PERIPHERAL_IVA2WDT      0x49030000
-#define DSPVA_PERIPHERAL_IVA2WDT   0x1180e000
-
-#define L4_PERIPHERAL_DISPLAY     0x48050000
-#define DSPVA_PERIPHERAL_DISPLAY  0x1180f000
-
-#define L4_PERIPHERAL_SSI         0x48058000
-#define DSPVA_PERIPHERAL_SSI      0x11804000
-#define L4_PERIPHERAL_GDD         0x48059000
-#define DSPVA_PERIPHERAL_GDD      0x11805000
-#define L4_PERIPHERAL_SS1         0x4805a000
-#define DSPVA_PERIPHERAL_SS1      0x11806000
-#define L4_PERIPHERAL_SS2         0x4805b000
-#define DSPVA_PERIPHERAL_SS2      0x11807000
-
-#define L4_PERIPHERAL_CAMERA      0x480BC000
-#define DSPVA_PERIPHERAL_CAMERA   0x11819000
-
-#define L4_PERIPHERAL_SDMA        0x48056000
-#define DSPVA_PERIPHERAL_SDMA     0x11810000	/* 0x1181d000 conflict w/ PER */
-
-#define L4_PERIPHERAL_UART1             0x4806a000
-#define DSPVA_PERIPHERAL_UART1          0x11811000
-#define L4_PERIPHERAL_UART2             0x4806c000
-#define DSPVA_PERIPHERAL_UART2          0x11812000
-#define L4_PERIPHERAL_UART3             0x49020000
-#define DSPVA_PERIPHERAL_UART3    0x11813000
-
-#define L4_PERIPHERAL_MCBSP1      0x48074000
-#define DSPVA_PERIPHERAL_MCBSP1   0x11814000
-#define L4_PERIPHERAL_MCBSP2      0x49022000
-#define DSPVA_PERIPHERAL_MCBSP2   0x11815000
-#define L4_PERIPHERAL_MCBSP3      0x49024000
-#define DSPVA_PERIPHERAL_MCBSP3   0x11816000
-#define L4_PERIPHERAL_MCBSP4      0x49026000
-#define DSPVA_PERIPHERAL_MCBSP4   0x11817000
-#define L4_PERIPHERAL_MCBSP5      0x48096000
-#define DSPVA_PERIPHERAL_MCBSP5   0x11818000
-
-#define L4_PERIPHERAL_GPTIMER5    0x49038000
-#define DSPVA_PERIPHERAL_GPTIMER5 0x11800000
-#define L4_PERIPHERAL_GPTIMER6    0x4903a000
-#define DSPVA_PERIPHERAL_GPTIMER6 0x11801000
-#define L4_PERIPHERAL_GPTIMER7    0x4903c000
-#define DSPVA_PERIPHERAL_GPTIMER7 0x11802000
-#define L4_PERIPHERAL_GPTIMER8    0x4903e000
-#define DSPVA_PERIPHERAL_GPTIMER8 0x11803000
-
-#define L4_PERIPHERAL_SPI1      0x48098000
-#define DSPVA_PERIPHERAL_SPI1   0x1181a000
-#define L4_PERIPHERAL_SPI2      0x4809a000
-#define DSPVA_PERIPHERAL_SPI2   0x1181b000
-
-#define L4_PERIPHERAL_MBOX        0x48094000
-#define DSPVA_PERIPHERAL_MBOX     0x11808000
-
-#define PM_GRPSEL_BASE	0x48307000
-#define DSPVA_GRPSEL_BASE	0x11821000
-
-#define L4_PERIPHERAL_SIDETONE_MCBSP2        0x49028000
-#define DSPVA_PERIPHERAL_SIDETONE_MCBSP2 0x11824000
-#define L4_PERIPHERAL_SIDETONE_MCBSP3        0x4902a000
-#define DSPVA_PERIPHERAL_SIDETONE_MCBSP3 0x11825000
-
-/* define a static array with L4 mappings */
-static const struct map_l4_peripheral l4_peripheral_table[] = {
-	{L4_PERIPHERAL_MBOX, DSPVA_PERIPHERAL_MBOX},
-	{L4_PERIPHERAL_SCM, DSPVA_PERIPHERAL_SCM},
-	{L4_PERIPHERAL_MMU, DSPVA_PERIPHERAL_MMU},
-	{L4_PERIPHERAL_GPTIMER5, DSPVA_PERIPHERAL_GPTIMER5},
-	{L4_PERIPHERAL_GPTIMER6, DSPVA_PERIPHERAL_GPTIMER6},
-	{L4_PERIPHERAL_GPTIMER7, DSPVA_PERIPHERAL_GPTIMER7},
-	{L4_PERIPHERAL_GPTIMER8, DSPVA_PERIPHERAL_GPTIMER8},
-	{L4_PERIPHERAL_GPIO1, DSPVA_PERIPHERAL_GPIO1},
-	{L4_PERIPHERAL_GPIO2, DSPVA_PERIPHERAL_GPIO2},
-	{L4_PERIPHERAL_GPIO3, DSPVA_PERIPHERAL_GPIO3},
-	{L4_PERIPHERAL_GPIO4, DSPVA_PERIPHERAL_GPIO4},
-	{L4_PERIPHERAL_GPIO5, DSPVA_PERIPHERAL_GPIO5},
-	{L4_PERIPHERAL_IVA2WDT, DSPVA_PERIPHERAL_IVA2WDT},
-	{L4_PERIPHERAL_DISPLAY, DSPVA_PERIPHERAL_DISPLAY},
-	{L4_PERIPHERAL_SSI, DSPVA_PERIPHERAL_SSI},
-	{L4_PERIPHERAL_GDD, DSPVA_PERIPHERAL_GDD},
-	{L4_PERIPHERAL_SS1, DSPVA_PERIPHERAL_SS1},
-	{L4_PERIPHERAL_SS2, DSPVA_PERIPHERAL_SS2},
-	{L4_PERIPHERAL_UART1, DSPVA_PERIPHERAL_UART1},
-	{L4_PERIPHERAL_UART2, DSPVA_PERIPHERAL_UART2},
-	{L4_PERIPHERAL_UART3, DSPVA_PERIPHERAL_UART3},
-	{L4_PERIPHERAL_MCBSP1, DSPVA_PERIPHERAL_MCBSP1},
-	{L4_PERIPHERAL_MCBSP2, DSPVA_PERIPHERAL_MCBSP2},
-	{L4_PERIPHERAL_MCBSP3, DSPVA_PERIPHERAL_MCBSP3},
-	{L4_PERIPHERAL_MCBSP4, DSPVA_PERIPHERAL_MCBSP4},
-	{L4_PERIPHERAL_MCBSP5, DSPVA_PERIPHERAL_MCBSP5},
-	{L4_PERIPHERAL_CAMERA, DSPVA_PERIPHERAL_CAMERA},
-	{L4_PERIPHERAL_SPI1, DSPVA_PERIPHERAL_SPI1},
-	{L4_PERIPHERAL_SPI2, DSPVA_PERIPHERAL_SPI2},
-	{L4_PERIPHERAL_PRM, DSPVA_PERIPHERAL_PRM},
-	{L4_PERIPHERAL_CM, DSPVA_PERIPHERAL_CM},
-	{L4_PERIPHERAL_PER, DSPVA_PERIPHERAL_PER},
-	{PM_GRPSEL_BASE, DSPVA_GRPSEL_BASE},
-	{L4_PERIPHERAL_SIDETONE_MCBSP2, DSPVA_PERIPHERAL_SIDETONE_MCBSP2},
-	{L4_PERIPHERAL_SIDETONE_MCBSP3, DSPVA_PERIPHERAL_SIDETONE_MCBSP3},
-	{L4_PERIPHERAL_NULL, DSPVA_PERIPHERAL_NULL}
-};
-
-/*
- *   15         10                  0
- *   ---------------------------------
- *  |0|0|1|0|0|0|c|c|c|i|i|i|i|i|i|i|
- *  ---------------------------------
- *  |  (class)  | (module specific) |
- *
- *  where  c -> Externel Clock Command: Clk & Autoidle Disable/Enable
- *  i -> External Clock ID Timers 5,6,7,8, McBSP1,2 and WDT3
- */
-
-/* MBX_PM_CLK_IDMASK: DSP External clock id mask. */
-#define MBX_PM_CLK_IDMASK   0x7F
-
-/* MBX_PM_CLK_CMDSHIFT: DSP External clock command shift. */
-#define MBX_PM_CLK_CMDSHIFT 7
-
-/* MBX_PM_CLK_CMDMASK: DSP External clock command mask. */
-#define MBX_PM_CLK_CMDMASK 7
-
-/* MBX_PM_MAX_RESOURCES: CORE 1 Clock resources. */
-#define MBX_CORE1_RESOURCES 7
-
-/* MBX_PM_MAX_RESOURCES: CORE 2 Clock Resources. */
-#define MBX_CORE2_RESOURCES 1
-
-/* MBX_PM_MAX_RESOURCES: TOTAL Clock Resources. */
-#define MBX_PM_MAX_RESOURCES 11
-
-/*  Power Management Commands */
-#define BPWR_DISABLE_CLOCK	0
-#define BPWR_ENABLE_CLOCK	1
-
-/* OMAP242x specific resources */
-enum bpwr_ext_clock_id {
-	BPWR_GP_TIMER5 = 0x10,
-	BPWR_GP_TIMER6,
-	BPWR_GP_TIMER7,
-	BPWR_GP_TIMER8,
-	BPWR_WD_TIMER3,
-	BPWR_MCBSP1,
-	BPWR_MCBSP2,
-	BPWR_MCBSP3,
-	BPWR_MCBSP4,
-	BPWR_MCBSP5,
-	BPWR_SSI = 0x20
-};
-
-static const u32 bpwr_clkid[] = {
-	(u32) BPWR_GP_TIMER5,
-	(u32) BPWR_GP_TIMER6,
-	(u32) BPWR_GP_TIMER7,
-	(u32) BPWR_GP_TIMER8,
-	(u32) BPWR_WD_TIMER3,
-	(u32) BPWR_MCBSP1,
-	(u32) BPWR_MCBSP2,
-	(u32) BPWR_MCBSP3,
-	(u32) BPWR_MCBSP4,
-	(u32) BPWR_MCBSP5,
-	(u32) BPWR_SSI
-};
-
-struct bpwr_clk_t {
-	u32 clk_id;
-	enum dsp_clk_id clk;
-};
-
-static const struct bpwr_clk_t bpwr_clks[] = {
-	{(u32) BPWR_GP_TIMER5, DSP_CLK_GPT5},
-	{(u32) BPWR_GP_TIMER6, DSP_CLK_GPT6},
-	{(u32) BPWR_GP_TIMER7, DSP_CLK_GPT7},
-	{(u32) BPWR_GP_TIMER8, DSP_CLK_GPT8},
-	{(u32) BPWR_WD_TIMER3, DSP_CLK_WDT3},
-	{(u32) BPWR_MCBSP1, DSP_CLK_MCBSP1},
-	{(u32) BPWR_MCBSP2, DSP_CLK_MCBSP2},
-	{(u32) BPWR_MCBSP3, DSP_CLK_MCBSP3},
-	{(u32) BPWR_MCBSP4, DSP_CLK_MCBSP4},
-	{(u32) BPWR_MCBSP5, DSP_CLK_MCBSP5},
-	{(u32) BPWR_SSI, DSP_CLK_SSI}
-};
-
-/* Interrupt Register Offsets */
-#define INTH_IT_REG_OFFSET              0x00	/* Interrupt register offset */
-#define INTH_MASK_IT_REG_OFFSET         0x04	/* Mask Interrupt reg offset */
-
-#define   DSP_MAILBOX1_INT              10
-/*
- *  Bit definition of  Interrupt  Level  Registers
- */
-
-/* Mail Box defines */
-#define MB_ARM2DSP1_REG_OFFSET          0x00
-
-#define MB_ARM2DSP1B_REG_OFFSET         0x04
-
-#define MB_DSP2ARM1B_REG_OFFSET         0x0C
-
-#define MB_ARM2DSP1_FLAG_REG_OFFSET     0x18
-
-#define MB_ARM2DSP_FLAG                 0x0001
-
-#define MBOX_ARM2DSP HW_MBOX_ID0
-#define MBOX_DSP2ARM HW_MBOX_ID1
-#define MBOX_ARM HW_MBOX_U0_ARM
-#define MBOX_DSP HW_MBOX_U1_DSP1
-
-#define ENABLE                          true
-#define DISABLE                         false
-
-#define HIGH_LEVEL                      true
-#define LOW_LEVEL                       false
-
-/* Macro's */
-#define CLEAR_BIT(reg, mask)             (reg &= ~mask)
-#define SET_BIT(reg, mask)               (reg |= mask)
-
-#define SET_GROUP_BITS16(reg, position, width, value) \
-	do {\
-		reg &= ~((0xFFFF >> (16 - (width))) << (position)); \
-		reg |= ((value & (0xFFFF >> (16 - (width)))) << (position)); \
-	} while (0);
-
-#define CLEAR_BIT_INDEX(reg, index)   (reg &= ~(1 << (index)))
-
-/* This Bridge driver's device context: */
-struct bridge_dev_context {
-	struct dev_object *dev_obj;	/* Handle to Bridge device object. */
-	u32 dsp_base_addr;	/* Arm's API to DSP virt base addr */
-	/*
-	 * DSP External memory prog address as seen virtually by the OS on
-	 * the host side.
-	 */
-	u32 dsp_ext_base_addr;	/* See the comment above */
-	u32 api_reg_base;	/* API mem map'd registers */
-	void __iomem *dsp_mmu_base;	/* DSP MMU Mapped registers */
-	u32 api_clk_base;	/* CLK Registers */
-	u32 dsp_clk_m2_base;	/* DSP Clock Module m2 */
-	u32 public_rhea;	/* Pub Rhea */
-	u32 int_addr;		/* MB INTR reg */
-	u32 tc_endianism;	/* TC Endianism register */
-	u32 test_base;		/* DSP MMU Mapped registers */
-	u32 self_loop;		/* Pointer to the selfloop */
-	u32 dsp_start_add;	/* API Boot vector */
-	u32 internal_size;	/* Internal memory size */
-
-	struct omap_mbox *mbox;		/* Mail box handle */
-
-	struct cfg_hostres *resources;	/* Host Resources */
-
-	/*
-	 * Processor specific info is set when prog loaded and read from DCD.
-	 * [See bridge_dev_ctrl()]  PROC info contains DSP-MMU TLB entries.
-	 */
-	/* DMMU TLB entries */
-	struct bridge_ioctl_extproc atlb_entry[BRDIOCTL_NUMOFMMUTLB];
-	u32 brd_state;       /* Last known board state. */
-
-	/* TC Settings */
-	bool tc_word_swap_on;	/* Traffic Controller Word Swap */
-	struct pg_table_attrs *pt_attrs;
-	u32 dsp_per_clks;
-};
-
-/*
- * If dsp_debug is true, do not branch to the DSP entry
- * point and wait for DSP to boot.
- */
-extern s32 dsp_debug;
-
-/*
- *  ======== sm_interrupt_dsp ========
- *  Purpose:
- *      Set interrupt value & send an interrupt to the DSP processor(s).
- *      This is typically used when mailbox interrupt mechanisms allow data
- *      to be associated with interrupt such as for OMAP's CMD/DATA regs.
- *  Parameters:
- *      dev_context:    Handle to Bridge driver defined device info.
- *      mb_val:         Value associated with interrupt(e.g. mailbox value).
- *  Returns:
- *      0:        Interrupt sent;
- *      else:           Unable to send interrupt.
- *  Requires:
- *  Ensures:
- */
-int sm_interrupt_dsp(struct bridge_dev_context *dev_context, u16 mb_val);
-
-#endif /* _TIOMAP_ */
diff --git a/drivers/staging/tidspbridge/core/_tiomap_pwr.h b/drivers/staging/tidspbridge/core/_tiomap_pwr.h
deleted file mode 100644
index 7bbd380..0000000
--- a/drivers/staging/tidspbridge/core/_tiomap_pwr.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * _tiomap_pwr.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Definitions and types for the DSP wake/sleep routines.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _TIOMAP_PWR_
-#define _TIOMAP_PWR_
-
-#ifdef CONFIG_PM
-extern s32 dsp_test_sleepstate;
-#endif
-
-extern struct mailbox_context mboxsetting;
-
-/*
- * ======== wake_dsp =========
- * Wakes up the DSP from DeepSleep
- */
-extern int wake_dsp(struct bridge_dev_context *dev_context,
-							void *pargs);
-
-/*
- * ======== sleep_dsp =========
- * Places the DSP in DeepSleep.
- */
-extern int sleep_dsp(struct bridge_dev_context *dev_context,
-			    u32 dw_cmd, void *pargs);
-/*
- *  ========interrupt_dsp========
- *	Sends an interrupt to DSP unconditionally.
- */
-extern void interrupt_dsp(struct bridge_dev_context *dev_context,
-							u16 mb_val);
-
-/*
- * ======== wake_dsp =========
- * Wakes up the DSP from DeepSleep
- */
-extern int dsp_peripheral_clk_ctrl(struct bridge_dev_context
-					*dev_context, void *pargs);
-/*
- *  ======== handle_hibernation_from_dsp ========
- *	Handle Hibernation requested from DSP
- */
-int handle_hibernation_from_dsp(struct bridge_dev_context *dev_context);
-/*
- *  ======== post_scale_dsp ========
- *	Handle Post Scale notification to DSP
- */
-int post_scale_dsp(struct bridge_dev_context *dev_context,
-							void *pargs);
-/*
- *  ======== pre_scale_dsp ========
- *	Handle Pre Scale notification to DSP
- */
-int pre_scale_dsp(struct bridge_dev_context *dev_context,
-							void *pargs);
-/*
- *  ======== handle_constraints_set ========
- *	Handle constraints request from DSP
- */
-int handle_constraints_set(struct bridge_dev_context *dev_context,
-				  void *pargs);
-
-/*
- *  ======== dsp_clk_wakeup_event_ctrl ========
- *     This function sets the group selction bits for while
- *     enabling/disabling.
- */
-void dsp_clk_wakeup_event_ctrl(u32 clock_id, bool enable);
-
-#endif /* _TIOMAP_PWR_ */
diff --git a/drivers/staging/tidspbridge/core/chnl_sm.c b/drivers/staging/tidspbridge/core/chnl_sm.c
deleted file mode 100644
index c855992..0000000
--- a/drivers/staging/tidspbridge/core/chnl_sm.c
+++ /dev/null
@@ -1,908 +0,0 @@
-/*
- * chnl_sm.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Implements upper edge functions for Bridge driver channel module.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
- *      The lower edge functions must be implemented by the Bridge driver
- *      writer, and are declared in chnl_sm.h.
- *
- *      Care is taken in this code to prevent simultaneous access to channel
- *      queues from
- *      1. Threads.
- *      2. io_dpc(), scheduled from the io_isr() as an event.
- *
- *      This is done primarily by:
- *      - Semaphores.
- *      - state flags in the channel object; and
- *      - ensuring the IO_Dispatch() routine, which is called from both
- *        CHNL_AddIOReq() and the DPC(if implemented), is not re-entered.
- *
- *  Channel Invariant:
- *      There is an important invariant condition which must be maintained per
- *      channel outside of bridge_chnl_get_ioc() and IO_Dispatch(), violation of
- *      which may cause timeouts and/or failure of function sync_wait_on_event.
- *      This invariant condition is:
- *
- *          list_empty(&pchnl->io_completions) ==> pchnl->sync_event is reset
- *      and
- *          !list_empty(&pchnl->io_completions) ==> pchnl->sync_event is set.
- */
-
-#include <linux/types.h>
-
-/*  ----------------------------------- OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/sync.h>
-
-/*  ----------------------------------- Bridge Driver */
-#include <dspbridge/dspdefs.h>
-#include <dspbridge/dspchnl.h>
-#include "_tiomap.h"
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/dev.h>
-
-/*  ----------------------------------- Others */
-#include <dspbridge/io_sm.h>
-
-/*  ----------------------------------- Define for This */
-#define USERMODE_ADDR   PAGE_OFFSET
-
-#define MAILBOX_IRQ INT_MAIL_MPU_IRQ
-
-/*  ----------------------------------- Function Prototypes */
-static int create_chirp_list(struct list_head *list, u32 chirps);
-
-static void free_chirp_list(struct list_head *list);
-
-static int search_free_channel(struct chnl_mgr *chnl_mgr_obj,
-				      u32 *chnl);
-
-/*
- *  ======== bridge_chnl_add_io_req ========
- *      Enqueue an I/O request for data transfer on a channel to the DSP.
- *      The direction (mode) is specified in the channel object. Note the DSP
- *      address is specified for channels opened in direct I/O mode.
- */
-int bridge_chnl_add_io_req(struct chnl_object *chnl_obj, void *host_buf,
-			       u32 byte_size, u32 buf_size,
-			       u32 dw_dsp_addr, u32 dw_arg)
-{
-	int status = 0;
-	struct chnl_object *pchnl = (struct chnl_object *)chnl_obj;
-	struct chnl_irp *chnl_packet_obj = NULL;
-	struct bridge_dev_context *dev_ctxt;
-	struct dev_object *dev_obj;
-	u8 dw_state;
-	bool is_eos;
-	struct chnl_mgr *chnl_mgr_obj;
-	u8 *host_sys_buf = NULL;
-	bool sched_dpc = false;
-	u16 mb_val = 0;
-
-	is_eos = (byte_size == 0);
-
-	/* Validate args */
-	if (!host_buf || !pchnl)
-		return -EFAULT;
-
-	if (is_eos && CHNL_IS_INPUT(pchnl->chnl_mode))
-		return -EPERM;
-
-	/*
-	 * Check the channel state: only queue chirp if channel state
-	 * allows it.
-	 */
-	dw_state = pchnl->state;
-	if (dw_state != CHNL_STATEREADY) {
-		if (dw_state & CHNL_STATECANCEL)
-			return -ECANCELED;
-		if ((dw_state & CHNL_STATEEOS) &&
-				CHNL_IS_OUTPUT(pchnl->chnl_mode))
-			return -EPIPE;
-		/* No other possible states left */
-	}
-
-	dev_obj = dev_get_first();
-	dev_get_bridge_context(dev_obj, &dev_ctxt);
-	if (!dev_ctxt)
-		return -EFAULT;
-
-	if (pchnl->chnl_type == CHNL_PCPY && pchnl->chnl_id > 1 && host_buf) {
-		if (!(host_buf < (void *)USERMODE_ADDR)) {
-			host_sys_buf = host_buf;
-			goto func_cont;
-		}
-		/* if addr in user mode, then copy to kernel space */
-		host_sys_buf = kmalloc(buf_size, GFP_KERNEL);
-		if (host_sys_buf == NULL)
-			return -ENOMEM;
-
-		if (CHNL_IS_OUTPUT(pchnl->chnl_mode)) {
-			status = copy_from_user(host_sys_buf, host_buf,
-					buf_size);
-			if (status) {
-				kfree(host_sys_buf);
-				host_sys_buf = NULL;
-				return -EFAULT;
-			}
-		}
-	}
-func_cont:
-	/* Mailbox IRQ is disabled to avoid race condition with DMA/ZCPY
-	 * channels. DPCCS is held to avoid race conditions with PCPY channels.
-	 * If DPC is scheduled in process context (iosm_schedule) and any
-	 * non-mailbox interrupt occurs, that DPC will run and break CS. Hence
-	 * we disable ALL DPCs. We will try to disable ONLY IO DPC later. */
-	chnl_mgr_obj = pchnl->chnl_mgr_obj;
-	spin_lock_bh(&chnl_mgr_obj->chnl_mgr_lock);
-	omap_mbox_disable_irq(dev_ctxt->mbox, IRQ_RX);
-	if (pchnl->chnl_type == CHNL_PCPY) {
-		/* This is a processor-copy channel. */
-		if (CHNL_IS_OUTPUT(pchnl->chnl_mode)) {
-			/* Check buffer size on output channels for fit. */
-			if (byte_size > io_buf_size(
-						pchnl->chnl_mgr_obj->iomgr)) {
-				status = -EINVAL;
-				goto out;
-			}
-		}
-	}
-
-	/* Get a free chirp: */
-	if (list_empty(&pchnl->free_packets_list)) {
-		status = -EIO;
-		goto out;
-	}
-	chnl_packet_obj = list_first_entry(&pchnl->free_packets_list,
-			struct chnl_irp, link);
-	list_del(&chnl_packet_obj->link);
-
-	/* Enqueue the chirp on the chnl's IORequest queue: */
-	chnl_packet_obj->host_user_buf = chnl_packet_obj->host_sys_buf =
-		host_buf;
-	if (pchnl->chnl_type == CHNL_PCPY && pchnl->chnl_id > 1)
-		chnl_packet_obj->host_sys_buf = host_sys_buf;
-
-	/*
-	 * Note: for dma chans dw_dsp_addr contains dsp address
-	 * of SM buffer.
-	 */
-	/* DSP address */
-	chnl_packet_obj->dsp_tx_addr = dw_dsp_addr / chnl_mgr_obj->word_size;
-	chnl_packet_obj->byte_size = byte_size;
-	chnl_packet_obj->buf_size = buf_size;
-	/* Only valid for output channel */
-	chnl_packet_obj->arg = dw_arg;
-	chnl_packet_obj->status = (is_eos ? CHNL_IOCSTATEOS :
-			CHNL_IOCSTATCOMPLETE);
-	list_add_tail(&chnl_packet_obj->link, &pchnl->io_requests);
-	pchnl->cio_reqs++;
-	/*
-	 * If end of stream, update the channel state to prevent
-	 * more IOR's.
-	 */
-	if (is_eos)
-		pchnl->state |= CHNL_STATEEOS;
-
-	/* Request IO from the DSP */
-	io_request_chnl(chnl_mgr_obj->iomgr, pchnl,
-			(CHNL_IS_INPUT(pchnl->chnl_mode) ? IO_INPUT :
-			 IO_OUTPUT), &mb_val);
-	sched_dpc = true;
-out:
-	omap_mbox_enable_irq(dev_ctxt->mbox, IRQ_RX);
-	spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
-	if (mb_val != 0)
-		sm_interrupt_dsp(dev_ctxt, mb_val);
-
-	/* Schedule a DPC, to do the actual data transfer */
-	if (sched_dpc)
-		iosm_schedule(chnl_mgr_obj->iomgr);
-
-	return status;
-}
-
-/*
- *  ======== bridge_chnl_cancel_io ========
- *      Return all I/O requests to the client which have not yet been
- *      transferred.  The channel's I/O completion object is
- *      signalled, and all the I/O requests are queued as IOC's, with the
- *      status field set to CHNL_IOCSTATCANCEL.
- *      This call is typically used in abort situations, and is a prelude to
- *      chnl_close();
- */
-int bridge_chnl_cancel_io(struct chnl_object *chnl_obj)
-{
-	struct chnl_object *pchnl = (struct chnl_object *)chnl_obj;
-	u32 chnl_id = -1;
-	s8 chnl_mode;
-	struct chnl_irp *chirp, *tmp;
-	struct chnl_mgr *chnl_mgr_obj = NULL;
-
-	/* Check args: */
-	if (!pchnl || !pchnl->chnl_mgr_obj)
-		return -EFAULT;
-
-	chnl_id = pchnl->chnl_id;
-	chnl_mode = pchnl->chnl_mode;
-	chnl_mgr_obj = pchnl->chnl_mgr_obj;
-
-	/*  Mark this channel as cancelled, to prevent further IORequests or
-	 *  IORequests or dispatching. */
-	spin_lock_bh(&chnl_mgr_obj->chnl_mgr_lock);
-
-	pchnl->state |= CHNL_STATECANCEL;
-
-	if (list_empty(&pchnl->io_requests)) {
-		spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
-		return 0;
-	}
-
-	if (pchnl->chnl_type == CHNL_PCPY) {
-		/* Indicate we have no more buffers available for transfer: */
-		if (CHNL_IS_INPUT(pchnl->chnl_mode)) {
-			io_cancel_chnl(chnl_mgr_obj->iomgr, chnl_id);
-		} else {
-			/* Record that we no longer have output buffers
-			 * available: */
-			chnl_mgr_obj->output_mask &= ~(1 << chnl_id);
-		}
-	}
-	/* Move all IOR's to IOC queue: */
-	list_for_each_entry_safe(chirp, tmp, &pchnl->io_requests, link) {
-		list_del(&chirp->link);
-		chirp->byte_size = 0;
-		chirp->status |= CHNL_IOCSTATCANCEL;
-		list_add_tail(&chirp->link, &pchnl->io_completions);
-		pchnl->cio_cs++;
-		pchnl->cio_reqs--;
-	}
-
-	spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
-
-	return 0;
-}
-
-/*
- *  ======== bridge_chnl_close ========
- *  Purpose:
- *      Ensures all pending I/O on this channel is cancelled, discards all
- *      queued I/O completion notifications, then frees the resources allocated
- *      for this channel, and makes the corresponding logical channel id
- *      available for subsequent use.
- */
-int bridge_chnl_close(struct chnl_object *chnl_obj)
-{
-	int status;
-	struct chnl_object *pchnl = (struct chnl_object *)chnl_obj;
-
-	/* Check args: */
-	if (!pchnl)
-		return -EFAULT;
-	/* Cancel IO: this ensures no further IO requests or notifications */
-	status = bridge_chnl_cancel_io(chnl_obj);
-	if (status)
-		return status;
-	/* Invalidate channel object: Protects from CHNL_GetIOCompletion() */
-	/* Free the slot in the channel manager: */
-	pchnl->chnl_mgr_obj->channels[pchnl->chnl_id] = NULL;
-	spin_lock_bh(&pchnl->chnl_mgr_obj->chnl_mgr_lock);
-	pchnl->chnl_mgr_obj->open_channels -= 1;
-	spin_unlock_bh(&pchnl->chnl_mgr_obj->chnl_mgr_lock);
-	if (pchnl->ntfy_obj) {
-		ntfy_delete(pchnl->ntfy_obj);
-		kfree(pchnl->ntfy_obj);
-		pchnl->ntfy_obj = NULL;
-	}
-	/* Reset channel event: (NOTE: user_event freed in user context) */
-	if (pchnl->sync_event) {
-		sync_reset_event(pchnl->sync_event);
-		kfree(pchnl->sync_event);
-		pchnl->sync_event = NULL;
-	}
-	/* Free I/O request and I/O completion queues: */
-	free_chirp_list(&pchnl->io_completions);
-	pchnl->cio_cs = 0;
-
-	free_chirp_list(&pchnl->io_requests);
-	pchnl->cio_reqs = 0;
-
-	free_chirp_list(&pchnl->free_packets_list);
-
-	/* Release channel object. */
-	kfree(pchnl);
-
-	return status;
-}
-
-/*
- *  ======== bridge_chnl_create ========
- *      Create a channel manager object, responsible for opening new channels
- *      and closing old ones for a given board.
- */
-int bridge_chnl_create(struct chnl_mgr **channel_mgr,
-			      struct dev_object *hdev_obj,
-			      const struct chnl_mgrattrs *mgr_attrts)
-{
-	int status = 0;
-	struct chnl_mgr *chnl_mgr_obj = NULL;
-	u8 max_channels;
-
-	/* Allocate channel manager object */
-	chnl_mgr_obj = kzalloc(sizeof(struct chnl_mgr), GFP_KERNEL);
-	if (chnl_mgr_obj) {
-		/*
-		 * The max_channels attr must equal the # of supported chnls for
-		 * each transport(# chnls for PCPY = DDMA = ZCPY): i.e.
-		 *      mgr_attrts->max_channels = CHNL_MAXCHANNELS =
-		 *                       DDMA_MAXDDMACHNLS = DDMA_MAXZCPYCHNLS.
-		 */
-		max_channels = CHNL_MAXCHANNELS + CHNL_MAXCHANNELS * CHNL_PCPY;
-		/* Create array of channels */
-		chnl_mgr_obj->channels = kzalloc(sizeof(struct chnl_object *)
-						* max_channels, GFP_KERNEL);
-		if (chnl_mgr_obj->channels) {
-			/* Initialize chnl_mgr object */
-			chnl_mgr_obj->type = CHNL_TYPESM;
-			chnl_mgr_obj->word_size = mgr_attrts->word_size;
-			/* Total # chnls supported */
-			chnl_mgr_obj->max_channels = max_channels;
-			chnl_mgr_obj->open_channels = 0;
-			chnl_mgr_obj->output_mask = 0;
-			chnl_mgr_obj->last_output = 0;
-			chnl_mgr_obj->dev_obj = hdev_obj;
-			spin_lock_init(&chnl_mgr_obj->chnl_mgr_lock);
-		} else {
-			status = -ENOMEM;
-		}
-	} else {
-		status = -ENOMEM;
-	}
-
-	if (status) {
-		bridge_chnl_destroy(chnl_mgr_obj);
-		*channel_mgr = NULL;
-	} else {
-		/* Return channel manager object to caller... */
-		*channel_mgr = chnl_mgr_obj;
-	}
-	return status;
-}
-
-/*
- *  ======== bridge_chnl_destroy ========
- *  Purpose:
- *      Close all open channels, and destroy the channel manager.
- */
-int bridge_chnl_destroy(struct chnl_mgr *hchnl_mgr)
-{
-	int status = 0;
-	struct chnl_mgr *chnl_mgr_obj = hchnl_mgr;
-	u32 chnl_id;
-
-	if (hchnl_mgr) {
-		/* Close all open channels: */
-		for (chnl_id = 0; chnl_id < chnl_mgr_obj->max_channels;
-		     chnl_id++) {
-			status =
-			    bridge_chnl_close(chnl_mgr_obj->channels
-					      [chnl_id]);
-			if (status)
-				dev_dbg(bridge, "%s: Error status 0x%x\n",
-					__func__, status);
-		}
-
-		/* Free channel manager object: */
-		kfree(chnl_mgr_obj->channels);
-
-		/* Set hchnl_mgr to NULL in device object. */
-		dev_set_chnl_mgr(chnl_mgr_obj->dev_obj, NULL);
-		/* Free this Chnl Mgr object: */
-		kfree(hchnl_mgr);
-	} else {
-		status = -EFAULT;
-	}
-	return status;
-}
-
-/*
- *  ======== bridge_chnl_flush_io ========
- *  purpose:
- *      Flushes all the outstanding data requests on a channel.
- */
-int bridge_chnl_flush_io(struct chnl_object *chnl_obj, u32 timeout)
-{
-	int status = 0;
-	struct chnl_object *pchnl = (struct chnl_object *)chnl_obj;
-	s8 chnl_mode = -1;
-	struct chnl_mgr *chnl_mgr_obj;
-	struct chnl_ioc chnl_ioc_obj;
-	/* Check args: */
-	if (pchnl) {
-		if ((timeout == CHNL_IOCNOWAIT)
-		    && CHNL_IS_OUTPUT(pchnl->chnl_mode)) {
-			status = -EINVAL;
-		} else {
-			chnl_mode = pchnl->chnl_mode;
-			chnl_mgr_obj = pchnl->chnl_mgr_obj;
-		}
-	} else {
-		status = -EFAULT;
-	}
-	if (!status) {
-		/* Note: Currently, if another thread continues to add IO
-		 * requests to this channel, this function will continue to
-		 * flush all such queued IO requests. */
-		if (CHNL_IS_OUTPUT(chnl_mode)
-		    && (pchnl->chnl_type == CHNL_PCPY)) {
-			/* Wait for IO completions, up to the specified
-			 * timeout: */
-			while (!list_empty(&pchnl->io_requests) && !status) {
-				status = bridge_chnl_get_ioc(chnl_obj,
-						timeout, &chnl_ioc_obj);
-				if (status)
-					continue;
-
-				if (chnl_ioc_obj.status & CHNL_IOCSTATTIMEOUT)
-					status = -ETIMEDOUT;
-
-			}
-		} else {
-			status = bridge_chnl_cancel_io(chnl_obj);
-			/* Now, leave the channel in the ready state: */
-			pchnl->state &= ~CHNL_STATECANCEL;
-		}
-	}
-	return status;
-}
-
-/*
- *  ======== bridge_chnl_get_info ========
- *  Purpose:
- *      Retrieve information related to a channel.
- */
-int bridge_chnl_get_info(struct chnl_object *chnl_obj,
-			     struct chnl_info *channel_info)
-{
-	int status = 0;
-	struct chnl_object *pchnl = (struct chnl_object *)chnl_obj;
-
-	if (channel_info != NULL) {
-		if (pchnl) {
-			/* Return the requested information: */
-			channel_info->chnl_mgr = pchnl->chnl_mgr_obj;
-			channel_info->event_obj = pchnl->user_event;
-			channel_info->cnhl_id = pchnl->chnl_id;
-			channel_info->mode = pchnl->chnl_mode;
-			channel_info->bytes_tx = pchnl->bytes_moved;
-			channel_info->process = pchnl->process;
-			channel_info->sync_event = pchnl->sync_event;
-			channel_info->cio_cs = pchnl->cio_cs;
-			channel_info->cio_reqs = pchnl->cio_reqs;
-			channel_info->state = pchnl->state;
-		} else {
-			status = -EFAULT;
-		}
-	} else {
-		status = -EFAULT;
-	}
-	return status;
-}
-
-/*
- *  ======== bridge_chnl_get_ioc ========
- *      Optionally wait for I/O completion on a channel.  Dequeue an I/O
- *      completion record, which contains information about the completed
- *      I/O request.
- *      Note: Ensures Channel Invariant (see notes above).
- */
-int bridge_chnl_get_ioc(struct chnl_object *chnl_obj, u32 timeout,
-			    struct chnl_ioc *chan_ioc)
-{
-	int status = 0;
-	struct chnl_object *pchnl = (struct chnl_object *)chnl_obj;
-	struct chnl_irp *chnl_packet_obj;
-	int stat_sync;
-	bool dequeue_ioc = true;
-	struct chnl_ioc ioc = { NULL, 0, 0, 0, 0 };
-	u8 *host_sys_buf = NULL;
-	struct bridge_dev_context *dev_ctxt;
-	struct dev_object *dev_obj;
-
-	/* Check args: */
-	if (!chan_ioc || !pchnl) {
-		status = -EFAULT;
-	} else if (timeout == CHNL_IOCNOWAIT) {
-		if (list_empty(&pchnl->io_completions))
-			status = -EREMOTEIO;
-
-	}
-
-	dev_obj = dev_get_first();
-	dev_get_bridge_context(dev_obj, &dev_ctxt);
-	if (!dev_ctxt)
-		status = -EFAULT;
-
-	if (status)
-		goto func_end;
-
-	ioc.status = CHNL_IOCSTATCOMPLETE;
-	if (timeout !=
-	    CHNL_IOCNOWAIT && list_empty(&pchnl->io_completions)) {
-		if (timeout == CHNL_IOCINFINITE)
-			timeout = SYNC_INFINITE;
-
-		stat_sync = sync_wait_on_event(pchnl->sync_event, timeout);
-		if (stat_sync == -ETIME) {
-			/* No response from DSP */
-			ioc.status |= CHNL_IOCSTATTIMEOUT;
-			dequeue_ioc = false;
-		} else if (stat_sync == -EPERM) {
-			/* This can occur when the user mode thread is
-			 * aborted (^C), or when _VWIN32_WaitSingleObject()
-			 * fails due to unknown causes. */
-			/* Even though Wait failed, there may be something in
-			 * the Q: */
-			if (list_empty(&pchnl->io_completions)) {
-				ioc.status |= CHNL_IOCSTATCANCEL;
-				dequeue_ioc = false;
-			}
-		}
-	}
-	/* See comment in AddIOReq */
-	spin_lock_bh(&pchnl->chnl_mgr_obj->chnl_mgr_lock);
-	omap_mbox_disable_irq(dev_ctxt->mbox, IRQ_RX);
-	if (dequeue_ioc) {
-		/* Dequeue IOC and set chan_ioc; */
-		chnl_packet_obj = list_first_entry(&pchnl->io_completions,
-				struct chnl_irp, link);
-		list_del(&chnl_packet_obj->link);
-		/* Update chan_ioc from channel state and chirp: */
-		pchnl->cio_cs--;
-		/*
-		 * If this is a zero-copy channel, then set IOC's pbuf
-		 * to the DSP's address. This DSP address will get
-		 * translated to user's virtual addr later.
-		 */
-		host_sys_buf = chnl_packet_obj->host_sys_buf;
-		ioc.buf = chnl_packet_obj->host_user_buf;
-		ioc.byte_size = chnl_packet_obj->byte_size;
-		ioc.buf_size = chnl_packet_obj->buf_size;
-		ioc.arg = chnl_packet_obj->arg;
-		ioc.status |= chnl_packet_obj->status;
-		/* Place the used chirp on the free list: */
-		list_add_tail(&chnl_packet_obj->link,
-				&pchnl->free_packets_list);
-	} else {
-		ioc.buf = NULL;
-		ioc.byte_size = 0;
-		ioc.arg = 0;
-		ioc.buf_size = 0;
-	}
-	/* Ensure invariant: If any IOC's are queued for this channel... */
-	if (!list_empty(&pchnl->io_completions)) {
-		/*  Since DSPStream_Reclaim() does not take a timeout
-		 *  parameter, we pass the stream's timeout value to
-		 *  bridge_chnl_get_ioc. We cannot determine whether or not
-		 *  we have waited in user mode. Since the stream's timeout
-		 *  value may be non-zero, we still have to set the event.
-		 *  Therefore, this optimization is taken out.
-		 *
-		 *  if (timeout == CHNL_IOCNOWAIT) {
-		 *    ... ensure event is set..
-		 *      sync_set_event(pchnl->sync_event);
-		 *  } */
-		sync_set_event(pchnl->sync_event);
-	} else {
-		/* else, if list is empty, ensure event is reset. */
-		sync_reset_event(pchnl->sync_event);
-	}
-	omap_mbox_enable_irq(dev_ctxt->mbox, IRQ_RX);
-	spin_unlock_bh(&pchnl->chnl_mgr_obj->chnl_mgr_lock);
-	if (dequeue_ioc
-	    && (pchnl->chnl_type == CHNL_PCPY && pchnl->chnl_id > 1)) {
-		if (!(ioc.buf < (void *)USERMODE_ADDR))
-			goto func_cont;
-
-		/* If the addr is in user mode, then copy it */
-		if (!host_sys_buf || !ioc.buf) {
-			status = -EFAULT;
-			goto func_cont;
-		}
-		if (!CHNL_IS_INPUT(pchnl->chnl_mode))
-			goto func_cont1;
-
-		/*host_user_buf */
-		status = copy_to_user(ioc.buf, host_sys_buf, ioc.byte_size);
-		if (status) {
-			if (current->flags & PF_EXITING)
-				status = 0;
-		}
-		if (status)
-			status = -EFAULT;
-func_cont1:
-		kfree(host_sys_buf);
-	}
-func_cont:
-	/* Update User's IOC block: */
-	*chan_ioc = ioc;
-func_end:
-	return status;
-}
-
-/*
- *  ======== bridge_chnl_get_mgr_info ========
- *      Retrieve information related to the channel manager.
- */
-int bridge_chnl_get_mgr_info(struct chnl_mgr *hchnl_mgr, u32 ch_id,
-				 struct chnl_mgrinfo *mgr_info)
-{
-	struct chnl_mgr *chnl_mgr_obj = (struct chnl_mgr *)hchnl_mgr;
-
-	if (!mgr_info || !hchnl_mgr)
-		return -EFAULT;
-
-	if (ch_id > CHNL_MAXCHANNELS)
-		return -ECHRNG;
-
-	/* Return the requested information: */
-	mgr_info->chnl_obj = chnl_mgr_obj->channels[ch_id];
-	mgr_info->open_channels = chnl_mgr_obj->open_channels;
-	mgr_info->type = chnl_mgr_obj->type;
-	/* total # of chnls */
-	mgr_info->max_channels = chnl_mgr_obj->max_channels;
-
-	return 0;
-}
-
-/*
- *  ======== bridge_chnl_idle ========
- *      Idles a particular channel.
- */
-int bridge_chnl_idle(struct chnl_object *chnl_obj, u32 timeout,
-			    bool flush_data)
-{
-	s8 chnl_mode;
-	struct chnl_mgr *chnl_mgr_obj;
-	int status = 0;
-
-	chnl_mode = chnl_obj->chnl_mode;
-	chnl_mgr_obj = chnl_obj->chnl_mgr_obj;
-
-	if (CHNL_IS_OUTPUT(chnl_mode) && !flush_data) {
-		/* Wait for IO completions, up to the specified timeout: */
-		status = bridge_chnl_flush_io(chnl_obj, timeout);
-	} else {
-		status = bridge_chnl_cancel_io(chnl_obj);
-
-		/* Reset the byte count and put channel back in ready state. */
-		chnl_obj->bytes_moved = 0;
-		chnl_obj->state &= ~CHNL_STATECANCEL;
-	}
-
-	return status;
-}
-
-/*
- *  ======== bridge_chnl_open ========
- *      Open a new half-duplex channel to the DSP board.
- */
-int bridge_chnl_open(struct chnl_object **chnl,
-			    struct chnl_mgr *hchnl_mgr, s8 chnl_mode,
-			    u32 ch_id, const struct chnl_attr *pattrs)
-{
-	int status = 0;
-	struct chnl_mgr *chnl_mgr_obj = hchnl_mgr;
-	struct chnl_object *pchnl = NULL;
-	struct sync_object *sync_event = NULL;
-
-	*chnl = NULL;
-
-	/* Validate Args: */
-	if (!pattrs->uio_reqs)
-		return -EINVAL;
-
-	if (!hchnl_mgr)
-		return -EFAULT;
-
-	if (ch_id != CHNL_PICKFREE) {
-		if (ch_id >= chnl_mgr_obj->max_channels)
-			return -ECHRNG;
-		if (chnl_mgr_obj->channels[ch_id] != NULL)
-			return -EALREADY;
-	} else {
-		/* Check for free channel */
-		status = search_free_channel(chnl_mgr_obj, &ch_id);
-		if (status)
-			return status;
-	}
-
-
-	/* Create channel object: */
-	pchnl = kzalloc(sizeof(struct chnl_object), GFP_KERNEL);
-	if (!pchnl)
-		return -ENOMEM;
-
-	/* Protect queues from io_dpc: */
-	pchnl->state = CHNL_STATECANCEL;
-
-	/* Allocate initial IOR and IOC queues: */
-	status = create_chirp_list(&pchnl->free_packets_list,
-			pattrs->uio_reqs);
-	if (status)
-		goto out_err;
-
-	INIT_LIST_HEAD(&pchnl->io_requests);
-	INIT_LIST_HEAD(&pchnl->io_completions);
-
-	pchnl->chnl_packets = pattrs->uio_reqs;
-	pchnl->cio_cs = 0;
-	pchnl->cio_reqs = 0;
-
-	sync_event = kzalloc(sizeof(struct sync_object), GFP_KERNEL);
-	if (!sync_event) {
-		status = -ENOMEM;
-		goto out_err;
-	}
-	sync_init_event(sync_event);
-
-	pchnl->ntfy_obj = kmalloc(sizeof(struct ntfy_object), GFP_KERNEL);
-	if (!pchnl->ntfy_obj) {
-		status = -ENOMEM;
-		goto out_err;
-	}
-	ntfy_init(pchnl->ntfy_obj);
-
-	/* Initialize CHNL object fields: */
-	pchnl->chnl_mgr_obj = chnl_mgr_obj;
-	pchnl->chnl_id = ch_id;
-	pchnl->chnl_mode = chnl_mode;
-	pchnl->user_event = sync_event;
-	pchnl->sync_event = sync_event;
-	/* Get the process handle */
-	pchnl->process = current->tgid;
-	pchnl->cb_arg = 0;
-	pchnl->bytes_moved = 0;
-	/* Default to proc-copy */
-	pchnl->chnl_type = CHNL_PCPY;
-
-	/* Insert channel object in channel manager: */
-	chnl_mgr_obj->channels[pchnl->chnl_id] = pchnl;
-	spin_lock_bh(&chnl_mgr_obj->chnl_mgr_lock);
-	chnl_mgr_obj->open_channels++;
-	spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
-	/* Return result... */
-	pchnl->state = CHNL_STATEREADY;
-	*chnl = pchnl;
-
-	return status;
-
-out_err:
-	/* Free memory */
-	free_chirp_list(&pchnl->io_completions);
-	free_chirp_list(&pchnl->io_requests);
-	free_chirp_list(&pchnl->free_packets_list);
-
-	kfree(sync_event);
-
-	if (pchnl->ntfy_obj) {
-		ntfy_delete(pchnl->ntfy_obj);
-		kfree(pchnl->ntfy_obj);
-		pchnl->ntfy_obj = NULL;
-	}
-	kfree(pchnl);
-
-	return status;
-}
-
-/*
- *  ======== bridge_chnl_register_notify ========
- *      Registers for events on a particular channel.
- */
-int bridge_chnl_register_notify(struct chnl_object *chnl_obj,
-				    u32 event_mask, u32 notify_type,
-				    struct dsp_notification *hnotification)
-{
-	int status = 0;
-
-
-	if (event_mask)
-		status = ntfy_register(chnl_obj->ntfy_obj, hnotification,
-						event_mask, notify_type);
-	else
-		status = ntfy_unregister(chnl_obj->ntfy_obj, hnotification);
-
-	return status;
-}
-
-/*
- *  ======== create_chirp_list ========
- *  Purpose:
- *      Initialize a queue of channel I/O Request/Completion packets.
- *  Parameters:
- *      list:       Pointer to a list_head
- *      chirps:     Number of Chirps to allocate.
- *  Returns:
- *      0 if successful, error code otherwise.
- *  Requires:
- *  Ensures:
- */
-static int create_chirp_list(struct list_head *list, u32 chirps)
-{
-	struct chnl_irp *chirp;
-	u32 i;
-
-	INIT_LIST_HEAD(list);
-
-	/* Make N chirps and place on queue. */
-	for (i = 0; i < chirps; i++) {
-		chirp = kzalloc(sizeof(struct chnl_irp), GFP_KERNEL);
-		if (!chirp)
-			break;
-		list_add_tail(&chirp->link, list);
-	}
-
-	/* If we couldn't allocate all chirps, free those allocated: */
-	if (i != chirps) {
-		free_chirp_list(list);
-		return -ENOMEM;
-	}
-
-	return 0;
-}
-
-/*
- *  ======== free_chirp_list ========
- *  Purpose:
- *      Free the queue of Chirps.
- */
-static void free_chirp_list(struct list_head *chirp_list)
-{
-	struct chnl_irp *chirp, *tmp;
-
-	list_for_each_entry_safe(chirp, tmp, chirp_list, link) {
-		list_del(&chirp->link);
-		kfree(chirp);
-	}
-}
-
-/*
- *  ======== search_free_channel ========
- *      Search for a free channel slot in the array of channel pointers.
- */
-static int search_free_channel(struct chnl_mgr *chnl_mgr_obj,
-				      u32 *chnl)
-{
-	int status = -ENOSR;
-	u32 i;
-
-	for (i = 0; i < chnl_mgr_obj->max_channels; i++) {
-		if (chnl_mgr_obj->channels[i] == NULL) {
-			status = 0;
-			*chnl = i;
-			break;
-		}
-	}
-
-	return status;
-}
diff --git a/drivers/staging/tidspbridge/core/dsp-clock.c b/drivers/staging/tidspbridge/core/dsp-clock.c
deleted file mode 100644
index a1aca44..0000000
--- a/drivers/staging/tidspbridge/core/dsp-clock.c
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * clk.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Clock and Timer services.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#define L4_34XX_BASE		0x48000000
-
-#include <linux/types.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-#include <plat/dmtimer.h>
-#include <linux/platform_data/asoc-ti-mcbsp.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/drv.h>
-#include <dspbridge/dev.h>
-#include "_tiomap.h"
-
-/*  ----------------------------------- This */
-#include <dspbridge/clk.h>
-
-/*  ----------------------------------- Defines, Data Structures, Typedefs */
-
-#define OMAP_SSI_OFFSET			0x58000
-#define OMAP_SSI_SIZE			0x1000
-#define OMAP_SSI_SYSCONFIG_OFFSET	0x10
-
-#define SSI_AUTOIDLE			(1 << 0)
-#define SSI_SIDLE_SMARTIDLE		(2 << 3)
-#define SSI_MIDLE_NOIDLE		(1 << 12)
-
-/* Clk types requested by the dsp */
-#define IVA2_CLK	0
-#define GPT_CLK		1
-#define WDT_CLK		2
-#define MCBSP_CLK	3
-#define SSI_CLK		4
-
-/* Bridge GPT id (1 - 4), DM Timer id (5 - 8) */
-#define DMT_ID(id) ((id) + 4)
-#define DM_TIMER_CLOCKS		4
-
-/* Bridge MCBSP id (6 - 10), OMAP Mcbsp id (0 - 4) */
-#define MCBSP_ID(id) ((id) - 6)
-
-static struct omap_dm_timer *timer[4];
-
-struct clk *iva2_clk;
-
-struct dsp_ssi {
-	struct clk *sst_fck;
-	struct clk *ssr_fck;
-	struct clk *ick;
-};
-
-static struct dsp_ssi ssi;
-
-static u32 dsp_clocks;
-
-static inline u32 is_dsp_clk_active(u32 clk, u8 id)
-{
-	return clk & (1 << id);
-}
-
-static inline void set_dsp_clk_active(u32 *clk, u8 id)
-{
-	*clk |= (1 << id);
-}
-
-static inline void set_dsp_clk_inactive(u32 *clk, u8 id)
-{
-	*clk &= ~(1 << id);
-}
-
-static s8 get_clk_type(u8 id)
-{
-	s8 type;
-
-	if (id == DSP_CLK_IVA2)
-		type = IVA2_CLK;
-	else if (id <= DSP_CLK_GPT8)
-		type = GPT_CLK;
-	else if (id == DSP_CLK_WDT3)
-		type = WDT_CLK;
-	else if (id <= DSP_CLK_MCBSP5)
-		type = MCBSP_CLK;
-	else if (id == DSP_CLK_SSI)
-		type = SSI_CLK;
-	else
-		type = -1;
-
-	return type;
-}
-
-/*
- *  ======== dsp_clk_exit ========
- *  Purpose:
- *      Cleanup CLK module.
- */
-void dsp_clk_exit(void)
-{
-	int i;
-
-	dsp_clock_disable_all(dsp_clocks);
-
-	for (i = 0; i < DM_TIMER_CLOCKS; i++)
-		omap_dm_timer_free(timer[i]);
-
-	clk_unprepare(iva2_clk);
-	clk_put(iva2_clk);
-	clk_unprepare(ssi.sst_fck);
-	clk_put(ssi.sst_fck);
-	clk_unprepare(ssi.ssr_fck);
-	clk_put(ssi.ssr_fck);
-	clk_unprepare(ssi.ick);
-	clk_put(ssi.ick);
-}
-
-/*
- *  ======== dsp_clk_init ========
- *  Purpose:
- *      Initialize CLK module.
- */
-void dsp_clk_init(void)
-{
-	static struct platform_device dspbridge_device;
-	int i, id;
-
-	dspbridge_device.dev.bus = &platform_bus_type;
-
-	for (i = 0, id = 5; i < DM_TIMER_CLOCKS; i++, id++)
-		timer[i] = omap_dm_timer_request_specific(id);
-
-	iva2_clk = clk_get(&dspbridge_device.dev, "iva2_ck");
-	if (IS_ERR(iva2_clk))
-		dev_err(bridge, "failed to get iva2 clock %p\n", iva2_clk);
-	else
-		clk_prepare(iva2_clk);
-
-	ssi.sst_fck = clk_get(&dspbridge_device.dev, "ssi_sst_fck");
-	ssi.ssr_fck = clk_get(&dspbridge_device.dev, "ssi_ssr_fck");
-	ssi.ick = clk_get(&dspbridge_device.dev, "ssi_ick");
-
-	if (IS_ERR(ssi.sst_fck) || IS_ERR(ssi.ssr_fck) || IS_ERR(ssi.ick)) {
-		dev_err(bridge, "failed to get ssi: sst %p, ssr %p, ick %p\n",
-					ssi.sst_fck, ssi.ssr_fck, ssi.ick);
-	} else {
-		clk_prepare(ssi.sst_fck);
-		clk_prepare(ssi.ssr_fck);
-		clk_prepare(ssi.ick);
-	}
-}
-
-/**
- * dsp_gpt_wait_overflow - set gpt overflow and wait for fixed timeout
- * @clk_id:      GP Timer clock id.
- * @load:        Overflow value.
- *
- * Sets an overflow interrupt for the desired GPT waiting for a timeout
- * of 5 msecs for the interrupt to occur.
- */
-void dsp_gpt_wait_overflow(short int clk_id, unsigned int load)
-{
-	struct omap_dm_timer *gpt = timer[clk_id - 1];
-	unsigned long timeout;
-
-	if (!gpt)
-		return;
-
-	/* Enable overflow interrupt */
-	omap_dm_timer_set_int_enable(gpt, OMAP_TIMER_INT_OVERFLOW);
-
-	/*
-	 * Set counter value to overflow counter after
-	 * one tick and start timer.
-	 */
-	omap_dm_timer_set_load_start(gpt, 0, load);
-
-	/* Wait 80us for timer to overflow */
-	udelay(80);
-
-	timeout = msecs_to_jiffies(5);
-	/* Check interrupt status and wait for interrupt */
-	while (!(omap_dm_timer_read_status(gpt) & OMAP_TIMER_INT_OVERFLOW)) {
-		if (time_is_after_jiffies(timeout)) {
-			pr_err("%s: GPTimer interrupt failed\n", __func__);
-			break;
-		}
-	}
-}
-
-/*
- *  ======== dsp_clk_enable ========
- *  Purpose:
- *      Enable Clock .
- *
- */
-int dsp_clk_enable(enum dsp_clk_id clk_id)
-{
-	int status = 0;
-
-	if (is_dsp_clk_active(dsp_clocks, clk_id)) {
-		dev_err(bridge, "WARN: clock id %d already enabled\n", clk_id);
-		goto out;
-	}
-
-	switch (get_clk_type(clk_id)) {
-	case IVA2_CLK:
-		clk_enable(iva2_clk);
-		break;
-	case GPT_CLK:
-		status = omap_dm_timer_start(timer[clk_id - 1]);
-		break;
-#ifdef CONFIG_SND_OMAP_SOC_MCBSP
-	case MCBSP_CLK:
-		omap_mcbsp_request(MCBSP_ID(clk_id));
-		omap2_mcbsp_set_clks_src(MCBSP_ID(clk_id), MCBSP_CLKS_PAD_SRC);
-		break;
-#endif
-	case WDT_CLK:
-		dev_err(bridge, "ERROR: DSP requested to enable WDT3 clk\n");
-		break;
-	case SSI_CLK:
-		clk_enable(ssi.sst_fck);
-		clk_enable(ssi.ssr_fck);
-		clk_enable(ssi.ick);
-
-		/*
-		 * The SSI module need to configured not to have the Forced
-		 * idle for master interface. If it is set to forced idle,
-		 * the SSI module is transitioning to standby thereby causing
-		 * the client in the DSP hang waiting for the SSI module to
-		 * be active after enabling the clocks
-		 */
-		ssi_clk_prepare(true);
-		break;
-	default:
-		dev_err(bridge, "Invalid clock id for enable\n");
-		status = -EPERM;
-	}
-
-	if (!status)
-		set_dsp_clk_active(&dsp_clocks, clk_id);
-
-out:
-	return status;
-}
-
-/**
- * dsp_clock_enable_all - Enable clocks used by the DSP
- * @dev_context		Driver's device context strucure
- *
- * This function enables all the peripheral clocks that were requested by DSP.
- */
-u32 dsp_clock_enable_all(u32 dsp_per_clocks)
-{
-	u32 clk_id;
-	u32 status = -EPERM;
-
-	for (clk_id = 0; clk_id < DSP_CLK_NOT_DEFINED; clk_id++) {
-		if (is_dsp_clk_active(dsp_per_clocks, clk_id))
-			status = dsp_clk_enable(clk_id);
-	}
-
-	return status;
-}
-
-/*
- *  ======== dsp_clk_disable ========
- *  Purpose:
- *      Disable the clock.
- *
- */
-int dsp_clk_disable(enum dsp_clk_id clk_id)
-{
-	int status = 0;
-
-	if (!is_dsp_clk_active(dsp_clocks, clk_id)) {
-		dev_err(bridge, "ERR: clock id %d already disabled\n", clk_id);
-		goto out;
-	}
-
-	switch (get_clk_type(clk_id)) {
-	case IVA2_CLK:
-		clk_disable(iva2_clk);
-		break;
-	case GPT_CLK:
-		status = omap_dm_timer_stop(timer[clk_id - 1]);
-		break;
-#ifdef CONFIG_SND_OMAP_SOC_MCBSP
-	case MCBSP_CLK:
-		omap2_mcbsp_set_clks_src(MCBSP_ID(clk_id), MCBSP_CLKS_PRCM_SRC);
-		omap_mcbsp_free(MCBSP_ID(clk_id));
-		break;
-#endif
-	case WDT_CLK:
-		dev_err(bridge, "ERROR: DSP requested to disable WDT3 clk\n");
-		break;
-	case SSI_CLK:
-		ssi_clk_prepare(false);
-		ssi_clk_prepare(false);
-		clk_disable(ssi.sst_fck);
-		clk_disable(ssi.ssr_fck);
-		clk_disable(ssi.ick);
-		break;
-	default:
-		dev_err(bridge, "Invalid clock id for disable\n");
-		status = -EPERM;
-	}
-
-	if (!status)
-		set_dsp_clk_inactive(&dsp_clocks, clk_id);
-
-out:
-	return status;
-}
-
-/**
- * dsp_clock_disable_all - Disable all active clocks
- * @dev_context		Driver's device context structure
- *
- * This function disables all the peripheral clocks that were enabled by DSP.
- * It is meant to be called only when DSP is entering hibernation or when DSP
- * is in error state.
- */
-u32 dsp_clock_disable_all(u32 dsp_per_clocks)
-{
-	u32 clk_id;
-	u32 status = -EPERM;
-
-	for (clk_id = 0; clk_id < DSP_CLK_NOT_DEFINED; clk_id++) {
-		if (is_dsp_clk_active(dsp_per_clocks, clk_id))
-			status = dsp_clk_disable(clk_id);
-	}
-
-	return status;
-}
-
-u32 dsp_clk_get_iva2_rate(void)
-{
-	u32 clk_speed_khz;
-
-	clk_speed_khz = clk_get_rate(iva2_clk);
-	clk_speed_khz /= 1000;
-	dev_dbg(bridge, "%s: clk speed Khz = %d\n", __func__, clk_speed_khz);
-
-	return clk_speed_khz;
-}
-
-void ssi_clk_prepare(bool FLAG)
-{
-	void __iomem *ssi_base;
-	unsigned int value;
-
-	ssi_base = ioremap(L4_34XX_BASE + OMAP_SSI_OFFSET, OMAP_SSI_SIZE);
-	if (!ssi_base) {
-		pr_err("%s: error, SSI not configured\n", __func__);
-		return;
-	}
-
-	if (FLAG) {
-		/* Set Autoidle, SIDLEMode to smart idle, and MIDLEmode to
-		 * no idle
-		 */
-		value = SSI_AUTOIDLE | SSI_SIDLE_SMARTIDLE | SSI_MIDLE_NOIDLE;
-	} else {
-		/* Set Autoidle, SIDLEMode to forced idle, and MIDLEmode to
-		 * forced idle
-		 */
-		value = SSI_AUTOIDLE;
-	}
-
-	__raw_writel(value, ssi_base + OMAP_SSI_SYSCONFIG_OFFSET);
-	iounmap(ssi_base);
-}
-
diff --git a/drivers/staging/tidspbridge/core/io_sm.c b/drivers/staging/tidspbridge/core/io_sm.c
deleted file mode 100644
index 42f94e1..0000000
--- a/drivers/staging/tidspbridge/core/io_sm.c
+++ /dev/null
@@ -1,2246 +0,0 @@
-/*
- * io_sm.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * IO dispatcher for a shared memory channel driver.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
- * Channel Invariant:
- * There is an important invariant condition which must be maintained per
- * channel outside of bridge_chnl_get_ioc() and IO_Dispatch(), violation of
- * which may cause timeouts and/or failure of the sync_wait_on_event
- * function.
- */
-#include <linux/types.h>
-#include <linux/list.h>
-
-/* Host OS */
-#include <dspbridge/host_os.h>
-#include <linux/workqueue.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/* Services Layer */
-#include <dspbridge/ntfy.h>
-#include <dspbridge/sync.h>
-
-/* Hardware Abstraction Layer */
-#include <hw_defs.h>
-#include <hw_mmu.h>
-
-/* Bridge Driver */
-#include <dspbridge/dspdeh.h>
-#include <dspbridge/dspio.h>
-#include <dspbridge/dspioctl.h>
-#include <dspbridge/wdt.h>
-#include <_tiomap.h>
-#include <tiomap_io.h>
-#include <_tiomap_pwr.h>
-
-/* Platform Manager */
-#include <dspbridge/cod.h>
-#include <dspbridge/node.h>
-#include <dspbridge/dev.h>
-
-/* Others */
-#include <dspbridge/rms_sh.h>
-#include <dspbridge/mgr.h>
-#include <dspbridge/drv.h>
-#include "_cmm.h"
-#include "module_list.h"
-
-/* This */
-#include <dspbridge/io_sm.h>
-#include "_msg_sm.h"
-
-/* Defines, Data Structures, Typedefs */
-#define OUTPUTNOTREADY  0xffff
-#define NOTENABLED      0xffff	/* Channel(s) not enabled */
-
-#define EXTEND      "_EXT_END"
-
-#define SWAP_WORD(x)     (x)
-#define UL_PAGE_ALIGN_SIZE 0x10000	/* Page Align Size */
-
-#define MAX_PM_REQS 32
-
-#define MMU_FAULT_HEAD1 0xa5a5a5a5
-#define MMU_FAULT_HEAD2 0x96969696
-#define POLL_MAX 1000
-#define MAX_MMU_DBGBUFF 10240
-
-/* IO Manager: only one created per board */
-struct io_mgr {
-	/* These four fields must be the first fields in a io_mgr_ struct */
-	/* Bridge device context */
-	struct bridge_dev_context *bridge_context;
-	/* Function interface to Bridge driver */
-	struct bridge_drv_interface *intf_fxns;
-	struct dev_object *dev_obj;	/* Device this board represents */
-
-	/* These fields initialized in bridge_io_create() */
-	struct chnl_mgr *chnl_mgr;
-	struct shm *shared_mem;	/* Shared Memory control */
-	u8 *input;		/* Address of input channel */
-	u8 *output;		/* Address of output channel */
-	struct msg_mgr *msg_mgr;	/* Message manager */
-	/* Msg control for from DSP messages */
-	struct msg_ctrl *msg_input_ctrl;
-	/* Msg control for to DSP messages */
-	struct msg_ctrl *msg_output_ctrl;
-	u8 *msg_input;		/* Address of input messages */
-	u8 *msg_output;		/* Address of output messages */
-	u32 sm_buf_size;	/* Size of a shared memory I/O channel */
-	bool shared_irq;	/* Is this IRQ shared? */
-	u32 word_size;		/* Size in bytes of DSP word */
-	u16 intr_val;		/* Interrupt value */
-	/* Private extnd proc info; mmu setup */
-	struct mgr_processorextinfo ext_proc_info;
-	struct cmm_object *cmm_mgr;	/* Shared Mem Mngr */
-	struct work_struct io_workq;	/* workqueue */
-#if defined(CONFIG_TIDSPBRIDGE_BACKTRACE)
-	u32 trace_buffer_begin;	/* Trace message start address */
-	u32 trace_buffer_end;	/* Trace message end address */
-	u32 trace_buffer_current;	/* Trace message current address */
-	u32 gpp_read_pointer;		/* GPP Read pointer to Trace buffer */
-	u8 *msg;
-	u32 gpp_va;
-	u32 dsp_va;
-#endif
-	/* IO Dpc */
-	u32 dpc_req;		/* Number of requested DPC's. */
-	u32 dpc_sched;		/* Number of executed DPC's. */
-	struct tasklet_struct dpc_tasklet;
-	spinlock_t dpc_lock;
-
-};
-
-struct shm_symbol_val {
-	u32 shm_base;
-	u32 shm_lim;
-	u32 msg_base;
-	u32 msg_lim;
-	u32 shm0_end;
-	u32 dyn_ext;
-	u32 ext_end;
-};
-
-/* Function Prototypes */
-static void io_dispatch_pm(struct io_mgr *pio_mgr);
-static void notify_chnl_complete(struct chnl_object *pchnl,
-				 struct chnl_irp *chnl_packet_obj);
-static void input_chnl(struct io_mgr *pio_mgr, struct chnl_object *pchnl,
-			u8 io_mode);
-static void output_chnl(struct io_mgr *pio_mgr, struct chnl_object *pchnl,
-			u8 io_mode);
-static void input_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr);
-static void output_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr);
-static u32 find_ready_output(struct chnl_mgr *chnl_mgr_obj,
-			     struct chnl_object *pchnl, u32 mask);
-
-/* Bus Addr (cached kernel) */
-static int register_shm_segs(struct io_mgr *hio_mgr,
-				    struct cod_manager *cod_man,
-				    u32 dw_gpp_base_pa);
-
-static inline void set_chnl_free(struct shm *sm, u32 chnl)
-{
-	sm->host_free_mask &= ~(1 << chnl);
-}
-
-static inline void set_chnl_busy(struct shm *sm, u32 chnl)
-{
-	sm->host_free_mask |= 1 << chnl;
-}
-
-
-/*
- *  ======== bridge_io_create ========
- *      Create an IO manager object.
- */
-int bridge_io_create(struct io_mgr **io_man,
-			    struct dev_object *hdev_obj,
-			    const struct io_attrs *mgr_attrts)
-{
-	struct io_mgr *pio_mgr = NULL;
-	struct bridge_dev_context *hbridge_context = NULL;
-	struct cfg_devnode *dev_node_obj;
-	struct chnl_mgr *hchnl_mgr;
-	u8 dev_type;
-
-	/* Check requirements */
-	if (!io_man || !mgr_attrts || mgr_attrts->word_size == 0)
-		return -EFAULT;
-
-	*io_man = NULL;
-
-	dev_get_chnl_mgr(hdev_obj, &hchnl_mgr);
-	if (!hchnl_mgr || hchnl_mgr->iomgr)
-		return -EFAULT;
-
-	/*
-	 * Message manager will be created when a file is loaded, since
-	 * size of message buffer in shared memory is configurable in
-	 * the base image.
-	 */
-	dev_get_bridge_context(hdev_obj, &hbridge_context);
-	if (!hbridge_context)
-		return -EFAULT;
-
-	dev_get_dev_type(hdev_obj, &dev_type);
-
-	/* Allocate IO manager object */
-	pio_mgr = kzalloc(sizeof(struct io_mgr), GFP_KERNEL);
-	if (!pio_mgr)
-		return -ENOMEM;
-
-	/* Initialize chnl_mgr object */
-	pio_mgr->chnl_mgr = hchnl_mgr;
-	pio_mgr->word_size = mgr_attrts->word_size;
-
-	if (dev_type == DSP_UNIT) {
-		/* Create an IO DPC */
-		tasklet_init(&pio_mgr->dpc_tasklet, io_dpc, (u32) pio_mgr);
-
-		/* Initialize DPC counters */
-		pio_mgr->dpc_req = 0;
-		pio_mgr->dpc_sched = 0;
-
-		spin_lock_init(&pio_mgr->dpc_lock);
-
-		if (dev_get_dev_node(hdev_obj, &dev_node_obj)) {
-			bridge_io_destroy(pio_mgr);
-			return -EIO;
-		}
-	}
-
-	pio_mgr->bridge_context = hbridge_context;
-	pio_mgr->shared_irq = mgr_attrts->irq_shared;
-	if (dsp_wdt_init()) {
-		bridge_io_destroy(pio_mgr);
-		return -EPERM;
-	}
-
-	/* Return IO manager object to caller... */
-	hchnl_mgr->iomgr = pio_mgr;
-	*io_man = pio_mgr;
-
-	return 0;
-}
-
-/*
- *  ======== bridge_io_destroy ========
- *  Purpose:
- *      Disable interrupts, destroy the IO manager.
- */
-int bridge_io_destroy(struct io_mgr *hio_mgr)
-{
-	int status = 0;
-
-	if (hio_mgr) {
-		/* Free IO DPC object */
-		tasklet_kill(&hio_mgr->dpc_tasklet);
-
-#if defined(CONFIG_TIDSPBRIDGE_BACKTRACE)
-		kfree(hio_mgr->msg);
-#endif
-		dsp_wdt_exit();
-		/* Free this IO manager object */
-		kfree(hio_mgr);
-	} else {
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-struct shm_symbol_val *_get_shm_symbol_values(struct io_mgr *hio_mgr)
-{
-	struct shm_symbol_val *s;
-	struct cod_manager *cod_man;
-	int status;
-
-	s = kzalloc(sizeof(*s), GFP_KERNEL);
-	if (!s)
-		return ERR_PTR(-ENOMEM);
-
-	status = dev_get_cod_mgr(hio_mgr->dev_obj, &cod_man);
-	if (status)
-		goto free_symbol;
-
-	/* Get start and length of channel part of shared memory */
-	status = cod_get_sym_value(cod_man, CHNL_SHARED_BUFFER_BASE_SYM,
-				   &s->shm_base);
-	if (status)
-		goto free_symbol;
-
-	status = cod_get_sym_value(cod_man, CHNL_SHARED_BUFFER_LIMIT_SYM,
-				   &s->shm_lim);
-	if (status)
-		goto free_symbol;
-
-	if (s->shm_lim <= s->shm_base) {
-		status = -EINVAL;
-		goto free_symbol;
-	}
-
-	/* Get start and length of message part of shared memory */
-	status = cod_get_sym_value(cod_man, MSG_SHARED_BUFFER_BASE_SYM,
-				   &s->msg_base);
-	if (status)
-		goto free_symbol;
-
-	status = cod_get_sym_value(cod_man, MSG_SHARED_BUFFER_LIMIT_SYM,
-				   &s->msg_lim);
-	if (status)
-		goto free_symbol;
-
-	if (s->msg_lim <= s->msg_base) {
-		status = -EINVAL;
-		goto free_symbol;
-	}
-
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-	status = cod_get_sym_value(cod_man, DSP_TRACESEC_END, &s->shm0_end);
-#else
-	status = cod_get_sym_value(cod_man, SHM0_SHARED_END_SYM, &s->shm0_end);
-#endif
-	if (status)
-		goto free_symbol;
-
-	status = cod_get_sym_value(cod_man, DYNEXTBASE, &s->dyn_ext);
-	if (status)
-		goto free_symbol;
-
-	status = cod_get_sym_value(cod_man, EXTEND, &s->ext_end);
-	if (status)
-		goto free_symbol;
-
-	return s;
-
-free_symbol:
-	kfree(s);
-	return ERR_PTR(status);
-}
-
-/*
- *  ======== bridge_io_on_loaded ========
- *  Purpose:
- *      Called when a new program is loaded to get shared memory buffer
- *      parameters from COFF file. ulSharedBufferBase and ulSharedBufferLimit
- *      are in DSP address units.
- */
-int bridge_io_on_loaded(struct io_mgr *hio_mgr)
-{
-	struct bridge_dev_context *dc = hio_mgr->bridge_context;
-	struct cfg_hostres *cfg_res = dc->resources;
-	struct bridge_ioctl_extproc *eproc;
-	struct cod_manager *cod_man;
-	struct chnl_mgr *hchnl_mgr;
-	struct msg_mgr *hmsg_mgr;
-	struct shm_symbol_val *s;
-	int status;
-	u8 num_procs;
-	s32 ndx;
-	u32 i;
-	u32 mem_sz, msg_sz, pad_sz, shm_sz, shm_base_offs;
-	u32 seg0_sz, seg1_sz;
-	u32 pa, va, da;
-	u32 pa_curr, va_curr, da_curr;
-	u32 bytes;
-	u32 all_bits = 0;
-	u32 page_size[] = {
-		HW_PAGE_SIZE16MB, HW_PAGE_SIZE1MB,
-		HW_PAGE_SIZE64KB, HW_PAGE_SIZE4KB
-	};
-	u32 map_attrs = DSP_MAPLITTLEENDIAN | DSP_MAPPHYSICALADDR |
-			DSP_MAPELEMSIZE32 | DSP_MAPDONOTLOCK;
-
-	status = dev_get_cod_mgr(hio_mgr->dev_obj, &cod_man);
-	if (status)
-		return status;
-
-	hchnl_mgr = hio_mgr->chnl_mgr;
-
-	/* The message manager is destroyed when the board is stopped */
-	dev_get_msg_mgr(hio_mgr->dev_obj, &hio_mgr->msg_mgr);
-	hmsg_mgr = hio_mgr->msg_mgr;
-	if (!hchnl_mgr || !hmsg_mgr)
-		return -EFAULT;
-
-	if (hio_mgr->shared_mem)
-		hio_mgr->shared_mem = NULL;
-
-	s = _get_shm_symbol_values(hio_mgr);
-	if (IS_ERR(s))
-		return PTR_ERR(s);
-
-	/* Get total length in bytes */
-	shm_sz = (s->shm_lim - s->shm_base + 1) * hio_mgr->word_size;
-
-	/* Calculate size of a PROCCOPY shared memory region */
-	dev_dbg(bridge, "%s: (proc)proccopy shmmem size: 0x%x bytes\n",
-		__func__, shm_sz - sizeof(struct shm));
-
-	/* Length (bytes) of messaging part of shared memory */
-	msg_sz = (s->msg_lim - s->msg_base + 1) * hio_mgr->word_size;
-
-	/* Total length (bytes) of shared memory: chnl + msg */
-	mem_sz = shm_sz + msg_sz;
-
-	/* Get memory reserved in host resources */
-	(void)mgr_enum_processor_info(0,
-				      (struct dsp_processorinfo *)
-						&hio_mgr->ext_proc_info,
-				      sizeof(struct mgr_processorextinfo),
-				      &num_procs);
-
-	/* IO supports only one DSP for now */
-	if (num_procs != 1) {
-		status = -EINVAL;
-		goto free_symbol;
-	}
-
-	/* The first MMU TLB entry(TLB_0) in DCD is ShmBase */
-	pa = cfg_res->mem_phys[1];
-	va = cfg_res->mem_base[1];
-
-	/* This is the virtual uncached ioremapped address!!! */
-	/* Why can't we directly take the DSPVA from the symbols? */
-	da = hio_mgr->ext_proc_info.ty_tlb[0].dsp_virt;
-	seg0_sz = (s->shm0_end - da) * hio_mgr->word_size;
-	seg1_sz = (s->ext_end - s->dyn_ext) * hio_mgr->word_size;
-
-	/* 4K align */
-	seg1_sz = (seg1_sz + 0xFFF) & (~0xFFFUL);
-
-	/* 64K align */
-	seg0_sz = (seg0_sz + 0xFFFF) & (~0xFFFFUL);
-
-	pad_sz = UL_PAGE_ALIGN_SIZE - ((pa + seg1_sz) % UL_PAGE_ALIGN_SIZE);
-	if (pad_sz == UL_PAGE_ALIGN_SIZE)
-		pad_sz = 0x0;
-
-	dev_dbg(bridge, "%s: pa %x, va %x, da %x\n", __func__, pa, va, da);
-	dev_dbg(bridge,
-		"shm0_end %x, dyn_ext %x, ext_end %x, seg0_sz %x seg1_sz %x\n",
-		s->shm0_end, s->dyn_ext, s->ext_end, seg0_sz, seg1_sz);
-
-	if ((seg0_sz + seg1_sz + pad_sz) > cfg_res->mem_length[1]) {
-		pr_err("%s: shm Error, reserved 0x%x required 0x%x\n",
-		       __func__, cfg_res->mem_length[1],
-		       seg0_sz + seg1_sz + pad_sz);
-		status = -ENOMEM;
-		goto free_symbol;
-	}
-
-	pa_curr = pa;
-	va_curr = s->dyn_ext * hio_mgr->word_size;
-	da_curr = va;
-	bytes = seg1_sz;
-
-	/*
-	 * Try to fit into TLB entries. If not possible, push them to page
-	 * tables. It is quite possible that if sections are not on
-	 * bigger page boundary, we may end up making several small pages.
-	 * So, push them onto page tables, if that is the case.
-	 */
-	while (bytes) {
-		/*
-		 * To find the max. page size with which both PA & VA are
-		 * aligned.
-		 */
-		all_bits = pa_curr | va_curr;
-		dev_dbg(bridge,
-			"seg all_bits %x, pa_curr %x, va_curr %x, bytes %x\n",
-			all_bits, pa_curr, va_curr, bytes);
-
-		for (i = 0; i < 4; i++) {
-			if ((bytes >= page_size[i]) &&
-			    ((all_bits & (page_size[i] - 1)) == 0)) {
-				status = hio_mgr->intf_fxns->brd_mem_map(dc,
-							pa_curr, va_curr,
-							page_size[i], map_attrs,
-							NULL);
-				if (status)
-					goto free_symbol;
-
-				pa_curr += page_size[i];
-				va_curr += page_size[i];
-				da_curr += page_size[i];
-				bytes -= page_size[i];
-				/*
-				 * Don't try smaller sizes. Hopefully we have
-				 * reached an address aligned to a bigger page
-				 * size.
-				 */
-				break;
-			}
-		}
-	}
-
-	pa_curr += pad_sz;
-	va_curr += pad_sz;
-	da_curr += pad_sz;
-	bytes = seg0_sz;
-	va_curr = da * hio_mgr->word_size;
-
-	eproc = kzalloc(sizeof(*eproc) * BRDIOCTL_NUMOFMMUTLB, GFP_KERNEL);
-	if (!eproc) {
-		status = -ENOMEM;
-		goto free_symbol;
-	}
-
-	ndx = 0;
-	/* Configure the TLB entries for the next cacheable segment */
-	while (bytes) {
-		/*
-		 * To find the max. page size with which both PA & VA are
-		 * aligned.
-		 */
-		all_bits = pa_curr | va_curr;
-		dev_dbg(bridge,
-			"seg1 all_bits %x, pa_curr %x, va_curr %x, bytes %x\n",
-			all_bits, pa_curr, va_curr, bytes);
-
-		for (i = 0; i < 4; i++) {
-			if (!(bytes >= page_size[i]) ||
-			    !((all_bits & (page_size[i] - 1)) == 0))
-				continue;
-
-			if (ndx >= MAX_LOCK_TLB_ENTRIES) {
-				status = hio_mgr->intf_fxns->brd_mem_map(dc,
-							pa_curr, va_curr,
-							page_size[i], map_attrs,
-							NULL);
-				dev_dbg(bridge,
-					"PTE pa %x va %x dsp_va %x sz %x\n",
-					eproc[ndx].gpp_pa,
-					eproc[ndx].gpp_va,
-					eproc[ndx].dsp_va *
-					hio_mgr->word_size, page_size[i]);
-				if (status)
-					goto free_eproc;
-			}
-
-			/* This is the physical address written to DSP MMU */
-			eproc[ndx].gpp_pa = pa_curr;
-
-			/*
-			 * This is the virtual uncached ioremapped
-			 * address!!!
-			 */
-			eproc[ndx].gpp_va = da_curr;
-			eproc[ndx].dsp_va = va_curr / hio_mgr->word_size;
-			eproc[ndx].size = page_size[i];
-			eproc[ndx].endianism = HW_LITTLE_ENDIAN;
-			eproc[ndx].elem_size = HW_ELEM_SIZE16BIT;
-			eproc[ndx].mixed_mode = HW_MMU_CPUES;
-			dev_dbg(bridge, "%s: tlb pa %x va %x dsp_va %x sz %x\n",
-				__func__, eproc[ndx].gpp_pa,
-				eproc[ndx].gpp_va,
-				eproc[ndx].dsp_va * hio_mgr->word_size,
-				page_size[i]);
-			ndx++;
-
-			pa_curr += page_size[i];
-			va_curr += page_size[i];
-			da_curr += page_size[i];
-			bytes -= page_size[i];
-			/*
-			 * Don't try smaller sizes. Hopefully we have reached
-			 * an address aligned to a bigger page size.
-			 */
-			break;
-		}
-	}
-
-	/*
-	 * Copy remaining entries from CDB. All entries are 1 MB and
-	 * should not conflict with shm entries on MPU or DSP side.
-	 */
-	for (i = 3; i < 7 && ndx < BRDIOCTL_NUMOFMMUTLB; i++) {
-		struct mgr_processorextinfo *ep = &hio_mgr->ext_proc_info;
-		u32 word_sz = hio_mgr->word_size;
-
-		if (ep->ty_tlb[i].gpp_phys == 0)
-			continue;
-
-		if ((ep->ty_tlb[i].gpp_phys > pa - 0x100000 &&
-		     ep->ty_tlb[i].gpp_phys <= pa + seg0_sz) ||
-		    (ep->ty_tlb[i].dsp_virt > da - 0x100000 / word_sz &&
-		     ep->ty_tlb[i].dsp_virt <= da + seg0_sz / word_sz)) {
-			dev_dbg(bridge,
-				"err cdb%d pa %x da %x shm pa %x da %x sz %x\n",
-				i, ep->ty_tlb[i].gpp_phys,
-				ep->ty_tlb[i].dsp_virt, pa, da, seg0_sz);
-			status = -EPERM;
-			goto free_eproc;
-		}
-
-		if (ndx >= MAX_LOCK_TLB_ENTRIES) {
-			status = hio_mgr->intf_fxns->brd_mem_map(dc,
-						ep->ty_tlb[i].gpp_phys,
-						ep->ty_tlb[i].dsp_virt,
-						0x100000, map_attrs, NULL);
-			if (status)
-				goto free_eproc;
-		}
-
-		eproc[ndx].dsp_va = ep->ty_tlb[i].dsp_virt;
-		eproc[ndx].gpp_pa = ep->ty_tlb[i].gpp_phys;
-		eproc[ndx].gpp_va = 0;
-
-		/* 1 MB */
-		eproc[ndx].size = 0x100000;
-		dev_dbg(bridge, "shm MMU entry pa %x da 0x%x\n",
-			eproc[ndx].gpp_pa, eproc[ndx].dsp_va);
-		ndx++;
-	}
-
-	/* Map the L4 peripherals */
-	i = 0;
-	while (l4_peripheral_table[i].phys_addr) {
-		status = hio_mgr->intf_fxns->brd_mem_map(dc,
-					l4_peripheral_table[i].phys_addr,
-					l4_peripheral_table[i].dsp_virt_addr,
-					HW_PAGE_SIZE4KB, map_attrs, NULL);
-		if (status)
-			goto free_eproc;
-		i++;
-	}
-
-	for (i = ndx; i < BRDIOCTL_NUMOFMMUTLB; i++) {
-		eproc[i].dsp_va = 0;
-		eproc[i].gpp_pa = 0;
-		eproc[i].gpp_va = 0;
-		eproc[i].size = 0;
-	}
-
-	/*
-	 * Set the shm physical address entry (grayed out in CDB file)
-	 * to the virtual uncached ioremapped address of shm reserved
-	 * on MPU.
-	 */
-	hio_mgr->ext_proc_info.ty_tlb[0].gpp_phys =
-		(va + seg1_sz + pad_sz);
-
-	/*
-	 * Need shm Phys addr. IO supports only one DSP for now:
-	 * num_procs = 1.
-	 */
-	if (!hio_mgr->ext_proc_info.ty_tlb[0].gpp_phys)
-		return -EFAULT;
-
-	if (eproc[0].dsp_va > s->shm_base)
-		return -EPERM;
-
-	/* shm_base may not be at ul_dsp_va address */
-	shm_base_offs = (s->shm_base - eproc[0].dsp_va) *
-		    hio_mgr->word_size;
-	/*
-	 * bridge_dev_ctrl() will set dev context dsp-mmu info. In
-	 * bridge_brd_start() the MMU will be re-programed with MMU
-	 * DSPVa-GPPPa pair info while DSP is in a known
-	 * (reset) state.
-	 */
-	status = hio_mgr->intf_fxns->dev_cntrl(hio_mgr->bridge_context,
-					       BRDIOCTL_SETMMUCONFIG, eproc);
-	if (status)
-		goto free_eproc;
-
-	s->shm_base = hio_mgr->ext_proc_info.ty_tlb[0].gpp_phys;
-	s->shm_base += shm_base_offs;
-	s->shm_base = (u32) MEM_LINEAR_ADDRESS((void *)s->shm_base,
-					       mem_sz);
-	if (!s->shm_base) {
-		status = -EFAULT;
-		goto free_eproc;
-	}
-
-	/* Register SM */
-	status = register_shm_segs(hio_mgr, cod_man, eproc[0].gpp_pa);
-
-	hio_mgr->shared_mem = (struct shm *)s->shm_base;
-	hio_mgr->input = (u8 *) hio_mgr->shared_mem + sizeof(struct shm);
-	hio_mgr->output = hio_mgr->input + (shm_sz -
-					    sizeof(struct shm)) / 2;
-	hio_mgr->sm_buf_size = hio_mgr->output - hio_mgr->input;
-
-	/*  Set up Shared memory addresses for messaging */
-	hio_mgr->msg_input_ctrl =
-		(struct msg_ctrl *)((u8 *) hio_mgr->shared_mem + shm_sz);
-	hio_mgr->msg_input =
-		(u8 *) hio_mgr->msg_input_ctrl + sizeof(struct msg_ctrl);
-	hio_mgr->msg_output_ctrl =
-		(struct msg_ctrl *)((u8 *) hio_mgr->msg_input_ctrl +
-					   msg_sz / 2);
-	hio_mgr->msg_output =
-		(u8 *) hio_mgr->msg_output_ctrl + sizeof(struct msg_ctrl);
-	hmsg_mgr->max_msgs =
-		((u8 *) hio_mgr->msg_output_ctrl - hio_mgr->msg_input) /
-		sizeof(struct msg_dspmsg);
-
-	dev_dbg(bridge, "IO MGR shm details: shared_mem %p, input %p, "
-		"output %p, msg_input_ctrl %p, msg_input %p, "
-		"msg_output_ctrl %p, msg_output %p\n",
-		(u8 *) hio_mgr->shared_mem, hio_mgr->input,
-		hio_mgr->output, (u8 *) hio_mgr->msg_input_ctrl,
-		hio_mgr->msg_input, (u8 *) hio_mgr->msg_output_ctrl,
-		hio_mgr->msg_output);
-	dev_dbg(bridge, "(proc) Mas msgs in shared memory: 0x%x\n",
-		hmsg_mgr->max_msgs);
-	memset((void *)hio_mgr->shared_mem, 0, sizeof(struct shm));
-
-#if defined(CONFIG_TIDSPBRIDGE_BACKTRACE)
-	/* Get the start address of trace buffer */
-	status = cod_get_sym_value(cod_man, SYS_PUTCBEG,
-				   &hio_mgr->trace_buffer_begin);
-	if (status)
-		goto free_eproc;
-
-	hio_mgr->gpp_read_pointer =
-		hio_mgr->trace_buffer_begin =
-			(va + seg1_sz + pad_sz) +
-			(hio_mgr->trace_buffer_begin - da);
-
-	/* Get the end address of trace buffer */
-	status = cod_get_sym_value(cod_man, SYS_PUTCEND,
-				   &hio_mgr->trace_buffer_end);
-	if (status)
-		goto free_eproc;
-
-	hio_mgr->trace_buffer_end =
-		(va + seg1_sz + pad_sz) +
-		(hio_mgr->trace_buffer_end - da);
-
-	/* Get the current address of DSP write pointer */
-	status = cod_get_sym_value(cod_man, BRIDGE_SYS_PUTC_CURRENT,
-				   &hio_mgr->trace_buffer_current);
-	if (status)
-		goto free_eproc;
-
-	hio_mgr->trace_buffer_current =
-		(va + seg1_sz + pad_sz) +
-		(hio_mgr->trace_buffer_current - da);
-
-	/* Calculate the size of trace buffer */
-	kfree(hio_mgr->msg);
-	hio_mgr->msg = kmalloc(((hio_mgr->trace_buffer_end -
-				hio_mgr->trace_buffer_begin) *
-				hio_mgr->word_size) + 2, GFP_KERNEL);
-	if (!hio_mgr->msg) {
-		status = -ENOMEM;
-		goto free_eproc;
-	}
-
-	hio_mgr->dsp_va = da;
-	hio_mgr->gpp_va = (va + seg1_sz + pad_sz);
-#endif
-
-free_eproc:
-	kfree(eproc);
-free_symbol:
-	kfree(s);
-
-	return status;
-}
-
-/*
- *  ======== io_buf_size ========
- *      Size of shared memory I/O channel.
- */
-u32 io_buf_size(struct io_mgr *hio_mgr)
-{
-	if (hio_mgr)
-		return hio_mgr->sm_buf_size;
-	else
-		return 0;
-}
-
-/*
- *  ======== io_cancel_chnl ========
- *      Cancel IO on a given PCPY channel.
- */
-void io_cancel_chnl(struct io_mgr *hio_mgr, u32 chnl)
-{
-	struct io_mgr *pio_mgr = (struct io_mgr *)hio_mgr;
-	struct shm *sm;
-
-	if (!hio_mgr)
-		goto func_end;
-	sm = hio_mgr->shared_mem;
-
-	/* Inform DSP that we have no more buffers on this channel */
-	set_chnl_free(sm, chnl);
-
-	sm_interrupt_dsp(pio_mgr->bridge_context, MBX_PCPY_CLASS);
-func_end:
-	return;
-}
-
-
-/*
- *  ======== io_dispatch_pm ========
- *      Performs I/O dispatch on PM related messages from DSP
- */
-static void io_dispatch_pm(struct io_mgr *pio_mgr)
-{
-	int status;
-	u32 parg[2];
-
-	/* Perform Power message processing here */
-	parg[0] = pio_mgr->intr_val;
-
-	/* Send the command to the Bridge clk/pwr manager to handle */
-	if (parg[0] == MBX_PM_HIBERNATE_EN) {
-		dev_dbg(bridge, "PM: Hibernate command\n");
-		status = pio_mgr->intf_fxns->
-				dev_cntrl(pio_mgr->bridge_context,
-					      BRDIOCTL_PWR_HIBERNATE, parg);
-		if (status)
-			pr_err("%s: hibernate cmd failed 0x%x\n",
-				       __func__, status);
-	} else if (parg[0] == MBX_PM_OPP_REQ) {
-		parg[1] = pio_mgr->shared_mem->opp_request.rqst_opp_pt;
-		dev_dbg(bridge, "PM: Requested OPP = 0x%x\n", parg[1]);
-		status = pio_mgr->intf_fxns->
-				dev_cntrl(pio_mgr->bridge_context,
-					BRDIOCTL_CONSTRAINT_REQUEST, parg);
-		if (status)
-			dev_dbg(bridge, "PM: Failed to set constraint "
-				"= 0x%x\n", parg[1]);
-	} else {
-		dev_dbg(bridge, "PM: clk control value of msg = 0x%x\n",
-			parg[0]);
-		status = pio_mgr->intf_fxns->
-				dev_cntrl(pio_mgr->bridge_context,
-					      BRDIOCTL_CLK_CTRL, parg);
-		if (status)
-			dev_dbg(bridge, "PM: Failed to ctrl the DSP clk"
-				"= 0x%x\n", *parg);
-	}
-}
-
-/*
- *  ======== io_dpc ========
- *      Deferred procedure call for shared memory channel driver ISR.  Carries
- *      out the dispatch of I/O as a non-preemptible event. It can only be
- *      pre-empted by an ISR.
- */
-void io_dpc(unsigned long ref_data)
-{
-	struct io_mgr *pio_mgr = (struct io_mgr *)ref_data;
-	struct chnl_mgr *chnl_mgr_obj;
-	struct msg_mgr *msg_mgr_obj;
-	struct deh_mgr *hdeh_mgr;
-	u32 requested;
-	u32 serviced;
-
-	if (!pio_mgr)
-		goto func_end;
-	chnl_mgr_obj = pio_mgr->chnl_mgr;
-	dev_get_msg_mgr(pio_mgr->dev_obj, &msg_mgr_obj);
-	dev_get_deh_mgr(pio_mgr->dev_obj, &hdeh_mgr);
-	if (!chnl_mgr_obj)
-		goto func_end;
-
-	requested = pio_mgr->dpc_req;
-	serviced = pio_mgr->dpc_sched;
-
-	if (serviced == requested)
-		goto func_end;
-
-	/* Process pending DPC's */
-	do {
-		/* Check value of interrupt reg to ensure it's a valid error */
-		if ((pio_mgr->intr_val > DEH_BASE) &&
-		    (pio_mgr->intr_val < DEH_LIMIT)) {
-			/* Notify DSP/BIOS exception */
-			if (hdeh_mgr) {
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-				print_dsp_debug_trace(pio_mgr);
-#endif
-				bridge_deh_notify(hdeh_mgr, DSP_SYSERROR,
-						  pio_mgr->intr_val);
-			}
-		}
-		/* Proc-copy channel dispatch */
-		input_chnl(pio_mgr, NULL, IO_SERVICE);
-		output_chnl(pio_mgr, NULL, IO_SERVICE);
-
-#ifdef CHNL_MESSAGES
-		if (msg_mgr_obj) {
-			/* Perform I/O dispatch on message queues */
-			input_msg(pio_mgr, msg_mgr_obj);
-			output_msg(pio_mgr, msg_mgr_obj);
-		}
-
-#endif
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-		if (pio_mgr->intr_val & MBX_DBG_SYSPRINTF) {
-			/* Notify DSP Trace message */
-			print_dsp_debug_trace(pio_mgr);
-		}
-#endif
-		serviced++;
-	} while (serviced != requested);
-	pio_mgr->dpc_sched = requested;
-func_end:
-	return;
-}
-
-/*
- *  ======== io_mbox_msg ========
- *      Main interrupt handler for the shared memory IO manager.
- *      Calls the Bridge's CHNL_ISR to determine if this interrupt is ours, then
- *      schedules a DPC to dispatch I/O.
- */
-int io_mbox_msg(struct notifier_block *self, unsigned long len, void *msg)
-{
-	struct io_mgr *pio_mgr;
-	struct dev_object *dev_obj;
-	unsigned long flags;
-
-	dev_obj = dev_get_first();
-	dev_get_io_mgr(dev_obj, &pio_mgr);
-
-	if (!pio_mgr)
-		return NOTIFY_BAD;
-
-	pio_mgr->intr_val = (u16)((u32)msg);
-	if (pio_mgr->intr_val & MBX_PM_CLASS)
-		io_dispatch_pm(pio_mgr);
-
-	if (pio_mgr->intr_val == MBX_DEH_RESET) {
-		pio_mgr->intr_val = 0;
-	} else {
-		spin_lock_irqsave(&pio_mgr->dpc_lock, flags);
-		pio_mgr->dpc_req++;
-		spin_unlock_irqrestore(&pio_mgr->dpc_lock, flags);
-		tasklet_schedule(&pio_mgr->dpc_tasklet);
-	}
-	return NOTIFY_OK;
-}
-
-/*
- *  ======== io_request_chnl ========
- *  Purpose:
- *      Request channel I/O from the DSP. Sets flags in shared memory, then
- *      interrupts the DSP.
- */
-void io_request_chnl(struct io_mgr *io_manager, struct chnl_object *pchnl,
-			u8 io_mode, u16 *mbx_val)
-{
-	struct chnl_mgr *chnl_mgr_obj;
-	struct shm *sm;
-
-	if (!pchnl || !mbx_val)
-		goto func_end;
-	chnl_mgr_obj = io_manager->chnl_mgr;
-	sm = io_manager->shared_mem;
-	if (io_mode == IO_INPUT) {
-		/* Indicate to the DSP we have a buffer available for input */
-		set_chnl_busy(sm, pchnl->chnl_id);
-		*mbx_val = MBX_PCPY_CLASS;
-	} else if (io_mode == IO_OUTPUT) {
-		/*
-		 * Record the fact that we have a buffer available for
-		 * output.
-		 */
-		chnl_mgr_obj->output_mask |= (1 << pchnl->chnl_id);
-	} else {
-	}
-func_end:
-	return;
-}
-
-/*
- *  ======== iosm_schedule ========
- *      Schedule DPC for IO.
- */
-void iosm_schedule(struct io_mgr *io_manager)
-{
-	unsigned long flags;
-
-	if (!io_manager)
-		return;
-
-	/* Increment count of DPC's pending. */
-	spin_lock_irqsave(&io_manager->dpc_lock, flags);
-	io_manager->dpc_req++;
-	spin_unlock_irqrestore(&io_manager->dpc_lock, flags);
-
-	/* Schedule DPC */
-	tasklet_schedule(&io_manager->dpc_tasklet);
-}
-
-/*
- *  ======== find_ready_output ========
- *      Search for a host output channel which is ready to send.  If this is
- *      called as a result of servicing the DPC, then implement a round
- *      robin search; otherwise, this was called by a client thread (via
- *      IO_Dispatch()), so just start searching from the current channel id.
- */
-static u32 find_ready_output(struct chnl_mgr *chnl_mgr_obj,
-			     struct chnl_object *pchnl, u32 mask)
-{
-	u32 ret = OUTPUTNOTREADY;
-	u32 id, start_id;
-	u32 shift;
-
-	id = (pchnl !=
-	      NULL ? pchnl->chnl_id : (chnl_mgr_obj->last_output + 1));
-	id = ((id == CHNL_MAXCHANNELS) ? 0 : id);
-	if (id >= CHNL_MAXCHANNELS)
-		goto func_end;
-	if (mask) {
-		shift = (1 << id);
-		start_id = id;
-		do {
-			if (mask & shift) {
-				ret = id;
-				if (pchnl == NULL)
-					chnl_mgr_obj->last_output = id;
-				break;
-			}
-			id = id + 1;
-			id = ((id == CHNL_MAXCHANNELS) ? 0 : id);
-			shift = (1 << id);
-		} while (id != start_id);
-	}
-func_end:
-	return ret;
-}
-
-/*
- *  ======== input_chnl ========
- *      Dispatch a buffer on an input channel.
- */
-static void input_chnl(struct io_mgr *pio_mgr, struct chnl_object *pchnl,
-			u8 io_mode)
-{
-	struct chnl_mgr *chnl_mgr_obj;
-	struct shm *sm;
-	u32 chnl_id;
-	u32 bytes;
-	struct chnl_irp *chnl_packet_obj = NULL;
-	u32 dw_arg;
-	bool clear_chnl = false;
-	bool notify_client = false;
-
-	sm = pio_mgr->shared_mem;
-	chnl_mgr_obj = pio_mgr->chnl_mgr;
-
-	/* Attempt to perform input */
-	if (!sm->input_full)
-		goto func_end;
-
-	bytes = sm->input_size * chnl_mgr_obj->word_size;
-	chnl_id = sm->input_id;
-	dw_arg = sm->arg;
-	if (chnl_id >= CHNL_MAXCHANNELS) {
-		/* Shouldn't be here: would indicate corrupted shm. */
-		goto func_end;
-	}
-	pchnl = chnl_mgr_obj->channels[chnl_id];
-	if ((pchnl != NULL) && CHNL_IS_INPUT(pchnl->chnl_mode)) {
-		if ((pchnl->state & ~CHNL_STATEEOS) == CHNL_STATEREADY) {
-			/* Get the I/O request, and attempt a transfer */
-			if (!list_empty(&pchnl->io_requests)) {
-				if (!pchnl->cio_reqs)
-					goto func_end;
-
-				chnl_packet_obj = list_first_entry(
-						&pchnl->io_requests,
-						struct chnl_irp, link);
-				list_del(&chnl_packet_obj->link);
-				pchnl->cio_reqs--;
-
-				/*
-				 * Ensure we don't overflow the client's
-				 * buffer.
-				 */
-				bytes = min(bytes, chnl_packet_obj->byte_size);
-				memcpy(chnl_packet_obj->host_sys_buf,
-						pio_mgr->input, bytes);
-				pchnl->bytes_moved += bytes;
-				chnl_packet_obj->byte_size = bytes;
-				chnl_packet_obj->arg = dw_arg;
-				chnl_packet_obj->status = CHNL_IOCSTATCOMPLETE;
-
-				if (bytes == 0) {
-					/*
-					 * This assertion fails if the DSP
-					 * sends EOS more than once on this
-					 * channel.
-					 */
-					if (pchnl->state & CHNL_STATEEOS)
-						goto func_end;
-					/*
-					 * Zero bytes indicates EOS. Update
-					 * IOC status for this chirp, and also
-					 * the channel state.
-					 */
-					chnl_packet_obj->status |=
-						CHNL_IOCSTATEOS;
-					pchnl->state |= CHNL_STATEEOS;
-					/*
-					 * Notify that end of stream has
-					 * occurred.
-					 */
-					ntfy_notify(pchnl->ntfy_obj,
-							DSP_STREAMDONE);
-				}
-				/* Tell DSP if no more I/O buffers available */
-				if (list_empty(&pchnl->io_requests))
-					set_chnl_free(sm, pchnl->chnl_id);
-				clear_chnl = true;
-				notify_client = true;
-			} else {
-				/*
-				 * Input full for this channel, but we have no
-				 * buffers available.  The channel must be
-				 * "idling". Clear out the physical input
-				 * channel.
-				 */
-				clear_chnl = true;
-			}
-		} else {
-			/* Input channel cancelled: clear input channel */
-			clear_chnl = true;
-		}
-	} else {
-		/* DPC fired after host closed channel: clear input channel */
-		clear_chnl = true;
-	}
-	if (clear_chnl) {
-		/* Indicate to the DSP we have read the input */
-		sm->input_full = 0;
-		sm_interrupt_dsp(pio_mgr->bridge_context, MBX_PCPY_CLASS);
-	}
-	if (notify_client) {
-		/* Notify client with IO completion record */
-		notify_chnl_complete(pchnl, chnl_packet_obj);
-	}
-func_end:
-	return;
-}
-
-/*
- *  ======== input_msg ========
- *      Copies messages from shared memory to the message queues.
- */
-static void input_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
-{
-	u32 num_msgs;
-	u32 i;
-	u8 *msg_input;
-	struct msg_queue *msg_queue_obj;
-	struct msg_frame *pmsg;
-	struct msg_dspmsg msg;
-	struct msg_ctrl *msg_ctr_obj;
-	u32 input_empty;
-	u32 addr;
-
-	msg_ctr_obj = pio_mgr->msg_input_ctrl;
-	/* Get the number of input messages to be read */
-	input_empty = msg_ctr_obj->buf_empty;
-	num_msgs = msg_ctr_obj->size;
-	if (input_empty)
-		return;
-
-	msg_input = pio_mgr->msg_input;
-	for (i = 0; i < num_msgs; i++) {
-		/* Read the next message */
-		addr = (u32) &(((struct msg_dspmsg *)msg_input)->msg.cmd);
-		msg.msg.cmd =
-			read_ext32_bit_dsp_data(pio_mgr->bridge_context, addr);
-		addr = (u32) &(((struct msg_dspmsg *)msg_input)->msg.arg1);
-		msg.msg.arg1 =
-			read_ext32_bit_dsp_data(pio_mgr->bridge_context, addr);
-		addr = (u32) &(((struct msg_dspmsg *)msg_input)->msg.arg2);
-		msg.msg.arg2 =
-			read_ext32_bit_dsp_data(pio_mgr->bridge_context, addr);
-		addr = (u32) &(((struct msg_dspmsg *)msg_input)->msgq_id);
-		msg.msgq_id =
-			read_ext32_bit_dsp_data(pio_mgr->bridge_context, addr);
-		msg_input += sizeof(struct msg_dspmsg);
-
-		/* Determine which queue to put the message in */
-		dev_dbg(bridge,	"input msg: cmd=0x%x arg1=0x%x "
-				"arg2=0x%x msgq_id=0x%x\n", msg.msg.cmd,
-				msg.msg.arg1, msg.msg.arg2, msg.msgq_id);
-		/*
-		 * Interrupt may occur before shared memory and message
-		 * input locations have been set up. If all nodes were
-		 * cleaned up, hmsg_mgr->max_msgs should be 0.
-		 */
-		list_for_each_entry(msg_queue_obj, &hmsg_mgr->queue_list,
-				list_elem) {
-			if (msg.msgq_id != msg_queue_obj->msgq_id)
-				continue;
-			/* Found it */
-			if (msg.msg.cmd == RMS_EXITACK) {
-				/*
-				 * Call the node exit notification.
-				 * The exit message does not get
-				 * queued.
-				 */
-				(*hmsg_mgr->on_exit)(msg_queue_obj->arg,
-						msg.msg.arg1);
-				break;
-			}
-			/*
-			 * Not an exit acknowledgement, queue
-			 * the message.
-			 */
-			if (list_empty(&msg_queue_obj->msg_free_list)) {
-				/*
-				 * No free frame to copy the
-				 * message into.
-				 */
-				pr_err("%s: no free msg frames,"
-						" discarding msg\n",
-						__func__);
-				break;
-			}
-
-			pmsg = list_first_entry(&msg_queue_obj->msg_free_list,
-					struct msg_frame, list_elem);
-			list_del(&pmsg->list_elem);
-			pmsg->msg_data = msg;
-			list_add_tail(&pmsg->list_elem,
-					&msg_queue_obj->msg_used_list);
-			ntfy_notify(msg_queue_obj->ntfy_obj,
-					DSP_NODEMESSAGEREADY);
-			sync_set_event(msg_queue_obj->sync_event);
-		}
-	}
-	/* Set the post SWI flag */
-	if (num_msgs > 0) {
-		/* Tell the DSP we've read the messages */
-		msg_ctr_obj->buf_empty = true;
-		msg_ctr_obj->post_swi = true;
-		sm_interrupt_dsp(pio_mgr->bridge_context, MBX_PCPY_CLASS);
-	}
-}
-
-/*
- *  ======== notify_chnl_complete ========
- *  Purpose:
- *      Signal the channel event, notifying the client that I/O has completed.
- */
-static void notify_chnl_complete(struct chnl_object *pchnl,
-				 struct chnl_irp *chnl_packet_obj)
-{
-	bool signal_event;
-
-	if (!pchnl || !pchnl->sync_event || !chnl_packet_obj)
-		goto func_end;
-
-	/*
-	 * Note: we signal the channel event only if the queue of IO
-	 * completions is empty.  If it is not empty, the event is sure to be
-	 * signalled by the only IO completion list consumer:
-	 * bridge_chnl_get_ioc().
-	 */
-	signal_event = list_empty(&pchnl->io_completions);
-	/* Enqueue the IO completion info for the client */
-	list_add_tail(&chnl_packet_obj->link, &pchnl->io_completions);
-	pchnl->cio_cs++;
-
-	if (pchnl->cio_cs > pchnl->chnl_packets)
-		goto func_end;
-	/* Signal the channel event (if not already set) that IO is complete */
-	if (signal_event)
-		sync_set_event(pchnl->sync_event);
-
-	/* Notify that IO is complete */
-	ntfy_notify(pchnl->ntfy_obj, DSP_STREAMIOCOMPLETION);
-func_end:
-	return;
-}
-
-/*
- *  ======== output_chnl ========
- *  Purpose:
- *      Dispatch a buffer on an output channel.
- */
-static void output_chnl(struct io_mgr *pio_mgr, struct chnl_object *pchnl,
-			u8 io_mode)
-{
-	struct chnl_mgr *chnl_mgr_obj;
-	struct shm *sm;
-	u32 chnl_id;
-	struct chnl_irp *chnl_packet_obj;
-	u32 dw_dsp_f_mask;
-
-	chnl_mgr_obj = pio_mgr->chnl_mgr;
-	sm = pio_mgr->shared_mem;
-	/* Attempt to perform output */
-	if (sm->output_full)
-		goto func_end;
-
-	if (pchnl && !((pchnl->state & ~CHNL_STATEEOS) == CHNL_STATEREADY))
-		goto func_end;
-
-	/* Look to see if both a PC and DSP output channel are ready */
-	dw_dsp_f_mask = sm->dsp_free_mask;
-	chnl_id =
-	    find_ready_output(chnl_mgr_obj, pchnl,
-			      (chnl_mgr_obj->output_mask & dw_dsp_f_mask));
-	if (chnl_id == OUTPUTNOTREADY)
-		goto func_end;
-
-	pchnl = chnl_mgr_obj->channels[chnl_id];
-	if (!pchnl || list_empty(&pchnl->io_requests)) {
-		/* Shouldn't get here */
-		goto func_end;
-	}
-
-	if (!pchnl->cio_reqs)
-		goto func_end;
-
-	/* Get the I/O request, and attempt a transfer */
-	chnl_packet_obj = list_first_entry(&pchnl->io_requests,
-			struct chnl_irp, link);
-	list_del(&chnl_packet_obj->link);
-
-	pchnl->cio_reqs--;
-
-	/* Record fact that no more I/O buffers available */
-	if (list_empty(&pchnl->io_requests))
-		chnl_mgr_obj->output_mask &= ~(1 << chnl_id);
-
-	/* Transfer buffer to DSP side */
-	chnl_packet_obj->byte_size = min(pio_mgr->sm_buf_size,
-					chnl_packet_obj->byte_size);
-	memcpy(pio_mgr->output,	chnl_packet_obj->host_sys_buf,
-					chnl_packet_obj->byte_size);
-	pchnl->bytes_moved += chnl_packet_obj->byte_size;
-	/* Write all 32 bits of arg */
-	sm->arg = chnl_packet_obj->arg;
-#if _CHNL_WORDSIZE == 2
-	/* Access can be different SM access word size (e.g. 16/32 bit words) */
-	sm->output_id = (u16) chnl_id;
-	sm->output_size = (u16) (chnl_packet_obj->byte_size +
-				chnl_mgr_obj->word_size - 1) /
-				(u16) chnl_mgr_obj->word_size;
-#else
-	sm->output_id = chnl_id;
-	sm->output_size = (chnl_packet_obj->byte_size +
-			chnl_mgr_obj->word_size - 1) / chnl_mgr_obj->word_size;
-#endif
-	sm->output_full =  1;
-	/* Indicate to the DSP we have written the output */
-	sm_interrupt_dsp(pio_mgr->bridge_context, MBX_PCPY_CLASS);
-	/* Notify client with IO completion record (keep EOS) */
-	chnl_packet_obj->status &= CHNL_IOCSTATEOS;
-	notify_chnl_complete(pchnl, chnl_packet_obj);
-	/* Notify if stream is done. */
-	if (chnl_packet_obj->status & CHNL_IOCSTATEOS)
-		ntfy_notify(pchnl->ntfy_obj, DSP_STREAMDONE);
-
-func_end:
-	return;
-}
-
-/*
- *  ======== output_msg ========
- *      Copies messages from the message queues to the shared memory.
- */
-static void output_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
-{
-	u32 num_msgs = 0;
-	u32 i;
-	struct msg_dspmsg *msg_output;
-	struct msg_frame *pmsg;
-	struct msg_ctrl *msg_ctr_obj;
-	u32 val;
-	u32 addr;
-
-	msg_ctr_obj = pio_mgr->msg_output_ctrl;
-
-	/* Check if output has been cleared */
-	if (!msg_ctr_obj->buf_empty)
-		return;
-
-	num_msgs = (hmsg_mgr->msgs_pending > hmsg_mgr->max_msgs) ?
-		hmsg_mgr->max_msgs : hmsg_mgr->msgs_pending;
-	msg_output = (struct msg_dspmsg *) pio_mgr->msg_output;
-
-	/* Copy num_msgs messages into shared memory */
-	for (i = 0; i < num_msgs; i++) {
-		if (list_empty(&hmsg_mgr->msg_used_list))
-			continue;
-
-		pmsg = list_first_entry(&hmsg_mgr->msg_used_list,
-				struct msg_frame, list_elem);
-		list_del(&pmsg->list_elem);
-
-		val = (pmsg->msg_data).msgq_id;
-		addr = (u32) &msg_output->msgq_id;
-		write_ext32_bit_dsp_data(pio_mgr->bridge_context, addr, val);
-
-		val = (pmsg->msg_data).msg.cmd;
-		addr = (u32) &msg_output->msg.cmd;
-		write_ext32_bit_dsp_data(pio_mgr->bridge_context, addr, val);
-
-		val = (pmsg->msg_data).msg.arg1;
-		addr = (u32) &msg_output->msg.arg1;
-		write_ext32_bit_dsp_data(pio_mgr->bridge_context, addr, val);
-
-		val = (pmsg->msg_data).msg.arg2;
-		addr = (u32) &msg_output->msg.arg2;
-		write_ext32_bit_dsp_data(pio_mgr->bridge_context, addr, val);
-
-		msg_output++;
-		list_add_tail(&pmsg->list_elem, &hmsg_mgr->msg_free_list);
-		sync_set_event(hmsg_mgr->sync_event);
-	}
-
-	if (num_msgs > 0) {
-		hmsg_mgr->msgs_pending -= num_msgs;
-#if _CHNL_WORDSIZE == 2
-		/*
-		 * Access can be different SM access word size
-		 * (e.g. 16/32 bit words)
-		 */
-		msg_ctr_obj->size = (u16) num_msgs;
-#else
-		msg_ctr_obj->size = num_msgs;
-#endif
-		msg_ctr_obj->buf_empty = false;
-		/* Set the post SWI flag */
-		msg_ctr_obj->post_swi = true;
-		/* Tell the DSP we have written the output. */
-		sm_interrupt_dsp(pio_mgr->bridge_context, MBX_PCPY_CLASS);
-	}
-}
-
-/*
- *  ======== register_shm_segs ========
- *  purpose:
- *      Registers GPP SM segment with CMM.
- */
-static int register_shm_segs(struct io_mgr *hio_mgr,
-				    struct cod_manager *cod_man,
-				    u32 dw_gpp_base_pa)
-{
-	int status = 0;
-	u32 ul_shm0_base = 0;
-	u32 shm0_end = 0;
-	u32 ul_shm0_rsrvd_start = 0;
-	u32 ul_rsrvd_size = 0;
-	u32 ul_gpp_phys;
-	u32 ul_dsp_virt;
-	u32 ul_shm_seg_id0 = 0;
-	u32 dw_offset, dw_gpp_base_va, ul_dsp_size;
-
-	/*
-	 * Read address and size info for first SM region.
-	 * Get start of 1st SM Heap region.
-	 */
-	status =
-	    cod_get_sym_value(cod_man, SHM0_SHARED_BASE_SYM, &ul_shm0_base);
-	if (ul_shm0_base == 0) {
-		status = -EPERM;
-		goto func_end;
-	}
-	/* Get end of 1st SM Heap region */
-	if (!status) {
-		/* Get start and length of message part of shared memory */
-		status = cod_get_sym_value(cod_man, SHM0_SHARED_END_SYM,
-					   &shm0_end);
-		if (shm0_end == 0) {
-			status = -EPERM;
-			goto func_end;
-		}
-	}
-	/* Start of Gpp reserved region */
-	if (!status) {
-		/* Get start and length of message part of shared memory */
-		status =
-		    cod_get_sym_value(cod_man, SHM0_SHARED_RESERVED_BASE_SYM,
-				      &ul_shm0_rsrvd_start);
-		if (ul_shm0_rsrvd_start == 0) {
-			status = -EPERM;
-			goto func_end;
-		}
-	}
-	/* Register with CMM */
-	if (!status) {
-		status = dev_get_cmm_mgr(hio_mgr->dev_obj, &hio_mgr->cmm_mgr);
-		if (!status) {
-			status = cmm_un_register_gppsm_seg(hio_mgr->cmm_mgr,
-							   CMM_ALLSEGMENTS);
-		}
-	}
-	/* Register new SM region(s) */
-	if (!status && (shm0_end - ul_shm0_base) > 0) {
-		/* Calc size (bytes) of SM the GPP can alloc from */
-		ul_rsrvd_size =
-		    (shm0_end - ul_shm0_rsrvd_start + 1) * hio_mgr->word_size;
-		if (ul_rsrvd_size <= 0) {
-			status = -EPERM;
-			goto func_end;
-		}
-		/* Calc size of SM DSP can alloc from */
-		ul_dsp_size =
-		    (ul_shm0_rsrvd_start - ul_shm0_base) * hio_mgr->word_size;
-		if (ul_dsp_size <= 0) {
-			status = -EPERM;
-			goto func_end;
-		}
-		/* First TLB entry reserved for Bridge SM use. */
-		ul_gpp_phys = hio_mgr->ext_proc_info.ty_tlb[0].gpp_phys;
-		/* Get size in bytes */
-		ul_dsp_virt =
-		    hio_mgr->ext_proc_info.ty_tlb[0].dsp_virt *
-		    hio_mgr->word_size;
-		/*
-		 * Calc byte offset used to convert GPP phys <-> DSP byte
-		 * address.
-		 */
-		if (dw_gpp_base_pa > ul_dsp_virt)
-			dw_offset = dw_gpp_base_pa - ul_dsp_virt;
-		else
-			dw_offset = ul_dsp_virt - dw_gpp_base_pa;
-
-		if (ul_shm0_rsrvd_start * hio_mgr->word_size < ul_dsp_virt) {
-			status = -EPERM;
-			goto func_end;
-		}
-		/*
-		 * Calc Gpp phys base of SM region.
-		 * This is actually uncached kernel virtual address.
-		 */
-		dw_gpp_base_va =
-		    ul_gpp_phys + ul_shm0_rsrvd_start * hio_mgr->word_size -
-		    ul_dsp_virt;
-		/*
-		 * Calc Gpp phys base of SM region.
-		 * This is the physical address.
-		 */
-		dw_gpp_base_pa =
-		    dw_gpp_base_pa + ul_shm0_rsrvd_start * hio_mgr->word_size -
-		    ul_dsp_virt;
-		/* Register SM Segment 0. */
-		status =
-		    cmm_register_gppsm_seg(hio_mgr->cmm_mgr, dw_gpp_base_pa,
-					   ul_rsrvd_size, dw_offset,
-					   (dw_gpp_base_pa >
-					    ul_dsp_virt) ? CMM_ADDTODSPPA :
-					   CMM_SUBFROMDSPPA,
-					   (u32) (ul_shm0_base *
-						  hio_mgr->word_size),
-					   ul_dsp_size, &ul_shm_seg_id0,
-					   dw_gpp_base_va);
-		/* First SM region is seg_id = 1 */
-		if (ul_shm_seg_id0 != 1)
-			status = -EPERM;
-	}
-func_end:
-	return status;
-}
-
-/* ZCPY IO routines. */
-/*
- *  ======== IO_SHMcontrol ========
- *      Sets the requested shm setting.
- */
-int io_sh_msetting(struct io_mgr *hio_mgr, u8 desc, void *pargs)
-{
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-	u32 i;
-	struct dspbridge_platform_data *pdata =
-	    omap_dspbridge_dev->dev.platform_data;
-
-	switch (desc) {
-	case SHM_CURROPP:
-		/* Update the shared memory with requested OPP information */
-		if (pargs != NULL)
-			hio_mgr->shared_mem->opp_table_struct.curr_opp_pt =
-			    *(u32 *) pargs;
-		else
-			return -EPERM;
-		break;
-	case SHM_OPPINFO:
-		/*
-		 * Update the shared memory with the voltage, frequency,
-		 * min and max frequency values for an OPP.
-		 */
-		for (i = 0; i <= dsp_max_opps; i++) {
-			hio_mgr->shared_mem->opp_table_struct.opp_point[i].
-			    voltage = vdd1_dsp_freq[i][0];
-			dev_dbg(bridge, "OPP-shm: voltage: %d\n",
-				vdd1_dsp_freq[i][0]);
-			hio_mgr->shared_mem->opp_table_struct.
-			    opp_point[i].frequency = vdd1_dsp_freq[i][1];
-			dev_dbg(bridge, "OPP-shm: frequency: %d\n",
-				vdd1_dsp_freq[i][1]);
-			hio_mgr->shared_mem->opp_table_struct.opp_point[i].
-			    min_freq = vdd1_dsp_freq[i][2];
-			dev_dbg(bridge, "OPP-shm: min freq: %d\n",
-				vdd1_dsp_freq[i][2]);
-			hio_mgr->shared_mem->opp_table_struct.opp_point[i].
-			    max_freq = vdd1_dsp_freq[i][3];
-			dev_dbg(bridge, "OPP-shm: max freq: %d\n",
-				vdd1_dsp_freq[i][3]);
-		}
-		hio_mgr->shared_mem->opp_table_struct.num_opp_pts =
-		    dsp_max_opps;
-		dev_dbg(bridge, "OPP-shm: max OPP number: %d\n", dsp_max_opps);
-		/* Update the current OPP number */
-		if (pdata->dsp_get_opp)
-			i = (*pdata->dsp_get_opp) ();
-		hio_mgr->shared_mem->opp_table_struct.curr_opp_pt = i;
-		dev_dbg(bridge, "OPP-shm: value programmed = %d\n", i);
-		break;
-	case SHM_GETOPP:
-		/* Get the OPP that DSP has requested */
-		*(u32 *) pargs = hio_mgr->shared_mem->opp_request.rqst_opp_pt;
-		break;
-	default:
-		break;
-	}
-#endif
-	return 0;
-}
-
-/*
- *  ======== bridge_io_get_proc_load ========
- *      Gets the Processor's Load information
- */
-int bridge_io_get_proc_load(struct io_mgr *hio_mgr,
-				struct dsp_procloadstat *proc_lstat)
-{
-	if (!hio_mgr->shared_mem)
-		return -EFAULT;
-
-	proc_lstat->curr_load =
-			hio_mgr->shared_mem->load_mon_info.curr_dsp_load;
-	proc_lstat->predicted_load =
-	    hio_mgr->shared_mem->load_mon_info.pred_dsp_load;
-	proc_lstat->curr_dsp_freq =
-	    hio_mgr->shared_mem->load_mon_info.curr_dsp_freq;
-	proc_lstat->predicted_freq =
-	    hio_mgr->shared_mem->load_mon_info.pred_dsp_freq;
-
-	dev_dbg(bridge, "Curr Load = %d, Pred Load = %d, Curr Freq = %d, "
-		"Pred Freq = %d\n", proc_lstat->curr_load,
-		proc_lstat->predicted_load, proc_lstat->curr_dsp_freq,
-		proc_lstat->predicted_freq);
-	return 0;
-}
-
-
-#if defined(CONFIG_TIDSPBRIDGE_BACKTRACE)
-void print_dsp_debug_trace(struct io_mgr *hio_mgr)
-{
-	u32 ul_new_message_length = 0, ul_gpp_cur_pointer;
-
-	while (true) {
-		/* Get the DSP current pointer */
-		ul_gpp_cur_pointer =
-		    *(u32 *) (hio_mgr->trace_buffer_current);
-		ul_gpp_cur_pointer =
-		    hio_mgr->gpp_va + (ul_gpp_cur_pointer -
-					  hio_mgr->dsp_va);
-
-		/* No new debug messages available yet */
-		if (ul_gpp_cur_pointer == hio_mgr->gpp_read_pointer) {
-			break;
-		} else if (ul_gpp_cur_pointer > hio_mgr->gpp_read_pointer) {
-			/* Continuous data */
-			ul_new_message_length =
-			    ul_gpp_cur_pointer - hio_mgr->gpp_read_pointer;
-
-			memcpy(hio_mgr->msg,
-			       (char *)hio_mgr->gpp_read_pointer,
-			       ul_new_message_length);
-			hio_mgr->msg[ul_new_message_length] = '\0';
-			/*
-			 * Advance the GPP trace pointer to DSP current
-			 * pointer.
-			 */
-			hio_mgr->gpp_read_pointer += ul_new_message_length;
-			/* Print the trace messages */
-			pr_info("DSPTrace: %s\n", hio_mgr->msg);
-		} else if (ul_gpp_cur_pointer < hio_mgr->gpp_read_pointer) {
-			/* Handle trace buffer wraparound */
-			memcpy(hio_mgr->msg,
-			       (char *)hio_mgr->gpp_read_pointer,
-			       hio_mgr->trace_buffer_end -
-			       hio_mgr->gpp_read_pointer);
-			ul_new_message_length =
-			    ul_gpp_cur_pointer - hio_mgr->trace_buffer_begin;
-			memcpy(&hio_mgr->msg[hio_mgr->trace_buffer_end -
-					      hio_mgr->gpp_read_pointer],
-			       (char *)hio_mgr->trace_buffer_begin,
-			       ul_new_message_length);
-			hio_mgr->msg[hio_mgr->trace_buffer_end -
-				      hio_mgr->gpp_read_pointer +
-				      ul_new_message_length] = '\0';
-			/*
-			 * Advance the GPP trace pointer to DSP current
-			 * pointer.
-			 */
-			hio_mgr->gpp_read_pointer =
-			    hio_mgr->trace_buffer_begin +
-			    ul_new_message_length;
-			/* Print the trace messages */
-			pr_info("DSPTrace: %s\n", hio_mgr->msg);
-		}
-	}
-}
-#endif
-
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-/*
- *  ======== print_dsp_trace_buffer ========
- *      Prints the trace buffer returned from the DSP (if DBG_Trace is enabled).
- *  Parameters:
- *    hdeh_mgr:          Handle to DEH manager object
- *                      number of extra carriage returns to generate.
- *  Returns:
- *      0:        Success.
- *      -ENOMEM:    Unable to allocate memory.
- *  Requires:
- *      hdeh_mgr muse be valid. Checked in bridge_deh_notify.
- */
-int print_dsp_trace_buffer(struct bridge_dev_context *hbridge_context)
-{
-	int status = 0;
-	struct cod_manager *cod_mgr;
-	u32 ul_trace_end;
-	u32 ul_trace_begin;
-	u32 trace_cur_pos;
-	u32 ul_num_bytes = 0;
-	u32 ul_num_words = 0;
-	u32 ul_word_size = 2;
-	char *psz_buf;
-	char *str_beg;
-	char *trace_end;
-	char *buf_end;
-	char *new_line;
-
-	struct bridge_dev_context *pbridge_context = hbridge_context;
-	struct bridge_drv_interface *intf_fxns;
-	struct dev_object *dev_obj = (struct dev_object *)
-	    pbridge_context->dev_obj;
-
-	status = dev_get_cod_mgr(dev_obj, &cod_mgr);
-
-	if (cod_mgr) {
-		/* Look for SYS_PUTCBEG/SYS_PUTCEND */
-		status =
-		    cod_get_sym_value(cod_mgr, COD_TRACEBEG, &ul_trace_begin);
-	} else {
-		status = -EFAULT;
-	}
-	if (!status)
-		status =
-		    cod_get_sym_value(cod_mgr, COD_TRACEEND, &ul_trace_end);
-
-	if (!status)
-		/* trace_cur_pos will hold the address of a DSP pointer */
-		status = cod_get_sym_value(cod_mgr, COD_TRACECURPOS,
-							&trace_cur_pos);
-
-	if (status)
-		goto func_end;
-
-	ul_num_bytes = (ul_trace_end - ul_trace_begin);
-
-	ul_num_words = ul_num_bytes * ul_word_size;
-	status = dev_get_intf_fxns(dev_obj, &intf_fxns);
-
-	if (status)
-		goto func_end;
-
-	psz_buf = kzalloc(ul_num_bytes + 2, GFP_ATOMIC);
-	if (psz_buf != NULL) {
-		/* Read trace buffer data */
-		status = (*intf_fxns->brd_read)(pbridge_context,
-			(u8 *)psz_buf, (u32)ul_trace_begin,
-			ul_num_bytes, 0);
-
-		if (status)
-			goto func_end;
-
-		/* Pack and do newline conversion */
-		pr_debug("PrintDspTraceBuffer: "
-			"before pack and unpack.\n");
-		pr_debug("%s: DSP Trace Buffer Begin:\n"
-			"=======================\n%s\n",
-			__func__, psz_buf);
-
-		/* Read the value at the DSP address in trace_cur_pos. */
-		status = (*intf_fxns->brd_read)(pbridge_context,
-				(u8 *)&trace_cur_pos, (u32)trace_cur_pos,
-				4, 0);
-		if (status)
-			goto func_end;
-		/* Pack and do newline conversion */
-		pr_info("DSP Trace Buffer Begin:\n"
-			"=======================\n%s\n",
-			psz_buf);
-
-
-		/* convert to offset */
-		trace_cur_pos = trace_cur_pos - ul_trace_begin;
-
-		if (ul_num_bytes) {
-			/*
-			 * The buffer is not full, find the end of the
-			 * data -- buf_end will be >= pszBuf after
-			 * while.
-			 */
-			buf_end = &psz_buf[ul_num_bytes+1];
-			/* DSP print position */
-			trace_end = &psz_buf[trace_cur_pos];
-
-			/*
-			 * Search buffer for a new_line and replace it
-			 * with '\0', then print as string.
-			 * Continue until end of buffer is reached.
-			 */
-			str_beg = trace_end;
-			ul_num_bytes = buf_end - str_beg;
-
-			while (str_beg < buf_end) {
-				new_line = strnchr(str_beg, ul_num_bytes,
-								'\n');
-				if (new_line && new_line < buf_end) {
-					*new_line = 0;
-					pr_debug("%s\n", str_beg);
-					str_beg = ++new_line;
-					ul_num_bytes = buf_end - str_beg;
-				} else {
-					/*
-					 * Assume buffer empty if it contains
-					 * a zero
-					 */
-					if (*str_beg != '\0') {
-						str_beg[ul_num_bytes] = 0;
-						pr_debug("%s\n", str_beg);
-					}
-					str_beg = buf_end;
-					ul_num_bytes = 0;
-				}
-			}
-			/*
-			 * Search buffer for a nNewLine and replace it
-			 * with '\0', then print as string.
-			 * Continue until buffer is exhausted.
-			 */
-			str_beg = psz_buf;
-			ul_num_bytes = trace_end - str_beg;
-
-			while (str_beg < trace_end) {
-				new_line = strnchr(str_beg, ul_num_bytes, '\n');
-				if (new_line != NULL && new_line < trace_end) {
-					*new_line = 0;
-					pr_debug("%s\n", str_beg);
-					str_beg = ++new_line;
-					ul_num_bytes = trace_end - str_beg;
-				} else {
-					/*
-					 * Assume buffer empty if it contains
-					 * a zero
-					 */
-					if (*str_beg != '\0') {
-						str_beg[ul_num_bytes] = 0;
-						pr_debug("%s\n", str_beg);
-					}
-					str_beg = trace_end;
-					ul_num_bytes = 0;
-				}
-			}
-		}
-		pr_info("\n=======================\n"
-			"DSP Trace Buffer End:\n");
-		kfree(psz_buf);
-	} else {
-		status = -ENOMEM;
-	}
-func_end:
-	if (status)
-		dev_dbg(bridge, "%s Failed, status 0x%x\n", __func__, status);
-	return status;
-}
-
-/**
- * dump_dsp_stack() - This function dumps the data on the DSP stack.
- * @bridge_context:	Bridge driver's device context pointer.
- *
- */
-int dump_dsp_stack(struct bridge_dev_context *bridge_context)
-{
-	int status = 0;
-	struct cod_manager *code_mgr;
-	struct node_mgr *node_mgr;
-	u32 trace_begin;
-	char name[256];
-	struct {
-		u32 head[2];
-		u32 size;
-	} mmu_fault_dbg_info;
-	u32 *buffer;
-	u32 *buffer_beg;
-	u32 *buffer_end;
-	u32 exc_type;
-	u32 dyn_ext_base;
-	u32 i;
-	u32 offset_output;
-	u32 total_size;
-	u32 poll_cnt;
-	const char *dsp_regs[] = {"EFR", "IERR", "ITSR", "NTSR",
-				"IRP", "NRP", "AMR", "SSR",
-				"ILC", "RILC", "IER", "CSR"};
-	const char *exec_ctxt[] = {"Task", "SWI", "HWI", "Unknown"};
-	struct bridge_drv_interface *intf_fxns;
-	struct dev_object *dev_object = bridge_context->dev_obj;
-
-	status = dev_get_cod_mgr(dev_object, &code_mgr);
-	if (!code_mgr) {
-		pr_debug("%s: Failed on dev_get_cod_mgr.\n", __func__);
-		status = -EFAULT;
-	}
-
-	if (!status) {
-		status = dev_get_node_manager(dev_object, &node_mgr);
-		if (!node_mgr) {
-			pr_debug("%s: Failed on dev_get_node_manager.\n",
-								__func__);
-			status = -EFAULT;
-		}
-	}
-
-	if (!status) {
-		/* Look for SYS_PUTCBEG/SYS_PUTCEND: */
-		status =
-			cod_get_sym_value(code_mgr, COD_TRACEBEG, &trace_begin);
-		pr_debug("%s: trace_begin Value 0x%x\n",
-			__func__, trace_begin);
-		if (status)
-			pr_debug("%s: Failed on cod_get_sym_value.\n",
-								__func__);
-	}
-	if (!status)
-		status = dev_get_intf_fxns(dev_object, &intf_fxns);
-	/*
-	 * Check for the "magic number" in the trace buffer.  If it has
-	 * yet to appear then poll the trace buffer to wait for it.  Its
-	 * appearance signals that the DSP has finished dumping its state.
-	 */
-	mmu_fault_dbg_info.head[0] = 0;
-	mmu_fault_dbg_info.head[1] = 0;
-	if (!status) {
-		poll_cnt = 0;
-		while ((mmu_fault_dbg_info.head[0] != MMU_FAULT_HEAD1 ||
-			mmu_fault_dbg_info.head[1] != MMU_FAULT_HEAD2) &&
-			poll_cnt < POLL_MAX) {
-
-			/* Read DSP dump size from the DSP trace buffer... */
-			status = (*intf_fxns->brd_read)(bridge_context,
-				(u8 *)&mmu_fault_dbg_info, (u32)trace_begin,
-				sizeof(mmu_fault_dbg_info), 0);
-
-			if (status)
-				break;
-
-			poll_cnt++;
-		}
-
-		if (mmu_fault_dbg_info.head[0] != MMU_FAULT_HEAD1 &&
-			mmu_fault_dbg_info.head[1] != MMU_FAULT_HEAD2) {
-			status = -ETIME;
-			pr_err("%s:No DSP MMU-Fault information available.\n",
-							__func__);
-		}
-	}
-
-	if (!status) {
-		total_size = mmu_fault_dbg_info.size;
-		/* Limit the size in case DSP went crazy */
-		if (total_size > MAX_MMU_DBGBUFF)
-			total_size = MAX_MMU_DBGBUFF;
-
-		buffer = kzalloc(total_size, GFP_ATOMIC);
-		if (!buffer) {
-			status = -ENOMEM;
-			pr_debug("%s: Failed to "
-				"allocate stack dump buffer.\n", __func__);
-			goto func_end;
-		}
-
-		buffer_beg = buffer;
-		buffer_end =  buffer + total_size / 4;
-
-		/* Read bytes from the DSP trace buffer... */
-		status = (*intf_fxns->brd_read)(bridge_context,
-				(u8 *)buffer, (u32)trace_begin,
-				total_size, 0);
-		if (status) {
-			pr_debug("%s: Failed to Read Trace Buffer.\n",
-								__func__);
-			goto func_end;
-		}
-
-		pr_err("\nAproximate Crash Position:\n"
-			"--------------------------\n");
-
-		exc_type = buffer[3];
-		if (!exc_type)
-			i = buffer[79];         /* IRP */
-		else
-			i = buffer[80];         /* NRP */
-
-		status =
-		    cod_get_sym_value(code_mgr, DYNEXTBASE, &dyn_ext_base);
-		if (status) {
-			status = -EFAULT;
-			goto func_end;
-		}
-
-		if ((i > dyn_ext_base) && (node_find_addr(node_mgr, i,
-			0x1000, &offset_output, name) == 0))
-			pr_err("0x%-8x [\"%s\" + 0x%x]\n", i, name,
-							i - offset_output);
-		else
-			pr_err("0x%-8x [Unable to match to a symbol.]\n", i);
-
-		buffer += 4;
-
-		pr_err("\nExecution Info:\n"
-			"---------------\n");
-
-		if (*buffer < ARRAY_SIZE(exec_ctxt)) {
-			pr_err("Execution context \t%s\n",
-				exec_ctxt[*buffer++]);
-		} else {
-			pr_err("Execution context corrupt\n");
-			kfree(buffer_beg);
-			return -EFAULT;
-		}
-		pr_err("Task Handle\t\t0x%x\n", *buffer++);
-		pr_err("Stack Pointer\t\t0x%x\n", *buffer++);
-		pr_err("Stack Top\t\t0x%x\n", *buffer++);
-		pr_err("Stack Bottom\t\t0x%x\n", *buffer++);
-		pr_err("Stack Size\t\t0x%x\n", *buffer++);
-		pr_err("Stack Size In Use\t0x%x\n", *buffer++);
-
-		pr_err("\nCPU Registers\n"
-			"---------------\n");
-
-		for (i = 0; i < 32; i++) {
-			if (i == 4 || i == 6 || i == 8)
-				pr_err("A%d 0x%-8x [Function Argument %d]\n",
-							i, *buffer++, i-3);
-			else if (i == 15)
-				pr_err("A15 0x%-8x [Frame Pointer]\n",
-								*buffer++);
-			else
-				pr_err("A%d 0x%x\n", i, *buffer++);
-		}
-
-		pr_err("\nB0 0x%x\n", *buffer++);
-		pr_err("B1 0x%x\n", *buffer++);
-		pr_err("B2 0x%x\n", *buffer++);
-
-		if ((*buffer > dyn_ext_base) && (node_find_addr(node_mgr,
-			*buffer, 0x1000, &offset_output, name) == 0))
-
-			pr_err("B3 0x%-8x [Function Return Pointer:"
-				" \"%s\" + 0x%x]\n", *buffer, name,
-				*buffer - offset_output);
-		else
-			pr_err("B3 0x%-8x [Function Return Pointer:"
-				"Unable to match to a symbol.]\n", *buffer);
-
-		buffer++;
-
-		for (i = 4; i < 32; i++) {
-			if (i == 4 || i == 6 || i == 8)
-				pr_err("B%d 0x%-8x [Function Argument %d]\n",
-							i, *buffer++, i-2);
-			else if (i == 14)
-				pr_err("B14 0x%-8x [Data Page Pointer]\n",
-								*buffer++);
-			else
-				pr_err("B%d 0x%x\n", i, *buffer++);
-		}
-
-		pr_err("\n");
-
-		for (i = 0; i < ARRAY_SIZE(dsp_regs); i++)
-			pr_err("%s 0x%x\n", dsp_regs[i], *buffer++);
-
-		pr_err("\nStack:\n"
-			"------\n");
-
-		for (i = 0; buffer < buffer_end; i++, buffer++) {
-			if ((*buffer > dyn_ext_base) && (
-				node_find_addr(node_mgr, *buffer , 0x600,
-				&offset_output, name) == 0))
-				pr_err("[%d] 0x%-8x [\"%s\" + 0x%x]\n",
-					i, *buffer, name,
-					*buffer - offset_output);
-			else
-				pr_err("[%d] 0x%x\n", i, *buffer);
-		}
-		kfree(buffer_beg);
-	}
-func_end:
-	return status;
-}
-
-/**
- * dump_dl_modules() - This functions dumps the _DLModules loaded in DSP side
- * @bridge_context:		Bridge driver's device context pointer.
- *
- */
-void dump_dl_modules(struct bridge_dev_context *bridge_context)
-{
-	struct cod_manager *code_mgr;
-	struct bridge_drv_interface *intf_fxns;
-	struct bridge_dev_context *bridge_ctxt = bridge_context;
-	struct dev_object *dev_object = bridge_ctxt->dev_obj;
-	struct modules_header modules_hdr;
-	struct dll_module *module_struct = NULL;
-	u32 module_dsp_addr;
-	u32 module_size;
-	u32 module_struct_size = 0;
-	u32 sect_ndx;
-	char *sect_str;
-	int status = 0;
-
-	status = dev_get_intf_fxns(dev_object, &intf_fxns);
-	if (status) {
-		pr_debug("%s: Failed on dev_get_intf_fxns.\n", __func__);
-		goto func_end;
-	}
-
-	status = dev_get_cod_mgr(dev_object, &code_mgr);
-	if (!code_mgr) {
-		pr_debug("%s: Failed on dev_get_cod_mgr.\n", __func__);
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	/* Lookup  the address of the modules_header structure */
-	status = cod_get_sym_value(code_mgr, "_DLModules", &module_dsp_addr);
-	if (status) {
-		pr_debug("%s: Failed on cod_get_sym_value for _DLModules.\n",
-			__func__);
-		goto func_end;
-	}
-
-	pr_debug("%s: _DLModules at 0x%x\n", __func__, module_dsp_addr);
-
-	/* Copy the modules_header structure from DSP memory. */
-	status = (*intf_fxns->brd_read)(bridge_context, (u8 *) &modules_hdr,
-				(u32) module_dsp_addr, sizeof(modules_hdr), 0);
-
-	if (status) {
-		pr_debug("%s: Failed failed to read modules header.\n",
-								__func__);
-		goto func_end;
-	}
-
-	module_dsp_addr = modules_hdr.first_module;
-	module_size = modules_hdr.first_module_size;
-
-	pr_debug("%s: dll_module_header 0x%x %d\n", __func__, module_dsp_addr,
-								module_size);
-
-	pr_err("\nDynamically Loaded Modules:\n"
-		"---------------------------\n");
-
-	/* For each dll_module structure in the list... */
-	while (module_size) {
-		/*
-		 * Allocate/re-allocate memory to hold the dll_module
-		 * structure. The memory is re-allocated only if the existing
-		 * allocation is too small.
-		 */
-		if (module_size > module_struct_size) {
-			kfree(module_struct);
-			module_struct = kzalloc(module_size+128, GFP_ATOMIC);
-			module_struct_size = module_size+128;
-			pr_debug("%s: allocated module struct %p %d\n",
-				__func__, module_struct, module_struct_size);
-			if (!module_struct)
-				goto func_end;
-		}
-		/* Copy the dll_module structure from DSP memory */
-		status = (*intf_fxns->brd_read)(bridge_context,
-			(u8 *)module_struct, module_dsp_addr, module_size, 0);
-
-		if (status) {
-			pr_debug(
-			"%s: Failed to read dll_module struct for 0x%x.\n",
-			__func__, module_dsp_addr);
-			break;
-		}
-
-		/* Update info regarding the _next_ module in the list. */
-		module_dsp_addr = module_struct->next_module;
-		module_size = module_struct->next_module_size;
-
-		pr_debug("%s: next module 0x%x %d, this module num sects %d\n",
-			__func__, module_dsp_addr, module_size,
-			module_struct->num_sects);
-
-		/*
-		 * The section name strings start immediately following
-		 * the array of dll_sect structures.
-		 */
-		sect_str = (char *) &module_struct->
-					sects[module_struct->num_sects];
-		pr_err("%s\n", sect_str);
-
-		/*
-		 * Advance to the first section name string.
-		 * Each string follows the one before.
-		 */
-		sect_str += strlen(sect_str) + 1;
-
-		/* Access each dll_sect structure and its name string. */
-		for (sect_ndx = 0;
-			sect_ndx < module_struct->num_sects; sect_ndx++) {
-			pr_err("    Section: 0x%x ",
-				module_struct->sects[sect_ndx].sect_load_adr);
-
-			if (((u32) sect_str - (u32) module_struct) <
-				module_struct_size) {
-				pr_err("%s\n", sect_str);
-				/* Each string follows the one before. */
-				sect_str += strlen(sect_str)+1;
-			} else {
-				pr_err("<string error>\n");
-				pr_debug("%s: section name sting address "
-					"is invalid %p\n", __func__, sect_str);
-			}
-		}
-	}
-func_end:
-	kfree(module_struct);
-}
-#endif
diff --git a/drivers/staging/tidspbridge/core/msg_sm.c b/drivers/staging/tidspbridge/core/msg_sm.c
deleted file mode 100644
index 7b517eb..0000000
--- a/drivers/staging/tidspbridge/core/msg_sm.c
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- * msg_sm.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Implements upper edge functions for Bridge message module.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#include <linux/types.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/sync.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/dev.h>
-
-/*  ----------------------------------- Others */
-#include <dspbridge/io_sm.h>
-
-/*  ----------------------------------- This */
-#include <_msg_sm.h>
-#include <dspbridge/dspmsg.h>
-
-/*  ----------------------------------- Function Prototypes */
-static int add_new_msg(struct list_head *msg_list);
-static void delete_msg_mgr(struct msg_mgr *hmsg_mgr);
-static void delete_msg_queue(struct msg_queue *msg_queue_obj, u32 num_to_dsp);
-static void free_msg_list(struct list_head *msg_list);
-
-/*
- *  ======== bridge_msg_create ========
- *      Create an object to manage message queues. Only one of these objects
- *      can exist per device object.
- */
-int bridge_msg_create(struct msg_mgr **msg_man,
-			     struct dev_object *hdev_obj,
-			     msg_onexit msg_callback)
-{
-	struct msg_mgr *msg_mgr_obj;
-	struct io_mgr *hio_mgr;
-	int status = 0;
-
-	if (!msg_man || !msg_callback || !hdev_obj)
-		return -EFAULT;
-
-	dev_get_io_mgr(hdev_obj, &hio_mgr);
-	if (!hio_mgr)
-		return -EFAULT;
-
-	*msg_man = NULL;
-	/* Allocate msg_ctrl manager object */
-	msg_mgr_obj = kzalloc(sizeof(struct msg_mgr), GFP_KERNEL);
-	if (!msg_mgr_obj)
-		return -ENOMEM;
-
-	msg_mgr_obj->on_exit = msg_callback;
-	msg_mgr_obj->iomgr = hio_mgr;
-	/* List of MSG_QUEUEs */
-	INIT_LIST_HEAD(&msg_mgr_obj->queue_list);
-	/*
-	 * Queues of message frames for messages to the DSP. Message
-	 * frames will only be added to the free queue when a
-	 * msg_queue object is created.
-	 */
-	INIT_LIST_HEAD(&msg_mgr_obj->msg_free_list);
-	INIT_LIST_HEAD(&msg_mgr_obj->msg_used_list);
-	spin_lock_init(&msg_mgr_obj->msg_mgr_lock);
-
-	/*
-	 * Create an event to be used by bridge_msg_put() in waiting
-	 * for an available free frame from the message manager.
-	 */
-	msg_mgr_obj->sync_event =
-		kzalloc(sizeof(struct sync_object), GFP_KERNEL);
-	if (!msg_mgr_obj->sync_event) {
-		kfree(msg_mgr_obj);
-		return -ENOMEM;
-	}
-	sync_init_event(msg_mgr_obj->sync_event);
-
-	*msg_man = msg_mgr_obj;
-
-	return status;
-}
-
-/*
- *  ======== bridge_msg_create_queue ========
- *      Create a msg_queue for sending/receiving messages to/from a node
- *      on the DSP.
- */
-int bridge_msg_create_queue(struct msg_mgr *hmsg_mgr, struct msg_queue **msgq,
-				u32 msgq_id, u32 max_msgs, void *arg)
-{
-	u32 i;
-	u32 num_allocated = 0;
-	struct msg_queue *msg_q;
-	int status = 0;
-
-	if (!hmsg_mgr || msgq == NULL)
-		return -EFAULT;
-
-	*msgq = NULL;
-	/* Allocate msg_queue object */
-	msg_q = kzalloc(sizeof(struct msg_queue), GFP_KERNEL);
-	if (!msg_q)
-		return -ENOMEM;
-
-	msg_q->max_msgs = max_msgs;
-	msg_q->msg_mgr = hmsg_mgr;
-	msg_q->arg = arg;	/* Node handle */
-	msg_q->msgq_id = msgq_id;	/* Node env (not valid yet) */
-	/* Queues of Message frames for messages from the DSP */
-	INIT_LIST_HEAD(&msg_q->msg_free_list);
-	INIT_LIST_HEAD(&msg_q->msg_used_list);
-
-	/*  Create event that will be signalled when a message from
-	 *  the DSP is available. */
-	msg_q->sync_event = kzalloc(sizeof(struct sync_object), GFP_KERNEL);
-	if (!msg_q->sync_event) {
-		status = -ENOMEM;
-		goto out_err;
-
-	}
-	sync_init_event(msg_q->sync_event);
-
-	/* Create a notification list for message ready notification. */
-	msg_q->ntfy_obj = kmalloc(sizeof(struct ntfy_object), GFP_KERNEL);
-	if (!msg_q->ntfy_obj) {
-		status = -ENOMEM;
-		goto out_err;
-	}
-	ntfy_init(msg_q->ntfy_obj);
-
-	/*  Create events that will be used to synchronize cleanup
-	 *  when the object is deleted. sync_done will be set to
-	 *  unblock threads in MSG_Put() or MSG_Get(). sync_done_ack
-	 *  will be set by the unblocked thread to signal that it
-	 *  is unblocked and will no longer reference the object. */
-	msg_q->sync_done = kzalloc(sizeof(struct sync_object), GFP_KERNEL);
-	if (!msg_q->sync_done) {
-		status = -ENOMEM;
-		goto out_err;
-	}
-	sync_init_event(msg_q->sync_done);
-
-	msg_q->sync_done_ack = kzalloc(sizeof(struct sync_object), GFP_KERNEL);
-	if (!msg_q->sync_done_ack) {
-		status = -ENOMEM;
-		goto out_err;
-	}
-	sync_init_event(msg_q->sync_done_ack);
-
-	/* Enter critical section */
-	spin_lock_bh(&hmsg_mgr->msg_mgr_lock);
-	/* Initialize message frames and put in appropriate queues */
-	for (i = 0; i < max_msgs && !status; i++) {
-		status = add_new_msg(&hmsg_mgr->msg_free_list);
-		if (!status) {
-			num_allocated++;
-			status = add_new_msg(&msg_q->msg_free_list);
-		}
-	}
-	if (status) {
-		spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-		goto out_err;
-	}
-
-	list_add_tail(&msg_q->list_elem, &hmsg_mgr->queue_list);
-	*msgq = msg_q;
-	/* Signal that free frames are now available */
-	if (!list_empty(&hmsg_mgr->msg_free_list))
-		sync_set_event(hmsg_mgr->sync_event);
-
-	/* Exit critical section */
-	spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-
-	return 0;
-out_err:
-	delete_msg_queue(msg_q, num_allocated);
-	return status;
-}
-
-/*
- *  ======== bridge_msg_delete ========
- *      Delete a msg_ctrl manager allocated in bridge_msg_create().
- */
-void bridge_msg_delete(struct msg_mgr *hmsg_mgr)
-{
-	delete_msg_mgr(hmsg_mgr);
-}
-
-/*
- *  ======== bridge_msg_delete_queue ========
- *      Delete a msg_ctrl queue allocated in bridge_msg_create_queue.
- */
-void bridge_msg_delete_queue(struct msg_queue *msg_queue_obj)
-{
-	struct msg_mgr *hmsg_mgr;
-	u32 io_msg_pend;
-
-	if (!msg_queue_obj || !msg_queue_obj->msg_mgr)
-		return;
-
-	hmsg_mgr = msg_queue_obj->msg_mgr;
-	msg_queue_obj->done = true;
-	/*  Unblock all threads blocked in MSG_Get() or MSG_Put(). */
-	io_msg_pend = msg_queue_obj->io_msg_pend;
-	while (io_msg_pend) {
-		/* Unblock thread */
-		sync_set_event(msg_queue_obj->sync_done);
-		/* Wait for acknowledgement */
-		sync_wait_on_event(msg_queue_obj->sync_done_ack, SYNC_INFINITE);
-		io_msg_pend = msg_queue_obj->io_msg_pend;
-	}
-	/* Remove message queue from hmsg_mgr->queue_list */
-	spin_lock_bh(&hmsg_mgr->msg_mgr_lock);
-	list_del(&msg_queue_obj->list_elem);
-	/* Free the message queue object */
-	delete_msg_queue(msg_queue_obj, msg_queue_obj->max_msgs);
-	if (list_empty(&hmsg_mgr->msg_free_list))
-		sync_reset_event(hmsg_mgr->sync_event);
-	spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-}
-
-/*
- *  ======== bridge_msg_get ========
- *      Get a message from a msg_ctrl queue.
- */
-int bridge_msg_get(struct msg_queue *msg_queue_obj,
-			  struct dsp_msg *pmsg, u32 utimeout)
-{
-	struct msg_frame *msg_frame_obj;
-	struct msg_mgr *hmsg_mgr;
-	struct sync_object *syncs[2];
-	u32 index;
-	int status = 0;
-
-	if (!msg_queue_obj || pmsg == NULL)
-		return -ENOMEM;
-
-	hmsg_mgr = msg_queue_obj->msg_mgr;
-
-	spin_lock_bh(&hmsg_mgr->msg_mgr_lock);
-	/* If a message is already there, get it */
-	if (!list_empty(&msg_queue_obj->msg_used_list)) {
-		msg_frame_obj = list_first_entry(&msg_queue_obj->msg_used_list,
-				struct msg_frame, list_elem);
-		list_del(&msg_frame_obj->list_elem);
-		*pmsg = msg_frame_obj->msg_data.msg;
-		list_add_tail(&msg_frame_obj->list_elem,
-				&msg_queue_obj->msg_free_list);
-		if (list_empty(&msg_queue_obj->msg_used_list))
-			sync_reset_event(msg_queue_obj->sync_event);
-		spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-		return 0;
-	}
-
-	if (msg_queue_obj->done) {
-		spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-		return -EPERM;
-	}
-	msg_queue_obj->io_msg_pend++;
-	spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-
-	/*
-	 * Wait til message is available, timeout, or done. We don't
-	 * have to schedule the DPC, since the DSP will send messages
-	 * when they are available.
-	 */
-	syncs[0] = msg_queue_obj->sync_event;
-	syncs[1] = msg_queue_obj->sync_done;
-	status = sync_wait_on_multiple_events(syncs, 2, utimeout, &index);
-
-	spin_lock_bh(&hmsg_mgr->msg_mgr_lock);
-	if (msg_queue_obj->done) {
-		msg_queue_obj->io_msg_pend--;
-		spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-		/*
-		 * Signal that we're not going to access msg_queue_obj
-		 * anymore, so it can be deleted.
-		 */
-		sync_set_event(msg_queue_obj->sync_done_ack);
-		return -EPERM;
-	}
-	if (!status && !list_empty(&msg_queue_obj->msg_used_list)) {
-		/* Get msg from used list */
-		msg_frame_obj = list_first_entry(&msg_queue_obj->msg_used_list,
-				struct msg_frame, list_elem);
-		list_del(&msg_frame_obj->list_elem);
-		/* Copy message into pmsg and put frame on the free list */
-		*pmsg = msg_frame_obj->msg_data.msg;
-		list_add_tail(&msg_frame_obj->list_elem,
-				&msg_queue_obj->msg_free_list);
-	}
-	msg_queue_obj->io_msg_pend--;
-	/* Reset the event if there are still queued messages */
-	if (!list_empty(&msg_queue_obj->msg_used_list))
-		sync_set_event(msg_queue_obj->sync_event);
-
-	spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-
-	return status;
-}
-
-/*
- *  ======== bridge_msg_put ========
- *      Put a message onto a msg_ctrl queue.
- */
-int bridge_msg_put(struct msg_queue *msg_queue_obj,
-			  const struct dsp_msg *pmsg, u32 utimeout)
-{
-	struct msg_frame *msg_frame_obj;
-	struct msg_mgr *hmsg_mgr;
-	struct sync_object *syncs[2];
-	u32 index;
-	int status;
-
-	if (!msg_queue_obj || !pmsg || !msg_queue_obj->msg_mgr)
-		return -EFAULT;
-
-	hmsg_mgr = msg_queue_obj->msg_mgr;
-
-	spin_lock_bh(&hmsg_mgr->msg_mgr_lock);
-
-	/* If a message frame is available, use it */
-	if (!list_empty(&hmsg_mgr->msg_free_list)) {
-		msg_frame_obj = list_first_entry(&hmsg_mgr->msg_free_list,
-				struct msg_frame, list_elem);
-		list_del(&msg_frame_obj->list_elem);
-		msg_frame_obj->msg_data.msg = *pmsg;
-		msg_frame_obj->msg_data.msgq_id =
-			msg_queue_obj->msgq_id;
-		list_add_tail(&msg_frame_obj->list_elem,
-				&hmsg_mgr->msg_used_list);
-		hmsg_mgr->msgs_pending++;
-
-		if (list_empty(&hmsg_mgr->msg_free_list))
-			sync_reset_event(hmsg_mgr->sync_event);
-
-		/* Release critical section before scheduling DPC */
-		spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-		/* Schedule a DPC, to do the actual data transfer: */
-		iosm_schedule(hmsg_mgr->iomgr);
-		return 0;
-	}
-
-	if (msg_queue_obj->done) {
-		spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-		return -EPERM;
-	}
-	msg_queue_obj->io_msg_pend++;
-
-	spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-
-	/* Wait til a free message frame is available, timeout, or done */
-	syncs[0] = hmsg_mgr->sync_event;
-	syncs[1] = msg_queue_obj->sync_done;
-	status = sync_wait_on_multiple_events(syncs, 2, utimeout, &index);
-	if (status)
-		return status;
-
-	/* Enter critical section */
-	spin_lock_bh(&hmsg_mgr->msg_mgr_lock);
-	if (msg_queue_obj->done) {
-		msg_queue_obj->io_msg_pend--;
-		/* Exit critical section */
-		spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-		/*
-		 * Signal that we're not going to access msg_queue_obj
-		 * anymore, so it can be deleted.
-		 */
-		sync_set_event(msg_queue_obj->sync_done_ack);
-		return -EPERM;
-	}
-
-	if (list_empty(&hmsg_mgr->msg_free_list)) {
-		spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-		return -EFAULT;
-	}
-
-	/* Get msg from free list */
-	msg_frame_obj = list_first_entry(&hmsg_mgr->msg_free_list,
-			struct msg_frame, list_elem);
-	/*
-	 * Copy message into pmsg and put frame on the
-	 * used list.
-	 */
-	list_del(&msg_frame_obj->list_elem);
-	msg_frame_obj->msg_data.msg = *pmsg;
-	msg_frame_obj->msg_data.msgq_id = msg_queue_obj->msgq_id;
-	list_add_tail(&msg_frame_obj->list_elem, &hmsg_mgr->msg_used_list);
-	hmsg_mgr->msgs_pending++;
-	/*
-	 * Schedule a DPC, to do the actual
-	 * data transfer.
-	 */
-	iosm_schedule(hmsg_mgr->iomgr);
-
-	msg_queue_obj->io_msg_pend--;
-	/* Reset event if there are still frames available */
-	if (!list_empty(&hmsg_mgr->msg_free_list))
-		sync_set_event(hmsg_mgr->sync_event);
-
-	/* Exit critical section */
-	spin_unlock_bh(&hmsg_mgr->msg_mgr_lock);
-
-	return 0;
-}
-
-/*
- *  ======== bridge_msg_register_notify ========
- */
-int bridge_msg_register_notify(struct msg_queue *msg_queue_obj,
-				   u32 event_mask, u32 notify_type,
-				   struct dsp_notification *hnotification)
-{
-	int status = 0;
-
-	if (!msg_queue_obj || !hnotification) {
-		status = -ENOMEM;
-		goto func_end;
-	}
-
-	if (!(event_mask == DSP_NODEMESSAGEREADY || event_mask == 0)) {
-		status = -EPERM;
-		goto func_end;
-	}
-
-	if (notify_type != DSP_SIGNALEVENT) {
-		status = -EBADR;
-		goto func_end;
-	}
-
-	if (event_mask)
-		status = ntfy_register(msg_queue_obj->ntfy_obj, hnotification,
-						event_mask, notify_type);
-	else
-		status = ntfy_unregister(msg_queue_obj->ntfy_obj,
-							hnotification);
-
-	if (status == -EINVAL) {
-		/*  Not registered. Ok, since we couldn't have known. Node
-		 *  notifications are split between node state change handled
-		 *  by NODE, and message ready handled by msg_ctrl. */
-		status = 0;
-	}
-func_end:
-	return status;
-}
-
-/*
- *  ======== bridge_msg_set_queue_id ========
- */
-void bridge_msg_set_queue_id(struct msg_queue *msg_queue_obj, u32 msgq_id)
-{
-	/*
-	 *  A message queue must be created when a node is allocated,
-	 *  so that node_register_notify() can be called before the node
-	 *  is created. Since we don't know the node environment until the
-	 *  node is created, we need this function to set msg_queue_obj->msgq_id
-	 *  to the node environment, after the node is created.
-	 */
-	if (msg_queue_obj)
-		msg_queue_obj->msgq_id = msgq_id;
-}
-
-/*
- *  ======== add_new_msg ========
- *      Must be called in message manager critical section.
- */
-static int add_new_msg(struct list_head *msg_list)
-{
-	struct msg_frame *pmsg;
-
-	pmsg = kzalloc(sizeof(struct msg_frame), GFP_ATOMIC);
-	if (!pmsg)
-		return -ENOMEM;
-
-	list_add_tail(&pmsg->list_elem, msg_list);
-
-	return 0;
-}
-
-/*
- *  ======== delete_msg_mgr ========
- */
-static void delete_msg_mgr(struct msg_mgr *hmsg_mgr)
-{
-	if (!hmsg_mgr)
-		return;
-
-	/* FIXME: free elements from queue_list? */
-	free_msg_list(&hmsg_mgr->msg_free_list);
-	free_msg_list(&hmsg_mgr->msg_used_list);
-	kfree(hmsg_mgr->sync_event);
-	kfree(hmsg_mgr);
-}
-
-/*
- *  ======== delete_msg_queue ========
- */
-static void delete_msg_queue(struct msg_queue *msg_queue_obj, u32 num_to_dsp)
-{
-	struct msg_mgr *hmsg_mgr;
-	struct msg_frame *pmsg, *tmp;
-	u32 i;
-
-	if (!msg_queue_obj || !msg_queue_obj->msg_mgr)
-		return;
-
-	hmsg_mgr = msg_queue_obj->msg_mgr;
-
-	/* Pull off num_to_dsp message frames from Msg manager and free */
-	i = 0;
-	list_for_each_entry_safe(pmsg, tmp, &hmsg_mgr->msg_free_list,
-			list_elem) {
-		list_del(&pmsg->list_elem);
-		kfree(pmsg);
-		if (i++ >= num_to_dsp)
-			break;
-	}
-
-	free_msg_list(&msg_queue_obj->msg_free_list);
-	free_msg_list(&msg_queue_obj->msg_used_list);
-
-	if (msg_queue_obj->ntfy_obj) {
-		ntfy_delete(msg_queue_obj->ntfy_obj);
-		kfree(msg_queue_obj->ntfy_obj);
-	}
-
-	kfree(msg_queue_obj->sync_event);
-	kfree(msg_queue_obj->sync_done);
-	kfree(msg_queue_obj->sync_done_ack);
-
-	kfree(msg_queue_obj);
-}
-
-/*
- *  ======== free_msg_list ========
- */
-static void free_msg_list(struct list_head *msg_list)
-{
-	struct msg_frame *pmsg, *tmp;
-
-	if (!msg_list)
-		return;
-
-	list_for_each_entry_safe(pmsg, tmp, msg_list, list_elem) {
-		list_del(&pmsg->list_elem);
-		kfree(pmsg);
-	}
-}
diff --git a/drivers/staging/tidspbridge/core/sync.c b/drivers/staging/tidspbridge/core/sync.c
deleted file mode 100644
index 743ff09..0000000
--- a/drivers/staging/tidspbridge/core/sync.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * sync.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Synchronization services.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/sync.h>
-#include <dspbridge/ntfy.h>
-
-DEFINE_SPINLOCK(sync_lock);
-
-/**
- * sync_set_event() - set or signal and specified event
- * @event:	Event to be set..
- *
- * set the @event, if there is an thread waiting for the event
- * it will be waken up, this function only wakes one thread.
- */
-
-void sync_set_event(struct sync_object *event)
-{
-	spin_lock_bh(&sync_lock);
-	complete(&event->comp);
-	if (event->multi_comp)
-		complete(event->multi_comp);
-	spin_unlock_bh(&sync_lock);
-}
-
-/**
- * sync_wait_on_multiple_events() - waits for multiple events to be set.
- * @events:	Array of events to wait for them.
- * @count:	number of elements of the array.
- * @timeout	timeout on waiting for the evetns.
- * @pu_index	index of the event set.
- *
- * These functions will wait until any of the array element is set or until
- * timeout. In case of success the function will return 0 and
- * @pu_index will store the index of the array element set or in case
- * of timeout the function will return -ETIME or in case of
- * interrupting by a signal it will return -EPERM.
- */
-
-int sync_wait_on_multiple_events(struct sync_object **events,
-				     unsigned count, unsigned timeout,
-				     unsigned *index)
-{
-	unsigned i;
-	int status = -EPERM;
-	struct completion m_comp;
-
-	init_completion(&m_comp);
-
-	if (SYNC_INFINITE == timeout)
-		timeout = MAX_SCHEDULE_TIMEOUT;
-
-	spin_lock_bh(&sync_lock);
-	for (i = 0; i < count; i++) {
-		if (completion_done(&events[i]->comp)) {
-			reinit_completion(&events[i]->comp);
-			*index = i;
-			spin_unlock_bh(&sync_lock);
-			status = 0;
-			goto func_end;
-		}
-	}
-
-	for (i = 0; i < count; i++)
-		events[i]->multi_comp = &m_comp;
-
-	spin_unlock_bh(&sync_lock);
-
-	if (!wait_for_completion_interruptible_timeout(&m_comp,
-					msecs_to_jiffies(timeout)))
-		status = -ETIME;
-
-	spin_lock_bh(&sync_lock);
-	for (i = 0; i < count; i++) {
-		if (completion_done(&events[i]->comp)) {
-			reinit_completion(&events[i]->comp);
-			*index = i;
-			status = 0;
-		}
-		events[i]->multi_comp = NULL;
-	}
-	spin_unlock_bh(&sync_lock);
-func_end:
-	return status;
-}
-
-/**
- * dsp_notifier_event() - callback function to nofity events
- * @this:		pointer to itself struct notifier_block
- * @event:	event to be notified.
- * @data:		Currently not used.
- *
- */
-int dsp_notifier_event(struct notifier_block *this, unsigned long event,
-							void *data)
-{
-	struct  ntfy_event *ne = container_of(this, struct ntfy_event,
-							noti_block);
-	if (ne->event & event)
-		sync_set_event(&ne->sync_obj);
-	return NOTIFY_OK;
-}
diff --git a/drivers/staging/tidspbridge/core/tiomap3430.c b/drivers/staging/tidspbridge/core/tiomap3430.c
deleted file mode 100644
index f63dd8f..0000000
--- a/drivers/staging/tidspbridge/core/tiomap3430.c
+++ /dev/null
@@ -1,1815 +0,0 @@
-/*
- * tiomap.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Processor Manager Driver for TI OMAP3430 EVM.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/platform_data/dsp-omap.h>
-
-#include <linux/types.h>
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-#include <linux/mm.h>
-#include <linux/mmzone.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/drv.h>
-#include <dspbridge/sync.h>
-
-/* ------------------------------------ Hardware Abstraction Layer */
-#include <hw_defs.h>
-#include <hw_mmu.h>
-
-/*  ----------------------------------- Link Driver */
-#include <dspbridge/dspdefs.h>
-#include <dspbridge/dspchnl.h>
-#include <dspbridge/dspdeh.h>
-#include <dspbridge/dspio.h>
-#include <dspbridge/dspmsg.h>
-#include <dspbridge/pwr.h>
-#include <dspbridge/io_sm.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/dev.h>
-#include <dspbridge/dspapi.h>
-#include <dspbridge/dmm.h>
-#include <dspbridge/wdt.h>
-
-/*  ----------------------------------- Local */
-#include "_tiomap.h"
-#include "_tiomap_pwr.h"
-#include "tiomap_io.h"
-
-/* Offset in shared mem to write to in order to synchronize start with DSP */
-#define SHMSYNCOFFSET 4		/* GPP byte offset */
-
-#define BUFFERSIZE 1024
-
-#define TIHELEN_ACKTIMEOUT  10000
-
-#define MMU_SECTION_ADDR_MASK    0xFFF00000
-#define MMU_SSECTION_ADDR_MASK   0xFF000000
-#define MMU_LARGE_PAGE_MASK      0xFFFF0000
-#define MMU_SMALL_PAGE_MASK      0xFFFFF000
-#define OMAP3_IVA2_BOOTADDR_MASK 0xFFFFFC00
-#define PAGES_II_LVL_TABLE   512
-#define PHYS_TO_PAGE(phys)      pfn_to_page((phys) >> PAGE_SHIFT)
-
-/* IVA Boot modes */
-#define DIRECT		0
-#define IDLE		1
-
-/* Forward Declarations: */
-static int bridge_brd_monitor(struct bridge_dev_context *dev_ctxt);
-static int bridge_brd_read(struct bridge_dev_context *dev_ctxt,
-				  u8 *host_buff,
-				  u32 dsp_addr, u32 ul_num_bytes,
-				  u32 mem_type);
-static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
-				   u32 dsp_addr);
-static int bridge_brd_status(struct bridge_dev_context *dev_ctxt,
-				    int *board_state);
-static int bridge_brd_stop(struct bridge_dev_context *dev_ctxt);
-static int bridge_brd_write(struct bridge_dev_context *dev_ctxt,
-				   u8 *host_buff,
-				   u32 dsp_addr, u32 ul_num_bytes,
-				   u32 mem_type);
-static int bridge_brd_set_state(struct bridge_dev_context *dev_ctxt,
-				    u32 brd_state);
-static int bridge_brd_mem_copy(struct bridge_dev_context *dev_ctxt,
-				   u32 dsp_dest_addr, u32 dsp_src_addr,
-				   u32 ul_num_bytes, u32 mem_type);
-static int bridge_brd_mem_write(struct bridge_dev_context *dev_ctxt,
-				    u8 *host_buff, u32 dsp_addr,
-				    u32 ul_num_bytes, u32 mem_type);
-static int bridge_brd_mem_map(struct bridge_dev_context *dev_ctxt,
-				  u32 ul_mpu_addr, u32 virt_addr,
-				  u32 ul_num_bytes, u32 ul_map_attr,
-				  struct page **mapped_pages);
-static int bridge_brd_mem_un_map(struct bridge_dev_context *dev_ctxt,
-				     u32 virt_addr, u32 ul_num_bytes);
-static int bridge_dev_create(struct bridge_dev_context
-					**dev_cntxt,
-					struct dev_object *hdev_obj,
-					struct cfg_hostres *config_param);
-static int bridge_dev_ctrl(struct bridge_dev_context *dev_context,
-				  u32 dw_cmd, void *pargs);
-static int bridge_dev_destroy(struct bridge_dev_context *dev_ctxt);
-static u32 user_va2_pa(struct mm_struct *mm, u32 address);
-static int pte_update(struct bridge_dev_context *dev_ctxt, u32 pa,
-			     u32 va, u32 size,
-			     struct hw_mmu_map_attrs_t *map_attrs);
-static int pte_set(struct pg_table_attrs *pt, u32 pa, u32 va,
-			  u32 size, struct hw_mmu_map_attrs_t *attrs);
-static int mem_map_vmalloc(struct bridge_dev_context *dev_context,
-				  u32 ul_mpu_addr, u32 virt_addr,
-				  u32 ul_num_bytes,
-				  struct hw_mmu_map_attrs_t *hw_attrs);
-
-bool wait_for_start(struct bridge_dev_context *dev_context,
-			void __iomem *sync_addr);
-
-/*  ----------------------------------- Globals */
-
-/* Attributes of L2 page tables for DSP MMU */
-struct page_info {
-	u32 num_entries;	/* Number of valid PTEs in the L2 PT */
-};
-
-/* Attributes used to manage the DSP MMU page tables */
-struct pg_table_attrs {
-	spinlock_t pg_lock;	/* Critical section object handle */
-
-	u32 l1_base_pa;		/* Physical address of the L1 PT */
-	u32 l1_base_va;		/* Virtual  address of the L1 PT */
-	u32 l1_size;		/* Size of the L1 PT */
-	u32 l1_tbl_alloc_pa;
-	/* Physical address of Allocated mem for L1 table. May not be aligned */
-	u32 l1_tbl_alloc_va;
-	/* Virtual address of Allocated mem for L1 table. May not be aligned */
-	u32 l1_tbl_alloc_sz;
-	/* Size of consistent memory allocated for L1 table.
-	 * May not be aligned */
-
-	u32 l2_base_pa;		/* Physical address of the L2 PT */
-	u32 l2_base_va;		/* Virtual  address of the L2 PT */
-	u32 l2_size;		/* Size of the L2 PT */
-	u32 l2_tbl_alloc_pa;
-	/* Physical address of Allocated mem for L2 table. May not be aligned */
-	u32 l2_tbl_alloc_va;
-	/* Virtual address of Allocated mem for L2 table. May not be aligned */
-	u32 l2_tbl_alloc_sz;
-	/* Size of consistent memory allocated for L2 table.
-	 * May not be aligned */
-
-	u32 l2_num_pages;	/* Number of allocated L2 PT */
-	/* Array [l2_num_pages] of L2 PT info structs */
-	struct page_info *pg_info;
-};
-
-/*
- *  This Bridge driver's function interface table.
- */
-static struct bridge_drv_interface drv_interface_fxns = {
-	/* Bridge API ver. for which this bridge driver is built. */
-	BRD_API_MAJOR_VERSION,
-	BRD_API_MINOR_VERSION,
-	bridge_dev_create,
-	bridge_dev_destroy,
-	bridge_dev_ctrl,
-	bridge_brd_monitor,
-	bridge_brd_start,
-	bridge_brd_stop,
-	bridge_brd_status,
-	bridge_brd_read,
-	bridge_brd_write,
-	bridge_brd_set_state,
-	bridge_brd_mem_copy,
-	bridge_brd_mem_write,
-	bridge_brd_mem_map,
-	bridge_brd_mem_un_map,
-	/* The following CHNL functions are provided by chnl_io.lib: */
-	bridge_chnl_create,
-	bridge_chnl_destroy,
-	bridge_chnl_open,
-	bridge_chnl_close,
-	bridge_chnl_add_io_req,
-	bridge_chnl_get_ioc,
-	bridge_chnl_cancel_io,
-	bridge_chnl_flush_io,
-	bridge_chnl_get_info,
-	bridge_chnl_get_mgr_info,
-	bridge_chnl_idle,
-	bridge_chnl_register_notify,
-	/* The following IO functions are provided by chnl_io.lib: */
-	bridge_io_create,
-	bridge_io_destroy,
-	bridge_io_on_loaded,
-	bridge_io_get_proc_load,
-	/* The following msg_ctrl functions are provided by chnl_io.lib: */
-	bridge_msg_create,
-	bridge_msg_create_queue,
-	bridge_msg_delete,
-	bridge_msg_delete_queue,
-	bridge_msg_get,
-	bridge_msg_put,
-	bridge_msg_register_notify,
-	bridge_msg_set_queue_id,
-};
-
-static struct notifier_block dsp_mbox_notifier = {
-	.notifier_call = io_mbox_msg,
-};
-
-static inline void flush_all(struct bridge_dev_context *dev_context)
-{
-	if (dev_context->brd_state == BRD_DSP_HIBERNATION ||
-	    dev_context->brd_state == BRD_HIBERNATION)
-		wake_dsp(dev_context, NULL);
-
-	hw_mmu_tlb_flush_all(dev_context->dsp_mmu_base);
-}
-
-static void bad_page_dump(u32 pa, struct page *pg)
-{
-	pr_emerg("DSPBRIDGE: MAP function: COUNT 0 FOR PA 0x%x\n", pa);
-	pr_emerg("Bad page state in process '%s'\n"
-		 "page:%p flags:0x%0*lx mapping:%p mapcount:%d count:%d\n"
-		 "Backtrace:\n",
-		 current->comm, pg, (int)(2 * sizeof(unsigned long)),
-		 (unsigned long)pg->flags, pg->mapping,
-		 page_mapcount(pg), page_count(pg));
-	dump_stack();
-}
-
-/*
- *  ======== bridge_drv_entry ========
- *  purpose:
- *      Bridge Driver entry point.
- */
-void bridge_drv_entry(struct bridge_drv_interface **drv_intf,
-		   const char *driver_file_name)
-{
-	if (strcmp(driver_file_name, "UMA") == 0)
-		*drv_intf = &drv_interface_fxns;
-	else
-		dev_dbg(bridge, "%s Unknown Bridge file name", __func__);
-
-}
-
-/*
- *  ======== bridge_brd_monitor ========
- *  purpose:
- *      This bridge_brd_monitor puts DSP into a Loadable state.
- *      i.e Application can load and start the device.
- *
- *  Preconditions:
- *      Device in 'OFF' state.
- */
-static int bridge_brd_monitor(struct bridge_dev_context *dev_ctxt)
-{
-	struct bridge_dev_context *dev_context = dev_ctxt;
-	u32 temp;
-	struct omap_dsp_platform_data *pdata =
-		omap_dspbridge_dev->dev.platform_data;
-
-	temp = (*pdata->dsp_prm_read)(OMAP3430_IVA2_MOD, OMAP2_PM_PWSTST) &
-					OMAP_POWERSTATEST_MASK;
-	if (!(temp & 0x02)) {
-		/* IVA2 is not in ON state */
-		/* Read and set PM_PWSTCTRL_IVA2  to ON */
-		(*pdata->dsp_prm_rmw_bits)(OMAP_POWERSTATEST_MASK,
-			PWRDM_POWER_ON, OMAP3430_IVA2_MOD, OMAP2_PM_PWSTCTRL);
-		/* Set the SW supervised state transition */
-		(*pdata->dsp_cm_write)(OMAP34XX_CLKSTCTRL_FORCE_WAKEUP,
-					OMAP3430_IVA2_MOD, OMAP2_CM_CLKSTCTRL);
-
-		/* Wait until the state has moved to ON */
-		while ((*pdata->dsp_prm_read)(OMAP3430_IVA2_MOD,
-					      OMAP2_PM_PWSTST) &
-						OMAP_INTRANSITION_MASK)
-			;
-		/* Disable Automatic transition */
-		(*pdata->dsp_cm_write)(OMAP34XX_CLKSTCTRL_DISABLE_AUTO,
-					OMAP3430_IVA2_MOD, OMAP2_CM_CLKSTCTRL);
-	}
-	(*pdata->dsp_prm_rmw_bits)(OMAP3430_RST2_IVA2_MASK, 0,
-					OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL);
-	dsp_clk_enable(DSP_CLK_IVA2);
-
-	/* set the device state to IDLE */
-	dev_context->brd_state = BRD_IDLE;
-
-	return 0;
-}
-
-/*
- *  ======== bridge_brd_read ========
- *  purpose:
- *      Reads buffers for DSP memory.
- */
-static int bridge_brd_read(struct bridge_dev_context *dev_ctxt,
-				  u8 *host_buff, u32 dsp_addr,
-				  u32 ul_num_bytes, u32 mem_type)
-{
-	int status = 0;
-	struct bridge_dev_context *dev_context = dev_ctxt;
-	u32 offset;
-	u32 dsp_base_addr = dev_ctxt->dsp_base_addr;
-
-	if (dsp_addr < dev_context->dsp_start_add) {
-		status = -EPERM;
-		return status;
-	}
-	/* change here to account for the 3 bands of the DSP internal memory */
-	if ((dsp_addr - dev_context->dsp_start_add) <
-	    dev_context->internal_size) {
-		offset = dsp_addr - dev_context->dsp_start_add;
-	} else {
-		status = read_ext_dsp_data(dev_context, host_buff, dsp_addr,
-					   ul_num_bytes, mem_type);
-		return status;
-	}
-	/* copy the data from DSP memory */
-	memcpy(host_buff, (void *)(dsp_base_addr + offset), ul_num_bytes);
-	return status;
-}
-
-/*
- *  ======== bridge_brd_set_state ========
- *  purpose:
- *      This routine updates the Board status.
- */
-static int bridge_brd_set_state(struct bridge_dev_context *dev_ctxt,
-				    u32 brd_state)
-{
-	int status = 0;
-	struct bridge_dev_context *dev_context = dev_ctxt;
-
-	dev_context->brd_state = brd_state;
-	return status;
-}
-
-/*
- *  ======== bridge_brd_start ========
- *  purpose:
- *      Initializes DSP MMU and Starts DSP.
- *
- *  Preconditions:
- *  a) DSP domain is 'ACTIVE'.
- *  b) DSP_RST1 is asserted.
- *  b) DSP_RST2 is released.
- */
-static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
-				   u32 dsp_addr)
-{
-	int status = 0;
-	struct bridge_dev_context *dev_context = dev_ctxt;
-	void __iomem *sync_addr;
-	u32 ul_shm_base;	/* Gpp Phys SM base addr(byte) */
-	u32 ul_shm_base_virt;	/* Dsp Virt SM base addr */
-	u32 ul_tlb_base_virt;	/* Base of MMU TLB entry */
-	u32 shm_sync_pa;
-	/* Offset of shm_base_virt from tlb_base_virt */
-	u32 ul_shm_offset_virt;
-	s32 entry_ndx;
-	s32 itmp_entry_ndx = 0;	/* DSP-MMU TLB entry base address */
-	struct cfg_hostres *resources = NULL;
-	u32 temp;
-	u32 ul_dsp_clk_rate;
-	u32 ul_dsp_clk_addr;
-	u32 ul_bios_gp_timer;
-	u32 clk_cmd;
-	struct io_mgr *hio_mgr;
-	u32 ul_load_monitor_timer;
-	u32 wdt_en = 0;
-	struct omap_dsp_platform_data *pdata =
-		omap_dspbridge_dev->dev.platform_data;
-
-	/* The device context contains all the mmu setup info from when the
-	 * last dsp base image was loaded. The first entry is always
-	 * SHMMEM base. */
-	/* Get SHM_BEG - convert to byte address */
-	(void)dev_get_symbol(dev_context->dev_obj, SHMBASENAME,
-			     &ul_shm_base_virt);
-	ul_shm_base_virt *= DSPWORDSIZE;
-	/* DSP Virtual address */
-	ul_tlb_base_virt = dev_context->atlb_entry[0].dsp_va;
-	ul_shm_offset_virt =
-	    ul_shm_base_virt - (ul_tlb_base_virt * DSPWORDSIZE);
-	/* Kernel logical address */
-	ul_shm_base = dev_context->atlb_entry[0].gpp_va + ul_shm_offset_virt;
-
-	/* SHM physical sync address */
-	shm_sync_pa = dev_context->atlb_entry[0].gpp_pa + ul_shm_offset_virt +
-			SHMSYNCOFFSET;
-
-	/* 2nd wd is used as sync field */
-	sync_addr = ioremap(shm_sync_pa, SZ_32);
-	if (!sync_addr)
-		return -ENOMEM;
-
-	/* Write a signature into the shm base + offset; this will
-	 * get cleared when the DSP program starts. */
-	if ((ul_shm_base_virt == 0) || (ul_shm_base == 0)) {
-		pr_err("%s: Illegal SM base\n", __func__);
-		status = -EPERM;
-	} else
-		__raw_writel(0xffffffff, sync_addr);
-
-	if (!status) {
-		resources = dev_context->resources;
-		if (!resources)
-			status = -EPERM;
-
-		/* Assert RST1 i.e only the RST only for DSP megacell */
-		if (!status) {
-			(*pdata->dsp_prm_rmw_bits)(OMAP3430_RST1_IVA2_MASK,
-					OMAP3430_RST1_IVA2_MASK,
-					OMAP3430_IVA2_MOD,
-					OMAP2_RM_RSTCTRL);
-
-			/* Mask address with 1K for compatibility */
-			pdata->set_bootaddr(dsp_addr &
-						OMAP3_IVA2_BOOTADDR_MASK);
-			pdata->set_bootmode(dsp_debug ? IDLE : DIRECT);
-		}
-	}
-	if (!status) {
-		/* Reset and Unreset the RST2, so that BOOTADDR is copied to
-		 * IVA2 SYSC register */
-		(*pdata->dsp_prm_rmw_bits)(OMAP3430_RST2_IVA2_MASK,
-			OMAP3430_RST2_IVA2_MASK, OMAP3430_IVA2_MOD,
-			OMAP2_RM_RSTCTRL);
-		udelay(100);
-		(*pdata->dsp_prm_rmw_bits)(OMAP3430_RST2_IVA2_MASK, 0,
-					OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL);
-		udelay(100);
-
-		/* Disbale the DSP MMU */
-		hw_mmu_disable(resources->dmmu_base);
-		/* Disable TWL */
-		hw_mmu_twl_disable(resources->dmmu_base);
-
-		/* Only make TLB entry if both addresses are non-zero */
-		for (entry_ndx = 0; entry_ndx < BRDIOCTL_NUMOFMMUTLB;
-		     entry_ndx++) {
-			struct bridge_ioctl_extproc *e =
-				&dev_context->atlb_entry[entry_ndx];
-			struct hw_mmu_map_attrs_t map_attrs = {
-				.endianism = e->endianism,
-				.element_size = e->elem_size,
-				.mixed_size = e->mixed_mode,
-			};
-
-			if (!e->gpp_pa || !e->dsp_va)
-				continue;
-
-			dev_dbg(bridge,
-					"MMU %d, pa: 0x%x, va: 0x%x, size: 0x%x",
-					itmp_entry_ndx,
-					e->gpp_pa,
-					e->dsp_va,
-					e->size);
-
-			hw_mmu_tlb_add(dev_context->dsp_mmu_base,
-					e->gpp_pa,
-					e->dsp_va,
-					e->size,
-					itmp_entry_ndx,
-					&map_attrs, 1, 1);
-
-			itmp_entry_ndx++;
-		}
-	}
-
-	/* Lock the above TLB entries and get the BIOS and load monitor timer
-	 * information */
-	if (!status) {
-		hw_mmu_num_locked_set(resources->dmmu_base, itmp_entry_ndx);
-		hw_mmu_victim_num_set(resources->dmmu_base, itmp_entry_ndx);
-		hw_mmu_ttb_set(resources->dmmu_base,
-			       dev_context->pt_attrs->l1_base_pa);
-		hw_mmu_twl_enable(resources->dmmu_base);
-		/* Enable the SmartIdle and AutoIdle bit for MMU_SYSCONFIG */
-
-		temp = __raw_readl((resources->dmmu_base) + 0x10);
-		temp = (temp & 0xFFFFFFEF) | 0x11;
-		__raw_writel(temp, (resources->dmmu_base) + 0x10);
-
-		/* Let the DSP MMU run */
-		hw_mmu_enable(resources->dmmu_base);
-
-		/* Enable the BIOS clock */
-		(void)dev_get_symbol(dev_context->dev_obj,
-				     BRIDGEINIT_BIOSGPTIMER, &ul_bios_gp_timer);
-		(void)dev_get_symbol(dev_context->dev_obj,
-				     BRIDGEINIT_LOADMON_GPTIMER,
-				     &ul_load_monitor_timer);
-	}
-
-	if (!status) {
-		if (ul_load_monitor_timer != 0xFFFF) {
-			clk_cmd = (BPWR_ENABLE_CLOCK << MBX_PM_CLK_CMDSHIFT) |
-			    ul_load_monitor_timer;
-			dsp_peripheral_clk_ctrl(dev_context, &clk_cmd);
-		} else {
-			dev_dbg(bridge, "Not able to get the symbol for Load "
-				"Monitor Timer\n");
-		}
-	}
-
-	if (!status) {
-		if (ul_bios_gp_timer != 0xFFFF) {
-			clk_cmd = (BPWR_ENABLE_CLOCK << MBX_PM_CLK_CMDSHIFT) |
-			    ul_bios_gp_timer;
-			dsp_peripheral_clk_ctrl(dev_context, &clk_cmd);
-		} else {
-			dev_dbg(bridge,
-				"Not able to get the symbol for BIOS Timer\n");
-		}
-	}
-
-	if (!status) {
-		/* Set the DSP clock rate */
-		(void)dev_get_symbol(dev_context->dev_obj,
-				     "_BRIDGEINIT_DSP_FREQ", &ul_dsp_clk_addr);
-		/*Set Autoidle Mode for IVA2 PLL */
-		(*pdata->dsp_cm_write)(1 << OMAP3430_AUTO_IVA2_DPLL_SHIFT,
-				OMAP3430_IVA2_MOD, OMAP3430_CM_AUTOIDLE_PLL);
-
-		if ((unsigned int *)ul_dsp_clk_addr != NULL) {
-			/* Get the clock rate */
-			ul_dsp_clk_rate = dsp_clk_get_iva2_rate();
-			dev_dbg(bridge, "%s: DSP clock rate (KHZ): 0x%x \n",
-				__func__, ul_dsp_clk_rate);
-			(void)bridge_brd_write(dev_context,
-					       (u8 *) &ul_dsp_clk_rate,
-					       ul_dsp_clk_addr, sizeof(u32), 0);
-		}
-		/*
-		 * Enable Mailbox events and also drain any pending
-		 * stale messages.
-		 */
-		dev_context->mbox = omap_mbox_get("dsp", &dsp_mbox_notifier);
-		if (IS_ERR(dev_context->mbox)) {
-			dev_context->mbox = NULL;
-			pr_err("%s: Failed to get dsp mailbox handle\n",
-								__func__);
-			status = -EPERM;
-		}
-
-	}
-	if (!status) {
-/*PM_IVA2GRPSEL_PER = 0xC0;*/
-		temp = readl(resources->per_pm_base + 0xA8);
-		temp = (temp & 0xFFFFFF30) | 0xC0;
-		writel(temp, resources->per_pm_base + 0xA8);
-
-/*PM_MPUGRPSEL_PER &= 0xFFFFFF3F; */
-		temp = readl(resources->per_pm_base + 0xA4);
-		temp = (temp & 0xFFFFFF3F);
-		writel(temp, resources->per_pm_base + 0xA4);
-/*CM_SLEEPDEP_PER |= 0x04; */
-		temp = readl(resources->per_base + 0x44);
-		temp = (temp & 0xFFFFFFFB) | 0x04;
-		writel(temp, resources->per_base + 0x44);
-
-/*CM_CLKSTCTRL_IVA2 = 0x00000003 -To Allow automatic transitions */
-		(*pdata->dsp_cm_write)(OMAP34XX_CLKSTCTRL_ENABLE_AUTO,
-					OMAP3430_IVA2_MOD, OMAP2_CM_CLKSTCTRL);
-
-		/* Let DSP go */
-		dev_dbg(bridge, "%s Unreset\n", __func__);
-		/* Enable DSP MMU Interrupts */
-		hw_mmu_event_enable(resources->dmmu_base,
-				    HW_MMU_ALL_INTERRUPTS);
-		/* release the RST1, DSP starts executing now .. */
-		(*pdata->dsp_prm_rmw_bits)(OMAP3430_RST1_IVA2_MASK, 0,
-					OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL);
-
-		dev_dbg(bridge, "Waiting for Sync @ 0x%x\n", *(u32 *)sync_addr);
-		dev_dbg(bridge, "DSP c_int00 Address =  0x%x\n", dsp_addr);
-		if (dsp_debug)
-			while (__raw_readw(sync_addr))
-				;
-
-		/* Wait for DSP to clear word in shared memory */
-		/* Read the Location */
-		if (!wait_for_start(dev_context, sync_addr))
-			status = -ETIMEDOUT;
-
-		dev_get_symbol(dev_context->dev_obj, "_WDT_enable", &wdt_en);
-		if (wdt_en) {
-			/* Start wdt */
-			dsp_wdt_sm_set((void *)ul_shm_base);
-			dsp_wdt_enable(true);
-		}
-
-		status = dev_get_io_mgr(dev_context->dev_obj, &hio_mgr);
-		if (hio_mgr) {
-			io_sh_msetting(hio_mgr, SHM_OPPINFO, NULL);
-			/* Write the synchronization bit to indicate the
-			 * completion of OPP table update to DSP
-			 */
-			__raw_writel(0XCAFECAFE, sync_addr);
-
-			/* update board state */
-			dev_context->brd_state = BRD_RUNNING;
-			/* (void)chnlsm_enable_interrupt(dev_context); */
-		} else {
-			dev_context->brd_state = BRD_UNKNOWN;
-		}
-	}
-
-	iounmap(sync_addr);
-
-	return status;
-}
-
-/*
- *  ======== bridge_brd_stop ========
- *  purpose:
- *      Puts DSP in self loop.
- *
- *  Preconditions :
- *  a) None
- */
-static int bridge_brd_stop(struct bridge_dev_context *dev_ctxt)
-{
-	int status = 0;
-	struct bridge_dev_context *dev_context = dev_ctxt;
-	struct pg_table_attrs *pt_attrs;
-	u32 dsp_pwr_state;
-	struct omap_dsp_platform_data *pdata =
-		omap_dspbridge_dev->dev.platform_data;
-
-	if (dev_context->brd_state == BRD_STOPPED)
-		return status;
-
-	/* as per TRM, it is advised to first drive the IVA2 to 'Standby' mode,
-	 * before turning off the clocks.. This is to ensure that there are no
-	 * pending L3 or other transactons from IVA2 */
-	dsp_pwr_state = (*pdata->dsp_prm_read)
-		(OMAP3430_IVA2_MOD, OMAP2_PM_PWSTST) & OMAP_POWERSTATEST_MASK;
-	if (dsp_pwr_state != PWRDM_POWER_OFF) {
-		(*pdata->dsp_prm_rmw_bits)(OMAP3430_RST2_IVA2_MASK, 0,
-					OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL);
-		sm_interrupt_dsp(dev_context, MBX_PM_DSPIDLE);
-		mdelay(10);
-
-		/* IVA2 is not in OFF state */
-		/* Set PM_PWSTCTRL_IVA2  to OFF */
-		(*pdata->dsp_prm_rmw_bits)(OMAP_POWERSTATEST_MASK,
-			PWRDM_POWER_OFF, OMAP3430_IVA2_MOD, OMAP2_PM_PWSTCTRL);
-		/* Set the SW supervised state transition for Sleep */
-		(*pdata->dsp_cm_write)(OMAP34XX_CLKSTCTRL_FORCE_SLEEP,
-					OMAP3430_IVA2_MOD, OMAP2_CM_CLKSTCTRL);
-	}
-	udelay(10);
-	/* Release the Ext Base virtual Address as the next DSP Program
-	 * may have a different load address */
-	if (dev_context->dsp_ext_base_addr)
-		dev_context->dsp_ext_base_addr = 0;
-
-	dev_context->brd_state = BRD_STOPPED;	/* update board state */
-
-	dsp_wdt_enable(false);
-
-	/* This is a good place to clear the MMU page tables as well */
-	if (dev_context->pt_attrs) {
-		pt_attrs = dev_context->pt_attrs;
-		memset((u8 *) pt_attrs->l1_base_va, 0x00, pt_attrs->l1_size);
-		memset((u8 *) pt_attrs->l2_base_va, 0x00, pt_attrs->l2_size);
-		memset((u8 *) pt_attrs->pg_info, 0x00,
-		       (pt_attrs->l2_num_pages * sizeof(struct page_info)));
-	}
-	/* Disable the mailbox interrupts */
-	if (dev_context->mbox) {
-		omap_mbox_disable_irq(dev_context->mbox, IRQ_RX);
-		omap_mbox_put(dev_context->mbox, &dsp_mbox_notifier);
-		dev_context->mbox = NULL;
-	}
-	/* Reset IVA2 clocks*/
-	(*pdata->dsp_prm_write)(OMAP3430_RST1_IVA2_MASK |
-			OMAP3430_RST2_IVA2_MASK | OMAP3430_RST3_IVA2_MASK,
-			OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL);
-
-	dsp_clock_disable_all(dev_context->dsp_per_clks);
-	dsp_clk_disable(DSP_CLK_IVA2);
-
-	return status;
-}
-
-/*
- *  ======== bridge_brd_status ========
- *      Returns the board status.
- */
-static int bridge_brd_status(struct bridge_dev_context *dev_ctxt,
-				    int *board_state)
-{
-	struct bridge_dev_context *dev_context = dev_ctxt;
-	*board_state = dev_context->brd_state;
-	return 0;
-}
-
-/*
- *  ======== bridge_brd_write ========
- *      Copies the buffers to DSP internal or external memory.
- */
-static int bridge_brd_write(struct bridge_dev_context *dev_ctxt,
-				   u8 *host_buff, u32 dsp_addr,
-				   u32 ul_num_bytes, u32 mem_type)
-{
-	int status = 0;
-	struct bridge_dev_context *dev_context = dev_ctxt;
-
-	if (dsp_addr < dev_context->dsp_start_add) {
-		status = -EPERM;
-		return status;
-	}
-	if ((dsp_addr - dev_context->dsp_start_add) <
-	    dev_context->internal_size) {
-		status = write_dsp_data(dev_ctxt, host_buff, dsp_addr,
-					ul_num_bytes, mem_type);
-	} else {
-		status = write_ext_dsp_data(dev_context, host_buff, dsp_addr,
-					    ul_num_bytes, mem_type, false);
-	}
-
-	return status;
-}
-
-/*
- *  ======== bridge_dev_create ========
- *      Creates a driver object. Puts DSP in self loop.
- */
-static int bridge_dev_create(struct bridge_dev_context
-					**dev_cntxt,
-					struct dev_object *hdev_obj,
-					struct cfg_hostres *config_param)
-{
-	int status = 0;
-	struct bridge_dev_context *dev_context = NULL;
-	s32 entry_ndx;
-	struct cfg_hostres *resources = config_param;
-	struct pg_table_attrs *pt_attrs;
-	u32 pg_tbl_pa;
-	u32 pg_tbl_va;
-	u32 align_size;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	/* Allocate and initialize a data structure to contain the bridge driver
-	 *  state, which becomes the context for later calls into this driver */
-	dev_context = kzalloc(sizeof(struct bridge_dev_context), GFP_KERNEL);
-	if (!dev_context) {
-		status = -ENOMEM;
-		goto func_end;
-	}
-
-	dev_context->dsp_start_add = (u32) OMAP_GEM_BASE;
-	dev_context->self_loop = (u32) NULL;
-	dev_context->dsp_per_clks = 0;
-	dev_context->internal_size = OMAP_DSP_SIZE;
-	/*  Clear dev context MMU table entries.
-	 *  These get set on bridge_io_on_loaded() call after program loaded. */
-	for (entry_ndx = 0; entry_ndx < BRDIOCTL_NUMOFMMUTLB; entry_ndx++) {
-		dev_context->atlb_entry[entry_ndx].gpp_pa =
-		    dev_context->atlb_entry[entry_ndx].dsp_va = 0;
-	}
-	dev_context->dsp_base_addr = (u32) MEM_LINEAR_ADDRESS((void *)
-								 (config_param->
-								  mem_base
-								  [3]),
-								 config_param->
-								 mem_length
-								 [3]);
-	if (!dev_context->dsp_base_addr)
-		status = -EPERM;
-
-	pt_attrs = kzalloc(sizeof(struct pg_table_attrs), GFP_KERNEL);
-	if (pt_attrs != NULL) {
-		pt_attrs->l1_size = SZ_16K; /* 4096 entries of 32 bits */
-		align_size = pt_attrs->l1_size;
-		/* Align sizes are expected to be power of 2 */
-		/* we like to get aligned on L1 table size */
-		pg_tbl_va = (u32) mem_alloc_phys_mem(pt_attrs->l1_size,
-						     align_size, &pg_tbl_pa);
-
-		/* Check if the PA is aligned for us */
-		if ((pg_tbl_pa) & (align_size - 1)) {
-			/* PA not aligned to page table size ,
-			 * try with more allocation and align */
-			mem_free_phys_mem((void *)pg_tbl_va, pg_tbl_pa,
-					  pt_attrs->l1_size);
-			/* we like to get aligned on L1 table size */
-			pg_tbl_va =
-			    (u32) mem_alloc_phys_mem((pt_attrs->l1_size) * 2,
-						     align_size, &pg_tbl_pa);
-			/* We should be able to get aligned table now */
-			pt_attrs->l1_tbl_alloc_pa = pg_tbl_pa;
-			pt_attrs->l1_tbl_alloc_va = pg_tbl_va;
-			pt_attrs->l1_tbl_alloc_sz = pt_attrs->l1_size * 2;
-			/* Align the PA to the next 'align'  boundary */
-			pt_attrs->l1_base_pa =
-			    ((pg_tbl_pa) +
-			     (align_size - 1)) & (~(align_size - 1));
-			pt_attrs->l1_base_va =
-			    pg_tbl_va + (pt_attrs->l1_base_pa - pg_tbl_pa);
-		} else {
-			/* We got aligned PA, cool */
-			pt_attrs->l1_tbl_alloc_pa = pg_tbl_pa;
-			pt_attrs->l1_tbl_alloc_va = pg_tbl_va;
-			pt_attrs->l1_tbl_alloc_sz = pt_attrs->l1_size;
-			pt_attrs->l1_base_pa = pg_tbl_pa;
-			pt_attrs->l1_base_va = pg_tbl_va;
-		}
-		if (pt_attrs->l1_base_va)
-			memset((u8 *) pt_attrs->l1_base_va, 0x00,
-			       pt_attrs->l1_size);
-
-		/* number of L2 page tables = DMM pool used + SHMMEM +EXTMEM +
-		 * L4 pages */
-		pt_attrs->l2_num_pages = ((DMMPOOLSIZE >> 20) + 6);
-		pt_attrs->l2_size = HW_MMU_COARSE_PAGE_SIZE *
-		    pt_attrs->l2_num_pages;
-		align_size = 4;	/* Make it u32 aligned */
-		/* we like to get aligned on L1 table size */
-		pg_tbl_va = (u32) mem_alloc_phys_mem(pt_attrs->l2_size,
-						     align_size, &pg_tbl_pa);
-		pt_attrs->l2_tbl_alloc_pa = pg_tbl_pa;
-		pt_attrs->l2_tbl_alloc_va = pg_tbl_va;
-		pt_attrs->l2_tbl_alloc_sz = pt_attrs->l2_size;
-		pt_attrs->l2_base_pa = pg_tbl_pa;
-		pt_attrs->l2_base_va = pg_tbl_va;
-
-		if (pt_attrs->l2_base_va)
-			memset((u8 *) pt_attrs->l2_base_va, 0x00,
-			       pt_attrs->l2_size);
-
-		pt_attrs->pg_info = kzalloc(pt_attrs->l2_num_pages *
-					sizeof(struct page_info), GFP_KERNEL);
-		dev_dbg(bridge,
-			"L1 pa %x, va %x, size %x\n L2 pa %x, va "
-			"%x, size %x\n", pt_attrs->l1_base_pa,
-			pt_attrs->l1_base_va, pt_attrs->l1_size,
-			pt_attrs->l2_base_pa, pt_attrs->l2_base_va,
-			pt_attrs->l2_size);
-		dev_dbg(bridge, "pt_attrs %p L2 NumPages %x pg_info %p\n",
-			pt_attrs, pt_attrs->l2_num_pages, pt_attrs->pg_info);
-	}
-	if ((pt_attrs != NULL) && (pt_attrs->l1_base_va != 0) &&
-	    (pt_attrs->l2_base_va != 0) && (pt_attrs->pg_info != NULL))
-		dev_context->pt_attrs = pt_attrs;
-	else
-		status = -ENOMEM;
-
-	if (!status) {
-		spin_lock_init(&pt_attrs->pg_lock);
-		dev_context->tc_word_swap_on = drv_datap->tc_wordswapon;
-
-		/* Set the Clock Divisor for the DSP module */
-		udelay(5);
-		/* MMU address is obtained from the host
-		 * resources struct */
-		dev_context->dsp_mmu_base = resources->dmmu_base;
-	}
-	if (!status) {
-		dev_context->dev_obj = hdev_obj;
-		/* Store current board state. */
-		dev_context->brd_state = BRD_UNKNOWN;
-		dev_context->resources = resources;
-		dsp_clk_enable(DSP_CLK_IVA2);
-		bridge_brd_stop(dev_context);
-		/* Return ptr to our device state to the DSP API for storage */
-		*dev_cntxt = dev_context;
-	} else {
-		if (pt_attrs != NULL) {
-			kfree(pt_attrs->pg_info);
-
-			if (pt_attrs->l2_tbl_alloc_va) {
-				mem_free_phys_mem((void *)
-						  pt_attrs->l2_tbl_alloc_va,
-						  pt_attrs->l2_tbl_alloc_pa,
-						  pt_attrs->l2_tbl_alloc_sz);
-			}
-			if (pt_attrs->l1_tbl_alloc_va) {
-				mem_free_phys_mem((void *)
-						  pt_attrs->l1_tbl_alloc_va,
-						  pt_attrs->l1_tbl_alloc_pa,
-						  pt_attrs->l1_tbl_alloc_sz);
-			}
-		}
-		kfree(pt_attrs);
-		kfree(dev_context);
-	}
-func_end:
-	return status;
-}
-
-/*
- *  ======== bridge_dev_ctrl ========
- *      Receives device specific commands.
- */
-static int bridge_dev_ctrl(struct bridge_dev_context *dev_context,
-				  u32 dw_cmd, void *pargs)
-{
-	int status = 0;
-	struct bridge_ioctl_extproc *pa_ext_proc =
-					(struct bridge_ioctl_extproc *)pargs;
-	s32 ndx;
-
-	switch (dw_cmd) {
-	case BRDIOCTL_CHNLREAD:
-		break;
-	case BRDIOCTL_CHNLWRITE:
-		break;
-	case BRDIOCTL_SETMMUCONFIG:
-		/* store away dsp-mmu setup values for later use */
-		for (ndx = 0; ndx < BRDIOCTL_NUMOFMMUTLB; ndx++, pa_ext_proc++)
-			dev_context->atlb_entry[ndx] = *pa_ext_proc;
-		break;
-	case BRDIOCTL_DEEPSLEEP:
-	case BRDIOCTL_EMERGENCYSLEEP:
-		/* Currently only DSP Idle is supported Need to update for
-		 * later releases */
-		status = sleep_dsp(dev_context, PWR_DEEPSLEEP, pargs);
-		break;
-	case BRDIOCTL_WAKEUP:
-		status = wake_dsp(dev_context, pargs);
-		break;
-	case BRDIOCTL_CLK_CTRL:
-		status = 0;
-		/* Looking For Baseport Fix for Clocks */
-		status = dsp_peripheral_clk_ctrl(dev_context, pargs);
-		break;
-	case BRDIOCTL_PWR_HIBERNATE:
-		status = handle_hibernation_from_dsp(dev_context);
-		break;
-	case BRDIOCTL_PRESCALE_NOTIFY:
-		status = pre_scale_dsp(dev_context, pargs);
-		break;
-	case BRDIOCTL_POSTSCALE_NOTIFY:
-		status = post_scale_dsp(dev_context, pargs);
-		break;
-	case BRDIOCTL_CONSTRAINT_REQUEST:
-		status = handle_constraints_set(dev_context, pargs);
-		break;
-	default:
-		status = -EPERM;
-		break;
-	}
-	return status;
-}
-
-/*
- *  ======== bridge_dev_destroy ========
- *      Destroys the driver object.
- */
-static int bridge_dev_destroy(struct bridge_dev_context *dev_ctxt)
-{
-	struct pg_table_attrs *pt_attrs;
-	int status = 0;
-	struct bridge_dev_context *dev_context = (struct bridge_dev_context *)
-	    dev_ctxt;
-	struct cfg_hostres *host_res;
-	u32 shm_size;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	/* It should never happen */
-	if (!dev_ctxt)
-		return -EFAULT;
-
-	/* first put the device to stop state */
-	bridge_brd_stop(dev_context);
-	if (dev_context->pt_attrs) {
-		pt_attrs = dev_context->pt_attrs;
-		kfree(pt_attrs->pg_info);
-
-		if (pt_attrs->l2_tbl_alloc_va) {
-			mem_free_phys_mem((void *)pt_attrs->l2_tbl_alloc_va,
-					  pt_attrs->l2_tbl_alloc_pa,
-					  pt_attrs->l2_tbl_alloc_sz);
-		}
-		if (pt_attrs->l1_tbl_alloc_va) {
-			mem_free_phys_mem((void *)pt_attrs->l1_tbl_alloc_va,
-					  pt_attrs->l1_tbl_alloc_pa,
-					  pt_attrs->l1_tbl_alloc_sz);
-		}
-		kfree(pt_attrs);
-
-	}
-
-	if (dev_context->resources) {
-		host_res = dev_context->resources;
-		shm_size = drv_datap->shm_size;
-		if (shm_size >= 0x10000) {
-			if ((host_res->mem_base[1]) &&
-			    (host_res->mem_phys[1])) {
-				mem_free_phys_mem((void *)
-						  host_res->mem_base
-						  [1],
-						  host_res->mem_phys
-						  [1], shm_size);
-			}
-		} else {
-			dev_dbg(bridge, "%s: Error getting shm size "
-				"from registry: %x. Not calling "
-				"mem_free_phys_mem\n", __func__,
-				status);
-		}
-		host_res->mem_base[1] = 0;
-		host_res->mem_phys[1] = 0;
-
-		if (host_res->mem_base[0])
-			iounmap((void *)host_res->mem_base[0]);
-		if (host_res->mem_base[2])
-			iounmap((void *)host_res->mem_base[2]);
-		if (host_res->mem_base[3])
-			iounmap((void *)host_res->mem_base[3]);
-		if (host_res->mem_base[4])
-			iounmap((void *)host_res->mem_base[4]);
-		if (host_res->dmmu_base)
-			iounmap(host_res->dmmu_base);
-		if (host_res->per_base)
-			iounmap(host_res->per_base);
-		if (host_res->per_pm_base)
-			iounmap((void *)host_res->per_pm_base);
-		if (host_res->core_pm_base)
-			iounmap((void *)host_res->core_pm_base);
-
-		host_res->mem_base[0] = (u32) NULL;
-		host_res->mem_base[2] = (u32) NULL;
-		host_res->mem_base[3] = (u32) NULL;
-		host_res->mem_base[4] = (u32) NULL;
-		host_res->dmmu_base = NULL;
-
-		kfree(host_res);
-	}
-
-	/* Free the driver's device context: */
-	kfree(drv_datap->base_img);
-	kfree((void *)dev_ctxt);
-	return status;
-}
-
-static int bridge_brd_mem_copy(struct bridge_dev_context *dev_ctxt,
-				   u32 dsp_dest_addr, u32 dsp_src_addr,
-				   u32 ul_num_bytes, u32 mem_type)
-{
-	int status = 0;
-	u32 src_addr = dsp_src_addr;
-	u32 dest_addr = dsp_dest_addr;
-	u32 copy_bytes = 0;
-	u32 total_bytes = ul_num_bytes;
-	u8 host_buf[BUFFERSIZE];
-	struct bridge_dev_context *dev_context = dev_ctxt;
-
-	while (total_bytes > 0 && !status) {
-		copy_bytes =
-		    total_bytes > BUFFERSIZE ? BUFFERSIZE : total_bytes;
-		/* Read from External memory */
-		status = read_ext_dsp_data(dev_ctxt, host_buf, src_addr,
-					   copy_bytes, mem_type);
-		if (!status) {
-			if (dest_addr < (dev_context->dsp_start_add +
-					 dev_context->internal_size)) {
-				/* Write to Internal memory */
-				status = write_dsp_data(dev_ctxt, host_buf,
-							dest_addr, copy_bytes,
-							mem_type);
-			} else {
-				/* Write to External memory */
-				status =
-				    write_ext_dsp_data(dev_ctxt, host_buf,
-						       dest_addr, copy_bytes,
-						       mem_type, false);
-			}
-		}
-		total_bytes -= copy_bytes;
-		src_addr += copy_bytes;
-		dest_addr += copy_bytes;
-	}
-	return status;
-}
-
-/* Mem Write does not halt the DSP to write unlike bridge_brd_write */
-static int bridge_brd_mem_write(struct bridge_dev_context *dev_ctxt,
-				    u8 *host_buff, u32 dsp_addr,
-				    u32 ul_num_bytes, u32 mem_type)
-{
-	int status = 0;
-	struct bridge_dev_context *dev_context = dev_ctxt;
-	u32 ul_remain_bytes = 0;
-	u32 ul_bytes = 0;
-
-	ul_remain_bytes = ul_num_bytes;
-	while (ul_remain_bytes > 0 && !status) {
-		ul_bytes =
-		    ul_remain_bytes > BUFFERSIZE ? BUFFERSIZE : ul_remain_bytes;
-		if (dsp_addr < (dev_context->dsp_start_add +
-				 dev_context->internal_size)) {
-			status =
-			    write_dsp_data(dev_ctxt, host_buff, dsp_addr,
-					   ul_bytes, mem_type);
-		} else {
-			status = write_ext_dsp_data(dev_ctxt, host_buff,
-						    dsp_addr, ul_bytes,
-						    mem_type, true);
-		}
-		ul_remain_bytes -= ul_bytes;
-		dsp_addr += ul_bytes;
-		host_buff = host_buff + ul_bytes;
-	}
-	return status;
-}
-
-/*
- *  ======== bridge_brd_mem_map ========
- *      This function maps MPU buffer to the DSP address space. It performs
- *  linear to physical address translation if required. It translates each
- *  page since linear addresses can be physically non-contiguous
- *  All address & size arguments are assumed to be page aligned (in proc.c)
- *
- *  TODO: Disable MMU while updating the page tables (but that'll stall DSP)
- */
-static int bridge_brd_mem_map(struct bridge_dev_context *dev_ctxt,
-				  u32 ul_mpu_addr, u32 virt_addr,
-				  u32 ul_num_bytes, u32 ul_map_attr,
-				  struct page **mapped_pages)
-{
-	u32 attrs;
-	int status = 0;
-	struct bridge_dev_context *dev_context = dev_ctxt;
-	struct hw_mmu_map_attrs_t hw_attrs;
-	struct vm_area_struct *vma;
-	struct mm_struct *mm = current->mm;
-	u32 write = 0;
-	u32 num_usr_pgs = 0;
-	struct page *mapped_page, *pg;
-	s32 pg_num;
-	u32 va = virt_addr;
-	struct task_struct *curr_task = current;
-	u32 pg_i = 0;
-	u32 mpu_addr, pa;
-
-	dev_dbg(bridge,
-		"%s hDevCtxt %p, pa %x, va %x, size %x, ul_map_attr %x\n",
-		__func__, dev_ctxt, ul_mpu_addr, virt_addr, ul_num_bytes,
-		ul_map_attr);
-	if (ul_num_bytes == 0)
-		return -EINVAL;
-
-	if (ul_map_attr & DSP_MAP_DIR_MASK) {
-		attrs = ul_map_attr;
-	} else {
-		/* Assign default attributes */
-		attrs = ul_map_attr | (DSP_MAPVIRTUALADDR | DSP_MAPELEMSIZE16);
-	}
-	/* Take mapping properties */
-	if (attrs & DSP_MAPBIGENDIAN)
-		hw_attrs.endianism = HW_BIG_ENDIAN;
-	else
-		hw_attrs.endianism = HW_LITTLE_ENDIAN;
-
-	hw_attrs.mixed_size = (enum hw_mmu_mixed_size_t)
-	    ((attrs & DSP_MAPMIXEDELEMSIZE) >> 2);
-	/* Ignore element_size if mixed_size is enabled */
-	if (hw_attrs.mixed_size == 0) {
-		if (attrs & DSP_MAPELEMSIZE8) {
-			/* Size is 8 bit */
-			hw_attrs.element_size = HW_ELEM_SIZE8BIT;
-		} else if (attrs & DSP_MAPELEMSIZE16) {
-			/* Size is 16 bit */
-			hw_attrs.element_size = HW_ELEM_SIZE16BIT;
-		} else if (attrs & DSP_MAPELEMSIZE32) {
-			/* Size is 32 bit */
-			hw_attrs.element_size = HW_ELEM_SIZE32BIT;
-		} else if (attrs & DSP_MAPELEMSIZE64) {
-			/* Size is 64 bit */
-			hw_attrs.element_size = HW_ELEM_SIZE64BIT;
-		} else {
-			/*
-			 * Mixedsize isn't enabled, so size can't be
-			 * zero here
-			 */
-			return -EINVAL;
-		}
-	}
-	if (attrs & DSP_MAPDONOTLOCK)
-		hw_attrs.donotlockmpupage = 1;
-	else
-		hw_attrs.donotlockmpupage = 0;
-
-	if (attrs & DSP_MAPVMALLOCADDR) {
-		return mem_map_vmalloc(dev_ctxt, ul_mpu_addr, virt_addr,
-				       ul_num_bytes, &hw_attrs);
-	}
-	/*
-	 * Do OS-specific user-va to pa translation.
-	 * Combine physically contiguous regions to reduce TLBs.
-	 * Pass the translated pa to pte_update.
-	 */
-	if ((attrs & DSP_MAPPHYSICALADDR)) {
-		status = pte_update(dev_context, ul_mpu_addr, virt_addr,
-				    ul_num_bytes, &hw_attrs);
-		goto func_cont;
-	}
-
-	/*
-	 * Important Note: ul_mpu_addr is mapped from user application process
-	 * to current process - it must lie completely within the current
-	 * virtual memory address space in order to be of use to us here!
-	 */
-	down_read(&mm->mmap_sem);
-	vma = find_vma(mm, ul_mpu_addr);
-	if (vma)
-		dev_dbg(bridge,
-			"VMAfor UserBuf: ul_mpu_addr=%x, ul_num_bytes=%x, "
-			"vm_start=%lx, vm_end=%lx, vm_flags=%lx\n", ul_mpu_addr,
-			ul_num_bytes, vma->vm_start, vma->vm_end,
-			vma->vm_flags);
-
-	/*
-	 * It is observed that under some circumstances, the user buffer is
-	 * spread across several VMAs. So loop through and check if the entire
-	 * user buffer is covered
-	 */
-	while ((vma) && (ul_mpu_addr + ul_num_bytes > vma->vm_end)) {
-		/* jump to the next VMA region */
-		vma = find_vma(mm, vma->vm_end + 1);
-		dev_dbg(bridge,
-			"VMA for UserBuf ul_mpu_addr=%x ul_num_bytes=%x, "
-			"vm_start=%lx, vm_end=%lx, vm_flags=%lx\n", ul_mpu_addr,
-			ul_num_bytes, vma->vm_start, vma->vm_end,
-			vma->vm_flags);
-	}
-	if (!vma) {
-		pr_err("%s: Failed to get VMA region for 0x%x (%d)\n",
-		       __func__, ul_mpu_addr, ul_num_bytes);
-		status = -EINVAL;
-		up_read(&mm->mmap_sem);
-		goto func_cont;
-	}
-
-	if (vma->vm_flags & VM_IO) {
-		num_usr_pgs = ul_num_bytes / PG_SIZE4K;
-		mpu_addr = ul_mpu_addr;
-
-		/* Get the physical addresses for user buffer */
-		for (pg_i = 0; pg_i < num_usr_pgs; pg_i++) {
-			pa = user_va2_pa(mm, mpu_addr);
-			if (!pa) {
-				status = -EPERM;
-				pr_err("DSPBRIDGE: VM_IO mapping physical"
-				       "address is invalid\n");
-				break;
-			}
-			if (pfn_valid(__phys_to_pfn(pa))) {
-				pg = PHYS_TO_PAGE(pa);
-				get_page(pg);
-				if (page_count(pg) < 1) {
-					pr_err("Bad page in VM_IO buffer\n");
-					bad_page_dump(pa, pg);
-				}
-			}
-			status = pte_set(dev_context->pt_attrs, pa,
-					 va, HW_PAGE_SIZE4KB, &hw_attrs);
-			if (status)
-				break;
-
-			va += HW_PAGE_SIZE4KB;
-			mpu_addr += HW_PAGE_SIZE4KB;
-			pa += HW_PAGE_SIZE4KB;
-		}
-	} else {
-		num_usr_pgs = ul_num_bytes / PG_SIZE4K;
-		if (vma->vm_flags & (VM_WRITE | VM_MAYWRITE))
-			write = 1;
-
-		for (pg_i = 0; pg_i < num_usr_pgs; pg_i++) {
-			pg_num = get_user_pages(curr_task, mm, ul_mpu_addr, 1,
-						write, 1, &mapped_page, NULL);
-			if (pg_num > 0) {
-				if (page_count(mapped_page) < 1) {
-					pr_err("Bad page count after doing"
-					       "get_user_pages on"
-					       "user buffer\n");
-					bad_page_dump(page_to_phys(mapped_page),
-						      mapped_page);
-				}
-				status = pte_set(dev_context->pt_attrs,
-						 page_to_phys(mapped_page), va,
-						 HW_PAGE_SIZE4KB, &hw_attrs);
-				if (status)
-					break;
-
-				if (mapped_pages)
-					mapped_pages[pg_i] = mapped_page;
-
-				va += HW_PAGE_SIZE4KB;
-				ul_mpu_addr += HW_PAGE_SIZE4KB;
-			} else {
-				pr_err("DSPBRIDGE: get_user_pages FAILED,"
-				       "MPU addr = 0x%x,"
-				       "vma->vm_flags = 0x%lx,"
-				       "get_user_pages Err"
-				       "Value = %d, Buffer"
-				       "size=0x%x\n", ul_mpu_addr,
-				       vma->vm_flags, pg_num, ul_num_bytes);
-				status = -EPERM;
-				break;
-			}
-		}
-	}
-	up_read(&mm->mmap_sem);
-func_cont:
-	if (status) {
-		/*
-		 * Roll out the mapped pages incase it failed in middle of
-		 * mapping
-		 */
-		if (pg_i) {
-			bridge_brd_mem_un_map(dev_context, virt_addr,
-					   (pg_i * PG_SIZE4K));
-		}
-		status = -EPERM;
-	}
-	/*
-	 * In any case, flush the TLB
-	 * This is called from here instead from pte_update to avoid unnecessary
-	 * repetition while mapping non-contiguous physical regions of a virtual
-	 * region
-	 */
-	flush_all(dev_context);
-	dev_dbg(bridge, "%s status %x\n", __func__, status);
-	return status;
-}
-
-/*
- *  ======== bridge_brd_mem_un_map ========
- *      Invalidate the PTEs for the DSP VA block to be unmapped.
- *
- *      PTEs of a mapped memory block are contiguous in any page table
- *      So, instead of looking up the PTE address for every 4K block,
- *      we clear consecutive PTEs until we unmap all the bytes
- */
-static int bridge_brd_mem_un_map(struct bridge_dev_context *dev_ctxt,
-				     u32 virt_addr, u32 ul_num_bytes)
-{
-	u32 l1_base_va;
-	u32 l2_base_va;
-	u32 l2_base_pa;
-	u32 l2_page_num;
-	u32 pte_val;
-	u32 pte_size;
-	u32 pte_count;
-	u32 pte_addr_l1;
-	u32 pte_addr_l2 = 0;
-	u32 rem_bytes;
-	u32 rem_bytes_l2;
-	u32 va_curr;
-	struct page *pg = NULL;
-	int status = 0;
-	struct bridge_dev_context *dev_context = dev_ctxt;
-	struct pg_table_attrs *pt = dev_context->pt_attrs;
-	u32 temp;
-	u32 paddr;
-	u32 numof4k_pages = 0;
-
-	va_curr = virt_addr;
-	rem_bytes = ul_num_bytes;
-	rem_bytes_l2 = 0;
-	l1_base_va = pt->l1_base_va;
-	pte_addr_l1 = hw_mmu_pte_addr_l1(l1_base_va, va_curr);
-	dev_dbg(bridge, "%s dev_ctxt %p, va %x, NumBytes %x l1_base_va %x, "
-		"pte_addr_l1 %x\n", __func__, dev_ctxt, virt_addr,
-		ul_num_bytes, l1_base_va, pte_addr_l1);
-
-	while (rem_bytes && !status) {
-		u32 va_curr_orig = va_curr;
-		/* Find whether the L1 PTE points to a valid L2 PT */
-		pte_addr_l1 = hw_mmu_pte_addr_l1(l1_base_va, va_curr);
-		pte_val = *(u32 *) pte_addr_l1;
-		pte_size = hw_mmu_pte_size_l1(pte_val);
-
-		if (pte_size != HW_MMU_COARSE_PAGE_SIZE)
-			goto skip_coarse_page;
-
-		/*
-		 * Get the L2 PA from the L1 PTE, and find
-		 * corresponding L2 VA
-		 */
-		l2_base_pa = hw_mmu_pte_coarse_l1(pte_val);
-		l2_base_va = l2_base_pa - pt->l2_base_pa + pt->l2_base_va;
-		l2_page_num =
-		    (l2_base_pa - pt->l2_base_pa) / HW_MMU_COARSE_PAGE_SIZE;
-		/*
-		 * Find the L2 PTE address from which we will start
-		 * clearing, the number of PTEs to be cleared on this
-		 * page, and the size of VA space that needs to be
-		 * cleared on this L2 page
-		 */
-		pte_addr_l2 = hw_mmu_pte_addr_l2(l2_base_va, va_curr);
-		pte_count = pte_addr_l2 & (HW_MMU_COARSE_PAGE_SIZE - 1);
-		pte_count = (HW_MMU_COARSE_PAGE_SIZE - pte_count) / sizeof(u32);
-		if (rem_bytes < (pte_count * PG_SIZE4K))
-			pte_count = rem_bytes / PG_SIZE4K;
-		rem_bytes_l2 = pte_count * PG_SIZE4K;
-
-		/*
-		 * Unmap the VA space on this L2 PT. A quicker way
-		 * would be to clear pte_count entries starting from
-		 * pte_addr_l2. However, below code checks that we don't
-		 * clear invalid entries or less than 64KB for a 64KB
-		 * entry. Similar checking is done for L1 PTEs too
-		 * below
-		 */
-		while (rem_bytes_l2 && !status) {
-			pte_val = *(u32 *) pte_addr_l2;
-			pte_size = hw_mmu_pte_size_l2(pte_val);
-			/* va_curr aligned to pte_size? */
-			if (pte_size == 0 || rem_bytes_l2 < pte_size ||
-			    va_curr & (pte_size - 1)) {
-				status = -EPERM;
-				break;
-			}
-
-			/* Collect Physical addresses from VA */
-			paddr = (pte_val & ~(pte_size - 1));
-			if (pte_size == HW_PAGE_SIZE64KB)
-				numof4k_pages = 16;
-			else
-				numof4k_pages = 1;
-			temp = 0;
-			while (temp++ < numof4k_pages) {
-				if (!pfn_valid(__phys_to_pfn(paddr))) {
-					paddr += HW_PAGE_SIZE4KB;
-					continue;
-				}
-				pg = PHYS_TO_PAGE(paddr);
-				if (page_count(pg) < 1) {
-					pr_info("DSPBRIDGE: UNMAP function: "
-						"COUNT 0 FOR PA 0x%x, size = "
-						"0x%x\n", paddr, ul_num_bytes);
-					bad_page_dump(paddr, pg);
-				} else {
-					set_page_dirty(pg);
-					page_cache_release(pg);
-				}
-				paddr += HW_PAGE_SIZE4KB;
-			}
-			if (hw_mmu_pte_clear(pte_addr_l2, va_curr, pte_size)) {
-				status = -EPERM;
-				goto EXIT_LOOP;
-			}
-
-			status = 0;
-			rem_bytes_l2 -= pte_size;
-			va_curr += pte_size;
-			pte_addr_l2 += (pte_size >> 12) * sizeof(u32);
-		}
-		spin_lock(&pt->pg_lock);
-		if (rem_bytes_l2 == 0) {
-			pt->pg_info[l2_page_num].num_entries -= pte_count;
-			if (pt->pg_info[l2_page_num].num_entries == 0) {
-				/*
-				 * Clear the L1 PTE pointing to the L2 PT
-				 */
-				if (!hw_mmu_pte_clear(l1_base_va, va_curr_orig,
-						     HW_MMU_COARSE_PAGE_SIZE))
-					status = 0;
-				else {
-					status = -EPERM;
-					spin_unlock(&pt->pg_lock);
-					goto EXIT_LOOP;
-				}
-			}
-			rem_bytes -= pte_count * PG_SIZE4K;
-		} else
-			status = -EPERM;
-
-		spin_unlock(&pt->pg_lock);
-		continue;
-skip_coarse_page:
-		/* va_curr aligned to pte_size? */
-		/* pte_size = 1 MB or 16 MB */
-		if (pte_size == 0 || rem_bytes < pte_size ||
-		    va_curr & (pte_size - 1)) {
-			status = -EPERM;
-			break;
-		}
-
-		if (pte_size == HW_PAGE_SIZE1MB)
-			numof4k_pages = 256;
-		else
-			numof4k_pages = 4096;
-		temp = 0;
-		/* Collect Physical addresses from VA */
-		paddr = (pte_val & ~(pte_size - 1));
-		while (temp++ < numof4k_pages) {
-			if (pfn_valid(__phys_to_pfn(paddr))) {
-				pg = PHYS_TO_PAGE(paddr);
-				if (page_count(pg) < 1) {
-					pr_info("DSPBRIDGE: UNMAP function: "
-						"COUNT 0 FOR PA 0x%x, size = "
-						"0x%x\n", paddr, ul_num_bytes);
-					bad_page_dump(paddr, pg);
-				} else {
-					set_page_dirty(pg);
-					page_cache_release(pg);
-				}
-			}
-			paddr += HW_PAGE_SIZE4KB;
-		}
-		if (!hw_mmu_pte_clear(l1_base_va, va_curr, pte_size)) {
-			status = 0;
-			rem_bytes -= pte_size;
-			va_curr += pte_size;
-		} else {
-			status = -EPERM;
-			goto EXIT_LOOP;
-		}
-	}
-	/*
-	 * It is better to flush the TLB here, so that any stale old entries
-	 * get flushed
-	 */
-EXIT_LOOP:
-	flush_all(dev_context);
-	dev_dbg(bridge,
-		"%s: va_curr %x, pte_addr_l1 %x pte_addr_l2 %x rem_bytes %x,"
-		" rem_bytes_l2 %x status %x\n", __func__, va_curr, pte_addr_l1,
-		pte_addr_l2, rem_bytes, rem_bytes_l2, status);
-	return status;
-}
-
-/*
- *  ======== user_va2_pa ========
- *  Purpose:
- *      This function walks through the page tables to convert a userland
- *      virtual address to physical address
- */
-static u32 user_va2_pa(struct mm_struct *mm, u32 address)
-{
-	pgd_t *pgd;
-	pud_t *pud;
-	pmd_t *pmd;
-	pte_t *ptep, pte;
-
-	pgd = pgd_offset(mm, address);
-	if (pgd_none(*pgd) || pgd_bad(*pgd))
-		return 0;
-
-	pud = pud_offset(pgd, address);
-	if (pud_none(*pud) || pud_bad(*pud))
-		return 0;
-
-	pmd = pmd_offset(pud, address);
-	if (pmd_none(*pmd) || pmd_bad(*pmd))
-		return 0;
-
-	ptep = pte_offset_map(pmd, address);
-	if (ptep) {
-		pte = *ptep;
-		if (pte_present(pte))
-			return pte & PAGE_MASK;
-	}
-
-	return 0;
-}
-
-/*
- *  ======== pte_update ========
- *      This function calculates the optimum page-aligned addresses and sizes
- *      Caller must pass page-aligned values
- */
-static int pte_update(struct bridge_dev_context *dev_ctxt, u32 pa,
-			     u32 va, u32 size,
-			     struct hw_mmu_map_attrs_t *map_attrs)
-{
-	u32 i;
-	u32 all_bits;
-	u32 pa_curr = pa;
-	u32 va_curr = va;
-	u32 num_bytes = size;
-	struct bridge_dev_context *dev_context = dev_ctxt;
-	int status = 0;
-	u32 page_size[] = { HW_PAGE_SIZE16MB, HW_PAGE_SIZE1MB,
-		HW_PAGE_SIZE64KB, HW_PAGE_SIZE4KB
-	};
-
-	while (num_bytes && !status) {
-		/* To find the max. page size with which both PA & VA are
-		 * aligned */
-		all_bits = pa_curr | va_curr;
-
-		for (i = 0; i < 4; i++) {
-			if ((num_bytes >= page_size[i]) && ((all_bits &
-							     (page_size[i] -
-							      1)) == 0)) {
-				status =
-				    pte_set(dev_context->pt_attrs, pa_curr,
-					    va_curr, page_size[i], map_attrs);
-				pa_curr += page_size[i];
-				va_curr += page_size[i];
-				num_bytes -= page_size[i];
-				/* Don't try smaller sizes. Hopefully we have
-				 * reached an address aligned to a bigger page
-				 * size */
-				break;
-			}
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== pte_set ========
- *      This function calculates PTE address (MPU virtual) to be updated
- *      It also manages the L2 page tables
- */
-static int pte_set(struct pg_table_attrs *pt, u32 pa, u32 va,
-			  u32 size, struct hw_mmu_map_attrs_t *attrs)
-{
-	u32 i;
-	u32 pte_val;
-	u32 pte_addr_l1;
-	u32 pte_size;
-	/* Base address of the PT that will be updated */
-	u32 pg_tbl_va;
-	u32 l1_base_va;
-	/* Compiler warns that the next three variables might be used
-	 * uninitialized in this function. Doesn't seem so. Working around,
-	 * anyways. */
-	u32 l2_base_va = 0;
-	u32 l2_base_pa = 0;
-	u32 l2_page_num = 0;
-	int status = 0;
-
-	l1_base_va = pt->l1_base_va;
-	pg_tbl_va = l1_base_va;
-	if ((size == HW_PAGE_SIZE64KB) || (size == HW_PAGE_SIZE4KB)) {
-		/* Find whether the L1 PTE points to a valid L2 PT */
-		pte_addr_l1 = hw_mmu_pte_addr_l1(l1_base_va, va);
-		if (pte_addr_l1 <= (pt->l1_base_va + pt->l1_size)) {
-			pte_val = *(u32 *) pte_addr_l1;
-			pte_size = hw_mmu_pte_size_l1(pte_val);
-		} else {
-			return -EPERM;
-		}
-		spin_lock(&pt->pg_lock);
-		if (pte_size == HW_MMU_COARSE_PAGE_SIZE) {
-			/* Get the L2 PA from the L1 PTE, and find
-			 * corresponding L2 VA */
-			l2_base_pa = hw_mmu_pte_coarse_l1(pte_val);
-			l2_base_va =
-			    l2_base_pa - pt->l2_base_pa + pt->l2_base_va;
-			l2_page_num =
-			    (l2_base_pa -
-			     pt->l2_base_pa) / HW_MMU_COARSE_PAGE_SIZE;
-		} else if (pte_size == 0) {
-			/* L1 PTE is invalid. Allocate a L2 PT and
-			 * point the L1 PTE to it */
-			/* Find a free L2 PT. */
-			for (i = 0; (i < pt->l2_num_pages) &&
-			     (pt->pg_info[i].num_entries != 0); i++)
-				;
-			if (i < pt->l2_num_pages) {
-				l2_page_num = i;
-				l2_base_pa = pt->l2_base_pa + (l2_page_num *
-						HW_MMU_COARSE_PAGE_SIZE);
-				l2_base_va = pt->l2_base_va + (l2_page_num *
-						HW_MMU_COARSE_PAGE_SIZE);
-				/* Endianness attributes are ignored for
-				 * HW_MMU_COARSE_PAGE_SIZE */
-				status =
-				    hw_mmu_pte_set(l1_base_va, l2_base_pa, va,
-						   HW_MMU_COARSE_PAGE_SIZE,
-						   attrs);
-			} else {
-				status = -ENOMEM;
-			}
-		} else {
-			/* Found valid L1 PTE of another size.
-			 * Should not overwrite it. */
-			status = -EPERM;
-		}
-		if (!status) {
-			pg_tbl_va = l2_base_va;
-			if (size == HW_PAGE_SIZE64KB)
-				pt->pg_info[l2_page_num].num_entries += 16;
-			else
-				pt->pg_info[l2_page_num].num_entries++;
-			dev_dbg(bridge, "PTE: L2 BaseVa %x, BasePa %x, PageNum "
-				"%x, num_entries %x\n", l2_base_va,
-				l2_base_pa, l2_page_num,
-				pt->pg_info[l2_page_num].num_entries);
-		}
-		spin_unlock(&pt->pg_lock);
-	}
-	if (!status) {
-		dev_dbg(bridge, "PTE: pg_tbl_va %x, pa %x, va %x, size %x\n",
-			pg_tbl_va, pa, va, size);
-		dev_dbg(bridge, "PTE: endianism %x, element_size %x, "
-			"mixed_size %x\n", attrs->endianism,
-			attrs->element_size, attrs->mixed_size);
-		status = hw_mmu_pte_set(pg_tbl_va, pa, va, size, attrs);
-	}
-
-	return status;
-}
-
-/* Memory map kernel VA -- memory allocated with vmalloc */
-static int mem_map_vmalloc(struct bridge_dev_context *dev_context,
-				  u32 ul_mpu_addr, u32 virt_addr,
-				  u32 ul_num_bytes,
-				  struct hw_mmu_map_attrs_t *hw_attrs)
-{
-	int status = 0;
-	struct page *page[1];
-	u32 i;
-	u32 pa_curr;
-	u32 pa_next;
-	u32 va_curr;
-	u32 size_curr;
-	u32 num_pages;
-	u32 pa;
-	u32 num_of4k_pages;
-	u32 temp = 0;
-
-	/*
-	 * Do Kernel va to pa translation.
-	 * Combine physically contiguous regions to reduce TLBs.
-	 * Pass the translated pa to pte_update.
-	 */
-	num_pages = ul_num_bytes / PAGE_SIZE;	/* PAGE_SIZE = OS page size */
-	i = 0;
-	va_curr = ul_mpu_addr;
-	page[0] = vmalloc_to_page((void *)va_curr);
-	pa_next = page_to_phys(page[0]);
-	while (!status && (i < num_pages)) {
-		/*
-		 * Reuse pa_next from the previous iteration to avoid
-		 * an extra va2pa call
-		 */
-		pa_curr = pa_next;
-		size_curr = PAGE_SIZE;
-		/*
-		 * If the next page is physically contiguous,
-		 * map it with the current one by increasing
-		 * the size of the region to be mapped
-		 */
-		while (++i < num_pages) {
-			page[0] =
-			    vmalloc_to_page((void *)(va_curr + size_curr));
-			pa_next = page_to_phys(page[0]);
-
-			if (pa_next == (pa_curr + size_curr))
-				size_curr += PAGE_SIZE;
-			else
-				break;
-
-		}
-		if (pa_next == 0) {
-			status = -ENOMEM;
-			break;
-		}
-		pa = pa_curr;
-		num_of4k_pages = size_curr / HW_PAGE_SIZE4KB;
-		while (temp++ < num_of4k_pages) {
-			get_page(PHYS_TO_PAGE(pa));
-			pa += HW_PAGE_SIZE4KB;
-		}
-		status = pte_update(dev_context, pa_curr, virt_addr +
-				    (va_curr - ul_mpu_addr), size_curr,
-				    hw_attrs);
-		va_curr += size_curr;
-	}
-	/*
-	 * In any case, flush the TLB
-	 * This is called from here instead from pte_update to avoid unnecessary
-	 * repetition while mapping non-contiguous physical regions of a virtual
-	 * region
-	 */
-	flush_all(dev_context);
-	dev_dbg(bridge, "%s status %x\n", __func__, status);
-	return status;
-}
-
-/*
- *  ======== wait_for_start ========
- *      Wait for the singal from DSP that it has started, or time out.
- */
-bool wait_for_start(struct bridge_dev_context *dev_context,
-			void __iomem *sync_addr)
-{
-	u16 timeout = TIHELEN_ACKTIMEOUT;
-
-	/*  Wait for response from board */
-	while (__raw_readw(sync_addr) && --timeout)
-		udelay(10);
-
-	/*  If timed out: return false */
-	if (!timeout) {
-		pr_err("%s: Timed out waiting DSP to Start\n", __func__);
-		return false;
-	}
-	return true;
-}
diff --git a/drivers/staging/tidspbridge/core/tiomap3430_pwr.c b/drivers/staging/tidspbridge/core/tiomap3430_pwr.c
deleted file mode 100644
index 657104f..0000000
--- a/drivers/staging/tidspbridge/core/tiomap3430_pwr.c
+++ /dev/null
@@ -1,556 +0,0 @@
-/*
- * tiomap_pwr.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Implementation of DSP wake/sleep routines.
- *
- * Copyright (C) 2007-2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-#include <linux/platform_data/dsp-omap.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/drv.h>
-#include <dspbridge/io_sm.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/brddefs.h>
-#include <dspbridge/dev.h>
-#include <dspbridge/io.h>
-
-/* ------------------------------------ Hardware Abstraction Layer */
-#include <hw_defs.h>
-#include <hw_mmu.h>
-
-#include <dspbridge/pwr.h>
-
-/*  ----------------------------------- Bridge Driver */
-#include <dspbridge/dspdeh.h>
-#include <dspbridge/wdt.h>
-
-/*  ----------------------------------- specific to this file */
-#include "_tiomap.h"
-#include "_tiomap_pwr.h"
-#include <mach-omap2/prm-regbits-34xx.h>
-#include <mach-omap2/cm-regbits-34xx.h>
-
-#define PWRSTST_TIMEOUT          200
-
-/*
- *  ======== handle_constraints_set ========
- *	Sets new DSP constraint
- */
-int handle_constraints_set(struct bridge_dev_context *dev_context,
-				  void *pargs)
-{
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-	u32 *constraint_val;
-	struct omap_dsp_platform_data *pdata =
-		omap_dspbridge_dev->dev.platform_data;
-
-	constraint_val = (u32 *) (pargs);
-	/* Read the target value requested by DSP */
-	dev_dbg(bridge, "OPP: %s opp requested = 0x%x\n", __func__,
-		(u32) *(constraint_val + 1));
-
-	/* Set the new opp value */
-	if (pdata->dsp_set_min_opp)
-		(*pdata->dsp_set_min_opp) ((u32) *(constraint_val + 1));
-#endif /* #ifdef CONFIG_TIDSPBRIDGE_DVFS */
-	return 0;
-}
-
-/*
- *  ======== handle_hibernation_from_dsp ========
- *	Handle Hibernation requested from DSP
- */
-int handle_hibernation_from_dsp(struct bridge_dev_context *dev_context)
-{
-	int status = 0;
-#ifdef CONFIG_PM
-	u16 timeout = PWRSTST_TIMEOUT / 10;
-	u32 pwr_state;
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-	u32 opplevel;
-	struct io_mgr *hio_mgr;
-#endif
-	struct omap_dsp_platform_data *pdata =
-		omap_dspbridge_dev->dev.platform_data;
-
-	pwr_state = (*pdata->dsp_prm_read)(OMAP3430_IVA2_MOD, OMAP2_PM_PWSTST) &
-						OMAP_POWERSTATEST_MASK;
-	/* Wait for DSP to move into OFF state */
-	while ((pwr_state != PWRDM_POWER_OFF) && --timeout) {
-		if (msleep_interruptible(10)) {
-			pr_err("Waiting for DSP OFF mode interrupted\n");
-			return -EPERM;
-		}
-		pwr_state = (*pdata->dsp_prm_read)(OMAP3430_IVA2_MOD,
-						   OMAP2_PM_PWSTST) &
-						   OMAP_POWERSTATEST_MASK;
-	}
-	if (timeout == 0) {
-		pr_err("%s: Timed out waiting for DSP off mode\n", __func__);
-		status = -ETIMEDOUT;
-		return status;
-	} else {
-
-		/* Save mailbox settings */
-		omap_mbox_save_ctx(dev_context->mbox);
-
-		/* Turn off DSP Peripheral clocks and DSP Load monitor timer */
-		status = dsp_clock_disable_all(dev_context->dsp_per_clks);
-
-		/* Disable wdt on hibernation. */
-		dsp_wdt_enable(false);
-
-		if (!status) {
-			/* Update the Bridger Driver state */
-			dev_context->brd_state = BRD_DSP_HIBERNATION;
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-			status =
-			    dev_get_io_mgr(dev_context->dev_obj, &hio_mgr);
-			if (!hio_mgr) {
-				status = DSP_EHANDLE;
-				return status;
-			}
-			io_sh_msetting(hio_mgr, SHM_GETOPP, &opplevel);
-
-			/*
-			 * Set the OPP to low level before moving to OFF
-			 * mode
-			 */
-			if (pdata->dsp_set_min_opp)
-				(*pdata->dsp_set_min_opp) (VDD1_OPP1);
-			status = 0;
-#endif /* CONFIG_TIDSPBRIDGE_DVFS */
-		}
-	}
-#endif
-	return status;
-}
-
-/*
- *  ======== sleep_dsp ========
- *	Put DSP in low power consuming state.
- */
-int sleep_dsp(struct bridge_dev_context *dev_context, u32 dw_cmd,
-		     void *pargs)
-{
-	int status = 0;
-#ifdef CONFIG_PM
-#ifdef CONFIG_TIDSPBRIDGE_NTFY_PWRERR
-	struct deh_mgr *hdeh_mgr;
-#endif /* CONFIG_TIDSPBRIDGE_NTFY_PWRERR */
-	u16 timeout = PWRSTST_TIMEOUT / 10;
-	u32 pwr_state, target_pwr_state;
-	struct omap_dsp_platform_data *pdata =
-		omap_dspbridge_dev->dev.platform_data;
-
-	/* Check if sleep code is valid */
-	if ((dw_cmd != PWR_DEEPSLEEP) && (dw_cmd != PWR_EMERGENCYDEEPSLEEP))
-		return -EINVAL;
-
-	switch (dev_context->brd_state) {
-	case BRD_RUNNING:
-		omap_mbox_save_ctx(dev_context->mbox);
-		if (dsp_test_sleepstate == PWRDM_POWER_OFF) {
-			sm_interrupt_dsp(dev_context, MBX_PM_DSPHIBERNATE);
-			dev_dbg(bridge, "PM: %s - sent hibernate cmd to DSP\n",
-				__func__);
-			target_pwr_state = PWRDM_POWER_OFF;
-		} else {
-			sm_interrupt_dsp(dev_context, MBX_PM_DSPRETENTION);
-			target_pwr_state = PWRDM_POWER_RET;
-		}
-		break;
-	case BRD_RETENTION:
-		omap_mbox_save_ctx(dev_context->mbox);
-		if (dsp_test_sleepstate == PWRDM_POWER_OFF) {
-			sm_interrupt_dsp(dev_context, MBX_PM_DSPHIBERNATE);
-			target_pwr_state = PWRDM_POWER_OFF;
-		} else
-			return 0;
-		break;
-	case BRD_HIBERNATION:
-	case BRD_DSP_HIBERNATION:
-		/* Already in Hibernation, so just return */
-		dev_dbg(bridge, "PM: %s - DSP already in hibernation\n",
-			__func__);
-		return 0;
-	case BRD_STOPPED:
-		dev_dbg(bridge, "PM: %s - Board in STOP state\n", __func__);
-		return 0;
-	default:
-		dev_dbg(bridge, "PM: %s - Bridge in Illegal state\n", __func__);
-		return -EPERM;
-	}
-
-	/* Get the PRCM DSP power domain status */
-	pwr_state = (*pdata->dsp_prm_read)(OMAP3430_IVA2_MOD, OMAP2_PM_PWSTST) &
-						OMAP_POWERSTATEST_MASK;
-
-	/* Wait for DSP to move into target power state */
-	while ((pwr_state != target_pwr_state) && --timeout) {
-		if (msleep_interruptible(10)) {
-			pr_err("Waiting for DSP to Suspend interrupted\n");
-			return -EPERM;
-		}
-		pwr_state = (*pdata->dsp_prm_read)(OMAP3430_IVA2_MOD,
-						   OMAP2_PM_PWSTST) &
-						   OMAP_POWERSTATEST_MASK;
-	}
-
-	if (!timeout) {
-		pr_err("%s: Timed out waiting for DSP off mode, state %x\n",
-		       __func__, pwr_state);
-#ifdef CONFIG_TIDSPBRIDGE_NTFY_PWRERR
-		dev_get_deh_mgr(dev_context->dev_obj, &hdeh_mgr);
-		bridge_deh_notify(hdeh_mgr, DSP_PWRERROR, 0);
-#endif /* CONFIG_TIDSPBRIDGE_NTFY_PWRERR */
-		return -ETIMEDOUT;
-	} else {
-		/* Update the Bridger Driver state */
-		if (dsp_test_sleepstate == PWRDM_POWER_OFF)
-			dev_context->brd_state = BRD_HIBERNATION;
-		else
-			dev_context->brd_state = BRD_RETENTION;
-
-		/* Disable wdt on hibernation. */
-		dsp_wdt_enable(false);
-
-		/* Turn off DSP Peripheral clocks */
-		status = dsp_clock_disable_all(dev_context->dsp_per_clks);
-		if (status)
-			return status;
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-		else if (target_pwr_state == PWRDM_POWER_OFF) {
-			/*
-			 * Set the OPP to low level before moving to OFF mode
-			 */
-			if (pdata->dsp_set_min_opp)
-				(*pdata->dsp_set_min_opp) (VDD1_OPP1);
-		}
-#endif /* CONFIG_TIDSPBRIDGE_DVFS */
-	}
-#endif /* CONFIG_PM */
-	return status;
-}
-
-/*
- *  ======== wake_dsp ========
- *	Wake up DSP from sleep.
- */
-int wake_dsp(struct bridge_dev_context *dev_context, void *pargs)
-{
-	int status = 0;
-#ifdef CONFIG_PM
-
-	/* Check the board state, if it is not 'SLEEP' then return */
-	if (dev_context->brd_state == BRD_RUNNING ||
-	    dev_context->brd_state == BRD_STOPPED) {
-		/* The Device is in 'RET' or 'OFF' state and Bridge state is not
-		 * 'SLEEP', this means state inconsistency, so return */
-		return 0;
-	}
-
-	/* Send a wakeup message to DSP */
-	sm_interrupt_dsp(dev_context, MBX_PM_DSPWAKEUP);
-
-	/* Set the device state to RUNNIG */
-	dev_context->brd_state = BRD_RUNNING;
-#endif /* CONFIG_PM */
-	return status;
-}
-
-/*
- *  ======== dsp_peripheral_clk_ctrl ========
- *	Enable/Disable the DSP peripheral clocks as needed..
- */
-int dsp_peripheral_clk_ctrl(struct bridge_dev_context *dev_context,
-				   void *pargs)
-{
-	u32 ext_clk = 0;
-	u32 ext_clk_id = 0;
-	u32 ext_clk_cmd = 0;
-	u32 clk_id_index = MBX_PM_MAX_RESOURCES;
-	u32 tmp_index;
-	u32 dsp_per_clks_before;
-	int status = 0;
-
-	dsp_per_clks_before = dev_context->dsp_per_clks;
-
-	ext_clk = (u32) *((u32 *) pargs);
-	ext_clk_id = ext_clk & MBX_PM_CLK_IDMASK;
-
-	/* process the power message -- TODO, keep it in a separate function */
-	for (tmp_index = 0; tmp_index < MBX_PM_MAX_RESOURCES; tmp_index++) {
-		if (ext_clk_id == bpwr_clkid[tmp_index]) {
-			clk_id_index = tmp_index;
-			break;
-		}
-	}
-	/* TODO -- Assert may be a too hard restriction here.. May be we should
-	 * just return with failure when the CLK ID does not match */
-	if (clk_id_index == MBX_PM_MAX_RESOURCES) {
-		/* return with a more meaningfull error code */
-		return -EPERM;
-	}
-	ext_clk_cmd = (ext_clk >> MBX_PM_CLK_CMDSHIFT) & MBX_PM_CLK_CMDMASK;
-	switch (ext_clk_cmd) {
-	case BPWR_DISABLE_CLOCK:
-		status = dsp_clk_disable(bpwr_clks[clk_id_index].clk);
-		dsp_clk_wakeup_event_ctrl(bpwr_clks[clk_id_index].clk_id,
-					  false);
-		if (!status) {
-			(dev_context->dsp_per_clks) &=
-				(~((u32) (1 << bpwr_clks[clk_id_index].clk)));
-		}
-		break;
-	case BPWR_ENABLE_CLOCK:
-		status = dsp_clk_enable(bpwr_clks[clk_id_index].clk);
-		dsp_clk_wakeup_event_ctrl(bpwr_clks[clk_id_index].clk_id, true);
-		if (!status)
-			(dev_context->dsp_per_clks) |=
-				(1 << bpwr_clks[clk_id_index].clk);
-		break;
-	default:
-		dev_dbg(bridge, "%s: Unsupported CMD\n", __func__);
-		/* unsupported cmd */
-		/* TODO -- provide support for AUTOIDLE Enable/Disable
-		 * commands */
-	}
-	return status;
-}
-
-/*
- *  ========pre_scale_dsp========
- *  Sends prescale notification to DSP
- *
- */
-int pre_scale_dsp(struct bridge_dev_context *dev_context, void *pargs)
-{
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-	u32 level;
-	u32 voltage_domain;
-
-	voltage_domain = *((u32 *) pargs);
-	level = *((u32 *) pargs + 1);
-
-	dev_dbg(bridge, "OPP: %s voltage_domain = %x, level = 0x%x\n",
-		__func__, voltage_domain, level);
-	if ((dev_context->brd_state == BRD_HIBERNATION) ||
-	    (dev_context->brd_state == BRD_RETENTION) ||
-	    (dev_context->brd_state == BRD_DSP_HIBERNATION)) {
-		dev_dbg(bridge, "OPP: %s IVA in sleep. No message to DSP\n");
-		return 0;
-	} else if (dev_context->brd_state == BRD_RUNNING) {
-		/* Send a prenotification to DSP */
-		dev_dbg(bridge, "OPP: %s sent notification to DSP\n", __func__);
-		sm_interrupt_dsp(dev_context, MBX_PM_SETPOINT_PRENOTIFY);
-		return 0;
-	} else {
-		return -EPERM;
-	}
-#endif /* #ifdef CONFIG_TIDSPBRIDGE_DVFS */
-	return 0;
-}
-
-/*
- *  ========post_scale_dsp========
- *  Sends postscale notification to DSP
- *
- */
-int post_scale_dsp(struct bridge_dev_context *dev_context,
-							void *pargs)
-{
-	int status = 0;
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-	u32 level;
-	u32 voltage_domain;
-	struct io_mgr *hio_mgr;
-
-	status = dev_get_io_mgr(dev_context->dev_obj, &hio_mgr);
-	if (!hio_mgr)
-		return -EFAULT;
-
-	voltage_domain = *((u32 *) pargs);
-	level = *((u32 *) pargs + 1);
-	dev_dbg(bridge, "OPP: %s voltage_domain = %x, level = 0x%x\n",
-		__func__, voltage_domain, level);
-	if ((dev_context->brd_state == BRD_HIBERNATION) ||
-	    (dev_context->brd_state == BRD_RETENTION) ||
-	    (dev_context->brd_state == BRD_DSP_HIBERNATION)) {
-		/* Update the OPP value in shared memory */
-		io_sh_msetting(hio_mgr, SHM_CURROPP, &level);
-		dev_dbg(bridge, "OPP: %s IVA in sleep. Wrote to shm\n",
-			__func__);
-	} else if (dev_context->brd_state == BRD_RUNNING) {
-		/* Update the OPP value in shared memory */
-		io_sh_msetting(hio_mgr, SHM_CURROPP, &level);
-		/* Send a post notification to DSP */
-		sm_interrupt_dsp(dev_context, MBX_PM_SETPOINT_POSTNOTIFY);
-		dev_dbg(bridge,
-			"OPP: %s wrote to shm. Sent post notification to DSP\n",
-			 __func__);
-	} else {
-		status = -EPERM;
-	}
-#endif /* #ifdef CONFIG_TIDSPBRIDGE_DVFS */
-	return status;
-}
-
-void dsp_clk_wakeup_event_ctrl(u32 clock_id, bool enable)
-{
-	struct cfg_hostres *resources;
-	int status = 0;
-	u32 iva2_grpsel;
-	u32 mpu_grpsel;
-	struct dev_object *hdev_object = NULL;
-	struct bridge_dev_context *bridge_context = NULL;
-
-	hdev_object = (struct dev_object *)drv_get_first_dev_object();
-	if (!hdev_object)
-		return;
-
-	status = dev_get_bridge_context(hdev_object, &bridge_context);
-	if (!bridge_context)
-		return;
-
-	resources = bridge_context->resources;
-	if (!resources)
-		return;
-
-	switch (clock_id) {
-	case BPWR_GP_TIMER5:
-		iva2_grpsel = readl(resources->per_pm_base + 0xA8);
-		mpu_grpsel = readl(resources->per_pm_base + 0xA4);
-		if (enable) {
-			iva2_grpsel |= OMAP3430_GRPSEL_GPT5_MASK;
-			mpu_grpsel &= ~OMAP3430_GRPSEL_GPT5_MASK;
-		} else {
-			mpu_grpsel |= OMAP3430_GRPSEL_GPT5_MASK;
-			iva2_grpsel &= ~OMAP3430_GRPSEL_GPT5_MASK;
-		}
-		writel(iva2_grpsel, resources->per_pm_base + 0xA8);
-		writel(mpu_grpsel, resources->per_pm_base + 0xA4);
-		break;
-	case BPWR_GP_TIMER6:
-		iva2_grpsel = readl(resources->per_pm_base + 0xA8);
-		mpu_grpsel = readl(resources->per_pm_base + 0xA4);
-		if (enable) {
-			iva2_grpsel |= OMAP3430_GRPSEL_GPT6_MASK;
-			mpu_grpsel &= ~OMAP3430_GRPSEL_GPT6_MASK;
-		} else {
-			mpu_grpsel |= OMAP3430_GRPSEL_GPT6_MASK;
-			iva2_grpsel &= ~OMAP3430_GRPSEL_GPT6_MASK;
-		}
-		writel(iva2_grpsel, resources->per_pm_base + 0xA8);
-		writel(mpu_grpsel, resources->per_pm_base + 0xA4);
-		break;
-	case BPWR_GP_TIMER7:
-		iva2_grpsel = readl(resources->per_pm_base + 0xA8);
-		mpu_grpsel = readl(resources->per_pm_base + 0xA4);
-		if (enable) {
-			iva2_grpsel |= OMAP3430_GRPSEL_GPT7_MASK;
-			mpu_grpsel &= ~OMAP3430_GRPSEL_GPT7_MASK;
-		} else {
-			mpu_grpsel |= OMAP3430_GRPSEL_GPT7_MASK;
-			iva2_grpsel &= ~OMAP3430_GRPSEL_GPT7_MASK;
-		}
-		writel(iva2_grpsel, resources->per_pm_base + 0xA8);
-		writel(mpu_grpsel, resources->per_pm_base + 0xA4);
-		break;
-	case BPWR_GP_TIMER8:
-		iva2_grpsel = readl(resources->per_pm_base + 0xA8);
-		mpu_grpsel = readl(resources->per_pm_base + 0xA4);
-		if (enable) {
-			iva2_grpsel |= OMAP3430_GRPSEL_GPT8_MASK;
-			mpu_grpsel &= ~OMAP3430_GRPSEL_GPT8_MASK;
-		} else {
-			mpu_grpsel |= OMAP3430_GRPSEL_GPT8_MASK;
-			iva2_grpsel &= ~OMAP3430_GRPSEL_GPT8_MASK;
-		}
-		writel(iva2_grpsel, resources->per_pm_base + 0xA8);
-		writel(mpu_grpsel, resources->per_pm_base + 0xA4);
-		break;
-	case BPWR_MCBSP1:
-		iva2_grpsel = readl(resources->core_pm_base + 0xA8);
-		mpu_grpsel = readl(resources->core_pm_base + 0xA4);
-		if (enable) {
-			iva2_grpsel |= OMAP3430_GRPSEL_MCBSP1_MASK;
-			mpu_grpsel &= ~OMAP3430_GRPSEL_MCBSP1_MASK;
-		} else {
-			mpu_grpsel |= OMAP3430_GRPSEL_MCBSP1_MASK;
-			iva2_grpsel &= ~OMAP3430_GRPSEL_MCBSP1_MASK;
-		}
-		writel(iva2_grpsel, resources->core_pm_base + 0xA8);
-		writel(mpu_grpsel, resources->core_pm_base + 0xA4);
-		break;
-	case BPWR_MCBSP2:
-		iva2_grpsel = readl(resources->per_pm_base + 0xA8);
-		mpu_grpsel = readl(resources->per_pm_base + 0xA4);
-		if (enable) {
-			iva2_grpsel |= OMAP3430_GRPSEL_MCBSP2_MASK;
-			mpu_grpsel &= ~OMAP3430_GRPSEL_MCBSP2_MASK;
-		} else {
-			mpu_grpsel |= OMAP3430_GRPSEL_MCBSP2_MASK;
-			iva2_grpsel &= ~OMAP3430_GRPSEL_MCBSP2_MASK;
-		}
-		writel(iva2_grpsel, resources->per_pm_base + 0xA8);
-		writel(mpu_grpsel, resources->per_pm_base + 0xA4);
-		break;
-	case BPWR_MCBSP3:
-		iva2_grpsel = readl(resources->per_pm_base + 0xA8);
-		mpu_grpsel = readl(resources->per_pm_base + 0xA4);
-		if (enable) {
-			iva2_grpsel |= OMAP3430_GRPSEL_MCBSP3_MASK;
-			mpu_grpsel &= ~OMAP3430_GRPSEL_MCBSP3_MASK;
-		} else {
-			mpu_grpsel |= OMAP3430_GRPSEL_MCBSP3_MASK;
-			iva2_grpsel &= ~OMAP3430_GRPSEL_MCBSP3_MASK;
-		}
-		writel(iva2_grpsel, resources->per_pm_base + 0xA8);
-		writel(mpu_grpsel, resources->per_pm_base + 0xA4);
-		break;
-	case BPWR_MCBSP4:
-		iva2_grpsel = readl(resources->per_pm_base + 0xA8);
-		mpu_grpsel = readl(resources->per_pm_base + 0xA4);
-		if (enable) {
-			iva2_grpsel |= OMAP3430_GRPSEL_MCBSP4_MASK;
-			mpu_grpsel &= ~OMAP3430_GRPSEL_MCBSP4_MASK;
-		} else {
-			mpu_grpsel |= OMAP3430_GRPSEL_MCBSP4_MASK;
-			iva2_grpsel &= ~OMAP3430_GRPSEL_MCBSP4_MASK;
-		}
-		writel(iva2_grpsel, resources->per_pm_base + 0xA8);
-		writel(mpu_grpsel, resources->per_pm_base + 0xA4);
-		break;
-	case BPWR_MCBSP5:
-		iva2_grpsel = readl(resources->per_pm_base + 0xA8);
-		mpu_grpsel = readl(resources->per_pm_base + 0xA4);
-		if (enable) {
-			iva2_grpsel |= OMAP3430_GRPSEL_MCBSP5_MASK;
-			mpu_grpsel &= ~OMAP3430_GRPSEL_MCBSP5_MASK;
-		} else {
-			mpu_grpsel |= OMAP3430_GRPSEL_MCBSP5_MASK;
-			iva2_grpsel &= ~OMAP3430_GRPSEL_MCBSP5_MASK;
-		}
-		writel(iva2_grpsel, resources->per_pm_base + 0xA8);
-		writel(mpu_grpsel, resources->per_pm_base + 0xA4);
-		break;
-	}
-}
diff --git a/drivers/staging/tidspbridge/core/tiomap_io.c b/drivers/staging/tidspbridge/core/tiomap_io.c
deleted file mode 100644
index 2836467..0000000
--- a/drivers/staging/tidspbridge/core/tiomap_io.c
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * tiomap_io.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Implementation for the io read/write routines.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/platform_data/dsp-omap.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/dev.h>
-#include <dspbridge/drv.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/wdt.h>
-
-/*  ----------------------------------- specific to this file */
-#include "_tiomap.h"
-#include "_tiomap_pwr.h"
-#include "tiomap_io.h"
-
-static u32 ul_ext_base;
-static u32 ul_ext_end;
-
-static u32 shm0_end;
-static u32 ul_dyn_ext_base;
-static u32 ul_trace_sec_beg;
-static u32 ul_trace_sec_end;
-static u32 ul_shm_base_virt;
-
-bool symbols_reloaded = true;
-
-/*
- *  ======== read_ext_dsp_data ========
- *      Copies DSP external memory buffers to the host side buffers.
- */
-int read_ext_dsp_data(struct bridge_dev_context *dev_ctxt,
-			     u8 *host_buff, u32 dsp_addr,
-			     u32 ul_num_bytes, u32 mem_type)
-{
-	int status = 0;
-	struct bridge_dev_context *dev_context = dev_ctxt;
-	u32 offset;
-	u32 ul_tlb_base_virt = 0;
-	u32 ul_shm_offset_virt = 0;
-	u32 dw_ext_prog_virt_mem;
-	u32 dw_base_addr = dev_context->dsp_ext_base_addr;
-	bool trace_read = false;
-
-	if (!ul_shm_base_virt) {
-		status = dev_get_symbol(dev_context->dev_obj,
-					SHMBASENAME, &ul_shm_base_virt);
-	}
-
-	/* Check if it is a read of Trace section */
-	if (!status && !ul_trace_sec_beg) {
-		status = dev_get_symbol(dev_context->dev_obj,
-					DSP_TRACESEC_BEG, &ul_trace_sec_beg);
-	}
-
-	if (!status && !ul_trace_sec_end) {
-		status = dev_get_symbol(dev_context->dev_obj,
-					DSP_TRACESEC_END, &ul_trace_sec_end);
-	}
-
-	if (!status) {
-		if ((dsp_addr <= ul_trace_sec_end) &&
-		    (dsp_addr >= ul_trace_sec_beg))
-			trace_read = true;
-	}
-
-	/* If reading from TRACE, force remap/unmap */
-	if (trace_read && dw_base_addr) {
-		dw_base_addr = 0;
-		dev_context->dsp_ext_base_addr = 0;
-	}
-
-	if (!dw_base_addr) {
-		/* Initialize ul_ext_base and ul_ext_end */
-		ul_ext_base = 0;
-		ul_ext_end = 0;
-
-		/* Get DYNEXT_BEG, EXT_BEG and EXT_END. */
-		if (!status && !ul_dyn_ext_base) {
-			status = dev_get_symbol(dev_context->dev_obj,
-						DYNEXTBASE, &ul_dyn_ext_base);
-		}
-
-		if (!status) {
-			status = dev_get_symbol(dev_context->dev_obj,
-						EXTBASE, &ul_ext_base);
-		}
-
-		if (!status) {
-			status = dev_get_symbol(dev_context->dev_obj,
-						EXTEND, &ul_ext_end);
-		}
-
-		/* Trace buffer is right after the shm SEG0,
-		 *  so set the base address to SHMBASE */
-		if (trace_read) {
-			ul_ext_base = ul_shm_base_virt;
-			ul_ext_end = ul_trace_sec_end;
-		}
-
-
-		if (ul_ext_end < ul_ext_base)
-			status = -EPERM;
-
-		if (!status) {
-			ul_tlb_base_virt =
-			    dev_context->atlb_entry[0].dsp_va * DSPWORDSIZE;
-			dw_ext_prog_virt_mem =
-			    dev_context->atlb_entry[0].gpp_va;
-
-			if (!trace_read) {
-				ul_shm_offset_virt =
-				    ul_shm_base_virt - ul_tlb_base_virt;
-				ul_shm_offset_virt +=
-				    PG_ALIGN_HIGH(ul_ext_end - ul_dyn_ext_base +
-						  1, HW_PAGE_SIZE64KB);
-				dw_ext_prog_virt_mem -= ul_shm_offset_virt;
-				dw_ext_prog_virt_mem +=
-				    (ul_ext_base - ul_dyn_ext_base);
-				dev_context->dsp_ext_base_addr =
-				    dw_ext_prog_virt_mem;
-
-				/*
-				 * This dsp_ext_base_addr will get cleared
-				 * only when the board is stopped.
-				*/
-				if (!dev_context->dsp_ext_base_addr)
-					status = -EPERM;
-			}
-
-			dw_base_addr = dw_ext_prog_virt_mem;
-		}
-	}
-
-	if (!dw_base_addr || !ul_ext_base || !ul_ext_end)
-		status = -EPERM;
-
-	offset = dsp_addr - ul_ext_base;
-
-	if (!status)
-		memcpy(host_buff, (u8 *) dw_base_addr + offset, ul_num_bytes);
-
-	return status;
-}
-
-/*
- *  ======== write_dsp_data ========
- *  purpose:
- *      Copies buffers to the DSP internal/external memory.
- */
-int write_dsp_data(struct bridge_dev_context *dev_context,
-			  u8 *host_buff, u32 dsp_addr, u32 ul_num_bytes,
-			  u32 mem_type)
-{
-	u32 offset;
-	u32 dw_base_addr = dev_context->dsp_base_addr;
-	struct cfg_hostres *resources = dev_context->resources;
-	int status = 0;
-	u32 base1, base2, base3;
-
-	base1 = OMAP_DSP_MEM1_SIZE;
-	base2 = OMAP_DSP_MEM2_BASE - OMAP_DSP_MEM1_BASE;
-	base3 = OMAP_DSP_MEM3_BASE - OMAP_DSP_MEM1_BASE;
-
-	if (!resources)
-		return -EPERM;
-
-	offset = dsp_addr - dev_context->dsp_start_add;
-	if (offset < base1) {
-		dw_base_addr = MEM_LINEAR_ADDRESS(resources->mem_base[2],
-						  resources->mem_length[2]);
-	} else if (offset > base1 && offset < base2 + OMAP_DSP_MEM2_SIZE) {
-		dw_base_addr = MEM_LINEAR_ADDRESS(resources->mem_base[3],
-						  resources->mem_length[3]);
-		offset = offset - base2;
-	} else if (offset >= base2 + OMAP_DSP_MEM2_SIZE &&
-		   offset < base3 + OMAP_DSP_MEM3_SIZE) {
-		dw_base_addr = MEM_LINEAR_ADDRESS(resources->mem_base[4],
-						  resources->mem_length[4]);
-		offset = offset - base3;
-	} else {
-		return -EPERM;
-	}
-	if (ul_num_bytes)
-		memcpy((u8 *) (dw_base_addr + offset), host_buff, ul_num_bytes);
-	else
-		*((u32 *) host_buff) = dw_base_addr + offset;
-
-	return status;
-}
-
-/*
- *  ======== write_ext_dsp_data ========
- *  purpose:
- *      Copies buffers to the external memory.
- *
- */
-int write_ext_dsp_data(struct bridge_dev_context *dev_context,
-			      u8 *host_buff, u32 dsp_addr,
-			      u32 ul_num_bytes, u32 mem_type,
-			      bool dynamic_load)
-{
-	u32 dw_base_addr = dev_context->dsp_ext_base_addr;
-	u32 dw_offset = 0;
-	u8 temp_byte1, temp_byte2;
-	u8 remain_byte[4];
-	s32 i;
-	int ret = 0;
-	u32 dw_ext_prog_virt_mem;
-	u32 ul_tlb_base_virt = 0;
-	u32 ul_shm_offset_virt = 0;
-	struct cfg_hostres *host_res = dev_context->resources;
-	bool trace_load = false;
-
-	temp_byte1 = 0x0;
-	temp_byte2 = 0x0;
-
-	if (symbols_reloaded) {
-		/* Check if it is a load to Trace section */
-		ret = dev_get_symbol(dev_context->dev_obj,
-				     DSP_TRACESEC_BEG, &ul_trace_sec_beg);
-		if (!ret)
-			ret = dev_get_symbol(dev_context->dev_obj,
-					     DSP_TRACESEC_END,
-					     &ul_trace_sec_end);
-	}
-	if (!ret) {
-		if ((dsp_addr <= ul_trace_sec_end) &&
-		    (dsp_addr >= ul_trace_sec_beg))
-			trace_load = true;
-	}
-
-	/* If dynamic, force remap/unmap */
-	if ((dynamic_load || trace_load) && dw_base_addr) {
-		dw_base_addr = 0;
-		MEM_UNMAP_LINEAR_ADDRESS((void *)
-					 dev_context->dsp_ext_base_addr);
-		dev_context->dsp_ext_base_addr = 0x0;
-	}
-	if (!dw_base_addr) {
-		if (symbols_reloaded)
-			/* Get SHM_BEG  EXT_BEG and EXT_END. */
-			ret = dev_get_symbol(dev_context->dev_obj,
-					     SHMBASENAME, &ul_shm_base_virt);
-		if (dynamic_load) {
-			if (!ret) {
-				if (symbols_reloaded)
-					ret =
-					    dev_get_symbol
-					    (dev_context->dev_obj, DYNEXTBASE,
-					     &ul_ext_base);
-			}
-			if (!ret) {
-				/* DR  OMAPS00013235 : DLModules array may be
-				 * in EXTMEM. It is expected that DYNEXTMEM and
-				 * EXTMEM are contiguous, so checking for the
-				 * upper bound at EXTEND should be Ok. */
-				if (symbols_reloaded)
-					ret =
-					    dev_get_symbol
-					    (dev_context->dev_obj, EXTEND,
-					     &ul_ext_end);
-			}
-		} else {
-			if (symbols_reloaded) {
-				if (!ret)
-					ret =
-					    dev_get_symbol
-					    (dev_context->dev_obj, EXTBASE,
-					     &ul_ext_base);
-				if (!ret)
-					ret =
-					    dev_get_symbol
-					    (dev_context->dev_obj, EXTEND,
-					     &ul_ext_end);
-			}
-		}
-		/* Trace buffer it right after the shm SEG0, so set the
-		 *      base address to SHMBASE */
-		if (trace_load)
-			ul_ext_base = ul_shm_base_virt;
-
-		if (ul_ext_end < ul_ext_base)
-			ret = -EPERM;
-
-		if (!ret) {
-			ul_tlb_base_virt =
-			    dev_context->atlb_entry[0].dsp_va * DSPWORDSIZE;
-
-			if (symbols_reloaded) {
-				ret = dev_get_symbol
-					    (dev_context->dev_obj,
-					     DSP_TRACESEC_END, &shm0_end);
-				if (!ret) {
-					ret =
-					    dev_get_symbol
-					    (dev_context->dev_obj, DYNEXTBASE,
-					     &ul_dyn_ext_base);
-				}
-			}
-			ul_shm_offset_virt =
-			    ul_shm_base_virt - ul_tlb_base_virt;
-			if (trace_load) {
-				dw_ext_prog_virt_mem =
-				    dev_context->atlb_entry[0].gpp_va;
-			} else {
-				dw_ext_prog_virt_mem = host_res->mem_base[1];
-				dw_ext_prog_virt_mem +=
-				    (ul_ext_base - ul_dyn_ext_base);
-			}
-
-			dev_context->dsp_ext_base_addr =
-			    (u32) MEM_LINEAR_ADDRESS((void *)
-						     dw_ext_prog_virt_mem,
-						     ul_ext_end - ul_ext_base);
-			dw_base_addr += dev_context->dsp_ext_base_addr;
-			/* This dsp_ext_base_addr will get cleared only when
-			 * the board is stopped. */
-			if (!dev_context->dsp_ext_base_addr)
-				ret = -EPERM;
-		}
-	}
-	if (!dw_base_addr || !ul_ext_base || !ul_ext_end)
-		ret = -EPERM;
-
-	if (!ret) {
-		for (i = 0; i < 4; i++)
-			remain_byte[i] = 0x0;
-
-		dw_offset = dsp_addr - ul_ext_base;
-		/* Also make sure the dsp_addr is < ul_ext_end */
-		if (dsp_addr > ul_ext_end || dw_offset > dsp_addr)
-			ret = -EPERM;
-	}
-	if (!ret) {
-		if (ul_num_bytes)
-			memcpy((u8 *) dw_base_addr + dw_offset, host_buff,
-			       ul_num_bytes);
-		else
-			*((u32 *) host_buff) = dw_base_addr + dw_offset;
-	}
-	/* Unmap here to force remap for other Ext loads */
-	if ((dynamic_load || trace_load) && dev_context->dsp_ext_base_addr) {
-		MEM_UNMAP_LINEAR_ADDRESS((void *)
-					 dev_context->dsp_ext_base_addr);
-		dev_context->dsp_ext_base_addr = 0x0;
-	}
-	symbols_reloaded = false;
-	return ret;
-}
-
-int sm_interrupt_dsp(struct bridge_dev_context *dev_context, u16 mb_val)
-{
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-	u32 opplevel = 0;
-#endif
-	struct omap_dsp_platform_data *pdata =
-		omap_dspbridge_dev->dev.platform_data;
-	struct cfg_hostres *resources = dev_context->resources;
-	int status = 0;
-	u32 temp;
-
-	if (!dev_context->mbox)
-		return 0;
-
-	if (!resources)
-		return -EPERM;
-
-	if (dev_context->brd_state == BRD_DSP_HIBERNATION ||
-	    dev_context->brd_state == BRD_HIBERNATION) {
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-		if (pdata->dsp_get_opp)
-			opplevel = (*pdata->dsp_get_opp) ();
-		if (opplevel == VDD1_OPP1) {
-			if (pdata->dsp_set_min_opp)
-				(*pdata->dsp_set_min_opp) (VDD1_OPP2);
-		}
-#endif
-		/* Restart the peripheral clocks */
-		dsp_clock_enable_all(dev_context->dsp_per_clks);
-		dsp_wdt_enable(true);
-
-		/*
-		 * 2:0 AUTO_IVA2_DPLL - Enabling IVA2 DPLL auto control
-		 *     in CM_AUTOIDLE_PLL_IVA2 register
-		 */
-		(*pdata->dsp_cm_write)(1 << OMAP3430_AUTO_IVA2_DPLL_SHIFT,
-				OMAP3430_IVA2_MOD, OMAP3430_CM_AUTOIDLE_PLL);
-
-		/*
-		 * 7:4 IVA2_DPLL_FREQSEL - IVA2 internal frq set to
-		 *     0.75 MHz - 1.0 MHz
-		 * 2:0 EN_IVA2_DPLL - Enable IVA2 DPLL in lock mode
-		 */
-		(*pdata->dsp_cm_rmw_bits)(OMAP3430_IVA2_DPLL_FREQSEL_MASK |
-				OMAP3430_EN_IVA2_DPLL_MASK,
-				0x3 << OMAP3430_IVA2_DPLL_FREQSEL_SHIFT |
-				0x7 << OMAP3430_EN_IVA2_DPLL_SHIFT,
-				OMAP3430_IVA2_MOD, OMAP3430_CM_CLKEN_PLL);
-
-		/* Restore mailbox settings */
-		omap_mbox_restore_ctx(dev_context->mbox);
-
-		/* Access MMU SYS CONFIG register to generate a short wakeup */
-		temp = readl(resources->dmmu_base + 0x10);
-
-		dev_context->brd_state = BRD_RUNNING;
-	} else if (dev_context->brd_state == BRD_RETENTION) {
-		/* Restart the peripheral clocks */
-		dsp_clock_enable_all(dev_context->dsp_per_clks);
-	}
-
-	status = omap_mbox_msg_send(dev_context->mbox, mb_val);
-
-	if (status) {
-		pr_err("omap_mbox_msg_send Fail and status = %d\n", status);
-		status = -EPERM;
-	}
-
-	return 0;
-}
diff --git a/drivers/staging/tidspbridge/core/tiomap_io.h b/drivers/staging/tidspbridge/core/tiomap_io.h
deleted file mode 100644
index a3f19c7..0000000
--- a/drivers/staging/tidspbridge/core/tiomap_io.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * tiomap_io.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Definitions, types and function prototypes for the io (r/w external mem).
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _TIOMAP_IO_
-#define _TIOMAP_IO_
-
-/*
- * Symbol that defines beginning of shared memory.
- * For OMAP (Helen) this is the DSP Virtual base address of SDRAM.
- * This will be used to program DSP MMU to map DSP Virt to GPP phys.
- * (see dspMmuTlbEntry()).
- */
-#define SHMBASENAME "SHM_BEG"
-#define EXTBASE     "EXT_BEG"
-#define EXTEND      "_EXT_END"
-#define DYNEXTBASE  "_DYNEXT_BEG"
-#define DYNEXTEND   "_DYNEXT_END"
-#define IVAEXTMEMBASE   "_IVAEXTMEM_BEG"
-#define IVAEXTMEMEND   "_IVAEXTMEM_END"
-
-#define DSP_TRACESEC_BEG  "_BRIDGE_TRACE_BEG"
-#define DSP_TRACESEC_END  "_BRIDGE_TRACE_END"
-
-#define SYS_PUTCBEG               "_SYS_PUTCBEG"
-#define SYS_PUTCEND               "_SYS_PUTCEND"
-#define BRIDGE_SYS_PUTC_CURRENT   "_BRIDGE_SYS_PUTC_current"
-
-#define WORDSWAP_ENABLE 0x3	/* Enable word swap */
-
-/*
- *  ======== read_ext_dsp_data ========
- *  Reads it from DSP External memory. The external memory for the DSP
- * is configured by the combination of DSP MMU and shm Memory manager in the CDB
- */
-extern int read_ext_dsp_data(struct bridge_dev_context *dev_ctxt,
-				    u8 *host_buff, u32 dsp_addr,
-				    u32 ul_num_bytes, u32 mem_type);
-
-/*
- *  ======== write_dsp_data ========
- */
-extern int write_dsp_data(struct bridge_dev_context *dev_context,
-				 u8 *host_buff, u32 dsp_addr,
-				 u32 ul_num_bytes, u32 mem_type);
-
-/*
- *  ======== write_ext_dsp_data ========
- *  Writes to the DSP External memory for external program.
- *  The ext mem for progra is configured by the combination of DSP MMU and
- *  shm Memory manager in the CDB
- */
-extern int write_ext_dsp_data(struct bridge_dev_context *dev_context,
-				     u8 *host_buff, u32 dsp_addr,
-				     u32 ul_num_bytes, u32 mem_type,
-				     bool dynamic_load);
-
-/*
- * ======== write_ext32_bit_dsp_data ========
- * Writes 32 bit data to the external memory
- */
-extern inline void write_ext32_bit_dsp_data(const
-					struct bridge_dev_context *dev_context,
-					u32 dsp_addr, u32 val)
-{
-	*(u32 *) dsp_addr = ((dev_context->tc_word_swap_on) ? (((val << 16) &
-								 0xFFFF0000) |
-								((val >> 16) &
-								 0x0000FFFF)) :
-			      val);
-}
-
-/*
- * ======== read_ext32_bit_dsp_data ========
- * Reads 32 bit data from the external memory
- */
-extern inline u32 read_ext32_bit_dsp_data(const struct bridge_dev_context
-					  *dev_context, u32 dsp_addr)
-{
-	u32 ret;
-	ret = *(u32 *) dsp_addr;
-
-	ret = ((dev_context->tc_word_swap_on) ? (((ret << 16)
-						  & 0xFFFF0000) | ((ret >> 16) &
-								   0x0000FFFF))
-	       : ret);
-	return ret;
-}
-
-#endif /* _TIOMAP_IO_ */
diff --git a/drivers/staging/tidspbridge/core/ue_deh.c b/drivers/staging/tidspbridge/core/ue_deh.c
deleted file mode 100644
index e68f0ba..0000000
--- a/drivers/staging/tidspbridge/core/ue_deh.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * ue_deh.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Implements upper edge DSP exception handling (DEH) functions.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- * Copyright (C) 2010 Felipe Contreras
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/kernel.h>
-#include <linux/interrupt.h>
-
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/dspdeh.h>
-#include <dspbridge/dev.h>
-#include "_tiomap.h"
-#include "_deh.h"
-
-#include <dspbridge/io_sm.h>
-#include <dspbridge/drv.h>
-#include <dspbridge/wdt.h>
-
-static u32 fault_addr;
-
-static void mmu_fault_dpc(unsigned long data)
-{
-	struct deh_mgr *deh = (void *)data;
-
-	if (!deh)
-		return;
-
-	bridge_deh_notify(deh, DSP_MMUFAULT, 0);
-}
-
-static irqreturn_t mmu_fault_isr(int irq, void *data)
-{
-	struct deh_mgr *deh = data;
-	struct cfg_hostres *resources;
-	u32 event;
-
-	if (!deh)
-		return IRQ_HANDLED;
-
-	resources = deh->bridge_context->resources;
-	if (!resources) {
-		dev_dbg(bridge, "%s: Failed to get Host Resources\n",
-				__func__);
-		return IRQ_HANDLED;
-	}
-
-	hw_mmu_event_status(resources->dmmu_base, &event);
-	if (event == HW_MMU_TRANSLATION_FAULT) {
-		hw_mmu_fault_addr_read(resources->dmmu_base, &fault_addr);
-		dev_dbg(bridge, "%s: event=0x%x, fault_addr=0x%x\n", __func__,
-				event, fault_addr);
-		/*
-		 * Schedule a DPC directly. In the future, it may be
-		 * necessary to check if DSP MMU fault is intended for
-		 * Bridge.
-		 */
-		tasklet_schedule(&deh->dpc_tasklet);
-
-		/* Disable the MMU events, else once we clear it will
-		 * start to raise INTs again */
-		hw_mmu_event_disable(resources->dmmu_base,
-				HW_MMU_TRANSLATION_FAULT);
-	} else {
-		hw_mmu_event_disable(resources->dmmu_base,
-				HW_MMU_ALL_INTERRUPTS);
-	}
-	return IRQ_HANDLED;
-}
-
-int bridge_deh_create(struct deh_mgr **ret_deh,
-		struct dev_object *hdev_obj)
-{
-	int status;
-	struct deh_mgr *deh;
-	struct bridge_dev_context *hbridge_context = NULL;
-
-	/*  Message manager will be created when a file is loaded, since
-	 *  size of message buffer in shared memory is configurable in
-	 *  the base image. */
-	/* Get Bridge context info. */
-	dev_get_bridge_context(hdev_obj, &hbridge_context);
-	/* Allocate IO manager object: */
-	deh = kzalloc(sizeof(*deh), GFP_KERNEL);
-	if (!deh) {
-		status = -ENOMEM;
-		goto err;
-	}
-
-	/* Create an NTFY object to manage notifications */
-	deh->ntfy_obj = kmalloc(sizeof(struct ntfy_object), GFP_KERNEL);
-	if (!deh->ntfy_obj) {
-		status = -ENOMEM;
-		goto err;
-	}
-	ntfy_init(deh->ntfy_obj);
-
-	/* Create a MMUfault DPC */
-	tasklet_init(&deh->dpc_tasklet, mmu_fault_dpc, (u32) deh);
-
-	/* Fill in context structure */
-	deh->bridge_context = hbridge_context;
-
-	/* Install ISR function for DSP MMU fault */
-	status = request_irq(INT_DSP_MMU_IRQ, mmu_fault_isr, 0,
-			"DspBridge\tiommu fault", deh);
-	if (status < 0)
-		goto err;
-
-	*ret_deh = deh;
-	return 0;
-
-err:
-	bridge_deh_destroy(deh);
-	*ret_deh = NULL;
-	return status;
-}
-
-int bridge_deh_destroy(struct deh_mgr *deh)
-{
-	if (!deh)
-		return -EFAULT;
-
-	/* If notification object exists, delete it */
-	if (deh->ntfy_obj) {
-		ntfy_delete(deh->ntfy_obj);
-		kfree(deh->ntfy_obj);
-	}
-	/* Disable DSP MMU fault */
-	free_irq(INT_DSP_MMU_IRQ, deh);
-
-	/* Free DPC object */
-	tasklet_kill(&deh->dpc_tasklet);
-
-	/* Deallocate the DEH manager object */
-	kfree(deh);
-
-	return 0;
-}
-
-int bridge_deh_register_notify(struct deh_mgr *deh, u32 event_mask,
-		u32 notify_type,
-		struct dsp_notification *hnotification)
-{
-	if (!deh)
-		return -EFAULT;
-
-	if (event_mask)
-		return ntfy_register(deh->ntfy_obj, hnotification,
-				event_mask, notify_type);
-	else
-		return ntfy_unregister(deh->ntfy_obj, hnotification);
-}
-
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-static void mmu_fault_print_stack(struct bridge_dev_context *dev_context)
-{
-	struct cfg_hostres *resources;
-	struct hw_mmu_map_attrs_t map_attrs = {
-		.endianism = HW_LITTLE_ENDIAN,
-		.element_size = HW_ELEM_SIZE16BIT,
-		.mixed_size = HW_MMU_CPUES,
-	};
-	void *dummy_va_addr;
-
-	resources = dev_context->resources;
-	dummy_va_addr = (void *)__get_free_page(GFP_ATOMIC);
-
-	/*
-	 * Before acking the MMU fault, let's make sure MMU can only
-	 * access entry #0. Then add a new entry so that the DSP OS
-	 * can continue in order to dump the stack.
-	 */
-	hw_mmu_twl_disable(resources->dmmu_base);
-	hw_mmu_tlb_flush_all(resources->dmmu_base);
-
-	hw_mmu_tlb_add(resources->dmmu_base,
-			virt_to_phys(dummy_va_addr), fault_addr,
-			HW_PAGE_SIZE4KB, 1,
-			&map_attrs, HW_SET, HW_SET);
-
-	dsp_clk_enable(DSP_CLK_GPT8);
-
-	dsp_gpt_wait_overflow(DSP_CLK_GPT8, 0xfffffffe);
-
-	/* Clear MMU interrupt */
-	hw_mmu_event_ack(resources->dmmu_base,
-			HW_MMU_TRANSLATION_FAULT);
-	dump_dsp_stack(dev_context);
-	dsp_clk_disable(DSP_CLK_GPT8);
-
-	hw_mmu_disable(resources->dmmu_base);
-	free_page((unsigned long)dummy_va_addr);
-}
-#endif
-
-static inline const char *event_to_string(int event)
-{
-	switch (event) {
-	case DSP_SYSERROR: return "DSP_SYSERROR"; break;
-	case DSP_MMUFAULT: return "DSP_MMUFAULT"; break;
-	case DSP_PWRERROR: return "DSP_PWRERROR"; break;
-	case DSP_WDTOVERFLOW: return "DSP_WDTOVERFLOW"; break;
-	default: return "unknown event"; break;
-	}
-}
-
-void bridge_deh_notify(struct deh_mgr *deh, int event, int info)
-{
-	struct bridge_dev_context *dev_context;
-	const char *str = event_to_string(event);
-
-	if (!deh)
-		return;
-
-	dev_dbg(bridge, "%s: device exception", __func__);
-	dev_context = deh->bridge_context;
-
-	switch (event) {
-	case DSP_SYSERROR:
-		dev_err(bridge, "%s: %s, info=0x%x", __func__,
-				str, info);
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-		dump_dl_modules(dev_context);
-		dump_dsp_stack(dev_context);
-#endif
-		break;
-	case DSP_MMUFAULT:
-		dev_err(bridge, "%s: %s, addr=0x%x", __func__,
-				str, fault_addr);
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-		print_dsp_trace_buffer(dev_context);
-		dump_dl_modules(dev_context);
-		mmu_fault_print_stack(dev_context);
-#endif
-		break;
-	default:
-		dev_err(bridge, "%s: %s", __func__, str);
-		break;
-	}
-
-	/* Filter subsequent notifications when an error occurs */
-	if (dev_context->brd_state != BRD_ERROR) {
-		ntfy_notify(deh->ntfy_obj, event);
-#ifdef CONFIG_TIDSPBRIDGE_RECOVERY
-		bridge_recover_schedule();
-#endif
-	}
-
-	/* Set the Board state as ERROR */
-	dev_context->brd_state = BRD_ERROR;
-	/* Disable all the clocks that were enabled by DSP */
-	dsp_clock_disable_all(dev_context->dsp_per_clks);
-	/*
-	 * Avoid the subsequent WDT if it happens once,
-	 * also if fatal error occurs.
-	 */
-	dsp_wdt_enable(false);
-}
diff --git a/drivers/staging/tidspbridge/core/wdt.c b/drivers/staging/tidspbridge/core/wdt.c
deleted file mode 100644
index b19f887..0000000
--- a/drivers/staging/tidspbridge/core/wdt.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * wdt.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * IO dispatcher for a shared memory channel driver.
- *
- * Copyright (C) 2010 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#include <linux/types.h>
-
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/dspdeh.h>
-#include <dspbridge/dev.h>
-#include <dspbridge/_chnl_sm.h>
-#include <dspbridge/wdt.h>
-#include <dspbridge/host_os.h>
-
-
-#define OMAP34XX_WDT3_BASE	(0x49000000 + 0x30000)
-#define INT_34XX_WDT3_IRQ	(36 + NR_IRQS)
-
-static struct dsp_wdt_setting dsp_wdt;
-
-void dsp_wdt_dpc(unsigned long data)
-{
-	struct deh_mgr *deh_mgr;
-
-	dev_get_deh_mgr(dev_get_first(), &deh_mgr);
-	if (deh_mgr)
-		bridge_deh_notify(deh_mgr, DSP_WDTOVERFLOW, 0);
-}
-
-irqreturn_t dsp_wdt_isr(int irq, void *data)
-{
-	u32 value;
-	/* ack wdt3 interrupt */
-	value = __raw_readl(dsp_wdt.reg_base + OMAP3_WDT3_ISR_OFFSET);
-	__raw_writel(value, dsp_wdt.reg_base + OMAP3_WDT3_ISR_OFFSET);
-
-	tasklet_schedule(&dsp_wdt.wdt3_tasklet);
-	return IRQ_HANDLED;
-}
-
-int dsp_wdt_init(void)
-{
-	int ret = 0;
-
-	dsp_wdt.sm_wdt = NULL;
-	dsp_wdt.reg_base = ioremap(OMAP34XX_WDT3_BASE, SZ_4K);
-	if (!dsp_wdt.reg_base)
-		return -ENOMEM;
-
-	tasklet_init(&dsp_wdt.wdt3_tasklet, dsp_wdt_dpc, 0);
-
-	dsp_wdt.fclk = clk_get(NULL, "wdt3_fck");
-
-	if (!IS_ERR(dsp_wdt.fclk)) {
-		clk_prepare(dsp_wdt.fclk);
-
-		dsp_wdt.iclk = clk_get(NULL, "wdt3_ick");
-		if (IS_ERR(dsp_wdt.iclk)) {
-			clk_put(dsp_wdt.fclk);
-			dsp_wdt.fclk = NULL;
-			ret = -EFAULT;
-		} else {
-			clk_prepare(dsp_wdt.iclk);
-		}
-	} else
-		ret = -EFAULT;
-
-	if (!ret)
-		ret = request_irq(INT_34XX_WDT3_IRQ, dsp_wdt_isr, 0,
-							"dsp_wdt", &dsp_wdt);
-
-	/* Disable at this moment, it will be enabled when DSP starts */
-	if (!ret)
-		disable_irq(INT_34XX_WDT3_IRQ);
-
-	return ret;
-}
-
-void dsp_wdt_sm_set(void *data)
-{
-	dsp_wdt.sm_wdt = data;
-	dsp_wdt.sm_wdt->wdt_overflow = 5;	/* in seconds */
-}
-
-
-void dsp_wdt_exit(void)
-{
-	free_irq(INT_34XX_WDT3_IRQ, &dsp_wdt);
-	tasklet_kill(&dsp_wdt.wdt3_tasklet);
-
-	if (dsp_wdt.fclk) {
-		clk_unprepare(dsp_wdt.fclk);
-		clk_put(dsp_wdt.fclk);
-	}
-	if (dsp_wdt.iclk) {
-		clk_unprepare(dsp_wdt.iclk);
-		clk_put(dsp_wdt.iclk);
-	}
-
-	dsp_wdt.fclk = NULL;
-	dsp_wdt.iclk = NULL;
-	dsp_wdt.sm_wdt = NULL;
-
-	if (dsp_wdt.reg_base)
-		iounmap(dsp_wdt.reg_base);
-	dsp_wdt.reg_base = NULL;
-}
-
-void dsp_wdt_enable(bool enable)
-{
-	u32 tmp;
-	static bool wdt_enable;
-
-	if (wdt_enable == enable || !dsp_wdt.fclk || !dsp_wdt.iclk)
-		return;
-
-	wdt_enable = enable;
-
-	if (enable) {
-		clk_enable(dsp_wdt.fclk);
-		clk_enable(dsp_wdt.iclk);
-		dsp_wdt.sm_wdt->wdt_setclocks = 1;
-		tmp = __raw_readl(dsp_wdt.reg_base + OMAP3_WDT3_ISR_OFFSET);
-		__raw_writel(tmp, dsp_wdt.reg_base + OMAP3_WDT3_ISR_OFFSET);
-		enable_irq(INT_34XX_WDT3_IRQ);
-	} else {
-		disable_irq(INT_34XX_WDT3_IRQ);
-		dsp_wdt.sm_wdt->wdt_setclocks = 0;
-		clk_disable(dsp_wdt.iclk);
-		clk_disable(dsp_wdt.fclk);
-	}
-}
diff --git a/drivers/staging/tidspbridge/dynload/cload.c b/drivers/staging/tidspbridge/dynload/cload.c
deleted file mode 100644
index 83f2106..0000000
--- a/drivers/staging/tidspbridge/dynload/cload.c
+++ /dev/null
@@ -1,1959 +0,0 @@
-/*
- * cload.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/slab.h>
-
-#include "header.h"
-
-#include "module_list.h"
-#define LINKER_MODULES_HEADER ("_" MODULES_HEADER)
-
-/*
- * forward references
- */
-static void dload_symbols(struct dload_state *dlthis);
-static void dload_data(struct dload_state *dlthis);
-static void allocate_sections(struct dload_state *dlthis);
-static void string_table_free(struct dload_state *dlthis);
-static void symbol_table_free(struct dload_state *dlthis);
-static void section_table_free(struct dload_state *dlthis);
-static void init_module_handle(struct dload_state *dlthis);
-#if BITS_PER_AU > BITS_PER_BYTE
-static char *unpack_name(struct dload_state *dlthis, u32 soffset);
-#endif
-
-static const char cinitname[] = { ".cinit" };
-static const char loader_dllview_root[] = { "?DLModules?" };
-
-/*
- * Error strings
- */
-static const char readstrm[] = { "Error reading %s from input stream" };
-static const char err_alloc[] = { "Syms->dload_allocate( %d ) failed" };
-static const char tgtalloc[] = {
-	"Target memory allocate failed, section %s size " FMT_UI32 };
-static const char initfail[] = { "%s to target address " FMT_UI32 " failed" };
-static const char dlvwrite[] = { "Write to DLLview list failed" };
-static const char iconnect[] = { "Connect call to init interface failed" };
-static const char err_checksum[] = { "Checksum failed on %s" };
-
-/*************************************************************************
- * Procedure dload_error
- *
- * Parameters:
- *	errtxt	description of the error, printf style
- *	...		additional information
- *
- * Effect:
- *	Reports or records the error as appropriate.
- *********************************************************************** */
-void dload_error(struct dload_state *dlthis, const char *errtxt, ...)
-{
-	va_list args;
-
-	va_start(args, errtxt);
-	dlthis->mysym->error_report(dlthis->mysym, errtxt, args);
-	va_end(args);
-	dlthis->dload_errcount += 1;
-
-}				/* dload_error */
-
-#define DL_ERROR(zza, zzb) dload_error(dlthis, zza, zzb)
-
-/*************************************************************************
- * Procedure dload_syms_error
- *
- * Parameters:
- *	errtxt	description of the error, printf style
- *	...		additional information
- *
- * Effect:
- *	Reports or records the error as appropriate.
- *********************************************************************** */
-void dload_syms_error(struct dynamic_loader_sym *syms, const char *errtxt, ...)
-{
-	va_list args;
-
-	va_start(args, errtxt);
-	syms->error_report(syms, errtxt, args);
-	va_end(args);
-}
-
-/*************************************************************************
- * Procedure dynamic_load_module
- *
- * Parameters:
- *	module	The input stream that supplies the module image
- *	syms	Host-side symbol table and malloc/free functions
- *	alloc	Target-side memory allocation
- *	init	Target-side memory initialization
- *	options	Option flags DLOAD_*
- *	mhandle	A module handle for use with Dynamic_Unload
- *
- * Effect:
- *	The module image is read using *module.  Target storage for the new
- *	image is
- * obtained from *alloc.  Symbols defined and referenced by the module are
- * managed using *syms.  The image is then relocated and references
- *	resolved as necessary, and the resulting executable bits are placed
- *	into target memory using *init.
- *
- * Returns:
- *	On a successful load, a module handle is placed in *mhandle,
- *	and zero is returned.  On error, the number of errors detected is
- *	returned.  Individual errors are reported during the load process
- *	using syms->error_report().
- ********************************************************************** */
-int dynamic_load_module(struct dynamic_loader_stream *module,
-			struct dynamic_loader_sym *syms,
-			struct dynamic_loader_allocate *alloc,
-			struct dynamic_loader_initialize *init,
-			unsigned options, void **mhandle)
-{
-	register unsigned *dp, sz;
-	struct dload_state dl_state;	/* internal state for this call */
-
-	/* blast our internal state */
-	dp = (unsigned *)&dl_state;
-	for (sz = sizeof(dl_state) / sizeof(unsigned); sz > 0; sz -= 1)
-		*dp++ = 0;
-
-	/* Enable _only_ BSS initialization if enabled by user */
-	if ((options & DLOAD_INITBSS) == DLOAD_INITBSS)
-		dl_state.myoptions = DLOAD_INITBSS;
-
-	/* Check that mandatory arguments are present */
-	if (!module || !syms) {
-		dload_error(&dl_state, "Required parameter is NULL");
-	} else {
-		dl_state.strm = module;
-		dl_state.mysym = syms;
-		dload_headers(&dl_state);
-		if (!dl_state.dload_errcount)
-			dload_strings(&dl_state, false);
-		if (!dl_state.dload_errcount)
-			dload_sections(&dl_state);
-
-		if (init && !dl_state.dload_errcount) {
-			if (init->connect(init)) {
-				dl_state.myio = init;
-				dl_state.myalloc = alloc;
-				/* do now, before reducing symbols */
-				allocate_sections(&dl_state);
-			} else
-				dload_error(&dl_state, iconnect);
-		}
-
-		if (!dl_state.dload_errcount) {
-			/* fix up entry point address */
-			unsigned sref = dl_state.dfile_hdr.df_entry_secn - 1;
-
-			if (sref < dl_state.allocated_secn_count)
-				dl_state.dfile_hdr.df_entrypt +=
-				    dl_state.ldr_sections[sref].run_addr;
-
-			dload_symbols(&dl_state);
-		}
-
-		if (init && !dl_state.dload_errcount)
-			dload_data(&dl_state);
-
-		init_module_handle(&dl_state);
-
-		/* dl_state.myio is init or 0 at this point. */
-		if (dl_state.myio) {
-			if ((!dl_state.dload_errcount) &&
-			    (dl_state.dfile_hdr.df_entry_secn != DN_UNDEF) &&
-			    (!init->execute(init,
-					    dl_state.dfile_hdr.df_entrypt)))
-				dload_error(&dl_state, "Init->Execute Failed");
-			init->release(init);
-		}
-
-		symbol_table_free(&dl_state);
-		section_table_free(&dl_state);
-		string_table_free(&dl_state);
-		dload_tramp_cleanup(&dl_state);
-
-		if (dl_state.dload_errcount) {
-			dynamic_unload_module(dl_state.myhandle, syms, alloc,
-					      init);
-			dl_state.myhandle = NULL;
-		}
-	}
-
-	if (mhandle)
-		*mhandle = dl_state.myhandle;	/* give back the handle */
-
-	return dl_state.dload_errcount;
-}				/* DLOAD_File */
-
-/*************************************************************************
- * Procedure dynamic_open_module
- *
- * Parameters:
- *      module  The input stream that supplies the module image
- *      syms    Host-side symbol table and malloc/free functions
- *      alloc   Target-side memory allocation
- *      init    Target-side memory initialization
- *      options Option flags DLOAD_*
- *      mhandle A module handle for use with Dynamic_Unload
- *
- * Effect:
- *      The module image is read using *module.  Target storage for the new
- *      image is
- * 	obtained from *alloc.  Symbols defined and referenced by the module are
- * 	managed using *syms.  The image is then relocated and references
- *      resolved as necessary, and the resulting executable bits are placed
- *      into target memory using *init.
- *
- * Returns:
- *      On a successful load, a module handle is placed in *mhandle,
- *      and zero is returned.  On error, the number of errors detected is
- *      returned.  Individual errors are reported during the load process
- *      using syms->error_report().
- ********************************************************************** */
-int
-dynamic_open_module(struct dynamic_loader_stream *module,
-		    struct dynamic_loader_sym *syms,
-		    struct dynamic_loader_allocate *alloc,
-		    struct dynamic_loader_initialize *init,
-		    unsigned options, void **mhandle)
-{
-	register unsigned *dp, sz;
-	struct dload_state dl_state;	/* internal state for this call */
-
-	/* blast our internal state */
-	dp = (unsigned *)&dl_state;
-	for (sz = sizeof(dl_state) / sizeof(unsigned); sz > 0; sz -= 1)
-		*dp++ = 0;
-
-	/* Enable _only_ BSS initialization if enabled by user */
-	if ((options & DLOAD_INITBSS) == DLOAD_INITBSS)
-		dl_state.myoptions = DLOAD_INITBSS;
-
-	/* Check that mandatory arguments are present */
-	if (!module || !syms) {
-		dload_error(&dl_state, "Required parameter is NULL");
-	} else {
-		dl_state.strm = module;
-		dl_state.mysym = syms;
-		dload_headers(&dl_state);
-		if (!dl_state.dload_errcount)
-			dload_strings(&dl_state, false);
-		if (!dl_state.dload_errcount)
-			dload_sections(&dl_state);
-
-		if (init && !dl_state.dload_errcount) {
-			if (init->connect(init)) {
-				dl_state.myio = init;
-				dl_state.myalloc = alloc;
-				/* do now, before reducing symbols */
-				allocate_sections(&dl_state);
-			} else
-				dload_error(&dl_state, iconnect);
-		}
-
-		if (!dl_state.dload_errcount) {
-			/* fix up entry point address */
-			unsigned sref = dl_state.dfile_hdr.df_entry_secn - 1;
-
-			if (sref < dl_state.allocated_secn_count)
-				dl_state.dfile_hdr.df_entrypt +=
-				    dl_state.ldr_sections[sref].run_addr;
-
-			dload_symbols(&dl_state);
-		}
-
-		init_module_handle(&dl_state);
-
-		/* dl_state.myio is either 0 or init at this point. */
-		if (dl_state.myio) {
-			if ((!dl_state.dload_errcount) &&
-			    (dl_state.dfile_hdr.df_entry_secn != DN_UNDEF) &&
-			    (!init->execute(init,
-					    dl_state.dfile_hdr.df_entrypt)))
-				dload_error(&dl_state, "Init->Execute Failed");
-			init->release(init);
-		}
-
-		symbol_table_free(&dl_state);
-		section_table_free(&dl_state);
-		string_table_free(&dl_state);
-
-		if (dl_state.dload_errcount) {
-			dynamic_unload_module(dl_state.myhandle, syms, alloc,
-					      init);
-			dl_state.myhandle = NULL;
-		}
-	}
-
-	if (mhandle)
-		*mhandle = dl_state.myhandle;	/* give back the handle */
-
-	return dl_state.dload_errcount;
-}				/* DLOAD_File */
-
-/*************************************************************************
- * Procedure dload_headers
- *
- * Parameters:
- *	none
- *
- * Effect:
- *	Loads the DOFF header and verify record.  Deals with any byte-order
- * issues and checks them for validity.
- *********************************************************************** */
-#define COMBINED_HEADER_SIZE (sizeof(struct doff_filehdr_t)+ \
-			     sizeof(struct doff_verify_rec_t))
-
-void dload_headers(struct dload_state *dlthis)
-{
-	u32 map;
-
-	/* Read the header and the verify record as one.  If we don't get it
-	   all, we're done */
-	if (dlthis->strm->read_buffer(dlthis->strm, &dlthis->dfile_hdr,
-				      COMBINED_HEADER_SIZE) !=
-	    COMBINED_HEADER_SIZE) {
-		DL_ERROR(readstrm, "File Headers");
-		return;
-	}
-	/*
-	 * Verify that we have the byte order of the file correct.
-	 * If not, must fix it before we can continue
-	 */
-	map = REORDER_MAP(dlthis->dfile_hdr.df_byte_reshuffle);
-	if (map != REORDER_MAP(BYTE_RESHUFFLE_VALUE)) {
-		/* input is either byte-shuffled or bad */
-		if ((map & 0xFCFCFCFC) == 0) {	/* no obviously bogus bits */
-			dload_reorder(&dlthis->dfile_hdr, COMBINED_HEADER_SIZE,
-				      map);
-		}
-		if (dlthis->dfile_hdr.df_byte_reshuffle !=
-		    BYTE_RESHUFFLE_VALUE) {
-			/* didn't fix the problem, the byte swap map is bad */
-			dload_error(dlthis,
-				    "Bad byte swap map " FMT_UI32 " in header",
-				    dlthis->dfile_hdr.df_byte_reshuffle);
-			return;
-		}
-		dlthis->reorder_map = map;	/* keep map for future use */
-	}
-
-	/*
-	 * Verify checksum of header and verify record
-	 */
-	if (~dload_checksum(&dlthis->dfile_hdr,
-			    sizeof(struct doff_filehdr_t)) ||
-	    ~dload_checksum(&dlthis->verify,
-			    sizeof(struct doff_verify_rec_t))) {
-		DL_ERROR(err_checksum, "header or verify record");
-		return;
-	}
-#if HOST_ENDIANNESS
-	dlthis->dfile_hdr.df_byte_reshuffle = map;	/* put back for later */
-#endif
-
-	/* Check for valid target ID */
-	if ((dlthis->dfile_hdr.df_target_id != TARGET_ID) &&
-	    -(dlthis->dfile_hdr.df_target_id != TMS470_ID)) {
-		dload_error(dlthis, "Bad target ID 0x%x and TARGET_ID 0x%x",
-			    dlthis->dfile_hdr.df_target_id, TARGET_ID);
-		return;
-	}
-	/* Check for valid file format */
-	if ((dlthis->dfile_hdr.df_doff_version != DOFF0)) {
-		dload_error(dlthis, "Bad DOFF version 0x%x",
-			    dlthis->dfile_hdr.df_doff_version);
-		return;
-	}
-
-	/*
-	 * Apply reasonableness checks to count fields
-	 */
-	if (dlthis->dfile_hdr.df_strtab_size > MAX_REASONABLE_STRINGTAB) {
-		dload_error(dlthis, "Excessive string table size " FMT_UI32,
-			    dlthis->dfile_hdr.df_strtab_size);
-		return;
-	}
-	if (dlthis->dfile_hdr.df_no_scns > MAX_REASONABLE_SECTIONS) {
-		dload_error(dlthis, "Excessive section count 0x%x",
-			    dlthis->dfile_hdr.df_no_scns);
-		return;
-	}
-#ifndef TARGET_ENDIANNESS
-	/*
-	 * Check that endianness does not disagree with explicit specification
-	 */
-	if ((dlthis->dfile_hdr.df_flags >> ALIGN_COFF_ENDIANNESS) &
-	    dlthis->myoptions & ENDIANNESS_MASK) {
-		dload_error(dlthis,
-			    "Input endianness disagrees with specified option");
-		return;
-	}
-	dlthis->big_e_target = dlthis->dfile_hdr.df_flags & DF_BIG;
-#endif
-
-}				/* dload_headers */
-
-/*	COFF Section Processing
- *
- *	COFF sections are read in and retained intact.  Each record is embedded
- * 	in a new structure that records the updated load and
- * 	run addresses of the section */
-
-static const char secn_errid[] = { "section" };
-
-/*************************************************************************
- * Procedure dload_sections
- *
- * Parameters:
- *	none
- *
- * Effect:
- *	Loads the section records into an internal table.
- *********************************************************************** */
-void dload_sections(struct dload_state *dlthis)
-{
-	s16 siz;
-	struct doff_scnhdr_t *shp;
-	unsigned nsecs = dlthis->dfile_hdr.df_no_scns;
-
-	/* allocate space for the DOFF section records */
-	siz = nsecs * sizeof(struct doff_scnhdr_t);
-	shp =
-	    (struct doff_scnhdr_t *)dlthis->mysym->dload_allocate(dlthis->mysym,
-								  siz);
-	if (!shp) {		/* not enough storage */
-		DL_ERROR(err_alloc, siz);
-		return;
-	}
-	dlthis->sect_hdrs = shp;
-
-	/* read in the section records */
-	if (dlthis->strm->read_buffer(dlthis->strm, shp, siz) != siz) {
-		DL_ERROR(readstrm, secn_errid);
-		return;
-	}
-
-	/* if we need to fix up byte order, do it now */
-	if (dlthis->reorder_map)
-		dload_reorder(shp, siz, dlthis->reorder_map);
-
-	/* check for validity */
-	if (~dload_checksum(dlthis->sect_hdrs, siz) !=
-	    dlthis->verify.dv_scn_rec_checksum) {
-		DL_ERROR(err_checksum, secn_errid);
-		return;
-	}
-
-}				/* dload_sections */
-
-/*****************************************************************************
- * Procedure allocate_sections
- *
- * Parameters:
- *	alloc	target memory allocator class
- *
- * Effect:
- *	Assigns new (target) addresses for sections
- **************************************************************************** */
-static void allocate_sections(struct dload_state *dlthis)
-{
-	u16 curr_sect, nsecs, siz;
-	struct doff_scnhdr_t *shp;
-	struct ldr_section_info *asecs;
-	struct my_handle *hndl;
-
-	nsecs = dlthis->dfile_hdr.df_no_scns;
-	if (!nsecs)
-		return;
-	if ((dlthis->myalloc == NULL) &&
-	    (dlthis->dfile_hdr.df_target_scns > 0)) {
-		DL_ERROR("Arg 3 (alloc) required but NULL", 0);
-		return;
-	}
-	/*
-	 * allocate space for the module handle, which we will keep for unload
-	 * purposes include an additional section store for an auto-generated
-	 * trampoline section in case we need it.
-	 */
-	siz = (dlthis->dfile_hdr.df_target_scns + 1) *
-	    sizeof(struct ldr_section_info) + MY_HANDLE_SIZE;
-
-	hndl =
-	    (struct my_handle *)dlthis->mysym->dload_allocate(dlthis->mysym,
-							      siz);
-	if (!hndl) {		/* not enough storage */
-		DL_ERROR(err_alloc, siz);
-		return;
-	}
-	/* initialize the handle header */
-	hndl->dm.next = hndl->dm.prev = hndl;	/* circular list */
-	hndl->dm.root = NULL;
-	hndl->dm.dbthis = 0;
-	dlthis->myhandle = hndl;	/* save away for return */
-	/* pointer to the section list of allocated sections */
-	dlthis->ldr_sections = asecs = hndl->secns;
-	/* * Insert names into all sections, make copies of
-	   the sections we allocate */
-	shp = dlthis->sect_hdrs;
-	for (curr_sect = 0; curr_sect < nsecs; curr_sect++) {
-		u32 soffset = shp->ds_offset;
-#if BITS_PER_AU <= BITS_PER_BYTE
-		/* attempt to insert the name of this section */
-		if (soffset < dlthis->dfile_hdr.df_strtab_size)
-			((struct ldr_section_info *)shp)->name =
-				dlthis->str_head + soffset;
-		else {
-			dload_error(dlthis, "Bad name offset in section %d",
-				    curr_sect);
-			((struct ldr_section_info *)shp)->name = NULL;
-		}
-#endif
-		/* allocate target storage for sections that require it */
-		if (ds_needs_allocation(shp)) {
-			*asecs = *(struct ldr_section_info *)shp;
-			asecs->context = 0;	/* zero the context field */
-#if BITS_PER_AU > BITS_PER_BYTE
-			asecs->name = unpack_name(dlthis, soffset);
-			dlthis->debug_string_size = soffset + dlthis->temp_len;
-#else
-			dlthis->debug_string_size = soffset;
-#endif
-			if (dlthis->myalloc != NULL) {
-				if (!dlthis->myalloc->
-				    dload_allocate(dlthis->myalloc, asecs,
-						   ds_alignment(asecs->type))) {
-					dload_error(dlthis, tgtalloc,
-						    asecs->name, asecs->size);
-					return;
-				}
-			}
-			/* keep address deltas in original section table */
-			shp->ds_vaddr = asecs->load_addr - shp->ds_vaddr;
-			shp->ds_paddr = asecs->run_addr - shp->ds_paddr;
-			dlthis->allocated_secn_count += 1;
-		}		/* allocate target storage */
-		shp += 1;
-		asecs += 1;
-	}
-#if BITS_PER_AU <= BITS_PER_BYTE
-	dlthis->debug_string_size +=
-	    strlen(dlthis->str_head + dlthis->debug_string_size) + 1;
-#endif
-}				/* allocate sections */
-
-/*************************************************************************
- * Procedure section_table_free
- *
- * Parameters:
- *	none
- *
- * Effect:
- *	Frees any state used by the symbol table.
- *
- * WARNING:
- *	This routine is not allowed to declare errors!
- *********************************************************************** */
-static void section_table_free(struct dload_state *dlthis)
-{
-	struct doff_scnhdr_t *shp;
-
-	shp = dlthis->sect_hdrs;
-	if (shp)
-		dlthis->mysym->dload_deallocate(dlthis->mysym, shp);
-
-}				/* section_table_free */
-
-/*************************************************************************
- * Procedure dload_strings
- *
- * Parameters:
- *  sec_names_only   If true only read in the "section names"
- *		     portion of the string table
- *
- * Effect:
- *	Loads the DOFF string table into memory. DOFF keeps all strings in a
- * big unsorted array.  We just read that array into memory in bulk.
- *********************************************************************** */
-static const char stringtbl[] = { "string table" };
-
-void dload_strings(struct dload_state *dlthis, bool sec_names_only)
-{
-	u32 ssiz;
-	char *strbuf;
-
-	if (sec_names_only) {
-		ssiz = BYTE_TO_HOST(DOFF_ALIGN
-				    (dlthis->dfile_hdr.df_scn_name_size));
-	} else {
-		ssiz = BYTE_TO_HOST(DOFF_ALIGN
-				    (dlthis->dfile_hdr.df_strtab_size));
-	}
-	if (ssiz == 0)
-		return;
-
-	/* get some memory for the string table */
-#if BITS_PER_AU > BITS_PER_BYTE
-	strbuf = (char *)dlthis->mysym->dload_allocate(dlthis->mysym, ssiz +
-						       dlthis->dfile_hdr.
-						       df_max_str_len);
-#else
-	strbuf = (char *)dlthis->mysym->dload_allocate(dlthis->mysym, ssiz);
-#endif
-	if (strbuf == NULL) {
-		DL_ERROR(err_alloc, ssiz);
-		return;
-	}
-	dlthis->str_head = strbuf;
-#if BITS_PER_AU > BITS_PER_BYTE
-	dlthis->str_temp = strbuf + ssiz;
-#endif
-	/* read in the strings and verify them */
-	if ((unsigned)(dlthis->strm->read_buffer(dlthis->strm, strbuf,
-						 ssiz)) != ssiz) {
-		DL_ERROR(readstrm, stringtbl);
-	}
-	/* if we need to fix up byte order, do it now */
-#ifndef _BIG_ENDIAN
-	if (dlthis->reorder_map)
-		dload_reorder(strbuf, ssiz, dlthis->reorder_map);
-
-	if ((!sec_names_only) && (~dload_checksum(strbuf, ssiz) !=
-				  dlthis->verify.dv_str_tab_checksum)) {
-		DL_ERROR(err_checksum, stringtbl);
-	}
-#else
-	if (dlthis->dfile_hdr.df_byte_reshuffle !=
-	    HOST_BYTE_ORDER(REORDER_MAP(BYTE_RESHUFFLE_VALUE))) {
-		/* put strings in big-endian order, not in PC order */
-		dload_reorder(strbuf, ssiz,
-			      HOST_BYTE_ORDER(dlthis->
-					      dfile_hdr.df_byte_reshuffle));
-	}
-	if ((!sec_names_only) && (~dload_reverse_checksum(strbuf, ssiz) !=
-				  dlthis->verify.dv_str_tab_checksum)) {
-		DL_ERROR(err_checksum, stringtbl);
-	}
-#endif
-}				/* dload_strings */
-
-/*************************************************************************
- * Procedure string_table_free
- *
- * Parameters:
- *	none
- *
- * Effect:
- *	Frees any state used by the string table.
- *
- * WARNING:
- *	This routine is not allowed to declare errors!
- ************************************************************************ */
-static void string_table_free(struct dload_state *dlthis)
-{
-	if (dlthis->str_head)
-		dlthis->mysym->dload_deallocate(dlthis->mysym,
-						dlthis->str_head);
-
-}				/* string_table_free */
-
-/*
- * Symbol Table Maintenance Functions
- *
- * COFF symbols are read by dload_symbols(), which is called after
- * sections have been allocated.  Symbols which might be used in
- * relocation (ie, not debug info) are retained in an internal temporary
- * compressed table (type local_symbol). A particular symbol is recovered
- * by index by calling dload_find_symbol().  dload_find_symbol
- * reconstructs a more explicit representation (type SLOTVEC) which is
- * used by reloc.c
- */
-/* real size of debug header */
-#define DBG_HDR_SIZE (sizeof(struct dll_module) - sizeof(struct dll_sect))
-
-static const char sym_errid[] = { "symbol" };
-
-/**************************************************************************
- * Procedure dload_symbols
- *
- * Parameters:
- *	none
- *
- * Effect:
- *	Reads in symbols and retains ones that might be needed for relocation
- * purposes.
- *********************************************************************** */
-/* size of symbol buffer no bigger than target data buffer, to limit stack
- * usage */
-#define MY_SYM_BUF_SIZ (BYTE_TO_HOST(IMAGE_PACKET_SIZE)/\
-			sizeof(struct doff_syment_t))
-
-static void dload_symbols(struct dload_state *dlthis)
-{
-	u32 sym_count, siz, dsiz, symbols_left;
-	u32 checks;
-	struct local_symbol *sp;
-	struct dynload_symbol *symp;
-	struct dynload_symbol *newsym;
-	struct doff_syment_t *my_sym_buf;
-
-	sym_count = dlthis->dfile_hdr.df_no_syms;
-	if (sym_count == 0)
-		return;
-
-	/*
-	 * We keep a local symbol table for all of the symbols in the input.
-	 * This table contains only section & value info, as we do not have
-	 * to do any name processing for locals.  We reuse this storage
-	 * as a temporary for .dllview record construction.
-	 * Allocate storage for the whole table.  Add 1 to the section count
-	 * in case a trampoline section is auto-generated as well as the
-	 * size of the trampoline section name so DLLView doesn't get lost.
-	 */
-
-	siz = sym_count * sizeof(struct local_symbol);
-	dsiz = DBG_HDR_SIZE +
-	    (sizeof(struct dll_sect) * dlthis->allocated_secn_count) +
-	    BYTE_TO_HOST_ROUND(dlthis->debug_string_size + 1);
-	if (dsiz > siz)
-		siz = dsiz;	/* larger of symbols and .dllview temp */
-	sp = (struct local_symbol *)dlthis->mysym->dload_allocate(dlthis->mysym,
-								  siz);
-	if (!sp) {
-		DL_ERROR(err_alloc, siz);
-		return;
-	}
-	dlthis->local_symtab = sp;
-	/* Read the symbols in the input, store them in the table, and post any
-	 * globals to the global symbol table.  In the process, externals
-	 become defined from the global symbol table */
-	checks = dlthis->verify.dv_sym_tab_checksum;
-	symbols_left = sym_count;
-
-	my_sym_buf = kzalloc(sizeof(*my_sym_buf) * MY_SYM_BUF_SIZ, GFP_KERNEL);
-	if (!my_sym_buf)
-		return;
-
-	do {			/* read all symbols */
-		char *sname;
-		u32 val;
-		s32 delta;
-		struct doff_syment_t *input_sym;
-		unsigned syms_in_buf;
-
-		input_sym = my_sym_buf;
-		syms_in_buf = symbols_left > MY_SYM_BUF_SIZ ?
-		    MY_SYM_BUF_SIZ : symbols_left;
-		siz = syms_in_buf * sizeof(struct doff_syment_t);
-		if (dlthis->strm->read_buffer(dlthis->strm, input_sym, siz) !=
-		    siz) {
-			DL_ERROR(readstrm, sym_errid);
-			goto free_sym_buf;
-		}
-		if (dlthis->reorder_map)
-			dload_reorder(input_sym, siz, dlthis->reorder_map);
-
-		checks += dload_checksum(input_sym, siz);
-		do {		/* process symbols in buffer */
-			symbols_left -= 1;
-			/* attempt to derive the name of this symbol */
-			sname = NULL;
-			if (input_sym->dn_offset > 0) {
-#if BITS_PER_AU <= BITS_PER_BYTE
-				if ((u32) input_sym->dn_offset <
-				    dlthis->dfile_hdr.df_strtab_size)
-					sname = dlthis->str_head +
-					    BYTE_TO_HOST(input_sym->dn_offset);
-				else
-					dload_error(dlthis,
-						    "Bad name offset in symbol "
-						    " %d", symbols_left);
-#else
-				sname = unpack_name(dlthis,
-						    input_sym->dn_offset);
-#endif
-			}
-			val = input_sym->dn_value;
-			delta = 0;
-			sp->sclass = input_sym->dn_sclass;
-			sp->secnn = input_sym->dn_scnum;
-			/* if this is an undefined symbol,
-			 * define it (or fail) now */
-			if (sp->secnn == DN_UNDEF) {
-				/* pointless for static undefined */
-				if (input_sym->dn_sclass != DN_EXT)
-					goto loop_cont;
-
-				/* try to define symbol from previously
-				 * loaded images */
-				symp = dlthis->mysym->find_matching_symbol
-				    (dlthis->mysym, sname);
-				if (!symp) {
-					DL_ERROR
-					    ("Undefined external symbol %s",
-					     sname);
-					goto loop_cont;
-				}
-				val = delta = symp->value;
-#ifdef ENABLE_TRAMP_DEBUG
-				dload_syms_error(dlthis->mysym,
-						 "===> ext sym [%s] at %x",
-						 sname, val);
-#endif
-
-				goto loop_cont;
-			}
-			/* symbol defined by this module */
-			if (sp->secnn > 0) {
-				/* symbol references a section */
-				if ((unsigned)sp->secnn <=
-				    dlthis->allocated_secn_count) {
-					/* section was allocated */
-					struct doff_scnhdr_t *srefp =
-					    &dlthis->sect_hdrs[sp->secnn - 1];
-
-					if (input_sym->dn_sclass ==
-					    DN_STATLAB ||
-					    input_sym->dn_sclass == DN_EXTLAB) {
-						/* load */
-						delta = srefp->ds_vaddr;
-					} else {
-						/* run */
-						delta = srefp->ds_paddr;
-					}
-					val += delta;
-				}
-				goto loop_itr;
-			}
-			/* This symbol is an absolute symbol */
-			if (sp->secnn == DN_ABS && ((sp->sclass == DN_EXT) ||
-						    (sp->sclass ==
-						     DN_EXTLAB))) {
-				symp =
-				    dlthis->mysym->find_matching_symbol(dlthis->
-									mysym,
-									sname);
-				if (!symp)
-					goto loop_itr;
-				/* This absolute symbol is already defined. */
-				if (symp->value == input_sym->dn_value) {
-					/* If symbol values are equal, continue
-					 * but don't add to the global symbol
-					 * table */
-					sp->value = val;
-					sp->delta = delta;
-					sp += 1;
-					input_sym += 1;
-					continue;
-				} else {
-					/* If symbol values are not equal,
-					 * return with redefinition error */
-					DL_ERROR("Absolute symbol %s is "
-						 "defined multiple times with "
-						 "different values", sname);
-					goto free_sym_buf;
-				}
-			}
-loop_itr:
-			/* if this is a global symbol, post it to the
-			 * global table */
-			if (input_sym->dn_sclass == DN_EXT ||
-			    input_sym->dn_sclass == DN_EXTLAB) {
-				/* Keep this global symbol for subsequent
-				 * modules. Don't complain on error, to allow
-				 * symbol API to suppress global symbols */
-				if (!sname)
-					goto loop_cont;
-
-				newsym = dlthis->mysym->add_to_symbol_table
-				    (dlthis->mysym, sname,
-				     (unsigned)dlthis->myhandle);
-				if (newsym)
-					newsym->value = val;
-
-			}	/* global */
-loop_cont:
-			sp->value = val;
-			sp->delta = delta;
-			sp += 1;
-			input_sym += 1;
-		} while ((syms_in_buf -= 1) > 0);	/* process sym in buf */
-	} while (symbols_left > 0);	/* read all symbols */
-	if (~checks)
-		dload_error(dlthis, "Checksum of symbols failed");
-
-free_sym_buf:
-	kfree(my_sym_buf);
-	return;
-}				/* dload_symbols */
-
-/*****************************************************************************
- * Procedure symbol_table_free
- *
- * Parameters:
- *	none
- *
- * Effect:
- *	Frees any state used by the symbol table.
- *
- * WARNING:
- *	This routine is not allowed to declare errors!
- **************************************************************************** */
-static void symbol_table_free(struct dload_state *dlthis)
-{
-	if (dlthis->local_symtab) {
-		if (dlthis->dload_errcount) {	/* blow off our symbols */
-			dlthis->mysym->purge_symbol_table(dlthis->mysym,
-							  (unsigned)
-							  dlthis->myhandle);
-		}
-		dlthis->mysym->dload_deallocate(dlthis->mysym,
-						dlthis->local_symtab);
-	}
-}				/* symbol_table_free */
-
-/* .cinit Processing
- *
- * The dynamic loader does .cinit interpretation.  cload_cinit()
- * acts as a special write-to-target function, in that it takes relocated
- * data from the normal data flow, and interprets it as .cinit actions.
- * Because the normal data flow does not  necessarily process the whole
- * .cinit section in one buffer, cload_cinit() must be prepared to
- * interpret the data piecemeal.  A state machine is used for this
- * purpose.
- */
-
-/* The following are only for use by reloc.c and things it calls */
-static const struct ldr_section_info cinit_info_init = { cinitname, 0, 0,
-	(ldr_addr)-1, 0, DLOAD_BSS, 0
-};
-
-/*************************************************************************
- * Procedure cload_cinit
- *
- * Parameters:
- *	ipacket		Pointer to data packet to be loaded
- *
- * Effect:
- *	Interprets the data in the buffer as .cinit data, and performs the
- * appropriate initializations.
- *********************************************************************** */
-static void cload_cinit(struct dload_state *dlthis,
-			struct image_packet_t *ipacket)
-{
-#if TDATA_TO_HOST(CINIT_COUNT)*BITS_PER_AU > 16
-	s32 init_count, left;
-#else
-	s16 init_count, left;
-#endif
-	unsigned char *pktp = ipacket->img_data;
-	unsigned char *pktend = pktp + BYTE_TO_HOST_ROUND(ipacket->packet_size);
-	int temp;
-	ldr_addr atmp;
-	struct ldr_section_info cinit_info;
-
-	/*  PROCESS ALL THE INITIALIZATION RECORDS THE BUFFER. */
-	while (true) {
-		left = pktend - pktp;
-		switch (dlthis->cinit_state) {
-		case CI_COUNT:	/* count field */
-			if (left < TDATA_TO_HOST(CINIT_COUNT))
-				goto loopexit;
-			temp = dload_unpack(dlthis, (tgt_au_t *) pktp,
-					    CINIT_COUNT * TDATA_AU_BITS, 0,
-					    ROP_SGN);
-			pktp += TDATA_TO_HOST(CINIT_COUNT);
-			/* negative signifies BSS table, zero means done */
-			if (temp <= 0) {
-				dlthis->cinit_state = CI_DONE;
-				break;
-			}
-			dlthis->cinit_count = temp;
-			dlthis->cinit_state = CI_ADDRESS;
-			break;
-#if CINIT_ALIGN < CINIT_ADDRESS
-		case CI_PARTADDRESS:
-			pktp -= TDATA_TO_HOST(CINIT_ALIGN);
-			/* back up pointer into space courtesy of caller */
-			*(uint16_t *) pktp = dlthis->cinit_addr;
-			/* stuff in saved bits  !! FALL THRU !! */
-#endif
-		case CI_ADDRESS:	/* Address field for a copy packet */
-			if (left < TDATA_TO_HOST(CINIT_ADDRESS)) {
-#if CINIT_ALIGN < CINIT_ADDRESS
-				if (left == TDATA_TO_HOST(CINIT_ALIGN)) {
-					/* address broken into halves */
-					dlthis->cinit_addr = *(uint16_t *) pktp;
-					/* remember 1st half */
-					dlthis->cinit_state = CI_PARTADDRESS;
-					left = 0;
-				}
-#endif
-				goto loopexit;
-			}
-			atmp = dload_unpack(dlthis, (tgt_au_t *) pktp,
-					    CINIT_ADDRESS * TDATA_AU_BITS, 0,
-					    ROP_UNS);
-			pktp += TDATA_TO_HOST(CINIT_ADDRESS);
-#if CINIT_PAGE_BITS > 0
-			dlthis->cinit_page = atmp &
-			    ((1 << CINIT_PAGE_BITS) - 1);
-			atmp >>= CINIT_PAGE_BITS;
-#else
-			dlthis->cinit_page = CINIT_DEFAULT_PAGE;
-#endif
-			dlthis->cinit_addr = atmp;
-			dlthis->cinit_state = CI_COPY;
-			break;
-		case CI_COPY:	/* copy bits to the target */
-			init_count = HOST_TO_TDATA(left);
-			if (init_count > dlthis->cinit_count)
-				init_count = dlthis->cinit_count;
-			if (init_count == 0)
-				goto loopexit;	/* get more bits */
-			cinit_info = cinit_info_init;
-			cinit_info.page = dlthis->cinit_page;
-			if (!dlthis->myio->writemem(dlthis->myio, pktp,
-						   TDATA_TO_TADDR
-						   (dlthis->cinit_addr),
-						   &cinit_info,
-						   TDATA_TO_HOST(init_count))) {
-				dload_error(dlthis, initfail, "write",
-					    dlthis->cinit_addr);
-			}
-			dlthis->cinit_count -= init_count;
-			if (dlthis->cinit_count <= 0) {
-				dlthis->cinit_state = CI_COUNT;
-				init_count = (init_count + CINIT_ALIGN - 1) &
-				    -CINIT_ALIGN;
-				/* align to next init */
-			}
-			pktp += TDATA_TO_HOST(init_count);
-			dlthis->cinit_addr += init_count;
-			break;
-		case CI_DONE:	/* no more .cinit to do */
-			return;
-		}		/* switch (cinit_state) */
-	}			/* while */
-
-loopexit:
-	if (left > 0) {
-		dload_error(dlthis, "%d bytes left over in cinit packet", left);
-		dlthis->cinit_state = CI_DONE;	/* left over bytes are bad */
-	}
-}				/* cload_cinit */
-
-/*	Functions to interface to reloc.c
- *
- * reloc.c is the relocation module borrowed from the linker, with
- * minimal (we hope) changes for our purposes.  cload_sect_data() invokes
- * this module on a section to relocate and load the image data for that
- * section.  The actual read and write actions are supplied by the global
- * routines below.
- */
-
-/************************************************************************
- * Procedure relocate_packet
- *
- * Parameters:
- *	ipacket		Pointer to an image packet to relocate
- *
- * Effect:
- *	Performs the required relocations on the packet.  Returns a checksum
- * of the relocation operations.
- *********************************************************************** */
-#define MY_RELOC_BUF_SIZ 8
-/* careful! exists at the same time as the image buffer */
-static int relocate_packet(struct dload_state *dlthis,
-			   struct image_packet_t *ipacket,
-			   u32 *checks, bool *tramps_generated)
-{
-	u32 rnum;
-	*tramps_generated = false;
-
-	rnum = ipacket->num_relocs;
-	do {			/* all relocs */
-		unsigned rinbuf;
-		int siz;
-		struct reloc_record_t *rp, rrec[MY_RELOC_BUF_SIZ];
-
-		rp = rrec;
-		rinbuf = rnum > MY_RELOC_BUF_SIZ ? MY_RELOC_BUF_SIZ : rnum;
-		siz = rinbuf * sizeof(struct reloc_record_t);
-		if (dlthis->strm->read_buffer(dlthis->strm, rp, siz) != siz) {
-			DL_ERROR(readstrm, "relocation");
-			return 0;
-		}
-		/* reorder the bytes if need be */
-		if (dlthis->reorder_map)
-			dload_reorder(rp, siz, dlthis->reorder_map);
-
-		*checks += dload_checksum(rp, siz);
-		do {
-			/* perform the relocation operation */
-			dload_relocate(dlthis, (tgt_au_t *) ipacket->img_data,
-				       rp, tramps_generated, false);
-			rp += 1;
-			rnum -= 1;
-		} while ((rinbuf -= 1) > 0);
-	} while (rnum > 0);	/* all relocs */
-	/* If trampoline(s) were generated, we need to do an update of the
-	 * trampoline copy of the packet since a 2nd phase relo will be done
-	 * later. */
-	if (*tramps_generated == true) {
-		dload_tramp_pkt_udpate(dlthis,
-				       (dlthis->image_secn -
-					dlthis->ldr_sections),
-				       dlthis->image_offset, ipacket);
-	}
-
-	return 1;
-}				/* dload_read_reloc */
-
-#define IPH_SIZE (sizeof(struct image_packet_t) - sizeof(u32))
-
-/* VERY dangerous */
-static const char imagepak[] = { "image packet" };
-
-struct img_buffer {
-	struct image_packet_t ipacket;
-	u8 bufr[BYTE_TO_HOST(IMAGE_PACKET_SIZE)];
-};
-
-/*************************************************************************
- * Procedure dload_data
- *
- * Parameters:
- *	none
- *
- * Effect:
- *	Read image data from input file, relocate it, and download it to the
- *	target.
- *********************************************************************** */
-static void dload_data(struct dload_state *dlthis)
-{
-	u16 curr_sect;
-	struct doff_scnhdr_t *sptr = dlthis->sect_hdrs;
-	struct ldr_section_info *lptr = dlthis->ldr_sections;
-	struct img_buffer *ibuf;
-	u8 *dest;
-
-	/* Indicates whether CINIT processing has occurred */
-	bool cinit_processed = false;
-
-	ibuf = kzalloc(sizeof(*ibuf), GFP_KERNEL);
-	if (!ibuf)
-		return;
-
-	/* Loop through the sections and load them one at a time.
-	 */
-	for (curr_sect = 0; curr_sect < dlthis->dfile_hdr.df_no_scns;
-	     curr_sect += 1) {
-		if (ds_needs_download(sptr)) {
-			s32 nip;
-			ldr_addr image_offset = 0;
-			/* set relocation info for this section */
-			if (curr_sect < dlthis->allocated_secn_count)
-				dlthis->delta_runaddr = sptr->ds_paddr;
-			else {
-				lptr = (struct ldr_section_info *)sptr;
-				dlthis->delta_runaddr = 0;
-			}
-			dlthis->image_secn = lptr;
-#if BITS_PER_AU > BITS_PER_BYTE
-			lptr->name = unpack_name(dlthis, sptr->ds_offset);
-#endif
-			nip = sptr->ds_nipacks;
-			while ((nip -= 1) >= 0) {	/* process packets */
-
-				s32 ipsize;
-				u32 checks;
-				bool tramp_generated = false;
-
-				/* get the fixed header bits */
-				if (dlthis->strm->read_buffer(dlthis->strm,
-							      &ibuf->ipacket,
-							      IPH_SIZE) !=
-				    IPH_SIZE) {
-					DL_ERROR(readstrm, imagepak);
-					goto free_ibuf;
-				}
-				/* reorder the header if need be */
-				if (dlthis->reorder_map) {
-					dload_reorder(&ibuf->ipacket, IPH_SIZE,
-						      dlthis->reorder_map);
-				}
-				/* now read the rest of the packet */
-				ipsize =
-				    BYTE_TO_HOST(DOFF_ALIGN
-						 (ibuf->ipacket.packet_size));
-				if (ipsize > BYTE_TO_HOST(IMAGE_PACKET_SIZE)) {
-					DL_ERROR("Bad image packet size %d",
-						 ipsize);
-					goto free_ibuf;
-				}
-				dest = ibuf->bufr;
-				/* End of determination */
-
-				if (dlthis->strm->read_buffer(dlthis->strm,
-							      ibuf->bufr,
-							      ipsize) !=
-				    ipsize) {
-					DL_ERROR(readstrm, imagepak);
-					goto free_ibuf;
-				}
-				ibuf->ipacket.img_data = dest;
-
-				/* reorder the bytes if need be */
-#if !defined(_BIG_ENDIAN) || (TARGET_AU_BITS > 16)
-				if (dlthis->reorder_map) {
-					dload_reorder(dest, ipsize,
-						      dlthis->reorder_map);
-				}
-				checks = dload_checksum(dest, ipsize);
-#else
-				if (dlthis->dfile_hdr.df_byte_reshuffle !=
-				    TARGET_ORDER(REORDER_MAP
-						 (BYTE_RESHUFFLE_VALUE))) {
-					/* put image bytes in big-endian order,
-					 * not PC order */
-					dload_reorder(dest, ipsize,
-						      TARGET_ORDER
-						      (dlthis->dfile_hdr.
-						       df_byte_reshuffle));
-				}
-#if TARGET_AU_BITS > 8
-				checks = dload_reverse_checksum16(dest, ipsize);
-#else
-				checks = dload_reverse_checksum(dest, ipsize);
-#endif
-#endif
-
-				checks += dload_checksum(&ibuf->ipacket,
-							 IPH_SIZE);
-				/* relocate the image bits as needed */
-				if (ibuf->ipacket.num_relocs) {
-					dlthis->image_offset = image_offset;
-					if (!relocate_packet(dlthis,
-							     &ibuf->ipacket,
-							     &checks,
-							     &tramp_generated))
-						goto free_ibuf;	/* error */
-				}
-				if (~checks)
-					DL_ERROR(err_checksum, imagepak);
-				/* Only write the result to the target if no
-				 * trampoline was generated.  Otherwise it
-				 *will be done during trampoline finalize. */
-
-				if (tramp_generated == false) {
-
-					/* stuff the result into target
-					 * memory */
-					if (dload_check_type(sptr,
-						DLOAD_CINIT)) {
-						cload_cinit(dlthis,
-							    &ibuf->ipacket);
-						cinit_processed = true;
-					} else {
-						/* FIXME */
-						if (!dlthis->myio->
-						    writemem(dlthis->
-							myio,
-							ibuf->bufr,
-							lptr->
-							load_addr +
-							image_offset,
-							lptr,
-							BYTE_TO_HOST
-							(ibuf->
-							ipacket.
-							packet_size))) {
-							DL_ERROR
-							  ("Write to "
-							  FMT_UI32
-							  " failed",
-							  lptr->
-							  load_addr +
-							  image_offset);
-						}
-					}
-				}
-				image_offset +=
-				    BYTE_TO_TADDR(ibuf->ipacket.packet_size);
-			}	/* process packets */
-			/* if this is a BSS section, we may want to fill it */
-			if (!dload_check_type(sptr, DLOAD_BSS))
-				goto loop_cont;
-
-			if (!(dlthis->myoptions & DLOAD_INITBSS))
-				goto loop_cont;
-
-			if (cinit_processed) {
-				/* Don't clear BSS after load-time
-				 * initialization */
-				DL_ERROR
-				    ("Zero-initialization at " FMT_UI32
-				     " after " "load-time initialization!",
-				     lptr->load_addr);
-				goto loop_cont;
-			}
-			/* fill the .bss area */
-			dlthis->myio->fillmem(dlthis->myio,
-					      TADDR_TO_HOST(lptr->load_addr),
-					      lptr, TADDR_TO_HOST(lptr->size),
-					      DLOAD_FILL_BSS);
-			goto loop_cont;
-		}
-		/* if DS_DOWNLOAD_MASK */
-		/* If not loading, but BSS, zero initialize */
-		if (!dload_check_type(sptr, DLOAD_BSS))
-			goto loop_cont;
-
-		if (!(dlthis->myoptions & DLOAD_INITBSS))
-			goto loop_cont;
-
-		if (curr_sect >= dlthis->allocated_secn_count)
-			lptr = (struct ldr_section_info *)sptr;
-
-		if (cinit_processed) {
-			/*Don't clear BSS after load-time initialization */
-			DL_ERROR("Zero-initialization at " FMT_UI32
-				 " attempted after "
-				 "load-time initialization!", lptr->load_addr);
-			goto loop_cont;
-		}
-		/* fill the .bss area */
-		dlthis->myio->fillmem(dlthis->myio,
-				      TADDR_TO_HOST(lptr->load_addr), lptr,
-				      TADDR_TO_HOST(lptr->size),
-				      DLOAD_FILL_BSS);
-loop_cont:
-		sptr += 1;
-		lptr += 1;
-	}			/* load sections */
-
-	/*  Finalize any trampolines that were created during the load */
-	if (dload_tramp_finalize(dlthis) == 0) {
-		DL_ERROR("Finalization of auto-trampolines (size = " FMT_UI32
-			 ") failed", dlthis->tramp.tramp_sect_next_addr);
-	}
-free_ibuf:
-	kfree(ibuf);
-	return;
-}				/* dload_data */
-
-/*************************************************************************
- * Procedure dload_reorder
- *
- * Parameters:
- *	data	32-bit aligned pointer to data to be byte-swapped
- *	dsiz	size of the data to be reordered in sizeof() units.
- *	map		32-bit map defining how to reorder the data.  Value
- *			must be REORDER_MAP() of some permutation
- *			of 0x00 01 02 03
- *
- * Effect:
- *	Re-arranges the bytes in each word according to the map specified.
- *
- *********************************************************************** */
-/* mask for byte shift count */
-#define SHIFT_COUNT_MASK (3 << LOG_BITS_PER_BYTE)
-
-void dload_reorder(void *data, int dsiz, unsigned int map)
-{
-	register u32 tmp, tmap, datv;
-	u32 *dp = (u32 *) data;
-
-	map <<= LOG_BITS_PER_BYTE;	/* align map with SHIFT_COUNT_MASK */
-	do {
-		tmp = 0;
-		datv = *dp;
-		tmap = map;
-		do {
-			tmp |= (datv & BYTE_MASK) << (tmap & SHIFT_COUNT_MASK);
-			tmap >>= BITS_PER_BYTE;
-		} while (datv >>= BITS_PER_BYTE);
-		*dp++ = tmp;
-	} while ((dsiz -= sizeof(u32)) > 0);
-}				/* dload_reorder */
-
-/*************************************************************************
- * Procedure dload_checksum
- *
- * Parameters:
- *	data	32-bit aligned pointer to data to be checksummed
- *	siz		size of the data to be checksummed in sizeof() units.
- *
- * Effect:
- *	Returns a checksum of the specified block
- *
- *********************************************************************** */
-u32 dload_checksum(void *data, unsigned siz)
-{
-	u32 sum;
-	u32 *dp;
-	int left;
-
-	sum = 0;
-	dp = (u32 *) data;
-	for (left = siz; left > 0; left -= sizeof(u32))
-		sum += *dp++;
-	return sum;
-}				/* dload_checksum */
-
-#if HOST_ENDIANNESS
-/*************************************************************************
- * Procedure dload_reverse_checksum
- *
- * Parameters:
- *	data	32-bit aligned pointer to data to be checksummed
- *	siz		size of the data to be checksummed in sizeof() units.
- *
- * Effect:
- *	Returns a checksum of the specified block, which is assumed to be bytes
- * in big-endian order.
- *
- * Notes:
- *	In a big-endian host, things like the string table are stored as bytes
- * in host order. But dllcreate always checksums in little-endian order.
- * It is most efficient to just handle the difference a word at a time.
- *
- ********************************************************************** */
-u32 dload_reverse_checksum(void *data, unsigned siz)
-{
-	u32 sum, temp;
-	u32 *dp;
-	int left;
-
-	sum = 0;
-	dp = (u32 *) data;
-
-	for (left = siz; left > 0; left -= sizeof(u32)) {
-		temp = *dp++;
-		sum += temp << BITS_PER_BYTE * 3;
-		sum += temp >> BITS_PER_BYTE * 3;
-		sum += (temp >> BITS_PER_BYTE) & (BYTE_MASK << BITS_PER_BYTE);
-		sum += (temp & (BYTE_MASK << BITS_PER_BYTE)) << BITS_PER_BYTE;
-	}
-
-	return sum;
-}				/* dload_reverse_checksum */
-
-#if (TARGET_AU_BITS > 8) && (TARGET_AU_BITS < 32)
-u32 dload_reverse_checksum16(void *data, unsigned siz)
-{
-	uint_fast32_t sum, temp;
-	u32 *dp;
-	int left;
-
-	sum = 0;
-	dp = (u32 *) data;
-
-	for (left = siz; left > 0; left -= sizeof(u32)) {
-		temp = *dp++;
-		sum += temp << BITS_PER_BYTE * 2;
-		sum += temp >> BITS_PER_BYTE * 2;
-	}
-
-	return sum;
-}				/* dload_reverse_checksum16 */
-#endif
-#endif
-
-/*************************************************************************
- * Procedure swap_words
- *
- * Parameters:
- *	data	32-bit aligned pointer to data to be swapped
- *	siz	size of the data to be swapped.
- *	bitmap	Bit map of how to swap each 32-bit word; 1 => 2 shorts,
- *		0 => 1 long
- *
- * Effect:
- *	Swaps the specified data according to the specified map
- *
- *********************************************************************** */
-static void swap_words(void *data, unsigned siz, unsigned bitmap)
-{
-	register int i;
-#if TARGET_AU_BITS < 16
-	register u16 *sp;
-#endif
-	register u32 *lp;
-
-	siz /= sizeof(u16);
-
-#if TARGET_AU_BITS < 16
-	/* pass 1: do all the bytes */
-	i = siz;
-	sp = (u16 *) data;
-	do {
-		register u16 tmp;
-
-		tmp = *sp;
-		*sp++ = SWAP16BY8(tmp);
-	} while ((i -= 1) > 0);
-#endif
-
-#if TARGET_AU_BITS < 32
-	/* pass 2: fixup the 32-bit words */
-	i = siz >> 1;
-	lp = (u32 *) data;
-	do {
-		if ((bitmap & 1) == 0) {
-			register u32 tmp;
-			tmp = *lp;
-			*lp = SWAP32BY16(tmp);
-		}
-		lp += 1;
-		bitmap >>= 1;
-	} while ((i -= 1) > 0);
-#endif
-}				/* swap_words */
-
-/*************************************************************************
- * Procedure copy_tgt_strings
- *
- * Parameters:
- *	dstp		Destination address.  Assumed to be 32-bit aligned
- *	srcp		Source address.  Assumed to be 32-bit aligned
- *	charcount	Number of characters to copy.
- *
- * Effect:
- *	Copies strings from the source (which is in usual .dof file order on
- * the loading processor) to the destination buffer (which should be in proper
- * target addressable unit order).  Makes sure the last string in the
- * buffer is NULL terminated (for safety).
- * Returns the first unused destination address.
- *********************************************************************** */
-static char *copy_tgt_strings(void *dstp, void *srcp, unsigned charcount)
-{
-	register tgt_au_t *src = (tgt_au_t *) srcp;
-	register tgt_au_t *dst = (tgt_au_t *) dstp;
-	register int cnt = charcount;
-
-	do {
-#if TARGET_AU_BITS <= BITS_PER_AU
-		/* byte-swapping issues may exist for strings on target */
-		*dst++ = *src++;
-#else
-		*dst++ = *src++;
-#endif
-	} while ((cnt -= (sizeof(tgt_au_t) * BITS_PER_AU / BITS_PER_BYTE)) > 0);
-	/*apply force to make sure that the string table has null terminator */
-#if (BITS_PER_AU == BITS_PER_BYTE) && (TARGET_AU_BITS == BITS_PER_BYTE)
-	dst[-1] = 0;
-#else
-	/* little endian */
-	dst[-1] &= (1 << (BITS_PER_AU - BITS_PER_BYTE)) - 1;
-#endif
-	return (char *)dst;
-}				/* copy_tgt_strings */
-
-/*************************************************************************
- * Procedure init_module_handle
- *
- * Parameters:
- *	none
- *
- * Effect:
- *	Initializes the module handle we use to enable unloading, and installs
- * the debug information required by the target.
- *
- * Notes:
- * The handle returned from dynamic_load_module needs to encapsulate all the
- * allocations done for the module, and enable them plus the modules symbols to
- * be deallocated.
- *
- *********************************************************************** */
-#ifndef _BIG_ENDIAN
-static const struct ldr_section_info dllview_info_init = { ".dllview", 0, 0,
-	(ldr_addr)-1, DBG_LIST_PAGE, DLOAD_DATA, 0
-};
-#else
-static const struct ldr_section_info dllview_info_init = { ".dllview", 0, 0,
-	(ldr_addr)-1, DLOAD_DATA, DBG_LIST_PAGE, 0
-};
-#endif
-static void init_module_handle(struct dload_state *dlthis)
-{
-	struct my_handle *hndl;
-	u16 curr_sect;
-	struct ldr_section_info *asecs;
-	struct dll_module *dbmod;
-	struct dll_sect *dbsec;
-	struct dbg_mirror_root *mlist;
-	register char *cp;
-	struct modules_header mhdr;
-	struct ldr_section_info dllview_info;
-	struct dynload_symbol *debug_mirror_sym;
-
-	hndl = dlthis->myhandle;
-	if (!hndl)
-		return;		/* must be errors detected, so forget it */
-
-	/*  Store the section count */
-	hndl->secn_count = dlthis->allocated_secn_count;
-
-	/*  If a trampoline section was created, add it in */
-	if (dlthis->tramp.tramp_sect_next_addr != 0)
-		hndl->secn_count += 1;
-
-	hndl->secn_count = hndl->secn_count << 1;
-
-	hndl->secn_count = dlthis->allocated_secn_count << 1;
-#ifndef TARGET_ENDIANNESS
-	if (dlthis->big_e_target)
-		hndl->secn_count += 1;	/* flag for big-endian */
-#endif
-	if (dlthis->dload_errcount)
-		return;		/* abandon if errors detected */
-	/* Locate the symbol that names the header for the CCS debug list
-	   of modules. If not found, we just don't generate the debug record.
-	   If found, we create our modules list.  We make sure to create the
-	   loader_dllview_root even if there is no relocation info to record,
-	   just to try to put both symbols in the same symbol table and
-	   module. */
-	debug_mirror_sym = dlthis->mysym->find_matching_symbol(dlthis->mysym,
-							loader_dllview_root);
-	if (!debug_mirror_sym) {
-		struct dynload_symbol *dlmodsym;
-		struct dbg_mirror_root *mlst;
-
-		/* our root symbol is not yet present;
-		   check if we have DLModules defined */
-		dlmodsym = dlthis->mysym->find_matching_symbol(dlthis->mysym,
-							LINKER_MODULES_HEADER);
-		if (!dlmodsym)
-			return;	/* no DLModules list so no debug info */
-		/* if we have DLModules defined, construct our header */
-		mlst = (struct dbg_mirror_root *)
-		    dlthis->mysym->dload_allocate(dlthis->mysym,
-						  sizeof(struct
-							 dbg_mirror_root));
-		if (!mlst) {
-			DL_ERROR(err_alloc, sizeof(struct dbg_mirror_root));
-			return;
-		}
-		mlst->next = NULL;
-		mlst->changes = 0;
-		mlst->refcount = 0;
-		mlst->dbthis = TDATA_TO_TADDR(dlmodsym->value);
-		/* add our root symbol */
-		debug_mirror_sym = dlthis->mysym->add_to_symbol_table
-		    (dlthis->mysym, loader_dllview_root,
-		     (unsigned)dlthis->myhandle);
-		if (!debug_mirror_sym) {
-			/* failed, recover memory */
-			dlthis->mysym->dload_deallocate(dlthis->mysym, mlst);
-			return;
-		}
-		debug_mirror_sym->value = (u32) mlst;
-	}
-	/* First create the DLLview record and stuff it into the buffer.
-	   Then write it to the DSP.  Record pertinent locations in our hndl,
-	   and add it to the per-processor list of handles with debug info. */
-#ifndef DEBUG_HEADER_IN_LOADER
-	mlist = (struct dbg_mirror_root *)debug_mirror_sym->value;
-	if (!mlist)
-		return;
-#else
-	mlist = (struct dbg_mirror_root *)&debug_list_header;
-#endif
-	hndl->dm.root = mlist;	/* set pointer to root into our handle */
-	if (!dlthis->allocated_secn_count)
-		return;		/* no load addresses to be recorded */
-	/* reuse temporary symbol storage */
-	dbmod = (struct dll_module *)dlthis->local_symtab;
-	/* Create the DLLview record in the memory we retain for our handle */
-	dbmod->num_sects = dlthis->allocated_secn_count;
-	dbmod->timestamp = dlthis->verify.dv_timdat;
-	dbmod->version = INIT_VERSION;
-	dbmod->verification = VERIFICATION;
-	asecs = dlthis->ldr_sections;
-	dbsec = dbmod->sects;
-	for (curr_sect = dlthis->allocated_secn_count;
-	     curr_sect > 0; curr_sect -= 1) {
-		dbsec->sect_load_adr = asecs->load_addr;
-		dbsec->sect_run_adr = asecs->run_addr;
-		dbsec += 1;
-		asecs += 1;
-	}
-
-	/*  If a trampoline section was created go ahead and add its info */
-	if (dlthis->tramp.tramp_sect_next_addr != 0) {
-		dbmod->num_sects++;
-		dbsec->sect_load_adr = asecs->load_addr;
-		dbsec->sect_run_adr = asecs->run_addr;
-		dbsec++;
-		asecs++;
-	}
-
-	/* now cram in the names */
-	cp = copy_tgt_strings(dbsec, dlthis->str_head,
-			      dlthis->debug_string_size);
-
-	/* If a trampoline section was created, add its name so DLLView
-	 * can show the user the section info. */
-	if (dlthis->tramp.tramp_sect_next_addr != 0) {
-		cp = copy_tgt_strings(cp,
-				      dlthis->tramp.final_string_table,
-				      strlen(dlthis->tramp.final_string_table) +
-				      1);
-	}
-
-	/* round off the size of the debug record, and remember same */
-	hndl->dm.dbsiz = HOST_TO_TDATA_ROUND(cp - (char *)dbmod);
-	*cp = 0;		/* strictly to make our test harness happy */
-	dllview_info = dllview_info_init;
-	dllview_info.size = TDATA_TO_TADDR(hndl->dm.dbsiz);
-	/* Initialize memory context to default heap */
-	dllview_info.context = 0;
-	hndl->dm.context = 0;
-	/* fill in next pointer and size */
-	if (mlist->next) {
-		dbmod->next_module = TADDR_TO_TDATA(mlist->next->dm.dbthis);
-		dbmod->next_module_size = mlist->next->dm.dbsiz;
-	} else {
-		dbmod->next_module_size = 0;
-		dbmod->next_module = 0;
-	}
-	/* allocate memory for on-DSP DLLview debug record */
-	if (!dlthis->myalloc)
-		return;
-	if (!dlthis->myalloc->dload_allocate(dlthis->myalloc, &dllview_info,
-					     HOST_TO_TADDR(sizeof(u32)))) {
-		return;
-	}
-	/* Store load address of .dllview section */
-	hndl->dm.dbthis = dllview_info.load_addr;
-	/* Store memory context (segid) in which .dllview section
-	 * was  allocated */
-	hndl->dm.context = dllview_info.context;
-	mlist->refcount += 1;
-	/* swap bytes in the entire debug record, but not the string table */
-	if (TARGET_ENDIANNESS_DIFFERS(TARGET_BIG_ENDIAN)) {
-		swap_words(dbmod, (char *)dbsec - (char *)dbmod,
-			   DLL_MODULE_BITMAP);
-	}
-	/* Update the DLLview list on the DSP write new record */
-	if (!dlthis->myio->writemem(dlthis->myio, dbmod,
-				    dllview_info.load_addr, &dllview_info,
-				    TADDR_TO_HOST(dllview_info.size))) {
-		return;
-	}
-	/* write new header */
-	mhdr.first_module_size = hndl->dm.dbsiz;
-	mhdr.first_module = TADDR_TO_TDATA(dllview_info.load_addr);
-	/* swap bytes in the module header, if needed */
-	if (TARGET_ENDIANNESS_DIFFERS(TARGET_BIG_ENDIAN)) {
-		swap_words(&mhdr, sizeof(struct modules_header) - sizeof(u16),
-			   MODULES_HEADER_BITMAP);
-	}
-	dllview_info = dllview_info_init;
-	if (!dlthis->myio->writemem(dlthis->myio, &mhdr, mlist->dbthis,
-				    &dllview_info,
-				    sizeof(struct modules_header) -
-				    sizeof(u16))) {
-		return;
-	}
-	/* Add the module handle to this processor's list
-	   of handles with debug info */
-	hndl->dm.next = mlist->next;
-	if (hndl->dm.next)
-		hndl->dm.next->dm.prev = hndl;
-	hndl->dm.prev = (struct my_handle *)mlist;
-	mlist->next = hndl;	/* insert after root */
-}				/* init_module_handle */
-
-/*************************************************************************
- * Procedure dynamic_unload_module
- *
- * Parameters:
- *	mhandle	A module handle from dynamic_load_module
- *	syms	Host-side symbol table and malloc/free functions
- *	alloc	Target-side memory allocation
- *
- * Effect:
- *	The module specified by mhandle is unloaded.  Unloading causes all
- * target memory to be deallocated, all symbols defined by the module to
- * be purged, and any host-side storage used by the dynamic loader for
- * this module to be released.
- *
- * Returns:
- *	Zero for success. On error, the number of errors detected is returned.
- * Individual errors are reported using syms->error_report().
- *********************************************************************** */
-int dynamic_unload_module(void *mhandle,
-			  struct dynamic_loader_sym *syms,
-			  struct dynamic_loader_allocate *alloc,
-			  struct dynamic_loader_initialize *init)
-{
-	s16 curr_sect;
-	struct ldr_section_info *asecs;
-	struct my_handle *hndl;
-	struct dbg_mirror_root *root;
-	unsigned errcount = 0;
-	struct ldr_section_info dllview_info = dllview_info_init;
-	struct modules_header mhdr;
-
-	hndl = (struct my_handle *)mhandle;
-	if (!hndl)
-		return 0;	/* if handle is null, nothing to do */
-	/* Clear out the module symbols
-	 * Note that if this is the module that defined MODULES_HEADER
-	 (the head of the target debug list)
-	 * then this operation will blow away that symbol.
-	 It will therefore be impossible for subsequent
-	 * operations to add entries to this un-referenceable list. */
-	if (!syms)
-		return 1;
-	syms->purge_symbol_table(syms, (unsigned)hndl);
-	/* Deallocate target memory for sections
-	 * NOTE: The trampoline section, if created, gets deleted here, too */
-
-	asecs = hndl->secns;
-	if (alloc)
-		for (curr_sect = (hndl->secn_count >> 1); curr_sect > 0;
-		     curr_sect -= 1) {
-			asecs->name = NULL;
-			alloc->dload_deallocate(alloc, asecs++);
-		}
-	root = hndl->dm.root;
-	if (!root) {
-		/* there is a debug list containing this module */
-		goto func_end;
-	}
-	if (!hndl->dm.dbthis) {	/* target-side dllview record exists */
-		goto loop_end;
-	}
-	/* Retrieve memory context in which .dllview was allocated */
-	dllview_info.context = hndl->dm.context;
-	if (hndl->dm.prev == hndl)
-		goto exitunltgt;
-
-	/* target-side dllview record is in list */
-	/* dequeue this record from our GPP-side mirror list */
-	hndl->dm.prev->dm.next = hndl->dm.next;
-	if (hndl->dm.next)
-		hndl->dm.next->dm.prev = hndl->dm.prev;
-	/* Update next_module of previous entry in target list
-	 * We are using mhdr here as a surrogate for either a
-	 struct modules_header or a dll_module */
-	if (hndl->dm.next) {
-		mhdr.first_module = TADDR_TO_TDATA(hndl->dm.next->dm.dbthis);
-		mhdr.first_module_size = hndl->dm.next->dm.dbsiz;
-	} else {
-		mhdr.first_module = 0;
-		mhdr.first_module_size = 0;
-	}
-	if (!init)
-		goto exitunltgt;
-
-	if (!init->connect(init)) {
-		dload_syms_error(syms, iconnect);
-		errcount += 1;
-		goto exitunltgt;
-	}
-	/* swap bytes in the module header, if needed */
-	if (TARGET_ENDIANNESS_DIFFERS(hndl->secn_count & 0x1)) {
-		swap_words(&mhdr, sizeof(struct modules_header) - sizeof(u16),
-			   MODULES_HEADER_BITMAP);
-	}
-	if (!init->writemem(init, &mhdr, hndl->dm.prev->dm.dbthis,
-			    &dllview_info, sizeof(struct modules_header) -
-			    sizeof(mhdr.update_flag))) {
-		dload_syms_error(syms, dlvwrite);
-		errcount += 1;
-	}
-	/* update change counter */
-	root->changes += 1;
-	if (!init->writemem(init, &(root->changes),
-			    root->dbthis + HOST_TO_TADDR
-			    (sizeof(mhdr.first_module) +
-			     sizeof(mhdr.first_module_size)),
-			    &dllview_info, sizeof(mhdr.update_flag))) {
-		dload_syms_error(syms, dlvwrite);
-		errcount += 1;
-	}
-	init->release(init);
-exitunltgt:
-	/* release target storage */
-	dllview_info.size = TDATA_TO_TADDR(hndl->dm.dbsiz);
-	dllview_info.load_addr = hndl->dm.dbthis;
-	if (alloc)
-		alloc->dload_deallocate(alloc, &dllview_info);
-	root->refcount -= 1;
-	/* target-side dllview record exists */
-loop_end:
-#ifndef DEBUG_HEADER_IN_LOADER
-	if (root->refcount <= 0) {
-		/* if all references gone, blow off the header */
-		/* our root symbol may be gone due to the Purge above,
-		   but if not, do not destroy the root */
-		if (syms->find_matching_symbol
-		    (syms, loader_dllview_root) == NULL)
-			syms->dload_deallocate(syms, root);
-	}
-#endif
-func_end:
-	/* there is a debug list containing this module */
-	syms->dload_deallocate(syms, mhandle);	/* release our storage */
-	return errcount;
-}				/* dynamic_unload_module */
-
-#if BITS_PER_AU > BITS_PER_BYTE
-/*************************************************************************
- * Procedure unpack_name
- *
- * Parameters:
- *	soffset	Byte offset into the string table
- *
- * Effect:
- *	Returns a pointer to the string specified by the offset supplied, or
- * NULL for error.
- *
- *********************************************************************** */
-static char *unpack_name(struct dload_state *dlthis, u32 soffset)
-{
-	u8 tmp, *src;
-	char *dst;
-
-	if (soffset >= dlthis->dfile_hdr.df_strtab_size) {
-		dload_error(dlthis, "Bad string table offset " FMT_UI32,
-			    soffset);
-		return NULL;
-	}
-	src = (uint_least8_t *) dlthis->str_head +
-	    (soffset >> (LOG_BITS_PER_AU - LOG_BITS_PER_BYTE));
-	dst = dlthis->str_temp;
-	if (soffset & 1)
-		*dst++ = *src++;	/* only 1 character in first word */
-	do {
-		tmp = *src++;
-		*dst = (tmp >> BITS_PER_BYTE);
-		if (!(*dst++))
-			break;
-	} while ((*dst++ = tmp & BYTE_MASK));
-	dlthis->temp_len = dst - dlthis->str_temp;
-	/* squirrel away length including terminating null */
-	return dlthis->str_temp;
-}				/* unpack_name */
-#endif
diff --git a/drivers/staging/tidspbridge/dynload/dload_internal.h b/drivers/staging/tidspbridge/dynload/dload_internal.h
deleted file mode 100644
index b9d079b..0000000
--- a/drivers/staging/tidspbridge/dynload/dload_internal.h
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * dload_internal.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _DLOAD_INTERNAL_
-#define _DLOAD_INTERNAL_
-
-#include <linux/types.h>
-
-/*
- * Internal state definitions for the dynamic loader
- */
-
-/* type used for relocation intermediate results */
-typedef s32 rvalue;
-
-/* unsigned version of same; must have at least as many bits */
-typedef u32 urvalue;
-
-/*
- * Dynamic loader configuration constants
- */
-/* error issued if input has more sections than this limit */
-#define REASONABLE_SECTION_LIMIT 100
-
-/* (Addressable unit) value used to clear BSS section */
-#define DLOAD_FILL_BSS 0
-
-/*
- * Reorder maps explained (?)
- *
- * The doff file format defines a 32-bit pattern used to determine the
- * byte order of an image being read.  That value is
- * BYTE_RESHUFFLE_VALUE == 0x00010203
- * For purposes of the reorder routine, we would rather have the all-is-OK
- * for 32-bits pattern be 0x03020100.  This first macro makes the
- * translation from doff file header value to MAP value: */
-#define REORDER_MAP(rawmap) ((rawmap) ^ 0x3030303)
-/* This translation is made in dload_headers.  Thereafter, the all-is-OK
- * value for the maps stored in dlthis is REORDER_MAP(BYTE_RESHUFFLE_VALUE).
- * But sadly, not all bits of the doff file are 32-bit integers.
- * The notable exceptions are strings and image bits.
- * Strings obey host byte order: */
-#if defined(_BIG_ENDIAN)
-#define HOST_BYTE_ORDER(cookedmap) ((cookedmap) ^ 0x3030303)
-#else
-#define HOST_BYTE_ORDER(cookedmap) (cookedmap)
-#endif
-/* Target bits consist of target AUs (could be bytes, or 16-bits,
- * or 32-bits) stored as an array in host order.  A target order
- * map is defined by: */
-#if !defined(_BIG_ENDIAN) || TARGET_AU_BITS > 16
-#define TARGET_ORDER(cookedmap) (cookedmap)
-#elif TARGET_AU_BITS > 8
-#define TARGET_ORDER(cookedmap) ((cookedmap) ^ 0x2020202)
-#else
-#define TARGET_ORDER(cookedmap) ((cookedmap) ^ 0x3030303)
-#endif
-
-/* forward declaration for handle returned by dynamic loader */
-struct my_handle;
-
-/*
- * a list of module handles, which mirrors the debug list on the target
- */
-struct dbg_mirror_root {
-	/* must be same as dbg_mirror_list; __DLModules address on target */
-	u32 dbthis;
-	struct my_handle *next;	/* must be same as dbg_mirror_list */
-	u16 changes;		/* change counter */
-	u16 refcount;		/* number of modules referencing this root */
-};
-
-struct dbg_mirror_list {
-	u32 dbthis;
-	struct my_handle *next, *prev;
-	struct dbg_mirror_root *root;
-	u16 dbsiz;
-	u32 context;	/* Save context for .dllview memory allocation */
-};
-
-#define VARIABLE_SIZE 1
-/*
- * the structure we actually return as an opaque module handle
- */
-struct my_handle {
-	struct dbg_mirror_list dm;	/* !!! must be first !!! */
-	/* sections following << 1, LSB is set for big-endian target */
-	u16 secn_count;
-	struct ldr_section_info secns[VARIABLE_SIZE];
-};
-#define MY_HANDLE_SIZE (sizeof(struct my_handle) -\
-			sizeof(struct ldr_section_info))
-/* real size of my_handle */
-
-/*
- * reduced symbol structure used for symbols during relocation
- */
-struct local_symbol {
-	s32 value;		/* Relocated symbol value */
-	s32 delta;		/* Original value in input file */
-	s16 secnn;		/* section number */
-	s16 sclass;		/* symbol class */
-};
-
-/*
- * Trampoline data structures
- */
-#define TRAMP_NO_GEN_AVAIL              65535
-#define TRAMP_SYM_PREFIX                "__$dbTR__"
-#define TRAMP_SECT_NAME                 ".dbTR"
-/* MUST MATCH THE LENGTH ABOVE!! */
-#define TRAMP_SYM_PREFIX_LEN            9
-/* Includes NULL termination */
-#define TRAMP_SYM_HEX_ASCII_LEN         9
-
-#define GET_CONTAINER(ptr, type, field) ((type *)((unsigned long)ptr -\
-				(unsigned long)(&((type *)0)->field)))
-#ifndef FIELD_OFFSET
-#define FIELD_OFFSET(type, field)       ((unsigned long)(&((type *)0)->field))
-#endif
-
-/*
-    The trampoline code for the target is located in a table called
-    "tramp_gen_info" with is indexed by looking up the index in the table
-    "tramp_map".  The tramp_map index is acquired using the target
-    HASH_FUNC on the relocation type that caused the trampoline.  Each
-    trampoline code table entry MUST follow this format:
-
-    |----------------------------------------------|
-    |  tramp_gen_code_hdr                          |
-    |----------------------------------------------|
-    |  Trampoline image code                       |
-    |  (the raw instruction code for the target)   |
-    |----------------------------------------------|
-    |  Relocation entries for the image code       |
-    |----------------------------------------------|
-
-    This is very similar to how image data is laid out in the DOFF file
-    itself.
- */
-struct tramp_gen_code_hdr {
-	u32 tramp_code_size;	/*  in BYTES */
-	u32 num_relos;
-	u32 relo_offset;	/*  in BYTES */
-};
-
-struct tramp_img_pkt {
-	struct tramp_img_pkt *next;	/*  MUST BE FIRST */
-	u32 base;
-	struct tramp_gen_code_hdr hdr;
-	u8 payload[VARIABLE_SIZE];
-};
-
-struct tramp_img_dup_relo {
-	struct tramp_img_dup_relo *next;
-	struct reloc_record_t relo;
-};
-
-struct tramp_img_dup_pkt {
-	struct tramp_img_dup_pkt *next;	/*  MUST BE FIRST */
-	s16 secnn;
-	u32 offset;
-	struct image_packet_t img_pkt;
-	struct tramp_img_dup_relo *relo_chain;
-
-	/*  PAYLOAD OF IMG PKT FOLLOWS */
-};
-
-struct tramp_sym {
-	struct tramp_sym *next;	/*  MUST BE FIRST */
-	u32 index;
-	u32 str_index;
-	struct local_symbol sym_info;
-};
-
-struct tramp_string {
-	struct tramp_string *next;	/*  MUST BE FIRST */
-	u32 index;
-	char str[VARIABLE_SIZE];	/*  NULL terminated */
-};
-
-struct tramp_info {
-	u32 tramp_sect_next_addr;
-	struct ldr_section_info sect_info;
-
-	struct tramp_sym *symbol_head;
-	struct tramp_sym *symbol_tail;
-	u32 tramp_sym_next_index;
-	struct local_symbol *final_sym_table;
-
-	struct tramp_string *string_head;
-	struct tramp_string *string_tail;
-	u32 tramp_string_next_index;
-	u32 tramp_string_size;
-	char *final_string_table;
-
-	struct tramp_img_pkt *tramp_pkts;
-	struct tramp_img_dup_pkt *dup_pkts;
-};
-
-/*
- * States of the .cinit state machine
- */
-enum cinit_mode {
-	CI_COUNT = 0,		/* expecting a count */
-	CI_ADDRESS,		/* expecting an address */
-#if CINIT_ALIGN < CINIT_ADDRESS	/* handle case of partial address field */
-	CI_PARTADDRESS,		/* have only part of the address */
-#endif
-	CI_COPY,		/* in the middle of copying data */
-	CI_DONE			/* end of .cinit table */
-};
-
-/*
- * The internal state of the dynamic loader, which is passed around as
- * an object
- */
-struct dload_state {
-	struct dynamic_loader_stream *strm;	/* The module input stream */
-	struct dynamic_loader_sym *mysym;	/* Symbols for this session */
-	/* target memory allocator */
-	struct dynamic_loader_allocate *myalloc;
-	struct dynamic_loader_initialize *myio;	/* target memory initializer */
-	unsigned myoptions;	/* Options parameter dynamic_load_module */
-
-	char *str_head;		/* Pointer to string table */
-#if BITS_PER_AU > BITS_PER_BYTE
-	char *str_temp;		/* Pointer to temporary buffer for strings */
-	/* big enough to hold longest string */
-	unsigned temp_len;	/* length of last temporary string */
-	char *xstrings;		/* Pointer to buffer for expanded */
-	/* strings for sec names */
-#endif
-	/* Total size of strings for DLLView section names */
-	unsigned debug_string_size;
-	/* Pointer to parallel section info for allocated sections only */
-	struct doff_scnhdr_t *sect_hdrs;	/* Pointer to section table */
-	struct ldr_section_info *ldr_sections;
-#if TMS32060
-	/* The address of the start of the .bss section */
-	ldr_addr bss_run_base;
-#endif
-	struct local_symbol *local_symtab;	/* Relocation symbol table */
-
-	/* pointer to DL section info for the section being relocated */
-	struct ldr_section_info *image_secn;
-	/* change in run address for current section during relocation */
-	ldr_addr delta_runaddr;
-	ldr_addr image_offset;	/* offset of current packet in section */
-	enum cinit_mode cinit_state;	/* current state of cload_cinit() */
-	int cinit_count;	/* the current count */
-	ldr_addr cinit_addr;	/* the current address */
-	s16 cinit_page;		/* the current page */
-	/* Handle to be returned by dynamic_load_module */
-	struct my_handle *myhandle;
-	unsigned dload_errcount;	/* Total # of errors reported so far */
-	/* Number of target sections that require allocation and relocation */
-	unsigned allocated_secn_count;
-#ifndef TARGET_ENDIANNESS
-	int big_e_target;	/* Target data in big-endian format */
-#endif
-	/* map for reordering bytes, 0 if not needed */
-	u32 reorder_map;
-	struct doff_filehdr_t dfile_hdr;	/* DOFF file header structure */
-	struct doff_verify_rec_t verify;	/* Verify record */
-
-	struct tramp_info tramp;	/* Trampoline data, if needed */
-
-	int relstkidx;		/* index into relocation value stack */
-	/* relocation value stack used in relexp.c */
-	rvalue relstk[STATIC_EXPR_STK_SIZE];
-
-};
-
-#ifdef TARGET_ENDIANNESS
-#define TARGET_BIG_ENDIAN TARGET_ENDIANNESS
-#else
-#define TARGET_BIG_ENDIAN (dlthis->big_e_target)
-#endif
-
-/*
- * Exports from cload.c to rest of the world
- */
-extern void dload_error(struct dload_state *dlthis, const char *errtxt, ...);
-extern void dload_syms_error(struct dynamic_loader_sym *syms,
-			     const char *errtxt, ...);
-extern void dload_headers(struct dload_state *dlthis);
-extern void dload_strings(struct dload_state *dlthis, bool sec_names_only);
-extern void dload_sections(struct dload_state *dlthis);
-extern void dload_reorder(void *data, int dsiz, u32 map);
-extern u32 dload_checksum(void *data, unsigned siz);
-
-#if HOST_ENDIANNESS
-extern uint32_t dload_reverse_checksum(void *data, unsigned siz);
-#if (TARGET_AU_BITS > 8) && (TARGET_AU_BITS < 32)
-extern uint32_t dload_reverse_checksum16(void *data, unsigned siz);
-#endif
-#endif
-
-/*
- * exported by reloc.c
- */
-extern void dload_relocate(struct dload_state *dlthis, tgt_au_t *data,
-			   struct reloc_record_t *rp, bool *tramps_generated,
-			   bool second_pass);
-
-extern rvalue dload_unpack(struct dload_state *dlthis, tgt_au_t *data,
-			   int fieldsz, int offset, unsigned sgn);
-
-extern int dload_repack(struct dload_state *dlthis, rvalue val, tgt_au_t *data,
-			int fieldsz, int offset, unsigned sgn);
-
-/*
- * exported by tramp.c
- */
-extern bool dload_tramp_avail(struct dload_state *dlthis,
-			      struct reloc_record_t *rp);
-
-int dload_tramp_generate(struct dload_state *dlthis, s16 secnn,
-			 u32 image_offset, struct image_packet_t *ipacket,
-			 struct reloc_record_t *rp);
-
-extern int dload_tramp_pkt_udpate(struct dload_state *dlthis,
-				  s16 secnn, u32 image_offset,
-				  struct image_packet_t *ipacket);
-
-extern int dload_tramp_finalize(struct dload_state *dlthis);
-
-extern void dload_tramp_cleanup(struct dload_state *dlthis);
-
-#endif /* _DLOAD_INTERNAL_ */
diff --git a/drivers/staging/tidspbridge/dynload/doff.h b/drivers/staging/tidspbridge/dynload/doff.h
deleted file mode 100644
index a7c31457..0000000
--- a/drivers/staging/tidspbridge/dynload/doff.h
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * doff.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Structures & definitions used for dynamically loaded modules file format.
- * This format is a reformatted version of COFF. It optimizes the layout for
- * the dynamic loader.
- *
- * .dof files, when viewed as a sequence of 32-bit integers, look the same
- * on big-endian and little-endian machines.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _DOFF_H
-#define _DOFF_H
-
-
-#define BYTE_RESHUFFLE_VALUE 0x00010203
-
-/* DOFF file header containing fields categorizing the remainder of the file */
-struct doff_filehdr_t {
-
-	/* string table size, including filename, in bytes */
-	u32 df_strtab_size;
-
-	/* entry point if one exists */
-	u32 df_entrypt;
-
-	/* identifies byte ordering of file;
-	 * always set to BYTE_RESHUFFLE_VALUE */
-	u32 df_byte_reshuffle;
-
-	/* Size of the string table up to and including the last section name */
-	/* Size includes the name of the COFF file also */
-	u32 df_scn_name_size;
-
-#ifndef _BIG_ENDIAN
-	/* number of symbols */
-	u16 df_no_syms;
-
-	/* length in bytes of the longest string, including terminating NULL */
-	/* excludes the name of the file */
-	u16 df_max_str_len;
-
-	/* total number of sections including no-load ones */
-	u16 df_no_scns;
-
-	/* number of sections containing target code allocated or downloaded */
-	u16 df_target_scns;
-
-	/* unique id for dll file format & version */
-	u16 df_doff_version;
-
-	/* identifies ISA */
-	u16 df_target_id;
-
-	/* useful file flags */
-	u16 df_flags;
-
-	/* section reference for entry point, N_UNDEF for none, */
-	/* N_ABS for absolute address */
-	s16 df_entry_secn;
-#else
-	/* length of the longest string, including terminating NULL */
-	u16 df_max_str_len;
-
-	/* number of symbols */
-	u16 df_no_syms;
-
-	/* number of sections containing target code allocated or downloaded */
-	u16 df_target_scns;
-
-	/* total number of sections including no-load ones */
-	u16 df_no_scns;
-
-	/* identifies ISA */
-	u16 df_target_id;
-
-	/* unique id for dll file format & version */
-	u16 df_doff_version;
-
-	/* section reference for entry point, N_UNDEF for none, */
-	/* N_ABS for absolute address */
-	s16 df_entry_secn;
-
-	/* useful file flags */
-	u16 df_flags;
-#endif
-	/* checksum for file header record */
-	u32 df_checksum;
-
-};
-
-/* flags in the df_flags field */
-#define  DF_LITTLE   0x100
-#define  DF_BIG      0x200
-#define  DF_BYTE_ORDER (DF_LITTLE | DF_BIG)
-
-/* Supported processors */
-#define TMS470_ID   0x97
-#define LEAD_ID     0x98
-#define TMS32060_ID 0x99
-#define LEAD3_ID    0x9c
-
-/* Primary processor for loading */
-#if TMS32060
-#define TARGET_ID   TMS32060_ID
-#endif
-
-/* Verification record containing values used to test integrity of the bits */
-struct doff_verify_rec_t {
-
-	/* time and date stamp */
-	u32 dv_timdat;
-
-	/* checksum for all section records */
-	u32 dv_scn_rec_checksum;
-
-	/* checksum for string table */
-	u32 dv_str_tab_checksum;
-
-	/* checksum for symbol table */
-	u32 dv_sym_tab_checksum;
-
-	/* checksum for verification record */
-	u32 dv_verify_rec_checksum;
-
-};
-
-/* String table is an array of null-terminated strings.  The first entry is
- * the filename, which is added by DLLcreate.  No new structure definitions
- * are required.
- */
-
-/* Section Records including information on the corresponding image packets */
-/*
- *      !!WARNING!!
- *
- * This structure is expected to match in form ldr_section_info in
- * dynamic_loader.h
- */
-
-struct doff_scnhdr_t {
-
-	s32 ds_offset;		/* offset into string table of name */
-	s32 ds_paddr;		/* RUN address, in target AU */
-	s32 ds_vaddr;		/* LOAD address, in target AU */
-	s32 ds_size;		/* section size, in target AU */
-#ifndef _BIG_ENDIAN
-	u16 ds_page;		/* memory page id */
-	u16 ds_flags;		/* section flags */
-#else
-	u16 ds_flags;		/* section flags */
-	u16 ds_page;		/* memory page id */
-#endif
-	u32 ds_first_pkt_offset;
-	/* Absolute byte offset into the file */
-	/* where the first image record resides */
-
-	s32 ds_nipacks;		/* number of image packets */
-
-};
-
-/* Symbol table entry */
-struct doff_syment_t {
-
-	s32 dn_offset;		/* offset into string table of name */
-	s32 dn_value;		/* value of symbol */
-#ifndef _BIG_ENDIAN
-	s16 dn_scnum;		/* section number */
-	s16 dn_sclass;		/* storage class */
-#else
-	s16 dn_sclass;		/* storage class */
-	s16 dn_scnum;		/* section number, 1-based */
-#endif
-
-};
-
-/* special values for dn_scnum */
-#define  DN_UNDEF  0		/* undefined symbol */
-#define  DN_ABS    (-1)		/* value of symbol is absolute */
-/* special values for dn_sclass */
-#define DN_EXT     2
-#define DN_STATLAB 20
-#define DN_EXTLAB  21
-
-/* Default value of image bits in packet */
-/* Configurable by user on the command line */
-#define IMAGE_PACKET_SIZE 1024
-
-/* An image packet contains a chunk of data from a section along with */
-/* information necessary for its processing. */
-struct image_packet_t {
-
-	s32 num_relocs;		/* number of relocations for */
-	/* this packet */
-
-	s32 packet_size;	/* number of bytes in array */
-	/* "bits" occupied  by */
-	/* valid data.  Could be */
-	/* < IMAGE_PACKET_SIZE to */
-	/* prevent splitting a */
-	/* relocation across packets. */
-	/* Last packet of a section */
-	/* will most likely contain */
-	/* < IMAGE_PACKET_SIZE bytes */
-	/* of valid data */
-
-	s32 img_chksum;		/* Checksum for image packet */
-	/* and the corresponding */
-	/* relocation records */
-
-	u8 *img_data;		/* Actual data in section */
-
-};
-
-/* The relocation structure definition matches the COFF version.  Offsets */
-/* however are relative to the image packet base not the section base. */
-struct reloc_record_t {
-
-	s32 vaddr;
-
-	/* expressed in target AUs */
-
-	union {
-		struct {
-#ifndef _BIG_ENDIAN
-			u8 _offset;	/* bit offset of rel fld */
-			u8 _fieldsz;	/* size of rel fld */
-			u8 _wordsz;	/* # bytes containing rel fld */
-			u8 _dum1;
-			u16 _dum2;
-			u16 _type;
-#else
-			unsigned _dum1:8;
-			unsigned _wordsz:8;	/* # bytes containing rel fld */
-			unsigned _fieldsz:8;	/* size of rel fld */
-			unsigned _offset:8;	/* bit offset of rel fld */
-			u16 _type;
-			u16 _dum2;
-#endif
-		} _r_field;
-
-		struct {
-			u32 _spc;	/* image packet relative PC */
-#ifndef _BIG_ENDIAN
-			u16 _dum;
-			u16 _type;	/* relocation type */
-#else
-			u16 _type;	/* relocation type */
-			u16 _dum;
-#endif
-		} _r_spc;
-
-		struct {
-			u32 _uval;	/* constant value */
-#ifndef _BIG_ENDIAN
-			u16 _dum;
-			u16 _type;	/* relocation type */
-#else
-			u16 _type;	/* relocation type */
-			u16 _dum;
-#endif
-		} _r_uval;
-
-		struct {
-			s32 _symndx;	/* 32-bit sym tbl index */
-#ifndef _BIG_ENDIAN
-			u16 _disp;	/* extra addr encode data */
-			u16 _type;	/* relocation type */
-#else
-			u16 _type;	/* relocation type */
-			u16 _disp;	/* extra addr encode data */
-#endif
-		} _r_sym;
-	} _u_reloc;
-
-};
-
-/* abbreviations for convenience */
-#ifndef TYPE
-#define TYPE      _u_reloc._r_sym._type
-#define UVAL      _u_reloc._r_uval._uval
-#define SYMNDX    _u_reloc._r_sym._symndx
-#define OFFSET    _u_reloc._r_field._offset
-#define FIELDSZ   _u_reloc._r_field._fieldsz
-#define WORDSZ    _u_reloc._r_field._wordsz
-#define R_DISP      _u_reloc._r_sym._disp
-#endif
-
-/**************************************************************************** */
-/* */
-/* Important DOFF macros used for file processing */
-/* */
-/**************************************************************************** */
-
-/* DOFF Versions */
-#define         DOFF0                       0
-
-/* Return the address/size >= to addr that is at a 32-bit boundary */
-/* This assumes that a byte is 8 bits */
-#define         DOFF_ALIGN(addr)            (((addr) + 3) & ~3UL)
-
-/**************************************************************************** */
-/* */
-/* The DOFF section header flags field is laid out as follows: */
-/* */
-/*  Bits 0-3 : Section Type */
-/*  Bit    4 : Set when section requires target memory to be allocated by DL */
-/*  Bit    5 : Set when section requires downloading */
-/*  Bits 8-11: Alignment, same as COFF */
-/* */
-/**************************************************************************** */
-
-/* Enum for DOFF section types (bits 0-3 of flag): See dynamic_loader.h */
-#define DS_SECTION_TYPE_MASK	0xF
-/* DS_ALLOCATE indicates whether a section needs space on the target */
-#define DS_ALLOCATE_MASK            0x10
-/* DS_DOWNLOAD indicates that the loader needs to copy bits */
-#define DS_DOWNLOAD_MASK            0x20
-/* Section alignment requirement in AUs */
-#define DS_ALIGNMENT_SHIFT	8
-
-static inline bool dload_check_type(struct doff_scnhdr_t *sptr, u32 flag)
-{
-	return (sptr->ds_flags & DS_SECTION_TYPE_MASK) == flag;
-}
-static inline bool ds_needs_allocation(struct doff_scnhdr_t *sptr)
-{
-	return sptr->ds_flags & DS_ALLOCATE_MASK;
-}
-
-static inline bool ds_needs_download(struct doff_scnhdr_t *sptr)
-{
-	return sptr->ds_flags & DS_DOWNLOAD_MASK;
-}
-
-static inline int ds_alignment(u16 ds_flags)
-{
-	return 1 << ((ds_flags >> DS_ALIGNMENT_SHIFT) & DS_SECTION_TYPE_MASK);
-}
-
-
-#endif /* _DOFF_H */
diff --git a/drivers/staging/tidspbridge/dynload/getsection.c b/drivers/staging/tidspbridge/dynload/getsection.c
deleted file mode 100644
index e0b3771..0000000
--- a/drivers/staging/tidspbridge/dynload/getsection.c
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * getsection.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <dspbridge/getsection.h>
-#include "header.h"
-
-/*
- * Error strings
- */
-static const char readstrm[] = { "Error reading %s from input stream" };
-static const char seek[] = { "Set file position to %d failed" };
-static const char isiz[] = { "Bad image packet size %d" };
-static const char err_checksum[] = { "Checksum failed on %s" };
-
-static const char err_reloc[] = { "dload_get_section unable to read"
-	    "sections containing relocation entries"
-};
-
-#if BITS_PER_AU > BITS_PER_BYTE
-static const char err_alloc[] = { "Syms->dload_allocate( %d ) failed" };
-static const char stbl[] = { "Bad string table offset " FMT_UI32 };
-#endif
-
-/************************************************************** */
-/********************* SUPPORT FUNCTIONS ********************** */
-/************************************************************** */
-
-#if BITS_PER_AU > BITS_PER_BYTE
-/**************************************************************************
- * Procedure unpack_sec_name
- *
- * Parameters:
- *  dlthis		Handle from dload_module_open for this module
- *	soffset	    Byte offset into the string table
- *  dst         Place to store the expanded string
- *
- * Effect:
- *	Stores a string from the string table into the destination, expanding
- * it in the process.  Returns a pointer just past the end of the stored
- * string on success, or NULL on failure.
- *
- ************************************************************************ */
-static char *unpack_sec_name(struct dload_state *dlthis, u32 soffset, char *dst)
-{
-	u8 tmp, *src;
-
-	if (soffset >= dlthis->dfile_hdr.df_scn_name_size) {
-		dload_error(dlthis, stbl, soffset);
-		return NULL;
-	}
-	src = (u8 *) dlthis->str_head +
-	    (soffset >> (LOG_BITS_PER_AU - LOG_BITS_PER_BYTE));
-	if (soffset & 1)
-		*dst++ = *src++;	/* only 1 character in first word */
-	do {
-		tmp = *src++;
-		*dst = (tmp >> BITS_PER_BYTE)
-		    if (!(*dst++))
-			break;
-	} while ((*dst++ = tmp & BYTE_MASK));
-
-	return dst;
-}
-
-/**************************************************************************
- * Procedure expand_sec_names
- *
- * Parameters:
- *  dlthis		Handle from dload_module_open for this module
- *
- * Effect:
- *    Allocates a buffer, unpacks and copies strings from string table into it.
- * Stores a pointer to the buffer into a state variable.
- ************************************************************************* */
-static void expand_sec_names(struct dload_state *dlthis)
-{
-	char *xstrings, *curr, *next;
-	u32 xsize;
-	u16 sec;
-	struct ldr_section_info *shp;
-	/* assume worst-case size requirement */
-	xsize = dlthis->dfile_hdr.df_max_str_len * dlthis->dfile_hdr.df_no_scns;
-	xstrings = (char *)dlthis->mysym->dload_allocate(dlthis->mysym, xsize);
-	if (xstrings == NULL) {
-		dload_error(dlthis, err_alloc, xsize);
-		return;
-	}
-	dlthis->xstrings = xstrings;
-	/* For each sec, copy and expand its name */
-	curr = xstrings;
-	for (sec = 0; sec < dlthis->dfile_hdr.df_no_scns; sec++) {
-		shp = (struct ldr_section_info *)&dlthis->sect_hdrs[sec];
-		next = unpack_sec_name(dlthis, *(u32 *) &shp->name, curr);
-		if (next == NULL)
-			break;	/* error */
-		shp->name = curr;
-		curr = next;
-	}
-}
-
-#endif
-
-/************************************************************** */
-/********************* EXPORTED FUNCTIONS ********************* */
-/************************************************************** */
-
-/**************************************************************************
- * Procedure dload_module_open
- *
- * Parameters:
- *	module	The input stream that supplies the module image
- *	syms	Host-side malloc/free and error reporting functions.
- *			Other methods are unused.
- *
- * Effect:
- *	Reads header information from a dynamic loader module using the
-    specified
- * stream object, and returns a handle for the module information.  This
- * handle may be used in subsequent query calls to obtain information
- * contained in the module.
- *
- * Returns:
- *	NULL if an error is encountered, otherwise a module handle for use
- * in subsequent operations.
- ************************************************************************* */
-void *dload_module_open(struct dynamic_loader_stream *module,
-				    struct dynamic_loader_sym *syms)
-{
-	struct dload_state *dlthis;	/* internal state for this call */
-	unsigned *dp, sz;
-	u32 sec_start;
-#if BITS_PER_AU <= BITS_PER_BYTE
-	u16 sec;
-#endif
-
-	/* Check that mandatory arguments are present */
-	if (!module || !syms) {
-		if (syms != NULL)
-			dload_syms_error(syms, "Required parameter is NULL");
-
-		return NULL;
-	}
-
-	dlthis = (struct dload_state *)
-	    syms->dload_allocate(syms, sizeof(struct dload_state));
-	if (!dlthis) {
-		/* not enough storage */
-		dload_syms_error(syms, "Can't allocate module info");
-		return NULL;
-	}
-
-	/* clear our internal state */
-	dp = (unsigned *)dlthis;
-	for (sz = sizeof(struct dload_state) / sizeof(unsigned);
-	     sz > 0; sz -= 1)
-		*dp++ = 0;
-
-	dlthis->strm = module;
-	dlthis->mysym = syms;
-
-	/* read in the doff image and store in our state variable */
-	dload_headers(dlthis);
-
-	if (!dlthis->dload_errcount)
-		dload_strings(dlthis, true);
-
-	/* skip ahead past the unread portion of the string table */
-	sec_start = sizeof(struct doff_filehdr_t) +
-	    sizeof(struct doff_verify_rec_t) +
-	    BYTE_TO_HOST(DOFF_ALIGN(dlthis->dfile_hdr.df_strtab_size));
-
-	if (dlthis->strm->set_file_posn(dlthis->strm, sec_start) != 0) {
-		dload_error(dlthis, seek, sec_start);
-		return NULL;
-	}
-
-	if (!dlthis->dload_errcount)
-		dload_sections(dlthis);
-
-	if (dlthis->dload_errcount) {
-		dload_module_close(dlthis);	/* errors, blow off our state */
-		dlthis = NULL;
-		return NULL;
-	}
-#if BITS_PER_AU > BITS_PER_BYTE
-	/* Expand all section names from the string table into the */
-	/* state variable, and convert section names from a relative */
-	/* string table offset to a pointers to the expanded string. */
-	expand_sec_names(dlthis);
-#else
-	/* Convert section names from a relative string table offset */
-	/* to a pointer into the string table. */
-	for (sec = 0; sec < dlthis->dfile_hdr.df_no_scns; sec++) {
-		struct ldr_section_info *shp =
-		    (struct ldr_section_info *)&dlthis->sect_hdrs[sec];
-		shp->name = dlthis->str_head + *(u32 *) &shp->name;
-	}
-#endif
-
-	return dlthis;
-}
-
-/***************************************************************************
- * Procedure dload_get_section_info
- *
- * Parameters:
- *  minfo		Handle from dload_module_open for this module
- *	section_name	Pointer to the string name of the section desired
- *	section_info	Address of a section info structure pointer to be
- *			initialized
- *
- * Effect:
- *	Finds the specified section in the module information, and initializes
- * the provided struct ldr_section_info pointer.
- *
- * Returns:
- *	true for success, false for section not found
- ************************************************************************* */
-int dload_get_section_info(void *minfo, const char *section_name,
-			   const struct ldr_section_info **const section_info)
-{
-	struct dload_state *dlthis;
-	struct ldr_section_info *shp;
-	u16 sec;
-
-	dlthis = (struct dload_state *)minfo;
-	if (!dlthis)
-		return false;
-
-	for (sec = 0; sec < dlthis->dfile_hdr.df_no_scns; sec++) {
-		shp = (struct ldr_section_info *)&dlthis->sect_hdrs[sec];
-		if (strcmp(section_name, shp->name) == 0) {
-			*section_info = shp;
-			return true;
-		}
-	}
-
-	return false;
-}
-
-#define IPH_SIZE (sizeof(struct image_packet_t) - sizeof(u32))
-
-/**************************************************************************
- * Procedure dload_get_section
- *
- * Parameters:
- *  minfo		Handle from dload_module_open for this module
- *	section_info	Pointer to a section info structure for the desired
- *			section
- *	section_data	Buffer to contain the section initialized data
- *
- * Effect:
- *	Copies the initialized data for the specified section into the
- * supplied buffer.
- *
- * Returns:
- *	true for success, false for section not found
- ************************************************************************* */
-int dload_get_section(void *minfo,
-		      const struct ldr_section_info *section_info,
-		      void *section_data)
-{
-	struct dload_state *dlthis;
-	u32 pos;
-	struct doff_scnhdr_t *sptr = NULL;
-	s32 nip;
-	struct image_packet_t ipacket;
-	s32 ipsize;
-	u32 checks;
-	s8 *dest = (s8 *) section_data;
-
-	dlthis = (struct dload_state *)minfo;
-	if (!dlthis)
-		return false;
-	sptr = (struct doff_scnhdr_t *)section_info;
-	if (sptr == NULL)
-		return false;
-
-	/* skip ahead to the start of the first packet */
-	pos = BYTE_TO_HOST(DOFF_ALIGN((u32) sptr->ds_first_pkt_offset));
-	if (dlthis->strm->set_file_posn(dlthis->strm, pos) != 0) {
-		dload_error(dlthis, seek, pos);
-		return false;
-	}
-
-	nip = sptr->ds_nipacks;
-	while ((nip -= 1) >= 0) {	/* for each packet */
-		/* get the fixed header bits */
-		if (dlthis->strm->read_buffer(dlthis->strm, &ipacket,
-					      IPH_SIZE) != IPH_SIZE) {
-			dload_error(dlthis, readstrm, "image packet");
-			return false;
-		}
-		/* reorder the header if need be */
-		if (dlthis->reorder_map)
-			dload_reorder(&ipacket, IPH_SIZE, dlthis->reorder_map);
-
-		/* Now read the packet image bits. Note: round the size up to
-		 * the next multiple of 4 bytes; this is what checksum
-		 * routines want. */
-		ipsize = BYTE_TO_HOST(DOFF_ALIGN(ipacket.packet_size));
-		if (ipsize > BYTE_TO_HOST(IMAGE_PACKET_SIZE)) {
-			dload_error(dlthis, isiz, ipsize);
-			return false;
-		}
-		if (dlthis->strm->read_buffer
-		    (dlthis->strm, dest, ipsize) != ipsize) {
-			dload_error(dlthis, readstrm, "image packet");
-			return false;
-		}
-		/* reorder the bytes if need be */
-#if !defined(_BIG_ENDIAN) || (TARGET_AU_BITS > 16)
-		if (dlthis->reorder_map)
-			dload_reorder(dest, ipsize, dlthis->reorder_map);
-
-		checks = dload_checksum(dest, ipsize);
-#else
-		if (dlthis->dfile_hdr.df_byte_reshuffle !=
-		    TARGET_ORDER(REORDER_MAP(BYTE_RESHUFFLE_VALUE))) {
-			/* put image bytes in big-endian order, not PC order */
-			dload_reorder(dest, ipsize,
-				      TARGET_ORDER(dlthis->
-						dfile_hdr.df_byte_reshuffle));
-		}
-#if TARGET_AU_BITS > 8
-		checks = dload_reverse_checksum16(dest, ipsize);
-#else
-		checks = dload_reverse_checksum(dest, ipsize);
-#endif
-#endif
-		checks += dload_checksum(&ipacket, IPH_SIZE);
-
-		/* NYI: unable to handle relocation entries here.  Reloc
-		 * entries referring to fields that span the packet boundaries
-		 * may result in packets of sizes that are not multiple of
-		 * 4 bytes. Our checksum implementation works on 32-bit words
-		 * only. */
-		if (ipacket.num_relocs != 0) {
-			dload_error(dlthis, err_reloc, ipsize);
-			return false;
-		}
-
-		if (~checks) {
-			dload_error(dlthis, err_checksum, "image packet");
-			return false;
-		}
-
-		/*Advance destination ptr by the size of the just-read packet */
-		dest += ipsize;
-	}
-
-	return true;
-}
-
-/***************************************************************************
- * Procedure dload_module_close
- *
- * Parameters:
- *  minfo		Handle from dload_module_open for this module
- *
- * Effect:
- *	Releases any storage associated with the module handle.  On return,
- * the module handle is invalid.
- *
- * Returns:
- *	Zero for success. On error, the number of errors detected is returned.
- * Individual errors are reported using syms->error_report(), where syms was
- * an argument to dload_module_open
- ************************************************************************* */
-void dload_module_close(void *minfo)
-{
-	struct dload_state *dlthis;
-
-	dlthis = (struct dload_state *)minfo;
-	if (!dlthis)
-		return;
-
-	if (dlthis->str_head)
-		dlthis->mysym->dload_deallocate(dlthis->mysym,
-						dlthis->str_head);
-
-	if (dlthis->sect_hdrs)
-		dlthis->mysym->dload_deallocate(dlthis->mysym,
-						dlthis->sect_hdrs);
-
-#if BITS_PER_AU > BITS_PER_BYTE
-	if (dlthis->xstrings)
-		dlthis->mysym->dload_deallocate(dlthis->mysym,
-						dlthis->xstrings);
-
-#endif
-
-	dlthis->mysym->dload_deallocate(dlthis->mysym, dlthis);
-}
diff --git a/drivers/staging/tidspbridge/dynload/header.h b/drivers/staging/tidspbridge/dynload/header.h
deleted file mode 100644
index 5b50a15a..0000000
--- a/drivers/staging/tidspbridge/dynload/header.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * header.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/string.h>
-#define DL_STRCMP  strcmp
-
-/* maximum parenthesis nesting in relocation stack expressions */
-#define STATIC_EXPR_STK_SIZE 10
-
-#include <linux/types.h>
-
-#include "doff.h"
-#include <dspbridge/dynamic_loader.h>
-#include "params.h"
-#include "dload_internal.h"
-#include "reloc_table.h"
-
-/*
- * Plausibility limits
- *
- * These limits are imposed upon the input DOFF file as a check for validity.
- * They are hard limits, in that the load will fail if they are exceeded.
- * The numbers selected are arbitrary, in that the loader implementation does
- * not require these limits.
- */
-
-/* maximum number of bytes in string table */
-#define MAX_REASONABLE_STRINGTAB (0x100000)
-/* maximum number of code,data,etc. sections */
-#define MAX_REASONABLE_SECTIONS (200)
-/* maximum number of linker symbols */
-#define MAX_REASONABLE_SYMBOLS (100000)
-
-/* shift count to align F_BIG with DLOAD_LITTLE */
-#define ALIGN_COFF_ENDIANNESS 7
-#define ENDIANNESS_MASK (DF_BYTE_ORDER >> ALIGN_COFF_ENDIANNESS)
diff --git a/drivers/staging/tidspbridge/dynload/module_list.h b/drivers/staging/tidspbridge/dynload/module_list.h
deleted file mode 100644
index a216bb1..0000000
--- a/drivers/staging/tidspbridge/dynload/module_list.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * dspbridge/mpu_driver/src/dynload/module_list.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
- * This C header file gives the layout of the data structure created by the
- * dynamic loader to describe the set of modules loaded into the DSP.
- *
- * Linked List Structure:
- * ----------------------
- * The data structure defined here is a singly-linked list.  The list
- * represents the set of modules which are currently loaded in the DSP memory.
- * The first entry in the list is a header record which contains a flag
- * representing the state of the list.  The rest of the entries in the list
- * are module records.
- *
- * Global symbol  _DLModules designates the first record in the list (i.e. the
- * header record).  This symbol must be defined in any program that wishes to
- * use DLLview plug-in.
- *
- * String Representation:
- * ----------------------
- * The string names of the module and its sections are stored in a block of
- * memory which follows the module record itself.  The strings are ordered:
- * module name first, followed by section names in order from the first
- * section to the last.  String names are tightly packed arrays of 8-bit
- * characters (two characters per 16-bit word on the C55x).  Strings are
- * zero-byte-terminated.
- *
- * Creating and updating the list:
- * -------------------------------
- * Upon loading a new module into the DSP memory the dynamic loader inserts a
- * new module record as the first module record in the list.  The fields of
- * this module record are initialized to reflect the properties of the module.
- * The dynamic loader does NOT increment the flag/counter in the list's header
- * record.
- *
- * Upon unloading a module from the DSP memory the dynamic loader removes the
- * module's record from this list.  The dynamic loader also increments the
- * flag/counter in the list's header record to indicate that the list has been
- * changed.
- */
-
-#ifndef _MODULE_LIST_H_
-#define _MODULE_LIST_H_
-
-#include <linux/types.h>
-
-/* Global pointer to the modules_header structure */
-#define MODULES_HEADER "_DLModules"
-#define MODULES_HEADER_NO_UNDERSCORE "DLModules"
-
-/* Initial version number */
-#define INIT_VERSION 1
-
-/* Verification number -- to be recorded in each module record */
-#define VERIFICATION 0x79
-
-/* forward declarations */
-struct dll_module;
-struct dll_sect;
-
-/* the first entry in the list is the modules_header record;
- * its address is contained in the global _DLModules pointer */
-struct modules_header {
-
-	/*
-	 * Address of the first dll_module record in the list or NULL.
-	 * Note: for C55x this is a word address (C55x data is
-	 * word-addressable)
-	 */
-	u32 first_module;
-
-	/* Combined storage size (in target addressable units) of the
-	 * dll_module record which follows this header record, or zero
-	 * if the list is empty.  This size includes the module's string table.
-	 * Note: for C55x the unit is a 16-bit word */
-	u16 first_module_size;
-
-	/* Counter is incremented whenever a module record is removed from
-	 * the list */
-	u16 update_flag;
-
-};
-
-/* for each 32-bits in above structure, a bitmap, LSB first, whose bits are:
- * 0 => a 32-bit value, 1 => 2 16-bit values */
-/* swapping bitmap for type modules_header */
-#define MODULES_HEADER_BITMAP 0x2
-
-/* information recorded about each section in a module */
-struct dll_sect {
-
-	/* Load-time address of the section.
-	 * Note: for C55x this is a byte address for program sections, and
-	 * a word address for data sections.  C55x program memory is
-	 * byte-addressable, while data memory is word-addressable. */
-	u32 sect_load_adr;
-
-	/* Run-time address of the section.
-	 * Note 1: for C55x this is a byte address for program sections, and
-	 * a word address for data sections.
-	 * Note 2: for C55x two most significant bits of this field indicate
-	 * the section type: '00' for a code section, '11' for a data section
-	 * (C55 addresses are really only 24-bits wide). */
-	u32 sect_run_adr;
-
-};
-
-/* the rest of the entries in the list are module records */
-struct dll_module {
-
-	/* Address of the next dll_module record in the list, or 0 if this is
-	 * the last record in the list.
-	 * Note: for C55x this is a word address (C55x data is
-	 * word-addressable) */
-	u32 next_module;
-
-	/* Combined storage size (in target addressable units) of the
-	 * dll_module record which follows this one, or zero if this is the
-	 * last record in the list.  This size includes the module's string
-	 * table.
-	 * Note: for C55x the unit is a 16-bit word. */
-	u16 next_module_size;
-
-	/* version number of the tooling; set to INIT_VERSION for Phase 1 */
-	u16 version;
-
-	/* the verification word; set to VERIFICATION */
-	u16 verification;
-
-	/* Number of sections in the sects array */
-	u16 num_sects;
-
-	/* Module's "unique" id; copy of the timestamp from the host
-	 * COFF file */
-	u32 timestamp;
-
-	/* Array of num_sects elements of the module's section records */
-	struct dll_sect sects[1];
-};
-
-/* for each 32 bits in above structure, a bitmap, LSB first, whose bits are:
- * 0 => a 32-bit value, 1 => 2 16-bit values */
-#define DLL_MODULE_BITMAP 0x6	/* swapping bitmap for type dll_module */
-
-#endif /* _MODULE_LIST_H_ */
diff --git a/drivers/staging/tidspbridge/dynload/params.h b/drivers/staging/tidspbridge/dynload/params.h
deleted file mode 100644
index d797fcd..0000000
--- a/drivers/staging/tidspbridge/dynload/params.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * params.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * This file defines host and target properties for all machines
- * supported by the dynamic loader.  To be tedious...
- *
- * host: the machine on which the dynamic loader runs
- * target: the machine that the dynamic loader is loading
- *
- * Host and target may or may not be the same, depending upon the particular
- * use.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/******************************************************************************
- *
- *							Host Properties
- *
- **************************************************************************** */
-
-#define BITS_PER_BYTE 8		/* bits in the standard PC/SUN byte */
-#define LOG_BITS_PER_BYTE 3	/* log base 2 of same */
-#define BYTE_MASK ((1U<<BITS_PER_BYTE)-1)
-
-#if defined(__TMS320C55X__) || defined(_TMS320C5XX)
-#define BITS_PER_AU 16
-#define LOG_BITS_PER_AU 4
- /* use this print string in error messages for uint32_t */
-#define FMT_UI32 "0x%lx"
-#define FMT8_UI32 "%08lx"	/* same but no 0x, fixed width field */
-#else
-/* bits in the smallest addressable data storage unit */
-#define BITS_PER_AU 8
-/* log base 2 of the same; useful for shift counts */
-#define LOG_BITS_PER_AU 3
-#define FMT_UI32 "0x%x"
-#define FMT8_UI32 "%08x"
-#endif
-
-/* generic fastest method for swapping bytes and shorts */
-#define SWAP32BY16(zz) (((zz) << 16) | ((zz) >> 16))
-#define SWAP16BY8(zz) (((zz) << 8) | ((zz) >> 8))
-
-/* !! don't be tempted to insert type definitions here; use <stdint.h> !! */
-
-/******************************************************************************
- *
- *							Target Properties
- *
- **************************************************************************** */
-
-/*-------------------------------------------------------------------------- */
-/* TMS320C6x Target Specific Parameters (byte-addressable) */
-/*-------------------------------------------------------------------------- */
-#if TMS32060
-#define MEMORG          0x0L	/* Size of configured memory */
-#define MEMSIZE         0x0L	/* (full address space) */
-
-#define CINIT_ALIGN     8	/* alignment of cinit record in TDATA AUs */
-#define CINIT_COUNT	4	/* width of count field in TDATA AUs */
-#define CINIT_ADDRESS	4	/* width of address field in TDATA AUs */
-#define CINIT_PAGE_BITS	0	/* Number of LSBs of address that
-				 * are page number */
-
-#define LENIENT_SIGNED_RELEXPS 0	/* DOES SIGNED ALLOW MAX UNSIGNED */
-
-#undef TARGET_ENDIANNESS	/* may be big or little endian */
-
-/* align a target address to a word boundary */
-#define TARGET_WORD_ALIGN(zz) (((zz) + 0x3) & -0x4)
-#endif
-
-/*--------------------------------------------------------------------------
- *
- *			DEFAULT SETTINGS and DERIVED PROPERTIES
- *
- * This section establishes defaults for values not specified above
- *-------------------------------------------------------------------------- */
-#ifndef TARGET_AU_BITS
-#define TARGET_AU_BITS 8	/* width of the target addressable unit */
-#define LOG_TARGET_AU_BITS 3	/* log2 of same */
-#endif
-
-#ifndef CINIT_DEFAULT_PAGE
-#define CINIT_DEFAULT_PAGE 0	/* default .cinit page number */
-#endif
-
-#ifndef DATA_RUN2LOAD
-#define DATA_RUN2LOAD(zz) (zz)	/* translate data run address to load address */
-#endif
-
-#ifndef DBG_LIST_PAGE
-#define DBG_LIST_PAGE 0		/* page number for .dllview section */
-#endif
-
-#ifndef TARGET_WORD_ALIGN
-/* align a target address to a word boundary */
-#define TARGET_WORD_ALIGN(zz) (zz)
-#endif
-
-#ifndef TDATA_TO_TADDR
-#define TDATA_TO_TADDR(zz) (zz)	/* target data address to target AU address */
-#define TADDR_TO_TDATA(zz) (zz)	/* target AU address to target data address */
-#define TDATA_AU_BITS	TARGET_AU_BITS	/* bits per data AU */
-#define LOG_TDATA_AU_BITS	LOG_TARGET_AU_BITS
-#endif
-
-/*
- *
- * Useful properties and conversions derived from the above
- *
- */
-
-/*
- * Conversions between host and target addresses
- */
-#if LOG_BITS_PER_AU == LOG_TARGET_AU_BITS
-/* translate target addressable unit to host address */
-#define TADDR_TO_HOST(x) (x)
-/* translate host address to target addressable unit */
-#define HOST_TO_TADDR(x) (x)
-#elif LOG_BITS_PER_AU > LOG_TARGET_AU_BITS
-#define TADDR_TO_HOST(x) ((x) >> (LOG_BITS_PER_AU-LOG_TARGET_AU_BITS))
-#define HOST_TO_TADDR(x) ((x) << (LOG_BITS_PER_AU-LOG_TARGET_AU_BITS))
-#else
-#define TADDR_TO_HOST(x) ((x) << (LOG_TARGET_AU_BITS-LOG_BITS_PER_AU))
-#define HOST_TO_TADDR(x) ((x) >> (LOG_TARGET_AU_BITS-LOG_BITS_PER_AU))
-#endif
-
-#if LOG_BITS_PER_AU == LOG_TDATA_AU_BITS
-/* translate target addressable unit to host address */
-#define TDATA_TO_HOST(x) (x)
-/* translate host address to target addressable unit */
-#define HOST_TO_TDATA(x) (x)
-/* translate host address to target addressable unit, round up */
-#define HOST_TO_TDATA_ROUND(x) (x)
-/* byte offset to host offset, rounded up for TDATA size */
-#define BYTE_TO_HOST_TDATA_ROUND(x) BYTE_TO_HOST_ROUND(x)
-#elif LOG_BITS_PER_AU > LOG_TDATA_AU_BITS
-#define TDATA_TO_HOST(x) ((x) >> (LOG_BITS_PER_AU-LOG_TDATA_AU_BITS))
-#define HOST_TO_TDATA(x) ((x) << (LOG_BITS_PER_AU-LOG_TDATA_AU_BITS))
-#define HOST_TO_TDATA_ROUND(x) ((x) << (LOG_BITS_PER_AU-LOG_TDATA_AU_BITS))
-#define BYTE_TO_HOST_TDATA_ROUND(x) BYTE_TO_HOST_ROUND(x)
-#else
-#define TDATA_TO_HOST(x) ((x) << (LOG_TDATA_AU_BITS-LOG_BITS_PER_AU))
-#define HOST_TO_TDATA(x) ((x) >> (LOG_TDATA_AU_BITS-LOG_BITS_PER_AU))
-#define HOST_TO_TDATA_ROUND(x) (((x) +\
-				(1<<(LOG_TDATA_AU_BITS-LOG_BITS_PER_AU))-1) >>\
-				(LOG_TDATA_AU_BITS-LOG_BITS_PER_AU))
-#define BYTE_TO_HOST_TDATA_ROUND(x) (BYTE_TO_HOST((x) +\
-	(1<<(LOG_TDATA_AU_BITS-LOG_BITS_PER_BYTE))-1) &\
-	-(TDATA_AU_BITS/BITS_PER_AU))
-#endif
-
-/*
- * Input in DOFF format is always expresed in bytes, regardless of loading host
- * so we wind up converting from bytes to target and host units even when the
- * host is not a byte machine.
- */
-#if LOG_BITS_PER_AU == LOG_BITS_PER_BYTE
-#define BYTE_TO_HOST(x) (x)
-#define BYTE_TO_HOST_ROUND(x) (x)
-#define HOST_TO_BYTE(x) (x)
-#elif LOG_BITS_PER_AU >= LOG_BITS_PER_BYTE
-#define BYTE_TO_HOST(x) ((x) >> (LOG_BITS_PER_AU - LOG_BITS_PER_BYTE))
-#define BYTE_TO_HOST_ROUND(x) ((x + (BITS_PER_AU/BITS_PER_BYTE-1)) >>\
-			      (LOG_BITS_PER_AU - LOG_BITS_PER_BYTE))
-#define HOST_TO_BYTE(x) ((x) << (LOG_BITS_PER_AU - LOG_BITS_PER_BYTE))
-#else
-/* lets not try to deal with sub-8-bit byte machines */
-#endif
-
-#if LOG_TARGET_AU_BITS == LOG_BITS_PER_BYTE
-/* translate target addressable unit to byte address */
-#define TADDR_TO_BYTE(x) (x)
-/* translate byte address to target addressable unit */
-#define BYTE_TO_TADDR(x) (x)
-#elif LOG_TARGET_AU_BITS > LOG_BITS_PER_BYTE
-#define TADDR_TO_BYTE(x) ((x) << (LOG_TARGET_AU_BITS-LOG_BITS_PER_BYTE))
-#define BYTE_TO_TADDR(x) ((x) >> (LOG_TARGET_AU_BITS-LOG_BITS_PER_BYTE))
-#else
-/* lets not try to deal with sub-8-bit byte machines */
-#endif
-
-#ifdef _BIG_ENDIAN
-#define HOST_ENDIANNESS 1
-#else
-#define HOST_ENDIANNESS 0
-#endif
-
-#ifdef TARGET_ENDIANNESS
-#define TARGET_ENDIANNESS_DIFFERS(rtend) (HOST_ENDIANNESS^TARGET_ENDIANNESS)
-#elif HOST_ENDIANNESS
-#define TARGET_ENDIANNESS_DIFFERS(rtend) (!(rtend))
-#else
-#define TARGET_ENDIANNESS_DIFFERS(rtend) (rtend)
-#endif
-
-/* the unit in which we process target image data */
-#if TARGET_AU_BITS <= 8
-typedef u8 tgt_au_t;
-#elif TARGET_AU_BITS <= 16
-typedef u16 tgt_au_t;
-#else
-typedef u32 tgt_au_t;
-#endif
-
-/* size of that unit */
-#if TARGET_AU_BITS < BITS_PER_AU
-#define TGTAU_BITS BITS_PER_AU
-#define LOG_TGTAU_BITS LOG_BITS_PER_AU
-#else
-#define TGTAU_BITS TARGET_AU_BITS
-#define LOG_TGTAU_BITS LOG_TARGET_AU_BITS
-#endif
diff --git a/drivers/staging/tidspbridge/dynload/reloc.c b/drivers/staging/tidspbridge/dynload/reloc.c
deleted file mode 100644
index bb422b6..0000000
--- a/drivers/staging/tidspbridge/dynload/reloc.c
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
- * reloc.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include "header.h"
-
-#if TMS32060
-/* the magic symbol for the start of BSS */
-static const char bsssymbol[] = { ".bss" };
-#endif
-
-#if TMS32060
-#include "reloc_table_c6000.c"
-#endif
-
-#if TMS32060
-/* From coff.h - ignore these relocation operations */
-#define R_C60ALIGN     0x76	/* C60: Alignment info for compressor */
-#define R_C60FPHEAD    0x77	/* C60: Explicit assembly directive */
-#define R_C60NOCMP    0x100	/* C60: Don't compress this code scn */
-#endif
-
-/**************************************************************************
- * Procedure dload_unpack
- *
- * Parameters:
- *	data	pointer to storage unit containing lowest host address of
- *		image data
- *	fieldsz	Size of bit field, 0 < fieldsz <= sizeof(rvalue)*BITS_PER_AU
- *	offset	Offset from LSB, 0 <= offset < BITS_PER_AU
- *	sgn	Signedness of the field (ROP_SGN, ROP_UNS, ROP_MAX, ROP_ANY)
- *
- * Effect:
- *	Extracts the specified field and returns it.
- ************************************************************************* */
-rvalue dload_unpack(struct dload_state *dlthis, tgt_au_t *data, int fieldsz,
-		    int offset, unsigned sgn)
-{
-	register rvalue objval;
-	register int shift, direction;
-	register tgt_au_t *dp = data;
-
-	fieldsz -= 1;	/* avoid nastiness with 32-bit shift of 32-bit value */
-	/* * collect up enough bits to contain the desired field */
-	if (TARGET_BIG_ENDIAN) {
-		dp += (fieldsz + offset) >> LOG_TGTAU_BITS;
-		direction = -1;
-	} else
-		direction = 1;
-	objval = *dp >> offset;
-	shift = TGTAU_BITS - offset;
-	while (shift <= fieldsz) {
-		dp += direction;
-		objval += (rvalue) *dp << shift;
-		shift += TGTAU_BITS;
-	}
-
-	/* * sign or zero extend the value appropriately */
-	if (sgn == ROP_UNS)
-		objval &= (2 << fieldsz) - 1;
-	else {
-		shift = sizeof(rvalue) * BITS_PER_AU - 1 - fieldsz;
-		objval = (objval << shift) >> shift;
-	}
-
-	return objval;
-
-}				/* dload_unpack */
-
-/**************************************************************************
- * Procedure dload_repack
- *
- * Parameters:
- *	val		Value to insert
- *	data	Pointer to storage unit containing lowest host address of
- * 		image data
- *	fieldsz	Size of bit field, 0 < fieldsz <= sizeof(rvalue)*BITS_PER_AU
- *	offset	Offset from LSB, 0 <= offset < BITS_PER_AU
- *	sgn	Signedness of the field (ROP_SGN, ROP_UNS, ROP_MAX, ROP_ANY)
- *
- * Effect:
- *	Stuffs the specified value in the specified field.  Returns 0 for
- *	success
- * or 1 if the value will not fit in the specified field according to the
- * specified signedness rule.
- ************************************************************************* */
-static const unsigned char ovf_limit[] = { 1, 2, 2 };
-
-int dload_repack(struct dload_state *dlthis, rvalue val, tgt_au_t *data,
-		 int fieldsz, int offset, unsigned sgn)
-{
-	register urvalue objval, mask;
-	register int shift, direction;
-	register tgt_au_t *dp = data;
-
-	fieldsz -= 1;	/* avoid nastiness with 32-bit shift of 32-bit value */
-	/* clip the bits */
-	mask = (2UL << fieldsz) - 1;
-	objval = (val & mask);
-	/* * store the bits through the specified mask */
-	if (TARGET_BIG_ENDIAN) {
-		dp += (fieldsz + offset) >> LOG_TGTAU_BITS;
-		direction = -1;
-	} else
-		direction = 1;
-
-	/* insert LSBs */
-	*dp = (*dp & ~(mask << offset)) + (objval << offset);
-	shift = TGTAU_BITS - offset;
-	/* align mask and objval with AU boundary */
-	objval >>= shift;
-	mask >>= shift;
-
-	while (mask) {
-		dp += direction;
-		*dp = (*dp & ~mask) + objval;
-		objval >>= TGTAU_BITS;
-		mask >>= TGTAU_BITS;
-	}
-
-	/*
-	 * check for overflow
-	 */
-	if (sgn) {
-		unsigned tmp = (val >> fieldsz) + (sgn & 0x1);
-
-		if (tmp > ovf_limit[sgn - 1])
-			return 1;
-	}
-	return 0;
-
-}				/* dload_repack */
-
-/* lookup table for the scaling amount in a C6x instruction */
-#if TMS32060
-#define SCALE_BITS 4		/* there are 4 bits in the scale field */
-#define SCALE_MASK 0x7		/* we really only use the bottom 3 bits */
-static const u8 c60_scale[SCALE_MASK + 1] = {
-	1, 0, 0, 0, 1, 1, 2, 2
-};
-#endif
-
-/**************************************************************************
- * Procedure dload_relocate
- *
- * Parameters:
- *	data	Pointer to base of image data
- *	rp		Pointer to relocation operation
- *
- * Effect:
- *	Performs the specified relocation operation
- ************************************************************************* */
-void dload_relocate(struct dload_state *dlthis, tgt_au_t *data,
-		    struct reloc_record_t *rp, bool *tramps_generated,
-		    bool second_pass)
-{
-	rvalue val, reloc_amt, orig_val = 0;
-	unsigned int fieldsz = 0;
-	unsigned int offset = 0;
-	unsigned int reloc_info = 0;
-	unsigned int reloc_action = 0;
-	register int rx = 0;
-	rvalue *stackp = NULL;
-	int top;
-	struct local_symbol *svp = NULL;
-#ifdef RFV_SCALE
-	unsigned int scale = 0;
-#endif
-	struct image_packet_t *img_pkt = NULL;
-
-	/* The image packet data struct is only used during first pass
-	 * relocation in the event that a trampoline is needed.  2nd pass
-	 * relocation doesn't guarantee that data is coming from an
-	 * image_packet_t structure. See cload.c, dload_data for how img_data is
-	 * set. If that changes this needs to be updated!!! */
-	if (second_pass == false)
-		img_pkt = (struct image_packet_t *)((u8 *) data -
-						    sizeof(struct
-							   image_packet_t));
-
-	rx = HASH_FUNC(rp->TYPE);
-	while (rop_map1[rx] != rp->TYPE) {
-		rx = HASH_L(rop_map2[rx]);
-		if (rx < 0) {
-#if TMS32060
-			switch (rp->TYPE) {
-			case R_C60ALIGN:
-			case R_C60NOCMP:
-			case R_C60FPHEAD:
-				/* Ignore these reloc types and return */
-				break;
-			default:
-				/* Unknown reloc type, print error and return */
-				dload_error(dlthis, "Bad coff operator 0x%x",
-					    rp->TYPE);
-			}
-#else
-			dload_error(dlthis, "Bad coff operator 0x%x", rp->TYPE);
-#endif
-			return;
-		}
-	}
-	rx = HASH_I(rop_map2[rx]);
-	if ((rx < (sizeof(rop_action) / sizeof(u16)))
-	    && (rx < (sizeof(rop_info) / sizeof(u16))) && (rx > 0)) {
-		reloc_action = rop_action[rx];
-		reloc_info = rop_info[rx];
-	} else {
-		dload_error(dlthis, "Buffer Overflow - Array Index Out "
-			    "of Bounds");
-	}
-
-	/* Compute the relocation amount for the referenced symbol, if any */
-	reloc_amt = rp->UVAL;
-	if (RFV_SYM(reloc_info)) {	/* relocation uses a symbol reference */
-		/* If this is first pass, use the module local symbol table,
-		 * else use the trampoline symbol table. */
-		if (second_pass == false) {
-			if ((u32) rp->SYMNDX < dlthis->dfile_hdr.df_no_syms) {
-				/* real symbol reference */
-				svp = &dlthis->local_symtab[rp->SYMNDX];
-				reloc_amt = (RFV_SYM(reloc_info) == ROP_SYMD) ?
-				    svp->delta : svp->value;
-			}
-			/* reloc references current section */
-			else if (rp->SYMNDX == -1) {
-				reloc_amt = (RFV_SYM(reloc_info) == ROP_SYMD) ?
-				    dlthis->delta_runaddr :
-				    dlthis->image_secn->run_addr;
-			}
-		}
-	}
-	/* relocation uses a symbol reference */
-	/* Handle stack adjustment */
-	val = 0;
-	top = RFV_STK(reloc_info);
-	if (top) {
-		top += dlthis->relstkidx - RSTK_UOP;
-		if (top >= STATIC_EXPR_STK_SIZE) {
-			dload_error(dlthis,
-				    "Expression stack overflow in %s at offset "
-				    FMT_UI32, dlthis->image_secn->name,
-				    rp->vaddr + dlthis->image_offset);
-			return;
-		}
-		val = dlthis->relstk[dlthis->relstkidx];
-		dlthis->relstkidx = top;
-		stackp = &dlthis->relstk[top];
-	}
-	/* Derive field position and size, if we need them */
-	if (reloc_info & ROP_RW) {	/* read or write action in our future */
-		fieldsz = RFV_WIDTH(reloc_action);
-		if (fieldsz) {	/* field info from table */
-			offset = RFV_POSN(reloc_action);
-			if (TARGET_BIG_ENDIAN)
-				/* make sure vaddr is the lowest target
-				 * address containing bits */
-				rp->vaddr += RFV_BIGOFF(reloc_info);
-		} else {	/* field info from relocation op */
-			fieldsz = rp->FIELDSZ;
-			offset = rp->OFFSET;
-			if (TARGET_BIG_ENDIAN)
-				/* make sure vaddr is the lowest target
-				   address containing bits */
-				rp->vaddr += (rp->WORDSZ - offset - fieldsz)
-				    >> LOG_TARGET_AU_BITS;
-		}
-		data = (tgt_au_t *) ((char *)data + TADDR_TO_HOST(rp->vaddr));
-		/* compute lowest host location of referenced data */
-#if BITS_PER_AU > TARGET_AU_BITS
-		/* conversion from target address to host address may lose
-		   address bits; add loss to offset */
-		if (TARGET_BIG_ENDIAN) {
-			offset += -((rp->vaddr << LOG_TARGET_AU_BITS) +
-				    offset + fieldsz) &
-			    (BITS_PER_AU - TARGET_AU_BITS);
-		} else {
-			offset += (rp->vaddr << LOG_TARGET_AU_BITS) &
-			    (BITS_PER_AU - 1);
-		}
-#endif
-#ifdef RFV_SCALE
-		scale = RFV_SCALE(reloc_info);
-#endif
-	}
-	/* read the object value from the current image, if so ordered */
-	if (reloc_info & ROP_R) {
-		/* relocation reads current image value */
-		val = dload_unpack(dlthis, data, fieldsz, offset,
-				   RFV_SIGN(reloc_info));
-		/* Save off the original value in case the relo overflows and
-		 * we can trampoline it. */
-		orig_val = val;
-
-#ifdef RFV_SCALE
-		val <<= scale;
-#endif
-	}
-	/* perform the necessary arithmetic */
-	switch (RFV_ACTION(reloc_action)) {	/* relocation actions */
-	case RACT_VAL:
-		break;
-	case RACT_ASGN:
-		val = reloc_amt;
-		break;
-	case RACT_ADD:
-		val += reloc_amt;
-		break;
-	case RACT_PCR:
-		/*-----------------------------------------------------------
-		 * Handle special cases of jumping from absolute sections
-		 * (special reloc type) or to absolute destination
-		 * (symndx == -1).  In either case, set the appropriate
-		 * relocation amount to 0.
-		 *----------------------------------------------------------- */
-		if (rp->SYMNDX == -1)
-			reloc_amt = 0;
-		val += reloc_amt - dlthis->delta_runaddr;
-		break;
-	case RACT_ADDISP:
-		val += rp->R_DISP + reloc_amt;
-		break;
-	case RACT_ASGPC:
-		val = dlthis->image_secn->run_addr + reloc_amt;
-		break;
-	case RACT_PLUS:
-		if (stackp != NULL)
-			val += *stackp;
-		break;
-	case RACT_SUB:
-		if (stackp != NULL)
-			val = *stackp - val;
-		break;
-	case RACT_NEG:
-		val = -val;
-		break;
-	case RACT_MPY:
-		if (stackp != NULL)
-			val *= *stackp;
-		break;
-	case RACT_DIV:
-		if (stackp != NULL)
-			val = *stackp / val;
-		break;
-	case RACT_MOD:
-		if (stackp != NULL)
-			val = *stackp % val;
-		break;
-	case RACT_SR:
-		if (val >= sizeof(rvalue) * BITS_PER_AU)
-			val = 0;
-		else if (stackp != NULL)
-			val = (urvalue) *stackp >> val;
-		break;
-	case RACT_ASR:
-		if (val >= sizeof(rvalue) * BITS_PER_AU)
-			val = sizeof(rvalue) * BITS_PER_AU - 1;
-		else if (stackp != NULL)
-			val = *stackp >> val;
-		break;
-	case RACT_SL:
-		if (val >= sizeof(rvalue) * BITS_PER_AU)
-			val = 0;
-		else if (stackp != NULL)
-			val = *stackp << val;
-		break;
-	case RACT_AND:
-		if (stackp != NULL)
-			val &= *stackp;
-		break;
-	case RACT_OR:
-		if (stackp != NULL)
-			val |= *stackp;
-		break;
-	case RACT_XOR:
-		if (stackp != NULL)
-			val ^= *stackp;
-		break;
-	case RACT_NOT:
-		val = ~val;
-		break;
-#if TMS32060
-	case RACT_C6SECT:
-		/* actually needed address of secn containing symbol */
-		if (svp != NULL) {
-			if (rp->SYMNDX >= 0)
-				if (svp->secnn > 0)
-					reloc_amt = dlthis->ldr_sections
-					    [svp->secnn - 1].run_addr;
-		}
-		/* !!! FALL THRU !!! */
-	case RACT_C6BASE:
-		if (dlthis->bss_run_base == 0) {
-			struct dynload_symbol *symp;
-
-			symp = dlthis->mysym->find_matching_symbol
-			    (dlthis->mysym, bsssymbol);
-			/* lookup value of global BSS base */
-			if (symp)
-				dlthis->bss_run_base = symp->value;
-			else
-				dload_error(dlthis,
-					    "Global BSS base referenced in %s "
-					    "offset" FMT_UI32 " but not "
-					    "defined",
-					    dlthis->image_secn->name,
-					    rp->vaddr + dlthis->image_offset);
-		}
-		reloc_amt -= dlthis->bss_run_base;
-		/* !!! FALL THRU !!! */
-	case RACT_C6DSPL:
-		/* scale factor determined by 3 LSBs of field */
-		scale = c60_scale[val & SCALE_MASK];
-		offset += SCALE_BITS;
-		fieldsz -= SCALE_BITS;
-		val >>= SCALE_BITS;	/* ignore the scale field hereafter */
-		val <<= scale;
-		val += reloc_amt;	/* do the usual relocation */
-		if (((1 << scale) - 1) & val)
-			dload_error(dlthis,
-				    "Unaligned reference in %s offset "
-				    FMT_UI32, dlthis->image_secn->name,
-				    rp->vaddr + dlthis->image_offset);
-		break;
-#endif
-	}			/* relocation actions */
-	/* * Put back result as required */
-	if (reloc_info & ROP_W) {	/* relocation writes image value */
-#ifdef RFV_SCALE
-		val >>= scale;
-#endif
-		if (dload_repack(dlthis, val, data, fieldsz, offset,
-				 RFV_SIGN(reloc_info))) {
-			/* Check to see if this relo can be trampolined,
-			 * but only in first phase relocation.  2nd phase
-			 * relocation cannot trampoline. */
-			if ((second_pass == false) &&
-			    (dload_tramp_avail(dlthis, rp) == true)) {
-
-				/* Before generating the trampoline, restore
-				 * the value to its original so the 2nd pass
-				 *  relo will work. */
-				dload_repack(dlthis, orig_val, data, fieldsz,
-					     offset, RFV_SIGN(reloc_info));
-				if (!dload_tramp_generate(dlthis,
-							(dlthis->image_secn -
-							 dlthis->ldr_sections),
-							 dlthis->image_offset,
-							 img_pkt, rp)) {
-					dload_error(dlthis,
-						    "Failed to "
-						    "generate trampoline for "
-						    "bit overflow");
-					dload_error(dlthis,
-						    "Relocation val " FMT_UI32
-						    " overflows %d bits in %s "
-						    "offset " FMT_UI32, val,
-						    fieldsz,
-						    dlthis->image_secn->name,
-						    dlthis->image_offset +
-						    rp->vaddr);
-				} else
-					*tramps_generated = true;
-			} else {
-				dload_error(dlthis, "Relocation value "
-					    FMT_UI32 " overflows %d bits in %s"
-					    " offset " FMT_UI32, val, fieldsz,
-					    dlthis->image_secn->name,
-					    dlthis->image_offset + rp->vaddr);
-			}
-		}
-	} else if (top)
-		*stackp = val;
-}				/* reloc_value */
diff --git a/drivers/staging/tidspbridge/dynload/reloc_table.h b/drivers/staging/tidspbridge/dynload/reloc_table.h
deleted file mode 100644
index 6aab03d..0000000
--- a/drivers/staging/tidspbridge/dynload/reloc_table.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * reloc_table.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _RELOC_TABLE_H_
-#define _RELOC_TABLE_H_
-/*
- * Table of relocation operator properties
- */
-#include <linux/types.h>
-
-/* How does this relocation operation access the program image? */
-#define ROP_N	0		/* does not access image */
-#define ROP_R	1		/* read from image */
-#define ROP_W	2		/* write to image */
-#define ROP_RW	3		/* read from and write to image */
-
-/* For program image access, what are the overflow rules for the bit field? */
-/* Beware! Procedure repack depends on this encoding */
-#define ROP_ANY	0		/* no overflow ever, just truncate the value */
-#define ROP_SGN	1		/* signed field */
-#define ROP_UNS	2		/* unsigned field */
-#define ROP_MAX 3	/* allow maximum range of either signed or unsigned */
-
-/* How does the relocation operation use the symbol reference */
-#define ROP_IGN	0		/* no symbol is referenced */
-#define ROP_LIT 0		/* use rp->UVAL literal field */
-#define ROP_SYM	1		/* symbol value is used in relocation */
-#define ROP_SYMD 2		/* delta value vs last link is used */
-
-/* How does the reloc op use the stack? */
-#define RSTK_N 0		/* Does not use */
-#define RSTK_POP 1		/* Does a POP */
-#define RSTK_UOP 2		/* Unary op, stack position unaffected */
-#define RSTK_PSH 3		/* Does a push */
-
-/*
- * Computational actions performed by the dynamic loader
- */
-enum dload_actions {
-	/* don't alter the current val (from stack or mem fetch) */
-	RACT_VAL,
-	/* set value to reference amount (from symbol reference) */
-	RACT_ASGN,
-	RACT_ADD,		/* add reference to value */
-	RACT_PCR,		/* add reference minus PC delta to value */
-	RACT_ADDISP,		/* add reference plus R_DISP */
-	RACT_ASGPC,		/* set value to section addr plus reference */
-
-	RACT_PLUS,		/* stack + */
-	RACT_SUB,		/* stack - */
-	RACT_NEG,		/* stack unary - */
-
-	RACT_MPY,		/* stack * */
-	RACT_DIV,		/* stack / */
-	RACT_MOD,		/* stack % */
-
-	RACT_SR,		/* stack unsigned >> */
-	RACT_ASR,		/* stack signed >> */
-	RACT_SL,		/* stack << */
-	RACT_AND,		/* stack & */
-	RACT_OR,		/* stack | */
-	RACT_XOR,		/* stack ^ */
-	RACT_NOT,		/* stack ~ */
-	RACT_C6SECT,		/* for C60 R_SECT op */
-	RACT_C6BASE,		/* for C60 R_BASE op */
-	RACT_C6DSPL,		/* for C60 scaled 15-bit displacement */
-	RACT_PCR23T		/* for ARM Thumb long branch */
-};
-
-/*
- * macros used to extract values
- */
-#define RFV_POSN(aaa) ((aaa) & 0xF)
-#define RFV_WIDTH(aaa) (((aaa) >> 4) & 0x3F)
-#define RFV_ACTION(aaa) ((aaa) >> 10)
-
-#define RFV_SIGN(iii) (((iii) >> 2) & 0x3)
-#define RFV_SYM(iii) (((iii) >> 4) & 0x3)
-#define RFV_STK(iii) (((iii) >> 6) & 0x3)
-#define RFV_ACCS(iii) ((iii) & 0x3)
-
-#if (TMS32060)
-#define RFV_SCALE(iii) ((iii) >> 11)
-#define RFV_BIGOFF(iii) (((iii) >> 8) & 0x7)
-#else
-#define RFV_BIGOFF(iii) ((iii) >> 8)
-#endif
-
-#endif /* _RELOC_TABLE_H_ */
diff --git a/drivers/staging/tidspbridge/dynload/reloc_table_c6000.c b/drivers/staging/tidspbridge/dynload/reloc_table_c6000.c
deleted file mode 100644
index a28bc04..0000000
--- a/drivers/staging/tidspbridge/dynload/reloc_table_c6000.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * reloc_table_c6000.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/* Tables generated for c6000 */
-
-#define HASH_FUNC(zz) (((((zz) + 1) * 1845UL) >> 11) & 63)
-#define HASH_L(zz) ((zz) >> 8)
-#define HASH_I(zz) ((zz) & 0xFF)
-
-static const u16 rop_map1[] = {
-	0,
-	1,
-	2,
-	20,
-	4,
-	5,
-	6,
-	15,
-	80,
-	81,
-	82,
-	83,
-	84,
-	85,
-	86,
-	87,
-	17,
-	18,
-	19,
-	21,
-	16,
-	16394,
-	16404,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	32,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	40,
-	112,
-	113,
-	65535,
-	16384,
-	16385,
-	16386,
-	16387,
-	16388,
-	16389,
-	16390,
-	16391,
-	16392,
-	16393,
-	16395,
-	16396,
-	16397,
-	16398,
-	16399,
-	16400,
-	16401,
-	16402,
-	16403,
-	16405,
-	16406,
-	65535,
-	65535,
-	65535
-};
-
-static const s16 rop_map2[] = {
-	-256,
-	-255,
-	-254,
-	-245,
-	-253,
-	-252,
-	-251,
-	-250,
-	-241,
-	-240,
-	-239,
-	-238,
-	-237,
-	-236,
-	1813,
-	5142,
-	-248,
-	-247,
-	778,
-	-244,
-	-249,
-	-221,
-	-211,
-	-1,
-	-1,
-	-1,
-	-1,
-	-1,
-	-1,
-	-243,
-	-1,
-	-1,
-	-1,
-	-1,
-	-1,
-	-1,
-	-242,
-	-233,
-	-232,
-	-1,
-	-231,
-	-230,
-	-229,
-	-228,
-	-227,
-	-226,
-	-225,
-	-224,
-	-223,
-	5410,
-	-220,
-	-219,
-	-218,
-	-217,
-	-216,
-	-215,
-	-214,
-	-213,
-	5676,
-	-210,
-	-209,
-	-1,
-	-1,
-	-1
-};
-
-static const u16 rop_action[] = {
-	2560,
-	2304,
-	2304,
-	2432,
-	2432,
-	2560,
-	2176,
-	2304,
-	2560,
-	3200,
-	3328,
-	3584,
-	3456,
-	2304,
-	4208,
-	20788,
-	21812,
-	3415,
-	3245,
-	2311,
-	4359,
-	19764,
-	2311,
-	3191,
-	3280,
-	6656,
-	7680,
-	8704,
-	9728,
-	10752,
-	11776,
-	12800,
-	13824,
-	14848,
-	15872,
-	16896,
-	17920,
-	18944,
-	0,
-	0,
-	0,
-	0,
-	1536,
-	1536,
-	1536,
-	5632,
-	512,
-	0
-};
-
-static const u16 rop_info[] = {
-	0,
-	35,
-	35,
-	35,
-	35,
-	35,
-	35,
-	35,
-	35,
-	39,
-	39,
-	39,
-	39,
-	35,
-	34,
-	283,
-	299,
-	4135,
-	4391,
-	291,
-	33059,
-	283,
-	295,
-	4647,
-	4135,
-	64,
-	64,
-	128,
-	64,
-	64,
-	64,
-	64,
-	64,
-	64,
-	64,
-	64,
-	64,
-	128,
-	201,
-	197,
-	74,
-	70,
-	208,
-	196,
-	200,
-	192,
-	192,
-	66
-};
diff --git a/drivers/staging/tidspbridge/dynload/tramp.c b/drivers/staging/tidspbridge/dynload/tramp.c
deleted file mode 100644
index 5f04313..0000000
--- a/drivers/staging/tidspbridge/dynload/tramp.c
+++ /dev/null
@@ -1,1143 +0,0 @@
-/*
- * tramp.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2009 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include "header.h"
-
-#if TMS32060
-#include "tramp_table_c6000.c"
-#endif
-
-#define MAX_RELOS_PER_PASS	4
-
-/*
- * Function:	priv_tramp_sect_tgt_alloc
- * Description: Allocate target memory for the trampoline section.  The
- *	  target mem size is easily obtained as the next available address.
- */
-static int priv_tramp_sect_tgt_alloc(struct dload_state *dlthis)
-{
-	int ret_val = 0;
-	struct ldr_section_info *sect_info;
-
-	/*  Populate the trampoline loader section and allocate it on the
-	 * target.  The section name is ALWAYS the first string in the final
-	 * string table for trampolines.  The trampoline section is always
-	 * 1 beyond the total number of allocated sections. */
-	sect_info = &dlthis->ldr_sections[dlthis->allocated_secn_count];
-
-	sect_info->name = dlthis->tramp.final_string_table;
-	sect_info->size = dlthis->tramp.tramp_sect_next_addr;
-	sect_info->context = 0;
-	sect_info->type =
-	    (4 << 8) | DLOAD_TEXT | DS_ALLOCATE_MASK | DS_DOWNLOAD_MASK;
-	sect_info->page = 0;
-	sect_info->run_addr = 0;
-	sect_info->load_addr = 0;
-	ret_val = dlthis->myalloc->dload_allocate(dlthis->myalloc,
-						  sect_info,
-						  ds_alignment
-						  (sect_info->type));
-
-	if (ret_val == 0)
-		dload_error(dlthis, "Failed to allocate target memory for"
-			    " trampoline");
-
-	return ret_val;
-}
-
-/*
- * Function:	priv_h2a
- * Description: Helper function to convert a hex value to its ASCII
- *	  representation.  Used for trampoline symbol name generation.
- */
-static u8 priv_h2a(u8 value)
-{
-	if (value > 0xF)
-		return 0xFF;
-
-	if (value <= 9)
-		value += 0x30;
-	else
-		value += 0x37;
-
-	return value;
-}
-
-/*
- * Function:	priv_tramp_sym_gen_name
- * Description: Generate a trampoline symbol name (ASCII) using the value
- *	  of the symbol.  This places the new name into the user buffer.
- *	  The name is fixed in length and of the form: __$dbTR__xxxxxxxx
- *	  (where "xxxxxxxx" is the hex value).
- */
-static void priv_tramp_sym_gen_name(u32 value, char *dst)
-{
-	u32 i;
-	char *prefix = TRAMP_SYM_PREFIX;
-	char *dst_local = dst;
-	u8 tmp;
-
-	/*  Clear out the destination, including the ending NULL */
-	for (i = 0; i < (TRAMP_SYM_PREFIX_LEN + TRAMP_SYM_HEX_ASCII_LEN); i++)
-		*(dst_local + i) = 0;
-
-	/*  Copy the prefix to start */
-	for (i = 0; i < strlen(TRAMP_SYM_PREFIX); i++) {
-		*dst_local = *(prefix + i);
-		dst_local++;
-	}
-
-	/*  Now convert the value passed in to a string equiv of the hex */
-	for (i = 0; i < sizeof(value); i++) {
-#ifndef _BIG_ENDIAN
-		tmp = *(((u8 *) &value) + (sizeof(value) - 1) - i);
-		*dst_local = priv_h2a((tmp & 0xF0) >> 4);
-		dst_local++;
-		*dst_local = priv_h2a(tmp & 0x0F);
-		dst_local++;
-#else
-		tmp = *(((u8 *) &value) + i);
-		*dst_local = priv_h2a((tmp & 0xF0) >> 4);
-		dst_local++;
-		*dst_local = priv_h2a(tmp & 0x0F);
-		dst_local++;
-#endif
-	}
-
-	/*  NULL terminate */
-	*dst_local = 0;
-}
-
-/*
- * Function:	priv_tramp_string_create
- * Description: Create a new string specific to the trampoline loading and add
- *	  it to the trampoline string list.  This list contains the
- *	  trampoline section name and trampoline point symbols.
- */
-static struct tramp_string *priv_tramp_string_create(struct dload_state *dlthis,
-						     u32 str_len, char *str)
-{
-	struct tramp_string *new_string = NULL;
-	u32 i;
-
-	/*  Create a new string object with the specified size. */
-	new_string =
-	    (struct tramp_string *)dlthis->mysym->dload_allocate(dlthis->mysym,
-								 (sizeof
-								  (struct
-								   tramp_string)
-								  + str_len +
-								  1));
-	if (new_string != NULL) {
-		/*  Clear the string first.  This ensures the ending NULL is
-		 * present and the optimizer won't touch it. */
-		for (i = 0; i < (sizeof(struct tramp_string) + str_len + 1);
-		     i++)
-			*((u8 *) new_string + i) = 0;
-
-		/*  Add this string to our virtual table by assigning it the
-		 * next index and pushing it to the tail of the list. */
-		new_string->index = dlthis->tramp.tramp_string_next_index;
-		dlthis->tramp.tramp_string_next_index++;
-		dlthis->tramp.tramp_string_size += str_len + 1;
-
-		new_string->next = NULL;
-		if (dlthis->tramp.string_head == NULL)
-			dlthis->tramp.string_head = new_string;
-		else
-			dlthis->tramp.string_tail->next = new_string;
-
-		dlthis->tramp.string_tail = new_string;
-
-		/*  Copy the string over to the new object */
-		for (i = 0; i < str_len; i++)
-			new_string->str[i] = str[i];
-	}
-
-	return new_string;
-}
-
-/*
- * Function:	priv_tramp_string_find
- * Description: Walk the trampoline string list and find a match for the
- *	  provided string.  If not match is found, NULL is returned.
- */
-static struct tramp_string *priv_tramp_string_find(struct dload_state *dlthis,
-						   char *str)
-{
-	struct tramp_string *cur_str = NULL;
-	struct tramp_string *ret_val = NULL;
-	u32 i;
-	u32 str_len = strlen(str);
-
-	for (cur_str = dlthis->tramp.string_head;
-	     (ret_val == NULL) && (cur_str != NULL); cur_str = cur_str->next) {
-		/*  If the string lengths aren't equal, don't bother
-		 * comparing */
-		if (str_len != strlen(cur_str->str))
-			continue;
-
-		/*  Walk the strings until one of them ends */
-		for (i = 0; i < str_len; i++) {
-			/*  If they don't match in the current position then
-			 * break out now, no sense in continuing to look at
-			 * this string. */
-			if (str[i] != cur_str->str[i])
-				break;
-		}
-
-		if (i == str_len)
-			ret_val = cur_str;
-	}
-
-	return ret_val;
-}
-
-/*
- * Function:	priv_string_tbl_finalize
- * Description: Flatten the trampoline string list into a table of NULL
- *	  terminated strings.  This is the same format of string table
- *	  as used by the COFF/DOFF file.
- */
-static int priv_string_tbl_finalize(struct dload_state *dlthis)
-{
-	int ret_val = 0;
-	struct tramp_string *cur_string;
-	char *cur_loc;
-	char *tmp;
-
-	/*  Allocate enough space for all strings that have been created.  The
-	 * table is simply all strings concatenated together will NULL
-	 * endings. */
-	dlthis->tramp.final_string_table =
-	    (char *)dlthis->mysym->dload_allocate(dlthis->mysym,
-						  dlthis->tramp.
-						  tramp_string_size);
-	if (dlthis->tramp.final_string_table != NULL) {
-		/*  We got our buffer, walk the list and release the nodes as*
-		 * we go */
-		cur_loc = dlthis->tramp.final_string_table;
-		cur_string = dlthis->tramp.string_head;
-		while (cur_string != NULL) {
-			/*  Move the head/tail pointers */
-			dlthis->tramp.string_head = cur_string->next;
-			if (dlthis->tramp.string_tail == cur_string)
-				dlthis->tramp.string_tail = NULL;
-
-			/*  Copy the string contents */
-			for (tmp = cur_string->str;
-			     *tmp != '\0'; tmp++, cur_loc++)
-				*cur_loc = *tmp;
-
-			/*  Pick up the NULL termination since it was missed by
-			 * breaking using it to end the above loop. */
-			*cur_loc = '\0';
-			cur_loc++;
-
-			/*  Free the string node, we don't need it any more. */
-			dlthis->mysym->dload_deallocate(dlthis->mysym,
-							cur_string);
-
-			/*  Move our pointer to the next one */
-			cur_string = dlthis->tramp.string_head;
-		}
-
-		/*  Update our return value to success */
-		ret_val = 1;
-	} else
-		dload_error(dlthis, "Failed to allocate trampoline "
-			    "string table");
-
-	return ret_val;
-}
-
-/*
- * Function:	priv_tramp_sect_alloc
- * Description: Virtually allocate space from the trampoline section.  This
- *	  function returns the next offset within the trampoline section
- *	  that is available and moved the next available offset by the
- *	  requested size.  NO TARGET ALLOCATION IS DONE AT THIS TIME.
- */
-static u32 priv_tramp_sect_alloc(struct dload_state *dlthis, u32 tramp_size)
-{
-	u32 ret_val;
-
-	/*  If the next available address is 0, this is our first allocation.
-	 * Create a section name string to go into the string table . */
-	if (dlthis->tramp.tramp_sect_next_addr == 0) {
-		dload_syms_error(dlthis->mysym, "*** WARNING ***  created "
-				 "dynamic TRAMPOLINE section for module %s",
-				 dlthis->str_head);
-	}
-
-	/*  Reserve space for the new trampoline */
-	ret_val = dlthis->tramp.tramp_sect_next_addr;
-	dlthis->tramp.tramp_sect_next_addr += tramp_size;
-	return ret_val;
-}
-
-/*
- * Function:	priv_tramp_sym_create
- * Description: Allocate and create a new trampoline specific symbol and add
- *	  it to the trampoline symbol list.  These symbols will include
- *	  trampoline points as well as the external symbols they
- *	  reference.
- */
-static struct tramp_sym *priv_tramp_sym_create(struct dload_state *dlthis,
-					       u32 str_index,
-					       struct local_symbol *tmp_sym)
-{
-	struct tramp_sym *new_sym = NULL;
-	u32 i;
-
-	/*  Allocate new space for the symbol in the symbol table. */
-	new_sym =
-	    (struct tramp_sym *)dlthis->mysym->dload_allocate(dlthis->mysym,
-					      sizeof(struct tramp_sym));
-	if (new_sym != NULL) {
-		for (i = 0; i != sizeof(struct tramp_sym); i++)
-			*((char *)new_sym + i) = 0;
-
-		/*  Assign this symbol the next symbol index for easier
-		 * reference later during relocation. */
-		new_sym->index = dlthis->tramp.tramp_sym_next_index;
-		dlthis->tramp.tramp_sym_next_index++;
-
-		/*  Populate the symbol information.  At this point any
-		 * trampoline symbols will be the offset location, not the
-		 * final.  Copy over the symbol info to start, then be sure to
-		 * get the string index from the trampoline string table. */
-		new_sym->sym_info = *tmp_sym;
-		new_sym->str_index = str_index;
-
-		/*  Push the new symbol to the tail of the symbol table list */
-		new_sym->next = NULL;
-		if (dlthis->tramp.symbol_head == NULL)
-			dlthis->tramp.symbol_head = new_sym;
-		else
-			dlthis->tramp.symbol_tail->next = new_sym;
-
-		dlthis->tramp.symbol_tail = new_sym;
-	}
-
-	return new_sym;
-}
-
-/*
- * Function:	priv_tramp_sym_get
- * Description: Search for the symbol with the matching string index (from
- *	  the trampoline string table) and return the trampoline
- *	  symbol object, if found.  Otherwise return NULL.
- */
-static struct tramp_sym *priv_tramp_sym_get(struct dload_state *dlthis,
-					    u32 string_index)
-{
-	struct tramp_sym *sym_found = NULL;
-
-	/*  Walk the symbol table list and search vs. the string index */
-	for (sym_found = dlthis->tramp.symbol_head;
-	     sym_found != NULL; sym_found = sym_found->next) {
-		if (sym_found->str_index == string_index)
-			break;
-	}
-
-	return sym_found;
-}
-
-/*
- * Function:	priv_tramp_sym_find
- * Description: Search for a trampoline symbol based on the string name of
- *	  the symbol.  Return the symbol object, if found, otherwise
- *	  return NULL.
- */
-static struct tramp_sym *priv_tramp_sym_find(struct dload_state *dlthis,
-					     char *string)
-{
-	struct tramp_sym *sym_found = NULL;
-	struct tramp_string *str_found = NULL;
-
-	/*  First, search for the string, then search for the sym based on the
-	   string index. */
-	str_found = priv_tramp_string_find(dlthis, string);
-	if (str_found != NULL)
-		sym_found = priv_tramp_sym_get(dlthis, str_found->index);
-
-	return sym_found;
-}
-
-/*
- * Function:	priv_tramp_sym_finalize
- * Description: Allocate a flat symbol table for the trampoline section,
- *	  put each trampoline symbol into the table, adjust the
- *	  symbol value based on the section address on the target and
- *	  free the trampoline symbol list nodes.
- */
-static int priv_tramp_sym_finalize(struct dload_state *dlthis)
-{
-	int ret_val = 0;
-	struct tramp_sym *cur_sym;
-	struct ldr_section_info *tramp_sect =
-	    &dlthis->ldr_sections[dlthis->allocated_secn_count];
-	struct local_symbol *new_sym;
-
-	/*  Allocate a table to hold a flattened version of all symbols
-	 * created. */
-	dlthis->tramp.final_sym_table =
-	    (struct local_symbol *)dlthis->mysym->dload_allocate(dlthis->mysym,
-				 (sizeof(struct local_symbol) * dlthis->tramp.
-						  tramp_sym_next_index));
-	if (dlthis->tramp.final_sym_table != NULL) {
-		/*  Walk the list of all symbols, copy it over to the flattened
-		 * table. After it has been copied, the node can be freed as
-		 * it is no longer needed. */
-		new_sym = dlthis->tramp.final_sym_table;
-		cur_sym = dlthis->tramp.symbol_head;
-		while (cur_sym != NULL) {
-			/*  Pop it off the list */
-			dlthis->tramp.symbol_head = cur_sym->next;
-			if (cur_sym == dlthis->tramp.symbol_tail)
-				dlthis->tramp.symbol_tail = NULL;
-
-			/*  Copy the symbol contents into the flat table */
-			*new_sym = cur_sym->sym_info;
-
-			/*  Now finalize the symbol.  If it is in the tramp
-			 * section, we need to adjust for the section start.
-			 * If it is external then we don't need to adjust at
-			 * all.
-			 * NOTE: THIS CODE ASSUMES THAT THE TRAMPOLINE IS
-			 * REFERENCED LIKE A CALL TO AN EXTERNAL SO VALUE AND
-			 * DELTA ARE THE SAME.  SEE THE FUNCTION dload_symbols
-			 * WHERE DN_UNDEF IS HANDLED FOR MORE REFERENCE. */
-			if (new_sym->secnn < 0) {
-				new_sym->value += tramp_sect->load_addr;
-				new_sym->delta = new_sym->value;
-			}
-
-			/*  Let go of the symbol node */
-			dlthis->mysym->dload_deallocate(dlthis->mysym, cur_sym);
-
-			/*  Move to the next node */
-			cur_sym = dlthis->tramp.symbol_head;
-			new_sym++;
-		}
-
-		ret_val = 1;
-	} else
-		dload_error(dlthis, "Failed to alloc trampoline sym table");
-
-	return ret_val;
-}
-
-/*
- * Function:	priv_tgt_img_gen
- * Description: Allocate storage for and copy the target specific image data
- *	and fix up its relocations for the new external symbol.  If
- *	a trampoline image packet was successfully created it is added
- *	to the trampoline list.
- */
-static int priv_tgt_img_gen(struct dload_state *dlthis, u32 base,
-			    u32 gen_index, struct tramp_sym *new_ext_sym)
-{
-	struct tramp_img_pkt *new_img_pkt = NULL;
-	u32 i;
-	u32 pkt_size = tramp_img_pkt_size_get();
-	u8 *gen_tbl_entry;
-	u8 *pkt_data;
-	struct reloc_record_t *cur_relo;
-	int ret_val = 0;
-
-	/*  Allocate a new image packet and set it up. */
-	new_img_pkt =
-	    (struct tramp_img_pkt *)dlthis->mysym->dload_allocate(dlthis->mysym,
-								  pkt_size);
-	if (new_img_pkt != NULL) {
-		/*  Save the base, this is where it goes in the section */
-		new_img_pkt->base = base;
-
-		/*  Copy over the image data and relos from the target table */
-		pkt_data = (u8 *) &new_img_pkt->hdr;
-		gen_tbl_entry = (u8 *) &tramp_gen_info[gen_index];
-		for (i = 0; i < pkt_size; i++) {
-			*pkt_data = *gen_tbl_entry;
-			pkt_data++;
-			gen_tbl_entry++;
-		}
-
-		/*  Update the relocations to point to the external symbol */
-		cur_relo =
-		    (struct reloc_record_t *)((u8 *) &new_img_pkt->hdr +
-					      new_img_pkt->hdr.relo_offset);
-		for (i = 0; i < new_img_pkt->hdr.num_relos; i++)
-			cur_relo[i].SYMNDX = new_ext_sym->index;
-
-		/*  Add it to the trampoline list. */
-		new_img_pkt->next = dlthis->tramp.tramp_pkts;
-		dlthis->tramp.tramp_pkts = new_img_pkt;
-
-		ret_val = 1;
-	}
-
-	return ret_val;
-}
-
-/*
- * Function:	priv_pkt_relo
- * Description: Take the provided image data and the collection of relocations
- *	  for it and perform the relocations.  Note that all relocations
- *	  at this stage are considered SECOND PASS since the original
- *	  image has already been processed in the first pass.  This means
- *	  TRAMPOLINES ARE TREATED AS 2ND PASS even though this is really
- *	  the first (and only) relocation that will be performed on them.
- */
-static int priv_pkt_relo(struct dload_state *dlthis, tgt_au_t *data,
-			 struct reloc_record_t *rp[], u32 relo_count)
-{
-	int ret_val = 1;
-	u32 i;
-	bool tmp;
-
-	/*  Walk through all of the relos and process them.  This function is
-	 * the equivalent of relocate_packet() from cload.c, but specialized
-	 * for trampolines and 2nd phase relocations. */
-	for (i = 0; i < relo_count; i++)
-		dload_relocate(dlthis, data, rp[i], &tmp, true);
-
-	return ret_val;
-}
-
-/*
- * Function:	priv_tramp_pkt_finalize
- * Description: Walk the list of all trampoline packets and finalize them.
- *	  Each trampoline image packet will be relocated now that the
- *	  trampoline section has been allocated on the target.  Once
- *	  all of the relocations are done the trampoline image data
- *	  is written into target memory and the trampoline packet
- *	  is freed: it is no longer needed after this point.
- */
-static int priv_tramp_pkt_finalize(struct dload_state *dlthis)
-{
-	int ret_val = 1;
-	struct tramp_img_pkt *cur_pkt = NULL;
-	struct reloc_record_t *relos[MAX_RELOS_PER_PASS];
-	u32 relos_done;
-	u32 i;
-	struct reloc_record_t *cur_relo;
-	struct ldr_section_info *sect_info =
-	    &dlthis->ldr_sections[dlthis->allocated_secn_count];
-
-	/*  Walk the list of trampoline packets and relocate each packet.  This
-	 * function is the trampoline equivalent of dload_data() from
-	 * cload.c. */
-	cur_pkt = dlthis->tramp.tramp_pkts;
-	while ((ret_val != 0) && (cur_pkt != NULL)) {
-		/*  Remove the pkt from the list */
-		dlthis->tramp.tramp_pkts = cur_pkt->next;
-
-		/*  Setup section and image offset information for the relo */
-		dlthis->image_secn = sect_info;
-		dlthis->image_offset = cur_pkt->base;
-		dlthis->delta_runaddr = sect_info->run_addr;
-
-		/*  Walk through all relos for the packet */
-		relos_done = 0;
-		cur_relo = (struct reloc_record_t *)((u8 *) &cur_pkt->hdr +
-						     cur_pkt->hdr.relo_offset);
-		while (relos_done < cur_pkt->hdr.num_relos) {
-#ifdef ENABLE_TRAMP_DEBUG
-			dload_syms_error(dlthis->mysym,
-					 "===> Trampoline %x branches to %x",
-					 sect_info->run_addr +
-					 dlthis->image_offset,
-					 dlthis->
-					 tramp.final_sym_table[cur_relo->
-							       SYMNDX].value);
-#endif
-
-			for (i = 0;
-			     ((i < MAX_RELOS_PER_PASS) &&
-			      ((i + relos_done) < cur_pkt->hdr.num_relos)); i++)
-				relos[i] = cur_relo + i;
-
-			/*  Do the actual relo */
-			ret_val = priv_pkt_relo(dlthis,
-						(tgt_au_t *) &cur_pkt->payload,
-						relos, i);
-			if (ret_val == 0) {
-				dload_error(dlthis,
-					    "Relocation of trampoline pkt at %x"
-					    " failed", cur_pkt->base +
-					    sect_info->run_addr);
-				break;
-			}
-
-			relos_done += i;
-			cur_relo += i;
-		}
-
-		/*  Make sure we didn't hit a problem */
-		if (ret_val != 0) {
-			/*  Relos are done for the packet, write it to the
-			 * target */
-			ret_val = dlthis->myio->writemem(dlthis->myio,
-							 &cur_pkt->payload,
-							 sect_info->load_addr +
-							 cur_pkt->base,
-							 sect_info,
-							 BYTE_TO_HOST
-							 (cur_pkt->hdr.
-							  tramp_code_size));
-			if (ret_val == 0) {
-				dload_error(dlthis,
-					    "Write to " FMT_UI32 " failed",
-					    sect_info->load_addr +
-					    cur_pkt->base);
-			}
-
-			/*  Done with the pkt, let it go */
-			dlthis->mysym->dload_deallocate(dlthis->mysym, cur_pkt);
-
-			/*  Get the next packet to process */
-			cur_pkt = dlthis->tramp.tramp_pkts;
-		}
-	}
-
-	return ret_val;
-}
-
-/*
- * Function:	priv_dup_pkt_finalize
- * Description: Walk the list of duplicate image packets and finalize them.
- *	  Each duplicate packet will be relocated again for the
- *	  relocations that previously failed and have been adjusted
- *	  to point at a trampoline.  Once all relocations for a packet
- *	  have been done, write the packet into target memory.  The
- *	  duplicate packet and its relocation chain are all freed
- *	  after use here as they are no longer needed after this.
- */
-static int priv_dup_pkt_finalize(struct dload_state *dlthis)
-{
-	int ret_val = 1;
-	struct tramp_img_dup_pkt *cur_pkt;
-	struct tramp_img_dup_relo *cur_relo;
-	struct reloc_record_t *relos[MAX_RELOS_PER_PASS];
-	struct doff_scnhdr_t *sect_hdr = NULL;
-	s32 i;
-
-	/* Similar to the trampoline pkt finalize, this function walks each dup
-	 * pkt that was generated and performs all relocations that were
-	 * deferred to a 2nd pass.  This is the equivalent of dload_data() from
-	 * cload.c, but does not need the additional reorder and checksum
-	 * processing as it has already been done. */
-	cur_pkt = dlthis->tramp.dup_pkts;
-	while ((ret_val != 0) && (cur_pkt != NULL)) {
-		/*  Remove the node from the list, we'll be freeing it
-		 * shortly */
-		dlthis->tramp.dup_pkts = cur_pkt->next;
-
-		/*  Setup the section and image offset for relocation */
-		dlthis->image_secn = &dlthis->ldr_sections[cur_pkt->secnn];
-		dlthis->image_offset = cur_pkt->offset;
-
-		/*  In order to get the delta run address, we need to reference
-		 * the original section header.  It's a bit ugly, but needed
-		 * for relo. */
-		i = (s32) (dlthis->image_secn - dlthis->ldr_sections);
-		sect_hdr = dlthis->sect_hdrs + i;
-		dlthis->delta_runaddr = sect_hdr->ds_paddr;
-
-		/*  Walk all relos in the chain and process each. */
-		cur_relo = cur_pkt->relo_chain;
-		while (cur_relo != NULL) {
-			/*  Process them a chunk at a time to be efficient */
-			for (i = 0; (i < MAX_RELOS_PER_PASS)
-			     && (cur_relo != NULL);
-			     i++, cur_relo = cur_relo->next) {
-				relos[i] = &cur_relo->relo;
-				cur_pkt->relo_chain = cur_relo->next;
-			}
-
-			/*  Do the actual relo */
-			ret_val = priv_pkt_relo(dlthis,
-						cur_pkt->img_pkt.img_data,
-						relos, i);
-			if (ret_val == 0) {
-				dload_error(dlthis,
-					    "Relocation of dup pkt at %x"
-					    " failed", cur_pkt->offset +
-					    dlthis->image_secn->run_addr);
-				break;
-			}
-
-			/*  Release all of these relos, we're done with them */
-			while (i > 0) {
-				dlthis->mysym->dload_deallocate(dlthis->mysym,
-						GET_CONTAINER
-						(relos[i - 1],
-						 struct tramp_img_dup_relo,
-						 relo));
-				i--;
-			}
-
-			/*  DO NOT ADVANCE cur_relo, IT IS ALREADY READY TO
-			 * GO! */
-		}
-
-		/* Done with all relos.  Make sure we didn't have a problem and
-		 * write it out to the target */
-		if (ret_val != 0) {
-			ret_val = dlthis->myio->writemem(dlthis->myio,
-							 cur_pkt->img_pkt.
-							 img_data,
-							 dlthis->image_secn->
-							 load_addr +
-							 cur_pkt->offset,
-							 dlthis->image_secn,
-							 BYTE_TO_HOST
-							 (cur_pkt->img_pkt.
-							  packet_size));
-			if (ret_val == 0) {
-				dload_error(dlthis,
-					    "Write to " FMT_UI32 " failed",
-					    dlthis->image_secn->load_addr +
-					    cur_pkt->offset);
-			}
-
-			dlthis->mysym->dload_deallocate(dlthis->mysym, cur_pkt);
-
-			/*  Advance to the next packet */
-			cur_pkt = dlthis->tramp.dup_pkts;
-		}
-	}
-
-	return ret_val;
-}
-
-/*
- * Function:	priv_dup_find
- * Description: Walk the list of existing duplicate packets and find a
- *	  match based on the section number and image offset.  Return
- *	  the duplicate packet if found, otherwise NULL.
- */
-static struct tramp_img_dup_pkt *priv_dup_find(struct dload_state *dlthis,
-					       s16 secnn, u32 image_offset)
-{
-	struct tramp_img_dup_pkt *cur_pkt = NULL;
-
-	for (cur_pkt = dlthis->tramp.dup_pkts;
-	     cur_pkt != NULL; cur_pkt = cur_pkt->next) {
-		if ((cur_pkt->secnn == secnn) &&
-		    (cur_pkt->offset == image_offset)) {
-			/*  Found a match, break out */
-			break;
-		}
-	}
-
-	return cur_pkt;
-}
-
-/*
- * Function:	priv_img_pkt_dup
- * Description: Duplicate the original image packet.  If this is the first
- *	  time this image packet has been seen (based on section number
- *	  and image offset), create a new duplicate packet and add it
- *	  to the dup packet list.  If not, just get the existing one and
- *	  update it with the current packet contents (since relocation
- *	  on the packet is still ongoing in first pass.)  Create a
- *	  duplicate of the provided relocation, but update it to point
- *	  to the new trampoline symbol.  Add the new relocation dup to
- *	  the dup packet's relo chain for 2nd pass relocation later.
- */
-static int priv_img_pkt_dup(struct dload_state *dlthis,
-			    s16 secnn, u32 image_offset,
-			    struct image_packet_t *ipacket,
-			    struct reloc_record_t *rp,
-			    struct tramp_sym *new_tramp_sym)
-{
-	struct tramp_img_dup_pkt *dup_pkt = NULL;
-	u32 new_dup_size;
-	s32 i;
-	int ret_val = 0;
-	struct tramp_img_dup_relo *dup_relo = NULL;
-
-	/*  Determine if this image packet is already being tracked in the
-	   dup list for other trampolines. */
-	dup_pkt = priv_dup_find(dlthis, secnn, image_offset);
-
-	if (dup_pkt == NULL) {
-		/*  This image packet does not exist in our tracking, so create
-		 * a new one and add it to the head of the list. */
-		new_dup_size = sizeof(struct tramp_img_dup_pkt) +
-		    ipacket->packet_size;
-
-		dup_pkt = (struct tramp_img_dup_pkt *)
-		    dlthis->mysym->dload_allocate(dlthis->mysym, new_dup_size);
-		if (dup_pkt != NULL) {
-			/*  Save off the section and offset information */
-			dup_pkt->secnn = secnn;
-			dup_pkt->offset = image_offset;
-			dup_pkt->relo_chain = NULL;
-
-			/*  Copy the original packet content */
-			dup_pkt->img_pkt = *ipacket;
-			dup_pkt->img_pkt.img_data = (u8 *) (dup_pkt + 1);
-			for (i = 0; i < ipacket->packet_size; i++)
-				*(dup_pkt->img_pkt.img_data + i) =
-				    *(ipacket->img_data + i);
-
-			/*  Add the packet to the dup list */
-			dup_pkt->next = dlthis->tramp.dup_pkts;
-			dlthis->tramp.dup_pkts = dup_pkt;
-		} else
-			dload_error(dlthis, "Failed to create dup packet!");
-	} else {
-		/*  The image packet contents could have changed since
-		 * trampoline detection happens during relocation of the image
-		 * packets.  So, we need to update the image packet contents
-		 * before adding relo information. */
-		for (i = 0; i < dup_pkt->img_pkt.packet_size; i++)
-			*(dup_pkt->img_pkt.img_data + i) =
-			    *(ipacket->img_data + i);
-	}
-
-	/*  Since the previous code may have allocated a new dup packet for us,
-	   double check that we actually have one. */
-	if (dup_pkt != NULL) {
-		/*  Allocate a new node for the relo chain.  Each image packet
-		 * can potentially have multiple relocations that cause a
-		 * trampoline to be generated.  So, we keep them in a chain,
-		 * order is not important. */
-		dup_relo = dlthis->mysym->dload_allocate(dlthis->mysym,
-					 sizeof(struct tramp_img_dup_relo));
-		if (dup_relo != NULL) {
-			/*  Copy the relo contents, adjust for the new
-			 * trampoline and add it to the list. */
-			dup_relo->relo = *rp;
-			dup_relo->relo.SYMNDX = new_tramp_sym->index;
-
-			dup_relo->next = dup_pkt->relo_chain;
-			dup_pkt->relo_chain = dup_relo;
-
-			/*  That's it, we're done.  Make sure we update our
-			 * return value to be success since everything finished
-			 * ok */
-			ret_val = 1;
-		} else
-			dload_error(dlthis, "Unable to alloc dup relo");
-	}
-
-	return ret_val;
-}
-
-/*
- * Function:	dload_tramp_avail
- * Description: Check to see if the target supports a trampoline for this type
- *	  of relocation.  Return true if it does, otherwise false.
- */
-bool dload_tramp_avail(struct dload_state *dlthis, struct reloc_record_t *rp)
-{
-	bool ret_val = false;
-	u16 map_index;
-	u16 gen_index;
-
-	/*  Check type hash vs. target tramp table */
-	map_index = HASH_FUNC(rp->TYPE);
-	gen_index = tramp_map[map_index];
-	if (gen_index != TRAMP_NO_GEN_AVAIL)
-		ret_val = true;
-
-	return ret_val;
-}
-
-/*
- * Function:	dload_tramp_generate
- * Description: Create a new trampoline for the provided image packet and
- *	  relocation causing problems.  This will create the trampoline
- *	  as well as duplicate/update the image packet and relocation
- *	  causing the problem, which will be relo'd again during
- *	  finalization.
- */
-int dload_tramp_generate(struct dload_state *dlthis, s16 secnn,
-			 u32 image_offset, struct image_packet_t *ipacket,
-			 struct reloc_record_t *rp)
-{
-	u16 map_index;
-	u16 gen_index;
-	int ret_val = 1;
-	char tramp_sym_str[TRAMP_SYM_PREFIX_LEN + TRAMP_SYM_HEX_ASCII_LEN];
-	struct local_symbol *ref_sym;
-	struct tramp_sym *new_tramp_sym;
-	struct tramp_sym *new_ext_sym;
-	struct tramp_string *new_tramp_str;
-	u32 new_tramp_base;
-	struct local_symbol tmp_sym;
-	struct local_symbol ext_tmp_sym;
-
-	/*  Hash the relo type to get our generator information */
-	map_index = HASH_FUNC(rp->TYPE);
-	gen_index = tramp_map[map_index];
-	if (gen_index != TRAMP_NO_GEN_AVAIL) {
-		/*  If this is the first trampoline, create the section name in
-		 * our string table for debug help later. */
-		if (dlthis->tramp.string_head == NULL) {
-			priv_tramp_string_create(dlthis,
-						 strlen(TRAMP_SECT_NAME),
-						 TRAMP_SECT_NAME);
-		}
-#ifdef ENABLE_TRAMP_DEBUG
-		dload_syms_error(dlthis->mysym,
-				 "Trampoline at img loc %x, references %x",
-				 dlthis->ldr_sections[secnn].run_addr +
-				 image_offset + rp->vaddr,
-				 dlthis->local_symtab[rp->SYMNDX].value);
-#endif
-
-		/*  Generate the trampoline string, check if already defined.
-		 * If the relo symbol index is -1, it means we need the section
-		 * info for relo later.  To do this we'll dummy up a symbol
-		 * with the section delta and run addresses. */
-		if (rp->SYMNDX == -1) {
-			ext_tmp_sym.value =
-			    dlthis->ldr_sections[secnn].run_addr;
-			ext_tmp_sym.delta = dlthis->sect_hdrs[secnn].ds_paddr;
-			ref_sym = &ext_tmp_sym;
-		} else
-			ref_sym = &(dlthis->local_symtab[rp->SYMNDX]);
-
-		priv_tramp_sym_gen_name(ref_sym->value, tramp_sym_str);
-		new_tramp_sym = priv_tramp_sym_find(dlthis, tramp_sym_str);
-		if (new_tramp_sym == NULL) {
-			/*  If tramp string not defined, create it and a new
-			 * string, and symbol for it as well as the original
-			 * symbol which caused the trampoline. */
-			new_tramp_str = priv_tramp_string_create(dlthis,
-								strlen
-								(tramp_sym_str),
-								 tramp_sym_str);
-			if (new_tramp_str == NULL) {
-				dload_error(dlthis, "Failed to create new "
-					    "trampoline string\n");
-				ret_val = 0;
-			} else {
-				/*  Allocate tramp section space for the new
-				 * tramp from the target */
-				new_tramp_base = priv_tramp_sect_alloc(dlthis,
-						       tramp_size_get());
-
-				/*  We have a string, create the new symbol and
-				 * duplicate the external. */
-				tmp_sym.value = new_tramp_base;
-				tmp_sym.delta = 0;
-				tmp_sym.secnn = -1;
-				tmp_sym.sclass = 0;
-				new_tramp_sym = priv_tramp_sym_create(dlthis,
-							      new_tramp_str->
-							      index,
-							      &tmp_sym);
-
-				new_ext_sym = priv_tramp_sym_create(dlthis, -1,
-								    ref_sym);
-
-				if ((new_tramp_sym != NULL) &&
-				    (new_ext_sym != NULL)) {
-					/*  Call the image generator to get the
-					 * new image data and fix up its
-					 * relocations for the external
-					 * symbol. */
-					ret_val = priv_tgt_img_gen(dlthis,
-								 new_tramp_base,
-								 gen_index,
-								 new_ext_sym);
-
-					/*  Add generated image data to tramp
-					 * image list */
-					if (ret_val != 1) {
-						dload_error(dlthis, "Failed to "
-							    "create img pkt for"
-							    " trampoline\n");
-					}
-				} else {
-					dload_error(dlthis, "Failed to create "
-						    "new tramp syms "
-						    "(%8.8X, %8.8X)\n",
-						    new_tramp_sym, new_ext_sym);
-					ret_val = 0;
-				}
-			}
-		}
-
-		/*  Duplicate the image data and relo record that caused the
-		 * tramp, including update the relo data to point to the tramp
-		 * symbol. */
-		if (ret_val == 1) {
-			ret_val = priv_img_pkt_dup(dlthis, secnn, image_offset,
-						   ipacket, rp, new_tramp_sym);
-			if (ret_val != 1) {
-				dload_error(dlthis, "Failed to create dup of "
-					    "original img pkt\n");
-			}
-		}
-	}
-
-	return ret_val;
-}
-
-/*
- * Function:	dload_tramp_pkt_update
- * Description: Update the duplicate copy of this image packet, which the
- *	  trampoline layer is already tracking.  This call is critical
- *	  to make if trampolines were generated anywhere within the
- *	  packet and first pass relo continued on the remainder.  The
- *	  trampoline layer needs the updates image data so when 2nd
- *	  pass relo is done during finalize the image packet can be
- *	  written to the target since all relo is done.
- */
-int dload_tramp_pkt_udpate(struct dload_state *dlthis, s16 secnn,
-			   u32 image_offset, struct image_packet_t *ipacket)
-{
-	struct tramp_img_dup_pkt *dup_pkt = NULL;
-	s32 i;
-	int ret_val = 0;
-
-	/*  Find the image packet in question, the caller needs us to update it
-	   since a trampoline was previously generated. */
-	dup_pkt = priv_dup_find(dlthis, secnn, image_offset);
-	if (dup_pkt != NULL) {
-		for (i = 0; i < dup_pkt->img_pkt.packet_size; i++)
-			*(dup_pkt->img_pkt.img_data + i) =
-			    *(ipacket->img_data + i);
-
-		ret_val = 1;
-	} else {
-		dload_error(dlthis,
-			    "Unable to find existing DUP pkt for %x, offset %x",
-			    secnn, image_offset);
-
-	}
-
-	return ret_val;
-}
-
-/*
- * Function:	dload_tramp_finalize
- * Description: If any trampolines were created, finalize everything on the
- *	  target by allocating the trampoline section on the target,
- *	  finalizing the trampoline symbols, finalizing the trampoline
- *	  packets (write the new section to target memory) and finalize
- *	  the duplicate packets by doing 2nd pass relo over them.
- */
-int dload_tramp_finalize(struct dload_state *dlthis)
-{
-	int ret_val = 1;
-
-	if (dlthis->tramp.tramp_sect_next_addr != 0) {
-		/*  Finalize strings into a flat table.  This is needed so it
-		 * can be added to the debug string table later. */
-		ret_val = priv_string_tbl_finalize(dlthis);
-
-		/*  Do target allocation for section BEFORE finalizing
-		 * symbols. */
-		if (ret_val != 0)
-			ret_val = priv_tramp_sect_tgt_alloc(dlthis);
-
-		/*  Finalize symbols with their correct target information and
-		 * flatten */
-		if (ret_val != 0)
-			ret_val = priv_tramp_sym_finalize(dlthis);
-
-		/*  Finalize all trampoline packets.  This performs the
-		 * relocation on the packets as well as writing them to target
-		 * memory. */
-		if (ret_val != 0)
-			ret_val = priv_tramp_pkt_finalize(dlthis);
-
-		/*  Perform a 2nd pass relocation on the dup list. */
-		if (ret_val != 0)
-			ret_val = priv_dup_pkt_finalize(dlthis);
-	}
-
-	return ret_val;
-}
-
-/*
- * Function:	dload_tramp_cleanup
- * Description: Release all temporary resources used in the trampoline layer.
- *	  Note that the target memory which may have been allocated and
- *	  written to store the trampolines is NOT RELEASED HERE since it
- *	  is potentially still in use.  It is automatically released
- *	  when the module is unloaded.
- */
-void dload_tramp_cleanup(struct dload_state *dlthis)
-{
-	struct tramp_info *tramp = &dlthis->tramp;
-	struct tramp_sym *cur_sym;
-	struct tramp_string *cur_string;
-	struct tramp_img_pkt *cur_tramp_pkt;
-	struct tramp_img_dup_pkt *cur_dup_pkt;
-	struct tramp_img_dup_relo *cur_dup_relo;
-
-	/*  If there were no tramps generated, just return */
-	if (tramp->tramp_sect_next_addr == 0)
-		return;
-
-	/*  Destroy all tramp information */
-	for (cur_sym = tramp->symbol_head;
-	     cur_sym != NULL; cur_sym = tramp->symbol_head) {
-		tramp->symbol_head = cur_sym->next;
-		if (tramp->symbol_tail == cur_sym)
-			tramp->symbol_tail = NULL;
-
-		dlthis->mysym->dload_deallocate(dlthis->mysym, cur_sym);
-	}
-
-	if (tramp->final_sym_table != NULL)
-		dlthis->mysym->dload_deallocate(dlthis->mysym,
-						tramp->final_sym_table);
-
-	for (cur_string = tramp->string_head;
-	     cur_string != NULL; cur_string = tramp->string_head) {
-		tramp->string_head = cur_string->next;
-		if (tramp->string_tail == cur_string)
-			tramp->string_tail = NULL;
-
-		dlthis->mysym->dload_deallocate(dlthis->mysym, cur_string);
-	}
-
-	if (tramp->final_string_table != NULL)
-		dlthis->mysym->dload_deallocate(dlthis->mysym,
-						tramp->final_string_table);
-
-	for (cur_tramp_pkt = tramp->tramp_pkts;
-	     cur_tramp_pkt != NULL; cur_tramp_pkt = tramp->tramp_pkts) {
-		tramp->tramp_pkts = cur_tramp_pkt->next;
-		dlthis->mysym->dload_deallocate(dlthis->mysym, cur_tramp_pkt);
-	}
-
-	for (cur_dup_pkt = tramp->dup_pkts;
-	     cur_dup_pkt != NULL; cur_dup_pkt = tramp->dup_pkts) {
-		tramp->dup_pkts = cur_dup_pkt->next;
-
-		for (cur_dup_relo = cur_dup_pkt->relo_chain;
-		     cur_dup_relo != NULL;
-		     cur_dup_relo = cur_dup_pkt->relo_chain) {
-			cur_dup_pkt->relo_chain = cur_dup_relo->next;
-			dlthis->mysym->dload_deallocate(dlthis->mysym,
-							cur_dup_relo);
-		}
-
-		dlthis->mysym->dload_deallocate(dlthis->mysym, cur_dup_pkt);
-	}
-}
diff --git a/drivers/staging/tidspbridge/dynload/tramp_table_c6000.c b/drivers/staging/tidspbridge/dynload/tramp_table_c6000.c
deleted file mode 100644
index 09cc64f..0000000
--- a/drivers/staging/tidspbridge/dynload/tramp_table_c6000.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * tramp_table_c6000.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include "dload_internal.h"
-
-/*  These are defined in coff.h, but may not be available on all platforms
-	so we'll go ahead and define them here. */
-#ifndef R_C60LO16
-#define R_C60LO16	  0x54	/* C60: MVK Low Half Register */
-#define R_C60HI16	  0x55	/* C60: MVKH/MVKLH High Half Register */
-#endif
-
-#define C6X_TRAMP_WORD_COUNT			8
-#define C6X_TRAMP_MAX_RELOS			 8
-
-/*  THIS HASH FUNCTION MUST MATCH THE ONE reloc_table_c6000.c */
-#define HASH_FUNC(zz) (((((zz) + 1) * 1845UL) >> 11) & 63)
-
-/*  THIS MUST MATCH reloc_record_t FOR A SYMBOL BASED RELO */
-struct c6000_relo_record {
-	s32 vaddr;
-	s32 symndx;
-#ifndef _BIG_ENDIAN
-	u16 disp;
-	u16 type;
-#else
-	u16 type;
-	u16 disp;
-#endif
-};
-
-struct c6000_gen_code {
-	struct tramp_gen_code_hdr hdr;
-	u32 tramp_instrs[C6X_TRAMP_WORD_COUNT];
-	struct c6000_relo_record relos[C6X_TRAMP_MAX_RELOS];
-};
-
-/*  Hash mapping for relos that can cause trampolines. */
-static const u16 tramp_map[] = {
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	0,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535,
-	65535
-};
-
-static const struct c6000_gen_code tramp_gen_info[] = {
-	/*  Tramp caused by R_C60PCR21 */
-	{
-	 /*  Header - 8 instructions, 2 relos */
-	 {
-	  sizeof(u32) * C6X_TRAMP_WORD_COUNT,
-	  2,
-	  FIELD_OFFSET(struct c6000_gen_code, relos)
-	  },
-
-	 /*  Trampoline instructions */
-	 {
-	  0x053C54F7,		/*       STW.D2T2  B10, *sp--[2] */
-	  0x0500002A,		/*  || MVK.S2   <blank>, B10 */
-	  0x0500006A,		/*       MVKH.S2   <blank>, B10 */
-	  0x00280362,		/*       B.S2     B10 */
-	  0x053C52E6,		/*       LDW.D2T2  *++sp[2], B10 */
-	  0x00006000,		/*       NOP       4 */
-	  0x00000000,		/*       NOP */
-	  0x00000000		/*       NOP */
-	  },
-
-	 /*  Relocations */
-	 {
-	  {4, 0, 0, R_C60LO16},
-	  {8, 0, 0, R_C60HI16},
-	  {0, 0, 0, 0x0000},
-	  {0, 0, 0, 0x0000},
-	  {0, 0, 0, 0x0000},
-	  {0, 0, 0, 0x0000},
-	  {0, 0, 0, 0x0000},
-	  {0, 0, 0, 0x0000}
-	  }
-	 }
-};
-
-/*  TARGET SPECIFIC FUNCTIONS THAT MUST BE DEFINED */
-static u32 tramp_size_get(void)
-{
-	return sizeof(u32) * C6X_TRAMP_WORD_COUNT;
-}
-
-static u32 tramp_img_pkt_size_get(void)
-{
-	return sizeof(struct c6000_gen_code);
-}
diff --git a/drivers/staging/tidspbridge/gen/gh.c b/drivers/staging/tidspbridge/gen/gh.c
deleted file mode 100644
index 936470c..0000000
--- a/drivers/staging/tidspbridge/gen/gh.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * gh.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/err.h>
-#include <linux/hashtable.h>
-#include <linux/slab.h>
-
-struct gh_node {
-	struct hlist_node hl;
-	u8 data[0];
-};
-
-#define GH_HASH_ORDER 8
-
-struct gh_t_hash_tab {
-	u32 val_size;
-	DECLARE_HASHTABLE(hash_table, GH_HASH_ORDER);
-	u32 (*hash)(const void *key);
-	bool (*match)(const void *key, const void *value);
-	void (*delete)(void *key);
-};
-
-/*
- *  ======== gh_create ========
- */
-
-struct gh_t_hash_tab *gh_create(u32 val_size, u32 (*hash)(const void *),
-				bool (*match)(const void *, const void *),
-				void (*delete)(void *))
-{
-	struct gh_t_hash_tab *hash_tab;
-
-	hash_tab = kzalloc(sizeof(struct gh_t_hash_tab), GFP_KERNEL);
-	if (!hash_tab)
-		return ERR_PTR(-ENOMEM);
-
-	hash_init(hash_tab->hash_table);
-
-	hash_tab->val_size = val_size;
-	hash_tab->hash = hash;
-	hash_tab->match = match;
-	hash_tab->delete = delete;
-
-	return hash_tab;
-}
-
-/*
- *  ======== gh_delete ========
- */
-void gh_delete(struct gh_t_hash_tab *hash_tab)
-{
-	struct gh_node *n;
-	struct hlist_node *tmp;
-	u32 i;
-
-	if (hash_tab) {
-		hash_for_each_safe(hash_tab->hash_table, i, tmp, n, hl) {
-			hash_del(&n->hl);
-			if (hash_tab->delete)
-				hash_tab->delete(n->data);
-			kfree(n);
-		}
-
-		kfree(hash_tab);
-	}
-}
-
-/*
- *  ======== gh_find ========
- */
-
-void *gh_find(struct gh_t_hash_tab *hash_tab, const void *key)
-{
-	struct gh_node *n;
-	u32 key_hash = hash_tab->hash(key);
-
-	hash_for_each_possible(hash_tab->hash_table, n, hl, key_hash) {
-		if (hash_tab->match(key, n->data))
-			return n->data;
-	}
-
-	return ERR_PTR(-ENODATA);
-}
-
-/*
- *  ======== gh_insert ========
- */
-
-void *gh_insert(struct gh_t_hash_tab *hash_tab, const void *key,
-		const void *value)
-{
-	struct gh_node *n;
-
-	n = kmalloc(sizeof(struct gh_node) + hash_tab->val_size,
-			GFP_KERNEL);
-
-	if (!n)
-		return ERR_PTR(-ENOMEM);
-
-	INIT_HLIST_NODE(&n->hl);
-	hash_add(hash_tab->hash_table, &n->hl, hash_tab->hash(key));
-	memcpy(n->data, value, hash_tab->val_size);
-
-	return n->data;
-}
-
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-/**
- * gh_iterate() - This function goes through all the elements in the hash table
- *		looking for the dsp symbols.
- * @hash_tab:	Hash table
- * @callback:	pointer to callback function
- * @user_data:	User data, contains the find_symbol_context pointer
- *
- */
-void gh_iterate(struct gh_t_hash_tab *hash_tab,
-		void (*callback)(void *, void *), void *user_data)
-{
-	struct gh_node *n;
-	u32 i;
-
-	if (!hash_tab)
-		return;
-
-	hash_for_each(hash_tab->hash_table, i, n, hl)
-		callback(&n->data, user_data);
-}
-#endif
diff --git a/drivers/staging/tidspbridge/hw/EasiGlobal.h b/drivers/staging/tidspbridge/hw/EasiGlobal.h
deleted file mode 100644
index e48d7f6..0000000
--- a/drivers/staging/tidspbridge/hw/EasiGlobal.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * EasiGlobal.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2007 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _EASIGLOBAL_H
-#define _EASIGLOBAL_H
-#include <linux/types.h>
-
-/*
- * DEFINE:        READ_ONLY, WRITE_ONLY &  READ_WRITE
- *
- * DESCRIPTION: Defines used to describe register types for EASI-checker tests.
- */
-
-#define READ_ONLY    1
-#define WRITE_ONLY   2
-#define READ_WRITE   3
-
-/*
- * MACRO:        _DEBUG_LEVEL1_EASI
- *
- * DESCRIPTION:  A MACRO which can be used to indicate that a particular beach
- *               register access function was called.
- *
- * NOTE:         We currently dont use this functionality.
- */
-#define _DEBUG_LEVEL1_EASI(easi_num)     ((void)0)
-
-#endif /* _EASIGLOBAL_H */
diff --git a/drivers/staging/tidspbridge/hw/MMUAccInt.h b/drivers/staging/tidspbridge/hw/MMUAccInt.h
deleted file mode 100644
index 1cefca3..0000000
--- a/drivers/staging/tidspbridge/hw/MMUAccInt.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * MMUAccInt.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2007 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _MMU_ACC_INT_H
-#define _MMU_ACC_INT_H
-
-/* Mappings of level 1 EASI function numbers to function names */
-
-#define EASIL1_MMUMMU_SYSCONFIG_READ_REGISTER32 (MMU_BASE_EASIL1 + 3)
-#define EASIL1_MMUMMU_SYSCONFIG_IDLE_MODE_WRITE32  (MMU_BASE_EASIL1 + 17)
-#define EASIL1_MMUMMU_SYSCONFIG_AUTO_IDLE_WRITE32    (MMU_BASE_EASIL1 + 39)
-#define EASIL1_MMUMMU_IRQSTATUS_WRITE_REGISTER32   (MMU_BASE_EASIL1 + 51)
-#define EASIL1_MMUMMU_IRQENABLE_READ_REGISTER32 (MMU_BASE_EASIL1 + 102)
-#define EASIL1_MMUMMU_IRQENABLE_WRITE_REGISTER32 (MMU_BASE_EASIL1 + 103)
-#define EASIL1_MMUMMU_WALKING_STTWL_RUNNING_READ32 (MMU_BASE_EASIL1 + 156)
-#define EASIL1_MMUMMU_CNTLTWL_ENABLE_READ32 (MMU_BASE_EASIL1 + 174)
-#define EASIL1_MMUMMU_CNTLTWL_ENABLE_WRITE32   (MMU_BASE_EASIL1 + 180)
-#define EASIL1_MMUMMU_CNTLMMU_ENABLE_WRITE32     (MMU_BASE_EASIL1 + 190)
-#define EASIL1_MMUMMU_FAULT_AD_READ_REGISTER32   (MMU_BASE_EASIL1 + 194)
-#define EASIL1_MMUMMU_TTB_WRITE_REGISTER32  (MMU_BASE_EASIL1 + 198)
-#define EASIL1_MMUMMU_LOCK_READ_REGISTER32   (MMU_BASE_EASIL1 + 203)
-#define EASIL1_MMUMMU_LOCK_WRITE_REGISTER32  (MMU_BASE_EASIL1 + 204)
-#define EASIL1_MMUMMU_LOCK_BASE_VALUE_READ32  (MMU_BASE_EASIL1 + 205)
-#define EASIL1_MMUMMU_LOCK_CURRENT_VICTIM_READ32 (MMU_BASE_EASIL1 + 209)
-#define EASIL1_MMUMMU_LOCK_CURRENT_VICTIM_WRITE32 (MMU_BASE_EASIL1 + 211)
-#define EASIL1_MMUMMU_LOCK_CURRENT_VICTIM_SET32  (MMU_BASE_EASIL1 + 212)
-#define EASIL1_MMUMMU_LD_TLB_READ_REGISTER32    (MMU_BASE_EASIL1 + 213)
-#define EASIL1_MMUMMU_LD_TLB_WRITE_REGISTER32   (MMU_BASE_EASIL1 + 214)
-#define EASIL1_MMUMMU_CAM_WRITE_REGISTER32   (MMU_BASE_EASIL1 + 226)
-#define EASIL1_MMUMMU_RAM_WRITE_REGISTER32 (MMU_BASE_EASIL1 + 268)
-#define EASIL1_MMUMMU_FLUSH_ENTRY_WRITE_REGISTER32  (MMU_BASE_EASIL1 + 322)
-
-/* Register offset address definitions */
-#define MMU_MMU_SYSCONFIG_OFFSET   0x10
-#define MMU_MMU_IRQSTATUS_OFFSET  0x18
-#define MMU_MMU_IRQENABLE_OFFSET    0x1c
-#define MMU_MMU_WALKING_ST_OFFSET 0x40
-#define MMU_MMU_CNTL_OFFSET   0x44
-#define MMU_MMU_FAULT_AD_OFFSET  0x48
-#define MMU_MMU_TTB_OFFSET  0x4c
-#define MMU_MMU_LOCK_OFFSET   0x50
-#define MMU_MMU_LD_TLB_OFFSET  0x54
-#define MMU_MMU_CAM_OFFSET   0x58
-#define MMU_MMU_RAM_OFFSET   0x5c
-#define MMU_MMU_GFLUSH_OFFSET  0x60
-#define MMU_MMU_FLUSH_ENTRY_OFFSET  0x64
-/* Bitfield mask and offset declarations */
-#define MMU_MMU_SYSCONFIG_IDLE_MODE_MASK  0x18
-#define MMU_MMU_SYSCONFIG_IDLE_MODE_OFFSET  3
-#define MMU_MMU_SYSCONFIG_AUTO_IDLE_MASK  0x1
-#define MMU_MMU_SYSCONFIG_AUTO_IDLE_OFFSET   0
-#define MMU_MMU_WALKING_ST_TWL_RUNNING_MASK 0x1
-#define MMU_MMU_WALKING_ST_TWL_RUNNING_OFFSET  0
-#define MMU_MMU_CNTL_TWL_ENABLE_MASK 0x4
-#define MMU_MMU_CNTL_TWL_ENABLE_OFFSET 2
-#define MMU_MMU_CNTL_MMU_ENABLE_MASK    0x2
-#define MMU_MMU_CNTL_MMU_ENABLE_OFFSET   1
-#define MMU_MMU_LOCK_BASE_VALUE_MASK 0xfc00
-#define MMU_MMU_LOCK_BASE_VALUE_OFFSET   10
-#define MMU_MMU_LOCK_CURRENT_VICTIM_MASK   0x3f0
-#define MMU_MMU_LOCK_CURRENT_VICTIM_OFFSET    4
-
-#endif /* _MMU_ACC_INT_H */
diff --git a/drivers/staging/tidspbridge/hw/MMURegAcM.h b/drivers/staging/tidspbridge/hw/MMURegAcM.h
deleted file mode 100644
index ab1a16d..0000000
--- a/drivers/staging/tidspbridge/hw/MMURegAcM.h
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * MMURegAcM.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2007 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _MMU_REG_ACM_H
-#define _MMU_REG_ACM_H
-
-#include <linux/io.h>
-#include <EasiGlobal.h>
-
-#include "MMUAccInt.h"
-
-#if defined(USE_LEVEL_1_MACROS)
-
-#define MMUMMU_SYSCONFIG_READ_REGISTER32(base_address)\
-    (_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_SYSCONFIG_READ_REGISTER32),\
-      __raw_readl((base_address)+MMU_MMU_SYSCONFIG_OFFSET))
-
-#define MMUMMU_SYSCONFIG_IDLE_MODE_WRITE32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_SYSCONFIG_OFFSET;\
-    register u32 data = __raw_readl((base_address)+offset);\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_SYSCONFIG_IDLE_MODE_WRITE32);\
-    data &= ~(MMU_MMU_SYSCONFIG_IDLE_MODE_MASK);\
-    new_value <<= MMU_MMU_SYSCONFIG_IDLE_MODE_OFFSET;\
-    new_value &= MMU_MMU_SYSCONFIG_IDLE_MODE_MASK;\
-    new_value |= data;\
-    __raw_writel(new_value, base_address+offset);\
-}
-
-#define MMUMMU_SYSCONFIG_AUTO_IDLE_WRITE32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_SYSCONFIG_OFFSET;\
-    register u32 data = __raw_readl((base_address)+offset);\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_SYSCONFIG_AUTO_IDLE_WRITE32);\
-    data &= ~(MMU_MMU_SYSCONFIG_AUTO_IDLE_MASK);\
-    new_value <<= MMU_MMU_SYSCONFIG_AUTO_IDLE_OFFSET;\
-    new_value &= MMU_MMU_SYSCONFIG_AUTO_IDLE_MASK;\
-    new_value |= data;\
-    __raw_writel(new_value, base_address+offset);\
-}
-
-#define MMUMMU_IRQSTATUS_READ_REGISTER32(base_address)\
-    (_DEBUG_LEVEL1_EASI(easil1_mmummu_irqstatus_read_register32),\
-      __raw_readl((base_address)+MMU_MMU_IRQSTATUS_OFFSET))
-
-#define MMUMMU_IRQSTATUS_WRITE_REGISTER32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_IRQSTATUS_OFFSET;\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_IRQSTATUS_WRITE_REGISTER32);\
-    __raw_writel(new_value, (base_address)+offset);\
-}
-
-#define MMUMMU_IRQENABLE_READ_REGISTER32(base_address)\
-    (_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_IRQENABLE_READ_REGISTER32),\
-      __raw_readl((base_address)+MMU_MMU_IRQENABLE_OFFSET))
-
-#define MMUMMU_IRQENABLE_WRITE_REGISTER32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_IRQENABLE_OFFSET;\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_IRQENABLE_WRITE_REGISTER32);\
-    __raw_writel(new_value, (base_address)+offset);\
-}
-
-#define MMUMMU_WALKING_STTWL_RUNNING_READ32(base_address)\
-    (_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_WALKING_STTWL_RUNNING_READ32),\
-      (((__raw_readl(((base_address)+(MMU_MMU_WALKING_ST_OFFSET))))\
-      & MMU_MMU_WALKING_ST_TWL_RUNNING_MASK) >>\
-      MMU_MMU_WALKING_ST_TWL_RUNNING_OFFSET))
-
-#define MMUMMU_CNTLTWL_ENABLE_READ32(base_address)\
-    (_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_CNTLTWL_ENABLE_READ32),\
-      (((__raw_readl(((base_address)+(MMU_MMU_CNTL_OFFSET)))) &\
-      MMU_MMU_CNTL_TWL_ENABLE_MASK) >>\
-      MMU_MMU_CNTL_TWL_ENABLE_OFFSET))
-
-#define MMUMMU_CNTLTWL_ENABLE_WRITE32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_CNTL_OFFSET;\
-    register u32 data = __raw_readl((base_address)+offset);\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_CNTLTWL_ENABLE_WRITE32);\
-    data &= ~(MMU_MMU_CNTL_TWL_ENABLE_MASK);\
-    new_value <<= MMU_MMU_CNTL_TWL_ENABLE_OFFSET;\
-    new_value &= MMU_MMU_CNTL_TWL_ENABLE_MASK;\
-    new_value |= data;\
-    __raw_writel(new_value, base_address+offset);\
-}
-
-#define MMUMMU_CNTLMMU_ENABLE_WRITE32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_CNTL_OFFSET;\
-    register u32 data = __raw_readl((base_address)+offset);\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_CNTLMMU_ENABLE_WRITE32);\
-    data &= ~(MMU_MMU_CNTL_MMU_ENABLE_MASK);\
-    new_value <<= MMU_MMU_CNTL_MMU_ENABLE_OFFSET;\
-    new_value &= MMU_MMU_CNTL_MMU_ENABLE_MASK;\
-    new_value |= data;\
-    __raw_writel(new_value, base_address+offset);\
-}
-
-#define MMUMMU_FAULT_AD_READ_REGISTER32(base_address)\
-    (_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_FAULT_AD_READ_REGISTER32),\
-      __raw_readl((base_address)+MMU_MMU_FAULT_AD_OFFSET))
-
-#define MMUMMU_TTB_WRITE_REGISTER32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_TTB_OFFSET;\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_TTB_WRITE_REGISTER32);\
-    __raw_writel(new_value, (base_address)+offset);\
-}
-
-#define MMUMMU_LOCK_READ_REGISTER32(base_address)\
-    (_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LOCK_READ_REGISTER32),\
-      __raw_readl((base_address)+MMU_MMU_LOCK_OFFSET))
-
-#define MMUMMU_LOCK_WRITE_REGISTER32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_LOCK_OFFSET;\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LOCK_WRITE_REGISTER32);\
-    __raw_writel(new_value, (base_address)+offset);\
-}
-
-#define MMUMMU_LOCK_BASE_VALUE_READ32(base_address)\
-    (_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LOCK_BASE_VALUE_READ32),\
-      (((__raw_readl(((base_address)+(MMU_MMU_LOCK_OFFSET)))) &\
-      MMU_MMU_LOCK_BASE_VALUE_MASK) >>\
-      MMU_MMU_LOCK_BASE_VALUE_OFFSET))
-
-#define MMUMMU_LOCK_BASE_VALUE_WRITE32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_LOCK_OFFSET;\
-    register u32 data = __raw_readl((base_address)+offset);\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(easil1_mmummu_lock_base_value_write32);\
-    data &= ~(MMU_MMU_LOCK_BASE_VALUE_MASK);\
-    new_value <<= MMU_MMU_LOCK_BASE_VALUE_OFFSET;\
-    new_value &= MMU_MMU_LOCK_BASE_VALUE_MASK;\
-    new_value |= data;\
-    __raw_writel(new_value, base_address+offset);\
-}
-
-#define MMUMMU_LOCK_CURRENT_VICTIM_READ32(base_address)\
-    (_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LOCK_CURRENT_VICTIM_READ32),\
-      (((__raw_readl(((base_address)+(MMU_MMU_LOCK_OFFSET)))) &\
-      MMU_MMU_LOCK_CURRENT_VICTIM_MASK) >>\
-      MMU_MMU_LOCK_CURRENT_VICTIM_OFFSET))
-
-#define MMUMMU_LOCK_CURRENT_VICTIM_WRITE32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_LOCK_OFFSET;\
-    register u32 data = __raw_readl((base_address)+offset);\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LOCK_CURRENT_VICTIM_WRITE32);\
-    data &= ~(MMU_MMU_LOCK_CURRENT_VICTIM_MASK);\
-    new_value <<= MMU_MMU_LOCK_CURRENT_VICTIM_OFFSET;\
-    new_value &= MMU_MMU_LOCK_CURRENT_VICTIM_MASK;\
-    new_value |= data;\
-    __raw_writel(new_value, base_address+offset);\
-}
-
-#define MMUMMU_LOCK_CURRENT_VICTIM_SET32(var, value)\
-    (_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LOCK_CURRENT_VICTIM_SET32),\
-      (((var) & ~(MMU_MMU_LOCK_CURRENT_VICTIM_MASK)) |\
-      (((value) << MMU_MMU_LOCK_CURRENT_VICTIM_OFFSET) &\
-      MMU_MMU_LOCK_CURRENT_VICTIM_MASK)))
-
-#define MMUMMU_LD_TLB_READ_REGISTER32(base_address)\
-    (_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LD_TLB_READ_REGISTER32),\
-      __raw_readl((base_address)+MMU_MMU_LD_TLB_OFFSET))
-
-#define MMUMMU_LD_TLB_WRITE_REGISTER32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_LD_TLB_OFFSET;\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LD_TLB_WRITE_REGISTER32);\
-    __raw_writel(new_value, (base_address)+offset);\
-}
-
-#define MMUMMU_CAM_WRITE_REGISTER32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_CAM_OFFSET;\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_CAM_WRITE_REGISTER32);\
-    __raw_writel(new_value, (base_address)+offset);\
-}
-
-#define MMUMMU_RAM_WRITE_REGISTER32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_RAM_OFFSET;\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_RAM_WRITE_REGISTER32);\
-    __raw_writel(new_value, (base_address)+offset);\
-}
-
-#define MMUMMU_FLUSH_ENTRY_WRITE_REGISTER32(base_address, value)\
-{\
-    const u32 offset = MMU_MMU_FLUSH_ENTRY_OFFSET;\
-    register u32 new_value = (value);\
-    _DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_FLUSH_ENTRY_WRITE_REGISTER32);\
-    __raw_writel(new_value, (base_address)+offset);\
-}
-
-#endif /* USE_LEVEL_1_MACROS */
-
-#endif /* _MMU_REG_ACM_H */
diff --git a/drivers/staging/tidspbridge/hw/hw_defs.h b/drivers/staging/tidspbridge/hw/hw_defs.h
deleted file mode 100644
index d5266d4..0000000
--- a/drivers/staging/tidspbridge/hw/hw_defs.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * hw_defs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global HW definitions
- *
- * Copyright (C) 2007 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _HW_DEFS_H
-#define _HW_DEFS_H
-
-/* Page size */
-#define HW_PAGE_SIZE4KB   0x1000
-#define HW_PAGE_SIZE64KB  0x10000
-#define HW_PAGE_SIZE1MB   0x100000
-#define HW_PAGE_SIZE16MB  0x1000000
-
-/* hw_status:  return type for HW API */
-typedef long hw_status;
-
-/*  Macro used to set and clear any bit */
-#define HW_CLEAR	0
-#define HW_SET		1
-
-/* hw_endianism_t:  Enumerated Type used to specify the endianism
- *		Do NOT change these values. They are used as bit fields. */
-enum hw_endianism_t {
-	HW_LITTLE_ENDIAN,
-	HW_BIG_ENDIAN
-};
-
-/* hw_element_size_t:  Enumerated Type used to specify the element size
- *		Do NOT change these values. They are used as bit fields. */
-enum hw_element_size_t {
-	HW_ELEM_SIZE8BIT,
-	HW_ELEM_SIZE16BIT,
-	HW_ELEM_SIZE32BIT,
-	HW_ELEM_SIZE64BIT
-};
-
-/* hw_idle_mode_t:  Enumerated Type used to specify Idle modes */
-enum hw_idle_mode_t {
-	HW_FORCE_IDLE,
-	HW_NO_IDLE,
-	HW_SMART_IDLE
-};
-
-#endif /* _HW_DEFS_H */
diff --git a/drivers/staging/tidspbridge/hw/hw_mmu.c b/drivers/staging/tidspbridge/hw/hw_mmu.c
deleted file mode 100644
index 50244a4..0000000
--- a/drivers/staging/tidspbridge/hw/hw_mmu.c
+++ /dev/null
@@ -1,487 +0,0 @@
-/*
- * hw_mmu.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * API definitions to setup MMU TLB and PTE
- *
- * Copyright (C) 2007 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/io.h>
-#include "MMURegAcM.h"
-#include <hw_defs.h>
-#include <hw_mmu.h>
-#include <linux/types.h>
-#include <linux/err.h>
-
-#define MMU_BASE_VAL_MASK	0xFC00
-#define MMU_PAGE_MAX	     3
-#define MMU_ELEMENTSIZE_MAX      3
-#define MMU_ADDR_MASK	    0xFFFFF000
-#define MMU_TTB_MASK	     0xFFFFC000
-#define MMU_SECTION_ADDR_MASK    0xFFF00000
-#define MMU_SSECTION_ADDR_MASK   0xFF000000
-#define MMU_PAGE_TABLE_MASK      0xFFFFFC00
-#define MMU_LARGE_PAGE_MASK      0xFFFF0000
-#define MMU_SMALL_PAGE_MASK      0xFFFFF000
-
-#define MMU_LOAD_TLB	0x00000001
-#define MMU_GFLUSH	0x60
-
-/*
- * hw_mmu_page_size_t: Enumerated Type used to specify the MMU Page Size(SLSS)
- */
-enum hw_mmu_page_size_t {
-	HW_MMU_SECTION,
-	HW_MMU_LARGE_PAGE,
-	HW_MMU_SMALL_PAGE,
-	HW_MMU_SUPERSECTION
-};
-
-/*
- * FUNCTION	      : mmu_set_cam_entry
- *
- * INPUTS:
- *
- *       Identifier      : base_address
- *       Type		 : void __iomem *
- *       Description     : Base Address of instance of MMU module
- *
- *       Identifier      : page_sz
- *       TypE		: const u32
- *       Description     : It indicates the page size
- *
- *       Identifier      : preserved_bit
- *       Type		: const u32
- *       Description     : It indicates the TLB entry is preserved entry
- *							or not
- *
- *       Identifier      : valid_bit
- *       Type		: const u32
- *       Description     : It indicates the TLB entry is valid entry or not
- *
- *
- *       Identifier      : virtual_addr_tag
- *       Type	    	: const u32
- *       Description     : virtual Address
- *
- * RETURNS:
- *
- *       Type	    	: hw_status
- *       Description     : 0		 -- No errors occurred
- *			 RET_BAD_NULL_PARAM     -- A Pointer Parameter
- *						   was set to NULL
- *			 RET_PARAM_OUT_OF_RANGE -- Input Parameter out
- *						   of Range
- *
- * PURPOSE:	      	: Set MMU_CAM reg
- *
- * METHOD:	       	: Check the Input parameters and set the CAM entry.
- */
-static hw_status mmu_set_cam_entry(void __iomem *base_address,
-				   const u32 page_sz,
-				   const u32 preserved_bit,
-				   const u32 valid_bit,
-				   const u32 virtual_addr_tag);
-
-/*
- * FUNCTION	      : mmu_set_ram_entry
- *
- * INPUTS:
- *
- *       Identifier      : base_address
- *       Type		 : void __iomem *
- *       Description     : Base Address of instance of MMU module
- *
- *       Identifier      : physical_addr
- *       Type	    	: const u32
- *       Description     : Physical Address to which the corresponding
- *			 virtual   Address shouldpoint
- *
- *       Identifier      : endianism
- *       Type	    	: hw_endianism_t
- *       Description     : endianism for the given page
- *
- *       Identifier      : element_size
- *       Type	    	: hw_element_size_t
- *       Description     : The element size ( 8,16, 32 or 64 bit)
- *
- *       Identifier      : mixed_size
- *       Type	    	: hw_mmu_mixed_size_t
- *       Description     : Element Size to follow CPU or TLB
- *
- * RETURNS:
- *
- *       Type	    	: hw_status
- *       Description     : 0		 -- No errors occurred
- *			 RET_BAD_NULL_PARAM     -- A Pointer Parameter
- *							was set to NULL
- *			 RET_PARAM_OUT_OF_RANGE -- Input Parameter
- *							out of Range
- *
- * PURPOSE:	      : Set MMU_CAM reg
- *
- * METHOD:	       : Check the Input parameters and set the RAM entry.
- */
-static hw_status mmu_set_ram_entry(void __iomem *base_address,
-				   const u32 physical_addr,
-				   enum hw_endianism_t endianism,
-				   enum hw_element_size_t element_size,
-				   enum hw_mmu_mixed_size_t mixed_size);
-
-/* HW FUNCTIONS */
-
-hw_status hw_mmu_enable(void __iomem *base_address)
-{
-	hw_status status = 0;
-
-	MMUMMU_CNTLMMU_ENABLE_WRITE32(base_address, HW_SET);
-
-	return status;
-}
-
-hw_status hw_mmu_disable(void __iomem *base_address)
-{
-	hw_status status = 0;
-
-	MMUMMU_CNTLMMU_ENABLE_WRITE32(base_address, HW_CLEAR);
-
-	return status;
-}
-
-hw_status hw_mmu_num_locked_set(void __iomem *base_address,
-				u32 num_locked_entries)
-{
-	hw_status status = 0;
-
-	MMUMMU_LOCK_BASE_VALUE_WRITE32(base_address, num_locked_entries);
-
-	return status;
-}
-
-hw_status hw_mmu_victim_num_set(void __iomem *base_address,
-				u32 victim_entry_num)
-{
-	hw_status status = 0;
-
-	MMUMMU_LOCK_CURRENT_VICTIM_WRITE32(base_address, victim_entry_num);
-
-	return status;
-}
-
-hw_status hw_mmu_event_ack(void __iomem *base_address, u32 irq_mask)
-{
-	hw_status status = 0;
-
-	MMUMMU_IRQSTATUS_WRITE_REGISTER32(base_address, irq_mask);
-
-	return status;
-}
-
-hw_status hw_mmu_event_disable(void __iomem *base_address, u32 irq_mask)
-{
-	hw_status status = 0;
-	u32 irq_reg;
-
-	irq_reg = MMUMMU_IRQENABLE_READ_REGISTER32(base_address);
-
-	MMUMMU_IRQENABLE_WRITE_REGISTER32(base_address, irq_reg & ~irq_mask);
-
-	return status;
-}
-
-hw_status hw_mmu_event_enable(void __iomem *base_address, u32 irq_mask)
-{
-	hw_status status = 0;
-	u32 irq_reg;
-
-	irq_reg = MMUMMU_IRQENABLE_READ_REGISTER32(base_address);
-
-	MMUMMU_IRQENABLE_WRITE_REGISTER32(base_address, irq_reg | irq_mask);
-
-	return status;
-}
-
-hw_status hw_mmu_event_status(void __iomem *base_address, u32 *irq_mask)
-{
-	hw_status status = 0;
-
-	*irq_mask = MMUMMU_IRQSTATUS_READ_REGISTER32(base_address);
-
-	return status;
-}
-
-hw_status hw_mmu_fault_addr_read(void __iomem *base_address, u32 *addr)
-{
-	hw_status status = 0;
-
-	/* read values from register */
-	*addr = MMUMMU_FAULT_AD_READ_REGISTER32(base_address);
-
-	return status;
-}
-
-hw_status hw_mmu_ttb_set(void __iomem *base_address, u32 ttb_phys_addr)
-{
-	hw_status status = 0;
-	u32 load_ttb;
-
-	load_ttb = ttb_phys_addr & ~0x7FUL;
-	/* write values to register */
-	MMUMMU_TTB_WRITE_REGISTER32(base_address, load_ttb);
-
-	return status;
-}
-
-hw_status hw_mmu_twl_enable(void __iomem *base_address)
-{
-	hw_status status = 0;
-
-	MMUMMU_CNTLTWL_ENABLE_WRITE32(base_address, HW_SET);
-
-	return status;
-}
-
-hw_status hw_mmu_twl_disable(void __iomem *base_address)
-{
-	hw_status status = 0;
-
-	MMUMMU_CNTLTWL_ENABLE_WRITE32(base_address, HW_CLEAR);
-
-	return status;
-}
-
-hw_status hw_mmu_tlb_add(void __iomem *base_address,
-			 u32 physical_addr,
-			 u32 virtual_addr,
-			 u32 page_sz,
-			 u32 entry_num,
-			 struct hw_mmu_map_attrs_t *map_attrs,
-			 s8 preserved_bit, s8 valid_bit)
-{
-	hw_status status = 0;
-	u32 lock_reg;
-	u32 virtual_addr_tag;
-	enum hw_mmu_page_size_t mmu_pg_size;
-
-	/*Check the input Parameters */
-	switch (page_sz) {
-	case HW_PAGE_SIZE4KB:
-		mmu_pg_size = HW_MMU_SMALL_PAGE;
-		break;
-
-	case HW_PAGE_SIZE64KB:
-		mmu_pg_size = HW_MMU_LARGE_PAGE;
-		break;
-
-	case HW_PAGE_SIZE1MB:
-		mmu_pg_size = HW_MMU_SECTION;
-		break;
-
-	case HW_PAGE_SIZE16MB:
-		mmu_pg_size = HW_MMU_SUPERSECTION;
-		break;
-
-	default:
-		return -EINVAL;
-	}
-
-	lock_reg = MMUMMU_LOCK_READ_REGISTER32(base_address);
-
-	/* Generate the 20-bit tag from virtual address */
-	virtual_addr_tag = ((virtual_addr & MMU_ADDR_MASK) >> 12);
-
-	/* Write the fields in the CAM Entry Register */
-	mmu_set_cam_entry(base_address, mmu_pg_size, preserved_bit, valid_bit,
-			  virtual_addr_tag);
-
-	/* Write the different fields of the RAM Entry Register */
-	/* endianism of the page,Element Size of the page (8, 16, 32, 64 bit) */
-	mmu_set_ram_entry(base_address, physical_addr, map_attrs->endianism,
-			  map_attrs->element_size, map_attrs->mixed_size);
-
-	/* Update the MMU Lock Register */
-	/* currentVictim between lockedBaseValue and (MMU_Entries_Number - 1) */
-	MMUMMU_LOCK_CURRENT_VICTIM_WRITE32(base_address, entry_num);
-
-	/* Enable loading of an entry in TLB by writing 1
-	   into LD_TLB_REG register */
-	MMUMMU_LD_TLB_WRITE_REGISTER32(base_address, MMU_LOAD_TLB);
-
-	MMUMMU_LOCK_WRITE_REGISTER32(base_address, lock_reg);
-
-	return status;
-}
-
-hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
-			 u32 physical_addr,
-			 u32 virtual_addr,
-			 u32 page_sz, struct hw_mmu_map_attrs_t *map_attrs)
-{
-	hw_status status = 0;
-	u32 pte_addr, pte_val;
-	s32 num_entries = 1;
-
-	switch (page_sz) {
-	case HW_PAGE_SIZE4KB:
-		pte_addr = hw_mmu_pte_addr_l2(pg_tbl_va,
-					      virtual_addr &
-					      MMU_SMALL_PAGE_MASK);
-		pte_val =
-		    ((physical_addr & MMU_SMALL_PAGE_MASK) |
-		     (map_attrs->endianism << 9) | (map_attrs->
-						    element_size << 4) |
-		     (map_attrs->mixed_size << 11) | 2);
-		break;
-
-	case HW_PAGE_SIZE64KB:
-		num_entries = 16;
-		pte_addr = hw_mmu_pte_addr_l2(pg_tbl_va,
-					      virtual_addr &
-					      MMU_LARGE_PAGE_MASK);
-		pte_val =
-		    ((physical_addr & MMU_LARGE_PAGE_MASK) |
-		     (map_attrs->endianism << 9) | (map_attrs->
-						    element_size << 4) |
-		     (map_attrs->mixed_size << 11) | 1);
-		break;
-
-	case HW_PAGE_SIZE1MB:
-		pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va,
-					      virtual_addr &
-					      MMU_SECTION_ADDR_MASK);
-		pte_val =
-		    ((((physical_addr & MMU_SECTION_ADDR_MASK) |
-		       (map_attrs->endianism << 15) | (map_attrs->
-						       element_size << 10) |
-		       (map_attrs->mixed_size << 17)) & ~0x40000) | 0x2);
-		break;
-
-	case HW_PAGE_SIZE16MB:
-		num_entries = 16;
-		pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va,
-					      virtual_addr &
-					      MMU_SSECTION_ADDR_MASK);
-		pte_val =
-		    (((physical_addr & MMU_SSECTION_ADDR_MASK) |
-		      (map_attrs->endianism << 15) | (map_attrs->
-						      element_size << 10) |
-		      (map_attrs->mixed_size << 17)
-		     ) | 0x40000 | 0x2);
-		break;
-
-	case HW_MMU_COARSE_PAGE_SIZE:
-		pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va,
-					      virtual_addr &
-					      MMU_SECTION_ADDR_MASK);
-		pte_val = (physical_addr & MMU_PAGE_TABLE_MASK) | 1;
-		break;
-
-	default:
-		return -EINVAL;
-	}
-
-	while (--num_entries >= 0)
-		((u32 *) pte_addr)[num_entries] = pte_val;
-
-	return status;
-}
-
-hw_status hw_mmu_pte_clear(const u32 pg_tbl_va, u32 virtual_addr, u32 page_size)
-{
-	hw_status status = 0;
-	u32 pte_addr;
-	s32 num_entries = 1;
-
-	switch (page_size) {
-	case HW_PAGE_SIZE4KB:
-		pte_addr = hw_mmu_pte_addr_l2(pg_tbl_va,
-					      virtual_addr &
-					      MMU_SMALL_PAGE_MASK);
-		break;
-
-	case HW_PAGE_SIZE64KB:
-		num_entries = 16;
-		pte_addr = hw_mmu_pte_addr_l2(pg_tbl_va,
-					      virtual_addr &
-					      MMU_LARGE_PAGE_MASK);
-		break;
-
-	case HW_PAGE_SIZE1MB:
-	case HW_MMU_COARSE_PAGE_SIZE:
-		pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va,
-					      virtual_addr &
-					      MMU_SECTION_ADDR_MASK);
-		break;
-
-	case HW_PAGE_SIZE16MB:
-		num_entries = 16;
-		pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va,
-					      virtual_addr &
-					      MMU_SSECTION_ADDR_MASK);
-		break;
-
-	default:
-		return -EINVAL;
-	}
-
-	while (--num_entries >= 0)
-		((u32 *) pte_addr)[num_entries] = 0;
-
-	return status;
-}
-
-/* mmu_set_cam_entry */
-static hw_status mmu_set_cam_entry(void __iomem *base_address,
-				   const u32 page_sz,
-				   const u32 preserved_bit,
-				   const u32 valid_bit,
-				   const u32 virtual_addr_tag)
-{
-	hw_status status = 0;
-	u32 mmu_cam_reg;
-
-	mmu_cam_reg = (virtual_addr_tag << 12);
-	mmu_cam_reg = (mmu_cam_reg) | (page_sz) | (valid_bit << 2) |
-	    (preserved_bit << 3);
-
-	/* write values to register */
-	MMUMMU_CAM_WRITE_REGISTER32(base_address, mmu_cam_reg);
-
-	return status;
-}
-
-/* mmu_set_ram_entry */
-static hw_status mmu_set_ram_entry(void __iomem *base_address,
-				   const u32 physical_addr,
-				   enum hw_endianism_t endianism,
-				   enum hw_element_size_t element_size,
-				   enum hw_mmu_mixed_size_t mixed_size)
-{
-	hw_status status = 0;
-	u32 mmu_ram_reg;
-
-	mmu_ram_reg = (physical_addr & MMU_ADDR_MASK);
-	mmu_ram_reg = (mmu_ram_reg) | ((endianism << 9) | (element_size << 7) |
-				       (mixed_size << 6));
-
-	/* write values to register */
-	MMUMMU_RAM_WRITE_REGISTER32(base_address, mmu_ram_reg);
-
-	return status;
-
-}
-
-void hw_mmu_tlb_flush_all(void __iomem *base)
-{
-	__raw_writel(1, base + MMU_GFLUSH);
-}
diff --git a/drivers/staging/tidspbridge/hw/hw_mmu.h b/drivers/staging/tidspbridge/hw/hw_mmu.h
deleted file mode 100644
index 1c50bb3..0000000
--- a/drivers/staging/tidspbridge/hw/hw_mmu.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * hw_mmu.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * MMU types and API declarations
- *
- * Copyright (C) 2007 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _HW_MMU_H
-#define _HW_MMU_H
-
-#include <linux/types.h>
-
-/* Bitmasks for interrupt sources */
-#define HW_MMU_TRANSLATION_FAULT   0x2
-#define HW_MMU_ALL_INTERRUPTS      0x1F
-
-#define HW_MMU_COARSE_PAGE_SIZE 0x400
-
-/* hw_mmu_mixed_size_t:  Enumerated Type used to specify whether to follow
-			CPU/TLB Element size */
-enum hw_mmu_mixed_size_t {
-	HW_MMU_TLBES,
-	HW_MMU_CPUES
-};
-
-/* hw_mmu_map_attrs_t:  Struct containing MMU mapping attributes */
-struct hw_mmu_map_attrs_t {
-	enum hw_endianism_t endianism;
-	enum hw_element_size_t element_size;
-	enum hw_mmu_mixed_size_t mixed_size;
-	bool donotlockmpupage;
-};
-
-extern hw_status hw_mmu_enable(void __iomem *base_address);
-
-extern hw_status hw_mmu_disable(void __iomem *base_address);
-
-extern hw_status hw_mmu_num_locked_set(void __iomem *base_address,
-				       u32 num_locked_entries);
-
-extern hw_status hw_mmu_victim_num_set(void __iomem *base_address,
-				       u32 victim_entry_num);
-
-/* For MMU faults */
-extern hw_status hw_mmu_event_ack(void __iomem *base_address,
-				  u32 irq_mask);
-
-extern hw_status hw_mmu_event_disable(void __iomem *base_address,
-				      u32 irq_mask);
-
-extern hw_status hw_mmu_event_enable(void __iomem *base_address,
-				     u32 irq_mask);
-
-extern hw_status hw_mmu_event_status(void __iomem *base_address,
-				     u32 *irq_mask);
-
-extern hw_status hw_mmu_fault_addr_read(void __iomem *base_address,
-					u32 *addr);
-
-/* Set the TT base address */
-extern hw_status hw_mmu_ttb_set(void __iomem *base_address,
-				u32 ttb_phys_addr);
-
-extern hw_status hw_mmu_twl_enable(void __iomem *base_address);
-
-extern hw_status hw_mmu_twl_disable(void __iomem *base_address);
-
-extern hw_status hw_mmu_tlb_add(void __iomem *base_address,
-				u32 physical_addr,
-				u32 virtual_addr,
-				u32 page_sz,
-				u32 entry_num,
-				struct hw_mmu_map_attrs_t *map_attrs,
-				s8 preserved_bit, s8 valid_bit);
-
-/* For PTEs */
-extern hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
-				u32 physical_addr,
-				u32 virtual_addr,
-				u32 page_sz,
-				struct hw_mmu_map_attrs_t *map_attrs);
-
-extern hw_status hw_mmu_pte_clear(const u32 pg_tbl_va,
-				  u32 virtual_addr, u32 page_size);
-
-void hw_mmu_tlb_flush_all(void __iomem *base);
-
-static inline u32 hw_mmu_pte_addr_l1(u32 l1_base, u32 va)
-{
-	u32 pte_addr;
-	u32 va31_to20;
-
-	va31_to20 = va >> (20 - 2);	/* Left-shift by 2 here itself */
-	va31_to20 &= 0xFFFFFFFCUL;
-	pte_addr = l1_base + va31_to20;
-
-	return pte_addr;
-}
-
-static inline u32 hw_mmu_pte_addr_l2(u32 l2_base, u32 va)
-{
-	u32 pte_addr;
-
-	pte_addr = (l2_base & 0xFFFFFC00) | ((va >> 10) & 0x3FC);
-
-	return pte_addr;
-}
-
-static inline u32 hw_mmu_pte_coarse_l1(u32 pte_val)
-{
-	u32 pte_coarse;
-
-	pte_coarse = pte_val & 0xFFFFFC00;
-
-	return pte_coarse;
-}
-
-static inline u32 hw_mmu_pte_size_l1(u32 pte_val)
-{
-	u32 pte_size = 0;
-
-	if ((pte_val & 0x3) == 0x1) {
-		/* Points to L2 PT */
-		pte_size = HW_MMU_COARSE_PAGE_SIZE;
-	}
-
-	if ((pte_val & 0x3) == 0x2) {
-		if (pte_val & (1 << 18))
-			pte_size = HW_PAGE_SIZE16MB;
-		else
-			pte_size = HW_PAGE_SIZE1MB;
-	}
-
-	return pte_size;
-}
-
-static inline u32 hw_mmu_pte_size_l2(u32 pte_val)
-{
-	u32 pte_size = 0;
-
-	if (pte_val & 0x2)
-		pte_size = HW_PAGE_SIZE4KB;
-	else if (pte_val & 0x1)
-		pte_size = HW_PAGE_SIZE64KB;
-
-	return pte_size;
-}
-
-#endif /* _HW_MMU_H */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/_chnl_sm.h b/drivers/staging/tidspbridge/include/dspbridge/_chnl_sm.h
deleted file mode 100644
index cc95a18..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/_chnl_sm.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * _chnl_sm.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Private header file defining channel manager and channel objects for
- * a shared memory channel driver.
- *
- * Shared between the modules implementing the shared memory channel class
- * library.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _CHNL_SM_
-#define _CHNL_SM_
-
-#include <dspbridge/dspapi.h>
-#include <dspbridge/dspdefs.h>
-
-#include <linux/list.h>
-#include <dspbridge/ntfy.h>
-
-/*
- *  These target side symbols define the beginning and ending addresses
- *  of shared memory buffer. They are defined in the *cfg.cmd file by
- *  cdb code.
- */
-#define CHNL_SHARED_BUFFER_BASE_SYM "_SHM_BEG"
-#define CHNL_SHARED_BUFFER_LIMIT_SYM "_SHM_END"
-#define BRIDGEINIT_BIOSGPTIMER "_BRIDGEINIT_BIOSGPTIMER"
-#define BRIDGEINIT_LOADMON_GPTIMER "_BRIDGEINIT_LOADMON_GPTIMER"
-
-#ifndef _CHNL_WORDSIZE
-#define _CHNL_WORDSIZE 4	/* default _CHNL_WORDSIZE is 2 bytes/word */
-#endif
-
-#define MAXOPPS 16
-
-/* Shared memory config options */
-#define SHM_CURROPP	0	/* Set current OPP in shm */
-#define SHM_OPPINFO	1	/* Set dsp voltage and freq table values */
-#define SHM_GETOPP	2	/* Get opp requested by DSP */
-
-struct opp_table_entry {
-	u32 voltage;
-	u32 frequency;
-	u32 min_freq;
-	u32 max_freq;
-};
-
-struct opp_struct {
-	u32 curr_opp_pt;
-	u32 num_opp_pts;
-	struct opp_table_entry opp_point[MAXOPPS];
-};
-
-/* Request to MPU */
-struct opp_rqst_struct {
-	u32 rqst_dsp_freq;
-	u32 rqst_opp_pt;
-};
-
-/* Info to MPU */
-struct load_mon_struct {
-	u32 curr_dsp_load;
-	u32 curr_dsp_freq;
-	u32 pred_dsp_load;
-	u32 pred_dsp_freq;
-};
-
-/* Structure in shared between DSP and PC for communication. */
-struct shm {
-	u32 dsp_free_mask;	/* Written by DSP, read by PC. */
-	u32 host_free_mask;	/* Written by PC, read by DSP */
-
-	u32 input_full;		/* Input channel has unread data. */
-	u32 input_id;		/* Channel for which input is available. */
-	u32 input_size;		/* Size of data block (in DSP words). */
-
-	u32 output_full;	/* Output channel has unread data. */
-	u32 output_id;		/* Channel for which output is available. */
-	u32 output_size;	/* Size of data block (in DSP words). */
-
-	u32 arg;		/* Arg for Issue/Reclaim (23 bits for 55x). */
-	u32 resvd;		/* Keep structure size even for 32-bit DSPs */
-
-	/* Operating Point structure */
-	struct opp_struct opp_table_struct;
-	/* Operating Point Request structure */
-	struct opp_rqst_struct opp_request;
-	/* load monitor information structure */
-	struct load_mon_struct load_mon_info;
-	/* Flag for WDT enable/disable F/I clocks */
-	u32 wdt_setclocks;
-	u32 wdt_overflow;	/* WDT overflow time */
-	char dummy[176];	/* padding to 256 byte boundary */
-	u32 shm_dbg_var[64];	/* shared memory debug variables */
-};
-
-	/* Channel Manager: only one created per board: */
-struct chnl_mgr {
-	/* Function interface to Bridge driver */
-	struct bridge_drv_interface *intf_fxns;
-	struct io_mgr *iomgr;	/* IO manager */
-	/* Device this board represents */
-	struct dev_object *dev_obj;
-
-	/* These fields initialized in bridge_chnl_create(): */
-	u32 output_mask;	/* Host output channels w/ full buffers */
-	u32 last_output;	/* Last output channel fired from DPC */
-	/* Critical section object handle */
-	spinlock_t chnl_mgr_lock;
-	u32 word_size;		/* Size in bytes of DSP word */
-	u8 max_channels;	/* Total number of channels */
-	u8 open_channels;	/* Total number of open channels */
-	struct chnl_object **channels;		/* Array of channels */
-	u8 type;		/* Type of channel class library */
-	/* If no shm syms, return for CHNL_Open */
-	int chnl_open_status;
-};
-
-/*
- *  Channel: up to CHNL_MAXCHANNELS per board or if DSP-DMA supported then
- *     up to CHNL_MAXCHANNELS + CHNL_MAXDDMACHNLS per board.
- */
-struct chnl_object {
-	/* Pointer back to channel manager */
-	struct chnl_mgr *chnl_mgr_obj;
-	u32 chnl_id;		/* Channel id */
-	u8 state;		/* Current channel state */
-	s8 chnl_mode;		/* Chnl mode and attributes */
-	/* Chnl I/O completion event (user mode) */
-	void *user_event;
-	/* Abstract synchronization object */
-	struct sync_object *sync_event;
-	u32 process;		/* Process which created this channel */
-	u32 cb_arg;		/* Argument to use with callback */
-	struct list_head io_requests;	/* List of IOR's to driver */
-	s32 cio_cs;		/* Number of IOC's in queue */
-	s32 cio_reqs;		/* Number of IORequests in queue */
-	s32 chnl_packets;	/* Initial number of free Irps */
-	/* List of IOC's from driver */
-	struct list_head io_completions;
-	struct list_head free_packets_list;	/* List of free Irps */
-	struct ntfy_object *ntfy_obj;
-	u32 bytes_moved;	/* Total number of bytes transferred */
-
-	/* For DSP-DMA */
-
-	/* Type of chnl transport:CHNL_[PCPY][DDMA] */
-	u32 chnl_type;
-};
-
-/* I/O Request/completion packet: */
-struct chnl_irp {
-	struct list_head link;	/* Link to next CHIRP in queue. */
-	/* Buffer to be filled/emptied. (User) */
-	u8 *host_user_buf;
-	/* Buffer to be filled/emptied. (System) */
-	u8 *host_sys_buf;
-	u32 arg;		/* Issue/Reclaim argument. */
-	u32 dsp_tx_addr;	/* Transfer address on DSP side. */
-	u32 byte_size;		/* Bytes transferred. */
-	u32 buf_size;		/* Actual buffer size when allocated. */
-	u32 status;		/* Status of IO completion. */
-};
-
-#endif /* _CHNL_SM_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/brddefs.h b/drivers/staging/tidspbridge/include/dspbridge/brddefs.h
deleted file mode 100644
index 725d7b37..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/brddefs.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * brddefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global BRD constants and types, shared between DSP API and Bridge driver.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef BRDDEFS_
-#define BRDDEFS_
-
-/* platform status values */
-#define BRD_STOPPED     0x0	/* No Monitor Loaded, Not running. */
-#define BRD_IDLE        0x1	/* Monitor Loaded, but suspended. */
-#define BRD_RUNNING     0x2	/* Monitor loaded, and executing. */
-#define BRD_UNKNOWN     0x3	/* Board state is indeterminate. */
-#define BRD_LOADED      0x5
-#define BRD_SLEEP_TRANSITION 0x6	/* Sleep transition in progress */
-#define BRD_HIBERNATION 0x7	/* MPU initiated hibernation */
-#define BRD_RETENTION     0x8	/* Retention mode */
-#define BRD_DSP_HIBERNATION     0x9	/* DSP initiated hibernation */
-#define BRD_ERROR		0xA	/* Board state is Error */
-
-/* BRD Object */
-struct brd_object;
-
-#endif /* BRDDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/cfgdefs.h b/drivers/staging/tidspbridge/include/dspbridge/cfgdefs.h
deleted file mode 100644
index b32c756..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/cfgdefs.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * cfgdefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global CFG constants and types, shared between DSP API and Bridge driver.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef CFGDEFS_
-#define CFGDEFS_
-
-/* Host Resources: */
-#define CFG_MAXMEMREGISTERS     9
-
-/* IRQ flag */
-#define CFG_IRQSHARED           0x01	/* IRQ can be shared */
-
-/* A platform-related device handle: */
-struct cfg_devnode;
-
-/*
- *  Host resource structure.
- */
-struct cfg_hostres {
-	u32 num_mem_windows;	/* Set to default */
-	/* This is the base.memory */
-	u32 mem_base[CFG_MAXMEMREGISTERS];	/* shm virtual address */
-	u32 mem_length[CFG_MAXMEMREGISTERS];	/* Length of the Base */
-	u32 mem_phys[CFG_MAXMEMREGISTERS];	/* shm Physical address */
-	u8 birq_registers;	/* IRQ Number */
-	u8 birq_attrib;		/* IRQ Attribute */
-	u32 offset_for_monitor;	/* The Shared memory starts from
-					 * mem_base + this offset */
-	/*
-	 *  Info needed by NODE for allocating channels to communicate with RMS:
-	 *      chnl_offset:       Offset of RMS channels. Lower channels are
-	 *                          reserved.
-	 *      chnl_buf_size:      Size of channel buffer to send to RMS
-	 *      num_chnls:		Total number of channels
-	 *      			(including reserved).
-	 */
-	u32 chnl_offset;
-	u32 chnl_buf_size;
-	u32 num_chnls;
-	void __iomem *per_base;
-	void __iomem *per_pm_base;
-	void __iomem *core_pm_base;
-	void __iomem *dmmu_base;
-};
-
-#endif /* CFGDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/chnl.h b/drivers/staging/tidspbridge/include/dspbridge/chnl.h
deleted file mode 100644
index 9b018b1..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/chnl.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * chnl.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP API channel interface: multiplexes data streams through the single
- * physical link managed by a Bridge driver.
- *
- * See DSP API chnl.h for more details.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef CHNL_
-#define CHNL_
-
-#include <dspbridge/chnlpriv.h>
-
-/*
- *  ======== chnl_create ========
- *  Purpose:
- *      Create a channel manager object, responsible for opening new channels
- *      and closing old ones for a given board.
- *  Parameters:
- *      channel_mgr:    Location to store a channel manager object on output.
- *      hdev_obj:     Handle to a device object.
- *      mgr_attrts:      Channel manager attributes.
- *      mgr_attrts->max_channels:   Max channels
- *      mgr_attrts->birq:        Channel's I/O IRQ number.
- *      mgr_attrts->irq_shared:     TRUE if the IRQ is shareable.
- *      mgr_attrts->word_size:   DSP Word size in equivalent PC bytes..
- *  Returns:
- *      0:                Success;
- *      -EFAULT:            hdev_obj is invalid.
- *      -EINVAL: max_channels is 0.
- *               Invalid DSP word size (must be > 0).
- *               Invalid base address for DSP communications.
- *      -ENOMEM:            Insufficient memory for requested resources.
- *      -EIO:             Unable to plug channel ISR for configured IRQ.
- *      -ECHRNG:     This manager cannot handle this many channels.
- *      -EEXIST:       Channel manager already exists for this device.
- *  Requires:
- *      channel_mgr != NULL.
- *      mgr_attrts != NULL.
- *  Ensures:
- *      0:                Subsequent calls to chnl_create() for the same
- *                              board without an intervening call to
- *                              chnl_destroy() will fail.
- */
-extern int chnl_create(struct chnl_mgr **channel_mgr,
-			      struct dev_object *hdev_obj,
-			      const struct chnl_mgrattrs *mgr_attrts);
-
-/*
- *  ======== chnl_destroy ========
- *  Purpose:
- *      Close all open channels, and destroy the channel manager.
- *  Parameters:
- *      hchnl_mgr:           Channel manager object.
- *  Returns:
- *      0:            Success.
- *      -EFAULT:        hchnl_mgr was invalid.
- *  Requires:
- *  Ensures:
- *      0:            Cancels I/O on each open channel.
- *                          Closes each open channel.
- *                          chnl_create may subsequently be called for the
- *                          same board.
- */
-extern int chnl_destroy(struct chnl_mgr *hchnl_mgr);
-
-#endif /* CHNL_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/chnldefs.h b/drivers/staging/tidspbridge/include/dspbridge/chnldefs.h
deleted file mode 100644
index cb67c30..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/chnldefs.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * chnldefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * System-wide channel objects and constants.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef CHNLDEFS_
-#define CHNLDEFS_
-
-/* Channel id option. */
-#define CHNL_PICKFREE       (~0UL)	/* Let manager pick a free channel. */
-
-/* Channel modes */
-#define CHNL_MODETODSP		0	/* Data streaming to the DSP. */
-#define CHNL_MODEFROMDSP	1	/* Data streaming from the DSP. */
-
-/* GetIOCompletion flags */
-#define CHNL_IOCINFINITE     0xffffffff	/* Wait forever for IO completion. */
-#define CHNL_IOCNOWAIT       0x0	/* Dequeue an IOC, if available. */
-
-/* IO Completion Record status: */
-#define CHNL_IOCSTATCOMPLETE 0x0000	/* IO Completed. */
-#define CHNL_IOCSTATCANCEL   0x0002	/* IO was cancelled */
-#define CHNL_IOCSTATTIMEOUT  0x0008	/* Wait for IOC timed out. */
-#define CHNL_IOCSTATEOS      0x8000	/* End Of Stream reached. */
-
-/* Macros for checking I/O Completion status: */
-#define CHNL_IS_IO_COMPLETE(ioc)  (!(ioc.status & ~CHNL_IOCSTATEOS))
-#define CHNL_IS_IO_CANCELLED(ioc) (ioc.status & CHNL_IOCSTATCANCEL)
-#define CHNL_IS_TIMED_OUT(ioc)    (ioc.status & CHNL_IOCSTATTIMEOUT)
-
-/* Channel attributes: */
-struct chnl_attr {
-	u32 uio_reqs;		/* Max # of preallocated I/O requests. */
-	void *event_obj;	/* User supplied auto-reset event object. */
-	char *str_event_name;	/* Ptr to name of user event object. */
-	void *reserved1;	/* Reserved for future use. */
-	u32 reserved2;		/* Reserved for future use. */
-
-};
-
-/* I/O completion record: */
-struct chnl_ioc {
-	void *buf;		/* Buffer to be filled/emptied. */
-	u32 byte_size;		/* Bytes transferred. */
-	u32 buf_size;		/* Actual buffer size in bytes */
-	u32 status;		/* Status of IO completion. */
-	u32 arg;		/* User argument associated with buf. */
-};
-
-#endif /* CHNLDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/chnlpriv.h b/drivers/staging/tidspbridge/include/dspbridge/chnlpriv.h
deleted file mode 100644
index 4114c79..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/chnlpriv.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * chnlpriv.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Private channel header shared between DSPSYS, DSPAPI and
- * Bridge driver modules.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef CHNLPRIV_
-#define CHNLPRIV_
-
-#include <dspbridge/chnldefs.h>
-#include <dspbridge/devdefs.h>
-#include <dspbridge/sync.h>
-
-/* Channel manager limits: */
-#define CHNL_MAXCHANNELS    32	/* Max channels available per transport */
-
-/*
- *  Trans port channel Id definitions:(must match dsp-side).
- *
- *  For CHNL_MAXCHANNELS = 16:
- *
- *  ChnlIds:
- *      0-15  (PCPY) - transport 0)
- *      16-31 (DDMA) - transport 1)
- *      32-47 (ZCPY) - transport 2)
- */
-#define CHNL_PCPY       0	/* Proc-copy transport 0 */
-
-/* Higher level channel states: */
-#define CHNL_STATEREADY		0	/* Channel ready for I/O. */
-#define CHNL_STATECANCEL	1	/* I/O was cancelled. */
-#define CHNL_STATEEOS		2	/* End Of Stream reached. */
-
-/* Macros for checking mode: */
-#define CHNL_IS_INPUT(mode)      (mode & CHNL_MODEFROMDSP)
-#define CHNL_IS_OUTPUT(mode)     (!CHNL_IS_INPUT(mode))
-
-/* Types of channel class libraries: */
-#define CHNL_TYPESM         1	/* Shared memory driver. */
-
-/* Channel info. */
-struct chnl_info {
-	struct chnl_mgr *chnl_mgr;	/* Owning channel manager. */
-	u32 cnhl_id;		/* Channel ID. */
-	void *event_obj;	/* Channel I/O completion event. */
-	/*Abstraction of I/O completion event. */
-	struct sync_object *sync_event;
-	s8 mode;		/* Channel mode. */
-	u8 state;		/* Current channel state. */
-	u32 bytes_tx;		/* Total bytes transferred. */
-	u32 cio_cs;		/* Number of IOCs in queue. */
-	u32 cio_reqs;		/* Number of IO Requests in queue. */
-	u32 process;		/* Process owning this channel. */
-};
-
-/* Channel manager info: */
-struct chnl_mgrinfo {
-	u8 type;		/* Type of channel class library. */
-	/* Channel handle, given the channel id. */
-	struct chnl_object *chnl_obj;
-	u8 open_channels;	/* Number of open channels. */
-	u8 max_channels;	/* total # of chnls supported */
-};
-
-/* Channel Manager Attrs: */
-struct chnl_mgrattrs {
-	/* Max number of channels this manager can use. */
-	u8 max_channels;
-	u32 word_size;		/* DSP Word size. */
-};
-
-#endif /* CHNLPRIV_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/clk.h b/drivers/staging/tidspbridge/include/dspbridge/clk.h
deleted file mode 100644
index 685341c..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/clk.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * clk.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Provides Clock functions.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _CLK_H
-#define _CLK_H
-
-enum dsp_clk_id {
-	DSP_CLK_IVA2 = 0,
-	DSP_CLK_GPT5,
-	DSP_CLK_GPT6,
-	DSP_CLK_GPT7,
-	DSP_CLK_GPT8,
-	DSP_CLK_WDT3,
-	DSP_CLK_MCBSP1,
-	DSP_CLK_MCBSP2,
-	DSP_CLK_MCBSP3,
-	DSP_CLK_MCBSP4,
-	DSP_CLK_MCBSP5,
-	DSP_CLK_SSI,
-	DSP_CLK_NOT_DEFINED
-};
-
-/*
- *  ======== dsp_clk_exit ========
- *  Purpose:
- *      Discontinue usage of module; free resources when reference count
- *      reaches 0.
- *  Parameters:
- *  Returns:
- *  Requires:
- *      CLK initialized.
- *  Ensures:
- *      Resources used by module are freed when cRef reaches zero.
- */
-extern void dsp_clk_exit(void);
-
-/*
- *  ======== dsp_clk_init ========
- *  Purpose:
- *      Initializes private state of CLK module.
- *  Parameters:
- *  Returns:
- *      TRUE if initialized; FALSE if error occurred.
- *  Requires:
- *  Ensures:
- *      CLK initialized.
- */
-extern void dsp_clk_init(void);
-
-void dsp_gpt_wait_overflow(short int clk_id, unsigned int load);
-
-/*
- *  ======== dsp_clk_enable ========
- *  Purpose:
- *      Enables the clock requested.
- *  Parameters:
- *  Returns:
- *      0:	Success.
- *	-EPERM:	Error occurred while enabling the clock.
- *  Requires:
- *  Ensures:
- */
-extern int dsp_clk_enable(enum dsp_clk_id clk_id);
-
-u32 dsp_clock_enable_all(u32 dsp_per_clocks);
-
-/*
- *  ======== dsp_clk_disable ========
- *  Purpose:
- *      Disables the clock requested.
- *  Parameters:
- *  Returns:
- *      0:        Success.
- *      -EPERM:      Error occurred while disabling the clock.
- *  Requires:
- *  Ensures:
- */
-extern int dsp_clk_disable(enum dsp_clk_id clk_id);
-
-extern u32 dsp_clk_get_iva2_rate(void);
-
-u32 dsp_clock_disable_all(u32 dsp_per_clocks);
-
-extern void ssi_clk_prepare(bool FLAG);
-
-#endif /* _SYNC_H */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/cmm.h b/drivers/staging/tidspbridge/include/dspbridge/cmm.h
deleted file mode 100644
index 2adf9ec..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/cmm.h
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * cmm.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * The Communication Memory Management(CMM) module provides shared memory
- * management services for DSP/BIOS Bridge data streaming and messaging.
- * Multiple shared memory segments can be registered with CMM. Memory is
- * coelesced back to the appropriate pool when a buffer is freed.
- *
- * The CMM_Xlator[xxx] functions are used for node messaging and data
- * streaming address translation to perform zero-copy inter-processor
- * data transfer(GPP<->DSP). A "translator" object is created for a node or
- * stream object that contains per thread virtual address information. This
- * translator info is used at runtime to perform SM address translation
- * to/from the DSP address space.
- *
- * Notes:
- *   cmm_xlator_alloc_buf - Used by Node and Stream modules for SM address
- *			  translation.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef CMM_
-#define CMM_
-
-#include <dspbridge/devdefs.h>
-
-#include <dspbridge/cmmdefs.h>
-#include <dspbridge/host_os.h>
-
-/*
- *  ======== cmm_calloc_buf ========
- *  Purpose:
- *      Allocate memory buffers that can be used for data streaming or
- *      messaging.
- *  Parameters:
- *      hcmm_mgr:   Cmm Mgr handle.
- *      usize:     Number of bytes to allocate.
- *      pattr:     Attributes of memory to allocate.
- *      pp_buf_va:   Address of where to place VA.
- *  Returns:
- *      Pointer to a zero'd block of SM memory;
- *      NULL if memory couldn't be allocated,
- *      or if byte_size == 0,
- *  Requires:
- *      Valid hcmm_mgr.
- *      CMM initialized.
- *  Ensures:
- *      The returned pointer, if not NULL, points to a valid memory block of
- *      the size requested.
- *
- */
-extern void *cmm_calloc_buf(struct cmm_object *hcmm_mgr,
-			    u32 usize, struct cmm_attrs *pattrs,
-			    void **pp_buf_va);
-
-/*
- *  ======== cmm_create ========
- *  Purpose:
- *      Create a communication memory manager object.
- *  Parameters:
- *      ph_cmm_mgr:	Location to store a communication manager handle on
- *      		output.
- *      hdev_obj: Handle to a device object.
- *      mgr_attrts: Comm mem manager attributes.
- *  Returns:
- *      0:        Success;
- *      -ENOMEM:    Insufficient memory for requested resources.
- *      -EPERM:      Failed to initialize critical sect sync object.
- *
- *  Requires:
- *      ph_cmm_mgr != NULL.
- *      mgr_attrts->min_block_size >= 4 bytes.
- *  Ensures:
- *
- */
-extern int cmm_create(struct cmm_object **ph_cmm_mgr,
-			     struct dev_object *hdev_obj,
-			     const struct cmm_mgrattrs *mgr_attrts);
-
-/*
- *  ======== cmm_destroy ========
- *  Purpose:
- *      Destroy the communication memory manager object.
- *  Parameters:
- *      hcmm_mgr:   Cmm Mgr handle.
- *      force:     Force deallocation of all cmm memory immediately if set TRUE.
- *                 If FALSE, and outstanding allocations will return -EPERM
- *                 status.
- *  Returns:
- *      0:        CMM object & resources deleted.
- *      -EPERM:      Unable to free CMM object due to outstanding allocation.
- *      -EFAULT:    Unable to free CMM due to bad handle.
- *  Requires:
- *      CMM is initialized.
- *      hcmm_mgr != NULL.
- *  Ensures:
- *      Memory resources used by Cmm Mgr are freed.
- */
-extern int cmm_destroy(struct cmm_object *hcmm_mgr, bool force);
-
-/*
- *  ======== cmm_free_buf ========
- *  Purpose:
- *      Free the given buffer.
- *  Parameters:
- *      hcmm_mgr:    Cmm Mgr handle.
- *      pbuf:       Pointer to memory allocated by cmm_calloc_buf().
- *      ul_seg_id:    SM segment Id used in CMM_Calloc() attrs.
- *                  Set to 0 to use default segment.
- *  Returns:
- *      0
- *      -EPERM
- *  Requires:
- *      CMM initialized.
- *      buf_pa != NULL
- *  Ensures:
- *
- */
-extern int cmm_free_buf(struct cmm_object *hcmm_mgr,
-			       void *buf_pa, u32 ul_seg_id);
-
-/*
- *  ======== cmm_get_handle ========
- *  Purpose:
- *      Return the handle to the cmm mgr for the given device obj.
- *  Parameters:
- *      hprocessor:   Handle to a Processor.
- *      ph_cmm_mgr:	Location to store the shared memory mgr handle on
- *      		output.
- *
- *  Returns:
- *      0:        Cmm Mgr opaque handle returned.
- *      -EFAULT:    Invalid handle.
- *  Requires:
- *      ph_cmm_mgr != NULL
- *      hdev_obj != NULL
- *  Ensures:
- */
-extern int cmm_get_handle(void *hprocessor,
-				 struct cmm_object **ph_cmm_mgr);
-
-/*
- *  ======== cmm_get_info ========
- *  Purpose:
- *      Return the current SM and VM utilization information.
- *  Parameters:
- *      hcmm_mgr:     Handle to a Cmm Mgr.
- *      cmm_info_obj:    Location to store the Cmm information on output.
- *
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid handle.
- *      -EINVAL Invalid input argument.
- *  Requires:
- *  Ensures:
- *
- */
-extern int cmm_get_info(struct cmm_object *hcmm_mgr,
-			       struct cmm_info *cmm_info_obj);
-
-/*
- *  ======== cmm_register_gppsm_seg ========
- *  Purpose:
- *      Register a block of SM with the CMM.
- *  Parameters:
- *      hcmm_mgr:         Handle to a Cmm Mgr.
- *      lpGPPBasePA:     GPP Base Physical address.
- *      ul_size:          Size in GPP bytes.
- *      dsp_addr_offset  GPP PA to DSP PA Offset.
- *      c_factor:         Add offset if CMM_ADDTODSPPA, sub if CMM_SUBFROMDSPPA.
- *      dw_dsp_base:       DSP virtual base byte address.
- *      ul_dsp_size:       Size of DSP segment in bytes.
- *      sgmt_id:         Address to store segment Id.
- *
- *  Returns:
- *      0:         Success.
- *      -EFAULT:     Invalid hcmm_mgr handle.
- *      -EINVAL: Invalid input argument.
- *      -EPERM:       Unable to register.
- *      - On success *sgmt_id is a valid SM segment ID.
- *  Requires:
- *      ul_size > 0
- *      sgmt_id != NULL
- *      dw_gpp_base_pa != 0
- *      c_factor = CMM_ADDTODSPPA || c_factor = CMM_SUBFROMDSPPA
- *  Ensures:
- *
- */
-extern int cmm_register_gppsm_seg(struct cmm_object *hcmm_mgr,
-					 unsigned int dw_gpp_base_pa,
-					 u32 ul_size,
-					 u32 dsp_addr_offset,
-					 s8 c_factor,
-					 unsigned int dw_dsp_base,
-					 u32 ul_dsp_size,
-					 u32 *sgmt_id, u32 gpp_base_va);
-
-/*
- *  ======== cmm_un_register_gppsm_seg ========
- *  Purpose:
- *      Unregister the given memory segment that was previously registered
- *      by cmm_register_gppsm_seg.
- *  Parameters:
- *      hcmm_mgr:    Handle to a Cmm Mgr.
- *      ul_seg_id     Segment identifier returned by cmm_register_gppsm_seg.
- *  Returns:
- *       0:         Success.
- *       -EFAULT:     Invalid handle.
- *       -EINVAL: Invalid ul_seg_id.
- *       -EPERM:       Unable to unregister for unknown reason.
- *  Requires:
- *  Ensures:
- *
- */
-extern int cmm_un_register_gppsm_seg(struct cmm_object *hcmm_mgr,
-					    u32 ul_seg_id);
-
-/*
- *  ======== cmm_xlator_alloc_buf ========
- *  Purpose:
- *      Allocate the specified SM buffer and create a local memory descriptor.
- *      Place on the descriptor on the translator's HaQ (Host Alloc'd Queue).
- *  Parameters:
- *      xlator:    Handle to a Xlator object.
- *      va_buf:     Virtual address ptr(client context)
- *      pa_size:    Size of SM memory to allocate.
- *  Returns:
- *      Ptr to valid physical address(Pa) of pa_size bytes, NULL if failed.
- *  Requires:
- *      va_buf != 0.
- *      pa_size != 0.
- *  Ensures:
- *
- */
-extern void *cmm_xlator_alloc_buf(struct cmm_xlatorobject *xlator,
-				  void *va_buf, u32 pa_size);
-
-/*
- *  ======== cmm_xlator_create ========
- *  Purpose:
- *     Create a translator(xlator) object used for process specific Va<->Pa
- *     address translation. Node messaging and streams use this to perform
- *     inter-processor(GPP<->DSP) zero-copy data transfer.
- *  Parameters:
- *     xlator:         Address to place handle to a new Xlator handle.
- *     hcmm_mgr:        Handle to Cmm Mgr associated with this translator.
- *     xlator_attrs:   Translator attributes used for the client NODE or STREAM.
- *  Returns:
- *     0:            Success.
- *     -EINVAL:    Bad input Attrs.
- *     -ENOMEM:   Insufficient memory(local) for requested resources.
- *  Requires:
- *     xlator != NULL
- *     hcmm_mgr != NULL
- *     xlator_attrs != NULL
- *  Ensures:
- *
- */
-extern int cmm_xlator_create(struct cmm_xlatorobject **xlator,
-				    struct cmm_object *hcmm_mgr,
-				    struct cmm_xlatorattrs *xlator_attrs);
-
-/*
- *  ======== cmm_xlator_free_buf ========
- *  Purpose:
- *      Free SM buffer and descriptor.
- *      Does not free client process VM.
- *  Parameters:
- *      xlator:    handle to translator.
- *      buf_va      Virtual address of PA to free.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Bad translator handle.
- *  Requires:
- *  Ensures:
- *
- */
-extern int cmm_xlator_free_buf(struct cmm_xlatorobject *xlator,
-				      void *buf_va);
-
-/*
- *  ======== cmm_xlator_info ========
- *  Purpose:
- *      Set/Get process specific "translator" address info.
- *      This is used to perform fast virtual address translation
- *      for shared memory buffers between the GPP and DSP.
- *  Parameters:
- *     xlator:     handle to translator.
- *     paddr:       Virtual base address of segment.
- *     ul_size:      Size in bytes.
- *     segm_id:     Segment identifier of SM segment(s)
- *     set_info     Set xlator fields if TRUE, else return base addr
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Bad translator handle.
- *  Requires:
- *      (paddr != NULL)
- *      (ul_size > 0)
- *  Ensures:
- *
- */
-extern int cmm_xlator_info(struct cmm_xlatorobject *xlator,
-				  u8 **paddr,
-				  u32 ul_size, u32 segm_id, bool set_info);
-
-/*
- *  ======== cmm_xlator_translate ========
- *  Purpose:
- *      Perform address translation VA<->PA for the specified stream or
- *      message shared memory buffer.
- *  Parameters:
- *     xlator: handle to translator.
- *     paddr    address of buffer to translate.
- *     xtype    Type of address xlation. CMM_PA2VA or CMM_VA2PA.
- *  Returns:
- *     Valid address on success, else NULL.
- *  Requires:
- *      paddr != NULL
- *      xtype >= CMM_VA2PA) && (xtype <= CMM_DSPPA2PA)
- *  Ensures:
- *
- */
-extern void *cmm_xlator_translate(struct cmm_xlatorobject *xlator,
-				  void *paddr, enum cmm_xlatetype xtype);
-
-#endif /* CMM_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/cmmdefs.h b/drivers/staging/tidspbridge/include/dspbridge/cmmdefs.h
deleted file mode 100644
index a264fa69..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/cmmdefs.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * cmmdefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global MEM constants and types.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef CMMDEFS_
-#define CMMDEFS_
-
-
-/* Cmm attributes used in cmm_create() */
-struct cmm_mgrattrs {
-	/* Minimum SM allocation; default 32 bytes. */
-	u32 min_block_size;
-};
-
-/* Attributes for CMM_AllocBuf() & CMM_AllocDesc() */
-struct cmm_attrs {
-	u32 seg_id;		/*  1,2... are SM segments. 0 is not. */
-	u32 alignment;		/*  0,1,2,4....min_block_size */
-};
-
-/*
- *  DSPPa to GPPPa Conversion Factor.
- *
- *  For typical platforms:
- *      converted Address = PaDSP + ( c_factor * addressToConvert).
- */
-#define CMM_SUBFROMDSPPA	-1
-#define CMM_ADDTODSPPA		1
-
-#define CMM_ALLSEGMENTS         0xFFFFFF	/* All SegIds */
-#define CMM_MAXGPPSEGS          1	/* Maximum # of SM segs */
-
-/*
- *  SMSEGs are SM segments the DSP allocates from.
- *
- *  This info is used by the GPP to xlate DSP allocated PAs.
- */
-
-struct cmm_seginfo {
-	u32 seg_base_pa;	/* Start Phys address of SM segment */
-	/* Total size in bytes of segment: DSP+GPP */
-	u32 total_seg_size;
-	u32 gpp_base_pa;	/* Start Phys addr of Gpp SM seg */
-	u32 gpp_size;	/* Size of Gpp SM seg in bytes */
-	u32 dsp_base_va;	/* DSP virt base byte address */
-	u32 dsp_size;		/* DSP seg size in bytes */
-	/* # of current GPP allocations from this segment */
-	u32 in_use_cnt;
-	u32 seg_base_va;	/* Start Virt address of SM seg */
-
-};
-
-/* CMM useful information */
-struct cmm_info {
-	/* # of SM segments registered with this Cmm. */
-	u32 num_gppsm_segs;
-	/* Total # of allocations outstanding for CMM */
-	u32 total_in_use_cnt;
-	/* Min SM block size allocation from cmm_create() */
-	u32 min_block_size;
-	/* Info per registered SM segment. */
-	struct cmm_seginfo seg_info[CMM_MAXGPPSEGS];
-};
-
-/* XlatorCreate attributes */
-struct cmm_xlatorattrs {
-	u32 seg_id;		/* segment Id used for SM allocations */
-	u32 dsp_bufs;		/* # of DSP-side bufs */
-	u32 dsp_buf_size;	/* size of DSP-side bufs in GPP bytes */
-	/* Vm base address alloc'd in client process context */
-	void *vm_base;
-	/* vm_size must be >= (dwMaxNumBufs * dwMaxSize) */
-	u32 vm_size;
-};
-
-/*
- * Cmm translation types. Use to map SM addresses to process context.
- */
-enum cmm_xlatetype {
-	CMM_VA2PA = 0,		/* Virtual to GPP physical address xlation */
-	CMM_PA2VA = 1,		/* GPP Physical to virtual */
-	CMM_VA2DSPPA = 2,	/* Va to DSP Pa */
-	CMM_PA2DSPPA = 3,	/* GPP Pa to DSP Pa */
-	CMM_DSPPA2PA = 4,	/* DSP Pa to GPP Pa */
-};
-
-struct cmm_object;
-struct cmm_xlatorobject;
-
-#endif /* CMMDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/cod.h b/drivers/staging/tidspbridge/include/dspbridge/cod.h
deleted file mode 100644
index ba2005d..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/cod.h
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * cod.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Code management module for DSPs. This module provides an interface
- * interface for loading both static and dynamic code objects onto DSP
- * systems.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef COD_
-#define COD_
-
-#include <dspbridge/dblldefs.h>
-
-#define COD_MAXPATHLENGTH       255
-#define COD_TRACEBEG            "SYS_PUTCBEG"
-#define COD_TRACEEND            "SYS_PUTCEND"
-#define COD_TRACECURPOS	"BRIDGE_SYS_PUTC_current"
-
-#define COD_NOLOAD              DBLL_NOLOAD
-#define COD_SYMB                DBLL_SYMB
-
-/* COD code manager handle */
-struct cod_manager;
-
-/* COD library handle */
-struct cod_libraryobj;
-
-/*
- *  Function prototypes for writing memory to a DSP system, allocating
- *  and freeing DSP memory.
- */
-typedef u32(*cod_writefxn) (void *priv_ref, u32 dsp_add,
-			    void *pbuf, u32 ul_num_bytes, u32 mem_space);
-
-/*
- *  ======== cod_close ========
- *  Purpose:
- *      Close a library opened with cod_open().
- *  Parameters:
- *      lib             - Library handle returned by cod_open().
- *  Returns:
- *      None.
- *  Requires:
- *      COD module initialized.
- *      valid lib.
- *  Ensures:
- *
- */
-extern void cod_close(struct cod_libraryobj *lib);
-
-/*
- *  ======== cod_create ========
- *  Purpose:
- *      Create an object to manage code on a DSP system. This object can be
- *      used to load an initial program image with arguments that can later
- *      be expanded with dynamically loaded object files.
- *      Symbol table information is managed by this object and can be retrieved
- *      using the cod_get_sym_value() function.
- *  Parameters:
- *      manager:        created manager object
- *      str_zl_file:    ZL DLL filename, of length < COD_MAXPATHLENGTH.
- *  Returns:
- *      0:                Success.
- *      -ESPIPE:   ZL_Create failed.
- *      -ENOSYS:           attrs was not NULL.  We don't yet support
- *                              non default values of attrs.
- *  Requires:
- *      COD module initialized.
- *      str_zl_file != NULL
- *  Ensures:
- */
-extern int cod_create(struct cod_manager **mgr,
-			     char *str_zl_file);
-
-/*
- *  ======== cod_delete ========
- *  Purpose:
- *      Delete a code manager object.
- *  Parameters:
- *      cod_mgr_obj:   handle of manager to be deleted
- *  Returns:
- *      None.
- *  Requires:
- *      COD module initialized.
- *      valid cod_mgr_obj.
- *  Ensures:
- */
-extern void cod_delete(struct cod_manager *cod_mgr_obj);
-
-/*
- *  ======== cod_get_base_lib ========
- *  Purpose:
- *      Get handle to the base image DBL library.
- *  Parameters:
- *      cod_mgr_obj:   handle of manager to be deleted
- *      plib:       location to store library handle on output.
- *  Returns:
- *      0:    Success.
- *  Requires:
- *      COD module initialized.
- *      valid cod_mgr_obj.
- *      plib != NULL.
- *  Ensures:
- */
-extern int cod_get_base_lib(struct cod_manager *cod_mgr_obj,
-				   struct dbll_library_obj **plib);
-
-/*
- *  ======== cod_get_base_name ========
- *  Purpose:
- *      Get the name of the base image DBL library.
- *  Parameters:
- *      cod_mgr_obj:   handle of manager to be deleted
- *      sz_name:    location to store library name on output.
- *      usize:       size of name buffer.
- *  Returns:
- *      0:    Success.
- *      -EPERM:  Buffer too small.
- *  Requires:
- *      COD module initialized.
- *      valid cod_mgr_obj.
- *      sz_name != NULL.
- *  Ensures:
- */
-extern int cod_get_base_name(struct cod_manager *cod_mgr_obj,
-				    char *sz_name, u32 usize);
-
-/*
- *  ======== cod_get_entry ========
- *  Purpose:
- *      Retrieve the entry point of a loaded DSP program image
- *  Parameters:
- *      cod_mgr_obj:   handle of manager to be deleted
- *      entry_pt:   pointer to location for entry point
- *  Returns:
- *      0:       Success.
- *  Requires:
- *      COD module initialized.
- *      valid cod_mgr_obj.
- *      entry_pt != NULL.
- *  Ensures:
- */
-extern int cod_get_entry(struct cod_manager *cod_mgr_obj,
-				u32 *entry_pt);
-
-/*
- *  ======== cod_get_loader ========
- *  Purpose:
- *      Get handle to the DBL loader.
- *  Parameters:
- *      cod_mgr_obj:   handle of manager to be deleted
- *      loader:     location to store loader handle on output.
- *  Returns:
- *      0:    Success.
- *  Requires:
- *      COD module initialized.
- *      valid cod_mgr_obj.
- *      loader != NULL.
- *  Ensures:
- */
-extern int cod_get_loader(struct cod_manager *cod_mgr_obj,
-				 struct dbll_tar_obj **loader);
-
-/*
- *  ======== cod_get_section ========
- *  Purpose:
- *      Retrieve the starting address and length of a section in the COFF file
- *      given the section name.
- *  Parameters:
- *      lib         Library handle returned from cod_open().
- *      str_sect:   name of the section, with or without leading "."
- *      addr:       Location to store address.
- *      len:        Location to store length.
- *  Returns:
- *      0:                Success
- *      -ESPIPE:  Symbols could not be found or have not been loaded onto
- *                the board.
- *  Requires:
- *      COD module initialized.
- *      valid cod_mgr_obj.
- *      str_sect != NULL;
- *      addr != NULL;
- *      len != NULL;
- *  Ensures:
- *      0:  *addr and *len contain the address and length of the
- *                 section.
- *      else:  *addr == 0 and *len == 0;
- *
- */
-extern int cod_get_section(struct cod_libraryobj *lib,
-				  char *str_sect,
-				  u32 *addr, u32 *len);
-
-/*
- *  ======== cod_get_sym_value ========
- *  Purpose:
- *      Retrieve the value for the specified symbol. The symbol is first
- *      searched for literally and then, if not found, searched for as a
- *      C symbol.
- *  Parameters:
- *      lib:        library handle returned from cod_open().
- *      pstrSymbol: name of the symbol
- *      value:      value of the symbol
- *  Returns:
- *      0:                Success.
- *      -ESPIPE:  Symbols could not be found or have not been loaded onto
- *                the board.
- *  Requires:
- *      COD module initialized.
- *      Valid cod_mgr_obj.
- *      str_sym != NULL.
- *      pul_value != NULL.
- *  Ensures:
- */
-extern int cod_get_sym_value(struct cod_manager *cod_mgr_obj,
-				    char *str_sym, u32 * pul_value);
-
-/*
- *  ======== cod_load_base ========
- *  Purpose:
- *      Load the initial program image, optionally with command-line arguments,
- *      on the DSP system managed by the supplied handle. The program to be
- *      loaded must be the first element of the args array and must be a fully
- *      qualified pathname.
- *  Parameters:
- *      hmgr:       manager to load the code with
- *      num_argc:   number of arguments in the args array
- *      args:       array of strings for arguments to DSP program
- *      write_fxn:   board-specific function to write data to DSP system
- *      arb:       arbitrary pointer to be passed as first arg to write_fxn
- *      envp:       array of environment strings for DSP exec.
- *  Returns:
- *      0:                   Success.
- *      -EBADF:       Failed to open target code.
- *  Requires:
- *      COD module initialized.
- *      hmgr is valid.
- *      num_argc > 0.
- *      args != NULL.
- *      args[0] != NULL.
- *      pfn_write != NULL.
- *  Ensures:
- */
-extern int cod_load_base(struct cod_manager *cod_mgr_obj,
-				u32 num_argc, char *args[],
-				cod_writefxn pfn_write, void *arb,
-				char *envp[]);
-
-/*
- *  ======== cod_open ========
- *  Purpose:
- *      Open a library for reading sections. Does not load or set the base.
- *  Parameters:
- *      hmgr:           manager to load the code with
- *      sz_coff_path:   Coff file to open.
- *      flags:          COD_NOLOAD (don't load symbols) or COD_SYMB (load
- *                      symbols).
- *      lib_obj:        Handle returned that can be used in calls to cod_close
- *                      and cod_get_section.
- *  Returns:
- *      S_OK:                   Success.
- *      -EBADF:       Failed to open target code.
- *  Requires:
- *      COD module initialized.
- *      hmgr is valid.
- *      flags == COD_NOLOAD || flags == COD_SYMB.
- *      sz_coff_path != NULL.
- *  Ensures:
- */
-extern int cod_open(struct cod_manager *hmgr,
-			   char *sz_coff_path,
-			   u32 flags, struct cod_libraryobj **lib_obj);
-
-/*
- *  ======== cod_open_base ========
- *  Purpose:
- *      Open base image for reading sections. Does not load the base.
- *  Parameters:
- *      hmgr:           manager to load the code with
- *      sz_coff_path:   Coff file to open.
- *      flags:          Specifies whether to load symbols.
- *  Returns:
- *      0:            Success.
- *      -EBADF:   Failed to open target code.
- *  Requires:
- *      COD module initialized.
- *      hmgr is valid.
- *      sz_coff_path != NULL.
- *  Ensures:
- */
-extern int cod_open_base(struct cod_manager *hmgr, char *sz_coff_path,
-				dbll_flags flags);
-
-/*
- *  ======== cod_read_section ========
- *  Purpose:
- *      Retrieve the content of a code section given the section name.
- *  Parameters:
- *      cod_mgr_obj    - manager in which to search for the symbol
- *      str_sect    - name of the section, with or without leading "."
- *      str_content - buffer to store content of the section.
- *  Returns:
- *      0: on success, error code on failure
- *      -ESPIPE:  Symbols have not been loaded onto the board.
- *  Requires:
- *      COD module initialized.
- *      valid cod_mgr_obj.
- *      str_sect != NULL;
- *      str_content != NULL;
- *  Ensures:
- *      0:  *str_content stores the content of the named section.
- */
-extern int cod_read_section(struct cod_libraryobj *lib,
-				   char *str_sect,
-				   char *str_content, u32 content_size);
-
-#endif /* COD_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dbdcd.h b/drivers/staging/tidspbridge/include/dspbridge/dbdcd.h
deleted file mode 100644
index 7cc3e12..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dbdcd.h
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * dbdcd.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Defines the DSP/BIOS Bridge Configuration Database (DCD) API.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DBDCD_
-#define DBDCD_
-
-#include <dspbridge/dbdcddef.h>
-#include <dspbridge/host_os.h>
-#include <dspbridge/nldrdefs.h>
-
-/*
- *  ======== dcd_auto_register ========
- *  Purpose:
- *      This function automatically registers DCD objects specified in a
- *      special COFF section called ".dcd_register"
- *  Parameters:
- *      hdcd_mgr:                A DCD manager handle.
- *      sz_coff_path:           Pointer to name of COFF file containing DCD
- *                              objects to be registered.
- *  Returns:
- *      0:                Success.
- *      -EACCES: Unable to find auto-registration/read/load section.
- *      -EFAULT:            Invalid DCD_HMANAGER handle..
- *  Requires:
- *      DCD initialized.
- *  Ensures:
- *  Note:
- *      Due to the DCD database construction, it is essential for a DCD-enabled
- *      COFF file to contain the right COFF sections, especially
- *      ".dcd_register", which is used for auto registration.
- */
-extern int dcd_auto_register(struct dcd_manager *hdcd_mgr,
-				    char *sz_coff_path);
-
-/*
- *  ======== dcd_auto_unregister ========
- *  Purpose:
- *      This function automatically unregisters DCD objects specified in a
- *      special COFF section called ".dcd_register"
- *  Parameters:
- *      hdcd_mgr:                A DCD manager handle.
- *      sz_coff_path:           Pointer to name of COFF file containing
- *                              DCD objects to be unregistered.
- *  Returns:
- *      0:                Success.
- *      -EACCES: Unable to find auto-registration/read/load section.
- *      -EFAULT:            Invalid DCD_HMANAGER handle..
- *  Requires:
- *      DCD initialized.
- *  Ensures:
- *  Note:
- *      Due to the DCD database construction, it is essential for a DCD-enabled
- *      COFF file to contain the right COFF sections, especially
- *      ".dcd_register", which is used for auto unregistration.
- */
-extern int dcd_auto_unregister(struct dcd_manager *hdcd_mgr,
-				      char *sz_coff_path);
-
-/*
- *  ======== dcd_create_manager ========
- *  Purpose:
- *      This function creates a DCD module manager.
- *  Parameters:
- *      sz_zl_dll_name: Pointer to a DLL name string.
- *      dcd_mgr:        A pointer to a DCD manager handle.
- *  Returns:
- *      0:        Success.
- *      -ENOMEM:    Unable to allocate memory for DCD manager handle.
- *      -EPERM:      General failure.
- *  Requires:
- *      DCD initialized.
- *      sz_zl_dll_name is non-NULL.
- *      dcd_mgr is non-NULL.
- *  Ensures:
- *      A DCD manager handle is created.
- */
-extern int dcd_create_manager(char *sz_zl_dll_name,
-				     struct dcd_manager **dcd_mgr);
-
-/*
- *  ======== dcd_destroy_manager ========
- *  Purpose:
- *      This function destroys a DCD module manager.
- *  Parameters:
- *      hdcd_mgr:        A DCD manager handle.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid DCD manager handle.
- *  Requires:
- *      DCD initialized.
- *  Ensures:
- */
-extern int dcd_destroy_manager(struct dcd_manager *hdcd_mgr);
-
-/*
- *  ======== dcd_enumerate_object ========
- *  Purpose:
- *      This function enumerates currently visible DSP/BIOS Bridge objects
- *      and returns the UUID and type of each enumerated object.
- *  Parameters:
- *      index:              The object enumeration index.
- *      obj_type:            Type of object to enumerate.
- *      uuid_obj:              Pointer to a dsp_uuid object.
- *  Returns:
- *      0:            Success.
- *      -EPERM:          Unable to enumerate through the DCD database.
- *      ENODATA:  Enumeration completed. This is not an error code.
- *  Requires:
- *      DCD initialized.
- *      uuid_obj is a valid pointer.
- *  Ensures:
- *  Details:
- *      This function can be used in conjunction with dcd_get_object_def to
- *      retrieve object properties.
- */
-extern int dcd_enumerate_object(s32 index,
-				       enum dsp_dcdobjtype obj_type,
-				       struct dsp_uuid *uuid_obj);
-
-/*
- *  ======== dcd_exit ========
- *  Purpose:
- *      This function cleans up the DCD module.
- *  Parameters:
- *  Returns:
- *  Requires:
- *      DCD initialized.
- *  Ensures:
- */
-extern void dcd_exit(void);
-
-/*
- *  ======== dcd_get_dep_libs ========
- *  Purpose:
- *      Given the uuid of a library and size of array of uuids, this function
- *      fills the array with the uuids of all dependent libraries of the input
- *      library.
- *  Parameters:
- *      hdcd_mgr: A DCD manager handle.
- *      uuid_obj: Pointer to a dsp_uuid for a library.
- *      num_libs: Size of uuid array (number of library uuids).
- *      dep_lib_uuids: Array of dependent library uuids to be filled in.
- *      prstnt_dep_libs:    Array indicating if corresponding lib is persistent.
- *      phase: phase to obtain correct input library
- *  Returns:
- *      0: Success.
- *      -ENOMEM: Memory allocation failure.
- *      -EACCES: Failure to read section containing library info.
- *      -EPERM: General failure.
- *  Requires:
- *      DCD initialized.
- *      Valid hdcd_mgr.
- *      uuid_obj != NULL
- *      dep_lib_uuids != NULL.
- *  Ensures:
- */
-extern int dcd_get_dep_libs(struct dcd_manager *hdcd_mgr,
-				   struct dsp_uuid *uuid_obj,
-				   u16 num_libs,
-				   struct dsp_uuid *dep_lib_uuids,
-				   bool *prstnt_dep_libs,
-				   enum nldr_phase phase);
-
-/*
- *  ======== dcd_get_num_dep_libs ========
- *  Purpose:
- *      Given the uuid of a library, determine its number of dependent
- *      libraries.
- *  Parameters:
- *      hdcd_mgr:        A DCD manager handle.
- *      uuid_obj:          Pointer to a dsp_uuid for a library.
- *      num_libs:       Size of uuid array (number of library uuids).
- *      num_pers_libs:  number of persistent dependent library.
- *      phase:          Phase to obtain correct input library
- *  Returns:
- *      0: Success.
- *      -ENOMEM: Memory allocation failure.
- *      -EACCES: Failure to read section containing library info.
- *      -EPERM: General failure.
- *  Requires:
- *      DCD initialized.
- *      Valid hdcd_mgr.
- *      uuid_obj != NULL
- *      num_libs != NULL.
- *  Ensures:
- */
-extern int dcd_get_num_dep_libs(struct dcd_manager *hdcd_mgr,
-				       struct dsp_uuid *uuid_obj,
-				       u16 *num_libs,
-				       u16 *num_pers_libs,
-				       enum nldr_phase phase);
-
-/*
- *  ======== dcd_get_library_name ========
- *  Purpose:
- *      This function returns the name of a (dynamic) library for a given
- *      UUID.
- *  Parameters:
- *      hdcd_mgr: A DCD manager handle.
- *      uuid_obj:	Pointer to a dsp_uuid that represents a unique DSP/BIOS
- *                      Bridge object.
- *      str_lib_name: Buffer to hold library name.
- *      buff_size: Contains buffer size. Set to string size on output.
- *      phase:          Which phase to load
- *      phase_split:    Are phases in multiple libraries
- *  Returns:
- *      0: Success.
- *      -EPERM: General failure.
- *  Requires:
- *      DCD initialized.
- *      Valid hdcd_mgr.
- *      str_lib_name != NULL.
- *      uuid_obj != NULL
- *      buff_size != NULL.
- *  Ensures:
- */
-extern int dcd_get_library_name(struct dcd_manager *hdcd_mgr,
-				       struct dsp_uuid *uuid_obj,
-				       char *str_lib_name,
-				       u32 *buff_size,
-				       enum nldr_phase phase,
-				       bool *phase_split);
-
-/*
- *  ======== dcd_get_object_def ========
- *  Purpose:
- *      This function returns the properties/attributes of a DSP/BIOS Bridge
- *      object.
- *  Parameters:
- *      hdcd_mgr:            A DCD manager handle.
- *      uuid_obj:              Pointer to a dsp_uuid that represents a unique
- *                          DSP/BIOS Bridge object.
- *      obj_type:            The type of DSP/BIOS Bridge object to be
- *                          referenced (node, processor, etc).
- *      obj_def:            Pointer to an object definition structure. A
- *                          union of various possible DCD object types.
- *  Returns:
- *      0: Success.
- *      -EACCES: Unable to access/read/parse/load content of object code
- *               section.
- *      -EPERM:          General failure.
- *      -EFAULT:        Invalid DCD_HMANAGER handle.
- *  Requires:
- *      DCD initialized.
- *      obj_uuid is non-NULL.
- *      obj_def is non-NULL.
- *  Ensures:
- */
-extern int dcd_get_object_def(struct dcd_manager *hdcd_mgr,
-				     struct dsp_uuid *obj_uuid,
-				     enum dsp_dcdobjtype obj_type,
-				     struct dcd_genericobj *obj_def);
-
-/*
- *  ======== dcd_get_objects ========
- *  Purpose:
- *      This function finds all DCD objects specified in a special
- *      COFF section called ".dcd_register", and for each object,
- *      call a "register" function.  The "register" function may perform
- *      various actions, such as 1) register nodes in the node database, 2)
- *      unregister nodes from the node database, and 3) add overlay nodes.
- *  Parameters:
- *      hdcd_mgr:                A DCD manager handle.
- *      sz_coff_path:           Pointer to name of COFF file containing DCD
- *                              objects.
- *      register_fxn:           Callback fxn to be applied on each located
- *                              DCD object.
- *      handle:                 Handle to pass to callback.
- *  Returns:
- *      0:                Success.
- *      -EACCES: Unable to access/read/parse/load content of object code
- *               section.
- *      -EFAULT:            Invalid DCD_HMANAGER handle..
- *  Requires:
- *      DCD initialized.
- *  Ensures:
- *  Note:
- *      Due to the DCD database construction, it is essential for a DCD-enabled
- *      COFF file to contain the right COFF sections, especially
- *      ".dcd_register", which is used for auto registration.
- */
-extern int dcd_get_objects(struct dcd_manager *hdcd_mgr,
-				  char *sz_coff_path,
-				  dcd_registerfxn register_fxn, void *handle);
-
-/*
- *  ======== dcd_init ========
- *  Purpose:
- *      This function initializes DCD.
- *  Parameters:
- *  Returns:
- *      FALSE:  Initialization failed.
- *      TRUE:   Initialization succeeded.
- *  Requires:
- *  Ensures:
- *      DCD initialized.
- */
-extern bool dcd_init(void);
-
-/*
- *  ======== dcd_register_object ========
- *  Purpose:
- *      This function registers a DSP/BIOS Bridge object in the DCD database.
- *  Parameters:
- *      uuid_obj:          Pointer to a dsp_uuid that identifies a DSP/BIOS
- *                      Bridge object.
- *      obj_type:        Type of object.
- *      psz_path_name:    Path to the object's COFF file.
- *  Returns:
- *      0:        Success.
- *      -EPERM:      Failed to register object.
- *  Requires:
- *      DCD initialized.
- *      uuid_obj and szPathName are non-NULL values.
- *      obj_type is a valid type value.
- *  Ensures:
- */
-extern int dcd_register_object(struct dsp_uuid *uuid_obj,
-				      enum dsp_dcdobjtype obj_type,
-				      char *psz_path_name);
-
-/*
- *  ======== dcd_unregister_object ========
- *  Purpose:
- *      This function de-registers a valid DSP/BIOS Bridge object from the DCD
- *      database.
- *  Parameters:
- *      uuid_obj:      Pointer to a dsp_uuid that identifies a DSP/BIOS Bridge
- *                  object.
- *      obj_type:    Type of object.
- *  Returns:
- *      0:    Success.
- *      -EPERM:  Unable to de-register the specified object.
- *  Requires:
- *      DCD initialized.
- *      uuid_obj is a non-NULL value.
- *      obj_type is a valid type value.
- *  Ensures:
- */
-extern int dcd_unregister_object(struct dsp_uuid *uuid_obj,
-					enum dsp_dcdobjtype obj_type);
-
-#endif /* _DBDCD_H */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dbdcddef.h b/drivers/staging/tidspbridge/include/dspbridge/dbdcddef.h
deleted file mode 100644
index bc201b3..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dbdcddef.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * dbdcddef.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DCD (DSP/BIOS Bridge Configuration Database) constants and types.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DBDCDDEF_
-#define DBDCDDEF_
-
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/mgrpriv.h>	/* for mgr_processorextinfo */
-
-/*
- *  The following defines are critical elements for the DCD module:
- *
- * - DCD_REGKEY enables DCD functions to locate registered DCD objects.
- * - DCD_REGISTER_SECTION identifies the COFF section where the UUID of
- *   registered DCD objects are stored.
- */
-#define DCD_REGKEY              "Software\\TexasInstruments\\DspBridge\\DCD"
-#define DCD_REGISTER_SECTION    ".dcd_register"
-
-#define DCD_MAXPATHLENGTH    255
-
-/* DCD Manager Object */
-struct dcd_manager;
-
-struct dcd_key_elem {
-	struct list_head link;	/* Make it linked to a list */
-	char name[DCD_MAXPATHLENGTH];	/*  Name of a given value entry */
-	char *path;		/*  Pointer to the actual data */
-};
-
-/* DCD Node Properties */
-struct dcd_nodeprops {
-	struct dsp_ndbprops ndb_props;
-	u32 msg_segid;
-	u32 msg_notify_type;
-	char *str_create_phase_fxn;
-	char *str_delete_phase_fxn;
-	char *str_execute_phase_fxn;
-	char *str_i_alg_name;
-
-	/* Dynamic load properties */
-	u16 load_type;	/* Static, dynamic, overlay */
-	u32 data_mem_seg_mask;		/* Data memory requirements */
-	u32 code_mem_seg_mask;		/* Code memory requirements */
-};
-
-/* DCD Generic Object Type */
-struct dcd_genericobj {
-	union dcd_obj {
-		struct dcd_nodeprops node_obj;	/* node object. */
-		/* processor object. */
-		struct dsp_processorinfo proc_info;
-		/* extended proc object (private) */
-		struct mgr_processorextinfo ext_proc_obj;
-	} obj_data;
-};
-
-/* DCD Internal Callback Type */
-typedef int(*dcd_registerfxn) (struct dsp_uuid *uuid_obj,
-				      enum dsp_dcdobjtype obj_type,
-				      void *handle);
-
-#endif /* DBDCDDEF_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dbdefs.h b/drivers/staging/tidspbridge/include/dspbridge/dbdefs.h
deleted file mode 100644
index c8f4645..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dbdefs.h
+++ /dev/null
@@ -1,488 +0,0 @@
-/*
- * dbdefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global definitions and constants for DSP/BIOS Bridge.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DBDEFS_
-#define DBDEFS_
-
-#include <linux/types.h>
-
-#include <dspbridge/rms_sh.h>	/* Types shared between GPP and DSP */
-
-#define PG_SIZE4K 4096
-#define PG_MASK(pg_size) (~((pg_size)-1))
-#define PG_ALIGN_LOW(addr, pg_size) ((addr) & PG_MASK(pg_size))
-#define PG_ALIGN_HIGH(addr, pg_size) (((addr)+(pg_size)-1) & PG_MASK(pg_size))
-
-/* API return value and calling convention */
-#define DBAPI                       int
-
-/* Maximum length of node name, used in dsp_ndbprops */
-#define DSP_MAXNAMELEN              32
-
-/* notify_type values for the RegisterNotify() functions. */
-#define DSP_SIGNALEVENT             0x00000001
-
-/* Types of events for processors */
-#define DSP_PROCESSORSTATECHANGE    0x00000001
-#define DSP_PROCESSORATTACH         0x00000002
-#define DSP_PROCESSORDETACH         0x00000004
-#define DSP_PROCESSORRESTART        0x00000008
-
-/* DSP exception events (DSP/BIOS and DSP MMU fault) */
-#define DSP_MMUFAULT                0x00000010
-#define DSP_SYSERROR                0x00000020
-#define DSP_EXCEPTIONABORT          0x00000300
-#define DSP_PWRERROR                0x00000080
-#define DSP_WDTOVERFLOW	0x00000040
-
-/* IVA exception events (IVA MMU fault) */
-#define IVA_MMUFAULT                0x00000040
-/* Types of events for nodes */
-#define DSP_NODESTATECHANGE         0x00000100
-#define DSP_NODEMESSAGEREADY        0x00000200
-
-/* Types of events for streams */
-#define DSP_STREAMDONE              0x00001000
-#define DSP_STREAMIOCOMPLETION      0x00002000
-
-/* Handle definition representing the GPP node in DSPNode_Connect() calls */
-#define DSP_HGPPNODE                0xFFFFFFFF
-
-/* Node directions used in DSPNode_Connect() */
-#define DSP_TONODE                  1
-#define DSP_FROMNODE                2
-
-/* Define Node Minimum and Maximum Priorities */
-#define DSP_NODE_MIN_PRIORITY       1
-#define DSP_NODE_MAX_PRIORITY       15
-
-/* msg_ctrl contains SM buffer description */
-#define DSP_RMSBUFDESC RMS_BUFDESC
-
-/* Processor ID numbers */
-#define DSP_UNIT    0
-#define IVA_UNIT    1
-
-#define DSPWORD       unsigned char
-#define DSPWORDSIZE     sizeof(DSPWORD)
-
-#define    MAX_PROFILES     16
-
-/* DSP chip type */
-#define DSPTYPE64	0x99
-
-/* Handy Macros */
-#define VALID_PROC_EVENT (DSP_PROCESSORSTATECHANGE | DSP_PROCESSORATTACH | \
-	DSP_PROCESSORDETACH | DSP_PROCESSORRESTART | DSP_NODESTATECHANGE | \
-	DSP_STREAMDONE | DSP_STREAMIOCOMPLETION | DSP_MMUFAULT | \
-	DSP_SYSERROR | DSP_WDTOVERFLOW | DSP_PWRERROR)
-
-static inline bool is_valid_proc_event(u32 x)
-{
-	return (x == 0 || (x & VALID_PROC_EVENT && !(x & ~VALID_PROC_EVENT)));
-}
-
-/* The Node UUID structure */
-struct dsp_uuid {
-	u32 data1;
-	u16 data2;
-	u16 data3;
-	u8 data4;
-	u8 data5;
-	u8 data6[6];
-};
-
-/* DCD types */
-enum dsp_dcdobjtype {
-	DSP_DCDNODETYPE,
-	DSP_DCDPROCESSORTYPE,
-	DSP_DCDLIBRARYTYPE,
-	DSP_DCDCREATELIBTYPE,
-	DSP_DCDEXECUTELIBTYPE,
-	DSP_DCDDELETELIBTYPE,
-	/* DSP_DCDMAXOBJTYPE is meant to be the last DCD object type */
-	DSP_DCDMAXOBJTYPE
-};
-
-/* Processor states */
-enum dsp_procstate {
-	PROC_STOPPED,
-	PROC_LOADED,
-	PROC_RUNNING,
-	PROC_ERROR
-};
-
-/*
- *  Node types: Message node, task node, xDAIS socket node, and
- *  device node. _NODE_GPP is used when defining a stream connection
- *  between a task or socket node and the GPP.
- *
- */
-enum node_type {
-	NODE_DEVICE,
-	NODE_TASK,
-	NODE_DAISSOCKET,
-	NODE_MESSAGE,
-	NODE_GPP
-};
-
-/*
- *  ======== node_state ========
- *  Internal node states.
- */
-enum node_state {
-	NODE_ALLOCATED,
-	NODE_CREATED,
-	NODE_RUNNING,
-	NODE_PAUSED,
-	NODE_DONE,
-	NODE_CREATING,
-	NODE_STARTING,
-	NODE_PAUSING,
-	NODE_TERMINATING,
-	NODE_DELETING,
-};
-
-/* Stream states */
-enum dsp_streamstate {
-	STREAM_IDLE,
-	STREAM_READY,
-	STREAM_PENDING,
-	STREAM_DONE
-};
-
-/* Stream connect types */
-enum dsp_connecttype {
-	CONNECTTYPE_NODEOUTPUT,
-	CONNECTTYPE_GPPOUTPUT,
-	CONNECTTYPE_NODEINPUT,
-	CONNECTTYPE_GPPINPUT
-};
-
-/* Stream mode types */
-enum dsp_strmmode {
-	STRMMODE_PROCCOPY,	/* Processor(s) copy stream data payloads */
-	STRMMODE_ZEROCOPY,	/* Strm buffer ptrs swapped no data copied */
-	STRMMODE_LDMA,		/* Local DMA : OMAP's System-DMA device */
-	STRMMODE_RDMA		/* Remote DMA: OMAP's DSP-DMA device */
-};
-
-/* Resource Types */
-enum dsp_resourceinfotype {
-	DSP_RESOURCE_DYNDARAM = 0,
-	DSP_RESOURCE_DYNSARAM,
-	DSP_RESOURCE_DYNEXTERNAL,
-	DSP_RESOURCE_DYNSRAM,
-	DSP_RESOURCE_PROCLOAD
-};
-
-/* Memory Segment Types */
-enum dsp_memtype {
-	DSP_DYNDARAM = 0,
-	DSP_DYNSARAM,
-	DSP_DYNEXTERNAL,
-	DSP_DYNSRAM
-};
-
-/* Memory Flush Types */
-enum dsp_flushtype {
-	PROC_INVALIDATE_MEM = 0,
-	PROC_WRITEBACK_MEM,
-	PROC_WRITEBACK_INVALIDATE_MEM,
-};
-
-/* Memory Segment Status Values */
-struct dsp_memstat {
-	u32 size;
-	u32 total_free_size;
-	u32 len_max_free_block;
-	u32 num_free_blocks;
-	u32 num_alloc_blocks;
-};
-
-/* Processor Load information Values */
-struct dsp_procloadstat {
-	u32 curr_load;
-	u32 predicted_load;
-	u32 curr_dsp_freq;
-	u32 predicted_freq;
-};
-
-/* Attributes for STRM connections between nodes */
-struct dsp_strmattr {
-	u32 seg_id;		/* Memory segment on DSP to allocate buffers */
-	u32 buf_size;		/* Buffer size (DSP words) */
-	u32 num_bufs;		/* Number of buffers */
-	u32 buf_alignment;	/* Buffer alignment */
-	u32 timeout;		/* Timeout for blocking STRM calls */
-	enum dsp_strmmode strm_mode;	/* mode of stream when opened */
-	/* DMA chnl id if dsp_strmmode is LDMA or RDMA */
-	u32 dma_chnl_id;
-	u32 dma_priority;	/* DMA channel priority 0=lowest, >0=high */
-};
-
-/* The dsp_cbdata structure */
-struct dsp_cbdata {
-	u32 cb_data;
-	u8 node_data[1];
-};
-
-/* The dsp_msg structure */
-struct dsp_msg {
-	u32 cmd;
-	u32 arg1;
-	u32 arg2;
-};
-
-/* The dsp_resourcereqmts structure for node's resource requirements */
-struct dsp_resourcereqmts {
-	u32 cb_struct;
-	u32 static_data_size;
-	u32 global_data_size;
-	u32 program_mem_size;
-	u32 wc_execution_time;
-	u32 wc_period;
-	u32 wc_deadline;
-	u32 avg_exection_time;
-	u32 minimum_period;
-};
-
-/*
- * The dsp_streamconnect structure describes a stream connection
- * between two nodes, or between a node and the GPP
- */
-struct dsp_streamconnect {
-	u32 cb_struct;
-	enum dsp_connecttype connect_type;
-	u32 this_node_stream_index;
-	void *connected_node;
-	struct dsp_uuid ui_connected_node_id;
-	u32 connected_node_stream_index;
-};
-
-struct dsp_nodeprofs {
-	u32 heap_size;
-};
-
-/* The dsp_ndbprops structure reports the attributes of a node */
-struct dsp_ndbprops {
-	u32 cb_struct;
-	struct dsp_uuid ui_node_id;
-	char ac_name[DSP_MAXNAMELEN];
-	enum node_type ntype;
-	u32 cache_on_gpp;
-	struct dsp_resourcereqmts dsp_resource_reqmts;
-	s32 prio;
-	u32 stack_size;
-	u32 sys_stack_size;
-	u32 stack_seg;
-	u32 message_depth;
-	u32 num_input_streams;
-	u32 num_output_streams;
-	u32 timeout;
-	u32 count_profiles;	/* Number of supported profiles */
-	/* Array of profiles */
-	struct dsp_nodeprofs node_profiles[MAX_PROFILES];
-	u32 stack_seg_name;	/* Stack Segment Name */
-};
-
-	/* The dsp_nodeattrin structure describes the attributes of a
-	 * node client */
-struct dsp_nodeattrin {
-	u32 cb_struct;
-	s32 prio;
-	u32 timeout;
-	u32 profile_id;
-	/* Reserved, for Bridge Internal use only */
-	u32 heap_size;
-	void *pgpp_virt_addr;	/* Reserved, for Bridge Internal use only */
-};
-
-	/* The dsp_nodeinfo structure is used to retrieve information
-	 * about a node */
-struct dsp_nodeinfo {
-	u32 cb_struct;
-	struct dsp_ndbprops nb_node_database_props;
-	u32 execution_priority;
-	enum node_state ns_execution_state;
-	void *device_owner;
-	u32 number_streams;
-	struct dsp_streamconnect sc_stream_connection[16];
-	u32 node_env;
-};
-
-	/* The dsp_nodeattr structure describes the attributes of a node */
-struct dsp_nodeattr {
-	u32 cb_struct;
-	struct dsp_nodeattrin in_node_attr_in;
-	u32 node_attr_inputs;
-	u32 node_attr_outputs;
-	struct dsp_nodeinfo node_info;
-};
-
-/*
- *  Notification type: either the name of an opened event, or an event or
- *  window handle.
- */
-struct dsp_notification {
-	char *name;
-	void *handle;
-};
-
-/* The dsp_processorattrin structure describes the attributes of a processor */
-struct dsp_processorattrin {
-	u32 cb_struct;
-	u32 timeout;
-};
-/*
- * The dsp_processorinfo structure describes basic capabilities of a
- * DSP processor
- */
-struct dsp_processorinfo {
-	u32 cb_struct;
-	int processor_family;
-	int processor_type;
-	u32 clock_rate;
-	u32 internal_mem_size;
-	u32 external_mem_size;
-	u32 processor_id;
-	int ty_running_rtos;
-	s32 node_min_priority;
-	s32 node_max_priority;
-};
-
-/* Error information of last DSP exception signalled to the GPP */
-struct dsp_errorinfo {
-	u32 err_mask;
-	u32 val1;
-	u32 val2;
-	u32 val3;
-};
-
-/* The dsp_processorstate structure describes the state of a DSP processor */
-struct dsp_processorstate {
-	u32 cb_struct;
-	enum dsp_procstate proc_state;
-};
-
-/*
- * The dsp_resourceinfo structure is used to retrieve information about a
- * processor's resources
- */
-struct dsp_resourceinfo {
-	u32 cb_struct;
-	enum dsp_resourceinfotype resource_type;
-	union {
-		u32 resource;
-		struct dsp_memstat mem_stat;
-		struct dsp_procloadstat proc_load_stat;
-	} result;
-};
-
-/*
- * The dsp_streamattrin structure describes the attributes of a stream,
- * including segment and alignment of data buffers allocated with
- * DSPStream_AllocateBuffers(), if applicable
- */
-struct dsp_streamattrin {
-	u32 cb_struct;
-	u32 timeout;
-	u32 segment_id;
-	u32 buf_alignment;
-	u32 num_bufs;
-	enum dsp_strmmode strm_mode;
-	u32 dma_chnl_id;
-	u32 dma_priority;
-};
-
-/* The dsp_bufferattr structure describes the attributes of a data buffer */
-struct dsp_bufferattr {
-	u32 cb_struct;
-	u32 segment_id;
-	u32 buf_alignment;
-};
-
-/*
- *  The dsp_streaminfo structure is used to retrieve information
- *  about a stream.
- */
-struct dsp_streaminfo {
-	u32 cb_struct;
-	u32 number_bufs_allowed;
-	u32 number_bufs_in_stream;
-	u32 number_bytes;
-	void *sync_object_handle;
-	enum dsp_streamstate ss_stream_state;
-};
-
-/* DMM MAP attributes
-It is a bit mask with each bit value indicating a specific attribute
-bit 0 - GPP address type (user virtual=0, physical=1)
-bit 1 - MMU Endianism (Big Endian=1, Little Endian=0)
-bit 2 - MMU mixed page attribute (Mixed/ CPUES=1, TLBES =0)
-bit 3 - MMU element size = 8bit (valid only for non mixed page entries)
-bit 4 - MMU element size = 16bit (valid only for non mixed page entries)
-bit 5 - MMU element size = 32bit (valid only for non mixed page entries)
-bit 6 - MMU element size = 64bit (valid only for non mixed page entries)
-
-bit 14 - Input (read only) buffer
-bit 15 - Output (writeable) buffer
-*/
-
-/* Types of mapping attributes */
-
-/* MPU address is virtual and needs to be translated to physical addr */
-#define DSP_MAPVIRTUALADDR          0x00000000
-#define DSP_MAPPHYSICALADDR         0x00000001
-
-/* Mapped data is big endian */
-#define DSP_MAPBIGENDIAN            0x00000002
-#define DSP_MAPLITTLEENDIAN         0x00000000
-
-/* Element size is based on DSP r/w access size */
-#define DSP_MAPMIXEDELEMSIZE        0x00000004
-
-/*
- * Element size for MMU mapping (8, 16, 32, or 64 bit)
- * Ignored if DSP_MAPMIXEDELEMSIZE enabled
- */
-#define DSP_MAPELEMSIZE8            0x00000008
-#define DSP_MAPELEMSIZE16           0x00000010
-#define DSP_MAPELEMSIZE32           0x00000020
-#define DSP_MAPELEMSIZE64           0x00000040
-
-#define DSP_MAPVMALLOCADDR         0x00000080
-
-#define DSP_MAPDONOTLOCK	   0x00000100
-
-#define DSP_MAP_DIR_MASK		0x3FFF
-
-#define GEM_CACHE_LINE_SIZE     128
-#define GEM_L1P_PREFETCH_SIZE   128
-
-/*
- * Definitions from dbreg.h
- */
-
-#define DSPPROCTYPE_C64		6410
-#define IVAPROCTYPE_ARM7	470
-
-/* Max registry path length. Also the max registry value length. */
-#define MAXREGPATHLENGTH	255
-
-#endif /* DBDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dbll.h b/drivers/staging/tidspbridge/include/dspbridge/dbll.h
deleted file mode 100644
index 46a9e00..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dbll.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * dbll.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- *  DSP/BIOS Bridge Dynamic load library module interface. Function header
- *  comments are in the file dblldefs.h.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DBLL_
-#define DBLL_
-
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/dblldefs.h>
-
-extern bool symbols_reloaded;
-
-extern void dbll_close(struct dbll_library_obj *zl_lib);
-extern int dbll_create(struct dbll_tar_obj **target_obj,
-			      struct dbll_attrs *pattrs);
-extern void dbll_delete(struct dbll_tar_obj *target);
-extern void dbll_exit(void);
-extern bool dbll_get_addr(struct dbll_library_obj *zl_lib, char *name,
-			  struct dbll_sym_val **sym_val);
-extern void dbll_get_attrs(struct dbll_tar_obj *target,
-			   struct dbll_attrs *pattrs);
-extern bool dbll_get_c_addr(struct dbll_library_obj *zl_lib, char *name,
-			    struct dbll_sym_val **sym_val);
-extern int dbll_get_sect(struct dbll_library_obj *lib, char *name,
-				u32 *paddr, u32 *psize);
-extern bool dbll_init(void);
-extern int dbll_load(struct dbll_library_obj *lib,
-			    dbll_flags flags,
-			    struct dbll_attrs *attrs, u32 * entry);
-extern int dbll_open(struct dbll_tar_obj *target, char *file,
-			    dbll_flags flags,
-		       struct dbll_library_obj **lib_obj);
-extern int dbll_read_sect(struct dbll_library_obj *lib,
-				 char *name, char *buf, u32 size);
-extern void dbll_unload(struct dbll_library_obj *lib, struct dbll_attrs *attrs);
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-bool dbll_find_dsp_symbol(struct dbll_library_obj *zl_lib, u32 address,
-		u32 offset_range, u32 *sym_addr_output, char *name_output);
-#endif
-
-#endif /* DBLL_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h b/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h
deleted file mode 100644
index a19e078..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h
+++ /dev/null
@@ -1,431 +0,0 @@
-/*
- * dblldefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DBLLDEFS_
-#define DBLLDEFS_
-
-/*
- *  Bit masks for dbl_flags.
- */
-#define DBLL_NOLOAD   0x0	/* Don't load symbols, code, or data */
-#define DBLL_SYMB     0x1	/* load symbols */
-#define DBLL_CODE     0x2	/* load code */
-#define DBLL_DATA     0x4	/* load data */
-#define DBLL_DYNAMIC  0x8	/* dynamic load */
-#define DBLL_BSS      0x20	/* Unitialized section */
-
-#define DBLL_MAXPATHLENGTH       255
-
-/*
- *  ======== DBLL_Target ========
- *
- */
-struct dbll_tar_obj;
-
-/*
- *  ======== dbll_flags ========
- *  Specifies whether to load code, data, or symbols
- */
-typedef s32 dbll_flags;
-
-/*
- *  ======== DBLL_Library ========
- *
- */
-struct dbll_library_obj;
-
-/*
- *  ======== dbll_sect_info ========
- *  For collecting info on overlay sections
- */
-struct dbll_sect_info {
-	const char *name;	/* name of section */
-	u32 sect_run_addr;	/* run address of section */
-	u32 sect_load_addr;	/* load address of section */
-	u32 size;		/* size of section (target MAUs) */
-	dbll_flags type;	/* Code, data, or BSS */
-};
-
-/*
- *  ======== dbll_sym_val ========
- *  (Needed for dynamic load library)
- */
-struct dbll_sym_val {
-	u32 value;
-};
-
-/*
- *  ======== dbll_alloc_fxn ========
- *  Allocate memory function.  Allocate or reserve (if reserved == TRUE)
- *  "size" bytes of memory from segment "space" and return the address in
- *  *dsp_address (or starting at *dsp_address if reserve == TRUE). Returns 0 on
- *  success, or an error code on failure.
- */
-typedef s32(*dbll_alloc_fxn) (void *hdl, s32 space, u32 size, u32 align,
-			      u32 *dsp_address, s32 seg_id, s32 req,
-			      bool reserved);
-
-/*
- *  ======== dbll_close_fxn ========
- */
-typedef s32(*dbll_f_close_fxn) (void *);
-
-/*
- *  ======== dbll_free_fxn ========
- *  Free memory function.  Free, or unreserve (if reserved == TRUE) "size"
- *  bytes of memory from segment "space"
- */
-typedef bool(*dbll_free_fxn) (void *hdl, u32 addr, s32 space, u32 size,
-			      bool reserved);
-
-/*
- *  ======== dbll_f_open_fxn ========
- */
-typedef void *(*dbll_f_open_fxn) (const char *, const char *);
-
-/*
- *  ======== dbll_log_write_fxn ========
- *  Function to call when writing data from a section, to log the info.
- *  Can be NULL if no logging is required.
- */
-typedef int(*dbll_log_write_fxn) (void *handle,
-					 struct dbll_sect_info *sect, u32 addr,
-					 u32 bytes);
-
-/*
- *  ======== dbll_read_fxn ========
- */
-typedef s32(*dbll_read_fxn) (void *, size_t, size_t, void *);
-
-/*
- *  ======== dbll_seek_fxn ========
- */
-typedef s32(*dbll_seek_fxn) (void *, long, int);
-
-/*
- *  ======== dbll_sym_lookup ========
- *  Symbol lookup function - Find the symbol name and return its value.
- *
- *  Parameters:
- *      handle          - Opaque handle
- *      parg            - Opaque argument.
- *      name            - Name of symbol to lookup.
- *      sym             - Location to store address of symbol structure.
- *
- *  Returns:
- *      TRUE:           Success (symbol was found).
- *      FALSE:          Failed to find symbol.
- */
-typedef bool(*dbll_sym_lookup) (void *handle, void *parg, void *rmm_handle,
-				const char *name, struct dbll_sym_val **sym);
-
-/*
- *  ======== dbll_tell_fxn ========
- */
-typedef s32(*dbll_tell_fxn) (void *);
-
-/*
- *  ======== dbll_write_fxn ========
- *  Write memory function.  Write "n" HOST bytes of memory to segment "mtype"
- *  starting at address "dsp_address" from the buffer "buf".  The buffer is
- *  formatted as an array of words appropriate for the DSP.
- */
-typedef s32(*dbll_write_fxn) (void *hdl, u32 dsp_address, void *buf,
-			      u32 n, s32 mtype);
-
-/*
- *  ======== dbll_attrs ========
- */
-struct dbll_attrs {
-	dbll_alloc_fxn alloc;
-	dbll_free_fxn free;
-	void *rmm_handle;	/* Handle to pass to alloc, free functions */
-	dbll_write_fxn write;
-	void *input_params;	/* Handle to pass to write, cinit function */
-	bool base_image;
-	dbll_log_write_fxn log_write;
-	void *log_write_handle;
-
-	/* Symbol matching function and handle to pass to it */
-	dbll_sym_lookup sym_lookup;
-	void *sym_handle;
-	void *sym_arg;
-
-	/*
-	 *  These file manipulation functions should be compatible with the
-	 *  "C" run time library functions of the same name.
-	 */
-	 s32 (*fread)(void *ptr, size_t size, size_t count, void *filp);
-	 s32 (*fseek)(void *filp, long offset, int origin);
-	 s32 (*ftell)(void *filp);
-	 s32 (*fclose)(void *filp);
-	 void *(*fopen)(const char *path, const char *mode);
-};
-
-/*
- *  ======== dbll_close ========
- *  Close library opened with dbll_open.
- *  Parameters:
- *      lib             - Handle returned from dbll_open().
- *  Returns:
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *  Ensures:
- */
-typedef void (*dbll_close_fxn) (struct dbll_library_obj *library);
-
-/*
- *  ======== dbll_create ========
- *  Create a target object, specifying the alloc, free, and write functions.
- *  Parameters:
- *      target_obj         - Location to store target handle on output.
- *      pattrs          - Attributes.
- *  Returns:
- *      0:        Success.
- *      -ENOMEM:    Memory allocation failed.
- *  Requires:
- *      DBL initialized.
- *      pattrs != NULL.
- *      target_obj != NULL;
- *  Ensures:
- *      Success:        *target_obj != NULL.
- *      Failure:        *target_obj == NULL.
- */
-typedef int(*dbll_create_fxn) (struct dbll_tar_obj **target_obj,
-				      struct dbll_attrs *attrs);
-
-/*
- *  ======== dbll_delete ========
- *  Delete target object and free resources for any loaded libraries.
- *  Parameters:
- *      target          - Handle returned from DBLL_Create().
- *  Returns:
- *  Requires:
- *      DBL initialized.
- *      Valid target.
- *  Ensures:
- */
-typedef void (*dbll_delete_fxn) (struct dbll_tar_obj *target);
-
-/*
- *  ======== dbll_exit ========
- *  Discontinue use of DBL module.
- *  Parameters:
- *  Returns:
- *  Requires:
- *      refs > 0.
- *  Ensures:
- *      refs >= 0.
- */
-typedef void (*dbll_exit_fxn) (void);
-
-/*
- *  ======== dbll_get_addr ========
- *  Get address of name in the specified library.
- *  Parameters:
- *      lib             - Handle returned from dbll_open().
- *      name            - Name of symbol
- *      sym_val         - Location to store symbol address on output.
- *  Returns:
- *      TRUE:           Success.
- *      FALSE:          Symbol not found.
- *  Requires:
- *      DBL initialized.
- *      Valid library.
- *      name != NULL.
- *      sym_val != NULL.
- *  Ensures:
- */
-typedef bool(*dbll_get_addr_fxn) (struct dbll_library_obj *lib, char *name,
-				  struct dbll_sym_val **sym_val);
-
-/*
- *  ======== dbll_get_attrs ========
- *  Retrieve the attributes of the target.
- *  Parameters:
- *      target          - Handle returned from DBLL_Create().
- *      pattrs          - Location to store attributes on output.
- *  Returns:
- *  Requires:
- *      DBL initialized.
- *      Valid target.
- *      pattrs != NULL.
- *  Ensures:
- */
-typedef void (*dbll_get_attrs_fxn) (struct dbll_tar_obj *target,
-				    struct dbll_attrs *attrs);
-
-/*
- *  ======== dbll_get_c_addr ========
- *  Get address of "C" name on the specified library.
- *  Parameters:
- *      lib             - Handle returned from dbll_open().
- *      name            - Name of symbol
- *      sym_val         - Location to store symbol address on output.
- *  Returns:
- *      TRUE:           Success.
- *      FALSE:          Symbol not found.
- *  Requires:
- *      DBL initialized.
- *      Valid target.
- *      name != NULL.
- *      sym_val != NULL.
- *  Ensures:
- */
-typedef bool(*dbll_get_c_addr_fxn) (struct dbll_library_obj *lib, char *name,
-				    struct dbll_sym_val **sym_val);
-
-/*
- *  ======== dbll_get_sect ========
- *  Get address and size of a named section.
- *  Parameters:
- *      lib             - Library handle returned from dbll_open().
- *      name            - Name of section.
- *      paddr           - Location to store section address on output.
- *      psize           - Location to store section size on output.
- *  Returns:
- *      0:        Success.
- *      -ENXIO:    Section not found.
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *      name != NULL.
- *      paddr != NULL;
- *      psize != NULL.
- *  Ensures:
- */
-typedef int(*dbll_get_sect_fxn) (struct dbll_library_obj *lib,
-					char *name, u32 *addr, u32 *size);
-
-/*
- *  ======== dbll_init ========
- *  Initialize DBL module.
- *  Parameters:
- *  Returns:
- *      TRUE:           Success.
- *      FALSE:          Failure.
- *  Requires:
- *      refs >= 0.
- *  Ensures:
- *      Success:        refs > 0.
- *      Failure:        refs >= 0.
- */
-typedef bool(*dbll_init_fxn) (void);
-
-/*
- *  ======== dbll_load ========
- *  Load library onto the target.
- *
- *  Parameters:
- *      lib             - Library handle returned from dbll_open().
- *      flags           - Load code, data and/or symbols.
- *      attrs           - May contain alloc, free, and write function.
- *      entry_pt        - Location to store program entry on output.
- *  Returns:
- *      0:        Success.
- *      -EBADF:     File read failed.
- *      -EILSEQ:   Failure in dynamic loader library.
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *      entry != NULL.
- *  Ensures:
- */
-typedef int(*dbll_load_fxn) (struct dbll_library_obj *lib,
-				    dbll_flags flags,
-				    struct dbll_attrs *attrs, u32 *entry);
-/*
- *  ======== dbll_open ========
- *  dbll_open() returns a library handle that can be used to load/unload
- *  the symbols/code/data via dbll_load()/dbll_unload().
- *  Parameters:
- *      target          - Handle returned from dbll_create().
- *      file            - Name of file to open.
- *      flags           - If flags & DBLL_SYMB, load symbols.
- *      lib_obj         - Location to store library handle on output.
- *  Returns:
- *      0:            Success.
- *      -ENOMEM:        Memory allocation failure.
- *      -EBADF:         File open/read failure.
- *                      Unable to determine target type.
- *  Requires:
- *      DBL initialized.
- *      Valid target.
- *      file != NULL.
- *      lib_obj != NULL.
- *      dbll_attrs fopen function non-NULL.
- *  Ensures:
- *      Success:        Valid *lib_obj.
- *      Failure:        *lib_obj == NULL.
- */
-typedef int(*dbll_open_fxn) (struct dbll_tar_obj *target, char *file,
-				    dbll_flags flags,
-				    struct dbll_library_obj **lib_obj);
-
-/*
- *  ======== dbll_read_sect ========
- *  Read COFF section into a character buffer.
- *  Parameters:
- *      lib             - Library handle returned from dbll_open().
- *      name            - Name of section.
- *      pbuf            - Buffer to write section contents into.
- *      size            - Buffer size
- *  Returns:
- *      0:        Success.
- *      -ENXIO:    Named section does not exists.
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *      name != NULL.
- *      pbuf != NULL.
- *      size != 0.
- *  Ensures:
- */
-typedef int(*dbll_read_sect_fxn) (struct dbll_library_obj *lib,
-					 char *name, char *content,
-					 u32 cont_size);
-/*
- *  ======== dbll_unload ========
- *  Unload library loaded with dbll_load().
- *  Parameters:
- *      lib             - Handle returned from dbll_open().
- *      attrs           - Contains free() function and handle to pass to it.
- *  Returns:
- *  Requires:
- *      DBL initialized.
- *      Valid lib.
- *  Ensures:
- */
-typedef void (*dbll_unload_fxn) (struct dbll_library_obj *library,
-				 struct dbll_attrs *attrs);
-struct dbll_fxns {
-	dbll_close_fxn close_fxn;
-	dbll_create_fxn create_fxn;
-	dbll_delete_fxn delete_fxn;
-	dbll_exit_fxn exit_fxn;
-	dbll_get_attrs_fxn get_attrs_fxn;
-	dbll_get_addr_fxn get_addr_fxn;
-	dbll_get_c_addr_fxn get_c_addr_fxn;
-	dbll_get_sect_fxn get_sect_fxn;
-	dbll_init_fxn init_fxn;
-	dbll_load_fxn load_fxn;
-	dbll_open_fxn open_fxn;
-	dbll_read_sect_fxn read_sect_fxn;
-	dbll_unload_fxn unload_fxn;
-};
-
-#endif /* DBLDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dev.h b/drivers/staging/tidspbridge/include/dspbridge/dev.h
deleted file mode 100644
index fa2d79e..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dev.h
+++ /dev/null
@@ -1,620 +0,0 @@
-/*
- * dev.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Bridge Bridge driver device operations.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DEV_
-#define DEV_
-
-/*  ----------------------------------- Module Dependent Headers */
-#include <dspbridge/chnldefs.h>
-#include <dspbridge/cmm.h>
-#include <dspbridge/cod.h>
-#include <dspbridge/dspdeh.h>
-#include <dspbridge/nodedefs.h>
-#include <dspbridge/disp.h>
-#include <dspbridge/dspdefs.h>
-#include <dspbridge/dmm.h>
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/devdefs.h>
-
-/*
- *  ======== dev_brd_write_fxn ========
- *  Purpose:
- *      Exported function to be used as the COD write function.  This function
- *      is passed a handle to a DEV_hObject by ZL in arb, then calls the
- *      device's bridge_brd_write() function.
- *  Parameters:
- *      arb:           Handle to a Device Object.
- *      dev_ctxt:    Handle to Bridge driver defined device info.
- *      dsp_addr:       Address on DSP board (Destination).
- *      host_buf:       Pointer to host buffer (Source).
- *      ul_num_bytes:     Number of bytes to transfer.
- *      mem_type:       Memory space on DSP to which to transfer.
- *  Returns:
- *      Number of bytes written.  Returns 0 if the DEV_hObject passed in via
- *      arb is invalid.
- *  Requires:
- *      DEV Initialized.
- *      host_buf != NULL
- *  Ensures:
- */
-extern u32 dev_brd_write_fxn(void *arb,
-			     u32 dsp_add,
-			     void *host_buf, u32 ul_num_bytes, u32 mem_space);
-
-/*
- *  ======== dev_create_device ========
- *  Purpose:
- *      Called by the operating system to load the Bridge Driver for a
- *      'Bridge device.
- *  Parameters:
- *      device_obj:     Ptr to location to receive the device object handle.
- *      driver_file_name: Name of Bridge driver PE DLL file to load.  If the
- *                      absolute path is not provided, the file is loaded
- *                      through 'Bridge's module search path.
- *      host_config:    Host configuration information, to be passed down
- *                      to the Bridge driver when bridge_dev_create() is called.
- *      pDspConfig:     DSP resources, to be passed down to the Bridge driver
- *                      when bridge_dev_create() is called.
- *      dev_node_obj:       Platform specific device node.
- *  Returns:
- *      0:            Module is loaded, device object has been created
- *      -ENOMEM:        Insufficient memory to create needed resources.
- *      -EPERM:              Unable to find Bridge driver entry point function.
- *      -ESPIPE:   Unable to load ZL DLL.
- *  Requires:
- *      DEV Initialized.
- *      device_obj != NULL.
- *      driver_file_name != NULL.
- *      host_config != NULL.
- *      pDspConfig != NULL.
- *  Ensures:
- *      0:  *device_obj will contain handle to the new device object.
- *      Otherwise, does not create the device object, ensures the Bridge driver
- *      module is unloaded, and sets *device_obj to NULL.
- */
-extern int dev_create_device(struct dev_object
-				    **device_obj,
-				    const char *driver_file_name,
-				    struct cfg_devnode *dev_node_obj);
-
-/*
- *  ======== dev_create2 ========
- *  Purpose:
- *      After successful loading of the image from api_init_complete2
- *      (PROC Auto_Start) or proc_load this fxn is called. This creates
- *      the Node Manager and updates the DEV Object.
- *  Parameters:
- *      hdev_obj: Handle to device object created with dev_create_device().
- *  Returns:
- *      0:    Successful Creation of Node Manager
- *      -EPERM:  Some Error Occurred.
- *  Requires:
- *      DEV Initialized
- *      Valid hdev_obj
- *  Ensures:
- *      0 and hdev_obj->node_mgr != NULL
- *      else    hdev_obj->node_mgr == NULL
- */
-extern int dev_create2(struct dev_object *hdev_obj);
-
-/*
- *  ======== dev_destroy2 ========
- *  Purpose:
- *      Destroys the Node manager for this device.
- *  Parameters:
- *      hdev_obj: Handle to device object created with dev_create_device().
- *  Returns:
- *      0:    Successful Creation of Node Manager
- *      -EPERM:  Some Error Occurred.
- *  Requires:
- *      DEV Initialized
- *      Valid hdev_obj
- *  Ensures:
- *      0 and hdev_obj->node_mgr == NULL
- *      else    -EPERM.
- */
-extern int dev_destroy2(struct dev_object *hdev_obj);
-
-/*
- *  ======== dev_destroy_device ========
- *  Purpose:
- *      Destroys the channel manager for this device, if any, calls
- *      bridge_dev_destroy(), and then attempts to unload the Bridge module.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with
- *                      dev_create_device().
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hdev_obj.
- *      -EPERM:     The Bridge driver failed it's bridge_dev_destroy() function.
- *  Requires:
- *      DEV Initialized.
- *  Ensures:
- */
-extern int dev_destroy_device(struct dev_object
-				     *hdev_obj);
-
-/*
- *  ======== dev_get_chnl_mgr ========
- *  Purpose:
- *      Retrieve the handle to the channel manager created for this device.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with
- *                      dev_create_device().
- *      *mgr:           Ptr to location to store handle.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hdev_obj.
- *  Requires:
- *      mgr != NULL.
- *      DEV Initialized.
- *  Ensures:
- *      0:        *mgr contains a handle to a channel manager object,
- *                      or NULL.
- *      else:           *mgr is NULL.
- */
-extern int dev_get_chnl_mgr(struct dev_object *hdev_obj,
-				   struct chnl_mgr **mgr);
-
-/*
- *  ======== dev_get_cmm_mgr ========
- *  Purpose:
- *      Retrieve the handle to the shared memory manager created for this
- *      device.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with
- *                      dev_create_device().
- *      *mgr:           Ptr to location to store handle.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hdev_obj.
- *  Requires:
- *      mgr != NULL.
- *      DEV Initialized.
- *  Ensures:
- *      0:        *mgr contains a handle to a channel manager object,
- *                      or NULL.
- *      else:           *mgr is NULL.
- */
-extern int dev_get_cmm_mgr(struct dev_object *hdev_obj,
-				  struct cmm_object **mgr);
-
-/*
- *  ======== dev_get_dmm_mgr ========
- *  Purpose:
- *      Retrieve the handle to the dynamic memory manager created for this
- *      device.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with
- *                      dev_create_device().
- *      *mgr:           Ptr to location to store handle.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hdev_obj.
- *  Requires:
- *      mgr != NULL.
- *      DEV Initialized.
- *  Ensures:
- *      0:        *mgr contains a handle to a channel manager object,
- *                      or NULL.
- *      else:           *mgr is NULL.
- */
-extern int dev_get_dmm_mgr(struct dev_object *hdev_obj,
-				  struct dmm_object **mgr);
-
-/*
- *  ======== dev_get_cod_mgr ========
- *  Purpose:
- *      Retrieve the COD manager create for this device.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with
- *                      dev_create_device().
- *      *cod_mgr:       Ptr to location to store handle.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hdev_obj.
- *  Requires:
- *      cod_mgr != NULL.
- *      DEV Initialized.
- *  Ensures:
- *      0:        *cod_mgr contains a handle to a COD manager object.
- *      else:           *cod_mgr is NULL.
- */
-extern int dev_get_cod_mgr(struct dev_object *hdev_obj,
-				  struct cod_manager **cod_mgr);
-
-/*
- *  ======== dev_get_deh_mgr ========
- *  Purpose:
- *      Retrieve the DEH manager created for this device.
- *  Parameters:
- *      hdev_obj: Handle to device object created with dev_create_device().
- *      *deh_manager:  Ptr to location to store handle.
- *  Returns:
- *      0:    Success.
- *      -EFAULT:   Invalid hdev_obj.
- *  Requires:
- *      deh_manager != NULL.
- *      DEH Initialized.
- *  Ensures:
- *      0:    *deh_manager contains a handle to a DEH manager object.
- *      else:       *deh_manager is NULL.
- */
-extern int dev_get_deh_mgr(struct dev_object *hdev_obj,
-				  struct deh_mgr **deh_manager);
-
-/*
- *  ======== dev_get_dev_node ========
- *  Purpose:
- *      Retrieve the platform specific device ID for this device.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with
- *                      dev_create_device().
- *      dev_nde:        Ptr to location to get the device node handle.
- *  Returns:
- *      0:        Returns a DEVNODE in *dev_node_obj.
- *      -EFAULT:    Invalid hdev_obj.
- *  Requires:
- *      dev_nde != NULL.
- *      DEV Initialized.
- *  Ensures:
- *      0:        *dev_nde contains a platform specific device ID;
- *      else:           *dev_nde is NULL.
- */
-extern int dev_get_dev_node(struct dev_object *hdev_obj,
-				   struct cfg_devnode **dev_nde);
-
-/*
- *  ======== dev_get_dev_type ========
- *  Purpose:
- *      Retrieve the platform specific device ID for this device.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with
- *                      dev_create_device().
- *      dev_nde:        Ptr to location to get the device node handle.
- *  Returns:
- *      0:        Success
- *      -EFAULT:    Invalid hdev_obj.
- *  Requires:
- *      dev_nde != NULL.
- *      DEV Initialized.
- *  Ensures:
- *      0:        *dev_nde contains a platform specific device ID;
- *      else:           *dev_nde is NULL.
- */
-extern int dev_get_dev_type(struct dev_object *device_obj,
-					u8 *dev_type);
-
-/*
- *  ======== dev_get_first ========
- *  Purpose:
- *      Retrieve the first Device Object handle from an internal linked list of
- *      of DEV_OBJECTs maintained by DEV.
- *  Parameters:
- *  Returns:
- *      NULL if there are no device objects stored; else
- *      a valid DEV_HOBJECT.
- *  Requires:
- *      No calls to dev_create_device or dev_destroy_device (which my modify the
- *      internal device object list) may occur between calls to dev_get_first
- *      and dev_get_next.
- *  Ensures:
- *      The DEV_HOBJECT returned is valid.
- *      A subsequent call to dev_get_next will return the next device object in
- *      the list.
- */
-extern struct dev_object *dev_get_first(void);
-
-/*
- *  ======== dev_get_intf_fxns ========
- *  Purpose:
- *      Retrieve the Bridge driver interface function structure for the
- *      loaded Bridge driver.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with
- *                      dev_create_device().
- *      *if_fxns:       Ptr to location to store fxn interface.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hdev_obj.
- *  Requires:
- *      if_fxns != NULL.
- *      DEV Initialized.
- *  Ensures:
- *      0:        *if_fxns contains a pointer to the Bridge
- *                      driver interface;
- *      else:           *if_fxns is NULL.
- */
-extern int dev_get_intf_fxns(struct dev_object *hdev_obj,
-			    struct bridge_drv_interface **if_fxns);
-
-/*
- *  ======== dev_get_io_mgr ========
- *  Purpose:
- *      Retrieve the handle to the IO manager created for this device.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with
- *                      dev_create_device().
- *      *mgr:           Ptr to location to store handle.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hdev_obj.
- *  Requires:
- *      mgr != NULL.
- *      DEV Initialized.
- *  Ensures:
- *      0:        *mgr contains a handle to an IO manager object.
- *      else:           *mgr is NULL.
- */
-extern int dev_get_io_mgr(struct dev_object *hdev_obj,
-				 struct io_mgr **mgr);
-
-/*
- *  ======== dev_get_next ========
- *  Purpose:
- *      Retrieve the next Device Object handle from an internal linked list of
- *      of DEV_OBJECTs maintained by DEV, after having previously called
- *      dev_get_first() and zero or more dev_get_next
- *  Parameters:
- *      hdev_obj: Handle to the device object returned from a previous
- *                  call to dev_get_first() or dev_get_next().
- *  Returns:
- *      NULL if there are no further device objects on the list or hdev_obj
- *      was invalid;
- *      else the next valid DEV_HOBJECT in the list.
- *  Requires:
- *      No calls to dev_create_device or dev_destroy_device (which my modify the
- *      internal device object list) may occur between calls to dev_get_first
- *      and dev_get_next.
- *  Ensures:
- *      The DEV_HOBJECT returned is valid.
- *      A subsequent call to dev_get_next will return the next device object in
- *      the list.
- */
-extern struct dev_object *dev_get_next(struct dev_object
-				       *hdev_obj);
-
-/*
- *  ========= dev_get_msg_mgr ========
- *  Purpose:
- *      Retrieve the msg_ctrl Manager Handle from the DevObject.
- *  Parameters:
- *      hdev_obj: Handle to the Dev Object
- *      msg_man:    Location where msg_ctrl Manager handle will be returned.
- *  Returns:
- *  Requires:
- *      DEV Initialized.
- *      Valid hdev_obj.
- *      node_man != NULL.
- *  Ensures:
- */
-extern void dev_get_msg_mgr(struct dev_object *hdev_obj,
-			    struct msg_mgr **msg_man);
-
-/*
- *  ========= dev_get_node_manager ========
- *  Purpose:
- *      Retrieve the Node Manager Handle from the DevObject. It is an
- *      accessor function
- *  Parameters:
- *      hdev_obj:     Handle to the Dev Object
- *      node_man:       Location where Handle to the Node Manager will be
- *                      returned..
- *  Returns:
- *      0:        Success
- *      -EFAULT:    Invalid Dev Object handle.
- *  Requires:
- *      DEV Initialized.
- *      node_man is not null
- *  Ensures:
- *      0:        *node_man contains a handle to a Node manager object.
- *      else:           *node_man is NULL.
- */
-extern int dev_get_node_manager(struct dev_object
-				       *hdev_obj,
-				       struct node_mgr **node_man);
-
-/*
- *  ======== dev_get_symbol ========
- *  Purpose:
- *      Get the value of a symbol in the currently loaded program.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with
- *                      dev_create_device().
- *      str_sym:        Name of symbol to look up.
- *      pul_value:       Ptr to symbol value.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hdev_obj.
- *      -ESPIPE: Symbols couldn not be found or have not been loaded onto
- *               the board.
- *  Requires:
- *      str_sym != NULL.
- *      pul_value != NULL.
- *      DEV Initialized.
- *  Ensures:
- *      0:        *pul_value contains the symbol value;
- */
-extern int dev_get_symbol(struct dev_object *hdev_obj,
-				 const char *str_sym, u32 * pul_value);
-
-/*
- *  ======== dev_get_bridge_context ========
- *  Purpose:
- *      Retrieve the Bridge Context handle, as returned by the
- *      bridge_dev_create fxn.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with dev_create_device()
- *      *phbridge_context:  Ptr to location to store context handle.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hdev_obj.
- *  Requires:
- *      phbridge_context != NULL.
- *      DEV Initialized.
- *  Ensures:
- *      0:        *phbridge_context contains context handle;
- *      else:           *phbridge_context is NULL;
- */
-extern int dev_get_bridge_context(struct dev_object *hdev_obj,
-				      struct bridge_dev_context
-				      **phbridge_context);
-
-/*
- *  ======== dev_insert_proc_object ========
- *  Purpose:
- *      Inserts the Processor Object into the List of PROC Objects
- *      kept in the DEV Object
- *  Parameters:
- *      proc_obj:    Handle to the Proc Object
- *      hdev_obj      Handle to the Dev Object
- *      bAttachedNew    Specifies if there are already processors attached
- *  Returns:
- *      0:        Successfully inserted into the list
- *  Requires:
- *      proc_obj is not NULL
- *      hdev_obj is a valid handle to the DEV.
- *      DEV Initialized.
- *      List(of Proc object in Dev) Exists.
- *  Ensures:
- *      0 & the PROC Object is inserted and the list is not empty
- *  Details:
- *      If the List of Proc Object is empty bAttachedNew is TRUE, it indicated
- *      this is the first Processor attaching.
- *      If it is False, there are already processors attached.
- */
-extern int dev_insert_proc_object(struct dev_object
-					 *hdev_obj,
-					 u32 proc_obj,
-					 bool *already_attached);
-
-/*
- *  ======== dev_remove_proc_object ========
- *  Purpose:
- *      Search for and remove a Proc object from the given list maintained
- *      by the DEV
- *  Parameters:
- *      p_proc_object:        Ptr to ProcObject to insert.
- *      dev_obj:         Ptr to Dev Object where the list is.
- *      already_attached:  Ptr to return the bool
- *  Returns:
- *      0:            If successful.
- *      -EPERM           Failure to Remove the PROC Object from the list
- *  Requires:
- *      DevObject is Valid
- *      proc_obj != 0
- *      dev_obj->proc_list != NULL
- *      !LST_IS_EMPTY(dev_obj->proc_list)
- *      already_attached !=NULL
- *  Ensures:
- *  Details:
- *      List will be deleted when the DEV is destroyed.
- *
- */
-extern int dev_remove_proc_object(struct dev_object
-					 *hdev_obj, u32 proc_obj);
-
-/*
- *  ======== dev_notify_clients ========
- *  Purpose:
- *      Notify all clients of this device of a change in device status.
- *      Clients may include multiple users of BRD, as well as CHNL.
- *      This function is asychronous, and may be called by a timer event
- *      set up by a watchdog timer.
- *  Parameters:
- *      hdev_obj:  Handle to device object created with dev_create_device().
- *      ret:         A status word, most likely a BRD_STATUS.
- *  Returns:
- *      0:     All registered clients were asynchronously notified.
- *      -EINVAL:   Invalid hdev_obj.
- *  Requires:
- *      DEV Initialized.
- *  Ensures:
- *      0: Notifications are queued by the operating system to be
- *      delivered to clients.  This function does not ensure that
- *      the notifications will ever be delivered.
- */
-extern int dev_notify_clients(struct dev_object *hdev_obj, u32 ret);
-
-/*
- *  ======== dev_remove_device ========
- *  Purpose:
- *      Destroys the Device Object created by dev_start_device.
- *  Parameters:
- *      dev_node_obj:       Device node as it is know to OS.
- *  Returns:
- *      0:        If success;
- *      <error code>    Otherwise.
- *  Requires:
- *  Ensures:
- */
-extern int dev_remove_device(struct cfg_devnode *dev_node_obj);
-
-/*
- *  ======== dev_set_chnl_mgr ========
- *  Purpose:
- *      Set the channel manager for this device.
- *  Parameters:
- *      hdev_obj:     Handle to device object created with
- *                      dev_create_device().
- *      hmgr:           Handle to a channel manager, or NULL.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hdev_obj.
- *  Requires:
- *      DEV Initialized.
- *  Ensures:
- */
-extern int dev_set_chnl_mgr(struct dev_object *hdev_obj,
-				   struct chnl_mgr *hmgr);
-
-/*
- *  ======== dev_set_msg_mgr ========
- *  Purpose:
- *      Set the Message manager for this device.
- *  Parameters:
- *      hdev_obj: Handle to device object created with dev_create_device().
- *      hmgr:       Handle to a message manager, or NULL.
- *  Returns:
- *  Requires:
- *      DEV Initialized.
- *  Ensures:
- */
-extern void dev_set_msg_mgr(struct dev_object *hdev_obj, struct msg_mgr *hmgr);
-
-/*
- *  ======== dev_start_device ========
- *  Purpose:
- *      Initializes the new device with bridge environment.  This involves
- *      querying CM for allocated resources, querying the registry for
- *      necessary dsp resources (requested in the INF file), and using this
- *      information to create a bridge device object.
- *  Parameters:
- *      dev_node_obj:       Device node as it is know to OS.
- *  Returns:
- *      0:        If success;
- *      <error code>    Otherwise.
- *  Requires:
- *      DEV initialized.
- *  Ensures:
- */
-extern int dev_start_device(struct cfg_devnode *dev_node_obj);
-
-#endif /* DEV_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/devdefs.h b/drivers/staging/tidspbridge/include/dspbridge/devdefs.h
deleted file mode 100644
index a2f9241..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/devdefs.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * devdefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Definition of common include typedef between dspdefs.h and dev.h. Required
- * to break circular dependency between Bridge driver and DEV include files.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DEVDEFS_
-#define DEVDEFS_
-
-/* Bridge Device Object */
-struct dev_object;
-
-#endif /* DEVDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/disp.h b/drivers/staging/tidspbridge/include/dspbridge/disp.h
deleted file mode 100644
index 39d3cea..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/disp.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * disp.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP/BIOS Bridge Node Dispatcher.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DISP_
-#define DISP_
-
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/nodedefs.h>
-#include <dspbridge/nodepriv.h>
-
-struct disp_object;
-
-/* Node Dispatcher attributes */
-struct disp_attr {
-	u32 chnl_offset;	/* Offset of channel ids reserved for RMS */
-	/* Size of buffer for sending data to RMS */
-	u32 chnl_buf_size;
-	int proc_family;	/* eg, 5000 */
-	int proc_type;		/* eg, 5510 */
-	void *reserved1;	/* Reserved for future use. */
-	u32 reserved2;		/* Reserved for future use. */
-};
-
-
-/*
- *  ======== disp_create ========
- *  Create a NODE Dispatcher object. This object handles the creation,
- *  deletion, and execution of nodes on the DSP target, through communication
- *  with the Resource Manager Server running on the target. Each NODE
- *  Manager object should have exactly one NODE Dispatcher.
- *
- *  Parameters:
- *      dispatch_obj:   Location to store node dispatcher object on output.
- *      hdev_obj:     Device for this processor.
- *      disp_attrs:     Node dispatcher attributes.
- *  Returns:
- *      0:                Success;
- *      -ENOMEM:            Insufficient memory for requested resources.
- *      -EPERM:              Unable to create dispatcher.
- *  Requires:
- *      disp_attrs != NULL.
- *      hdev_obj != NULL.
- *      dispatch_obj != NULL.
- *  Ensures:
- *      0:        IS_VALID(*dispatch_obj).
- *      error:          *dispatch_obj == NULL.
- */
-extern int disp_create(struct disp_object **dispatch_obj,
-			      struct dev_object *hdev_obj,
-			      const struct disp_attr *disp_attrs);
-
-/*
- *  ======== disp_delete ========
- *  Delete the NODE Dispatcher.
- *
- *  Parameters:
- *      disp_obj:  Node Dispatcher object.
- *  Returns:
- *  Requires:
- *      Valid disp_obj.
- *  Ensures:
- *      disp_obj is invalid.
- */
-extern void disp_delete(struct disp_object *disp_obj);
-
-/*
- *  ======== disp_node_change_priority ========
- *  Change the priority of a node currently running on the target.
- *
- *  Parameters:
- *      disp_obj:            Node Dispatcher object.
- *      hnode:                  Node object representing a node currently
- *                              allocated or running on the DSP.
- *      ulFxnAddress:           Address of RMS function for changing priority.
- *      node_env:                Address of node's environment structure.
- *      prio:              New priority level to set node's priority to.
- *  Returns:
- *      0:                Success.
- *      -ETIME:           A timeout occurred before the DSP responded.
- *  Requires:
- *      Valid disp_obj.
- *      hnode != NULL.
- *  Ensures:
- */
-extern int disp_node_change_priority(struct disp_object
-					    *disp_obj,
-					    struct node_object *hnode,
-					    u32 rms_fxn,
-					    nodeenv node_env, s32 prio);
-
-/*
- *  ======== disp_node_create ========
- *  Create a node on the DSP by remotely calling the node's create function.
- *
- *  Parameters:
- *      disp_obj:    Node Dispatcher object.
- *      hnode:          Node handle obtained from node_allocate().
- *      ul_fxn_addr:      Address or RMS create node function.
- *      ul_create_fxn:    Address of node's create function.
- *      pargs:          Arguments to pass to RMS node create function.
- *      node_env:       Location to store node environment pointer on
- *                      output.
- *  Returns:
- *      0:        Success.
- *      -ETIME:   A timeout occurred before the DSP responded.
- *      -EPERM:      A failure occurred, unable to create node.
- *  Requires:
- *      Valid disp_obj.
- *      pargs != NULL.
- *      hnode != NULL.
- *      node_env != NULL.
- *      node_get_type(hnode) != NODE_DEVICE.
- *  Ensures:
- */
-extern int disp_node_create(struct disp_object *disp_obj,
-				   struct node_object *hnode,
-				   u32 rms_fxn,
-				   u32 ul_create_fxn,
-				   const struct node_createargs
-				   *pargs, nodeenv *node_env);
-
-/*
- *  ======== disp_node_delete ========
- *  Delete a node on the DSP by remotely calling the node's delete function.
- *
- *  Parameters:
- *      disp_obj:    Node Dispatcher object.
- *      hnode:          Node object representing a node currently
- *                      loaded on the DSP.
- *      ul_fxn_addr:      Address or RMS delete node function.
- *      ul_delete_fxn:    Address of node's delete function.
- *      node_env:        Address of node's environment structure.
- *  Returns:
- *      0:        Success.
- *      -ETIME:   A timeout occurred before the DSP responded.
- *  Requires:
- *      Valid disp_obj.
- *      hnode != NULL.
- *  Ensures:
- */
-extern int disp_node_delete(struct disp_object *disp_obj,
-				   struct node_object *hnode,
-				   u32 rms_fxn,
-				   u32 ul_delete_fxn, nodeenv node_env);
-
-/*
- *  ======== disp_node_run ========
- *  Start execution of a node's execute phase, or resume execution of a node
- *  that has been suspended (via DISP_NodePause()) on the DSP.
- *
- *  Parameters:
- *      disp_obj:    Node Dispatcher object.
- *      hnode:          Node object representing a node to be executed
- *                      on the DSP.
- *      ul_fxn_addr:      Address or RMS node execute function.
- *      ul_execute_fxn:   Address of node's execute function.
- *      node_env:        Address of node's environment structure.
- *  Returns:
- *      0:        Success.
- *      -ETIME:   A timeout occurred before the DSP responded.
- *  Requires:
- *      Valid disp_obj.
- *      hnode != NULL.
- *  Ensures:
- */
-extern int disp_node_run(struct disp_object *disp_obj,
-				struct node_object *hnode,
-				u32 rms_fxn,
-				u32 ul_execute_fxn, nodeenv node_env);
-
-#endif /* DISP_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dmm.h b/drivers/staging/tidspbridge/include/dspbridge/dmm.h
deleted file mode 100644
index c3487be..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dmm.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * dmm.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * The Dynamic Memory Mapping(DMM) module manages the DSP Virtual address
- * space that can be directly mapped to any MPU buffer or memory region.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DMM_
-#define DMM_
-
-#include <dspbridge/dbdefs.h>
-
-struct dmm_object;
-
-/* DMM attributes used in dmm_create() */
-struct dmm_mgrattrs {
-	u32 reserved;
-};
-
-#define DMMPOOLSIZE      0x4000000
-
-/*
- *  ======== dmm_get_handle ========
- *  Purpose:
- *      Return the dynamic memory manager object for this device.
- *      This is typically called from the client process.
- */
-
-extern int dmm_get_handle(void *hprocessor,
-				 struct dmm_object **dmm_manager);
-
-extern int dmm_reserve_memory(struct dmm_object *dmm_mgr,
-				     u32 size, u32 *prsv_addr);
-
-extern int dmm_un_reserve_memory(struct dmm_object *dmm_mgr,
-					u32 rsv_addr);
-
-extern int dmm_map_memory(struct dmm_object *dmm_mgr, u32 addr,
-				 u32 size);
-
-extern int dmm_un_map_memory(struct dmm_object *dmm_mgr,
-				    u32 addr, u32 *psize);
-
-extern int dmm_destroy(struct dmm_object *dmm_mgr);
-
-extern int dmm_delete_tables(struct dmm_object *dmm_mgr);
-
-extern int dmm_create(struct dmm_object **dmm_manager,
-			     struct dev_object *hdev_obj,
-			     const struct dmm_mgrattrs *mgr_attrts);
-
-extern int dmm_create_tables(struct dmm_object *dmm_mgr,
-				    u32 addr, u32 size);
-
-#ifdef DSP_DMM_DEBUG
-u32 dmm_mem_map_dump(struct dmm_object *dmm_mgr);
-#endif
-
-#endif /* DMM_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/drv.h b/drivers/staging/tidspbridge/include/dspbridge/drv.h
deleted file mode 100644
index b0c7708..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/drv.h
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- * drv.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DRV Resource allocation module. Driver Object gets Created
- * at the time of Loading. It holds the List of Device Objects
- * in the system.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DRV_
-#define DRV_
-
-#include <dspbridge/devdefs.h>
-
-#include <linux/idr.h>
-
-/* Bridge Driver Object */
-struct drv_object;
-
-/* Provide the DSP Internal memory windows that can be accessed from L3 address
- * space */
-
-#define OMAP_GEM_BASE   0x107F8000
-#define OMAP_DSP_SIZE   0x00720000
-
-/* MEM1 is L2 RAM + L2 Cache space */
-#define OMAP_DSP_MEM1_BASE 0x5C7F8000
-#define OMAP_DSP_MEM1_SIZE 0x18000
-
-/* MEM2 is L1P RAM/CACHE space */
-#define OMAP_DSP_MEM2_BASE 0x5CE00000
-#define OMAP_DSP_MEM2_SIZE 0x8000
-
-/* MEM3 is L1D RAM/CACHE space */
-#define OMAP_DSP_MEM3_BASE 0x5CF04000
-#define OMAP_DSP_MEM3_SIZE 0x14000
-
-#define OMAP_PER_CM_BASE 0x48005000
-#define OMAP_PER_CM_SIZE 0x1000
-
-#define OMAP_PER_PRM_BASE 0x48307000
-#define OMAP_PER_PRM_SIZE 0x1000
-
-#define OMAP_CORE_PRM_BASE 0x48306A00
-#define OMAP_CORE_PRM_SIZE 0x1000
-
-#define OMAP_DMMU_BASE 0x5D000000
-#define OMAP_DMMU_SIZE 0x1000
-
-/* GPP PROCESS CLEANUP Data structures */
-
-/* New structure (member of process context) abstracts NODE resource info */
-struct node_res_object {
-	void *node;
-	s32 node_allocated;	/* Node status */
-	s32 heap_allocated;	/* Heap status */
-	s32 streams_allocated;	/* Streams status */
-	int id;
-};
-
-/* used to cache dma mapping information */
-struct bridge_dma_map_info {
-	/* direction of DMA in action, or DMA_NONE */
-	enum dma_data_direction dir;
-	/* number of elements requested by us */
-	int num_pages;
-	/* number of elements returned from dma_map_sg */
-	int sg_num;
-	/* list of buffers used in this DMA action */
-	struct scatterlist *sg;
-};
-
-/* Used for DMM mapped memory accounting */
-struct dmm_map_object {
-	struct list_head link;
-	u32 dsp_addr;
-	u32 mpu_addr;
-	u32 size;
-	u32 num_usr_pgs;
-	struct page **pages;
-	struct bridge_dma_map_info dma_info;
-};
-
-/* Used for DMM reserved memory accounting */
-struct dmm_rsv_object {
-	struct list_head link;
-	u32 dsp_reserved_addr;
-};
-
-/* New structure (member of process context) abstracts stream resource info */
-struct strm_res_object {
-	s32 stream_allocated;	/* Stream status */
-	void *stream;
-	u32 num_bufs;
-	u32 dir;
-	int id;
-};
-
-/* Overall Bridge process resource usage state */
-enum gpp_proc_res_state {
-	PROC_RES_ALLOCATED,
-	PROC_RES_FREED
-};
-
-/* Bridge Data */
-struct drv_data {
-	char *base_img;
-	s32 shm_size;
-	int tc_wordswapon;
-	void *drv_object;
-	void *dev_object;
-	void *mgr_object;
-};
-
-/* Process Context */
-struct process_context {
-	/* Process State */
-	enum gpp_proc_res_state res_state;
-
-	/* Handle to Processor */
-	void *processor;
-
-	/* DSP Node resources */
-	struct idr *node_id;
-
-	/* DMM mapped memory resources */
-	struct list_head dmm_map_list;
-	spinlock_t dmm_map_lock;
-
-	/* DMM reserved memory resources */
-	struct list_head dmm_rsv_list;
-	spinlock_t dmm_rsv_lock;
-
-	/* Stream resources */
-	struct idr *stream_id;
-};
-
-/*
- *  ======== drv_create ========
- *  Purpose:
- *      Creates the Driver Object. This is done during the driver loading.
- *      There is only one Driver Object in the DSP/BIOS Bridge.
- *  Parameters:
- *      drv_obj:        Location to store created DRV Object handle.
- *  Returns:
- *      0:        Success
- *      -ENOMEM:    Failed in Memory allocation
- *      -EPERM:      General Failure
- *  Requires:
- *      DRV Initialized (refs > 0 )
- *      drv_obj != NULL.
- *  Ensures:
- *      0:        - *drv_obj is a valid DRV interface to the device.
- *                      - List of DevObject Created and Initialized.
- *                      - List of dev_node String created and initialized.
- *                      - Registry is updated with the DRV Object.
- *      !0:       DRV Object not created
- *  Details:
- *      There is one Driver Object for the Driver representing
- *      the driver itself. It contains the list of device
- *      Objects and the list of Device Extensions in the system.
- *      Also it can hold other necessary
- *      information in its storage area.
- */
-extern int drv_create(struct drv_object **drv_obj);
-
-/*
- *  ======== drv_destroy ========
- *  Purpose:
- *      destroys the Dev Object list, DrvExt list
- *      and destroy the DRV object
- *      Called upon driver unLoading.or unsuccessful loading of the driver.
- *  Parameters:
- *      driver_obj:     Handle to Driver object .
- *  Returns:
- *      0:        Success.
- *      -EPERM:      Failed to destroy DRV Object
- *  Requires:
- *      DRV Initialized (cRegs > 0 )
- *      hdrv_obj is not NULL and a valid DRV handle .
- *      List of DevObject is Empty.
- *      List of DrvExt is Empty
- *  Ensures:
- *      0:        - DRV Object destroyed and hdrv_obj is not a valid
- *                        DRV handle.
- *                      - Registry is updated with "0" as the DRV Object.
- */
-extern int drv_destroy(struct drv_object *driver_obj);
-
-/*
- *  ======== drv_get_first_dev_object ========
- *  Purpose:
- *      Returns the Ptr to the FirstDev Object in the List
- *  Parameters:
- *  Requires:
- *      DRV Initialized
- *  Returns:
- *      dw_dev_object:  Ptr to the First Dev Object as a u32
- *      0 if it fails to retrieve the First Dev Object
- *  Ensures:
- */
-extern u32 drv_get_first_dev_object(void);
-
-/*
- *  ======== drv_get_first_dev_extension ========
- *  Purpose:
- *      Returns the Ptr to the First Device Extension in the List
- *  Parameters:
- *  Requires:
- *      DRV Initialized
- *  Returns:
- *      dw_dev_extension:     Ptr to the First Device Extension as a u32
- *      0:                  Failed to Get the Device Extension
- *  Ensures:
- */
-extern u32 drv_get_first_dev_extension(void);
-
-/*
- *  ======== drv_get_dev_object ========
- *  Purpose:
- *      Given a index, returns a handle to DevObject from the list
- *  Parameters:
- *      hdrv_obj:     Handle to the Manager
- *      device_obj:     Location to store the Dev Handle
- *  Requires:
- *      DRV Initialized
- *      index >= 0
- *      hdrv_obj is not NULL and Valid DRV Object
- *      device_obj is not NULL
- *      Device Object List not Empty
- *  Returns:
- *      0:        Success
- *      -EPERM:      Failed to Get the Dev Object
- *  Ensures:
- *      0:        *device_obj != NULL
- *      -EPERM:      *device_obj = NULL
- */
-extern int drv_get_dev_object(u32 index,
-				     struct drv_object *hdrv_obj,
-				     struct dev_object **device_obj);
-
-/*
- *  ======== drv_get_next_dev_object ========
- *  Purpose:
- *      Returns the Ptr to the Next Device Object from the the List
- *  Parameters:
- *      hdev_obj:     Handle to the Device Object
- *  Requires:
- *      DRV Initialized
- *      hdev_obj != 0
- *  Returns:
- *      dw_dev_object:    Ptr to the Next Dev Object as a u32
- *      0:              If it fail to get the next Dev Object.
- *  Ensures:
- */
-extern u32 drv_get_next_dev_object(u32 hdev_obj);
-
-/*
- *  ======== drv_get_next_dev_extension ========
- *  Purpose:
- *      Returns the Ptr to the Next Device Extension from the the List
- *  Parameters:
- *      dev_extension:      Handle to the Device Extension
- *  Requires:
- *      DRV Initialized
- *      dev_extension != 0.
- *  Returns:
- *      dw_dev_extension:     Ptr to the Next Dev Extension
- *      0:                  If it fail to Get the next Dev Extension
- *  Ensures:
- */
-extern u32 drv_get_next_dev_extension(u32 dev_extension);
-
-/*
- *  ======== drv_insert_dev_object ========
- *  Purpose:
- *      Insert a DeviceObject into the list of Driver object.
- *  Parameters:
- *      driver_obj:     Handle to DrvObject
- *      hdev_obj:     Handle to DeviceObject to insert.
- *  Returns:
- *      0:        If successful.
- *      -EPERM:      General Failure:
- *  Requires:
- *      hdrv_obj != NULL and Valid DRV Handle.
- *      hdev_obj != NULL.
- *  Ensures:
- *      0:        Device Object is inserted and the List is not empty.
- */
-extern int drv_insert_dev_object(struct drv_object *driver_obj,
-					struct dev_object *hdev_obj);
-
-/*
- *  ======== drv_remove_dev_object ========
- *  Purpose:
- *      Search for and remove a Device object from the given list of Device Obj
- *      objects.
- *  Parameters:
- *      driver_obj:     Handle to DrvObject
- *      hdev_obj:     Handle to DevObject to Remove
- *  Returns:
- *      0:        Success.
- *      -EPERM:      Unable to find dev_obj.
- *  Requires:
- *      hdrv_obj != NULL and a Valid DRV Handle.
- *      hdev_obj != NULL.
- *      List exists and is not empty.
- *  Ensures:
- *      List either does not exist (NULL), or is not empty if it does exist.
- */
-extern int drv_remove_dev_object(struct drv_object *driver_obj,
-					struct dev_object *hdev_obj);
-
-/*
- *  ======== drv_request_resources ========
- *  Purpose:
- *      Assigns the Resources or Releases them.
- *  Parameters:
- *      dw_context:          Path to the driver Registry Key.
- *      dev_node_strg:     Ptr to dev_node String stored in the Device Ext.
- *  Returns:
- *      TRUE if success; FALSE otherwise.
- *  Requires:
- *  Ensures:
- *      The Resources are assigned based on Bus type.
- *      The hardware is initialized. Resource information is
- *      gathered from the Registry(ISA, PCMCIA)or scanned(PCI)
- *      Resource structure is stored in the registry which will be
- *      later used by the CFG module.
- */
-extern int drv_request_resources(u32 dw_context,
-					u32 *dev_node_strg);
-
-/*
- *  ======== drv_release_resources ========
- *  Purpose:
- *      Assigns the Resources or Releases them.
- *  Parameters:
- *      dw_context:      Path to the driver Registry Key.
- *      hdrv_obj:     Handle to the Driver Object.
- *  Returns:
- *      TRUE if success; FALSE otherwise.
- *  Requires:
- *  Ensures:
- *      The Resources are released based on Bus type.
- *      Resource structure is deleted from the registry
- */
-extern int drv_release_resources(u32 dw_context,
-					struct drv_object *hdrv_obj);
-
-/**
- * drv_request_bridge_res_dsp() - Reserves shared memory for bridge.
- * @phost_resources:  pointer to host resources.
- */
-int drv_request_bridge_res_dsp(void **phost_resources);
-
-#ifdef CONFIG_TIDSPBRIDGE_RECOVERY
-void bridge_recover_schedule(void);
-#endif
-
-/*
- *  ======== mem_ext_phys_pool_init ========
- *  Purpose:
- *      Uses the physical memory chunk passed for internal consistent memory
- *      allocations.
- *      physical address based on the page frame address.
- *  Parameters:
- *      pool_phys_base  starting address of the physical memory pool.
- *      pool_size      size of the physical memory pool.
- *  Returns:
- *      none.
- *  Requires:
- *      - MEM initialized.
- *      - valid physical address for the base and size > 0
- */
-extern void mem_ext_phys_pool_init(u32 pool_phys_base, u32 pool_size);
-
-/*
- *  ======== mem_ext_phys_pool_release ========
- */
-extern void mem_ext_phys_pool_release(void);
-
-/*  ======== mem_alloc_phys_mem ========
- *  Purpose:
- *      Allocate physically contiguous, uncached memory
- *  Parameters:
- *      byte_size:     Number of bytes to allocate.
- *      align_mask:    Alignment Mask.
- *      physical_address: Physical address of allocated memory.
- *  Returns:
- *      Pointer to a block of memory;
- *      NULL if memory couldn't be allocated, or if byte_size == 0.
- *  Requires:
- *      MEM initialized.
- *  Ensures:
- *      The returned pointer, if not NULL, points to a valid memory block of
- *      the size requested.  Returned physical address refers to physical
- *      location of memory.
- */
-extern void *mem_alloc_phys_mem(u32 byte_size,
-				u32 align_mask, u32 *physical_address);
-
-/*
- *  ======== mem_free_phys_mem ========
- *  Purpose:
- *      Free the given block of physically contiguous memory.
- *  Parameters:
- *      virtual_address:  Pointer to virtual memory region allocated
- *      by mem_alloc_phys_mem().
- *      physical_address:  Pointer to physical memory region  allocated
- *      by mem_alloc_phys_mem().
- *      byte_size:  Size of the memory region allocated by mem_alloc_phys_mem().
- *  Returns:
- *  Requires:
- *      MEM initialized.
- *      virtual_address is a valid memory address returned by
- *          mem_alloc_phys_mem()
- *  Ensures:
- *      virtual_address is no longer a valid pointer to memory.
- */
-extern void mem_free_phys_mem(void *virtual_address,
-			      u32 physical_address, u32 byte_size);
-
-/*
- *  ======== MEM_LINEAR_ADDRESS ========
- *  Purpose:
- *      Get the linear address corresponding to the given physical address.
- *  Parameters:
- *      phys_addr:  Physical address to be mapped.
- *      byte_size:     Number of bytes in physical range to map.
- *  Returns:
- *      The corresponding linear address, or NULL if unsuccessful.
- *  Requires:
- *      MEM initialized.
- *  Ensures:
- *  Notes:
- *      If valid linear address is returned, be sure to call
- *      MEM_UNMAP_LINEAR_ADDRESS().
- */
-#define MEM_LINEAR_ADDRESS(phy_addr, byte_size) phy_addr
-
-/*
- *  ======== MEM_UNMAP_LINEAR_ADDRESS ========
- *  Purpose:
- *      Unmap the linear address mapped in MEM_LINEAR_ADDRESS.
- *  Parameters:
- *      base_addr: Ptr to mapped memory (as returned by MEM_LINEAR_ADDRESS()).
- *  Returns:
- *  Requires:
- *      - MEM initialized.
- *      - base_addr is a valid linear address mapped in MEM_LINEAR_ADDRESS.
- *  Ensures:
- *      - base_addr no longer points to a valid linear address.
- */
-#define MEM_UNMAP_LINEAR_ADDRESS(base_addr) {}
-
-#endif /* DRV_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dspapi-ioctl.h b/drivers/staging/tidspbridge/include/dspbridge/dspapi-ioctl.h
deleted file mode 100644
index 6ff8082..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dspapi-ioctl.h
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * dspapi-ioctl.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Contains structures and commands that are used for interaction
- * between the DDSP API and Bridge driver.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DSPAPIIOCTL_
-#define DSPAPIIOCTL_
-
-#include <dspbridge/cmm.h>
-#include <dspbridge/strmdefs.h>
-#include <dspbridge/dbdcd.h>
-
-union trapped_args {
-
-	/* MGR Module */
-	struct {
-		u32 node_id;
-		struct dsp_ndbprops __user *ndb_props;
-		u32 ndb_props_size;
-		u32 __user *num_nodes;
-	} args_mgr_enumnode_info;
-
-	struct {
-		u32 processor_id;
-		struct dsp_processorinfo __user *processor_info;
-		u32 processor_info_size;
-		u32 __user *num_procs;
-	} args_mgr_enumproc_info;
-
-	struct {
-		struct dsp_uuid *uuid_obj;
-		enum dsp_dcdobjtype obj_type;
-		char *sz_path_name;
-	} args_mgr_registerobject;
-
-	struct {
-		struct dsp_uuid *uuid_obj;
-		enum dsp_dcdobjtype obj_type;
-	} args_mgr_unregisterobject;
-
-	struct {
-		struct dsp_notification __user *__user *anotifications;
-		u32 count;
-		u32 __user *index;
-		u32 timeout;
-	} args_mgr_wait;
-
-	/* PROC Module */
-	struct {
-		u32 processor_id;
-		struct dsp_processorattrin __user *attr_in;
-		void *__user *ph_processor;
-	} args_proc_attach;
-
-	struct {
-		void *processor;
-		u32 cmd;
-		struct dsp_cbdata __user *args;
-	} args_proc_ctrl;
-
-	struct {
-		void *processor;
-	} args_proc_detach;
-
-	struct {
-		void *processor;
-		void *__user *node_tab;
-		u32 node_tab_size;
-		u32 __user *num_nodes;
-		u32 __user *allocated;
-	} args_proc_enumnode_info;
-
-	struct {
-		void *processor;
-		u32 resource_type;
-		struct dsp_resourceinfo *resource_info;
-		u32 resource_info_size;
-	} args_proc_enumresources;
-
-	struct {
-		void *processor;
-		struct dsp_processorstate __user *proc_state_obj;
-		u32 state_info_size;
-	} args_proc_getstate;
-
-	struct {
-		void *processor;
-		u8 __user *buf;
-		u8 __user *size;
-		u32 max_size;
-	} args_proc_gettrace;
-
-	struct {
-		void *processor;
-		s32 argc_index;
-		char __user *__user *user_args;
-		char *__user *user_envp;
-	} args_proc_load;
-
-	struct {
-		void *processor;
-		u32 event_mask;
-		u32 notify_type;
-		struct dsp_notification __user *notification;
-	} args_proc_register_notify;
-
-	struct {
-		void *processor;
-		u32 size;
-		void *__user *rsv_addr;
-	} args_proc_rsvmem;
-
-	struct {
-		void *processor;
-		u32 size;
-		void *rsv_addr;
-	} args_proc_unrsvmem;
-
-	struct {
-		void *processor;
-		void *mpu_addr;
-		u32 size;
-		void *req_addr;
-		void *__user *map_addr;
-		u32 map_attr;
-	} args_proc_mapmem;
-
-	struct {
-		void *processor;
-		u32 size;
-		void *map_addr;
-	} args_proc_unmapmem;
-
-	struct {
-		void *processor;
-		void *mpu_addr;
-		u32 size;
-		u32 dir;
-	} args_proc_dma;
-
-	struct {
-		void *processor;
-		void *mpu_addr;
-		u32 size;
-		u32 flags;
-	} args_proc_flushmemory;
-
-	struct {
-		void *processor;
-		void *mpu_addr;
-		u32 size;
-	} args_proc_invalidatememory;
-
-	/* NODE Module */
-	struct {
-		void *processor;
-		struct dsp_uuid __user *node_id_ptr;
-		struct dsp_cbdata __user *args;
-		struct dsp_nodeattrin __user *attr_in;
-		void *__user *node;
-	} args_node_allocate;
-
-	struct {
-		void *node;
-		u32 size;
-		struct dsp_bufferattr __user *attr;
-		u8 *__user *buffer;
-	} args_node_allocmsgbuf;
-
-	struct {
-		void *node;
-		s32 prio;
-	} args_node_changepriority;
-
-	struct {
-		void *node;
-		u32 stream_id;
-		void *other_node;
-		u32 other_stream;
-		struct dsp_strmattr __user *attrs;
-		struct dsp_cbdata __user *conn_param;
-	} args_node_connect;
-
-	struct {
-		void *node;
-	} args_node_create;
-
-	struct {
-		void *node;
-	} args_node_delete;
-
-	struct {
-		void *node;
-		struct dsp_bufferattr __user *attr;
-		u8 *buffer;
-	} args_node_freemsgbuf;
-
-	struct {
-		void *node;
-		struct dsp_nodeattr __user *attr;
-		u32 attr_size;
-	} args_node_getattr;
-
-	struct {
-		void *node;
-		struct dsp_msg __user *message;
-		u32 timeout;
-	} args_node_getmessage;
-
-	struct {
-		void *node;
-	} args_node_pause;
-
-	struct {
-		void *node;
-		struct dsp_msg __user *message;
-		u32 timeout;
-	} args_node_putmessage;
-
-	struct {
-		void *node;
-		u32 event_mask;
-		u32 notify_type;
-		struct dsp_notification __user *notification;
-	} args_node_registernotify;
-
-	struct {
-		void *node;
-	} args_node_run;
-
-	struct {
-		void *node;
-		int __user *status;
-	} args_node_terminate;
-
-	struct {
-		void *processor;
-		struct dsp_uuid __user *node_id_ptr;
-		struct dsp_ndbprops __user *node_props;
-	} args_node_getuuidprops;
-
-	/* STRM module */
-
-	struct {
-		void *stream;
-		u32 size;
-		u8 *__user *ap_buffer;
-		u32 num_bufs;
-	} args_strm_allocatebuffer;
-
-	struct {
-		void *stream;
-	} args_strm_close;
-
-	struct {
-		void *stream;
-		u8 *__user *ap_buffer;
-		u32 num_bufs;
-	} args_strm_freebuffer;
-
-	struct {
-		void *stream;
-		void **event;
-	} args_strm_geteventhandle;
-
-	struct {
-		void *stream;
-		struct stream_info __user *stream_info;
-		u32 stream_info_size;
-	} args_strm_getinfo;
-
-	struct {
-		void *stream;
-		bool flush_flag;
-	} args_strm_idle;
-
-	struct {
-		void *stream;
-		u8 *buffer;
-		u32 bytes;
-		u32 buf_size;
-		u32 arg;
-	} args_strm_issue;
-
-	struct {
-		void *node;
-		u32 direction;
-		u32 index;
-		struct strm_attr __user *attr_in;
-		void *__user *stream;
-	} args_strm_open;
-
-	struct {
-		void *stream;
-		u8 *__user *buf_ptr;
-		u32 __user *bytes;
-		u32 __user *buf_size_ptr;
-		u32 __user *arg;
-	} args_strm_reclaim;
-
-	struct {
-		void *stream;
-		u32 event_mask;
-		u32 notify_type;
-		struct dsp_notification __user *notification;
-	} args_strm_registernotify;
-
-	struct {
-		void *__user *stream_tab;
-		u32 strm_num;
-		u32 __user *mask;
-		u32 timeout;
-	} args_strm_select;
-
-	/* CMM Module */
-	struct {
-		struct cmm_object *cmm_mgr;
-		u32 size;
-		struct cmm_attrs *attrs;
-		void **buf_va;
-	} args_cmm_allocbuf;
-
-	struct {
-		struct cmm_object *cmm_mgr;
-		void *buf_pa;
-		u32 seg_id;
-	} args_cmm_freebuf;
-
-	struct {
-		void *processor;
-		struct cmm_object *__user *cmm_mgr;
-	} args_cmm_gethandle;
-
-	struct {
-		struct cmm_object *cmm_mgr;
-		struct cmm_info __user *cmm_info_obj;
-	} args_cmm_getinfo;
-
-	/* UTIL module */
-	struct {
-		s32 util_argc;
-		char **argv;
-	} args_util_testdll;
-};
-
-/*
- * Dspbridge Ioctl numbering scheme
- *
- *    7                           0
- *  ---------------------------------
- *  |  Module   |   Ioctl Number    |
- *  ---------------------------------
- *  | x | x | x | 0 | 0 | 0 | 0 | 0 |
- *  ---------------------------------
- */
-
-/* Ioctl driver identifier */
-#define DB		0xDB
-
-/*
- * Following are used to distinguish between module ioctls, this is needed
- * in case new ioctls are introduced.
- */
-#define DB_MODULE_MASK		0xE0
-#define DB_IOC_MASK		0x1F
-
-/* Ioctl module masks */
-#define DB_MGR		0x0
-#define DB_PROC		0x20
-#define DB_NODE		0x40
-#define DB_STRM		0x60
-#define DB_CMM		0x80
-
-#define DB_MODULE_SHIFT		5
-
-/* Used to calculate the ioctl per dspbridge module */
-#define DB_IOC(module, num) \
-			(((module) & DB_MODULE_MASK) | ((num) & DB_IOC_MASK))
-/* Used to get dspbridge ioctl module */
-#define DB_GET_MODULE(cmd)	((cmd) & DB_MODULE_MASK)
-/* Used to get dspbridge ioctl number */
-#define DB_GET_IOC(cmd)		((cmd) & DB_IOC_MASK)
-
-/* TODO: Remove deprecated and not implemented */
-
-/* MGR Module */
-#define MGR_ENUMNODE_INFO	_IOWR(DB, DB_IOC(DB_MGR, 0), unsigned long)
-#define MGR_ENUMPROC_INFO	_IOWR(DB, DB_IOC(DB_MGR, 1), unsigned long)
-#define MGR_REGISTEROBJECT	_IOWR(DB, DB_IOC(DB_MGR, 2), unsigned long)
-#define MGR_UNREGISTEROBJECT	_IOWR(DB, DB_IOC(DB_MGR, 3), unsigned long)
-#define MGR_WAIT		_IOWR(DB, DB_IOC(DB_MGR, 4), unsigned long)
-/* MGR_GET_PROC_RES Deprecated */
-#define MGR_GET_PROC_RES	_IOR(DB, DB_IOC(DB_MGR, 5), unsigned long)
-
-/* PROC Module */
-#define PROC_ATTACH		_IOWR(DB, DB_IOC(DB_PROC, 0), unsigned long)
-#define PROC_CTRL		_IOR(DB, DB_IOC(DB_PROC, 1), unsigned long)
-/* PROC_DETACH Deprecated */
-#define PROC_DETACH		_IOR(DB, DB_IOC(DB_PROC, 2), unsigned long)
-#define PROC_ENUMNODE		_IOWR(DB, DB_IOC(DB_PROC, 3), unsigned long)
-#define PROC_ENUMRESOURCES	_IOWR(DB, DB_IOC(DB_PROC, 4), unsigned long)
-#define PROC_GET_STATE		_IOWR(DB, DB_IOC(DB_PROC, 5), unsigned long)
-#define PROC_GET_TRACE		_IOWR(DB, DB_IOC(DB_PROC, 6), unsigned long)
-#define PROC_LOAD		_IOW(DB, DB_IOC(DB_PROC, 7), unsigned long)
-#define PROC_REGISTERNOTIFY	_IOWR(DB, DB_IOC(DB_PROC, 8), unsigned long)
-#define PROC_START		_IOW(DB, DB_IOC(DB_PROC, 9), unsigned long)
-#define PROC_RSVMEM		_IOWR(DB, DB_IOC(DB_PROC, 10), unsigned long)
-#define PROC_UNRSVMEM		_IOW(DB, DB_IOC(DB_PROC, 11), unsigned long)
-#define PROC_MAPMEM		_IOWR(DB, DB_IOC(DB_PROC, 12), unsigned long)
-#define PROC_UNMAPMEM		_IOR(DB, DB_IOC(DB_PROC, 13), unsigned long)
-#define PROC_FLUSHMEMORY	_IOW(DB, DB_IOC(DB_PROC, 14), unsigned long)
-#define PROC_STOP		_IOWR(DB, DB_IOC(DB_PROC, 15), unsigned long)
-#define PROC_INVALIDATEMEMORY	_IOW(DB, DB_IOC(DB_PROC, 16), unsigned long)
-#define PROC_BEGINDMA		_IOW(DB, DB_IOC(DB_PROC, 17), unsigned long)
-#define PROC_ENDDMA		_IOW(DB, DB_IOC(DB_PROC, 18), unsigned long)
-
-/* NODE Module */
-#define NODE_ALLOCATE		_IOWR(DB, DB_IOC(DB_NODE, 0), unsigned long)
-#define NODE_ALLOCMSGBUF	_IOWR(DB, DB_IOC(DB_NODE, 1), unsigned long)
-#define NODE_CHANGEPRIORITY	_IOW(DB, DB_IOC(DB_NODE, 2), unsigned long)
-#define NODE_CONNECT		_IOW(DB, DB_IOC(DB_NODE, 3), unsigned long)
-#define NODE_CREATE		_IOW(DB, DB_IOC(DB_NODE, 4), unsigned long)
-#define NODE_DELETE		_IOW(DB, DB_IOC(DB_NODE, 5), unsigned long)
-#define NODE_FREEMSGBUF		_IOW(DB, DB_IOC(DB_NODE, 6), unsigned long)
-#define NODE_GETATTR		_IOWR(DB, DB_IOC(DB_NODE, 7), unsigned long)
-#define NODE_GETMESSAGE		_IOWR(DB, DB_IOC(DB_NODE, 8), unsigned long)
-#define NODE_PAUSE		_IOW(DB, DB_IOC(DB_NODE, 9), unsigned long)
-#define NODE_PUTMESSAGE		_IOW(DB, DB_IOC(DB_NODE, 10), unsigned long)
-#define NODE_REGISTERNOTIFY	_IOWR(DB, DB_IOC(DB_NODE, 11), unsigned long)
-#define NODE_RUN		_IOW(DB, DB_IOC(DB_NODE, 12), unsigned long)
-#define NODE_TERMINATE		_IOWR(DB, DB_IOC(DB_NODE, 13), unsigned long)
-#define NODE_GETUUIDPROPS	_IOWR(DB, DB_IOC(DB_NODE, 14), unsigned long)
-
-/* STRM Module */
-#define STRM_ALLOCATEBUFFER	_IOWR(DB, DB_IOC(DB_STRM, 0), unsigned long)
-#define STRM_CLOSE		_IOW(DB, DB_IOC(DB_STRM, 1), unsigned long)
-#define STRM_FREEBUFFER		_IOWR(DB, DB_IOC(DB_STRM, 2), unsigned long)
-#define STRM_GETEVENTHANDLE	_IO(DB, DB_IOC(DB_STRM, 3))	/* Not Impl'd */
-#define STRM_GETINFO		_IOWR(DB, DB_IOC(DB_STRM, 4), unsigned long)
-#define STRM_IDLE		_IOW(DB, DB_IOC(DB_STRM, 5), unsigned long)
-#define STRM_ISSUE		_IOW(DB, DB_IOC(DB_STRM, 6), unsigned long)
-#define STRM_OPEN		_IOWR(DB, DB_IOC(DB_STRM, 7), unsigned long)
-#define STRM_RECLAIM		_IOWR(DB, DB_IOC(DB_STRM, 8), unsigned long)
-#define STRM_REGISTERNOTIFY	_IOWR(DB, DB_IOC(DB_STRM, 9), unsigned long)
-#define STRM_SELECT		_IOWR(DB, DB_IOC(DB_STRM, 10), unsigned long)
-
-/* CMM Module */
-#define CMM_ALLOCBUF		_IO(DB, DB_IOC(DB_CMM, 0))	/* Not Impl'd */
-#define CMM_FREEBUF		_IO(DB, DB_IOC(DB_CMM, 1))	/* Not Impl'd */
-#define CMM_GETHANDLE		_IOR(DB, DB_IOC(DB_CMM, 2), unsigned long)
-#define CMM_GETINFO		_IOR(DB, DB_IOC(DB_CMM, 3), unsigned long)
-
-#endif /* DSPAPIIOCTL_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dspapi.h b/drivers/staging/tidspbridge/include/dspbridge/dspapi.h
deleted file mode 100644
index c99c687..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dspapi.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * dspapi.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Includes the wrapper functions called directly by the
- * DeviceIOControl interface.
- *
- * Notes:
- *   Bridge services exported to Bridge driver are initialized by the DSPAPI on
- *   behalf of the Bridge driver. Bridge driver must not call module Init/Exit
- *   functions.
- *
- *   To ensure Bridge driver binary compatibility across different platforms,
- *   for the same processor, a Bridge driver must restrict its usage of system
- *   services to those exported by the DSPAPI library.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DSPAPI_
-#define DSPAPI_
-
-#include <dspbridge/dspapi-ioctl.h>
-
-/* This BRD API Library Version: */
-#define BRD_API_MAJOR_VERSION   (u32)8	/* .8x - Alpha, .9x - Beta, 1.x FCS */
-#define BRD_API_MINOR_VERSION   (u32)0
-
-/*
- *  ======== api_call_dev_ioctl ========
- *  Purpose:
- *      Call the (wrapper) function for the corresponding API IOCTL.
- *  Parameters:
- *      cmd:        IOCTL id, base 0.
- *      args:       Argument structure.
- *      result:
- *  Returns:
- *      0 if command called; -EINVAL if command not in IOCTL
- *      table.
- *  Requires:
- *  Ensures:
- */
-extern int api_call_dev_ioctl(unsigned int cmd,
-				      union trapped_args *args,
-				      u32 *result, void *pr_ctxt);
-
-/*
- *  ======== api_init ========
- *  Purpose:
- *      Initialize modules used by Bridge API.
- *      This procedure is called when the driver is loaded.
- *  Parameters:
- *  Returns:
- *      TRUE if success; FALSE otherwise.
- *  Requires:
- *  Ensures:
- */
-extern bool api_init(void);
-
-/*
- *  ======== api_init_complete2 ========
- *  Purpose:
- *      Perform any required bridge initialization which cannot
- *      be performed in api_init() or dev_start_device() due
- *      to the fact that some services are not yet
- *      completely initialized.
- *  Parameters:
- *  Returns:
- *      0:        Allow this device to load
- *      -EPERM:      Failure.
- *  Requires:
- *      Bridge API initialized.
- *  Ensures:
- */
-extern int api_init_complete2(void);
-
-/*
- *  ======== api_exit ========
- *  Purpose:
- *      Exit all modules initialized in api_init(void).
- *      This procedure is called when the driver is unloaded.
- *  Parameters:
- *  Returns:
- *  Requires:
- *      api_init(void) was previously called.
- *  Ensures:
- *      Resources acquired in api_init(void) are freed.
- */
-extern void api_exit(void);
-
-/* MGR wrapper functions */
-extern u32 mgrwrap_enum_node_info(union trapped_args *args, void *pr_ctxt);
-extern u32 mgrwrap_enum_proc_info(union trapped_args *args, void *pr_ctxt);
-extern u32 mgrwrap_register_object(union trapped_args *args, void *pr_ctxt);
-extern u32 mgrwrap_unregister_object(union trapped_args *args, void *pr_ctxt);
-extern u32 mgrwrap_wait_for_bridge_events(union trapped_args *args,
-					  void *pr_ctxt);
-
-extern u32 mgrwrap_get_process_resources_info(union trapped_args *args,
-					      void *pr_ctxt);
-
-/* CPRC (Processor) wrapper Functions */
-extern u32 procwrap_attach(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_ctrl(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_detach(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_enum_node_info(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_enum_resources(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_get_state(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_get_trace(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_load(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_register_notify(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_start(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_reserve_memory(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_un_reserve_memory(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_map(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_un_map(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_flush_memory(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_stop(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_invalidate_memory(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_begin_dma(union trapped_args *args, void *pr_ctxt);
-extern u32 procwrap_end_dma(union trapped_args *args, void *pr_ctxt);
-
-/* NODE wrapper functions */
-extern u32 nodewrap_allocate(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_alloc_msg_buf(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_change_priority(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_connect(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_create(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_delete(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_free_msg_buf(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_get_attr(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_get_message(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_pause(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_put_message(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_register_notify(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_run(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_terminate(union trapped_args *args, void *pr_ctxt);
-extern u32 nodewrap_get_uuid_props(union trapped_args *args, void *pr_ctxt);
-
-/* STRM wrapper functions */
-extern u32 strmwrap_allocate_buffer(union trapped_args *args, void *pr_ctxt);
-extern u32 strmwrap_close(union trapped_args *args, void *pr_ctxt);
-extern u32 strmwrap_free_buffer(union trapped_args *args, void *pr_ctxt);
-extern u32 strmwrap_get_event_handle(union trapped_args *args, void *pr_ctxt);
-extern u32 strmwrap_get_info(union trapped_args *args, void *pr_ctxt);
-extern u32 strmwrap_idle(union trapped_args *args, void *pr_ctxt);
-extern u32 strmwrap_issue(union trapped_args *args, void *pr_ctxt);
-extern u32 strmwrap_open(union trapped_args *args, void *pr_ctxt);
-extern u32 strmwrap_reclaim(union trapped_args *args, void *pr_ctxt);
-extern u32 strmwrap_register_notify(union trapped_args *args, void *pr_ctxt);
-extern u32 strmwrap_select(union trapped_args *args, void *pr_ctxt);
-
-extern u32 cmmwrap_calloc_buf(union trapped_args *args, void *pr_ctxt);
-extern u32 cmmwrap_free_buf(union trapped_args *args, void *pr_ctxt);
-extern u32 cmmwrap_get_handle(union trapped_args *args, void *pr_ctxt);
-extern u32 cmmwrap_get_info(union trapped_args *args, void *pr_ctxt);
-
-#endif /* DSPAPI_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dspchnl.h b/drivers/staging/tidspbridge/include/dspbridge/dspchnl.h
deleted file mode 100644
index 7146a50..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dspchnl.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * dspchnl.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Declares the upper edge channel class library functions required by
- * all Bridge driver / DSP API driver interface tables. These functions are
- * implemented by every class of Bridge channel library.
- *
- * Notes:
- *   The function comment headers reside in dspdefs.h.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DSPCHNL_
-#define DSPCHNL_
-
-extern int bridge_chnl_create(struct chnl_mgr **channel_mgr,
-				     struct dev_object *hdev_obj,
-				     const struct chnl_mgrattrs
-				     *mgr_attrts);
-
-extern int bridge_chnl_destroy(struct chnl_mgr *hchnl_mgr);
-
-extern int bridge_chnl_open(struct chnl_object **chnl,
-				   struct chnl_mgr *hchnl_mgr,
-				   s8 chnl_mode,
-				   u32 ch_id,
-				   const struct chnl_attr
-				   *pattrs);
-
-extern int bridge_chnl_close(struct chnl_object *chnl_obj);
-
-extern int bridge_chnl_add_io_req(struct chnl_object *chnl_obj,
-				      void *host_buf,
-				      u32 byte_size, u32 buf_size,
-				      u32 dw_dsp_addr, u32 dw_arg);
-
-extern int bridge_chnl_get_ioc(struct chnl_object *chnl_obj,
-				   u32 timeout, struct chnl_ioc *chan_ioc);
-
-extern int bridge_chnl_cancel_io(struct chnl_object *chnl_obj);
-
-extern int bridge_chnl_flush_io(struct chnl_object *chnl_obj,
-				    u32 timeout);
-
-extern int bridge_chnl_get_info(struct chnl_object *chnl_obj,
-				    struct chnl_info *channel_info);
-
-extern int bridge_chnl_get_mgr_info(struct chnl_mgr *hchnl_mgr,
-					u32 ch_id, struct chnl_mgrinfo
-					*mgr_info);
-
-extern int bridge_chnl_idle(struct chnl_object *chnl_obj,
-				   u32 timeout, bool flush_data);
-
-extern int bridge_chnl_register_notify(struct chnl_object *chnl_obj,
-					   u32 event_mask,
-					   u32 notify_type,
-					   struct dsp_notification
-					   *hnotification);
-
-#endif /* DSPCHNL_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dspdefs.h b/drivers/staging/tidspbridge/include/dspbridge/dspdefs.h
deleted file mode 100644
index ed32bf3..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dspdefs.h
+++ /dev/null
@@ -1,1048 +0,0 @@
-/*
- * dspdefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Bridge driver entry point and interface function declarations.
- *
- * Notes:
- *   The DSP API obtains it's function interface to
- *   the Bridge driver via a call to bridge_drv_entry().
- *
- *   Bridge services exported to Bridge drivers are initialized by the
- *   DSP API on behalf of the Bridge driver.
- *
- *   Bridge function DBC Requires and Ensures are also made by the DSP API on
- *   behalf of the Bridge driver, to simplify the Bridge driver code.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DSPDEFS_
-#define DSPDEFS_
-
-#include <dspbridge/brddefs.h>
-#include <dspbridge/cfgdefs.h>
-#include <dspbridge/chnlpriv.h>
-#include <dspbridge/dspdeh.h>
-#include <dspbridge/devdefs.h>
-#include <dspbridge/io.h>
-#include <dspbridge/msgdefs.h>
-
-/* Handle to Bridge driver's private device context. */
-struct bridge_dev_context;
-
-/*--------------------------------------------------------------------------- */
-/* BRIDGE DRIVER FUNCTION TYPES */
-/*--------------------------------------------------------------------------- */
-
-/*
- *  ======== bridge_brd_monitor ========
- *  Purpose:
- *      Bring the board to the BRD_IDLE (monitor) state.
- *  Parameters:
- *      dev_ctxt:    Handle to Bridge driver defined device context.
- *  Returns:
- *      0:        Success.
- *      -ETIMEDOUT:  Timeout occurred waiting for a response from hardware.
- *      -EPERM:      Other, unspecified error.
- *  Requires:
- *      dev_ctxt != NULL
- *  Ensures:
- *      0:        Board is in BRD_IDLE state;
- *      else:           Board state is indeterminate.
- */
-typedef int(*fxn_brd_monitor) (struct bridge_dev_context *dev_ctxt);
-
-/*
- *  ======== fxn_brd_setstate ========
- *  Purpose:
- *      Sets the Bridge driver state
- *  Parameters:
- *      dev_ctxt:    Handle to Bridge driver defined device info.
- *      brd_state:      Board state
- *  Returns:
- *      0:        Success.
- *      -EPERM:      Other, unspecified error.
- *  Requires:
- *      dev_ctxt != NULL;
- *      brd_state  <= BRD_LASTSTATE.
- *  Ensures:
- *      brd_state  <= BRD_LASTSTATE.
- *  Update the Board state to the specified state.
- */
-typedef int(*fxn_brd_setstate) (struct bridge_dev_context
-				       * dev_ctxt, u32 brd_state);
-
-/*
- *  ======== bridge_brd_start ========
- *  Purpose:
- *      Bring board to the BRD_RUNNING (start) state.
- *  Parameters:
- *      dev_ctxt:    Handle to Bridge driver defined device context.
- *      dsp_addr:       DSP address at which to start execution.
- *  Returns:
- *      0:        Success.
- *      -ETIMEDOUT:  Timeout occurred waiting for a response from hardware.
- *      -EPERM:      Other, unspecified error.
- *  Requires:
- *      dev_ctxt != NULL
- *      Board is in monitor (BRD_IDLE) state.
- *  Ensures:
- *      0:        Board is in BRD_RUNNING state.
- *                      Interrupts to the PC are enabled.
- *      else:           Board state is indeterminate.
- */
-typedef int(*fxn_brd_start) (struct bridge_dev_context
-				    * dev_ctxt, u32 dsp_addr);
-
-/*
- *  ======== bridge_brd_mem_copy ========
- *  Purpose:
- *  Copy memory from one DSP address to another
- *  Parameters:
- *      dev_context:    Pointer to context handle
- *  dsp_dest_addr:  DSP address to copy to
- *  dsp_src_addr:   DSP address to copy from
- *  ul_num_bytes: Number of bytes to copy
- *  mem_type:   What section of memory to copy to
- *  Returns:
- *      0:        Success.
- *      -EPERM:      Other, unspecified error.
- *  Requires:
- *      dev_context != NULL
- *  Ensures:
- *      0:        Board is in BRD_RUNNING state.
- *                      Interrupts to the PC are enabled.
- *      else:           Board state is indeterminate.
- */
-typedef int(*fxn_brd_memcopy) (struct bridge_dev_context
-				      * dev_ctxt,
-				      u32 dsp_dest_addr,
-				      u32 dsp_src_addr,
-				      u32 ul_num_bytes, u32 mem_type);
-/*
- *  ======== bridge_brd_mem_write ========
- *  Purpose:
- *      Write a block of host memory into a DSP address, into a given memory
- *      space.  Unlike bridge_brd_write, this API does reset the DSP
- *  Parameters:
- *      dev_ctxt:    Handle to Bridge driver defined device info.
- *      dsp_addr:       Address on DSP board (Destination).
- *      host_buf:       Pointer to host buffer (Source).
- *      ul_num_bytes:     Number of bytes to transfer.
- *      mem_type:       Memory space on DSP to which to transfer.
- *  Returns:
- *      0:        Success.
- *      -ETIMEDOUT:  Timeout occurred waiting for a response from hardware.
- *      -EPERM:      Other, unspecified error.
- *  Requires:
- *      dev_ctxt != NULL;
- *      host_buf != NULL.
- *  Ensures:
- */
-typedef int(*fxn_brd_memwrite) (struct bridge_dev_context
-				       * dev_ctxt,
-				       u8 *host_buf,
-				       u32 dsp_addr, u32 ul_num_bytes,
-				       u32 mem_type);
-
-/*
- *  ======== bridge_brd_mem_map ========
- *  Purpose:
- *      Map a MPU memory region to a DSP/IVA memory space
- *  Parameters:
- *      dev_ctxt:    Handle to Bridge driver defined device info.
- *      ul_mpu_addr:      MPU memory region start address.
- *      virt_addr:      DSP/IVA memory region u8 address.
- *      ul_num_bytes:     Number of bytes to map.
- *      map_attrs:       Mapping attributes (e.g. endianness).
- *  Returns:
- *      0:        Success.
- *      -EPERM:      Other, unspecified error.
- *  Requires:
- *      dev_ctxt != NULL;
- *  Ensures:
- */
-typedef int(*fxn_brd_memmap) (struct bridge_dev_context
-				     * dev_ctxt, u32 ul_mpu_addr,
-				     u32 virt_addr, u32 ul_num_bytes,
-				     u32 map_attr,
-				     struct page **mapped_pages);
-
-/*
- *  ======== bridge_brd_mem_un_map ========
- *  Purpose:
- *      UnMap an MPU memory region from DSP/IVA memory space
- *  Parameters:
- *      dev_ctxt:    Handle to Bridge driver defined device info.
- *      virt_addr:      DSP/IVA memory region u8 address.
- *      ul_num_bytes:     Number of bytes to unmap.
- *  Returns:
- *      0:        Success.
- *      -EPERM:      Other, unspecified error.
- *  Requires:
- *      dev_ctxt != NULL;
- *  Ensures:
- */
-typedef int(*fxn_brd_memunmap) (struct bridge_dev_context
-				       * dev_ctxt,
-				       u32 virt_addr, u32 ul_num_bytes);
-
-/*
- *  ======== bridge_brd_stop ========
- *  Purpose:
- *      Bring board to the BRD_STOPPED state.
- *  Parameters:
- *      dev_ctxt:    Handle to Bridge driver defined device context.
- *  Returns:
- *      0:        Success.
- *      -ETIMEDOUT:  Timeout occurred waiting for a response from hardware.
- *      -EPERM:      Other, unspecified error.
- *  Requires:
- *      dev_ctxt != NULL
- *  Ensures:
- *      0:        Board is in BRD_STOPPED (stop) state;
- *                      Interrupts to the PC are disabled.
- *      else:           Board state is indeterminate.
- */
-typedef int(*fxn_brd_stop) (struct bridge_dev_context *dev_ctxt);
-
-/*
- *  ======== bridge_brd_status ========
- *  Purpose:
- *      Report the current state of the board.
- *  Parameters:
- *      dev_ctxt:    Handle to Bridge driver defined device context.
- *      board_state:    Ptr to BRD status variable.
- *  Returns:
- *      0:
- *  Requires:
- *      board_state != NULL;
- *      dev_ctxt != NULL
- *  Ensures:
- *      *board_state is one of
- *       {BRD_STOPPED, BRD_IDLE, BRD_RUNNING, BRD_UNKNOWN};
- */
-typedef int(*fxn_brd_status) (struct bridge_dev_context *dev_ctxt,
-				     int *board_state);
-
-/*
- *  ======== bridge_brd_read ========
- *  Purpose:
- *      Read a block of DSP memory, from a given memory space, into a host
- *      buffer.
- *  Parameters:
- *      dev_ctxt:    Handle to Bridge driver defined device info.
- *      host_buf:       Pointer to host buffer (Destination).
- *      dsp_addr:       Address on DSP board (Source).
- *      ul_num_bytes:     Number of bytes to transfer.
- *      mem_type:       Memory space on DSP from which to transfer.
- *  Returns:
- *      0:        Success.
- *      -ETIMEDOUT:  Timeout occurred waiting for a response from hardware.
- *      -EPERM:      Other, unspecified error.
- *  Requires:
- *      dev_ctxt != NULL;
- *      host_buf != NULL.
- *  Ensures:
- *  Will not write more than ul_num_bytes bytes into host_buf.
- */
-typedef int(*fxn_brd_read) (struct bridge_dev_context *dev_ctxt,
-				   u8 *host_buf,
-				   u32 dsp_addr,
-				   u32 ul_num_bytes, u32 mem_type);
-
-/*
- *  ======== bridge_brd_write ========
- *  Purpose:
- *      Write a block of host memory into a DSP address, into a given memory
- *      space.
- *  Parameters:
- *      dev_ctxt:    Handle to Bridge driver defined device info.
- *      dsp_addr:       Address on DSP board (Destination).
- *      host_buf:       Pointer to host buffer (Source).
- *      ul_num_bytes:     Number of bytes to transfer.
- *      mem_type:       Memory space on DSP to which to transfer.
- *  Returns:
- *      0:        Success.
- *      -ETIMEDOUT:  Timeout occurred waiting for a response from hardware.
- *      -EPERM:      Other, unspecified error.
- *  Requires:
- *      dev_ctxt != NULL;
- *      host_buf != NULL.
- *  Ensures:
- */
-typedef int(*fxn_brd_write) (struct bridge_dev_context *dev_ctxt,
-				    u8 *host_buf,
-				    u32 dsp_addr,
-				    u32 ul_num_bytes, u32 mem_type);
-
-/*
- *  ======== bridge_chnl_create ========
- *  Purpose:
- *      Create a channel manager object, responsible for opening new channels
- *      and closing old ones for a given 'Bridge board.
- *  Parameters:
- *      channel_mgr:    Location to store a channel manager object on output.
- *      hdev_obj:     Handle to a device object.
- *      mgr_attrts:      Channel manager attributes.
- *      mgr_attrts->max_channels: Max channels
- *      mgr_attrts->birq:      Channel's I/O IRQ number.
- *      mgr_attrts->irq_shared:   TRUE if the IRQ is shareable.
- *      mgr_attrts->word_size: DSP Word size in equivalent PC bytes..
- *      mgr_attrts->shm_base:  Base physical address of shared memory, if any.
- *      mgr_attrts->sm_length: Bytes of shared memory block.
- *  Returns:
- *      0:            Success;
- *      -ENOMEM:        Insufficient memory for requested resources.
- *      -EIO:         Unable to plug ISR for given IRQ.
- *      -EFAULT:    Couldn't map physical address to a virtual one.
- *  Requires:
- *      channel_mgr != NULL.
- *      mgr_attrts != NULL
- *      mgr_attrts field are all valid:
- *          0 < max_channels <= CHNL_MAXCHANNELS.
- *          birq <= 15.
- *          word_size > 0.
- *      hdev_obj != NULL
- *      No channel manager exists for this board.
- *  Ensures:
- */
-typedef int(*fxn_chnl_create) (struct chnl_mgr
-				      **channel_mgr,
-				      struct dev_object
-				      * hdev_obj,
-				      const struct
-				      chnl_mgrattrs * mgr_attrts);
-
-/*
- *  ======== bridge_chnl_destroy ========
- *  Purpose:
- *      Close all open channels, and destroy the channel manager.
- *  Parameters:
- *      hchnl_mgr:       Channel manager object.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    hchnl_mgr was invalid.
- *  Requires:
- *  Ensures:
- *      0: Cancels I/O on each open channel. Closes each open channel.
- *          chnl_create may subsequently be called for the same device.
- */
-typedef int(*fxn_chnl_destroy) (struct chnl_mgr *hchnl_mgr);
-/*
- *  ======== bridge_deh_notify ========
- *  Purpose:
- *      When notified of DSP error, take appropriate action.
- *  Parameters:
- *      hdeh_mgr:        Handle to DEH manager object.
- *      evnt_mask:    Indicate the type of exception
- *      error_info:    Error information
- *  Returns:
- *
- *  Requires:
- *      hdeh_mgr != NULL;
- *     evnt_mask with a valid exception
- *  Ensures:
- */
-typedef void (*fxn_deh_notify) (struct deh_mgr *hdeh_mgr,
-				u32 evnt_mask, u32 error_info);
-
-/*
- *  ======== bridge_chnl_open ========
- *  Purpose:
- *      Open a new half-duplex channel to the DSP board.
- *  Parameters:
- *      chnl:           Location to store a channel object handle.
- *      hchnl_mgr:	Handle to channel manager, as returned by
- *      		CHNL_GetMgr().
- *      chnl_mode:          One of {CHNL_MODETODSP, CHNL_MODEFROMDSP} specifies
- *                      direction of data transfer.
- *      ch_id:        If CHNL_PICKFREE is specified, the channel manager will
- *                      select a free channel id (default);
- *                      otherwise this field specifies the id of the channel.
- *      pattrs:         Channel attributes.  Attribute fields are as follows:
- *      pattrs->uio_reqs: Specifies the maximum number of I/O requests which can
- *                      be pending at any given time. All request packets are
- *                      preallocated when the channel is opened.
- *      pattrs->event_obj: This field allows the user to supply an auto reset
- *                      event object for channel I/O completion notifications.
- *                      It is the responsibility of the user to destroy this
- *                      object AFTER closing the channel.
- *                      This channel event object can be retrieved using
- *                      CHNL_GetEventHandle().
- *      pattrs->hReserved: The kernel mode handle of this event object.
- *
- *  Returns:
- *      0:                Success.
- *      -EFAULT:            hchnl_mgr is invalid.
- *      -ENOMEM:            Insufficient memory for requested resources.
- *      -EINVAL:        Invalid number of IOReqs.
- *      -ENOSR:    No free channels available.
- *      -ECHRNG:       Channel ID is out of range.
- *      -EALREADY:        Channel is in use.
- *      -EIO:         No free IO request packets available for
- *                              queuing.
- *  Requires:
- *      chnl != NULL.
- *      pattrs != NULL.
- *      pattrs->event_obj is a valid event handle.
- *      pattrs->hReserved is the kernel mode handle for pattrs->event_obj.
- *  Ensures:
- *      0:                *chnl is a valid channel.
- *      else:                   *chnl is set to NULL if (chnl != NULL);
- */
-typedef int(*fxn_chnl_open) (struct chnl_object
-				    **chnl,
-				    struct chnl_mgr *hchnl_mgr,
-				    s8 chnl_mode,
-				    u32 ch_id,
-				    const struct
-				    chnl_attr * pattrs);
-
-/*
- *  ======== bridge_chnl_close ========
- *  Purpose:
- *      Ensures all pending I/O on this channel is cancelled, discards all
- *      queued I/O completion notifications, then frees the resources allocated
- *      for this channel, and makes the corresponding logical channel id
- *      available for subsequent use.
- *  Parameters:
- *      chnl_obj:          Handle to a channel object.
- *  Returns:
- *      0:        Success;
- *      -EFAULT:    Invalid chnl_obj.
- *  Requires:
- *      No thread must be blocked on this channel's I/O completion event.
- *  Ensures:
- *      0:        chnl_obj is no longer valid.
- */
-typedef int(*fxn_chnl_close) (struct chnl_object *chnl_obj);
-
-/*
- *  ======== bridge_chnl_add_io_req ========
- *  Purpose:
- *      Enqueue an I/O request for data transfer on a channel to the DSP.
- *      The direction (mode) is specified in the channel object. Note the DSP
- *      address is specified for channels opened in direct I/O mode.
- *  Parameters:
- *      chnl_obj:          Channel object handle.
- *      host_buf:       Host buffer address source.
- *      byte_size:	Number of PC bytes to transfer. A zero value indicates
- *                      that this buffer is the last in the output channel.
- *                      A zero value is invalid for an input channel.
- *!     buf_size:       Actual buffer size in host bytes.
- *      dw_dsp_addr:      DSP address for transfer.  (Currently ignored).
- *      dw_arg:          A user argument that travels with the buffer.
- *  Returns:
- *      0:        Success;
- *      -EFAULT: Invalid chnl_obj or host_buf.
- *      -EPERM:   User cannot mark EOS on an input channel.
- *      -ECANCELED: I/O has been cancelled on this channel.  No further
- *                      I/O is allowed.
- *      -EPIPE:     End of stream was already marked on a previous
- *                      IORequest on this channel.  No further I/O is expected.
- *      -EINVAL: Buffer submitted to this output channel is larger than
- *                      the size of the physical shared memory output window.
- *  Requires:
- *  Ensures:
- *      0: The buffer will be transferred if the channel is ready;
- *          otherwise, will be queued for transfer when the channel becomes
- *          ready.  In any case, notifications of I/O completion are
- *          asynchronous.
- *          If byte_size is 0 for an output channel, subsequent CHNL_AddIOReq's
- *          on this channel will fail with error code -EPIPE.  The
- *          corresponding IOC for this I/O request will have its status flag
- *          set to CHNL_IOCSTATEOS.
- */
-typedef int(*fxn_chnl_addioreq) (struct chnl_object
-					* chnl_obj,
-					void *host_buf,
-					u32 byte_size,
-					u32 buf_size,
-					u32 dw_dsp_addr, u32 dw_arg);
-
-/*
- *  ======== bridge_chnl_get_ioc ========
- *  Purpose:
- *      Dequeue an I/O completion record, which contains information about the
- *      completed I/O request.
- *  Parameters:
- *      chnl_obj:          Channel object handle.
- *      timeout:        A value of CHNL_IOCNOWAIT will simply dequeue the
- *                      first available IOC.
- *      chan_ioc:       On output, contains host buffer address, bytes
- *                      transferred, and status of I/O completion.
- *      chan_ioc->status:   See chnldefs.h.
- *  Returns:
- *      0:        Success.
- *      -EFAULT: Invalid chnl_obj or chan_ioc.
- *      -EREMOTEIO:   CHNL_IOCNOWAIT was specified as the timeout parameter
- *                      yet no I/O completions were queued.
- *  Requires:
- *      timeout == CHNL_IOCNOWAIT.
- *  Ensures:
- *      0: if there are any remaining IOC's queued before this call
- *          returns, the channel event object will be left in a signalled
- *          state.
- */
-typedef int(*fxn_chnl_getioc) (struct chnl_object *chnl_obj,
-				      u32 timeout,
-				      struct chnl_ioc *chan_ioc);
-
-/*
- *  ======== bridge_chnl_cancel_io ========
- *  Purpose:
- *      Return all I/O requests to the client which have not yet been
- *      transferred.  The channel's I/O completion object is
- *      signalled, and all the I/O requests are queued as IOC's, with the
- *      status field set to CHNL_IOCSTATCANCEL.
- *      This call is typically used in abort situations, and is a prelude to
- *      chnl_close();
- *  Parameters:
- *      chnl_obj:          Channel object handle.
- *  Returns:
- *      0:        Success;
- *      -EFAULT:    Invalid chnl_obj.
- *  Requires:
- *  Ensures:
- *      Subsequent I/O requests to this channel will not be accepted.
- */
-typedef int(*fxn_chnl_cancelio) (struct chnl_object *chnl_obj);
-
-/*
- *  ======== bridge_chnl_flush_io ========
- *  Purpose:
- *      For an output stream (to the DSP), indicates if any IO requests are in
- *      the output request queue.  For input streams (from the DSP), will
- *      cancel all pending IO requests.
- *  Parameters:
- *      chnl_obj:              Channel object handle.
- *      timeout:            Timeout value for flush operation.
- *  Returns:
- *      0:            Success;
- *      S_CHNLIOREQUEST:    Returned if any IORequests are in the output queue.
- *      -EFAULT:        Invalid chnl_obj.
- *  Requires:
- *  Ensures:
- *      0:            No I/O requests will be pending on this channel.
- */
-typedef int(*fxn_chnl_flushio) (struct chnl_object *chnl_obj,
-				       u32 timeout);
-
-/*
- *  ======== bridge_chnl_get_info ========
- *  Purpose:
- *      Retrieve information related to a channel.
- *  Parameters:
- *      chnl_obj:          Handle to a valid channel object, or NULL.
- *      channel_info:   Location to store channel info.
- *  Returns:
- *      0:        Success;
- *      -EFAULT: Invalid chnl_obj or channel_info.
- *  Requires:
- *  Ensures:
- *      0:        channel_info points to a filled in chnl_info struct,
- *                      if (channel_info != NULL).
- */
-typedef int(*fxn_chnl_getinfo) (struct chnl_object *chnl_obj,
-				       struct chnl_info *channel_info);
-
-/*
- *  ======== bridge_chnl_get_mgr_info ========
- *  Purpose:
- *      Retrieve information related to the channel manager.
- *  Parameters:
- *      hchnl_mgr:           Handle to a valid channel manager, or NULL.
- *      ch_id:            Channel ID.
- *      mgr_info:           Location to store channel manager info.
- *  Returns:
- *      0:            Success;
- *      -EFAULT: Invalid hchnl_mgr or mgr_info.
- *      -ECHRNG:   Invalid channel ID.
- *  Requires:
- *  Ensures:
- *      0:            mgr_info points to a filled in chnl_mgrinfo
- *                          struct, if (mgr_info != NULL).
- */
-typedef int(*fxn_chnl_getmgrinfo) (struct chnl_mgr
-					  * hchnl_mgr,
-					  u32 ch_id,
-					  struct chnl_mgrinfo *mgr_info);
-
-/*
- *  ======== bridge_chnl_idle ========
- *  Purpose:
- *      Idle a channel. If this is an input channel, or if this is an output
- *      channel and flush_data is TRUE, all currently enqueued buffers will be
- *      dequeued (data discarded for output channel).
- *      If this is an output channel and flush_data is FALSE, this function
- *      will block until all currently buffered data is output, or the timeout
- *      specified has been reached.
- *
- *  Parameters:
- *      chnl_obj:          Channel object handle.
- *      timeout:        If output channel and flush_data is FALSE, timeout value
- *                      to wait for buffers to be output. (Not used for
- *                      input channel).
- *      flush_data:     If output channel and flush_data is TRUE, discard any
- *                      currently buffered data. If FALSE, wait for currently
- *                      buffered data to be output, or timeout, whichever
- *                      occurs first. flush_data is ignored for input channel.
- *  Returns:
- *      0:            Success;
- *      -EFAULT:        Invalid chnl_obj.
- *      -ETIMEDOUT: Timeout occurred before channel could be idled.
- *  Requires:
- *  Ensures:
- */
-typedef int(*fxn_chnl_idle) (struct chnl_object *chnl_obj,
-				    u32 timeout, bool flush_data);
-
-/*
- *  ======== bridge_chnl_register_notify ========
- *  Purpose:
- *      Register for notification of events on a channel.
- *  Parameters:
- *      chnl_obj:          Channel object handle.
- *      event_mask:     Type of events to be notified about: IO completion
- *                      (DSP_STREAMIOCOMPLETION) or end of stream
- *                      (DSP_STREAMDONE).
- *      notify_type:    DSP_SIGNALEVENT.
- *      hnotification:  Handle of a dsp_notification object.
- *  Returns:
- *      0:        Success.
- *      -ENOMEM:    Insufficient memory.
- *      -EINVAL:     event_mask is 0 and hnotification was not
- *                      previously registered.
- *      -EFAULT:    NULL hnotification, hnotification event name
- *                      too long, or hnotification event name NULL.
- *  Requires:
- *      Valid chnl_obj.
- *      hnotification != NULL.
- *      (event_mask & ~(DSP_STREAMIOCOMPLETION | DSP_STREAMDONE)) == 0.
- *      notify_type == DSP_SIGNALEVENT.
- *  Ensures:
- */
-typedef int(*fxn_chnl_registernotify)
- (struct chnl_object *chnl_obj,
-  u32 event_mask, u32 notify_type, struct dsp_notification *hnotification);
-
-/*
- *  ======== bridge_dev_create ========
- *  Purpose:
- *      Complete creation of the device object for this board.
- *  Parameters:
- *      device_ctx:     Ptr to location to store a Bridge device context.
- *      hdev_obj:     Handle to a Device Object, created and managed by DSP API.
- *      config_param:        Ptr to configuration parameters provided by the
- *                      Configuration Manager during device loading.
- *      pDspConfig:     DSP resources, as specified in the registry key for this
- *                      device.
- *  Returns:
- *      0:            Success.
- *      -ENOMEM:        Unable to allocate memory for device context.
- *  Requires:
- *      device_ctx != NULL;
- *      hdev_obj != NULL;
- *      config_param != NULL;
- *      pDspConfig != NULL;
- *      Fields in config_param and pDspConfig contain valid values.
- *  Ensures:
- *      0:        All Bridge driver specific DSP resource and other
- *                      board context has been allocated.
- *      -ENOMEM:    Bridge failed to allocate resources.
- *                      Any acquired resources have been freed.  The DSP API
- *                      will not call bridge_dev_destroy() if
- *                      bridge_dev_create() fails.
- *  Details:
- *      Called during the CONFIGMG's Device_Init phase. Based on host and
- *      DSP configuration information, create a board context, a handle to
- *      which is passed into other Bridge BRD and CHNL functions.  The
- *      board context contains state information for the device. Since the
- *      addresses of all pointer parameters may be invalid when this
- *      function returns, they must not be stored into the device context
- *      structure.
- */
-typedef int(*fxn_dev_create) (struct bridge_dev_context
-				     **device_ctx,
-				     struct dev_object
-				     * hdev_obj,
-				     struct cfg_hostres
-				     * config_param);
-
-/*
- *  ======== bridge_dev_ctrl ========
- *  Purpose:
- *      Bridge driver specific interface.
- *  Parameters:
- *      dev_ctxt:    Handle to Bridge driver defined device info.
- *      dw_cmd:          Bridge driver defined command code.
- *      pargs:          Pointer to an arbitrary argument structure.
- *  Returns:
- *      0 or -EPERM. Actual command error codes should be passed back in
- *      the pargs structure, and are defined by the Bridge driver implementor.
- *  Requires:
- *      All calls are currently assumed to be synchronous.  There are no
- *      IOCTL completion routines provided.
- *  Ensures:
- */
-typedef int(*fxn_dev_ctrl) (struct bridge_dev_context *dev_ctxt,
-				   u32 dw_cmd, void *pargs);
-
-/*
- *  ======== bridge_dev_destroy ========
- *  Purpose:
- *      Deallocate Bridge device extension structures and all other resources
- *      acquired by the Bridge driver.
- *      No calls to other Bridge driver functions may subsequently
- *      occur, except for bridge_dev_create().
- *  Parameters:
- *      dev_ctxt:    Handle to Bridge driver defined device information.
- *  Returns:
- *      0:        Success.
- *      -EPERM:      Failed to release a resource previously acquired.
- *  Requires:
- *      dev_ctxt != NULL;
- *  Ensures:
- *      0: Device context is freed.
- */
-typedef int(*fxn_dev_destroy) (struct bridge_dev_context *dev_ctxt);
-
-/*
- *  ======== bridge_io_create ========
- *  Purpose:
- *      Create an object that manages I/O between CHNL and msg_ctrl.
- *  Parameters:
- *      io_man:         Location to store IO manager on output.
- *      hchnl_mgr:       Handle to channel manager.
- *      hmsg_mgr:        Handle to message manager.
- *  Returns:
- *      0:        Success.
- *      -ENOMEM:    Memory allocation failure.
- *      -EPERM:      Creation failed.
- *  Requires:
- *      hdev_obj != NULL;
- *      Channel manager already created;
- *      Message manager already created;
- *      mgr_attrts != NULL;
- *      io_man != NULL;
- *  Ensures:
- */
-typedef int(*fxn_io_create) (struct io_mgr **io_man,
-				    struct dev_object *hdev_obj,
-				    const struct io_attrs *mgr_attrts);
-
-/*
- *  ======== bridge_io_destroy ========
- *  Purpose:
- *      Destroy object created in bridge_io_create.
- *  Parameters:
- *      hio_mgr:         IO Manager.
- *  Returns:
- *      0:        Success.
- *      -ENOMEM:    Memory allocation failure.
- *      -EPERM:      Creation failed.
- *  Requires:
- *      Valid hio_mgr;
- *  Ensures:
- */
-typedef int(*fxn_io_destroy) (struct io_mgr *hio_mgr);
-
-/*
- *  ======== bridge_io_on_loaded ========
- *  Purpose:
- *      Called whenever a program is loaded to update internal data. For
- *      example, if shared memory is used, this function would update the
- *      shared memory location and address.
- *  Parameters:
- *      hio_mgr:     IO Manager.
- *  Returns:
- *      0:    Success.
- *      -EPERM:  Internal failure occurred.
- *  Requires:
- *      Valid hio_mgr;
- *  Ensures:
- */
-typedef int(*fxn_io_onloaded) (struct io_mgr *hio_mgr);
-
-/*
- *  ======== fxn_io_getprocload ========
- *  Purpose:
- *      Called to get the Processor's current and predicted load
- *  Parameters:
- *      hio_mgr:     IO Manager.
- *      proc_load_stat   Processor Load statistics
- *  Returns:
- *      0:    Success.
- *      -EPERM:  Internal failure occurred.
- *  Requires:
- *      Valid hio_mgr;
- *  Ensures:
- */
-typedef int(*fxn_io_getprocload) (struct io_mgr *hio_mgr,
-					 struct dsp_procloadstat *
-					 proc_load_stat);
-
-/*
- *  ======== bridge_msg_create ========
- *  Purpose:
- *      Create an object to manage message queues. Only one of these objects
- *      can exist per device object.
- *  Parameters:
- *      msg_man:            Location to store msg_ctrl manager on output.
- *      hdev_obj:         Handle to a device object.
- *      msg_callback:        Called whenever an RMS_EXIT message is received.
- *  Returns:
- *      0:            Success.
- *      -ENOMEM:        Insufficient memory.
- *  Requires:
- *      msg_man != NULL.
- *      msg_callback != NULL.
- *      hdev_obj != NULL.
- *  Ensures:
- */
-typedef int(*fxn_msg_create)
- (struct msg_mgr **msg_man,
-  struct dev_object *hdev_obj, msg_onexit msg_callback);
-
-/*
- *  ======== bridge_msg_create_queue ========
- *  Purpose:
- *      Create a msg_ctrl queue for sending or receiving messages from a Message
- *      node on the DSP.
- *  Parameters:
- *      hmsg_mgr:            msg_ctrl queue manager handle returned from
- *                          bridge_msg_create.
- *      msgq:               Location to store msg_ctrl queue on output.
- *      msgq_id:	    Identifier for messages (node environment pointer).
- *      max_msgs:           Max number of simultaneous messages for the node.
- *      h:                  Handle passed to hmsg_mgr->msg_callback().
- *  Returns:
- *      0:            Success.
- *      -ENOMEM:        Insufficient memory.
- *  Requires:
- *      msgq != NULL.
- *      h != NULL.
- *      max_msgs > 0.
- *  Ensures:
- *      msgq !=NULL <==> 0.
- */
-typedef int(*fxn_msg_createqueue)
- (struct msg_mgr *hmsg_mgr,
-  struct msg_queue **msgq, u32 msgq_id, u32 max_msgs, void *h);
-
-/*
- *  ======== bridge_msg_delete ========
- *  Purpose:
- *      Delete a msg_ctrl manager allocated in bridge_msg_create().
- *  Parameters:
- *      hmsg_mgr:    Handle returned from bridge_msg_create().
- *  Returns:
- *  Requires:
- *      Valid hmsg_mgr.
- *  Ensures:
- */
-typedef void (*fxn_msg_delete) (struct msg_mgr *hmsg_mgr);
-
-/*
- *  ======== bridge_msg_delete_queue ========
- *  Purpose:
- *      Delete a msg_ctrl queue allocated in bridge_msg_create_queue.
- *  Parameters:
- *      msg_queue_obj:  Handle to msg_ctrl queue returned from
- *                  bridge_msg_create_queue.
- *  Returns:
- *  Requires:
- *      Valid msg_queue_obj.
- *  Ensures:
- */
-typedef void (*fxn_msg_deletequeue) (struct msg_queue *msg_queue_obj);
-
-/*
- *  ======== bridge_msg_get ========
- *  Purpose:
- *      Get a message from a msg_ctrl queue.
- *  Parameters:
- *      msg_queue_obj:     Handle to msg_ctrl queue returned from
- *                     bridge_msg_create_queue.
- *      pmsg:          Location to copy message into.
- *      utimeout:      Timeout to wait for a message.
- *  Returns:
- *      0:       Success.
- *      -ETIME:  Timeout occurred.
- *      -EPERM:     No frames available for message (max_msgs too
- *                     small).
- *  Requires:
- *      Valid msg_queue_obj.
- *      pmsg != NULL.
- *  Ensures:
- */
-typedef int(*fxn_msg_get) (struct msg_queue *msg_queue_obj,
-				  struct dsp_msg *pmsg, u32 utimeout);
-
-/*
- *  ======== bridge_msg_put ========
- *  Purpose:
- *      Put a message onto a msg_ctrl queue.
- *  Parameters:
- *      msg_queue_obj:      Handle to msg_ctrl queue returned from
- *                      bridge_msg_create_queue.
- *      pmsg:           Pointer to message.
- *      utimeout:       Timeout to wait for a message.
- *  Returns:
- *      0:        Success.
- *      -ETIME:   Timeout occurred.
- *      -EPERM:      No frames available for message (max_msgs too
- *                      small).
- *  Requires:
- *      Valid msg_queue_obj.
- *      pmsg != NULL.
- *  Ensures:
- */
-typedef int(*fxn_msg_put) (struct msg_queue *msg_queue_obj,
-				  const struct dsp_msg *pmsg, u32 utimeout);
-
-/*
- *  ======== bridge_msg_register_notify ========
- *  Purpose:
- *      Register notification for when a message is ready.
- *  Parameters:
- *      msg_queue_obj:      Handle to msg_ctrl queue returned from
- *                      bridge_msg_create_queue.
- *      event_mask:     Type of events to be notified about: Must be
- *                      DSP_NODEMESSAGEREADY, or 0 to unregister.
- *      notify_type:    DSP_SIGNALEVENT.
- *      hnotification:  Handle of notification object.
- *  Returns:
- *      0:        Success.
- *      -ENOMEM:    Insufficient memory.
- *  Requires:
- *      Valid msg_queue_obj.
- *      hnotification != NULL.
- *      notify_type == DSP_SIGNALEVENT.
- *      event_mask == DSP_NODEMESSAGEREADY || event_mask == 0.
- *  Ensures:
- */
-typedef int(*fxn_msg_registernotify)
- (struct msg_queue *msg_queue_obj,
-  u32 event_mask, u32 notify_type, struct dsp_notification *hnotification);
-
-/*
- *  ======== bridge_msg_set_queue_id ========
- *  Purpose:
- *      Set message queue id to node environment. Allows bridge_msg_create_queue
- *      to be called in node_allocate, before the node environment is known.
- *  Parameters:
- *      msg_queue_obj:  Handle to msg_ctrl queue returned from
- *                  bridge_msg_create_queue.
- *      msgq_id:       Node environment pointer.
- *  Returns:
- *  Requires:
- *      Valid msg_queue_obj.
- *      msgq_id != 0.
- *  Ensures:
- */
-typedef void (*fxn_msg_setqueueid) (struct msg_queue *msg_queue_obj,
-				    u32 msgq_id);
-
-/*
- *  Bridge Driver interface function table.
- *
- *  The information in this table is filled in by the specific Bridge driver,
- *  and copied into the DSP API's own space.  If any interface
- *  function field is set to a value of NULL, then the DSP API will
- *  consider that function not implemented, and return the error code
- *  -ENOSYS when a Bridge driver client attempts to call that function.
- *
- *  This function table contains DSP API version numbers, which are used by the
- *  Bridge driver loader to help ensure backwards compatility between older
- *  Bridge drivers and newer DSP API.  These must be set to
- *  BRD_API_MAJOR_VERSION and BRD_API_MINOR_VERSION, respectively.
- *
- *  A Bridge driver need not export a CHNL interface.  In this case, *all* of
- *  the bridge_chnl_* entries must be set to NULL.
- */
-struct bridge_drv_interface {
-	u32 brd_api_major_version;	/* Set to BRD_API_MAJOR_VERSION. */
-	u32 brd_api_minor_version;	/* Set to BRD_API_MINOR_VERSION. */
-	fxn_dev_create dev_create;	/* Create device context */
-	fxn_dev_destroy dev_destroy;	/* Destroy device context */
-	fxn_dev_ctrl dev_cntrl;	/* Optional vendor interface */
-	fxn_brd_monitor brd_monitor;	/* Load and/or start monitor */
-	fxn_brd_start brd_start;	/* Start DSP program. */
-	fxn_brd_stop brd_stop;	/* Stop/reset board. */
-	fxn_brd_status brd_status;	/* Get current board status. */
-	fxn_brd_read brd_read;	/* Read board memory */
-	fxn_brd_write brd_write;	/* Write board memory. */
-	fxn_brd_setstate brd_set_state;	/* Sets the Board State */
-	fxn_brd_memcopy brd_mem_copy;	/* Copies DSP Memory */
-	fxn_brd_memwrite brd_mem_write;	/* Write DSP Memory w/o halt */
-	fxn_brd_memmap brd_mem_map;	/* Maps MPU mem to DSP mem */
-	fxn_brd_memunmap brd_mem_un_map;	/* Unmaps MPU mem to DSP mem */
-	fxn_chnl_create chnl_create;	/* Create channel manager. */
-	fxn_chnl_destroy chnl_destroy;	/* Destroy channel manager. */
-	fxn_chnl_open chnl_open;	/* Create a new channel. */
-	fxn_chnl_close chnl_close;	/* Close a channel. */
-	fxn_chnl_addioreq chnl_add_io_req;	/* Req I/O on a channel. */
-	fxn_chnl_getioc chnl_get_ioc;	/* Wait for I/O completion. */
-	fxn_chnl_cancelio chnl_cancel_io;	/* Cancl I/O on a channel. */
-	fxn_chnl_flushio chnl_flush_io;	/* Flush I/O. */
-	fxn_chnl_getinfo chnl_get_info;	/* Get channel specific info */
-	/* Get channel manager info. */
-	fxn_chnl_getmgrinfo chnl_get_mgr_info;
-	fxn_chnl_idle chnl_idle;	/* Idle the channel */
-	/* Register for notif. */
-	fxn_chnl_registernotify chnl_register_notify;
-	fxn_io_create io_create;	/* Create IO manager */
-	fxn_io_destroy io_destroy;	/* Destroy IO manager */
-	fxn_io_onloaded io_on_loaded;	/* Notify of program loaded */
-	/* Get Processor's current and predicted load */
-	fxn_io_getprocload io_get_proc_load;
-	fxn_msg_create msg_create;	/* Create message manager */
-	/* Create message queue */
-	fxn_msg_createqueue msg_create_queue;
-	fxn_msg_delete msg_delete;	/* Delete message manager */
-	/* Delete message queue */
-	fxn_msg_deletequeue msg_delete_queue;
-	fxn_msg_get msg_get;	/* Get a message */
-	fxn_msg_put msg_put;	/* Send a message */
-	/* Register for notif. */
-	fxn_msg_registernotify msg_register_notify;
-	/* Set message queue id */
-	fxn_msg_setqueueid msg_set_queue_id;
-};
-
-/*
- *  ======== bridge_drv_entry ========
- *  Purpose:
- *      Registers Bridge driver functions with the DSP API. Called only once
- *      by the DSP API.  The caller will first check DSP API version
- *      compatibility, and then copy the interface functions into its own
- *      memory space.
- *  Parameters:
- *      drv_intf  Pointer to a location to receive a pointer to the
- *                      Bridge driver interface.
- *  Returns:
- *  Requires:
- *      The code segment this function resides in must expect to be discarded
- *      after completion.
- *  Ensures:
- *      drv_intf pointer initialized to Bridge driver's function
- *      interface. No system resources are acquired by this function.
- *  Details:
- *      Called during the Device_Init phase.
- */
-void bridge_drv_entry(struct bridge_drv_interface **drv_intf,
-		   const char *driver_file_name);
-
-#endif /* DSPDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dspdeh.h b/drivers/staging/tidspbridge/include/dspbridge/dspdeh.h
deleted file mode 100644
index d258ab6..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dspdeh.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * dspdeh.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Defines upper edge DEH functions required by all Bridge driver/DSP API
- * interface tables.
- *
- * Notes:
- *   Function comment headers reside with the function typedefs in dspdefs.h.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- * Copyright (C) 2010 Felipe Contreras
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DSPDEH_
-#define DSPDEH_
-
-struct deh_mgr;
-struct dev_object;
-struct dsp_notification;
-
-int bridge_deh_create(struct deh_mgr **ret_deh,
-		struct dev_object *hdev_obj);
-
-int bridge_deh_destroy(struct deh_mgr *deh);
-
-int bridge_deh_register_notify(struct deh_mgr *deh,
-		u32 event_mask,
-		u32 notify_type,
-		struct dsp_notification *hnotification);
-
-void bridge_deh_notify(struct deh_mgr *deh, int event, int info);
-
-#endif /* DSPDEH_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dspdrv.h b/drivers/staging/tidspbridge/include/dspbridge/dspdrv.h
deleted file mode 100644
index 7adf1e7..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dspdrv.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * dspdrv.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * This is the Stream Interface for the DSp API.
- * All Device operations are performed via DeviceIOControl.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#if !defined _DSPDRV_H_
-#define _DSPDRV_H_
-
-/*
- *  ======== dsp_deinit ========
- *  Purpose:
- *      This function is called by Device Manager to de-initialize a device.
- *      This function is not called by applications.
- *  Parameters:
- *      device_context:Handle to the device context. The XXX_Init function
- *      creates and returns this identifier.
- *  Returns:
- *      TRUE indicates the device successfully de-initialized. Otherwise it
- *      returns FALSE.
- *  Requires:
- *      device_context!= NULL. For a built in device this should never
- *      get called.
- *  Ensures:
- */
-extern bool dsp_deinit(u32 device_context);
-
-/*
- *  ======== dsp_init ========
- *  Purpose:
- *      This function is called by Device Manager to initialize a device.
- *      This function is not called by applications
- *  Parameters:
- *      dw_context:  Specifies a pointer to a string containing the registry
- *                  path to the active key for the stream interface driver.
- *                  HKEY_LOCAL_MACHINE\Drivers\Active
- *  Returns:
- *      Returns a handle to the device context created. This is the our actual
- *      Device Object representing the DSP Device instance.
- *  Requires:
- *  Ensures:
- *      Succeeded:  device context > 0
- *      Failed:     device Context = 0
- */
-extern u32 dsp_init(u32 *init_status);
-
-#endif
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dspio.h b/drivers/staging/tidspbridge/include/dspbridge/dspio.h
deleted file mode 100644
index 66b64fa..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dspio.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * dspio.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Declares the upper edge IO functions required by all Bridge driver /DSP API
- * interface tables.
- *
- * Notes:
- *   Function comment headers reside in dspdefs.h.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DSPIO_
-#define DSPIO_
-
-#include <dspbridge/devdefs.h>
-#include <dspbridge/io.h>
-
-
-extern int bridge_io_create(struct io_mgr **io_man,
-				   struct dev_object *hdev_obj,
-				   const struct io_attrs *mgr_attrts);
-
-extern int bridge_io_destroy(struct io_mgr *hio_mgr);
-
-extern int bridge_io_on_loaded(struct io_mgr *hio_mgr);
-
-extern int bridge_io_get_proc_load(struct io_mgr *hio_mgr,
-				       struct dsp_procloadstat *proc_lstat);
-
-#endif /* DSPIO_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dspioctl.h b/drivers/staging/tidspbridge/include/dspbridge/dspioctl.h
deleted file mode 100644
index 0fcda197..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dspioctl.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * dspioctl.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Bridge driver BRD_IOCtl reserved command definitions.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DSPIOCTL_
-#define DSPIOCTL_
-
-/* ------------------------------------ Hardware Abstraction Layer */
-#include <hw_defs.h>
-#include <hw_mmu.h>
-
-/*
- * Any IOCTLS at or above this value are reserved for standard Bridge driver
- * interfaces.
- */
-#define BRDIOCTL_RESERVEDBASE       0x8000
-
-#define BRDIOCTL_CHNLREAD           (BRDIOCTL_RESERVEDBASE + 0x10)
-#define BRDIOCTL_CHNLWRITE          (BRDIOCTL_RESERVEDBASE + 0x20)
-/* DMMU */
-#define BRDIOCTL_SETMMUCONFIG       (BRDIOCTL_RESERVEDBASE + 0x60)
-/* PWR */
-#define BRDIOCTL_PWRCONTROL         (BRDIOCTL_RESERVEDBASE + 0x70)
-
-/* attention, modifiers:
- * Some of these control enumerations are made visible to user for power
- * control, so any changes to this list, should also be updated in the user
- * header file 'dbdefs.h' ***/
-/* These ioctls are reserved for PWR power commands for the DSP */
-#define BRDIOCTL_DEEPSLEEP          (BRDIOCTL_PWRCONTROL + 0x0)
-#define BRDIOCTL_EMERGENCYSLEEP     (BRDIOCTL_PWRCONTROL + 0x1)
-#define BRDIOCTL_WAKEUP             (BRDIOCTL_PWRCONTROL + 0x2)
-#define BRDIOCTL_CLK_CTRL		    (BRDIOCTL_PWRCONTROL + 0x7)
-/* DSP Initiated Hibernate */
-#define BRDIOCTL_PWR_HIBERNATE	(BRDIOCTL_PWRCONTROL + 0x8)
-#define BRDIOCTL_PRESCALE_NOTIFY (BRDIOCTL_PWRCONTROL + 0x9)
-#define BRDIOCTL_POSTSCALE_NOTIFY (BRDIOCTL_PWRCONTROL + 0xA)
-#define BRDIOCTL_CONSTRAINT_REQUEST (BRDIOCTL_PWRCONTROL + 0xB)
-
-/* Number of actual DSP-MMU TLB entries */
-#define BRDIOCTL_NUMOFMMUTLB        32
-
-struct bridge_ioctl_extproc {
-	u32 dsp_va;		/* DSP virtual address */
-	u32 gpp_pa;		/* GPP physical address */
-	/* GPP virtual address. __va does not work for ioremapped addresses */
-	u32 gpp_va;
-	u32 size;		/* Size of the mapped memory in bytes */
-	enum hw_endianism_t endianism;
-	enum hw_mmu_mixed_size_t mixed_mode;
-	enum hw_element_size_t elem_size;
-};
-
-#endif /* DSPIOCTL_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dspmsg.h b/drivers/staging/tidspbridge/include/dspbridge/dspmsg.h
deleted file mode 100644
index d4bd458..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dspmsg.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * dspmsg.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Declares the upper edge message class library functions required by
- * all Bridge driver / DSP API interface tables.  These functions are
- * implemented by every class of Bridge driver channel library.
- *
- * Notes:
- *   Function comment headers reside in dspdefs.h.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef DSPMSG_
-#define DSPMSG_
-
-#include <dspbridge/msgdefs.h>
-
-extern int bridge_msg_create(struct msg_mgr **msg_man,
-				    struct dev_object *hdev_obj,
-				    msg_onexit msg_callback);
-
-extern int bridge_msg_create_queue(struct msg_mgr *hmsg_mgr,
-				       struct msg_queue **msgq,
-				       u32 msgq_id, u32 max_msgs, void *arg);
-
-extern void bridge_msg_delete(struct msg_mgr *hmsg_mgr);
-
-extern void bridge_msg_delete_queue(struct msg_queue *msg_queue_obj);
-
-extern int bridge_msg_get(struct msg_queue *msg_queue_obj,
-				 struct dsp_msg *pmsg, u32 utimeout);
-
-extern int bridge_msg_put(struct msg_queue *msg_queue_obj,
-				 const struct dsp_msg *pmsg, u32 utimeout);
-
-extern int bridge_msg_register_notify(struct msg_queue *msg_queue_obj,
-					  u32 event_mask,
-					  u32 notify_type,
-					  struct dsp_notification
-					  *hnotification);
-
-extern void bridge_msg_set_queue_id(struct msg_queue *msg_queue_obj,
-					u32 msgq_id);
-
-#endif /* DSPMSG_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dynamic_loader.h b/drivers/staging/tidspbridge/include/dspbridge/dynamic_loader.h
deleted file mode 100644
index 052d27e..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/dynamic_loader.h
+++ /dev/null
@@ -1,490 +0,0 @@
-/*
- * dynamic_loader.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _DYNAMIC_LOADER_H_
-#define _DYNAMIC_LOADER_H_
-#include <linux/kernel.h>
-#include <linux/types.h>
-
-/*
- * Dynamic Loader
- *
- * The function of the dynamic loader is to load a "module" containing
- * instructions for a "target" processor into that processor.  In the process
- * it assigns memory for the module, resolves symbol references made by the
- * module, and remembers symbols defined by the module.
- *
- * The dynamic loader is parameterized for a particular system by 4 classes
- * that supply the module and system specific functions it requires
- */
-	/* The read functions for the module image to be loaded */
-struct dynamic_loader_stream;
-
-	/* This class defines "host" symbol and support functions */
-struct dynamic_loader_sym;
-
-	/* This class defines the allocator for "target" memory */
-struct dynamic_loader_allocate;
-
-	/* This class defines the copy-into-target-memory functions */
-struct dynamic_loader_initialize;
-
-/*
- * Option flags to modify the behavior of module loading
- */
-#define DLOAD_INITBSS 0x1	/* initialize BSS sections to zero */
-
-/*****************************************************************************
- * Procedure dynamic_load_module
- *
- * Parameters:
- *  module  The input stream that supplies the module image
- *  syms    Host-side symbol table and malloc/free functions
- *  alloc   Target-side memory allocation
- *  init    Target-side memory initialization, or NULL for symbol read only
- *  options Option flags DLOAD_*
- *  mhandle A module handle for use with Dynamic_Unload
- *
- * Effect:
- *  The module image is read using *module.  Target storage for the new image is
- * obtained from *alloc.  Symbols defined and referenced by the module are
- * managed using *syms.  The image is then relocated and references resolved
- * as necessary, and the resulting executable bits are placed into target memory
- * using *init.
- *
- * Returns:
- *  On a successful load, a module handle is placed in *mhandle, and zero is
- * returned.  On error, the number of errors detected is returned.  Individual
- * errors are reported during the load process using syms->error_report().
- **************************************************************************** */
-extern int dynamic_load_module(
-				      /* the source for the module image */
-				      struct dynamic_loader_stream *module,
-				      /* host support for symbols and storage */
-				      struct dynamic_loader_sym *syms,
-				      /* the target memory allocator */
-				      struct dynamic_loader_allocate *alloc,
-				      /* the target memory initializer */
-				      struct dynamic_loader_initialize *init,
-				      unsigned options,	/* option flags */
-				      /* the returned module handle */
-				      void **mhandle);
-
-/*****************************************************************************
- * Procedure dynamic_open_module
- *
- * Parameters:
- *  module  The input stream that supplies the module image
- *  syms    Host-side symbol table and malloc/free functions
- *  alloc   Target-side memory allocation
- *  init    Target-side memory initialization, or NULL for symbol read only
- *  options Option flags DLOAD_*
- *  mhandle A module handle for use with Dynamic_Unload
- *
- * Effect:
- *  The module image is read using *module.  Target storage for the new image is
- * obtained from *alloc.  Symbols defined and referenced by the module are
- * managed using *syms.  The image is then relocated and references resolved
- * as necessary, and the resulting executable bits are placed into target memory
- * using *init.
- *
- * Returns:
- *  On a successful load, a module handle is placed in *mhandle, and zero is
- * returned.  On error, the number of errors detected is returned.  Individual
- * errors are reported during the load process using syms->error_report().
- **************************************************************************** */
-extern int dynamic_open_module(
-				      /* the source for the module image */
-				      struct dynamic_loader_stream *module,
-				      /* host support for symbols and storage */
-				      struct dynamic_loader_sym *syms,
-				      /* the target memory allocator */
-				      struct dynamic_loader_allocate *alloc,
-				      /* the target memory initializer */
-				      struct dynamic_loader_initialize *init,
-				      unsigned options,	/* option flags */
-				      /* the returned module handle */
-				      void **mhandle);
-
-/*****************************************************************************
- * Procedure dynamic_unload_module
- *
- * Parameters:
- *  mhandle A module handle from dynamic_load_module
- *  syms    Host-side symbol table and malloc/free functions
- *  alloc   Target-side memory allocation
- *
- * Effect:
- *  The module specified by mhandle is unloaded.  Unloading causes all
- * target memory to be deallocated, all symbols defined by the module to
- * be purged, and any host-side storage used by the dynamic loader for
- * this module to be released.
- *
- * Returns:
- *  Zero for success. On error, the number of errors detected is returned.
- * Individual errors are reported using syms->error_report().
- **************************************************************************** */
-extern int dynamic_unload_module(void *mhandle,	/* the module
-							 * handle */
-				 /* host support for symbols and
-				  * storage */
-				 struct dynamic_loader_sym *syms,
-				 /* the target memory allocator */
-				 struct dynamic_loader_allocate *alloc,
-				 /* the target memory initializer */
-				 struct dynamic_loader_initialize *init);
-
-/*****************************************************************************
- *****************************************************************************
- * A class used by the dynamic loader for input of the module image
- *****************************************************************************
- **************************************************************************** */
-struct dynamic_loader_stream {
-/* public: */
-    /*************************************************************************
-     * read_buffer
-     *
-     * PARAMETERS :
-     *  buffer  Pointer to the buffer to fill
-     *  bufsiz  Amount of data desired in sizeof() units
-     *
-     * EFFECT :
-     *  Reads the specified amount of data from the module input stream
-     * into the specified buffer.  Returns the amount of data read in sizeof()
-     * units (which if less than the specification, represents an error).
-     *
-     * NOTES:
-     *  In release 1 increments the file position by the number of bytes read
-     *
-     ************************************************************************ */
-	int (*read_buffer) (struct dynamic_loader_stream *thisptr,
-			    void *buffer, unsigned bufsiz);
-
-    /*************************************************************************
-     * set_file_posn (release 1 only)
-     *
-     * PARAMETERS :
-     *  posn  Desired file position relative to start of file in sizeof() units.
-     *
-     * EFFECT :
-     *  Adjusts the internal state of the stream object so that the next
-     * read_buffer call will begin to read at the specified offset from
-     * the beginning of the input module.  Returns 0 for success, non-zero
-     * for failure.
-     *
-     ************************************************************************ */
-	int (*set_file_posn) (struct dynamic_loader_stream *thisptr,
-			      /* to be eliminated in release 2 */
-			      unsigned int posn);
-
-};
-
-/*****************************************************************************
- *****************************************************************************
- * A class used by the dynamic loader for symbol table support and
- * miscellaneous host-side functions
- *****************************************************************************
- **************************************************************************** */
-
-typedef u32 ldr_addr;
-
-/*
- * the structure of a symbol known to the dynamic loader
- */
-struct dynload_symbol {
-	ldr_addr value;
-};
-
-struct dynamic_loader_sym {
-/* public: */
-    /*************************************************************************
-     * find_matching_symbol
-     *
-     * PARAMETERS :
-     *  name    The name of the desired symbol
-     *
-     * EFFECT :
-     *  Locates a symbol matching the name specified.  A pointer to the
-     * symbol is returned if it exists; 0 is returned if no such symbol is
-     * found.
-     *
-     ************************************************************************ */
-	struct dynload_symbol *(*find_matching_symbol)
-	 (struct dynamic_loader_sym *thisptr, const char *name);
-
-    /*************************************************************************
-     * add_to_symbol_table
-     *
-     * PARAMETERS :
-     *  nname       Pointer to the name of the new symbol
-     *  moduleid    An opaque module id assigned by the dynamic loader
-     *
-     * EFFECT :
-     *  The new symbol is added to the table.  A pointer to the symbol is
-     * returned, or NULL is returned for failure.
-     *
-     * NOTES:
-     *  It is permissible for this function to return NULL; the effect is that
-     * the named symbol will not be available to resolve references in
-     * subsequent loads.  Returning NULL will not cause the current load
-     * to fail.
-     ************************************************************************ */
-	struct dynload_symbol *(*add_to_symbol_table)
-	 (struct dynamic_loader_sym *
-	  thisptr, const char *nname, unsigned moduleid);
-
-    /*************************************************************************
-     * purge_symbol_table
-     *
-     * PARAMETERS :
-     *  moduleid    An opaque module id assigned by the dynamic loader
-     *
-     * EFFECT :
-     *  Each symbol in the symbol table whose moduleid matches the argument
-     * is removed from the table.
-     ************************************************************************ */
-	void (*purge_symbol_table) (struct dynamic_loader_sym *thisptr,
-				    unsigned moduleid);
-
-    /*************************************************************************
-     * dload_allocate
-     *
-     * PARAMETERS :
-     *  memsiz  size of desired memory in sizeof() units
-     *
-     * EFFECT :
-     *  Returns a pointer to some "host" memory for use by the dynamic
-     * loader, or NULL for failure.
-     * This function is serves as a replaceable form of "malloc" to
-     * allow the user to configure the memory usage of the dynamic loader.
-     ************************************************************************ */
-	void *(*dload_allocate) (struct dynamic_loader_sym *thisptr,
-				 unsigned memsiz);
-
-    /*************************************************************************
-     * dload_deallocate
-     *
-     * PARAMETERS :
-     *  memptr  pointer to previously allocated memory
-     *
-     * EFFECT :
-     *  Releases the previously allocated "host" memory.
-     ************************************************************************ */
-	void (*dload_deallocate) (struct dynamic_loader_sym *thisptr,
-				  void *memptr);
-
-    /*************************************************************************
-     * error_report
-     *
-     * PARAMETERS :
-     *  errstr  pointer to an error string
-     *  args    additional arguments
-     *
-     * EFFECT :
-     *  This function provides an error reporting interface for the dynamic
-     * loader.  The error string and arguments are designed as for the
-     * library function vprintf.
-     ************************************************************************ */
-	void (*error_report) (struct dynamic_loader_sym *thisptr,
-			      const char *errstr, va_list args);
-
-};				/* class dynamic_loader_sym */
-
-/*****************************************************************************
- *****************************************************************************
- * A class used by the dynamic loader to allocate and deallocate target memory.
- *****************************************************************************
- **************************************************************************** */
-
-struct ldr_section_info {
-	/* Name of the memory section assigned at build time */
-	const char *name;
-	ldr_addr run_addr;	/* execution address of the section */
-	ldr_addr load_addr;	/* load address of the section */
-	ldr_addr size;		/* size of the section in addressable units */
-#ifndef _BIG_ENDIAN
-	u16 page;		/* memory page or view */
-	u16 type;		/* one of the section types below */
-#else
-	u16 type;		/* one of the section types below */
-	u16 page;		/* memory page or view */
-#endif
-	/* a context field for use by dynamic_loader_allocate;
-	 *   ignored but maintained by the dynamic loader */
-	u32 context;
-};
-
-/* use this macro to extract type of section from ldr_section_info.type field */
-#define DLOAD_SECTION_TYPE(typeinfo) (typeinfo & 0xF)
-
-/* type of section to be allocated */
-#define DLOAD_TEXT 0
-#define DLOAD_DATA 1
-#define DLOAD_BSS 2
-	/* internal use only, run-time cinit will be of type DLOAD_DATA */
-#define DLOAD_CINIT 3
-
-struct dynamic_loader_allocate {
-/* public: */
-
-    /*************************************************************************
-    * Function allocate
-    *
-    * Parameters:
-    *   info        A pointer to an information block for the section
-    *   align       The alignment of the storage in target AUs
-    *
-    * Effect:
-    *   Allocates target memory for the specified section and fills in the
-    * load_addr and run_addr fields of the section info structure. Returns TRUE
-    * for success, FALSE for failure.
-    *
-    * Notes:
-    *   Frequently load_addr and run_addr are the same, but if they are not
-    * load_addr is used with dynamic_loader_initialize, and run_addr is
-    * used for almost all relocations.  This function should always initialize
-    * both fields.
-    ************************************************************************ */
-	int (*dload_allocate) (struct dynamic_loader_allocate *thisptr,
-			       struct ldr_section_info *info, unsigned align);
-
-    /*************************************************************************
-    * Function deallocate
-    *
-    * Parameters:
-    *   info        A pointer to an information block for the section
-    *
-    * Effect:
-    *   Releases the target memory previously allocated.
-    *
-    * Notes:
-    * The content of the info->name field is undefined on call to this function.
-    ************************************************************************ */
-	void (*dload_deallocate) (struct dynamic_loader_allocate *thisptr,
-				  struct ldr_section_info *info);
-
-};				/* class dynamic_loader_allocate */
-
-/*****************************************************************************
- *****************************************************************************
- * A class used by the dynamic loader to load data into a target.  This class
- * provides the interface-specific functions needed to load data.
- *****************************************************************************
- **************************************************************************** */
-
-struct dynamic_loader_initialize {
-/* public: */
-    /*************************************************************************
-    * Function connect
-    *
-    * Parameters:
-    *   none
-    *
-    * Effect:
-    *   Connect to the initialization interface. Returns TRUE for success,
-    * FALSE for failure.
-    *
-    * Notes:
-    *   This function is called prior to use of any other functions in
-    * this interface.
-    ************************************************************************ */
-	int (*connect) (struct dynamic_loader_initialize *thisptr);
-
-    /*************************************************************************
-    * Function readmem
-    *
-    * Parameters:
-    *   bufr        Pointer to a word-aligned buffer for the result
-    *   locn        Target address of first data element
-    *   info        Section info for the section in which the address resides
-    *   bytsiz      Size of the data to be read in sizeof() units
-    *
-    * Effect:
-    *   Fills the specified buffer with data from the target.  Returns TRUE for
-    * success, FALSE for failure.
-    ************************************************************************ */
-	int (*readmem) (struct dynamic_loader_initialize *thisptr,
-			void *bufr,
-			ldr_addr locn,
-			struct ldr_section_info *info, unsigned bytsiz);
-
-    /*************************************************************************
-    * Function writemem
-    *
-    * Parameters:
-    *   bufr        Pointer to a word-aligned buffer of data
-    *   locn        Target address of first data element to be written
-    *   info        Section info for the section in which the address resides
-    *   bytsiz      Size of the data to be written in sizeof() units
-    *
-    * Effect:
-    *   Writes the specified buffer to the target.  Returns TRUE for success,
-    * FALSE for failure.
-    ************************************************************************ */
-	int (*writemem) (struct dynamic_loader_initialize *thisptr,
-			 void *bufr,
-			 ldr_addr locn,
-			 struct ldr_section_info *info, unsigned bytsiz);
-
-    /*************************************************************************
-    * Function fillmem
-    *
-    * Parameters:
-    *   locn        Target address of first data element to be written
-    *   info        Section info for the section in which the address resides
-    *   bytsiz      Size of the data to be written in sizeof() units
-    *   val         Value to be written in each byte
-    * Effect:
-    *   Fills the specified area of target memory.  Returns TRUE for success,
-    * FALSE for failure.
-    ************************************************************************ */
-	int (*fillmem) (struct dynamic_loader_initialize *thisptr,
-			ldr_addr locn, struct ldr_section_info *info,
-			unsigned bytsiz, unsigned val);
-
-    /*************************************************************************
-    * Function execute
-    *
-    * Parameters:
-    *   start       Starting address
-    *
-    * Effect:
-    *   The target code at the specified starting address is executed.
-    *
-    * Notes:
-    *   This function is called at the end of the dynamic load process
-    * if the input module has specified a starting address.
-    ************************************************************************ */
-	int (*execute) (struct dynamic_loader_initialize *thisptr,
-			ldr_addr start);
-
-    /*************************************************************************
-    * Function release
-    *
-    * Parameters:
-    *   none
-    *
-    * Effect:
-    *   Releases the connection to the load interface.
-    *
-    * Notes:
-    *   This function is called at the end of the dynamic load process.
-    ************************************************************************ */
-	void (*release) (struct dynamic_loader_initialize *thisptr);
-
-};				/* class dynamic_loader_initialize */
-
-#endif /* _DYNAMIC_LOADER_H_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/getsection.h b/drivers/staging/tidspbridge/include/dspbridge/getsection.h
deleted file mode 100644
index 626063d..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/getsection.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * getsection.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * This file provides an API add-on to the dynamic loader that allows the user
- * to query section information and extract section data from dynamic load
- * modules.
- *
- * Notes:
- *   Functions in this API assume that the supplied dynamic_loader_stream
- *   object supports the set_file_posn method.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _GETSECTION_H_
-#define _GETSECTION_H_
-
-#include "dynamic_loader.h"
-
-/*
- * Procedure dload_module_open
- *
- * Parameters:
- *  module  The input stream that supplies the module image
- *  syms    Host-side malloc/free and error reporting functions.
- *          Other methods are unused.
- *
- * Effect:
- *  Reads header information from a dynamic loader module using the specified
- * stream object, and returns a handle for the module information.  This
- * handle may be used in subsequent query calls to obtain information
- * contained in the module.
- *
- * Returns:
- *  NULL if an error is encountered, otherwise a module handle for use
- * in subsequent operations.
- */
-extern void *dload_module_open(struct dynamic_loader_stream
-					   *module, struct dynamic_loader_sym
-					   *syms);
-
-/*
- * Procedure dload_get_section_info
- *
- * Parameters:
- *  minfo       Handle from dload_module_open for this module
- *  section_name Pointer to the string name of the section desired
- *  section_info Address of a section info structure pointer to be initialized
- *
- * Effect:
- *  Finds the specified section in the module information, and fills in
- * the provided ldr_section_info structure.
- *
- * Returns:
- *  TRUE for success, FALSE for section not found
- */
-extern int dload_get_section_info(void *minfo,
-				  const char *section_name,
-				  const struct ldr_section_info
-				  **const section_info);
-
-/*
- * Procedure dload_get_section
- *
- * Parameters:
- *  minfo       Handle from dload_module_open for this module
- *  section_info Pointer to a section info structure for the desired section
- *  section_data Buffer to contain the section initialized data
- *
- * Effect:
- *  Copies the initialized data for the specified section into the
- * supplied buffer.
- *
- * Returns:
- *  TRUE for success, FALSE for section not found
- */
-extern int dload_get_section(void *minfo,
-			     const struct ldr_section_info *section_info,
-			     void *section_data);
-
-/*
- * Procedure dload_module_close
- *
- * Parameters:
- *  minfo       Handle from dload_module_open for this module
- *
- * Effect:
- *  Releases any storage associated with the module handle.  On return,
- * the module handle is invalid.
- *
- * Returns:
- *  Zero for success. On error, the number of errors detected is returned.
- * Individual errors are reported using syms->error_report(), where syms was
- * an argument to dload_module_open
- */
-extern void dload_module_close(void *minfo);
-
-#endif /* _GETSECTION_H_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/gh.h b/drivers/staging/tidspbridge/include/dspbridge/gh.h
deleted file mode 100644
index e4303b4..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/gh.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * gh.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef GH_
-#define GH_
-#include <dspbridge/host_os.h>
-
-extern struct gh_t_hash_tab *gh_create(u32 val_size,
-	u32 (*hash)(const void *), bool (*match)(const void *,
-	const void *), void (*delete) (void *));
-extern void gh_delete(struct gh_t_hash_tab *hash_tab);
-extern void *gh_find(struct gh_t_hash_tab *hash_tab, const void *key);
-extern void *gh_insert(struct gh_t_hash_tab *hash_tab, const void *key,
-		       const void *value);
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-void gh_iterate(struct gh_t_hash_tab *hash_tab,
-	void (*callback)(void *, void *), void *user_data);
-#endif
-#endif /* GH_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/host_os.h b/drivers/staging/tidspbridge/include/dspbridge/host_os.h
deleted file mode 100644
index d1441db..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/host_os.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * host_os.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _HOST_OS_H_
-#define _HOST_OS_H_
-
-#include <linux/atomic.h>
-#include <linux/semaphore.h>
-#include <linux/uaccess.h>
-#include <linux/irq.h>
-#include <linux/io.h>
-#include <linux/syscalls.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/stddef.h>
-#include <linux/types.h>
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-#include <linux/sched.h>
-#include <linux/fs.h>
-#include <linux/file.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/ctype.h>
-#include <linux/mm.h>
-#include <linux/device.h>
-#include <linux/vmalloc.h>
-#include <linux/ioport.h>
-#include <linux/platform_device.h>
-#include <linux/clk.h>
-#include <linux/omap-mailbox.h>
-#include <linux/pagemap.h>
-#include <asm/cacheflush.h>
-#include <linux/dma-mapping.h>
-
-/* TODO -- Remove, once omap-iommu is used */
-#define INT_DSP_MMU_IRQ        (28 + NR_IRQS)
-
-#define PRCM_VDD1 1
-
-extern struct platform_device *omap_dspbridge_dev;
-extern struct device *bridge;
-
-#endif
diff --git a/drivers/staging/tidspbridge/include/dspbridge/io.h b/drivers/staging/tidspbridge/include/dspbridge/io.h
deleted file mode 100644
index 7505718..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/io.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * io.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * The io module manages IO between CHNL and msg_ctrl.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef IO_
-#define IO_
-
-#include <dspbridge/cfgdefs.h>
-#include <dspbridge/devdefs.h>
-
-/* IO Objects: */
-struct io_mgr;
-
-/* IO manager attributes: */
-struct io_attrs {
-	u8 birq;		/* Channel's I/O IRQ number. */
-	bool irq_shared;	/* TRUE if the IRQ is shareable. */
-	u32 word_size;		/* DSP Word size. */
-	u32 shm_base;		/* Physical base address of shared memory. */
-	u32 sm_length;		/* Size (in bytes) of shared memory. */
-};
-
-
-/*
- *  ======== io_create ========
- *  Purpose:
- *      Create an IO manager object, responsible for managing IO between
- *      CHNL and msg_ctrl.
- *  Parameters:
- *      channel_mgr:            Location to store a channel manager object on
- *                              output.
- *      hdev_obj:             Handle to a device object.
- *      mgr_attrts:              IO manager attributes.
- *      mgr_attrts->birq:        I/O IRQ number.
- *      mgr_attrts->irq_shared:     TRUE if the IRQ is shareable.
- *      mgr_attrts->word_size:   DSP Word size in equivalent PC bytes..
- *  Returns:
- *      0:                Success;
- *      -ENOMEM:            Insufficient memory for requested resources.
- *      -EIO:             Unable to plug channel ISR for configured IRQ.
- *      -EINVAL: Invalid DSP word size (must be > 0).
- *               Invalid base address for DSP communications.
- *  Requires:
- *      io_man != NULL.
- *      mgr_attrts != NULL.
- *  Ensures:
- */
-extern int io_create(struct io_mgr **io_man,
-			    struct dev_object *hdev_obj,
-			    const struct io_attrs *mgr_attrts);
-
-/*
- *  ======== io_destroy ========
- *  Purpose:
- *      Destroy the IO manager.
- *  Parameters:
- *      hio_mgr:         IOmanager object.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    hio_mgr was invalid.
- *  Requires:
- *  Ensures:
- */
-extern int io_destroy(struct io_mgr *hio_mgr);
-
-#endif /* CHNL_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/io_sm.h b/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
deleted file mode 100644
index 903ff12..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * io_sm.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * IO dispatcher for a shared memory channel driver.
- * Also, includes macros to simulate shm via port io calls.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef IOSM_
-#define IOSM_
-
-#include <dspbridge/_chnl_sm.h>
-#include <dspbridge/host_os.h>
-
-#include <dspbridge/io.h>
-#include <dspbridge/mbx_sh.h>	/* shared mailbox codes */
-
-/* Magic code used to determine if DSP signaled exception. */
-#define DEH_BASE        MBX_DEH_BASE
-#define DEH_LIMIT       MBX_DEH_LIMIT
-
-#define IO_INPUT            0
-#define IO_OUTPUT           1
-#define IO_SERVICE          2
-
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-/* The maximum number of OPPs that are supported */
-extern s32 dsp_max_opps;
-/* The Vdd1 opp table information */
-extern u32 vdd1_dsp_freq[6][4];
-#endif
-
-/*
- *  ======== io_cancel_chnl ========
- *  Purpose:
- *      Cancel IO on a given channel.
- *  Parameters:
- *      hio_mgr:     IO Manager.
- *      chnl:       Index of channel to cancel IO on.
- *  Returns:
- *  Requires:
- *      Valid hio_mgr.
- *  Ensures:
- */
-extern void io_cancel_chnl(struct io_mgr *hio_mgr, u32 chnl);
-
-/*
- *  ======== io_dpc ========
- *  Purpose:
- *      Deferred procedure call for shared memory channel driver ISR.  Carries
- *      out the dispatch of I/O.
- *  Parameters:
- *      ref_data:   Pointer to reference data registered via a call to
- *                  DPC_Create().
- *  Returns:
- *  Requires:
- *      Must not block.
- *      Must not acquire resources.
- *      All data touched must be locked in memory if running in kernel mode.
- *  Ensures:
- *      Non-preemptible (but interruptible).
- */
-extern void io_dpc(unsigned long ref_data);
-
-/*
- *  ======== io_mbox_msg ========
- *  Purpose:
- *	Main message handler for the shared memory Bridge channel manager.
- *	Determine if this message is ours, then schedules a DPC to
- *	dispatch I/O.
- *  Parameters:
- *	self:	Pointer to its own notifier_block struct.
- *	len:	Length of message.
- *	msg:	Message code received.
- *  Returns:
- *	NOTIFY_OK if handled; NOTIFY_BAD otherwise.
- */
-int io_mbox_msg(struct notifier_block *self, unsigned long len, void *msg);
-
-/*
- *  ======== io_request_chnl ========
- *  Purpose:
- *      Request I/O from the DSP. Sets flags in shared memory, then interrupts
- *      the DSP.
- *  Parameters:
- *      hio_mgr:     IO manager handle.
- *      pchnl:      Ptr to the channel requesting I/O.
- *      io_mode:      Mode of channel: {IO_INPUT | IO_OUTPUT}.
- *  Returns:
- *  Requires:
- *      pchnl != NULL
- *  Ensures:
- */
-extern void io_request_chnl(struct io_mgr *io_manager,
-			    struct chnl_object *pchnl,
-			    u8 io_mode, u16 *mbx_val);
-
-/*
- *  ======== iosm_schedule ========
- *  Purpose:
- *      Schedule DPC for IO.
- *  Parameters:
- *      pio_mgr:     Ptr to a I/O manager.
- *  Returns:
- *  Requires:
- *      pchnl != NULL
- *  Ensures:
- */
-extern void iosm_schedule(struct io_mgr *io_manager);
-
-/*
- *  ======== io_sh_msetting ========
- *  Purpose:
- *      Sets the shared memory setting
- *  Parameters:
- *      hio_mgr:         Handle to a I/O manager.
- *      desc:             Shared memory type
- *      pargs:          Ptr to shm setting
- *  Returns:
- *  Requires:
- *      hio_mgr != NULL
- *      pargs != NULL
- *  Ensures:
- */
-extern int io_sh_msetting(struct io_mgr *hio_mgr, u8 desc, void *pargs);
-
-/*
- *  Misc functions for the CHNL_IO shared memory library:
- */
-
-/* Maximum channel bufsize that can be used. */
-extern u32 io_buf_size(struct io_mgr *hio_mgr);
-
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-/*
- *  ========print_dsp_trace_buffer ========
- *      Print DSP tracebuffer.
- */
-extern int print_dsp_trace_buffer(struct bridge_dev_context
-					 *hbridge_context);
-
-int dump_dsp_stack(struct bridge_dev_context *bridge_context);
-
-void dump_dl_modules(struct bridge_dev_context *bridge_context);
-
-void print_dsp_debug_trace(struct io_mgr *hio_mgr);
-#endif
-
-#endif /* IOSM_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/mbx_sh.h b/drivers/staging/tidspbridge/include/dspbridge/mbx_sh.h
deleted file mode 100644
index d4cb394..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/mbx_sh.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * mbx_sh.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Definitions for shared mailbox cmd/data values.(used on both
- * the GPP and DSP sides).
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
- *  Bridge usage of OMAP mailbox 1 is determined by the "class" of the
- *  mailbox interrupt's cmd value received. The class value are defined
- *  as a bit (10 thru 15) being set.
- *
- *  Note: Only 16 bits of each is used. Other 16 bit data reg available.
- *
- *   16 bit Mbx bit defns:
- *
- * A). Exception/Error handling (Module DEH) : class = 0.
- *
- *    15         10                  0
- *   ---------------------------------
- *   |0|0|0|0|0|0|x|x|x|x|x|x|x|x|x|x|
- *   ---------------------------------
- *   |  (class)  | (module specific) |
- *
- *
- * B: DSP-DMA link driver channels (DDMA) : class = 1.
- *
- *    15         10                  0
- *   ---------------------------------
- *   |0|0|0|0|0|1|b|b|b|b|b|c|c|c|c|c|
- *   ---------------------------------
- *   |  (class)  | (module specific) |
- *
- *   where b -> buffer index  (32 DDMA buffers/chnl max)
- *         c -> channel Id    (32 DDMA chnls max)
- *
- *
- * C: Proc-copy link driver channels (PCPY) : class = 2.
- *
- *    15         10                  0
- *   ---------------------------------
- *   |0|0|0|0|1|0|x|x|x|x|x|x|x|x|x|x|
- *   ---------------------------------
- *   |  (class)  | (module specific) |
- *
- *
- * D: Zero-copy link driver channels (DDZC) : class = 4.
- *
- *    15         10                  0
- *   ---------------------------------
- *   |0|0|0|1|0|0|x|x|x|x|x|c|c|c|c|c|
- *   ---------------------------------
- *   |  (class)  | (module specific) |
- *
- *   where x -> not used
- *         c -> channel Id    (32 ZCPY chnls max)
- *
- *
- * E: Power management : class = 8.
- *
- *    15         10                  0
- *   ---------------------------------
- *   |0|0|1|0|0|0|x|x|x|x|x|c|c|c|c|c|
-
- * 	0010 00xx xxxc cccc
- *	0010 00nn pppp qqqq
- *	nn:
- *	00 = reserved
- *	01 = pwr state change
- *	10 = opp pre-change
- *	11 = opp post-change
- *
- *	if nn = pwr state change:
- *	pppp = don't care
- *	qqqq:
- *	0010 = hibernate
- *	0010 0001 0000 0010
- *	0110 = retention
- *	0010 0001 0000 0110
- *	others reserved
- *
- *	if nn = opp pre-change:
- *	pppp = current opp
- *	qqqq = next opp
- *
- *	if nn = opp post-change:
- *	pppp = prev opp
- *	qqqq = current opp
- *
- *   ---------------------------------
- *   |  (class)  | (module specific) |
- *
- *   where x -> not used
- *         c -> Power management command
- *
- */
-
-#ifndef _MBX_SH_H
-#define _MBX_SH_H
-
-#define MBX_PCPY_CLASS     0x0800	/* PROC-COPY  " */
-#define MBX_PM_CLASS       0x2000	/* Power Management */
-#define MBX_DBG_CLASS      0x4000	/* For debugging purpose */
-
-/*
- * Exception Handler codes
- * Magic code used to determine if DSP signaled exception.
- */
-#define MBX_DEH_BASE        0x0
-#define MBX_DEH_USERS_BASE  0x100	/* 256 */
-#define MBX_DEH_LIMIT       0x3FF	/* 1023 */
-#define MBX_DEH_RESET       0x101	/* DSP RESET (DEH) */
-
-/*
- *  Link driver command/status codes.
- */
-
-/*  Power Management Commands */
-#define MBX_PM_DSPIDLE                  (MBX_PM_CLASS + 0x0)
-#define MBX_PM_DSPWAKEUP                (MBX_PM_CLASS + 0x1)
-#define MBX_PM_EMERGENCYSLEEP           (MBX_PM_CLASS + 0x2)
-#define MBX_PM_SETPOINT_PRENOTIFY       (MBX_PM_CLASS + 0x6)
-#define MBX_PM_SETPOINT_POSTNOTIFY      (MBX_PM_CLASS + 0x7)
-#define MBX_PM_DSPRETENTION        (MBX_PM_CLASS + 0x8)
-#define MBX_PM_DSPHIBERNATE        (MBX_PM_CLASS + 0x9)
-#define MBX_PM_HIBERNATE_EN        (MBX_PM_CLASS + 0xA)
-#define MBX_PM_OPP_REQ                  (MBX_PM_CLASS + 0xB)
-
-/* Bridge Debug Commands */
-#define MBX_DBG_SYSPRINTF       (MBX_DBG_CLASS + 0x0)
-
-#endif /* _MBX_SH_H */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/memdefs.h b/drivers/staging/tidspbridge/include/dspbridge/memdefs.h
deleted file mode 100644
index 78d2c5d..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/memdefs.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * memdefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global MEM constants and types, shared between Bridge driver and DSP API.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef MEMDEFS_
-#define MEMDEFS_
-
-/*
- *  MEM_VIRTUALSEGID is used by Node & Strm to access virtual address space in
- *  the correct client process context.
- */
-#define MEM_SETVIRTUALSEGID     0x10000000
-#define MEM_GETVIRTUALSEGID     0x20000000
-#define MEM_MASKVIRTUALSEGID    (MEM_SETVIRTUALSEGID | MEM_GETVIRTUALSEGID)
-
-#endif /* MEMDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/mgr.h b/drivers/staging/tidspbridge/include/dspbridge/mgr.h
deleted file mode 100644
index 47b0318..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/mgr.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * mgr.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * This is the DSP API RM module interface.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef MGR_
-#define MGR_
-
-#include <dspbridge/mgrpriv.h>
-
-#define MAX_EVENTS 32
-
-/*
- *  ======== mgr_wait_for_bridge_events ========
- *  Purpose:
- *      Block on any Bridge event(s)
- *  Parameters:
- *      anotifications  : array of pointers to notification objects.
- *      count          : number of elements in above array
- *      pu_index         : index of signaled event object
- *      utimeout        : timeout interval in milliseocnds
- *  Returns:
- *      0         : Success.
- *      -ETIME    : Wait timed out. *pu_index is undetermined.
- *  Details:
- */
-
-int mgr_wait_for_bridge_events(struct dsp_notification
-				      **anotifications,
-				      u32 count, u32 *pu_index,
-				      u32 utimeout);
-
-/*
- *  ======== mgr_create ========
- *  Purpose:
- *      Creates the Manager Object. This is done during the driver loading.
- *      There is only one Manager Object in the DSP/BIOS Bridge.
- *  Parameters:
- *      mgr_obj:        Location to store created MGR Object handle.
- *      dev_node_obj:       Device object as known to the system.
- *  Returns:
- *      0:        Success
- *      -ENOMEM:    Failed to Create the Object
- *      -EPERM:      General Failure
- *  Requires:
- *      MGR Initialized (refs > 0 )
- *      mgr_obj != NULL.
- *  Ensures:
- *      0:        *mgr_obj is a valid MGR interface to the device.
- *                      MGR Object stores the DCD Manager Handle.
- *                      MGR Object stored in the Regsitry.
- *      !0:       MGR Object not created
- *  Details:
- *      DCD Dll is loaded and MGR Object stores the handle of the DLL.
- */
-extern int mgr_create(struct mgr_object **mgr_obj,
-			     struct cfg_devnode *dev_node_obj);
-
-/*
- *  ======== mgr_destroy ========
- *  Purpose:
- *      Destroys the MGR object. Called upon driver unloading.
- *  Parameters:
- *      hmgr_obj:     Handle to Manager object .
- *  Returns:
- *      0:        Success.
- *                      DCD Manager freed; MGR Object destroyed;
- *                      MGR Object deleted from the Registry.
- *      -EPERM:      Failed to destroy MGR Object
- *  Requires:
- *      MGR Initialized (refs > 0 )
- *      hmgr_obj is a valid MGR handle .
- *  Ensures:
- *      0:        MGR Object destroyed and hmgr_obj is Invalid MGR
- *                      Handle.
- */
-extern int mgr_destroy(struct mgr_object *hmgr_obj);
-
-/*
- *  ======== mgr_enum_node_info ========
- *  Purpose:
- *      Enumerate and get configuration information about nodes configured
- *      in the node database.
- *  Parameters:
- *      node_id:              The node index (base 0).
- *      pndb_props:          Ptr to the dsp_ndbprops structure for output.
- *      undb_props_size:      Size of the dsp_ndbprops structure.
- *      pu_num_nodes:         Location where the number of nodes configured
- *                          in the database will be returned.
- *  Returns:
- *      0:            Success.
- *      -EINVAL:    Parameter node_id is > than the number of nodes.
- *                          configutred in the system
- *      -EIDRM:  During Enumeration there has been a change in
- *                              the number of nodes configured or in the
- *                              the properties of the enumerated nodes.
- *      -EPERM:          Failed to querry the Node Data Base
- *  Requires:
- *      pNDBPROPS is not null
- *      undb_props_size >= sizeof(dsp_ndbprops)
- *      pu_num_nodes is not null
- *      MGR Initialized (refs > 0 )
- *  Ensures:
- *      SUCCESS on successful retreival of data and *pu_num_nodes > 0 OR
- *      DSP_FAILED  && *pu_num_nodes == 0.
- *  Details:
- */
-extern int mgr_enum_node_info(u32 node_id,
-				     struct dsp_ndbprops *pndb_props,
-				     u32 undb_props_size,
-				     u32 *pu_num_nodes);
-
-/*
- *  ======== mgr_enum_processor_info ========
- *  Purpose:
- *      Enumerate and get configuration information about available DSP
- *      processors
- *  Parameters:
- *      processor_id:         The processor index (zero-based).
- *      processor_info:     Ptr to the dsp_processorinfo structure .
- *      processor_info_size: Size of dsp_processorinfo structure.
- *      pu_num_procs:         Location where the number of DSPs configured
- *                          in the database will be returned
- *  Returns:
- *      0:            Success.
- *      -EINVAL:    Parameter processor_id is > than the number of
- *                          DSP Processors in the system.
- *      -EPERM:          Failed to querry the Node Data Base
- *  Requires:
- *      processor_info is not null
- *      pu_num_procs is not null
- *      processor_info_size >= sizeof(dsp_processorinfo)
- *      MGR Initialized (refs > 0 )
- *  Ensures:
- *      SUCCESS on successful retreival of data and *pu_num_procs > 0 OR
- *      DSP_FAILED && *pu_num_procs == 0.
- *  Details:
- */
-extern int mgr_enum_processor_info(u32 processor_id,
-					  struct dsp_processorinfo
-					  *processor_info,
-					  u32 processor_info_size,
-					  u8 *pu_num_procs);
-/*
- *  ======== mgr_exit ========
- *  Purpose:
- *      Decrement reference count, and free resources when reference count is
- *      0.
- *  Parameters:
- *  Returns:
- *  Requires:
- *      MGR is initialized.
- *  Ensures:
- *      When reference count == 0, MGR's private resources are freed.
- */
-extern void mgr_exit(void);
-
-/*
- *  ======== mgr_get_dcd_handle ========
- *  Purpose:
- *      Retrieves the MGR handle. Accessor Function
- *  Parameters:
- *      mgr_handle:     Handle to the Manager Object
- *      dcd_handle:     Ptr to receive the DCD Handle.
- *  Returns:
- *      0:        Success
- *      -EPERM:      Failure to get the Handle
- *  Requires:
- *      MGR is initialized.
- *      dcd_handle != NULL
- *  Ensures:
- *      0 and *dcd_handle != NULL ||
- *      -EPERM and *dcd_handle == NULL
- */
-extern int mgr_get_dcd_handle(struct mgr_object
-				     *mgr_handle, u32 *dcd_handle);
-
-/*
- *  ======== mgr_init ========
- *  Purpose:
- *      Initialize MGR's private state, keeping a reference count on each
- *      call. Initializes the DCD.
- *  Parameters:
- *  Returns:
- *      TRUE if initialized; FALSE if error occurred.
- *  Requires:
- *  Ensures:
- *      TRUE: A requirement for the other public MGR functions.
- */
-extern bool mgr_init(void);
-
-#endif /* MGR_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/mgrpriv.h b/drivers/staging/tidspbridge/include/dspbridge/mgrpriv.h
deleted file mode 100644
index 3a4e337..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/mgrpriv.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * mgrpriv.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global MGR constants and types, shared by PROC, MGR, and DSP API.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef MGRPRIV_
-#define MGRPRIV_
-
-/*
- * OMAP1510 specific
- */
-#define MGR_MAXTLBENTRIES  32
-
-/* RM MGR Object */
-struct mgr_object;
-
-struct mgr_tlbentry {
-	u32 dsp_virt;	/* DSP virtual address */
-	u32 gpp_phys;	/* GPP physical address */
-};
-
-/*
- *  The DSP_PROCESSOREXTINFO structure describes additional extended
- *  capabilities of a DSP processor not exposed to user.
- */
-struct mgr_processorextinfo {
-	struct dsp_processorinfo ty_basic;	/* user processor info */
-	/* private dsp mmu entries */
-	struct mgr_tlbentry ty_tlb[MGR_MAXTLBENTRIES];
-};
-
-#endif /* MGRPRIV_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/msg.h b/drivers/staging/tidspbridge/include/dspbridge/msg.h
deleted file mode 100644
index 2c8712c..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/msg.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * msg.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP/BIOS Bridge msg_ctrl Module.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef MSG_
-#define MSG_
-
-#include <dspbridge/devdefs.h>
-#include <dspbridge/msgdefs.h>
-
-/*
- *  ======== msg_create ========
- *  Purpose:
- *      Create an object to manage message queues. Only one of these objects
- *      can exist per device object. The msg_ctrl manager must be created before
- *      the IO Manager.
- *  Parameters:
- *      msg_man:            Location to store msg_ctrl manager handle on output.
- *      hdev_obj:         The device object.
- *      msg_callback:        Called whenever an RMS_EXIT message is received.
- *  Returns:
- *  Requires:
- *      msg_man != NULL.
- *      hdev_obj != NULL.
- *      msg_callback != NULL.
- *  Ensures:
- */
-extern int msg_create(struct msg_mgr **msg_man,
-			     struct dev_object *hdev_obj,
-			     msg_onexit msg_callback);
-
-/*
- *  ======== msg_delete ========
- *  Purpose:
- *      Delete a msg_ctrl manager allocated in msg_create().
- *  Parameters:
- *      hmsg_mgr:            Handle returned from msg_create().
- *  Returns:
- *  Requires:
- *      Valid hmsg_mgr.
- *  Ensures:
- */
-extern void msg_delete(struct msg_mgr *hmsg_mgr);
-
-#endif /* MSG_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/msgdefs.h b/drivers/staging/tidspbridge/include/dspbridge/msgdefs.h
deleted file mode 100644
index 80a3fa1..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/msgdefs.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * msgdefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global msg_ctrl constants and types.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef MSGDEFS_
-#define MSGDEFS_
-
-/* msg_ctrl Objects: */
-struct msg_mgr;
-struct msg_queue;
-
-/* Function prototype for callback to be called on RMS_EXIT message received */
-typedef void (*msg_onexit) (void *h, s32 node_status);
-
-#endif /* MSGDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/nldr.h b/drivers/staging/tidspbridge/include/dspbridge/nldr.h
deleted file mode 100644
index c5e48ca..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/nldr.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * nldr.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP/BIOS Bridge dynamic loader interface.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/dbdcddef.h>
-#include <dspbridge/dev.h>
-#include <dspbridge/rmm.h>
-#include <dspbridge/nldrdefs.h>
-
-#ifndef NLDR_
-#define NLDR_
-
-extern int nldr_allocate(struct nldr_object *nldr_obj,
-				void *priv_ref, const struct dcd_nodeprops
-				*node_props,
-				struct nldr_nodeobject **nldr_nodeobj,
-				bool *pf_phase_split);
-
-extern int nldr_create(struct nldr_object **nldr,
-			      struct dev_object *hdev_obj,
-			      const struct nldr_attrs *pattrs);
-
-extern void nldr_delete(struct nldr_object *nldr_obj);
-
-extern int nldr_get_fxn_addr(struct nldr_nodeobject *nldr_node_obj,
-				    char *str_fxn, u32 * addr);
-
-extern int nldr_get_rmm_manager(struct nldr_object *nldr,
-				       struct rmm_target_obj **rmm_mgr);
-
-extern int nldr_load(struct nldr_nodeobject *nldr_node_obj,
-			    enum nldr_phase phase);
-extern int nldr_unload(struct nldr_nodeobject *nldr_node_obj,
-			      enum nldr_phase phase);
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-int nldr_find_addr(struct nldr_nodeobject *nldr_node, u32 sym_addr,
-	u32 offset_range, void *offset_output, char *sym_name);
-#endif
-
-#endif /* NLDR_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/nldrdefs.h b/drivers/staging/tidspbridge/include/dspbridge/nldrdefs.h
deleted file mode 100644
index 7e3c7f5..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/nldrdefs.h
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * nldrdefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global Dynamic + static/overlay Node loader (NLDR) constants and types.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef NLDRDEFS_
-#define NLDRDEFS_
-
-#include <dspbridge/dbdcddef.h>
-#include <dspbridge/devdefs.h>
-
-#define NLDR_MAXPATHLENGTH       255
-/* NLDR Objects: */
-struct nldr_object;
-struct nldr_nodeobject;
-
-/*
- *  ======== nldr_loadtype ========
- *  Load types for a node. Must match values in node.h55.
- */
-enum nldr_loadtype {
-	NLDR_STATICLOAD,	/* Linked in base image, not overlay */
-	NLDR_DYNAMICLOAD,	/* Dynamically loaded node */
-	NLDR_OVLYLOAD		/* Linked in base image, overlay node */
-};
-
-/*
- *  ======== nldr_ovlyfxn ========
- *  Causes code or data to be copied from load address to run address. This
- *  is the "cod_writefxn" that gets passed to the DBLL_Library and is used as
- *  the ZL write function.
- *
- *  Parameters:
- *      priv_ref:       Handle to identify the node.
- *      dsp_run_addr:   Run address of code or data.
- *      dsp_load_addr:  Load address of code or data.
- *      ul_num_bytes:     Number of (GPP) bytes to copy.
- *      mem_space:      RMS_CODE or RMS_DATA.
- *  Returns:
- *      ul_num_bytes:     Success.
- *      0:              Failure.
- *  Requires:
- *  Ensures:
- */
-typedef u32(*nldr_ovlyfxn) (void *priv_ref, u32 dsp_run_addr,
-			    u32 dsp_load_addr, u32 ul_num_bytes, u32 mem_space);
-
-/*
- *  ======== nldr_writefxn ========
- *  Write memory function. Used for dynamic load writes.
- *  Parameters:
- *      priv_ref:       Handle to identify the node.
- *      dsp_add:        Address of code or data.
- *      pbuf:           Code or data to be written
- *      ul_num_bytes:     Number of (GPP) bytes to write.
- *      mem_space:      DBLL_DATA or DBLL_CODE.
- *  Returns:
- *      ul_num_bytes:     Success.
- *      0:              Failure.
- *  Requires:
- *  Ensures:
- */
-typedef u32(*nldr_writefxn) (void *priv_ref,
-			     u32 dsp_add, void *pbuf,
-			     u32 ul_num_bytes, u32 mem_space);
-
-/*
- *  ======== nldr_attrs ========
- *  Attributes passed to nldr_create function.
- */
-struct nldr_attrs {
-	nldr_ovlyfxn ovly;
-	nldr_writefxn write;
-	u16 dsp_word_size;
-	u16 dsp_mau_size;
-};
-
-/*
- *  ======== nldr_phase ========
- *  Indicates node create, delete, or execute phase function.
- */
-enum nldr_phase {
-	NLDR_CREATE,
-	NLDR_DELETE,
-	NLDR_EXECUTE,
-	NLDR_NOPHASE
-};
-
-/*
- *  Typedefs of loader functions imported from a DLL, or defined in a
- *  function table.
- */
-
-/*
- *  ======== nldr_allocate ========
- *  Allocate resources to manage the loading of a node on the DSP.
- *
- *  Parameters:
- *      nldr_obj:          Handle of loader that will load the node.
- *      priv_ref:       Handle to identify the node.
- *      node_props:     Pointer to a dcd_nodeprops for the node.
- *      nldr_nodeobj:   Location to store node handle on output. This handle
- *                      will be passed to nldr_load/nldr_unload.
- *      pf_phase_split:   pointer to int variable referenced in node.c
- *  Returns:
- *      0:        Success.
- *      -ENOMEM:    Insufficient memory on GPP.
- *  Requires:
- *      Valid nldr_obj.
- *      node_props != NULL.
- *      nldr_nodeobj != NULL.
- *  Ensures:
- *      0:        IsValidNode(*nldr_nodeobj).
- *      error:          *nldr_nodeobj == NULL.
- */
-typedef int(*nldr_allocatefxn) (struct nldr_object *nldr_obj,
-				       void *priv_ref,
-				       const struct dcd_nodeprops
-				       * node_props,
-				       struct nldr_nodeobject
-				       **nldr_nodeobj,
-				       bool *pf_phase_split);
-
-/*
- *  ======== nldr_create ========
- *  Create a loader object. This object handles the loading and unloading of
- *  create, delete, and execute phase functions of nodes on the DSP target.
- *
- *  Parameters:
- *      nldr:           Location to store loader handle on output.
- *      hdev_obj:     Device for this processor.
- *      pattrs:         Loader attributes.
- *  Returns:
- *      0:        Success;
- *      -ENOMEM:    Insufficient memory for requested resources.
- *  Requires:
- *      nldr != NULL.
- *      hdev_obj != NULL.
- *	pattrs != NULL.
- *  Ensures:
- *      0:        Valid *nldr.
- *      error:          *nldr == NULL.
- */
-typedef int(*nldr_createfxn) (struct nldr_object **nldr,
-				     struct dev_object *hdev_obj,
-				     const struct nldr_attrs *pattrs);
-
-/*
- *  ======== nldr_delete ========
- *  Delete the NLDR loader.
- *
- *  Parameters:
- *      nldr_obj:          Node manager object.
- *  Returns:
- *  Requires:
- *      Valid nldr_obj.
- *  Ensures:
- *	nldr_obj invalid
- */
-typedef void (*nldr_deletefxn) (struct nldr_object *nldr_obj);
-
-/*
- *  ======== NLDR_Free ========
- *  Free resources allocated in nldr_allocate.
- *
- *  Parameters:
- *      nldr_node_obj:      Handle returned from nldr_allocate().
- *  Returns:
- *  Requires:
- *      Valid nldr_node_obj.
- *  Ensures:
- */
-typedef void (*nldr_freefxn) (struct nldr_nodeobject *nldr_node_obj);
-
-/*
- *  ======== nldr_get_fxn_addr ========
- *  Get address of create, delete, or execute phase function of a node on
- *  the DSP.
- *
- *  Parameters:
- *      nldr_node_obj:      Handle returned from nldr_allocate().
- *      str_fxn:        Name of function.
- *      addr:           Location to store function address.
- *  Returns:
- *      0:        Success.
- *      -ESPIPE:    Address of function not found.
- *  Requires:
- *      Valid nldr_node_obj.
- *      addr != NULL;
- *      str_fxn != NULL;
- *  Ensures:
- */
-typedef int(*nldr_getfxnaddrfxn) (struct nldr_nodeobject
-					 * nldr_node_obj,
-					 char *str_fxn, u32 * addr);
-
-/*
- *  ======== nldr_load ========
- *  Load create, delete, or execute phase function of a node on the DSP.
- *
- *  Parameters:
- *      nldr_node_obj:      Handle returned from nldr_allocate().
- *      phase:          Type of function to load (create, delete, or execute).
- *  Returns:
- *      0:                Success.
- *      -ENOMEM:            Insufficient memory on GPP.
- *      -ENXIO:     Can't overlay phase because overlay memory
- *                              is already in use.
- *      -EILSEQ:           Failure in dynamic loader library.
- *  Requires:
- *      Valid nldr_node_obj.
- *  Ensures:
- */
-typedef int(*nldr_loadfxn) (struct nldr_nodeobject *nldr_node_obj,
-				   enum nldr_phase phase);
-
-/*
- *  ======== nldr_unload ========
- *  Unload create, delete, or execute phase function of a node on the DSP.
- *
- *  Parameters:
- *      nldr_node_obj:      Handle returned from nldr_allocate().
- *      phase:          Node function to unload (create, delete, or execute).
- *  Returns:
- *      0:        Success.
- *      -ENOMEM:    Insufficient memory on GPP.
- *  Requires:
- *      Valid nldr_node_obj.
- *  Ensures:
- */
-typedef int(*nldr_unloadfxn) (struct nldr_nodeobject *nldr_node_obj,
-				     enum nldr_phase phase);
-
-/*
- *  ======== node_ldr_fxns ========
- */
-struct node_ldr_fxns {
-	nldr_allocatefxn allocate;
-	nldr_createfxn create;
-	nldr_deletefxn delete;
-	nldr_getfxnaddrfxn get_fxn_addr;
-	nldr_loadfxn load;
-	nldr_unloadfxn unload;
-};
-
-#endif /* NLDRDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/node.h b/drivers/staging/tidspbridge/include/dspbridge/node.h
deleted file mode 100644
index 68ed74a..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/node.h
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * node.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP/BIOS Bridge Node Manager.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef NODE_
-#define NODE_
-
-#include <dspbridge/procpriv.h>
-
-#include <dspbridge/nodedefs.h>
-#include <dspbridge/disp.h>
-#include <dspbridge/nldrdefs.h>
-#include <dspbridge/drv.h>
-
-/*
- *  ======== node_allocate ========
- *  Purpose:
- *      Allocate GPP resources to manage a node on the DSP.
- *  Parameters:
- *      hprocessor:         Handle of processor that is allocating the node.
- *      node_uuid:          Pointer to a dsp_uuid for the node.
- *      pargs:              Optional arguments to be passed to the node.
- *      attr_in:            Optional pointer to node attributes (priority,
- *                          timeout...)
- *      noderes:             Location to store node resource info.
- *  Returns:
- *      0:            Success.
- *      -ENOMEM:        Insufficient memory on GPP.
- *      -ENOKEY:          Node UUID has not been registered.
- *      -ESPIPE:        iAlg functions not found for a DAIS node.
- *      -EDOM:         attr_in != NULL and attr_in->prio out of
- *                          range.
- *      -EPERM:          A failure occurred, unable to allocate node.
- *      -EBADR:    Proccessor is not in the running state.
- *  Requires:
- *      hprocessor != NULL.
- *      node_uuid != NULL.
- *      noderes != NULL.
- *  Ensures:
- *      0:            IsValidNode(*ph_node).
- *      error:              *noderes == NULL.
- */
-extern int node_allocate(struct proc_object *hprocessor,
-				const struct dsp_uuid *node_uuid,
-				const struct dsp_cbdata
-				*pargs, const struct dsp_nodeattrin
-				*attr_in,
-				struct node_res_object **noderes,
-				struct process_context *pr_ctxt);
-
-/*
- *  ======== node_alloc_msg_buf ========
- *  Purpose:
- *      Allocate and Prepare a buffer whose descriptor will be passed to a
- *      Node within a (dsp_msg)message
- *  Parameters:
- *      hnode:          The node handle.
- *      usize:          The size of the buffer to be allocated.
- *      pattr:          Pointer to a dsp_bufferattr structure.
- *      pbuffer:        Location to store the address of the allocated
- *                      buffer on output.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid node handle.
- *      -ENOMEM:    Insufficent memory.
- *      -EPERM:      General Failure.
- *      -EINVAL:      Invalid Size.
- *  Requires:
- *      pbuffer != NULL.
- *  Ensures:
- */
-extern int node_alloc_msg_buf(struct node_object *hnode,
-				     u32 usize, struct dsp_bufferattr
-				     *pattr, u8 **pbuffer);
-
-/*
- *  ======== node_change_priority ========
- *  Purpose:
- *      Change the priority of an allocated node.
- *  Parameters:
- *      hnode:              Node handle returned from node_allocate.
- *      prio:          New priority level to set node's priority to.
- *  Returns:
- *      0:            Success.
- *      -EFAULT:        Invalid hnode.
- *      -EDOM:         prio is out of range.
- *      -EPERM: The specified node is not a task node.
- *              Unable to change node's runtime priority level.
- *      -EBADR:    Node is not in the NODE_ALLOCATED, NODE_PAUSED,
- *                          or NODE_RUNNING state.
- *      -ETIME:       A timeout occurred before the DSP responded.
- *  Requires:
- *  Ensures:
- *      0 && (Node's current priority == prio)
- */
-extern int node_change_priority(struct node_object *hnode, s32 prio);
-
-/*
- *  ======== node_connect ========
- *  Purpose:
- *      Connect two nodes on the DSP, or a node on the DSP to the GPP. In the
- *      case that the connection is being made between a node on the DSP and
- *      the GPP, one of the node handles (either node1 or node2) must be
- *      the constant NODE_HGPPNODE.
- *  Parameters:
- *      node1:         Handle of first node to connect to second node. If
- *                      this is a connection from the GPP to node2, node1
- *                      must be the constant NODE_HGPPNODE. Otherwise, node1
- *                      must be a node handle returned from a successful call
- *                      to Node_Allocate().
- *      node2:         Handle of second node. Must be either NODE_HGPPNODE
- *                      if this is a connection from DSP node to GPP, or a
- *                      node handle returned from a successful call to
- *                      node_allocate().
- *      stream1:        Output stream index on first node, to be connected
- *                      to second node's input stream. Value must range from
- *                      0 <= stream1 < number of output streams.
- *      stream2:        Input stream index on second node. Value must range
- *                      from 0 <= stream2 < number of input streams.
- *      pattrs:         Stream attributes (NULL ==> use defaults).
- *      conn_param:     A pointer to a dsp_cbdata structure that defines
- *                      connection parameter for device nodes to pass to DSP
- *                      side.
- *                      If the value of this parameter is NULL, then this API
- *                      behaves like DSPNode_Connect. This parameter will have
- *                      length of the string and the null terminated string in
- *                      dsp_cbdata struct. This can be extended in future tp
- *                      pass binary data.
- *  Returns:
- *      0:                Success.
- *      -EFAULT:            Invalid node1 or node2.
- *      -ENOMEM:            Insufficient host memory.
- *      -EINVAL:             A stream index parameter is invalid.
- *      -EISCONN:  A connection already exists for one of the
- *                              indices stream1 or stream2.
- *      -EBADR:        Either node1 or node2 is not in the
- *                              NODE_ALLOCATED state.
- *      -ECONNREFUSED: No more connections available.
- *      -EPERM:              Attempt to make an illegal connection (eg,
- *                              Device node to device node, or device node to
- *                              GPP), the two nodes are on different DSPs.
- *  Requires:
- *  Ensures:
- */
-extern int node_connect(struct node_object *node1,
-			       u32 stream1,
-			       struct node_object *node2,
-			       u32 stream2,
-			       struct dsp_strmattr *pattrs,
-			       struct dsp_cbdata
-			       *conn_param);
-
-/*
- *  ======== node_create ========
- *  Purpose:
- *      Create a node on the DSP by remotely calling the node's create
- *      function. If necessary, load code that contains the node's create
- *      function.
- *  Parameters:
- *      hnode:              Node handle returned from node_allocate().
- *  Returns:
- *      0:            Success.
- *      -EFAULT:        Invalid hnode.
- *      -ESPIPE:        Create function not found in the COFF file.
- *      -EBADR:    Node is not in the NODE_ALLOCATED state.
- *      -ENOMEM:        Memory allocation failure on the DSP.
- *      -ETIME:       A timeout occurred before the DSP responded.
- *      -EPERM:          A failure occurred, unable to create node.
- *  Requires:
- *  Ensures:
- */
-extern int node_create(struct node_object *hnode);
-
-/*
- *  ======== node_create_mgr ========
- *  Purpose:
- *      Create a NODE Manager object. This object handles the creation,
- *      deletion, and execution of nodes on the DSP target. The NODE Manager
- *      also maintains a pipe map of used and available node connections.
- *      Each DEV object should have exactly one NODE Manager object.
- *
- *  Parameters:
- *      node_man:       Location to store node manager handle on output.
- *      hdev_obj:     Device for this processor.
- *  Returns:
- *      0:        Success;
- *      -ENOMEM:    Insufficient memory for requested resources.
- *      -EPERM:      General failure.
- *  Requires:
- *      node_man != NULL.
- *      hdev_obj != NULL.
- *  Ensures:
- *      0:        Valide *node_man.
- *      error:          *node_man == NULL.
- */
-extern int node_create_mgr(struct node_mgr **node_man,
-				  struct dev_object *hdev_obj);
-
-/*
- *  ======== node_delete ========
- *  Purpose:
- *      Delete resources allocated in node_allocate(). If the node was
- *      created, delete the node on the DSP by remotely calling the node's
- *      delete function. Loads the node's delete function if necessary.
- *      GPP side resources are freed after node's delete function returns.
- *  Parameters:
- *      noderes:              Node resource info handle returned from
- *                                 node_allocate().
- *      pr_ctxt:                Pointer to process context data.
- *  Returns:
- *      0:            Success.
- *      -EFAULT:        Invalid hnode.
- *      -ETIME:       A timeout occurred before the DSP responded.
- *      -EPERM:          A failure occurred in deleting the node.
- *      -ESPIPE:        Delete function not found in the COFF file.
- *  Requires:
- *  Ensures:
- *      0:            hnode is invalid.
- */
-extern int node_delete(struct node_res_object *noderes,
-			      struct process_context *pr_ctxt);
-
-/*
- *  ======== node_delete_mgr ========
- *  Purpose:
- *      Delete the NODE Manager.
- *  Parameters:
- *      hnode_mgr:       Node manager object.
- *  Returns:
- *      0:        Success.
- *  Requires:
- *      Valid hnode_mgr.
- *  Ensures:
- */
-extern int node_delete_mgr(struct node_mgr *hnode_mgr);
-
-/*
- *  ======== node_enum_nodes ========
- *  Purpose:
- *      Enumerate the nodes currently allocated for the DSP.
- *  Parameters:
- *      hnode_mgr:       Node manager returned from node_create_mgr().
- *      node_tab:       Array to copy node handles into.
- *      node_tab_size:   Number of handles that can be written to node_tab.
- *      pu_num_nodes:     Location where number of node handles written to
- *                      node_tab will be written.
- *      pu_allocated:    Location to write total number of allocated nodes.
- *  Returns:
- *      0:        Success.
- *      -EINVAL:      node_tab is too small to hold all node handles.
- *  Requires:
- *      Valid hnode_mgr.
- *      node_tab != NULL || node_tab_size == 0.
- *      pu_num_nodes != NULL.
- *      pu_allocated != NULL.
- *  Ensures:
- *      - (-EINVAL && *pu_num_nodes == 0)
- *      - || (0 && *pu_num_nodes <= node_tab_size)  &&
- *        (*pu_allocated == *pu_num_nodes)
- */
-extern int node_enum_nodes(struct node_mgr *hnode_mgr,
-				  void **node_tab,
-				  u32 node_tab_size,
-				  u32 *pu_num_nodes,
-				  u32 *pu_allocated);
-
-/*
- *  ======== node_free_msg_buf ========
- *  Purpose:
- *      Free a message buffer previously allocated with node_alloc_msg_buf.
- *  Parameters:
- *      hnode:          The node handle.
- *      pbuffer:        (Address) Buffer allocated by node_alloc_msg_buf.
- *      pattr:          Same buffer attributes passed to node_alloc_msg_buf.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid node handle.
- *      -EPERM:      Failure to free the buffer.
- *  Requires:
- *      pbuffer != NULL.
- *  Ensures:
- */
-extern int node_free_msg_buf(struct node_object *hnode,
-				    u8 *pbuffer,
-				    struct dsp_bufferattr
-				    *pattr);
-
-/*
- *  ======== node_get_attr ========
- *  Purpose:
- *      Copy the current attributes of the specified node into a dsp_nodeattr
- *      structure.
- *  Parameters:
- *      hnode:          Node object allocated from node_allocate().
- *      pattr:          Pointer to dsp_nodeattr structure to copy node's
- *                      attributes.
- *      attr_size:      Size of pattr.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hnode.
- *  Requires:
- *      pattr != NULL.
- *  Ensures:
- *      0:        *pattrs contains the node's current attributes.
- */
-extern int node_get_attr(struct node_object *hnode,
-				struct dsp_nodeattr *pattr, u32 attr_size);
-
-/*
- *  ======== node_get_message ========
- *  Purpose:
- *      Retrieve a message from a node on the DSP. The node must be either a
- *      message node, task node, or XDAIS socket node.
- *      If a message is not available, this function will block until a
- *      message is available, or the node's timeout value is reached.
- *  Parameters:
- *      hnode:          Node handle returned from node_allocate().
- *      message:       Pointer to dsp_msg structure to copy the
- *                      message into.
- *      utimeout:       Timeout in milliseconds to wait for message.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hnode.
- *      -EPERM: Cannot retrieve messages from this type of node.
- *              Error occurred while trying to retrieve a message.
- *      -ETIME:   Timeout occurred and no message is available.
- *  Requires:
- *      message != NULL.
- *  Ensures:
- */
-extern int node_get_message(struct node_object *hnode,
-				   struct dsp_msg *message, u32 utimeout);
-
-/*
- *  ======== node_get_nldr_obj ========
- *  Purpose:
- *      Retrieve the Nldr manager
- *  Parameters:
- *      hnode_mgr:       Node Manager
- *      nldr_ovlyobj:   Pointer to a Nldr manager handle
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hnode.
- *  Ensures:
- */
-extern int node_get_nldr_obj(struct node_mgr *hnode_mgr,
-				    struct nldr_object **nldr_ovlyobj);
-
-/*
- *  ======== node_on_exit ========
- *  Purpose:
- *      Gets called when RMS_EXIT is received for a node. PROC needs to pass
- *      this function as a parameter to msg_create(). This function then gets
- *      called by the Bridge driver when an exit message for a node is received.
- *  Parameters:
- *      hnode:      Handle of the node that the exit message is for.
- *      node_status:    Return status of the node's execute phase.
- *  Returns:
- *  Ensures:
- */
-void node_on_exit(struct node_object *hnode, s32 node_status);
-
-/*
- *  ======== node_pause ========
- *  Purpose:
- *      Suspend execution of a node currently running on the DSP.
- *  Parameters:
- *      hnode:              Node object representing a node currently
- *                          running on the DSP.
- *  Returns:
- *      0:            Success.
- *      -EFAULT:        Invalid hnode.
- *      -EPERM: Node is not a task or socket node.
- *              Failed to pause node.
- *      -ETIME:       A timeout occurred before the DSP responded.
- *      DSP_EWRONGSTSATE:   Node is not in NODE_RUNNING state.
- *  Requires:
- *  Ensures:
- */
-extern int node_pause(struct node_object *hnode);
-
-/*
- *  ======== node_put_message ========
- *  Purpose:
- *      Send a message to a message node, task node, or XDAIS socket node.
- *      This function will block until the message stream can accommodate
- *      the message, or a timeout occurs. The message will be copied, so Msg
- *      can be re-used immediately after return.
- *  Parameters:
- *      hnode:              Node handle returned by node_allocate().
- *      pmsg:               Location of message to be sent to the node.
- *      utimeout:           Timeout in msecs to wait.
- *  Returns:
- *      0:            Success.
- *      -EFAULT:        Invalid hnode.
- *      -EPERM: Messages can't be sent to this type of node.
- *              Unable to send message.
- *      -ETIME:       Timeout occurred before message could be set.
- *      -EBADR:    Node is in invalid state for sending messages.
- *  Requires:
- *      pmsg != NULL.
- *  Ensures:
- */
-extern int node_put_message(struct node_object *hnode,
-				   const struct dsp_msg *pmsg, u32 utimeout);
-
-/*
- *  ======== node_register_notify ========
- *  Purpose:
- *      Register to be notified on specific events for this node.
- *  Parameters:
- *      hnode:          Node handle returned by node_allocate().
- *      event_mask:     Mask of types of events to be notified about.
- *      notify_type:    Type of notification to be sent.
- *      hnotification:  Handle to be used for notification.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hnode.
- *      -ENOMEM:    Insufficient memory on GPP.
- *      -EINVAL:     event_mask is invalid.
- *      -ENOSYS:   Notification type specified by notify_type is not
- *                      supported.
- *  Requires:
- *      hnotification != NULL.
- *  Ensures:
- */
-extern int node_register_notify(struct node_object *hnode,
-				       u32 event_mask, u32 notify_type,
-				       struct dsp_notification
-				       *hnotification);
-
-/*
- *  ======== node_run ========
- *  Purpose:
- *      Start execution of a node's execute phase, or resume execution of
- *      a node that has been suspended (via node_pause()) on the DSP. Load
- *      the node's execute function if necessary.
- *  Parameters:
- *      hnode:              Node object representing a node currently
- *                          running on the DSP.
- *  Returns:
- *      0:            Success.
- *      -EFAULT:        Invalid hnode.
- *      -EPERM: hnode doesn't represent a message, task or dais socket node.
- *              Unable to start or resume execution.
- *      -ETIME:       A timeout occurred before the DSP responded.
- *      DSP_EWRONGSTSATE:   Node is not in NODE_PAUSED or NODE_CREATED state.
- *      -ESPIPE:        Execute function not found in the COFF file.
- *  Requires:
- *  Ensures:
- */
-extern int node_run(struct node_object *hnode);
-
-/*
- *  ======== node_terminate ========
- *  Purpose:
- *      Signal a node running on the DSP that it should exit its execute
- *      phase function.
- *  Parameters:
- *      hnode:              Node object representing a node currently
- *                          running on the DSP.
- *      pstatus:            Location to store execute-phase function return
- *                          value.
- *  Returns:
- *      0:            Success.
- *      -EFAULT:        Invalid hnode.
- *      -ETIME:       A timeout occurred before the DSP responded.
- *      -EPERM: Type of node specified cannot be terminated.
- *              Unable to terminate the node.
- *      -EBADR:    Operation not valid for the current node state.
- *  Requires:
- *      pstatus != NULL.
- *  Ensures:
- */
-extern int node_terminate(struct node_object *hnode,
-				 int *pstatus);
-
-/*
- *  ======== node_get_uuid_props ========
- *  Purpose:
- *      Fetch Node properties given the UUID
- *  Parameters:
- *
- */
-extern int node_get_uuid_props(void *hprocessor,
-				      const struct dsp_uuid *node_uuid,
-				      struct dsp_ndbprops
-				      *node_props);
-
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-/**
- * node_find_addr() - Find the closest symbol to the given address.
- *
- * @node_mgr:		Node manager handle
- * @sym_addr:		Given address to find the closest symbol
- * @offset_range:		offset range to look fo the closest symbol
- * @sym_addr_output:	Symbol Output address
- * @sym_name:		String with the symbol name of the closest symbol
- *
- * 	This function finds the closest symbol to the address where a MMU
- *	Fault occurred on the DSP side.
- */
-int node_find_addr(struct node_mgr *node_mgr, u32 sym_addr,
-				u32 offset_range, void *sym_addr_output,
-				char *sym_name);
-
-enum node_state node_get_state(void *hnode);
-#endif
-
-#endif /* NODE_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/nodedefs.h b/drivers/staging/tidspbridge/include/dspbridge/nodedefs.h
deleted file mode 100644
index fb9623d..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/nodedefs.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * nodedefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global NODE constants and types, shared by PROCESSOR, NODE, and DISP.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef NODEDEFS_
-#define NODEDEFS_
-
-#define NODE_SUSPENDEDPRI -1
-
-/* NODE Objects: */
-struct node_mgr;
-struct node_object;
-
-#endif /* NODEDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/nodepriv.h b/drivers/staging/tidspbridge/include/dspbridge/nodepriv.h
deleted file mode 100644
index d5b54bb..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/nodepriv.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * nodepriv.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Private node header shared by NODE and DISP.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef NODEPRIV_
-#define NODEPRIV_
-
-#include <dspbridge/strmdefs.h>
-#include <dspbridge/nodedefs.h>
-#include <dspbridge/nldrdefs.h>
-
-/* DSP address of node environment structure */
-typedef u32 nodeenv;
-
-/*
- *  Node create structures
- */
-
-/* Message node */
-struct node_msgargs {
-	u32 max_msgs;		/* Max # of simultaneous messages for node */
-	u32 seg_id;		/* Segment for allocating message buffers */
-	u32 notify_type;	/* Notify type (SEM_post, SWI_post, etc.) */
-	u32 arg_length;		/* Length in 32-bit words of arg data block */
-	u8 *pdata;		/* Argument data for node */
-};
-
-struct node_strmdef {
-	u32 buf_size;		/* Size of buffers for SIO stream */
-	u32 num_bufs;		/* max # of buffers in SIO stream at once */
-	u32 seg_id;		/* Memory segment id to allocate buffers */
-	u32 timeout;		/* Timeout for blocking SIO calls */
-	u32 buf_alignment;	/* Buffer alignment */
-	char *sz_device;	/* Device name for stream */
-};
-
-/* Task node */
-struct node_taskargs {
-	struct node_msgargs node_msg_args;
-	s32 prio;
-	u32 stack_size;
-	u32 sys_stack_size;
-	u32 stack_seg;
-	u32 dsp_heap_res_addr;	/* DSP virtual heap address */
-	u32 dsp_heap_addr;	/* DSP virtual heap address */
-	u32 heap_size;		/* Heap size */
-	u32 gpp_heap_addr;	/* GPP virtual heap address */
-	u32 profile_id;		/* Profile ID */
-	u32 num_inputs;
-	u32 num_outputs;
-	u32 dais_arg;	/* Address of iAlg object */
-	struct node_strmdef *strm_in_def;
-	struct node_strmdef *strm_out_def;
-};
-
-/*
- *  ======== node_createargs ========
- */
-struct node_createargs {
-	union {
-		struct node_msgargs node_msg_args;
-		struct node_taskargs task_arg_obj;
-	} asa;
-};
-
-/*
- *  ======== node_get_channel_id ========
- *  Purpose:
- *      Get the channel index reserved for a stream connection between the
- *      host and a node. This index is reserved when node_connect() is called
- *      to connect the node with the host. This index should be passed to
- *      the CHNL_Open function when the stream is actually opened.
- *  Parameters:
- *      hnode:          Node object allocated from node_allocate().
- *      dir:           Input (DSP_TONODE) or output (DSP_FROMNODE).
- *      index:         Stream index.
- *      chan_id:        Location to store channel index.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hnode.
- *      -EPERM:  Not a task or DAIS socket node.
- *      -EINVAL:     The node's stream corresponding to index and dir
- *                      is not a stream to or from the host.
- *  Requires:
- *      Valid dir.
- *      chan_id != NULL.
- *  Ensures:
- */
-extern int node_get_channel_id(struct node_object *hnode,
-				      u32 dir, u32 index, u32 *chan_id);
-
-/*
- *  ======== node_get_strm_mgr ========
- *  Purpose:
- *      Get the STRM manager for a node.
- *  Parameters:
- *      hnode:          Node allocated with node_allocate().
- *      strm_man:       Location to store STRM manager on output.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hnode.
- *  Requires:
- *      strm_man != NULL.
- *  Ensures:
- */
-extern int node_get_strm_mgr(struct node_object *hnode,
-				    struct strm_mgr **strm_man);
-
-/*
- *  ======== node_get_timeout ========
- *  Purpose:
- *      Get the timeout value of a node.
- *  Parameters:
- *      hnode:      Node allocated with node_allocate(), or DSP_HGPPNODE.
- *  Returns:
- *      Node's timeout value.
- *  Requires:
- *      Valid hnode.
- *  Ensures:
- */
-extern u32 node_get_timeout(struct node_object *hnode);
-
-/*
- *  ======== node_get_type ========
- *  Purpose:
- *      Get the type (device, message, task, or XDAIS socket) of a node.
- *  Parameters:
- *      hnode:      Node allocated with node_allocate(), or DSP_HGPPNODE.
- *  Returns:
- *      Node type:  NODE_DEVICE, NODE_TASK, NODE_XDAIS, or NODE_GPP.
- *  Requires:
- *      Valid hnode.
- *  Ensures:
- */
-extern enum node_type node_get_type(struct node_object *hnode);
-
-/*
- *  ======== get_node_info ========
- *  Purpose:
- *      Get node information without holding semaphore.
- *  Parameters:
- *      hnode:      Node allocated with node_allocate(), or DSP_HGPPNODE.
- *  Returns:
- *      Node info:  priority, device owner, no. of streams, execution state
- *                  NDB properties.
- *  Requires:
- *      Valid hnode.
- *  Ensures:
- */
-extern void get_node_info(struct node_object *hnode,
-			  struct dsp_nodeinfo *node_info);
-
-/*
- *  ======== node_get_load_type ========
- *  Purpose:
- *      Get the load type (dynamic, overlay, static) of a node.
- *  Parameters:
- *      hnode:      Node allocated with node_allocate(), or DSP_HGPPNODE.
- *  Returns:
- *      Node type:  NLDR_DYNAMICLOAD, NLDR_OVLYLOAD, NLDR_STATICLOAD
- *  Requires:
- *      Valid hnode.
- *  Ensures:
- */
-extern enum nldr_loadtype node_get_load_type(struct node_object *hnode);
-
-#endif /* NODEPRIV_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/ntfy.h b/drivers/staging/tidspbridge/include/dspbridge/ntfy.h
deleted file mode 100644
index 6bb94d2..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/ntfy.h
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * ntfy.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Manage lists of notification events.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef NTFY_
-#define NTFY_
-
-#include <dspbridge/host_os.h>
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/sync.h>
-
-/**
- * ntfy_object - head structure to nofify dspbridge events
- * @head:	List of notify objects
- * @ntfy_lock:	lock for list access.
- *
- */
-struct ntfy_object {
-	struct raw_notifier_head head;/* List of notifier objects */
-	spinlock_t ntfy_lock;	/* For critical sections */
-};
-
-/**
- * ntfy_event - structure store specify event to be notified
- * @noti_block:	List of notify objects
- * @event:	event that it respond
- * @type: 	event type (only DSP_SIGNALEVENT supported)
- * @sync_obj:	sync_event used to set the event
- *
- */
-struct ntfy_event {
-	struct notifier_block noti_block;
-	u32 event;	/* Events to be notified about */
-	u32 type;	/* Type of notification to be sent */
-	struct sync_object sync_obj;
-};
-
-
-/**
- * dsp_notifier_event() - callback function to nofity events
- * @this:		pointer to itself struct notifier_block
- * @event:	event to be notified.
- * @data:		Currently not used.
- *
- */
-int dsp_notifier_event(struct notifier_block *this, unsigned long event,
-			   void *data);
-
-/**
- * ntfy_init() - Set the initial state of the ntfy_object structure.
- * @no:		pointer to ntfy_object structure.
- *
- * This function sets the initial state of the ntfy_object in order it
- * can be used by the other ntfy functions.
- */
-
-static inline void ntfy_init(struct ntfy_object *no)
-{
-	spin_lock_init(&no->ntfy_lock);
-	RAW_INIT_NOTIFIER_HEAD(&no->head);
-}
-
-/**
- * ntfy_delete() - delete list of nofy events registered.
- * @ntfy_obj:	Pointer to the ntfy object structure.
- *
- * This function is used to remove all the notify events registered.
- * unregister function is not needed in this function, to unregister
- * a ntfy_event please look at ntfy_register function.
- *
- */
-static inline void ntfy_delete(struct ntfy_object *ntfy_obj)
-{
-	struct ntfy_event *ne;
-	struct notifier_block *nb;
-
-	spin_lock_bh(&ntfy_obj->ntfy_lock);
-	nb = ntfy_obj->head.head;
-	while (nb) {
-		ne = container_of(nb, struct ntfy_event, noti_block);
-		nb = nb->next;
-		kfree(ne);
-	}
-	spin_unlock_bh(&ntfy_obj->ntfy_lock);
-}
-
-/**
- * ntfy_notify() - nofity all event register for an specific event.
- * @ntfy_obj:	Pointer to the ntfy_object structure.
- * @event:	event to be notified.
- *
- * This function traverses all the ntfy events registers and
- * set the event with mach with @event.
- */
-static inline void ntfy_notify(struct ntfy_object *ntfy_obj, u32 event)
-{
-	spin_lock_bh(&ntfy_obj->ntfy_lock);
-	raw_notifier_call_chain(&ntfy_obj->head, event, NULL);
-	spin_unlock_bh(&ntfy_obj->ntfy_lock);
-}
-
-
-
-/**
- * ntfy_init() - Create and initialize a ntfy_event structure.
- * @event:	event that the ntfy event will respond
- * @type		event type (only DSP_SIGNALEVENT supported)
- *
- * This function create a ntfy_event element and sets the event it will
- * respond the ntfy_event in order it can be used by the other ntfy functions.
- * In case of success it will return a pointer to the ntfy_event struct
- * created. Otherwise it will return NULL;
- */
-
-static inline struct ntfy_event *ntfy_event_create(u32 event, u32 type)
-{
-	struct ntfy_event *ne;
-	ne = kmalloc(sizeof(struct ntfy_event), GFP_KERNEL);
-	if (ne) {
-		sync_init_event(&ne->sync_obj);
-		ne->noti_block.notifier_call = dsp_notifier_event;
-		ne->event = event;
-		ne->type = type;
-	}
-	return ne;
-}
-
-/**
- * ntfy_register() - register new ntfy_event into a given ntfy_object
- * @ntfy_obj:	Pointer to the ntfy_object structure.
- * @noti:		Pointer to the handle to be returned to the user space.
- * @event	event that the ntfy event will respond
- * @type		event type (only DSP_SIGNALEVENT supported)
- *
- * This function register a new ntfy_event into the ntfy_object list,
- * which will respond to the @event passed.
- * This function will return 0 in case of error.
- * -EFAULT in case of bad pointers and
- * DSP_EMemory in case of no memory to create ntfy_event.
- */
-static  inline int ntfy_register(struct ntfy_object *ntfy_obj,
-			 struct dsp_notification *noti,
-			 u32 event, u32 type)
-{
-	struct ntfy_event *ne;
-	int status = 0;
-
-	if (!noti || !ntfy_obj) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	if (!event) {
-		status = -EINVAL;
-		goto func_end;
-	}
-	ne = ntfy_event_create(event, type);
-	if (!ne) {
-		status = -ENOMEM;
-		goto func_end;
-	}
-	noti->handle = &ne->sync_obj;
-
-	spin_lock_bh(&ntfy_obj->ntfy_lock);
-	raw_notifier_chain_register(&ntfy_obj->head, &ne->noti_block);
-	spin_unlock_bh(&ntfy_obj->ntfy_lock);
-func_end:
-	return status;
-}
-
-/**
- * ntfy_unregister() - unregister a ntfy_event from a given ntfy_object
- * @ntfy_obj:	Pointer to the ntfy_object structure.
- * @noti:		Pointer to the event that will be removed.
- *
- * This function unregister a ntfy_event from the ntfy_object list,
- * @noti contains the event which is wanted to be removed.
- * This function will return 0 in case of error.
- * -EFAULT in case of bad pointers and
- * DSP_EMemory in case of no memory to create ntfy_event.
- */
-static  inline int ntfy_unregister(struct ntfy_object *ntfy_obj,
-			 struct dsp_notification *noti)
-{
-	int status = 0;
-	struct ntfy_event *ne;
-
-	if (!noti || !ntfy_obj) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	ne = container_of((struct sync_object *)noti, struct ntfy_event,
-								sync_obj);
-	spin_lock_bh(&ntfy_obj->ntfy_lock);
-	raw_notifier_chain_unregister(&ntfy_obj->head,
-						&ne->noti_block);
-	kfree(ne);
-	spin_unlock_bh(&ntfy_obj->ntfy_lock);
-func_end:
-	return status;
-}
-
-#endif				/* NTFY_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/proc.h b/drivers/staging/tidspbridge/include/dspbridge/proc.h
deleted file mode 100644
index 64c2457..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/proc.h
+++ /dev/null
@@ -1,591 +0,0 @@
-/*
- * proc.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * This is the DSP API RM module interface.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef PROC_
-#define PROC_
-
-#include <dspbridge/cfgdefs.h>
-#include <dspbridge/devdefs.h>
-#include <dspbridge/drv.h>
-
-/*
- *  ======== proc_attach ========
- *  Purpose:
- *      Prepare for communication with a particular DSP processor, and return
- *      a handle to the processor object. The PROC Object gets created
- *  Parameters:
- *      processor_id  :	   The processor index (zero-based).
- *      hmgr_obj  :	   Handle to the Manager Object
- *      attr_in     :	   Ptr to the dsp_processorattrin structure.
- *			      A NULL value means use default values.
- *      ph_processor :	   Ptr to location to store processor handle.
- *  Returns:
- *      0     :	   Success.
- *      -EPERM   :	   General failure.
- *      -EFAULT :	   Invalid processor handle.
- *      0:   Success; Processor already attached.
- *  Requires:
- *      ph_processor != NULL.
- *      PROC Initialized.
- *  Ensures:
- *      -EPERM, and *ph_processor == NULL, OR
- *      Success and *ph_processor is a Valid Processor handle OR
- *      0 and *ph_processor is a Valid Processor.
- *  Details:
- *      When attr_in is NULL, the default timeout value is 10 seconds.
- */
-extern int proc_attach(u32 processor_id,
-			      const struct dsp_processorattrin
-			      *attr_in, void **ph_processor,
-			      struct process_context *pr_ctxt);
-
-/*
- *  ======== proc_auto_start =========
- *  Purpose:
- *      A Particular device gets loaded with the default image
- *      if the AutoStart flag is set.
- *  Parameters:
- *      hdev_obj  :   Handle to the Device
- *  Returns:
- *      0     :   On Successful Loading
- *      -ENOENT   :   No DSP exec file found.
- *      -EPERM   :   General Failure
- *  Requires:
- *      hdev_obj != NULL.
- *      dev_node_obj != NULL.
- *      PROC Initialized.
- *  Ensures:
- */
-extern int proc_auto_start(struct cfg_devnode *dev_node_obj,
-				  struct dev_object *hdev_obj);
-
-/*
- *  ======== proc_ctrl ========
- *  Purpose:
- *      Pass control information to the GPP device driver managing the DSP
- *      processor. This will be an OEM-only function, and not part of the
- *      'Bridge application developer's API.
- *  Parameters:
- *      hprocessor  :       The processor handle.
- *      dw_cmd       :       Private driver IOCTL cmd ID.
- *      pargs       :       Ptr to an driver defined argument structure.
- *  Returns:
- *      0     :       SUCCESS
- *      -EFAULT :       Invalid processor handle.
- *      -ETIME:       A Timeout Occurred before the Control information
- *			  could be sent.
- *      -EPERM   :       General Failure.
- *  Requires:
- *      PROC Initialized.
- *  Ensures
- *  Details:
- *      This function Calls bridge_dev_ctrl.
- */
-extern int proc_ctrl(void *hprocessor,
-			    u32 dw_cmd, struct dsp_cbdata *arg);
-
-/*
- *  ======== proc_detach ========
- *  Purpose:
- *      Close a DSP processor and de-allocate all (GPP) resources reserved
- *      for it. The Processor Object is deleted.
- *  Parameters:
- *      pr_ctxt     :   The processor handle.
- *  Returns:
- *      0     :   Success.
- *      -EFAULT :   InValid Handle.
- *      -EPERM   :   General failure.
- *  Requires:
- *      PROC Initialized.
- *  Ensures:
- *      PROC Object is destroyed.
- */
-extern int proc_detach(struct process_context *pr_ctxt);
-
-/*
- *  ======== proc_enum_nodes ========
- *  Purpose:
- *      Enumerate the nodes currently allocated on a processor.
- *  Parameters:
- *      hprocessor  :   The processor handle.
- *      node_tab    :   The first Location of an array allocated for node
- *		      handles.
- *      node_tab_size:   The number of (DSP_HNODE) handles that can be held
- *		      to the memory the client has allocated for node_tab
- *      pu_num_nodes  :   Location where DSPProcessor_EnumNodes will return
- *		      the number of valid handles written to node_tab
- *      pu_allocated :   Location where DSPProcessor_EnumNodes will return
- *		      the number of nodes that are allocated on the DSP.
- *  Returns:
- *      0     :   Success.
- *      -EFAULT :   Invalid processor handle.
- *      -EINVAL   :   The amount of memory allocated for node_tab is
- *		      insufficent. That is the number of nodes actually
- *		      allocated on the DSP is greater than the value
- *		      specified for node_tab_size.
- *      -EPERM   :   Unable to get Resource Information.
- *  Details:
- *  Requires
- *      pu_num_nodes is not NULL.
- *      pu_allocated is not NULL.
- *      node_tab is not NULL.
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- */
-extern int proc_enum_nodes(void *hprocessor,
-				  void **node_tab,
-				  u32 node_tab_size,
-				  u32 *pu_num_nodes,
-				  u32 *pu_allocated);
-
-/*
- *  ======== proc_get_resource_info ========
- *  Purpose:
- *      Enumerate the resources currently available on a processor.
- *  Parameters:
- *      hprocessor  :       The processor handle.
- *      resource_type:      Type of resource .
- *      resource_info:      Ptr to the dsp_resourceinfo structure.
- *      resource_info_size:  Size of the structure.
- *  Returns:
- *      0     :       Success.
- *      -EFAULT :       Invalid processor handle.
- *      -EBADR:    The processor is not in the PROC_RUNNING state.
- *      -ETIME:       A timeout occurred before the DSP responded to the
- *			  querry.
- *      -EPERM   :       Unable to get Resource Information
- *  Requires:
- *      resource_info is not NULL.
- *      Parameter resource_type is Valid.[TBD]
- *      resource_info_size is >= sizeof dsp_resourceinfo struct.
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- *      This function currently returns
- *      -ENOSYS, and does not write any data to the resource_info struct.
- */
-extern int proc_get_resource_info(void *hprocessor,
-					 u32 resource_type,
-					 struct dsp_resourceinfo
-					 *resource_info,
-					 u32 resource_info_size);
-
-/*
- * ======== proc_get_dev_object =========
- *  Purpose:
- *      Returns the DEV Hanlde for a given Processor handle
- *  Parameters:
- *      hprocessor  :   Processor Handle
- *      device_obj :    Location to store the DEV Handle.
- *  Returns:
- *      0     :   Success; *device_obj has Dev handle
- *      -EPERM   :   Failure; *device_obj is zero.
- *  Requires:
- *      device_obj is not NULL
- *      PROC Initialized.
- *  Ensures:
- *      0     :   *device_obj is not NULL
- *      -EPERM   :   *device_obj is NULL.
- */
-extern int proc_get_dev_object(void *hprocessor,
-				      struct dev_object **device_obj);
-
-/*
- *  ======== proc_get_state ========
- *  Purpose:
- *      Report the state of the specified DSP processor.
- *  Parameters:
- *      hprocessor  :   The processor handle.
- *      proc_state_obj :   Ptr to location to store the dsp_processorstate
- *		      structure.
- *      state_info_size: Size of dsp_processorstate.
- *  Returns:
- *      0     :   Success.
- *      -EFAULT :   Invalid processor handle.
- *      -EPERM   :   General failure while querying processor state.
- *  Requires:
- *      proc_state_obj is not NULL
- *      state_info_size is >= than the size of dsp_processorstate structure.
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- */
-extern int proc_get_state(void *hprocessor, struct dsp_processorstate
-				 *proc_state_obj, u32 state_info_size);
-
-/*
- *  ======== PROC_GetProcessorID ========
- *  Purpose:
- *      Report the state of the specified DSP processor.
- *  Parameters:
- *      hprocessor  :   The processor handle.
- *      proc_id      :   Processor ID
- *
- *  Returns:
- *      0     :   Success.
- *      -EFAULT :   Invalid processor handle.
- *      -EPERM   :   General failure while querying processor state.
- *  Requires:
- *      proc_state_obj is not NULL
- *      state_info_size is >= than the size of dsp_processorstate structure.
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- */
-extern int proc_get_processor_id(void *proc, u32 * proc_id);
-
-/*
- *  ======== proc_get_trace ========
- *  Purpose:
- *      Retrieve the trace buffer from the specified DSP processor.
- *  Parameters:
- *      hprocessor  :   The processor handle.
- *      pbuf	:   Ptr to buffer to hold trace output.
- *      max_size    :   Maximum size of the output buffer.
- *  Returns:
- *      0     :   Success.
- *      -EFAULT :   Invalid processor handle.
- *      -EPERM   :   General failure while retrieving processor trace
- *		      Buffer.
- *  Requires:
- *      pbuf is not NULL
- *      max_size is > 0.
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- */
-extern int proc_get_trace(void *hprocessor, u8 * pbuf, u32 max_size);
-
-/*
- *  ======== proc_load ========
- *  Purpose:
- *      Reset a processor and load a new base program image.
- *      This will be an OEM-only function.
- *  Parameters:
- *      hprocessor:       The processor handle.
- *      argc_index:       The number of Arguments(strings)in the aArgV[]
- *      user_args:       An Array of Arguments(Unicode Strings)
- *      user_envp:       An Array of Environment settings(Unicode Strings)
- *  Returns:
- *      0:       Success.
- *      -ENOENT:       The DSP Executable was not found.
- *      -EFAULT:       Invalid processor handle.
- *      -EPERM   :       Unable to Load the Processor
- *  Requires:
- *      user_args is not NULL
- *      argc_index is > 0
- *      PROC Initialized.
- *  Ensures:
- *      Success and ProcState == PROC_LOADED
- *      or DSP_FAILED status.
- *  Details:
- *      Does not implement access rights to control which GPP application
- *      can load the processor.
- */
-extern int proc_load(void *hprocessor,
-			    const s32 argc_index, const char **user_args,
-			    const char **user_envp);
-
-/*
- *  ======== proc_register_notify ========
- *  Purpose:
- *      Register to be notified of specific processor events
- *  Parameters:
- *      hprocessor  :   The processor handle.
- *      event_mask  :   Mask of types of events to be notified about.
- *      notify_type :   Type of notification to be sent.
- *      hnotification:  Handle to be used for notification.
- *  Returns:
- *      0     :   Success.
- *      -EFAULT :   Invalid processor handle or hnotification.
- *      -EINVAL  :   Parameter event_mask is Invalid
- *      DSP_ENOTIMP :   The notification type specified in uNotifyMask
- *		      is not supported.
- *      -EPERM   :   Unable to register for notification.
- *  Requires:
- *      hnotification is not NULL
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- */
-extern int proc_register_notify(void *hprocessor,
-				       u32 event_mask, u32 notify_type,
-				       struct dsp_notification
-				       *hnotification);
-
-/*
- *  ======== proc_notify_clients ========
- *  Purpose:
- *      Notify the Processor Clients
- *  Parameters:
- *      proc       :   The processor handle.
- *      events     :   Event to be notified about.
- *  Returns:
- *      0     :   Success.
- *      -EFAULT :   Invalid processor handle.
- *      -EPERM   :   Failure to Set or Reset the Event
- *  Requires:
- *      events is Supported or Valid type of Event
- *      proc is a valid handle
- *      PROC Initialized.
- *  Ensures:
- */
-extern int proc_notify_clients(void *proc, u32 events);
-
-/*
- *  ======== proc_notify_all_clients ========
- *  Purpose:
- *      Notify the Processor Clients
- *  Parameters:
- *      proc       :   The processor handle.
- *      events     :   Event to be notified about.
- *  Returns:
- *      0     :   Success.
- *      -EFAULT :   Invalid processor handle.
- *      -EPERM   :   Failure to Set or Reset the Event
- *  Requires:
- *      events is Supported or Valid type of Event
- *      proc is a valid handle
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- *      NODE And STRM would use this function to notify their clients
- *      about the state changes in NODE or STRM.
- */
-extern int proc_notify_all_clients(void *proc, u32 events);
-
-/*
- *  ======== proc_start ========
- *  Purpose:
- *      Start a processor running.
- *      Processor must be in PROC_LOADED state.
- *      This will be an OEM-only function, and not part of the 'Bridge
- *      application developer's API.
- *  Parameters:
- *      hprocessor  :       The processor handle.
- *  Returns:
- *      0     :       Success.
- *      -EFAULT :       Invalid processor handle.
- *      -EBADR:    Processor is not in PROC_LOADED state.
- *      -EPERM   :       Unable to start the processor.
- *  Requires:
- *      PROC Initialized.
- *  Ensures:
- *      Success and ProcState == PROC_RUNNING or DSP_FAILED status.
- *  Details:
- */
-extern int proc_start(void *hprocessor);
-
-/*
- *  ======== proc_stop ========
- *  Purpose:
- *      Start a processor running.
- *      Processor must be in PROC_LOADED state.
- *      This will be an OEM-only function, and not part of the 'Bridge
- *      application developer's API.
- *  Parameters:
- *      hprocessor  :       The processor handle.
- *  Returns:
- *      0     :       Success.
- *      -EFAULT :       Invalid processor handle.
- *      -EBADR:    Processor is not in PROC_LOADED state.
- *      -EPERM   :       Unable to start the processor.
- *  Requires:
- *      PROC Initialized.
- *  Ensures:
- *      Success and ProcState == PROC_RUNNING or DSP_FAILED status.
- *  Details:
- */
-extern int proc_stop(void *hprocessor);
-
-/*
- *  ======== proc_end_dma ========
- *  Purpose:
- *      Begin a DMA transfer
- *  Parameters:
- *      hprocessor      :   The processor handle.
- *      pmpu_addr	:   Buffer start address
- *      ul_size		:   Buffer size
- *      dir		:   The direction of the transfer
- *  Requires:
- *      Memory was previously mapped.
- */
-extern int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
-						enum dma_data_direction dir);
-/*
- *  ======== proc_begin_dma ========
- *  Purpose:
- *      Begin a DMA transfer
- *  Parameters:
- *      hprocessor      :   The processor handle.
- *      pmpu_addr	:   Buffer start address
- *      ul_size		:   Buffer size
- *      dir		:   The direction of the transfer
- *  Requires:
- *      Memory was previously mapped.
- */
-extern int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
-						enum dma_data_direction dir);
-
-/*
- *  ======== proc_flush_memory ========
- *  Purpose:
- *      Flushes a buffer from the MPU data cache.
- *  Parameters:
- *      hprocessor      :   The processor handle.
- *      pmpu_addr	:   Buffer start address
- *      ul_size	  :   Buffer size
- *      ul_flags	 :   Reserved.
- *  Returns:
- *      0	 :   Success.
- *      -EFAULT     :   Invalid processor handle.
- *      -EPERM       :   General failure.
- *  Requires:
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- *      All the arguments are currently ignored.
- */
-extern int proc_flush_memory(void *hprocessor,
-				    void *pmpu_addr, u32 ul_size, u32 ul_flags);
-
-/*
- *  ======== proc_invalidate_memory ========
- *  Purpose:
- *      Invalidates a buffer from the MPU data cache.
- *  Parameters:
- *      hprocessor      :   The processor handle.
- *      pmpu_addr	:   Buffer start address
- *      ul_size	  :   Buffer size
- *  Returns:
- *      0	 :   Success.
- *      -EFAULT     :   Invalid processor handle.
- *      -EPERM       :   General failure.
- *  Requires:
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- *      All the arguments are currently ignored.
- */
-extern int proc_invalidate_memory(void *hprocessor,
-					 void *pmpu_addr, u32 ul_size);
-
-/*
- *  ======== proc_map ========
- *  Purpose:
- *      Maps a MPU buffer to DSP address space.
- *  Parameters:
- *      hprocessor      :   The processor handle.
- *      pmpu_addr	:   Starting address of the memory region to map.
- *      ul_size	  :   Size of the memory region to map.
- *      req_addr	:   Requested DSP start address. Offset-adjusted actual
- *			  mapped address is in the last argument.
- *      pp_map_addr       :   Ptr to DSP side mapped u8 address.
- *      ul_map_attr       :   Optional endianness attributes, virt to phys flag.
- *  Returns:
- *      0	 :   Success.
- *      -EFAULT     :   Invalid processor handle.
- *      -EPERM       :   General failure.
- *      -ENOMEM     :   MPU side memory allocation error.
- *      -ENOENT   :   Cannot find a reserved region starting with this
- *		      :   address.
- *  Requires:
- *      pmpu_addr is not NULL
- *      ul_size is not zero
- *      pp_map_addr is not NULL
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- */
-extern int proc_map(void *hprocessor,
-			   void *pmpu_addr,
-			   u32 ul_size,
-			   void *req_addr,
-			   void **pp_map_addr, u32 ul_map_attr,
-			   struct process_context *pr_ctxt);
-
-/*
- *  ======== proc_reserve_memory ========
- *  Purpose:
- *      Reserve a virtually contiguous region of DSP address space.
- *  Parameters:
- *      hprocessor      :   The processor handle.
- *      ul_size	  :   Size of the address space to reserve.
- *      pp_rsv_addr       :   Ptr to DSP side reserved u8 address.
- *  Returns:
- *      0	 :   Success.
- *      -EFAULT     :   Invalid processor handle.
- *      -EPERM       :   General failure.
- *      -ENOMEM     :   Cannot reserve chunk of this size.
- *  Requires:
- *      pp_rsv_addr is not NULL
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- */
-extern int proc_reserve_memory(void *hprocessor,
-				      u32 ul_size, void **pp_rsv_addr,
-				      struct process_context *pr_ctxt);
-
-/*
- *  ======== proc_un_map ========
- *  Purpose:
- *      Removes a MPU buffer mapping from the DSP address space.
- *  Parameters:
- *      hprocessor      :   The processor handle.
- *      map_addr	:   Starting address of the mapped memory region.
- *  Returns:
- *      0	 :   Success.
- *      -EFAULT     :   Invalid processor handle.
- *      -EPERM       :   General failure.
- *      -ENOENT   :   Cannot find a mapped region starting with this
- *		      :   address.
- *  Requires:
- *      map_addr is not NULL
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- */
-extern int proc_un_map(void *hprocessor, void *map_addr,
-			      struct process_context *pr_ctxt);
-
-/*
- *  ======== proc_un_reserve_memory ========
- *  Purpose:
- *      Frees a previously reserved region of DSP address space.
- *  Parameters:
- *      hprocessor      :   The processor handle.
- *      prsv_addr	:   Ptr to DSP side reservedBYTE address.
- *  Returns:
- *      0	 :   Success.
- *      -EFAULT     :   Invalid processor handle.
- *      -EPERM       :   General failure.
- *      -ENOENT   :   Cannot find a reserved region starting with this
- *		      :   address.
- *  Requires:
- *      prsv_addr is not NULL
- *      PROC Initialized.
- *  Ensures:
- *  Details:
- */
-extern int proc_un_reserve_memory(void *hprocessor,
-					 void *prsv_addr,
-					 struct process_context *pr_ctxt);
-
-#endif /* PROC_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/procpriv.h b/drivers/staging/tidspbridge/include/dspbridge/procpriv.h
deleted file mode 100644
index 77d1f0e..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/procpriv.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * procpriv.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global PROC constants and types, shared by PROC, MGR and DSP API.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef PROCPRIV_
-#define PROCPRIV_
-
-/* RM PROC Object */
-struct proc_object;
-
-#endif /* PROCPRIV_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/pwr.h b/drivers/staging/tidspbridge/include/dspbridge/pwr.h
deleted file mode 100644
index 0fb0664..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/pwr.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * pwr.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef PWR_
-#define PWR_
-
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/mbx_sh.h>
-
-/* valid sleep command codes that can be sent by GPP via mailbox: */
-#define PWR_DEEPSLEEP           MBX_PM_DSPIDLE
-#define PWR_EMERGENCYDEEPSLEEP  MBX_PM_EMERGENCYSLEEP
-#define PWR_WAKEUP              MBX_PM_DSPWAKEUP
-
-
-/*
- *  ======== pwr_sleep_dsp ========
- *      Signal the DSP to go to sleep.
- *
- *  Parameters:
- *      sleep_code:          New sleep state for DSP.  (Initially, valid codes
- *                          are PWR_DEEPSLEEP or PWR_EMERGENCYDEEPSLEEP; both of
- *                          these codes will simply put the DSP in deep sleep.)
- *
- *	timeout:            Maximum time (msec) that PWR should wait for
- *                          confirmation that the DSP sleep state has been
- *                          reached.  If PWR should simply send the command to
- *                          the DSP to go to sleep and then return (i.e.,
- *                          asynchrounous sleep), the timeout should be
- *                          specified as zero.
- *
- *  Returns:
- *      0:            Success.
- *      0: Success, but the DSP was already asleep.
- *      -EINVAL:    The specified sleep_code is not supported.
- *      -ETIME:       A timeout occurred while waiting for DSP sleep
- *                          confirmation.
- *      -EPERM:          General failure, unable to send sleep command to
- *                          the DSP.
- */
-extern int pwr_sleep_dsp(const u32 sleep_code, const u32 timeout);
-
-/*
- *  ======== pwr_wake_dsp ========
- *    Signal the DSP to wake from sleep.
- *
- *  Parameters:
- *	timeout:            Maximum time (msec) that PWR should wait for
- *                          confirmation that the DSP is awake.  If PWR should
- *                          simply send a command to the DSP to wake and then
- *                          return (i.e., asynchrounous wake), timeout should
- *                          be specified as zero.
- *
- *  Returns:
- *      0:            Success.
- *      0:  Success, but the DSP was already awake.
- *      -ETIME:       A timeout occurred while waiting for wake
- *                          confirmation.
- *      -EPERM:          General failure, unable to send wake command to
- *                          the DSP.
- */
-extern int pwr_wake_dsp(const u32 timeout);
-
-/*
- *  ======== pwr_pm_pre_scale ========
- *    Prescale notification to DSP.
- *
- *  Parameters:
- *	voltage_domain:   The voltage domain for which notification is sent
- *    level:			The level of voltage domain
- *
- *  Returns:
- *      0:            Success.
- *      0:  Success, but the DSP was already awake.
- *      -ETIME:       A timeout occurred while waiting for wake
- *                          confirmation.
- *      -EPERM:          General failure, unable to send wake command to
- *                          the DSP.
- */
-extern int pwr_pm_pre_scale(u16 voltage_domain, u32 level);
-
-/*
- *  ======== pwr_pm_post_scale ========
- *    PostScale notification to DSP.
- *
- *  Parameters:
- *	voltage_domain:   The voltage domain for which notification is sent
- *    level:			The level of voltage domain
- *
- *  Returns:
- *      0:            Success.
- *      0:  Success, but the DSP was already awake.
- *      -ETIME:       A timeout occurred while waiting for wake
- *                          confirmation.
- *      -EPERM:          General failure, unable to send wake command to
- *                          the DSP.
- */
-extern int pwr_pm_post_scale(u16 voltage_domain, u32 level);
-
-#endif /* PWR_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/resourcecleanup.h b/drivers/staging/tidspbridge/include/dspbridge/resourcecleanup.h
deleted file mode 100644
index 8c9c902..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/resourcecleanup.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * resourcecleanup.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <dspbridge/nodepriv.h>
-#include <dspbridge/drv.h>
-
-extern int drv_remove_all_dmm_res_elements(void *process_ctxt);
-
-extern int drv_remove_all_node_res_elements(void *process_ctxt);
-
-extern int drv_remove_all_resources(void *process_ctxt);
-
-extern int drv_insert_node_res_element(void *hnode, void *node_resource,
-					      void *process_ctxt);
-
-extern void drv_proc_node_update_heap_status(void *node_resource, s32 status);
-
-extern void drv_proc_node_update_status(void *node_resource, s32 status);
-
-extern int drv_proc_update_strm_res(u32 num_bufs, void *strm_resources);
-
-extern int drv_proc_insert_strm_res_element(void *stream_obj,
-						   void *strm_res,
-						   void *process_ctxt);
-
-extern int drv_remove_all_strm_res_elements(void *process_ctxt);
-
-extern enum node_state node_get_state(void *hnode);
diff --git a/drivers/staging/tidspbridge/include/dspbridge/rmm.h b/drivers/staging/tidspbridge/include/dspbridge/rmm.h
deleted file mode 100644
index f7a4dc8..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/rmm.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * rmm.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * This memory manager provides general heap management and arbitrary
- * alignment for any number of memory segments, and management of overlay
- * memory.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef RMM_
-#define RMM_
-
-/*
- *  ======== rmm_addr ========
- *  DSP address + segid
- */
-struct rmm_addr {
-	u32 addr;
-	s32 segid;
-};
-
-/*
- *  ======== rmm_segment ========
- *  Memory segment on the DSP available for remote allocations.
- */
-struct rmm_segment {
-	u32 base;		/* Base of the segment */
-	u32 length;		/* Size of the segment (target MAUs) */
-	s32 space;		/* Code or data */
-	u32 number;		/* Number of Allocated Blocks */
-};
-
-/*
- *  ======== RMM_Target ========
- */
-struct rmm_target_obj;
-
-/*
- *  ======== rmm_alloc ========
- *
- *  rmm_alloc is used to remotely allocate or reserve memory on the DSP.
- *
- *  Parameters:
- *      target          - Target returned from rmm_create().
- *      segid           - Memory segment to allocate from.
- *      size            - Size (target MAUS) to allocate.
- *      align           - alignment.
- *      dsp_address     - If reserve is FALSE, the location to store allocated
- *                        address on output, otherwise, the DSP address to
- *                        reserve.
- *      reserve         - If TRUE, reserve the memory specified by dsp_address.
- *  Returns:
- *      0:                Success.
- *      -ENOMEM:            Memory allocation on GPP failed.
- *      -ENXIO:     Cannot "allocate" overlay memory because it's
- *                              already in use.
- *  Requires:
- *      RMM initialized.
- *      Valid target.
- *      dsp_address != NULL.
- *      size > 0
- *      reserve || target->num_segs > 0.
- *  Ensures:
- */
-extern int rmm_alloc(struct rmm_target_obj *target, u32 segid, u32 size,
-			u32 align, u32 *dsp_address, bool reserve);
-
-/*
- *  ======== rmm_create ========
- *  Create a target object with memory segments for remote allocation. If
- *  seg_tab == NULL or num_segs == 0, memory can only be reserved through
- *  rmm_alloc().
- *
- *  Parameters:
- *      target_obj:        - Location to store target on output.
- *      seg_tab:         - Table of memory segments.
- *      num_segs:        - Number of memory segments.
- *  Returns:
- *      0:        Success.
- *      -ENOMEM:    Memory allocation failed.
- *  Requires:
- *      RMM initialized.
- *      target_obj != NULL.
- *      num_segs == 0 || seg_tab != NULL.
- *  Ensures:
- *      Success:        Valid *target_obj.
- *      Failure:        *target_obj == NULL.
- */
-extern int rmm_create(struct rmm_target_obj **target_obj,
-			     struct rmm_segment seg_tab[], u32 num_segs);
-
-/*
- *  ======== rmm_delete ========
- *  Delete target allocated in rmm_create().
- *
- *  Parameters:
- *      target          - Target returned from rmm_create().
- *  Returns:
- *  Requires:
- *      RMM initialized.
- *      Valid target.
- *  Ensures:
- */
-extern void rmm_delete(struct rmm_target_obj *target);
-
-/*
- *  ======== rmm_free ========
- *  Free or unreserve memory allocated through rmm_alloc().
- *
- *  Parameters:
- *      target:         - Target returned from rmm_create().
- *      segid:          - Segment of memory to free.
- *      dsp_address:    - Address to free or unreserve.
- *      size:           - Size of memory to free or unreserve.
- *      reserved:       - TRUE if memory was reserved only, otherwise FALSE.
- *  Returns:
- *  Requires:
- *      RMM initialized.
- *      Valid target.
- *      reserved || segid < target->num_segs.
- *      reserve || [dsp_address, dsp_address + size] is a valid memory range.
- *  Ensures:
- */
-extern bool rmm_free(struct rmm_target_obj *target, u32 segid, u32 dsp_addr,
-		     u32 size, bool reserved);
-
-/*
- *  ======== rmm_stat ========
- *  Obtain  memory segment status
- *
- *  Parameters:
- *      segid:       Segment ID of the dynamic loading segment.
- *      mem_stat_buf: Pointer to allocated buffer into which memory stats are
- *                   placed.
- *  Returns:
- *      TRUE:   Success.
- *      FALSE:  Failure.
- *  Requires:
- *      segid < target->num_segs
- *  Ensures:
- */
-extern bool rmm_stat(struct rmm_target_obj *target, enum dsp_memtype segid,
-		     struct dsp_memstat *mem_stat_buf);
-
-#endif /* RMM_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/rms_sh.h b/drivers/staging/tidspbridge/include/dspbridge/rms_sh.h
deleted file mode 100644
index ba7f4784..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/rms_sh.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * rms_sh.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP/BIOS Bridge Resource Manager Server shared definitions (used on both
- * GPP and DSP sides).
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef RMS_SH_
-#define RMS_SH_
-
-#include <dspbridge/rmstypes.h>
-
-/* Memory Types: */
-#define RMS_CODE                0	/* Program space */
-#define RMS_DATA                1	/* Data space */
-
-/* RM Server Command and Response Buffer Sizes: */
-#define RMS_COMMANDBUFSIZE     256	/* Size of command buffer */
-
-/* Pre-Defined Command/Response Codes: */
-#define RMS_EXIT                0x80000000	/* GPP->Node: shutdown */
-#define RMS_EXITACK             0x40000000	/* Node->GPP: ack shutdown */
-#define RMS_BUFDESC             0x20000000	/* Arg1 SM buf, Arg2 SM size */
-#define RMS_KILLTASK            0x10000000	/* GPP->Node: Kill Task */
-
-/* RM Server RPC Command Structure: */
-struct rms_command {
-	rms_word fxn;		/* Server function address */
-	rms_word arg1;		/* First argument */
-	rms_word arg2;		/* Second argument */
-	rms_word data;		/* Function-specific data array */
-};
-
-/*
- *  The rms_strm_def structure defines the parameters for both input and output
- *  streams, and is passed to a node's create function.
- */
-struct rms_strm_def {
-	rms_word bufsize;	/* Buffer size (in DSP words) */
-	rms_word nbufs;		/* Max number of bufs in stream */
-	rms_word segid;		/* Segment to allocate buffers */
-	rms_word align;		/* Alignment for allocated buffers */
-	rms_word timeout;	/* Timeout (msec) for blocking calls */
-	char name[1];	/* Device Name (terminated by '\0') */
-};
-
-/* Message node create args structure: */
-struct rms_msg_args {
-	rms_word max_msgs;	/* Max # simultaneous msgs to node */
-	rms_word segid;		/* Mem segment for NODE_allocMsgBuf */
-	rms_word notify_type;	/* Type of message notification */
-	rms_word arg_length;	/* Length (in DSP chars) of arg data */
-	rms_word arg_data;	/* Arg data for node */
-};
-
-/* Partial task create args structure */
-struct rms_more_task_args {
-	rms_word priority;	/* Task's runtime priority level */
-	rms_word stack_size;	/* Task's stack size */
-	rms_word sysstack_size;	/* Task's system stack size (55x) */
-	rms_word stack_seg;	/* Memory segment for task's stack */
-	rms_word heap_addr;	/* base address of the node memory heap in
-				 * external memory (DSP virtual address) */
-	rms_word heap_size;	/* size in MAUs of the node memory heap in
-				 * external memory */
-	rms_word misc;		/* Misc field.  Not used for 'normal'
-				 * task nodes; for xDAIS socket nodes
-				 * specifies the IALG_Fxn pointer.
-				 */
-	/* # input STRM definition structures */
-	rms_word num_input_streams;
-};
-
-#endif /* RMS_SH_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/rmstypes.h b/drivers/staging/tidspbridge/include/dspbridge/rmstypes.h
deleted file mode 100644
index 83c0f1d..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/rmstypes.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * rmstypes.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP/BIOS Bridge Resource Manager Server shared data type definitions.
- *
- * Copyright (C) 2008 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef RMSTYPES_
-#define RMSTYPES_
-#include <linux/types.h>
-typedef u32 rms_word;
-
-#endif /* RMSTYPES_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/strm.h b/drivers/staging/tidspbridge/include/dspbridge/strm.h
deleted file mode 100644
index 97aee4c..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/strm.h
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * strm.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSPBridge Stream Manager.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef STRM_
-#define STRM_
-
-#include <dspbridge/dev.h>
-
-#include <dspbridge/strmdefs.h>
-#include <dspbridge/proc.h>
-
-/*
- *  ======== strm_allocate_buffer ========
- *  Purpose:
- *      Allocate data buffer(s) for use with a stream.
- *  Parameter:
- *      strmres:     Stream resource info handle returned from strm_open().
- *      usize:          Size (GPP bytes) of the buffer(s).
- *      num_bufs:       Number of buffers to allocate.
- *      ap_buffer:       Array to hold buffer addresses.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid stream_obj.
- *      -ENOMEM:    Insufficient memory.
- *      -EPERM:      Failure occurred, unable to allocate buffers.
- *      -EINVAL:      usize must be > 0 bytes.
- *  Requires:
- *      ap_buffer != NULL.
- *  Ensures:
- */
-extern int strm_allocate_buffer(struct strm_res_object *strmres,
-				       u32 usize,
-				       u8 **ap_buffer,
-				       u32 num_bufs,
-				       struct process_context *pr_ctxt);
-
-/*
- *  ======== strm_close ========
- *  Purpose:
- *      Close a stream opened with strm_open().
- *  Parameter:
- *      strmres:          Stream resource info handle returned from strm_open().
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid stream_obj.
- *      -EPIPE:   Some data buffers issued to the stream have not
- *                      been reclaimed.
- *      -EPERM:      Failure to close stream.
- *  Requires:
- *  Ensures:
- */
-extern int strm_close(struct strm_res_object *strmres,
-			     struct process_context *pr_ctxt);
-
-/*
- *  ======== strm_create ========
- *  Purpose:
- *      Create a STRM manager object. This object holds information about the
- *      device needed to open streams.
- *  Parameters:
- *      strm_man:       Location to store handle to STRM manager object on
- *                      output.
- *      dev_obj:           Device for this processor.
- *  Returns:
- *      0:        Success;
- *      -ENOMEM:    Insufficient memory for requested resources.
- *      -EPERM:      General failure.
- *  Requires:
- *      strm_man != NULL.
- *      dev_obj != NULL.
- *  Ensures:
- *      0:        Valid *strm_man.
- *      error:          *strm_man == NULL.
- */
-extern int strm_create(struct strm_mgr **strm_man,
-			      struct dev_object *dev_obj);
-
-/*
- *  ======== strm_delete ========
- *  Purpose:
- *      Delete the STRM Object.
- *  Parameters:
- *      strm_mgr_obj:       Handle to STRM manager object from strm_create.
- *  Returns:
- *  Requires:
- *      Valid strm_mgr_obj.
- *  Ensures:
- *      strm_mgr_obj is not valid.
- */
-extern void strm_delete(struct strm_mgr *strm_mgr_obj);
-
-/*
- *  ======== strm_free_buffer ========
- *  Purpose:
- *      Free buffer(s) allocated with strm_allocate_buffer.
- *  Parameter:
- *      strmres:     Stream resource info handle returned from strm_open().
- *      ap_buffer:       Array containing buffer addresses.
- *      num_bufs:       Number of buffers to be freed.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid stream handle.
- *      -EPERM:      Failure occurred, unable to free buffers.
- *  Requires:
- *      ap_buffer != NULL.
- *  Ensures:
- */
-extern int strm_free_buffer(struct strm_res_object *strmres,
-				   u8 **ap_buffer, u32 num_bufs,
-				   struct process_context *pr_ctxt);
-
-/*
- *  ======== strm_get_info ========
- *  Purpose:
- *      Get information about a stream. User's dsp_streaminfo is contained
- *      in stream_info struct. stream_info also contains Bridge private info.
- *  Parameters:
- *      stream_obj:         Stream handle returned from strm_open().
- *      stream_info:        Location to store stream info on output.
- *      uSteamInfoSize:     Size of user's dsp_streaminfo structure.
- *  Returns:
- *      0:            Success.
- *      -EFAULT:        Invalid stream_obj.
- *      -EINVAL:          stream_info_size < sizeof(dsp_streaminfo).
- *      -EPERM:          Unable to get stream info.
- *  Requires:
- *      stream_info != NULL.
- *  Ensures:
- */
-extern int strm_get_info(struct strm_object *stream_obj,
-				struct stream_info *stream_info,
-				u32 stream_info_size);
-
-/*
- *  ======== strm_idle ========
- *  Purpose:
- *      Idle a stream and optionally flush output data buffers.
- *      If this is an output stream and flush_data is TRUE, all data currently
- *      enqueued will be discarded.
- *      If this is an output stream and flush_data is FALSE, this function
- *      will block until all currently buffered data is output, or the timeout
- *      specified has been reached.
- *      After a successful call to strm_idle(), all buffers can immediately
- *      be reclaimed.
- *  Parameters:
- *      stream_obj:     Stream handle returned from strm_open().
- *      flush_data:     If TRUE, discard output buffers.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid stream_obj.
- *      -ETIME:   A timeout occurred before the stream could be idled.
- *      -EPERM:      Unable to idle stream.
- *  Requires:
- *  Ensures:
- */
-extern int strm_idle(struct strm_object *stream_obj, bool flush_data);
-
-/*
- *  ======== strm_issue ========
- *  Purpose:
- *      Send a buffer of data to a stream.
- *  Parameters:
- *      stream_obj:         Stream handle returned from strm_open().
- *      pbuf:               Pointer to buffer of data to be sent to the stream.
- *      ul_bytes:            Number of bytes of data in the buffer.
- *      ul_buf_size:          Actual buffer size in bytes.
- *      dw_arg:              A user argument that travels with the buffer.
- *  Returns:
- *      0:            Success.
- *      -EFAULT:        Invalid stream_obj.
- *      -ENOSR:    The stream is full.
- *      -EPERM:          Failure occurred, unable to issue buffer.
- *  Requires:
-*      pbuf != NULL.
- *  Ensures:
- */
-extern int strm_issue(struct strm_object *stream_obj, u8 * pbuf,
-			     u32 ul_bytes, u32 ul_buf_size, u32 dw_arg);
-
-/*
- *  ======== strm_open ========
- *  Purpose:
- *      Open a stream for sending/receiving data buffers to/from a task of
- *      DAIS socket node on the DSP.
- *  Parameters:
- *      hnode:          Node handle returned from node_allocate().
- *      dir:           DSP_TONODE or DSP_FROMNODE.
- *      index:         Stream index.
- *      pattr:          Pointer to structure containing attributes to be
- *                      applied to stream. Cannot be NULL.
- *      strmres:     Location to store stream resource info handle on output.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid hnode.
- *      -EPERM: Invalid direction.
- *              hnode is not a task or DAIS socket node.
- *              Unable to open stream.
- *      -EINVAL:     Invalid index.
- *  Requires:
- *      strmres != NULL.
- *      pattr != NULL.
- *  Ensures:
- *      0:        *strmres is valid.
- *      error:          *strmres == NULL.
- */
-extern int strm_open(struct node_object *hnode, u32 dir,
-			    u32 index, struct strm_attr *pattr,
-			    struct strm_res_object **strmres,
-			    struct process_context *pr_ctxt);
-
-/*
- *  ======== strm_reclaim ========
- *  Purpose:
- *      Request a buffer back from a stream.
- *  Parameters:
- *      stream_obj:          Stream handle returned from strm_open().
- *      buf_ptr:        Location to store pointer to reclaimed buffer.
- *      nbytes:         Location where number of bytes of data in the
- *                      buffer will be written.
- *      buff_size:      Location where actual buffer size will be written.
- *      pdw_arg:         Location where user argument that travels with
- *                      the buffer will be written.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid stream_obj.
- *      -ETIME:   A timeout occurred before a buffer could be
- *                      retrieved.
- *      -EPERM:      Failure occurred, unable to reclaim buffer.
- *  Requires:
- *      buf_ptr != NULL.
- *      nbytes != NULL.
- *      pdw_arg != NULL.
- *  Ensures:
- */
-extern int strm_reclaim(struct strm_object *stream_obj,
-			       u8 **buf_ptr, u32 * nbytes,
-			       u32 *buff_size, u32 *pdw_arg);
-
-/*
- *  ======== strm_register_notify ========
- *  Purpose:
- *      Register to be notified on specific events for this stream.
- *  Parameters:
- *      stream_obj:     Stream handle returned by strm_open().
- *      event_mask:     Mask of types of events to be notified about.
- *      notify_type:    Type of notification to be sent.
- *      hnotification:  Handle to be used for notification.
- *  Returns:
- *      0:        Success.
- *      -EFAULT:    Invalid stream_obj.
- *      -ENOMEM:    Insufficient memory on GPP.
- *      -EINVAL:     event_mask is invalid.
- *      -ENOSYS:   Notification type specified by notify_type is not
- *                      supported.
- *  Requires:
- *      hnotification != NULL.
- *  Ensures:
- */
-extern int strm_register_notify(struct strm_object *stream_obj,
-				       u32 event_mask, u32 notify_type,
-				       struct dsp_notification
-				       *hnotification);
-
-/*
- *  ======== strm_select ========
- *  Purpose:
- *      Select a ready stream.
- *  Parameters:
- *      strm_tab:       Array of stream handles returned from strm_open().
- *      strms:          Number of stream handles in array.
- *      pmask:          Location to store mask of ready streams on output.
- *      utimeout:       Timeout value (milliseconds).
- *  Returns:
- *      0:        Success.
- *      -EDOM:     strms out of range.
-
- *      -EFAULT:    Invalid stream handle in array.
- *      -ETIME:   A timeout occurred before a stream became ready.
- *      -EPERM:      Failure occurred, unable to select a stream.
- *  Requires:
- *      strm_tab != NULL.
- *      strms > 0.
- *      pmask != NULL.
- *  Ensures:
- *      0:        *pmask != 0 || utimeout == 0.
- *      Error:          *pmask == 0.
- */
-extern int strm_select(struct strm_object **strm_tab,
-			      u32 strms, u32 *pmask, u32 utimeout);
-
-#endif /* STRM_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/strmdefs.h b/drivers/staging/tidspbridge/include/dspbridge/strmdefs.h
deleted file mode 100644
index 4f90e6b..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/strmdefs.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * strmdefs.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Global STRM constants and types.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef STRMDEFS_
-#define STRMDEFS_
-
-struct strm_mgr;
-
-struct strm_object;
-
-struct strm_attr {
-	void *user_event;
-	char *str_event_name;
-	void *virt_base;	/* Process virtual base address of
-				 * mapped SM */
-	u32 virt_size;		/* Size of virtual space in bytes */
-	struct dsp_streamattrin *stream_attr_in;
-};
-
-struct stream_info {
-	enum dsp_strmmode strm_mode;	/* transport mode of
-					 * stream(DMA, ZEROCOPY..) */
-	u32 segment_id;		/* Segment strm allocs from. 0 is local mem */
-	void *virt_base;	/* "      " Stream'process virt base */
-	struct dsp_streaminfo *user_strm;	/* User's stream information
-						 * returned */
-};
-
-#endif /* STRMDEFS_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/sync.h b/drivers/staging/tidspbridge/include/dspbridge/sync.h
deleted file mode 100644
index fc19b97..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/sync.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * sync.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Provide synchronization services.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef _SYNC_H
-#define _SYNC_H
-
-#include <dspbridge/dbdefs.h>
-#include <dspbridge/host_os.h>
-
-
-/* Special timeout value indicating an infinite wait: */
-#define SYNC_INFINITE  0xffffffff
-
-/**
- * struct sync_object - the basic sync_object structure
- * @comp:	use to signal events
- * @multi_comp:	use to signal multiple events.
- *
- */
-struct sync_object{
-	struct completion comp;
-	struct completion *multi_comp;
-};
-
-/**
- * sync_init_event() - set initial state for a sync_event element
- * @event:	event to be initialized.
- *
- * Set the initial state for a sync_event element.
- */
-
-static inline void sync_init_event(struct sync_object *event)
-{
-	init_completion(&event->comp);
-	event->multi_comp = NULL;
-}
-
-/**
- * sync_reset_event() - reset a sync_event element
- * @event:	event to be reset.
- *
- * This function reset to the initial state to @event.
- */
-
-static inline void sync_reset_event(struct sync_object *event)
-{
-	reinit_completion(&event->comp);
-	event->multi_comp = NULL;
-}
-
-/**
- * sync_set_event() - set or signal and specified event
- * @event:	Event to be set..
- *
- * set the @event, if there is an thread waiting for the event
- * it will be waken up, this function only wakes one thread.
- */
-
-void sync_set_event(struct sync_object *event);
-
-/**
- * sync_wait_on_event() - waits for a event to be set.
- * @event:	events to wait for it.
- * @timeout	timeout on waiting for the evetn.
- *
- * This function will wait until @event is set or until timeout. In case of
- * success the function will return 0 and
- * in case of timeout the function will return -ETIME
- * in case of signal the function will return -ERESTARTSYS
- */
-
-static inline int sync_wait_on_event(struct sync_object *event,
-							unsigned timeout)
-{
-	int res;
-
-	res = wait_for_completion_interruptible_timeout(&event->comp,
-						msecs_to_jiffies(timeout));
-	if (!res)
-		res = -ETIME;
-	else if (res > 0)
-		res = 0;
-
-	return res;
-}
-
-/**
- * sync_wait_on_multiple_events() - waits for multiple events to be set.
- * @events:	Array of events to wait for them.
- * @count:	number of elements of the array.
- * @timeout	timeout on waiting for the evetns.
- * @pu_index	index of the event set.
- *
- * This function will wait until any of the array element is set or until
- * timeout. In case of success the function will return 0 and
- * @pu_index will store the index of the array element set and in case
- * of timeout the function will return -ETIME.
- */
-
-int sync_wait_on_multiple_events(struct sync_object **events,
-				     unsigned count, unsigned timeout,
-				     unsigned *index);
-
-#endif /* _SYNC_H */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h b/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h
deleted file mode 100644
index b4951a1..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * uuidutil.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * This file contains the specification of UUID helper functions.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef UUIDUTIL_
-#define UUIDUTIL_
-
-#define MAXUUIDLEN  37
-
-#endif /* UUIDUTIL_ */
diff --git a/drivers/staging/tidspbridge/include/dspbridge/wdt.h b/drivers/staging/tidspbridge/include/dspbridge/wdt.h
deleted file mode 100644
index 36193db..0000000
--- a/drivers/staging/tidspbridge/include/dspbridge/wdt.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * wdt.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * IO dispatcher for a shared memory channel driver.
- *
- * Copyright (C) 2010 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#ifndef __DSP_WDT3_H_
-#define __DSP_WDT3_H_
-
-/* WDT defines */
-#define OMAP3_WDT3_ISR_OFFSET	0x0018
-
-
-/**
- * struct dsp_wdt_setting - the basic dsp_wdt_setting structure
- * @reg_base:	pointer to the base of the wdt registers
- * @sm_wdt:	pointer to flags in shared memory
- * @wdt3_tasklet	tasklet to manage wdt event
- * @fclk		handle to wdt3 functional clock
- * @iclk		handle to wdt3 interface clock
- *
- * This struct is used in the function to manage wdt3.
- */
-
-struct dsp_wdt_setting {
-	void __iomem *reg_base;
-	struct shm *sm_wdt;
-	struct tasklet_struct wdt3_tasklet;
-	struct clk *fclk;
-	struct clk *iclk;
-};
-
-/**
- * dsp_wdt_init() - initialize wdt3 module.
- *
- * This function initialize to wdt3 module, so that
- * other wdt3 function can be used.
- */
-int dsp_wdt_init(void);
-
-/**
- * dsp_wdt_exit() - initialize wdt3 module.
- *
- * This function frees all resources allocated for wdt3 module.
- */
-void dsp_wdt_exit(void);
-
-/**
- * dsp_wdt_enable() - enable/disable wdt3
- * @enable:	bool value to enable/disable wdt3
- *
- * This function enables or disables wdt3 base on @enable value.
- *
- */
-void dsp_wdt_enable(bool enable);
-
-/**
- * dsp_wdt_sm_set() - store pointer to the share memory
- * @data:		pointer to dspbridge share memory
- *
- * This function is used to pass a valid pointer to share memory,
- * so that the flags can be set in order DSP side can read them.
- *
- */
-void dsp_wdt_sm_set(void *data);
-
-#endif
-
diff --git a/drivers/staging/tidspbridge/pmgr/chnl.c b/drivers/staging/tidspbridge/pmgr/chnl.c
deleted file mode 100644
index e03c326..0000000
--- a/drivers/staging/tidspbridge/pmgr/chnl.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * chnl.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP API channel interface: multiplexes data streams through the single
- * physical link managed by a Bridge Bridge driver.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/types.h>
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/sync.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/proc.h>
-#include <dspbridge/dev.h>
-
-/*  ----------------------------------- Others */
-#include <dspbridge/chnlpriv.h>
-#include <chnlobj.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/chnl.h>
-
-/*
- *  ======== chnl_create ========
- *  Purpose:
- *      Create a channel manager object, responsible for opening new channels
- *      and closing old ones for a given 'Bridge board.
- */
-int chnl_create(struct chnl_mgr **channel_mgr,
-		       struct dev_object *hdev_obj,
-		       const struct chnl_mgrattrs *mgr_attrts)
-{
-	int status;
-	struct chnl_mgr *hchnl_mgr;
-	struct chnl_mgr_ *chnl_mgr_obj = NULL;
-
-	*channel_mgr = NULL;
-
-	/* Validate args: */
-	if ((0 < mgr_attrts->max_channels) &&
-	    (mgr_attrts->max_channels <= CHNL_MAXCHANNELS))
-		status = 0;
-	else if (mgr_attrts->max_channels == 0)
-		status = -EINVAL;
-	else
-		status = -ECHRNG;
-
-	if (mgr_attrts->word_size == 0)
-		status = -EINVAL;
-
-	if (!status) {
-		status = dev_get_chnl_mgr(hdev_obj, &hchnl_mgr);
-		if (!status && hchnl_mgr != NULL)
-			status = -EEXIST;
-
-	}
-
-	if (!status) {
-		struct bridge_drv_interface *intf_fxns;
-
-		dev_get_intf_fxns(hdev_obj, &intf_fxns);
-		/* Let Bridge channel module finish the create: */
-		status = (*intf_fxns->chnl_create) (&hchnl_mgr, hdev_obj,
-							mgr_attrts);
-		if (!status) {
-			/* Fill in DSP API channel module's fields of the
-			 * chnl_mgr structure */
-			chnl_mgr_obj = (struct chnl_mgr_ *)hchnl_mgr;
-			chnl_mgr_obj->intf_fxns = intf_fxns;
-			/* Finally, return the new channel manager handle: */
-			*channel_mgr = hchnl_mgr;
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== chnl_destroy ========
- *  Purpose:
- *      Close all open channels, and destroy the channel manager.
- */
-int chnl_destroy(struct chnl_mgr *hchnl_mgr)
-{
-	struct chnl_mgr_ *chnl_mgr_obj = (struct chnl_mgr_ *)hchnl_mgr;
-	struct bridge_drv_interface *intf_fxns;
-	int status;
-
-	if (chnl_mgr_obj) {
-		intf_fxns = chnl_mgr_obj->intf_fxns;
-		/* Let Bridge channel module destroy the chnl_mgr: */
-		status = (*intf_fxns->chnl_destroy) (hchnl_mgr);
-	} else {
-		status = -EFAULT;
-	}
-
-	return status;
-}
diff --git a/drivers/staging/tidspbridge/pmgr/chnlobj.h b/drivers/staging/tidspbridge/pmgr/chnlobj.h
deleted file mode 100644
index 6795e0a..0000000
--- a/drivers/staging/tidspbridge/pmgr/chnlobj.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * chnlobj.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Structure subcomponents of channel class library channel objects which
- * are exposed to DSP API from Bridge driver.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef CHNLOBJ_
-#define CHNLOBJ_
-
-#include <dspbridge/chnldefs.h>
-#include <dspbridge/dspdefs.h>
-
-/*
- *  This struct is the first field in a chnl_mgr struct. Other. implementation
- *  specific fields follow this structure in memory.
- */
-struct chnl_mgr_ {
-	/* These must be the first fields in a chnl_mgr struct: */
-
-	/* Function interface to Bridge driver. */
-	struct bridge_drv_interface *intf_fxns;
-};
-
-/*
- *  This struct is the first field in a chnl_object struct. Other,
- *  implementation specific fields follow this structure in memory.
- */
-struct chnl_object_ {
-	/* These must be the first fields in a chnl_object struct: */
-	struct chnl_mgr_ *chnl_mgr_obj;	/* Pointer back to channel manager. */
-};
-
-#endif /* CHNLOBJ_ */
diff --git a/drivers/staging/tidspbridge/pmgr/cmm.c b/drivers/staging/tidspbridge/pmgr/cmm.c
deleted file mode 100644
index f961e0e..0000000
--- a/drivers/staging/tidspbridge/pmgr/cmm.c
+++ /dev/null
@@ -1,915 +0,0 @@
-/*
- * cmm.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * The Communication(Shared) Memory Management(CMM) module provides
- * shared memory management services for DSP/BIOS Bridge data streaming
- * and messaging.
- *
- * Multiple shared memory segments can be registered with CMM.
- * Each registered SM segment is represented by a SM "allocator" that
- * describes a block of physically contiguous shared memory used for
- * future allocations by CMM.
- *
- * Memory is coalesced back to the appropriate heap when a buffer is
- * freed.
- *
- * Notes:
- *   Va: Virtual address.
- *   Pa: Physical or kernel system address.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#include <linux/types.h>
-#include <linux/list.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/sync.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/dev.h>
-#include <dspbridge/proc.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/cmm.h>
-
-/*  ----------------------------------- Defines, Data Structures, Typedefs */
-#define NEXT_PA(pnode)   (pnode->pa + pnode->size)
-
-/* Other bus/platform translations */
-#define DSPPA2GPPPA(base, x, y)  ((x)+(y))
-#define GPPPA2DSPPA(base, x, y)  ((x)-(y))
-
-/*
- *  Allocators define a block of contiguous memory used for future allocations.
- *
- *      sma - shared memory allocator.
- *      vma - virtual memory allocator.(not used).
- */
-struct cmm_allocator {		/* sma */
-	unsigned int shm_base;	/* Start of physical SM block */
-	u32 sm_size;		/* Size of SM block in bytes */
-	unsigned int vm_base;	/* Start of VM block. (Dev driver
-					 * context for 'sma') */
-	u32 dsp_phys_addr_offset;	/* DSP PA to GPP PA offset for this
-					 * SM space */
-	s8 c_factor;		/* DSPPa to GPPPa Conversion Factor */
-	unsigned int dsp_base;	/* DSP virt base byte address */
-	u32 dsp_size;	/* DSP seg size in bytes */
-	struct cmm_object *cmm_mgr;	/* back ref to parent mgr */
-	/* node list of available memory */
-	struct list_head free_list;
-	/* node list of memory in use */
-	struct list_head in_use_list;
-};
-
-struct cmm_xlator {		/* Pa<->Va translator object */
-	/* CMM object this translator associated */
-	struct cmm_object *cmm_mgr;
-	/*
-	 *  Client process virtual base address that corresponds to phys SM
-	 *  base address for translator's seg_id.
-	 *  Only 1 segment ID currently supported.
-	 */
-	unsigned int virt_base;	/* virtual base address */
-	u32 virt_size;		/* size of virt space in bytes */
-	u32 seg_id;		/* Segment Id */
-};
-
-/* CMM Mgr */
-struct cmm_object {
-	/*
-	 * Cmm Lock is used to serialize access mem manager for multi-threads.
-	 */
-	struct mutex cmm_lock;	/* Lock to access cmm mgr */
-	struct list_head node_free_list;	/* Free list of memory nodes */
-	u32 min_block_size;	/* Min SM block; default 16 bytes */
-	u32 page_size;	/* Memory Page size (1k/4k) */
-	/* GPP SM segment ptrs */
-	struct cmm_allocator *pa_gppsm_seg_tab[CMM_MAXGPPSEGS];
-};
-
-/* Default CMM Mgr attributes */
-static struct cmm_mgrattrs cmm_dfltmgrattrs = {
-	/* min_block_size, min block size(bytes) allocated by cmm mgr */
-	16
-};
-
-/* Default allocation attributes */
-static struct cmm_attrs cmm_dfltalctattrs = {
-	1		/* seg_id, default segment Id for allocator */
-};
-
-/* Address translator default attrs */
-static struct cmm_xlatorattrs cmm_dfltxlatorattrs = {
-	/* seg_id, does not have to match cmm_dfltalctattrs ul_seg_id */
-	1,
-	0,			/* dsp_bufs */
-	0,			/* dsp_buf_size */
-	NULL,			/* vm_base */
-	0,			/* vm_size */
-};
-
-/* SM node representing a block of memory. */
-struct cmm_mnode {
-	struct list_head link;	/* must be 1st element */
-	u32 pa;		/* Phys addr */
-	u32 va;			/* Virtual address in device process context */
-	u32 size;		/* SM block size in bytes */
-	u32 client_proc;	/* Process that allocated this mem block */
-};
-
-/*  ----------------------------------- Function Prototypes */
-static void add_to_free_list(struct cmm_allocator *allocator,
-			     struct cmm_mnode *pnode);
-static struct cmm_allocator *get_allocator(struct cmm_object *cmm_mgr_obj,
-					   u32 ul_seg_id);
-static struct cmm_mnode *get_free_block(struct cmm_allocator *allocator,
-					u32 usize);
-static struct cmm_mnode *get_node(struct cmm_object *cmm_mgr_obj, u32 dw_pa,
-				  u32 dw_va, u32 ul_size);
-/* get available slot for new allocator */
-static s32 get_slot(struct cmm_object *cmm_mgr_obj);
-static void un_register_gppsm_seg(struct cmm_allocator *psma);
-
-/*
- *  ======== cmm_calloc_buf ========
- *  Purpose:
- *      Allocate a SM buffer, zero contents, and return the physical address
- *      and optional driver context virtual address(pp_buf_va).
- *
- *      The freelist is sorted in increasing size order. Get the first
- *      block that satifies the request and sort the remaining back on
- *      the freelist; if large enough. The kept block is placed on the
- *      inUseList.
- */
-void *cmm_calloc_buf(struct cmm_object *hcmm_mgr, u32 usize,
-		     struct cmm_attrs *pattrs, void **pp_buf_va)
-{
-	struct cmm_object *cmm_mgr_obj = (struct cmm_object *)hcmm_mgr;
-	void *buf_pa = NULL;
-	struct cmm_mnode *pnode = NULL;
-	struct cmm_mnode *new_node = NULL;
-	struct cmm_allocator *allocator = NULL;
-	u32 delta_size;
-	u8 *pbyte = NULL;
-	s32 cnt;
-
-	if (pattrs == NULL)
-		pattrs = &cmm_dfltalctattrs;
-
-	if (pp_buf_va != NULL)
-		*pp_buf_va = NULL;
-
-	if (cmm_mgr_obj && (usize != 0)) {
-		if (pattrs->seg_id > 0) {
-			/* SegId > 0 is SM */
-			/* get the allocator object for this segment id */
-			allocator =
-			    get_allocator(cmm_mgr_obj, pattrs->seg_id);
-			/* keep block size a multiple of min_block_size */
-			usize =
-			    ((usize - 1) & ~(cmm_mgr_obj->min_block_size -
-					     1))
-			    + cmm_mgr_obj->min_block_size;
-			mutex_lock(&cmm_mgr_obj->cmm_lock);
-			pnode = get_free_block(allocator, usize);
-		}
-		if (pnode) {
-			delta_size = (pnode->size - usize);
-			if (delta_size >= cmm_mgr_obj->min_block_size) {
-				/* create a new block with the leftovers and
-				 * add to freelist */
-				new_node =
-				    get_node(cmm_mgr_obj, pnode->pa + usize,
-					     pnode->va + usize,
-					     (u32) delta_size);
-				/* leftovers go free */
-				add_to_free_list(allocator, new_node);
-				/* adjust our node's size */
-				pnode->size = usize;
-			}
-			/* Tag node with client process requesting allocation
-			 * We'll need to free up a process's alloc'd SM if the
-			 * client process goes away.
-			 */
-			/* Return TGID instead of process handle */
-			pnode->client_proc = current->tgid;
-
-			/* put our node on InUse list */
-			list_add_tail(&pnode->link, &allocator->in_use_list);
-			buf_pa = (void *)pnode->pa;	/* physical address */
-			/* clear mem */
-			pbyte = (u8 *) pnode->va;
-			for (cnt = 0; cnt < (s32) usize; cnt++, pbyte++)
-				*pbyte = 0;
-
-			if (pp_buf_va != NULL) {
-				/* Virtual address */
-				*pp_buf_va = (void *)pnode->va;
-			}
-		}
-		mutex_unlock(&cmm_mgr_obj->cmm_lock);
-	}
-	return buf_pa;
-}
-
-/*
- *  ======== cmm_create ========
- *  Purpose:
- *      Create a communication memory manager object.
- */
-int cmm_create(struct cmm_object **ph_cmm_mgr,
-		      struct dev_object *hdev_obj,
-		      const struct cmm_mgrattrs *mgr_attrts)
-{
-	struct cmm_object *cmm_obj = NULL;
-	int status = 0;
-
-	*ph_cmm_mgr = NULL;
-	/* create, zero, and tag a cmm mgr object */
-	cmm_obj = kzalloc(sizeof(struct cmm_object), GFP_KERNEL);
-	if (!cmm_obj)
-		return -ENOMEM;
-
-	if (mgr_attrts == NULL)
-		mgr_attrts = &cmm_dfltmgrattrs;	/* set defaults */
-
-	/* save away smallest block allocation for this cmm mgr */
-	cmm_obj->min_block_size = mgr_attrts->min_block_size;
-	cmm_obj->page_size = PAGE_SIZE;
-
-	/* create node free list */
-	INIT_LIST_HEAD(&cmm_obj->node_free_list);
-	mutex_init(&cmm_obj->cmm_lock);
-	*ph_cmm_mgr = cmm_obj;
-
-	return status;
-}
-
-/*
- *  ======== cmm_destroy ========
- *  Purpose:
- *      Release the communication memory manager resources.
- */
-int cmm_destroy(struct cmm_object *hcmm_mgr, bool force)
-{
-	struct cmm_object *cmm_mgr_obj = (struct cmm_object *)hcmm_mgr;
-	struct cmm_info temp_info;
-	int status = 0;
-	s32 slot_seg;
-	struct cmm_mnode *node, *tmp;
-
-	if (!hcmm_mgr) {
-		status = -EFAULT;
-		return status;
-	}
-	mutex_lock(&cmm_mgr_obj->cmm_lock);
-	/* If not force then fail if outstanding allocations exist */
-	if (!force) {
-		/* Check for outstanding memory allocations */
-		status = cmm_get_info(hcmm_mgr, &temp_info);
-		if (!status) {
-			if (temp_info.total_in_use_cnt > 0) {
-				/* outstanding allocations */
-				status = -EPERM;
-			}
-		}
-	}
-	if (!status) {
-		/* UnRegister SM allocator */
-		for (slot_seg = 0; slot_seg < CMM_MAXGPPSEGS; slot_seg++) {
-			if (cmm_mgr_obj->pa_gppsm_seg_tab[slot_seg] != NULL) {
-				un_register_gppsm_seg
-				    (cmm_mgr_obj->pa_gppsm_seg_tab[slot_seg]);
-				/* Set slot to NULL for future reuse */
-				cmm_mgr_obj->pa_gppsm_seg_tab[slot_seg] = NULL;
-			}
-		}
-	}
-	list_for_each_entry_safe(node, tmp, &cmm_mgr_obj->node_free_list,
-			link) {
-		list_del(&node->link);
-		kfree(node);
-	}
-	mutex_unlock(&cmm_mgr_obj->cmm_lock);
-	if (!status) {
-		/* delete CS & cmm mgr object */
-		mutex_destroy(&cmm_mgr_obj->cmm_lock);
-		kfree(cmm_mgr_obj);
-	}
-	return status;
-}
-
-/*
- *  ======== cmm_free_buf ========
- *  Purpose:
- *      Free the given buffer.
- */
-int cmm_free_buf(struct cmm_object *hcmm_mgr, void *buf_pa, u32 ul_seg_id)
-{
-	struct cmm_object *cmm_mgr_obj = (struct cmm_object *)hcmm_mgr;
-	int status = -EFAULT;
-	struct cmm_mnode *curr, *tmp;
-	struct cmm_allocator *allocator;
-	struct cmm_attrs *pattrs;
-
-	if (ul_seg_id == 0) {
-		pattrs = &cmm_dfltalctattrs;
-		ul_seg_id = pattrs->seg_id;
-	}
-	if (!hcmm_mgr || !(ul_seg_id > 0)) {
-		status = -EFAULT;
-		return status;
-	}
-
-	allocator = get_allocator(cmm_mgr_obj, ul_seg_id);
-	if (!allocator)
-		return status;
-
-	mutex_lock(&cmm_mgr_obj->cmm_lock);
-	list_for_each_entry_safe(curr, tmp, &allocator->in_use_list, link) {
-		if (curr->pa == (u32) buf_pa) {
-			list_del(&curr->link);
-			add_to_free_list(allocator, curr);
-			status = 0;
-			break;
-		}
-	}
-	mutex_unlock(&cmm_mgr_obj->cmm_lock);
-
-	return status;
-}
-
-/*
- *  ======== cmm_get_handle ========
- *  Purpose:
- *      Return the communication memory manager object for this device.
- *      This is typically called from the client process.
- */
-int cmm_get_handle(void *hprocessor, struct cmm_object **ph_cmm_mgr)
-{
-	int status = 0;
-	struct dev_object *hdev_obj;
-
-	if (hprocessor != NULL)
-		status = proc_get_dev_object(hprocessor, &hdev_obj);
-	else
-		hdev_obj = dev_get_first();	/* default */
-
-	if (!status)
-		status = dev_get_cmm_mgr(hdev_obj, ph_cmm_mgr);
-
-	return status;
-}
-
-/*
- *  ======== cmm_get_info ========
- *  Purpose:
- *      Return the current memory utilization information.
- */
-int cmm_get_info(struct cmm_object *hcmm_mgr,
-			struct cmm_info *cmm_info_obj)
-{
-	struct cmm_object *cmm_mgr_obj = (struct cmm_object *)hcmm_mgr;
-	u32 ul_seg;
-	int status = 0;
-	struct cmm_allocator *altr;
-	struct cmm_mnode *curr;
-
-	if (!hcmm_mgr) {
-		status = -EFAULT;
-		return status;
-	}
-	mutex_lock(&cmm_mgr_obj->cmm_lock);
-	cmm_info_obj->num_gppsm_segs = 0;	/* # of SM segments */
-	/* Total # of outstanding alloc */
-	cmm_info_obj->total_in_use_cnt = 0;
-	/* min block size */
-	cmm_info_obj->min_block_size = cmm_mgr_obj->min_block_size;
-	/* check SM memory segments */
-	for (ul_seg = 1; ul_seg <= CMM_MAXGPPSEGS; ul_seg++) {
-		/* get the allocator object for this segment id */
-		altr = get_allocator(cmm_mgr_obj, ul_seg);
-		if (!altr)
-			continue;
-		cmm_info_obj->num_gppsm_segs++;
-		cmm_info_obj->seg_info[ul_seg - 1].seg_base_pa =
-			altr->shm_base - altr->dsp_size;
-		cmm_info_obj->seg_info[ul_seg - 1].total_seg_size =
-			altr->dsp_size + altr->sm_size;
-		cmm_info_obj->seg_info[ul_seg - 1].gpp_base_pa =
-			altr->shm_base;
-		cmm_info_obj->seg_info[ul_seg - 1].gpp_size =
-			altr->sm_size;
-		cmm_info_obj->seg_info[ul_seg - 1].dsp_base_va =
-			altr->dsp_base;
-		cmm_info_obj->seg_info[ul_seg - 1].dsp_size =
-			altr->dsp_size;
-		cmm_info_obj->seg_info[ul_seg - 1].seg_base_va =
-			altr->vm_base - altr->dsp_size;
-		cmm_info_obj->seg_info[ul_seg - 1].in_use_cnt = 0;
-
-		list_for_each_entry(curr, &altr->in_use_list, link) {
-			cmm_info_obj->total_in_use_cnt++;
-			cmm_info_obj->seg_info[ul_seg - 1].in_use_cnt++;
-		}
-	}
-	mutex_unlock(&cmm_mgr_obj->cmm_lock);
-	return status;
-}
-
-/*
- *  ======== cmm_register_gppsm_seg ========
- *  Purpose:
- *      Register a block of SM with the CMM to be used for later GPP SM
- *      allocations.
- */
-int cmm_register_gppsm_seg(struct cmm_object *hcmm_mgr,
-				  u32 dw_gpp_base_pa, u32 ul_size,
-				  u32 dsp_addr_offset, s8 c_factor,
-				  u32 dw_dsp_base, u32 ul_dsp_size,
-				  u32 *sgmt_id, u32 gpp_base_va)
-{
-	struct cmm_object *cmm_mgr_obj = (struct cmm_object *)hcmm_mgr;
-	struct cmm_allocator *psma = NULL;
-	int status = 0;
-	struct cmm_mnode *new_node;
-	s32 slot_seg;
-
-	dev_dbg(bridge, "%s: dw_gpp_base_pa %x ul_size %x dsp_addr_offset %x dw_dsp_base %x ul_dsp_size %x gpp_base_va %x\n",
-			__func__, dw_gpp_base_pa, ul_size, dsp_addr_offset,
-			dw_dsp_base, ul_dsp_size, gpp_base_va);
-
-	if (!hcmm_mgr)
-		return -EFAULT;
-
-	/* make sure we have room for another allocator */
-	mutex_lock(&cmm_mgr_obj->cmm_lock);
-
-	slot_seg = get_slot(cmm_mgr_obj);
-	if (slot_seg < 0) {
-		status = -EPERM;
-		goto func_end;
-	}
-
-	/* Check if input ul_size is big enough to alloc at least one block */
-	if (ul_size < cmm_mgr_obj->min_block_size) {
-		status = -EINVAL;
-		goto func_end;
-	}
-
-	/* create, zero, and tag an SM allocator object */
-	psma = kzalloc(sizeof(struct cmm_allocator), GFP_KERNEL);
-	if (!psma) {
-		status = -ENOMEM;
-		goto func_end;
-	}
-
-	psma->cmm_mgr = hcmm_mgr;	/* ref to parent */
-	psma->shm_base = dw_gpp_base_pa;	/* SM Base phys */
-	psma->sm_size = ul_size;	/* SM segment size in bytes */
-	psma->vm_base = gpp_base_va;
-	psma->dsp_phys_addr_offset = dsp_addr_offset;
-	psma->c_factor = c_factor;
-	psma->dsp_base = dw_dsp_base;
-	psma->dsp_size = ul_dsp_size;
-	if (psma->vm_base == 0) {
-		status = -EPERM;
-		goto func_end;
-	}
-	/* return the actual segment identifier */
-	*sgmt_id = (u32) slot_seg + 1;
-
-	INIT_LIST_HEAD(&psma->free_list);
-	INIT_LIST_HEAD(&psma->in_use_list);
-
-	/* Get a mem node for this hunk-o-memory */
-	new_node = get_node(cmm_mgr_obj, dw_gpp_base_pa,
-			psma->vm_base, ul_size);
-	/* Place node on the SM allocator's free list */
-	if (new_node) {
-		list_add_tail(&new_node->link, &psma->free_list);
-	} else {
-		status = -ENOMEM;
-		goto func_end;
-	}
-	/* make entry */
-	cmm_mgr_obj->pa_gppsm_seg_tab[slot_seg] = psma;
-
-func_end:
-	/* Cleanup allocator */
-	if (status && psma)
-		un_register_gppsm_seg(psma);
-	mutex_unlock(&cmm_mgr_obj->cmm_lock);
-
-	return status;
-}
-
-/*
- *  ======== cmm_un_register_gppsm_seg ========
- *  Purpose:
- *      UnRegister GPP SM segments with the CMM.
- */
-int cmm_un_register_gppsm_seg(struct cmm_object *hcmm_mgr,
-				     u32 ul_seg_id)
-{
-	struct cmm_object *cmm_mgr_obj = (struct cmm_object *)hcmm_mgr;
-	int status = 0;
-	struct cmm_allocator *psma;
-	u32 ul_id = ul_seg_id;
-
-	if (!hcmm_mgr)
-		return -EFAULT;
-
-	if (ul_seg_id == CMM_ALLSEGMENTS)
-		ul_id = 1;
-
-	if ((ul_id <= 0) || (ul_id > CMM_MAXGPPSEGS))
-		return -EINVAL;
-
-	/*
-	 * FIXME: CMM_MAXGPPSEGS == 1. why use a while cycle? Seems to me like
-	 * the ul_seg_id is not needed here. It must be always 1.
-	 */
-	while (ul_id <= CMM_MAXGPPSEGS) {
-		mutex_lock(&cmm_mgr_obj->cmm_lock);
-		/* slot = seg_id-1 */
-		psma = cmm_mgr_obj->pa_gppsm_seg_tab[ul_id - 1];
-		if (psma != NULL) {
-			un_register_gppsm_seg(psma);
-			/* Set alctr ptr to NULL for future reuse */
-			cmm_mgr_obj->pa_gppsm_seg_tab[ul_id - 1] = NULL;
-		} else if (ul_seg_id != CMM_ALLSEGMENTS) {
-			status = -EPERM;
-		}
-		mutex_unlock(&cmm_mgr_obj->cmm_lock);
-		if (ul_seg_id != CMM_ALLSEGMENTS)
-			break;
-
-		ul_id++;
-	}	/* end while */
-	return status;
-}
-
-/*
- *  ======== un_register_gppsm_seg ========
- *  Purpose:
- *      UnRegister the SM allocator by freeing all its resources and
- *      nulling cmm mgr table entry.
- *  Note:
- *      This routine is always called within cmm lock crit sect.
- */
-static void un_register_gppsm_seg(struct cmm_allocator *psma)
-{
-	struct cmm_mnode *curr, *tmp;
-
-	/* free nodes on free list */
-	list_for_each_entry_safe(curr, tmp, &psma->free_list, link) {
-		list_del(&curr->link);
-		kfree(curr);
-	}
-
-	/* free nodes on InUse list */
-	list_for_each_entry_safe(curr, tmp, &psma->in_use_list, link) {
-		list_del(&curr->link);
-		kfree(curr);
-	}
-
-	if ((void *)psma->vm_base != NULL)
-		MEM_UNMAP_LINEAR_ADDRESS((void *)psma->vm_base);
-
-	/* Free allocator itself */
-	kfree(psma);
-}
-
-/*
- *  ======== get_slot ========
- *  Purpose:
- *      An available slot # is returned. Returns negative on failure.
- */
-static s32 get_slot(struct cmm_object *cmm_mgr_obj)
-{
-	s32 slot_seg = -1;	/* neg on failure */
-	/* get first available slot in cmm mgr SMSegTab[] */
-	for (slot_seg = 0; slot_seg < CMM_MAXGPPSEGS; slot_seg++) {
-		if (cmm_mgr_obj->pa_gppsm_seg_tab[slot_seg] == NULL)
-			break;
-
-	}
-	if (slot_seg == CMM_MAXGPPSEGS)
-		slot_seg = -1;	/* failed */
-
-	return slot_seg;
-}
-
-/*
- *  ======== get_node ========
- *  Purpose:
- *      Get a memory node from freelist or create a new one.
- */
-static struct cmm_mnode *get_node(struct cmm_object *cmm_mgr_obj, u32 dw_pa,
-				  u32 dw_va, u32 ul_size)
-{
-	struct cmm_mnode *pnode;
-
-	/* Check cmm mgr's node freelist */
-	if (list_empty(&cmm_mgr_obj->node_free_list)) {
-		pnode = kzalloc(sizeof(struct cmm_mnode), GFP_KERNEL);
-		if (!pnode)
-			return NULL;
-	} else {
-		/* surely a valid element */
-		pnode = list_first_entry(&cmm_mgr_obj->node_free_list,
-				struct cmm_mnode, link);
-		list_del_init(&pnode->link);
-	}
-
-	pnode->pa = dw_pa;
-	pnode->va = dw_va;
-	pnode->size = ul_size;
-
-	return pnode;
-}
-
-/*
- *  ======== delete_node ========
- *  Purpose:
- *      Put a memory node on the cmm nodelist for later use.
- *      Doesn't actually delete the node. Heap thrashing friendly.
- */
-static void delete_node(struct cmm_object *cmm_mgr_obj, struct cmm_mnode *pnode)
-{
-	list_add_tail(&pnode->link, &cmm_mgr_obj->node_free_list);
-}
-
-/*
- * ====== get_free_block ========
- *  Purpose:
- *      Scan the free block list and return the first block that satisfies
- *      the size.
- */
-static struct cmm_mnode *get_free_block(struct cmm_allocator *allocator,
-					u32 usize)
-{
-	struct cmm_mnode *node, *tmp;
-
-	if (!allocator)
-		return NULL;
-
-	list_for_each_entry_safe(node, tmp, &allocator->free_list, link) {
-		if (usize <= node->size) {
-			list_del(&node->link);
-			return node;
-		}
-	}
-
-	return NULL;
-}
-
-/*
- *  ======== add_to_free_list ========
- *  Purpose:
- *      Coalesce node into the freelist in ascending size order.
- */
-static void add_to_free_list(struct cmm_allocator *allocator,
-			     struct cmm_mnode *node)
-{
-	struct cmm_mnode *curr;
-
-	if (!node) {
-		pr_err("%s: failed - node is NULL\n", __func__);
-		return;
-	}
-
-	list_for_each_entry(curr, &allocator->free_list, link) {
-		if (NEXT_PA(curr) == node->pa) {
-			curr->size += node->size;
-			delete_node(allocator->cmm_mgr, node);
-			return;
-		}
-		if (curr->pa == NEXT_PA(node)) {
-			curr->pa = node->pa;
-			curr->va = node->va;
-			curr->size += node->size;
-			delete_node(allocator->cmm_mgr, node);
-			return;
-		}
-	}
-	list_for_each_entry(curr, &allocator->free_list, link) {
-		if (curr->size >= node->size) {
-			list_add_tail(&node->link, &curr->link);
-			return;
-		}
-	}
-	list_add_tail(&node->link, &allocator->free_list);
-}
-
-/*
- * ======== get_allocator ========
- *  Purpose:
- *      Return the allocator for the given SM Segid.
- *      SegIds:  1,2,3..max.
- */
-static struct cmm_allocator *get_allocator(struct cmm_object *cmm_mgr_obj,
-					   u32 ul_seg_id)
-{
-	return cmm_mgr_obj->pa_gppsm_seg_tab[ul_seg_id - 1];
-}
-
-/*
- *  The CMM_Xlator[xxx] routines below are used by Node and Stream
- *  to perform SM address translation to the client process address space.
- *  A "translator" object is created by a node/stream for each SM seg used.
- */
-
-/*
- *  ======== cmm_xlator_create ========
- *  Purpose:
- *      Create an address translator object.
- */
-int cmm_xlator_create(struct cmm_xlatorobject **xlator,
-			     struct cmm_object *hcmm_mgr,
-			     struct cmm_xlatorattrs *xlator_attrs)
-{
-	struct cmm_xlator *xlator_object = NULL;
-	int status = 0;
-
-	*xlator = NULL;
-	if (xlator_attrs == NULL)
-		xlator_attrs = &cmm_dfltxlatorattrs;	/* set defaults */
-
-	xlator_object = kzalloc(sizeof(struct cmm_xlator), GFP_KERNEL);
-	if (xlator_object != NULL) {
-		xlator_object->cmm_mgr = hcmm_mgr;	/* ref back to CMM */
-		/* SM seg_id */
-		xlator_object->seg_id = xlator_attrs->seg_id;
-	} else {
-		status = -ENOMEM;
-	}
-	if (!status)
-		*xlator = (struct cmm_xlatorobject *)xlator_object;
-
-	return status;
-}
-
-/*
- *  ======== cmm_xlator_alloc_buf ========
- */
-void *cmm_xlator_alloc_buf(struct cmm_xlatorobject *xlator, void *va_buf,
-			   u32 pa_size)
-{
-	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
-	void *pbuf = NULL;
-	void *tmp_va_buff;
-	struct cmm_attrs attrs;
-
-	if (xlator_obj) {
-		attrs.seg_id = xlator_obj->seg_id;
-		__raw_writel(0, va_buf);
-		/* Alloc SM */
-		pbuf =
-		    cmm_calloc_buf(xlator_obj->cmm_mgr, pa_size, &attrs, NULL);
-		if (pbuf) {
-			/* convert to translator(node/strm) process Virtual
-			 * address */
-			 tmp_va_buff = cmm_xlator_translate(xlator,
-							 pbuf, CMM_PA2VA);
-			__raw_writel((u32)tmp_va_buff, va_buf);
-		}
-	}
-	return pbuf;
-}
-
-/*
- *  ======== cmm_xlator_free_buf ========
- *  Purpose:
- *      Free the given SM buffer and descriptor.
- *      Does not free virtual memory.
- */
-int cmm_xlator_free_buf(struct cmm_xlatorobject *xlator, void *buf_va)
-{
-	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
-	int status = -EPERM;
-	void *buf_pa = NULL;
-
-	if (xlator_obj) {
-		/* convert Va to Pa so we can free it. */
-		buf_pa = cmm_xlator_translate(xlator, buf_va, CMM_VA2PA);
-		if (buf_pa) {
-			status = cmm_free_buf(xlator_obj->cmm_mgr, buf_pa,
-					      xlator_obj->seg_id);
-			if (status) {
-				/* Uh oh, this shouldn't happen. Descriptor
-				 * gone! */
-				pr_err("%s, line %d: Assertion failed\n",
-				       __FILE__, __LINE__);
-			}
-		}
-	}
-	return status;
-}
-
-/*
- *  ======== cmm_xlator_info ========
- *  Purpose:
- *      Set/Get translator info.
- */
-int cmm_xlator_info(struct cmm_xlatorobject *xlator, u8 **paddr,
-			   u32 ul_size, u32 segm_id, bool set_info)
-{
-	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
-	int status = 0;
-
-	if (xlator_obj) {
-		if (set_info) {
-			/* set translators virtual address range */
-			xlator_obj->virt_base = (u32) *paddr;
-			xlator_obj->virt_size = ul_size;
-		} else {	/* return virt base address */
-			*paddr = (u8 *) xlator_obj->virt_base;
-		}
-	} else {
-		status = -EFAULT;
-	}
-	return status;
-}
-
-/*
- *  ======== cmm_xlator_translate ========
- */
-void *cmm_xlator_translate(struct cmm_xlatorobject *xlator, void *paddr,
-			   enum cmm_xlatetype xtype)
-{
-	u32 dw_addr_xlate = 0;
-	struct cmm_xlator *xlator_obj = (struct cmm_xlator *)xlator;
-	struct cmm_object *cmm_mgr_obj = NULL;
-	struct cmm_allocator *allocator = NULL;
-	u32 dw_offset = 0;
-
-	if (!xlator_obj)
-		goto loop_cont;
-
-	cmm_mgr_obj = (struct cmm_object *)xlator_obj->cmm_mgr;
-	/* get this translator's default SM allocator */
-	allocator = cmm_mgr_obj->pa_gppsm_seg_tab[xlator_obj->seg_id - 1];
-	if (!allocator)
-		goto loop_cont;
-
-	if ((xtype == CMM_VA2DSPPA) || (xtype == CMM_VA2PA) ||
-	    (xtype == CMM_PA2VA)) {
-		if (xtype == CMM_PA2VA) {
-			/* Gpp Va = Va Base + offset */
-			dw_offset = (u8 *) paddr - (u8 *) (allocator->shm_base -
-							   allocator->
-							   dsp_size);
-			dw_addr_xlate = xlator_obj->virt_base + dw_offset;
-			/* Check if translated Va base is in range */
-			if ((dw_addr_xlate < xlator_obj->virt_base) ||
-			    (dw_addr_xlate >=
-			     (xlator_obj->virt_base +
-			      xlator_obj->virt_size))) {
-				dw_addr_xlate = 0;	/* bad address */
-			}
-		} else {
-			/* Gpp PA =  Gpp Base + offset */
-			dw_offset =
-			    (u8 *) paddr - (u8 *) xlator_obj->virt_base;
-			dw_addr_xlate =
-			    allocator->shm_base - allocator->dsp_size +
-			    dw_offset;
-		}
-	} else {
-		dw_addr_xlate = (u32) paddr;
-	}
-	/*Now convert address to proper target physical address if needed */
-	if ((xtype == CMM_VA2DSPPA) || (xtype == CMM_PA2DSPPA)) {
-		/* Got Gpp Pa now, convert to DSP Pa */
-		dw_addr_xlate =
-		    GPPPA2DSPPA((allocator->shm_base - allocator->dsp_size),
-				dw_addr_xlate,
-				allocator->dsp_phys_addr_offset *
-				allocator->c_factor);
-	} else if (xtype == CMM_DSPPA2PA) {
-		/* Got DSP Pa, convert to GPP Pa */
-		dw_addr_xlate =
-		    DSPPA2GPPPA(allocator->shm_base - allocator->dsp_size,
-				dw_addr_xlate,
-				allocator->dsp_phys_addr_offset *
-				allocator->c_factor);
-	}
-loop_cont:
-	return (void *)dw_addr_xlate;
-}
diff --git a/drivers/staging/tidspbridge/pmgr/cod.c b/drivers/staging/tidspbridge/pmgr/cod.c
deleted file mode 100644
index 6c29379..0000000
--- a/drivers/staging/tidspbridge/pmgr/cod.c
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
- * cod.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * This module implements DSP code management for the DSP/BIOS Bridge
- * environment. It is mostly a thin wrapper.
- *
- * This module provides an interface for loading both static and
- * dynamic code objects onto DSP systems.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/types.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-#include <linux/fs.h>
-#include <linux/uaccess.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- Platform Manager */
-/* Include appropriate loader header file */
-#include <dspbridge/dbll.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/cod.h>
-
-/*
- *  ======== cod_manager ========
- */
-struct cod_manager {
-	struct dbll_tar_obj *target;
-	struct dbll_library_obj *base_lib;
-	bool loaded;		/* Base library loaded? */
-	u32 entry;
-	struct dbll_fxns fxns;
-	struct dbll_attrs attrs;
-	char sz_zl_file[COD_MAXPATHLENGTH];
-};
-
-/*
- *  ======== cod_libraryobj ========
- */
-struct cod_libraryobj {
-	struct dbll_library_obj *dbll_lib;
-	struct cod_manager *cod_mgr;
-};
-
-static struct dbll_fxns ldr_fxns = {
-	(dbll_close_fxn) dbll_close,
-	(dbll_create_fxn) dbll_create,
-	(dbll_delete_fxn) dbll_delete,
-	(dbll_exit_fxn) dbll_exit,
-	(dbll_get_attrs_fxn) dbll_get_attrs,
-	(dbll_get_addr_fxn) dbll_get_addr,
-	(dbll_get_c_addr_fxn) dbll_get_c_addr,
-	(dbll_get_sect_fxn) dbll_get_sect,
-	(dbll_init_fxn) dbll_init,
-	(dbll_load_fxn) dbll_load,
-	(dbll_open_fxn) dbll_open,
-	(dbll_read_sect_fxn) dbll_read_sect,
-	(dbll_unload_fxn) dbll_unload,
-};
-
-static bool no_op(void);
-
-/*
- * File operations (originally were under kfile.c)
- */
-static s32 cod_f_close(struct file *filp)
-{
-	/* Check for valid handle */
-	if (!filp)
-		return -EFAULT;
-
-	filp_close(filp, NULL);
-
-	/* we can't use 0 here */
-	return 0;
-}
-
-static struct file *cod_f_open(const char *psz_file_name, const char *sz_mode)
-{
-	mm_segment_t fs;
-	struct file *filp;
-
-	fs = get_fs();
-	set_fs(get_ds());
-
-	/* ignore given mode and open file as read-only */
-	filp = filp_open(psz_file_name, O_RDONLY, 0);
-
-	if (IS_ERR(filp))
-		filp = NULL;
-
-	set_fs(fs);
-
-	return filp;
-}
-
-static s32 cod_f_read(void __user *pbuffer, s32 size, s32 count,
-		      struct file *filp)
-{
-	/* check for valid file handle */
-	if (!filp)
-		return -EFAULT;
-
-	if ((size > 0) && (count > 0) && pbuffer) {
-		u32 dw_bytes_read;
-		mm_segment_t fs;
-
-		/* read from file */
-		fs = get_fs();
-		set_fs(get_ds());
-		dw_bytes_read = filp->f_op->read(filp, pbuffer, size * count,
-						 &(filp->f_pos));
-		set_fs(fs);
-
-		if (!dw_bytes_read)
-			return -EBADF;
-
-		return dw_bytes_read / size;
-	}
-
-	return -EINVAL;
-}
-
-static s32 cod_f_seek(struct file *filp, s32 offset, s32 origin)
-{
-	loff_t dw_cur_pos;
-
-	/* check for valid file handle */
-	if (!filp)
-		return -EFAULT;
-
-	/* based on the origin flag, move the internal pointer */
-	dw_cur_pos = filp->f_op->llseek(filp, offset, origin);
-
-	if ((s32) dw_cur_pos < 0)
-		return -EPERM;
-
-	/* we can't use 0 here */
-	return 0;
-}
-
-static s32 cod_f_tell(struct file *filp)
-{
-	loff_t dw_cur_pos;
-
-	if (!filp)
-		return -EFAULT;
-
-	/* Get current position */
-	dw_cur_pos = filp->f_op->llseek(filp, 0, SEEK_CUR);
-
-	if ((s32) dw_cur_pos < 0)
-		return -EPERM;
-
-	return dw_cur_pos;
-}
-
-/*
- *  ======== cod_close ========
- */
-void cod_close(struct cod_libraryobj *lib)
-{
-	struct cod_manager *hmgr;
-
-	hmgr = lib->cod_mgr;
-	hmgr->fxns.close_fxn(lib->dbll_lib);
-
-	kfree(lib);
-}
-
-/*
- *  ======== cod_create ========
- *  Purpose:
- *      Create an object to manage code on a DSP system.
- *      This object can be used to load an initial program image with
- *      arguments that can later be expanded with
- *      dynamically loaded object files.
- *
- */
-int cod_create(struct cod_manager **mgr, char *str_zl_file)
-{
-	struct cod_manager *mgr_new;
-	struct dbll_attrs zl_attrs;
-	int status = 0;
-
-	/* assume failure */
-	*mgr = NULL;
-
-	mgr_new = kzalloc(sizeof(struct cod_manager), GFP_KERNEL);
-	if (mgr_new == NULL)
-		return -ENOMEM;
-
-	/* Set up loader functions */
-	mgr_new->fxns = ldr_fxns;
-
-	/* initialize the ZL module */
-	mgr_new->fxns.init_fxn();
-
-	zl_attrs.alloc = (dbll_alloc_fxn) no_op;
-	zl_attrs.free = (dbll_free_fxn) no_op;
-	zl_attrs.fread = (dbll_read_fxn) cod_f_read;
-	zl_attrs.fseek = (dbll_seek_fxn) cod_f_seek;
-	zl_attrs.ftell = (dbll_tell_fxn) cod_f_tell;
-	zl_attrs.fclose = (dbll_f_close_fxn) cod_f_close;
-	zl_attrs.fopen = (dbll_f_open_fxn) cod_f_open;
-	zl_attrs.sym_lookup = NULL;
-	zl_attrs.base_image = true;
-	zl_attrs.log_write = NULL;
-	zl_attrs.log_write_handle = NULL;
-	zl_attrs.write = NULL;
-	zl_attrs.rmm_handle = NULL;
-	zl_attrs.input_params = NULL;
-	zl_attrs.sym_handle = NULL;
-	zl_attrs.sym_arg = NULL;
-
-	mgr_new->attrs = zl_attrs;
-
-	status = mgr_new->fxns.create_fxn(&mgr_new->target, &zl_attrs);
-
-	if (status) {
-		cod_delete(mgr_new);
-		return -ESPIPE;
-	}
-
-	/* return the new manager */
-	*mgr = mgr_new;
-
-	return 0;
-}
-
-/*
- *  ======== cod_delete ========
- *  Purpose:
- *      Delete a code manager object.
- */
-void cod_delete(struct cod_manager *cod_mgr_obj)
-{
-	if (cod_mgr_obj->base_lib) {
-		if (cod_mgr_obj->loaded)
-			cod_mgr_obj->fxns.unload_fxn(cod_mgr_obj->base_lib,
-							&cod_mgr_obj->attrs);
-
-		cod_mgr_obj->fxns.close_fxn(cod_mgr_obj->base_lib);
-	}
-	if (cod_mgr_obj->target) {
-		cod_mgr_obj->fxns.delete_fxn(cod_mgr_obj->target);
-		cod_mgr_obj->fxns.exit_fxn();
-	}
-	kfree(cod_mgr_obj);
-}
-
-/*
- *  ======== cod_get_base_lib ========
- *  Purpose:
- *      Get handle to the base image DBL library.
- */
-int cod_get_base_lib(struct cod_manager *cod_mgr_obj,
-			    struct dbll_library_obj **plib)
-{
-	int status = 0;
-
-	*plib = (struct dbll_library_obj *)cod_mgr_obj->base_lib;
-
-	return status;
-}
-
-/*
- *  ======== cod_get_base_name ========
- */
-int cod_get_base_name(struct cod_manager *cod_mgr_obj, char *sz_name,
-			     u32 usize)
-{
-	int status = 0;
-
-	if (usize <= COD_MAXPATHLENGTH)
-		strlcpy(sz_name, cod_mgr_obj->sz_zl_file, usize);
-	else
-		status = -EPERM;
-
-	return status;
-}
-
-/*
- *  ======== cod_get_entry ========
- *  Purpose:
- *      Retrieve the entry point of a loaded DSP program image
- *
- */
-int cod_get_entry(struct cod_manager *cod_mgr_obj, u32 *entry_pt)
-{
-	*entry_pt = cod_mgr_obj->entry;
-
-	return 0;
-}
-
-/*
- *  ======== cod_get_loader ========
- *  Purpose:
- *      Get handle to the DBLL loader.
- */
-int cod_get_loader(struct cod_manager *cod_mgr_obj,
-			  struct dbll_tar_obj **loader)
-{
-	int status = 0;
-
-	*loader = (struct dbll_tar_obj *)cod_mgr_obj->target;
-
-	return status;
-}
-
-/*
- *  ======== cod_get_section ========
- *  Purpose:
- *      Retrieve the starting address and length of a section in the COFF file
- *      given the section name.
- */
-int cod_get_section(struct cod_libraryobj *lib, char *str_sect,
-			   u32 *addr, u32 *len)
-{
-	struct cod_manager *cod_mgr_obj;
-	int status = 0;
-
-	*addr = 0;
-	*len = 0;
-	if (lib != NULL) {
-		cod_mgr_obj = lib->cod_mgr;
-		status = cod_mgr_obj->fxns.get_sect_fxn(lib->dbll_lib, str_sect,
-							addr, len);
-	} else {
-		status = -ESPIPE;
-	}
-
-	return status;
-}
-
-/*
- *  ======== cod_get_sym_value ========
- *  Purpose:
- *      Retrieve the value for the specified symbol. The symbol is first
- *      searched for literally and then, if not found, searched for as a
- *      C symbol.
- *
- */
-int cod_get_sym_value(struct cod_manager *cod_mgr_obj, char *str_sym,
-			     u32 *pul_value)
-{
-	struct dbll_sym_val *dbll_sym;
-
-	dev_dbg(bridge, "%s: cod_mgr_obj: %p str_sym: %s pul_value: %p\n",
-		__func__, cod_mgr_obj, str_sym, pul_value);
-	if (cod_mgr_obj->base_lib) {
-		if (!cod_mgr_obj->fxns.
-		    get_addr_fxn(cod_mgr_obj->base_lib, str_sym, &dbll_sym)) {
-			if (!cod_mgr_obj->fxns.
-			    get_c_addr_fxn(cod_mgr_obj->base_lib, str_sym,
-						&dbll_sym))
-				return -ESPIPE;
-		}
-	} else {
-		return -ESPIPE;
-	}
-
-	*pul_value = dbll_sym->value;
-
-	return 0;
-}
-
-/*
- *  ======== cod_load_base ========
- *  Purpose:
- *      Load the initial program image, optionally with command-line arguments,
- *      on the DSP system managed by the supplied handle. The program to be
- *      loaded must be the first element of the args array and must be a fully
- *      qualified pathname.
- *  Details:
- *      if num_argc doesn't match the number of arguments in the args array, the
- *      args array is searched for a NULL terminating entry, and argc is
- *      recalculated to reflect this.  In this way, we can support NULL
- *      terminating args arrays, if num_argc is very large.
- */
-int cod_load_base(struct cod_manager *cod_mgr_obj, u32 num_argc, char *args[],
-			 cod_writefxn pfn_write, void *arb, char *envp[])
-{
-	dbll_flags flags;
-	struct dbll_attrs save_attrs;
-	struct dbll_attrs new_attrs;
-	int status;
-	u32 i;
-
-	/*
-	 *  Make sure every argv[] stated in argc has a value, or change argc to
-	 *  reflect true number in NULL terminated argv array.
-	 */
-	for (i = 0; i < num_argc; i++) {
-		if (args[i] == NULL) {
-			num_argc = i;
-			break;
-		}
-	}
-
-	/* set the write function for this operation */
-	cod_mgr_obj->fxns.get_attrs_fxn(cod_mgr_obj->target, &save_attrs);
-
-	new_attrs = save_attrs;
-	new_attrs.write = (dbll_write_fxn) pfn_write;
-	new_attrs.input_params = arb;
-	new_attrs.alloc = (dbll_alloc_fxn) no_op;
-	new_attrs.free = (dbll_free_fxn) no_op;
-	new_attrs.log_write = NULL;
-	new_attrs.log_write_handle = NULL;
-
-	/* Load the image */
-	flags = DBLL_CODE | DBLL_DATA | DBLL_SYMB;
-	status = cod_mgr_obj->fxns.load_fxn(cod_mgr_obj->base_lib, flags,
-					    &new_attrs,
-					    &cod_mgr_obj->entry);
-	if (status)
-		cod_mgr_obj->fxns.close_fxn(cod_mgr_obj->base_lib);
-
-	if (!status)
-		cod_mgr_obj->loaded = true;
-	else
-		cod_mgr_obj->base_lib = NULL;
-
-	return status;
-}
-
-/*
- *  ======== cod_open ========
- *      Open library for reading sections.
- */
-int cod_open(struct cod_manager *hmgr, char *sz_coff_path,
-		    u32 flags, struct cod_libraryobj **lib_obj)
-{
-	int status = 0;
-	struct cod_libraryobj *lib = NULL;
-
-	*lib_obj = NULL;
-
-	lib = kzalloc(sizeof(struct cod_libraryobj), GFP_KERNEL);
-	if (lib == NULL)
-		status = -ENOMEM;
-
-	if (!status) {
-		lib->cod_mgr = hmgr;
-		status = hmgr->fxns.open_fxn(hmgr->target, sz_coff_path, flags,
-					     &lib->dbll_lib);
-		if (!status)
-			*lib_obj = lib;
-	}
-
-	if (status)
-		pr_err("%s: error status 0x%x, sz_coff_path: %s flags: 0x%x\n",
-		       __func__, status, sz_coff_path, flags);
-	return status;
-}
-
-/*
- *  ======== cod_open_base ========
- *  Purpose:
- *      Open base image for reading sections.
- */
-int cod_open_base(struct cod_manager *hmgr, char *sz_coff_path,
-			 dbll_flags flags)
-{
-	int status = 0;
-	struct dbll_library_obj *lib;
-
-	/* if we previously opened a base image, close it now */
-	if (hmgr->base_lib) {
-		if (hmgr->loaded) {
-			hmgr->fxns.unload_fxn(hmgr->base_lib, &hmgr->attrs);
-			hmgr->loaded = false;
-		}
-		hmgr->fxns.close_fxn(hmgr->base_lib);
-		hmgr->base_lib = NULL;
-	}
-	status = hmgr->fxns.open_fxn(hmgr->target, sz_coff_path, flags, &lib);
-	if (!status) {
-		/* hang onto the library for subsequent sym table usage */
-		hmgr->base_lib = lib;
-		strncpy(hmgr->sz_zl_file, sz_coff_path, COD_MAXPATHLENGTH - 1);
-		hmgr->sz_zl_file[COD_MAXPATHLENGTH - 1] = '\0';
-	}
-
-	if (status)
-		pr_err("%s: error status 0x%x sz_coff_path: %s\n", __func__,
-		       status, sz_coff_path);
-	return status;
-}
-
-/*
- *  ======== cod_read_section ========
- *  Purpose:
- *      Retrieve the content of a code section given the section name.
- */
-int cod_read_section(struct cod_libraryobj *lib, char *str_sect,
-			    char *str_content, u32 content_size)
-{
-	int status = 0;
-
-	if (lib != NULL)
-		status =
-		    lib->cod_mgr->fxns.read_sect_fxn(lib->dbll_lib, str_sect,
-						     str_content, content_size);
-	else
-		status = -ESPIPE;
-
-	return status;
-}
-
-/*
- *  ======== no_op ========
- *  Purpose:
- *      No Operation.
- *
- */
-static bool no_op(void)
-{
-	return true;
-}
diff --git a/drivers/staging/tidspbridge/pmgr/dbll.c b/drivers/staging/tidspbridge/pmgr/dbll.c
deleted file mode 100644
index 8e21d1e..0000000
--- a/drivers/staging/tidspbridge/pmgr/dbll.c
+++ /dev/null
@@ -1,1421 +0,0 @@
-/*
- * dbll.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#include <linux/types.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-#include <dspbridge/gh.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-
-/* Dynamic loader library interface */
-#include <dspbridge/dynamic_loader.h>
-#include <dspbridge/getsection.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/dbll.h>
-#include <dspbridge/rmm.h>
-
-/* Max buffer length */
-#define MAXEXPR 128
-
-#define DOFF_ALIGN(x) (((x) + 3) & ~3UL)
-
-/*
- *  ======== struct dbll_tar_obj* ========
- *  A target may have one or more libraries of symbols/code/data loaded
- *  onto it, where a library is simply the symbols/code/data contained
- *  in a DOFF file.
- */
-/*
- *  ======== dbll_tar_obj ========
- */
-struct dbll_tar_obj {
-	struct dbll_attrs attrs;
-	struct dbll_library_obj *head;	/* List of all opened libraries */
-};
-
-/*
- *  The following 4 typedefs are "super classes" of the dynamic loader
- *  library types used in dynamic loader functions (dynamic_loader.h).
- */
-/*
- *  ======== dbll_stream ========
- *  Contains dynamic_loader_stream
- */
-struct dbll_stream {
-	struct dynamic_loader_stream dl_stream;
-	struct dbll_library_obj *lib;
-};
-
-/*
- *  ======== ldr_symbol ========
- */
-struct ldr_symbol {
-	struct dynamic_loader_sym dl_symbol;
-	struct dbll_library_obj *lib;
-};
-
-/*
- *  ======== dbll_alloc ========
- */
-struct dbll_alloc {
-	struct dynamic_loader_allocate dl_alloc;
-	struct dbll_library_obj *lib;
-};
-
-/*
- *  ======== dbll_init_obj ========
- */
-struct dbll_init_obj {
-	struct dynamic_loader_initialize dl_init;
-	struct dbll_library_obj *lib;
-};
-
-/*
- *  ======== DBLL_Library ========
- *  A library handle is returned by DBLL_Open() and is passed to dbll_load()
- *  to load symbols/code/data, and to dbll_unload(), to remove the
- *  symbols/code/data loaded by dbll_load().
- */
-
-/*
- *  ======== dbll_library_obj ========
- */
-struct dbll_library_obj {
-	struct dbll_library_obj *next;	/* Next library in target's list */
-	struct dbll_library_obj *prev;	/* Previous in the list */
-	struct dbll_tar_obj *target_obj;	/* target for this library */
-
-	/* Objects needed by dynamic loader */
-	struct dbll_stream stream;
-	struct ldr_symbol symbol;
-	struct dbll_alloc allocate;
-	struct dbll_init_obj init;
-	void *dload_mod_obj;
-
-	char *file_name;	/* COFF file name */
-	void *fp;		/* Opaque file handle */
-	u32 entry;		/* Entry point */
-	void *desc;	/* desc of DOFF file loaded */
-	u32 open_ref;		/* Number of times opened */
-	u32 load_ref;		/* Number of times loaded */
-	struct gh_t_hash_tab *sym_tab;	/* Hash table of symbols */
-	u32 pos;
-};
-
-/*
- *  ======== dbll_symbol ========
- */
-struct dbll_symbol {
-	struct dbll_sym_val value;
-	char *name;
-};
-
-static void dof_close(struct dbll_library_obj *zl_lib);
-static int dof_open(struct dbll_library_obj *zl_lib);
-static s32 no_op(struct dynamic_loader_initialize *thisptr, void *bufr,
-		 ldr_addr locn, struct ldr_section_info *info,
-		 unsigned bytsize);
-
-/*
- *  Functions called by dynamic loader
- *
- */
-/* dynamic_loader_stream */
-static int dbll_read_buffer(struct dynamic_loader_stream *this, void *buffer,
-			    unsigned bufsize);
-static int dbll_set_file_posn(struct dynamic_loader_stream *this,
-			      unsigned int pos);
-/* dynamic_loader_sym */
-static struct dynload_symbol *dbll_find_symbol(struct dynamic_loader_sym *this,
-					       const char *name);
-static struct dynload_symbol *dbll_add_to_symbol_table(struct dynamic_loader_sym
-						       *this, const char *name,
-						       unsigned module_id);
-static struct dynload_symbol *find_in_symbol_table(struct dynamic_loader_sym
-						   *this, const char *name,
-						   unsigned moduleid);
-static void dbll_purge_symbol_table(struct dynamic_loader_sym *this,
-				    unsigned module_id);
-static void *allocate(struct dynamic_loader_sym *this, unsigned memsize);
-static void deallocate(struct dynamic_loader_sym *this, void *mem_ptr);
-static void dbll_err_report(struct dynamic_loader_sym *this, const char *errstr,
-			    va_list args);
-/* dynamic_loader_allocate */
-static int dbll_rmm_alloc(struct dynamic_loader_allocate *this,
-			  struct ldr_section_info *info, unsigned align);
-static void rmm_dealloc(struct dynamic_loader_allocate *this,
-			struct ldr_section_info *info);
-
-/* dynamic_loader_initialize */
-static int connect(struct dynamic_loader_initialize *this);
-static int read_mem(struct dynamic_loader_initialize *this, void *buf,
-		    ldr_addr addr, struct ldr_section_info *info,
-		    unsigned bytes);
-static int write_mem(struct dynamic_loader_initialize *this, void *buf,
-		     ldr_addr addr, struct ldr_section_info *info,
-		     unsigned nbytes);
-static int fill_mem(struct dynamic_loader_initialize *this, ldr_addr addr,
-		    struct ldr_section_info *info, unsigned bytes,
-		    unsigned val);
-static int execute(struct dynamic_loader_initialize *this, ldr_addr start);
-static void release(struct dynamic_loader_initialize *this);
-
-/* symbol table hash functions */
-static u32 name_hash(const void *key);
-static bool name_match(const void *key, const void *sp);
-static void sym_delete(void *value);
-
-/* Symbol Redefinition */
-static int redefined_symbol;
-static int gbl_search = 1;
-
-/*
- *  ======== dbll_close ========
- */
-void dbll_close(struct dbll_library_obj *zl_lib)
-{
-	struct dbll_tar_obj *zl_target;
-
-	zl_target = zl_lib->target_obj;
-	zl_lib->open_ref--;
-	if (zl_lib->open_ref == 0) {
-		/* Remove library from list */
-		if (zl_target->head == zl_lib)
-			zl_target->head = zl_lib->next;
-
-		if (zl_lib->prev)
-			(zl_lib->prev)->next = zl_lib->next;
-
-		if (zl_lib->next)
-			(zl_lib->next)->prev = zl_lib->prev;
-
-		/* Free DOF resources */
-		dof_close(zl_lib);
-		kfree(zl_lib->file_name);
-
-		/* remove symbols from symbol table */
-		if (zl_lib->sym_tab)
-			gh_delete(zl_lib->sym_tab);
-
-		/* remove the library object itself */
-		kfree(zl_lib);
-		zl_lib = NULL;
-	}
-}
-
-/*
- *  ======== dbll_create ========
- */
-int dbll_create(struct dbll_tar_obj **target_obj,
-		       struct dbll_attrs *pattrs)
-{
-	struct dbll_tar_obj *pzl_target;
-	int status = 0;
-
-	/* Allocate DBL target object */
-	pzl_target = kzalloc(sizeof(struct dbll_tar_obj), GFP_KERNEL);
-	if (target_obj != NULL) {
-		if (pzl_target == NULL) {
-			*target_obj = NULL;
-			status = -ENOMEM;
-		} else {
-			pzl_target->attrs = *pattrs;
-			*target_obj = (struct dbll_tar_obj *)pzl_target;
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== dbll_delete ========
- */
-void dbll_delete(struct dbll_tar_obj *target)
-{
-	struct dbll_tar_obj *zl_target = (struct dbll_tar_obj *)target;
-
-	kfree(zl_target);
-
-}
-
-/*
- *  ======== dbll_exit ========
- *  Discontinue usage of DBL module.
- */
-void dbll_exit(void)
-{
-	/* do nothing */
-}
-
-/*
- *  ======== dbll_get_addr ========
- *  Get address of name in the specified library.
- */
-bool dbll_get_addr(struct dbll_library_obj *zl_lib, char *name,
-		   struct dbll_sym_val **sym_val)
-{
-	struct dbll_symbol *sym;
-
-	sym = (struct dbll_symbol *)gh_find(zl_lib->sym_tab, name);
-	if (IS_ERR(sym))
-		return false;
-
-	*sym_val = &sym->value;
-
-	dev_dbg(bridge, "%s: lib: %p name: %s paddr: %p\n",
-		__func__, zl_lib, name, sym_val);
-	return true;
-}
-
-/*
- *  ======== dbll_get_attrs ========
- *  Retrieve the attributes of the target.
- */
-void dbll_get_attrs(struct dbll_tar_obj *target, struct dbll_attrs *pattrs)
-{
-	struct dbll_tar_obj *zl_target = (struct dbll_tar_obj *)target;
-
-	if ((pattrs != NULL) && (zl_target != NULL))
-		*pattrs = zl_target->attrs;
-
-}
-
-/*
- *  ======== dbll_get_c_addr ========
- *  Get address of a "C" name in the specified library.
- */
-bool dbll_get_c_addr(struct dbll_library_obj *zl_lib, char *name,
-		     struct dbll_sym_val **sym_val)
-{
-	struct dbll_symbol *sym;
-	char cname[MAXEXPR + 1];
-
-	cname[0] = '_';
-
-	strncpy(cname + 1, name, sizeof(cname) - 2);
-	cname[MAXEXPR] = '\0';	/* insure '\0' string termination */
-
-	/* Check for C name, if not found */
-	sym = (struct dbll_symbol *)gh_find(zl_lib->sym_tab, cname);
-	if (IS_ERR(sym))
-		return false;
-
-	*sym_val = &sym->value;
-
-	return true;
-}
-
-/*
- *  ======== dbll_get_sect ========
- *  Get the base address and size (in bytes) of a COFF section.
- */
-int dbll_get_sect(struct dbll_library_obj *lib, char *name, u32 *paddr,
-			 u32 *psize)
-{
-	u32 byte_size;
-	bool opened_doff = false;
-	const struct ldr_section_info *sect = NULL;
-	struct dbll_library_obj *zl_lib = (struct dbll_library_obj *)lib;
-	int status = 0;
-
-	/* If DOFF file is not open, we open it. */
-	if (zl_lib != NULL) {
-		if (zl_lib->fp == NULL) {
-			status = dof_open(zl_lib);
-			if (!status)
-				opened_doff = true;
-
-		} else {
-			(*(zl_lib->target_obj->attrs.fseek)) (zl_lib->fp,
-							      zl_lib->pos,
-							      SEEK_SET);
-		}
-	} else {
-		status = -EFAULT;
-	}
-	if (!status) {
-		byte_size = 1;
-		if (dload_get_section_info(zl_lib->desc, name, &sect)) {
-			*paddr = sect->load_addr;
-			*psize = sect->size * byte_size;
-			/* Make sure size is even for good swap */
-			if (*psize % 2)
-				(*psize)++;
-
-			/* Align size */
-			*psize = DOFF_ALIGN(*psize);
-		} else {
-			status = -ENXIO;
-		}
-	}
-	if (opened_doff) {
-		dof_close(zl_lib);
-		opened_doff = false;
-	}
-
-	dev_dbg(bridge, "%s: lib: %p name: %s paddr: %p psize: %p, status 0x%x\n",
-			__func__, lib, name, paddr, psize, status);
-
-	return status;
-}
-
-/*
- *  ======== dbll_init ========
- */
-bool dbll_init(void)
-{
-	/* do nothing */
-
-	return true;
-}
-
-/*
- *  ======== dbll_load ========
- */
-int dbll_load(struct dbll_library_obj *lib, dbll_flags flags,
-		     struct dbll_attrs *attrs, u32 *entry)
-{
-	struct dbll_library_obj *zl_lib = (struct dbll_library_obj *)lib;
-	struct dbll_tar_obj *dbzl;
-	bool got_symbols = true;
-	s32 err;
-	int status = 0;
-	bool opened_doff = false;
-
-	/*
-	 *  Load if not already loaded.
-	 */
-	if (zl_lib->load_ref == 0 || !(flags & DBLL_DYNAMIC)) {
-		dbzl = zl_lib->target_obj;
-		dbzl->attrs = *attrs;
-		/* Create a hash table for symbols if not already created */
-		if (zl_lib->sym_tab == NULL) {
-			got_symbols = false;
-			zl_lib->sym_tab = gh_create(sizeof(struct dbll_symbol),
-						    name_hash,
-						    name_match, sym_delete);
-			if (IS_ERR(zl_lib->sym_tab)) {
-				status = PTR_ERR(zl_lib->sym_tab);
-				zl_lib->sym_tab = NULL;
-			}
-
-		}
-		/*
-		 *  Set up objects needed by the dynamic loader
-		 */
-		/* Stream */
-		zl_lib->stream.dl_stream.read_buffer = dbll_read_buffer;
-		zl_lib->stream.dl_stream.set_file_posn = dbll_set_file_posn;
-		zl_lib->stream.lib = zl_lib;
-		/* Symbol */
-		zl_lib->symbol.dl_symbol.find_matching_symbol =
-		    dbll_find_symbol;
-		if (got_symbols) {
-			zl_lib->symbol.dl_symbol.add_to_symbol_table =
-			    find_in_symbol_table;
-		} else {
-			zl_lib->symbol.dl_symbol.add_to_symbol_table =
-			    dbll_add_to_symbol_table;
-		}
-		zl_lib->symbol.dl_symbol.purge_symbol_table =
-		    dbll_purge_symbol_table;
-		zl_lib->symbol.dl_symbol.dload_allocate = allocate;
-		zl_lib->symbol.dl_symbol.dload_deallocate = deallocate;
-		zl_lib->symbol.dl_symbol.error_report = dbll_err_report;
-		zl_lib->symbol.lib = zl_lib;
-		/* Allocate */
-		zl_lib->allocate.dl_alloc.dload_allocate = dbll_rmm_alloc;
-		zl_lib->allocate.dl_alloc.dload_deallocate = rmm_dealloc;
-		zl_lib->allocate.lib = zl_lib;
-		/* Init */
-		zl_lib->init.dl_init.connect = connect;
-		zl_lib->init.dl_init.readmem = read_mem;
-		zl_lib->init.dl_init.writemem = write_mem;
-		zl_lib->init.dl_init.fillmem = fill_mem;
-		zl_lib->init.dl_init.execute = execute;
-		zl_lib->init.dl_init.release = release;
-		zl_lib->init.lib = zl_lib;
-		/* If COFF file is not open, we open it. */
-		if (zl_lib->fp == NULL) {
-			status = dof_open(zl_lib);
-			if (!status)
-				opened_doff = true;
-
-		}
-		if (!status) {
-			zl_lib->pos = (*(zl_lib->target_obj->attrs.ftell))
-			    (zl_lib->fp);
-			/* Reset file cursor */
-			(*(zl_lib->target_obj->attrs.fseek)) (zl_lib->fp,
-							      (long)0,
-							      SEEK_SET);
-			symbols_reloaded = true;
-			/* The 5th argument, DLOAD_INITBSS, tells the DLL
-			 * module to zero-init all BSS sections.  In general,
-			 * this is not necessary and also increases load time.
-			 * We may want to make this configurable by the user */
-			err = dynamic_load_module(&zl_lib->stream.dl_stream,
-						  &zl_lib->symbol.dl_symbol,
-						  &zl_lib->allocate.dl_alloc,
-						  &zl_lib->init.dl_init,
-						  DLOAD_INITBSS,
-						  &zl_lib->dload_mod_obj);
-
-			if (err != 0) {
-				status = -EILSEQ;
-			} else if (redefined_symbol) {
-				zl_lib->load_ref++;
-				dbll_unload(zl_lib, (struct dbll_attrs *)attrs);
-				redefined_symbol = false;
-				status = -EILSEQ;
-			} else {
-				*entry = zl_lib->entry;
-			}
-		}
-	}
-	if (!status)
-		zl_lib->load_ref++;
-
-	/* Clean up DOFF resources */
-	if (opened_doff)
-		dof_close(zl_lib);
-
-	dev_dbg(bridge, "%s: lib: %p flags: 0x%x entry: %p, status 0x%x\n",
-		__func__, lib, flags, entry, status);
-
-	return status;
-}
-
-/*
- *  ======== dbll_open ========
- */
-int dbll_open(struct dbll_tar_obj *target, char *file, dbll_flags flags,
-		     struct dbll_library_obj **lib_obj)
-{
-	struct dbll_tar_obj *zl_target = (struct dbll_tar_obj *)target;
-	struct dbll_library_obj *zl_lib = NULL;
-	s32 err;
-	int status = 0;
-
-	zl_lib = zl_target->head;
-	while (zl_lib != NULL) {
-		if (strcmp(zl_lib->file_name, file) == 0) {
-			/* Library is already opened */
-			zl_lib->open_ref++;
-			break;
-		}
-		zl_lib = zl_lib->next;
-	}
-	if (zl_lib == NULL) {
-		/* Allocate DBL library object */
-		zl_lib = kzalloc(sizeof(struct dbll_library_obj), GFP_KERNEL);
-		if (zl_lib == NULL) {
-			status = -ENOMEM;
-		} else {
-			zl_lib->pos = 0;
-			/* Increment ref count to allow close on failure
-			 * later on */
-			zl_lib->open_ref++;
-			zl_lib->target_obj = zl_target;
-			/* Keep a copy of the file name */
-			zl_lib->file_name = kzalloc(strlen(file) + 1,
-							GFP_KERNEL);
-			if (zl_lib->file_name == NULL) {
-				status = -ENOMEM;
-			} else {
-				strncpy(zl_lib->file_name, file,
-					strlen(file) + 1);
-			}
-			zl_lib->sym_tab = NULL;
-		}
-	}
-	/*
-	 *  Set up objects needed by the dynamic loader
-	 */
-	if (status)
-		goto func_cont;
-
-	/* Stream */
-	zl_lib->stream.dl_stream.read_buffer = dbll_read_buffer;
-	zl_lib->stream.dl_stream.set_file_posn = dbll_set_file_posn;
-	zl_lib->stream.lib = zl_lib;
-	/* Symbol */
-	zl_lib->symbol.dl_symbol.add_to_symbol_table = dbll_add_to_symbol_table;
-	zl_lib->symbol.dl_symbol.find_matching_symbol = dbll_find_symbol;
-	zl_lib->symbol.dl_symbol.purge_symbol_table = dbll_purge_symbol_table;
-	zl_lib->symbol.dl_symbol.dload_allocate = allocate;
-	zl_lib->symbol.dl_symbol.dload_deallocate = deallocate;
-	zl_lib->symbol.dl_symbol.error_report = dbll_err_report;
-	zl_lib->symbol.lib = zl_lib;
-	/* Allocate */
-	zl_lib->allocate.dl_alloc.dload_allocate = dbll_rmm_alloc;
-	zl_lib->allocate.dl_alloc.dload_deallocate = rmm_dealloc;
-	zl_lib->allocate.lib = zl_lib;
-	/* Init */
-	zl_lib->init.dl_init.connect = connect;
-	zl_lib->init.dl_init.readmem = read_mem;
-	zl_lib->init.dl_init.writemem = write_mem;
-	zl_lib->init.dl_init.fillmem = fill_mem;
-	zl_lib->init.dl_init.execute = execute;
-	zl_lib->init.dl_init.release = release;
-	zl_lib->init.lib = zl_lib;
-	if (!status && zl_lib->fp == NULL)
-		status = dof_open(zl_lib);
-
-	zl_lib->pos = (*(zl_lib->target_obj->attrs.ftell)) (zl_lib->fp);
-	(*(zl_lib->target_obj->attrs.fseek)) (zl_lib->fp, (long)0, SEEK_SET);
-	/* Create a hash table for symbols if flag is set */
-	if (zl_lib->sym_tab != NULL || !(flags & DBLL_SYMB))
-		goto func_cont;
-
-	zl_lib->sym_tab =
-	    gh_create(sizeof(struct dbll_symbol), name_hash, name_match,
-		      sym_delete);
-	if (IS_ERR(zl_lib->sym_tab)) {
-		status = PTR_ERR(zl_lib->sym_tab);
-		zl_lib->sym_tab = NULL;
-	} else {
-		/* Do a fake load to get symbols - set write func to no_op */
-		zl_lib->init.dl_init.writemem = no_op;
-		err = dynamic_open_module(&zl_lib->stream.dl_stream,
-					  &zl_lib->symbol.dl_symbol,
-					  &zl_lib->allocate.dl_alloc,
-					  &zl_lib->init.dl_init, 0,
-					  &zl_lib->dload_mod_obj);
-		if (err != 0) {
-			status = -EILSEQ;
-		} else {
-			/* Now that we have the symbol table, we can unload */
-			err = dynamic_unload_module(zl_lib->dload_mod_obj,
-						    &zl_lib->symbol.dl_symbol,
-						    &zl_lib->allocate.dl_alloc,
-						    &zl_lib->init.dl_init);
-			if (err != 0)
-				status = -EILSEQ;
-
-			zl_lib->dload_mod_obj = NULL;
-		}
-	}
-func_cont:
-	if (!status) {
-		if (zl_lib->open_ref == 1) {
-			/* First time opened - insert in list */
-			if (zl_target->head)
-				(zl_target->head)->prev = zl_lib;
-
-			zl_lib->prev = NULL;
-			zl_lib->next = zl_target->head;
-			zl_target->head = zl_lib;
-		}
-		*lib_obj = (struct dbll_library_obj *)zl_lib;
-	} else {
-		*lib_obj = NULL;
-		if (zl_lib != NULL)
-			dbll_close((struct dbll_library_obj *)zl_lib);
-
-	}
-
-	dev_dbg(bridge, "%s: target: %p file: %s lib_obj: %p, status 0x%x\n",
-		__func__, target, file, lib_obj, status);
-
-	return status;
-}
-
-/*
- *  ======== dbll_read_sect ========
- *  Get the content of a COFF section.
- */
-int dbll_read_sect(struct dbll_library_obj *lib, char *name,
-			  char *buf, u32 size)
-{
-	struct dbll_library_obj *zl_lib = (struct dbll_library_obj *)lib;
-	bool opened_doff = false;
-	u32 byte_size;		/* size of bytes */
-	u32 ul_sect_size;	/* size of section */
-	const struct ldr_section_info *sect = NULL;
-	int status = 0;
-
-	/* If DOFF file is not open, we open it. */
-	if (zl_lib != NULL) {
-		if (zl_lib->fp == NULL) {
-			status = dof_open(zl_lib);
-			if (!status)
-				opened_doff = true;
-
-		} else {
-			(*(zl_lib->target_obj->attrs.fseek)) (zl_lib->fp,
-							      zl_lib->pos,
-							      SEEK_SET);
-		}
-	} else {
-		status = -EFAULT;
-	}
-	if (status)
-		goto func_cont;
-
-	byte_size = 1;
-	if (!dload_get_section_info(zl_lib->desc, name, &sect)) {
-		status = -ENXIO;
-		goto func_cont;
-	}
-	/*
-	 * Ensure the supplied buffer size is sufficient to store
-	 * the section buf to be read.
-	 */
-	ul_sect_size = sect->size * byte_size;
-	/* Make sure size is even for good swap */
-	if (ul_sect_size % 2)
-		ul_sect_size++;
-
-	/* Align size */
-	ul_sect_size = DOFF_ALIGN(ul_sect_size);
-	if (ul_sect_size > size) {
-		status = -EPERM;
-	} else {
-		if (!dload_get_section(zl_lib->desc, sect, buf))
-			status = -EBADF;
-
-	}
-func_cont:
-	if (opened_doff) {
-		dof_close(zl_lib);
-		opened_doff = false;
-	}
-
-	dev_dbg(bridge, "%s: lib: %p name: %s buf: %p size: 0x%x, status 0x%x\n",
-			__func__, lib, name, buf, size, status);
-	return status;
-}
-
-/*
- *  ======== dbll_unload ========
- */
-void dbll_unload(struct dbll_library_obj *lib, struct dbll_attrs *attrs)
-{
-	struct dbll_library_obj *zl_lib = (struct dbll_library_obj *)lib;
-	s32 err = 0;
-
-	dev_dbg(bridge, "%s: lib: %p\n", __func__, lib);
-	zl_lib->load_ref--;
-	/* Unload only if reference count is 0 */
-	if (zl_lib->load_ref != 0)
-		return;
-
-	zl_lib->target_obj->attrs = *attrs;
-	if (zl_lib->dload_mod_obj) {
-		err = dynamic_unload_module(zl_lib->dload_mod_obj,
-					    &zl_lib->symbol.dl_symbol,
-					    &zl_lib->allocate.dl_alloc,
-					    &zl_lib->init.dl_init);
-		if (err != 0)
-			dev_dbg(bridge, "%s: failed: 0x%x\n", __func__, err);
-	}
-	/* remove symbols from symbol table */
-	if (zl_lib->sym_tab != NULL) {
-		gh_delete(zl_lib->sym_tab);
-		zl_lib->sym_tab = NULL;
-	}
-	/* delete DOFF desc since it holds *lots* of host OS
-	 * resources */
-	dof_close(zl_lib);
-}
-
-/*
- *  ======== dof_close ========
- */
-static void dof_close(struct dbll_library_obj *zl_lib)
-{
-	if (zl_lib->desc) {
-		dload_module_close(zl_lib->desc);
-		zl_lib->desc = NULL;
-	}
-	/* close file */
-	if (zl_lib->fp) {
-		(zl_lib->target_obj->attrs.fclose) (zl_lib->fp);
-		zl_lib->fp = NULL;
-	}
-}
-
-/*
- *  ======== dof_open ========
- */
-static int dof_open(struct dbll_library_obj *zl_lib)
-{
-	void *open = *(zl_lib->target_obj->attrs.fopen);
-	int status = 0;
-
-	/* First open the file for the dynamic loader, then open COF */
-	zl_lib->fp =
-	    (void *)((dbll_f_open_fxn) (open)) (zl_lib->file_name, "rb");
-
-	/* Open DOFF module */
-	if (zl_lib->fp && zl_lib->desc == NULL) {
-		(*(zl_lib->target_obj->attrs.fseek)) (zl_lib->fp, (long)0,
-						      SEEK_SET);
-		zl_lib->desc =
-		    dload_module_open(&zl_lib->stream.dl_stream,
-				      &zl_lib->symbol.dl_symbol);
-		if (zl_lib->desc == NULL) {
-			(zl_lib->target_obj->attrs.fclose) (zl_lib->fp);
-			zl_lib->fp = NULL;
-			status = -EBADF;
-		}
-	} else {
-		status = -EBADF;
-	}
-
-	return status;
-}
-
-/*
- *  ======== name_hash ========
- */
-static u32 name_hash(const void *key)
-{
-	u32 hash;
-	const char *name = key;
-
-	hash = 0;
-
-	while (*name) {
-		hash <<= 1;
-		hash ^= *name++;
-	}
-
-	return hash;
-}
-
-/*
- *  ======== name_match ========
- */
-static bool name_match(const void *key, const void *sp)
-{
-	if ((key != NULL) && (sp != NULL)) {
-		if (strcmp(key, ((struct dbll_symbol *)sp)->name) == 0)
-			return true;
-	}
-	return false;
-}
-
-/*
- *  ======== no_op ========
- */
-static int no_op(struct dynamic_loader_initialize *thisptr, void *bufr,
-		 ldr_addr locn, struct ldr_section_info *info, unsigned bytsize)
-{
-	return 1;
-}
-
-/*
- *  ======== sym_delete ========
- */
-static void sym_delete(void *value)
-{
-	struct dbll_symbol *sp = (struct dbll_symbol *)value;
-
-	kfree(sp->name);
-}
-
-/*
- *  Dynamic Loader Functions
- */
-
-/* dynamic_loader_stream */
-/*
- *  ======== dbll_read_buffer ========
- */
-static int dbll_read_buffer(struct dynamic_loader_stream *this, void *buffer,
-			    unsigned bufsize)
-{
-	struct dbll_stream *pstream = (struct dbll_stream *)this;
-	struct dbll_library_obj *lib;
-	int bytes_read = 0;
-
-	lib = pstream->lib;
-	if (lib != NULL) {
-		bytes_read =
-		    (*(lib->target_obj->attrs.fread)) (buffer, 1, bufsize,
-						       lib->fp);
-	}
-	return bytes_read;
-}
-
-/*
- *  ======== dbll_set_file_posn ========
- */
-static int dbll_set_file_posn(struct dynamic_loader_stream *this,
-			      unsigned int pos)
-{
-	struct dbll_stream *pstream = (struct dbll_stream *)this;
-	struct dbll_library_obj *lib;
-	int status = 0;		/* Success */
-
-	lib = pstream->lib;
-	if (lib != NULL) {
-		status = (*(lib->target_obj->attrs.fseek)) (lib->fp, (long)pos,
-							    SEEK_SET);
-	}
-
-	return status;
-}
-
-/* dynamic_loader_sym */
-
-/*
- *  ======== dbll_find_symbol ========
- */
-static struct dynload_symbol *dbll_find_symbol(struct dynamic_loader_sym *this,
-					       const char *name)
-{
-	struct dynload_symbol *ret_sym;
-	struct ldr_symbol *ldr_sym = (struct ldr_symbol *)this;
-	struct dbll_library_obj *lib;
-	struct dbll_sym_val *dbll_sym = NULL;
-	bool status = false;	/* Symbol not found yet */
-
-	lib = ldr_sym->lib;
-	if (lib != NULL) {
-		if (lib->target_obj->attrs.sym_lookup) {
-			/* Check current lib + base lib + dep lib +
-			 * persistent lib */
-			status = (*(lib->target_obj->attrs.sym_lookup))
-			    (lib->target_obj->attrs.sym_handle,
-			     lib->target_obj->attrs.sym_arg,
-			     lib->target_obj->attrs.rmm_handle, name,
-			     &dbll_sym);
-		} else {
-			/* Just check current lib for symbol */
-			status = dbll_get_addr((struct dbll_library_obj *)lib,
-					       (char *)name, &dbll_sym);
-			if (!status) {
-				status = dbll_get_c_addr(
-						(struct dbll_library_obj *)
-						lib, (char *)name,
-						&dbll_sym);
-			}
-		}
-	}
-
-	if (!status && gbl_search)
-		dev_dbg(bridge, "%s: Symbol not found: %s\n", __func__, name);
-
-	ret_sym = (struct dynload_symbol *)dbll_sym;
-	return ret_sym;
-}
-
-/*
- *  ======== find_in_symbol_table ========
- */
-static struct dynload_symbol *find_in_symbol_table(struct dynamic_loader_sym
-						   *this, const char *name,
-						   unsigned moduleid)
-{
-	struct ldr_symbol *ldr_sym = (struct ldr_symbol *)this;
-	struct dbll_library_obj *lib;
-	struct dbll_symbol *sym;
-
-	lib = ldr_sym->lib;
-	sym = (struct dbll_symbol *)gh_find(lib->sym_tab, (char *)name);
-
-	if (IS_ERR(sym))
-		return NULL;
-
-	return (struct dynload_symbol *)&sym->value;
-}
-
-/*
- *  ======== dbll_add_to_symbol_table ========
- */
-static struct dynload_symbol *dbll_add_to_symbol_table(struct dynamic_loader_sym
-						       *this, const char *name,
-						       unsigned module_id)
-{
-	struct dbll_symbol *sym_ptr = NULL;
-	struct dbll_symbol symbol;
-	struct dynload_symbol *dbll_sym = NULL;
-	struct ldr_symbol *ldr_sym = (struct ldr_symbol *)this;
-	struct dbll_library_obj *lib;
-	struct dynload_symbol *ret;
-
-	lib = ldr_sym->lib;
-
-	/* Check to see if symbol is already defined in symbol table */
-	if (!(lib->target_obj->attrs.base_image)) {
-		gbl_search = false;
-		dbll_sym = dbll_find_symbol(this, name);
-		gbl_search = true;
-		if (dbll_sym) {
-			redefined_symbol = true;
-			dev_dbg(bridge, "%s already defined in symbol table\n",
-				name);
-			return NULL;
-		}
-	}
-	/* Allocate string to copy symbol name */
-	symbol.name = kzalloc(strlen((char *const)name) + 1, GFP_KERNEL);
-	if (symbol.name == NULL)
-		return NULL;
-
-	if (symbol.name != NULL) {
-		/* Just copy name (value will be filled in by dynamic loader) */
-		strncpy(symbol.name, (char *const)name,
-			strlen((char *const)name) + 1);
-
-		/* Add symbol to symbol table */
-		sym_ptr =
-		    (struct dbll_symbol *)gh_insert(lib->sym_tab, (void *)name,
-						    (void *)&symbol);
-		if (IS_ERR(sym_ptr)) {
-			kfree(symbol.name);
-			sym_ptr = NULL;
-		}
-
-	}
-	if (sym_ptr != NULL)
-		ret = (struct dynload_symbol *)&sym_ptr->value;
-	else
-		ret = NULL;
-
-	return ret;
-}
-
-/*
- *  ======== dbll_purge_symbol_table ========
- */
-static void dbll_purge_symbol_table(struct dynamic_loader_sym *this,
-				    unsigned module_id)
-{
-	struct ldr_symbol *ldr_sym = (struct ldr_symbol *)this;
-	struct dbll_library_obj *lib;
-
-	lib = ldr_sym->lib;
-	/* May not need to do anything */
-}
-
-/*
- *  ======== allocate ========
- */
-static void *allocate(struct dynamic_loader_sym *this, unsigned memsize)
-{
-	struct ldr_symbol *ldr_sym = (struct ldr_symbol *)this;
-	struct dbll_library_obj *lib;
-	void *buf;
-
-	lib = ldr_sym->lib;
-
-	buf = kzalloc(memsize, GFP_KERNEL);
-
-	return buf;
-}
-
-/*
- *  ======== deallocate ========
- */
-static void deallocate(struct dynamic_loader_sym *this, void *mem_ptr)
-{
-	struct ldr_symbol *ldr_sym = (struct ldr_symbol *)this;
-	struct dbll_library_obj *lib;
-
-	lib = ldr_sym->lib;
-
-	kfree(mem_ptr);
-}
-
-/*
- *  ======== dbll_err_report ========
- */
-static void dbll_err_report(struct dynamic_loader_sym *this, const char *errstr,
-			    va_list args)
-{
-	struct ldr_symbol *ldr_sym = (struct ldr_symbol *)this;
-	struct dbll_library_obj *lib;
-	char temp_buf[MAXEXPR];
-
-	lib = ldr_sym->lib;
-	vsnprintf((char *)temp_buf, MAXEXPR, (char *)errstr, args);
-	dev_dbg(bridge, "%s\n", temp_buf);
-}
-
-/* dynamic_loader_allocate */
-
-/*
- *  ======== dbll_rmm_alloc ========
- */
-static int dbll_rmm_alloc(struct dynamic_loader_allocate *this,
-			  struct ldr_section_info *info, unsigned align)
-{
-	struct dbll_alloc *dbll_alloc_obj = (struct dbll_alloc *)this;
-	struct dbll_library_obj *lib;
-	int status = 0;
-	u32 mem_sect_type;
-	struct rmm_addr rmm_addr_obj;
-	s32 ret = true;
-	unsigned stype = DLOAD_SECTION_TYPE(info->type);
-	char *token = NULL;
-	char *sz_sec_last_token = NULL;
-	char *sz_last_token = NULL;
-	char *sz_sect_name = NULL;
-	char *psz_cur;
-	s32 token_len = 0;
-	s32 seg_id = -1;
-	s32 req = -1;
-	s32 count = 0;
-	u32 alloc_size = 0;
-	u32 run_addr_flag = 0;
-
-	lib = dbll_alloc_obj->lib;
-
-	mem_sect_type =
-	    (stype == DLOAD_TEXT) ? DBLL_CODE : (stype ==
-						 DLOAD_BSS) ? DBLL_BSS :
-	    DBLL_DATA;
-
-	/* Attempt to extract the segment ID and requirement information from
-	   the name of the section */
-	token_len = strlen((char *)(info->name)) + 1;
-
-	sz_sect_name = kzalloc(token_len, GFP_KERNEL);
-	sz_last_token = kzalloc(token_len, GFP_KERNEL);
-	sz_sec_last_token = kzalloc(token_len, GFP_KERNEL);
-
-	if (sz_sect_name == NULL || sz_sec_last_token == NULL ||
-	    sz_last_token == NULL) {
-		status = -ENOMEM;
-		goto func_cont;
-	}
-	strncpy(sz_sect_name, (char *)(info->name), token_len);
-	psz_cur = sz_sect_name;
-	while ((token = strsep(&psz_cur, ":")) && *token != '\0') {
-		strncpy(sz_sec_last_token, sz_last_token,
-			strlen(sz_last_token) + 1);
-		strncpy(sz_last_token, token, strlen(token) + 1);
-		token = strsep(&psz_cur, ":");
-		count++;	/* optimizes processing */
-	}
-	/* If token is 0 or 1, and sz_sec_last_token is DYN_DARAM or DYN_SARAM,
-	   or DYN_EXTERNAL, then mem granularity information is present
-	   within the section name - only process if there are at least three
-	   tokens within the section name (just a minor optimization) */
-	if (count >= 3) {
-		status = kstrtos32(sz_last_token, 10, &req);
-		if (status)
-			goto func_cont;
-	}
-
-	if ((req == 0) || (req == 1)) {
-		if (strcmp(sz_sec_last_token, "DYN_DARAM") == 0) {
-			seg_id = 0;
-		} else {
-			if (strcmp(sz_sec_last_token, "DYN_SARAM") == 0) {
-				seg_id = 1;
-			} else {
-				if (strcmp(sz_sec_last_token,
-					   "DYN_EXTERNAL") == 0)
-					seg_id = 2;
-			}
-		}
-	}
-func_cont:
-	kfree(sz_sect_name);
-	sz_sect_name = NULL;
-	kfree(sz_last_token);
-	sz_last_token = NULL;
-	kfree(sz_sec_last_token);
-	sz_sec_last_token = NULL;
-
-	if (mem_sect_type == DBLL_CODE)
-		alloc_size = info->size + GEM_L1P_PREFETCH_SIZE;
-	else
-		alloc_size = info->size;
-
-	if (info->load_addr != info->run_addr)
-		run_addr_flag = 1;
-	/* TODO - ideally, we can pass the alignment requirement also
-	 * from here */
-	if (lib != NULL) {
-		status =
-		    (lib->target_obj->attrs.alloc) (lib->target_obj->attrs.
-						    rmm_handle, mem_sect_type,
-						    alloc_size, align,
-						    (u32 *) &rmm_addr_obj,
-						    seg_id, req, false);
-	}
-	if (status) {
-		ret = false;
-	} else {
-		/* RMM gives word address. Need to convert to byte address */
-		info->load_addr = rmm_addr_obj.addr * DSPWORDSIZE;
-		if (!run_addr_flag)
-			info->run_addr = info->load_addr;
-		info->context = (u32) rmm_addr_obj.segid;
-		dev_dbg(bridge, "%s: %s base = 0x%x len = 0x%x, info->run_addr 0x%x, info->load_addr 0x%x\n",
-			__func__, info->name, info->load_addr / DSPWORDSIZE,
-			info->size / DSPWORDSIZE, info->run_addr,
-			info->load_addr);
-	}
-	return ret;
-}
-
-/*
- *  ======== rmm_dealloc ========
- */
-static void rmm_dealloc(struct dynamic_loader_allocate *this,
-			struct ldr_section_info *info)
-{
-	struct dbll_alloc *dbll_alloc_obj = (struct dbll_alloc *)this;
-	struct dbll_library_obj *lib;
-	u32 segid;
-	int status = 0;
-	unsigned stype = DLOAD_SECTION_TYPE(info->type);
-	u32 mem_sect_type;
-	u32 free_size = 0;
-
-	mem_sect_type =
-	    (stype == DLOAD_TEXT) ? DBLL_CODE : (stype ==
-						 DLOAD_BSS) ? DBLL_BSS :
-	    DBLL_DATA;
-	lib = dbll_alloc_obj->lib;
-	/* segid was set by alloc function */
-	segid = (u32) info->context;
-	if (mem_sect_type == DBLL_CODE)
-		free_size = info->size + GEM_L1P_PREFETCH_SIZE;
-	else
-		free_size = info->size;
-	if (lib != NULL) {
-		status =
-		    (lib->target_obj->attrs.free) (lib->target_obj->attrs.
-						   sym_handle, segid,
-						   info->load_addr /
-						   DSPWORDSIZE, free_size,
-						   false);
-	}
-}
-
-/* dynamic_loader_initialize */
-/*
- *  ======== connect ========
- */
-static int connect(struct dynamic_loader_initialize *this)
-{
-	return true;
-}
-
-/*
- *  ======== read_mem ========
- *  This function does not need to be implemented.
- */
-static int read_mem(struct dynamic_loader_initialize *this, void *buf,
-		    ldr_addr addr, struct ldr_section_info *info,
-		    unsigned nbytes)
-{
-	struct dbll_init_obj *init_obj = (struct dbll_init_obj *)this;
-	struct dbll_library_obj *lib;
-	int bytes_read = 0;
-
-	lib = init_obj->lib;
-	/* Need bridge_brd_read function */
-	return bytes_read;
-}
-
-/*
- *  ======== write_mem ========
- */
-static int write_mem(struct dynamic_loader_initialize *this, void *buf,
-		     ldr_addr addr, struct ldr_section_info *info,
-		     unsigned bytes)
-{
-	struct dbll_init_obj *init_obj = (struct dbll_init_obj *)this;
-	struct dbll_library_obj *lib;
-	struct dbll_tar_obj *target_obj;
-	struct dbll_sect_info sect_info;
-	u32 mem_sect_type;
-	bool ret = true;
-
-	lib = init_obj->lib;
-	if (!lib)
-		return false;
-
-	target_obj = lib->target_obj;
-
-	mem_sect_type =
-	    (DLOAD_SECTION_TYPE(info->type) ==
-	     DLOAD_TEXT) ? DBLL_CODE : DBLL_DATA;
-	if (target_obj && target_obj->attrs.write) {
-		ret =
-		    (*target_obj->attrs.write) (target_obj->attrs.input_params,
-						addr, buf, bytes,
-						mem_sect_type);
-
-		if (target_obj->attrs.log_write) {
-			sect_info.name = info->name;
-			sect_info.sect_run_addr = info->run_addr;
-			sect_info.sect_load_addr = info->load_addr;
-			sect_info.size = info->size;
-			sect_info.type = mem_sect_type;
-			/* Pass the information about what we've written to
-			 * another module */
-			(*target_obj->attrs.log_write) (target_obj->attrs.
-							log_write_handle,
-							&sect_info, addr,
-							bytes);
-		}
-	}
-	return ret;
-}
-
-/*
- *  ======== fill_mem ========
- *  Fill bytes of memory at a given address with a given value by
- *  writing from a buffer containing the given value.  Write in
- *  sets of MAXEXPR (128) bytes to avoid large stack buffer issues.
- */
-static int fill_mem(struct dynamic_loader_initialize *this, ldr_addr addr,
-		    struct ldr_section_info *info, unsigned bytes, unsigned val)
-{
-	bool ret = true;
-	char *pbuf;
-	struct dbll_library_obj *lib;
-	struct dbll_init_obj *init_obj = (struct dbll_init_obj *)this;
-
-	lib = init_obj->lib;
-	pbuf = NULL;
-	/* Pass the NULL pointer to write_mem to get the start address of Shared
-	   memory. This is a trick to just get the start address, there is no
-	   writing taking place with this Writemem
-	 */
-	if ((lib->target_obj->attrs.write) != (dbll_write_fxn) no_op)
-		write_mem(this, &pbuf, addr, info, 0);
-	if (pbuf)
-		memset(pbuf, val, bytes);
-
-	return ret;
-}
-
-/*
- *  ======== execute ========
- */
-static int execute(struct dynamic_loader_initialize *this, ldr_addr start)
-{
-	struct dbll_init_obj *init_obj = (struct dbll_init_obj *)this;
-	struct dbll_library_obj *lib;
-	bool ret = true;
-
-	lib = init_obj->lib;
-	/* Save entry point */
-	if (lib != NULL)
-		lib->entry = (u32) start;
-
-	return ret;
-}
-
-/*
- *  ======== release ========
- */
-static void release(struct dynamic_loader_initialize *this)
-{
-}
-
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-/**
- *  find_symbol_context - Basic symbol context structure
- * @address:		Symbol Address
- * @offset_range:		Offset range where the search for the DSP symbol
- *			started.
- * @cur_best_offset:	Best offset to start looking for the DSP symbol
- * @sym_addr:		Address of the DSP symbol
- * @name:		Symbol name
- *
- */
-struct find_symbol_context {
-	/* input */
-	u32 address;
-	u32 offset_range;
-	/* state */
-	u32 cur_best_offset;
-	/* output */
-	u32 sym_addr;
-	char name[120];
-};
-
-/**
- * find_symbol_callback() - Validates symbol address and copies the symbol name
- *			to the user data.
- * @elem:		dsp library context
- * @user_data:		Find symbol context
- *
- */
-void find_symbol_callback(void *elem, void *user_data)
-{
-	struct dbll_symbol *symbol = elem;
-	struct find_symbol_context *context = user_data;
-	u32 symbol_addr = symbol->value.value;
-	u32 offset = context->address - symbol_addr;
-
-	/*
-	 * Address given should be greater than symbol address,
-	 * symbol address should be  within specified range
-	 * and the offset should be better than previous one
-	 */
-	if (context->address >= symbol_addr && symbol_addr < (u32)-1 &&
-		offset < context->cur_best_offset) {
-		context->cur_best_offset = offset;
-		context->sym_addr = symbol_addr;
-		strlcpy(context->name, symbol->name, sizeof(context->name));
-	}
-
-	return;
-}
-
-/**
- * dbll_find_dsp_symbol() - This function retrieves the dsp symbol from the dsp binary.
- * @zl_lib:		DSP binary obj library pointer
- * @address:		Given address to find the dsp symbol
- * @offset_range:		offset range to look for dsp symbol
- * @sym_addr_output:	Symbol Output address
- * @name_output:		String with the dsp symbol
- *
- *	This function retrieves the dsp symbol from the dsp binary.
- */
-bool dbll_find_dsp_symbol(struct dbll_library_obj *zl_lib, u32 address,
-				u32 offset_range, u32 *sym_addr_output,
-				char *name_output)
-{
-	bool status = false;
-	struct find_symbol_context context;
-
-	context.address = address;
-	context.offset_range = offset_range;
-	context.cur_best_offset = offset_range;
-	context.sym_addr = 0;
-	context.name[0] = '\0';
-
-	gh_iterate(zl_lib->sym_tab, find_symbol_callback, &context);
-
-	if (context.name[0]) {
-		status = true;
-		strcpy(name_output, context.name);
-		*sym_addr_output = context.sym_addr;
-	}
-
-	return status;
-}
-#endif
diff --git a/drivers/staging/tidspbridge/pmgr/dev.c b/drivers/staging/tidspbridge/pmgr/dev.c
deleted file mode 100644
index 616dc1f..0000000
--- a/drivers/staging/tidspbridge/pmgr/dev.c
+++ /dev/null
@@ -1,969 +0,0 @@
-/*
- * dev.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Implementation of Bridge Bridge driver device operations.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#include <linux/types.h>
-#include <linux/list.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/cod.h>
-#include <dspbridge/drv.h>
-#include <dspbridge/proc.h>
-#include <dspbridge/dmm.h>
-
-/*  ----------------------------------- Resource Manager */
-#include <dspbridge/mgr.h>
-#include <dspbridge/node.h>
-
-/*  ----------------------------------- Others */
-#include <dspbridge/dspapi.h>	/* DSP API version info. */
-
-#include <dspbridge/chnl.h>
-#include <dspbridge/io.h>
-#include <dspbridge/msg.h>
-#include <dspbridge/cmm.h>
-#include <dspbridge/dspdeh.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/dev.h>
-
-/*  ----------------------------------- Defines, Data Structures, Typedefs */
-
-#define MAKEVERSION(major, minor)   (major * 10 + minor)
-#define BRD_API_VERSION		MAKEVERSION(BRD_API_MAJOR_VERSION,	\
-				BRD_API_MINOR_VERSION)
-
-/* The Bridge device object: */
-struct dev_object {
-	struct list_head link;	/* Link to next dev_object. */
-	u8 dev_type;		/* Device Type */
-	struct cfg_devnode *dev_node_obj;	/* Platform specific dev id */
-	/* Bridge Context Handle */
-	struct bridge_dev_context *bridge_context;
-	/* Function interface to Bridge driver. */
-	struct bridge_drv_interface bridge_interface;
-	struct brd_object *lock_owner;	/* Client with exclusive access. */
-	struct cod_manager *cod_mgr;	/* Code manager handle. */
-	struct chnl_mgr *chnl_mgr;	/* Channel manager. */
-	struct deh_mgr *deh_mgr;	/* DEH manager. */
-	struct msg_mgr *msg_mgr;	/* Message manager. */
-	struct io_mgr *iomgr;	/* IO manager (CHNL, msg_ctrl) */
-	struct cmm_object *cmm_mgr;	/* SM memory manager. */
-	struct dmm_object *dmm_mgr;	/* Dynamic memory manager. */
-	u32 word_size;		/* DSP word size: quick access. */
-	struct drv_object *drv_obj;	/* Driver Object */
-	/* List of Processors attached to this device */
-	struct list_head proc_list;
-	struct node_mgr *node_mgr;
-};
-
-struct drv_ext {
-	struct list_head link;
-	char sz_string[MAXREGPATHLENGTH];
-};
-
-/*  ----------------------------------- Function Prototypes */
-static int fxn_not_implemented(int arg, ...);
-static int init_cod_mgr(struct dev_object *dev_obj);
-static void store_interface_fxns(struct bridge_drv_interface *drv_fxns,
-				 struct bridge_drv_interface *intf_fxns);
-/*
- *  ======== dev_brd_write_fxn ========
- *  Purpose:
- *      Exported function to be used as the COD write function.  This function
- *      is passed a handle to a DEV_hObject, then calls the
- *      device's bridge_brd_write() function.
- */
-u32 dev_brd_write_fxn(void *arb, u32 dsp_add, void *host_buf,
-		      u32 ul_num_bytes, u32 mem_space)
-{
-	struct dev_object *dev_obj = (struct dev_object *)arb;
-	u32 ul_written = 0;
-	int status;
-
-	if (dev_obj) {
-		/* Require of BrdWrite() */
-		status = (*dev_obj->bridge_interface.brd_write) (
-					dev_obj->bridge_context, host_buf,
-					dsp_add, ul_num_bytes, mem_space);
-		/* Special case of getting the address only */
-		if (ul_num_bytes == 0)
-			ul_num_bytes = 1;
-		if (!status)
-			ul_written = ul_num_bytes;
-
-	}
-	return ul_written;
-}
-
-/*
- *  ======== dev_create_device ========
- *  Purpose:
- *      Called by the operating system to load the PM Bridge Driver for a
- *      PM board (device).
- */
-int dev_create_device(struct dev_object **device_obj,
-			     const char *driver_file_name,
-			     struct cfg_devnode *dev_node_obj)
-{
-	struct cfg_hostres *host_res;
-	struct bridge_drv_interface *drv_fxns = NULL;
-	struct dev_object *dev_obj = NULL;
-	struct chnl_mgrattrs mgr_attrs;
-	struct io_attrs io_mgr_attrs;
-	u32 num_windows;
-	struct drv_object *hdrv_obj = NULL;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-	int status = 0;
-
-	status = drv_request_bridge_res_dsp((void *)&host_res);
-
-	if (status) {
-		dev_dbg(bridge, "%s: Failed to reserve bridge resources\n",
-			__func__);
-		goto leave;
-	}
-
-	/*  Get the Bridge driver interface functions */
-	bridge_drv_entry(&drv_fxns, driver_file_name);
-
-	/* Retrieve the Object handle from the driver data */
-	if (drv_datap && drv_datap->drv_object) {
-		hdrv_obj = drv_datap->drv_object;
-	} else {
-		status = -EPERM;
-		pr_err("%s: Failed to retrieve the object handle\n", __func__);
-	}
-
-	/* Create the device object, and pass a handle to the Bridge driver for
-	 * storage. */
-	if (!status) {
-		dev_obj = kzalloc(sizeof(struct dev_object), GFP_KERNEL);
-		if (dev_obj) {
-			/* Fill out the rest of the Dev Object structure: */
-			dev_obj->dev_node_obj = dev_node_obj;
-			dev_obj->cod_mgr = NULL;
-			dev_obj->chnl_mgr = NULL;
-			dev_obj->deh_mgr = NULL;
-			dev_obj->lock_owner = NULL;
-			dev_obj->word_size = DSPWORDSIZE;
-			dev_obj->drv_obj = hdrv_obj;
-			dev_obj->dev_type = DSP_UNIT;
-			/* Store this Bridge's interface functions, based on its
-			 * version. */
-			store_interface_fxns(drv_fxns,
-						&dev_obj->bridge_interface);
-
-			/* Call fxn_dev_create() to get the Bridge's device
-			 * context handle. */
-			status = (dev_obj->bridge_interface.dev_create)
-			    (&dev_obj->bridge_context, dev_obj,
-			     host_res);
-		} else {
-			status = -ENOMEM;
-		}
-	}
-	/* Attempt to create the COD manager for this device: */
-	if (!status)
-		status = init_cod_mgr(dev_obj);
-
-	/* Attempt to create the channel manager for this device: */
-	if (!status) {
-		mgr_attrs.max_channels = CHNL_MAXCHANNELS;
-		io_mgr_attrs.birq = host_res->birq_registers;
-		io_mgr_attrs.irq_shared =
-		    (host_res->birq_attrib & CFG_IRQSHARED);
-		io_mgr_attrs.word_size = DSPWORDSIZE;
-		mgr_attrs.word_size = DSPWORDSIZE;
-		num_windows = host_res->num_mem_windows;
-		if (num_windows) {
-			/* Assume last memory window is for CHNL */
-			io_mgr_attrs.shm_base = host_res->mem_base[1] +
-			    host_res->offset_for_monitor;
-			io_mgr_attrs.sm_length =
-			    host_res->mem_length[1] -
-			    host_res->offset_for_monitor;
-		} else {
-			io_mgr_attrs.shm_base = 0;
-			io_mgr_attrs.sm_length = 0;
-			pr_err("%s: No memory reserved for shared structures\n",
-			       __func__);
-		}
-		status = chnl_create(&dev_obj->chnl_mgr, dev_obj, &mgr_attrs);
-		if (status == -ENOSYS) {
-			/* It's OK for a device not to have a channel
-			 * manager: */
-			status = 0;
-		}
-		/* Create CMM mgr even if Msg Mgr not impl. */
-		status = cmm_create(&dev_obj->cmm_mgr,
-				    (struct dev_object *)dev_obj, NULL);
-		/* Only create IO manager if we have a channel manager */
-		if (!status && dev_obj->chnl_mgr) {
-			status = io_create(&dev_obj->iomgr, dev_obj,
-					   &io_mgr_attrs);
-		}
-		/* Only create DEH manager if we have an IO manager */
-		if (!status) {
-			/* Instantiate the DEH module */
-			status = bridge_deh_create(&dev_obj->deh_mgr, dev_obj);
-		}
-		/* Create DMM mgr . */
-		status = dmm_create(&dev_obj->dmm_mgr,
-				    (struct dev_object *)dev_obj, NULL);
-	}
-	/* Add the new DEV_Object to the global list: */
-	if (!status)
-		status = drv_insert_dev_object(hdrv_obj, dev_obj);
-
-	/* Create the Processor List */
-	if (!status)
-		INIT_LIST_HEAD(&dev_obj->proc_list);
-leave:
-	/*  If all went well, return a handle to the dev object;
-	 *  else, cleanup and return NULL in the OUT parameter. */
-	if (!status) {
-		*device_obj = dev_obj;
-	} else {
-		if (dev_obj) {
-			if (dev_obj->cod_mgr)
-				cod_delete(dev_obj->cod_mgr);
-			if (dev_obj->dmm_mgr)
-				dmm_destroy(dev_obj->dmm_mgr);
-			kfree(dev_obj);
-		}
-
-		*device_obj = NULL;
-	}
-
-	return status;
-}
-
-/*
- *  ======== dev_create2 ========
- *  Purpose:
- *      After successful loading of the image from api_init_complete2
- *      (PROC Auto_Start) or proc_load this fxn is called. This creates
- *      the Node Manager and updates the DEV Object.
- */
-int dev_create2(struct dev_object *hdev_obj)
-{
-	int status = 0;
-	struct dev_object *dev_obj = hdev_obj;
-
-	/* There can be only one Node Manager per DEV object */
-	status = node_create_mgr(&dev_obj->node_mgr, hdev_obj);
-	if (status)
-		dev_obj->node_mgr = NULL;
-
-	return status;
-}
-
-/*
- *  ======== dev_destroy2 ========
- *  Purpose:
- *      Destroys the Node manager for this device.
- */
-int dev_destroy2(struct dev_object *hdev_obj)
-{
-	int status = 0;
-	struct dev_object *dev_obj = hdev_obj;
-
-	if (dev_obj->node_mgr) {
-		if (node_delete_mgr(dev_obj->node_mgr))
-			status = -EPERM;
-		else
-			dev_obj->node_mgr = NULL;
-
-	}
-
-	return status;
-}
-
-/*
- *  ======== dev_destroy_device ========
- *  Purpose:
- *      Destroys the channel manager for this device, if any, calls
- *      bridge_dev_destroy(), and then attempts to unload the Bridge module.
- */
-int dev_destroy_device(struct dev_object *hdev_obj)
-{
-	int status = 0;
-	struct dev_object *dev_obj = hdev_obj;
-
-	if (hdev_obj) {
-		if (dev_obj->cod_mgr) {
-			cod_delete(dev_obj->cod_mgr);
-			dev_obj->cod_mgr = NULL;
-		}
-
-		if (dev_obj->node_mgr) {
-			node_delete_mgr(dev_obj->node_mgr);
-			dev_obj->node_mgr = NULL;
-		}
-
-		/* Free the io, channel, and message managers for this board: */
-		if (dev_obj->iomgr) {
-			io_destroy(dev_obj->iomgr);
-			dev_obj->iomgr = NULL;
-		}
-		if (dev_obj->chnl_mgr) {
-			chnl_destroy(dev_obj->chnl_mgr);
-			dev_obj->chnl_mgr = NULL;
-		}
-		if (dev_obj->msg_mgr) {
-			msg_delete(dev_obj->msg_mgr);
-			dev_obj->msg_mgr = NULL;
-		}
-
-		if (dev_obj->deh_mgr) {
-			/* Uninitialize DEH module. */
-			bridge_deh_destroy(dev_obj->deh_mgr);
-			dev_obj->deh_mgr = NULL;
-		}
-		if (dev_obj->cmm_mgr) {
-			cmm_destroy(dev_obj->cmm_mgr, true);
-			dev_obj->cmm_mgr = NULL;
-		}
-
-		if (dev_obj->dmm_mgr) {
-			dmm_destroy(dev_obj->dmm_mgr);
-			dev_obj->dmm_mgr = NULL;
-		}
-
-		/* Call the driver's bridge_dev_destroy() function: */
-		/* Require of DevDestroy */
-		if (dev_obj->bridge_context) {
-			status = (*dev_obj->bridge_interface.dev_destroy)
-			    (dev_obj->bridge_context);
-			dev_obj->bridge_context = NULL;
-		} else
-			status = -EPERM;
-		if (!status) {
-			/* Remove this DEV_Object from the global list: */
-			drv_remove_dev_object(dev_obj->drv_obj, dev_obj);
-			/* Free The library * LDR_FreeModule
-			 * (dev_obj->module_obj); */
-			/* Free this dev object: */
-			kfree(dev_obj);
-			dev_obj = NULL;
-		}
-	} else {
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== dev_get_chnl_mgr ========
- *  Purpose:
- *      Retrieve the handle to the channel manager handle created for this
- *      device.
- */
-int dev_get_chnl_mgr(struct dev_object *hdev_obj,
-			    struct chnl_mgr **mgr)
-{
-	int status = 0;
-	struct dev_object *dev_obj = hdev_obj;
-
-	if (hdev_obj) {
-		*mgr = dev_obj->chnl_mgr;
-	} else {
-		*mgr = NULL;
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== dev_get_cmm_mgr ========
- *  Purpose:
- *      Retrieve the handle to the shared memory manager created for this
- *      device.
- */
-int dev_get_cmm_mgr(struct dev_object *hdev_obj,
-			   struct cmm_object **mgr)
-{
-	int status = 0;
-	struct dev_object *dev_obj = hdev_obj;
-
-	if (hdev_obj) {
-		*mgr = dev_obj->cmm_mgr;
-	} else {
-		*mgr = NULL;
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== dev_get_dmm_mgr ========
- *  Purpose:
- *      Retrieve the handle to the dynamic memory manager created for this
- *      device.
- */
-int dev_get_dmm_mgr(struct dev_object *hdev_obj,
-			   struct dmm_object **mgr)
-{
-	int status = 0;
-	struct dev_object *dev_obj = hdev_obj;
-
-	if (hdev_obj) {
-		*mgr = dev_obj->dmm_mgr;
-	} else {
-		*mgr = NULL;
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== dev_get_cod_mgr ========
- *  Purpose:
- *      Retrieve the COD manager create for this device.
- */
-int dev_get_cod_mgr(struct dev_object *hdev_obj,
-			   struct cod_manager **cod_mgr)
-{
-	int status = 0;
-	struct dev_object *dev_obj = hdev_obj;
-
-	if (hdev_obj) {
-		*cod_mgr = dev_obj->cod_mgr;
-	} else {
-		*cod_mgr = NULL;
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ========= dev_get_deh_mgr ========
- */
-int dev_get_deh_mgr(struct dev_object *hdev_obj,
-			   struct deh_mgr **deh_manager)
-{
-	int status = 0;
-
-	if (hdev_obj) {
-		*deh_manager = hdev_obj->deh_mgr;
-	} else {
-		*deh_manager = NULL;
-		status = -EFAULT;
-	}
-	return status;
-}
-
-/*
- *  ======== dev_get_dev_node ========
- *  Purpose:
- *      Retrieve the platform specific device ID for this device.
- */
-int dev_get_dev_node(struct dev_object *hdev_obj,
-			    struct cfg_devnode **dev_nde)
-{
-	int status = 0;
-	struct dev_object *dev_obj = hdev_obj;
-
-	if (hdev_obj) {
-		*dev_nde = dev_obj->dev_node_obj;
-	} else {
-		*dev_nde = NULL;
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== dev_get_first ========
- *  Purpose:
- *      Retrieve the first Device Object handle from an internal linked list
- *      DEV_OBJECTs maintained by DEV.
- */
-struct dev_object *dev_get_first(void)
-{
-	struct dev_object *dev_obj = NULL;
-
-	dev_obj = (struct dev_object *)drv_get_first_dev_object();
-
-	return dev_obj;
-}
-
-/*
- *  ======== dev_get_intf_fxns ========
- *  Purpose:
- *      Retrieve the Bridge interface function structure for the loaded driver.
- *      if_fxns != NULL.
- */
-int dev_get_intf_fxns(struct dev_object *hdev_obj,
-			     struct bridge_drv_interface **if_fxns)
-{
-	int status = 0;
-	struct dev_object *dev_obj = hdev_obj;
-
-	if (hdev_obj) {
-		*if_fxns = &dev_obj->bridge_interface;
-	} else {
-		*if_fxns = NULL;
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ========= dev_get_io_mgr ========
- */
-int dev_get_io_mgr(struct dev_object *hdev_obj,
-			  struct io_mgr **io_man)
-{
-	int status = 0;
-
-	if (hdev_obj) {
-		*io_man = hdev_obj->iomgr;
-	} else {
-		*io_man = NULL;
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== dev_get_next ========
- *  Purpose:
- *      Retrieve the next Device Object handle from an internal linked list
- *      of DEV_OBJECTs maintained by DEV, after having previously called
- *      dev_get_first() and zero or more dev_get_next
- */
-struct dev_object *dev_get_next(struct dev_object *hdev_obj)
-{
-	struct dev_object *next_dev_object = NULL;
-
-	if (hdev_obj) {
-		next_dev_object = (struct dev_object *)
-		    drv_get_next_dev_object((u32) hdev_obj);
-	}
-
-	return next_dev_object;
-}
-
-/*
- *  ========= dev_get_msg_mgr ========
- */
-void dev_get_msg_mgr(struct dev_object *hdev_obj, struct msg_mgr **msg_man)
-{
-	*msg_man = hdev_obj->msg_mgr;
-}
-
-/*
- *  ======== dev_get_node_manager ========
- *  Purpose:
- *      Retrieve the Node Manager Handle
- */
-int dev_get_node_manager(struct dev_object *hdev_obj,
-				struct node_mgr **node_man)
-{
-	int status = 0;
-	struct dev_object *dev_obj = hdev_obj;
-
-	if (hdev_obj) {
-		*node_man = dev_obj->node_mgr;
-	} else {
-		*node_man = NULL;
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== dev_get_symbol ========
- */
-int dev_get_symbol(struct dev_object *hdev_obj,
-			  const char *str_sym, u32 *pul_value)
-{
-	int status = 0;
-	struct cod_manager *cod_mgr;
-
-	if (hdev_obj) {
-		status = dev_get_cod_mgr(hdev_obj, &cod_mgr);
-		if (cod_mgr)
-			status = cod_get_sym_value(cod_mgr, (char *)str_sym,
-						   pul_value);
-		else
-			status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== dev_get_bridge_context ========
- *  Purpose:
- *      Retrieve the Bridge Context handle, as returned by the
- *      bridge_dev_create fxn.
- */
-int dev_get_bridge_context(struct dev_object *hdev_obj,
-			       struct bridge_dev_context **phbridge_context)
-{
-	int status = 0;
-	struct dev_object *dev_obj = hdev_obj;
-
-	if (hdev_obj) {
-		*phbridge_context = dev_obj->bridge_context;
-	} else {
-		*phbridge_context = NULL;
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== dev_notify_clients ========
- *  Purpose:
- *      Notify all clients of this device of a change in device status.
- */
-int dev_notify_clients(struct dev_object *dev_obj, u32 ret)
-{
-	struct list_head *curr;
-
-	/*
-	 * FIXME: this code needs struct proc_object to have a list_head
-	 * at the beginning. If not, this can go horribly wrong.
-	 */
-	list_for_each(curr, &dev_obj->proc_list)
-		proc_notify_clients((void *)curr, ret);
-
-	return 0;
-}
-
-/*
- *  ======== dev_remove_device ========
- */
-int dev_remove_device(struct cfg_devnode *dev_node_obj)
-{
-	struct dev_object *hdev_obj;	/* handle to device object */
-	int status = 0;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	if (!drv_datap)
-		status = -ENODATA;
-
-	if (!dev_node_obj)
-		status = -EFAULT;
-
-	/* Retrieve the device object handle originally stored with
-	 * the dev_node: */
-	if (!status) {
-		/* check the device string and then store dev object */
-		if (!strcmp((char *)((struct drv_ext *)dev_node_obj)->sz_string,
-								"TIOMAP1510")) {
-			hdev_obj = drv_datap->dev_object;
-			/* Destroy the device object. */
-			status = dev_destroy_device(hdev_obj);
-		} else {
-			status = -EPERM;
-		}
-	}
-
-	if (status)
-		pr_err("%s: Failed, status 0x%x\n", __func__, status);
-
-	return status;
-}
-
-/*
- *  ======== dev_set_chnl_mgr ========
- *  Purpose:
- *      Set the channel manager for this device.
- */
-int dev_set_chnl_mgr(struct dev_object *hdev_obj,
-			    struct chnl_mgr *hmgr)
-{
-	int status = 0;
-	struct dev_object *dev_obj = hdev_obj;
-
-	if (hdev_obj)
-		dev_obj->chnl_mgr = hmgr;
-	else
-		status = -EFAULT;
-
-	return status;
-}
-
-/*
- *  ======== dev_set_msg_mgr ========
- *  Purpose:
- *      Set the message manager for this device.
- */
-void dev_set_msg_mgr(struct dev_object *hdev_obj, struct msg_mgr *hmgr)
-{
-	hdev_obj->msg_mgr = hmgr;
-}
-
-/*
- *  ======== dev_start_device ========
- *  Purpose:
- *      Initializes the new device with the BRIDGE environment.
- */
-int dev_start_device(struct cfg_devnode *dev_node_obj)
-{
-	struct dev_object *hdev_obj = NULL;	/* handle to 'Bridge Device */
-	/* Bridge driver filename */
-	char *bridge_file_name = "UMA";
-	int status;
-	struct mgr_object *hmgr_obj = NULL;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	/* Given all resources, create a device object. */
-	status = dev_create_device(&hdev_obj, bridge_file_name,
-				   dev_node_obj);
-	if (!status) {
-		/* Store away the hdev_obj with the DEVNODE */
-		if (!drv_datap || !dev_node_obj) {
-			status = -EFAULT;
-			pr_err("%s: Failed, status 0x%x\n", __func__, status);
-		} else if (!(strcmp((char *)dev_node_obj, "TIOMAP1510"))) {
-			drv_datap->dev_object = (void *) hdev_obj;
-		}
-		if (!status) {
-			/* Create the Manager Object */
-			status = mgr_create(&hmgr_obj, dev_node_obj);
-			if (status && !(strcmp((char *)dev_node_obj,
-							"TIOMAP1510"))) {
-				/* Ensure the device extension is NULL */
-				drv_datap->dev_object = NULL;
-			}
-		}
-		if (status) {
-			/* Clean up */
-			dev_destroy_device(hdev_obj);
-			hdev_obj = NULL;
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== fxn_not_implemented ========
- *  Purpose:
- *      Takes the place of a Bridge Null Function.
- *  Parameters:
- *      Multiple, optional.
- *  Returns:
- *      -ENOSYS:   Always.
- */
-static int fxn_not_implemented(int arg, ...)
-{
-	return -ENOSYS;
-}
-
-/*
- *  ======== init_cod_mgr ========
- *  Purpose:
- *      Create a COD manager for this device.
- *  Parameters:
- *      dev_obj:             Pointer to device object created with
- *                              dev_create_device()
- *  Returns:
- *      0:                Success.
- *      -EFAULT:            Invalid hdev_obj.
- *  Requires:
- *      Should only be called once by dev_create_device() for a given DevObject.
- *  Ensures:
- */
-static int init_cod_mgr(struct dev_object *dev_obj)
-{
-	int status = 0;
-	char *sz_dummy_file = "dummy";
-
-	status = cod_create(&dev_obj->cod_mgr, sz_dummy_file);
-
-	return status;
-}
-
-/*
- *  ======== dev_insert_proc_object ========
- *  Purpose:
- *      Insert a ProcObject into the list maintained by DEV.
- *  Parameters:
- *      p_proc_object:        Ptr to ProcObject to insert.
- *      dev_obj:         Ptr to Dev Object where the list is.
-  *     already_attached:  Ptr to return the bool
- *  Returns:
- *      0:           If successful.
- *  Requires:
- *      List Exists
- *      hdev_obj is Valid handle
- *      DEV Initialized
- *      already_attached != NULL
- *      proc_obj != 0
- *  Ensures:
- *      0 and List is not Empty.
- */
-int dev_insert_proc_object(struct dev_object *hdev_obj,
-				  u32 proc_obj, bool *already_attached)
-{
-	struct dev_object *dev_obj = (struct dev_object *)hdev_obj;
-
-	if (!list_empty(&dev_obj->proc_list))
-		*already_attached = true;
-
-	/* Add DevObject to tail. */
-	/*
-	 * FIXME: this code needs struct proc_object to have a list_head
-	 * at the beginning. If not, this can go horribly wrong.
-	 */
-	list_add_tail((struct list_head *)proc_obj, &dev_obj->proc_list);
-
-	return 0;
-}
-
-/*
- *  ======== dev_remove_proc_object ========
- *  Purpose:
- *      Search for and remove a Proc object from the given list maintained
- *      by the DEV
- *  Parameters:
- *      p_proc_object:        Ptr to ProcObject to insert.
- *      dev_obj          Ptr to Dev Object where the list is.
- *  Returns:
- *      0:            If successful.
- *  Requires:
- *      List exists and is not empty
- *      proc_obj != 0
- *      hdev_obj is a valid Dev handle.
- *  Ensures:
- *  Details:
- *      List will be deleted when the DEV is destroyed.
- */
-int dev_remove_proc_object(struct dev_object *hdev_obj, u32 proc_obj)
-{
-	int status = -EPERM;
-	struct list_head *cur_elem;
-	struct dev_object *dev_obj = (struct dev_object *)hdev_obj;
-
-	/* Search list for dev_obj: */
-	list_for_each(cur_elem, &dev_obj->proc_list) {
-		if ((u32) cur_elem == proc_obj) {
-			list_del(cur_elem);
-			status = 0;
-			break;
-		}
-	}
-
-	return status;
-}
-
-int dev_get_dev_type(struct dev_object *dev_obj, u8 *dev_type)
-{
-	*dev_type = dev_obj->dev_type;
-	return 0;
-}
-
-/*
- *  ======== store_interface_fxns ========
- *  Purpose:
- *      Copy the Bridge's interface functions into the device object,
- *      ensuring that fxn_not_implemented() is set for:
- *
- *      1. All Bridge function pointers which are NULL; and
- *      2. All function slots in the struct dev_object structure which have no
- *         corresponding slots in the the Bridge's interface, because the Bridge
- *         is of an *older* version.
- *  Parameters:
- *      intf_fxns:      Interface fxn Structure of the Bridge's Dev Object.
- *      drv_fxns:      Interface Fxns offered by the Bridge during DEV_Create().
- *  Returns:
- *  Requires:
- *      Input pointers are valid.
- *      Bridge driver is *not* written for a newer DSP API.
- *  Ensures:
- *      All function pointers in the dev object's fxn interface are not NULL.
- */
-static void store_interface_fxns(struct bridge_drv_interface *drv_fxns,
-				 struct bridge_drv_interface *intf_fxns)
-{
-	u32 bridge_version;
-
-	/* Local helper macro: */
-#define  STORE_FXN(cast, pfn) \
-	(intf_fxns->pfn = ((drv_fxns->pfn != NULL) ? drv_fxns->pfn : \
-			   (cast)fxn_not_implemented))
-
-	bridge_version = MAKEVERSION(drv_fxns->brd_api_major_version,
-				     drv_fxns->brd_api_minor_version);
-	intf_fxns->brd_api_major_version = drv_fxns->brd_api_major_version;
-	intf_fxns->brd_api_minor_version = drv_fxns->brd_api_minor_version;
-	/* Install functions up to DSP API version .80 (first alpha): */
-	if (bridge_version > 0) {
-		STORE_FXN(fxn_dev_create, dev_create);
-		STORE_FXN(fxn_dev_destroy, dev_destroy);
-		STORE_FXN(fxn_dev_ctrl, dev_cntrl);
-		STORE_FXN(fxn_brd_monitor, brd_monitor);
-		STORE_FXN(fxn_brd_start, brd_start);
-		STORE_FXN(fxn_brd_stop, brd_stop);
-		STORE_FXN(fxn_brd_status, brd_status);
-		STORE_FXN(fxn_brd_read, brd_read);
-		STORE_FXN(fxn_brd_write, brd_write);
-		STORE_FXN(fxn_brd_setstate, brd_set_state);
-		STORE_FXN(fxn_brd_memcopy, brd_mem_copy);
-		STORE_FXN(fxn_brd_memwrite, brd_mem_write);
-		STORE_FXN(fxn_brd_memmap, brd_mem_map);
-		STORE_FXN(fxn_brd_memunmap, brd_mem_un_map);
-		STORE_FXN(fxn_chnl_create, chnl_create);
-		STORE_FXN(fxn_chnl_destroy, chnl_destroy);
-		STORE_FXN(fxn_chnl_open, chnl_open);
-		STORE_FXN(fxn_chnl_close, chnl_close);
-		STORE_FXN(fxn_chnl_addioreq, chnl_add_io_req);
-		STORE_FXN(fxn_chnl_getioc, chnl_get_ioc);
-		STORE_FXN(fxn_chnl_cancelio, chnl_cancel_io);
-		STORE_FXN(fxn_chnl_flushio, chnl_flush_io);
-		STORE_FXN(fxn_chnl_getinfo, chnl_get_info);
-		STORE_FXN(fxn_chnl_getmgrinfo, chnl_get_mgr_info);
-		STORE_FXN(fxn_chnl_idle, chnl_idle);
-		STORE_FXN(fxn_chnl_registernotify, chnl_register_notify);
-		STORE_FXN(fxn_io_create, io_create);
-		STORE_FXN(fxn_io_destroy, io_destroy);
-		STORE_FXN(fxn_io_onloaded, io_on_loaded);
-		STORE_FXN(fxn_io_getprocload, io_get_proc_load);
-		STORE_FXN(fxn_msg_create, msg_create);
-		STORE_FXN(fxn_msg_createqueue, msg_create_queue);
-		STORE_FXN(fxn_msg_delete, msg_delete);
-		STORE_FXN(fxn_msg_deletequeue, msg_delete_queue);
-		STORE_FXN(fxn_msg_get, msg_get);
-		STORE_FXN(fxn_msg_put, msg_put);
-		STORE_FXN(fxn_msg_registernotify, msg_register_notify);
-		STORE_FXN(fxn_msg_setqueueid, msg_set_queue_id);
-	}
-	/* Add code for any additional functions in newerBridge versions here */
-#undef  STORE_FXN
-}
diff --git a/drivers/staging/tidspbridge/pmgr/dmm.c b/drivers/staging/tidspbridge/pmgr/dmm.c
deleted file mode 100644
index fcf564a..0000000
--- a/drivers/staging/tidspbridge/pmgr/dmm.c
+++ /dev/null
@@ -1,487 +0,0 @@
-/*
- * dmm.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * The Dynamic Memory Manager (DMM) module manages the DSP Virtual address
- * space that can be directly mapped to any MPU buffer or memory region
- *
- * Notes:
- *   Region: Generic memory entitiy having a start address and a size
- *   Chunk:  Reserved region
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#include <linux/types.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/sync.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/dev.h>
-#include <dspbridge/proc.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/dmm.h>
-
-/*  ----------------------------------- Defines, Data Structures, Typedefs */
-#define DMM_ADDR_VIRTUAL(a) \
-	(((struct map_page *)(a) - virtual_mapping_table) * PG_SIZE4K +\
-	dyn_mem_map_beg)
-#define DMM_ADDR_TO_INDEX(a) (((a) - dyn_mem_map_beg) / PG_SIZE4K)
-
-/* DMM Mgr */
-struct dmm_object {
-	/* Dmm Lock is used to serialize access mem manager for
-	 * multi-threads. */
-	spinlock_t dmm_lock;	/* Lock to access dmm mgr */
-};
-
-struct map_page {
-	u32 region_size:15;
-	u32 mapped_size:15;
-	u32 reserved:1;
-	u32 mapped:1;
-};
-
-/*  Create the free list */
-static struct map_page *virtual_mapping_table;
-static u32 free_region;		/* The index of free region */
-static u32 free_size;
-static u32 dyn_mem_map_beg;	/* The Beginning of dynamic memory mapping */
-static u32 table_size;		/* The size of virt and phys pages tables */
-
-/*  ----------------------------------- Function Prototypes */
-static struct map_page *get_region(u32 addr);
-static struct map_page *get_free_region(u32 len);
-static struct map_page *get_mapped_region(u32 addrs);
-
-/*  ======== dmm_create_tables ========
- *  Purpose:
- *      Create table to hold the information of physical address
- *      the buffer pages that is passed by the user, and the table
- *      to hold the information of the virtual memory that is reserved
- *      for DSP.
- */
-int dmm_create_tables(struct dmm_object *dmm_mgr, u32 addr, u32 size)
-{
-	struct dmm_object *dmm_obj = (struct dmm_object *)dmm_mgr;
-	int status = 0;
-
-	status = dmm_delete_tables(dmm_obj);
-	if (!status) {
-		dyn_mem_map_beg = addr;
-		table_size = PG_ALIGN_HIGH(size, PG_SIZE4K) / PG_SIZE4K;
-		/*  Create the free list */
-		virtual_mapping_table = __vmalloc(table_size *
-				sizeof(struct map_page), GFP_KERNEL |
-				__GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
-		if (virtual_mapping_table == NULL)
-			status = -ENOMEM;
-		else {
-			/* On successful allocation,
-			 * all entries are zero ('free') */
-			free_region = 0;
-			free_size = table_size * PG_SIZE4K;
-			virtual_mapping_table[0].region_size = table_size;
-		}
-	}
-
-	if (status)
-		pr_err("%s: failure, status 0x%x\n", __func__, status);
-
-	return status;
-}
-
-/*
- *  ======== dmm_create ========
- *  Purpose:
- *      Create a dynamic memory manager object.
- */
-int dmm_create(struct dmm_object **dmm_manager,
-		      struct dev_object *hdev_obj,
-		      const struct dmm_mgrattrs *mgr_attrts)
-{
-	struct dmm_object *dmm_obj = NULL;
-	int status = 0;
-
-	*dmm_manager = NULL;
-	/* create, zero, and tag a cmm mgr object */
-	dmm_obj = kzalloc(sizeof(struct dmm_object), GFP_KERNEL);
-	if (dmm_obj != NULL) {
-		spin_lock_init(&dmm_obj->dmm_lock);
-		*dmm_manager = dmm_obj;
-	} else {
-		status = -ENOMEM;
-	}
-
-	return status;
-}
-
-/*
- *  ======== dmm_destroy ========
- *  Purpose:
- *      Release the communication memory manager resources.
- */
-int dmm_destroy(struct dmm_object *dmm_mgr)
-{
-	struct dmm_object *dmm_obj = (struct dmm_object *)dmm_mgr;
-	int status = 0;
-
-	if (dmm_mgr) {
-		status = dmm_delete_tables(dmm_obj);
-		if (!status)
-			kfree(dmm_obj);
-	} else
-		status = -EFAULT;
-
-	return status;
-}
-
-/*
- *  ======== dmm_delete_tables ========
- *  Purpose:
- *      Delete DMM Tables.
- */
-int dmm_delete_tables(struct dmm_object *dmm_mgr)
-{
-	int status = 0;
-
-	/* Delete all DMM tables */
-	if (dmm_mgr)
-		vfree(virtual_mapping_table);
-	else
-		status = -EFAULT;
-	return status;
-}
-
-/*
- *  ======== dmm_get_handle ========
- *  Purpose:
- *      Return the dynamic memory manager object for this device.
- *      This is typically called from the client process.
- */
-int dmm_get_handle(void *hprocessor, struct dmm_object **dmm_manager)
-{
-	int status = 0;
-	struct dev_object *hdev_obj;
-
-	if (hprocessor != NULL)
-		status = proc_get_dev_object(hprocessor, &hdev_obj);
-	else
-		hdev_obj = dev_get_first();	/* default */
-
-	if (!status)
-		status = dev_get_dmm_mgr(hdev_obj, dmm_manager);
-
-	return status;
-}
-
-/*
- *  ======== dmm_map_memory ========
- *  Purpose:
- *      Add a mapping block to the reserved chunk. DMM assumes that this block
- *  will be mapped in the DSP/IVA's address space. DMM returns an error if a
- *  mapping overlaps another one. This function stores the info that will be
- *  required later while unmapping the block.
- */
-int dmm_map_memory(struct dmm_object *dmm_mgr, u32 addr, u32 size)
-{
-	struct dmm_object *dmm_obj = (struct dmm_object *)dmm_mgr;
-	struct map_page *chunk;
-	int status = 0;
-
-	spin_lock(&dmm_obj->dmm_lock);
-	/* Find the Reserved memory chunk containing the DSP block to
-	 * be mapped */
-	chunk = (struct map_page *)get_region(addr);
-	if (chunk != NULL) {
-		/* Mark the region 'mapped', leave the 'reserved' info as-is */
-		chunk->mapped = true;
-		chunk->mapped_size = (size / PG_SIZE4K);
-	} else
-		status = -ENOENT;
-	spin_unlock(&dmm_obj->dmm_lock);
-
-	dev_dbg(bridge, "%s dmm_mgr %p, addr %x, size %x\n\tstatus %x, chunk %p",
-			__func__, dmm_mgr, addr, size, status, chunk);
-
-	return status;
-}
-
-/*
- *  ======== dmm_reserve_memory ========
- *  Purpose:
- *      Reserve a chunk of virtually contiguous DSP/IVA address space.
- */
-int dmm_reserve_memory(struct dmm_object *dmm_mgr, u32 size,
-			      u32 *prsv_addr)
-{
-	int status = 0;
-	struct dmm_object *dmm_obj = (struct dmm_object *)dmm_mgr;
-	struct map_page *node;
-	u32 rsv_addr = 0;
-	u32 rsv_size = 0;
-
-	spin_lock(&dmm_obj->dmm_lock);
-
-	/* Try to get a DSP chunk from the free list */
-	node = get_free_region(size);
-	if (node != NULL) {
-		/*  DSP chunk of given size is available. */
-		rsv_addr = DMM_ADDR_VIRTUAL(node);
-		/* Calculate the number entries to use */
-		rsv_size = size / PG_SIZE4K;
-		if (rsv_size < node->region_size) {
-			/* Mark remainder of free region */
-			node[rsv_size].mapped = false;
-			node[rsv_size].reserved = false;
-			node[rsv_size].region_size =
-			    node->region_size - rsv_size;
-			node[rsv_size].mapped_size = 0;
-		}
-		/*  get_region will return first fit chunk. But we only use what
-		   is requested. */
-		node->mapped = false;
-		node->reserved = true;
-		node->region_size = rsv_size;
-		node->mapped_size = 0;
-		/* Return the chunk's starting address */
-		*prsv_addr = rsv_addr;
-	} else
-		/*dSP chunk of given size is not available */
-		status = -ENOMEM;
-
-	spin_unlock(&dmm_obj->dmm_lock);
-
-	dev_dbg(bridge, "%s dmm_mgr %p, size %x, prsv_addr %p\n\tstatus %x, rsv_addr %x, rsv_size %x\n",
-			__func__, dmm_mgr, size,
-			prsv_addr, status, rsv_addr, rsv_size);
-
-	return status;
-}
-
-/*
- *  ======== dmm_un_map_memory ========
- *  Purpose:
- *      Remove the mapped block from the reserved chunk.
- */
-int dmm_un_map_memory(struct dmm_object *dmm_mgr, u32 addr, u32 *psize)
-{
-	struct dmm_object *dmm_obj = (struct dmm_object *)dmm_mgr;
-	struct map_page *chunk;
-	int status = 0;
-
-	spin_lock(&dmm_obj->dmm_lock);
-	chunk = get_mapped_region(addr);
-	if (chunk == NULL)
-		status = -ENOENT;
-
-	if (!status) {
-		/* Unmap the region */
-		*psize = chunk->mapped_size * PG_SIZE4K;
-		chunk->mapped = false;
-		chunk->mapped_size = 0;
-	}
-	spin_unlock(&dmm_obj->dmm_lock);
-
-	dev_dbg(bridge, "%s: dmm_mgr %p, addr %x, psize %p\n\tstatus %x, chunk %p\n",
-			__func__, dmm_mgr, addr, psize, status, chunk);
-
-	return status;
-}
-
-/*
- *  ======== dmm_un_reserve_memory ========
- *  Purpose:
- *      Free a chunk of reserved DSP/IVA address space.
- */
-int dmm_un_reserve_memory(struct dmm_object *dmm_mgr, u32 rsv_addr)
-{
-	struct dmm_object *dmm_obj = (struct dmm_object *)dmm_mgr;
-	struct map_page *chunk;
-	u32 i;
-	int status = 0;
-	u32 chunk_size;
-
-	spin_lock(&dmm_obj->dmm_lock);
-
-	/* Find the chunk containing the reserved address */
-	chunk = get_mapped_region(rsv_addr);
-	if (chunk == NULL)
-		status = -ENOENT;
-
-	if (!status) {
-		/* Free all the mapped pages for this reserved region */
-		i = 0;
-		while (i < chunk->region_size) {
-			if (chunk[i].mapped) {
-				/* Remove mapping from the page tables. */
-				chunk_size = chunk[i].mapped_size;
-				/* Clear the mapping flags */
-				chunk[i].mapped = false;
-				chunk[i].mapped_size = 0;
-				i += chunk_size;
-			} else
-				i++;
-		}
-		/* Clear the flags (mark the region 'free') */
-		chunk->reserved = false;
-		/* NOTE: We do NOT coalesce free regions here.
-		 * Free regions are coalesced in get_region(), as it traverses
-		 *the whole mapping table
-		 */
-	}
-	spin_unlock(&dmm_obj->dmm_lock);
-
-	dev_dbg(bridge, "%s: dmm_mgr %p, rsv_addr %x\n\tstatus %x chunk %p",
-		__func__, dmm_mgr, rsv_addr, status, chunk);
-
-	return status;
-}
-
-/*
- *  ======== get_region ========
- *  Purpose:
- *      Returns a region containing the specified memory region
- */
-static struct map_page *get_region(u32 addr)
-{
-	struct map_page *curr_region = NULL;
-	u32 i = 0;
-
-	if (virtual_mapping_table != NULL) {
-		/* find page mapped by this address */
-		i = DMM_ADDR_TO_INDEX(addr);
-		if (i < table_size)
-			curr_region = virtual_mapping_table + i;
-	}
-
-	dev_dbg(bridge, "%s: curr_region %p, free_region %d, free_size %d\n",
-		__func__, curr_region, free_region, free_size);
-	return curr_region;
-}
-
-/*
- *  ======== get_free_region ========
- *  Purpose:
- *  Returns the requested free region
- */
-static struct map_page *get_free_region(u32 len)
-{
-	struct map_page *curr_region = NULL;
-	u32 i = 0;
-	u32 region_size = 0;
-	u32 next_i = 0;
-
-	if (virtual_mapping_table == NULL)
-		return curr_region;
-	if (len > free_size) {
-		/* Find the largest free region
-		 * (coalesce during the traversal) */
-		while (i < table_size) {
-			region_size = virtual_mapping_table[i].region_size;
-			next_i = i + region_size;
-			if (virtual_mapping_table[i].reserved == false) {
-				/* Coalesce, if possible */
-				if (next_i < table_size &&
-				    virtual_mapping_table[next_i].reserved
-				    == false) {
-					virtual_mapping_table[i].region_size +=
-					    virtual_mapping_table
-					    [next_i].region_size;
-					continue;
-				}
-				region_size *= PG_SIZE4K;
-				if (region_size > free_size) {
-					free_region = i;
-					free_size = region_size;
-				}
-			}
-			i = next_i;
-		}
-	}
-	if (len <= free_size) {
-		curr_region = virtual_mapping_table + free_region;
-		free_region += (len / PG_SIZE4K);
-		free_size -= len;
-	}
-	return curr_region;
-}
-
-/*
- *  ======== get_mapped_region ========
- *  Purpose:
- *  Returns the requestedmapped region
- */
-static struct map_page *get_mapped_region(u32 addrs)
-{
-	u32 i = 0;
-	struct map_page *curr_region = NULL;
-
-	if (virtual_mapping_table == NULL)
-		return curr_region;
-
-	i = DMM_ADDR_TO_INDEX(addrs);
-	if (i < table_size && (virtual_mapping_table[i].mapped ||
-			       virtual_mapping_table[i].reserved))
-		curr_region = virtual_mapping_table + i;
-	return curr_region;
-}
-
-#ifdef DSP_DMM_DEBUG
-u32 dmm_mem_map_dump(struct dmm_object *dmm_mgr)
-{
-	struct map_page *curr_node = NULL;
-	u32 i;
-	u32 freemem = 0;
-	u32 bigsize = 0;
-
-	spin_lock(&dmm_mgr->dmm_lock);
-
-	if (virtual_mapping_table != NULL) {
-		for (i = 0; i < table_size; i +=
-		     virtual_mapping_table[i].region_size) {
-			curr_node = virtual_mapping_table + i;
-			if (curr_node->reserved) {
-				/*printk("RESERVED size = 0x%x, "
-				   "Map size = 0x%x\n",
-				   (curr_node->region_size * PG_SIZE4K),
-				   (curr_node->mapped == false) ? 0 :
-				   (curr_node->mapped_size * PG_SIZE4K));
-				 */
-			} else {
-/*				printk("UNRESERVED size = 0x%x\n",
-					(curr_node->region_size * PG_SIZE4K));
- */
-				freemem += (curr_node->region_size * PG_SIZE4K);
-				if (curr_node->region_size > bigsize)
-					bigsize = curr_node->region_size;
-			}
-		}
-	}
-	spin_unlock(&dmm_mgr->dmm_lock);
-	dev_info(bridge, "Total DSP VA FREE memory = %d Mbytes\n",
-	       freemem / (1024 * 1024));
-	dev_info(bridge, "Total DSP VA USED memory= %d Mbytes\n",
-	       (((table_size * PG_SIZE4K) - freemem)) / (1024 * 1024));
-	dev_info(bridge, "DSP VA - Biggest FREE block = %d Mbytes\n",
-	       (bigsize * PG_SIZE4K / (1024 * 1024)));
-
-	return 0;
-}
-#endif
diff --git a/drivers/staging/tidspbridge/pmgr/dspapi.c b/drivers/staging/tidspbridge/pmgr/dspapi.c
deleted file mode 100644
index c4ccf17..0000000
--- a/drivers/staging/tidspbridge/pmgr/dspapi.c
+++ /dev/null
@@ -1,1841 +0,0 @@
-/*
- * dspapi.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Common DSP API functions, also includes the wrapper
- * functions called directly by the DeviceIOControl interface.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#include <linux/types.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/ntfy.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/chnl.h>
-#include <dspbridge/dev.h>
-#include <dspbridge/drv.h>
-
-#include <dspbridge/proc.h>
-#include <dspbridge/strm.h>
-
-/*  ----------------------------------- Resource Manager */
-#include <dspbridge/disp.h>
-#include <dspbridge/mgr.h>
-#include <dspbridge/node.h>
-#include <dspbridge/rmm.h>
-
-/*  ----------------------------------- Others */
-#include <dspbridge/msg.h>
-#include <dspbridge/cmm.h>
-#include <dspbridge/io.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/dspapi.h>
-#include <dspbridge/dbdcd.h>
-
-#include <dspbridge/resourcecleanup.h>
-
-/*  ----------------------------------- Defines, Data Structures, Typedefs */
-#define MAX_TRACEBUFLEN 255
-#define MAX_LOADARGS    16
-#define MAX_NODES       64
-#define MAX_STREAMS     16
-#define MAX_BUFS	64
-
-/* Used to get dspbridge ioctl table */
-#define DB_GET_IOC_TABLE(cmd)	(DB_GET_MODULE(cmd) >> DB_MODULE_SHIFT)
-
-/* Device IOCtl function pointer */
-struct api_cmd {
-	u32(*fxn) (union trapped_args *args, void *pr_ctxt);
-	u32 index;
-};
-
-/*  ----------------------------------- Globals */
-static u32 api_c_refs;
-
-/*
- *  Function tables.
- *  The order of these functions MUST be the same as the order of the command
- *  numbers defined in dspapi-ioctl.h  This is how an IOCTL number in user mode
- *  turns into a function call in kernel mode.
- */
-
-/* MGR wrapper functions */
-static struct api_cmd mgr_cmd[] = {
-	{mgrwrap_enum_node_info},	/* MGR_ENUMNODE_INFO */
-	{mgrwrap_enum_proc_info},	/* MGR_ENUMPROC_INFO */
-	{mgrwrap_register_object},	/* MGR_REGISTEROBJECT */
-	{mgrwrap_unregister_object},	/* MGR_UNREGISTEROBJECT */
-	{mgrwrap_wait_for_bridge_events},	/* MGR_WAIT */
-	{mgrwrap_get_process_resources_info},	/* MGR_GET_PROC_RES */
-};
-
-/* PROC wrapper functions */
-static struct api_cmd proc_cmd[] = {
-	{procwrap_attach},	/* PROC_ATTACH */
-	{procwrap_ctrl},	/* PROC_CTRL */
-	{procwrap_detach},	/* PROC_DETACH */
-	{procwrap_enum_node_info},	/* PROC_ENUMNODE */
-	{procwrap_enum_resources},	/* PROC_ENUMRESOURCES */
-	{procwrap_get_state},	/* PROC_GET_STATE */
-	{procwrap_get_trace},	/* PROC_GET_TRACE */
-	{procwrap_load},	/* PROC_LOAD */
-	{procwrap_register_notify},	/* PROC_REGISTERNOTIFY */
-	{procwrap_start},	/* PROC_START */
-	{procwrap_reserve_memory},	/* PROC_RSVMEM */
-	{procwrap_un_reserve_memory},	/* PROC_UNRSVMEM */
-	{procwrap_map},		/* PROC_MAPMEM */
-	{procwrap_un_map},	/* PROC_UNMAPMEM */
-	{procwrap_flush_memory},	/* PROC_FLUSHMEMORY */
-	{procwrap_stop},	/* PROC_STOP */
-	{procwrap_invalidate_memory},	/* PROC_INVALIDATEMEMORY */
-	{procwrap_begin_dma},	/* PROC_BEGINDMA */
-	{procwrap_end_dma},	/* PROC_ENDDMA */
-};
-
-/* NODE wrapper functions */
-static struct api_cmd node_cmd[] = {
-	{nodewrap_allocate},	/* NODE_ALLOCATE */
-	{nodewrap_alloc_msg_buf},	/* NODE_ALLOCMSGBUF */
-	{nodewrap_change_priority},	/* NODE_CHANGEPRIORITY */
-	{nodewrap_connect},	/* NODE_CONNECT */
-	{nodewrap_create},	/* NODE_CREATE */
-	{nodewrap_delete},	/* NODE_DELETE */
-	{nodewrap_free_msg_buf},	/* NODE_FREEMSGBUF */
-	{nodewrap_get_attr},	/* NODE_GETATTR */
-	{nodewrap_get_message},	/* NODE_GETMESSAGE */
-	{nodewrap_pause},	/* NODE_PAUSE */
-	{nodewrap_put_message},	/* NODE_PUTMESSAGE */
-	{nodewrap_register_notify},	/* NODE_REGISTERNOTIFY */
-	{nodewrap_run},		/* NODE_RUN */
-	{nodewrap_terminate},	/* NODE_TERMINATE */
-	{nodewrap_get_uuid_props},	/* NODE_GETUUIDPROPS */
-};
-
-/* STRM wrapper functions */
-static struct api_cmd strm_cmd[] = {
-	{strmwrap_allocate_buffer},	/* STRM_ALLOCATEBUFFER */
-	{strmwrap_close},	/* STRM_CLOSE */
-	{strmwrap_free_buffer},	/* STRM_FREEBUFFER */
-	{strmwrap_get_event_handle},	/* STRM_GETEVENTHANDLE */
-	{strmwrap_get_info},	/* STRM_GETINFO */
-	{strmwrap_idle},	/* STRM_IDLE */
-	{strmwrap_issue},	/* STRM_ISSUE */
-	{strmwrap_open},	/* STRM_OPEN */
-	{strmwrap_reclaim},	/* STRM_RECLAIM */
-	{strmwrap_register_notify},	/* STRM_REGISTERNOTIFY */
-	{strmwrap_select},	/* STRM_SELECT */
-};
-
-/* CMM wrapper functions */
-static struct api_cmd cmm_cmd[] = {
-	{cmmwrap_calloc_buf},	/* CMM_ALLOCBUF */
-	{cmmwrap_free_buf},	/* CMM_FREEBUF */
-	{cmmwrap_get_handle},	/* CMM_GETHANDLE */
-	{cmmwrap_get_info},	/* CMM_GETINFO */
-};
-
-/* Array used to store ioctl table sizes. It can hold up to 8 entries */
-static u8 size_cmd[] = {
-	ARRAY_SIZE(mgr_cmd),
-	ARRAY_SIZE(proc_cmd),
-	ARRAY_SIZE(node_cmd),
-	ARRAY_SIZE(strm_cmd),
-	ARRAY_SIZE(cmm_cmd),
-};
-
-static inline void _cp_fm_usr(void *to, const void __user *from,
-			      int *err, unsigned long bytes)
-{
-	if (*err)
-		return;
-
-	if (unlikely(!from)) {
-		*err = -EFAULT;
-		return;
-	}
-
-	if (unlikely(copy_from_user(to, from, bytes)))
-		*err = -EFAULT;
-}
-
-#define CP_FM_USR(to, from, err, n)				\
-	_cp_fm_usr(to, from, &(err), (n) * sizeof(*(to)))
-
-static inline void _cp_to_usr(void __user *to, const void *from,
-			      int *err, unsigned long bytes)
-{
-	if (*err)
-		return;
-
-	if (unlikely(!to)) {
-		*err = -EFAULT;
-		return;
-	}
-
-	if (unlikely(copy_to_user(to, from, bytes)))
-		*err = -EFAULT;
-}
-
-#define CP_TO_USR(to, from, err, n)				\
-	_cp_to_usr(to, from, &(err), (n) * sizeof(*(from)))
-
-/*
- *  ======== api_call_dev_ioctl ========
- *  Purpose:
- *      Call the (wrapper) function for the corresponding API IOCTL.
- */
-inline int api_call_dev_ioctl(u32 cmd, union trapped_args *args,
-				      u32 *result, void *pr_ctxt)
-{
-	u32(*ioctl_cmd) (union trapped_args *args, void *pr_ctxt) = NULL;
-	int i;
-
-	if (_IOC_TYPE(cmd) != DB) {
-		pr_err("%s: Incompatible dspbridge ioctl number\n", __func__);
-		goto err;
-	}
-
-	if (DB_GET_IOC_TABLE(cmd) > ARRAY_SIZE(size_cmd)) {
-		pr_err("%s: undefined ioctl module\n", __func__);
-		goto err;
-	}
-
-	/* Check the size of the required cmd table */
-	i = DB_GET_IOC(cmd);
-	if (i > size_cmd[DB_GET_IOC_TABLE(cmd)]) {
-		pr_err("%s: requested ioctl %d out of bounds for table %d\n",
-		       __func__, i, DB_GET_IOC_TABLE(cmd));
-		goto err;
-	}
-
-	switch (DB_GET_MODULE(cmd)) {
-	case DB_MGR:
-		ioctl_cmd = mgr_cmd[i].fxn;
-		break;
-	case DB_PROC:
-		ioctl_cmd = proc_cmd[i].fxn;
-		break;
-	case DB_NODE:
-		ioctl_cmd = node_cmd[i].fxn;
-		break;
-	case DB_STRM:
-		ioctl_cmd = strm_cmd[i].fxn;
-		break;
-	case DB_CMM:
-		ioctl_cmd = cmm_cmd[i].fxn;
-		break;
-	}
-
-	if (!ioctl_cmd) {
-		pr_err("%s: requested ioctl not defined\n", __func__);
-		goto err;
-	} else {
-		*result = (*ioctl_cmd) (args, pr_ctxt);
-	}
-
-	return 0;
-
-err:
-	return -EINVAL;
-}
-
-/*
- *  ======== api_exit ========
- */
-void api_exit(void)
-{
-	api_c_refs--;
-
-	if (api_c_refs == 0)
-		mgr_exit();
-}
-
-/*
- *  ======== api_init ========
- *  Purpose:
- *      Module initialization used by Bridge API.
- */
-bool api_init(void)
-{
-	bool ret = true;
-
-	if (api_c_refs == 0)
-		ret = mgr_init();
-
-	if (ret)
-		api_c_refs++;
-
-	return ret;
-}
-
-/*
- *  ======== api_init_complete2 ========
- *  Purpose:
- *      Perform any required bridge initialization which cannot
- *      be performed in api_init() or dev_start_device() due
- *      to the fact that some services are not yet
- *      completely initialized.
- *  Parameters:
- *  Returns:
- *      0:	Allow this device to load
- *      -EPERM:      Failure.
- *  Requires:
- *      Bridge API initialized.
- *  Ensures:
- */
-int api_init_complete2(void)
-{
-	int status = 0;
-	struct cfg_devnode *dev_node;
-	struct dev_object *hdev_obj;
-	struct drv_data *drv_datap;
-	u8 dev_type;
-
-	/*  Walk the list of DevObjects, get each devnode, and attempting to
-	 *  autostart the board. Note that this requires COF loading, which
-	 *  requires KFILE. */
-	for (hdev_obj = dev_get_first(); hdev_obj != NULL;
-	     hdev_obj = dev_get_next(hdev_obj)) {
-		if (dev_get_dev_node(hdev_obj, &dev_node))
-			continue;
-
-		if (dev_get_dev_type(hdev_obj, &dev_type))
-			continue;
-
-		if ((dev_type == DSP_UNIT) || (dev_type == IVA_UNIT)) {
-			drv_datap = dev_get_drvdata(bridge);
-
-			if (drv_datap && drv_datap->base_img)
-				proc_auto_start(dev_node, hdev_obj);
-		}
-	}
-
-	return status;
-}
-
-/* TODO: Remove deprecated and not implemented ioctl wrappers */
-
-/*
- * ======== mgrwrap_enum_node_info ========
- */
-u32 mgrwrap_enum_node_info(union trapped_args *args, void *pr_ctxt)
-{
-	u8 *pndb_props;
-	u32 num_nodes = 0;
-	int status;
-	u32 size = args->args_mgr_enumnode_info.ndb_props_size;
-
-	if (size < sizeof(struct dsp_ndbprops))
-		return -EINVAL;
-	size = sizeof(struct dsp_ndbprops);
-
-	pndb_props = kmalloc(size, GFP_KERNEL);
-	if (pndb_props == NULL)
-		return -ENOMEM;
-
-	status =
-	    mgr_enum_node_info(args->args_mgr_enumnode_info.node_id,
-			       (struct dsp_ndbprops *)pndb_props, size,
-			       &num_nodes);
-
-	CP_TO_USR(args->args_mgr_enumnode_info.ndb_props, pndb_props, status,
-		  size);
-	CP_TO_USR(args->args_mgr_enumnode_info.num_nodes, &num_nodes, status,
-		  1);
-	kfree(pndb_props);
-
-	return status;
-}
-
-/*
- * ======== mgrwrap_enum_proc_info ========
- */
-u32 mgrwrap_enum_proc_info(union trapped_args *args, void *pr_ctxt)
-{
-	u8 *processor_info;
-	u8 num_procs = 0;
-	int status;
-	u32 size = args->args_mgr_enumproc_info.processor_info_size;
-
-	if (size < sizeof(struct dsp_processorinfo))
-		return -EINVAL;
-
-	if (size > sizeof(struct mgr_processorextinfo))
-		size = sizeof(struct mgr_processorextinfo);
-
-	processor_info = kzalloc(size, GFP_KERNEL);
-	if (processor_info == NULL)
-		return -ENOMEM;
-
-	status =
-	    mgr_enum_processor_info(args->args_mgr_enumproc_info.
-				    processor_id,
-				    (struct dsp_processorinfo *)
-				    processor_info, size, &num_procs);
-
-	CP_TO_USR(args->args_mgr_enumproc_info.processor_info, processor_info,
-		  status, size);
-	CP_TO_USR(args->args_mgr_enumproc_info.num_procs, &num_procs,
-		  status, 1);
-	kfree(processor_info);
-
-	return status;
-}
-
-#define WRAP_MAP2CALLER(x) x
-/*
- * ======== mgrwrap_register_object ========
- */
-u32 mgrwrap_register_object(union trapped_args *args, void *pr_ctxt)
-{
-	u32 ret;
-	struct dsp_uuid uuid_obj;
-	u32 path_size = 0;
-	char *psz_path_name = NULL;
-	int status = 0;
-
-	CP_FM_USR(&uuid_obj, args->args_mgr_registerobject.uuid_obj, status, 1);
-	if (status)
-		goto func_end;
-	path_size = strlen_user((char *)
-				args->args_mgr_registerobject.sz_path_name);
-	if (!path_size) {
-		status = -EINVAL;
-		goto func_end;
-	}
-
-	psz_path_name = kmalloc(path_size, GFP_KERNEL);
-	if (!psz_path_name) {
-		status = -ENOMEM;
-		goto func_end;
-	}
-	ret = strncpy_from_user(psz_path_name,
-				(char *)args->args_mgr_registerobject.
-				sz_path_name, path_size);
-	if (!ret) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	if (args->args_mgr_registerobject.obj_type >= DSP_DCDMAXOBJTYPE) {
-		status = -EINVAL;
-		goto func_end;
-	}
-
-	status = dcd_register_object(&uuid_obj,
-				     args->args_mgr_registerobject.obj_type,
-				     (char *)psz_path_name);
-func_end:
-	kfree(psz_path_name);
-	return status;
-}
-
-/*
- * ======== mgrwrap_unregister_object ========
- */
-u32 mgrwrap_unregister_object(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct dsp_uuid uuid_obj;
-
-	CP_FM_USR(&uuid_obj, args->args_mgr_registerobject.uuid_obj, status, 1);
-	if (status)
-		goto func_end;
-
-	status = dcd_unregister_object(&uuid_obj,
-				       args->args_mgr_unregisterobject.
-				       obj_type);
-func_end:
-	return status;
-
-}
-
-/*
- * ======== mgrwrap_wait_for_bridge_events ========
- */
-u32 mgrwrap_wait_for_bridge_events(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct dsp_notification *anotifications[MAX_EVENTS];
-	struct dsp_notification notifications[MAX_EVENTS];
-	u32 index = 0, i;
-	u32 count = args->args_mgr_wait.count;
-
-	if (count > MAX_EVENTS)
-		return -EINVAL;
-
-	/* get the array of pointers to user structures */
-	CP_FM_USR(anotifications, args->args_mgr_wait.anotifications,
-		  status, count);
-	/* get the events */
-	for (i = 0; i < count; i++) {
-		CP_FM_USR(&notifications[i], anotifications[i], status, 1);
-		if (status || !notifications[i].handle)
-			return -EINVAL;
-		/* set the array of pointers to kernel structures */
-		anotifications[i] = &notifications[i];
-	}
-	status = mgr_wait_for_bridge_events(anotifications, count,
-						 &index,
-						 args->args_mgr_wait.
-						 timeout);
-	CP_TO_USR(args->args_mgr_wait.index, &index, status, 1);
-	return status;
-}
-
-/*
- * ======== MGRWRAP_GetProcessResourceInfo ========
- */
-u32 __deprecated mgrwrap_get_process_resources_info(union trapped_args *args,
-						    void *pr_ctxt)
-{
-	pr_err("%s: deprecated dspbridge ioctl\n", __func__);
-	return 0;
-}
-
-/*
- * ======== procwrap_attach ========
- */
-u32 procwrap_attach(union trapped_args *args, void *pr_ctxt)
-{
-	void *processor;
-	int status = 0;
-	struct dsp_processorattrin proc_attr_in, *attr_in = NULL;
-
-	/* Optional argument */
-	if (args->args_proc_attach.attr_in) {
-		CP_FM_USR(&proc_attr_in, args->args_proc_attach.attr_in, status,
-			  1);
-		if (!status)
-			attr_in = &proc_attr_in;
-		else
-			goto func_end;
-
-	}
-	status = proc_attach(args->args_proc_attach.processor_id, attr_in,
-			     &processor, pr_ctxt);
-	CP_TO_USR(args->args_proc_attach.ph_processor, &processor, status, 1);
-func_end:
-	return status;
-}
-
-/*
- * ======== procwrap_ctrl ========
- */
-u32 procwrap_ctrl(union trapped_args *args, void *pr_ctxt)
-{
-	u32 cb_data_size, __user * psize = (u32 __user *)
-	    args->args_proc_ctrl.args;
-	u8 *pargs = NULL;
-	int status = 0;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	if (psize) {
-		if (get_user(cb_data_size, psize)) {
-			status = -EPERM;
-			goto func_end;
-		}
-		cb_data_size += sizeof(u32);
-		pargs = kmalloc(cb_data_size, GFP_KERNEL);
-		if (pargs == NULL) {
-			status = -ENOMEM;
-			goto func_end;
-		}
-
-		CP_FM_USR(pargs, args->args_proc_ctrl.args, status,
-			  cb_data_size);
-	}
-	if (!status) {
-		status = proc_ctrl(hprocessor,
-				   args->args_proc_ctrl.cmd,
-				   (struct dsp_cbdata *)pargs);
-	}
-
-	/* CP_TO_USR(args->args_proc_ctrl.args, pargs, status, 1); */
-	kfree(pargs);
-func_end:
-	return status;
-}
-
-/*
- * ======== procwrap_detach ========
- */
-u32 __deprecated procwrap_detach(union trapped_args *args, void *pr_ctxt)
-{
-	/* proc_detach called at bridge_release only */
-	pr_err("%s: deprecated dspbridge ioctl\n", __func__);
-	return 0;
-}
-
-/*
- * ======== procwrap_enum_node_info ========
- */
-u32 procwrap_enum_node_info(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-	void *node_tab[MAX_NODES];
-	u32 num_nodes;
-	u32 alloc_cnt;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	if (!args->args_proc_enumnode_info.node_tab_size)
-		return -EINVAL;
-
-	status = proc_enum_nodes(hprocessor,
-				 node_tab,
-				 args->args_proc_enumnode_info.node_tab_size,
-				 &num_nodes, &alloc_cnt);
-	CP_TO_USR(args->args_proc_enumnode_info.node_tab, node_tab, status,
-		  num_nodes);
-	CP_TO_USR(args->args_proc_enumnode_info.num_nodes, &num_nodes,
-		  status, 1);
-	CP_TO_USR(args->args_proc_enumnode_info.allocated, &alloc_cnt,
-		  status, 1);
-	return status;
-}
-
-u32 procwrap_end_dma(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-
-	if (args->args_proc_dma.dir >= DMA_NONE)
-		return -EINVAL;
-
-	status = proc_end_dma(pr_ctxt,
-				   args->args_proc_dma.mpu_addr,
-				   args->args_proc_dma.size,
-				   args->args_proc_dma.dir);
-	return status;
-}
-
-u32 procwrap_begin_dma(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-
-	if (args->args_proc_dma.dir >= DMA_NONE)
-		return -EINVAL;
-
-	status = proc_begin_dma(pr_ctxt,
-				   args->args_proc_dma.mpu_addr,
-				   args->args_proc_dma.size,
-				   args->args_proc_dma.dir);
-	return status;
-}
-
-/*
- * ======== procwrap_flush_memory ========
- */
-u32 procwrap_flush_memory(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-
-	if (args->args_proc_flushmemory.flags >
-	    PROC_WRITEBACK_INVALIDATE_MEM)
-		return -EINVAL;
-
-	status = proc_flush_memory(pr_ctxt,
-				   args->args_proc_flushmemory.mpu_addr,
-				   args->args_proc_flushmemory.size,
-				   args->args_proc_flushmemory.flags);
-	return status;
-}
-
-/*
- * ======== procwrap_invalidate_memory ========
- */
-u32 procwrap_invalidate_memory(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-
-	status =
-	    proc_invalidate_memory(pr_ctxt,
-				   args->args_proc_invalidatememory.mpu_addr,
-				   args->args_proc_invalidatememory.size);
-	return status;
-}
-
-/*
- * ======== procwrap_enum_resources ========
- */
-u32 procwrap_enum_resources(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct dsp_resourceinfo resource_info;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	if (args->args_proc_enumresources.resource_info_size <
-	    sizeof(struct dsp_resourceinfo))
-		return -EINVAL;
-
-	status =
-	    proc_get_resource_info(hprocessor,
-				   args->args_proc_enumresources.resource_type,
-				   &resource_info,
-				   args->args_proc_enumresources.
-				   resource_info_size);
-
-	CP_TO_USR(args->args_proc_enumresources.resource_info, &resource_info,
-		  status, 1);
-
-	return status;
-
-}
-
-/*
- * ======== procwrap_get_state ========
- */
-u32 procwrap_get_state(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-	struct dsp_processorstate proc_state;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	if (args->args_proc_getstate.state_info_size <
-	    sizeof(struct dsp_processorstate))
-		return -EINVAL;
-
-	status = proc_get_state(hprocessor, &proc_state,
-			   args->args_proc_getstate.state_info_size);
-	CP_TO_USR(args->args_proc_getstate.proc_state_obj, &proc_state, status,
-		  1);
-	return status;
-
-}
-
-/*
- * ======== procwrap_get_trace ========
- */
-u32 procwrap_get_trace(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-	u8 *pbuf;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	if (args->args_proc_gettrace.max_size > MAX_TRACEBUFLEN)
-		return -EINVAL;
-
-	pbuf = kzalloc(args->args_proc_gettrace.max_size, GFP_KERNEL);
-	if (pbuf != NULL) {
-		status = proc_get_trace(hprocessor, pbuf,
-					args->args_proc_gettrace.max_size);
-	} else {
-		status = -ENOMEM;
-	}
-	CP_TO_USR(args->args_proc_gettrace.buf, pbuf, status,
-		  args->args_proc_gettrace.max_size);
-	kfree(pbuf);
-
-	return status;
-}
-
-/*
- * ======== procwrap_load ========
- */
-u32 procwrap_load(union trapped_args *args, void *pr_ctxt)
-{
-	s32 i, len;
-	int status = 0;
-	char *temp;
-	s32 count = args->args_proc_load.argc_index;
-	u8 **argv = NULL, **envp = NULL;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	if (count <= 0 || count > MAX_LOADARGS) {
-		status = -EINVAL;
-		goto func_cont;
-	}
-
-	argv = kmalloc(count * sizeof(u8 *), GFP_KERNEL);
-	if (!argv) {
-		status = -ENOMEM;
-		goto func_cont;
-	}
-
-	CP_FM_USR(argv, args->args_proc_load.user_args, status, count);
-	if (status) {
-		kfree(argv);
-		argv = NULL;
-		goto func_cont;
-	}
-
-	for (i = 0; i < count; i++) {
-		if (argv[i]) {
-			/* User space pointer to argument */
-			temp = (char *)argv[i];
-			/* len is increased by 1 to accommodate NULL */
-			len = strlen_user((char *)temp) + 1;
-			/* Kernel space pointer to argument */
-			argv[i] = kmalloc(len, GFP_KERNEL);
-			if (argv[i]) {
-				CP_FM_USR(argv[i], temp, status, len);
-				if (status) {
-					kfree(argv[i]);
-					argv[i] = NULL;
-					goto func_cont;
-				}
-			} else {
-				status = -ENOMEM;
-				goto func_cont;
-			}
-		}
-	}
-	/* TODO: validate this */
-	if (args->args_proc_load.user_envp) {
-		/* number of elements in the envp array including NULL */
-		count = 0;
-		do {
-			if (get_user(temp,
-				     args->args_proc_load.user_envp + count)) {
-				status = -EFAULT;
-				goto func_cont;
-			}
-			count++;
-		} while (temp);
-		envp = kmalloc(count * sizeof(u8 *), GFP_KERNEL);
-		if (!envp) {
-			status = -ENOMEM;
-			goto func_cont;
-		}
-
-		CP_FM_USR(envp, args->args_proc_load.user_envp, status, count);
-		if (status) {
-			kfree(envp);
-			envp = NULL;
-			goto func_cont;
-		}
-		for (i = 0; envp[i]; i++) {
-			/* User space pointer to argument */
-			temp = (char *)envp[i];
-			/* len is increased by 1 to accommodate NULL */
-			len = strlen_user((char *)temp) + 1;
-			/* Kernel space pointer to argument */
-			envp[i] = kmalloc(len, GFP_KERNEL);
-			if (envp[i]) {
-				CP_FM_USR(envp[i], temp, status, len);
-				if (status) {
-					kfree(envp[i]);
-					envp[i] = NULL;
-					goto func_cont;
-				}
-			} else {
-				status = -ENOMEM;
-				goto func_cont;
-			}
-		}
-	}
-
-	if (!status) {
-		status = proc_load(hprocessor,
-				   args->args_proc_load.argc_index,
-				   (const char **)argv, (const char **)envp);
-	}
-func_cont:
-	if (envp) {
-		i = 0;
-		while (envp[i])
-			kfree(envp[i++]);
-
-		kfree(envp);
-	}
-
-	if (argv) {
-		count = args->args_proc_load.argc_index;
-		for (i = 0; (i < count) && argv[i]; i++)
-			kfree(argv[i]);
-
-		kfree(argv);
-	}
-
-	return status;
-}
-
-/*
- * ======== procwrap_map ========
- */
-u32 procwrap_map(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-	void *map_addr;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	if (!args->args_proc_mapmem.size)
-		return -EINVAL;
-
-	status = proc_map(args->args_proc_mapmem.processor,
-			  args->args_proc_mapmem.mpu_addr,
-			  args->args_proc_mapmem.size,
-			  args->args_proc_mapmem.req_addr, &map_addr,
-			  args->args_proc_mapmem.map_attr, pr_ctxt);
-	if (!status) {
-		if (put_user(map_addr, args->args_proc_mapmem.map_addr)) {
-			status = -EINVAL;
-			proc_un_map(hprocessor, map_addr, pr_ctxt);
-		}
-
-	}
-	return status;
-}
-
-/*
- * ======== procwrap_register_notify ========
- */
-u32 procwrap_register_notify(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-	struct dsp_notification notification;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	/* Initialize the notification data structure */
-	notification.name = NULL;
-	notification.handle = NULL;
-
-	status = proc_register_notify(hprocessor,
-				 args->args_proc_register_notify.event_mask,
-				 args->args_proc_register_notify.notify_type,
-				 &notification);
-	CP_TO_USR(args->args_proc_register_notify.notification, &notification,
-		  status, 1);
-	return status;
-}
-
-/*
- * ======== procwrap_reserve_memory ========
- */
-u32 procwrap_reserve_memory(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-	void *prsv_addr;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	if ((args->args_proc_rsvmem.size <= 0) ||
-	    (args->args_proc_rsvmem.size & (PG_SIZE4K - 1)) != 0)
-		return -EINVAL;
-
-	status = proc_reserve_memory(hprocessor,
-				     args->args_proc_rsvmem.size, &prsv_addr,
-				     pr_ctxt);
-	if (!status) {
-		if (put_user(prsv_addr, args->args_proc_rsvmem.rsv_addr)) {
-			status = -EINVAL;
-			proc_un_reserve_memory(args->args_proc_rsvmem.
-					       processor, prsv_addr, pr_ctxt);
-		}
-	}
-	return status;
-}
-
-/*
- * ======== procwrap_start ========
- */
-u32 procwrap_start(union trapped_args *args, void *pr_ctxt)
-{
-	u32 ret;
-
-	ret = proc_start(((struct process_context *)pr_ctxt)->processor);
-	return ret;
-}
-
-/*
- * ======== procwrap_un_map ========
- */
-u32 procwrap_un_map(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-
-	status = proc_un_map(((struct process_context *)pr_ctxt)->processor,
-			     args->args_proc_unmapmem.map_addr, pr_ctxt);
-	return status;
-}
-
-/*
- * ======== procwrap_un_reserve_memory ========
- */
-u32 procwrap_un_reserve_memory(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	status = proc_un_reserve_memory(hprocessor,
-					args->args_proc_unrsvmem.rsv_addr,
-					pr_ctxt);
-	return status;
-}
-
-/*
- * ======== procwrap_stop ========
- */
-u32 procwrap_stop(union trapped_args *args, void *pr_ctxt)
-{
-	u32 ret;
-
-	ret = proc_stop(((struct process_context *)pr_ctxt)->processor);
-
-	return ret;
-}
-
-/*
- * ======== find_handle =========
- */
-inline void find_node_handle(struct node_res_object **noderes,
-				void *pr_ctxt, void *hnode)
-{
-	rcu_read_lock();
-	*noderes = idr_find(((struct process_context *)pr_ctxt)->node_id,
-								(int)hnode - 1);
-	rcu_read_unlock();
-	return;
-}
-
-
-/*
- * ======== nodewrap_allocate ========
- */
-u32 nodewrap_allocate(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct dsp_uuid node_uuid;
-	u32 cb_data_size = 0;
-	u32 __user *psize = (u32 __user *) args->args_node_allocate.args;
-	u8 *pargs = NULL;
-	struct dsp_nodeattrin proc_attr_in, *attr_in = NULL;
-	struct node_res_object *node_res;
-	int nodeid;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	/* Optional argument */
-	if (psize) {
-		if (get_user(cb_data_size, psize))
-			status = -EPERM;
-
-		cb_data_size += sizeof(u32);
-		if (!status) {
-			pargs = kmalloc(cb_data_size, GFP_KERNEL);
-			if (pargs == NULL)
-				status = -ENOMEM;
-
-		}
-		CP_FM_USR(pargs, args->args_node_allocate.args, status,
-			  cb_data_size);
-	}
-	CP_FM_USR(&node_uuid, args->args_node_allocate.node_id_ptr, status, 1);
-	if (status)
-		goto func_cont;
-	/* Optional argument */
-	if (args->args_node_allocate.attr_in) {
-		CP_FM_USR(&proc_attr_in, args->args_node_allocate.attr_in,
-			  status, 1);
-		if (!status)
-			attr_in = &proc_attr_in;
-		else
-			status = -ENOMEM;
-
-	}
-	if (!status) {
-		status = node_allocate(hprocessor,
-				       &node_uuid, (struct dsp_cbdata *)pargs,
-				       attr_in, &node_res, pr_ctxt);
-	}
-	if (!status) {
-		nodeid = node_res->id + 1;
-		CP_TO_USR(args->args_node_allocate.node, &nodeid,
-			status, 1);
-		if (status) {
-			status = -EFAULT;
-			node_delete(node_res, pr_ctxt);
-		}
-	}
-func_cont:
-	kfree(pargs);
-
-	return status;
-}
-
-/*
- *  ======== nodewrap_alloc_msg_buf ========
- */
-u32 nodewrap_alloc_msg_buf(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct dsp_bufferattr *pattr = NULL;
-	struct dsp_bufferattr attr;
-	u8 *pbuffer = NULL;
-	struct node_res_object *node_res;
-
-	find_node_handle(&node_res,  pr_ctxt,
-				args->args_node_allocmsgbuf.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	if (!args->args_node_allocmsgbuf.size)
-		return -EINVAL;
-
-	if (args->args_node_allocmsgbuf.attr) {	/* Optional argument */
-		CP_FM_USR(&attr, args->args_node_allocmsgbuf.attr, status, 1);
-		if (!status)
-			pattr = &attr;
-
-	}
-	/* argument */
-	CP_FM_USR(&pbuffer, args->args_node_allocmsgbuf.buffer, status, 1);
-	if (!status) {
-		status = node_alloc_msg_buf(node_res->node,
-					    args->args_node_allocmsgbuf.size,
-					    pattr, &pbuffer);
-	}
-	CP_TO_USR(args->args_node_allocmsgbuf.buffer, &pbuffer, status, 1);
-	return status;
-}
-
-/*
- * ======== nodewrap_change_priority ========
- */
-u32 nodewrap_change_priority(union trapped_args *args, void *pr_ctxt)
-{
-	u32 ret;
-	struct node_res_object *node_res;
-
-	find_node_handle(&node_res, pr_ctxt,
-				args->args_node_changepriority.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	ret = node_change_priority(node_res->node,
-				   args->args_node_changepriority.prio);
-
-	return ret;
-}
-
-/*
- * ======== nodewrap_connect ========
- */
-u32 nodewrap_connect(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct dsp_strmattr attrs;
-	struct dsp_strmattr *pattrs = NULL;
-	u32 cb_data_size;
-	u32 __user *psize = (u32 __user *) args->args_node_connect.conn_param;
-	u8 *pargs = NULL;
-	struct node_res_object *node_res1, *node_res2;
-	struct node_object *node1 = NULL, *node2 = NULL;
-
-	if ((int)args->args_node_connect.node != DSP_HGPPNODE) {
-		find_node_handle(&node_res1, pr_ctxt,
-				args->args_node_connect.node);
-		if (node_res1)
-			node1 = node_res1->node;
-	} else {
-		node1 = args->args_node_connect.node;
-	}
-
-	if ((int)args->args_node_connect.other_node != DSP_HGPPNODE) {
-		find_node_handle(&node_res2, pr_ctxt,
-				args->args_node_connect.other_node);
-		if (node_res2)
-			node2 = node_res2->node;
-	} else {
-		node2 = args->args_node_connect.other_node;
-	}
-
-	if (!node1 || !node2)
-		return -EFAULT;
-
-	/* Optional argument */
-	if (psize) {
-		if (get_user(cb_data_size, psize))
-			status = -EPERM;
-
-		cb_data_size += sizeof(u32);
-		if (!status) {
-			pargs = kmalloc(cb_data_size, GFP_KERNEL);
-			if (pargs == NULL) {
-				status = -ENOMEM;
-				goto func_cont;
-			}
-
-		}
-		CP_FM_USR(pargs, args->args_node_connect.conn_param, status,
-			  cb_data_size);
-		if (status)
-			goto func_cont;
-	}
-	if (args->args_node_connect.attrs) {	/* Optional argument */
-		CP_FM_USR(&attrs, args->args_node_connect.attrs, status, 1);
-		if (!status)
-			pattrs = &attrs;
-
-	}
-	if (!status) {
-		status = node_connect(node1,
-				      args->args_node_connect.stream_id,
-				      node2,
-				      args->args_node_connect.other_stream,
-				      pattrs, (struct dsp_cbdata *)pargs);
-	}
-func_cont:
-	kfree(pargs);
-
-	return status;
-}
-
-/*
- * ======== nodewrap_create ========
- */
-u32 nodewrap_create(union trapped_args *args, void *pr_ctxt)
-{
-	u32 ret;
-	struct node_res_object *node_res;
-
-	find_node_handle(&node_res, pr_ctxt, args->args_node_create.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	ret = node_create(node_res->node);
-
-	return ret;
-}
-
-/*
- * ======== nodewrap_delete ========
- */
-u32 nodewrap_delete(union trapped_args *args, void *pr_ctxt)
-{
-	u32 ret;
-	struct node_res_object *node_res;
-
-	find_node_handle(&node_res, pr_ctxt, args->args_node_delete.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	ret = node_delete(node_res, pr_ctxt);
-
-	return ret;
-}
-
-/*
- *  ======== nodewrap_free_msg_buf ========
- */
-u32 nodewrap_free_msg_buf(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct dsp_bufferattr *pattr = NULL;
-	struct dsp_bufferattr attr;
-	struct node_res_object *node_res;
-
-	find_node_handle(&node_res, pr_ctxt, args->args_node_freemsgbuf.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	if (args->args_node_freemsgbuf.attr) {	/* Optional argument */
-		CP_FM_USR(&attr, args->args_node_freemsgbuf.attr, status, 1);
-		if (!status)
-			pattr = &attr;
-
-	}
-
-	if (!args->args_node_freemsgbuf.buffer)
-		return -EFAULT;
-
-	if (!status) {
-		status = node_free_msg_buf(node_res->node,
-					   args->args_node_freemsgbuf.buffer,
-					   pattr);
-	}
-
-	return status;
-}
-
-/*
- * ======== nodewrap_get_attr ========
- */
-u32 nodewrap_get_attr(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct dsp_nodeattr attr;
-	struct node_res_object *node_res;
-
-	find_node_handle(&node_res, pr_ctxt, args->args_node_getattr.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	status = node_get_attr(node_res->node, &attr,
-			       args->args_node_getattr.attr_size);
-	CP_TO_USR(args->args_node_getattr.attr, &attr, status, 1);
-
-	return status;
-}
-
-/*
- * ======== nodewrap_get_message ========
- */
-u32 nodewrap_get_message(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-	struct dsp_msg msg;
-	struct node_res_object *node_res;
-
-	find_node_handle(&node_res, pr_ctxt, args->args_node_getmessage.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	status = node_get_message(node_res->node, &msg,
-				  args->args_node_getmessage.timeout);
-
-	CP_TO_USR(args->args_node_getmessage.message, &msg, status, 1);
-
-	return status;
-}
-
-/*
- * ======== nodewrap_pause ========
- */
-u32 nodewrap_pause(union trapped_args *args, void *pr_ctxt)
-{
-	u32 ret;
-	struct node_res_object *node_res;
-
-	find_node_handle(&node_res, pr_ctxt, args->args_node_pause.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	ret = node_pause(node_res->node);
-
-	return ret;
-}
-
-/*
- * ======== nodewrap_put_message ========
- */
-u32 nodewrap_put_message(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct dsp_msg msg;
-	struct node_res_object *node_res;
-
-	find_node_handle(&node_res, pr_ctxt, args->args_node_putmessage.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	CP_FM_USR(&msg, args->args_node_putmessage.message, status, 1);
-
-	if (!status) {
-		status =
-		    node_put_message(node_res->node, &msg,
-				     args->args_node_putmessage.timeout);
-	}
-
-	return status;
-}
-
-/*
- * ======== nodewrap_register_notify ========
- */
-u32 nodewrap_register_notify(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct dsp_notification notification;
-	struct node_res_object *node_res;
-
-	find_node_handle(&node_res, pr_ctxt,
-			args->args_node_registernotify.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	/* Initialize the notification data structure */
-	notification.name = NULL;
-	notification.handle = NULL;
-
-	if (!args->args_proc_register_notify.event_mask)
-		CP_FM_USR(&notification,
-			  args->args_proc_register_notify.notification,
-			  status, 1);
-
-	status = node_register_notify(node_res->node,
-				      args->args_node_registernotify.event_mask,
-				      args->args_node_registernotify.
-				      notify_type, &notification);
-	CP_TO_USR(args->args_node_registernotify.notification, &notification,
-		  status, 1);
-	return status;
-}
-
-/*
- * ======== nodewrap_run ========
- */
-u32 nodewrap_run(union trapped_args *args, void *pr_ctxt)
-{
-	u32 ret;
-	struct node_res_object *node_res;
-
-	find_node_handle(&node_res, pr_ctxt, args->args_node_run.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	ret = node_run(node_res->node);
-
-	return ret;
-}
-
-/*
- * ======== nodewrap_terminate ========
- */
-u32 nodewrap_terminate(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-	int tempstatus;
-	struct node_res_object *node_res;
-
-	find_node_handle(&node_res, pr_ctxt, args->args_node_terminate.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	status = node_terminate(node_res->node, &tempstatus);
-
-	CP_TO_USR(args->args_node_terminate.status, &tempstatus, status, 1);
-
-	return status;
-}
-
-/*
- * ======== nodewrap_get_uuid_props ========
- */
-u32 nodewrap_get_uuid_props(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct dsp_uuid node_uuid;
-	struct dsp_ndbprops *pnode_props = NULL;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	CP_FM_USR(&node_uuid, args->args_node_getuuidprops.node_id_ptr, status,
-		  1);
-	if (status)
-		goto func_cont;
-	pnode_props = kmalloc(sizeof(struct dsp_ndbprops), GFP_KERNEL);
-	if (pnode_props != NULL) {
-		status =
-		    node_get_uuid_props(hprocessor, &node_uuid, pnode_props);
-		CP_TO_USR(args->args_node_getuuidprops.node_props, pnode_props,
-			  status, 1);
-	} else
-		status = -ENOMEM;
-func_cont:
-	kfree(pnode_props);
-	return status;
-}
-
-/*
- * ======== find_strm_handle =========
- */
-inline void find_strm_handle(struct strm_res_object **strmres,
-				void *pr_ctxt, void *hstream)
-{
-	rcu_read_lock();
-	*strmres = idr_find(((struct process_context *)pr_ctxt)->stream_id,
-							(int)hstream - 1);
-	rcu_read_unlock();
-	return;
-}
-
-/*
- * ======== strmwrap_allocate_buffer ========
- */
-u32 strmwrap_allocate_buffer(union trapped_args *args, void *pr_ctxt)
-{
-	int status;
-	u8 **ap_buffer = NULL;
-	u32 num_bufs = args->args_strm_allocatebuffer.num_bufs;
-	struct strm_res_object *strm_res;
-
-	find_strm_handle(&strm_res, pr_ctxt,
-		args->args_strm_allocatebuffer.stream);
-
-	if (!strm_res)
-		return -EFAULT;
-
-	if (num_bufs > MAX_BUFS)
-		return -EINVAL;
-
-	ap_buffer = kmalloc((num_bufs * sizeof(u8 *)), GFP_KERNEL);
-	if (ap_buffer == NULL)
-		return -ENOMEM;
-
-	status = strm_allocate_buffer(strm_res,
-				      args->args_strm_allocatebuffer.size,
-				      ap_buffer, num_bufs, pr_ctxt);
-	if (!status) {
-		CP_TO_USR(args->args_strm_allocatebuffer.ap_buffer, ap_buffer,
-			  status, num_bufs);
-		if (status) {
-			status = -EFAULT;
-			strm_free_buffer(strm_res,
-					 ap_buffer, num_bufs, pr_ctxt);
-		}
-	}
-	kfree(ap_buffer);
-
-	return status;
-}
-
-/*
- * ======== strmwrap_close ========
- */
-u32 strmwrap_close(union trapped_args *args, void *pr_ctxt)
-{
-	struct strm_res_object *strm_res;
-
-	find_strm_handle(&strm_res, pr_ctxt, args->args_strm_close.stream);
-
-	if (!strm_res)
-		return -EFAULT;
-
-	return strm_close(strm_res, pr_ctxt);
-}
-
-/*
- * ======== strmwrap_free_buffer ========
- */
-u32 strmwrap_free_buffer(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	u8 **ap_buffer = NULL;
-	u32 num_bufs = args->args_strm_freebuffer.num_bufs;
-	struct strm_res_object *strm_res;
-
-	find_strm_handle(&strm_res, pr_ctxt,
-			args->args_strm_freebuffer.stream);
-
-	if (!strm_res)
-		return -EFAULT;
-
-	if (num_bufs > MAX_BUFS)
-		return -EINVAL;
-
-	ap_buffer = kmalloc_array(num_bufs, sizeof(u8 *), GFP_KERNEL);
-	if (ap_buffer == NULL)
-		return -ENOMEM;
-
-	CP_FM_USR(ap_buffer, args->args_strm_freebuffer.ap_buffer, status,
-		  num_bufs);
-
-	if (!status)
-		status = strm_free_buffer(strm_res,
-					  ap_buffer, num_bufs, pr_ctxt);
-
-	CP_TO_USR(args->args_strm_freebuffer.ap_buffer, ap_buffer, status,
-		  num_bufs);
-	kfree(ap_buffer);
-
-	return status;
-}
-
-/*
- * ======== strmwrap_get_event_handle ========
- */
-u32 __deprecated strmwrap_get_event_handle(union trapped_args *args,
-					   void *pr_ctxt)
-{
-	pr_err("%s: deprecated dspbridge ioctl\n", __func__);
-	return -ENOSYS;
-}
-
-/*
- * ======== strmwrap_get_info ========
- */
-u32 strmwrap_get_info(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct stream_info strm_info;
-	struct dsp_streaminfo user;
-	struct dsp_streaminfo *temp;
-	struct strm_res_object *strm_res;
-
-	find_strm_handle(&strm_res, pr_ctxt,
-			args->args_strm_getinfo.stream);
-
-	if (!strm_res)
-		return -EFAULT;
-
-	CP_FM_USR(&strm_info, args->args_strm_getinfo.stream_info, status, 1);
-	temp = strm_info.user_strm;
-
-	strm_info.user_strm = &user;
-
-	if (!status) {
-		status = strm_get_info(strm_res->stream,
-				       &strm_info,
-				       args->args_strm_getinfo.
-				       stream_info_size);
-	}
-	CP_TO_USR(temp, strm_info.user_strm, status, 1);
-	strm_info.user_strm = temp;
-	CP_TO_USR(args->args_strm_getinfo.stream_info, &strm_info, status, 1);
-	return status;
-}
-
-/*
- * ======== strmwrap_idle ========
- */
-u32 strmwrap_idle(union trapped_args *args, void *pr_ctxt)
-{
-	u32 ret;
-	struct strm_res_object *strm_res;
-
-	find_strm_handle(&strm_res, pr_ctxt, args->args_strm_idle.stream);
-
-	if (!strm_res)
-		return -EFAULT;
-
-	ret = strm_idle(strm_res->stream, args->args_strm_idle.flush_flag);
-
-	return ret;
-}
-
-/*
- * ======== strmwrap_issue ========
- */
-u32 strmwrap_issue(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct strm_res_object *strm_res;
-
-	find_strm_handle(&strm_res, pr_ctxt, args->args_strm_issue.stream);
-
-	if (!strm_res)
-		return -EFAULT;
-
-	if (!args->args_strm_issue.buffer)
-		return -EFAULT;
-
-	/* No need of doing CP_FM_USR for the user buffer (pbuffer)
-	   as this is done in Bridge internal function bridge_chnl_add_io_req
-	   in chnl_sm.c */
-	status = strm_issue(strm_res->stream,
-			    args->args_strm_issue.buffer,
-			    args->args_strm_issue.bytes,
-			    args->args_strm_issue.buf_size,
-			    args->args_strm_issue.arg);
-
-	return status;
-}
-
-/*
- * ======== strmwrap_open ========
- */
-u32 strmwrap_open(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct strm_attr attr;
-	struct strm_res_object *strm_res_obj;
-	struct dsp_streamattrin strm_attr_in;
-	struct node_res_object *node_res;
-	int strmid;
-
-	find_node_handle(&node_res, pr_ctxt, args->args_strm_open.node);
-
-	if (!node_res)
-		return -EFAULT;
-
-	CP_FM_USR(&attr, args->args_strm_open.attr_in, status, 1);
-
-	if (attr.stream_attr_in != NULL) {	/* Optional argument */
-		CP_FM_USR(&strm_attr_in, attr.stream_attr_in, status, 1);
-		if (!status) {
-			attr.stream_attr_in = &strm_attr_in;
-			if (attr.stream_attr_in->strm_mode == STRMMODE_LDMA)
-				return -ENOSYS;
-		}
-
-	}
-	status = strm_open(node_res->node,
-			   args->args_strm_open.direction,
-			   args->args_strm_open.index, &attr, &strm_res_obj,
-			   pr_ctxt);
-	if (!status) {
-		strmid = strm_res_obj->id + 1;
-		CP_TO_USR(args->args_strm_open.stream, &strmid, status, 1);
-	}
-	return status;
-}
-
-/*
- * ======== strmwrap_reclaim ========
- */
-u32 strmwrap_reclaim(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	u8 *buf_ptr;
-	u32 ul_bytes;
-	u32 dw_arg;
-	u32 ul_buf_size;
-	struct strm_res_object *strm_res;
-
-	find_strm_handle(&strm_res, pr_ctxt, args->args_strm_reclaim.stream);
-
-	if (!strm_res)
-		return -EFAULT;
-
-	status = strm_reclaim(strm_res->stream, &buf_ptr,
-			      &ul_bytes, &ul_buf_size, &dw_arg);
-	CP_TO_USR(args->args_strm_reclaim.buf_ptr, &buf_ptr, status, 1);
-	CP_TO_USR(args->args_strm_reclaim.bytes, &ul_bytes, status, 1);
-	CP_TO_USR(args->args_strm_reclaim.arg, &dw_arg, status, 1);
-
-	if (args->args_strm_reclaim.buf_size_ptr != NULL) {
-		CP_TO_USR(args->args_strm_reclaim.buf_size_ptr, &ul_buf_size,
-			  status, 1);
-	}
-
-	return status;
-}
-
-/*
- * ======== strmwrap_register_notify ========
- */
-u32 strmwrap_register_notify(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct dsp_notification notification;
-	struct strm_res_object *strm_res;
-
-	find_strm_handle(&strm_res, pr_ctxt,
-			args->args_strm_registernotify.stream);
-
-	if (!strm_res)
-		return -EFAULT;
-
-	/* Initialize the notification data structure */
-	notification.name = NULL;
-	notification.handle = NULL;
-
-	status = strm_register_notify(strm_res->stream,
-				      args->args_strm_registernotify.event_mask,
-				      args->args_strm_registernotify.
-				      notify_type, &notification);
-	CP_TO_USR(args->args_strm_registernotify.notification, &notification,
-		  status, 1);
-
-	return status;
-}
-
-/*
- * ======== strmwrap_select ========
- */
-u32 strmwrap_select(union trapped_args *args, void *pr_ctxt)
-{
-	u32 mask = 0;
-	struct strm_object *strm_tab[MAX_STREAMS];
-	int status = 0;
-	struct strm_res_object *strm_res;
-	int *ids[MAX_STREAMS];
-	int i;
-
-	if (args->args_strm_select.strm_num > MAX_STREAMS)
-		return -EINVAL;
-
-	CP_FM_USR(ids, args->args_strm_select.stream_tab, status,
-		args->args_strm_select.strm_num);
-
-	if (status)
-		return status;
-
-	for (i = 0; i < args->args_strm_select.strm_num; i++) {
-		find_strm_handle(&strm_res, pr_ctxt, ids[i]);
-
-		if (!strm_res)
-			return -EFAULT;
-
-		strm_tab[i] = strm_res->stream;
-	}
-
-	if (!status) {
-		status = strm_select(strm_tab, args->args_strm_select.strm_num,
-				     &mask, args->args_strm_select.timeout);
-	}
-	CP_TO_USR(args->args_strm_select.mask, &mask, status, 1);
-	return status;
-}
-
-/* CMM */
-
-/*
- * ======== cmmwrap_calloc_buf ========
- */
-u32 __deprecated cmmwrap_calloc_buf(union trapped_args *args, void *pr_ctxt)
-{
-	/* This operation is done in kernel */
-	pr_err("%s: deprecated dspbridge ioctl\n", __func__);
-	return -ENOSYS;
-}
-
-/*
- * ======== cmmwrap_free_buf ========
- */
-u32 __deprecated cmmwrap_free_buf(union trapped_args *args, void *pr_ctxt)
-{
-	/* This operation is done in kernel */
-	pr_err("%s: deprecated dspbridge ioctl\n", __func__);
-	return -ENOSYS;
-}
-
-/*
- * ======== cmmwrap_get_handle ========
- */
-u32 cmmwrap_get_handle(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct cmm_object *hcmm_mgr;
-	void *hprocessor = ((struct process_context *)pr_ctxt)->processor;
-
-	status = cmm_get_handle(hprocessor, &hcmm_mgr);
-
-	CP_TO_USR(args->args_cmm_gethandle.cmm_mgr, &hcmm_mgr, status, 1);
-
-	return status;
-}
-
-/*
- * ======== cmmwrap_get_info ========
- */
-u32 cmmwrap_get_info(union trapped_args *args, void *pr_ctxt)
-{
-	int status = 0;
-	struct cmm_info cmm_info_obj;
-
-	status = cmm_get_info(args->args_cmm_getinfo.cmm_mgr, &cmm_info_obj);
-
-	CP_TO_USR(args->args_cmm_getinfo.cmm_info_obj, &cmm_info_obj, status,
-		  1);
-
-	return status;
-}
diff --git a/drivers/staging/tidspbridge/pmgr/io.c b/drivers/staging/tidspbridge/pmgr/io.c
deleted file mode 100644
index 4073c9c..0000000
--- a/drivers/staging/tidspbridge/pmgr/io.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * io.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * IO manager interface: Manages IO between CHNL and msg_ctrl.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#include <linux/types.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/dev.h>
-
-/*  ----------------------------------- This */
-#include <ioobj.h>
-#include <dspbridge/io.h>
-
-/*
- *  ======== io_create ========
- *  Purpose:
- *      Create an IO manager object, responsible for managing IO between
- *      CHNL and msg_ctrl
- */
-int io_create(struct io_mgr **io_man, struct dev_object *hdev_obj,
-		     const struct io_attrs *mgr_attrts)
-{
-	struct bridge_drv_interface *intf_fxns;
-	struct io_mgr *hio_mgr = NULL;
-	struct io_mgr_ *pio_mgr = NULL;
-	int status = 0;
-
-	*io_man = NULL;
-
-	/* A memory base of 0 implies no memory base: */
-	if ((mgr_attrts->shm_base != 0) && (mgr_attrts->sm_length == 0))
-		status = -EINVAL;
-
-	if (mgr_attrts->word_size == 0)
-		status = -EINVAL;
-
-	if (!status) {
-		dev_get_intf_fxns(hdev_obj, &intf_fxns);
-
-		/* Let Bridge channel module finish the create: */
-		status = (*intf_fxns->io_create) (&hio_mgr, hdev_obj,
-						      mgr_attrts);
-
-		if (!status) {
-			pio_mgr = (struct io_mgr_ *)hio_mgr;
-			pio_mgr->intf_fxns = intf_fxns;
-			pio_mgr->dev_obj = hdev_obj;
-
-			/* Return the new channel manager handle: */
-			*io_man = hio_mgr;
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== io_destroy ========
- *  Purpose:
- *      Delete IO manager.
- */
-int io_destroy(struct io_mgr *hio_mgr)
-{
-	struct bridge_drv_interface *intf_fxns;
-	struct io_mgr_ *pio_mgr = (struct io_mgr_ *)hio_mgr;
-	int status;
-
-	intf_fxns = pio_mgr->intf_fxns;
-
-	/* Let Bridge channel module destroy the io_mgr: */
-	status = (*intf_fxns->io_destroy) (hio_mgr);
-
-	return status;
-}
diff --git a/drivers/staging/tidspbridge/pmgr/ioobj.h b/drivers/staging/tidspbridge/pmgr/ioobj.h
deleted file mode 100644
index 7defd94..0000000
--- a/drivers/staging/tidspbridge/pmgr/ioobj.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * ioobj.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Structure subcomponents of channel class library IO objects which
- * are exposed to DSP API from Bridge driver.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef IOOBJ_
-#define IOOBJ_
-
-#include <dspbridge/devdefs.h>
-#include <dspbridge/dspdefs.h>
-
-/*
- *  This struct is the first field in a io_mgr struct. Other, implementation
- *  specific fields follow this structure in memory.
- */
-struct io_mgr_ {
-	/* These must be the first fields in a io_mgr struct: */
-	struct bridge_dev_context *bridge_context;	/* Bridge context. */
-	/* Function interface to Bridge driver. */
-	struct bridge_drv_interface *intf_fxns;
-	struct dev_object *dev_obj;	/* Device this board represents. */
-};
-
-#endif /* IOOBJ_ */
diff --git a/drivers/staging/tidspbridge/pmgr/msg.c b/drivers/staging/tidspbridge/pmgr/msg.c
deleted file mode 100644
index f093cfb..0000000
--- a/drivers/staging/tidspbridge/pmgr/msg.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * msg.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP/BIOS Bridge msg_ctrl Module.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#include <linux/types.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- Bridge Driver */
-#include <dspbridge/dspdefs.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/dev.h>
-
-/*  ----------------------------------- This */
-#include <msgobj.h>
-#include <dspbridge/msg.h>
-
-/*
- *  ======== msg_create ========
- *  Purpose:
- *      Create an object to manage message queues. Only one of these objects
- *      can exist per device object.
- */
-int msg_create(struct msg_mgr **msg_man,
-		      struct dev_object *hdev_obj, msg_onexit msg_callback)
-{
-	struct bridge_drv_interface *intf_fxns;
-	struct msg_mgr_ *msg_mgr_obj;
-	struct msg_mgr *hmsg_mgr;
-	int status = 0;
-
-	*msg_man = NULL;
-
-	dev_get_intf_fxns(hdev_obj, &intf_fxns);
-
-	/* Let Bridge message module finish the create: */
-	status =
-	    (*intf_fxns->msg_create) (&hmsg_mgr, hdev_obj, msg_callback);
-
-	if (!status) {
-		/* Fill in DSP API message module's fields of the msg_mgr
-		 * structure */
-		msg_mgr_obj = (struct msg_mgr_ *)hmsg_mgr;
-		msg_mgr_obj->intf_fxns = intf_fxns;
-
-		/* Finally, return the new message manager handle: */
-		*msg_man = hmsg_mgr;
-	} else {
-		status = -EPERM;
-	}
-	return status;
-}
-
-/*
- *  ======== msg_delete ========
- *  Purpose:
- *      Delete a msg_ctrl manager allocated in msg_create().
- */
-void msg_delete(struct msg_mgr *hmsg_mgr)
-{
-	struct msg_mgr_ *msg_mgr_obj = (struct msg_mgr_ *)hmsg_mgr;
-	struct bridge_drv_interface *intf_fxns;
-
-	if (msg_mgr_obj) {
-		intf_fxns = msg_mgr_obj->intf_fxns;
-
-		/* Let Bridge message module destroy the msg_mgr: */
-		(*intf_fxns->msg_delete) (hmsg_mgr);
-	} else {
-		dev_dbg(bridge, "%s: Error hmsg_mgr handle: %p\n",
-			__func__, hmsg_mgr);
-	}
-}
diff --git a/drivers/staging/tidspbridge/pmgr/msgobj.h b/drivers/staging/tidspbridge/pmgr/msgobj.h
deleted file mode 100644
index 14ca633..0000000
--- a/drivers/staging/tidspbridge/pmgr/msgobj.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * msgobj.h
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Structure subcomponents of channel class library msg_ctrl objects which
- * are exposed to DSP API from Bridge driver.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#ifndef MSGOBJ_
-#define MSGOBJ_
-
-#include <dspbridge/dspdefs.h>
-
-#include <dspbridge/msgdefs.h>
-
-/*
- *  This struct is the first field in a msg_mgr struct. Other, implementation
- *  specific fields follow this structure in memory.
- */
-struct msg_mgr_ {
-	/* The first field must match that in _msg_sm.h */
-
-	/* Function interface to Bridge driver. */
-	struct bridge_drv_interface *intf_fxns;
-};
-
-#endif /* MSGOBJ_ */
diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c
deleted file mode 100644
index c91d1d7..0000000
--- a/drivers/staging/tidspbridge/rmgr/dbdcd.c
+++ /dev/null
@@ -1,1484 +0,0 @@
-/*
- * dbdcd.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * This file contains the implementation of the DSP/BIOS Bridge
- * Configuration Database (DCD).
- *
- * Notes:
- *   The fxn dcd_get_objects can apply a callback fxn to each DCD object
- *   that is located in a specified COFF file.  At the moment,
- *   dcd_auto_register, dcd_auto_unregister, and NLDR module all use
- *   dcd_get_objects.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#include <linux/types.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/cod.h>
-
-/*  ----------------------------------- Others */
-#include <dspbridge/uuidutil.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/dbdcd.h>
-
-/*  ----------------------------------- Global defines. */
-#define MAX_INT2CHAR_LENGTH     16	/* Max int2char len of 32 bit int */
-
-/* Name of section containing dependent libraries */
-#define DEPLIBSECT		".dspbridge_deplibs"
-
-/* DCD specific structures. */
-struct dcd_manager {
-	struct cod_manager *cod_mgr;	/* Handle to COD manager object. */
-};
-
-/*  Pointer to the registry support key */
-static struct list_head reg_key_list;
-static DEFINE_SPINLOCK(dbdcd_lock);
-
-/* Global reference variables. */
-static u32 refs;
-static u32 enum_refs;
-
-/* Helper function prototypes. */
-static s32 atoi(char *psz_buf);
-static int get_attrs_from_buf(char *psz_buf, u32 ul_buf_size,
-				     enum dsp_dcdobjtype obj_type,
-				     struct dcd_genericobj *gen_obj);
-static void compress_buf(char *psz_buf, u32 ul_buf_size, s32 char_size);
-static char dsp_char2_gpp_char(char *word, s32 dsp_char_size);
-static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
-				   struct dsp_uuid *uuid_obj,
-				   u16 *num_libs,
-				   u16 *num_pers_libs,
-				   struct dsp_uuid *dep_lib_uuids,
-				   bool *prstnt_dep_libs,
-				   enum nldr_phase phase);
-
-/*
- *  ======== dcd_uuid_from_string ========
- *  Purpose:
- *      Converts an ANSI string to a dsp_uuid.
- *  Parameters:
- *      sz_uuid:    Pointer to a string that represents a dsp_uuid object.
- *      uuid_obj:      Pointer to a dsp_uuid object.
- *  Returns:
- *      0:        Success.
- *      -EINVAL:  Coversion failed
- *  Requires:
- *      uuid_obj & sz_uuid are non-NULL values.
- *  Ensures:
- *  Details:
- *      We assume the string representation of a UUID has the following format:
- *      "12345678_1234_1234_1234_123456789abc".
- */
-static int dcd_uuid_from_string(char *sz_uuid, struct dsp_uuid *uuid_obj)
-{
-	char c;
-	u64 t;
-	struct dsp_uuid uuid_tmp;
-
-	/*
-	 * sscanf implementation cannot deal with hh format modifier
-	 * if the converted value doesn't fit in u32. So, convert the
-	 * last six bytes to u64 and memcpy what is needed
-	 */
-	if (sscanf(sz_uuid, "%8x%c%4hx%c%4hx%c%2hhx%2hhx%c%llx",
-	       &uuid_tmp.data1, &c, &uuid_tmp.data2, &c,
-	       &uuid_tmp.data3, &c, &uuid_tmp.data4,
-	       &uuid_tmp.data5, &c, &t) != 10)
-		return -EINVAL;
-
-	t = cpu_to_be64(t);
-	memcpy(&uuid_tmp.data6[0], ((char *)&t) + 2, 6);
-	*uuid_obj = uuid_tmp;
-
-	return 0;
-}
-
-/*
- *  ======== dcd_auto_register ========
- *  Purpose:
- *      Parses the supplied image and resigsters with DCD.
- */
-int dcd_auto_register(struct dcd_manager *hdcd_mgr,
-			     char *sz_coff_path)
-{
-	int status = 0;
-
-	if (hdcd_mgr)
-		status = dcd_get_objects(hdcd_mgr, sz_coff_path,
-					 (dcd_registerfxn) dcd_register_object,
-					 (void *)sz_coff_path);
-	else
-		status = -EFAULT;
-
-	return status;
-}
-
-/*
- *  ======== dcd_auto_unregister ========
- *  Purpose:
- *      Parses the supplied DSP image and unresiters from DCD.
- */
-int dcd_auto_unregister(struct dcd_manager *hdcd_mgr,
-			       char *sz_coff_path)
-{
-	int status = 0;
-
-	if (hdcd_mgr)
-		status = dcd_get_objects(hdcd_mgr, sz_coff_path,
-					 (dcd_registerfxn) dcd_register_object,
-					 NULL);
-	else
-		status = -EFAULT;
-
-	return status;
-}
-
-/*
- *  ======== dcd_create_manager ========
- *  Purpose:
- *      Creates DCD manager.
- */
-int dcd_create_manager(char *sz_zl_dll_name,
-			      struct dcd_manager **dcd_mgr)
-{
-	struct cod_manager *cod_mgr;	/* COD manager handle */
-	struct dcd_manager *dcd_mgr_obj = NULL;	/* DCD Manager pointer */
-	int status = 0;
-
-	status = cod_create(&cod_mgr, sz_zl_dll_name);
-	if (status)
-		goto func_end;
-
-	/* Create a DCD object. */
-	dcd_mgr_obj = kzalloc(sizeof(struct dcd_manager), GFP_KERNEL);
-	if (dcd_mgr_obj != NULL) {
-		/* Fill out the object. */
-		dcd_mgr_obj->cod_mgr = cod_mgr;
-
-		/* Return handle to this DCD interface. */
-		*dcd_mgr = dcd_mgr_obj;
-	} else {
-		status = -ENOMEM;
-
-		/*
-		 * If allocation of DcdManager object failed, delete the
-		 * COD manager.
-		 */
-		cod_delete(cod_mgr);
-	}
-
-func_end:
-	return status;
-}
-
-/*
- *  ======== dcd_destroy_manager ========
- *  Purpose:
- *      Frees DCD Manager object.
- */
-int dcd_destroy_manager(struct dcd_manager *hdcd_mgr)
-{
-	struct dcd_manager *dcd_mgr_obj = hdcd_mgr;
-	int status = -EFAULT;
-
-	if (hdcd_mgr) {
-		/* Delete the COD manager. */
-		cod_delete(dcd_mgr_obj->cod_mgr);
-
-		/* Deallocate a DCD manager object. */
-		kfree(dcd_mgr_obj);
-
-		status = 0;
-	}
-
-	return status;
-}
-
-/*
- *  ======== dcd_enumerate_object ========
- *  Purpose:
- *      Enumerates objects in the DCD.
- */
-int dcd_enumerate_object(s32 index, enum dsp_dcdobjtype obj_type,
-				struct dsp_uuid *uuid_obj)
-{
-	int status = 0;
-	char sz_reg_key[DCD_MAXPATHLENGTH];
-	char sz_value[DCD_MAXPATHLENGTH];
-	struct dsp_uuid dsp_uuid_obj;
-	char sz_obj_type[MAX_INT2CHAR_LENGTH];	/* str. rep. of obj_type. */
-	u32 dw_key_len = 0;
-	struct dcd_key_elem *dcd_key;
-	int len;
-
-	if ((index != 0) && (enum_refs == 0)) {
-		/*
-		 * If an enumeration is being performed on an index greater
-		 * than zero, then the current enum_refs must have been
-		 * incremented to greater than zero.
-		 */
-		status = -EIDRM;
-	} else {
-		/*
-		 * Pre-determine final key length. It's length of DCD_REGKEY +
-		 *  "_\0" + length of sz_obj_type string + terminating NULL.
-		 */
-		dw_key_len = strlen(DCD_REGKEY) + 1 + sizeof(sz_obj_type) + 1;
-
-		/* Create proper REG key; concatenate DCD_REGKEY with
-		 * obj_type. */
-		strncpy(sz_reg_key, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
-		if ((strlen(sz_reg_key) + strlen("_\0")) <
-		    DCD_MAXPATHLENGTH) {
-			strncat(sz_reg_key, "_\0", 2);
-		} else {
-			status = -EPERM;
-		}
-
-		/* This snprintf is guaranteed not to exceed max size of an
-		 * integer. */
-		status = snprintf(sz_obj_type, MAX_INT2CHAR_LENGTH, "%d",
-				  obj_type);
-
-		if (status == -1) {
-			status = -EPERM;
-		} else {
-			status = 0;
-			if ((strlen(sz_reg_key) + strlen(sz_obj_type)) <
-			    DCD_MAXPATHLENGTH) {
-				strncat(sz_reg_key, sz_obj_type,
-					strlen(sz_obj_type) + 1);
-			} else {
-				status = -EPERM;
-			}
-		}
-
-		if (!status) {
-			len = strlen(sz_reg_key);
-			spin_lock(&dbdcd_lock);
-			list_for_each_entry(dcd_key, &reg_key_list, link) {
-				if (!strncmp(dcd_key->name, sz_reg_key, len)
-						&& !index--) {
-					strncpy(sz_value, &dcd_key->name[len],
-					       strlen(&dcd_key->name[len]) + 1);
-						break;
-				}
-			}
-			spin_unlock(&dbdcd_lock);
-
-			if (&dcd_key->link == &reg_key_list)
-				status = -ENODATA;
-		}
-
-		if (!status) {
-			/* Create UUID value using string retrieved from
-			 * registry. */
-			status = dcd_uuid_from_string(sz_value, &dsp_uuid_obj);
-
-			if (!status) {
-				*uuid_obj = dsp_uuid_obj;
-
-				/* Increment enum_refs to update reference
-				 * count. */
-				enum_refs++;
-			}
-		} else if (status == -ENODATA) {
-			/* At the end of enumeration. Reset enum_refs. */
-			enum_refs = 0;
-
-			/*
-			 * TODO: Revisit, this is not an error case but code
-			 * expects non-zero value.
-			 */
-			status = ENODATA;
-		} else {
-			status = -EPERM;
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== dcd_exit ========
- *  Purpose:
- *      Discontinue usage of the DCD module.
- */
-void dcd_exit(void)
-{
-	struct dcd_key_elem *rv, *rv_tmp;
-
-	refs--;
-	if (refs == 0) {
-		list_for_each_entry_safe(rv, rv_tmp, &reg_key_list, link) {
-			list_del(&rv->link);
-			kfree(rv->path);
-			kfree(rv);
-		}
-	}
-
-}
-
-/*
- *  ======== dcd_get_dep_libs ========
- */
-int dcd_get_dep_libs(struct dcd_manager *hdcd_mgr,
-			    struct dsp_uuid *uuid_obj,
-			    u16 num_libs, struct dsp_uuid *dep_lib_uuids,
-			    bool *prstnt_dep_libs,
-			    enum nldr_phase phase)
-{
-	int status = 0;
-
-	status =
-	    get_dep_lib_info(hdcd_mgr, uuid_obj, &num_libs, NULL, dep_lib_uuids,
-			     prstnt_dep_libs, phase);
-
-	return status;
-}
-
-/*
- *  ======== dcd_get_num_dep_libs ========
- */
-int dcd_get_num_dep_libs(struct dcd_manager *hdcd_mgr,
-				struct dsp_uuid *uuid_obj,
-				u16 *num_libs, u16 *num_pers_libs,
-				enum nldr_phase phase)
-{
-	int status = 0;
-
-	status = get_dep_lib_info(hdcd_mgr, uuid_obj, num_libs, num_pers_libs,
-				  NULL, NULL, phase);
-
-	return status;
-}
-
-/*
- *  ======== dcd_get_object_def ========
- *  Purpose:
- *      Retrieves the properties of a node or processor based on the UUID and
- *      object type.
- */
-int dcd_get_object_def(struct dcd_manager *hdcd_mgr,
-			      struct dsp_uuid *obj_uuid,
-			      enum dsp_dcdobjtype obj_type,
-			      struct dcd_genericobj *obj_def)
-{
-	struct dcd_manager *dcd_mgr_obj = hdcd_mgr;	/* ptr to DCD mgr */
-	struct cod_libraryobj *lib = NULL;
-	int status = 0;
-	int len;
-	u32 ul_addr = 0;	/* Used by cod_get_section */
-	u32 ul_len = 0;		/* Used by cod_get_section */
-	u32 dw_buf_size;	/* Used by REG functions */
-	char sz_reg_key[DCD_MAXPATHLENGTH];
-	char *sz_uuid;		/*[MAXUUIDLEN]; */
-	char *tmp;
-	struct dcd_key_elem *dcd_key = NULL;
-	char sz_sect_name[MAXUUIDLEN + 2];	/* ".[UUID]\0" */
-	char *psz_coff_buf;
-	u32 dw_key_len;		/* Len of REG key. */
-	char sz_obj_type[MAX_INT2CHAR_LENGTH];	/* str. rep. of obj_type. */
-
-	sz_uuid = kzalloc(MAXUUIDLEN, GFP_KERNEL);
-	if (!sz_uuid) {
-		status = -ENOMEM;
-		goto func_end;
-	}
-
-	if (!hdcd_mgr) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	/* Pre-determine final key length. It's length of DCD_REGKEY +
-	 *  "_\0" + length of sz_obj_type string + terminating NULL */
-	dw_key_len = strlen(DCD_REGKEY) + 1 + sizeof(sz_obj_type) + 1;
-
-	/* Create proper REG key; concatenate DCD_REGKEY with obj_type. */
-	strncpy(sz_reg_key, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
-
-	if ((strlen(sz_reg_key) + strlen("_\0")) < DCD_MAXPATHLENGTH)
-		strncat(sz_reg_key, "_\0", 2);
-	else
-		status = -EPERM;
-
-	status = snprintf(sz_obj_type, MAX_INT2CHAR_LENGTH, "%d", obj_type);
-	if (status == -1) {
-		status = -EPERM;
-	} else {
-		status = 0;
-
-		if ((strlen(sz_reg_key) + strlen(sz_obj_type)) <
-		    DCD_MAXPATHLENGTH) {
-			strncat(sz_reg_key, sz_obj_type,
-				strlen(sz_obj_type) + 1);
-		} else {
-			status = -EPERM;
-		}
-
-		/* Create UUID value to set in registry. */
-		snprintf(sz_uuid, MAXUUIDLEN, "%pUL", obj_uuid);
-
-		if ((strlen(sz_reg_key) + MAXUUIDLEN) < DCD_MAXPATHLENGTH)
-			strncat(sz_reg_key, sz_uuid, MAXUUIDLEN);
-		else
-			status = -EPERM;
-
-		/* Retrieve paths from the registry based on struct dsp_uuid */
-		dw_buf_size = DCD_MAXPATHLENGTH;
-	}
-	if (!status) {
-		spin_lock(&dbdcd_lock);
-		list_for_each_entry(dcd_key, &reg_key_list, link) {
-			if (!strncmp(dcd_key->name, sz_reg_key,
-						strlen(sz_reg_key) + 1))
-				break;
-		}
-		spin_unlock(&dbdcd_lock);
-		if (&dcd_key->link == &reg_key_list) {
-			status = -ENOKEY;
-			goto func_end;
-		}
-	}
-
-
-	/* Open COFF file. */
-	status = cod_open(dcd_mgr_obj->cod_mgr, dcd_key->path,
-							COD_NOLOAD, &lib);
-	if (status) {
-		status = -EACCES;
-		goto func_end;
-	}
-
-	/* Ensure sz_uuid + 1 is not greater than sizeof sz_sect_name. */
-	len = strlen(sz_uuid);
-	if (len + 1 > sizeof(sz_sect_name)) {
-		status = -EPERM;
-		goto func_end;
-	}
-
-	/* Create section name based on node UUID. A period is
-	 * pre-pended to the UUID string to form the section name.
-	 * I.e. ".24BC8D90_BB45_11d4_B756_006008BDB66F" */
-
-	len -= 4;	/* uuid has 4 delimiters '-' */
-	tmp = sz_uuid;
-
-	strncpy(sz_sect_name, ".", 2);
-	do {
-		char *uuid = strsep(&tmp, "-");
-
-		if (!uuid)
-			break;
-		len -= strlen(uuid);
-		strncat(sz_sect_name, uuid, strlen(uuid) + 1);
-	} while (len && strncat(sz_sect_name, "_", 2));
-
-	/* Get section information. */
-	status = cod_get_section(lib, sz_sect_name, &ul_addr, &ul_len);
-	if (status) {
-		status = -EACCES;
-		goto func_end;
-	}
-
-	/* Allocate zeroed buffer. */
-	psz_coff_buf = kzalloc(ul_len + 4, GFP_KERNEL);
-	if (psz_coff_buf == NULL) {
-		status = -ENOMEM;
-		goto func_end;
-	}
-#ifdef _DB_TIOMAP
-	if (strstr(dcd_key->path, "iva") == NULL) {
-		/* Locate section by objectID and read its content. */
-		status =
-		    cod_read_section(lib, sz_sect_name, psz_coff_buf, ul_len);
-	} else {
-		status =
-		    cod_read_section(lib, sz_sect_name, psz_coff_buf, ul_len);
-		dev_dbg(bridge, "%s: Skipped Byte swap for IVA!!\n", __func__);
-	}
-#else
-	status = cod_read_section(lib, sz_sect_name, psz_coff_buf, ul_len);
-#endif
-	if (!status) {
-		/* Compress DSP buffer to conform to PC format. */
-		if (strstr(dcd_key->path, "iva") == NULL) {
-			compress_buf(psz_coff_buf, ul_len, DSPWORDSIZE);
-		} else {
-			compress_buf(psz_coff_buf, ul_len, 1);
-			dev_dbg(bridge, "%s: Compressing IVA COFF buffer by 1 "
-				"for IVA!!\n", __func__);
-		}
-
-		/* Parse the content of the COFF buffer. */
-		status =
-		    get_attrs_from_buf(psz_coff_buf, ul_len, obj_type, obj_def);
-		if (status)
-			status = -EACCES;
-	} else {
-		status = -EACCES;
-	}
-
-	/* Free the previously allocated dynamic buffer. */
-	kfree(psz_coff_buf);
-func_end:
-	if (lib)
-		cod_close(lib);
-
-	kfree(sz_uuid);
-
-	return status;
-}
-
-/*
- *  ======== dcd_get_objects ========
- */
-int dcd_get_objects(struct dcd_manager *hdcd_mgr,
-			   char *sz_coff_path, dcd_registerfxn register_fxn,
-			   void *handle)
-{
-	struct dcd_manager *dcd_mgr_obj = hdcd_mgr;
-	int status = 0;
-	char *psz_coff_buf;
-	char *psz_cur;
-	struct cod_libraryobj *lib = NULL;
-	u32 ul_addr = 0;	/* Used by cod_get_section */
-	u32 ul_len = 0;		/* Used by cod_get_section */
-	char seps[] = ":, ";
-	char *token = NULL;
-	struct dsp_uuid dsp_uuid_obj;
-	s32 object_type;
-
-	if (!hdcd_mgr) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	/* Open DSP coff file, don't load symbols. */
-	status = cod_open(dcd_mgr_obj->cod_mgr, sz_coff_path, COD_NOLOAD, &lib);
-	if (status) {
-		status = -EACCES;
-		goto func_cont;
-	}
-
-	/* Get DCD_RESIGER_SECTION section information. */
-	status = cod_get_section(lib, DCD_REGISTER_SECTION, &ul_addr, &ul_len);
-	if (status || !(ul_len > 0)) {
-		status = -EACCES;
-		goto func_cont;
-	}
-
-	/* Allocate zeroed buffer. */
-	psz_coff_buf = kzalloc(ul_len + 4, GFP_KERNEL);
-	if (psz_coff_buf == NULL) {
-		status = -ENOMEM;
-		goto func_cont;
-	}
-#ifdef _DB_TIOMAP
-	if (strstr(sz_coff_path, "iva") == NULL) {
-		/* Locate section by objectID and read its content. */
-		status = cod_read_section(lib, DCD_REGISTER_SECTION,
-					  psz_coff_buf, ul_len);
-	} else {
-		dev_dbg(bridge, "%s: Skipped Byte swap for IVA!!\n", __func__);
-		status = cod_read_section(lib, DCD_REGISTER_SECTION,
-					  psz_coff_buf, ul_len);
-	}
-#else
-	status =
-	    cod_read_section(lib, DCD_REGISTER_SECTION, psz_coff_buf, ul_len);
-#endif
-	if (!status) {
-		/* Compress DSP buffer to conform to PC format. */
-		if (strstr(sz_coff_path, "iva") == NULL) {
-			compress_buf(psz_coff_buf, ul_len, DSPWORDSIZE);
-		} else {
-			compress_buf(psz_coff_buf, ul_len, 1);
-			dev_dbg(bridge, "%s: Compress COFF buffer with 1 word "
-				"for IVA!!\n", __func__);
-		}
-
-		/* Read from buffer and register object in buffer. */
-		psz_cur = psz_coff_buf;
-		while ((token = strsep(&psz_cur, seps)) && *token != '\0') {
-			/*  Retrieve UUID string. */
-			status = dcd_uuid_from_string(token, &dsp_uuid_obj);
-
-			if (!status) {
-				/*  Retrieve object type */
-				token = strsep(&psz_cur, seps);
-
-				/*  Retrieve object type */
-				object_type = atoi(token);
-
-				/*
-				*  Apply register_fxn to the found DCD object.
-				*  Possible actions include:
-				*
-				*  1) Register found DCD object.
-				*  2) Unregister found DCD object
-				*     (when handle == NULL)
-				*  3) Add overlay node.
-				*/
-				status =
-				    register_fxn(&dsp_uuid_obj, object_type,
-						 handle);
-			}
-			if (status) {
-				/* if error occurs, break from while loop. */
-				break;
-			}
-		}
-	} else {
-		status = -EACCES;
-	}
-
-	/* Free the previously allocated dynamic buffer. */
-	kfree(psz_coff_buf);
-func_cont:
-	if (lib)
-		cod_close(lib);
-
-func_end:
-	return status;
-}
-
-/*
- *  ======== dcd_get_library_name ========
- *  Purpose:
- *      Retrieves the library name for the given UUID.
- *
- */
-int dcd_get_library_name(struct dcd_manager *hdcd_mgr,
-				struct dsp_uuid *uuid_obj,
-				char *str_lib_name,
-				u32 *buff_size,
-				enum nldr_phase phase, bool *phase_split)
-{
-	char sz_reg_key[DCD_MAXPATHLENGTH];
-	char sz_uuid[MAXUUIDLEN];
-	u32 dw_key_len;		/* Len of REG key. */
-	char sz_obj_type[MAX_INT2CHAR_LENGTH];	/* str. rep. of obj_type. */
-	int status = 0;
-	struct dcd_key_elem *dcd_key = NULL;
-
-	dev_dbg(bridge, "%s: hdcd_mgr %p, uuid_obj %p, str_lib_name %p,"
-		" buff_size %p\n", __func__, hdcd_mgr, uuid_obj, str_lib_name,
-		buff_size);
-
-	/*
-	 *  Pre-determine final key length. It's length of DCD_REGKEY +
-	 *  "_\0" + length of sz_obj_type string + terminating NULL.
-	 */
-	dw_key_len = strlen(DCD_REGKEY) + 1 + sizeof(sz_obj_type) + 1;
-
-	/* Create proper REG key; concatenate DCD_REGKEY with obj_type. */
-	strncpy(sz_reg_key, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
-	if ((strlen(sz_reg_key) + strlen("_\0")) < DCD_MAXPATHLENGTH)
-		strncat(sz_reg_key, "_\0", 2);
-	else
-		status = -EPERM;
-
-	switch (phase) {
-	case NLDR_CREATE:
-		/* create phase type */
-		sprintf(sz_obj_type, "%d", DSP_DCDCREATELIBTYPE);
-		break;
-	case NLDR_EXECUTE:
-		/* execute phase type */
-		sprintf(sz_obj_type, "%d", DSP_DCDEXECUTELIBTYPE);
-		break;
-	case NLDR_DELETE:
-		/* delete phase type */
-		sprintf(sz_obj_type, "%d", DSP_DCDDELETELIBTYPE);
-		break;
-	case NLDR_NOPHASE:
-		/* known to be a dependent library */
-		sprintf(sz_obj_type, "%d", DSP_DCDLIBRARYTYPE);
-		break;
-	default:
-		status = -EINVAL;
-	}
-	if (!status) {
-		if ((strlen(sz_reg_key) + strlen(sz_obj_type)) <
-		    DCD_MAXPATHLENGTH) {
-			strncat(sz_reg_key, sz_obj_type,
-				strlen(sz_obj_type) + 1);
-		} else {
-			status = -EPERM;
-		}
-		/* Create UUID value to find match in registry. */
-		snprintf(sz_uuid, MAXUUIDLEN, "%pUL", uuid_obj);
-		if ((strlen(sz_reg_key) + MAXUUIDLEN) < DCD_MAXPATHLENGTH)
-			strncat(sz_reg_key, sz_uuid, MAXUUIDLEN);
-		else
-			status = -EPERM;
-	}
-	if (!status) {
-		spin_lock(&dbdcd_lock);
-		list_for_each_entry(dcd_key, &reg_key_list, link) {
-			/*  See if the name matches. */
-			if (!strncmp(dcd_key->name, sz_reg_key,
-						strlen(sz_reg_key) + 1))
-				break;
-		}
-		spin_unlock(&dbdcd_lock);
-	}
-
-	if (&dcd_key->link == &reg_key_list)
-		status = -ENOKEY;
-
-	/* If can't find, phases might be registered as generic LIBRARYTYPE */
-	if (status && phase != NLDR_NOPHASE) {
-		if (phase_split)
-			*phase_split = false;
-
-		strncpy(sz_reg_key, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
-		if ((strlen(sz_reg_key) + strlen("_\0")) <
-		    DCD_MAXPATHLENGTH) {
-			strncat(sz_reg_key, "_\0", 2);
-		} else {
-			status = -EPERM;
-		}
-		sprintf(sz_obj_type, "%d", DSP_DCDLIBRARYTYPE);
-		if ((strlen(sz_reg_key) + strlen(sz_obj_type))
-		    < DCD_MAXPATHLENGTH) {
-			strncat(sz_reg_key, sz_obj_type,
-				strlen(sz_obj_type) + 1);
-		} else {
-			status = -EPERM;
-		}
-		snprintf(sz_uuid, MAXUUIDLEN, "%pUL", uuid_obj);
-		if ((strlen(sz_reg_key) + MAXUUIDLEN) < DCD_MAXPATHLENGTH)
-			strncat(sz_reg_key, sz_uuid, MAXUUIDLEN);
-		else
-			status = -EPERM;
-
-		spin_lock(&dbdcd_lock);
-		list_for_each_entry(dcd_key, &reg_key_list, link) {
-			/*  See if the name matches. */
-			if (!strncmp(dcd_key->name, sz_reg_key,
-						strlen(sz_reg_key) + 1))
-				break;
-		}
-		spin_unlock(&dbdcd_lock);
-
-		status = (&dcd_key->link != &reg_key_list) ?
-						0 : -ENOKEY;
-	}
-
-	if (!status)
-		memcpy(str_lib_name, dcd_key->path, strlen(dcd_key->path) + 1);
-	return status;
-}
-
-/*
- *  ======== dcd_init ========
- *  Purpose:
- *      Initialize the DCD module.
- */
-bool dcd_init(void)
-{
-	bool ret = true;
-
-	if (refs == 0)
-		INIT_LIST_HEAD(&reg_key_list);
-
-	if (ret)
-		refs++;
-
-	return ret;
-}
-
-/*
- *  ======== dcd_register_object ========
- *  Purpose:
- *      Registers a node or a processor with the DCD.
- *      If psz_path_name == NULL, unregister the specified DCD object.
- */
-int dcd_register_object(struct dsp_uuid *uuid_obj,
-			       enum dsp_dcdobjtype obj_type,
-			       char *psz_path_name)
-{
-	int status = 0;
-	char sz_reg_key[DCD_MAXPATHLENGTH];
-	char sz_uuid[MAXUUIDLEN + 1];
-	u32 dw_path_size = 0;
-	u32 dw_key_len;		/* Len of REG key. */
-	char sz_obj_type[MAX_INT2CHAR_LENGTH];	/* str. rep. of obj_type. */
-	struct dcd_key_elem *dcd_key = NULL;
-
-	dev_dbg(bridge, "%s: object UUID %p, obj_type %d, szPathName %s\n",
-		__func__, uuid_obj, obj_type, psz_path_name);
-
-	/*
-	 * Pre-determine final key length. It's length of DCD_REGKEY +
-	 *  "_\0" + length of sz_obj_type string + terminating NULL.
-	 */
-	dw_key_len = strlen(DCD_REGKEY) + 1 + sizeof(sz_obj_type) + 1;
-
-	/* Create proper REG key; concatenate DCD_REGKEY with obj_type. */
-	strncpy(sz_reg_key, DCD_REGKEY, strlen(DCD_REGKEY) + 1);
-	if ((strlen(sz_reg_key) + strlen("_\0")) < DCD_MAXPATHLENGTH)
-		strncat(sz_reg_key, "_\0", 2);
-	else {
-		status = -EPERM;
-		goto func_end;
-	}
-
-	status = snprintf(sz_obj_type, MAX_INT2CHAR_LENGTH, "%d", obj_type);
-	if (status == -1) {
-		status = -EPERM;
-	} else {
-		status = 0;
-		if ((strlen(sz_reg_key) + strlen(sz_obj_type)) <
-		    DCD_MAXPATHLENGTH) {
-			strncat(sz_reg_key, sz_obj_type,
-				strlen(sz_obj_type) + 1);
-		} else
-			status = -EPERM;
-
-		/* Create UUID value to set in registry. */
-		snprintf(sz_uuid, MAXUUIDLEN, "%pUL", uuid_obj);
-		if ((strlen(sz_reg_key) + MAXUUIDLEN) < DCD_MAXPATHLENGTH)
-			strncat(sz_reg_key, sz_uuid, MAXUUIDLEN);
-		else
-			status = -EPERM;
-	}
-
-	if (status)
-		goto func_end;
-
-	/*
-	 * If psz_path_name != NULL, perform registration, otherwise,
-	 * perform unregistration.
-	 */
-
-	if (psz_path_name) {
-		dw_path_size = strlen(psz_path_name) + 1;
-		spin_lock(&dbdcd_lock);
-		list_for_each_entry(dcd_key, &reg_key_list, link) {
-			/*  See if the name matches. */
-			if (!strncmp(dcd_key->name, sz_reg_key,
-						strlen(sz_reg_key) + 1))
-				break;
-		}
-		spin_unlock(&dbdcd_lock);
-		if (&dcd_key->link == &reg_key_list) {
-			/*
-			 * Add new reg value (UUID+obj_type)
-			 * with COFF path info
-			 */
-
-			dcd_key = kmalloc(sizeof(struct dcd_key_elem),
-								GFP_KERNEL);
-			if (!dcd_key) {
-				status = -ENOMEM;
-				goto func_end;
-			}
-
-			dcd_key->path = kmalloc(dw_path_size, GFP_KERNEL);
-
-			if (!dcd_key->path) {
-				kfree(dcd_key);
-				status = -ENOMEM;
-				goto func_end;
-			}
-
-			strncpy(dcd_key->name, sz_reg_key,
-						strlen(sz_reg_key) + 1);
-			strncpy(dcd_key->path, psz_path_name ,
-						dw_path_size);
-			spin_lock(&dbdcd_lock);
-			list_add_tail(&dcd_key->link, &reg_key_list);
-			spin_unlock(&dbdcd_lock);
-		} else {
-			/*  Make sure the new data is the same. */
-			if (strncmp(dcd_key->path, psz_path_name,
-							dw_path_size)) {
-				/*  The caller needs a different data size! */
-				kfree(dcd_key->path);
-				dcd_key->path = kmalloc(dw_path_size,
-								GFP_KERNEL);
-				if (dcd_key->path == NULL) {
-					status = -ENOMEM;
-					goto func_end;
-				}
-			}
-
-			/*  We have a match!  Copy out the data. */
-			memcpy(dcd_key->path, psz_path_name, dw_path_size);
-		}
-		dev_dbg(bridge, "%s: psz_path_name=%s, dw_path_size=%d\n",
-			__func__, psz_path_name, dw_path_size);
-	} else {
-		/* Deregister an existing object */
-		spin_lock(&dbdcd_lock);
-		list_for_each_entry(dcd_key, &reg_key_list, link) {
-			if (!strncmp(dcd_key->name, sz_reg_key,
-						strlen(sz_reg_key) + 1)) {
-				list_del(&dcd_key->link);
-				kfree(dcd_key->path);
-				kfree(dcd_key);
-				break;
-			}
-		}
-		spin_unlock(&dbdcd_lock);
-		if (&dcd_key->link == &reg_key_list)
-			status = -EPERM;
-	}
-
-	if (!status) {
-		/*
-		 *  Because the node database has been updated through a
-		 *  successful object registration/de-registration operation,
-		 *  we need to reset the object enumeration counter to allow
-		 *  current enumerations to reflect this update in the node
-		 *  database.
-		 */
-		enum_refs = 0;
-	}
-func_end:
-	return status;
-}
-
-/*
- *  ======== dcd_unregister_object ========
- *  Call DCD_Register object with psz_path_name set to NULL to
- *  perform actual object de-registration.
- */
-int dcd_unregister_object(struct dsp_uuid *uuid_obj,
-				 enum dsp_dcdobjtype obj_type)
-{
-	int status = 0;
-
-	/*
-	 *  When dcd_register_object is called with NULL as pathname,
-	 *  it indicates an unregister object operation.
-	 */
-	status = dcd_register_object(uuid_obj, obj_type, NULL);
-
-	return status;
-}
-
-/*
- **********************************************************************
- * DCD Helper Functions
- **********************************************************************
- */
-
-/*
- *  ======== atoi ========
- *  Purpose:
- *      This function converts strings in decimal or hex format to integers.
- */
-static s32 atoi(char *psz_buf)
-{
-	char *pch = psz_buf;
-	s32 base = 0;
-
-	while (isspace(*pch))
-		pch++;
-
-	if (*pch == '-' || *pch == '+') {
-		base = 10;
-		pch++;
-	} else if (*pch && tolower(pch[strlen(pch) - 1]) == 'h') {
-		base = 16;
-	}
-
-	return simple_strtoul(pch, NULL, base);
-}
-
-/*
- *  ======== get_attrs_from_buf ========
- *  Purpose:
- *      Parse the content of a buffer filled with DSP-side data and
- *      retrieve an object's attributes from it. IMPORTANT: Assume the
- *      buffer has been converted from DSP format to GPP format.
- */
-static int get_attrs_from_buf(char *psz_buf, u32 ul_buf_size,
-				     enum dsp_dcdobjtype obj_type,
-				     struct dcd_genericobj *gen_obj)
-{
-	int status = 0;
-	char seps[] = ", ";
-	char *psz_cur;
-	char *token;
-	s32 token_len = 0;
-	u32 i = 0;
-#ifdef _DB_TIOMAP
-	s32 entry_id;
-#endif
-
-	switch (obj_type) {
-	case DSP_DCDNODETYPE:
-		/*
-		 * Parse COFF sect buffer to retrieve individual tokens used
-		 * to fill in object attrs.
-		 */
-		psz_cur = psz_buf;
-		token = strsep(&psz_cur, seps);
-
-		/* u32 cb_struct */
-		gen_obj->obj_data.node_obj.ndb_props.cb_struct =
-		    (u32) atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		/* dsp_uuid ui_node_id */
-		status = dcd_uuid_from_string(token,
-					      &gen_obj->obj_data.node_obj.
-					      ndb_props.ui_node_id);
-		if (status)
-			break;
-
-		token = strsep(&psz_cur, seps);
-
-		/* ac_name */
-		token_len = strlen(token);
-		if (token_len > DSP_MAXNAMELEN - 1)
-			token_len = DSP_MAXNAMELEN - 1;
-
-		strncpy(gen_obj->obj_data.node_obj.ndb_props.ac_name,
-			token, token_len);
-		gen_obj->obj_data.node_obj.ndb_props.ac_name[token_len] = '\0';
-		token = strsep(&psz_cur, seps);
-		/* u32 ntype */
-		gen_obj->obj_data.node_obj.ndb_props.ntype = atoi(token);
-		token = strsep(&psz_cur, seps);
-		/* u32 cache_on_gpp */
-		gen_obj->obj_data.node_obj.ndb_props.cache_on_gpp = atoi(token);
-		token = strsep(&psz_cur, seps);
-		/* dsp_resourcereqmts dsp_resource_reqmts */
-		gen_obj->obj_data.node_obj.ndb_props.dsp_resource_reqmts.
-		    cb_struct = (u32) atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.node_obj.ndb_props.
-		    dsp_resource_reqmts.static_data_size = atoi(token);
-		token = strsep(&psz_cur, seps);
-		gen_obj->obj_data.node_obj.ndb_props.
-		    dsp_resource_reqmts.global_data_size = atoi(token);
-		token = strsep(&psz_cur, seps);
-		gen_obj->obj_data.node_obj.ndb_props.
-		    dsp_resource_reqmts.program_mem_size = atoi(token);
-		token = strsep(&psz_cur, seps);
-		gen_obj->obj_data.node_obj.ndb_props.
-		    dsp_resource_reqmts.wc_execution_time = atoi(token);
-		token = strsep(&psz_cur, seps);
-		gen_obj->obj_data.node_obj.ndb_props.
-		    dsp_resource_reqmts.wc_period = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.node_obj.ndb_props.
-		    dsp_resource_reqmts.wc_deadline = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.node_obj.ndb_props.
-		    dsp_resource_reqmts.avg_exection_time = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.node_obj.ndb_props.
-		    dsp_resource_reqmts.minimum_period = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		/* s32 prio */
-		gen_obj->obj_data.node_obj.ndb_props.prio = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		/* u32 stack_size */
-		gen_obj->obj_data.node_obj.ndb_props.stack_size = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		/* u32 sys_stack_size */
-		gen_obj->obj_data.node_obj.ndb_props.sys_stack_size =
-		    atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		/* u32 stack_seg */
-		gen_obj->obj_data.node_obj.ndb_props.stack_seg = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		/* u32 message_depth */
-		gen_obj->obj_data.node_obj.ndb_props.message_depth =
-		    atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		/* u32 num_input_streams */
-		gen_obj->obj_data.node_obj.ndb_props.num_input_streams =
-		    atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		/* u32 num_output_streams */
-		gen_obj->obj_data.node_obj.ndb_props.num_output_streams =
-		    atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		/* u32 timeout */
-		gen_obj->obj_data.node_obj.ndb_props.timeout = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		/* char *str_create_phase_fxn */
-		token_len = strlen(token);
-		gen_obj->obj_data.node_obj.str_create_phase_fxn =
-					kzalloc(token_len + 1, GFP_KERNEL);
-		strncpy(gen_obj->obj_data.node_obj.str_create_phase_fxn,
-			token, token_len);
-		gen_obj->obj_data.node_obj.str_create_phase_fxn[token_len] =
-		    '\0';
-		token = strsep(&psz_cur, seps);
-
-		/* char *str_execute_phase_fxn */
-		token_len = strlen(token);
-		gen_obj->obj_data.node_obj.str_execute_phase_fxn =
-					kzalloc(token_len + 1, GFP_KERNEL);
-		strncpy(gen_obj->obj_data.node_obj.str_execute_phase_fxn,
-			token, token_len);
-		gen_obj->obj_data.node_obj.str_execute_phase_fxn[token_len] =
-		    '\0';
-		token = strsep(&psz_cur, seps);
-
-		/* char *str_delete_phase_fxn */
-		token_len = strlen(token);
-		gen_obj->obj_data.node_obj.str_delete_phase_fxn =
-					kzalloc(token_len + 1, GFP_KERNEL);
-		strncpy(gen_obj->obj_data.node_obj.str_delete_phase_fxn,
-			token, token_len);
-		gen_obj->obj_data.node_obj.str_delete_phase_fxn[token_len] =
-		    '\0';
-		token = strsep(&psz_cur, seps);
-
-		/* Segment id for message buffers */
-		gen_obj->obj_data.node_obj.msg_segid = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		/* Message notification type */
-		gen_obj->obj_data.node_obj.msg_notify_type = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		/* char *str_i_alg_name */
-		if (token) {
-			token_len = strlen(token);
-			gen_obj->obj_data.node_obj.str_i_alg_name =
-					kzalloc(token_len + 1, GFP_KERNEL);
-			strncpy(gen_obj->obj_data.node_obj.str_i_alg_name,
-				token, token_len);
-			gen_obj->obj_data.node_obj.str_i_alg_name[token_len] =
-			    '\0';
-			token = strsep(&psz_cur, seps);
-		}
-
-		/* Load type (static, dynamic, or overlay) */
-		if (token) {
-			gen_obj->obj_data.node_obj.load_type = atoi(token);
-			token = strsep(&psz_cur, seps);
-		}
-
-		/* Dynamic load data requirements */
-		if (token) {
-			gen_obj->obj_data.node_obj.data_mem_seg_mask =
-			    atoi(token);
-			token = strsep(&psz_cur, seps);
-		}
-
-		/* Dynamic load code requirements */
-		if (token) {
-			gen_obj->obj_data.node_obj.code_mem_seg_mask =
-			    atoi(token);
-			token = strsep(&psz_cur, seps);
-		}
-
-		/* Extract node profiles into node properties */
-		if (token) {
-
-			gen_obj->obj_data.node_obj.ndb_props.count_profiles =
-			    atoi(token);
-			for (i = 0;
-			     i <
-			     gen_obj->obj_data.node_obj.
-			     ndb_props.count_profiles; i++) {
-				token = strsep(&psz_cur, seps);
-				if (token) {
-					/* Heap Size for the node */
-					gen_obj->obj_data.node_obj.
-					    ndb_props.node_profiles[i].
-					    heap_size = atoi(token);
-				}
-			}
-		}
-		token = strsep(&psz_cur, seps);
-		if (token) {
-			gen_obj->obj_data.node_obj.ndb_props.stack_seg_name =
-			    (u32) (token);
-		}
-
-		break;
-
-	case DSP_DCDPROCESSORTYPE:
-		/*
-		 * Parse COFF sect buffer to retrieve individual tokens used
-		 * to fill in object attrs.
-		 */
-		psz_cur = psz_buf;
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.proc_info.cb_struct = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.proc_info.processor_family = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.proc_info.processor_type = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.proc_info.clock_rate = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.proc_info.internal_mem_size = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.proc_info.external_mem_size = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.proc_info.processor_id = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.proc_info.ty_running_rtos = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.proc_info.node_min_priority = atoi(token);
-		token = strsep(&psz_cur, seps);
-
-		gen_obj->obj_data.proc_info.node_max_priority = atoi(token);
-
-#ifdef _DB_TIOMAP
-		/* Proc object may contain additional(extended) attributes. */
-		/* attr must match proc.hxx */
-		for (entry_id = 0; entry_id < 7; entry_id++) {
-			token = strsep(&psz_cur, seps);
-			gen_obj->obj_data.ext_proc_obj.ty_tlb[entry_id].
-			    gpp_phys = atoi(token);
-
-			token = strsep(&psz_cur, seps);
-			gen_obj->obj_data.ext_proc_obj.ty_tlb[entry_id].
-			    dsp_virt = atoi(token);
-		}
-#endif
-
-		break;
-
-	default:
-		status = -EPERM;
-		break;
-	}
-
-	return status;
-}
-
-/*
- *  ======== CompressBuffer ========
- *  Purpose:
- *      Compress the DSP buffer, if necessary, to conform to PC format.
- */
-static void compress_buf(char *psz_buf, u32 ul_buf_size, s32 char_size)
-{
-	char *p;
-	char ch;
-	char *q;
-
-	p = psz_buf;
-	if (p == NULL)
-		return;
-
-	for (q = psz_buf; q < (psz_buf + ul_buf_size);) {
-		ch = dsp_char2_gpp_char(q, char_size);
-		if (ch == '\\') {
-			q += char_size;
-			ch = dsp_char2_gpp_char(q, char_size);
-			switch (ch) {
-			case 't':
-				*p = '\t';
-				break;
-
-			case 'n':
-				*p = '\n';
-				break;
-
-			case 'r':
-				*p = '\r';
-				break;
-
-			case '0':
-				*p = '\0';
-				break;
-
-			default:
-				*p = ch;
-				break;
-			}
-		} else {
-			*p = ch;
-		}
-		p++;
-		q += char_size;
-	}
-
-	/* NULL out remainder of buffer. */
-	while (p < q)
-		*p++ = '\0';
-}
-
-/*
- *  ======== dsp_char2_gpp_char ========
- *  Purpose:
- *      Convert DSP char to host GPP char in a portable manner
- */
-static char dsp_char2_gpp_char(char *word, s32 dsp_char_size)
-{
-	char ch = '\0';
-	char *ch_src;
-	s32 i;
-
-	for (ch_src = word, i = dsp_char_size; i > 0; i--)
-		ch |= *ch_src++;
-
-	return ch;
-}
-
-/*
- *  ======== get_dep_lib_info ========
- */
-static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
-				   struct dsp_uuid *uuid_obj,
-				   u16 *num_libs,
-				   u16 *num_pers_libs,
-				   struct dsp_uuid *dep_lib_uuids,
-				   bool *prstnt_dep_libs,
-				   enum nldr_phase phase)
-{
-	struct dcd_manager *dcd_mgr_obj = hdcd_mgr;
-	char *psz_coff_buf = NULL;
-	char *psz_cur;
-	char *psz_file_name = NULL;
-	struct cod_libraryobj *lib = NULL;
-	u32 ul_addr = 0;	/* Used by cod_get_section */
-	u32 ul_len = 0;		/* Used by cod_get_section */
-	u32 dw_data_size = COD_MAXPATHLENGTH;
-	char seps[] = ", ";
-	char *token = NULL;
-	bool get_uuids = (dep_lib_uuids != NULL);
-	u16 dep_libs = 0;
-	int status = 0;
-
-	/*  Initialize to 0 dependent libraries, if only counting number of
-	 *  dependent libraries */
-	if (!get_uuids) {
-		*num_libs = 0;
-		*num_pers_libs = 0;
-	}
-
-	/* Allocate a buffer for file name */
-	psz_file_name = kzalloc(dw_data_size, GFP_KERNEL);
-	if (psz_file_name == NULL) {
-		status = -ENOMEM;
-	} else {
-		/* Get the name of the library */
-		status = dcd_get_library_name(hdcd_mgr, uuid_obj, psz_file_name,
-					      &dw_data_size, phase, NULL);
-	}
-
-	/* Open the library */
-	if (!status) {
-		status = cod_open(dcd_mgr_obj->cod_mgr, psz_file_name,
-				  COD_NOLOAD, &lib);
-	}
-	if (!status) {
-		/* Get dependent library section information. */
-		status = cod_get_section(lib, DEPLIBSECT, &ul_addr, &ul_len);
-
-		if (status) {
-			/* Ok, no dependent libraries */
-			ul_len = 0;
-			status = 0;
-		}
-	}
-
-	if (status || !(ul_len > 0))
-		goto func_cont;
-
-	/* Allocate zeroed buffer. */
-	psz_coff_buf = kzalloc(ul_len + 4, GFP_KERNEL);
-	if (psz_coff_buf == NULL)
-		status = -ENOMEM;
-
-	/* Read section contents. */
-	status = cod_read_section(lib, DEPLIBSECT, psz_coff_buf, ul_len);
-	if (status)
-		goto func_cont;
-
-	/* Compress and format DSP buffer to conform to PC format. */
-	compress_buf(psz_coff_buf, ul_len, DSPWORDSIZE);
-
-	/* Read from buffer */
-	psz_cur = psz_coff_buf;
-	while ((token = strsep(&psz_cur, seps)) && *token != '\0') {
-		if (get_uuids) {
-			if (dep_libs >= *num_libs) {
-				/* Gone beyond the limit */
-				break;
-			} else {
-				/* Retrieve UUID string. */
-				status = dcd_uuid_from_string(token,
-							      &(dep_lib_uuids
-								[dep_libs]));
-				if (status)
-					break;
-
-				/* Is this library persistent? */
-				token = strsep(&psz_cur, seps);
-				prstnt_dep_libs[dep_libs] = atoi(token);
-				dep_libs++;
-			}
-		} else {
-			/* Advanc to next token */
-			token = strsep(&psz_cur, seps);
-			if (atoi(token))
-				(*num_pers_libs)++;
-
-			/* Just counting number of dependent libraries */
-			(*num_libs)++;
-		}
-	}
-func_cont:
-	if (lib)
-		cod_close(lib);
-
-	/* Free previously allocated dynamic buffers. */
-	kfree(psz_file_name);
-
-	kfree(psz_coff_buf);
-
-	return status;
-}
diff --git a/drivers/staging/tidspbridge/rmgr/disp.c b/drivers/staging/tidspbridge/rmgr/disp.c
deleted file mode 100644
index 4af51b7..0000000
--- a/drivers/staging/tidspbridge/rmgr/disp.c
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
- * disp.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Node Dispatcher interface. Communicates with Resource Manager Server
- * (RMS) on DSP. Access to RMS is synchronized in NODE.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#include <linux/types.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/sync.h>
-
-/*  ----------------------------------- Link Driver */
-#include <dspbridge/dspdefs.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/dev.h>
-#include <dspbridge/chnldefs.h>
-
-/*  ----------------------------------- Resource Manager */
-#include <dspbridge/nodedefs.h>
-#include <dspbridge/nodepriv.h>
-#include <dspbridge/rms_sh.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/disp.h>
-
-/* Size of a reply from RMS */
-#define REPLYSIZE (3 * sizeof(rms_word))
-
-/* Reserved channel offsets for communication with RMS */
-#define CHNLTORMSOFFSET       0
-#define CHNLFROMRMSOFFSET     1
-
-#define CHNLIOREQS      1
-
-/*
- *  ======== disp_object ========
- */
-struct disp_object {
-	struct dev_object *dev_obj;	/* Device for this processor */
-	/* Function interface to Bridge driver */
-	struct bridge_drv_interface *intf_fxns;
-	struct chnl_mgr *chnl_mgr;	/* Channel manager */
-	struct chnl_object *chnl_to_dsp;	/* Chnl for commands to RMS */
-	struct chnl_object *chnl_from_dsp;	/* Chnl for replies from RMS */
-	u8 *buf;		/* Buffer for commands, replies */
-	u32 bufsize;		/* buf size in bytes */
-	u32 bufsize_rms;	/* buf size in RMS words */
-	u32 char_size;		/* Size of DSP character */
-	u32 word_size;		/* Size of DSP word */
-	u32 data_mau_size;	/* Size of DSP Data MAU */
-};
-
-static void delete_disp(struct disp_object *disp_obj);
-static int fill_stream_def(rms_word *pdw_buf, u32 *ptotal, u32 offset,
-				  struct node_strmdef strm_def, u32 max,
-				  u32 chars_in_rms_word);
-static int send_message(struct disp_object *disp_obj, u32 timeout,
-			       u32 ul_bytes, u32 *pdw_arg);
-
-/*
- *  ======== disp_create ========
- *  Create a NODE Dispatcher object.
- */
-int disp_create(struct disp_object **dispatch_obj,
-		       struct dev_object *hdev_obj,
-		       const struct disp_attr *disp_attrs)
-{
-	struct disp_object *disp_obj;
-	struct bridge_drv_interface *intf_fxns;
-	u32 ul_chnl_id;
-	struct chnl_attr chnl_attr_obj;
-	int status = 0;
-	u8 dev_type;
-
-	*dispatch_obj = NULL;
-
-	/* Allocate Node Dispatcher object */
-	disp_obj = kzalloc(sizeof(struct disp_object), GFP_KERNEL);
-	if (disp_obj == NULL)
-		status = -ENOMEM;
-	else
-		disp_obj->dev_obj = hdev_obj;
-
-	/* Get Channel manager and Bridge function interface */
-	if (!status) {
-		status = dev_get_chnl_mgr(hdev_obj, &(disp_obj->chnl_mgr));
-		if (!status) {
-			(void)dev_get_intf_fxns(hdev_obj, &intf_fxns);
-			disp_obj->intf_fxns = intf_fxns;
-		}
-	}
-
-	/* check device type and decide if streams or messag'ing is used for
-	 * RMS/EDS */
-	if (status)
-		goto func_cont;
-
-	status = dev_get_dev_type(hdev_obj, &dev_type);
-
-	if (status)
-		goto func_cont;
-
-	if (dev_type != DSP_UNIT) {
-		status = -EPERM;
-		goto func_cont;
-	}
-
-	disp_obj->char_size = DSPWORDSIZE;
-	disp_obj->word_size = DSPWORDSIZE;
-	disp_obj->data_mau_size = DSPWORDSIZE;
-	/* Open channels for communicating with the RMS */
-	chnl_attr_obj.uio_reqs = CHNLIOREQS;
-	chnl_attr_obj.event_obj = NULL;
-	ul_chnl_id = disp_attrs->chnl_offset + CHNLTORMSOFFSET;
-	status = (*intf_fxns->chnl_open) (&(disp_obj->chnl_to_dsp),
-					      disp_obj->chnl_mgr,
-					      CHNL_MODETODSP, ul_chnl_id,
-					      &chnl_attr_obj);
-
-	if (!status) {
-		ul_chnl_id = disp_attrs->chnl_offset + CHNLFROMRMSOFFSET;
-		status =
-		    (*intf_fxns->chnl_open) (&(disp_obj->chnl_from_dsp),
-						 disp_obj->chnl_mgr,
-						 CHNL_MODEFROMDSP, ul_chnl_id,
-						 &chnl_attr_obj);
-	}
-	if (!status) {
-		/* Allocate buffer for commands, replies */
-		disp_obj->bufsize = disp_attrs->chnl_buf_size;
-		disp_obj->bufsize_rms = RMS_COMMANDBUFSIZE;
-		disp_obj->buf = kzalloc(disp_obj->bufsize, GFP_KERNEL);
-		if (disp_obj->buf == NULL)
-			status = -ENOMEM;
-	}
-func_cont:
-	if (!status)
-		*dispatch_obj = disp_obj;
-	else
-		delete_disp(disp_obj);
-
-	return status;
-}
-
-/*
- *  ======== disp_delete ========
- *  Delete the NODE Dispatcher.
- */
-void disp_delete(struct disp_object *disp_obj)
-{
-	delete_disp(disp_obj);
-}
-
-/*
- *  ======== disp_node_change_priority ========
- *  Change the priority of a node currently running on the target.
- */
-int disp_node_change_priority(struct disp_object *disp_obj,
-				     struct node_object *hnode,
-				     u32 rms_fxn, nodeenv node_env, s32 prio)
-{
-	u32 dw_arg;
-	struct rms_command *rms_cmd;
-	int status = 0;
-
-	/* Send message to RMS to change priority */
-	rms_cmd = (struct rms_command *)(disp_obj->buf);
-	rms_cmd->fxn = (rms_word) (rms_fxn);
-	rms_cmd->arg1 = (rms_word) node_env;
-	rms_cmd->arg2 = prio;
-	status = send_message(disp_obj, node_get_timeout(hnode),
-			      sizeof(struct rms_command), &dw_arg);
-
-	return status;
-}
-
-/*
- *  ======== disp_node_create ========
- *  Create a node on the DSP by remotely calling the node's create function.
- */
-int disp_node_create(struct disp_object *disp_obj,
-			    struct node_object *hnode, u32 rms_fxn,
-			    u32 ul_create_fxn,
-			    const struct node_createargs *pargs,
-			    nodeenv *node_env)
-{
-	struct node_msgargs node_msg_args;
-	struct node_taskargs task_arg_obj;
-	struct rms_command *rms_cmd;
-	struct rms_msg_args *pmsg_args;
-	struct rms_more_task_args *more_task_args;
-	enum node_type node_type;
-	u32 dw_length;
-	rms_word *pdw_buf = NULL;
-	u32 ul_bytes;
-	u32 i;
-	u32 total;
-	u32 chars_in_rms_word;
-	s32 task_args_offset;
-	s32 sio_in_def_offset;
-	s32 sio_out_def_offset;
-	s32 sio_defs_offset;
-	s32 args_offset = -1;
-	s32 offset;
-	struct node_strmdef strm_def;
-	u32 max;
-	int status = 0;
-	struct dsp_nodeinfo node_info;
-	u8 dev_type;
-
-	status = dev_get_dev_type(disp_obj->dev_obj, &dev_type);
-
-	if (status)
-		goto func_end;
-
-	if (dev_type != DSP_UNIT) {
-		dev_dbg(bridge, "%s: unknown device type = 0x%x\n",
-			__func__, dev_type);
-		goto func_end;
-	}
-	node_type = node_get_type(hnode);
-	node_msg_args = pargs->asa.node_msg_args;
-	max = disp_obj->bufsize_rms;	/*Max # of RMS words that can be sent */
-	chars_in_rms_word = sizeof(rms_word) / disp_obj->char_size;
-	/* Number of RMS words needed to hold arg data */
-	dw_length =
-	    (node_msg_args.arg_length + chars_in_rms_word -
-	     1) / chars_in_rms_word;
-	/* Make sure msg args and command fit in buffer */
-	total = sizeof(struct rms_command) / sizeof(rms_word) +
-	    sizeof(struct rms_msg_args)
-	    / sizeof(rms_word) - 1 + dw_length;
-	if (total >= max) {
-		status = -EPERM;
-		dev_dbg(bridge, "%s: Message args too large for buffer! size "
-			"= %d, max = %d\n", __func__, total, max);
-	}
-	/*
-	 *  Fill in buffer to send to RMS.
-	 *  The buffer will have the following  format:
-	 *
-	 *  RMS command:
-	 *      Address of RMS_CreateNode()
-	 *      Address of node's create function
-	 *      dummy argument
-	 *      node type
-	 *
-	 *  Message Args:
-	 *      max number of messages
-	 *      segid for message buffer allocation
-	 *      notification type to use when message is received
-	 *      length of message arg data
-	 *      message args data
-	 *
-	 *  Task Args (if task or socket node):
-	 *      priority
-	 *      stack size
-	 *      system stack size
-	 *      stack segment
-	 *      misc
-	 *      number of input streams
-	 *      pSTRMInDef[] - offsets of STRM definitions for input streams
-	 *      number of output streams
-	 *      pSTRMOutDef[] - offsets of STRM definitions for output
-	 *      streams
-	 *      STRMInDef[] - array of STRM definitions for input streams
-	 *      STRMOutDef[] - array of STRM definitions for output streams
-	 *
-	 *  Socket Args (if DAIS socket node):
-	 *
-	 */
-	if (!status) {
-		total = 0;	/* Total number of words in buffer so far */
-		pdw_buf = (rms_word *) disp_obj->buf;
-		rms_cmd = (struct rms_command *)pdw_buf;
-		rms_cmd->fxn = (rms_word) (rms_fxn);
-		rms_cmd->arg1 = (rms_word) (ul_create_fxn);
-		if (node_get_load_type(hnode) == NLDR_DYNAMICLOAD) {
-			/* Flush ICACHE on Load */
-			rms_cmd->arg2 = 1;	/* dummy argument */
-		} else {
-			/* Do not flush ICACHE */
-			rms_cmd->arg2 = 0;	/* dummy argument */
-		}
-		rms_cmd->data = node_get_type(hnode);
-		/*
-		 *  args_offset is the offset of the data field in struct
-		 *  rms_command structure. We need this to calculate stream
-		 *  definition offsets.
-		 */
-		args_offset = 3;
-		total += sizeof(struct rms_command) / sizeof(rms_word);
-		/* Message args */
-		pmsg_args = (struct rms_msg_args *)(pdw_buf + total);
-		pmsg_args->max_msgs = node_msg_args.max_msgs;
-		pmsg_args->segid = node_msg_args.seg_id;
-		pmsg_args->notify_type = node_msg_args.notify_type;
-		pmsg_args->arg_length = node_msg_args.arg_length;
-		total += sizeof(struct rms_msg_args) / sizeof(rms_word) - 1;
-		memcpy(pdw_buf + total, node_msg_args.pdata,
-		       node_msg_args.arg_length);
-		total += dw_length;
-	}
-	if (status)
-		goto func_end;
-
-	/* If node is a task node, copy task create arguments into  buffer */
-	if (node_type == NODE_TASK || node_type == NODE_DAISSOCKET) {
-		task_arg_obj = pargs->asa.task_arg_obj;
-		task_args_offset = total;
-		total += sizeof(struct rms_more_task_args) / sizeof(rms_word) +
-		    1 + task_arg_obj.num_inputs + task_arg_obj.num_outputs;
-		/* Copy task arguments */
-		if (total < max) {
-			total = task_args_offset;
-			more_task_args = (struct rms_more_task_args *)(pdw_buf +
-								       total);
-			/*
-			 * Get some important info about the node. Note that we
-			 * don't just reach into the hnode struct because
-			 * that would break the node object's abstraction.
-			 */
-			get_node_info(hnode, &node_info);
-			more_task_args->priority = node_info.execution_priority;
-			more_task_args->stack_size = task_arg_obj.stack_size;
-			more_task_args->sysstack_size =
-			    task_arg_obj.sys_stack_size;
-			more_task_args->stack_seg = task_arg_obj.stack_seg;
-			more_task_args->heap_addr = task_arg_obj.dsp_heap_addr;
-			more_task_args->heap_size = task_arg_obj.heap_size;
-			more_task_args->misc = task_arg_obj.dais_arg;
-			more_task_args->num_input_streams =
-			    task_arg_obj.num_inputs;
-			total +=
-			    sizeof(struct rms_more_task_args) /
-			    sizeof(rms_word);
-			dev_dbg(bridge, "%s: dsp_heap_addr %x, heap_size %x\n",
-				__func__, task_arg_obj.dsp_heap_addr,
-				task_arg_obj.heap_size);
-			/* Keep track of pSIOInDef[] and pSIOOutDef[]
-			 * positions in the buffer, since this needs to be
-			 * filled in later. */
-			sio_in_def_offset = total;
-			total += task_arg_obj.num_inputs;
-			pdw_buf[total++] = task_arg_obj.num_outputs;
-			sio_out_def_offset = total;
-			total += task_arg_obj.num_outputs;
-			sio_defs_offset = total;
-			/* Fill SIO defs and offsets */
-			offset = sio_defs_offset;
-			for (i = 0; i < task_arg_obj.num_inputs; i++) {
-				if (status)
-					break;
-
-				pdw_buf[sio_in_def_offset + i] =
-				    (offset - args_offset)
-				    * (sizeof(rms_word) / DSPWORDSIZE);
-				strm_def = task_arg_obj.strm_in_def[i];
-				status =
-				    fill_stream_def(pdw_buf, &total, offset,
-						    strm_def, max,
-						    chars_in_rms_word);
-				offset = total;
-			}
-			for (i = 0; (i < task_arg_obj.num_outputs) &&
-			     (!status); i++) {
-				pdw_buf[sio_out_def_offset + i] =
-				    (offset - args_offset)
-				    * (sizeof(rms_word) / DSPWORDSIZE);
-				strm_def = task_arg_obj.strm_out_def[i];
-				status =
-				    fill_stream_def(pdw_buf, &total, offset,
-						    strm_def, max,
-						    chars_in_rms_word);
-				offset = total;
-			}
-		} else {
-			/* Args won't fit */
-			status = -EPERM;
-		}
-	}
-	if (!status) {
-		ul_bytes = total * sizeof(rms_word);
-		status = send_message(disp_obj, node_get_timeout(hnode),
-				      ul_bytes, node_env);
-	}
-func_end:
-	return status;
-}
-
-/*
- *  ======== disp_node_delete ========
- *  purpose:
- *      Delete a node on the DSP by remotely calling the node's delete function.
- *
- */
-int disp_node_delete(struct disp_object *disp_obj,
-			    struct node_object *hnode, u32 rms_fxn,
-			    u32 ul_delete_fxn, nodeenv node_env)
-{
-	u32 dw_arg;
-	struct rms_command *rms_cmd;
-	int status = 0;
-	u8 dev_type;
-
-	status = dev_get_dev_type(disp_obj->dev_obj, &dev_type);
-
-	if (!status) {
-
-		if (dev_type == DSP_UNIT) {
-
-			/*
-			 *  Fill in buffer to send to RMS
-			 */
-			rms_cmd = (struct rms_command *)disp_obj->buf;
-			rms_cmd->fxn = (rms_word) (rms_fxn);
-			rms_cmd->arg1 = (rms_word) node_env;
-			rms_cmd->arg2 = (rms_word) (ul_delete_fxn);
-			rms_cmd->data = node_get_type(hnode);
-
-			status = send_message(disp_obj, node_get_timeout(hnode),
-					      sizeof(struct rms_command),
-					      &dw_arg);
-		}
-	}
-	return status;
-}
-
-/*
- *  ======== disp_node_run ========
- *  purpose:
- *      Start execution of a node's execute phase, or resume execution of a node
- *      that has been suspended (via DISP_NodePause()) on the DSP.
- */
-int disp_node_run(struct disp_object *disp_obj,
-			 struct node_object *hnode, u32 rms_fxn,
-			 u32 ul_execute_fxn, nodeenv node_env)
-{
-	u32 dw_arg;
-	struct rms_command *rms_cmd;
-	int status = 0;
-	u8 dev_type;
-
-	status = dev_get_dev_type(disp_obj->dev_obj, &dev_type);
-
-	if (!status) {
-
-		if (dev_type == DSP_UNIT) {
-
-			/*
-			 *  Fill in buffer to send to RMS.
-			 */
-			rms_cmd = (struct rms_command *)disp_obj->buf;
-			rms_cmd->fxn = (rms_word) (rms_fxn);
-			rms_cmd->arg1 = (rms_word) node_env;
-			rms_cmd->arg2 = (rms_word) (ul_execute_fxn);
-			rms_cmd->data = node_get_type(hnode);
-
-			status = send_message(disp_obj, node_get_timeout(hnode),
-					      sizeof(struct rms_command),
-					      &dw_arg);
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== delete_disp ========
- *  purpose:
- *      Frees the resources allocated for the dispatcher.
- */
-static void delete_disp(struct disp_object *disp_obj)
-{
-	int status = 0;
-	struct bridge_drv_interface *intf_fxns;
-
-	if (disp_obj) {
-		intf_fxns = disp_obj->intf_fxns;
-
-		/* Free Node Dispatcher resources */
-		if (disp_obj->chnl_from_dsp) {
-			/* Channel close can fail only if the channel handle
-			 * is invalid. */
-			status = (*intf_fxns->chnl_close)
-			    (disp_obj->chnl_from_dsp);
-			if (status) {
-				dev_dbg(bridge, "%s: Failed to close channel "
-					"from RMS: 0x%x\n", __func__, status);
-			}
-		}
-		if (disp_obj->chnl_to_dsp) {
-			status =
-			    (*intf_fxns->chnl_close) (disp_obj->
-							  chnl_to_dsp);
-			if (status) {
-				dev_dbg(bridge, "%s: Failed to close channel to"
-					" RMS: 0x%x\n", __func__, status);
-			}
-		}
-		kfree(disp_obj->buf);
-
-		kfree(disp_obj);
-	}
-}
-
-/*
- *  ======== fill_stream_def ========
- *  purpose:
- *      Fills stream definitions.
- */
-static int fill_stream_def(rms_word *pdw_buf, u32 *ptotal, u32 offset,
-				  struct node_strmdef strm_def, u32 max,
-				  u32 chars_in_rms_word)
-{
-	struct rms_strm_def *strm_def_obj;
-	u32 total = *ptotal;
-	u32 name_len;
-	u32 dw_length;
-	int status = 0;
-
-	if (total + sizeof(struct rms_strm_def) / sizeof(rms_word) >= max) {
-		status = -EPERM;
-	} else {
-		strm_def_obj = (struct rms_strm_def *)(pdw_buf + total);
-		strm_def_obj->bufsize = strm_def.buf_size;
-		strm_def_obj->nbufs = strm_def.num_bufs;
-		strm_def_obj->segid = strm_def.seg_id;
-		strm_def_obj->align = strm_def.buf_alignment;
-		strm_def_obj->timeout = strm_def.timeout;
-	}
-
-	if (!status) {
-		/*
-		 *  Since we haven't added the device name yet, subtract
-		 *  1 from total.
-		 */
-		total += sizeof(struct rms_strm_def) / sizeof(rms_word) - 1;
-		dw_length = strlen(strm_def.sz_device) + 1;
-
-		/* Number of RMS_WORDS needed to hold device name */
-		name_len =
-		    (dw_length + chars_in_rms_word - 1) / chars_in_rms_word;
-
-		if (total + name_len >= max) {
-			status = -EPERM;
-		} else {
-			/*
-			 *  Zero out last word, since the device name may not
-			 *  extend to completely fill this word.
-			 */
-			pdw_buf[total + name_len - 1] = 0;
-			/** TODO USE SERVICES * */
-			memcpy(pdw_buf + total, strm_def.sz_device, dw_length);
-			total += name_len;
-			*ptotal = total;
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== send_message ======
- *  Send command message to RMS, get reply from RMS.
- */
-static int send_message(struct disp_object *disp_obj, u32 timeout,
-			       u32 ul_bytes, u32 *pdw_arg)
-{
-	struct bridge_drv_interface *intf_fxns;
-	struct chnl_object *chnl_obj;
-	u32 dw_arg = 0;
-	u8 *pbuf;
-	struct chnl_ioc chnl_ioc_obj;
-	int status = 0;
-
-	*pdw_arg = (u32) NULL;
-	intf_fxns = disp_obj->intf_fxns;
-	chnl_obj = disp_obj->chnl_to_dsp;
-	pbuf = disp_obj->buf;
-
-	/* Send the command */
-	status = (*intf_fxns->chnl_add_io_req) (chnl_obj, pbuf, ul_bytes, 0,
-						    0L, dw_arg);
-	if (status)
-		goto func_end;
-
-	status =
-	    (*intf_fxns->chnl_get_ioc) (chnl_obj, timeout, &chnl_ioc_obj);
-	if (!status) {
-		if (!CHNL_IS_IO_COMPLETE(chnl_ioc_obj)) {
-			if (CHNL_IS_TIMED_OUT(chnl_ioc_obj))
-				status = -ETIME;
-			else
-				status = -EPERM;
-		}
-	}
-	/* Get the reply */
-	if (status)
-		goto func_end;
-
-	chnl_obj = disp_obj->chnl_from_dsp;
-	ul_bytes = REPLYSIZE;
-	status = (*intf_fxns->chnl_add_io_req) (chnl_obj, pbuf, ul_bytes,
-						    0, 0L, dw_arg);
-	if (status)
-		goto func_end;
-
-	status =
-	    (*intf_fxns->chnl_get_ioc) (chnl_obj, timeout, &chnl_ioc_obj);
-	if (!status) {
-		if (CHNL_IS_TIMED_OUT(chnl_ioc_obj)) {
-			status = -ETIME;
-		} else if (chnl_ioc_obj.byte_size < ul_bytes) {
-			/* Did not get all of the reply from the RMS */
-			status = -EPERM;
-		} else {
-			if (CHNL_IS_IO_COMPLETE(chnl_ioc_obj)) {
-				if (*((int *)chnl_ioc_obj.buf) < 0) {
-					/* Translate DSP's to kernel error */
-					status = -EREMOTEIO;
-					dev_dbg(bridge, "%s: DSP-side failed:"
-						" DSP errcode = 0x%x, Kernel "
-						"errcode = %d\n", __func__,
-						*(int *)pbuf, status);
-				}
-				*pdw_arg =
-				    (((rms_word *) (chnl_ioc_obj.buf))[1]);
-			} else {
-				status = -EPERM;
-			}
-		}
-	}
-func_end:
-	return status;
-}
diff --git a/drivers/staging/tidspbridge/rmgr/drv.c b/drivers/staging/tidspbridge/rmgr/drv.c
deleted file mode 100644
index 757ae20..0000000
--- a/drivers/staging/tidspbridge/rmgr/drv.c
+++ /dev/null
@@ -1,816 +0,0 @@
-/*
- * drv.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP/BIOS Bridge resource allocation module.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-#include <linux/types.h>
-#include <linux/list.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/drv.h>
-#include <dspbridge/dev.h>
-
-#include <dspbridge/node.h>
-#include <dspbridge/proc.h>
-#include <dspbridge/strm.h>
-#include <dspbridge/nodepriv.h>
-#include <dspbridge/dspchnl.h>
-#include <dspbridge/resourcecleanup.h>
-
-/*  ----------------------------------- Defines, Data Structures, Typedefs */
-struct drv_object {
-	struct list_head dev_list;
-	struct list_head dev_node_string;
-};
-
-/*
- *  This is the Device Extension. Named with the Prefix
- *  DRV_ since it is living in this module
- */
-struct drv_ext {
-	struct list_head link;
-	char sz_string[MAXREGPATHLENGTH];
-};
-
-/*  ----------------------------------- Globals */
-static bool ext_phys_mem_pool_enabled;
-struct ext_phys_mem_pool {
-	u32 phys_mem_base;
-	u32 phys_mem_size;
-	u32 virt_mem_base;
-	u32 next_phys_alloc_ptr;
-};
-static struct ext_phys_mem_pool ext_mem_pool;
-
-/*  ----------------------------------- Function Prototypes */
-static int request_bridge_resources(struct cfg_hostres *res);
-
-
-/* GPP PROCESS CLEANUP CODE */
-
-static int drv_proc_free_node_res(int id, void *p, void *data);
-
-/* Allocate and add a node resource element
-* This function is called from .Node_Allocate. */
-int drv_insert_node_res_element(void *hnode, void *node_resource,
-				       void *process_ctxt)
-{
-	struct node_res_object **node_res_obj =
-	    (struct node_res_object **)node_resource;
-	struct process_context *ctxt = (struct process_context *)process_ctxt;
-	int retval;
-
-	*node_res_obj = kzalloc(sizeof(struct node_res_object), GFP_KERNEL);
-	if (!*node_res_obj)
-		return -ENOMEM;
-
-	(*node_res_obj)->node = hnode;
-	retval = idr_alloc(ctxt->node_id, *node_res_obj, 0, 0, GFP_KERNEL);
-	if (retval >= 0) {
-		(*node_res_obj)->id = retval;
-		return 0;
-	}
-
-	kfree(*node_res_obj);
-
-	if (retval == -ENOSPC) {
-		pr_err("%s: FAILED, IDR is FULL\n", __func__);
-		return -EFAULT;
-	} else {
-		pr_err("%s: OUT OF MEMORY\n", __func__);
-		return -ENOMEM;
-	}
-}
-
-/* Release all Node resources and its context
- * Actual Node De-Allocation */
-static int drv_proc_free_node_res(int id, void *p, void *data)
-{
-	struct process_context *ctxt = data;
-	int status;
-	struct node_res_object *node_res_obj = p;
-	u32 node_state;
-
-	if (node_res_obj->node_allocated) {
-		node_state = node_get_state(node_res_obj->node);
-		if (node_state <= NODE_DELETING) {
-			if ((node_state == NODE_RUNNING) ||
-			    (node_state == NODE_PAUSED) ||
-			    (node_state == NODE_TERMINATING))
-				node_terminate
-				    (node_res_obj->node, &status);
-
-			node_delete(node_res_obj, ctxt);
-		}
-	}
-
-	return 0;
-}
-
-/* Release all Mapped and Reserved DMM resources */
-int drv_remove_all_dmm_res_elements(void *process_ctxt)
-{
-	struct process_context *ctxt = (struct process_context *)process_ctxt;
-	int status = 0;
-	struct dmm_map_object *temp_map, *map_obj;
-	struct dmm_rsv_object *temp_rsv, *rsv_obj;
-
-	/* Free DMM mapped memory resources */
-	list_for_each_entry_safe(map_obj, temp_map, &ctxt->dmm_map_list, link) {
-		status = proc_un_map(ctxt->processor,
-				     (void *)map_obj->dsp_addr, ctxt);
-		if (status)
-			pr_err("%s: proc_un_map failed!"
-			       " status = 0x%xn", __func__, status);
-	}
-
-	/* Free DMM reserved memory resources */
-	list_for_each_entry_safe(rsv_obj, temp_rsv, &ctxt->dmm_rsv_list, link) {
-		status = proc_un_reserve_memory(ctxt->processor, (void *)
-						rsv_obj->dsp_reserved_addr,
-						ctxt);
-		if (status)
-			pr_err("%s: proc_un_reserve_memory failed!"
-			       " status = 0x%xn", __func__, status);
-	}
-	return status;
-}
-
-/* Update Node allocation status */
-void drv_proc_node_update_status(void *node_resource, s32 status)
-{
-	struct node_res_object *node_res_obj =
-	    (struct node_res_object *)node_resource;
-	node_res_obj->node_allocated = status;
-}
-
-/* Update Node Heap status */
-void drv_proc_node_update_heap_status(void *node_resource, s32 status)
-{
-	struct node_res_object *node_res_obj =
-	    (struct node_res_object *)node_resource;
-	node_res_obj->heap_allocated = status;
-}
-
-/* Release all Node resources and its context
-* This is called from .bridge_release.
- */
-int drv_remove_all_node_res_elements(void *process_ctxt)
-{
-	struct process_context *ctxt = process_ctxt;
-
-	idr_for_each(ctxt->node_id, drv_proc_free_node_res, ctxt);
-	idr_destroy(ctxt->node_id);
-
-	return 0;
-}
-
-/* Allocate the STRM resource element
-* This is called after the actual resource is allocated
- */
-int drv_proc_insert_strm_res_element(void *stream_obj,
-					    void *strm_res, void *process_ctxt)
-{
-	struct strm_res_object **pstrm_res =
-	    (struct strm_res_object **)strm_res;
-	struct process_context *ctxt = (struct process_context *)process_ctxt;
-	int retval;
-
-	*pstrm_res = kzalloc(sizeof(struct strm_res_object), GFP_KERNEL);
-	if (*pstrm_res == NULL)
-		return -EFAULT;
-
-	(*pstrm_res)->stream = stream_obj;
-	retval = idr_alloc(ctxt->stream_id, *pstrm_res, 0, 0, GFP_KERNEL);
-	if (retval >= 0) {
-		(*pstrm_res)->id = retval;
-		return 0;
-	}
-
-	if (retval == -ENOSPC) {
-		pr_err("%s: FAILED, IDR is FULL\n", __func__);
-		return -EPERM;
-	} else {
-		pr_err("%s: OUT OF MEMORY\n", __func__);
-		return -ENOMEM;
-	}
-}
-
-static int drv_proc_free_strm_res(int id, void *p, void *process_ctxt)
-{
-	struct process_context *ctxt = process_ctxt;
-	struct strm_res_object *strm_res = p;
-	struct stream_info strm_info;
-	struct dsp_streaminfo user;
-	u8 **ap_buffer = NULL;
-	u8 *buf_ptr;
-	u32 ul_bytes;
-	u32 dw_arg;
-	s32 ul_buf_size;
-
-	if (strm_res->num_bufs) {
-		ap_buffer = kmalloc((strm_res->num_bufs *
-				       sizeof(u8 *)), GFP_KERNEL);
-		if (ap_buffer) {
-			strm_free_buffer(strm_res,
-						  ap_buffer,
-						  strm_res->num_bufs,
-						  ctxt);
-			kfree(ap_buffer);
-		}
-	}
-	strm_info.user_strm = &user;
-	user.number_bufs_in_stream = 0;
-	strm_get_info(strm_res->stream, &strm_info, sizeof(strm_info));
-	while (user.number_bufs_in_stream--)
-		strm_reclaim(strm_res->stream, &buf_ptr, &ul_bytes,
-			     (u32 *) &ul_buf_size, &dw_arg);
-	strm_close(strm_res, ctxt);
-	return 0;
-}
-
-/* Release all Stream resources and its context
-* This is called from .bridge_release.
- */
-int drv_remove_all_strm_res_elements(void *process_ctxt)
-{
-	struct process_context *ctxt = process_ctxt;
-
-	idr_for_each(ctxt->stream_id, drv_proc_free_strm_res, ctxt);
-	idr_destroy(ctxt->stream_id);
-
-	return 0;
-}
-
-/* Updating the stream resource element */
-int drv_proc_update_strm_res(u32 num_bufs, void *strm_resources)
-{
-	int status = 0;
-	struct strm_res_object **strm_res =
-	    (struct strm_res_object **)strm_resources;
-
-	(*strm_res)->num_bufs = num_bufs;
-	return status;
-}
-
-/* GPP PROCESS CLEANUP CODE END */
-
-/*
- *  ======== = drv_create ======== =
- *  Purpose:
- *      DRV Object gets created only once during Driver Loading.
- */
-int drv_create(struct drv_object **drv_obj)
-{
-	int status = 0;
-	struct drv_object *pdrv_object = NULL;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	pdrv_object = kzalloc(sizeof(struct drv_object), GFP_KERNEL);
-	if (pdrv_object) {
-		/* Create and Initialize List of device objects */
-		INIT_LIST_HEAD(&pdrv_object->dev_list);
-		INIT_LIST_HEAD(&pdrv_object->dev_node_string);
-	} else {
-		status = -ENOMEM;
-	}
-	/* Store the DRV Object in the driver data */
-	if (!status) {
-		if (drv_datap) {
-			drv_datap->drv_object = (void *)pdrv_object;
-		} else {
-			status = -EPERM;
-			pr_err("%s: Failed to store DRV object\n", __func__);
-		}
-	}
-
-	if (!status) {
-		*drv_obj = pdrv_object;
-	} else {
-		/* Free the DRV Object */
-		kfree(pdrv_object);
-	}
-
-	return status;
-}
-
-/*
- *  ======== = drv_destroy ======== =
- *  purpose:
- *      Invoked during bridge de-initialization
- */
-int drv_destroy(struct drv_object *driver_obj)
-{
-	int status = 0;
-	struct drv_object *pdrv_object = (struct drv_object *)driver_obj;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	kfree(pdrv_object);
-	/* Update the DRV Object in the driver data */
-	if (drv_datap) {
-		drv_datap->drv_object = NULL;
-	} else {
-		status = -EPERM;
-		pr_err("%s: Failed to store DRV object\n", __func__);
-	}
-
-	return status;
-}
-
-/*
- *  ======== drv_get_dev_object ========
- *  Purpose:
- *      Given a index, returns a handle to DevObject from the list.
- */
-int drv_get_dev_object(u32 index, struct drv_object *hdrv_obj,
-			      struct dev_object **device_obj)
-{
-	int status = 0;
-	struct dev_object *dev_obj;
-	u32 i;
-
-	dev_obj = (struct dev_object *)drv_get_first_dev_object();
-	for (i = 0; i < index; i++) {
-		dev_obj =
-		    (struct dev_object *)drv_get_next_dev_object((u32) dev_obj);
-	}
-	if (dev_obj) {
-		*device_obj = (struct dev_object *)dev_obj;
-	} else {
-		*device_obj = NULL;
-		status = -EPERM;
-	}
-
-	return status;
-}
-
-/*
- *  ======== drv_get_first_dev_object ========
- *  Purpose:
- *      Retrieve the first Device Object handle from an internal linked list of
- *      of DEV_OBJECTs maintained by DRV.
- */
-u32 drv_get_first_dev_object(void)
-{
-	u32 dw_dev_object = 0;
-	struct drv_object *pdrv_obj;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	if (drv_datap && drv_datap->drv_object) {
-		pdrv_obj = drv_datap->drv_object;
-		if (!list_empty(&pdrv_obj->dev_list))
-			dw_dev_object = (u32) pdrv_obj->dev_list.next;
-	} else {
-		pr_err("%s: Failed to retrieve the object handle\n", __func__);
-	}
-
-	return dw_dev_object;
-}
-
-/*
- *  ======== DRV_GetFirstDevNodeString ========
- *  Purpose:
- *      Retrieve the first Device Extension from an internal linked list of
- *      of Pointer to dev_node Strings maintained by DRV.
- */
-u32 drv_get_first_dev_extension(void)
-{
-	u32 dw_dev_extension = 0;
-	struct drv_object *pdrv_obj;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	if (drv_datap && drv_datap->drv_object) {
-		pdrv_obj = drv_datap->drv_object;
-		if (!list_empty(&pdrv_obj->dev_node_string)) {
-			dw_dev_extension =
-			    (u32) pdrv_obj->dev_node_string.next;
-		}
-	} else {
-		pr_err("%s: Failed to retrieve the object handle\n", __func__);
-	}
-
-	return dw_dev_extension;
-}
-
-/*
- *  ======== drv_get_next_dev_object ========
- *  Purpose:
- *      Retrieve the next Device Object handle from an internal linked list of
- *      of DEV_OBJECTs maintained by DRV, after having previously called
- *      drv_get_first_dev_object() and zero or more DRV_GetNext.
- */
-u32 drv_get_next_dev_object(u32 hdev_obj)
-{
-	u32 dw_next_dev_object = 0;
-	struct drv_object *pdrv_obj;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-	struct list_head *curr;
-
-	if (drv_datap && drv_datap->drv_object) {
-		pdrv_obj = drv_datap->drv_object;
-		if (!list_empty(&pdrv_obj->dev_list)) {
-			curr = (struct list_head *)hdev_obj;
-			if (list_is_last(curr, &pdrv_obj->dev_list))
-				return 0;
-			dw_next_dev_object = (u32) curr->next;
-		}
-	} else {
-		pr_err("%s: Failed to retrieve the object handle\n", __func__);
-	}
-
-	return dw_next_dev_object;
-}
-
-/*
- *  ======== drv_get_next_dev_extension ========
- *  Purpose:
- *      Retrieve the next Device Extension from an internal linked list of
- *      of pointer to DevNodeString maintained by DRV, after having previously
- *      called drv_get_first_dev_extension() and zero or more
- *      drv_get_next_dev_extension().
- */
-u32 drv_get_next_dev_extension(u32 dev_extension)
-{
-	u32 dw_dev_extension = 0;
-	struct drv_object *pdrv_obj;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-	struct list_head *curr;
-
-	if (drv_datap && drv_datap->drv_object) {
-		pdrv_obj = drv_datap->drv_object;
-		if (!list_empty(&pdrv_obj->dev_node_string)) {
-			curr = (struct list_head *)dev_extension;
-			if (list_is_last(curr, &pdrv_obj->dev_node_string))
-				return 0;
-			dw_dev_extension = (u32) curr->next;
-		}
-	} else {
-		pr_err("%s: Failed to retrieve the object handle\n", __func__);
-	}
-
-	return dw_dev_extension;
-}
-
-/*
- *  ======== drv_insert_dev_object ========
- *  Purpose:
- *      Insert a DevObject into the list of Manager object.
- */
-int drv_insert_dev_object(struct drv_object *driver_obj,
-				 struct dev_object *hdev_obj)
-{
-	struct drv_object *pdrv_object = (struct drv_object *)driver_obj;
-
-	list_add_tail((struct list_head *)hdev_obj, &pdrv_object->dev_list);
-
-	return 0;
-}
-
-/*
- *  ======== drv_remove_dev_object ========
- *  Purpose:
- *      Search for and remove a DeviceObject from the given list of DRV
- *      objects.
- */
-int drv_remove_dev_object(struct drv_object *driver_obj,
-				 struct dev_object *hdev_obj)
-{
-	int status = -EPERM;
-	struct drv_object *pdrv_object = (struct drv_object *)driver_obj;
-	struct list_head *cur_elem;
-
-	/* Search list for p_proc_object: */
-	list_for_each(cur_elem, &pdrv_object->dev_list) {
-		/* If found, remove it. */
-		if ((struct dev_object *)cur_elem == hdev_obj) {
-			list_del(cur_elem);
-			status = 0;
-			break;
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== drv_request_resources ========
- *  Purpose:
- *      Requests  resources from the OS.
- */
-int drv_request_resources(u32 dw_context, u32 *dev_node_strg)
-{
-	int status = 0;
-	struct drv_object *pdrv_object;
-	struct drv_ext *pszdev_node;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	/*
-	 *  Allocate memory to hold the string. This will live until
-	 *  it is freed in the Release resources. Update the driver object
-	 *  list.
-	 */
-
-	if (!drv_datap || !drv_datap->drv_object)
-		status = -ENODATA;
-	else
-		pdrv_object = drv_datap->drv_object;
-
-	if (!status) {
-		pszdev_node = kzalloc(sizeof(struct drv_ext), GFP_KERNEL);
-		if (pszdev_node) {
-			strncpy(pszdev_node->sz_string,
-				(char *)dw_context, MAXREGPATHLENGTH - 1);
-			pszdev_node->sz_string[MAXREGPATHLENGTH - 1] = '\0';
-			/* Update the Driver Object List */
-			*dev_node_strg = (u32) pszdev_node->sz_string;
-			list_add_tail(&pszdev_node->link,
-					&pdrv_object->dev_node_string);
-		} else {
-			status = -ENOMEM;
-			*dev_node_strg = 0;
-		}
-	} else {
-		dev_dbg(bridge, "%s: Failed to get Driver Object from Registry",
-			__func__);
-		*dev_node_strg = 0;
-	}
-
-	return status;
-}
-
-/*
- *  ======== drv_release_resources ========
- *  Purpose:
- *      Releases  resources from the OS.
- */
-int drv_release_resources(u32 dw_context, struct drv_object *hdrv_obj)
-{
-	int status = 0;
-	struct drv_ext *pszdev_node;
-
-	/*
-	 *  Irrespective of the status go ahead and clean it
-	 *  The following will over write the status.
-	 */
-	for (pszdev_node = (struct drv_ext *)drv_get_first_dev_extension();
-	     pszdev_node != NULL; pszdev_node = (struct drv_ext *)
-	     drv_get_next_dev_extension((u32) pszdev_node)) {
-		if ((u32) pszdev_node == dw_context) {
-			/* Found it */
-			/* Delete from the Driver object list */
-			list_del(&pszdev_node->link);
-			kfree(pszdev_node);
-			break;
-		}
-	}
-	return status;
-}
-
-/*
- *  ======== request_bridge_resources ========
- *  Purpose:
- *      Reserves shared memory for bridge.
- */
-static int request_bridge_resources(struct cfg_hostres *res)
-{
-	struct cfg_hostres *host_res = res;
-
-	/* num_mem_windows must not be more than CFG_MAXMEMREGISTERS */
-	host_res->num_mem_windows = 2;
-
-	/* First window is for DSP internal memory */
-	dev_dbg(bridge, "mem_base[0] 0x%x\n", host_res->mem_base[0]);
-	dev_dbg(bridge, "mem_base[3] 0x%x\n", host_res->mem_base[3]);
-	dev_dbg(bridge, "dmmu_base %p\n", host_res->dmmu_base);
-
-	/* for 24xx base port is not mapping the mamory for DSP
-	 * internal memory TODO Do a ioremap here */
-	/* Second window is for DSP external memory shared with MPU */
-
-	/* These are hard-coded values */
-	host_res->birq_registers = 0;
-	host_res->birq_attrib = 0;
-	host_res->offset_for_monitor = 0;
-	host_res->chnl_offset = 0;
-	/* CHNL_MAXCHANNELS */
-	host_res->num_chnls = CHNL_MAXCHANNELS;
-	host_res->chnl_buf_size = 0x400;
-
-	return 0;
-}
-
-/*
- *  ======== drv_request_bridge_res_dsp ========
- *  Purpose:
- *      Reserves shared memory for bridge.
- */
-int drv_request_bridge_res_dsp(void **phost_resources)
-{
-	int status = 0;
-	struct cfg_hostres *host_res;
-	u32 dw_buff_size;
-	u32 dma_addr;
-	u32 shm_size;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	dw_buff_size = sizeof(struct cfg_hostres);
-
-	host_res = kzalloc(dw_buff_size, GFP_KERNEL);
-
-	if (host_res != NULL) {
-		request_bridge_resources(host_res);
-		/* num_mem_windows must not be more than CFG_MAXMEMREGISTERS */
-		host_res->num_mem_windows = 4;
-
-		host_res->mem_base[0] = 0;
-		host_res->mem_base[2] = (u32) ioremap(OMAP_DSP_MEM1_BASE,
-							 OMAP_DSP_MEM1_SIZE);
-		host_res->mem_base[3] = (u32) ioremap(OMAP_DSP_MEM2_BASE,
-							 OMAP_DSP_MEM2_SIZE);
-		host_res->mem_base[4] = (u32) ioremap(OMAP_DSP_MEM3_BASE,
-							 OMAP_DSP_MEM3_SIZE);
-		host_res->per_base = ioremap(OMAP_PER_CM_BASE,
-						OMAP_PER_CM_SIZE);
-		host_res->per_pm_base = ioremap(OMAP_PER_PRM_BASE,
-						OMAP_PER_PRM_SIZE);
-		host_res->core_pm_base = ioremap(OMAP_CORE_PRM_BASE,
-							OMAP_CORE_PRM_SIZE);
-		host_res->dmmu_base = ioremap(OMAP_DMMU_BASE,
-						 OMAP_DMMU_SIZE);
-
-		dev_dbg(bridge, "mem_base[0] 0x%x\n",
-			host_res->mem_base[0]);
-		dev_dbg(bridge, "mem_base[1] 0x%x\n",
-			host_res->mem_base[1]);
-		dev_dbg(bridge, "mem_base[2] 0x%x\n",
-			host_res->mem_base[2]);
-		dev_dbg(bridge, "mem_base[3] 0x%x\n",
-			host_res->mem_base[3]);
-		dev_dbg(bridge, "mem_base[4] 0x%x\n",
-			host_res->mem_base[4]);
-		dev_dbg(bridge, "dmmu_base %p\n", host_res->dmmu_base);
-
-		shm_size = drv_datap->shm_size;
-		if (shm_size >= 0x10000) {
-			/* Allocate Physically contiguous,
-			 * non-cacheable  memory */
-			host_res->mem_base[1] =
-			    (u32) mem_alloc_phys_mem(shm_size, 0x100000,
-						     &dma_addr);
-			if (host_res->mem_base[1] == 0) {
-				status = -ENOMEM;
-				pr_err("shm reservation Failed\n");
-			} else {
-				host_res->mem_length[1] = shm_size;
-				host_res->mem_phys[1] = dma_addr;
-
-				dev_dbg(bridge, "%s: Bridge shm address 0x%x "
-					"dma_addr %x size %x\n", __func__,
-					host_res->mem_base[1],
-					dma_addr, shm_size);
-			}
-		}
-		if (!status) {
-			/* These are hard-coded values */
-			host_res->birq_registers = 0;
-			host_res->birq_attrib = 0;
-			host_res->offset_for_monitor = 0;
-			host_res->chnl_offset = 0;
-			/* CHNL_MAXCHANNELS */
-			host_res->num_chnls = CHNL_MAXCHANNELS;
-			host_res->chnl_buf_size = 0x400;
-			dw_buff_size = sizeof(struct cfg_hostres);
-		}
-		*phost_resources = host_res;
-	}
-	/* End Mem alloc */
-	return status;
-}
-
-void mem_ext_phys_pool_init(u32 pool_phys_base, u32 pool_size)
-{
-	u32 pool_virt_base;
-
-	/* get the virtual address for the physical memory pool passed */
-	pool_virt_base = (u32) ioremap(pool_phys_base, pool_size);
-
-	if ((void **)pool_virt_base == NULL) {
-		pr_err("%s: external physical memory map failed\n", __func__);
-		ext_phys_mem_pool_enabled = false;
-	} else {
-		ext_mem_pool.phys_mem_base = pool_phys_base;
-		ext_mem_pool.phys_mem_size = pool_size;
-		ext_mem_pool.virt_mem_base = pool_virt_base;
-		ext_mem_pool.next_phys_alloc_ptr = pool_phys_base;
-		ext_phys_mem_pool_enabled = true;
-	}
-}
-
-void mem_ext_phys_pool_release(void)
-{
-	if (ext_phys_mem_pool_enabled) {
-		iounmap((void *)(ext_mem_pool.virt_mem_base));
-		ext_phys_mem_pool_enabled = false;
-	}
-}
-
-/*
- *  ======== mem_ext_phys_mem_alloc ========
- *  Purpose:
- *     Allocate physically contiguous, uncached memory from external memory pool
- */
-
-static void *mem_ext_phys_mem_alloc(u32 bytes, u32 align, u32 *phys_addr)
-{
-	u32 new_alloc_ptr;
-	u32 offset;
-	u32 virt_addr;
-
-	if (align == 0)
-		align = 1;
-
-	if (bytes > ((ext_mem_pool.phys_mem_base + ext_mem_pool.phys_mem_size)
-		     - ext_mem_pool.next_phys_alloc_ptr)) {
-		phys_addr = NULL;
-		return NULL;
-	} else {
-		offset = (ext_mem_pool.next_phys_alloc_ptr & (align - 1));
-		if (offset == 0)
-			new_alloc_ptr = ext_mem_pool.next_phys_alloc_ptr;
-		else
-			new_alloc_ptr = (ext_mem_pool.next_phys_alloc_ptr) +
-			    (align - offset);
-		if ((new_alloc_ptr + bytes) <=
-		    (ext_mem_pool.phys_mem_base + ext_mem_pool.phys_mem_size)) {
-			/* we can allocate */
-			*phys_addr = new_alloc_ptr;
-			ext_mem_pool.next_phys_alloc_ptr =
-			    new_alloc_ptr + bytes;
-			virt_addr =
-			    ext_mem_pool.virt_mem_base + (new_alloc_ptr -
-							  ext_mem_pool.
-							  phys_mem_base);
-			return (void *)virt_addr;
-		} else {
-			*phys_addr = 0;
-			return NULL;
-		}
-	}
-}
-
-/*
- *  ======== mem_alloc_phys_mem ========
- *  Purpose:
- *      Allocate physically contiguous, uncached memory
- */
-void *mem_alloc_phys_mem(u32 byte_size, u32 align_mask,
-				u32 *physical_address)
-{
-	void *va_mem = NULL;
-	dma_addr_t pa_mem;
-
-	if (byte_size > 0) {
-		if (ext_phys_mem_pool_enabled) {
-			va_mem = mem_ext_phys_mem_alloc(byte_size, align_mask,
-							(u32 *) &pa_mem);
-		} else
-			va_mem = dma_alloc_coherent(NULL, byte_size, &pa_mem,
-								GFP_KERNEL);
-		if (va_mem == NULL)
-			*physical_address = 0;
-		else
-			*physical_address = pa_mem;
-	}
-	return va_mem;
-}
-
-/*
- *  ======== mem_free_phys_mem ========
- *  Purpose:
- *      Free the given block of physically contiguous memory.
- */
-void mem_free_phys_mem(void *virtual_address, u32 physical_address,
-		       u32 byte_size)
-{
-	if (!ext_phys_mem_pool_enabled)
-		dma_free_coherent(NULL, byte_size, virtual_address,
-				  physical_address);
-}
diff --git a/drivers/staging/tidspbridge/rmgr/drv_interface.c b/drivers/staging/tidspbridge/rmgr/drv_interface.c
deleted file mode 100644
index e3918d2..0000000
--- a/drivers/staging/tidspbridge/rmgr/drv_interface.c
+++ /dev/null
@@ -1,650 +0,0 @@
-/*
- * drv_interface.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP/BIOS Bridge driver interface.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/platform_data/dsp-omap.h>
-
-#include <linux/types.h>
-#include <linux/platform_device.h>
-#include <linux/pm.h>
-#include <linux/module.h>
-#include <linux/device.h>
-#include <linux/moduleparam.h>
-#include <linux/cdev.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/clk.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/dspapi.h>
-#include <dspbridge/dspdrv.h>
-
-/*  ----------------------------------- Resource Manager */
-#include <dspbridge/pwr.h>
-
-#include <dspbridge/resourcecleanup.h>
-#include <dspbridge/proc.h>
-#include <dspbridge/dev.h>
-
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-#include <mach-omap2/omap3-opp.h>
-#endif
-
-/*  ----------------------------------- Globals */
-#define DSPBRIDGE_VERSION	"0.3"
-s32 dsp_debug;
-
-struct platform_device *omap_dspbridge_dev;
-struct device *bridge;
-
-/* This is a test variable used by Bridge to test different sleep states */
-s32 dsp_test_sleepstate;
-
-static struct cdev bridge_cdev;
-
-static struct class *bridge_class;
-
-static u32 driver_context;
-static s32 driver_major;
-static char *base_img;
-static s32 shm_size = 0x500000;	/* 5 MB */
-static int tc_wordswapon;	/* Default value is always false */
-#ifdef CONFIG_TIDSPBRIDGE_RECOVERY
-#define REC_TIMEOUT 5000	/*recovery timeout in msecs */
-static atomic_t bridge_cref;	/* number of bridge open handles */
-static struct workqueue_struct *bridge_rec_queue;
-static struct work_struct bridge_recovery_work;
-static DECLARE_COMPLETION(bridge_comp);
-static DECLARE_COMPLETION(bridge_open_comp);
-static bool recover;
-#endif
-
-#ifdef CONFIG_PM
-struct omap34_xx_bridge_suspend_data {
-	int suspended;
-	wait_queue_head_t suspend_wq;
-};
-
-static struct omap34_xx_bridge_suspend_data bridge_suspend_data;
-
-static int omap34_xxbridge_suspend_lockout(struct omap34_xx_bridge_suspend_data
-					   *s, struct file *f)
-{
-	if ((s)->suspended) {
-		if ((f)->f_flags & O_NONBLOCK)
-			return -EPERM;
-		wait_event_interruptible((s)->suspend_wq, (s)->suspended == 0);
-	}
-	return 0;
-}
-#endif
-
-module_param(dsp_debug, int, 0);
-MODULE_PARM_DESC(dsp_debug, "Wait after loading DSP image. default = false");
-
-module_param(dsp_test_sleepstate, int, 0);
-MODULE_PARM_DESC(dsp_test_sleepstate, "DSP Sleep state = 0");
-
-module_param(base_img, charp, 0);
-MODULE_PARM_DESC(base_img, "DSP base image, default = NULL");
-
-module_param(shm_size, int, 0);
-MODULE_PARM_DESC(shm_size, "shm size, default = 4 MB, minimum = 64 KB");
-
-module_param(tc_wordswapon, int, 0);
-MODULE_PARM_DESC(tc_wordswapon, "TC Word Swap Option. default = 0");
-
-MODULE_AUTHOR("Texas Instruments");
-MODULE_LICENSE("GPL");
-MODULE_VERSION(DSPBRIDGE_VERSION);
-
-/*
- * This function is called when an application opens handle to the
- * bridge driver.
- */
-static int bridge_open(struct inode *ip, struct file *filp)
-{
-	int status = 0;
-	struct process_context *pr_ctxt = NULL;
-
-	/*
-	 * Allocate a new process context and insert it into global
-	 * process context list.
-	 */
-
-#ifdef CONFIG_TIDSPBRIDGE_RECOVERY
-	if (recover) {
-		if (filp->f_flags & O_NONBLOCK ||
-		    wait_for_completion_interruptible(&bridge_open_comp))
-			return -EBUSY;
-	}
-#endif
-	pr_ctxt = kzalloc(sizeof(struct process_context), GFP_KERNEL);
-	if (!pr_ctxt)
-		return -ENOMEM;
-
-	pr_ctxt->res_state = PROC_RES_ALLOCATED;
-	spin_lock_init(&pr_ctxt->dmm_map_lock);
-	INIT_LIST_HEAD(&pr_ctxt->dmm_map_list);
-	spin_lock_init(&pr_ctxt->dmm_rsv_lock);
-	INIT_LIST_HEAD(&pr_ctxt->dmm_rsv_list);
-
-	pr_ctxt->node_id = kzalloc(sizeof(struct idr), GFP_KERNEL);
-	if (!pr_ctxt->node_id) {
-		status = -ENOMEM;
-		goto err1;
-	}
-
-	idr_init(pr_ctxt->node_id);
-
-	pr_ctxt->stream_id = kzalloc(sizeof(struct idr), GFP_KERNEL);
-	if (!pr_ctxt->stream_id) {
-		status = -ENOMEM;
-		goto err2;
-	}
-
-	idr_init(pr_ctxt->stream_id);
-
-	filp->private_data = pr_ctxt;
-
-#ifdef CONFIG_TIDSPBRIDGE_RECOVERY
-	atomic_inc(&bridge_cref);
-#endif
-	return 0;
-
-err2:
-	kfree(pr_ctxt->node_id);
-err1:
-	kfree(pr_ctxt);
-	return status;
-}
-
-/*
- * This function is called when an application closes handle to the bridge
- * driver.
- */
-static int bridge_release(struct inode *ip, struct file *filp)
-{
-	int status = 0;
-	struct process_context *pr_ctxt;
-
-	if (!filp->private_data) {
-		status = -EIO;
-		goto err;
-	}
-
-	pr_ctxt = filp->private_data;
-	flush_signals(current);
-	drv_remove_all_resources(pr_ctxt);
-	proc_detach(pr_ctxt);
-	kfree(pr_ctxt->node_id);
-	kfree(pr_ctxt->stream_id);
-	kfree(pr_ctxt);
-
-	filp->private_data = NULL;
-
-err:
-#ifdef CONFIG_TIDSPBRIDGE_RECOVERY
-	if (!atomic_dec_return(&bridge_cref))
-		complete(&bridge_comp);
-#endif
-	return status;
-}
-
-/* This function provides IO interface to the bridge driver. */
-static long bridge_ioctl(struct file *filp, unsigned int code,
-			 unsigned long args)
-{
-	int status;
-	u32 retval = 0;
-	union trapped_args buf_in;
-
-#ifdef CONFIG_TIDSPBRIDGE_RECOVERY
-	if (recover) {
-		status = -EIO;
-		goto err;
-	}
-#endif
-#ifdef CONFIG_PM
-	status = omap34_xxbridge_suspend_lockout(&bridge_suspend_data, filp);
-	if (status != 0)
-		return status;
-#endif
-
-	if (!filp->private_data) {
-		status = -EIO;
-		goto err;
-	}
-
-	status = copy_from_user(&buf_in, (union trapped_args *)args,
-				sizeof(union trapped_args));
-
-	if (!status) {
-		status = api_call_dev_ioctl(code, &buf_in, &retval,
-					    filp->private_data);
-
-		if (!status) {
-			status = retval;
-		} else {
-			dev_dbg(bridge, "%s: IOCTL Failed, code: 0x%x "
-				"status 0x%x\n", __func__, code, status);
-			status = -1;
-		}
-
-	}
-
-err:
-	return status;
-}
-
-/* This function maps kernel space memory to user space memory. */
-static int bridge_mmap(struct file *filp, struct vm_area_struct *vma)
-{
-	unsigned long base_pgoff;
-	int status;
-	struct omap_dsp_platform_data *pdata =
-					omap_dspbridge_dev->dev.platform_data;
-
-	/* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */
-	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-
-	dev_dbg(bridge, "%s: vm filp %p start %lx end %lx page_prot %ulx "
-		"flags %lx\n", __func__, filp,
-		vma->vm_start, vma->vm_end, vma->vm_page_prot,
-		vma->vm_flags);
-
-	/*
-	 * vm_iomap_memory() expects vma->vm_pgoff to be expressed as an offset
-	 * from the start of the physical memory pool, but we're called with
-	 * a pfn (physical page number) stored there instead.
-	 *
-	 * To avoid duplicating lots of tricky overflow checking logic,
-	 * temporarily convert vma->vm_pgoff to the offset vm_iomap_memory()
-	 * expects, but restore the original value once the mapping has been
-	 * created.
-	 */
-	base_pgoff = pdata->phys_mempool_base >> PAGE_SHIFT;
-
-	if (vma->vm_pgoff < base_pgoff)
-		return -EINVAL;
-
-	vma->vm_pgoff -= base_pgoff;
-
-	status = vm_iomap_memory(vma,
-				 pdata->phys_mempool_base,
-				 pdata->phys_mempool_size);
-
-	/* Restore the original value of vma->vm_pgoff */
-	vma->vm_pgoff += base_pgoff;
-
-	return status;
-}
-
-static const struct file_operations bridge_fops = {
-	.open = bridge_open,
-	.release = bridge_release,
-	.unlocked_ioctl = bridge_ioctl,
-	.mmap = bridge_mmap,
-	.llseek = noop_llseek,
-};
-
-#ifdef CONFIG_PM
-static u32 time_out = 1000;
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-s32 dsp_max_opps = VDD1_OPP5;
-#endif
-
-/* Maximum Opps that can be requested by IVA */
-/*vdd1 rate table */
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-const struct omap_opp vdd1_rate_table_bridge[] = {
-	{0, 0, 0},
-	/*OPP1 */
-	{S125M, VDD1_OPP1, 0},
-	/*OPP2 */
-	{S250M, VDD1_OPP2, 0},
-	/*OPP3 */
-	{S500M, VDD1_OPP3, 0},
-	/*OPP4 */
-	{S550M, VDD1_OPP4, 0},
-	/*OPP5 */
-	{S600M, VDD1_OPP5, 0},
-};
-#endif
-#endif
-
-struct omap_dsp_platform_data *omap_dspbridge_pdata;
-
-u32 vdd1_dsp_freq[6][4] = {
-	{0, 0, 0, 0},
-	/*OPP1 */
-	{0, 90000, 0, 86000},
-	/*OPP2 */
-	{0, 180000, 80000, 170000},
-	/*OPP3 */
-	{0, 360000, 160000, 340000},
-	/*OPP4 */
-	{0, 396000, 325000, 376000},
-	/*OPP5 */
-	{0, 430000, 355000, 430000},
-};
-
-#ifdef CONFIG_TIDSPBRIDGE_RECOVERY
-static void bridge_recover(struct work_struct *work)
-{
-	struct dev_object *dev;
-	struct cfg_devnode *dev_node;
-
-	if (atomic_read(&bridge_cref)) {
-		reinit_completion(&bridge_comp);
-		while (!wait_for_completion_timeout(&bridge_comp,
-						msecs_to_jiffies(REC_TIMEOUT)))
-			pr_info("%s:%d handle(s) still opened\n",
-					__func__, atomic_read(&bridge_cref));
-	}
-	dev = dev_get_first();
-	dev_get_dev_node(dev, &dev_node);
-	if (!dev_node || proc_auto_start(dev_node, dev))
-		pr_err("DSP could not be restarted\n");
-	recover = false;
-	complete_all(&bridge_open_comp);
-}
-
-void bridge_recover_schedule(void)
-{
-	reinit_completion(&bridge_open_comp);
-	recover = true;
-	queue_work(bridge_rec_queue, &bridge_recovery_work);
-}
-#endif
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-static int dspbridge_scale_notification(struct notifier_block *op,
-					unsigned long val, void *ptr)
-{
-	struct omap_dsp_platform_data *pdata =
-	    omap_dspbridge_dev->dev.platform_data;
-
-	if (CPUFREQ_POSTCHANGE == val && pdata->dsp_get_opp)
-		pwr_pm_post_scale(PRCM_VDD1, pdata->dsp_get_opp());
-
-	return 0;
-}
-
-static struct notifier_block iva_clk_notifier = {
-	.notifier_call = dspbridge_scale_notification,
-	NULL,
-};
-#endif
-
-/**
- * omap3_bridge_startup() - perform low lever initializations
- * @pdev:      pointer to platform device
- *
- * Initializes recovery, PM and DVFS required data, before calling
- * clk and memory init routines.
- */
-static int omap3_bridge_startup(struct platform_device *pdev)
-{
-	struct omap_dsp_platform_data *pdata = pdev->dev.platform_data;
-	struct drv_data *drv_datap = NULL;
-	u32 phys_membase, phys_memsize;
-	int err;
-
-#ifdef CONFIG_TIDSPBRIDGE_RECOVERY
-	bridge_rec_queue = create_workqueue("bridge_rec_queue");
-	INIT_WORK(&bridge_recovery_work, bridge_recover);
-	reinit_completion(&bridge_comp);
-#endif
-
-#ifdef CONFIG_PM
-	/* Initialize the wait queue */
-	bridge_suspend_data.suspended = 0;
-	init_waitqueue_head(&bridge_suspend_data.suspend_wq);
-
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-	for (i = 0; i < 6; i++)
-		pdata->mpu_speed[i] = vdd1_rate_table_bridge[i].rate;
-
-	err = cpufreq_register_notifier(&iva_clk_notifier,
-					CPUFREQ_TRANSITION_NOTIFIER);
-	if (err)
-		pr_err("%s: clk_notifier_register failed for iva2_ck\n",
-								__func__);
-#endif
-#endif
-
-	dsp_clk_init();
-
-	drv_datap = kzalloc(sizeof(struct drv_data), GFP_KERNEL);
-	if (!drv_datap) {
-		err = -ENOMEM;
-		goto err1;
-	}
-
-	drv_datap->shm_size = shm_size;
-	drv_datap->tc_wordswapon = tc_wordswapon;
-
-	if (base_img) {
-		drv_datap->base_img = kstrdup(base_img, GFP_KERNEL);
-		if (!drv_datap->base_img) {
-			err = -ENOMEM;
-			goto err2;
-		}
-	}
-
-	dev_set_drvdata(bridge, drv_datap);
-
-	if (shm_size < 0x10000) {	/* 64 KB */
-		err = -EINVAL;
-		pr_err("%s: shm size must be at least 64 KB\n", __func__);
-		goto err3;
-	}
-	dev_dbg(bridge, "%s: requested shm_size = 0x%x\n", __func__, shm_size);
-
-	phys_membase = pdata->phys_mempool_base;
-	phys_memsize = pdata->phys_mempool_size;
-	if (phys_membase > 0 && phys_memsize > 0)
-		mem_ext_phys_pool_init(phys_membase, phys_memsize);
-
-	if (tc_wordswapon)
-		dev_dbg(bridge, "%s: TC Word Swap is enabled\n", __func__);
-
-	driver_context = dsp_init(&err);
-	if (err) {
-		pr_err("DSP Bridge driver initialization failed\n");
-		goto err4;
-	}
-
-	return 0;
-
-err4:
-	mem_ext_phys_pool_release();
-err3:
-	kfree(drv_datap->base_img);
-err2:
-	kfree(drv_datap);
-err1:
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-	cpufreq_unregister_notifier(&iva_clk_notifier,
-				    CPUFREQ_TRANSITION_NOTIFIER);
-#endif
-	dsp_clk_exit();
-
-	return err;
-}
-
-static int omap34_xx_bridge_probe(struct platform_device *pdev)
-{
-	int err;
-	dev_t dev = 0;
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-	int i = 0;
-#endif
-
-	omap_dspbridge_dev = pdev;
-
-	/* Global bridge device */
-	bridge = &omap_dspbridge_dev->dev;
-
-	/* Bridge low level initializations */
-	err = omap3_bridge_startup(pdev);
-	if (err)
-		goto err1;
-
-	/* use 2.6 device model */
-	err = alloc_chrdev_region(&dev, 0, 1, "DspBridge");
-	if (err) {
-		pr_err("%s: Can't get major %d\n", __func__, driver_major);
-		goto err1;
-	}
-
-	cdev_init(&bridge_cdev, &bridge_fops);
-	bridge_cdev.owner = THIS_MODULE;
-
-	err = cdev_add(&bridge_cdev, dev, 1);
-	if (err) {
-		pr_err("%s: Failed to add bridge device\n", __func__);
-		goto err2;
-	}
-
-	/* udev support */
-	bridge_class = class_create(THIS_MODULE, "ti_bridge");
-	if (IS_ERR(bridge_class)) {
-		pr_err("%s: Error creating bridge class\n", __func__);
-		err = PTR_ERR(bridge_class);
-		goto err3;
-	}
-
-	driver_major = MAJOR(dev);
-	device_create(bridge_class, NULL, MKDEV(driver_major, 0),
-		      NULL, "DspBridge");
-	pr_info("DSP Bridge driver loaded\n");
-
-	return 0;
-
-err3:
-	cdev_del(&bridge_cdev);
-err2:
-	unregister_chrdev_region(dev, 1);
-err1:
-	return err;
-}
-
-static int omap34_xx_bridge_remove(struct platform_device *pdev)
-{
-	dev_t devno;
-	int status = 0;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	/* Retrieve the Object handle from the driver data */
-	if (!drv_datap || !drv_datap->drv_object) {
-		status = -ENODATA;
-		pr_err("%s: Failed to retrieve the object handle\n", __func__);
-		goto func_cont;
-	}
-
-#ifdef CONFIG_TIDSPBRIDGE_DVFS
-	if (cpufreq_unregister_notifier(&iva_clk_notifier,
-					CPUFREQ_TRANSITION_NOTIFIER))
-		pr_err("%s: cpufreq_unregister_notifier failed for iva2_ck\n",
-		       __func__);
-#endif /* #ifdef CONFIG_TIDSPBRIDGE_DVFS */
-
-	if (driver_context) {
-		/* Put the DSP in reset state */
-		dsp_deinit(driver_context);
-		driver_context = 0;
-	}
-
-	kfree(drv_datap);
-	dev_set_drvdata(bridge, NULL);
-
-func_cont:
-	mem_ext_phys_pool_release();
-
-	dsp_clk_exit();
-
-	devno = MKDEV(driver_major, 0);
-	cdev_del(&bridge_cdev);
-	unregister_chrdev_region(devno, 1);
-	if (bridge_class) {
-		/* remove the device from sysfs */
-		device_destroy(bridge_class, MKDEV(driver_major, 0));
-		class_destroy(bridge_class);
-
-	}
-	return status;
-}
-
-#ifdef CONFIG_PM
-static int bridge_suspend(struct platform_device *pdev, pm_message_t state)
-{
-	u32 status;
-	u32 command = PWR_EMERGENCYDEEPSLEEP;
-
-	status = pwr_sleep_dsp(command, time_out);
-	if (status)
-		return -1;
-
-	bridge_suspend_data.suspended = 1;
-	return 0;
-}
-
-static int bridge_resume(struct platform_device *pdev)
-{
-	u32 status;
-
-	status = pwr_wake_dsp(time_out);
-	if (status)
-		return -1;
-
-	bridge_suspend_data.suspended = 0;
-	wake_up(&bridge_suspend_data.suspend_wq);
-	return 0;
-}
-#endif
-
-static struct platform_driver bridge_driver = {
-	.driver = {
-		   .name = "omap-dsp",
-		   },
-	.probe = omap34_xx_bridge_probe,
-	.remove = omap34_xx_bridge_remove,
-#ifdef CONFIG_PM
-	.suspend = bridge_suspend,
-	.resume = bridge_resume,
-#endif
-};
-
-/* To remove all process resources before removing the process from the
- * process context list */
-int drv_remove_all_resources(void *process_ctxt)
-{
-	int status = 0;
-	struct process_context *ctxt = (struct process_context *)process_ctxt;
-
-	drv_remove_all_strm_res_elements(ctxt);
-	drv_remove_all_node_res_elements(ctxt);
-	drv_remove_all_dmm_res_elements(ctxt);
-	ctxt->res_state = PROC_RES_FREED;
-	return status;
-}
-
-module_platform_driver(bridge_driver);
diff --git a/drivers/staging/tidspbridge/rmgr/dspdrv.c b/drivers/staging/tidspbridge/rmgr/dspdrv.c
deleted file mode 100644
index 012e4a3..0000000
--- a/drivers/staging/tidspbridge/rmgr/dspdrv.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * dspdrv.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Interface to allocate and free bridge resources.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*  ----------------------------------- Host OS */
-#include <linux/types.h>
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/drv.h>
-#include <dspbridge/dev.h>
-#include <dspbridge/dspapi.h>
-
-/*  ----------------------------------- Resource Manager */
-#include <dspbridge/mgr.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/dspdrv.h>
-
-/*
- *  ======== dsp_init ========
- *  Allocates bridge resources. Loads a base image onto DSP, if specified.
- */
-u32 dsp_init(u32 *init_status)
-{
-	char dev_node[MAXREGPATHLENGTH] = "TIOMAP1510";
-	int status = -EPERM;
-	struct drv_object *drv_obj = NULL;
-	u32 device_node;
-	u32 device_node_string;
-
-	if (!api_init())
-		goto func_cont;
-
-	status = drv_create(&drv_obj);
-	if (status) {
-		api_exit();
-		goto func_cont;
-	}
-
-	/* End drv_create */
-	/* Request Resources */
-	status = drv_request_resources((u32) &dev_node, &device_node_string);
-	if (!status) {
-		/* Attempt to Start the Device */
-		status = dev_start_device((struct cfg_devnode *)
-					  device_node_string);
-		if (status)
-			(void)drv_release_resources
-			    ((u32) device_node_string, drv_obj);
-	} else {
-		dev_dbg(bridge, "%s: drv_request_resources Failed\n", __func__);
-		status = -EPERM;
-	}
-
-	/* Unwind whatever was loaded */
-	if (status) {
-		/* irrespective of the status of dev_remove_device we continue
-		 * unloading. Get the Driver Object iterate through and remove.
-		 * Reset the status to E_FAIL to avoid going through
-		 * api_init_complete2. */
-		for (device_node = drv_get_first_dev_extension();
-		     device_node != 0;
-		     device_node = drv_get_next_dev_extension(device_node)) {
-			(void)dev_remove_device((struct cfg_devnode *)
-						device_node);
-			(void)drv_release_resources((u32) device_node, drv_obj);
-		}
-		/* Remove the Driver Object */
-		(void)drv_destroy(drv_obj);
-		drv_obj = NULL;
-		api_exit();
-		dev_dbg(bridge, "%s: Logical device failed init\n", __func__);
-	}			/* Unwinding the loaded drivers */
-func_cont:
-	/* Attempt to Start the Board */
-	if (!status) {
-		/* BRD_AutoStart could fail if the dsp executable is not the
-		 * correct one. We should not propagate that error
-		 * into the device loader. */
-		(void)api_init_complete2();
-	} else {
-		dev_dbg(bridge, "%s: Failed\n", __func__);
-	}			/* End api_init_complete2 */
-	*init_status = status;
-	/* Return the Driver Object */
-	return (u32) drv_obj;
-}
-
-/*
- *  ======== dsp_deinit ========
- *  Frees the resources allocated for bridge.
- */
-bool dsp_deinit(u32 device_context)
-{
-	bool ret = true;
-	u32 device_node;
-	struct mgr_object *mgr_obj = NULL;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	while ((device_node = drv_get_first_dev_extension()) != 0) {
-		(void)dev_remove_device((struct cfg_devnode *)device_node);
-
-		(void)drv_release_resources((u32) device_node,
-					(struct drv_object *)device_context);
-	}
-
-	(void)drv_destroy((struct drv_object *)device_context);
-
-	/* Get the Manager Object from driver data
-	 * MGR Destroy will unload the DCD dll */
-	if (drv_datap && drv_datap->mgr_object) {
-		mgr_obj = drv_datap->mgr_object;
-		(void)mgr_destroy(mgr_obj);
-	} else {
-		pr_err("%s: Failed to retrieve the object handle\n", __func__);
-	}
-
-	api_exit();
-
-	return ret;
-}
diff --git a/drivers/staging/tidspbridge/rmgr/mgr.c b/drivers/staging/tidspbridge/rmgr/mgr.c
deleted file mode 100644
index 93e6282..0000000
--- a/drivers/staging/tidspbridge/rmgr/mgr.c
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * mgr.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Implementation of Manager interface to the device object at the
- * driver level. This queries the NDB data base and retrieves the
- * data about Node and Processor.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/types.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/sync.h>
-
-/*  ----------------------------------- Others */
-#include <dspbridge/dbdcd.h>
-#include <dspbridge/drv.h>
-#include <dspbridge/dev.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/mgr.h>
-
-/*  ----------------------------------- Defines, Data Structures, Typedefs */
-#define ZLDLLNAME               ""
-
-struct mgr_object {
-	struct dcd_manager *dcd_mgr;	/* Proc/Node data manager */
-};
-
-/*  ----------------------------------- Globals */
-static u32 refs;
-
-/*
- *  ========= mgr_create =========
- *  Purpose:
- *      MGR Object gets created only once during driver Loading.
- */
-int mgr_create(struct mgr_object **mgr_obj,
-		      struct cfg_devnode *dev_node_obj)
-{
-	int status = 0;
-	struct mgr_object *pmgr_obj = NULL;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	pmgr_obj = kzalloc(sizeof(struct mgr_object), GFP_KERNEL);
-	if (pmgr_obj) {
-		status = dcd_create_manager(ZLDLLNAME, &pmgr_obj->dcd_mgr);
-		if (!status) {
-			/* If succeeded store the handle in the MGR Object */
-			if (drv_datap) {
-				drv_datap->mgr_object = (void *)pmgr_obj;
-			} else {
-				status = -EPERM;
-				pr_err("%s: Failed to store MGR object\n",
-								__func__);
-			}
-
-			if (!status) {
-				*mgr_obj = pmgr_obj;
-			} else {
-				dcd_destroy_manager(pmgr_obj->dcd_mgr);
-				kfree(pmgr_obj);
-			}
-		} else {
-			/* failed to Create DCD Manager */
-			kfree(pmgr_obj);
-		}
-	} else {
-		status = -ENOMEM;
-	}
-
-	return status;
-}
-
-/*
- *  ========= mgr_destroy =========
- *     This function is invoked during bridge driver unloading.Frees MGR object.
- */
-int mgr_destroy(struct mgr_object *hmgr_obj)
-{
-	int status = 0;
-	struct mgr_object *pmgr_obj = (struct mgr_object *)hmgr_obj;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	/* Free resources */
-	if (hmgr_obj->dcd_mgr)
-		dcd_destroy_manager(hmgr_obj->dcd_mgr);
-
-	kfree(pmgr_obj);
-	/* Update the driver data with NULL for MGR Object */
-	if (drv_datap) {
-		drv_datap->mgr_object = NULL;
-	} else {
-		status = -EPERM;
-		pr_err("%s: Failed to store MGR object\n", __func__);
-	}
-
-	return status;
-}
-
-/*
- *  ======== mgr_enum_node_info ========
- *      Enumerate and get configuration information about nodes configured
- *      in the node database.
- */
-int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops *pndb_props,
-			      u32 undb_props_size, u32 *pu_num_nodes)
-{
-	int status = 0;
-	struct dsp_uuid node_uuid;
-	u32 node_index = 0;
-	struct dcd_genericobj gen_obj;
-	struct mgr_object *pmgr_obj = NULL;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	*pu_num_nodes = 0;
-	/* Get the Manager Object from the driver data */
-	if (!drv_datap || !drv_datap->mgr_object) {
-		pr_err("%s: Failed to retrieve the object handle\n", __func__);
-		return -ENODATA;
-	}
-	pmgr_obj = drv_datap->mgr_object;
-
-	/* Forever loop till we hit failed or no more items in the
-	 * Enumeration. We will exit the loop other than 0; */
-	while (!status) {
-		status = dcd_enumerate_object(node_index++, DSP_DCDNODETYPE,
-				&node_uuid);
-		if (status)
-			break;
-		*pu_num_nodes = node_index;
-		if (node_id == (node_index - 1)) {
-			status = dcd_get_object_def(pmgr_obj->dcd_mgr,
-					&node_uuid, DSP_DCDNODETYPE, &gen_obj);
-			if (status)
-				break;
-			/* Get the Obj def */
-			*pndb_props = gen_obj.obj_data.node_obj.ndb_props;
-		}
-	}
-
-	/* the last status is not 0, but neither an error */
-	if (status > 0)
-		status = 0;
-
-	return status;
-}
-
-/*
- *  ======== mgr_enum_processor_info ========
- *      Enumerate and get configuration information about available
- *      DSP processors.
- */
-int mgr_enum_processor_info(u32 processor_id,
-				   struct dsp_processorinfo *
-				   processor_info, u32 processor_info_size,
-				   u8 *pu_num_procs)
-{
-	int status = 0;
-	int status1 = 0;
-	int status2 = 0;
-	struct dsp_uuid temp_uuid;
-	u32 temp_index = 0;
-	u32 proc_index = 0;
-	struct dcd_genericobj gen_obj;
-	struct mgr_object *pmgr_obj = NULL;
-	struct mgr_processorextinfo *ext_info;
-	struct dev_object *hdev_obj;
-	struct drv_object *hdrv_obj;
-	u8 dev_type;
-	struct cfg_devnode *dev_node;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-	bool proc_detect = false;
-
-	*pu_num_procs = 0;
-
-	/* Retrieve the Object handle from the driver data */
-	if (!drv_datap || !drv_datap->drv_object) {
-		status = -ENODATA;
-		pr_err("%s: Failed to retrieve the object handle\n", __func__);
-	} else {
-		hdrv_obj = drv_datap->drv_object;
-	}
-
-	if (!status) {
-		status = drv_get_dev_object(processor_id, hdrv_obj, &hdev_obj);
-		if (!status) {
-			status = dev_get_dev_type(hdev_obj, (u8 *) &dev_type);
-			status = dev_get_dev_node(hdev_obj, &dev_node);
-			if (dev_type != DSP_UNIT)
-				status = -EPERM;
-
-			if (!status)
-				processor_info->processor_type = DSPTYPE64;
-		}
-	}
-	if (status)
-		goto func_end;
-
-	/* Get The Manager Object from the driver data */
-	if (drv_datap && drv_datap->mgr_object) {
-		pmgr_obj = drv_datap->mgr_object;
-	} else {
-		dev_dbg(bridge, "%s: Failed to get MGR Object\n", __func__);
-		goto func_end;
-	}
-	/* Forever loop till we hit no more items in the
-	 * Enumeration. We will exit the loop other than 0; */
-	while (status1 == 0) {
-		status1 = dcd_enumerate_object(temp_index++,
-					       DSP_DCDPROCESSORTYPE,
-					       &temp_uuid);
-		if (status1 != 0)
-			break;
-
-		proc_index++;
-		/* Get the Object properties to find the Device/Processor
-		 * Type */
-		if (proc_detect != false)
-			continue;
-
-		status2 = dcd_get_object_def(pmgr_obj->dcd_mgr,
-					     (struct dsp_uuid *)&temp_uuid,
-					     DSP_DCDPROCESSORTYPE, &gen_obj);
-		if (!status2) {
-			/* Get the Obj def */
-			if (processor_info_size <
-			    sizeof(struct mgr_processorextinfo)) {
-				*processor_info = gen_obj.obj_data.proc_info;
-			} else {
-				/* extended info */
-				ext_info = (struct mgr_processorextinfo *)
-				    processor_info;
-				*ext_info = gen_obj.obj_data.ext_proc_obj;
-			}
-			dev_dbg(bridge, "%s: Got proctype  from DCD %x\n",
-				__func__, processor_info->processor_type);
-			/* See if we got the needed processor */
-			if (dev_type == DSP_UNIT) {
-				if (processor_info->processor_type ==
-				    DSPPROCTYPE_C64)
-					proc_detect = true;
-			} else if (dev_type == IVA_UNIT) {
-				if (processor_info->processor_type ==
-				    IVAPROCTYPE_ARM7)
-					proc_detect = true;
-			}
-			/* User applications only check for chip type, so
-			 * this is a clumsy overwrite */
-			processor_info->processor_type = DSPTYPE64;
-		} else {
-			dev_dbg(bridge, "%s: Failed to get DCD processor info %x\n",
-					__func__, status2);
-			status = -EPERM;
-		}
-	}
-	*pu_num_procs = proc_index;
-	if (proc_detect == false) {
-		dev_dbg(bridge, "%s: Failed to get proc info from DCD, so use CFG registry\n",
-				__func__);
-		processor_info->processor_type = DSPTYPE64;
-	}
-func_end:
-	return status;
-}
-
-/*
- *  ======== mgr_exit ========
- *      Decrement reference count, and free resources when reference count is
- *      0.
- */
-void mgr_exit(void)
-{
-	refs--;
-	if (refs == 0)
-		dcd_exit();
-}
-
-/*
- *  ======== mgr_get_dcd_handle ========
- *      Retrieves the MGR handle. Accessor Function.
- */
-int mgr_get_dcd_handle(struct mgr_object *mgr_handle,
-			      u32 *dcd_handle)
-{
-	int status = -EPERM;
-	struct mgr_object *pmgr_obj = (struct mgr_object *)mgr_handle;
-
-	*dcd_handle = (u32) NULL;
-	if (pmgr_obj) {
-		*dcd_handle = (u32) pmgr_obj->dcd_mgr;
-		status = 0;
-	}
-
-	return status;
-}
-
-/*
- *  ======== mgr_init ========
- *      Initialize MGR's private state, keeping a reference count on each call.
- */
-bool mgr_init(void)
-{
-	bool ret = true;
-
-	if (refs == 0)
-		ret = dcd_init();	/*  DCD Module */
-
-	if (ret)
-		refs++;
-
-	return ret;
-}
-
-/*
- *  ======== mgr_wait_for_bridge_events ========
- *      Block on any Bridge event(s)
- */
-int mgr_wait_for_bridge_events(struct dsp_notification **anotifications,
-				      u32 count, u32 *pu_index,
-				      u32 utimeout)
-{
-	int status;
-	struct sync_object *sync_events[MAX_EVENTS];
-	u32 i;
-
-	for (i = 0; i < count; i++)
-		sync_events[i] = anotifications[i]->handle;
-
-	status = sync_wait_on_multiple_events(sync_events, count, utimeout,
-					      pu_index);
-
-	return status;
-
-}
diff --git a/drivers/staging/tidspbridge/rmgr/nldr.c b/drivers/staging/tidspbridge/rmgr/nldr.c
deleted file mode 100644
index 900585a..0000000
--- a/drivers/staging/tidspbridge/rmgr/nldr.c
+++ /dev/null
@@ -1,1861 +0,0 @@
-/*
- * nldr.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP/BIOS Bridge dynamic + overlay Node loader.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/types.h>
-
-#include <dspbridge/host_os.h>
-
-#include <dspbridge/dbdefs.h>
-
-/* Platform manager */
-#include <dspbridge/cod.h>
-#include <dspbridge/dev.h>
-
-/* Resource manager */
-#include <dspbridge/dbll.h>
-#include <dspbridge/dbdcd.h>
-#include <dspbridge/rmm.h>
-#include <dspbridge/uuidutil.h>
-
-#include <dspbridge/nldr.h>
-#include <linux/lcm.h>
-
-/* Name of section containing dynamic load mem */
-#define DYNMEMSECT  ".dspbridge_mem"
-
-/* Name of section containing dependent library information */
-#define DEPLIBSECT  ".dspbridge_deplibs"
-
-/* Max depth of recursion for loading node's dependent libraries */
-#define MAXDEPTH	    5
-
-/* Max number of persistent libraries kept by a node */
-#define MAXLIBS	 5
-
-/*
- *  Defines for extracting packed dynamic load memory requirements from two
- *  masks.
- *  These defines must match node.cdb and dynm.cdb
- *  Format of data/code mask is:
- *   uuuuuuuu|fueeeeee|fudddddd|fucccccc|
- *  where
- *      u = unused
- *      cccccc = preferred/required dynamic mem segid for create phase data/code
- *      dddddd = preferred/required dynamic mem segid for delete phase data/code
- *      eeeeee = preferred/req. dynamic mem segid for execute phase data/code
- *      f = flag indicating if memory is preferred or required:
- *	  f = 1 if required, f = 0 if preferred.
- *
- *  The 6 bits of the segid are interpreted as follows:
- *
- *  If the 6th bit (bit 5) is not set, then this specifies a memory segment
- *  between 0 and 31 (a maximum of 32 dynamic loading memory segments).
- *  If the 6th bit (bit 5) is set, segid has the following interpretation:
- *      segid = 32 - Any internal memory segment can be used.
- *      segid = 33 - Any external memory segment can be used.
- *      segid = 63 - Any memory segment can be used (in this case the
- *		   required/preferred flag is irrelevant).
- *
- */
-/* Maximum allowed dynamic loading memory segments */
-#define MAXMEMSEGS      32
-
-#define MAXSEGID	3	/* Largest possible (real) segid */
-#define MEMINTERNALID   32	/* Segid meaning use internal mem */
-#define MEMEXTERNALID   33	/* Segid meaning use external mem */
-#define NULLID	  63		/* Segid meaning no memory req/pref */
-#define FLAGBIT	 7		/* 7th bit is pref./req. flag */
-#define SEGMASK	 0x3f		/* Bits 0 - 5 */
-
-#define CREATEBIT	0	/* Create segid starts at bit 0 */
-#define DELETEBIT	8	/* Delete segid starts at bit 8 */
-#define EXECUTEBIT      16	/* Execute segid starts at bit 16 */
-
-/*
- *  Masks that define memory type.  Must match defines in dynm.cdb.
- */
-#define DYNM_CODE	0x2
-#define DYNM_DATA	0x4
-#define DYNM_CODEDATA   (DYNM_CODE | DYNM_DATA)
-#define DYNM_INTERNAL   0x8
-#define DYNM_EXTERNAL   0x10
-
-/*
- *  Defines for packing memory requirement/preference flags for code and
- *  data of each of the node's phases into one mask.
- *  The bit is set if the segid is required for loading code/data of the
- *  given phase. The bit is not set, if the segid is preferred only.
- *
- *  These defines are also used as indeces into a segid array for the node.
- *  eg node's segid[CREATEDATAFLAGBIT] is the memory segment id that the
- *  create phase data is required or preferred to be loaded into.
- */
-#define CREATEDATAFLAGBIT   0
-#define CREATECODEFLAGBIT   1
-#define EXECUTEDATAFLAGBIT  2
-#define EXECUTECODEFLAGBIT  3
-#define DELETEDATAFLAGBIT   4
-#define DELETECODEFLAGBIT   5
-#define MAXFLAGS	    6
-
-    /*
-     *  These names may be embedded in overlay sections to identify which
-     *  node phase the section should be overlayed.
- */
-#define PCREATE	 "create"
-#define PDELETE	 "delete"
-#define PEXECUTE	"execute"
-
-static inline bool is_equal_uuid(struct dsp_uuid *uuid1,
-							struct dsp_uuid *uuid2)
-{
-	return !memcmp(uuid1, uuid2, sizeof(struct dsp_uuid));
-}
-
-    /*
-     *  ======== mem_seg_info ========
-     *  Format of dynamic loading memory segment info in coff file.
-     *  Must match dynm.h55.
- */
-struct mem_seg_info {
-	u32 segid;		/* Dynamic loading memory segment number */
-	u32 base;
-	u32 len;
-	u32 type;		/* Mask of DYNM_CODE, DYNM_INTERNAL, etc. */
-};
-
-/*
- *  ======== lib_node ========
- *  For maintaining a tree of library dependencies.
- */
-struct lib_node {
-	struct dbll_library_obj *lib;	/* The library */
-	u16 dep_libs;		/* Number of dependent libraries */
-	struct lib_node *dep_libs_tree;	/* Dependent libraries of lib */
-};
-
-/*
- *  ======== ovly_sect ========
- *  Information needed to overlay a section.
- */
-struct ovly_sect {
-	struct ovly_sect *next_sect;
-	u32 sect_load_addr;	/* Load address of section */
-	u32 sect_run_addr;	/* Run address of section */
-	u32 size;		/* Size of section */
-	u16 page;		/* DBL_CODE, DBL_DATA */
-};
-
-/*
- *  ======== ovly_node ========
- *  For maintaining a list of overlay nodes, with sections that need to be
- *  overlayed for each of the nodes phases.
- */
-struct ovly_node {
-	struct dsp_uuid uuid;
-	char *node_name;
-	struct ovly_sect *create_sects_list;
-	struct ovly_sect *delete_sects_list;
-	struct ovly_sect *execute_sects_list;
-	struct ovly_sect *other_sects_list;
-	u16 create_sects;
-	u16 delete_sects;
-	u16 execute_sects;
-	u16 other_sects;
-	u16 create_ref;
-	u16 delete_ref;
-	u16 execute_ref;
-	u16 other_ref;
-};
-
-/*
- *  ======== nldr_object ========
- *  Overlay loader object.
- */
-struct nldr_object {
-	struct dev_object *dev_obj;	/* Device object */
-	struct dcd_manager *dcd_mgr;	/* Proc/Node data manager */
-	struct dbll_tar_obj *dbll;	/* The DBL loader */
-	struct dbll_library_obj *base_lib;	/* Base image library */
-	struct rmm_target_obj *rmm;	/* Remote memory manager for DSP */
-	struct dbll_fxns ldr_fxns;	/* Loader function table */
-	struct dbll_attrs ldr_attrs;	/* attrs to pass to loader functions */
-	nldr_ovlyfxn ovly_fxn;	/* "write" for overlay nodes */
-	nldr_writefxn write_fxn;	/* "write" for dynamic nodes */
-	struct ovly_node *ovly_table;	/* Table of overlay nodes */
-	u16 ovly_nodes;		/* Number of overlay nodes in base */
-	u16 ovly_nid;		/* Index for tracking overlay nodes */
-	u16 dload_segs;		/* Number of dynamic load mem segs */
-	u32 *seg_table;		/* memtypes of dynamic memory segs
-				 * indexed by segid
-				 */
-	u16 dsp_mau_size;	/* Size of DSP MAU */
-	u16 dsp_word_size;	/* Size of DSP word */
-};
-
-/*
- *  ======== nldr_nodeobject ========
- *  Dynamic node object. This object is created when a node is allocated.
- */
-struct nldr_nodeobject {
-	struct nldr_object *nldr_obj;	/* Dynamic loader handle */
-	void *priv_ref;		/* Handle to pass to dbl_write_fxn */
-	struct dsp_uuid uuid;	/* Node's UUID */
-	bool dynamic;		/* Dynamically loaded node? */
-	bool overlay;		/* Overlay node? */
-	bool *phase_split;	/* Multiple phase libraries? */
-	struct lib_node root;	/* Library containing node phase */
-	struct lib_node create_lib;	/* Library with create phase lib */
-	struct lib_node execute_lib;	/* Library with execute phase lib */
-	struct lib_node delete_lib;	/* Library with delete phase lib */
-	/* libs remain loaded until Delete */
-	struct lib_node pers_lib_table[MAXLIBS];
-	s32 pers_libs;		/* Number of persistent libraries */
-	/* Path in lib dependency tree */
-	struct dbll_library_obj *lib_path[MAXDEPTH + 1];
-	enum nldr_phase phase;	/* Node phase currently being loaded */
-
-	/*
-	 *  Dynamic loading memory segments for data and code of each phase.
-	 */
-	u16 seg_id[MAXFLAGS];
-
-	/*
-	 *  Mask indicating whether each mem segment specified in seg_id[]
-	 *  is preferred or required.
-	 *  For example
-	 *  	if (code_data_flag_mask & (1 << EXECUTEDATAFLAGBIT)) != 0,
-	 *  then it is required to load execute phase data into the memory
-	 *  specified by seg_id[EXECUTEDATAFLAGBIT].
-	 */
-	u32 code_data_flag_mask;
-};
-
-/* Dynamic loader function table */
-static struct dbll_fxns ldr_fxns = {
-	(dbll_close_fxn) dbll_close,
-	(dbll_create_fxn) dbll_create,
-	(dbll_delete_fxn) dbll_delete,
-	(dbll_exit_fxn) dbll_exit,
-	(dbll_get_attrs_fxn) dbll_get_attrs,
-	(dbll_get_addr_fxn) dbll_get_addr,
-	(dbll_get_c_addr_fxn) dbll_get_c_addr,
-	(dbll_get_sect_fxn) dbll_get_sect,
-	(dbll_init_fxn) dbll_init,
-	(dbll_load_fxn) dbll_load,
-	(dbll_open_fxn) dbll_open,
-	(dbll_read_sect_fxn) dbll_read_sect,
-	(dbll_unload_fxn) dbll_unload,
-};
-
-static int add_ovly_info(void *handle, struct dbll_sect_info *sect_info,
-				u32 addr, u32 bytes);
-static int add_ovly_node(struct dsp_uuid *uuid_obj,
-				enum dsp_dcdobjtype obj_type, void *handle);
-static int add_ovly_sect(struct nldr_object *nldr_obj,
-				struct ovly_sect **lst,
-				struct dbll_sect_info *sect_inf,
-				bool *exists, u32 addr, u32 bytes);
-static s32 fake_ovly_write(void *handle, u32 dsp_address, void *buf, u32 bytes,
-			   s32 mtype);
-static void free_sects(struct nldr_object *nldr_obj,
-		       struct ovly_sect *phase_sects, u16 alloc_num);
-static bool get_symbol_value(void *handle, void *parg, void *rmm_handle,
-			     char *sym_name, struct dbll_sym_val **sym);
-static int load_lib(struct nldr_nodeobject *nldr_node_obj,
-			   struct lib_node *root, struct dsp_uuid uuid,
-			   bool root_prstnt,
-			   struct dbll_library_obj **lib_path,
-			   enum nldr_phase phase, u16 depth);
-static int load_ovly(struct nldr_nodeobject *nldr_node_obj,
-			    enum nldr_phase phase);
-static int remote_alloc(void **ref, u16 mem_sect, u32 size,
-			       u32 align, u32 *dsp_address,
-			       s32 segmnt_id,
-			       s32 req, bool reserve);
-static int remote_free(void **ref, u16 space, u32 dsp_address, u32 size,
-			      bool reserve);
-
-static void unload_lib(struct nldr_nodeobject *nldr_node_obj,
-		       struct lib_node *root);
-static void unload_ovly(struct nldr_nodeobject *nldr_node_obj,
-			enum nldr_phase phase);
-static bool find_in_persistent_lib_array(struct nldr_nodeobject *nldr_node_obj,
-					 struct dbll_library_obj *lib);
-
-/*
- *  ======== nldr_allocate ========
- */
-int nldr_allocate(struct nldr_object *nldr_obj, void *priv_ref,
-			 const struct dcd_nodeprops *node_props,
-			 struct nldr_nodeobject **nldr_nodeobj,
-			 bool *pf_phase_split)
-{
-	struct nldr_nodeobject *nldr_node_obj = NULL;
-	int status = 0;
-
-	/* Initialize handle in case of failure */
-	*nldr_nodeobj = NULL;
-	/* Allocate node object */
-	nldr_node_obj = kzalloc(sizeof(struct nldr_nodeobject), GFP_KERNEL);
-
-	if (nldr_node_obj == NULL) {
-		status = -ENOMEM;
-	} else {
-		nldr_node_obj->phase_split = pf_phase_split;
-		nldr_node_obj->pers_libs = 0;
-		nldr_node_obj->nldr_obj = nldr_obj;
-		nldr_node_obj->priv_ref = priv_ref;
-		/* Save node's UUID. */
-		nldr_node_obj->uuid = node_props->ndb_props.ui_node_id;
-		/*
-		 *  Determine if node is a dynamically loaded node from
-		 *  ndb_props.
-		 */
-		if (node_props->load_type == NLDR_DYNAMICLOAD) {
-			/* Dynamic node */
-			nldr_node_obj->dynamic = true;
-			/*
-			 *  Extract memory requirements from ndb_props masks
-			 */
-			/* Create phase */
-			nldr_node_obj->seg_id[CREATEDATAFLAGBIT] = (u16)
-			    (node_props->data_mem_seg_mask >> CREATEBIT) &
-			    SEGMASK;
-			nldr_node_obj->code_data_flag_mask |=
-			    ((node_props->data_mem_seg_mask >>
-			      (CREATEBIT + FLAGBIT)) & 1) << CREATEDATAFLAGBIT;
-			nldr_node_obj->seg_id[CREATECODEFLAGBIT] = (u16)
-			    (node_props->code_mem_seg_mask >>
-			     CREATEBIT) & SEGMASK;
-			nldr_node_obj->code_data_flag_mask |=
-			    ((node_props->code_mem_seg_mask >>
-			      (CREATEBIT + FLAGBIT)) & 1) << CREATECODEFLAGBIT;
-			/* Execute phase */
-			nldr_node_obj->seg_id[EXECUTEDATAFLAGBIT] = (u16)
-			    (node_props->data_mem_seg_mask >>
-			     EXECUTEBIT) & SEGMASK;
-			nldr_node_obj->code_data_flag_mask |=
-			    ((node_props->data_mem_seg_mask >>
-			      (EXECUTEBIT + FLAGBIT)) & 1) <<
-			    EXECUTEDATAFLAGBIT;
-			nldr_node_obj->seg_id[EXECUTECODEFLAGBIT] = (u16)
-			    (node_props->code_mem_seg_mask >>
-			     EXECUTEBIT) & SEGMASK;
-			nldr_node_obj->code_data_flag_mask |=
-			    ((node_props->code_mem_seg_mask >>
-			      (EXECUTEBIT + FLAGBIT)) & 1) <<
-			    EXECUTECODEFLAGBIT;
-			/* Delete phase */
-			nldr_node_obj->seg_id[DELETEDATAFLAGBIT] = (u16)
-			    (node_props->data_mem_seg_mask >> DELETEBIT) &
-			    SEGMASK;
-			nldr_node_obj->code_data_flag_mask |=
-			    ((node_props->data_mem_seg_mask >>
-			      (DELETEBIT + FLAGBIT)) & 1) << DELETEDATAFLAGBIT;
-			nldr_node_obj->seg_id[DELETECODEFLAGBIT] = (u16)
-			    (node_props->code_mem_seg_mask >>
-			     DELETEBIT) & SEGMASK;
-			nldr_node_obj->code_data_flag_mask |=
-			    ((node_props->code_mem_seg_mask >>
-			      (DELETEBIT + FLAGBIT)) & 1) << DELETECODEFLAGBIT;
-		} else {
-			/* Non-dynamically loaded nodes are part of the
-			 * base image */
-			nldr_node_obj->root.lib = nldr_obj->base_lib;
-			/* Check for overlay node */
-			if (node_props->load_type == NLDR_OVLYLOAD)
-				nldr_node_obj->overlay = true;
-
-		}
-		*nldr_nodeobj = (struct nldr_nodeobject *)nldr_node_obj;
-	}
-	/* Cleanup on failure */
-	if (status && nldr_node_obj)
-		kfree(nldr_node_obj);
-
-	return status;
-}
-
-/*
- *  ======== nldr_create ========
- */
-int nldr_create(struct nldr_object **nldr,
-		       struct dev_object *hdev_obj,
-		       const struct nldr_attrs *pattrs)
-{
-	struct cod_manager *cod_mgr;	/* COD manager */
-	char *psz_coff_buf = NULL;
-	char sz_zl_file[COD_MAXPATHLENGTH];
-	struct nldr_object *nldr_obj = NULL;
-	struct dbll_attrs save_attrs;
-	struct dbll_attrs new_attrs;
-	dbll_flags flags;
-	u32 ul_entry;
-	u16 dload_segs = 0;
-	struct mem_seg_info *mem_info_obj;
-	u32 ul_len = 0;
-	u32 ul_addr;
-	struct rmm_segment *rmm_segs = NULL;
-	u16 i;
-	int status = 0;
-
-	/* Allocate dynamic loader object */
-	nldr_obj = kzalloc(sizeof(struct nldr_object), GFP_KERNEL);
-	if (nldr_obj) {
-		nldr_obj->dev_obj = hdev_obj;
-		/* warning, lazy status checking alert! */
-		dev_get_cod_mgr(hdev_obj, &cod_mgr);
-		if (cod_mgr) {
-			status = cod_get_loader(cod_mgr, &nldr_obj->dbll);
-			status = cod_get_base_lib(cod_mgr, &nldr_obj->base_lib);
-			status =
-			    cod_get_base_name(cod_mgr, sz_zl_file,
-							COD_MAXPATHLENGTH);
-		}
-		status = 0;
-		/* end lazy status checking */
-		nldr_obj->dsp_mau_size = pattrs->dsp_mau_size;
-		nldr_obj->dsp_word_size = pattrs->dsp_word_size;
-		nldr_obj->ldr_fxns = ldr_fxns;
-		if (!(nldr_obj->ldr_fxns.init_fxn()))
-			status = -ENOMEM;
-
-	} else {
-		status = -ENOMEM;
-	}
-	/* Create the DCD Manager */
-	if (!status)
-		status = dcd_create_manager(NULL, &nldr_obj->dcd_mgr);
-
-	/* Get dynamic loading memory sections from base lib */
-	if (!status) {
-		status =
-		    nldr_obj->ldr_fxns.get_sect_fxn(nldr_obj->base_lib,
-						    DYNMEMSECT, &ul_addr,
-						    &ul_len);
-		if (!status) {
-			psz_coff_buf =
-				kzalloc(ul_len * nldr_obj->dsp_mau_size,
-								GFP_KERNEL);
-			if (!psz_coff_buf)
-				status = -ENOMEM;
-		} else {
-			/* Ok to not have dynamic loading memory */
-			status = 0;
-			ul_len = 0;
-			dev_dbg(bridge, "%s: failed - no dynamic loading mem "
-				"segments: 0x%x\n", __func__, status);
-		}
-	}
-	if (!status && ul_len > 0) {
-		/* Read section containing dynamic load mem segments */
-		status =
-		    nldr_obj->ldr_fxns.read_sect_fxn(nldr_obj->base_lib,
-						     DYNMEMSECT, psz_coff_buf,
-						     ul_len);
-	}
-	if (!status && ul_len > 0) {
-		/* Parse memory segment data */
-		dload_segs = (u16) (*((u32 *) psz_coff_buf));
-		if (dload_segs > MAXMEMSEGS)
-			status = -EBADF;
-	}
-	/* Parse dynamic load memory segments */
-	if (!status && dload_segs > 0) {
-		rmm_segs = kzalloc(sizeof(struct rmm_segment) * dload_segs,
-								GFP_KERNEL);
-		nldr_obj->seg_table =
-				kzalloc(sizeof(u32) * dload_segs, GFP_KERNEL);
-		if (rmm_segs == NULL || nldr_obj->seg_table == NULL) {
-			status = -ENOMEM;
-		} else {
-			nldr_obj->dload_segs = dload_segs;
-			mem_info_obj = (struct mem_seg_info *)(psz_coff_buf +
-							       sizeof(u32));
-			for (i = 0; i < dload_segs; i++) {
-				rmm_segs[i].base = (mem_info_obj + i)->base;
-				rmm_segs[i].length = (mem_info_obj + i)->len;
-				rmm_segs[i].space = 0;
-				nldr_obj->seg_table[i] =
-				    (mem_info_obj + i)->type;
-				dev_dbg(bridge,
-					"(proc) DLL MEMSEGMENT: %d, "
-					"Base: 0x%x, Length: 0x%x\n", i,
-					rmm_segs[i].base, rmm_segs[i].length);
-			}
-		}
-	}
-	/* Create Remote memory manager */
-	if (!status)
-		status = rmm_create(&nldr_obj->rmm, rmm_segs, dload_segs);
-
-	if (!status) {
-		/* set the alloc, free, write functions for loader */
-		nldr_obj->ldr_fxns.get_attrs_fxn(nldr_obj->dbll, &save_attrs);
-		new_attrs = save_attrs;
-		new_attrs.alloc = (dbll_alloc_fxn) remote_alloc;
-		new_attrs.free = (dbll_free_fxn) remote_free;
-		new_attrs.sym_lookup = (dbll_sym_lookup) get_symbol_value;
-		new_attrs.sym_handle = nldr_obj;
-		new_attrs.write = (dbll_write_fxn) pattrs->write;
-		nldr_obj->ovly_fxn = pattrs->ovly;
-		nldr_obj->write_fxn = pattrs->write;
-		nldr_obj->ldr_attrs = new_attrs;
-	}
-	kfree(rmm_segs);
-
-	kfree(psz_coff_buf);
-
-	/* Get overlay nodes */
-	if (!status) {
-		status =
-		    cod_get_base_name(cod_mgr, sz_zl_file, COD_MAXPATHLENGTH);
-		/* lazy check */
-		/* First count number of overlay nodes */
-		status =
-		    dcd_get_objects(nldr_obj->dcd_mgr, sz_zl_file,
-				    add_ovly_node, (void *)nldr_obj);
-		/* Now build table of overlay nodes */
-		if (!status && nldr_obj->ovly_nodes > 0) {
-			/* Allocate table for overlay nodes */
-			nldr_obj->ovly_table =
-					kzalloc(sizeof(struct ovly_node) *
-					nldr_obj->ovly_nodes, GFP_KERNEL);
-			/* Put overlay nodes in the table */
-			nldr_obj->ovly_nid = 0;
-			status = dcd_get_objects(nldr_obj->dcd_mgr, sz_zl_file,
-						 add_ovly_node,
-						 (void *)nldr_obj);
-		}
-	}
-	/* Do a fake reload of the base image to get overlay section info */
-	if (!status && nldr_obj->ovly_nodes > 0) {
-		save_attrs.write = fake_ovly_write;
-		save_attrs.log_write = add_ovly_info;
-		save_attrs.log_write_handle = nldr_obj;
-		flags = DBLL_CODE | DBLL_DATA | DBLL_SYMB;
-		status = nldr_obj->ldr_fxns.load_fxn(nldr_obj->base_lib, flags,
-						     &save_attrs, &ul_entry);
-	}
-	if (!status) {
-		*nldr = (struct nldr_object *)nldr_obj;
-	} else {
-		if (nldr_obj)
-			nldr_delete((struct nldr_object *)nldr_obj);
-
-		*nldr = NULL;
-	}
-	/* FIXME:Temp. Fix. Must be removed */
-	return status;
-}
-
-/*
- *  ======== nldr_delete ========
- */
-void nldr_delete(struct nldr_object *nldr_obj)
-{
-	struct ovly_sect *ovly_section;
-	struct ovly_sect *next;
-	u16 i;
-
-	nldr_obj->ldr_fxns.exit_fxn();
-	if (nldr_obj->rmm)
-		rmm_delete(nldr_obj->rmm);
-
-	kfree(nldr_obj->seg_table);
-
-	if (nldr_obj->dcd_mgr)
-		dcd_destroy_manager(nldr_obj->dcd_mgr);
-
-	/* Free overlay node information */
-	if (nldr_obj->ovly_table) {
-		for (i = 0; i < nldr_obj->ovly_nodes; i++) {
-			ovly_section =
-			    nldr_obj->ovly_table[i].create_sects_list;
-			while (ovly_section) {
-				next = ovly_section->next_sect;
-				kfree(ovly_section);
-				ovly_section = next;
-			}
-			ovly_section =
-			    nldr_obj->ovly_table[i].delete_sects_list;
-			while (ovly_section) {
-				next = ovly_section->next_sect;
-				kfree(ovly_section);
-				ovly_section = next;
-			}
-			ovly_section =
-			    nldr_obj->ovly_table[i].execute_sects_list;
-			while (ovly_section) {
-				next = ovly_section->next_sect;
-				kfree(ovly_section);
-				ovly_section = next;
-			}
-			ovly_section = nldr_obj->ovly_table[i].other_sects_list;
-			while (ovly_section) {
-				next = ovly_section->next_sect;
-				kfree(ovly_section);
-				ovly_section = next;
-			}
-		}
-		kfree(nldr_obj->ovly_table);
-	}
-	kfree(nldr_obj);
-}
-
-/*
- *  ======== nldr_get_fxn_addr ========
- */
-int nldr_get_fxn_addr(struct nldr_nodeobject *nldr_node_obj,
-			     char *str_fxn, u32 *addr)
-{
-	struct dbll_sym_val *dbll_sym;
-	struct nldr_object *nldr_obj;
-	int status = 0;
-	bool status1 = false;
-	s32 i = 0;
-	struct lib_node root = { NULL, 0, NULL };
-
-	nldr_obj = nldr_node_obj->nldr_obj;
-	/* Called from node_create(), node_delete(), or node_run(). */
-	if (nldr_node_obj->dynamic && *nldr_node_obj->phase_split) {
-		switch (nldr_node_obj->phase) {
-		case NLDR_CREATE:
-			root = nldr_node_obj->create_lib;
-			break;
-		case NLDR_EXECUTE:
-			root = nldr_node_obj->execute_lib;
-			break;
-		case NLDR_DELETE:
-			root = nldr_node_obj->delete_lib;
-			break;
-		default:
-			break;
-		}
-	} else {
-		/* for Overlay nodes or non-split Dynamic nodes */
-		root = nldr_node_obj->root;
-	}
-	status1 =
-	    nldr_obj->ldr_fxns.get_c_addr_fxn(root.lib, str_fxn, &dbll_sym);
-	if (!status1)
-		status1 =
-		    nldr_obj->ldr_fxns.get_addr_fxn(root.lib, str_fxn,
-						    &dbll_sym);
-
-	/* If symbol not found, check dependent libraries */
-	if (!status1) {
-		for (i = 0; i < root.dep_libs; i++) {
-			status1 =
-			    nldr_obj->ldr_fxns.get_addr_fxn(root.dep_libs_tree
-							    [i].lib, str_fxn,
-							    &dbll_sym);
-			if (!status1) {
-				status1 =
-				    nldr_obj->ldr_fxns.
-				    get_c_addr_fxn(root.dep_libs_tree[i].lib,
-						   str_fxn, &dbll_sym);
-			}
-			if (status1) {
-				/* Symbol found */
-				break;
-			}
-		}
-	}
-	/* Check persistent libraries */
-	if (!status1) {
-		for (i = 0; i < nldr_node_obj->pers_libs; i++) {
-			status1 =
-			    nldr_obj->ldr_fxns.
-			    get_addr_fxn(nldr_node_obj->pers_lib_table[i].lib,
-					 str_fxn, &dbll_sym);
-			if (!status1) {
-				status1 =
-				    nldr_obj->ldr_fxns.
-				    get_c_addr_fxn(nldr_node_obj->pers_lib_table
-						   [i].lib, str_fxn, &dbll_sym);
-			}
-			if (status1) {
-				/* Symbol found */
-				break;
-			}
-		}
-	}
-
-	if (status1)
-		*addr = dbll_sym->value;
-	else
-		status = -ESPIPE;
-
-	return status;
-}
-
-/*
- *  ======== nldr_get_rmm_manager ========
- *  Given a NLDR object, retrieve RMM Manager Handle
- */
-int nldr_get_rmm_manager(struct nldr_object *nldr,
-				struct rmm_target_obj **rmm_mgr)
-{
-	int status = 0;
-	struct nldr_object *nldr_obj = nldr;
-
-	if (nldr) {
-		*rmm_mgr = nldr_obj->rmm;
-	} else {
-		*rmm_mgr = NULL;
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== nldr_load ========
- */
-int nldr_load(struct nldr_nodeobject *nldr_node_obj,
-		     enum nldr_phase phase)
-{
-	struct nldr_object *nldr_obj;
-	struct dsp_uuid lib_uuid;
-	int status = 0;
-
-	nldr_obj = nldr_node_obj->nldr_obj;
-
-	if (nldr_node_obj->dynamic) {
-		nldr_node_obj->phase = phase;
-
-		lib_uuid = nldr_node_obj->uuid;
-
-		/* At this point, we may not know if node is split into
-		 * different libraries. So we'll go ahead and load the
-		 * library, and then save the pointer to the appropriate
-		 * location after we know. */
-
-		status =
-		    load_lib(nldr_node_obj, &nldr_node_obj->root, lib_uuid,
-			     false, nldr_node_obj->lib_path, phase, 0);
-
-		if (!status) {
-			if (*nldr_node_obj->phase_split) {
-				switch (phase) {
-				case NLDR_CREATE:
-					nldr_node_obj->create_lib =
-					    nldr_node_obj->root;
-					break;
-
-				case NLDR_EXECUTE:
-					nldr_node_obj->execute_lib =
-					    nldr_node_obj->root;
-					break;
-
-				case NLDR_DELETE:
-					nldr_node_obj->delete_lib =
-					    nldr_node_obj->root;
-					break;
-
-				default:
-					break;
-				}
-			}
-		}
-	} else {
-		if (nldr_node_obj->overlay)
-			status = load_ovly(nldr_node_obj, phase);
-
-	}
-
-	return status;
-}
-
-/*
- *  ======== nldr_unload ========
- */
-int nldr_unload(struct nldr_nodeobject *nldr_node_obj,
-		       enum nldr_phase phase)
-{
-	int status = 0;
-	struct lib_node *root_lib = NULL;
-	s32 i = 0;
-
-	if (nldr_node_obj != NULL) {
-		if (nldr_node_obj->dynamic) {
-			if (*nldr_node_obj->phase_split) {
-				switch (phase) {
-				case NLDR_CREATE:
-					root_lib = &nldr_node_obj->create_lib;
-					break;
-				case NLDR_EXECUTE:
-					root_lib = &nldr_node_obj->execute_lib;
-					break;
-				case NLDR_DELETE:
-					root_lib = &nldr_node_obj->delete_lib;
-					/* Unload persistent libraries */
-					for (i = 0;
-					     i < nldr_node_obj->pers_libs;
-					     i++) {
-						unload_lib(nldr_node_obj,
-							   &nldr_node_obj->
-							   pers_lib_table[i]);
-					}
-					nldr_node_obj->pers_libs = 0;
-					break;
-				default:
-					break;
-				}
-			} else {
-				/* Unload main library */
-				root_lib = &nldr_node_obj->root;
-			}
-			if (root_lib)
-				unload_lib(nldr_node_obj, root_lib);
-		} else {
-			if (nldr_node_obj->overlay)
-				unload_ovly(nldr_node_obj, phase);
-
-		}
-	}
-	return status;
-}
-
-/*
- *  ======== add_ovly_info ========
- */
-static int add_ovly_info(void *handle, struct dbll_sect_info *sect_info,
-				u32 addr, u32 bytes)
-{
-	char *node_name;
-	char *sect_name = (char *)sect_info->name;
-	bool sect_exists = false;
-	char seps = ':';
-	char *pch;
-	u16 i;
-	struct nldr_object *nldr_obj = (struct nldr_object *)handle;
-	int status = 0;
-
-	/* Is this an overlay section (load address != run address)? */
-	if (sect_info->sect_load_addr == sect_info->sect_run_addr)
-		goto func_end;
-
-	/* Find the node it belongs to */
-	for (i = 0; i < nldr_obj->ovly_nodes; i++) {
-		node_name = nldr_obj->ovly_table[i].node_name;
-		if (strncmp(node_name, sect_name + 1, strlen(node_name)) == 0) {
-			/* Found the node */
-			break;
-		}
-	}
-	if (!(i < nldr_obj->ovly_nodes))
-		goto func_end;
-
-	/* Determine which phase this section belongs to */
-	for (pch = sect_name + 1; *pch && *pch != seps; pch++)
-		;
-
-	if (*pch) {
-		pch++;		/* Skip over the ':' */
-		if (strncmp(pch, PCREATE, strlen(PCREATE)) == 0) {
-			status =
-			    add_ovly_sect(nldr_obj,
-					  &nldr_obj->
-					  ovly_table[i].create_sects_list,
-					  sect_info, &sect_exists, addr, bytes);
-			if (!status && !sect_exists)
-				nldr_obj->ovly_table[i].create_sects++;
-
-		} else if (strncmp(pch, PDELETE, strlen(PDELETE)) == 0) {
-			status =
-			    add_ovly_sect(nldr_obj,
-					  &nldr_obj->
-					  ovly_table[i].delete_sects_list,
-					  sect_info, &sect_exists, addr, bytes);
-			if (!status && !sect_exists)
-				nldr_obj->ovly_table[i].delete_sects++;
-
-		} else if (strncmp(pch, PEXECUTE, strlen(PEXECUTE)) == 0) {
-			status =
-			    add_ovly_sect(nldr_obj,
-					  &nldr_obj->
-					  ovly_table[i].execute_sects_list,
-					  sect_info, &sect_exists, addr, bytes);
-			if (!status && !sect_exists)
-				nldr_obj->ovly_table[i].execute_sects++;
-
-		} else {
-			/* Put in "other" sections */
-			status =
-			    add_ovly_sect(nldr_obj,
-					  &nldr_obj->
-					  ovly_table[i].other_sects_list,
-					  sect_info, &sect_exists, addr, bytes);
-			if (!status && !sect_exists)
-				nldr_obj->ovly_table[i].other_sects++;
-
-		}
-	}
-func_end:
-	return status;
-}
-
-/*
- *  ======== add_ovly_node =========
- *  Callback function passed to dcd_get_objects.
- */
-static int add_ovly_node(struct dsp_uuid *uuid_obj,
-				enum dsp_dcdobjtype obj_type, void *handle)
-{
-	struct nldr_object *nldr_obj = (struct nldr_object *)handle;
-	char *node_name = NULL;
-	char *pbuf = NULL;
-	u32 len;
-	struct dcd_genericobj obj_def;
-	int status = 0;
-
-	if (obj_type != DSP_DCDNODETYPE)
-		goto func_end;
-
-	status =
-	    dcd_get_object_def(nldr_obj->dcd_mgr, uuid_obj, obj_type,
-			       &obj_def);
-	if (status)
-		goto func_end;
-
-	/* If overlay node, add to the list */
-	if (obj_def.obj_data.node_obj.load_type == NLDR_OVLYLOAD) {
-		if (nldr_obj->ovly_table == NULL) {
-			nldr_obj->ovly_nodes++;
-		} else {
-			/* Add node to table */
-			nldr_obj->ovly_table[nldr_obj->ovly_nid].uuid =
-			    *uuid_obj;
-			len =
-			    strlen(obj_def.obj_data.node_obj.ndb_props.ac_name);
-			node_name = obj_def.obj_data.node_obj.ndb_props.ac_name;
-			pbuf = kzalloc(len + 1, GFP_KERNEL);
-			if (pbuf == NULL) {
-				status = -ENOMEM;
-			} else {
-				strncpy(pbuf, node_name, len);
-				nldr_obj->ovly_table[nldr_obj->ovly_nid].
-				    node_name = pbuf;
-				nldr_obj->ovly_nid++;
-			}
-		}
-	}
-	/* These were allocated in dcd_get_object_def */
-	kfree(obj_def.obj_data.node_obj.str_create_phase_fxn);
-
-	kfree(obj_def.obj_data.node_obj.str_execute_phase_fxn);
-
-	kfree(obj_def.obj_data.node_obj.str_delete_phase_fxn);
-
-	kfree(obj_def.obj_data.node_obj.str_i_alg_name);
-
-func_end:
-	return status;
-}
-
-/*
- *  ======== add_ovly_sect ========
- */
-static int add_ovly_sect(struct nldr_object *nldr_obj,
-				struct ovly_sect **lst,
-				struct dbll_sect_info *sect_inf,
-				bool *exists, u32 addr, u32 bytes)
-{
-	struct ovly_sect *new_sect = NULL;
-	struct ovly_sect *last_sect;
-	struct ovly_sect *ovly_section;
-	int status = 0;
-
-	ovly_section = last_sect = *lst;
-	*exists = false;
-	while (ovly_section) {
-		/*
-		 *  Make sure section has not already been added. Multiple
-		 *  'write' calls may be made to load the section.
-		 */
-		if (ovly_section->sect_load_addr == addr) {
-			/* Already added */
-			*exists = true;
-			break;
-		}
-		last_sect = ovly_section;
-		ovly_section = ovly_section->next_sect;
-	}
-
-	if (!ovly_section) {
-		/* New section */
-		new_sect = kzalloc(sizeof(struct ovly_sect), GFP_KERNEL);
-		if (new_sect == NULL) {
-			status = -ENOMEM;
-		} else {
-			new_sect->sect_load_addr = addr;
-			new_sect->sect_run_addr = sect_inf->sect_run_addr +
-			    (addr - sect_inf->sect_load_addr);
-			new_sect->size = bytes;
-			new_sect->page = sect_inf->type;
-		}
-
-		/* Add to the list */
-		if (!status) {
-			if (*lst == NULL) {
-				/* First in the list */
-				*lst = new_sect;
-			} else {
-				last_sect->next_sect = new_sect;
-			}
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== fake_ovly_write ========
- */
-static s32 fake_ovly_write(void *handle, u32 dsp_address, void *buf, u32 bytes,
-			   s32 mtype)
-{
-	return (s32) bytes;
-}
-
-/*
- *  ======== free_sects ========
- */
-static void free_sects(struct nldr_object *nldr_obj,
-		       struct ovly_sect *phase_sects, u16 alloc_num)
-{
-	struct ovly_sect *ovly_section = phase_sects;
-	u16 i = 0;
-	bool ret;
-
-	while (ovly_section && i < alloc_num) {
-		/* 'Deallocate' */
-		/* segid - page not supported yet */
-		/* Reserved memory */
-		ret =
-		    rmm_free(nldr_obj->rmm, 0, ovly_section->sect_run_addr,
-			     ovly_section->size, true);
-		ovly_section = ovly_section->next_sect;
-		i++;
-	}
-}
-
-/*
- *  ======== get_symbol_value ========
- *  Find symbol in library's base image.  If not there, check dependent
- *  libraries.
- */
-static bool get_symbol_value(void *handle, void *parg, void *rmm_handle,
-			     char *sym_name, struct dbll_sym_val **sym)
-{
-	struct nldr_object *nldr_obj = (struct nldr_object *)handle;
-	struct nldr_nodeobject *nldr_node_obj =
-	    (struct nldr_nodeobject *)rmm_handle;
-	struct lib_node *root = (struct lib_node *)parg;
-	u16 i;
-	bool status = false;
-
-	/* check the base image */
-	status = nldr_obj->ldr_fxns.get_addr_fxn(nldr_obj->base_lib,
-						 sym_name, sym);
-	if (!status)
-		status =
-		    nldr_obj->ldr_fxns.get_c_addr_fxn(nldr_obj->base_lib,
-							sym_name, sym);
-
-	/*
-	 *  Check in root lib itself. If the library consists of
-	 *  multiple object files linked together, some symbols in the
-	 *  library may need to be resolved.
-	 */
-	if (!status) {
-		status = nldr_obj->ldr_fxns.get_addr_fxn(root->lib, sym_name,
-							 sym);
-		if (!status) {
-			status =
-			    nldr_obj->ldr_fxns.get_c_addr_fxn(root->lib,
-							      sym_name, sym);
-		}
-	}
-
-	/*
-	 *  Check in root lib's dependent libraries, but not dependent
-	 *  libraries' dependents.
-	 */
-	if (!status) {
-		for (i = 0; i < root->dep_libs; i++) {
-			status =
-			    nldr_obj->ldr_fxns.get_addr_fxn(root->
-							    dep_libs_tree
-							    [i].lib,
-							    sym_name, sym);
-			if (!status) {
-				status =
-				    nldr_obj->ldr_fxns.
-				    get_c_addr_fxn(root->dep_libs_tree[i].lib,
-						   sym_name, sym);
-			}
-			if (status) {
-				/* Symbol found */
-				break;
-			}
-		}
-	}
-	/*
-	 * Check in persistent libraries
-	 */
-	if (!status) {
-		for (i = 0; i < nldr_node_obj->pers_libs; i++) {
-			status =
-			    nldr_obj->ldr_fxns.
-			    get_addr_fxn(nldr_node_obj->pers_lib_table[i].lib,
-					 sym_name, sym);
-			if (!status) {
-				status = nldr_obj->ldr_fxns.get_c_addr_fxn
-				    (nldr_node_obj->pers_lib_table[i].lib,
-				     sym_name, sym);
-			}
-			if (status) {
-				/* Symbol found */
-				break;
-			}
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== load_lib ========
- *  Recursively load library and all its dependent libraries. The library
- *  we're loading is specified by a uuid.
- */
-static int load_lib(struct nldr_nodeobject *nldr_node_obj,
-			   struct lib_node *root, struct dsp_uuid uuid,
-			   bool root_prstnt,
-			   struct dbll_library_obj **lib_path,
-			   enum nldr_phase phase, u16 depth)
-{
-	struct nldr_object *nldr_obj = nldr_node_obj->nldr_obj;
-	u16 nd_libs = 0;	/* Number of dependent libraries */
-	u16 np_libs = 0;	/* Number of persistent libraries */
-	u16 nd_libs_loaded = 0;	/* Number of dep. libraries loaded */
-	u16 i;
-	u32 entry;
-	u32 dw_buf_size = NLDR_MAXPATHLENGTH;
-	dbll_flags flags = DBLL_SYMB | DBLL_CODE | DBLL_DATA | DBLL_DYNAMIC;
-	struct dbll_attrs new_attrs;
-	char *psz_file_name = NULL;
-	struct dsp_uuid *dep_lib_uui_ds = NULL;
-	bool *persistent_dep_libs = NULL;
-	int status = 0;
-	bool lib_status = false;
-	struct lib_node *dep_lib;
-
-	if (depth > MAXDEPTH) {
-		/* Error */
-	}
-	root->lib = NULL;
-	/* Allocate a buffer for library file name of size DBL_MAXPATHLENGTH */
-	psz_file_name = kzalloc(DBLL_MAXPATHLENGTH, GFP_KERNEL);
-	if (psz_file_name == NULL)
-		status = -ENOMEM;
-
-	if (!status) {
-		/* Get the name of the library */
-		if (depth == 0) {
-			status =
-			    dcd_get_library_name(nldr_node_obj->nldr_obj->
-						 dcd_mgr, &uuid, psz_file_name,
-						 &dw_buf_size, phase,
-						 nldr_node_obj->phase_split);
-		} else {
-			/* Dependent libraries are registered with a phase */
-			status =
-			    dcd_get_library_name(nldr_node_obj->nldr_obj->
-						 dcd_mgr, &uuid, psz_file_name,
-						 &dw_buf_size, NLDR_NOPHASE,
-						 NULL);
-		}
-	}
-	if (!status) {
-		/* Open the library, don't load symbols */
-		status =
-		    nldr_obj->ldr_fxns.open_fxn(nldr_obj->dbll, psz_file_name,
-						DBLL_NOLOAD, &root->lib);
-	}
-	/* Done with file name */
-	kfree(psz_file_name);
-
-	/* Check to see if library not already loaded */
-	if (!status && root_prstnt) {
-		lib_status =
-		    find_in_persistent_lib_array(nldr_node_obj, root->lib);
-		/* Close library */
-		if (lib_status) {
-			nldr_obj->ldr_fxns.close_fxn(root->lib);
-			return 0;
-		}
-	}
-	if (!status) {
-		/* Check for circular dependencies. */
-		for (i = 0; i < depth; i++) {
-			if (root->lib == lib_path[i]) {
-				/* This condition could be checked by a
-				 * tool at build time. */
-				status = -EILSEQ;
-			}
-		}
-	}
-	if (!status) {
-		/* Add library to current path in dependency tree */
-		lib_path[depth] = root->lib;
-		depth++;
-		/* Get number of dependent libraries */
-		status =
-		    dcd_get_num_dep_libs(nldr_node_obj->nldr_obj->dcd_mgr,
-					 &uuid, &nd_libs, &np_libs, phase);
-	}
-	if (!status) {
-		if (!(*nldr_node_obj->phase_split))
-			np_libs = 0;
-
-		/* nd_libs = #of dependent libraries */
-		root->dep_libs = nd_libs - np_libs;
-		if (nd_libs > 0) {
-			dep_lib_uui_ds = kzalloc(sizeof(struct dsp_uuid) *
-							nd_libs, GFP_KERNEL);
-			persistent_dep_libs =
-				kzalloc(sizeof(bool) * nd_libs, GFP_KERNEL);
-			if (!dep_lib_uui_ds || !persistent_dep_libs)
-				status = -ENOMEM;
-
-			if (root->dep_libs > 0) {
-				/* Allocate arrays for dependent lib UUIDs,
-				 * lib nodes */
-				root->dep_libs_tree = kzalloc
-						(sizeof(struct lib_node) *
-						(root->dep_libs), GFP_KERNEL);
-				if (!(root->dep_libs_tree))
-					status = -ENOMEM;
-
-			}
-
-			if (!status) {
-				/* Get the dependent library UUIDs */
-				status =
-				    dcd_get_dep_libs(nldr_node_obj->
-						     nldr_obj->dcd_mgr, &uuid,
-						     nd_libs, dep_lib_uui_ds,
-						     persistent_dep_libs,
-						     phase);
-			}
-		}
-	}
-
-	/*
-	 *  Recursively load dependent libraries.
-	 */
-	if (!status) {
-		for (i = 0; i < nd_libs; i++) {
-			/* If root library is NOT persistent, and dep library
-			 * is, then record it.  If root library IS persistent,
-			 * the deplib is already included */
-			if (!root_prstnt && persistent_dep_libs[i] &&
-			    *nldr_node_obj->phase_split) {
-				if ((nldr_node_obj->pers_libs) >= MAXLIBS) {
-					status = -EILSEQ;
-					break;
-				}
-
-				/* Allocate library outside of phase */
-				dep_lib =
-				    &nldr_node_obj->pers_lib_table
-				    [nldr_node_obj->pers_libs];
-			} else {
-				if (root_prstnt)
-					persistent_dep_libs[i] = true;
-
-				/* Allocate library within phase */
-				dep_lib = &root->dep_libs_tree[nd_libs_loaded];
-			}
-
-			status = load_lib(nldr_node_obj, dep_lib,
-					  dep_lib_uui_ds[i],
-					  persistent_dep_libs[i], lib_path,
-					  phase, depth);
-
-			if (!status) {
-				if ((status != 0) &&
-				    !root_prstnt && persistent_dep_libs[i] &&
-				    *nldr_node_obj->phase_split) {
-					(nldr_node_obj->pers_libs)++;
-				} else {
-					if (!persistent_dep_libs[i] ||
-					    !(*nldr_node_obj->phase_split)) {
-						nd_libs_loaded++;
-					}
-				}
-			} else {
-				break;
-			}
-		}
-	}
-
-	/* Now we can load the root library */
-	if (!status) {
-		new_attrs = nldr_obj->ldr_attrs;
-		new_attrs.sym_arg = root;
-		new_attrs.rmm_handle = nldr_node_obj;
-		new_attrs.input_params = nldr_node_obj->priv_ref;
-		new_attrs.base_image = false;
-
-		status =
-		    nldr_obj->ldr_fxns.load_fxn(root->lib, flags, &new_attrs,
-						&entry);
-	}
-
-	/*
-	 *  In case of failure, unload any dependent libraries that
-	 *  were loaded, and close the root library.
-	 *  (Persistent libraries are unloaded from the very top)
-	 */
-	if (status) {
-		if (phase != NLDR_EXECUTE) {
-			for (i = 0; i < nldr_node_obj->pers_libs; i++)
-				unload_lib(nldr_node_obj,
-					   &nldr_node_obj->pers_lib_table[i]);
-
-			nldr_node_obj->pers_libs = 0;
-		}
-		for (i = 0; i < nd_libs_loaded; i++)
-			unload_lib(nldr_node_obj, &root->dep_libs_tree[i]);
-
-		if (root->lib)
-			nldr_obj->ldr_fxns.close_fxn(root->lib);
-
-	}
-
-	/* Going up one node in the dependency tree */
-	depth--;
-
-	kfree(dep_lib_uui_ds);
-	dep_lib_uui_ds = NULL;
-
-	kfree(persistent_dep_libs);
-	persistent_dep_libs = NULL;
-
-	return status;
-}
-
-/*
- *  ======== load_ovly ========
- */
-static int load_ovly(struct nldr_nodeobject *nldr_node_obj,
-			    enum nldr_phase phase)
-{
-	struct nldr_object *nldr_obj = nldr_node_obj->nldr_obj;
-	struct ovly_node *po_node = NULL;
-	struct ovly_sect *phase_sects = NULL;
-	struct ovly_sect *other_sects_list = NULL;
-	u16 i;
-	u16 alloc_num = 0;
-	u16 other_alloc = 0;
-	u16 *ref_count = NULL;
-	u16 *other_ref = NULL;
-	u32 bytes;
-	struct ovly_sect *ovly_section;
-	int status = 0;
-
-	/* Find the node in the table */
-	for (i = 0; i < nldr_obj->ovly_nodes; i++) {
-		if (is_equal_uuid
-		    (&nldr_node_obj->uuid, &nldr_obj->ovly_table[i].uuid)) {
-			/* Found it */
-			po_node = &(nldr_obj->ovly_table[i]);
-			break;
-		}
-	}
-
-
-	if (!po_node) {
-		status = -ENOENT;
-		goto func_end;
-	}
-
-	switch (phase) {
-	case NLDR_CREATE:
-		ref_count = &(po_node->create_ref);
-		other_ref = &(po_node->other_ref);
-		phase_sects = po_node->create_sects_list;
-		other_sects_list = po_node->other_sects_list;
-		break;
-
-	case NLDR_EXECUTE:
-		ref_count = &(po_node->execute_ref);
-		phase_sects = po_node->execute_sects_list;
-		break;
-
-	case NLDR_DELETE:
-		ref_count = &(po_node->delete_ref);
-		phase_sects = po_node->delete_sects_list;
-		break;
-
-	default:
-		break;
-	}
-
-	if (ref_count == NULL)
-		goto func_end;
-
-	if (*ref_count != 0)
-		goto func_end;
-
-	/* 'Allocate' memory for overlay sections of this phase */
-	ovly_section = phase_sects;
-	while (ovly_section) {
-		/* allocate *//* page not supported yet */
-		/* reserve *//* align */
-		status = rmm_alloc(nldr_obj->rmm, 0, ovly_section->size, 0,
-				   &(ovly_section->sect_run_addr), true);
-		if (!status) {
-			ovly_section = ovly_section->next_sect;
-			alloc_num++;
-		} else {
-			break;
-		}
-	}
-	if (other_ref && *other_ref == 0) {
-		/* 'Allocate' memory for other overlay sections
-		 * (create phase) */
-		if (!status) {
-			ovly_section = other_sects_list;
-			while (ovly_section) {
-				/* page not supported *//* align */
-				/* reserve */
-				status =
-				    rmm_alloc(nldr_obj->rmm, 0,
-					      ovly_section->size, 0,
-					      &(ovly_section->sect_run_addr),
-					      true);
-				if (!status) {
-					ovly_section = ovly_section->next_sect;
-					other_alloc++;
-				} else {
-					break;
-				}
-			}
-		}
-	}
-	if (*ref_count == 0) {
-		if (!status) {
-			/* Load sections for this phase */
-			ovly_section = phase_sects;
-			while (ovly_section && !status) {
-				bytes =
-				    (*nldr_obj->ovly_fxn) (nldr_node_obj->
-							   priv_ref,
-							   ovly_section->
-							   sect_run_addr,
-							   ovly_section->
-							   sect_load_addr,
-							   ovly_section->size,
-							   ovly_section->page);
-				if (bytes != ovly_section->size)
-					status = -EPERM;
-
-				ovly_section = ovly_section->next_sect;
-			}
-		}
-	}
-	if (other_ref && *other_ref == 0) {
-		if (!status) {
-			/* Load other sections (create phase) */
-			ovly_section = other_sects_list;
-			while (ovly_section && !status) {
-				bytes =
-				    (*nldr_obj->ovly_fxn) (nldr_node_obj->
-							   priv_ref,
-							   ovly_section->
-							   sect_run_addr,
-							   ovly_section->
-							   sect_load_addr,
-							   ovly_section->size,
-							   ovly_section->page);
-				if (bytes != ovly_section->size)
-					status = -EPERM;
-
-				ovly_section = ovly_section->next_sect;
-			}
-		}
-	}
-	if (status) {
-		/* 'Deallocate' memory */
-		free_sects(nldr_obj, phase_sects, alloc_num);
-		free_sects(nldr_obj, other_sects_list, other_alloc);
-	}
-func_end:
-	if (!status && (ref_count != NULL)) {
-		*ref_count += 1;
-		if (other_ref)
-			*other_ref += 1;
-
-	}
-
-	return status;
-}
-
-/*
- *  ======== remote_alloc ========
- */
-static int remote_alloc(void **ref, u16 mem_sect, u32 size,
-			       u32 align, u32 *dsp_address,
-			       s32 segmnt_id, s32 req,
-			       bool reserve)
-{
-	struct nldr_nodeobject *hnode = (struct nldr_nodeobject *)ref;
-	struct nldr_object *nldr_obj;
-	struct rmm_target_obj *rmm;
-	u16 mem_phase_bit = MAXFLAGS;
-	u16 segid = 0;
-	u16 i;
-	u16 mem_sect_type;
-	u32 word_size;
-	struct rmm_addr *rmm_addr_obj = (struct rmm_addr *)dsp_address;
-	bool mem_load_req = false;
-	int status = -ENOMEM;	/* Set to fail */
-
-	nldr_obj = hnode->nldr_obj;
-	rmm = nldr_obj->rmm;
-	/* Convert size to DSP words */
-	word_size =
-	    (size + nldr_obj->dsp_word_size -
-	     1) / nldr_obj->dsp_word_size;
-	/* Modify memory 'align' to account for DSP cache line size */
-	align = lcm(GEM_CACHE_LINE_SIZE, align);
-	dev_dbg(bridge, "%s: memory align to 0x%x\n", __func__, align);
-	if (segmnt_id != -1) {
-		rmm_addr_obj->segid = segmnt_id;
-		segid = segmnt_id;
-		mem_load_req = req;
-	} else {
-		switch (hnode->phase) {
-		case NLDR_CREATE:
-			mem_phase_bit = CREATEDATAFLAGBIT;
-			break;
-		case NLDR_DELETE:
-			mem_phase_bit = DELETEDATAFLAGBIT;
-			break;
-		case NLDR_EXECUTE:
-			mem_phase_bit = EXECUTEDATAFLAGBIT;
-			break;
-		default:
-			break;
-		}
-		if (mem_sect == DBLL_CODE)
-			mem_phase_bit++;
-
-		if (mem_phase_bit < MAXFLAGS)
-			segid = hnode->seg_id[mem_phase_bit];
-
-		/* Determine if there is a memory loading requirement */
-		if ((hnode->code_data_flag_mask >> mem_phase_bit) & 0x1)
-			mem_load_req = true;
-
-	}
-	mem_sect_type = (mem_sect == DBLL_CODE) ? DYNM_CODE : DYNM_DATA;
-
-	/* Find an appropriate segment based on mem_sect */
-	if (segid == NULLID) {
-		/* No memory requirements of preferences */
-		goto func_cont;
-	}
-	if (segid <= MAXSEGID) {
-		/* Attempt to allocate from segid first. */
-		rmm_addr_obj->segid = segid;
-		status =
-		    rmm_alloc(rmm, segid, word_size, align, dsp_address, false);
-		if (status) {
-			dev_dbg(bridge, "%s: Unable allocate from segment %d\n",
-				__func__, segid);
-		}
-	} else {
-		/* segid > MAXSEGID ==> Internal or external memory */
-		/*  Check for any internal or external memory segment,
-		 *  depending on segid. */
-		mem_sect_type |= segid == MEMINTERNALID ?
-		    DYNM_INTERNAL : DYNM_EXTERNAL;
-		for (i = 0; i < nldr_obj->dload_segs; i++) {
-			if ((nldr_obj->seg_table[i] & mem_sect_type) !=
-			    mem_sect_type)
-				continue;
-
-			status = rmm_alloc(rmm, i, word_size, align,
-					dsp_address, false);
-			if (!status) {
-				/* Save segid for freeing later */
-				rmm_addr_obj->segid = i;
-				break;
-			}
-		}
-	}
-func_cont:
-	/* Haven't found memory yet, attempt to find any segment that works */
-	if (status == -ENOMEM && !mem_load_req) {
-		dev_dbg(bridge, "%s: Preferred segment unavailable, trying "
-			"another\n", __func__);
-		for (i = 0; i < nldr_obj->dload_segs; i++) {
-			/* All bits of mem_sect_type must be set */
-			if ((nldr_obj->seg_table[i] & mem_sect_type) !=
-			    mem_sect_type)
-				continue;
-
-			status = rmm_alloc(rmm, i, word_size, align,
-					   dsp_address, false);
-			if (!status) {
-				/* Save segid */
-				rmm_addr_obj->segid = i;
-				break;
-			}
-		}
-	}
-
-	return status;
-}
-
-static int remote_free(void **ref, u16 space, u32 dsp_address,
-			      u32 size, bool reserve)
-{
-	struct nldr_object *nldr_obj = (struct nldr_object *)ref;
-	struct rmm_target_obj *rmm;
-	u32 word_size;
-	int status = -ENOMEM;	/* Set to fail */
-
-	rmm = nldr_obj->rmm;
-
-	/* Convert size to DSP words */
-	word_size =
-	    (size + nldr_obj->dsp_word_size -
-	     1) / nldr_obj->dsp_word_size;
-
-	if (rmm_free(rmm, space, dsp_address, word_size, reserve))
-		status = 0;
-
-	return status;
-}
-
-/*
- *  ======== unload_lib ========
- */
-static void unload_lib(struct nldr_nodeobject *nldr_node_obj,
-		       struct lib_node *root)
-{
-	struct dbll_attrs new_attrs;
-	struct nldr_object *nldr_obj = nldr_node_obj->nldr_obj;
-	u16 i;
-
-
-	/* Unload dependent libraries */
-	for (i = 0; i < root->dep_libs; i++)
-		unload_lib(nldr_node_obj, &root->dep_libs_tree[i]);
-
-	root->dep_libs = 0;
-
-	new_attrs = nldr_obj->ldr_attrs;
-	new_attrs.rmm_handle = nldr_obj->rmm;
-	new_attrs.input_params = nldr_node_obj->priv_ref;
-	new_attrs.base_image = false;
-	new_attrs.sym_arg = root;
-
-	if (root->lib) {
-		/* Unload the root library */
-		nldr_obj->ldr_fxns.unload_fxn(root->lib, &new_attrs);
-		nldr_obj->ldr_fxns.close_fxn(root->lib);
-	}
-
-	/* Free dependent library list */
-	kfree(root->dep_libs_tree);
-	root->dep_libs_tree = NULL;
-}
-
-/*
- *  ======== unload_ovly ========
- */
-static void unload_ovly(struct nldr_nodeobject *nldr_node_obj,
-			enum nldr_phase phase)
-{
-	struct nldr_object *nldr_obj = nldr_node_obj->nldr_obj;
-	struct ovly_node *po_node = NULL;
-	struct ovly_sect *phase_sects = NULL;
-	struct ovly_sect *other_sects_list = NULL;
-	u16 i;
-	u16 alloc_num = 0;
-	u16 other_alloc = 0;
-	u16 *ref_count = NULL;
-	u16 *other_ref = NULL;
-
-	/* Find the node in the table */
-	for (i = 0; i < nldr_obj->ovly_nodes; i++) {
-		if (is_equal_uuid
-		    (&nldr_node_obj->uuid, &nldr_obj->ovly_table[i].uuid)) {
-			/* Found it */
-			po_node = &(nldr_obj->ovly_table[i]);
-			break;
-		}
-	}
-
-
-	if (!po_node)
-		/* TODO: Should we print warning here? */
-		return;
-
-	switch (phase) {
-	case NLDR_CREATE:
-		ref_count = &(po_node->create_ref);
-		phase_sects = po_node->create_sects_list;
-		alloc_num = po_node->create_sects;
-		break;
-	case NLDR_EXECUTE:
-		ref_count = &(po_node->execute_ref);
-		phase_sects = po_node->execute_sects_list;
-		alloc_num = po_node->execute_sects;
-		break;
-	case NLDR_DELETE:
-		ref_count = &(po_node->delete_ref);
-		other_ref = &(po_node->other_ref);
-		phase_sects = po_node->delete_sects_list;
-		/* 'Other' overlay sections are unloaded in the delete phase */
-		other_sects_list = po_node->other_sects_list;
-		alloc_num = po_node->delete_sects;
-		other_alloc = po_node->other_sects;
-		break;
-	default:
-		break;
-	}
-	if (ref_count && (*ref_count > 0)) {
-		*ref_count -= 1;
-		if (other_ref)
-			*other_ref -= 1;
-	}
-
-	if (ref_count && *ref_count == 0) {
-		/* 'Deallocate' memory */
-		free_sects(nldr_obj, phase_sects, alloc_num);
-	}
-	if (other_ref && *other_ref == 0)
-		free_sects(nldr_obj, other_sects_list, other_alloc);
-}
-
-/*
- *  ======== find_in_persistent_lib_array ========
- */
-static bool find_in_persistent_lib_array(struct nldr_nodeobject *nldr_node_obj,
-					 struct dbll_library_obj *lib)
-{
-	s32 i = 0;
-
-	for (i = 0; i < nldr_node_obj->pers_libs; i++) {
-		if (lib == nldr_node_obj->pers_lib_table[i].lib)
-			return true;
-
-	}
-
-	return false;
-}
-
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-/**
- * nldr_find_addr() - Find the closest symbol to the given address based on
- *		dynamic node object.
- *
- * @nldr_node:		Dynamic node object
- * @sym_addr:		Given address to find the dsp symbol
- * @offset_range:		offset range to look for dsp symbol
- * @offset_output:		Symbol Output address
- * @sym_name:		String with the dsp symbol
- *
- * 	This function finds the node library for a given address and
- *	retrieves the dsp symbol by calling dbll_find_dsp_symbol.
- */
-int nldr_find_addr(struct nldr_nodeobject *nldr_node, u32 sym_addr,
-			u32 offset_range, void *offset_output, char *sym_name)
-{
-	int status = 0;
-	bool status1 = false;
-	s32 i = 0;
-	struct lib_node root = { NULL, 0, NULL };
-
-	if (nldr_node->dynamic && *nldr_node->phase_split) {
-		switch (nldr_node->phase) {
-		case NLDR_CREATE:
-			root = nldr_node->create_lib;
-			break;
-		case NLDR_EXECUTE:
-			root = nldr_node->execute_lib;
-			break;
-		case NLDR_DELETE:
-			root = nldr_node->delete_lib;
-			break;
-		default:
-			break;
-		}
-	} else {
-		/* for Overlay nodes or non-split Dynamic nodes */
-		root = nldr_node->root;
-	}
-
-	status1 = dbll_find_dsp_symbol(root.lib, sym_addr,
-			offset_range, offset_output, sym_name);
-
-	/* If symbol not found, check dependent libraries */
-	if (!status1)
-		for (i = 0; i < root.dep_libs; i++) {
-			status1 = dbll_find_dsp_symbol(
-				root.dep_libs_tree[i].lib, sym_addr,
-				offset_range, offset_output, sym_name);
-			if (status1)
-				/* Symbol found */
-				break;
-		}
-	/* Check persistent libraries */
-	if (!status1)
-		for (i = 0; i < nldr_node->pers_libs; i++) {
-			status1 = dbll_find_dsp_symbol(
-				nldr_node->pers_lib_table[i].lib, sym_addr,
-				offset_range, offset_output, sym_name);
-			if (status1)
-				/* Symbol found */
-				break;
-		}
-
-	if (!status1) {
-		pr_debug("%s: Address 0x%x not found in range %d.\n",
-					__func__, sym_addr, offset_range);
-		status = -ESPIPE;
-	} else {
-		pr_debug("%s(0x%x, 0x%x, 0x%x, 0x%x,  %s)\n",
-			 __func__, (u32) nldr_node, sym_addr, offset_range,
-			 (u32) offset_output, sym_name);
-	}
-
-	return status;
-}
-#endif
diff --git a/drivers/staging/tidspbridge/rmgr/node.c b/drivers/staging/tidspbridge/rmgr/node.c
deleted file mode 100644
index 133f2db..0000000
--- a/drivers/staging/tidspbridge/rmgr/node.c
+++ /dev/null
@@ -1,3031 +0,0 @@
-/*
- * node.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP/BIOS Bridge Node Manager.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/types.h>
-#include <linux/bitmap.h>
-#include <linux/list.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/memdefs.h>
-#include <dspbridge/proc.h>
-#include <dspbridge/strm.h>
-#include <dspbridge/sync.h>
-#include <dspbridge/ntfy.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/cmm.h>
-#include <dspbridge/cod.h>
-#include <dspbridge/dev.h>
-#include <dspbridge/msg.h>
-
-/*  ----------------------------------- Resource Manager */
-#include <dspbridge/dbdcd.h>
-#include <dspbridge/disp.h>
-#include <dspbridge/rms_sh.h>
-
-/*  ----------------------------------- Link Driver */
-#include <dspbridge/dspdefs.h>
-#include <dspbridge/dspioctl.h>
-
-/*  ----------------------------------- Others */
-#include <dspbridge/uuidutil.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/nodepriv.h>
-#include <dspbridge/node.h>
-#include <dspbridge/dmm.h>
-
-/* Static/Dynamic Loader includes */
-#include <dspbridge/dbll.h>
-#include <dspbridge/nldr.h>
-
-#include <dspbridge/drv.h>
-#include <dspbridge/resourcecleanup.h>
-#include <_tiomap.h>
-
-#include <dspbridge/dspdeh.h>
-
-#define HOSTPREFIX	  "/host"
-#define PIPEPREFIX	  "/dbpipe"
-
-#define MAX_INPUTS(h)  \
-		((h)->dcd_props.obj_data.node_obj.ndb_props.num_input_streams)
-#define MAX_OUTPUTS(h) \
-		((h)->dcd_props.obj_data.node_obj.ndb_props.num_output_streams)
-
-#define NODE_GET_PRIORITY(h) ((h)->prio)
-#define NODE_SET_PRIORITY(hnode, prio) ((hnode)->prio = prio)
-#define NODE_SET_STATE(hnode, state) ((hnode)->node_state = state)
-
-#define MAXPIPES	100	/* Max # of /pipe connections (CSL limit) */
-#define MAXDEVSUFFIXLEN 2	/* Max(Log base 10 of MAXPIPES, MAXSTREAMS) */
-
-#define PIPENAMELEN     (sizeof(PIPEPREFIX) + MAXDEVSUFFIXLEN)
-#define HOSTNAMELEN     (sizeof(HOSTPREFIX) + MAXDEVSUFFIXLEN)
-
-#define MAXDEVNAMELEN	32	/* dsp_ndbprops.ac_name size */
-#define CREATEPHASE	1
-#define EXECUTEPHASE	2
-#define DELETEPHASE	3
-
-/* Define default STRM parameters */
-/*
- *  TBD: Put in header file, make global DSP_STRMATTRS with defaults,
- *  or make defaults configurable.
- */
-#define DEFAULTBUFSIZE		32
-#define DEFAULTNBUFS		2
-#define DEFAULTSEGID		0
-#define DEFAULTALIGNMENT	0
-#define DEFAULTTIMEOUT		10000
-
-#define RMSQUERYSERVER		0
-#define RMSCONFIGURESERVER	1
-#define RMSCREATENODE		2
-#define RMSEXECUTENODE		3
-#define RMSDELETENODE		4
-#define RMSCHANGENODEPRIORITY	5
-#define RMSREADMEMORY		6
-#define RMSWRITEMEMORY		7
-#define RMSCOPY			8
-#define MAXTIMEOUT		2000
-
-#define NUMRMSFXNS		9
-
-#define PWR_TIMEOUT		500	/* default PWR timeout in msec */
-
-#define STACKSEGLABEL "L1DSRAM_HEAP"	/* Label for DSP Stack Segment Addr */
-
-/*
- *  ======== node_mgr ========
- */
-struct node_mgr {
-	struct dev_object *dev_obj;	/* Device object */
-	/* Function interface to Bridge driver */
-	struct bridge_drv_interface *intf_fxns;
-	struct dcd_manager *dcd_mgr;	/* Proc/Node data manager */
-	struct disp_object *disp_obj;	/* Node dispatcher */
-	struct list_head node_list;	/* List of all allocated nodes */
-	u32 num_nodes;		/* Number of nodes in node_list */
-	u32 num_created;	/* Number of nodes *created* on DSP */
-	DECLARE_BITMAP(pipe_map, MAXPIPES); /* Pipe connection bitmap */
-	DECLARE_BITMAP(pipe_done_map, MAXPIPES); /* Pipes that are half free */
-	/* Channel allocation bitmap */
-	DECLARE_BITMAP(chnl_map, CHNL_MAXCHANNELS);
-	/* DMA Channel allocation bitmap */
-	DECLARE_BITMAP(dma_chnl_map, CHNL_MAXCHANNELS);
-	/* Zero-Copy Channel alloc bitmap */
-	DECLARE_BITMAP(zc_chnl_map, CHNL_MAXCHANNELS);
-	struct ntfy_object *ntfy_obj;	/* Manages registered notifications */
-	struct mutex node_mgr_lock;	/* For critical sections */
-	u32 fxn_addrs[NUMRMSFXNS];	/* RMS function addresses */
-	struct msg_mgr *msg_mgr_obj;
-
-	/* Processor properties needed by Node Dispatcher */
-	u32 num_chnls;		/* Total number of channels */
-	u32 chnl_offset;	/* Offset of chnl ids rsvd for RMS */
-	u32 chnl_buf_size;	/* Buffer size for data to RMS */
-	int proc_family;	/* eg, 5000 */
-	int proc_type;		/* eg, 5510 */
-	u32 dsp_word_size;	/* Size of DSP word on host bytes */
-	u32 dsp_data_mau_size;	/* Size of DSP data MAU */
-	u32 dsp_mau_size;	/* Size of MAU */
-	s32 min_pri;		/* Minimum runtime priority for node */
-	s32 max_pri;		/* Maximum runtime priority for node */
-
-	struct strm_mgr *strm_mgr_obj;	/* STRM manager */
-
-	/* Loader properties */
-	struct nldr_object *nldr_obj;	/* Handle to loader */
-	struct node_ldr_fxns nldr_fxns;	/* Handle to loader functions */
-};
-
-/*
- *  ======== connecttype ========
- */
-enum connecttype {
-	NOTCONNECTED = 0,
-	NODECONNECT,
-	HOSTCONNECT,
-	DEVICECONNECT,
-};
-
-/*
- *  ======== stream_chnl ========
- */
-struct stream_chnl {
-	enum connecttype type;	/* Type of stream connection */
-	u32 dev_id;		/* pipe or channel id */
-};
-
-/*
- *  ======== node_object ========
- */
-struct node_object {
-	struct list_head list_elem;
-	struct node_mgr *node_mgr;	/* The manager of this node */
-	struct proc_object *processor;	/* Back pointer to processor */
-	struct dsp_uuid node_uuid;	/* Node's ID */
-	s32 prio;		/* Node's current priority */
-	u32 timeout;		/* Timeout for blocking NODE calls */
-	u32 heap_size;		/* Heap Size */
-	u32 dsp_heap_virt_addr;	/* Heap Size */
-	u32 gpp_heap_virt_addr;	/* Heap Size */
-	enum node_type ntype;	/* Type of node: message, task, etc */
-	enum node_state node_state;	/* NODE_ALLOCATED, NODE_CREATED, ... */
-	u32 num_inputs;		/* Current number of inputs */
-	u32 num_outputs;	/* Current number of outputs */
-	u32 max_input_index;	/* Current max input stream index */
-	u32 max_output_index;	/* Current max output stream index */
-	struct stream_chnl *inputs;	/* Node's input streams */
-	struct stream_chnl *outputs;	/* Node's output streams */
-	struct node_createargs create_args;	/* Args for node create func */
-	nodeenv node_env;	/* Environment returned by RMS */
-	struct dcd_genericobj dcd_props;	/* Node properties from DCD */
-	struct dsp_cbdata *args;	/* Optional args to pass to node */
-	struct ntfy_object *ntfy_obj;	/* Manages registered notifications */
-	char *str_dev_name;	/* device name, if device node */
-	struct sync_object *sync_done;	/* Synchronize node_terminate */
-	s32 exit_status;	/* execute function return status */
-
-	/* Information needed for node_get_attr() */
-	void *device_owner;	/* If dev node, task that owns it */
-	u32 num_gpp_inputs;	/* Current # of from GPP streams */
-	u32 num_gpp_outputs;	/* Current # of to GPP streams */
-	/* Current stream connections */
-	struct dsp_streamconnect *stream_connect;
-
-	/* Message queue */
-	struct msg_queue *msg_queue_obj;
-
-	/* These fields used for SM messaging */
-	struct cmm_xlatorobject *xlator;	/* Node's SM addr translator */
-
-	/* Handle to pass to dynamic loader */
-	struct nldr_nodeobject *nldr_node_obj;
-	bool loaded;		/* Code is (dynamically) loaded */
-	bool phase_split;	/* Phases split in many libs or ovly */
-
-};
-
-/* Default buffer attributes */
-static struct dsp_bufferattr node_dfltbufattrs = {
-	.cb_struct = 0,
-	.segment_id = 1,
-	.buf_alignment = 0,
-};
-
-static void delete_node(struct node_object *hnode,
-			struct process_context *pr_ctxt);
-static void delete_node_mgr(struct node_mgr *hnode_mgr);
-static void fill_stream_connect(struct node_object *node1,
-				struct node_object *node2, u32 stream1,
-				u32 stream2);
-static void fill_stream_def(struct node_object *hnode,
-			    struct node_strmdef *pstrm_def,
-			    struct dsp_strmattr *pattrs);
-static void free_stream(struct node_mgr *hnode_mgr, struct stream_chnl stream);
-static int get_fxn_address(struct node_object *hnode, u32 *fxn_addr,
-				  u32 phase);
-static int get_node_props(struct dcd_manager *hdcd_mgr,
-				 struct node_object *hnode,
-				 const struct dsp_uuid *node_uuid,
-				 struct dcd_genericobj *dcd_prop);
-static int get_proc_props(struct node_mgr *hnode_mgr,
-				 struct dev_object *hdev_obj);
-static int get_rms_fxns(struct node_mgr *hnode_mgr);
-static u32 ovly(void *priv_ref, u32 dsp_run_addr, u32 dsp_load_addr,
-		u32 ul_num_bytes, u32 mem_space);
-static u32 mem_write(void *priv_ref, u32 dsp_add, void *pbuf,
-		     u32 ul_num_bytes, u32 mem_space);
-
-/* Dynamic loader functions. */
-static struct node_ldr_fxns nldr_fxns = {
-	nldr_allocate,
-	nldr_create,
-	nldr_delete,
-	nldr_get_fxn_addr,
-	nldr_load,
-	nldr_unload,
-};
-
-enum node_state node_get_state(void *hnode)
-{
-	struct node_object *pnode = (struct node_object *)hnode;
-
-	if (!pnode)
-		return -1;
-	return pnode->node_state;
-}
-
-/*
- *  ======== node_allocate ========
- *  Purpose:
- *      Allocate GPP resources to manage a node on the DSP.
- */
-int node_allocate(struct proc_object *hprocessor,
-			const struct dsp_uuid *node_uuid,
-			const struct dsp_cbdata *pargs,
-			const struct dsp_nodeattrin *attr_in,
-			struct node_res_object **noderes,
-			struct process_context *pr_ctxt)
-{
-	struct node_mgr *hnode_mgr;
-	struct dev_object *hdev_obj;
-	struct node_object *pnode = NULL;
-	enum node_type node_type = NODE_TASK;
-	struct node_msgargs *pmsg_args;
-	struct node_taskargs *ptask_args;
-	u32 num_streams;
-	struct bridge_drv_interface *intf_fxns;
-	int status = 0;
-	struct cmm_object *hcmm_mgr = NULL;	/* Shared memory manager hndl */
-	u32 proc_id;
-	u32 pul_value;
-	u32 dynext_base;
-	u32 off_set = 0;
-	u32 ul_stack_seg_val;
-	struct cfg_hostres *host_res;
-	struct bridge_dev_context *pbridge_context;
-	u32 mapped_addr = 0;
-	u32 map_attrs = 0x0;
-	struct dsp_processorstate proc_state;
-#ifdef DSP_DMM_DEBUG
-	struct dmm_object *dmm_mgr;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-#endif
-
-	void *node_res;
-
-	*noderes = NULL;
-
-	status = proc_get_processor_id(hprocessor, &proc_id);
-
-	if (proc_id != DSP_UNIT)
-		goto func_end;
-
-	status = proc_get_dev_object(hprocessor, &hdev_obj);
-	if (!status) {
-		status = dev_get_node_manager(hdev_obj, &hnode_mgr);
-		if (hnode_mgr == NULL)
-			status = -EPERM;
-
-	}
-
-	if (status)
-		goto func_end;
-
-	status = dev_get_bridge_context(hdev_obj, &pbridge_context);
-	if (!pbridge_context) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	status = proc_get_state(hprocessor, &proc_state,
-				sizeof(struct dsp_processorstate));
-	if (status)
-		goto func_end;
-	/* If processor is in error state then don't attempt
-	   to send the message */
-	if (proc_state.proc_state == PROC_ERROR) {
-		status = -EPERM;
-		goto func_end;
-	}
-
-	/* Assuming that 0 is not a valid function address */
-	if (hnode_mgr->fxn_addrs[0] == 0) {
-		/* No RMS on target - we currently can't handle this */
-		pr_err("%s: Failed, no RMS in base image\n", __func__);
-		status = -EPERM;
-	} else {
-		/* Validate attr_in fields, if non-NULL */
-		if (attr_in) {
-			/* Check if attr_in->prio is within range */
-			if (attr_in->prio < hnode_mgr->min_pri ||
-			    attr_in->prio > hnode_mgr->max_pri)
-				status = -EDOM;
-		}
-	}
-	/* Allocate node object and fill in */
-	if (status)
-		goto func_end;
-
-	pnode = kzalloc(sizeof(struct node_object), GFP_KERNEL);
-	if (pnode == NULL) {
-		status = -ENOMEM;
-		goto func_end;
-	}
-	pnode->node_mgr = hnode_mgr;
-	/* This critical section protects get_node_props */
-	mutex_lock(&hnode_mgr->node_mgr_lock);
-
-	/* Get dsp_ndbprops from node database */
-	status = get_node_props(hnode_mgr->dcd_mgr, pnode, node_uuid,
-				&(pnode->dcd_props));
-	if (status)
-		goto func_cont;
-
-	pnode->node_uuid = *node_uuid;
-	pnode->processor = hprocessor;
-	pnode->ntype = pnode->dcd_props.obj_data.node_obj.ndb_props.ntype;
-	pnode->timeout = pnode->dcd_props.obj_data.node_obj.ndb_props.timeout;
-	pnode->prio = pnode->dcd_props.obj_data.node_obj.ndb_props.prio;
-
-	/* Currently only C64 DSP builds support Node Dynamic * heaps */
-	/* Allocate memory for node heap */
-	pnode->create_args.asa.task_arg_obj.heap_size = 0;
-	pnode->create_args.asa.task_arg_obj.dsp_heap_addr = 0;
-	pnode->create_args.asa.task_arg_obj.dsp_heap_res_addr = 0;
-	pnode->create_args.asa.task_arg_obj.gpp_heap_addr = 0;
-	if (!attr_in)
-		goto func_cont;
-
-	/* Check if we have a user allocated node heap */
-	if (!(attr_in->pgpp_virt_addr))
-		goto func_cont;
-
-	/* check for page aligned Heap size */
-	if (((attr_in->heap_size) & (PG_SIZE4K - 1))) {
-		pr_err("%s: node heap size not aligned to 4K, size = 0x%x\n",
-		       __func__, attr_in->heap_size);
-		status = -EINVAL;
-	} else {
-		pnode->create_args.asa.task_arg_obj.heap_size =
-		    attr_in->heap_size;
-		pnode->create_args.asa.task_arg_obj.gpp_heap_addr =
-		    (u32) attr_in->pgpp_virt_addr;
-	}
-	if (status)
-		goto func_cont;
-
-	status = proc_reserve_memory(hprocessor,
-				     pnode->create_args.asa.task_arg_obj.
-				     heap_size + PAGE_SIZE,
-				     (void **)&(pnode->create_args.asa.
-					task_arg_obj.dsp_heap_res_addr),
-				     pr_ctxt);
-	if (status) {
-		pr_err("%s: Failed to reserve memory for heap: 0x%x\n",
-		       __func__, status);
-		goto func_cont;
-	}
-#ifdef DSP_DMM_DEBUG
-	status = dmm_get_handle(p_proc_object, &dmm_mgr);
-	if (!dmm_mgr) {
-		status = DSP_EHANDLE;
-		goto func_cont;
-	}
-
-	dmm_mem_map_dump(dmm_mgr);
-#endif
-
-	map_attrs |= DSP_MAPLITTLEENDIAN;
-	map_attrs |= DSP_MAPELEMSIZE32;
-	map_attrs |= DSP_MAPVIRTUALADDR;
-	status = proc_map(hprocessor, (void *)attr_in->pgpp_virt_addr,
-			  pnode->create_args.asa.task_arg_obj.heap_size,
-			  (void *)pnode->create_args.asa.task_arg_obj.
-			  dsp_heap_res_addr, (void **)&mapped_addr, map_attrs,
-			  pr_ctxt);
-	if (status)
-		pr_err("%s: Failed to map memory for Heap: 0x%x\n",
-		       __func__, status);
-	else
-		pnode->create_args.asa.task_arg_obj.dsp_heap_addr =
-		    (u32) mapped_addr;
-
-func_cont:
-	mutex_unlock(&hnode_mgr->node_mgr_lock);
-	if (attr_in != NULL) {
-		/* Overrides of NBD properties */
-		pnode->timeout = attr_in->timeout;
-		pnode->prio = attr_in->prio;
-	}
-	/* Create object to manage notifications */
-	if (!status) {
-		pnode->ntfy_obj = kmalloc(sizeof(struct ntfy_object),
-							GFP_KERNEL);
-		if (pnode->ntfy_obj)
-			ntfy_init(pnode->ntfy_obj);
-		else
-			status = -ENOMEM;
-	}
-
-	if (!status) {
-		node_type = node_get_type(pnode);
-		/*  Allocate dsp_streamconnect array for device, task, and
-		 *  dais socket nodes. */
-		if (node_type != NODE_MESSAGE) {
-			num_streams = MAX_INPUTS(pnode) + MAX_OUTPUTS(pnode);
-			pnode->stream_connect = kzalloc(num_streams *
-					sizeof(struct dsp_streamconnect),
-					GFP_KERNEL);
-			if (num_streams > 0 && pnode->stream_connect == NULL)
-				status = -ENOMEM;
-
-		}
-		if (!status && (node_type == NODE_TASK ||
-					      node_type == NODE_DAISSOCKET)) {
-			/* Allocate arrays for maintainig stream connections */
-			pnode->inputs = kzalloc(MAX_INPUTS(pnode) *
-					sizeof(struct stream_chnl), GFP_KERNEL);
-			pnode->outputs = kzalloc(MAX_OUTPUTS(pnode) *
-					sizeof(struct stream_chnl), GFP_KERNEL);
-			ptask_args = &(pnode->create_args.asa.task_arg_obj);
-			ptask_args->strm_in_def = kzalloc(MAX_INPUTS(pnode) *
-						sizeof(struct node_strmdef),
-						GFP_KERNEL);
-			ptask_args->strm_out_def = kzalloc(MAX_OUTPUTS(pnode) *
-						sizeof(struct node_strmdef),
-						GFP_KERNEL);
-			if ((MAX_INPUTS(pnode) > 0 && (pnode->inputs == NULL ||
-						       ptask_args->strm_in_def
-						       == NULL))
-			    || (MAX_OUTPUTS(pnode) > 0
-				&& (pnode->outputs == NULL
-				    || ptask_args->strm_out_def == NULL)))
-				status = -ENOMEM;
-		}
-	}
-	if (!status && (node_type != NODE_DEVICE)) {
-		/* Create an event that will be posted when RMS_EXIT is
-		 * received. */
-		pnode->sync_done = kzalloc(sizeof(struct sync_object),
-								GFP_KERNEL);
-		if (pnode->sync_done)
-			sync_init_event(pnode->sync_done);
-		else
-			status = -ENOMEM;
-
-		if (!status) {
-			/*Get the shared mem mgr for this nodes dev object */
-			status = cmm_get_handle(hprocessor, &hcmm_mgr);
-			if (!status) {
-				/* Allocate a SM addr translator for this node
-				 * w/ deflt attr */
-				status = cmm_xlator_create(&pnode->xlator,
-							   hcmm_mgr, NULL);
-			}
-		}
-		if (!status) {
-			/* Fill in message args */
-			if ((pargs != NULL) && (pargs->cb_data > 0)) {
-				pmsg_args =
-				    &(pnode->create_args.asa.node_msg_args);
-				pmsg_args->pdata = kzalloc(pargs->cb_data,
-								GFP_KERNEL);
-				if (pmsg_args->pdata == NULL) {
-					status = -ENOMEM;
-				} else {
-					pmsg_args->arg_length = pargs->cb_data;
-					memcpy(pmsg_args->pdata,
-					       pargs->node_data,
-					       pargs->cb_data);
-				}
-			}
-		}
-	}
-
-	if (!status && node_type != NODE_DEVICE) {
-		/* Create a message queue for this node */
-		intf_fxns = hnode_mgr->intf_fxns;
-		status =
-		    (*intf_fxns->msg_create_queue) (hnode_mgr->msg_mgr_obj,
-							&pnode->msg_queue_obj,
-							0,
-							pnode->create_args.asa.
-							node_msg_args.max_msgs,
-							pnode);
-	}
-
-	if (!status) {
-		/* Create object for dynamic loading */
-
-		status = hnode_mgr->nldr_fxns.allocate(hnode_mgr->nldr_obj,
-							   (void *)pnode,
-							   &pnode->dcd_props.
-							   obj_data.node_obj,
-							   &pnode->
-							   nldr_node_obj,
-							   &pnode->phase_split);
-	}
-
-	/* Compare value read from Node Properties and check if it is same as
-	 * STACKSEGLABEL, if yes read the Address of STACKSEGLABEL, calculate
-	 * GPP Address, Read the value in that address and override the
-	 * stack_seg value in task args */
-	if (!status &&
-	    (char *)pnode->dcd_props.obj_data.node_obj.ndb_props.
-	    stack_seg_name != NULL) {
-		if (strcmp((char *)
-			   pnode->dcd_props.obj_data.node_obj.ndb_props.
-			   stack_seg_name, STACKSEGLABEL) == 0) {
-			void __iomem *stack_seg;
-			u32 stack_seg_pa;
-
-			status =
-			    hnode_mgr->nldr_fxns.
-			    get_fxn_addr(pnode->nldr_node_obj, "DYNEXT_BEG",
-					     &dynext_base);
-			if (status)
-				pr_err("%s: Failed to get addr for DYNEXT_BEG"
-				       " status = 0x%x\n", __func__, status);
-
-			status =
-			    hnode_mgr->nldr_fxns.
-			    get_fxn_addr(pnode->nldr_node_obj,
-					     "L1DSRAM_HEAP", &pul_value);
-
-			if (status)
-				pr_err("%s: Failed to get addr for L1DSRAM_HEAP"
-				       " status = 0x%x\n", __func__, status);
-
-			host_res = pbridge_context->resources;
-			if (!host_res)
-				status = -EPERM;
-
-			if (status) {
-				pr_err("%s: Failed to get host resource, status"
-				       " = 0x%x\n", __func__, status);
-				goto func_end;
-			}
-
-			off_set = pul_value - dynext_base;
-			stack_seg_pa = host_res->mem_phys[1] + off_set;
-			stack_seg = ioremap(stack_seg_pa, SZ_32);
-			if (!stack_seg) {
-				status = -ENOMEM;
-				goto func_end;
-			}
-
-			ul_stack_seg_val = readl(stack_seg);
-
-			iounmap(stack_seg);
-
-			dev_dbg(bridge, "%s: StackSegVal = 0x%x, StackSegAddr ="
-				" 0x%x\n", __func__, ul_stack_seg_val,
-				host_res->mem_base[1] + off_set);
-
-			pnode->create_args.asa.task_arg_obj.stack_seg =
-			    ul_stack_seg_val;
-
-		}
-	}
-
-	if (!status) {
-		/* Add the node to the node manager's list of allocated
-		 * nodes. */
-		NODE_SET_STATE(pnode, NODE_ALLOCATED);
-
-		mutex_lock(&hnode_mgr->node_mgr_lock);
-
-		list_add_tail(&pnode->list_elem, &hnode_mgr->node_list);
-		++(hnode_mgr->num_nodes);
-
-		/* Exit critical section */
-		mutex_unlock(&hnode_mgr->node_mgr_lock);
-
-		/* Preset this to assume phases are split
-		 * (for overlay and dll) */
-		pnode->phase_split = true;
-
-		/* Notify all clients registered for DSP_NODESTATECHANGE. */
-		proc_notify_all_clients(hprocessor, DSP_NODESTATECHANGE);
-	} else {
-		/* Cleanup */
-		if (pnode)
-			delete_node(pnode, pr_ctxt);
-
-	}
-
-	if (!status) {
-		status = drv_insert_node_res_element(pnode, &node_res, pr_ctxt);
-		if (status) {
-			delete_node(pnode, pr_ctxt);
-			goto func_end;
-		}
-
-		*noderes = (struct node_res_object *)node_res;
-		drv_proc_node_update_heap_status(node_res, true);
-		drv_proc_node_update_status(node_res, true);
-	}
-func_end:
-	dev_dbg(bridge, "%s: hprocessor: %p pNodeId: %p pargs: %p attr_in: %p "
-		"node_res: %p status: 0x%x\n", __func__, hprocessor,
-		node_uuid, pargs, attr_in, noderes, status);
-	return status;
-}
-
-/*
- *  ======== node_alloc_msg_buf ========
- *  Purpose:
- *      Allocates buffer for zero copy messaging.
- */
-DBAPI node_alloc_msg_buf(struct node_object *hnode, u32 usize,
-			 struct dsp_bufferattr *pattr,
-			 u8 **pbuffer)
-{
-	struct node_object *pnode = (struct node_object *)hnode;
-	int status = 0;
-	bool va_flag = false;
-	bool set_info;
-	u32 proc_id;
-
-	if (!pnode)
-		status = -EFAULT;
-	else if (node_get_type(pnode) == NODE_DEVICE)
-		status = -EPERM;
-
-	if (status)
-		goto func_end;
-
-	if (pattr == NULL)
-		pattr = &node_dfltbufattrs;	/* set defaults */
-
-	status = proc_get_processor_id(pnode->processor, &proc_id);
-	if (proc_id != DSP_UNIT)
-		goto func_end;
-
-	/*  If segment ID includes MEM_SETVIRTUALSEGID then pbuffer is a
-	 *  virt  address, so set this info in this node's translator
-	 *  object for  future ref. If MEM_GETVIRTUALSEGID then retrieve
-	 *  virtual address  from node's translator. */
-	if ((pattr->segment_id & MEM_SETVIRTUALSEGID) ||
-	    (pattr->segment_id & MEM_GETVIRTUALSEGID)) {
-		va_flag = true;
-		set_info = (pattr->segment_id & MEM_SETVIRTUALSEGID) ?
-		    true : false;
-		/* Clear mask bits */
-		pattr->segment_id &= ~MEM_MASKVIRTUALSEGID;
-		/* Set/get this node's translators virtual address base/size */
-		status = cmm_xlator_info(pnode->xlator, pbuffer, usize,
-					 pattr->segment_id, set_info);
-	}
-	if (!status && (!va_flag)) {
-		if (pattr->segment_id != 1) {
-			/* Node supports single SM segment only. */
-			status = -EBADR;
-		}
-		/*  Arbitrary SM buffer alignment not supported for host side
-		 *  allocs, but guaranteed for the following alignment
-		 *  values. */
-		switch (pattr->buf_alignment) {
-		case 0:
-		case 1:
-		case 2:
-		case 4:
-			break;
-		default:
-			/* alignment value not supportted */
-			status = -EPERM;
-			break;
-		}
-		if (!status) {
-			/* allocate physical buffer from seg_id in node's
-			 * translator */
-			(void)cmm_xlator_alloc_buf(pnode->xlator, pbuffer,
-						   usize);
-			if (*pbuffer == NULL) {
-				pr_err("%s: error - Out of shared memory\n",
-				       __func__);
-				status = -ENOMEM;
-			}
-		}
-	}
-func_end:
-	return status;
-}
-
-/*
- *  ======== node_change_priority ========
- *  Purpose:
- *      Change the priority of a node in the allocated state, or that is
- *      currently running or paused on the target.
- */
-int node_change_priority(struct node_object *hnode, s32 prio)
-{
-	struct node_object *pnode = (struct node_object *)hnode;
-	struct node_mgr *hnode_mgr = NULL;
-	enum node_type node_type;
-	enum node_state state;
-	int status = 0;
-	u32 proc_id;
-
-	if (!hnode || !hnode->node_mgr) {
-		status = -EFAULT;
-	} else {
-		hnode_mgr = hnode->node_mgr;
-		node_type = node_get_type(hnode);
-		if (node_type != NODE_TASK && node_type != NODE_DAISSOCKET)
-			status = -EPERM;
-		else if (prio < hnode_mgr->min_pri || prio > hnode_mgr->max_pri)
-			status = -EDOM;
-	}
-	if (status)
-		goto func_end;
-
-	/* Enter critical section */
-	mutex_lock(&hnode_mgr->node_mgr_lock);
-
-	state = node_get_state(hnode);
-	if (state == NODE_ALLOCATED || state == NODE_PAUSED) {
-		NODE_SET_PRIORITY(hnode, prio);
-	} else {
-		if (state != NODE_RUNNING) {
-			status = -EBADR;
-			goto func_cont;
-		}
-		status = proc_get_processor_id(pnode->processor, &proc_id);
-		if (proc_id == DSP_UNIT) {
-			status =
-			    disp_node_change_priority(hnode_mgr->disp_obj,
-						      hnode,
-						      hnode_mgr->fxn_addrs
-						      [RMSCHANGENODEPRIORITY],
-						      hnode->node_env, prio);
-		}
-		if (status >= 0)
-			NODE_SET_PRIORITY(hnode, prio);
-
-	}
-func_cont:
-	/* Leave critical section */
-	mutex_unlock(&hnode_mgr->node_mgr_lock);
-func_end:
-	return status;
-}
-
-/*
- *  ======== node_connect ========
- *  Purpose:
- *      Connect two nodes on the DSP, or a node on the DSP to the GPP.
- */
-int node_connect(struct node_object *node1, u32 stream1,
-			struct node_object *node2,
-			u32 stream2, struct dsp_strmattr *pattrs,
-			struct dsp_cbdata *conn_param)
-{
-	struct node_mgr *hnode_mgr;
-	char *pstr_dev_name = NULL;
-	enum node_type node1_type = NODE_TASK;
-	enum node_type node2_type = NODE_TASK;
-	enum dsp_strmmode strm_mode;
-	struct node_strmdef *pstrm_def;
-	struct node_strmdef *input = NULL;
-	struct node_strmdef *output = NULL;
-	struct node_object *dev_node_obj;
-	struct node_object *hnode;
-	struct stream_chnl *pstream;
-	u32 pipe_id;
-	u32 chnl_id;
-	s8 chnl_mode;
-	u32 dw_length;
-	int status = 0;
-
-	if (!node1 || !node2)
-		return -EFAULT;
-
-	/* The two nodes must be on the same processor */
-	if (node1 != (struct node_object *)DSP_HGPPNODE &&
-			node2 != (struct node_object *)DSP_HGPPNODE &&
-			node1->node_mgr != node2->node_mgr)
-		return -EPERM;
-
-	/* Cannot connect a node to itself */
-	if (node1 == node2)
-		return -EPERM;
-
-	/* node_get_type() will return NODE_GPP if hnode =  DSP_HGPPNODE. */
-	node1_type = node_get_type(node1);
-	node2_type = node_get_type(node2);
-	/* Check stream indices ranges */
-	if ((node1_type != NODE_GPP && node1_type != NODE_DEVICE &&
-				stream1 >= MAX_OUTPUTS(node1)) ||
-			(node2_type != NODE_GPP && node2_type != NODE_DEVICE &&
-			 stream2 >= MAX_INPUTS(node2)))
-		return -EINVAL;
-
-	/*
-	 *  Only the following types of connections are allowed:
-	 *      task/dais socket < == > task/dais socket
-	 *      task/dais socket < == > device
-	 *      task/dais socket < == > GPP
-	 *
-	 *  ie, no message nodes, and at least one task or dais
-	 *  socket node.
-	 */
-	if (node1_type == NODE_MESSAGE || node2_type == NODE_MESSAGE ||
-			(node1_type != NODE_TASK &&
-			 node1_type != NODE_DAISSOCKET &&
-			 node2_type != NODE_TASK &&
-			 node2_type != NODE_DAISSOCKET))
-		return -EPERM;
-	/*
-	 * Check stream mode. Default is STRMMODE_PROCCOPY.
-	 */
-	if (pattrs && pattrs->strm_mode != STRMMODE_PROCCOPY)
-		return -EPERM;	/* illegal stream mode */
-
-	if (node1_type != NODE_GPP)
-		hnode_mgr = node1->node_mgr;
-	else
-		hnode_mgr = node2->node_mgr;
-
-	/* Enter critical section */
-	mutex_lock(&hnode_mgr->node_mgr_lock);
-
-	/* Nodes must be in the allocated state */
-	if (node1_type != NODE_GPP &&
-			node_get_state(node1) != NODE_ALLOCATED) {
-		status = -EBADR;
-		goto out_unlock;
-	}
-
-	if (node2_type != NODE_GPP &&
-			node_get_state(node2) != NODE_ALLOCATED) {
-		status = -EBADR;
-		goto out_unlock;
-	}
-
-	/*
-	 *  Check that stream indices for task and dais socket nodes
-	 *  are not already be used. (Device nodes checked later)
-	 */
-	if (node1_type == NODE_TASK || node1_type == NODE_DAISSOCKET) {
-		output = &(node1->create_args.asa.
-				task_arg_obj.strm_out_def[stream1]);
-		if (output->sz_device) {
-			status = -EISCONN;
-			goto out_unlock;
-		}
-
-	}
-	if (node2_type == NODE_TASK || node2_type == NODE_DAISSOCKET) {
-		input = &(node2->create_args.asa.
-				task_arg_obj.strm_in_def[stream2]);
-		if (input->sz_device) {
-			status = -EISCONN;
-			goto out_unlock;
-		}
-
-	}
-	/* Connecting two task nodes? */
-	if ((node1_type == NODE_TASK || node1_type == NODE_DAISSOCKET) &&
-				(node2_type == NODE_TASK ||
-				 node2_type == NODE_DAISSOCKET)) {
-		/* Find available pipe */
-		pipe_id = find_first_zero_bit(hnode_mgr->pipe_map, MAXPIPES);
-		if (pipe_id == MAXPIPES) {
-			status = -ECONNREFUSED;
-			goto out_unlock;
-		}
-		set_bit(pipe_id, hnode_mgr->pipe_map);
-		node1->outputs[stream1].type = NODECONNECT;
-		node2->inputs[stream2].type = NODECONNECT;
-		node1->outputs[stream1].dev_id = pipe_id;
-		node2->inputs[stream2].dev_id = pipe_id;
-		output->sz_device = kzalloc(PIPENAMELEN + 1, GFP_KERNEL);
-		input->sz_device = kzalloc(PIPENAMELEN + 1, GFP_KERNEL);
-		if (!output->sz_device || !input->sz_device) {
-			/* Undo the connection */
-			kfree(output->sz_device);
-			kfree(input->sz_device);
-			clear_bit(pipe_id, hnode_mgr->pipe_map);
-			status = -ENOMEM;
-			goto out_unlock;
-		}
-		/* Copy "/dbpipe<pipId>" name to device names */
-		sprintf(output->sz_device, "%s%d", PIPEPREFIX, pipe_id);
-		strcpy(input->sz_device, output->sz_device);
-	}
-	/* Connecting task node to host? */
-	if (node1_type == NODE_GPP || node2_type == NODE_GPP) {
-		pstr_dev_name = kzalloc(HOSTNAMELEN + 1, GFP_KERNEL);
-		if (!pstr_dev_name) {
-			status = -ENOMEM;
-			goto out_unlock;
-		}
-
-		chnl_mode = (node1_type == NODE_GPP) ?
-			CHNL_MODETODSP : CHNL_MODEFROMDSP;
-
-		/*
-		 *  Reserve a channel id. We need to put the name "/host<id>"
-		 *  in the node's create_args, but the host
-		 *  side channel will not be opened until DSPStream_Open is
-		 *  called for this node.
-		 */
-		strm_mode = pattrs ? pattrs->strm_mode : STRMMODE_PROCCOPY;
-		switch (strm_mode) {
-		case STRMMODE_RDMA:
-			chnl_id = find_first_zero_bit(hnode_mgr->dma_chnl_map,
-					CHNL_MAXCHANNELS);
-			if (chnl_id < CHNL_MAXCHANNELS) {
-				set_bit(chnl_id, hnode_mgr->dma_chnl_map);
-				/* dma chans are 2nd transport chnl set
-				 * ids(e.g. 16-31) */
-				chnl_id = chnl_id + hnode_mgr->num_chnls;
-			}
-			break;
-		case STRMMODE_ZEROCOPY:
-			chnl_id = find_first_zero_bit(hnode_mgr->zc_chnl_map,
-					CHNL_MAXCHANNELS);
-			if (chnl_id < CHNL_MAXCHANNELS) {
-				set_bit(chnl_id, hnode_mgr->zc_chnl_map);
-				/* zero-copy chans are 3nd transport set
-				 * (e.g. 32-47) */
-				chnl_id = chnl_id +
-					(2 * hnode_mgr->num_chnls);
-			}
-			break;
-		case STRMMODE_PROCCOPY:
-			chnl_id = find_first_zero_bit(hnode_mgr->chnl_map,
-					CHNL_MAXCHANNELS);
-			if (chnl_id < CHNL_MAXCHANNELS)
-				set_bit(chnl_id, hnode_mgr->chnl_map);
-			break;
-		default:
-			status = -EINVAL;
-			goto out_unlock;
-		}
-		if (chnl_id == CHNL_MAXCHANNELS) {
-			status = -ECONNREFUSED;
-			goto out_unlock;
-		}
-
-		if (node1 == (struct node_object *)DSP_HGPPNODE) {
-			node2->inputs[stream2].type = HOSTCONNECT;
-			node2->inputs[stream2].dev_id = chnl_id;
-			input->sz_device = pstr_dev_name;
-		} else {
-			node1->outputs[stream1].type = HOSTCONNECT;
-			node1->outputs[stream1].dev_id = chnl_id;
-			output->sz_device = pstr_dev_name;
-		}
-		sprintf(pstr_dev_name, "%s%d", HOSTPREFIX, chnl_id);
-	}
-	/* Connecting task node to device node? */
-	if ((node1_type == NODE_DEVICE) || (node2_type == NODE_DEVICE)) {
-		if (node2_type == NODE_DEVICE) {
-			/* node1 == > device */
-			dev_node_obj = node2;
-			hnode = node1;
-			pstream = &(node1->outputs[stream1]);
-			pstrm_def = output;
-		} else {
-			/* device == > node2 */
-			dev_node_obj = node1;
-			hnode = node2;
-			pstream = &(node2->inputs[stream2]);
-			pstrm_def = input;
-		}
-		/* Set up create args */
-		pstream->type = DEVICECONNECT;
-		dw_length = strlen(dev_node_obj->str_dev_name);
-		if (conn_param)
-			pstrm_def->sz_device = kzalloc(dw_length + 1 +
-					conn_param->cb_data,
-					GFP_KERNEL);
-		else
-			pstrm_def->sz_device = kzalloc(dw_length + 1,
-					GFP_KERNEL);
-		if (!pstrm_def->sz_device) {
-			status = -ENOMEM;
-			goto out_unlock;
-		}
-		/* Copy device name */
-		strncpy(pstrm_def->sz_device,
-				dev_node_obj->str_dev_name, dw_length);
-		if (conn_param)
-			strncat(pstrm_def->sz_device,
-					(char *)conn_param->node_data,
-					(u32) conn_param->cb_data);
-		dev_node_obj->device_owner = hnode;
-	}
-	/* Fill in create args */
-	if (node1_type == NODE_TASK || node1_type == NODE_DAISSOCKET) {
-		node1->create_args.asa.task_arg_obj.num_outputs++;
-		fill_stream_def(node1, output, pattrs);
-	}
-	if (node2_type == NODE_TASK || node2_type == NODE_DAISSOCKET) {
-		node2->create_args.asa.task_arg_obj.num_inputs++;
-		fill_stream_def(node2, input, pattrs);
-	}
-	/* Update node1 and node2 stream_connect */
-	if (node1_type != NODE_GPP && node1_type != NODE_DEVICE) {
-		node1->num_outputs++;
-		if (stream1 > node1->max_output_index)
-			node1->max_output_index = stream1;
-
-	}
-	if (node2_type != NODE_GPP && node2_type != NODE_DEVICE) {
-		node2->num_inputs++;
-		if (stream2 > node2->max_input_index)
-			node2->max_input_index = stream2;
-
-	}
-	fill_stream_connect(node1, node2, stream1, stream2);
-	/* end of sync_enter_cs */
-	/* Exit critical section */
-out_unlock:
-	if (status && pstr_dev_name)
-		kfree(pstr_dev_name);
-	mutex_unlock(&hnode_mgr->node_mgr_lock);
-	dev_dbg(bridge, "%s: node1: %p stream1: %d node2: %p stream2: %d"
-			"pattrs: %p status: 0x%x\n", __func__, node1,
-			stream1, node2, stream2, pattrs, status);
-	return status;
-}
-
-/*
- *  ======== node_create ========
- *  Purpose:
- *      Create a node on the DSP by remotely calling the node's create function.
- */
-int node_create(struct node_object *hnode)
-{
-	struct node_object *pnode = (struct node_object *)hnode;
-	struct node_mgr *hnode_mgr;
-	struct bridge_drv_interface *intf_fxns;
-	u32 ul_create_fxn;
-	enum node_type node_type;
-	int status = 0;
-	int status1 = 0;
-	struct dsp_cbdata cb_data;
-	u32 proc_id = 255;
-	struct dsp_processorstate proc_state;
-	struct proc_object *hprocessor;
-#if defined(CONFIG_TIDSPBRIDGE_DVFS) && !defined(CONFIG_CPU_FREQ)
-	struct dspbridge_platform_data *pdata =
-	    omap_dspbridge_dev->dev.platform_data;
-#endif
-
-	if (!pnode) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	hprocessor = hnode->processor;
-	status = proc_get_state(hprocessor, &proc_state,
-				sizeof(struct dsp_processorstate));
-	if (status)
-		goto func_end;
-	/* If processor is in error state then don't attempt to create
-	   new node */
-	if (proc_state.proc_state == PROC_ERROR) {
-		status = -EPERM;
-		goto func_end;
-	}
-	/* create struct dsp_cbdata struct for PWR calls */
-	cb_data.cb_data = PWR_TIMEOUT;
-	node_type = node_get_type(hnode);
-	hnode_mgr = hnode->node_mgr;
-	intf_fxns = hnode_mgr->intf_fxns;
-	/* Get access to node dispatcher */
-	mutex_lock(&hnode_mgr->node_mgr_lock);
-
-	/* Check node state */
-	if (node_get_state(hnode) != NODE_ALLOCATED)
-		status = -EBADR;
-
-	if (!status)
-		status = proc_get_processor_id(pnode->processor, &proc_id);
-
-	if (status)
-		goto func_cont2;
-
-	if (proc_id != DSP_UNIT)
-		goto func_cont2;
-
-	/* Make sure streams are properly connected */
-	if ((hnode->num_inputs && hnode->max_input_index >
-	     hnode->num_inputs - 1) ||
-	    (hnode->num_outputs && hnode->max_output_index >
-	     hnode->num_outputs - 1))
-		status = -ENOTCONN;
-
-	if (!status) {
-		/* If node's create function is not loaded, load it */
-		/* Boost the OPP level to max level that DSP can be requested */
-#if defined(CONFIG_TIDSPBRIDGE_DVFS) && !defined(CONFIG_CPU_FREQ)
-		if (pdata->cpu_set_freq)
-			(*pdata->cpu_set_freq) (pdata->mpu_speed[VDD1_OPP3]);
-#endif
-		status = hnode_mgr->nldr_fxns.load(hnode->nldr_node_obj,
-						       NLDR_CREATE);
-		/* Get address of node's create function */
-		if (!status) {
-			hnode->loaded = true;
-			if (node_type != NODE_DEVICE) {
-				status = get_fxn_address(hnode, &ul_create_fxn,
-							 CREATEPHASE);
-			}
-		} else {
-			pr_err("%s: failed to load create code: 0x%x\n",
-			       __func__, status);
-		}
-		/* Request the lowest OPP level */
-#if defined(CONFIG_TIDSPBRIDGE_DVFS) && !defined(CONFIG_CPU_FREQ)
-		if (pdata->cpu_set_freq)
-			(*pdata->cpu_set_freq) (pdata->mpu_speed[VDD1_OPP1]);
-#endif
-		/* Get address of iAlg functions, if socket node */
-		if (!status) {
-			if (node_type == NODE_DAISSOCKET) {
-				status = hnode_mgr->nldr_fxns.get_fxn_addr
-				    (hnode->nldr_node_obj,
-				     hnode->dcd_props.obj_data.node_obj.
-				     str_i_alg_name,
-				     &hnode->create_args.asa.
-				     task_arg_obj.dais_arg);
-			}
-		}
-	}
-	if (!status) {
-		if (node_type != NODE_DEVICE) {
-			status = disp_node_create(hnode_mgr->disp_obj, hnode,
-						  hnode_mgr->fxn_addrs
-						  [RMSCREATENODE],
-						  ul_create_fxn,
-						  &(hnode->create_args),
-						  &(hnode->node_env));
-			if (status >= 0) {
-				/* Set the message queue id to the node env
-				 * pointer */
-				intf_fxns = hnode_mgr->intf_fxns;
-				(*intf_fxns->msg_set_queue_id) (hnode->
-							msg_queue_obj,
-							hnode->node_env);
-			}
-		}
-	}
-	/*  Phase II/Overlays: Create, execute, delete phases  possibly in
-	 *  different files/sections. */
-	if (hnode->loaded && hnode->phase_split) {
-		/* If create code was dynamically loaded, we can now unload
-		 * it. */
-		status1 = hnode_mgr->nldr_fxns.unload(hnode->nldr_node_obj,
-							  NLDR_CREATE);
-		hnode->loaded = false;
-	}
-	if (status1)
-		pr_err("%s: Failed to unload create code: 0x%x\n",
-		       __func__, status1);
-func_cont2:
-	/* Update node state and node manager state */
-	if (status >= 0) {
-		NODE_SET_STATE(hnode, NODE_CREATED);
-		hnode_mgr->num_created++;
-		goto func_cont;
-	}
-	if (status != -EBADR) {
-		/* Put back in NODE_ALLOCATED state if error occurred */
-		NODE_SET_STATE(hnode, NODE_ALLOCATED);
-	}
-func_cont:
-	/* Free access to node dispatcher */
-	mutex_unlock(&hnode_mgr->node_mgr_lock);
-func_end:
-	if (status >= 0) {
-		proc_notify_clients(hnode->processor, DSP_NODESTATECHANGE);
-		ntfy_notify(hnode->ntfy_obj, DSP_NODESTATECHANGE);
-	}
-
-	dev_dbg(bridge, "%s: hnode: %p status: 0x%x\n", __func__,
-		hnode, status);
-	return status;
-}
-
-/*
- *  ======== node_create_mgr ========
- *  Purpose:
- *      Create a NODE Manager object.
- */
-int node_create_mgr(struct node_mgr **node_man,
-			   struct dev_object *hdev_obj)
-{
-	u32 i;
-	struct node_mgr *node_mgr_obj = NULL;
-	struct disp_attr disp_attr_obj;
-	char *sz_zl_file = "";
-	struct nldr_attrs nldr_attrs_obj;
-	int status = 0;
-	u8 dev_type;
-
-	*node_man = NULL;
-	/* Allocate Node manager object */
-	node_mgr_obj = kzalloc(sizeof(struct node_mgr), GFP_KERNEL);
-	if (!node_mgr_obj)
-		return -ENOMEM;
-
-	node_mgr_obj->dev_obj = hdev_obj;
-
-	node_mgr_obj->ntfy_obj = kmalloc(sizeof(struct ntfy_object),
-			GFP_KERNEL);
-	if (!node_mgr_obj->ntfy_obj) {
-		status = -ENOMEM;
-		goto out_err;
-	}
-	ntfy_init(node_mgr_obj->ntfy_obj);
-
-	INIT_LIST_HEAD(&node_mgr_obj->node_list);
-
-	dev_get_dev_type(hdev_obj, &dev_type);
-
-	status = dcd_create_manager(sz_zl_file, &node_mgr_obj->dcd_mgr);
-	if (status)
-		goto out_err;
-
-	status = get_proc_props(node_mgr_obj, hdev_obj);
-	if (status)
-		goto out_err;
-
-	/* Create NODE Dispatcher */
-	disp_attr_obj.chnl_offset = node_mgr_obj->chnl_offset;
-	disp_attr_obj.chnl_buf_size = node_mgr_obj->chnl_buf_size;
-	disp_attr_obj.proc_family = node_mgr_obj->proc_family;
-	disp_attr_obj.proc_type = node_mgr_obj->proc_type;
-
-	status = disp_create(&node_mgr_obj->disp_obj, hdev_obj, &disp_attr_obj);
-	if (status)
-		goto out_err;
-
-	/* Create a STRM Manager */
-	status = strm_create(&node_mgr_obj->strm_mgr_obj, hdev_obj);
-	if (status)
-		goto out_err;
-
-	dev_get_intf_fxns(hdev_obj, &node_mgr_obj->intf_fxns);
-	/* Get msg_ctrl queue manager */
-	dev_get_msg_mgr(hdev_obj, &node_mgr_obj->msg_mgr_obj);
-	mutex_init(&node_mgr_obj->node_mgr_lock);
-
-	/* Block out reserved channels */
-	for (i = 0; i < node_mgr_obj->chnl_offset; i++)
-		set_bit(i, node_mgr_obj->chnl_map);
-
-	/* Block out channels reserved for RMS */
-	set_bit(node_mgr_obj->chnl_offset, node_mgr_obj->chnl_map);
-	set_bit(node_mgr_obj->chnl_offset + 1, node_mgr_obj->chnl_map);
-
-	/* NO RM Server on the IVA */
-	if (dev_type != IVA_UNIT) {
-		/* Get addresses of any RMS functions loaded */
-		status = get_rms_fxns(node_mgr_obj);
-		if (status)
-			goto out_err;
-	}
-
-	/* Get loader functions and create loader */
-	node_mgr_obj->nldr_fxns = nldr_fxns;	/* Dyn loader funcs */
-
-	nldr_attrs_obj.ovly = ovly;
-	nldr_attrs_obj.write = mem_write;
-	nldr_attrs_obj.dsp_word_size = node_mgr_obj->dsp_word_size;
-	nldr_attrs_obj.dsp_mau_size = node_mgr_obj->dsp_mau_size;
-	status = node_mgr_obj->nldr_fxns.create(&node_mgr_obj->nldr_obj,
-			hdev_obj,
-			&nldr_attrs_obj);
-	if (status)
-		goto out_err;
-
-	*node_man = node_mgr_obj;
-
-	return status;
-out_err:
-	delete_node_mgr(node_mgr_obj);
-	return status;
-}
-
-/*
- *  ======== node_delete ========
- *  Purpose:
- *      Delete a node on the DSP by remotely calling the node's delete function.
- *      Loads the node's delete function if necessary. Free GPP side resources
- *      after node's delete function returns.
- */
-int node_delete(struct node_res_object *noderes,
-		       struct process_context *pr_ctxt)
-{
-	struct node_object *pnode = noderes->node;
-	struct node_mgr *hnode_mgr;
-	struct proc_object *hprocessor;
-	struct disp_object *disp_obj;
-	u32 ul_delete_fxn;
-	enum node_type node_type;
-	enum node_state state;
-	int status = 0;
-	int status1 = 0;
-	struct dsp_cbdata cb_data;
-	u32 proc_id;
-	struct bridge_drv_interface *intf_fxns;
-
-	void *node_res = noderes;
-
-	struct dsp_processorstate proc_state;
-
-	if (!pnode) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	/* create struct dsp_cbdata struct for PWR call */
-	cb_data.cb_data = PWR_TIMEOUT;
-	hnode_mgr = pnode->node_mgr;
-	hprocessor = pnode->processor;
-	disp_obj = hnode_mgr->disp_obj;
-	node_type = node_get_type(pnode);
-	intf_fxns = hnode_mgr->intf_fxns;
-	/* Enter critical section */
-	mutex_lock(&hnode_mgr->node_mgr_lock);
-
-	state = node_get_state(pnode);
-	/*  Execute delete phase code for non-device node in all cases
-	 *  except when the node was only allocated. Delete phase must be
-	 *  executed even if create phase was executed, but failed.
-	 *  If the node environment pointer is non-NULL, the delete phase
-	 *  code must be  executed. */
-	if (!(state == NODE_ALLOCATED && pnode->node_env == (u32) NULL) &&
-	    node_type != NODE_DEVICE) {
-		status = proc_get_processor_id(pnode->processor, &proc_id);
-		if (status)
-			goto func_cont1;
-
-		if (proc_id == DSP_UNIT || proc_id == IVA_UNIT) {
-			/*  If node has terminated, execute phase code will
-			 *  have already been unloaded in node_on_exit(). If the
-			 *  node is PAUSED, the execute phase is loaded, and it
-			 *  is now ok to unload it. If the node is running, we
-			 *  will unload the execute phase only after deleting
-			 *  the node. */
-			if (state == NODE_PAUSED && pnode->loaded &&
-			    pnode->phase_split) {
-				/* Ok to unload execute code as long as node
-				 * is not * running */
-				status1 =
-				    hnode_mgr->nldr_fxns.
-				    unload(pnode->nldr_node_obj,
-					       NLDR_EXECUTE);
-				pnode->loaded = false;
-				NODE_SET_STATE(pnode, NODE_DONE);
-			}
-			/* Load delete phase code if not loaded or if haven't
-			 * * unloaded EXECUTE phase */
-			if ((!(pnode->loaded) || (state == NODE_RUNNING)) &&
-			    pnode->phase_split) {
-				status =
-				    hnode_mgr->nldr_fxns.
-				    load(pnode->nldr_node_obj, NLDR_DELETE);
-				if (!status)
-					pnode->loaded = true;
-				else
-					pr_err("%s: fail - load delete code:"
-					       " 0x%x\n", __func__, status);
-			}
-		}
-func_cont1:
-		if (!status) {
-			/* Unblock a thread trying to terminate the node */
-			(void)sync_set_event(pnode->sync_done);
-			if (proc_id == DSP_UNIT) {
-				/* ul_delete_fxn = address of node's delete
-				 * function */
-				status = get_fxn_address(pnode, &ul_delete_fxn,
-							 DELETEPHASE);
-			} else if (proc_id == IVA_UNIT)
-				ul_delete_fxn = (u32) pnode->node_env;
-			if (!status) {
-				status = proc_get_state(hprocessor,
-						&proc_state,
-						sizeof(struct
-						       dsp_processorstate));
-				if (proc_state.proc_state != PROC_ERROR) {
-					status =
-					    disp_node_delete(disp_obj, pnode,
-							     hnode_mgr->
-							     fxn_addrs
-							     [RMSDELETENODE],
-							     ul_delete_fxn,
-							     pnode->node_env);
-				} else
-					NODE_SET_STATE(pnode, NODE_DONE);
-
-				/* Unload execute, if not unloaded, and delete
-				 * function */
-				if (state == NODE_RUNNING &&
-				    pnode->phase_split) {
-					status1 =
-					    hnode_mgr->nldr_fxns.
-					    unload(pnode->nldr_node_obj,
-						       NLDR_EXECUTE);
-				}
-				if (status1)
-					pr_err("%s: fail - unload execute code:"
-					       " 0x%x\n", __func__, status1);
-
-				status1 =
-				    hnode_mgr->nldr_fxns.unload(pnode->
-							    nldr_node_obj,
-							    NLDR_DELETE);
-				pnode->loaded = false;
-				if (status1)
-					pr_err("%s: fail - unload delete code: "
-					       "0x%x\n", __func__, status1);
-			}
-		}
-	}
-	/* Free host side resources even if a failure occurred */
-	/* Remove node from hnode_mgr->node_list */
-	list_del(&pnode->list_elem);
-	hnode_mgr->num_nodes--;
-	/* Decrement count of nodes created on DSP */
-	if ((state != NODE_ALLOCATED) || ((state == NODE_ALLOCATED) &&
-					  (pnode->node_env != (u32) NULL)))
-		hnode_mgr->num_created--;
-	/*  Free host-side resources allocated by node_create()
-	 *  delete_node() fails if SM buffers not freed by client! */
-	drv_proc_node_update_status(node_res, false);
-	delete_node(pnode, pr_ctxt);
-
-	/*
-	 * Release all Node resources and its context
-	 */
-	idr_remove(pr_ctxt->node_id, ((struct node_res_object *)node_res)->id);
-	kfree(node_res);
-
-	/* Exit critical section */
-	mutex_unlock(&hnode_mgr->node_mgr_lock);
-	proc_notify_clients(hprocessor, DSP_NODESTATECHANGE);
-func_end:
-	dev_dbg(bridge, "%s: pnode: %p status 0x%x\n", __func__, pnode, status);
-	return status;
-}
-
-/*
- *  ======== node_delete_mgr ========
- *  Purpose:
- *      Delete the NODE Manager.
- */
-int node_delete_mgr(struct node_mgr *hnode_mgr)
-{
-	if (!hnode_mgr)
-		return -EFAULT;
-
-	delete_node_mgr(hnode_mgr);
-
-	return 0;
-}
-
-/*
- *  ======== node_enum_nodes ========
- *  Purpose:
- *      Enumerate currently allocated nodes.
- */
-int node_enum_nodes(struct node_mgr *hnode_mgr, void **node_tab,
-			   u32 node_tab_size, u32 *pu_num_nodes,
-			   u32 *pu_allocated)
-{
-	struct node_object *hnode;
-	u32 i = 0;
-	int status = 0;
-
-	if (!hnode_mgr) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	/* Enter critical section */
-	mutex_lock(&hnode_mgr->node_mgr_lock);
-
-	if (hnode_mgr->num_nodes > node_tab_size) {
-		*pu_allocated = hnode_mgr->num_nodes;
-		*pu_num_nodes = 0;
-		status = -EINVAL;
-	} else {
-		list_for_each_entry(hnode, &hnode_mgr->node_list, list_elem)
-			node_tab[i++] = hnode;
-		*pu_allocated = *pu_num_nodes = hnode_mgr->num_nodes;
-	}
-	/* end of sync_enter_cs */
-	/* Exit critical section */
-	mutex_unlock(&hnode_mgr->node_mgr_lock);
-func_end:
-	return status;
-}
-
-/*
- *  ======== node_free_msg_buf ========
- *  Purpose:
- *      Frees the message buffer.
- */
-int node_free_msg_buf(struct node_object *hnode, u8 *pbuffer,
-			     struct dsp_bufferattr *pattr)
-{
-	struct node_object *pnode = (struct node_object *)hnode;
-	int status = 0;
-	u32 proc_id;
-
-	if (!hnode) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	status = proc_get_processor_id(pnode->processor, &proc_id);
-	if (proc_id == DSP_UNIT) {
-		if (!status) {
-			if (pattr == NULL) {
-				/* set defaults */
-				pattr = &node_dfltbufattrs;
-			}
-			/* Node supports single SM segment only */
-			if (pattr->segment_id != 1)
-				status = -EBADR;
-
-			/* pbuffer is clients Va. */
-			status = cmm_xlator_free_buf(pnode->xlator, pbuffer);
-		}
-	} else {
-	}
-func_end:
-	return status;
-}
-
-/*
- *  ======== node_get_attr ========
- *  Purpose:
- *      Copy the current attributes of the specified node into a dsp_nodeattr
- *      structure.
- */
-int node_get_attr(struct node_object *hnode,
-			 struct dsp_nodeattr *pattr, u32 attr_size)
-{
-	struct node_mgr *hnode_mgr;
-
-	if (!hnode)
-		return -EFAULT;
-
-	hnode_mgr = hnode->node_mgr;
-	/* Enter hnode_mgr critical section since we're accessing
-	 * data that could be changed by node_change_priority() and
-	 * node_connect(). */
-	mutex_lock(&hnode_mgr->node_mgr_lock);
-	pattr->cb_struct = sizeof(struct dsp_nodeattr);
-	/* dsp_nodeattrin */
-	pattr->in_node_attr_in.cb_struct =
-		sizeof(struct dsp_nodeattrin);
-	pattr->in_node_attr_in.prio = hnode->prio;
-	pattr->in_node_attr_in.timeout = hnode->timeout;
-	pattr->in_node_attr_in.heap_size =
-		hnode->create_args.asa.task_arg_obj.heap_size;
-	pattr->in_node_attr_in.pgpp_virt_addr = (void *)
-		hnode->create_args.asa.task_arg_obj.gpp_heap_addr;
-	pattr->node_attr_inputs = hnode->num_gpp_inputs;
-	pattr->node_attr_outputs = hnode->num_gpp_outputs;
-	/* dsp_nodeinfo */
-	get_node_info(hnode, &(pattr->node_info));
-	/* end of sync_enter_cs */
-	/* Exit critical section */
-	mutex_unlock(&hnode_mgr->node_mgr_lock);
-
-	return 0;
-}
-
-/*
- *  ======== node_get_channel_id ========
- *  Purpose:
- *      Get the channel index reserved for a stream connection between the
- *      host and a node.
- */
-int node_get_channel_id(struct node_object *hnode, u32 dir, u32 index,
-			       u32 *chan_id)
-{
-	enum node_type node_type;
-	int status = -EINVAL;
-
-	if (!hnode) {
-		status = -EFAULT;
-		return status;
-	}
-	node_type = node_get_type(hnode);
-	if (node_type != NODE_TASK && node_type != NODE_DAISSOCKET) {
-		status = -EPERM;
-		return status;
-	}
-	if (dir == DSP_TONODE) {
-		if (index < MAX_INPUTS(hnode)) {
-			if (hnode->inputs[index].type == HOSTCONNECT) {
-				*chan_id = hnode->inputs[index].dev_id;
-				status = 0;
-			}
-		}
-	} else {
-		if (index < MAX_OUTPUTS(hnode)) {
-			if (hnode->outputs[index].type == HOSTCONNECT) {
-				*chan_id = hnode->outputs[index].dev_id;
-				status = 0;
-			}
-		}
-	}
-	return status;
-}
-
-/*
- *  ======== node_get_message ========
- *  Purpose:
- *      Retrieve a message from a node on the DSP.
- */
-int node_get_message(struct node_object *hnode,
-			    struct dsp_msg *message, u32 utimeout)
-{
-	struct node_mgr *hnode_mgr;
-	enum node_type node_type;
-	struct bridge_drv_interface *intf_fxns;
-	int status = 0;
-	void *tmp_buf;
-	struct dsp_processorstate proc_state;
-	struct proc_object *hprocessor;
-
-	if (!hnode) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	hprocessor = hnode->processor;
-	status = proc_get_state(hprocessor, &proc_state,
-				sizeof(struct dsp_processorstate));
-	if (status)
-		goto func_end;
-	/* If processor is in error state then don't attempt to get the
-	   message */
-	if (proc_state.proc_state == PROC_ERROR) {
-		status = -EPERM;
-		goto func_end;
-	}
-	hnode_mgr = hnode->node_mgr;
-	node_type = node_get_type(hnode);
-	if (node_type != NODE_MESSAGE && node_type != NODE_TASK &&
-	    node_type != NODE_DAISSOCKET) {
-		status = -EPERM;
-		goto func_end;
-	}
-	/*  This function will block unless a message is available. Since
-	 *  DSPNode_RegisterNotify() allows notification when a message
-	 *  is available, the system can be designed so that
-	 *  DSPNode_GetMessage() is only called when a message is
-	 *  available. */
-	intf_fxns = hnode_mgr->intf_fxns;
-	status =
-	    (*intf_fxns->msg_get) (hnode->msg_queue_obj, message, utimeout);
-	/* Check if message contains SM descriptor */
-	if (status || !(message->cmd & DSP_RMSBUFDESC))
-		goto func_end;
-
-	/* Translate DSP byte addr to GPP Va. */
-	tmp_buf = cmm_xlator_translate(hnode->xlator,
-				       (void *)(message->arg1 *
-						hnode->node_mgr->
-						dsp_word_size), CMM_DSPPA2PA);
-	if (tmp_buf != NULL) {
-		/* now convert this GPP Pa to Va */
-		tmp_buf = cmm_xlator_translate(hnode->xlator, tmp_buf,
-					       CMM_PA2VA);
-		if (tmp_buf != NULL) {
-			/* Adjust SM size in msg */
-			message->arg1 = (u32) tmp_buf;
-			message->arg2 *= hnode->node_mgr->dsp_word_size;
-		} else {
-			status = -ESRCH;
-		}
-	} else {
-		status = -ESRCH;
-	}
-func_end:
-	dev_dbg(bridge, "%s: hnode: %p message: %p utimeout: 0x%x\n", __func__,
-		hnode, message, utimeout);
-	return status;
-}
-
-/*
- *   ======== node_get_nldr_obj ========
- */
-int node_get_nldr_obj(struct node_mgr *hnode_mgr,
-			     struct nldr_object **nldr_ovlyobj)
-{
-	int status = 0;
-	struct node_mgr *node_mgr_obj = hnode_mgr;
-
-	if (!hnode_mgr)
-		status = -EFAULT;
-	else
-		*nldr_ovlyobj = node_mgr_obj->nldr_obj;
-
-	return status;
-}
-
-/*
- *  ======== node_get_strm_mgr ========
- *  Purpose:
- *      Returns the Stream manager.
- */
-int node_get_strm_mgr(struct node_object *hnode,
-			     struct strm_mgr **strm_man)
-{
-	int status = 0;
-
-	if (!hnode)
-		status = -EFAULT;
-	else
-		*strm_man = hnode->node_mgr->strm_mgr_obj;
-
-	return status;
-}
-
-/*
- *  ======== node_get_load_type ========
- */
-enum nldr_loadtype node_get_load_type(struct node_object *hnode)
-{
-	if (!hnode) {
-		dev_dbg(bridge, "%s: Failed. hnode: %p\n", __func__, hnode);
-		return -1;
-	} else {
-		return hnode->dcd_props.obj_data.node_obj.load_type;
-	}
-}
-
-/*
- *  ======== node_get_timeout ========
- *  Purpose:
- *      Returns the timeout value for this node.
- */
-u32 node_get_timeout(struct node_object *hnode)
-{
-	if (!hnode) {
-		dev_dbg(bridge, "%s: failed. hnode: %p\n", __func__, hnode);
-		return 0;
-	} else {
-		return hnode->timeout;
-	}
-}
-
-/*
- *  ======== node_get_type ========
- *  Purpose:
- *      Returns the node type.
- */
-enum node_type node_get_type(struct node_object *hnode)
-{
-	enum node_type node_type;
-
-	if (hnode == (struct node_object *)DSP_HGPPNODE)
-		node_type = NODE_GPP;
-	else {
-		if (!hnode)
-			node_type = -1;
-		else
-			node_type = hnode->ntype;
-	}
-	return node_type;
-}
-
-/*
- *  ======== node_on_exit ========
- *  Purpose:
- *      Gets called when RMS_EXIT is received for a node.
- */
-void node_on_exit(struct node_object *hnode, s32 node_status)
-{
-	if (!hnode)
-		return;
-
-	/* Set node state to done */
-	NODE_SET_STATE(hnode, NODE_DONE);
-	hnode->exit_status = node_status;
-	if (hnode->loaded && hnode->phase_split) {
-		(void)hnode->node_mgr->nldr_fxns.unload(hnode->
-							     nldr_node_obj,
-							     NLDR_EXECUTE);
-		hnode->loaded = false;
-	}
-	/* Unblock call to node_terminate */
-	(void)sync_set_event(hnode->sync_done);
-	/* Notify clients */
-	proc_notify_clients(hnode->processor, DSP_NODESTATECHANGE);
-	ntfy_notify(hnode->ntfy_obj, DSP_NODESTATECHANGE);
-}
-
-/*
- *  ======== node_pause ========
- *  Purpose:
- *      Suspend execution of a node currently running on the DSP.
- */
-int node_pause(struct node_object *hnode)
-{
-	struct node_object *pnode = (struct node_object *)hnode;
-	enum node_type node_type;
-	enum node_state state;
-	struct node_mgr *hnode_mgr;
-	int status = 0;
-	u32 proc_id;
-	struct dsp_processorstate proc_state;
-	struct proc_object *hprocessor;
-
-	if (!hnode) {
-		status = -EFAULT;
-	} else {
-		node_type = node_get_type(hnode);
-		if (node_type != NODE_TASK && node_type != NODE_DAISSOCKET)
-			status = -EPERM;
-	}
-	if (status)
-		goto func_end;
-
-	status = proc_get_processor_id(pnode->processor, &proc_id);
-
-	if (proc_id == IVA_UNIT)
-		status = -ENOSYS;
-
-	if (!status) {
-		hnode_mgr = hnode->node_mgr;
-
-		/* Enter critical section */
-		mutex_lock(&hnode_mgr->node_mgr_lock);
-		state = node_get_state(hnode);
-		/* Check node state */
-		if (state != NODE_RUNNING)
-			status = -EBADR;
-
-		if (status)
-			goto func_cont;
-		hprocessor = hnode->processor;
-		status = proc_get_state(hprocessor, &proc_state,
-				sizeof(struct dsp_processorstate));
-		if (status)
-			goto func_cont;
-		/* If processor is in error state then don't attempt
-		   to send the message */
-		if (proc_state.proc_state == PROC_ERROR) {
-			status = -EPERM;
-			goto func_cont;
-		}
-
-		status = disp_node_change_priority(hnode_mgr->disp_obj, hnode,
-			hnode_mgr->fxn_addrs[RMSCHANGENODEPRIORITY],
-			hnode->node_env, NODE_SUSPENDEDPRI);
-
-		/* Update state */
-		if (status >= 0)
-			NODE_SET_STATE(hnode, NODE_PAUSED);
-
-func_cont:
-		/* End of sync_enter_cs */
-		/* Leave critical section */
-		mutex_unlock(&hnode_mgr->node_mgr_lock);
-		if (status >= 0) {
-			proc_notify_clients(hnode->processor,
-					    DSP_NODESTATECHANGE);
-			ntfy_notify(hnode->ntfy_obj, DSP_NODESTATECHANGE);
-		}
-	}
-func_end:
-	dev_dbg(bridge, "%s: hnode: %p status 0x%x\n", __func__, hnode, status);
-	return status;
-}
-
-/*
- *  ======== node_put_message ========
- *  Purpose:
- *      Send a message to a message node, task node, or XDAIS socket node. This
- *      function will block until the message stream can accommodate the
- *      message, or a timeout occurs.
- */
-int node_put_message(struct node_object *hnode,
-			    const struct dsp_msg *pmsg, u32 utimeout)
-{
-	struct node_mgr *hnode_mgr = NULL;
-	enum node_type node_type;
-	struct bridge_drv_interface *intf_fxns;
-	enum node_state state;
-	int status = 0;
-	void *tmp_buf;
-	struct dsp_msg new_msg;
-	struct dsp_processorstate proc_state;
-	struct proc_object *hprocessor;
-
-	if (!hnode) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	hprocessor = hnode->processor;
-	status = proc_get_state(hprocessor, &proc_state,
-				sizeof(struct dsp_processorstate));
-	if (status)
-		goto func_end;
-	/* If processor is in bad state then don't attempt sending the
-	   message */
-	if (proc_state.proc_state == PROC_ERROR) {
-		status = -EPERM;
-		goto func_end;
-	}
-	hnode_mgr = hnode->node_mgr;
-	node_type = node_get_type(hnode);
-	if (node_type != NODE_MESSAGE && node_type != NODE_TASK &&
-	    node_type != NODE_DAISSOCKET)
-		status = -EPERM;
-
-	if (!status) {
-		/*  Check node state. Can't send messages to a node after
-		 *  we've sent the RMS_EXIT command. There is still the
-		 *  possibility that node_terminate can be called after we've
-		 *  checked the state. Could add another SYNC object to
-		 *  prevent this (can't use node_mgr_lock, since we don't
-		 *  want to block other NODE functions). However, the node may
-		 *  still exit on its own, before this message is sent. */
-		mutex_lock(&hnode_mgr->node_mgr_lock);
-		state = node_get_state(hnode);
-		if (state == NODE_TERMINATING || state == NODE_DONE)
-			status = -EBADR;
-
-		/* end of sync_enter_cs */
-		mutex_unlock(&hnode_mgr->node_mgr_lock);
-	}
-	if (status)
-		goto func_end;
-
-	/* assign pmsg values to new msg */
-	new_msg = *pmsg;
-	/* Now, check if message contains a SM buffer descriptor */
-	if (pmsg->cmd & DSP_RMSBUFDESC) {
-		/* Translate GPP Va to DSP physical buf Ptr. */
-		tmp_buf = cmm_xlator_translate(hnode->xlator,
-					       (void *)new_msg.arg1,
-					       CMM_VA2DSPPA);
-		if (tmp_buf != NULL) {
-			/* got translation, convert to MAUs in msg */
-			if (hnode->node_mgr->dsp_word_size != 0) {
-				new_msg.arg1 =
-				    (u32) tmp_buf /
-				    hnode->node_mgr->dsp_word_size;
-				/* MAUs */
-				new_msg.arg2 /= hnode->node_mgr->
-				    dsp_word_size;
-			} else {
-				pr_err("%s: dsp_word_size is zero!\n",
-				       __func__);
-				status = -EPERM;	/* bad DSPWordSize */
-			}
-		} else {	/* failed to translate buffer address */
-			status = -ESRCH;
-		}
-	}
-	if (!status) {
-		intf_fxns = hnode_mgr->intf_fxns;
-		status = (*intf_fxns->msg_put) (hnode->msg_queue_obj,
-						    &new_msg, utimeout);
-	}
-func_end:
-	dev_dbg(bridge, "%s: hnode: %p pmsg: %p utimeout: 0x%x, "
-		"status 0x%x\n", __func__, hnode, pmsg, utimeout, status);
-	return status;
-}
-
-/*
- *  ======== node_register_notify ========
- *  Purpose:
- *      Register to be notified on specific events for this node.
- */
-int node_register_notify(struct node_object *hnode, u32 event_mask,
-				u32 notify_type,
-				struct dsp_notification *hnotification)
-{
-	struct bridge_drv_interface *intf_fxns;
-	int status = 0;
-
-	if (!hnode) {
-		status = -EFAULT;
-	} else {
-		/* Check if event mask is a valid node related event */
-		if (event_mask & ~(DSP_NODESTATECHANGE | DSP_NODEMESSAGEREADY))
-			status = -EINVAL;
-
-		/* Check if notify type is valid */
-		if (notify_type != DSP_SIGNALEVENT)
-			status = -EINVAL;
-
-		/* Only one Notification can be registered at a
-		 * time - Limitation */
-		if (event_mask == (DSP_NODESTATECHANGE | DSP_NODEMESSAGEREADY))
-			status = -EINVAL;
-	}
-	if (!status) {
-		if (event_mask == DSP_NODESTATECHANGE) {
-			status = ntfy_register(hnode->ntfy_obj, hnotification,
-					       event_mask & DSP_NODESTATECHANGE,
-					       notify_type);
-		} else {
-			/* Send Message part of event mask to msg_ctrl */
-			intf_fxns = hnode->node_mgr->intf_fxns;
-			status = (*intf_fxns->msg_register_notify)
-			    (hnode->msg_queue_obj,
-			     event_mask & DSP_NODEMESSAGEREADY, notify_type,
-			     hnotification);
-		}
-
-	}
-	dev_dbg(bridge, "%s: hnode: %p event_mask: 0x%x notify_type: 0x%x "
-		"hnotification: %p status 0x%x\n", __func__, hnode,
-		event_mask, notify_type, hnotification, status);
-	return status;
-}
-
-/*
- *  ======== node_run ========
- *  Purpose:
- *      Start execution of a node's execute phase, or resume execution of a node
- *      that has been suspended (via NODE_NodePause()) on the DSP. Load the
- *      node's execute function if necessary.
- */
-int node_run(struct node_object *hnode)
-{
-	struct node_object *pnode = (struct node_object *)hnode;
-	struct node_mgr *hnode_mgr;
-	enum node_type node_type;
-	enum node_state state;
-	u32 ul_execute_fxn;
-	u32 ul_fxn_addr;
-	int status = 0;
-	u32 proc_id;
-	struct bridge_drv_interface *intf_fxns;
-	struct dsp_processorstate proc_state;
-	struct proc_object *hprocessor;
-
-	if (!hnode) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	hprocessor = hnode->processor;
-	status = proc_get_state(hprocessor, &proc_state,
-				sizeof(struct dsp_processorstate));
-	if (status)
-		goto func_end;
-	/* If processor is in error state then don't attempt to run the node */
-	if (proc_state.proc_state == PROC_ERROR) {
-		status = -EPERM;
-		goto func_end;
-	}
-	node_type = node_get_type(hnode);
-	if (node_type == NODE_DEVICE)
-		status = -EPERM;
-	if (status)
-		goto func_end;
-
-	hnode_mgr = hnode->node_mgr;
-	if (!hnode_mgr) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	intf_fxns = hnode_mgr->intf_fxns;
-	/* Enter critical section */
-	mutex_lock(&hnode_mgr->node_mgr_lock);
-
-	state = node_get_state(hnode);
-	if (state != NODE_CREATED && state != NODE_PAUSED)
-		status = -EBADR;
-
-	if (!status)
-		status = proc_get_processor_id(pnode->processor, &proc_id);
-
-	if (status)
-		goto func_cont1;
-
-	if ((proc_id != DSP_UNIT) && (proc_id != IVA_UNIT))
-		goto func_cont1;
-
-	if (state == NODE_CREATED) {
-		/* If node's execute function is not loaded, load it */
-		if (!(hnode->loaded) && hnode->phase_split) {
-			status =
-			    hnode_mgr->nldr_fxns.load(hnode->nldr_node_obj,
-							  NLDR_EXECUTE);
-			if (!status) {
-				hnode->loaded = true;
-			} else {
-				pr_err("%s: fail - load execute code: 0x%x\n",
-				       __func__, status);
-			}
-		}
-		if (!status) {
-			/* Get address of node's execute function */
-			if (proc_id == IVA_UNIT)
-				ul_execute_fxn = (u32) hnode->node_env;
-			else {
-				status = get_fxn_address(hnode, &ul_execute_fxn,
-							 EXECUTEPHASE);
-			}
-		}
-		if (!status) {
-			ul_fxn_addr = hnode_mgr->fxn_addrs[RMSEXECUTENODE];
-			status =
-			    disp_node_run(hnode_mgr->disp_obj, hnode,
-					  ul_fxn_addr, ul_execute_fxn,
-					  hnode->node_env);
-		}
-	} else if (state == NODE_PAUSED) {
-		ul_fxn_addr = hnode_mgr->fxn_addrs[RMSCHANGENODEPRIORITY];
-		status = disp_node_change_priority(hnode_mgr->disp_obj, hnode,
-						   ul_fxn_addr, hnode->node_env,
-						   NODE_GET_PRIORITY(hnode));
-	} else {
-		/* We should never get here */
-	}
-func_cont1:
-	/* Update node state. */
-	if (status >= 0)
-		NODE_SET_STATE(hnode, NODE_RUNNING);
-	else			/* Set state back to previous value */
-		NODE_SET_STATE(hnode, state);
-	/*End of sync_enter_cs */
-	/* Exit critical section */
-	mutex_unlock(&hnode_mgr->node_mgr_lock);
-	if (status >= 0) {
-		proc_notify_clients(hnode->processor, DSP_NODESTATECHANGE);
-		ntfy_notify(hnode->ntfy_obj, DSP_NODESTATECHANGE);
-	}
-func_end:
-	dev_dbg(bridge, "%s: hnode: %p status 0x%x\n", __func__, hnode, status);
-	return status;
-}
-
-/*
- *  ======== node_terminate ========
- *  Purpose:
- *      Signal a node running on the DSP that it should exit its execute phase
- *      function.
- */
-int node_terminate(struct node_object *hnode, int *pstatus)
-{
-	struct node_object *pnode = (struct node_object *)hnode;
-	struct node_mgr *hnode_mgr = NULL;
-	enum node_type node_type;
-	struct bridge_drv_interface *intf_fxns;
-	enum node_state state;
-	struct dsp_msg msg, killmsg;
-	int status = 0;
-	u32 proc_id, kill_time_out;
-	struct deh_mgr *hdeh_mgr;
-	struct dsp_processorstate proc_state;
-
-	if (!hnode || !hnode->node_mgr) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	if (pnode->processor == NULL) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	status = proc_get_processor_id(pnode->processor, &proc_id);
-
-	if (!status) {
-		hnode_mgr = hnode->node_mgr;
-		node_type = node_get_type(hnode);
-		if (node_type != NODE_TASK && node_type != NODE_DAISSOCKET)
-			status = -EPERM;
-	}
-	if (!status) {
-		/* Check node state */
-		mutex_lock(&hnode_mgr->node_mgr_lock);
-		state = node_get_state(hnode);
-		if (state != NODE_RUNNING) {
-			status = -EBADR;
-			/* Set the exit status if node terminated on
-			 * its own. */
-			if (state == NODE_DONE)
-				*pstatus = hnode->exit_status;
-
-		} else {
-			NODE_SET_STATE(hnode, NODE_TERMINATING);
-		}
-		/* end of sync_enter_cs */
-		mutex_unlock(&hnode_mgr->node_mgr_lock);
-	}
-	if (!status) {
-		/*
-		 *  Send exit message. Do not change state to NODE_DONE
-		 *  here. That will be done in callback.
-		 */
-		status = proc_get_state(pnode->processor, &proc_state,
-					sizeof(struct dsp_processorstate));
-		if (status)
-			goto func_cont;
-		/* If processor is in error state then don't attempt to send
-		 * A kill task command */
-		if (proc_state.proc_state == PROC_ERROR) {
-			status = -EPERM;
-			goto func_cont;
-		}
-
-		msg.cmd = RMS_EXIT;
-		msg.arg1 = hnode->node_env;
-		killmsg.cmd = RMS_KILLTASK;
-		killmsg.arg1 = hnode->node_env;
-		intf_fxns = hnode_mgr->intf_fxns;
-
-		if (hnode->timeout > MAXTIMEOUT)
-			kill_time_out = MAXTIMEOUT;
-		else
-			kill_time_out = (hnode->timeout) * 2;
-
-		status = (*intf_fxns->msg_put) (hnode->msg_queue_obj, &msg,
-						    hnode->timeout);
-		if (status)
-			goto func_cont;
-
-		/*
-		 * Wait on synchronization object that will be
-		 * posted in the callback on receiving RMS_EXIT
-		 * message, or by node_delete. Check for valid hnode,
-		 * in case posted by node_delete().
-		 */
-		status = sync_wait_on_event(hnode->sync_done,
-					    kill_time_out / 2);
-		if (status != ETIME)
-			goto func_cont;
-
-		status = (*intf_fxns->msg_put)(hnode->msg_queue_obj,
-						&killmsg, hnode->timeout);
-		if (status)
-			goto func_cont;
-		status = sync_wait_on_event(hnode->sync_done,
-					     kill_time_out / 2);
-		if (status) {
-			/*
-			 * Here it goes the part of the simulation of
-			 * the DSP exception.
-			 */
-			dev_get_deh_mgr(hnode_mgr->dev_obj, &hdeh_mgr);
-			if (!hdeh_mgr)
-				goto func_cont;
-
-			bridge_deh_notify(hdeh_mgr, DSP_SYSERROR,
-					  DSP_EXCEPTIONABORT);
-		}
-	}
-func_cont:
-	if (!status) {
-		/* Enter CS before getting exit status, in case node was
-		 * deleted. */
-		mutex_lock(&hnode_mgr->node_mgr_lock);
-		/* Make sure node wasn't deleted while we blocked */
-		if (!hnode) {
-			status = -EPERM;
-		} else {
-			*pstatus = hnode->exit_status;
-			dev_dbg(bridge, "%s: hnode: %p env 0x%x status 0x%x\n",
-				__func__, hnode, hnode->node_env, status);
-		}
-		mutex_unlock(&hnode_mgr->node_mgr_lock);
-	}			/*End of sync_enter_cs */
-func_end:
-	return status;
-}
-
-/*
- *  ======== delete_node ========
- *  Purpose:
- *      Free GPP resources allocated in node_allocate() or node_connect().
- */
-static void delete_node(struct node_object *hnode,
-			struct process_context *pr_ctxt)
-{
-	struct node_mgr *hnode_mgr;
-	struct bridge_drv_interface *intf_fxns;
-	u32 i;
-	enum node_type node_type;
-	struct stream_chnl stream;
-	struct node_msgargs node_msg_args;
-	struct node_taskargs task_arg_obj;
-#ifdef DSP_DMM_DEBUG
-	struct dmm_object *dmm_mgr;
-	struct proc_object *p_proc_object =
-	    (struct proc_object *)hnode->processor;
-#endif
-	int status;
-
-	if (!hnode)
-		goto func_end;
-	hnode_mgr = hnode->node_mgr;
-	if (!hnode_mgr)
-		goto func_end;
-
-	node_type = node_get_type(hnode);
-	if (node_type != NODE_DEVICE) {
-		node_msg_args = hnode->create_args.asa.node_msg_args;
-		kfree(node_msg_args.pdata);
-
-		/* Free msg_ctrl queue */
-		if (hnode->msg_queue_obj) {
-			intf_fxns = hnode_mgr->intf_fxns;
-			(*intf_fxns->msg_delete_queue) (hnode->
-							    msg_queue_obj);
-			hnode->msg_queue_obj = NULL;
-		}
-
-		kfree(hnode->sync_done);
-
-		/* Free all stream info */
-		if (hnode->inputs) {
-			for (i = 0; i < MAX_INPUTS(hnode); i++) {
-				stream = hnode->inputs[i];
-				free_stream(hnode_mgr, stream);
-			}
-			kfree(hnode->inputs);
-			hnode->inputs = NULL;
-		}
-		if (hnode->outputs) {
-			for (i = 0; i < MAX_OUTPUTS(hnode); i++) {
-				stream = hnode->outputs[i];
-				free_stream(hnode_mgr, stream);
-			}
-			kfree(hnode->outputs);
-			hnode->outputs = NULL;
-		}
-		task_arg_obj = hnode->create_args.asa.task_arg_obj;
-		if (task_arg_obj.strm_in_def) {
-			for (i = 0; i < MAX_INPUTS(hnode); i++) {
-				kfree(task_arg_obj.strm_in_def[i].sz_device);
-				task_arg_obj.strm_in_def[i].sz_device = NULL;
-			}
-			kfree(task_arg_obj.strm_in_def);
-			task_arg_obj.strm_in_def = NULL;
-		}
-		if (task_arg_obj.strm_out_def) {
-			for (i = 0; i < MAX_OUTPUTS(hnode); i++) {
-				kfree(task_arg_obj.strm_out_def[i].sz_device);
-				task_arg_obj.strm_out_def[i].sz_device = NULL;
-			}
-			kfree(task_arg_obj.strm_out_def);
-			task_arg_obj.strm_out_def = NULL;
-		}
-		if (task_arg_obj.dsp_heap_res_addr) {
-			status = proc_un_map(hnode->processor, (void *)
-					     task_arg_obj.dsp_heap_addr,
-					     pr_ctxt);
-
-			status = proc_un_reserve_memory(hnode->processor,
-							(void *)
-							task_arg_obj.
-							dsp_heap_res_addr,
-							pr_ctxt);
-#ifdef DSP_DMM_DEBUG
-			status = dmm_get_handle(p_proc_object, &dmm_mgr);
-			if (dmm_mgr)
-				dmm_mem_map_dump(dmm_mgr);
-			else
-				status = DSP_EHANDLE;
-#endif
-		}
-	}
-	if (node_type != NODE_MESSAGE) {
-		kfree(hnode->stream_connect);
-		hnode->stream_connect = NULL;
-	}
-	kfree(hnode->str_dev_name);
-	hnode->str_dev_name = NULL;
-
-	if (hnode->ntfy_obj) {
-		ntfy_delete(hnode->ntfy_obj);
-		kfree(hnode->ntfy_obj);
-		hnode->ntfy_obj = NULL;
-	}
-
-	/* These were allocated in dcd_get_object_def (via node_allocate) */
-	kfree(hnode->dcd_props.obj_data.node_obj.str_create_phase_fxn);
-	hnode->dcd_props.obj_data.node_obj.str_create_phase_fxn = NULL;
-
-	kfree(hnode->dcd_props.obj_data.node_obj.str_execute_phase_fxn);
-	hnode->dcd_props.obj_data.node_obj.str_execute_phase_fxn = NULL;
-
-	kfree(hnode->dcd_props.obj_data.node_obj.str_delete_phase_fxn);
-	hnode->dcd_props.obj_data.node_obj.str_delete_phase_fxn = NULL;
-
-	kfree(hnode->dcd_props.obj_data.node_obj.str_i_alg_name);
-	hnode->dcd_props.obj_data.node_obj.str_i_alg_name = NULL;
-
-	/* Free all SM address translator resources */
-	kfree(hnode->xlator);
-	kfree(hnode->nldr_node_obj);
-	hnode->nldr_node_obj = NULL;
-	hnode->node_mgr = NULL;
-	kfree(hnode);
-	hnode = NULL;
-func_end:
-	return;
-}
-
-/*
- *  ======== delete_node_mgr ========
- *  Purpose:
- *      Frees the node manager.
- */
-static void delete_node_mgr(struct node_mgr *hnode_mgr)
-{
-	struct node_object *hnode, *tmp;
-
-	if (hnode_mgr) {
-		/* Free resources */
-		if (hnode_mgr->dcd_mgr)
-			dcd_destroy_manager(hnode_mgr->dcd_mgr);
-
-		/* Remove any elements remaining in lists */
-		list_for_each_entry_safe(hnode, tmp, &hnode_mgr->node_list,
-				list_elem) {
-			list_del(&hnode->list_elem);
-			delete_node(hnode, NULL);
-		}
-		mutex_destroy(&hnode_mgr->node_mgr_lock);
-		if (hnode_mgr->ntfy_obj) {
-			ntfy_delete(hnode_mgr->ntfy_obj);
-			kfree(hnode_mgr->ntfy_obj);
-		}
-
-		if (hnode_mgr->disp_obj)
-			disp_delete(hnode_mgr->disp_obj);
-
-		if (hnode_mgr->strm_mgr_obj)
-			strm_delete(hnode_mgr->strm_mgr_obj);
-
-		/* Delete the loader */
-		if (hnode_mgr->nldr_obj)
-			hnode_mgr->nldr_fxns.delete(hnode_mgr->nldr_obj);
-
-		kfree(hnode_mgr);
-	}
-}
-
-/*
- *  ======== fill_stream_connect ========
- *  Purpose:
- *      Fills stream information.
- */
-static void fill_stream_connect(struct node_object *node1,
-				struct node_object *node2,
-				u32 stream1, u32 stream2)
-{
-	u32 strm_index;
-	struct dsp_streamconnect *strm1 = NULL;
-	struct dsp_streamconnect *strm2 = NULL;
-	enum node_type node1_type = NODE_TASK;
-	enum node_type node2_type = NODE_TASK;
-
-	node1_type = node_get_type(node1);
-	node2_type = node_get_type(node2);
-	if (node1 != (struct node_object *)DSP_HGPPNODE) {
-
-		if (node1_type != NODE_DEVICE) {
-			strm_index = node1->num_inputs +
-			    node1->num_outputs - 1;
-			strm1 = &(node1->stream_connect[strm_index]);
-			strm1->cb_struct = sizeof(struct dsp_streamconnect);
-			strm1->this_node_stream_index = stream1;
-		}
-
-		if (node2 != (struct node_object *)DSP_HGPPNODE) {
-			/* NODE == > NODE */
-			if (node1_type != NODE_DEVICE) {
-				strm1->connected_node = node2;
-				strm1->ui_connected_node_id = node2->node_uuid;
-				strm1->connected_node_stream_index = stream2;
-				strm1->connect_type = CONNECTTYPE_NODEOUTPUT;
-			}
-			if (node2_type != NODE_DEVICE) {
-				strm_index = node2->num_inputs +
-				    node2->num_outputs - 1;
-				strm2 = &(node2->stream_connect[strm_index]);
-				strm2->cb_struct =
-				    sizeof(struct dsp_streamconnect);
-				strm2->this_node_stream_index = stream2;
-				strm2->connected_node = node1;
-				strm2->ui_connected_node_id = node1->node_uuid;
-				strm2->connected_node_stream_index = stream1;
-				strm2->connect_type = CONNECTTYPE_NODEINPUT;
-			}
-		} else if (node1_type != NODE_DEVICE)
-			strm1->connect_type = CONNECTTYPE_GPPOUTPUT;
-	} else {
-		/* GPP == > NODE */
-		strm_index = node2->num_inputs + node2->num_outputs - 1;
-		strm2 = &(node2->stream_connect[strm_index]);
-		strm2->cb_struct = sizeof(struct dsp_streamconnect);
-		strm2->this_node_stream_index = stream2;
-		strm2->connect_type = CONNECTTYPE_GPPINPUT;
-	}
-}
-
-/*
- *  ======== fill_stream_def ========
- *  Purpose:
- *      Fills Stream attributes.
- */
-static void fill_stream_def(struct node_object *hnode,
-			    struct node_strmdef *pstrm_def,
-			    struct dsp_strmattr *pattrs)
-{
-	struct node_mgr *hnode_mgr = hnode->node_mgr;
-
-	if (pattrs != NULL) {
-		pstrm_def->num_bufs = pattrs->num_bufs;
-		pstrm_def->buf_size =
-		    pattrs->buf_size / hnode_mgr->dsp_data_mau_size;
-		pstrm_def->seg_id = pattrs->seg_id;
-		pstrm_def->buf_alignment = pattrs->buf_alignment;
-		pstrm_def->timeout = pattrs->timeout;
-	} else {
-		pstrm_def->num_bufs = DEFAULTNBUFS;
-		pstrm_def->buf_size =
-		    DEFAULTBUFSIZE / hnode_mgr->dsp_data_mau_size;
-		pstrm_def->seg_id = DEFAULTSEGID;
-		pstrm_def->buf_alignment = DEFAULTALIGNMENT;
-		pstrm_def->timeout = DEFAULTTIMEOUT;
-	}
-}
-
-/*
- *  ======== free_stream ========
- *  Purpose:
- *      Updates the channel mask and frees the pipe id.
- */
-static void free_stream(struct node_mgr *hnode_mgr, struct stream_chnl stream)
-{
-	/* Free up the pipe id unless other node has not yet been deleted. */
-	if (stream.type == NODECONNECT) {
-		if (test_bit(stream.dev_id, hnode_mgr->pipe_done_map)) {
-			/* The other node has already been deleted */
-			clear_bit(stream.dev_id, hnode_mgr->pipe_done_map);
-			clear_bit(stream.dev_id, hnode_mgr->pipe_map);
-		} else {
-			/* The other node has not been deleted yet */
-			set_bit(stream.dev_id, hnode_mgr->pipe_done_map);
-		}
-	} else if (stream.type == HOSTCONNECT) {
-		if (stream.dev_id < hnode_mgr->num_chnls) {
-			clear_bit(stream.dev_id, hnode_mgr->chnl_map);
-		} else if (stream.dev_id < (2 * hnode_mgr->num_chnls)) {
-			/* dsp-dma */
-			clear_bit(stream.dev_id - (1 * hnode_mgr->num_chnls),
-					hnode_mgr->dma_chnl_map);
-		} else if (stream.dev_id < (3 * hnode_mgr->num_chnls)) {
-			/* zero-copy */
-			clear_bit(stream.dev_id - (2 * hnode_mgr->num_chnls),
-					hnode_mgr->zc_chnl_map);
-		}
-	}
-}
-
-/*
- *  ======== get_fxn_address ========
- *  Purpose:
- *      Retrieves the address for create, execute or delete phase for a node.
- */
-static int get_fxn_address(struct node_object *hnode, u32 *fxn_addr,
-				  u32 phase)
-{
-	char *pstr_fxn_name = NULL;
-	struct node_mgr *hnode_mgr = hnode->node_mgr;
-	int status = 0;
-
-	switch (phase) {
-	case CREATEPHASE:
-		pstr_fxn_name =
-		    hnode->dcd_props.obj_data.node_obj.str_create_phase_fxn;
-		break;
-	case EXECUTEPHASE:
-		pstr_fxn_name =
-		    hnode->dcd_props.obj_data.node_obj.str_execute_phase_fxn;
-		break;
-	case DELETEPHASE:
-		pstr_fxn_name =
-		    hnode->dcd_props.obj_data.node_obj.str_delete_phase_fxn;
-		break;
-	default:
-		/* Should never get here */
-		break;
-	}
-
-	status =
-	    hnode_mgr->nldr_fxns.get_fxn_addr(hnode->nldr_node_obj,
-						  pstr_fxn_name, fxn_addr);
-
-	return status;
-}
-
-/*
- *  ======== get_node_info ========
- *  Purpose:
- *      Retrieves the node information.
- */
-void get_node_info(struct node_object *hnode, struct dsp_nodeinfo *node_info)
-{
-	u32 i;
-
-	node_info->cb_struct = sizeof(struct dsp_nodeinfo);
-	node_info->nb_node_database_props =
-	    hnode->dcd_props.obj_data.node_obj.ndb_props;
-	node_info->execution_priority = hnode->prio;
-	node_info->device_owner = hnode->device_owner;
-	node_info->number_streams = hnode->num_inputs + hnode->num_outputs;
-	node_info->node_env = hnode->node_env;
-
-	node_info->ns_execution_state = node_get_state(hnode);
-
-	/* Copy stream connect data */
-	for (i = 0; i < hnode->num_inputs + hnode->num_outputs; i++)
-		node_info->sc_stream_connection[i] = hnode->stream_connect[i];
-
-}
-
-/*
- *  ======== get_node_props ========
- *  Purpose:
- *      Retrieve node properties.
- */
-static int get_node_props(struct dcd_manager *hdcd_mgr,
-				 struct node_object *hnode,
-				 const struct dsp_uuid *node_uuid,
-				 struct dcd_genericobj *dcd_prop)
-{
-	u32 len;
-	struct node_msgargs *pmsg_args;
-	struct node_taskargs *task_arg_obj;
-	enum node_type node_type = NODE_TASK;
-	struct dsp_ndbprops *pndb_props =
-	    &(dcd_prop->obj_data.node_obj.ndb_props);
-	int status = 0;
-	char sz_uuid[MAXUUIDLEN];
-
-	status = dcd_get_object_def(hdcd_mgr, (struct dsp_uuid *)node_uuid,
-				    DSP_DCDNODETYPE, dcd_prop);
-
-	if (!status) {
-		hnode->ntype = node_type = pndb_props->ntype;
-
-		/* Create UUID value to set in registry. */
-		snprintf(sz_uuid, MAXUUIDLEN, "%pUL", node_uuid);
-		dev_dbg(bridge, "(node) UUID: %s\n", sz_uuid);
-
-		/* Fill in message args that come from NDB */
-		if (node_type != NODE_DEVICE) {
-			pmsg_args = &(hnode->create_args.asa.node_msg_args);
-			pmsg_args->seg_id =
-			    dcd_prop->obj_data.node_obj.msg_segid;
-			pmsg_args->notify_type =
-			    dcd_prop->obj_data.node_obj.msg_notify_type;
-			pmsg_args->max_msgs = pndb_props->message_depth;
-			dev_dbg(bridge, "(node) Max Number of Messages: 0x%x\n",
-				pmsg_args->max_msgs);
-		} else {
-			/* Copy device name */
-			len = strlen(pndb_props->ac_name);
-			hnode->str_dev_name = kzalloc(len + 1, GFP_KERNEL);
-			if (hnode->str_dev_name == NULL) {
-				status = -ENOMEM;
-			} else {
-				strncpy(hnode->str_dev_name,
-					pndb_props->ac_name, len);
-			}
-		}
-	}
-	if (!status) {
-		/* Fill in create args that come from NDB */
-		if (node_type == NODE_TASK || node_type == NODE_DAISSOCKET) {
-			task_arg_obj = &(hnode->create_args.asa.task_arg_obj);
-			task_arg_obj->prio = pndb_props->prio;
-			task_arg_obj->stack_size = pndb_props->stack_size;
-			task_arg_obj->sys_stack_size =
-			    pndb_props->sys_stack_size;
-			task_arg_obj->stack_seg = pndb_props->stack_seg;
-			dev_dbg(bridge, "(node) Priority: 0x%x Stack Size: "
-				"0x%x words System Stack Size: 0x%x words "
-				"Stack Segment: 0x%x profile count : 0x%x\n",
-				task_arg_obj->prio, task_arg_obj->stack_size,
-				task_arg_obj->sys_stack_size,
-				task_arg_obj->stack_seg,
-				pndb_props->count_profiles);
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== get_proc_props ========
- *  Purpose:
- *      Retrieve the processor properties.
- */
-static int get_proc_props(struct node_mgr *hnode_mgr,
-				 struct dev_object *hdev_obj)
-{
-	struct cfg_hostres *host_res;
-	struct bridge_dev_context *pbridge_context;
-	int status = 0;
-
-	status = dev_get_bridge_context(hdev_obj, &pbridge_context);
-	if (!pbridge_context)
-		status = -EFAULT;
-
-	if (!status) {
-		host_res = pbridge_context->resources;
-		if (!host_res)
-			return -EPERM;
-		hnode_mgr->chnl_offset = host_res->chnl_offset;
-		hnode_mgr->chnl_buf_size = host_res->chnl_buf_size;
-		hnode_mgr->num_chnls = host_res->num_chnls;
-
-		/*
-		 *  PROC will add an API to get dsp_processorinfo.
-		 *  Fill in default values for now.
-		 */
-		/* TODO -- Instead of hard coding, take from registry */
-		hnode_mgr->proc_family = 6000;
-		hnode_mgr->proc_type = 6410;
-		hnode_mgr->min_pri = DSP_NODE_MIN_PRIORITY;
-		hnode_mgr->max_pri = DSP_NODE_MAX_PRIORITY;
-		hnode_mgr->dsp_word_size = DSPWORDSIZE;
-		hnode_mgr->dsp_data_mau_size = DSPWORDSIZE;
-		hnode_mgr->dsp_mau_size = 1;
-
-	}
-	return status;
-}
-
-/*
- *  ======== node_get_uuid_props ========
- *  Purpose:
- *      Fetch Node UUID properties from DCD/DOF file.
- */
-int node_get_uuid_props(void *hprocessor,
-			       const struct dsp_uuid *node_uuid,
-			       struct dsp_ndbprops *node_props)
-{
-	struct node_mgr *hnode_mgr = NULL;
-	struct dev_object *hdev_obj;
-	int status = 0;
-	struct dcd_nodeprops dcd_node_props;
-	struct dsp_processorstate proc_state;
-
-	if (hprocessor == NULL || node_uuid == NULL) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	status = proc_get_state(hprocessor, &proc_state,
-				sizeof(struct dsp_processorstate));
-	if (status)
-		goto func_end;
-	/* If processor is in error state then don't attempt
-	   to send the message */
-	if (proc_state.proc_state == PROC_ERROR) {
-		status = -EPERM;
-		goto func_end;
-	}
-
-	status = proc_get_dev_object(hprocessor, &hdev_obj);
-	if (hdev_obj) {
-		status = dev_get_node_manager(hdev_obj, &hnode_mgr);
-		if (hnode_mgr == NULL) {
-			status = -EFAULT;
-			goto func_end;
-		}
-	}
-
-	/*
-	 * Enter the critical section. This is needed because
-	 * dcd_get_object_def will ultimately end up calling dbll_open/close,
-	 * which needs to be protected in order to not corrupt the zlib manager
-	 * (COD).
-	 */
-	mutex_lock(&hnode_mgr->node_mgr_lock);
-
-	dcd_node_props.str_create_phase_fxn = NULL;
-	dcd_node_props.str_execute_phase_fxn = NULL;
-	dcd_node_props.str_delete_phase_fxn = NULL;
-	dcd_node_props.str_i_alg_name = NULL;
-
-	status = dcd_get_object_def(hnode_mgr->dcd_mgr,
-		(struct dsp_uuid *)node_uuid, DSP_DCDNODETYPE,
-		(struct dcd_genericobj *)&dcd_node_props);
-
-	if (!status) {
-		*node_props = dcd_node_props.ndb_props;
-		kfree(dcd_node_props.str_create_phase_fxn);
-
-		kfree(dcd_node_props.str_execute_phase_fxn);
-
-		kfree(dcd_node_props.str_delete_phase_fxn);
-
-		kfree(dcd_node_props.str_i_alg_name);
-	}
-	/*  Leave the critical section, we're done. */
-	mutex_unlock(&hnode_mgr->node_mgr_lock);
-func_end:
-	return status;
-}
-
-/*
- *  ======== get_rms_fxns ========
- *  Purpose:
- *      Retrieve the RMS functions.
- */
-static int get_rms_fxns(struct node_mgr *hnode_mgr)
-{
-	s32 i;
-	struct dev_object *dev_obj = hnode_mgr->dev_obj;
-	int status = 0;
-
-	static char *psz_fxns[NUMRMSFXNS] = {
-		"RMS_queryServer",	/* RMSQUERYSERVER */
-		"RMS_configureServer",	/* RMSCONFIGURESERVER */
-		"RMS_createNode",	/* RMSCREATENODE */
-		"RMS_executeNode",	/* RMSEXECUTENODE */
-		"RMS_deleteNode",	/* RMSDELETENODE */
-		"RMS_changeNodePriority",	/* RMSCHANGENODEPRIORITY */
-		"RMS_readMemory",	/* RMSREADMEMORY */
-		"RMS_writeMemory",	/* RMSWRITEMEMORY */
-		"RMS_copy",	/* RMSCOPY */
-	};
-
-	for (i = 0; i < NUMRMSFXNS; i++) {
-		status = dev_get_symbol(dev_obj, psz_fxns[i],
-					&(hnode_mgr->fxn_addrs[i]));
-		if (status) {
-			if (status == -ESPIPE) {
-				/*
-				 *  May be loaded dynamically (in the future),
-				 *  but return an error for now.
-				 */
-				dev_dbg(bridge, "%s: RMS function: %s currently"
-					" not loaded\n", __func__, psz_fxns[i]);
-			} else {
-				dev_dbg(bridge, "%s: Symbol not found: %s "
-					"status = 0x%x\n", __func__,
-					psz_fxns[i], status);
-				break;
-			}
-		}
-	}
-
-	return status;
-}
-
-/*
- *  ======== ovly ========
- *  Purpose:
- *      Called during overlay.Sends command to RMS to copy a block of data.
- */
-static u32 ovly(void *priv_ref, u32 dsp_run_addr, u32 dsp_load_addr,
-		u32 ul_num_bytes, u32 mem_space)
-{
-	struct node_object *hnode = (struct node_object *)priv_ref;
-	struct node_mgr *hnode_mgr;
-	u32 ul_bytes = 0;
-	u32 ul_size;
-	u32 ul_timeout;
-	int status = 0;
-	struct bridge_dev_context *hbridge_context;
-	/* Function interface to Bridge driver*/
-	struct bridge_drv_interface *intf_fxns;
-
-	hnode_mgr = hnode->node_mgr;
-
-	ul_size = ul_num_bytes / hnode_mgr->dsp_word_size;
-	ul_timeout = hnode->timeout;
-
-	/* Call new MemCopy function */
-	intf_fxns = hnode_mgr->intf_fxns;
-	status = dev_get_bridge_context(hnode_mgr->dev_obj, &hbridge_context);
-	if (!status) {
-		status =
-		    (*intf_fxns->brd_mem_copy) (hbridge_context,
-						dsp_run_addr, dsp_load_addr,
-						ul_num_bytes, (u32) mem_space);
-		if (!status)
-			ul_bytes = ul_num_bytes;
-		else
-			pr_debug("%s: failed to copy brd memory, status 0x%x\n",
-				 __func__, status);
-	} else {
-		pr_debug("%s: failed to get Bridge context, status 0x%x\n",
-			 __func__, status);
-	}
-
-	return ul_bytes;
-}
-
-/*
- *  ======== mem_write ========
- */
-static u32 mem_write(void *priv_ref, u32 dsp_add, void *pbuf,
-		     u32 ul_num_bytes, u32 mem_space)
-{
-	struct node_object *hnode = (struct node_object *)priv_ref;
-	struct node_mgr *hnode_mgr;
-	u16 mem_sect_type;
-	u32 ul_timeout;
-	int status = 0;
-	struct bridge_dev_context *hbridge_context;
-	/* Function interface to Bridge driver */
-	struct bridge_drv_interface *intf_fxns;
-
-	hnode_mgr = hnode->node_mgr;
-
-	ul_timeout = hnode->timeout;
-	mem_sect_type = (mem_space & DBLL_CODE) ? RMS_CODE : RMS_DATA;
-
-	/* Call new MemWrite function */
-	intf_fxns = hnode_mgr->intf_fxns;
-	status = dev_get_bridge_context(hnode_mgr->dev_obj, &hbridge_context);
-	status = (*intf_fxns->brd_mem_write) (hbridge_context, pbuf,
-					dsp_add, ul_num_bytes, mem_sect_type);
-
-	return ul_num_bytes;
-}
-
-#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
-/*
- *  ======== node_find_addr ========
- */
-int node_find_addr(struct node_mgr *node_mgr, u32 sym_addr,
-		u32 offset_range, void *sym_addr_output, char *sym_name)
-{
-	struct node_object *node_obj;
-	int status = -ENOENT;
-
-	list_for_each_entry(node_obj, &node_mgr->node_list, list_elem) {
-		status = nldr_find_addr(node_obj->nldr_node_obj, sym_addr,
-			offset_range, sym_addr_output, sym_name);
-		if (!status) {
-			pr_debug("%s(0x%x, 0x%x, 0x%x, 0x%x, %s)\n", __func__,
-				 (unsigned int) node_mgr,
-				 sym_addr, offset_range,
-				 (unsigned int) sym_addr_output, sym_name);
-			break;
-		}
-	}
-
-	return status;
-}
-#endif
diff --git a/drivers/staging/tidspbridge/rmgr/proc.c b/drivers/staging/tidspbridge/rmgr/proc.c
deleted file mode 100644
index 23e5146..0000000
--- a/drivers/staging/tidspbridge/rmgr/proc.c
+++ /dev/null
@@ -1,1836 +0,0 @@
-/*
- * proc.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Processor interface at the driver level.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/types.h>
-/* ------------------------------------ Host OS */
-#include <linux/dma-mapping.h>
-#include <linux/scatterlist.h>
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/ntfy.h>
-#include <dspbridge/sync.h>
-/*  ----------------------------------- Bridge Driver */
-#include <dspbridge/dspdefs.h>
-#include <dspbridge/dspdeh.h>
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/cod.h>
-#include <dspbridge/dev.h>
-#include <dspbridge/procpriv.h>
-#include <dspbridge/dmm.h>
-
-/*  ----------------------------------- Resource Manager */
-#include <dspbridge/mgr.h>
-#include <dspbridge/node.h>
-#include <dspbridge/nldr.h>
-#include <dspbridge/rmm.h>
-
-/*  ----------------------------------- Others */
-#include <dspbridge/dbdcd.h>
-#include <dspbridge/msg.h>
-#include <dspbridge/dspioctl.h>
-#include <dspbridge/drv.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/proc.h>
-#include <dspbridge/pwr.h>
-
-#include <dspbridge/resourcecleanup.h>
-/*  ----------------------------------- Defines, Data Structures, Typedefs */
-#define MAXCMDLINELEN       255
-#define PROC_ENVPROCID      "PROC_ID=%d"
-#define MAXPROCIDLEN	(8 + 5)
-#define PROC_DFLT_TIMEOUT   10000	/* Time out in milliseconds */
-#define PWR_TIMEOUT	 500	/* Sleep/wake timout in msec */
-#define EXTEND	      "_EXT_END"	/* Extmem end addr in DSP binary */
-
-#define DSP_CACHE_LINE 128
-
-#define BUFMODE_MASK	(3 << 14)
-
-/* Buffer modes from DSP perspective */
-#define RBUF		0x4000		/* Input buffer */
-#define WBUF		0x8000		/* Output Buffer */
-
-extern struct device *bridge;
-
-/*  ----------------------------------- Globals */
-
-/* The proc_object structure. */
-struct proc_object {
-	struct list_head link;	/* Link to next proc_object */
-	struct dev_object *dev_obj;	/* Device this PROC represents */
-	u32 process;		/* Process owning this Processor */
-	struct mgr_object *mgr_obj;	/* Manager Object Handle */
-	u32 attach_count;	/* Processor attach count */
-	u32 processor_id;	/* Processor number */
-	u32 timeout;		/* Time out count */
-	enum dsp_procstate proc_state;	/* Processor state */
-	u32 unit;		/* DDSP unit number */
-	bool is_already_attached;	/*
-					 * True if the Device below has
-					 * GPP Client attached
-					 */
-	struct ntfy_object *ntfy_obj;	/* Manages  notifications */
-	/* Bridge Context Handle */
-	struct bridge_dev_context *bridge_context;
-	/* Function interface to Bridge driver */
-	struct bridge_drv_interface *intf_fxns;
-	char *last_coff;
-	struct list_head proc_list;
-};
-
-DEFINE_MUTEX(proc_lock);	/* For critical sections */
-
-/*  ----------------------------------- Function Prototypes */
-static int proc_monitor(struct proc_object *proc_obj);
-static s32 get_envp_count(char **envp);
-static char **prepend_envp(char **new_envp, char **envp, s32 envp_elems,
-			   s32 cnew_envp, char *sz_var);
-
-/* remember mapping information */
-static struct dmm_map_object *add_mapping_info(struct process_context *pr_ctxt,
-				u32 mpu_addr, u32 dsp_addr, u32 size)
-{
-	struct dmm_map_object *map_obj;
-
-	u32 num_usr_pgs = size / PG_SIZE4K;
-
-	pr_debug("%s: adding map info: mpu_addr 0x%x virt 0x%x size 0x%x\n",
-						__func__, mpu_addr,
-						dsp_addr, size);
-
-	map_obj = kzalloc(sizeof(struct dmm_map_object), GFP_KERNEL);
-	if (!map_obj)
-		return NULL;
-
-	INIT_LIST_HEAD(&map_obj->link);
-
-	map_obj->pages = kcalloc(num_usr_pgs, sizeof(struct page *),
-				 GFP_KERNEL);
-	if (!map_obj->pages) {
-		kfree(map_obj);
-		return NULL;
-	}
-
-	map_obj->mpu_addr = mpu_addr;
-	map_obj->dsp_addr = dsp_addr;
-	map_obj->size = size;
-	map_obj->num_usr_pgs = num_usr_pgs;
-
-	spin_lock(&pr_ctxt->dmm_map_lock);
-	list_add(&map_obj->link, &pr_ctxt->dmm_map_list);
-	spin_unlock(&pr_ctxt->dmm_map_lock);
-
-	return map_obj;
-}
-
-static int match_exact_map_obj(struct dmm_map_object *map_obj,
-					u32 dsp_addr, u32 size)
-{
-	if (map_obj->dsp_addr == dsp_addr && map_obj->size != size)
-		pr_err("%s: addr match (0x%x), size don't (0x%x != 0x%x)\n",
-				__func__, dsp_addr, map_obj->size, size);
-
-	return map_obj->dsp_addr == dsp_addr &&
-		map_obj->size == size;
-}
-
-static void remove_mapping_information(struct process_context *pr_ctxt,
-						u32 dsp_addr, u32 size)
-{
-	struct dmm_map_object *map_obj;
-
-	pr_debug("%s: looking for virt 0x%x size 0x%x\n", __func__,
-							dsp_addr, size);
-
-	spin_lock(&pr_ctxt->dmm_map_lock);
-	list_for_each_entry(map_obj, &pr_ctxt->dmm_map_list, link) {
-		pr_debug("%s: candidate: mpu_addr 0x%x virt 0x%x size 0x%x\n",
-							__func__,
-							map_obj->mpu_addr,
-							map_obj->dsp_addr,
-							map_obj->size);
-
-		if (match_exact_map_obj(map_obj, dsp_addr, size)) {
-			pr_debug("%s: match, deleting map info\n", __func__);
-			list_del(&map_obj->link);
-			kfree(map_obj->dma_info.sg);
-			kfree(map_obj->pages);
-			kfree(map_obj);
-			goto out;
-		}
-		pr_debug("%s: candidate didn't match\n", __func__);
-	}
-
-	pr_err("%s: failed to find given map info\n", __func__);
-out:
-	spin_unlock(&pr_ctxt->dmm_map_lock);
-}
-
-static int match_containing_map_obj(struct dmm_map_object *map_obj,
-					u32 mpu_addr, u32 size)
-{
-	u32 map_obj_end = map_obj->mpu_addr + map_obj->size;
-
-	return mpu_addr >= map_obj->mpu_addr &&
-		mpu_addr + size <= map_obj_end;
-}
-
-static struct dmm_map_object *find_containing_mapping(
-				struct process_context *pr_ctxt,
-				u32 mpu_addr, u32 size)
-{
-	struct dmm_map_object *map_obj;
-
-	pr_debug("%s: looking for mpu_addr 0x%x size 0x%x\n", __func__,
-						mpu_addr, size);
-
-	spin_lock(&pr_ctxt->dmm_map_lock);
-	list_for_each_entry(map_obj, &pr_ctxt->dmm_map_list, link) {
-		pr_debug("%s: candidate: mpu_addr 0x%x virt 0x%x size 0x%x\n",
-						__func__,
-						map_obj->mpu_addr,
-						map_obj->dsp_addr,
-						map_obj->size);
-		if (match_containing_map_obj(map_obj, mpu_addr, size)) {
-			pr_debug("%s: match!\n", __func__);
-			goto out;
-		}
-
-		pr_debug("%s: no match!\n", __func__);
-	}
-
-	map_obj = NULL;
-out:
-	spin_unlock(&pr_ctxt->dmm_map_lock);
-	return map_obj;
-}
-
-static int find_first_page_in_cache(struct dmm_map_object *map_obj,
-					unsigned long mpu_addr)
-{
-	u32 mapped_base_page = map_obj->mpu_addr >> PAGE_SHIFT;
-	u32 requested_base_page = mpu_addr >> PAGE_SHIFT;
-	int pg_index = requested_base_page - mapped_base_page;
-
-	if (pg_index < 0 || pg_index >= map_obj->num_usr_pgs) {
-		pr_err("%s: failed (got %d)\n", __func__, pg_index);
-		return -1;
-	}
-
-	pr_debug("%s: first page is %d\n", __func__, pg_index);
-	return pg_index;
-}
-
-static inline struct page *get_mapping_page(struct dmm_map_object *map_obj,
-								int pg_i)
-{
-	pr_debug("%s: looking for pg_i %d, num_usr_pgs: %d\n", __func__,
-					pg_i, map_obj->num_usr_pgs);
-
-	if (pg_i < 0 || pg_i >= map_obj->num_usr_pgs) {
-		pr_err("%s: requested pg_i %d is out of mapped range\n",
-				__func__, pg_i);
-		return NULL;
-	}
-
-	return map_obj->pages[pg_i];
-}
-
-/*
- *  ======== proc_attach ========
- *  Purpose:
- *      Prepare for communication with a particular DSP processor, and return
- *      a handle to the processor object.
- */
-int
-proc_attach(u32 processor_id,
-	    const struct dsp_processorattrin *attr_in,
-	    void **ph_processor, struct process_context *pr_ctxt)
-{
-	int status = 0;
-	struct dev_object *hdev_obj;
-	struct proc_object *p_proc_object = NULL;
-	struct mgr_object *hmgr_obj = NULL;
-	struct drv_object *hdrv_obj = NULL;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-	u8 dev_type;
-
-	if (pr_ctxt->processor) {
-		*ph_processor = pr_ctxt->processor;
-		return status;
-	}
-
-	/* Get the Driver and Manager Object Handles */
-	if (!drv_datap || !drv_datap->drv_object || !drv_datap->mgr_object) {
-		status = -ENODATA;
-		pr_err("%s: Failed to get object handles\n", __func__);
-	} else {
-		hdrv_obj = drv_datap->drv_object;
-		hmgr_obj = drv_datap->mgr_object;
-	}
-
-	if (!status) {
-		/* Get the Device Object */
-		status = drv_get_dev_object(processor_id, hdrv_obj, &hdev_obj);
-	}
-	if (!status)
-		status = dev_get_dev_type(hdev_obj, &dev_type);
-
-	if (status)
-		goto func_end;
-
-	/* If we made it this far, create the Processor object: */
-	p_proc_object = kzalloc(sizeof(struct proc_object), GFP_KERNEL);
-	/* Fill out the Processor Object: */
-	if (p_proc_object == NULL) {
-		status = -ENOMEM;
-		goto func_end;
-	}
-	p_proc_object->dev_obj = hdev_obj;
-	p_proc_object->mgr_obj = hmgr_obj;
-	p_proc_object->processor_id = dev_type;
-	/* Store TGID instead of process handle */
-	p_proc_object->process = current->tgid;
-
-	INIT_LIST_HEAD(&p_proc_object->proc_list);
-
-	if (attr_in)
-		p_proc_object->timeout = attr_in->timeout;
-	else
-		p_proc_object->timeout = PROC_DFLT_TIMEOUT;
-
-	status = dev_get_intf_fxns(hdev_obj, &p_proc_object->intf_fxns);
-	if (!status) {
-		status = dev_get_bridge_context(hdev_obj,
-					     &p_proc_object->bridge_context);
-		if (status)
-			kfree(p_proc_object);
-	} else
-		kfree(p_proc_object);
-
-	if (status)
-		goto func_end;
-
-	/* Create the Notification Object */
-	/* This is created with no event mask, no notify mask
-	 * and no valid handle to the notification. They all get
-	 * filled up when proc_register_notify is called */
-	p_proc_object->ntfy_obj = kmalloc(sizeof(struct ntfy_object),
-							GFP_KERNEL);
-	if (p_proc_object->ntfy_obj)
-		ntfy_init(p_proc_object->ntfy_obj);
-	else
-		status = -ENOMEM;
-
-	if (!status) {
-		/* Insert the Processor Object into the DEV List.
-		 * Return handle to this Processor Object:
-		 * Find out if the Device is already attached to a
-		 * Processor. If so, return AlreadyAttached status */
-		status = dev_insert_proc_object(p_proc_object->dev_obj,
-						(u32) p_proc_object,
-						&p_proc_object->
-						is_already_attached);
-		if (!status) {
-			if (p_proc_object->is_already_attached)
-				status = 0;
-		} else {
-			if (p_proc_object->ntfy_obj) {
-				ntfy_delete(p_proc_object->ntfy_obj);
-				kfree(p_proc_object->ntfy_obj);
-			}
-
-			kfree(p_proc_object);
-		}
-		if (!status) {
-			*ph_processor = (void *)p_proc_object;
-			pr_ctxt->processor = *ph_processor;
-			(void)proc_notify_clients(p_proc_object,
-						  DSP_PROCESSORATTACH);
-		}
-	} else {
-		/* Don't leak memory if status is failed */
-		kfree(p_proc_object);
-	}
-func_end:
-	return status;
-}
-
-static int get_exec_file(struct cfg_devnode *dev_node_obj,
-				struct dev_object *hdev_obj,
-				u32 size, char *exec_file)
-{
-	u8 dev_type;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-	dev_get_dev_type(hdev_obj, (u8 *) &dev_type);
-
-	if (!exec_file)
-		return -EFAULT;
-
-	if (dev_type == DSP_UNIT) {
-		if (!drv_datap || !drv_datap->base_img)
-			return -EFAULT;
-
-		if (strlen(drv_datap->base_img) >= size)
-			return -EINVAL;
-
-		strcpy(exec_file, drv_datap->base_img);
-	} else {
-		return -ENOENT;
-	}
-
-	return 0;
-}
-
-/*
- *  ======== proc_auto_start ======== =
- *  Purpose:
- *      A Particular device gets loaded with the default image
- *      if the AutoStart flag is set.
- *  Parameters:
- *      hdev_obj:     Handle to the Device
- *  Returns:
- *      0:   On Successful Loading
- *      -EPERM  General Failure
- *  Requires:
- *      hdev_obj != NULL
- *  Ensures:
- */
-int proc_auto_start(struct cfg_devnode *dev_node_obj,
-			   struct dev_object *hdev_obj)
-{
-	int status = -EPERM;
-	struct proc_object *p_proc_object;
-	char sz_exec_file[MAXCMDLINELEN];
-	char *argv[2];
-	struct mgr_object *hmgr_obj = NULL;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-	u8 dev_type;
-
-	/* Create a Dummy PROC Object */
-	if (!drv_datap || !drv_datap->mgr_object) {
-		status = -ENODATA;
-		pr_err("%s: Failed to retrieve the object handle\n", __func__);
-		goto func_end;
-	} else {
-		hmgr_obj = drv_datap->mgr_object;
-	}
-
-	p_proc_object = kzalloc(sizeof(struct proc_object), GFP_KERNEL);
-	if (p_proc_object == NULL) {
-		status = -ENOMEM;
-		goto func_end;
-	}
-	p_proc_object->dev_obj = hdev_obj;
-	p_proc_object->mgr_obj = hmgr_obj;
-	status = dev_get_intf_fxns(hdev_obj, &p_proc_object->intf_fxns);
-	if (!status)
-		status = dev_get_bridge_context(hdev_obj,
-					     &p_proc_object->bridge_context);
-	if (status)
-		goto func_cont;
-
-	/* Stop the Device, put it into standby mode */
-	status = proc_stop(p_proc_object);
-
-	if (status)
-		goto func_cont;
-
-	/* Get the default executable for this board... */
-	dev_get_dev_type(hdev_obj, (u8 *) &dev_type);
-	p_proc_object->processor_id = dev_type;
-	status = get_exec_file(dev_node_obj, hdev_obj, sizeof(sz_exec_file),
-			       sz_exec_file);
-	if (!status) {
-		argv[0] = sz_exec_file;
-		argv[1] = NULL;
-		/* ...and try to load it: */
-		status = proc_load(p_proc_object, 1, (const char **)argv, NULL);
-		if (!status)
-			status = proc_start(p_proc_object);
-	}
-	kfree(p_proc_object->last_coff);
-	p_proc_object->last_coff = NULL;
-func_cont:
-	kfree(p_proc_object);
-func_end:
-	return status;
-}
-
-/*
- *  ======== proc_ctrl ========
- *  Purpose:
- *      Pass control information to the GPP device driver managing the
- *      DSP processor.
- *
- *      This will be an OEM-only function, and not part of the DSP/BIOS Bridge
- *      application developer's API.
- *      Call the bridge_dev_ctrl fxn with the Argument. This is a Synchronous
- *      Operation. arg can be null.
- */
-int proc_ctrl(void *hprocessor, u32 dw_cmd, struct dsp_cbdata *arg)
-{
-	int status = 0;
-	struct proc_object *p_proc_object = hprocessor;
-	u32 timeout = 0;
-
-	if (p_proc_object) {
-		/* intercept PWR deep sleep command */
-		if (dw_cmd == BRDIOCTL_DEEPSLEEP) {
-			timeout = arg->cb_data;
-			status = pwr_sleep_dsp(PWR_DEEPSLEEP, timeout);
-		}
-		/* intercept PWR emergency sleep command */
-		else if (dw_cmd == BRDIOCTL_EMERGENCYSLEEP) {
-			timeout = arg->cb_data;
-			status = pwr_sleep_dsp(PWR_EMERGENCYDEEPSLEEP, timeout);
-		} else if (dw_cmd == PWR_DEEPSLEEP) {
-			/* timeout = arg->cb_data; */
-			status = pwr_sleep_dsp(PWR_DEEPSLEEP, timeout);
-		}
-		/* intercept PWR wake commands */
-		else if (dw_cmd == BRDIOCTL_WAKEUP) {
-			timeout = arg->cb_data;
-			status = pwr_wake_dsp(timeout);
-		} else if (dw_cmd == PWR_WAKEUP) {
-			/* timeout = arg->cb_data; */
-			status = pwr_wake_dsp(timeout);
-		} else
-		    if (!((*p_proc_object->intf_fxns->dev_cntrl)
-				      (p_proc_object->bridge_context, dw_cmd,
-				       arg))) {
-			status = 0;
-		} else {
-			status = -EPERM;
-		}
-	} else {
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== proc_detach ========
- *  Purpose:
- *      Destroys the  Processor Object. Removes the notification from the Dev
- *      List.
- */
-int proc_detach(struct process_context *pr_ctxt)
-{
-	int status = 0;
-	struct proc_object *p_proc_object = NULL;
-
-	p_proc_object = (struct proc_object *)pr_ctxt->processor;
-
-	if (p_proc_object) {
-		/* Notify the Client */
-		ntfy_notify(p_proc_object->ntfy_obj, DSP_PROCESSORDETACH);
-		/* Remove the notification memory */
-		if (p_proc_object->ntfy_obj) {
-			ntfy_delete(p_proc_object->ntfy_obj);
-			kfree(p_proc_object->ntfy_obj);
-		}
-
-		kfree(p_proc_object->last_coff);
-		p_proc_object->last_coff = NULL;
-		/* Remove the Proc from the DEV List */
-		(void)dev_remove_proc_object(p_proc_object->dev_obj,
-					     (u32) p_proc_object);
-		/* Free the Processor Object */
-		kfree(p_proc_object);
-		pr_ctxt->processor = NULL;
-	} else {
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== proc_enum_nodes ========
- *  Purpose:
- *      Enumerate and get configuration information about nodes allocated
- *      on a DSP processor.
- */
-int proc_enum_nodes(void *hprocessor, void **node_tab,
-			   u32 node_tab_size, u32 *pu_num_nodes,
-			   u32 *pu_allocated)
-{
-	int status = -EPERM;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	struct node_mgr *hnode_mgr = NULL;
-
-	if (p_proc_object) {
-		if (!(dev_get_node_manager(p_proc_object->dev_obj,
-						       &hnode_mgr))) {
-			if (hnode_mgr) {
-				status = node_enum_nodes(hnode_mgr, node_tab,
-							 node_tab_size,
-							 pu_num_nodes,
-							 pu_allocated);
-			}
-		}
-	} else {
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/* Cache operation against kernel address instead of users */
-static int build_dma_sg(struct dmm_map_object *map_obj, unsigned long start,
-						ssize_t len, int pg_i)
-{
-	struct page *page;
-	unsigned long offset;
-	ssize_t rest;
-	int ret = 0, i = 0;
-	struct scatterlist *sg = map_obj->dma_info.sg;
-
-	while (len) {
-		page = get_mapping_page(map_obj, pg_i);
-		if (!page) {
-			pr_err("%s: no page for %08lx\n", __func__, start);
-			ret = -EINVAL;
-			goto out;
-		} else if (IS_ERR(page)) {
-			pr_err("%s: err page for %08lx(%lu)\n", __func__, start,
-			       PTR_ERR(page));
-			ret = PTR_ERR(page);
-			goto out;
-		}
-
-		offset = start & ~PAGE_MASK;
-		rest = min_t(ssize_t, PAGE_SIZE - offset, len);
-
-		sg_set_page(&sg[i], page, rest, offset);
-
-		len -= rest;
-		start += rest;
-		pg_i++, i++;
-	}
-
-	if (i != map_obj->dma_info.num_pages) {
-		pr_err("%s: bad number of sg iterations\n", __func__);
-		ret = -EFAULT;
-		goto out;
-	}
-
-out:
-	return ret;
-}
-
-static int memory_regain_ownership(struct dmm_map_object *map_obj,
-		unsigned long start, ssize_t len, enum dma_data_direction dir)
-{
-	int ret = 0;
-	unsigned long first_data_page = start >> PAGE_SHIFT;
-	unsigned long last_data_page = ((u32)(start + len - 1) >> PAGE_SHIFT);
-	/* calculating the number of pages this area spans */
-	unsigned long num_pages = last_data_page - first_data_page + 1;
-	struct bridge_dma_map_info *dma_info = &map_obj->dma_info;
-
-	if (!dma_info->sg)
-		goto out;
-
-	if (dma_info->dir != dir || dma_info->num_pages != num_pages) {
-		pr_err("%s: dma info doesn't match given params\n", __func__);
-		return -EINVAL;
-	}
-
-	dma_unmap_sg(bridge, dma_info->sg, num_pages, dma_info->dir);
-
-	pr_debug("%s: dma_map_sg unmapped\n", __func__);
-
-	kfree(dma_info->sg);
-
-	map_obj->dma_info.sg = NULL;
-
-out:
-	return ret;
-}
-
-/* Cache operation against kernel address instead of users */
-static int memory_give_ownership(struct dmm_map_object *map_obj,
-		unsigned long start, ssize_t len, enum dma_data_direction dir)
-{
-	int pg_i, ret, sg_num;
-	struct scatterlist *sg;
-	unsigned long first_data_page = start >> PAGE_SHIFT;
-	unsigned long last_data_page = ((u32)(start + len - 1) >> PAGE_SHIFT);
-	/* calculating the number of pages this area spans */
-	unsigned long num_pages = last_data_page - first_data_page + 1;
-
-	pg_i = find_first_page_in_cache(map_obj, start);
-	if (pg_i < 0) {
-		pr_err("%s: failed to find first page in cache\n", __func__);
-		ret = -EINVAL;
-		goto out;
-	}
-
-	sg = kcalloc(num_pages, sizeof(*sg), GFP_KERNEL);
-	if (!sg) {
-		ret = -ENOMEM;
-		goto out;
-	}
-
-	sg_init_table(sg, num_pages);
-
-	/* cleanup a previous sg allocation */
-	/* this may happen if application doesn't signal for e/o DMA */
-	kfree(map_obj->dma_info.sg);
-
-	map_obj->dma_info.sg = sg;
-	map_obj->dma_info.dir = dir;
-	map_obj->dma_info.num_pages = num_pages;
-
-	ret = build_dma_sg(map_obj, start, len, pg_i);
-	if (ret)
-		goto kfree_sg;
-
-	sg_num = dma_map_sg(bridge, sg, num_pages, dir);
-	if (sg_num < 1) {
-		pr_err("%s: dma_map_sg failed: %d\n", __func__, sg_num);
-		ret = -EFAULT;
-		goto kfree_sg;
-	}
-
-	pr_debug("%s: dma_map_sg mapped %d elements\n", __func__, sg_num);
-	map_obj->dma_info.sg_num = sg_num;
-
-	return 0;
-
-kfree_sg:
-	kfree(sg);
-	map_obj->dma_info.sg = NULL;
-out:
-	return ret;
-}
-
-int proc_begin_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
-				enum dma_data_direction dir)
-{
-	/* Keep STATUS here for future additions to this function */
-	int status = 0;
-	struct process_context *pr_ctxt = (struct process_context *) hprocessor;
-	struct dmm_map_object *map_obj;
-
-	if (!pr_ctxt) {
-		status = -EFAULT;
-		goto err_out;
-	}
-
-	pr_debug("%s: addr 0x%x, size 0x%x, type %d\n", __func__,
-							(u32)pmpu_addr,
-							ul_size, dir);
-
-	mutex_lock(&proc_lock);
-
-	/* find requested memory are in cached mapping information */
-	map_obj = find_containing_mapping(pr_ctxt, (u32) pmpu_addr, ul_size);
-	if (!map_obj) {
-		pr_err("%s: find_containing_mapping failed\n", __func__);
-		status = -EFAULT;
-		goto no_map;
-	}
-
-	if (memory_give_ownership(map_obj, (u32) pmpu_addr, ul_size, dir)) {
-		pr_err("%s: InValid address parameters %p %x\n",
-			       __func__, pmpu_addr, ul_size);
-		status = -EFAULT;
-	}
-
-no_map:
-	mutex_unlock(&proc_lock);
-err_out:
-
-	return status;
-}
-
-int proc_end_dma(void *hprocessor, void *pmpu_addr, u32 ul_size,
-			enum dma_data_direction dir)
-{
-	/* Keep STATUS here for future additions to this function */
-	int status = 0;
-	struct process_context *pr_ctxt = (struct process_context *) hprocessor;
-	struct dmm_map_object *map_obj;
-
-	if (!pr_ctxt) {
-		status = -EFAULT;
-		goto err_out;
-	}
-
-	pr_debug("%s: addr 0x%x, size 0x%x, type %d\n", __func__,
-							(u32)pmpu_addr,
-							ul_size, dir);
-
-	mutex_lock(&proc_lock);
-
-	/* find requested memory are in cached mapping information */
-	map_obj = find_containing_mapping(pr_ctxt, (u32) pmpu_addr, ul_size);
-	if (!map_obj) {
-		pr_err("%s: find_containing_mapping failed\n", __func__);
-		status = -EFAULT;
-		goto no_map;
-	}
-
-	if (memory_regain_ownership(map_obj, (u32) pmpu_addr, ul_size, dir)) {
-		pr_err("%s: InValid address parameters %p %x\n",
-		       __func__, pmpu_addr, ul_size);
-		status = -EFAULT;
-	}
-
-no_map:
-	mutex_unlock(&proc_lock);
-err_out:
-	return status;
-}
-
-/*
- *  ======== proc_flush_memory ========
- *  Purpose:
- *     Flush cache
- */
-int proc_flush_memory(void *hprocessor, void *pmpu_addr,
-			     u32 ul_size, u32 ul_flags)
-{
-	enum dma_data_direction dir = DMA_BIDIRECTIONAL;
-
-	return proc_begin_dma(hprocessor, pmpu_addr, ul_size, dir);
-}
-
-/*
- *  ======== proc_invalidate_memory ========
- *  Purpose:
- *     Invalidates the memory specified
- */
-int proc_invalidate_memory(void *hprocessor, void *pmpu_addr, u32 size)
-{
-	enum dma_data_direction dir = DMA_FROM_DEVICE;
-
-	return proc_begin_dma(hprocessor, pmpu_addr, size, dir);
-}
-
-/*
- *  ======== proc_get_resource_info ========
- *  Purpose:
- *      Enumerate the resources currently available on a processor.
- */
-int proc_get_resource_info(void *hprocessor, u32 resource_type,
-				  struct dsp_resourceinfo *resource_info,
-				  u32 resource_info_size)
-{
-	int status = -EPERM;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	struct node_mgr *hnode_mgr = NULL;
-	struct nldr_object *nldr_obj = NULL;
-	struct rmm_target_obj *rmm = NULL;
-	struct io_mgr *hio_mgr = NULL;	/* IO manager handle */
-
-	if (!p_proc_object) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	switch (resource_type) {
-	case DSP_RESOURCE_DYNDARAM:
-	case DSP_RESOURCE_DYNSARAM:
-	case DSP_RESOURCE_DYNEXTERNAL:
-	case DSP_RESOURCE_DYNSRAM:
-		status = dev_get_node_manager(p_proc_object->dev_obj,
-					      &hnode_mgr);
-		if (!hnode_mgr) {
-			status = -EFAULT;
-			goto func_end;
-		}
-
-		status = node_get_nldr_obj(hnode_mgr, &nldr_obj);
-		if (!status) {
-			status = nldr_get_rmm_manager(nldr_obj, &rmm);
-			if (rmm) {
-				if (!rmm_stat(rmm,
-					      (enum dsp_memtype)resource_type,
-					      (struct dsp_memstat *)
-					      &(resource_info->result.
-						mem_stat)))
-					status = -EINVAL;
-			} else {
-				status = -EFAULT;
-			}
-		}
-		break;
-	case DSP_RESOURCE_PROCLOAD:
-		status = dev_get_io_mgr(p_proc_object->dev_obj, &hio_mgr);
-		if (hio_mgr)
-			status =
-			    p_proc_object->intf_fxns->
-			    io_get_proc_load(hio_mgr,
-						 (struct dsp_procloadstat *)
-						 &(resource_info->result.
-						   proc_load_stat));
-		else
-			status = -EFAULT;
-		break;
-	default:
-		status = -EPERM;
-		break;
-	}
-func_end:
-	return status;
-}
-
-/*
- *  ======== proc_get_dev_object ========
- *  Purpose:
- *      Return the Dev Object handle for a given Processor.
- *
- */
-int proc_get_dev_object(void *hprocessor,
-			       struct dev_object **device_obj)
-{
-	int status = -EPERM;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-
-	if (p_proc_object) {
-		*device_obj = p_proc_object->dev_obj;
-		status = 0;
-	} else {
-		*device_obj = NULL;
-		status = -EFAULT;
-	}
-
-	return status;
-}
-
-/*
- *  ======== proc_get_state ========
- *  Purpose:
- *      Report the state of the specified DSP processor.
- */
-int proc_get_state(void *hprocessor,
-			  struct dsp_processorstate *proc_state_obj,
-			  u32 state_info_size)
-{
-	int status = 0;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	int brd_status;
-
-	if (p_proc_object) {
-		/* First, retrieve BRD state information */
-		status = (*p_proc_object->intf_fxns->brd_status)
-		    (p_proc_object->bridge_context, &brd_status);
-		if (!status) {
-			switch (brd_status) {
-			case BRD_STOPPED:
-				proc_state_obj->proc_state = PROC_STOPPED;
-				break;
-			case BRD_SLEEP_TRANSITION:
-			case BRD_DSP_HIBERNATION:
-				/* Fall through */
-			case BRD_RUNNING:
-				proc_state_obj->proc_state = PROC_RUNNING;
-				break;
-			case BRD_LOADED:
-				proc_state_obj->proc_state = PROC_LOADED;
-				break;
-			case BRD_ERROR:
-				proc_state_obj->proc_state = PROC_ERROR;
-				break;
-			default:
-				proc_state_obj->proc_state = 0xFF;
-				status = -EPERM;
-				break;
-			}
-		}
-	} else {
-		status = -EFAULT;
-	}
-	dev_dbg(bridge, "%s, results: status: 0x%x proc_state_obj: 0x%x\n",
-		__func__, status, proc_state_obj->proc_state);
-	return status;
-}
-
-/*
- *  ======== proc_get_trace ========
- *  Purpose:
- *      Retrieve the current contents of the trace buffer, located on the
- *      Processor.  Predefined symbols for the trace buffer must have been
- *      configured into the DSP executable.
- *  Details:
- *      We support using the symbols SYS_PUTCBEG and SYS_PUTCEND to define a
- *      trace buffer, only.  Treat it as an undocumented feature.
- *      This call is destructive, meaning the processor is placed in the monitor
- *      state as a result of this function.
- */
-int proc_get_trace(void *hprocessor, u8 *pbuf, u32 max_size)
-{
-	int status;
-
-	status = -ENOSYS;
-	return status;
-}
-
-/*
- *  ======== proc_load ========
- *  Purpose:
- *      Reset a processor and load a new base program image.
- *      This will be an OEM-only function, and not part of the DSP/BIOS Bridge
- *      application developer's API.
- */
-int proc_load(void *hprocessor, const s32 argc_index,
-		     const char **user_args, const char **user_envp)
-{
-	int status = 0;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	struct io_mgr *hio_mgr;	/* IO manager handle */
-	struct msg_mgr *hmsg_mgr;
-	struct cod_manager *cod_mgr;	/* Code manager handle */
-	char *pargv0;		/* temp argv[0] ptr */
-	char **new_envp;	/* Updated envp[] array. */
-	char sz_proc_id[MAXPROCIDLEN];	/* Size of "PROC_ID=<n>" */
-	s32 envp_elems;		/* Num elements in envp[]. */
-	s32 cnew_envp;		/* "  " in new_envp[] */
-	s32 nproc_id = 0;	/* Anticipate MP version. */
-	struct dcd_manager *hdcd_handle;
-	struct dmm_object *dmm_mgr;
-	u32 dw_ext_end;
-	u32 proc_id;
-	int brd_state;
-	struct drv_data *drv_datap = dev_get_drvdata(bridge);
-
-#ifdef OPT_LOAD_TIME_INSTRUMENTATION
-	struct timeval tv1;
-	struct timeval tv2;
-#endif
-
-#if defined(CONFIG_TIDSPBRIDGE_DVFS) && !defined(CONFIG_CPU_FREQ)
-	struct dspbridge_platform_data *pdata =
-	    omap_dspbridge_dev->dev.platform_data;
-#endif
-
-#ifdef OPT_LOAD_TIME_INSTRUMENTATION
-	do_gettimeofday(&tv1);
-#endif
-	if (!p_proc_object) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	dev_get_cod_mgr(p_proc_object->dev_obj, &cod_mgr);
-	if (!cod_mgr) {
-		status = -EPERM;
-		goto func_end;
-	}
-	status = proc_stop(hprocessor);
-	if (status)
-		goto func_end;
-
-	/* Place the board in the monitor state. */
-	status = proc_monitor(hprocessor);
-	if (status)
-		goto func_end;
-
-	/* Save ptr to  original argv[0]. */
-	pargv0 = (char *)user_args[0];
-	/*Prepend "PROC_ID=<nproc_id>"to envp array for target. */
-	envp_elems = get_envp_count((char **)user_envp);
-	cnew_envp = (envp_elems ? (envp_elems + 1) : (envp_elems + 2));
-	new_envp = kzalloc(cnew_envp * sizeof(char **), GFP_KERNEL);
-	if (new_envp) {
-		status = snprintf(sz_proc_id, MAXPROCIDLEN, PROC_ENVPROCID,
-				  nproc_id);
-		if (status == -1) {
-			dev_dbg(bridge, "%s: Proc ID string overflow\n",
-				__func__);
-			status = -EPERM;
-		} else {
-			new_envp =
-			    prepend_envp(new_envp, (char **)user_envp,
-					 envp_elems, cnew_envp, sz_proc_id);
-			/* Get the DCD Handle */
-			status = mgr_get_dcd_handle(p_proc_object->mgr_obj,
-						    (u32 *) &hdcd_handle);
-			if (!status) {
-				/*  Before proceeding with new load,
-				 *  check if a previously registered COFF
-				 *  exists.
-				 *  If yes, unregister nodes in previously
-				 *  registered COFF.  If any error occurred,
-				 *  set previously registered COFF to NULL. */
-				if (p_proc_object->last_coff != NULL) {
-					status =
-					    dcd_auto_unregister(hdcd_handle,
-								p_proc_object->
-								last_coff);
-					/* Regardless of auto unregister status,
-					 *  free previously allocated
-					 *  memory. */
-					kfree(p_proc_object->last_coff);
-					p_proc_object->last_coff = NULL;
-				}
-			}
-			/* On success, do cod_open_base() */
-			status = cod_open_base(cod_mgr, (char *)user_args[0],
-					       COD_SYMB);
-		}
-	} else {
-		status = -ENOMEM;
-	}
-	if (!status) {
-		/* Auto-register data base */
-		/* Get the DCD Handle */
-		status = mgr_get_dcd_handle(p_proc_object->mgr_obj,
-					    (u32 *) &hdcd_handle);
-		if (!status) {
-			/*  Auto register nodes in specified COFF
-			 *  file.  If registration did not fail,
-			 *  (status = 0 or -EACCES)
-			 *  save the name of the COFF file for
-			 *  de-registration in the future. */
-			status =
-			    dcd_auto_register(hdcd_handle,
-					      (char *)user_args[0]);
-			if (status == -EACCES)
-				status = 0;
-
-			if (status) {
-				status = -EPERM;
-			} else {
-				/* Allocate memory for pszLastCoff */
-				p_proc_object->last_coff =
-						kzalloc((strlen(user_args[0]) +
-						1), GFP_KERNEL);
-				/* If memory allocated, save COFF file name */
-				if (p_proc_object->last_coff) {
-					strncpy(p_proc_object->last_coff,
-						(char *)user_args[0],
-						(strlen((char *)user_args[0]) +
-						 1));
-				}
-			}
-		}
-	}
-	/* Update shared memory address and size */
-	if (!status) {
-		/*  Create the message manager. This must be done
-		 *  before calling the IOOnLoaded function. */
-		dev_get_msg_mgr(p_proc_object->dev_obj, &hmsg_mgr);
-		if (!hmsg_mgr) {
-			status = msg_create(&hmsg_mgr, p_proc_object->dev_obj,
-					    (msg_onexit) node_on_exit);
-			dev_set_msg_mgr(p_proc_object->dev_obj, hmsg_mgr);
-		}
-	}
-	if (!status) {
-		/* Set the Device object's message manager */
-		status = dev_get_io_mgr(p_proc_object->dev_obj, &hio_mgr);
-		if (hio_mgr)
-			status = (*p_proc_object->intf_fxns->io_on_loaded)
-								(hio_mgr);
-		else
-			status = -EFAULT;
-	}
-	if (!status) {
-		/* Now, attempt to load an exec: */
-
-		/* Boost the OPP level to Maximum level supported by baseport */
-#if defined(CONFIG_TIDSPBRIDGE_DVFS) && !defined(CONFIG_CPU_FREQ)
-		if (pdata->cpu_set_freq)
-			(*pdata->cpu_set_freq) (pdata->mpu_speed[VDD1_OPP5]);
-#endif
-		status = cod_load_base(cod_mgr, argc_index, (char **)user_args,
-				       dev_brd_write_fxn,
-				       p_proc_object->dev_obj, NULL);
-		if (status) {
-			if (status == -EBADF) {
-				dev_dbg(bridge, "%s: Failure to Load the EXE\n",
-					__func__);
-			}
-			if (status == -ESPIPE) {
-				pr_err("%s: Couldn't parse the file\n",
-				       __func__);
-			}
-		}
-		/* Requesting the lowest opp supported */
-#if defined(CONFIG_TIDSPBRIDGE_DVFS) && !defined(CONFIG_CPU_FREQ)
-		if (pdata->cpu_set_freq)
-			(*pdata->cpu_set_freq) (pdata->mpu_speed[VDD1_OPP1]);
-#endif
-
-	}
-	if (!status) {
-		/* Update the Processor status to loaded */
-		status = (*p_proc_object->intf_fxns->brd_set_state)
-		    (p_proc_object->bridge_context, BRD_LOADED);
-		if (!status) {
-			p_proc_object->proc_state = PROC_LOADED;
-			if (p_proc_object->ntfy_obj)
-				proc_notify_clients(p_proc_object,
-						    DSP_PROCESSORSTATECHANGE);
-		}
-	}
-	if (!status) {
-		status = proc_get_processor_id(hprocessor, &proc_id);
-		if (proc_id == DSP_UNIT) {
-			/* Use all available DSP address space after EXTMEM
-			 * for DMM */
-			if (!status)
-				status = cod_get_sym_value(cod_mgr, EXTEND,
-							   &dw_ext_end);
-
-			/* Reset DMM structs and add an initial free chunk */
-			if (!status) {
-				status =
-				    dev_get_dmm_mgr(p_proc_object->dev_obj,
-						    &dmm_mgr);
-				if (dmm_mgr) {
-					/* Set dw_ext_end to DMM START u8
-					 * address */
-					dw_ext_end =
-					    (dw_ext_end + 1) * DSPWORDSIZE;
-					/* DMM memory is from EXT_END */
-					status = dmm_create_tables(dmm_mgr,
-								   dw_ext_end,
-								   DMMPOOLSIZE);
-				} else {
-					status = -EFAULT;
-				}
-			}
-		}
-	}
-	/* Restore the original argv[0] */
-	kfree(new_envp);
-	user_args[0] = pargv0;
-	if (!status) {
-		if (!((*p_proc_object->intf_fxns->brd_status)
-				(p_proc_object->bridge_context, &brd_state))) {
-			pr_info("%s: Processor Loaded %s\n", __func__, pargv0);
-			kfree(drv_datap->base_img);
-			drv_datap->base_img = kstrdup(pargv0, GFP_KERNEL);
-			if (!drv_datap->base_img)
-				status = -ENOMEM;
-		}
-	}
-
-func_end:
-	if (status) {
-		pr_err("%s: Processor failed to load\n", __func__);
-		proc_stop(p_proc_object);
-	}
-#ifdef OPT_LOAD_TIME_INSTRUMENTATION
-	do_gettimeofday(&tv2);
-	if (tv2.tv_usec < tv1.tv_usec) {
-		tv2.tv_usec += 1000000;
-		tv2.tv_sec--;
-	}
-	dev_dbg(bridge, "%s: time to load %d sec and %d usec\n", __func__,
-		tv2.tv_sec - tv1.tv_sec, tv2.tv_usec - tv1.tv_usec);
-#endif
-	return status;
-}
-
-/*
- *  ======== proc_map ========
- *  Purpose:
- *      Maps a MPU buffer to DSP address space.
- */
-int proc_map(void *hprocessor, void *pmpu_addr, u32 ul_size,
-		    void *req_addr, void **pp_map_addr, u32 ul_map_attr,
-		    struct process_context *pr_ctxt)
-{
-	u32 va_align;
-	u32 pa_align;
-	struct dmm_object *dmm_mgr;
-	u32 size_align;
-	int status = 0;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	struct dmm_map_object *map_obj;
-	u32 tmp_addr = 0;
-
-#ifdef CONFIG_TIDSPBRIDGE_CACHE_LINE_CHECK
-	if ((ul_map_attr & BUFMODE_MASK) != RBUF) {
-		if (!IS_ALIGNED((u32)pmpu_addr, DSP_CACHE_LINE) ||
-		    !IS_ALIGNED(ul_size, DSP_CACHE_LINE)) {
-			pr_err("%s: not aligned: 0x%x (%d)\n", __func__,
-						(u32)pmpu_addr, ul_size);
-			return -EFAULT;
-		}
-	}
-#endif
-
-	/* Calculate the page-aligned PA, VA and size */
-	va_align = PG_ALIGN_LOW((u32) req_addr, PG_SIZE4K);
-	pa_align = PG_ALIGN_LOW((u32) pmpu_addr, PG_SIZE4K);
-	size_align = PG_ALIGN_HIGH(ul_size + (u32) pmpu_addr - pa_align,
-				   PG_SIZE4K);
-
-	if (!p_proc_object) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	/* Critical section */
-	mutex_lock(&proc_lock);
-	dmm_get_handle(p_proc_object, &dmm_mgr);
-	if (dmm_mgr)
-		status = dmm_map_memory(dmm_mgr, va_align, size_align);
-	else
-		status = -EFAULT;
-
-	/* Add mapping to the page tables. */
-	if (!status) {
-
-		/* Mapped address = MSB of VA | LSB of PA */
-		tmp_addr = (va_align | ((u32) pmpu_addr & (PG_SIZE4K - 1)));
-		/* mapped memory resource tracking */
-		map_obj = add_mapping_info(pr_ctxt, pa_align, tmp_addr,
-						size_align);
-		if (!map_obj)
-			status = -ENOMEM;
-		else
-			status = (*p_proc_object->intf_fxns->brd_mem_map)
-			    (p_proc_object->bridge_context, pa_align, va_align,
-			     size_align, ul_map_attr, map_obj->pages);
-	}
-	if (!status) {
-		/* Mapped address = MSB of VA | LSB of PA */
-		*pp_map_addr = (void *) tmp_addr;
-	} else {
-		remove_mapping_information(pr_ctxt, tmp_addr, size_align);
-		dmm_un_map_memory(dmm_mgr, va_align, &size_align);
-	}
-	mutex_unlock(&proc_lock);
-
-	if (status)
-		goto func_end;
-
-func_end:
-	dev_dbg(bridge, "%s: hprocessor %p, pmpu_addr %p, ul_size %x, "
-		"req_addr %p, ul_map_attr %x, pp_map_addr %p, va_align %x, "
-		"pa_align %x, size_align %x status 0x%x\n", __func__,
-		hprocessor, pmpu_addr, ul_size, req_addr, ul_map_attr,
-		pp_map_addr, va_align, pa_align, size_align, status);
-
-	return status;
-}
-
-/*
- *  ======== proc_register_notify ========
- *  Purpose:
- *      Register to be notified of specific processor events.
- */
-int proc_register_notify(void *hprocessor, u32 event_mask,
-				u32 notify_type, struct dsp_notification
-				*hnotification)
-{
-	int status = 0;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	struct deh_mgr *hdeh_mgr;
-
-	/* Check processor handle */
-	if (!p_proc_object) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	/* Check if event mask is a valid processor related event */
-	if (event_mask & ~(DSP_PROCESSORSTATECHANGE | DSP_PROCESSORATTACH |
-			DSP_PROCESSORDETACH | DSP_PROCESSORRESTART |
-			DSP_MMUFAULT | DSP_SYSERROR | DSP_PWRERROR |
-			DSP_WDTOVERFLOW))
-		status = -EINVAL;
-
-	/* Check if notify type is valid */
-	if (notify_type != DSP_SIGNALEVENT)
-		status = -EINVAL;
-
-	if (!status) {
-		/* If event mask is not DSP_SYSERROR, DSP_MMUFAULT,
-		 * or DSP_PWRERROR then register event immediately. */
-		if (event_mask &
-		    ~(DSP_SYSERROR | DSP_MMUFAULT | DSP_PWRERROR |
-				DSP_WDTOVERFLOW)) {
-			status = ntfy_register(p_proc_object->ntfy_obj,
-					       hnotification, event_mask,
-					       notify_type);
-			/* Special case alert, special case alert!
-			 * If we're trying to *deregister* (i.e. event_mask
-			 * is 0), a DSP_SYSERROR or DSP_MMUFAULT notification,
-			 * we have to deregister with the DEH manager.
-			 * There's no way to know, based on event_mask which
-			 * manager the notification event was registered with,
-			 * so if we're trying to deregister and ntfy_register
-			 * failed, we'll give the deh manager a shot.
-			 */
-			if ((event_mask == 0) && status) {
-				status =
-				    dev_get_deh_mgr(p_proc_object->dev_obj,
-						    &hdeh_mgr);
-				status =
-					bridge_deh_register_notify(hdeh_mgr,
-							event_mask,
-							notify_type,
-							hnotification);
-			}
-		} else {
-			status = dev_get_deh_mgr(p_proc_object->dev_obj,
-						 &hdeh_mgr);
-			status =
-			    bridge_deh_register_notify(hdeh_mgr,
-					    event_mask,
-					    notify_type,
-					    hnotification);
-
-		}
-	}
-func_end:
-	return status;
-}
-
-/*
- *  ======== proc_reserve_memory ========
- *  Purpose:
- *      Reserve a virtually contiguous region of DSP address space.
- */
-int proc_reserve_memory(void *hprocessor, u32 ul_size,
-			       void **pp_rsv_addr,
-			       struct process_context *pr_ctxt)
-{
-	struct dmm_object *dmm_mgr;
-	int status = 0;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	struct dmm_rsv_object *rsv_obj;
-
-	if (!p_proc_object) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	status = dmm_get_handle(p_proc_object, &dmm_mgr);
-	if (!dmm_mgr) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	status = dmm_reserve_memory(dmm_mgr, ul_size, (u32 *) pp_rsv_addr);
-	if (status != 0)
-		goto func_end;
-
-	/*
-	 * A successful reserve should be followed by insertion of rsv_obj
-	 * into dmm_rsv_list, so that reserved memory resource tracking
-	 * remains uptodate
-	 */
-	rsv_obj = kmalloc(sizeof(struct dmm_rsv_object), GFP_KERNEL);
-	if (rsv_obj) {
-		rsv_obj->dsp_reserved_addr = (u32) *pp_rsv_addr;
-		spin_lock(&pr_ctxt->dmm_rsv_lock);
-		list_add(&rsv_obj->link, &pr_ctxt->dmm_rsv_list);
-		spin_unlock(&pr_ctxt->dmm_rsv_lock);
-	}
-
-func_end:
-	dev_dbg(bridge, "%s: hprocessor: 0x%p ul_size: 0x%x pp_rsv_addr: 0x%p "
-		"status 0x%x\n", __func__, hprocessor,
-		ul_size, pp_rsv_addr, status);
-	return status;
-}
-
-/*
- *  ======== proc_start ========
- *  Purpose:
- *      Start a processor running.
- */
-int proc_start(void *hprocessor)
-{
-	int status = 0;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	struct cod_manager *cod_mgr;	/* Code manager handle */
-	u32 dw_dsp_addr;	/* Loaded code's entry point. */
-	int brd_state;
-
-	if (!p_proc_object) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	/* Call the bridge_brd_start */
-	if (p_proc_object->proc_state != PROC_LOADED) {
-		status = -EBADR;
-		goto func_end;
-	}
-	status = dev_get_cod_mgr(p_proc_object->dev_obj, &cod_mgr);
-	if (!cod_mgr) {
-		status = -EFAULT;
-		goto func_cont;
-	}
-
-	status = cod_get_entry(cod_mgr, &dw_dsp_addr);
-	if (status)
-		goto func_cont;
-
-	status = (*p_proc_object->intf_fxns->brd_start)
-	    (p_proc_object->bridge_context, dw_dsp_addr);
-	if (status)
-		goto func_cont;
-
-	/* Call dev_create2 */
-	status = dev_create2(p_proc_object->dev_obj);
-	if (!status) {
-		p_proc_object->proc_state = PROC_RUNNING;
-		/* Deep sleep switces off the peripheral clocks.
-		 * we just put the DSP CPU in idle in the idle loop.
-		 * so there is no need to send a command to DSP */
-
-		if (p_proc_object->ntfy_obj) {
-			proc_notify_clients(p_proc_object,
-					    DSP_PROCESSORSTATECHANGE);
-		}
-	} else {
-		/* Failed to Create Node Manager and DISP Object
-		 * Stop the Processor from running. Put it in STOPPED State */
-		(void)(*p_proc_object->intf_fxns->
-		       brd_stop) (p_proc_object->bridge_context);
-		p_proc_object->proc_state = PROC_STOPPED;
-	}
-func_cont:
-	if (!status) {
-		if (!((*p_proc_object->intf_fxns->brd_status)
-				(p_proc_object->bridge_context, &brd_state))) {
-			pr_info("%s: dsp in running state\n", __func__);
-		}
-	} else {
-		pr_err("%s: Failed to start the dsp\n", __func__);
-		proc_stop(p_proc_object);
-	}
-
-func_end:
-	return status;
-}
-
-/*
- *  ======== proc_stop ========
- *  Purpose:
- *      Stop a processor running.
- */
-int proc_stop(void *hprocessor)
-{
-	int status = 0;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	struct msg_mgr *hmsg_mgr;
-	struct node_mgr *hnode_mgr;
-	void *hnode;
-	u32 node_tab_size = 1;
-	u32 num_nodes = 0;
-	u32 nodes_allocated = 0;
-
-	if (!p_proc_object) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	/* check if there are any running nodes */
-	status = dev_get_node_manager(p_proc_object->dev_obj, &hnode_mgr);
-	if (!status && hnode_mgr) {
-		status = node_enum_nodes(hnode_mgr, &hnode, node_tab_size,
-					 &num_nodes, &nodes_allocated);
-		if ((status == -EINVAL) || (nodes_allocated > 0)) {
-			pr_err("%s: Can't stop device, active nodes = %d\n",
-				__func__, nodes_allocated);
-			return -EBADR;
-		}
-	}
-	/* Call the bridge_brd_stop */
-	/* It is OK to stop a device that does n't have nodes OR not started */
-	status =
-	    (*p_proc_object->intf_fxns->
-	     brd_stop) (p_proc_object->bridge_context);
-	if (!status) {
-		dev_dbg(bridge, "%s: processor in standby mode\n", __func__);
-		p_proc_object->proc_state = PROC_STOPPED;
-		/* Destroy the Node Manager, msg_ctrl Manager */
-		if (!(dev_destroy2(p_proc_object->dev_obj))) {
-			/* Destroy the msg_ctrl by calling msg_delete */
-			dev_get_msg_mgr(p_proc_object->dev_obj, &hmsg_mgr);
-			if (hmsg_mgr) {
-				msg_delete(hmsg_mgr);
-				dev_set_msg_mgr(p_proc_object->dev_obj, NULL);
-			}
-		}
-	} else {
-		pr_err("%s: Failed to stop the processor\n", __func__);
-	}
-func_end:
-
-	return status;
-}
-
-/*
- *  ======== proc_un_map ========
- *  Purpose:
- *      Removes a MPU buffer mapping from the DSP address space.
- */
-int proc_un_map(void *hprocessor, void *map_addr,
-		       struct process_context *pr_ctxt)
-{
-	int status = 0;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	struct dmm_object *dmm_mgr;
-	u32 va_align;
-	u32 size_align;
-
-	va_align = PG_ALIGN_LOW((u32) map_addr, PG_SIZE4K);
-	if (!p_proc_object) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	status = dmm_get_handle(hprocessor, &dmm_mgr);
-	if (!dmm_mgr) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	/* Critical section */
-	mutex_lock(&proc_lock);
-	/*
-	 * Update DMM structures. Get the size to unmap.
-	 * This function returns error if the VA is not mapped
-	 */
-	status = dmm_un_map_memory(dmm_mgr, (u32) va_align, &size_align);
-	/* Remove mapping from the page tables. */
-	if (!status) {
-		status = (*p_proc_object->intf_fxns->brd_mem_un_map)
-		    (p_proc_object->bridge_context, va_align, size_align);
-	}
-
-	if (status)
-		goto unmap_failed;
-
-	/*
-	 * A successful unmap should be followed by removal of map_obj
-	 * from dmm_map_list, so that mapped memory resource tracking
-	 * remains uptodate
-	 */
-	remove_mapping_information(pr_ctxt, (u32) map_addr, size_align);
-
-unmap_failed:
-	mutex_unlock(&proc_lock);
-
-func_end:
-	dev_dbg(bridge, "%s: hprocessor: 0x%p map_addr: 0x%p status: 0x%x\n",
-		__func__, hprocessor, map_addr, status);
-	return status;
-}
-
-/*
- *  ======== proc_un_reserve_memory ========
- *  Purpose:
- *      Frees a previously reserved region of DSP address space.
- */
-int proc_un_reserve_memory(void *hprocessor, void *prsv_addr,
-				  struct process_context *pr_ctxt)
-{
-	struct dmm_object *dmm_mgr;
-	int status = 0;
-	struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
-	struct dmm_rsv_object *rsv_obj;
-
-	if (!p_proc_object) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	status = dmm_get_handle(p_proc_object, &dmm_mgr);
-	if (!dmm_mgr) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	status = dmm_un_reserve_memory(dmm_mgr, (u32) prsv_addr);
-	if (status != 0)
-		goto func_end;
-
-	/*
-	 * A successful unreserve should be followed by removal of rsv_obj
-	 * from dmm_rsv_list, so that reserved memory resource tracking
-	 * remains uptodate
-	 */
-	spin_lock(&pr_ctxt->dmm_rsv_lock);
-	list_for_each_entry(rsv_obj, &pr_ctxt->dmm_rsv_list, link) {
-		if (rsv_obj->dsp_reserved_addr == (u32) prsv_addr) {
-			list_del(&rsv_obj->link);
-			kfree(rsv_obj);
-			break;
-		}
-	}
-	spin_unlock(&pr_ctxt->dmm_rsv_lock);
-
-func_end:
-	dev_dbg(bridge, "%s: hprocessor: 0x%p prsv_addr: 0x%p status: 0x%x\n",
-		__func__, hprocessor, prsv_addr, status);
-	return status;
-}
-
-/*
- *  ======== = proc_monitor ======== ==
- *  Purpose:
- *      Place the Processor in Monitor State. This is an internal
- *      function and a requirement before Processor is loaded.
- *      This does a bridge_brd_stop, dev_destroy2 and bridge_brd_monitor.
- *      In dev_destroy2 we delete the node manager.
- *  Parameters:
- *      p_proc_object:    Pointer to Processor Object
- *  Returns:
- *      0:	Processor placed in monitor mode.
- *      !0:       Failed to place processor in monitor mode.
- *  Requires:
- *      Valid Processor Handle
- *  Ensures:
- *      Success:	ProcObject state is PROC_IDLE
- */
-static int proc_monitor(struct proc_object *proc_obj)
-{
-	int status = -EPERM;
-	struct msg_mgr *hmsg_mgr;
-
-	/* This is needed only when Device is loaded when it is
-	 * already 'ACTIVE' */
-	/* Destroy the Node Manager, msg_ctrl Manager */
-	if (!dev_destroy2(proc_obj->dev_obj)) {
-		/* Destroy the msg_ctrl by calling msg_delete */
-		dev_get_msg_mgr(proc_obj->dev_obj, &hmsg_mgr);
-		if (hmsg_mgr) {
-			msg_delete(hmsg_mgr);
-			dev_set_msg_mgr(proc_obj->dev_obj, NULL);
-		}
-	}
-	/* Place the Board in the Monitor State */
-	if (!((*proc_obj->intf_fxns->brd_monitor)
-			  (proc_obj->bridge_context))) {
-		status = 0;
-	}
-
-	return status;
-}
-
-/*
- *  ======== get_envp_count ========
- *  Purpose:
- *      Return the number of elements in the envp array, including the
- *      terminating NULL element.
- */
-static s32 get_envp_count(char **envp)
-{
-	s32 ret = 0;
-
-	if (envp) {
-		while (*envp++)
-			ret++;
-
-		ret += 1;	/* Include the terminating NULL in the count. */
-	}
-
-	return ret;
-}
-
-/*
- *  ======== prepend_envp ========
- *  Purpose:
- *      Prepend an environment variable=value pair to the new envp array, and
- *      copy in the existing var=value pairs in the old envp array.
- */
-static char **prepend_envp(char **new_envp, char **envp, s32 envp_elems,
-			   s32 cnew_envp, char *sz_var)
-{
-	char **pp_envp = new_envp;
-
-	/* Prepend new environ var=value string */
-	*new_envp++ = sz_var;
-
-	/* Copy user's environment into our own. */
-	while (envp_elems--)
-		*new_envp++ = *envp++;
-
-	/* Ensure NULL terminates the new environment strings array. */
-	if (envp_elems == 0)
-		*new_envp = NULL;
-
-	return pp_envp;
-}
-
-/*
- *  ======== proc_notify_clients ========
- *  Purpose:
- *      Notify the processor the events.
- */
-int proc_notify_clients(void *proc, u32 events)
-{
-	int status = 0;
-	struct proc_object *p_proc_object = (struct proc_object *)proc;
-
-	if (!p_proc_object) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	ntfy_notify(p_proc_object->ntfy_obj, events);
-func_end:
-	return status;
-}
-
-/*
- *  ======== proc_notify_all_clients ========
- *  Purpose:
- *      Notify the processor the events. This includes notifying all clients
- *      attached to a particulat DSP.
- */
-int proc_notify_all_clients(void *proc, u32 events)
-{
-	int status = 0;
-	struct proc_object *p_proc_object = (struct proc_object *)proc;
-
-	if (!p_proc_object) {
-		status = -EFAULT;
-		goto func_end;
-	}
-
-	dev_notify_clients(p_proc_object->dev_obj, events);
-
-func_end:
-	return status;
-}
-
-/*
- *  ======== proc_get_processor_id ========
- *  Purpose:
- *      Retrieves the processor ID.
- */
-int proc_get_processor_id(void *proc, u32 *proc_id)
-{
-	int status = 0;
-	struct proc_object *p_proc_object = (struct proc_object *)proc;
-
-	if (p_proc_object)
-		*proc_id = p_proc_object->processor_id;
-	else
-		status = -EFAULT;
-
-	return status;
-}
diff --git a/drivers/staging/tidspbridge/rmgr/pwr.c b/drivers/staging/tidspbridge/rmgr/pwr.c
deleted file mode 100644
index 17748df..0000000
--- a/drivers/staging/tidspbridge/rmgr/pwr.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * pwr.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * PWR API for controlling DSP power states.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/pwr.h>
-
-/*  ----------------------------------- Resource Manager */
-#include <dspbridge/devdefs.h>
-#include <dspbridge/drv.h>
-
-/*  ----------------------------------- Platform Manager */
-#include <dspbridge/dev.h>
-
-/*  ----------------------------------- Link Driver */
-#include <dspbridge/dspioctl.h>
-
-/*
- *  ======== pwr_sleep_dsp ========
- *    Send command to DSP to enter sleep state.
- */
-int pwr_sleep_dsp(const u32 sleep_code, const u32 timeout)
-{
-	struct bridge_drv_interface *intf_fxns;
-	struct bridge_dev_context *dw_context;
-	int status = -EPERM;
-	struct dev_object *hdev_obj = NULL;
-	u32 ioctlcode = 0;
-	u32 arg = timeout;
-
-	for (hdev_obj = (struct dev_object *)drv_get_first_dev_object();
-	     hdev_obj != NULL;
-	     hdev_obj =
-	     (struct dev_object *)drv_get_next_dev_object((u32) hdev_obj)) {
-		if (dev_get_bridge_context(hdev_obj,
-						(struct bridge_dev_context **)
-						   &dw_context)) {
-			continue;
-		}
-		if (dev_get_intf_fxns(hdev_obj,
-						(struct bridge_drv_interface **)
-						&intf_fxns)) {
-			continue;
-		}
-		if (sleep_code == PWR_DEEPSLEEP)
-			ioctlcode = BRDIOCTL_DEEPSLEEP;
-		else if (sleep_code == PWR_EMERGENCYDEEPSLEEP)
-			ioctlcode = BRDIOCTL_EMERGENCYSLEEP;
-		else
-			status = -EINVAL;
-
-		if (status != -EINVAL) {
-			status = (*intf_fxns->dev_cntrl) (dw_context,
-							      ioctlcode,
-							      (void *)&arg);
-		}
-	}
-	return status;
-}
-
-/*
- *  ======== pwr_wake_dsp ========
- *    Send command to DSP to wake it from sleep.
- */
-int pwr_wake_dsp(const u32 timeout)
-{
-	struct bridge_drv_interface *intf_fxns;
-	struct bridge_dev_context *dw_context;
-	int status = -EPERM;
-	struct dev_object *hdev_obj = NULL;
-	u32 arg = timeout;
-
-	for (hdev_obj = (struct dev_object *)drv_get_first_dev_object();
-	     hdev_obj != NULL;
-	     hdev_obj = (struct dev_object *)drv_get_next_dev_object
-	     ((u32) hdev_obj)) {
-		if (!(dev_get_bridge_context(hdev_obj,
-						      (struct bridge_dev_context
-						       **)&dw_context))) {
-			if (!(dev_get_intf_fxns(hdev_obj,
-			      (struct bridge_drv_interface **)&intf_fxns))) {
-				status =
-				    (*intf_fxns->dev_cntrl) (dw_context,
-							BRDIOCTL_WAKEUP,
-							(void *)&arg);
-			}
-		}
-	}
-	return status;
-}
-
-/*
- *  ======== pwr_pm_pre_scale========
- *    Sends pre-notification message to DSP.
- */
-int pwr_pm_pre_scale(u16 voltage_domain, u32 level)
-{
-	struct bridge_drv_interface *intf_fxns;
-	struct bridge_dev_context *dw_context;
-	int status = -EPERM;
-	struct dev_object *hdev_obj = NULL;
-	u32 arg[2];
-
-	arg[0] = voltage_domain;
-	arg[1] = level;
-
-	for (hdev_obj = (struct dev_object *)drv_get_first_dev_object();
-	     hdev_obj != NULL;
-	     hdev_obj = (struct dev_object *)drv_get_next_dev_object
-	     ((u32) hdev_obj)) {
-		if (!(dev_get_bridge_context(hdev_obj,
-						      (struct bridge_dev_context
-						       **)&dw_context))) {
-			if (!(dev_get_intf_fxns(hdev_obj,
-			      (struct bridge_drv_interface **)&intf_fxns))) {
-				status =
-				    (*intf_fxns->dev_cntrl) (dw_context,
-						BRDIOCTL_PRESCALE_NOTIFY,
-						(void *)&arg);
-			}
-		}
-	}
-	return status;
-}
-
-/*
- *  ======== pwr_pm_post_scale========
- *    Sends post-notification message to DSP.
- */
-int pwr_pm_post_scale(u16 voltage_domain, u32 level)
-{
-	struct bridge_drv_interface *intf_fxns;
-	struct bridge_dev_context *dw_context;
-	int status = -EPERM;
-	struct dev_object *hdev_obj = NULL;
-	u32 arg[2];
-
-	arg[0] = voltage_domain;
-	arg[1] = level;
-
-	for (hdev_obj = (struct dev_object *)drv_get_first_dev_object();
-	     hdev_obj != NULL;
-	     hdev_obj = (struct dev_object *)drv_get_next_dev_object
-	     ((u32) hdev_obj)) {
-		if (!(dev_get_bridge_context(hdev_obj,
-						      (struct bridge_dev_context
-						       **)&dw_context))) {
-			if (!(dev_get_intf_fxns(hdev_obj,
-			      (struct bridge_drv_interface **)&intf_fxns))) {
-				status =
-				    (*intf_fxns->dev_cntrl) (dw_context,
-						BRDIOCTL_POSTSCALE_NOTIFY,
-						(void *)&arg);
-			}
-		}
-	}
-	return status;
-
-}
diff --git a/drivers/staging/tidspbridge/rmgr/rmm.c b/drivers/staging/tidspbridge/rmgr/rmm.c
deleted file mode 100644
index 52187bd..0000000
--- a/drivers/staging/tidspbridge/rmgr/rmm.c
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
- * rmm.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
- *  This memory manager provides general heap management and arbitrary
- *  alignment for any number of memory segments.
- *
- *  Notes:
- *
- *  Memory blocks are allocated from the end of the first free memory
- *  block large enough to satisfy the request.  Alignment requirements
- *  are satisfied by "sliding" the block forward until its base satisfies
- *  the alignment specification; if this is not possible then the next
- *  free block large enough to hold the request is tried.
- *
- *  Since alignment can cause the creation of a new free block - the
- *  unused memory formed between the start of the original free block
- *  and the start of the allocated block - the memory manager must free
- *  this memory to prevent a memory leak.
- *
- *  Overlay memory is managed by reserving through rmm_alloc, and freeing
- *  it through rmm_free. The memory manager prevents DSP code/data that is
- *  overlayed from being overwritten as long as the memory it runs at has
- *  been allocated, and not yet freed.
- */
-
-#include <linux/types.h>
-#include <linux/list.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/rmm.h>
-
-/*
- *  ======== rmm_header ========
- *  This header is used to maintain a list of free memory blocks.
- */
-struct rmm_header {
-	struct rmm_header *next;	/* form a free memory link list */
-	u32 size;		/* size of the free memory */
-	u32 addr;		/* DSP address of memory block */
-};
-
-/*
- *  ======== rmm_ovly_sect ========
- *  Keeps track of memory occupied by overlay section.
- */
-struct rmm_ovly_sect {
-	struct list_head list_elem;
-	u32 addr;		/* Start of memory section */
-	u32 size;		/* Length (target MAUs) of section */
-	s32 page;		/* Memory page */
-};
-
-/*
- *  ======== rmm_target_obj ========
- */
-struct rmm_target_obj {
-	struct rmm_segment *seg_tab;
-	struct rmm_header **free_list;
-	u32 num_segs;
-	struct list_head ovly_list;	/* List of overlay memory in use */
-};
-
-static bool alloc_block(struct rmm_target_obj *target, u32 segid, u32 size,
-			u32 align, u32 *dsp_address);
-static bool free_block(struct rmm_target_obj *target, u32 segid, u32 addr,
-		       u32 size);
-
-/*
- *  ======== rmm_alloc ========
- */
-int rmm_alloc(struct rmm_target_obj *target, u32 segid, u32 size,
-		     u32 align, u32 *dsp_address, bool reserve)
-{
-	struct rmm_ovly_sect *sect, *prev_sect = NULL;
-	struct rmm_ovly_sect *new_sect;
-	u32 addr;
-	int status = 0;
-
-	if (!reserve) {
-		if (!alloc_block(target, segid, size, align, dsp_address)) {
-			status = -ENOMEM;
-		} else {
-			/* Increment the number of allocated blocks in this
-			 * segment */
-			target->seg_tab[segid].number++;
-		}
-		goto func_end;
-	}
-	/* An overlay section - See if block is already in use. If not,
-	 * insert into the list in ascending address size. */
-	addr = *dsp_address;
-	/*  Find place to insert new list element. List is sorted from
-	 *  smallest to largest address. */
-	list_for_each_entry(sect, &target->ovly_list, list_elem) {
-		if (addr <= sect->addr) {
-			/* Check for overlap with sect */
-			if ((addr + size > sect->addr) || (prev_sect &&
-							   (prev_sect->addr +
-							    prev_sect->size >
-							    addr))) {
-				status = -ENXIO;
-			}
-			break;
-		}
-		prev_sect = sect;
-	}
-	if (!status) {
-		/* No overlap - allocate list element for new section. */
-		new_sect = kzalloc(sizeof(struct rmm_ovly_sect), GFP_KERNEL);
-		if (new_sect == NULL) {
-			status = -ENOMEM;
-		} else {
-			new_sect->addr = addr;
-			new_sect->size = size;
-			new_sect->page = segid;
-			if (list_is_last(&sect->list_elem, &target->ovly_list))
-				/* Put new section at the end of the list */
-				list_add_tail(&new_sect->list_elem,
-						&target->ovly_list);
-			else
-				/* Put new section just before sect */
-				list_add_tail(&new_sect->list_elem,
-						&sect->list_elem);
-		}
-	}
-func_end:
-	return status;
-}
-
-/*
- *  ======== rmm_create ========
- */
-int rmm_create(struct rmm_target_obj **target_obj,
-		      struct rmm_segment seg_tab[], u32 num_segs)
-{
-	struct rmm_header *hptr;
-	struct rmm_segment *sptr, *tmp;
-	struct rmm_target_obj *target;
-	s32 i;
-	int status = 0;
-
-	/* Allocate DBL target object */
-	target = kzalloc(sizeof(struct rmm_target_obj), GFP_KERNEL);
-
-	if (target == NULL)
-		status = -ENOMEM;
-
-	if (status)
-		goto func_cont;
-
-	target->num_segs = num_segs;
-	if (!(num_segs > 0))
-		goto func_cont;
-
-	/* Allocate the memory for freelist from host's memory */
-	target->free_list = kzalloc(num_segs * sizeof(struct rmm_header *),
-							GFP_KERNEL);
-	if (target->free_list == NULL) {
-		status = -ENOMEM;
-	} else {
-		/* Allocate headers for each element on the free list */
-		for (i = 0; i < (s32) num_segs; i++) {
-			target->free_list[i] =
-				kzalloc(sizeof(struct rmm_header), GFP_KERNEL);
-			if (target->free_list[i] == NULL) {
-				status = -ENOMEM;
-				break;
-			}
-		}
-		/* Allocate memory for initial segment table */
-		target->seg_tab = kzalloc(num_segs * sizeof(struct rmm_segment),
-								GFP_KERNEL);
-		if (target->seg_tab == NULL) {
-			status = -ENOMEM;
-		} else {
-			/* Initialize segment table and free list */
-			sptr = target->seg_tab;
-			for (i = 0, tmp = seg_tab; num_segs > 0;
-			     num_segs--, i++) {
-				*sptr = *tmp;
-				hptr = target->free_list[i];
-				hptr->addr = tmp->base;
-				hptr->size = tmp->length;
-				hptr->next = NULL;
-				tmp++;
-				sptr++;
-			}
-		}
-	}
-func_cont:
-	/* Initialize overlay memory list */
-	if (!status)
-		INIT_LIST_HEAD(&target->ovly_list);
-
-	if (!status) {
-		*target_obj = target;
-	} else {
-		*target_obj = NULL;
-		if (target)
-			rmm_delete(target);
-
-	}
-
-	return status;
-}
-
-/*
- *  ======== rmm_delete ========
- */
-void rmm_delete(struct rmm_target_obj *target)
-{
-	struct rmm_ovly_sect *sect, *tmp;
-	struct rmm_header *hptr;
-	struct rmm_header *next;
-	u32 i;
-
-	kfree(target->seg_tab);
-
-	list_for_each_entry_safe(sect, tmp, &target->ovly_list, list_elem) {
-		list_del(&sect->list_elem);
-		kfree(sect);
-	}
-
-	if (target->free_list != NULL) {
-		/* Free elements on freelist */
-		for (i = 0; i < target->num_segs; i++) {
-			hptr = next = target->free_list[i];
-			while (next) {
-				hptr = next;
-				next = hptr->next;
-				kfree(hptr);
-			}
-		}
-		kfree(target->free_list);
-	}
-
-	kfree(target);
-}
-
-/*
- *  ======== rmm_free ========
- */
-bool rmm_free(struct rmm_target_obj *target, u32 segid, u32 dsp_addr, u32 size,
-	      bool reserved)
-{
-	struct rmm_ovly_sect *sect, *tmp;
-	bool ret = false;
-
-	/*
-	 *  Free or unreserve memory.
-	 */
-	if (!reserved) {
-		ret = free_block(target, segid, dsp_addr, size);
-		if (ret)
-			target->seg_tab[segid].number--;
-
-	} else {
-		/* Unreserve memory */
-		list_for_each_entry_safe(sect, tmp, &target->ovly_list,
-				list_elem) {
-			if (dsp_addr == sect->addr) {
-				/* Remove from list */
-				list_del(&sect->list_elem);
-				kfree(sect);
-				return true;
-			}
-		}
-	}
-	return ret;
-}
-
-/*
- *  ======== rmm_stat ========
- */
-bool rmm_stat(struct rmm_target_obj *target, enum dsp_memtype segid,
-	      struct dsp_memstat *mem_stat_buf)
-{
-	struct rmm_header *head;
-	bool ret = false;
-	u32 max_free_size = 0;
-	u32 total_free_size = 0;
-	u32 free_blocks = 0;
-
-	if ((u32) segid < target->num_segs) {
-		head = target->free_list[segid];
-
-		/* Collect data from free_list */
-		while (head != NULL) {
-			max_free_size = max(max_free_size, head->size);
-			total_free_size += head->size;
-			free_blocks++;
-			head = head->next;
-		}
-
-		/* ul_size */
-		mem_stat_buf->size = target->seg_tab[segid].length;
-
-		/* num_free_blocks */
-		mem_stat_buf->num_free_blocks = free_blocks;
-
-		/* total_free_size */
-		mem_stat_buf->total_free_size = total_free_size;
-
-		/* len_max_free_block */
-		mem_stat_buf->len_max_free_block = max_free_size;
-
-		/* num_alloc_blocks */
-		mem_stat_buf->num_alloc_blocks =
-		    target->seg_tab[segid].number;
-
-		ret = true;
-	}
-
-	return ret;
-}
-
-/*
- *  ======== balloc ========
- *  This allocation function allocates memory from the lowest addresses
- *  first.
- */
-static bool alloc_block(struct rmm_target_obj *target, u32 segid, u32 size,
-			u32 align, u32 *dsp_address)
-{
-	struct rmm_header *head;
-	struct rmm_header *prevhead = NULL;
-	struct rmm_header *next;
-	u32 tmpalign;
-	u32 alignbytes;
-	u32 hsize;
-	u32 allocsize;
-	u32 addr;
-
-	alignbytes = (align == 0) ? 1 : align;
-	prevhead = NULL;
-	head = target->free_list[segid];
-
-	do {
-		hsize = head->size;
-		next = head->next;
-
-		addr = head->addr;	/* alloc from the bottom */
-
-		/* align allocation */
-		(tmpalign = (u32) addr % alignbytes);
-		if (tmpalign != 0)
-			tmpalign = alignbytes - tmpalign;
-
-		allocsize = size + tmpalign;
-
-		if (hsize >= allocsize) {	/* big enough */
-			if (hsize == allocsize && prevhead != NULL) {
-				prevhead->next = next;
-				kfree(head);
-			} else {
-				head->size = hsize - allocsize;
-				head->addr += allocsize;
-			}
-
-			/* free up any hole created by alignment */
-			if (tmpalign)
-				free_block(target, segid, addr, tmpalign);
-
-			*dsp_address = addr + tmpalign;
-			return true;
-		}
-
-		prevhead = head;
-		head = next;
-
-	} while (head != NULL);
-
-	return false;
-}
-
-/*
- *  ======== free_block ========
- *  TO DO: free_block() allocates memory, which could result in failure.
- *  Could allocate an rmm_header in rmm_alloc(), to be kept in a pool.
- *  free_block() could use an rmm_header from the pool, freeing as blocks
- *  are coalesced.
- */
-static bool free_block(struct rmm_target_obj *target, u32 segid, u32 addr,
-		       u32 size)
-{
-	struct rmm_header *head;
-	struct rmm_header *thead;
-	struct rmm_header *rhead;
-	bool ret = true;
-
-	/* Create a memory header to hold the newly free'd block. */
-	rhead = kzalloc(sizeof(struct rmm_header), GFP_KERNEL);
-	if (rhead == NULL) {
-		ret = false;
-	} else {
-		/* search down the free list to find the right place for addr */
-		head = target->free_list[segid];
-
-		if (addr >= head->addr) {
-			while (head->next != NULL && addr > head->next->addr)
-				head = head->next;
-
-			thead = head->next;
-
-			head->next = rhead;
-			rhead->next = thead;
-			rhead->addr = addr;
-			rhead->size = size;
-		} else {
-			*rhead = *head;
-			head->next = rhead;
-			head->addr = addr;
-			head->size = size;
-			thead = rhead->next;
-		}
-
-		/* join with upper block, if possible */
-		if (thead != NULL && (rhead->addr + rhead->size) ==
-		    thead->addr) {
-			head->next = rhead->next;
-			thead->size = size + thead->size;
-			thead->addr = addr;
-			kfree(rhead);
-			rhead = thead;
-		}
-
-		/* join with the lower block, if possible */
-		if ((head->addr + head->size) == rhead->addr) {
-			head->next = rhead->next;
-			head->size = head->size + rhead->size;
-			kfree(rhead);
-		}
-	}
-
-	return ret;
-}
diff --git a/drivers/staging/tidspbridge/rmgr/strm.c b/drivers/staging/tidspbridge/rmgr/strm.c
deleted file mode 100644
index b88b27b..0000000
--- a/drivers/staging/tidspbridge/rmgr/strm.c
+++ /dev/null
@@ -1,733 +0,0 @@
-/*
- * strm.c
- *
- * DSP-BIOS Bridge driver support functions for TI OMAP processors.
- *
- * DSP/BIOS Bridge Stream Manager.
- *
- * Copyright (C) 2005-2006 Texas Instruments, Inc.
- *
- * This package 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.
- *
- * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <linux/types.h>
-
-/*  ----------------------------------- Host OS */
-#include <dspbridge/host_os.h>
-
-/*  ----------------------------------- DSP/BIOS Bridge */
-#include <dspbridge/dbdefs.h>
-
-/*  ----------------------------------- OS Adaptation Layer */
-#include <dspbridge/sync.h>
-
-/*  ----------------------------------- Bridge Driver */
-#include <dspbridge/dspdefs.h>
-
-/*  ----------------------------------- Resource Manager */
-#include <dspbridge/nodepriv.h>
-
-/*  ----------------------------------- Others */
-#include <dspbridge/cmm.h>
-
-/*  ----------------------------------- This */
-#include <dspbridge/strm.h>
-
-#include <dspbridge/resourcecleanup.h>
-
-/*  ----------------------------------- Defines, Data Structures, Typedefs */
-#define DEFAULTTIMEOUT      10000
-#define DEFAULTNUMBUFS      2
-
-/*
- *  ======== strm_mgr ========
- *  The strm_mgr contains device information needed to open the underlying
- *  channels of a stream.
- */
-struct strm_mgr {
-	struct dev_object *dev_obj;	/* Device for this processor */
-	struct chnl_mgr *chnl_mgr;	/* Channel manager */
-	/* Function interface to Bridge driver */
-	struct bridge_drv_interface *intf_fxns;
-};
-
-/*
- *  ======== strm_object ========
- *  This object is allocated in strm_open().
- */
-struct strm_object {
-	struct strm_mgr *strm_mgr_obj;
-	struct chnl_object *chnl_obj;
-	u32 dir;		/* DSP_TONODE or DSP_FROMNODE */
-	u32 timeout;
-	u32 num_bufs;		/* Max # of bufs allowed in stream */
-	u32 bufs_in_strm;	/* Current # of bufs in stream */
-	u32 bytes;		/* bytes transferred since idled */
-	/* STREAM_IDLE, STREAM_READY, ... */
-	enum dsp_streamstate strm_state;
-	void *user_event;	/* Saved for strm_get_info() */
-	enum dsp_strmmode strm_mode;	/* STRMMODE_[PROCCOPY][ZEROCOPY]... */
-	u32 dma_chnl_id;	/* DMA chnl id */
-	u32 dma_priority;	/* DMA priority:DMAPRI_[LOW][HIGH] */
-	u32 segment_id;		/* >0 is SM segment.=0 is local heap */
-	u32 buf_alignment;	/* Alignment for stream bufs */
-	/* Stream's SM address translator */
-	struct cmm_xlatorobject *xlator;
-};
-
-/*  ----------------------------------- Function Prototypes */
-static int delete_strm(struct strm_object *stream_obj);
-
-/*
- *  ======== strm_allocate_buffer ========
- *  Purpose:
- *      Allocates buffers for a stream.
- */
-int strm_allocate_buffer(struct strm_res_object *strmres, u32 usize,
-				u8 **ap_buffer, u32 num_bufs,
-				struct process_context *pr_ctxt)
-{
-	int status = 0;
-	u32 alloc_cnt = 0;
-	u32 i;
-	struct strm_object *stream_obj = strmres->stream;
-
-	if (stream_obj) {
-		/*
-		 * Allocate from segment specified at time of stream open.
-		 */
-		if (usize == 0)
-			status = -EINVAL;
-
-	} else {
-		status = -EFAULT;
-	}
-
-	if (status)
-		goto func_end;
-
-	for (i = 0; i < num_bufs; i++) {
-		(void)cmm_xlator_alloc_buf(stream_obj->xlator, &ap_buffer[i],
-					   usize);
-		if (ap_buffer[i] == NULL) {
-			status = -ENOMEM;
-			alloc_cnt = i;
-			break;
-		}
-	}
-	if (status)
-		strm_free_buffer(strmres, ap_buffer, alloc_cnt, pr_ctxt);
-
-	if (status)
-		goto func_end;
-
-	drv_proc_update_strm_res(num_bufs, strmres);
-
-func_end:
-	return status;
-}
-
-/*
- *  ======== strm_close ========
- *  Purpose:
- *      Close a stream opened with strm_open().
- */
-int strm_close(struct strm_res_object *strmres,
-		      struct process_context *pr_ctxt)
-{
-	struct bridge_drv_interface *intf_fxns;
-	struct chnl_info chnl_info_obj;
-	int status = 0;
-	struct strm_object *stream_obj = strmres->stream;
-
-	if (!stream_obj) {
-		status = -EFAULT;
-	} else {
-		/* Have all buffers been reclaimed? If not, return
-		 * -EPIPE */
-		intf_fxns = stream_obj->strm_mgr_obj->intf_fxns;
-		status =
-		    (*intf_fxns->chnl_get_info) (stream_obj->chnl_obj,
-						     &chnl_info_obj);
-
-		if (chnl_info_obj.cio_cs > 0 || chnl_info_obj.cio_reqs > 0)
-			status = -EPIPE;
-		else
-			status = delete_strm(stream_obj);
-	}
-
-	if (status)
-		goto func_end;
-
-	idr_remove(pr_ctxt->stream_id, strmres->id);
-func_end:
-	dev_dbg(bridge, "%s: stream_obj: %p, status 0x%x\n", __func__,
-		stream_obj, status);
-	return status;
-}
-
-/*
- *  ======== strm_create ========
- *  Purpose:
- *      Create a STRM manager object.
- */
-int strm_create(struct strm_mgr **strm_man,
-		       struct dev_object *dev_obj)
-{
-	struct strm_mgr *strm_mgr_obj;
-	int status = 0;
-
-	*strm_man = NULL;
-	/* Allocate STRM manager object */
-	strm_mgr_obj = kzalloc(sizeof(struct strm_mgr), GFP_KERNEL);
-	if (strm_mgr_obj == NULL)
-		status = -ENOMEM;
-	else
-		strm_mgr_obj->dev_obj = dev_obj;
-
-	/* Get Channel manager and Bridge function interface */
-	if (!status) {
-		status = dev_get_chnl_mgr(dev_obj, &(strm_mgr_obj->chnl_mgr));
-		if (!status) {
-			(void)dev_get_intf_fxns(dev_obj,
-						&(strm_mgr_obj->intf_fxns));
-		}
-	}
-
-	if (!status)
-		*strm_man = strm_mgr_obj;
-	else
-		kfree(strm_mgr_obj);
-
-	return status;
-}
-
-/*
- *  ======== strm_delete ========
- *  Purpose:
- *      Delete the STRM Manager Object.
- */
-void strm_delete(struct strm_mgr *strm_mgr_obj)
-{
-	kfree(strm_mgr_obj);
-}
-
-/*
- *  ======== strm_free_buffer ========
- *  Purpose:
- *      Frees the buffers allocated for a stream.
- */
-int strm_free_buffer(struct strm_res_object *strmres, u8 **ap_buffer,
-			    u32 num_bufs, struct process_context *pr_ctxt)
-{
-	int status = 0;
-	u32 i = 0;
-	struct strm_object *stream_obj = strmres->stream;
-
-	if (!stream_obj)
-		status = -EFAULT;
-
-	if (!status) {
-		for (i = 0; i < num_bufs; i++) {
-			status =
-			    cmm_xlator_free_buf(stream_obj->xlator,
-						ap_buffer[i]);
-			if (status)
-				break;
-			ap_buffer[i] = NULL;
-		}
-	}
-	drv_proc_update_strm_res(num_bufs - i, strmres);
-
-	return status;
-}
-
-/*
- *  ======== strm_get_info ========
- *  Purpose:
- *      Retrieves information about a stream.
- */
-int strm_get_info(struct strm_object *stream_obj,
-			 struct stream_info *stream_info,
-			 u32 stream_info_size)
-{
-	struct bridge_drv_interface *intf_fxns;
-	struct chnl_info chnl_info_obj;
-	int status = 0;
-	void *virt_base = NULL;	/* NULL if no SM used */
-
-	if (!stream_obj) {
-		status = -EFAULT;
-	} else {
-		if (stream_info_size < sizeof(struct stream_info)) {
-			/* size of users info */
-			status = -EINVAL;
-		}
-	}
-	if (status)
-		goto func_end;
-
-	intf_fxns = stream_obj->strm_mgr_obj->intf_fxns;
-	status =
-	    (*intf_fxns->chnl_get_info) (stream_obj->chnl_obj,
-						  &chnl_info_obj);
-	if (status)
-		goto func_end;
-
-	if (stream_obj->xlator) {
-		/* We have a translator */
-		cmm_xlator_info(stream_obj->xlator, (u8 **) &virt_base, 0,
-				stream_obj->segment_id, false);
-	}
-	stream_info->segment_id = stream_obj->segment_id;
-	stream_info->strm_mode = stream_obj->strm_mode;
-	stream_info->virt_base = virt_base;
-	stream_info->user_strm->number_bufs_allowed = stream_obj->num_bufs;
-	stream_info->user_strm->number_bufs_in_stream = chnl_info_obj.cio_cs +
-	    chnl_info_obj.cio_reqs;
-	/* # of bytes transferred since last call to DSPStream_Idle() */
-	stream_info->user_strm->number_bytes = chnl_info_obj.bytes_tx;
-	stream_info->user_strm->sync_object_handle = chnl_info_obj.event_obj;
-	/* Determine stream state based on channel state and info */
-	if (chnl_info_obj.state & CHNL_STATEEOS) {
-		stream_info->user_strm->ss_stream_state = STREAM_DONE;
-	} else {
-		if (chnl_info_obj.cio_cs > 0)
-			stream_info->user_strm->ss_stream_state = STREAM_READY;
-		else if (chnl_info_obj.cio_reqs > 0)
-			stream_info->user_strm->ss_stream_state =
-			    STREAM_PENDING;
-		else
-			stream_info->user_strm->ss_stream_state = STREAM_IDLE;
-
-	}
-func_end:
-	return status;
-}
-
-/*
- *  ======== strm_idle ========
- *  Purpose:
- *      Idles a particular stream.
- */
-int strm_idle(struct strm_object *stream_obj, bool flush_data)
-{
-	struct bridge_drv_interface *intf_fxns;
-	int status = 0;
-
-	if (!stream_obj) {
-		status = -EFAULT;
-	} else {
-		intf_fxns = stream_obj->strm_mgr_obj->intf_fxns;
-
-		status = (*intf_fxns->chnl_idle) (stream_obj->chnl_obj,
-						      stream_obj->timeout,
-						      flush_data);
-	}
-
-	dev_dbg(bridge, "%s: stream_obj: %p flush_data: 0x%x status: 0x%x\n",
-		__func__, stream_obj, flush_data, status);
-	return status;
-}
-
-/*
- *  ======== strm_issue ========
- *  Purpose:
- *      Issues a buffer on a stream
- */
-int strm_issue(struct strm_object *stream_obj, u8 *pbuf, u32 ul_bytes,
-		      u32 ul_buf_size, u32 dw_arg)
-{
-	struct bridge_drv_interface *intf_fxns;
-	int status = 0;
-	void *tmp_buf = NULL;
-
-	if (!stream_obj) {
-		status = -EFAULT;
-	} else {
-		intf_fxns = stream_obj->strm_mgr_obj->intf_fxns;
-
-		if (stream_obj->segment_id != 0) {
-			tmp_buf = cmm_xlator_translate(stream_obj->xlator,
-						       (void *)pbuf,
-						       CMM_VA2DSPPA);
-			if (tmp_buf == NULL)
-				status = -ESRCH;
-
-		}
-		if (!status) {
-			status = (*intf_fxns->chnl_add_io_req)
-			    (stream_obj->chnl_obj, pbuf, ul_bytes, ul_buf_size,
-			     (u32) tmp_buf, dw_arg);
-		}
-		if (status == -EIO)
-			status = -ENOSR;
-	}
-
-	dev_dbg(bridge, "%s: stream_obj: %p pbuf: %p ul_bytes: 0x%x dw_arg:"
-		" 0x%x status: 0x%x\n", __func__, stream_obj, pbuf,
-		ul_bytes, dw_arg, status);
-	return status;
-}
-
-/*
- *  ======== strm_open ========
- *  Purpose:
- *      Open a stream for sending/receiving data buffers to/from a task or
- *      XDAIS socket node on the DSP.
- */
-int strm_open(struct node_object *hnode, u32 dir, u32 index,
-		     struct strm_attr *pattr,
-		     struct strm_res_object **strmres,
-		     struct process_context *pr_ctxt)
-{
-	struct strm_mgr *strm_mgr_obj;
-	struct bridge_drv_interface *intf_fxns;
-	u32 ul_chnl_id;
-	struct strm_object *strm_obj = NULL;
-	s8 chnl_mode;
-	struct chnl_attr chnl_attr_obj;
-	int status = 0;
-	struct cmm_object *hcmm_mgr = NULL;	/* Shared memory manager hndl */
-
-	void *stream_res;
-
-	*strmres = NULL;
-	if (dir != DSP_TONODE && dir != DSP_FROMNODE) {
-		status = -EPERM;
-	} else {
-		/* Get the channel id from the node (set in node_connect()) */
-		status = node_get_channel_id(hnode, dir, index, &ul_chnl_id);
-	}
-	if (!status)
-		status = node_get_strm_mgr(hnode, &strm_mgr_obj);
-
-	if (!status) {
-		strm_obj = kzalloc(sizeof(struct strm_object), GFP_KERNEL);
-		if (strm_obj == NULL) {
-			status = -ENOMEM;
-		} else {
-			strm_obj->strm_mgr_obj = strm_mgr_obj;
-			strm_obj->dir = dir;
-			strm_obj->strm_state = STREAM_IDLE;
-			strm_obj->user_event = pattr->user_event;
-			if (pattr->stream_attr_in != NULL) {
-				strm_obj->timeout =
-				    pattr->stream_attr_in->timeout;
-				strm_obj->num_bufs =
-				    pattr->stream_attr_in->num_bufs;
-				strm_obj->strm_mode =
-				    pattr->stream_attr_in->strm_mode;
-				strm_obj->segment_id =
-				    pattr->stream_attr_in->segment_id;
-				strm_obj->buf_alignment =
-				    pattr->stream_attr_in->buf_alignment;
-				strm_obj->dma_chnl_id =
-				    pattr->stream_attr_in->dma_chnl_id;
-				strm_obj->dma_priority =
-				    pattr->stream_attr_in->dma_priority;
-				chnl_attr_obj.uio_reqs =
-				    pattr->stream_attr_in->num_bufs;
-			} else {
-				strm_obj->timeout = DEFAULTTIMEOUT;
-				strm_obj->num_bufs = DEFAULTNUMBUFS;
-				strm_obj->strm_mode = STRMMODE_PROCCOPY;
-				strm_obj->segment_id = 0;	/* local mem */
-				strm_obj->buf_alignment = 0;
-				strm_obj->dma_chnl_id = 0;
-				strm_obj->dma_priority = 0;
-				chnl_attr_obj.uio_reqs = DEFAULTNUMBUFS;
-			}
-			chnl_attr_obj.reserved1 = NULL;
-			/* DMA chnl flush timeout */
-			chnl_attr_obj.reserved2 = strm_obj->timeout;
-			chnl_attr_obj.event_obj = NULL;
-			if (pattr->user_event != NULL)
-				chnl_attr_obj.event_obj = pattr->user_event;
-
-		}
-	}
-	if (status)
-		goto func_cont;
-
-	if ((pattr->virt_base == NULL) || !(pattr->virt_size > 0))
-		goto func_cont;
-
-	/* No System DMA */
-	/* Get the shared mem mgr for this streams dev object */
-	status = dev_get_cmm_mgr(strm_mgr_obj->dev_obj, &hcmm_mgr);
-	if (!status) {
-		/*Allocate a SM addr translator for this strm. */
-		status = cmm_xlator_create(&strm_obj->xlator, hcmm_mgr, NULL);
-		if (!status) {
-			/*  Set translators Virt Addr attributes */
-			status = cmm_xlator_info(strm_obj->xlator,
-						 (u8 **) &pattr->virt_base,
-						 pattr->virt_size,
-						 strm_obj->segment_id, true);
-		}
-	}
-func_cont:
-	if (!status) {
-		/* Open channel */
-		chnl_mode = (dir == DSP_TONODE) ?
-		    CHNL_MODETODSP : CHNL_MODEFROMDSP;
-		intf_fxns = strm_mgr_obj->intf_fxns;
-		status = (*intf_fxns->chnl_open) (&(strm_obj->chnl_obj),
-						      strm_mgr_obj->chnl_mgr,
-						      chnl_mode, ul_chnl_id,
-						      &chnl_attr_obj);
-		if (status) {
-			/*
-			 * over-ride non-returnable status codes so we return
-			 * something documented
-			 */
-			if (status != -ENOMEM && status !=
-			    -EINVAL && status != -EPERM) {
-				/*
-				 * We got a status that's not return-able.
-				 * Assert that we got something we were
-				 * expecting (-EFAULT isn't acceptable,
-				 * strm_mgr_obj->chnl_mgr better be valid or we
-				 * assert here), and then return -EPERM.
-				 */
-				status = -EPERM;
-			}
-		}
-	}
-	if (!status) {
-		status = drv_proc_insert_strm_res_element(strm_obj,
-							&stream_res, pr_ctxt);
-		if (status)
-			delete_strm(strm_obj);
-		else
-			*strmres = (struct strm_res_object *)stream_res;
-	} else {
-		(void)delete_strm(strm_obj);
-	}
-
-	dev_dbg(bridge, "%s: hnode: %p dir: 0x%x index: 0x%x pattr: %p "
-		"strmres: %p status: 0x%x\n", __func__,
-		hnode, dir, index, pattr, strmres, status);
-	return status;
-}
-
-/*
- *  ======== strm_reclaim ========
- *  Purpose:
- *      Relcaims a buffer from a stream.
- */
-int strm_reclaim(struct strm_object *stream_obj, u8 **buf_ptr,
-			u32 *nbytes, u32 *buff_size, u32 *pdw_arg)
-{
-	struct bridge_drv_interface *intf_fxns;
-	struct chnl_ioc chnl_ioc_obj;
-	int status = 0;
-	void *tmp_buf = NULL;
-
-	if (!stream_obj) {
-		status = -EFAULT;
-		goto func_end;
-	}
-	intf_fxns = stream_obj->strm_mgr_obj->intf_fxns;
-
-	status =
-	    (*intf_fxns->chnl_get_ioc) (stream_obj->chnl_obj,
-					    stream_obj->timeout,
-					    &chnl_ioc_obj);
-	if (!status) {
-		*nbytes = chnl_ioc_obj.byte_size;
-		if (buff_size)
-			*buff_size = chnl_ioc_obj.buf_size;
-
-		*pdw_arg = chnl_ioc_obj.arg;
-		if (!CHNL_IS_IO_COMPLETE(chnl_ioc_obj)) {
-			if (CHNL_IS_TIMED_OUT(chnl_ioc_obj)) {
-				status = -ETIME;
-			} else {
-				/* Allow reclaims after idle to succeed */
-				if (!CHNL_IS_IO_CANCELLED(chnl_ioc_obj))
-					status = -EPERM;
-
-			}
-		}
-		/* Translate zerocopy buffer if channel not canceled. */
-		if (!status
-		    && (!CHNL_IS_IO_CANCELLED(chnl_ioc_obj))
-		    && (stream_obj->strm_mode == STRMMODE_ZEROCOPY)) {
-			/*
-			 *  This is a zero-copy channel so chnl_ioc_obj.buf
-			 *  contains the DSP address of SM. We need to
-			 *  translate it to a virtual address for the user
-			 *  thread to access.
-			 *  Note: Could add CMM_DSPPA2VA to CMM in the future.
-			 */
-			tmp_buf = cmm_xlator_translate(stream_obj->xlator,
-						       chnl_ioc_obj.buf,
-						       CMM_DSPPA2PA);
-			if (tmp_buf != NULL) {
-				/* now convert this GPP Pa to Va */
-				tmp_buf = cmm_xlator_translate(stream_obj->
-							       xlator,
-							       tmp_buf,
-							       CMM_PA2VA);
-			}
-			if (tmp_buf == NULL)
-				status = -ESRCH;
-
-			chnl_ioc_obj.buf = tmp_buf;
-		}
-		*buf_ptr = chnl_ioc_obj.buf;
-	}
-func_end:
-	dev_dbg(bridge, "%s: stream_obj: %p buf_ptr: %p nbytes: %p "
-		"pdw_arg: %p status 0x%x\n", __func__, stream_obj,
-		buf_ptr, nbytes, pdw_arg, status);
-	return status;
-}
-
-/*
- *  ======== strm_register_notify ========
- *  Purpose:
- *      Register to be notified on specific events for this stream.
- */
-int strm_register_notify(struct strm_object *stream_obj, u32 event_mask,
-				u32 notify_type, struct dsp_notification
-				*hnotification)
-{
-	struct bridge_drv_interface *intf_fxns;
-	int status = 0;
-
-	if (!stream_obj) {
-		status = -EFAULT;
-	} else if ((event_mask & ~((DSP_STREAMIOCOMPLETION) |
-				   DSP_STREAMDONE)) != 0) {
-		status = -EINVAL;
-	} else {
-		if (notify_type != DSP_SIGNALEVENT)
-			status = -ENOSYS;
-
-	}
-	if (!status) {
-		intf_fxns = stream_obj->strm_mgr_obj->intf_fxns;
-
-		status =
-		    (*intf_fxns->chnl_register_notify) (stream_obj->
-							    chnl_obj,
-							    event_mask,
-							    notify_type,
-							    hnotification);
-	}
-
-	return status;
-}
-
-/*
- *  ======== strm_select ========
- *  Purpose:
- *      Selects a ready stream.
- */
-int strm_select(struct strm_object **strm_tab, u32 strms,
-		       u32 *pmask, u32 utimeout)
-{
-	u32 index;
-	struct chnl_info chnl_info_obj;
-	struct bridge_drv_interface *intf_fxns;
-	struct sync_object **sync_events = NULL;
-	u32 i;
-	int status = 0;
-
-	*pmask = 0;
-	for (i = 0; i < strms; i++) {
-		if (!strm_tab[i]) {
-			status = -EFAULT;
-			break;
-		}
-	}
-	if (status)
-		goto func_end;
-
-	/* Determine which channels have IO ready */
-	for (i = 0; i < strms; i++) {
-		intf_fxns = strm_tab[i]->strm_mgr_obj->intf_fxns;
-		status = (*intf_fxns->chnl_get_info) (strm_tab[i]->chnl_obj,
-							  &chnl_info_obj);
-		if (status) {
-			break;
-		} else {
-			if (chnl_info_obj.cio_cs > 0)
-				*pmask |= (1 << i);
-
-		}
-	}
-	if (!status && utimeout > 0 && *pmask == 0) {
-		/* Non-zero timeout */
-		sync_events = kmalloc(strms * sizeof(struct sync_object *),
-								GFP_KERNEL);
-
-		if (sync_events == NULL) {
-			status = -ENOMEM;
-		} else {
-			for (i = 0; i < strms; i++) {
-				intf_fxns =
-				    strm_tab[i]->strm_mgr_obj->intf_fxns;
-				status = (*intf_fxns->chnl_get_info)
-				    (strm_tab[i]->chnl_obj, &chnl_info_obj);
-				if (status)
-					break;
-				else
-					sync_events[i] =
-					    chnl_info_obj.sync_event;
-
-			}
-		}
-		if (!status) {
-			status =
-			    sync_wait_on_multiple_events(sync_events, strms,
-							 utimeout, &index);
-			if (!status) {
-				/* Since we waited on the event, we have to
-				 * reset it */
-				sync_set_event(sync_events[index]);
-				*pmask = 1 << index;
-			}
-		}
-	}
-func_end:
-	kfree(sync_events);
-
-	return status;
-}
-
-/*
- *  ======== delete_strm ========
- *  Purpose:
- *      Frees the resources allocated for a stream.
- */
-static int delete_strm(struct strm_object *stream_obj)
-{
-	struct bridge_drv_interface *intf_fxns;
-	int status = 0;
-
-	if (stream_obj) {
-		if (stream_obj->chnl_obj) {
-			intf_fxns = stream_obj->strm_mgr_obj->intf_fxns;
-			/* Channel close can fail only if the channel handle
-			 * is invalid. */
-			status = (*intf_fxns->chnl_close)
-					(stream_obj->chnl_obj);
-		}
-		/* Free all SM address translator resources */
-		kfree(stream_obj->xlator);
-		kfree(stream_obj);
-	} else {
-		status = -EFAULT;
-	}
-	return status;
-}
diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c
index 4d1347a..ef7242ee 100644
--- a/drivers/staging/unisys/virthba/virthba.c
+++ b/drivers/staging/unisys/virthba/virthba.c
@@ -50,7 +50,7 @@
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
 #include <asm/param.h>
-#include <linux/proc_fs.h>
+#include <linux/debugfs.h>
 #include <linux/types.h>
 
 #include "virthba.h"
@@ -67,6 +67,11 @@
 /* NOTE:  L1_CACHE_BYTES >=128 */
 #define DEVICE_ATTRIBUTE struct device_attribute
 
+ /* MAX_BUF = 6 lines x 10 MAXVHBA x 80 characters
+ *         = 4800 bytes ~ 2^13 = 8192 bytes
+ */
+#define MAX_BUF 8192
+
 /*****************************************************/
 /* Forward declarations                              */
 /*****************************************************/
@@ -105,15 +110,10 @@
 static int virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state);
 static void doDiskAddRemove(struct work_struct *work);
 static void virthba_serverdown_complete(struct work_struct *work);
-
-static ssize_t info_proc_read(struct file *file, char __user *buf,
-			      size_t len, loff_t *offset);
-static ssize_t rqwu_proc_write(struct file *file, const char __user *buffer,
-			       size_t count, loff_t *ppos);
-static ssize_t enable_ints_read(struct file *file, char __user *buffer,
-				size_t count, loff_t *ppos);
-static ssize_t enable_ints_write(struct file *file, const char __user *buffer,
-				 size_t count, loff_t *ppos);
+static ssize_t info_debugfs_read(struct file *file, char __user *buf,
+			size_t len, loff_t *offset);
+static ssize_t enable_ints_write(struct file *file,
+			const char __user *buffer, size_t count, loff_t *ppos);
 
 /*****************************************************/
 /* Globals                                           */
@@ -208,7 +208,6 @@
 static DEVICE_ATTRIBUTE *virthba_shost_attrs[];
 static struct scsi_host_template virthba_driver_template = {
 	.name = "Unisys Virtual HBA",
-	.proc_name = "uisvirthba",
 	.info = virthba_get_info,
 	.ioctl = virthba_ioctl,
 	.queuecommand = virthba_queue_command,
@@ -232,31 +231,22 @@
 	struct virthba_info *virthbainfo;
 };
 
-static const struct file_operations proc_info_fops = {
-	.read = info_proc_read,
+static const struct file_operations debugfs_info_fops = {
+	.read = info_debugfs_read,
 };
 
-static const struct file_operations proc_rqwu_fops = {
-	.write = rqwu_proc_write,
-};
-
-static const struct file_operations proc_enable_ints_fops = {
-	.read = enable_ints_read,
+static const struct file_operations debugfs_enable_ints_fops = {
 	.write = enable_ints_write,
 };
 
+/*****************************************************/
+/* Structs                                           */
+/*****************************************************/
 
 #define VIRTHBASOPENMAX 1
 /* array of open devices maintained by open() and close(); */
 static struct virthba_devices_open VirtHbasOpen[VIRTHBASOPENMAX];
-static struct proc_dir_entry *virthba_proc_dir;
-static struct proc_dir_entry *info_proc_entry;
-static struct proc_dir_entry *rqwaitus_proc_entry;
-static struct proc_dir_entry *enable_ints_proc_entry;
-#define INFO_PROC_ENTRY_FN "info"
-#define ENABLE_INTS_ENTRY_FN "enable_ints"
-#define RQWU_PROC_ENTRY_FN "rqwait_usecs"
-#define DIR_PROC_ENTRY "virthba"
+static struct dentry *virthba_debugfs_dir;
 
 /*****************************************************/
 /* Local Functions				     */
@@ -1376,25 +1366,21 @@
 }
 
 /*****************************************************/
-/* proc filesystem functions						 */
+/* Debugfs filesystem functions                      */
 /*****************************************************/
 
-static ssize_t
-info_proc_read(struct file *file, char __user *buf, size_t len, loff_t *offset)
+static ssize_t info_debugfs_read(struct file *file,
+			char __user *buf, size_t len, loff_t *offset)
 {
-	int length = 0;
+	ssize_t bytes_read = 0;
+	int str_pos = 0;
 	U64 phys_flags_addr;
 	int i;
 	struct virthba_info *virthbainfo;
 	char *vbuf;
-	loff_t pos = *offset;
 
-	if (pos < 0)
-		return -EINVAL;
-
-	if (pos > 0 || !len)
-		return 0;
-
+	if (len > MAX_BUF)
+		len = MAX_BUF;
 	vbuf = kzalloc(len, GFP_KERNEL);
 	if (!vbuf)
 		return -ENOMEM;
@@ -1404,51 +1390,44 @@
 			continue;
 
 		virthbainfo = VirtHbasOpen[i].virthbainfo;
-		length += sprintf(vbuf + length, "CHANSOCK is not defined.\n");
 
-		length += sprintf(vbuf + length, "MaxBuffLen:%u\n", MaxBuffLen);
+		str_pos += scnprintf(vbuf + str_pos,
+				len - str_pos, "MaxBuffLen:%u\n", MaxBuffLen);
 
-		length += sprintf(vbuf + length, "\nvirthba result queue poll wait:%d usecs.\n",
-				  rsltq_wait_usecs);
-
-		length += sprintf(vbuf + length, "\ninterrupts_rcvd = %llu, interrupts_disabled = %llu\n",
-				  virthbainfo->interrupts_rcvd,
-				  virthbainfo->interrupts_disabled);
-		length += sprintf(vbuf + length, "\ninterrupts_notme = %llu,\n",
-				  virthbainfo->interrupts_notme);
+		str_pos += scnprintf(vbuf + str_pos, len - str_pos,
+				"\nvirthba result queue poll wait:%d usecs.\n",
+				rsltq_wait_usecs);
+		str_pos += scnprintf(vbuf + str_pos, len - str_pos,
+				"\ninterrupts_rcvd = %llu, interrupts_disabled = %llu\n",
+				virthbainfo->interrupts_rcvd,
+				virthbainfo->interrupts_disabled);
+		str_pos += scnprintf(vbuf + str_pos,
+				len - str_pos, "\ninterrupts_notme = %llu,\n",
+				virthbainfo->interrupts_notme);
 		phys_flags_addr = virt_to_phys((__force  void *)
 					       virthbainfo->flags_addr);
-		length += sprintf(vbuf + length, "flags_addr = %p, phys_flags_addr=0x%016llx, FeatureFlags=%llu\n",
-			  virthbainfo->flags_addr, phys_flags_addr,
-				  (__le64)readq(virthbainfo->flags_addr));
-		length += sprintf(vbuf + length, "acquire_failed_cnt:%llu\n",
-				  virthbainfo->acquire_failed_cnt);
-		length += sprintf(vbuf + length, "\n");
-	}
-	if (copy_to_user(buf, vbuf, length)) {
-		kfree(vbuf);
-		return -EFAULT;
+		str_pos += scnprintf(vbuf + str_pos, len - str_pos,
+				"flags_addr = %p, phys_flags_addr=0x%016llx, FeatureFlags=%llu\n",
+				virthbainfo->flags_addr, phys_flags_addr,
+				(__le64)readq(virthbainfo->flags_addr));
+		str_pos += scnprintf(vbuf + str_pos,
+			len - str_pos, "acquire_failed_cnt:%llu\n",
+			virthbainfo->acquire_failed_cnt);
+		str_pos += scnprintf(vbuf + str_pos, len - str_pos, "\n");
 	}
 
+	bytes_read = simple_read_from_buffer(buf, len, offset, vbuf, str_pos);
 	kfree(vbuf);
-	*offset += length;
-	return length;
+	return bytes_read;
 }
 
-static ssize_t
-enable_ints_read(struct file *file, char __user *buffer,
-		  size_t count, loff_t *ppos)
-{
-	return 0;
-}
-
-static ssize_t
-enable_ints_write(struct file *file, const char __user *buffer,
-		  size_t count, loff_t *ppos)
+static ssize_t enable_ints_write(struct file *file,
+			const char __user *buffer, size_t count, loff_t *ppos)
 {
 	char buf[4];
 	int i, new_value;
 	struct virthba_info *virthbainfo;
+
 	U64 __iomem *Features_addr;
 	U64 mask;
 
@@ -1462,9 +1441,9 @@
 		return -EFAULT;
 	}
 
-	i = sscanf(buf, "%d", &new_value);
+	i = kstrtoint(buf, 10 , &new_value);
 
-	if (i < 1) {
+	if (i != 0) {
 		LOGERR("Failed to scan value for enable_ints, buf<<%.*s>>",
 		       (int) count, buf);
 		return -EFAULT;
@@ -1496,35 +1475,6 @@
 	return count;
 }
 
-static ssize_t
-rqwu_proc_write(struct file *file, const char __user *buffer,
-		size_t count, loff_t *ppos)
-{
-	char buf[16];
-	int i, usecs;
-
-	if (count >= ARRAY_SIZE(buf))
-		return -EINVAL;
-
-	if (copy_from_user(buf, buffer, count)) {
-		LOGERR("copy_from_user failed. buf<<%.*s>> count<<%lu>>\n",
-		       (int) count, buf, count);
-		return -EFAULT;
-	}
-
-	i = sscanf(buf, "%d", &usecs);
-
-	if (i < 1) {
-		LOGERR("Failed to scan value for rqwait_usecs buf<<%.*s>>",
-		       (int) count, buf);
-		return -EFAULT;
-	}
-
-	/* set global wait time */
-	rsltq_wait_usecs = usecs;
-	return count;
-}
-
 /* As per VirtpciFunc returns 1 for success and 0 for failure */
 static int
 virthba_serverup(struct virtpci_dev *virtpcidev)
@@ -1708,18 +1658,16 @@
 		POSTCODE_LINUX_3(VHBA_CREATE_FAILURE_PC, error,
 				 POSTCODE_SEVERITY_ERR);
 	} else {
-		/* create the proc directories */
-		virthba_proc_dir = proc_mkdir(DIR_PROC_ENTRY, NULL);
-		info_proc_entry = proc_create(INFO_PROC_ENTRY_FN, 0,
-					      virthba_proc_dir,
-					      &proc_info_fops);
-		rqwaitus_proc_entry = proc_create(RQWU_PROC_ENTRY_FN, 0,
-						  virthba_proc_dir,
-						  &proc_rqwu_fops);
-		enable_ints_proc_entry = proc_create(ENABLE_INTS_ENTRY_FN, 0,
-						     virthba_proc_dir,
-						     &proc_enable_ints_fops);
 
+		/* create the debugfs directories and entries */
+		virthba_debugfs_dir = debugfs_create_dir("virthba", NULL);
+		debugfs_create_file("info", S_IRUSR, virthba_debugfs_dir,
+				NULL, &debugfs_info_fops);
+		debugfs_create_u32("rqwait_usecs", S_IRUSR | S_IWUSR,
+				virthba_debugfs_dir, &rsltq_wait_usecs);
+		debugfs_create_file("enable_ints", S_IWUSR,
+				virthba_debugfs_dir, NULL,
+				&debugfs_enable_ints_fops);
 		/* Initialize DARWorkQ */
 		INIT_WORK(&DARWorkQ, doDiskAddRemove);
 		spin_lock_init(&DARWorkQLock);
@@ -1799,18 +1747,7 @@
 		virthba_serverdown_workqueue = NULL;
 	}
 
-	if (info_proc_entry)
-		remove_proc_entry(INFO_PROC_ENTRY_FN, virthba_proc_dir);
-
-	if (rqwaitus_proc_entry)
-		remove_proc_entry(RQWU_PROC_ENTRY_FN, NULL);
-
-	if (enable_ints_proc_entry)
-		remove_proc_entry(ENABLE_INTS_ENTRY_FN, NULL);
-
-	if (virthba_proc_dir)
-		remove_proc_entry(DIR_PROC_ENTRY, NULL);
-
+	debugfs_remove_recursive(virthba_debugfs_dir);
 	LOGINF("Leaving virthba_mod_exit\n");
 
 }
diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c
index 7d840b0..a80617f 100644
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ b/drivers/staging/unisys/virtpci/virtpci.c
@@ -36,6 +36,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/if_ether.h>
 #include <linux/version.h>
+#include <linux/debugfs.h>
 #include "version.h"
 #include "guestlinuxdebug.h"
 #include "timskmodutils.h"
@@ -58,6 +59,11 @@
 
 #define BUS_ID(x) dev_name(x)
 
+/* MAX_BUF = 4 busses x ( 32 devices/bus + 1 busline) x 80 characters
+ *         = 10,560 bytes ~ 2^14 = 16,384 bytes
+ */
+#define MAX_BUF 16384
+
 #include "virtpci.h"
 
 /* this is shorter than using __FILE__ (full path name) in
@@ -100,6 +106,12 @@
 static int virtpci_device_probe(struct device *dev);
 static int virtpci_device_remove(struct device *dev);
 
+static ssize_t info_debugfs_read(struct file *file, char __user *buf,
+			      size_t len, loff_t *offset);
+
+static const struct file_operations debugfs_info_fops = {
+	.read = info_debugfs_read,
+};
 
 /*****************************************************/
 /* Globals                                           */
@@ -140,6 +152,13 @@
 /* filled in with info about this driver, wrt it servicing client busses */
 static ULTRA_VBUS_DEVICEINFO Bus_DriverInfo;
 
+/*****************************************************/
+/* debugfs entries                                   */
+/*****************************************************/
+/* dentry is used to create the debugfs entry directory
+ * for virtpci
+ */
+static struct dentry *virtpci_debugfs_dir;
 
 struct virtpci_busdev {
 	struct device virtpci_bus_device;
@@ -1377,6 +1396,90 @@
 EXPORT_SYMBOL_GPL(virtpci_unregister_driver);
 
 /*****************************************************/
+/* debugfs filesystem functions                      */
+/*****************************************************/
+struct print_vbus_info {
+	int *str_pos;
+	char *buf;
+	size_t *len;
+};
+
+static int print_vbus(struct device *vbus, void *data)
+{
+	struct print_vbus_info *p = (struct print_vbus_info *)data;
+
+	*p->str_pos += scnprintf(p->buf + *p->str_pos, *p->len - *p->str_pos,
+				"bus_id:%s\n", dev_name(vbus));
+	return 0;
+}
+
+static ssize_t info_debugfs_read(struct file *file, char __user *buf,
+			      size_t len, loff_t *offset)
+{
+	ssize_t bytes_read = 0;
+	int str_pos = 0;
+	struct virtpci_dev *tmpvpcidev;
+	unsigned long flags;
+	struct print_vbus_info printparam;
+	char *vbuf;
+
+	if (len > MAX_BUF)
+		len = MAX_BUF;
+	vbuf = kzalloc(len, GFP_KERNEL);
+	if (!vbuf)
+		return -ENOMEM;
+
+	str_pos += scnprintf(vbuf + str_pos, len - str_pos,
+			" Virtual PCI Bus devices\n");
+	printparam.str_pos = &str_pos;
+	printparam.buf = vbuf;
+	printparam.len = &len;
+	if (bus_for_each_dev(&virtpci_bus_type, NULL,
+			     (void *) &printparam, print_vbus))
+		LOGERR("Failed to find bus\n");
+
+	str_pos += scnprintf(vbuf + str_pos, len - str_pos,
+			"\n Virtual PCI devices\n");
+	read_lock_irqsave(&VpcidevListLock, flags);
+	tmpvpcidev = VpcidevListHead;
+	while (tmpvpcidev) {
+		if (tmpvpcidev->devtype == VIRTHBA_TYPE) {
+			str_pos += scnprintf(vbuf + str_pos, len - str_pos,
+					"[%d:%d] VHba:%08x:%08x max-config:%d-%d-%d-%d",
+					tmpvpcidev->busNo, tmpvpcidev->deviceNo,
+					tmpvpcidev->scsi.wwnn.wwnn1,
+					tmpvpcidev->scsi.wwnn.wwnn2,
+					tmpvpcidev->scsi.max.max_channel,
+					tmpvpcidev->scsi.max.max_id,
+					tmpvpcidev->scsi.max.max_lun,
+					tmpvpcidev->scsi.max.cmd_per_lun);
+		} else {
+			str_pos += scnprintf(vbuf + str_pos, len - str_pos,
+					"[%d:%d] VNic:%02x:%02x:%02x:%02x:%02x:%02x num_rcv_bufs:%d mtu:%d",
+					tmpvpcidev->busNo, tmpvpcidev->deviceNo,
+					tmpvpcidev->net.mac_addr[0],
+					tmpvpcidev->net.mac_addr[1],
+					tmpvpcidev->net.mac_addr[2],
+					tmpvpcidev->net.mac_addr[3],
+					tmpvpcidev->net.mac_addr[4],
+					tmpvpcidev->net.mac_addr[5],
+					tmpvpcidev->net.num_rcv_bufs,
+					tmpvpcidev->net.mtu);
+		}
+		str_pos += scnprintf(vbuf + str_pos,
+				len - str_pos, " chanptr:%p\n",
+				tmpvpcidev->queueinfo.chan);
+				tmpvpcidev = tmpvpcidev->next;
+	}
+	read_unlock_irqrestore(&VpcidevListLock, flags);
+
+	str_pos += scnprintf(vbuf + str_pos, len - str_pos, "\n");
+	bytes_read = simple_read_from_buffer(buf, len, offset, vbuf, str_pos);
+	kfree(vbuf);
+	return bytes_read;
+}
+
+/*****************************************************/
 /* Module Init & Exit functions                      */
 /*****************************************************/
 
@@ -1426,7 +1529,10 @@
 
 	LOGINF("successfully registered virtpci_ctrlchan_func (0x%p) as callback.\n",
 	     (void *) &virtpci_ctrlchan_func);
-
+	/* create debugfs directory and info file inside. */
+	virtpci_debugfs_dir = debugfs_create_dir("virtpci", NULL);
+	debugfs_create_file("info", S_IRUSR, virtpci_debugfs_dir,
+			NULL, &debugfs_info_fops);
 	LOGINF("Leaving\n");
 	POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
 	return 0;
@@ -1442,7 +1548,7 @@
 
 	device_unregister(&virtpci_rootbus_device);
 	bus_unregister(&virtpci_bus_type);
-
+	debugfs_remove_recursive(virtpci_debugfs_dir);
 	LOGINF("Leaving\n");
 
 }
diff --git a/drivers/staging/unisys/visorchipset/Makefile b/drivers/staging/unisys/visorchipset/Makefile
index 5071878..1268690 100644
--- a/drivers/staging/unisys/visorchipset/Makefile
+++ b/drivers/staging/unisys/visorchipset/Makefile
@@ -4,8 +4,7 @@
 
 obj-$(CONFIG_UNISYS_VISORCHIPSET)	+= visorchipset.o
 
-visorchipset-y := visorchipset_main.o controlvm_direct.o file.o \
-			parser.o
+visorchipset-y := visorchipset_main.o file.o parser.o
 
 ccflags-y += -Idrivers/staging/unisys/include
 ccflags-y += -Idrivers/staging/unisys/uislib
diff --git a/drivers/staging/unisys/visorchipset/controlvm.h b/drivers/staging/unisys/visorchipset/controlvm.h
deleted file mode 100644
index 012891c..0000000
--- a/drivers/staging/unisys/visorchipset/controlvm.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* controlvm.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 as published by
- * the Free Software Foundation; either version 2 of the License, 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, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-#ifndef __CONTROLVM_H__
-#define __CONTROLVM_H__
-
-#include "timskmod.h"
-
-int         controlvm_init(void);
-void        controlvm_deinit(void);
-HOSTADDRESS controlvm_get_channel_address(void);
-
-#endif
diff --git a/drivers/staging/unisys/visorchipset/controlvm_direct.c b/drivers/staging/unisys/visorchipset/controlvm_direct.c
deleted file mode 100644
index cd10e3a..0000000
--- a/drivers/staging/unisys/visorchipset/controlvm_direct.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* controlvm_direct.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 as published by
- * the Free Software Foundation; either version 2 of the License, 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, GOOD TITLE or
- * NON INFRINGEMENT.  See the GNU General Public License for more
- * details.
- */
-
-/* This is a controlvm-related code that is dependent upon firmware running
- * on a virtual partition.
- */
-
-#include "globals.h"
-#include "uisutils.h"
-#include "controlvm.h"
-#define CURRENT_FILE_PC VISOR_CHIPSET_PC_controlvm_direct_c
-
-
-/* We can fill in this code when we learn how to make vmcalls... */
-
-
-
-int controlvm_init(void)
-{
-	return 0;
-}
-
-
-
-void controlvm_deinit(void)
-{
-}
-
-
-
-HOSTADDRESS controlvm_get_channel_address(void)
-{
-	static BOOL warned = FALSE;
-	U64 addr = 0;
-
-	U32 size = 0;
-
-	if (!VMCALL_SUCCESSFUL(Issue_VMCALL_IO_CONTROLVM_ADDR(&addr, &size))) {
-		if (!warned) {
-			ERRDRV("%s - vmcall to determine controlvm channel addr failed",
-			       __func__);
-			warned = TRUE;
-		}
-		return 0;
-	}
-	INFODRV("controlvm addr=%Lx", addr);
-	return addr;
-}
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index f897128..48db6ee 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -16,7 +16,6 @@
  */
 
 #include "globals.h"
-#include "controlvm.h"
 #include "visorchipset.h"
 #include "procobjecttree.h"
 #include "visorchannel.h"
@@ -125,42 +124,7 @@
 	p[PARTPROP_last] = NULL;
 }
 
-typedef enum {
-	CTLVMPROP_invalid,
-	CTLVMPROP_physAddr,
-	CTLVMPROP_controlChannelAddr,
-	CTLVMPROP_controlChannelBytes,
-	CTLVMPROP_sparBootPart,
-	CTLVMPROP_sparStoragePart,
-	CTLVMPROP_livedumpLength,
-	CTLVMPROP_livedumpCrc32,
-	/* add new properties above, but don't forget to change
-	 * InitControlVmProperties() show_controlvm_property() also...
-	 */
-	CTLVMPROP_last
-} CONTROLVM_property;
-
-static const char *ControlVmTypeNames[] = { "controlvm", NULL };
-
-static char *ControlVmPropertyNames[CTLVMPROP_last + 1];
-static void
-InitControlVmProperties(void)
-{
-	char **p = ControlVmPropertyNames;
-	p[CTLVMPROP_invalid] = "";
-	p[CTLVMPROP_physAddr] = "physAddr";
-	p[CTLVMPROP_controlChannelAddr] = "controlChannelAddr";
-	p[CTLVMPROP_controlChannelBytes] = "controlChannelBytes";
-	p[CTLVMPROP_sparBootPart] = "spar_boot_part";
-	p[CTLVMPROP_sparStoragePart] = "spar_storage_part";
-	p[CTLVMPROP_livedumpLength] = "livedumpLength";
-	p[CTLVMPROP_livedumpCrc32] = "livedumpCrc32";
-	p[CTLVMPROP_last] = NULL;
-}
-
-static MYPROCOBJECT *ControlVmObject;
 static MYPROCTYPE *PartitionType;
-static MYPROCTYPE *ControlVmType;
 
 #define VISORCHIPSET_DIAG_PROC_ENTRY_FN "diagdump"
 static struct proc_dir_entry *diag_proc_dir;
@@ -185,31 +149,12 @@
 static ssize_t proc_write_installer(struct file *file,
 				    const char __user *buffer,
 				    size_t count, loff_t *ppos);
-static ssize_t proc_read_toolaction(struct file *file, char __user *buf,
-				    size_t len, loff_t *offset);
-static ssize_t proc_write_toolaction(struct file *file,
-				     const char __user *buffer,
-				     size_t count, loff_t *ppos);
-static ssize_t proc_read_bootToTool(struct file *file, char __user *buf,
-				    size_t len, loff_t *offset);
-static ssize_t proc_write_bootToTool(struct file *file,
-				     const char __user *buffer,
-				     size_t count, loff_t *ppos);
+
 static const struct file_operations proc_installer_fops = {
 	.read = proc_read_installer,
 	.write = proc_write_installer,
 };
 
-static const struct file_operations proc_toolaction_fops = {
-	.read = proc_read_toolaction,
-	.write = proc_write_toolaction,
-};
-
-static const struct file_operations proc_bootToTool_fops = {
-	.read = proc_read_bootToTool,
-	.write = proc_write_bootToTool,
-};
-
 typedef struct {
 	U8 __iomem *ptr;	/* pointer to base address of payload pool */
 	U64 offset;		/* offset from beginning of controlvm
@@ -357,10 +302,40 @@
 /* info for /dev/visorchipset */
 static dev_t MajorDev = -1; /**< indicates major num for device */
 
+/* prototypes for attributes */
+static ssize_t toolaction_show(struct device *dev,
+	struct device_attribute *attr, char *buf);
+static ssize_t toolaction_store(struct device *dev,
+	struct device_attribute *attr, const char *buf, size_t count);
+static DEVICE_ATTR_RW(toolaction);
+
+static ssize_t boottotool_show(struct device *dev,
+	struct device_attribute *attr, char *buf);
+static ssize_t boottotool_store(struct device *dev,
+	struct device_attribute *attr, const char *buf, size_t count);
+static DEVICE_ATTR_RW(boottotool);
+
+static struct attribute *visorchipset_install_attrs[] = {
+	&dev_attr_toolaction.attr,
+	&dev_attr_boottotool.attr,
+	NULL
+};
+
+static struct attribute_group visorchipset_install_group = {
+	.name = "install",
+	.attrs = visorchipset_install_attrs
+};
+
+static const struct attribute_group *visorchipset_dev_groups[] = {
+	&visorchipset_install_group,
+	NULL
+};
+
 /* /sys/devices/platform/visorchipset */
 static struct platform_device Visorchipset_platform_device = {
 	.name = "visorchipset",
 	.id = -1,
+	.dev.groups = visorchipset_dev_groups,
 };
 
 /* Function prototypes */
@@ -372,6 +347,66 @@
 						  msgHdr, int response,
 						  ULTRA_SEGMENT_STATE state);
 
+ssize_t toolaction_show(struct device *dev, struct device_attribute *attr,
+		char *buf)
+{
+	U8 toolAction;
+
+	visorchannel_read(ControlVm_channel,
+		offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
+			   ToolAction), &toolAction, sizeof(U8));
+	return scnprintf(buf, PAGE_SIZE, "%u\n", toolAction);
+}
+
+ssize_t toolaction_store(struct device *dev, struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	U8 toolAction;
+
+	if (sscanf(buf, "%hhu\n", &toolAction) == 1) {
+		if (visorchannel_write(ControlVm_channel,
+			offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
+				ToolAction),
+			&toolAction, sizeof(U8)) < 0)
+				return -EFAULT;
+			else
+				return count;
+	} else
+		return -EIO;
+}
+
+ssize_t boottotool_show(struct device *dev, struct device_attribute *attr,
+		char *buf)
+{
+	ULTRA_EFI_SPAR_INDICATION efiSparIndication;
+
+	visorchannel_read(ControlVm_channel,
+		offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
+			EfiSparIndication), &efiSparIndication,
+		sizeof(ULTRA_EFI_SPAR_INDICATION));
+	return scnprintf(buf, PAGE_SIZE, "%u\n",
+			efiSparIndication.BootToTool);
+}
+
+ssize_t boottotool_store(struct device *dev, struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	int val;
+	ULTRA_EFI_SPAR_INDICATION efiSparIndication;
+
+	if (sscanf(buf, "%u\n", &val) == 1) {
+		efiSparIndication.BootToTool = val;
+		if (visorchannel_write(ControlVm_channel,
+			offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
+				 EfiSparIndication),
+			&(efiSparIndication),
+		sizeof(ULTRA_EFI_SPAR_INDICATION)) < 0)
+				return -EFAULT;
+			else
+				return count;
+	} else
+		return -EIO;
+}
 static void
 show_partition_property(struct seq_file *f, void *ctx, int property)
 {
@@ -397,63 +432,6 @@
 }
 
 static void
-show_controlvm_property(struct seq_file *f, void *ctx, int property)
-{
-	/* Note: ctx is not needed since we only have 1 controlvm channel */
-	switch (property) {
-	case CTLVMPROP_physAddr:
-		if (ControlVm_channel == NULL)
-			seq_puts(f, "0x0\n");
-		else
-			seq_printf(f, "0x%-16.16Lx\n",
-				   visorchannel_get_physaddr
-				   (ControlVm_channel));
-		break;
-	case CTLVMPROP_controlChannelAddr:
-		if (ControlVm_channel == NULL)
-			seq_puts(f, "0x0\n");
-		else {
-			GUEST_PHYSICAL_ADDRESS addr = 0;
-			visorchannel_read(ControlVm_channel,
-					  offsetof
-					  (ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-					   gpControlChannel), &addr,
-					  sizeof(addr));
-			seq_printf(f, "0x%-16.16Lx\n", (u64) (addr));
-		}
-		break;
-	case CTLVMPROP_controlChannelBytes:
-		if (ControlVm_channel == NULL)
-			seq_puts(f, "0x0\n");
-		else {
-			U32 bytes = 0;
-			visorchannel_read(ControlVm_channel,
-					  offsetof
-					  (ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-					   ControlChannelBytes), &bytes,
-					  sizeof(bytes));
-			seq_printf(f, "%lu\n", (ulong) (bytes));
-		}
-		break;
-	case CTLVMPROP_sparBootPart:
-		seq_puts(f, "0:0:0:0/1\n");
-		break;
-	case CTLVMPROP_sparStoragePart:
-		seq_puts(f, "0:0:0:0/2\n");
-		break;
-	case CTLVMPROP_livedumpLength:
-		seq_printf(f, "%lu\n", LiveDump_info.length);
-		break;
-	case CTLVMPROP_livedumpCrc32:
-		seq_printf(f, "%lu\n", (ulong) LiveDump_info.crc32);
-		break;
-	default:
-		seq_printf(f, "(%d??)\n", property);
-		break;
-	}
-}
-
-static void
 proc_Init(void)
 {
 	if (ProcDir == NULL) {
@@ -669,8 +647,6 @@
 controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response)
 {
 	CONTROLVM_MESSAGE outmsg;
-	if (!ControlVm_channel)
-		return;
 	controlvm_init_response(&outmsg, msgHdr, response);
 	/* For DiagPool channel DEVICE_CHANGESTATE, we need to send
 	* back the deviceChangeState structure in the packet. */
@@ -697,8 +673,6 @@
 			       ULTRA_CHIPSET_FEATURE features)
 {
 	CONTROLVM_MESSAGE outmsg;
-	if (!ControlVm_channel)
-		return;
 	controlvm_init_response(&outmsg, msgHdr, response);
 	outmsg.cmd.initChipset.features = features;
 	if (!visorchannel_signalinsert(ControlVm_channel,
@@ -713,8 +687,6 @@
 				      int response, ULTRA_SEGMENT_STATE state)
 {
 	CONTROLVM_MESSAGE outmsg;
-	if (!ControlVm_channel)
-		return;
 	controlvm_init_response(&outmsg, msgHdr, response);
 	outmsg.cmd.deviceChangeState.state = state;
 	outmsg.cmd.deviceChangeState.flags.physicalDevice = 1;
@@ -832,9 +804,6 @@
 	VISORCHIPSET_DEVICE_INFO *p = NULL;
 	CONTROLVM_MESSAGE outmsg;
 
-	if (!ControlVm_channel)
-		return;
-
 	p = finddevice(&DevInfoList, busNo, devNo);
 	if (!p) {
 		LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo);
@@ -1929,12 +1898,25 @@
 	return TRUE;
 }
 
+HOSTADDRESS controlvm_get_channel_address(void)
+{
+	U64 addr = 0;
+	U32 size = 0;
+
+	if (!VMCALL_SUCCESSFUL(Issue_VMCALL_IO_CONTROLVM_ADDR(&addr, &size))) {
+		ERRDRV("%s - vmcall to determine controlvm channel addr failed",
+		       __func__);
+		return 0;
+	}
+	INFODRV("controlvm addr=%Lx", addr);
+	return addr;
+}
+
 static void
 controlvm_periodic_work(struct work_struct *work)
 {
 	VISORCHIPSET_CHANNEL_INFO chanInfo;
 	CONTROLVM_MESSAGE inmsg;
-	char s[99];
 	BOOL gotACommand = FALSE;
 	BOOL handle_command_failed = FALSE;
 	static U64 Poll_Count;
@@ -1949,32 +1931,9 @@
 		goto Away;
 
 	memset(&chanInfo, 0, sizeof(VISORCHIPSET_CHANNEL_INFO));
-	if (!ControlVm_channel) {
-		HOSTADDRESS addr = controlvm_get_channel_address();
-		if (addr != 0) {
-			ControlVm_channel =
-			    visorchannel_create_with_lock
-			    (addr,
-			     sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL),
-			     UltraControlvmChannelProtocolGuid);
-			if (ControlVm_channel == NULL)
-				LOGERR("failed to create controlvm channel");
-			else if (ULTRA_CONTROLVM_CHANNEL_OK_CLIENT
-				 (visorchannel_get_header(ControlVm_channel),
-				  NULL)) {
-				LOGINF("Channel %s (ControlVm) discovered",
-				       visorchannel_id(ControlVm_channel, s));
-				initialize_controlvm_payload();
-			} else {
-				LOGERR("controlvm channel is invalid");
-				visorchannel_destroy(ControlVm_channel);
-				ControlVm_channel = NULL;
-			}
-		}
-	}
 
 	Poll_Count++;
-	if ((ControlVm_channel != NULL) || (Poll_Count >= 250))
+	if (Poll_Count >= 250)
 		;	/* keep going */
 	else
 		goto Away;
@@ -1993,54 +1952,46 @@
 		}
 	}
 
-	if (ControlVm_channel) {
-		while (visorchannel_signalremove(ControlVm_channel,
-						 CONTROLVM_QUEUE_RESPONSE,
-						 &inmsg)) {
-			if (inmsg.hdr.PayloadMaxBytes != 0) {
-				LOGERR("Payload of size %lu returned @%lu with unexpected message id %d.",
-				     (ulong) inmsg.hdr.PayloadMaxBytes,
-				     (ulong) inmsg.hdr.PayloadVmOffset,
-				     inmsg.hdr.Id);
-			}
+	while (visorchannel_signalremove(ControlVm_channel,
+					 CONTROLVM_QUEUE_RESPONSE,
+					 &inmsg)) {
+		if (inmsg.hdr.PayloadMaxBytes != 0) {
+			LOGERR("Payload of size %lu returned @%lu with unexpected message id %d.",
+			     (ulong) inmsg.hdr.PayloadMaxBytes,
+			     (ulong) inmsg.hdr.PayloadVmOffset,
+			     inmsg.hdr.Id);
 		}
-		if (!gotACommand) {
-			if (ControlVm_Pending_Msg_Valid) {
-				/* we throttled processing of a prior
-				* msg, so try to process it again
-				* rather than reading a new one
-				*/
-				inmsg = ControlVm_Pending_Msg;
-				ControlVm_Pending_Msg_Valid = FALSE;
-				gotACommand = TRUE;
-			} else
-				gotACommand = read_controlvm_event(&inmsg);
-		}
+	}
+	if (!gotACommand) {
+		if (ControlVm_Pending_Msg_Valid) {
+			/* we throttled processing of a prior
+			* msg, so try to process it again
+			* rather than reading a new one
+			*/
+			inmsg = ControlVm_Pending_Msg;
+			ControlVm_Pending_Msg_Valid = FALSE;
+			gotACommand = TRUE;
+		} else
+			gotACommand = read_controlvm_event(&inmsg);
 	}
 
 	handle_command_failed = FALSE;
 	while (gotACommand && (!handle_command_failed)) {
 		Most_recent_message_jiffies = jiffies;
-		if (ControlVm_channel) {
-			if (handle_command(inmsg,
-					   visorchannel_get_physaddr
-					   (ControlVm_channel)))
-				gotACommand = read_controlvm_event(&inmsg);
-			else {
-				/* this is a scenario where throttling
-				* is required, but probably NOT an
-				* error...; we stash the current
-				* controlvm msg so we will attempt to
-				* reprocess it on our next loop
-				*/
-				handle_command_failed = TRUE;
-				ControlVm_Pending_Msg = inmsg;
-				ControlVm_Pending_Msg_Valid = TRUE;
-			}
-
-		} else {
-			handle_command(inmsg, 0);
-			gotACommand = FALSE;
+		if (handle_command(inmsg,
+				   visorchannel_get_physaddr
+				   (ControlVm_channel)))
+			gotACommand = read_controlvm_event(&inmsg);
+		else {
+			/* this is a scenario where throttling
+			* is required, but probably NOT an
+			* error...; we stash the current
+			* controlvm msg so we will attempt to
+			* reprocess it on our next loop
+			*/
+			handle_command_failed = TRUE;
+			ControlVm_Pending_Msg = inmsg;
+			ControlVm_Pending_Msg_Valid = TRUE;
 		}
 	}
 
@@ -2077,7 +2028,6 @@
 	CONTROLVM_MESSAGE localCrashCreateBusMsg;
 	CONTROLVM_MESSAGE localCrashCreateDevMsg;
 	CONTROLVM_MESSAGE msg;
-	HOSTADDRESS host_addr;
 	U32 localSavedCrashMsgOffset;
 	U16 localSavedCrashMsgCount;
 
@@ -2100,26 +2050,6 @@
 
 	chipset_init(&msg);
 
-	host_addr = controlvm_get_channel_address();
-	if (!host_addr) {
-		LOGERR("Huh?  Host address is NULL");
-		POSTCODE_LINUX_2(CRASH_DEV_HADDR_NULL, POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
-	ControlVm_channel =
-	    visorchannel_create_with_lock
-	    (host_addr,
-	     sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL),
-	     UltraControlvmChannelProtocolGuid);
-
-	if (ControlVm_channel == NULL) {
-		LOGERR("failed to create controlvm channel");
-		POSTCODE_LINUX_2(CRASH_DEV_CONTROLVM_NULL,
-				 POSTCODE_SEVERITY_ERR);
-		return;
-	}
-
 	/* get saved message count */
 	if (visorchannel_read(ControlVm_channel,
 			      offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
@@ -2410,9 +2340,6 @@
 	char *vbuf;
 	loff_t pos = *offset;
 
-	if (!ControlVm_channel)
-		return -ENODEV;
-
 	if (pos < 0)
 		return -EINVAL;
 
@@ -2462,9 +2389,6 @@
 	U16 remainingSteps;
 	U32 error, textId;
 
-	if (!ControlVm_channel)
-		return -ENODEV;
-
 	/* Check to make sure there is no buffer overflow */
 	if (count > (sizeof(buf) - 1))
 		return -EINVAL;
@@ -2514,173 +2438,6 @@
 	return count;
 }
 
-/**
- * Reads the ToolAction field of ControlVMChannel.
- */
-static ssize_t
-proc_read_toolaction(struct file *file, char __user *buf,
-		     size_t len, loff_t *offset)
-{
-	int length = 0;
-	U8 toolAction;
-	char *vbuf;
-	loff_t pos = *offset;
-
-	if (!ControlVm_channel)
-		return -ENODEV;
-
-	if (pos < 0)
-		return -EINVAL;
-
-	if (pos > 0 || !len)
-		return 0;
-
-	vbuf = kzalloc(len, GFP_KERNEL);
-	if (!vbuf)
-		return -ENOMEM;
-
-	visorchannel_read(ControlVm_channel,
-			  offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-				   ToolAction), &toolAction, sizeof(U8));
-
-	length = sprintf(vbuf, "%u\n", toolAction);
-	if (copy_to_user(buf, vbuf, length)) {
-		kfree(vbuf);
-		return -EFAULT;
-	}
-
-	kfree(vbuf);
-	*offset += length;
-	return length;
-}
-
-/**
- * Writes to the ToolAction field of ControlVMChannel.
- * Input: ToolAction
- * Limit 3 characters input
- */
-#define UINT8_MAX (255U)
-static ssize_t
-proc_write_toolaction(struct file *file,
-		      const char __user *buffer, size_t count, loff_t *ppos)
-{
-	char buf[3];
-	U8 toolAction;
-
-	if (!ControlVm_channel)
-		return -ENODEV;
-
-	/* Check to make sure there is no buffer overflow */
-	if (count > (sizeof(buf) - 1))
-		return -EINVAL;
-
-	if (copy_from_user(buf, buffer, count)) {
-		WARN(1, "Error copying from user space\n");
-		return -EFAULT;
-	}
-
-	if (sscanf(buf, "%hhd", &toolAction) != 1)
-		toolAction = UINT8_MAX;
-
-	if (toolAction != UINT8_MAX) {
-		if (visorchannel_write
-		    (ControlVm_channel,
-		     offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, ToolAction),
-		     &toolAction, sizeof(U8)) < 0)
-			WARN(1, "Installation ToolAction Write Failed - ToolAction = %d\n",
-			     toolAction);
-	}
-
-	/* So this function isn't called multiple times, must return
-	 * size of buffer
-	 */
-	return count;
-}
-
-/**
- * Reads the EfiSparIndication.BootToTool field of ControlVMChannel.
- */
-static ssize_t
-proc_read_bootToTool(struct file *file, char __user *buf,
-		     size_t len, loff_t *offset)
-{
-	int length = 0;
-	ULTRA_EFI_SPAR_INDICATION efiSparIndication;
-	char *vbuf;
-	loff_t pos = *offset;
-
-	if (!ControlVm_channel)
-		return -ENODEV;
-
-	if (pos < 0)
-		return -EINVAL;
-
-	if (pos > 0 || !len)
-		return 0;
-
-	vbuf = kzalloc(len, GFP_KERNEL);
-	if (!vbuf)
-		return -ENOMEM;
-
-	visorchannel_read(ControlVm_channel,
-			  offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-				   EfiSparIndication), &efiSparIndication,
-			  sizeof(ULTRA_EFI_SPAR_INDICATION));
-
-	length = sprintf(vbuf, "%d\n", (int) efiSparIndication.BootToTool);
-	if (copy_to_user(buf, vbuf, length)) {
-		kfree(vbuf);
-		return -EFAULT;
-	}
-
-	kfree(vbuf);
-	*offset += length;
-	return length;
-}
-
-/**
- * Writes to the EfiSparIndication.BootToTool field of ControlVMChannel.
- * Input: 1 or 0 (1 being on, 0 being off)
- */
-static ssize_t
-proc_write_bootToTool(struct file *file,
-		      const char __user *buffer, size_t count, loff_t *ppos)
-{
-	char buf[3];
-	int inputVal;
-	ULTRA_EFI_SPAR_INDICATION efiSparIndication;
-
-	if (!ControlVm_channel)
-		return -ENODEV;
-
-	/* Check to make sure there is no buffer overflow */
-	if (count > (sizeof(buf) - 1))
-		return -EINVAL;
-
-	if (copy_from_user(buf, buffer, count)) {
-		WARN(1, "Error copying from user space\n");
-		return -EFAULT;
-	}
-
-	if (sscanf(buf, "%i", &inputVal) != 1)
-		inputVal = 0;
-
-	efiSparIndication.BootToTool = (inputVal == 1 ? 1 : 0);
-
-	if (visorchannel_write
-	    (ControlVm_channel,
-	     offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EfiSparIndication),
-	     &efiSparIndication, sizeof(ULTRA_EFI_SPAR_INDICATION)) < 0)
-		printk
-		    ("Installation BootToTool Write Failed - BootToTool = %d\n",
-		     (int) efiSparIndication.BootToTool);
-
-	/* So this function isn't called multiple times, must return
-	 * size of buffer
-	 */
-	return count;
-}
-
 static const struct file_operations chipset_proc_fops = {
 	.owner = THIS_MODULE,
 	.read = visorchipset_proc_read_writeonly,
@@ -2691,9 +2448,9 @@
 visorchipset_init(void)
 {
 	int rc = 0, x = 0;
+	char s[64];
 	struct proc_dir_entry *installer_file;
-	struct proc_dir_entry *toolaction_file;
-	struct proc_dir_entry *bootToTool_file;
+	HOSTADDRESS addr;
 
 	if (!unisys_spar_platform)
 		return -ENODEV;
@@ -2725,7 +2482,30 @@
 		goto Away;
 	}
 
-	controlvm_init();
+	addr = controlvm_get_channel_address();
+	if (addr != 0) {
+		ControlVm_channel =
+		    visorchannel_create_with_lock
+		    (addr,
+		     sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL),
+		     UltraControlvmChannelProtocolGuid);
+		if (ULTRA_CONTROLVM_CHANNEL_OK_CLIENT
+			 (visorchannel_get_header(ControlVm_channel),
+			  NULL)) {
+			LOGINF("Channel %s (ControlVm) discovered",
+			       visorchannel_id(ControlVm_channel, s));
+			initialize_controlvm_payload();
+		} else {
+			LOGERR("controlvm channel is invalid");
+			visorchannel_destroy(ControlVm_channel);
+			ControlVm_channel = NULL;
+			return -ENODEV;
+		}
+	} else {
+		LOGERR("no controlvm channel discovered");
+		return -ENODEV;
+	}
+
 	MajorDev = MKDEV(visorchipset_major, 0);
 	rc = visorchipset_file_init(MajorDev, &ControlVm_channel);
 	if (rc < 0) {
@@ -2736,30 +2516,16 @@
 
 	proc_Init();
 	memset(PartitionPropertyNames, 0, sizeof(PartitionPropertyNames));
-	memset(ControlVmPropertyNames, 0, sizeof(ControlVmPropertyNames));
 	InitPartitionProperties();
-	InitControlVmProperties();
 
 	PartitionType = visor_proc_CreateType(ProcDir, PartitionTypeNames,
 					      (const char **)
 					      PartitionPropertyNames,
 					      &show_partition_property);
-	ControlVmType =
-	    visor_proc_CreateType(ProcDir, ControlVmTypeNames,
-				  (const char **) ControlVmPropertyNames,
-				  &show_controlvm_property);
-
-	ControlVmObject = visor_proc_CreateObject(ControlVmType, NULL, NULL);
 
 	/* Setup Installation fields */
 	installer_file = proc_create("installer", 0644, ProcDir,
 				     &proc_installer_fops);
-	/* Setup the ToolAction field */
-	toolaction_file = proc_create("toolaction", 0644, ProcDir,
-				      &proc_toolaction_fops);
-	/* Setup the BootToTool field */
-	bootToTool_file = proc_create("boottotool", 0644, ProcDir,
-				      &proc_bootToTool_fops);
 
 	memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
 
@@ -2855,16 +2621,9 @@
 		kmem_cache_destroy(Putfile_buffer_list_pool);
 		Putfile_buffer_list_pool = NULL;
 	}
-	if (ControlVmObject) {
-		visor_proc_DestroyObject(ControlVmObject);
-		ControlVmObject = NULL;
-	}
+
 	cleanup_controlvm_structures();
 
-	if (ControlVmType) {
-		visor_proc_DestroyType(ControlVmType);
-		ControlVmType = NULL;
-	}
 	if (PartitionType) {
 		visor_proc_DestroyType(PartitionType);
 		PartitionType = NULL;
@@ -2890,13 +2649,10 @@
 	memset(&g_DelDumpMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
 
 	proc_DeInit();
-	if (ControlVm_channel != NULL) {
-		LOGINF("Channel %s (ControlVm) disconnected",
-		       visorchannel_id(ControlVm_channel, s));
-		visorchannel_destroy(ControlVm_channel);
-		ControlVm_channel = NULL;
-	}
-	controlvm_deinit();
+	LOGINF("Channel %s (ControlVm) disconnected",
+	       visorchannel_id(ControlVm_channel, s));
+	visorchannel_destroy(ControlVm_channel);
+
 	visorchipset_file_cleanup();
 	POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
 	LOGINF("chipset driver unloaded");
diff --git a/drivers/staging/vme/devices/vme_pio2_core.c b/drivers/staging/vme/devices/vme_pio2_core.c
index fd19c25..84c5a07 100644
--- a/drivers/staging/vme/devices/vme_pio2_core.c
+++ b/drivers/staging/vme/devices/vme_pio2_core.c
@@ -182,30 +182,30 @@
 
 	if (vdev->num >= bus_num) {
 		dev_err(&vdev->dev,
-			"The enumeration of the VMEbus to which the board is connected must be specified");
+			"The enumeration of the VMEbus to which the board is connected must be specified\n");
 		return 0;
 	}
 
 	if (vdev->num >= base_num) {
 		dev_err(&vdev->dev,
-			"The VME address for the cards registers must be specified");
+			"The VME address for the cards registers must be specified\n");
 		return 0;
 	}
 
 	if (vdev->num >= vector_num) {
 		dev_err(&vdev->dev,
-			"The IRQ vector used by the card must be specified");
+			"The IRQ vector used by the card must be specified\n");
 		return 0;
 	}
 
 	if (vdev->num >= level_num) {
 		dev_err(&vdev->dev,
-			"The IRQ level used by the card must be specified");
+			"The IRQ level used by the card must be specified\n");
 		return 0;
 	}
 
 	if (vdev->num >= variant_num) {
-		dev_err(&vdev->dev, "The variant of the card must be specified");
+		dev_err(&vdev->dev, "The variant of the card must be specified\n");
 		return 0;
 	}
 
@@ -324,7 +324,7 @@
 	retval = pio2_reset_card(card);
 	if (retval) {
 		dev_err(&card->vdev->dev,
-			"Failed to reset card, is location valid?");
+			"Failed to reset card, is location valid?\n");
 		retval = -ENODEV;
 		goto err_reset;
 	}
diff --git a/drivers/staging/vme/devices/vme_pio2_gpio.c b/drivers/staging/vme/devices/vme_pio2_gpio.c
index 2a2d920..f00af07 100644
--- a/drivers/staging/vme/devices/vme_pio2_gpio.c
+++ b/drivers/staging/vme/devices/vme_pio2_gpio.c
@@ -108,7 +108,7 @@
 	if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == OUTPUT) |
 		(card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) {
 		dev_err(&card->vdev->dev,
-			"Channel directionality not configurable at runtine\n");
+			"Channel directionality not configurable at runtime\n");
 
 		data = -EINVAL;
 	} else {
@@ -127,7 +127,7 @@
 	if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == INPUT) |
 		(card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) {
 		dev_err(&card->vdev->dev,
-			"Channel directionality not configurable at runtine\n");
+			"Channel directionality not configurable at runtime\n");
 
 		data = -EINVAL;
 	} else {
@@ -222,7 +222,7 @@
 	const char *label = card->gc.label;
 
 	if (gpiochip_remove(&(card->gc)))
-		dev_err(&card->vdev->dev, "Failed to remove GPIO");
+		dev_err(&card->vdev->dev, "Failed to remove GPIO\n");
 
 	kfree(label);
 }
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c
index 2d84972..920e50a 100644
--- a/drivers/staging/vme/devices/vme_user.c
+++ b/drivers/staging/vme/devices/vme_user.c
@@ -433,7 +433,6 @@
 	default:
 		mutex_unlock(&image[minor].mutex);
 		return -EINVAL;
-		break;
 	}
 
 	if ((absolute < 0) || (absolute >= image_size)) {
@@ -511,7 +510,6 @@
 			}
 
 			return retval;
-			break;
 
 		case VME_SET_MASTER:
 
@@ -552,7 +550,6 @@
 			}
 
 			return retval;
-			break;
 
 		case VME_SET_SLAVE:
 
@@ -806,7 +803,6 @@
 		default:
 			err = -EINVAL;
 			goto err_sysfs;
-			break;
 		}
 
 		num = (type[i] == SLAVE_MINOR) ? i - (MASTER_MAX + 1) : i;
diff --git a/drivers/staging/vt6655/80211hdr.h b/drivers/staging/vt6655/80211hdr.h
index ba155cd..e05d135 100644
--- a/drivers/staging/vt6655/80211hdr.h
+++ b/drivers/staging/vt6655/80211hdr.h
@@ -33,7 +33,6 @@
 
 #include "ttype.h"
 
-/*---------------------  Export Definitions -------------------------*/
 /* bit type */
 #define BIT0	0x00000001
 #define BIT1	0x00000002
@@ -315,10 +314,4 @@
 	WLAN_80211HDR_A4        sA4;
 } UWLAN_80211HDR, *PUWLAN_80211HDR;
 
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
-
 #endif /* __80211HDR_H__ */
diff --git a/drivers/staging/vt6655/80211mgr.h b/drivers/staging/vt6655/80211mgr.h
index 065238b..8b126bb 100644
--- a/drivers/staging/vt6655/80211mgr.h
+++ b/drivers/staging/vt6655/80211mgr.h
@@ -34,8 +34,6 @@
 #include "ttype.h"
 #include "80211hdr.h"
 
-/*---------------------  Export Definitions -------------------------*/
-
 #define WLAN_MIN_ARRAY          1
 
 /* Information Element ID value */
@@ -202,12 +200,6 @@
 #define MEASURE_MODE_INCAPABLE  0x02
 #define MEASURE_MODE_REFUSED    0x04
 
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Types  ------------------------------*/
-
 /* Information Element Types */
 
 #pragma pack(1)
@@ -472,14 +464,11 @@
 	unsigned int	len;
 	unsigned char *pBuf;
 	PUWLAN_80211HDR         pHdr;
-	/* fixed fields */
 	PQWORD                  pqwTimestamp;
 	unsigned short *pwBeaconInterval;
 	unsigned short *pwCapInfo;
-	/*-- info elements ----------*/
 	PWLAN_IE_SSID           pSSID;
 	PWLAN_IE_SUPP_RATES     pSuppRates;
-/*  PWLAN_IE_FH_PARMS       pFHParms; */
 	PWLAN_IE_DS_PARMS       pDSParms;
 	PWLAN_IE_CF_PARMS       pCFParms;
 	PWLAN_IE_TIM            pTIM;
@@ -501,10 +490,6 @@
 	unsigned int	len;
 	unsigned char *pBuf;
 	PUWLAN_80211HDR         pHdr;
-
-	/* fixed fields */
-	/* info elements */
-	/* this frame type has a null body */
 } WLAN_FR_IBSSATIM, *PWLAN_FR_IBSSATIM;
 
 /* Disassociation */
@@ -513,9 +498,7 @@
 	unsigned int	len;
 	unsigned char *pBuf;
 	PUWLAN_80211HDR         pHdr;
-	/*-- fixed fields -----------*/
 	unsigned short *pwReason;
-	/*-- info elements ----------*/
 } WLAN_FR_DISASSOC, *PWLAN_FR_DISASSOC;
 
 /* Association Request */
@@ -524,10 +507,8 @@
 	unsigned int	len;
 	unsigned char *pBuf;
 	PUWLAN_80211HDR         pHdr;
-	/*-- fixed fields -----------*/
 	unsigned short *pwCapInfo;
 	unsigned short *pwListenInterval;
-	/*-- info elements ----------*/
 	PWLAN_IE_SSID           pSSID;
 	PWLAN_IE_SUPP_RATES     pSuppRates;
 	PWLAN_IE_RSN            pRSN;
@@ -543,11 +524,9 @@
 	unsigned int	len;
 	unsigned char *pBuf;
 	PUWLAN_80211HDR         pHdr;
-	/*-- fixed fields -----------*/
 	unsigned short *pwCapInfo;
 	unsigned short *pwStatus;
 	unsigned short *pwAid;
-	/*-- info elements ----------*/
 	PWLAN_IE_SUPP_RATES     pSuppRates;
 	PWLAN_IE_SUPP_RATES     pExtSuppRates;
 } WLAN_FR_ASSOCRESP, *PWLAN_FR_ASSOCRESP;
@@ -558,13 +537,9 @@
 	unsigned int	len;
 	unsigned char *pBuf;
 	PUWLAN_80211HDR         pHdr;
-
-	/*-- fixed fields -----------*/
 	unsigned short *pwCapInfo;
 	unsigned short *pwListenInterval;
 	PIEEE_ADDR              pAddrCurrAP;
-
-	/*-- info elements ----------*/
 	PWLAN_IE_SSID           pSSID;
 	PWLAN_IE_SUPP_RATES     pSuppRates;
 	PWLAN_IE_RSN            pRSN;
@@ -578,11 +553,9 @@
 	unsigned int	len;
 	unsigned char *pBuf;
 	PUWLAN_80211HDR         pHdr;
-	/*-- fixed fields -----------*/
 	unsigned short *pwCapInfo;
 	unsigned short *pwStatus;
 	unsigned short *pwAid;
-	/*-- info elements ----------*/
 	PWLAN_IE_SUPP_RATES     pSuppRates;
 	PWLAN_IE_SUPP_RATES     pExtSuppRates;
 } WLAN_FR_REASSOCRESP, *PWLAN_FR_REASSOCRESP;
@@ -593,8 +566,6 @@
 	unsigned int	len;
 	unsigned char *pBuf;
 	PUWLAN_80211HDR         pHdr;
-	/*-- fixed fields -----------*/
-	/*-- info elements ----------*/
 	PWLAN_IE_SSID           pSSID;
 	PWLAN_IE_SUPP_RATES     pSuppRates;
 	PWLAN_IE_SUPP_RATES     pExtSuppRates;
@@ -606,11 +577,9 @@
 	unsigned int	len;
 	unsigned char *pBuf;
 	PUWLAN_80211HDR         pHdr;
-	/*-- fixed fields -----------*/
 	PQWORD                  pqwTimestamp;
 	unsigned short *pwBeaconInterval;
 	unsigned short *pwCapInfo;
-	/*-- info elements ----------*/
 	PWLAN_IE_SSID           pSSID;
 	PWLAN_IE_SUPP_RATES     pSuppRates;
 	PWLAN_IE_DS_PARMS       pDSParms;
@@ -633,11 +602,9 @@
 	unsigned int	len;
 	unsigned char *pBuf;
 	PUWLAN_80211HDR         pHdr;
-	/*-- fixed fields -----------*/
 	unsigned short *pwAuthAlgorithm;
 	unsigned short *pwAuthSequence;
 	unsigned short *pwStatus;
-	/*-- info elements ----------*/
 	PWLAN_IE_CHALLENGE      pChallenge;
 } WLAN_FR_AUTHEN, *PWLAN_FR_AUTHEN;
 
@@ -647,14 +614,9 @@
 	unsigned int	len;
 	unsigned char *pBuf;
 	PUWLAN_80211HDR         pHdr;
-	/*-- fixed fields -----------*/
 	unsigned short *pwReason;
-
-	/*-- info elements ----------*/
 } WLAN_FR_DEAUTHEN, *PWLAN_FR_DEAUTHEN;
 
-/*---------------------  Export Functions  --------------------------*/
-
 void
 vMgrEncodeBeacon(
 	PWLAN_FR_BEACON  pFrame
diff --git a/drivers/staging/vt6655/IEEE11h.c b/drivers/staging/vt6655/IEEE11h.c
index 6cfad1c..180a27c 100644
--- a/drivers/staging/vt6655/IEEE11h.c
+++ b/drivers/staging/vt6655/IEEE11h.c
@@ -41,7 +41,6 @@
 #include "channel.h"
 
 /*---------------------  Static Definitions -------------------------*/
-static int          msglevel                = MSG_LEVEL_INFO;
 
 #pragma pack(1)
 
@@ -98,185 +97,11 @@
 /*---------------------  Static Variables  --------------------------*/
 
 /*---------------------  Static Functions  --------------------------*/
-static bool s_bRxMSRReq(PSMgmtObject pMgmt, PWLAN_FRAME_MSRREQ pMSRReq,
-			unsigned int uLength)
-{
-	size_t    uNumOfEIDs = 0;
-	bool bResult = true;
-
-	if (uLength <= WLAN_A3FR_MAXLEN)
-		memcpy(pMgmt->abyCurrentMSRReq, pMSRReq, uLength);
-	uNumOfEIDs = ((uLength - offsetof(WLAN_FRAME_MSRREQ,
-					  sMSRReqEIDs))/
-		      (sizeof(WLAN_IE_MEASURE_REQ)));
-	pMgmt->pCurrMeasureEIDRep = &(((PWLAN_FRAME_MSRREP)
-				       (pMgmt->abyCurrentMSRRep))->sMSRRepEIDs[0]);
-	pMgmt->uLengthOfRepEIDs = 0;
-	bResult = CARDbStartMeasure(pMgmt->pAdapter,
-				    ((PWLAN_FRAME_MSRREQ)
-				     (pMgmt->abyCurrentMSRReq))->sMSRReqEIDs,
-				    uNumOfEIDs
-);
-	return bResult;
-}
-
-static bool s_bRxTPCReq(PSMgmtObject pMgmt,
-			PWLAN_FRAME_TPCREQ pTPCReq,
-			unsigned char byRate,
-			unsigned char byRSSI)
-{
-	PWLAN_FRAME_TPCREP  pFrame;
-	PSTxMgmtPacket      pTxPacket = NULL;
-
-	pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
-	memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN);
-	pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket +
-						    sizeof(STxMgmtPacket));
-
-	pFrame = (PWLAN_FRAME_TPCREP)((unsigned char *)pTxPacket +
-				      sizeof(STxMgmtPacket));
-
-	pFrame->Header.wFrameCtl = (WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) |
-				    WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION)
-);
-
-	memcpy(pFrame->Header.abyAddr1,
-	       pTPCReq->Header.abyAddr2,
-	       WLAN_ADDR_LEN);
-	memcpy(pFrame->Header.abyAddr2,
-	       CARDpGetCurrentAddress(pMgmt->pAdapter),
-	       WLAN_ADDR_LEN);
-	memcpy(pFrame->Header.abyAddr3,
-	       pMgmt->abyCurrBSSID,
-	       WLAN_BSSID_LEN);
-
-	pFrame->byCategory = 0;
-	pFrame->byAction = 3;
-	pFrame->byDialogToken = ((PWLAN_FRAME_MSRREQ)
-				 (pMgmt->abyCurrentMSRReq))->byDialogToken;
-
-	pFrame->sTPCRepEIDs.byElementID = WLAN_EID_TPC_REP;
-	pFrame->sTPCRepEIDs.len = 2;
-	pFrame->sTPCRepEIDs.byTxPower = CARDbyGetTransmitPower(pMgmt->pAdapter);
-	switch (byRate) {
-	case RATE_54M:
-		pFrame->sTPCRepEIDs.byLinkMargin = 65 - byRSSI;
-		break;
-	case RATE_48M:
-		pFrame->sTPCRepEIDs.byLinkMargin = 66 - byRSSI;
-		break;
-	case RATE_36M:
-		pFrame->sTPCRepEIDs.byLinkMargin = 70 - byRSSI;
-		break;
-	case RATE_24M:
-		pFrame->sTPCRepEIDs.byLinkMargin = 74 - byRSSI;
-		break;
-	case RATE_18M:
-		pFrame->sTPCRepEIDs.byLinkMargin = 77 - byRSSI;
-		break;
-	case RATE_12M:
-		pFrame->sTPCRepEIDs.byLinkMargin = 79 - byRSSI;
-		break;
-	case RATE_9M:
-		pFrame->sTPCRepEIDs.byLinkMargin = 81 - byRSSI;
-		break;
-	case RATE_6M:
-	default:
-		pFrame->sTPCRepEIDs.byLinkMargin = 82 - byRSSI;
-		break;
-	}
-
-	pTxPacket->cbMPDULen = sizeof(WLAN_FRAME_TPCREP);
-	pTxPacket->cbPayloadLen = sizeof(WLAN_FRAME_TPCREP) -
-		WLAN_HDR_ADDR3_LEN;
-	if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING)
-		return false;
-	return true;
-}
 
 /*---------------------  Export Variables  --------------------------*/
 
 /*---------------------  Export Functions  --------------------------*/
 
-/*+
- *
- * Description:
- *      Handles action management frames.
- *
- * Parameters:
- *  In:
- *      pMgmt           - Management Object structure
- *      pRxPacket       - Received packet
- *  Out:
- *      none
- *
- * Return Value: None.
- *
- -*/
-bool
-IEEE11hbMgrRxAction(void *pMgmtHandle, void *pRxPacket)
-{
-	PSMgmtObject            pMgmt = (PSMgmtObject) pMgmtHandle;
-	PWLAN_FRAME_ACTION      pAction = NULL;
-	unsigned int uLength = 0;
-	PWLAN_IE_CH_SW          pChannelSwitch = NULL;
-
-	/* decode the frame */
-	uLength = ((PSRxMgmtPacket)pRxPacket)->cbMPDULen;
-	if (uLength > WLAN_A3FR_MAXLEN)
-		return false;
-
-	pAction = (PWLAN_FRAME_ACTION)
-		(((PSRxMgmtPacket)pRxPacket)->p80211Header);
-
-	if (pAction->byCategory == 0) {
-		switch (pAction->byAction) {
-		case ACTION_MSRREQ:
-			return s_bRxMSRReq(pMgmt,
-					   (PWLAN_FRAME_MSRREQ)
-					   pAction,
-					   uLength);
-			break;
-		case ACTION_MSRREP:
-			break;
-		case ACTION_TPCREQ:
-			return s_bRxTPCReq(pMgmt,
-					   (PWLAN_FRAME_TPCREQ) pAction,
-					   ((PSRxMgmtPacket)pRxPacket)->byRxRate,
-					   (unsigned char)
-					   ((PSRxMgmtPacket)pRxPacket)->uRSSI);
-			break;
-		case ACTION_TPCREP:
-			break;
-		case ACTION_CHSW:
-			pChannelSwitch = (PWLAN_IE_CH_SW) (pAction->abyVars);
-			if ((pChannelSwitch->byElementID == WLAN_EID_CH_SWITCH)
-			    && (pChannelSwitch->len == 3)) {
-				/* valid element id */
-				CARDbChannelSwitch(pMgmt->pAdapter,
-						   pChannelSwitch->byMode,
-						   get_channel_mapping(pMgmt->pAdapter,
-								       pChannelSwitch->byChannel,
-								       pMgmt->eCurrentPHYMode),
-						   pChannelSwitch->byCount);
-			}
-			break;
-		default:
-			DBG_PRT(MSG_LEVEL_DEBUG,
-				KERN_INFO "Unknown Action = %d\n",
-				pAction->byAction);
-			break;
-		}
-	} else {
-		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unknown Category = %d\n",
-			pAction->byCategory);
-		pAction->byCategory |= 0x80;
-
-		return true;
-	}
-	return true;
-}
-
 bool IEEE11hbMSRRepTx(void *pMgmtHandle)
 {
 	PSMgmtObject            pMgmt = (PSMgmtObject) pMgmtHandle;
diff --git a/drivers/staging/vt6655/aes_ccmp.c b/drivers/staging/vt6655/aes_ccmp.c
index 4ccfe06..a25e6cf 100644
--- a/drivers/staging/vt6655/aes_ccmp.c
+++ b/drivers/staging/vt6655/aes_ccmp.c
@@ -35,6 +35,7 @@
 
 #include "device.h"
 #include "80211hdr.h"
+#include "aes_ccmp.h"
 
 /*---------------------  Static Definitions -------------------------*/
 
diff --git a/drivers/staging/vt6655/aes_ccmp.h b/drivers/staging/vt6655/aes_ccmp.h
index cc02e64..fe0c506 100644
--- a/drivers/staging/vt6655/aes_ccmp.h
+++ b/drivers/staging/vt6655/aes_ccmp.h
@@ -32,15 +32,6 @@
 
 #include "ttype.h"
 
-/*---------------------  Export Definitions -------------------------*/
-
-/*---------------------  Export Types  ------------------------------*/
-
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
 bool AESbGenCCMP(unsigned char *pbyRxKey, unsigned char *pbyFrame, unsigned short wFrameSize);
 
 #endif /* __AES_H__ */
diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c
index 490ca96..67bc3b4 100644
--- a/drivers/staging/vt6655/baseband.c
+++ b/drivers/staging/vt6655/baseband.c
@@ -75,7 +75,7 @@
 /*---------------------  Static Variables  --------------------------*/
 
 #define CB_VT3253_INIT_FOR_RFMD 446
-unsigned char byVT3253InitTab_RFMD[CB_VT3253_INIT_FOR_RFMD][2] = {
+static unsigned char byVT3253InitTab_RFMD[CB_VT3253_INIT_FOR_RFMD][2] = {
 	{0x00, 0x30},
 	{0x01, 0x00},
 	{0x02, 0x00},
@@ -525,7 +525,7 @@
 };
 
 #define CB_VT3253B0_INIT_FOR_RFMD 256
-unsigned char byVT3253B0_RFMD[CB_VT3253B0_INIT_FOR_RFMD][2] = {
+static unsigned char byVT3253B0_RFMD[CB_VT3253B0_INIT_FOR_RFMD][2] = {
 	{0x00, 0x31},
 	{0x01, 0x00},
 	{0x02, 0x00},
@@ -786,7 +786,7 @@
 
 #define CB_VT3253B0_AGC_FOR_RFMD2959 195
 /* For RFMD2959 */
-unsigned char byVT3253B0_AGC4_RFMD2959[CB_VT3253B0_AGC_FOR_RFMD2959][2] = {
+static unsigned char byVT3253B0_AGC4_RFMD2959[CB_VT3253B0_AGC_FOR_RFMD2959][2] = {
 	{0xF0, 0x00},
 	{0xF1, 0x3E},
 	{0xF0, 0x80},
@@ -986,7 +986,7 @@
 
 #define CB_VT3253B0_INIT_FOR_AIROHA2230 256
 /* For AIROHA */
-unsigned char byVT3253B0_AIROHA2230[CB_VT3253B0_INIT_FOR_AIROHA2230][2] = {
+static unsigned char byVT3253B0_AIROHA2230[CB_VT3253B0_INIT_FOR_AIROHA2230][2] = {
 	{0x00, 0x31},
 	{0x01, 0x00},
 	{0x02, 0x00},
@@ -1247,7 +1247,7 @@
 
 #define CB_VT3253B0_INIT_FOR_UW2451 256
 /* For UW2451 */
-unsigned char byVT3253B0_UW2451[CB_VT3253B0_INIT_FOR_UW2451][2] = {
+static unsigned char byVT3253B0_UW2451[CB_VT3253B0_INIT_FOR_UW2451][2] = {
 	{0x00, 0x31},
 	{0x01, 0x00},
 	{0x02, 0x00},
@@ -1508,7 +1508,7 @@
 
 #define CB_VT3253B0_AGC 193
 /* For AIROHA */
-unsigned char byVT3253B0_AGC[CB_VT3253B0_AGC][2] = {
+static unsigned char byVT3253B0_AGC[CB_VT3253B0_AGC][2] = {
 	{0xF0, 0x00},
 	{0xF1, 0x00},
 	{0xF0, 0x80},
@@ -1704,7 +1704,7 @@
 	{0xF0, 0x00},
 };
 
-const unsigned short awcFrameTime[MAX_RATE] =
+static const unsigned short awcFrameTime[MAX_RATE] =
 {10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216};
 
 /*---------------------  Static Functions  --------------------------*/
@@ -1987,7 +1987,7 @@
  * Return Value: true if succeeded; false if failed.
  *
  */
-bool BBbReadEmbedded(unsigned long dwIoBase, unsigned char byBBAddr, unsigned char *pbyData)
+bool BBbReadEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char *pbyData)
 {
 	unsigned short ww;
 	unsigned char byValue;
@@ -2029,7 +2029,7 @@
  * Return Value: true if succeeded; false if failed.
  *
  */
-bool BBbWriteEmbedded(unsigned long dwIoBase, unsigned char byBBAddr, unsigned char byData)
+bool BBbWriteEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byData)
 {
 	unsigned short ww;
 	unsigned char byValue;
@@ -2070,7 +2070,7 @@
  * Return Value: true if all TestBits are set; false otherwise.
  *
  */
-bool BBbIsRegBitsOn(unsigned long dwIoBase, unsigned char byBBAddr, unsigned char byTestBits)
+bool BBbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byTestBits)
 {
 	unsigned char byOrgData;
 
@@ -2092,7 +2092,7 @@
  * Return Value: true if all TestBits are clear; false otherwise.
  *
  */
-bool BBbIsRegBitsOff(unsigned long dwIoBase, unsigned char byBBAddr, unsigned char byTestBits)
+bool BBbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byTestBits)
 {
 	unsigned char byOrgData;
 
@@ -2119,7 +2119,7 @@
 {
 	bool bResult = true;
 	int        ii;
-	unsigned long dwIoBase = pDevice->PortOffset;
+	void __iomem *dwIoBase = pDevice->PortOffset;
 	unsigned char byRFType = pDevice->byRFType;
 	unsigned char byLocalID = pDevice->byLocalID;
 
@@ -2285,7 +2285,7 @@
  * Return Value: none
  *
  */
-void BBvReadAllRegs(unsigned long dwIoBase, unsigned char *pbyBBRegs)
+void BBvReadAllRegs(void __iomem *dwIoBase, unsigned char *pbyBBRegs)
 {
 	int  ii;
 	unsigned char byBase = 1;
@@ -2312,7 +2312,7 @@
 void BBvLoopbackOn(PSDevice pDevice)
 {
 	unsigned char byData;
-	unsigned long dwIoBase = pDevice->PortOffset;
+	void __iomem *dwIoBase = pDevice->PortOffset;
 
 	/* CR C9 = 0x00 */
 	BBbReadEmbedded(dwIoBase, 0xC9, &pDevice->byBBCRc9); /* CR201 */
@@ -2365,7 +2365,7 @@
 void BBvLoopbackOff(PSDevice pDevice)
 {
 	unsigned char byData;
-	unsigned long dwIoBase = pDevice->PortOffset;
+	void __iomem *dwIoBase = pDevice->PortOffset;
 
 	BBbWriteEmbedded(dwIoBase, 0xC9, pDevice->byBBCRc9); /* CR201 */
 	BBbWriteEmbedded(dwIoBase, 0x88, pDevice->byBBCR88); /* CR136 */
@@ -2448,7 +2448,7 @@
  *
  */
 void
-BBvSoftwareReset(unsigned long dwIoBase)
+BBvSoftwareReset(void __iomem *dwIoBase)
 {
 	BBbWriteEmbedded(dwIoBase, 0x50, 0x40);
 	BBbWriteEmbedded(dwIoBase, 0x50, 0);
@@ -2469,7 +2469,7 @@
  *
  */
 void
-BBvPowerSaveModeON(unsigned long dwIoBase)
+BBvPowerSaveModeON(void __iomem *dwIoBase)
 {
 	unsigned char byOrgData;
 
@@ -2491,7 +2491,7 @@
  *
  */
 void
-BBvPowerSaveModeOFF(unsigned long dwIoBase)
+BBvPowerSaveModeOFF(void __iomem *dwIoBase)
 {
 	unsigned char byOrgData;
 
@@ -2515,7 +2515,7 @@
  */
 
 void
-BBvSetTxAntennaMode(unsigned long dwIoBase, unsigned char byAntennaMode)
+BBvSetTxAntennaMode(void __iomem *dwIoBase, unsigned char byAntennaMode)
 {
 	unsigned char byBBTxConf;
 
@@ -2548,7 +2548,7 @@
  */
 
 void
-BBvSetRxAntennaMode(unsigned long dwIoBase, unsigned char byAntennaMode)
+BBvSetRxAntennaMode(void __iomem *dwIoBase, unsigned char byAntennaMode)
 {
 	unsigned char byBBRxConf;
 
@@ -2578,14 +2578,14 @@
  *
  */
 void
-BBvSetDeepSleep(unsigned long dwIoBase, unsigned char byLocalID)
+BBvSetDeepSleep(void __iomem *dwIoBase, unsigned char byLocalID)
 {
 	BBbWriteEmbedded(dwIoBase, 0x0C, 0x17); /* CR12 */
 	BBbWriteEmbedded(dwIoBase, 0x0D, 0xB9); /* CR13 */
 }
 
 void
-BBvExitDeepSleep(unsigned long dwIoBase, unsigned char byLocalID)
+BBvExitDeepSleep(void __iomem *dwIoBase, unsigned char byLocalID)
 {
 	BBbWriteEmbedded(dwIoBase, 0x0C, 0x00); /* CR12 */
 	BBbWriteEmbedded(dwIoBase, 0x0D, 0x01); /* CR13 */
diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h
index e31bb76..2466e2f8 100644
--- a/drivers/staging/vt6655/baseband.h
+++ b/drivers/staging/vt6655/baseband.h
@@ -99,26 +99,26 @@
 	unsigned char *pbyPhySgn
 );
 
-bool BBbReadEmbedded(unsigned long dwIoBase, unsigned char byBBAddr, unsigned char *pbyData);
-bool BBbWriteEmbedded(unsigned long dwIoBase, unsigned char byBBAddr, unsigned char byData);
+bool BBbReadEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char *pbyData);
+bool BBbWriteEmbedded(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byData);
 
-void BBvReadAllRegs(unsigned long dwIoBase, unsigned char *pbyBBRegs);
+void BBvReadAllRegs(void __iomem *dwIoBase, unsigned char *pbyBBRegs);
 void BBvLoopbackOn(PSDevice pDevice);
 void BBvLoopbackOff(PSDevice pDevice);
 void BBvSetShortSlotTime(PSDevice pDevice);
-bool BBbIsRegBitsOn(unsigned long dwIoBase, unsigned char byBBAddr, unsigned char byTestBits);
-bool BBbIsRegBitsOff(unsigned long dwIoBase, unsigned char byBBAddr, unsigned char byTestBits);
+bool BBbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byTestBits);
+bool BBbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byBBAddr, unsigned char byTestBits);
 void BBvSetVGAGainOffset(PSDevice pDevice, unsigned char byData);
 
 // VT3253 Baseband
 bool BBbVT3253Init(PSDevice pDevice);
-void BBvSoftwareReset(unsigned long dwIoBase);
-void BBvPowerSaveModeON(unsigned long dwIoBase);
-void BBvPowerSaveModeOFF(unsigned long dwIoBase);
-void BBvSetTxAntennaMode(unsigned long dwIoBase, unsigned char byAntennaMode);
-void BBvSetRxAntennaMode(unsigned long dwIoBase, unsigned char byAntennaMode);
-void BBvSetDeepSleep(unsigned long dwIoBase, unsigned char byLocalID);
-void BBvExitDeepSleep(unsigned long dwIoBase, unsigned char byLocalID);
+void BBvSoftwareReset(void __iomem *dwIoBase);
+void BBvPowerSaveModeON(void __iomem *dwIoBase);
+void BBvPowerSaveModeOFF(void __iomem *dwIoBase);
+void BBvSetTxAntennaMode(void __iomem *dwIoBase, unsigned char byAntennaMode);
+void BBvSetRxAntennaMode(void __iomem *dwIoBase, unsigned char byAntennaMode);
+void BBvSetDeepSleep(void __iomem *dwIoBase, unsigned char byLocalID);
+void BBvExitDeepSleep(void __iomem *dwIoBase, unsigned char byLocalID);
 
 // timer for antenna diversity
 
diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c
index 59679cd..eb3474d 100644
--- a/drivers/staging/vt6655/bssdb.c
+++ b/drivers/staging/vt6655/bssdb.c
@@ -65,14 +65,14 @@
 /*---------------------  Static Variables  --------------------------*/
 static int msglevel = MSG_LEVEL_INFO;
 
-const unsigned short awHWRetry0[5][5] = {
+static const unsigned short awHWRetry0[5][5] = {
 	{RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M},
 	{RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M},
 	{RATE_36M, RATE_36M, RATE_24M, RATE_18M, RATE_18M},
 	{RATE_48M, RATE_48M, RATE_36M, RATE_24M, RATE_24M},
 	{RATE_54M, RATE_54M, RATE_48M, RATE_36M, RATE_36M}
 };
-const unsigned short awHWRetry1[5][5] = {
+static const unsigned short awHWRetry1[5][5] = {
 	{RATE_18M, RATE_18M, RATE_12M, RATE_6M, RATE_6M},
 	{RATE_24M, RATE_24M, RATE_18M, RATE_6M, RATE_6M},
 	{RATE_36M, RATE_36M, RATE_24M, RATE_12M, RATE_12M},
diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c
index e21abd8..e29dcd8 100644
--- a/drivers/staging/vt6655/card.c
+++ b/drivers/staging/vt6655/card.c
@@ -87,7 +87,7 @@
 
 /*---------------------  Static Variables  --------------------------*/
 
-const unsigned short cwRXBCNTSFOff[MAX_RATE] =
+static const unsigned short cwRXBCNTSFOff[MAX_RATE] =
 {17, 17, 17, 17, 34, 23, 17, 11, 8, 5, 4, 3};
 
 /*---------------------  Static Functions  --------------------------*/
@@ -351,6 +351,7 @@
 bool CARDbIsShortPreamble(void *pDeviceHandler)
 {
 	PSDevice    pDevice = (PSDevice) pDeviceHandler;
+
 	if (pDevice->byPreambleType == 0)
 		return false;
 
@@ -372,6 +373,7 @@
 bool CARDbIsShorSlotTime(void *pDeviceHandler)
 {
 	PSDevice    pDevice = (PSDevice) pDeviceHandler;
+
 	return pDevice->bShortSlotTime;
 }
 
@@ -929,6 +931,7 @@
 {
 	PSDevice    pDevice = (PSDevice) pDeviceHandler;
 	bool bResult = true;
+
 	printk("chester power on\n");
 	if (pDevice->bRadioControlOff == true) {
 		if (pDevice->bHWRadioOff == true) printk("chester bHWRadioOff\n");
@@ -1573,7 +1576,7 @@
  * Return Value: response Control frame rate
  *
  */
-unsigned short CARDwGetCCKControlRate(void *pDeviceHandler, unsigned short wRateIdx)
+static unsigned short CARDwGetCCKControlRate(void *pDeviceHandler, unsigned short wRateIdx)
 {
 	PSDevice    pDevice = (PSDevice) pDeviceHandler;
 	unsigned int ui = (unsigned int) wRateIdx;
@@ -1600,7 +1603,7 @@
  * Return Value: response Control frame rate
  *
  */
-unsigned short CARDwGetOFDMControlRate(void *pDeviceHandler, unsigned short wRateIdx)
+static unsigned short CARDwGetOFDMControlRate(void *pDeviceHandler, unsigned short wRateIdx)
 {
 	PSDevice pDevice = (PSDevice) pDeviceHandler;
 	unsigned int ui = (unsigned int) wRateIdx;
@@ -1888,7 +1891,7 @@
  * Return Value: none
  *
  */
-void CARDvSetLoopbackMode(unsigned long dwIoBase, unsigned short wLoopbackMode)
+void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode)
 {
 	switch (wLoopbackMode) {
 	case CARD_LB_NONE:
@@ -1977,7 +1980,7 @@
  * Return Value: true if success; otherwise false
  *
  */
-bool CARDbGetCurrentTSF(unsigned long dwIoBase, PQWORD pqwCurrTSF)
+bool CARDbGetCurrentTSF(void __iomem *dwIoBase, PQWORD pqwCurrTSF)
 {
 	unsigned short ww;
 	unsigned char byData;
@@ -2050,7 +2053,7 @@
  * Return Value: none
  *
  */
-void CARDvSetFirstNextTBTT(unsigned long dwIoBase, unsigned short wBeaconInterval)
+void CARDvSetFirstNextTBTT(void __iomem *dwIoBase, unsigned short wBeaconInterval)
 {
 	QWORD   qwNextTBTT;
 
@@ -2081,7 +2084,7 @@
  * Return Value: none
  *
  */
-void CARDvUpdateNextTBTT(unsigned long dwIoBase, QWORD qwTSF, unsigned short wBeaconInterval)
+void CARDvUpdateNextTBTT(void __iomem *dwIoBase, QWORD qwTSF, unsigned short wBeaconInterval)
 {
 	qwTSF = CARDqGetNextTBTT(qwTSF, wBeaconInterval);
 	// Set NextTBTT
diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h
index 829be92..2ab46f3 100644
--- a/drivers/staging/vt6655/card.h
+++ b/drivers/staging/vt6655/card.h
@@ -89,11 +89,11 @@
 void CARDvUpdateBasicTopRate(void *pDeviceHandler);
 bool CARDbAddBasicRate(void *pDeviceHandler, unsigned short wRateIdx);
 bool CARDbIsOFDMinBasicRate(void *pDeviceHandler);
-void CARDvSetLoopbackMode(unsigned long dwIoBase, unsigned short wLoopbackMode);
+void CARDvSetLoopbackMode(void __iomem *dwIoBase, unsigned short wLoopbackMode);
 bool CARDbSoftwareReset(void *pDeviceHandler);
-void CARDvSetFirstNextTBTT(unsigned long dwIoBase, unsigned short wBeaconInterval);
-void CARDvUpdateNextTBTT(unsigned long dwIoBase, QWORD qwTSF, unsigned short wBeaconInterval);
-bool CARDbGetCurrentTSF(unsigned long dwIoBase, PQWORD pqwCurrTSF);
+void CARDvSetFirstNextTBTT(void __iomem *dwIoBase, unsigned short wBeaconInterval);
+void CARDvUpdateNextTBTT(void __iomem *dwIoBase, QWORD qwTSF, unsigned short wBeaconInterval);
+bool CARDbGetCurrentTSF(void __iomem *dwIoBase, PQWORD pqwCurrTSF);
 QWORD CARDqGetNextTBTT(QWORD qwTSF, unsigned short wBeaconInterval);
 QWORD CARDqGetTSFOffset(unsigned char byRxRate, QWORD qwTSF1, QWORD qwTSF2);
 bool CARDbSetTxPower(void *pDeviceHandler, unsigned long ulTxPower);
diff --git a/drivers/staging/vt6655/datarate.c b/drivers/staging/vt6655/datarate.c
index f8420d6..83ad74c 100644
--- a/drivers/staging/vt6655/datarate.c
+++ b/drivers/staging/vt6655/datarate.c
@@ -47,11 +47,12 @@
 
 /*---------------------  Static Classes  ----------------------------*/
 
-extern unsigned short TxRate_iwconfig; //2008-5-8 <add> by chester
+extern unsigned short TxRate_iwconfig; /* 2008-5-8 <add> by chester */
 /*---------------------  Static Variables  --------------------------*/
 static int msglevel = MSG_LEVEL_INFO;
-static const unsigned char acbyIERate[MAX_RATE] =
-{0x02, 0x04, 0x0B, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
+static const unsigned char acbyIERate[MAX_RATE] = {
+0x02, 0x04, 0x0B, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C
+};
 
 #define AUTORATE_TXOK_CNT       0x0400
 #define AUTORATE_TXFAIL_CNT     0x0064
@@ -70,7 +71,7 @@
 {
 	unsigned char ii;
 
-	// clear statistic counter for auto_rate
+	/* clear statistic counter for auto_rate */
 	for (ii = 0; ii <= MAX_RATE; ii++) {
 		psNodeDBTable->uTxOk[ii] = 0;
 		psNodeDBTable->uTxFail[ii] = 0;
@@ -102,8 +103,8 @@
 {
 	unsigned char ii;
 
-	//Erase basicRate flag.
-	byRate = byRate & 0x7F;//0111 1111
+	/* Erase basicRate flag. */
+	byRate = byRate & 0x7F;/* 0111 1111 */
 
 	for (ii = 0; ii < MAX_RATE; ii++) {
 		if (acbyIERate[ii] == byRate)
@@ -151,13 +152,14 @@
 {
 	unsigned short ii;
 
-	//Erase basicRate flag.
-	byRate = byRate & 0x7F;//0111 1111
+	/* Erase basicRate flag. */
+	byRate = byRate & 0x7F;/* 0111 1111 */
 
 	for (ii = 0; ii < MAX_RATE; ii++) {
 		if (acbyIERate[ii] == byRate)
 			return ii;
 	}
+
 	return 0;
 }
 
@@ -218,7 +220,7 @@
 	for (ii = 0; ii < uRateLen; ii++) {
 		byRate = (unsigned char)(pItemRates->abyRates[ii]);
 		if (WLAN_MGMT_IS_BASICRATE(byRate) && bUpdateBasicRate)  {
-			// Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate
+			/* Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate */
 			CARDbAddBasicRate((void *)pDevice, wGetRateIdx(byRate));
 			DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ParseMaxRate AddBasicRate: %d\n", wGetRateIdx(byRate));
 		}
@@ -238,9 +240,9 @@
 
 		for (ii = 0; ii < uExtRateLen; ii++) {
 			byRate = (unsigned char)(pItemExtRates->abyRates[ii]);
-			// select highest basic rate
+			/* select highest basic rate */
 			if (WLAN_MGMT_IS_BASICRATE(pItemExtRates->abyRates[ii])) {
-				// Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate
+				/* Add to basic rate set, update pDevice->byTopCCKBasicRate and pDevice->byTopOFDMBasicRate */
 				CARDbAddBasicRate((void *)pDevice, wGetRateIdx(byRate));
 				DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ParseMaxRate AddBasicRate: %d\n", wGetRateIdx(byRate));
 			}
@@ -302,10 +304,9 @@
 	unsigned short wIdxUpRate = 0;
 	unsigned long dwTxDiff = 0;
 
-	if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING) {
-		// Don't do Fallback when scanning Channel
+	if (pDevice->pMgmt->eScanState != WMAC_NO_SCANNING)
+		/* Don't do Fallback when scanning Channel */
 		return;
-	}
 
 	psNodeDBTable->uTimeCount++;
 
@@ -357,11 +358,13 @@
 		    (psNodeDBTable->uTxFail[MAX_RATE] * 4)) {
 			psNodeDBTable->wTxDataRate = wIdxUpRate;
 		}
-	} else { // adhoc, if uTxOk =0 & uTxFail = 0
+	} else {
+		/* adhoc, if uTxOk =0 & uTxFail = 0 */
 		if (psNodeDBTable->uTxFail[MAX_RATE] == 0)
 			psNodeDBTable->wTxDataRate = wIdxUpRate;
 	}
-//2008-5-8 <add> by chester
+
+	/* 2008-5-8 <add> by chester */
 	TxRate_iwconfig = psNodeDBTable->wTxDataRate;
 	s_vResetCounter(psNodeDBTable);
 
diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h
index aab63ca..647e36fe 100644
--- a/drivers/staging/vt6655/device.h
+++ b/drivers/staging/vt6655/device.h
@@ -391,7 +391,7 @@
 
 	CHIP_TYPE                   chip_id;
 
-	unsigned long               PortOffset;
+	void __iomem                *PortOffset;
 	unsigned long dwIsr;
 	u32                         memaddr;
 	u32                         ioaddr;
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index 2327386..5eeb19e 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -98,7 +98,9 @@
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("VIA Networking Solomon-A/B/G Wireless LAN Adapter Driver");
 
+#ifdef	THREAD
 static int mlme_kill;
+#endif
 
 #define DEVICE_PARAM(N, D)
 
@@ -260,7 +262,7 @@
 	{0, NULL}
 };
 
-const struct pci_device_id vt6655_pci_id_table[] = {
+static const struct pci_device_id vt6655_pci_id_table[] = {
 	{ PCI_VDEVICE(VIA, 0x3253), (kernel_ulong_t)chip_info_table},
 	{ 0, }
 };
@@ -285,7 +287,7 @@
 static int device_notify_reboot(struct notifier_block *, unsigned long event, void *ptr);
 static int viawget_suspend(struct pci_dev *pcid, pm_message_t state);
 static int viawget_resume(struct pci_dev *pcid);
-struct notifier_block device_notifier = {
+static struct notifier_block device_notifier = {
 	.notifier_call = device_notify_reboot,
 	.next = NULL,
 	.priority = 0,
@@ -891,9 +893,9 @@
 
 #endif
 
-	pDevice->PortOffset = (unsigned long)ioremap(pDevice->memaddr & PCI_BASE_ADDRESS_MEM_MASK, pDevice->io_size);
+	pDevice->PortOffset = ioremap(pDevice->memaddr & PCI_BASE_ADDRESS_MEM_MASK, pDevice->io_size);
 
-	if (pDevice->PortOffset == 0) {
+	if (pDevice->PortOffset == NULL) {
 		printk(KERN_ERR DEVICE_NAME ": Failed to IO remapping ..\n");
 		device_free_info(pDevice);
 		return -ENODEV;
@@ -1079,7 +1081,7 @@
 		unregister_netdev(dev);
 
 	if (pDevice->PortOffset)
-		iounmap((void *)pDevice->PortOffset);
+		iounmap(pDevice->PortOffset);
 
 	if (pDevice->pcid)
 		pci_release_regions(pDevice->pcid);
@@ -1612,7 +1614,8 @@
 //PLICE_DEBUG<-
 
 //PLICE_DEBUG ->
-int MlmeThread(
+#ifdef	THREAD
+static int MlmeThread(
 	void *Context)
 {
 	PSDevice	pDevice =  (PSDevice) Context;
@@ -1635,6 +1638,7 @@
 
 	return 0;
 }
+#endif
 
 static int  device_open(struct net_device *dev) {
 	PSDevice pDevice = (PSDevice)netdev_priv(dev);
diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c
index 09a8bf5..f5bc4a2 100644
--- a/drivers/staging/vt6655/key.c
+++ b/drivers/staging/vt6655/key.c
@@ -58,7 +58,7 @@
 
 /*---------------------  Static Functions  --------------------------*/
 static void
-s_vCheckKeyTableValid(PSKeyManagement pTable, unsigned long dwIoBase)
+s_vCheckKeyTableValid(PSKeyManagement pTable, void __iomem *dwIoBase)
 {
 	int i;
 
@@ -91,7 +91,7 @@
  * Return Value: none
  *
  */
-void KeyvInitTable(PSKeyManagement pTable, unsigned long dwIoBase)
+void KeyvInitTable(PSKeyManagement pTable, void __iomem *dwIoBase)
 {
 	int i;
 	int jj;
@@ -187,7 +187,7 @@
 	PQWORD          pKeyRSC,
 	unsigned char *pbyKey,
 	unsigned char byKeyDecMode,
-	unsigned long dwIoBase,
+	void __iomem *dwIoBase,
 	unsigned char byLocalID
 )
 {
@@ -351,7 +351,7 @@
 	PSKeyManagement pTable,
 	unsigned char *pbyBSSID,
 	unsigned long dwKeyIndex,
-	unsigned long dwIoBase
+	void __iomem *dwIoBase
 )
 {
 	int  i;
@@ -418,7 +418,7 @@
 bool KeybRemoveAllKey(
 	PSKeyManagement pTable,
 	unsigned char *pbyBSSID,
-	unsigned long dwIoBase
+	void __iomem *dwIoBase
 )
 {
 	int i, u;
@@ -453,7 +453,7 @@
 void KeyvRemoveWEPKey(
 	PSKeyManagement pTable,
 	unsigned long dwKeyIndex,
-	unsigned long dwIoBase
+	void __iomem *dwIoBase
 )
 {
 	if ((dwKeyIndex & 0x000000FF) < MAX_GROUP_KEY) {
@@ -473,7 +473,7 @@
 
 void KeyvRemoveAllWEPKey(
 	PSKeyManagement pTable,
-	unsigned long dwIoBase
+	void __iomem *dwIoBase
 )
 {
 	int i;
@@ -610,7 +610,7 @@
 	PQWORD          pKeyRSC,
 	unsigned char *pbyKey,
 	unsigned char byKeyDecMode,
-	unsigned long dwIoBase,
+	void __iomem *dwIoBase,
 	unsigned char byLocalID
 )
 {
@@ -716,7 +716,7 @@
 	PQWORD          pKeyRSC,
 	unsigned char *pbyKey,
 	unsigned char byKeyDecMode,
-	unsigned long dwIoBase,
+	void __iomem *dwIoBase,
 	unsigned char byLocalID
 )
 {
diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h
index 4b8b4b6..4eee192 100644
--- a/drivers/staging/vt6655/key.h
+++ b/drivers/staging/vt6655/key.h
@@ -97,7 +97,7 @@
 
 /*---------------------  Export Functions  --------------------------*/
 
-void KeyvInitTable(PSKeyManagement pTable, unsigned long dwIoBase);
+void KeyvInitTable(PSKeyManagement pTable, void __iomem *dwIoBase);
 
 bool KeybGetKey(
 	PSKeyManagement pTable,
@@ -114,7 +114,7 @@
 	PQWORD          pKeyRSC,
 	unsigned char *pbyKey,
 	unsigned char byKeyDecMode,
-	unsigned long dwIoBase,
+	void __iomem *dwIoBase,
 	unsigned char byLocalID
 );
 
@@ -125,7 +125,7 @@
 	PQWORD          pKeyRSC,
 	unsigned char *pbyKey,
 	unsigned char byKeyDecMode,
-	unsigned long dwIoBase,
+	void __iomem *dwIoBase,
 	unsigned char byLocalID
 );
 
@@ -133,7 +133,7 @@
 	PSKeyManagement pTable,
 	unsigned char *pbyBSSID,
 	unsigned long dwKeyIndex,
-	unsigned long dwIoBase
+	void __iomem *dwIoBase
 );
 
 bool KeybGetTransmitKey(
@@ -151,18 +151,18 @@
 bool KeybRemoveAllKey(
 	PSKeyManagement pTable,
 	unsigned char *pbyBSSID,
-	unsigned long dwIoBase
+	void __iomem *dwIoBase
 );
 
 void KeyvRemoveWEPKey(
 	PSKeyManagement pTable,
 	unsigned long dwKeyIndex,
-	unsigned long dwIoBase
+	void __iomem *dwIoBase
 );
 
 void KeyvRemoveAllWEPKey(
 	PSKeyManagement pTable,
-	unsigned long dwIoBase
+	void __iomem *dwIoBase
 );
 
 bool KeybSetAllGroupKey(
@@ -172,7 +172,7 @@
 	PQWORD          pKeyRSC,
 	unsigned char *pbyKey,
 	unsigned char byKeyDecMode,
-	unsigned long dwIoBase,
+	void __iomem *dwIoBase,
 	unsigned char byLocalID
 );
 
diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c
index af6876a..9bbc873 100644
--- a/drivers/staging/vt6655/mac.c
+++ b/drivers/staging/vt6655/mac.c
@@ -98,7 +98,7 @@
  * Return Value: none
  *
  */
-void MACvReadAllRegs(unsigned long dwIoBase, unsigned char *pbyMacRegs)
+void MACvReadAllRegs(void __iomem *dwIoBase, unsigned char *pbyMacRegs)
 {
 	int ii;
 
@@ -134,7 +134,7 @@
  * Return Value: true if all test bits On; otherwise false
  *
  */
-bool MACbIsRegBitsOn(unsigned long dwIoBase, unsigned char byRegOfs, unsigned char byTestBits)
+bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits)
 {
 	unsigned char byData;
 
@@ -157,7 +157,7 @@
  * Return Value: true if all test bits Off; otherwise false
  *
  */
-bool MACbIsRegBitsOff(unsigned long dwIoBase, unsigned char byRegOfs, unsigned char byTestBits)
+bool MACbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits)
 {
 	unsigned char byData;
 
@@ -178,7 +178,7 @@
  * Return Value: true if interrupt is disable; otherwise false
  *
  */
-bool MACbIsIntDisable(unsigned long dwIoBase)
+bool MACbIsIntDisable(void __iomem *dwIoBase)
 {
 	unsigned long dwData;
 
@@ -203,7 +203,7 @@
  * Return Value: Mask Value read
  *
  */
-unsigned char MACbyReadMultiAddr(unsigned long dwIoBase, unsigned int uByteIdx)
+unsigned char MACbyReadMultiAddr(void __iomem *dwIoBase, unsigned int uByteIdx)
 {
 	unsigned char byData;
 
@@ -228,7 +228,7 @@
  * Return Value: none
  *
  */
-void MACvWriteMultiAddr(unsigned long dwIoBase, unsigned int uByteIdx, unsigned char byData)
+void MACvWriteMultiAddr(void __iomem *dwIoBase, unsigned int uByteIdx, unsigned char byData)
 {
 	MACvSelectPage1(dwIoBase);
 	VNSvOutPortB(dwIoBase + MAC_REG_MAR0 + uByteIdx, byData);
@@ -249,7 +249,7 @@
  * Return Value: none
  *
  */
-void MACvSetMultiAddrByHash(unsigned long dwIoBase, unsigned char byHashIdx)
+void MACvSetMultiAddrByHash(void __iomem *dwIoBase, unsigned char byHashIdx)
 {
 	unsigned int uByteIdx;
 	unsigned char byBitMask;
@@ -280,7 +280,7 @@
  * Return Value: none
  *
  */
-void MACvResetMultiAddrByHash(unsigned long dwIoBase, unsigned char byHashIdx)
+void MACvResetMultiAddrByHash(void __iomem *dwIoBase, unsigned char byHashIdx)
 {
 	unsigned int uByteIdx;
 	unsigned char byBitMask;
@@ -311,7 +311,7 @@
  * Return Value: none
  *
  */
-void MACvSetRxThreshold(unsigned long dwIoBase, unsigned char byThreshold)
+void MACvSetRxThreshold(void __iomem *dwIoBase, unsigned char byThreshold)
 {
 	unsigned char byOrgValue;
 
@@ -336,7 +336,7 @@
  * Return Value: none
  *
  */
-void MACvGetRxThreshold(unsigned long dwIoBase, unsigned char *pbyThreshold)
+void MACvGetRxThreshold(void __iomem *dwIoBase, unsigned char *pbyThreshold)
 {
 	// get FCR0
 	VNSvInPortB(dwIoBase + MAC_REG_FCR0, pbyThreshold);
@@ -357,7 +357,7 @@
  * Return Value: none
  *
  */
-void MACvSetTxThreshold(unsigned long dwIoBase, unsigned char byThreshold)
+void MACvSetTxThreshold(void __iomem *dwIoBase, unsigned char byThreshold)
 {
 	unsigned char byOrgValue;
 
@@ -382,7 +382,7 @@
  * Return Value: none
  *
  */
-void MACvGetTxThreshold(unsigned long dwIoBase, unsigned char *pbyThreshold)
+void MACvGetTxThreshold(void __iomem *dwIoBase, unsigned char *pbyThreshold)
 {
 	// get FCR0
 	VNSvInPortB(dwIoBase + MAC_REG_FCR0, pbyThreshold);
@@ -403,7 +403,7 @@
  * Return Value: none
  *
  */
-void MACvSetDmaLength(unsigned long dwIoBase, unsigned char byDmaLength)
+void MACvSetDmaLength(void __iomem *dwIoBase, unsigned char byDmaLength)
 {
 	unsigned char byOrgValue;
 
@@ -428,7 +428,7 @@
  * Return Value: none
  *
  */
-void MACvGetDmaLength(unsigned long dwIoBase, unsigned char *pbyDmaLength)
+void MACvGetDmaLength(void __iomem *dwIoBase, unsigned char *pbyDmaLength)
 {
 	// get FCR0
 	VNSvInPortB(dwIoBase + MAC_REG_FCR0, pbyDmaLength);
@@ -449,7 +449,7 @@
  * Return Value: none
  *
  */
-void MACvSetShortRetryLimit(unsigned long dwIoBase, unsigned char byRetryLimit)
+void MACvSetShortRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit)
 {
 	// set SRT
 	VNSvOutPortB(dwIoBase + MAC_REG_SRT, byRetryLimit);
@@ -468,7 +468,7 @@
  * Return Value: none
  *
  */
-void MACvGetShortRetryLimit(unsigned long dwIoBase, unsigned char *pbyRetryLimit)
+void MACvGetShortRetryLimit(void __iomem *dwIoBase, unsigned char *pbyRetryLimit)
 {
 	// get SRT
 	VNSvInPortB(dwIoBase + MAC_REG_SRT, pbyRetryLimit);
@@ -488,7 +488,7 @@
  * Return Value: none
  *
  */
-void MACvSetLongRetryLimit(unsigned long dwIoBase, unsigned char byRetryLimit)
+void MACvSetLongRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit)
 {
 	// set LRT
 	VNSvOutPortB(dwIoBase + MAC_REG_LRT, byRetryLimit);
@@ -507,7 +507,7 @@
  * Return Value: none
  *
  */
-void MACvGetLongRetryLimit(unsigned long dwIoBase, unsigned char *pbyRetryLimit)
+void MACvGetLongRetryLimit(void __iomem *dwIoBase, unsigned char *pbyRetryLimit)
 {
 	// get LRT
 	VNSvInPortB(dwIoBase + MAC_REG_LRT, pbyRetryLimit);
@@ -527,7 +527,7 @@
  * Return Value: none
  *
  */
-void MACvSetLoopbackMode(unsigned long dwIoBase, unsigned char byLoopbackMode)
+void MACvSetLoopbackMode(void __iomem *dwIoBase, unsigned char byLoopbackMode)
 {
 	unsigned char byOrgValue;
 
@@ -553,7 +553,7 @@
  * Return Value: true if in Loopback mode; otherwise false
  *
  */
-bool MACbIsInLoopbackMode(unsigned long dwIoBase)
+bool MACbIsInLoopbackMode(void __iomem *dwIoBase)
 {
 	unsigned char byOrgValue;
 
@@ -577,7 +577,7 @@
  * Return Value: none
  *
  */
-void MACvSetPacketFilter(unsigned long dwIoBase, unsigned short wFilterType)
+void MACvSetPacketFilter(void __iomem *dwIoBase, unsigned short wFilterType)
 {
 	unsigned char byOldRCR;
 	unsigned char byNewRCR = 0;
@@ -636,7 +636,7 @@
  * Return Value: none
  *
  */
-void MACvSaveContext(unsigned long dwIoBase, unsigned char *pbyCxtBuf)
+void MACvSaveContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf)
 {
 	int         ii;
 
@@ -667,7 +667,7 @@
  * Return Value: none
  *
  */
-void MACvRestoreContext(unsigned long dwIoBase, unsigned char *pbyCxtBuf)
+void MACvRestoreContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf)
 {
 	int         ii;
 
@@ -716,7 +716,7 @@
  * Return Value: true if all values are the same; otherwise false
  *
  */
-bool MACbCompareContext(unsigned long dwIoBase, unsigned char *pbyCxtBuf)
+bool MACbCompareContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf)
 {
 	unsigned long dwData;
 
@@ -756,7 +756,7 @@
  * Return Value: true if Reset Success; otherwise false
  *
  */
-bool MACbSoftwareReset(unsigned long dwIoBase)
+bool MACbSoftwareReset(void __iomem *dwIoBase)
 {
 	unsigned char byData;
 	unsigned short ww;
@@ -787,7 +787,7 @@
  * Return Value: true if success; otherwise false
  *
  */
-bool MACbSafeSoftwareReset(unsigned long dwIoBase)
+bool MACbSafeSoftwareReset(void __iomem *dwIoBase)
 {
 	unsigned char abyTmpRegData[MAC_MAX_CONTEXT_SIZE_PAGE0+MAC_MAX_CONTEXT_SIZE_PAGE1];
 	bool bRetVal;
@@ -819,7 +819,7 @@
  * Return Value: true if success; otherwise false
  *
  */
-bool MACbSafeRxOff(unsigned long dwIoBase)
+bool MACbSafeRxOff(void __iomem *dwIoBase)
 {
 	unsigned short ww;
 	unsigned long dwData;
@@ -880,7 +880,7 @@
  * Return Value: true if success; otherwise false
  *
  */
-bool MACbSafeTxOff(unsigned long dwIoBase)
+bool MACbSafeTxOff(void __iomem *dwIoBase)
 {
 	unsigned short ww;
 	unsigned long dwData;
@@ -943,7 +943,7 @@
  * Return Value: true if success; otherwise false
  *
  */
-bool MACbSafeStop(unsigned long dwIoBase)
+bool MACbSafeStop(void __iomem *dwIoBase)
 {
 	MACvRegBitsOff(dwIoBase, MAC_REG_TCR, TCR_AUTOBCNTX);
 
@@ -978,7 +978,7 @@
  * Return Value: true if success; otherwise false
  *
  */
-bool MACbShutdown(unsigned long dwIoBase)
+bool MACbShutdown(void __iomem *dwIoBase)
 {
 	// disable MAC IMR
 	MACvIntDisable(dwIoBase);
@@ -1005,7 +1005,7 @@
  * Return Value: none
  *
  */
-void MACvInitialize(unsigned long dwIoBase)
+void MACvInitialize(void __iomem *dwIoBase)
 {
 	// clear sticky bits
 	MACvClearStckDS(dwIoBase);
@@ -1041,7 +1041,7 @@
  * Return Value: none
  *
  */
-void MACvSetCurrRx0DescAddr(unsigned long dwIoBase, unsigned long dwCurrDescAddr)
+void MACvSetCurrRx0DescAddr(void __iomem *dwIoBase, unsigned long dwCurrDescAddr)
 {
 	unsigned short ww;
 	unsigned char byData;
@@ -1079,7 +1079,7 @@
  * Return Value: none
  *
  */
-void MACvSetCurrRx1DescAddr(unsigned long dwIoBase, unsigned long dwCurrDescAddr)
+void MACvSetCurrRx1DescAddr(void __iomem *dwIoBase, unsigned long dwCurrDescAddr)
 {
 	unsigned short ww;
 	unsigned char byData;
@@ -1117,7 +1117,7 @@
  * Return Value: none
  *
  */
-void MACvSetCurrTx0DescAddrEx(unsigned long dwIoBase, unsigned long dwCurrDescAddr)
+void MACvSetCurrTx0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr)
 {
 	unsigned short ww;
 	unsigned char byData;
@@ -1155,7 +1155,7 @@
  *
  */
 //TxDMA1 = AC0DMA
-void MACvSetCurrAC0DescAddrEx(unsigned long dwIoBase, unsigned long dwCurrDescAddr)
+void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr)
 {
 	unsigned short ww;
 	unsigned char byData;
@@ -1179,7 +1179,7 @@
 		VNSvOutPortB(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_RUN);
 }
 
-void MACvSetCurrTXDescAddr(int iTxType, unsigned long dwIoBase, unsigned long dwCurrDescAddr)
+void MACvSetCurrTXDescAddr(int iTxType, void __iomem *dwIoBase, unsigned long dwCurrDescAddr)
 {
 	if (iTxType == TYPE_AC0DMA)
 		MACvSetCurrAC0DescAddrEx(dwIoBase, dwCurrDescAddr);
@@ -1201,7 +1201,7 @@
  * Return Value: none
  *
  */
-void MACvTimer0MicroSDelay(unsigned long dwIoBase, unsigned int uDelay)
+void MACvTimer0MicroSDelay(void __iomem *dwIoBase, unsigned int uDelay)
 {
 	unsigned char byValue;
 	unsigned int uu, ii;
@@ -1236,7 +1236,7 @@
  * Return Value: none
  *
  */
-void MACvOneShotTimer0MicroSec(unsigned long dwIoBase, unsigned int uDelayTime)
+void MACvOneShotTimer0MicroSec(void __iomem *dwIoBase, unsigned int uDelayTime)
 {
 	VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0);
 	VNSvOutPortD(dwIoBase + MAC_REG_TMDATA0, uDelayTime);
@@ -1257,14 +1257,14 @@
  * Return Value: none
  *
  */
-void MACvOneShotTimer1MicroSec(unsigned long dwIoBase, unsigned int uDelayTime)
+void MACvOneShotTimer1MicroSec(void __iomem *dwIoBase, unsigned int uDelayTime)
 {
 	VNSvOutPortB(dwIoBase + MAC_REG_TMCTL1, 0);
 	VNSvOutPortD(dwIoBase + MAC_REG_TMDATA1, uDelayTime);
 	VNSvOutPortB(dwIoBase + MAC_REG_TMCTL1, (TMCTL_TMD | TMCTL_TE));
 }
 
-void MACvSetMISCFifo(unsigned long dwIoBase, unsigned short wOffset, unsigned long dwData)
+void MACvSetMISCFifo(void __iomem *dwIoBase, unsigned short wOffset, unsigned long dwData)
 {
 	if (wOffset > 273)
 		return;
@@ -1273,7 +1273,7 @@
 	VNSvOutPortW(dwIoBase + MAC_REG_MISCFFCTL, MISCFFCTL_WRITE);
 }
 
-bool MACbTxDMAOff(unsigned long dwIoBase, unsigned int idx)
+bool MACbTxDMAOff(void __iomem *dwIoBase, unsigned int idx)
 {
 	unsigned char byData;
 	unsigned int ww = 0;
@@ -1301,7 +1301,7 @@
 	return true;
 }
 
-void MACvClearBusSusInd(unsigned long dwIoBase)
+void MACvClearBusSusInd(void __iomem *dwIoBase)
 {
 	unsigned long dwOrgValue;
 	unsigned int ww;
@@ -1323,7 +1323,7 @@
 	}
 }
 
-void MACvEnableBusSusEn(unsigned long dwIoBase)
+void MACvEnableBusSusEn(void __iomem *dwIoBase)
 {
 	unsigned char byOrgValue;
 	unsigned long dwOrgValue;
@@ -1345,7 +1345,7 @@
 	}
 }
 
-bool MACbFlushSYNCFifo(unsigned long dwIoBase)
+bool MACbFlushSYNCFifo(void __iomem *dwIoBase)
 {
 	unsigned char byOrgValue;
 	unsigned int ww;
@@ -1369,7 +1369,7 @@
 	return true;
 }
 
-bool MACbPSWakeup(unsigned long dwIoBase)
+bool MACbPSWakeup(void __iomem *dwIoBase)
 {
 	unsigned char byOrgValue;
 	unsigned int ww;
@@ -1409,7 +1409,7 @@
  *
  */
 
-void MACvSetKeyEntry(unsigned long dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx,
+void MACvSetKeyEntry(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx,
 		     unsigned int uKeyIdx, unsigned char *pbyAddr, u32 *pdwKey, unsigned char byLocalID)
 {
 	unsigned short wOffset;
@@ -1473,7 +1473,7 @@
  * Return Value: none
  *
  */
-void MACvDisableKeyEntry(unsigned long dwIoBase, unsigned int uEntryIdx)
+void MACvDisableKeyEntry(void __iomem *dwIoBase, unsigned int uEntryIdx)
 {
 	unsigned short wOffset;
 
@@ -1500,7 +1500,7 @@
  *
  */
 
-void MACvSetDefaultKeyEntry(unsigned long dwIoBase, unsigned int uKeyLen,
+void MACvSetDefaultKeyEntry(void __iomem *dwIoBase, unsigned int uKeyLen,
 			    unsigned int uKeyIdx, unsigned long *pdwKey, unsigned char byLocalID)
 {
 	unsigned short wOffset;
@@ -1549,7 +1549,7 @@
  *
  */
 /*
-  void MACvEnableDefaultKey(unsigned long dwIoBase, unsigned char byLocalID)
+  void MACvEnableDefaultKey(void __iomem *dwIoBase, unsigned char byLocalID)
   {
   unsigned short wOffset;
   unsigned long dwData;
@@ -1583,7 +1583,7 @@
  * Return Value: none
  *
  */
-void MACvDisableDefaultKey(unsigned long dwIoBase)
+void MACvDisableDefaultKey(void __iomem *dwIoBase)
 {
 	unsigned short wOffset;
 	unsigned long dwData;
@@ -1612,7 +1612,7 @@
  * Return Value: none
  *
  */
-void MACvSetDefaultTKIPKeyEntry(unsigned long dwIoBase, unsigned int uKeyLen,
+void MACvSetDefaultTKIPKeyEntry(void __iomem *dwIoBase, unsigned int uKeyLen,
 				unsigned int uKeyIdx, unsigned long *pdwKey, unsigned char byLocalID)
 {
 	unsigned short wOffset;
@@ -1665,7 +1665,7 @@
  *
  */
 
-void MACvSetDefaultKeyCtl(unsigned long dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx, unsigned char byLocalID)
+void MACvSetDefaultKeyCtl(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx, unsigned char byLocalID)
 {
 	unsigned short wOffset;
 	unsigned long dwData;
diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h
index 7333b8b..98ade83 100644
--- a/drivers/staging/vt6655/mac.h
+++ b/drivers/staging/vt6655/mac.h
@@ -973,78 +973,78 @@
 /*---------------------  Export Functions  --------------------------*/
 
 extern unsigned short TxRate_iwconfig;//2008-5-8 <add> by chester
-void MACvReadAllRegs(unsigned long dwIoBase, unsigned char *pbyMacRegs);
+void MACvReadAllRegs(void __iomem *dwIoBase, unsigned char *pbyMacRegs);
 
-bool MACbIsRegBitsOn(unsigned long dwIoBase, unsigned char byRegOfs, unsigned char byTestBits);
-bool MACbIsRegBitsOff(unsigned long dwIoBase, unsigned char byRegOfs, unsigned char byTestBits);
+bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits);
+bool MACbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits);
 
-bool MACbIsIntDisable(unsigned long dwIoBase);
+bool MACbIsIntDisable(void __iomem *dwIoBase);
 
-unsigned char MACbyReadMultiAddr(unsigned long dwIoBase, unsigned int uByteIdx);
-void MACvWriteMultiAddr(unsigned long dwIoBase, unsigned int uByteIdx, unsigned char byData);
-void MACvSetMultiAddrByHash(unsigned long dwIoBase, unsigned char byHashIdx);
-void MACvResetMultiAddrByHash(unsigned long dwIoBase, unsigned char byHashIdx);
+unsigned char MACbyReadMultiAddr(void __iomem *dwIoBase, unsigned int uByteIdx);
+void MACvWriteMultiAddr(void __iomem *dwIoBase, unsigned int uByteIdx, unsigned char byData);
+void MACvSetMultiAddrByHash(void __iomem *dwIoBase, unsigned char byHashIdx);
+void MACvResetMultiAddrByHash(void __iomem *dwIoBase, unsigned char byHashIdx);
 
-void MACvSetRxThreshold(unsigned long dwIoBase, unsigned char byThreshold);
-void MACvGetRxThreshold(unsigned long dwIoBase, unsigned char *pbyThreshold);
+void MACvSetRxThreshold(void __iomem *dwIoBase, unsigned char byThreshold);
+void MACvGetRxThreshold(void __iomem *dwIoBase, unsigned char *pbyThreshold);
 
-void MACvSetTxThreshold(unsigned long dwIoBase, unsigned char byThreshold);
-void MACvGetTxThreshold(unsigned long dwIoBase, unsigned char *pbyThreshold);
+void MACvSetTxThreshold(void __iomem *dwIoBase, unsigned char byThreshold);
+void MACvGetTxThreshold(void __iomem *dwIoBase, unsigned char *pbyThreshold);
 
-void MACvSetDmaLength(unsigned long dwIoBase, unsigned char byDmaLength);
-void MACvGetDmaLength(unsigned long dwIoBase, unsigned char *pbyDmaLength);
+void MACvSetDmaLength(void __iomem *dwIoBase, unsigned char byDmaLength);
+void MACvGetDmaLength(void __iomem *dwIoBase, unsigned char *pbyDmaLength);
 
-void MACvSetShortRetryLimit(unsigned long dwIoBase, unsigned char byRetryLimit);
-void MACvGetShortRetryLimit(unsigned long dwIoBase, unsigned char *pbyRetryLimit);
+void MACvSetShortRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit);
+void MACvGetShortRetryLimit(void __iomem *dwIoBase, unsigned char *pbyRetryLimit);
 
-void MACvSetLongRetryLimit(unsigned long dwIoBase, unsigned char byRetryLimit);
-void MACvGetLongRetryLimit(unsigned long dwIoBase, unsigned char *pbyRetryLimit);
+void MACvSetLongRetryLimit(void __iomem *dwIoBase, unsigned char byRetryLimit);
+void MACvGetLongRetryLimit(void __iomem *dwIoBase, unsigned char *pbyRetryLimit);
 
-void MACvSetLoopbackMode(unsigned long dwIoBase, unsigned char byLoopbackMode);
-bool MACbIsInLoopbackMode(unsigned long dwIoBase);
+void MACvSetLoopbackMode(void __iomem *dwIoBase, unsigned char byLoopbackMode);
+bool MACbIsInLoopbackMode(void __iomem *dwIoBase);
 
-void MACvSetPacketFilter(unsigned long dwIoBase, unsigned short wFilterType);
+void MACvSetPacketFilter(void __iomem *dwIoBase, unsigned short wFilterType);
 
-void MACvSaveContext(unsigned long dwIoBase, unsigned char *pbyCxtBuf);
-void MACvRestoreContext(unsigned long dwIoBase, unsigned char *pbyCxtBuf);
-bool MACbCompareContext(unsigned long dwIoBase, unsigned char *pbyCxtBuf);
+void MACvSaveContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf);
+void MACvRestoreContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf);
+bool MACbCompareContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf);
 
-bool MACbSoftwareReset(unsigned long dwIoBase);
-bool MACbSafeSoftwareReset(unsigned long dwIoBase);
-bool MACbSafeRxOff(unsigned long dwIoBase);
-bool MACbSafeTxOff(unsigned long dwIoBase);
-bool MACbSafeStop(unsigned long dwIoBase);
-bool MACbShutdown(unsigned long dwIoBase);
-void MACvInitialize(unsigned long dwIoBase);
-void MACvSetCurrRx0DescAddr(unsigned long dwIoBase, unsigned long dwCurrDescAddr);
-void MACvSetCurrRx1DescAddr(unsigned long dwIoBase, unsigned long dwCurrDescAddr);
-void MACvSetCurrTXDescAddr(int iTxType, unsigned long dwIoBase, unsigned long dwCurrDescAddr);
-void MACvSetCurrTx0DescAddrEx(unsigned long dwIoBase, unsigned long dwCurrDescAddr);
-void MACvSetCurrAC0DescAddrEx(unsigned long dwIoBase, unsigned long dwCurrDescAddr);
-void MACvSetCurrSyncDescAddrEx(unsigned long dwIoBase, unsigned long dwCurrDescAddr);
-void MACvSetCurrATIMDescAddrEx(unsigned long dwIoBase, unsigned long dwCurrDescAddr);
-void MACvTimer0MicroSDelay(unsigned long dwIoBase, unsigned int uDelay);
-void MACvOneShotTimer0MicroSec(unsigned long dwIoBase, unsigned int uDelayTime);
-void MACvOneShotTimer1MicroSec(unsigned long dwIoBase, unsigned int uDelayTime);
+bool MACbSoftwareReset(void __iomem *dwIoBase);
+bool MACbSafeSoftwareReset(void __iomem *dwIoBase);
+bool MACbSafeRxOff(void __iomem *dwIoBase);
+bool MACbSafeTxOff(void __iomem *dwIoBase);
+bool MACbSafeStop(void __iomem *dwIoBase);
+bool MACbShutdown(void __iomem *dwIoBase);
+void MACvInitialize(void __iomem *dwIoBase);
+void MACvSetCurrRx0DescAddr(void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
+void MACvSetCurrRx1DescAddr(void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
+void MACvSetCurrTXDescAddr(int iTxType, void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
+void MACvSetCurrTx0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
+void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
+void MACvSetCurrSyncDescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
+void MACvSetCurrATIMDescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr);
+void MACvTimer0MicroSDelay(void __iomem *dwIoBase, unsigned int uDelay);
+void MACvOneShotTimer0MicroSec(void __iomem *dwIoBase, unsigned int uDelayTime);
+void MACvOneShotTimer1MicroSec(void __iomem *dwIoBase, unsigned int uDelayTime);
 
-void MACvSetMISCFifo(unsigned long dwIoBase, unsigned short wOffset, unsigned long dwData);
+void MACvSetMISCFifo(void __iomem *dwIoBase, unsigned short wOffset, unsigned long dwData);
 
-bool MACbTxDMAOff(unsigned long dwIoBase, unsigned int idx);
+bool MACbTxDMAOff(void __iomem *dwIoBase, unsigned int idx);
 
-void MACvClearBusSusInd(unsigned long dwIoBase);
-void MACvEnableBusSusEn(unsigned long dwIoBase);
+void MACvClearBusSusInd(void __iomem *dwIoBase);
+void MACvEnableBusSusEn(void __iomem *dwIoBase);
 
-bool MACbFlushSYNCFifo(unsigned long dwIoBase);
-bool MACbPSWakeup(unsigned long dwIoBase);
+bool MACbFlushSYNCFifo(void __iomem *dwIoBase);
+bool MACbPSWakeup(void __iomem *dwIoBase);
 
-void MACvSetKeyEntry(unsigned long dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx,
+void MACvSetKeyEntry(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx,
 		     unsigned int uKeyIdx, unsigned char *pbyAddr, u32 *pdwKey, unsigned char byLocalID);
-void MACvDisableKeyEntry(unsigned long dwIoBase, unsigned int uEntryIdx);
-void MACvSetDefaultKeyEntry(unsigned long dwIoBase, unsigned int uKeyLen,
+void MACvDisableKeyEntry(void __iomem *dwIoBase, unsigned int uEntryIdx);
+void MACvSetDefaultKeyEntry(void __iomem *dwIoBase, unsigned int uKeyLen,
 			    unsigned int uKeyIdx, unsigned long *pdwKey, unsigned char byLocalID);
-void MACvDisableDefaultKey(unsigned long dwIoBase);
-void MACvSetDefaultTKIPKeyEntry(unsigned long dwIoBase, unsigned int uKeyLen,
+void MACvDisableDefaultKey(void __iomem *dwIoBase);
+void MACvSetDefaultTKIPKeyEntry(void __iomem *dwIoBase, unsigned int uKeyLen,
 				unsigned int uKeyIdx, unsigned long *pdwKey, unsigned char byLocalID);
-void MACvSetDefaultKeyCtl(unsigned long dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx, unsigned char byLocalID);
+void MACvSetDefaultKeyCtl(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx, unsigned char byLocalID);
 
 #endif // __MAC_H__
diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c
index 99c89a1..33913e5 100644
--- a/drivers/staging/vt6655/rf.c
+++ b/drivers/staging/vt6655/rf.c
@@ -424,7 +424,7 @@
  * Return Value: true if succeeded; false if failed.
  *
  */
-static bool s_bAL7230Init(unsigned long dwIoBase)
+static bool s_bAL7230Init(void __iomem *dwIoBase)
 {
 	int     ii;
 	bool bResult;
@@ -467,7 +467,7 @@
 }
 
 // Need to Pull PLLON low when writing channel registers through 3-wire interface
-static bool s_bAL7230SelectChannel(unsigned long dwIoBase, unsigned char byChannel)
+static bool s_bAL7230SelectChannel(void __iomem *dwIoBase, unsigned char byChannel)
 {
 	bool bResult;
 
@@ -567,7 +567,7 @@
  * Return Value: true if succeeded; false if failed.
  *
  */
-bool IFRFbWriteEmbedded(unsigned long dwIoBase, unsigned long dwData)
+bool IFRFbWriteEmbedded(void __iomem *dwIoBase, unsigned long dwData)
 {
 	unsigned short ww;
 	unsigned long dwValue;
@@ -626,7 +626,7 @@
  * Return Value: true if succeeded; false if failed.
  *
  */
-static bool RFbAL2230Init(unsigned long dwIoBase)
+static bool RFbAL2230Init(void __iomem *dwIoBase)
 {
 	int     ii;
 	bool bResult;
@@ -673,7 +673,7 @@
 	return bResult;
 }
 
-static bool RFbAL2230SelectChannel(unsigned long dwIoBase, unsigned char byChannel)
+static bool RFbAL2230SelectChannel(void __iomem *dwIoBase, unsigned char byChannel)
 {
 	bool bResult;
 
@@ -783,7 +783,7 @@
  * Return Value: true if succeeded; false if failed.
  *
  */
-bool RFbSelectChannel(unsigned long dwIoBase, unsigned char byRFType, unsigned char byChannel)
+bool RFbSelectChannel(void __iomem *dwIoBase, unsigned char byRFType, unsigned char byChannel)
 {
 	bool bResult = true;
 	switch (byRFType) {
@@ -818,7 +818,7 @@
  * Return Value: None.
  *
  */
-bool RFvWriteWakeProgSyn(unsigned long dwIoBase, unsigned char byRFType, unsigned int uChannel)
+bool RFvWriteWakeProgSyn(void __iomem *dwIoBase, unsigned char byRFType, unsigned int uChannel)
 {
 	int   ii;
 	unsigned char byInitCount = 0;
@@ -1070,7 +1070,7 @@
 
 // Post processing for the 11b/g and 11a.
 // for save time on changing Reg2,3,5,7,10,12,15
-bool RFbAL7230SelectChannelPostProcess(unsigned long dwIoBase, unsigned char byOldChannel, unsigned char byNewChannel)
+bool RFbAL7230SelectChannelPostProcess(void __iomem *dwIoBase, unsigned char byOldChannel, unsigned char byNewChannel)
 {
 	bool bResult;
 
diff --git a/drivers/staging/vt6655/rf.h b/drivers/staging/vt6655/rf.h
index ef3c6de..ba55561 100644
--- a/drivers/staging/vt6655/rf.h
+++ b/drivers/staging/vt6655/rf.h
@@ -74,12 +74,12 @@
 
 /*---------------------  Export Functions  --------------------------*/
 
-bool IFRFbWriteEmbedded(unsigned long dwIoBase, unsigned long dwData);
-bool RFbSelectChannel(unsigned long dwIoBase, unsigned char byRFType, unsigned char byChannel);
+bool IFRFbWriteEmbedded(void __iomem *dwIoBase, unsigned long dwData);
+bool RFbSelectChannel(void __iomem *dwIoBase, unsigned char byRFType, unsigned char byChannel);
 bool RFbInit(
 	PSDevice  pDevice
 );
-bool RFvWriteWakeProgSyn(unsigned long dwIoBase, unsigned char byRFType, unsigned int uChannel);
+bool RFvWriteWakeProgSyn(void __iomem *dwIoBase, unsigned char byRFType, unsigned int uChannel);
 bool RFbSetPower(PSDevice pDevice, unsigned int uRATE, unsigned int uCH);
 bool RFbRawSetPower(
 	PSDevice  pDevice,
@@ -95,7 +95,7 @@
 );
 
 //{{ RobertYu: 20050104
-bool RFbAL7230SelectChannelPostProcess(unsigned long dwIoBase, unsigned char byOldChannel, unsigned char byNewChannel);
+bool RFbAL7230SelectChannelPostProcess(void __iomem *dwIoBase, unsigned char byOldChannel, unsigned char byNewChannel);
 //}} RobertYu
 
 #endif // __RF_H__
diff --git a/drivers/staging/vt6655/srom.c b/drivers/staging/vt6655/srom.c
index eaddc33..5396e58 100644
--- a/drivers/staging/vt6655/srom.c
+++ b/drivers/staging/vt6655/srom.c
@@ -73,7 +73,7 @@
  * Return Value: data read
  *
  */
-unsigned char SROMbyReadEmbedded(unsigned long dwIoBase, unsigned char byContntOffset)
+unsigned char SROMbyReadEmbedded(void __iomem *dwIoBase, unsigned char byContntOffset)
 {
 	unsigned short wDelay, wNoACK;
 	unsigned char byWait;
@@ -121,7 +121,7 @@
  * Return Value: true if succeeded; false if failed.
  *
  */
-bool SROMbWriteEmbedded(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byData)
+bool SROMbWriteEmbedded(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byData)
 {
 	unsigned short wDelay, wNoACK;
 	unsigned char byWait;
@@ -173,7 +173,7 @@
  * Return Value: none
  *
  */
-void SROMvRegBitsOn(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byBits)
+void SROMvRegBitsOn(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byBits)
 {
 	unsigned char byOrgData;
 
@@ -193,7 +193,7 @@
  *      none
  *
  */
-void SROMvRegBitsOff(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byBits)
+void SROMvRegBitsOff(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byBits)
 {
 	unsigned char byOrgData;
 
@@ -215,7 +215,7 @@
  * Return Value: true if all test bits on; otherwise false
  *
  */
-bool SROMbIsRegBitsOn(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byTestBits)
+bool SROMbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byTestBits)
 {
 	unsigned char byOrgData;
 
@@ -237,7 +237,7 @@
  * Return Value: true if all test bits off; otherwise false
  *
  */
-bool SROMbIsRegBitsOff(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byTestBits)
+bool SROMbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byTestBits)
 {
 	unsigned char byOrgData;
 
@@ -257,7 +257,7 @@
  * Return Value: none
  *
  */
-void SROMvReadAllContents(unsigned long dwIoBase, unsigned char *pbyEepromRegs)
+void SROMvReadAllContents(void __iomem *dwIoBase, unsigned char *pbyEepromRegs)
 {
 	int     ii;
 
@@ -281,7 +281,7 @@
  * Return Value: none
  *
  */
-void SROMvWriteAllContents(unsigned long dwIoBase, unsigned char *pbyEepromRegs)
+void SROMvWriteAllContents(void __iomem *dwIoBase, unsigned char *pbyEepromRegs)
 {
 	int     ii;
 
@@ -304,7 +304,7 @@
  * Return Value: none
  *
  */
-void SROMvReadEtherAddress(unsigned long dwIoBase, unsigned char *pbyEtherAddress)
+void SROMvReadEtherAddress(void __iomem *dwIoBase, unsigned char *pbyEtherAddress)
 {
 	unsigned char ii;
 
@@ -328,7 +328,7 @@
  * Return Value: none
  *
  */
-void SROMvWriteEtherAddress(unsigned long dwIoBase, unsigned char *pbyEtherAddress)
+void SROMvWriteEtherAddress(void __iomem *dwIoBase, unsigned char *pbyEtherAddress)
 {
 	unsigned char ii;
 
@@ -351,7 +351,7 @@
  * Return Value: none
  *
  */
-void SROMvReadSubSysVenId(unsigned long dwIoBase, unsigned long *pdwSubSysVenId)
+void SROMvReadSubSysVenId(void __iomem *dwIoBase, unsigned long *pdwSubSysVenId)
 {
 	unsigned char *pbyData;
 
@@ -376,7 +376,7 @@
  * Return Value: true if success; otherwise false
  *
  */
-bool SROMbAutoLoad(unsigned long dwIoBase)
+bool SROMbAutoLoad(void __iomem *dwIoBase)
 {
 	unsigned char byWait;
 	int     ii;
diff --git a/drivers/staging/vt6655/srom.h b/drivers/staging/vt6655/srom.h
index 1df58c5..3128e53 100644
--- a/drivers/staging/vt6655/srom.h
+++ b/drivers/staging/vt6655/srom.h
@@ -133,23 +133,23 @@
 
 /*---------------------  Export Functions  --------------------------*/
 
-unsigned char SROMbyReadEmbedded(unsigned long dwIoBase, unsigned char byContntOffset);
-bool SROMbWriteEmbedded(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byData);
+unsigned char SROMbyReadEmbedded(void __iomem *dwIoBase, unsigned char byContntOffset);
+bool SROMbWriteEmbedded(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byData);
 
-void SROMvRegBitsOn(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byBits);
-void SROMvRegBitsOff(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byBits);
+void SROMvRegBitsOn(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byBits);
+void SROMvRegBitsOff(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byBits);
 
-bool SROMbIsRegBitsOn(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byTestBits);
-bool SROMbIsRegBitsOff(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byTestBits);
+bool SROMbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byTestBits);
+bool SROMbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byTestBits);
 
-void SROMvReadAllContents(unsigned long dwIoBase, unsigned char *pbyEepromRegs);
-void SROMvWriteAllContents(unsigned long dwIoBase, unsigned char *pbyEepromRegs);
+void SROMvReadAllContents(void __iomem *dwIoBase, unsigned char *pbyEepromRegs);
+void SROMvWriteAllContents(void __iomem *dwIoBase, unsigned char *pbyEepromRegs);
 
-void SROMvReadEtherAddress(unsigned long dwIoBase, unsigned char *pbyEtherAddress);
-void SROMvWriteEtherAddress(unsigned long dwIoBase, unsigned char *pbyEtherAddress);
+void SROMvReadEtherAddress(void __iomem *dwIoBase, unsigned char *pbyEtherAddress);
+void SROMvWriteEtherAddress(void __iomem *dwIoBase, unsigned char *pbyEtherAddress);
 
-void SROMvReadSubSysVenId(unsigned long dwIoBase, unsigned long *pdwSubSysVenId);
+void SROMvReadSubSysVenId(void __iomem *dwIoBase, unsigned long *pdwSubSysVenId);
 
-bool SROMbAutoLoad(unsigned long dwIoBase);
+bool SROMbAutoLoad(void __iomem *dwIoBase);
 
 #endif // __EEPROM_H__
diff --git a/drivers/staging/vt6655/upc.h b/drivers/staging/vt6655/upc.h
index 155e664..af12a86 100644
--- a/drivers/staging/vt6655/upc.h
+++ b/drivers/staging/vt6655/upc.h
@@ -72,38 +72,32 @@
 
 #define VNSvInPortB(dwIOAddress, pbyData)				\
 do {									\
-	volatile unsigned char *pbyAddr = (unsigned char *)(dwIOAddress); \
-	*(pbyData) = readb(pbyAddr);					\
+	*(pbyData) = readb(dwIOAddress);				\
 } while (0)
 
 #define VNSvInPortW(dwIOAddress, pwData)				\
 do {									\
-	volatile unsigned short *pwAddr = (unsigned short *)(dwIOAddress); \
-	*(pwData) = readw(pwAddr);					\
+	*(pwData) = readw(dwIOAddress);					\
 } while (0)
 
 #define VNSvInPortD(dwIOAddress, pdwData)				\
 do {									\
-	volatile unsigned long *pdwAddr = (unsigned long *)(dwIOAddress); \
-	*(pdwData) = readl(pdwAddr);					\
+	*(pdwData) = readl(dwIOAddress);				\
 } while (0)
 
 #define VNSvOutPortB(dwIOAddress, byData)				\
 do {									\
-	volatile unsigned char *pbyAddr = (unsigned char *)(dwIOAddress); \
-	writeb((unsigned char)byData, pbyAddr);				\
+	writeb((unsigned char)byData, dwIOAddress);			\
 } while (0)
 
 #define VNSvOutPortW(dwIOAddress, wData)				\
 do {									\
-	volatile unsigned short *pwAddr = ((unsigned short *)(dwIOAddress)); \
-	writew((unsigned short)wData, pwAddr);				\
+	writew((unsigned short)wData, dwIOAddress);			\
 } while (0)
 
 #define VNSvOutPortD(dwIOAddress, dwData)				\
 do {									\
-	volatile unsigned long *pdwAddr = (unsigned long *)(dwIOAddress); \
-	writel((unsigned long)dwData, pdwAddr);				\
+	writel((unsigned long)dwData, dwIOAddress);			\
 } while (0)
 
 #endif
diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c
index a689645..a379cec 100644
--- a/drivers/staging/vt6655/wcmd.c
+++ b/drivers/staging/vt6655/wcmd.c
@@ -234,7 +234,7 @@
  *
  -*/
 
-PSTxMgmtPacket
+static PSTxMgmtPacket
 s_MgrMakeProbeRequest(
 	PSDevice pDevice,
 	PSMgmtObject pMgmt,
diff --git a/drivers/staging/vt6655/wcmd.h b/drivers/staging/vt6655/wcmd.h
index 2844476..126b61c 100644
--- a/drivers/staging/vt6655/wcmd.h
+++ b/drivers/staging/vt6655/wcmd.h
@@ -33,12 +33,9 @@
 #include "80211hdr.h"
 #include "80211mgr.h"
 
-/*---------------------  Export Definitions -------------------------*/
+#define AUTHENTICATE_TIMEOUT   1000
+#define ASSOCIATE_TIMEOUT      1000
 
-#define AUTHENTICATE_TIMEOUT   1000 //ms
-#define ASSOCIATE_TIMEOUT      1000 //ms
-
-// Command code
 typedef enum tagCMD_CODE {
 	WLAN_CMD_BSSID_SCAN,
 	WLAN_CMD_SSID,
@@ -76,7 +73,6 @@
 	bool bForceSCAN;
 } CMD_ITEM, *PCMD_ITEM;
 
-// Command state
 typedef enum tagCMD_STATE {
 	WLAN_CMD_SCAN_START,
 	WLAN_CMD_SCAN_END,
@@ -92,13 +88,6 @@
 	WLAN_CMD_IDLE
 } CMD_STATE, *PCMD_STATE;
 
-/*---------------------  Export Classes  ----------------------------*/
-
-/*---------------------  Export Variables  --------------------------*/
-
-/*---------------------  Export Types  ------------------------------*/
-
-/*---------------------  Export Functions  --------------------------*/
 void
 vResetCommandTimer(
 	void *hDeviceContext
diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c
index cc4f5b9..9853a8f 100644
--- a/drivers/staging/vt6655/wmgr.c
+++ b/drivers/staging/vt6655/wmgr.c
@@ -3144,7 +3144,7 @@
  *
  -*/
 
-PSTxMgmtPacket
+static PSTxMgmtPacket
 s_MgrMakeProbeResponse(
 	PSDevice pDevice,
 	PSMgmtObject pMgmt,
@@ -3326,7 +3326,7 @@
  *
  -*/
 
-PSTxMgmtPacket
+static PSTxMgmtPacket
 s_MgrMakeAssocRequest(
 	PSDevice pDevice,
 	PSMgmtObject pMgmt,
@@ -3586,7 +3586,7 @@
  *
  -*/
 
-PSTxMgmtPacket
+static PSTxMgmtPacket
 s_MgrMakeReAssocRequest(
 	PSDevice pDevice,
 	PSMgmtObject pMgmt,
@@ -3831,7 +3831,7 @@
  *
  -*/
 
-PSTxMgmtPacket
+static PSTxMgmtPacket
 s_MgrMakeAssocResponse(
 	PSDevice pDevice,
 	PSMgmtObject pMgmt,
@@ -3902,7 +3902,7 @@
  *
  -*/
 
-PSTxMgmtPacket
+static PSTxMgmtPacket
 s_MgrMakeReAssocResponse(
 	PSDevice pDevice,
 	PSMgmtObject pMgmt,
diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
index c1675d5..e6c7b60 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -26,9 +26,10 @@
  * Date: Jun. 5, 2002
  *
  * Functions:
- *      vnt_get_frame_time        - Calculate data frame transmitting time
- *      vnt_get_phy_field   - Calculate PhyLength, PhyService and Phy Signal parameter for baseband Tx
- *      BBbVT3184Init          - VIA VT3184 baseband chip init code
+ *	vnt_get_frame_time	- Calculate data frame transmitting time
+ *	vnt_get_phy_field	- Calculate PhyLength, PhyService and Phy
+ *				  Signal parameter for baseband Tx
+ *	vnt_vt3184_init		- VIA VT3184 baseband chip init code
  *
  * Revision History:
  *
@@ -86,7 +87,7 @@
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00  /* 0xff */
 };
 
-//{{RobertYu:20060515, new BB setting for VT3226D0
+/* {{RobertYu:20060515, new BB setting for VT3226D0 */
 static u8 vnt_vt3184_vt3226d0[] = {
 	0x31, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
 	0x70, 0x45, 0x2a, 0x76, 0x00, 0x00, 0x80, 0x00, /* 0x0f */
@@ -122,8 +123,9 @@
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00  /* 0xff */
 };
 
-static const u16 awcFrameTime[MAX_RATE] =
-{10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216};
+static const u16 vnt_frame_time[MAX_RATE] = {
+	10, 20, 55, 110, 24, 36, 48, 72, 96, 144, 192, 216
+};
 
 /*
  * Description: Calculate data frame transmitting time
@@ -150,7 +152,7 @@
 	if (tx_rate > RATE_54M)
 		return 0;
 
-	rate = (unsigned int)awcFrameTime[tx_rate];
+	rate = (unsigned int)vnt_frame_time[tx_rate];
 
 	if (tx_rate <= 3) {
 		if (preamble_type == 1)
@@ -191,9 +193,9 @@
  *      tx_rate           - Tx Rate
  *  Out:
  *	struct vnt_phy_field *phy
- * 			- pointer to Phy Length field
- *			- pointer to Phy Service field
- * 			- pointer to Phy Signal field
+ *		- pointer to Phy Length field
+ *		- pointer to Phy Service field
+ *		- pointer to Phy Signal field
  *
  * Return Value: none
  *
@@ -205,7 +207,7 @@
 	u32 count = 0;
 	u32 tmp;
 	int ext_bit;
-	u8 preamble_type = priv->byPreambleType;
+	u8 preamble_type = priv->preamble_type;
 
 	bit_count = frame_length * 8;
 	ext_bit = false;
@@ -343,18 +345,18 @@
  * Return Value: none
  *
  */
-void BBvSetAntennaMode(struct vnt_private *priv, u8 antenna_mode)
+void vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode)
 {
 	switch (antenna_mode) {
 	case ANT_TXA:
 	case ANT_TXB:
 		break;
 	case ANT_RXA:
-		priv->byBBRxConf &= 0xFC;
+		priv->bb_rx_conf &= 0xFC;
 		break;
 	case ANT_RXB:
-		priv->byBBRxConf &= 0xFE;
-		priv->byBBRxConf |= 0x02;
+		priv->bb_rx_conf &= 0xFE;
+		priv->bb_rx_conf |= 0x02;
 		break;
 	}
 
@@ -376,7 +378,7 @@
  *
  */
 
-int BBbVT3184Init(struct vnt_private *priv)
+int vnt_vt3184_init(struct vnt_private *priv)
 {
 	int status;
 	u16 length;
@@ -388,36 +390,29 @@
 
 	status = vnt_control_in(priv, MESSAGE_TYPE_READ, 0,
 		MESSAGE_REQUEST_EEPROM, EEP_MAX_CONTEXT_SIZE,
-						priv->abyEEPROM);
+						priv->eeprom);
 	if (status != STATUS_SUCCESS)
 		return false;
 
-	priv->byZoneType = priv->abyEEPROM[EEP_OFS_ZONETYPE];
+	priv->rf_type = priv->eeprom[EEP_OFS_RFTYPE];
 
-	priv->byRFType = priv->abyEEPROM[EEP_OFS_RFTYPE];
+	dev_dbg(&priv->usb->dev, "RF Type %d\n", priv->rf_type);
 
-	dev_dbg(&priv->usb->dev, "Zone Type %x\n", priv->byZoneType);
-
-	dev_dbg(&priv->usb->dev, "RF Type %d\n", priv->byRFType);
-
-	if ((priv->byRFType == RF_AL2230) ||
-				(priv->byRFType == RF_AL2230S)) {
-		priv->byBBRxConf = vnt_vt3184_al2230[10];
+	if ((priv->rf_type == RF_AL2230) ||
+				(priv->rf_type == RF_AL2230S)) {
+		priv->bb_rx_conf = vnt_vt3184_al2230[10];
 		length = sizeof(vnt_vt3184_al2230);
 		addr = vnt_vt3184_al2230;
 		agc = vnt_vt3184_agc;
 		length_agc = sizeof(vnt_vt3184_agc);
 
-		priv->abyBBVGA[0] = 0x1C;
-		priv->abyBBVGA[1] = 0x10;
-		priv->abyBBVGA[2] = 0x0;
-		priv->abyBBVGA[3] = 0x0;
-		priv->ldBmThreshold[0] = -70;
-		priv->ldBmThreshold[1] = -48;
-		priv->ldBmThreshold[2] = 0;
-		priv->ldBmThreshold[3] = 0;
-	} else if (priv->byRFType == RF_AIROHA7230) {
-		priv->byBBRxConf = vnt_vt3184_al2230[10];
+		priv->bb_vga[0] = 0x1C;
+		priv->bb_vga[1] = 0x10;
+		priv->bb_vga[2] = 0x0;
+		priv->bb_vga[3] = 0x0;
+
+	} else if (priv->rf_type == RF_AIROHA7230) {
+		priv->bb_rx_conf = vnt_vt3184_al2230[10];
 		length = sizeof(vnt_vt3184_al2230);
 		addr = vnt_vt3184_al2230;
 		agc = vnt_vt3184_agc;
@@ -425,49 +420,42 @@
 
 		addr[0xd7] = 0x06;
 
-		priv->abyBBVGA[0] = 0x1c;
-		priv->abyBBVGA[1] = 0x10;
-		priv->abyBBVGA[2] = 0x0;
-		priv->abyBBVGA[3] = 0x0;
-		priv->ldBmThreshold[0] = -70;
-		priv->ldBmThreshold[1] = -48;
-		priv->ldBmThreshold[2] = 0;
-		priv->ldBmThreshold[3] = 0;
-	} else if ((priv->byRFType == RF_VT3226) ||
-			(priv->byRFType == RF_VT3226D0)) {
-		priv->byBBRxConf = vnt_vt3184_vt3226d0[10];
+		priv->bb_vga[0] = 0x1c;
+		priv->bb_vga[1] = 0x10;
+		priv->bb_vga[2] = 0x0;
+		priv->bb_vga[3] = 0x0;
+
+	} else if ((priv->rf_type == RF_VT3226) ||
+			(priv->rf_type == RF_VT3226D0)) {
+		priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
 		length = sizeof(vnt_vt3184_vt3226d0);
 		addr = vnt_vt3184_vt3226d0;
 		agc = vnt_vt3184_agc;
 		length_agc = sizeof(vnt_vt3184_agc);
 
-		priv->abyBBVGA[0] = 0x20;
-		priv->abyBBVGA[1] = 0x10;
-		priv->abyBBVGA[2] = 0x0;
-		priv->abyBBVGA[3] = 0x0;
-		priv->ldBmThreshold[0] = -70;
-		priv->ldBmThreshold[1] = -48;
-		priv->ldBmThreshold[2] = 0;
-		priv->ldBmThreshold[3] = 0;
+		priv->bb_vga[0] = 0x20;
+		priv->bb_vga[1] = 0x10;
+		priv->bb_vga[2] = 0x0;
+		priv->bb_vga[3] = 0x0;
+
 		/* Fix VT3226 DFC system timing issue */
-		vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
-	} else if ((priv->byRFType == RF_VT3342A0)) {
-		priv->byBBRxConf = vnt_vt3184_vt3226d0[10];
+		vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2,
+				    SOFTPWRCTL_RFLEOPT);
+	} else if (priv->rf_type == RF_VT3342A0) {
+		priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
 		length = sizeof(vnt_vt3184_vt3226d0);
 		addr = vnt_vt3184_vt3226d0;
 		agc = vnt_vt3184_agc;
 		length_agc = sizeof(vnt_vt3184_agc);
 
-		priv->abyBBVGA[0] = 0x20;
-		priv->abyBBVGA[1] = 0x10;
-		priv->abyBBVGA[2] = 0x0;
-		priv->abyBBVGA[3] = 0x0;
-		priv->ldBmThreshold[0] = -70;
-		priv->ldBmThreshold[1] = -48;
-		priv->ldBmThreshold[2] = 0;
-		priv->ldBmThreshold[3] = 0;
+		priv->bb_vga[0] = 0x20;
+		priv->bb_vga[1] = 0x10;
+		priv->bb_vga[2] = 0x0;
+		priv->bb_vga[3] = 0x0;
+
 		/* Fix VT3226 DFC system timing issue */
-		vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2, SOFTPWRCTL_RFLEOPT);
+		vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2,
+				    SOFTPWRCTL_RFLEOPT);
 	} else {
 		return true;
 	}
@@ -482,12 +470,12 @@
 	vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
 		MESSAGE_REQUEST_BBAGC, length_agc, array);
 
-	if ((priv->byRFType == RF_VT3226) ||
-		(priv->byRFType == RF_VT3342A0)) {
+	if ((priv->rf_type == RF_VT3226) ||
+		(priv->rf_type == RF_VT3342A0)) {
 		vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
 						MAC_REG_ITRTMSET, 0x23);
 		vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01);
-	} else if (priv->byRFType == RF_VT3226D0) {
+	} else if (priv->rf_type == RF_VT3226D0) {
 		vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
 						MAC_REG_ITRTMSET, 0x11);
 		vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01);
@@ -522,39 +510,39 @@
  * Return Value: none
  *
  */
-void BBvSetShortSlotTime(struct vnt_private *priv)
+void vnt_set_short_slot_time(struct vnt_private *priv)
 {
 	u8 bb_vga = 0;
 
-	if (priv->bShortSlotTime)
-		priv->byBBRxConf &= 0xdf;
+	if (priv->short_slot_time)
+		priv->bb_rx_conf &= 0xdf;
 	else
-		priv->byBBRxConf |= 0x20;
+		priv->bb_rx_conf |= 0x20;
 
 	vnt_control_in_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga);
 
-	if (bb_vga == priv->abyBBVGA[0])
-		priv->byBBRxConf |= 0x20;
+	if (bb_vga == priv->bb_vga[0])
+		priv->bb_rx_conf |= 0x20;
 
-	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf);
+	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->bb_rx_conf);
 }
 
-void BBvSetVGAGainOffset(struct vnt_private *priv, u8 data)
+void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data)
 {
 
 	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0xE7, data);
 
 	/* patch for 3253B0 Baseband with Cardbus module */
-	if (priv->bShortSlotTime)
-		priv->byBBRxConf &= 0xdf; /* 1101 1111 */
+	if (priv->short_slot_time)
+		priv->bb_rx_conf &= 0xdf; /* 1101 1111 */
 	else
-		priv->byBBRxConf |= 0x20; /* 0010 0000 */
+		priv->bb_rx_conf |= 0x20; /* 0010 0000 */
 
-	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->byBBRxConf);
+	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->bb_rx_conf);
 }
 
 /*
- * Description: BBvSetDeepSleep
+ * Description: vnt_set_deep_sleep
  *
  * Parameters:
  *  In:
@@ -565,24 +553,24 @@
  * Return Value: none
  *
  */
-void BBvSetDeepSleep(struct vnt_private *priv)
+void vnt_set_deep_sleep(struct vnt_private *priv)
 {
 	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);/* CR12 */
 	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0xB9);/* CR13 */
 }
 
-void BBvExitDeepSleep(struct vnt_private *priv)
+void vnt_exit_deep_sleep(struct vnt_private *priv)
 {
 	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x00);/* CR12 */
 	vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);/* CR13 */
 }
 
-void BBvUpdatePreEDThreshold(struct vnt_private *priv, int scanning)
+void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning)
 {
 	u8 cr_201 = 0x0, cr_206 = 0x0;
-	u8 ed_inx = priv->byBBPreEDIndex;
+	u8 ed_inx = priv->bb_pre_ed_index;
 
-	switch (priv->byRFType) {
+	switch (priv->rf_type) {
 	case RF_AL2230:
 	case RF_AL2230S:
 	case RF_AIROHA7230:
@@ -592,69 +580,69 @@
 			break;
 		}
 
-		if (priv->byBBPreEDRSSI <= 45) {
+		if (priv->bb_pre_ed_rssi <= 45) {
 			ed_inx = 20;
 			cr_201 = 0xff;
-		} else if (priv->byBBPreEDRSSI <= 46) {
+		} else if (priv->bb_pre_ed_rssi <= 46) {
 			ed_inx = 19;
 			cr_201 = 0x1a;
-		} else if (priv->byBBPreEDRSSI <= 47) {
+		} else if (priv->bb_pre_ed_rssi <= 47) {
 			ed_inx = 18;
 			cr_201 = 0x15;
-		} else if (priv->byBBPreEDRSSI <= 49) {
+		} else if (priv->bb_pre_ed_rssi <= 49) {
 			ed_inx = 17;
 			cr_201 = 0xe;
-		} else if (priv->byBBPreEDRSSI <= 51) {
+		} else if (priv->bb_pre_ed_rssi <= 51) {
 			ed_inx = 16;
 			cr_201 = 0x9;
-		} else if (priv->byBBPreEDRSSI <= 53) {
+		} else if (priv->bb_pre_ed_rssi <= 53) {
 			ed_inx = 15;
 			cr_201 = 0x6;
-		} else if (priv->byBBPreEDRSSI <= 55) {
+		} else if (priv->bb_pre_ed_rssi <= 55) {
 			ed_inx = 14;
 			cr_201 = 0x3;
-		} else if (priv->byBBPreEDRSSI <= 56) {
+		} else if (priv->bb_pre_ed_rssi <= 56) {
 			ed_inx = 13;
 			cr_201 = 0x2;
 			cr_206 = 0xa0;
-		} else if (priv->byBBPreEDRSSI <= 57) {
+		} else if (priv->bb_pre_ed_rssi <= 57) {
 			ed_inx = 12;
 			cr_201 = 0x2;
 			cr_206 = 0x20;
-		} else if (priv->byBBPreEDRSSI <= 58) {
+		} else if (priv->bb_pre_ed_rssi <= 58) {
 			ed_inx = 11;
 			cr_201 = 0x1;
 			cr_206 = 0xa0;
-		} else if (priv->byBBPreEDRSSI <= 59) {
+		} else if (priv->bb_pre_ed_rssi <= 59) {
 			ed_inx = 10;
 			cr_201 = 0x1;
 			cr_206 = 0x54;
-		} else if (priv->byBBPreEDRSSI <= 60) {
+		} else if (priv->bb_pre_ed_rssi <= 60) {
 			ed_inx = 9;
 			cr_201 = 0x1;
 			cr_206 = 0x18;
-		} else if (priv->byBBPreEDRSSI <= 61) {
+		} else if (priv->bb_pre_ed_rssi <= 61) {
 			ed_inx = 8;
 			cr_206 = 0xe3;
-		} else if (priv->byBBPreEDRSSI <= 62) {
+		} else if (priv->bb_pre_ed_rssi <= 62) {
 			ed_inx = 7;
 			cr_206 = 0xb9;
-		} else if (priv->byBBPreEDRSSI <= 63) {
+		} else if (priv->bb_pre_ed_rssi <= 63) {
 			ed_inx = 6;
 			cr_206 = 0x93;
-		} else if (priv->byBBPreEDRSSI <= 64) {
+		} else if (priv->bb_pre_ed_rssi <= 64) {
 			ed_inx = 5;
 			cr_206 = 0x79;
-		} else if (priv->byBBPreEDRSSI <= 65) {
+		} else if (priv->bb_pre_ed_rssi <= 65) {
 			ed_inx = 4;
 			cr_206 = 0x62;
-		} else if (priv->byBBPreEDRSSI <= 66) {
+		} else if (priv->bb_pre_ed_rssi <= 66) {
 			ed_inx = 3;
 			cr_206 = 0x51;
-		} else if (priv->byBBPreEDRSSI <= 67) {
+		} else if (priv->bb_pre_ed_rssi <= 67) {
 			ed_inx = 2;
 			cr_206 = 0x43;
-		} else if (priv->byBBPreEDRSSI <= 68) {
+		} else if (priv->bb_pre_ed_rssi <= 68) {
 			ed_inx = 1;
 			cr_206 = 0x36;
 		} else {
@@ -671,75 +659,75 @@
 			break;
 		}
 
-		if (priv->byBBPreEDRSSI <= 41) {
+		if (priv->bb_pre_ed_rssi <= 41) {
 			ed_inx = 22;
 			cr_201 = 0xff;
-		} else if (priv->byBBPreEDRSSI <= 42) {
+		} else if (priv->bb_pre_ed_rssi <= 42) {
 			ed_inx = 21;
 			cr_201 = 0x36;
-		} else if (priv->byBBPreEDRSSI <= 43) {
+		} else if (priv->bb_pre_ed_rssi <= 43) {
 			ed_inx = 20;
 			cr_201 = 0x26;
-		} else if (priv->byBBPreEDRSSI <= 45) {
+		} else if (priv->bb_pre_ed_rssi <= 45) {
 			ed_inx = 19;
 			cr_201 = 0x18;
-		} else if (priv->byBBPreEDRSSI <= 47) {
+		} else if (priv->bb_pre_ed_rssi <= 47) {
 			ed_inx = 18;
 			cr_201 = 0x11;
-		} else if (priv->byBBPreEDRSSI <= 49) {
+		} else if (priv->bb_pre_ed_rssi <= 49) {
 			ed_inx = 17;
 			cr_201 = 0xa;
-		} else if (priv->byBBPreEDRSSI <= 51) {
+		} else if (priv->bb_pre_ed_rssi <= 51) {
 			ed_inx = 16;
 			cr_201 = 0x7;
-		} else if (priv->byBBPreEDRSSI <= 53) {
+		} else if (priv->bb_pre_ed_rssi <= 53) {
 			ed_inx = 15;
 			cr_201 = 0x4;
-		} else if (priv->byBBPreEDRSSI <= 55) {
+		} else if (priv->bb_pre_ed_rssi <= 55) {
 			ed_inx = 14;
 			cr_201 = 0x2;
 			cr_206 = 0xc0;
-		} else if (priv->byBBPreEDRSSI <= 56) {
+		} else if (priv->bb_pre_ed_rssi <= 56) {
 			ed_inx = 13;
 			cr_201 = 0x2;
 			cr_206 = 0x30;
-		} else if (priv->byBBPreEDRSSI <= 57) {
+		} else if (priv->bb_pre_ed_rssi <= 57) {
 			ed_inx = 12;
 			cr_201 = 0x1;
 			cr_206 = 0xb0;
-		} else if (priv->byBBPreEDRSSI <= 58) {
+		} else if (priv->bb_pre_ed_rssi <= 58) {
 			ed_inx = 11;
 			cr_201 = 0x1;
 			cr_206 = 0x70;
-		} else if (priv->byBBPreEDRSSI <= 59) {
+		} else if (priv->bb_pre_ed_rssi <= 59) {
 			ed_inx = 10;
 			cr_201 = 0x1;
 			cr_206 = 0x30;
-		} else if (priv->byBBPreEDRSSI <= 60) {
+		} else if (priv->bb_pre_ed_rssi <= 60) {
 			ed_inx = 9;
 			cr_206 = 0xea;
-		} else if (priv->byBBPreEDRSSI <= 61) {
+		} else if (priv->bb_pre_ed_rssi <= 61) {
 			ed_inx = 8;
 			cr_206 = 0xc0;
-		} else if (priv->byBBPreEDRSSI <= 62) {
+		} else if (priv->bb_pre_ed_rssi <= 62) {
 			ed_inx = 7;
 			cr_206 = 0x9c;
-		} else if (priv->byBBPreEDRSSI <= 63) {
+		} else if (priv->bb_pre_ed_rssi <= 63) {
 			ed_inx = 6;
 			cr_206 = 0x80;
-		} else if (priv->byBBPreEDRSSI <= 64) {
+		} else if (priv->bb_pre_ed_rssi <= 64) {
 			ed_inx = 5;
 			cr_206 = 0x68;
-		} else if (priv->byBBPreEDRSSI <= 65) {
+		} else if (priv->bb_pre_ed_rssi <= 65) {
 			ed_inx = 4;
 			cr_206 = 0x52;
-		} else if (priv->byBBPreEDRSSI <= 66) {
+		} else if (priv->bb_pre_ed_rssi <= 66) {
 			ed_inx = 3;
 			cr_206 = 0x43;
-		} else if (priv->byBBPreEDRSSI <= 67) {
+		} else if (priv->bb_pre_ed_rssi <= 67) {
 			ed_inx = 2;
 			cr_206 = 0x36;
-		} else if (priv->byBBPreEDRSSI <= 68) {
+		} else if (priv->bb_pre_ed_rssi <= 68) {
 			ed_inx = 1;
 			cr_206 = 0x2d;
 		} else {
@@ -755,69 +743,69 @@
 			break;
 		}
 
-		if (priv->byBBPreEDRSSI <= 41) {
+		if (priv->bb_pre_ed_rssi <= 41) {
 			ed_inx = 20;
 			cr_201 = 0xff;
-		} else if (priv->byBBPreEDRSSI <= 42) {
+		} else if (priv->bb_pre_ed_rssi <= 42) {
 			ed_inx = 19;
 			cr_201 = 0x36;
-		} else if (priv->byBBPreEDRSSI <= 43) {
+		} else if (priv->bb_pre_ed_rssi <= 43) {
 			ed_inx = 18;
 			cr_201 = 0x26;
-		} else if (priv->byBBPreEDRSSI <= 45) {
+		} else if (priv->bb_pre_ed_rssi <= 45) {
 			ed_inx = 17;
 			cr_201 = 0x18;
-		} else if (priv->byBBPreEDRSSI <= 47) {
+		} else if (priv->bb_pre_ed_rssi <= 47) {
 			ed_inx = 16;
 			cr_201 = 0x11;
-		} else if (priv->byBBPreEDRSSI <= 49) {
+		} else if (priv->bb_pre_ed_rssi <= 49) {
 			ed_inx = 15;
 			cr_201 = 0xa;
-		} else if (priv->byBBPreEDRSSI <= 51) {
+		} else if (priv->bb_pre_ed_rssi <= 51) {
 			ed_inx = 14;
 			cr_201 = 0x7;
-		} else if (priv->byBBPreEDRSSI <= 53) {
+		} else if (priv->bb_pre_ed_rssi <= 53) {
 			ed_inx = 13;
 			cr_201 = 0x4;
-		} else if (priv->byBBPreEDRSSI <= 55) {
+		} else if (priv->bb_pre_ed_rssi <= 55) {
 			ed_inx = 12;
 			cr_201 = 0x2;
 			cr_206 = 0xc0;
-		} else if (priv->byBBPreEDRSSI <= 56) {
+		} else if (priv->bb_pre_ed_rssi <= 56) {
 			ed_inx = 11;
 			cr_201 = 0x2;
 			cr_206 = 0x30;
-		} else if (priv->byBBPreEDRSSI <= 57) {
+		} else if (priv->bb_pre_ed_rssi <= 57) {
 			ed_inx = 10;
 			cr_201 = 0x1;
 			cr_206 = 0xb0;
-		} else if (priv->byBBPreEDRSSI <= 58) {
+		} else if (priv->bb_pre_ed_rssi <= 58) {
 			ed_inx = 9;
 			cr_201 = 0x1;
 			cr_206 = 0x70;
-		} else if (priv->byBBPreEDRSSI <= 59) {
+		} else if (priv->bb_pre_ed_rssi <= 59) {
 			ed_inx = 8;
 			cr_201 = 0x1;
 			cr_206 = 0x30;
-		} else if (priv->byBBPreEDRSSI <= 60) {
+		} else if (priv->bb_pre_ed_rssi <= 60) {
 			ed_inx = 7;
 			cr_206 = 0xea;
-		} else if (priv->byBBPreEDRSSI <= 61) {
+		} else if (priv->bb_pre_ed_rssi <= 61) {
 			ed_inx = 6;
 			cr_206 = 0xc0;
-		} else if (priv->byBBPreEDRSSI <= 62) {
+		} else if (priv->bb_pre_ed_rssi <= 62) {
 			ed_inx = 5;
 			cr_206 = 0x9c;
-		} else if (priv->byBBPreEDRSSI <= 63) {
+		} else if (priv->bb_pre_ed_rssi <= 63) {
 			ed_inx = 4;
 			cr_206 = 0x80;
-		} else if (priv->byBBPreEDRSSI <= 64) {
+		} else if (priv->bb_pre_ed_rssi <= 64) {
 			ed_inx = 3;
 			cr_206 = 0x68;
-		} else if (priv->byBBPreEDRSSI <= 65) {
+		} else if (priv->bb_pre_ed_rssi <= 65) {
 			ed_inx = 2;
 			cr_206 = 0x52;
-		} else if (priv->byBBPreEDRSSI <= 66) {
+		} else if (priv->bb_pre_ed_rssi <= 66) {
 			ed_inx = 1;
 			cr_206 = 0x43;
 		} else {
@@ -828,13 +816,13 @@
 
 	}
 
-	if (ed_inx == priv->byBBPreEDIndex && !scanning)
+	if (ed_inx == priv->bb_pre_ed_index && !scanning)
 		return;
 
-	priv->byBBPreEDIndex = ed_inx;
+	priv->bb_pre_ed_index = ed_inx;
 
-	dev_dbg(&priv->usb->dev, "%s byBBPreEDRSSI %d\n",
-					__func__, priv->byBBPreEDRSSI);
+	dev_dbg(&priv->usb->dev, "%s bb_pre_ed_rssi %d\n",
+					__func__, priv->bb_pre_ed_rssi);
 
 	if (!cr_201 && !cr_206)
 		return;
diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h
index c73244b..771ea40 100644
--- a/drivers/staging/vt6656/baseband.h
+++ b/drivers/staging/vt6656/baseband.h
@@ -93,12 +93,12 @@
 void vnt_get_phy_field(struct vnt_private *, u32 frame_length,
 	u16 tx_rate, u8 pkt_type, struct vnt_phy_field *);
 
-void BBvSetShortSlotTime(struct vnt_private *);
-void BBvSetVGAGainOffset(struct vnt_private *, u8 byData);
-void BBvSetAntennaMode(struct vnt_private *, u8 byAntennaMode);
-int BBbVT3184Init(struct vnt_private *);
-void BBvSetDeepSleep(struct vnt_private *);
-void BBvExitDeepSleep(struct vnt_private *);
-void BBvUpdatePreEDThreshold(struct vnt_private *, int scanning);
+void vnt_set_short_slot_time(struct vnt_private *);
+void vnt_set_vga_gain_offset(struct vnt_private *, u8);
+void vnt_set_antenna_mode(struct vnt_private *, u8);
+int vnt_vt3184_init(struct vnt_private *);
+void vnt_set_deep_sleep(struct vnt_private *);
+void vnt_exit_deep_sleep(struct vnt_private *);
+void vnt_update_pre_ed_threshold(struct vnt_private *, int scanning);
 
 #endif /* __BASEBAND_H__ */
diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index ea06b63..c06dd9d 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -55,11 +55,12 @@
 #include "key.h"
 #include "usbpipe.h"
 
-//const u16 cwRXBCNTSFOff[MAX_RATE] =
-//{17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3};
+/* const u16 cwRXBCNTSFOff[MAX_RATE] =
+   {17, 34, 96, 192, 34, 23, 17, 11, 8, 5, 4, 3}; */
 
-static const u16 cwRXBCNTSFOff[MAX_RATE] =
-{192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3};
+static const u16 cwRXBCNTSFOff[MAX_RATE] = {
+	192, 96, 34, 17, 34, 23, 17, 11, 8, 5, 4, 3
+};
 
 /*
  * Description: Set NIC media channel
@@ -108,7 +109,7 @@
 	u16 ui = rate_idx;
 
 	while (ui > RATE_1M) {
-		if (priv->wBasicRate & (1 << ui))
+		if (priv->basic_rates & (1 << ui))
 			return ui;
 		ui--;
 	}
@@ -134,7 +135,7 @@
 	u16 ui = rate_idx;
 
 	dev_dbg(&priv->usb->dev, "%s basic rate: %d\n",
-					__func__,  priv->wBasicRate);
+					__func__,  priv->basic_rates);
 
 	if (!vnt_ofdm_min_rate(priv)) {
 		dev_dbg(&priv->usb->dev, "%s (NO OFDM) %d\n",
@@ -145,7 +146,7 @@
 	}
 
 	while (ui > RATE_11M) {
-		if (priv->wBasicRate & (1 << ui)) {
+		if (priv->basic_rates & (1 << ui)) {
 			dev_dbg(&priv->usb->dev, "%s rate: %d\n",
 							__func__, ui);
 			return ui;
@@ -364,84 +365,78 @@
 	u8 max_min = 0;
 	u8 data[4];
 
-	if (priv->byPacketType == PK_TYPE_11A) {
-		priv->uSlot = C_SLOT_SHORT;
-		priv->uSIFS = C_SIFS_A;
-		priv->uDIFS = C_SIFS_A + 2 * C_SLOT_SHORT;
-		priv->uCwMin = C_CWMIN_A;
+	if (priv->packet_type == PK_TYPE_11A) {
+		priv->slot = C_SLOT_SHORT;
+		priv->sifs = C_SIFS_A;
+		priv->difs = C_SIFS_A + 2 * C_SLOT_SHORT;
 		max_min = 4;
-	} else if (priv->byPacketType == PK_TYPE_11B) {
-		priv->uSlot = C_SLOT_LONG;
-		priv->uSIFS = C_SIFS_BG;
-		priv->uDIFS = C_SIFS_BG + 2 * C_SLOT_LONG;
-		priv->uCwMin = C_CWMIN_B;
+	} else if (priv->packet_type == PK_TYPE_11B) {
+		priv->slot = C_SLOT_LONG;
+		priv->sifs = C_SIFS_BG;
+		priv->difs = C_SIFS_BG + 2 * C_SLOT_LONG;
 		max_min = 5;
 	} else {/* PK_TYPE_11GA & PK_TYPE_11GB */
 		bool ofdm_rate = false;
 		unsigned int ii = 0;
 
-		priv->uSIFS = C_SIFS_BG;
+		priv->sifs = C_SIFS_BG;
 
-		if (priv->bShortSlotTime)
-			priv->uSlot = C_SLOT_SHORT;
+		if (priv->short_slot_time)
+			priv->slot = C_SLOT_SHORT;
 		else
-			priv->uSlot = C_SLOT_LONG;
+			priv->slot = C_SLOT_LONG;
 
-		priv->uDIFS = C_SIFS_BG + 2 * priv->uSlot;
+		priv->difs = C_SIFS_BG + 2 * priv->slot;
 
 		for (ii = RATE_54M; ii >= RATE_6M; ii--) {
-			if (priv->wBasicRate & ((u32)(0x1 << ii))) {
+			if (priv->basic_rates & ((u32)(0x1 << ii))) {
 				ofdm_rate = true;
 				break;
 			}
 		}
 
-		if (ofdm_rate == true) {
-			priv->uCwMin = C_CWMIN_A;
+		if (ofdm_rate == true)
 			max_min = 4;
-		} else {
-			priv->uCwMin = C_CWMIN_B;
+		else
 			max_min = 5;
-			}
 	}
 
-	priv->uCwMax = C_CWMAX;
-	priv->uEIFS = C_EIFS;
+	priv->eifs = C_EIFS;
 
-	switch (priv->byRFType) {
+	switch (priv->rf_type) {
 	case RF_VT3226D0:
-		if (priv->byBBType != BB_TYPE_11B) {
-			priv->uSIFS -= 1;
-			priv->uDIFS -= 1;
+		if (priv->bb_type != BB_TYPE_11B) {
+			priv->sifs -= 1;
+			priv->difs -= 1;
 			break;
 		}
 	case RF_AIROHA7230:
 	case RF_AL2230:
 	case RF_AL2230S:
-		if (priv->byBBType != BB_TYPE_11B)
+		if (priv->bb_type != BB_TYPE_11B)
 			break;
 	case RF_RFMD2959:
 	case RF_VT3226:
 	case RF_VT3342A0:
-		priv->uSIFS -= 3;
-		priv->uDIFS -= 3;
+		priv->sifs -= 3;
+		priv->difs -= 3;
 		break;
 	case RF_MAXIM2829:
-		if (priv->byBBType == BB_TYPE_11A) {
-			priv->uSIFS -= 5;
-			priv->uDIFS -= 5;
+		if (priv->bb_type == BB_TYPE_11A) {
+			priv->sifs -= 5;
+			priv->difs -= 5;
 		} else {
-			priv->uSIFS -= 2;
-			priv->uDIFS -= 2;
+			priv->sifs -= 2;
+			priv->difs -= 2;
 		}
 
 		break;
 	}
 
-	data[0] = (u8)priv->uSIFS;
-	data[1] = (u8)priv->uDIFS;
-	data[2] = (u8)priv->uEIFS;
-	data[3] = (u8)priv->uSlot;
+	data[0] = (u8)priv->sifs;
+	data[1] = (u8)priv->difs;
+	data[2] = (u8)priv->eifs;
+	data[3] = (u8)priv->slot;
 
 	vnt_control_out(priv, MESSAGE_TYPE_WRITE, MAC_REG_SIFS,
 		MESSAGE_REQUEST_MACREG, 4, &data[0]);
@@ -459,16 +454,16 @@
 
 	/*Determines the highest basic rate.*/
 	for (i = RATE_54M; i >= RATE_6M; i--) {
-		if (priv->wBasicRate & (u16)(1 << i)) {
+		if (priv->basic_rates & (u16)(1 << i)) {
 			top_ofdm = i;
 			break;
 		}
 	}
 
-	priv->byTopOFDMBasicRate = top_ofdm;
+	priv->top_ofdm_basic_rate = top_ofdm;
 
 	for (i = RATE_11M;; i--) {
-		if (priv->wBasicRate & (u16)(1 << i)) {
+		if (priv->basic_rates & (u16)(1 << i)) {
 			top_cck = i;
 			break;
 		}
@@ -476,15 +471,15 @@
 			break;
 	}
 
-	priv->byTopCCKBasicRate = top_cck;
- }
+	priv->top_cck_basic_rate = top_cck;
+}
 
 int vnt_ofdm_min_rate(struct vnt_private *priv)
 {
 	int ii;
 
 	for (ii = RATE_54M; ii >= RATE_6M; ii--) {
-		if ((priv->wBasicRate) & ((u16)(1 << ii)))
+		if ((priv->basic_rates) & ((u16)(1 << ii)))
 			return true;
 	}
 
@@ -494,8 +489,8 @@
 u8 vnt_get_pkt_type(struct vnt_private *priv)
 {
 
-	if (priv->byBBType == BB_TYPE_11A || priv->byBBType == BB_TYPE_11B)
-		return (u8)priv->byBBType;
+	if (priv->bb_type == BB_TYPE_11A || priv->bb_type == BB_TYPE_11B)
+		return (u8)priv->bb_type;
 	else if (vnt_ofdm_min_rate(priv))
 		return PK_TYPE_11GA;
 	else
@@ -582,7 +577,7 @@
 bool vnt_get_current_tsf(struct vnt_private *priv, u64 *current_tsf)
 {
 
-	*current_tsf = priv->qwCurrTSF;
+	*current_tsf = priv->current_tsf;
 
 	return true;
 }
@@ -603,7 +598,7 @@
 
 	vnt_mac_reg_bits_on(priv, MAC_REG_TFTCTL, TFTCTL_TSFCNTRST);
 
-	priv->qwCurrTSF = 0;
+	priv->current_tsf = 0;
 
 	return true;
 }
@@ -710,7 +705,7 @@
 	data[7] = (u8)(tsf >> 56);
 
 	vnt_control_out(priv, MESSAGE_TYPE_SET_TSFTBTT,
-		MESSAGE_REQUEST_TBTT, 0, 8, data);
+			MESSAGE_REQUEST_TBTT, 0, 8, data);
 
 	dev_dbg(&priv->usb->dev, "%s TBTT: %8llx\n", __func__, tsf);
 
@@ -733,9 +728,7 @@
 {
 	int ret = true;
 
-	priv->bRadioOff = true;
-
-	switch (priv->byRFType) {
+	switch (priv->rf_type) {
 	case RF_AL2230:
 	case RF_AL2230S:
 	case RF_AIROHA7230:
@@ -749,7 +742,9 @@
 
 	vnt_mac_reg_bits_off(priv, MAC_REG_HOSTCR, HOSTCR_RXON);
 
-	BBvSetDeepSleep(priv);
+	vnt_set_deep_sleep(priv);
+
+	vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL1, GPIO3_INTMD);
 
 	return ret;
 }
@@ -770,16 +765,11 @@
 {
 	int ret = true;
 
-	if (priv->bHWRadioOff == true || priv->bRadioControlOff == true)
-		return false;
-
-	priv->bRadioOff = false;
-
-	BBvExitDeepSleep(priv);
+	vnt_exit_deep_sleep(priv);
 
 	vnt_mac_reg_bits_on(priv, MAC_REG_HOSTCR, HOSTCR_RXON);
 
-	switch (priv->byRFType) {
+	switch (priv->rf_type) {
 	case RF_AL2230:
 	case RF_AL2230S:
 	case RF_AIROHA7230:
@@ -791,49 +781,51 @@
 		break;
 	}
 
+	vnt_mac_reg_bits_off(priv, MAC_REG_GPIOCTL1, GPIO3_INTMD);
+
 	return ret;
 }
 
 void vnt_set_bss_mode(struct vnt_private *priv)
 {
-	if (priv->byRFType == RF_AIROHA7230 && priv->byBBType == BB_TYPE_11A)
+	if (priv->rf_type == RF_AIROHA7230 && priv->bb_type == BB_TYPE_11A)
 		vnt_mac_set_bb_type(priv, BB_TYPE_11G);
 	else
-		vnt_mac_set_bb_type(priv, priv->byBBType);
+		vnt_mac_set_bb_type(priv, priv->bb_type);
 
-	priv->byPacketType = vnt_get_pkt_type(priv);
+	priv->packet_type = vnt_get_pkt_type(priv);
 
-	if (priv->byBBType == BB_TYPE_11A)
+	if (priv->bb_type == BB_TYPE_11A)
 		vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x03);
-	else if (priv->byBBType == BB_TYPE_11B)
+	else if (priv->bb_type == BB_TYPE_11B)
 		vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x02);
-	else if (priv->byBBType == BB_TYPE_11G)
+	else if (priv->bb_type == BB_TYPE_11G)
 		vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x88, 0x08);
 
 	vnt_update_ifs(priv);
-	vnt_set_rspinf(priv, (u8)priv->byBBType);
+	vnt_set_rspinf(priv, (u8)priv->bb_type);
 
-	if (priv->byBBType == BB_TYPE_11A) {
-		if (priv->byRFType == RF_AIROHA7230) {
-			priv->abyBBVGA[0] = 0x20;
+	if (priv->bb_type == BB_TYPE_11A) {
+		if (priv->rf_type == RF_AIROHA7230) {
+			priv->bb_vga[0] = 0x20;
 
 			vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG,
-						0xe7, priv->abyBBVGA[0]);
+						0xe7, priv->bb_vga[0]);
 		}
 
-		priv->abyBBVGA[2] = 0x10;
-		priv->abyBBVGA[3] = 0x10;
+		priv->bb_vga[2] = 0x10;
+		priv->bb_vga[3] = 0x10;
 	} else {
-		if (priv->byRFType == RF_AIROHA7230) {
-			priv->abyBBVGA[0] = 0x1c;
+		if (priv->rf_type == RF_AIROHA7230) {
+			priv->bb_vga[0] = 0x1c;
 
 			vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG,
-						0xe7, priv->abyBBVGA[0]);
+						0xe7, priv->bb_vga[0]);
 		}
 
-		priv->abyBBVGA[2] = 0x0;
-		priv->abyBBVGA[3] = 0x0;
+		priv->bb_vga[2] = 0x0;
+		priv->bb_vga[3] = 0x0;
 	}
 
-	BBvSetVGAGainOffset(priv, priv->abyBBVGA[0]);
+	vnt_set_vga_gain_offset(priv, priv->bb_vga[0]);
 }
diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h
index 5b7cc5a..03fc167 100644
--- a/drivers/staging/vt6656/card.h
+++ b/drivers/staging/vt6656/card.h
@@ -32,16 +32,9 @@
 
 /* init card type */
 
-typedef enum _CARD_PHY_TYPE {
-    PHY_TYPE_AUTO = 0,
-    PHY_TYPE_11B,
-    PHY_TYPE_11G,
-    PHY_TYPE_11A
-} CARD_PHY_TYPE, *PCARD_PHY_TYPE;
-
-#define CB_MAX_CHANNEL_24G  14
-#define CB_MAX_CHANNEL_5G       42 /* add channel9(5045MHz), 41==>42 */
-#define CB_MAX_CHANNEL      (CB_MAX_CHANNEL_24G+CB_MAX_CHANNEL_5G)
+#define CB_MAX_CHANNEL_24G	14
+#define CB_MAX_CHANNEL_5G	42 /* add channel9(5045MHz), 41==>42 */
+#define CB_MAX_CHANNEL		(CB_MAX_CHANNEL_24G + CB_MAX_CHANNEL_5G)
 
 struct vnt_private;
 
diff --git a/drivers/staging/vt6656/channel.c b/drivers/staging/vt6656/channel.c
index fb1838e..8412d05 100644
--- a/drivers/staging/vt6656/channel.c
+++ b/drivers/staging/vt6656/channel.c
@@ -28,8 +28,9 @@
  *
  *
  * Revision History:
- *      01-18-2005      RobertYu:  remove the for loop searching in ChannelValid,
- *                                 change ChannelRuleTab to lookup-type, reorder table items.
+ *	01-18-2005	RobertYu:	remove the for loop searching in
+ *					ChannelValid, change ChannelRuleTab
+ *					to lookup-type, reorder table items.
  *
  *
  */
@@ -145,7 +146,7 @@
 	struct ieee80211_channel *ch;
 	int i;
 
-	switch (priv->byRFType) {
+	switch (priv->rf_type) {
 	case RF_AIROHA7230:
 	case RF_VT3342A0:
 	default:
diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 436f109..6b7bb8c 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -185,16 +185,6 @@
 /* USB registers */
 #define USB_REG4			0x604
 
-#define DBG_PRT(l, p, args...) { if (l <= msglevel) printk(p, ##args); }
-
-typedef enum __device_msg_level {
-	MSG_LEVEL_ERR = 0,            /* Errors causing abnormal operation */
-	MSG_LEVEL_NOTICE = 1,         /* Errors needing user notification */
-	MSG_LEVEL_INFO = 2,           /* Normal message. */
-	MSG_LEVEL_VERBOSE = 3,        /* Will report all trival errors. */
-	MSG_LEVEL_DEBUG = 4           /* Only for debug purpose. */
-} DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL;
-
 #define DEVICE_INIT_COLD	0x0 /* cold init */
 #define DEVICE_INIT_RESET	0x1 /* reset init or Dx to D0 power remain */
 #define DEVICE_INIT_DXPL	0x2 /* Dx to D0 power lost init */
@@ -229,12 +219,10 @@
 
 /* RCB (Receive Control Block) */
 struct vnt_rcb {
-	void *Next;
-	signed long Ref;
-	void *pDevice;
-	struct urb *pUrb;
+	void *priv;
+	struct urb *urb;
 	struct sk_buff *skb;
-	int bBoolInUse;
+	int in_use;
 };
 
 /* used to track bulk out irps */
@@ -244,20 +232,18 @@
 	struct urb *urb;
 	struct ieee80211_hdr *hdr;
 	unsigned int buf_len;
+	u32 frame_len;
 	u16 tx_hdr_size;
+	u16 tx_rate;
 	u8 type;
 	u8 pkt_no;
+	u8 pkt_type;
+	u8 need_ack;
 	u8 fb_option;
 	bool in_use;
 	unsigned char data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS];
 };
 
-/* tx packet info for rxtx */
-struct vnt_tx_pkt_info {
-	u16 fifo_ctl;
-	u8 dest_addr[ETH_ALEN];
-};
-
 /*
  * Structure to keep track of USB interrupt packets
  */
@@ -268,13 +254,12 @@
 
 /*++ NDIS related */
 
-typedef enum __DEVICE_NDIS_STATUS {
-    STATUS_SUCCESS = 0,
-    STATUS_FAILURE,
-    STATUS_RESOURCES,
-    STATUS_PENDING,
-} DEVICE_NDIS_STATUS, *PDEVICE_NDIS_STATUS;
-
+enum {
+	STATUS_SUCCESS = 0,
+	STATUS_FAILURE,
+	STATUS_RESOURCES,
+	STATUS_PENDING,
+};
 
 /* flags for options */
 #define     DEVICE_FLAGS_UNPLUG          0x00000001UL
@@ -289,7 +274,6 @@
 	u8 mac_hw;
 	/* netdev */
 	struct usb_device *usb;
-	struct net_device_stats stats;
 
 	u64 tsf_time;
 	u8 rx_rate;
@@ -304,106 +288,92 @@
 	unsigned long Flags;
 
 	/* USB */
-	struct urb *pInterruptURB;
+	struct urb *interrupt_urb;
 	u32 int_interval;
 
 	/* Variables to track resources for the BULK In Pipe */
-	struct vnt_rcb *apRCB[CB_MAX_RX_DESC];
-	u32 cbRD;
+	struct vnt_rcb *rcb[CB_MAX_RX_DESC];
+	u32 num_rcb;
 
 	/* Variables to track resources for the BULK Out Pipe */
-	struct vnt_usb_send_context *apTD[CB_MAX_TX_DESC];
-	u32 cbTD;
-	struct vnt_tx_pkt_info pkt_info[16];
+	struct vnt_usb_send_context *tx_context[CB_MAX_TX_DESC];
+	u32 num_tx_context;
 
 	/* Variables to track resources for the Interrupt In Pipe */
 	struct vnt_interrupt_buffer int_buf;
 
 	/* Version control */
-	u16 wFirmwareVersion;
-	u8 byLocalID;
-	u8 byRFType;
-	u8 byBBRxConf;
-
-	u8 byZoneType;
+	u16 firmware_version;
+	u8 local_id;
+	u8 rf_type;
+	u8 bb_rx_conf;
 
 	struct vnt_cmd_card_init init_command;
 	struct vnt_rsp_card_init init_response;
-	u8 abyCurrentNetAddr[ETH_ALEN];
-	u8 abyPermanentNetAddr[ETH_ALEN];
+	u8 current_net_addr[ETH_ALEN];
+	u8 permanent_net_addr[ETH_ALEN];
 
-	int bExistSWNetAddr;
+	u8 exist_sw_net_addr;
 
-	u64 qwCurrTSF;
+	u64 current_tsf;
 
 	/* 802.11 MAC specific */
-	u32 uCurrRSSI;
+	u32 current_rssi;
 
 	/* Antenna Diversity */
-	int bTxRxAntInv;
-	u32 dwRxAntennaSel;
-	u32 dwTxAntennaSel;
-	u8 byAntennaCount;
-	u8 byRxAntennaMode;
-	u8 byTxAntennaMode;
-	u8 byRadioCtl;
-	u8 bHWRadioOff;
+	int tx_rx_ant_inv;
+	u32 rx_antenna_sel;
+	u8 rx_antenna_mode;
+	u8 tx_antenna_mode;
+	u8 radio_ctl;
 
 	/* IFS & Cw */
-	u32 uSIFS;  /* Current SIFS */
-	u32 uDIFS;  /* Current DIFS */
-	u32 uEIFS;  /* Current EIFS */
-	u32 uSlot;  /* Current SlotTime */
-	u32 uCwMin; /* Current CwMin */
-	u32 uCwMax; /* CwMax is fixed on 1023 */
+	u32 sifs;  /* Current SIFS */
+	u32 difs;  /* Current DIFS */
+	u32 eifs;  /* Current EIFS */
+	u32 slot;  /* Current SlotTime */
 
 	/* Rate */
-	u8 byBBType; /* 0: 11A, 1:11B, 2:11G */
-	u8 byPacketType; /* 0:11a 1:11b 2:11gb 3:11ga */
-	u32 wBasicRate;
-	u8 byTopOFDMBasicRate;
-	u8 byTopCCKBasicRate;
+	u8 bb_type; /* 0: 11A, 1:11B, 2:11G */
+	u8 packet_type; /* 0:11a 1:11b 2:11gb 3:11ga */
+	u32 basic_rates;
+	u8 top_ofdm_basic_rate;
+	u8 top_cck_basic_rate;
 
-	u8 abyEEPROM[EEP_MAX_CONTEXT_SIZE];  /*u32 alignment */
+	u8 eeprom[EEP_MAX_CONTEXT_SIZE];  /*u32 alignment */
 
-	u8 byPreambleType;
+	u8 preamble_type;
 
 	/* For RF Power table */
-	u8 byCCKPwr;
-	u8 byOFDMPwrG;
-	u8 byOFDMPwrA;
-	u8 byCurPwr;
-	u8 abyCCKPwrTbl[14];
-	u8 abyOFDMPwrTbl[14];
-	u8 abyOFDMAPwrTbl[42];
+	u8 cck_pwr;
+	u8 ofdm_pwr_g;
+	u8 ofdm_pwr_a;
+	u8 power;
+	u8 cck_pwr_tbl[14];
+	u8 ofdm_pwr_tbl[14];
+	u8 ofdm_a_pwr_tbl[42];
 
-	u16 wCurrentRate;
+	u16 current_rate;
 	u16 tx_rate_fb0;
 	u16 tx_rate_fb1;
 
-	u8 byShortRetryLimit;
-	u8 byLongRetryLimit;
+	u8 short_retry_limit;
+	u8 long_retry_limit;
 
 	enum nl80211_iftype op_mode;
 
-	int bShortSlotTime;
-	int bBarkerPreambleMd;
-
-	int bRadioControlOff;
-	int bRadioOff;
+	int short_slot_time;
 
 	/* Power save */
 	u16 current_aid;
 
 	/* Beacon releated */
-	u16 wSeqCounter;
+	u16 seq_counter;
 
 	enum vnt_cmd_state command_state;
 
 	enum vnt_cmd command;
 
-	int bStopDataPkt;
-
 	/* 802.11 counter */
 
 	enum vnt_cmd cmd_queue[CMD_Q_SIZE];
@@ -414,38 +384,25 @@
 
 	unsigned long key_entry_inuse;
 
-	u8 byAutoFBCtrl;
+	u8 auto_fb_ctrl;
 
 	/* For Update BaseBand VGA Gain Offset */
-	u32 uBBVGADiffCount;
-	u8 byBBVGANew;
-	u8 byBBVGACurrent;
-	u8 abyBBVGA[BB_VGA_LEVEL];
-	signed long ldBmThreshold[BB_VGA_LEVEL];
+	u8 bb_vga[BB_VGA_LEVEL];
 
-	u8 byBBPreEDRSSI;
-	u8 byBBPreEDIndex;
-
-	int bRadioCmd;
+	u8 bb_pre_ed_rssi;
+	u8 bb_pre_ed_index;
 
 	/* command timer */
 	struct delayed_work run_command_work;
 
-	u8 tx_data_time_out;
-
-	int bChannelSwitch;
-	u8 byNewChannel;
-	u8 byChannelSwitchCount;
-
-	struct iw_statistics wstats; /* wireless stats */
 	struct ieee80211_low_level_stats low_stats;
 };
 
-#define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) {   \
-    if ((uVar) >= ((uModulo) - 1))                  \
-        (uVar) = 0;                                 \
-    else                                            \
-        (uVar)++;                                   \
+#define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) {	\
+	if ((uVar) >= ((uModulo) - 1))			\
+		(uVar) = 0;				\
+	else						\
+		(uVar)++;				\
 }
 
 #define fMP_DISCONNECTED                    0x00000002
diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c
index f3da0db..f5fbb5f 100644
--- a/drivers/staging/vt6656/dpc.c
+++ b/drivers/staging/vt6656/dpc.c
@@ -133,7 +133,7 @@
 
 	priv->tsf_time = le64_to_cpu(*tsf_time);
 
-	if (priv->byBBType == BB_TYPE_11G) {
+	if (priv->bb_type == BB_TYPE_11G) {
 		sq_3 = skb_data + 8 + pay_load_with_padding + 12;
 		sq = sq_3;
 	} else {
@@ -152,8 +152,8 @@
 
 	vnt_rf_rssi_to_dbm(priv, *rssi, &rx_dbm);
 
-	priv->byBBPreEDRSSI = (u8)rx_dbm + 1;
-	priv->uCurrRSSI = priv->byBBPreEDRSSI;
+	priv->bb_pre_ed_rssi = (u8)rx_dbm + 1;
+	priv->current_rssi = priv->bb_pre_ed_rssi;
 
 	frame = skb_data + 8;
 
@@ -175,7 +175,7 @@
 	rx_status.rate_idx = rate_idx;
 
 	if (ieee80211_has_protected(fc)) {
-		if (priv->byLocalID > REV_ID_VT3253_A1) {
+		if (priv->local_id > REV_ID_VT3253_A1) {
 			rx_status.flag |= RX_FLAG_DECRYPTED;
 
 			/* Drop packet */
diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c
index f2250ee..eae4f32d 100644
--- a/drivers/staging/vt6656/firmware.c
+++ b/drivers/staging/vt6656/firmware.c
@@ -118,24 +118,24 @@
 					0,
 					MESSAGE_REQUEST_VERSION,
 					2,
-					(u8 *) &(priv->wFirmwareVersion));
+					(u8 *)&priv->firmware_version);
 
 	dev_dbg(&priv->usb->dev, "Firmware Version [%04x]\n",
-						priv->wFirmwareVersion);
+						priv->firmware_version);
 
 	if (status != STATUS_SUCCESS) {
 		dev_dbg(&priv->usb->dev, "Firmware Invalid.\n");
 		return false;
 	}
-	if (priv->wFirmwareVersion == 0xFFFF) {
+	if (priv->firmware_version == 0xFFFF) {
 		dev_dbg(&priv->usb->dev, "In Loader.\n");
 		return false;
 	}
 
 	dev_dbg(&priv->usb->dev, "Firmware Version [%04x]\n",
-						priv->wFirmwareVersion);
+						priv->firmware_version);
 
-	if (priv->wFirmwareVersion < FIRMWARE_VERSION) {
+	if (priv->firmware_version < FIRMWARE_VERSION) {
 		/* branch to loader for download new firmware */
 		vnt_firmware_branch_to_sram(priv);
 		return false;
diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c
index 15841b8..2ef70e4 100644
--- a/drivers/staging/vt6656/int.c
+++ b/drivers/staging/vt6656/int.c
@@ -37,8 +37,6 @@
 #include "power.h"
 #include "usbpipe.h"
 
-static int msglevel = MSG_LEVEL_INFO; /* MSG_LEVEL_DEBUG */
-
 static const u8 fallback_rate0[5][5] = {
 	{RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M},
 	{RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M},
@@ -55,40 +53,18 @@
 	{RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M}
 };
 
-/*+
- *
- *  Function:   InterruptPollingThread
- *
- *  Synopsis:   Thread running at IRQL PASSIVE_LEVEL.
- *
- *  Arguments: Device Extension
- *
- *  Returns:
- *
- *  Algorithm:  Call USBD for input data;
- *
- *  History:    dd-mm-yyyy   Author    Comment
- *
- *
- *  Notes:
- *
- *  USB reads are by nature 'Blocking', and when in a read, the device looks
- *  like it's in a 'stall' condition, so we deliberately time out every second
- *  if we've gotten no data
- *
--*/
-void INTvWorkItem(struct vnt_private *pDevice)
+void vnt_int_start_interrupt(struct vnt_private *priv)
 {
 	unsigned long flags;
-	int ntStatus;
+	int status;
 
-	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n");
+	dev_dbg(&priv->usb->dev, "---->Interrupt Polling Thread\n");
 
-	spin_lock_irqsave(&pDevice->lock, flags);
+	spin_lock_irqsave(&priv->lock, flags);
 
-	ntStatus = PIPEnsInterruptRead(pDevice);
+	status = vnt_start_interrupt_urb(priv);
 
-	spin_unlock_irqrestore(&pDevice->lock, flags);
+	spin_unlock_irqrestore(&priv->lock, flags);
 }
 
 static int vnt_int_report_rate(struct vnt_private *priv, u8 pkt_no, u8 tsr)
@@ -99,10 +75,10 @@
 	u8 tx_retry = (tsr & 0xf0) >> 4;
 	s8 idx;
 
-	if (pkt_no >= priv->cbTD)
+	if (pkt_no >= priv->num_tx_context)
 		return -EINVAL;
 
-	context = priv->apTD[pkt_no];
+	context = priv->tx_context[pkt_no];
 
 	if (!context->skb)
 		return -EINVAL;
@@ -147,13 +123,12 @@
 	return 0;
 }
 
-void INTnsProcessData(struct vnt_private *priv)
+void vnt_int_process_data(struct vnt_private *priv)
 {
 	struct vnt_interrupt_data *int_data;
-	struct net_device_stats *stats = &priv->stats;
 	struct ieee80211_low_level_stats *low_stats = &priv->low_stats;
 
-	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n");
+	dev_dbg(&priv->usb->dev, "---->s_nsInterruptProcessData\n");
 
 	int_data = (struct vnt_interrupt_data *)priv->int_buf.data_buf;
 
@@ -178,16 +153,8 @@
 			if (priv->hw->conf.flags & IEEE80211_CONF_PS)
 				vnt_schedule_command(priv,
 							WLAN_CMD_TBTT_WAKEUP);
-#if 0 /* TODO channel switch */
-			if (priv->bChannelSwitch) {
-				priv->byChannelSwitchCount--;
-				if (priv->byChannelSwitchCount == 0)
-					vnt_schedule_command(priv,
-							WLAN_CMD_11H_CHSW);
-			}
-#endif
 		}
-		priv->qwCurrTSF = le64_to_cpu(int_data->tsf);
+		priv->current_tsf = le64_to_cpu(int_data->tsf);
 
 		low_stats->dot11RTSSuccessCount += int_data->rts_success;
 		low_stats->dot11RTSFailureCount += int_data->rts_fail;
@@ -196,7 +163,4 @@
 	}
 
 	priv->int_buf.in_use = false;
-
-	stats->tx_errors = priv->wstats.discard.retries;
-	stats->tx_dropped = priv->wstats.discard.retries;
 }
diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h
index 08db868..154605c 100644
--- a/drivers/staging/vt6656/int.h
+++ b/drivers/staging/vt6656/int.h
@@ -55,7 +55,7 @@
 	u8 sw[2];
 } __packed;
 
-void INTvWorkItem(struct vnt_private *);
-void INTnsProcessData(struct vnt_private *);
+void vnt_int_start_interrupt(struct vnt_private *);
+void vnt_int_process_data(struct vnt_private *);
 
 #endif /* __INT_H__ */
diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
index b76ee31..22f2961 100644
--- a/drivers/staging/vt6656/key.c
+++ b/drivers/staging/vt6656/key.c
@@ -158,7 +158,7 @@
 
 		break;
 	case WLAN_CIPHER_SUITE_CCMP:
-		if (priv->byLocalID <= MAC_REVISION_A1)
+		if (priv->local_id <= MAC_REVISION_A1)
 			return -EINVAL;
 
 		key_dec_mode = KEY_CTL_CCMP;
diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h
index 3e17457..d53fcef 100644
--- a/drivers/staging/vt6656/mac.h
+++ b/drivers/staging/vt6656/mac.h
@@ -36,371 +36,326 @@
 
 #include "device.h"
 
-#define REV_ID_VT3253_A0    0x00
-#define REV_ID_VT3253_A1    0x01
-#define REV_ID_VT3253_B0    0x08
-#define REV_ID_VT3253_B1    0x09
+#define REV_ID_VT3253_A0	0x00
+#define REV_ID_VT3253_A1	0x01
+#define REV_ID_VT3253_B0	0x08
+#define REV_ID_VT3253_B1	0x09
 
-//
-// Registers in the MAC
-//
-#define MAC_REG_BISTCMD     0x04
-#define MAC_REG_BISTSR0     0x05
-#define MAC_REG_BISTSR1     0x06
-#define MAC_REG_BISTSR2     0x07
-#define MAC_REG_I2MCSR      0x08
-#define MAC_REG_I2MTGID     0x09
-#define MAC_REG_I2MTGAD     0x0A
-#define MAC_REG_I2MCFG      0x0B
-#define MAC_REG_I2MDIPT     0x0C
-#define MAC_REG_I2MDOPT     0x0E
-#define MAC_REG_USBSUS      0x0F
+/* Registers in the MAC */
+#define MAC_REG_BISTCMD		0x04
+#define MAC_REG_BISTSR0		0x05
+#define MAC_REG_BISTSR1		0x06
+#define MAC_REG_BISTSR2		0x07
+#define MAC_REG_I2MCSR		0x08
+#define MAC_REG_I2MTGID		0x09
+#define MAC_REG_I2MTGAD		0x0a
+#define MAC_REG_I2MCFG		0x0b
+#define MAC_REG_I2MDIPT		0x0c
+#define MAC_REG_I2MDOPT		0x0e
+#define MAC_REG_USBSUS		0x0f
 
-#define MAC_REG_LOCALID     0x14
-#define MAC_REG_TESTCFG     0x15
-#define MAC_REG_JUMPER0     0x16
-#define MAC_REG_JUMPER1     0x17
-#define MAC_REG_TMCTL       0x18
-#define MAC_REG_TMDATA0     0x1C
-#define MAC_REG_TMDATA1     0x1D
-#define MAC_REG_TMDATA2     0x1E
-#define MAC_REG_TMDATA3     0x1F
+#define MAC_REG_LOCALID		0x14
+#define MAC_REG_TESTCFG		0x15
+#define MAC_REG_JUMPER0		0x16
+#define MAC_REG_JUMPER1		0x17
+#define MAC_REG_TMCTL		0x18
+#define MAC_REG_TMDATA0		0x1c
+#define MAC_REG_TMDATA1		0x1d
+#define MAC_REG_TMDATA2		0x1e
+#define MAC_REG_TMDATA3		0x1f
 
-// MAC Parameter related
-#define MAC_REG_LRT         0x20        //
-#define MAC_REG_SRT         0x21        //
-#define MAC_REG_SIFS        0x22        //
-#define MAC_REG_DIFS        0x23        //
-#define MAC_REG_EIFS        0x24        //
-#define MAC_REG_SLOT        0x25        //
-#define MAC_REG_BI          0x26        //
-#define MAC_REG_CWMAXMIN0   0x28        //
-#define MAC_REG_LINKOFFTOTM 0x2A
-#define MAC_REG_SWTMOT      0x2B
-#define MAC_REG_RTSOKCNT    0x2C
-#define MAC_REG_RTSFAILCNT  0x2D
-#define MAC_REG_ACKFAILCNT  0x2E
-#define MAC_REG_FCSERRCNT   0x2F
-// TSF Related
-#define MAC_REG_TSFCNTR     0x30        //
-#define MAC_REG_NEXTTBTT    0x38        //
-#define MAC_REG_TSFOFST     0x40        //
-#define MAC_REG_TFTCTL      0x48        //
-// WMAC Control/Status Related
-#define MAC_REG_ENCFG0      0x4C        //
-#define MAC_REG_ENCFG1      0x4D        //
-#define MAC_REG_ENCFG2      0x4E        //
+/* MAC Parameter related */
+#define MAC_REG_LRT		0x20
+#define MAC_REG_SRT		0x21
+#define MAC_REG_SIFS		0x22
+#define MAC_REG_DIFS		0x23
+#define MAC_REG_EIFS		0x24
+#define MAC_REG_SLOT		0x25
+#define MAC_REG_BI		0x26
+#define MAC_REG_CWMAXMIN0	0x28
+#define MAC_REG_LINKOFFTOTM	0x2a
+#define MAC_REG_SWTMOT		0x2b
+#define MAC_REG_RTSOKCNT	0x2c
+#define MAC_REG_RTSFAILCNT	0x2d
+#define MAC_REG_ACKFAILCNT	0x2e
+#define MAC_REG_FCSERRCNT	0x2f
 
-#define MAC_REG_CFG         0x50        //
-#define MAC_REG_TEST        0x52        //
-#define MAC_REG_HOSTCR      0x54        //
-#define MAC_REG_MACCR       0x55        //
-#define MAC_REG_RCR         0x56        //
-#define MAC_REG_TCR         0x57        //
-#define MAC_REG_IMR         0x58        //
-#define MAC_REG_ISR         0x5C
-#define MAC_REG_ISR1        0x5D
-// Power Saving Related
-#define MAC_REG_PSCFG       0x60        //
-#define MAC_REG_PSCTL       0x61        //
-#define MAC_REG_PSPWRSIG    0x62        //
-#define MAC_REG_BBCR13      0x63
-#define MAC_REG_AIDATIM     0x64
-#define MAC_REG_PWBT        0x66
-#define MAC_REG_WAKEOKTMR   0x68
-#define MAC_REG_CALTMR      0x69
-#define MAC_REG_SYNSPACCNT  0x6A
-#define MAC_REG_WAKSYNOPT   0x6B
-// Baseband/IF Control Group
-#define MAC_REG_BBREGCTL    0x6C        //
-#define MAC_REG_CHANNEL     0x6D
-#define MAC_REG_BBREGADR    0x6E
-#define MAC_REG_BBREGDATA   0x6F
-#define MAC_REG_IFREGCTL    0x70        //
-#define MAC_REG_IFDATA      0x71        //
-#define MAC_REG_ITRTMSET    0x74        //
-#define MAC_REG_PAPEDELAY   0x77
-#define MAC_REG_SOFTPWRCTL  0x78        //
-#define MAC_REG_SOFTPWRCTL2 0x79        //
-#define MAC_REG_GPIOCTL0    0x7A        //
-#define MAC_REG_GPIOCTL1    0x7B        //
+/* TSF Related */
+#define MAC_REG_TSFCNTR		0x30
+#define MAC_REG_NEXTTBTT	0x38
+#define MAC_REG_TSFOFST		0x40
+#define MAC_REG_TFTCTL		0x48
 
-// MiscFF PIO related
-#define MAC_REG_MISCFFNDEX  0xBC
-#define MAC_REG_MISCFFCTL   0xBE
-#define MAC_REG_MISCFFDATA  0xC0
+/* WMAC Control/Status Related */
+#define MAC_REG_ENCFG0		0x4c
+#define MAC_REG_ENCFG1		0x4d
+#define MAC_REG_ENCFG2		0x4e
 
-// MAC Configuration Group
-#define MAC_REG_PAR0        0xC4
-#define MAC_REG_PAR4        0xC8
-#define MAC_REG_BSSID0      0xCC
-#define MAC_REG_BSSID4      0xD0
-#define MAC_REG_MAR0        0xD4
-#define MAC_REG_MAR4        0xD8
-// MAC RSPPKT INFO Group
-#define MAC_REG_RSPINF_B_1  0xDC
-#define MAC_REG_RSPINF_B_2  0xE0
-#define MAC_REG_RSPINF_B_5  0xE4
-#define MAC_REG_RSPINF_B_11 0xE8
-#define MAC_REG_RSPINF_A_6  0xEC
-#define MAC_REG_RSPINF_A_9  0xEE
-#define MAC_REG_RSPINF_A_12 0xF0
-#define MAC_REG_RSPINF_A_18 0xF2
-#define MAC_REG_RSPINF_A_24 0xF4
-#define MAC_REG_RSPINF_A_36 0xF6
-#define MAC_REG_RSPINF_A_48 0xF8
-#define MAC_REG_RSPINF_A_54 0xFA
-#define MAC_REG_RSPINF_A_72 0xFC
+#define MAC_REG_CFG		0x50
+#define MAC_REG_TEST		0x52
+#define MAC_REG_HOSTCR		0x54
+#define MAC_REG_MACCR		0x55
+#define MAC_REG_RCR		0x56
+#define MAC_REG_TCR		0x57
+#define MAC_REG_IMR		0x58
+#define MAC_REG_ISR		0x5c
+#define MAC_REG_ISR1		0x5d
 
-//
-// Bits in the I2MCFG EEPROM register
-//
-#define I2MCFG_BOUNDCTL     0x80
-#define I2MCFG_WAITCTL      0x20
-#define I2MCFG_SCLOECTL     0x10
-#define I2MCFG_WBUSYCTL     0x08
-#define I2MCFG_NORETRY      0x04
-#define I2MCFG_I2MLDSEQ     0x02
-#define I2MCFG_I2CMFAST     0x01
+/* Power Saving Related */
+#define MAC_REG_PSCFG		0x60
+#define MAC_REG_PSCTL		0x61
+#define MAC_REG_PSPWRSIG	0x62
+#define MAC_REG_BBCR13		0x63
+#define MAC_REG_AIDATIM		0x64
+#define MAC_REG_PWBT		0x66
+#define MAC_REG_WAKEOKTMR	0x68
+#define MAC_REG_CALTMR		0x69
+#define MAC_REG_SYNSPACCNT	0x6a
+#define MAC_REG_WAKSYNOPT	0x6b
 
-//
-// Bits in the I2MCSR EEPROM register
-//
-#define I2MCSR_EEMW         0x80
-#define I2MCSR_EEMR         0x40
-#define I2MCSR_AUTOLD       0x08
-#define I2MCSR_NACK         0x02
-#define I2MCSR_DONE         0x01
+/* Baseband/IF Control Group */
+#define MAC_REG_BBREGCTL	0x6c
+#define MAC_REG_CHANNEL		0x6d
+#define MAC_REG_BBREGADR	0x6e
+#define MAC_REG_BBREGDATA	0x6f
+#define MAC_REG_IFREGCTL	0x70
+#define MAC_REG_IFDATA		0x71
+#define MAC_REG_ITRTMSET	0x74
+#define MAC_REG_PAPEDELAY	0x77
+#define MAC_REG_SOFTPWRCTL	0x78
+#define MAC_REG_SOFTPWRCTL2	0x79
+#define MAC_REG_GPIOCTL0	0x7a
+#define MAC_REG_GPIOCTL1	0x7b
 
-//
-// Bits in the TMCTL register
-//
-#define TMCTL_TSUSP         0x04
-#define TMCTL_TMD           0x02
-#define TMCTL_TE            0x01
+/* MiscFF PIO related */
+#define MAC_REG_MISCFFNDEX	0xbc
+#define MAC_REG_MISCFFCTL	0xbe
+#define MAC_REG_MISCFFDATA	0xc0
 
-//
-// Bits in the TFTCTL register
-//
-#define TFTCTL_HWUTSF       0x80        //
-#define TFTCTL_TBTTSYNC     0x40
-#define TFTCTL_HWUTSFEN     0x20
-#define TFTCTL_TSFCNTRRD    0x10        //
-#define TFTCTL_TBTTSYNCEN   0x08        //
-#define TFTCTL_TSFSYNCEN    0x04        //
-#define TFTCTL_TSFCNTRST    0x02        //
-#define TFTCTL_TSFCNTREN    0x01        //
+/* MAC Configuration Group */
+#define MAC_REG_PAR0		0xc4
+#define MAC_REG_PAR4		0xc8
+#define MAC_REG_BSSID0		0xcc
+#define MAC_REG_BSSID4		0xd0
+#define MAC_REG_MAR0		0xd4
+#define MAC_REG_MAR4		0xd8
 
-//
-// Bits in the EnhanceCFG_0 register
-//
-#define EnCFG_BBType_a      0x00
-#define EnCFG_BBType_b      0x01
-#define EnCFG_BBType_g      0x02
-#define EnCFG_BBType_MASK   0x03
-#define EnCFG_ProtectMd     0x20
+/* MAC RSPPKT INFO Group */
+#define MAC_REG_RSPINF_B_1	0xdC
+#define MAC_REG_RSPINF_B_2	0xe0
+#define MAC_REG_RSPINF_B_5	0xe4
+#define MAC_REG_RSPINF_B_11	0xe8
+#define MAC_REG_RSPINF_A_6	0xec
+#define MAC_REG_RSPINF_A_9	0xee
+#define MAC_REG_RSPINF_A_12	0xf0
+#define MAC_REG_RSPINF_A_18	0xf2
+#define MAC_REG_RSPINF_A_24	0xf4
+#define MAC_REG_RSPINF_A_36	0xf6
+#define MAC_REG_RSPINF_A_48	0xf8
+#define MAC_REG_RSPINF_A_54	0xfa
+#define MAC_REG_RSPINF_A_72	0xfc
 
-//
-// Bits in the EnhanceCFG_1 register
-//
-#define EnCFG_BcnSusInd     0x01
-#define EnCFG_BcnSusClr     0x02
+/* Bits in the I2MCFG EEPROM register */
+#define I2MCFG_BOUNDCTL		0x80
+#define I2MCFG_WAITCTL		0x20
+#define I2MCFG_SCLOECTL		0x10
+#define I2MCFG_WBUSYCTL		0x08
+#define I2MCFG_NORETRY		0x04
+#define I2MCFG_I2MLDSEQ		0x02
+#define I2MCFG_I2CMFAST		0x01
 
-//
-// Bits in the EnhanceCFG_2 register
-//
-#define EnCFG_NXTBTTCFPSTR  0x01
-#define EnCFG_BarkerPream   0x02
-#define EnCFG_PktBurstMode  0x04
+/* Bits in the I2MCSR EEPROM register */
+#define I2MCSR_EEMW		0x80
+#define I2MCSR_EEMR		0x40
+#define I2MCSR_AUTOLD		0x08
+#define I2MCSR_NACK		0x02
+#define I2MCSR_DONE		0x01
 
-//
-// Bits in the CFG register
-//
-#define CFG_TKIPOPT         0x80
-#define CFG_RXDMAOPT        0x40
-#define CFG_TMOT_SW         0x20
-#define CFG_TMOT_HWLONG     0x10
-#define CFG_TMOT_HW         0x00
-#define CFG_CFPENDOPT       0x08
-#define CFG_BCNSUSEN        0x04
-#define CFG_NOTXTIMEOUT     0x02
-#define CFG_NOBUFOPT        0x01
+/* Bits in the TMCTL register */
+#define TMCTL_TSUSP		0x04
+#define TMCTL_TMD		0x02
+#define TMCTL_TE		0x01
 
-//
-// Bits in the TEST register
-//
-#define TEST_LBEXT          0x80        //
-#define TEST_LBINT          0x40        //
-#define TEST_LBNONE         0x00        //
-#define TEST_SOFTINT        0x20        //
-#define TEST_CONTTX         0x10        //
-#define TEST_TXPE           0x08        //
-#define TEST_NAVDIS         0x04        //
-#define TEST_NOCTS          0x02        //
-#define TEST_NOACK          0x01        //
+/* Bits in the TFTCTL register */
+#define TFTCTL_HWUTSF		0x80
+#define TFTCTL_TBTTSYNC		0x40
+#define TFTCTL_HWUTSFEN		0x20
+#define TFTCTL_TSFCNTRRD	0x10
+#define TFTCTL_TBTTSYNCEN	0x08
+#define TFTCTL_TSFSYNCEN	0x04
+#define TFTCTL_TSFCNTRST	0x02
+#define TFTCTL_TSFCNTREN	0x01
 
-//
-// Bits in the HOSTCR register
-//
-#define HOSTCR_TXONST       0x80        //
-#define HOSTCR_RXONST       0x40        //
-#define HOSTCR_ADHOC        0x20        // Network Type 1 = Ad-hoc
-#define HOSTCR_AP           0x10        // Port Type 1 = AP
-#define HOSTCR_TXON         0x08        //0000 1000
-#define HOSTCR_RXON         0x04        //0000 0100
-#define HOSTCR_MACEN        0x02        //0000 0010
-#define HOSTCR_SOFTRST      0x01        //0000 0001
+/* Bits in the EnhanceCFG_0 register */
+#define EnCFG_BBType_a		0x00
+#define EnCFG_BBType_b		0x01
+#define EnCFG_BBType_g		0x02
+#define EnCFG_BBType_MASK	0x03
+#define EnCFG_ProtectMd		0x20
 
-//
-// Bits in the MACCR register
-//
-#define MACCR_SYNCFLUSHOK   0x04        //
-#define MACCR_SYNCFLUSH     0x02        //
-#define MACCR_CLRNAV        0x01        //
+/* Bits in the EnhanceCFG_1 register */
+#define EnCFG_BcnSusInd		0x01
+#define EnCFG_BcnSusClr		0x02
 
-//
-// Bits in the RCR register
-//
-#define RCR_SSID            0x80
-#define RCR_RXALLTYPE       0x40        //
-#define RCR_UNICAST         0x20        //
-#define RCR_BROADCAST       0x10        //
-#define RCR_MULTICAST       0x08        //
-#define RCR_WPAERR          0x04        //
-#define RCR_ERRCRC          0x02        //
-#define RCR_BSSID           0x01        //
+/* Bits in the EnhanceCFG_2 register */
+#define EnCFG_NXTBTTCFPSTR	0x01
+#define EnCFG_BarkerPream	0x02
+#define EnCFG_PktBurstMode	0x04
 
-//
-// Bits in the TCR register
-//
-#define TCR_SYNCDCFOPT      0x02        //
-#define TCR_AUTOBCNTX       0x01        // Beacon automatically transmit enable
+/* Bits in the CFG register */
+#define CFG_TKIPOPT		0x80
+#define CFG_RXDMAOPT		0x40
+#define CFG_TMOT_SW		0x20
+#define CFG_TMOT_HWLONG		0x10
+#define CFG_TMOT_HW		0x00
+#define CFG_CFPENDOPT		0x08
+#define CFG_BCNSUSEN		0x04
+#define CFG_NOTXTIMEOUT		0x02
+#define CFG_NOBUFOPT		0x01
 
-//ISR1
-#define ISR_GPIO3           0x40
-#define ISR_RXNOBUF         0x08
-#define ISR_MIBNEARFULL     0x04
-#define ISR_SOFTINT         0x02
-#define ISR_FETALERR        0x01
+/* Bits in the TEST register */
+#define TEST_LBEXT		0x80
+#define TEST_LBINT		0x40
+#define TEST_LBNONE		0x00
+#define TEST_SOFTINT		0x20
+#define TEST_CONTTX		0x10
+#define TEST_TXPE		0x08
+#define TEST_NAVDIS		0x04
+#define TEST_NOCTS		0x02
+#define TEST_NOACK		0x01
 
-#define LEDSTS_STS          0x06
-#define LEDSTS_TMLEN        0x78
-#define LEDSTS_OFF          0x00
-#define LEDSTS_ON           0x02
-#define LEDSTS_SLOW         0x04
-#define LEDSTS_INTER        0x06
+/* Bits in the HOSTCR register */
+#define HOSTCR_TXONST		0x80
+#define HOSTCR_RXONST		0x40
+#define HOSTCR_ADHOC		0x20
+#define HOSTCR_AP		0x10
+#define HOSTCR_TXON		0x08
+#define HOSTCR_RXON		0x04
+#define HOSTCR_MACEN		0x02
+#define HOSTCR_SOFTRST		0x01
 
-//ISR0
-#define ISR_WATCHDOG        0x80
-#define ISR_SOFTTIMER       0x40
-#define ISR_GPIO0           0x20
-#define ISR_TBTT            0x10
-#define ISR_RXDMA0          0x08
-#define ISR_BNTX            0x04
-#define ISR_ACTX            0x01
+/* Bits in the MACCR register */
+#define MACCR_SYNCFLUSHOK	0x04
+#define MACCR_SYNCFLUSH		0x02
+#define MACCR_CLRNAV		0x01
 
-//
-// Bits in the PSCFG register
-//
-#define PSCFG_PHILIPMD      0x40        //
-#define PSCFG_WAKECALEN     0x20        //
-#define PSCFG_WAKETMREN     0x10        //
-#define PSCFG_BBPSPROG      0x08        //
-#define PSCFG_WAKESYN       0x04        //
-#define PSCFG_SLEEPSYN      0x02        //
-#define PSCFG_AUTOSLEEP     0x01        //
+/* Bits in the RCR register */
+#define RCR_SSID		0x80
+#define RCR_RXALLTYPE		0x40
+#define RCR_UNICAST		0x20
+#define RCR_BROADCAST		0x10
+#define RCR_MULTICAST		0x08
+#define RCR_WPAERR		0x04
+#define RCR_ERRCRC		0x02
+#define RCR_BSSID		0x01
 
-//
-// Bits in the PSCTL register
-//
-#define PSCTL_WAKEDONE      0x20        //
-#define PSCTL_PS            0x10        //
-#define PSCTL_GO2DOZE       0x08        //
-#define PSCTL_LNBCN         0x04        //
-#define PSCTL_ALBCN         0x02        //
-#define PSCTL_PSEN          0x01        //
+/* Bits in the TCR register */
+#define TCR_SYNCDCFOPT		0x02
+#define TCR_AUTOBCNTX		0x01
 
-//
-// Bits in the PSPWSIG register
-//
-#define PSSIG_WPE3          0x80        //
-#define PSSIG_WPE2          0x40        //
-#define PSSIG_WPE1          0x20        //
-#define PSSIG_WRADIOPE      0x10        //
-#define PSSIG_SPE3          0x08        //
-#define PSSIG_SPE2          0x04        //
-#define PSSIG_SPE1          0x02        //
-#define PSSIG_SRADIOPE      0x01        //
+/* ISR1 */
+#define ISR_GPIO3		0x40
+#define ISR_RXNOBUF		0x08
+#define ISR_MIBNEARFULL		0x04
+#define ISR_SOFTINT		0x02
+#define ISR_FETALERR		0x01
 
-//
-// Bits in the BBREGCTL register
-//
-#define BBREGCTL_DONE       0x04        //
-#define BBREGCTL_REGR       0x02        //
-#define BBREGCTL_REGW       0x01        //
+#define LEDSTS_STS		0x06
+#define LEDSTS_TMLEN		0x78
+#define LEDSTS_OFF		0x00
+#define LEDSTS_ON		0x02
+#define LEDSTS_SLOW		0x04
+#define LEDSTS_INTER		0x06
 
-//
-// Bits in the IFREGCTL register
-//
-#define IFREGCTL_DONE       0x04        //
-#define IFREGCTL_IFRF       0x02        //
-#define IFREGCTL_REGW       0x01        //
+/* ISR0 */
+#define ISR_WATCHDOG		0x80
+#define ISR_SOFTTIMER		0x40
+#define ISR_GPIO0		0x20
+#define ISR_TBTT		0x10
+#define ISR_RXDMA0		0x08
+#define ISR_BNTX		0x04
+#define ISR_ACTX		0x01
 
-//
-// Bits in the SOFTPWRCTL register
-//
-#define SOFTPWRCTL_RFLEOPT      0x08  //
-#define SOFTPWRCTL_TXPEINV      0x02  //
-#define SOFTPWRCTL_SWPECTI      0x01  //
-#define SOFTPWRCTL_SWPAPE       0x20  //
-#define SOFTPWRCTL_SWCALEN      0x10  //
-#define SOFTPWRCTL_SWRADIO_PE   0x08  //
-#define SOFTPWRCTL_SWPE2        0x04  //
-#define SOFTPWRCTL_SWPE1        0x02  //
-#define SOFTPWRCTL_SWPE3        0x01  //
+/* Bits in the PSCFG register */
+#define PSCFG_PHILIPMD		0x40
+#define PSCFG_WAKECALEN		0x20
+#define PSCFG_WAKETMREN		0x10
+#define PSCFG_BBPSPROG		0x08
+#define PSCFG_WAKESYN		0x04
+#define PSCFG_SLEEPSYN		0x02
+#define PSCFG_AUTOSLEEP		0x01
 
-//
-// Bits in the GPIOCTL1 register
-//
-#define GPIO3_MD                0x20    //
-#define GPIO3_DATA              0x40    //
-#define GPIO3_INTMD             0x80    //
+/* Bits in the PSCTL register */
+#define PSCTL_WAKEDONE		0x20
+#define PSCTL_PS		0x10
+#define PSCTL_GO2DOZE		0x08
+#define PSCTL_LNBCN		0x04
+#define PSCTL_ALBCN		0x02
+#define PSCTL_PSEN		0x01
 
-//
-// Bits in the MISCFFCTL register
-//
-#define MISCFFCTL_WRITE     0x0001      //
+/* Bits in the PSPWSIG register */
+#define PSSIG_WPE3		0x80
+#define PSSIG_WPE2		0x40
+#define PSSIG_WPE1		0x20
+#define PSSIG_WRADIOPE		0x10
+#define PSSIG_SPE3		0x08
+#define PSSIG_SPE2		0x04
+#define PSSIG_SPE1		0x02
+#define PSSIG_SRADIOPE		0x01
 
-// Loopback mode
-#define MAC_LB_EXT          0x02        //
-#define MAC_LB_INTERNAL     0x01        //
-#define MAC_LB_NONE         0x00        //
+/* Bits in the BBREGCTL register */
+#define BBREGCTL_DONE		0x04
+#define BBREGCTL_REGR		0x02
+#define BBREGCTL_REGW		0x01
 
-// Ethernet address filter type
-#define PKT_TYPE_NONE           0x00    // turn off receiver
-#define PKT_TYPE_ALL_MULTICAST  0x80
-#define PKT_TYPE_PROMISCUOUS    0x40
-#define PKT_TYPE_DIRECTED       0x20    // obselete, directed address is always accepted
-#define PKT_TYPE_BROADCAST      0x10
-#define PKT_TYPE_MULTICAST      0x08
-#define PKT_TYPE_ERROR_WPA      0x04
-#define PKT_TYPE_ERROR_CRC      0x02
-#define PKT_TYPE_BSSID          0x01
+/* Bits in the IFREGCTL register */
+#define IFREGCTL_DONE		0x04
+#define IFREGCTL_IFRF		0x02
+#define IFREGCTL_REGW		0x01
+
+/* Bits in the SOFTPWRCTL register */
+#define SOFTPWRCTL_RFLEOPT	0x08
+#define SOFTPWRCTL_TXPEINV	0x02
+#define SOFTPWRCTL_SWPECTI	0x01
+#define SOFTPWRCTL_SWPAPE	0x20
+#define SOFTPWRCTL_SWCALEN	0x10
+#define SOFTPWRCTL_SWRADIO_PE	0x08
+#define SOFTPWRCTL_SWPE2	0x04
+#define SOFTPWRCTL_SWPE1	0x02
+#define SOFTPWRCTL_SWPE3	0x01
+
+/* Bits in the GPIOCTL1 register */
+#define GPIO3_MD		0x20
+#define GPIO3_DATA		0x40
+#define GPIO3_INTMD		0x80
+
+/* Bits in the MISCFFCTL register */
+#define MISCFFCTL_WRITE		0x0001
+
+/* Loopback mode */
+#define MAC_LB_EXT		0x02
+#define MAC_LB_INTERNAL		0x01
+#define MAC_LB_NONE		0x00
+
+/* Ethernet address filter type */
+#define PKT_TYPE_NONE		0x00 /* turn off receiver */
+#define PKT_TYPE_ALL_MULTICAST	0x80
+#define PKT_TYPE_PROMISCUOUS	0x40
+#define PKT_TYPE_DIRECTED	0x20 /* obselete */
+#define PKT_TYPE_BROADCAST	0x10
+#define PKT_TYPE_MULTICAST	0x08
+#define PKT_TYPE_ERROR_WPA	0x04
+#define PKT_TYPE_ERROR_CRC	0x02
+#define PKT_TYPE_BSSID		0x01
 
 #define Default_BI              0x200
 
-// MiscFIFO Offset
-#define MISCFIFO_KEYETRY0       32
-#define MISCFIFO_KEYENTRYSIZE   22
+/* MiscFIFO Offset */
+#define MISCFIFO_KEYETRY0	32
+#define MISCFIFO_KEYENTRYSIZE	22
 
-// max time out delay time
-#define W_MAX_TIMEOUT       0xFFF0U     //
-
-// wait time within loop
-#define CB_DELAY_LOOP_WAIT  10          // 10ms
-
-#define MAC_REVISION_A0     0x00
-#define MAC_REVISION_A1     0x01
+#define MAC_REVISION_A0		0x00
+#define MAC_REVISION_A1		0x01
 
 struct vnt_mac_set_key {
 	union {
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index dffd0c7..b99def7 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -61,9 +61,6 @@
 #include "channel.h"
 #include "int.h"
 
-/* static int msglevel = MSG_LEVEL_DEBUG; */
-static int          msglevel                =MSG_LEVEL_INFO;
-
 /*
  * define module options
  */
@@ -75,77 +72,20 @@
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION(DEVICE_FULL_DRV_NAM);
 
-#define DEVICE_PARAM(N,D) \
-        static int N[MAX_UINTS]=OPTION_DEFAULT;\
-        module_param_array(N, int, NULL, 0);\
-        MODULE_PARM_DESC(N, D);
+#define RX_DESC_DEF0 64
+static int vnt_rx_buffers = RX_DESC_DEF0;
+module_param_named(rx_buffers, vnt_rx_buffers, int, 0644);
+MODULE_PARM_DESC(rx_buffers, "Number of receive usb rx buffers");
 
-#define RX_DESC_DEF0     64
-DEVICE_PARAM(RxDescriptors0,"Number of receive usb desc buffer");
-
-#define TX_DESC_DEF0     64
-DEVICE_PARAM(TxDescriptors0,"Number of transmit usb desc buffer");
-
-#define CHANNEL_DEF     6
-DEVICE_PARAM(Channel, "Channel number");
-
-/* PreambleType[] is the preamble length used for transmit.
-   0: indicate allows long preamble type
-   1: indicate allows short preamble type
-*/
-
-#define PREAMBLE_TYPE_DEF     1
-
-DEVICE_PARAM(PreambleType, "Preamble Type");
+#define TX_DESC_DEF0 64
+static int vnt_tx_buffers = TX_DESC_DEF0;
+module_param_named(tx_buffers, vnt_tx_buffers, int, 0644);
+MODULE_PARM_DESC(tx_buffers, "Number of receive usb tx buffers");
 
 #define RTS_THRESH_DEF     2347
-DEVICE_PARAM(RTSThreshold, "RTS threshold");
-
 #define FRAG_THRESH_DEF     2346
-DEVICE_PARAM(FragThreshold, "Fragmentation threshold");
-
-#define DATA_RATE_DEF     13
-/* datarate[] index
-   0: indicate 1 Mbps   0x02
-   1: indicate 2 Mbps   0x04
-   2: indicate 5.5 Mbps 0x0B
-   3: indicate 11 Mbps  0x16
-   4: indicate 6 Mbps   0x0c
-   5: indicate 9 Mbps   0x12
-   6: indicate 12 Mbps  0x18
-   7: indicate 18 Mbps  0x24
-   8: indicate 24 Mbps  0x30
-   9: indicate 36 Mbps  0x48
-  10: indicate 48 Mbps  0x60
-  11: indicate 54 Mbps  0x6c
-  12: indicate 72 Mbps  0x90
-  13: indicate auto rate
-*/
-
-DEVICE_PARAM(ConnectionRate, "Connection data rate");
-
-#define OP_MODE_DEF     0
-DEVICE_PARAM(OPMode, "Infrastruct, adhoc, AP mode ");
-
-/* OpMode[] is used for transmit.
-   0: indicate infrastruct mode used
-   1: indicate adhoc mode used
-   2: indicate AP mode used
-*/
-
-/* PSMode[]
-   0: indicate disable power saving mode
-   1: indicate enable power saving mode
-*/
-
-#define PS_MODE_DEF     0
-DEVICE_PARAM(PSMode, "Power saving mode");
-
 #define SHORT_RETRY_DEF     8
-DEVICE_PARAM(ShortRetryLimit, "Short frame retry limits");
-
 #define LONG_RETRY_DEF     4
-DEVICE_PARAM(LongRetryLimit, "long frame retry limits");
 
 /* BasebandType[] baseband type selected
    0: indicate 802.11a type
@@ -154,16 +94,6 @@
 */
 
 #define BBP_TYPE_DEF     2
-DEVICE_PARAM(BasebandType, "baseband type");
-
-/* 80211hEnable[]
-   0: indicate disable 802.11h
-   1: indicate enable 802.11h
-*/
-
-#define X80211h_MODE_DEF     0
-
-DEVICE_PARAM(b80211hEnable, "802.11h mode");
 
 /*
  * Static vars definitions
@@ -174,137 +104,116 @@
 	{}
 };
 
-/* frequency list (map channels to frequencies) */
-/*
-static const long frequency_list[] = {
-    2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484,
-    4915, 4920, 4925, 4935, 4940, 4945, 4960, 4980,
-    5035, 5040, 5045, 5055, 5060, 5080, 5170, 5180, 5190, 5200, 5210, 5220, 5230, 5240,
-    5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580, 5600, 5620, 5640, 5660, 5680,
-    5700, 5745, 5765, 5785, 5805, 5825
-	};
+static void device_set_options(struct vnt_private *priv)
+{
+	/* Set number of TX buffers */
+	if (vnt_tx_buffers < CB_MIN_TX_DESC || vnt_tx_buffers > CB_MAX_TX_DESC)
+		priv->num_tx_context = TX_DESC_DEF0;
+	else
+		priv->num_tx_context = vnt_tx_buffers;
 
-*/
+	/* Set number of RX buffers */
+	if (vnt_rx_buffers < CB_MIN_RX_DESC || vnt_rx_buffers > CB_MAX_RX_DESC)
+		priv->num_rcb = RX_DESC_DEF0;
+	else
+		priv->num_rcb = vnt_rx_buffers;
 
-static int vt6656_probe(struct usb_interface *intf,
-			const struct usb_device_id *id);
-static void vt6656_disconnect(struct usb_interface *intf);
-
-#ifdef CONFIG_PM	/* Minimal support for suspend and resume */
-static int vt6656_suspend(struct usb_interface *intf, pm_message_t message);
-static int vt6656_resume(struct usb_interface *intf);
-#endif /* CONFIG_PM */
-
-static int device_init_registers(struct vnt_private *pDevice);
-
-static void device_free_tx_bufs(struct vnt_private *pDevice);
-static void device_free_rx_bufs(struct vnt_private *pDevice);
-static void device_free_int_bufs(struct vnt_private *pDevice);
-static bool device_alloc_bufs(struct vnt_private *pDevice);
-
-static void usb_device_reset(struct vnt_private *pDevice);
-
-static void
-device_set_options(struct vnt_private *pDevice) {
-    pDevice->cbTD = TX_DESC_DEF0;
-    pDevice->cbRD = RX_DESC_DEF0;
-    pDevice->byShortRetryLimit = SHORT_RETRY_DEF;
-    pDevice->byLongRetryLimit = LONG_RETRY_DEF;
-    pDevice->op_mode = NL80211_IFTYPE_UNSPECIFIED;
-    pDevice->byBBType = BBP_TYPE_DEF;
-    pDevice->byPacketType = pDevice->byBBType;
-    pDevice->byAutoFBCtrl = AUTO_FB_0;
-    pDevice->byPreambleType = 0;
-    pDevice->bExistSWNetAddr = false;
+	priv->short_retry_limit = SHORT_RETRY_DEF;
+	priv->long_retry_limit = LONG_RETRY_DEF;
+	priv->op_mode = NL80211_IFTYPE_UNSPECIFIED;
+	priv->bb_type = BBP_TYPE_DEF;
+	priv->packet_type = priv->bb_type;
+	priv->auto_fb_ctrl = AUTO_FB_0;
+	priv->preamble_type = 0;
+	priv->exist_sw_net_addr = false;
 }
 
 /*
  * initialization of MAC & BBP registers
  */
-static int device_init_registers(struct vnt_private *pDevice)
+static int device_init_registers(struct vnt_private *priv)
 {
-	struct vnt_cmd_card_init *init_cmd = &pDevice->init_command;
-	struct vnt_rsp_card_init *init_rsp = &pDevice->init_response;
-	u8 byAntenna;
+	struct vnt_cmd_card_init *init_cmd = &priv->init_command;
+	struct vnt_rsp_card_init *init_rsp = &priv->init_response;
+	u8 antenna;
 	int ii;
-	int ntStatus = STATUS_SUCCESS;
-	u8 byTmp;
-	u8 byCalibTXIQ = 0, byCalibTXDC = 0, byCalibRXIQ = 0;
+	int status = STATUS_SUCCESS;
+	u8 tmp;
+	u8 calib_tx_iq = 0, calib_tx_dc = 0, calib_rx_iq = 0;
 
-	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n",
-				DEVICE_INIT_COLD, pDevice->byPacketType);
+	dev_dbg(&priv->usb->dev, "---->INIbInitAdapter. [%d][%d]\n",
+				DEVICE_INIT_COLD, priv->packet_type);
 
-	if (!vnt_check_firmware_version(pDevice)) {
-		if (vnt_download_firmware(pDevice) == true) {
-			if (vnt_firmware_branch_to_sram(pDevice) == false) {
-				DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+	if (!vnt_check_firmware_version(priv)) {
+		if (vnt_download_firmware(priv) == true) {
+			if (vnt_firmware_branch_to_sram(priv) == false) {
+				dev_dbg(&priv->usb->dev,
 					" vnt_firmware_branch_to_sram fail\n");
 				return false;
 			}
 		} else {
-			DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
-				" FIRMWAREbDownload fail\n");
+			dev_dbg(&priv->usb->dev, "FIRMWAREbDownload fail\n");
 			return false;
 		}
 	}
 
-	if (!BBbVT3184Init(pDevice)) {
-		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" BBbVT3184Init fail\n");
+	if (!vnt_vt3184_init(priv)) {
+		dev_dbg(&priv->usb->dev, "vnt_vt3184_init fail\n");
 		return false;
 	}
 
 	init_cmd->init_class = DEVICE_INIT_COLD;
-	init_cmd->exist_sw_net_addr = (u8) pDevice->bExistSWNetAddr;
+	init_cmd->exist_sw_net_addr = priv->exist_sw_net_addr;
 	for (ii = 0; ii < 6; ii++)
-		init_cmd->sw_net_addr[ii] = pDevice->abyCurrentNetAddr[ii];
-	init_cmd->short_retry_limit = pDevice->byShortRetryLimit;
-	init_cmd->long_retry_limit = pDevice->byLongRetryLimit;
+		init_cmd->sw_net_addr[ii] = priv->current_net_addr[ii];
+	init_cmd->short_retry_limit = priv->short_retry_limit;
+	init_cmd->long_retry_limit = priv->long_retry_limit;
 
 	/* issue card_init command to device */
-	ntStatus = vnt_control_out(pDevice,
+	status = vnt_control_out(priv,
 		MESSAGE_TYPE_CARDINIT, 0, 0,
 		sizeof(struct vnt_cmd_card_init), (u8 *)init_cmd);
-	if (ntStatus != STATUS_SUCCESS) {
-		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Issue Card init fail\n");
+	if (status != STATUS_SUCCESS) {
+		dev_dbg(&priv->usb->dev, "Issue Card init fail\n");
 		return false;
 	}
 
-	ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_INIT_RSP, 0, 0,
+	status = vnt_control_in(priv, MESSAGE_TYPE_INIT_RSP, 0, 0,
 		sizeof(struct vnt_rsp_card_init), (u8 *)init_rsp);
-	if (ntStatus != STATUS_SUCCESS) {
-		DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+	if (status != STATUS_SUCCESS) {
+		dev_dbg(&priv->usb->dev,
 			"Cardinit request in status fail!\n");
 		return false;
 	}
 
 	/* local ID for AES functions */
-	ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_READ,
+	status = vnt_control_in(priv, MESSAGE_TYPE_READ,
 		MAC_REG_LOCALID, MESSAGE_REQUEST_MACREG, 1,
-			&pDevice->byLocalID);
-	if (ntStatus != STATUS_SUCCESS)
+			&priv->local_id);
+	if (status != STATUS_SUCCESS)
 		return false;
 
 	/* do MACbSoftwareReset in MACvInitialize */
 
-	pDevice->byTopOFDMBasicRate = RATE_24M;
-	pDevice->byTopCCKBasicRate = RATE_1M;
+	priv->top_ofdm_basic_rate = RATE_24M;
+	priv->top_cck_basic_rate = RATE_1M;
 
 	/* target to IF pin while programming to RF chip */
-	pDevice->byCurPwr = 0xFF;
+	priv->power = 0xFF;
 
-	pDevice->byCCKPwr = pDevice->abyEEPROM[EEP_OFS_PWR_CCK];
-	pDevice->byOFDMPwrG = pDevice->abyEEPROM[EEP_OFS_PWR_OFDMG];
+	priv->cck_pwr = priv->eeprom[EEP_OFS_PWR_CCK];
+	priv->ofdm_pwr_g = priv->eeprom[EEP_OFS_PWR_OFDMG];
 	/* load power table */
 	for (ii = 0; ii < 14; ii++) {
-		pDevice->abyCCKPwrTbl[ii] =
-			pDevice->abyEEPROM[ii + EEP_OFS_CCK_PWR_TBL];
+		priv->cck_pwr_tbl[ii] =
+			priv->eeprom[ii + EEP_OFS_CCK_PWR_TBL];
+		if (priv->cck_pwr_tbl[ii] == 0)
+			priv->cck_pwr_tbl[ii] = priv->cck_pwr;
 
-		if (pDevice->abyCCKPwrTbl[ii] == 0)
-			pDevice->abyCCKPwrTbl[ii] = pDevice->byCCKPwr;
-		pDevice->abyOFDMPwrTbl[ii] =
-				pDevice->abyEEPROM[ii + EEP_OFS_OFDM_PWR_TBL];
-		if (pDevice->abyOFDMPwrTbl[ii] == 0)
-			pDevice->abyOFDMPwrTbl[ii] = pDevice->byOFDMPwrG;
+		priv->ofdm_pwr_tbl[ii] =
+				priv->eeprom[ii + EEP_OFS_OFDM_PWR_TBL];
+		if (priv->ofdm_pwr_tbl[ii] == 0)
+			priv->ofdm_pwr_tbl[ii] = priv->ofdm_pwr_g;
 	}
 
 	/*
@@ -312,169 +221,159 @@
 	 * then need to recover 12, 13, 14 channels with 11 channel
 	 */
 	for (ii = 11; ii < 14; ii++) {
-		pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10];
-		pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10];
+		priv->cck_pwr_tbl[ii] = priv->cck_pwr_tbl[10];
+		priv->ofdm_pwr_tbl[ii] = priv->ofdm_pwr_tbl[10];
 	}
 
-	pDevice->byOFDMPwrA = 0x34; /* same as RFbMA2829SelectChannel */
+	priv->ofdm_pwr_a = 0x34; /* same as RFbMA2829SelectChannel */
 
 	/* load OFDM A power table */
 	for (ii = 0; ii < CB_MAX_CHANNEL_5G; ii++) {
-		pDevice->abyOFDMAPwrTbl[ii] =
-			pDevice->abyEEPROM[ii + EEP_OFS_OFDMA_PWR_TBL];
+		priv->ofdm_a_pwr_tbl[ii] =
+			priv->eeprom[ii + EEP_OFS_OFDMA_PWR_TBL];
 
-		if (pDevice->abyOFDMAPwrTbl[ii] == 0)
-			pDevice->abyOFDMAPwrTbl[ii] = pDevice->byOFDMPwrA;
+		if (priv->ofdm_a_pwr_tbl[ii] == 0)
+			priv->ofdm_a_pwr_tbl[ii] = priv->ofdm_pwr_a;
 	}
 
-	byAntenna = pDevice->abyEEPROM[EEP_OFS_ANTENNA];
+	antenna = priv->eeprom[EEP_OFS_ANTENNA];
 
-	if (byAntenna & EEP_ANTINV)
-		pDevice->bTxRxAntInv = true;
+	if (antenna & EEP_ANTINV)
+		priv->tx_rx_ant_inv = true;
 	else
-		pDevice->bTxRxAntInv = false;
+		priv->tx_rx_ant_inv = false;
 
-	byAntenna &= (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
+	antenna &= (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
 
-	if (byAntenna == 0) /* if not set default is both */
-		byAntenna = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
+	if (antenna == 0) /* if not set default is both */
+		antenna = (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN);
 
-	if (byAntenna == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) {
-		pDevice->byAntennaCount = 2;
-		pDevice->byTxAntennaMode = ANT_B;
-		pDevice->dwTxAntennaSel = 1;
-		pDevice->dwRxAntennaSel = 1;
+	if (antenna == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) {
+		priv->tx_antenna_mode = ANT_B;
+		priv->rx_antenna_sel = 1;
 
-		if (pDevice->bTxRxAntInv == true)
-			pDevice->byRxAntennaMode = ANT_A;
+		if (priv->tx_rx_ant_inv == true)
+			priv->rx_antenna_mode = ANT_A;
 		else
-			pDevice->byRxAntennaMode = ANT_B;
+			priv->rx_antenna_mode = ANT_B;
 	} else  {
-		pDevice->byAntennaCount = 1;
-		pDevice->dwTxAntennaSel = 0;
-		pDevice->dwRxAntennaSel = 0;
+		priv->rx_antenna_sel = 0;
 
-		if (byAntenna & EEP_ANTENNA_AUX) {
-			pDevice->byTxAntennaMode = ANT_A;
+		if (antenna & EEP_ANTENNA_AUX) {
+			priv->tx_antenna_mode = ANT_A;
 
-			if (pDevice->bTxRxAntInv == true)
-				pDevice->byRxAntennaMode = ANT_B;
+			if (priv->tx_rx_ant_inv == true)
+				priv->rx_antenna_mode = ANT_B;
 			else
-				pDevice->byRxAntennaMode = ANT_A;
+				priv->rx_antenna_mode = ANT_A;
 		} else {
-			pDevice->byTxAntennaMode = ANT_B;
+			priv->tx_antenna_mode = ANT_B;
 
-		if (pDevice->bTxRxAntInv == true)
-			pDevice->byRxAntennaMode = ANT_A;
+		if (priv->tx_rx_ant_inv == true)
+			priv->rx_antenna_mode = ANT_A;
 		else
-			pDevice->byRxAntennaMode = ANT_B;
+			priv->rx_antenna_mode = ANT_B;
 		}
 	}
 
+	/* Set initial antenna mode */
+	vnt_set_antenna_mode(priv, priv->rx_antenna_mode);
+
 	/* get Auto Fall Back type */
-	pDevice->byAutoFBCtrl = AUTO_FB_0;
+	priv->auto_fb_ctrl = AUTO_FB_0;
 
 	/* default Auto Mode */
-	pDevice->byBBType = BB_TYPE_11G;
+	priv->bb_type = BB_TYPE_11G;
 
 	/* get RFType */
-	pDevice->byRFType = init_rsp->rf_type;
+	priv->rf_type = init_rsp->rf_type;
 
 	/* load vt3266 calibration parameters in EEPROM */
-	if (pDevice->byRFType == RF_VT3226D0) {
-		if ((pDevice->abyEEPROM[EEP_OFS_MAJOR_VER] == 0x1) &&
-			(pDevice->abyEEPROM[EEP_OFS_MINOR_VER] >= 0x4)) {
+	if (priv->rf_type == RF_VT3226D0) {
+		if ((priv->eeprom[EEP_OFS_MAJOR_VER] == 0x1) &&
+		    (priv->eeprom[EEP_OFS_MINOR_VER] >= 0x4)) {
 
-			byCalibTXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_IQ];
-			byCalibTXDC = pDevice->abyEEPROM[EEP_OFS_CALIB_TX_DC];
-			byCalibRXIQ = pDevice->abyEEPROM[EEP_OFS_CALIB_RX_IQ];
-			if (byCalibTXIQ || byCalibTXDC || byCalibRXIQ) {
-			/* CR255, enable TX/RX IQ and DC compensation mode */
-				vnt_control_out_u8(pDevice,
-					MESSAGE_REQUEST_BBREG,
-					0xff,
-					0x03);
-			/* CR251, TX I/Q Imbalance Calibration */
-				vnt_control_out_u8(pDevice,
-					MESSAGE_REQUEST_BBREG,
-					0xfb,
-					byCalibTXIQ);
-			/* CR252, TX DC-Offset Calibration */
-				vnt_control_out_u8(pDevice,
-					MESSAGE_REQUEST_BBREG,
-					0xfC,
-					byCalibTXDC);
-			/* CR253, RX I/Q Imbalance Calibration */
-				vnt_control_out_u8(pDevice,
-					MESSAGE_REQUEST_BBREG,
-					0xfd,
-					byCalibRXIQ);
+			calib_tx_iq = priv->eeprom[EEP_OFS_CALIB_TX_IQ];
+			calib_tx_dc = priv->eeprom[EEP_OFS_CALIB_TX_DC];
+			calib_rx_iq = priv->eeprom[EEP_OFS_CALIB_RX_IQ];
+			if (calib_tx_iq || calib_tx_dc || calib_rx_iq) {
+				/* CR255, enable TX/RX IQ and
+				   DC compensation mode */
+				vnt_control_out_u8(priv,
+						   MESSAGE_REQUEST_BBREG,
+						   0xff,
+						   0x03);
+				/* CR251, TX I/Q Imbalance Calibration */
+				vnt_control_out_u8(priv,
+						   MESSAGE_REQUEST_BBREG,
+						   0xfb,
+						   calib_tx_iq);
+				/* CR252, TX DC-Offset Calibration */
+				vnt_control_out_u8(priv,
+						   MESSAGE_REQUEST_BBREG,
+						   0xfC,
+						   calib_tx_dc);
+				/* CR253, RX I/Q Imbalance Calibration */
+				vnt_control_out_u8(priv,
+						   MESSAGE_REQUEST_BBREG,
+						   0xfd,
+						   calib_rx_iq);
 			} else {
-			/* CR255, turn off BB Calibration compensation */
-				vnt_control_out_u8(pDevice,
-					MESSAGE_REQUEST_BBREG,
-					0xff,
-					0x0);
+				/* CR255, turn off
+				   BB Calibration compensation */
+				vnt_control_out_u8(priv,
+						   MESSAGE_REQUEST_BBREG,
+						   0xff,
+						   0x0);
 			}
 		}
 	}
 
 	/* get permanent network address */
-	memcpy(pDevice->abyPermanentNetAddr, init_rsp->net_addr, 6);
-	memcpy(pDevice->abyCurrentNetAddr,
-				pDevice->abyPermanentNetAddr, ETH_ALEN);
+	memcpy(priv->permanent_net_addr, init_rsp->net_addr, 6);
+	memcpy(priv->current_net_addr, priv->permanent_net_addr, ETH_ALEN);
 
 	/* if exist SW network address, use it */
-	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Network address = %pM\n",
-		pDevice->abyCurrentNetAddr);
+	dev_dbg(&priv->usb->dev, "Network address = %pM\n",
+		priv->current_net_addr);
 
 	/*
 	* set BB and packet type at the same time
 	* set Short Slot Time, xIFS, and RSPINF
 	*/
-	if (pDevice->byBBType == BB_TYPE_11A)
-		pDevice->bShortSlotTime = true;
+	if (priv->bb_type == BB_TYPE_11A)
+		priv->short_slot_time = true;
 	else
-		pDevice->bShortSlotTime = false;
+		priv->short_slot_time = false;
 
-	BBvSetShortSlotTime(pDevice);
+	vnt_set_short_slot_time(priv);
 
-	pDevice->byRadioCtl = pDevice->abyEEPROM[EEP_OFS_RADIOCTL];
-	pDevice->bHWRadioOff = false;
+	priv->radio_ctl = priv->eeprom[EEP_OFS_RADIOCTL];
 
-	if ((pDevice->byRadioCtl & EEP_RADIOCTL_ENABLE) != 0) {
-		ntStatus = vnt_control_in(pDevice, MESSAGE_TYPE_READ,
-			MAC_REG_GPIOCTL1, MESSAGE_REQUEST_MACREG, 1, &byTmp);
+	if ((priv->radio_ctl & EEP_RADIOCTL_ENABLE) != 0) {
+		status = vnt_control_in(priv, MESSAGE_TYPE_READ,
+			MAC_REG_GPIOCTL1, MESSAGE_REQUEST_MACREG, 1, &tmp);
 
-		if (ntStatus != STATUS_SUCCESS)
+		if (status != STATUS_SUCCESS)
 			return false;
 
-		if ((byTmp & GPIO3_DATA) == 0) {
-			pDevice->bHWRadioOff = true;
-			vnt_mac_reg_bits_on(pDevice, MAC_REG_GPIOCTL1,
+		if ((tmp & GPIO3_DATA) == 0)
+			vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL1,
 								GPIO3_INTMD);
-		} else {
-			vnt_mac_reg_bits_off(pDevice, MAC_REG_GPIOCTL1,
+		else
+			vnt_mac_reg_bits_off(priv, MAC_REG_GPIOCTL1,
 								GPIO3_INTMD);
-			pDevice->bHWRadioOff = false;
-		}
-
 	}
 
-	vnt_mac_set_led(pDevice, LEDSTS_TMLEN, 0x38);
+	vnt_mac_set_led(priv, LEDSTS_TMLEN, 0x38);
 
-	vnt_mac_set_led(pDevice, LEDSTS_STS, LEDSTS_SLOW);
+	vnt_mac_set_led(priv, LEDSTS_STS, LEDSTS_SLOW);
 
-	vnt_mac_reg_bits_on(pDevice, MAC_REG_GPIOCTL0, 0x01);
+	vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL0, 0x01);
 
-	if ((pDevice->bHWRadioOff == true) ||
-				(pDevice->bRadioControlOff == true)) {
-		vnt_radio_power_off(pDevice);
-	} else {
-		vnt_radio_power_on(pDevice);
-	}
+	vnt_radio_power_on(priv);
 
-	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"<----INIbInitAdapter Exit\n");
+	dev_dbg(&priv->usb->dev, "<----INIbInitAdapter Exit\n");
 
 	return true;
 }
@@ -484,8 +383,8 @@
 	struct vnt_usb_send_context *tx_context;
 	int ii;
 
-	for (ii = 0; ii < priv->cbTD; ii++) {
-		tx_context = priv->apTD[ii];
+	for (ii = 0; ii < priv->num_tx_context; ii++) {
+		tx_context = priv->tx_context[ii];
 		/* deallocate URBs */
 		if (tx_context->urb) {
 			usb_kill_urb(tx_context->urb);
@@ -503,15 +402,15 @@
 	struct vnt_rcb *rcb;
 	int ii;
 
-	for (ii = 0; ii < priv->cbRD; ii++) {
-		rcb = priv->apRCB[ii];
+	for (ii = 0; ii < priv->num_rcb; ii++) {
+		rcb = priv->rcb[ii];
 		if (!rcb)
 			continue;
 
 		/* deallocate URBs */
-		if (rcb->pUrb) {
-			usb_kill_urb(rcb->pUrb);
-			usb_free_urb(rcb->pUrb);
+		if (rcb->urb) {
+			usb_kill_urb(rcb->urb);
+			usb_free_urb(rcb->urb);
 		}
 
 		/* deallocate skb */
@@ -524,12 +423,14 @@
 	return;
 }
 
-static void usb_device_reset(struct vnt_private *pDevice)
+static void usb_device_reset(struct vnt_private *priv)
 {
- int status;
- status = usb_reset_device(pDevice->usb);
+	int status;
+
+	status = usb_reset_device(priv->usb);
 	if (status)
-            printk("usb_device_reset fail status=%d\n",status);
+		dev_warn(&priv->usb->dev,
+			 "usb_device_reset fail status=%d\n", status);
 	return ;
 }
 
@@ -546,7 +447,7 @@
 	struct vnt_rcb *rcb;
 	int ii;
 
-	for (ii = 0; ii < priv->cbTD; ii++) {
+	for (ii = 0; ii < priv->num_tx_context; ii++) {
 		tx_context = kmalloc(sizeof(struct vnt_usb_send_context),
 								GFP_KERNEL);
 		if (tx_context == NULL) {
@@ -555,65 +456,62 @@
 			goto free_tx;
 		}
 
-		priv->apTD[ii] = tx_context;
+		priv->tx_context[ii] = tx_context;
 		tx_context->priv = priv;
 		tx_context->pkt_no = ii;
 
 		/* allocate URBs */
 		tx_context->urb = usb_alloc_urb(0, GFP_ATOMIC);
 		if (!tx_context->urb) {
-			DBG_PRT(MSG_LEVEL_ERR,
-				KERN_ERR "alloc tx urb failed\n");
+			dev_err(&priv->usb->dev, "alloc tx urb failed\n");
 			goto free_tx;
 		}
 
 		tx_context->in_use = false;
 	}
 
-	for (ii = 0; ii < priv->cbRD; ii++) {
-		priv->apRCB[ii] = kzalloc(sizeof(struct vnt_rcb), GFP_KERNEL);
-		if (!priv->apRCB[ii]) {
+	for (ii = 0; ii < priv->num_rcb; ii++) {
+		priv->rcb[ii] = kzalloc(sizeof(struct vnt_rcb), GFP_KERNEL);
+		if (!priv->rcb[ii]) {
 			dev_err(&priv->usb->dev,
 					"failed to allocate rcb no %d\n", ii);
 			goto free_rx_tx;
 		}
 
-		rcb = priv->apRCB[ii];
+		rcb = priv->rcb[ii];
 
-		rcb->pDevice = priv;
+		rcb->priv = priv;
 
 		/* allocate URBs */
-		rcb->pUrb = usb_alloc_urb(0, GFP_ATOMIC);
-		if (rcb->pUrb == NULL) {
-			DBG_PRT(MSG_LEVEL_ERR, KERN_ERR
-				" Failed to alloc rx urb\n");
+		rcb->urb = usb_alloc_urb(0, GFP_ATOMIC);
+		if (rcb->urb == NULL) {
+			dev_err(&priv->usb->dev, "Failed to alloc rx urb\n");
 			goto free_rx_tx;
 		}
 
 		rcb->skb = dev_alloc_skb(priv->rx_buf_sz);
 		if (rcb->skb == NULL) {
-			DBG_PRT(MSG_LEVEL_ERR, KERN_ERR
-						" Failed to alloc rx skb\n");
+			dev_err(&priv->usb->dev, "Failed to alloc rx skb\n");
 			goto free_rx_tx;
 		}
 
-		rcb->bBoolInUse = false;
+		rcb->in_use = false;
 
 		/* submit rx urb */
-		if (PIPEnsBulkInUsbRead(priv, rcb))
+		if (vnt_submit_rx_urb(priv, rcb))
 			goto free_rx_tx;
 	}
 
-	priv->pInterruptURB = usb_alloc_urb(0, GFP_ATOMIC);
-	if (priv->pInterruptURB == NULL) {
-		DBG_PRT(MSG_LEVEL_ERR, KERN_ERR"Failed to alloc int urb\n");
+	priv->interrupt_urb = usb_alloc_urb(0, GFP_ATOMIC);
+	if (priv->interrupt_urb == NULL) {
+		dev_err(&priv->usb->dev, "Failed to alloc int urb\n");
 		goto free_rx_tx;
 	}
 
 	priv->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL);
 	if (priv->int_buf.data_buf == NULL) {
-		DBG_PRT(MSG_LEVEL_ERR, KERN_ERR"Failed to alloc int buf\n");
-		usb_free_urb(priv->pInterruptURB);
+		dev_err(&priv->usb->dev, "Failed to alloc int buf\n");
+		usb_free_urb(priv->interrupt_urb);
 		goto free_rx_tx;
 	}
 
@@ -664,7 +562,7 @@
 
 	priv->int_interval = 1;  /* bInterval is set to 1 */
 
-	INTvWorkItem(priv);
+	vnt_int_start_interrupt(priv);
 
 	priv->flags |= DEVICE_FLAGS_OPENED;
 
@@ -677,8 +575,8 @@
 	device_free_tx_bufs(priv);
 	device_free_int_bufs(priv);
 
-	usb_kill_urb(priv->pInterruptURB);
-	usb_free_urb(priv->pInterruptURB);
+	usb_kill_urb(priv->interrupt_urb);
+	usb_free_urb(priv->interrupt_urb);
 
 	return -ENOMEM;
 }
@@ -716,8 +614,8 @@
 	device_free_rx_bufs(priv);
 	device_free_int_bufs(priv);
 
-	usb_kill_urb(priv->pInterruptURB);
-	usb_free_urb(priv->pInterruptURB);
+	usb_kill_urb(priv->interrupt_urb);
+	usb_free_urb(priv->interrupt_urb);
 
 	return;
 }
@@ -811,20 +709,20 @@
 		else
 			bb_type = BB_TYPE_11G;
 
-		if (priv->byBBType != bb_type) {
-			priv->byBBType = bb_type;
+		if (priv->bb_type != bb_type) {
+			priv->bb_type = bb_type;
 
 			vnt_set_bss_mode(priv);
 		}
 	}
 
 	if (changed & IEEE80211_CONF_CHANGE_POWER) {
-		if (priv->byBBType == BB_TYPE_11B)
-			priv->wCurrentRate = RATE_1M;
+		if (priv->bb_type == BB_TYPE_11B)
+			priv->current_rate = RATE_1M;
 		else
-			priv->wCurrentRate = RATE_54M;
+			priv->current_rate = RATE_54M;
 
-		vnt_rf_setpower(priv, priv->wCurrentRate,
+		vnt_rf_setpower(priv, priv->current_rate,
 				conf->chandef.chan->hw_value);
 	}
 
@@ -836,6 +734,7 @@
 		u32 changed)
 {
 	struct vnt_private *priv = hw->priv;
+
 	priv->current_aid = conf->aid;
 
 	if (changed & BSS_CHANGED_BSSID)
@@ -843,7 +742,7 @@
 
 
 	if (changed & BSS_CHANGED_BASIC_RATES) {
-		priv->wBasicRate = conf->basic_rates;
+		priv->basic_rates = conf->basic_rates;
 
 		vnt_update_top_rates(priv);
 
@@ -853,10 +752,10 @@
 	if (changed & BSS_CHANGED_ERP_PREAMBLE) {
 		if (conf->use_short_preamble) {
 			vnt_mac_enable_barker_preamble_mode(priv);
-			priv->byPreambleType = true;
+			priv->preamble_type = true;
 		} else {
 			vnt_mac_disable_barker_preamble_mode(priv);
-			priv->byPreambleType = false;
+			priv->preamble_type = false;
 		}
 	}
 
@@ -869,17 +768,17 @@
 
 	if (changed & BSS_CHANGED_ERP_SLOT) {
 		if (conf->use_short_slot)
-			priv->bShortSlotTime = true;
+			priv->short_slot_time = true;
 		else
-			priv->bShortSlotTime = false;
+			priv->short_slot_time = false;
 
-		BBvSetShortSlotTime(priv);
-		BBvSetVGAGainOffset(priv, priv->abyBBVGA[0]);
-		BBvUpdatePreEDThreshold(priv, false);
+		vnt_set_short_slot_time(priv);
+		vnt_set_vga_gain_offset(priv, priv->bb_vga[0]);
+		vnt_update_pre_ed_threshold(priv, false);
 	}
 
 	if (changed & BSS_CHANGED_TXPOWER)
-		vnt_rf_setpower(priv, priv->wCurrentRate,
+		vnt_rf_setpower(priv, priv->current_rate,
 					conf->chandef.chan->hw_value);
 
 	if (changed & BSS_CHANGED_BEACON_ENABLED) {
@@ -996,7 +895,7 @@
 
 	vnt_set_bss_mode(priv);
 	/* Set max sensitivity*/
-	BBvUpdatePreEDThreshold(priv, true);
+	vnt_update_pre_ed_threshold(priv, true);
 }
 
 static void vnt_sw_scan_complete(struct ieee80211_hw *hw)
@@ -1004,7 +903,7 @@
 	struct vnt_private *priv = hw->priv;
 
 	/* Return sensitivity to channel level*/
-	BBvUpdatePreEDThreshold(priv, false);
+	vnt_update_pre_ed_threshold(priv, false);
 }
 
 static int vnt_get_stats(struct ieee80211_hw *hw,
@@ -1021,7 +920,7 @@
 {
 	struct vnt_private *priv = hw->priv;
 
-	return priv->qwCurrTSF;
+	return priv->current_tsf;
 }
 
 static void vnt_set_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
@@ -1066,7 +965,7 @@
 	if (!(device_init_registers(priv)))
 		return -EAGAIN;
 
-	SET_IEEE80211_PERM_ADDR(priv->hw, priv->abyPermanentNetAddr);
+	SET_IEEE80211_PERM_ADDR(priv->hw, priv->permanent_net_addr);
 
 	vnt_init_bands(priv);
 
diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c
index dbda303..0ffbaed 100644
--- a/drivers/staging/vt6656/power.c
+++ b/drivers/staging/vt6656/power.c
@@ -42,8 +42,6 @@
 #include "card.h"
 #include "usbpipe.h"
 
-static int msglevel = MSG_LEVEL_INFO;
-
 /*
  *
  * Routine Description:
@@ -93,7 +91,7 @@
 		vnt_mac_reg_bits_on(priv, MAC_REG_PSCTL, PSCTL_ALBCN);
 	}
 
-	DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "PS:Power Saving Mode Enable...\n");
+	dev_dbg(&priv->usb->dev,  "PS:Power Saving Mode Enable...\n");
 }
 
 /*
diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c
index 28e64b4..c0edcae 100644
--- a/drivers/staging/vt6656/rf.c
+++ b/drivers/staging/vt6656/rf.c
@@ -624,7 +624,7 @@
 int vnt_rf_setpower(struct vnt_private *priv, u32 rate, u32 channel)
 {
 	int ret = true;
-	u8 power = priv->byCCKPwr;
+	u8 power = priv->cck_pwr;
 
 	if (channel == 0)
 		return -EINVAL;
@@ -636,8 +636,8 @@
 	case RATE_11M:
 		channel--;
 
-		if (channel < sizeof(priv->abyCCKPwrTbl))
-			power = priv->abyCCKPwrTbl[channel];
+		if (channel < sizeof(priv->cck_pwr_tbl))
+			power = priv->cck_pwr_tbl[channel];
 		break;
 	case RATE_6M:
 	case RATE_9M:
@@ -647,9 +647,9 @@
 	case RATE_48M:
 	case RATE_54M:
 		if (channel > CB_MAX_CHANNEL_24G)
-			power = priv->abyOFDMAPwrTbl[channel-15];
+			power = priv->ofdm_a_pwr_tbl[channel-15];
 		else
-			power = priv->abyOFDMPwrTbl[channel-1];
+			power = priv->ofdm_pwr_tbl[channel-1];
 		break;
 	}
 
@@ -660,12 +660,12 @@
 
 static u8 vnt_rf_addpower(struct vnt_private *priv)
 {
-	s32 rssi = -priv->uCurrRSSI;
+	s32 rssi = -priv->current_rssi;
 
 	if (!rssi)
 		return 7;
 
-	if (priv->byRFType == RF_VT3226D0) {
+	if (priv->rf_type == RF_VT3226D0) {
 		if (rssi < -70)
 			return 9;
 		else if (rssi < -65)
@@ -694,12 +694,12 @@
 	if (power > VNT_RF_MAX_POWER)
 		power = VNT_RF_MAX_POWER;
 
-	if (priv->byCurPwr == power)
+	if (priv->power == power)
 		return true;
 
-	priv->byCurPwr = power;
+	priv->power = power;
 
-	switch (priv->byRFType) {
+	switch (priv->rf_type) {
 	case RF_AL2230:
 		if (power >= AL2230_PWR_IDX_LEN)
 			return false;
@@ -811,7 +811,7 @@
 	long a = 0;
 	u8 airoharf[4] = {0, 18, 0, 40};
 
-	switch (priv->byRFType) {
+	switch (priv->rf_type) {
 	case RF_AL2230:
 	case RF_AL2230S:
 	case RF_AIROHA7230:
@@ -834,7 +834,7 @@
 	u16 length, value;
 	u8 array[256];
 
-	switch (priv->byRFType) {
+	switch (priv->rf_type) {
 	case RF_AL2230:
 	case RF_AL2230S:
 		length1 = CB_AL2230_INIT_SEQ * 3;
@@ -920,7 +920,7 @@
 		addr3 += length;
 	}
 
-	if (priv->byRFType == RF_AIROHA7230) {
+	if (priv->rf_type == RF_AIROHA7230) {
 		length1 = CB_AL7230_INIT_SEQ * 3;
 		length2 = CB_MAX_CHANNEL * 3;
 		addr1 = &(al7230_init_table_amode[0][0]);
diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c
index 1f1ec04..2d1ef88 100644
--- a/drivers/staging/vt6656/rxtx.c
+++ b/drivers/staging/vt6656/rxtx.c
@@ -81,11 +81,11 @@
 
 	dev_dbg(&priv->usb->dev, "%s\n", __func__);
 
-	for (ii = 0; ii < priv->cbTD; ii++) {
-		if (!priv->apTD[ii])
+	for (ii = 0; ii < priv->num_tx_context; ii++) {
+		if (!priv->tx_context[ii])
 			return NULL;
 
-		context = priv->apTD[ii];
+		context = priv->tx_context[ii];
 		if (context->in_use == false) {
 			context->in_use = true;
 			memset(context->data, 0,
@@ -97,7 +97,7 @@
 		}
 	}
 
-	if (ii == priv->cbTD)
+	if (ii == priv->num_tx_context)
 		dev_dbg(&priv->usb->dev, "%s No Free Tx Context\n", __func__);
 
 	return NULL;
@@ -105,7 +105,7 @@
 
 static __le16 vnt_time_stamp_off(struct vnt_private *priv, u16 rate)
 {
-	return cpu_to_le16(vnt_time_stampoff[priv->byPreambleType % 2]
+	return cpu_to_le16(vnt_time_stampoff[priv->preamble_type % 2]
 							[rate % MAX_RATE]);
 }
 
@@ -114,18 +114,18 @@
 {
 	u32 data_time, ack_time;
 
-	data_time = vnt_get_frame_time(priv->byPreambleType, pkt_type,
+	data_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
 							frame_length, rate);
 
 	if (pkt_type == PK_TYPE_11B)
-		ack_time = vnt_get_frame_time(priv->byPreambleType, pkt_type,
-					14, (u16)priv->byTopCCKBasicRate);
+		ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
+					14, (u16)priv->top_cck_basic_rate);
 	else
-		ack_time = vnt_get_frame_time(priv->byPreambleType, pkt_type,
-					14, (u16)priv->byTopOFDMBasicRate);
+		ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
+					14, (u16)priv->top_ofdm_basic_rate);
 
 	if (need_ack)
-		return data_time + priv->uSIFS + ack_time;
+		return data_time + priv->sifs + ack_time;
 
 	return data_time;
 }
@@ -144,74 +144,77 @@
 
 	rrv_time = rts_time = cts_time = ack_time = data_time = 0;
 
-	data_time = vnt_get_frame_time(priv->byPreambleType, pkt_type,
+	data_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
 						frame_length, current_rate);
 
 	if (rsv_type == 0) {
-		rts_time = vnt_get_frame_time(priv->byPreambleType,
-			pkt_type, 20, priv->byTopCCKBasicRate);
-		cts_time = ack_time = vnt_get_frame_time(priv->byPreambleType,
-			pkt_type, 14, priv->byTopCCKBasicRate);
+		rts_time = vnt_get_frame_time(priv->preamble_type,
+			pkt_type, 20, priv->top_cck_basic_rate);
+		cts_time = ack_time = vnt_get_frame_time(priv->preamble_type,
+			pkt_type, 14, priv->top_cck_basic_rate);
 	} else if (rsv_type == 1) {
-		rts_time = vnt_get_frame_time(priv->byPreambleType,
-			pkt_type, 20, priv->byTopCCKBasicRate);
-		cts_time = vnt_get_frame_time(priv->byPreambleType, pkt_type,
-			14, priv->byTopCCKBasicRate);
-		ack_time = vnt_get_frame_time(priv->byPreambleType, pkt_type,
-			14, priv->byTopOFDMBasicRate);
+		rts_time = vnt_get_frame_time(priv->preamble_type,
+			pkt_type, 20, priv->top_cck_basic_rate);
+		cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
+			14, priv->top_cck_basic_rate);
+		ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
+			14, priv->top_ofdm_basic_rate);
 	} else if (rsv_type == 2) {
-		rts_time = vnt_get_frame_time(priv->byPreambleType, pkt_type,
-			20, priv->byTopOFDMBasicRate);
-		cts_time = ack_time = vnt_get_frame_time(priv->byPreambleType,
-			pkt_type, 14, priv->byTopOFDMBasicRate);
+		rts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
+			20, priv->top_ofdm_basic_rate);
+		cts_time = ack_time = vnt_get_frame_time(priv->preamble_type,
+			pkt_type, 14, priv->top_ofdm_basic_rate);
 	} else if (rsv_type == 3) {
-		cts_time = vnt_get_frame_time(priv->byPreambleType, pkt_type,
-			14, priv->byTopCCKBasicRate);
-		ack_time = vnt_get_frame_time(priv->byPreambleType, pkt_type,
-			14, priv->byTopOFDMBasicRate);
+		cts_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
+			14, priv->top_cck_basic_rate);
+		ack_time = vnt_get_frame_time(priv->preamble_type, pkt_type,
+			14, priv->top_ofdm_basic_rate);
 
-		rrv_time = cts_time + ack_time + data_time + 2 * priv->uSIFS;
+		rrv_time = cts_time + ack_time + data_time + 2 * priv->sifs;
 
 		return cpu_to_le16((u16)rrv_time);
 	}
 
-	rrv_time = rts_time + cts_time + ack_time + data_time + 3 * priv->uSIFS;
+	rrv_time = rts_time + cts_time + ack_time + data_time + 3 * priv->sifs;
 
 	return cpu_to_le16((u16)rrv_time);
 }
 
-static __le16 vnt_get_duration_le(struct vnt_private *piv,
+static __le16 vnt_get_duration_le(struct vnt_private *priv,
 					u8 pkt_type, int need_ack)
 {
 	u32 ack_time = 0;
 
 	if (need_ack) {
 		if (pkt_type == PK_TYPE_11B)
-			ack_time = vnt_get_frame_time(piv->byPreambleType,
-				pkt_type, 14, piv->byTopCCKBasicRate);
+			ack_time = vnt_get_frame_time(priv->preamble_type,
+				pkt_type, 14, priv->top_cck_basic_rate);
 		else
-			ack_time = vnt_get_frame_time(piv->byPreambleType,
-				pkt_type, 14, piv->byTopOFDMBasicRate);
+			ack_time = vnt_get_frame_time(priv->preamble_type,
+				pkt_type, 14, priv->top_ofdm_basic_rate);
 
-		return cpu_to_le16((u16)(piv->uSIFS + ack_time));
+		return cpu_to_le16((u16)(priv->sifs + ack_time));
 	}
 
 	return 0;
 }
 
-static __le16 vnt_get_rtscts_duration_le(struct vnt_private *priv, u8 dur_type,
-	u32 frame_length, u8 pkt_type, u16 rate, int need_ack)
+static __le16 vnt_get_rtscts_duration_le(struct vnt_usb_send_context *context,
+					 u8 dur_type, u8 pkt_type, u16 rate)
 {
+	struct vnt_private *priv = context->priv;
 	u32 cts_time = 0, dur_time = 0;
+	u32 frame_length = context->frame_len;
+	u8 need_ack = context->need_ack;
 
 	switch (dur_type) {
 	case RTSDUR_BB:
 	case RTSDUR_BA:
 	case RTSDUR_BA_F0:
 	case RTSDUR_BA_F1:
-		cts_time = vnt_get_frame_time(priv->byPreambleType,
-				pkt_type, 14, priv->byTopCCKBasicRate);
-		dur_time = cts_time + 2 * priv->uSIFS +
+		cts_time = vnt_get_frame_time(priv->preamble_type,
+				pkt_type, 14, priv->top_cck_basic_rate);
+		dur_time = cts_time + 2 * priv->sifs +
 			vnt_get_rsvtime(priv, pkt_type,
 						frame_length, rate, need_ack);
 		break;
@@ -219,9 +222,9 @@
 	case RTSDUR_AA:
 	case RTSDUR_AA_F0:
 	case RTSDUR_AA_F1:
-		cts_time = vnt_get_frame_time(priv->byPreambleType,
-				pkt_type, 14, priv->byTopOFDMBasicRate);
-		dur_time = cts_time + 2 * priv->uSIFS +
+		cts_time = vnt_get_frame_time(priv->preamble_type,
+				pkt_type, 14, priv->top_ofdm_basic_rate);
+		dur_time = cts_time + 2 * priv->sifs +
 			vnt_get_rsvtime(priv, pkt_type,
 						frame_length, rate, need_ack);
 		break;
@@ -229,7 +232,7 @@
 	case CTSDUR_BA:
 	case CTSDUR_BA_F0:
 	case CTSDUR_BA_F1:
-		dur_time = priv->uSIFS + vnt_get_rsvtime(priv,
+		dur_time = priv->sifs + vnt_get_rsvtime(priv,
 				pkt_type, frame_length, rate, need_ack);
 		break;
 
@@ -254,17 +257,19 @@
 }
 
 static u16 vnt_rxtx_datahead_g(struct vnt_usb_send_context *tx_context,
-		u8 pkt_type, u16 rate, struct vnt_tx_datahead_g *buf,
-		u32 frame_len, int need_ack)
+			       struct vnt_tx_datahead_g *buf)
 {
 
 	struct vnt_private *priv = tx_context->priv;
 	struct ieee80211_hdr *hdr =
 				(struct ieee80211_hdr *)tx_context->skb->data;
+	u32 frame_len = tx_context->frame_len;
+	u16 rate = tx_context->tx_rate;
+	u8 need_ack = tx_context->need_ack;
 
 	/* Get SignalField,ServiceField,Length */
-	vnt_get_phy_field(priv, frame_len, rate, pkt_type, &buf->a);
-	vnt_get_phy_field(priv, frame_len, priv->byTopCCKBasicRate,
+	vnt_get_phy_field(priv, frame_len, rate, tx_context->pkt_type, &buf->a);
+	vnt_get_phy_field(priv, frame_len, priv->top_cck_basic_rate,
 							PK_TYPE_11B, &buf->b);
 
 	/* Get Duration and TimeStamp */
@@ -274,14 +279,15 @@
 		buf->duration_a = dur;
 		buf->duration_b = dur;
 	} else {
-		buf->duration_a = vnt_get_duration_le(priv, pkt_type, need_ack);
+		buf->duration_a = vnt_get_duration_le(priv,
+						tx_context->pkt_type, need_ack);
 		buf->duration_b = vnt_get_duration_le(priv,
 							PK_TYPE_11B, need_ack);
 	}
 
 	buf->time_stamp_off_a = vnt_time_stamp_off(priv, rate);
 	buf->time_stamp_off_b = vnt_time_stamp_off(priv,
-					priv->byTopCCKBasicRate);
+					priv->top_cck_basic_rate);
 
 	tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, &buf->hdr);
 
@@ -289,27 +295,32 @@
 }
 
 static u16 vnt_rxtx_datahead_g_fb(struct vnt_usb_send_context *tx_context,
-		u8 pkt_type, u16 rate, struct vnt_tx_datahead_g_fb *buf,
-		u32 frame_len, int need_ack)
+				  struct vnt_tx_datahead_g_fb *buf)
 {
 	struct vnt_private *priv = tx_context->priv;
+	u32 frame_len = tx_context->frame_len;
+	u16 rate = tx_context->tx_rate;
+	u8 need_ack = tx_context->need_ack;
 
 	/* Get SignalField,ServiceField,Length */
-	vnt_get_phy_field(priv, frame_len, rate, pkt_type, &buf->a);
+	vnt_get_phy_field(priv, frame_len, rate, tx_context->pkt_type, &buf->a);
 
-	vnt_get_phy_field(priv, frame_len, priv->byTopCCKBasicRate,
+	vnt_get_phy_field(priv, frame_len, priv->top_cck_basic_rate,
 						PK_TYPE_11B, &buf->b);
 
 	/* Get Duration and TimeStamp */
-	buf->duration_a = vnt_get_duration_le(priv, pkt_type, need_ack);
+	buf->duration_a = vnt_get_duration_le(priv, tx_context->pkt_type,
+					      need_ack);
 	buf->duration_b = vnt_get_duration_le(priv, PK_TYPE_11B, need_ack);
 
-	buf->duration_a_f0 = vnt_get_duration_le(priv, pkt_type, need_ack);
-	buf->duration_a_f1 = vnt_get_duration_le(priv, pkt_type, need_ack);
+	buf->duration_a_f0 = vnt_get_duration_le(priv, tx_context->pkt_type,
+						 need_ack);
+	buf->duration_a_f1 = vnt_get_duration_le(priv, tx_context->pkt_type,
+						 need_ack);
 
 	buf->time_stamp_off_a = vnt_time_stamp_off(priv, rate);
 	buf->time_stamp_off_b = vnt_time_stamp_off(priv,
-						priv->byTopCCKBasicRate);
+						priv->top_cck_basic_rate);
 
 	tx_context->tx_hdr_size = vnt_mac_hdr_pos(tx_context, &buf->hdr);
 
@@ -317,10 +328,13 @@
 }
 
 static u16 vnt_rxtx_datahead_a_fb(struct vnt_usb_send_context *tx_context,
-		u8 pkt_type, u16 rate, struct vnt_tx_datahead_a_fb *buf,
-		u32 frame_len, int need_ack)
+				  struct vnt_tx_datahead_a_fb *buf)
 {
 	struct vnt_private *priv = tx_context->priv;
+	u16 rate = tx_context->tx_rate;
+	u8 pkt_type = tx_context->pkt_type;
+	u8 need_ack = tx_context->need_ack;
+	u32 frame_len = tx_context->frame_len;
 
 	/* Get SignalField,ServiceField,Length */
 	vnt_get_phy_field(priv, frame_len, rate, pkt_type, &buf->a);
@@ -338,15 +352,18 @@
 }
 
 static u16 vnt_rxtx_datahead_ab(struct vnt_usb_send_context *tx_context,
-		u8 pkt_type, u16 rate, struct vnt_tx_datahead_ab *buf,
-		u32 frame_len, int need_ack)
+				struct vnt_tx_datahead_ab *buf)
 {
 	struct vnt_private *priv = tx_context->priv;
 	struct ieee80211_hdr *hdr =
 				(struct ieee80211_hdr *)tx_context->skb->data;
+	u32 frame_len = tx_context->frame_len;
+	u16 rate = tx_context->tx_rate;
+	u8 need_ack = tx_context->need_ack;
 
 	/* Get SignalField,ServiceField,Length */
-	vnt_get_phy_field(priv, frame_len, rate, pkt_type, &buf->ab);
+	vnt_get_phy_field(priv, frame_len, rate,
+			  tx_context->pkt_type, &buf->ab);
 
 	/* Get Duration and TimeStampOff */
 	if (ieee80211_is_pspoll(hdr->frame_control)) {
@@ -354,7 +371,8 @@
 
 		buf->duration = dur;
 	} else {
-		buf->duration = vnt_get_duration_le(priv, pkt_type, need_ack);
+		buf->duration = vnt_get_duration_le(priv, tx_context->pkt_type,
+						    need_ack);
 	}
 
 	buf->time_stamp_off = vnt_time_stamp_off(priv, rate);
@@ -381,116 +399,130 @@
 }
 
 static u16 vnt_rxtx_rts_g_head(struct vnt_usb_send_context *tx_context,
-	struct vnt_rts_g *buf, u8 pkt_type, u32 frame_len, int need_ack,
-	u16 current_rate)
+			       struct vnt_rts_g *buf)
 {
 	struct vnt_private *priv = tx_context->priv;
 	u16 rts_frame_len = 20;
+	u16 current_rate = tx_context->tx_rate;
 
-	vnt_get_phy_field(priv, rts_frame_len, priv->byTopCCKBasicRate,
+	vnt_get_phy_field(priv, rts_frame_len, priv->top_cck_basic_rate,
 		PK_TYPE_11B, &buf->b);
-	vnt_get_phy_field(priv, rts_frame_len,
-		priv->byTopOFDMBasicRate, pkt_type, &buf->a);
+	vnt_get_phy_field(priv, rts_frame_len, priv->top_ofdm_basic_rate,
+			  tx_context->pkt_type, &buf->a);
 
-	buf->duration_bb = vnt_get_rtscts_duration_le(priv, RTSDUR_BB,
-		frame_len, PK_TYPE_11B, priv->byTopCCKBasicRate, need_ack);
-	buf->duration_aa = vnt_get_rtscts_duration_le(priv, RTSDUR_AA,
-		frame_len, pkt_type, current_rate, need_ack);
-	buf->duration_ba = vnt_get_rtscts_duration_le(priv, RTSDUR_BA,
-		frame_len, pkt_type, current_rate, need_ack);
+	buf->duration_bb = vnt_get_rtscts_duration_le(tx_context, RTSDUR_BB,
+						      PK_TYPE_11B,
+						      priv->top_cck_basic_rate);
+	buf->duration_aa = vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA,
+						      tx_context->pkt_type,
+						      current_rate);
+	buf->duration_ba = vnt_get_rtscts_duration_le(tx_context, RTSDUR_BA,
+						      tx_context->pkt_type,
+						      current_rate);
 
 	vnt_fill_ieee80211_rts(tx_context, &buf->data, buf->duration_aa);
 
-	return vnt_rxtx_datahead_g(tx_context, pkt_type, current_rate,
-			&buf->data_head, frame_len, need_ack);
+	return vnt_rxtx_datahead_g(tx_context, &buf->data_head);
 }
 
 static u16 vnt_rxtx_rts_g_fb_head(struct vnt_usb_send_context *tx_context,
-	struct vnt_rts_g_fb *buf, u8 pkt_type, u32 frame_len, int need_ack,
-	u16 current_rate)
+				  struct vnt_rts_g_fb *buf)
 {
 	struct vnt_private *priv = tx_context->priv;
+	u16 current_rate = tx_context->tx_rate;
 	u16 rts_frame_len = 20;
 
-	vnt_get_phy_field(priv, rts_frame_len, priv->byTopCCKBasicRate,
+	vnt_get_phy_field(priv, rts_frame_len, priv->top_cck_basic_rate,
 		PK_TYPE_11B, &buf->b);
-	vnt_get_phy_field(priv, rts_frame_len,
-		priv->byTopOFDMBasicRate, pkt_type, &buf->a);
+	vnt_get_phy_field(priv, rts_frame_len, priv->top_ofdm_basic_rate,
+			  tx_context->pkt_type, &buf->a);
 
+	buf->duration_bb = vnt_get_rtscts_duration_le(tx_context, RTSDUR_BB,
+						      PK_TYPE_11B,
+						      priv->top_cck_basic_rate);
+	buf->duration_aa = vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA,
+						      tx_context->pkt_type,
+						      current_rate);
+	buf->duration_ba = vnt_get_rtscts_duration_le(tx_context, RTSDUR_BA,
+						      tx_context->pkt_type,
+						      current_rate);
 
-	buf->duration_bb = vnt_get_rtscts_duration_le(priv, RTSDUR_BB,
-		frame_len, PK_TYPE_11B, priv->byTopCCKBasicRate, need_ack);
-	buf->duration_aa = vnt_get_rtscts_duration_le(priv, RTSDUR_AA,
-		frame_len, pkt_type, current_rate, need_ack);
-	buf->duration_ba = vnt_get_rtscts_duration_le(priv, RTSDUR_BA,
-		frame_len, pkt_type, current_rate, need_ack);
-
-
-	buf->rts_duration_ba_f0 = vnt_get_rtscts_duration_le(priv, RTSDUR_BA_F0,
-		frame_len, pkt_type, priv->tx_rate_fb0, need_ack);
-	buf->rts_duration_aa_f0 = vnt_get_rtscts_duration_le(priv, RTSDUR_AA_F0,
-		frame_len, pkt_type, priv->tx_rate_fb0, need_ack);
-	buf->rts_duration_ba_f1 = vnt_get_rtscts_duration_le(priv, RTSDUR_BA_F1,
-		frame_len, pkt_type, priv->tx_rate_fb1, need_ack);
-	buf->rts_duration_aa_f1 = vnt_get_rtscts_duration_le(priv, RTSDUR_AA_F1,
-		frame_len, pkt_type, priv->tx_rate_fb1, need_ack);
+	buf->rts_duration_ba_f0 =
+		vnt_get_rtscts_duration_le(tx_context, RTSDUR_BA_F0,
+					   tx_context->pkt_type,
+					   priv->tx_rate_fb0);
+	buf->rts_duration_aa_f0 =
+		vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA_F0,
+					   tx_context->pkt_type,
+					   priv->tx_rate_fb0);
+	buf->rts_duration_ba_f1 =
+		vnt_get_rtscts_duration_le(tx_context, RTSDUR_BA_F1,
+					   tx_context->pkt_type,
+					   priv->tx_rate_fb1);
+	buf->rts_duration_aa_f1 =
+		vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA_F1,
+					   tx_context->pkt_type,
+					   priv->tx_rate_fb1);
 
 	vnt_fill_ieee80211_rts(tx_context, &buf->data, buf->duration_aa);
 
-	return vnt_rxtx_datahead_g_fb(tx_context, pkt_type, current_rate,
-			&buf->data_head, frame_len, need_ack);
+	return vnt_rxtx_datahead_g_fb(tx_context, &buf->data_head);
 }
 
 static u16 vnt_rxtx_rts_ab_head(struct vnt_usb_send_context *tx_context,
-	struct vnt_rts_ab *buf,	u8 pkt_type, u32 frame_len, int need_ack,
-	u16 current_rate)
+				struct vnt_rts_ab *buf)
 {
 	struct vnt_private *priv = tx_context->priv;
+	u16 current_rate = tx_context->tx_rate;
 	u16 rts_frame_len = 20;
 
-	vnt_get_phy_field(priv, rts_frame_len,
-		priv->byTopOFDMBasicRate, pkt_type, &buf->ab);
+	vnt_get_phy_field(priv, rts_frame_len, priv->top_ofdm_basic_rate,
+			  tx_context->pkt_type, &buf->ab);
 
-	buf->duration = vnt_get_rtscts_duration_le(priv, RTSDUR_AA, frame_len,
-		pkt_type, current_rate, need_ack);
+	buf->duration = vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA,
+						   tx_context->pkt_type,
+						   current_rate);
 
 	vnt_fill_ieee80211_rts(tx_context, &buf->data, buf->duration);
 
-	return vnt_rxtx_datahead_ab(tx_context, pkt_type, current_rate,
-			&buf->data_head, frame_len, need_ack);
+	return vnt_rxtx_datahead_ab(tx_context, &buf->data_head);
 }
 
 static u16 vnt_rxtx_rts_a_fb_head(struct vnt_usb_send_context *tx_context,
-	struct vnt_rts_a_fb *buf, u8 pkt_type, u32 frame_len, int need_ack,
-	u16 current_rate)
+				  struct vnt_rts_a_fb *buf)
 {
 	struct vnt_private *priv = tx_context->priv;
+	u16 current_rate = tx_context->tx_rate;
 	u16 rts_frame_len = 20;
 
 	vnt_get_phy_field(priv, rts_frame_len,
-		priv->byTopOFDMBasicRate, pkt_type, &buf->a);
+		priv->top_ofdm_basic_rate, tx_context->pkt_type, &buf->a);
 
-	buf->duration = vnt_get_rtscts_duration_le(priv, RTSDUR_AA, frame_len,
-		pkt_type, current_rate, need_ack);
+	buf->duration = vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA,
+						   tx_context->pkt_type,
+						   current_rate);
 
-	buf->rts_duration_f0 = vnt_get_rtscts_duration_le(priv, RTSDUR_AA_F0,
-		frame_len, pkt_type, priv->tx_rate_fb0, need_ack);
+	buf->rts_duration_f0 =
+		vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA_F0,
+					   tx_context->pkt_type,
+					   priv->tx_rate_fb0);
 
-	buf->rts_duration_f1 = vnt_get_rtscts_duration_le(priv, RTSDUR_AA_F1,
-		frame_len, pkt_type, priv->tx_rate_fb1, need_ack);
+	buf->rts_duration_f1 =
+		vnt_get_rtscts_duration_le(tx_context, RTSDUR_AA_F1,
+					   tx_context->pkt_type,
+					   priv->tx_rate_fb1);
 
 	vnt_fill_ieee80211_rts(tx_context, &buf->data, buf->duration);
 
-	return vnt_rxtx_datahead_a_fb(tx_context, pkt_type, current_rate,
-			&buf->data_head, frame_len, need_ack);
+	return vnt_rxtx_datahead_a_fb(tx_context, &buf->data_head);
 }
 
 static u16 vnt_fill_cts_head(struct vnt_usb_send_context *tx_context,
-	u8 pkt_type, union vnt_tx_data_head *head, u32 frame_len,
-	int need_ack, u16 current_rate)
+	union vnt_tx_data_head *head)
 {
 	struct vnt_private *priv = tx_context->priv;
 	u32 cts_frame_len = 14;
+	u16 current_rate = tx_context->tx_rate;
 
 	if (!head)
 		return 0;
@@ -500,176 +532,175 @@
 		struct vnt_cts_fb *buf = &head->cts_g_fb;
 		/* Get SignalField,ServiceField,Length */
 		vnt_get_phy_field(priv, cts_frame_len,
-			priv->byTopCCKBasicRate, PK_TYPE_11B, &buf->b);
-		buf->duration_ba = vnt_get_rtscts_duration_le(priv, CTSDUR_BA,
-			frame_len, pkt_type,
-			current_rate, need_ack);
+			priv->top_cck_basic_rate, PK_TYPE_11B, &buf->b);
+		buf->duration_ba =
+			vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA,
+						   tx_context->pkt_type,
+						   current_rate);
 		/* Get CTSDuration_ba_f0 */
-		buf->cts_duration_ba_f0 = vnt_get_rtscts_duration_le(priv,
-			CTSDUR_BA_F0, frame_len, pkt_type,
-			priv->tx_rate_fb0, need_ack);
+		buf->cts_duration_ba_f0 =
+			vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA_F0,
+						   tx_context->pkt_type,
+						   priv->tx_rate_fb0);
 		/* Get CTSDuration_ba_f1 */
-		buf->cts_duration_ba_f1 = vnt_get_rtscts_duration_le(priv,
-			CTSDUR_BA_F1, frame_len, pkt_type,
-			priv->tx_rate_fb1, need_ack);
+		buf->cts_duration_ba_f1 =
+			vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA_F1,
+						   tx_context->pkt_type,
+						   priv->tx_rate_fb1);
 		/* Get CTS Frame body */
 		buf->data.duration = buf->duration_ba;
 		buf->data.frame_control =
 			cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
 
-		memcpy(buf->data.ra, priv->abyCurrentNetAddr, ETH_ALEN);
+		memcpy(buf->data.ra, priv->current_net_addr, ETH_ALEN);
 
-		return vnt_rxtx_datahead_g_fb(tx_context, pkt_type,
-				current_rate, &buf->data_head, frame_len,
-				need_ack);
+		return vnt_rxtx_datahead_g_fb(tx_context, &buf->data_head);
 	} else {
 		struct vnt_cts *buf = &head->cts_g;
 		/* Get SignalField,ServiceField,Length */
 		vnt_get_phy_field(priv, cts_frame_len,
-			priv->byTopCCKBasicRate, PK_TYPE_11B, &buf->b);
+			priv->top_cck_basic_rate, PK_TYPE_11B, &buf->b);
 		/* Get CTSDuration_ba */
-		buf->duration_ba = vnt_get_rtscts_duration_le(priv,
-			CTSDUR_BA, frame_len, pkt_type,
-			current_rate, need_ack);
+		buf->duration_ba =
+			vnt_get_rtscts_duration_le(tx_context, CTSDUR_BA,
+						   tx_context->pkt_type,
+						   current_rate);
 		/*Get CTS Frame body*/
 		buf->data.duration = buf->duration_ba;
 		buf->data.frame_control =
 			cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS);
 
-		memcpy(buf->data.ra, priv->abyCurrentNetAddr, ETH_ALEN);
+		memcpy(buf->data.ra, priv->current_net_addr, ETH_ALEN);
 
-		return vnt_rxtx_datahead_g(tx_context, pkt_type, current_rate,
-				&buf->data_head, frame_len, need_ack);
+		return vnt_rxtx_datahead_g(tx_context, &buf->data_head);
         }
 
 	return 0;
 }
 
 static u16 vnt_rxtx_rts(struct vnt_usb_send_context *tx_context,
-	union vnt_tx_head *tx_head, u8 pkt_type, u32 frame_size,
-	int need_ack, u16 current_rate, bool need_mic)
+			union vnt_tx_head *tx_head, bool need_mic)
 {
 	struct vnt_private *priv = tx_context->priv;
 	struct vnt_rrv_time_rts *buf = &tx_head->tx_rts.rts;
 	union vnt_tx_data_head *head = &tx_head->tx_rts.tx.head;
+	u32 frame_len = tx_context->frame_len;
+	u16 current_rate = tx_context->tx_rate;
+	u8 need_ack = tx_context->need_ack;
 
 	buf->rts_rrv_time_aa = vnt_get_rtscts_rsvtime_le(priv, 2,
-				pkt_type, frame_size, current_rate);
+			tx_context->pkt_type, frame_len, current_rate);
 	buf->rts_rrv_time_ba = vnt_get_rtscts_rsvtime_le(priv, 1,
-				pkt_type, frame_size, current_rate);
+			tx_context->pkt_type, frame_len, current_rate);
 	buf->rts_rrv_time_bb = vnt_get_rtscts_rsvtime_le(priv, 0,
-				pkt_type, frame_size, current_rate);
+			tx_context->pkt_type, frame_len, current_rate);
 
-	buf->rrv_time_a = vnt_rxtx_rsvtime_le16(priv, pkt_type, frame_size,
-							current_rate, need_ack);
-	buf->rrv_time_b = vnt_rxtx_rsvtime_le16(priv, PK_TYPE_11B, frame_size,
-					priv->byTopCCKBasicRate, need_ack);
+	buf->rrv_time_a = vnt_rxtx_rsvtime_le16(priv, tx_context->pkt_type,
+						frame_len, current_rate,
+						need_ack);
+	buf->rrv_time_b = vnt_rxtx_rsvtime_le16(priv, PK_TYPE_11B, frame_len,
+					priv->top_cck_basic_rate, need_ack);
 
 	if (need_mic)
 		head = &tx_head->tx_rts.tx.mic.head;
 
 	if (tx_context->fb_option)
-		return vnt_rxtx_rts_g_fb_head(tx_context, &head->rts_g_fb,
-			pkt_type, frame_size, need_ack, current_rate);
+		return vnt_rxtx_rts_g_fb_head(tx_context, &head->rts_g_fb);
 
-	return vnt_rxtx_rts_g_head(tx_context, &head->rts_g,
-				pkt_type, frame_size, need_ack, current_rate);
+	return vnt_rxtx_rts_g_head(tx_context, &head->rts_g);
 }
 
 static u16 vnt_rxtx_cts(struct vnt_usb_send_context *tx_context,
-	union vnt_tx_head *tx_head, u8 pkt_type, u32 frame_size,
-	int need_ack, u16 current_rate, bool need_mic)
+			union vnt_tx_head *tx_head, bool need_mic)
 {
 	struct vnt_private *priv = tx_context->priv;
 	struct vnt_rrv_time_cts *buf = &tx_head->tx_cts.cts;
 	union vnt_tx_data_head *head = &tx_head->tx_cts.tx.head;
+	u32 frame_len = tx_context->frame_len;
+	u16 current_rate = tx_context->tx_rate;
+	u8 need_ack = tx_context->need_ack;
 
-
-	buf->rrv_time_a = vnt_rxtx_rsvtime_le16(priv, pkt_type,
-					frame_size, current_rate, need_ack);
+	buf->rrv_time_a = vnt_rxtx_rsvtime_le16(priv, tx_context->pkt_type,
+					frame_len, current_rate, need_ack);
 	buf->rrv_time_b = vnt_rxtx_rsvtime_le16(priv, PK_TYPE_11B,
-				frame_size, priv->byTopCCKBasicRate, need_ack);
+				frame_len, priv->top_cck_basic_rate, need_ack);
 
 	buf->cts_rrv_time_ba = vnt_get_rtscts_rsvtime_le(priv, 3,
-			pkt_type, frame_size, current_rate);
+			tx_context->pkt_type, frame_len, current_rate);
 
 	if (need_mic)
 		head = &tx_head->tx_cts.tx.mic.head;
 
 	/* Fill CTS */
-	return vnt_fill_cts_head(tx_context, pkt_type, head, frame_size,
-							need_ack, current_rate);
+	return vnt_fill_cts_head(tx_context, head);
 }
 
 static u16 vnt_rxtx_ab(struct vnt_usb_send_context *tx_context,
-	union vnt_tx_head *tx_head, u8 pkt_type, u32 frame_size,
-	int need_ack, u16 current_rate, bool need_rts, bool need_mic)
+		       union vnt_tx_head *tx_head, bool need_rts, bool need_mic)
 {
 	struct vnt_private *priv = tx_context->priv;
 	struct vnt_rrv_time_ab *buf = &tx_head->tx_ab.ab;
 	union vnt_tx_data_head *head = &tx_head->tx_ab.tx.head;
+	u32 frame_len = tx_context->frame_len;
+	u16 current_rate = tx_context->tx_rate;
+	u8 need_ack = tx_context->need_ack;
 
-	buf->rrv_time = vnt_rxtx_rsvtime_le16(priv, pkt_type,
-			frame_size, current_rate, need_ack);
+	buf->rrv_time = vnt_rxtx_rsvtime_le16(priv, tx_context->pkt_type,
+			frame_len, current_rate, need_ack);
 
 	if (need_mic)
 		head = &tx_head->tx_ab.tx.mic.head;
 
 	if (need_rts) {
-		if (pkt_type == PK_TYPE_11B)
+		if (tx_context->pkt_type == PK_TYPE_11B)
 			buf->rts_rrv_time = vnt_get_rtscts_rsvtime_le(priv, 0,
-				pkt_type, frame_size, current_rate);
+				tx_context->pkt_type, frame_len, current_rate);
 		else /* PK_TYPE_11A */
 			buf->rts_rrv_time = vnt_get_rtscts_rsvtime_le(priv, 2,
-				pkt_type, frame_size, current_rate);
+				tx_context->pkt_type, frame_len, current_rate);
 
-		if (tx_context->fb_option && pkt_type == PK_TYPE_11A)
+		if (tx_context->fb_option &&
+		    tx_context->pkt_type == PK_TYPE_11A)
 			return vnt_rxtx_rts_a_fb_head(tx_context,
-					&head->rts_a_fb, pkt_type, frame_size,
-					need_ack, current_rate);
+						      &head->rts_a_fb);
 
-		return vnt_rxtx_rts_ab_head(tx_context, &head->rts_ab,
-				pkt_type, frame_size, need_ack, current_rate);
+		return vnt_rxtx_rts_ab_head(tx_context, &head->rts_ab);
 	}
 
-	if (pkt_type == PK_TYPE_11A)
-		return vnt_rxtx_datahead_a_fb(tx_context, pkt_type,
-			current_rate, &head->data_head_a_fb,
-				frame_size, need_ack);
+	if (tx_context->pkt_type == PK_TYPE_11A)
+		return vnt_rxtx_datahead_a_fb(tx_context,
+					      &head->data_head_a_fb);
 
-	return vnt_rxtx_datahead_ab(tx_context, pkt_type, current_rate,
-				&head->data_head_ab, frame_size, need_ack);
+	return vnt_rxtx_datahead_ab(tx_context, &head->data_head_ab);
 }
 
 static u16 vnt_generate_tx_parameter(struct vnt_usb_send_context *tx_context,
-	u8 pkt_type, u16 current_rate, struct vnt_tx_buffer *tx_buffer,
-	struct vnt_mic_hdr **mic_hdr, u32 need_mic, u32 frame_size,
-	int need_ack, bool need_rts)
+	struct vnt_tx_buffer *tx_buffer,
+	struct vnt_mic_hdr **mic_hdr, u32 need_mic,
+	bool need_rts)
 {
 
-	if (pkt_type == PK_TYPE_11GB || pkt_type == PK_TYPE_11GA) {
+	if (tx_context->pkt_type == PK_TYPE_11GB ||
+	    tx_context->pkt_type == PK_TYPE_11GA) {
 		if (need_rts) {
 			if (need_mic)
 				*mic_hdr = &tx_buffer->
 						tx_head.tx_rts.tx.mic.hdr;
 
 			return vnt_rxtx_rts(tx_context, &tx_buffer->tx_head,
-					pkt_type, frame_size, need_ack,
-						current_rate, need_mic);
+					    need_mic);
 		}
 
 		if (need_mic)
 			*mic_hdr = &tx_buffer->tx_head.tx_cts.tx.mic.hdr;
 
-		return vnt_rxtx_cts(tx_context, &tx_buffer->tx_head, pkt_type,
-				frame_size, need_ack, current_rate, need_mic);
+		return vnt_rxtx_cts(tx_context, &tx_buffer->tx_head, need_mic);
 	}
 
 	if (need_mic)
 		*mic_hdr = &tx_buffer->tx_head.tx_ab.tx.mic.hdr;
 
-	return vnt_rxtx_ab(tx_context, &tx_buffer->tx_head, pkt_type,
-		frame_size, need_ack, current_rate, need_rts, need_mic);
+	return vnt_rxtx_ab(tx_context, &tx_buffer->tx_head, need_rts, need_mic);
 }
 
 static void vnt_fill_txkey(struct vnt_usb_send_context *tx_context,
@@ -753,10 +784,9 @@
 	struct vnt_tx_fifo_head *tx_buffer_head;
 	struct vnt_usb_send_context *tx_context;
 	unsigned long flags;
-	u32 frame_size = 0;
 	u16 tx_bytes, tx_header_size, tx_body_size, current_rate, duration_id;
 	u8 pkt_type, fb_option = AUTO_FB_NONE;
-	bool need_rts = false, need_ack = false, is_pspoll = false;
+	bool need_rts = false, is_pspoll = false;
 	bool need_mic = false;
 
 	hdr = (struct ieee80211_hdr *)(skb->data);
@@ -764,14 +794,14 @@
 	rate = ieee80211_get_tx_rate(priv->hw, info);
 
 	current_rate = rate->hw_value;
-	if (priv->wCurrentRate != current_rate &&
+	if (priv->current_rate != current_rate &&
 			!(priv->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) {
-		priv->wCurrentRate = current_rate;
+		priv->current_rate = current_rate;
 		vnt_schedule_command(priv, WLAN_CMD_SETPOWER);
 	}
 
 	if (current_rate > RATE_11M)
-		pkt_type = priv->byPacketType;
+		pkt_type = priv->packet_type;
 	else
 		pkt_type = PK_TYPE_11B;
 
@@ -785,6 +815,10 @@
 	}
 
 	tx_context->skb = skb;
+	tx_context->pkt_type = pkt_type;
+	tx_context->need_ack = false;
+	tx_context->frame_len = skb->len + 4;
+	tx_context->tx_rate = current_rate;
 
 	spin_unlock_irqrestore(&priv->lock, flags);
 
@@ -792,22 +826,20 @@
 	tx_buffer_head = &tx_buffer->fifo_head;
 	tx_body_size = skb->len;
 
-	frame_size = tx_body_size + 4;
-
 	/*Set fifo controls */
 	if (pkt_type == PK_TYPE_11A)
-		tx_buffer_head->wFIFOCtl = 0;
+		tx_buffer_head->fifo_ctl = 0;
 	else if (pkt_type == PK_TYPE_11B)
-		tx_buffer_head->wFIFOCtl = FIFOCTL_11B;
+		tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11B);
 	else if (pkt_type == PK_TYPE_11GB)
-		tx_buffer_head->wFIFOCtl = FIFOCTL_11GB;
+		tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11GB);
 	else if (pkt_type == PK_TYPE_11GA)
-		tx_buffer_head->wFIFOCtl = FIFOCTL_11GA;
+		tx_buffer_head->fifo_ctl = cpu_to_le16(FIFOCTL_11GA);
 
 	if (!ieee80211_is_data(hdr->frame_control)) {
-		tx_buffer_head->wFIFOCtl |= (FIFOCTL_GENINT |
-			FIFOCTL_ISDMA0);
-		tx_buffer_head->wFIFOCtl |= FIFOCTL_TMOEN;
+		tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_GENINT |
+							FIFOCTL_ISDMA0);
+		tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_TMOEN);
 
 		tx_buffer_head->time_stamp =
 			cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us);
@@ -817,25 +849,25 @@
 	}
 
 	if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) {
-		tx_buffer_head->wFIFOCtl |= FIFOCTL_NEEDACK;
-		need_ack = true;
+		tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_NEEDACK);
+		tx_context->need_ack = true;
 	}
 
 	if (ieee80211_has_retry(hdr->frame_control))
-		tx_buffer_head->wFIFOCtl |= FIFOCTL_LRETRY;
+		tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LRETRY);
 
 	if (tx_rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
-		priv->byPreambleType = PREAMBLE_SHORT;
+		priv->preamble_type = PREAMBLE_SHORT;
 	else
-		priv->byPreambleType = PREAMBLE_LONG;
+		priv->preamble_type = PREAMBLE_LONG;
 
 	if (tx_rate->flags & IEEE80211_TX_RC_USE_RTS_CTS) {
 		need_rts = true;
-		tx_buffer_head->wFIFOCtl |= FIFOCTL_RTS;
+		tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_RTS);
 	}
 
 	if (ieee80211_has_a4(hdr->frame_control))
-		tx_buffer_head->wFIFOCtl |= FIFOCTL_LHEAD;
+		tx_buffer_head->fifo_ctl |= cpu_to_le16(FIFOCTL_LHEAD);
 
 	if (info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER)
 		is_pspoll = true;
@@ -859,15 +891,16 @@
 		default:
 			break;
 		}
-		frame_size += tx_key->icv_len;
+		tx_context->frame_len += tx_key->icv_len;
 	}
 
 	tx_buffer_head->current_rate = cpu_to_le16(current_rate);
 
 	/* legacy rates TODO use ieee80211_tx_rate */
 	if (current_rate >= RATE_18M && ieee80211_is_data(hdr->frame_control)) {
-		if (priv->byAutoFBCtrl == AUTO_FB_0) {
-			tx_buffer_head->wFIFOCtl |= FIFOCTL_AUTO_FB_0;
+		if (priv->auto_fb_ctrl == AUTO_FB_0) {
+			tx_buffer_head->fifo_ctl |=
+						cpu_to_le16(FIFOCTL_AUTO_FB_0);
 
 			priv->tx_rate_fb0 =
 				vnt_fb_opt0[FB_RATE0][current_rate - RATE_18M];
@@ -875,8 +908,9 @@
 				vnt_fb_opt0[FB_RATE1][current_rate - RATE_18M];
 
 			fb_option = AUTO_FB_0;
-		} else if (priv->byAutoFBCtrl == AUTO_FB_1) {
-			tx_buffer_head->wFIFOCtl |= FIFOCTL_AUTO_FB_1;
+		} else if (priv->auto_fb_ctrl == AUTO_FB_1) {
+			tx_buffer_head->fifo_ctl |=
+						cpu_to_le16(FIFOCTL_AUTO_FB_1);
 
 			priv->tx_rate_fb0 =
 				vnt_fb_opt1[FB_RATE0][current_rate - RATE_18M];
@@ -889,9 +923,8 @@
 
 	tx_context->fb_option = fb_option;
 
-	duration_id = vnt_generate_tx_parameter(tx_context, pkt_type,
-			current_rate, tx_buffer, &mic_hdr, need_mic, frame_size,
-						need_ack, need_rts);
+	duration_id = vnt_generate_tx_parameter(tx_context, tx_buffer, &mic_hdr,
+						need_mic, need_rts);
 
 	tx_header_size = tx_context->tx_hdr_size;
 	if (!tx_header_size) {
@@ -914,12 +947,12 @@
 				tx_key, skb, tx_body_size, mic_hdr);
 	}
 
-	priv->wSeqCounter = (le16_to_cpu(hdr->seq_ctrl) &
+	priv->seq_counter = (le16_to_cpu(hdr->seq_ctrl) &
 						IEEE80211_SCTL_SEQ) >> 4;
 
 	tx_buffer->tx_byte_count = cpu_to_le16(tx_bytes);
-	tx_buffer->byPKTNO = tx_context->pkt_no;
-	tx_buffer->byType = 0x00;
+	tx_buffer->pkt_no = tx_context->pkt_no;
+	tx_buffer->type = 0x00;
 
 	tx_bytes += 4;
 
@@ -928,7 +961,7 @@
 
 	spin_lock_irqsave(&priv->lock, flags);
 
-	if (PIPEnsSendBulkOut(priv, tx_context) != STATUS_PENDING) {
+	if (vnt_tx_context(priv, tx_context) != STATUS_PENDING) {
 		spin_unlock_irqrestore(&priv->lock, flags);
 		return -EIO;
 	}
@@ -966,7 +999,7 @@
 	beacon_buffer = (struct vnt_beacon_buffer *)&context->data[0];
 	short_head = &beacon_buffer->short_head;
 
-	if (priv->byBBType == BB_TYPE_11A) {
+	if (priv->bb_type == BB_TYPE_11A) {
 		current_rate = RATE_6M;
 
 		/* Get SignalField,ServiceField,Length */
@@ -980,7 +1013,7 @@
 				vnt_time_stamp_off(priv, current_rate);
 	} else {
 		current_rate = RATE_1M;
-		short_head->fifo_ctl |= FIFOCTL_11B;
+		short_head->fifo_ctl |= cpu_to_le16(FIFOCTL_11B);
 
 		/* Get SignalField,ServiceField,Length */
 		vnt_get_phy_field(priv, frame_size, current_rate,
@@ -1004,25 +1037,25 @@
 	if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) {
 		struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)mgmt_hdr;
 		hdr->duration_id = 0;
-		hdr->seq_ctrl = cpu_to_le16(priv->wSeqCounter << 4);
+		hdr->seq_ctrl = cpu_to_le16(priv->seq_counter << 4);
 	}
 
-	priv->wSeqCounter++;
-	if (priv->wSeqCounter > 0x0fff)
-		priv->wSeqCounter = 0;
+	priv->seq_counter++;
+	if (priv->seq_counter > 0x0fff)
+		priv->seq_counter = 0;
 
 	count = sizeof(struct vnt_tx_short_buf_head) + skb->len;
 
 	beacon_buffer->tx_byte_count = cpu_to_le16(count);
-	beacon_buffer->byPKTNO = context->pkt_no;
-	beacon_buffer->byType = 0x01;
+	beacon_buffer->pkt_no = context->pkt_no;
+	beacon_buffer->type = 0x01;
 
 	context->type = CONTEXT_BEACON_PACKET;
 	context->buf_len = count + 4; /* USB header */
 
 	spin_lock_irqsave(&priv->lock, flags);
 
-	if (PIPEnsSendBulkOut(priv, context) != STATUS_PENDING)
+	if (vnt_tx_context(priv, context) != STATUS_PENDING)
 		ieee80211_free_txskb(priv->hw, context->skb);
 
 	spin_unlock_irqrestore(&priv->lock, flags);
diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h
index 1cfa5ae..90b34ab2 100644
--- a/drivers/staging/vt6656/rxtx.h
+++ b/drivers/staging/vt6656/rxtx.h
@@ -222,22 +222,22 @@
 
 struct vnt_tx_fifo_head {
 	u8 tx_key[WLAN_KEY_LEN_CCMP];
-	u16 wFIFOCtl;
+	__le16 fifo_ctl;
 	__le16 time_stamp;
 	__le16 frag_ctl;
 	__le16 current_rate;
 } __packed;
 
 struct vnt_tx_buffer {
-	u8 byType;
-	u8 byPKTNO;
+	u8 type;
+	u8 pkt_no;
 	__le16 tx_byte_count;
 	struct vnt_tx_fifo_head fifo_head;
 	union vnt_tx_head tx_head;
 } __packed;
 
 struct vnt_tx_short_buf_head {
-	u16 fifo_ctl;
+	__le16 fifo_ctl;
 	u16 time_stamp;
 	struct vnt_phy_field ab;
 	__le16 duration;
@@ -245,8 +245,8 @@
 } __packed;
 
 struct vnt_beacon_buffer {
-	u8 byType;
-	u8 byPKTNO;
+	u8 type;
+	u8 pkt_no;
 	__le16 tx_byte_count;
 	struct vnt_tx_short_buf_head short_head;
 	struct ieee80211_mgmt mgmt_hdr;
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index dd031bb..7b050ba 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -45,21 +45,7 @@
 #include "device.h"
 #include "usbpipe.h"
 
-//endpoint def
-//endpoint 0: control
-//endpoint 1: interrupt
-//endpoint 2: read bulk
-//endpoint 3: write bulk
-
-#define USB_CTL_WAIT   500 //ms
-
-#ifndef URB_ASYNC_UNLINK
-#define URB_ASYNC_UNLINK    0
-#endif
-
-static void s_nsInterruptUsbIoCompleteRead(struct urb *urb);
-static void s_nsBulkInUsbIoCompleteRead(struct urb *urb);
-static void s_nsBulkOutIoCompleteWrite(struct urb *urb);
+#define USB_CTL_WAIT	500 /* ms */
 
 int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
 		u16 index, u16 length, u8 *buffer)
@@ -117,63 +103,7 @@
 			reg_off, reg, sizeof(u8), data);
 }
 
-/*
- * Description:
- *      Allocates an usb interrupt in irp and calls USBD.
- *
- * Parameters:
- *  In:
- *      pDevice     - Pointer to the adapter
- *  Out:
- *      none
- *
- * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
- *
- */
-
-int PIPEnsInterruptRead(struct vnt_private *priv)
-{
-	int status = STATUS_FAILURE;
-
-	if (priv->int_buf.in_use == true)
-		return STATUS_FAILURE;
-
-	priv->int_buf.in_use = true;
-
-	usb_fill_int_urb(priv->pInterruptURB,
-		priv->usb,
-		usb_rcvintpipe(priv->usb, 1),
-		priv->int_buf.data_buf,
-		MAX_INTERRUPT_SIZE,
-		s_nsInterruptUsbIoCompleteRead,
-		priv,
-		priv->int_interval);
-
-	status = usb_submit_urb(priv->pInterruptURB, GFP_ATOMIC);
-	if (status) {
-		dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", status);
-		priv->int_buf.in_use = false;
-	}
-
-	return status;
-}
-
-/*
- * Description:
- *      Complete function of usb interrupt in irp.
- *
- * Parameters:
- *  In:
- *      pDevice     - Pointer to the adapter
- *
- *  Out:
- *      none
- *
- * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
- *
- */
-
-static void s_nsInterruptUsbIoCompleteRead(struct urb *urb)
+static void vnt_start_interrupt_urb_complete(struct urb *urb)
 {
 	struct vnt_private *priv = urb->context;
 	int status;
@@ -198,10 +128,10 @@
 
 		dev_dbg(&priv->usb->dev, "%s status = %d\n", __func__, status);
 	} else {
-		INTnsProcessData(priv);
+		vnt_int_process_data(priv);
 	}
 
-	status = usb_submit_urb(priv->pInterruptURB, GFP_ATOMIC);
+	status = usb_submit_urb(priv->interrupt_urb, GFP_ATOMIC);
 	if (status) {
 		dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", status);
 	} else {
@@ -211,70 +141,37 @@
 	return;
 }
 
-/*
- * Description:
- *      Allocates an usb BulkIn  irp and calls USBD.
- *
- * Parameters:
- *  In:
- *      pDevice     - Pointer to the adapter
- *  Out:
- *      none
- *
- * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
- *
- */
-
-int PIPEnsBulkInUsbRead(struct vnt_private *priv, struct vnt_rcb *rcb)
+int vnt_start_interrupt_urb(struct vnt_private *priv)
 {
-	int status = 0;
-	struct urb *urb;
+	int status = STATUS_FAILURE;
 
-	urb = rcb->pUrb;
-	if (rcb->skb == NULL) {
-		dev_dbg(&priv->usb->dev, "rcb->skb is null\n");
-		return status;
+	if (priv->int_buf.in_use == true)
+		return STATUS_FAILURE;
+
+	priv->int_buf.in_use = true;
+
+	usb_fill_int_urb(priv->interrupt_urb,
+			 priv->usb,
+			 usb_rcvintpipe(priv->usb, 1),
+			 priv->int_buf.data_buf,
+			 MAX_INTERRUPT_SIZE,
+			 vnt_start_interrupt_urb_complete,
+			 priv,
+			 priv->int_interval);
+
+	status = usb_submit_urb(priv->interrupt_urb, GFP_ATOMIC);
+	if (status) {
+		dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", status);
+		priv->int_buf.in_use = false;
 	}
 
-	usb_fill_bulk_urb(urb,
-		priv->usb,
-		usb_rcvbulkpipe(priv->usb, 2),
-		skb_put(rcb->skb, skb_tailroom(rcb->skb)),
-		MAX_TOTAL_SIZE_WITH_ALL_HEADERS,
-		s_nsBulkInUsbIoCompleteRead,
-		rcb);
-
-	status = usb_submit_urb(urb, GFP_ATOMIC);
-	if (status != 0) {
-		dev_dbg(&priv->usb->dev, "Submit Rx URB failed %d\n", status);
-		return STATUS_FAILURE ;
-	}
-
-	rcb->Ref = 1;
-	rcb->bBoolInUse = true;
-
 	return status;
 }
 
-/*
- * Description:
- *      Complete function of usb BulkIn irp.
- *
- * Parameters:
- *  In:
- *      pDevice     - Pointer to the adapter
- *
- *  Out:
- *      none
- *
- * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
- *
- */
-
-static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
+static void vnt_submit_rx_urb_complete(struct urb *urb)
 {
 	struct vnt_rcb *rcb = urb->context;
-	struct vnt_private *priv = rcb->pDevice;
+	struct vnt_private *priv = rcb->priv;
 	unsigned long flags;
 
 	switch (urb->status) {
@@ -299,7 +196,7 @@
 				dev_dbg(&priv->usb->dev,
 					"Failed to re-alloc rx skb\n");
 
-				rcb->bBoolInUse = false;
+				rcb->in_use = false;
 				spin_unlock_irqrestore(&priv->lock, flags);
 				return;
 			}
@@ -317,87 +214,43 @@
 	if (usb_submit_urb(urb, GFP_ATOMIC)) {
 		dev_dbg(&priv->usb->dev, "Failed to re submit rx skb\n");
 
-		rcb->bBoolInUse = false;
+		rcb->in_use = false;
 	}
 
 	return;
 }
 
-/*
- * Description:
- *      Allocates an usb BulkOut  irp and calls USBD.
- *
- * Parameters:
- *  In:
- *      pDevice     - Pointer to the adapter
- *  Out:
- *      none
- *
- * Return Value: STATUS_INSUFFICIENT_RESOURCES or result of IoCallDriver
- *
- */
-
-int PIPEnsSendBulkOut(struct vnt_private *priv,
-				struct vnt_usb_send_context *context)
+int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb)
 {
-	int status;
+	int status = 0;
 	struct urb *urb;
 
-	if (!(MP_IS_READY(priv) && priv->Flags & fMP_POST_WRITES)) {
-		context->in_use = false;
-		return STATUS_RESOURCES;
+	urb = rcb->urb;
+	if (rcb->skb == NULL) {
+		dev_dbg(&priv->usb->dev, "rcb->skb is null\n");
+		return status;
 	}
 
-	urb = context->urb;
-
 	usb_fill_bulk_urb(urb,
-			priv->usb,
-			usb_sndbulkpipe(priv->usb, 3),
-			context->data,
-			context->buf_len,
-			s_nsBulkOutIoCompleteWrite,
-			context);
+			  priv->usb,
+			  usb_rcvbulkpipe(priv->usb, 2),
+			  skb_put(rcb->skb, skb_tailroom(rcb->skb)),
+			  MAX_TOTAL_SIZE_WITH_ALL_HEADERS,
+			  vnt_submit_rx_urb_complete,
+			  rcb);
 
 	status = usb_submit_urb(urb, GFP_ATOMIC);
 	if (status != 0) {
-		dev_dbg(&priv->usb->dev, "Submit Tx URB failed %d\n", status);
-
-		context->in_use = false;
+		dev_dbg(&priv->usb->dev, "Submit Rx URB failed %d\n", status);
 		return STATUS_FAILURE;
 	}
 
-	return STATUS_PENDING;
+	rcb->in_use = true;
+
+	return status;
 }
 
-/*
- * Description: s_nsBulkOutIoCompleteWrite
- *     1a) Indicate to the protocol the status of the write.
- *     1b) Return ownership of the packet to the protocol.
- *
- *     2)  If any more packets are queue for sending, send another packet
- *         to USBD.
- *         If the attempt to send the packet to the driver fails,
- *         return ownership of the packet to the protocol and
- *         try another packet (until one succeeds).
- *
- * Parameters:
- *  In:
- *      pdoUsbDevObj  - pointer to the USB device object which
- *                      completed the irp
- *      pIrp          - the irp which was completed by the
- *                      device object
- *      pContext      - the context given to IoSetCompletionRoutine
- *                      before calling IoCallDriver on the irp
- *                      The pContext is a pointer to the USB device object.
- *  Out:
- *      none
- *
- * Return Value: STATUS_MORE_PROCESSING_REQUIRED - allows the completion routine
- *               (IofCompleteRequest) to stop working on the irp.
- *
- */
-
-static void s_nsBulkOutIoCompleteWrite(struct urb *urb)
+static void vnt_tx_context_complete(struct urb *urb)
 {
 	struct vnt_usb_send_context *context = urb->context;
 	struct vnt_private *priv = context->priv;
@@ -429,3 +282,35 @@
 
 	return;
 }
+
+int vnt_tx_context(struct vnt_private *priv,
+		   struct vnt_usb_send_context *context)
+{
+	int status;
+	struct urb *urb;
+
+	if (!(MP_IS_READY(priv) && priv->Flags & fMP_POST_WRITES)) {
+		context->in_use = false;
+		return STATUS_RESOURCES;
+	}
+
+	urb = context->urb;
+
+	usb_fill_bulk_urb(urb,
+			  priv->usb,
+			  usb_sndbulkpipe(priv->usb, 3),
+			  context->data,
+			  context->buf_len,
+			  vnt_tx_context_complete,
+			  context);
+
+	status = usb_submit_urb(urb, GFP_ATOMIC);
+	if (status != 0) {
+		dev_dbg(&priv->usb->dev, "Submit Tx URB failed %d\n", status);
+
+		context->in_use = false;
+		return STATUS_FAILURE;
+	}
+
+	return STATUS_PENDING;
+}
diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h
index ea71782..e74aa08 100644
--- a/drivers/staging/vt6656/usbpipe.h
+++ b/drivers/staging/vt6656/usbpipe.h
@@ -38,9 +38,8 @@
 void vnt_control_out_u8(struct vnt_private *, u8, u8, u8);
 void vnt_control_in_u8(struct vnt_private *, u8, u8, u8 *);
 
-int PIPEnsInterruptRead(struct vnt_private *);
-int PIPEnsBulkInUsbRead(struct vnt_private *, struct vnt_rcb *pRCB);
-int PIPEnsSendBulkOut(struct vnt_private *,
-				struct vnt_usb_send_context *pContext);
+int vnt_start_interrupt_urb(struct vnt_private *);
+int vnt_submit_rx_urb(struct vnt_private *, struct vnt_rcb *);
+int vnt_tx_context(struct vnt_private *, struct vnt_usb_send_context *);
 
 #endif /* __USBPIPE_H__ */
diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c
index bf41e67..e4a5e2b 100644
--- a/drivers/staging/vt6656/wcmd.c
+++ b/drivers/staging/vt6656/wcmd.c
@@ -83,10 +83,6 @@
 		priv->command_state = WLAN_CMD_CHANGE_ANTENNA_START;
 		break;
 
-	case WLAN_CMD_11H_CHSW:
-		priv->command_state = WLAN_CMD_11H_CHSW_START;
-		break;
-
 	default:
 		break;
 	}
@@ -139,34 +135,30 @@
 
 	case WLAN_CMD_SETPOWER_START:
 
-		vnt_rf_setpower(priv, priv->wCurrentRate,
+		vnt_rf_setpower(priv, priv->current_rate,
 				priv->hw->conf.chandef.chan->hw_value);
 
 		break;
 
 	case WLAN_CMD_CHANGE_ANTENNA_START:
 		dev_dbg(&priv->usb->dev, "Change from Antenna%d to",
-							priv->dwRxAntennaSel);
+							priv->rx_antenna_sel);
 
-		if (priv->dwRxAntennaSel == 0) {
-			priv->dwRxAntennaSel = 1;
-			if (priv->bTxRxAntInv == true)
-				BBvSetAntennaMode(priv, ANT_RXA);
+		if (priv->rx_antenna_sel == 0) {
+			priv->rx_antenna_sel = 1;
+			if (priv->tx_rx_ant_inv == true)
+				vnt_set_antenna_mode(priv, ANT_RXA);
 			else
-				BBvSetAntennaMode(priv, ANT_RXB);
+				vnt_set_antenna_mode(priv, ANT_RXB);
 		} else {
-			priv->dwRxAntennaSel = 0;
-			if (priv->bTxRxAntInv == true)
-				BBvSetAntennaMode(priv, ANT_RXB);
+			priv->rx_antenna_sel = 0;
+			if (priv->tx_rx_ant_inv == true)
+				vnt_set_antenna_mode(priv, ANT_RXB);
 			else
-				BBvSetAntennaMode(priv, ANT_RXA);
+				vnt_set_antenna_mode(priv, ANT_RXA);
 		}
 		break;
 
-	case WLAN_CMD_11H_CHSW_START:
-		vnt_set_channel(priv, priv->hw->conf.chandef.chan->hw_value);
-		break;
-
 	default:
 		break;
 	}
diff --git a/drivers/staging/vt6656/wcmd.h b/drivers/staging/vt6656/wcmd.h
index 0fc2c40..79df04a 100644
--- a/drivers/staging/vt6656/wcmd.h
+++ b/drivers/staging/vt6656/wcmd.h
@@ -40,8 +40,7 @@
 	WLAN_CMD_SETPOWER,
 	WLAN_CMD_TBTT_WAKEUP,
 	WLAN_CMD_BECON_SEND,
-	WLAN_CMD_CHANGE_ANTENNA,
-	WLAN_CMD_11H_CHSW,
+	WLAN_CMD_CHANGE_ANTENNA
 };
 
 #define CMD_Q_SIZE              32
@@ -53,7 +52,6 @@
 	WLAN_CMD_TBTT_WAKEUP_START,
 	WLAN_CMD_BECON_SEND_START,
 	WLAN_CMD_CHANGE_ANTENNA_START,
-	WLAN_CMD_11H_CHSW_START,
 	WLAN_CMD_IDLE
 };
 
diff --git a/drivers/staging/xillybus/README b/drivers/staging/xillybus/README
index d2d848a..81d111b 100644
--- a/drivers/staging/xillybus/README
+++ b/drivers/staging/xillybus/README
@@ -26,7 +26,6 @@
   -- Data granularity
   -- Probing
   -- Buffer allocation
-  -- Memory management
   -- The "nonempty" message (supporting poll)
 
 
@@ -365,28 +364,6 @@
 into that page. It can be shown that all pages requested from the kernel
 (except possibly for the last) are 100% utilized this way.
 
-Memory management
------------------
-
-The tricky part about the buffer allocation procedure described above is
-freeing and unmapping the buffers, in particular if something goes wrong in
-the middle, and the allocations need to be rolled back. The three-stage
-probing procedure makes this even more crucial, since temporary buffers are
-set up and mapped in the first of its two stages.
-
-To keep the code clean from complicated and bug-prone memory release routines,
-there are special routines for allocating memory. For example, instead of
-calling kzalloc, there's
-
-void *xilly_malloc(struct xilly_cleanup *mem, size_t size)
-
-which effectively allocates a zeroed buffer of size "size". Its first
-argument, "mem", is where this allocation is enlisted, so that it's released
-when xillybus_do_cleanup() is called with the same "mem" structure.
-
-Two other functions enlist allocations in this structure: xilly_pagealloc()
-for page allocations and xilly_map_single_*() for DMA mapping.
-
 The "nonempty" message (supporting poll)
 ---------------------------------------
 
diff --git a/drivers/staging/xillybus/xillybus_core.c b/drivers/staging/xillybus/xillybus_core.c
index ab6502c..0214009 100644
--- a/drivers/staging/xillybus/xillybus_core.c
+++ b/drivers/staging/xillybus/xillybus_core.c
@@ -138,7 +138,6 @@
 	 * guaranteed no interrupt will occur, but in theory, the cache
 	 * lines may not be updated. So a memory barrier is issued.
 	 */
-
 	smp_rmb();
 
 	buf = ep->msgbuf_addr;
@@ -159,10 +158,10 @@
 				ep->msg_counter,
 				i/2);
 
-			if (++ep->failed_messages > 10)
+			if (++ep->failed_messages > 10) {
 				dev_err(ep->dev,
 					"Lost sync with interrupt messages. Stopping.\n");
-			else {
+			} else {
 				ep->ephw->hw_sync_sgl_for_device(
 					ep,
 					ep->msgbuf_dma_addr,
@@ -533,8 +532,9 @@
 
 			if (!buffers)
 				goto memfail;
-		} else
+		} else {
 			bytebufsize = bufsize << 2;
+		}
 
 		if (!is_writebuf) {
 			channel->num_rd_buffers = bufnum;
@@ -546,8 +546,7 @@
 			channel->rd_buffers = buffers;
 			rc = xilly_get_dma_buffers(ep, &rd_alloc, buffers,
 						   bufnum, bytebufsize);
-		}
-		else if (channelnum > 0) {
+		} else if (channelnum > 0) {
 			channel->num_wr_buffers = bufnum;
 
 			channel->seekable = seekable;
@@ -610,8 +609,8 @@
 			"IDT device name list overflow. Aborting.\n");
 		idt_handle->chandesc = NULL;
 		return;
-	} else
-		idt_handle->chandesc = scan;
+	}
+	idt_handle->chandesc = scan;
 
 	len = endpoint->idtlen - (3 + ((int) (scan - idt)));
 
@@ -722,6 +721,7 @@
 
 	while (1) { /* Note that we may drop mutex within this loop */
 		int bytes_to_do = count - bytes_done;
+
 		spin_lock_irqsave(&channel->wr_spinlock, flags);
 
 		empty = channel->wr_empty;
@@ -1963,10 +1963,8 @@
 	struct xilly_endpoint *endpoint;
 
 	endpoint = devm_kzalloc(dev, sizeof(*endpoint), GFP_KERNEL);
-	if (!endpoint) {
-		dev_err(dev, "Failed to allocate memory. Aborting.\n");
+	if (!endpoint)
 		return NULL;
-	}
 
 	endpoint->pdev = pdev;
 	endpoint->dev = dev;
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index a99c631..2c516f2 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -306,7 +306,7 @@
 {
 	struct imx_thermal_data *data = platform_get_drvdata(pdev);
 	struct regmap *map;
-	int t1, t2, n1, n2;
+	int t1, n1;
 	int ret;
 	u32 val;
 	u64 temp64;
@@ -333,14 +333,10 @@
 	/*
 	 * Sensor data layout:
 	 *   [31:20] - sensor value @ 25C
-	 *    [19:8] - sensor value of hot
-	 *     [7:0] - hot temperature value
 	 * Use universal formula now and only need sensor value @ 25C
 	 * slope = 0.4297157 - (0.0015976 * 25C fuse)
 	 */
 	n1 = val >> 20;
-	n2 = (val & 0xfff00) >> 8;
-	t2 = val & 0xff;
 	t1 = 25; /* t1 always 25C */
 
 	/*
@@ -366,16 +362,16 @@
 	data->c2 = n1 * data->c1 + 1000 * t1;
 
 	/*
-	 * Set the default passive cooling trip point to 20 °C below the
-	 * maximum die temperature. Can be changed from userspace.
+	 * Set the default passive cooling trip point,
+	 * can be changed from userspace.
 	 */
-	data->temp_passive = 1000 * (t2 - 20);
+	data->temp_passive = IMX_TEMP_PASSIVE;
 
 	/*
-	 * The maximum die temperature is t2, let's give 5 °C cushion
-	 * for noise and possible temperature rise between measurements.
+	 * The maximum die temperature set to 20 C higher than
+	 * IMX_TEMP_PASSIVE.
 	 */
-	data->temp_critical = 1000 * (t2 - 5);
+	data->temp_critical = 1000 * 20 + data->temp_passive;
 
 	return 0;
 }
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index 04b1be7..4b2b999 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -156,8 +156,8 @@
 
 			ret = thermal_zone_bind_cooling_device(thermal,
 						tbp->trip_id, cdev,
-						tbp->min,
-						tbp->max);
+						tbp->max,
+						tbp->min);
 			if (ret)
 				return ret;
 		}
@@ -712,11 +712,12 @@
 	}
 
 	i = 0;
-	for_each_child_of_node(child, gchild)
+	for_each_child_of_node(child, gchild) {
 		ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++],
 						      tz->trips, tz->ntrips);
 		if (ret)
 			goto free_tbps;
+	}
 
 finish:
 	of_node_put(child);
diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
index fdb0719..1967bee 100644
--- a/drivers/thermal/thermal_hwmon.c
+++ b/drivers/thermal/thermal_hwmon.c
@@ -140,6 +140,12 @@
 	return NULL;
 }
 
+static bool thermal_zone_crit_temp_valid(struct thermal_zone_device *tz)
+{
+	unsigned long temp;
+	return tz->ops->get_crit_temp && !tz->ops->get_crit_temp(tz, &temp);
+}
+
 int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
 {
 	struct thermal_hwmon_device *hwmon;
@@ -189,21 +195,18 @@
 	if (result)
 		goto free_temp_mem;
 
-	if (tz->ops->get_crit_temp) {
-		unsigned long temperature;
-		if (!tz->ops->get_crit_temp(tz, &temperature)) {
-			snprintf(temp->temp_crit.name,
-				 sizeof(temp->temp_crit.name),
+	if (thermal_zone_crit_temp_valid(tz)) {
+		snprintf(temp->temp_crit.name,
+				sizeof(temp->temp_crit.name),
 				"temp%d_crit", hwmon->count);
-			temp->temp_crit.attr.attr.name = temp->temp_crit.name;
-			temp->temp_crit.attr.attr.mode = 0444;
-			temp->temp_crit.attr.show = temp_crit_show;
-			sysfs_attr_init(&temp->temp_crit.attr.attr);
-			result = device_create_file(hwmon->device,
-						    &temp->temp_crit.attr);
-			if (result)
-				goto unregister_input;
-		}
+		temp->temp_crit.attr.attr.name = temp->temp_crit.name;
+		temp->temp_crit.attr.attr.mode = 0444;
+		temp->temp_crit.attr.show = temp_crit_show;
+		sysfs_attr_init(&temp->temp_crit.attr.attr);
+		result = device_create_file(hwmon->device,
+					    &temp->temp_crit.attr);
+		if (result)
+			goto unregister_input;
 	}
 
 	mutex_lock(&thermal_hwmon_list_lock);
@@ -250,7 +253,7 @@
 	}
 
 	device_remove_file(hwmon->device, &temp->temp_input.attr);
-	if (tz->ops->get_crit_temp)
+	if (thermal_zone_crit_temp_valid(tz))
 		device_remove_file(hwmon->device, &temp->temp_crit.attr);
 
 	mutex_lock(&thermal_hwmon_list_lock);
diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
index a1271b5..634b6ce 100644
--- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
@@ -1155,7 +1155,7 @@
 	/* register shadow for context save and restore */
 	bgp->regval = devm_kzalloc(&pdev->dev, sizeof(*bgp->regval) *
 				   bgp->conf->sensor_count, GFP_KERNEL);
-	if (!bgp) {
+	if (!bgp->regval) {
 		dev_err(&pdev->dev, "Unable to allocate mem for driver ref\n");
 		return ERR_PTR(-ENOMEM);
 	}
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index c9f5c9d..008c223 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -177,7 +177,7 @@
 		uart->port.icount.tx++;
 		uart->port.x_char = 0;
 		sent = 1;
-	} else if (xmit->tail != xmit->head) {	/* TODO: uart_circ_empty */
+	} else if (!uart_circ_empty(xmit)) {
 		ch = xmit->buf[xmit->tail];
 		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
 		uart->port.icount.tx++;
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index e2f9387..044e86d 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -567,6 +567,9 @@
 	struct imx_port *sport = (struct imx_port *)port;
 	unsigned long temp;
 
+	if (uart_circ_empty(&port->state->xmit))
+		return;
+
 	if (USE_IRDA(sport)) {
 		/* half duplex in IrDA mode; have to disable receive mode */
 		temp = readl(sport->port.membase + UCR4);
diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c
index 1efd4c3..99b7b86 100644
--- a/drivers/tty/serial/ip22zilog.c
+++ b/drivers/tty/serial/ip22zilog.c
@@ -603,6 +603,8 @@
 	} else {
 		struct circ_buf *xmit = &port->state->xmit;
 
+		if (uart_circ_empty(xmit))
+			return;
 		writeb(xmit->buf[xmit->tail], &channel->data);
 		ZSDELAY();
 		ZS_WSYNC(channel);
diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c
index 68f2c53..5702828 100644
--- a/drivers/tty/serial/m32r_sio.c
+++ b/drivers/tty/serial/m32r_sio.c
@@ -266,9 +266,11 @@
 	if (!(up->ier & UART_IER_THRI)) {
 		up->ier |= UART_IER_THRI;
 		serial_out(up, UART_IER, up->ier);
-		serial_out(up, UART_TX, xmit->buf[xmit->tail]);
-		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
-		up->port.icount.tx++;
+		if (!uart_circ_empty(xmit)) {
+			serial_out(up, UART_TX, xmit->buf[xmit->tail]);
+			xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+			up->port.icount.tx++;
+		}
 	}
 	while((serial_in(up, UART_LSR) & UART_EMPTY) != UART_EMPTY);
 #else
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index 8193635..f7ad5b9 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -653,6 +653,8 @@
 	} else {
 		struct circ_buf *xmit = &port->state->xmit;
 
+		if (uart_circ_empty(xmit))
+			goto out;
 		write_zsdata(uap, xmit->buf[xmit->tail]);
 		zssync(uap);
 		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
@@ -661,6 +663,7 @@
 		if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
 			uart_write_wakeup(&uap->port);
 	}
+ out:
 	pmz_debug("pmz: start_tx() done.\n");
 }
 
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c
index 80a58ec..2f57df9 100644
--- a/drivers/tty/serial/sunsab.c
+++ b/drivers/tty/serial/sunsab.c
@@ -427,6 +427,9 @@
 	struct circ_buf *xmit = &up->port.state->xmit;
 	int i;
 
+	if (uart_circ_empty(xmit))
+		return;
+
 	up->interrupt_mask1 &= ~(SAB82532_IMR1_ALLS|SAB82532_IMR1_XPR);
 	writeb(up->interrupt_mask1, &up->regs->w.imr1);
 	
diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index a85db8b..02df394 100644
--- a/drivers/tty/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
@@ -703,6 +703,8 @@
 	} else {
 		struct circ_buf *xmit = &port->state->xmit;
 
+		if (uart_circ_empty(xmit))
+			return;
 		writeb(xmit->buf[xmit->tail], &channel->data);
 		ZSDELAY();
 		ZS_WSYNC(channel);
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 762e4a5..330df5c 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -153,6 +153,7 @@
 	{ USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
 	{ USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
 	{ USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
+	{ USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */
 	{ USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
 	{ USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */
 	{ USB_DEVICE(0x1E29, 0x0501) }, /* Festo CMSP */
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 115662c1..8a3813b 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -720,7 +720,8 @@
 	{ USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) },
-	{ USB_DEVICE(TESTO_VID, TESTO_USB_INTERFACE_PID) },
+	{ USB_DEVICE(TESTO_VID, TESTO_1_PID) },
+	{ USB_DEVICE(TESTO_VID, TESTO_3_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_GAMMA_SCOUT_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) },
 	{ USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) },
@@ -944,6 +945,8 @@
 	{ USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_2_PID) },
 	{ USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_3_PID) },
 	{ USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_4_PID) },
+	/* Infineon Devices */
+	{ USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_PID, 1) },
 	{ }					/* Terminating entry */
 };
 
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 500474c..c4777bc 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -584,6 +584,12 @@
 #define RATOC_PRODUCT_ID_USB60F	0xb020
 
 /*
+ * Infineon Technologies
+ */
+#define INFINEON_VID		0x058b
+#define INFINEON_TRIBOARD_PID	0x0028 /* DAS JTAG TriBoard TC1798 V1.0 */
+
+/*
  * Acton Research Corp.
  */
 #define ACTON_VID		0x0647	/* Vendor ID */
@@ -798,7 +804,8 @@
  * Submitted by Colin Leroy
  */
 #define TESTO_VID			0x128D
-#define TESTO_USB_INTERFACE_PID		0x0001
+#define TESTO_1_PID			0x0001
+#define TESTO_3_PID			0x0003
 
 /*
  * Mobility Electronics products.
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index ac73f49..a968894 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -1487,6 +1487,8 @@
 		.driver_info = (kernel_ulong_t)&net_intf2_blacklist },
 	{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff, 0xff),  /* ZTE MF91 */
 		.driver_info = (kernel_ulong_t)&net_intf2_blacklist },
+	{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1428, 0xff, 0xff, 0xff),  /* Telewell TW-LTE 4G v2 */
+		.driver_info = (kernel_ulong_t)&net_intf2_blacklist },
 	{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1533, 0xff, 0xff, 0xff) },
 	{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1534, 0xff, 0xff, 0xff) },
 	{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1535, 0xff, 0xff, 0xff) },
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index 13b5bfb..9a26242 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -193,7 +193,7 @@
 	depends on USB_STORAGE
 	---help---
 	  Say Y here if you wish to control a ENE SD/MS Card reader.
-	  To use SM card, please build driver/staging/keucr/keucr.ko
+	  Note that this driver does not support SM cards.
 
 	  This option depends on 'SCSI' support being enabled, but you
 	  probably also need 'SCSI device support: SCSI disk support'
diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c
index ef6efb5..56f782b 100644
--- a/drivers/usb/storage/ene_ub6250.c
+++ b/drivers/usb/storage/ene_ub6250.c
@@ -2344,8 +2344,8 @@
 	}
 
 	if (!(misc_reg03 & 0x01)) {
-		pr_info("ums_eneub6250: The driver only supports SD/MS card. "
-			"To use SM card, please build driver/staging/keucr\n");
+		pr_info("ums_eneub6250: This driver only supports SD/MS cards. "
+			"It does not support SM cards.\n");
 	}
 
 	return result;
diff --git a/firmware/Makefile b/firmware/Makefile
index 5747417..0862d34 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -219,6 +219,12 @@
 obj-y				 += $(patsubst %,%.gen.o, $(fw-external-y))
 obj-$(CONFIG_FIRMWARE_IN_KERNEL) += $(patsubst %,%.gen.o, $(fw-shipped-y))
 
+ifeq ($(KBUILD_SRC),)
+# Makefile.build only creates subdirectories for O= builds, but external
+# firmware might live outside the kernel source tree
+_dummy := $(foreach d,$(addprefix $(obj)/,$(dir $(fw-external-y))), $(shell [ -d $(d) ] || mkdir -p $(d)))
+endif
+
 # Remove .S files and binaries created from ihex
 # (during 'make clean' .config isn't included so they're all in $(fw-shipped-))
 targets := $(fw-shipped-) $(patsubst $(obj)/%,%, \
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 3f5c188..0b7e28e 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -966,10 +966,10 @@
 			continue;
 		}
 
-		if (ei->i_es_lru_nr == 0 || ei == locked_ei)
+		if (ei->i_es_lru_nr == 0 || ei == locked_ei ||
+		    !write_trylock(&ei->i_es_lock))
 			continue;
 
-		write_lock(&ei->i_es_lock);
 		shrunk = __es_try_to_reclaim_extents(ei, nr_to_scan);
 		if (ei->i_es_lru_nr == 0)
 			list_del_init(&ei->i_es_lru);
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index a87455d..5b87fc3 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -338,7 +338,7 @@
 			fatal = err;
 	} else {
 		ext4_error(sb, "bit already cleared for inode %lu", ino);
-		if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {
+		if (gdp && !EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {
 			int count;
 			count = ext4_free_inodes_count(sb, gdp);
 			percpu_counter_sub(&sbi->s_freeinodes_counter,
@@ -874,6 +874,13 @@
 		goto out;
 	}
 
+	BUFFER_TRACE(group_desc_bh, "get_write_access");
+	err = ext4_journal_get_write_access(handle, group_desc_bh);
+	if (err) {
+		ext4_std_error(sb, err);
+		goto out;
+	}
+
 	/* We may have to initialize the block bitmap if it isn't already */
 	if (ext4_has_group_desc_csum(sb) &&
 	    gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
@@ -910,13 +917,6 @@
 		}
 	}
 
-	BUFFER_TRACE(group_desc_bh, "get_write_access");
-	err = ext4_journal_get_write_access(handle, group_desc_bh);
-	if (err) {
-		ext4_std_error(sb, err);
-		goto out;
-	}
-
 	/* Update the relevant bg descriptor fields */
 	if (ext4_has_group_desc_csum(sb)) {
 		int free;
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 7f72f50..2dcb936 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -752,8 +752,8 @@
 
 	if (free != grp->bb_free) {
 		ext4_grp_locked_error(sb, group, 0, 0,
-				      "%u clusters in bitmap, %u in gd; "
-				      "block bitmap corrupt.",
+				      "block bitmap and bg descriptor "
+				      "inconsistent: %u vs %u free clusters",
 				      free, grp->bb_free);
 		/*
 		 * If we intend to continue, we consider group descriptor
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b9b9aab..6df7bc6 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1525,8 +1525,6 @@
 			arg = JBD2_DEFAULT_MAX_COMMIT_AGE;
 		sbi->s_commit_interval = HZ * arg;
 	} else if (token == Opt_max_batch_time) {
-		if (arg == 0)
-			arg = EXT4_DEF_MAX_BATCH_TIME;
 		sbi->s_max_batch_time = arg;
 	} else if (token == Opt_min_batch_time) {
 		sbi->s_min_batch_time = arg;
@@ -2809,10 +2807,11 @@
 	es = sbi->s_es;
 
 	if (es->s_error_count)
-		ext4_msg(sb, KERN_NOTICE, "error count: %u",
+		/* fsck newer than v1.41.13 is needed to clean this condition. */
+		ext4_msg(sb, KERN_NOTICE, "error count since last fsck: %u",
 			 le32_to_cpu(es->s_error_count));
 	if (es->s_first_error_time) {
-		printk(KERN_NOTICE "EXT4-fs (%s): initial error at %u: %.*s:%d",
+		printk(KERN_NOTICE "EXT4-fs (%s): initial error at time %u: %.*s:%d",
 		       sb->s_id, le32_to_cpu(es->s_first_error_time),
 		       (int) sizeof(es->s_first_error_func),
 		       es->s_first_error_func,
@@ -2826,7 +2825,7 @@
 		printk("\n");
 	}
 	if (es->s_last_error_time) {
-		printk(KERN_NOTICE "EXT4-fs (%s): last error at %u: %.*s:%d",
+		printk(KERN_NOTICE "EXT4-fs (%s): last error at time %u: %.*s:%d",
 		       sb->s_id, le32_to_cpu(es->s_last_error_time),
 		       (int) sizeof(es->s_last_error_func),
 		       es->s_last_error_func,
@@ -3880,38 +3879,19 @@
 			goto failed_mount2;
 		}
 	}
-
-	/*
-	 * set up enough so that it can read an inode,
-	 * and create new inode for buddy allocator
-	 */
-	sbi->s_gdb_count = db_count;
-	if (!test_opt(sb, NOLOAD) &&
-	    EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL))
-		sb->s_op = &ext4_sops;
-	else
-		sb->s_op = &ext4_nojournal_sops;
-
-	ext4_ext_init(sb);
-	err = ext4_mb_init(sb);
-	if (err) {
-		ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)",
-			 err);
-		goto failed_mount2;
-	}
-
 	if (!ext4_check_descriptors(sb, &first_not_zeroed)) {
 		ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
-		goto failed_mount2a;
+		goto failed_mount2;
 	}
 	if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG))
 		if (!ext4_fill_flex_info(sb)) {
 			ext4_msg(sb, KERN_ERR,
 			       "unable to initialize "
 			       "flex_bg meta info!");
-			goto failed_mount2a;
+			goto failed_mount2;
 		}
 
+	sbi->s_gdb_count = db_count;
 	get_random_bytes(&sbi->s_next_generation, sizeof(u32));
 	spin_lock_init(&sbi->s_next_gen_lock);
 
@@ -3946,6 +3926,14 @@
 	sbi->s_stripe = ext4_get_stripe_size(sbi);
 	sbi->s_extent_max_zeroout_kb = 32;
 
+	/*
+	 * set up enough so that it can read an inode
+	 */
+	if (!test_opt(sb, NOLOAD) &&
+	    EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL))
+		sb->s_op = &ext4_sops;
+	else
+		sb->s_op = &ext4_nojournal_sops;
 	sb->s_export_op = &ext4_export_ops;
 	sb->s_xattr = ext4_xattr_handlers;
 #ifdef CONFIG_QUOTA
@@ -4135,13 +4123,21 @@
 	if (err) {
 		ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for "
 			 "reserved pool", ext4_calculate_resv_clusters(sb));
-		goto failed_mount5;
+		goto failed_mount4a;
 	}
 
 	err = ext4_setup_system_zone(sb);
 	if (err) {
 		ext4_msg(sb, KERN_ERR, "failed to initialize system "
 			 "zone (%d)", err);
+		goto failed_mount4a;
+	}
+
+	ext4_ext_init(sb);
+	err = ext4_mb_init(sb);
+	if (err) {
+		ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)",
+			 err);
 		goto failed_mount5;
 	}
 
@@ -4218,8 +4214,11 @@
 failed_mount7:
 	ext4_unregister_li_request(sb);
 failed_mount6:
-	ext4_release_system_zone(sb);
+	ext4_mb_release(sb);
 failed_mount5:
+	ext4_ext_release(sb);
+	ext4_release_system_zone(sb);
+failed_mount4a:
 	dput(sb->s_root);
 	sb->s_root = NULL;
 failed_mount4:
@@ -4243,14 +4242,11 @@
 	percpu_counter_destroy(&sbi->s_extent_cache_cnt);
 	if (sbi->s_mmp_tsk)
 		kthread_stop(sbi->s_mmp_tsk);
-failed_mount2a:
-	ext4_mb_release(sb);
 failed_mount2:
 	for (i = 0; i < db_count; i++)
 		brelse(sbi->s_group_desc[i]);
 	ext4_kvfree(sbi->s_group_desc);
 failed_mount:
-	ext4_ext_release(sb);
 	if (sbi->s_chksum_driver)
 		crypto_free_shash(sbi->s_chksum_driver);
 	if (sbi->s_proc) {
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 0924521..f8cf619 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -608,8 +608,8 @@
  *     b. do not use extent cache for better performance
  *     c. give the block addresses to blockdev
  */
-static int get_data_block(struct inode *inode, sector_t iblock,
-			struct buffer_head *bh_result, int create)
+static int __get_data_block(struct inode *inode, sector_t iblock,
+			struct buffer_head *bh_result, int create, bool fiemap)
 {
 	struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
 	unsigned int blkbits = inode->i_sb->s_blocksize_bits;
@@ -637,7 +637,7 @@
 			err = 0;
 		goto unlock_out;
 	}
-	if (dn.data_blkaddr == NEW_ADDR)
+	if (dn.data_blkaddr == NEW_ADDR && !fiemap)
 		goto put_out;
 
 	if (dn.data_blkaddr != NULL_ADDR) {
@@ -671,7 +671,7 @@
 				err = 0;
 			goto unlock_out;
 		}
-		if (dn.data_blkaddr == NEW_ADDR)
+		if (dn.data_blkaddr == NEW_ADDR && !fiemap)
 			goto put_out;
 
 		end_offset = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode));
@@ -708,10 +708,23 @@
 	return err;
 }
 
+static int get_data_block(struct inode *inode, sector_t iblock,
+			struct buffer_head *bh_result, int create)
+{
+	return __get_data_block(inode, iblock, bh_result, create, false);
+}
+
+static int get_data_block_fiemap(struct inode *inode, sector_t iblock,
+			struct buffer_head *bh_result, int create)
+{
+	return __get_data_block(inode, iblock, bh_result, create, true);
+}
+
 int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		u64 start, u64 len)
 {
-	return generic_block_fiemap(inode, fieinfo, start, len, get_data_block);
+	return generic_block_fiemap(inode, fieinfo,
+				start, len, get_data_block_fiemap);
 }
 
 static int f2fs_read_data_page(struct file *file, struct page *page)
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 966acb0..a4addd7 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -376,11 +376,11 @@
 
 put_error:
 	f2fs_put_page(page, 1);
+error:
 	/* once the failed inode becomes a bad inode, i_mode is S_IFREG */
 	truncate_inode_pages(&inode->i_data, 0);
 	truncate_blocks(inode, 0);
 	remove_dirty_dir_inode(inode);
-error:
 	remove_inode_page(inode);
 	return ERR_PTR(err);
 }
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e51c732..58df97e 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -342,9 +342,6 @@
 	struct dirty_seglist_info *dirty_info;	/* dirty segment information */
 	struct curseg_info *curseg_array;	/* active segment information */
 
-	struct list_head wblist_head;	/* list of under-writeback pages */
-	spinlock_t wblist_lock;		/* lock for checkpoint */
-
 	block_t seg0_blkaddr;		/* block address of 0'th segment */
 	block_t main_blkaddr;		/* start block address of main area */
 	block_t ssa_blkaddr;		/* start block address of SSA area */
@@ -644,7 +641,8 @@
  */
 static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
 {
-	WARN_ON((nid >= NM_I(sbi)->max_nid));
+	if (unlikely(nid < F2FS_ROOT_INO(sbi)))
+		return -EINVAL;
 	if (unlikely(nid >= NM_I(sbi)->max_nid))
 		return -EINVAL;
 	return 0;
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index c58e330..7d8b962 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -659,16 +659,19 @@
 	off_start = offset & (PAGE_CACHE_SIZE - 1);
 	off_end = (offset + len) & (PAGE_CACHE_SIZE - 1);
 
+	f2fs_lock_op(sbi);
+
 	for (index = pg_start; index <= pg_end; index++) {
 		struct dnode_of_data dn;
 
-		f2fs_lock_op(sbi);
+		if (index == pg_end && !off_end)
+			goto noalloc;
+
 		set_new_dnode(&dn, inode, NULL, NULL, 0);
 		ret = f2fs_reserve_block(&dn, index);
-		f2fs_unlock_op(sbi);
 		if (ret)
 			break;
-
+noalloc:
 		if (pg_start == pg_end)
 			new_size = offset + len;
 		else if (index == pg_start && off_start)
@@ -683,8 +686,9 @@
 		i_size_read(inode) < new_size) {
 		i_size_write(inode, new_size);
 		mark_inode_dirty(inode);
-		f2fs_write_inode(inode, NULL);
+		update_inode_page(inode);
 	}
+	f2fs_unlock_op(sbi);
 
 	return ret;
 }
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index adc622c..2cf6962 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -78,6 +78,7 @@
 	if (check_nid_range(sbi, inode->i_ino)) {
 		f2fs_msg(inode->i_sb, KERN_ERR, "bad inode number: %lu",
 			 (unsigned long) inode->i_ino);
+		WARN_ON(1);
 		return -EINVAL;
 	}
 
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 9138c32..a6bdddc 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -417,9 +417,6 @@
 		}
 
 		f2fs_set_link(new_dir, new_entry, new_page, old_inode);
-		down_write(&F2FS_I(old_inode)->i_sem);
-		F2FS_I(old_inode)->i_pino = new_dir->i_ino;
-		up_write(&F2FS_I(old_inode)->i_sem);
 
 		new_inode->i_ctime = CURRENT_TIME;
 		down_write(&F2FS_I(new_inode)->i_sem);
@@ -448,6 +445,10 @@
 		}
 	}
 
+	down_write(&F2FS_I(old_inode)->i_sem);
+	file_lost_pino(old_inode);
+	up_write(&F2FS_I(old_inode)->i_sem);
+
 	old_inode->i_ctime = CURRENT_TIME;
 	mark_inode_dirty(old_inode);
 
@@ -457,9 +458,6 @@
 		if (old_dir != new_dir) {
 			f2fs_set_link(old_inode, old_dir_entry,
 						old_dir_page, new_dir);
-			down_write(&F2FS_I(old_inode)->i_sem);
-			F2FS_I(old_inode)->i_pino = new_dir->i_ino;
-			up_write(&F2FS_I(old_inode)->i_sem);
 			update_inode_page(old_inode);
 		} else {
 			kunmap(old_dir_page);
@@ -474,7 +472,8 @@
 	return 0;
 
 put_out_dir:
-	f2fs_put_page(new_page, 1);
+	kunmap(new_page);
+	f2fs_put_page(new_page, 0);
 out_dir:
 	if (old_dir_entry) {
 		kunmap(old_dir_page);
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 9dfb9a0..4b697cc 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -42,6 +42,8 @@
 		mem_size = (nm_i->nat_cnt * sizeof(struct nat_entry)) >> 12;
 		res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 2);
 	} else if (type == DIRTY_DENTS) {
+		if (sbi->sb->s_bdi->dirty_exceeded)
+			return false;
 		mem_size = get_pages(sbi, F2FS_DIRTY_DENTS);
 		res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 1);
 	}
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index f25f0e0..d04613d 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -272,14 +272,15 @@
 		return -ENOMEM;
 	spin_lock_init(&fcc->issue_lock);
 	init_waitqueue_head(&fcc->flush_wait_queue);
+	sbi->sm_info->cmd_control_info = fcc;
 	fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi,
 				"f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev));
 	if (IS_ERR(fcc->f2fs_issue_flush)) {
 		err = PTR_ERR(fcc->f2fs_issue_flush);
 		kfree(fcc);
+		sbi->sm_info->cmd_control_info = NULL;
 		return err;
 	}
-	sbi->sm_info->cmd_control_info = fcc;
 
 	return err;
 }
@@ -1885,8 +1886,6 @@
 
 	/* init sm info */
 	sbi->sm_info = sm_info;
-	INIT_LIST_HEAD(&sm_info->wblist_head);
-	spin_lock_init(&sm_info->wblist_lock);
 	sm_info->seg0_blkaddr = le32_to_cpu(raw_super->segment0_blkaddr);
 	sm_info->main_blkaddr = le32_to_cpu(raw_super->main_blkaddr);
 	sm_info->segment_count = le32_to_cpu(raw_super->segment_count);
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index b2b1863..8f96d93 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -689,9 +689,7 @@
 	struct f2fs_sb_info *sbi = F2FS_SB(sb);
 	struct inode *inode;
 
-	if (unlikely(ino < F2FS_ROOT_INO(sbi)))
-		return ERR_PTR(-ESTALE);
-	if (unlikely(ino >= NM_I(sbi)->max_nid))
+	if (check_nid_range(sbi, ino))
 		return ERR_PTR(-ESTALE);
 
 	/*
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 38cfcf5..6f0f590 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1588,9 +1588,12 @@
 	 * to perform a synchronous write.  We do this to detect the
 	 * case where a single process is doing a stream of sync
 	 * writes.  No point in waiting for joiners in that case.
+	 *
+	 * Setting max_batch_time to 0 disables this completely.
 	 */
 	pid = current->pid;
-	if (handle->h_sync && journal->j_last_sync_writer != pid) {
+	if (handle->h_sync && journal->j_last_sync_writer != pid &&
+	    journal->j_max_batch_time) {
 		u64 commit_time, trans_time;
 
 		journal->j_last_sync_writer = pid;
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index d171b98..f973ae9 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -211,6 +211,36 @@
 	kernfs_put(root_kn);
 }
 
+/**
+ * kernfs_pin_sb: try to pin the superblock associated with a kernfs_root
+ * @kernfs_root: the kernfs_root in question
+ * @ns: the namespace tag
+ *
+ * Pin the superblock so the superblock won't be destroyed in subsequent
+ * operations.  This can be used to block ->kill_sb() which may be useful
+ * for kernfs users which dynamically manage superblocks.
+ *
+ * Returns NULL if there's no superblock associated to this kernfs_root, or
+ * -EINVAL if the superblock is being freed.
+ */
+struct super_block *kernfs_pin_sb(struct kernfs_root *root, const void *ns)
+{
+	struct kernfs_super_info *info;
+	struct super_block *sb = NULL;
+
+	mutex_lock(&kernfs_mutex);
+	list_for_each_entry(info, &root->supers, node) {
+		if (info->ns == ns) {
+			sb = info->sb;
+			if (!atomic_inc_not_zero(&info->sb->s_active))
+				sb = ERR_PTR(-EINVAL);
+			break;
+		}
+	}
+	mutex_unlock(&kernfs_mutex);
+	return sb;
+}
+
 void __init kernfs_init(void)
 {
 	kernfs_node_cache = kmem_cache_create("kernfs_node_cache",
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 2fc7abe..b56b1cc0 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2641,7 +2641,7 @@
 {
 	__be32 *p;
 
-	p = xdr_reserve_space(xdr, 6);
+	p = xdr_reserve_space(xdr, 20);
 	if (!p)
 		return NULL;
 	*p++ = htonl(2);
diff --git a/include/acpi/video.h b/include/acpi/video.h
index ea4c7bb..843ef1a 100644
--- a/include/acpi/video.h
+++ b/include/acpi/video.h
@@ -22,6 +22,7 @@
 extern void acpi_video_unregister_backlight(void);
 extern int acpi_video_get_edid(struct acpi_device *device, int type,
 			       int device_id, void **edid);
+extern bool acpi_video_verify_backlight_support(void);
 #else
 static inline int acpi_video_register(void) { return 0; }
 static inline void acpi_video_unregister(void) { return; }
@@ -31,6 +32,7 @@
 {
 	return -ENODEV;
 }
+static inline bool acpi_video_verify_backlight_support(void) { return false; }
 #endif
 
 #endif
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 471ba48..c1c0b0cf 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -693,7 +693,7 @@
 	. = ALIGN(PAGE_SIZE);						\
 	*(.data..percpu..page_aligned)					\
 	. = ALIGN(cacheline);						\
-	*(.data..percpu..readmostly)					\
+	*(.data..percpu..read_mostly)					\
 	. = ALIGN(cacheline);						\
 	*(.data..percpu)						\
 	*(.data..percpu..shared_aligned)				\
diff --git a/include/dt-bindings/clock/exynos5420.h b/include/dt-bindings/clock/exynos5420.h
index 97dcb89..21d51ae 100644
--- a/include/dt-bindings/clock/exynos5420.h
+++ b/include/dt-bindings/clock/exynos5420.h
@@ -63,7 +63,6 @@
 #define CLK_SCLK_MPHY_IXTAL24	161
 
 /* gate clocks */
-#define CLK_ACLK66_PERIC	256
 #define CLK_UART0		257
 #define CLK_UART1		258
 #define CLK_UART2		259
@@ -203,6 +202,8 @@
 #define CLK_MOUT_G3D		641
 #define CLK_MOUT_VPLL		642
 #define CLK_MOUT_MAUDIO0	643
+#define CLK_MOUT_USER_ACLK333	644
+#define CLK_MOUT_SW_ACLK333	645
 
 /* divider clocks */
 #define CLK_DOUT_PIXEL		768
diff --git a/include/linux/device.h b/include/linux/device.h
index af424ac..34a24ce 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -605,6 +605,10 @@
 
 /* managed devm_k.alloc/kfree for device drivers */
 extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp);
+extern char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
+			     va_list ap);
+extern char *devm_kasprintf(struct device *dev, gfp_t gfp,
+			    const char *fmt, ...);
 static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
 {
 	return devm_kmalloc(dev, size, gfp | __GFP_ZERO);
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index 145375e..30faf79 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -305,6 +305,7 @@
 			       struct kernfs_root *root, unsigned long magic,
 			       bool *new_sb_created, const void *ns);
 void kernfs_kill_sb(struct super_block *sb);
+struct super_block *kernfs_pin_sb(struct kernfs_root *root, const void *ns);
 
 void kernfs_init(void);
 
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
index a5fc7d0..dec01d6 100644
--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -146,10 +146,10 @@
  * Declaration/definition used for per-CPU variables that must be read mostly.
  */
 #define DECLARE_PER_CPU_READ_MOSTLY(type, name)			\
-	DECLARE_PER_CPU_SECTION(type, name, "..readmostly")
+	DECLARE_PER_CPU_SECTION(type, name, "..read_mostly")
 
 #define DEFINE_PER_CPU_READ_MOSTLY(type, name)				\
-	DEFINE_PER_CPU_SECTION(type, name, "..readmostly")
+	DEFINE_PER_CPU_SECTION(type, name, "..read_mostly")
 
 /*
  * Intermodule exports for per-CPU variables.  sparse forgets about
diff --git a/include/linux/platform_data/dsp-omap.h b/include/linux/platform_data/dsp-omap.h
deleted file mode 100644
index 5927709..0000000
--- a/include/linux/platform_data/dsp-omap.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __OMAP_DSP_H__
-#define __OMAP_DSP_H__
-
-#include <linux/types.h>
-
-struct omap_dsp_platform_data {
-	void (*dsp_set_min_opp) (u8 opp_id);
-	u8 (*dsp_get_opp) (void);
-	void (*cpu_set_freq) (unsigned long f);
-	unsigned long (*cpu_get_freq) (void);
-	unsigned long mpu_speed[6];
-
-	/* functions to write and read PRCM registers */
-	void (*dsp_prm_write)(u32, s16 , u16);
-	u32 (*dsp_prm_read)(s16 , u16);
-	u32 (*dsp_prm_rmw_bits)(u32, u32, s16, s16);
-	void (*dsp_cm_write)(u32, s16 , u16);
-	u32 (*dsp_cm_read)(s16 , u16);
-	u32 (*dsp_cm_rmw_bits)(u32, u32, s16, s16);
-
-	void (*set_bootaddr)(u32);
-	void (*set_bootmode)(u8);
-
-	phys_addr_t phys_mempool_base;
-	phys_addr_t phys_mempool_size;
-};
-
-#if defined(CONFIG_TIDSPBRIDGE) || defined(CONFIG_TIDSPBRIDGE_MODULE)
-extern void omap_dsp_reserve_sdram_memblock(void);
-#else
-static inline void omap_dsp_reserve_sdram_memblock(void) { }
-#endif
-
-#endif
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 7868fc3..70776ae 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1648,10 +1648,13 @@
 			 int flags, const char *unused_dev_name,
 			 void *data)
 {
+	struct super_block *pinned_sb = NULL;
+	struct cgroup_subsys *ss;
 	struct cgroup_root *root;
 	struct cgroup_sb_opts opts;
 	struct dentry *dentry;
 	int ret;
+	int i;
 	bool new_sb;
 
 	/*
@@ -1677,6 +1680,27 @@
 		goto out_unlock;
 	}
 
+	/*
+	 * Destruction of cgroup root is asynchronous, so subsystems may
+	 * still be dying after the previous unmount.  Let's drain the
+	 * dying subsystems.  We just need to ensure that the ones
+	 * unmounted previously finish dying and don't care about new ones
+	 * starting.  Testing ref liveliness is good enough.
+	 */
+	for_each_subsys(ss, i) {
+		if (!(opts.subsys_mask & (1 << i)) ||
+		    ss->root == &cgrp_dfl_root)
+			continue;
+
+		if (!percpu_ref_tryget_live(&ss->root->cgrp.self.refcnt)) {
+			mutex_unlock(&cgroup_mutex);
+			msleep(10);
+			ret = restart_syscall();
+			goto out_free;
+		}
+		cgroup_put(&ss->root->cgrp);
+	}
+
 	for_each_root(root) {
 		bool name_match = false;
 
@@ -1717,15 +1741,23 @@
 		}
 
 		/*
-		 * A root's lifetime is governed by its root cgroup.
-		 * tryget_live failure indicate that the root is being
-		 * destroyed.  Wait for destruction to complete so that the
-		 * subsystems are free.  We can use wait_queue for the wait
-		 * but this path is super cold.  Let's just sleep for a bit
-		 * and retry.
+		 * We want to reuse @root whose lifetime is governed by its
+		 * ->cgrp.  Let's check whether @root is alive and keep it
+		 * that way.  As cgroup_kill_sb() can happen anytime, we
+		 * want to block it by pinning the sb so that @root doesn't
+		 * get killed before mount is complete.
+		 *
+		 * With the sb pinned, tryget_live can reliably indicate
+		 * whether @root can be reused.  If it's being killed,
+		 * drain it.  We can use wait_queue for the wait but this
+		 * path is super cold.  Let's just sleep a bit and retry.
 		 */
-		if (!percpu_ref_tryget_live(&root->cgrp.self.refcnt)) {
+		pinned_sb = kernfs_pin_sb(root->kf_root, NULL);
+		if (IS_ERR(pinned_sb) ||
+		    !percpu_ref_tryget_live(&root->cgrp.self.refcnt)) {
 			mutex_unlock(&cgroup_mutex);
+			if (!IS_ERR_OR_NULL(pinned_sb))
+				deactivate_super(pinned_sb);
 			msleep(10);
 			ret = restart_syscall();
 			goto out_free;
@@ -1770,6 +1802,16 @@
 				CGROUP_SUPER_MAGIC, &new_sb);
 	if (IS_ERR(dentry) || !new_sb)
 		cgroup_put(&root->cgrp);
+
+	/*
+	 * If @pinned_sb, we're reusing an existing root and holding an
+	 * extra ref on its sb.  Mount is complete.  Put the extra ref.
+	 */
+	if (pinned_sb) {
+		WARN_ON(new_sb);
+		deactivate_super(pinned_sb);
+	}
+
 	return dentry;
 }
 
@@ -3328,7 +3370,7 @@
 
 	rcu_read_lock();
 	css_for_each_child(child, css) {
-		if (css->flags & CSS_ONLINE) {
+		if (child->flags & CSS_ONLINE) {
 			ret = true;
 			break;
 		}
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index f6b33c6..116a416 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1181,7 +1181,13 @@
 
 int current_cpuset_is_being_rebound(void)
 {
-	return task_cs(current) == cpuset_being_rebound;
+	int ret;
+
+	rcu_read_lock();
+	ret = task_cs(current) == cpuset_being_rebound;
+	rcu_read_unlock();
+
+	return ret;
 }
 
 static int update_relax_domain_level(struct cpuset *cs, s64 val)
@@ -1617,7 +1623,17 @@
 	 * resources, wait for the previously scheduled operations before
 	 * proceeding, so that we don't end up keep removing tasks added
 	 * after execution capability is restored.
+	 *
+	 * cpuset_hotplug_work calls back into cgroup core via
+	 * cgroup_transfer_tasks() and waiting for it from a cgroupfs
+	 * operation like this one can lead to a deadlock through kernfs
+	 * active_ref protection.  Let's break the protection.  Losing the
+	 * protection is okay as we check whether @cs is online after
+	 * grabbing cpuset_mutex anyway.  This only happens on the legacy
+	 * hierarchies.
 	 */
+	css_get(&cs->css);
+	kernfs_break_active_protection(of->kn);
 	flush_work(&cpuset_hotplug_work);
 
 	mutex_lock(&cpuset_mutex);
@@ -1645,6 +1661,8 @@
 	free_trial_cpuset(trialcs);
 out_unlock:
 	mutex_unlock(&cpuset_mutex);
+	kernfs_unbreak_active_protection(of->kn);
+	css_put(&cs->css);
 	return retval ?: nbytes;
 }
 
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 6203d29..35974ac 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3284,6 +3284,7 @@
 		}
 	}
 
+	dev_set_uevent_suppress(&wq_dev->dev, false);
 	kobject_uevent(&wq_dev->dev.kobj, KOBJ_ADD);
 	return 0;
 }
@@ -4879,7 +4880,7 @@
 	BUG_ON(!tbl);
 
 	for_each_node(node)
-		BUG_ON(!alloc_cpumask_var_node(&tbl[node], GFP_KERNEL,
+		BUG_ON(!zalloc_cpumask_var_node(&tbl[node], GFP_KERNEL,
 				node_online(node) ? node : NUMA_NO_NODE));
 
 	for_each_possible_cpu(cpu) {
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index eb58de1..8f5330d 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -2139,7 +2139,6 @@
 	} else
 		*new = *old;
 
-	rcu_read_lock();
 	if (current_cpuset_is_being_rebound()) {
 		nodemask_t mems = cpuset_mems_allowed(current);
 		if (new->flags & MPOL_F_REBINDING)
@@ -2147,7 +2146,6 @@
 		else
 			mpol_rebind_policy(new, &mems, MPOL_REBIND_ONCE);
 	}
-	rcu_read_unlock();
 	atomic_set(&new->refcnt, 1);
 	return new;
 }
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index da058da..16a07cf 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2073,6 +2073,7 @@
 sub dump_function($$) {
     my $prototype = shift;
     my $file = shift;
+    my $noret = 0;
 
     $prototype =~ s/^static +//;
     $prototype =~ s/^extern +//;
@@ -2086,7 +2087,7 @@
     $prototype =~ s/__init_or_module +//;
     $prototype =~ s/__must_check +//;
     $prototype =~ s/__weak +//;
-    $prototype =~ s/^#\s*define\s+//; #ak added
+    my $define = $prototype =~ s/^#\s*define\s+//; #ak added
     $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//;
 
     # Yes, this truly is vile.  We are looking for:
@@ -2105,7 +2106,15 @@
     # - atomic_set (macro)
     # - pci_match_device, __copy_to_user (long return type)
 
-    if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
+    if ($define && $prototype =~ m/^()([a-zA-Z0-9_~:]+)\s+/) {
+        # This is an object-like macro, it has no return type and no parameter
+        # list.
+        # Function-like macros are not allowed to have spaces between
+        # declaration_name and opening parenthesis (notice the \s+).
+        $return_type = $1;
+        $declaration_name = $2;
+        $noret = 1;
+    } elsif ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
 	$prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
 	$prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
 	$prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ ||
@@ -2140,7 +2149,7 @@
         # of warnings goes sufficiently down, the check is only performed in
         # verbose mode.
         # TODO: always perform the check.
-        if ($verbose) {
+        if ($verbose && !$noret) {
                 check_return_section($file, $declaration_name, $return_type);
         }
 
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c
index 0849b7b..0db94f49 100644
--- a/sound/soc/fsl/imx-pcm-dma.c
+++ b/sound/soc/fsl/imx-pcm-dma.c
@@ -59,7 +59,6 @@
 {
 	return devm_snd_dmaengine_pcm_register(&pdev->dev,
 		&imx_dmaengine_pcm_config,
-		SND_DMAENGINE_PCM_FLAG_NO_RESIDUE |
 		SND_DMAENGINE_PCM_FLAG_COMPAT);
 }
 EXPORT_SYMBOL_GPL(imx_pcm_dma_init);
diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile
index 4473211..e775adc 100644
--- a/tools/thermal/tmon/Makefile
+++ b/tools/thermal/tmon/Makefile
@@ -21,7 +21,7 @@
 OBJS +=
 
 tmon: $(OBJS) Makefile tmon.h
-	$(CC) ${CFLAGS} $(LDFLAGS) $(OBJS)  -o $(TARGET) -lm -lpanel -lncursesw  -lpthread
+	$(CC) ${CFLAGS} $(LDFLAGS) $(OBJS)  -o $(TARGET) -lm -lpanel -lncursesw -ltinfo -lpthread
 
 valgrind: tmon
 	 sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET)  1> /dev/null
diff --git a/tools/thermal/tmon/tmon.c b/tools/thermal/tmon/tmon.c
index b30f531..09b7c32 100644
--- a/tools/thermal/tmon/tmon.c
+++ b/tools/thermal/tmon/tmon.c
@@ -142,6 +142,7 @@
 static void prepare_logging(void)
 {
 	int i;
+	struct stat logstat;
 
 	if (!logging)
 		return;
@@ -152,6 +153,29 @@
 		return;
 	}
 
+	if (lstat(TMON_LOG_FILE, &logstat) < 0) {
+		syslog(LOG_ERR, "Unable to stat log file %s\n", TMON_LOG_FILE);
+		fclose(tmon_log);
+		tmon_log = NULL;
+		return;
+	}
+
+	/* The log file must be a regular file owned by us */
+	if (S_ISLNK(logstat.st_mode)) {
+		syslog(LOG_ERR, "Log file is a symlink.  Will not log\n");
+		fclose(tmon_log);
+		tmon_log = NULL;
+		return;
+	}
+
+	if (logstat.st_uid != getuid()) {
+		syslog(LOG_ERR, "We don't own the log file.  Not logging\n");
+		fclose(tmon_log);
+		tmon_log = NULL;
+		return;
+	}
+
+
 	fprintf(tmon_log, "#----------- THERMAL SYSTEM CONFIG -------------\n");
 	for (i = 0; i < ptdata.nr_tz_sensor; i++) {
 		char binding_str[33]; /* size of long + 1 */
@@ -331,7 +355,7 @@
 	disable_tui();
 
 	/* change the file mode mask */
-	umask(0);
+	umask(S_IWGRP | S_IWOTH);
 
 	/* new SID for the daemon process */
 	sid = setsid();